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

📄 php_domxml.c

📁 php-4.4.7学习linux时下载的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	PHP_FALIAS(child_nodes,				domxml_node_children,			NULL)	PHP_FALIAS(previous_sibling,		domxml_node_previous_sibling,	NULL)	PHP_FALIAS(next_sibling,			domxml_node_next_sibling,		NULL)	PHP_FALIAS(has_child_nodes,			domxml_node_has_child_nodes,	NULL)	PHP_FALIAS(parent,					domxml_node_parent,				NULL)	PHP_FALIAS(parent_node,				domxml_node_parent,				NULL)	PHP_FALIAS(insert_before,			domxml_node_insert_before,		NULL)	PHP_FALIAS(append_child,			domxml_node_append_child,		NULL)	PHP_FALIAS(remove_child,			domxml_node_remove_child,		NULL)	PHP_FALIAS(replace_child,			domxml_node_replace_child,		NULL)	PHP_FALIAS(owner_document,			domxml_node_owner_document,		NULL)	PHP_FALIAS(new_child,				domxml_node_new_child,			NULL)	PHP_FALIAS(attributes,				domxml_node_attributes,			NULL)	PHP_FALIAS(has_attributes,			domxml_node_has_attributes,		NULL)	PHP_FALIAS(prefix,				domxml_node_prefix,				NULL)	PHP_FALIAS(namespace_uri,			domxml_node_namespace_uri,				NULL)	PHP_FALIAS(clone_node,				domxml_clone_node,				NULL)/* Non DOM functions start here */	PHP_FALIAS(add_namespace,			domxml_node_add_namespace,		NULL)	PHP_FALIAS(set_namespace,			domxml_node_set_namespace,		NULL)	PHP_FALIAS(add_child,				domxml_node_append_child,		NULL)	PHP_FALIAS(append_sibling,			domxml_node_append_sibling,		NULL)	PHP_FALIAS(node,					domxml_node,					NULL)	PHP_FALIAS(unlink,					domxml_node_unlink_node,		NULL)	PHP_FALIAS(unlink_node,				domxml_node_unlink_node,		NULL)	PHP_FALIAS(replace_node,			domxml_node_replace_node,		NULL)	PHP_FALIAS(set_content,				domxml_node_set_content,		NULL)	PHP_FALIAS(get_content,				domxml_node_get_content,		NULL)	PHP_FALIAS(text_concat,				domxml_node_text_concat,		NULL)	PHP_FALIAS(set_name,				domxml_node_set_name,			NULL)	PHP_FALIAS(is_blank_node,			domxml_is_blank_node,			NULL)	PHP_FALIAS(dump_node,				domxml_dump_node,				NULL)	{NULL, NULL, NULL}};static zend_function_entry php_domxmlelement_class_functions[] = {	PHP_FALIAS(domelement,				domxml_doc_create_element,		NULL)	PHP_FALIAS(name,					domxml_elem_tagname,			NULL)	PHP_FALIAS(tagname,					domxml_elem_tagname,			NULL)	PHP_FALIAS(get_attribute,			domxml_elem_get_attribute,		NULL)	PHP_FALIAS(set_attribute,			domxml_elem_set_attribute,		NULL)	PHP_FALIAS(remove_attribute,		domxml_elem_remove_attribute,	NULL)	PHP_FALIAS(get_attribute_node,		domxml_elem_get_attribute_node,	NULL)/* since this function is not implemented, outcomment it for the time beeing	PHP_FALIAS(set_attribute_node,		domxml_elem_set_attribute_node,	NULL)*/	PHP_FALIAS(get_elements_by_tagname,	domxml_elem_get_elements_by_tagname,	NULL)	PHP_FALIAS(has_attribute,	domxml_elem_has_attribute,	NULL)	{NULL, NULL, NULL}};static zend_function_entry php_domxmlcdata_class_functions[] = {	PHP_FALIAS(domcdata,				domxml_doc_create_cdata_section,NULL)	PHP_FALIAS(length,					domxml_cdata_length,			NULL)	{NULL, NULL, NULL}};static zend_function_entry php_domxmltext_class_functions[] = {	PHP_FALIAS(domtext,					domxml_doc_create_text_node,	NULL)	{NULL, NULL, NULL}};static zend_function_entry php_domxmlcomment_class_functions[] = {	PHP_FALIAS(domcomment,				domxml_doc_create_comment,		NULL)	{NULL, NULL, NULL}};static zend_function_entry php_domxmlnotation_class_functions[] = {	PHP_FALIAS(public_id,				domxml_notation_public_id,		NULL)	PHP_FALIAS(system_id,				domxml_notation_system_id,		NULL)	{NULL, NULL, NULL}};static zend_function_entry php_domxmlentityref_class_functions[] = {	PHP_FALIAS(domentityreference,		domxml_doc_create_entity_reference,	NULL)	{NULL, NULL, NULL}};static zend_function_entry php_domxmlentity_class_functions[] = {/*	PHP_FALIAS(public_id,				domxml_entity_public_id,		NULL)	PHP_FALIAS(system_id,				domxml_entity_system_id,		NULL)	PHP_FALIAS(notation_name,			domxml_entity_notation_name,	NULL)*/	{NULL, NULL, NULL}};static zend_function_entry php_domxmlpi_class_functions[] = {	PHP_FALIAS(domprocessinginstruction, domxml_doc_create_processing_instruction, NULL)	PHP_FALIAS(target,					domxml_pi_target,				NULL)	PHP_FALIAS(data,					domxml_pi_data,					NULL)	{NULL, NULL, NULL}};#if defined(LIBXML_XPATH_ENABLED)static zend_function_entry php_xpathctx_class_functions[] = {	PHP_FALIAS(xpath_eval,				xpath_eval,						NULL)	PHP_FALIAS(xpath_eval_expression,	xpath_eval_expression,			NULL)	PHP_FALIAS(xpath_register_ns,		xpath_register_ns,				NULL)	{NULL, NULL, NULL}};static zend_function_entry php_xpathobject_class_functions[] = {	{NULL, NULL, NULL}};#endifstatic zend_function_entry php_domxmlattr_class_functions[] = {	PHP_FALIAS(domattribute,			domxml_doc_create_attribute,	NULL)	/* DOM_XML Consistent calls */	PHP_FALIAS(node_name,				domxml_attr_name,				NULL)	PHP_FALIAS(node_value,				domxml_attr_value,				NULL)	PHP_FALIAS(node_specified,			domxml_attr_specified,			NULL)	/* W3C compliant calls */	PHP_FALIAS(name,					domxml_attr_name,				NULL)	PHP_FALIAS(value,					domxml_attr_value,				NULL)	PHP_FALIAS(specified,				domxml_attr_specified,			NULL)/*	PHP_FALIAS(owner_element,			domxml_attr_owner_element,		NULL)*/	{NULL, NULL, NULL}};static zend_function_entry php_domxmlns_class_functions[] = {	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(prefix,				domxml_node_prefix,			NULL)	PHP_FALIAS(namespace_uri,			domxml_node_namespace_uri,		NULL)	PHP_FALIAS(owner_document,			domxml_node_owner_document,		NULL)	PHP_FALIAS(parent_node,				domxml_node_parent,			NULL)	{NULL, NULL, NULL}};#if HAVE_DOMXSLTstatic zend_function_entry php_domxsltstylesheet_class_functions[] = {/* TODO: maybe some more methods? */	PHP_FALIAS(process, 				domxml_xslt_process, 			NULL)	PHP_FALIAS(result_dump_mem, 			domxml_xslt_result_dump_mem, 		NULL)	PHP_FALIAS(result_dump_file, 			domxml_xslt_result_dump_file, 		NULL)	{NULL, NULL, NULL}};#endifzend_module_entry domxml_module_entry = {	STANDARD_MODULE_HEADER,	"domxml",	domxml_functions,	PHP_MINIT(domxml),	PHP_MSHUTDOWN(domxml),	PHP_RINIT(domxml),	PHP_RSHUTDOWN(domxml),	PHP_MINFO(domxml),	DOMXML_API_VERSION, /* Extension versionnumber */	STANDARD_MODULE_PROPERTIES};#ifdef COMPILE_DL_DOMXMLZEND_GET_MODULE(domxml)#endifstatic void dom_object_set_data(void *obj, zval *wrapper){/*	char tmp[20];	sprintf(tmp, "%08X", obj);	fprintf(stderr, "Adding %s to hash\n", tmp);*/	((xmlNodePtr) obj)->_private = wrapper;}static zval *dom_object_get_data(void *obj){/*	char tmp[20];	sprintf(tmp, "%08X", obj);	fprintf(stderr, "Trying getting %s from object ...", tmp);	if(((xmlNodePtr) obj)->_private)		fprintf(stderr, " found\n");	else		fprintf(stderr, " not found\n");*/	return ((zval *) (((xmlNodePtr) obj)->_private));}static inline void node_wrapper_dtor(xmlNodePtr node){	zval *wrapper;	int refcount = 0;	/* FIXME: type check probably unnecessary here? */	if (!node) /* || Z_TYPE_P(node) == XML_DTD_NODE)*/		return;	wrapper = dom_object_get_data(node);	if (wrapper != NULL ) {		refcount = wrapper->refcount;		zval_ptr_dtor(&wrapper);		/*only set it to null, if refcount was 1 before, otherwise it has still needed references */		if (refcount == 1) {			dom_object_set_data(node, NULL);		}	}}/*	This function should only be used when freeing nodes 	as dependant objects are destroyed */static inline void node_wrapper_free(xmlNodePtr node  TSRMLS_DC){	zval *wrapper, **handle;	int type, refcount = 0;	if (!node) {		return;	}	wrapper = dom_object_get_data(node);	if (wrapper != NULL ) {		/* All references need to be destroyed */		if (zend_hash_index_find(Z_OBJPROP_P(wrapper), 0, (void **) &handle) ==	SUCCESS) {			if (zend_list_find(Z_LVAL_PP(handle), &type)) {				zend_list_delete(Z_LVAL_PP(handle));			}		} else {			refcount = wrapper->refcount;			zval_ptr_dtor(&wrapper);			/* only set it to null, if refcount was 1 before, otherwise it has still needed references */			if (refcount == 1) {				dom_object_set_data(node, NULL);			}		}	}}static inline void attr_list_wrapper_dtor(xmlAttrPtr attr){	while (attr != NULL) {		/* Attribute nodes contain children which can be accessed */		node_wrapper_dtor((xmlNodePtr) attr);		attr = attr->next;	}}/*	destroyref is a bool indicating if all registered objects for nodes 	within the tree should be destroyed */static inline void node_list_wrapper_dtor(xmlNodePtr node, int destroyref TSRMLS_DC){	while (node != NULL) {		node_list_wrapper_dtor(node->children, destroyref TSRMLS_CC);		switch (node->type) {			/* Skip property freeing for the following types */			case XML_ATTRIBUTE_DECL:			case XML_DTD_NODE:			case XML_ELEMENT_DECL:			case XML_ENTITY_DECL:			case XML_ATTRIBUTE_NODE:				break;			default:				/*	Attribute Nodes contain accessible children					Call this function with the propert list				attr_list_wrapper_dtor(node->properties);  */				node_list_wrapper_dtor((xmlNodePtr) node->properties, destroyref TSRMLS_CC);		}		if (destroyref == 1) {			node_wrapper_free(node TSRMLS_CC);		} else {			node_wrapper_dtor(node);		}		node = node->next;	}}/*	Navigate through the tree and unlink nodes which are referenced by objects */static inline void node_list_unlink(xmlNodePtr node){	zval *wrapper;	while (node != NULL) {		wrapper = dom_object_get_data(node);		if (wrapper != NULL ) {			/* This node is referenced so no need to check children */			xmlUnlinkNode(node);		} else {			node_list_unlink(node->children);			switch (node->type) {				/* Skip property freeing for the following types */				case XML_ATTRIBUTE_DECL:				case XML_DTD_NODE:				case XML_ENTITY_DECL:				case XML_ELEMENT_DECL:				case XML_ATTRIBUTE_NODE:					break;				default:					node_list_unlink((xmlNodePtr) node->properties);			}		}		node = node->next;	}}static xmlNodeSetPtr php_get_elements_by_tagname(xmlNodePtr n, xmlChar* name, xmlNodeSet *rv ){	xmlNodePtr cld = NULL;	/* TODO	   Namespace support	 */	if ( n != NULL && name != NULL ) {		cld = n;		while ( cld != NULL ) {			if (cld->type == XML_ELEMENT_NODE && (xmlStrEqual(name, "*") || xmlStrcmp(name, cld->name) == 0)){				if ( rv == NULL ) {					rv = xmlXPathNodeSetCreate( cld ) ;				}				else {					xmlXPathNodeSetAdd( rv, cld );				}			}			rv = php_get_elements_by_tagname(cld->children, name, rv);			cld = cld->next;		}	}	return rv;}static void php_free_xml_doc(zend_rsrc_list_entry *rsrc TSRMLS_DC){	xmlDoc *doc = (xmlDoc *) rsrc->ptr;	if (doc) {		node_list_wrapper_dtor(doc->children, 1 TSRMLS_CC);		node_wrapper_dtor((xmlNodePtr) doc);		xmlFreeDoc(doc);	}}static void php_free_xml_node(zend_rsrc_list_entry *rsrc TSRMLS_DC){	xmlNodePtr node = (xmlNodePtr) rsrc->ptr;	/* if node has no parent, it will not be freed by php_free_xml_doc, so do it here	and for all children as well. */	if (node->parent == NULL || node->type == XML_NAMESPACE_DECL) {		/* Attribute Nodes ccontain accessible children 		attr_list_wrapper_dtor(node->properties); */		xmlSetTreeDoc(node, NULL);		if (node->type == XML_NAMESPACE_DECL) {			if (node->ns) {				xmlFreeNs(node->ns);				node->ns = NULL;			}			node->type = XML_ELEMENT_NODE;		} else {			node_list_wrapper_dtor((xmlNodePtr) node->properties, 1 TSRMLS_CC);		}		node_list_wrapper_dtor(node->children, 1 TSRMLS_CC);		node_wrapper_dtor(node);		xmlFreeNode(node);	} else {		node_wrapper_dtor(node);	}}static void php_free_xml_attr(zend_rsrc_list_entry *rsrc TSRMLS_DC){	xmlNodePtr node = (xmlNodePtr) rsrc->ptr;	if (node->parent == NULL) {		/* Attribute Nodes contain accessible children */		node_list_wrapper_dtor(node->children, 1 TSRMLS_CC);		node_wrapper_dtor(node);		xmlFreeProp((xmlAttrPtr) node);	} else {		node_wrapper_dtor(node);	}}#if defined(LIBXML_XPATH_ENABLED)static void php_free_xpath_context(zend_rsrc_list_entry *rsrc TSRMLS_DC){	xmlXPathContextPtr ctx = (xmlXPathContextPtr) rsrc->ptr;

⌨️ 快捷键说明

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