diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2005-12-02 02:05:26 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2005-12-02 02:05:26 +0000 |
commit | bcd9356df51183637c6ba16ef5b161bbe41c3877 (patch) | |
tree | 38b43e031cd8a5590b86e3259b0a30b54c6b8298 /ext | |
parent | 950de078898f49fddbf866c7612e2c65c4ccd43a (diff) | |
download | php-git-bcd9356df51183637c6ba16ef5b161bbe41c3877.tar.gz |
Added xmlwriter to 5.1
Diffstat (limited to 'ext')
24 files changed, 2840 insertions, 0 deletions
diff --git a/ext/xmlwriter/CREDITS b/ext/xmlwriter/CREDITS new file mode 100644 index 0000000000..d3a9ebe1bb --- /dev/null +++ b/ext/xmlwriter/CREDITS @@ -0,0 +1,3 @@ +XMLWriter +Rob Richards +Pierre-Alain Joye diff --git a/ext/xmlwriter/LICENSE b/ext/xmlwriter/LICENSE new file mode 100644 index 0000000000..f0da69c7b1 --- /dev/null +++ b/ext/xmlwriter/LICENSE @@ -0,0 +1,68 @@ +-------------------------------------------------------------------- +The PHP License, version 3.01 +Copyright (c) 1999 - 2005 The PHP Group. All rights reserved. +-------------------------------------------------------------------- + +Redistribution and use in source and binary forms, with or without +modification, is permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. + +3. The name "PHP" must not be used to endorse or promote products +derived from this software without prior written permission. For +written permission, please contact group@php.net. + +4. Products derived from this software may not be called "PHP", nor +may "PHP" appear in their name, without prior written permission +from group@php.net. You may indicate that your software works in +conjunction with PHP by saying "Foo for PHP" instead of calling +it "PHP Foo" or "phpfoo" + +5. The PHP Group may publish revised and/or new versions of the +license from time to time. Each version will be given a +distinguishing version number. +Once covered code has been published under a particular version +of the license, you may always continue to use it under the terms +of that version. You may also choose to use such covered code +under the terms of any subsequent version of the license +published by the PHP Group. No one other than the PHP Group has +the right to modify the terms applicable to covered code created +under this License. + +6. Redistributions of any form whatsoever must retain the following +acknowledgment: +"This product includes PHP software, freely available from +<http://www.php.net/software/>". + +THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND +ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP +DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------------------------------------------------------- + +This software consists of voluntary contributions made by many +individuals on behalf of the PHP Group. + +The PHP Group can be contacted via Email at group@php.net. + +For more information on the PHP Group and the PHP project, +please see <http://www.php.net>. + +PHP includes the Zend Engine, freely available at +<http://www.zend.com>. diff --git a/ext/xmlwriter/TODO b/ext/xmlwriter/TODO new file mode 100644 index 0000000000..bfc895d769 --- /dev/null +++ b/ext/xmlwriter/TODO @@ -0,0 +1,5 @@ +- Fix up config file for PHP 5 to use libxml extension configuration +- Add tests for Namespace functions/methods +- Sync with xmlwriter (new dtd func?) +- Write documentations in docbook + diff --git a/ext/xmlwriter/config.m4 b/ext/xmlwriter/config.m4 new file mode 100644 index 0000000000..a1952b3879 --- /dev/null +++ b/ext/xmlwriter/config.m4 @@ -0,0 +1,61 @@ +dnl +dnl $Id$ +dnl + +AC_DEFUN([PHP_XMLWRITER_CHECK_VERSION],[ + old_CPPFLAGS=$CPPFLAGS + CPPFLAGS=-I$XMLWRITER_DIR/include$XMLWRITER_DIR_ADD + AC_MSG_CHECKING(for libxml version) + AC_EGREP_CPP(yes,[ +#include <libxml/xmlversion.h> +#if LIBXML_VERSION >= 20600 + yes +#endif + ],[ + AC_MSG_RESULT(>= 2.6.0) + ],[ + AC_MSG_ERROR(libxml version 2.6.0 or greater required.) + ]) + CPPFLAGS=$old_CPPFLAGS +]) + +PHP_ARG_WITH(xmlwriter, for XMLWriter support, +[ --with-xmlwriter Include XMLWriter support.]) + +if test "$PHP_XMLWRITER" != "no"; then + + XMLWRITER_DIR_ADD="" + if test -r $PHP_XMLWRITER/include/libxml2/libxml/xmlwriter.h; then + XMLWRITER_DIR=$PHP_XMLWRITER + XMLWRITER_DIR_ADD="/libxml2" + elif test -r $PHP_XMLWRITER/include/libxml/xmlwriter.h; then + XMLWRITER_DIR=$PHP_XMLWRITER + else + for i in /usr/local /usr; do + test -r $i/include/libxml/xmlwriter.h && XMLWRITER_DIR=$i + test -r $i/include/libxml2/libxml/xmlwriter.h && XMLWRITER_DIR=$i && XMLWRITER_DIR_ADD="/libxml2" + done + fi + + if test -z "$XMLWRITER_DIR"; then + AC_MSG_RESULT(not found) + AC_MSG_ERROR(Please reinstall the libxml >= 2.6.0 distribution) + fi + + PHP_XMLWRITER_CHECK_VERSION + + XML2_CONFIG=$XMLWRITER_DIR/bin/xml2-config + + if test -x $XML2_CONFIG; then + XMLWRITER_LIBS=`$XML2_CONFIG --libs` + PHP_EVAL_LIBLINE($XMLWRITER_LIBS, XMLWRITER_SHARED_LIBADD) + else + PHP_ADD_LIBRARY_WITH_PATH($XMLWRITER_LIBNAME, $XMLWRITER_DIR/lib, XMLWRITER_SHARED_LIBADD) + fi + + PHP_ADD_INCLUDE($XMLWRITER_DIR/include$XMLWRITER_DIR_ADD) + + AC_DEFINE(HAVE_XMLWRITER,1,[ ]) + PHP_NEW_EXTENSION(xmlwriter, php_xmlwriter.c, $ext_shared) + PHP_SUBST(XMLWRITER_SHARED_LIBADD) +fi diff --git a/ext/xmlwriter/config.w32 b/ext/xmlwriter/config.w32 new file mode 100644 index 0000000000..c18b2c13fd --- /dev/null +++ b/ext/xmlwriter/config.w32 @@ -0,0 +1,18 @@ +// $Id$ +// vim:ft=javascript + +ARG_WITH("xmlwriter", "XMLWriter support", "no"); + +if (PHP_XMLWRITER == "yes" && PHP_LIBXML == "yes") { + if (CHECK_HEADER_ADD_INCLUDE('libxml/xmlwriter.h', 'CFLAGS_XMLWRITER', PHP_XMLWRITER)) { + EXTENSION("xmlwriter", "php_xmlwriter.c"); + AC_DEFINE("HAVE_XMLWRITER", 1, "XMLWriter support"); + if (!PHP_XMLWRITER_SHARED) { + ADD_FLAG("CFLAGS_XMLWRITER", "/D LIBXML_STATIC"); + } + ADD_EXTENSION_DEP('xmlwriter', 'libxml'); + } else { + WARNING('Could not find xmlwriter.h'); + } +} + diff --git a/ext/xmlwriter/examples/xmlwriter_file.php b/ext/xmlwriter/examples/xmlwriter_file.php new file mode 100644 index 0000000000..13bb262334 --- /dev/null +++ b/ext/xmlwriter/examples/xmlwriter_file.php @@ -0,0 +1,44 @@ +<?php +dl('xmlwriter.so'); + +$xw = xmlwriter_open_uri('./a.xml'); +xmlwriter_set_indent($xw, 1); +$res = xmlwriter_set_indent_string($xw, ' '); + +xmlwriter_start_document($xw, '1.0', 'UTF-8'); + +// A first element +xmlwriter_start_element($xw, 'tag1'); + +// Attribute 'att1' for element 'tag1' +xmlwriter_start_attribute($xw, 'att1'); +xmlwriter_text($xw, 'valueofatt1'); +xmlwriter_end_attribute($xw); + +xmlwriter_write_comment($xw, 'this is a comment.'); + +// Start a child element +xmlwriter_start_element($xw, 'tag11'); +xmlwriter_text($xw, utf8_encode('This is a sample text, ä')); +xmlwriter_end_element($xw); // tag11 + +xmlwriter_end_element($xw); // tag1 + + +// CDATA +xmlwriter_start_element($xw, 'testc'); +xmlwriter_write_cdata($xw, "This is a cdata content"); +xmlwriter_end_element($xw); // testctag + +xmlwriter_start_element($xw, 'testc'); +xmlwriter_start_cdata($xw); +xmlwriter_text($xw, "test cdata2"); +xmlwriter_end_cdata($xw); +xmlwriter_end_element($xw); // testctag + +// A processing instruction +xmlwriter_start_pi($xw, 'php'); +xmlwriter_text($xw, '$foo=2;echo $foo;'); +xmlwriter_end_pi($xw); + +xmlwriter_end_document($xw); diff --git a/ext/xmlwriter/examples/xmlwriter_mem.php b/ext/xmlwriter/examples/xmlwriter_mem.php new file mode 100644 index 0000000000..8f8eef9fa0 --- /dev/null +++ b/ext/xmlwriter/examples/xmlwriter_mem.php @@ -0,0 +1,39 @@ +<?php +dl('xmlwriter.so'); + +$xw = xmlwriter_open_memory(); +xmlwriter_set_indent($xw, 1); +$res = xmlwriter_set_indent_string($xw, ' '); + +xmlwriter_start_document($xw, '1.0', 'UTF-8'); + +// A first element +xmlwriter_start_element($xw, 'tag1'); + +// Attribute 'att1' for element 'tag1' +xmlwriter_start_attribute($xw, 'att1'); +xmlwriter_text($xw, 'valueofatt1'); +xmlwriter_end_attribute($xw); + +xmlwriter_text($xw, utf8_encode('This is a sample text, ä')); +xmlwriter_end_element($xw); // tag1 + + +$res = xmlwriter_start_comment($xw); +xmlwriter_text($xw, "Demo text comment"); +$res = xmlwriter_end_comment($xw); + +xmlwriter_end_document($xw); +$out = xmlwriter_output_memory($xw, 0); + +echo $out; + +// flush the xml buffer using optional +// flust argument, default is 1 +$out = xmlwriter_output_memory($xw, 1); +echo $out; + + +$out = xmlwriter_output_memory($xw); +echo $out; + diff --git a/ext/xmlwriter/examples/xmlwriter_mem_ns.php b/ext/xmlwriter/examples/xmlwriter_mem_ns.php new file mode 100644 index 0000000000..e4d013194e --- /dev/null +++ b/ext/xmlwriter/examples/xmlwriter_mem_ns.php @@ -0,0 +1,30 @@ +<?php +dl('xmlwriter.so'); + +$xw = xmlwriter_open_memory(); +xmlwriter_set_indent($xw, 1); +$res = xmlwriter_set_indent_string($xw, ' '); + +xmlwriter_start_document($xw, '1.0', 'UTF-8'); +// A first element +xmlwriter_start_element_ns($xw,'prefix', 'books', 'uri'); +xmlwriter_start_attribute($xw, 'isbn'); + +/* Uncomment this line if you have libxml 2.6.17 or CVS version + after 2005/02/22 + earlier versions segfault +*/ +/* +xmlwriter_start_attribute_ns($xw, 'prefix', 'isbn', 'uri'); +xmlwriter_end_attribute($xw); +*/ +xmlwriter_end_attribute($xw); + +xmlwriter_text($xw, 'book1'); +xmlwriter_end_element($xw); + +xmlwriter_end_document($xw); +$out = xmlwriter_output_memory($xw, 0); + +echo $out; + diff --git a/ext/xmlwriter/examples/xmlwriter_oo.php b/ext/xmlwriter/examples/xmlwriter_oo.php new file mode 100644 index 0000000000..01ada93781 --- /dev/null +++ b/ext/xmlwriter/examples/xmlwriter_oo.php @@ -0,0 +1,9 @@ +<?php +$xw = new XMLWriter(); +$xw->openUri('test.xml'); +$xw->startDocument("1.0"); +$xw->startElement("book"); +$xw->text("example"); +$xw->endElement(); +$xw->endDocument(); +$xw->flush(0); diff --git a/ext/xmlwriter/package.xml b/ext/xmlwriter/package.xml new file mode 100644 index 0000000000..01f7ad4424 --- /dev/null +++ b/ext/xmlwriter/package.xml @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!DOCTYPE package SYSTEM "../package.dtd"> +<package> + <name>xmlwriter</name> + <summary>Provides fast, non-cached, forward-only means to write XML data.</summary> + <description>This extension wraps the libxml xmlWriter API. Represents a writer that provides a non-cached, forward-only means of generating streams or files containing XML data. +</description> + <license>PHP</license> + <maintainers> + <maintainer> + <user>rrichards</user> + <name>Rob Richards</name> + <email>rrichards@php.net</email> + <role>lead</role> + </maintainer> + </maintainers> + <maintainer> + <user>pajoye</user> + <name>Pierre-Alain Joye</name> + <email>pajoye@php.net</email> + <role>developer</role> + </maintainer> + <release> + <version>2.0.2</version> + <date>2005-12-01</date> + <state>stable</state> + <notes>- fix build under 5.0 +- fix crash when XMLWriter is instantiated but not used +- Switch from BSD-like license to PHP License 3.01 +</notes> + </release> + <changelog> + <release> + <version>2.0.0</version> + <date>2005-08-07</date> + <state>stable</state> + <notes> + fix tests using UTF-8 + move to stable state + </notes> + </release> + + <release> + <version>1.1.0</version> + <date>2005-05-24</date> + <state>beta</state> + <notes> + Add OO interface (php5 only) + Add test cases + </notes> + </release> + <release> + <release> + <version>2.0.1</version> + <date>2005-11-15</date> + <state>stable</state> + <notes>- Switch from PHP License to BSD-like license +- Allow recursive calls to __get/__set for different properties (ilia) + </notes> + </release> + <version>1.0</version> + <date>2005-05-02</date> + <state>stable</state> + <notes> + Many Bug Fixes + Use PHP streams under PHP 4 + Add xmlwriter_flush function to flush buffer + Add support for xmlTextWriterStart/EndComment + </notes> + </release> + <release> + <version>0.1</version> + <date>2004-07-20</date> + <state>alpha</state> + <notes>Initial Release </notes> + </release> + <release> + <version>0.2</version> + <date>2004-10-08</date> + <state>alpha</state> + <notes>Fix bug 2482 and other function parameters</notes> + </release> + </changelog> + + <configureoptions> + <configureoption name="with-xmlwriter" default="autodetect" prompt="Include XMLWriter support?"/> + </configureoptions> + <filelist> + <file role="src" name="config.m4"/> + <file role="src" name="config.w32"/> + <file role="src" name="php_xmlwriter.c"/> + <file role="src" name="php_xmlwriter.h"/> + <dir name="tests" role="test"> + <file name="001.phpt"/> + <file name="002.phpt"/> + <file name="003.phpt"/> + <file name="004.phpt"/> + <file name="OO_001.phpt"/> + <file name="OO_002.phpt"/> + <file name="OO_003.phpt"/> + <file name="OO_004.phpt"/> + </dir> + </filelist> + <deps> + <dep type="php" rel="ge" version="4.3.0" /> + </deps> +</package> diff --git a/ext/xmlwriter/package2.xml b/ext/xmlwriter/package2.xml new file mode 100644 index 0000000000..ec6ef313b1 --- /dev/null +++ b/ext/xmlwriter/package2.xml @@ -0,0 +1,94 @@ +<?xml version="1.0"?> +<package packagerversion="1.4.0a2" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <name>xmlwriter</name> + <channel>pecl.php.net</channel> + <summary>Provides fast, non-cached, forward-only means to write XML data.</summary> + <description>This extension wraps the libxml xmlWriter API. Represents a writer that provides a non-cached, forward-only means of generating streams or files containing XML data. +</description> + <lead> + <name>Rob Richards</name> + <user>rrichards</user> + <email>rrichards@php.net</email> + <active>yes</active> + </lead> + <developer> + <name>Pierre-Alain Joye</name> + <user>pajoye</user> + <email>pajoye@php.net</email> + <active>yes</active> + </developer> + <date>2005-12-01</date> + <version> + <release>2.0.2</release> + <api>2.0.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license uri="http://www.php.net/license/3_01.txt">PHP</license> + <notes>- fix build under 5.0 +- fix crash when XMLWriter is instantiated but not used +- Switch from BSD-like license to PHP License 3.01 +</notes> + <contents> + <dir name="/"> + <file role="src" name="config.m4"/> + <file role="src" name="config.w32"/> + <file role="src" name="php_xmlwriter.c"/> + <file role="src" name="php_xmlwriter.h"/> + <dir name="tests" role="test"> + <file role="test" name="001.phpt"/> + <file role="test" name="002.phpt"/> + <file role="test" name="003.phpt"/> + <file role="test" name="004.phpt"/> + <file role="test" name="OO_001.phpt"/> + <file role="test" name="OO_002.phpt"/> + <file role="test" name="OO_003.phpt"/> + <file role="test" name="OO_004.phpt"/> + </dir> + </dir> + </contents> + <dependencies> + <required> + <php> + <min>4.3.0</min> + </php> + <pearinstaller> + <min>1.4.0a2</min> + </pearinstaller> + </required> + </dependencies> + <providesextension>xmlwriter</providesextension> + <extsrcrelease /> + <changelog> + <release> + <version> + <release>2.0.1</release> + <api>2.0.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD</license> + <notes>- Switch from PHP License to BSD-like license +- Allow recursive calls to __get/__set for different properties (ilia) + </notes> + </release> + <release> + <date>2005-08-07</date> + <time>01:20:00</time> + <version> + <release>2.0.0</release> + <api>2.0.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license uri="http://www.php.net/license">PHP License</license> + <notes>Promote to stable</notes> + </release> + </changelog> +</package> diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c new file mode 100644 index 0000000000..be72dd3e4b --- /dev/null +++ b/ext/xmlwriter/php_xmlwriter.c @@ -0,0 +1,1831 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2005 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Rob Richards <rrichards@php.net> | + | Pierre-A. Joye <pajoye@php.net> | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "php_xmlwriter.h" + +zend_class_entry *xmlwriter_class_entry; + +/* {{{ xmlwriter_object_free_storage */ +static void xmlwriter_free_resource_ptr(xmlwriter_object *intern TSRMLS_DC) +{ + if (intern) { + if (intern->ptr) { + xmlFreeTextWriter(intern->ptr); + intern->ptr = NULL; + } + if (intern->output) { + xmlBufferFree(intern->output); + intern->output = NULL; + } + efree(intern); + } +} +/* }}} */ + +#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); \ + intern = obj->xmlwriter_ptr; \ + if (!intern) { \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid or unitialized XMLWriter object"); \ + RETURN_FALSE; \ + } \ + } +/* }}} */ + +static zend_object_handlers xmlwriter_object_handlers; + +/* {{{ xmlwriter_object_free_storage */ +static void xmlwriter_object_free_storage(void *object TSRMLS_DC) +{ + ze_xmlwriter_object * intern = (ze_xmlwriter_object *) object; + if (!intern) { + return; + } + if (intern->xmlwriter_ptr) { + xmlwriter_free_resource_ptr(intern->xmlwriter_ptr TSRMLS_CC); + } + intern->xmlwriter_ptr = NULL; + if (intern->zo.properties) { + zend_hash_destroy(intern->zo.properties); + FREE_HASHTABLE(intern->zo.properties); + } + + efree(intern); +} +/* }}} */ + + +/* {{{ xmlwriter_object_new */ +PHP_XMLWRITER_API zend_object_value xmlwriter_object_new(zend_class_entry *class_type TSRMLS_DC) +{ + ze_xmlwriter_object *intern; + zval *tmp; + zend_object_value retval; + + intern = emalloc(sizeof(ze_xmlwriter_object)); + memset(&intern->zo, 0, sizeof(zend_object)); + intern->zo.ce = class_type; + intern->xmlwriter_ptr = NULL; + + ALLOC_HASHTABLE(intern->zo.properties); + zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, + (void *) &tmp, sizeof(zval *)); + + 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; +} +/* }}} */ +#endif + +#define XMLW_NAME_CHK(__err) \ + if (xmlValidateName((xmlChar *) name, 0) != 0) { \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, #__err); \ + RETURN_FALSE; \ + } \ + +/* {{{ xmlwriter_functions */ +static zend_function_entry xmlwriter_functions[] = { + PHP_FE(xmlwriter_open_uri, NULL) + PHP_FE(xmlwriter_open_memory, NULL) +#if LIBXML_VERSION >= 20605 + PHP_FE(xmlwriter_set_indent, NULL) + PHP_FE(xmlwriter_set_indent_string, NULL) +#endif +#if LIBXML_VERSION >= 20607 + PHP_FE(xmlwriter_start_comment, NULL) + PHP_FE(xmlwriter_end_comment, NULL) +#endif + PHP_FE(xmlwriter_start_attribute, NULL) + PHP_FE(xmlwriter_end_attribute, NULL) + PHP_FE(xmlwriter_write_attribute, NULL) +#if LIBXML_VERSION > 20617 + PHP_FE(xmlwriter_start_attribute_ns,NULL) +#endif + PHP_FE(xmlwriter_start_element, NULL) + PHP_FE(xmlwriter_end_element, NULL) + PHP_FE(xmlwriter_start_element_ns, NULL) + PHP_FE(xmlwriter_write_element, NULL) + PHP_FE(xmlwriter_write_element_ns, NULL) + PHP_FE(xmlwriter_start_pi, NULL) + PHP_FE(xmlwriter_end_pi, NULL) + PHP_FE(xmlwriter_write_pi, NULL) + PHP_FE(xmlwriter_start_cdata, NULL) + PHP_FE(xmlwriter_end_cdata, NULL) + PHP_FE(xmlwriter_write_cdata, NULL) + PHP_FE(xmlwriter_text, NULL) + PHP_FE(xmlwriter_start_document, NULL) + PHP_FE(xmlwriter_end_document, NULL) + PHP_FE(xmlwriter_write_comment, NULL) + PHP_FE(xmlwriter_start_dtd, NULL) + PHP_FE(xmlwriter_end_dtd, NULL) + PHP_FE(xmlwriter_write_dtd, NULL) + PHP_FE(xmlwriter_start_dtd_element, NULL) + PHP_FE(xmlwriter_end_dtd_element, NULL) + PHP_FE(xmlwriter_output_memory, NULL) + PHP_FE(xmlwriter_flush, NULL) + {NULL, NULL, NULL} +}; +/* }}} */ + +#ifdef ZEND_ENGINE_2 +/* {{{ xmlwriter_class_functions */ +static zend_function_entry xmlwriter_class_functions[] = { + PHP_ME_MAPPING(openUri, xmlwriter_open_uri, NULL) + PHP_ME_MAPPING(openMemory, xmlwriter_open_memory, NULL) +#if LIBXML_VERSION >= 20605 + PHP_ME_MAPPING(setIndent, xmlwriter_set_indent, NULL) + PHP_ME_MAPPING(setIndentString, xmlwriter_set_indent_string, NULL) +#endif +#if LIBXML_VERSION >= 20607 + PHP_ME_MAPPING(startComment, xmlwriter_start_comment, NULL) + PHP_ME_MAPPING(endComment, xmlwriter_end_comment, NULL) +#endif + PHP_ME_MAPPING(startAttribute, xmlwriter_start_attribute, NULL) + PHP_ME_MAPPING(endAttribute, xmlwriter_end_attribute, NULL) + PHP_ME_MAPPING(writeAttribute, xmlwriter_write_attribute, NULL) +#if LIBXML_VERSION > 20617 + PHP_ME_MAPPING(startAttributeNs, xmlwriter_start_attribute_ns,NULL) +#endif + PHP_ME_MAPPING(startElement, xmlwriter_start_element, NULL) + PHP_ME_MAPPING(endElement, xmlwriter_end_element, NULL) + PHP_ME_MAPPING(startElementNs, xmlwriter_start_element_ns, NULL) + PHP_ME_MAPPING(writeElement, xmlwriter_write_element, NULL) + PHP_ME_MAPPING(writeElementNs, xmlwriter_write_element_ns, NULL) + PHP_ME_MAPPING(startPi, xmlwriter_start_pi, NULL) + PHP_ME_MAPPING(endPi, xmlwriter_end_pi, NULL) + PHP_ME_MAPPING(writePi, xmlwriter_write_pi, NULL) + PHP_ME_MAPPING(startCdata, xmlwriter_start_cdata, NULL) + PHP_ME_MAPPING(endCdata, xmlwriter_end_cdata, NULL) + PHP_ME_MAPPING(writeCdata, xmlwriter_write_cdata, NULL) + PHP_ME_MAPPING(text, xmlwriter_text, NULL) + PHP_ME_MAPPING(startDocument, xmlwriter_start_document, NULL) + PHP_ME_MAPPING(endDocument, xmlwriter_end_document, NULL) + PHP_ME_MAPPING(writeComment, xmlwriter_write_comment, NULL) + PHP_ME_MAPPING(startDtd, xmlwriter_start_dtd, NULL) + PHP_ME_MAPPING(endDtd, xmlwriter_end_dtd, NULL) + PHP_ME_MAPPING(writeDtd, xmlwriter_write_dtd, NULL) + PHP_ME_MAPPING(startDtdElement, xmlwriter_start_dtd_element, NULL) + PHP_ME_MAPPING(endDtdElement, xmlwriter_end_dtd_element, NULL) + PHP_ME_MAPPING(outputMemory, xmlwriter_output_memory, NULL) + PHP_ME_MAPPING(flush, xmlwriter_flush, NULL) + {NULL, NULL, NULL} +}; +/* }}} */ +#endif + +/* {{{ function prototypes */ +PHP_MINIT_FUNCTION(xmlwriter); +PHP_MSHUTDOWN_FUNCTION(xmlwriter); +PHP_MINFO_FUNCTION(xmlwriter); + +static int le_xmlwriter; +/* }}} */ + +/* _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 */ +char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, int resolved_path_len TSRMLS_DC) { + xmlURI *uri; + xmlChar *escsource; + char *file_dest; + int isFileUri = 0; + + uri = xmlCreateURI(); + escsource = xmlURIEscapeStr(source, ":"); + xmlParseURIReference(uri, escsource); + xmlFree(escsource); + + if (uri->scheme != NULL) { + /* absolute file uris - libxml only supports localhost or empty host */ + if (strncasecmp(source, "file:///",8) == 0) { + isFileUri = 1; +#ifdef PHP_WIN32 + source += 8; +#else + source += 7; +#endif + } else if (strncasecmp(source, "file://localhost/",17) == 0) { + isFileUri = 1; +#ifdef PHP_WIN32 + source += 17; +#else + source += 16; +#endif + } + } + + file_dest = source; + + if ((uri->scheme == NULL || isFileUri)) { + /* XXX possible buffer overflow if VCWD_REALPATH does not know size of resolved_path */ + if (! VCWD_REALPATH(source, resolved_path)) { + expand_filepath(source, resolved_path TSRMLS_CC); + } + file_dest = resolved_path; + } + + xmlFreeURI(uri); + + return file_dest; +} +/* }}} */ + +#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", ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, NULL); + return ret_val; +} +/* }}} */ + +/* {{{ php_xmlwriter_streams_IO_write */ +int php_xmlwriter_streams_IO_write(void *context, const char *buffer, int len) +{ + TSRMLS_FETCH(); + return php_stream_write((php_stream*)context, buffer, len); +} +/* }}} */ + +/* {{{ xmlwriter_objects_clone */ +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 = { + STANDARD_MODULE_HEADER, + "xmlwriter", + xmlwriter_functions, + PHP_MINIT(xmlwriter), + PHP_MSHUTDOWN(xmlwriter), + NULL, + NULL, + PHP_MINFO(xmlwriter), + "0.1", + STANDARD_MODULE_PROPERTIES +}; +/* }}} */ + +#ifdef COMPILE_DL_XMLWRITER +ZEND_GET_MODULE(xmlwriter) +#endif + +/* {{{ xmlwriter_objects_clone */ +void xmlwriter_objects_clone(void *object, void **object_clone TSRMLS_DC) +{ + /* TODO */ +} +/* }}} */ + +/* {{{ xmlwriter_dtor */ +static void xmlwriter_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) { + xmlwriter_object *intern; + + intern = (xmlwriter_object *) rsrc->ptr; + xmlwriter_free_resource_ptr(intern TSRMLS_CC); +} +/* }}} */ + +#if LIBXML_VERSION >= 20605 +/* {{{ proto bool xmlwriter_set_indent(resource xmlwriter, bool) +Toggle indentation on/off - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_set_indent) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + int retval; + zend_bool indent; + +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + + if (this) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &pind, &indent) == FAILURE) { + return; + } + XMLWRITER_FROM_OBJECT(intern, this); + } else +#endif + { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rb", &pind, &indent) == FAILURE) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + + ptr = intern->ptr; + if (ptr) { + retval = xmlTextWriterSetIndent(ptr, indent); + if (retval == 0) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_set_indent_string(resource xmlwriter, string indentString) +Set string used for indenting - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_set_indent_string) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *indent; + int indent_len, retval; + +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + + if (this) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &indent, &indent_len) == FAILURE) { + return; + } + XMLWRITER_FROM_OBJECT(intern, this); + } else +#endif + { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &indent, &indent_len) == FAILURE) { + return; + } + + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterSetIndentString(ptr, indent); + if (retval == 0) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +#endif + +/* {{{ proto bool xmlwriter_start_attribute(resource xmlwriter, string name) +Create start attribute - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_start_attribute) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *name; + int name_len, retval; +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + + if (this) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "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) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + + XMLW_NAME_CHK("Invalid Element Name"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterStartAttribute(ptr, name); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +static void php_xmlwriter_end(INTERNAL_FUNCTION_PARAMETERS, int type) +{ + zval *pind; + 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) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + ptr = intern->ptr; + + if (ptr) { + switch (type) { + case 0: + retval = xmlTextWriterEndAttribute(ptr); + break; + case 1: + retval = xmlTextWriterEndElement(ptr); + break; + case 2: + retval = xmlTextWriterEndPI(ptr); + break; + case 3: + retval = xmlTextWriterEndCDATA(ptr); + break; + case 4: + retval = xmlTextWriterEndComment(ptr); + break; + case 5: + retval = xmlTextWriterEndDocument(ptr); + break; + case 6: + retval = xmlTextWriterEndDTD(ptr); + break; + case 7: + retval = xmlTextWriterEndDTDElement(ptr); + break; + case 8: + retval = xmlTextWriterEndDTDAttlist(ptr); + break; + case 9: + retval = xmlTextWriterEndDTDEntity(ptr); + break; + default: + retval = -1; + break; + } + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} + + +/* {{{ proto bool xmlwriter_end_attribute(resource xmlwriter) +End attribute - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_end_attribute) +{ + php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); +} +/* }}} */ + +#if LIBXML_VERSION > 20617 +/* {{{ proto bool xmlwriter_start_attribute_ns(resource xmlwriter, string prefix, string name, string uri) +Create start namespaced attribute - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_start_attribute_ns) +{ + zval *pind; + 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", + &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, + &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + XMLW_NAME_CHK("Invalid Attribute Name"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterStartAttributeNS(ptr, prefix, name, uri); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ +#endif + +/* {{{ proto bool xmlwriter_write_attribute(resource xmlwriter, string name, string content) +Write full attribute - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_write_attribute) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *name, *content; + 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", + &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, + &name, &name_len, &content, &content_len) == FAILURE) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + XMLW_NAME_CHK("Invalid Attribute Name"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterWriteAttribute(ptr, name, content); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_write_attribute_ns(resource xmlwriter, string prefix, string name, string uri, string content) +Write full namespaced attribute - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_write_attribute_ns) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *name, *prefix, *uri, *content; + 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, "ssss", + &name, &name_len, &content, &content_len) == FAILURE) { + return; + } + XMLWRITER_FROM_OBJECT(intern, this); + } else +#endif + { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssss", &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); + } + + XMLW_NAME_CHK("Invalid Attribute Name"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterWriteAttributeNS(ptr, prefix, name, uri, content); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_start_element(resource xmlwriter, string name) +Create start element tag - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_start_element) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *name; + int name_len, retval; +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + + if (this) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "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) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + XMLW_NAME_CHK("Invalid Element Name"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterStartElement(ptr, name); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + + +/* {{{ proto bool xmlwriter_start_element_ns(resource xmlwriter, string prefix, string name, string uri) +Create start namespaced element tag - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_start_element_ns) +{ + zval *pind; + 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", + &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, + &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + XMLW_NAME_CHK("Invalid Element Name"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterStartElementNS(ptr, prefix, name, uri); + if (retval != -1) { + RETURN_TRUE; + } + + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_end_element(resource xmlwriter) +End current element - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_end_element) +{ + php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); +} +/* }}} */ + +/* {{{ proto bool xmlwriter_write_element(resource xmlwriter, string name, string content) +Write full element tag - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_write_element) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *name, *content; + 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", + &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, + &name, &name_len, &content, &content_len) == FAILURE) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + XMLW_NAME_CHK("Invalid Element Name"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterWriteElement(ptr, name, content); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ 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 */ +PHP_FUNCTION(xmlwriter_write_element_ns) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *name, *prefix, *uri, *content; + 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, "rssss", + &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, "rssss", &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); + } + + XMLW_NAME_CHK("Invalid Element Name"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterWriteElementNS(ptr, prefix, name, uri, content); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_start_pi(resource xmlwriter, string target) +Create start PI tag - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_start_pi) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *name; + int name_len, retval; + +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + + if (this) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "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) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + XMLW_NAME_CHK("Invalid PI Target"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterStartPI(ptr, name); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_end_pi(resource xmlwriter) +End current PI - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_end_pi) +{ + php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, 2); +} +/* }}} */ + +/* {{{ proto bool xmlwriter_write_pi(resource xmlwriter, string target, string content) +Write full PI tag - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_write_pi) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *name, *content; + 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", + &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, + &name, &name_len, &content, &content_len) == FAILURE) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + XMLW_NAME_CHK("Invalid PI Target"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterWritePI(ptr, name, content); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_start_cdata(resource xmlwriter) +Create start CDATA tag - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_start_cdata) +{ + zval *pind; + 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) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterStartCDATA(ptr); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_end_cdata(resource xmlwriter) +End current CDATA - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_end_cdata) +{ + php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, 3); +} +/* }}} */ + +/* {{{ proto bool xmlwriter_write_cdata(resource xmlwriter, string content) +Write full CDATA tag - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_write_cdata) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *content; + int content_len, retval; + +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + + if (this) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &content, &content_len) == FAILURE) { + return; + } + XMLWRITER_FROM_OBJECT(intern, this); + } else +#endif + { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, + &content, &content_len) == FAILURE) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterWriteCDATA(ptr, content); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_text(resource xmlwriter, string content) +Write text - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_text) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *content; + int content_len, retval; + +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + + if (this) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &content, &content_len) == FAILURE) { + return; + } + XMLWRITER_FROM_OBJECT(intern, this); + } else +#endif + { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &content, &content_len) == FAILURE) { + return; + } + + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterWriteString(ptr, content); + if (retval) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +#if LIBXML_VERSION >= 20607 +/* {{{ proto bool xmlwriter_start_comment(resource xmlwriter) +Create start comment - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_start_comment) +{ + zval *pind; + 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) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterStartComment(ptr); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_end_comment(resource xmlwriter) +Create end comment - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_end_comment) +{ + php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, 4); +} +/* }}} */ +#endif /* LIBXML_VERSION >= 20607 */ + + +/* {{{ proto bool xmlwriter_write_comment(resource xmlwriter, string content) +Write full comment tag - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_write_comment) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *content; + int content_len, retval; + + +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + + if (this) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", + &content, &content_len) == FAILURE) { + return; + } + XMLWRITER_FROM_OBJECT(intern, this); + } else +#endif + { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, + &content, &content_len) == FAILURE) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterWriteComment(ptr, content); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_start_document(resource xmlwriter, string version, string encoding, string standalone) +Create document tag - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_start_document) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *version = NULL, *enc = NULL, *alone = NULL; + int version_len, enc_len, alone_len, retval; + +#ifdef ZEND_ENGINE_2 + zval *this = 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) { + 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) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterStartDocument(ptr, version, enc, alone); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_end_document(resource xmlwriter) +End current document - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_end_document) +{ + php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, 5); +} +/* }}} */ + +/* {{{ proto bool xmlwriter_start_dtd(resource xmlwriter, string name, string pubid, string sysid) +Create start DTD tag - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_start_dtd) +{ + zval *pind; + 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(); + + if (this) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|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) { + return; + } + + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterStartDTD(ptr, name, pubid, sysid); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_end_dtd(resource xmlwriter) +End current DTD - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_end_dtd) +{ + php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, 6); +} +/* }}} */ + +/* {{{ proto bool xmlwriter_write_dtd(resource xmlwriter, string name, string pubid, string sysid, string subset) +Write full DTD tag - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_write_dtd) +{ + zval *pind; + 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(); + + 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) { + 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) { + return; + } + + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterWriteDTD(ptr, name, pubid, sysid, subset); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_start_dtd_element(resource xmlwriter, string name) +Create start DTD element - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_start_dtd_element) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *name; + int name_len, retval; + +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + + if (this) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "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) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + XMLW_NAME_CHK("Invalid Attribute Name"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterStartDTDElement(ptr, name); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_end_dtd_element(resource xmlwriter) +End current DTD element - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_end_dtd_element) +{ + php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, 7); +} +/* }}} */ + +/* {{{ proto bool xmlwriter_write_dtd_element(resource xmlwriter, string name, string content) +Write full DTD element tag - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_write_dtd_element) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *name, *content; + int name_len, content_len, retval; + +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + + if (this) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { + return; + } + XMLWRITER_FROM_OBJECT(intern, this); + } else +#endif + { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind, + &name, &name_len, &content, &content_len) == FAILURE) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + XMLW_NAME_CHK("Invalid Element Name"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterWriteDTDElement(ptr, name, content); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_start_dtd_attlist(resource xmlwriter, string name) +Create start DTD AttList - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_start_dtd_attlist) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *name; + int name_len, retval; + +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + + if (this) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "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) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + XMLW_NAME_CHK("Invalid Attribute Name"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterStartDTDAttlist(ptr, name); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_end_dtd_attlist(resource xmlwriter) +End current DTD AttList - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_end_dtd_attlist) +{ + php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, 8); +} +/* }}} */ + +/* {{{ proto bool xmlwriter_write_dtd_attlist(resource xmlwriter, string name, string content) +Write full DTD AttList tag - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_write_dtd_attlist) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *name, *content; + 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", + &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, + &name, &name_len, &content, &content_len) == FAILURE) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + XMLW_NAME_CHK("Invalid Element Name"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterWriteDTDAttlist(ptr, name, content); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_start_dtd_entity(resource xmlwriter, string name, bool isparam) +Create start DTD Entity - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_start_dtd_entity) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *name; + int name_len, retval; + zend_bool isparm; + + +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + + if (this) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "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) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + XMLW_NAME_CHK("Invalid Attribute Name"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterStartDTDEntity(ptr, isparm, name); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto bool xmlwriter_end_dtd_entity(resource xmlwriter) +End current DTD Entity - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_end_dtd_entity) +{ + php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, 9); +} +/* }}} */ + +/* {{{ proto bool xmlwriter_write_dtd_entity(resource xmlwriter, string name, string content) +Write full DTD Entity tag - returns FALSE on error */ +PHP_FUNCTION(xmlwriter_write_dtd_entity) +{ + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *name, *content; + 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", + &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, + &name, &name_len, &content, &content_len) == FAILURE) { + return; + } + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + + XMLW_NAME_CHK("Invalid Element Name"); + + ptr = intern->ptr; + + if (ptr) { + retval = xmlTextWriterWriteDTDAttlist(ptr, name, content); + if (retval != -1) { + RETURN_TRUE; + } + } + + RETURN_FALSE; +} +/* }}} */ + +/* {{{ proto resource xmlwriter_open_uri(resource xmlwriter, string source) +Create new xmlwriter using source uri for output */ +PHP_FUNCTION(xmlwriter_open_uri) +{ + char *valid_file = NULL; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + char *source; + char resolved_path[MAXPATHLEN + 1]; + int source_len; + +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + ze_xmlwriter_object *ze_obj; +#endif + +#ifndef ZEND_ENGINE_2 + xmlOutputBufferPtr out_buffer; + void *ioctx; +#endif + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &source, &source_len) == FAILURE) { + WRONG_PARAM_COUNT; + return; + } + +#ifdef ZEND_ENGINE_2 + if (this) { + // We do not use XMLWRITER_FROM_OBJECT, xmlwriter init function here + ze_obj = (ze_xmlwriter_object*) zend_object_store_get_object(this TSRMLS_CC); + } +#endif + + if (source_len == 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty string as source"); + RETURN_FALSE; + } + + valid_file = _xmlwriter_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); + if (!valid_file) { + RETURN_FALSE; + } + +#ifndef ZEND_ENGINE_2 + ioctx = php_xmlwriter_streams_IO_open_write_wrapper(valid_file TSRMLS_CC); + if (ioctx == NULL) { + 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; + } + + intern = emalloc(sizeof(xmlwriter_object)); + intern->ptr = ptr; + intern->output = NULL; +#ifndef ZEND_ENGINE_2 + intern->uri_output = out_buffer; +#else + if (this) { + ze_obj->xmlwriter_ptr = intern; + RETURN_TRUE; + } else +#endif + { + ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter); + } +} +/* }}} */ + +/* {{{ proto resource xmlwriter_open_memory() +Create new xmlwriter using memory for string output */ +PHP_FUNCTION(xmlwriter_open_memory) +{ + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + xmlBufferPtr buffer; + +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + ze_xmlwriter_object *ze_obj; +#endif + +#ifdef ZEND_ENGINE_2 + if (this) { + // We do not use XMLWRITER_FROM_OBJECT, xmlwriter init function here + ze_obj = (ze_xmlwriter_object*) zend_object_store_get_object(this TSRMLS_CC); + } +#endif + + buffer = xmlBufferCreate(); + + if (buffer == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create output buffer"); + RETURN_FALSE; + } + + ptr = xmlNewTextWriterMemory(buffer, 0); + if (! ptr) { + xmlBufferFree(buffer); + RETURN_FALSE; + } + + intern = emalloc(sizeof(xmlwriter_object)); + intern->ptr = ptr; + intern->output = buffer; +#ifndef ZEND_ENGINE_2 + intern->uri_output = NULL; +#else + if (this) { + ze_obj->xmlwriter_ptr = intern; + RETURN_TRUE; + } else +#endif + { + ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter); + } + +} +/* }}} */ + +/* {{{ php_xmlwriter_flush */ +static void php_xmlwriter_flush(INTERNAL_FUNCTION_PARAMETERS, int force_string) { + zval *pind; + xmlwriter_object *intern; + xmlTextWriterPtr ptr; + xmlBufferPtr buffer; + zend_bool empty = 1; + int output_bytes; + + +#ifdef ZEND_ENGINE_2 + zval *this = getThis(); + + if (this) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|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) { + return; + } + + ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter); + } + ptr = intern->ptr; + + if (ptr) { + buffer = intern->output; + if (force_string == 1 && buffer == NULL) { + RETURN_EMPTY_STRING(); + } + output_bytes = xmlTextWriterFlush(ptr); + if (buffer) { + RETVAL_STRING(buffer->content, 1); + if (empty) { + xmlBufferEmpty(buffer); + } + } else { + RETVAL_LONG(output_bytes); + } + return; + } + + RETURN_EMPTY_STRING(); +} +/* }}} */ + +/* {{{ proto string xmlwriter_output_memory(resource xmlwriter [,bool flush]) +Output current buffer as string */ +PHP_FUNCTION(xmlwriter_output_memory) +{ + php_xmlwriter_flush(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); +} +/* }}} */ + +/* {{{ proto mixed xmlwriter_flush(resource xmlwriter [,bool empty]) +Output current buffer */ +PHP_FUNCTION(xmlwriter_flush) +{ + php_xmlwriter_flush(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); +} +/* }}} */ + +/* {{{ PHP_MINIT_FUNCTION + */ +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; + 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 + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_MSHUTDOWN_FUNCTION + */ +PHP_MSHUTDOWN_FUNCTION(xmlwriter) +{ + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_MINFO_FUNCTION + */ +PHP_MINFO_FUNCTION(xmlwriter) +{ + php_info_print_table_start(); + { + php_info_print_table_row(2, "XMLWriter", "enabled"); + } + php_info_print_table_end(); +} +/* }}} */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/xmlwriter/php_xmlwriter.h b/ext/xmlwriter/php_xmlwriter.h new file mode 100644 index 0000000000..933d7f11af --- /dev/null +++ b/ext/xmlwriter/php_xmlwriter.h @@ -0,0 +1,112 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2005 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Rob Richards <rrichards@php.net> | + | Pierre-A. Joye <pajoye@php.net> | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifndef PHP_XMLWRITER_H +#define PHP_XMLWRITER_H + +extern zend_module_entry xmlwriter_module_entry; +#define phpext_xmlwriter_ptr &xmlwriter_module_entry + +#ifdef PHP_WIN32 +#define PHP_XMLWRITER_API __declspec(dllexport) +#else +#define PHP_XMLWRITER_API +#endif + +#ifdef ZTS +#include "TSRM.h" +#endif + +#include <libxml/tree.h> +#include <libxml/xmlwriter.h> +#include <libxml/uri.h> + +/* Resource struct, not the object :) */ +typedef struct _xmlwriter_object { + xmlTextWriterPtr ptr; + xmlBufferPtr output; +#ifndef ZEND_ENGINE_2 + xmlOutputBufferPtr uri_output; +#endif +} xmlwriter_object; + + +/* Extends zend object */ +typedef struct _ze_xmlwriter_object { + zend_object zo; + xmlwriter_object *xmlwriter_ptr; +} ze_xmlwriter_object; + +static void xmlwriter_free_resource_ptr(xmlwriter_object *intern TSRMLS_DC); +static void xmlwriter_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC); + +zend_class_entry *xmlwriter_class_entry_ce; + +#if LIBXML_VERSION >= 20605 +PHP_FUNCTION(xmlwriter_set_indent); +PHP_FUNCTION(xmlwriter_set_indent_string); +#endif +PHP_FUNCTION(xmlwriter_start_attribute); +PHP_FUNCTION(xmlwriter_end_attribute); +PHP_FUNCTION(xmlwriter_start_attribute_ns); +PHP_FUNCTION(xmlwriter_write_attribute); +#if LIBXML_VERSION > 20617 +PHP_FUNCTION(xmlwriter_write_attribute_ns); +#endif +PHP_FUNCTION(xmlwriter_start_element); +PHP_FUNCTION(xmlwriter_end_element); +PHP_FUNCTION(xmlwriter_start_element_ns); +PHP_FUNCTION(xmlwriter_write_element); +PHP_FUNCTION(xmlwriter_write_element_ns); +PHP_FUNCTION(xmlwriter_start_pi); +PHP_FUNCTION(xmlwriter_end_pi); +PHP_FUNCTION(xmlwriter_write_pi); +PHP_FUNCTION(xmlwriter_start_cdata); +PHP_FUNCTION(xmlwriter_end_cdata); +PHP_FUNCTION(xmlwriter_write_cdata); +PHP_FUNCTION(xmlwriter_text); +PHP_FUNCTION(xmlwriter_start_document); +PHP_FUNCTION(xmlwriter_end_document); +#if LIBXML_VERSION >= 20607 +PHP_FUNCTION(xmlwriter_start_comment); +PHP_FUNCTION(xmlwriter_end_comment); +#endif +PHP_FUNCTION(xmlwriter_write_comment); +PHP_FUNCTION(xmlwriter_start_dtd); +PHP_FUNCTION(xmlwriter_end_dtd); +PHP_FUNCTION(xmlwriter_write_dtd); +PHP_FUNCTION(xmlwriter_start_dtd_element); +PHP_FUNCTION(xmlwriter_end_dtd_element); +PHP_FUNCTION(xmlwriter_open_uri); +PHP_FUNCTION(xmlwriter_open_memory); +PHP_FUNCTION(xmlwriter_output_memory); +PHP_FUNCTION(xmlwriter_flush); + +#endif /* PHP_XMLWRITER_H */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/xmlwriter/tests/001.phpt b/ext/xmlwriter/tests/001.phpt new file mode 100644 index 0000000000..a9349d2d16 --- /dev/null +++ b/ext/xmlwriter/tests/001.phpt @@ -0,0 +1,25 @@ +--TEST-- +XMLWriter: libxml2 XML Writer, file buffer, flush +--SKIPIF-- +<?php if (!extension_loaded("xmlwriter")) print "skip"; ?> +--FILE-- +<?php +/* $Id$ */ + +$doc_dest = '001.xml'; +$xw = xmlwriter_open_uri($doc_dest); +xmlwriter_start_document($xw, '1.0', 'UTF-8'); +xmlwriter_start_element($xw, "tag1"); +xmlwriter_end_document($xw); + +// Force to write and empty the buffer +$output_bytes = xmlwriter_flush($xw, true); +echo file_get_contents($doc_dest); +unset($xw); +unlink('001.xml'); +?> +===DONE=== +--EXPECT-- +<?xml version="1.0" encoding="UTF-8"?> +<tag1/> +===DONE=== diff --git a/ext/xmlwriter/tests/002.phpt b/ext/xmlwriter/tests/002.phpt new file mode 100644 index 0000000000..f2537a47ff --- /dev/null +++ b/ext/xmlwriter/tests/002.phpt @@ -0,0 +1,22 @@ +--TEST-- +XMLWriter: libxml2 XML Writer, membuffer, flush +--SKIPIF-- +<?php if (!extension_loaded("xmlwriter")) print "skip"; ?> +--FILE-- +<?php +/* $Id$ */ + +$doc_dest = '001.xml'; +$xw = xmlwriter_open_memory($doc_dest); +xmlwriter_start_document($xw, '1.0', 'UTF-8'); +xmlwriter_start_element($xw, "tag1"); +xmlwriter_end_document($xw); + +// Force to write and empty the buffer +echo xmlwriter_flush($xw, true); +?> +===DONE=== +--EXPECT-- +<?xml version="1.0" encoding="UTF-8"?> +<tag1/> +===DONE=== diff --git a/ext/xmlwriter/tests/003.phpt b/ext/xmlwriter/tests/003.phpt new file mode 100644 index 0000000000..5415797864 --- /dev/null +++ b/ext/xmlwriter/tests/003.phpt @@ -0,0 +1,35 @@ +--TEST-- +XMLWriter: libxml2 XML Writer, membuffer, flush, attribute +--SKIPIF-- +<?php if (!extension_loaded("xmlwriter")) print "skip"; ?> +--FILE-- +<?php +/* $Id$ */ + +$doc_dest = '001.xml'; +$xw = xmlwriter_open_memory($doc_dest); +xmlwriter_start_document($xw, '1.0', 'UTF-8'); +xmlwriter_start_element($xw, "tag1"); + + +$res = xmlwriter_start_attribute($xw, 'attr1'); +xmlwriter_text($xw, "attr1_value"); +xmlwriter_end_attribute($xw); + +xmlwriter_write_attribute($xw, "att2", "att2_value"); +xmlwriter_text($xw, "Test text for tag1"); +$res = xmlwriter_start_element($xw, 'tag2'); +if ($res < 1) { + echo "StartElement context validation failed\n"; + exit(); +} +xmlwriter_end_document($xw); + +// Force to write and empty the buffer +echo xmlwriter_flush($xw, true); +?> +===DONE=== +--EXPECT-- +<?xml version="1.0" encoding="UTF-8"?> +<tag1 attr1="attr1_value" att2="att2_value">Test text for tag1<tag2/></tag1> +===DONE=== diff --git a/ext/xmlwriter/tests/004.phpt b/ext/xmlwriter/tests/004.phpt new file mode 100644 index 0000000000..2d3e858725 --- /dev/null +++ b/ext/xmlwriter/tests/004.phpt @@ -0,0 +1,36 @@ +--TEST-- +XMLWriter: libxml2 XML Writer, file buffer, flush +--SKIPIF-- +<?php if (!extension_loaded("xmlwriter")) print "skip"; ?> +--FILE-- +<?php +/* $Id$ */ + +$doc_dest = '001.xml'; +$xw = xmlwriter_open_uri($doc_dest); +xmlwriter_start_document($xw, '1.0', 'UTF-8'); +xmlwriter_start_element($xw, "tag1"); + +xmlwriter_start_pi($xw, "PHP"); +xmlwriter_text($xw, 'echo $a;'); +xmlwriter_end_pi($xw); +xmlwriter_end_document($xw); + +// Force to write and empty the buffer +$output_bytes = xmlwriter_flush($xw, true); +$md5_out = md5_file($doc_dest); +$md5_res = md5('<?xml version="1.0" encoding="UTF-8"?> +<tag1><?PHP echo $a;?></tag1> +'); +unset($xw); +unlink('001.xml'); +if ($md5_out != $md5_res) { + echo "failed: $md5_res != $md5_out\n"; +} else { + echo "ok.\n"; +} +?> +===DONE=== +--EXPECT-- +ok. +===DONE=== diff --git a/ext/xmlwriter/tests/005.phpt b/ext/xmlwriter/tests/005.phpt new file mode 100644 index 0000000000..ab933c6f56 --- /dev/null +++ b/ext/xmlwriter/tests/005.phpt @@ -0,0 +1,33 @@ +--TEST-- +XMLWriter: libxml2 XML Writer, comments +--SKIPIF-- +<?php +if (!extension_loaded("xmlwriter")) die("skip"); +if (!function_exists("xmlwriter_start_comment")) die("skip: libxml2 2.6.7+ required"); +?> +--FILE-- +<?php +/* $Id$ */ + +$doc_dest = '001.xml'; +$xw = xmlwriter_open_uri($doc_dest); +xmlwriter_start_document($xw, '1.0', 'UTF-8'); +xmlwriter_start_element($xw, "tag1"); + +xmlwriter_start_comment($xw); +xmlwriter_text($xw, 'comment'); +xmlwriter_end_comment($xw); +xmlwriter_write_comment($xw, "comment #2"); +xmlwriter_end_document($xw); + +// Force to write and empty the buffer +$output_bytes = xmlwriter_flush($xw, true); +echo file_get_contents($doc_dest); +unset($xw); +unlink('001.xml'); +?> +===DONE=== +--EXPECT-- +<?xml version="1.0" encoding="UTF-8"?> +<tag1><!--comment--><!--comment #2--></tag1> +===DONE=== diff --git a/ext/xmlwriter/tests/OO_001.phpt b/ext/xmlwriter/tests/OO_001.phpt new file mode 100644 index 0000000000..be448b9c65 --- /dev/null +++ b/ext/xmlwriter/tests/OO_001.phpt @@ -0,0 +1,26 @@ +--TEST-- +XMLWriter: libxml2 XML Writer, file buffer, flush +--SKIPIF-- +<?php if (!extension_loaded("xmlwriter")) print "skip"; ?> +--FILE-- +<?php +/* $Id$ */ + +$doc_dest = '001.xml'; +$xw = new XMLWriter(); +$xw->openUri($doc_dest); +$xw->startDocument('1.0', 'UTF-8', 'standalonearg'); +$xw->startElement("tag1"); +$xw->endDocument(); + +// Force to write and empty the buffer +$output_bytes = $xw->flush(true); +echo file_get_contents($doc_dest); +unset($xw); +unlink('001.xml'); +?> +===DONE=== +--EXPECT-- +<?xml version="1.0" encoding="UTF-8" standalone="standalonearg"?> +<tag1/> +===DONE=== diff --git a/ext/xmlwriter/tests/OO_002.phpt b/ext/xmlwriter/tests/OO_002.phpt new file mode 100644 index 0000000000..ec605f50a4 --- /dev/null +++ b/ext/xmlwriter/tests/OO_002.phpt @@ -0,0 +1,22 @@ +--TEST-- +XMLWriter: libxml2 XML Writer, membuffer, flush +--SKIPIF-- +<?php if (!extension_loaded("xmlwriter")) print "skip"; ?> +--FILE-- +<?php +/* $Id$ */ + +$xw = new XMLWriter(); +$xw->openMemory(); +$xw->startDocument('1.0', 'UTF-8', 'standalone'); +$xw->startElement("tag1"); +$xw->endDocument(); + +// Force to write and empty the buffer +echo $xw->flush(true); +?> +===DONE=== +--EXPECT-- +<?xml version="1.0" encoding="UTF-8" standalone="standalone"?> +<tag1/> +===DONE=== diff --git a/ext/xmlwriter/tests/OO_003.phpt b/ext/xmlwriter/tests/OO_003.phpt new file mode 100644 index 0000000000..7fb47910f0 --- /dev/null +++ b/ext/xmlwriter/tests/OO_003.phpt @@ -0,0 +1,37 @@ +--TEST-- +XMLWriter: libxml2 XML Writer, membuffer, flush, text, attribute +--SKIPIF-- +<?php if (!extension_loaded("xmlwriter")) print "skip"; ?> +--FILE-- +<?php +/* $Id$ */ + +$xw = new XMLWriter(); +$xw->openMemory(); +$xw->startDocument('1.0', 'UTF-8'); +$xw->startElement("tag1"); + +$res = $xw->startAttribute('attr1'); +$xw->text("attr1_value"); +$xw->endAttribute(); + +$res = $xw->startAttribute('attr2'); +$xw->text("attr2_value"); +$xw->endAttribute(); + +$xw->text("Test text for tag1"); +$res = $xw->startElement('tag2'); +if ($res < 1) { + echo "StartElement context validation failed\n"; + exit(); +} +$xw->endDocument(); + +// Force to write and empty the buffer +echo $xw->flush(true); +?> +===DONE=== +--EXPECT-- +<?xml version="1.0" encoding="UTF-8"?> +<tag1 attr1="attr1_value" attr2="attr2_value">Test text for tag1<tag2/></tag1> +===DONE=== diff --git a/ext/xmlwriter/tests/OO_004.phpt b/ext/xmlwriter/tests/OO_004.phpt new file mode 100644 index 0000000000..08b423ccef --- /dev/null +++ b/ext/xmlwriter/tests/OO_004.phpt @@ -0,0 +1,37 @@ +--TEST-- +XMLWriter: libxml2 XML Writer, file buffer, flush +--SKIPIF-- +<?php if (!extension_loaded("xmlwriter")) print "skip"; ?> +--FILE-- +<?php +/* $Id$ */ + +$doc_dest = '001.xml'; +$xw = new XMLWriter(); +$xw->openUri($doc_dest); +$xw->startDocument('1.0', 'UTF-8'); +$xw->startElement("tag1"); + +$xw->startPi("PHP"); +$xw->text('echo $a;'); +$xw->endPi(); +$xw->endDocument(); + +// Force to write and empty the buffer +$xw->flush(true); +$md5_out = md5_file($doc_dest); +$md5_res = md5('<?xml version="1.0" encoding="UTF-8"?> +<tag1><?PHP echo $a;?></tag1> +'); +unset($xw); +unlink('001.xml'); +if ($md5_out != $md5_res) { + echo "failed: $md5_res != $md5_out\n"; +} else { + echo "ok.\n"; +} +?> +===DONE=== +--EXPECT-- +ok. +===DONE=== diff --git a/ext/xmlwriter/tests/OO_005.phpt b/ext/xmlwriter/tests/OO_005.phpt new file mode 100644 index 0000000000..2c6d2f4333 --- /dev/null +++ b/ext/xmlwriter/tests/OO_005.phpt @@ -0,0 +1,33 @@ +--TEST-- +XMLWriter: libxml2 XML Writer, comments +--SKIPIF-- +<?php +if (!extension_loaded("xmlwriter")) die("skip"); +if (!function_exists("xmlwriter_start_comment")) die("skip: libxml2 2.6.7+ required"); +?> +--FILE-- +<?php +/* $Id$ */ + +$doc_dest = '001.xml'; +$xw = new XMLWriter(); +$xw->openUri($doc_dest); +$xw->startDocument('1.0', 'UTF-8'); +$xw->startElement("tag1"); +$xw->startComment(); +$xw->text('comment'); +$xw->endComment(); +$xw->writeComment("comment #2"); +$xw->endDocument(); + +// Force to write and empty the buffer +$output_bytes = $xw->flush(true); +echo file_get_contents($doc_dest); +unset($xw); +unlink('001.xml'); +?> +===DONE=== +--EXPECT-- +<?xml version="1.0" encoding="UTF-8"?> +<tag1><!--comment--><!--comment #2--></tag1> +===DONE=== diff --git a/ext/xmlwriter/xmlwriter.dsp b/ext/xmlwriter/xmlwriter.dsp new file mode 100644 index 0000000000..e5eca77be5 --- /dev/null +++ b/ext/xmlwriter/xmlwriter.dsp @@ -0,0 +1,113 @@ +# Microsoft Developer Studio Project File - Name="xmlwriter" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=xmlwriter - Win32 Release_TS
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "xmlwriter.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "xmlwriter.mak" CFG="xmlwriter - Win32 Release_TS"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "xmlwriter - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "xmlwriter - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "xmlwriter - Win32 Release_TS"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release_TS"
+# PROP BASE Intermediate_Dir "Release_TS"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release_TS"
+# PROP Intermediate_Dir "Release_TS"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XMLWRITER_EXPORTS" /D "COMPILE_DL_XMLWRITER" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D "LIBXML_THREAD_ENABLED" /FR /YX /FD /GZ /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XMLWRITER_EXPORTS" /D "COMPILE_DL_XMLWRITER" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_XMLWRITER=1 /D "LIBXML_STATIC" /YX /FD /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"msvcrt" /out:"..\..\Debug_TS/php_xmlwriter.dll" /libpath:"..\..\Debug_TS" /libpath:"..\..\..\bindlib_w32\Release"
+# ADD LINK32 wsock32.lib php4ts.lib libxml2_a.lib iconv.lib resolv.lib kernel32.lib user32.lib gdi32.lib winspool.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_xmlwriter.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\bindlib_w32\Release"
+# SUBTRACT LINK32 /debug
+
+!ELSEIF "$(CFG)" == "xmlwriter - Win32 Debug_TS"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "xmlwriter___Win32_Debug_TS"
+# PROP BASE Intermediate_Dir "xmlwriter___Win32_Debug_TS"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Debug_TS"
+# PROP Intermediate_Dir "Debug_TS"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XMLWRITER_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XMLWRITER_EXPORTS" /D "COMPILE_DL_XMLWRITER" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D "LIBXML_STATIC" /FR /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 wsock32.lib php4ts_debug.lib libxml2_a.lib iconv.lib resolv.lib kernel32.lib user32.lib gdi32.lib winspool.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"msvcrt" /out:"..\..\Debug_TS/php_xmlwriter.dll" /libpath:"..\..\Debug_TS" /libpath:"..\..\..\bindlib_w32\Release"
+
+!ENDIF
+
+# Begin Target
+
+# Name "xmlwriter - Win32 Release_TS"
+# Name "xmlwriter - Win32 Debug_TS"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\php_xmlwriter.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\php_xmlwriter.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
|