mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 01:26:58 +00:00
merged new xmlrpc-c revision 1472 from https://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/trunk
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8545 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
File diff suppressed because it is too large
Load Diff
28
libs/xmlrpc-c/include/xmlrpc-c/abyss_opensslsock.h
Normal file
28
libs/xmlrpc-c/include/xmlrpc-c/abyss_opensslsock.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* This is just a sub-file for abyss.h */
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
struct abyss_openssl_chaninfo {
|
||||
/* TODO: figure out useful information to put in here.
|
||||
Maybe client IP address and port. Maybe authenticated host name.
|
||||
Maybe authentication level.
|
||||
Maybe a certificate.
|
||||
*/
|
||||
int dummy;
|
||||
};
|
||||
|
||||
void
|
||||
ChanSwitchOpensslCreate(unsigned short const portNumber,
|
||||
TChanSwitch ** const chanSwitchPP,
|
||||
const char ** const errorP);
|
||||
|
||||
void
|
||||
ChanSwitchOpensslCreateFd(int const fd,
|
||||
TChanSwitch ** const chanSwitchPP,
|
||||
const char ** const errorP);
|
||||
|
||||
void
|
||||
ChannelOpensslCreateSsl(SSL * const sslP,
|
||||
TChannel ** const channelPP,
|
||||
struct abyss_openssl_chaninfo ** const channelInfoPP,
|
||||
const char ** const errorP);
|
42
libs/xmlrpc-c/include/xmlrpc-c/abyss_unixsock.h
Normal file
42
libs/xmlrpc-c/include/xmlrpc-c/abyss_unixsock.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* This is just a sub-file for abyss.h */
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
struct abyss_unix_chaninfo {
|
||||
size_t peerAddrLen;
|
||||
struct sockaddr peerAddr;
|
||||
};
|
||||
|
||||
void
|
||||
ChanSwitchUnixCreate(unsigned short const portNumber,
|
||||
TChanSwitch ** const chanSwitchPP,
|
||||
const char ** const errorP);
|
||||
|
||||
void
|
||||
ChanSwitchUnixCreateFd(int const fd,
|
||||
TChanSwitch ** const chanSwitchPP,
|
||||
const char ** const errorP);
|
||||
|
||||
void
|
||||
ChannelUnixCreateFd(int const fd,
|
||||
TChannel ** const channelPP,
|
||||
struct abyss_unix_chaninfo ** const channelInfoPP,
|
||||
const char ** const errorP);
|
||||
|
||||
void
|
||||
ChannelUnixGetPeerName(TChannel * const channelP,
|
||||
struct sockaddr ** const sockaddrPP,
|
||||
size_t * const sockaddrLenP,
|
||||
const char ** const errorP);
|
||||
|
||||
void
|
||||
SocketUnixCreateFd(int const fd,
|
||||
TSocket ** const socketPP);
|
||||
|
||||
typedef int TOsSocket;
|
||||
/* TOsSocket is the type of a conventional socket offered by our OS.
|
||||
This is for backward compatibility; everyone should use TChanSwitch
|
||||
and TChannel instead today.
|
||||
*/
|
||||
|
||||
|
27
libs/xmlrpc-c/include/xmlrpc-c/abyss_winsock.h
Normal file
27
libs/xmlrpc-c/include/xmlrpc-c/abyss_winsock.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/* This is just a sub-file for abyss.h */
|
||||
|
||||
#include <winsock.h>
|
||||
|
||||
struct abyss_win_chaninfo {
|
||||
size_t peerAddrLen;
|
||||
struct sockaddr peerAddr;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
ChanSwitchWinCreate(unsigned short const portNumber,
|
||||
TChanSwitch ** const chanSwitchPP,
|
||||
const char ** const errorP);
|
||||
|
||||
void
|
||||
ChanSwitchWinCreateWinsock(SOCKET const winsock,
|
||||
TChanSwitch ** const chanSwitchPP,
|
||||
const char ** const errorP);
|
||||
|
||||
void
|
||||
ChannelWinCreateWinsock(SOCKET const fd,
|
||||
TChannel ** const channelPP,
|
||||
struct abyss_win_chaninfo ** const channelInfoPP,
|
||||
const char ** const errorP);
|
||||
|
||||
typedef SOCKET TOsSocket;
|
@@ -6,8 +6,11 @@
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <xmlrpc-c/util.h>
|
||||
#include <xmlrpc-c/config.h>
|
||||
/* Defines XMLRPC_HAVE_WCHAR, XMLRPC_INT64 */
|
||||
|
||||
#ifdef HAVE_UNICODE_WCHAR
|
||||
#if XMLRPC_HAVE_WCHAR
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
@@ -17,16 +20,26 @@ extern "C" {
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** Typedefs
|
||||
**=========================================================================
|
||||
** We define names for these types, because they may change from platform
|
||||
** to platform.
|
||||
** Version of libxmlrpc
|
||||
**=======================================================================*/
|
||||
extern unsigned int const xmlrpc_version_major;
|
||||
extern unsigned int const xmlrpc_version_minor;
|
||||
extern unsigned int const xmlrpc_version_point;
|
||||
|
||||
/*=========================================================================
|
||||
** C types equivalent to XML-RPC types
|
||||
**=======================================================================*/
|
||||
|
||||
/* We define names for these types, because they may change from platform
|
||||
to platform.
|
||||
*/
|
||||
|
||||
typedef signed int xmlrpc_int;
|
||||
/* An integer of the type defined by XML-RPC <int>; i.e. 32 bit */
|
||||
typedef signed int xmlrpc_int32;
|
||||
/* An integer of the type defined by XML-RPC <int4>; i.e. 32 bit */
|
||||
typedef XMLRPC_INT32 xmlrpc_int32;
|
||||
/* An integer of the type defined by XML-RPC <i4>; i.e. 32 bit */
|
||||
typedef XMLRPC_INT64 xmlrpc_int64;
|
||||
/* An integer of the type defined by "XML-RPC" <i8>; i.e. 64 bit */
|
||||
typedef int xmlrpc_bool;
|
||||
/* A boolean (of the type defined by XML-RPC <boolean>, but there's
|
||||
really only one kind)
|
||||
@@ -38,296 +51,19 @@ typedef double xmlrpc_double;
|
||||
for mathematical completeness.
|
||||
*/
|
||||
|
||||
#define XMLRPC_INT32_MAX (2147483647)
|
||||
/* xmlrpc_socket is just for backward compatibility, in case someone decided
|
||||
to use this in user code. New code should use the native type for a
|
||||
socket (e.g. int or SOCKET). (We stopped using this because for winsock
|
||||
users, we would have to #include <winsock.h> in every file that
|
||||
#includes <xmlrpc-c/base.h> and we don't want that).
|
||||
*/
|
||||
typedef int xmlrpc_socket;
|
||||
|
||||
#define XMLRPC_INT32_MAX 0x7fffffff
|
||||
#define XMLRPC_INT32_MIN (-XMLRPC_INT32_MAX - 1)
|
||||
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** C struct size computations
|
||||
**=======================================================================*/
|
||||
|
||||
/* Use XMLRPC_STRUCT_MEMBER_SIZE() to determine how big a structure is
|
||||
up to and including a specified member. E.g. if you have
|
||||
struct mystruct {int red; int green; int blue};, then
|
||||
XMLRPC_STRUCT_MEMBER_SIZE(mystruct, green) is (8).
|
||||
*/
|
||||
|
||||
#define _XMLRPC_STRUCT_MEMBER_OFFSET(TYPE, MBRNAME) \
|
||||
((unsigned long)(char*)&((TYPE *)0)->MBRNAME)
|
||||
#define _XMLRPC_STRUCT_MEMBER_SIZE(TYPE, MBRNAME) \
|
||||
sizeof(((TYPE *)0)->MBRNAME)
|
||||
#define XMLRPC_STRUCTSIZE(TYPE, MBRNAME) \
|
||||
(_XMLRPC_STRUCT_MEMBER_OFFSET(TYPE, MBRNAME) + \
|
||||
_XMLRPC_STRUCT_MEMBER_SIZE(TYPE, MBRNAME))
|
||||
|
||||
/*=========================================================================
|
||||
** Assertions and Debugging
|
||||
**=========================================================================
|
||||
** Note that an assertion is _not_ a directive to check a condition and
|
||||
** crash if it isn't true. It is an assertion that the condition _is_
|
||||
** true. This assertion helps people to read the code. The program
|
||||
** may also check the assertion as it runs, and if it conflicts with reality,
|
||||
** recognize that the program is incorrect and abort it. In practice,
|
||||
** it does this checking when the program was compiled without the NDEBUG
|
||||
** macro defined.
|
||||
*/
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
#define XMLRPC_ASSERT(cond) \
|
||||
do \
|
||||
if (!(cond)) \
|
||||
xmlrpc_assertion_failed(__FILE__, __LINE__); \
|
||||
while (0)
|
||||
|
||||
#else
|
||||
#define XMLRPC_ASSERT(cond) (0)
|
||||
#endif
|
||||
|
||||
extern void xmlrpc_assertion_failed (char* file, int line);
|
||||
|
||||
/* Validate a pointer. */
|
||||
#define XMLRPC_ASSERT_PTR_OK(ptr) \
|
||||
XMLRPC_ASSERT((ptr) != NULL)
|
||||
|
||||
/* We only call this if something truly drastic happens. */
|
||||
#define XMLRPC_FATAL_ERROR(msg) xmlrpc_fatal_error(__FILE__, __LINE__, (msg))
|
||||
|
||||
extern void xmlrpc_fatal_error (char* file, int line, char* msg);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** Strings
|
||||
**=======================================================================*/
|
||||
|
||||
/* Traditional C strings are char *, because they come from a time before
|
||||
there was 'const'. Now, const char * makes a lot more sense. Also,
|
||||
in modern times, we tend to dynamically allocate memory for strings.
|
||||
We need this free function accordingly. Ordinary free() doesn't check
|
||||
the type, and can generate a warning due to the 'const'.
|
||||
*/
|
||||
void
|
||||
xmlrpc_strfree(const char * const string);
|
||||
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** xmlrpc_env
|
||||
**=========================================================================
|
||||
** XML-RPC represents runtime errors as <fault> elements. These contain
|
||||
** <faultCode> and <faultString> elements.
|
||||
**
|
||||
** Since we need as much thread-safety as possible, we borrow an idea from
|
||||
** CORBA--we store exception information in an "environment" object.
|
||||
** You'll pass this to many different functions, and it will get filled
|
||||
** out appropriately.
|
||||
**
|
||||
** For example:
|
||||
**
|
||||
** xmlrpc_env env;
|
||||
**
|
||||
** xmlrpc_env_init(&env);
|
||||
**
|
||||
** xmlrpc_do_something(&env);
|
||||
** if (env.fault_occurred)
|
||||
** report_error_appropriately();
|
||||
**
|
||||
** xmlrpc_env_clean(&env);
|
||||
*/
|
||||
|
||||
#define XMLRPC_INTERNAL_ERROR (-500)
|
||||
#define XMLRPC_TYPE_ERROR (-501)
|
||||
#define XMLRPC_INDEX_ERROR (-502)
|
||||
#define XMLRPC_PARSE_ERROR (-503)
|
||||
#define XMLRPC_NETWORK_ERROR (-504)
|
||||
#define XMLRPC_TIMEOUT_ERROR (-505)
|
||||
#define XMLRPC_NO_SUCH_METHOD_ERROR (-506)
|
||||
#define XMLRPC_REQUEST_REFUSED_ERROR (-507)
|
||||
#define XMLRPC_INTROSPECTION_DISABLED_ERROR (-508)
|
||||
#define XMLRPC_LIMIT_EXCEEDED_ERROR (-509)
|
||||
#define XMLRPC_INVALID_UTF8_ERROR (-510)
|
||||
|
||||
typedef struct _xmlrpc_env {
|
||||
int fault_occurred;
|
||||
xmlrpc_int32 fault_code;
|
||||
char* fault_string;
|
||||
} xmlrpc_env;
|
||||
|
||||
/* Initialize and destroy the contents of the provided xmlrpc_env object.
|
||||
** These functions will never fail. */
|
||||
void xmlrpc_env_init (xmlrpc_env* env);
|
||||
void xmlrpc_env_clean (xmlrpc_env* env);
|
||||
|
||||
/* Fill out an xmlrpc_fault with the specified values, and set the
|
||||
** fault_occurred flag. This function will make a private copy of 'string',
|
||||
** so you retain responsibility for your copy. */
|
||||
void
|
||||
xmlrpc_env_set_fault(xmlrpc_env * const env,
|
||||
int const faultCode,
|
||||
const char * const faultDescription);
|
||||
|
||||
/* The same as the above, but using a printf-style format string. */
|
||||
void
|
||||
xmlrpc_env_set_fault_formatted (xmlrpc_env * const envP,
|
||||
int const code,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
/* This one infers XMLRPC_INTERNAL_ERROR and has a shorter name.
|
||||
So a call takes up less source code space.
|
||||
*/
|
||||
void
|
||||
xmlrpc_faultf(xmlrpc_env * const envP,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
/* A simple debugging assertion. */
|
||||
#define XMLRPC_ASSERT_ENV_OK(env) \
|
||||
XMLRPC_ASSERT((env) != NULL && !(env)->fault_occurred)
|
||||
|
||||
/* This version must *not* interpret 'str' as a format string, to avoid
|
||||
** several evil attacks. */
|
||||
#define XMLRPC_FAIL(env,code,str) \
|
||||
do { xmlrpc_env_set_fault((env),(code),(str)); goto cleanup; } while (0)
|
||||
|
||||
#define XMLRPC_FAIL1(env,code,str,arg1) \
|
||||
do { \
|
||||
xmlrpc_env_set_fault_formatted((env),(code),(str),(arg1)); \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
#define XMLRPC_FAIL2(env,code,str,arg1,arg2) \
|
||||
do { \
|
||||
xmlrpc_env_set_fault_formatted((env),(code),(str),(arg1),(arg2)); \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
#define XMLRPC_FAIL3(env,code,str,arg1,arg2,arg3) \
|
||||
do { \
|
||||
xmlrpc_env_set_fault_formatted((env),(code), \
|
||||
(str),(arg1),(arg2),(arg3)); \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
#define XMLRPC_FAIL_IF_NULL(ptr,env,code,str) \
|
||||
do { \
|
||||
if ((ptr) == NULL) \
|
||||
XMLRPC_FAIL((env),(code),(str)); \
|
||||
} while (0)
|
||||
|
||||
#define XMLRPC_FAIL_IF_FAULT(env) \
|
||||
do { if ((env)->fault_occurred) goto cleanup; } while (0)
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** Resource Limits
|
||||
**=========================================================================
|
||||
** To discourage denial-of-service attacks, we provide several adjustable
|
||||
** resource limits. These functions are *not* re-entrant.
|
||||
*/
|
||||
|
||||
/* Limit IDs. There will be more of these as time goes on. */
|
||||
#define XMLRPC_NESTING_LIMIT_ID (0)
|
||||
#define XMLRPC_XML_SIZE_LIMIT_ID (1)
|
||||
#define XMLRPC_LAST_LIMIT_ID (XMLRPC_XML_SIZE_LIMIT_ID)
|
||||
|
||||
/* By default, deserialized data may be no more than 64 levels deep. */
|
||||
#define XMLRPC_NESTING_LIMIT_DEFAULT (64)
|
||||
|
||||
/* By default, XML data from the network may be no larger than 512K.
|
||||
** Some client and server modules may fail to enforce this properly. */
|
||||
#define XMLRPC_XML_SIZE_LIMIT_DEFAULT (512*1024)
|
||||
|
||||
/* Set a specific limit to the specified value. */
|
||||
extern void xmlrpc_limit_set (int limit_id, size_t value);
|
||||
|
||||
/* Get the value of a specified limit. */
|
||||
extern size_t xmlrpc_limit_get (int limit_id);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** xmlrpc_mem_block
|
||||
**=========================================================================
|
||||
** A resizable chunk of memory. This is mostly used internally, but it is
|
||||
** also used by the public API in a few places.
|
||||
** The struct fields are private!
|
||||
*/
|
||||
|
||||
typedef struct _xmlrpc_mem_block {
|
||||
size_t _size;
|
||||
size_t _allocated;
|
||||
void* _block;
|
||||
} xmlrpc_mem_block;
|
||||
|
||||
/* Allocate a new xmlrpc_mem_block. */
|
||||
xmlrpc_mem_block* xmlrpc_mem_block_new (xmlrpc_env* env, size_t size);
|
||||
|
||||
/* Destroy an existing xmlrpc_mem_block, and everything it contains. */
|
||||
void xmlrpc_mem_block_free (xmlrpc_mem_block* block);
|
||||
|
||||
/* Initialize the contents of the provided xmlrpc_mem_block. */
|
||||
void xmlrpc_mem_block_init
|
||||
(xmlrpc_env* env, xmlrpc_mem_block* block, size_t size);
|
||||
|
||||
/* Deallocate the contents of the provided xmlrpc_mem_block, but not the
|
||||
** block itself. */
|
||||
void xmlrpc_mem_block_clean (xmlrpc_mem_block* block);
|
||||
|
||||
/* Get the size and contents of the xmlrpc_mem_block. */
|
||||
size_t
|
||||
xmlrpc_mem_block_size(const xmlrpc_mem_block * const block);
|
||||
|
||||
void *
|
||||
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);
|
||||
|
||||
/* Append data to an existing xmlrpc_mem_block. */
|
||||
void xmlrpc_mem_block_append
|
||||
(xmlrpc_env* env, xmlrpc_mem_block* block, const void *data, size_t len);
|
||||
|
||||
#define XMLRPC_MEMBLOCK_NEW(type,env,size) \
|
||||
xmlrpc_mem_block_new((env), sizeof(type) * (size))
|
||||
#define XMLRPC_MEMBLOCK_FREE(type,block) \
|
||||
xmlrpc_mem_block_free(block)
|
||||
#define XMLRPC_MEMBLOCK_INIT(type,env,block,size) \
|
||||
xmlrpc_mem_block_init((env), (block), sizeof(type) * (size))
|
||||
#define XMLRPC_MEMBLOCK_CLEAN(type,block) \
|
||||
xmlrpc_mem_block_clean(block)
|
||||
#define XMLRPC_MEMBLOCK_SIZE(type,block) \
|
||||
(xmlrpc_mem_block_size(block) / sizeof(type))
|
||||
#define XMLRPC_MEMBLOCK_CONTENTS(type,block) \
|
||||
((type*) xmlrpc_mem_block_contents(block))
|
||||
#define XMLRPC_MEMBLOCK_RESIZE(type,env,block,size) \
|
||||
xmlrpc_mem_block_resize(env, block, sizeof(type) * (size))
|
||||
#define XMLRPC_MEMBLOCK_APPEND(type,env,block,data,size) \
|
||||
xmlrpc_mem_block_append(env, block, data, sizeof(type) * (size))
|
||||
|
||||
/* Here are some backward compatibility definitions. These longer names
|
||||
used to be the only ones and typed memory blocks were considered
|
||||
special.
|
||||
*/
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_NEW(type,env,size) \
|
||||
XMLRPC_MEMBLOCK_NEW(type,env,size)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_FREE(type,block) \
|
||||
XMLRPC_MEMBLOCK_FREE(type,block)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_INIT(type,env,block,size) \
|
||||
XMLRPC_MEMBLOCK_INIT(type,env,block,size)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_CLEAN(type,block) \
|
||||
XMLRPC_MEMBLOCK_CLEAN(type,block)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_SIZE(type,block) \
|
||||
XMLRPC_MEMBLOCK_SIZE(type,block)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_CONTENTS(type,block) \
|
||||
XMLRPC_MEMBLOCK_CONTENTS(type,block)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_RESIZE(type,env,block,size) \
|
||||
XMLRPC_MEMBLOCK_RESIZE(type,env,block,size)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_APPEND(type,env,block,data,size) \
|
||||
XMLRPC_MEMBLOCK_APPEND(type,env,block,data,size)
|
||||
|
||||
#define XMLRPC_INT64_MAX 0x7fffffffffffffffll
|
||||
#define XMLRPC_INT64_MIN (-XMLRPC_INT64_MAX - 1)
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
@@ -337,22 +73,28 @@ void xmlrpc_mem_block_append
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
XMLRPC_TYPE_INT = 0,
|
||||
XMLRPC_TYPE_BOOL = 1,
|
||||
XMLRPC_TYPE_DOUBLE = 2,
|
||||
XMLRPC_TYPE_DATETIME = 3,
|
||||
XMLRPC_TYPE_STRING = 4,
|
||||
XMLRPC_TYPE_BASE64 = 5,
|
||||
XMLRPC_TYPE_ARRAY = 6,
|
||||
XMLRPC_TYPE_STRUCT = 7,
|
||||
XMLRPC_TYPE_C_PTR = 8,
|
||||
XMLRPC_TYPE_NIL = 9,
|
||||
XMLRPC_TYPE_INT = 0,
|
||||
XMLRPC_TYPE_BOOL = 1,
|
||||
XMLRPC_TYPE_DOUBLE = 2,
|
||||
XMLRPC_TYPE_DATETIME = 3,
|
||||
XMLRPC_TYPE_STRING = 4,
|
||||
XMLRPC_TYPE_BASE64 = 5,
|
||||
XMLRPC_TYPE_ARRAY = 6,
|
||||
XMLRPC_TYPE_STRUCT = 7,
|
||||
XMLRPC_TYPE_C_PTR = 8,
|
||||
XMLRPC_TYPE_NIL = 9,
|
||||
XMLRPC_TYPE_I8 = 10,
|
||||
XMLRPC_TYPE_DEAD = 0xDEAD
|
||||
} xmlrpc_type;
|
||||
|
||||
#define XMLRPC_HAVE_I8 1
|
||||
|
||||
/* These are *always* allocated on the heap. No exceptions. */
|
||||
typedef struct _xmlrpc_value xmlrpc_value;
|
||||
|
||||
const char *
|
||||
xmlrpc_type_name(xmlrpc_type const type);
|
||||
|
||||
void
|
||||
xmlrpc_abort_if_array_bad(xmlrpc_value * const arrayP);
|
||||
|
||||
@@ -360,19 +102,23 @@ 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);
|
||||
extern xmlrpc_type xmlrpc_value_type (xmlrpc_value* const value);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_int_new(xmlrpc_env * const envP,
|
||||
int const intValue);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_i8_new(xmlrpc_env * const envP,
|
||||
xmlrpc_int64 const value);
|
||||
|
||||
void
|
||||
xmlrpc_read_int(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
@@ -423,19 +169,49 @@ xmlrpc_string_new_lp(xmlrpc_env * const envP,
|
||||
size_t const length,
|
||||
const char * const stringValue);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_new_va(xmlrpc_env * const envP,
|
||||
const char * const format,
|
||||
va_list args);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_new_f(xmlrpc_env * const envP,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_new_lp_cr(xmlrpc_env * const envP,
|
||||
size_t const length,
|
||||
const char * const value);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_new_cr(xmlrpc_env * const envP,
|
||||
const char * const value);
|
||||
|
||||
void
|
||||
xmlrpc_read_string(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
const char ** const stringValueP);
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_read_string_crlf(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
const char ** const stringValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_string_lp_crlf(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
size_t * const lengthP,
|
||||
const char ** const stringValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_string_lp(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
size_t * const lengthP,
|
||||
const char ** const stringValueP);
|
||||
|
||||
#ifdef HAVE_UNICODE_WCHAR
|
||||
#if XMLRPC_HAVE_WCHAR
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_w_new(xmlrpc_env * const envP,
|
||||
const wchar_t * const stringValue);
|
||||
@@ -450,12 +226,33 @@ xmlrpc_read_string_w(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const valueP,
|
||||
const wchar_t ** const stringValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_string_w_crlf(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const valueP,
|
||||
const wchar_t ** const stringValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_string_w_lp(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const valueP,
|
||||
size_t * const lengthP,
|
||||
const wchar_t ** const stringValueP);
|
||||
#endif
|
||||
|
||||
void
|
||||
xmlrpc_read_string_w_lp_crlf(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const valueP,
|
||||
size_t * const lengthP,
|
||||
const wchar_t ** const stringValueP);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_w_new_lp_cr(xmlrpc_env * const envP,
|
||||
size_t const length,
|
||||
const wchar_t * const value);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_string_w_new_cr(xmlrpc_env * const envP,
|
||||
const wchar_t * const value);
|
||||
|
||||
#endif /* XMLRPC_HAVE_WCHAR */
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_base64_new(xmlrpc_env * const envP,
|
||||
@@ -485,9 +282,9 @@ xmlrpc_array_size(xmlrpc_env * const env,
|
||||
/* Append an item to an XML-RPC array.
|
||||
** Sets XMLRPC_TYPE_ERROR if 'array' is not an array. */
|
||||
extern void
|
||||
xmlrpc_array_append_item (xmlrpc_env * envP,
|
||||
xmlrpc_value * arrayP,
|
||||
xmlrpc_value * valueP);
|
||||
xmlrpc_array_append_item (xmlrpc_env * const envP,
|
||||
xmlrpc_value * const arrayP,
|
||||
xmlrpc_value * const valueP);
|
||||
|
||||
void
|
||||
xmlrpc_array_read_item(xmlrpc_env * const envP,
|
||||
@@ -515,18 +312,8 @@ int index,
|
||||
xmlrpc_value* value);
|
||||
*/
|
||||
|
||||
void
|
||||
xmlrpc_read_nil(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const valueP);
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_read_cptr(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
void ** const ptrValueP);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_struct_new(xmlrpc_env * env);
|
||||
xmlrpc_struct_new(xmlrpc_env * const env);
|
||||
|
||||
/* Return the number of key/value pairs in a struct.
|
||||
** Sets XMLRPC_TYPE_ERROR if 'strct' is not a struct. */
|
||||
@@ -573,18 +360,18 @@ xmlrpc_struct_find_value_v(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const keyP,
|
||||
xmlrpc_value ** const valuePP);
|
||||
|
||||
void
|
||||
xmlrpc_struct_read_value(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const structP,
|
||||
const char * const key,
|
||||
xmlrpc_value ** const valuePP);
|
||||
|
||||
void
|
||||
xmlrpc_struct_read_value_v(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const structP,
|
||||
xmlrpc_value * const keyP,
|
||||
xmlrpc_value ** const valuePP);
|
||||
|
||||
void
|
||||
xmlrpc_struct_read_value(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const strctP,
|
||||
const char * const key,
|
||||
xmlrpc_value ** const valuePP);
|
||||
|
||||
/* The "get_value" functions are deprecated. Use the "find_value"
|
||||
and "read_value" functions instead.
|
||||
*/
|
||||
@@ -650,11 +437,27 @@ xmlrpc_struct_read_member(xmlrpc_env * const envP,
|
||||
Deprecated. Use xmlrpc_struct_read_member() instead.
|
||||
*/
|
||||
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);
|
||||
|
||||
void
|
||||
xmlrpc_read_cptr(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
void ** const ptrValueP);
|
||||
|
||||
void
|
||||
xmlrpc_read_nil(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const valueP);
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_read_i8(xmlrpc_env * const envP,
|
||||
const xmlrpc_value * const valueP,
|
||||
xmlrpc_int64 * const intValueP);
|
||||
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_cptr_new(xmlrpc_env * const envP,
|
||||
@@ -675,7 +478,7 @@ xmlrpc_build_value(xmlrpc_env * const env,
|
||||
void
|
||||
xmlrpc_build_value_va(xmlrpc_env * const env,
|
||||
const char * const format,
|
||||
va_list args,
|
||||
va_list const args,
|
||||
xmlrpc_value ** const valPP,
|
||||
const char ** const tailP);
|
||||
|
||||
@@ -689,7 +492,7 @@ void
|
||||
xmlrpc_decompose_value_va(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const value,
|
||||
const char * const format,
|
||||
va_list args);
|
||||
va_list const args);
|
||||
|
||||
/* xmlrpc_parse_value... is the same as xmlrpc_decompose_value... except
|
||||
that it doesn't do proper memory management -- it returns xmlrpc_value's
|
||||
@@ -709,44 +512,67 @@ void
|
||||
xmlrpc_parse_value_va(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const value,
|
||||
const char * const format,
|
||||
va_list args);
|
||||
va_list const args);
|
||||
|
||||
/*=========================================================================
|
||||
** Encoding XML
|
||||
**=======================================================================*/
|
||||
|
||||
/* Serialize an XML value without any XML header. This is primarily used
|
||||
** for testing purposes. */
|
||||
void
|
||||
xmlrpc_serialize_value(xmlrpc_env * env,
|
||||
xmlrpc_mem_block * output,
|
||||
xmlrpc_value * value);
|
||||
typedef enum xmlrpc_dialect {
|
||||
xmlrpc_dialect_i8,
|
||||
xmlrpc_dialect_apache
|
||||
} xmlrpc_dialect;
|
||||
|
||||
/* Serialize a list of parameters without any XML header. This is
|
||||
** primarily used for testing purposes. */
|
||||
void
|
||||
xmlrpc_serialize_params(xmlrpc_env * env,
|
||||
xmlrpc_mem_block * output,
|
||||
xmlrpc_value * param_array);
|
||||
|
||||
/* Serialize an XML-RPC call. */
|
||||
void
|
||||
xmlrpc_serialize_call (xmlrpc_env * const env,
|
||||
xmlrpc_mem_block * const output,
|
||||
const char * const method_name,
|
||||
xmlrpc_value * const param_array);
|
||||
xmlrpc_serialize_value2(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
xmlrpc_value * const valueP,
|
||||
xmlrpc_dialect const dialect);
|
||||
|
||||
/* Serialize an XML-RPC return value. */
|
||||
extern void
|
||||
xmlrpc_serialize_response(xmlrpc_env * env,
|
||||
xmlrpc_mem_block * output,
|
||||
xmlrpc_value * value);
|
||||
void
|
||||
xmlrpc_serialize_value(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
xmlrpc_value * const valueP);
|
||||
|
||||
/* Serialize an XML-RPC fault (as specified by 'fault'). */
|
||||
extern void
|
||||
xmlrpc_serialize_fault(xmlrpc_env * env,
|
||||
xmlrpc_mem_block * output,
|
||||
xmlrpc_env * fault);
|
||||
void
|
||||
xmlrpc_serialize_params2(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
xmlrpc_value * const paramArrayP,
|
||||
xmlrpc_dialect const dialect);
|
||||
|
||||
void
|
||||
xmlrpc_serialize_params(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
void
|
||||
xmlrpc_serialize_call2(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const paramArrayP,
|
||||
xmlrpc_dialect const dialect);
|
||||
|
||||
void
|
||||
xmlrpc_serialize_call(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
void
|
||||
xmlrpc_serialize_response2(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
xmlrpc_value * const valueP,
|
||||
xmlrpc_dialect const dialect);
|
||||
|
||||
void
|
||||
xmlrpc_serialize_response(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
xmlrpc_value * const valueP);
|
||||
|
||||
void
|
||||
xmlrpc_serialize_fault(xmlrpc_env * const envP,
|
||||
xmlrpc_mem_block * const outputP,
|
||||
const xmlrpc_env * const faultP);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
@@ -764,13 +590,21 @@ xmlrpc_parse_call(xmlrpc_env * const envP,
|
||||
const char ** const out_method_name,
|
||||
xmlrpc_value ** const out_param_array);
|
||||
|
||||
/* Parse an XML-RPC response. If a fault occurs (or was received over the
|
||||
** wire), return NULL and set up 'env'. The calling is responsible for
|
||||
** calling xmlrpc_DECREF on the return value (if it isn't NULL). */
|
||||
void
|
||||
xmlrpc_parse_response2(xmlrpc_env * const envP,
|
||||
const char * const xmlData,
|
||||
size_t const xmlDataLen,
|
||||
xmlrpc_value ** const resultPP,
|
||||
int * const faultCodeP,
|
||||
const char ** const faultStringP);
|
||||
|
||||
|
||||
/* xmlrpc_parse_response() is for backward compatibility */
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_parse_response(xmlrpc_env * env,
|
||||
const char * xml_data,
|
||||
size_t xml_len);
|
||||
xmlrpc_parse_response(xmlrpc_env * const envP,
|
||||
const char * const xmlData,
|
||||
size_t const xmlDataLen);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
@@ -801,42 +635,6 @@ xmlrpc_base64_decode(xmlrpc_env * const envP,
|
||||
size_t const ascii_len);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** UTF-8 Encoding and Decoding
|
||||
**=========================================================================
|
||||
** We need a correct, reliable and secure UTF-8 decoder. This decoder
|
||||
** raises a fault if it encounters invalid UTF-8.
|
||||
**
|
||||
** Note that ANSI C does not precisely define the representation used
|
||||
** by wchar_t--it may be UCS-2, UTF-16, UCS-4, or something from outer
|
||||
** space. If your platform does something especially bizarre, you may
|
||||
** need to reimplement these routines.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_UNICODE_WCHAR
|
||||
|
||||
/* Ensure that a string contains valid, legally-encoded UTF-8 data.
|
||||
** (Incorrectly-encoded UTF-8 strings are often used to bypass security
|
||||
** checks.) */
|
||||
void
|
||||
xmlrpc_validate_utf8 (xmlrpc_env * const env,
|
||||
const char * const utf8_data,
|
||||
size_t const utf8_len);
|
||||
|
||||
/* Decode a UTF-8 string. */
|
||||
xmlrpc_mem_block *
|
||||
xmlrpc_utf8_to_wcs(xmlrpc_env * env,
|
||||
char * utf8_data,
|
||||
size_t utf8_len);
|
||||
|
||||
/* Encode a UTF-8 string. */
|
||||
xmlrpc_mem_block *
|
||||
xmlrpc_wcs_to_utf8(xmlrpc_env * env,
|
||||
wchar_t * wcs_data,
|
||||
size_t wcs_len);
|
||||
|
||||
#endif /* HAVE_UNICODE_WCHAR */
|
||||
|
||||
/*=========================================================================
|
||||
** Authorization Cookie Handling
|
||||
**=========================================================================
|
||||
@@ -847,12 +645,44 @@ xmlrpc_wcs_to_utf8(xmlrpc_env * env,
|
||||
** a cookie replacement of basic authentication.)
|
||||
**/
|
||||
|
||||
extern void xmlrpc_authcookie_set(xmlrpc_env * env,
|
||||
const char * username,
|
||||
const char * password);
|
||||
extern void xmlrpc_authcookie_set(xmlrpc_env * const env,
|
||||
const char * const username,
|
||||
const char * const password);
|
||||
|
||||
char *xmlrpc_authcookie(void);
|
||||
|
||||
/*=========================================================================
|
||||
Resource Limits
|
||||
|
||||
Ideally, there would be enough resource limits to ensure that
|
||||
XML-RPC partners cannot cause libxmlrpc objects and routines to use
|
||||
more resource than is available for them (either by accident or
|
||||
malice). We have a long way to go to get there.
|
||||
|
||||
=========================================================================*/
|
||||
/* These functions are _not_ re-entrant and the limits are per-process
|
||||
(i.e. their values live in static global variables).
|
||||
*/
|
||||
|
||||
/* Limit IDs. There will be more of these as time goes on. */
|
||||
#define XMLRPC_NESTING_LIMIT_ID (0)
|
||||
#define XMLRPC_XML_SIZE_LIMIT_ID (1)
|
||||
#define XMLRPC_LAST_LIMIT_ID (XMLRPC_XML_SIZE_LIMIT_ID)
|
||||
|
||||
/* By default, deserialized data may be no more than 64 levels deep. */
|
||||
#define XMLRPC_NESTING_LIMIT_DEFAULT (64)
|
||||
|
||||
/* By default, XML data from the network may be no larger than 512K.
|
||||
** Some client and server modules may fail to enforce this properly. */
|
||||
#define XMLRPC_XML_SIZE_LIMIT_DEFAULT (512*1024)
|
||||
|
||||
/* Set a specific limit to the specified value. */
|
||||
extern void xmlrpc_limit_set (int const limit_id, size_t const value);
|
||||
|
||||
/* Get the value of a specified limit. */
|
||||
extern size_t xmlrpc_limit_get (int const limit_id);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#ifndef XMLRPC_HPP_INCLUDED
|
||||
#define XMLRPC_HPP_INCLUDED
|
||||
#ifndef XMLRPC_BASE_HPP_INCLUDED
|
||||
#define XMLRPC_BASE_HPP_INCLUDED
|
||||
|
||||
#include <climits>
|
||||
#include <cfloat>
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "xmlrpc-c/base.h"
|
||||
#include <xmlrpc-c/base.h>
|
||||
|
||||
namespace xmlrpc_c {
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
TYPE_STRUCT = 7,
|
||||
TYPE_C_PTR = 8,
|
||||
TYPE_NIL = 9,
|
||||
TYPE_I8 = 10,
|
||||
TYPE_DEAD = 0xDEAD
|
||||
};
|
||||
|
||||
@@ -44,6 +45,9 @@ public:
|
||||
xmlrpc_c::value&
|
||||
operator=(xmlrpc_c::value const&);
|
||||
|
||||
bool
|
||||
isInstantiated() const;
|
||||
|
||||
// The following are not meant to be public to users, but just to
|
||||
// other Xmlrpc-c library modules. If we ever go to a pure C++
|
||||
// implementation, not based on C xmlrpc_value objects, this shouldn't
|
||||
@@ -54,7 +58,7 @@ public:
|
||||
|
||||
void
|
||||
addToCStruct(xmlrpc_value * const structP,
|
||||
std::string const key) const;
|
||||
std::string const key) const;
|
||||
|
||||
xmlrpc_value *
|
||||
cValue() const;
|
||||
@@ -63,7 +67,7 @@ public:
|
||||
|
||||
void
|
||||
instantiate(xmlrpc_value * const valueP);
|
||||
// Work only on a placeholder object created by the no-argument
|
||||
// Works only on a placeholder object created by the no-argument
|
||||
// constructor.
|
||||
|
||||
xmlrpc_value * cValueP;
|
||||
@@ -96,10 +100,18 @@ public:
|
||||
|
||||
class value_string : public value {
|
||||
public:
|
||||
value_string(std::string const& cvalue);
|
||||
enum nlCode {nlCode_all, nlCode_lf};
|
||||
|
||||
value_string(std::string const& cppvalue,
|
||||
nlCode const nlCode);
|
||||
|
||||
value_string(std::string const& cppvalue);
|
||||
|
||||
value_string(xmlrpc_c::value const baseValue);
|
||||
|
||||
std::string
|
||||
crlfValue() const;
|
||||
|
||||
operator std::string() const;
|
||||
};
|
||||
|
||||
@@ -120,8 +132,12 @@ class value_datetime : public value {
|
||||
public:
|
||||
value_datetime(std::string const cvalue);
|
||||
value_datetime(time_t const cvalue);
|
||||
#if XMLRPC_HAVE_TIMEVAL
|
||||
value_datetime(struct timeval const& cvalue);
|
||||
#endif
|
||||
#if XMLRPC_HAVE_TIMESPEC
|
||||
value_datetime(struct timespec const& cvalue);
|
||||
#endif
|
||||
|
||||
value_datetime(xmlrpc_c::value const baseValue);
|
||||
|
||||
@@ -147,15 +163,6 @@ public:
|
||||
|
||||
|
||||
|
||||
class value_nil : public value {
|
||||
public:
|
||||
value_nil();
|
||||
|
||||
value_nil(xmlrpc_c::value const baseValue);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class value_struct : public value {
|
||||
public:
|
||||
value_struct(std::map<std::string, xmlrpc_c::value> const& cvalue);
|
||||
@@ -182,6 +189,26 @@ public:
|
||||
|
||||
|
||||
|
||||
class value_nil : public value {
|
||||
public:
|
||||
value_nil();
|
||||
|
||||
value_nil(xmlrpc_c::value const baseValue);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class value_i8 : public value {
|
||||
public:
|
||||
value_i8(xmlrpc_int64 const cvalue);
|
||||
|
||||
value_i8(xmlrpc_c::value const baseValue);
|
||||
|
||||
operator xmlrpc_int64() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class fault {
|
||||
/*----------------------------------------------------------------------------
|
||||
This is an XML-RPC fault.
|
||||
@@ -255,9 +282,12 @@ class paramList {
|
||||
public:
|
||||
paramList(unsigned int const paramCount = 0);
|
||||
|
||||
void
|
||||
paramList&
|
||||
add(xmlrpc_c::value const param);
|
||||
|
||||
paramList&
|
||||
addx(xmlrpc_c::value const param);
|
||||
|
||||
unsigned int
|
||||
size() const;
|
||||
|
||||
@@ -300,6 +330,11 @@ public:
|
||||
void
|
||||
getNil(unsigned int const paramNumber) const;
|
||||
|
||||
xmlrpc_int64
|
||||
getI8(unsigned int const paramNumber,
|
||||
xmlrpc_int64 const minimum = XMLRPC_INT64_MIN,
|
||||
xmlrpc_int64 const maximum = XMLRPC_INT64_MAX) const;
|
||||
|
||||
void
|
||||
verifyEnd(unsigned int const paramNumber) const;
|
||||
|
||||
|
25
libs/xmlrpc-c/include/xmlrpc-c/base64.hpp
Normal file
25
libs/xmlrpc-c/include/xmlrpc-c/base64.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef XMLRPC_BASE64_HPP_INCLUDED
|
||||
#define XMLRPC_BASE64_HPP_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace xmlrpc_c {
|
||||
|
||||
|
||||
enum newlineCtl {NEWLINE_NO, NEWLINE_YES};
|
||||
|
||||
std::string
|
||||
base64FromBytes(
|
||||
std::vector<unsigned char> const& bytes,
|
||||
xmlrpc_c::newlineCtl const newlineCtl = xmlrpc_c::NEWLINE_YES);
|
||||
|
||||
|
||||
|
||||
std::vector<unsigned char>
|
||||
bytesFromBase64(std::string const& base64);
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
@@ -1,5 +1,5 @@
|
||||
/*============================================================================
|
||||
xmlrpc_client_int.h
|
||||
base_int.h
|
||||
==============================================================================
|
||||
This header file defines the interface between modules inside
|
||||
xmlrpc-c.
|
||||
@@ -11,12 +11,19 @@
|
||||
============================================================================*/
|
||||
|
||||
|
||||
#ifndef XMLRPC_INT_H_INCLUDED
|
||||
#define XMLRPC_INT_H_INCLUDED
|
||||
#ifndef XMLRPC_C_BASE_INT_H_INCLUDED
|
||||
#define XMLRPC_C_BASE_INT_H_INCLUDED
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
#include "bool.h"
|
||||
#include "int.h"
|
||||
|
||||
#include <xmlrpc-c/base.h>
|
||||
#include <xmlrpc-c/util_int.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
|
||||
struct _xmlrpc_value {
|
||||
@@ -26,20 +33,37 @@ struct _xmlrpc_value {
|
||||
/* Certain data types store their data directly in the xmlrpc_value. */
|
||||
union {
|
||||
xmlrpc_int32 i;
|
||||
xmlrpc_int64 i8;
|
||||
xmlrpc_bool b;
|
||||
double d;
|
||||
/* time_t t */
|
||||
void *c_ptr;
|
||||
void * c_ptr;
|
||||
} _value;
|
||||
|
||||
/* Other data types use a memory block.
|
||||
|
||||
For a string, this is the characters of the string in UTF-8, plus
|
||||
a NUL added to the end.
|
||||
For a string, this is the characters of the lines of the string
|
||||
in UTF-8, with lines delimited by either CR, LF, or CRLF, plus
|
||||
a NUL added to the end. The characters of the lines may be any
|
||||
character representable in UTF-8, even the ones that are not
|
||||
legal XML (XML doesn't allow ASCII control characters except
|
||||
tab, CR, LF). But note that a line can't contain CR or LF
|
||||
because that would form a line delimiter. To disambiguate:
|
||||
CRLF together is always one line delimiter.
|
||||
|
||||
This format for string is quite convenient because it is also
|
||||
the format of that part of an XML document which is the
|
||||
contents of a <string> element (except of course that for the
|
||||
non-XML characters, we have to stretch the definition of XML).
|
||||
|
||||
For base64, this is bytes of the byte string, directly.
|
||||
|
||||
For datetime, this is in the same format as the contents of
|
||||
a <dateTime.iso8601> XML element. That really ought to be changed
|
||||
to time_t some day.
|
||||
*/
|
||||
xmlrpc_mem_block _block;
|
||||
|
||||
#ifdef HAVE_UNICODE_WCHAR
|
||||
xmlrpc_mem_block *_wcs_block;
|
||||
/* This is a copy of the string value in _block, but in UTF-16
|
||||
instead of UTF-8. This member is not always present. If NULL,
|
||||
@@ -49,8 +73,10 @@ struct _xmlrpc_value {
|
||||
redundant with _block.
|
||||
|
||||
This member is always NULL when the data type is not string.
|
||||
|
||||
This member is always NULL on a system that does not have
|
||||
Unicode wchar functions.
|
||||
*/
|
||||
#endif
|
||||
};
|
||||
|
||||
#define XMLRPC_ASSERT_VALUE_OK(val) \
|
||||
@@ -65,9 +91,9 @@ struct _xmlrpc_value {
|
||||
|
||||
|
||||
typedef struct {
|
||||
unsigned char key_hash;
|
||||
xmlrpc_value *key;
|
||||
xmlrpc_value *value;
|
||||
uint32_t keyHash;
|
||||
xmlrpc_value * key;
|
||||
xmlrpc_value * value;
|
||||
} _struct_member;
|
||||
|
||||
|
||||
@@ -78,38 +104,20 @@ xmlrpc_createXmlrpcValue(xmlrpc_env * const envP,
|
||||
const char *
|
||||
xmlrpc_typeName(xmlrpc_type const type);
|
||||
|
||||
|
||||
struct _xmlrpc_registry {
|
||||
int _introspection_enabled;
|
||||
xmlrpc_value *_methods;
|
||||
xmlrpc_value *_default_method;
|
||||
xmlrpc_value *_preinvoke_method;
|
||||
};
|
||||
|
||||
|
||||
/* When we deallocate a pointer in a struct, we often replace it with
|
||||
** this and throw in a few assertions here and there. */
|
||||
#define XMLRPC_BAD_POINTER ((void*) 0xDEADBEEF)
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_traceXml(const char * const label,
|
||||
const char * const xml,
|
||||
unsigned int const xmlLength);
|
||||
|
||||
void
|
||||
xmlrpc_destroyString(xmlrpc_value * const stringP);
|
||||
|
||||
void
|
||||
xmlrpc_destroyStruct(xmlrpc_value * const structP);
|
||||
|
||||
void
|
||||
xmlrpc_destroyArrayContents(xmlrpc_value * const arrayP);
|
||||
|
||||
const char *
|
||||
xmlrpc_makePrintable(const char * const input);
|
||||
|
||||
const char *
|
||||
xmlrpc_makePrintableChar(char const input);
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
The following are for use by the legacy xmlrpc_parse_value(). They don't
|
||||
do proper memory management, so they aren't appropriate for general use,
|
||||
@@ -138,7 +146,7 @@ xmlrpc_read_string_lp_old(xmlrpc_env * const envP,
|
||||
size_t * const lengthP,
|
||||
const char ** const stringValueP);
|
||||
|
||||
#ifdef HAVE_UNICODE_WCHAR
|
||||
#if XMLRPC_HAVE_WCHAR
|
||||
void
|
||||
xmlrpc_read_string_w_old(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const valueP,
|
||||
@@ -185,6 +193,6 @@ xmlrpc_read_base64_old(xmlrpc_env * const envP,
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
14
libs/xmlrpc-c/include/xmlrpc-c/c_util.h
Normal file
14
libs/xmlrpc-c/include/xmlrpc-c/c_util.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef XMLRPC_C_C_UTIL_H_INCLUDED
|
||||
#define XMLRPC_C_C_UTIL_H_INCLUDED
|
||||
|
||||
/* 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
|
||||
|
||||
#endif
|
@@ -16,33 +16,61 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*=========================================================================
|
||||
** Initialization and Shutdown
|
||||
**=========================================================================
|
||||
** These routines initialize and terminate the XML-RPC client. If you're
|
||||
** already using libwww on your own, you can pass
|
||||
** XMLRPC_CLIENT_SKIP_LIBWWW_INIT to avoid initializing it twice.
|
||||
struct xmlrpc_client;
|
||||
struct xmlrpc_client_transport;
|
||||
struct xmlrpc_client_transport_ops;
|
||||
#ifndef __cplusplus
|
||||
typedef struct xmlrpc_client xmlrpc_client;
|
||||
typedef struct xmlrpc_client_transport xmlrpc_client_transport;
|
||||
typedef struct xmlrpc_client_transport_ops xmlrpc_client_transport_ops;
|
||||
#endif
|
||||
|
||||
/* libxmlrpc_client typically does _not_ actually include all of the
|
||||
XML transports declared here by xmlrpc_*_transport_ops.
|
||||
|
||||
Use 'xmlrpc-c-config --features' to determine which features are
|
||||
installed.
|
||||
*/
|
||||
|
||||
#define XMLRPC_CLIENT_NO_FLAGS (0)
|
||||
#define XMLRPC_CLIENT_SKIP_LIBWWW_INIT (1)
|
||||
/* Before Xmlrpc-c 1.13 (December 2007), we declared struct
|
||||
xmlrpc_xportparms, as a sort of "base class." The struct was never
|
||||
complete -- you just cast pointer to it it to pointers to other
|
||||
types. It turned out not to be really helpful and casts are ugly,
|
||||
so now we just use void * as a base class pointer.
|
||||
*/
|
||||
|
||||
extern void
|
||||
xmlrpc_client_init(int const flags,
|
||||
const char * const appname,
|
||||
const char * const appversion);
|
||||
extern struct xmlrpc_client_transport_ops xmlrpc_libwww_transport_ops;
|
||||
extern struct xmlrpc_client_transport_ops xmlrpc_wininet_transport_ops;
|
||||
extern struct xmlrpc_client_transport_ops xmlrpc_curl_transport_ops;
|
||||
|
||||
struct xmlrpc_xportparms;
|
||||
/* This is a "base class". The struct is never complete; you're
|
||||
supposed to cast between struct xmlrpc_xportparms * and
|
||||
"struct xmlrpc_..._xportparms *" in order to use it.
|
||||
*/
|
||||
enum xmlrpc_sslversion {
|
||||
XMLRPC_SSLVERSION_DEFAULT,
|
||||
XMLRPC_SSLVERSION_TLSv1,
|
||||
XMLRPC_SSLVERSION_SSLv2,
|
||||
XMLRPC_SSLVERSION_SSLv3
|
||||
};
|
||||
|
||||
struct xmlrpc_curl_xportparms {
|
||||
/* This is designed so that zero values are always the defaults. */
|
||||
const char * network_interface;
|
||||
xmlrpc_bool no_ssl_verifypeer;
|
||||
xmlrpc_bool no_ssl_verifyhost;
|
||||
const char * user_agent;
|
||||
const char * ssl_cert;
|
||||
const char * sslcerttype;
|
||||
const char * sslcertpasswd;
|
||||
const char * sslkey;
|
||||
const char * sslkeytype;
|
||||
const char * sslkeypasswd;
|
||||
const char * sslengine;
|
||||
xmlrpc_bool sslengine_default;
|
||||
enum xmlrpc_sslversion sslversion;
|
||||
const char * cainfo;
|
||||
const char * capath;
|
||||
const char * randomfile;
|
||||
const char * egdsocket;
|
||||
const char * ssl_cipher_list;
|
||||
unsigned int timeout;
|
||||
};
|
||||
|
||||
|
||||
@@ -61,10 +89,17 @@ struct xmlrpc_wininet_xportparms {
|
||||
/* XMLRPC_WXPSIZE(xyz) is analogous to XMLRPC_CPSIZE, below */
|
||||
|
||||
struct xmlrpc_clientparms {
|
||||
/* (transport, transportparmsP, transportparm_size) and
|
||||
(transportOpsP, transportP) are mutually exclusive.
|
||||
*/
|
||||
const char * transport;
|
||||
struct xmlrpc_xportparms * transportparmsP;
|
||||
/* Cast a "struct ..._xportparms *" to fit here */
|
||||
const void * transportparmsP;
|
||||
/* This should be type "const struct ..._xportparms *" */
|
||||
size_t transportparm_size;
|
||||
|
||||
const struct xmlrpc_client_transport_ops * transportOpsP;
|
||||
xmlrpc_client_transport * transportP;
|
||||
xmlrpc_dialect dialect;
|
||||
};
|
||||
|
||||
#define XMLRPC_CPSIZE(mbrname) \
|
||||
@@ -77,24 +112,9 @@ struct xmlrpc_clientparms {
|
||||
not the caller is new enough to have supplied a certain parameter.
|
||||
*/
|
||||
|
||||
void
|
||||
xmlrpc_client_init2(xmlrpc_env * const env,
|
||||
int const flags,
|
||||
const char * const appname,
|
||||
const char * const appversion,
|
||||
const struct xmlrpc_clientparms * const clientparms,
|
||||
unsigned int const parm_size);
|
||||
|
||||
extern void
|
||||
xmlrpc_client_cleanup(void);
|
||||
|
||||
const char *
|
||||
xmlrpc_client_get_default_transport(xmlrpc_env * const env);
|
||||
|
||||
/*=========================================================================
|
||||
** Required for both internal and external development.
|
||||
**=========================================================================
|
||||
*/
|
||||
/* A callback function to handle the response to an asynchronous call.
|
||||
** If 'fault->fault_occurred' is true, then response will be NULL. All
|
||||
** arguments except 'user_data' will be deallocated internally; please do
|
||||
@@ -112,32 +132,39 @@ typedef void (*xmlrpc_response_handler) (const char *server_url,
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** xmlrpc_server_info
|
||||
**=========================================================================
|
||||
** We normally refer to servers by URL. But sometimes we need to do extra
|
||||
** setup for particular servers. In that case, we can create an
|
||||
** xmlrpc_server_info object, configure it in various ways, and call the
|
||||
** remote server.
|
||||
**
|
||||
** (This interface is also designed to discourage further multiplication
|
||||
** of xmlrpc_client_call APIs. We have enough of those already. Please
|
||||
** add future options and flags using xmlrpc_server_info.)
|
||||
*/
|
||||
xmlrpc_server_info
|
||||
===========================================================================
|
||||
We normally refer to servers by URL. But sometimes we need to do extra
|
||||
setup for particular servers. In that case, we can create an
|
||||
xmlrpc_server_info object, configure it in various ways, and call the
|
||||
remote server.
|
||||
|
||||
(This interface is also designed to discourage further multiplication
|
||||
of xmlrpc_client_call APIs. We have enough of those already. Please
|
||||
add future options and flags using xmlrpc_server_info.)
|
||||
=========================================================================*/
|
||||
|
||||
typedef struct _xmlrpc_server_info xmlrpc_server_info;
|
||||
|
||||
/* Create a new server info record, pointing to the specified server. */
|
||||
xmlrpc_server_info *
|
||||
xmlrpc_server_info_new(xmlrpc_env * const env,
|
||||
const char * const server_url);
|
||||
xmlrpc_server_info_new(xmlrpc_env * const envP,
|
||||
const char * const serverUrl);
|
||||
|
||||
/* Create a new server info record, with a copy of the old server. */
|
||||
extern xmlrpc_server_info *
|
||||
xmlrpc_server_info_copy(xmlrpc_env *env, xmlrpc_server_info *src_server);
|
||||
xmlrpc_server_info_copy(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const srcP);
|
||||
|
||||
/* Delete a server info record. */
|
||||
extern void
|
||||
xmlrpc_server_info_free (xmlrpc_server_info *server);
|
||||
void
|
||||
xmlrpc_server_info_free(xmlrpc_server_info * const serverP);
|
||||
|
||||
|
||||
void
|
||||
xmlrpc_server_info_set_user(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const serverInfoP,
|
||||
const char * const username,
|
||||
const char * const password);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_set_basic_auth(xmlrpc_env * const envP,
|
||||
@@ -145,118 +172,116 @@ xmlrpc_server_info_set_basic_auth(xmlrpc_env * const envP,
|
||||
const char * const username,
|
||||
const char * const password);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** xmlrpc_client_call
|
||||
**=========================================================================
|
||||
** A synchronous XML-RPC client. Do not attempt to call any of these
|
||||
** functions from inside an asynchronous callback!
|
||||
*/
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_client_call(xmlrpc_env * const envP,
|
||||
const char * const server_url,
|
||||
const char * const method_name,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_client_call_params(xmlrpc_env * const envP,
|
||||
const char * const serverUrl,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_client_call_server(xmlrpc_env * const envP,
|
||||
const xmlrpc_server_info * const server,
|
||||
const char * const method_name,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_client_call_server_params(
|
||||
xmlrpc_env * const envP,
|
||||
const xmlrpc_server_info * const serverP,
|
||||
const char * const method_name,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
void
|
||||
xmlrpc_server_info_allow_auth_basic(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
void
|
||||
xmlrpc_client_transport_call(
|
||||
xmlrpc_server_info_disallow_auth_basic(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_allow_auth_digest(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_disallow_auth_digest(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_allow_auth_negotiate(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_disallow_auth_negotiate(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_allow_auth_ntlm(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
void
|
||||
xmlrpc_server_info_disallow_auth_ntlm(xmlrpc_env * const envP,
|
||||
xmlrpc_server_info * const sP);
|
||||
|
||||
extern unsigned int const xmlrpc_client_version_major;
|
||||
extern unsigned int const xmlrpc_client_version_minor;
|
||||
extern unsigned int const xmlrpc_client_version_point;
|
||||
|
||||
void
|
||||
xmlrpc_client_setup_global_const(xmlrpc_env * const envP);
|
||||
|
||||
void
|
||||
xmlrpc_client_teardown_global_const(void);
|
||||
|
||||
void
|
||||
xmlrpc_client_create(xmlrpc_env * const envP,
|
||||
int const flags,
|
||||
const char * const appname,
|
||||
const char * const appversion,
|
||||
const struct xmlrpc_clientparms * const clientparmsP,
|
||||
unsigned int const parmSize,
|
||||
xmlrpc_client ** const clientPP);
|
||||
|
||||
void
|
||||
xmlrpc_client_destroy(xmlrpc_client * const clientP);
|
||||
|
||||
void
|
||||
xmlrpc_client_transport_call2(
|
||||
xmlrpc_env * const envP,
|
||||
void * const reserved, /* for client handle */
|
||||
xmlrpc_client * const clientP,
|
||||
const xmlrpc_server_info * const serverP,
|
||||
xmlrpc_mem_block * const callXmlP,
|
||||
xmlrpc_mem_block ** const respXmlPP);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** xmlrpc_client_call_asynch
|
||||
**=========================================================================
|
||||
** An asynchronous XML-RPC client.
|
||||
*/
|
||||
|
||||
/* Make an asynchronous XML-RPC call. We make internal copies of all
|
||||
** arguments except user_data, so you can deallocate them safely as soon
|
||||
** as you return. Errors will be passed to the callback. You will need
|
||||
** to run the event loop somehow; see below.
|
||||
** WARNING: If an error occurs while building the argument, the
|
||||
** response handler will be called with a NULL param_array. */
|
||||
void
|
||||
xmlrpc_client_call_asynch(const char * const server_url,
|
||||
const char * const method_name,
|
||||
xmlrpc_response_handler callback,
|
||||
void * const user_data,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
/* As above, but use an xmlrpc_server_info object. The server object can be
|
||||
** safely destroyed as soon as this function returns. */
|
||||
void
|
||||
xmlrpc_client_call_server_asynch(xmlrpc_server_info * const server,
|
||||
const char * const method_name,
|
||||
xmlrpc_response_handler callback,
|
||||
void * const user_data,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
/* As above, but the parameter list is supplied as an xmlrpc_value
|
||||
** containing an array.
|
||||
*/
|
||||
void
|
||||
xmlrpc_client_call_asynch_params(const char * const server_url,
|
||||
const char * const method_name,
|
||||
xmlrpc_response_handler callback,
|
||||
void * const user_data,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
/* As above, but use an xmlrpc_server_info object. The server object can be
|
||||
** safely destroyed as soon as this function returns. */
|
||||
xmlrpc_client_call2(xmlrpc_env * const envP,
|
||||
struct xmlrpc_client * const clientP,
|
||||
const xmlrpc_server_info * const serverInfoP,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const paramArrayP,
|
||||
xmlrpc_value ** const resultPP);
|
||||
|
||||
void
|
||||
xmlrpc_client_call2f(xmlrpc_env * const envP,
|
||||
xmlrpc_client * const clientP,
|
||||
const char * const serverUrl,
|
||||
const char * const methodName,
|
||||
xmlrpc_value ** const resultPP,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
void
|
||||
xmlrpc_client_call_server_asynch_params(
|
||||
xmlrpc_server_info * const server,
|
||||
const char * const method_name,
|
||||
xmlrpc_response_handler callback,
|
||||
void * const user_data,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
/*=========================================================================
|
||||
** Event Loop Interface
|
||||
**=========================================================================
|
||||
** These functions can be used to run the XML-RPC event loop. If you
|
||||
** don't like these, you can also run the libwww event loop directly.
|
||||
*/
|
||||
xmlrpc_client_event_loop_finish(xmlrpc_client * const clientP);
|
||||
|
||||
/* Finish all outstanding asynchronous calls. Alternatively, the loop
|
||||
** will exit if someone calls xmlrpc_client_event_loop_end. */
|
||||
extern void
|
||||
xmlrpc_client_event_loop_finish_asynch(void);
|
||||
void
|
||||
xmlrpc_client_event_loop_finish_timeout(xmlrpc_client * const clientP,
|
||||
unsigned long const milliseconds);
|
||||
|
||||
void
|
||||
xmlrpc_client_start_rpc(xmlrpc_env * const envP,
|
||||
struct xmlrpc_client * const clientP,
|
||||
xmlrpc_server_info * const serverInfoP,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const argP,
|
||||
xmlrpc_response_handler responseHandler,
|
||||
void * const userData);
|
||||
|
||||
/* Finish all outstanding asynchronous calls. */
|
||||
extern void
|
||||
xmlrpc_client_event_loop_finish_asynch_timeout(unsigned long milliseconds);
|
||||
void
|
||||
xmlrpc_client_start_rpcf(xmlrpc_env * const envP,
|
||||
xmlrpc_client * const clientP,
|
||||
const char * const serverUrl,
|
||||
const char * const methodName,
|
||||
xmlrpc_response_handler callback,
|
||||
void * const userData,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
void
|
||||
xmlrpc_client_set_interrupt(xmlrpc_client * const clientP,
|
||||
int * const interruptP);
|
||||
|
||||
#include <xmlrpc-c/client_global.h>
|
||||
|
||||
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
|
||||
**
|
||||
|
@@ -2,33 +2,17 @@
|
||||
#define CLIENT_HPP_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include <xmlrpc-c/girerr.hpp>
|
||||
#include <xmlrpc-c/girmem.hpp>
|
||||
#include <xmlrpc-c/base.hpp>
|
||||
#include <xmlrpc-c/timeout.hpp>
|
||||
#include <xmlrpc-c/client.h>
|
||||
#include <xmlrpc-c/client_transport.hpp>
|
||||
|
||||
namespace xmlrpc_c {
|
||||
|
||||
|
||||
class carriageParm {
|
||||
/*----------------------------------------------------------------------------
|
||||
The parameter to a client for an individual RPC. It tells specifics
|
||||
of how to carry the call to the server and the response back. For
|
||||
example, it may identify the server. It may identify communication
|
||||
protocols to use. It may indicate permission and accounting
|
||||
information.
|
||||
|
||||
This is a base class; the carriage parameter is specific to the
|
||||
class of client. For example, an HTTP-based client would have a
|
||||
URL and HTTP basic authentication info as parameter.
|
||||
-----------------------------------------------------------------------------*/
|
||||
protected:
|
||||
virtual ~carriageParm();
|
||||
carriageParm();
|
||||
};
|
||||
|
||||
class clientTransactionPtr;
|
||||
|
||||
class clientTransaction : public girmem::autoObject {
|
||||
@@ -50,13 +34,18 @@ class clientTransactionPtr : public girmem::autoObjectPtr {
|
||||
|
||||
public:
|
||||
clientTransactionPtr();
|
||||
|
||||
clientTransactionPtr(clientTransaction * const transP);
|
||||
|
||||
virtual ~clientTransactionPtr();
|
||||
|
||||
virtual xmlrpc_c::clientTransaction *
|
||||
operator->() const;
|
||||
};
|
||||
|
||||
class client {
|
||||
class clientPtr;
|
||||
|
||||
class client : public girmem::autoObject {
|
||||
/*----------------------------------------------------------------------------
|
||||
A generic client -- a means of performing an RPC. This is so generic
|
||||
that it can be used for clients that are not XML-RPC.
|
||||
@@ -64,20 +53,71 @@ class client {
|
||||
This is a base class. Derived classes define things such as that
|
||||
XML and HTTP get used to perform the RPC.
|
||||
-----------------------------------------------------------------------------*/
|
||||
friend class clientTransactionPtr;
|
||||
|
||||
public:
|
||||
virtual ~client();
|
||||
|
||||
virtual void
|
||||
call(carriageParm * const carriageParmP,
|
||||
std::string const methodName,
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
xmlrpc_c::rpcOutcome * const outcomeP) = 0;
|
||||
call(xmlrpc_c::carriageParm * const carriageParmP,
|
||||
std::string const& methodName,
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
xmlrpc_c::rpcOutcome * const outcomeP) = 0;
|
||||
|
||||
virtual void
|
||||
start(xmlrpc_c::carriageParm * const carriageParmP,
|
||||
std::string const methodName,
|
||||
std::string const& methodName,
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
xmlrpc_c::clientTransactionPtr const& tranP);
|
||||
|
||||
void
|
||||
finishAsync(xmlrpc_c::timeout const timeout);
|
||||
|
||||
virtual void
|
||||
setInterrupt(int *);
|
||||
};
|
||||
|
||||
class clientPtr : public girmem::autoObjectPtr {
|
||||
public:
|
||||
clientPtr();
|
||||
|
||||
explicit clientPtr(xmlrpc_c::client * const clientP);
|
||||
|
||||
xmlrpc_c::client *
|
||||
operator->() const;
|
||||
|
||||
xmlrpc_c::client *
|
||||
get() const;
|
||||
};
|
||||
|
||||
class serverAccessor : public girmem::autoObject {
|
||||
|
||||
public:
|
||||
serverAccessor(xmlrpc_c::clientPtr const clientP,
|
||||
xmlrpc_c::carriageParmPtr const carriageParmP);
|
||||
|
||||
void
|
||||
call(std::string const& methodName,
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
xmlrpc_c::rpcOutcome * const outcomeP) const;
|
||||
|
||||
private:
|
||||
xmlrpc_c::clientPtr const clientP;
|
||||
xmlrpc_c::carriageParmPtr const carriageParmP;
|
||||
};
|
||||
|
||||
class serverAccessorPtr : public girmem::autoObjectPtr {
|
||||
public:
|
||||
serverAccessorPtr();
|
||||
|
||||
explicit
|
||||
serverAccessorPtr(xmlrpc_c::serverAccessor * const serverAccessorP);
|
||||
|
||||
xmlrpc_c::serverAccessor *
|
||||
operator->() const;
|
||||
|
||||
xmlrpc_c::serverAccessor *
|
||||
get() const;
|
||||
};
|
||||
|
||||
class connection {
|
||||
@@ -100,162 +140,6 @@ public:
|
||||
xmlrpc_c::carriageParm * carriageParmP;
|
||||
};
|
||||
|
||||
class carriageParm_http0 : public carriageParm {
|
||||
|
||||
public:
|
||||
carriageParm_http0(std::string const serverUrl);
|
||||
|
||||
~carriageParm_http0();
|
||||
|
||||
void
|
||||
setBasicAuth(std::string const userid,
|
||||
std::string const password);
|
||||
|
||||
xmlrpc_server_info * c_serverInfoP;
|
||||
|
||||
protected:
|
||||
// Only a derived class is allowed to create an object with no
|
||||
// server URL, and the derived class expected to follow it up
|
||||
// with an instantiate() to establish the server URL.
|
||||
|
||||
carriageParm_http0();
|
||||
|
||||
void
|
||||
instantiate(std::string const serverUrl);
|
||||
};
|
||||
|
||||
class carriageParm_curl0 : public xmlrpc_c::carriageParm_http0 {
|
||||
|
||||
public:
|
||||
carriageParm_curl0(std::string const serverUrl);
|
||||
|
||||
};
|
||||
|
||||
class carriageParm_libwww0 : public xmlrpc_c::carriageParm_http0 {
|
||||
|
||||
public:
|
||||
carriageParm_libwww0(std::string const serverUrl);
|
||||
|
||||
};
|
||||
|
||||
class carriageParm_wininet0 : public xmlrpc_c::carriageParm_http0 {
|
||||
|
||||
public:
|
||||
carriageParm_wininet0(std::string const serverUrl);
|
||||
|
||||
};
|
||||
|
||||
class xmlTransactionPtr;
|
||||
|
||||
class xmlTransaction : public girmem::autoObject {
|
||||
|
||||
friend class xmlTransactionPtr;
|
||||
|
||||
public:
|
||||
virtual void
|
||||
finish(std::string const& responseXml) const;
|
||||
|
||||
virtual void
|
||||
finishErr(girerr::error const& error) const;
|
||||
|
||||
protected:
|
||||
xmlTransaction();
|
||||
};
|
||||
|
||||
class xmlTransactionPtr : public girmem::autoObjectPtr {
|
||||
public:
|
||||
xmlTransactionPtr();
|
||||
|
||||
xmlrpc_c::xmlTransaction *
|
||||
operator->() const;
|
||||
};
|
||||
|
||||
class clientXmlTransport {
|
||||
/*----------------------------------------------------------------------------
|
||||
An object which transports XML to and from an XML-RPC server for an
|
||||
XML-RPC client.
|
||||
|
||||
This is a base class. Derived classes define methods to perform the
|
||||
transportation in particular ways.
|
||||
-----------------------------------------------------------------------------*/
|
||||
public:
|
||||
virtual ~clientXmlTransport();
|
||||
|
||||
virtual void
|
||||
call(xmlrpc_c::carriageParm * const carriageParmP,
|
||||
std::string const& callXml,
|
||||
std::string * const responseXmlP) = 0;
|
||||
|
||||
virtual void
|
||||
start(xmlrpc_c::carriageParm * const carriageParmP,
|
||||
std::string const& callXml,
|
||||
xmlrpc_c::xmlTransactionPtr const& xmlTranP);
|
||||
|
||||
virtual void
|
||||
finishAsync(xmlrpc_c::timeout const timeout);
|
||||
|
||||
static void
|
||||
asyncComplete(
|
||||
struct xmlrpc_call_info * const callInfoP,
|
||||
xmlrpc_mem_block * const responseXmlMP,
|
||||
xmlrpc_env const transportEnv);
|
||||
};
|
||||
|
||||
class clientXmlTransport_http : public xmlrpc_c::clientXmlTransport {
|
||||
/*----------------------------------------------------------------------------
|
||||
A base class for client XML transports that use the simple, classic
|
||||
C HTTP transports.
|
||||
-----------------------------------------------------------------------------*/
|
||||
public:
|
||||
virtual ~clientXmlTransport_http();
|
||||
|
||||
void
|
||||
call(xmlrpc_c::carriageParm * const carriageParmP,
|
||||
std::string const& callXml,
|
||||
std::string * const responseXmlP);
|
||||
|
||||
void
|
||||
start(xmlrpc_c::carriageParm * const carriageParmP,
|
||||
std::string const& callXml,
|
||||
xmlrpc_c::xmlTransactionPtr const& xmlTranP);
|
||||
|
||||
virtual void
|
||||
finishAsync(xmlrpc_c::timeout const timeout);
|
||||
|
||||
protected:
|
||||
clientXmlTransport_http() {} // ensure no one can create
|
||||
struct xmlrpc_client_transport * c_transportP;
|
||||
const struct xmlrpc_client_transport_ops * c_transportOpsP;
|
||||
};
|
||||
|
||||
class clientXmlTransport_curl : public xmlrpc_c::clientXmlTransport_http {
|
||||
|
||||
public:
|
||||
clientXmlTransport_curl(std::string const networkInterface = "",
|
||||
bool const noSslVerifyPeer = false,
|
||||
bool const noSslVerifyHost = false,
|
||||
std::string const userAgent = "");
|
||||
|
||||
~clientXmlTransport_curl();
|
||||
};
|
||||
|
||||
class clientXmlTransport_libwww : public xmlrpc_c::clientXmlTransport_http {
|
||||
|
||||
public:
|
||||
clientXmlTransport_libwww(std::string const appname = "",
|
||||
std::string const appversion = "");
|
||||
|
||||
~clientXmlTransport_libwww();
|
||||
};
|
||||
|
||||
class clientXmlTransport_wininet : public xmlrpc_c::clientXmlTransport_http {
|
||||
|
||||
public:
|
||||
clientXmlTransport_wininet(bool const allowInvalidSslCerts = false);
|
||||
|
||||
~clientXmlTransport_wininet();
|
||||
};
|
||||
|
||||
class client_xml : public xmlrpc_c::client {
|
||||
/*----------------------------------------------------------------------------
|
||||
A client that uses XML-RPC XML in the RPC. This class does not define
|
||||
@@ -264,23 +148,36 @@ class client_xml : public xmlrpc_c::client {
|
||||
public:
|
||||
client_xml(xmlrpc_c::clientXmlTransport * const transportP);
|
||||
|
||||
client_xml(xmlrpc_c::clientXmlTransport * const transportP,
|
||||
xmlrpc_dialect const dialect);
|
||||
|
||||
client_xml(xmlrpc_c::clientXmlTransportPtr const transportP);
|
||||
|
||||
client_xml(xmlrpc_c::clientXmlTransportPtr const transportP,
|
||||
xmlrpc_dialect const dialect);
|
||||
|
||||
~client_xml();
|
||||
|
||||
void
|
||||
call(carriageParm * const carriageParmP,
|
||||
std::string const methodName,
|
||||
std::string const& methodName,
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
xmlrpc_c::rpcOutcome * const outcomeP);
|
||||
|
||||
void
|
||||
start(xmlrpc_c::carriageParm * const carriageParmP,
|
||||
std::string const methodName,
|
||||
std::string const& methodName,
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
xmlrpc_c::clientTransactionPtr const& tranP);
|
||||
|
||||
void
|
||||
finishAsync(xmlrpc_c::timeout const timeout);
|
||||
|
||||
virtual void
|
||||
setInterrupt(int * interruptP);
|
||||
|
||||
private:
|
||||
xmlrpc_c::clientXmlTransport * transportP;
|
||||
struct client_xml_impl * implP;
|
||||
};
|
||||
|
||||
class xmlTransaction_client : public xmlrpc_c::xmlTransaction {
|
||||
@@ -363,32 +260,20 @@ public:
|
||||
xmlrpc_c::fault
|
||||
getFault() const;
|
||||
|
||||
protected:
|
||||
rpc(std::string const methodName,
|
||||
xmlrpc_c::paramList const& paramList);
|
||||
|
||||
virtual ~rpc();
|
||||
|
||||
private:
|
||||
enum state {
|
||||
STATE_UNFINISHED, // RPC is running or not started yet
|
||||
STATE_ERROR, // We couldn't execute the RPC
|
||||
STATE_FAILED, // RPC executed successfully, but failed per XML-RPC
|
||||
STATE_SUCCEEDED // RPC is done, no exception
|
||||
};
|
||||
enum state state;
|
||||
girerr::error * errorP; // Defined only in STATE_ERROR
|
||||
xmlrpc_c::rpcOutcome outcome;
|
||||
// Defined only in STATE_FAILED and STATE_SUCCEEDED
|
||||
std::string methodName;
|
||||
xmlrpc_c::paramList paramList;
|
||||
struct rpc_impl * implP;
|
||||
};
|
||||
|
||||
class rpcPtr : public clientTransactionPtr {
|
||||
public:
|
||||
rpcPtr();
|
||||
|
||||
rpcPtr(xmlrpc_c::rpc * const rpcP);
|
||||
explicit rpcPtr(xmlrpc_c::rpc * const rpcP);
|
||||
|
||||
rpcPtr(std::string const methodName,
|
||||
xmlrpc_c::paramList const& paramList);
|
||||
|
141
libs/xmlrpc-c/include/xmlrpc-c/client_global.h
Normal file
141
libs/xmlrpc-c/include/xmlrpc-c/client_global.h
Normal file
@@ -0,0 +1,141 @@
|
||||
#ifndef CLIENT_GLOBAL_H_INCLUDED
|
||||
#define CLIENT_GLOBAL_H_INCLUDED
|
||||
|
||||
/*=========================================================================
|
||||
** Initialization and Shutdown
|
||||
**=========================================================================
|
||||
** These routines initialize and terminate the XML-RPC client. If you're
|
||||
** already using libwww on your own, you can pass
|
||||
** XMLRPC_CLIENT_SKIP_LIBWWW_INIT to avoid initializing it twice.
|
||||
*/
|
||||
|
||||
#define XMLRPC_CLIENT_NO_FLAGS (0)
|
||||
#define XMLRPC_CLIENT_SKIP_LIBWWW_INIT (1)
|
||||
|
||||
extern void
|
||||
xmlrpc_client_init(int const flags,
|
||||
const char * const appname,
|
||||
const char * const appversion);
|
||||
|
||||
void
|
||||
xmlrpc_client_init2(xmlrpc_env * const env,
|
||||
int const flags,
|
||||
const char * const appname,
|
||||
const char * const appversion,
|
||||
const struct xmlrpc_clientparms * const clientparms,
|
||||
unsigned int const parm_size);
|
||||
|
||||
extern void
|
||||
xmlrpc_client_cleanup(void);
|
||||
|
||||
/*=========================================================================
|
||||
** xmlrpc_client_call
|
||||
**=========================================================================
|
||||
** A synchronous XML-RPC client. Do not attempt to call any of these
|
||||
** functions from inside an asynchronous callback!
|
||||
*/
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_client_call(xmlrpc_env * const envP,
|
||||
const char * const server_url,
|
||||
const char * const method_name,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_client_call_params(xmlrpc_env * const envP,
|
||||
const char * const serverUrl,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_client_call_server(xmlrpc_env * const envP,
|
||||
const xmlrpc_server_info * const server,
|
||||
const char * const method_name,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
xmlrpc_value *
|
||||
xmlrpc_client_call_server_params(
|
||||
xmlrpc_env * const envP,
|
||||
const xmlrpc_server_info * const serverP,
|
||||
const char * const method_name,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
void
|
||||
xmlrpc_client_transport_call(
|
||||
xmlrpc_env * const envP,
|
||||
void * const reserved, /* for client handle */
|
||||
const xmlrpc_server_info * const serverP,
|
||||
xmlrpc_mem_block * const callXmlP,
|
||||
xmlrpc_mem_block ** const respXmlPP);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** xmlrpc_client_call_asynch
|
||||
**=========================================================================
|
||||
** An asynchronous XML-RPC client.
|
||||
*/
|
||||
|
||||
/* Make an asynchronous XML-RPC call. We make internal copies of all
|
||||
** arguments except user_data, so you can deallocate them safely as soon
|
||||
** as you return. Errors will be passed to the callback. You will need
|
||||
** to run the event loop somehow; see below.
|
||||
** WARNING: If an error occurs while building the argument, the
|
||||
** response handler will be called with a NULL param_array. */
|
||||
void
|
||||
xmlrpc_client_call_asynch(const char * const server_url,
|
||||
const char * const method_name,
|
||||
xmlrpc_response_handler callback,
|
||||
void * const user_data,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
/* As above, but use an xmlrpc_server_info object. The server object can be
|
||||
** safely destroyed as soon as this function returns. */
|
||||
void
|
||||
xmlrpc_client_call_server_asynch(xmlrpc_server_info * const server,
|
||||
const char * const method_name,
|
||||
xmlrpc_response_handler callback,
|
||||
void * const user_data,
|
||||
const char * const format,
|
||||
...);
|
||||
|
||||
/* As above, but the parameter list is supplied as an xmlrpc_value
|
||||
** containing an array.
|
||||
*/
|
||||
void
|
||||
xmlrpc_client_call_asynch_params(const char * const server_url,
|
||||
const char * const method_name,
|
||||
xmlrpc_response_handler callback,
|
||||
void * const user_data,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
/* As above, but use an xmlrpc_server_info object. The server object can be
|
||||
** safely destroyed as soon as this function returns. */
|
||||
void
|
||||
xmlrpc_client_call_server_asynch_params(
|
||||
xmlrpc_server_info * const server,
|
||||
const char * const method_name,
|
||||
xmlrpc_response_handler callback,
|
||||
void * const user_data,
|
||||
xmlrpc_value * const paramArrayP);
|
||||
|
||||
/*=========================================================================
|
||||
** Event Loop Interface
|
||||
**=========================================================================
|
||||
** These functions can be used to run the XML-RPC event loop. If you
|
||||
** don't like these, you can also run the libwww event loop directly.
|
||||
*/
|
||||
|
||||
/* Finish all outstanding asynchronous calls. Alternatively, the loop
|
||||
** will exit if someone calls xmlrpc_client_event_loop_end. */
|
||||
extern void
|
||||
xmlrpc_client_event_loop_finish_asynch(void);
|
||||
|
||||
|
||||
/* Finish all outstanding asynchronous calls. */
|
||||
extern void
|
||||
xmlrpc_client_event_loop_finish_asynch_timeout(unsigned long const milliseconds);
|
||||
|
||||
#endif
|
@@ -14,24 +14,43 @@
|
||||
#ifndef XMLRPC_CLIENT_INT_H_INCLUDED
|
||||
#define XMLRPC_CLIENT_INT_H_INCLUDED
|
||||
|
||||
#include "xmlrpc-c/util.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
struct _xmlrpc_server_info {
|
||||
char *_server_url;
|
||||
char *_http_basic_auth;
|
||||
const char * serverUrl;
|
||||
struct {
|
||||
bool basic;
|
||||
bool digest;
|
||||
bool gssnegotiate;
|
||||
bool ntlm;
|
||||
} allowedAuth;
|
||||
const char * userNamePw;
|
||||
/* The username/password value for HTTP, i.e. in
|
||||
"user:password" form
|
||||
|
||||
This can be NULL to indicate "none", but only if 'allowedAuth'
|
||||
doesn't allow any form of authentication.
|
||||
*/
|
||||
const char * basicAuthHdrValue;
|
||||
/* A complete value for an HTTP Authorization: header that
|
||||
requests HTTP basic authentication. This exists whether
|
||||
or not 'allowedAuth' allows basic authentication, and is
|
||||
completely redundant with 'userNamePw'. It exists mainly
|
||||
for historical reasons, and may also save some computation
|
||||
when the same xmrpc_server_info is used for multiple
|
||||
HTTP connections.
|
||||
|
||||
This is NULL exactly when 'userNamePw' is NULL.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Create a new server info record, with a copy of the old server. */
|
||||
extern xmlrpc_server_info *
|
||||
xmlrpc_server_info_copy(xmlrpc_env *env, xmlrpc_server_info *aserver);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** Transport Implementation functions.
|
||||
**=========================================================================
|
||||
*/
|
||||
**========================================================================= */
|
||||
#include "xmlrpc-c/transport.h"
|
||||
|
||||
/* The generalized event loop. This uses the above flags. For more details,
|
||||
|
@@ -14,8 +14,6 @@ class clientSimple {
|
||||
public:
|
||||
clientSimple();
|
||||
|
||||
~clientSimple();
|
||||
|
||||
void
|
||||
call(std::string const serverUrl,
|
||||
std::string const methodName,
|
||||
@@ -35,8 +33,7 @@ public:
|
||||
xmlrpc_c::value * const resultP);
|
||||
|
||||
private:
|
||||
xmlrpc_c::client * clientP;
|
||||
xmlrpc_c::clientXmlTransport * transportP;
|
||||
xmlrpc_c::clientPtr clientP;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
448
libs/xmlrpc-c/include/xmlrpc-c/client_transport.hpp
Normal file
448
libs/xmlrpc-c/include/xmlrpc-c/client_transport.hpp
Normal file
@@ -0,0 +1,448 @@
|
||||
#ifndef CLIENT_TRANSPORT_HPP_INCLUDED
|
||||
#define CLIENT_TRANSPORT_HPP_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <xmlrpc-c/util.h>
|
||||
#include <xmlrpc-c/client.h>
|
||||
#include <xmlrpc-c/girerr.hpp>
|
||||
#include <xmlrpc-c/girmem.hpp>
|
||||
#include <xmlrpc-c/timeout.hpp>
|
||||
|
||||
namespace xmlrpc_c {
|
||||
|
||||
class carriageParmPtr;
|
||||
|
||||
class carriageParm : public girmem::autoObject {
|
||||
/*----------------------------------------------------------------------------
|
||||
The parameter to a client for an individual RPC. It tells specifics
|
||||
of how to carry the call to the server and the response back. For
|
||||
example, it may identify the server. It may identify communication
|
||||
protocols to use. It may indicate permission and accounting
|
||||
information.
|
||||
|
||||
This is a base class; the carriage parameter is specific to the
|
||||
class of client. For example, an HTTP-based client would have a
|
||||
URL and HTTP basic authentication info as parameter.
|
||||
-----------------------------------------------------------------------------*/
|
||||
protected:
|
||||
virtual ~carriageParm();
|
||||
carriageParm();
|
||||
};
|
||||
|
||||
class carriageParmPtr : public girmem::autoObjectPtr {
|
||||
|
||||
public:
|
||||
carriageParmPtr();
|
||||
|
||||
explicit carriageParmPtr(xmlrpc_c::carriageParm * const carriageParmP);
|
||||
|
||||
xmlrpc_c::carriageParm *
|
||||
operator->() const;
|
||||
|
||||
xmlrpc_c::carriageParm *
|
||||
get() const;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
class xmlTransactionPtr;
|
||||
|
||||
class xmlTransaction : public girmem::autoObject {
|
||||
|
||||
friend class xmlTransactionPtr;
|
||||
|
||||
public:
|
||||
virtual void
|
||||
finish(std::string const& responseXml) const;
|
||||
|
||||
virtual void
|
||||
finishErr(girerr::error const& error) const;
|
||||
|
||||
protected:
|
||||
xmlTransaction();
|
||||
};
|
||||
|
||||
class xmlTransactionPtr : public girmem::autoObjectPtr {
|
||||
public:
|
||||
xmlTransactionPtr();
|
||||
|
||||
xmlTransactionPtr(xmlTransaction * xmlTransP);
|
||||
|
||||
xmlrpc_c::xmlTransaction *
|
||||
operator->() const;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
class clientXmlTransport : public girmem::autoObject {
|
||||
/*----------------------------------------------------------------------------
|
||||
An object which transports XML to and from an XML-RPC server for an
|
||||
XML-RPC client.
|
||||
|
||||
This is a base class. Derived classes define methods to perform the
|
||||
transportation in particular ways.
|
||||
-----------------------------------------------------------------------------*/
|
||||
public:
|
||||
virtual ~clientXmlTransport();
|
||||
|
||||
virtual void
|
||||
call(xmlrpc_c::carriageParm * const carriageParmP,
|
||||
std::string const& callXml,
|
||||
std::string * const responseXmlP) = 0;
|
||||
|
||||
virtual void
|
||||
start(xmlrpc_c::carriageParm * const carriageParmP,
|
||||
std::string const& callXml,
|
||||
xmlrpc_c::xmlTransactionPtr const& xmlTranP);
|
||||
|
||||
virtual void
|
||||
finishAsync(xmlrpc_c::timeout const timeout);
|
||||
|
||||
static void
|
||||
asyncComplete(
|
||||
struct xmlrpc_call_info * const callInfoP,
|
||||
xmlrpc_mem_block * const responseXmlMP,
|
||||
xmlrpc_env const transportEnv);
|
||||
|
||||
virtual void
|
||||
setInterrupt(int * const interruptP);
|
||||
};
|
||||
|
||||
class clientXmlTransportPtr : public girmem::autoObjectPtr {
|
||||
|
||||
public:
|
||||
clientXmlTransportPtr();
|
||||
|
||||
clientXmlTransportPtr(xmlrpc_c::clientXmlTransport * const transportP);
|
||||
|
||||
xmlrpc_c::clientXmlTransport *
|
||||
operator->() const;
|
||||
|
||||
xmlrpc_c::clientXmlTransport *
|
||||
get() const;
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
HTTP
|
||||
===========================================================================*/
|
||||
|
||||
class carriageParm_http0 : public xmlrpc_c::carriageParm {
|
||||
|
||||
public:
|
||||
carriageParm_http0(std::string const serverUrl);
|
||||
|
||||
~carriageParm_http0();
|
||||
|
||||
void
|
||||
setUser(std::string const userid,
|
||||
std::string const password);
|
||||
|
||||
void
|
||||
allowAuthBasic();
|
||||
|
||||
void
|
||||
disallowAuthBasic();
|
||||
|
||||
void
|
||||
allowAuthDigest();
|
||||
|
||||
void
|
||||
disallowAuthDigest();
|
||||
|
||||
void
|
||||
allowAuthNegotiate();
|
||||
|
||||
void
|
||||
disallowAuthNegotiate();
|
||||
|
||||
void
|
||||
allowAuthNtlm();
|
||||
|
||||
void
|
||||
disallowAuthNtlm();
|
||||
|
||||
void
|
||||
setBasicAuth(std::string const userid,
|
||||
std::string const password);
|
||||
|
||||
xmlrpc_server_info * c_serverInfoP;
|
||||
|
||||
protected:
|
||||
// Only a derived class is allowed to create an object with no
|
||||
// server URL, and the derived class is expected to follow it up
|
||||
// with an instantiate() to establish the server URL.
|
||||
|
||||
carriageParm_http0();
|
||||
|
||||
void
|
||||
instantiate(std::string const serverUrl);
|
||||
};
|
||||
|
||||
class carriageParm_http0Ptr : public xmlrpc_c::carriageParmPtr {
|
||||
|
||||
public:
|
||||
carriageParm_http0Ptr();
|
||||
carriageParm_http0Ptr(xmlrpc_c::carriageParm_http0 * const carriageParmP);
|
||||
|
||||
xmlrpc_c::carriageParm_http0 *
|
||||
operator->() const;
|
||||
};
|
||||
|
||||
class clientXmlTransport_http : public xmlrpc_c::clientXmlTransport {
|
||||
/*----------------------------------------------------------------------------
|
||||
A base class for client XML transports that use the simple, classic
|
||||
C HTTP transports.
|
||||
-----------------------------------------------------------------------------*/
|
||||
public:
|
||||
virtual ~clientXmlTransport_http();
|
||||
|
||||
void
|
||||
call(xmlrpc_c::carriageParm * const carriageParmP,
|
||||
std::string const& callXml,
|
||||
std::string * const responseXmlP);
|
||||
|
||||
void
|
||||
start(xmlrpc_c::carriageParm * const carriageParmP,
|
||||
std::string const& callXml,
|
||||
xmlrpc_c::xmlTransactionPtr const& xmlTranP);
|
||||
|
||||
virtual void
|
||||
finishAsync(xmlrpc_c::timeout const timeout);
|
||||
|
||||
virtual void
|
||||
setInterrupt(int * const interruptP);
|
||||
|
||||
static std::vector<std::string>
|
||||
availableTypes();
|
||||
|
||||
static clientXmlTransportPtr
|
||||
create();
|
||||
|
||||
protected:
|
||||
clientXmlTransport_http() {} // ensure no one can create
|
||||
struct xmlrpc_client_transport * c_transportP;
|
||||
const struct xmlrpc_client_transport_ops * c_transportOpsP;
|
||||
};
|
||||
|
||||
|
||||
/*===========================================================================
|
||||
curl
|
||||
===========================================================================*/
|
||||
|
||||
class carriageParm_curl0 : public xmlrpc_c::carriageParm_http0 {
|
||||
|
||||
public:
|
||||
carriageParm_curl0(std::string const serverUrl);
|
||||
};
|
||||
|
||||
class carriageParm_curl0Ptr : public xmlrpc_c::carriageParm_http0Ptr {
|
||||
|
||||
public:
|
||||
carriageParm_curl0Ptr();
|
||||
carriageParm_curl0Ptr(xmlrpc_c::carriageParm_curl0 * const carriageParmP);
|
||||
|
||||
xmlrpc_c::carriageParm_curl0 *
|
||||
operator->() const;
|
||||
};
|
||||
|
||||
class clientXmlTransport_curl : public xmlrpc_c::clientXmlTransport_http {
|
||||
|
||||
public:
|
||||
class constrOpt {
|
||||
public:
|
||||
constrOpt();
|
||||
|
||||
constrOpt & network_interface (std::string const& arg);
|
||||
constrOpt & no_ssl_verifypeer (bool const& arg);
|
||||
constrOpt & no_ssl_verifyhost (bool const& arg);
|
||||
constrOpt & user_agent (std::string const& arg);
|
||||
constrOpt & ssl_cert (std::string const& arg);
|
||||
constrOpt & sslcerttype (std::string const& arg);
|
||||
constrOpt & sslcertpasswd (std::string const& arg);
|
||||
constrOpt & sslkey (std::string const& arg);
|
||||
constrOpt & sslkeytype (std::string const& arg);
|
||||
constrOpt & sslkeypasswd (std::string const& arg);
|
||||
constrOpt & sslengine (std::string const& arg);
|
||||
constrOpt & sslengine_default (bool const& arg);
|
||||
constrOpt & sslversion (xmlrpc_sslversion const& arg);
|
||||
constrOpt & cainfo (std::string const& arg);
|
||||
constrOpt & capath (std::string const& arg);
|
||||
constrOpt & randomfile (std::string const& arg);
|
||||
constrOpt & egdsocket (std::string const& arg);
|
||||
constrOpt & ssl_cipher_list (std::string const& arg);
|
||||
constrOpt & timeout (unsigned int const& arg);
|
||||
|
||||
struct {
|
||||
std::string network_interface;
|
||||
bool no_ssl_verifypeer;
|
||||
bool no_ssl_verifyhost;
|
||||
std::string user_agent;
|
||||
std::string ssl_cert;
|
||||
std::string sslcerttype;
|
||||
std::string sslcertpasswd;
|
||||
std::string sslkey;
|
||||
std::string sslkeytype;
|
||||
std::string sslkeypasswd;
|
||||
std::string sslengine;
|
||||
bool sslengine_default;
|
||||
xmlrpc_sslversion sslversion;
|
||||
std::string cainfo;
|
||||
std::string capath;
|
||||
std::string randomfile;
|
||||
std::string egdsocket;
|
||||
std::string ssl_cipher_list;
|
||||
unsigned int timeout;
|
||||
} value;
|
||||
struct {
|
||||
bool network_interface;
|
||||
bool no_ssl_verifypeer;
|
||||
bool no_ssl_verifyhost;
|
||||
bool user_agent;
|
||||
bool ssl_cert;
|
||||
bool sslcerttype;
|
||||
bool sslcertpasswd;
|
||||
bool sslkey;
|
||||
bool sslkeytype;
|
||||
bool sslkeypasswd;
|
||||
bool sslengine;
|
||||
bool sslengine_default;
|
||||
bool sslversion;
|
||||
bool cainfo;
|
||||
bool capath;
|
||||
bool randomfile;
|
||||
bool egdsocket;
|
||||
bool ssl_cipher_list;
|
||||
bool timeout;
|
||||
} present;
|
||||
};
|
||||
|
||||
clientXmlTransport_curl(constrOpt const& opt);
|
||||
|
||||
clientXmlTransport_curl(std::string const networkInterface = "",
|
||||
bool const noSslVerifyPeer = false,
|
||||
bool const noSslVerifyHost = false,
|
||||
std::string const userAgent = "");
|
||||
|
||||
~clientXmlTransport_curl();
|
||||
|
||||
private:
|
||||
void
|
||||
initialize(constrOpt const& opt);
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
libwww
|
||||
===========================================================================*/
|
||||
|
||||
class carriageParm_libwww0 : public xmlrpc_c::carriageParm_http0 {
|
||||
|
||||
public:
|
||||
carriageParm_libwww0(std::string const serverUrl);
|
||||
|
||||
};
|
||||
|
||||
class carriageParm_libwww0Ptr : public xmlrpc_c::carriageParm_http0Ptr {
|
||||
|
||||
public:
|
||||
carriageParm_libwww0Ptr();
|
||||
carriageParm_libwww0Ptr(xmlrpc_c::carriageParm_libwww0 * const);
|
||||
|
||||
xmlrpc_c::carriageParm_libwww0 *
|
||||
operator->() const;
|
||||
};
|
||||
|
||||
class clientXmlTransport_libwww : public xmlrpc_c::clientXmlTransport_http {
|
||||
|
||||
public:
|
||||
clientXmlTransport_libwww(std::string const appname = "",
|
||||
std::string const appversion = "");
|
||||
|
||||
~clientXmlTransport_libwww();
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
wininet
|
||||
===========================================================================*/
|
||||
|
||||
class carriageParm_wininet0 : public xmlrpc_c::carriageParm_http0 {
|
||||
|
||||
public:
|
||||
carriageParm_wininet0(std::string const serverUrl);
|
||||
|
||||
};
|
||||
|
||||
class carriageParm_wininet0Ptr : public xmlrpc_c::carriageParm_http0Ptr {
|
||||
|
||||
public:
|
||||
carriageParm_wininet0Ptr();
|
||||
carriageParm_wininet0Ptr(xmlrpc_c::carriageParm_wininet0 * const);
|
||||
|
||||
xmlrpc_c::carriageParm_wininet0 *
|
||||
operator->() const;
|
||||
};
|
||||
|
||||
class clientXmlTransport_wininet : public xmlrpc_c::clientXmlTransport_http {
|
||||
|
||||
public:
|
||||
clientXmlTransport_wininet(bool const allowInvalidSslCerts = false);
|
||||
|
||||
~clientXmlTransport_wininet();
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
pstream
|
||||
===========================================================================*/
|
||||
|
||||
class packetSocket;
|
||||
|
||||
class carriageParm_pstream : public xmlrpc_c::carriageParm {
|
||||
|
||||
// There are no parameters for carrying an RPC on a packet stream.
|
||||
// There's only one way to carry it.
|
||||
};
|
||||
|
||||
class carriageParm_pstreamPtr : public xmlrpc_c::carriageParmPtr {
|
||||
|
||||
public:
|
||||
carriageParm_pstreamPtr();
|
||||
carriageParm_pstreamPtr(
|
||||
xmlrpc_c::carriageParm_pstream * const carriageParmP);
|
||||
|
||||
xmlrpc_c::carriageParm_pstream *
|
||||
operator->() const;
|
||||
};
|
||||
|
||||
class clientXmlTransport_pstream : public xmlrpc_c::clientXmlTransport {
|
||||
|
||||
public:
|
||||
class constrOpt {
|
||||
public:
|
||||
constrOpt();
|
||||
|
||||
constrOpt & fd (int const& arg);
|
||||
|
||||
struct {
|
||||
int fd;
|
||||
} value;
|
||||
struct {
|
||||
bool fd;
|
||||
} present;
|
||||
};
|
||||
|
||||
clientXmlTransport_pstream(constrOpt const& opt);
|
||||
|
||||
~clientXmlTransport_pstream();
|
||||
|
||||
void
|
||||
call(xmlrpc_c::carriageParm * const carriageParmP,
|
||||
std::string const& callXml,
|
||||
std::string * const responseXmlP);
|
||||
|
||||
private:
|
||||
packetSocket * packetSocketP;
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
#endif
|
@@ -21,6 +21,11 @@ private:
|
||||
std::string _what;
|
||||
};
|
||||
|
||||
// throwf() always throws a girerr::error .
|
||||
|
||||
void
|
||||
throwf(const char * const format, ...);
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
@@ -19,6 +19,7 @@
|
||||
# include <pthread.h>
|
||||
typedef pthread_mutex_t girmem_lock;
|
||||
#else
|
||||
# include <windows.h>
|
||||
typedef CRITICAL_SECTION girmem_lock;
|
||||
#endif
|
||||
|
||||
@@ -51,14 +52,20 @@ public:
|
||||
~autoObjectPtr();
|
||||
|
||||
void
|
||||
instantiate(girmem::autoObject * const objectP);
|
||||
|
||||
point(girmem::autoObject * const objectP);
|
||||
|
||||
void
|
||||
unpoint();
|
||||
|
||||
autoObjectPtr
|
||||
operator=(girmem::autoObjectPtr const& objectPtr);
|
||||
|
||||
girmem::autoObject *
|
||||
operator->() const;
|
||||
|
||||
girmem::autoObject *
|
||||
get() const;
|
||||
|
||||
protected:
|
||||
girmem::autoObject * objectP;
|
||||
};
|
||||
|
19
libs/xmlrpc-c/include/xmlrpc-c/inttypes.h
Normal file
19
libs/xmlrpc-c/include/xmlrpc-c/inttypes.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef XMLRPC_INTTYPES_H_INCLUDED
|
||||
#define XMLRPC_INTTYPES_H_INCLUDED
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
typedef unsigned short xmlrpc_uint16_t;
|
||||
typedef unsigned int xmlrpc_uint32_t;
|
||||
typedef unsigned __int64 xmlrpc_uint64_t;
|
||||
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
|
||||
typedef uint16_t xmlrpc_uint16_t;
|
||||
typedef uint32_t xmlrpc_uint32_t;
|
||||
typedef uint64_t xmlrpc_uint64_t;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -25,6 +25,7 @@
|
||||
// -Bryan 2005.03.12.
|
||||
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <xmlrpc-c/base.h>
|
||||
#include <xmlrpc-c/client.h>
|
||||
@@ -87,7 +88,7 @@ public:
|
||||
XmlRpcEnv (void) { xmlrpc_env_init(&mEnv); }
|
||||
~XmlRpcEnv (void) { xmlrpc_env_clean(&mEnv); }
|
||||
|
||||
bool faultOccurred (void) const { return mEnv.fault_occurred; };
|
||||
bool faultOccurred (void) const {return (mEnv.fault_occurred != 0);};
|
||||
bool hasFaultOccurred (void) const { return faultOccurred(); };
|
||||
/* hasFaultOccurred() is for backward compatibility.
|
||||
faultOccurred() is a superior name for this.
|
||||
|
165
libs/xmlrpc-c/include/xmlrpc-c/packetsocket.hpp
Normal file
165
libs/xmlrpc-c/include/xmlrpc-c/packetsocket.hpp
Normal file
@@ -0,0 +1,165 @@
|
||||
#ifndef PACKETSOCKET_HPP_INCLUDED
|
||||
#define PACKETSOCKET_HPP_INCLUDED
|
||||
|
||||
/*============================================================================
|
||||
packetsocket
|
||||
==============================================================================
|
||||
This is a facility for communicating socket-style, with defined
|
||||
packets like a datagram socket but with reliable delivery like a
|
||||
stream socket. It's like a POSIX "sequential packet" socket, except
|
||||
it is built on top of a stream socket, so it is usable on the many
|
||||
systems that have stream sockets but not sequential packet sockets.
|
||||
============================================================================*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string>
|
||||
#include <queue>
|
||||
|
||||
#include <xmlrpc-c/girmem.hpp>
|
||||
|
||||
namespace xmlrpc_c {
|
||||
|
||||
class packet : public girmem::autoObject {
|
||||
|
||||
public:
|
||||
packet();
|
||||
|
||||
packet(const unsigned char * const data,
|
||||
size_t const dataLength);
|
||||
|
||||
packet(const char * const data,
|
||||
size_t const dataLength);
|
||||
|
||||
~packet();
|
||||
|
||||
unsigned char *
|
||||
getBytes() const { return this->bytes; }
|
||||
|
||||
size_t
|
||||
getLength() const { return this->length; }
|
||||
|
||||
void
|
||||
addData(const unsigned char * const data,
|
||||
size_t const dataLength);
|
||||
|
||||
private:
|
||||
unsigned char * bytes; // malloc'ed
|
||||
size_t length;
|
||||
size_t allocSize;
|
||||
|
||||
void
|
||||
initialize(const unsigned char * const data,
|
||||
size_t const dataLength);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class packetPtr: public girmem::autoObjectPtr {
|
||||
|
||||
public:
|
||||
packetPtr();
|
||||
|
||||
explicit packetPtr(packet * const packetP);
|
||||
|
||||
packet *
|
||||
operator->() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class packetSocket {
|
||||
/*----------------------------------------------------------------------------
|
||||
This is an Internet communication vehicle that transmits individual
|
||||
variable-length packets of text.
|
||||
|
||||
It is based on a stream socket.
|
||||
|
||||
It would be much better to use a kernel SOCK_SEQPACKET socket, but
|
||||
Linux 2.4 does not have them.
|
||||
-----------------------------------------------------------------------------*/
|
||||
public:
|
||||
packetSocket(int sockFd);
|
||||
|
||||
~packetSocket();
|
||||
|
||||
void
|
||||
writeWait(packetPtr const& packetPtr) const;
|
||||
|
||||
void
|
||||
read(bool * const eofP,
|
||||
bool * const gotPacketP,
|
||||
packetPtr * const packetPP);
|
||||
|
||||
void
|
||||
readWait(volatile const int * const interruptP,
|
||||
bool * const eofP,
|
||||
bool * const gotPacketP,
|
||||
packetPtr * const packetPP);
|
||||
|
||||
void
|
||||
readWait(volatile const int * const interruptP,
|
||||
bool * const eofP,
|
||||
packetPtr * const packetPP);
|
||||
|
||||
void
|
||||
readWait(bool * const eofP,
|
||||
packetPtr * const packetPP);
|
||||
|
||||
private:
|
||||
int sockFd;
|
||||
// The kernel stream socket we use.
|
||||
bool eof;
|
||||
// The packet socket is at end-of-file for reads.
|
||||
// 'readBuffer' is empty and there won't be any more data to fill
|
||||
// it because the underlying stream socket is closed.
|
||||
std::queue<packetPtr> readBuffer;
|
||||
packetPtr packetAccumP;
|
||||
// The receive packet we're currently accumulating; it will join
|
||||
// 'readBuffer' when we've received the whole packet (and we've
|
||||
// seen the END escape sequence so we know we've received it all).
|
||||
// If we're not currently accumulating a packet (haven't seen a
|
||||
// PKT escape sequence), this points to nothing.
|
||||
bool inEscapeSeq;
|
||||
// In our trek through the data read from the underlying stream
|
||||
// socket, we are after an ESC character and before the end of the
|
||||
// escape sequence. 'escAccum' shows what of the escape sequence
|
||||
// we've seen so far.
|
||||
bool inPacket;
|
||||
// We're now receiving packet data from the underlying stream
|
||||
// socket. We've seen a complete PKT escape sequence, but have not
|
||||
// seen a complete END escape sequence since.
|
||||
struct {
|
||||
unsigned char bytes[3];
|
||||
size_t len;
|
||||
} escAccum;
|
||||
|
||||
void
|
||||
bufferFinishedPacket();
|
||||
|
||||
void
|
||||
takeSomeEscapeSeq(const unsigned char * const buffer,
|
||||
size_t const length,
|
||||
size_t * const bytesTakenP);
|
||||
|
||||
void
|
||||
takeSomePacket(const unsigned char * const buffer,
|
||||
size_t const length,
|
||||
size_t * const bytesTakenP);
|
||||
|
||||
void
|
||||
verifyNothingAccumulated();
|
||||
|
||||
void
|
||||
processBytesRead(const unsigned char * const buffer,
|
||||
size_t const bytesRead);
|
||||
|
||||
void
|
||||
readFromFile();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
@@ -32,15 +32,6 @@ public:
|
||||
std::string signature() const { return _signature; };
|
||||
std::string help() const { return _help; };
|
||||
|
||||
// self() is a strange concession to the fact that we interface with
|
||||
// C code. C code needs a regular pointer to this method, but our
|
||||
// C++ interface carefully prevents one from making such a pointer,
|
||||
// since it would be an uncounted reference. So users of self() must
|
||||
// make sure that the reference it returns is always subordinate to a
|
||||
// methodPtr reference.
|
||||
|
||||
xmlrpc_c::method * self();
|
||||
|
||||
protected:
|
||||
std::string _signature;
|
||||
std::string _help;
|
||||
@@ -95,8 +86,6 @@ public:
|
||||
execute(std::string const& methodName,
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
xmlrpc_c::value * const resultP) = 0;
|
||||
|
||||
xmlrpc_c::defaultMethod * self(); // analogous to 'method' class
|
||||
};
|
||||
|
||||
class defaultMethodPtr : public girmem::autoObjectPtr {
|
||||
@@ -108,9 +97,14 @@ public:
|
||||
|
||||
xmlrpc_c::defaultMethod *
|
||||
operator->() const;
|
||||
|
||||
xmlrpc_c::defaultMethod *
|
||||
get() const;
|
||||
};
|
||||
|
||||
class registry {
|
||||
|
||||
|
||||
class registry : public girmem::autoObject {
|
||||
/*----------------------------------------------------------------------------
|
||||
An Xmlrpc-c server method registry. An Xmlrpc-c server transport
|
||||
(e.g. an HTTP server) uses this object to process an incoming
|
||||
@@ -131,6 +125,20 @@ public:
|
||||
|
||||
void
|
||||
disableIntrospection();
|
||||
|
||||
class shutdown {
|
||||
public:
|
||||
virtual ~shutdown() = 0;
|
||||
virtual void
|
||||
doit(std::string const& comment,
|
||||
void * const callInfo) const = 0;
|
||||
};
|
||||
|
||||
void
|
||||
setShutdown(const shutdown * const shutdownP);
|
||||
|
||||
void
|
||||
setDialect(xmlrpc_dialect const dialect);
|
||||
|
||||
void
|
||||
processCall(std::string const& body,
|
||||
@@ -145,23 +153,37 @@ public:
|
||||
private:
|
||||
|
||||
xmlrpc_registry * c_registryP;
|
||||
/* Pointer to the C registry object we use to implement this
|
||||
object.
|
||||
*/
|
||||
// Pointer to the C registry object we use to implement this
|
||||
// object.
|
||||
|
||||
std::list<xmlrpc_c::methodPtr> methodList;
|
||||
/* This is a list of all the method objects (actually, pointers
|
||||
to them). But since the real registry is the C registry object,
|
||||
all this list is for is to maintain references to the objects
|
||||
to which the C registry points so that they continue to exist.
|
||||
*/
|
||||
// This is a list of all the method objects (actually, pointers
|
||||
// to them). But since the real registry is the C registry object,
|
||||
// all this list is for is to maintain references to the objects
|
||||
// to which the C registry points so that they continue to exist.
|
||||
|
||||
xmlrpc_c::defaultMethodPtr defaultMethodP;
|
||||
/* The real identifier of the default method is the C registry
|
||||
object; this member exists only to maintain a reference to the
|
||||
object to which the C registry points so that it will continue
|
||||
to exist.
|
||||
*/
|
||||
// The real identifier of the default method is the C registry
|
||||
// object; this member exists only to maintain a reference to the
|
||||
// object to which the C registry points so that it will continue
|
||||
// to exist.
|
||||
};
|
||||
|
||||
|
||||
class registryPtr : public girmem::autoObjectPtr {
|
||||
|
||||
public:
|
||||
registryPtr();
|
||||
|
||||
registryPtr(xmlrpc_c::registry * const registryP);
|
||||
|
||||
xmlrpc_c::registry *
|
||||
operator->() const;
|
||||
|
||||
xmlrpc_c::registry *
|
||||
get() const;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
24
libs/xmlrpc-c/include/xmlrpc-c/select_int.h
Normal file
24
libs/xmlrpc-c/include/xmlrpc-c/select_int.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef SELECT_INT_H_INCLUDED
|
||||
#define SELECT_INT_H_INCLUDED
|
||||
|
||||
#ifndef WIN32
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
|
||||
#include "xmlrpc-c/time_int.h"
|
||||
#ifdef WIN32
|
||||
#ifndef sigset_t
|
||||
typedef int sigset_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int
|
||||
xmlrpc_pselect(int const n,
|
||||
fd_set * const readfdsP,
|
||||
fd_set * const writefdsP,
|
||||
fd_set * const exceptfdsP,
|
||||
const xmlrpc_timespec * const timeoutP,
|
||||
sigset_t * const sigmaskP);
|
||||
|
||||
#endif
|
@@ -9,145 +9,121 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*=========================================================================
|
||||
** XML-RPC Server Method Registry
|
||||
**=========================================================================
|
||||
** A method registry maintains a list of functions, and handles
|
||||
** dispatching. To build an XML-RPC server, just add an XML-RPC protocol
|
||||
** driver.
|
||||
**
|
||||
** Methods are C functions which take some combination of the following
|
||||
** parameters. All pointers except user_data belong to the library, and
|
||||
** must not be freed by the callback or used after the callback returns.
|
||||
**
|
||||
** env: An XML-RPC error-handling environment. No faults will be
|
||||
** set when the function is called. If an error occurs,
|
||||
** set an appropriate fault and return NULL. (If a fault is
|
||||
** set, the NULL return value will be enforced!)
|
||||
** host: The 'Host:' header passed by the XML-RPC client, or NULL,
|
||||
** if no 'Host:' header has been provided.
|
||||
** method_name: The name used to call this method.
|
||||
** user_data: The user_data used to register this method.
|
||||
** param_array: The parameters passed to this function, stored in an
|
||||
** XML-RPC array. You are *not* responsible for calling
|
||||
** xmlrpc_DECREF on this array.
|
||||
**
|
||||
** Return value: If no fault has been set, the function must return a
|
||||
** valid xmlrpc_value. This will be serialized, returned
|
||||
** to the caller, and xmlrpc_DECREF'd.
|
||||
*/
|
||||
typedef struct xmlrpc_registry xmlrpc_registry;
|
||||
|
||||
/* A function to call before invoking a method for doing things like access
|
||||
** control or sanity checks. If a fault is set from this function, the
|
||||
** method will not be called and the fault will be returned. */
|
||||
typedef void
|
||||
(*xmlrpc_preinvoke_method)(xmlrpc_env * env,
|
||||
const char * method_name,
|
||||
xmlrpc_value * param_array,
|
||||
void * user_data);
|
||||
(*xmlrpc_preinvoke_method)(xmlrpc_env * const envP,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const paramArrayP,
|
||||
void * const userData);
|
||||
|
||||
/* An ordinary method. */
|
||||
typedef xmlrpc_value *
|
||||
(*xmlrpc_method)(xmlrpc_env * env,
|
||||
xmlrpc_value * param_array,
|
||||
void * user_data);
|
||||
(*xmlrpc_method1)(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const paramArrayP,
|
||||
void * const serverInfo);
|
||||
|
||||
/* A default method to call if no method can be found. */
|
||||
typedef xmlrpc_value *
|
||||
(*xmlrpc_default_method)(xmlrpc_env * env,
|
||||
const char * host,
|
||||
const char * method_name,
|
||||
xmlrpc_value * param_array,
|
||||
void * user_data);
|
||||
(*xmlrpc_method2)(xmlrpc_env * const envP,
|
||||
xmlrpc_value * const paramArrayP,
|
||||
void * const serverInfo,
|
||||
void * const callInfo);
|
||||
|
||||
/* Our registry structure. This has no public members. */
|
||||
typedef struct _xmlrpc_registry xmlrpc_registry;
|
||||
typedef xmlrpc_method1 xmlrpc_method; /* backward compatibility */
|
||||
|
||||
typedef xmlrpc_value *
|
||||
(*xmlrpc_default_method)(xmlrpc_env * const envP,
|
||||
const char * const callInfoP,
|
||||
const char * const methodName,
|
||||
xmlrpc_value * const paramArrayP,
|
||||
void * const serverInfo);
|
||||
|
||||
extern unsigned int const xmlrpc_server_version_major;
|
||||
extern unsigned int const xmlrpc_server_version_minor;
|
||||
extern unsigned int const xmlrpc_server_version_point;
|
||||
|
||||
/* Create a new method registry. */
|
||||
xmlrpc_registry *
|
||||
xmlrpc_registry_new(xmlrpc_env * env);
|
||||
xmlrpc_registry_new(xmlrpc_env * const envP);
|
||||
|
||||
/* Delete a method registry. */
|
||||
void
|
||||
xmlrpc_registry_free(xmlrpc_registry * registry);
|
||||
xmlrpc_registry_free(xmlrpc_registry * const registryP);
|
||||
|
||||
/* Disable introspection. The xmlrpc_registry has introspection
|
||||
** capability built-in. If you want to make nosy people work harder,
|
||||
** you can turn this off. */
|
||||
void
|
||||
xmlrpc_registry_disable_introspection(xmlrpc_registry * registry);
|
||||
xmlrpc_registry_disable_introspection(xmlrpc_registry * const registryP);
|
||||
|
||||
/* Register a method. The host parameter must be NULL (for now). You
|
||||
** are responsible for owning and managing user_data. The registry
|
||||
** will make internal copies of any other pointers it needs to
|
||||
** keep around. */
|
||||
void
|
||||
xmlrpc_registry_add_method(xmlrpc_env * env,
|
||||
xmlrpc_registry * registry,
|
||||
const char * host,
|
||||
const char * method_name,
|
||||
xmlrpc_method method,
|
||||
void * user_data);
|
||||
xmlrpc_registry_add_method(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
const char * const host,
|
||||
const char * const methodName,
|
||||
xmlrpc_method const method,
|
||||
void * const serverInfo);
|
||||
|
||||
/* As above, but allow the user to supply introspection information.
|
||||
**
|
||||
** Signatures use their own little description language. It consists
|
||||
** of one-letter type code (similar to the ones used in xmlrpc_parse_value)
|
||||
** for the result, a colon, and zero or more one-letter type codes for
|
||||
** the parameters. For example:
|
||||
** i:ibdsAS86
|
||||
** If a function has more than one possible prototype, separate them with
|
||||
** commas:
|
||||
** i:,i:s,i:ii
|
||||
** If the function signature can't be represented using this language,
|
||||
** pass a single question mark:
|
||||
** ?
|
||||
** Help strings are ASCII text, and may contain HTML markup. */
|
||||
void
|
||||
xmlrpc_registry_add_method_w_doc(xmlrpc_env * env,
|
||||
xmlrpc_registry * registry,
|
||||
const char * host,
|
||||
const char * method_name,
|
||||
xmlrpc_method method,
|
||||
void * user_data,
|
||||
const char * signature,
|
||||
const char * help);
|
||||
xmlrpc_registry_add_method_w_doc(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
const char * const host,
|
||||
const char * const methodName,
|
||||
xmlrpc_method const method,
|
||||
void * const serverInfo,
|
||||
const char * const signatureString,
|
||||
const char * const help);
|
||||
|
||||
void
|
||||
xmlrpc_registry_add_method2(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
const char * const methodName,
|
||||
xmlrpc_method2 method,
|
||||
const char * const signatureString,
|
||||
const char * const help,
|
||||
void * const serverInfo);
|
||||
|
||||
void
|
||||
xmlrpc_registry_set_default_method(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
xmlrpc_default_method const handler,
|
||||
void * const userData);
|
||||
|
||||
void
|
||||
xmlrpc_registry_set_preinvoke_method(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
xmlrpc_preinvoke_method const method,
|
||||
void * const userData);
|
||||
|
||||
|
||||
typedef void xmlrpc_server_shutdown_fn(xmlrpc_env * const envP,
|
||||
void * const context,
|
||||
const char * const comment,
|
||||
void * const callInfo);
|
||||
|
||||
void
|
||||
xmlrpc_registry_set_shutdown(xmlrpc_registry * const registryP,
|
||||
xmlrpc_server_shutdown_fn * const shutdownFn,
|
||||
void * const context);
|
||||
|
||||
void
|
||||
xmlrpc_registry_set_dialect(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
xmlrpc_dialect const dialect);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Lower interface -- services to be used by an HTTP request handler
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
xmlrpc_registry_process_call2(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
const char * const xmlData,
|
||||
size_t const xmlLen,
|
||||
void * const callInfo,
|
||||
xmlrpc_mem_block ** const outputPP);
|
||||
|
||||
/* Given a registry, a host name, and XML data; parse the <methodCall>,
|
||||
** find the appropriate method, call it, serialize the response, and
|
||||
** return it as an xmlrpc_mem_block. Most errors will be serialized
|
||||
** as <fault> responses. If a *really* bad error occurs, set a fault and
|
||||
** return NULL. (Actually, we currently give up with a fatal error,
|
||||
** but that should change eventually.)
|
||||
** The caller is responsible for destroying the memory block. */
|
||||
xmlrpc_mem_block *
|
||||
xmlrpc_registry_process_call(xmlrpc_env * const envP,
|
||||
xmlrpc_registry * const registryP,
|
||||
const char * const host,
|
||||
const char * const xml_data,
|
||||
size_t const xml_len);
|
||||
const char * const xmlData,
|
||||
size_t const xmlLen);
|
||||
|
||||
/* Define a default method for the specified registry. This will be invoked
|
||||
** if no other method matches. The user_data pointer is property of the
|
||||
** application, and will not be freed or manipulated by the registry. */
|
||||
void
|
||||
xmlrpc_registry_set_default_method(xmlrpc_env * env,
|
||||
xmlrpc_registry * registry,
|
||||
xmlrpc_default_method handler,
|
||||
void * user_data);
|
||||
|
||||
/* Define a preinvoke method for the specified registry. This function will
|
||||
** be called before any method (either the default or a registered one) is
|
||||
** invoked. Applications can use this to do things like access control or
|
||||
** sanity checks. The user_data pointer is property of the application,
|
||||
** and will not be freed or manipulated by the registry. */
|
||||
void
|
||||
xmlrpc_registry_set_preinvoke_method(xmlrpc_env * env,
|
||||
xmlrpc_registry * registry,
|
||||
xmlrpc_preinvoke_method method,
|
||||
void * user_data);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,33 +1,43 @@
|
||||
/*============================================================================
|
||||
server_abyss.h
|
||||
==============================================================================
|
||||
This declares the user interface to libxmlrpc_server_abyss, which
|
||||
provides facilities for running an XML-RPC server based on the Xmlrpc-c
|
||||
Abyss HTTP server.
|
||||
============================================================================*/
|
||||
|
||||
/* Copyright and license information is at the end of the file */
|
||||
|
||||
#ifndef XMLRPC_SERVER_ABYSS_H_INCLUDED
|
||||
#define XMLRPC_SERVER_ABYSS_H_INCLUDED
|
||||
|
||||
#include "xmlrpc-c/server.h"
|
||||
#ifdef WIN32
|
||||
#include <winsock.h> /* For XMLRPC_SOCKET (= SOCKET) */
|
||||
#endif
|
||||
|
||||
#include <xmlrpc-c/config.h> /* For XMLRPC_SOCKET */
|
||||
#include <xmlrpc-c/abyss.h>
|
||||
#include <xmlrpc-c/server.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct _TServer;
|
||||
|
||||
/*=========================================================================
|
||||
** XML-RPC Server (based on Abyss)
|
||||
**=========================================================================
|
||||
** A simple XML-RPC server based on the Abyss web server. If errors
|
||||
** occur during server setup, the server will exit. In general, if you
|
||||
** want to use this API, you'll need to be familiar with Abyss.
|
||||
**
|
||||
** There are two ways to use Abyss:
|
||||
** 1) You can use the handy wrapper functions.
|
||||
** 2) You can set up Abyss yourself, and install the appropriate
|
||||
** handlers manually.
|
||||
*/
|
||||
|
||||
#define XMLRPC_SERVER_ABYSS_NO_FLAGS (0)
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** Global Initialization/Termination.
|
||||
**
|
||||
** These are not thread-safe. You call them at the beginning and end
|
||||
** of your program, when it is only one thread.
|
||||
**=======================================================================*/
|
||||
|
||||
void
|
||||
xmlrpc_server_abyss_global_init(xmlrpc_env * const envP);
|
||||
|
||||
void
|
||||
xmlrpc_server_abyss_global_term(void);
|
||||
|
||||
/*=========================================================================
|
||||
** Basic Abyss Server Functions
|
||||
@@ -53,7 +63,11 @@ typedef struct {
|
||||
unsigned int keepalive_max_conn;
|
||||
unsigned int timeout;
|
||||
xmlrpc_bool dont_advertise;
|
||||
|
||||
xmlrpc_bool socket_bound;
|
||||
XMLRPC_SOCKET socket_handle;
|
||||
const char * uri_path;
|
||||
xmlrpc_bool chunk_response;
|
||||
xmlrpc_bool enable_shutdown;
|
||||
} xmlrpc_server_abyss_parms;
|
||||
|
||||
|
||||
@@ -62,23 +76,81 @@ typedef struct {
|
||||
|
||||
/* XMLRPC_APSIZE(xyz) is the minimum size a struct xmlrpc_server_abyss_parms
|
||||
must be to include the 'xyz' member. This is essential to forward and
|
||||
backward compatbility, as new members will be added to the end of the
|
||||
backward compatibility, as new members will be added to the end of the
|
||||
struct in future releases. This is how the callee knows whether or
|
||||
not the caller is new enough to have supplied a certain parameter.
|
||||
*/
|
||||
|
||||
/*=========================================================================
|
||||
** Simple server with Abyss under the covers
|
||||
**=======================================================================*/
|
||||
|
||||
void
|
||||
xmlrpc_server_abyss(xmlrpc_env * const envP,
|
||||
const xmlrpc_server_abyss_parms * const parms,
|
||||
unsigned int const parm_size);
|
||||
|
||||
/*=========================================================================
|
||||
** Object-oriented XML-RPC server with Abyss under the covers
|
||||
**=======================================================================*/
|
||||
|
||||
typedef struct xmlrpc_server_abyss xmlrpc_server_abyss_t;
|
||||
|
||||
void
|
||||
xmlrpc_server_abyss_set_handlers(struct _TServer * const srvP,
|
||||
xmlrpc_server_abyss_create(xmlrpc_env * const envP,
|
||||
const xmlrpc_server_abyss_parms * const parmsP,
|
||||
unsigned int const parmSize,
|
||||
xmlrpc_server_abyss_t ** const serverPP);
|
||||
|
||||
void
|
||||
xmlrpc_server_abyss_destroy(xmlrpc_server_abyss_t * const serverP);
|
||||
|
||||
void
|
||||
xmlrpc_server_abyss_run_server(xmlrpc_env * const envP,
|
||||
xmlrpc_server_abyss_t * const serverP);
|
||||
|
||||
void
|
||||
xmlrpc_server_abyss_terminate(xmlrpc_env * const envP,
|
||||
xmlrpc_server_abyss_t * const serverP);
|
||||
|
||||
void
|
||||
xmlrpc_server_abyss_reset_terminate(xmlrpc_env * const envP,
|
||||
xmlrpc_server_abyss_t * const serverP);
|
||||
|
||||
void
|
||||
xmlrpc_server_abyss_use_sigchld(xmlrpc_server_abyss_t * const serverP);
|
||||
|
||||
|
||||
typedef struct xmlrpc_server_abyss_sig xmlrpc_server_abyss_sig;
|
||||
|
||||
void
|
||||
xmlrpc_server_abyss_setup_sig(
|
||||
xmlrpc_env * const envP,
|
||||
xmlrpc_server_abyss_t * const serverP,
|
||||
xmlrpc_server_abyss_sig ** const oldHandlersPP);
|
||||
|
||||
void
|
||||
xmlrpc_server_abyss_restore_sig(
|
||||
const xmlrpc_server_abyss_sig * const oldHandlersP);
|
||||
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** Functions to make an XML-RPC server out of your own Abyss server
|
||||
**=======================================================================*/
|
||||
|
||||
void
|
||||
xmlrpc_server_abyss_set_handlers2(TServer * const srvP,
|
||||
const char * const filename,
|
||||
xmlrpc_registry * const registryP);
|
||||
|
||||
void
|
||||
xmlrpc_server_abyss_set_handlers(TServer * const serverP,
|
||||
xmlrpc_registry * const registryP);
|
||||
|
||||
void
|
||||
xmlrpc_server_abyss_set_handler(xmlrpc_env * const envP,
|
||||
struct _TServer * const srvP,
|
||||
TServer * const serverP,
|
||||
const char * const filename,
|
||||
xmlrpc_registry * const registryP);
|
||||
|
||||
@@ -109,8 +181,8 @@ xmlrpc_server_abyss_run(void);
|
||||
** function.
|
||||
**/
|
||||
void
|
||||
xmlrpc_server_abyss_run_first(void (runfirst(void *)),
|
||||
void * const runfirstArg);
|
||||
xmlrpc_server_abyss_run_first(runfirstFn const runfirst,
|
||||
void * const runfirstArg);
|
||||
|
||||
/*=========================================================================
|
||||
** Method Registry
|
||||
@@ -145,18 +217,18 @@ xmlrpc_server_abyss_registry (void);
|
||||
/* A quick & easy shorthand for adding a method. Depending on
|
||||
** how you've configured your copy of Abyss, it's probably not safe to
|
||||
** call this method after calling xmlrpc_server_abyss_run. */
|
||||
void xmlrpc_server_abyss_add_method (char *method_name,
|
||||
xmlrpc_method method,
|
||||
void *user_data);
|
||||
void xmlrpc_server_abyss_add_method (char * const method_name,
|
||||
xmlrpc_method const method,
|
||||
void * const user_data);
|
||||
|
||||
/* As above, but provide documentation (see xmlrpc_registry_add_method_w_doc
|
||||
** for more information). You should really use this one. */
|
||||
extern void
|
||||
xmlrpc_server_abyss_add_method_w_doc (char *method_name,
|
||||
xmlrpc_method method,
|
||||
void *user_data,
|
||||
char *signature,
|
||||
char *help);
|
||||
xmlrpc_server_abyss_add_method_w_doc (char * const method_name,
|
||||
xmlrpc_method const method,
|
||||
void * const user_data,
|
||||
char * const signature,
|
||||
char * const help);
|
||||
|
||||
/*=========================================================================
|
||||
** Content Handlers
|
||||
|
@@ -1,5 +1,11 @@
|
||||
#ifndef SERVER_ABYSS_HPP_INCLUDED
|
||||
#define SERVER_ABYSS_HPP_INCLUDED
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock.h> // For XMLRPC_SOCKET (= SOCKET)
|
||||
#endif
|
||||
|
||||
#include "xmlrpc-c/config.h" // For XMLRPC_SOCKET
|
||||
#include "xmlrpc-c/base.hpp"
|
||||
#include "abyss.h"
|
||||
|
||||
@@ -8,6 +14,52 @@ namespace xmlrpc_c {
|
||||
class serverAbyss {
|
||||
|
||||
public:
|
||||
class constrOpt {
|
||||
public:
|
||||
constrOpt();
|
||||
|
||||
constrOpt & registryPtr (xmlrpc_c::registryPtr const& arg);
|
||||
constrOpt & registryP (const xmlrpc_c::registry * const& arg);
|
||||
constrOpt & socketFd (XMLRPC_SOCKET const& arg);
|
||||
constrOpt & portNumber (unsigned int const& arg);
|
||||
constrOpt & logFileName (std::string const& arg);
|
||||
constrOpt & keepaliveTimeout (unsigned int const& arg);
|
||||
constrOpt & keepaliveMaxConn (unsigned int const& arg);
|
||||
constrOpt & timeout (unsigned int const& arg);
|
||||
constrOpt & dontAdvertise (bool const& arg);
|
||||
constrOpt & uriPath (std::string const& arg);
|
||||
constrOpt & chunkResponse (bool const& arg);
|
||||
|
||||
struct value {
|
||||
xmlrpc_c::registryPtr registryPtr;
|
||||
const xmlrpc_c::registry * registryP;
|
||||
XMLRPC_SOCKET socketFd;
|
||||
unsigned int portNumber;
|
||||
std::string logFileName;
|
||||
unsigned int keepaliveTimeout;
|
||||
unsigned int keepaliveMaxConn;
|
||||
unsigned int timeout;
|
||||
bool dontAdvertise;
|
||||
std::string uriPath;
|
||||
bool chunkResponse;
|
||||
} value;
|
||||
struct {
|
||||
bool registryPtr;
|
||||
bool registryP;
|
||||
bool socketFd;
|
||||
bool portNumber;
|
||||
bool logFileName;
|
||||
bool keepaliveTimeout;
|
||||
bool keepaliveMaxConn;
|
||||
bool timeout;
|
||||
bool dontAdvertise;
|
||||
bool uriPath;
|
||||
bool chunkResponse;
|
||||
} present;
|
||||
};
|
||||
|
||||
serverAbyss(constrOpt const& opt);
|
||||
|
||||
serverAbyss(
|
||||
xmlrpc_c::registry const& registry,
|
||||
unsigned int const portNumber = 8080,
|
||||
@@ -15,32 +67,67 @@ public:
|
||||
unsigned int const keepaliveTimeout = 0,
|
||||
unsigned int const keepaliveMaxConn = 0,
|
||||
unsigned int const timeout = 0,
|
||||
bool const dontAdvertise = false
|
||||
bool const dontAdvertise = false,
|
||||
bool const socketBound = false,
|
||||
XMLRPC_SOCKET const socketFd = 0
|
||||
);
|
||||
~serverAbyss();
|
||||
|
||||
void run();
|
||||
void
|
||||
run();
|
||||
|
||||
void
|
||||
runOnce();
|
||||
|
||||
void
|
||||
runConn(int const socketFd);
|
||||
|
||||
void
|
||||
terminate();
|
||||
|
||||
class shutdown : public xmlrpc_c::registry::shutdown {
|
||||
public:
|
||||
shutdown(xmlrpc_c::serverAbyss * const severAbyssP);
|
||||
virtual ~shutdown();
|
||||
void doit(std::string const& comment, void * const callInfo) const;
|
||||
private:
|
||||
xmlrpc_c::serverAbyss * const serverAbyssP;
|
||||
};
|
||||
|
||||
private:
|
||||
// We rely on the creator to keep the registry object around as
|
||||
// long as the server object is, so that this pointer is valid.
|
||||
// We need to use some kind of automatic handle instead.
|
||||
|
||||
const xmlrpc_c::registry * registryP;
|
||||
|
||||
std::string configFileName;
|
||||
std::string logFileName;
|
||||
unsigned int portNumber;
|
||||
unsigned int keepaliveTimeout;
|
||||
unsigned int keepaliveMaxConn;
|
||||
unsigned int timeout;
|
||||
bool dontAdvertise;
|
||||
// The user has the choice of supplying the registry by plain pointer
|
||||
// (and managing the object's existence himself) or by autoObjectPtr
|
||||
// (with automatic management). 'registryPtr' exists here only to
|
||||
// maintain a reference count in the case that the user supplied an
|
||||
// autoObjectPtr. The object doesn't reference the C++ registry
|
||||
// object except during construction, because the C registry is the
|
||||
// real registry.
|
||||
xmlrpc_c::registryPtr registryPtr;
|
||||
|
||||
TServer cServer;
|
||||
|
||||
void
|
||||
setAdditionalServerParms(constrOpt const& opt);
|
||||
|
||||
void
|
||||
initialize(constrOpt const& opt);
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
server_abyss_set_handlers(TServer * const srvP,
|
||||
xmlrpc_c::registry const& registry);
|
||||
xmlrpc_c::registry const& registry,
|
||||
std::string const& uriPath = "/RPC2");
|
||||
|
||||
void
|
||||
server_abyss_set_handlers(TServer * const srvP,
|
||||
const xmlrpc_c::registry * const registryP,
|
||||
std::string const& uriPath = "/RPC2");
|
||||
|
||||
void
|
||||
server_abyss_set_handlers(TServer * const srvP,
|
||||
xmlrpc_c::registryPtr const registryPtr,
|
||||
std::string const& uriPath = "/RPC2");
|
||||
|
||||
} // namespace
|
||||
|
||||
|
75
libs/xmlrpc-c/include/xmlrpc-c/server_pstream.hpp
Normal file
75
libs/xmlrpc-c/include/xmlrpc-c/server_pstream.hpp
Normal file
@@ -0,0 +1,75 @@
|
||||
#ifndef SERVER_PSTREAM_HPP_INCLUDED
|
||||
#define SERVER_PSTREAM_HPP_INCLUDED
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock.h> /* For XMLRPC_SOCKET (= SOCKET) */
|
||||
#endif
|
||||
|
||||
#include <xmlrpc-c/config.h> /* For XMLRPC_SOCKET */
|
||||
#include <xmlrpc-c/registry.hpp>
|
||||
#include <xmlrpc-c/packetsocket.hpp>
|
||||
|
||||
namespace xmlrpc_c {
|
||||
|
||||
class serverPstreamConn {
|
||||
|
||||
public:
|
||||
|
||||
class constrOpt {
|
||||
public:
|
||||
constrOpt();
|
||||
|
||||
constrOpt & registryPtr (xmlrpc_c::registryPtr const& arg);
|
||||
constrOpt & registryP (const xmlrpc_c::registry * const& arg);
|
||||
constrOpt & socketFd (XMLRPC_SOCKET const& arg);
|
||||
|
||||
struct value {
|
||||
xmlrpc_c::registryPtr registryPtr;
|
||||
const xmlrpc_c::registry * registryP;
|
||||
XMLRPC_SOCKET socketFd;
|
||||
} value;
|
||||
struct {
|
||||
bool registryPtr;
|
||||
bool registryP;
|
||||
bool socketFd;
|
||||
} present;
|
||||
};
|
||||
|
||||
serverPstreamConn(constrOpt const& opt);
|
||||
|
||||
~serverPstreamConn();
|
||||
|
||||
void
|
||||
runOnce(volatile const int * const interruptP,
|
||||
bool * const eofP);
|
||||
|
||||
void
|
||||
runOnce(bool * const eofP);
|
||||
|
||||
private:
|
||||
|
||||
// 'registryP' is what we actually use; 'registryHolder' just holds a
|
||||
// reference to 'registryP' so the registry doesn't disappear while
|
||||
// this server exists. But note that if the creator doesn't supply
|
||||
// a registryPtr, 'registryHolder' is just a placeholder variable and
|
||||
// the creator is responsible for making sure the registry doesn't
|
||||
// go anywhere while the server exists.
|
||||
|
||||
registryPtr registryHolder;
|
||||
const registry * registryP;
|
||||
|
||||
packetSocket * packetSocketP;
|
||||
// The packet socket over which we received RPCs.
|
||||
// This is permanently connected to our fixed client.
|
||||
|
||||
void
|
||||
establishRegistry(constrOpt const& opt);
|
||||
|
||||
void
|
||||
establishPacketSocket(constrOpt const& opt);
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
7
libs/xmlrpc-c/include/xmlrpc-c/sleep_int.h
Normal file
7
libs/xmlrpc-c/include/xmlrpc-c/sleep_int.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef SLEEP_INT_H_INCLUDED
|
||||
#define SLEEP_INT_H_INCLUDED
|
||||
|
||||
void
|
||||
xmlrpc_millisecond_sleep(unsigned int const milliseconds);
|
||||
|
||||
#endif
|
84
libs/xmlrpc-c/include/xmlrpc-c/string_int.h
Normal file
84
libs/xmlrpc-c/include/xmlrpc-c/string_int.h
Normal file
@@ -0,0 +1,84 @@
|
||||
#ifndef XMLRPC_C_STRING_INT_H_INCLUDED
|
||||
#define XMLRPC_C_STRING_INT_H_INCLUDED
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
#include "c_util.h"
|
||||
#include "bool.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char * const xmlrpc_strsol;
|
||||
|
||||
void
|
||||
xmlrpc_vasprintf(const char ** const retvalP,
|
||||
const char * const fmt,
|
||||
va_list varargs);
|
||||
|
||||
void GNU_PRINTF_ATTR(2,3)
|
||||
xmlrpc_asprintf(const char ** const retvalP, const char * const fmt, ...);
|
||||
|
||||
const char *
|
||||
xmlrpc_strdupnull(const char * const string);
|
||||
|
||||
void
|
||||
xmlrpc_strfree(const char * const string);
|
||||
|
||||
void
|
||||
xmlrpc_strfreenull(const char * const string);
|
||||
|
||||
static __inline__ bool
|
||||
xmlrpc_streq(const char * const a,
|
||||
const char * const b) {
|
||||
return (strcmp(a, b) == 0);
|
||||
}
|
||||
|
||||
static __inline__ bool
|
||||
xmlrpc_memeq(const void * const a,
|
||||
const void * const b,
|
||||
size_t const size) {
|
||||
|
||||
return (memcmp(a, b, size) == 0);
|
||||
}
|
||||
|
||||
static __inline__ bool
|
||||
xmlrpc_strcaseeq(const char * const a,
|
||||
const char * const b) {
|
||||
#if HAVE_STRCASECMP
|
||||
return (strcasecmp(a, b) == 0);
|
||||
#elif HAVE__STRICMP
|
||||
return (_stricmp(a, b) == 0);
|
||||
#elif HAVE_STRICMP
|
||||
return (stricmp(a, b) == 0);
|
||||
#else
|
||||
#error "This platform has no known case-independent string compare fn"
|
||||
#endif
|
||||
}
|
||||
|
||||
static __inline__ bool
|
||||
xmlrpc_strneq(const char * const a,
|
||||
const char * const b,
|
||||
size_t const len) {
|
||||
return (strncmp(a, b, len) == 0);
|
||||
}
|
||||
|
||||
const char *
|
||||
xmlrpc_makePrintable(const char * const input);
|
||||
|
||||
const char *
|
||||
xmlrpc_makePrintable_lp(const char * const input,
|
||||
size_t const inputLength);
|
||||
|
||||
const char *
|
||||
xmlrpc_makePrintableChar(char const input);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
35
libs/xmlrpc-c/include/xmlrpc-c/time_int.h
Normal file
35
libs/xmlrpc-c/include/xmlrpc-c/time_int.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef TIME_H_INCLUDED
|
||||
#define TIME_H_INCLUDED
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "xmlrpc_config.h"
|
||||
#include "xmlrpc-c/util.h"
|
||||
#include "int.h"
|
||||
|
||||
#if HAVE_TIMESPEC
|
||||
typedef struct timespec xmlrpc_timespec;
|
||||
#else
|
||||
typedef struct {
|
||||
uint32_t tv_sec;
|
||||
uint32_t tv_nsec;
|
||||
} xmlrpc_timespec;
|
||||
#endif
|
||||
|
||||
void
|
||||
xmlrpc_gettimeofday(xmlrpc_timespec * const todP);
|
||||
|
||||
void
|
||||
xmlrpc_timegm(const struct tm * const brokenTime,
|
||||
time_t * const timeValueP,
|
||||
const char ** const errorP);
|
||||
|
||||
void
|
||||
xmlrpc_localtime(time_t const datetime,
|
||||
struct tm * const tmP);
|
||||
|
||||
void
|
||||
xmlrpc_gmtime(time_t const datetime,
|
||||
struct tm * const resultP);
|
||||
|
||||
#endif
|
@@ -8,9 +8,10 @@ struct timeout {
|
||||
timeout() : finite(false) {}
|
||||
|
||||
timeout(unsigned int const duration) : duration(duration) {}
|
||||
// 'duration' is the timeout time in milliseconds
|
||||
|
||||
bool finite;
|
||||
unsigned int duration;
|
||||
unsigned int duration; // in milliseconds
|
||||
};
|
||||
|
||||
|
||||
|
@@ -6,7 +6,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "xmlrpc-c/base.h"
|
||||
#include <xmlrpc-c/util.h>
|
||||
#include <xmlrpc-c/client.h>
|
||||
|
||||
struct xmlrpc_call_info;
|
||||
|
||||
@@ -16,12 +17,16 @@ struct xmlrpc_client_transport;
|
||||
** Transport function type declarations.
|
||||
**=========================================================================
|
||||
*/
|
||||
typedef void (*xmlrpc_transport_setup)(xmlrpc_env * const envP);
|
||||
|
||||
typedef void (*xmlrpc_transport_teardown)(void);
|
||||
|
||||
typedef void (*xmlrpc_transport_create)(
|
||||
xmlrpc_env * const envP,
|
||||
int const flags,
|
||||
const char * const appname,
|
||||
const char * const appversion,
|
||||
const struct xmlrpc_xportparms * const transportparmsP,
|
||||
const void * const transportparmsP,
|
||||
size_t const transportparm_size,
|
||||
struct xmlrpc_client_transport ** const handlePP);
|
||||
|
||||
@@ -58,14 +63,20 @@ typedef void (*xmlrpc_transport_finish_asynch)(
|
||||
xmlrpc_timeoutType const timeoutType,
|
||||
xmlrpc_timeout const timeout);
|
||||
|
||||
typedef void (*xmlrpc_transport_set_interrupt)(
|
||||
struct xmlrpc_client_transport * const clientTransportP,
|
||||
int * const interruptP);
|
||||
|
||||
struct xmlrpc_client_transport_ops {
|
||||
|
||||
xmlrpc_transport_setup setup_global_const;
|
||||
xmlrpc_transport_teardown teardown_global_const;
|
||||
xmlrpc_transport_create create;
|
||||
xmlrpc_transport_destroy destroy;
|
||||
xmlrpc_transport_send_request send_request;
|
||||
xmlrpc_transport_call call;
|
||||
xmlrpc_transport_finish_asynch finish_asynch;
|
||||
xmlrpc_transport_set_interrupt set_interrupt;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
328
libs/xmlrpc-c/include/xmlrpc-c/util.h
Normal file
328
libs/xmlrpc-c/include/xmlrpc-c/util.h
Normal file
@@ -0,0 +1,328 @@
|
||||
/*=============================================================================
|
||||
xmlrpc-c/util.h
|
||||
===============================================================================
|
||||
|
||||
This is the interface to the libxmlrpc_util library, which contains
|
||||
utility routines that have nothing to do with XML-RPC. The library
|
||||
exists because other Xmlrpc-c libraries use the utilities.
|
||||
|
||||
By Bryan Henderson, San Jose, CA 05.09.21.
|
||||
|
||||
Contributed to the public domain by its author.
|
||||
=============================================================================*/
|
||||
|
||||
#ifndef XMLRPC_C_UTIL_H_INCLUDED
|
||||
#define XMLRPC_C_UTIL_H_INCLUDED
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <xmlrpc-c/config.h> /* Defines XMLRPC_HAVE_WCHAR */
|
||||
#include <xmlrpc-c/c_util.h> /* for GNU_PRINTF_ATTR */
|
||||
|
||||
#if XMLRPC_HAVE_WCHAR
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** C struct size computations
|
||||
**=======================================================================*/
|
||||
|
||||
/* Use XMLRPC_STRUCT_MEMBER_SIZE() to determine how big a structure is
|
||||
up to and including a specified member. E.g. if you have
|
||||
struct mystruct {int red; int green; int blue};, then
|
||||
XMLRPC_STRUCT_MEMBER_SIZE(mystruct, green) is (8).
|
||||
*/
|
||||
|
||||
#define _XMLRPC_STRUCT_MEMBER_OFFSET(TYPE, MBRNAME) \
|
||||
((unsigned long)(char*)&((TYPE *)0)->MBRNAME)
|
||||
#define _XMLRPC_STRUCT_MEMBER_SIZE(TYPE, MBRNAME) \
|
||||
sizeof(((TYPE *)0)->MBRNAME)
|
||||
#define XMLRPC_STRUCTSIZE(TYPE, MBRNAME) \
|
||||
(_XMLRPC_STRUCT_MEMBER_OFFSET(TYPE, MBRNAME) + \
|
||||
_XMLRPC_STRUCT_MEMBER_SIZE(TYPE, MBRNAME))
|
||||
|
||||
/*=========================================================================
|
||||
** Assertions and Debugging
|
||||
**=========================================================================
|
||||
** Note that an assertion is _not_ a directive to check a condition and
|
||||
** crash if it isn't true. It is an assertion that the condition _is_
|
||||
** true. This assertion helps people to read the code. The program
|
||||
** may also check the assertion as it runs, and if it conflicts with reality,
|
||||
** recognize that the program is incorrect and abort it. In practice,
|
||||
** it does this checking when the program was compiled without the NDEBUG
|
||||
** macro defined.
|
||||
*/
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
#define XMLRPC_ASSERT(cond) \
|
||||
do \
|
||||
if (!(cond)) \
|
||||
xmlrpc_assertion_failed(__FILE__, __LINE__); \
|
||||
while (0)
|
||||
|
||||
#else
|
||||
#define XMLRPC_ASSERT(cond) while (0) {}
|
||||
#endif
|
||||
|
||||
void
|
||||
xmlrpc_assertion_failed(const char * const fileName,
|
||||
int const lineNumber);
|
||||
|
||||
/* Validate a pointer. */
|
||||
#define XMLRPC_ASSERT_PTR_OK(ptr) \
|
||||
XMLRPC_ASSERT((ptr) != NULL)
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** xmlrpc_env
|
||||
**=========================================================================
|
||||
** XML-RPC represents runtime errors as <fault> elements. These contain
|
||||
** <faultCode> and <faultString> elements.
|
||||
**
|
||||
** Since we need as much thread-safety as possible, we borrow an idea from
|
||||
** CORBA--we store exception information in an "environment" object.
|
||||
** You'll pass this to many different functions, and it will get filled
|
||||
** out appropriately.
|
||||
**
|
||||
** For example:
|
||||
**
|
||||
** xmlrpc_env env;
|
||||
**
|
||||
** xmlrpc_env_init(&env);
|
||||
**
|
||||
** xmlrpc_do_something(&env);
|
||||
** if (env.fault_occurred)
|
||||
** report_error_appropriately();
|
||||
**
|
||||
** xmlrpc_env_clean(&env);
|
||||
*/
|
||||
|
||||
#define XMLRPC_INTERNAL_ERROR (-500)
|
||||
#define XMLRPC_TYPE_ERROR (-501)
|
||||
#define XMLRPC_INDEX_ERROR (-502)
|
||||
#define XMLRPC_PARSE_ERROR (-503)
|
||||
#define XMLRPC_NETWORK_ERROR (-504)
|
||||
#define XMLRPC_TIMEOUT_ERROR (-505)
|
||||
#define XMLRPC_NO_SUCH_METHOD_ERROR (-506)
|
||||
#define XMLRPC_REQUEST_REFUSED_ERROR (-507)
|
||||
#define XMLRPC_INTROSPECTION_DISABLED_ERROR (-508)
|
||||
#define XMLRPC_LIMIT_EXCEEDED_ERROR (-509)
|
||||
#define XMLRPC_INVALID_UTF8_ERROR (-510)
|
||||
|
||||
typedef struct _xmlrpc_env {
|
||||
int fault_occurred;
|
||||
int fault_code;
|
||||
char * fault_string;
|
||||
} xmlrpc_env;
|
||||
|
||||
/* Initialize and destroy the contents of the provided xmlrpc_env object.
|
||||
** These functions will never fail. */
|
||||
void xmlrpc_env_init (xmlrpc_env* env);
|
||||
void xmlrpc_env_clean (xmlrpc_env* const env);
|
||||
|
||||
/* Fill out an xmlrpc_fault with the specified values, and set the
|
||||
** fault_occurred flag. This function will make a private copy of 'string',
|
||||
** so you retain responsibility for your copy. */
|
||||
void
|
||||
xmlrpc_env_set_fault(xmlrpc_env * const env,
|
||||
int const faultCode,
|
||||
const char * const faultDescription);
|
||||
|
||||
/* The same as the above, but using varargs */
|
||||
void
|
||||
xmlrpc_set_fault_formatted_v(xmlrpc_env * const envP,
|
||||
int const code,
|
||||
const char * const format,
|
||||
va_list const args);
|
||||
|
||||
/* The same as the above, but using a printf-style format string. */
|
||||
void
|
||||
xmlrpc_env_set_fault_formatted(xmlrpc_env * const envP,
|
||||
int const code,
|
||||
const char * const format,
|
||||
...) GNU_PRINTF_ATTR(3,4);
|
||||
|
||||
/* This one infers XMLRPC_INTERNAL_ERROR and has a shorter name.
|
||||
So a call takes up less source code space.
|
||||
*/
|
||||
void
|
||||
xmlrpc_faultf(xmlrpc_env * const envP,
|
||||
const char * const format,
|
||||
...) GNU_PRINTF_ATTR(2,3);
|
||||
|
||||
/* A simple debugging assertion. */
|
||||
#define XMLRPC_ASSERT_ENV_OK(envP) \
|
||||
XMLRPC_ASSERT((envP) != NULL && \
|
||||
(envP->fault_string == NULL) && \
|
||||
!(envP)->fault_occurred)
|
||||
|
||||
/* This version must *not* interpret 'str' as a format string, to avoid
|
||||
** several evil attacks. */
|
||||
#define XMLRPC_FAIL(env,code,str) \
|
||||
do { xmlrpc_env_set_fault((env),(code),(str)); goto cleanup; } while (0)
|
||||
|
||||
#define XMLRPC_FAIL1(env,code,str,arg1) \
|
||||
do { \
|
||||
xmlrpc_env_set_fault_formatted((env),(code),(str),(arg1)); \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
#define XMLRPC_FAIL2(env,code,str,arg1,arg2) \
|
||||
do { \
|
||||
xmlrpc_env_set_fault_formatted((env),(code),(str),(arg1),(arg2)); \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
#define XMLRPC_FAIL3(env,code,str,arg1,arg2,arg3) \
|
||||
do { \
|
||||
xmlrpc_env_set_fault_formatted((env),(code), \
|
||||
(str),(arg1),(arg2),(arg3)); \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
#if !defined(__cplusplus)
|
||||
#if defined(__GNUC__)
|
||||
#define XMLRPC_FAILF( env, code, fmt, ... ) \
|
||||
do { \
|
||||
xmlrpc_env_set_fault_formatted((env), (code), (fmt), \
|
||||
##__VA_ARGS__ ); \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define XMLRPC_FAIL_IF_NULL(ptr,env,code,str) \
|
||||
do { \
|
||||
if ((ptr) == NULL) \
|
||||
XMLRPC_FAIL((env),(code),(str)); \
|
||||
} while (0)
|
||||
|
||||
#define XMLRPC_FAIL_IF_FAULT(env) \
|
||||
do { if ((env)->fault_occurred) goto cleanup; } while (0)
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** xmlrpc_mem_block
|
||||
**=========================================================================
|
||||
** A resizable chunk of memory. This is mostly used internally, but it is
|
||||
** also used by the public API in a few places.
|
||||
** The struct fields are private!
|
||||
*/
|
||||
|
||||
typedef struct _xmlrpc_mem_block {
|
||||
size_t _size;
|
||||
size_t _allocated;
|
||||
void* _block;
|
||||
} xmlrpc_mem_block;
|
||||
|
||||
/* Allocate a new xmlrpc_mem_block. */
|
||||
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* const block);
|
||||
|
||||
/* Initialize the contents of the provided xmlrpc_mem_block. */
|
||||
void xmlrpc_mem_block_init
|
||||
(xmlrpc_env* const env, xmlrpc_mem_block* const block, size_t const size);
|
||||
|
||||
/* Deallocate the contents of the provided xmlrpc_mem_block, but not the
|
||||
** block itself. */
|
||||
void xmlrpc_mem_block_clean (xmlrpc_mem_block* const block);
|
||||
|
||||
/* Get the size and contents of the xmlrpc_mem_block. */
|
||||
size_t
|
||||
xmlrpc_mem_block_size(const xmlrpc_mem_block * const block);
|
||||
|
||||
void *
|
||||
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* 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* const env, xmlrpc_mem_block* const block, const void * const data, size_t const len);
|
||||
|
||||
#define XMLRPC_MEMBLOCK_NEW(type,env,size) \
|
||||
xmlrpc_mem_block_new((env), sizeof(type) * (size))
|
||||
#define XMLRPC_MEMBLOCK_FREE(type,block) \
|
||||
xmlrpc_mem_block_free(block)
|
||||
#define XMLRPC_MEMBLOCK_INIT(type,env,block,size) \
|
||||
xmlrpc_mem_block_init((env), (block), sizeof(type) * (size))
|
||||
#define XMLRPC_MEMBLOCK_CLEAN(type,block) \
|
||||
xmlrpc_mem_block_clean(block)
|
||||
#define XMLRPC_MEMBLOCK_SIZE(type,block) \
|
||||
(xmlrpc_mem_block_size(block) / sizeof(type))
|
||||
#define XMLRPC_MEMBLOCK_CONTENTS(type,block) \
|
||||
((type*) xmlrpc_mem_block_contents(block))
|
||||
#define XMLRPC_MEMBLOCK_RESIZE(type,env,block,size) \
|
||||
xmlrpc_mem_block_resize(env, block, sizeof(type) * (size))
|
||||
#define XMLRPC_MEMBLOCK_APPEND(type,env,block,data,size) \
|
||||
xmlrpc_mem_block_append(env, block, data, sizeof(type) * (size))
|
||||
|
||||
/* Here are some backward compatibility definitions. These longer names
|
||||
used to be the only ones and typed memory blocks were considered
|
||||
special.
|
||||
*/
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_NEW(type,env,size) \
|
||||
XMLRPC_MEMBLOCK_NEW(type,env,size)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_FREE(type,block) \
|
||||
XMLRPC_MEMBLOCK_FREE(type,block)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_INIT(type,env,block,size) \
|
||||
XMLRPC_MEMBLOCK_INIT(type,env,block,size)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_CLEAN(type,block) \
|
||||
XMLRPC_MEMBLOCK_CLEAN(type,block)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_SIZE(type,block) \
|
||||
XMLRPC_MEMBLOCK_SIZE(type,block)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_CONTENTS(type,block) \
|
||||
XMLRPC_MEMBLOCK_CONTENTS(type,block)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_RESIZE(type,env,block,size) \
|
||||
XMLRPC_MEMBLOCK_RESIZE(type,env,block,size)
|
||||
#define XMLRPC_TYPED_MEM_BLOCK_APPEND(type,env,block,data,size) \
|
||||
XMLRPC_MEMBLOCK_APPEND(type,env,block,data,size)
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
** UTF-8 Encoding and Decoding
|
||||
**=======================================================================*/
|
||||
|
||||
void
|
||||
xmlrpc_validate_utf8(xmlrpc_env * const envP,
|
||||
const char * const utf8Data,
|
||||
size_t const utf8Len);
|
||||
|
||||
/* Decode a UTF-8 string. */
|
||||
xmlrpc_mem_block *
|
||||
xmlrpc_utf8_to_wcs(xmlrpc_env * const envP,
|
||||
const char * const utf8_data,
|
||||
size_t const utf8_len);
|
||||
|
||||
/* Encode a UTF-8 string. */
|
||||
|
||||
#if XMLRPC_HAVE_WCHAR
|
||||
xmlrpc_mem_block *
|
||||
xmlrpc_wcs_to_utf8(xmlrpc_env * const envP,
|
||||
const wchar_t * const wcsData,
|
||||
size_t const wcsLen);
|
||||
#endif
|
||||
|
||||
void
|
||||
xmlrpc_force_to_utf8(char * const buffer);
|
||||
|
||||
void
|
||||
xmlrpc_force_to_xml_chars(char * const buffer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
13
libs/xmlrpc-c/include/xmlrpc-c/util_int.h
Normal file
13
libs/xmlrpc-c/include/xmlrpc-c/util_int.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef XMLRPC_C_UTIL_INT_H_INCLUDED
|
||||
#define XMLRPC_C_UTIL_INT_H_INCLUDED
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
/* When we deallocate a pointer in a struct, we often replace it with
|
||||
** this and throw in a few assertions here and there. */
|
||||
#define XMLRPC_BAD_POINTER ((void*) 0xDEADBEEF)
|
||||
|
||||
#endif
|
@@ -12,6 +12,12 @@ generateCall(std::string const& methodName,
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
std::string * const callXmlP);
|
||||
|
||||
void
|
||||
generateCall(std::string const& methodName,
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
xmlrpc_dialect const dialect,
|
||||
std::string * const callXmlP);
|
||||
|
||||
void
|
||||
parseSuccessfulResponse(std::string const& responseXml,
|
||||
xmlrpc_c::value * const resultP);
|
||||
|
@@ -27,11 +27,12 @@
|
||||
typedef struct _xml_element xml_element;
|
||||
|
||||
/* Destroy an xml_element. */
|
||||
void xml_element_free (xml_element *elem);
|
||||
void xml_element_free (xml_element * const elem);
|
||||
|
||||
/* Return a pointer to the element's name. Do not free this pointer!
|
||||
** This pointer should point to standard ASCII or UTF-8 data. */
|
||||
char *xml_element_name (xml_element *elem);
|
||||
const char *
|
||||
xml_element_name(const xml_element * const elemP);
|
||||
|
||||
/* Return the xml_element's CDATA. Do not free this pointer!
|
||||
** This pointer should point to standard ASCII or UTF-8 data.
|
||||
@@ -46,8 +47,11 @@ size_t xml_element_cdata_size (xml_element *elem);
|
||||
char *xml_element_cdata (xml_element *elem);
|
||||
|
||||
/* Return the xml_element's child elements. Do not free this pointer! */
|
||||
size_t xml_element_children_size (xml_element *elem);
|
||||
xml_element **xml_element_children (xml_element *elem);
|
||||
size_t
|
||||
xml_element_children_size(const xml_element * const elemP);
|
||||
|
||||
xml_element **
|
||||
xml_element_children(const xml_element * const elemP);
|
||||
|
||||
|
||||
/*=========================================================================
|
||||
@@ -58,7 +62,11 @@ xml_element **xml_element_children (xml_element *elem);
|
||||
** You are responsible for calling xml_element_free on the returned pointer.
|
||||
*/
|
||||
|
||||
xml_element *xml_parse (xmlrpc_env *env, const char *xml_data, int xml_len);
|
||||
void
|
||||
xml_parse(xmlrpc_env * const envP,
|
||||
const char * const xmlData,
|
||||
size_t const xmlDataLen,
|
||||
xml_element ** const resultPP);
|
||||
|
||||
|
||||
/* Copyright (C) 2001 by First Peer, Inc. All rights reserved.
|
||||
|
Reference in New Issue
Block a user