mirror of
https://github.com/php/php-src.git
synced 2025-08-21 01:45:16 +02:00
WS & CS fixes..
This commit is contained in:
parent
e451d88399
commit
6638543a72
1 changed files with 262 additions and 233 deletions
|
@ -22,14 +22,12 @@
|
||||||
* - Support Notation Nodes
|
* - Support Notation Nodes
|
||||||
* */
|
* */
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "ext/standard/php_rand.h"
|
#include "ext/standard/php_rand.h"
|
||||||
|
|
||||||
#include "php_domxml.h"
|
#include "php_domxml.h"
|
||||||
|
|
||||||
#if HAVE_DOMXML
|
#if HAVE_DOMXML
|
||||||
|
@ -38,7 +36,6 @@
|
||||||
#define PHP_XPTR 2
|
#define PHP_XPTR 2
|
||||||
|
|
||||||
/* General macros used by domxml */
|
/* 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_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))) { \
|
#define DOMXML_DOMOBJ_NEW(zval, obj, ret) if (NULL == (zval = php_domobject_new(obj, ret, zval TSRMLS_CC))) { \
|
||||||
|
@ -163,7 +160,6 @@ static int le_domxmlparserp;
|
||||||
static int le_domxmlentityrefp;
|
static int le_domxmlentityrefp;
|
||||||
/*static int le_domxmlnsp;*/
|
/*static int le_domxmlnsp;*/
|
||||||
|
|
||||||
|
|
||||||
#if HAVE_DOMXSLT
|
#if HAVE_DOMXSLT
|
||||||
static int le_domxsltstylesheetp;
|
static int le_domxsltstylesheetp;
|
||||||
#endif
|
#endif
|
||||||
|
@ -200,7 +196,6 @@ zend_class_entry *xpathobject_class_entry;
|
||||||
zend_class_entry *domxsltstylesheet_class_entry;
|
zend_class_entry *domxsltstylesheet_class_entry;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int node_attributes(zval **attributes, xmlNode *nodep TSRMLS_DC);
|
static int node_attributes(zval **attributes, xmlNode *nodep TSRMLS_DC);
|
||||||
static int node_children(zval **children, xmlNode *nodep TSRMLS_DC);
|
static int node_children(zval **children, xmlNode *nodep TSRMLS_DC);
|
||||||
|
|
||||||
|
@ -548,7 +543,6 @@ zend_module_entry domxml_module_entry = {
|
||||||
ZEND_GET_MODULE(domxml)
|
ZEND_GET_MODULE(domxml)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void dom_object_set_data(void *obj, zval *wrapper)
|
static void dom_object_set_data(void *obj, zval *wrapper)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -559,34 +553,36 @@ static void dom_object_set_data(void *obj, zval *wrapper)
|
||||||
((xmlNodePtr) obj)->_private = wrapper;
|
((xmlNodePtr) obj)->_private = wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static zval *dom_object_get_data(void *obj)
|
static zval *dom_object_get_data(void *obj)
|
||||||
{
|
{
|
||||||
/* char tmp[20];
|
/* char tmp[20];
|
||||||
sprintf(tmp, "%08X", obj);
|
sprintf(tmp, "%08X", obj);
|
||||||
fprintf(stderr, "Trying getting %s from object ...", tmp);
|
fprintf(stderr, "Trying getting %s from object ...", tmp);
|
||||||
if(((xmlNodePtr) obj)->_private)
|
if (((xmlNodePtr) obj)->_private) {
|
||||||
fprintf(stderr, " found\n");
|
fprintf(stderr, " found\n");
|
||||||
else
|
} else {
|
||||||
fprintf(stderr, " not found\n");
|
fprintf(stderr, " not found\n");
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
return ((zval *) (((xmlNodePtr) obj)->_private));
|
return ((zval *) (((xmlNodePtr) obj)->_private));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void node_wrapper_dtor(xmlNodePtr node)
|
static inline void node_wrapper_dtor(xmlNodePtr node)
|
||||||
{
|
{
|
||||||
zval *wrapper;
|
zval *wrapper;
|
||||||
int refcount = 0;
|
int refcount = 0;
|
||||||
|
|
||||||
/* FIXME: type check probably unnecessary here? */
|
/* FIXME: type check probably unnecessary here? */
|
||||||
if (!node) /* || Z_TYPE_P(node) == XML_DTD_NODE)*/
|
if (!node) { /* || Z_TYPE_P(node) == XML_DTD_NODE) */
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wrapper = dom_object_get_data(node);
|
wrapper = dom_object_get_data(node);
|
||||||
|
|
||||||
if (wrapper != NULL ) {
|
if (wrapper != NULL ) {
|
||||||
refcount = wrapper->refcount;
|
refcount = wrapper->refcount;
|
||||||
zval_ptr_dtor(&wrapper);
|
zval_ptr_dtor(&wrapper);
|
||||||
|
|
||||||
/* only set it to null, if refcount was 1 before, otherwise it has still needed references */
|
/* only set it to null, if refcount was 1 before, otherwise it has still needed references */
|
||||||
if (refcount == 1) {
|
if (refcount == 1) {
|
||||||
dom_object_set_data(node, NULL);
|
dom_object_set_data(node, NULL);
|
||||||
|
@ -595,7 +591,6 @@ static inline void node_wrapper_dtor(xmlNodePtr node)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void attr_list_wrapper_dtor(xmlAttrPtr attr)
|
static inline void attr_list_wrapper_dtor(xmlAttrPtr attr)
|
||||||
{
|
{
|
||||||
while (attr != NULL) {
|
while (attr != NULL) {
|
||||||
|
@ -604,7 +599,6 @@ static inline void attr_list_wrapper_dtor(xmlAttrPtr attr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void node_list_wrapper_dtor(xmlNodePtr node)
|
static inline void node_list_wrapper_dtor(xmlNodePtr node)
|
||||||
{
|
{
|
||||||
while (node != NULL) {
|
while (node != NULL) {
|
||||||
|
@ -635,8 +629,7 @@ static xmlNodeSetPtr php_get_elements_by_tagname(xmlNodePtr n, xmlChar* name, xm
|
||||||
if (xmlStrcmp( name, cld->name) == 0) {
|
if (xmlStrcmp( name, cld->name) == 0) {
|
||||||
if (rv == NULL) {
|
if (rv == NULL) {
|
||||||
rv = xmlXPathNodeSetCreate(cld);
|
rv = xmlXPathNodeSetCreate(cld);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
xmlXPathNodeSetAdd(rv, cld);
|
xmlXPathNodeSetAdd(rv, cld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -658,7 +651,6 @@ static void php_free_xml_doc(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void php_free_xml_node(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
static void php_free_xml_node(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||||
{
|
{
|
||||||
xmlNodePtr node = (xmlNodePtr) rsrc->ptr;
|
xmlNodePtr node = (xmlNodePtr) rsrc->ptr;
|
||||||
|
@ -673,7 +665,6 @@ static void php_free_xml_node(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||||
} else {
|
} else {
|
||||||
node_wrapper_dtor(node);
|
node_wrapper_dtor(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void php_free_xml_attr(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
static void php_free_xml_attr(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||||
|
@ -687,7 +678,6 @@ static void php_free_xml_attr(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(LIBXML_XPATH_ENABLED)
|
#if defined(LIBXML_XPATH_ENABLED)
|
||||||
static void php_free_xpath_context(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
static void php_free_xpath_context(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||||
{
|
{
|
||||||
|
@ -743,10 +733,11 @@ static zval *xsltstylesheet_get_data(void *obj)
|
||||||
char tmp[20];
|
char tmp[20];
|
||||||
sprintf(tmp, "%08X", obj);
|
sprintf(tmp, "%08X", obj);
|
||||||
fprintf(stderr, "Trying getting %s from object ...", tmp);
|
fprintf(stderr, "Trying getting %s from object ...", tmp);
|
||||||
if(((xmlNodePtr) obj)->_private)
|
if (((xmlNodePtr) obj)->_private) {
|
||||||
fprintf(stderr, " found\n");
|
fprintf(stderr, " found\n");
|
||||||
else
|
} else {
|
||||||
fprintf(stderr, " not found\n");
|
fprintf(stderr, " not found\n");
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
return ((zval *) (((xsltStylesheetPtr) obj)->_private));
|
return ((zval *) (((xsltStylesheetPtr) obj)->_private));
|
||||||
}
|
}
|
||||||
|
@ -801,7 +792,6 @@ static void php_xsltstylesheet_set_object(zval *wrapper, void *obj, int rsrc_typ
|
||||||
}
|
}
|
||||||
#endif /* HAVE_DOMXSLT */
|
#endif /* HAVE_DOMXSLT */
|
||||||
|
|
||||||
|
|
||||||
void *php_xpath_get_object(zval *wrapper, int rsrc_type1, int rsrc_type2 TSRMLS_DC)
|
void *php_xpath_get_object(zval *wrapper, int rsrc_type1, int rsrc_type2 TSRMLS_DC)
|
||||||
{
|
{
|
||||||
void *obj;
|
void *obj;
|
||||||
|
@ -888,10 +878,11 @@ static zval *xpath_context_get_data(void *obj)
|
||||||
char tmp[20];
|
char tmp[20];
|
||||||
sprintf(tmp, "%08X", obj);
|
sprintf(tmp, "%08X", obj);
|
||||||
fprintf(stderr, "Trying getting %s from hash ...", tmp);
|
fprintf(stderr, "Trying getting %s from hash ...", tmp);
|
||||||
if(((xmlXPathContextPtr) obj)->user)
|
if (((xmlXPathContextPtr) obj)->user) {
|
||||||
fprintf(stderr, " found\n");
|
fprintf(stderr, " found\n");
|
||||||
else
|
} else {
|
||||||
fprintf(stderr, " not found\n");
|
fprintf(stderr, " not found\n");
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
return ((zval *) (((xmlXPathContextPtr) obj)->user));
|
return ((zval *) (((xmlXPathContextPtr) obj)->user));
|
||||||
}
|
}
|
||||||
|
@ -1015,8 +1006,7 @@ static char **php_xmlparser_make_params(zval *idvars TSRMLS_DC)
|
||||||
if (zend_hash_get_current_key(parht, &string_key, &num_key, 1) != HASH_KEY_IS_STRING) {
|
if (zend_hash_get_current_key(parht, &string_key, &num_key, 1) != HASH_KEY_IS_STRING) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument or parameter array");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument or parameter array");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SEPARATE_ZVAL(value);
|
SEPARATE_ZVAL(value);
|
||||||
convert_to_string_ex(value);
|
convert_to_string_ex(value);
|
||||||
expr = Z_STRVAL_PP(value);
|
expr = Z_STRVAL_PP(value);
|
||||||
|
@ -1086,7 +1076,6 @@ static void php_dom_set_object(zval *wrapper, void *obj, int rsrc_type TSRMLS_DC
|
||||||
dom_object_set_data(obj, wrapper);
|
dom_object_set_data(obj, wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PHPAPI zval *php_domobject_new(xmlNodePtr obj, int *found, zval *wrapper_in TSRMLS_DC)
|
PHPAPI zval *php_domobject_new(xmlNodePtr obj, int *found, zval *wrapper_in TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval *wrapper;
|
zval *wrapper;
|
||||||
|
@ -1096,12 +1085,11 @@ PHPAPI zval *php_domobject_new(xmlNodePtr obj, int *found, zval *wrapper_in TSR
|
||||||
*found = 0;
|
*found = 0;
|
||||||
|
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
if(!wrapper_in)
|
if (!wrapper_in) {
|
||||||
{
|
|
||||||
MAKE_STD_ZVAL(wrapper);
|
MAKE_STD_ZVAL(wrapper);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
wrapper = wrapper_in;
|
wrapper = wrapper_in;
|
||||||
|
}
|
||||||
ZVAL_NULL(wrapper);
|
ZVAL_NULL(wrapper);
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
@ -1112,46 +1100,46 @@ PHPAPI zval *php_domobject_new(xmlNodePtr obj, int *found, zval *wrapper_in TSR
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!wrapper_in)
|
if (!wrapper_in) {
|
||||||
{
|
|
||||||
MAKE_STD_ZVAL(wrapper);
|
MAKE_STD_ZVAL(wrapper);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
wrapper = wrapper_in;
|
wrapper = wrapper_in;
|
||||||
|
}
|
||||||
|
|
||||||
switch (Z_TYPE_P(obj)) {
|
switch (Z_TYPE_P(obj)) {
|
||||||
|
|
||||||
case XML_ELEMENT_NODE:
|
case XML_ELEMENT_NODE: {
|
||||||
{
|
|
||||||
xmlNodePtr nodep = obj;
|
xmlNodePtr nodep = obj;
|
||||||
if(!wrapper_in)
|
if (!wrapper_in) {
|
||||||
object_init_ex(wrapper, domxmlelement_class_entry);
|
object_init_ex(wrapper, domxmlelement_class_entry);
|
||||||
|
}
|
||||||
rsrc_type = le_domxmlelementp;
|
rsrc_type = le_domxmlelementp;
|
||||||
add_property_long(wrapper, "type", Z_TYPE_P(nodep));
|
add_property_long(wrapper, "type", Z_TYPE_P(nodep));
|
||||||
add_property_stringl(wrapper, "tagname", (char *) nodep->name, strlen(nodep->name), 1);
|
add_property_stringl(wrapper, "tagname", (char *) nodep->name, strlen(nodep->name), 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case XML_TEXT_NODE:
|
case XML_TEXT_NODE: {
|
||||||
{
|
|
||||||
xmlNodePtr nodep = obj;
|
xmlNodePtr nodep = obj;
|
||||||
if(!wrapper_in)
|
if (!wrapper_in) {
|
||||||
object_init_ex(wrapper, domxmltext_class_entry);
|
object_init_ex(wrapper, domxmltext_class_entry);
|
||||||
|
}
|
||||||
rsrc_type = le_domxmltextp;
|
rsrc_type = le_domxmltextp;
|
||||||
content = xmlNodeGetContent(nodep);
|
content = xmlNodeGetContent(nodep);
|
||||||
add_property_long(wrapper, "type", Z_TYPE_P(nodep));
|
add_property_long(wrapper, "type", Z_TYPE_P(nodep));
|
||||||
add_property_stringl(wrapper, "name", "#text", 5, 1);
|
add_property_stringl(wrapper, "name", "#text", 5, 1);
|
||||||
if (content)
|
if (content) {
|
||||||
add_property_stringl(wrapper, "content", (char *) content, strlen(content), 1);
|
add_property_stringl(wrapper, "content", (char *) content, strlen(content), 1);
|
||||||
|
}
|
||||||
xmlFree(content);
|
xmlFree(content);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case XML_COMMENT_NODE:
|
case XML_COMMENT_NODE: {
|
||||||
{
|
|
||||||
xmlNodePtr nodep = obj;
|
xmlNodePtr nodep = obj;
|
||||||
if(!wrapper_in)
|
if (!wrapper_in) {
|
||||||
object_init_ex(wrapper, domxmlcomment_class_entry);
|
object_init_ex(wrapper, domxmlcomment_class_entry);
|
||||||
|
}
|
||||||
rsrc_type = le_domxmlcommentp;
|
rsrc_type = le_domxmlcommentp;
|
||||||
content = xmlNodeGetContent(nodep);
|
content = xmlNodeGetContent(nodep);
|
||||||
if (content) {
|
if (content) {
|
||||||
|
@ -1163,11 +1151,11 @@ PHPAPI zval *php_domobject_new(xmlNodePtr obj, int *found, zval *wrapper_in TSR
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case XML_PI_NODE:
|
case XML_PI_NODE: {
|
||||||
{
|
|
||||||
xmlNodePtr nodep = obj;
|
xmlNodePtr nodep = obj;
|
||||||
if(!wrapper_in)
|
if (!wrapper_in) {
|
||||||
object_init_ex(wrapper, domxmlpi_class_entry);
|
object_init_ex(wrapper, domxmlpi_class_entry);
|
||||||
|
}
|
||||||
rsrc_type = le_domxmlpip;
|
rsrc_type = le_domxmlpip;
|
||||||
content = xmlNodeGetContent(nodep);
|
content = xmlNodeGetContent(nodep);
|
||||||
add_property_stringl(wrapper, "name", (char *) nodep->name, strlen(nodep->name), 1);
|
add_property_stringl(wrapper, "name", (char *) nodep->name, strlen(nodep->name), 1);
|
||||||
|
@ -1178,22 +1166,22 @@ PHPAPI zval *php_domobject_new(xmlNodePtr obj, int *found, zval *wrapper_in TSR
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case XML_ENTITY_REF_NODE:
|
case XML_ENTITY_REF_NODE: {
|
||||||
{
|
|
||||||
xmlNodePtr nodep = obj;
|
xmlNodePtr nodep = obj;
|
||||||
if(!wrapper_in)
|
if (!wrapper_in) {
|
||||||
object_init_ex(wrapper, domxmlentityref_class_entry);
|
object_init_ex(wrapper, domxmlentityref_class_entry);
|
||||||
|
}
|
||||||
rsrc_type = le_domxmlentityrefp;
|
rsrc_type = le_domxmlentityrefp;
|
||||||
add_property_stringl(wrapper, "name", (char *) nodep->name, strlen(nodep->name), 1);
|
add_property_stringl(wrapper, "name", (char *) nodep->name, strlen(nodep->name), 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case XML_ENTITY_DECL:
|
case XML_ENTITY_DECL:
|
||||||
case XML_ELEMENT_DECL:
|
case XML_ELEMENT_DECL: {
|
||||||
{
|
|
||||||
xmlNodePtr nodep = obj;
|
xmlNodePtr nodep = obj;
|
||||||
if(!wrapper_in)
|
if (!wrapper_in) {
|
||||||
object_init_ex(wrapper, domxmlnode_class_entry);
|
object_init_ex(wrapper, domxmlnode_class_entry);
|
||||||
|
}
|
||||||
rsrc_type = le_domxmlnodep;
|
rsrc_type = le_domxmlnodep;
|
||||||
add_property_long(wrapper, "type", Z_TYPE_P(nodep));
|
add_property_long(wrapper, "type", Z_TYPE_P(nodep));
|
||||||
add_property_stringl(wrapper, "name", (char *) nodep->name, strlen(nodep->name), 1);
|
add_property_stringl(wrapper, "name", (char *) nodep->name, strlen(nodep->name), 1);
|
||||||
|
@ -1207,11 +1195,11 @@ PHPAPI zval *php_domobject_new(xmlNodePtr obj, int *found, zval *wrapper_in TSR
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case XML_ATTRIBUTE_NODE:
|
case XML_ATTRIBUTE_NODE: {
|
||||||
{
|
|
||||||
xmlAttrPtr attrp = (xmlAttrPtr) obj;
|
xmlAttrPtr attrp = (xmlAttrPtr) obj;
|
||||||
if(!wrapper_in)
|
if (!wrapper_in) {
|
||||||
object_init_ex(wrapper, domxmlattr_class_entry);
|
object_init_ex(wrapper, domxmlattr_class_entry);
|
||||||
|
}
|
||||||
rsrc_type = le_domxmlattrp;
|
rsrc_type = le_domxmlattrp;
|
||||||
add_property_long(wrapper, "type", Z_TYPE_P(attrp));
|
add_property_long(wrapper, "type", Z_TYPE_P(attrp));
|
||||||
add_property_stringl(wrapper, "name", (char *) attrp->name, strlen(attrp->name), 1);
|
add_property_stringl(wrapper, "name", (char *) attrp->name, strlen(attrp->name), 1);
|
||||||
|
@ -1224,27 +1212,30 @@ PHPAPI zval *php_domobject_new(xmlNodePtr obj, int *found, zval *wrapper_in TSR
|
||||||
}
|
}
|
||||||
|
|
||||||
case XML_DOCUMENT_NODE:
|
case XML_DOCUMENT_NODE:
|
||||||
case XML_HTML_DOCUMENT_NODE:
|
case XML_HTML_DOCUMENT_NODE: {
|
||||||
{
|
|
||||||
xmlDocPtr docp = (xmlDocPtr) obj;
|
xmlDocPtr docp = (xmlDocPtr) obj;
|
||||||
|
if (!wrapper_in) {
|
||||||
if(!wrapper_in)
|
|
||||||
object_init_ex(wrapper, domxmldoc_class_entry);
|
object_init_ex(wrapper, domxmldoc_class_entry);
|
||||||
|
}
|
||||||
rsrc_type = le_domxmldocp;
|
rsrc_type = le_domxmldocp;
|
||||||
if (docp->name)
|
if (docp->name) {
|
||||||
add_property_stringl(wrapper, "name", (char *) docp->name, strlen(docp->name), 1);
|
add_property_stringl(wrapper, "name", (char *) docp->name, strlen(docp->name), 1);
|
||||||
else
|
} else {
|
||||||
add_property_stringl(wrapper, "name", "#document", 9, 1);
|
add_property_stringl(wrapper, "name", "#document", 9, 1);
|
||||||
if (docp->URL)
|
}
|
||||||
|
if (docp->URL) {
|
||||||
add_property_stringl(wrapper, "url", (char *) docp->URL, strlen(docp->URL), 1);
|
add_property_stringl(wrapper, "url", (char *) docp->URL, strlen(docp->URL), 1);
|
||||||
else
|
} else {
|
||||||
add_property_stringl(wrapper, "url", "", 0, 1);
|
add_property_stringl(wrapper, "url", "", 0, 1);
|
||||||
if (docp->version)
|
}
|
||||||
|
if (docp->version) {
|
||||||
add_property_stringl(wrapper, "version", (char *) docp->version, strlen(docp->version), 1);
|
add_property_stringl(wrapper, "version", (char *) docp->version, strlen(docp->version), 1);
|
||||||
else
|
} else {
|
||||||
add_property_stringl(wrapper, "version", "", 0, 1);
|
add_property_stringl(wrapper, "version", "", 0, 1);
|
||||||
if (docp->encoding)
|
}
|
||||||
|
if (docp->encoding) {
|
||||||
add_property_stringl(wrapper, "encoding", (char *) docp->encoding, strlen(docp->encoding), 1);
|
add_property_stringl(wrapper, "encoding", (char *) docp->encoding, strlen(docp->encoding), 1);
|
||||||
|
}
|
||||||
add_property_long(wrapper, "standalone", docp->standalone);
|
add_property_long(wrapper, "standalone", docp->standalone);
|
||||||
add_property_long(wrapper, "type", Z_TYPE_P(docp));
|
add_property_long(wrapper, "type", Z_TYPE_P(docp));
|
||||||
add_property_long(wrapper, "compression", docp->compression);
|
add_property_long(wrapper, "compression", docp->compression);
|
||||||
|
@ -1265,33 +1256,36 @@ PHPAPI zval *php_domobject_new(xmlNodePtr obj, int *found, zval *wrapper_in TSR
|
||||||
* rather is a DocumentType
|
* rather is a DocumentType
|
||||||
*/
|
*/
|
||||||
case XML_DTD_NODE:
|
case XML_DTD_NODE:
|
||||||
case XML_DOCUMENT_TYPE_NODE:
|
case XML_DOCUMENT_TYPE_NODE: {
|
||||||
{
|
|
||||||
xmlDtdPtr dtd = (xmlDtdPtr) obj;
|
xmlDtdPtr dtd = (xmlDtdPtr) obj;
|
||||||
if(!wrapper_in)
|
if (!wrapper_in) {
|
||||||
object_init_ex(wrapper, domxmldoctype_class_entry);
|
object_init_ex(wrapper, domxmldoctype_class_entry);
|
||||||
|
}
|
||||||
/* rsrc_type = le_domxmldtdp; */
|
/* rsrc_type = le_domxmldtdp; */
|
||||||
rsrc_type = le_domxmldoctypep;
|
rsrc_type = le_domxmldoctypep;
|
||||||
/* add_property_long(wrapper, "type", Z_TYPE_P(dtd)); */
|
/* add_property_long(wrapper, "type", Z_TYPE_P(dtd)); */
|
||||||
add_property_long(wrapper, "type", XML_DOCUMENT_TYPE_NODE);
|
add_property_long(wrapper, "type", XML_DOCUMENT_TYPE_NODE);
|
||||||
if (dtd->ExternalID)
|
if (dtd->ExternalID) {
|
||||||
add_property_string(wrapper, "publicId", (char *) dtd->ExternalID, 1);
|
add_property_string(wrapper, "publicId", (char *) dtd->ExternalID, 1);
|
||||||
else
|
} else {
|
||||||
add_property_string(wrapper, "publicId", "", 1);
|
add_property_string(wrapper, "publicId", "", 1);
|
||||||
if (dtd->SystemID)
|
}
|
||||||
|
if (dtd->SystemID) {
|
||||||
add_property_string(wrapper, "systemId", (char *) dtd->SystemID, 1);
|
add_property_string(wrapper, "systemId", (char *) dtd->SystemID, 1);
|
||||||
else
|
} else {
|
||||||
add_property_string(wrapper, "systemId", "", 1);
|
add_property_string(wrapper, "systemId", "", 1);
|
||||||
if (dtd->name)
|
}
|
||||||
|
if (dtd->name) {
|
||||||
add_property_string(wrapper, "name", (char *) dtd->name, 1);
|
add_property_string(wrapper, "name", (char *) dtd->name, 1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case XML_CDATA_SECTION_NODE:
|
case XML_CDATA_SECTION_NODE: {
|
||||||
{
|
|
||||||
xmlNodePtr nodep = obj;
|
xmlNodePtr nodep = obj;
|
||||||
if(!wrapper_in)
|
if (!wrapper_in) {
|
||||||
object_init_ex(wrapper, domxmlcdata_class_entry);
|
object_init_ex(wrapper, domxmlcdata_class_entry);
|
||||||
|
}
|
||||||
rsrc_type = le_domxmlcdatap;
|
rsrc_type = le_domxmlcdatap;
|
||||||
content = xmlNodeGetContent(nodep);
|
content = xmlNodeGetContent(nodep);
|
||||||
add_property_long(wrapper, "type", Z_TYPE_P(nodep));
|
add_property_long(wrapper, "type", Z_TYPE_P(nodep));
|
||||||
|
@ -1405,26 +1399,30 @@ static void domxml_error_validate(void *ctx, const char *msg, ...)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlDocPtr php_dom_xmlSAXParse(xmlSAXHandlerPtr sax, const char *buffer, int size, int recovery, void *data) {
|
xmlDocPtr php_dom_xmlSAXParse(xmlSAXHandlerPtr sax, const char *buffer, int size, int recovery, void *data)
|
||||||
|
{
|
||||||
xmlDocPtr ret;
|
xmlDocPtr ret;
|
||||||
xmlParserCtxtPtr ctxt;
|
xmlParserCtxtPtr ctxt;
|
||||||
domxml_ErrorCtxt errorCtxt;
|
domxml_ErrorCtxt errorCtxt;
|
||||||
char *directory = NULL;
|
char *directory = NULL;
|
||||||
|
|
||||||
xmlInitParser();
|
xmlInitParser();
|
||||||
|
|
||||||
/* if size == -1, we assume, it's a filename not a inmemory xml doc */
|
/* if size == -1, we assume, it's a filename not a inmemory xml doc */
|
||||||
if (size == -1) {
|
if (size == -1) {
|
||||||
ctxt = (xmlParserCtxt *) xmlCreateFileParserCtxt(buffer);
|
ctxt = (xmlParserCtxt *) xmlCreateFileParserCtxt(buffer);
|
||||||
} else {
|
} else {
|
||||||
ctxt = (xmlParserCtxt *) xmlCreateMemoryParserCtxt((xmlChar *) buffer, size);
|
ctxt = (xmlParserCtxt *) xmlCreateMemoryParserCtxt((xmlChar *) buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctxt == NULL) {
|
if (ctxt == NULL) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sax != NULL) {
|
if (sax != NULL) {
|
||||||
if (ctxt->sax != NULL)
|
if (ctxt->sax != NULL) {
|
||||||
xmlFree(ctxt->sax);
|
xmlFree(ctxt->sax);
|
||||||
|
}
|
||||||
ctxt->sax = sax;
|
ctxt->sax = sax;
|
||||||
}
|
}
|
||||||
if (data!=NULL) {
|
if (data!=NULL) {
|
||||||
|
@ -1433,11 +1431,13 @@ xmlDocPtr php_dom_xmlSAXParse(xmlSAXHandlerPtr sax, const char *buffer, int size
|
||||||
|
|
||||||
/* store directory name */
|
/* store directory name */
|
||||||
if (size == -1) {
|
if (size == -1) {
|
||||||
if ((ctxt->directory == NULL) && (directory == NULL))
|
if ((ctxt->directory == NULL) && (directory == NULL)) {
|
||||||
directory = xmlParserGetDirectory(buffer);
|
directory = xmlParserGetDirectory(buffer);
|
||||||
if ((ctxt->directory == NULL) && (directory != NULL))
|
}
|
||||||
|
if ((ctxt->directory == NULL) && (directory != NULL)) {
|
||||||
ctxt->directory = (char *) xmlStrdup((xmlChar *) directory);
|
ctxt->directory = (char *) xmlStrdup((xmlChar *) directory);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
errorCtxt.valid = &ctxt->vctxt;
|
errorCtxt.valid = &ctxt->vctxt;
|
||||||
errorCtxt.errors = data;
|
errorCtxt.errors = data;
|
||||||
errorCtxt.parser = ctxt;
|
errorCtxt.parser = ctxt;
|
||||||
|
@ -1457,8 +1457,10 @@ xmlDocPtr php_dom_xmlSAXParse(xmlSAXHandlerPtr sax, const char *buffer, int size
|
||||||
xmlFreeDoc(ctxt->myDoc);
|
xmlFreeDoc(ctxt->myDoc);
|
||||||
ctxt->myDoc = NULL;
|
ctxt->myDoc = NULL;
|
||||||
}
|
}
|
||||||
if (sax != NULL)
|
|
||||||
|
if (sax != NULL) {
|
||||||
ctxt->sax = NULL;
|
ctxt->sax = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
xmlFreeParserCtxt(ctxt);
|
xmlFreeParserCtxt(ctxt);
|
||||||
|
|
||||||
|
@ -1692,8 +1694,7 @@ PHP_MINFO_FUNCTION(domxml)
|
||||||
/* {{{ proto array domxml_attr_name(void)
|
/* {{{ proto array domxml_attr_name(void)
|
||||||
Returns list of attribute names
|
Returns list of attribute names
|
||||||
Notice: domxml_node_name() does exactly the same for attribute-nodes,
|
Notice: domxml_node_name() does exactly the same for attribute-nodes,
|
||||||
is this function here still needed, or would an alias be enough?
|
is this function here still needed, or would an alias be enough? */
|
||||||
*/
|
|
||||||
PHP_FUNCTION(domxml_attr_name)
|
PHP_FUNCTION(domxml_attr_name)
|
||||||
{
|
{
|
||||||
zval *id;
|
zval *id;
|
||||||
|
@ -2127,8 +2128,9 @@ PHP_FUNCTION(domxml_node_has_attributes)
|
||||||
|
|
||||||
DOMXML_NO_ARGS();
|
DOMXML_NO_ARGS();
|
||||||
|
|
||||||
if (Z_TYPE_P(nodep) != XML_ELEMENT_NODE)
|
if (Z_TYPE_P(nodep) != XML_ELEMENT_NODE) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (nodep->properties) {
|
if (nodep->properties) {
|
||||||
RETURN_TRUE;
|
RETURN_TRUE;
|
||||||
|
@ -2243,10 +2245,11 @@ PHP_FUNCTION(domxml_node_children)
|
||||||
/* Even if the nodep is a XML_DOCUMENT_NODE the type is at the
|
/* Even if the nodep is a XML_DOCUMENT_NODE the type is at the
|
||||||
same position.
|
same position.
|
||||||
*/
|
*/
|
||||||
if ((Z_TYPE_P(nodep) == XML_DOCUMENT_NODE) || (Z_TYPE_P(nodep) == XML_HTML_DOCUMENT_NODE))
|
if ((Z_TYPE_P(nodep) == XML_DOCUMENT_NODE) || (Z_TYPE_P(nodep) == XML_HTML_DOCUMENT_NODE)) {
|
||||||
last = ((xmlDoc *) nodep)->children;
|
last = ((xmlDoc *) nodep)->children;
|
||||||
else
|
} else {
|
||||||
last = nodep->children;
|
last = nodep->children;
|
||||||
|
}
|
||||||
|
|
||||||
array_init(return_value);
|
array_init(return_value);
|
||||||
|
|
||||||
|
@ -2454,8 +2457,9 @@ PHP_FUNCTION(domxml_node_insert_before)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_child == NULL)
|
if (new_child == NULL) {
|
||||||
new_child = xmlAddPrevSibling(refp, child);
|
new_child = xmlAddPrevSibling(refp, child);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* first unlink node, if child is already a child of parent
|
/* first unlink node, if child is already a child of parent
|
||||||
for some strange reason, this is needed
|
for some strange reason, this is needed
|
||||||
|
@ -2976,12 +2980,14 @@ struct _idsIterator {
|
||||||
xmlNode *element;
|
xmlNode *element;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void idsHashScanner(void *payload, void *data, xmlChar *name) {
|
static void idsHashScanner(void *payload, void *data, xmlChar *name)
|
||||||
|
{
|
||||||
idsIterator *priv = (idsIterator *) data;
|
idsIterator *priv = (idsIterator *) data;
|
||||||
|
|
||||||
if (priv->element == NULL && xmlStrEqual (name, priv->elementId))
|
if (priv->element == NULL && xmlStrEqual (name, priv->elementId)) {
|
||||||
priv->element = ((xmlNode *)((xmlID *)payload)->attr)->parent;
|
priv->element = ((xmlNode *)((xmlID *)payload)->attr)->parent;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* {{{ proto string domxml_doc_get_element_by_id(string id)
|
/* {{{ proto string domxml_doc_get_element_by_id(string id)
|
||||||
Returns element for given id or false if not found */
|
Returns element for given id or false if not found */
|
||||||
|
@ -3279,11 +3285,11 @@ PHP_FUNCTION(domxml_doc_create_element_ns)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
/* if no namespace with the same uri was found, we have to create a new one.
|
/* if no namespace with the same uri was found, we have to create a new one.
|
||||||
I do this here with "a" + a random number. this is not very sophisticated,
|
* I do this here with "a" + a random number. this is not very sophisticated,
|
||||||
therefore if someone has a better idea in creating unique prefixes, here's your
|
* therefore if someone has a better idea in creating unique prefixes, here's your
|
||||||
chance (a0,a1, etc would be good enough, this is the way mozilla does it). I'm
|
* chance (a0,a1, etc would be good enough, this is the way mozilla does it). I'm
|
||||||
to lazy right now to think of a better solution... */
|
* to lazy right now to think of a better solution...
|
||||||
|
*/
|
||||||
if (nsptr == NULL) {
|
if (nsptr == NULL) {
|
||||||
/* if there was a prefix provided, take that, otherwise generate a new one
|
/* if there was a prefix provided, take that, otherwise generate a new one
|
||||||
this is not w3c-like, since the have no option to provide a prefix, but
|
this is not w3c-like, since the have no option to provide a prefix, but
|
||||||
|
@ -3788,18 +3794,21 @@ PHP_FUNCTION(xmldoc)
|
||||||
array_init(errors);
|
array_init(errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode & DOMXML_LOAD_DONT_KEEP_BLANKS)
|
if (mode & DOMXML_LOAD_DONT_KEEP_BLANKS) {
|
||||||
oldvalue_keepblanks = xmlKeepBlanksDefault(0);
|
oldvalue_keepblanks = xmlKeepBlanksDefault(0);
|
||||||
else
|
} else {
|
||||||
oldvalue_keepblanks = xmlKeepBlanksDefault(1);
|
oldvalue_keepblanks = xmlKeepBlanksDefault(1);
|
||||||
|
}
|
||||||
|
|
||||||
if(mode & DOMXML_LOAD_SUBSTITUTE_ENTITIES)
|
if (mode & DOMXML_LOAD_SUBSTITUTE_ENTITIES) {
|
||||||
prevSubstValue = xmlSubstituteEntitiesDefault (1);
|
prevSubstValue = xmlSubstituteEntitiesDefault (1);
|
||||||
else
|
} else {
|
||||||
prevSubstValue = xmlSubstituteEntitiesDefault (0);
|
prevSubstValue = xmlSubstituteEntitiesDefault (0);
|
||||||
|
}
|
||||||
|
|
||||||
if(mode & DOMXML_LOAD_COMPLETE_ATTRS)
|
if (mode & DOMXML_LOAD_COMPLETE_ATTRS) {
|
||||||
xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
|
xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
|
||||||
|
}
|
||||||
|
|
||||||
switch (mode & (DOMXML_LOAD_PARSING | DOMXML_LOAD_VALIDATING | DOMXML_LOAD_RECOVERING)) {
|
switch (mode & (DOMXML_LOAD_PARSING | DOMXML_LOAD_VALIDATING | DOMXML_LOAD_RECOVERING)) {
|
||||||
case DOMXML_LOAD_PARSING:
|
case DOMXML_LOAD_PARSING:
|
||||||
|
@ -3832,8 +3841,9 @@ PHP_FUNCTION(xmldoc)
|
||||||
xmlLoadExtDtdDefaultValue = prevLoadExtDtdValue;
|
xmlLoadExtDtdDefaultValue = prevLoadExtDtdValue;
|
||||||
xmlKeepBlanksDefault(oldvalue_keepblanks);
|
xmlKeepBlanksDefault(oldvalue_keepblanks);
|
||||||
|
|
||||||
if (!docp)
|
if (!docp) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* dtd = xmlGetIntSubset(docp);
|
/* dtd = xmlGetIntSubset(docp);
|
||||||
if (dtd) {
|
if (dtd) {
|
||||||
|
@ -3872,18 +3882,21 @@ PHP_FUNCTION(xmldocfile)
|
||||||
array_init(errors);
|
array_init(errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode & DOMXML_LOAD_DONT_KEEP_BLANKS)
|
if (mode & DOMXML_LOAD_DONT_KEEP_BLANKS) {
|
||||||
oldvalue_keepblanks = xmlKeepBlanksDefault(0);
|
oldvalue_keepblanks = xmlKeepBlanksDefault(0);
|
||||||
else
|
} else {
|
||||||
oldvalue_keepblanks = xmlKeepBlanksDefault(1);
|
oldvalue_keepblanks = xmlKeepBlanksDefault(1);
|
||||||
|
}
|
||||||
|
|
||||||
if(mode & DOMXML_LOAD_SUBSTITUTE_ENTITIES)
|
if (mode & DOMXML_LOAD_SUBSTITUTE_ENTITIES) {
|
||||||
prevSubstValue = xmlSubstituteEntitiesDefault (1);
|
prevSubstValue = xmlSubstituteEntitiesDefault (1);
|
||||||
else
|
} else {
|
||||||
prevSubstValue = xmlSubstituteEntitiesDefault (0);
|
prevSubstValue = xmlSubstituteEntitiesDefault (0);
|
||||||
|
}
|
||||||
|
|
||||||
if(mode & DOMXML_LOAD_COMPLETE_ATTRS)
|
if (mode & DOMXML_LOAD_COMPLETE_ATTRS) {
|
||||||
xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
|
xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
|
||||||
|
}
|
||||||
|
|
||||||
switch (mode & (DOMXML_LOAD_PARSING | DOMXML_LOAD_VALIDATING | DOMXML_LOAD_RECOVERING)) {
|
switch (mode & (DOMXML_LOAD_PARSING | DOMXML_LOAD_VALIDATING | DOMXML_LOAD_RECOVERING)) {
|
||||||
case DOMXML_LOAD_PARSING:
|
case DOMXML_LOAD_PARSING:
|
||||||
|
@ -3943,8 +3956,9 @@ PHP_FUNCTION(domxml_html_dump_mem)
|
||||||
|
|
||||||
htmlDocDumpMemory(docp, &mem, &size);
|
htmlDocDumpMemory(docp, &mem, &size);
|
||||||
if (!size) {
|
if (!size) {
|
||||||
if (mem)
|
if (mem) {
|
||||||
xmlFree(mem);
|
xmlFree(mem);
|
||||||
|
}
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
RETVAL_STRINGL(mem, size, 1);
|
RETVAL_STRINGL(mem, size, 1);
|
||||||
|
@ -3972,8 +3986,9 @@ PHP_FUNCTION(html_doc)
|
||||||
} else {
|
} else {
|
||||||
docp = htmlParseDoc(buffer, NULL);
|
docp = htmlParseDoc(buffer, NULL);
|
||||||
}
|
}
|
||||||
if (!docp)
|
if (!docp) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
DOMXML_RET_OBJ(rv, (xmlNodePtr) docp, &ret);
|
DOMXML_RET_OBJ(rv, (xmlNodePtr) docp, &ret);
|
||||||
}
|
}
|
||||||
|
@ -4000,15 +4015,19 @@ PHP_FUNCTION(html_doc_file)
|
||||||
DOMXML_RET_OBJ(rv, (xmlNodePtr) docp, &ret);
|
DOMXML_RET_OBJ(rv, (xmlNodePtr) docp, &ret);
|
||||||
|
|
||||||
add_property_resource(return_value, "doc", ret);
|
add_property_resource(return_value, "doc", ret);
|
||||||
if (docp->name)
|
if (docp->name) {
|
||||||
add_property_stringl(return_value, "name", (char *) docp->name, strlen(docp->name), 1);
|
add_property_stringl(return_value, "name", (char *) docp->name, strlen(docp->name), 1);
|
||||||
if (docp->URL)
|
}
|
||||||
|
if (docp->URL) {
|
||||||
add_property_stringl(return_value, "url", (char *) docp->URL, strlen(docp->URL), 1);
|
add_property_stringl(return_value, "url", (char *) docp->URL, strlen(docp->URL), 1);
|
||||||
if (docp->version)
|
}
|
||||||
|
if (docp->version) {
|
||||||
add_property_stringl(return_value, "version", (char *) docp->version, strlen(docp->version), 1);
|
add_property_stringl(return_value, "version", (char *) docp->version, strlen(docp->version), 1);
|
||||||
|
}
|
||||||
/* add_property_stringl(return_value, "version", (char *) docp->version, strlen(docp->version), 1);*/
|
/* add_property_stringl(return_value, "version", (char *) docp->version, strlen(docp->version), 1);*/
|
||||||
if (docp->encoding)
|
if (docp->encoding) {
|
||||||
add_property_stringl(return_value, "encoding", (char *) docp->encoding, strlen(docp->encoding), 1);
|
add_property_stringl(return_value, "encoding", (char *) docp->encoding, strlen(docp->encoding), 1);
|
||||||
|
}
|
||||||
add_property_long(return_value, "standalone", docp->standalone);
|
add_property_long(return_value, "standalone", docp->standalone);
|
||||||
add_property_long(return_value, "type", Z_TYPE_P(docp));
|
add_property_long(return_value, "type", Z_TYPE_P(docp));
|
||||||
add_property_long(return_value, "compression", docp->compression);
|
add_property_long(return_value, "compression", docp->compression);
|
||||||
|
@ -4047,8 +4066,9 @@ PHP_FUNCTION(domxml_node_text_concat)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content_len)
|
if (content_len) {
|
||||||
xmlTextConcat(nodep, content, content_len);
|
xmlTextConcat(nodep, content, content_len);
|
||||||
|
}
|
||||||
|
|
||||||
RETURN_TRUE;
|
RETURN_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -4134,8 +4154,8 @@ PHP_FUNCTION(domxml_doc_validate)
|
||||||
} else {
|
} else {
|
||||||
RETVAL_FALSE;
|
RETVAL_FALSE;
|
||||||
}
|
}
|
||||||
xmlDoValidityCheckingDefaultValue = oldvalue;
|
|
||||||
|
|
||||||
|
xmlDoValidityCheckingDefaultValue = oldvalue;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -4430,8 +4450,7 @@ PHP_FUNCTION(domxml_parser_end)
|
||||||
}
|
}
|
||||||
if (parserp->myDoc != NULL) {
|
if (parserp->myDoc != NULL) {
|
||||||
DOMXML_RET_OBJ(rv, (xmlNodePtr) parserp->myDoc, &ret);
|
DOMXML_RET_OBJ(rv, (xmlNodePtr) parserp->myDoc, &ret);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
RETVAL_FALSE
|
RETVAL_FALSE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4449,8 +4468,7 @@ PHP_FUNCTION(domxml_parser_get_document)
|
||||||
|
|
||||||
if (parserp->myDoc != NULL) {
|
if (parserp->myDoc != NULL) {
|
||||||
DOMXML_RET_OBJ(rv, (xmlNodePtr) parserp->myDoc, &ret);
|
DOMXML_RET_OBJ(rv, (xmlNodePtr) parserp->myDoc, &ret);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
RETVAL_FALSE
|
RETVAL_FALSE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4496,10 +4514,12 @@ static int node_namespace(zval **attributes, xmlNode *nodep TSRMLS_DC)
|
||||||
SEPARATE_ZVAL(&pattr);
|
SEPARATE_ZVAL(&pattr);
|
||||||
|
|
||||||
/* if (!ret) { */
|
/* if (!ret) { */
|
||||||
if (ns->href)
|
if (ns->href) {
|
||||||
add_property_stringl(pattr, "href", (char *) ns->href, strlen(ns->href), 1);
|
add_property_stringl(pattr, "href", (char *) ns->href, strlen(ns->href), 1);
|
||||||
if (ns->prefix)
|
}
|
||||||
|
if (ns->prefix) {
|
||||||
add_property_stringl(pattr, "prefix", (char *) ns->prefix, strlen(ns->prefix), 1);
|
add_property_stringl(pattr, "prefix", (char *) ns->prefix, strlen(ns->prefix), 1);
|
||||||
|
}
|
||||||
add_property_long(pattr, "type", Z_TYPE_P(ns));
|
add_property_long(pattr, "type", Z_TYPE_P(ns));
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
|
@ -4521,11 +4541,13 @@ static int node_attributes(zval **attributes, xmlNode *nodep TSRMLS_DC)
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
/* Get the children of the current node */
|
/* Get the children of the current node */
|
||||||
if (Z_TYPE_P(nodep) != XML_ELEMENT_NODE)
|
if (Z_TYPE_P(nodep) != XML_ELEMENT_NODE) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
attr = nodep->properties;
|
attr = nodep->properties;
|
||||||
if (!attr)
|
if (!attr) {
|
||||||
return -2;
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
/* create an php array for the children */
|
/* create an php array for the children */
|
||||||
MAKE_STD_ZVAL(*attributes);
|
MAKE_STD_ZVAL(*attributes);
|
||||||
|
@ -4579,17 +4601,20 @@ static int node_children(zval **children, xmlNode *nodep TSRMLS_DC)
|
||||||
/* Get the namespace of the current node and add it as a property */
|
/* Get the namespace of the current node and add it as a property */
|
||||||
/* XXX FIXME XXX */
|
/* XXX FIXME XXX */
|
||||||
/*
|
/*
|
||||||
if(!node_namespace(&namespace, last))
|
if (!node_namespace(&namespace, last)) {
|
||||||
zend_hash_update(Z_OBJPROP_P(child), "namespace", sizeof("namespace"), (void *) &namespace, sizeof(zval *), NULL);
|
zend_hash_update(Z_OBJPROP_P(child), "namespace", sizeof("namespace"), (void *) &namespace, sizeof(zval *), NULL);
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Get the attributes of the current node and add it as a property */
|
/* Get the attributes of the current node and add it as a property */
|
||||||
if (node_attributes(&attributes, last TSRMLS_CC) >= 0)
|
if (node_attributes(&attributes, last TSRMLS_CC) >= 0) {
|
||||||
zend_hash_update(Z_OBJPROP_P(child), "attributes", sizeof("attributes"), (void *) &attributes, sizeof(zval *), NULL);
|
zend_hash_update(Z_OBJPROP_P(child), "attributes", sizeof("attributes"), (void *) &attributes, sizeof(zval *), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* Get recursively the children of the current node and add it as a property */
|
/* Get recursively the children of the current node and add it as a property */
|
||||||
if (node_children(&mchildren, last->children TSRMLS_CC) >= 0)
|
if (node_children(&mchildren, last->children TSRMLS_CC) >= 0) {
|
||||||
zend_hash_update(Z_OBJPROP_P(child), "children", sizeof("children"), (void *) &mchildren, sizeof(zval *), NULL);
|
zend_hash_update(Z_OBJPROP_P(child), "children", sizeof("children"), (void *) &mchildren, sizeof(zval *), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
@ -4665,11 +4690,14 @@ static void php_xpathptr_new_context(INTERNAL_FUNCTION_PARAMETERS, int mode)
|
||||||
DOMXML_PARAM_NONE(docp, id, le_domxmldocp);
|
DOMXML_PARAM_NONE(docp, id, le_domxmldocp);
|
||||||
|
|
||||||
#if defined(LIBXML_XPTR_ENABLED)
|
#if defined(LIBXML_XPTR_ENABLED)
|
||||||
if (mode == PHP_XPTR)
|
if (mode == PHP_XPTR) {
|
||||||
ctx = xmlXPtrNewContext(docp, NULL, NULL);
|
ctx = xmlXPtrNewContext(docp, NULL, NULL);
|
||||||
else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
ctx = xmlXPathNewContext(docp);
|
ctx = xmlXPathNewContext(docp);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -4761,8 +4789,7 @@ static void php_xpathptr_eval(INTERNAL_FUNCTION_PARAMETERS, int mode, int expr)
|
||||||
case XPATH_UNDEFINED:
|
case XPATH_UNDEFINED:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XPATH_NODESET:
|
case XPATH_NODESET: {
|
||||||
{
|
|
||||||
int i;
|
int i;
|
||||||
zval *arr;
|
zval *arr;
|
||||||
xmlNodeSetPtr nodesetp;
|
xmlNodeSetPtr nodesetp;
|
||||||
|
@ -4946,7 +4973,6 @@ PHP_FUNCTION(domxml_doc_xinclude)
|
||||||
} else {
|
} else {
|
||||||
RETVAL_FALSE;
|
RETVAL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -5004,13 +5030,15 @@ PHP_FUNCTION(domxml_xslt_stylesheet)
|
||||||
xmlSubstituteEntitiesDefault (prevSubstValue);
|
xmlSubstituteEntitiesDefault (prevSubstValue);
|
||||||
xmlLoadExtDtdDefaultValue = prevExtDtdValue;
|
xmlLoadExtDtdDefaultValue = prevExtDtdValue;
|
||||||
|
|
||||||
if (!docp)
|
if (!docp) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
sheetp = xsltParseStylesheetDoc(docp);
|
sheetp = xsltParseStylesheetDoc(docp);
|
||||||
|
|
||||||
if (!sheetp)
|
if (!sheetp) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
rv = php_xsltstylesheet_new(sheetp, &ret TSRMLS_CC);
|
rv = php_xsltstylesheet_new(sheetp, &ret TSRMLS_CC);
|
||||||
DOMXML_RET_ZVAL(rv);
|
DOMXML_RET_ZVAL(rv);
|
||||||
|
@ -5035,13 +5063,15 @@ PHP_FUNCTION(domxml_xslt_stylesheet_doc)
|
||||||
|
|
||||||
newdocp = xmlCopyDoc(docp, 1);
|
newdocp = xmlCopyDoc(docp, 1);
|
||||||
|
|
||||||
if (!newdocp)
|
if (!newdocp) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
sheetp = xsltParseStylesheetDoc(newdocp);
|
sheetp = xsltParseStylesheetDoc(newdocp);
|
||||||
|
|
||||||
if (!sheetp)
|
if (!sheetp) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
rv = php_xsltstylesheet_new(sheetp, &ret TSRMLS_CC);
|
rv = php_xsltstylesheet_new(sheetp, &ret TSRMLS_CC);
|
||||||
DOMXML_RET_ZVAL(rv);
|
DOMXML_RET_ZVAL(rv);
|
||||||
|
@ -5071,8 +5101,9 @@ PHP_FUNCTION(domxml_xslt_stylesheet_file)
|
||||||
xmlSubstituteEntitiesDefault (prevSubstValue);
|
xmlSubstituteEntitiesDefault (prevSubstValue);
|
||||||
xmlLoadExtDtdDefaultValue = prevExtDtdValue;
|
xmlLoadExtDtdDefaultValue = prevExtDtdValue;
|
||||||
|
|
||||||
if (!sheetp)
|
if (!sheetp) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
rv = php_xsltstylesheet_new(sheetp, &ret TSRMLS_CC);
|
rv = php_xsltstylesheet_new(sheetp, &ret TSRMLS_CC);
|
||||||
DOMXML_RET_ZVAL(rv);
|
DOMXML_RET_ZVAL(rv);
|
||||||
|
@ -5129,15 +5160,13 @@ static char **php_domxslt_make_params(zval *idvars, int xpath_params TSRMLS_DC)
|
||||||
if (zend_hash_get_current_key(parht, &string_key, &num_key, 1) != HASH_KEY_IS_STRING) {
|
if (zend_hash_get_current_key(parht, &string_key, &num_key, 1) != HASH_KEY_IS_STRING) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument or parameter array");
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument or parameter array");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SEPARATE_ZVAL(value);
|
SEPARATE_ZVAL(value);
|
||||||
convert_to_string_ex(value);
|
convert_to_string_ex(value);
|
||||||
|
|
||||||
if (!xpath_params) {
|
if (!xpath_params) {
|
||||||
xpath_expr = php_domxslt_string_to_xpathexpr(Z_STRVAL_PP(value) TSRMLS_CC);
|
xpath_expr = php_domxslt_string_to_xpathexpr(Z_STRVAL_PP(value) TSRMLS_CC);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
xpath_expr = Z_STRVAL_PP(value);
|
xpath_expr = Z_STRVAL_PP(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue