⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlrpc-epi-php.c

📁 php-4.4.7学习linux时下载的源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
/*  This file is part of, or distributed with, libXMLRPC - a C library for   xml-encoded function calls.  Author: Dan Libby (dan@libby.com)  Epinions.com may be contacted at feedback@epinions-inc.com*//*    Copyright 2001 Epinions, Inc.   Subject to the following 3 conditions, Epinions, Inc.  permits you, free   of charge, to (a) use, copy, distribute, modify, perform and display this   software and associated documentation files (the "Software"), and (b)   permit others to whom the Software is furnished to do so as well.    1) The above copyright notice and this permission notice shall be included   without modification in all copies or substantial portions of the   Software.    2) THE SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY OR CONDITION OF   ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY   IMPLIED WARRANTIES OF ACCURACY, MERCHANTABILITY, FITNESS FOR A PARTICULAR   PURPOSE OR NONINFRINGEMENT.    3) IN NO EVENT SHALL EPINIONS, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,   SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT   OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER ARISING, INCLUDING   NEGLIGENCE), EVEN IF EPINIONS, INC.  IS AWARE OF THE POSSIBILITY OF SUCH   DAMAGES.    *//* auto-generated portions of this file are also subject to the php license *//*   +----------------------------------------------------------------------+   | PHP Version 4                                                        |   +----------------------------------------------------------------------+   | Copyright (c) 1997-2007 The PHP Group                                |   +----------------------------------------------------------------------+   | This source file is subject to version 3.01 of the PHP license,      |   | that is bundled with this package in the file LICENSE, and is        |   | available through the world-wide-web at the following url:           |   | http://www.php.net/license/3_01.txt                                  |   | If you did not receive a copy of the PHP license and are unable to   |   | obtain it through the world-wide-web, please send a note to          |   | license@php.net so we can mail you a copy immediately.               |   +----------------------------------------------------------------------+   | Author: Dan Libby                                                    |   +----------------------------------------------------------------------+ *//* $Id: xmlrpc-epi-php.c,v 1.24.2.4.4.6 2007/01/01 09:46:49 sebastian Exp $ *//*********************************************************************** BUGS:                                                               **  - when calling a php user function, there appears to be no way to  **    distinguish between a return value of null, and no return value  **    at all.  The xml serialization layer(s) will then return a value **    of null, when the right thing may be no value at all. (SOAP)     ***********************************************************************/#ifdef HAVE_CONFIG_H#include "config.h"#endif#include "php.h"#include "ext/standard/info.h"#include "php_ini.h"#include "php_xmlrpc.h"#include "xmlrpc.h"#define PHP_EXT_VERSION "0.51"/* You should tweak config.m4 so this symbol (or some else suitable)	gets defined.  */ZEND_DECLARE_MODULE_GLOBALS(xmlrpc)static int le_xmlrpc_server;static unsigned char second_args_force_ref[] = { 3, BYREF_NONE, BYREF_FORCE, BYREF_NONE };static unsigned char first_args_force_ref[] = { 2, BYREF_FORCE, BYREF_NONE };function_entry xmlrpc_functions[] = {	PHP_FE(xmlrpc_encode,									NULL) 	PHP_FE(xmlrpc_decode,									NULL)	PHP_FE(xmlrpc_decode_request,							second_args_force_ref)	PHP_FE(xmlrpc_encode_request,							NULL)	PHP_FE(xmlrpc_get_type,									NULL)	PHP_FE(xmlrpc_set_type,									first_args_force_ref)	PHP_FE(xmlrpc_is_fault,									NULL)	PHP_FE(xmlrpc_server_create,							NULL)	PHP_FE(xmlrpc_server_destroy,							NULL)	PHP_FE(xmlrpc_server_register_method,					NULL)	PHP_FE(xmlrpc_server_call_method,						NULL)	PHP_FE(xmlrpc_parse_method_descriptions,				NULL)	PHP_FE(xmlrpc_server_add_introspection_data,			NULL)	PHP_FE(xmlrpc_server_register_introspection_callback,	NULL)	{NULL, NULL, NULL}};zend_module_entry xmlrpc_module_entry = {	STANDARD_MODULE_HEADER,	"xmlrpc",	xmlrpc_functions,	PHP_MINIT(xmlrpc),	PHP_MSHUTDOWN(xmlrpc),	PHP_RINIT(xmlrpc),      /* Replace with NULL if there's nothing to do at request start */	PHP_RSHUTDOWN(xmlrpc),  /* Replace with NULL if there's nothing to do at request end */	PHP_MINFO(xmlrpc),	PHP_EXT_VERSION,	STANDARD_MODULE_PROPERTIES};#ifdef COMPILE_DL_XMLRPCZEND_GET_MODULE(xmlrpc)#endif/******************************** local structures and defines ********************************//* per server data */typedef struct _xmlrpc_server_data {	zval* method_map;	zval* introspection_map;	XMLRPC_SERVER server_ptr;} xmlrpc_server_data;/* how to format output */typedef struct _php_output_options {	int b_php_out;	int b_auto_version;	STRUCT_XMLRPC_REQUEST_OUTPUT_OPTIONS xmlrpc_out;} php_output_options;/* data passed to C callback */typedef struct _xmlrpc_callback_data {	zval* xmlrpc_method;	zval* php_function;	zval* caller_params;	zval* return_data;	xmlrpc_server_data* server;	char php_executed;} xmlrpc_callback_data;/* output options */#define OUTPUT_TYPE_KEY       "output_type"#define OUTPUT_TYPE_KEY_LEN   (sizeof(OUTPUT_TYPE_KEY) - 1)#define OUTPUT_TYPE_VALUE_PHP "php"#define OUTPUT_TYPE_VALUE_XML "xml"#define VERBOSITY_KEY                  "verbosity"#define VERBOSITY_KEY_LEN              (sizeof(VERBOSITY_KEY) - 1)#define VERBOSITY_VALUE_NO_WHITE_SPACE "no_white_space"#define VERBOSITY_VALUE_NEWLINES_ONLY  "newlines_only"#define VERBOSITY_VALUE_PRETTY         "pretty"#define ESCAPING_KEY             "escaping"#define ESCAPING_KEY_LEN         (sizeof(ESCAPING_KEY) - 1)#define ESCAPING_VALUE_CDATA     "cdata"#define ESCAPING_VALUE_NON_ASCII "non-ascii"#define ESCAPING_VALUE_NON_PRINT "non-print"#define ESCAPING_VALUE_MARKUP    "markup"#define VERSION_KEY          "version"#define VERSION_KEY_LEN      (sizeof(VERSION_KEY) - 1)#define VERSION_VALUE_SIMPLE "simple"#define VERSION_VALUE_XMLRPC "xmlrpc"#define VERSION_VALUE_SOAP11 "soap 1.1"#define VERSION_VALUE_AUTO   "auto"#define ENCODING_KEY     "encoding"#define ENCODING_KEY_LEN (sizeof(ENCODING_KEY) - 1)#define ENCODING_DEFAULT "iso-8859-1"/* value types */#define OBJECT_TYPE_ATTR  "xmlrpc_type"#define OBJECT_VALUE_ATTR "scalar"#define OBJECT_VALUE_TS_ATTR "timestamp"/* faults */#define FAULT_CODE       "faultCode"#define FAULT_CODE_LEN   (sizeof(FAULT_CODE) - 1)#define FAULT_STRING     "faultString"#define FAULT_STRING_LEN (sizeof(FAULT_STRING) - 1)/************************ forward declarations ************************/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);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);int set_zval_xmlrpc_type(zval* value, XMLRPC_VALUE_TYPE type);/********************** startup / shutdown **********************/static void destroy_server_data(xmlrpc_server_data *server){	if (server) {		XMLRPC_ServerDestroy(server->server_ptr);		zval_dtor(server->method_map);		FREE_ZVAL(server->method_map);		zval_dtor(server->introspection_map);		FREE_ZVAL(server->introspection_map);		efree(server);	}}/* called when server is being destructed. either when xmlrpc_server_destroy * is called, or when request ends.  */static void xmlrpc_server_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC){	if (rsrc && rsrc->ptr) {		destroy_server_data((xmlrpc_server_data*) rsrc->ptr);	}}/* module init */PHP_MINIT_FUNCTION(xmlrpc){	le_xmlrpc_server = zend_register_list_destructors_ex(xmlrpc_server_destructor, NULL, "xmlrpc server", module_number);	return SUCCESS;}/* module shutdown */PHP_MSHUTDOWN_FUNCTION(xmlrpc){	return SUCCESS;}/* Remove if there's nothing to do at request start */PHP_RINIT_FUNCTION(xmlrpc){	return SUCCESS;}/* Remove if there's nothing to do at request end */PHP_RSHUTDOWN_FUNCTION(xmlrpc){	return SUCCESS;}/* display info in phpinfo() */PHP_MINFO_FUNCTION(xmlrpc){	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();}/******************** random utilities ********************//* Utility functions for adding data types to arrays, with or without key (assoc, non-assoc). * Could easily be further generalized to work with objects. */#if 0static int add_long(zval* list, char* id, int num) {	if(id) return add_assoc_long(list, id, num);	else   return add_next_index_long(list, num);}static int add_double(zval* list, char* id, double num) {	if(id) return add_assoc_double(list, id, num);	else   return add_next_index_double(list, num);}static int add_string(zval* list, char* id, char* string, int duplicate) {	if(id) return add_assoc_string(list, id, string, duplicate);	else   return add_next_index_string(list, string, duplicate);}static int add_stringl(zval* list, char* id, char* string, uint length, int duplicate) {	if(id) return add_assoc_stringl(list, id, string, length, duplicate);	else   return add_next_index_stringl(list, string, length, duplicate);}#endifstatic int add_zval(zval* list, const char* id, zval** val){	if (list && val) {		if (id) {			return zend_hash_update(Z_ARRVAL_P(list), (char*) id, strlen(id) + 1, (void *) val, sizeof(zval **), NULL);		} else {			return zend_hash_next_index_insert(Z_ARRVAL_P(list), (void *) val, sizeof(zval **), NULL); 		}	}	/* what is the correct return on error? */	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)#else#define my_zend_hash_get_current_key(ht, my_key, num_index) zend_hash_get_current_key(ht, my_key, num_index)#endif /************************** input / output options **************************//* parse an array (user input) into output options suitable for use by xmlrpc engine * and determine whether to return data as xml or php vars */static void set_output_options(php_output_options* options, zval* output_opts){	if (options) {		/* defaults */		options->b_php_out = 0;		options->b_auto_version = 1;		options->xmlrpc_out.version = xmlrpc_version_1_0;		options->xmlrpc_out.xml_elem_opts.encoding = ENCODING_DEFAULT;		options->xmlrpc_out.xml_elem_opts.verbosity = xml_elem_pretty;		options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_markup_escaping | xml_elem_non_ascii_escaping | xml_elem_non_print_escaping;		if (output_opts && Z_TYPE_P(output_opts) == IS_ARRAY) {			zval** val;			/* type of output (xml/php) */			if (zend_hash_find(Z_ARRVAL_P(output_opts), OUTPUT_TYPE_KEY, OUTPUT_TYPE_KEY_LEN + 1, (void**) &val) == SUCCESS) {				if (Z_TYPE_PP(val) == IS_STRING) {					if (!strcmp(Z_STRVAL_PP(val), OUTPUT_TYPE_VALUE_PHP)) {						options->b_php_out = 1;					} else if (!strcmp(Z_STRVAL_PP(val), OUTPUT_TYPE_VALUE_XML)) {						options->b_php_out = 0;					}				}			}			/* verbosity of generated xml */			if (zend_hash_find(Z_ARRVAL_P(output_opts), VERBOSITY_KEY, VERBOSITY_KEY_LEN + 1, (void**) &val) == SUCCESS) {				if (Z_TYPE_PP(val) == IS_STRING) {					if (!strcmp(Z_STRVAL_PP(val), VERBOSITY_VALUE_NO_WHITE_SPACE)) {						options->xmlrpc_out.xml_elem_opts.verbosity = xml_elem_no_white_space;					} else if (!strcmp(Z_STRVAL_PP(val), VERBOSITY_VALUE_NEWLINES_ONLY)) {						options->xmlrpc_out.xml_elem_opts.verbosity = xml_elem_newlines_only;					} else if (!strcmp(Z_STRVAL_PP(val), VERBOSITY_VALUE_PRETTY)) {						options->xmlrpc_out.xml_elem_opts.verbosity = xml_elem_pretty;					}				}			}			/* version of xml to output */			if (zend_hash_find(Z_ARRVAL_P(output_opts), VERSION_KEY, VERSION_KEY_LEN + 1, (void**) &val) == SUCCESS) {				if (Z_TYPE_PP(val) == IS_STRING) {					options->b_auto_version = 0;					if (!strcmp(Z_STRVAL_PP(val), VERSION_VALUE_XMLRPC)) {						options->xmlrpc_out.version = xmlrpc_version_1_0;					} else if (!strcmp(Z_STRVAL_PP(val), VERSION_VALUE_SIMPLE)) {						options->xmlrpc_out.version = xmlrpc_version_simple;					} else if (!strcmp((*val)->value.str.val, VERSION_VALUE_SOAP11)) {							options->xmlrpc_out.version = xmlrpc_version_soap_1_1;					} else { /* if(!strcmp((*val)->value.str.val, VERSION_VALUE_AUTO)) { */							options->b_auto_version = 1;					}				}			}		  /* 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) {		        options->xmlrpc_out.xml_elem_opts.encoding = estrdup(Z_STRVAL_PP(val));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -