summaryrefslogtreecommitdiff
path: root/ext/xmlwriter/php_xmlwriter.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/xmlwriter/php_xmlwriter.c')
-rw-r--r--ext/xmlwriter/php_xmlwriter.c703
1 files changed, 294 insertions, 409 deletions
diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c
index f726caa5c1..be7e82555a 100644
--- a/ext/xmlwriter/php_xmlwriter.c
+++ b/ext/xmlwriter/php_xmlwriter.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2016 The PHP Group |
+----------------------------------------------------------------------+
@@ -83,14 +83,14 @@ static PHP_FUNCTION(xmlwriter_flush);
static zend_class_entry *xmlwriter_class_entry_ce;
-static void xmlwriter_free_resource_ptr(xmlwriter_object *intern TSRMLS_DC);
-static void xmlwriter_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC);
+static void xmlwriter_free_resource_ptr(xmlwriter_object *intern);
+static void xmlwriter_dtor(zend_resource *rsrc);
typedef int (*xmlwriter_read_one_char_t)(xmlTextWriterPtr writer, const xmlChar *content);
typedef int (*xmlwriter_read_int_t)(xmlTextWriterPtr writer);
/* {{{ xmlwriter_object_free_storage */
-static void xmlwriter_free_resource_ptr(xmlwriter_object *intern TSRMLS_DC)
+static void xmlwriter_free_resource_ptr(xmlwriter_object *intern)
{
if (intern) {
if (intern->ptr) {
@@ -106,14 +106,13 @@ static void xmlwriter_free_resource_ptr(xmlwriter_object *intern TSRMLS_DC)
}
/* }}} */
-#ifdef ZEND_ENGINE_2
/* {{{ XMLWRITER_FROM_OBJECT */
#define XMLWRITER_FROM_OBJECT(intern, object) \
{ \
- ze_xmlwriter_object *obj = (ze_xmlwriter_object*) zend_object_store_get_object(object TSRMLS_CC); \
+ ze_xmlwriter_object *obj = Z_XMLWRITER_P(object); \
intern = obj->xmlwriter_ptr; \
if (!intern) { \
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid or uninitialized XMLWriter object"); \
+ php_error_docref(NULL, E_WARNING, "Invalid or uninitialized XMLWriter object"); \
RETURN_FALSE; \
} \
}
@@ -122,54 +121,41 @@ static void xmlwriter_free_resource_ptr(xmlwriter_object *intern TSRMLS_DC)
static zend_object_handlers xmlwriter_object_handlers;
/* {{{ xmlwriter_object_free_storage */
-static void xmlwriter_object_free_storage(void *object TSRMLS_DC)
+static void xmlwriter_object_free_storage(zend_object *object)
{
- ze_xmlwriter_object * intern = (ze_xmlwriter_object *) object;
+ ze_xmlwriter_object *intern = php_xmlwriter_fetch_object(object);
if (!intern) {
return;
}
if (intern->xmlwriter_ptr) {
- xmlwriter_free_resource_ptr(intern->xmlwriter_ptr TSRMLS_CC);
+ xmlwriter_free_resource_ptr(intern->xmlwriter_ptr);
}
intern->xmlwriter_ptr = NULL;
- zend_object_std_dtor(&intern->zo TSRMLS_CC);
-
- efree(intern);
+ zend_object_std_dtor(&intern->std);
}
/* }}} */
/* {{{ xmlwriter_object_new */
-static zend_object_value xmlwriter_object_new(zend_class_entry *class_type TSRMLS_DC)
+static zend_object *xmlwriter_object_new(zend_class_entry *class_type)
{
ze_xmlwriter_object *intern;
- zend_object_value retval;
- intern = emalloc(sizeof(ze_xmlwriter_object));
- memset(&intern->zo, 0, sizeof(zend_object));
- intern->xmlwriter_ptr = NULL;
-
- zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
- object_properties_init(&intern->zo, class_type);
-
- retval.handle = zend_objects_store_put(intern,
- NULL,
- (zend_objects_free_object_storage_t) xmlwriter_object_free_storage,
- NULL TSRMLS_CC);
-
- retval.handlers = (zend_object_handlers *) & xmlwriter_object_handlers;
-
- return retval;
+ intern = ecalloc(1, sizeof(ze_xmlwriter_object) + zend_object_properties_size(class_type));
+ zend_object_std_init(&intern->std, class_type);
+ object_properties_init(&intern->std, class_type);
+ intern->std.handlers = &xmlwriter_object_handlers;
+
+ return &intern->std;
}
/* }}} */
-#endif
#define XMLW_NAME_CHK(__err) \
if (xmlValidateName((xmlChar *) name, 0) != 0) { \
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", __err); \
+ php_error_docref(NULL, E_WARNING, "%s", __err); \
RETURN_FALSE; \
} \
-
+
/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO(arginfo_xmlwriter_void, 0)
ZEND_END_ARG_INFO()
@@ -530,7 +516,6 @@ static const zend_function_entry xmlwriter_functions[] = {
};
/* }}} */
-#ifdef ZEND_ENGINE_2
/* {{{ xmlwriter_class_functions */
static const zend_function_entry xmlwriter_class_functions[] = {
PHP_ME_MAPPING(openUri, xmlwriter_open_uri, arginfo_xmlwriter_open_uri, 0)
@@ -586,7 +571,6 @@ static const zend_function_entry xmlwriter_class_functions[] = {
{NULL, NULL, NULL}
};
/* }}} */
-#endif
/* {{{ function prototypes */
static PHP_MINIT_FUNCTION(xmlwriter);
@@ -596,10 +580,10 @@ static PHP_MINFO_FUNCTION(xmlwriter);
static int le_xmlwriter;
/* }}} */
-/* _xmlwriter_get_valid_file_path should be made a
+/* _xmlwriter_get_valid_file_path should be made a
common function in libxml extension as code is common to a few xml extensions */
/* {{{ _xmlwriter_get_valid_file_path */
-static char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, int resolved_path_len TSRMLS_DC) {
+static char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, int resolved_path_len ) {
xmlURI *uri;
xmlChar *escsource;
char *file_dest;
@@ -642,7 +626,7 @@ static char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, i
char file_dirname[MAXPATHLEN];
size_t dir_len;
- if (!VCWD_REALPATH(source, resolved_path) && !expand_filepath(source, resolved_path TSRMLS_CC)) {
+ if (!VCWD_REALPATH(source, resolved_path) && !expand_filepath(source, resolved_path)) {
xmlFreeURI(uri);
return NULL;
}
@@ -651,7 +635,7 @@ static char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, i
dir_len = php_dirname(file_dirname, strlen(source));
if (dir_len > 0) {
- struct stat buf;
+ zend_stat_t buf;
if (php_sys_stat(file_dirname, &buf) != 0) {
xmlFreeURI(uri);
return NULL;
@@ -669,38 +653,6 @@ static char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, i
}
/* }}} */
-#ifndef ZEND_ENGINE_2
-/* Channel libxml file io layer through the PHP streams subsystem.
- * This allows use of ftps:// and https:// urls */
-
-/* {{{ php_xmlwriter_streams_IO_open_write_wrapper */
-static void *php_xmlwriter_streams_IO_open_write_wrapper(const char *filename TSRMLS_DC)
-{
- php_stream_wrapper *wrapper = NULL;
- void *ret_val = NULL;
-
- ret_val = php_stream_open_wrapper_ex((char *)filename, "wb", REPORT_ERRORS, NULL, NULL);
- return ret_val;
-}
-/* }}} */
-
-/* {{{ php_xmlwriter_streams_IO_write */
-static int php_xmlwriter_streams_IO_write(void *context, const char *buffer, int len)
-{
- TSRMLS_FETCH();
- return php_stream_write((php_stream*)context, buffer, len);
-}
-/* }}} */
-
-/* {{{ php_xmlwriter_streams_IO_close */
-static int php_xmlwriter_streams_IO_close(void *context)
-{
- TSRMLS_FETCH();
- return php_stream_close((php_stream*)context);
-}
-/* }}} */
-#endif
-
/* {{{ xmlwriter_module_entry
*/
zend_module_entry xmlwriter_module_entry = {
@@ -712,7 +664,7 @@ zend_module_entry xmlwriter_module_entry = {
NULL,
NULL,
PHP_MINFO(xmlwriter),
- "0.1",
+ PHP_XMLWRITER_VERSION,
STANDARD_MODULE_PROPERTIES
};
/* }}} */
@@ -721,19 +673,19 @@ zend_module_entry xmlwriter_module_entry = {
ZEND_GET_MODULE(xmlwriter)
#endif
-/* {{{ xmlwriter_objects_clone
-static void xmlwriter_objects_clone(void *object, void **object_clone TSRMLS_DC)
+/* {{{ xmlwriter_objects_clone
+static void xmlwriter_objects_clone(void *object, void **object_clone)
{
TODO
}
}}} */
/* {{{ xmlwriter_dtor */
-static void xmlwriter_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
+static void xmlwriter_dtor(zend_resource *rsrc) {
xmlwriter_object *intern;
intern = (xmlwriter_object *) rsrc->ptr;
- xmlwriter_free_resource_ptr(intern TSRMLS_CC);
+ xmlwriter_free_resource_ptr(intern);
}
/* }}} */
@@ -743,24 +695,23 @@ static void php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAMETERS, xmlwriter_rea
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name;
- int name_len, retval;
+ size_t name_len, retval;
+
+ zval *self = getThis();
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &name, &name_len) == FAILURE) {
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &pind, &name, &name_len) == FAILURE) {
return;
}
-
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
if (err_string != NULL) {
@@ -775,7 +726,7 @@ static void php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAMETERS, xmlwriter_rea
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
@@ -785,21 +736,20 @@ static void php_xmlwriter_end(INTERNAL_FUNCTION_PARAMETERS, xmlwriter_read_int_t
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
int retval;
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- XMLWRITER_FROM_OBJECT(intern, this);
+ zval *self = getThis();
+
+ if (self) {
+ XMLWRITER_FROM_OBJECT(intern, self);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
ptr = intern->ptr;
@@ -810,7 +760,7 @@ static void php_xmlwriter_end(INTERNAL_FUNCTION_PARAMETERS, xmlwriter_read_int_t
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
@@ -825,21 +775,20 @@ static PHP_FUNCTION(xmlwriter_set_indent)
int retval;
zend_bool indent;
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &indent) == FAILURE) {
+ zval *self = getThis();
+
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &indent) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rb", &pind, &indent) == FAILURE) {
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rb", &pind, &indent) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
@@ -850,7 +799,7 @@ static PHP_FUNCTION(xmlwriter_set_indent)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -890,24 +839,24 @@ static PHP_FUNCTION(xmlwriter_start_attribute_ns)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name, *prefix, *uri;
- int name_len, prefix_len, uri_len, retval;
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss!",
+ size_t name_len, prefix_len, uri_len;
+ int retval;
+ zval *self = getThis();
+
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss!",
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss!", &pind,
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsss!", &pind,
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Attribute Name");
@@ -920,7 +869,7 @@ static PHP_FUNCTION(xmlwriter_start_attribute_ns)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -934,25 +883,24 @@ static PHP_FUNCTION(xmlwriter_write_attribute)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name, *content;
- int name_len, content_len, retval;
+ size_t name_len, content_len;
+ int retval;
+ zval *self = getThis();
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss",
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss", &pind,
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Attribute Name");
@@ -965,7 +913,7 @@ static PHP_FUNCTION(xmlwriter_write_attribute)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -979,25 +927,25 @@ static PHP_FUNCTION(xmlwriter_write_attribute_ns)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name, *prefix, *uri, *content;
- int name_len, prefix_len, uri_len, content_len, retval;
+ size_t name_len, prefix_len, uri_len, content_len;
+ int retval;
+
+ zval *self = getThis();
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss!s",
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss!s",
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss!s", &pind,
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsss!s", &pind,
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Attribute Name");
@@ -1010,7 +958,7 @@ static PHP_FUNCTION(xmlwriter_write_attribute_ns)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -1032,24 +980,24 @@ static PHP_FUNCTION(xmlwriter_start_element_ns)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name, *prefix, *uri;
- int name_len, prefix_len, uri_len, retval;
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss!",
+ size_t name_len, prefix_len, uri_len;
+ int retval;
+ zval *self = getThis();
+
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!ss!",
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss!", &pind,
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!ss!", &pind,
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Element Name");
@@ -1061,9 +1009,9 @@ static PHP_FUNCTION(xmlwriter_start_element_ns)
if (retval != -1) {
RETURN_TRUE;
}
-
+
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -1092,25 +1040,24 @@ static PHP_FUNCTION(xmlwriter_write_element)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name, *content = NULL;
- int name_len, content_len, retval;
+ size_t name_len, content_len;
+ int retval;
+ zval *self = getThis();
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!",
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!",
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!", &pind,
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|s!", &pind,
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Element Name");
@@ -1134,7 +1081,7 @@ static PHP_FUNCTION(xmlwriter_write_element)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -1147,25 +1094,24 @@ static PHP_FUNCTION(xmlwriter_write_element_ns)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name, *prefix, *uri, *content = NULL;
- int name_len, prefix_len, uri_len, content_len, retval;
+ size_t name_len, prefix_len, uri_len, content_len;
+ int retval;
+ zval *self = getThis();
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss!|s!",
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!ss!|s!",
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss!|s!", &pind,
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!ss!|s!", &pind,
&prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Element Name");
@@ -1189,7 +1135,7 @@ static PHP_FUNCTION(xmlwriter_write_element_ns)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -1218,25 +1164,25 @@ static PHP_FUNCTION(xmlwriter_write_pi)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name, *content;
- int name_len, content_len, retval;
+ size_t name_len, content_len;
+ int retval;
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
+ zval *self = getThis();
+
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss",
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss", &pind,
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid PI Target");
@@ -1249,7 +1195,7 @@ static PHP_FUNCTION(xmlwriter_write_pi)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -1262,18 +1208,17 @@ static PHP_FUNCTION(xmlwriter_start_cdata)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
int retval;
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ zval *self = getThis();
+
+ if (self) {
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
ptr = intern->ptr;
@@ -1284,7 +1229,7 @@ static PHP_FUNCTION(xmlwriter_start_cdata)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -1330,18 +1275,17 @@ static PHP_FUNCTION(xmlwriter_start_comment)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
int retval;
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ zval *self = getThis();
+
+ if (self) {
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
ptr = intern->ptr;
@@ -1352,7 +1296,7 @@ static PHP_FUNCTION(xmlwriter_start_comment)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -1383,23 +1327,23 @@ static PHP_FUNCTION(xmlwriter_start_document)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *version = NULL, *enc = NULL, *alone = NULL;
- int version_len, enc_len, alone_len, retval;
+ size_t version_len, enc_len, alone_len;
+ int retval;
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
+ zval *self = getThis();
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!", &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!s!", &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|s!s!s!", &pind, &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!s!", &pind, &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
ptr = intern->ptr;
@@ -1410,7 +1354,7 @@ static PHP_FUNCTION(xmlwriter_start_document)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -1431,25 +1375,23 @@ static PHP_FUNCTION(xmlwriter_start_dtd)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name, *pubid = NULL, *sysid = NULL;
- int name_len, pubid_len, sysid_len, retval;
-
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
+ size_t name_len, pubid_len, sysid_len;
+ int retval;
+ zval *self = getThis();
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!s!", &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!s!", &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
return;
}
-
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
ptr = intern->ptr;
@@ -1459,7 +1401,7 @@ static PHP_FUNCTION(xmlwriter_start_dtd)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -1480,25 +1422,24 @@ static PHP_FUNCTION(xmlwriter_write_dtd)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name, *pubid = NULL, *sysid = NULL, *subset = NULL;
- int name_len, pubid_len, sysid_len, subset_len, retval;
-
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
+ size_t name_len, pubid_len, sysid_len, subset_len;
+ int retval;
+ zval *self = getThis();
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!s!s!", &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len, &subset, &subset_len) == FAILURE) {
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!s!s!", &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len, &subset, &subset_len) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len, &subset, &subset_len) == FAILURE) {
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|s!s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len, &subset, &subset_len) == FAILURE) {
return;
}
-
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
ptr = intern->ptr;
@@ -1509,7 +1450,7 @@ static PHP_FUNCTION(xmlwriter_write_dtd)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -1538,24 +1479,23 @@ static PHP_FUNCTION(xmlwriter_write_dtd_element)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name, *content;
- int name_len, content_len, retval;
-
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
+ size_t name_len, content_len;
+ int retval;
+ zval *self = getThis();
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &name, &name_len, &content, &content_len) == FAILURE) {
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss", &pind,
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Element Name");
@@ -1568,7 +1508,7 @@ static PHP_FUNCTION(xmlwriter_write_dtd_element)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -1598,26 +1538,24 @@ static PHP_FUNCTION(xmlwriter_write_dtd_attlist)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name, *content;
- int name_len, content_len, retval;
-
-
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
+ size_t name_len, content_len;
+ int retval;
+ zval *self = getThis();
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss",
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss", &pind,
&name, &name_len, &content, &content_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Element Name");
@@ -1630,7 +1568,7 @@ static PHP_FUNCTION(xmlwriter_write_dtd_attlist)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -1643,25 +1581,22 @@ static PHP_FUNCTION(xmlwriter_start_dtd_entity)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name;
- int name_len, retval;
+ size_t name_len, retval;
zend_bool isparm;
+ zval *self = getThis();
-
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sb", &name, &name_len, &isparm) == FAILURE) {
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sb", &name, &name_len, &isparm) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsb", &pind, &name, &name_len, &isparm) == FAILURE) {
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsb", &pind, &name, &name_len, &isparm) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Attribute Name");
@@ -1674,7 +1609,7 @@ static PHP_FUNCTION(xmlwriter_start_dtd_entity)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -1687,7 +1622,7 @@ static PHP_FUNCTION(xmlwriter_end_dtd_entity)
}
/* }}} */
-/* {{{ proto bool xmlwriter_write_dtd_entity(resource xmlwriter, string name, string content [, int pe [, string pubid [, string sysid [, string ndataid]]]])
+/* {{{ proto bool xmlwriter_write_dtd_entity(resource xmlwriter, string name, string content [, bool pe [, string pubid [, string sysid [, string ndataid]]]])
Write full DTD Entity tag - returns FALSE on error */
static PHP_FUNCTION(xmlwriter_write_dtd_entity)
{
@@ -1695,31 +1630,30 @@ static PHP_FUNCTION(xmlwriter_write_dtd_entity)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
char *name, *content;
- int name_len, content_len, retval;
+ size_t name_len, content_len;
+ int retval;
/* Optional parameters */
char *pubid = NULL, *sysid = NULL, *ndataid = NULL;
zend_bool pe = 0;
- int pubid_len, sysid_len, ndataid_len;
+ size_t pubid_len, sysid_len, ndataid_len;
+ zval *self = getThis();
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|bsss",
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|bsss",
&name, &name_len, &content, &content_len, &pe, &pubid, &pubid_len,
&sysid, &sysid_len, &ndataid, &ndataid_len) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss|bsss", &pind,
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss|bsss", &pind,
&name, &name_len, &content, &content_len, &pe, &pubid, &pubid_len,
&sysid, &sysid_len, &ndataid, &ndataid_len) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
XMLW_NAME_CHK("Invalid Element Name");
@@ -1732,7 +1666,7 @@ static PHP_FUNCTION(xmlwriter_write_dtd_entity)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -1747,60 +1681,31 @@ static PHP_FUNCTION(xmlwriter_open_uri)
xmlTextWriterPtr ptr;
char *source;
char resolved_path[MAXPATHLEN + 1];
- int source_len;
-
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
+ size_t source_len;
+ zval *self = getThis();
ze_xmlwriter_object *ze_obj = NULL;
-#endif
-#ifndef ZEND_ENGINE_2
- xmlOutputBufferPtr out_buffer;
- void *ioctx;
-#endif
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &source, &source_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &source, &source_len) == FAILURE) {
return;
}
-
-#ifdef ZEND_ENGINE_2
- if (this) {
+
+ if (self) {
/* We do not use XMLWRITER_FROM_OBJECT, xmlwriter init function here */
- ze_obj = (ze_xmlwriter_object*) zend_object_store_get_object(this TSRMLS_CC);
+ ze_obj = Z_XMLWRITER_P(self);
}
-#endif
if (source_len == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty string as source");
+ php_error_docref(NULL, E_WARNING, "Empty string as source");
RETURN_FALSE;
}
- valid_file = _xmlwriter_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC);
+ valid_file = _xmlwriter_get_valid_file_path(source, resolved_path, MAXPATHLEN);
if (!valid_file) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to resolve file path");
- RETURN_FALSE;
- }
-
- /* TODO: Fix either the PHP stream or libxml APIs: it can then detect when a given
- path is valid and not report out of memory error. Once it is done, remove the
- directory check in _xmlwriter_get_valid_file_path */
-#ifndef ZEND_ENGINE_2
- ioctx = php_xmlwriter_streams_IO_open_write_wrapper(valid_file TSRMLS_CC);
- if (ioctx == NULL) {
+ php_error_docref(NULL, E_WARNING, "Unable to resolve file path");
RETURN_FALSE;
}
- out_buffer = xmlOutputBufferCreateIO(php_xmlwriter_streams_IO_write,
- php_xmlwriter_streams_IO_close, ioctx, NULL);
-
- if (out_buffer == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create output buffer");
- RETURN_FALSE;
- }
- ptr = xmlNewTextWriter(out_buffer);
-#else
ptr = xmlNewTextWriterFilename(valid_file, 0);
-#endif
if (!ptr) {
RETURN_FALSE;
@@ -1809,19 +1714,14 @@ static PHP_FUNCTION(xmlwriter_open_uri)
intern = emalloc(sizeof(xmlwriter_object));
intern->ptr = ptr;
intern->output = NULL;
-#ifndef ZEND_ENGINE_2
- intern->uri_output = out_buffer;
-#else
- if (this) {
+ if (self) {
if (ze_obj->xmlwriter_ptr) {
- xmlwriter_free_resource_ptr(ze_obj->xmlwriter_ptr TSRMLS_CC);
+ xmlwriter_free_resource_ptr(ze_obj->xmlwriter_ptr);
}
ze_obj->xmlwriter_ptr = intern;
RETURN_TRUE;
- } else
-#endif
- {
- ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter);
+ } else {
+ RETURN_RES(zend_register_resource(intern, le_xmlwriter));
}
}
/* }}} */
@@ -1833,23 +1733,18 @@ static PHP_FUNCTION(xmlwriter_open_memory)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
xmlBufferPtr buffer;
-
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
+ zval *self = getThis();
ze_xmlwriter_object *ze_obj = NULL;
-#endif
-#ifdef ZEND_ENGINE_2
- if (this) {
+ if (self) {
/* We do not use XMLWRITER_FROM_OBJECT, xmlwriter init function here */
- ze_obj = (ze_xmlwriter_object*) zend_object_store_get_object(this TSRMLS_CC);
+ ze_obj = Z_XMLWRITER_P(self);
}
-#endif
buffer = xmlBufferCreate();
if (buffer == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create output buffer");
+ php_error_docref(NULL, E_WARNING, "Unable to create output buffer");
RETURN_FALSE;
}
@@ -1862,19 +1757,14 @@ static PHP_FUNCTION(xmlwriter_open_memory)
intern = emalloc(sizeof(xmlwriter_object));
intern->ptr = ptr;
intern->output = buffer;
-#ifndef ZEND_ENGINE_2
- intern->uri_output = NULL;
-#else
- if (this) {
+ if (self) {
if (ze_obj->xmlwriter_ptr) {
- xmlwriter_free_resource_ptr(ze_obj->xmlwriter_ptr TSRMLS_CC);
+ xmlwriter_free_resource_ptr(ze_obj->xmlwriter_ptr);
}
ze_obj->xmlwriter_ptr = intern;
RETURN_TRUE;
- } else
-#endif
- {
- ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter);
+ } else {
+ RETURN_RES(zend_register_resource(intern, le_xmlwriter));
}
}
@@ -1888,24 +1778,21 @@ static void php_xmlwriter_flush(INTERNAL_FUNCTION_PARAMETERS, int force_string)
xmlBufferPtr buffer;
zend_bool empty = 1;
int output_bytes;
+ zval *self = getThis();
-
-#ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &empty) == FAILURE) {
+ if (self) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &empty) == FAILURE) {
return;
}
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
-#endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|b", &pind, &empty) == FAILURE) {
+ XMLWRITER_FROM_OBJECT(intern, self);
+ } else {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|b", &pind, &empty) == FAILURE) {
return;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
+ RETURN_FALSE;
+ }
}
ptr = intern->ptr;
@@ -1916,7 +1803,7 @@ static void php_xmlwriter_flush(INTERNAL_FUNCTION_PARAMETERS, int force_string)
}
output_bytes = xmlTextWriterFlush(ptr);
if (buffer) {
- RETVAL_STRING((char *) buffer->content, 1);
+ RETVAL_STRING((char *) buffer->content);
if (empty) {
xmlBufferEmpty(buffer);
}
@@ -1925,7 +1812,7 @@ static void php_xmlwriter_flush(INTERNAL_FUNCTION_PARAMETERS, int force_string)
}
return;
}
-
+
RETURN_EMPTY_STRING();
}
/* }}} */
@@ -1950,19 +1837,17 @@ static PHP_FUNCTION(xmlwriter_flush)
*/
static PHP_MINIT_FUNCTION(xmlwriter)
{
-#ifdef ZEND_ENGINE_2
zend_class_entry ce;
-#endif
-
le_xmlwriter = zend_register_list_destructors_ex(xmlwriter_dtor, NULL, "xmlwriter", module_number);
-#ifdef ZEND_ENGINE_2
memcpy(&xmlwriter_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
- xmlwriter_object_handlers.clone_obj = NULL;
+ xmlwriter_object_handlers.offset = XtOffsetOf(ze_xmlwriter_object, std);
+ xmlwriter_object_handlers.free_obj = xmlwriter_object_free_storage;
+ xmlwriter_object_handlers.clone_obj = NULL;
INIT_CLASS_ENTRY(ce, "XMLWriter", xmlwriter_class_functions);
ce.create_object = xmlwriter_object_new;
- xmlwriter_class_entry_ce = zend_register_internal_class(&ce TSRMLS_CC);
-#endif
+ xmlwriter_class_entry_ce = zend_register_internal_class(&ce);
+
return SUCCESS;
}
/* }}} */