1 /*----------------------------------------------------------------------------
 2 Name:      XmlBlasterUnmanaged.h
 3 Project:   xmlBlaster.org
 4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
 5 Comment:   Provides simplified access methods to xmlBlaster client C library
 6            to be usable as .net unmanaged DLL (called by C#) on e.g. Windows XP
 7 Author:    "Marcel Ruff" <xmlBlaster@marcelruff.info>
 8 Date:      07/2006
 9 See:       http://www.xmlblaster.org/xmlBlaster/doc/requirements/interface.html
10 -----------------------------------------------------------------------------*/
11 #ifndef _XmlBlasterUnmanaged_H
12 #define _XmlBlasterUnmanaged_H
13 
14 /*
15  To access this .dll as unmanaged code from C#, the C-API must be simplified,
16  for example fixed size arrays like "char errorCode[256]" are tricky.
17  We implement here a simple wrapper around XmlBlasterAccessUnparsed.h
18  This code is called from xmlBlaster/src/csharp/NativeC.cs
19  See: http://www.xmlblaster.org/xmlBlaster/doc/requirements/client.csharp.html
20  */
21 
22 
23 #ifdef __cplusplus
24 #ifndef XMLBLASTER_C_COMPILE_AS_CPP /* 'g++ -DXMLBLASTER_C_COMPILE_AS_CPP ...' allows to compile the lib as C++ code */
25 extern "C" {
26 #endif
27 #endif
28 
29 #include <XmlBlasterAccessUnparsed.h>
30 
31 #ifndef WINCE
32 
33 /**
34  * Usage without fixed array size, to avoid 'unsafe' code in C#
35  */
36 typedef struct XmlBlasterUnmanagedException {
37    uint32_t remote;
38    char *errorCode;
39    char *message;
40 } XmlBlasterUnmanagedException;
41 
42 /**
43  * Helper struct to pass an array of strings back to C#
44  */
45 typedef struct XmlBlasterUnmanagedStringArr {
46    const char *str; 
47 } XmlBlasterUnmanagedStringArr;
48 
49 
50 typedef const char * (*XmlBlasterUnmanagedUpdateFp)(const char *cbSessionId, const char *key, char *contentStr, int32_t contentLen, const char *qos, XmlBlasterUnmanagedException *xmlBlasterException);
51 
52 Dll_Export extern XmlBlasterAccessUnparsed *getXmlBlasterAccessUnparsedUnmanaged(int argc, const char* const* argv);
53 Dll_Export void freeXmlBlasterAccessUnparsedUnmanaged(XmlBlasterAccessUnparsed *xmlBlasterAccess);
54 
55 Dll_Export extern  char *xmlBlasterUnmanagedConnect(struct XmlBlasterAccessUnparsed *xa, const char * const qos, XmlBlasterUnmanagedUpdateFp update, XmlBlasterUnmanagedException *exception);
56 Dll_Export extern  bool  xmlBlasterUnmanagedInitialize(struct XmlBlasterAccessUnparsed *xa, XmlBlasterUnmanagedUpdateFp update, XmlBlasterUnmanagedException *exception);
57 Dll_Export extern  bool  xmlBlasterUnmanagedDisconnect(struct XmlBlasterAccessUnparsed *xa, const char * qos, XmlBlasterUnmanagedException *exception);
58 Dll_Export extern  char *xmlBlasterUnmanagedPublish(struct XmlBlasterAccessUnparsed *xa, MsgUnit *msgUnit, XmlBlasterUnmanagedException *exception);
59 Dll_Export extern  QosArr *xmlBlasterUnmanagedPublishArr(struct XmlBlasterAccessUnparsed *xa, MsgUnitArr *msgUnitArr, XmlBlasterUnmanagedException *exception);
60 Dll_Export extern void xmlBlasterUnmanagedPublishOneway(struct XmlBlasterAccessUnparsed *xa, MsgUnit *msgUnitArr, int length, XmlBlasterUnmanagedException *exception);
61 Dll_Export extern  char *xmlBlasterUnmanagedSubscribe(struct XmlBlasterAccessUnparsed *xa, const char * const key, const char * qos, XmlBlasterUnmanagedException *exception);
62 Dll_Export extern void xmlBlasterUnmanagedUnSubscribe(struct XmlBlasterAccessUnparsed *xa, const char * const key, const char * qos, XmlBlasterUnmanagedException *exception, uint32_t* pSize, XmlBlasterUnmanagedStringArr** ppStruct);
63 Dll_Export extern void xmlBlasterUnmanagedErase(struct XmlBlasterAccessUnparsed *xa, const char * const key, const char * qos, XmlBlasterUnmanagedException *exception, uint32_t* pSize, XmlBlasterUnmanagedStringArr** ppStruct);
64 Dll_Export extern  void xmlBlasterUnmanagedGet(struct XmlBlasterAccessUnparsed *xa, const char * const key, const char * qos, XmlBlasterUnmanagedException *exception, uint32_t* pSize, MsgUnit** ppStruct);
65 Dll_Export extern  char *xmlBlasterUnmanagedPing(struct XmlBlasterAccessUnparsed *xa, const char * const qos, XmlBlasterUnmanagedException *exception);
66 Dll_Export extern  bool xmlBlasterUnmanagedIsConnected(struct XmlBlasterAccessUnparsed *xa);
67 Dll_Export extern const char *xmlBlasterUnmanagedUsage(void);
68 
69 
70 #ifdef __cplusplus
71 #ifndef XMLBLASTER_C_COMPILE_AS_CPP
72 }
73 #endif
74 #endif
75 
76 #endif /*!defined(WINCE)*/
77 #endif /* _XmlBlasterUnmanaged_H */


syntax highlighted by Code2HTML, v. 0.9.1