|
Nokia N97 SDK Example Applications Guide |
00001 /** 00002 * @file MsgQCheck.cpp 00003 * Description: Source file for MsgQLib's MsgQCheck API 00004 * Copyright (c) 2007 Nokia Corporation. 00005 * This material, including documentation and any related 00006 * computer programs, is protected by copyright controlled by 00007 * Nokia Corporation. 00008 */ 00009 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
|
© Nokia 2009 |