Index: src/c/socket/pthreadVC.lib
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/c/socket/pthreadVC.dll
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: src/c/socket/xmlBlasterSocket.h
===================================================================
--- src/c/socket/xmlBlasterSocket.h	(revision 12917)
+++ src/c/socket/xmlBlasterSocket.h	(working copy)
@@ -1,124 +1,125 @@
-/*----------------------------------------------------------------------------
-Name:      xmlBlasterSocket.h
-Project:   xmlBlaster.org
-Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
-Comment:   SOCKET internal header (not included directly by clients)
-Author:    "Marcel Ruff" <xmlBlaster@marcelruff.info>
------------------------------------------------------------------------------*/
-#ifndef XMLBLASTER_SOCKET_H
-#define XMLBLASTER_SOCKET_H
-
-#include <stdlib.h>
-
-#ifdef _WINDOWS
-                             /* #if _MSC_VER > 1300 */
-#include <Winsock2.h>        /* WS2_32.DLL: The newer lib which extends winsock.h */
-
-/*#  include <winsock.h> */  /* WSOCK32.DLL: The old lib, if you activate replace SD_BOTH with 2 in XmlBlasterConnectionUnparsed.c  */
-/* From a mailing list:
-   #ifndef INCL_WINSOCK_API_TYPEDEFS
-   #define INCL_WINSOCK_API_TYPEDEFS 1
-   #endif
-
-   // then include:
-   #include <winsock2.h>
-
-   also any header you include ( mainly a concern in your stdafx.h file ) that may suck in the winsock.h file you should do a:
-
-   #define _WINSOCKAPI_
-*/
-#  define ssize_t signed int
-#else
-#  include <sys/socket.h>
-#  include <netinet/in.h>
-#  include <netdb.h>
-#  include <arpa/inet.h>   /* inet_addr() */
-#endif
-#include <util/msgUtil.h>
-
-#ifdef __cplusplus
-#ifndef XMLBLASTER_C_COMPILE_AS_CPP /* 'g++ -DXMLBLASTER_C_COMPILE_AS_CPP ...' allows to compile the lib as C++ code */
-extern "C" {
-#endif
-#endif
-
-#define  MAX_MSG_LEN 1000000000
-
-/**
- * Settings for MSG_FLAG_POS_TYPE
- */
-typedef enum XMLBLASTER_MSG_TYPE_ENUM {
-   MSG_TYPE_INVOKE = 73,
-   MSG_TYPE_RESPONSE = 82,
-   MSG_TYPE_EXCEPTION = 69
-} XMLBLASTER_MSG_TYPE;
-
-/**
- * Helper struct to hold all necessary informations
- */
-typedef struct SocketDataHolder {
-   size_t msgLen;
-   bool checksum;
-   bool compressed;
-   char type;  /**< XMLBLASTER_MSG_TYPE */
-   char version;
-   char requestId[MAX_REQUESTID_LEN];
-   char methodName[MAX_METHODNAME_LEN];
-   char secretSessionId[MAX_SESSIONID_LEN];
-   size_t dataLenUncompressed;
-   XmlBlasterBlob blob; /**< blob.data is allocated with malloc, you need to free() it yourself, is compressed if marked as such */
-} SocketDataHolder;
-
-#define MSG_LEN_FIELD_LEN 10
-#define MAX_PACKET_SIZE 10*1024
-#define MSG_FLAG_FIELD_LEN 6
-/* static const int MSG_FLAG_FIELD_LEN = 6; */
-enum MSG_FLAG_POS_ENUM {
-   MSG_FLAG_POS_CHECKSUM = MSG_LEN_FIELD_LEN,
-   MSG_FLAG_POS_COMPRESS,
-   MSG_FLAG_POS_TYPE,
-   MSG_FLAG_POS_RESERVED1,
-   MSG_FLAG_POS_RESERVED2,
-   MSG_FLAG_POS_VERSION,
-   MSG_POS_REQESTID
-};
-
-#define XMLBLASTER_SOCKET_VERSION 49
-
-
-extern void closeSocket(int fd);
-extern ssize_t writen(const int fd, const char *ptr, const size_t nbytes);
-extern ssize_t readn(const int fd, char *ptr, const size_t nbytes);
-
-/**
- * Creates a raw blob to push over a socket as described in the protocol.socket requirement. 
- * @param data is returned
- * @param dataLen is returned
- * @see http://www.xmlblaster.org/xmlBlaster/doc/requirements/protocol.socket.html
- * @return The raw message, the caller needs to free() it.
- */
-extern char *encodeSocketMessage(
-              enum XMLBLASTER_MSG_TYPE_ENUM msgType,
-              const char * const requestId,    /**< The unique request ID for each invocation */
-              const char * const methodName,   
-              const char * const secretSessionId,
-              const char *data,
-              size_t dataLen,
-              bool debug,
-              size_t *rawMsgLen);
-Dll_Export BlobHolder encodeMsgUnit(MsgUnit *msgUnit, bool debug);  /* export for C++ embedding */
-Dll_Export BlobHolder encodeMsgUnitArr(MsgUnitArr *msgUnitArr, bool debug);
-Dll_Export bool parseSocketData(int xmlBlasterSocket, const XmlBlasterReadFromSocketFuncHolder *fpHolder, SocketDataHolder *socketDataHolder, XmlBlasterException *exception, bool *stopP, bool udp, bool debug);
-Dll_Export void convertToXmlBlasterException(const XmlBlasterBlob *blob, XmlBlasterException *exception, bool debug);
-Dll_Export void encodeXmlBlasterException(XmlBlasterBlob *blob, const XmlBlasterException *exception, bool debug);
-Dll_Export MsgUnitArr *parseMsgUnitArr(size_t dataLen, char *data);
-Dll_Export QosArr *parseQosArr(size_t dataLen, char *data);
-
-#ifdef __cplusplus
-#ifndef XMLBLASTER_C_COMPILE_AS_CPP
-} /* extern "C" */
-#endif
-#endif
-
-#endif /* XMLBLASTER_SOCKET_H */
-
+/*----------------------------------------------------------------------------
+Name:      xmlBlasterSocket.h
+Project:   xmlBlaster.org
+Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
+Comment:   SOCKET internal header (not included directly by clients)
+Author:    "Marcel Ruff" <xmlBlaster@marcelruff.info>
+-----------------------------------------------------------------------------*/
+#ifndef XMLBLASTER_SOCKET_H
+#define XMLBLASTER_SOCKET_H
+
+#include <stdlib.h>
+
+#ifdef _WINDOWS
+                             /* #if _MSC_VER > 1300 */
+#include <Winsock2.h>        /* WS2_32.DLL: The newer lib which extends winsock.h */
+
+/*#  include <winsock.h> */  /* WSOCK32.DLL: The old lib, if you activate replace SD_BOTH with 2 in XmlBlasterConnectionUnparsed.c  */
+/* From a mailing list:
+   #ifndef INCL_WINSOCK_API_TYPEDEFS
+   #define INCL_WINSOCK_API_TYPEDEFS 1
+   #endif
+
+   // then include:
+   #include <winsock2.h>
+
+   also any header you include ( mainly a concern in your stdafx.h file ) that may suck in the winsock.h file you should do a:
+
+   #define _WINSOCKAPI_
+*/
+#  define ssize_t signed int
+#else
+#  include <sys/types.h>
+#  include <sys/socket.h>
+#  include <netinet/in.h>
+#  include <netdb.h>
+#  include <arpa/inet.h>   /* inet_addr() */
+#endif
+#include <util/msgUtil.h>
+
+#ifdef __cplusplus
+#ifndef XMLBLASTER_C_COMPILE_AS_CPP /* 'g++ -DXMLBLASTER_C_COMPILE_AS_CPP ...' allows to compile the lib as C++ code */
+extern "C" {
+#endif
+#endif
+
+#define  MAX_MSG_LEN 1000000000
+
+/**
+ * Settings for MSG_FLAG_POS_TYPE
+ */
+typedef enum XMLBLASTER_MSG_TYPE_ENUM {
+   MSG_TYPE_INVOKE = 73,
+   MSG_TYPE_RESPONSE = 82,
+   MSG_TYPE_EXCEPTION = 69
+} XMLBLASTER_MSG_TYPE;
+
+/**
+ * Helper struct to hold all necessary informations
+ */
+typedef struct SocketDataHolder {
+   size_t msgLen;
+   bool checksum;
+   bool compressed;
+   char type;  /**< XMLBLASTER_MSG_TYPE */
+   char version;
+   char requestId[MAX_REQUESTID_LEN];
+   char methodName[MAX_METHODNAME_LEN];
+   char secretSessionId[MAX_SESSIONID_LEN];
+   size_t dataLenUncompressed;
+   XmlBlasterBlob blob; /**< blob.data is allocated with malloc, you need to free() it yourself, is compressed if marked as such */
+} SocketDataHolder;
+
+#define MSG_LEN_FIELD_LEN 10
+#define MAX_PACKET_SIZE 10*1024
+#define MSG_FLAG_FIELD_LEN 6
+/* static const int MSG_FLAG_FIELD_LEN = 6; */
+enum MSG_FLAG_POS_ENUM {
+   MSG_FLAG_POS_CHECKSUM = MSG_LEN_FIELD_LEN,
+   MSG_FLAG_POS_COMPRESS,
+   MSG_FLAG_POS_TYPE,
+   MSG_FLAG_POS_RESERVED1,
+   MSG_FLAG_POS_RESERVED2,
+   MSG_FLAG_POS_VERSION,
+   MSG_POS_REQESTID
+};
+
+#define XMLBLASTER_SOCKET_VERSION 49
+
+
+extern void closeSocket(int fd);
+extern ssize_t writen(const int fd, const char *ptr, const size_t nbytes);
+extern ssize_t readn(const int fd, char *ptr, const size_t nbytes);
+
+/**
+ * Creates a raw blob to push over a socket as described in the protocol.socket requirement. 
+ * @param data is returned
+ * @param dataLen is returned
+ * @see http://www.xmlblaster.org/xmlBlaster/doc/requirements/protocol.socket.html
+ * @return The raw message, the caller needs to free() it.
+ */
+extern char *encodeSocketMessage(
+              enum XMLBLASTER_MSG_TYPE_ENUM msgType,
+              const char * const requestId,    /**< The unique request ID for each invocation */
+              const char * const methodName,   
+              const char * const secretSessionId,
+              const char *data,
+              size_t dataLen,
+              bool debug,
+              size_t *rawMsgLen);
+Dll_Export BlobHolder encodeMsgUnit(MsgUnit *msgUnit, bool debug);  /* export for C++ embedding */
+Dll_Export BlobHolder encodeMsgUnitArr(MsgUnitArr *msgUnitArr, bool debug);
+Dll_Export bool parseSocketData(int xmlBlasterSocket, const XmlBlasterReadFromSocketFuncHolder *fpHolder, SocketDataHolder *socketDataHolder, XmlBlasterException *exception, bool *stopP, bool udp, bool debug);
+Dll_Export void convertToXmlBlasterException(const XmlBlasterBlob *blob, XmlBlasterException *exception, bool debug);
+Dll_Export void encodeXmlBlasterException(XmlBlasterBlob *blob, const XmlBlasterException *exception, bool debug);
+Dll_Export MsgUnitArr *parseMsgUnitArr(size_t dataLen, char *data);
+Dll_Export QosArr *parseQosArr(size_t dataLen, char *data);
+
+#ifdef __cplusplus
+#ifndef XMLBLASTER_C_COMPILE_AS_CPP
+} /* extern "C" */
+#endif
+#endif
+
+#endif /* XMLBLASTER_SOCKET_H */
+
Index: src/c/util/msgUtil.c
===================================================================
--- src/c/util/msgUtil.c	(revision 12917)
+++ src/c/util/msgUtil.c	(working copy)
@@ -206,11 +206,129 @@
 #    define HAVE_FUNC_GETHOSTBYNAME_R_5 /* SUN */
 #  elif defined(__alpha)
 #    define HAVE_FUNC_GETHOSTBYNAME_R_3 /* OSF1 V5.1 1885 alpha */
+#  elif defined(__FreeBSD__)
+#    define LOCAL_GETHOSTBYNAME_R /* FreeBSD */
+/* this should actually work for other platforms... so long as they support pthreads */
 #  else
 #    define HAVE_FUNC_GETHOSTBYNAME_R_6 /* Linux */
 #  endif
 #endif
 
+/* a local version of the 6 argument call to gethostbyname_r 
+   this is copied from http://www.cygwin.com/ml/cygwin/2004-04/msg00532.html
+   thanks to Enzo Michelangeli for this
+*/
+
+#if defined(LOCAL_GETHOSTBYNAME_R)
+
+/* since this is a 6 arg format... just define that here */
+#define HAVE_FUNC_GETHOSTBYNAME_R_6
+/* duh? ERANGE value copied from web... */
+#define ERANGE 34
+int gethostbyname_r (const char *name,
+		     struct hostent *ret,
+		     char *buf,
+		     size_t buflen,
+		     struct hostent **result,
+		     int *h_errnop) {
+
+  int hsave;
+  struct hostent *ph;
+  static pthread_mutex_t __mutex = PTHREAD_MUTEX_INITIALIZER;
+  pthread_mutex_lock(&__mutex); /* begin critical area */
+  hsave = h_errno;
+  ph = gethostbyname(name);
+  *h_errnop = h_errno; /* copy h_errno to *h_herrnop */
+
+  if (ph == NULL) {
+    *result = NULL;
+  } else {
+    char **p, **q;
+    char *pbuf;
+    int nbytes=0;
+    int naddr=0, naliases=0;
+    /* determine if we have enough space in buf */
+
+    /* count how many addresses */
+    for (p = ph->h_addr_list; *p != 0; p++) {
+      nbytes += ph->h_length; /* addresses */
+      nbytes += sizeof(*p); /* pointers */
+      naddr++;
+    }
+    nbytes += sizeof(*p); /* one more for the terminating NULL */
+
+    /* count how many aliases, and total length of strings */
+
+    for (p = ph->h_aliases; *p != 0; p++) {
+      nbytes += (strlen(*p)+1); /* aliases */
+      nbytes += sizeof(*p);  /* pointers */
+      naliases++;
+    }
+    nbytes += sizeof(*p); /* one more for the terminating NULL */
+
+    /* here nbytes is the number of bytes required in buffer */
+    /* as a terminator must be there, the minimum value is ph->h_length */
+    if(nbytes > buflen) {
+      *result = NULL;
+      pthread_mutex_unlock(&__mutex); /* end critical area */
+      return ERANGE; /* not enough space in buf!! */
+    }
+
+    /* There is enough space. Now we need to do a deep copy! */
+    /* Allocation in buffer:
+       from [0] to [(naddr-1) * sizeof(*p)]:
+         pointers to addresses
+       at [naddr * sizeof(*p)]:
+         NULL
+       from [(naddr+1) * sizeof(*p)] to [(naddr+naliases) * sizeof(*p)] :
+         pointers to aliases
+       at [(naddr+naliases+1) * sizeof(*p)]:
+         NULL
+       then naddr addresses (fixed length), and naliases aliases (asciiz).
+    */
+
+    *ret = *ph;   /* copy whole structure (not its address!) */
+
+    /* copy addresses */
+    q = (char **)buf; /* pointer to pointers area (type: char **) */
+    ret->h_addr_list = q; /* update pointer to address list */
+    pbuf = buf + ((naddr+naliases+2)*sizeof(*p)); /* skip that area */
+    for (p = ph->h_addr_list; *p != 0; p++) {
+      memcpy(pbuf, *p, ph->h_length); /* copy address bytes */
+      *q++ = pbuf; /* the pointer is the one inside buf... */
+      pbuf += ph->h_length; /* advance pbuf */
+    }
+    *q++ = NULL; /* address list terminator */
+
+    /* copy aliases */
+
+    ret->h_aliases = q; /* update pointer to aliases list */
+    for (p = ph->h_aliases; *p != 0; p++) {
+      strcpy(pbuf, *p); /* copy alias strings */
+      *q++ = pbuf; /* the pointer is the one inside buf... */
+      pbuf += strlen(*p); /* advance pbuf */
+      *pbuf++ = 0; /* string terminator */
+    }
+    *q++ = NULL; /* terminator */
+
+    strcpy(pbuf, ph->h_name); /* copy alias strings */
+    ret->h_name = pbuf;
+    pbuf += strlen(ph->h_name); /* advance pbuf */
+    *pbuf++ = 0; /* string terminator */
+
+    *result = ret;  /* and let *result point to structure */
+
+  }
+  h_errno = hsave;  /* restore h_errno */
+
+  pthread_mutex_unlock(&__mutex); /* end critical area */
+
+  return (*result == NULL);
+
+}
+
+#endif /* LOCAL_GETHOSTBYNAME_R */
+
 /**
  * Thread safe host lookup. 
  * NOTE: If the return is not NULL you need to free(*tmphstbuf)
Index: src/c/util/basicDefs.h
===================================================================
--- src/c/util/basicDefs.h	(revision 12917)
+++ src/c/util/basicDefs.h	(working copy)
@@ -55,7 +55,15 @@
   typedef __int16 int16_t;
 #else
 
-# include<stdint.h>  /*-> C99:  uint64_t etc. */
+/* FreeBSD uses inttypes.h, not stdint.h.  Boost's lib suggests
+   this should read  defined(__FreeBSD__) || defined(__IBMCPP__)
+*/
+# if defined(__FreeBSD__) 
+#   include <inttypes.h>
+# else
+#   include <stdint.h>  /*-> C99:  uint64_t etc. */
+# endif
+
 # define PRINTF_PREFIX_INT64_T "%lld"
 #endif
 /*#define INT64_DIGITLEN_MAX 19  Size of a max int64_t dumped to a string: LLONG_MAX from limits.h 9223372036854775807 */
Index: build.properties
===================================================================
--- build.properties	(revision 12917)
+++ build.properties	(working copy)
@@ -87,9 +87,9 @@
 # Compile the SOCKET plugin only, without CORBA.
 # Additionally choose a Xerces XML setting below.
 # See http://www.xmlblaster.org/xmlBlaster/doc/requirements/client.cpp.socket.html
-#COMPILE_SOCKET_PLUGIN = 1
-#COMPILE_CORBA_PLUGIN  = 0
-#corba.product         = NONE
+COMPILE_SOCKET_PLUGIN = 1
+COMPILE_CORBA_PLUGIN  = 0
+corba.product         = NONE
 #------------------------------------------------------------------------------
 
 #------------------------------------------------------------------------------
@@ -200,10 +200,6 @@
 #corba.product = ORBIX
 #CORBACPP_HOME = C:/Dev/IONA
 #CORBACPP_VER  = 5.1
-# Copy
-#  xerces\Build\Win32\VC7\debug (or release) xercex-c_2.lib xerces-c_2D.lib
-# to
-#  %XMLCPP_HOME%\lib
 #------------------------------------------------------------------------------
 
 #------------------------------------------------------------------------------
@@ -254,3 +250,8 @@
 # to your PATH environment
 #------------------------------------------------------------------------------
 
+XMLCPP_HOME   = /usr/local
+XMLCPP_VER    =
+thread.impl   = BOOST
+
+use-gcc = 1
