|
Nokia N97 SDK Example Applications Guide |
00001 /** 00002 * @file MsgQLib.h 00003 * Description: Header file for MsgQLib 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 #ifndef MSGQLIB_H 00011 #define MSGQLIB_H 00012 00013 #include <_ansi.h> 00014 00015 #ifdef __cplusplus 00016 extern "C" { 00017 #endif 00018 00019 /* MsgQLib sizes */ 00020 #define MAX_MSG_LEN 2048 00021 00022 /* hash table parameters - table size must be a prime number */ 00023 #define MSGQ_TBL_SZ 101 00024 00025 /* message send states */ 00026 #define MSG_Q_READY 0 00027 #define MSG_Q_CLEANING 1 00028 00029 00030 #define NO_WAIT 0 00031 #define WAIT_FOREVER 0xFFFF 00032 00033 #ifndef NULL 00034 #define NULL 0 00035 #endif /* NULL */ 00036 00037 /* errors */ 00038 #define KMsgQLibErr 0x100 00039 #define KMsgQLibNoMemoryErr (KMsgQLibErr | 1) /* out of memory */ 00040 #define KMsgQLibQIdErr (KMsgQLibErr | 2) /* queue already in use or invalid */ 00041 #define KMsgQLibParamErr (KMsgQLibErr | 3) /* illegal parm(s)/val(s) */ 00042 #define KMsgQLibQFlushErr (KMsgQLibErr | 4) /* queue being flushed */ 00043 #define KMsgQLibQShortErr (KMsgQLibErr | 5) /* internal error: inconsistency between #of msgs*/ 00044 00045 #define MSG_Q_FIFO 1 00046 #define MSG_Q_PRIORITY 2 00047 #define MSG_PRI_NORMAL 3 00048 #define MSG_PRI_URGENT 4 00049 #define SEM_Q_FIFO 5 00050 #define SEM_Q_PRIORITY 6 00051 00052 #define OK 0 00053 #define ERROR -1 00054 00055 typedef unsigned long ULONG ; 00056 typedef unsigned short ushort_t; 00057 00058 /** 00059 * 00060 * Creates a message queue with the argument passed 00061 * 00062 * @param qName - queue name 00063 * @param maxMsgs - max messages in the queue 00064 * @param qOptions - message queue options 00065 * MSG_Q_FIFO 00066 * MSG_Q_PRIORITY 00067 * @param err - error code to be returned 00068 * 00069 * @return Returns status and error code 00070 */ 00071 IMPORT_C int MsgQCreate (ULONG qName, ULONG maxMsgs, ULONG qOptions, int* err); 00072 00073 /** 00074 * 00075 * This function deletes a message queue 00076 * 00077 * @param qName - queue name 00078 * @param err - error code to be returned 00079 * 00080 * @return Returns status and error code 00081 **/ 00082 IMPORT_C int MsgQDelete (ULONG qName, int* err); 00083 00084 /** 00085 * 00086 * This function sends a message with internal copy 00087 * 00088 * @param qName - queue name 00089 * @param msg - message to send 00090 * @param nBytes - length of message 00091 * @param priority - message priority 00092 * @param timeout - milliseconds to wait 00093 * @param err - error code to be returned 00094 * 00095 * @return Returns status and error code 00096 **/ 00097 00098 IMPORT_C int MsgQSend (ULONG qName, char* msg, ULONG nBytes, ULONG priority, int timeout, int* err); 00099 00100 /** 00101 * 00102 * This function receives a message with internal copy 00103 * 00104 * @param qName - queue name 00105 * @param msg - buffer for received message 00106 * @param maxNBytes - length of buffer 00107 * @param timeout - milliseconds to wait 00108 * @param err - error code to be returned 00109 * 00110 * @return Returns status and error code 00111 **/ 00112 00113 IMPORT_C int MsgQReceive (ULONG qName, char* msg, ULONG maxNBytes, int timeout, int* err); 00114 00115 /** 00116 * 00117 * This function checks how many messages are in a queue 00118 * 00119 * @param qName - queue name 00120 * @param err - error code to be returned 00121 * 00122 * @return Returns status and error code 00123 **/ 00124 IMPORT_C int MsgQCheck (ULONG qName, int* err); 00125 00126 /** 00127 * This function checks the maximum number of messages in a queue 00128 * 00129 * @param qName - queue name 00130 * @param err - error code to be returned 00131 * 00132 * @return Returns status and error code 00133 **/ 00134 IMPORT_C int MsgQMaxCheck (ULONG qName, int* err); 00135 00136 /** 00137 * 00138 * This function empties the specified queue 00139 * 00140 * @param qName - queue name 00141 * @param err - error code to be returned 00142 * 00143 * @return Returns status and error code 00144 **/ 00145 IMPORT_C int MsgQClean (ULONG qName, int* err); 00146 00147 #ifdef __cplusplus 00148 } 00149 #endif 00150 00151 #endif /* MSGQLIB_H */
|
© Nokia 2009 |