1 /*----------------------------------------------------------------------------
  2 Name:      XmlBlasterConnectionUnparsed.h
  3 Project:   xmlBlaster.org
  4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
  5 Comment:   Include this header in your client code
  6            The returned strings are not parsed, we need another layer
  7            doing XML parsing with expat.
  8            This library is thread safe, multiple client connections may
  9            be established in parallel.
 10 Author:    "Marcel Ruff" <xmlBlaster@marcelruff.info>
 11 Date:      05/2003
 12 See:       http://www.xmlblaster.org/xmlBlaster/doc/requirements/interface.html
 13 -----------------------------------------------------------------------------*/
 14 #ifndef XMLBLASTER_XmlBlasterConnectionUnparsed_H
 15 #define XMLBLASTER_XmlBlasterConnectionUnparsed_H
 16 
 17 #ifdef __cplusplus
 18 #ifndef XMLBLASTER_C_COMPILE_AS_CPP /* 'g++ -DXMLBLASTER_C_COMPILE_AS_CPP ...' allows to compile the lib as C++ code */
 19 extern "C" {
 20 #endif
 21 #endif
 22 #ifdef __IPhoneOS__
 23 #include <CoreFoundation/CFSocket.h>
 24 #include <CoreFoundation/CFStream.h>
 25 #include <CoreFoundation/CFString.h>
 26 #include <CFNetwork/CFHost.h>
 27 #include <CFNetwork/CFSocketStream.h>
 28 
 29 #endif
 30 #include <util/msgUtil.h>
 31 #include <util/queue/QueueInterface.h>
 32 #include <util/Properties.h>
 33 
 34 struct XmlBlasterZlibWriteBuffers;
 35 struct XmlBlasterConnectionUnparsedStruct;
 36 typedef struct XmlBlasterConnectionUnparsedStruct XmlBlasterConnectionUnparsed;
 37 
 38 /* Declare function pointers to use in struct to simulate object oriented access */
 39 typedef bool  ( * XmlBlasterConnectionUnparsedInitConnection)(XmlBlasterConnectionUnparsed *xb, XmlBlasterException *exception);
 40 typedef bool  ( * XmlBlasterConnectionUnparsedInitQueue)(XmlBlasterConnectionUnparsed *xb, QueueProperties *queueProperties, XmlBlasterException *exception);
 41 typedef char *( * XmlBlasterConnectionUnparsedConnect)(XmlBlasterConnectionUnparsed *xb, const char * const qos, XmlBlasterException *exception);
 42 typedef bool  ( * XmlBlasterConnectionUnparsedDisconnect)(XmlBlasterConnectionUnparsed *xb, const char * qos, XmlBlasterException *exception);
 43 typedef char *( * XmlBlasterConnectionUnparsedPublish)(XmlBlasterConnectionUnparsed *xb, MsgUnit *msgUnit, XmlBlasterException *exception);
 44 typedef QosArr *( * XmlBlasterConnectionUnparsedPublishArr)(XmlBlasterConnectionUnparsed *xb, MsgUnitArr *msgUnitArr, XmlBlasterException *exception);
 45 typedef void  ( * XmlBlasterConnectionUnparsedPublishOneway)(XmlBlasterConnectionUnparsed *xb, MsgUnitArr *msgUnitArr, XmlBlasterException *exception);
 46 typedef char *( * XmlBlasterConnectionUnparsedSubscribe)(XmlBlasterConnectionUnparsed *xb, const char * const key, const char * qos, XmlBlasterException *exception);
 47 typedef QosArr *( * XmlBlasterConnectionUnparsedUnSubscribe)(XmlBlasterConnectionUnparsed *xb, const char * const key, const char * qos, XmlBlasterException *exception);
 48 typedef QosArr *( * XmlBlasterConnectionUnparsedErase)(XmlBlasterConnectionUnparsed *xb, const char * const key, const char * qos, XmlBlasterException *exception);
 49 typedef MsgUnitArr *( * XmlBlasterConnectionUnparsedGet)(XmlBlasterConnectionUnparsed *xb, const char * const key, const char * qos, XmlBlasterException *exception);
 50 typedef char *( * XmlBlasterConnectionUnparsedPing)(XmlBlasterConnectionUnparsed *xb, const char * const qos, XmlBlasterException *exception);
 51 typedef bool  ( * XmlBlasterConnectionUnparsedIsConnected)(XmlBlasterConnectionUnparsed *xb);
 52 typedef void  ( * XmlBlasterConnectionUnparsedShutdown)(XmlBlasterConnectionUnparsed *xb);
 53 typedef MsgRequestInfo *( * XmlBlasterConnectionUnparsedPreSendEvent)(MsgRequestInfo *msgRequestInfo, XmlBlasterException *exception);
 54 typedef MsgRequestInfo *( * XmlBlasterConnectionUnparsedPostSendEvent)(MsgRequestInfo *msgRequestInfo, XmlBlasterException *exception);
 55 
 56 /**
 57  * All synchrnous client access to xmlBlaster goes over this struct and its function pointers.
 58  */
 59 struct Dll_Export XmlBlasterConnectionUnparsedStruct {
 60    int argc;
 61    const char * const*argv;
 62    Properties *props;
 63 #ifdef __IPhoneOS__
 64    CFSocketRef cfSocketRef;
 65    CFDataRef socketAddr;
 66    CFReadStreamRef readStream;
 67    CFWriteStreamRef writeStream;
 68 #endif
 69    int socketToXmlBlaster;
 70    int socketToXmlBlasterUdp;
 71    char secretSessionId[MAX_SECRETSESSIONID_LEN];
 72    bool isInitialized;
 73    XmlBlasterConnectionUnparsedInitConnection initConnection; /**< Used internally or by multi threaded embedding only as this is called by connect() automatically */
 74    XmlBlasterConnectionUnparsedInitQueue initQueue; /**< Call to initialize persistent queue support on lost connection */
 75    XmlBlasterConnectionUnparsedConnect connect;
 76    XmlBlasterConnectionUnparsedDisconnect disconnect;
 77    XmlBlasterConnectionUnparsedPublish publish;
 78    XmlBlasterConnectionUnparsedPublishArr publishArr;
 79    XmlBlasterConnectionUnparsedPublishOneway publishOneway;
 80    XmlBlasterConnectionUnparsedSubscribe subscribe;
 81    XmlBlasterConnectionUnparsedUnSubscribe unSubscribe;
 82    XmlBlasterConnectionUnparsedErase erase;
 83    XmlBlasterConnectionUnparsedGet get;
 84    XmlBlasterConnectionUnparsedPing ping;
 85    XmlBlasterConnectionUnparsedIsConnected isConnected;
 86    XmlBlasterConnectionUnparsedShutdown shutdown;
 87    XmlBlasterConnectionUnparsedPreSendEvent preSendEvent; /**< If a callback function pointer is registered it will be called just before sending a message */
 88    void *preSendEvent_userP;
 89    XmlBlasterConnectionUnparsedPostSendEvent postSendEvent; /**< If a callback function pointer is registered it will be called just after sending a message */
 90    void *postSendEvent_userP;
 91    I_Queue *queueP;
 92    XMLBLASTER_LOG_LEVEL logLevel;
 93    XmlBlasterLogging log;
 94    void *logUserP;               /**< For outside users to pass a user object back to the logging implementation */
 95    bool useUdpForOneway;         /**< For publishOneway() AND to start callback UDP server (for updateOneway()) */
 96 
 97    /* Socket write access: */
 98    XmlBlasterWriteToSocketFuncHolder writeToSocket;  /**< The function pointer to write n bytes of plain or compressed data to the socket
 99                                                   Is initialized in initConnection(), outside users may choose to initialize it to some other function pointer */
100    struct XmlBlasterZlibWriteBuffers *zlibWriteBuf; /**< Is null if no "zlib:stream" compression is switched on */
101 
102    /* Socket read access: */
103    XmlBlasterReadFromSocketFuncHolder readFromSocket; /**< Holding function pointer for compressed/uncompressed socket reads */
104    struct XmlBlasterZlibReadBuffers *zlibReadBuf; /**< Is null if no "zlib:stream" compression is switched on */
105 };
106 #ifdef __IPhoneOS__
107 
108    struct Dll_Export XmlBlasterConnectionUnparsedStruct* globalIPhoneXb;
109 #endif
110    /**
111  * Get an instance of this to get xmlBlaster access.
112  *
113  * Every call creates a new and independent client access instance to xmlBlaster
114  */
115 Dll_Export extern XmlBlasterConnectionUnparsed *getXmlBlasterConnectionUnparsed(int argc, const char* const* argv);
116 
117 /**
118  * Free your instance after accessing xmlBlaster.
119  * After freeing  *xmlBlasterAccess is set to null
120  * Call example: freeXmlBlasterConnectionUnparsed(&xa->connectionP);
121  */
122 Dll_Export extern void freeXmlBlasterConnectionUnparsed(XmlBlasterConnectionUnparsed **xmlBlasterAccess);
123 
124 /**
125  * Help usage
126  */
127 Dll_Export extern const char *xmlBlasterConnectionUnparsedUsage();
128 
129 #ifdef __IPhoneOS__
130    extern bool isIPhoneSocketConnectionEstablished(XmlBlasterConnectionUnparsed *xb);
131 #endif
132 
133 #ifdef __cplusplus
134 #ifndef XMLBLASTER_C_COMPILE_AS_CPP
135 }
136 #endif
137 #endif
138 
139 #endif /* XMLBLASTER_XmlBlasterConnectionUnparsed_H */


syntax highlighted by Code2HTML, v. 0.9.1