123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- #ifdef HAVE_CONFIG_H
- #include "config.h"
- #endif
- #include "php.h"
- #if HAVE_LIBXML && HAVE_DOM
- #include "php_dom.h"
- ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_namednodemap_get_named_item, 0, 0, 1)
- ZEND_ARG_INFO(0, name)
- ZEND_END_ARG_INFO();
- ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_namednodemap_set_named_item, 0, 0, 1)
- ZEND_ARG_OBJ_INFO(0, arg, DOMNode, 0)
- ZEND_END_ARG_INFO();
- ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_namednodemap_remove_named_item, 0, 0, 0)
- ZEND_ARG_INFO(0, name)
- ZEND_END_ARG_INFO();
- ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_namednodemap_item, 0, 0, 0)
- ZEND_ARG_INFO(0, index)
- ZEND_END_ARG_INFO();
- ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_namednodemap_get_named_item_ns, 0, 0, 0)
- ZEND_ARG_INFO(0, namespaceURI)
- ZEND_ARG_INFO(0, localName)
- ZEND_END_ARG_INFO();
- ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_namednodemap_set_named_item_ns, 0, 0, 0)
- ZEND_ARG_OBJ_INFO(0, arg, DOMNode, 0)
- ZEND_END_ARG_INFO();
- ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_namednodemap_remove_named_item_ns, 0, 0, 0)
- ZEND_ARG_INFO(0, namespaceURI)
- ZEND_ARG_INFO(0, localName)
- ZEND_END_ARG_INFO();
- ZEND_BEGIN_ARG_INFO_EX(arginfo_dom_namednodemap_count, 0, 0, 0)
- ZEND_END_ARG_INFO();
- const zend_function_entry php_dom_namednodemap_class_functions[] = {
- PHP_FALIAS(getNamedItem, dom_namednodemap_get_named_item, arginfo_dom_namednodemap_get_named_item)
- PHP_FALIAS(setNamedItem, dom_namednodemap_set_named_item, arginfo_dom_namednodemap_set_named_item)
- PHP_FALIAS(removeNamedItem, dom_namednodemap_remove_named_item, arginfo_dom_namednodemap_remove_named_item)
- PHP_FALIAS(item, dom_namednodemap_item, arginfo_dom_namednodemap_item)
- PHP_FALIAS(getNamedItemNS, dom_namednodemap_get_named_item_ns, arginfo_dom_namednodemap_get_named_item_ns)
- PHP_FALIAS(setNamedItemNS, dom_namednodemap_set_named_item_ns, arginfo_dom_namednodemap_set_named_item_ns)
- PHP_FALIAS(removeNamedItemNS, dom_namednodemap_remove_named_item_ns, arginfo_dom_namednodemap_remove_named_item_ns)
- PHP_FALIAS(count, dom_namednodemap_count, arginfo_dom_namednodemap_count)
- PHP_FE_END
- };
- int dom_namednodemap_length_read(dom_object *obj, zval *retval)
- {
- dom_nnodemap_object *objmap;
- xmlAttrPtr curnode;
- xmlNodePtr nodep;
- int count = 0;
- objmap = (dom_nnodemap_object *)obj->ptr;
- if (objmap != NULL) {
- if ((objmap->nodetype == XML_NOTATION_NODE) ||
- objmap->nodetype == XML_ENTITY_NODE) {
- if (objmap->ht) {
- count = xmlHashSize(objmap->ht);
- }
- } else {
- nodep = dom_object_get_node(objmap->baseobj);
- if (nodep) {
- curnode = nodep->properties;
- if (curnode) {
- count++;
- while (curnode->next != NULL) {
- count++;
- curnode = curnode->next;
- }
- }
- }
- }
- }
- ZVAL_LONG(retval, count);
- return SUCCESS;
- }
- PHP_FUNCTION(dom_namednodemap_get_named_item)
- {
- zval *id;
- int ret;
- size_t namedlen=0;
- dom_object *intern;
- xmlNodePtr itemnode = NULL;
- char *named;
- dom_nnodemap_object *objmap;
- xmlNodePtr nodep;
- xmlNotation *notep = NULL;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &id, dom_namednodemap_class_entry, &named, &namedlen) == FAILURE) {
- return;
- }
- intern = Z_DOMOBJ_P(id);
- objmap = (dom_nnodemap_object *)intern->ptr;
- if (objmap != NULL) {
- if ((objmap->nodetype == XML_NOTATION_NODE) ||
- objmap->nodetype == XML_ENTITY_NODE) {
- if (objmap->ht) {
- if (objmap->nodetype == XML_ENTITY_NODE) {
- itemnode = (xmlNodePtr)xmlHashLookup(objmap->ht, (xmlChar *) named);
- } else {
- notep = (xmlNotation *)xmlHashLookup(objmap->ht, (xmlChar *) named);
- if (notep) {
- itemnode = create_notation(notep->name, notep->PublicID, notep->SystemID);
- }
- }
- }
- } else {
- nodep = dom_object_get_node(objmap->baseobj);
- if (nodep) {
- itemnode = (xmlNodePtr)xmlHasProp(nodep, (xmlChar *) named);
- }
- }
- }
- if (itemnode) {
- DOM_RET_OBJ(itemnode, &ret, objmap->baseobj);
- return;
- } else {
- RETVAL_NULL();
- }
- }
- PHP_FUNCTION(dom_namednodemap_set_named_item)
- {
- DOM_NOT_IMPLEMENTED();
- }
- PHP_FUNCTION(dom_namednodemap_remove_named_item)
- {
- DOM_NOT_IMPLEMENTED();
- }
- PHP_FUNCTION(dom_namednodemap_item)
- {
- zval *id;
- zend_long index;
- int ret;
- dom_object *intern;
- xmlNodePtr itemnode = NULL;
- dom_nnodemap_object *objmap;
- xmlNodePtr nodep, curnode;
- int count;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &id, dom_namednodemap_class_entry, &index) == FAILURE) {
- return;
- }
- if (index >= 0) {
- if (ZEND_LONG_INT_OVFL(index)) {
- php_error_docref(NULL, E_WARNING, "Invalid index");
- RETURN_NULL();
- }
- intern = Z_DOMOBJ_P(id);
- objmap = (dom_nnodemap_object *)intern->ptr;
- if (objmap != NULL) {
- if ((objmap->nodetype == XML_NOTATION_NODE) ||
- objmap->nodetype == XML_ENTITY_NODE) {
- if (objmap->ht) {
- if (objmap->nodetype == XML_ENTITY_NODE) {
- itemnode = php_dom_libxml_hash_iter(objmap->ht, index);
- } else {
- itemnode = php_dom_libxml_notation_iter(objmap->ht, index);
- }
- }
- } else {
- nodep = dom_object_get_node(objmap->baseobj);
- if (nodep) {
- curnode = (xmlNodePtr)nodep->properties;
- count = 0;
- while (count < index && curnode != NULL) {
- count++;
- curnode = (xmlNodePtr)curnode->next;
- }
- itemnode = curnode;
- }
- }
- }
- if (itemnode) {
- DOM_RET_OBJ(itemnode, &ret, objmap->baseobj);
- return;
- }
- }
- RETVAL_NULL();
- }
- PHP_FUNCTION(dom_namednodemap_get_named_item_ns)
- {
- zval *id;
- int ret;
- size_t namedlen=0, urilen=0;
- dom_object *intern;
- xmlNodePtr itemnode = NULL;
- char *uri, *named;
- dom_nnodemap_object *objmap;
- xmlNodePtr nodep;
- xmlNotation *notep = NULL;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os!s", &id, dom_namednodemap_class_entry, &uri, &urilen, &named, &namedlen) == FAILURE) {
- return;
- }
- intern = Z_DOMOBJ_P(id);
- objmap = (dom_nnodemap_object *)intern->ptr;
- if (objmap != NULL) {
- if ((objmap->nodetype == XML_NOTATION_NODE) ||
- objmap->nodetype == XML_ENTITY_NODE) {
- if (objmap->ht) {
- if (objmap->nodetype == XML_ENTITY_NODE) {
- itemnode = (xmlNodePtr)xmlHashLookup(objmap->ht, (xmlChar *) named);
- } else {
- notep = (xmlNotation *)xmlHashLookup(objmap->ht, (xmlChar *) named);
- if (notep) {
- itemnode = create_notation(notep->name, notep->PublicID, notep->SystemID);
- }
- }
- }
- } else {
- nodep = dom_object_get_node(objmap->baseobj);
- if (nodep) {
- itemnode = (xmlNodePtr)xmlHasNsProp(nodep, (xmlChar *) named, (xmlChar *) uri);
- }
- }
- }
- if (itemnode) {
- DOM_RET_OBJ(itemnode, &ret, objmap->baseobj);
- return;
- } else {
- RETVAL_NULL();
- }
- }
- PHP_FUNCTION(dom_namednodemap_set_named_item_ns)
- {
- DOM_NOT_IMPLEMENTED();
- }
- PHP_FUNCTION(dom_namednodemap_remove_named_item_ns)
- {
- DOM_NOT_IMPLEMENTED();
- }
- PHP_FUNCTION(dom_namednodemap_count)
- {
- zval *id;
- dom_object *intern;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &id, dom_namednodemap_class_entry) == FAILURE) {
- return;
- }
- intern = Z_DOMOBJ_P(id);
- if(dom_namednodemap_length_read(intern, return_value) == FAILURE) {
- RETURN_FALSE;
- }
- }
- #endif
|