00001 /*---------------------------------------------------------------------------- 00002 Name: xmlBlaster/src/c/util/msgUtil.h 00003 Project: xmlBlaster.org 00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file 00005 Author: "Marcel Ruff" <xmlBlaster@marcelruff.info> 00006 -----------------------------------------------------------------------------*/ 00007 #ifndef XMLBLASTER_MSGUTIL_H 00008 #define XMLBLASTER_MSGUTIL_H 00009 00010 #include <util/helper.h> 00011 00012 #ifdef __cplusplus 00013 #ifndef XMLBLASTER_C_COMPILE_AS_CPP /* 'g++ -DXMLBLASTER_C_COMPILE_AS_CPP ...' allows to compile the lib as C++ code */ 00014 extern "C" { 00015 #endif 00016 #endif 00017 00018 #define MAX_ERRNO_LEN 256 00019 #define XMLBLASTER_MAX_USAGE_LEN 2048 /* Change XmlBlasterAccessUnparsed.c accordingly */ 00020 #define MAX_REQUESTID_LEN 256 00021 #define MAX_SECRETSESSIONID_LEN 256 00022 #define MAX_SESSIONID_LEN 256 00023 00024 /* See org.xmlBlaster.util.def.MethodName.java */ 00025 #define MAX_METHODNAME_LEN 20 00026 #define XMLBLASTER_CONNECT "connect" 00027 #define XMLBLASTER_DISCONNECT "disconnect" 00028 #define XMLBLASTER_PING "ping" 00029 #define XMLBLASTER_UPDATE "update" 00030 #define XMLBLASTER_UPDATE_ONEWAY "updateOneway" 00031 #define XMLBLASTER_PUBLISH "publish" 00032 #define XMLBLASTER_PUBLISH_ONEWAY "publishOneway" 00033 #define XMLBLASTER_GET "get" 00034 #define XMLBLASTER_SUBSCRIBE "subscribe" 00035 #define XMLBLASTER_UNSUBSCRIBE "unSubscribe" 00036 #define XMLBLASTER_ERASE "erase" 00037 00041 typedef BlobHolder XmlBlasterBlob; 00042 00048 typedef struct MsgUnit { 00049 const char *key; 00050 size_t contentLen; 00051 const char *content; 00052 const char *qos; 00053 char *responseQos; 00054 } MsgUnit; 00055 /* Note: We use the above 'const' to simplify assignment from C++ like 'msgUnit.key = std::string.c_str() */ 00056 00060 typedef struct MsgUnitStructArr { 00062 bool isOneway; 00064 char secretSessionId[MAX_SESSIONID_LEN]; 00065 uint32_t len; 00066 MsgUnit *msgUnitArr; 00067 } MsgUnitArr; 00068 00072 typedef struct QosStructArr { 00073 uint32_t len; /* Number of XML QoS strings */ 00074 const char **qosArr; 00075 } QosArr; 00076 00080 typedef struct MsgRequestInfoStruct { 00081 void *xa; /* XmlBlasterAccessUnparsed * */ 00082 char requestIdStr[MAX_REQUESTID_LEN]; 00083 const char *methodName; 00084 char responseType; /* XMLBLASTER_MSG_TYPE_ENUM */ 00085 XmlBlasterBlob blob; 00086 XmlBlasterBlob responseBlob; 00087 #ifdef XB_USE_PTHREADS 00088 pthread_mutex_t responseMutex; /* Needed for boss/worker model to block until an update arrives */ 00089 bool responseMutexIsLocked; 00090 pthread_cond_t responseCond; 00091 #endif 00092 bool rollback; 00093 } MsgRequestInfo; 00094 00095 /* See helper.h */ 00096 #define XMLBLASTEREXCEPTION_ERRORCODE_LEN EXCEPTIONSTRUCT_ERRORCODE_LEN 00097 #define XMLBLASTEREXCEPTION_MESSAGE_LEN EXCEPTIONSTRUCT_MESSAGE_LEN 00098 typedef ExceptionStruct XmlBlasterException; 00099 00100 Dll_Export extern void initializeXmlBlasterException(XmlBlasterException *xmlBlasterException); 00101 00102 Dll_Export extern const char *getXmlBlasterVersion(void); 00103 Dll_Export extern void xmlBlasterFree(char *p); 00104 Dll_Export extern void freeMsgUnitData(MsgUnit *msgUnit); 00105 Dll_Export extern void freeMsgUnit(MsgUnit *msgUnit); 00106 Dll_Export extern void freeMsgUnitArr(MsgUnitArr *msgUnitArr); 00107 Dll_Export extern void freeMsgUnitArrInternal(MsgUnitArr *msgUnitArr); 00108 Dll_Export extern void freeQosArr(QosArr *qosArr); 00109 Dll_Export extern char *messageUnitToXml(MsgUnit *msg); 00110 Dll_Export extern char *messageUnitToXmlLimited(MsgUnit *msg, int maxContentDumpLen); 00111 Dll_Export extern struct hostent * gethostbyname_re (const char *host,struct hostent *hostbuf,char **tmphstbuf,size_t *hstbuflen,char errP[MAX_ERRNO_LEN]); 00112 00113 #ifdef __cplusplus 00114 #ifndef XMLBLASTER_C_COMPILE_AS_CPP 00115 } /* extern "C" */ 00116 #endif 00117 #endif 00118 00119 #endif /* XMLBLASTER_MSGUTIL_H */ 00120