--- os2sdk/demos/examples/queues/serv.c 2018/08/09 12:25:13 1.1.1.1 +++ os2sdk/demos/examples/queues/serv.c 2018/08/09 12:26:14 1.1.1.2 @@ -3,7 +3,7 @@ * This program emulates the headwaiter reading requests (from a queue) * placed in the queue by the gatekeeper (see customer.c). The following * functions are illustrated here: - * DOSCREATEQUEUE, DOSQUERYQUEUE, DOSREADQUEUE, DOSCLOSEQUEUE + * DosCreateQueue, DosQueryQueue, DosReadQueue, DosCloseQueue * * This example first makes the shared segment created by customer.c * addressable. The data queued by the customer.c is contained in this @@ -16,40 +16,40 @@ * * Compile as: cl -AL -G2 -Lp server.c * - * Copyright (C) Microsoft Corp. 1986 + * Created by Microsoft Corp. 1986 */ -#include /* 286DOS function declarations */ +#define INCL_DOSMEMMGR +#define INCL_DOSQUEUES +#define INCL_DOSPROCESS +#define INCL_DOSERRORS + +#include +#include /* MS OS/2 function declarations */ #include "defines.h" /* definitions for example programs */ #define Q 0 /* determine type of Queue to create */ -#define ERROR_FILE_NOT_FOUND 2 - - - - - void main (argc, argv, envp) int argc; char *argv[]; char *envp; { - unsigned QueueHandle, /* handle to the queue */ - NumberElements = 0, /* number of elements in queue */ - DataLength, /* length of element received */ - SharedSel; /* selector to shared segment */ - unsigned long DataAddress, /* address of element received */ + HQUEUE QueueHandle; /* handle to the queue */ + USHORT NumberElements = 0; /* number of elements in queue */ + USHORT DataLength; /* length of element received */ + SEL SharedSel; /* selector to shared segment */ + ULONG DataAddress, /* address of element received */ PID_RequestID; /* will hold PID & request ID */ - unsigned char ElemPriority, /* priority of element in queue */ + UCHAR ElemPriority, /* priority of element in queue */ TableID, /* ID of the table */ Priorty, /* Priority of the Data Element */ type; /* example type */ /* get the shared segment */ - while (DOSGETSHRSEG (SEGNAME, &SharedSel) == + while (DosGetShrSeg (SEGNAME, &SharedSel) == ERROR_FILE_NOT_FOUND) /* keep trying to get the shared seg...*/ - DOSSLEEP(1000L); /* ...until the customer creates it */ + DosSleep(1000L); /* ...until the customer creates it */ /* create the appropriate queue */ if (argc > 1){ @@ -58,33 +58,33 @@ void main (argc, argv, envp) } else type = 'd'; switch (*argv[0]) { - case 'f': DOSCREATEQUEUE (&QueueHandle, FIFO, QUEUENAME); + case 'f': DosCreateQueue (&QueueHandle, FIFO, QUEUENAME); printf("FIFO Queue selected ... \n"); break; - case 'F': DOSCREATEQUEUE (&QueueHandle, FIFO, QUEUENAME); + case 'F': DosCreateQueue (&QueueHandle, FIFO, QUEUENAME); printf("FIFO Queue selected ...\n"); break; - case 'l': DOSCREATEQUEUE (&QueueHandle, LIFO, QUEUENAME); + case 'l': DosCreateQueue (&QueueHandle, LIFO, QUEUENAME); printf("LIFO Queue selected ...\n"); break; - case 'L': DOSCREATEQUEUE (&QueueHandle, LIFO, QUEUENAME); + case 'L': DosCreateQueue (&QueueHandle, LIFO, QUEUENAME); printf("LIFO Queue selected ...\n"); break; - case 'p': DOSCREATEQUEUE (&QueueHandle, PRIO, QUEUENAME); + case 'p': DosCreateQueue (&QueueHandle, PRIO, QUEUENAME); printf("PRIO Queue selected ...\n"); break; - case 'P': DOSCREATEQUEUE (&QueueHandle, PRIO, QUEUENAME); + case 'P': DosCreateQueue (&QueueHandle, PRIO, QUEUENAME); printf("PRIO Queue selected ...\n"); break; - default: DOSCREATEQUEUE (&QueueHandle, FIFO, QUEUENAME); + default: DosCreateQueue (&QueueHandle, FIFO, QUEUENAME); printf("FIFO Queue selected - default\n"); ; } /* endswitch */ /* check if there are any requests */ while (NumberElements == 0) { - DOSQUERYQUEUE (QueueHandle, &NumberElements); - DOSSLEEP(1000L); + DosQueryQueue (QueueHandle, &NumberElements); + DosSleep(1000L); } /* there are requests in the queue. */ @@ -97,12 +97,12 @@ void main (argc, argv, envp) do { /* read an element from the queue */ - DOSREADQUEUE (QueueHandle, &PID_RequestID, + DosReadQueue (QueueHandle, &PID_RequestID, &DataLength, &DataAddress, FIRSTELEMENT, - (unsigned char) WAIT, &ElemPriority, - (unsigned long) DUMMYPARAM); - TableID = *((unsigned char *) DataAddress); - Priorty = *((unsigned char *) DataAddress + 1); + (UCHAR) WAIT, &ElemPriority, + (HSEM) DUMMYPARAM); + TableID = *((PUCHAR) DataAddress); + Priorty = *((PUCHAR) DataAddress + 1); /* dispatch waiter to table */ @@ -116,8 +116,9 @@ void main (argc, argv, envp) /* free the shared segment */ - DOSFREESEG (SharedSel); + DosFreeSeg (SharedSel); /* close the queue */ - DOSCLOSEQUEUE (QueueHandle); + DosCloseQueue (QueueHandle); } +