add xmlrpc-c 1.03.14 to in tree libs

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3772 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris
2006-12-21 03:57:49 +00:00
parent 6d9679b164
commit 3abb7730b2
338 changed files with 98032 additions and 2 deletions

View File

@@ -0,0 +1,18 @@
#ifndef BOOL_H_INCLUDED
#define BOOL_H_INCLUDED
#ifndef TRUE
#define TRUE (1)
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef __cplusplus
#ifndef HAVE_BOOL
#define HAVE_BOOL
typedef int bool;
#endif
#endif
#endif

View File

@@ -0,0 +1,27 @@
#ifndef CASPRINTF_H_INCLUDED
#define CASPRINTF_H_INCLUDED
#include <stdarg.h>
/* GNU_PRINTF_ATTR lets the GNU compiler check printf-type
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
cvasprintf(const char ** const retvalP,
const char * const fmt,
va_list varargs);
void GNU_PRINTF_ATTR(2,3)
casprintf(const char ** const retvalP, const char * const fmt, ...);
void
strfree(const char * const string);
#endif

View File

@@ -0,0 +1,59 @@
#ifndef CMDLINE_PARSER_H
#define CMDLINE_PARSER_H
/*
NOTE NOTE NOTE: cmd_getOptionValueString() and
cmd_getArgument() return malloc'ed memory (and abort the program if
out of memory). You must free it.
*/
enum optiontype {OPTTYPE_FLAG, OPTTYPE_INT, OPTTYPE_UINT, OPTTYPE_STRING};
struct cmdlineParserCtl;
typedef struct cmdlineParserCtl * cmdlineParser;
void
cmd_processOptions(cmdlineParser const cpP,
int const argc,
const char ** const argv,
const char ** const errorP);
cmdlineParser
cmd_createOptionParser(void);
void
cmd_destroyOptionParser(cmdlineParser const cpP);
void
cmd_defineOption(cmdlineParser const cpP,
const char * const name,
enum optiontype const type);
int
cmd_optionIsPresent(cmdlineParser const cpP,
const char * const name);
unsigned int
cmd_getOptionValueUint(cmdlineParser const cpP,
const char * const name);
int
cmd_getOptionValueInt(cmdlineParser const cpP,
const char * const name);
const char *
cmd_getOptionValueString(cmdlineParser const cpP,
const char * const name);
unsigned int
cmd_argumentCount(cmdlineParser const cpP);
const char *
cmd_getArgument(cmdlineParser const cpP,
unsigned int const argNumber);
#endif

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,94 @@
/* These are some dynamic memory allocation facilities. They are essentially
an extension to C, as they do allocations with a cognizance of C
variables. You can use them to make C read more like a high level
language.
Before including this, you must define an __inline__ macro if your
compiler doesn't recognize it as a keyword.
*/
#ifndef MALLOCVAR_INCLUDED
#define MALLOCVAR_INCLUDED
#include "xmlrpc_config.h"
#include <limits.h>
#include <stdlib.h>
static __inline__ void
mallocProduct(void ** const resultP,
unsigned int const factor1,
unsigned int const factor2) {
/*----------------------------------------------------------------------------
malloc a space whose size in bytes is the product of 'factor1' and
'factor2'. But if that size cannot be represented as an unsigned int,
return NULL without allocating anything. Also return NULL if the malloc
fails.
If either factor is zero, malloc a single byte.
Note that malloc() actually takes a size_t size argument, so the
proper test would be whether the size can be represented by size_t,
not unsigned int. But there is no reliable indication available to
us, like UINT_MAX, of what the limitations of size_t are. We
assume size_t is at least as expressive as unsigned int and that
nobody really needs to allocate more than 4GB of memory.
-----------------------------------------------------------------------------*/
if (factor1 == 0 || factor2 == 0)
*resultP = malloc(1);
else {
if (UINT_MAX / factor2 < factor1)
*resultP = NULL;
else
*resultP = malloc(factor1 * factor2);
}
}
static __inline__ void
reallocProduct(void ** const blockP,
unsigned int const factor1,
unsigned int const factor2) {
if (UINT_MAX / factor2 < factor1)
*blockP = NULL;
else
*blockP = realloc(*blockP, factor1 * factor2);
}
#define MALLOCARRAY(arrayName, nElements) do { \
void * array; \
mallocProduct(&array, nElements, sizeof(arrayName[0])); \
arrayName = array; \
} while (0)
#define REALLOCARRAY(arrayName, nElements) \
reallocProduct((void **)&arrayName, nElements, sizeof(arrayName[0]))
#define MALLOCARRAY_NOFAIL(arrayName, nElements) \
do { \
MALLOCARRAY(arrayName, nElements); \
if ((arrayName) == NULL) \
abort(); \
} while(0)
#define REALLOCARRAY_NOFAIL(arrayName, nElements) \
do { \
REALLOCARRAY(arrayName, nElements); \
if ((arrayName) == NULL) \
abort(); \
} while(0)
#define MALLOCVAR(varName) \
varName = malloc(sizeof(*varName))
#define MALLOCVAR_NOFAIL(varName) \
do {if ((varName = malloc(sizeof(*varName))) == NULL) abort();} while(0)
#endif

View File

@@ -0,0 +1,68 @@
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE. */
#ifndef PTHREADX_H_INCLUDED
#define PTHREADX_H_INCLUDED
#ifndef WIN32
# define _REENTRANT
# include <pthread.h>
#elif defined (WIN32)
typedef HANDLE pthread_t;
typedef CRITICAL_SECTION pthread_mutex_t;
#define PTHREAD_MUTEX_INITIALIZER NULL
//usage: pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
typedef
struct {
int attrs; //currently unused. placeholder.
} pthread_attr_t;
typedef
struct {
int attrs; //currently unused. placeholder.
} pthread_mutexattr_t;
//typedef void * (*pthread_func)(void *);
typedef unsigned ( __stdcall *pthread_func )( void * );
extern int pthread_create(pthread_t *new_thread_ID,
const pthread_attr_t *attr,
pthread_func start_func, void *arg);
extern int pthread_cancel(pthread_t target_thread);
extern int pthread_join(pthread_t target_thread, void **status);
extern int pthread_detach(pthread_t target_thread);
extern int pthread_mutex_init(pthread_mutex_t *mp,
const pthread_mutexattr_t *attr);
extern int pthread_mutex_lock(pthread_mutex_t *mp);
extern int pthread_mutex_unlock(pthread_mutex_t *mp);
extern int pthread_mutex_destroy(pthread_mutex_t *mp);
#endif /* WIN32 */
#endif

View File

@@ -0,0 +1,15 @@
#ifndef SSTRING_H_INCLUDED
#define SSTRING_H_INCLUDED
/* This file contains string functions that are cognizant of the
declared size of the destination data structure.
*/
/* Copy string pointed by B to array A with size checking. */
#define SSTRCPY(A,B) \
(strncpy((A), (B), sizeof(A)), *((A)+sizeof(A)-1) = '\0')
#define SSTRCMP(A,B) \
(strncmp((A), (B), sizeof(A)))
#endif