examples/PIPS/opencmessagequeuelibraryex/engine/src/msgqcheck.c

00001 
00010 #include <errno.h>
00011 #include <sys/msg.h>
00012 #include "MsgQInternal.h"
00013 
00014 
00015 
00016 /*****************************************************************************
00017 *  MsgQCheck
00018 *  Function: Function for checking how many messages are in a queue
00019 *******************************************************************************/
00020 
00021 EXPORT_C int MsgQCheck(ULONG qName, int* err) {
00022         MSGQ_INFO* pMsgQInfo = NULL;
00023         int nMsgs;
00024         struct  msqid_ds  qStatus ;
00025 
00026         if ((pMsgQInfo = MsgQTableLookup(qName)) != NULL) {
00027                 //   get total count of msgs from the msg queue 
00028                 if ((msgctl(pMsgQInfo->qId,IPC_STAT ,&qStatus)) >= 0 ) {
00029                         nMsgs=qStatus.msg_qnum ;
00030                         if (nMsgs == pMsgQInfo->numMsgs) {
00031                                 *err = OK;
00032                                 return(nMsgs);
00033                         }
00034                         else {
00035                                 *err = KMsgQLibQShortErr;
00036                                 return(pMsgQInfo->numMsgs);
00037                         }
00038                 }
00039                 else
00040                         *err=errno;
00041         }
00042         else
00043                 *err = KMsgQLibQIdErr;
00044         return(ERROR);
00045 }
00046 

Generated by  doxygen 1.6.2