felipe          Sun Aug 24 00:45:20 2008 UTC

  Modified files:              
    /php-src/ext/xmlrpc xmlrpc-epi-php.c 
  Log:
  - MFB: New parameter parsing API
  - WS, Cosmetics
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/xmlrpc/xmlrpc-epi-php.c?r1=1.60&r2=1.61&diff_format=u
Index: php-src/ext/xmlrpc/xmlrpc-epi-php.c
diff -u php-src/ext/xmlrpc/xmlrpc-epi-php.c:1.60 
php-src/ext/xmlrpc/xmlrpc-epi-php.c:1.61
--- php-src/ext/xmlrpc/xmlrpc-epi-php.c:1.60    Fri Aug 15 22:13:58 2008
+++ php-src/ext/xmlrpc/xmlrpc-epi-php.c Sun Aug 24 00:45:20 2008
@@ -51,7 +51,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: xmlrpc-epi-php.c,v 1.60 2008/08/15 22:13:58 felipe Exp $ */
+/* $Id: xmlrpc-epi-php.c,v 1.61 2008/08/24 00:45:20 felipe Exp $ */
 
 /**********************************************************************
 * BUGS:                                                               *
@@ -265,7 +265,7 @@
 XMLRPC_VALUE_TYPE get_zval_xmlrpc_type(zval* value, zval** newvalue);
 static void php_xmlrpc_introspection_callback(XMLRPC_SERVER server, void* 
data);
 int sset_zval_xmlrpc_type(zval* value, XMLRPC_VALUE_TYPE type);
-zval* decode_request_worker(zval* xml_in, zval* encoding_in, zval* 
method_name_out);
+zval* decode_request_worker(char *xml_in, int xml_in_len, char *encoding_in, 
zval* method_name_out);
 const char* xmlrpc_type_as_str(XMLRPC_VALUE_TYPE type, XMLRPC_VECTOR_TYPE 
vtype);
 XMLRPC_VALUE_TYPE xmlrpc_str_as_type(const char* str);
 XMLRPC_VECTOR_TYPE xmlrpc_str_as_vector_type(const char* str);
@@ -437,29 +437,29 @@
                        }
 
                        /* encoding code set */
-                       if(zend_hash_find(Z_ARRVAL_P(output_opts), 
ENCODING_KEY, ENCODING_KEY_LEN + 1, (void**)&val) == SUCCESS) {
-                               if(Z_TYPE_PP(val) == IS_STRING) {
+                       if (zend_hash_find(Z_ARRVAL_P(output_opts), 
ENCODING_KEY, ENCODING_KEY_LEN + 1, (void**)&val) == SUCCESS) {
+                               if (Z_TYPE_PP(val) == IS_STRING) {
                                        
options->xmlrpc_out.xml_elem_opts.encoding = estrdup(Z_STRVAL_PP(val));
                                }
                        }
 
                        /* escaping options */
-                       if(zend_hash_find(Z_ARRVAL_P(output_opts), 
ESCAPING_KEY, ESCAPING_KEY_LEN + 1, (void**)&val) == SUCCESS) {
+                       if (zend_hash_find(Z_ARRVAL_P(output_opts), 
ESCAPING_KEY, ESCAPING_KEY_LEN + 1, (void**)&val) == SUCCESS) {
                                /* multiple values allowed.  check if array */
-                               if(Z_TYPE_PP(val) == IS_ARRAY) {
+                               if (Z_TYPE_PP(val) == IS_ARRAY) {
                                        zval** iter_val;
                                        
zend_hash_internal_pointer_reset(Z_ARRVAL_PP(val));
                                        
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_no_escaping;
-                                       while(1) {
-                                               
if(zend_hash_get_current_data(Z_ARRVAL_PP(val), (void**)&iter_val) == SUCCESS) {
-                                                       if(Z_TYPE_PP(iter_val) 
== IS_STRING && Z_STRVAL_PP(iter_val)) {
-                                                               
if(!strcmp(Z_STRVAL_PP(iter_val), ESCAPING_VALUE_CDATA)) {
+                                       while (1) {
+                                               if 
(zend_hash_get_current_data(Z_ARRVAL_PP(val), (void**)&iter_val) == SUCCESS) {
+                                                       if (Z_TYPE_PP(iter_val) 
== IS_STRING && Z_STRVAL_PP(iter_val)) {
+                                                               if 
(!strcmp(Z_STRVAL_PP(iter_val), ESCAPING_VALUE_CDATA)) {
                                                                        
options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_cdata_escaping;
-                                                               } else 
if(!strcmp(Z_STRVAL_PP(iter_val), ESCAPING_VALUE_NON_ASCII)) {
+                                                               } else if 
(!strcmp(Z_STRVAL_PP(iter_val), ESCAPING_VALUE_NON_ASCII)) {
                                                                        
options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_non_ascii_escaping;
-                                                               } else 
if(!strcmp(Z_STRVAL_PP(iter_val), ESCAPING_VALUE_NON_PRINT)) {
+                                                               } else if 
(!strcmp(Z_STRVAL_PP(iter_val), ESCAPING_VALUE_NON_PRINT)) {
                                                                        
options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_non_print_escaping;
-                                                               } else 
if(!strcmp(Z_STRVAL_PP(iter_val), ESCAPING_VALUE_MARKUP)) {
+                                                               } else if 
(!strcmp(Z_STRVAL_PP(iter_val), ESCAPING_VALUE_MARKUP)) {
                                                                        
options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_markup_escaping;
                                                                }
                                                        }
@@ -471,14 +471,14 @@
                                        }
                                }
                                /* else, check for single value */
-                               else if(Z_TYPE_PP(val) == IS_STRING) {
-                                       if(!strcmp(Z_STRVAL_PP(val), 
ESCAPING_VALUE_CDATA)) {
+                               else if (Z_TYPE_PP(val) == IS_STRING) {
+                                       if (!strcmp(Z_STRVAL_PP(val), 
ESCAPING_VALUE_CDATA)) {
                                                
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_cdata_escaping;
-                                       } else if(!strcmp(Z_STRVAL_PP(val), 
ESCAPING_VALUE_NON_ASCII)) {
+                                       } else if (!strcmp(Z_STRVAL_PP(val), 
ESCAPING_VALUE_NON_ASCII)) {
                                                
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_non_ascii_escaping;
-                                       } else if(!strcmp(Z_STRVAL_PP(val), 
ESCAPING_VALUE_NON_PRINT)) {
+                                       } else if (!strcmp(Z_STRVAL_PP(val), 
ESCAPING_VALUE_NON_PRINT)) {
                                                
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_non_print_escaping;
-                                       } else if(!strcmp(Z_STRVAL_PP(val), 
ESCAPING_VALUE_MARKUP)) {
+                                       } else if (!strcmp(Z_STRVAL_PP(val), 
ESCAPING_VALUE_MARKUP)) {
                                                
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_markup_escaping;
                                        }
                                }
@@ -505,18 +505,18 @@
        char* my_key;
 
        zend_hash_internal_pointer_reset(ht);
-       while(1) {
+       while (1) {
                int res = my_zend_hash_get_current_key(ht, &my_key, &num_index);
-               if(res == HASH_KEY_IS_LONG) {
-                       if(bStruct) {
+               if (res == HASH_KEY_IS_LONG) {
+                       if (bStruct) {
                                bMixed = 1;
                                break;
                        }
                        bArray = 1;
-               } else if(res == HASH_KEY_NON_EXISTANT) {
+               } else if (res == HASH_KEY_NON_EXISTANT) {
                        break;
-               } else if(res == HASH_KEY_IS_STRING) {
-                       if(bArray) {
+               } else if (res == HASH_KEY_IS_STRING || res == 
HASH_KEY_IS_UNICODE) {
+                       if (bArray) {
                                bMixed = 1;
                                break;
                        }
@@ -533,13 +533,13 @@
 static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int 
depth TSRMLS_DC) /* {{{ */
 {
        XMLRPC_VALUE xReturn = NULL;
-       if(in_val) {
+       if (in_val) {
                zval* val = NULL;
                XMLRPC_VALUE_TYPE type = get_zval_xmlrpc_type(in_val, &val);
-               if(val) {
-                       switch(type) {
+               if (val) {
+                       switch (type) {
                                case xmlrpc_base64:
-                                       if(Z_TYPE_P(val) == IS_NULL) {
+                                       if (Z_TYPE_P(val) == IS_NULL) {
                                                xReturn = 
XMLRPC_CreateValueEmpty();
                                                XMLRPC_SetValueID(xReturn, key, 
0);
                                        } else {
@@ -583,7 +583,7 @@
                                                xReturn = 
XMLRPC_CreateVector(key, determine_vector_type(Z_ARRVAL_P(val)));
 
                                                
zend_hash_internal_pointer_reset(Z_ARRVAL_P(val));
-                                               
while(zend_hash_get_current_data(Z_ARRVAL_P(val), (void**)&pIter) == SUCCESS) {
+                                               while 
(zend_hash_get_current_data(Z_ARRVAL_P(val), (void**)&pIter) == SUCCESS) {
                                                        int res = 
my_zend_hash_get_current_key(Z_ARRVAL_P(val), &my_key, &num_index);
 
                                                        switch (res) {
@@ -629,7 +629,7 @@
        zval* elem = NULL;
        const char* pStr;
 
-       if(el) {
+       if (el) {
                XMLRPC_VALUE_TYPE type = XMLRPC_GetValueType(el);
 
                MAKE_STD_ZVAL(elem); /* init. very important.  spent a 
frustrating day finding this out. */
@@ -640,7 +640,7 @@
                                break;
                        case xmlrpc_string:
                                pStr = XMLRPC_GetValueString(el);
-                               if(pStr) {
+                               if (pStr) {
                                        Z_STRLEN_P(elem) = 
XMLRPC_GetValueStringLen(el);
                                        Z_STRVAL_P(elem) = estrndup(pStr, 
Z_STRLEN_P(elem));
                                        Z_TYPE_P(elem) = IS_STRING;
@@ -665,7 +665,7 @@
                                break;
                        case xmlrpc_base64:
                                pStr = XMLRPC_GetValueBase64(el);
-                               if(pStr) {
+                               if (pStr) {
                                        Z_STRLEN_P(elem) = 
XMLRPC_GetValueStringLen(el);
                                        Z_STRVAL_P(elem) = estrndup(pStr, 
Z_STRLEN_P(elem));
                                        Z_TYPE_P(elem) = IS_STRING;
@@ -676,7 +676,7 @@
                                {
                                        XMLRPC_VALUE xIter = 
XMLRPC_VectorRewind(el);
 
-                                       while( xIter ) {
+                                       while (xIter) {
                                                zval *val = 
XMLRPC_to_PHP(xIter);
                                                if (val) {
                                                        add_zval(elem, 
XMLRPC_GetValueID(xIter), &val);
@@ -699,20 +699,20 @@
 PHP_FUNCTION(xmlrpc_encode_request)
 {
        XMLRPC_REQUEST xRequest = NULL;
-       zval **method, **vals, **out_opts;
-       char* outBuf;
+       char *outBuf;
+       zval **method, **vals, *out_opts;
        php_output_options out;
 
-       if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > 3 || 
(zend_get_parameters_ex(ZEND_NUM_ARGS(), &method, &vals, &out_opts) == 
FAILURE)) {
-               WRONG_PARAM_COUNT; /* prints/logs a warning and returns */
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ|a", &method, 
&vals, &out_opts) == FAILURE) {
+               return;
        }
 
-       set_output_options(&out, (ZEND_NUM_ARGS() == 3) ? *out_opts : 0);
+       set_output_options(&out, (ZEND_NUM_ARGS() == 3) ? out_opts : 0);
 
-       if(return_value_used) {
+       if (return_value_used) {
                xRequest = XMLRPC_RequestNew();
 
-               if(xRequest) {
+               if (xRequest) {
                        XMLRPC_RequestSetOutputOptions(xRequest, 
&out.xmlrpc_out);
                        if (Z_TYPE_PP(method) == IS_NULL) {
                                XMLRPC_RequestSetRequestType(xRequest, 
xmlrpc_request_response);
@@ -726,7 +726,7 @@
                        }
 
                        outBuf = XMLRPC_REQUEST_ToXML(xRequest, 0);
-                       if(outBuf) {
+                       if (outBuf) {
                                RETVAL_STRING(outBuf, 1);
                                free(outBuf);
                        }
@@ -748,19 +748,19 @@
        zval **arg1;
        char *outBuf;
 
-       if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &arg1) == 
FAILURE)) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg1) == 
FAILURE) {
+               return;
        }
 
-       if( return_value_used ) {
+       if (return_value_used) {
                /* convert native php type to xmlrpc type */
                xOut = PHP_to_XMLRPC(*arg1 TSRMLS_CC);
 
                /* generate raw xml from xmlrpc data */
                outBuf = XMLRPC_VALUE_ToXML(xOut, 0);
 
-               if(xOut) {
-                       if(outBuf) {
+               if (xOut) {
+                       if (outBuf) {
                                RETVAL_STRING(outBuf, 1);
                                free(outBuf);
                        }
@@ -771,21 +771,21 @@
 }
 /* }}} */
 
-zval* decode_request_worker (zval* xml_in, zval* encoding_in, zval* 
method_name_out) /* {{{ */
+zval* decode_request_worker(char *xml_in, int xml_in_len, char *encoding_in, 
zval* method_name_out) /* {{{ */
 {
        zval* retval = NULL;
        XMLRPC_REQUEST response;
        STRUCT_XMLRPC_REQUEST_INPUT_OPTIONS opts = {{0}};
-       opts.xml_elem_opts.encoding = encoding_in ? 
utf8_get_encoding_id_from_string(Z_STRVAL_P(encoding_in)) : ENCODING_DEFAULT;
+       opts.xml_elem_opts.encoding = encoding_in ? 
utf8_get_encoding_id_from_string(encoding_in) : ENCODING_DEFAULT;
 
        /* generate XMLRPC_REQUEST from raw xml */
-       response = XMLRPC_REQUEST_FromXML(Z_STRVAL_P(xml_in), 
Z_STRLEN_P(xml_in), &opts);
-       if(response) {
+       response = XMLRPC_REQUEST_FromXML(xml_in, xml_in_len, &opts);
+       if (response) {
                /* convert xmlrpc data to native php types */
                retval = XMLRPC_to_PHP(XMLRPC_RequestGetData(response));
 
-               if(XMLRPC_RequestGetRequestType(response) == 
xmlrpc_request_call) {
-                       if(method_name_out) {
+               if (XMLRPC_RequestGetRequestType(response) == 
xmlrpc_request_call) {
+                       if (method_name_out) {
                                zval_dtor(method_name_out);
                                Z_TYPE_P(method_name_out) = IS_STRING;
                                Z_STRVAL_P(method_name_out) = 
estrdup(XMLRPC_RequestGetMethodName(response));
@@ -804,22 +804,19 @@
    Decodes XML into native PHP types */
 PHP_FUNCTION(xmlrpc_decode_request)
 {
-       zval **xml, **method, **encoding = NULL;
-       int argc = ZEND_NUM_ARGS();
+       char *xml, *encoding = NULL;
+       zval **method;
+       int xml_len, encoding_len = 0;
 
-       if (argc < 2 || argc > 3 || (zend_get_parameters_ex(argc, &xml, 
&method, &encoding) == FAILURE)) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sZ|s", &xml, 
&xml_len, &method, &encoding, &encoding_len) == FAILURE) {
+               return;
        }
 
-       convert_to_string_ex(xml);
        convert_to_string_ex(method);
-       if(argc == 3) {
-               convert_to_string_ex(encoding);
-       }
 
-       if(return_value_used) {
-               zval* retval = decode_request_worker(*xml, encoding ? *encoding 
: NULL, *method);
-               if(retval) {
+       if (return_value_used) {
+               zval* retval = decode_request_worker(xml, xml_len, encoding_len 
? encoding : NULL, *method);
+               if (retval) {
                        *return_value = *retval;
                        FREE_ZVAL(retval);
                }
@@ -831,21 +828,16 @@
    Decodes XML into native PHP types */
 PHP_FUNCTION(xmlrpc_decode)
 {
-       zval **arg1, **arg2 = NULL;
-       int argc = ZEND_NUM_ARGS();
-
-       if (argc < 1 || argc > 2 || (zend_get_parameters_ex(argc, &arg1, &arg2) 
== FAILURE)) {
-               WRONG_PARAM_COUNT;
-       }
+       char *arg1, *arg2 = NULL;
+       int arg1_len, arg2_len = 0;
 
-       convert_to_string_ex(arg1);
-       if(argc == 2) {
-               convert_to_string_ex(arg2);
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &arg1, 
&arg1_len, &arg2, &arg2_len) == FAILURE) {
+               return;
        }
 
-       if(return_value_used) {
-               zval* retval = decode_request_worker(*arg1, arg2 ? *arg2 : 
NULL, NULL);
-               if(retval) {
+       if (return_value_used) {
+               zval* retval = decode_request_worker(arg1, arg1_len, arg2_len ? 
arg2 : NULL, NULL);
+               if (retval) {
                        *return_value = *retval;
                        FREE_ZVAL(retval);
                }
@@ -854,8 +846,8 @@
 /* }}} */
 
 /*************************
- * server related methods *
- *************************/
+* server related methods *
+*************************/
 
 /* {{{ proto resource xmlrpc_server_create(void)
    Creates an xmlrpc server */
@@ -865,7 +857,7 @@
                return;
        }
 
-       if(return_value_used) {
+       if (return_value_used) {
                zval *method_map, *introspection_map;
                xmlrpc_server_data *server = 
emalloc(sizeof(xmlrpc_server_data));
                MAKE_STD_ZVAL(method_map);
@@ -891,25 +883,22 @@
    Destroys server resources */
 PHP_FUNCTION(xmlrpc_server_destroy)
 {
-       zval **arg1;
-       int bSuccess = FAILURE;
+       zval *arg1;
+       int bSuccess = FAILURE, type;
+       xmlrpc_server_data *server;
 
-       if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &arg1) == 
FAILURE)) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == 
FAILURE) {
+               return;
        }
 
-       if(Z_TYPE_PP(arg1) == IS_RESOURCE) {
-               int type;
+       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) {
+               bSuccess = zend_list_delete(Z_LVAL_P(arg1));
 
-               if(server && type == le_xmlrpc_server) {
-                       bSuccess = zend_list_delete(Z_LVAL_PP(arg1));
-
-                       /* called by hashtable destructor
-                        * destroy_server_data(server);
-                        */
-               }
+               /* called by hashtable destructor
+                * destroy_server_data(server);
+                */
        }
        RETVAL_LONG(bSuccess == SUCCESS);
 }
@@ -952,7 +941,7 @@
 static void php_xmlrpc_introspection_callback(XMLRPC_SERVER server, void* 
data) /* {{{ */
 {
        zval retval, **php_function;
-       zval* callback_params[1];
+       zval *callback_params[1];
        zval php_function_name;
        xmlrpc_callback_data* pData = (xmlrpc_callback_data*)data;
        TSRMLS_FETCH();
@@ -962,8 +951,8 @@
 
        /* loop through and call all registered callbacks */
        
zend_hash_internal_pointer_reset(Z_ARRVAL_P(pData->server->introspection_map));
-       while(1) {
-               
if(zend_hash_get_current_data(Z_ARRVAL_P(pData->server->introspection_map), 
(void**)&php_function) == SUCCESS) {
+       while (1) {
+               if 
(zend_hash_get_current_data(Z_ARRVAL_P(pData->server->introspection_map), 
(void**)&php_function) == SUCCESS) {
                        if (zend_is_callable(*php_function, 0, 
&php_function_name TSRMLS_CC)) {
                                /* php func prototype: function string 
user_func($user_params) */
                                if (call_user_function(CG(function_table), 
NULL, *php_function, &retval, 1, callback_params TSRMLS_CC) == SUCCESS) {
@@ -975,16 +964,16 @@
 
                                        xData = 
XMLRPC_IntrospectionCreateDescription(Z_STRVAL(retval), &err);
 
-                                       if(xData) {
-                                               
if(!XMLRPC_ServerAddIntrospectionData(server, xData)) {
+                                       if (xData) {
+                                               if 
(!XMLRPC_ServerAddIntrospectionData(server, xData)) {
                                                        php_error_docref(NULL 
TSRMLS_CC, E_WARNING, "Unable to add introspection data returned from %v(), 
improper element structure", Z_UNIVAL(php_function_name));
                                                }
                                                XMLRPC_CleanupValue(xData);
                                        } else {
                                                /* 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 %ld, column %ld, message: %s] 
Unable to add introspection data returned from %v()", 
-                                                                       
err.xml_elem_error.column, err.xml_elem_error.line, 
err.xml_elem_error.parser_error, Z_UNIVAL(php_function_name));
+                                                               
err.xml_elem_error.column, err.xml_elem_error.line, 
err.xml_elem_error.parser_error, Z_UNIVAL(php_function_name));
                                                } else {
                                                        php_error_docref(NULL 
TSRMLS_CC, E_WARNING, "Unable to add introspection data returned from %v()", 
Z_UNIVAL(php_function_name));
                                                }
@@ -1001,7 +990,6 @@
                } else {
                        break;
                }
-
                
zend_hash_move_forward(Z_ARRVAL_P(pData->server->introspection_map));
        }
 
@@ -1014,28 +1002,30 @@
    Register a PHP function to handle method matching method_name */
 PHP_FUNCTION(xmlrpc_server_register_method)
 {
-       zval **method_key, **method_name, **handle, *method_name_save;
+       char *method_key;
+       int method_key_len;
+       zval *handle, *method_name_save, **method_name;
        int type;
        xmlrpc_server_data* server;
 
-       if (ZEND_NUM_ARGS() != 3 || (zend_get_parameters_ex(3, &handle, 
&method_key, &method_name) == FAILURE)) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsZ", &handle, 
&method_key, &method_key_len, &method_name) == FAILURE) {
+               return;
        }
 
-       server = zend_list_find(Z_LVAL_PP(handle), &type);
+       server = zend_list_find(Z_LVAL_P(handle), &type);
 
-       if(type == le_xmlrpc_server) {
+       if (type == le_xmlrpc_server) {
                /* register with C engine. every method just calls our standard 
callback, 
                 * and it then dispatches to php as necessary
                 */
-               if(XMLRPC_ServerRegisterMethod(server->server_ptr, 
Z_STRVAL_PP(method_key), php_xmlrpc_callback)) {
+               if (XMLRPC_ServerRegisterMethod(server->server_ptr, method_key, 
php_xmlrpc_callback)) {
                        /* save for later use */
                        MAKE_STD_ZVAL(method_name_save);
                        *method_name_save = **method_name;
                        zval_copy_ctor(method_name_save);
 
                        /* register our php method */
-                       add_zval(server->method_map, Z_STRVAL_PP(method_key), 
&method_name_save);
+                       add_zval(server->method_map, method_key, 
&method_name_save);
 
                        RETURN_BOOL(1);
                }
@@ -1048,17 +1038,17 @@
    Register a PHP function to generate documentation */
 PHP_FUNCTION(xmlrpc_server_register_introspection_callback)
 {
-       zval **method_name, **handle, *method_name_save;
+       zval **method_name, *handle, *method_name_save;
        int type;
        xmlrpc_server_data* server;
 
-       if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &handle, 
&method_name) == FAILURE)) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rZ", &handle, 
&method_name) == FAILURE) {
+               return;
        }
 
-       server = zend_list_find(Z_LVAL_PP(handle), &type);
+       server = zend_list_find(Z_LVAL_P(handle), &type);
 
-       if(type == le_xmlrpc_server) {
+       if (type == le_xmlrpc_server) {
                /* save for later use */
                MAKE_STD_ZVAL(method_name_save);
                *method_name_save = **method_name;
@@ -1074,6 +1064,7 @@
 /* }}} */
 
 /* this function is itchin for a re-write */
+
 /* {{{ proto mixed xmlrpc_server_call_method(resource server, string xml, 
mixed user_data [, array output_options])
    Parses XML requests and call methods */
 PHP_FUNCTION(xmlrpc_server_call_method)
@@ -1082,13 +1073,14 @@
        XMLRPC_REQUEST xRequest;
        STRUCT_XMLRPC_REQUEST_INPUT_OPTIONS input_opts;
        xmlrpc_server_data* server;
-       zval **rawxml, **caller_params, **handle, **output_opts = NULL;
-       int type;
+       zval **caller_params, *handle, **output_opts = NULL;
+       char *rawxml;
+       int rawxml_len, type;
        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;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsZ|Z", &handle, 
&rawxml, &rawxml_len, &caller_params, &output_opts) != SUCCESS) {
+               return;
        }
        /* user output options */
        if (argc == 3) {
@@ -1097,16 +1089,16 @@
                set_output_options(&out, *output_opts);
        }
 
-       server = zend_list_find(Z_LVAL_PP(handle), &type);
+       server = zend_list_find(Z_LVAL_P(handle), &type);
 
-       if(type == le_xmlrpc_server) {
+       if (type == le_xmlrpc_server) {
                /* 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);
 
                /* generate an XMLRPC_REQUEST from the raw xml input */
-               xRequest = XMLRPC_REQUEST_FromXML(Z_STRVAL_PP(rawxml), 
Z_STRLEN_PP(rawxml), &input_opts);
+               xRequest = XMLRPC_REQUEST_FromXML(rawxml, rawxml_len, 
&input_opts);
 
-               if(xRequest) {
+               if (xRequest) {
                        const char* methodname = 
XMLRPC_RequestGetMethodName(xRequest);
                        zval **php_function;
                        XMLRPC_VALUE xAnswer = NULL;
@@ -1128,10 +1120,10 @@
                        data.server = server;
 
                        /* check if the called method has been previous 
registered */
-                       if(zend_hash_find(Z_ARRVAL_P(server->method_map),
-                                               Z_STRVAL_P(data.xmlrpc_method), 
-                                               Z_STRLEN_P(data.xmlrpc_method) 
+ 1, 
-                                               (void**)&php_function) == 
SUCCESS) {
+                       if (zend_hash_find(Z_ARRVAL_P(server->method_map),
+                                                               
Z_STRVAL_P(data.xmlrpc_method), 
+                                                               
Z_STRLEN_P(data.xmlrpc_method) + 1, 
+                                                               
(void**)&php_function) == SUCCESS) {
 
                                data.php_function = *php_function;
                        }
@@ -1141,18 +1133,18 @@
                         * or somesuch.
                         */
                        xAnswer = XMLRPC_ServerCallMethod(server->server_ptr, 
xRequest, &data);
-                       if(xAnswer && out.b_php_out) {
+                       if (xAnswer && out.b_php_out) {
                                zval_dtor(data.return_data);
                                FREE_ZVAL(data.return_data);
                                data.return_data = XMLRPC_to_PHP(xAnswer);
-                       } else if(data.php_executed && !out.b_php_out) {
+                       } else if (data.php_executed && !out.b_php_out) {
                                xAnswer = PHP_to_XMLRPC(data.return_data 
TSRMLS_CC);
                        }
 
                        /* should we return data as xml? */
-                       if(!out.b_php_out) {
+                       if (!out.b_php_out) {
                                XMLRPC_REQUEST xResponse = XMLRPC_RequestNew();
-                               if(xResponse) {
+                               if (xResponse) {
                                        char *outBuf = 0;
                                        int buf_len = 0;
 
@@ -1171,7 +1163,7 @@
 
                                        /* generate xml */
                                        outBuf = 
XMLRPC_REQUEST_ToXML(xResponse, &buf_len);
-                                       if(outBuf) {
+                                       if (outBuf) {
                                                RETVAL_STRINGL(outBuf, buf_len, 
1);
                                                free(outBuf);
                                        }
@@ -1189,7 +1181,7 @@
                        zval_dtor(data.return_data);
                        FREE_ZVAL(data.return_data);
 
-                       if(xAnswer) {
+                       if (xAnswer) {
                                XMLRPC_CleanupValue(xAnswer);
                        }
 
@@ -1203,18 +1195,18 @@
    Adds introspection documentation  */
 PHP_FUNCTION(xmlrpc_server_add_introspection_data)
 {
-       zval **handle, **desc;
+       zval *handle, *desc;
        int type;
        xmlrpc_server_data* server;
 
-       if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &handle, &desc) 
== FAILURE)) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra", &handle, 
&desc) == FAILURE) {
+               return;
        }
 
-       server = zend_list_find(Z_LVAL_PP(handle), &type);
+       server = zend_list_find(Z_LVAL_P(handle), &type);
 
        if (type == le_xmlrpc_server) {
-               XMLRPC_VALUE xDesc = PHP_to_XMLRPC(*desc TSRMLS_CC);
+               XMLRPC_VALUE xDesc = PHP_to_XMLRPC(desc TSRMLS_CC);
                if (xDesc) {
                        int retval = 
XMLRPC_ServerAddIntrospectionData(server->server_ptr, xDesc);
                        XMLRPC_CleanupValue(xDesc);
@@ -1229,21 +1221,21 @@
    Decodes XML into a list of method descriptions */
 PHP_FUNCTION(xmlrpc_parse_method_descriptions)
 {
-       zval **arg1, *retval;
+       zval *retval;
+       char *arg1;
+       int arg1_len;
 
-       if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &arg1) == 
FAILURE)) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg1, 
&arg1_len) == FAILURE) {
+               return;
        }
 
-       convert_to_string_ex(arg1);
-
-       if(return_value_used) {
+       if (return_value_used) {
                STRUCT_XMLRPC_ERROR err = {0};
-               XMLRPC_VALUE xVal = 
XMLRPC_IntrospectionCreateDescription(Z_STRVAL_PP(arg1), &err);
-               if(xVal) {
+               XMLRPC_VALUE xVal = XMLRPC_IntrospectionCreateDescription(arg1, 
&err);
+               if (xVal) {
                        retval = XMLRPC_to_PHP(xVal);
 
-                       if(retval) {
+                       if (retval) {
                                *return_value = *retval;
                                zval_copy_ctor(return_value);
                        }
@@ -1251,7 +1243,7 @@
                        XMLRPC_CleanupValue(xVal);
                } else {
                        /* 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 %ld, column %ld, message: %s] Unable to create 
introspection data", 
                                                err.xml_elem_error.column, 
err.xml_elem_error.line, err.xml_elem_error.parser_error);
                        } else {
@@ -1265,8 +1257,8 @@
 /* }}} */
 
 /************
- * type data *
- ************/
+* type data *
+************/
 
 #define XMLRPC_TYPE_COUNT 9
 #define XMLRPC_VECTOR_TYPE_COUNT 4
@@ -1368,11 +1360,11 @@
                        Z_STRVAL_P(type) = estrdup(typestr);
                        Z_STRLEN_P(type) = strlen(typestr);
 
-                       if(newtype == xmlrpc_datetime) {
+                       if (newtype == xmlrpc_datetime) {
                                XMLRPC_VALUE v = 
XMLRPC_CreateValueDateTime_ISO8601(NULL, value->value.str.val);
-                               if(v) {
+                               if (v) {
                                        time_t timestamp = 
XMLRPC_GetValueDateTime(v);
-                                       if(timestamp) {
+                                       if (timestamp) {
                                                zval* ztimestamp;
 
                                                MAKE_STD_ZVAL(ztimestamp);
@@ -1381,7 +1373,7 @@
                                                ztimestamp->value.lval = 
timestamp;
 
                                                convert_to_object(value);
-                                               if(SUCCESS == 
zend_hash_update(Z_OBJPROP_P(value), OBJECT_TYPE_ATTR, 
sizeof(OBJECT_TYPE_ATTR), (void *) &type, sizeof(zval *), NULL)) {
+                                               if (SUCCESS == 
zend_hash_update(Z_OBJPROP_P(value), OBJECT_TYPE_ATTR, 
sizeof(OBJECT_TYPE_ATTR), (void *) &type, sizeof(zval *), NULL)) {
                                                        bSuccess = 
zend_hash_update(Z_OBJPROP_P(value), OBJECT_VALUE_TS_ATTR, 
sizeof(OBJECT_VALUE_TS_ATTR), (void *) &ztimestamp, sizeof(zval *), NULL);
                                                }
                                        } else {
@@ -1391,8 +1383,7 @@
                                } else {
                                        zval_ptr_dtor(&type);
                                }
-                       }
-                       else {
+                       } else {
                                convert_to_object(value);
                                bSuccess = zend_hash_update(Z_OBJPROP_P(value), 
OBJECT_TYPE_ATTR, sizeof(OBJECT_TYPE_ATTR), (void *) &type, sizeof(zval *), 
NULL);
                        }
@@ -1416,7 +1407,7 @@
                                break;
 #ifndef BOOL_AS_LONG
 
-                               /* Right thing to do, but it breaks some legacy 
code. */
+                       /* Right thing to do, but it breaks some legacy code. */
                        case IS_BOOL:
                                type = xmlrpc_boolean;
                                break;
@@ -1434,6 +1425,7 @@
                                type = xmlrpc_string;
                                break;
                        case IS_STRING:
+                       case IS_UNICODE:
                                type = xmlrpc_string;
                                break;
                        case IS_ARRAY:
@@ -1476,21 +1468,22 @@
    Sets xmlrpc type, base64 or datetime, for a PHP string value */
 PHP_FUNCTION(xmlrpc_set_type)
 {
-       zval **arg, **type;
+       zval **arg;
+       char *type;
+       int type_len;
        XMLRPC_VALUE_TYPE vtype;
 
-       if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &arg, &type) == 
FAILURE)) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zs", &arg, &type, 
&type_len) == FAILURE) {
+               return;
        }
 
-       convert_to_string_ex(type);
-       vtype = xmlrpc_str_as_type(Z_STRVAL_PP(type));
+       vtype = xmlrpc_str_as_type(type);
        if (vtype != xmlrpc_none) {
                if (set_zval_xmlrpc_type(*arg, vtype) == SUCCESS) {
                        RETURN_TRUE;
                }
        } else {
-               zend_error(E_WARNING,"invalid type '%s' passed to 
xmlrpc_set_type()", Z_STRVAL_PP(type));
+               zend_error(E_WARNING,"invalid type '%s' passed to 
xmlrpc_set_type()", type);
        }
        RETURN_FALSE;
 }
@@ -1504,8 +1497,8 @@
        XMLRPC_VALUE_TYPE type;
        XMLRPC_VECTOR_TYPE vtype = xmlrpc_vector_none;
 
-       if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &arg) == 
FAILURE)) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == 
FAILURE) {
+               return;
        }
 
        type = get_zval_xmlrpc_type(*arg, 0);
@@ -1521,25 +1514,21 @@
    Determines if an array value represents an XMLRPC fault. */
 PHP_FUNCTION(xmlrpc_is_fault)
 {
-       zval **arg, **val;
+       zval *arg, **val;
 
-       if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &arg) == 
FAILURE)) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &arg) == 
FAILURE) {
+               return;
        }
 
-       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;
-               }
+       /* 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;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to