1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891 |
- /*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 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> |
- +----------------------------------------------------------------------+
- */
- #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);
- static void xmlwriter_dtor(zend_resource *rsrc);
- typedef int (*xmlwriter_read_one_char_t)(xmlTextWriterPtr writer, const xmlChar *content);
- typedef int (*xmlwriter_read_int_t)(xmlTextWriterPtr writer);
- /* {{{ xmlwriter_object_free_storage */
- static void xmlwriter_free_resource_ptr(xmlwriter_object *intern)
- {
- if (intern) {
- if (intern->ptr) {
- xmlFreeTextWriter(intern->ptr);
- intern->ptr = NULL;
- }
- if (intern->output) {
- xmlBufferFree(intern->output);
- intern->output = NULL;
- }
- efree(intern);
- }
- }
- /* }}} */
- /* {{{ XMLWRITER_FROM_OBJECT */
- #define XMLWRITER_FROM_OBJECT(intern, object) \
- { \
- ze_xmlwriter_object *obj = Z_XMLWRITER_P(object); \
- intern = obj->xmlwriter_ptr; \
- if (!intern) { \
- php_error_docref(NULL, E_WARNING, "Invalid or uninitialized XMLWriter object"); \
- RETURN_FALSE; \
- } \
- }
- /* }}} */
- static zend_object_handlers xmlwriter_object_handlers;
- /* {{{{ xmlwriter_object_dtor */
- static void xmlwriter_object_dtor(zend_object *object)
- {
- ze_xmlwriter_object *intern = php_xmlwriter_fetch_object(object);
- /* freeing the resource here may leak, but otherwise we may use it after it has been freed */
- if (intern->xmlwriter_ptr) {
- xmlwriter_free_resource_ptr(intern->xmlwriter_ptr);
- }
- intern->xmlwriter_ptr = NULL;
- zend_objects_destroy_object(object);
- }
- /* }}} */
- /* {{{ xmlwriter_object_free_storage */
- static void xmlwriter_object_free_storage(zend_object *object)
- {
- ze_xmlwriter_object *intern = php_xmlwriter_fetch_object(object);
- zend_object_std_dtor(&intern->std);
- }
- /* }}} */
- /* {{{ xmlwriter_object_new */
- static zend_object *xmlwriter_object_new(zend_class_entry *class_type)
- {
- ze_xmlwriter_object *intern;
- intern = zend_object_alloc(sizeof(ze_xmlwriter_object), class_type);
- zend_object_std_init(&intern->std, class_type);
- object_properties_init(&intern->std, class_type);
- intern->std.handlers = &xmlwriter_object_handlers;
- return &intern->std;
- }
- /* }}} */
- #define XMLW_NAME_CHK(__err) \
- if (xmlValidateName((xmlChar *) name, 0) != 0) { \
- php_error_docref(NULL, 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
- };
- /* }}} */
- /* {{{ 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)
- PHP_FE_END
- };
- /* }}} */
- /* {{{ 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 ) {
- 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)) {
- xmlFreeURI(uri);
- return NULL;
- }
- memcpy(file_dirname, source, strlen(source));
- dir_len = php_dirname(file_dirname, strlen(source));
- if (dir_len > 0) {
- zend_stat_t 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;
- }
- /* }}} */
- /* {{{ 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),
- PHP_XMLWRITER_VERSION,
- 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)
- {
- TODO
- }
- }}} */
- /* {{{ xmlwriter_dtor */
- static void xmlwriter_dtor(zend_resource *rsrc) {
- xmlwriter_object *intern;
- intern = (xmlwriter_object *) rsrc->ptr;
- xmlwriter_free_resource_ptr(intern);
- }
- /* }}} */
- 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;
- size_t name_len;
- int retval;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &pind, &name, &name_len) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- zval *self = getThis();
- if (self) {
- XMLWRITER_FROM_OBJECT(intern, self);
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &indent) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rb", &pind, &indent) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- size_t name_len, prefix_len, uri_len;
- int retval;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss!",
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsss!", &pind,
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- size_t name_len, content_len;
- int retval;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss",
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- size_t name_len, prefix_len, uri_len, content_len;
- int retval;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss!s",
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsss!s", &pind,
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- size_t name_len, prefix_len, uri_len;
- int retval;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!ss!",
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!ss!", &pind,
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- size_t name_len, content_len;
- int retval;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!",
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|s!", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- size_t name_len, prefix_len, uri_len, content_len;
- int retval;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!ss!|s!",
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!ss!|s!", &pind,
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- size_t name_len, content_len;
- int retval;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss",
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- zval *self = getThis();
- if (self) {
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- zval *self = getThis();
- if (self) {
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pind) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- size_t version_len, enc_len, alone_len;
- int retval;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!s!", &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!s!", &pind, &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- size_t name_len, pubid_len, sysid_len;
- int retval;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!s!", &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- size_t name_len, pubid_len, sysid_len, subset_len;
- int retval;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!s!s!", &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len, &subset, &subset_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|s!s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len, &subset, &subset_len) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- size_t name_len, content_len;
- int retval;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- size_t name_len, content_len;
- int retval;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss",
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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;
- size_t name_len;
- int retval;
- zend_bool isparm;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sb", &name, &name_len, &isparm) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsb", &pind, &name, &name_len, &isparm) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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 [, bool 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;
- size_t name_len, content_len;
- int retval;
- /* Optional parameters */
- char *pubid = NULL, *sysid = NULL, *ndataid = NULL;
- zend_bool pe = 0;
- size_t pubid_len, sysid_len, ndataid_len;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|bsss",
- &name, &name_len, &content, &content_len, &pe, &pubid, &pubid_len,
- &sysid, &sysid_len, &ndataid, &ndataid_len) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rss|bsss", &pind,
- &name, &name_len, &content, &content_len, &pe, &pubid, &pubid_len,
- &sysid, &sysid_len, &ndataid, &ndataid_len) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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];
- size_t source_len;
- zval *self = getThis();
- ze_xmlwriter_object *ze_obj = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &source, &source_len) == FAILURE) {
- return;
- }
- if (self) {
- /* We do not use XMLWRITER_FROM_OBJECT, xmlwriter init function here */
- ze_obj = Z_XMLWRITER_P(self);
- }
- if (source_len == 0) {
- php_error_docref(NULL, E_WARNING, "Empty string as source");
- RETURN_FALSE;
- }
- valid_file = _xmlwriter_get_valid_file_path(source, resolved_path, MAXPATHLEN);
- if (!valid_file) {
- php_error_docref(NULL, E_WARNING, "Unable to resolve file path");
- RETURN_FALSE;
- }
- ptr = xmlNewTextWriterFilename(valid_file, 0);
- if (!ptr) {
- RETURN_FALSE;
- }
- intern = emalloc(sizeof(xmlwriter_object));
- intern->ptr = ptr;
- intern->output = NULL;
- if (self) {
- if (ze_obj->xmlwriter_ptr) {
- xmlwriter_free_resource_ptr(ze_obj->xmlwriter_ptr);
- }
- ze_obj->xmlwriter_ptr = intern;
- RETURN_TRUE;
- } else {
- RETURN_RES(zend_register_resource(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;
- zval *self = getThis();
- ze_xmlwriter_object *ze_obj = NULL;
- if (self) {
- /* We do not use XMLWRITER_FROM_OBJECT, xmlwriter init function here */
- ze_obj = Z_XMLWRITER_P(self);
- }
- buffer = xmlBufferCreate();
- if (buffer == NULL) {
- php_error_docref(NULL, 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;
- if (self) {
- if (ze_obj->xmlwriter_ptr) {
- xmlwriter_free_resource_ptr(ze_obj->xmlwriter_ptr);
- }
- ze_obj->xmlwriter_ptr = intern;
- RETURN_TRUE;
- } else {
- RETURN_RES(zend_register_resource(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;
- zval *self = getThis();
- if (self) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &empty) == FAILURE) {
- return;
- }
- XMLWRITER_FROM_OBJECT(intern, self);
- } else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|b", &pind, &empty) == FAILURE) {
- return;
- }
- if ((intern = (xmlwriter_object *)zend_fetch_resource(Z_RES_P(pind), "XMLWriter", le_xmlwriter)) == NULL) {
- RETURN_FALSE;
- }
- }
- 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);
- 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)
- {
- zend_class_entry ce;
- le_xmlwriter = zend_register_list_destructors_ex(xmlwriter_dtor, NULL, "xmlwriter", module_number);
- memcpy(&xmlwriter_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
- xmlwriter_object_handlers.offset = XtOffsetOf(ze_xmlwriter_object, std);
- xmlwriter_object_handlers.dtor_obj = xmlwriter_object_dtor;
- xmlwriter_object_handlers.free_obj = xmlwriter_object_free_storage;
- xmlwriter_object_handlers.clone_obj = NULL;
- INIT_CLASS_ENTRY(ce, "XMLWriter", xmlwriter_class_functions);
- ce.create_object = xmlwriter_object_new;
- xmlwriter_class_entry_ce = zend_register_internal_class(&ce);
- 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
- */
|