12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997 |
- /*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2016 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Rob Richards <rrichards@php.net> |
- | Pierre-A. Joye <pajoye@php.net> |
- +----------------------------------------------------------------------+
- */
- /* $Id$ */
- #ifdef HAVE_CONFIG_H
- #include "config.h"
- #endif
- #include "php.h"
- #include "php_ini.h"
- #include "ext/standard/info.h"
- #include "php_xmlwriter.h"
- #include "ext/standard/php_string.h"
- #if LIBXML_VERSION >= 20605
- static PHP_FUNCTION(xmlwriter_set_indent);
- static PHP_FUNCTION(xmlwriter_set_indent_string);
- #endif
- static PHP_FUNCTION(xmlwriter_start_attribute);
- static PHP_FUNCTION(xmlwriter_end_attribute);
- static PHP_FUNCTION(xmlwriter_write_attribute);
- #if LIBXML_VERSION > 20617
- static PHP_FUNCTION(xmlwriter_start_attribute_ns);
- static PHP_FUNCTION(xmlwriter_write_attribute_ns);
- #endif
- static PHP_FUNCTION(xmlwriter_start_element);
- static PHP_FUNCTION(xmlwriter_end_element);
- static PHP_FUNCTION(xmlwriter_full_end_element);
- static PHP_FUNCTION(xmlwriter_start_element_ns);
- static PHP_FUNCTION(xmlwriter_write_element);
- static PHP_FUNCTION(xmlwriter_write_element_ns);
- static PHP_FUNCTION(xmlwriter_start_pi);
- static PHP_FUNCTION(xmlwriter_end_pi);
- static PHP_FUNCTION(xmlwriter_write_pi);
- static PHP_FUNCTION(xmlwriter_start_cdata);
- static PHP_FUNCTION(xmlwriter_end_cdata);
- static PHP_FUNCTION(xmlwriter_write_cdata);
- static PHP_FUNCTION(xmlwriter_text);
- static PHP_FUNCTION(xmlwriter_write_raw);
- static PHP_FUNCTION(xmlwriter_start_document);
- static PHP_FUNCTION(xmlwriter_end_document);
- #if LIBXML_VERSION >= 20607
- static PHP_FUNCTION(xmlwriter_start_comment);
- static PHP_FUNCTION(xmlwriter_end_comment);
- #endif
- static PHP_FUNCTION(xmlwriter_write_comment);
- static PHP_FUNCTION(xmlwriter_start_dtd);
- static PHP_FUNCTION(xmlwriter_end_dtd);
- static PHP_FUNCTION(xmlwriter_write_dtd);
- static PHP_FUNCTION(xmlwriter_start_dtd_element);
- static PHP_FUNCTION(xmlwriter_end_dtd_element);
- static PHP_FUNCTION(xmlwriter_write_dtd_element);
- #if LIBXML_VERSION > 20608
- static PHP_FUNCTION(xmlwriter_start_dtd_attlist);
- static PHP_FUNCTION(xmlwriter_end_dtd_attlist);
- static PHP_FUNCTION(xmlwriter_write_dtd_attlist);
- static PHP_FUNCTION(xmlwriter_start_dtd_entity);
- static PHP_FUNCTION(xmlwriter_end_dtd_entity);
- static PHP_FUNCTION(xmlwriter_write_dtd_entity);
- #endif
- static PHP_FUNCTION(xmlwriter_open_uri);
- static PHP_FUNCTION(xmlwriter_open_memory);
- static PHP_FUNCTION(xmlwriter_output_memory);
- static PHP_FUNCTION(xmlwriter_flush);
- static zend_class_entry *xmlwriter_class_entry_ce;
- static void xmlwriter_free_resource_ptr(xmlwriter_object *intern TSRMLS_DC);
- static void xmlwriter_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC);
- typedef int (*xmlwriter_read_one_char_t)(xmlTextWriterPtr writer, const xmlChar *content);
- typedef int (*xmlwriter_read_int_t)(xmlTextWriterPtr writer);
- /* {{{ xmlwriter_object_free_storage */
- static void xmlwriter_free_resource_ptr(xmlwriter_object *intern TSRMLS_DC)
- {
- if (intern) {
- if (intern->ptr) {
- xmlFreeTextWriter(intern->ptr);
- intern->ptr = NULL;
- }
- if (intern->output) {
- xmlBufferFree(intern->output);
- intern->output = NULL;
- }
- efree(intern);
- }
- }
- /* }}} */
- #ifdef ZEND_ENGINE_2
- /* {{{ XMLWRITER_FROM_OBJECT */
- #define XMLWRITER_FROM_OBJECT(intern, object) \
- { \
- ze_xmlwriter_object *obj = (ze_xmlwriter_object*) zend_object_store_get_object(object TSRMLS_CC); \
- intern = obj->xmlwriter_ptr; \
- if (!intern) { \
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid or uninitialized XMLWriter object"); \
- RETURN_FALSE; \
- } \
- }
- /* }}} */
- static zend_object_handlers xmlwriter_object_handlers;
- /* {{{ xmlwriter_object_free_storage */
- static void xmlwriter_object_free_storage(void *object TSRMLS_DC)
- {
- ze_xmlwriter_object * intern = (ze_xmlwriter_object *) object;
- if (!intern) {
- return;
- }
- if (intern->xmlwriter_ptr) {
- xmlwriter_free_resource_ptr(intern->xmlwriter_ptr TSRMLS_CC);
- }
- intern->xmlwriter_ptr = NULL;
- zend_object_std_dtor(&intern->zo TSRMLS_CC);
-
- efree(intern);
- }
- /* }}} */
- /* {{{ xmlwriter_object_new */
- static zend_object_value xmlwriter_object_new(zend_class_entry *class_type TSRMLS_DC)
- {
- ze_xmlwriter_object *intern;
- zend_object_value retval;
- intern = emalloc(sizeof(ze_xmlwriter_object));
- memset(&intern->zo, 0, sizeof(zend_object));
- intern->xmlwriter_ptr = NULL;
-
- zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
- object_properties_init(&intern->zo, class_type);
- retval.handle = zend_objects_store_put(intern,
- NULL,
- (zend_objects_free_object_storage_t) xmlwriter_object_free_storage,
- NULL TSRMLS_CC);
-
- retval.handlers = (zend_object_handlers *) & xmlwriter_object_handlers;
-
- return retval;
- }
- /* }}} */
- #endif
- #define XMLW_NAME_CHK(__err) \
- if (xmlValidateName((xmlChar *) name, 0) != 0) { \
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", __err); \
- RETURN_FALSE; \
- } \
-
- /* {{{ arginfo */
- ZEND_BEGIN_ARG_INFO(arginfo_xmlwriter_void, 0)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_resource, 0, 0, 1)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_open_uri, 0, 0, 1)
- ZEND_ARG_INFO(0, uri)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_set_indent, 0, 0, 2)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, indent)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_set_indent, 0, 0, 1)
- ZEND_ARG_INFO(0, indent)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_set_indent_string, 0, 0, 2)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, indentString)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_set_indent_string, 0, 0, 1)
- ZEND_ARG_INFO(0, indentString)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_attribute, 0, 0, 2)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, name)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_attribute, 0, 0, 1)
- ZEND_ARG_INFO(0, name)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_attribute_ns, 0, 0, 4)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, prefix)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, uri)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_attribute_ns, 0, 0, 3)
- ZEND_ARG_INFO(0, prefix)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, uri)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_attribute_ns, 0, 0, 5)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, prefix)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, uri)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_attribute_ns, 0, 0, 4)
- ZEND_ARG_INFO(0, prefix)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, uri)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_attribute, 0, 0, 3)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, value)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_attribute, 0, 0, 2)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, value)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_element, 0, 0, 2)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, name)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_element, 0, 0, 1)
- ZEND_ARG_INFO(0, name)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_element_ns, 0, 0, 4)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, prefix)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, uri)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_element_ns, 0, 0, 3)
- ZEND_ARG_INFO(0, prefix)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, uri)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_element, 0, 0, 2)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_element, 0, 0, 1)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_element_ns, 0, 0, 4)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, prefix)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, uri)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_element_ns, 0, 0, 3)
- ZEND_ARG_INFO(0, prefix)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, uri)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_pi, 0, 0, 2)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, target)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_pi, 0, 0, 1)
- ZEND_ARG_INFO(0, target)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_pi, 0, 0, 3)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, target)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_pi, 0, 0, 2)
- ZEND_ARG_INFO(0, target)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_cdata, 0, 0, 2)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_cdata, 0, 0, 1)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_text, 0, 0, 2)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_text, 0, 0, 1)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_raw, 0, 0, 2)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_raw, 0, 0, 1)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_document, 0, 0, 1)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, version)
- ZEND_ARG_INFO(0, encoding)
- ZEND_ARG_INFO(0, standalone)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_document, 0, 0, 0)
- ZEND_ARG_INFO(0, version)
- ZEND_ARG_INFO(0, encoding)
- ZEND_ARG_INFO(0, standalone)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_comment, 0, 0, 2)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_comment, 0, 0, 1)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_dtd, 0, 0, 2)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, qualifiedName)
- ZEND_ARG_INFO(0, publicId)
- ZEND_ARG_INFO(0, systemId)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_dtd, 0, 0, 1)
- ZEND_ARG_INFO(0, qualifiedName)
- ZEND_ARG_INFO(0, publicId)
- ZEND_ARG_INFO(0, systemId)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_dtd, 0, 0, 2)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, publicId)
- ZEND_ARG_INFO(0, systemId)
- ZEND_ARG_INFO(0, subset)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_dtd, 0, 0, 1)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, publicId)
- ZEND_ARG_INFO(0, systemId)
- ZEND_ARG_INFO(0, subset)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_dtd_element, 0, 0, 2)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, qualifiedName)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_dtd_element, 0, 0, 1)
- ZEND_ARG_INFO(0, qualifiedName)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_dtd_element, 0, 0, 3)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_dtd_element, 0, 0, 2)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_dtd_attlist, 0, 0, 2)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, name)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_dtd_attlist, 0, 0, 1)
- ZEND_ARG_INFO(0, name)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_dtd_attlist, 0, 0, 3)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_dtd_attlist, 0, 0, 2)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_start_dtd_entity, 0, 0, 3)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, isparam)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_start_dtd_entity, 0, 0, 2)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, isparam)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_write_dtd_entity, 0, 0, 3)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_write_dtd_entity, 0, 0, 2)
- ZEND_ARG_INFO(0, name)
- ZEND_ARG_INFO(0, content)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_output_memory, 0, 0, 1)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, flush)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_output_memory, 0, 0, 0)
- ZEND_ARG_INFO(0, flush)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_flush, 0, 0, 1)
- ZEND_ARG_INFO(0, xmlwriter)
- ZEND_ARG_INFO(0, empty)
- ZEND_END_ARG_INFO()
- ZEND_BEGIN_ARG_INFO_EX(arginfo_xmlwriter_method_flush, 0, 0, 0)
- ZEND_ARG_INFO(0, empty)
- ZEND_END_ARG_INFO()
- /* }}} */
- /* {{{ xmlwriter_functions */
- static const zend_function_entry xmlwriter_functions[] = {
- PHP_FE(xmlwriter_open_uri, arginfo_xmlwriter_open_uri)
- PHP_FE(xmlwriter_open_memory, arginfo_xmlwriter_void)
- #if LIBXML_VERSION >= 20605
- PHP_FE(xmlwriter_set_indent, arginfo_xmlwriter_set_indent)
- PHP_FE(xmlwriter_set_indent_string, arginfo_xmlwriter_set_indent_string)
- #endif
- #if LIBXML_VERSION >= 20607
- PHP_FE(xmlwriter_start_comment, arginfo_xmlwriter_resource)
- PHP_FE(xmlwriter_end_comment, arginfo_xmlwriter_resource)
- #endif
- PHP_FE(xmlwriter_start_attribute, arginfo_xmlwriter_start_attribute)
- PHP_FE(xmlwriter_end_attribute, arginfo_xmlwriter_resource)
- PHP_FE(xmlwriter_write_attribute, arginfo_xmlwriter_write_attribute)
- #if LIBXML_VERSION > 20617
- PHP_FE(xmlwriter_start_attribute_ns,arginfo_xmlwriter_start_attribute_ns)
- PHP_FE(xmlwriter_write_attribute_ns,arginfo_xmlwriter_write_attribute_ns)
- #endif
- PHP_FE(xmlwriter_start_element, arginfo_xmlwriter_start_element)
- PHP_FE(xmlwriter_end_element, arginfo_xmlwriter_resource)
- PHP_FE(xmlwriter_full_end_element, arginfo_xmlwriter_resource)
- PHP_FE(xmlwriter_start_element_ns, arginfo_xmlwriter_start_element_ns)
- PHP_FE(xmlwriter_write_element, arginfo_xmlwriter_write_element)
- PHP_FE(xmlwriter_write_element_ns, arginfo_xmlwriter_write_element_ns)
- PHP_FE(xmlwriter_start_pi, arginfo_xmlwriter_start_pi)
- PHP_FE(xmlwriter_end_pi, arginfo_xmlwriter_resource)
- PHP_FE(xmlwriter_write_pi, arginfo_xmlwriter_write_pi)
- PHP_FE(xmlwriter_start_cdata, arginfo_xmlwriter_resource)
- PHP_FE(xmlwriter_end_cdata, arginfo_xmlwriter_resource)
- PHP_FE(xmlwriter_write_cdata, arginfo_xmlwriter_write_cdata)
- PHP_FE(xmlwriter_text, arginfo_xmlwriter_text)
- PHP_FE(xmlwriter_write_raw, arginfo_xmlwriter_write_raw)
- PHP_FE(xmlwriter_start_document, arginfo_xmlwriter_start_document)
- PHP_FE(xmlwriter_end_document, arginfo_xmlwriter_resource)
- PHP_FE(xmlwriter_write_comment, arginfo_xmlwriter_write_comment)
- PHP_FE(xmlwriter_start_dtd, arginfo_xmlwriter_start_dtd)
- PHP_FE(xmlwriter_end_dtd, arginfo_xmlwriter_resource)
- PHP_FE(xmlwriter_write_dtd, arginfo_xmlwriter_write_dtd)
- PHP_FE(xmlwriter_start_dtd_element, arginfo_xmlwriter_start_dtd_element)
- PHP_FE(xmlwriter_end_dtd_element, arginfo_xmlwriter_resource)
- PHP_FE(xmlwriter_write_dtd_element, arginfo_xmlwriter_write_dtd_element)
- #if LIBXML_VERSION > 20608
- PHP_FE(xmlwriter_start_dtd_attlist, arginfo_xmlwriter_start_dtd_attlist)
- PHP_FE(xmlwriter_end_dtd_attlist, arginfo_xmlwriter_resource)
- PHP_FE(xmlwriter_write_dtd_attlist, arginfo_xmlwriter_write_dtd_attlist)
- PHP_FE(xmlwriter_start_dtd_entity, arginfo_xmlwriter_start_dtd_entity)
- PHP_FE(xmlwriter_end_dtd_entity, arginfo_xmlwriter_resource)
- PHP_FE(xmlwriter_write_dtd_entity, arginfo_xmlwriter_write_dtd_entity)
- #endif
- PHP_FE(xmlwriter_output_memory, arginfo_xmlwriter_output_memory)
- PHP_FE(xmlwriter_flush, arginfo_xmlwriter_flush)
- PHP_FE_END
- };
- /* }}} */
- #ifdef ZEND_ENGINE_2
- /* {{{ xmlwriter_class_functions */
- static const zend_function_entry xmlwriter_class_functions[] = {
- PHP_ME_MAPPING(openUri, xmlwriter_open_uri, arginfo_xmlwriter_open_uri, 0)
- PHP_ME_MAPPING(openMemory, xmlwriter_open_memory, arginfo_xmlwriter_void, 0)
- #if LIBXML_VERSION >= 20605
- PHP_ME_MAPPING(setIndent, xmlwriter_set_indent, arginfo_xmlwriter_method_set_indent, 0)
- PHP_ME_MAPPING(setIndentString, xmlwriter_set_indent_string, arginfo_xmlwriter_method_set_indent_string, 0)
- #endif
- #if LIBXML_VERSION >= 20607
- PHP_ME_MAPPING(startComment, xmlwriter_start_comment, arginfo_xmlwriter_void, 0)
- PHP_ME_MAPPING(endComment, xmlwriter_end_comment, arginfo_xmlwriter_void, 0)
- #endif
- PHP_ME_MAPPING(startAttribute, xmlwriter_start_attribute, arginfo_xmlwriter_method_start_attribute, 0)
- PHP_ME_MAPPING(endAttribute, xmlwriter_end_attribute, arginfo_xmlwriter_void, 0)
- PHP_ME_MAPPING(writeAttribute, xmlwriter_write_attribute, arginfo_xmlwriter_method_write_attribute, 0)
- #if LIBXML_VERSION > 20617
- PHP_ME_MAPPING(startAttributeNs, xmlwriter_start_attribute_ns,arginfo_xmlwriter_method_start_attribute_ns, 0)
- PHP_ME_MAPPING(writeAttributeNs, xmlwriter_write_attribute_ns,arginfo_xmlwriter_method_write_attribute_ns, 0)
- #endif
- PHP_ME_MAPPING(startElement, xmlwriter_start_element, arginfo_xmlwriter_method_start_element, 0)
- PHP_ME_MAPPING(endElement, xmlwriter_end_element, arginfo_xmlwriter_void, 0)
- PHP_ME_MAPPING(fullEndElement, xmlwriter_full_end_element, arginfo_xmlwriter_void, 0)
- PHP_ME_MAPPING(startElementNs, xmlwriter_start_element_ns, arginfo_xmlwriter_method_start_element_ns, 0)
- PHP_ME_MAPPING(writeElement, xmlwriter_write_element, arginfo_xmlwriter_method_write_element, 0)
- PHP_ME_MAPPING(writeElementNs, xmlwriter_write_element_ns, arginfo_xmlwriter_method_write_element_ns, 0)
- PHP_ME_MAPPING(startPi, xmlwriter_start_pi, arginfo_xmlwriter_method_start_pi, 0)
- PHP_ME_MAPPING(endPi, xmlwriter_end_pi, arginfo_xmlwriter_void, 0)
- PHP_ME_MAPPING(writePi, xmlwriter_write_pi, arginfo_xmlwriter_method_write_pi, 0)
- PHP_ME_MAPPING(startCdata, xmlwriter_start_cdata, arginfo_xmlwriter_void, 0)
- PHP_ME_MAPPING(endCdata, xmlwriter_end_cdata, arginfo_xmlwriter_void, 0)
- PHP_ME_MAPPING(writeCdata, xmlwriter_write_cdata, arginfo_xmlwriter_method_write_cdata, 0)
- PHP_ME_MAPPING(text, xmlwriter_text, arginfo_xmlwriter_method_text, 0)
- PHP_ME_MAPPING(writeRaw, xmlwriter_write_raw, arginfo_xmlwriter_method_write_raw, 0)
- PHP_ME_MAPPING(startDocument, xmlwriter_start_document, arginfo_xmlwriter_method_start_document, 0)
- PHP_ME_MAPPING(endDocument, xmlwriter_end_document, arginfo_xmlwriter_void, 0)
- PHP_ME_MAPPING(writeComment, xmlwriter_write_comment, arginfo_xmlwriter_method_write_comment, 0)
- PHP_ME_MAPPING(startDtd, xmlwriter_start_dtd, arginfo_xmlwriter_method_start_dtd, 0)
- PHP_ME_MAPPING(endDtd, xmlwriter_end_dtd, arginfo_xmlwriter_void, 0)
- PHP_ME_MAPPING(writeDtd, xmlwriter_write_dtd, arginfo_xmlwriter_method_write_dtd, 0)
- PHP_ME_MAPPING(startDtdElement, xmlwriter_start_dtd_element,arginfo_xmlwriter_method_start_dtd_element, 0)
- PHP_ME_MAPPING(endDtdElement, xmlwriter_end_dtd_element, arginfo_xmlwriter_void, 0)
- PHP_ME_MAPPING(writeDtdElement, xmlwriter_write_dtd_element, arginfo_xmlwriter_method_write_dtd_element, 0)
- #if LIBXML_VERSION > 20608
- PHP_ME_MAPPING(startDtdAttlist, xmlwriter_start_dtd_attlist, arginfo_xmlwriter_method_start_dtd_attlist, 0)
- PHP_ME_MAPPING(endDtdAttlist, xmlwriter_end_dtd_attlist, arginfo_xmlwriter_void, 0)
- PHP_ME_MAPPING(writeDtdAttlist, xmlwriter_write_dtd_attlist, arginfo_xmlwriter_method_write_dtd_attlist, 0)
- PHP_ME_MAPPING(startDtdEntity, xmlwriter_start_dtd_entity, arginfo_xmlwriter_method_start_dtd_entity, 0)
- PHP_ME_MAPPING(endDtdEntity, xmlwriter_end_dtd_entity, arginfo_xmlwriter_void, 0)
- PHP_ME_MAPPING(writeDtdEntity, xmlwriter_write_dtd_entity, arginfo_xmlwriter_method_write_dtd_entity, 0)
- #endif
- PHP_ME_MAPPING(outputMemory, xmlwriter_output_memory, arginfo_xmlwriter_method_output_memory, 0)
- PHP_ME_MAPPING(flush, xmlwriter_flush, arginfo_xmlwriter_method_flush, 0)
- {NULL, NULL, NULL}
- };
- /* }}} */
- #endif
- /* {{{ function prototypes */
- static PHP_MINIT_FUNCTION(xmlwriter);
- static PHP_MSHUTDOWN_FUNCTION(xmlwriter);
- static PHP_MINFO_FUNCTION(xmlwriter);
- static int le_xmlwriter;
- /* }}} */
- /* _xmlwriter_get_valid_file_path should be made a
- common function in libxml extension as code is common to a few xml extensions */
- /* {{{ _xmlwriter_get_valid_file_path */
- static char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, int resolved_path_len TSRMLS_DC) {
- xmlURI *uri;
- xmlChar *escsource;
- char *file_dest;
- int isFileUri = 0;
- uri = xmlCreateURI();
- escsource = xmlURIEscapeStr((xmlChar *)source, (xmlChar *) ":");
- xmlParseURIReference(uri, (char *)escsource);
- xmlFree(escsource);
- if (uri->scheme != NULL) {
- /* absolute file uris - libxml only supports localhost or empty host */
- if (strncasecmp(source, "file:///", 8) == 0) {
- if (source[sizeof("file:///") - 1] == '\0') {
- xmlFreeURI(uri);
- return NULL;
- }
- isFileUri = 1;
- #ifdef PHP_WIN32
- source += 8;
- #else
- source += 7;
- #endif
- } else if (strncasecmp(source, "file://localhost/",17) == 0) {
- if (source[sizeof("file://localhost/") - 1] == '\0') {
- xmlFreeURI(uri);
- return NULL;
- }
- isFileUri = 1;
- #ifdef PHP_WIN32
- source += 17;
- #else
- source += 16;
- #endif
- }
- }
- if ((uri->scheme == NULL || isFileUri)) {
- char file_dirname[MAXPATHLEN];
- size_t dir_len;
- if (!VCWD_REALPATH(source, resolved_path) && !expand_filepath(source, resolved_path TSRMLS_CC)) {
- xmlFreeURI(uri);
- return NULL;
- }
- memcpy(file_dirname, source, strlen(source));
- dir_len = php_dirname(file_dirname, strlen(source));
- if (dir_len > 0) {
- struct stat buf;
- if (php_sys_stat(file_dirname, &buf) != 0) {
- xmlFreeURI(uri);
- return NULL;
- }
- }
- file_dest = resolved_path;
- } else {
- file_dest = source;
- }
- xmlFreeURI(uri);
- return file_dest;
- }
- /* }}} */
- #ifndef ZEND_ENGINE_2
- /* Channel libxml file io layer through the PHP streams subsystem.
- * This allows use of ftps:// and https:// urls */
- /* {{{ php_xmlwriter_streams_IO_open_write_wrapper */
- static void *php_xmlwriter_streams_IO_open_write_wrapper(const char *filename TSRMLS_DC)
- {
- php_stream_wrapper *wrapper = NULL;
- void *ret_val = NULL;
- ret_val = php_stream_open_wrapper_ex((char *)filename, "wb", REPORT_ERRORS, NULL, NULL);
- return ret_val;
- }
- /* }}} */
- /* {{{ php_xmlwriter_streams_IO_write */
- static int php_xmlwriter_streams_IO_write(void *context, const char *buffer, int len)
- {
- TSRMLS_FETCH();
- return php_stream_write((php_stream*)context, buffer, len);
- }
- /* }}} */
- /* {{{ php_xmlwriter_streams_IO_close */
- static int php_xmlwriter_streams_IO_close(void *context)
- {
- TSRMLS_FETCH();
- return php_stream_close((php_stream*)context);
- }
- /* }}} */
- #endif
- /* {{{ xmlwriter_module_entry
- */
- zend_module_entry xmlwriter_module_entry = {
- STANDARD_MODULE_HEADER,
- "xmlwriter",
- xmlwriter_functions,
- PHP_MINIT(xmlwriter),
- PHP_MSHUTDOWN(xmlwriter),
- NULL,
- NULL,
- PHP_MINFO(xmlwriter),
- "0.1",
- STANDARD_MODULE_PROPERTIES
- };
- /* }}} */
- #ifdef COMPILE_DL_XMLWRITER
- ZEND_GET_MODULE(xmlwriter)
- #endif
- /* {{{ xmlwriter_objects_clone
- static void xmlwriter_objects_clone(void *object, void **object_clone TSRMLS_DC)
- {
- TODO
- }
- }}} */
- /* {{{ xmlwriter_dtor */
- static void xmlwriter_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
- xmlwriter_object *intern;
- intern = (xmlwriter_object *) rsrc->ptr;
- xmlwriter_free_resource_ptr(intern TSRMLS_CC);
- }
- /* }}} */
- static void php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAMETERS, xmlwriter_read_one_char_t internal_function, char *err_string)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *name;
- int name_len, retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &name, &name_len) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- if (err_string != NULL) {
- XMLW_NAME_CHK(err_string);
- }
- ptr = intern->ptr;
- if (ptr) {
- retval = internal_function(ptr, (xmlChar *) name);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- static void php_xmlwriter_end(INTERNAL_FUNCTION_PARAMETERS, xmlwriter_read_int_t internal_function)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- int retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- XMLWRITER_FROM_OBJECT(intern, this);
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- ptr = intern->ptr;
- if (ptr) {
- retval = internal_function(ptr);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- #if LIBXML_VERSION >= 20605
- /* {{{ proto bool xmlwriter_set_indent(resource xmlwriter, bool indent)
- Toggle indentation on/off - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_set_indent)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- int retval;
- zend_bool indent;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &indent) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rb", &pind, &indent) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterSetIndent(ptr, indent);
- if (retval == 0) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_set_indent_string(resource xmlwriter, string indentString)
- Set string used for indenting - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_set_indent_string)
- {
- php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterSetIndentString, NULL);
- }
- /* }}} */
- #endif
- /* {{{ proto bool xmlwriter_start_attribute(resource xmlwriter, string name)
- Create start attribute - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_start_attribute)
- {
- php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterStartAttribute, "Invalid Attribute Name");
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_end_attribute(resource xmlwriter)
- End attribute - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_end_attribute)
- {
- php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndAttribute);
- }
- /* }}} */
- #if LIBXML_VERSION > 20617
- /* {{{ proto bool xmlwriter_start_attribute_ns(resource xmlwriter, string prefix, string name, string uri)
- Create start namespaced attribute - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_start_attribute_ns)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *name, *prefix, *uri;
- int name_len, prefix_len, uri_len, retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss!",
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss!", &pind,
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- XMLW_NAME_CHK("Invalid Attribute Name");
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterStartAttributeNS(ptr, (xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- #endif
- /* {{{ proto bool xmlwriter_write_attribute(resource xmlwriter, string name, string content)
- Write full attribute - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_write_attribute)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *name, *content;
- int name_len, content_len, retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- XMLW_NAME_CHK("Invalid Attribute Name");
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterWriteAttribute(ptr, (xmlChar *)name, (xmlChar *)content);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- #if LIBXML_VERSION > 20617
- /* {{{ proto bool xmlwriter_write_attribute_ns(resource xmlwriter, string prefix, string name, string uri, string content)
- Write full namespaced attribute - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_write_attribute_ns)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *name, *prefix, *uri, *content;
- int name_len, prefix_len, uri_len, content_len, retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss!s",
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss!s", &pind,
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- XMLW_NAME_CHK("Invalid Attribute Name");
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterWriteAttributeNS(ptr, (xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri, (xmlChar *)content);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- #endif
- /* {{{ proto bool xmlwriter_start_element(resource xmlwriter, string name)
- Create start element tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_start_element)
- {
- php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterStartElement, "Invalid Element Name");
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_start_element_ns(resource xmlwriter, string prefix, string name, string uri)
- Create start namespaced element tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_start_element_ns)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *name, *prefix, *uri;
- int name_len, prefix_len, uri_len, retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss!",
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss!", &pind,
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- XMLW_NAME_CHK("Invalid Element Name");
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterStartElementNS(ptr, (xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri);
- if (retval != -1) {
- RETURN_TRUE;
- }
-
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_end_element(resource xmlwriter)
- End current element - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_end_element)
- {
- php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndElement);
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_full_end_element(resource xmlwriter)
- End current element - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_full_end_element)
- {
- php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterFullEndElement);
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_write_element(resource xmlwriter, string name[, string content])
- Write full element tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_write_element)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *name, *content = NULL;
- int name_len, content_len, retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!",
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- XMLW_NAME_CHK("Invalid Element Name");
- ptr = intern->ptr;
- if (ptr) {
- if (!content) {
- retval = xmlTextWriterStartElement(ptr, (xmlChar *)name);
- if (retval == -1) {
- RETURN_FALSE;
- }
- xmlTextWriterEndElement(ptr);
- if (retval == -1) {
- RETURN_FALSE;
- }
- } else {
- retval = xmlTextWriterWriteElement(ptr, (xmlChar *)name, (xmlChar *)content);
- }
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_write_element_ns(resource xmlwriter, string prefix, string name, string uri[, string content])
- Write full namesapced element tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_write_element_ns)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *name, *prefix, *uri, *content = NULL;
- int name_len, prefix_len, uri_len, content_len, retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!ss!|s!",
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!ss!|s!", &pind,
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- XMLW_NAME_CHK("Invalid Element Name");
- ptr = intern->ptr;
- if (ptr) {
- if (!content) {
- retval = xmlTextWriterStartElementNS(ptr,(xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri);
- if (retval == -1) {
- RETURN_FALSE;
- }
- retval = xmlTextWriterEndElement(ptr);
- if (retval == -1) {
- RETURN_FALSE;
- }
- } else {
- retval = xmlTextWriterWriteElementNS(ptr, (xmlChar *)prefix, (xmlChar *)name, (xmlChar *)uri, (xmlChar *)content);
- }
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_start_pi(resource xmlwriter, string target)
- Create start PI tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_start_pi)
- {
- php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterStartPI, "Invalid PI Target");
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_end_pi(resource xmlwriter)
- End current PI - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_end_pi)
- {
- php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndPI);
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_write_pi(resource xmlwriter, string target, string content)
- Write full PI tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_write_pi)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *name, *content;
- int name_len, content_len, retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- XMLW_NAME_CHK("Invalid PI Target");
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterWritePI(ptr, (xmlChar *)name, (xmlChar *)content);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_start_cdata(resource xmlwriter)
- Create start CDATA tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_start_cdata)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- int retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterStartCDATA(ptr);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_end_cdata(resource xmlwriter)
- End current CDATA - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_end_cdata)
- {
- php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndCDATA);
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_write_cdata(resource xmlwriter, string content)
- Write full CDATA tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_write_cdata)
- {
- php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterWriteCDATA, NULL);
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_write_raw(resource xmlwriter, string content)
- Write text - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_write_raw)
- {
- php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterWriteRaw, NULL);
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_text(resource xmlwriter, string content)
- Write text - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_text)
- {
- php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterWriteString, NULL);
- }
- /* }}} */
- #if LIBXML_VERSION >= 20607
- /* {{{ proto bool xmlwriter_start_comment(resource xmlwriter)
- Create start comment - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_start_comment)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- int retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
-
- if (this) {
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterStartComment(ptr);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_end_comment(resource xmlwriter)
- Create end comment - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_end_comment)
- {
- php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndComment);
- }
- /* }}} */
- #endif /* LIBXML_VERSION >= 20607 */
- /* {{{ proto bool xmlwriter_write_comment(resource xmlwriter, string content)
- Write full comment tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_write_comment)
- {
- php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterWriteComment, NULL);
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_start_document(resource xmlwriter, string version, string encoding, string standalone)
- Create document tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_start_document)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *version = NULL, *enc = NULL, *alone = NULL;
- int version_len, enc_len, alone_len, retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!", &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|s!s!s!", &pind, &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterStartDocument(ptr, version, enc, alone);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_end_document(resource xmlwriter)
- End current document - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_end_document)
- {
- php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndDocument);
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_start_dtd(resource xmlwriter, string name, string pubid, string sysid)
- Create start DTD tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_start_dtd)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *name, *pubid = NULL, *sysid = NULL;
- int name_len, pubid_len, sysid_len, retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!s!", &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterStartDTD(ptr, (xmlChar *)name, (xmlChar *)pubid, (xmlChar *)sysid);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_end_dtd(resource xmlwriter)
- End current DTD - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_end_dtd)
- {
- php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndDTD);
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_write_dtd(resource xmlwriter, string name, string pubid, string sysid, string subset)
- Write full DTD tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_write_dtd)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *name, *pubid = NULL, *sysid = NULL, *subset = NULL;
- int name_len, pubid_len, sysid_len, subset_len, retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!s!s!", &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len, &subset, &subset_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len, &subset, &subset_len) == FAILURE) {
- return;
- }
-
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterWriteDTD(ptr, (xmlChar *)name, (xmlChar *)pubid, (xmlChar *)sysid, (xmlChar *)subset);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_start_dtd_element(resource xmlwriter, string name)
- Create start DTD element - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_start_dtd_element)
- {
- php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterStartDTDElement, "Invalid Element Name");
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_end_dtd_element(resource xmlwriter)
- End current DTD element - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_end_dtd_element)
- {
- php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndDTDElement);
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_write_dtd_element(resource xmlwriter, string name, string content)
- Write full DTD element tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_write_dtd_element)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *name, *content;
- int name_len, content_len, retval;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- XMLW_NAME_CHK("Invalid Element Name");
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterWriteDTDElement(ptr, (xmlChar *)name, (xmlChar *)content);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- #if LIBXML_VERSION > 20608
- /* {{{ proto bool xmlwriter_start_dtd_attlist(resource xmlwriter, string name)
- Create start DTD AttList - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_start_dtd_attlist)
- {
- php_xmlwriter_string_arg(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterStartDTDAttlist, "Invalid Element Name");
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_end_dtd_attlist(resource xmlwriter)
- End current DTD AttList - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_end_dtd_attlist)
- {
- php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndDTDAttlist);
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_write_dtd_attlist(resource xmlwriter, string name, string content)
- Write full DTD AttList tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_write_dtd_attlist)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *name, *content;
- int name_len, content_len, retval;
-
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- XMLW_NAME_CHK("Invalid Element Name");
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterWriteDTDAttlist(ptr, (xmlChar *)name, (xmlChar *)content);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_start_dtd_entity(resource xmlwriter, string name, bool isparam)
- Create start DTD Entity - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_start_dtd_entity)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *name;
- int name_len, retval;
- zend_bool isparm;
-
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sb", &name, &name_len, &isparm) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsb", &pind, &name, &name_len, &isparm) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- XMLW_NAME_CHK("Invalid Attribute Name");
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterStartDTDEntity(ptr, isparm, (xmlChar *)name);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_end_dtd_entity(resource xmlwriter)
- End current DTD Entity - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_end_dtd_entity)
- {
- php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndDTDEntity);
- }
- /* }}} */
- /* {{{ proto bool xmlwriter_write_dtd_entity(resource xmlwriter, string name, string content [, int pe [, string pubid [, string sysid [, string ndataid]]]])
- Write full DTD Entity tag - returns FALSE on error */
- static PHP_FUNCTION(xmlwriter_write_dtd_entity)
- {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *name, *content;
- int name_len, content_len, retval;
- /* Optional parameters */
- char *pubid = NULL, *sysid = NULL, *ndataid = NULL;
- zend_bool pe = 0;
- int pubid_len, sysid_len, ndataid_len;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|bsss",
- &name, &name_len, &content, &content_len, &pe, &pubid, &pubid_len,
- &sysid, &sysid_len, &ndataid, &ndataid_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss|bsss", &pind,
- &name, &name_len, &content, &content_len, &pe, &pubid, &pubid_len,
- &sysid, &sysid_len, &ndataid, &ndataid_len) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- XMLW_NAME_CHK("Invalid Element Name");
- ptr = intern->ptr;
- if (ptr) {
- retval = xmlTextWriterWriteDTDEntity(ptr, pe, (xmlChar *)name, (xmlChar *)pubid, (xmlChar *)sysid, (xmlChar *)ndataid, (xmlChar *)content);
- if (retval != -1) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
- }
- /* }}} */
- #endif
- /* {{{ proto resource xmlwriter_open_uri(string source)
- Create new xmlwriter using source uri for output */
- static PHP_FUNCTION(xmlwriter_open_uri)
- {
- char *valid_file = NULL;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- char *source;
- char resolved_path[MAXPATHLEN + 1];
- int source_len;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
- ze_xmlwriter_object *ze_obj = NULL;
- #endif
- #ifndef ZEND_ENGINE_2
- xmlOutputBufferPtr out_buffer;
- void *ioctx;
- #endif
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &source, &source_len) == FAILURE) {
- return;
- }
-
- #ifdef ZEND_ENGINE_2
- if (this) {
- /* We do not use XMLWRITER_FROM_OBJECT, xmlwriter init function here */
- ze_obj = (ze_xmlwriter_object*) zend_object_store_get_object(this TSRMLS_CC);
- }
- #endif
- if (source_len == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty string as source");
- RETURN_FALSE;
- }
- valid_file = _xmlwriter_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC);
- if (!valid_file) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to resolve file path");
- RETURN_FALSE;
- }
- /* TODO: Fix either the PHP stream or libxml APIs: it can then detect when a given
- path is valid and not report out of memory error. Once it is done, remove the
- directory check in _xmlwriter_get_valid_file_path */
- #ifndef ZEND_ENGINE_2
- ioctx = php_xmlwriter_streams_IO_open_write_wrapper(valid_file TSRMLS_CC);
- if (ioctx == NULL) {
- RETURN_FALSE;
- }
- out_buffer = xmlOutputBufferCreateIO(php_xmlwriter_streams_IO_write,
- php_xmlwriter_streams_IO_close, ioctx, NULL);
- if (out_buffer == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create output buffer");
- RETURN_FALSE;
- }
- ptr = xmlNewTextWriter(out_buffer);
- #else
- ptr = xmlNewTextWriterFilename(valid_file, 0);
- #endif
- if (!ptr) {
- RETURN_FALSE;
- }
- intern = emalloc(sizeof(xmlwriter_object));
- intern->ptr = ptr;
- intern->output = NULL;
- #ifndef ZEND_ENGINE_2
- intern->uri_output = out_buffer;
- #else
- if (this) {
- if (ze_obj->xmlwriter_ptr) {
- xmlwriter_free_resource_ptr(ze_obj->xmlwriter_ptr TSRMLS_CC);
- }
- ze_obj->xmlwriter_ptr = intern;
- RETURN_TRUE;
- } else
- #endif
- {
- ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter);
- }
- }
- /* }}} */
- /* {{{ proto resource xmlwriter_open_memory()
- Create new xmlwriter using memory for string output */
- static PHP_FUNCTION(xmlwriter_open_memory)
- {
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- xmlBufferPtr buffer;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
- ze_xmlwriter_object *ze_obj = NULL;
- #endif
- #ifdef ZEND_ENGINE_2
- if (this) {
- /* We do not use XMLWRITER_FROM_OBJECT, xmlwriter init function here */
- ze_obj = (ze_xmlwriter_object*) zend_object_store_get_object(this TSRMLS_CC);
- }
- #endif
- buffer = xmlBufferCreate();
- if (buffer == NULL) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create output buffer");
- RETURN_FALSE;
- }
- ptr = xmlNewTextWriterMemory(buffer, 0);
- if (! ptr) {
- xmlBufferFree(buffer);
- RETURN_FALSE;
- }
- intern = emalloc(sizeof(xmlwriter_object));
- intern->ptr = ptr;
- intern->output = buffer;
- #ifndef ZEND_ENGINE_2
- intern->uri_output = NULL;
- #else
- if (this) {
- if (ze_obj->xmlwriter_ptr) {
- xmlwriter_free_resource_ptr(ze_obj->xmlwriter_ptr TSRMLS_CC);
- }
- ze_obj->xmlwriter_ptr = intern;
- RETURN_TRUE;
- } else
- #endif
- {
- ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter);
- }
- }
- /* }}} */
- /* {{{ php_xmlwriter_flush */
- static void php_xmlwriter_flush(INTERNAL_FUNCTION_PARAMETERS, int force_string) {
- zval *pind;
- xmlwriter_object *intern;
- xmlTextWriterPtr ptr;
- xmlBufferPtr buffer;
- zend_bool empty = 1;
- int output_bytes;
- #ifdef ZEND_ENGINE_2
- zval *this = getThis();
- if (this) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &empty) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, this);
- } else
- #endif
- {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|b", &pind, &empty) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
- }
- ptr = intern->ptr;
- if (ptr) {
- buffer = intern->output;
- if (force_string == 1 && buffer == NULL) {
- RETURN_EMPTY_STRING();
- }
- output_bytes = xmlTextWriterFlush(ptr);
- if (buffer) {
- RETVAL_STRING((char *) buffer->content, 1);
- if (empty) {
- xmlBufferEmpty(buffer);
- }
- } else {
- RETVAL_LONG(output_bytes);
- }
- return;
- }
-
- RETURN_EMPTY_STRING();
- }
- /* }}} */
- /* {{{ proto string xmlwriter_output_memory(resource xmlwriter [,bool flush])
- Output current buffer as string */
- static PHP_FUNCTION(xmlwriter_output_memory)
- {
- php_xmlwriter_flush(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
- }
- /* }}} */
- /* {{{ proto mixed xmlwriter_flush(resource xmlwriter [,bool empty])
- Output current buffer */
- static PHP_FUNCTION(xmlwriter_flush)
- {
- php_xmlwriter_flush(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
- }
- /* }}} */
- /* {{{ PHP_MINIT_FUNCTION
- */
- static PHP_MINIT_FUNCTION(xmlwriter)
- {
- #ifdef ZEND_ENGINE_2
- zend_class_entry ce;
- #endif
- le_xmlwriter = zend_register_list_destructors_ex(xmlwriter_dtor, NULL, "xmlwriter", module_number);
- #ifdef ZEND_ENGINE_2
- memcpy(&xmlwriter_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
- xmlwriter_object_handlers.clone_obj = NULL;
- INIT_CLASS_ENTRY(ce, "XMLWriter", xmlwriter_class_functions);
- ce.create_object = xmlwriter_object_new;
- xmlwriter_class_entry_ce = zend_register_internal_class(&ce TSRMLS_CC);
- #endif
- return SUCCESS;
- }
- /* }}} */
- /* {{{ PHP_MSHUTDOWN_FUNCTION
- */
- static PHP_MSHUTDOWN_FUNCTION(xmlwriter)
- {
- return SUCCESS;
- }
- /* }}} */
- /* {{{ PHP_MINFO_FUNCTION
- */
- static PHP_MINFO_FUNCTION(xmlwriter)
- {
- php_info_print_table_start();
- {
- php_info_print_table_row(2, "XMLWriter", "enabled");
- }
- php_info_print_table_end();
- }
- /* }}} */
- /*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
|