util/msgUtil.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "helper.h"
#include "msgUtil.h"
#include <netdb.h>
#include <errno.h>

Include dependency graph for msgUtil.c:

Go to the source code of this file.

Functions

char * getXmlBlasterVersion (void)
 
Returns:
e.g.

void xmlBlasterFree (char *p)
 Frees the pointer with free().
void freeQosArr (QosArr *qosArr)
 Frees everything inside QosArr and the struct QosArr itself.
void freeMsgUnitArr (MsgUnitArr *msgUnitArr)
 Frees everything inside MsgUnitArr and the struct MsgUnitArr itself.
void freeMsgUnitArrInternal (MsgUnitArr *msgUnitArr)
 Frees everything inside MsgUnitArr but NOT the struct MsgUnitArr itself.
void freeMsgUnitData (MsgUnit *msgUnit)
 Does not free the msgUnit itself.
void freeMsgUnit (MsgUnit *msgUnit)
 Frees everything.
char * messageUnitToXmlLimited (MsgUnit *msg, int maxContentDumpLen)
 NOTE: You need to free the returned pointer with xmlBlasterFree() or directly with free()!
char * messageUnitToXml (MsgUnit *msg)
 NOTE: You need to free the returned pointer with xmlBlasterFree() or directly with free()!
void initializeXmlBlasterException (XmlBlasterException *xmlBlasterException)
 Should be called on any xmlBlasterException before using it.
hostent * gethostbyname_re (char *host, struct hostent *hostbuf, char **tmphstbuf, size_t *hstbuflen, char errP[256])
 Thread safe host lookup.


Function Documentation

void freeMsgUnit ( MsgUnit msgUnit  ) 

Frees everything.

Definition at line 150 of file msgUtil.c.

References freeMsgUnitData().

Here is the call graph for this function:

void freeMsgUnitArr ( MsgUnitArr msgUnitArr  ) 

Frees everything inside MsgUnitArr and the struct MsgUnitArr itself.

Parameters:
msgUnitArr The struct to free, passing NULL is OK

Definition at line 99 of file msgUtil.c.

References freeMsgUnitArrInternal().

Referenced by main(), parseQosArr(), sendResponseOrException(), xmlBlasterUnmanagedCEGet(), and xmlBlasterUnmanagedGet().

Here is the call graph for this function:

void freeMsgUnitArrInternal ( MsgUnitArr msgUnitArr  ) 

Frees everything inside MsgUnitArr but NOT the struct MsgUnitArr itself.

Parameters:
msgUnitArr The struct internals to free, passing NULL is OK

Definition at line 110 of file msgUtil.c.

References freeMsgUnitData(), MsgUnitStructArr::len, and MsgUnitStructArr::msgUnitArr.

Referenced by freeMsgUnitArr(), and main().

Here is the call graph for this function:

void freeMsgUnitData ( MsgUnit msgUnit  ) 

Does not free the msgUnit itself.

Definition at line 124 of file msgUtil.c.

References MsgUnit::content, MsgUnit::contentLen, MsgUnit::key, MsgUnit::qos, and MsgUnit::responseQos.

Referenced by freeMsgUnit(), freeMsgUnitArrInternal(), main(), myUpdate(), xmlBlasterUnmanagedCEPublish(), and xmlBlasterUnmanagedCEPublishOneway().

void freeQosArr ( QosArr qosArr  ) 

Frees everything inside QosArr and the struct QosArr itself.

Parameters:
qosArr The struct to free, passing NULL is OK

Definition at line 83 of file msgUtil.c.

References QosStructArr::len, and QosStructArr::qosArr.

Referenced by main(), xmlBlasterUnmanagedCEErase(), xmlBlasterUnmanagedCEUnSubscribe(), xmlBlasterUnmanagedErase(), and xmlBlasterUnmanagedUnSubscribe().

struct hostent* gethostbyname_re ( char *  host,
struct hostent *  hostbuf,
char **  tmphstbuf,
size_t *  hstbuflen,
char  errP[256] 
) [read]

Thread safe host lookup.

NOTE: If the return is not NULL you need to free(*tmphstbuf)

Author:
Caolan McNamara (2000) <caolan@skynet.ie> (with some leak fixes by Marcel)

Definition at line 340 of file msgUtil.c.

Referenced by createCallbackServer(), and initConnection().

char* getXmlBlasterVersion ( void   ) 

Returns:
e.g.

"0.848 #1207M"

Definition at line 47 of file msgUtil.c.

Referenced by main(), and xmlBlasterUnmanagedCEVersion().

void initializeXmlBlasterException ( XmlBlasterException xmlBlasterException  ) 

Should be called on any xmlBlasterException before using it.

Definition at line 207 of file msgUtil.c.

References ExceptionStruct::errorCode, ExceptionStruct::message, and ExceptionStruct::remote.

Referenced by checkArgs(), handleMessage(), sendData(), xmlBlasterUnmanagedCEErase(), xmlBlasterUnmanagedCEUnSubscribe(), xmlBlasterUnmanagedErase(), and xmlBlasterUnmanagedUnSubscribe().

char* messageUnitToXml ( MsgUnit msg  ) 

NOTE: You need to free the returned pointer with xmlBlasterFree() or directly with free()!

Returns:
A ASCII XML formatted message or NULL if out of memory

Definition at line 199 of file msgUtil.c.

References messageUnitToXmlLimited().

Referenced by myUpdate().

Here is the call graph for this function:

char* messageUnitToXmlLimited ( MsgUnit msg,
int  maxContentDumpLen 
)

NOTE: You need to free the returned pointer with xmlBlasterFree() or directly with free()!

Parameters:
msg The message
maxContentDumpLen for -1 get the complete content, else limit the content to the given number of bytes
Returns:
A ASCII XML formatted message or NULL if out of memory

Definition at line 165 of file msgUtil.c.

References MsgUnit::content, MsgUnit::contentLen, MsgUnit::key, MsgUnit::qos, SNPRINTF, strcatAlloc(), strcpyAlloc(), strFromBlobAlloc(), and strncpy0().

Referenced by main(), messageUnitToXml(), and myUpdate().

Here is the call graph for this function:

void xmlBlasterFree ( char *  p  ) 

Frees the pointer with free().

Users of this library can use xmlBlasterFree() instead of free(). This can be helpful on Windows and if this client library is a DLL and compiled with /MT but the client code is not (or vice versa). In such a case the executable uses different runtime libraries with different instances of malloc/free. On UNIX we don't need this function but it doesn't harm either.

Definition at line 72 of file msgUtil.c.

Referenced by interceptUpdate(), main(), myUpdate(), xmlBlasterUnmanagedCEConnect(), xmlBlasterUnmanagedCEDisconnect(), xmlBlasterUnmanagedCEErase(), xmlBlasterUnmanagedCEExceptionFree(), xmlBlasterUnmanagedCEFree(), xmlBlasterUnmanagedCEFreePP(), xmlBlasterUnmanagedCEGet(), xmlBlasterUnmanagedCEPing(), xmlBlasterUnmanagedCESubscribe(), and xmlBlasterUnmanagedCEUnSubscribe().