--- os2sdk/demos/examples/queues/cust.c 2018/08/09 12:25:13 1.1.1.1 +++ os2sdk/demos/examples/queues/cust.c 2018/08/09 12:26:13 1.1.1.2 @@ -3,7 +3,7 @@ * This program emulates the gatekeeper placing requests in a queue that * will be read by the headwaiter (see server.c). The following functions * are illustrated here: - * DOSOPENQUEUE, DOSWRITEQUEUE, DOSCLOSEQUEUE + * DosOpenQueue, DosWriteQueue, DosCloseQueue * * This example first allocates a shared segment. It loops trying to open * the queue until successful. It loops (for an arbitrary number of times) @@ -17,14 +17,19 @@ * * Compile as: cl -AL -G2 -Lp customer.c * - * Copyright (C) Microsoft Corp. 1986 + * Created by Microsoft Corp. 1986 */ -#include /* 286DOS function declarations */ +#define INCL_DOSMEMMGR +#define INCL_DOSQUEUES +#define INCL_DOSERRORS +#define INCL_DOSPROCESS + +#include /* contains SELECTOROF and + OFFSETOF macros */ +#include /* MS OS/2 function declarations */ #include "defines.h" /* definitions for example programs */ -#include /* contains FP_SEG and FP_OFF macros */ -#define ERROR_QUE_NAME_NOT_EXIST 343 void main (argc, argv, envp) int argc; @@ -35,9 +40,9 @@ void main (argc, argv, envp) unsigned TableID, /* table where a customer group is seated */ Priorty, /* Priority of Table */ *SharedSeg; /* pointer to shared segment */ - unsigned OwnerPID, /* queue owner's PID */ - QueueHandle, /* handle of queue */ - SharedSel; /* selector to shared segment */ + USHORT OwnerPID; /* queue owner's PID */ + HQUEUE QueueHandle; /* handle of queue */ + SEL SharedSel; /* selector to shared segment */ char type; /* type of example selected */ static unsigned CustData[MAXQWRITES] = {0x0600, 0x0501, 0x0802, 0x0003, 0x0104, 0x0305, 0x0406, 0x0707}; @@ -52,30 +57,30 @@ void main (argc, argv, envp) else type = 'd'; /* allocate shared segment */ - DOSALLOCSHRSEG ((unsigned) SEGSIZE, SEGNAME, &SharedSel); + DosAllocShrSeg (SEGSIZE, SEGNAME, &SharedSel); /* open the queue */ - while (DOSOPENQUEUE (&OwnerPID, &QueueHandle, QUEUENAME) == + while (DosOpenQueue (&OwnerPID, &QueueHandle, QUEUENAME) == ERROR_QUE_NAME_NOT_EXIST) /* keep trying to open the queue...*/ - DOSSLEEP(1000L); /* ...until the server creates it */ + DosSleep(1000L); /* ...until the server creates it */ /* compute the address to the shared segment */ - FP_SEG(SharedSeg) = SharedSel; - FP_OFF(SharedSeg) = 0; + SELECTOROF(SharedSeg) = SharedSel; + OFFSETOF(SharedSeg) = 0; /* write some requests to the queue, emulating customer's requests */ TableID = 1; if ((type == 'L') || (type == 'l')){ /* write data in LIFO format */ - DOSWRITEQUEUE (QueueHandle, NOMORE, DATALENGTH, - (char *) &SharedSeg[TableID++], /* any prio OK - not used */ + DosWriteQueue (QueueHandle, NOMORE, DATALENGTH, + (PBYTE) &SharedSeg[TableID++], /* any prio OK - not used */ LIFOPRIO); for (i = 0; i < MAXQWRITES; ++i){ SharedSeg[TableID] = CustData[i]; - DOSWRITEQUEUE (QueueHandle, REQWAITER, DATALENGTH, - (char *) &SharedSeg[TableID++], LIFOPRIO); + DosWriteQueue (QueueHandle, REQWAITER, DATALENGTH, + (PBYTE) &SharedSeg[TableID++], LIFOPRIO); } /* endfor */ @@ -85,21 +90,22 @@ void main (argc, argv, envp) for (i = 0; i < MAXQWRITES; ++i){ SharedSeg[TableID] = CustData[i]; Priorty = CustData[i] >> 8; /* Priority must be a WORD */ - DOSWRITEQUEUE (QueueHandle, REQWAITER, DATALENGTH, - (char *) &SharedSeg[TableID++], Priorty); + DosWriteQueue (QueueHandle, REQWAITER, DATALENGTH, + (PBYTE) &SharedSeg[TableID++], Priorty); } /* endfor */ /* indicate there are no more customers */ - DOSWRITEQUEUE (QueueHandle, NOMORE, DATALENGTH, - (char *) &SharedSeg[TableID], /* any prio OK - not used */ + DosWriteQueue (QueueHandle, NOMORE, DATALENGTH, + (PBYTE) &SharedSeg[TableID], /* any prio OK - not used */ ELEMPRIORITY); } /* endif */ /* free the shared segment */ - DOSFREESEG (SharedSel); + DosFreeSeg (SharedSel); /* close the queue */ - DOSCLOSEQUEUE (QueueHandle); + DosCloseQueue (QueueHandle); } +