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

📄 php_domxml.c

📁 php-4.4.7学习linux时下载的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/*   +----------------------------------------------------------------------+   | 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: Uwe Steinmann <steinm@php.net>                               |   +----------------------------------------------------------------------+ *//* $Id: php_domxml.c,v 1.218.2.50.2.5 2007/01/01 09:46:41 sebastian Exp $ *//* TODO * - Support Notation Nodes * */#ifdef HAVE_CONFIG_H#include "config.h"#endif#include "php.h"#include "ext/standard/php_rand.h"#include "php_domxml.h"#if HAVE_DOMXML#include "ext/standard/info.h"#define PHP_XPATH 1#define PHP_XPTR 2/* General macros used by domxml */#define DOMXML_IS_TYPE(zval, ce)					(zval && Z_TYPE_P(zval) == IS_OBJECT && Z_OBJCE_P(zval)->refcount == ce->refcount)#define DOMXML_DOMOBJ_NEW(zval, obj, ret)			if (NULL == (zval = php_domobject_new(obj, ret, zval TSRMLS_CC))) { \														php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create required DOM object"); \														RETURN_FALSE; \													}#define DOMXML_RET_ZVAL(zval)						SEPARATE_ZVAL(&zval); \													*return_value = *zval; \													FREE_ZVAL(zval);#define DOMXML_RET_OBJ(zval, obj, ret)				DOMXML_DOMOBJ_NEW(zval, obj, ret); \													DOMXML_RET_ZVAL(zval);#define DOMXML_GET_THIS(zval)						if (NULL == (zval = getThis())) { \														php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing"); \														RETURN_FALSE; \													}#define DOMXML_GET_OBJ(ret, zval, le)				if (NULL == (ret = php_dom_get_object(zval, le, 0 TSRMLS_CC))) { \														php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot fetch DOM object"); \														RETURN_FALSE; \													}#define DOMXML_GET_THIS_OBJ(ret, zval, le)			DOMXML_GET_THIS(zval); \													DOMXML_GET_OBJ(ret, zval, le);#define DOMXML_NO_ARGS()							if (ZEND_NUM_ARGS() != 0) { \														php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expects exactly 0 parameters, %d given", ZEND_NUM_ARGS()); \														return; \													}#define DOMXML_NOT_IMPLEMENTED()					php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not yet implemented"); \													return;/* WARNING: The number of parameters is actually the * number of passed variables to zend_parse_parameters(), * *NOT* the number of parameters expected by the PHP function. */#define DOMXML_PARAM_NONE(ret, zval, le)			if (NULL == (zval = getThis())) { \														if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &zval) == FAILURE) { \															return; \														} \													} \													DOMXML_GET_OBJ(ret, zval, le);#define DOMXML_PARAM_ONE(ret, zval, le, s, p1)	if (NULL == (zval = getThis())) { \														if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o"s, &zval, p1) == FAILURE) { \															return; \														} \													} else { \														if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, p1) == FAILURE) { \															return; \														} \													} \													DOMXML_GET_OBJ(ret, zval, le);#define DOMXML_PARAM_TWO(ret, zval, le, s, p1, p2)	if (NULL == (zval = getThis())) { \														if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o"s, &zval, p1, p2) == FAILURE) { \															return; \														} \													} else { \														if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, p1, p2) == FAILURE) { \															return; \														} \													} \													DOMXML_GET_OBJ(ret, zval, le);#define DOMXML_PARAM_THREE(ret, zval, le, s, p1, p2, p3)		if (NULL == (zval = getThis())) { \																	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o"s, &zval, p1, p2, p3) == FAILURE) { \																		return; \																	} \																} else { \																	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, p1, p2, p3) == FAILURE) { \																		return; \																	} \																} \																DOMXML_GET_OBJ(ret, zval, le);#define DOMXML_PARAM_FOUR(ret, zval, le, s, p1, p2, p3, p4)		if (NULL == (zval = getThis())) { \																	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o"s, &zval, p1, p2, p3, p4) == FAILURE) { \																		return; \																	} \																} else { \																	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, p1, p2, p3, p4) == FAILURE) { \																		return; \																	} \																} \																DOMXML_GET_OBJ(ret, zval, le);#define DOMXML_PARAM_SIX(ret, zval, le, s, p1, p2, p3, p4, p5, p6)		if (NULL == (zval = getThis())) { \																	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o"s, &zval, p1, p2, p3, p4, p5, p6) == FAILURE) { \																		return; \																	} \																} else { \																	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, p1, p2, p3, p4, p5, p6) == FAILURE) { \																		return; \																	} \																} \																DOMXML_GET_OBJ(ret, zval, le);#define DOMXML_LOAD_PARSING  0#define DOMXML_LOAD_VALIDATING 1#define DOMXML_LOAD_RECOVERING 2#define DOMXML_LOAD_SUBSTITUTE_ENTITIES 4#define DOMXML_LOAD_COMPLETE_ATTRS 8#define DOMXML_LOAD_DONT_KEEP_BLANKS 16#define DOMXML_LOAD_FILE 1static int le_domxmldocp;static int le_domxmldoctypep;static int le_domxmldtdp;static int le_domxmlnodep;static int le_domxmlelementp;static int le_domxmlattrp;static int le_domxmlcdatap;static int le_domxmltextp;static int le_domxmlpip;static int le_domxmlcommentp;static int le_domxmlnotationp;static int le_domxmlparserp;static int le_domxmlnamespacep;/*static int le_domxmlentityp;*/static int le_domxmlentityrefp;/*static int le_domxmlnsp;*/#if HAVE_DOMXSLTstatic int le_domxsltstylesheetp;#endifstatic void domxml_error(void *ctx, const char *msg, ...);static void domxml_error_ext(void *ctx, const char *msg, ...);static void domxml_error_validate(void *ctx, const char *msg, ...);#if defined(LIBXML_XPATH_ENABLED)static int le_xpathctxp;static int le_xpathobjectp;#endifzend_class_entry *domxmldoc_class_entry;zend_class_entry *domxmldoctype_class_entry;zend_class_entry *domxmlelement_class_entry;zend_class_entry *domxmldtd_class_entry;zend_class_entry *domxmlnode_class_entry;zend_class_entry *domxmlattr_class_entry;zend_class_entry *domxmlcdata_class_entry;zend_class_entry *domxmltext_class_entry;zend_class_entry *domxmlpi_class_entry;zend_class_entry *domxmlcomment_class_entry;zend_class_entry *domxmlnotation_class_entry;zend_class_entry *domxmlentity_class_entry;zend_class_entry *domxmlentityref_class_entry;zend_class_entry *domxmlns_class_entry;zend_class_entry *domxmlparser_class_entry;#if defined(LIBXML_XPATH_ENABLED)zend_class_entry *xpathctx_class_entry;zend_class_entry *xpathobject_class_entry;#endif#if HAVE_DOMXSLTzend_class_entry *domxsltstylesheet_class_entry;static int xslt_has_xsl_keys (xmlDocPtr doc);#endifstatic int node_attributes(zval **attributes, xmlNode *nodep TSRMLS_DC);static int node_children(zval **children, xmlNode *nodep TSRMLS_DC);static unsigned char first_args_force_ref[]  = { 1, BYREF_FORCE };static unsigned char second_args_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE };static unsigned char third_args_force_ref[]  = { 3, BYREF_NONE, BYREF_NONE, BYREF_FORCE };static zend_function_entry domxml_functions[] = {	PHP_FE(domxml_version,												NULL)	PHP_FE(xmldoc,														third_args_force_ref)	PHP_FALIAS(domxml_open_mem,				xmldoc,	third_args_force_ref)	PHP_FE(xmldocfile,														third_args_force_ref)	PHP_FALIAS(domxml_open_file,				xmldocfile,	third_args_force_ref)#if defined(LIBXML_HTML_ENABLED)	PHP_FE(html_doc,													NULL)	PHP_FE(html_doc_file,												NULL)#endif	PHP_FE(domxml_xmltree,														NULL)	PHP_FALIAS(xmltree,				domxml_xmltree,	NULL)	PHP_FE(domxml_substitute_entities_default,														NULL)	PHP_FE(domxml_doc_document_element,									NULL)	PHP_FE(domxml_doc_add_root,											NULL)	PHP_FE(domxml_doc_set_root,											NULL)	PHP_FE(domxml_dump_mem,												NULL)	PHP_FE(domxml_dump_mem_file,										NULL)	PHP_FE(domxml_dump_node,											NULL)#if defined(LIBXML_HTML_ENABLED)	PHP_FE(domxml_html_dump_mem,										NULL)#endif	PHP_FE(domxml_node_attributes,										NULL)	PHP_FE(domxml_elem_get_attribute,									NULL)	PHP_FE(domxml_elem_set_attribute,									NULL)	PHP_FE(domxml_node_children,										NULL)	PHP_FE(domxml_node_has_attributes,									NULL)	PHP_FE(domxml_node_new_child,										NULL)	PHP_FE(domxml_node,													NULL)	PHP_FE(domxml_node_unlink_node,										NULL)	PHP_FE(domxml_node_set_content,										NULL)	PHP_FE(domxml_node_get_content,										NULL)	PHP_FE(domxml_node_add_namespace,									NULL)	PHP_FE(domxml_node_set_namespace,									NULL)	PHP_FE(domxml_new_xmldoc,											NULL)	PHP_FALIAS(domxml_new_doc,				domxml_new_xmldoc,	NULL)	PHP_FE(domxml_parser,												NULL)	PHP_FE(domxml_parser_add_chunk,										NULL)	PHP_FE(domxml_parser_end,											NULL)	PHP_FE(domxml_parser_start_element,									NULL)	PHP_FE(domxml_parser_end_element,									NULL)	PHP_FE(domxml_parser_comment,										NULL)	PHP_FE(domxml_parser_characters,									NULL)	PHP_FE(domxml_parser_entity_reference,								NULL)	PHP_FE(domxml_parser_processing_instruction,						NULL)	PHP_FE(domxml_parser_cdata_section,									NULL)	PHP_FE(domxml_parser_namespace_decl,								NULL)	PHP_FE(domxml_parser_start_document,								NULL)	PHP_FE(domxml_parser_end_document,									NULL)	PHP_FE(domxml_parser_get_document,									NULL)#if defined(LIBXML_XPATH_ENABLED)	PHP_FE(xpath_new_context,											NULL)	PHP_FE(xpath_eval,													NULL)	PHP_FE(xpath_eval_expression,										NULL)	PHP_FE(xpath_register_ns,											NULL)	PHP_FE(domxml_doc_get_elements_by_tagname,							NULL)	PHP_FE(domxml_doc_get_element_by_id,								NULL)#endif#if defined(LIBXML_XPTR_ENABLED)	PHP_FE(xptr_new_context,											NULL)	PHP_FE(xptr_eval,													NULL)#endif#if HAVE_DOMXSLT	PHP_FE(domxml_xslt_version,											NULL)	PHP_FE(domxml_xslt_stylesheet,										NULL)	PHP_FE(domxml_xslt_stylesheet_doc,									NULL)	PHP_FE(domxml_xslt_stylesheet_file,									NULL)	PHP_FE(domxml_xslt_process,											NULL)	PHP_FE(domxml_xslt_result_dump_mem,							  			NULL)	PHP_FE(domxml_xslt_result_dump_file,							  			NULL)#endif	PHP_FALIAS(domxml_add_root,			domxml_doc_add_root,			NULL)	PHP_FALIAS(domxml_doc_get_root,		domxml_doc_document_element,	NULL)	PHP_FALIAS(domxml_root,				domxml_doc_document_element,	NULL)	PHP_FALIAS(domxml_attributes,		domxml_node_attributes,			NULL)	PHP_FALIAS(domxml_get_attribute,	domxml_elem_get_attribute,		NULL)	PHP_FALIAS(domxml_getattr,			domxml_elem_get_attribute,		NULL)	PHP_FALIAS(domxml_set_attribute,	domxml_elem_set_attribute,		NULL)	PHP_FALIAS(domxml_setattr,			domxml_elem_set_attribute,		NULL)	PHP_FALIAS(domxml_children,			domxml_node_children,			NULL)	PHP_FALIAS(domxml_new_child,		domxml_node_new_child,			NULL)	PHP_FALIAS(domxml_unlink_node,		domxml_node_unlink_node,		NULL)	PHP_FALIAS(set_content,				domxml_node_set_content,		NULL)	PHP_FALIAS(new_xmldoc,				domxml_new_xmldoc,				NULL)	PHP_FALIAS(domxml_dumpmem,			domxml_dump_mem,				NULL)	PHP_FE(domxml_doc_validate,											second_args_force_ref)	PHP_FE(domxml_doc_xinclude,											NULL)	{NULL, NULL, NULL}};static function_entry php_domxmldoc_class_functions[] = {	PHP_FALIAS(domdocument,				xmldoc,							NULL)	PHP_FALIAS(doctype, 				domxml_doc_doctype, 			NULL)	PHP_FALIAS(implementation,			domxml_doc_implementation,		NULL)	PHP_FALIAS(document_element,		domxml_doc_document_element,	NULL)	PHP_FALIAS(create_element,			domxml_doc_create_element,		NULL)	PHP_FALIAS(create_element_ns,		domxml_doc_create_element_ns,	NULL)	PHP_FALIAS(create_text_node,		domxml_doc_create_text_node,	NULL)	PHP_FALIAS(create_comment,			domxml_doc_create_comment,		NULL)	PHP_FALIAS(create_attribute,		domxml_doc_create_attribute,	NULL)	PHP_FALIAS(create_cdata_section,	domxml_doc_create_cdata_section,	NULL)	PHP_FALIAS(create_entity_reference,	domxml_doc_create_entity_reference,	NULL)	PHP_FALIAS(create_processing_instruction,	domxml_doc_create_processing_instruction,	NULL)	PHP_FALIAS(get_elements_by_tagname,	domxml_doc_get_elements_by_tagname,	NULL)	PHP_FALIAS(get_element_by_id,		domxml_doc_get_element_by_id,	NULL)	PHP_FALIAS(free,					domxml_doc_free_doc,			NULL)	/* Everything below this comment is none DOM compliant */	/* children is deprecated because it is inherited from DomNode *//*	PHP_FALIAS(children,				domxml_node_children,			NULL) */	PHP_FALIAS(add_root,				domxml_doc_add_root,			NULL)	PHP_FALIAS(set_root,				domxml_doc_set_root,			NULL)	PHP_FALIAS(get_root,				domxml_doc_document_element,	NULL)	PHP_FALIAS(root,					domxml_doc_document_element,	NULL)	PHP_FALIAS(imported_node,			domxml_doc_imported_node,		NULL)	PHP_FALIAS(dtd,						domxml_intdtd,					NULL)	PHP_FALIAS(ids,						domxml_doc_ids,					NULL)	PHP_FALIAS(dumpmem,					domxml_dump_mem,				NULL)	PHP_FALIAS(dump_mem,				domxml_dump_mem,				NULL)	PHP_FALIAS(dump_mem_file,			domxml_dump_mem_file,			NULL)	PHP_FALIAS(dump_file,				domxml_dump_mem_file,			NULL)#if defined(LIBXML_HTML_ENABLED)	PHP_FALIAS(html_dump_mem,			domxml_html_dump_mem,			NULL)#endif#if defined(LIBXML_XPATH_ENABLED)	PHP_FALIAS(xpath_init,				xpath_init,						NULL)	PHP_FALIAS(xpath_new_context,		xpath_new_context,				NULL)	PHP_FALIAS(xptr_new_context,		xptr_new_context,				NULL)#endif	PHP_FALIAS(validate,				domxml_doc_validate,				first_args_force_ref)	PHP_FALIAS(xinclude,				domxml_doc_xinclude,				NULL)	{NULL, NULL, NULL}};static function_entry php_domxmlparser_class_functions[] = {	PHP_FALIAS(add_chunk,				domxml_parser_add_chunk,		NULL)	PHP_FALIAS(end,						domxml_parser_end,				NULL)	PHP_FALIAS(set_keep_blanks,			domxml_parser_set_keep_blanks,	NULL)	PHP_FALIAS(start_element,				domxml_parser_start_element,		NULL)	PHP_FALIAS(end_element,				domxml_parser_end_element,		NULL)	PHP_FALIAS(characters,				domxml_parser_characters,		NULL)	PHP_FALIAS(entity_reference,				domxml_parser_entity_reference,		NULL)	PHP_FALIAS(processing_instruction,				domxml_parser_processing_instruction,		NULL)	PHP_FALIAS(cdata_section,				domxml_parser_cdata_section,		NULL)	PHP_FALIAS(comment,				domxml_parser_comment,		NULL)	PHP_FALIAS(namespace_decl,				domxml_parser_namespace_decl,		NULL)	PHP_FALIAS(start_document,				domxml_parser_start_document,		NULL)	PHP_FALIAS(end_document,				domxml_parser_end_document,		NULL)	PHP_FALIAS(get_document,				domxml_parser_get_document,		NULL)	{NULL, NULL, NULL}};static function_entry php_domxmldoctype_class_functions[] = {	PHP_FALIAS(name,					domxml_doctype_name,			NULL)	PHP_FALIAS(entities,				domxml_doctype_entities,		NULL)	PHP_FALIAS(notations,				domxml_doctype_notations,		NULL)	PHP_FALIAS(system_id,				domxml_doctype_system_id,		NULL)	PHP_FALIAS(public_id,				domxml_doctype_public_id,		NULL)/*	PHP_FALIAS(internal_subset,			domxml_doctype_internal_subset,	NULL)*/	{NULL, NULL, NULL}};static zend_function_entry php_domxmldtd_class_functions[] = {	{NULL, NULL, NULL}};static zend_function_entry php_domxmlnode_class_functions[] = {	PHP_FALIAS(domnode,					domxml_node,					NULL)	PHP_FALIAS(node_name,				domxml_node_name,				NULL)	PHP_FALIAS(node_type,				domxml_node_type,				NULL)	PHP_FALIAS(node_value,				domxml_node_value,				NULL)	PHP_FALIAS(first_child,				domxml_node_first_child,		NULL)	PHP_FALIAS(last_child,				domxml_node_last_child,			NULL)	PHP_FALIAS(children,				domxml_node_children,			NULL)

⌨️ 快捷键说明

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