diff options
author | Dan Libby <danda@php.net> | 2002-07-05 04:43:55 +0000 |
---|---|---|
committer | Dan Libby <danda@php.net> | 2002-07-05 04:43:55 +0000 |
commit | 2154e7b55b91e294cf5635aedc2388524a4d3ac9 (patch) | |
tree | 49a0a791a36c432793354cf9a959918674b31a90 /ext/xmlrpc/libxmlrpc | |
parent | eebae9f9efcda768d4059ae380173e4e752638d8 (diff) | |
download | php-git-2154e7b55b91e294cf5635aedc2388524a4d3ac9.tar.gz |
merged in updates from SF project. bring php repository up to date with xmlrpc-epi version 0.51
Diffstat (limited to 'ext/xmlrpc/libxmlrpc')
-rw-r--r-- | ext/xmlrpc/libxmlrpc/queue.c | 1 | ||||
-rw-r--r-- | ext/xmlrpc/libxmlrpc/simplestring.c | 7 | ||||
-rw-r--r-- | ext/xmlrpc/libxmlrpc/simplestring.h | 1 | ||||
-rw-r--r-- | ext/xmlrpc/libxmlrpc/system_methods.c | 4 | ||||
-rw-r--r-- | ext/xmlrpc/libxmlrpc/xml_element.c | 24 | ||||
-rw-r--r-- | ext/xmlrpc/libxmlrpc/xml_to_soap.c | 2 | ||||
-rw-r--r-- | ext/xmlrpc/libxmlrpc/xml_to_xmlrpc.c | 29 | ||||
-rw-r--r-- | ext/xmlrpc/libxmlrpc/xmlrpc.c | 176 | ||||
-rw-r--r-- | ext/xmlrpc/libxmlrpc/xmlrpc.h | 21 | ||||
-rw-r--r-- | ext/xmlrpc/libxmlrpc/xmlrpc_introspection.c | 4 | ||||
-rw-r--r-- | ext/xmlrpc/libxmlrpc/xmlrpc_private.h | 2 |
11 files changed, 248 insertions, 23 deletions
diff --git a/ext/xmlrpc/libxmlrpc/queue.c b/ext/xmlrpc/libxmlrpc/queue.c index ecef90caf6..24187383fd 100644 --- a/ext/xmlrpc/libxmlrpc/queue.c +++ b/ext/xmlrpc/libxmlrpc/queue.c @@ -367,6 +367,7 @@ int Q_PushTail(queue *q, void *d) return True_; } + return False_; } diff --git a/ext/xmlrpc/libxmlrpc/simplestring.c b/ext/xmlrpc/libxmlrpc/simplestring.c index 7ce68d3410..dd9850bb9c 100644 --- a/ext/xmlrpc/libxmlrpc/simplestring.c +++ b/ext/xmlrpc/libxmlrpc/simplestring.c @@ -44,6 +44,13 @@ static const char rcsid[] = "#(@) $Id$"; * CREATION DATE * 06/2000 * HISTORY + * $Log$ + * Revision 1.4 2002/02/13 20:58:50 danda + * patch to make source more windows friendly, contributed by Jeff Lawson + * + * Revision 1.3 2001/09/29 21:58:05 danda + * adding cvs log to history section + * * 10/15/2000 -- danda -- adding robodoc documentation * PORTABILITY * Coded on RedHat Linux 6.2. Builds on Solaris x86. Should build on just diff --git a/ext/xmlrpc/libxmlrpc/simplestring.h b/ext/xmlrpc/libxmlrpc/simplestring.h index a891ba6d78..c5d98cf1d8 100644 --- a/ext/xmlrpc/libxmlrpc/simplestring.h +++ b/ext/xmlrpc/libxmlrpc/simplestring.h @@ -62,6 +62,7 @@ typedef struct _simplestring { void simplestring_init(simplestring* string); void simplestring_clear(simplestring* string); void simplestring_free(simplestring* string); +void simplestring_add(simplestring* string, const char* add); void simplestring_addn(simplestring* string, const char* add, int add_len); #ifdef __cplusplus diff --git a/ext/xmlrpc/libxmlrpc/system_methods.c b/ext/xmlrpc/libxmlrpc/system_methods.c index 742b837143..c47236df14 100644 --- a/ext/xmlrpc/libxmlrpc/system_methods.c +++ b/ext/xmlrpc/libxmlrpc/system_methods.c @@ -35,6 +35,10 @@ * AUTHOR * Dan Libby, aka danda (dan@libby.com) * HISTORY + * $Log$ + * Revision 1.7 2001/09/29 21:58:05 danda + * adding cvs log to history section + * * 4/28/2001 -- danda -- adding system.multicall and separating out system methods. * TODO * NOTES diff --git a/ext/xmlrpc/libxmlrpc/xml_element.c b/ext/xmlrpc/libxmlrpc/xml_element.c index 2625e99913..edbc6de346 100644 --- a/ext/xmlrpc/libxmlrpc/xml_element.c +++ b/ext/xmlrpc/libxmlrpc/xml_element.c @@ -43,6 +43,22 @@ static const char rcsid[] = "#(@) $Id$"; * CREATION DATE * 06/2000 * HISTORY + * $Log$ + * Revision 1.9 2002/07/03 20:54:30 danda + * root element should not have a parent. patch from anon SF user + * + * Revision 1.8 2002/05/23 17:46:51 danda + * patch from mukund - fix non utf-8 encoding conversions + * + * Revision 1.7 2002/02/13 20:58:50 danda + * patch to make source more windows friendly, contributed by Jeff Lawson + * + * Revision 1.6 2002/01/08 01:06:55 danda + * enable <?xml version="1.0"?> format for parsers that are very picky. + * + * Revision 1.5 2001/09/29 21:58:05 danda + * adding cvs log to history section + * * 10/15/2000 -- danda -- adding robodoc documentation * TODO * Nicer external API. Get rid of macros. Make opaque types, etc. @@ -86,7 +102,7 @@ static const char rcsid[] = "#(@) $Id$"; #define XML_DECL_START "<?xml" #define XML_DECL_START_LEN sizeof(XML_DECL_START) - 1 -#define XML_DECL_VERSION "version='1.0'" +#define XML_DECL_VERSION "version=\"1.0\"" #define XML_DECL_VERSION_LEN sizeof(XML_DECL_VERSION) - 1 #define XML_DECL_ENCODING_ATTR "encoding" #define XML_DECL_ENCODING_ATTR_LEN sizeof(XML_DECL_ENCODING_ATTR) - 1 @@ -353,7 +369,6 @@ static void xml_element_serialize(xml_element *el, int (*fptr)(void *data, const xml_elem_writefunc(fptr, options->encoding, data, 0); xml_elem_writefunc(fptr, ATTR_DELIMITER, data, ATTR_DELIMITER_LEN); } - xml_elem_writefunc(fptr, WHITESPACE, data, WHITESPACE_LEN); xml_elem_writefunc(fptr, XML_DECL_END, data, XML_DECL_END_LEN); if(options->verbosity != xml_elem_no_white_space) { xml_elem_writefunc(fptr, NEWLINE, data, NEWLINE_LEN); @@ -591,8 +606,10 @@ static void charHandler(void *userData, /* Check if we need to decode utf-8 parser output to another encoding */ if(mydata->needs_enc_conversion && mydata->input_options->encoding) { - char* add_text = utf8_decode(s, len, &len, mydata->input_options->encoding); + int new_len = 0; + char* add_text = utf8_decode(s, len, &new_len, mydata->input_options->encoding); if(add_text) { + len = new_len; simplestring_addn(&mydata->current->text, add_text, len); free(add_text); return; @@ -700,6 +717,7 @@ xml_element* xml_elem_parse_buf(const char* in_buf, int len, XML_ELEM_INPUT_OPTI } else { xReturn = (xml_element*)Q_Head(&mydata.root->children); + xReturn->parent = NULL; } XML_ParserFree(parser); diff --git a/ext/xmlrpc/libxmlrpc/xml_to_soap.c b/ext/xmlrpc/libxmlrpc/xml_to_soap.c index fada389fb6..a09131aad6 100644 --- a/ext/xmlrpc/libxmlrpc/xml_to_soap.c +++ b/ext/xmlrpc/libxmlrpc/xml_to_soap.c @@ -5,7 +5,7 @@ */ -/************************************************************************ +/*-********************************************************************** * TODO: * * - [SOAP-ENC:position] read sparse arrays (and write?) * * - [SOAP-ENC:offset] read partially transmitted arrays (and write?) * diff --git a/ext/xmlrpc/libxmlrpc/xml_to_xmlrpc.c b/ext/xmlrpc/libxmlrpc/xml_to_xmlrpc.c index 8bace4dab6..c45d3ec3db 100644 --- a/ext/xmlrpc/libxmlrpc/xml_to_xmlrpc.c +++ b/ext/xmlrpc/libxmlrpc/xml_to_xmlrpc.c @@ -71,11 +71,30 @@ XMLRPC_VALUE xml_element_to_XMLRPC_REQUEST_worker(XMLRPC_REQUEST request, XMLRPC current_val = XMLRPC_CreateValueEmpty(); } - if (el->name) { - if (!strcmp(el->name, ELEM_DATA) /* should be ELEM_ARRAY, but there is an extra level. weird */ - || ((!strcmp(el->name, ELEM_PARAMS)) && - (XMLRPC_RequestGetRequestType(request) == xmlrpc_request_call)) /* this "PARAMS" concept is silly. dave?! */ - || !strcmp(el->name, ELEM_FAULT)) { /* so is this "FAULT" nonsense. */ + if (el->name) { + + /* first, deal with the crazy/stupid fault format */ + if (!strcmp(el->name, ELEM_FAULT)) { + xml_element* fault_value = (xml_element*)Q_Head(&el->children); + XMLRPC_SetIsVector(current_val, xmlrpc_vector_struct); + + if(fault_value) { + xml_element* fault_struct = (xml_element*)Q_Head(&fault_value->children); + if(fault_struct) { + xml_element* iter = (xml_element*)Q_Head(&fault_struct->children); + + while (iter) { + XMLRPC_VALUE xNextVal = XMLRPC_CreateValueEmpty(); + xml_element_to_XMLRPC_REQUEST_worker(request, current_val, xNextVal, iter); + XMLRPC_AddValueToVector(current_val, xNextVal); + iter = (xml_element*)Q_Next(&fault_struct->children); + } + } + } + } + else if (!strcmp(el->name, ELEM_DATA) /* should be ELEM_ARRAY, but there is an extra level. weird */ + || (!strcmp(el->name, ELEM_PARAMS) && + (XMLRPC_RequestGetRequestType(request) == xmlrpc_request_call)) ) { /* this "PARAMS" concept is silly. dave?! */ xml_element* iter = (xml_element*)Q_Head(&el->children); XMLRPC_SetIsVector(current_val, xmlrpc_vector_array); diff --git a/ext/xmlrpc/libxmlrpc/xmlrpc.c b/ext/xmlrpc/libxmlrpc/xmlrpc.c index cfac12d496..3eca7065a8 100644 --- a/ext/xmlrpc/libxmlrpc/xmlrpc.c +++ b/ext/xmlrpc/libxmlrpc/xmlrpc.c @@ -42,16 +42,31 @@ static const char rcsid[] = "#(@) $Id$"; * CREATION DATE * 9/1999 - 10/2000 * HISTORY + * $Log$ + * Revision 1.22 2002/03/09 23:15:44 danda + * add fault interrogation funcs + * + * Revision 1.21 2002/03/09 22:27:41 danda + * win32 build patches contributed by Jeff Lawson + * + * Revision 1.20 2002/02/13 20:58:50 danda + * patch to make source more windows friendly, contributed by Jeff Lawson + * + * Revision 1.19 2001/10/12 23:25:54 danda + * default to writing xmlrpc + * + * Revision 1.18 2001/09/29 21:58:05 danda + * adding cvs log to history section + * + * 10/15/2000 -- danda -- adding robodoc documentation + * 08/2000 -- danda -- PHP C extension that uses XMLRPC + * 08/2000 -- danda -- support for two vocabularies: danda-rpc and xml-rpc * 09/1999 -- danda -- Initial API, before I even knew of standard XMLRPC vocab. Response only. - * 06/2000 -- danda -- played with expat-ensor from www.ensor.org. Cool, but some flaws. * 07/2000 -- danda -- wrote new implementation to be compatible with xmlrpc standard and * incorporated some ideas from ensor, most notably the separation of * xml dom from xmlrpc api. - * 08/2000 -- danda -- support for two vocabularies: danda-rpc and xml-rpc - * 08/2000 -- danda -- PHP C extension that uses XMLRPC - * 10/15/2000 -- danda -- adding robodoc documentation + * 06/2000 -- danda -- played with expat-ensor from www.ensor.org. Cool, but some flaws. * TODO - * Server method introspection. (Enumerate available methods, describe I/O) * PORTABILITY * Coded on RedHat Linux 6.2. Builds on Solaris x86. Should build on just * about anything with minor mods. @@ -116,6 +131,7 @@ static const char rcsid[] = "#(@) $Id$"; #include "xml_element.h" #include "xmlrpc_private.h" #include "xmlrpc_introspection_private.h" +#include "system_methods_private.h" @@ -127,7 +143,6 @@ static int date_from_ISO8601 (const char *text, time_t * value) { struct tm tm; int n; int i; - time_t t; char buf[18]; if (strchr (text, '-')) { @@ -625,7 +640,8 @@ char* XMLRPC_REQUEST_ToXML(XMLRPC_REQUEST request, int* buf_len) { if (request->output.version == xmlrpc_version_simple) { root_elem = DANDARPC_REQUEST_to_xml_element (request); } - else if (request->output.version == xmlrpc_version_1_0) { + else if (request->output.version == xmlrpc_version_1_0 || + request->output.version == xmlrpc_version_none) { root_elem = XMLRPC_REQUEST_to_xml_element (request); } else if (request->output.version == xmlrpc_version_soap_1_1) { @@ -2382,7 +2398,7 @@ int XMLRPC_ServerRegisterMethod(XMLRPC_SERVER server, const char *name, XMLRPC_C /*******/ -inline server_method* find_method(XMLRPC_SERVER server, const char* name) { +server_method* find_method(XMLRPC_SERVER server, const char* name) { server_method* sm; q_iter qi = Q_Iter_Head_F(&server->methodlist); @@ -2649,7 +2665,7 @@ XMLRPC_CASE_COMPARISON XMLRPC_SetDefaultIdCaseComparison(XMLRPC_CASE_COMPARISON /*-****************** -* Utility API funcs * +* Fault API funcs * ********************/ /****f* UTILITY/XMLRPC_UtilityCreateFault @@ -2683,6 +2699,7 @@ XMLRPC_CASE_COMPARISON XMLRPC_SetDefaultIdCaseComparison(XMLRPC_CASE_COMPARISON * simplerpc serialization, meaning that there will be no "<fault>" element in that * serialization. There will simply be a standard struct with 2 child elements. * imho, the "<fault>" element is unnecessary and/or out of place as part of the standard API. + * * SOURCE */ XMLRPC_VALUE XMLRPC_UtilityCreateFault(int fault_code, const char* fault_string) { @@ -2749,6 +2766,147 @@ XMLRPC_VALUE XMLRPC_UtilityCreateFault(int fault_code, const char* fault_string) /*******/ +/****f* FAULT/XMLRPC_ValueIsFault + * NAME + * XMLRPC_ValueIsFault + * SYNOPSIS + * int XMLRPC_ValueIsFault (XMLRPC_VALUE value) + * FUNCTION + * Determines if a value encapsulates a fault "object" + * INPUTS + * value any XMLRPC_VALUE + * RESULT + * 1 if it is a fault, else 0 + * SEE ALSO + * XMLRPC_ResponseIsFault () + * SOURCE + */ +int XMLRPC_ValueIsFault (XMLRPC_VALUE value) { + if( XMLRPC_VectorGetValueWithID(value, "faultCode") && + XMLRPC_VectorGetValueWithID(value, "faultString") ) { + return 1; + } + return 0; +} +/*******/ + + +/****f* FAULT/XMLRPC_ResponseIsFault + * NAME + * XMLRPC_ResponseIsFault + * SYNOPSIS + * int XMLRPC_ResponseIsFault (XMLRPC_REQUEST response) + * FUNCTION + * Determines if a response contains an encapsulated fault "object" + * INPUTS + * value any XMLRPC_REQUEST. typically of type xmlrpc_request_response + * RESULT + * 1 if it contains a fault, else 0 + * SEE ALSO + * XMLRPC_ValueIsFault () + * SOURCE + */ +int XMLRPC_ResponseIsFault(XMLRPC_REQUEST response) { + return XMLRPC_ValueIsFault( XMLRPC_RequestGetData(response) ); +} + +/*******/ + +/****f* FAULT/XMLRPC_GetValueFaultCode + * NAME + * XMLRPC_GetValueFaultCode + * SYNOPSIS + * int XMLRPC_GetValueFaultCode (XMLRPC_VALUE value) + * FUNCTION + * returns fault code from a struct, if any + * INPUTS + * value XMLRPC_VALUE of type xmlrpc_vector_struct. + * RESULT + * fault code, else 0. + * BUGS + * impossible to distinguish faultCode == 0 from faultCode not present. + * SEE ALSO + * XMLRPC_GetResponseFaultCode () + * SOURCE + */ +int XMLRPC_GetValueFaultCode (XMLRPC_VALUE value) { + return XMLRPC_VectorGetIntWithID(value, "faultCode"); +} + +/*******/ + +/****f* FAULT/XMLRPC_GetResponseFaultCode + * NAME + * XMLRPC_GetResponseFaultCode + * SYNOPSIS + * int XMLRPC_GetResponseFaultCode(XMLRPC_REQUEST response) + * FUNCTION + * returns fault code from a response, if any + * INPUTS + * response XMLRPC_REQUEST. typically of type xmlrpc_request_response. + * RESULT + * fault code, else 0. + * BUGS + * impossible to distinguish faultCode == 0 from faultCode not present. + * SEE ALSO + * XMLRPC_GetValueFaultCode () + * SOURCE + */ +int XMLRPC_GetResponseFaultCode(XMLRPC_REQUEST response) { + return XMLRPC_GetValueFaultCode( XMLRPC_RequestGetData(response) ); +} + +/*******/ + + +/****f* FAULT/XMLRPC_GetValueFaultString + * NAME + * XMLRPC_GetValueFaultString + * SYNOPSIS + * const char* XMLRPC_GetValueFaultString (XMLRPC_VALUE value) + * FUNCTION + * returns fault string from a struct, if any + * INPUTS + * value XMLRPC_VALUE of type xmlrpc_vector_struct. + * RESULT + * fault string, else 0. + * SEE ALSO + * XMLRPC_GetResponseFaultString () + * SOURCE + */ +const char* XMLRPC_GetValueFaultString (XMLRPC_VALUE value) { + return XMLRPC_VectorGetStringWithID(value, "faultString"); +} + +/*******/ + +/****f* FAULT/XMLRPC_GetResponseFaultString + * NAME + * XMLRPC_GetResponseFaultString + * SYNOPSIS + * const char* XMLRPC_GetResponseFaultString (XMLRPC_REQUEST response) + * FUNCTION + * returns fault string from a response, if any + * INPUTS + * response XMLRPC_REQUEST. typically of type xmlrpc_request_response. + * RESULT + * fault string, else 0. + * SEE ALSO + * XMLRPC_GetValueFaultString () + * SOURCE + */ +const char* XMLRPC_GetResponseFaultString (XMLRPC_REQUEST response) { + return XMLRPC_GetValueFaultString( XMLRPC_RequestGetData(response) ); +} + +/*******/ + + +/*-****************** +* Utility API funcs * +********************/ + + /****f* UTILITY/XMLRPC_Free * NAME * XMLRPC_Free diff --git a/ext/xmlrpc/libxmlrpc/xmlrpc.h b/ext/xmlrpc/libxmlrpc/xmlrpc.h index bcfa46fadc..dde3d5e122 100644 --- a/ext/xmlrpc/libxmlrpc/xmlrpc.h +++ b/ext/xmlrpc/libxmlrpc/xmlrpc.h @@ -43,11 +43,11 @@ extern "C" { /* allow version to be specified via compile line define */ #ifndef XMLRPC_LIB_VERSION - #define XMLRPC_LIB_VERSION "0.50" + #define XMLRPC_LIB_VERSION "0.51" #endif /* this number, representing the date, must be increased each time the API changes */ -#define XMLRPC_API_NO 20010721 +#define XMLRPC_API_NO 20020623 /* this string should be changed with each packaged release */ #define XMLRPC_VERSION_STR "xmlrpc-epi v. " XMLRPC_LIB_VERSION @@ -191,8 +191,8 @@ typedef enum _xmlrpc_error_code { * SOURCE */ typedef enum _xmlrpc_version { - xmlrpc_version_none, /* not a recognized vocabulary */ - xmlrpc_version_1_0, /* xmlrpc 1.0 standard vocab */ + xmlrpc_version_none = 0, /* not a recognized vocabulary */ + xmlrpc_version_1_0 = 1, /* xmlrpc 1.0 standard vocab */ xmlrpc_version_simple = 2, /* alt more readable vocab */ xmlrpc_version_danda = 2, /* same as simple. legacy */ xmlrpc_version_soap_1_1 = 3 /* SOAP. version 1.1 */ @@ -334,6 +334,10 @@ XMLRPC_VALUE XMLRPC_CreateVector(const char* id, XMLRPC_VECTOR_TYPE type); /* Cleanup values */ void XMLRPC_CleanupValue(XMLRPC_VALUE value); +/* Request error */ +XMLRPC_VALUE XMLRPC_RequestSetError (XMLRPC_REQUEST request, XMLRPC_VALUE error); +XMLRPC_VALUE XMLRPC_RequestGetError (XMLRPC_REQUEST request); + /* Copy values */ XMLRPC_VALUE XMLRPC_CopyValue(XMLRPC_VALUE value); XMLRPC_VALUE XMLRPC_DupValueNew(XMLRPC_VALUE xSource); @@ -393,6 +397,15 @@ XMLRPC_VALUE XMLRPC_ServerCallMethod(XMLRPC_SERVER server, XMLRPC_REQUEST reques #include "xmlrpc_introspection.h" +/* Fault interrogation funcs */ +int XMLRPC_ValueIsFault (XMLRPC_VALUE value); +int XMLRPC_ResponseIsFault(XMLRPC_REQUEST response); +int XMLRPC_GetValueFaultCode (XMLRPC_VALUE value); +int XMLRPC_GetResponseFaultCode(XMLRPC_REQUEST response); +const char* XMLRPC_GetValueFaultString (XMLRPC_VALUE value); +const char* XMLRPC_GetResponseFaultString (XMLRPC_REQUEST response); + + /* Public Utility funcs */ XMLRPC_VALUE XMLRPC_UtilityCreateFault(int fault_code, const char* fault_string); void XMLRPC_Free(void* mem); diff --git a/ext/xmlrpc/libxmlrpc/xmlrpc_introspection.c b/ext/xmlrpc/libxmlrpc/xmlrpc_introspection.c index d9251b2709..bc1853ea73 100644 --- a/ext/xmlrpc/libxmlrpc/xmlrpc_introspection.c +++ b/ext/xmlrpc/libxmlrpc/xmlrpc_introspection.c @@ -35,6 +35,10 @@ * AUTHOR * Dan Libby, aka danda (dan@libby.com) * HISTORY + * $Log$ + * Revision 1.9 2001/09/29 21:58:05 danda + * adding cvs log to history section + * * 4/10/2001 -- danda -- initial introspection support * TODO * NOTES diff --git a/ext/xmlrpc/libxmlrpc/xmlrpc_private.h b/ext/xmlrpc/libxmlrpc/xmlrpc_private.h index afb1cd2479..65c6b136a6 100644 --- a/ext/xmlrpc/libxmlrpc/xmlrpc_private.h +++ b/ext/xmlrpc/libxmlrpc/xmlrpc_private.h @@ -160,7 +160,7 @@ typedef struct _server_method { /*---------------------------------------------------------------------------- * Functions */ -extern server_method* find_method(XMLRPC_SERVER server, const char* name); +server_method* find_method(XMLRPC_SERVER server, const char* name); const char* type_to_str(XMLRPC_VALUE_TYPE type, XMLRPC_VECTOR_TYPE vtype); /*---------------------------------------------------------------------------- |