summaryrefslogtreecommitdiff
path: root/ext/xmlwriter/php_xmlwriter.c
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:37:48 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:37:48 -0400
commiteddbbea4325e602ddc87c545531609132d4f0e3b (patch)
treef0994206a7e0a6251be7cc6729ba480f0c8729c2 /ext/xmlwriter/php_xmlwriter.c
parent2d4e5b09576bb4f0ba716cc82cdf29ea04d9184b (diff)
downloadphp-eddbbea4325e602ddc87c545531609132d4f0e3b.tar.gz
Imported Upstream version 5.2.3upstream/5.2.3
Diffstat (limited to 'ext/xmlwriter/php_xmlwriter.c')
-rw-r--r--ext/xmlwriter/php_xmlwriter.c58
1 files changed, 40 insertions, 18 deletions
diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c
index 56a696801..f90ffa7d7 100644
--- a/ext/xmlwriter/php_xmlwriter.c
+++ b/ext/xmlwriter/php_xmlwriter.c
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_xmlwriter.c,v 1.20.2.12.2.12 2007/01/06 18:03:43 rrichards Exp $ */
+/* $Id: php_xmlwriter.c,v 1.20.2.12.2.15 2007/05/14 09:23:49 pajoye Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -566,7 +566,7 @@ static PHP_FUNCTION(xmlwriter_start_attribute_ns)
zval *this = getThis();
if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss!",
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
return;
}
@@ -574,7 +574,7 @@ static PHP_FUNCTION(xmlwriter_start_attribute_ns)
} else
#endif
{
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss", &pind,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss!", &pind,
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
return;
}
@@ -656,7 +656,7 @@ static PHP_FUNCTION(xmlwriter_write_attribute_ns)
zval *this = getThis();
if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssss",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss!s",
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
return;
}
@@ -664,7 +664,7 @@ static PHP_FUNCTION(xmlwriter_write_attribute_ns)
} else
#endif
{
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssss", &pind,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss!s", &pind,
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
return;
}
@@ -695,7 +695,6 @@ static PHP_FUNCTION(xmlwriter_start_element)
}
/* }}} */
-
/* {{{ proto bool xmlwriter_start_element_ns(resource xmlwriter, string prefix, string name, string uri)
Create start namespaced element tag - returns FALSE on error */
static PHP_FUNCTION(xmlwriter_start_element_ns)
@@ -709,7 +708,7 @@ static PHP_FUNCTION(xmlwriter_start_element_ns)
zval *this = getThis();
if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss!",
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
return;
}
@@ -717,7 +716,7 @@ static PHP_FUNCTION(xmlwriter_start_element_ns)
} else
#endif
{
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss", &pind,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss!", &pind,
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
return;
}
@@ -756,20 +755,21 @@ static PHP_FUNCTION(xmlwriter_full_end_element)
}
/* }}} */
-/* {{{ proto bool xmlwriter_write_element(resource xmlwriter, string name, string content)
+/* {{{ proto bool xmlwriter_write_element(resource xmlwriter, string name[, string content])
Write full element tag - returns FALSE on error */
static PHP_FUNCTION(xmlwriter_write_element)
{
zval *pind;
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
- char *name, *content;
+ char *name, *content = NULL;
int name_len, content_len, retval;
+
#ifdef ZEND_ENGINE_2
zval *this = getThis();
if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!",
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
@@ -777,7 +777,7 @@ static PHP_FUNCTION(xmlwriter_write_element)
} else
#endif
{
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!", &pind,
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
@@ -789,7 +789,18 @@ static PHP_FUNCTION(xmlwriter_write_element)
ptr = intern->ptr;
if (ptr) {
- retval = xmlTextWriterWriteElement(ptr, (xmlChar *)name, (xmlChar *)content);
+ if (!content) {
+ retval = xmlTextWriterStartElement(ptr, (xmlChar *)name);
+ if (retval == -1) {
+ RETURN_FALSE;
+ }
+ xmlTextWriterEndElement(ptr);
+ if (retval == -1) {
+ RETURN_FALSE;
+ }
+ } else {
+ retval = xmlTextWriterWriteElement(ptr, (xmlChar *)name, (xmlChar *)content);
+ }
if (retval != -1) {
RETURN_TRUE;
}
@@ -799,21 +810,21 @@ static PHP_FUNCTION(xmlwriter_write_element)
}
/* }}} */
-/* {{{ proto bool xmlwriter_write_element_ns(resource xmlwriter, string prefix, string name, string uri, string content)
+/* {{{ proto bool xmlwriter_write_element_ns(resource xmlwriter, string prefix, string name, string uri[, string content])
Write full namesapced element tag - returns FALSE on error */
static PHP_FUNCTION(xmlwriter_write_element_ns)
{
zval *pind;
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
- char *name, *prefix, *uri, *content;
+ char *name, *prefix, *uri, *content = NULL;
int name_len, prefix_len, uri_len, content_len, retval;
#ifdef ZEND_ENGINE_2
zval *this = getThis();
if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!sss",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss!|s!",
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
return;
}
@@ -821,7 +832,7 @@ static PHP_FUNCTION(xmlwriter_write_element_ns)
} else
#endif
{
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!sss", &pind,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss!|s!", &pind,
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
return;
}
@@ -833,7 +844,18 @@ static PHP_FUNCTION(xmlwriter_write_element_ns)
ptr = intern->ptr;
if (ptr) {
- retval = xmlTextWriterWriteElementNS(ptr, (xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri, (xmlChar *)content);
+ if (!content) {
+ retval = xmlTextWriterStartElementNS(ptr,(xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri);
+ if (retval == -1) {
+ RETURN_FALSE;
+ }
+ retval = xmlTextWriterEndElement(ptr);
+ if (retval == -1) {
+ RETURN_FALSE;
+ }
+ } else {
+ retval = xmlTextWriterWriteElementNS(ptr, (xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri, (xmlChar *)content);
+ }
if (retval != -1) {
RETURN_TRUE;
}