PHP_FALIAS(dumpmem, domxml_dumpmem, NULL)
PHP_FALIAS(xpath_init, xpath_init, NULL)
PHP_FALIAS(xpath_new_context, xpath_new_context, NULL)
+ PHP_FALIAS(xptr_new_context, xpath_new_context, NULL)
{NULL, NULL, NULL}
};
{
/* don't know why that line was commented out in the previous version, so i left it (cmv) */
php_info_print_table_start();
- php_info_print_table_row(2, "DOM/XML Support", "enabled");
+ php_info_print_table_row(2, "DOM/XML, XPath, XPointer Support", "enabled");
php_info_print_table_row(2, "libmxl Version", LIBXML_DOTTED_VERSION );
php_info_print_table_end();
}
{
zval *id, **tmp;
int id_to_find;
- xmlNode *nodep;
+ xmlNodePtr nodep;
xmlAttr *attr;
int type;
int ret;
php_error(E_WARNING, "unable to find my handle property");
RETURN_FALSE;
}
- id_to_find = (*tmp)->value.lval;
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
} else {
RETURN_FALSE;
}
} else if ((ZEND_NUM_ARGS() != 1) || getParameters(ht, 1, &id) == FAILURE) {
WRONG_PARAM_COUNT;
} else {
- convert_to_long(id);
- id_to_find = id->value.lval;
+ if (zend_hash_find(id->value.obj.properties, "node", sizeof("node"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
}
- nodep = (xmlNode *)zend_list_find(id_to_find, &type);
- if (!nodep || type != le_domxmlnodep) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
- }
-
attr = nodep->properties;
if (!attr) {
RETURN_FALSE;
php_error(E_WARNING, "unable to find my handle property");
RETURN_FALSE;
}
- id_to_find = (*tmp)->value.lval;
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
} else {
RETURN_FALSE;
}
} else if ((ZEND_NUM_ARGS() != 1) || getParameters(ht, 1, &id) == FAILURE) {
WRONG_PARAM_COUNT;
} else {
- convert_to_long(id);
- id_to_find = id->value.lval;
- }
-
- nodep = (xmlNode *)zend_list_find(id_to_find, &type);
- if (!nodep || type != le_domxmlnodep) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
+ if (zend_hash_find(id->value.obj.properties, "node", sizeof("node"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
}
last = nodep->last;
php_error(E_WARNING, "unable to find my handle property");
RETURN_FALSE;
}
- id_to_find = (*tmp)->value.lval;
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
} else {
RETURN_FALSE;
}
} else if ((ZEND_NUM_ARGS() != 1) || getParameters(ht, 1, &id) == FAILURE) {
WRONG_PARAM_COUNT;
} else {
- convert_to_long(id);
- id_to_find = id->value.lval;
- }
-
- nodep = (xmlNode *)zend_list_find(id_to_find, &type);
- if (!nodep || type != le_domxmlnodep) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
+ if (zend_hash_find(id->value.obj.properties, "node", sizeof("node"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
}
last = nodep->parent;
if (ZEND_NUM_ARGS() == 0) {
id = getThis();
if (id) {
- if ((zend_hash_find(id->value.obj.properties, "node", sizeof("node"), (void **)&tmp) == FAILURE) &&
- (zend_hash_find(id->value.obj.properties, "doc", sizeof("doc"), (void **)&tmp) == FAILURE)) {
- php_error(E_WARNING, "unable to find my handle property");
- RETURN_FALSE;
- }
- id_to_find = (*tmp)->value.lval;
+ if (zend_hash_find(id->value.obj.properties, "node", sizeof("node"), (void **)&tmp) == FAILURE) {
+ if (zend_hash_find(id->value.obj.properties, "doc", sizeof("doc"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ } else
+ ZEND_FETCH_RESOURCE(nodep,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp)
+ } else
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
} else {
RETURN_FALSE;
}
} else if ((ZEND_NUM_ARGS() != 1) || getParameters(ht, 1, &id) == FAILURE) {
WRONG_PARAM_COUNT;
} else {
- convert_to_long(id);
- id_to_find = id->value.lval;
+ if ((zend_hash_find(id->value.obj.properties, "node", sizeof("node"), (void **)&tmp) == FAILURE) &&
+ (zend_hash_find(id->value.obj.properties, "doc", sizeof("doc"), (void **)&tmp) == FAILURE)) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
}
- nodep = (xmlNode *)zend_list_find(id_to_find, &type);
- if (!nodep || (type != le_domxmlnodep && type != le_domxmldocp)) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
- }
-
/* Even if the nodep is a XML_DOCUMENT_NODE the type is at the
same position.
*/
php_error(E_WARNING, "unable to find my handle property");
RETURN_FALSE;
}
- id_to_find = (*tmp)->value.lval;
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
} else {
RETURN_FALSE;
}
- convert_to_string(arg1);
} else if ((ZEND_NUM_ARGS() == 2) && getParameters(ht, 2, &id, &arg1) == SUCCESS) {
- convert_to_long(id);
- id_to_find = id->value.lval;
- convert_to_string(arg1);
+ if (zend_hash_find(id->value.obj.properties, "node", sizeof("node"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
} else {
WRONG_PARAM_COUNT;
}
- nodep = (xmlNode *)zend_list_find(id_to_find, &type);
- if (!nodep || type != le_domxmlnodep) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
- }
+ convert_to_string(arg1);
value = xmlGetProp(nodep, arg1->value.str.val);
if (!value) {
xmlNode *nodep;
xmlAttr *attr;
int type;
-
+
if ((ZEND_NUM_ARGS() == 2) && getParameters(ht, 2, &arg1, &arg2) == SUCCESS) {
id = getThis();
if (id) {
php_error(E_WARNING, "unable to find my handle property");
RETURN_FALSE;
}
- id_to_find = (*tmp)->value.lval;
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
} else {
RETURN_FALSE;
}
- convert_to_string(arg1);
- convert_to_string(arg2);
} else if ((ZEND_NUM_ARGS() == 3) && getParameters(ht, 3, &id, &arg1, &arg2) == SUCCESS) {
- convert_to_long(id);
- id_to_find = id->value.lval;
- convert_to_string(arg1);
- convert_to_string(arg2);
+ if (zend_hash_find(id->value.obj.properties, "node", sizeof("node"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
} else {
WRONG_PARAM_COUNT;
}
- nodep = (xmlNode *)zend_list_find(id_to_find, &type);
- if (!nodep || type != le_domxmlnodep) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
- }
+ convert_to_string(arg1);
+ convert_to_string(arg2);
attr = xmlSetProp(nodep, arg1->value.str.val, arg2->value.str.val);
if (!attr) {
id = getThis();
if (id) {
if (zend_hash_find(id->value.obj.properties, "node", sizeof("node"), (void **)&tmp) == FAILURE) {
- php_error(E_WARNING, "unable to find my node (%d)", id);
+ php_error(E_WARNING, "unable to find my handle property");
RETURN_FALSE;
}
- id_to_find = (*tmp)->value.lval;
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
} else {
RETURN_FALSE;
}
} else if ((ZEND_NUM_ARGS() != 1) || getParameters(ht, 1, &id) == FAILURE) {
WRONG_PARAM_COUNT;
} else {
- convert_to_long(id);
- id_to_find = id->value.lval;
- }
-
- nodep = (xmlNode *)zend_list_find(id_to_find, &type);
- if (!nodep || type != le_domxmlnodep) {
- php_error(E_WARNING, "unable to find node identifier (%d)", id_to_find);
- RETURN_FALSE;
+ if (zend_hash_find(id->value.obj.properties, "node", sizeof("node"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
}
if(0 > node_attributes(&return_value, nodep))
/* }}} */
/* {{{ proto string domxml_rootnew([int doc])
- Returns list of children nodes */
+ Returns root nodes */
PHP_FUNCTION(domxml_rootnew)
{
zval *id, **tmp;
int id_to_find;
- xmlDoc *nodep;
+ xmlDoc *docp;
xmlNode *last;
int type;
int ret;
php_error(E_WARNING, "unable to find my handle property");
RETURN_FALSE;
}
- id_to_find = (*tmp)->value.lval;
+ ZEND_FETCH_RESOURCE(docp,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp)
} else {
RETURN_FALSE;
}
} else if ((ZEND_NUM_ARGS() != 1) || getParameters(ht, 1, &id) == FAILURE) {
WRONG_PARAM_COUNT;
} else {
- convert_to_long(id);
- id_to_find = id->value.lval;
- }
-
- nodep = (xmlDoc *)zend_list_find(id_to_find, &type);
- if (!nodep || type != le_domxmldocp) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
+ if (zend_hash_find(id->value.obj.properties, "doc", sizeof("doc"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(docp,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp)
}
- last = nodep->children;
+ last = docp->children;
if (!last) {
RETURN_FALSE;
}
php_error(E_WARNING, "unable to find my handle property");
RETURN_FALSE;
}
- id_to_find = (*tmp)->value.lval;
+ ZEND_FETCH_RESOURCE(docp,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp)
} else {
RETURN_FALSE;
}
} else if ((ZEND_NUM_ARGS() != 1) || getParameters(ht, 1, &id) == FAILURE) {
WRONG_PARAM_COUNT;
} else {
- convert_to_long(id);
- id_to_find = id->value.lval;
- }
-
- docp = (xmlDoc *)zend_list_find(id_to_find, &type);
- if (!docp || type != le_domxmldocp) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
+ if (zend_hash_find(id->value.obj.properties, "doc", sizeof("doc"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(docp,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp)
}
node = docp->children;
php_error(E_WARNING, "unable to find my handle property");
RETURN_FALSE;
}
- id_to_find = (*tmp)->value.lval;
+ ZEND_FETCH_RESOURCE(docp,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp)
} else {
RETURN_FALSE;
}
} else if ((ZEND_NUM_ARGS() != 1) || getParameters(ht, 1, &id) == FAILURE) {
WRONG_PARAM_COUNT;
} else {
- convert_to_long(id);
- id_to_find = id->value.lval;
- }
-
- docp = (xmlDoc *)zend_list_find(id_to_find, &type);
- if (!docp || type != le_domxmldocp) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
+ if (zend_hash_find(id->value.obj.properties, "doc", sizeof("doc"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(docp,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp)
}
dtd = docp->intSubset;
php_error(E_WARNING, "unable to find my handle property");
RETURN_FALSE;
}
- id_to_find = (*tmp)->value.lval;
+ ZEND_FETCH_RESOURCE(docp,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp)
} else {
RETURN_FALSE;
}
} else if ((ZEND_NUM_ARGS() != 1) || getParameters(ht, 1, &id) == FAILURE) {
WRONG_PARAM_COUNT;
} else {
- convert_to_long(id);
- id_to_find = id->value.lval;
- }
-
- docp = (xmlDoc *)zend_list_find(id_to_find, &type);
- if (!docp || type != le_domxmldocp) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
+ if (zend_hash_find(id->value.obj.properties, "doc", sizeof("doc"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(docp,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp)
}
xmlDocDumpMemory(docp, &mem, &size);
xmlNode *child, *nodep;
int type;
int ret;
-
+
if (ZEND_NUM_ARGS() == 2) {
id = getThis();
if (id) {
php_error(E_WARNING, "unable to find my handle property");
RETURN_FALSE;
}
- id_to_find = (*tmp)->value.lval;
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
if(getParameters(ht, 2, &name, &content) == FAILURE)
WRONG_PARAM_COUNT;
} else {
} else if ((ZEND_NUM_ARGS() != 3) || getParameters(ht, 3, &id, &name, &content) == FAILURE) {
WRONG_PARAM_COUNT;
} else {
- convert_to_long(id);
- id_to_find = id->value.lval;
+ if (zend_hash_find(id->value.obj.properties, "node", sizeof("node"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(nodep,xmlNodePtr,tmp,-1, "DomNode", le_domxmlnodep)
}
convert_to_string(name);
convert_to_string(content);
- nodep = (xmlNode *)zend_list_find(id_to_find, &type);
- if (!nodep || type != le_domxmlnodep) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
- }
-
if(content->value.str.len)
child = xmlNewChild(nodep, NULL, name->value.str.val, content->value.str.val);
else
php_error(E_WARNING, "unable to find my handle property");
RETURN_FALSE;
}
- id_to_find = (*tmp)->value.lval;
+ ZEND_FETCH_RESOURCE(docp,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp)
if (getParameters(ht, 1, &name) == FAILURE)
WRONG_PARAM_COUNT;
} else {
} else if ((ZEND_NUM_ARGS() != 2) || getParameters(ht, 2, &id, &name) == FAILURE) {
WRONG_PARAM_COUNT;
} else {
- convert_to_long(id);
- id_to_find = id->value.lval;
+ if (zend_hash_find(id->value.obj.properties, "doc", sizeof("doc"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(docp,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp)
}
convert_to_string(name);
- docp = (xmlDoc *)zend_list_find(id_to_find, &type);
- if (!docp || type != le_domxmldocp) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
- }
-
node = xmlNewDocNode(docp, NULL, name->value.str.val, NULL);
if (!node) {
RETURN_FALSE;
while(last) {
zval *child;
+ int ret;
/* Each child is a node object */
MAKE_STD_ZVAL(child);
-/* ret = zend_list_insert(last, le_domxmlnodep); */
+ ret = zend_list_insert(last, le_domxmlnodep);
/* construct a node object for each child */
object_init_ex(child, domxmlnode_class_entry_ptr);
add_property_long(child, "type", last->type);
if(last->content)
add_property_stringl(child, "content", (char *) last->content, strlen(last->content), 1);
-/* add_property_resource(child, "node", ret); */
+ add_property_resource(child, "node", ret);
/* Get the namespace of the current node and add it as a property */
/* if(!node_namespace(&namespace, last))
php_error(E_WARNING, "unable to find my handle property");
RETURN_FALSE;
}
- id_to_find = (*tmp)->value.lval;
+ ZEND_FETCH_RESOURCE(docp,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp)
} else {
RETURN_FALSE;
}
} else if ((ZEND_NUM_ARGS() != 1) || getParameters(ht, 1, &id) == FAILURE) {
WRONG_PARAM_COUNT;
} else {
- convert_to_long(id);
- id_to_find = id->value.lval;
+ if (zend_hash_find(id->value.obj.properties, "doc", sizeof("doc"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my handle property");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(docp,xmlDocPtr,tmp,-1, "DomDocument", le_domxmldocp)
}
- docp = (xmlDocPtr) zend_list_find(id_to_find, &type);
- if (!docp || type != le_domxmldocp) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
- }
-
#if defined(LIBXML_XPTR_ENABLED)
if(mode == PHP_XPTR)
ctx = xmlXPtrNewContext(docp, NULL, NULL);
id = getThis();
if (id) {
if (zend_hash_find(id->value.obj.properties, "xpathctx", sizeof("xpathctx"), (void **)&tmp) == FAILURE) {
- php_error(E_WARNING, "unable to find my handle property");
+ php_error(E_WARNING, "unable to find my xpath context");
RETURN_FALSE;
}
- id_to_find = (*tmp)->value.lval;
+ ZEND_FETCH_RESOURCE(ctxp,xmlXPathContextPtr,tmp,-1, "XPathContext", le_xpathctxp)
+// id_to_find = (*tmp)->value.lval;
if (getParameters(ht, 1, &str) == FAILURE)
WRONG_PARAM_COUNT;
} else {
} else if ((ZEND_NUM_ARGS() != 2) || getParameters(ht, 2, &id, &str) == FAILURE) {
WRONG_PARAM_COUNT;
} else {
- convert_to_long(id);
- id_to_find = id->value.lval;
+ if (zend_hash_find(id->value.obj.properties, "xpathctx", sizeof("xpathctx"), (void **)&tmp) == FAILURE) {
+ php_error(E_WARNING, "unable to find my own xpath context");
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE(ctxp,xmlXPathContextPtr,tmp,-1, "XPathContext", le_xpathctxp)
}
convert_to_string(str);
- ctxp = (xmlXPathContextPtr) zend_list_find(id_to_find, &type);
- if (!ctxp || type != le_xpathctxp) {
- php_error(E_WARNING, "unable to find identifier (%d)", id_to_find);
- RETURN_FALSE;
- }
-
#if defined(LIBXML_XPTR_ENABLED)
if(mode == PHP_XPTR) {
xpathobjp = xmlXPtrEval(BAD_CAST str->value.str.val, ctxp);
zval *arr;
xmlNodeSetPtr nodesetp;
+ MAKE_STD_ZVAL(arr);
if (array_init(arr) == FAILURE) {
xmlXPathFreeObject(xpathobjp);
RETURN_FALSE;