PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/xmlwriter - php_xmlwriter.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 457 554 82.5 %
Date: 2018-12-01 Functions: 51 53 96.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   +----------------------------------------------------------------------+
       3             :   | PHP Version 7                                                        |
       4             :   +----------------------------------------------------------------------+
       5             :   | Copyright (c) 1997-2018 The PHP Group                                |
       6             :   +----------------------------------------------------------------------+
       7             :   | This source file is subject to version 3.01 of the PHP license,      |
       8             :   | that is bundled with this package in the file LICENSE, and is        |
       9             :   | available through the world-wide-web at the following url:           |
      10             :   | http://www.php.net/license/3_01.txt.                                 |
      11             :   | If you did not receive a copy of the PHP license and are unable to   |
      12             :   | obtain it through the world-wide-web, please send a note to          |
      13             :   | license@php.net so we can mail you a copy immediately.               |
      14             :   +----------------------------------------------------------------------+
      15             :   | Author: Rob Richards <rrichards@php.net>                             |
      16             :   |         Pierre-A. Joye <pajoye@php.net>                              |
      17             :   +----------------------------------------------------------------------+
      18             : */
      19             : 
      20             : #ifdef HAVE_CONFIG_H
      21             : #include "config.h"
      22             : #endif
      23             : 
      24             : 
      25             : #include "php.h"
      26             : #include "php_ini.h"
      27             : #include "ext/standard/info.h"
      28             : #include "php_xmlwriter.h"
      29             : #include "ext/standard/php_string.h"
      30             : 
      31             : static PHP_FUNCTION(xmlwriter_set_indent);
      32             : static PHP_FUNCTION(xmlwriter_set_indent_string);
      33             : static PHP_FUNCTION(xmlwriter_start_attribute);
      34             : static PHP_FUNCTION(xmlwriter_end_attribute);
      35             : static PHP_FUNCTION(xmlwriter_write_attribute);
      36             : static PHP_FUNCTION(xmlwriter_start_attribute_ns);
      37             : static PHP_FUNCTION(xmlwriter_write_attribute_ns);
      38             : static PHP_FUNCTION(xmlwriter_start_element);
      39             : static PHP_FUNCTION(xmlwriter_end_element);
      40             : static PHP_FUNCTION(xmlwriter_full_end_element);
      41             : static PHP_FUNCTION(xmlwriter_start_element_ns);
      42             : static PHP_FUNCTION(xmlwriter_write_element);
      43             : static PHP_FUNCTION(xmlwriter_write_element_ns);
      44             : static PHP_FUNCTION(xmlwriter_start_pi);
      45             : static PHP_FUNCTION(xmlwriter_end_pi);
      46             : static PHP_FUNCTION(xmlwriter_write_pi);
      47             : static PHP_FUNCTION(xmlwriter_start_cdata);
      48             : static PHP_FUNCTION(xmlwriter_end_cdata);
      49             : static PHP_FUNCTION(xmlwriter_write_cdata);
      50             : static PHP_FUNCTION(xmlwriter_text);
      51             : static PHP_FUNCTION(xmlwriter_write_raw);
      52             : static PHP_FUNCTION(xmlwriter_start_document);
      53             : static PHP_FUNCTION(xmlwriter_end_document);
      54             : static PHP_FUNCTION(xmlwriter_start_comment);
      55             : static PHP_FUNCTION(xmlwriter_end_comment);
      56             : static PHP_FUNCTION(xmlwriter_write_comment);
      57             : static PHP_FUNCTION(xmlwriter_start_dtd);
      58             : static PHP_FUNCTION(xmlwriter_end_dtd);
      59             : static PHP_FUNCTION(xmlwriter_write_dtd);
      60             : static PHP_FUNCTION(xmlwriter_start_dtd_element);
      61             : static PHP_FUNCTION(xmlwriter_end_dtd_element);
      62             : static PHP_FUNCTION(xmlwriter_write_dtd_element);
      63             : static PHP_FUNCTION(xmlwriter_start_dtd_attlist);
      64             : static PHP_FUNCTION(xmlwriter_end_dtd_attlist);
      65             : static PHP_FUNCTION(xmlwriter_write_dtd_attlist);
      66             : static PHP_FUNCTION(xmlwriter_start_dtd_entity);
      67             : static PHP_FUNCTION(xmlwriter_end_dtd_entity);
      68             : static PHP_FUNCTION(xmlwriter_write_dtd_entity);
      69             : static PHP_FUNCTION(xmlwriter_open_uri);
      70             : static PHP_FUNCTION(xmlwriter_open_memory);
      71             : static PHP_FUNCTION(xmlwriter_output_memory);
      72             : static PHP_FUNCTION(xmlwriter_flush);
      73             : 
      74             : static zend_class_entry *xmlwriter_class_entry_ce;
      75             : 
      76             : static void xmlwriter_free_resource_ptr(xmlwriter_object *intern);
      77             : static void xmlwriter_dtor(zend_resource *rsrc);
      78             : 
      79             : typedef int (*xmlwriter_read_one_char_t)(xmlTextWriterPtr writer, const xmlChar *content);
      80             : typedef int (*xmlwriter_read_int_t)(xmlTextWriterPtr writer);
      81             : 
      82             : /* {{{ xmlwriter_object_free_storage */
      83          37 : static void xmlwriter_free_resource_ptr(xmlwriter_object *intern)
      84             : {
      85          37 :         if (intern) {
      86          37 :                 if (intern->ptr) {
      87          37 :                         xmlFreeTextWriter(intern->ptr);
      88          37 :                         intern->ptr = NULL;
      89             :                 }
      90          37 :                 if (intern->output) {
      91          25 :                         xmlBufferFree(intern->output);
      92          25 :                         intern->output = NULL;
      93             :                 }
      94          37 :                 efree(intern);
      95             :         }
      96          37 : }
      97             : /* }}} */
      98             : 
      99             : /* {{{ XMLWRITER_FROM_OBJECT */
     100             : #define XMLWRITER_FROM_OBJECT(intern, object) \
     101             :         { \
     102             :                 ze_xmlwriter_object *obj = Z_XMLWRITER_P(object); \
     103             :                 intern = obj->xmlwriter_ptr; \
     104             :                 if (!intern) { \
     105             :                         php_error_docref(NULL, E_WARNING, "Invalid or uninitialized XMLWriter object"); \
     106             :                         RETURN_FALSE; \
     107             :                 } \
     108             :         }
     109             : /* }}} */
     110             : 
     111             : static zend_object_handlers xmlwriter_object_handlers;
     112             : 
     113             : /* {{{ xmlwriter_object_free_storage */
     114          18 : static void xmlwriter_object_free_storage(zend_object *object)
     115             : {
     116          18 :         ze_xmlwriter_object *intern = php_xmlwriter_fetch_object(object);
     117          18 :         if (!intern) {
     118           0 :                 return;
     119             :         }
     120          18 :         if (intern->xmlwriter_ptr) {
     121          15 :                 xmlwriter_free_resource_ptr(intern->xmlwriter_ptr);
     122             :         }
     123          18 :         intern->xmlwriter_ptr = NULL;
     124          18 :         zend_object_std_dtor(&intern->std);
     125             : }
     126             : /* }}} */
     127             : 
     128             : 
     129             : /* {{{ xmlwriter_object_new */
     130          18 : static zend_object *xmlwriter_object_new(zend_class_entry *class_type)
     131             : {
     132             :         ze_xmlwriter_object *intern;
     133             : 
     134          18 :         intern = zend_object_alloc(sizeof(ze_xmlwriter_object), class_type);
     135          18 :         zend_object_std_init(&intern->std, class_type);
     136          18 :         object_properties_init(&intern->std, class_type);
     137          18 :         intern->std.handlers = &xmlwriter_object_handlers;
     138             : 
     139          18 :         return &intern->std;
     140             : }
     141             : /* }}} */
     142             : 
     143             : #define XMLW_NAME_CHK(__err) \
     144             :         if (xmlValidateName((xmlChar *) name, 0) != 0) {        \
     145             :                 php_error_docref(NULL, E_WARNING, "%s", __err);       \
     146             :                 RETURN_FALSE;   \
     147             :         }       \
     148             : 
     149             : /* {{{ arginfo */
     150             : ZEND_BEGIN_ARG_INFO(arginfo_xmlwriter_void, 0)
     151             : ZEND_END_ARG_INFO()
     152             : 
     153             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_resource, 0, 0, 1)
     154             :         ZEND_ARG_INFO(0, xmlwriter)
     155             : ZEND_END_ARG_INFO()
     156             : 
     157             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_open_uri, 0, 0, 1)
     158             :         ZEND_ARG_INFO(0, uri)
     159             : ZEND_END_ARG_INFO()
     160             : 
     161             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_set_indent, 0, 0, 2)
     162             :         ZEND_ARG_INFO(0, xmlwriter)
     163             :         ZEND_ARG_INFO(0, indent)
     164             : ZEND_END_ARG_INFO()
     165             : 
     166             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_set_indent, 0, 0, 1)
     167             :         ZEND_ARG_INFO(0, indent)
     168             : ZEND_END_ARG_INFO()
     169             : 
     170             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_set_indent_string, 0, 0, 2)
     171             :         ZEND_ARG_INFO(0, xmlwriter)
     172             :         ZEND_ARG_INFO(0, indentString)
     173             : ZEND_END_ARG_INFO()
     174             : 
     175             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_set_indent_string, 0, 0, 1)
     176             :         ZEND_ARG_INFO(0, indentString)
     177             : ZEND_END_ARG_INFO()
     178             : 
     179             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_attribute, 0, 0, 2)
     180             :         ZEND_ARG_INFO(0, xmlwriter)
     181             :         ZEND_ARG_INFO(0, name)
     182             : ZEND_END_ARG_INFO()
     183             : 
     184             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_attribute, 0, 0, 1)
     185             :         ZEND_ARG_INFO(0, name)
     186             : ZEND_END_ARG_INFO()
     187             : 
     188             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_attribute_ns, 0, 0, 4)
     189             :         ZEND_ARG_INFO(0, xmlwriter)
     190             :         ZEND_ARG_INFO(0, prefix)
     191             :         ZEND_ARG_INFO(0, name)
     192             :         ZEND_ARG_INFO(0, uri)
     193             : ZEND_END_ARG_INFO()
     194             : 
     195             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_attribute_ns, 0, 0, 3)
     196             :         ZEND_ARG_INFO(0, prefix)
     197             :         ZEND_ARG_INFO(0, name)
     198             :         ZEND_ARG_INFO(0, uri)
     199             : ZEND_END_ARG_INFO()
     200             : 
     201             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_attribute_ns, 0, 0, 5)
     202             :         ZEND_ARG_INFO(0, xmlwriter)
     203             :         ZEND_ARG_INFO(0, prefix)
     204             :         ZEND_ARG_INFO(0, name)
     205             :         ZEND_ARG_INFO(0, uri)
     206             :         ZEND_ARG_INFO(0, content)
     207             : ZEND_END_ARG_INFO()
     208             : 
     209             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_attribute_ns, 0, 0, 4)
     210             :         ZEND_ARG_INFO(0, prefix)
     211             :         ZEND_ARG_INFO(0, name)
     212             :         ZEND_ARG_INFO(0, uri)
     213             :         ZEND_ARG_INFO(0, content)
     214             : ZEND_END_ARG_INFO()
     215             : 
     216             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_attribute, 0, 0, 3)
     217             :         ZEND_ARG_INFO(0, xmlwriter)
     218             :         ZEND_ARG_INFO(0, name)
     219             :         ZEND_ARG_INFO(0, value)
     220             : ZEND_END_ARG_INFO()
     221             : 
     222             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_attribute, 0, 0, 2)
     223             :         ZEND_ARG_INFO(0, name)
     224             :         ZEND_ARG_INFO(0, value)
     225             : ZEND_END_ARG_INFO()
     226             : 
     227             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_element, 0, 0, 2)
     228             :         ZEND_ARG_INFO(0, xmlwriter)
     229             :         ZEND_ARG_INFO(0, name)
     230             : ZEND_END_ARG_INFO()
     231             : 
     232             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_element, 0, 0, 1)
     233             :         ZEND_ARG_INFO(0, name)
     234             : ZEND_END_ARG_INFO()
     235             : 
     236             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_element_ns, 0, 0, 4)
     237             :         ZEND_ARG_INFO(0, xmlwriter)
     238             :         ZEND_ARG_INFO(0, prefix)
     239             :         ZEND_ARG_INFO(0, name)
     240             :         ZEND_ARG_INFO(0, uri)
     241             : ZEND_END_ARG_INFO()
     242             : 
     243             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_element_ns, 0, 0, 3)
     244             :         ZEND_ARG_INFO(0, prefix)
     245             :         ZEND_ARG_INFO(0, name)
     246             :         ZEND_ARG_INFO(0, uri)
     247             : ZEND_END_ARG_INFO()
     248             : 
     249             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_element, 0, 0, 2)
     250             :         ZEND_ARG_INFO(0, xmlwriter)
     251             :         ZEND_ARG_INFO(0, name)
     252             :         ZEND_ARG_INFO(0, content)
     253             : ZEND_END_ARG_INFO()
     254             : 
     255             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_element, 0, 0, 1)
     256             :         ZEND_ARG_INFO(0, name)
     257             :         ZEND_ARG_INFO(0, content)
     258             : ZEND_END_ARG_INFO()
     259             : 
     260             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_element_ns, 0, 0, 4)
     261             :         ZEND_ARG_INFO(0, xmlwriter)
     262             :         ZEND_ARG_INFO(0, prefix)
     263             :         ZEND_ARG_INFO(0, name)
     264             :         ZEND_ARG_INFO(0, uri)
     265             :         ZEND_ARG_INFO(0, content)
     266             : ZEND_END_ARG_INFO()
     267             : 
     268             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_element_ns, 0, 0, 3)
     269             :         ZEND_ARG_INFO(0, prefix)
     270             :         ZEND_ARG_INFO(0, name)
     271             :         ZEND_ARG_INFO(0, uri)
     272             :         ZEND_ARG_INFO(0, content)
     273             : ZEND_END_ARG_INFO()
     274             : 
     275             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_pi, 0, 0, 2)
     276             :         ZEND_ARG_INFO(0, xmlwriter)
     277             :         ZEND_ARG_INFO(0, target)
     278             : ZEND_END_ARG_INFO()
     279             : 
     280             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_pi, 0, 0, 1)
     281             :         ZEND_ARG_INFO(0, target)
     282             : ZEND_END_ARG_INFO()
     283             : 
     284             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_pi, 0, 0, 3)
     285             :         ZEND_ARG_INFO(0, xmlwriter)
     286             :         ZEND_ARG_INFO(0, target)
     287             :         ZEND_ARG_INFO(0, content)
     288             : ZEND_END_ARG_INFO()
     289             : 
     290             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_pi, 0, 0, 2)
     291             :         ZEND_ARG_INFO(0, target)
     292             :         ZEND_ARG_INFO(0, content)
     293             : ZEND_END_ARG_INFO()
     294             : 
     295             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_cdata, 0, 0, 2)
     296             :         ZEND_ARG_INFO(0, xmlwriter)
     297             :         ZEND_ARG_INFO(0, content)
     298             : ZEND_END_ARG_INFO()
     299             : 
     300             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_cdata, 0, 0, 1)
     301             :         ZEND_ARG_INFO(0, content)
     302             : ZEND_END_ARG_INFO()
     303             : 
     304             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_text, 0, 0, 2)
     305             :         ZEND_ARG_INFO(0, xmlwriter)
     306             :         ZEND_ARG_INFO(0, content)
     307             : ZEND_END_ARG_INFO()
     308             : 
     309             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_text, 0, 0, 1)
     310             :         ZEND_ARG_INFO(0, content)
     311             : ZEND_END_ARG_INFO()
     312             : 
     313             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_raw, 0, 0, 2)
     314             :         ZEND_ARG_INFO(0, xmlwriter)
     315             :         ZEND_ARG_INFO(0, content)
     316             : ZEND_END_ARG_INFO()
     317             : 
     318             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_raw, 0, 0, 1)
     319             :         ZEND_ARG_INFO(0, content)
     320             : ZEND_END_ARG_INFO()
     321             : 
     322             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_document, 0, 0, 1)
     323             :         ZEND_ARG_INFO(0, xmlwriter)
     324             :         ZEND_ARG_INFO(0, version)
     325             :         ZEND_ARG_INFO(0, encoding)
     326             :         ZEND_ARG_INFO(0, standalone)
     327             : ZEND_END_ARG_INFO()
     328             : 
     329             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_document, 0, 0, 0)
     330             :         ZEND_ARG_INFO(0, version)
     331             :         ZEND_ARG_INFO(0, encoding)
     332             :         ZEND_ARG_INFO(0, standalone)
     333             : ZEND_END_ARG_INFO()
     334             : 
     335             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_comment, 0, 0, 2)
     336             :         ZEND_ARG_INFO(0, xmlwriter)
     337             :         ZEND_ARG_INFO(0, content)
     338             : ZEND_END_ARG_INFO()
     339             : 
     340             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_comment, 0, 0, 1)
     341             :         ZEND_ARG_INFO(0, content)
     342             : ZEND_END_ARG_INFO()
     343             : 
     344             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_dtd, 0, 0, 2)
     345             :         ZEND_ARG_INFO(0, xmlwriter)
     346             :         ZEND_ARG_INFO(0, qualifiedName)
     347             :         ZEND_ARG_INFO(0, publicId)
     348             :         ZEND_ARG_INFO(0, systemId)
     349             : ZEND_END_ARG_INFO()
     350             : 
     351             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_dtd, 0, 0, 1)
     352             :         ZEND_ARG_INFO(0, qualifiedName)
     353             :         ZEND_ARG_INFO(0, publicId)
     354             :         ZEND_ARG_INFO(0, systemId)
     355             : ZEND_END_ARG_INFO()
     356             : 
     357             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_dtd, 0, 0, 2)
     358             :         ZEND_ARG_INFO(0, xmlwriter)
     359             :         ZEND_ARG_INFO(0, name)
     360             :         ZEND_ARG_INFO(0, publicId)
     361             :         ZEND_ARG_INFO(0, systemId)
     362             :         ZEND_ARG_INFO(0, subset)
     363             : ZEND_END_ARG_INFO()
     364             : 
     365             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_dtd, 0, 0, 1)
     366             :         ZEND_ARG_INFO(0, name)
     367             :         ZEND_ARG_INFO(0, publicId)
     368             :         ZEND_ARG_INFO(0, systemId)
     369             :         ZEND_ARG_INFO(0, subset)
     370             : ZEND_END_ARG_INFO()
     371             : 
     372             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_dtd_element, 0, 0, 2)
     373             :         ZEND_ARG_INFO(0, xmlwriter)
     374             :         ZEND_ARG_INFO(0, qualifiedName)
     375             : ZEND_END_ARG_INFO()
     376             : 
     377             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_dtd_element, 0, 0, 1)
     378             :         ZEND_ARG_INFO(0, qualifiedName)
     379             : ZEND_END_ARG_INFO()
     380             : 
     381             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_dtd_element, 0, 0, 3)
     382             :         ZEND_ARG_INFO(0, xmlwriter)
     383             :         ZEND_ARG_INFO(0, name)
     384             :         ZEND_ARG_INFO(0, content)
     385             : ZEND_END_ARG_INFO()
     386             : 
     387             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_dtd_element, 0, 0, 2)
     388             :         ZEND_ARG_INFO(0, name)
     389             :         ZEND_ARG_INFO(0, content)
     390             : ZEND_END_ARG_INFO()
     391             : 
     392             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_dtd_attlist, 0, 0, 2)
     393             :         ZEND_ARG_INFO(0, xmlwriter)
     394             :         ZEND_ARG_INFO(0, name)
     395             : ZEND_END_ARG_INFO()
     396             : 
     397             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_dtd_attlist, 0, 0, 1)
     398             :         ZEND_ARG_INFO(0, name)
     399             : ZEND_END_ARG_INFO()
     400             : 
     401             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_dtd_attlist, 0, 0, 3)
     402             :         ZEND_ARG_INFO(0, xmlwriter)
     403             :         ZEND_ARG_INFO(0, name)
     404             :         ZEND_ARG_INFO(0, content)
     405             : ZEND_END_ARG_INFO()
     406             : 
     407             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_dtd_attlist, 0, 0, 2)
     408             :         ZEND_ARG_INFO(0, name)
     409             :         ZEND_ARG_INFO(0, content)
     410             : ZEND_END_ARG_INFO()
     411             : 
     412             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_dtd_entity, 0, 0, 3)
     413             :         ZEND_ARG_INFO(0, xmlwriter)
     414             :         ZEND_ARG_INFO(0, name)
     415             :         ZEND_ARG_INFO(0, isparam)
     416             : ZEND_END_ARG_INFO()
     417             : 
     418             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_dtd_entity, 0, 0, 2)
     419             :         ZEND_ARG_INFO(0, name)
     420             :         ZEND_ARG_INFO(0, isparam)
     421             : ZEND_END_ARG_INFO()
     422             : 
     423             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_dtd_entity, 0, 0, 3)
     424             :         ZEND_ARG_INFO(0, xmlwriter)
     425             :         ZEND_ARG_INFO(0, name)
     426             :         ZEND_ARG_INFO(0, content)
     427             : ZEND_END_ARG_INFO()
     428             : 
     429             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_dtd_entity, 0, 0, 2)
     430             :         ZEND_ARG_INFO(0, name)
     431             :         ZEND_ARG_INFO(0, content)
     432             : ZEND_END_ARG_INFO()
     433             : 
     434             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_output_memory, 0, 0, 1)
     435             :         ZEND_ARG_INFO(0, xmlwriter)
     436             :         ZEND_ARG_INFO(0, flush)
     437             : ZEND_END_ARG_INFO()
     438             : 
     439             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_output_memory, 0, 0, 0)
     440             :         ZEND_ARG_INFO(0, flush)
     441             : ZEND_END_ARG_INFO()
     442             : 
     443             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_flush, 0, 0, 1)
     444             :         ZEND_ARG_INFO(0, xmlwriter)
     445             :         ZEND_ARG_INFO(0, empty)
     446             : ZEND_END_ARG_INFO()
     447             : 
     448             : ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_flush, 0, 0, 0)
     449             :         ZEND_ARG_INFO(0, empty)
     450             : ZEND_END_ARG_INFO()
     451             : /* }}} */
     452             : 
     453             : /* {{{ xmlwriter_functions */
     454             : static const zend_function_entry xmlwriter_functions[] = {
     455             :         PHP_FE(xmlwriter_open_uri,                      arginfo_xmlwriter_open_uri)
     456             :         PHP_FE(xmlwriter_open_memory,           arginfo_xmlwriter_void)
     457             :         PHP_FE(xmlwriter_set_indent,            arginfo_xmlwriter_set_indent)
     458             :         PHP_FE(xmlwriter_set_indent_string, arginfo_xmlwriter_set_indent_string)
     459             :         PHP_FE(xmlwriter_start_comment,         arginfo_xmlwriter_resource)
     460             :         PHP_FE(xmlwriter_end_comment,           arginfo_xmlwriter_resource)
     461             :         PHP_FE(xmlwriter_start_attribute,       arginfo_xmlwriter_start_attribute)
     462             :         PHP_FE(xmlwriter_end_attribute,         arginfo_xmlwriter_resource)
     463             :         PHP_FE(xmlwriter_write_attribute,       arginfo_xmlwriter_write_attribute)
     464             :         PHP_FE(xmlwriter_start_attribute_ns,arginfo_xmlwriter_start_attribute_ns)
     465             :         PHP_FE(xmlwriter_write_attribute_ns,arginfo_xmlwriter_write_attribute_ns)
     466             :         PHP_FE(xmlwriter_start_element,         arginfo_xmlwriter_start_element)
     467             :         PHP_FE(xmlwriter_end_element,           arginfo_xmlwriter_resource)
     468             :         PHP_FE(xmlwriter_full_end_element,      arginfo_xmlwriter_resource)
     469             :         PHP_FE(xmlwriter_start_element_ns,      arginfo_xmlwriter_start_element_ns)
     470             :         PHP_FE(xmlwriter_write_element,         arginfo_xmlwriter_write_element)
     471             :         PHP_FE(xmlwriter_write_element_ns,      arginfo_xmlwriter_write_element_ns)
     472             :         PHP_FE(xmlwriter_start_pi,                      arginfo_xmlwriter_start_pi)
     473             :         PHP_FE(xmlwriter_end_pi,                        arginfo_xmlwriter_resource)
     474             :         PHP_FE(xmlwriter_write_pi,                      arginfo_xmlwriter_write_pi)
     475             :         PHP_FE(xmlwriter_start_cdata,           arginfo_xmlwriter_resource)
     476             :         PHP_FE(xmlwriter_end_cdata,                     arginfo_xmlwriter_resource)
     477             :         PHP_FE(xmlwriter_write_cdata,           arginfo_xmlwriter_write_cdata)
     478             :         PHP_FE(xmlwriter_text,                          arginfo_xmlwriter_text)
     479             :         PHP_FE(xmlwriter_write_raw,                     arginfo_xmlwriter_write_raw)
     480             :         PHP_FE(xmlwriter_start_document,        arginfo_xmlwriter_start_document)
     481             :         PHP_FE(xmlwriter_end_document,          arginfo_xmlwriter_resource)
     482             :         PHP_FE(xmlwriter_write_comment,         arginfo_xmlwriter_write_comment)
     483             :         PHP_FE(xmlwriter_start_dtd,                     arginfo_xmlwriter_start_dtd)
     484             :         PHP_FE(xmlwriter_end_dtd,                       arginfo_xmlwriter_resource)
     485             :         PHP_FE(xmlwriter_write_dtd,                     arginfo_xmlwriter_write_dtd)
     486             :         PHP_FE(xmlwriter_start_dtd_element,     arginfo_xmlwriter_start_dtd_element)
     487             :         PHP_FE(xmlwriter_end_dtd_element,       arginfo_xmlwriter_resource)
     488             :         PHP_FE(xmlwriter_write_dtd_element,     arginfo_xmlwriter_write_dtd_element)
     489             :         PHP_FE(xmlwriter_start_dtd_attlist,     arginfo_xmlwriter_start_dtd_attlist)
     490             :         PHP_FE(xmlwriter_end_dtd_attlist,       arginfo_xmlwriter_resource)
     491             :         PHP_FE(xmlwriter_write_dtd_attlist,     arginfo_xmlwriter_write_dtd_attlist)
     492             :         PHP_FE(xmlwriter_start_dtd_entity,      arginfo_xmlwriter_start_dtd_entity)
     493             :         PHP_FE(xmlwriter_end_dtd_entity,        arginfo_xmlwriter_resource)
     494             :         PHP_FE(xmlwriter_write_dtd_entity,      arginfo_xmlwriter_write_dtd_entity)
     495             :         PHP_FE(xmlwriter_output_memory,         arginfo_xmlwriter_output_memory)
     496             :         PHP_FE(xmlwriter_flush,                         arginfo_xmlwriter_flush)
     497             :         PHP_FE_END
     498             : };
     499             : /* }}} */
     500             : 
     501             : /* {{{ xmlwriter_class_functions */
     502             : static const zend_function_entry xmlwriter_class_functions[] = {
     503             :         PHP_ME_MAPPING(openUri,         xmlwriter_open_uri,             arginfo_xmlwriter_open_uri, 0)
     504             :         PHP_ME_MAPPING(openMemory,      xmlwriter_open_memory,  arginfo_xmlwriter_void, 0)
     505             :         PHP_ME_MAPPING(setIndent,       xmlwriter_set_indent,   arginfo_xmlwriter_method_set_indent, 0)
     506             :         PHP_ME_MAPPING(setIndentString, xmlwriter_set_indent_string, arginfo_xmlwriter_method_set_indent_string, 0)
     507             :         PHP_ME_MAPPING(startComment,    xmlwriter_start_comment,        arginfo_xmlwriter_void, 0)
     508             :         PHP_ME_MAPPING(endComment,              xmlwriter_end_comment,          arginfo_xmlwriter_void, 0)
     509             :         PHP_ME_MAPPING(startAttribute,  xmlwriter_start_attribute,      arginfo_xmlwriter_method_start_attribute, 0)
     510             :         PHP_ME_MAPPING(endAttribute,    xmlwriter_end_attribute,        arginfo_xmlwriter_void, 0)
     511             :         PHP_ME_MAPPING(writeAttribute,  xmlwriter_write_attribute,      arginfo_xmlwriter_method_write_attribute, 0)
     512             :         PHP_ME_MAPPING(startAttributeNs,        xmlwriter_start_attribute_ns,arginfo_xmlwriter_method_start_attribute_ns, 0)
     513             :         PHP_ME_MAPPING(writeAttributeNs,        xmlwriter_write_attribute_ns,arginfo_xmlwriter_method_write_attribute_ns, 0)
     514             :         PHP_ME_MAPPING(startElement,    xmlwriter_start_element,        arginfo_xmlwriter_method_start_element, 0)
     515             :         PHP_ME_MAPPING(endElement,              xmlwriter_end_element,          arginfo_xmlwriter_void, 0)
     516             :         PHP_ME_MAPPING(fullEndElement,  xmlwriter_full_end_element,     arginfo_xmlwriter_void, 0)
     517             :         PHP_ME_MAPPING(startElementNs,  xmlwriter_start_element_ns,     arginfo_xmlwriter_method_start_element_ns, 0)
     518             :         PHP_ME_MAPPING(writeElement,    xmlwriter_write_element,        arginfo_xmlwriter_method_write_element, 0)
     519             :         PHP_ME_MAPPING(writeElementNs,  xmlwriter_write_element_ns,     arginfo_xmlwriter_method_write_element_ns, 0)
     520             :         PHP_ME_MAPPING(startPi,                 xmlwriter_start_pi,                     arginfo_xmlwriter_method_start_pi, 0)
     521             :         PHP_ME_MAPPING(endPi,                   xmlwriter_end_pi,                       arginfo_xmlwriter_void, 0)
     522             :         PHP_ME_MAPPING(writePi,                 xmlwriter_write_pi,                     arginfo_xmlwriter_method_write_pi, 0)
     523             :         PHP_ME_MAPPING(startCdata,              xmlwriter_start_cdata,          arginfo_xmlwriter_void, 0)
     524             :         PHP_ME_MAPPING(endCdata,                xmlwriter_end_cdata,            arginfo_xmlwriter_void, 0)
     525             :         PHP_ME_MAPPING(writeCdata,              xmlwriter_write_cdata,          arginfo_xmlwriter_method_write_cdata, 0)
     526             :         PHP_ME_MAPPING(text,                    xmlwriter_text,                         arginfo_xmlwriter_method_text, 0)
     527             :         PHP_ME_MAPPING(writeRaw,                xmlwriter_write_raw,            arginfo_xmlwriter_method_write_raw, 0)
     528             :         PHP_ME_MAPPING(startDocument,   xmlwriter_start_document,       arginfo_xmlwriter_method_start_document, 0)
     529             :         PHP_ME_MAPPING(endDocument,             xmlwriter_end_document,         arginfo_xmlwriter_void, 0)
     530             :         PHP_ME_MAPPING(writeComment,    xmlwriter_write_comment,        arginfo_xmlwriter_method_write_comment, 0)
     531             :         PHP_ME_MAPPING(startDtd,                xmlwriter_start_dtd,            arginfo_xmlwriter_method_start_dtd, 0)
     532             :         PHP_ME_MAPPING(endDtd,                  xmlwriter_end_dtd,                      arginfo_xmlwriter_void, 0)
     533             :         PHP_ME_MAPPING(writeDtd,                xmlwriter_write_dtd,            arginfo_xmlwriter_method_write_dtd, 0)
     534             :         PHP_ME_MAPPING(startDtdElement, xmlwriter_start_dtd_element,arginfo_xmlwriter_method_start_dtd_element, 0)
     535             :         PHP_ME_MAPPING(endDtdElement,   xmlwriter_end_dtd_element,      arginfo_xmlwriter_void, 0)
     536             :         PHP_ME_MAPPING(writeDtdElement, xmlwriter_write_dtd_element,    arginfo_xmlwriter_method_write_dtd_element, 0)
     537             :         PHP_ME_MAPPING(startDtdAttlist, xmlwriter_start_dtd_attlist,    arginfo_xmlwriter_method_start_dtd_attlist, 0)
     538             :         PHP_ME_MAPPING(endDtdAttlist,   xmlwriter_end_dtd_attlist,      arginfo_xmlwriter_void, 0)
     539             :         PHP_ME_MAPPING(writeDtdAttlist, xmlwriter_write_dtd_attlist,    arginfo_xmlwriter_method_write_dtd_attlist, 0)
     540             :         PHP_ME_MAPPING(startDtdEntity,  xmlwriter_start_dtd_entity,     arginfo_xmlwriter_method_start_dtd_entity, 0)
     541             :         PHP_ME_MAPPING(endDtdEntity,    xmlwriter_end_dtd_entity,       arginfo_xmlwriter_void, 0)
     542             :         PHP_ME_MAPPING(writeDtdEntity,  xmlwriter_write_dtd_entity,     arginfo_xmlwriter_method_write_dtd_entity, 0)
     543             :         PHP_ME_MAPPING(outputMemory,    xmlwriter_output_memory,        arginfo_xmlwriter_method_output_memory, 0)
     544             :         PHP_ME_MAPPING(flush,                   xmlwriter_flush,                        arginfo_xmlwriter_method_flush, 0)
     545             :         PHP_FE_END
     546             : };
     547             : /* }}} */
     548             : 
     549             : /* {{{ function prototypes */
     550             : static PHP_MINIT_FUNCTION(xmlwriter);
     551             : static PHP_MSHUTDOWN_FUNCTION(xmlwriter);
     552             : static PHP_MINFO_FUNCTION(xmlwriter);
     553             : 
     554             : static int le_xmlwriter;
     555             : /* }}} */
     556             : 
     557             : /* _xmlwriter_get_valid_file_path should be made a
     558             :         common function in libxml extension as code is common to a few xml extensions */
     559             : /* {{{ _xmlwriter_get_valid_file_path */
     560          16 : static char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, int resolved_path_len ) {
     561             :         xmlURI *uri;
     562             :         xmlChar *escsource;
     563             :         char *file_dest;
     564          16 :         int isFileUri = 0;
     565             : 
     566          16 :         uri = xmlCreateURI();
     567          16 :         escsource = xmlURIEscapeStr((xmlChar *)source, (xmlChar *) ":");
     568          16 :         xmlParseURIReference(uri, (char *)escsource);
     569          16 :         xmlFree(escsource);
     570             : 
     571          16 :         if (uri->scheme != NULL) {
     572             :                 /* absolute file uris - libxml only supports localhost or empty host */
     573           3 :                 if (strncasecmp(source, "file:///", 8) == 0) {
     574           2 :                         if (source[sizeof("file:///") - 1] == '\0') {
     575           1 :                                 xmlFreeURI(uri);
     576           1 :                                 return NULL;
     577             :                         }
     578           1 :                         isFileUri = 1;
     579             : #ifdef PHP_WIN32
     580             :                         source += 8;
     581             : #else
     582           1 :                         source += 7;
     583             : #endif
     584           1 :                 } else if (strncasecmp(source, "file://localhost/",17) == 0) {
     585           1 :                         if (source[sizeof("file://localhost/") - 1] == '\0') {
     586           1 :                                 xmlFreeURI(uri);
     587           1 :                                 return NULL;
     588             :                         }
     589             : 
     590           0 :                         isFileUri = 1;
     591             : #ifdef PHP_WIN32
     592             :                         source += 17;
     593             : #else
     594           0 :                         source += 16;
     595             : #endif
     596             :                 }
     597             :         }
     598             : 
     599          26 :         if ((uri->scheme == NULL || isFileUri)) {
     600             :                 char file_dirname[MAXPATHLEN];
     601             :                 size_t dir_len;
     602             : 
     603          14 :                 if (!VCWD_REALPATH(source, resolved_path) && !expand_filepath(source, resolved_path)) {
     604           1 :                         xmlFreeURI(uri);
     605           3 :                         return NULL;
     606             :                 }
     607             : 
     608          13 :                 memcpy(file_dirname, source, strlen(source));
     609          13 :                 dir_len = php_dirname(file_dirname, strlen(source));
     610             : 
     611          13 :                 if (dir_len > 0) {
     612             :                         zend_stat_t buf;
     613          13 :                         if (php_sys_stat(file_dirname, &buf) != 0) {
     614           1 :                                 xmlFreeURI(uri);
     615           1 :                                 return NULL;
     616             :                         }
     617             :                 }
     618             : 
     619          12 :                 file_dest = resolved_path;
     620             :         } else {
     621           0 :                 file_dest = source;
     622             :         }
     623             : 
     624          12 :         xmlFreeURI(uri);
     625             : 
     626          12 :         return file_dest;
     627             : }
     628             : /* }}} */
     629             : 
     630             : /* {{{ xmlwriter_module_entry
     631             :  */
     632             : zend_module_entry xmlwriter_module_entry = {
     633             :         STANDARD_MODULE_HEADER,
     634             :         "xmlwriter",
     635             :         xmlwriter_functions,
     636             :         PHP_MINIT(xmlwriter),
     637             :         PHP_MSHUTDOWN(xmlwriter),
     638             :         NULL,
     639             :         NULL,
     640             :         PHP_MINFO(xmlwriter),
     641             :         PHP_XMLWRITER_VERSION,
     642             :         STANDARD_MODULE_PROPERTIES
     643             : };
     644             : /* }}} */
     645             : 
     646             : #ifdef COMPILE_DL_XMLWRITER
     647             : ZEND_GET_MODULE(xmlwriter)
     648             : #endif
     649             : 
     650             : /* {{{ xmlwriter_objects_clone
     651             : static void xmlwriter_objects_clone(void *object, void **object_clone)
     652             : {
     653             :         TODO
     654             : }
     655             : }}} */
     656             : 
     657             : /* {{{ xmlwriter_dtor */
     658          22 : static void xmlwriter_dtor(zend_resource *rsrc) {
     659             :         xmlwriter_object *intern;
     660             : 
     661          22 :         intern = (xmlwriter_object *) rsrc->ptr;
     662          22 :         xmlwriter_free_resource_ptr(intern);
     663          22 : }
     664             : /* }}} */
     665             : 
     666          88 : static void php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAMETERS, xmlwriter_read_one_char_t internal_function, char *err_string)
     667             : {
     668             :         zval *pind;
     669             :         xmlwriter_object *intern;
     670             :         xmlTextWriterPtr ptr;
     671             :         char *name;
     672             :         size_t name_len;
     673             :         int retval;
     674             : 
     675         176 :         zval *self = getThis();
     676             : 
     677          88 :         if (self) {
     678          39 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) {
     679           0 :                         return;
     680             :                 }
     681          39 :                 XMLWRITER_FROM_OBJECT(intern, self);
     682             :         } else {
     683          49 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &pind, &name, &name_len) == FAILURE) {
     684           1 :                         return;
     685             :                 }
     686             : 
     687          48 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
     688           0 :                         RETURN_FALSE;
     689             :                 }
     690             :         }
     691             : 
     692          87 :         if (err_string != NULL) {
     693          52 :                 XMLW_NAME_CHK(err_string);
     694             :         }
     695             : 
     696          85 :         ptr = intern->ptr;
     697             : 
     698          85 :         if (ptr) {
     699          85 :                 retval = internal_function(ptr, (xmlChar *) name);
     700          85 :                 if (retval != -1) {
     701          85 :                         RETURN_TRUE;
     702             :                 }
     703             :         }
     704             : 
     705           0 :         RETURN_FALSE;
     706             : }
     707             : 
     708          83 : static void php_xmlwriter_end(INTERNAL_FUNCTION_PARAMETERS, xmlwriter_read_int_t internal_function)
     709             : {
     710             :         zval *pind;
     711             :         xmlwriter_object *intern;
     712             :         xmlTextWriterPtr ptr;
     713             :         int retval;
     714         166 :         zval *self = getThis();
     715             : 
     716          83 :         if (self) {
     717          38 :                 XMLWRITER_FROM_OBJECT(intern, self);
     718          38 :                 if (zend_parse_parameters_none() == FAILURE) {
     719           1 :                         return;
     720             :                 }
     721             :         } else {
     722          45 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
     723           0 :                         return;
     724             :                 }
     725          45 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
     726           0 :                         RETURN_FALSE;
     727             :                 }
     728             :         }
     729             : 
     730          82 :         ptr = intern->ptr;
     731             : 
     732          82 :         if (ptr) {
     733          82 :                 retval = internal_function(ptr);
     734          82 :                 if (retval != -1) {
     735          80 :                         RETURN_TRUE;
     736             :                 }
     737             :         }
     738             : 
     739           2 :         RETURN_FALSE;
     740             : }
     741             : 
     742             : /* {{{ proto bool xmlwriter_set_indent(resource xmlwriter, bool indent)
     743             : Toggle indentation on/off - returns FALSE on error */
     744          16 : static PHP_FUNCTION(xmlwriter_set_indent)
     745             : {
     746             :         zval *pind;
     747             :         xmlwriter_object *intern;
     748             :         xmlTextWriterPtr ptr;
     749             :         int retval;
     750             :         zend_bool indent;
     751             : 
     752          32 :         zval *self = getThis();
     753             : 
     754          16 :         if (self) {
     755           8 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &indent) == FAILURE) {
     756           0 :                         return;
     757             :                 }
     758           8 :                 XMLWRITER_FROM_OBJECT(intern, self);
     759             :         } else {
     760           8 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "rb", &pind, &indent) == FAILURE) {
     761           0 :                         return;
     762             :                 }
     763           8 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
     764           0 :                         RETURN_FALSE;
     765             :                 }
     766             :         }
     767             : 
     768             : 
     769          16 :         ptr = intern->ptr;
     770          16 :         if (ptr) {
     771          16 :                 retval = xmlTextWriterSetIndent(ptr, indent);
     772          16 :                 if (retval == 0) {
     773          16 :                         RETURN_TRUE;
     774             :                 }
     775             :         }
     776             : 
     777           0 :         RETURN_FALSE;
     778             : }
     779             : /* }}} */
     780             : 
     781             : /* {{{ proto bool xmlwriter_set_indent_string(resource xmlwriter, string indentString)
     782             : Set string used for indenting - returns FALSE on error */
     783           8 : static PHP_FUNCTION(xmlwriter_set_indent_string)
     784             : {
     785           8 :         php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterSetIndentString, NULL);
     786           8 : }
     787             : /* }}} */
     788             : 
     789             : /* {{{ proto bool xmlwriter_start_attribute(resource xmlwriter, string name)
     790             : Create start attribute - returns FALSE on error */
     791           6 : static PHP_FUNCTION(xmlwriter_start_attribute)
     792             : {
     793           6 :         php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterStartAttribute, "Invalid Attribute Name");
     794           6 : }
     795             : /* }}} */
     796             : 
     797             : /* {{{ proto bool xmlwriter_end_attribute(resource xmlwriter)
     798             : End attribute - returns FALSE on error */
     799          10 : static PHP_FUNCTION(xmlwriter_end_attribute)
     800             : {
     801          10 :         php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndAttribute);
     802          10 : }
     803             : /* }}} */
     804             : 
     805             : /* {{{ proto bool xmlwriter_start_attribute_ns(resource xmlwriter, string prefix, string name, string uri)
     806             : Create start namespaced attribute - returns FALSE on error */
     807           4 : static PHP_FUNCTION(xmlwriter_start_attribute_ns)
     808             : {
     809             :         zval *pind;
     810             :         xmlwriter_object *intern;
     811             :         xmlTextWriterPtr ptr;
     812             :         char *name, *prefix, *uri;
     813             :         size_t name_len, prefix_len, uri_len;
     814             :         int retval;
     815           8 :         zval *self = getThis();
     816             : 
     817           4 :         if (self) {
     818           2 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss!",
     819             :                         &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
     820           0 :                         return;
     821             :                 }
     822           2 :                 XMLWRITER_FROM_OBJECT(intern, self);
     823             :         } else {
     824           2 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsss!", &pind,
     825             :                         &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
     826           0 :                         return;
     827             :                 }
     828           2 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
     829           0 :                         RETURN_FALSE;
     830             :                 }
     831             :         }
     832             : 
     833           4 :         XMLW_NAME_CHK("Invalid Attribute Name");
     834             : 
     835           4 :         ptr = intern->ptr;
     836             : 
     837           4 :         if (ptr) {
     838           4 :                 retval = xmlTextWriterStartAttributeNS(ptr, (xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri);
     839           4 :                 if (retval != -1) {
     840           4 :                         RETURN_TRUE;
     841             :                 }
     842             :         }
     843             : 
     844           0 :         RETURN_FALSE;
     845             : }
     846             : /* }}} */
     847             : 
     848             : /* {{{ proto bool xmlwriter_write_attribute(resource xmlwriter, string name, string content)
     849             : Write full attribute - returns FALSE on error */
     850           9 : static PHP_FUNCTION(xmlwriter_write_attribute)
     851             : {
     852             :         zval *pind;
     853             :         xmlwriter_object *intern;
     854             :         xmlTextWriterPtr ptr;
     855             :         char *name, *content;
     856             :         size_t name_len, content_len;
     857             :         int retval;
     858          18 :         zval *self = getThis();
     859             : 
     860           9 :         if (self) {
     861           3 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss",
     862             :                         &name, &name_len, &content, &content_len) == FAILURE) {
     863           0 :                         return;
     864             :                 }
     865           3 :                 XMLWRITER_FROM_OBJECT(intern, self);
     866             :         } else {
     867           6 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss", &pind,
     868             :                         &name, &name_len, &content, &content_len) == FAILURE) {
     869           0 :                         return;
     870             :                 }
     871           6 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
     872           0 :                         RETURN_FALSE;
     873             :                 }
     874             :         }
     875             : 
     876           9 :         XMLW_NAME_CHK("Invalid Attribute Name");
     877             : 
     878           9 :         ptr = intern->ptr;
     879             : 
     880           9 :         if (ptr) {
     881           9 :                 retval = xmlTextWriterWriteAttribute(ptr, (xmlChar *)name, (xmlChar *)content);
     882           9 :                 if (retval != -1) {
     883           9 :                         RETURN_TRUE;
     884             :                 }
     885             :         }
     886             : 
     887           0 :         RETURN_FALSE;
     888             : }
     889             : /* }}} */
     890             : 
     891             : /* {{{ proto bool xmlwriter_write_attribute_ns(resource xmlwriter, string prefix, string name, string uri, string content)
     892             : Write full namespaced attribute - returns FALSE on error */
     893           7 : static PHP_FUNCTION(xmlwriter_write_attribute_ns)
     894             : {
     895             :         zval *pind;
     896             :         xmlwriter_object *intern;
     897             :         xmlTextWriterPtr ptr;
     898             :         char *name, *prefix, *uri, *content;
     899             :         size_t name_len, prefix_len, uri_len, content_len;
     900             :         int retval;
     901             : 
     902          14 :         zval *self = getThis();
     903             : 
     904           7 :         if (self) {
     905           2 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss!s",
     906             :                         &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
     907           0 :                         return;
     908             :                 }
     909           2 :                 XMLWRITER_FROM_OBJECT(intern, self);
     910             :         } else {
     911           5 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsss!s", &pind,
     912             :                         &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
     913           1 :                         return;
     914             :                 }
     915           4 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
     916           0 :                         RETURN_FALSE;
     917             :                 }
     918             :         }
     919             : 
     920           6 :         XMLW_NAME_CHK("Invalid Attribute Name");
     921             : 
     922           6 :         ptr = intern->ptr;
     923             : 
     924           6 :         if (ptr) {
     925           6 :                 retval = xmlTextWriterWriteAttributeNS(ptr, (xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri, (xmlChar *)content);
     926           6 :                 if (retval != -1) {
     927           5 :                         RETURN_TRUE;
     928             :                 }
     929             :         }
     930             : 
     931           1 :         RETURN_FALSE;
     932             : }
     933             : /* }}} */
     934             : 
     935             : /* {{{ proto bool xmlwriter_start_element(resource xmlwriter, string name)
     936             : Create start element tag - returns FALSE on error */
     937          40 : static PHP_FUNCTION(xmlwriter_start_element)
     938             : {
     939          40 :         php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterStartElement, "Invalid Element Name");
     940          40 : }
     941             : /* }}} */
     942             : 
     943             : /* {{{ proto bool xmlwriter_start_element_ns(resource xmlwriter, string prefix, string name, string uri)
     944             : Create start namespaced element tag - returns FALSE on error */
     945           9 : static PHP_FUNCTION(xmlwriter_start_element_ns)
     946             : {
     947             :         zval *pind;
     948             :         xmlwriter_object *intern;
     949             :         xmlTextWriterPtr ptr;
     950             :         char *name, *prefix, *uri;
     951             :         size_t name_len, prefix_len, uri_len;
     952             :         int retval;
     953          18 :         zval *self = getThis();
     954             : 
     955           9 :         if (self) {
     956           5 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!ss!",
     957             :                         &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
     958           0 :                         return;
     959             :                 }
     960           5 :                 XMLWRITER_FROM_OBJECT(intern, self);
     961             :         } else {
     962           4 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!ss!", &pind,
     963             :                         &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
     964           0 :                         return;
     965             :                 }
     966           4 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
     967           0 :                         RETURN_FALSE;
     968             :                 }
     969             :         }
     970             : 
     971           9 :         XMLW_NAME_CHK("Invalid Element Name");
     972             : 
     973           9 :         ptr = intern->ptr;
     974             : 
     975           9 :         if (ptr) {
     976           9 :                 retval = xmlTextWriterStartElementNS(ptr, (xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri);
     977           9 :                 if (retval != -1) {
     978           9 :                         RETURN_TRUE;
     979             :                 }
     980             : 
     981             :         }
     982             : 
     983           0 :         RETURN_FALSE;
     984             : }
     985             : /* }}} */
     986             : 
     987             : /* {{{ proto bool xmlwriter_end_element(resource xmlwriter)
     988             : End current element - returns FALSE on error */
     989          25 : static PHP_FUNCTION(xmlwriter_end_element)
     990             : {
     991          25 :         php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndElement);
     992          25 : }
     993             : /* }}} */
     994             : 
     995             : /* {{{ proto bool xmlwriter_full_end_element(resource xmlwriter)
     996             : End current element - returns FALSE on error */
     997           6 : static PHP_FUNCTION(xmlwriter_full_end_element)
     998             : {
     999           6 :         php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterFullEndElement);
    1000           6 : }
    1001             : /* }}} */
    1002             : 
    1003             : /* {{{ proto bool xmlwriter_write_element(resource xmlwriter, string name[, string content])
    1004             : Write full element tag - returns FALSE on error */
    1005           9 : static PHP_FUNCTION(xmlwriter_write_element)
    1006             : {
    1007             :         zval *pind;
    1008             :         xmlwriter_object *intern;
    1009             :         xmlTextWriterPtr ptr;
    1010           9 :         char *name, *content = NULL;
    1011             :         size_t name_len, content_len;
    1012             :         int retval;
    1013          18 :         zval *self = getThis();
    1014             : 
    1015           9 :         if (self) {
    1016           6 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!",
    1017             :                         &name, &name_len, &content, &content_len) == FAILURE) {
    1018           0 :                         return;
    1019             :                 }
    1020           6 :                 XMLWRITER_FROM_OBJECT(intern, self);
    1021             :         } else {
    1022           3 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|s!", &pind,
    1023             :                         &name, &name_len, &content, &content_len) == FAILURE) {
    1024           0 :                         return;
    1025             :                 }
    1026           3 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
    1027           0 :                         RETURN_FALSE;
    1028             :                 }
    1029             :         }
    1030             : 
    1031           9 :         XMLW_NAME_CHK("Invalid Element Name");
    1032             : 
    1033           9 :         ptr = intern->ptr;
    1034             : 
    1035           9 :         if (ptr) {
    1036           9 :                 if (!content) {
    1037           2 :                         retval = xmlTextWriterStartElement(ptr, (xmlChar *)name);
    1038           2 :             if (retval == -1) {
    1039           0 :                 RETURN_FALSE;
    1040             :             }
    1041           2 :                         xmlTextWriterEndElement(ptr);
    1042           2 :             if (retval == -1) {
    1043           0 :                 RETURN_FALSE;
    1044             :             }
    1045             :                 } else {
    1046           7 :                         retval = xmlTextWriterWriteElement(ptr, (xmlChar *)name, (xmlChar *)content);
    1047             :                 }
    1048           9 :                 if (retval != -1) {
    1049           9 :                         RETURN_TRUE;
    1050             :                 }
    1051             :         }
    1052             : 
    1053           0 :         RETURN_FALSE;
    1054             : }
    1055             : /* }}} */
    1056             : 
    1057             : /* {{{ proto bool xmlwriter_write_element_ns(resource xmlwriter, string prefix, string name, string uri[, string content])
    1058             : Write full namesapced element tag - returns FALSE on error */
    1059          13 : static PHP_FUNCTION(xmlwriter_write_element_ns)
    1060             : {
    1061             :         zval *pind;
    1062             :         xmlwriter_object *intern;
    1063             :         xmlTextWriterPtr ptr;
    1064          13 :         char *name, *prefix, *uri, *content = NULL;
    1065             :         size_t name_len, prefix_len, uri_len, content_len;
    1066             :         int retval;
    1067          26 :         zval *self = getThis();
    1068             : 
    1069          13 :         if (self) {
    1070           9 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!ss!|s!",
    1071             :                         &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
    1072           0 :                         return;
    1073             :                 }
    1074           9 :                 XMLWRITER_FROM_OBJECT(intern, self);
    1075             :         } else {
    1076           4 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!ss!|s!", &pind,
    1077             :                         &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
    1078           0 :                         return;
    1079             :                 }
    1080           4 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
    1081           0 :                         RETURN_FALSE;
    1082             :                 }
    1083             :         }
    1084             : 
    1085          13 :         XMLW_NAME_CHK("Invalid Element Name");
    1086             : 
    1087          13 :         ptr = intern->ptr;
    1088             : 
    1089          13 :         if (ptr) {
    1090          13 :                 if (!content) {
    1091           2 :                         retval = xmlTextWriterStartElementNS(ptr,(xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri);
    1092           2 :             if (retval == -1) {
    1093           0 :                 RETURN_FALSE;
    1094             :             }
    1095           2 :                         retval = xmlTextWriterEndElement(ptr);
    1096           2 :             if (retval == -1) {
    1097           0 :                 RETURN_FALSE;
    1098             :             }
    1099             :                 } else {
    1100          11 :                         retval = xmlTextWriterWriteElementNS(ptr, (xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri, (xmlChar *)content);
    1101             :                 }
    1102          13 :                 if (retval != -1) {
    1103          13 :                         RETURN_TRUE;
    1104             :                 }
    1105             :         }
    1106             : 
    1107           0 :         RETURN_FALSE;
    1108             : }
    1109             : /* }}} */
    1110             : 
    1111             : /* {{{ proto bool xmlwriter_start_pi(resource xmlwriter, string target)
    1112             : Create start PI tag - returns FALSE on error */
    1113           2 : static PHP_FUNCTION(xmlwriter_start_pi)
    1114             : {
    1115           2 :         php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterStartPI, "Invalid PI Target");
    1116           2 : }
    1117             : /* }}} */
    1118             : 
    1119             : /* {{{ proto bool xmlwriter_end_pi(resource xmlwriter)
    1120             : End current PI - returns FALSE on error */
    1121           2 : static PHP_FUNCTION(xmlwriter_end_pi)
    1122             : {
    1123           2 :         php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndPI);
    1124           2 : }
    1125             : /* }}} */
    1126             : 
    1127             : /* {{{ proto bool xmlwriter_write_pi(resource xmlwriter, string target, string content)
    1128             : Write full PI tag - returns FALSE on error */
    1129           2 : static PHP_FUNCTION(xmlwriter_write_pi)
    1130             : {
    1131             :         zval *pind;
    1132             :         xmlwriter_object *intern;
    1133             :         xmlTextWriterPtr ptr;
    1134             :         char *name, *content;
    1135             :         size_t name_len, content_len;
    1136             :         int retval;
    1137             : 
    1138           4 :         zval *self = getThis();
    1139             : 
    1140           2 :         if (self) {
    1141           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss",
    1142             :                         &name, &name_len, &content, &content_len) == FAILURE) {
    1143           0 :                         return;
    1144             :                 }
    1145           1 :                 XMLWRITER_FROM_OBJECT(intern, self);
    1146             :         } else {
    1147           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss", &pind,
    1148             :                         &name, &name_len, &content, &content_len) == FAILURE) {
    1149           0 :                         return;
    1150             :                 }
    1151           1 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
    1152           0 :                         RETURN_FALSE;
    1153             :                 }
    1154             :         }
    1155             : 
    1156           2 :         XMLW_NAME_CHK("Invalid PI Target");
    1157             : 
    1158           2 :         ptr = intern->ptr;
    1159             : 
    1160           2 :         if (ptr) {
    1161           2 :                 retval = xmlTextWriterWritePI(ptr, (xmlChar *)name, (xmlChar *)content);
    1162           2 :                 if (retval != -1) {
    1163           2 :                         RETURN_TRUE;
    1164             :                 }
    1165             :         }
    1166             : 
    1167           0 :         RETURN_FALSE;
    1168             : }
    1169             : /* }}} */
    1170             : 
    1171             : /* {{{ proto bool xmlwriter_start_cdata(resource xmlwriter)
    1172             : Create start CDATA tag - returns FALSE on error */
    1173           2 : static PHP_FUNCTION(xmlwriter_start_cdata)
    1174             : {
    1175             :         zval *pind;
    1176             :         xmlwriter_object *intern;
    1177             :         xmlTextWriterPtr ptr;
    1178             :         int retval;
    1179           4 :         zval *self = getThis();
    1180             : 
    1181           2 :         if (self) {
    1182           1 :                 XMLWRITER_FROM_OBJECT(intern, self);
    1183             :         } else {
    1184           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
    1185           0 :                         return;
    1186             :                 }
    1187           1 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
    1188           0 :                         RETURN_FALSE;
    1189             :                 }
    1190             :         }
    1191             : 
    1192           2 :         ptr = intern->ptr;
    1193             : 
    1194           2 :         if (ptr) {
    1195           2 :                 retval = xmlTextWriterStartCDATA(ptr);
    1196           2 :                 if (retval != -1) {
    1197           2 :                         RETURN_TRUE;
    1198             :                 }
    1199             :         }
    1200             : 
    1201           0 :         RETURN_FALSE;
    1202             : }
    1203             : /* }}} */
    1204             : 
    1205             : /* {{{ proto bool xmlwriter_end_cdata(resource xmlwriter)
    1206             : End current CDATA - returns FALSE on error */
    1207           2 : static PHP_FUNCTION(xmlwriter_end_cdata)
    1208             : {
    1209           2 :         php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndCDATA);
    1210           2 : }
    1211             : /* }}} */
    1212             : 
    1213             : /* {{{ proto bool xmlwriter_write_cdata(resource xmlwriter, string content)
    1214             : Write full CDATA tag - returns FALSE on error */
    1215           0 : static PHP_FUNCTION(xmlwriter_write_cdata)
    1216             : {
    1217           0 :         php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterWriteCDATA, NULL);
    1218           0 : }
    1219             : /* }}} */
    1220             : 
    1221             : /* {{{ proto bool xmlwriter_write_raw(resource xmlwriter, string content)
    1222             : Write text - returns FALSE on error */
    1223           0 : static PHP_FUNCTION(xmlwriter_write_raw)
    1224             : {
    1225           0 :         php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterWriteRaw, NULL);
    1226           0 : }
    1227             : /* }}} */
    1228             : 
    1229             : /* {{{ proto bool xmlwriter_text(resource xmlwriter, string content)
    1230             : Write text - returns FALSE on error */
    1231          23 : static PHP_FUNCTION(xmlwriter_text)
    1232             : {
    1233          23 :         php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterWriteString, NULL);
    1234          23 : }
    1235             : /* }}} */
    1236             : 
    1237             : /* {{{ proto bool xmlwriter_start_comment(resource xmlwriter)
    1238             : Create start comment - returns FALSE on error */
    1239           3 : static PHP_FUNCTION(xmlwriter_start_comment)
    1240             : {
    1241             :         zval *pind;
    1242             :         xmlwriter_object *intern;
    1243             :         xmlTextWriterPtr ptr;
    1244             :         int retval;
    1245           6 :         zval *self = getThis();
    1246             : 
    1247           3 :         if (self) {
    1248           1 :                 XMLWRITER_FROM_OBJECT(intern, self);
    1249             :         } else {
    1250           2 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
    1251           0 :                         return;
    1252             :                 }
    1253           2 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
    1254           0 :                         RETURN_FALSE;
    1255             :                 }
    1256             :         }
    1257             : 
    1258           3 :         ptr = intern->ptr;
    1259             : 
    1260           3 :         if (ptr) {
    1261           3 :                 retval = xmlTextWriterStartComment(ptr);
    1262           3 :                 if (retval != -1) {
    1263           3 :                         RETURN_TRUE;
    1264             :                 }
    1265             :         }
    1266             : 
    1267           0 :         RETURN_FALSE;
    1268             : }
    1269             : /* }}} */
    1270             : 
    1271             : /* {{{ proto bool xmlwriter_end_comment(resource xmlwriter)
    1272             : Create end comment - returns FALSE on error */
    1273           3 : static PHP_FUNCTION(xmlwriter_end_comment)
    1274             : {
    1275           3 :         php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndComment);
    1276           3 : }
    1277             : /* }}} */
    1278             : 
    1279             : /* {{{ proto bool xmlwriter_write_comment(resource xmlwriter, string content)
    1280             : Write full comment tag - returns FALSE on error */
    1281           5 : static PHP_FUNCTION(xmlwriter_write_comment)
    1282             : {
    1283           5 :         php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterWriteComment, NULL);
    1284           5 : }
    1285             : /* }}} */
    1286             : 
    1287             : /* {{{ proto bool xmlwriter_start_document(resource xmlwriter, string version, string encoding, string standalone)
    1288             : Create document tag - returns FALSE on error */
    1289          29 : static PHP_FUNCTION(xmlwriter_start_document)
    1290             : {
    1291             :         zval *pind;
    1292             :         xmlwriter_object *intern;
    1293             :         xmlTextWriterPtr ptr;
    1294          29 :         char *version = NULL, *enc = NULL, *alone = NULL;
    1295             :         size_t version_len, enc_len, alone_len;
    1296             :         int retval;
    1297             : 
    1298          58 :         zval *self = getThis();
    1299             : 
    1300          29 :         if (self) {
    1301          14 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!s!", &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
    1302           0 :                         return;
    1303             :                 }
    1304          14 :                 XMLWRITER_FROM_OBJECT(intern, self);
    1305             :         } else {
    1306          15 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!s!", &pind, &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
    1307           0 :                         return;
    1308             :                 }
    1309          15 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
    1310           0 :                         RETURN_FALSE;
    1311             :                 }
    1312             :         }
    1313             : 
    1314          29 :         ptr = intern->ptr;
    1315             : 
    1316          29 :         if (ptr) {
    1317          29 :                 retval = xmlTextWriterStartDocument(ptr, version, enc, alone);
    1318          29 :                 if (retval != -1) {
    1319          29 :                         RETURN_TRUE;
    1320             :                 }
    1321             :         }
    1322             : 
    1323           0 :         RETURN_FALSE;
    1324             : }
    1325             : /* }}} */
    1326             : 
    1327             : /* {{{ proto bool xmlwriter_end_document(resource xmlwriter)
    1328             : End current document - returns FALSE on error */
    1329          26 : static PHP_FUNCTION(xmlwriter_end_document)
    1330             : {
    1331          26 :         php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndDocument);
    1332          26 : }
    1333             : /* }}} */
    1334             : 
    1335             : /* {{{ proto bool xmlwriter_start_dtd(resource xmlwriter, string name, string pubid, string sysid)
    1336             : Create start DTD tag - returns FALSE on error */
    1337           4 : static PHP_FUNCTION(xmlwriter_start_dtd)
    1338             : {
    1339             :         zval *pind;
    1340             :         xmlwriter_object *intern;
    1341             :         xmlTextWriterPtr ptr;
    1342           4 :         char *name, *pubid = NULL, *sysid = NULL;
    1343             :         size_t name_len, pubid_len, sysid_len;
    1344             :         int retval;
    1345           8 :         zval *self = getThis();
    1346             : 
    1347           4 :         if (self) {
    1348           2 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!s!", &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
    1349           0 :                         return;
    1350             :                 }
    1351             : 
    1352           2 :                 XMLWRITER_FROM_OBJECT(intern, self);
    1353             :         } else {
    1354           2 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
    1355           0 :                         return;
    1356             :                 }
    1357           2 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
    1358           0 :                         RETURN_FALSE;
    1359             :                 }
    1360             :         }
    1361           4 :         ptr = intern->ptr;
    1362             : 
    1363           4 :         if (ptr) {
    1364           4 :                 retval = xmlTextWriterStartDTD(ptr, (xmlChar *)name, (xmlChar *)pubid, (xmlChar *)sysid);
    1365           4 :                 if (retval != -1) {
    1366           4 :                         RETURN_TRUE;
    1367             :                 }
    1368             :         }
    1369             : 
    1370           0 :         RETURN_FALSE;
    1371             : }
    1372             : /* }}} */
    1373             : 
    1374             : /* {{{ proto bool xmlwriter_end_dtd(resource xmlwriter)
    1375             : End current DTD - returns FALSE on error */
    1376           4 : static PHP_FUNCTION(xmlwriter_end_dtd)
    1377             : {
    1378           4 :         php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndDTD);
    1379           4 : }
    1380             : /* }}} */
    1381             : 
    1382             : /* {{{ proto bool xmlwriter_write_dtd(resource xmlwriter, string name, string pubid, string sysid, string subset)
    1383             : Write full DTD tag - returns FALSE on error */
    1384           3 : static PHP_FUNCTION(xmlwriter_write_dtd)
    1385             : {
    1386             :         zval *pind;
    1387             :         xmlwriter_object *intern;
    1388             :         xmlTextWriterPtr ptr;
    1389           3 :         char *name, *pubid = NULL, *sysid = NULL, *subset = NULL;
    1390             :         size_t name_len, pubid_len, sysid_len, subset_len;
    1391             :         int retval;
    1392           6 :         zval *self = getThis();
    1393             : 
    1394           3 :         if (self) {
    1395           0 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!s!s!", &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len, &subset, &subset_len) == FAILURE) {
    1396           0 :                         return;
    1397             :                 }
    1398             : 
    1399           0 :                 XMLWRITER_FROM_OBJECT(intern, self);
    1400             :         } else {
    1401           3 :                 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) {
    1402           1 :                         return;
    1403             :                 }
    1404             : 
    1405           2 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
    1406           0 :                         RETURN_FALSE;
    1407             :                 }
    1408             :         }
    1409             : 
    1410           2 :         ptr = intern->ptr;
    1411             : 
    1412           2 :         if (ptr) {
    1413           2 :                 retval = xmlTextWriterWriteDTD(ptr, (xmlChar *)name, (xmlChar *)pubid, (xmlChar *)sysid, (xmlChar *)subset);
    1414           2 :                 if (retval != -1) {
    1415           1 :                         RETURN_TRUE;
    1416             :                 }
    1417             :         }
    1418             : 
    1419           1 :         RETURN_FALSE;
    1420             : }
    1421             : /* }}} */
    1422             : 
    1423             : /* {{{ proto bool xmlwriter_start_dtd_element(resource xmlwriter, string name)
    1424             : Create start DTD element - returns FALSE on error */
    1425           2 : static PHP_FUNCTION(xmlwriter_start_dtd_element)
    1426             : {
    1427           2 :         php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterStartDTDElement, "Invalid Element Name");
    1428           2 : }
    1429             : /* }}} */
    1430             : 
    1431             : /* {{{ proto bool xmlwriter_end_dtd_element(resource xmlwriter)
    1432             : End current DTD element - returns FALSE on error */
    1433           2 : static PHP_FUNCTION(xmlwriter_end_dtd_element)
    1434             : {
    1435           2 :         php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndDTDElement);
    1436           2 : }
    1437             : /* }}} */
    1438             : 
    1439             : /* {{{ proto bool xmlwriter_write_dtd_element(resource xmlwriter, string name, string content)
    1440             : Write full DTD element tag - returns FALSE on error */
    1441           2 : static PHP_FUNCTION(xmlwriter_write_dtd_element)
    1442             : {
    1443             :         zval *pind;
    1444             :         xmlwriter_object *intern;
    1445             :         xmlTextWriterPtr ptr;
    1446             :         char *name, *content;
    1447             :         size_t name_len, content_len;
    1448             :         int retval;
    1449           4 :         zval *self = getThis();
    1450             : 
    1451           2 :         if (self) {
    1452           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &name, &name_len, &content, &content_len) == FAILURE) {
    1453           0 :                         return;
    1454             :                 }
    1455           1 :                 XMLWRITER_FROM_OBJECT(intern, self);
    1456             :         } else {
    1457           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss", &pind,
    1458             :                         &name, &name_len, &content, &content_len) == FAILURE) {
    1459           0 :                         return;
    1460             :                 }
    1461           1 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
    1462           0 :                         RETURN_FALSE;
    1463             :                 }
    1464             :         }
    1465             : 
    1466           2 :         XMLW_NAME_CHK("Invalid Element Name");
    1467             : 
    1468           2 :         ptr = intern->ptr;
    1469             : 
    1470           2 :         if (ptr) {
    1471           2 :                 retval = xmlTextWriterWriteDTDElement(ptr, (xmlChar *)name, (xmlChar *)content);
    1472           2 :                 if (retval != -1) {
    1473           2 :                         RETURN_TRUE;
    1474             :                 }
    1475             :         }
    1476             : 
    1477           0 :         RETURN_FALSE;
    1478             : }
    1479             : /* }}} */
    1480             : 
    1481             : /* {{{ proto bool xmlwriter_start_dtd_attlist(resource xmlwriter, string name)
    1482             : Create start DTD AttList - returns FALSE on error */
    1483           2 : static PHP_FUNCTION(xmlwriter_start_dtd_attlist)
    1484             : {
    1485           2 :         php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterStartDTDAttlist, "Invalid Element Name");
    1486           2 : }
    1487             : /* }}} */
    1488             : 
    1489             : /* {{{ proto bool xmlwriter_end_dtd_attlist(resource xmlwriter)
    1490             : End current DTD AttList - returns FALSE on error */
    1491           2 : static PHP_FUNCTION(xmlwriter_end_dtd_attlist)
    1492             : {
    1493           2 :         php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndDTDAttlist);
    1494           2 : }
    1495             : /* }}} */
    1496             : 
    1497             : /* {{{ proto bool xmlwriter_write_dtd_attlist(resource xmlwriter, string name, string content)
    1498             : Write full DTD AttList tag - returns FALSE on error */
    1499           2 : static PHP_FUNCTION(xmlwriter_write_dtd_attlist)
    1500             : {
    1501             :         zval *pind;
    1502             :         xmlwriter_object *intern;
    1503             :         xmlTextWriterPtr ptr;
    1504             :         char *name, *content;
    1505             :         size_t name_len, content_len;
    1506             :         int retval;
    1507           4 :         zval *self = getThis();
    1508             : 
    1509           2 :         if (self) {
    1510           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss",
    1511             :                         &name, &name_len, &content, &content_len) == FAILURE) {
    1512           0 :                         return;
    1513             :                 }
    1514           1 :                 XMLWRITER_FROM_OBJECT(intern, self);
    1515             :         } else {
    1516           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss", &pind,
    1517             :                         &name, &name_len, &content, &content_len) == FAILURE) {
    1518           0 :                         return;
    1519             :                 }
    1520           1 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
    1521           0 :                         RETURN_FALSE;
    1522             :                 }
    1523             :         }
    1524             : 
    1525           2 :         XMLW_NAME_CHK("Invalid Element Name");
    1526             : 
    1527           2 :         ptr = intern->ptr;
    1528             : 
    1529           2 :         if (ptr) {
    1530           2 :                 retval = xmlTextWriterWriteDTDAttlist(ptr, (xmlChar *)name, (xmlChar *)content);
    1531           2 :                 if (retval != -1) {
    1532           2 :                         RETURN_TRUE;
    1533             :                 }
    1534             :         }
    1535             : 
    1536           0 :         RETURN_FALSE;
    1537             : }
    1538             : /* }}} */
    1539             : 
    1540             : /* {{{ proto bool xmlwriter_start_dtd_entity(resource xmlwriter, string name, bool isparam)
    1541             : Create start DTD Entity - returns FALSE on error */
    1542           1 : static PHP_FUNCTION(xmlwriter_start_dtd_entity)
    1543             : {
    1544             :         zval *pind;
    1545             :         xmlwriter_object *intern;
    1546             :         xmlTextWriterPtr ptr;
    1547             :         char *name;
    1548             :         size_t name_len;
    1549             :         int retval;
    1550             :         zend_bool isparm;
    1551           2 :         zval *self = getThis();
    1552             : 
    1553           1 :         if (self) {
    1554           0 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "sb", &name, &name_len, &isparm) == FAILURE) {
    1555           0 :                         return;
    1556             :                 }
    1557           0 :                 XMLWRITER_FROM_OBJECT(intern, self);
    1558             :         } else {
    1559           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsb", &pind, &name, &name_len, &isparm) == FAILURE) {
    1560           0 :                         return;
    1561             :                 }
    1562           1 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
    1563           0 :                         RETURN_FALSE;
    1564             :                 }
    1565             :         }
    1566             : 
    1567           1 :         XMLW_NAME_CHK("Invalid Attribute Name");
    1568             : 
    1569           1 :         ptr = intern->ptr;
    1570             : 
    1571           1 :         if (ptr) {
    1572           1 :                 retval = xmlTextWriterStartDTDEntity(ptr, isparm, (xmlChar *)name);
    1573           1 :                 if (retval != -1) {
    1574           1 :                         RETURN_TRUE;
    1575             :                 }
    1576             :         }
    1577             : 
    1578           0 :         RETURN_FALSE;
    1579             : }
    1580             : /* }}} */
    1581             : 
    1582             : /* {{{ proto bool xmlwriter_end_dtd_entity(resource xmlwriter)
    1583             : End current DTD Entity - returns FALSE on error */
    1584           1 : static PHP_FUNCTION(xmlwriter_end_dtd_entity)
    1585             : {
    1586           1 :         php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndDTDEntity);
    1587           1 : }
    1588             : /* }}} */
    1589             : 
    1590             : /* {{{ proto bool xmlwriter_write_dtd_entity(resource xmlwriter, string name, string content [, bool pe [, string pubid [, string sysid [, string ndataid]]]])
    1591             : Write full DTD Entity tag - returns FALSE on error */
    1592           3 : static PHP_FUNCTION(xmlwriter_write_dtd_entity)
    1593             : {
    1594             :         zval *pind;
    1595             :         xmlwriter_object *intern;
    1596             :         xmlTextWriterPtr ptr;
    1597             :         char *name, *content;
    1598             :         size_t name_len, content_len;
    1599             :         int retval;
    1600             :         /* Optional parameters */
    1601           3 :         char *pubid = NULL, *sysid = NULL, *ndataid = NULL;
    1602           3 :         zend_bool pe = 0;
    1603             :         size_t pubid_len, sysid_len, ndataid_len;
    1604           6 :         zval *self = getThis();
    1605             : 
    1606           3 :         if (self) {
    1607           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|bsss",
    1608             :                         &name, &name_len, &content, &content_len, &pe, &pubid, &pubid_len,
    1609             :                         &sysid, &sysid_len, &ndataid, &ndataid_len) == FAILURE) {
    1610           0 :                         return;
    1611             :                 }
    1612           1 :                 XMLWRITER_FROM_OBJECT(intern, self);
    1613             :         } else {
    1614           2 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss|bsss", &pind,
    1615             :                         &name, &name_len, &content, &content_len, &pe, &pubid, &pubid_len,
    1616             :                         &sysid, &sysid_len, &ndataid, &ndataid_len) == FAILURE) {
    1617           0 :                         return;
    1618             :                 }
    1619           2 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
    1620           0 :                         RETURN_FALSE;
    1621             :                 }
    1622             :         }
    1623             : 
    1624           3 :         XMLW_NAME_CHK("Invalid Element Name");
    1625             : 
    1626           3 :         ptr = intern->ptr;
    1627             : 
    1628           3 :         if (ptr) {
    1629           3 :                 retval = xmlTextWriterWriteDTDEntity(ptr, pe, (xmlChar *)name, (xmlChar *)pubid, (xmlChar *)sysid, (xmlChar *)ndataid, (xmlChar *)content);
    1630           3 :                 if (retval != -1) {
    1631           3 :                         RETURN_TRUE;
    1632             :                 }
    1633             :         }
    1634             : 
    1635           0 :         RETURN_FALSE;
    1636             : }
    1637             : /* }}} */
    1638             : 
    1639             : /* {{{ proto resource xmlwriter_open_uri(string source)
    1640             : Create new xmlwriter using source uri for output */
    1641          18 : static PHP_FUNCTION(xmlwriter_open_uri)
    1642             : {
    1643          18 :         char *valid_file = NULL;
    1644             :         xmlwriter_object *intern;
    1645             :         xmlTextWriterPtr ptr;
    1646             :         char *source;
    1647             :         char resolved_path[MAXPATHLEN + 1];
    1648             :         size_t source_len;
    1649          36 :         zval *self = getThis();
    1650          18 :         ze_xmlwriter_object *ze_obj = NULL;
    1651             : 
    1652          18 :         if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &source, &source_len) == FAILURE) {
    1653           1 :                 return;
    1654             :         }
    1655             : 
    1656          17 :         if (self) {
    1657             :                 /* We do not use XMLWRITER_FROM_OBJECT, xmlwriter init function here */
    1658           4 :                 ze_obj = Z_XMLWRITER_P(self);
    1659             :         }
    1660             : 
    1661          17 :         if (source_len == 0) {
    1662           1 :                 php_error_docref(NULL, E_WARNING, "Empty string as source");
    1663           1 :                 RETURN_FALSE;
    1664             :         }
    1665             : 
    1666          16 :         valid_file = _xmlwriter_get_valid_file_path(source, resolved_path, MAXPATHLEN);
    1667          16 :         if (!valid_file) {
    1668           4 :                 php_error_docref(NULL, E_WARNING, "Unable to resolve file path");
    1669           4 :                 RETURN_FALSE;
    1670             :         }
    1671             : 
    1672          12 :         ptr = xmlNewTextWriterFilename(valid_file, 0);
    1673             : 
    1674          12 :         if (!ptr) {
    1675           0 :                 RETURN_FALSE;
    1676             :         }
    1677             : 
    1678          12 :         intern = emalloc(sizeof(xmlwriter_object));
    1679          12 :         intern->ptr = ptr;
    1680          12 :         intern->output = NULL;
    1681          12 :         if (self) {
    1682           4 :                 if (ze_obj->xmlwriter_ptr) {
    1683           0 :                         xmlwriter_free_resource_ptr(ze_obj->xmlwriter_ptr);
    1684             :                 }
    1685           4 :                 ze_obj->xmlwriter_ptr = intern;
    1686           4 :                 RETURN_TRUE;
    1687             :         } else {
    1688           8 :                 RETURN_RES(zend_register_resource(intern, le_xmlwriter));
    1689             :         }
    1690             : }
    1691             : /* }}} */
    1692             : 
    1693             : /* {{{ proto resource xmlwriter_open_memory()
    1694             : Create new xmlwriter using memory for string output */
    1695          25 : static PHP_FUNCTION(xmlwriter_open_memory)
    1696             : {
    1697             :         xmlwriter_object *intern;
    1698             :         xmlTextWriterPtr ptr;
    1699             :         xmlBufferPtr buffer;
    1700          50 :         zval *self = getThis();
    1701          25 :         ze_xmlwriter_object *ze_obj = NULL;
    1702             : 
    1703          25 :         if (self) {
    1704             :                 /* We do not use XMLWRITER_FROM_OBJECT, xmlwriter init function here */
    1705          11 :                 ze_obj = Z_XMLWRITER_P(self);
    1706             :         }
    1707             : 
    1708          25 :         buffer = xmlBufferCreate();
    1709             : 
    1710          25 :         if (buffer == NULL) {
    1711           0 :                 php_error_docref(NULL, E_WARNING, "Unable to create output buffer");
    1712           0 :                 RETURN_FALSE;
    1713             :         }
    1714             : 
    1715          25 :         ptr = xmlNewTextWriterMemory(buffer, 0);
    1716          25 :         if (! ptr) {
    1717           0 :                 xmlBufferFree(buffer);
    1718           0 :                 RETURN_FALSE;
    1719             :         }
    1720             : 
    1721          25 :         intern = emalloc(sizeof(xmlwriter_object));
    1722          25 :         intern->ptr = ptr;
    1723          25 :         intern->output = buffer;
    1724          25 :         if (self) {
    1725          11 :                 if (ze_obj->xmlwriter_ptr) {
    1726           0 :                         xmlwriter_free_resource_ptr(ze_obj->xmlwriter_ptr);
    1727             :                 }
    1728          11 :                 ze_obj->xmlwriter_ptr = intern;
    1729          11 :                 RETURN_TRUE;
    1730             :         } else {
    1731          14 :                 RETURN_RES(zend_register_resource(intern, le_xmlwriter));
    1732             :         }
    1733             : 
    1734             : }
    1735             : /* }}} */
    1736             : 
    1737             : /* {{{ php_xmlwriter_flush */
    1738          34 : static void php_xmlwriter_flush(INTERNAL_FUNCTION_PARAMETERS, int force_string) {
    1739             :         zval *pind;
    1740             :         xmlwriter_object *intern;
    1741             :         xmlTextWriterPtr ptr;
    1742             :         xmlBufferPtr buffer;
    1743          34 :         zend_bool empty = 1;
    1744             :         int output_bytes;
    1745          68 :         zval *self = getThis();
    1746             : 
    1747          34 :         if (self) {
    1748          15 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &empty) == FAILURE) {
    1749           0 :                         return;
    1750             :                 }
    1751          15 :                 XMLWRITER_FROM_OBJECT(intern, self);
    1752             :         } else {
    1753          19 :                 if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|b", &pind, &empty) == FAILURE) {
    1754           0 :                         return;
    1755             :                 }
    1756             : 
    1757          19 :                 if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
    1758           0 :                         RETURN_FALSE;
    1759             :                 }
    1760             :         }
    1761          34 :         ptr = intern->ptr;
    1762             : 
    1763          34 :         if (ptr) {
    1764          34 :                 buffer = intern->output;
    1765          34 :                 if (force_string == 1 && buffer == NULL) {
    1766           0 :                         RETURN_EMPTY_STRING();
    1767             :                 }
    1768          34 :                 output_bytes = xmlTextWriterFlush(ptr);
    1769          34 :                 if (buffer) {
    1770          50 :                         RETVAL_STRING((char *) buffer->content);
    1771          25 :                         if (empty) {
    1772          25 :                                 xmlBufferEmpty(buffer);
    1773             :                         }
    1774             :                 } else {
    1775           9 :                         RETVAL_LONG(output_bytes);
    1776             :                 }
    1777          34 :                 return;
    1778             :         }
    1779             : 
    1780           0 :         RETURN_EMPTY_STRING();
    1781             : }
    1782             : /* }}} */
    1783             : 
    1784             : /* {{{ proto string xmlwriter_output_memory(resource xmlwriter [,bool flush])
    1785             : Output current buffer as string */
    1786           1 : static PHP_FUNCTION(xmlwriter_output_memory)
    1787             : {
    1788           1 :         php_xmlwriter_flush(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
    1789           1 : }
    1790             : /* }}} */
    1791             : 
    1792             : /* {{{ proto mixed xmlwriter_flush(resource xmlwriter [,bool empty])
    1793             : Output current buffer */
    1794          33 : static PHP_FUNCTION(xmlwriter_flush)
    1795             : {
    1796          33 :         php_xmlwriter_flush(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
    1797          33 : }
    1798             : /* }}} */
    1799             : 
    1800             : /* {{{ PHP_MINIT_FUNCTION
    1801             :  */
    1802       24794 : static PHP_MINIT_FUNCTION(xmlwriter)
    1803             : {
    1804             :         zend_class_entry ce;
    1805       24794 :         le_xmlwriter = zend_register_list_destructors_ex(xmlwriter_dtor, NULL, "xmlwriter", module_number);
    1806             : 
    1807       24794 :         memcpy(&xmlwriter_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
    1808       24794 :         xmlwriter_object_handlers.offset = XtOffsetOf(ze_xmlwriter_object, std);
    1809       24794 :         xmlwriter_object_handlers.free_obj = xmlwriter_object_free_storage;
    1810       24794 :         xmlwriter_object_handlers.clone_obj = NULL;
    1811       24794 :         INIT_CLASS_ENTRY(ce, "XMLWriter", xmlwriter_class_functions);
    1812       24794 :         ce.create_object = xmlwriter_object_new;
    1813       24794 :         xmlwriter_class_entry_ce = zend_register_internal_class(&ce);
    1814             : 
    1815       24794 :         return SUCCESS;
    1816             : }
    1817             : /* }}} */
    1818             : 
    1819             : /* {{{ PHP_MSHUTDOWN_FUNCTION
    1820             :  */
    1821       24855 : static PHP_MSHUTDOWN_FUNCTION(xmlwriter)
    1822             : {
    1823       24855 :         return SUCCESS;
    1824             : }
    1825             : /* }}} */
    1826             : 
    1827             : /* {{{ PHP_MINFO_FUNCTION
    1828             :  */
    1829         145 : static PHP_MINFO_FUNCTION(xmlwriter)
    1830             : {
    1831         145 :         php_info_print_table_start();
    1832             :         {
    1833         145 :                 php_info_print_table_row(2, "XMLWriter", "enabled");
    1834             :         }
    1835         145 :         php_info_print_table_end();
    1836         145 : }
    1837             : /* }}} */
    1838             : 
    1839             : /*
    1840             :  * Local variables:
    1841             :  * tab-width: 4
    1842             :  * c-basic-offset: 4
    1843             :  * End:
    1844             :  * vim600: noet sw=4 ts=4 fdm=marker
    1845             :  * vim<600: noet sw=4 ts=4
    1846             :  */

Generated by: LCOV version 1.10

Generated at Sat, 01 Dec 2018 10:41:06 +0000 (13 days ago)

Copyright © 2005-2018 The PHP Group
All rights reserved.