mirror of
https://github.com/php/php-src.git
synced 2025-08-20 01:14:28 +02:00
Porting of patch applied to ext/xmlrpc.
This commit is contained in:
parent
a0b3f822f7
commit
e37aee1a34
1 changed files with 350 additions and 396 deletions
|
@ -307,11 +307,7 @@ static int add_zval(zval* list, const char* id, zval** val)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ZEND_MODULE_API_NO >= 20001222
|
|
||||||
#define my_zend_hash_get_current_key(ht, my_key, num_index) zend_hash_get_current_key(ht, my_key, num_index, 0)
|
#define my_zend_hash_get_current_key(ht, my_key, num_index) zend_hash_get_current_key(ht, my_key, num_index, 0)
|
||||||
#else
|
|
||||||
#define my_zend_hash_get_current_key(ht, my_key, num_index) zend_hash_get_current_key(ht, my_key, num_index)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*************************
|
/*************************
|
||||||
|
@ -610,18 +606,19 @@ static zval* XMLRPC_to_PHP(XMLRPC_VALUE el)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case xmlrpc_vector:
|
case xmlrpc_vector:
|
||||||
if(array_init(elem) == SUCCESS) {
|
array_init(elem);
|
||||||
XMLRPC_VALUE xIter = XMLRPC_VectorRewind(el);
|
{
|
||||||
|
XMLRPC_VALUE xIter = XMLRPC_VectorRewind(el);
|
||||||
|
|
||||||
while( xIter ) {
|
while( xIter ) {
|
||||||
zval* val = XMLRPC_to_PHP(xIter);
|
zval *val = XMLRPC_to_PHP(xIter);
|
||||||
if(val) {
|
if (val) {
|
||||||
add_zval(elem, XMLRPC_GetValueID(xIter), &val);
|
add_zval(elem, XMLRPC_GetValueID(xIter), &val);
|
||||||
}
|
}
|
||||||
xIter = XMLRPC_VectorNext(el);
|
xIter = XMLRPC_VectorNext(el);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -634,43 +631,40 @@ static zval* XMLRPC_to_PHP(XMLRPC_VALUE el)
|
||||||
Generates XML for a method request */
|
Generates XML for a method request */
|
||||||
PHP_FUNCTION(xmlrpc_encode_request)
|
PHP_FUNCTION(xmlrpc_encode_request)
|
||||||
{
|
{
|
||||||
XMLRPC_REQUEST xRequest = NULL;
|
XMLRPC_REQUEST xRequest = NULL;
|
||||||
zval* method, *vals, *out_opts;
|
zval **method, **vals, **out_opts;
|
||||||
char* outBuf;
|
char* outBuf;
|
||||||
php_output_options out;
|
php_output_options out;
|
||||||
|
|
||||||
if( !(ARG_COUNT(ht) == 2 || ARG_COUNT(ht) == 3) ||
|
if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > 3 || (zend_get_parameters_ex(ZEND_NUM_ARGS(), &method, &vals, &out_opts) == FAILURE)) {
|
||||||
getParameters(ht, ARG_COUNT(ht), &method, &vals, &out_opts) == FAILURE) {
|
WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
|
||||||
WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
|
}
|
||||||
}
|
|
||||||
|
|
||||||
set_output_options(&out, (ARG_COUNT(ht) == 3) ? out_opts : 0);
|
set_output_options(&out, (ZEND_NUM_ARGS() == 3) ? *out_opts : 0);
|
||||||
|
|
||||||
|
if(return_value_used) {
|
||||||
|
xRequest = XMLRPC_RequestNew();
|
||||||
|
|
||||||
if(return_value_used) {
|
if(xRequest) {
|
||||||
xRequest = XMLRPC_RequestNew();
|
XMLRPC_RequestSetOutputOptions(xRequest, &out.xmlrpc_out);
|
||||||
|
if (Z_TYPE_PP(method) == IS_NULL) {
|
||||||
|
XMLRPC_RequestSetRequestType(xRequest, xmlrpc_request_response);
|
||||||
|
} else {
|
||||||
|
XMLRPC_RequestSetMethodName(xRequest, Z_STRVAL_PP(method));
|
||||||
|
XMLRPC_RequestSetRequestType(xRequest, xmlrpc_request_call);
|
||||||
|
}
|
||||||
|
if (Z_TYPE_PP(vals) != IS_NULL) {
|
||||||
|
XMLRPC_RequestSetData(xRequest, PHP_to_XMLRPC(*vals));
|
||||||
|
}
|
||||||
|
|
||||||
if(xRequest) {
|
outBuf = XMLRPC_REQUEST_ToXML(xRequest, 0);
|
||||||
XMLRPC_RequestSetOutputOptions(xRequest, &out.xmlrpc_out);
|
if(outBuf) {
|
||||||
if(Z_TYPE_P(method) == IS_NULL) {
|
RETVAL_STRING(outBuf, 1);
|
||||||
XMLRPC_RequestSetRequestType(xRequest, xmlrpc_request_response);
|
free(outBuf);
|
||||||
}
|
}
|
||||||
else {
|
XMLRPC_RequestFree(xRequest, 1);
|
||||||
XMLRPC_RequestSetMethodName(xRequest, Z_STRVAL_P(method));
|
}
|
||||||
XMLRPC_RequestSetRequestType(xRequest, xmlrpc_request_call);
|
}
|
||||||
}
|
|
||||||
if(Z_TYPE_P(vals) != IS_NULL) {
|
|
||||||
XMLRPC_RequestSetData(xRequest, PHP_to_XMLRPC(vals));
|
|
||||||
}
|
|
||||||
|
|
||||||
outBuf = XMLRPC_REQUEST_ToXML(xRequest, 0);
|
|
||||||
if(outBuf) {
|
|
||||||
RETVAL_STRING(outBuf, 1);
|
|
||||||
free(outBuf);
|
|
||||||
}
|
|
||||||
XMLRPC_RequestFree(xRequest, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -678,31 +672,30 @@ PHP_FUNCTION(xmlrpc_encode_request)
|
||||||
Generates XML for a PHP value */
|
Generates XML for a PHP value */
|
||||||
PHP_FUNCTION(xmlrpc_encode)
|
PHP_FUNCTION(xmlrpc_encode)
|
||||||
{
|
{
|
||||||
XMLRPC_VALUE xOut = NULL;
|
XMLRPC_VALUE xOut = NULL;
|
||||||
zval* arg1;
|
zval **arg1;
|
||||||
char* outBuf;
|
char *outBuf;
|
||||||
|
|
||||||
if( !(ARG_COUNT(ht) == 1) ||
|
if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &arg1) == FAILURE)) {
|
||||||
getParameters(ht, ARG_COUNT(ht), &arg1) == FAILURE) {
|
WRONG_PARAM_COUNT;
|
||||||
WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if( return_value_used ) {
|
if( return_value_used ) {
|
||||||
/* convert native php type to xmlrpc type */
|
/* convert native php type to xmlrpc type */
|
||||||
xOut = PHP_to_XMLRPC(arg1);
|
xOut = PHP_to_XMLRPC(*arg1);
|
||||||
|
|
||||||
/* generate raw xml from xmlrpc data */
|
/* generate raw xml from xmlrpc data */
|
||||||
outBuf = XMLRPC_VALUE_ToXML(xOut, 0);
|
outBuf = XMLRPC_VALUE_ToXML(xOut, 0);
|
||||||
|
|
||||||
if(xOut) {
|
if(xOut) {
|
||||||
if(outBuf) {
|
if(outBuf) {
|
||||||
RETVAL_STRING(outBuf, 1);
|
RETVAL_STRING(outBuf, 1);
|
||||||
free(outBuf);
|
free(outBuf);
|
||||||
}
|
}
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
XMLRPC_CleanupValue(xOut);
|
XMLRPC_CleanupValue(xOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -739,30 +732,26 @@ zval* decode_request_worker (zval* xml_in, zval* encoding_in, zval* method_name_
|
||||||
Decodes XML into native PHP types */
|
Decodes XML into native PHP types */
|
||||||
PHP_FUNCTION(xmlrpc_decode_request)
|
PHP_FUNCTION(xmlrpc_decode_request)
|
||||||
{
|
{
|
||||||
zval* xml, *method, *encoding = NULL;
|
zval **xml, **method, **encoding = NULL;
|
||||||
|
int argc = ZEND_NUM_ARGS();
|
||||||
|
|
||||||
if( !(ARG_COUNT(ht) == 2 || ARG_COUNT(ht) == 3) || getParameters(ht, ARG_COUNT(ht), &xml, &method, &encoding) == FAILURE) {
|
if (argc < 2 || argc > 3 || (zend_get_parameters_ex(argc, &xml, &method, &encoding) == FAILURE)) {
|
||||||
WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
|
WRONG_PARAM_COUNT;
|
||||||
}
|
}
|
||||||
#if ZEND_MODULE_API_NO < 20010901
|
|
||||||
if (!ParameterPassedByReference(ht,2)) {
|
|
||||||
zend_error(E_WARNING,"second argument to xmlrpc_decode_request() passed by value, expecting reference");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
convert_to_string(xml);
|
convert_to_string_ex(xml);
|
||||||
convert_to_string(method);
|
convert_to_string_ex(method);
|
||||||
if(ARG_COUNT(ht) == 3) {
|
if(argc == 3) {
|
||||||
convert_to_string(encoding);
|
convert_to_string_ex(encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(return_value_used) {
|
if(return_value_used) {
|
||||||
zval* retval = decode_request_worker(xml, encoding, method);
|
zval* retval = decode_request_worker(*xml, *encoding, *method);
|
||||||
if(retval) {
|
if(retval) {
|
||||||
*return_value = *retval;
|
*return_value = *retval;
|
||||||
FREE_ZVAL(retval);
|
FREE_ZVAL(retval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -771,24 +760,25 @@ PHP_FUNCTION(xmlrpc_decode_request)
|
||||||
Decodes XML into native PHP types */
|
Decodes XML into native PHP types */
|
||||||
PHP_FUNCTION(xmlrpc_decode)
|
PHP_FUNCTION(xmlrpc_decode)
|
||||||
{
|
{
|
||||||
zval* arg1, *arg2 = NULL;
|
zval **arg1, **arg2 = NULL;
|
||||||
|
int argc = ZEND_NUM_ARGS();
|
||||||
|
|
||||||
if( !(ARG_COUNT(ht) == 1 || ARG_COUNT(ht) == 2) || getParameters(ht, ARG_COUNT(ht), &arg1, &arg2) == FAILURE) {
|
if (argc < 1 || argc > 2 || (zend_get_parameters_ex(argc, &arg1, &arg2) == FAILURE)) {
|
||||||
WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
|
WRONG_PARAM_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_to_string(arg1);
|
convert_to_string_ex(arg1);
|
||||||
if(ARG_COUNT(ht) == 2) {
|
if(argc == 2) {
|
||||||
convert_to_string(arg2);
|
convert_to_string_ex(arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(return_value_used) {
|
if(return_value_used) {
|
||||||
zval* retval = decode_request_worker(arg1, arg2, NULL);
|
zval* retval = decode_request_worker(*arg1, *arg2, NULL);
|
||||||
if(retval) {
|
if(retval) {
|
||||||
*return_value = *retval;
|
*return_value = *retval;
|
||||||
FREE_ZVAL(retval);
|
FREE_ZVAL(retval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -801,58 +791,56 @@ PHP_FUNCTION(xmlrpc_decode)
|
||||||
Creates an xmlrpc server */
|
Creates an xmlrpc server */
|
||||||
PHP_FUNCTION(xmlrpc_server_create)
|
PHP_FUNCTION(xmlrpc_server_create)
|
||||||
{
|
{
|
||||||
if(ARG_COUNT(ht) != 0) {
|
if(ZEND_NUM_ARGS() != 0) {
|
||||||
WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
|
WRONG_PARAM_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(return_value_used) {
|
if(return_value_used) {
|
||||||
zval *method_map, *introspection_map;
|
zval *method_map, *introspection_map;
|
||||||
MAKE_STD_ZVAL(method_map);
|
xmlrpc_server_data *server = emalloc(sizeof(xmlrpc_server_data));
|
||||||
MAKE_STD_ZVAL(introspection_map);
|
MAKE_STD_ZVAL(method_map);
|
||||||
|
MAKE_STD_ZVAL(introspection_map);
|
||||||
|
|
||||||
|
array_init(method_map);
|
||||||
|
array_init(introspection_map);
|
||||||
|
|
||||||
|
/* allocate server data. free'd in destroy_server_data() */
|
||||||
|
server->method_map = method_map;
|
||||||
|
server->introspection_map = introspection_map;
|
||||||
|
server->server_ptr = XMLRPC_ServerCreate();
|
||||||
|
|
||||||
if(array_init(method_map) == SUCCESS && array_init(introspection_map) == SUCCESS) {
|
XMLRPC_ServerRegisterIntrospectionCallback(server->server_ptr, php_xmlrpc_introspection_callback);
|
||||||
/* allocate server data. free'd in destroy_server_data() */
|
|
||||||
xmlrpc_server_data *server = emalloc(sizeof(xmlrpc_server_data));
|
|
||||||
|
|
||||||
if(server) {
|
/* store for later use */
|
||||||
server->method_map = method_map;
|
ZEND_REGISTER_RESOURCE(return_value,server, le_xmlrpc_server);
|
||||||
server->introspection_map = introspection_map;
|
}
|
||||||
server->server_ptr = XMLRPC_ServerCreate();
|
|
||||||
|
|
||||||
XMLRPC_ServerRegisterIntrospectionCallback(server->server_ptr, php_xmlrpc_introspection_callback);
|
|
||||||
|
|
||||||
/* store for later use */
|
|
||||||
ZEND_REGISTER_RESOURCE(return_value,server, le_xmlrpc_server);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* {{{ proto void xmlrpc_server_destroy(handle server)
|
/* {{{ proto void xmlrpc_server_destroy(handle server)
|
||||||
Destroys server resources */
|
Destroys server resources */
|
||||||
PHP_FUNCTION(xmlrpc_server_destroy)
|
PHP_FUNCTION(xmlrpc_server_destroy)
|
||||||
{
|
{
|
||||||
zval* arg1;
|
zval **arg1;
|
||||||
int bSuccess = FAILURE;
|
int bSuccess = FAILURE;
|
||||||
|
|
||||||
if(ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
|
if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &arg1) == FAILURE)) {
|
||||||
WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
|
WRONG_PARAM_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Z_TYPE_P(arg1) == IS_RESOURCE) {
|
if(Z_TYPE_PP(arg1) == IS_RESOURCE) {
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
xmlrpc_server_data *server = zend_list_find(Z_LVAL_P(arg1), &type);
|
xmlrpc_server_data *server = zend_list_find(Z_LVAL_PP(arg1), &type);
|
||||||
|
|
||||||
if(server && type == le_xmlrpc_server) {
|
if(server && type == le_xmlrpc_server) {
|
||||||
bSuccess = zend_list_delete(Z_LVAL_P(arg1));
|
bSuccess = zend_list_delete(Z_LVAL_PP(arg1));
|
||||||
|
|
||||||
/* called by hashtable destructor
|
/* called by hashtable destructor
|
||||||
* destroy_server_data(server);
|
* destroy_server_data(server);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RETVAL_LONG(bSuccess == SUCCESS);
|
RETVAL_LONG(bSuccess == SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -922,25 +910,25 @@ static void php_xmlrpc_introspection_callback(XMLRPC_SERVER server, void* data)
|
||||||
|
|
||||||
if(xData) {
|
if(xData) {
|
||||||
if(!XMLRPC_ServerAddIntrospectionData(server, xData)) {
|
if(!XMLRPC_ServerAddIntrospectionData(server, xData)) {
|
||||||
zend_error(E_WARNING, "Unable to add introspection data returned from %s(), improper element structure", Z_STRVAL_PP(php_function));
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add introspection data returned from %s(), improper element structure", Z_STRVAL_PP(php_function));
|
||||||
}
|
}
|
||||||
XMLRPC_CleanupValue(xData);
|
XMLRPC_CleanupValue(xData);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* could not create description */
|
/* could not create description */
|
||||||
if(err.xml_elem_error.parser_code) {
|
if(err.xml_elem_error.parser_code) {
|
||||||
zend_error(E_WARNING, "xml parse error: [line %i, column %i, message: %s] Unable to add introspection data returned from %s()",
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "xml parse error: [line %i, column %i, message: %s] Unable to add introspection data returned from %s()",
|
||||||
err.xml_elem_error.column, err.xml_elem_error.line, err.xml_elem_error.parser_error, Z_STRVAL_PP(php_function));
|
err.xml_elem_error.column, err.xml_elem_error.line, err.xml_elem_error.parser_error, Z_STRVAL_PP(php_function));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
zend_error(E_WARNING, "Unable to add introspection data returned from %s()",
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add introspection data returned from %s()",
|
||||||
Z_STRVAL_PP(php_function));
|
Z_STRVAL_PP(php_function));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* user func failed */
|
/* user func failed */
|
||||||
zend_error(E_WARNING, "Error calling user introspection callback: %s()", Z_STRVAL_PP(php_function));
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error calling user introspection callback: %s()", Z_STRVAL_PP(php_function));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -958,34 +946,33 @@ static void php_xmlrpc_introspection_callback(XMLRPC_SERVER server, void* data)
|
||||||
Register a PHP function to handle method matching method_name */
|
Register a PHP function to handle method matching method_name */
|
||||||
PHP_FUNCTION(xmlrpc_server_register_method)
|
PHP_FUNCTION(xmlrpc_server_register_method)
|
||||||
{
|
{
|
||||||
zval* method_key, *method_name, *handle, *method_name_save;
|
zval **method_key, **method_name, **handle, *method_name_save;
|
||||||
int type;
|
int type;
|
||||||
xmlrpc_server_data* server;
|
xmlrpc_server_data* server;
|
||||||
|
|
||||||
/* get some params. should be 3 */
|
if (ZEND_NUM_ARGS() != 3 || (zend_get_parameters_ex(3, &handle, &method_key, &method_name) == FAILURE)) {
|
||||||
if( !(ARG_COUNT(ht) == 3) || getParameters(ht, ARG_COUNT(ht), &handle, &method_key, &method_name) == FAILURE) {
|
WRONG_PARAM_COUNT;
|
||||||
WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
|
}
|
||||||
}
|
|
||||||
|
|
||||||
server = zend_list_find(Z_LVAL_P(handle), &type);
|
server = zend_list_find(Z_LVAL_PP(handle), &type);
|
||||||
|
|
||||||
if(type == le_xmlrpc_server) {
|
if(type == le_xmlrpc_server) {
|
||||||
/* register with C engine. every method just calls our standard callback,
|
/* register with C engine. every method just calls our standard callback,
|
||||||
* and it then dispatches to php as necessary
|
* and it then dispatches to php as necessary
|
||||||
*/
|
*/
|
||||||
if(XMLRPC_ServerRegisterMethod(server->server_ptr, Z_STRVAL_P(method_key), php_xmlrpc_callback)) {
|
if(XMLRPC_ServerRegisterMethod(server->server_ptr, Z_STRVAL_PP(method_key), php_xmlrpc_callback)) {
|
||||||
/* save for later use */
|
/* save for later use */
|
||||||
MAKE_STD_ZVAL(method_name_save);
|
MAKE_STD_ZVAL(method_name_save);
|
||||||
*method_name_save = *method_name;
|
*method_name_save = **method_name;
|
||||||
zval_copy_ctor(method_name_save);
|
zval_copy_ctor(method_name_save);
|
||||||
|
|
||||||
/* register our php method */
|
/* register our php method */
|
||||||
add_zval(server->method_map, Z_STRVAL_P(method_key), &method_name_save);
|
add_zval(server->method_map, Z_STRVAL_PP(method_key), &method_name_save);
|
||||||
|
|
||||||
RETURN_BOOL(1);
|
RETURN_BOOL(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RETURN_BOOL(0);
|
RETURN_BOOL(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -993,31 +980,28 @@ PHP_FUNCTION(xmlrpc_server_register_method)
|
||||||
Register a PHP function to generate documentation */
|
Register a PHP function to generate documentation */
|
||||||
PHP_FUNCTION(xmlrpc_server_register_introspection_callback)
|
PHP_FUNCTION(xmlrpc_server_register_introspection_callback)
|
||||||
{
|
{
|
||||||
zval* method_name, *handle, *method_name_save;
|
zval **method_name, **handle, *method_name_save;
|
||||||
int type;
|
int type;
|
||||||
xmlrpc_server_data* server;
|
xmlrpc_server_data* server;
|
||||||
|
|
||||||
/* get some params. should be 2 */
|
if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &handle, &method_name) == FAILURE)) {
|
||||||
if( !(ARG_COUNT(ht) == 2) || getParameters(ht, ARG_COUNT(ht), &handle, &method_name) == FAILURE) {
|
WRONG_PARAM_COUNT;
|
||||||
WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
|
}
|
||||||
}
|
|
||||||
|
|
||||||
server = zend_list_find(Z_LVAL_P(handle), &type);
|
server = zend_list_find(Z_LVAL_PP(handle), &type);
|
||||||
|
|
||||||
if(type == le_xmlrpc_server) {
|
if(type == le_xmlrpc_server) {
|
||||||
{
|
/* save for later use */
|
||||||
/* save for later use */
|
MAKE_STD_ZVAL(method_name_save);
|
||||||
MAKE_STD_ZVAL(method_name_save);
|
*method_name_save = **method_name;
|
||||||
*method_name_save = *method_name;
|
zval_copy_ctor(method_name_save);
|
||||||
zval_copy_ctor(method_name_save);
|
|
||||||
|
|
||||||
/* register our php method */
|
/* register our php method */
|
||||||
add_zval(server->introspection_map, NULL, &method_name_save);
|
add_zval(server->introspection_map, NULL, &method_name_save);
|
||||||
|
|
||||||
RETURN_BOOL(1);
|
RETURN_BOOL(1);
|
||||||
}
|
}
|
||||||
}
|
RETURN_BOOL(0);
|
||||||
RETURN_BOOL(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1027,97 +1011,79 @@ PHP_FUNCTION(xmlrpc_server_register_introspection_callback)
|
||||||
Parses XML requests and call methods */
|
Parses XML requests and call methods */
|
||||||
PHP_FUNCTION(xmlrpc_server_call_method)
|
PHP_FUNCTION(xmlrpc_server_call_method)
|
||||||
{
|
{
|
||||||
xmlrpc_callback_data data = {0};
|
xmlrpc_callback_data data = {0};
|
||||||
XMLRPC_REQUEST xRequest;
|
XMLRPC_REQUEST xRequest;
|
||||||
STRUCT_XMLRPC_REQUEST_INPUT_OPTIONS input_opts;
|
STRUCT_XMLRPC_REQUEST_INPUT_OPTIONS input_opts;
|
||||||
xmlrpc_server_data* server;
|
xmlrpc_server_data* server;
|
||||||
zval *rawxml, *caller_params, *handle, *output_opts;
|
zval **rawxml, **caller_params, **handle, **output_opts = NULL;
|
||||||
int type;
|
int type;
|
||||||
php_output_options out;
|
php_output_options out;
|
||||||
|
int argc =ZEND_NUM_ARGS();
|
||||||
|
|
||||||
|
if (argc < 3 || argc > 4 || (zend_get_parameters_ex(argc, &handle, &rawxml, &caller_params, &output_opts) != SUCCESS)) {
|
||||||
|
WRONG_PARAM_COUNT;
|
||||||
|
}
|
||||||
|
/* user output options */
|
||||||
|
set_output_options(&out, *output_opts);
|
||||||
|
|
||||||
/* get params. 3 or 4 params ok */
|
server = zend_list_find(Z_LVAL_PP(handle), &type);
|
||||||
if(ARG_COUNT(ht) == 4) {
|
|
||||||
if(getParameters(ht, ARG_COUNT(ht), &handle, &rawxml, &caller_params, &output_opts) != SUCCESS) {
|
|
||||||
WRONG_PARAM_COUNT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* user output options */
|
if(type == le_xmlrpc_server) {
|
||||||
set_output_options(&out, output_opts);
|
/* HACK: use output encoding for now */
|
||||||
}
|
input_opts.xml_elem_opts.encoding = utf8_get_encoding_id_from_string(out.xmlrpc_out.xml_elem_opts.encoding);
|
||||||
else if(ARG_COUNT(ht) == 3) {
|
|
||||||
if(getParameters(ht, ARG_COUNT(ht), &handle, &rawxml, &caller_params) != SUCCESS) {
|
|
||||||
WRONG_PARAM_COUNT;
|
|
||||||
}
|
|
||||||
/* user output options */
|
|
||||||
set_output_options(&out, NULL);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
WRONG_PARAM_COUNT;
|
|
||||||
}
|
|
||||||
|
|
||||||
server = zend_list_find(Z_LVAL_P(handle), &type);
|
/* generate an XMLRPC_REQUEST from the raw xml input */
|
||||||
|
xRequest = XMLRPC_REQUEST_FromXML(Z_STRVAL_PP(rawxml), Z_STRLEN_PP(rawxml), &input_opts);
|
||||||
|
|
||||||
if(type == le_xmlrpc_server) {
|
if(xRequest) {
|
||||||
/* HACK: use output encoding for now */
|
const char* methodname = XMLRPC_RequestGetMethodName(xRequest);
|
||||||
input_opts.xml_elem_opts.encoding = utf8_get_encoding_id_from_string(out.xmlrpc_out.xml_elem_opts.encoding);
|
zval **php_function;
|
||||||
|
XMLRPC_VALUE xAnswer = NULL;
|
||||||
|
MAKE_STD_ZVAL(data.xmlrpc_method); /* init. very important. spent a frustrating day finding this out. */
|
||||||
|
MAKE_STD_ZVAL(data.return_data);
|
||||||
|
Z_TYPE_P(data.return_data) = IS_NULL; /* in case value is never init'd, we don't dtor to think it is a string or something */
|
||||||
|
Z_TYPE_P(data.xmlrpc_method) = IS_NULL;
|
||||||
|
|
||||||
/* generate an XMLRPC_REQUEST from the raw xml input */
|
if (!methodname) {
|
||||||
xRequest = XMLRPC_REQUEST_FromXML(Z_STRVAL_P(rawxml), Z_STRLEN_P(rawxml), &input_opts);
|
methodname = "";
|
||||||
|
}
|
||||||
if(xRequest) {
|
|
||||||
const char* methodname = XMLRPC_RequestGetMethodName(xRequest);
|
|
||||||
zval** php_function;
|
|
||||||
XMLRPC_VALUE xAnswer = NULL;
|
|
||||||
MAKE_STD_ZVAL(data.xmlrpc_method); /* init. very important. spent a frustrating day finding this out. */
|
|
||||||
MAKE_STD_ZVAL(data.return_data);
|
|
||||||
Z_TYPE_P(data.return_data) = IS_NULL; /* in case value is never init'd, we don't dtor to think it is a string or something */
|
|
||||||
Z_TYPE_P(data.xmlrpc_method) = IS_NULL;
|
|
||||||
|
|
||||||
if (!methodname) {
|
|
||||||
methodname = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* setup some data to pass to the callback function */
|
/* setup some data to pass to the callback function */
|
||||||
Z_STRVAL_P(data.xmlrpc_method) = estrdup(methodname);
|
Z_STRVAL_P(data.xmlrpc_method) = estrdup(methodname);
|
||||||
Z_STRLEN_P(data.xmlrpc_method) = strlen(methodname);
|
Z_STRLEN_P(data.xmlrpc_method) = strlen(methodname);
|
||||||
Z_TYPE_P(data.xmlrpc_method) = IS_STRING;
|
Z_TYPE_P(data.xmlrpc_method) = IS_STRING;
|
||||||
data.caller_params = caller_params;
|
data.caller_params = *caller_params;
|
||||||
data.php_executed = 0;
|
data.php_executed = 0;
|
||||||
data.server = server;
|
data.server = server;
|
||||||
|
|
||||||
/* check if the called method has been previous registered */
|
/* check if the called method has been previous registered */
|
||||||
if(zend_hash_find(Z_ARRVAL_P(server->method_map),
|
if(zend_hash_find(Z_ARRVAL_P(server->method_map),
|
||||||
Z_STRVAL_P(data.xmlrpc_method),
|
Z_STRVAL_P(data.xmlrpc_method),
|
||||||
Z_STRLEN_P(data.xmlrpc_method) + 1,
|
Z_STRLEN_P(data.xmlrpc_method) + 1,
|
||||||
(void**)&php_function) == SUCCESS) {
|
(void**)&php_function) == SUCCESS) {
|
||||||
|
|
||||||
data.php_function = *php_function;
|
data.php_function = *php_function;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We could just call the php method directly ourselves at this point, but we do this
|
/* We could just call the php method directly ourselves at this point, but we do this
|
||||||
* with a C callback in case the xmlrpc library ever implements some cool usage stats,
|
* with a C callback in case the xmlrpc library ever implements some cool usage stats,
|
||||||
* or somesuch.
|
* or somesuch.
|
||||||
*/
|
*/
|
||||||
xAnswer = XMLRPC_ServerCallMethod(server->server_ptr, xRequest, &data);
|
xAnswer = XMLRPC_ServerCallMethod(server->server_ptr, xRequest, &data);
|
||||||
if(xAnswer) {
|
if(xAnswer && out.b_php_out) {
|
||||||
if(out.b_php_out) {
|
zval_dtor(data.return_data);
|
||||||
zval_dtor(data.return_data);
|
FREE_ZVAL(data.return_data);
|
||||||
FREE_ZVAL(data.return_data);
|
data.return_data = XMLRPC_to_PHP(xAnswer);
|
||||||
data.return_data = XMLRPC_to_PHP(xAnswer);
|
} else if(data.php_executed && !out.b_php_out) {
|
||||||
}
|
xAnswer = PHP_to_XMLRPC(data.return_data);
|
||||||
}
|
}
|
||||||
else if(data.php_executed) {
|
|
||||||
if(!out.b_php_out) {
|
|
||||||
xAnswer = PHP_to_XMLRPC(data.return_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* should we return data as xml? */
|
/* should we return data as xml? */
|
||||||
if(!out.b_php_out) {
|
if(!out.b_php_out) {
|
||||||
XMLRPC_REQUEST xResponse = XMLRPC_RequestNew();
|
XMLRPC_REQUEST xResponse = XMLRPC_RequestNew();
|
||||||
if(xResponse) {
|
if(xResponse) {
|
||||||
char* outBuf = 0;
|
char *outBuf = 0;
|
||||||
int buf_len = 0;
|
int buf_len = 0;
|
||||||
|
|
||||||
/* automagically determine output serialization type from request type */
|
/* automagically determine output serialization type from request type */
|
||||||
if (out.b_auto_version) {
|
if (out.b_auto_version) {
|
||||||
|
@ -1126,41 +1092,39 @@ PHP_FUNCTION(xmlrpc_server_call_method)
|
||||||
out.xmlrpc_out.version = opts->version;
|
out.xmlrpc_out.version = opts->version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* set some required request hoojum */
|
/* set some required request hoojum */
|
||||||
XMLRPC_RequestSetOutputOptions(xResponse, &out.xmlrpc_out);
|
XMLRPC_RequestSetOutputOptions(xResponse, &out.xmlrpc_out);
|
||||||
XMLRPC_RequestSetRequestType(xResponse, xmlrpc_request_response);
|
XMLRPC_RequestSetRequestType(xResponse, xmlrpc_request_response);
|
||||||
XMLRPC_RequestSetData(xResponse, xAnswer);
|
XMLRPC_RequestSetData(xResponse, xAnswer);
|
||||||
XMLRPC_RequestSetMethodName(xResponse, methodname);
|
XMLRPC_RequestSetMethodName(xResponse, methodname);
|
||||||
|
|
||||||
/* generate xml */
|
/* generate xml */
|
||||||
outBuf = XMLRPC_REQUEST_ToXML(xResponse, &buf_len);
|
outBuf = XMLRPC_REQUEST_ToXML(xResponse, &buf_len);
|
||||||
if(outBuf) {
|
if(outBuf) {
|
||||||
RETVAL_STRINGL(outBuf, buf_len, 1);
|
RETVAL_STRINGL(outBuf, buf_len, 1);
|
||||||
free(outBuf);
|
free(outBuf);
|
||||||
}
|
}
|
||||||
/* cleanup after ourselves. what a sty! */
|
/* cleanup after ourselves. what a sty! */
|
||||||
XMLRPC_RequestFree(xResponse, 0);
|
XMLRPC_RequestFree(xResponse, 0);
|
||||||
}
|
}
|
||||||
}
|
} else { /* or as native php types? */
|
||||||
/* or as native php types? */
|
*return_value = *data.return_data;
|
||||||
else {
|
zval_copy_ctor(return_value);
|
||||||
*return_value = *data.return_data;
|
}
|
||||||
zval_copy_ctor(return_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* cleanup after ourselves. what a sty! */
|
/* cleanup after ourselves. what a sty! */
|
||||||
zval_dtor(data.xmlrpc_method);
|
zval_dtor(data.xmlrpc_method);
|
||||||
FREE_ZVAL(data.xmlrpc_method);
|
FREE_ZVAL(data.xmlrpc_method);
|
||||||
zval_dtor(data.return_data);
|
zval_dtor(data.return_data);
|
||||||
FREE_ZVAL(data.return_data);
|
FREE_ZVAL(data.return_data);
|
||||||
|
|
||||||
if(xAnswer) {
|
if(xAnswer) {
|
||||||
XMLRPC_CleanupValue(xAnswer);
|
XMLRPC_CleanupValue(xAnswer);
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLRPC_RequestFree(xRequest, 1);
|
XMLRPC_RequestFree(xRequest, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1168,26 +1132,25 @@ PHP_FUNCTION(xmlrpc_server_call_method)
|
||||||
Adds introspection documentation */
|
Adds introspection documentation */
|
||||||
PHP_FUNCTION(xmlrpc_server_add_introspection_data)
|
PHP_FUNCTION(xmlrpc_server_add_introspection_data)
|
||||||
{
|
{
|
||||||
zval *handle, *desc;
|
zval **handle, **desc;
|
||||||
int type;
|
int type;
|
||||||
xmlrpc_server_data* server;
|
xmlrpc_server_data* server;
|
||||||
|
|
||||||
/* get some params. should be 2 */
|
if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &handle, &desc) == FAILURE)) {
|
||||||
if ( !(ARG_COUNT(ht) == 2) || getParameters(ht, ARG_COUNT(ht), &handle, &desc) == FAILURE) {
|
WRONG_PARAM_COUNT;
|
||||||
WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
|
}
|
||||||
}
|
|
||||||
|
|
||||||
server = zend_list_find(Z_LVAL_P(handle), &type);
|
server = zend_list_find(Z_LVAL_PP(handle), &type);
|
||||||
|
|
||||||
if (type == le_xmlrpc_server) {
|
if (type == le_xmlrpc_server) {
|
||||||
XMLRPC_VALUE xDesc = PHP_to_XMLRPC(desc);
|
XMLRPC_VALUE xDesc = PHP_to_XMLRPC(*desc);
|
||||||
if (xDesc) {
|
if (xDesc) {
|
||||||
int retval = XMLRPC_ServerAddIntrospectionData(server->server_ptr, xDesc);
|
int retval = XMLRPC_ServerAddIntrospectionData(server->server_ptr, xDesc);
|
||||||
XMLRPC_CleanupValue(xDesc);
|
XMLRPC_CleanupValue(xDesc);
|
||||||
RETURN_LONG(retval);
|
RETURN_LONG(retval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RETURN_LONG(0);
|
RETURN_LONG(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1195,40 +1158,38 @@ PHP_FUNCTION(xmlrpc_server_add_introspection_data)
|
||||||
Decodes XML into a list of method descriptions */
|
Decodes XML into a list of method descriptions */
|
||||||
PHP_FUNCTION(xmlrpc_parse_method_descriptions)
|
PHP_FUNCTION(xmlrpc_parse_method_descriptions)
|
||||||
{
|
{
|
||||||
zval* arg1, *retval;
|
zval **arg1, *retval;
|
||||||
|
|
||||||
if( !(ARG_COUNT(ht) == 1) || getParameters(ht, ARG_COUNT(ht), &arg1) == FAILURE) {
|
if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &arg1) == FAILURE)) {
|
||||||
WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
|
WRONG_PARAM_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_to_string(arg1);
|
convert_to_string_ex(arg1);
|
||||||
|
|
||||||
if(return_value_used) {
|
if(return_value_used) {
|
||||||
STRUCT_XMLRPC_ERROR err = {0};
|
STRUCT_XMLRPC_ERROR err = {0};
|
||||||
XMLRPC_VALUE xVal = XMLRPC_IntrospectionCreateDescription(Z_STRVAL_P(arg1), &err);
|
XMLRPC_VALUE xVal = XMLRPC_IntrospectionCreateDescription(Z_STRVAL_PP(arg1), &err);
|
||||||
if(xVal) {
|
if(xVal) {
|
||||||
retval = XMLRPC_to_PHP(xVal);
|
retval = XMLRPC_to_PHP(xVal);
|
||||||
|
|
||||||
if(retval) {
|
if(retval) {
|
||||||
*return_value = *retval;
|
*return_value = *retval;
|
||||||
zval_copy_ctor(return_value);
|
zval_copy_ctor(return_value);
|
||||||
}
|
}
|
||||||
/* dust, sweep, and mop */
|
/* dust, sweep, and mop */
|
||||||
XMLRPC_CleanupValue(xVal);
|
XMLRPC_CleanupValue(xVal);
|
||||||
}
|
} else {
|
||||||
else {
|
/* could not create description */
|
||||||
/* could not create description */
|
if(err.xml_elem_error.parser_code) {
|
||||||
if(err.xml_elem_error.parser_code) {
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "xml parse error: [line %i, column %i, message: %s] Unable to create introspection data",
|
||||||
zend_error(E_WARNING, "xml parse error: [line %i, column %i, message: %s] Unable to create introspection data",
|
err.xml_elem_error.column, err.xml_elem_error.line, err.xml_elem_error.parser_error);
|
||||||
err.xml_elem_error.column, err.xml_elem_error.line, err.xml_elem_error.parser_error);
|
} else {
|
||||||
}
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid xml structure. Unable to create introspection data");
|
||||||
else {
|
}
|
||||||
zend_error(E_WARNING, "Invalid xml structure. Unable to create introspection data");
|
|
||||||
}
|
|
||||||
|
|
||||||
zend_error(E_WARNING, "xml parse error. no method description created");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "xml parse error. no method description created");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1436,78 +1397,71 @@ XMLRPC_VALUE_TYPE get_zval_xmlrpc_type(zval* value, zval** newvalue)
|
||||||
Sets xmlrpc type, base64 or datetime, for a PHP string value */
|
Sets xmlrpc type, base64 or datetime, for a PHP string value */
|
||||||
PHP_FUNCTION(xmlrpc_set_type)
|
PHP_FUNCTION(xmlrpc_set_type)
|
||||||
{
|
{
|
||||||
zval* arg, *type;
|
zval **arg, **type;
|
||||||
XMLRPC_VALUE_TYPE vtype;
|
XMLRPC_VALUE_TYPE vtype;
|
||||||
|
|
||||||
if (!(ARG_COUNT(ht) == 2) || getParameters(ht, ARG_COUNT(ht), &arg, &type) == FAILURE) {
|
if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &arg, &type) == FAILURE)) {
|
||||||
WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
|
WRONG_PARAM_COUNT;
|
||||||
}
|
}
|
||||||
#if ZEND_MODULE_API_NO < 20010901
|
|
||||||
if (!ParameterPassedByReference(ht,1)) {
|
|
||||||
zend_error(E_WARNING,"first argument to xmlrpc_set_type() passed by value, expecting reference");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
convert_to_string(type);
|
convert_to_string_ex(type);
|
||||||
vtype = xmlrpc_str_as_type(Z_STRVAL_P(type));
|
vtype = xmlrpc_str_as_type(Z_STRVAL_PP(type));
|
||||||
if (vtype != xmlrpc_none) {
|
if (vtype != xmlrpc_none) {
|
||||||
if (set_zval_xmlrpc_type(arg, vtype) == SUCCESS) {
|
if (set_zval_xmlrpc_type(*arg, vtype) == SUCCESS) {
|
||||||
RETURN_TRUE;
|
RETURN_TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
zend_error(E_WARNING,"invalid type '%s' passed to xmlrpc_set_type()", Z_STRVAL_P(type));
|
zend_error(E_WARNING,"invalid type '%s' passed to xmlrpc_set_type()", Z_STRVAL_PP(type));
|
||||||
}
|
}
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* {{{ proto string xmlrpc_get_type(mixed value)
|
/* {{{ proto string xmlrpc_get_type(mixed value)
|
||||||
Gets xmlrpc type for a PHP value. Especially useful for base64 and datetime strings */
|
Gets xmlrpc type for a PHP value. Especially useful for base64 and datetime strings */
|
||||||
PHP_FUNCTION(xmlrpc_get_type)
|
PHP_FUNCTION(xmlrpc_get_type)
|
||||||
{
|
{
|
||||||
zval* arg;
|
zval **arg;
|
||||||
XMLRPC_VALUE_TYPE type;
|
XMLRPC_VALUE_TYPE type;
|
||||||
XMLRPC_VECTOR_TYPE vtype = xmlrpc_vector_none;
|
XMLRPC_VECTOR_TYPE vtype = xmlrpc_vector_none;
|
||||||
|
|
||||||
if (!(ARG_COUNT(ht) == 1) || getParameters(ht, ARG_COUNT(ht), &arg) == FAILURE) {
|
if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &arg) == FAILURE)) {
|
||||||
WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
|
WRONG_PARAM_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
type = get_zval_xmlrpc_type(arg, 0);
|
type = get_zval_xmlrpc_type(*arg, 0);
|
||||||
if (type == xmlrpc_vector) {
|
if (type == xmlrpc_vector) {
|
||||||
vtype = determine_vector_type(Z_ARRVAL_P(arg));
|
vtype = determine_vector_type(Z_ARRVAL_PP(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_STRING((char*) xmlrpc_type_as_str(type, vtype), 1);
|
RETURN_STRING((char*) xmlrpc_type_as_str(type, vtype), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* {{{ proto string xmlrpc_is_fault(array)
|
/* {{{ proto string xmlrpc_is_fault(array)
|
||||||
Determines if an array value represents an XMLRPC fault. */
|
Determines if an array value represents an XMLRPC fault. */
|
||||||
PHP_FUNCTION(xmlrpc_is_fault)
|
PHP_FUNCTION(xmlrpc_is_fault)
|
||||||
{
|
{
|
||||||
zval* arg, **val;
|
zval **arg, **val;
|
||||||
|
|
||||||
if (!(ARG_COUNT(ht) == 1) || getParameters(ht, ARG_COUNT(ht), &arg) == FAILURE) {
|
if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &arg) == FAILURE)) {
|
||||||
WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
|
WRONG_PARAM_COUNT;
|
||||||
}
|
|
||||||
|
|
||||||
if (Z_TYPE_P(arg) != IS_ARRAY) {
|
|
||||||
php_error(E_NOTICE, "%s(): Array argument expected", get_active_function_name(TSRMLS_C));
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
/* The "correct" way to do this would be to call the xmlrpc
|
|
||||||
* library XMLRPC_ValueIsFault() func. However, doing that
|
|
||||||
* would require us to create an xmlrpc value from the php
|
|
||||||
* array, which is rather expensive, especially if it was
|
|
||||||
* a big array. Thus, we resort to this not so clever hackery.
|
|
||||||
*/
|
|
||||||
if( zend_hash_find(Z_ARRVAL_P(arg), FAULT_CODE, FAULT_CODE_LEN + 1, (void**) &val) == SUCCESS &&
|
|
||||||
zend_hash_find(Z_ARRVAL_P(arg), FAULT_STRING, FAULT_STRING_LEN + 1, (void**) &val) == SUCCESS)
|
|
||||||
{
|
|
||||||
RETURN_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RETURN_FALSE;
|
if (Z_TYPE_PP(arg) != IS_ARRAY) {
|
||||||
|
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array argument expected");
|
||||||
|
} else {
|
||||||
|
/* The "correct" way to do this would be to call the xmlrpc
|
||||||
|
* library XMLRPC_ValueIsFault() func. However, doing that
|
||||||
|
* would require us to create an xmlrpc value from the php
|
||||||
|
* array, which is rather expensive, especially if it was
|
||||||
|
* a big array. Thus, we resort to this not so clever hackery.
|
||||||
|
*/
|
||||||
|
if (zend_hash_find(Z_ARRVAL_PP(arg), FAULT_CODE, FAULT_CODE_LEN + 1, (void**) &val) == SUCCESS &&
|
||||||
|
zend_hash_find(Z_ARRVAL_PP(arg), FAULT_STRING, FAULT_STRING_LEN + 1, (void**) &val) == SUCCESS) {
|
||||||
|
RETURN_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue