home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff290.lzh / IPC / IPC_Lib_Sources / UtilIPC.c < prev   
C/C++ Source or Header  |  1989-12-11  |  2KB  |  59 lines

  1. /********************************************************************
  2.  *                                                                  *
  3.  *                 IPC Utilities module 89:4:17                     *
  4.  *                                                                  *
  5.  *                  Shared Library version                          *
  6.  *                                                                  *
  7.  ********************************************************************/
  8.  
  9. #include "IPCStruct.h"
  10.  
  11. /*
  12.  *  -- MakeIPCId
  13.  *
  14.  *  turns a 4-character string into a 32-bit ID value.
  15.  *  -- Note: a string of less than 4 characters will be LEFT
  16.  *     justified (high bits)
  17.  *  -- more than 4 will be truncated.
  18.  */
  19.  
  20. ULONG __asm MakeIPCId(register __a0 char *name)
  21. {
  22.     ULONG temp=0;
  23.     int i;
  24.     for (i=4; i--; ) {
  25.         temp = (temp<<8) | *name;
  26.         if (*name) name++;
  27.     }
  28.     return temp;
  29. }
  30.  
  31.  
  32. /*
  33.  *  -- FindIPCItem
  34.  *
  35.  *  returns a pointer to the first item it finds in 'msg' that matches 'id',
  36.  *  starting at 'item'; if 'item' is NULL, it starts at the first item.
  37.  *  (Remember, if you are resuming a search from the last item found for
  38.  *  another of the same name, to INCREMENT 'item' from the previous value:
  39.  *  otherwise it will find the same item again!)
  40.  */
  41.  
  42. struct IPCItem * __asm FindIPCItem(
  43.                 register __a0 struct IPCMessage * msg,
  44.                 register __d0 ULONG id,
  45.                 register __a1 struct IPCItem * item)
  46. {
  47.     int i;
  48.     if (item)
  49.         i = msg->ipc_ItemCount -(item - msg->ipc_Items);
  50.     else {
  51.         i = msg->ipc_ItemCount;
  52.         item = msg->ipc_Items;
  53.     }
  54.     for ( ;i--; item++ )
  55.         if (item->ii_Id == id) return item;
  56.     return NULL;
  57. }
  58.  
  59.