diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-02-24 01:28:21 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-02-24 01:28:21 (GMT) |
commit | f30e7608484d48ec9a3f3073f4b7a351a44d90a9 (patch) | |
tree | 48b306d35d39e00747cd3c32e8a6cf51c1d2ed82 /Utilities/cmxmlrpc | |
parent | a8770ccc193371d19f16bad6e4cf7ef6932a4ad5 (diff) | |
download | CMake-f30e7608484d48ec9a3f3073f4b7a351a44d90a9.zip CMake-f30e7608484d48ec9a3f3073f4b7a351a44d90a9.tar.gz CMake-f30e7608484d48ec9a3f3073f4b7a351a44d90a9.tar.bz2 |
COMP: Several Windows fixes
Diffstat (limited to 'Utilities/cmxmlrpc')
-rw-r--r-- | Utilities/cmxmlrpc/CMakeLists.txt | 13 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/casprintf.c | 35 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/casprintf.h | 19 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/inline.h | 19 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/linklist.h | 193 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc.h | 26 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_client.h | 2 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_client_int.h | 3 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_config.h.in | 41 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_curl_transport.c | 7 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_data.c | 2 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_pthreads.h | 6 | ||||
-rw-r--r-- | Utilities/cmxmlrpc/xmlrpc_support.c | 4 |
13 files changed, 343 insertions, 27 deletions
diff --git a/Utilities/cmxmlrpc/CMakeLists.txt b/Utilities/cmxmlrpc/CMakeLists.txt index eb41764..7a7f823 100644 --- a/Utilities/cmxmlrpc/CMakeLists.txt +++ b/Utilities/cmxmlrpc/CMakeLists.txt @@ -1,5 +1,7 @@ PROJECT(XMLRPC) +INCLUDE_REGULAR_EXPRESSION("^.*$") + # Include all the necessary files for macros SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake") @@ -43,7 +45,8 @@ SET(DIRECTORY_SEPARATOR "/") INCLUDE_DIRECTORIES( "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" - "${CMAKE_EXPAT_INCLUDES}" + ${CMAKE_EXPAT_INCLUDES} + ${CMAKE_CURL_INCLUDES} ) CONFIGURE_FILE( @@ -66,11 +69,19 @@ SET(xmlrpc_SRCS xmlrpc_parse.c xmlrpc_registry.c xmlrpc_serialize.c + xmlrpc_curl_transport.c #xmlrpc_server_abyss.c xmlrpc_struct.c xmlrpc_strutil.c xmlrpc_support.c xmlrpc_utf8.c + casprintf.c ) +IF(WIN32) + SET(xmlrpc_SRCS ${xmlrpc_SRCS} + win32_pthreads.c + ) +ENDIF(WIN32) ADD_LIBRARY(cmXMLRPC ${xmlrpc_SRCS}) +TARGET_LINK_LIBRARIES(cmXMLRPC ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_CURL_LIBRARIES}) diff --git a/Utilities/cmxmlrpc/casprintf.c b/Utilities/cmxmlrpc/casprintf.c new file mode 100644 index 0000000..1fcc774 --- /dev/null +++ b/Utilities/cmxmlrpc/casprintf.c @@ -0,0 +1,35 @@ +#define _GNU_SOURCE +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> + +#include "xmlrpc_config.h" /* For HAVE_ASPRINTF */ +#include "casprintf.h" + +void GNU_PRINTF_ATTR(2,3) +casprintf(const char ** const retvalP, const char * const fmt, ...) { + + char *retval; + + va_list varargs; /* mysterious structure used by variable arg facility */ + + va_start(varargs, fmt); /* start up the mysterious variable arg facility */ + +#if HAVE_ASPRINTF + vasprintf(&retval, fmt, varargs); +#else + retval = malloc(8192); + vsnprintf(retval, 8192, fmt, varargs); +#endif + *retvalP = retval; +} + + + +void +strfree(const char * const string) { + free((void *)string); +} + + + diff --git a/Utilities/cmxmlrpc/casprintf.h b/Utilities/cmxmlrpc/casprintf.h new file mode 100644 index 0000000..eab336a --- /dev/null +++ b/Utilities/cmxmlrpc/casprintf.h @@ -0,0 +1,19 @@ +#ifndef CASPRINTF_H_INCLUDED + +/* GNU_PRINTF_ATTR lets the GNU compiler check pm_message() and pm_error() + calls to be sure the arguments match the format string, thus preventing + runtime segmentation faults and incorrect messages. +*/ +#ifdef __GNUC__ +#define GNU_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b))) +#else +#define GNU_PRINTF_ATTR(a,b) +#endif + +void GNU_PRINTF_ATTR(2,3) +casprintf(const char ** const retvalP, const char * const fmt, ...); + +void +strfree(const char * const string); + +#endif diff --git a/Utilities/cmxmlrpc/inline.h b/Utilities/cmxmlrpc/inline.h new file mode 100644 index 0000000..f90032b --- /dev/null +++ b/Utilities/cmxmlrpc/inline.h @@ -0,0 +1,19 @@ +#ifndef XMLRPC_INLINE_H_INCLUDED +#define XMLRPC_INLINE_H_INCLUDED + +/* Xmlrpc-c uses __inline__ to declare functions that should be + compiled as inline code. Some compilers, e.g. GNU, recognize the + __inline__ keyword. +*/ +#ifndef __GNUC__ +#ifndef __inline__ +#ifdef __sgi +#define __inline__ __inline +#else +#define __inline__ +#endif +#endif +#endif + + +#endif diff --git a/Utilities/cmxmlrpc/linklist.h b/Utilities/cmxmlrpc/linklist.h new file mode 100644 index 0000000..f6f2641 --- /dev/null +++ b/Utilities/cmxmlrpc/linklist.h @@ -0,0 +1,193 @@ +#ifndef LINKLIST_H_INCLUDED +#define LINKLIST_H_INCLUDED + +#include "inline.h" + +struct list_head { +/*---------------------------------------------------------------------------- + This is a header for an element of a doubly linked list, or an anchor + for such a list. + + itemP == NULL means it's an anchor; otherwise it's a header. + + Initialize a list header with list_init_header(). You don't have to + do anything to terminate a list header. + + Initialize an anchor with list_make_emtpy(). You don't have to do anything + to terminate a list header. +-----------------------------------------------------------------------------*/ + struct list_head * nextP; + /* For a header, this is the address of the list header for + the next element in the list. If there is no next element, + it points to the anchor. If the header is not in a list at + all, it is NULL. + + For an anchor, it is the address of the list header of the + first element. If the list is empty, it points to the + anchor itself. + */ + struct list_head * prevP; + /* For a header, this is the address of the list header for + the previous element in the list. If there is no previous element, + it points to the anchor. If the header is not in a list at + all, it is NULL. + + For an anchor, it is the address of the list header of the + last element. If the list is empty, it points to the + anchor itself. + */ + void * itemP; + /* For a header, this is the address of the list element to which it + belongs. For an anchor, this is NULL. + */ +}; + +static __inline__ void +list_init_header(struct list_head * const headerP, + void * const itemP) { + + headerP->prevP = NULL; + headerP->nextP = NULL; + headerP->itemP = itemP; +} + + + +static __inline__ int +list_is_linked(struct list_head * headerP) { + return headerP->prevP != NULL; +} + + + +static __inline__ int +list_is_empty(struct list_head * const anchorP) { + return anchorP->nextP == anchorP; +} + + + +static __inline__ unsigned int +list_count(struct list_head * const anchorP) { + unsigned int count; + + struct list_head * p; + + for (p = anchorP->nextP, count = 0; + p != anchorP; + p = p->nextP, ++count); + + return count; +} + + + +static __inline__ void +list_make_empty(struct list_head * const anchorP) { + anchorP->prevP = anchorP; + anchorP->nextP = anchorP; + anchorP->itemP = NULL; +} + +static __inline__ void +list_insert_after(struct list_head * const beforeHeaderP, + struct list_head * const newHeaderP) { + newHeaderP->prevP = beforeHeaderP; + newHeaderP->nextP = beforeHeaderP->nextP; + + beforeHeaderP->nextP = newHeaderP; + newHeaderP->nextP->prevP = newHeaderP; +} + + + +static __inline__ void +list_add_tail(struct list_head * const anchorP, + struct list_head * const headerP) { + list_insert_after(anchorP->prevP, headerP); +} + + + +static __inline__ void +list_add_head(struct list_head * const anchorP, + struct list_head * const headerP) { + list_insert_after(anchorP, headerP); +} + + + +static __inline__ void +list_remove(struct list_head * const headerP) { + headerP->prevP->nextP = headerP->nextP; + headerP->nextP->prevP = headerP->prevP; + headerP->prevP = NULL; + headerP->nextP = NULL; +} + + + +static __inline__ struct list_head * +list_remove_head(struct list_head * const anchorP) { + struct list_head * retval; + + if (list_is_empty(anchorP)) + retval = NULL; + else { + retval = anchorP->nextP; + list_remove(retval); + } + return retval; +} + + + +static __inline__ struct list_head * +list_remove_tail(struct list_head * const anchorP) { + struct list_head * retval; + + if (list_is_empty(anchorP)) + retval = NULL; + else { + retval = anchorP->prevP; + list_remove(retval); + } + return retval; +} + + + +static __inline__ void * +list_foreach(struct list_head * const anchorP, + void * functionP(struct list_head *, void *), + void * const context) { + + struct list_head * p; + struct list_head * nextP; + void * result; + + for (p = anchorP->nextP, nextP = p->nextP, result=NULL; + p != anchorP && result == NULL; + p = nextP, nextP = p->nextP) + result = (*functionP)(p, context); + + return result; +} + + + +static __inline__ void +list_append(struct list_head * const newAnchorP, + struct list_head * const baseAnchorP) { + + if (!list_is_empty(newAnchorP)) { + baseAnchorP->prevP->nextP = newAnchorP->nextP; + newAnchorP->nextP->prevP = baseAnchorP->prevP; + newAnchorP->prevP->nextP = baseAnchorP; + baseAnchorP->prevP = newAnchorP->prevP; + } +} + +#endif + + diff --git a/Utilities/cmxmlrpc/xmlrpc.h b/Utilities/cmxmlrpc/xmlrpc.h index e32730a..d7831ac 100644 --- a/Utilities/cmxmlrpc/xmlrpc.h +++ b/Utilities/cmxmlrpc/xmlrpc.h @@ -279,7 +279,7 @@ typedef struct _xmlrpc_mem_block { } xmlrpc_mem_block; /* Allocate a new xmlrpc_mem_block. */ -xmlrpc_mem_block* xmlrpc_mem_block_new (xmlrpc_env* env, size_t size); +xmlrpc_mem_block* xmlrpc_mem_block_new (xmlrpc_env* const env, size_t const size); /* Destroy an existing xmlrpc_mem_block, and everything it contains. */ void xmlrpc_mem_block_free (xmlrpc_mem_block* block); @@ -302,11 +302,11 @@ xmlrpc_mem_block_contents(const xmlrpc_mem_block * const block); /* Resize an xmlrpc_mem_block, preserving as much of the contents as ** possible. */ void xmlrpc_mem_block_resize - (xmlrpc_env* env, xmlrpc_mem_block* block, size_t size); + (xmlrpc_env* const env, xmlrpc_mem_block* const block, size_t const size); /* Append data to an existing xmlrpc_mem_block. */ void xmlrpc_mem_block_append - (xmlrpc_env* env, xmlrpc_mem_block* block, void *data, size_t len); + (xmlrpc_env* const env, xmlrpc_mem_block* const block, void *const data, size_t const len); #define XMLRPC_MEMBLOCK_NEW(type,env,size) \ xmlrpc_mem_block_new((env), sizeof(type) * (size)) @@ -387,11 +387,11 @@ xmlrpc_abort_if_array_bad(xmlrpc_value * const arrayP); xmlrpc_abort_if_array_bad(val) /* Increment the reference count of an xmlrpc_value. */ -extern void xmlrpc_INCREF (xmlrpc_value* value); +extern void xmlrpc_INCREF (xmlrpc_value* const value); /* Decrement the reference count of an xmlrpc_value. If there ** are no more references, free it. */ -extern void xmlrpc_DECREF (xmlrpc_value* value); +extern void xmlrpc_DECREF (xmlrpc_value* const value); /* Get the type of an XML-RPC value. */ extern xmlrpc_type xmlrpc_value_type (xmlrpc_value* value); @@ -465,9 +465,9 @@ xmlrpc_array_size(xmlrpc_env * const env, ** Increments the reference count of 'value' if no fault occurs. ** Sets XMLRPC_TYPE_ERROR if 'array' is not an array. */ extern void -xmlrpc_array_append_item (xmlrpc_env* env, - xmlrpc_value* array, - xmlrpc_value* value); +xmlrpc_array_append_item (xmlrpc_env* const env, + xmlrpc_value* const array, + xmlrpc_value* const value); void xmlrpc_array_read_item(xmlrpc_env * const envP, @@ -620,11 +620,11 @@ xmlrpc_struct_read_member(xmlrpc_env * const envP, Deprecated. */ void -xmlrpc_struct_get_key_and_value(xmlrpc_env * env, - xmlrpc_value * strct, - int index, - xmlrpc_value ** out_keyval, - xmlrpc_value ** out_value); +xmlrpc_struct_get_key_and_value(xmlrpc_env * const env, + xmlrpc_value * const strct, + int const index, + xmlrpc_value ** const out_keyval, + xmlrpc_value ** const out_value); /*========================================================================= diff --git a/Utilities/cmxmlrpc/xmlrpc_client.h b/Utilities/cmxmlrpc/xmlrpc_client.h index 1460c74..60c98ba 100644 --- a/Utilities/cmxmlrpc/xmlrpc_client.h +++ b/Utilities/cmxmlrpc/xmlrpc_client.h @@ -224,7 +224,7 @@ xmlrpc_client_event_loop_finish_asynch(void); /* Finish all outstanding asynchronous calls. */ extern void -xmlrpc_client_event_loop_finish_asynch_timeout(unsigned long milliseconds); +xmlrpc_client_event_loop_finish_asynch_timeout(timeout_t const milliseconds); diff --git a/Utilities/cmxmlrpc/xmlrpc_client_int.h b/Utilities/cmxmlrpc/xmlrpc_client_int.h index 77d491e..c94a1c7 100644 --- a/Utilities/cmxmlrpc/xmlrpc_client_int.h +++ b/Utilities/cmxmlrpc/xmlrpc_client_int.h @@ -28,9 +28,6 @@ extern xmlrpc_server_info * xmlrpc_server_info_copy(xmlrpc_env *env, xmlrpc_server_info *aserver); -/* A timeout in milliseconds. */ -typedef unsigned long timeout_t; - /*========================================================================= ** Transport Implementation functions. **========================================================================= diff --git a/Utilities/cmxmlrpc/xmlrpc_config.h.in b/Utilities/cmxmlrpc/xmlrpc_config.h.in index 7e74253..8cf9553 100644 --- a/Utilities/cmxmlrpc/xmlrpc_config.h.in +++ b/Utilities/cmxmlrpc/xmlrpc_config.h.in @@ -35,12 +35,43 @@ We could make 'configure' simply do a trial compile to figure out which one, but for now, this approximation is easier: */ -#ifndef __GNUC__ -#ifndef __inline__ -#ifdef __sgi -#define __inline__ __inline +#ifdef _WIN32 +# define __inline__ __inline #else -#define __inline__ +# ifndef __GNUC__ +# ifndef __inline__ +# ifdef __sgi +# define __inline__ __inline +# else +# define __inline__ +# endif +# endif +# endif #endif + +/* A timeout in milliseconds. */ +typedef unsigned long timeout_t; + +#if !defined(WIN32) && defined(_WIN32) +# define WIN32 #endif +#if defined(WIN32) +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #if !defined (vsnprintf) +#define vsnprintf _vsnprintf + #endif + #if !defined (snprintf) +#define snprintf _snprintf + #endif +#include <time.h> +#include <winsock2.h> +#include <direct.h> /* for _chdir() */ + + +__inline BOOL setenv(const char* name, const char* value, int i) +{ + return (SetEnvironmentVariable(name, value) != 0) ? TRUE : FALSE; +} #endif diff --git a/Utilities/cmxmlrpc/xmlrpc_curl_transport.c b/Utilities/cmxmlrpc/xmlrpc_curl_transport.c index 37d3dea..0852d28 100644 --- a/Utilities/cmxmlrpc/xmlrpc_curl_transport.c +++ b/Utilities/cmxmlrpc/xmlrpc_curl_transport.c @@ -22,12 +22,16 @@ #include <string.h> #include <stdlib.h> #include <errno.h> -#include <pthread.h> +#include "xmlrpc_pthreads.h" #include <curl/curl.h> #include <curl/types.h> #include <curl/easy.h> +#ifndef WIN32 +# include <unistd.h> +#endif + #if defined (WIN32) && defined(_DEBUG) # include <crtdbg.h> # define new DEBUG_NEW @@ -348,7 +352,6 @@ destroyCurlTransaction(curlTransaction * const curlTransactionP) { } -#include <unistd.h> static void performCurlTransaction(xmlrpc_env * const envP, curlTransaction * const curlTransactionP) { diff --git a/Utilities/cmxmlrpc/xmlrpc_data.c b/Utilities/cmxmlrpc/xmlrpc_data.c index 76713c9..0ba09a9 100644 --- a/Utilities/cmxmlrpc/xmlrpc_data.c +++ b/Utilities/cmxmlrpc/xmlrpc_data.c @@ -680,7 +680,7 @@ mkStructFromVal(xmlrpc_env * const envP, static void getValue(xmlrpc_env * const envP, const char** const format, - va_list * args, + va_list * const args, xmlrpc_value ** const valPP); diff --git a/Utilities/cmxmlrpc/xmlrpc_pthreads.h b/Utilities/cmxmlrpc/xmlrpc_pthreads.h index 81b0e80..dfb29c7 100644 --- a/Utilities/cmxmlrpc/xmlrpc_pthreads.h +++ b/Utilities/cmxmlrpc/xmlrpc_pthreads.h @@ -23,11 +23,14 @@ ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. */ +#ifndef xmlrpc_pthreads_h_ +#define xmlrpc_pthreads_h_ + #ifndef WIN32 # define _REENTRANT # include <pthread.h> #elif defined (WIN32) - +/*typedef PVOID HANDLE; */ typedef HANDLE pthread_t; typedef CRITICAL_SECTION pthread_mutex_t; @@ -64,3 +67,4 @@ extern int pthread_mutex_destroy(pthread_mutex_t *mp); #endif +#endif diff --git a/Utilities/cmxmlrpc/xmlrpc_support.c b/Utilities/cmxmlrpc/xmlrpc_support.c index f69b7e2..1708e7a 100644 --- a/Utilities/cmxmlrpc/xmlrpc_support.c +++ b/Utilities/cmxmlrpc/xmlrpc_support.c @@ -30,6 +30,10 @@ #include <string.h> #include <ctype.h> +#ifdef WIN32 +# define vsnprintf _vsnprintf +#endif + #include "xmlrpc.h" #include "xmlrpc_int.h" |