This program illustrates how to use APIs to create and manipulate a data queue.
/*********************************************************************/ /* */ /*Program Name: DQUEUEX */ /* */ /*Program Language: ILE C */ /* */ /*Description: This program illustrates how to use APIs to create */ /* and manipulate a data queue. */ /* */ /* */ /*Header Files Included: <stdio.h> */ /* <string.h> */ /* <stdlib.h> */ /* <decimal.h> */ /* <qrcvdtaq.h> */ /* <qsnddtaq.h> */ /* */ /*APIs Used: QSNDDTAQ - Send data queue */ /* QRCVDTAQ - Receive data queue */ /* */ /*********************************************************************/ /*********************************************************************/ /*********************************************************************/ /* Includes */ /*********************************************************************/ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <decimal.h> #include <qsnddtaq.h> /* from QSYSINC/h */ #include <qrcvdtaq.h> /* from QSYSINC/h */ /*********************************************************************/ /* */ /* Main */ /* */ /*********************************************************************/ void main() { decimal(5,0) DataLength = 10.0d, WaitTime = 0.0d; char QueueData[10]; /*******************************************************************/ /* Create library QUEUELIB. */ /*******************************************************************/ system("CRTLIB LIB(QUEUELIB)"); /*******************************************************************/ /* Create a data queue called EXAMPLEQ in library QUEUELIB. The */ /* queue will have a maximum entry length set at 10, and will be */ /* FIFO (first-in first-out). */ /*******************************************************************/ system("CRTDTAQ DTAQ(QUEUELIB/EXAMPLEQ) MAXLEN(10)"); /*******************************************************************/ /* Send information to the data queue. */ /*******************************************************************/ QSNDDTAQ("EXAMPLEQ ", /* Data queue name */ "QUEUELIB ", /* Queue library name */ DataLength, /* Length of queue entry */ "EXAMPLE "); /* Data sent to queue */ /*******************************************************************/ /* Receive information from the data queue. */ /*******************************************************************/ QRCVDTAQ("EXAMPLEQ ", /* Data queue name */ "QUEUELIB ", /* Queue library name */ &DataLength, /* Length of queue entry */ &QueueData, /* Data received from queue */ WaitTime); /* Wait time */ printf("Queue entry information: %.10s\n", QueueData); /*******************************************************************/ /* Delete the data queue. */ /*******************************************************************/ system("DLTDTAQ DTAQ(QUEUELIB/EXAMPLEQ)"); /*******************************************************************/ /* Delete the library. */ /*******************************************************************/ system("DLTLIB LIB(QUEUELIB)"); }