|
Nokia N97 SDK Example Applications Guide |
00001 /** 00002 * @file MsgQClean.cpp 00003 * Description: Source file for MsgQLib's MsgQClean 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 * MsgQClean (qName, err) 00017 * Description: Function that empties the specified queue 00018 *****************************************************************************/ 00019 00020 EXPORT_C int MsgQClean(ULONG qName, int* err) { 00021 MSGQ_INFO* pMsgQInfo = NULL; 00022 char msg[MAX_MSG_LEN]; 00023 int rcv_err; 00024 00025 if ((pMsgQInfo = MsgQTableLookup(qName)) != NULL) { 00026 // sending a message is not allowed 00027 pMsgQInfo->sendState = MSG_Q_CLEANING; 00028 // empty out the queue 00029 while(MsgQReceive(qName, msg, MAX_MSG_LEN, IPC_NOWAIT, &rcv_err) != ERROR) {}; 00030 if (rcv_err == ENOMSG) { 00031 *err = OK; 00032 return (OK); 00033 } 00034 else 00035 *err = rcv_err; 00036 // sending a message is allowed 00037 pMsgQInfo->sendState = MSG_Q_READY; 00038 } 00039 else 00040 *err = KMsgQLibQIdErr; 00041 00042 return(ERROR); 00043 } 00044 00045
|
© Nokia 2009 |