home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / MSJV46.ZIP / IPC.ZIP / MSGQ.C < prev    next >
C/C++ Source or Header  |  1989-07-31  |  1KB  |  58 lines

  1. /* msgq.c RHS 7/15/89
  2.  *
  3.  * message queue routines
  4.  */
  5. #define    INCL_DOS
  6. #include<os2.h>
  7.  
  8. #include"errexit.h"
  9. #include"msgq.h"
  10.  
  11. void MsgQCreate(HQUEUE *qhandle, char *qname)
  12.     {
  13.     USHORT retval;
  14.  
  15.     if(retval = DosCreateQueue(qhandle,QUE_FIFO,qname))
  16.         error_exit(retval,"DosCreateQueue");
  17.     }
  18.  
  19. void MsgQOpen(HQUEUE *qhandle, char *qname)
  20.     {
  21.     PID    qowner;
  22.     USHORT retval;
  23.  
  24.     if(retval = DosOpenQueue(&qowner,qhandle,qname))
  25.         error_exit(retval,qname);
  26.     }
  27.  
  28. void MsgQSend(HQUEUE qhandle, USHORT event)
  29.     {
  30.     USHORT retval;
  31.  
  32.     if(retval = DosWriteQueue(qhandle,event,0,(PBYTE)NULL,0))
  33.         error_exit(retval,"DosWriteQueue");
  34.     }
  35.  
  36. void MsgQGet(HQUEUE qhandle, USHORT *event)
  37.     {
  38.     QUEUERESULT     qresult;
  39.     USHORT             ellength;
  40.     PVOID            dummy;
  41.     BYTE               priority;
  42.     USHORT retval;
  43.  
  44.     if(retval = DosReadQueue(qhandle,&qresult,&ellength,
  45.             (PVOID FAR *)&dummy,0x0000,DCWW_WAIT,&priority,0L))
  46.         error_exit(retval,"DosReadQueue");
  47.     *event = qresult.usEventCode;
  48.     }
  49.  
  50. void MsgQClose(HQUEUE qhandle)
  51.     {
  52.     DosCloseQueue(qhandle);
  53.     }
  54.  
  55.     /******************************************************/
  56.  
  57.  
  58.