Back to index

php5  5.3.10
Defines | Functions | Variables
php_xmlrpc.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define phpext_xmlrpc_ptr   &xmlrpc_module_entry

Functions

 PHP_MINIT_FUNCTION (xmlrpc)
 PHP_MINFO_FUNCTION (xmlrpc)
 PHP_FUNCTION (xmlrpc_encode)
 PHP_FUNCTION (xmlrpc_decode)
 PHP_FUNCTION (xmlrpc_decode_request)
 PHP_FUNCTION (xmlrpc_encode_request)
 PHP_FUNCTION (xmlrpc_get_type)
 PHP_FUNCTION (xmlrpc_set_type)
 PHP_FUNCTION (xmlrpc_is_fault)
 PHP_FUNCTION (xmlrpc_server_create)
 PHP_FUNCTION (xmlrpc_server_destroy)
 PHP_FUNCTION (xmlrpc_server_register_method)
 PHP_FUNCTION (xmlrpc_server_call_method)
 PHP_FUNCTION (xmlrpc_parse_method_descriptions)
 PHP_FUNCTION (xmlrpc_server_add_introspection_data)
 PHP_FUNCTION (xmlrpc_server_register_introspection_callback)

Variables

zend_module_entry xmlrpc_module_entry

Define Documentation

Definition at line 62 of file php_xmlrpc.h.


Function Documentation

PHP_FUNCTION ( xmlrpc_encode  )

Definition at line 748 of file xmlrpc-epi-php.c.

{
       XMLRPC_VALUE xOut = NULL;
       zval **arg1;
       char *outBuf;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg1) == FAILURE) {
              return;
       }

       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) {
                            RETVAL_STRING(outBuf, 1);
                            free(outBuf);
                     }
                     /* cleanup */
                     XMLRPC_CleanupValue(xOut);
              }
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( xmlrpc_decode  )

Definition at line 838 of file xmlrpc-epi-php.c.

{
       char *arg1, *arg2 = NULL;
       int arg1_len, arg2_len = 0;

       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, arg1_len, arg2_len ? arg2 : NULL, NULL);
              if (retval) {
                     *return_value = *retval;
                     FREE_ZVAL(retval);
              }
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( xmlrpc_decode_request  )

Definition at line 815 of file xmlrpc-epi-php.c.

{
       char *xml, *encoding = NULL;
       zval **method;
       int xml_len, encoding_len = 0;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sZ|s", &xml, &xml_len, &method, &encoding, &encoding_len) == FAILURE) {
              return;
       }


       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);
              }
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( xmlrpc_encode_request  )

Definition at line 701 of file xmlrpc-epi-php.c.

{
       XMLRPC_REQUEST xRequest = NULL;
       char *outBuf;
       zval *vals, *out_opts = NULL;
       char *method = NULL;
       int method_len;
       php_output_options out;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!z|a", &method, &method_len, &vals, &out_opts) == FAILURE) {
              return;
       }

       set_output_options(&out, out_opts ? out_opts : 0);

       if (return_value_used) {
              xRequest = XMLRPC_RequestNew();

              if (xRequest) {
                     XMLRPC_RequestSetOutputOptions(xRequest, &out.xmlrpc_out);
                     if (method == NULL) {
                            XMLRPC_RequestSetRequestType(xRequest, xmlrpc_request_response);
                     } else {
                            XMLRPC_RequestSetMethodName(xRequest, method);
                            XMLRPC_RequestSetRequestType(xRequest, xmlrpc_request_call);
                     }
                     if (Z_TYPE_P(vals) != IS_NULL) {
                            XMLRPC_RequestSetData(xRequest, PHP_to_XMLRPC(vals TSRMLS_CC));
                     }

                     outBuf = XMLRPC_REQUEST_ToXML(xRequest, 0);
                     if (outBuf) {
                            RETVAL_STRING(outBuf, 1);
                            free(outBuf);
                     }
                     XMLRPC_RequestFree(xRequest, 1);
              }
       }
       
       if (strcmp(out.xmlrpc_out.xml_elem_opts.encoding, ENCODING_DEFAULT) != 0) {
              efree((char *)out.xmlrpc_out.xml_elem_opts.encoding);
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( xmlrpc_get_type  )

Definition at line 1499 of file xmlrpc-epi-php.c.

{
       zval **arg;
       XMLRPC_VALUE_TYPE type;
       XMLRPC_VECTOR_TYPE vtype = xmlrpc_vector_none;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
              return;
       }

       type = get_zval_xmlrpc_type(*arg, 0);
       if (type == xmlrpc_vector) {
              vtype = determine_vector_type((Z_TYPE_PP(arg) == IS_OBJECT) ? Z_OBJPROP_PP(arg) : Z_ARRVAL_PP(arg));
       }
   
       RETURN_STRING((char*) xmlrpc_type_as_str(type, vtype), 1);
}

Here is the call graph for this function:

PHP_FUNCTION ( xmlrpc_set_type  )

Definition at line 1474 of file xmlrpc-epi-php.c.

{
       zval **arg;
       char *type;
       int type_len;
       XMLRPC_VALUE_TYPE vtype;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zs", &arg, &type, &type_len) == FAILURE) {
              return;
       }

       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()", type);
       }
       RETURN_FALSE;
}

Here is the call graph for this function:

PHP_FUNCTION ( xmlrpc_is_fault  )

Definition at line 1520 of file xmlrpc-epi-php.c.

{
       zval *arg, **val;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &arg) == FAILURE) {
              return;
       }

       /* 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;
}

Here is the call graph for this function:

PHP_FUNCTION ( xmlrpc_server_create  )

Definition at line 863 of file xmlrpc-epi-php.c.

{
       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }

       if (return_value_used) {
              zval *method_map, *introspection_map;
              xmlrpc_server_data *server = emalloc(sizeof(xmlrpc_server_data));
              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();

              XMLRPC_ServerRegisterIntrospectionCallback(server->server_ptr, php_xmlrpc_introspection_callback);

              /* store for later use */
              ZEND_REGISTER_RESOURCE(return_value,server, le_xmlrpc_server);
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( xmlrpc_server_destroy  )

Definition at line 893 of file xmlrpc-epi-php.c.

{
       zval *arg1;
       int bSuccess = FAILURE, type;
       xmlrpc_server_data *server;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) {
              return;
       }

       server = zend_list_find(Z_LVAL_P(arg1), &type);

       if (server && type == le_xmlrpc_server) {
              bSuccess = zend_list_delete(Z_LVAL_P(arg1));

              /* called by hashtable destructor
               * destroy_server_data(server);
               */
       }
       RETVAL_LONG(bSuccess == SUCCESS);
}

Here is the call graph for this function:

PHP_FUNCTION ( xmlrpc_server_register_method  )

Definition at line 1026 of file xmlrpc-epi-php.c.

{
       char *method_key;
       int method_key_len;
       zval *handle, *method_name_save, **method_name;
       int type;
       xmlrpc_server_data* server;

       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_P(handle), &type);

       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, 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, method_key, &method_name_save);

                     RETURN_BOOL(1);
              }
       }
       RETURN_BOOL(0);
}

Here is the call graph for this function:

PHP_FUNCTION ( xmlrpc_server_call_method  )

Definition at line 1093 of file xmlrpc-epi-php.c.

{
       xmlrpc_callback_data data = {0};
       XMLRPC_REQUEST xRequest;
       STRUCT_XMLRPC_REQUEST_INPUT_OPTIONS input_opts;
       xmlrpc_server_data* server;
       zval **caller_params, *handle, *output_opts = NULL;
       char *rawxml;
       int rawxml_len, type;
       php_output_options out;
       int argc =ZEND_NUM_ARGS();
       
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsZ|a", &handle, &rawxml, &rawxml_len, &caller_params, &output_opts) != SUCCESS) {
              return;
       }
       /* user output options */
       if (argc == 3) {
              set_output_options(&out, NULL);
       } else {
              set_output_options(&out, output_opts);
       }

       server = zend_list_find(Z_LVAL_P(handle), &type);

       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(rawxml, rawxml_len, &input_opts);

              if (xRequest) {
                     const char* methodname = XMLRPC_RequestGetMethodName(xRequest);
                     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;

                     /* setup some data to pass to the callback function */
                     data.caller_params = *caller_params;
                     data.php_executed = 0;
                     data.server = server;

                     /* 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,
                      * or somesuch.
                      */
                     xAnswer = XMLRPC_ServerCallMethod(server->server_ptr, xRequest, &data);
                     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 && !xAnswer) {
                            xAnswer = PHP_to_XMLRPC(data.return_data TSRMLS_CC);
                     }

                     /* should we return data as xml? */
                     if (!out.b_php_out) {
                            XMLRPC_REQUEST xResponse = XMLRPC_RequestNew();
                            if (xResponse) {
                                   char *outBuf = 0;
                                   int buf_len = 0;

                                   /* automagically determine output serialization type from request type */
                                   if (out.b_auto_version) { 
                                          XMLRPC_REQUEST_OUTPUT_OPTIONS opts = XMLRPC_RequestGetOutputOptions(xRequest);
                                          if (opts) {
                                                 out.xmlrpc_out.version = opts->version;
                                          }
                                   }
                                   /* set some required request hoojum */
                                   XMLRPC_RequestSetOutputOptions(xResponse, &out.xmlrpc_out);
                                   XMLRPC_RequestSetRequestType(xResponse, xmlrpc_request_response);
                                   XMLRPC_RequestSetData(xResponse, xAnswer);
                                   XMLRPC_RequestSetMethodName(xResponse, methodname);

                                   /* generate xml */
                                   outBuf = XMLRPC_REQUEST_ToXML(xResponse, &buf_len);
                                   if (outBuf) {
                                          RETVAL_STRINGL(outBuf, buf_len, 1);
                                          free(outBuf);
                                   }
                                   /* cleanup after ourselves.  what a sty! */
                                   XMLRPC_RequestFree(xResponse, 0);
                            }
                     } else { /* or as native php types? */
                            *return_value = *data.return_data;
                            zval_copy_ctor(return_value);
                     }

                     /* cleanup after ourselves.  what a sty! */
                     zval_ptr_dtor(&data.xmlrpc_method);

                     zval_dtor(data.return_data);
                     FREE_ZVAL(data.return_data);

                     if (xAnswer) {
                            XMLRPC_CleanupValue(xAnswer);
                     }

                     XMLRPC_RequestFree(xRequest, 1);
              }
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( xmlrpc_parse_method_descriptions  )

Definition at line 1228 of file xmlrpc-epi-php.c.

{
       zval *retval;
       char *arg1;
       int arg1_len;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg1, &arg1_len) == FAILURE) {
              return;
       }

       if (return_value_used) {
              STRUCT_XMLRPC_ERROR err = {0};
              XMLRPC_VALUE xVal = XMLRPC_IntrospectionCreateDescription(arg1, &err);
              if (xVal) {
                     retval = XMLRPC_to_PHP(xVal);

                     if (retval) {
                            *return_value = *retval;
                            zval_copy_ctor(return_value);
                     }
                     /* dust, sweep, and mop */
                     XMLRPC_CleanupValue(xVal);
              } else {
                     /* could not create description */
                     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 {
                            php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid xml structure. Unable to create introspection data");
                     }

                     php_error_docref(NULL TSRMLS_CC, E_WARNING, "xml parse error. no method description created");
              }
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( xmlrpc_server_add_introspection_data  )

Definition at line 1202 of file xmlrpc-epi-php.c.

{
       zval *handle, *desc;
       int type;
       xmlrpc_server_data* server;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra", &handle, &desc) == FAILURE) {
              return;
       }

       server = zend_list_find(Z_LVAL_P(handle), &type);

       if (type == le_xmlrpc_server) {
              XMLRPC_VALUE xDesc = PHP_to_XMLRPC(desc TSRMLS_CC);
              if (xDesc) {
                     int retval = XMLRPC_ServerAddIntrospectionData(server->server_ptr, xDesc);
                     XMLRPC_CleanupValue(xDesc);
                     RETURN_LONG(retval);
              }
       }
       RETURN_LONG(0);
}

Here is the call graph for this function:

PHP_FUNCTION ( xmlrpc_server_register_introspection_callback  )

Definition at line 1062 of file xmlrpc-epi-php.c.

{
       zval **method_name, *handle, *method_name_save;
       int type;
       xmlrpc_server_data* server;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rZ", &handle, &method_name) == FAILURE) {
              return;
       }

       server = zend_list_find(Z_LVAL_P(handle), &type);

       if (type == le_xmlrpc_server) {
              /* 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->introspection_map, NULL, &method_name_save);

              RETURN_BOOL(1);
       }
       RETURN_BOOL(0);
}

Here is the call graph for this function:

PHP_MINFO_FUNCTION ( xmlrpc  )

Definition at line 300 of file xmlrpc-epi-php.c.

{
       php_info_print_table_start();
       php_info_print_table_row(2, "core library version", XMLRPC_GetVersionString());
       php_info_print_table_row(2, "php extension version", PHP_EXT_VERSION);
       php_info_print_table_row(2, "author", "Dan Libby");
       php_info_print_table_row(2, "homepage", "http://xmlrpc-epi.sourceforge.net");
       php_info_print_table_row(2, "open sourced by", "Epinions.com");
       php_info_print_table_end();
}

Here is the call graph for this function:

PHP_MINIT_FUNCTION ( xmlrpc  )

Definition at line 292 of file xmlrpc-epi-php.c.

Here is the call graph for this function:


Variable Documentation

zend_module_entry xmlrpc_module_entry

Definition at line 164 of file xmlrpc-epi-php.c.