00001 /*---------------------------------------------------------------------------- 00002 Name: XmlBlasterUnmanagedCE.h 00003 Project: xmlBlaster.org 00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file 00005 Comment: Provides simplified access methods to xmlBlaster client C library 00006 to be usable from Windows CE .NET Compact Framework 1.0 (CF) 00007 as a unmanaged DLL (called by C#) 00008 Note: A managed C++ wrapper is not supported in CF 00009 Author: "Marcel Ruff" <xmlBlaster@marcelruff.info> 00010 Date: 2006-12-07 00011 See: http://www.xmlblaster.org/xmlBlaster/doc/requirements/interface.html 00012 See: P/Invoke for CE: http://msdn2.microsoft.com/en-us/library/Aa446536.aspx 00013 -----------------------------------------------------------------------------*/ 00014 #ifndef _XmlBlasterUnmanagedCE_H 00015 #define _XmlBlasterUnmanagedCE_H 00016 00017 /* 00018 To access this .dll as unmanaged code from C#, the C-API must be simplified, 00019 for example fixed size arrays like "char errorCode[256]" are tricky. 00020 We implement here a simple wrapper around XmlBlasterAccessUnparsed.h 00021 This code is called from xmlBlaster/src/csharp/PInvokeCE.cs 00022 See: http://www.xmlblaster.org/xmlBlaster/doc/requirements/client.csharp.html 00023 00024 We should avoid C++ code as the name mangling makes difficulties, 00025 so we force C code here. 00026 See: http://www.opennetcf.org/Forums/topic.asp?TOPIC_ID=255 00027 */ 00028 00029 #include <XmlBlasterAccessUnparsed.h> 00030 00031 #ifdef __cplusplus 00032 extern "C" { 00033 #endif 00034 00038 typedef struct XmlBlasterUnmanagedCEException { 00039 uint32_t remote; 00040 char *errorCode; 00041 char *message; 00042 } XmlBlasterUnmanagedCEException; 00043 00044 /* 00045 public IntPtr key; 00046 public int contentLen; 00047 public IntPtr content; 00048 public IntPtr qos; 00049 public IntPtr responseQos; 00050 typedef struct MsgUnitUnmanagedCEget { 00051 char *key; 00052 uint32_t contentLen; 00053 char *content; 00054 char *qos; 00055 char *responseQos; 00056 } MsgUnitUnmanagedCEget; 00057 */ 00058 /* this only works if the size_t has 4 bytes (from MsgUnit) */ 00059 typedef MsgUnit MsgUnitUnmanagedCEpublish; 00060 typedef MsgUnit MsgUnitUnmanagedCEget; 00061 00062 00066 typedef struct XmlBlasterUnmanagedCEStringArr { 00067 const char *str; 00068 } XmlBlasterUnmanagedCEStringArr; 00069 00070 00071 Dll_Export extern char *xmlBlasterUnmanagedCEMalloc(int32_t size); 00072 Dll_Export extern void xmlBlasterUnmanagedCEFree(char *p); 00073 Dll_Export extern void xmlBlasterUnmanagedCEFreePP(char **pp); 00074 Dll_Export extern void xmlBlasterUnmanagedCEExceptionFree(XmlBlasterUnmanagedCEException *exception); 00075 00076 /* 00077 #define CALLBACK __stdcall 00078 #define WINAPI __stdcall 00079 #define WINAPIV __cdecl 00080 */ 00081 #if defined(_WINDOWS) 00082 # define XB_CALLBACK_DECL __cdecl 00083 # else/* XMLBLASTER_MONO */ 00084 # define XB_CALLBACK_DECL 00085 #endif 00086 typedef void (XB_CALLBACK_DECL *XmlBlasterUnmanagedCELoggerFp)(int32_t level, const char *location, const char *msg); 00087 typedef void (XB_CALLBACK_DECL *XmlBlasterUnmanagedCEUpdateFp)(const char *cbSessionId, MsgUnit *msgUnit, int32_t isOneway, XmlBlasterUnmanagedCEException *xmlBlasterException); 00088 typedef void (XB_CALLBACK_DECL *XmlBlasterUnmanagedCECallbackProgressListenerFp)(int32_t currBytesRead, int32_t nbytes); 00089 /*typedef int32_t (__cdecl *FPTR)( int32_t i );*/ 00090 typedef int32_t (XB_CALLBACK_DECL *FPTR)( int32_t i ); 00091 00092 Dll_Export extern const char *getXmlBlasterEmei(); 00093 00094 Dll_Export extern void xmlBlasterUnmanagedCERegisterLogger(struct XmlBlasterAccessUnparsed *xa, XmlBlasterUnmanagedCELoggerFp logger); 00095 Dll_Export extern void xmlBlasterUnmanagedCERegisterProgressListener(struct XmlBlasterAccessUnparsed *xa, XmlBlasterUnmanagedCECallbackProgressListenerFp progressListener); 00096 00097 Dll_Export extern XmlBlasterAccessUnparsed *getXmlBlasterAccessUnparsedUnmanagedCE(int argc, char** argv); 00098 Dll_Export extern void freeXmlBlasterAccessUnparsedUnmanagedCE(XmlBlasterAccessUnparsed *xmlBlasterAccess); 00099 00100 Dll_Export extern char *xmlBlasterUnmanagedCEConnect(struct XmlBlasterAccessUnparsed *xa, char *qos, XmlBlasterUnmanagedCEUpdateFp update, XmlBlasterUnmanagedCEException *exception); 00101 Dll_Export extern bool xmlBlasterUnmanagedCEInitialize(struct XmlBlasterAccessUnparsed *xa, XmlBlasterUnmanagedCEUpdateFp update, XmlBlasterUnmanagedCEException *exception); 00102 Dll_Export extern bool xmlBlasterUnmanagedCEDisconnect(struct XmlBlasterAccessUnparsed *xa, char *qos, XmlBlasterUnmanagedCEException *exception); 00103 Dll_Export extern char *xmlBlasterUnmanagedCEPublish(struct XmlBlasterAccessUnparsed *xa, MsgUnitUnmanagedCEpublish *msgUnit, XmlBlasterUnmanagedCEException *exception); 00104 Dll_Export extern QosArr *xmlBlasterUnmanagedCEPublishArr(struct XmlBlasterAccessUnparsed *xa, MsgUnitArr *msgUnitArr, XmlBlasterUnmanagedCEException *exception); 00105 Dll_Export extern void xmlBlasterUnmanagedCEPublishOneway(struct XmlBlasterAccessUnparsed *xa, void *msgUnitArr, int length, XmlBlasterUnmanagedCEException *exception); 00106 Dll_Export extern char *xmlBlasterUnmanagedCESubscribe(struct XmlBlasterAccessUnparsed *xa, char *key, char *qos, XmlBlasterUnmanagedCEException *exception); 00107 Dll_Export extern void xmlBlasterUnmanagedCEUnSubscribe(struct XmlBlasterAccessUnparsed *xa, char * key, char * qos, XmlBlasterUnmanagedCEException *exception, uint32_t* pSize, XmlBlasterUnmanagedCEStringArr** ppStruct); 00108 Dll_Export extern void xmlBlasterUnmanagedCEErase(struct XmlBlasterAccessUnparsed *xa, char * key, char * qos, XmlBlasterUnmanagedCEException *exception, uint32_t* pSize, XmlBlasterUnmanagedCEStringArr** ppStruct); 00109 Dll_Export extern void xmlBlasterUnmanagedCEGet(struct XmlBlasterAccessUnparsed *xa, char * key, char *qos, XmlBlasterUnmanagedCEException *exception, uint32_t* pSize, MsgUnitUnmanagedCEget** ppStruct); 00110 Dll_Export extern char *xmlBlasterUnmanagedCEPing(struct XmlBlasterAccessUnparsed *xa, char * qos, XmlBlasterUnmanagedCEException *exception); 00111 Dll_Export extern bool xmlBlasterUnmanagedCEIsConnected(struct XmlBlasterAccessUnparsed *xa); 00112 Dll_Export extern const char *xmlBlasterUnmanagedCEVersion(); 00113 Dll_Export extern const char *xmlBlasterUnmanagedCEUsage(); 00114 00115 #ifdef __cplusplus 00116 } /* extern "C" */ 00117 #endif 00118 #endif /* _XmlBlasterUnmanagedCE_H */ 00119