summaryrefslogtreecommitdiff
path: root/ext/xml
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/xml
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/xml')
-rw-r--r--ext/xml/CREDITS2
-rw-r--r--ext/xml/compat.c796
-rw-r--r--ext/xml/config.m459
-rw-r--r--ext/xml/config.w3219
-rw-r--r--ext/xml/expat_compat.h156
-rw-r--r--ext/xml/package.xml74
-rw-r--r--ext/xml/php_xml.h157
-rw-r--r--ext/xml/tests/bug25666.phpt35
-rw-r--r--ext/xml/tests/bug26528.phpt31
-rw-r--r--ext/xml/tests/bug26614.phpt93
-rw-r--r--ext/xml/tests/bug26614_libxml.phpt93
-rw-r--r--ext/xml/tests/bug27908.phpt23
-rw-r--r--ext/xml/tests/bug30266.phpt52
-rw-r--r--ext/xml/tests/bug32001.phpt406
-rw-r--r--ext/xml/tests/bug32001b.phpt182
-rw-r--r--ext/xml/tests/bug35447.phpt49
-rw-r--r--ext/xml/tests/bug43957.phpt13
-rw-r--r--ext/xml/tests/bug46699.phpt33
-rw-r--r--ext/xml/tests/bug49687.phpt24
-rw-r--r--ext/xml/tests/bug50576.phpt133
-rw-r--r--ext/xml/tests/bug62328.phpt21
-rw-r--r--ext/xml/tests/inc.ent1
-rw-r--r--ext/xml/tests/skipif.inc10
-rw-r--r--ext/xml/tests/utf8_decode_error.phpt44
-rw-r--r--ext/xml/tests/utf8_decode_variation1.phpt176
-rw-r--r--ext/xml/tests/utf8_encode_error.phpt44
-rw-r--r--ext/xml/tests/utf8_encode_variation1.phpt176
-rw-r--r--ext/xml/tests/xml001.phpt97
-rw-r--r--ext/xml/tests/xml002.phpt98
-rw-r--r--ext/xml/tests/xml003.phpt96
-rw-r--r--ext/xml/tests/xml004.phpt62
-rw-r--r--ext/xml/tests/xml006.phpt12
-rw-r--r--ext/xml/tests/xml007.phpt53
-rw-r--r--ext/xml/tests/xml009.phpt35
-rw-r--r--ext/xml/tests/xml010.phpt39
-rw-r--r--ext/xml/tests/xml011.phpt71
-rw-r--r--ext/xml/tests/xml_closures_001.phpt45
-rw-r--r--ext/xml/tests/xml_error_string_error.phpt44
-rw-r--r--ext/xml/tests/xml_error_string_variation1.phpt179
-rw-r--r--ext/xml/tests/xml_get_current_byte_index_error.phpt44
-rw-r--r--ext/xml/tests/xml_get_current_byte_index_variation1.phpt240
-rw-r--r--ext/xml/tests/xml_get_current_column_number_error.phpt44
-rw-r--r--ext/xml/tests/xml_get_current_column_number_variation1.phpt241
-rw-r--r--ext/xml/tests/xml_get_current_line_number_error.phpt44
-rw-r--r--ext/xml/tests/xml_get_current_line_number_variation1.phpt240
-rw-r--r--ext/xml/tests/xml_get_error_code_error.phpt44
-rw-r--r--ext/xml/tests/xml_get_error_code_variation1.phpt240
-rw-r--r--ext/xml/tests/xml_parse_error.phpt48
-rw-r--r--ext/xml/tests/xml_parse_into_struct_error.phpt49
-rw-r--r--ext/xml/tests/xml_parse_into_struct_variation.phpt120
-rw-r--r--ext/xml/tests/xml_parse_into_struct_variation1.phpt241
-rw-r--r--ext/xml/tests/xml_parse_variation1.phpt242
-rw-r--r--ext/xml/tests/xml_parser_create_error.phpt35
-rw-r--r--ext/xml/tests/xml_parser_create_ns_error.phpt36
-rw-r--r--ext/xml/tests/xml_parser_create_ns_variation1.phpt245
-rw-r--r--ext/xml/tests/xml_parser_create_variation1.phpt245
-rw-r--r--ext/xml/tests/xml_parser_free_error.phpt44
-rw-r--r--ext/xml/tests/xml_parser_free_variation1.phpt240
-rw-r--r--ext/xml/tests/xml_parser_get_option_error.phpt46
-rw-r--r--ext/xml/tests/xml_parser_get_option_variation1.phpt241
-rw-r--r--ext/xml/tests/xml_parser_get_option_variation2.phpt226
-rw-r--r--ext/xml/tests/xml_parser_set_option_basic.phpt57
-rw-r--r--ext/xml/tests/xml_parser_set_option_error.phpt49
-rw-r--r--ext/xml/tests/xml_parser_set_option_variation1.phpt241
-rw-r--r--ext/xml/tests/xml_parser_set_option_variation2.phpt215
-rw-r--r--ext/xml/tests/xml_parser_set_option_variation3.phpt187
-rw-r--r--ext/xml/tests/xml_set_character_data_handler_error.phpt47
-rw-r--r--ext/xml/tests/xml_set_character_data_handler_variation1.phpt245
-rw-r--r--ext/xml/tests/xml_set_default_handler_error.phpt47
-rw-r--r--ext/xml/tests/xml_set_default_handler_variation1.phpt245
-rw-r--r--ext/xml/tests/xml_set_element_handler_error.phpt47
-rw-r--r--ext/xml/tests/xml_set_element_handler_variation1.phpt245
-rw-r--r--ext/xml/tests/xml_set_end_namespace_decl_handler_error.phpt47
-rw-r--r--ext/xml/tests/xml_set_end_namespace_decl_handler_variation1.phpt245
-rw-r--r--ext/xml/tests/xml_set_external_entity_ref_handler_error.phpt47
-rw-r--r--ext/xml/tests/xml_set_external_entity_ref_handler_variation1.phpt245
-rw-r--r--ext/xml/tests/xml_set_notation_decl_handler_basic.phpt102
-rw-r--r--ext/xml/tests/xml_set_notation_decl_handler_error.phpt47
-rw-r--r--ext/xml/tests/xml_set_notation_decl_handler_variation1.phpt245
-rw-r--r--ext/xml/tests/xml_set_object_error.phpt51
-rw-r--r--ext/xml/tests/xml_set_object_variation1.phpt241
-rw-r--r--ext/xml/tests/xml_set_object_variation2.phpt230
-rw-r--r--ext/xml/tests/xml_set_processing_instruction_handler_basic.phpt52
-rw-r--r--ext/xml/tests/xml_set_processing_instruction_handler_error.phpt47
-rw-r--r--ext/xml/tests/xml_set_processing_instruction_handler_variation1.phpt245
-rw-r--r--ext/xml/tests/xml_set_start_namespace_decl_handler_basic.phpt61
-rw-r--r--ext/xml/tests/xml_set_start_namespace_decl_handler_error.phpt47
-rw-r--r--ext/xml/tests/xml_set_start_namespace_decl_handler_variation1.phpt245
-rw-r--r--ext/xml/tests/xml_set_unparsed_entity_decl_handler_error.phpt47
-rw-r--r--ext/xml/tests/xml_set_unparsed_entity_decl_handler_variation1.phpt245
-rw-r--r--ext/xml/tests/xmltest.xml20
-rw-r--r--ext/xml/xml.c1729
-rw-r--r--ext/xml/xml.mak172
93 files changed, 12963 insertions, 0 deletions
diff --git a/ext/xml/CREDITS b/ext/xml/CREDITS
new file mode 100644
index 0000000..b9cbfdd
--- /dev/null
+++ b/ext/xml/CREDITS
@@ -0,0 +1,2 @@
+XML
+Stig Bakken, Thies C. Arntzen, Sterling Hughes
diff --git a/ext/xml/compat.c b/ext/xml/compat.c
new file mode 100644
index 0000000..fbebb63
--- /dev/null
+++ b/ext/xml/compat.c
@@ -0,0 +1,796 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2013 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. |
+ +----------------------------------------------------------------------+
+ | Authors: Sterling Hughes <sterling@php.net> |
+ +----------------------------------------------------------------------+
+ */
+
+#include "php.h"
+#if defined(HAVE_LIBXML) && (defined(HAVE_XML) || defined(HAVE_XMLRPC)) && !defined(HAVE_LIBEXPAT)
+#include "expat_compat.h"
+
+typedef struct _php_xml_ns {
+ xmlNsPtr nsptr;
+ int ref_count;
+ void *next;
+ void *prev;
+} php_xml_ns;
+
+#ifdef LIBXML_EXPAT_COMPAT
+
+#define IS_NS_DECL(__ns) \
+ ((__ns) != NULL && strlen(__ns) == 5 && *(__ns) == 'x' && *((__ns)+1) == 'm' && \
+ *((__ns)+2) == 'l' && *((__ns)+3) == 'n' && *((__ns)+4) == 's')
+
+static void
+_qualify_namespace(XML_Parser parser, const xmlChar *name, const xmlChar *URI, xmlChar **qualified)
+{
+ if (URI) {
+ /* Use libxml functions otherwise its memory deallocation is screwed up */
+ *qualified = xmlStrdup(URI);
+ *qualified = xmlStrncat(*qualified, parser->_ns_seperator, 1);
+ *qualified = xmlStrncat(*qualified, name, xmlStrlen(name));
+ } else {
+ *qualified = xmlStrdup(name);
+ }
+}
+
+static void
+_start_element_handler(void *user, const xmlChar *name, const xmlChar **attributes)
+{
+ XML_Parser parser = (XML_Parser) user;
+ xmlChar *qualified_name = NULL;
+
+ if (parser->h_start_element == NULL) {
+ if (parser->h_default) {
+ int attno = 0;
+
+ qualified_name = xmlStrncatNew((xmlChar *)"<", name, xmlStrlen(name));
+ if (attributes) {
+ while (attributes[attno] != NULL) {
+ int att_len;
+ char *att_string, *att_name, *att_value;
+
+ att_name = (char *)attributes[attno++];
+ att_value = (char *)attributes[attno++];
+
+ att_len = spprintf(&att_string, 0, " %s=\"%s\"", att_name, att_value);
+
+ qualified_name = xmlStrncat(qualified_name, (xmlChar *)att_string, att_len);
+ efree(att_string);
+ }
+
+ }
+ qualified_name = xmlStrncat(qualified_name, (xmlChar *)">", 1);
+ parser->h_default(parser->user, (const XML_Char *) qualified_name, xmlStrlen(qualified_name));
+ xmlFree(qualified_name);
+ }
+ return;
+ }
+
+ qualified_name = xmlStrdup(name);
+
+ parser->h_start_element(parser->user, (const XML_Char *) qualified_name, (const XML_Char **) attributes);
+
+ xmlFree(qualified_name);
+}
+
+static void
+_start_element_handler_ns(void *user, const xmlChar *name, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar ** namespaces, int nb_attributes, int nb_defaulted, const xmlChar ** attributes)
+{
+ XML_Parser parser = (XML_Parser) user;
+ xmlChar *qualified_name = NULL;
+ xmlChar **attrs = NULL;
+ int i;
+ int z = 0;
+ int y = 0;
+
+ if (nb_namespaces > 0 && parser->h_start_ns != NULL) {
+ for (i = 0; i < nb_namespaces; i += 1) {
+ parser->h_start_ns(parser->user, (const XML_Char *) namespaces[y], (const XML_Char *) namespaces[y+1]);
+ y += 2;
+ }
+ y = 0;
+ }
+
+ if (parser->h_start_element == NULL) {
+ if (parser->h_default) {
+
+ if (prefix) {
+ qualified_name = xmlStrncatNew((xmlChar *)"<", prefix, xmlStrlen(prefix));
+ qualified_name = xmlStrncat(qualified_name, (xmlChar *)":", 1);
+ qualified_name = xmlStrncat(qualified_name, name, xmlStrlen(name));
+ } else {
+ qualified_name = xmlStrncatNew((xmlChar *)"<", name, xmlStrlen(name));
+ }
+
+ if (namespaces) {
+ int i, j;
+ for (i = 0,j = 0;j < nb_namespaces;j++) {
+ int ns_len;
+ char *ns_string, *ns_prefix, *ns_url;
+
+ ns_prefix = (char *) namespaces[i++];
+ ns_url = (char *) namespaces[i++];
+
+ if (ns_prefix) {
+ ns_len = spprintf(&ns_string, 0, " xmlns:%s=\"%s\"", ns_prefix, ns_url);
+ } else {
+ ns_len = spprintf(&ns_string, 0, " xmlns=\"%s\"", ns_url);
+ }
+ qualified_name = xmlStrncat(qualified_name, (xmlChar *)ns_string, ns_len);
+
+ efree(ns_string);
+ }
+ }
+
+ if (attributes) {
+ for (i = 0; i < nb_attributes; i += 1) {
+ int att_len;
+ char *att_string, *att_name, *att_value, *att_prefix, *att_valueend;
+
+ att_name = (char *) attributes[y++];
+ att_prefix = (char *)attributes[y++];
+ y++;
+ att_value = (char *)attributes[y++];
+ att_valueend = (char *)attributes[y++];
+
+ if (att_prefix) {
+ att_len = spprintf(&att_string, 0, " %s:%s=\"", att_prefix, att_name);
+ } else {
+ att_len = spprintf(&att_string, 0, " %s=\"", att_name);
+ }
+
+ qualified_name = xmlStrncat(qualified_name, (xmlChar *)att_string, att_len);
+ qualified_name = xmlStrncat(qualified_name, (xmlChar *)att_value, att_valueend - att_value);
+ qualified_name = xmlStrncat(qualified_name, (xmlChar *)"\"", 1);
+
+ efree(att_string);
+ }
+
+ }
+ qualified_name = xmlStrncat(qualified_name, (xmlChar *)">", 1);
+ parser->h_default(parser->user, (const XML_Char *) qualified_name, xmlStrlen(qualified_name));
+ xmlFree(qualified_name);
+ }
+ return;
+ }
+ _qualify_namespace(parser, name, URI, &qualified_name);
+
+ if (attributes != NULL) {
+ xmlChar *qualified_name_attr = NULL;
+ attrs = safe_emalloc((nb_attributes * 2) + 1, sizeof(int *), 0);
+
+ for (i = 0; i < nb_attributes; i += 1) {
+
+ if (attributes[y+1] != NULL) {
+ _qualify_namespace(parser, attributes[y] , attributes[y + 2], &qualified_name_attr);
+ } else {
+ qualified_name_attr = xmlStrdup(attributes[y]);
+ }
+ attrs[z] = qualified_name_attr;
+ attrs[z + 1] = xmlStrndup(attributes[y + 3] , (int) (attributes[y + 4] - attributes[y + 3]));
+ z += 2;
+ y += 5;
+ }
+
+ attrs[z] = NULL;
+ }
+ parser->h_start_element(parser->user, (const XML_Char *) qualified_name, (const XML_Char **) attrs);
+ if (attrs) {
+ for (i = 0; i < z; i++) {
+ xmlFree(attrs[i]);
+ }
+ efree(attrs);
+ }
+ xmlFree(qualified_name);
+}
+
+static void
+_namespace_handler(XML_Parser parser, xmlNsPtr nsptr)
+{
+ if (nsptr != NULL) {
+ _namespace_handler(parser, nsptr->next);
+ parser->h_end_ns(parser->user, nsptr->prefix);
+ }
+}
+
+static void
+_end_element_handler(void *user, const xmlChar *name)
+{
+ xmlChar *qualified_name;
+ XML_Parser parser = (XML_Parser) user;
+
+ if (parser->h_end_element == NULL) {
+ if (parser->h_default) {
+ char *end_element;
+
+ spprintf(&end_element, 0, "</%s>", (char *)name);
+ parser->h_default(parser->user, (const XML_Char *) end_element, strlen(end_element));
+ efree(end_element);
+ }
+ return;
+ }
+
+ qualified_name = xmlStrdup(name);
+
+ parser->h_end_element(parser->user, (const XML_Char *) qualified_name);
+
+ xmlFree(qualified_name);
+}
+
+static void
+_end_element_handler_ns(void *user, const xmlChar *name, const xmlChar * prefix, const xmlChar *URI)
+{
+ xmlChar *qualified_name;
+ XML_Parser parser = (XML_Parser) user;
+
+ if (parser->h_end_element == NULL) {
+ if (parser->h_default) {
+ char *end_element;
+ int end_element_len;
+
+ if (prefix) {
+ end_element_len = spprintf(&end_element, 0, "</%s:%s>", (char *) prefix, (char *)name);
+ } else {
+ end_element_len = spprintf(&end_element, 0, "</%s>", (char *)name);
+ }
+ parser->h_default(parser->user, (const XML_Char *) end_element, end_element_len);
+ efree(end_element);
+ }
+ return;
+ }
+
+ _qualify_namespace(parser, name, URI, &qualified_name);
+
+ parser->h_end_element(parser->user, (const XML_Char *) qualified_name);
+
+ xmlFree(qualified_name);
+}
+
+static void
+_cdata_handler(void *user, const xmlChar *cdata, int cdata_len)
+{
+ XML_Parser parser = (XML_Parser) user;
+
+ if (parser->h_cdata == NULL) {
+ if (parser->h_default) {
+ parser->h_default(parser->user, (const XML_Char *) cdata, cdata_len);
+ }
+ return;
+ }
+
+ parser->h_cdata(parser->user, (const XML_Char *) cdata, cdata_len);
+}
+
+static void
+_pi_handler(void *user, const xmlChar *target, const xmlChar *data)
+{
+ XML_Parser parser = (XML_Parser) user;
+
+ if (parser->h_pi == NULL) {
+ if (parser->h_default) {
+ char *full_pi;
+ spprintf(&full_pi, 0, "<?%s %s?>", (char *)target, (char *)data);
+ parser->h_default(parser->user, (const XML_Char *) full_pi, strlen(full_pi));
+ efree(full_pi);
+ }
+ return;
+ }
+
+ parser->h_pi(parser->user, (const XML_Char *) target, (const XML_Char *) data);
+}
+
+static void
+_unparsed_entity_decl_handler(void *user,
+ const xmlChar *name,
+ const xmlChar *pub_id,
+ const xmlChar *sys_id,
+ const xmlChar *notation)
+{
+ XML_Parser parser = (XML_Parser) user;
+
+ if (parser->h_unparsed_entity_decl == NULL) {
+ return;
+ }
+
+ parser->h_unparsed_entity_decl(parser->user, name, NULL, sys_id, pub_id, notation);
+}
+
+static void
+_notation_decl_handler(void *user, const xmlChar *notation, const xmlChar *pub_id, const xmlChar *sys_id)
+{
+ XML_Parser parser = (XML_Parser) user;
+
+ if (parser->h_notation_decl == NULL) {
+ return;
+ }
+
+ parser->h_notation_decl(parser->user, notation, NULL, sys_id, pub_id);
+}
+
+static void
+_build_comment(const xmlChar *data, int data_len, xmlChar **comment, int *comment_len)
+{
+ *comment_len = data_len + 7;
+
+ *comment = xmlMalloc(*comment_len + 1);
+ memcpy(*comment, "<!--", 4);
+ memcpy(*comment + 4, data, data_len);
+ memcpy(*comment + 4 + data_len, "-->", 3);
+
+ (*comment)[*comment_len] = '\0';
+}
+
+static void
+_comment_handler(void *user, const xmlChar *comment)
+{
+ XML_Parser parser = (XML_Parser) user;
+
+ if (parser->h_default) {
+ xmlChar *d_comment;
+ int d_comment_len;
+
+ _build_comment(comment, xmlStrlen(comment), &d_comment, &d_comment_len);
+ parser->h_default(parser->user, d_comment, d_comment_len);
+ xmlFree(d_comment);
+ }
+}
+
+static void
+_build_entity(const xmlChar *name, int len, xmlChar **entity, int *entity_len)
+{
+ *entity_len = len + 2;
+ *entity = xmlMalloc(*entity_len + 1);
+ (*entity)[0] = '&';
+ memcpy(*entity+1, name, len);
+ (*entity)[len+1] = ';';
+ (*entity)[*entity_len] = '\0';
+}
+
+static void
+_external_entity_ref_handler(void *user, const xmlChar *names, int type, const xmlChar *sys_id, const xmlChar *pub_id, xmlChar *content)
+{
+ XML_Parser parser = (XML_Parser) user;
+
+ if (parser->h_external_entity_ref == NULL) {
+ return;
+ }
+
+ parser->h_external_entity_ref(parser, names, "", sys_id, pub_id);
+}
+
+static xmlEntityPtr
+_get_entity(void *user, const xmlChar *name)
+{
+ XML_Parser parser = (XML_Parser) user;
+ xmlEntityPtr ret = NULL;
+
+ if (parser->parser->inSubset == 0) {
+ ret = xmlGetPredefinedEntity(name);
+ if (ret == NULL)
+ ret = xmlGetDocEntity(parser->parser->myDoc, name);
+
+ if (ret == NULL || (parser->parser->instate != XML_PARSER_ENTITY_VALUE && parser->parser->instate != XML_PARSER_ATTRIBUTE_VALUE)) {
+ if (ret == NULL || ret->etype == XML_INTERNAL_GENERAL_ENTITY || ret->etype == XML_INTERNAL_PARAMETER_ENTITY || ret->etype == XML_INTERNAL_PREDEFINED_ENTITY) {
+ /* Predefined entities will expand unless no cdata handler is present */
+ if (parser->h_default && ! (ret && ret->etype == XML_INTERNAL_PREDEFINED_ENTITY && parser->h_cdata)) {
+ xmlChar *entity;
+ int len;
+
+ _build_entity(name, xmlStrlen(name), &entity, &len);
+ parser->h_default(parser->user, (const xmlChar *) entity, len);
+ xmlFree(entity);
+ } else {
+ /* expat will not expand internal entities if default handler is present otherwise
+ it will expand and pass them to cdata handler */
+ if (parser->h_cdata && ret) {
+ parser->h_cdata(parser->user, ret->content, xmlStrlen(ret->content));
+ }
+ }
+ } else {
+ if (ret->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) {
+ _external_entity_ref_handler(user, ret->name, ret->etype, ret->SystemID, ret->ExternalID, NULL);
+ }
+ }
+ }
+ }
+
+ return ret;
+}
+
+static xmlSAXHandler
+php_xml_compat_handlers = {
+ NULL, /* internalSubset */
+ NULL, /* isStandalone */
+ NULL, /* hasInternalSubset */
+ NULL, /* hasExternalSubset */
+ NULL, /* resolveEntity */
+ _get_entity, /* getEntity */
+ NULL, /* entityDecl */
+ _notation_decl_handler,
+ NULL, /* attributeDecl */
+ NULL, /* elementDecl */
+ _unparsed_entity_decl_handler, /* unparsedEntity */
+ NULL, /* setDocumentLocator */
+ NULL, /* startDocument */
+ NULL, /* endDocument */
+ _start_element_handler, /* startElement */
+ _end_element_handler, /* endElement */
+ NULL, /* reference */
+ _cdata_handler,
+ NULL, /* ignorableWhitespace */
+ _pi_handler,
+ _comment_handler, /* comment */
+ NULL, /* warning */
+ NULL, /* error */
+ NULL, /* fatalError */
+ NULL, /* getParameterEntity */
+ _cdata_handler, /* cdataBlock */
+ NULL, /* externalSubset */
+ XML_SAX2_MAGIC,
+ NULL,
+ _start_element_handler_ns,
+ _end_element_handler_ns,
+ NULL
+};
+
+PHPAPI XML_Parser
+XML_ParserCreate(const XML_Char *encoding)
+{
+ return XML_ParserCreate_MM(encoding, NULL, NULL);
+}
+
+PHPAPI XML_Parser
+XML_ParserCreateNS(const XML_Char *encoding, const XML_Char sep)
+{
+ XML_Char tmp[2];
+ tmp[0] = sep;
+ tmp[1] = '\0';
+ return XML_ParserCreate_MM(encoding, NULL, tmp);
+}
+
+PHPAPI XML_Parser
+XML_ParserCreate_MM(const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite, const XML_Char *sep)
+{
+ XML_Parser parser;
+
+ parser = (XML_Parser) emalloc(sizeof(struct _XML_Parser));
+ memset(parser, 0, sizeof(struct _XML_Parser));
+ parser->use_namespace = 0;
+ parser->_ns_seperator = NULL;
+
+ parser->parser = xmlCreatePushParserCtxt((xmlSAXHandlerPtr) &php_xml_compat_handlers, (void *) parser, NULL, 0, NULL);
+ if (parser->parser == NULL) {
+ efree(parser);
+ return NULL;
+ }
+#if LIBXML_VERSION <= 20617
+ /* for older versions of libxml2, allow correct detection of
+ * charset in documents with a BOM: */
+ parser->parser->charset = XML_CHAR_ENCODING_NONE;
+#endif
+
+#if LIBXML_VERSION >= 20703
+ xmlCtxtUseOptions(parser->parser, XML_PARSE_OLDSAX);
+#endif
+
+ parser->parser->replaceEntities = 1;
+ parser->parser->wellFormed = 0;
+ if (sep != NULL) {
+ parser->use_namespace = 1;
+ parser->parser->sax2 = 1;
+ parser->_ns_seperator = xmlStrdup(sep);
+ } else {
+ /* Reset flag as XML_SAX2_MAGIC is needed for xmlCreatePushParserCtxt
+ so must be set in the handlers */
+ parser->parser->sax->initialized = 1;
+ }
+ return parser;
+}
+
+PHPAPI void
+XML_SetUserData(XML_Parser parser, void *user)
+{
+ parser->user = user;
+}
+
+PHPAPI void *
+XML_GetUserData(XML_Parser parser)
+{
+ return parser->user;
+}
+
+PHPAPI void
+XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start, XML_EndElementHandler end)
+{
+ parser->h_start_element = start;
+ parser->h_end_element = end;
+}
+
+PHPAPI void
+XML_SetCharacterDataHandler(XML_Parser parser, XML_CharacterDataHandler cdata)
+{
+ parser->h_cdata = cdata;
+}
+
+PHPAPI void
+XML_SetProcessingInstructionHandler(XML_Parser parser, XML_ProcessingInstructionHandler pi)
+{
+ parser->h_pi = pi;
+}
+
+PHPAPI void
+XML_SetCommentHandler(XML_Parser parser, XML_CommentHandler comment)
+{
+ parser->h_comment = comment;
+}
+
+PHPAPI void
+XML_SetDefaultHandler(XML_Parser parser, XML_DefaultHandler d)
+{
+ parser->h_default = d;
+}
+
+PHPAPI void
+XML_SetUnparsedEntityDeclHandler(XML_Parser parser, XML_UnparsedEntityDeclHandler unparsed_decl)
+{
+ parser->h_unparsed_entity_decl = unparsed_decl;
+}
+
+PHPAPI void
+XML_SetNotationDeclHandler(XML_Parser parser, XML_NotationDeclHandler notation_decl)
+{
+ parser->h_notation_decl = notation_decl;
+}
+
+PHPAPI void
+XML_SetExternalEntityRefHandler(XML_Parser parser, XML_ExternalEntityRefHandler ext_entity)
+{
+ parser->h_external_entity_ref = ext_entity;
+}
+
+PHPAPI void
+XML_SetStartNamespaceDeclHandler(XML_Parser parser, XML_StartNamespaceDeclHandler start_ns)
+{
+ parser->h_start_ns = start_ns;
+}
+
+PHPAPI void
+XML_SetEndNamespaceDeclHandler(XML_Parser parser, XML_EndNamespaceDeclHandler end_ns)
+{
+ parser->h_end_ns = end_ns;
+}
+
+PHPAPI int
+XML_Parse(XML_Parser parser, const XML_Char *data, int data_len, int is_final)
+{
+ int error;
+
+/* The following is a hack to keep BC with PHP 4 while avoiding
+the inifite loop in libxml <= 2.6.17 which occurs when no encoding
+has been defined and none can be detected */
+#if LIBXML_VERSION <= 20617
+ if (parser->parser->charset == XML_CHAR_ENCODING_NONE) {
+ if (data_len >= 4 || (parser->parser->input->buf->buffer->use + data_len >= 4)) {
+ xmlChar start[4];
+ int char_count;
+
+ char_count = parser->parser->input->buf->buffer->use;
+ if (char_count > 4) {
+ char_count = 4;
+ }
+
+ memcpy(start, parser->parser->input->buf->buffer->content, (size_t)char_count);
+ memcpy(start + char_count, data, (size_t)(4 - char_count));
+
+ if (xmlDetectCharEncoding(&start[0], 4) == XML_CHAR_ENCODING_NONE) {
+ parser->parser->charset = XML_CHAR_ENCODING_UTF8;
+ }
+ }
+ }
+#endif
+
+ error = xmlParseChunk(parser->parser, data, data_len, is_final);
+ if (!error) {
+ return 1;
+ } else if (parser->parser->lastError.level > XML_ERR_WARNING ){
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+PHPAPI int
+XML_GetErrorCode(XML_Parser parser)
+{
+ return parser->parser->errNo;
+}
+
+static const XML_Char *const error_mapping[] = {
+ "No error",
+ "No memory",
+ "Invalid document start",
+ "Empty document",
+ "Not well-formed (invalid token)",
+ "Invalid document end",
+ "Invalid hexadecimal character reference",
+ "Invalid decimal character reference",
+ "Invalid character reference",
+ "Invalid character",
+ "XML_ERR_CHARREF_AT_EOF",
+ "XML_ERR_CHARREF_IN_PROLOG",
+ "XML_ERR_CHARREF_IN_EPILOG",
+ "XML_ERR_CHARREF_IN_DTD",
+ "XML_ERR_ENTITYREF_AT_EOF",
+ "XML_ERR_ENTITYREF_IN_PROLOG",
+ "XML_ERR_ENTITYREF_IN_EPILOG",
+ "XML_ERR_ENTITYREF_IN_DTD",
+ "PEReference at end of document",
+ "PEReference in prolog",
+ "PEReference in epilog",
+ "PEReference: forbidden within markup decl in internal subset",
+ "XML_ERR_ENTITYREF_NO_NAME",
+ "EntityRef: expecting ';'",
+ "PEReference: no name",
+ "PEReference: expecting ';'",
+ "Undeclared entity error",
+ "Undeclared entity warning",
+ "Unparsed Entity",
+ "XML_ERR_ENTITY_IS_EXTERNAL",
+ "XML_ERR_ENTITY_IS_PARAMETER",
+ "Unknown encoding",
+ "Unsupported encoding",
+ "String not started expecting ' or \"",
+ "String not closed expecting \" or '",
+ "Namespace declaration error",
+ "EntityValue: \" or ' expected",
+ "EntityValue: \" or ' expected",
+ "< in attribute",
+ "Attribute not started",
+ "Attribute not finished",
+ "Attribute without value",
+ "Attribute redefined",
+ "SystemLiteral \" or ' expected",
+ "SystemLiteral \" or ' expected",
+ /* "XML_ERR_COMMENT_NOT_STARTED", <= eliminated on purpose */
+ "Comment not finished",
+ "Processing Instruction not started",
+ "Processing Instruction not finished",
+ "NOTATION: Name expected here",
+ "'>' required to close NOTATION declaration",
+ "'(' required to start ATTLIST enumeration",
+ "'(' required to start ATTLIST enumeration",
+ "MixedContentDecl : '|' or ')*' expected",
+ "XML_ERR_MIXED_NOT_FINISHED",
+ "ELEMENT in DTD not started",
+ "ELEMENT in DTD not finished",
+ "XML declaration not started",
+ "XML declaration not finished",
+ "XML_ERR_CONDSEC_NOT_STARTED",
+ "XML conditional section not closed",
+ "Content error in the external subset",
+ "DOCTYPE not finished",
+ "Sequence ']]>' not allowed in content",
+ "CDATA not finished",
+ "Reserved XML Name",
+ "Space required",
+ "XML_ERR_SEPARATOR_REQUIRED",
+ "NmToken expected in ATTLIST enumeration",
+ "XML_ERR_NAME_REQUIRED",
+ "MixedContentDecl : '#PCDATA' expected",
+ "SYSTEM or PUBLIC, the URI is missing",
+ "PUBLIC, the Public Identifier is missing",
+ "< required",
+ "> required",
+ "</ required",
+ "= required",
+ "Mismatched tag",
+ "Tag not finished",
+ "standalone accepts only 'yes' or 'no'",
+ "Invalid XML encoding name",
+ "Comment must not contain '--' (double-hyphen)",
+ "Invalid encoding",
+ "external parsed entities cannot be standalone",
+ "XML conditional section '[' expected",
+ "Entity value required",
+ "chunk is not well balanced",
+ "extra content at the end of well balanced chunk",
+ "XML_ERR_ENTITY_CHAR_ERROR",
+ "PEReferences forbidden in internal subset",
+ "Detected an entity reference loop",
+ "XML_ERR_ENTITY_BOUNDARY",
+ "Invalid URI",
+ "Fragment not allowed",
+ "XML_WAR_CATALOG_PI",
+ "XML_ERR_NO_DTD",
+ "conditional section INCLUDE or IGNORE keyword expected", /* 95 */
+ "Version in XML Declaration missing", /* 96 */
+ "XML_WAR_UNKNOWN_VERSION", /* 97 */
+ "XML_WAR_LANG_VALUE", /* 98 */
+ "XML_WAR_NS_URI", /* 99 */
+ "XML_WAR_NS_URI_RELATIVE", /* 100 */
+ "Missing encoding in text declaration" /* 101 */
+};
+
+PHPAPI const XML_Char *
+XML_ErrorString(int code)
+{
+ if (code < 0 || code >= (int)(sizeof(error_mapping) / sizeof(error_mapping[0]))) {
+ return "Unknown";
+ }
+ return error_mapping[code];
+}
+
+PHPAPI int
+XML_GetCurrentLineNumber(XML_Parser parser)
+{
+ return parser->parser->input->line;
+}
+
+PHPAPI int
+XML_GetCurrentColumnNumber(XML_Parser parser)
+{
+ return parser->parser->input->col;
+}
+
+PHPAPI int
+XML_GetCurrentByteIndex(XML_Parser parser)
+{
+ return parser->parser->input->consumed +
+ (parser->parser->input->cur - parser->parser->input->base);
+}
+
+PHPAPI int
+XML_GetCurrentByteCount(XML_Parser parser)
+{
+ /* WARNING: this is identical to ByteIndex; it should probably
+ * be different */
+ return parser->parser->input->consumed +
+ (parser->parser->input->cur - parser->parser->input->base);
+}
+
+PHPAPI const XML_Char *XML_ExpatVersion(void)
+{
+ return "1.0";
+}
+
+PHPAPI void
+XML_ParserFree(XML_Parser parser)
+{
+ if (parser->use_namespace) {
+ if (parser->_ns_seperator) {
+ xmlFree(parser->_ns_seperator);
+ }
+ }
+ if (parser->parser->myDoc) {
+ xmlFreeDoc(parser->parser->myDoc);
+ parser->parser->myDoc = NULL;
+ }
+ xmlFreeParserCtxt(parser->parser);
+ efree(parser);
+}
+
+#endif /* LIBXML_EXPAT_COMPAT */
+#endif
+
+/**
+ * Local Variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * End:
+ * vim600: fdm=marker
+ * vim: ts=4 noet sw=4
+ */
diff --git a/ext/xml/config.m4 b/ext/xml/config.m4
new file mode 100644
index 0000000..65f2291
--- /dev/null
+++ b/ext/xml/config.m4
@@ -0,0 +1,59 @@
+dnl
+dnl $Id$
+dnl
+
+PHP_ARG_ENABLE(xml,whether to enable XML support,
+[ --disable-xml Disable XML support], yes)
+
+if test -z "$PHP_LIBXML_DIR"; then
+ PHP_ARG_WITH(libxml-dir, libxml2 install dir,
+ [ --with-libxml-dir=DIR XML: libxml2 install prefix], no, no)
+fi
+
+PHP_ARG_WITH(libexpat-dir, libexpat install dir,
+[ --with-libexpat-dir=DIR XML: libexpat install prefix (deprecated)], no, no)
+
+if test "$PHP_XML" != "no"; then
+
+ dnl
+ dnl Default to libxml2 if --with-libexpat-dir is not used.
+ dnl
+ if test "$PHP_LIBEXPAT_DIR" = "no"; then
+
+ if test "$PHP_LIBXML" = "no"; then
+ AC_MSG_ERROR([XML extension requires LIBXML extension, add --enable-libxml])
+ fi
+
+ PHP_SETUP_LIBXML(XML_SHARED_LIBADD, [
+ xml_extra_sources="compat.c"
+ PHP_ADD_EXTENSION_DEP(xml, libxml)
+ ], [
+ AC_MSG_ERROR([xml2-config not found. Use --with-libxml-dir=<DIR>])
+ ])
+ fi
+
+ dnl
+ dnl Check for expat only if --with-libexpat-dir is used.
+ dnl
+ if test "$PHP_LIBEXPAT_DIR" != "no"; then
+ for i in $PHP_XML $PHP_LIBEXPAT_DIR /usr /usr/local; do
+ if test -f "$i/$PHP_LIBDIR/libexpat.a" || test -f "$i/$PHP_LIBDIR/libexpat.$SHLIB_SUFFIX_NAME"; then
+ EXPAT_DIR=$i
+ break
+ fi
+ done
+
+ if test -z "$EXPAT_DIR"; then
+ AC_MSG_ERROR([not found. Please reinstall the expat distribution.])
+ fi
+
+ PHP_ADD_INCLUDE($EXPAT_DIR/include)
+ PHP_ADD_LIBRARY_WITH_PATH(expat, $EXPAT_DIR/$PHP_LIBDIR, XML_SHARED_LIBADD)
+ AC_DEFINE(HAVE_LIBEXPAT, 1, [ ])
+ fi
+
+ PHP_NEW_EXTENSION(xml, xml.c $xml_extra_sources, $ext_shared)
+ PHP_SUBST(XML_SHARED_LIBADD)
+ PHP_INSTALL_HEADERS([ext/xml/])
+ AC_DEFINE(HAVE_XML, 1, [ ])
+fi
diff --git a/ext/xml/config.w32 b/ext/xml/config.w32
new file mode 100644
index 0000000..4ee0bd1
--- /dev/null
+++ b/ext/xml/config.w32
@@ -0,0 +1,19 @@
+// $Id$
+// vim:ft=javascript
+
+ARG_WITH("xml", "XML support", "yes");
+
+if (PHP_XML == "yes") {
+ if (PHP_LIBXML == "yes"
+ && ADD_EXTENSION_DEP('xml', 'libxml')) {
+ EXTENSION("xml", "xml.c compat.c");
+ AC_DEFINE("HAVE_XML", 1, "XML support");
+ if (!PHP_XML_SHARED) {
+ ADD_FLAG("CFLAGS_XML", "/D LIBXML_STATIC ");
+ }
+ PHP_INSTALL_HEADERS("", "ext/xml");
+ } else {
+ WARNING("xml support can't be enabled, libraries or headers are missing")
+ PHP_ZLIB = "no"
+ }
+}
diff --git a/ext/xml/expat_compat.h b/ext/xml/expat_compat.h
new file mode 100644
index 0000000..424785f
--- /dev/null
+++ b/ext/xml/expat_compat.h
@@ -0,0 +1,156 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2013 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. |
+ +----------------------------------------------------------------------+
+ | Authors: Sterling Hughes <sterling@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifndef PHP_EXPAT_COMPAT_H
+#define PHP_EXPAT_COMPAT_H
+
+#ifdef PHP_WIN32
+#include "config.w32.h"
+#else
+#include <php_config.h>
+#endif
+
+#if !defined(HAVE_LIBEXPAT) && defined(HAVE_LIBXML)
+#define LIBXML_EXPAT_COMPAT 1
+
+#include "php.h"
+#include "php_compat.h"
+
+#include <libxml/parser.h>
+#include <libxml/parserInternals.h>
+#include <libxml/tree.h>
+#include <libxml/hash.h>
+
+typedef xmlChar XML_Char;
+
+typedef void (*XML_StartElementHandler)(void *, const XML_Char *, const XML_Char **);
+typedef void (*XML_EndElementHandler)(void *, const XML_Char *);
+typedef void (*XML_CharacterDataHandler)(void *, const XML_Char *, int);
+typedef void (*XML_ProcessingInstructionHandler)(void *, const XML_Char *, const XML_Char *);
+typedef void (*XML_CommentHandler)(void *, const XML_Char *);
+typedef void (*XML_DefaultHandler)(void *, const XML_Char *, int);
+typedef void (*XML_UnparsedEntityDeclHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
+typedef void (*XML_NotationDeclHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
+typedef int (*XML_ExternalEntityRefHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
+typedef void (*XML_StartNamespaceDeclHandler)(void *, const XML_Char *, const XML_Char *);
+typedef void (*XML_EndNamespaceDeclHandler)(void *, const XML_Char *);
+
+typedef struct _XML_Memory_Handling_Suite {
+ void *(*malloc_fcn)(size_t size);
+ void *(*realloc_fcn)(void *ptr, size_t size);
+ void (*free_fcn)(void *ptr);
+} XML_Memory_Handling_Suite;
+
+typedef struct _XML_Parser {
+ int use_namespace;
+
+ xmlChar *_ns_seperator;
+
+ void *user;
+ xmlParserCtxtPtr parser;
+
+ XML_StartElementHandler h_start_element;
+ XML_EndElementHandler h_end_element;
+ XML_CharacterDataHandler h_cdata;
+ XML_ProcessingInstructionHandler h_pi;
+ XML_CommentHandler h_comment;
+ XML_DefaultHandler h_default;
+ XML_UnparsedEntityDeclHandler h_unparsed_entity_decl;
+ XML_NotationDeclHandler h_notation_decl;
+ XML_ExternalEntityRefHandler h_external_entity_ref;
+ XML_StartNamespaceDeclHandler h_start_ns;
+ XML_EndNamespaceDeclHandler h_end_ns;
+} *XML_Parser;
+
+enum XML_Error {
+ XML_ERROR_NONE,
+ XML_ERROR_NO_MEMORY,
+ XML_ERROR_SYNTAX,
+ XML_ERROR_NO_ELEMENTS,
+ XML_ERROR_INVALID_TOKEN,
+ XML_ERROR_UNCLOSED_TOKEN,
+ XML_ERROR_PARTIAL_CHAR,
+ XML_ERROR_TAG_MISMATCH,
+ XML_ERROR_DUPLICATE_ATTRIBUTE,
+ XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
+ XML_ERROR_PARAM_ENTITY_REF,
+ XML_ERROR_UNDEFINED_ENTITY,
+ XML_ERROR_RECURSIVE_ENTITY_REF,
+ XML_ERROR_ASYNC_ENTITY,
+ XML_ERROR_BAD_CHAR_REF,
+ XML_ERROR_BINARY_ENTITY_REF,
+ XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
+ XML_ERROR_MISPLACED_XML_PI,
+ XML_ERROR_UNKNOWN_ENCODING,
+ XML_ERROR_INCORRECT_ENCODING,
+ XML_ERROR_UNCLOSED_CDATA_SECTION,
+ XML_ERROR_EXTERNAL_ENTITY_HANDLING,
+ XML_ERROR_NOT_STANDALONE,
+ XML_ERROR_UNEXPECTED_STATE,
+ XML_ERROR_ENTITY_DECLARED_IN_PE,
+ XML_ERROR_FEATURE_REQUIRES_XML_DTD,
+ XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING
+};
+
+enum XML_Content_Type {
+ XML_CTYPE_EMPTY = 1,
+ XML_CTYPE_ANY,
+ XML_CTYPE_MIXED,
+ XML_CTYPE_NAME,
+ XML_CTYPE_CHOICE,
+ XML_CTYPE_SEQ
+};
+
+PHPAPI XML_Parser XML_ParserCreate(const XML_Char *);
+PHPAPI XML_Parser XML_ParserCreateNS(const XML_Char *, const XML_Char);
+PHPAPI XML_Parser XML_ParserCreate_MM(const XML_Char *, const XML_Memory_Handling_Suite *, const XML_Char *);
+PHPAPI void XML_SetUserData(XML_Parser, void *);
+PHPAPI void *XML_GetUserData(XML_Parser);
+PHPAPI void XML_SetElementHandler(XML_Parser, XML_StartElementHandler, XML_EndElementHandler);
+PHPAPI void XML_SetCharacterDataHandler(XML_Parser, XML_CharacterDataHandler);
+PHPAPI void XML_SetProcessingInstructionHandler(XML_Parser, XML_ProcessingInstructionHandler);
+PHPAPI void XML_SetDefaultHandler(XML_Parser, XML_DefaultHandler);
+PHPAPI void XML_SetUnparsedEntityDeclHandler(XML_Parser, XML_UnparsedEntityDeclHandler);
+PHPAPI void XML_SetNotationDeclHandler(XML_Parser, XML_NotationDeclHandler);
+PHPAPI void XML_SetExternalEntityRefHandler(XML_Parser, XML_ExternalEntityRefHandler);
+PHPAPI void XML_SetStartNamespaceDeclHandler(XML_Parser, XML_StartNamespaceDeclHandler);
+PHPAPI void XML_SetEndNamespaceDeclHandler(XML_Parser, XML_EndNamespaceDeclHandler);
+PHPAPI int XML_Parse(XML_Parser, const XML_Char *, int data_len, int is_final);
+PHPAPI int XML_GetErrorCode(XML_Parser);
+PHPAPI const XML_Char *XML_ErrorString(int);
+PHPAPI int XML_GetCurrentLineNumber(XML_Parser);
+PHPAPI int XML_GetCurrentColumnNumber(XML_Parser);
+PHPAPI int XML_GetCurrentByteIndex(XML_Parser);
+PHPAPI int XML_GetCurrentByteCount(XML_Parser);
+PHPAPI const XML_Char *XML_ExpatVersion(void);
+PHPAPI void XML_ParserFree(XML_Parser);
+
+#elif defined(HAVE_LIBEXPAT)
+#include <expat.h>
+#endif /* HAVE_LIBEXPAT */
+
+#endif /* PHP_EXPAT_COMPAT_H */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */
diff --git a/ext/xml/package.xml b/ext/xml/package.xml
new file mode 100644
index 0000000..ae5e645
--- /dev/null
+++ b/ext/xml/package.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE package SYSTEM "../pear/package.dtd">
+<package>
+ <name>xml</name>
+ <summary>XML Parsing functions</summary>
+ <maintainers>
+ <maintainer>
+ <user>ssb</user>
+ <name>Stig Bakken</name>
+ <email>ssb@php.net</email>
+ <role>lead</role>
+ </maintainer>
+ <maintainer>
+ <user>thies</user>
+ <name>Thies Arntzen</name>
+ <email>thies@php.net</email>
+ <role>lead</role>
+ </maintainer>
+ <maintainer>
+ <user>sterling</user>
+ <name>Sterling Hughes</name>
+ <email>sterling@php.net</email>
+ <role>lead</role>
+ </maintainer>
+ </maintainers>
+ <description>
+This extension lets you create XML parsers and then define
+handlers for different XML events. Each XML parser also has
+a few parameters you can adjust.
+ </description>
+ <license>PHP</license>
+ <release>
+ <state>beta</state>
+ <version>5.0rc1</version>
+ <date>2004-03-19</date>
+ <notes>
+package.xml added to support installation using pear installer
+ </notes>
+ <configureoptions>
+ <configureoption name="with-curl" default="autodetect" prompt="path to curl installation?"/>
+ </configureoptions>
+ <filelist>
+ <file role="doc" name="CREDITS"/>
+ <file role="src" name="config.m4"/>
+ <file role="src" name="config.mw32"/>
+ <file role="src" name="xml.mak"/>
+ <file role="src" name="compat.c"/>
+ <file role="src" name="expat_compat.h"/>
+ <file role="src" name="php_xml.h"/>
+ <file role="src" name="xml.c"/>
+ <file role="test" name="tests/.cvsignore"/>
+ <file role="test" name="tests/inc.ent"/>
+ <file role="test" name="tests/skipif.inc"/>
+ <file role="test" name="tests/xml001.phpt"/>
+ <file role="test" name="tests/xml002.phpt"/>
+ <file role="test" name="tests/xml003.phpt"/>
+ <file role="test" name="tests/xml004.phpt"/>
+ <file role="test" name="tests/xml006.phpt"/>
+ <file role="test" name="tests/xml007.phpt"/>
+ <file role="test" name="tests/xmltest.xml"/>
+ <file role="test" name="tests/bug25666.phpt"/>
+ <file role="test" name="tests/bug26528.phpt"/>
+ <file role="test" name="tests/bug26614.phpt"/>
+ <file role="test" name="tests/xml009.phpt"/>
+ <file role="test" name="tests/xml010.phpt"/>
+ </filelist>
+ <deps>
+ <dep type="php" rel="ge" version="5" />
+ </deps>
+ </release>
+</package>
+<!--
+vim:et:ts=1:sw=1
+-->
diff --git a/ext/xml/php_xml.h b/ext/xml/php_xml.h
new file mode 100644
index 0000000..7766834
--- /dev/null
+++ b/ext/xml/php_xml.h
@@ -0,0 +1,157 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2013 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. |
+ +----------------------------------------------------------------------+
+ | Authors: Stig Sæther Bakken <ssb@php.net> |
+ | Thies C. Arntzen <thies@thieso.net> |
+ | Sterling Hughes <sterling@php.net> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifndef PHP_XML_H
+#define PHP_XML_H
+
+#ifdef HAVE_XML
+extern zend_module_entry xml_module_entry;
+#define xml_module_ptr &xml_module_entry
+#else
+#define xml_module_ptr NULL
+#endif
+
+#ifdef HAVE_XML
+
+#include "ext/xml/expat_compat.h"
+
+
+#ifdef XML_UNICODE
+#error "UTF-16 Unicode support not implemented!"
+#endif
+
+ZEND_BEGIN_MODULE_GLOBALS(xml)
+ XML_Char *default_encoding;
+ZEND_END_MODULE_GLOBALS(xml)
+
+typedef struct {
+ int index;
+ int case_folding;
+ XML_Parser parser;
+ XML_Char *target_encoding;
+
+ zval *startElementHandler;
+ zval *endElementHandler;
+ zval *characterDataHandler;
+ zval *processingInstructionHandler;
+ zval *defaultHandler;
+ zval *unparsedEntityDeclHandler;
+ zval *notationDeclHandler;
+ zval *externalEntityRefHandler;
+ zval *unknownEncodingHandler;
+ zval *startNamespaceDeclHandler;
+ zval *endNamespaceDeclHandler;
+
+ zend_function *startElementPtr;
+ zend_function *endElementPtr;
+ zend_function *characterDataPtr;
+ zend_function *processingInstructionPtr;
+ zend_function *defaultPtr;
+ zend_function *unparsedEntityDeclPtr;
+ zend_function *notationDeclPtr;
+ zend_function *externalEntityRefPtr;
+ zend_function *unknownEncodingPtr;
+ zend_function *startNamespaceDeclPtr;
+ zend_function *endNamespaceDeclPtr;
+
+ zval *object;
+
+ zval *data;
+ zval *info;
+ int level;
+ int toffset;
+ int curtag;
+ zval **ctag;
+ char **ltags;
+ int lastwasopen;
+ int skipwhite;
+ int isparsing;
+
+ XML_Char *baseURI;
+} xml_parser;
+
+
+typedef struct {
+ XML_Char *name;
+ char (*decoding_function)(unsigned short);
+ unsigned short (*encoding_function)(unsigned char);
+} xml_encoding;
+
+
+enum php_xml_option {
+ PHP_XML_OPTION_CASE_FOLDING = 1,
+ PHP_XML_OPTION_TARGET_ENCODING,
+ PHP_XML_OPTION_SKIP_TAGSTART,
+ PHP_XML_OPTION_SKIP_WHITE
+};
+
+/* for xml_parse_into_struct */
+
+#define XML_MAXLEVEL 255 /* XXX this should be dynamic */
+
+PHP_FUNCTION(xml_parser_create);
+PHP_FUNCTION(xml_parser_create_ns);
+PHP_FUNCTION(xml_set_object);
+PHP_FUNCTION(xml_set_element_handler);
+PHP_FUNCTION(xml_set_character_data_handler);
+PHP_FUNCTION(xml_set_processing_instruction_handler);
+PHP_FUNCTION(xml_set_default_handler);
+PHP_FUNCTION(xml_set_unparsed_entity_decl_handler);
+PHP_FUNCTION(xml_set_notation_decl_handler);
+PHP_FUNCTION(xml_set_external_entity_ref_handler);
+PHP_FUNCTION(xml_set_start_namespace_decl_handler);
+PHP_FUNCTION(xml_set_end_namespace_decl_handler);
+PHP_FUNCTION(xml_parse);
+PHP_FUNCTION(xml_get_error_code);
+PHP_FUNCTION(xml_error_string);
+PHP_FUNCTION(xml_get_current_line_number);
+PHP_FUNCTION(xml_get_current_column_number);
+PHP_FUNCTION(xml_get_current_byte_index);
+PHP_FUNCTION(xml_parser_free);
+PHP_FUNCTION(xml_parser_set_option);
+PHP_FUNCTION(xml_parser_get_option);
+PHP_FUNCTION(utf8_encode);
+PHP_FUNCTION(utf8_decode);
+PHP_FUNCTION(xml_parse_into_struct);
+
+PHPAPI char *_xml_zval_strdup(zval *val);
+PHPAPI char *xml_utf8_decode(const XML_Char *, int, int *, const XML_Char *);
+PHPAPI char *xml_utf8_encode(const char *s, int len, int *newlen, const XML_Char *encoding);
+
+#endif /* HAVE_LIBEXPAT */
+
+#define phpext_xml_ptr xml_module_ptr
+
+#ifdef ZTS
+#define XML(v) TSRMG(xml_globals_id, zend_xml_globals *, v)
+#else
+#define XML(v) (xml_globals.v)
+#endif
+
+#endif /* PHP_XML_H */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */
diff --git a/ext/xml/tests/bug25666.phpt b/ext/xml/tests/bug25666.phpt
new file mode 100644
index 0000000..e162d5a
--- /dev/null
+++ b/ext/xml/tests/bug25666.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Bug #25666 (XML namespaces broken in libxml-based SAX interface)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this platform");}
+?>
+--FILE--
+<?php
+function start_elem($parser,$name,$attribs) {
+ var_dump($name);
+}
+function end_elem()
+{
+}
+
+$xml = <<<HERE
+<foo:a xmlns:foo="http://example.com/foo"
+ xmlns:bar="http://example.com/bar"
+ xmlns:baz="http://example.com/baz">
+ <bar:b />
+ <baz:c />
+</foo>
+HERE;
+
+$parser = xml_parser_create_ns("ISO-8859-1","@");
+xml_set_element_handler($parser,'start_elem','end_elem');
+xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+xml_parse($parser, $xml);
+xml_parser_free($parser);
+?>
+--EXPECT--
+string(24) "http://example.com/foo@a"
+string(24) "http://example.com/bar@b"
+string(24) "http://example.com/baz@c"
diff --git a/ext/xml/tests/bug26528.phpt b/ext/xml/tests/bug26528.phpt
new file mode 100644
index 0000000..40a1c53
--- /dev/null
+++ b/ext/xml/tests/bug26528.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #26528 (HTML entities are not being decoded)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+?>
+--FILE--
+<?php
+ $sample = "<?xml version=\"1.0\"?><test attr=\"angle&lt;bracket\"/>";
+ $parser = xml_parser_create();
+ $res = xml_parse_into_struct($parser,$sample,$vals,$index);
+ xml_parser_free($parser);
+ var_dump($vals);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ array(4) {
+ ["tag"]=>
+ string(4) "TEST"
+ ["type"]=>
+ string(8) "complete"
+ ["level"]=>
+ int(1)
+ ["attributes"]=>
+ array(1) {
+ ["ATTR"]=>
+ string(13) "angle<bracket"
+ }
+ }
+}
diff --git a/ext/xml/tests/bug26614.phpt b/ext/xml/tests/bug26614.phpt
new file mode 100644
index 0000000..e1df1bb
--- /dev/null
+++ b/ext/xml/tests/bug26614.phpt
@@ -0,0 +1,93 @@
+--TEST--
+Bug #26614 (CDATA sections skipped on line count)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+if (defined("LIBXML_VERSION")) die('skip expat test');
+?>
+--FILE--
+<?php
+/*
+this test works fine with Expat but fails with libxml
+which we now use as default
+
+further investigation has shown that not only line count
+is skippet on CDATA sections but that libxml does also
+show different column numbers and byte positions depending
+on context and in opposition to what one would expect to
+see and what good old Expat reported just fine ...
+*/
+
+$xmls = array();
+
+// Case 1: CDATA Sections
+$xmls["CDATA"] ='<?xml version="1.0" encoding="iso-8859-1" ?>
+<data>
+<![CDATA[
+multi
+line
+CDATA
+block
+]]>
+</data>';
+
+// Case 2: replace some characters so that we get comments instead
+$xmls["Comment"] ='<?xml version="1.0" encoding="iso-8859-1" ?>
+<data>
+<!-- ATA[
+multi
+line
+CDATA
+block
+-->
+</data>';
+
+// Case 3: replace even more characters so that only textual data is left
+$xmls["Text"] ='<?xml version="1.0" encoding="iso-8859-1" ?>
+<data>
+-!-- ATA[
+multi
+line
+CDATA
+block
+---
+</data>';
+
+function startElement($parser, $name, $attrs) {
+ printf("<$name> at line %d, col %d (byte %d)\n",
+ xml_get_current_line_number($parser),
+ xml_get_current_column_number($parser),
+ xml_get_current_byte_index($parser));
+}
+
+function endElement($parser, $name) {
+ printf("</$name> at line %d, col %d (byte %d)\n",
+ xml_get_current_line_number($parser),
+ xml_get_current_column_number($parser),
+ xml_get_current_byte_index($parser));
+}
+
+function characterData($parser, $data) {
+ // dummy
+}
+
+foreach ($xmls as $desc => $xml) {
+ echo "$desc\n";
+ $xml_parser = xml_parser_create();
+ xml_set_element_handler($xml_parser, "startElement", "endElement");
+ xml_set_character_data_handler($xml_parser, "characterData");
+ if (!xml_parse($xml_parser, $xml, true))
+ echo "Error: ".xml_error_string(xml_get_error_code($xml_parser))."\n";
+ xml_parser_free($xml_parser);
+}
+?>
+--EXPECT--
+CDATA
+<DATA> at line 2, col 0 (byte 45)
+</DATA> at line 9, col 0 (byte 90)
+Comment
+<DATA> at line 2, col 0 (byte 45)
+</DATA> at line 9, col 0 (byte 90)
+Text
+<DATA> at line 2, col 0 (byte 45)
+</DATA> at line 9, col 0 (byte 90)
diff --git a/ext/xml/tests/bug26614_libxml.phpt b/ext/xml/tests/bug26614_libxml.phpt
new file mode 100644
index 0000000..782bdb1
--- /dev/null
+++ b/ext/xml/tests/bug26614_libxml.phpt
@@ -0,0 +1,93 @@
+--TEST--
+Bug #26614 (CDATA sections skipped on line count)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+if (!defined("LIBXML_VERSION")) die('skip libxml2 test');
+?>
+--FILE--
+<?php
+/*
+this test works fine with Expat but fails with libxml
+which we now use as default
+
+further investigation has shown that not only line count
+is skippet on CDATA sections but that libxml does also
+show different column numbers and byte positions depending
+on context and in opposition to what one would expect to
+see and what good old Expat reported just fine ...
+*/
+
+$xmls = array();
+
+// Case 1: CDATA Sections
+$xmls["CDATA"] ='<?xml version="1.0" encoding="iso-8859-1" ?>
+<data>
+<![CDATA[
+multi
+line
+CDATA
+block
+]]>
+</data>';
+
+// Case 2: replace some characters so that we get comments instead
+$xmls["Comment"] ='<?xml version="1.0" encoding="iso-8859-1" ?>
+<data>
+<!-- ATA[
+multi
+line
+CDATA
+block
+-->
+</data>';
+
+// Case 3: replace even more characters so that only textual data is left
+$xmls["Text"] ='<?xml version="1.0" encoding="iso-8859-1" ?>
+<data>
+-!-- ATA[
+multi
+line
+CDATA
+block
+---
+</data>';
+
+function startElement($parser, $name, $attrs) {
+ printf("<$name> at line %d, col %d (byte %d)\n",
+ xml_get_current_line_number($parser),
+ xml_get_current_column_number($parser),
+ xml_get_current_byte_index($parser));
+}
+
+function endElement($parser, $name) {
+ printf("</$name> at line %d, col %d (byte %d)\n",
+ xml_get_current_line_number($parser),
+ xml_get_current_column_number($parser),
+ xml_get_current_byte_index($parser));
+}
+
+function characterData($parser, $data) {
+ // dummy
+}
+
+foreach ($xmls as $desc => $xml) {
+ echo "$desc\n";
+ $xml_parser = xml_parser_create();
+ xml_set_element_handler($xml_parser, "startElement", "endElement");
+ xml_set_character_data_handler($xml_parser, "characterData");
+ if (!xml_parse($xml_parser, $xml, true))
+ echo "Error: ".xml_error_string(xml_get_error_code($xml_parser))."\n";
+ xml_parser_free($xml_parser);
+}
+?>
+--EXPECTF--
+CDATA
+<DATA> at line 2, col %d (byte 9)
+</DATA> at line 9, col %d (byte 56)
+Comment
+<DATA> at line 2, col %d (byte 9)
+</DATA> at line 9, col %d (byte 56)
+Text
+<DATA> at line 2, col %d (byte 9)
+</DATA> at line 9, col %d (byte 56)
diff --git a/ext/xml/tests/bug27908.phpt b/ext/xml/tests/bug27908.phpt
new file mode 100644
index 0000000..e60466f
--- /dev/null
+++ b/ext/xml/tests/bug27908.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #27908 (default handler not being called)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+?>
+--FILE--
+<?php
+
+function x_default_handler($xp,$data)
+{
+ echo "x_default_handler $data\n";
+}
+$xp = xml_parser_create();
+xml_set_default_handler($xp,'x_default_handler');
+xml_parse($xp, '<root></root>',TRUE);
+xml_parser_free($xp);
+echo "Done\n";
+?>
+--EXPECT--
+x_default_handler <root>
+x_default_handler </root>
+Done
diff --git a/ext/xml/tests/bug30266.phpt b/ext/xml/tests/bug30266.phpt
new file mode 100644
index 0000000..0a3a5ca
--- /dev/null
+++ b/ext/xml/tests/bug30266.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Bug #30266 (Invalid opcode 137/1/8)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+?>
+--FILE--
+<?php
+/*
+
+Currently (Feb 10, 2005) CVS HEAD fails with the following message:
+
+Fatal error: Invalid opcode 137/1/8. in /home/hartmut/projects/php/dev/head/ext/xml/tests/bug30266.php on line 22
+
+*/
+class XML_Parser
+{
+ public $dummy = "a";
+
+ function parse($data)
+ {
+ $parser = xml_parser_create();
+
+ xml_set_object($parser, $this);
+
+ xml_set_element_handler($parser, 'startHandler', 'endHandler');
+
+ xml_parse($parser, $data, true);
+
+ xml_parser_free($parser);
+ }
+
+ function startHandler($XmlParser, $tag, $attr)
+ {
+ $this->dummy = "b";
+ throw new Exception("ex");
+ }
+
+ function endHandler($XmlParser, $tag)
+ {
+ }
+}
+
+$p1 = new Xml_Parser();
+try {
+ $p1->parse('<tag1><tag2></tag2></tag1>');
+} catch (Exception $e) {
+ echo "OK\n";
+}
+?>
+--EXPECT--
+OK
diff --git a/ext/xml/tests/bug32001.phpt b/ext/xml/tests/bug32001.phpt
new file mode 100644
index 0000000..0853b3a
--- /dev/null
+++ b/ext/xml/tests/bug32001.phpt
@@ -0,0 +1,406 @@
+--TEST--
+Bug #32001 (xml_parse*() goes into infinite loop when autodetection in effect), using UTF-*
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+if (!extension_loaded('iconv')) die ("skip iconv extension not available");
+?>
+--FILE--
+<?php
+class testcase {
+ private $encoding;
+ private $bom;
+ private $prologue;
+ private $tags;
+ private $chunk_size;
+
+ function testcase($enc, $chunk_size = 0, $bom = 0, $omit_prologue = 0) {
+ $this->encoding = $enc;
+ $this->chunk_size = $chunk_size;
+ $this->bom = $bom;
+ $this->prologue = !$omit_prologue;
+ $this->tags = array();
+ }
+
+ function start_element($parser, $name, $attrs) {
+ $attrs = array_map('bin2hex', $attrs);
+ $this->tags[] = bin2hex($name).": ".implode(', ', $attrs);
+ }
+
+ function end_element($parser, $name) {
+ }
+
+ function run() {
+ $data = '';
+
+ if ($this->prologue) {
+ $canonical_name = preg_replace('/BE|LE/i', '', $this->encoding);
+ $data .= "<?xml version=\"1.0\" encoding=\"$canonical_name\" ?>\n";
+ }
+
+ $data .= <<<HERE
+<テスト:テスト1 xmlns:テスト="http://www.example.com/テスト/" テスト="テスト">
+ <テスト:テスト2 テスト="テスト">
+ <テスト:テスト3>
+ test!
+ </テスト:テスト3>
+ </テスト:テスト2>
+</テスト:テスト1>
+HERE;
+
+ $data = iconv("UTF-8", $this->encoding, $data);
+
+ if ($this->bom) {
+ switch (strtoupper($this->encoding)) {
+ case 'UTF-8':
+ case 'UTF8':
+ $data = "\xef\xbb\xbf".$data;
+ break;
+
+ case 'UTF-16':
+ case 'UTF16':
+ case 'UTF-16BE':
+ case 'UTF16BE':
+ case 'UCS-2':
+ case 'UCS2':
+ case 'UCS-2BE':
+ case 'UCS2BE':
+ $data = "\xfe\xff".$data;
+ break;
+
+ case 'UTF-16LE':
+ case 'UTF16LE':
+ case 'UCS-2LE':
+ case 'UCS2LE':
+ $data = "\xff\xfe".$data;
+ break;
+
+ case 'UTF-32':
+ case 'UTF32':
+ case 'UTF-32BE':
+ case 'UTF32BE':
+ case 'UCS-4':
+ case 'UCS4':
+ case 'UCS-4BE':
+ case 'UCS4BE':
+ $data = "\x00\x00\xfe\xff".$data;
+ break;
+
+ case 'UTF-32LE':
+ case 'UTF32LE':
+ case 'UCS-4LE':
+ case 'UCS4LE':
+ $data = "\xff\xfe\x00\x00".$data;
+ break;
+ }
+ }
+
+ $parser = xml_parser_create(NULL);
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
+ xml_set_element_handler($parser, "start_element", "end_element");
+ xml_set_object($parser, $this);
+
+ if ($this->chunk_size == 0) {
+ $success = @xml_parse($parser, $data, true);
+ } else {
+ for ($offset = 0; $offset < strlen($data);
+ $offset += $this->chunk_size) {
+ $success = @xml_parse($parser, substr($data, $offset, $this->chunk_size), false);
+ if (!$success) {
+ break;
+ }
+ }
+ if ($success) {
+ $success = @xml_parse($parser, "", true);
+ }
+ }
+
+ echo "Encoding: $this->encoding\n";
+ echo "XML Prologue: ".($this->prologue ? 'present': 'not present'), "\n";
+ echo "Chunk size: ".($this->chunk_size ? "$this->chunk_size byte(s)\n": "all data at once\n");
+ echo "BOM: ".($this->bom ? 'prepended': 'not prepended'), "\n";
+
+ if ($success) {
+ var_dump($this->tags);
+ } else {
+ echo "[Error] ", xml_error_string(xml_get_error_code($parser)), "\n";
+ }
+ }
+}
+$suite = array(
+ new testcase("UTF-8", 0, 0, 0),
+ new testcase("UTF-8", 0, 0, 1),
+ new testcase("UTF-8", 0, 1, 0),
+ new testcase("UTF-8", 0, 1, 1),
+ new testcase("UTF-16BE", 0, 0, 0),
+ new testcase("UTF-16BE", 0, 1, 0),
+ new testcase("UTF-16BE", 0, 1, 1),
+ new testcase("UTF-16LE", 0, 0, 0),
+ new testcase("UTF-16LE", 0, 1, 0),
+ new testcase("UTF-16LE", 0, 1, 1),
+ new testcase("UTF-8", 1, 0, 0),
+ new testcase("UTF-8", 1, 0, 1),
+ new testcase("UTF-8", 1, 1, 0),
+ new testcase("UTF-8", 1, 1, 1),
+ new testcase("UTF-16BE", 1, 0, 0),
+ new testcase("UTF-16BE", 1, 1, 0),
+ new testcase("UTF-16BE", 1, 1, 1),
+ new testcase("UTF-16LE", 1, 0, 0),
+ new testcase("UTF-16LE", 1, 1, 0),
+ new testcase("UTF-16LE", 1, 1, 1),
+);
+
+if (XML_SAX_IMPL == 'libxml') {
+ echo "libxml2 Version => " . LIBXML_DOTTED_VERSION. "\n";
+} else {
+ echo "libxml2 Version => NONE\n";
+}
+
+foreach ($suite as $testcase) {
+ $testcase->run();
+}
+
+// vim600: sts=4 sw=4 ts=4 encoding=UTF-8
+?>
+--EXPECTF--
+libxml2 Version => %s
+Encoding: UTF-8
+XML Prologue: present
+Chunk size: all data at once
+BOM: not prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-8
+XML Prologue: not present
+Chunk size: all data at once
+BOM: not prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-8
+XML Prologue: present
+Chunk size: all data at once
+BOM: prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-8
+XML Prologue: not present
+Chunk size: all data at once
+BOM: prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-16BE
+XML Prologue: present
+Chunk size: all data at once
+BOM: not prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-16BE
+XML Prologue: present
+Chunk size: all data at once
+BOM: prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-16BE
+XML Prologue: not present
+Chunk size: all data at once
+BOM: prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-16LE
+XML Prologue: present
+Chunk size: all data at once
+BOM: not prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-16LE
+XML Prologue: present
+Chunk size: all data at once
+BOM: prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-16LE
+XML Prologue: not present
+Chunk size: all data at once
+BOM: prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-8
+XML Prologue: present
+Chunk size: 1 byte(s)
+BOM: not prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-8
+XML Prologue: not present
+Chunk size: 1 byte(s)
+BOM: not prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-8
+XML Prologue: present
+Chunk size: 1 byte(s)
+BOM: prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-8
+XML Prologue: not present
+Chunk size: 1 byte(s)
+BOM: prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-16BE
+XML Prologue: present
+Chunk size: 1 byte(s)
+BOM: not prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-16BE
+XML Prologue: present
+Chunk size: 1 byte(s)
+BOM: prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-16BE
+XML Prologue: not present
+Chunk size: 1 byte(s)
+BOM: prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-16LE
+XML Prologue: present
+Chunk size: 1 byte(s)
+BOM: not prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-16LE
+XML Prologue: present
+Chunk size: 1 byte(s)
+BOM: prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: UTF-16LE
+XML Prologue: not present
+Chunk size: 1 byte(s)
+BOM: prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
diff --git a/ext/xml/tests/bug32001b.phpt b/ext/xml/tests/bug32001b.phpt
new file mode 100644
index 0000000..ddf26ce
--- /dev/null
+++ b/ext/xml/tests/bug32001b.phpt
@@ -0,0 +1,182 @@
+--TEST--
+Bug #32001 (xml_parse*() goes into infinite loop when autodetection in effect), using EUC-JP, Shift_JIS, GB2312
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+if (!extension_loaded('iconv')) die ("skip iconv extension not available");
+foreach(array('EUC-JP', 'Shift_JISP', 'GB2312') as $encoding) {
+ if (@xml_parser_create($encoding) === false) die("skip libxml2 does not support $encoding encoding");
+}
+?>
+--FILE--
+<?php
+class testcase {
+ private $encoding;
+ private $bom;
+ private $prologue;
+ private $tags;
+ private $chunk_size;
+
+ function testcase($enc, $chunk_size = 0, $bom = 0, $omit_prologue = 0) {
+ $this->encoding = $enc;
+ $this->chunk_size = $chunk_size;
+ $this->bom = $bom;
+ $this->prologue = !$omit_prologue;
+ $this->tags = array();
+ }
+
+ function start_element($parser, $name, $attrs) {
+ $attrs = array_map('bin2hex', $attrs);
+ $this->tags[] = bin2hex($name).": ".implode(', ', $attrs);
+ }
+
+ function end_element($parser, $name) {
+ }
+
+ function run() {
+ $data = '';
+
+ if ($this->prologue) {
+ $canonical_name = preg_replace('/BE|LE/i', '', $this->encoding);
+ $data .= "<?xml version=\"1.0\" encoding=\"$canonical_name\" ?>\n";
+ }
+
+ $data .= <<<HERE
+<テスト:テスト1 xmlns:テスト="http://www.example.com/テスト/" テスト="テスト">
+ <テスト:テスト2 テスト="テスト">
+ <テスト:テスト3>
+ test!
+ </テスト:テスト3>
+ </テスト:テスト2>
+</テスト:テスト1>
+HERE;
+
+ $data = iconv("UTF-8", $this->encoding, $data);
+
+ $parser = xml_parser_create(NULL);
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
+ xml_set_element_handler($parser, "start_element", "end_element");
+ xml_set_object($parser, $this);
+
+ if ($this->chunk_size == 0) {
+ $success = @xml_parse($parser, $data, true);
+ } else {
+ for ($offset = 0; $offset < strlen($data);
+ $offset += $this->chunk_size) {
+ $success = @xml_parse($parser, substr($data, $offset, $this->chunk_size), false);
+ if (!$success) {
+ break;
+ }
+ }
+ if ($success) {
+ $success = @xml_parse($parser, "", true);
+ }
+ }
+
+ echo "Encoding: $this->encoding\n";
+ echo "XML Prologue: ".($this->prologue ? 'present': 'not present'), "\n";
+ echo "Chunk size: ".($this->chunk_size ? "$this->chunk_size byte(s)\n": "all data at once\n");
+ echo "BOM: ".($this->bom ? 'prepended': 'not prepended'), "\n";
+
+ if ($success) {
+ var_dump($this->tags);
+ } else {
+ echo "[Error] ", xml_error_string(xml_get_error_code($parser)), "\n";
+ }
+ }
+}
+$suite = array(
+ new testcase("EUC-JP" , 0),
+ new testcase("EUC-JP" , 1),
+ new testcase("Shift_JIS", 0),
+ new testcase("Shift_JIS", 1),
+ new testcase("GB2312", 0),
+ new testcase("GB2312", 1),
+);
+
+if (XML_SAX_IMPL == 'libxml') {
+ echo "libxml2 Version => " . LIBXML_DOTTED_VERSION. "\n";
+} else {
+ echo "libxml2 Version => NONE\n";
+}
+
+foreach ($suite as $testcase) {
+ $testcase->run();
+}
+
+// vim600: sts=4 sw=4 ts=4 encoding=UTF-8
+?>
+--EXPECTF--
+libxml2 Version => %s
+Encoding: EUC-JP
+XML Prologue: present
+Chunk size: all data at once
+BOM: not prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: EUC-JP
+XML Prologue: present
+Chunk size: 1 byte(s)
+BOM: not prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: Shift_JIS
+XML Prologue: present
+Chunk size: all data at once
+BOM: not prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: Shift_JIS
+XML Prologue: present
+Chunk size: 1 byte(s)
+BOM: not prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: GB2312
+XML Prologue: present
+Chunk size: all data at once
+BOM: not prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
+Encoding: GB2312
+XML Prologue: present
+Chunk size: 1 byte(s)
+BOM: not prepended
+array(3) {
+ [0]=>
+ string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388"
+ [1]=>
+ string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388"
+ [2]=>
+ string(42) "e38386e382b9e383883ae38386e382b9e3838833: "
+}
diff --git a/ext/xml/tests/bug35447.phpt b/ext/xml/tests/bug35447.phpt
new file mode 100644
index 0000000..8cbb5e5
--- /dev/null
+++ b/ext/xml/tests/bug35447.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Bug #35447 (xml_parse_into_struct() chokes on the UTF-8 BOM)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this plattform");}
+?>
+--FILE--
+<?php
+$data = <<<END_OF_XML
+\xEF\xBB\xBF<?xml version="1.0" encoding="utf-8"?\x3e
+<!DOCTYPE bundle [
+ <!ELEMENT bundle (resource)+>
+ <!ELEMENT resource (#PCDATA)>
+ <!ATTLIST resource
+ key CDATA #REQUIRED
+ type (literal|pattern|sub) "literal"
+ >
+]>
+<resource key="rSeeYou">A bient&amp;244;t</resource>
+END_OF_XML;
+
+$parser = xml_parser_create_ns('UTF-8');
+xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+$result = xml_parse_into_struct($parser, $data, $vals, $index);
+xml_parser_free($parser);
+var_dump($vals);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ array(5) {
+ ["tag"]=>
+ string(8) "resource"
+ ["type"]=>
+ string(8) "complete"
+ ["level"]=>
+ int(1)
+ ["attributes"]=>
+ array(2) {
+ ["key"]=>
+ string(7) "rSeeYou"
+ ["type"]=>
+ string(7) "literal"
+ }
+ ["value"]=>
+ string(13) "A bient&244;t"
+ }
+}
diff --git a/ext/xml/tests/bug43957.phpt b/ext/xml/tests/bug43957.phpt
new file mode 100644
index 0000000..f11d156
--- /dev/null
+++ b/ext/xml/tests/bug43957.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #43957 (utf8_decode() bogus conversion on multibyte indicator near end of string)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+if (!extension_loaded('xml')) die ("skip xml extension not available");
+?>
+--FILE--
+<?php
+ echo utf8_decode('abc'.chr(0xe0));
+?>
+--EXPECTF--
+abc?
diff --git a/ext/xml/tests/bug46699.phpt b/ext/xml/tests/bug46699.phpt
new file mode 100644
index 0000000..3996fd1
--- /dev/null
+++ b/ext/xml/tests/bug46699.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Bug #46699: (xml_parse crash when parser is namespace aware)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this platform");}
+?>
+--FILE--
+<?php
+function defaultfunc($parser, $data)
+{
+echo $data;
+}
+
+$xml = <<<HERE
+<a xmlns="http://example.com/foo"
+ xmlns:bar="http://example.com/bar">
+ <bar:b foo="bar">1</bar:b>
+ <bar:c bar:nix="null" foo="bar">2</bar:c>
+</a>
+HERE;
+
+$parser = xml_parser_create_ns("ISO-8859-1","@");
+xml_set_default_handler($parser,'defaultfunc');
+xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+xml_parse($parser, $xml);
+xml_parser_free($parser);
+?>
+--EXPECT--
+<a xmlns="http://example.com/foo" xmlns:bar="http://example.com/bar">
+ <bar:b foo="bar">1</bar:b>
+ <bar:c bar:nix="null" foo="bar">2</bar:c>
+</a>
diff --git a/ext/xml/tests/bug49687.phpt b/ext/xml/tests/bug49687.phpt
new file mode 100644
index 0000000..3ff19ce
--- /dev/null
+++ b/ext/xml/tests/bug49687.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #49687 Several utf8_decode deficiencies and vulnerabilities
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+if (!extension_loaded('xml')) die ("skip xml extension not available");
+?>
+--FILE--
+<?php
+
+$tests = array(
+ "\x41\xC2\x3E\x42",
+ "\xE3\x80\x22",
+ "\x41\x98\xBA\x42\xE2\x98\x43\xE2\x98\xBA\xE2\x98",
+);
+foreach ($tests as $t) {
+ echo bin2hex(utf8_decode($t)), "\n";
+}
+echo "Done.\n";
+--EXPECT--
+413f3e42
+3f22
+413f3f423f433f3f
+Done.
diff --git a/ext/xml/tests/bug50576.phpt b/ext/xml/tests/bug50576.phpt
new file mode 100644
index 0000000..fd3d0cb
--- /dev/null
+++ b/ext/xml/tests/bug50576.phpt
@@ -0,0 +1,133 @@
+--TEST--
+Bug #50576 (XML_OPTION_SKIP_TAGSTART option has no effect)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+?>
+--FILE--
+<?php
+
+$XML = <<<XML
+<?xml version="1.0"?>
+<ns1:listOfAwards xmlns:ns1="http://www.fpdsng.com/FPDS">
+<ns1:count>
+<ns1:total>867</ns1:total>
+</ns1:count>
+</ns1:listOfAwards>
+XML;
+
+$xml_parser = xml_parser_create();
+xml_parser_set_option($xml_parser, XML_OPTION_SKIP_TAGSTART, 4);
+xml_parse_into_struct($xml_parser, $XML, $vals, $index);
+echo 'Index array' . PHP_EOL;
+print_r($index);
+echo 'Vals array' . PHP_EOL;
+print_r($vals);
+xml_parser_free($xml_parser);
+
+function startElement($parser, $name, $attribs) { echo $name . PHP_EOL; }
+function endElement($parser, $name) { echo $name . PHP_EOL; }
+$xml_parser = xml_parser_create();
+xml_set_element_handler($xml_parser, 'startElement', 'endElement');
+xml_parser_set_option($xml_parser, XML_OPTION_SKIP_TAGSTART, 4);
+xml_parse($xml_parser, $XML);
+xml_parser_free($xml_parser);
+
+?>
+--EXPECTF--
+Index array
+Array
+(
+ [LISTOFAWARDS] => Array
+ (
+ [0] => 0
+ [1] => 5
+ [2] => 6
+ )
+
+ [COUNT] => Array
+ (
+ [0] => 1
+ [1] => 3
+ [2] => 4
+ )
+
+ [TOTAL] => Array
+ (
+ [0] => 2
+ )
+
+)
+Vals array
+Array
+(
+ [0] => Array
+ (
+ [tag] => LISTOFAWARDS
+ [type] => open
+ [level] => 1
+ [attributes] => Array
+ (
+ [XMLNS:NS1] => http://www.fpdsng.com/FPDS
+ )
+
+ [value] =>
+
+ )
+
+ [1] => Array
+ (
+ [tag] => COUNT
+ [type] => open
+ [level] => 2
+ [value] =>
+
+ )
+
+ [2] => Array
+ (
+ [tag] => TOTAL
+ [type] => complete
+ [level] => 3
+ [value] => 867
+ )
+
+ [3] => Array
+ (
+ [tag] => COUNT
+ [value] =>
+
+ [type] => cdata
+ [level] => 2
+ )
+
+ [4] => Array
+ (
+ [tag] => COUNT
+ [type] => close
+ [level] => 2
+ )
+
+ [5] => Array
+ (
+ [tag] => LISTOFAWARDS
+ [value] =>
+
+ [type] => cdata
+ [level] => 1
+ )
+
+ [6] => Array
+ (
+ [tag] => LISTOFAWARDS
+ [type] => close
+ [level] => 1
+ )
+
+)
+LISTOFAWARDS
+COUNT
+TOTAL
+TOTAL
+COUNT
+LISTOFAWARDS
diff --git a/ext/xml/tests/bug62328.phpt b/ext/xml/tests/bug62328.phpt
new file mode 100644
index 0000000..e4c3c59
--- /dev/null
+++ b/ext/xml/tests/bug62328.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #62328 (implementing __toString and a cast to string fails)
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+?>
+--FILE--
+<?php
+class UberSimpleXML extends SimpleXMLElement {
+ public function __toString() {
+ return 'stringification';
+ }
+}
+
+$xml = new UberSimpleXML('<xml/>');
+
+var_dump((string) $xml);
+var_dump($xml->__toString());
+--EXPECT--
+string(15) "stringification"
+string(15) "stringification"
diff --git a/ext/xml/tests/inc.ent b/ext/xml/tests/inc.ent
new file mode 100644
index 0000000..8f86465
--- /dev/null
+++ b/ext/xml/tests/inc.ent
@@ -0,0 +1 @@
+<!ENTITY included-entity "This is text included from an entity">
diff --git a/ext/xml/tests/skipif.inc b/ext/xml/tests/skipif.inc
new file mode 100644
index 0000000..44898f3
--- /dev/null
+++ b/ext/xml/tests/skipif.inc
@@ -0,0 +1,10 @@
+<?php
+// DO NOT dl load extension
+//if (!extension_loaded("xml")) {
+// $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so";
+// @dl("xml$dlext");
+//}
+if (!extension_loaded("xml")) {
+ die('skip xml extension not available');
+}
+?>
diff --git a/ext/xml/tests/utf8_decode_error.phpt b/ext/xml/tests/utf8_decode_error.phpt
new file mode 100644
index 0000000..8735fd8
--- /dev/null
+++ b/ext/xml/tests/utf8_decode_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test utf8_decode() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto string utf8_decode(string data)
+ * Description: Converts a UTF-8 encoded string to ISO-8859-1
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing utf8_decode() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing utf8_decode() function with Zero arguments --\n";
+var_dump( utf8_decode() );
+
+//Test utf8_decode with one more than the expected number of arguments
+echo "\n-- Testing utf8_decode() function with more than expected no. of arguments --\n";
+$data = 'string_val';
+$extra_arg = 10;
+var_dump( utf8_decode($data, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing utf8_decode() : error conditions ***
+
+-- Testing utf8_decode() function with Zero arguments --
+
+Warning: utf8_decode() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing utf8_decode() function with more than expected no. of arguments --
+
+Warning: utf8_decode() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/utf8_decode_variation1.phpt b/ext/xml/tests/utf8_decode_variation1.phpt
new file mode 100644
index 0000000..4b9679a
--- /dev/null
+++ b/ext/xml/tests/utf8_decode_variation1.phpt
@@ -0,0 +1,176 @@
+--TEST--
+Test utf8_decode() function : usage variations - different types for data
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto string utf8_decode(string data)
+ * Description: Converts a UTF-8 encoded string to ISO-8859-1
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing utf8_decode() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new aClass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for data
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( utf8_decode($value) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing utf8_decode() : usage variations ***
+
+Arg value 0
+string(1) "0"
+
+Arg value 1
+string(1) "1"
+
+Arg value 12345
+string(5) "12345"
+
+Arg value -2345
+string(5) "-2345"
+
+Arg value 10.5
+string(4) "10.5"
+
+Arg value -10.5
+string(5) "-10.5"
+
+Arg value 101234567000
+string(12) "101234567000"
+
+Arg value 1.07654321E-9
+string(13) "1.07654321E-9"
+
+Arg value 0.5
+string(3) "0.5"
+
+Arg value Array
+
+Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+
+Arg value 1
+string(1) "1"
+
+Arg value
+string(0) ""
+
+Arg value 1
+string(1) "1"
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+
+Arg value Some Ascii Data
+string(15) "Some Ascii Data"
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+Done
+
diff --git a/ext/xml/tests/utf8_encode_error.phpt b/ext/xml/tests/utf8_encode_error.phpt
new file mode 100644
index 0000000..a82f98f
--- /dev/null
+++ b/ext/xml/tests/utf8_encode_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test utf8_encode() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto string utf8_encode(string data)
+ * Description: Encodes an ISO-8859-1 string to UTF-8
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing utf8_encode() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing utf8_encode() function with Zero arguments --\n";
+var_dump( utf8_encode() );
+
+//Test utf8_encode with one more than the expected number of arguments
+echo "\n-- Testing utf8_encode() function with more than expected no. of arguments --\n";
+$data = 'string_val';
+$extra_arg = 10;
+var_dump( utf8_encode($data, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing utf8_encode() : error conditions ***
+
+-- Testing utf8_encode() function with Zero arguments --
+
+Warning: utf8_encode() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing utf8_encode() function with more than expected no. of arguments --
+
+Warning: utf8_encode() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/utf8_encode_variation1.phpt b/ext/xml/tests/utf8_encode_variation1.phpt
new file mode 100644
index 0000000..04b956c
--- /dev/null
+++ b/ext/xml/tests/utf8_encode_variation1.phpt
@@ -0,0 +1,176 @@
+--TEST--
+Test utf8_encode() function : usage variations - <type here specifics of this variation>
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto string utf8_encode(string data)
+ * Description: Encodes an ISO-8859-1 string to UTF-8
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing utf8_encode() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // object data
+ new aClass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for data
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( utf8_encode($value) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing utf8_encode() : usage variations ***
+
+Arg value 0
+string(1) "0"
+
+Arg value 1
+string(1) "1"
+
+Arg value 12345
+string(5) "12345"
+
+Arg value -2345
+string(5) "-2345"
+
+Arg value 10.5
+string(4) "10.5"
+
+Arg value -10.5
+string(5) "-10.5"
+
+Arg value 101234567000
+string(12) "101234567000"
+
+Arg value 1.07654321E-9
+string(13) "1.07654321E-9"
+
+Arg value 0.5
+string(3) "0.5"
+
+Arg value Array
+
+Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: utf8_encode() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+
+Arg value 1
+string(1) "1"
+
+Arg value
+string(0) ""
+
+Arg value 1
+string(1) "1"
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+
+Arg value Some Ascii Data
+string(15) "Some Ascii Data"
+
+Arg value
+string(0) ""
+
+Arg value
+string(0) ""
+Done
+
diff --git a/ext/xml/tests/xml001.phpt b/ext/xml/tests/xml001.phpt
new file mode 100644
index 0000000..9c03b55
--- /dev/null
+++ b/ext/xml/tests/xml001.phpt
@@ -0,0 +1,97 @@
+--TEST--
+XML parser test, function callbacks
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+XML_SAX_IMPL == 'libxml' && die('skip this test is not intended for libxml SAX parser');
+?>
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+
+$xml_parser = xml_parser_create();
+xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 1);
+xml_set_element_handler($xml_parser, "startElement", "endElement");
+xml_set_character_data_handler($xml_parser, "characterData");
+xml_set_processing_instruction_handler($xml_parser, "PIHandler");
+xml_set_default_handler($xml_parser, "defaultHandler");
+xml_set_external_entity_ref_handler($xml_parser, "externalEntityRefHandler");
+
+if (!($fp = @fopen("xmltest.xml", "r"))) {
+ die("could not open XML input");
+}
+
+while ($data = fread($fp, 4096)) {
+ if (!xml_parse($xml_parser, $data, feof($fp))) {
+ die(sprintf("XML error: %s at line %d\n",
+ xml_error_string(xml_get_error_code($xml_parser)),
+ xml_get_current_line_number($xml_parser)));
+ }
+}
+print "parse complete\n";
+xml_parser_free($xml_parser);
+
+function startElement($parser, $name, $attribs)
+{
+ print '{'.$name;
+ if (sizeof($attribs)) {
+ while (list($k, $v) = each($attribs)) {
+ print " $k=\"$v\"";
+ }
+ }
+ print '}';
+}
+
+function endElement($parser, $name)
+{
+ print '{/'.$name.'}';
+}
+
+function characterData($parser, $data)
+{
+ print '{CDATA['.$data.']}';
+}
+
+function PIHandler($parser, $target, $data)
+{
+ print '{PI['.$target.','.$data.']}';
+}
+
+function defaultHandler($parser, $data)
+{
+ if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") {
+ print '{ENTREF['.$data.']}';
+ } else {
+ print '{?['.$data.']}';
+ }
+}
+
+function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId)
+{
+ print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n";
+ return true;
+}
+
+?>
+--EXPECT--
+{?[<?xml version="1.0" encoding="ISO-8859-1"?>]}{?[
+]}{?[<!DOCTYPE]}{?[ ]}{?[phptest]}{?[ ]}{?[SYSTEM]}{?[ ]}{?["notfound.dtd"]}{?[ ]}{?[[]}{?[
+]}{?[<!ENTITY]}{?[ ]}{?[%]}{?[ ]}{?[incent]}{?[ ]}{?[SYSTEM]}{?[ ]}{?["inc.ent"]}{?[>]}{?[
+]}{?[%incent;]}{?[
+]}{?[]]}{?[>]}{?[
+]}{ROOT ID="elem1"}{CDATA[
+]}{CDATA[ Plain text.]}{CDATA[
+]}{CDATA[ ]}{ELEM1}{CDATA[
+]}{CDATA[ ]}{?[<!-- comment -->]}{CDATA[
+]}{CDATA[ ]}{ELEM2}{CDATA[
+]}{CDATA[ ]}{?[<![CDATA[]}{CDATA[CDATA block]}{?[]]>]}{CDATA[
+]}{CDATA[ ]}{ELEM3}{CDATA[
+]}{CDATA[ ]}{ENTREF[&included-entity;]}{CDATA[
+]}{CDATA[ ]}{ELEM4}{CDATA[
+]}{CDATA[ ]}{PI[test,processing instruction ]}{CDATA[
+]}{CDATA[ ]}{/ELEM4}{CDATA[
+]}{CDATA[ ]}{/ELEM3}{CDATA[
+]}{CDATA[ ]}{/ELEM2}{CDATA[
+]}{CDATA[ ]}{/ELEM1}{CDATA[
+]}{/ROOT}{?[
+]}parse complete
diff --git a/ext/xml/tests/xml002.phpt b/ext/xml/tests/xml002.phpt
new file mode 100644
index 0000000..ce547e8
--- /dev/null
+++ b/ext/xml/tests/xml002.phpt
@@ -0,0 +1,98 @@
+--TEST--
+XML parser test, object tuple callbacks
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+XML_SAX_IMPL == 'libxml' && die('skip this test is not intended for libxml SAX parser');
+?>
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+
+class myclass
+{
+ function startElement($parser, $name, $attribs)
+ {
+ print '{'.$name;
+ if (sizeof($attribs)) {
+ while (list($k, $v) = each($attribs)) {
+ print " $k=\"$v\"";
+ }
+ }
+ print '}';
+ }
+ function endElement($parser, $name)
+ {
+ print '{/'.$name.'}';
+ }
+ function characterData($parser, $data)
+ {
+ print '{CDATA['.$data.']}';
+ }
+ function PIHandler($parser, $target, $data)
+ {
+ print '{PI['.$target.','.$data.']}';
+ }
+ function defaultHandler($parser, $data)
+ {
+ if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") {
+ print '{ENTREF['.$data.']}';
+ } else {
+ print '{?['.$data.']}';
+ }
+ }
+ function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId)
+ {
+ print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n";
+ return true;
+ }
+}
+
+$xml_parser = xml_parser_create();
+$obj = new myclass;
+xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 1);
+xml_set_element_handler($xml_parser, array($obj,"startElement"),
+array($obj, "endElement"));
+xml_set_character_data_handler($xml_parser, array($obj, "characterData"));
+xml_set_processing_instruction_handler($xml_parser, array($obj, "PIHandler"));
+xml_set_default_handler($xml_parser, array($obj, "defaultHandler"));
+xml_set_external_entity_ref_handler($xml_parser,
+array($obj, "externalEntityRefHandler"));
+
+if (!($fp = @fopen("xmltest.xml", "r"))) {
+ die("could not open XML input");
+}
+
+while ($data = fread($fp, 4096)) {
+ if (!xml_parse($xml_parser, $data, feof($fp))) {
+ die(sprintf("XML error: %s at line %d\n",
+ xml_error_string(xml_get_error_code($xml_parser)),
+ xml_get_current_line_number($xml_parser)));
+ }
+}
+print "parse complete\n";
+xml_parser_free($xml_parser);
+
+?>
+--EXPECT--
+{?[<?xml version="1.0" encoding="ISO-8859-1"?>]}{?[
+]}{?[<!DOCTYPE]}{?[ ]}{?[phptest]}{?[ ]}{?[SYSTEM]}{?[ ]}{?["notfound.dtd"]}{?[ ]}{?[[]}{?[
+]}{?[<!ENTITY]}{?[ ]}{?[%]}{?[ ]}{?[incent]}{?[ ]}{?[SYSTEM]}{?[ ]}{?["inc.ent"]}{?[>]}{?[
+]}{?[%incent;]}{?[
+]}{?[]]}{?[>]}{?[
+]}{ROOT ID="elem1"}{CDATA[
+]}{CDATA[ Plain text.]}{CDATA[
+]}{CDATA[ ]}{ELEM1}{CDATA[
+]}{CDATA[ ]}{?[<!-- comment -->]}{CDATA[
+]}{CDATA[ ]}{ELEM2}{CDATA[
+]}{CDATA[ ]}{?[<![CDATA[]}{CDATA[CDATA block]}{?[]]>]}{CDATA[
+]}{CDATA[ ]}{ELEM3}{CDATA[
+]}{CDATA[ ]}{ENTREF[&included-entity;]}{CDATA[
+]}{CDATA[ ]}{ELEM4}{CDATA[
+]}{CDATA[ ]}{PI[test,processing instruction ]}{CDATA[
+]}{CDATA[ ]}{/ELEM4}{CDATA[
+]}{CDATA[ ]}{/ELEM3}{CDATA[
+]}{CDATA[ ]}{/ELEM2}{CDATA[
+]}{CDATA[ ]}{/ELEM1}{CDATA[
+]}{/ROOT}{?[
+]}parse complete
diff --git a/ext/xml/tests/xml003.phpt b/ext/xml/tests/xml003.phpt
new file mode 100644
index 0000000..6b0c3f5
--- /dev/null
+++ b/ext/xml/tests/xml003.phpt
@@ -0,0 +1,96 @@
+--TEST--
+XML parser test, xml_set_object callbacks
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+XML_SAX_IMPL == 'libxml' && die('skip this test is not intended for libxml SAX parser');
+?>
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+
+class myclass
+{
+ function startElement($parser, $name, $attribs)
+ {
+ print '{'.$name;
+ if (sizeof($attribs)) {
+ while (list($k, $v) = each($attribs)) {
+ print " $k=\"$v\"";
+ }
+ }
+ print '}';
+ }
+ function endElement($parser, $name)
+ {
+ print '{/'.$name.'}';
+ }
+ function characterData($parser, $data)
+ {
+ print '{CDATA['.$data.']}';
+ }
+ function PIHandler($parser, $target, $data)
+ {
+ print '{PI['.$target.','.$data.']}';
+ }
+ function defaultHandler($parser, $data)
+ {
+ if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") {
+ print '{ENTREF['.$data.']}';
+ } else {
+ print '{?['.$data.']}';
+ }
+ }
+ function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId)
+ {
+ print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n";
+ return true;
+ }
+}
+
+$xml_parser = xml_parser_create();
+$obj = new myclass;
+xml_set_object($xml_parser, $obj);
+xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 1);
+xml_set_element_handler($xml_parser, "startElement", "endElement");
+xml_set_character_data_handler($xml_parser, "characterData");
+xml_set_processing_instruction_handler($xml_parser, "PIHandler");
+xml_set_default_handler($xml_parser, "defaultHandler");
+xml_set_external_entity_ref_handler($xml_parser, "externalEntityRefHandler");
+
+if (!($fp = @fopen("xmltest.xml", "r"))) {
+ die("could not open XML input");
+}
+
+while ($data = fread($fp, 4096)) {
+ if (!xml_parse($xml_parser, $data, feof($fp))) {
+ die(sprintf("XML error: %s at line %d\n",
+ xml_error_string(xml_get_error_code($xml_parser)),
+ xml_get_current_line_number($xml_parser)));
+ }
+}
+print "parse complete\n";
+xml_parser_free($xml_parser);
+?>
+--EXPECT--
+{?[<?xml version="1.0" encoding="ISO-8859-1"?>]}{?[
+]}{?[<!DOCTYPE]}{?[ ]}{?[phptest]}{?[ ]}{?[SYSTEM]}{?[ ]}{?["notfound.dtd"]}{?[ ]}{?[[]}{?[
+]}{?[<!ENTITY]}{?[ ]}{?[%]}{?[ ]}{?[incent]}{?[ ]}{?[SYSTEM]}{?[ ]}{?["inc.ent"]}{?[>]}{?[
+]}{?[%incent;]}{?[
+]}{?[]]}{?[>]}{?[
+]}{ROOT ID="elem1"}{CDATA[
+]}{CDATA[ Plain text.]}{CDATA[
+]}{CDATA[ ]}{ELEM1}{CDATA[
+]}{CDATA[ ]}{?[<!-- comment -->]}{CDATA[
+]}{CDATA[ ]}{ELEM2}{CDATA[
+]}{CDATA[ ]}{?[<![CDATA[]}{CDATA[CDATA block]}{?[]]>]}{CDATA[
+]}{CDATA[ ]}{ELEM3}{CDATA[
+]}{CDATA[ ]}{ENTREF[&included-entity;]}{CDATA[
+]}{CDATA[ ]}{ELEM4}{CDATA[
+]}{CDATA[ ]}{PI[test,processing instruction ]}{CDATA[
+]}{CDATA[ ]}{/ELEM4}{CDATA[
+]}{CDATA[ ]}{/ELEM3}{CDATA[
+]}{CDATA[ ]}{/ELEM2}{CDATA[
+]}{CDATA[ ]}{/ELEM1}{CDATA[
+]}{/ROOT}{?[
+]}parse complete
diff --git a/ext/xml/tests/xml004.phpt b/ext/xml/tests/xml004.phpt
new file mode 100644
index 0000000..245a93f
--- /dev/null
+++ b/ext/xml/tests/xml004.phpt
@@ -0,0 +1,62 @@
+--TEST--
+XML parser case folding test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+
+$xp = xml_parser_create();
+xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
+xml_set_element_handler($xp, "start_element", "end_element");
+$fp = fopen("xmltest.xml", "r");
+while ($data = fread($fp, 4096)) {
+ xml_parse($xp, $data, feof($fp));
+}
+xml_parser_free($xp);
+$xp = xml_parser_create();
+xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, true);
+xml_set_element_handler($xp, "start_element", "end_element");
+$fp = fopen("xmltest.xml", "r");
+while ($data = fread($fp, 4096)) {
+ xml_parse($xp, $data, feof($fp));
+}
+xml_parser_free($xp);
+
+function start_element($xp, $elem, $attribs)
+{
+ print "<$elem";
+ if (sizeof($attribs)) {
+ while (list($k, $v) = each($attribs)) {
+ print " $k=\"$v\"";
+ }
+ }
+ print ">\n";
+}
+
+function end_element($xp, $elem)
+{
+ print "</$elem>\n";
+}
+?>
+--EXPECT--
+<root id="elem1">
+<elem1>
+<elem2>
+<elem3>
+<elem4>
+</elem4>
+</elem3>
+</elem2>
+</elem1>
+</root>
+<ROOT ID="elem1">
+<ELEM1>
+<ELEM2>
+<ELEM3>
+<ELEM4>
+</ELEM4>
+</ELEM3>
+</ELEM2>
+</ELEM1>
+</ROOT>
diff --git a/ext/xml/tests/xml006.phpt b/ext/xml/tests/xml006.phpt
new file mode 100644
index 0000000..c714e85
--- /dev/null
+++ b/ext/xml/tests/xml006.phpt
@@ -0,0 +1,12 @@
+--TEST--
+UTF-8<->ISO Latin 1 encoding/decoding test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+printf("%s -> %s\n", urlencode("æ"), urlencode(utf8_encode("æ")));
+printf("%s <- %s\n", urlencode(utf8_decode(urldecode("%C3%A6"))), "%C3%A6");
+?>
+--EXPECT--
+%E6 -> %C3%A6
+%E6 <- %C3%A6
diff --git a/ext/xml/tests/xml007.phpt b/ext/xml/tests/xml007.phpt
new file mode 100644
index 0000000..377475b
--- /dev/null
+++ b/ext/xml/tests/xml007.phpt
@@ -0,0 +1,53 @@
+--TEST--
+xml_parse_into_struct/umlauts in tags
+--SKIPIF--
+<?php // vim600: syn=php
+include("skipif.inc");
+if(strtoupper("äöüß") != "ÄÖÜß")
+{
+ die("skip strtoupper on non-ascii not supported on this platform");
+}
+?>
+--FILE--
+<?php
+function startHandler($parser,$tag,$attr)
+{
+ var_dump($tag,$attr);
+}
+
+function endHandler($parser,$tag)
+{
+ var_dump($tag);
+}
+
+$xmldata = '<?xml version="1.0" encoding="ISO-8859-1"?><äöü üäß="Üäß">ÄÖÜ</äöü>';
+$parser = xml_parser_create('ISO-8859-1');
+xml_set_element_handler($parser, "startHandler", "endHandler");
+xml_parse_into_struct($parser, $xmldata, $struct, $index);
+var_dump($struct);
+?>
+--EXPECT--
+string(3) "ÄÖÜ"
+array(1) {
+ ["ÜÄß"]=>
+ string(3) "Üäß"
+}
+string(3) "ÄÖÜ"
+array(1) {
+ [0]=>
+ array(5) {
+ ["tag"]=>
+ string(3) "ÄÖÜ"
+ ["type"]=>
+ string(8) "complete"
+ ["level"]=>
+ int(1)
+ ["attributes"]=>
+ array(1) {
+ ["ÜÄß"]=>
+ string(3) "Üäß"
+ }
+ ["value"]=>
+ string(3) "ÄÖÜ"
+ }
+}
diff --git a/ext/xml/tests/xml009.phpt b/ext/xml/tests/xml009.phpt
new file mode 100644
index 0000000..84b89bb
--- /dev/null
+++ b/ext/xml/tests/xml009.phpt
@@ -0,0 +1,35 @@
+--TEST--
+XML parser test, default namespaces
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this plattform");}
+?>
+--FILE--
+<?php
+function start_elem($parser,$name,$attribs) {
+ var_dump($name);
+}
+function end_elem()
+{
+}
+
+$xml = <<<HERE
+<a xmlns="http://example.com/foo"
+ xmlns:bar="http://example.com/bar"
+ xmlns:baz="http://example.com/baz">
+ <bar:b />
+ <bar:c xmlns:bar="http://example.com/foo"/>
+</a>
+HERE;
+
+$parser = xml_parser_create_ns("ISO-8859-1","@");
+xml_set_element_handler($parser,'start_elem','end_elem');
+xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+xml_parse($parser, $xml);
+xml_parser_free($parser);
+?>
+--EXPECT--
+string(24) "http://example.com/foo@a"
+string(24) "http://example.com/bar@b"
+string(24) "http://example.com/foo@c"
diff --git a/ext/xml/tests/xml010.phpt b/ext/xml/tests/xml010.phpt
new file mode 100644
index 0000000..e968442
--- /dev/null
+++ b/ext/xml/tests/xml010.phpt
@@ -0,0 +1,39 @@
+--TEST--
+XML parser test, attributes
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this plattform");}
+?>
+--FILE--
+<?php
+function start_elem($parser,$name,$attribs) {
+ print "$name ";
+
+ foreach($attribs as $key => $value) {
+ print "$key = $value ";
+ }
+ print "\n";
+}
+function end_elem()
+{
+}
+
+$xml = <<<HERE
+<a xmlns="http://example.com/foo"
+ xmlns:bar="http://example.com/bar">
+ <bar:b foo="bar"/>
+ <bar:c bar:nix="null" foo="bar"/>
+</a>
+HERE;
+
+$parser = xml_parser_create_ns("ISO-8859-1","@");
+xml_set_element_handler($parser,'start_elem','end_elem');
+xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+xml_parse($parser, $xml);
+xml_parser_free($parser);
+?>
+--EXPECT--
+http://example.com/foo@a
+http://example.com/bar@b foo = bar
+http://example.com/bar@c http://example.com/bar@nix = null foo = bar
diff --git a/ext/xml/tests/xml011.phpt b/ext/xml/tests/xml011.phpt
new file mode 100644
index 0000000..9c4cfca
--- /dev/null
+++ b/ext/xml/tests/xml011.phpt
@@ -0,0 +1,71 @@
+--TEST--
+XML Parser test: concat character data and set empty handlers
+--SKIPIF--
+<?php
+require_once("skipif.inc");
+?>
+--FILE--
+<?php
+function start_elem($parser,$name,$attribs) {
+ echo "<$name>";
+}
+function end_elem()
+{
+ echo "</$name>";
+}
+
+$xml = '<text>start<b /> This &amp; that</text>';
+
+$parser = xml_parser_create();
+xml_parse_into_struct($parser, $xml, $vals, $index);
+print_r($vals);
+xml_parser_free($parser);
+
+echo "\nChange to empty end handler\n";
+$parser = xml_parser_create();
+xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+xml_set_element_handler($parser,'start_elem','end_elem');
+xml_set_element_handler($parser,'start_elem',NULL);
+xml_parse($parser, $xml, TRUE);
+
+xml_parser_free($parser);
+echo "\nDone\n";
+?>
+--EXPECT--
+Array
+(
+ [0] => Array
+ (
+ [tag] => TEXT
+ [type] => open
+ [level] => 1
+ [value] => start
+ )
+
+ [1] => Array
+ (
+ [tag] => B
+ [type] => complete
+ [level] => 2
+ )
+
+ [2] => Array
+ (
+ [tag] => TEXT
+ [value] => This & that
+ [type] => cdata
+ [level] => 1
+ )
+
+ [3] => Array
+ (
+ [tag] => TEXT
+ [type] => close
+ [level] => 1
+ )
+
+)
+
+Change to empty end handler
+<text><b>
+Done
diff --git a/ext/xml/tests/xml_closures_001.phpt b/ext/xml/tests/xml_closures_001.phpt
new file mode 100644
index 0000000..37df254
--- /dev/null
+++ b/ext/xml/tests/xml_closures_001.phpt
@@ -0,0 +1,45 @@
+--TEST--
+XML parser test using closures as callbacks
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+
+$start_element = function ($xp, $elem, $attribs)
+{
+ print "<$elem";
+ if (sizeof($attribs)) {
+ while (list($k, $v) = each($attribs)) {
+ print " $k=\"$v\"";
+ }
+ }
+ print ">\n";
+};
+
+$end_element = function ($xp, $elem)
+{
+ print "</$elem>\n";
+};
+
+$xp = xml_parser_create();
+xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
+xml_set_element_handler($xp, $start_element, $end_element);
+$fp = fopen("xmltest.xml", "r");
+while ($data = fread($fp, 4096)) {
+ xml_parse($xp, $data, feof($fp));
+}
+xml_parser_free($xp);
+
+?>
+--EXPECT--
+<root id="elem1">
+<elem1>
+<elem2>
+<elem3>
+<elem4>
+</elem4>
+</elem3>
+</elem2>
+</elem1>
+</root>
diff --git a/ext/xml/tests/xml_error_string_error.phpt b/ext/xml/tests/xml_error_string_error.phpt
new file mode 100644
index 0000000..866346f
--- /dev/null
+++ b/ext/xml/tests/xml_error_string_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test xml_error_string() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto string xml_error_string(int code)
+ * Description: Get XML parser error string
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_error_string() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing xml_error_string() function with Zero arguments --\n";
+var_dump( xml_error_string() );
+
+//Test xml_error_string with one more than the expected number of arguments
+echo "\n-- Testing xml_error_string() function with more than expected no. of arguments --\n";
+$code = 10;
+$extra_arg = 10;
+var_dump( xml_error_string($code, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_error_string() : error conditions ***
+
+-- Testing xml_error_string() function with Zero arguments --
+
+Warning: xml_error_string() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing xml_error_string() function with more than expected no. of arguments --
+
+Warning: xml_error_string() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_error_string_variation1.phpt b/ext/xml/tests/xml_error_string_variation1.phpt
new file mode 100644
index 0000000..40b542c
--- /dev/null
+++ b/ext/xml/tests/xml_error_string_variation1.phpt
@@ -0,0 +1,179 @@
+--TEST--
+Test xml_error_string() function : usage variations - test different types for code
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto string xml_error_string(int code)
+ * Description: Get XML parser error string
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_error_string() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for code
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_error_string($value) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_error_string() : usage variations ***
+
+Arg value 10.5
+string(22) "XML_ERR_CHARREF_AT_EOF"
+
+Arg value -10.5
+string(7) "Unknown"
+
+Arg value 101234567000
+string(7) "Unknown"
+
+Arg value 1.07654321E-9
+string(8) "No error"
+
+Arg value 0.5
+string(8) "No error"
+
+Arg value Array
+
+Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_error_string() expects parameter 1 to be long, array given in %s on line %d
+NULL
+
+Arg value
+string(8) "No error"
+
+Arg value
+string(8) "No error"
+
+Arg value 1
+string(9) "No memory"
+
+Arg value
+string(8) "No error"
+
+Arg value 1
+string(9) "No memory"
+
+Arg value
+string(8) "No error"
+
+Arg value
+
+Warning: xml_error_string() expects parameter 1 to be long, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_error_string() expects parameter 1 to be long, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_error_string() expects parameter 1 to be long, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_error_string() expects parameter 1 to be long, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_error_string() expects parameter 1 to be long, object given in %s on line %d
+NULL
+
+Arg value
+string(8) "No error"
+
+Arg value
+string(8) "No error"
+Done
+
+
diff --git a/ext/xml/tests/xml_get_current_byte_index_error.phpt b/ext/xml/tests/xml_get_current_byte_index_error.phpt
new file mode 100644
index 0000000..74fa2e7
--- /dev/null
+++ b/ext/xml/tests/xml_get_current_byte_index_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test xml_get_current_byte_index() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_get_current_byte_index(resource parser)
+ * Description: Get current byte index for an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_get_current_byte_index() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing xml_get_current_byte_index() function with Zero arguments --\n";
+var_dump( xml_get_current_byte_index() );
+
+//Test xml_get_current_byte_index with one more than the expected number of arguments
+echo "\n-- Testing xml_get_current_byte_index() function with more than expected no. of arguments --\n";
+
+$extra_arg = 10;
+var_dump( xml_get_current_byte_index(null, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_get_current_byte_index() : error conditions ***
+
+-- Testing xml_get_current_byte_index() function with Zero arguments --
+
+Warning: xml_get_current_byte_index() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing xml_get_current_byte_index() function with more than expected no. of arguments --
+
+Warning: xml_get_current_byte_index() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_get_current_byte_index_variation1.phpt b/ext/xml/tests/xml_get_current_byte_index_variation1.phpt
new file mode 100644
index 0000000..b5c83d7
--- /dev/null
+++ b/ext/xml/tests/xml_get_current_byte_index_variation1.phpt
@@ -0,0 +1,240 @@
+--TEST--
+Test xml_get_current_byte_index() function : usage variations - <type here specifics of this variation>
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_get_current_byte_index(resource parser)
+ * Description: Get current byte index for an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_get_current_byte_index() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_get_current_byte_index($value) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_get_current_byte_index() : usage variations ***
+
+Arg value 0
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_get_current_byte_index(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_byte_index() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_get_current_column_number_error.phpt b/ext/xml/tests/xml_get_current_column_number_error.phpt
new file mode 100644
index 0000000..1fd28cc
--- /dev/null
+++ b/ext/xml/tests/xml_get_current_column_number_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test xml_get_current_column_number() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_get_current_column_number(resource parser)
+ * Description: Get current column number for an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_get_current_column_number() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing xml_get_current_column_number() function with Zero arguments --\n";
+var_dump( xml_get_current_column_number() );
+
+//Test xml_get_current_column_number with one more than the expected number of arguments
+echo "\n-- Testing xml_get_current_column_number() function with more than expected no. of arguments --\n";
+
+$extra_arg = 10;
+var_dump( xml_get_current_column_number(null, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_get_current_column_number() : error conditions ***
+
+-- Testing xml_get_current_column_number() function with Zero arguments --
+
+Warning: xml_get_current_column_number() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing xml_get_current_column_number() function with more than expected no. of arguments --
+
+Warning: xml_get_current_column_number() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_get_current_column_number_variation1.phpt b/ext/xml/tests/xml_get_current_column_number_variation1.phpt
new file mode 100644
index 0000000..0eeb8d0
--- /dev/null
+++ b/ext/xml/tests/xml_get_current_column_number_variation1.phpt
@@ -0,0 +1,241 @@
+--TEST--
+Test xml_get_current_column_number() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_get_current_column_number(resource parser)
+ * Description: Get current column number for an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+
+echo "*** Testing xml_get_current_column_number() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_get_current_column_number($value) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_get_current_column_number() : usage variations ***
+
+Arg value 0
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_get_current_column_number(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_column_number() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_get_current_line_number_error.phpt b/ext/xml/tests/xml_get_current_line_number_error.phpt
new file mode 100644
index 0000000..282c120
--- /dev/null
+++ b/ext/xml/tests/xml_get_current_line_number_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test xml_get_current_line_number() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_get_current_line_number(resource parser)
+ * Description: Get current line number for an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_get_current_line_number() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing xml_get_current_line_number() function with Zero arguments --\n";
+var_dump( xml_get_current_line_number() );
+
+//Test xml_get_current_line_number with one more than the expected number of arguments
+echo "\n-- Testing xml_get_current_line_number() function with more than expected no. of arguments --\n";
+
+$extra_arg = 10;
+var_dump( xml_get_current_line_number(null, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_get_current_line_number() : error conditions ***
+
+-- Testing xml_get_current_line_number() function with Zero arguments --
+
+Warning: xml_get_current_line_number() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing xml_get_current_line_number() function with more than expected no. of arguments --
+
+Warning: xml_get_current_line_number() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_get_current_line_number_variation1.phpt b/ext/xml/tests/xml_get_current_line_number_variation1.phpt
new file mode 100644
index 0000000..af41c6f
--- /dev/null
+++ b/ext/xml/tests/xml_get_current_line_number_variation1.phpt
@@ -0,0 +1,240 @@
+--TEST--
+Test xml_get_current_line_number() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_get_current_line_number(resource parser)
+ * Description: Get current line number for an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_get_current_line_number() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_get_current_line_number($value) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_get_current_line_number() : usage variations ***
+
+Arg value 0
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_get_current_line_number(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_current_line_number() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_get_error_code_error.phpt b/ext/xml/tests/xml_get_error_code_error.phpt
new file mode 100644
index 0000000..683734a
--- /dev/null
+++ b/ext/xml/tests/xml_get_error_code_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test xml_get_error_code() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_get_error_code(resource parser)
+ * Description: Get XML parser error code
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_get_error_code() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing xml_get_error_code() function with Zero arguments --\n";
+var_dump( xml_get_error_code() );
+
+//Test xml_get_error_code with one more than the expected number of arguments
+echo "\n-- Testing xml_get_error_code() function with more than expected no. of arguments --\n";
+
+$extra_arg = 10;
+var_dump( xml_get_error_code(null, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_get_error_code() : error conditions ***
+
+-- Testing xml_get_error_code() function with Zero arguments --
+
+Warning: xml_get_error_code() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing xml_get_error_code() function with more than expected no. of arguments --
+
+Warning: xml_get_error_code() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_get_error_code_variation1.phpt b/ext/xml/tests/xml_get_error_code_variation1.phpt
new file mode 100644
index 0000000..4749214
--- /dev/null
+++ b/ext/xml/tests/xml_get_error_code_variation1.phpt
@@ -0,0 +1,240 @@
+--TEST--
+Test xml_get_error_code() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_get_error_code(resource parser)
+ * Description: Get XML parser error code
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_get_error_code() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_get_error_code($value) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_get_error_code() : usage variations ***
+
+Arg value 0
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_get_error_code(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_get_error_code() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_parse_error.phpt b/ext/xml/tests/xml_parse_error.phpt
new file mode 100644
index 0000000..d8d8fff
--- /dev/null
+++ b/ext/xml/tests/xml_parse_error.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test xml_parse() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_parse(resource parser, string data [, int isFinal])
+ * Description: Start parsing an XML document
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parse() : error conditions ***\n";
+
+
+//Test xml_parse with one more than the expected number of arguments
+echo "\n-- Testing xml_parse() function with more than expected no. of arguments --\n";
+
+$data = 'string_val';
+$isFinal = false;
+$extra_arg = 10;
+var_dump( xml_parse(null, $data, $isFinal, $extra_arg) );
+
+// Testing xml_parse with one less than the expected number of arguments
+echo "\n-- Testing xml_parse() function with less than expected no. of arguments --\n";
+
+var_dump( xml_parse(null) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parse() : error conditions ***
+
+-- Testing xml_parse() function with more than expected no. of arguments --
+
+Warning: xml_parse() expects at most 3 parameters, 4 given in %s on line %d
+NULL
+
+-- Testing xml_parse() function with less than expected no. of arguments --
+
+Warning: xml_parse() expects at least 2 parameters, 1 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_parse_into_struct_error.phpt b/ext/xml/tests/xml_parse_into_struct_error.phpt
new file mode 100644
index 0000000..82a26ad
--- /dev/null
+++ b/ext/xml/tests/xml_parse_into_struct_error.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Test xml_parse_into_struct() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_parse_into_struct(resource parser, string data, array &struct, array &index)
+ * Description: Parsing a XML document
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parse_into_struct() : error conditions ***\n";
+
+//Test xml_parse_into_struct with one more than the expected number of arguments
+echo "\n-- Testing xml_parse_into_struct() function with more than expected no. of arguments --\n";
+
+$data = 'string_val';
+$struct = array(1, 2);
+$index = array(1, 2);
+$extra_arg = 10;
+var_dump( xml_parse_into_struct(null, $data, $struct, $index, $extra_arg) );
+
+// Testing xml_parse_into_struct with one less than the expected number of arguments
+echo "\n-- Testing xml_parse_into_struct() function with less than expected no. of arguments --\n";
+
+$data = 'string_val';
+var_dump( xml_parse_into_struct(null, $data) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parse_into_struct() : error conditions ***
+
+-- Testing xml_parse_into_struct() function with more than expected no. of arguments --
+
+Warning: xml_parse_into_struct() expects at most 4 parameters, 5 given in %s on line %d
+NULL
+
+-- Testing xml_parse_into_struct() function with less than expected no. of arguments --
+
+Warning: xml_parse_into_struct() expects at least 3 parameters, 2 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_parse_into_struct_variation.phpt b/ext/xml/tests/xml_parse_into_struct_variation.phpt
new file mode 100644
index 0000000..a353e51
--- /dev/null
+++ b/ext/xml/tests/xml_parse_into_struct_variation.phpt
@@ -0,0 +1,120 @@
+--TEST--
+Test xml_parse_into_struct() function : variation
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_parse_into_struct(resource parser, string data, array &struct, array &index)
+ * Description: Parsing a XML document
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parse_into_struct() : variation ***\n";
+
+$simple = "<main><para><note>simple note</note></para><para><note>simple note</note></para></main>";
+$p = xml_parser_create();
+xml_parse_into_struct($p, $simple, $vals, $index);
+xml_parser_free($p);
+echo "Index array\n";
+print_r($index);
+echo "\nVals array\n";
+print_r($vals);
+
+
+echo "Done";
+?>
+--EXPECT--
+*** Testing xml_parse_into_struct() : variation ***
+Index array
+Array
+(
+ [MAIN] => Array
+ (
+ [0] => 0
+ [1] => 7
+ )
+
+ [PARA] => Array
+ (
+ [0] => 1
+ [1] => 3
+ [2] => 4
+ [3] => 6
+ )
+
+ [NOTE] => Array
+ (
+ [0] => 2
+ [1] => 5
+ )
+
+)
+
+Vals array
+Array
+(
+ [0] => Array
+ (
+ [tag] => MAIN
+ [type] => open
+ [level] => 1
+ )
+
+ [1] => Array
+ (
+ [tag] => PARA
+ [type] => open
+ [level] => 2
+ )
+
+ [2] => Array
+ (
+ [tag] => NOTE
+ [type] => complete
+ [level] => 3
+ [value] => simple note
+ )
+
+ [3] => Array
+ (
+ [tag] => PARA
+ [type] => close
+ [level] => 2
+ )
+
+ [4] => Array
+ (
+ [tag] => PARA
+ [type] => open
+ [level] => 2
+ )
+
+ [5] => Array
+ (
+ [tag] => NOTE
+ [type] => complete
+ [level] => 3
+ [value] => simple note
+ )
+
+ [6] => Array
+ (
+ [tag] => PARA
+ [type] => close
+ [level] => 2
+ )
+
+ [7] => Array
+ (
+ [tag] => MAIN
+ [type] => close
+ [level] => 1
+ )
+
+)
+Done \ No newline at end of file
diff --git a/ext/xml/tests/xml_parse_into_struct_variation1.phpt b/ext/xml/tests/xml_parse_into_struct_variation1.phpt
new file mode 100644
index 0000000..fa1e8d2
--- /dev/null
+++ b/ext/xml/tests/xml_parse_into_struct_variation1.phpt
@@ -0,0 +1,241 @@
+--TEST--
+Test xml_parse_into_struct() function : usage variations - different types for parser
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_parse_into_struct(resource parser, string data, array &struct, array &index)
+ * Description: Parsing a XML document
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parse_into_struct() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+$data = 'string_val';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_parse_into_struct($value, $data, $struct, $index) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parse_into_struct() : usage variations ***
+
+Arg value 0
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_parse_into_struct(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parse_into_struct() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_parse_variation1.phpt b/ext/xml/tests/xml_parse_variation1.phpt
new file mode 100644
index 0000000..cf36666
--- /dev/null
+++ b/ext/xml/tests/xml_parse_variation1.phpt
@@ -0,0 +1,242 @@
+--TEST--
+Test xml_parse() function : usage variations - different types of parser
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_parse(resource parser, string data [, int isFinal])
+ * Description: Start parsing an XML document
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parse() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+$data = 'string_val';
+$isFinal = 10;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_parse($value, $data, $isFinal) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parse() : usage variations ***
+
+Arg value 0
+
+Warning: xml_parse() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parse() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_parse() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_parse() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_parse() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_parse() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_parse() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_parse() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_parse() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parse() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parse() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parse() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parse() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parse() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parse() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parse() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parse() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parse() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parse() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parse() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parse() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parse() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_parse() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_parse() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_parse() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_parse(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_parse() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parse() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_parser_create_error.phpt b/ext/xml/tests/xml_parser_create_error.phpt
new file mode 100644
index 0000000..571350e
--- /dev/null
+++ b/ext/xml/tests/xml_parser_create_error.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test xml_parser_create() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto resource xml_parser_create([string encoding])
+ * Description: Create an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parser_create() : error conditions ***\n";
+
+
+//Test xml_parser_create with one more than the expected number of arguments
+echo "\n-- Testing xml_parser_create() function with more than expected no. of arguments --\n";
+$encoding = 'utf-8';
+$extra_arg = 10;
+var_dump( xml_parser_create($encoding, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parser_create() : error conditions ***
+
+-- Testing xml_parser_create() function with more than expected no. of arguments --
+
+Warning: xml_parser_create() expects at most 1 parameter, 2 given in %s on line %d
+bool(false)
+Done
diff --git a/ext/xml/tests/xml_parser_create_ns_error.phpt b/ext/xml/tests/xml_parser_create_ns_error.phpt
new file mode 100644
index 0000000..fd50f29
--- /dev/null
+++ b/ext/xml/tests/xml_parser_create_ns_error.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Test xml_parser_create_ns() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto resource xml_parser_create_ns([string encoding [, string sep]])
+ * Description: Create an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parser_create_ns() : error conditions ***\n";
+
+
+//Test xml_parser_create_ns with one more than the expected number of arguments
+echo "\n-- Testing xml_parser_create_ns() function with more than expected no. of arguments --\n";
+$encoding = 'string_val';
+$sep = 'string_val';
+$extra_arg = 10;
+var_dump( xml_parser_create_ns($encoding, $sep, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parser_create_ns() : error conditions ***
+
+-- Testing xml_parser_create_ns() function with more than expected no. of arguments --
+
+Warning: xml_parser_create_ns() expects at most 2 parameters, 3 given in %s on line %d
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/xml/tests/xml_parser_create_ns_variation1.phpt b/ext/xml/tests/xml_parser_create_ns_variation1.phpt
new file mode 100644
index 0000000..2818b82
--- /dev/null
+++ b/ext/xml/tests/xml_parser_create_ns_variation1.phpt
@@ -0,0 +1,245 @@
+--TEST--
+Test xml_parser_create_ns() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto resource xml_parser_create_ns([string encoding [, string sep]])
+ * Description: Create an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parser_create_ns() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+ "ISO-8859-1",
+ "UTF-8",
+ "US-ASCII",
+ "UTF-32",
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for encoding
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ $res = xml_parser_create_ns($value);
+ var_dump($res);
+ if ($res !== false) {
+ xml_parser_free($res);
+ }
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parser_create_ns() : usage variations ***
+
+Arg value 0
+
+Warning: xml_parser_create_ns(): unsupported source encoding "0" in %s on line %d
+bool(false)
+
+Arg value 1
+
+Warning: xml_parser_create_ns(): unsupported source encoding "1" in %s on line %d
+bool(false)
+
+Arg value 12345
+
+Warning: xml_parser_create_ns(): unsupported source encoding "12345" in %s on line %d
+bool(false)
+
+Arg value -2345
+
+Warning: xml_parser_create_ns(): unsupported source encoding "-2345" in %s on line %d
+bool(false)
+
+Arg value 10.5
+
+Warning: xml_parser_create_ns(): unsupported source encoding "10.5" in %s on line %d
+bool(false)
+
+Arg value -10.5
+
+Warning: xml_parser_create_ns(): unsupported source encoding "-10.5" in %s on line %d
+bool(false)
+
+Arg value 101234567000
+
+Warning: xml_parser_create_ns(): unsupported source encoding "101234567000" in %s on line %d
+bool(false)
+
+Arg value 1.07654321E-9
+
+Warning: xml_parser_create_ns(): unsupported source encoding "1.07654321E-9" in %s on line %d
+bool(false)
+
+Arg value 0.5
+
+Warning: xml_parser_create_ns(): unsupported source encoding "0.5" in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Arg value
+resource(%d) of type (xml)
+
+Arg value
+resource(%d) of type (xml)
+
+Arg value 1
+
+Warning: xml_parser_create_ns(): unsupported source encoding "1" in %s on line %d
+bool(false)
+
+Arg value
+resource(%d) of type (xml)
+
+Arg value 1
+
+Warning: xml_parser_create_ns(): unsupported source encoding "1" in %s on line %d
+bool(false)
+
+Arg value
+resource(%d) of type (xml)
+
+Arg value
+resource(%d) of type (xml)
+
+Arg value
+resource(%d) of type (xml)
+
+Arg value string
+
+Warning: xml_parser_create_ns(): unsupported source encoding "string" in %s on line %d
+bool(false)
+
+Arg value string
+
+Warning: xml_parser_create_ns(): unsupported source encoding "string" in %s on line %d
+bool(false)
+
+Arg value ISO-8859-1
+resource(%d) of type (xml)
+
+Arg value UTF-8
+resource(%d) of type (xml)
+
+Arg value US-ASCII
+resource(%d) of type (xml)
+
+Arg value UTF-32
+
+Warning: xml_parser_create_ns(): unsupported source encoding "UTF-32" in %s on line %d
+bool(false)
+
+Arg value Some Ascii Data
+
+Warning: xml_parser_create_ns(): unsupported source encoding "Some Ascii Data" in %s on line %d
+bool(false)
+
+Arg value Resource id %s
+
+Warning: xml_parser_create_ns() expects parameter 1 to be string, resource given in %s on line %d
+bool(false)
+
+Arg value
+resource(%d) of type (xml)
+
+Arg value
+resource(%d) of type (xml)
+Done
diff --git a/ext/xml/tests/xml_parser_create_variation1.phpt b/ext/xml/tests/xml_parser_create_variation1.phpt
new file mode 100644
index 0000000..c5d588f
--- /dev/null
+++ b/ext/xml/tests/xml_parser_create_variation1.phpt
@@ -0,0 +1,245 @@
+--TEST--
+Test xml_parser_create() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto resource xml_parser_create([string encoding])
+ * Description: Create an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parser_create() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+ "ISO-8859-1",
+ "UTF-8",
+ "US-ASCII",
+ "UTF-32",
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for encoding
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ $res = xml_parser_create($value);
+ var_dump($res);
+ if ($res !== false) {
+ xml_parser_free($res);
+ }
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parser_create() : usage variations ***
+
+Arg value 0
+
+Warning: xml_parser_create(): unsupported source encoding "0" in %s on line %d
+bool(false)
+
+Arg value 1
+
+Warning: xml_parser_create(): unsupported source encoding "1" in %s on line %d
+bool(false)
+
+Arg value 12345
+
+Warning: xml_parser_create(): unsupported source encoding "12345" in %s on line %d
+bool(false)
+
+Arg value -2345
+
+Warning: xml_parser_create(): unsupported source encoding "-2345" in %s on line %d
+bool(false)
+
+Arg value 10.5
+
+Warning: xml_parser_create(): unsupported source encoding "10.5" in %s on line %d
+bool(false)
+
+Arg value -10.5
+
+Warning: xml_parser_create(): unsupported source encoding "-10.5" in %s on line %d
+bool(false)
+
+Arg value 101234567000
+
+Warning: xml_parser_create(): unsupported source encoding "101234567000" in %s on line %d
+bool(false)
+
+Arg value 1.07654321E-9
+
+Warning: xml_parser_create(): unsupported source encoding "1.07654321E-9" in %s on line %d
+bool(false)
+
+Arg value 0.5
+
+Warning: xml_parser_create(): unsupported source encoding "0.5" in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: xml_parser_create() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: xml_parser_create() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: xml_parser_create() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: xml_parser_create() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: xml_parser_create() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Arg value
+resource(%d) of type (xml)
+
+Arg value
+resource(%d) of type (xml)
+
+Arg value 1
+
+Warning: xml_parser_create(): unsupported source encoding "1" in %s on line %d
+bool(false)
+
+Arg value
+resource(%d) of type (xml)
+
+Arg value 1
+
+Warning: xml_parser_create(): unsupported source encoding "1" in %s on line %d
+bool(false)
+
+Arg value
+resource(%d) of type (xml)
+
+Arg value
+resource(%d) of type (xml)
+
+Arg value
+resource(%d) of type (xml)
+
+Arg value string
+
+Warning: xml_parser_create(): unsupported source encoding "string" in %s on line %d
+bool(false)
+
+Arg value string
+
+Warning: xml_parser_create(): unsupported source encoding "string" in %s on line %d
+bool(false)
+
+Arg value ISO-8859-1
+resource(%d) of type (xml)
+
+Arg value UTF-8
+resource(%d) of type (xml)
+
+Arg value US-ASCII
+resource(%d) of type (xml)
+
+Arg value UTF-32
+
+Warning: xml_parser_create(): unsupported source encoding "UTF-32" in %s on line %d
+bool(false)
+
+Arg value Some Ascii Data
+
+Warning: xml_parser_create(): unsupported source encoding "Some Ascii Data" in %s on line %d
+bool(false)
+
+Arg value Resource id %s
+
+Warning: xml_parser_create() expects parameter 1 to be string, resource given in %s on line %d
+bool(false)
+
+Arg value
+resource(%d) of type (xml)
+
+Arg value
+resource(%d) of type (xml)
+Done \ No newline at end of file
diff --git a/ext/xml/tests/xml_parser_free_error.phpt b/ext/xml/tests/xml_parser_free_error.phpt
new file mode 100644
index 0000000..13afb95
--- /dev/null
+++ b/ext/xml/tests/xml_parser_free_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test xml_parser_free() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_parser_free(resource parser)
+ * Description: Free an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parser_free() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing xml_parser_free() function with Zero arguments --\n";
+var_dump( xml_parser_free() );
+
+//Test xml_parser_free with one more than the expected number of arguments
+echo "\n-- Testing xml_parser_free() function with more than expected no. of arguments --\n";
+
+$extra_arg = 10;
+var_dump( xml_parser_free(null, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parser_free() : error conditions ***
+
+-- Testing xml_parser_free() function with Zero arguments --
+
+Warning: xml_parser_free() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing xml_parser_free() function with more than expected no. of arguments --
+
+Warning: xml_parser_free() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_parser_free_variation1.phpt b/ext/xml/tests/xml_parser_free_variation1.phpt
new file mode 100644
index 0000000..0ecb109
--- /dev/null
+++ b/ext/xml/tests/xml_parser_free_variation1.phpt
@@ -0,0 +1,240 @@
+--TEST--
+Test xml_parser_free() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_parser_free(resource parser)
+ * Description: Free an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parser_free() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_parser_free($value) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parser_free() : usage variations ***
+
+Arg value 0
+
+Warning: xml_parser_free() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parser_free() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_parser_free() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_parser_free() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_parser_free() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_parser_free() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_parser_free() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_parser_free() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_parser_free() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_free() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_free() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_free() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_free() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_free() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_free() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_free() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parser_free() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_free() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parser_free() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_free() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_free() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_free() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_parser_free() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_parser_free() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_parser_free() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_parser_free(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_parser_free() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_free() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_parser_get_option_error.phpt b/ext/xml/tests/xml_parser_get_option_error.phpt
new file mode 100644
index 0000000..a355369
--- /dev/null
+++ b/ext/xml/tests/xml_parser_get_option_error.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Test xml_parser_get_option() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_parser_get_option(resource parser, int option)
+ * Description: Get options from an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parser_get_option() : error conditions ***\n";
+
+
+//Test xml_parser_get_option with one more than the expected number of arguments
+echo "\n-- Testing xml_parser_get_option() function with more than expected no. of arguments --\n";
+
+$option = 10;
+$extra_arg = 10;
+var_dump( xml_parser_get_option(null, $option, $extra_arg) );
+
+// Testing xml_parser_get_option with one less than the expected number of arguments
+echo "\n-- Testing xml_parser_get_option() function with less than expected no. of arguments --\n";
+
+var_dump( xml_parser_get_option(null) );
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parser_get_option() : error conditions ***
+
+-- Testing xml_parser_get_option() function with more than expected no. of arguments --
+
+Warning: xml_parser_get_option() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing xml_parser_get_option() function with less than expected no. of arguments --
+
+Warning: xml_parser_get_option() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_parser_get_option_variation1.phpt b/ext/xml/tests/xml_parser_get_option_variation1.phpt
new file mode 100644
index 0000000..b53f803
--- /dev/null
+++ b/ext/xml/tests/xml_parser_get_option_variation1.phpt
@@ -0,0 +1,241 @@
+--TEST--
+Test xml_parser_get_option() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_parser_get_option(resource parser, int option)
+ * Description: Get options from an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parser_get_option() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+$option = 10;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_parser_get_option($value, $option) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parser_get_option() : usage variations ***
+
+Arg value 0
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_parser_get_option(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_get_option() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_parser_get_option_variation2.phpt b/ext/xml/tests/xml_parser_get_option_variation2.phpt
new file mode 100644
index 0000000..2341c41
--- /dev/null
+++ b/ext/xml/tests/xml_parser_get_option_variation2.phpt
@@ -0,0 +1,226 @@
+--TEST--
+Test xml_parser_get_option() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_parser_get_option(resource parser, int option)
+ * Description: Get options from an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parser_get_option() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+$parser = xml_parser_create();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // outside of range int data
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for option
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_parser_get_option($parser, $value) );
+};
+
+fclose($fp);
+xml_parser_free($parser);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parser_get_option() : usage variations ***
+
+Arg value 12345
+
+Warning: xml_parser_get_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value -2345
+
+Warning: xml_parser_get_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value 10.5
+
+Warning: xml_parser_get_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value -10.5
+
+Warning: xml_parser_get_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value 101234567000
+
+Warning: xml_parser_get_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value 1.07654321E-9
+
+Warning: xml_parser_get_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value 0.5
+
+Warning: xml_parser_get_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_get_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_parser_get_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value 1
+int(1)
+
+Arg value
+
+Warning: xml_parser_get_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value 1
+int(1)
+
+Arg value
+
+Warning: xml_parser_get_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_parser_get_option() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_get_option() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_parser_get_option() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_parser_get_option() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_parser_get_option() expects parameter 2 to be long, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_parser_get_option() expects parameter 2 to be long, resource given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_get_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_parser_get_option(): Unknown option in %s on line %d
+bool(false)
+Done
+
diff --git a/ext/xml/tests/xml_parser_set_option_basic.phpt b/ext/xml/tests/xml_parser_set_option_basic.phpt
new file mode 100644
index 0000000..61316a4
--- /dev/null
+++ b/ext/xml/tests/xml_parser_set_option_basic.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Test xml_set_notation_decl_handler function : basic
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto bool xml_set_notation_decl_handler ( resource $parser , callback $handler )
+ * Description: Sets the notation declaration handler function for the XML parser.
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "Simple testcase for xml_parser_get_option() function\n";
+
+$parser = xml_parser_create_ns();
+
+var_dump(xml_parser_get_option($parser, XML_OPTION_CASE_FOLDING));
+var_dump(xml_parser_get_option($parser, XML_OPTION_TARGET_ENCODING));
+
+var_dump(xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 1));
+var_dump(xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"));
+
+var_dump(xml_parser_get_option($parser, XML_OPTION_CASE_FOLDING));
+var_dump(xml_parser_get_option($parser, XML_OPTION_TARGET_ENCODING));
+
+var_dump(xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0));
+var_dump(xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"));
+
+var_dump(xml_parser_get_option($parser, XML_OPTION_CASE_FOLDING));
+var_dump(xml_parser_get_option($parser, XML_OPTION_TARGET_ENCODING));
+
+var_dump(xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "US-ASCII"));
+var_dump(xml_parser_get_option($parser, XML_OPTION_TARGET_ENCODING));
+
+xml_parser_free( $parser );
+
+echo "Done\n";
+?>
+--EXPECT--
+Simple testcase for xml_parser_get_option() function
+int(1)
+string(5) "UTF-8"
+bool(true)
+bool(true)
+int(1)
+string(10) "ISO-8859-1"
+bool(true)
+bool(true)
+int(0)
+string(5) "UTF-8"
+bool(true)
+string(8) "US-ASCII"
+Done
diff --git a/ext/xml/tests/xml_parser_set_option_error.phpt b/ext/xml/tests/xml_parser_set_option_error.phpt
new file mode 100644
index 0000000..28829bc
--- /dev/null
+++ b/ext/xml/tests/xml_parser_set_option_error.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Test xml_parser_set_option() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_parser_set_option(resource parser, int option, mixed value)
+ * Description: Set options in an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parser_set_option() : error conditions ***\n";
+
+
+//Test xml_parser_set_option with one more than the expected number of arguments
+echo "\n-- Testing xml_parser_set_option() function with more than expected no. of arguments --\n";
+
+$option = 10;
+$value = 1;
+$extra_arg = 10;
+var_dump( xml_parser_set_option(null, $option, $value, $extra_arg) );
+
+// Testing xml_parser_set_option with one less than the expected number of arguments
+echo "\n-- Testing xml_parser_set_option() function with less than expected no. of arguments --\n";
+
+$option = 10;
+var_dump( xml_parser_set_option(null, $option) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parser_set_option() : error conditions ***
+
+-- Testing xml_parser_set_option() function with more than expected no. of arguments --
+
+Warning: xml_parser_set_option() expects exactly 3 parameters, 4 given in %s on line %d
+NULL
+
+-- Testing xml_parser_set_option() function with less than expected no. of arguments --
+
+Warning: xml_parser_set_option() expects exactly 3 parameters, 2 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_parser_set_option_variation1.phpt b/ext/xml/tests/xml_parser_set_option_variation1.phpt
new file mode 100644
index 0000000..6cfce0b
--- /dev/null
+++ b/ext/xml/tests/xml_parser_set_option_variation1.phpt
@@ -0,0 +1,241 @@
+--TEST--
+Test xml_parser_set_option() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_parser_set_option(resource parser, int option, mixed value)
+ * Description: Set options in an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parser_set_option() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+$option = 10;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_parser_set_option($value, $option, 1) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parser_set_option() : usage variations ***
+
+Arg value 0
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_parser_set_option(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_set_option() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_parser_set_option_variation2.phpt b/ext/xml/tests/xml_parser_set_option_variation2.phpt
new file mode 100644
index 0000000..9900d6f
--- /dev/null
+++ b/ext/xml/tests/xml_parser_set_option_variation2.phpt
@@ -0,0 +1,215 @@
+--TEST--
+Test xml_parser_set_option() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_parser_set_option(resource parser, int option, mixed value)
+ * Description: Set options in an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parser_set_option() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+$parser = xml_parser_create();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // outside of range int data
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for option
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_parser_set_option($parser, $value, 1) );
+};
+
+xml_parser_free($parser);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parser_set_option() : usage variations ***
+
+Arg value 12345
+
+Warning: xml_parser_set_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value -2345
+
+Warning: xml_parser_set_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value 10.5
+
+Warning: xml_parser_set_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value -10.5
+
+Warning: xml_parser_set_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value 101234567000
+
+Warning: xml_parser_set_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value 1.07654321E-9
+
+Warning: xml_parser_set_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value 0.5
+
+Warning: xml_parser_set_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_parser_set_option() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_set_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_parser_set_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value 1
+bool(true)
+
+Arg value
+
+Warning: xml_parser_set_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value 1
+bool(true)
+
+Arg value
+
+Warning: xml_parser_set_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_parser_set_option() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_set_option() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_parser_set_option() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_parser_set_option() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_parser_set_option() expects parameter 2 to be long, object given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_parser_set_option(): Unknown option in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_parser_set_option(): Unknown option in %s on line %d
+bool(false)
+Done
+
diff --git a/ext/xml/tests/xml_parser_set_option_variation3.phpt b/ext/xml/tests/xml_parser_set_option_variation3.phpt
new file mode 100644
index 0000000..c215ef5
--- /dev/null
+++ b/ext/xml/tests/xml_parser_set_option_variation3.phpt
@@ -0,0 +1,187 @@
+--TEST--
+Test xml_parser_set_option() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_parser_set_option(resource parser, int option, mixed value)
+ * Description: Set options in an XML parser
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_parser_set_option() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+
+$parser = xml_parser_create();
+$option = 1;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for value
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_parser_set_option($parser, $option, $value) );
+};
+
+fclose($fp);
+xml_parser_free($parser);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_parser_set_option() : usage variations ***
+
+Arg value 0
+bool(true)
+
+Arg value 1
+bool(true)
+
+Arg value 12345
+bool(true)
+
+Arg value -2345
+bool(true)
+
+Arg value 10.5
+bool(true)
+
+Arg value -10.5
+bool(true)
+
+Arg value 101234567000
+bool(true)
+
+Arg value 1.07654321E-9
+bool(true)
+
+Arg value 0.5
+bool(true)
+
+Arg value Array
+bool(true)
+
+Arg value Array
+bool(true)
+
+Arg value Array
+bool(true)
+
+Arg value Array
+bool(true)
+
+Arg value Array
+bool(true)
+
+Arg value
+bool(true)
+
+Arg value
+bool(true)
+
+Arg value 1
+bool(true)
+
+Arg value
+bool(true)
+
+Arg value 1
+bool(true)
+
+Arg value
+bool(true)
+
+Arg value
+bool(true)
+
+Arg value
+bool(true)
+
+Arg value string
+bool(true)
+
+Arg value string
+bool(true)
+
+Arg value Some Ascii Data
+bool(true)
+
+Arg value Resource id %s
+bool(true)
+
+Arg value
+bool(true)
+
+Arg value
+bool(true)
+Done
diff --git a/ext/xml/tests/xml_set_character_data_handler_error.phpt b/ext/xml/tests/xml_set_character_data_handler_error.phpt
new file mode 100644
index 0000000..16faaa4
--- /dev/null
+++ b/ext/xml/tests/xml_set_character_data_handler_error.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test xml_set_character_data_handler() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_character_data_handler(resource parser, string hdl)
+ * Description: Set up character data handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_character_data_handler() : error conditions ***\n";
+
+
+//Test xml_set_character_data_handler with one more than the expected number of arguments
+echo "\n-- Testing xml_set_character_data_handler() function with more than expected no. of arguments --\n";
+
+$hdl = 'string_val';
+$extra_arg = 10;
+var_dump( xml_set_character_data_handler(null, $hdl, $extra_arg) );
+
+// Testing xml_set_character_data_handler with one less than the expected number of arguments
+echo "\n-- Testing xml_set_character_data_handler() function with less than expected no. of arguments --\n";
+
+var_dump( xml_set_character_data_handler(null) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_character_data_handler() : error conditions ***
+
+-- Testing xml_set_character_data_handler() function with more than expected no. of arguments --
+
+Warning: xml_set_character_data_handler() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing xml_set_character_data_handler() function with less than expected no. of arguments --
+
+Warning: xml_set_character_data_handler() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_character_data_handler_variation1.phpt b/ext/xml/tests/xml_set_character_data_handler_variation1.phpt
new file mode 100644
index 0000000..40cff91
--- /dev/null
+++ b/ext/xml/tests/xml_set_character_data_handler_variation1.phpt
@@ -0,0 +1,245 @@
+--TEST--
+Test xml_set_character_data_handler() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_character_data_handler(resource parser, string hdl)
+ * Description: Set up character data handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_character_data_handler() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+
+function validHandler(resource $parser ,string $data) {
+}
+
+// Initialise function arguments not being substituted (if any)
+$hdl = 'validHandler';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_set_character_data_handler($value, $hdl) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_character_data_handler() : usage variations ***
+
+Arg value 0
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_set_character_data_handler(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_character_data_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_default_handler_error.phpt b/ext/xml/tests/xml_set_default_handler_error.phpt
new file mode 100644
index 0000000..a4b1b7c
--- /dev/null
+++ b/ext/xml/tests/xml_set_default_handler_error.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test xml_set_default_handler() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_default_handler(resource parser, string hdl)
+ * Description: Set up default handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_default_handler() : error conditions ***\n";
+
+
+//Test xml_set_default_handler with one more than the expected number of arguments
+echo "\n-- Testing xml_set_default_handler() function with more than expected no. of arguments --\n";
+
+$hdl = 'string_val';
+$extra_arg = 10;
+var_dump( xml_set_default_handler(null, $hdl, $extra_arg) );
+
+// Testing xml_set_default_handler with one less than the expected number of arguments
+echo "\n-- Testing xml_set_default_handler() function with less than expected no. of arguments --\n";
+
+var_dump( xml_set_default_handler(null) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_default_handler() : error conditions ***
+
+-- Testing xml_set_default_handler() function with more than expected no. of arguments --
+
+Warning: xml_set_default_handler() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing xml_set_default_handler() function with less than expected no. of arguments --
+
+Warning: xml_set_default_handler() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_default_handler_variation1.phpt b/ext/xml/tests/xml_set_default_handler_variation1.phpt
new file mode 100644
index 0000000..35089a0
--- /dev/null
+++ b/ext/xml/tests/xml_set_default_handler_variation1.phpt
@@ -0,0 +1,245 @@
+--TEST--
+Test xml_set_default_handler() function : usage variations - test different types for parser
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_default_handler(resource parser, string hdl)
+ * Description: Set up default handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_default_handler() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+
+function validHandler(resource $parser ,string $data) {
+}
+
+// Initialise function arguments not being substituted (if any)
+$hdl = 'validHandler';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_set_default_handler($value, $hdl) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_default_handler() : usage variations ***
+
+Arg value 0
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_set_default_handler(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_default_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_element_handler_error.phpt b/ext/xml/tests/xml_set_element_handler_error.phpt
new file mode 100644
index 0000000..6ccaea1
--- /dev/null
+++ b/ext/xml/tests/xml_set_element_handler_error.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test xml_set_element_handler() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_element_handler(resource parser, string shdl, string ehdl)
+ * Description: Set up start and end element handlers
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_element_handler() : error conditions ***\n";
+
+
+//Test xml_set_element_handler with one more than the expected number of arguments
+echo "\n-- Testing xml_set_element_handler() function with more than expected no. of arguments --\n";
+
+$hdl = 'string_val';
+$extra_arg = 10;
+var_dump( xml_set_element_handler(null, $hdl, $hdl, $extra_arg) );
+
+// Testing xml_set_element_handler with one less than the expected number of arguments
+echo "\n-- Testing xml_set_element_handler() function with less than expected no. of arguments --\n";
+
+var_dump( xml_set_element_handler(null) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_element_handler() : error conditions ***
+
+-- Testing xml_set_element_handler() function with more than expected no. of arguments --
+
+Warning: xml_set_element_handler() expects exactly 3 parameters, 4 given in %s on line %d
+NULL
+
+-- Testing xml_set_element_handler() function with less than expected no. of arguments --
+
+Warning: xml_set_element_handler() expects exactly 3 parameters, 1 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_element_handler_variation1.phpt b/ext/xml/tests/xml_set_element_handler_variation1.phpt
new file mode 100644
index 0000000..225cf77
--- /dev/null
+++ b/ext/xml/tests/xml_set_element_handler_variation1.phpt
@@ -0,0 +1,245 @@
+--TEST--
+Test xml_set_element_handler() function : usage variations - test different types for parser
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_element_handler(resource parser, string shdl, string ehdl)
+ * Description: Set up start and end element handlers
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_element_handler() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+
+function validHandler(resource $parser ,string $data) {
+}
+
+// Initialise function arguments not being substituted (if any)
+$hdl = 'validHandler';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_set_element_handler($value, $hdl, $hdl) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_element_handler() : usage variations ***
+
+Arg value 0
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_set_element_handler(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_element_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_end_namespace_decl_handler_error.phpt b/ext/xml/tests/xml_set_end_namespace_decl_handler_error.phpt
new file mode 100644
index 0000000..81bb3f6
--- /dev/null
+++ b/ext/xml/tests/xml_set_end_namespace_decl_handler_error.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test xml_set_end_namespace_decl_handler() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_end_namespace_decl_handler(resource parser, string hdl)
+ * Description: Set up character data handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_end_namespace_decl_handler() : error conditions ***\n";
+
+
+//Test xml_set_end_namespace_decl_handler with one more than the expected number of arguments
+echo "\n-- Testing xml_set_end_namespace_decl_handler() function with more than expected no. of arguments --\n";
+
+$hdl = 'string_val';
+$extra_arg = 10;
+var_dump( xml_set_end_namespace_decl_handler(null, $hdl, $extra_arg) );
+
+// Testing xml_set_end_namespace_decl_handler with one less than the expected number of arguments
+echo "\n-- Testing xml_set_end_namespace_decl_handler() function with less than expected no. of arguments --\n";
+
+var_dump( xml_set_end_namespace_decl_handler(null) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_end_namespace_decl_handler() : error conditions ***
+
+-- Testing xml_set_end_namespace_decl_handler() function with more than expected no. of arguments --
+
+Warning: xml_set_end_namespace_decl_handler() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing xml_set_end_namespace_decl_handler() function with less than expected no. of arguments --
+
+Warning: xml_set_end_namespace_decl_handler() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_end_namespace_decl_handler_variation1.phpt b/ext/xml/tests/xml_set_end_namespace_decl_handler_variation1.phpt
new file mode 100644
index 0000000..c7c2f6f
--- /dev/null
+++ b/ext/xml/tests/xml_set_end_namespace_decl_handler_variation1.phpt
@@ -0,0 +1,245 @@
+--TEST--
+Test xml_set_end_namespace_decl_handler() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_end_namespace_decl_handler(resource parser, string hdl)
+ * Description: Set up character data handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_end_namespace_decl_handler() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+
+function validHandler(resource $parser ,string $data) {
+}
+
+// Initialise function arguments not being substituted (if any)
+$hdl = 'validHandler';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_set_end_namespace_decl_handler($value, $hdl) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_end_namespace_decl_handler() : usage variations ***
+
+Arg value 0
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_set_end_namespace_decl_handler(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_end_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_external_entity_ref_handler_error.phpt b/ext/xml/tests/xml_set_external_entity_ref_handler_error.phpt
new file mode 100644
index 0000000..6dd400a
--- /dev/null
+++ b/ext/xml/tests/xml_set_external_entity_ref_handler_error.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test xml_set_external_entity_ref_handler() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_external_entity_ref_handler(resource parser, string hdl)
+ * Description: Set up external entity reference handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_external_entity_ref_handler() : error conditions ***\n";
+
+
+//Test xml_set_external_entity_ref_handler with one more than the expected number of arguments
+echo "\n-- Testing xml_set_external_entity_ref_handler() function with more than expected no. of arguments --\n";
+
+$hdl = 'string_val';
+$extra_arg = 10;
+var_dump( xml_set_external_entity_ref_handler(null, $hdl, $extra_arg) );
+
+// Testing xml_set_external_entity_ref_handler with one less than the expected number of arguments
+echo "\n-- Testing xml_set_external_entity_ref_handler() function with less than expected no. of arguments --\n";
+
+var_dump( xml_set_external_entity_ref_handler(null) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_external_entity_ref_handler() : error conditions ***
+
+-- Testing xml_set_external_entity_ref_handler() function with more than expected no. of arguments --
+
+Warning: xml_set_external_entity_ref_handler() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing xml_set_external_entity_ref_handler() function with less than expected no. of arguments --
+
+Warning: xml_set_external_entity_ref_handler() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_external_entity_ref_handler_variation1.phpt b/ext/xml/tests/xml_set_external_entity_ref_handler_variation1.phpt
new file mode 100644
index 0000000..10835b3
--- /dev/null
+++ b/ext/xml/tests/xml_set_external_entity_ref_handler_variation1.phpt
@@ -0,0 +1,245 @@
+--TEST--
+Test xml_set_external_entity_ref_handler() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_external_entity_ref_handler(resource parser, string hdl)
+ * Description: Set up external entity reference handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_external_entity_ref_handler() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+
+function validHandler(resource $parser ,string $data) {
+}
+
+// Initialise function arguments not being substituted (if any)
+$hdl = 'validHandler';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_set_external_entity_ref_handler($value, $hdl) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_external_entity_ref_handler() : usage variations ***
+
+Arg value 0
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_set_external_entity_ref_handler(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_external_entity_ref_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_notation_decl_handler_basic.phpt b/ext/xml/tests/xml_set_notation_decl_handler_basic.phpt
new file mode 100644
index 0000000..6616681
--- /dev/null
+++ b/ext/xml/tests/xml_set_notation_decl_handler_basic.phpt
@@ -0,0 +1,102 @@
+--TEST--
+Test xml_set_notation_decl_handler function : basic
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto bool xml_set_notation_decl_handler ( resource $parser , callback $handler )
+ * Description: Sets the notation declaration handler function for the XML parser.
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+class XML_Parser
+{
+
+ function unparsed_entity_decl_handler($parser, $entity_name, $base, $system_ID, $public_ID, $notation_name)
+ {
+ echo "unparsed_entity_decl_handler called\n";
+ echo "...Entity name=" . $entity_name . "\n";
+ echo "...Base=" . $base . "\n";
+ echo "...System ID=" . $system_ID . "\n";
+ echo "...Public ID=" . $public_ID . "\n";
+ echo "...Notation name=" . $notation_name . "\n";
+ }
+
+ function notation_decl_handler($parser, $name, $base, $system_ID,$public_ID)
+ {
+ echo "notation_decl_handler called\n";
+ echo "...Name=" . $name . "\n";
+ echo "...Base=" . $base . "\n";
+ echo "...System ID=" . $system_ID . "\n";
+ echo "...Public ID=" . $public_ID . "\n";
+ }
+
+ function parse($data)
+ {
+ $parser = xml_parser_create();
+ xml_set_object($parser, $this);
+ xml_set_notation_decl_handler($parser, "notation_decl_handler");
+ xml_set_unparsed_entity_decl_handler($parser, "unparsed_entity_decl_handler");
+ xml_parse($parser, $data, true);
+ xml_parser_free($parser);
+ }
+}
+
+$xml = <<<HERE
+<?xml version="1.0"?>
+<!DOCTYPE dates [
+ <!NOTATION USDATE SYSTEM "http://www.schema.net/usdate.not">
+ <!NOTATION AUSDATE SYSTEM "http://www.schema.net/ausdate.not">
+ <!NOTATION ISODATE SYSTEM "http://www.schema.net/isodate.not">
+ <!ENTITY testUS SYSTEM "test_usdate.xml" NDATA USDATE>
+ <!ENTITY testAUS SYSTEM "test_ausdate.xml" NDATA AUSDATE>
+ <!ENTITY testISO SYSTEM "test_isodate_xml" NDATA ISODATE>]>
+]>
+HERE;
+
+echo "Simple test of xml_set_notation_decl_handler(() function\n";
+$p1 = new Xml_Parser();
+$p1->parse($xml);
+echo "Done\n";
+?>
+--EXPECT--
+Simple test of xml_set_notation_decl_handler(() function
+notation_decl_handler called
+...Name=USDATE
+...Base=
+...System ID=http://www.schema.net/usdate.not
+...Public ID=
+notation_decl_handler called
+...Name=AUSDATE
+...Base=
+...System ID=http://www.schema.net/ausdate.not
+...Public ID=
+notation_decl_handler called
+...Name=ISODATE
+...Base=
+...System ID=http://www.schema.net/isodate.not
+...Public ID=
+unparsed_entity_decl_handler called
+...Entity name=testUS
+...Base=
+...System ID=test_usdate.xml
+...Public ID=
+...Notation name=USDATE
+unparsed_entity_decl_handler called
+...Entity name=testAUS
+...Base=
+...System ID=test_ausdate.xml
+...Public ID=
+...Notation name=AUSDATE
+unparsed_entity_decl_handler called
+...Entity name=testISO
+...Base=
+...System ID=test_isodate_xml
+...Public ID=
+...Notation name=ISODATE
+Done
diff --git a/ext/xml/tests/xml_set_notation_decl_handler_error.phpt b/ext/xml/tests/xml_set_notation_decl_handler_error.phpt
new file mode 100644
index 0000000..fccc135
--- /dev/null
+++ b/ext/xml/tests/xml_set_notation_decl_handler_error.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test xml_set_notation_decl_handler() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_notation_decl_handler(resource parser, string hdl)
+ * Description: Set up notation declaration handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_notation_decl_handler() : error conditions ***\n";
+
+
+//Test xml_set_notation_decl_handler with one more than the expected number of arguments
+echo "\n-- Testing xml_set_notation_decl_handler() function with more than expected no. of arguments --\n";
+
+$hdl = 'string_val';
+$extra_arg = 10;
+var_dump( xml_set_notation_decl_handler(null, $hdl, $extra_arg) );
+
+// Testing xml_set_notation_decl_handler with one less than the expected number of arguments
+echo "\n-- Testing xml_set_notation_decl_handler() function with less than expected no. of arguments --\n";
+
+var_dump( xml_set_notation_decl_handler(null) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_notation_decl_handler() : error conditions ***
+
+-- Testing xml_set_notation_decl_handler() function with more than expected no. of arguments --
+
+Warning: xml_set_notation_decl_handler() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing xml_set_notation_decl_handler() function with less than expected no. of arguments --
+
+Warning: xml_set_notation_decl_handler() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_notation_decl_handler_variation1.phpt b/ext/xml/tests/xml_set_notation_decl_handler_variation1.phpt
new file mode 100644
index 0000000..d41e691
--- /dev/null
+++ b/ext/xml/tests/xml_set_notation_decl_handler_variation1.phpt
@@ -0,0 +1,245 @@
+--TEST--
+Test xml_set_notation_decl_handler() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_notation_decl_handler(resource parser, string hdl)
+ * Description: Set up notation declaration handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_notation_decl_handler() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+
+function validHandler(resource $parser ,string $data) {
+}
+
+// Initialise function arguments not being substituted (if any)
+$hdl = 'validHandler';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_set_notation_decl_handler($value, $hdl) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_notation_decl_handler() : usage variations ***
+
+Arg value 0
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_set_notation_decl_handler(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_notation_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_object_error.phpt b/ext/xml/tests/xml_set_object_error.phpt
new file mode 100644
index 0000000..db3266e
--- /dev/null
+++ b/ext/xml/tests/xml_set_object_error.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Test xml_set_object() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_object(resource parser, object &obj)
+ * Description: Set up object which should be used for callbacks
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_object() : error conditions ***\n";
+
+
+//Test xml_set_object with one more than the expected number of arguments
+echo "\n-- Testing xml_set_object() function with more than expected no. of arguments --\n";
+
+//WARNING: Unable to initialise parser of type resource
+
+$obj = new stdclass();
+$extra_arg = 10;
+var_dump( xml_set_object(null, $obj, $extra_arg) );
+
+// Testing xml_set_object with one less than the expected number of arguments
+echo "\n-- Testing xml_set_object() function with less than expected no. of arguments --\n";
+
+//WARNING: Unable to initialise parser of type resource
+
+var_dump( xml_set_object(null) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_object() : error conditions ***
+
+-- Testing xml_set_object() function with more than expected no. of arguments --
+
+Warning: xml_set_object() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing xml_set_object() function with less than expected no. of arguments --
+
+Warning: xml_set_object() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_object_variation1.phpt b/ext/xml/tests/xml_set_object_variation1.phpt
new file mode 100644
index 0000000..851dfaf
--- /dev/null
+++ b/ext/xml/tests/xml_set_object_variation1.phpt
@@ -0,0 +1,241 @@
+--TEST--
+Test xml_set_object() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_object(resource parser, object &obj)
+ * Description: Set up object which should be used for callbacks
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_object() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+// Initialise function arguments not being substituted (if any)
+$obj = new aClass();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_set_object($value, $obj) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_object() : usage variations ***
+
+Arg value 0
+
+Warning: xml_set_object() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_object() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_set_object() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_set_object() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_set_object() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_set_object() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_set_object() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_set_object() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_set_object() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_object() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_object() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_object() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_object() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_object() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_object() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_object() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_object() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_object() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_set_object() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_set_object(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_set_object() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_object_variation2.phpt b/ext/xml/tests/xml_set_object_variation2.phpt
new file mode 100644
index 0000000..0844661
--- /dev/null
+++ b/ext/xml/tests/xml_set_object_variation2.phpt
@@ -0,0 +1,230 @@
+--TEST--
+Test xml_set_object() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_object(resource parser, object &obj)
+ * Description: Set up object which should be used for callbacks
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_object() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+// Initialise function arguments not being substituted (if any)
+
+$parser = xml_parser_create();
+$fp = fopen(__FILE__, "r");
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for obj
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_set_object($parser, $value) );
+};
+
+xml_parser_free($parser);
+fclose($fp);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_object() : usage variations ***
+
+Arg value 0
+
+Warning: xml_set_object() expects parameter 2 to be object, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_object() expects parameter 2 to be object, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_set_object() expects parameter 2 to be object, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_set_object() expects parameter 2 to be object, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_set_object() expects parameter 2 to be object, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_set_object() expects parameter 2 to be object, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_set_object() expects parameter 2 to be object, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_set_object() expects parameter 2 to be object, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_set_object() expects parameter 2 to be object, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 2 to be object, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 2 to be object, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_object() expects parameter 2 to be object, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 2 to be object, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_object() expects parameter 2 to be object, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 2 to be object, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 2 to be object, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 2 to be object, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_object() expects parameter 2 to be object, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_object() expects parameter 2 to be object, string given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_set_object() expects parameter 2 to be object, resource given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 2 to be object, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_object() expects parameter 2 to be object, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_processing_instruction_handler_basic.phpt b/ext/xml/tests/xml_set_processing_instruction_handler_basic.phpt
new file mode 100644
index 0000000..e5589ce
--- /dev/null
+++ b/ext/xml/tests/xml_set_processing_instruction_handler_basic.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Test xml_set_processing_instruction_handler function : basic
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto bool xml_set_processing_instruction_handler ( resource $parser , callback $handler )
+ * Description: Sets the processing instruction (PI) handler function for the XML parser.
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+class XML_Parser
+{
+
+ function PIHandler($parser, $target, $data)
+ {
+ echo "Target: " . $target. "\n";
+ echo "Data: " . $data . "\n";
+ }
+
+ function parse($data)
+ {
+ $parser = xml_parser_create();
+ xml_set_object($parser, $this);
+ xml_set_processing_instruction_handler($parser, "PIHandler");
+ xml_parse($parser, $data, true);
+ xml_parser_free($parser);
+ }
+
+
+}
+
+$xml = <<<HERE
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml-stylesheet href="default.xsl" type="text/xml"?>
+HERE;
+
+echo "Simple test of xml_set_processing_instruction_handler() function\n";
+$p1 = new Xml_Parser();
+$p1->parse($xml);
+echo "Done\n";
+?>
+--EXPECT--
+Simple test of xml_set_processing_instruction_handler() function
+Target: xml-stylesheet
+Data: href="default.xsl" type="text/xml"
+Done \ No newline at end of file
diff --git a/ext/xml/tests/xml_set_processing_instruction_handler_error.phpt b/ext/xml/tests/xml_set_processing_instruction_handler_error.phpt
new file mode 100644
index 0000000..f2a8494
--- /dev/null
+++ b/ext/xml/tests/xml_set_processing_instruction_handler_error.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test xml_set_processing_instruction_handler() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_processing_instruction_handler(resource parser, string hdl)
+ * Description: Set up processing instruction (PI) handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_processing_instruction_handler() : error conditions ***\n";
+
+
+//Test xml_set_processing_instruction_handler with one more than the expected number of arguments
+echo "\n-- Testing xml_set_processing_instruction_handler() function with more than expected no. of arguments --\n";
+
+$hdl = 'string_val';
+$extra_arg = 10;
+var_dump( xml_set_processing_instruction_handler(null, $hdl, $extra_arg) );
+
+// Testing xml_set_processing_instruction_handler with one less than the expected number of arguments
+echo "\n-- Testing xml_set_processing_instruction_handler() function with less than expected no. of arguments --\n";
+
+var_dump( xml_set_processing_instruction_handler(null) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_processing_instruction_handler() : error conditions ***
+
+-- Testing xml_set_processing_instruction_handler() function with more than expected no. of arguments --
+
+Warning: xml_set_processing_instruction_handler() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing xml_set_processing_instruction_handler() function with less than expected no. of arguments --
+
+Warning: xml_set_processing_instruction_handler() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_processing_instruction_handler_variation1.phpt b/ext/xml/tests/xml_set_processing_instruction_handler_variation1.phpt
new file mode 100644
index 0000000..9da14cc
--- /dev/null
+++ b/ext/xml/tests/xml_set_processing_instruction_handler_variation1.phpt
@@ -0,0 +1,245 @@
+--TEST--
+Test xml_set_processing_instruction_handler() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_processing_instruction_handler(resource parser, string hdl)
+ * Description: Set up processing instruction (PI) handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_processing_instruction_handler() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+
+function validHandler(resource $parser ,string $data) {
+}
+
+// Initialise function arguments not being substituted (if any)
+$hdl = 'validHandler';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_set_processing_instruction_handler($value, $hdl) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_processing_instruction_handler() : usage variations ***
+
+Arg value 0
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_set_processing_instruction_handler(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_processing_instruction_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_start_namespace_decl_handler_basic.phpt b/ext/xml/tests/xml_set_start_namespace_decl_handler_basic.phpt
new file mode 100644
index 0000000..79b8cb8
--- /dev/null
+++ b/ext/xml/tests/xml_set_start_namespace_decl_handler_basic.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Test xml_set_start_namespace_decl_handler function: basic
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool xml_set_start_namespace_decl_handler ( resource $parser , callback $handler )
+ * Description: Set up start namespace declaration handler.
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+$xml = <<<HERE
+<aw1:book xmlns:aw1="http://www.somewhere.com/namespace1"
+ xmlns:aw2="file:/DTD/somewhere.dtd">
+<aw1:para>Any old text.</aw1:para>
+<aw2:td>An HTML table cell.</aw2:td>
+</aw1:book>
+HERE;
+
+$parser = xml_parser_create_ns();
+xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
+
+var_dump(xml_set_start_namespace_decl_handler( $parser, "Namespace_Start_Handler" ));
+var_dump(xml_set_end_namespace_decl_handler( $parser, "Namespace_End_Handler" ));
+
+xml_parse( $parser, $xml, true);
+xml_parser_free( $parser );
+
+echo "Done\n";
+
+function Namespace_Start_Handler( $parser, $prefix, $uri ) {
+ echo "Namespace_Start_Handler called\n";
+ echo "...Prefix: ". $prefix . "\n";
+ echo "...Uri: ". $uri . "\n";
+}
+
+function Namespace_End_Handler($parser, $prefix) {
+ echo "Namespace_End_Handler called\n";
+ echo "...Prefix: ". $prefix . "\n\n";
+}
+
+function DefaultHandler( $parser, $data ) {
+ print( 'DefaultHandler Called<br/>' );
+}
+?>
+--EXPECT--
+bool(true)
+bool(true)
+Namespace_Start_Handler called
+...Prefix: aw1
+...Uri: http://www.somewhere.com/namespace1
+Namespace_Start_Handler called
+...Prefix: aw2
+...Uri: file:/DTD/somewhere.dtd
+Done
+
diff --git a/ext/xml/tests/xml_set_start_namespace_decl_handler_error.phpt b/ext/xml/tests/xml_set_start_namespace_decl_handler_error.phpt
new file mode 100644
index 0000000..221b005
--- /dev/null
+++ b/ext/xml/tests/xml_set_start_namespace_decl_handler_error.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test xml_set_start_namespace_decl_handler() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_start_namespace_decl_handler(resource parser, string hdl)
+ * Description: Set up character data handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_start_namespace_decl_handler() : error conditions ***\n";
+
+
+//Test xml_set_start_namespace_decl_handler with one more than the expected number of arguments
+echo "\n-- Testing xml_set_start_namespace_decl_handler() function with more than expected no. of arguments --\n";
+
+$hdl = 'string_val';
+$extra_arg = 10;
+var_dump( xml_set_start_namespace_decl_handler(null, $hdl, $extra_arg) );
+
+// Testing xml_set_start_namespace_decl_handler with one less than the expected number of arguments
+echo "\n-- Testing xml_set_start_namespace_decl_handler() function with less than expected no. of arguments --\n";
+
+var_dump( xml_set_start_namespace_decl_handler(null) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_start_namespace_decl_handler() : error conditions ***
+
+-- Testing xml_set_start_namespace_decl_handler() function with more than expected no. of arguments --
+
+Warning: xml_set_start_namespace_decl_handler() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing xml_set_start_namespace_decl_handler() function with less than expected no. of arguments --
+
+Warning: xml_set_start_namespace_decl_handler() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_start_namespace_decl_handler_variation1.phpt b/ext/xml/tests/xml_set_start_namespace_decl_handler_variation1.phpt
new file mode 100644
index 0000000..684a0fd
--- /dev/null
+++ b/ext/xml/tests/xml_set_start_namespace_decl_handler_variation1.phpt
@@ -0,0 +1,245 @@
+--TEST--
+Test xml_set_start_namespace_decl_handler() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_start_namespace_decl_handler(resource parser, string hdl)
+ * Description: Set up character data handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_start_namespace_decl_handler() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+
+function validHandler(resource $parser ,string $data) {
+}
+
+// Initialise function arguments not being substituted (if any)
+$hdl = 'validHandler';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_set_start_namespace_decl_handler($value, $hdl) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_start_namespace_decl_handler() : usage variations ***
+
+Arg value 0
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_set_start_namespace_decl_handler(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_start_namespace_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_unparsed_entity_decl_handler_error.phpt b/ext/xml/tests/xml_set_unparsed_entity_decl_handler_error.phpt
new file mode 100644
index 0000000..952a698
--- /dev/null
+++ b/ext/xml/tests/xml_set_unparsed_entity_decl_handler_error.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test xml_set_unparsed_entity_decl_handler() function : error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_unparsed_entity_decl_handler(resource parser, string hdl)
+ * Description: Set up unparsed entity declaration handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_unparsed_entity_decl_handler() : error conditions ***\n";
+
+
+//Test xml_set_unparsed_entity_decl_handler with one more than the expected number of arguments
+echo "\n-- Testing xml_set_unparsed_entity_decl_handler() function with more than expected no. of arguments --\n";
+
+$hdl = 'string_val';
+$extra_arg = 10;
+var_dump( xml_set_unparsed_entity_decl_handler(null, $hdl, $extra_arg) );
+
+// Testing xml_set_unparsed_entity_decl_handler with one less than the expected number of arguments
+echo "\n-- Testing xml_set_unparsed_entity_decl_handler() function with less than expected no. of arguments --\n";
+
+var_dump( xml_set_unparsed_entity_decl_handler(null) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_unparsed_entity_decl_handler() : error conditions ***
+
+-- Testing xml_set_unparsed_entity_decl_handler() function with more than expected no. of arguments --
+
+Warning: xml_set_unparsed_entity_decl_handler() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing xml_set_unparsed_entity_decl_handler() function with less than expected no. of arguments --
+
+Warning: xml_set_unparsed_entity_decl_handler() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xml_set_unparsed_entity_decl_handler_variation1.phpt b/ext/xml/tests/xml_set_unparsed_entity_decl_handler_variation1.phpt
new file mode 100644
index 0000000..1804115
--- /dev/null
+++ b/ext/xml/tests/xml_set_unparsed_entity_decl_handler_variation1.phpt
@@ -0,0 +1,245 @@
+--TEST--
+Test xml_set_unparsed_entity_decl_handler() function : usage variations
+--SKIPIF--
+<?php
+if (!extension_loaded("xml")) {
+ print "skip - XML extension not loaded";
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto int xml_set_unparsed_entity_decl_handler(resource parser, string hdl)
+ * Description: Set up unparsed entity declaration handler
+ * Source code: ext/xml/xml.c
+ * Alias to functions:
+ */
+
+echo "*** Testing xml_set_unparsed_entity_decl_handler() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+class aClass {
+ function __toString() {
+ return "Some Ascii Data";
+ }
+}
+
+function validHandler(resource $parser ,string $data) {
+}
+
+// Initialise function arguments not being substituted (if any)
+$hdl = 'validHandler';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+$fp = fopen(__FILE__, "r");
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new aClass(),
+
+ // resource data
+ $fp,
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for parser
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( xml_set_unparsed_entity_decl_handler($value, $hdl) );
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing xml_set_unparsed_entity_decl_handler() : usage variations ***
+
+Arg value 0
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 12345
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value -2345
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Arg value 10.5
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value -10.5
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 101234567000
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 1.07654321E-9
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value 0.5
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value Array
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value 1
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value string
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Arg value Some Ascii Data
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Arg value Resource id %s
+
+Warning: xml_set_unparsed_entity_decl_handler(): supplied resource is not a valid XML Parser resource in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Arg value
+
+Warning: xml_set_unparsed_entity_decl_handler() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+Done
+
diff --git a/ext/xml/tests/xmltest.xml b/ext/xml/tests/xmltest.xml
new file mode 100644
index 0000000..c15d6ea
--- /dev/null
+++ b/ext/xml/tests/xmltest.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE phptest SYSTEM "notfound.dtd" [
+<!ENTITY % incent SYSTEM "inc.ent">
+%incent;
+]>
+<root id="elem1">
+ Plain text.
+ <elem1>
+ <!-- comment -->
+ <elem2>
+ <![CDATA[CDATA block]]>
+ <elem3>
+ &included-entity;
+ <elem4>
+ <?test processing instruction ?>
+ </elem4>
+ </elem3>
+ </elem2>
+ </elem1>
+</root>
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
new file mode 100644
index 0000000..2fea4f8
--- /dev/null
+++ b/ext/xml/xml.c
@@ -0,0 +1,1729 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2013 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. |
+ +----------------------------------------------------------------------+
+ | Authors: Stig Sæther Bakken <ssb@php.net> |
+ | Thies C. Arntzen <thies@thieso.net> |
+ | Sterling Hughes <sterling@php.net> |
+ +----------------------------------------------------------------------+
+ */
+
+/* $Id$ */
+
+#define IS_EXT_MODULE
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+
+#define PHP_XML_INTERNAL
+#include "zend_variables.h"
+#include "ext/standard/php_string.h"
+#include "ext/standard/info.h"
+#include "ext/standard/html.h"
+
+#if HAVE_XML
+
+#include "php_xml.h"
+# include "ext/standard/head.h"
+#ifdef LIBXML_EXPAT_COMPAT
+#include "ext/libxml/php_libxml.h"
+#endif
+
+/* Short-term TODO list:
+ * - Implement XML_ExternalEntityParserCreate()
+ * - XML_SetCommentHandler
+ * - XML_SetCdataSectionHandler
+ * - XML_SetParamEntityParsing
+ */
+
+/* Long-term TODO list:
+ * - Fix the expat library so you can install your own memory manager
+ * functions
+ */
+
+/* Known bugs:
+ * - Weird things happen with <![CDATA[]]> sections.
+ */
+
+ZEND_DECLARE_MODULE_GLOBALS(xml)
+
+/* {{{ dynamically loadable module stuff */
+#ifdef COMPILE_DL_XML
+ZEND_GET_MODULE(xml)
+#endif /* COMPILE_DL_XML */
+/* }}} */
+
+/* {{{ function prototypes */
+PHP_MINIT_FUNCTION(xml);
+PHP_MINFO_FUNCTION(xml);
+static PHP_GINIT_FUNCTION(xml);
+
+static void xml_parser_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC);
+static void xml_set_handler(zval **, zval **);
+inline static unsigned short xml_encode_iso_8859_1(unsigned char);
+inline static char xml_decode_iso_8859_1(unsigned short);
+inline static unsigned short xml_encode_us_ascii(unsigned char);
+inline static char xml_decode_us_ascii(unsigned short);
+static zval *xml_call_handler(xml_parser *, zval *, zend_function *, int, zval **);
+static zval *_xml_xmlchar_zval(const XML_Char *, int, const XML_Char *);
+static int _xml_xmlcharlen(const XML_Char *);
+static void _xml_add_to_info(xml_parser *parser,char *name);
+inline static char *_xml_decode_tag(xml_parser *parser, const char *tag);
+
+void _xml_startElementHandler(void *, const XML_Char *, const XML_Char **);
+void _xml_endElementHandler(void *, const XML_Char *);
+void _xml_characterDataHandler(void *, const XML_Char *, int);
+void _xml_processingInstructionHandler(void *, const XML_Char *, const XML_Char *);
+void _xml_defaultHandler(void *, const XML_Char *, int);
+void _xml_unparsedEntityDeclHandler(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
+void _xml_notationDeclHandler(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
+int _xml_externalEntityRefHandler(XML_Parser, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
+
+void _xml_startNamespaceDeclHandler(void *, const XML_Char *, const XML_Char *);
+void _xml_endNamespaceDeclHandler(void *, const XML_Char *);
+/* }}} */
+
+/* {{{ extension definition structures */
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_parser_create, 0, 0, 0)
+ ZEND_ARG_INFO(0, encoding)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_parser_create_ns, 0, 0, 0)
+ ZEND_ARG_INFO(0, encoding)
+ ZEND_ARG_INFO(0, sep)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_set_object, 0, 0, 2)
+ ZEND_ARG_INFO(0, parser)
+ ZEND_ARG_INFO(1, obj)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_set_element_handler, 0, 0, 3)
+ ZEND_ARG_INFO(0, parser)
+ ZEND_ARG_INFO(0, shdl)
+ ZEND_ARG_INFO(0, ehdl)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_set_character_data_handler, 0, 0, 2)
+ ZEND_ARG_INFO(0, parser)
+ ZEND_ARG_INFO(0, hdl)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_set_processing_instruction_handler, 0, 0, 2)
+ ZEND_ARG_INFO(0, parser)
+ ZEND_ARG_INFO(0, hdl)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_set_default_handler, 0, 0, 2)
+ ZEND_ARG_INFO(0, parser)
+ ZEND_ARG_INFO(0, hdl)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_set_unparsed_entity_decl_handler, 0, 0, 2)
+ ZEND_ARG_INFO(0, parser)
+ ZEND_ARG_INFO(0, hdl)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_set_notation_decl_handler, 0, 0, 2)
+ ZEND_ARG_INFO(0, parser)
+ ZEND_ARG_INFO(0, hdl)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_set_external_entity_ref_handler, 0, 0, 2)
+ ZEND_ARG_INFO(0, parser)
+ ZEND_ARG_INFO(0, hdl)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_set_start_namespace_decl_handler, 0, 0, 2)
+ ZEND_ARG_INFO(0, parser)
+ ZEND_ARG_INFO(0, hdl)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_set_end_namespace_decl_handler, 0, 0, 2)
+ ZEND_ARG_INFO(0, parser)
+ ZEND_ARG_INFO(0, hdl)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_parse, 0, 0, 2)
+ ZEND_ARG_INFO(0, parser)
+ ZEND_ARG_INFO(0, data)
+ ZEND_ARG_INFO(0, isfinal)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_parse_into_struct, 0, 0, 3)
+ ZEND_ARG_INFO(0, parser)
+ ZEND_ARG_INFO(0, data)
+ ZEND_ARG_INFO(1, values)
+ ZEND_ARG_INFO(1, index)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_get_error_code, 0, 0, 1)
+ ZEND_ARG_INFO(0, parser)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_error_string, 0, 0, 1)
+ ZEND_ARG_INFO(0, code)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_get_current_line_number, 0, 0, 1)
+ ZEND_ARG_INFO(0, parser)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_get_current_column_number, 0, 0, 1)
+ ZEND_ARG_INFO(0, parser)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_get_current_byte_index, 0, 0, 1)
+ ZEND_ARG_INFO(0, parser)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_parser_free, 0, 0, 1)
+ ZEND_ARG_INFO(0, parser)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_parser_set_option, 0, 0, 3)
+ ZEND_ARG_INFO(0, parser)
+ ZEND_ARG_INFO(0, option)
+ ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_xml_parser_get_option, 0, 0, 2)
+ ZEND_ARG_INFO(0, parser)
+ ZEND_ARG_INFO(0, option)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_utf8_encode, 0, 0, 1)
+ ZEND_ARG_INFO(0, data)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_utf8_decode, 0, 0, 1)
+ ZEND_ARG_INFO(0, data)
+ZEND_END_ARG_INFO()
+
+const zend_function_entry xml_functions[] = {
+ PHP_FE(xml_parser_create, arginfo_xml_parser_create)
+ PHP_FE(xml_parser_create_ns, arginfo_xml_parser_create_ns)
+ PHP_FE(xml_set_object, arginfo_xml_set_object)
+ PHP_FE(xml_set_element_handler, arginfo_xml_set_element_handler)
+ PHP_FE(xml_set_character_data_handler, arginfo_xml_set_character_data_handler)
+ PHP_FE(xml_set_processing_instruction_handler, arginfo_xml_set_processing_instruction_handler)
+ PHP_FE(xml_set_default_handler, arginfo_xml_set_default_handler)
+ PHP_FE(xml_set_unparsed_entity_decl_handler,arginfo_xml_set_unparsed_entity_decl_handler)
+ PHP_FE(xml_set_notation_decl_handler, arginfo_xml_set_notation_decl_handler)
+ PHP_FE(xml_set_external_entity_ref_handler, arginfo_xml_set_external_entity_ref_handler)
+ PHP_FE(xml_set_start_namespace_decl_handler,arginfo_xml_set_start_namespace_decl_handler)
+ PHP_FE(xml_set_end_namespace_decl_handler, arginfo_xml_set_end_namespace_decl_handler)
+ PHP_FE(xml_parse, arginfo_xml_parse)
+ PHP_FE(xml_parse_into_struct, arginfo_xml_parse_into_struct)
+ PHP_FE(xml_get_error_code, arginfo_xml_get_error_code)
+ PHP_FE(xml_error_string, arginfo_xml_error_string)
+ PHP_FE(xml_get_current_line_number, arginfo_xml_get_current_line_number)
+ PHP_FE(xml_get_current_column_number, arginfo_xml_get_current_column_number)
+ PHP_FE(xml_get_current_byte_index, arginfo_xml_get_current_byte_index)
+ PHP_FE(xml_parser_free, arginfo_xml_parser_free)
+ PHP_FE(xml_parser_set_option, arginfo_xml_parser_set_option)
+ PHP_FE(xml_parser_get_option, arginfo_xml_parser_get_option)
+ PHP_FE(utf8_encode, arginfo_utf8_encode)
+ PHP_FE(utf8_decode, arginfo_utf8_decode)
+ PHP_FE_END
+};
+
+#ifdef LIBXML_EXPAT_COMPAT
+static const zend_module_dep xml_deps[] = {
+ ZEND_MOD_REQUIRED("libxml")
+ ZEND_MOD_END
+};
+#endif
+
+zend_module_entry xml_module_entry = {
+#ifdef LIBXML_EXPAT_COMPAT
+ STANDARD_MODULE_HEADER_EX, NULL,
+ xml_deps,
+#else
+ STANDARD_MODULE_HEADER,
+#endif
+ "xml", /* extension name */
+ xml_functions, /* extension function list */
+ PHP_MINIT(xml), /* extension-wide startup function */
+ NULL, /* extension-wide shutdown function */
+ NULL, /* per-request startup function */
+ NULL, /* per-request shutdown function */
+ PHP_MINFO(xml), /* information function */
+ NO_VERSION_YET,
+ PHP_MODULE_GLOBALS(xml), /* globals descriptor */
+ PHP_GINIT(xml), /* globals ctor */
+ NULL, /* globals dtor */
+ NULL, /* post deactivate */
+ STANDARD_MODULE_PROPERTIES_EX
+};
+
+/* All the encoding functions are set to NULL right now, since all
+ * the encoding is currently done internally by expat/xmltok.
+ */
+xml_encoding xml_encodings[] = {
+ { "ISO-8859-1", xml_decode_iso_8859_1, xml_encode_iso_8859_1 },
+ { "US-ASCII", xml_decode_us_ascii, xml_encode_us_ascii },
+ { "UTF-8", NULL, NULL },
+ { NULL, NULL, NULL }
+};
+
+static XML_Memory_Handling_Suite php_xml_mem_hdlrs;
+
+/* True globals, no need for thread safety */
+static int le_xml_parser;
+
+/* }}} */
+
+/* {{{ startup, shutdown and info functions */
+static PHP_GINIT_FUNCTION(xml)
+{
+ xml_globals->default_encoding = "UTF-8";
+}
+
+static void *php_xml_malloc_wrapper(size_t sz)
+{
+ return emalloc(sz);
+}
+
+static void *php_xml_realloc_wrapper(void *ptr, size_t sz)
+{
+ return erealloc(ptr, sz);
+}
+
+static void php_xml_free_wrapper(void *ptr)
+{
+ if (ptr != NULL) {
+ efree(ptr);
+ }
+}
+
+PHP_MINIT_FUNCTION(xml)
+{
+ le_xml_parser = zend_register_list_destructors_ex(xml_parser_dtor, NULL, "xml", module_number);
+
+ REGISTER_LONG_CONSTANT("XML_ERROR_NONE", XML_ERROR_NONE, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_NO_MEMORY", XML_ERROR_NO_MEMORY, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_SYNTAX", XML_ERROR_SYNTAX, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_NO_ELEMENTS", XML_ERROR_NO_ELEMENTS, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_INVALID_TOKEN", XML_ERROR_INVALID_TOKEN, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_UNCLOSED_TOKEN", XML_ERROR_UNCLOSED_TOKEN, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_PARTIAL_CHAR", XML_ERROR_PARTIAL_CHAR, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_TAG_MISMATCH", XML_ERROR_TAG_MISMATCH, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_DUPLICATE_ATTRIBUTE", XML_ERROR_DUPLICATE_ATTRIBUTE, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_JUNK_AFTER_DOC_ELEMENT", XML_ERROR_JUNK_AFTER_DOC_ELEMENT, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_PARAM_ENTITY_REF", XML_ERROR_PARAM_ENTITY_REF, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_UNDEFINED_ENTITY", XML_ERROR_UNDEFINED_ENTITY, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_RECURSIVE_ENTITY_REF", XML_ERROR_RECURSIVE_ENTITY_REF, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_ASYNC_ENTITY", XML_ERROR_ASYNC_ENTITY, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_BAD_CHAR_REF", XML_ERROR_BAD_CHAR_REF, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_BINARY_ENTITY_REF", XML_ERROR_BINARY_ENTITY_REF, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF", XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_MISPLACED_XML_PI", XML_ERROR_MISPLACED_XML_PI, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_UNKNOWN_ENCODING", XML_ERROR_UNKNOWN_ENCODING, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_INCORRECT_ENCODING", XML_ERROR_INCORRECT_ENCODING, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_UNCLOSED_CDATA_SECTION", XML_ERROR_UNCLOSED_CDATA_SECTION, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_ERROR_EXTERNAL_ENTITY_HANDLING", XML_ERROR_EXTERNAL_ENTITY_HANDLING, CONST_CS|CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("XML_OPTION_CASE_FOLDING", PHP_XML_OPTION_CASE_FOLDING, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_OPTION_TARGET_ENCODING", PHP_XML_OPTION_TARGET_ENCODING, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_OPTION_SKIP_TAGSTART", PHP_XML_OPTION_SKIP_TAGSTART, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_OPTION_SKIP_WHITE", PHP_XML_OPTION_SKIP_WHITE, CONST_CS|CONST_PERSISTENT);
+
+ /* this object should not be pre-initialised at compile time,
+ as the order of members may vary */
+
+ php_xml_mem_hdlrs.malloc_fcn = php_xml_malloc_wrapper;
+ php_xml_mem_hdlrs.realloc_fcn = php_xml_realloc_wrapper;
+ php_xml_mem_hdlrs.free_fcn = php_xml_free_wrapper;
+
+#ifdef LIBXML_EXPAT_COMPAT
+ REGISTER_STRING_CONSTANT("XML_SAX_IMPL", "libxml", CONST_CS|CONST_PERSISTENT);
+#else
+ REGISTER_STRING_CONSTANT("XML_SAX_IMPL", "expat", CONST_CS|CONST_PERSISTENT);
+#endif
+
+ return SUCCESS;
+}
+
+PHP_MINFO_FUNCTION(xml)
+{
+ php_info_print_table_start();
+ php_info_print_table_row(2, "XML Support", "active");
+ php_info_print_table_row(2, "XML Namespace Support", "active");
+#if defined(LIBXML_DOTTED_VERSION) && defined(LIBXML_EXPAT_COMPAT)
+ php_info_print_table_row(2, "libxml2 Version", LIBXML_DOTTED_VERSION);
+#else
+ php_info_print_table_row(2, "EXPAT Version", XML_ExpatVersion());
+#endif
+ php_info_print_table_end();
+}
+/* }}} */
+
+/* {{{ extension-internal functions */
+static zval *_xml_resource_zval(long value)
+{
+ zval *ret;
+ TSRMLS_FETCH();
+
+ MAKE_STD_ZVAL(ret);
+
+ Z_TYPE_P(ret) = IS_RESOURCE;
+ Z_LVAL_P(ret) = value;
+
+ zend_list_addref(value);
+
+ return ret;
+}
+
+static zval *_xml_string_zval(const char *str)
+{
+ zval *ret;
+ int len = strlen(str);
+ MAKE_STD_ZVAL(ret);
+
+ Z_TYPE_P(ret) = IS_STRING;
+ Z_STRLEN_P(ret) = len;
+ Z_STRVAL_P(ret) = estrndup(str, len);
+ return ret;
+}
+
+static zval *_xml_xmlchar_zval(const XML_Char *s, int len, const XML_Char *encoding)
+{
+ zval *ret;
+ MAKE_STD_ZVAL(ret);
+
+ if (s == NULL) {
+ ZVAL_FALSE(ret);
+ return ret;
+ }
+ if (len == 0) {
+ len = _xml_xmlcharlen(s);
+ }
+ Z_TYPE_P(ret) = IS_STRING;
+ Z_STRVAL_P(ret) = xml_utf8_decode(s, len, &Z_STRLEN_P(ret), encoding);
+ return ret;
+}
+/* }}} */
+
+/* {{{ xml_parser_dtor() */
+static void xml_parser_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+{
+ xml_parser *parser = (xml_parser *)rsrc->ptr;
+
+ if (parser->parser) {
+ XML_ParserFree(parser->parser);
+ }
+ if (parser->ltags) {
+ int inx;
+ for (inx = 0; inx < parser->level; inx++)
+ efree(parser->ltags[ inx ]);
+ efree(parser->ltags);
+ }
+ if (parser->startElementHandler) {
+ zval_ptr_dtor(&parser->startElementHandler);
+ }
+ if (parser->endElementHandler) {
+ zval_ptr_dtor(&parser->endElementHandler);
+ }
+ if (parser->characterDataHandler) {
+ zval_ptr_dtor(&parser->characterDataHandler);
+ }
+ if (parser->processingInstructionHandler) {
+ zval_ptr_dtor(&parser->processingInstructionHandler);
+ }
+ if (parser->defaultHandler) {
+ zval_ptr_dtor(&parser->defaultHandler);
+ }
+ if (parser->unparsedEntityDeclHandler) {
+ zval_ptr_dtor(&parser->unparsedEntityDeclHandler);
+ }
+ if (parser->notationDeclHandler) {
+ zval_ptr_dtor(&parser->notationDeclHandler);
+ }
+ if (parser->externalEntityRefHandler) {
+ zval_ptr_dtor(&parser->externalEntityRefHandler);
+ }
+ if (parser->unknownEncodingHandler) {
+ zval_ptr_dtor(&parser->unknownEncodingHandler);
+ }
+ if (parser->startNamespaceDeclHandler) {
+ zval_ptr_dtor(&parser->startNamespaceDeclHandler);
+ }
+ if (parser->endNamespaceDeclHandler) {
+ zval_ptr_dtor(&parser->endNamespaceDeclHandler);
+ }
+ if (parser->baseURI) {
+ efree(parser->baseURI);
+ }
+ if (parser->object) {
+ zval_ptr_dtor(&parser->object);
+ }
+
+ efree(parser);
+}
+/* }}} */
+
+/* {{{ xml_set_handler() */
+static void xml_set_handler(zval **handler, zval **data)
+{
+ /* If we have already a handler, release it */
+ if (*handler) {
+ zval_ptr_dtor(handler);
+ }
+
+ /* IS_ARRAY might indicate that we're using array($obj, 'method') syntax */
+ if (Z_TYPE_PP(data) != IS_ARRAY && Z_TYPE_PP(data) != IS_OBJECT) {
+
+ convert_to_string_ex(data);
+ if (Z_STRLEN_PP(data) == 0) {
+ *handler = NULL;
+ return;
+ }
+ }
+
+ zval_add_ref(data);
+
+ *handler = *data;
+}
+/* }}} */
+
+/* {{{ xml_call_handler() */
+static zval *xml_call_handler(xml_parser *parser, zval *handler, zend_function *function_ptr, int argc, zval **argv)
+{
+ int i;
+ TSRMLS_FETCH();
+
+ if (parser && handler && !EG(exception)) {
+ zval ***args;
+ zval *retval;
+ int result;
+ zend_fcall_info fci;
+
+ args = safe_emalloc(sizeof(zval **), argc, 0);
+ for (i = 0; i < argc; i++) {
+ args[i] = &argv[i];
+ }
+
+ fci.size = sizeof(fci);
+ fci.function_table = EG(function_table);
+ fci.function_name = handler;
+ fci.symbol_table = NULL;
+ fci.object_ptr = parser->object;
+ fci.retval_ptr_ptr = &retval;
+ fci.param_count = argc;
+ fci.params = args;
+ fci.no_separation = 0;
+ /*fci.function_handler_cache = &function_ptr;*/
+
+ result = zend_call_function(&fci, NULL TSRMLS_CC);
+ if (result == FAILURE) {
+ zval **method;
+ zval **obj;
+
+ if (Z_TYPE_P(handler) == IS_STRING) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s()", Z_STRVAL_P(handler));
+ } else if (zend_hash_index_find(Z_ARRVAL_P(handler), 0, (void **) &obj) == SUCCESS &&
+ zend_hash_index_find(Z_ARRVAL_P(handler), 1, (void **) &method) == SUCCESS &&
+ Z_TYPE_PP(obj) == IS_OBJECT &&
+ Z_TYPE_PP(method) == IS_STRING) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s::%s()", Z_OBJCE_PP(obj)->name, Z_STRVAL_PP(method));
+ } else
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler");
+ }
+
+ for (i = 0; i < argc; i++) {
+ zval_ptr_dtor(args[i]);
+ }
+ efree(args);
+
+ if (result == FAILURE) {
+ return NULL;
+ } else {
+ return EG(exception) ? NULL : retval;
+ }
+ } else {
+ for (i = 0; i < argc; i++) {
+ zval_ptr_dtor(&argv[i]);
+ }
+ return NULL;
+ }
+}
+/* }}} */
+
+/* {{{ xml_encode_iso_8859_1() */
+inline static unsigned short xml_encode_iso_8859_1(unsigned char c)
+{
+ return (unsigned short)c;
+}
+/* }}} */
+
+/* {{{ xml_decode_iso_8859_1() */
+inline static char xml_decode_iso_8859_1(unsigned short c)
+{
+ return (char)(c > 0xff ? '?' : c);
+}
+/* }}} */
+
+/* {{{ xml_encode_us_ascii() */
+inline static unsigned short xml_encode_us_ascii(unsigned char c)
+{
+ return (unsigned short)c;
+}
+/* }}} */
+
+/* {{{ xml_decode_us_ascii() */
+inline static char xml_decode_us_ascii(unsigned short c)
+{
+ return (char)(c > 0x7f ? '?' : c);
+}
+/* }}} */
+
+/* {{{ xml_get_encoding() */
+static xml_encoding *xml_get_encoding(const XML_Char *name)
+{
+ xml_encoding *enc = &xml_encodings[0];
+
+ while (enc && enc->name) {
+ if (strcasecmp(name, enc->name) == 0) {
+ return enc;
+ }
+ enc++;
+ }
+ return NULL;
+}
+/* }}} */
+
+/* {{{ xml_utf8_encode */
+PHPAPI char *xml_utf8_encode(const char *s, int len, int *newlen, const XML_Char *encoding)
+{
+ int pos = len;
+ char *newbuf;
+ unsigned int c;
+ unsigned short (*encoder)(unsigned char) = NULL;
+ xml_encoding *enc = xml_get_encoding(encoding);
+
+ *newlen = 0;
+ if (enc) {
+ encoder = enc->encoding_function;
+ } else {
+ /* If the target encoding was unknown, fail */
+ return NULL;
+ }
+ if (encoder == NULL) {
+ /* If no encoder function was specified, return the data as-is.
+ */
+ newbuf = emalloc(len + 1);
+ memcpy(newbuf, s, len);
+ *newlen = len;
+ newbuf[*newlen] = '\0';
+ return newbuf;
+ }
+ /* This is the theoretical max (will never get beyond len * 2 as long
+ * as we are converting from single-byte characters, though) */
+ newbuf = safe_emalloc(len, 4, 1);
+ while (pos > 0) {
+ c = encoder ? encoder((unsigned char)(*s)) : (unsigned short)(*s);
+ if (c < 0x80) {
+ newbuf[(*newlen)++] = (char) c;
+ } else if (c < 0x800) {
+ newbuf[(*newlen)++] = (0xc0 | (c >> 6));
+ newbuf[(*newlen)++] = (0x80 | (c & 0x3f));
+ } else if (c < 0x10000) {
+ newbuf[(*newlen)++] = (0xe0 | (c >> 12));
+ newbuf[(*newlen)++] = (0xc0 | ((c >> 6) & 0x3f));
+ newbuf[(*newlen)++] = (0x80 | (c & 0x3f));
+ } else if (c < 0x200000) {
+ newbuf[(*newlen)++] = (0xf0 | (c >> 18));
+ newbuf[(*newlen)++] = (0xe0 | ((c >> 12) & 0x3f));
+ newbuf[(*newlen)++] = (0xc0 | ((c >> 6) & 0x3f));
+ newbuf[(*newlen)++] = (0x80 | (c & 0x3f));
+ }
+ pos--;
+ s++;
+ }
+ newbuf[*newlen] = 0;
+ newbuf = erealloc(newbuf, (*newlen)+1);
+ return newbuf;
+}
+/* }}} */
+
+/* {{{ xml_utf8_decode */
+PHPAPI char *xml_utf8_decode(const XML_Char *s, int len, int *newlen, const XML_Char *encoding)
+{
+ size_t pos = 0;
+ char *newbuf = emalloc(len + 1);
+ unsigned int c;
+ char (*decoder)(unsigned short) = NULL;
+ xml_encoding *enc = xml_get_encoding(encoding);
+
+ *newlen = 0;
+ if (enc) {
+ decoder = enc->decoding_function;
+ }
+ if (decoder == NULL) {
+ /* If the target encoding was unknown, or no decoder function
+ * was specified, return the UTF-8-encoded data as-is.
+ */
+ memcpy(newbuf, s, len);
+ *newlen = len;
+ newbuf[*newlen] = '\0';
+ return newbuf;
+ }
+
+ while (pos < (size_t)len) {
+ int status = FAILURE;
+ c = php_next_utf8_char((const unsigned char*)s, (size_t) len, &pos, &status);
+
+ if (status == FAILURE || c > 0xFFU) {
+ c = '?';
+ }
+
+ newbuf[*newlen] = decoder ? decoder(c) : c;
+ ++*newlen;
+ }
+ if (*newlen < len) {
+ newbuf = erealloc(newbuf, *newlen + 1);
+ }
+ newbuf[*newlen] = '\0';
+ return newbuf;
+}
+/* }}} */
+
+/* {{{ _xml_xmlcharlen() */
+static int _xml_xmlcharlen(const XML_Char *s)
+{
+ int len = 0;
+
+ while (*s) {
+ len++;
+ s++;
+ }
+ return len;
+}
+/* }}} */
+
+/* {{{ _xml_zval_strdup() */
+PHPAPI char *_xml_zval_strdup(zval *val)
+{
+ if (Z_TYPE_P(val) == IS_STRING) {
+ char *buf = emalloc(Z_STRLEN_P(val) + 1);
+ memcpy(buf, Z_STRVAL_P(val), Z_STRLEN_P(val));
+ buf[Z_STRLEN_P(val)] = '\0';
+ return buf;
+ }
+ return NULL;
+}
+/* }}} */
+
+/* {{{ _xml_add_to_info */
+static void _xml_add_to_info(xml_parser *parser,char *name)
+{
+ zval **element, *values;
+
+ if (! parser->info) {
+ return;
+ }
+
+ if (zend_hash_find(Z_ARRVAL_P(parser->info),name,strlen(name) + 1,(void **) &element) == FAILURE) {
+ MAKE_STD_ZVAL(values);
+
+ array_init(values);
+
+ zend_hash_update(Z_ARRVAL_P(parser->info), name, strlen(name)+1, (void *) &values, sizeof(zval*), (void **) &element);
+ }
+
+ add_next_index_long(*element,parser->curtag);
+
+ parser->curtag++;
+}
+/* }}} */
+
+/* {{{ _xml_decode_tag() */
+static char *_xml_decode_tag(xml_parser *parser, const char *tag)
+{
+ char *newstr;
+ int out_len;
+
+ newstr = xml_utf8_decode(tag, strlen(tag), &out_len, parser->target_encoding);
+
+ if (parser->case_folding) {
+ php_strtoupper(newstr, out_len);
+ }
+
+ return newstr;
+}
+/* }}} */
+
+/* {{{ _xml_startElementHandler() */
+void _xml_startElementHandler(void *userData, const XML_Char *name, const XML_Char **attributes)
+{
+ xml_parser *parser = (xml_parser *)userData;
+ const char **attrs = (const char **) attributes;
+ char *tag_name;
+ char *att, *val;
+ int val_len;
+ zval *retval, *args[3];
+
+ if (parser) {
+ parser->level++;
+
+ tag_name = _xml_decode_tag(parser, name);
+
+ if (parser->startElementHandler) {
+ args[0] = _xml_resource_zval(parser->index);
+ args[1] = _xml_string_zval(((char *) tag_name) + parser->toffset);
+ MAKE_STD_ZVAL(args[2]);
+ array_init(args[2]);
+
+ while (attributes && *attributes) {
+ att = _xml_decode_tag(parser, attributes[0]);
+ val = xml_utf8_decode(attributes[1], strlen(attributes[1]), &val_len, parser->target_encoding);
+
+ add_assoc_stringl(args[2], att, val, val_len, 0);
+
+ attributes += 2;
+
+ efree(att);
+ }
+
+ if ((retval = xml_call_handler(parser, parser->startElementHandler, parser->startElementPtr, 3, args))) {
+ zval_ptr_dtor(&retval);
+ }
+ }
+
+ if (parser->data) {
+ zval *tag, *atr;
+ int atcnt = 0;
+
+ MAKE_STD_ZVAL(tag);
+ MAKE_STD_ZVAL(atr);
+
+ array_init(tag);
+ array_init(atr);
+
+ _xml_add_to_info(parser,((char *) tag_name) + parser->toffset);
+
+ add_assoc_string(tag,"tag",((char *) tag_name) + parser->toffset,1); /* cast to avoid gcc-warning */
+ add_assoc_string(tag,"type","open",1);
+ add_assoc_long(tag,"level",parser->level);
+
+ parser->ltags[parser->level-1] = estrdup(tag_name);
+ parser->lastwasopen = 1;
+
+ attributes = (const XML_Char **) attrs;
+
+ while (attributes && *attributes) {
+ att = _xml_decode_tag(parser, attributes[0]);
+ val = xml_utf8_decode(attributes[1], strlen(attributes[1]), &val_len, parser->target_encoding);
+
+ add_assoc_stringl(atr,att,val,val_len,0);
+
+ atcnt++;
+ attributes += 2;
+
+ efree(att);
+ }
+
+ if (atcnt) {
+ zend_hash_add(Z_ARRVAL_P(tag),"attributes",sizeof("attributes"),&atr,sizeof(zval*),NULL);
+ } else {
+ zval_ptr_dtor(&atr);
+ }
+
+ zend_hash_next_index_insert(Z_ARRVAL_P(parser->data),&tag,sizeof(zval*),(void *) &parser->ctag);
+ }
+
+ efree(tag_name);
+ }
+}
+/* }}} */
+
+/* {{{ _xml_endElementHandler() */
+void _xml_endElementHandler(void *userData, const XML_Char *name)
+{
+ xml_parser *parser = (xml_parser *)userData;
+ char *tag_name;
+
+ if (parser) {
+ zval *retval, *args[2];
+
+ tag_name = _xml_decode_tag(parser, name);
+
+ if (parser->endElementHandler) {
+ args[0] = _xml_resource_zval(parser->index);
+ args[1] = _xml_string_zval(((char *) tag_name) + parser->toffset);
+
+ if ((retval = xml_call_handler(parser, parser->endElementHandler, parser->endElementPtr, 2, args))) {
+ zval_ptr_dtor(&retval);
+ }
+ }
+
+ if (parser->data) {
+ zval *tag;
+
+ if (parser->lastwasopen) {
+ add_assoc_string(*(parser->ctag),"type","complete",1);
+ } else {
+ MAKE_STD_ZVAL(tag);
+
+ array_init(tag);
+
+ _xml_add_to_info(parser,((char *) tag_name) + parser->toffset);
+
+ add_assoc_string(tag,"tag",((char *) tag_name) + parser->toffset,1); /* cast to avoid gcc-warning */
+ add_assoc_string(tag,"type","close",1);
+ add_assoc_long(tag,"level",parser->level);
+
+ zend_hash_next_index_insert(Z_ARRVAL_P(parser->data),&tag,sizeof(zval*),NULL);
+ }
+
+ parser->lastwasopen = 0;
+ }
+
+ efree(tag_name);
+
+ if (parser->ltags) {
+ efree(parser->ltags[parser->level-1]);
+ }
+
+ parser->level--;
+ }
+}
+/* }}} */
+
+/* {{{ _xml_characterDataHandler() */
+void _xml_characterDataHandler(void *userData, const XML_Char *s, int len)
+{
+ xml_parser *parser = (xml_parser *)userData;
+
+ if (parser) {
+ zval *retval, *args[2];
+
+ if (parser->characterDataHandler) {
+ args[0] = _xml_resource_zval(parser->index);
+ args[1] = _xml_xmlchar_zval(s, len, parser->target_encoding);
+ if ((retval = xml_call_handler(parser, parser->characterDataHandler, parser->characterDataPtr, 2, args))) {
+ zval_ptr_dtor(&retval);
+ }
+ }
+
+ if (parser->data) {
+ int i;
+ int doprint = 0;
+
+ char *decoded_value;
+ int decoded_len;
+
+ decoded_value = xml_utf8_decode(s,len,&decoded_len,parser->target_encoding);
+ for (i = 0; i < decoded_len; i++) {
+ switch (decoded_value[i]) {
+ case ' ':
+ case '\t':
+ case '\n':
+ continue;
+ default:
+ doprint = 1;
+ break;
+ }
+ if (doprint) {
+ break;
+ }
+ }
+ if (doprint || (! parser->skipwhite)) {
+ if (parser->lastwasopen) {
+ zval **myval;
+
+ /* check if the current tag already has a value - if yes append to that! */
+ if (zend_hash_find(Z_ARRVAL_PP(parser->ctag),"value",sizeof("value"),(void **) &myval) == SUCCESS) {
+ int newlen = Z_STRLEN_PP(myval) + decoded_len;
+ Z_STRVAL_PP(myval) = erealloc(Z_STRVAL_PP(myval),newlen+1);
+ strncpy(Z_STRVAL_PP(myval) + Z_STRLEN_PP(myval), decoded_value, decoded_len + 1);
+ Z_STRLEN_PP(myval) += decoded_len;
+ efree(decoded_value);
+ } else {
+ add_assoc_string(*(parser->ctag),"value",decoded_value,0);
+ }
+
+ } else {
+ zval *tag;
+ zval **curtag, **mytype, **myval;
+ HashPosition hpos=NULL;
+
+ zend_hash_internal_pointer_end_ex(Z_ARRVAL_P(parser->data), &hpos);
+
+ if (hpos && (zend_hash_get_current_data_ex(Z_ARRVAL_P(parser->data), (void **) &curtag, &hpos) == SUCCESS)) {
+ if (zend_hash_find(Z_ARRVAL_PP(curtag),"type",sizeof("type"),(void **) &mytype) == SUCCESS) {
+ if (!strcmp(Z_STRVAL_PP(mytype), "cdata")) {
+ if (zend_hash_find(Z_ARRVAL_PP(curtag),"value",sizeof("value"),(void **) &myval) == SUCCESS) {
+ int newlen = Z_STRLEN_PP(myval) + decoded_len;
+ Z_STRVAL_PP(myval) = erealloc(Z_STRVAL_PP(myval),newlen+1);
+ strncpy(Z_STRVAL_PP(myval) + Z_STRLEN_PP(myval), decoded_value, decoded_len + 1);
+ Z_STRLEN_PP(myval) += decoded_len;
+ efree(decoded_value);
+ return;
+ }
+ }
+ }
+ }
+
+ MAKE_STD_ZVAL(tag);
+
+ array_init(tag);
+
+ _xml_add_to_info(parser,parser->ltags[parser->level-1] + parser->toffset);
+
+ add_assoc_string(tag,"tag",parser->ltags[parser->level-1] + parser->toffset,1);
+ add_assoc_string(tag,"value",decoded_value,0);
+ add_assoc_string(tag,"type","cdata",1);
+ add_assoc_long(tag,"level",parser->level);
+
+ zend_hash_next_index_insert(Z_ARRVAL_P(parser->data),&tag,sizeof(zval*),NULL);
+ }
+ } else {
+ efree(decoded_value);
+ }
+ }
+ }
+}
+/* }}} */
+
+/* {{{ _xml_processingInstructionHandler() */
+void _xml_processingInstructionHandler(void *userData, const XML_Char *target, const XML_Char *data)
+{
+ xml_parser *parser = (xml_parser *)userData;
+
+ if (parser && parser->processingInstructionHandler) {
+ zval *retval, *args[3];
+
+ args[0] = _xml_resource_zval(parser->index);
+ args[1] = _xml_xmlchar_zval(target, 0, parser->target_encoding);
+ args[2] = _xml_xmlchar_zval(data, 0, parser->target_encoding);
+ if ((retval = xml_call_handler(parser, parser->processingInstructionHandler, parser->processingInstructionPtr, 3, args))) {
+ zval_ptr_dtor(&retval);
+ }
+ }
+}
+/* }}} */
+
+/* {{{ _xml_defaultHandler() */
+void _xml_defaultHandler(void *userData, const XML_Char *s, int len)
+{
+ xml_parser *parser = (xml_parser *)userData;
+
+ if (parser && parser->defaultHandler) {
+ zval *retval, *args[2];
+
+ args[0] = _xml_resource_zval(parser->index);
+ args[1] = _xml_xmlchar_zval(s, len, parser->target_encoding);
+ if ((retval = xml_call_handler(parser, parser->defaultHandler, parser->defaultPtr, 2, args))) {
+ zval_ptr_dtor(&retval);
+ }
+ }
+}
+/* }}} */
+
+/* {{{ _xml_unparsedEntityDeclHandler() */
+void _xml_unparsedEntityDeclHandler(void *userData,
+ const XML_Char *entityName,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId,
+ const XML_Char *notationName)
+{
+ xml_parser *parser = (xml_parser *)userData;
+
+ if (parser && parser->unparsedEntityDeclHandler) {
+ zval *retval, *args[6];
+
+ args[0] = _xml_resource_zval(parser->index);
+ args[1] = _xml_xmlchar_zval(entityName, 0, parser->target_encoding);
+ args[2] = _xml_xmlchar_zval(base, 0, parser->target_encoding);
+ args[3] = _xml_xmlchar_zval(systemId, 0, parser->target_encoding);
+ args[4] = _xml_xmlchar_zval(publicId, 0, parser->target_encoding);
+ args[5] = _xml_xmlchar_zval(notationName, 0, parser->target_encoding);
+ if ((retval = xml_call_handler(parser, parser->unparsedEntityDeclHandler, parser->unparsedEntityDeclPtr, 6, args))) {
+ zval_ptr_dtor(&retval);
+ }
+ }
+}
+/* }}} */
+
+/* {{{ _xml_notationDeclHandler() */
+void _xml_notationDeclHandler(void *userData,
+ const XML_Char *notationName,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId)
+{
+ xml_parser *parser = (xml_parser *)userData;
+
+ if (parser && parser->notationDeclHandler) {
+ zval *retval, *args[5];
+
+ args[0] = _xml_resource_zval(parser->index);
+ args[1] = _xml_xmlchar_zval(notationName, 0, parser->target_encoding);
+ args[2] = _xml_xmlchar_zval(base, 0, parser->target_encoding);
+ args[3] = _xml_xmlchar_zval(systemId, 0, parser->target_encoding);
+ args[4] = _xml_xmlchar_zval(publicId, 0, parser->target_encoding);
+ if ((retval = xml_call_handler(parser, parser->notationDeclHandler, parser->notationDeclPtr, 5, args))) {
+ zval_ptr_dtor(&retval);
+ }
+ }
+}
+/* }}} */
+
+/* {{{ _xml_externalEntityRefHandler() */
+int _xml_externalEntityRefHandler(XML_Parser parserPtr,
+ const XML_Char *openEntityNames,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId)
+{
+ xml_parser *parser = XML_GetUserData(parserPtr);
+ int ret = 0; /* abort if no handler is set (should be configurable?) */
+
+ if (parser && parser->externalEntityRefHandler) {
+ zval *retval, *args[5];
+
+ args[0] = _xml_resource_zval(parser->index);
+ args[1] = _xml_xmlchar_zval(openEntityNames, 0, parser->target_encoding);
+ args[2] = _xml_xmlchar_zval(base, 0, parser->target_encoding);
+ args[3] = _xml_xmlchar_zval(systemId, 0, parser->target_encoding);
+ args[4] = _xml_xmlchar_zval(publicId, 0, parser->target_encoding);
+ if ((retval = xml_call_handler(parser, parser->externalEntityRefHandler, parser->externalEntityRefPtr, 5, args))) {
+ convert_to_long(retval);
+ ret = Z_LVAL_P(retval);
+ efree(retval);
+ } else {
+ ret = 0;
+ }
+ }
+ return ret;
+}
+/* }}} */
+
+/* {{{ _xml_startNamespaceDeclHandler() */
+void _xml_startNamespaceDeclHandler(void *userData,const XML_Char *prefix, const XML_Char *uri)
+{
+ xml_parser *parser = (xml_parser *)userData;
+
+ if (parser && parser->startNamespaceDeclHandler) {
+ zval *retval, *args[3];
+
+ args[0] = _xml_resource_zval(parser->index);
+ args[1] = _xml_xmlchar_zval(prefix, 0, parser->target_encoding);
+ args[2] = _xml_xmlchar_zval(uri, 0, parser->target_encoding);
+ if ((retval = xml_call_handler(parser, parser->startNamespaceDeclHandler, parser->startNamespaceDeclPtr, 3, args))) {
+ zval_ptr_dtor(&retval);
+ }
+ }
+}
+/* }}} */
+
+/* {{{ _xml_endNamespaceDeclHandler() */
+void _xml_endNamespaceDeclHandler(void *userData, const XML_Char *prefix)
+{
+ xml_parser *parser = (xml_parser *)userData;
+
+ if (parser && parser->endNamespaceDeclHandler) {
+ zval *retval, *args[2];
+
+ args[0] = _xml_resource_zval(parser->index);
+ args[1] = _xml_xmlchar_zval(prefix, 0, parser->target_encoding);
+ if ((retval = xml_call_handler(parser, parser->endNamespaceDeclHandler, parser->endNamespaceDeclPtr, 2, args))) {
+ zval_ptr_dtor(&retval);
+ }
+ }
+}
+/* }}} */
+
+/************************* EXTENSION FUNCTIONS *************************/
+
+static void php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAMETERS, int ns_support) /* {{{ */
+{
+ xml_parser *parser;
+ int auto_detect = 0;
+
+ char *encoding_param = NULL;
+ int encoding_param_len = 0;
+
+ char *ns_param = NULL;
+ int ns_param_len = 0;
+
+ XML_Char *encoding;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, (ns_support ? "|ss": "|s"), &encoding_param, &encoding_param_len, &ns_param, &ns_param_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ if (encoding_param != NULL) {
+ /* The supported encoding types are hardcoded here because
+ * we are limited to the encodings supported by expat/xmltok.
+ */
+ if (encoding_param_len == 0) {
+ encoding = XML(default_encoding);
+ auto_detect = 1;
+ } else if (strcasecmp(encoding_param, "ISO-8859-1") == 0) {
+ encoding = "ISO-8859-1";
+ } else if (strcasecmp(encoding_param, "UTF-8") == 0) {
+ encoding = "UTF-8";
+ } else if (strcasecmp(encoding_param, "US-ASCII") == 0) {
+ encoding = "US-ASCII";
+ } else {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "unsupported source encoding \"%s\"", encoding_param);
+ RETURN_FALSE;
+ }
+ } else {
+ encoding = XML(default_encoding);
+ }
+
+ if (ns_support && ns_param == NULL){
+ ns_param = ":";
+ }
+
+ parser = ecalloc(1, sizeof(xml_parser));
+ parser->parser = XML_ParserCreate_MM((auto_detect ? NULL : encoding),
+ &php_xml_mem_hdlrs, ns_param);
+
+ parser->target_encoding = encoding;
+ parser->case_folding = 1;
+ parser->object = NULL;
+ parser->isparsing = 0;
+
+ XML_SetUserData(parser->parser, parser);
+
+ ZEND_REGISTER_RESOURCE(return_value, parser,le_xml_parser);
+ parser->index = Z_LVAL_P(return_value);
+}
+/* }}} */
+
+/* {{{ proto resource xml_parser_create([string encoding])
+ Create an XML parser */
+PHP_FUNCTION(xml_parser_create)
+{
+ php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+}
+/* }}} */
+
+/* {{{ proto resource xml_parser_create_ns([string encoding [, string sep]])
+ Create an XML parser */
+PHP_FUNCTION(xml_parser_create_ns)
+{
+ php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+}
+/* }}} */
+
+/* {{{ proto int xml_set_object(resource parser, object &obj)
+ Set up object which should be used for callbacks */
+PHP_FUNCTION(xml_set_object)
+{
+ xml_parser *parser;
+ zval *pind, *mythis;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ro", &pind, &mythis) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ /* please leave this commented - or ask thies@thieso.net before doing it (again) */
+ if (parser->object) {
+ zval_ptr_dtor(&parser->object);
+ }
+
+ /* please leave this commented - or ask thies@thieso.net before doing it (again) */
+/* #ifdef ZEND_ENGINE_2
+ zval_add_ref(&parser->object);
+#endif */
+
+ ALLOC_ZVAL(parser->object);
+ MAKE_COPY_ZVAL(&mythis, parser->object);
+
+ RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int xml_set_element_handler(resource parser, string shdl, string ehdl)
+ Set up start and end element handlers */
+PHP_FUNCTION(xml_set_element_handler)
+{
+ xml_parser *parser;
+ zval *pind, **shdl, **ehdl;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rZZ", &pind, &shdl, &ehdl) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ xml_set_handler(&parser->startElementHandler, shdl);
+ xml_set_handler(&parser->endElementHandler, ehdl);
+ XML_SetElementHandler(parser->parser, _xml_startElementHandler, _xml_endElementHandler);
+ RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int xml_set_character_data_handler(resource parser, string hdl)
+ Set up character data handler */
+PHP_FUNCTION(xml_set_character_data_handler)
+{
+ xml_parser *parser;
+ zval *pind, **hdl;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rZ", &pind, &hdl) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ xml_set_handler(&parser->characterDataHandler, hdl);
+ XML_SetCharacterDataHandler(parser->parser, _xml_characterDataHandler);
+ RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int xml_set_processing_instruction_handler(resource parser, string hdl)
+ Set up processing instruction (PI) handler */
+PHP_FUNCTION(xml_set_processing_instruction_handler)
+{
+ xml_parser *parser;
+ zval *pind, **hdl;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rZ", &pind, &hdl) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ xml_set_handler(&parser->processingInstructionHandler, hdl);
+ XML_SetProcessingInstructionHandler(parser->parser, _xml_processingInstructionHandler);
+ RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int xml_set_default_handler(resource parser, string hdl)
+ Set up default handler */
+PHP_FUNCTION(xml_set_default_handler)
+{
+ xml_parser *parser;
+ zval *pind, **hdl;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rZ", &pind, &hdl) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ xml_set_handler(&parser->defaultHandler, hdl);
+ XML_SetDefaultHandler(parser->parser, _xml_defaultHandler);
+ RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int xml_set_unparsed_entity_decl_handler(resource parser, string hdl)
+ Set up unparsed entity declaration handler */
+PHP_FUNCTION(xml_set_unparsed_entity_decl_handler)
+{
+ xml_parser *parser;
+ zval *pind, **hdl;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rZ", &pind, &hdl) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ xml_set_handler(&parser->unparsedEntityDeclHandler, hdl);
+ XML_SetUnparsedEntityDeclHandler(parser->parser, _xml_unparsedEntityDeclHandler);
+ RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int xml_set_notation_decl_handler(resource parser, string hdl)
+ Set up notation declaration handler */
+PHP_FUNCTION(xml_set_notation_decl_handler)
+{
+ xml_parser *parser;
+ zval *pind, **hdl;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rZ", &pind, &hdl) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ xml_set_handler(&parser->notationDeclHandler, hdl);
+ XML_SetNotationDeclHandler(parser->parser, _xml_notationDeclHandler);
+ RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int xml_set_external_entity_ref_handler(resource parser, string hdl)
+ Set up external entity reference handler */
+PHP_FUNCTION(xml_set_external_entity_ref_handler)
+{
+ xml_parser *parser;
+ zval *pind, **hdl;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rZ", &pind, &hdl) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ xml_set_handler(&parser->externalEntityRefHandler, hdl);
+ XML_SetExternalEntityRefHandler(parser->parser, (void *) _xml_externalEntityRefHandler);
+ RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int xml_set_start_namespace_decl_handler(resource parser, string hdl)
+ Set up character data handler */
+PHP_FUNCTION(xml_set_start_namespace_decl_handler)
+{
+ xml_parser *parser;
+ zval *pind, **hdl;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rZ", &pind, &hdl) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ xml_set_handler(&parser->startNamespaceDeclHandler, hdl);
+ XML_SetStartNamespaceDeclHandler(parser->parser, _xml_startNamespaceDeclHandler);
+ RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int xml_set_end_namespace_decl_handler(resource parser, string hdl)
+ Set up character data handler */
+PHP_FUNCTION(xml_set_end_namespace_decl_handler)
+{
+ xml_parser *parser;
+ zval *pind, **hdl;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rZ", &pind, &hdl) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ xml_set_handler(&parser->endNamespaceDeclHandler, hdl);
+ XML_SetEndNamespaceDeclHandler(parser->parser, _xml_endNamespaceDeclHandler);
+ RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int xml_parse(resource parser, string data [, int isFinal])
+ Start parsing an XML document */
+PHP_FUNCTION(xml_parse)
+{
+ xml_parser *parser;
+ zval *pind;
+ char *data;
+ int data_len, ret;
+ long isFinal = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &pind, &data, &data_len, &isFinal) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ parser->isparsing = 1;
+ ret = XML_Parse(parser->parser, data, data_len, isFinal);
+ parser->isparsing = 0;
+ RETVAL_LONG(ret);
+}
+
+/* }}} */
+
+/* {{{ proto int xml_parse_into_struct(resource parser, string data, array &values [, array &index ])
+ Parsing a XML document */
+
+PHP_FUNCTION(xml_parse_into_struct)
+{
+ xml_parser *parser;
+ zval *pind, **xdata, **info = NULL;
+ char *data;
+ int data_len, ret;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsZ|Z", &pind, &data, &data_len, &xdata, &info) == FAILURE) {
+ return;
+ }
+
+ if (info) {
+ zval_dtor(*info);
+ array_init(*info);
+ }
+
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ zval_dtor(*xdata);
+ array_init(*xdata);
+
+ parser->data = *xdata;
+
+ if (info) {
+ parser->info = *info;
+ }
+
+ parser->level = 0;
+ parser->ltags = safe_emalloc(XML_MAXLEVEL, sizeof(char *), 0);
+
+ XML_SetDefaultHandler(parser->parser, _xml_defaultHandler);
+ XML_SetElementHandler(parser->parser, _xml_startElementHandler, _xml_endElementHandler);
+ XML_SetCharacterDataHandler(parser->parser, _xml_characterDataHandler);
+
+ parser->isparsing = 1;
+ ret = XML_Parse(parser->parser, data, data_len, 1);
+ parser->isparsing = 0;
+
+ RETVAL_LONG(ret);
+}
+/* }}} */
+
+/* {{{ proto int xml_get_error_code(resource parser)
+ Get XML parser error code */
+PHP_FUNCTION(xml_get_error_code)
+{
+ xml_parser *parser;
+ zval *pind;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ RETVAL_LONG((long)XML_GetErrorCode(parser->parser));
+}
+/* }}} */
+
+/* {{{ proto string xml_error_string(int code)
+ Get XML parser error string */
+PHP_FUNCTION(xml_error_string)
+{
+ long code;
+ char *str;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &code) == FAILURE) {
+ return;
+ }
+
+ str = (char *)XML_ErrorString((int)code);
+ if (str) {
+ RETVAL_STRING(str, 1);
+ }
+}
+/* }}} */
+
+/* {{{ proto int xml_get_current_line_number(resource parser)
+ Get current line number for an XML parser */
+PHP_FUNCTION(xml_get_current_line_number)
+{
+ xml_parser *parser;
+ zval *pind;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ RETVAL_LONG(XML_GetCurrentLineNumber(parser->parser));
+}
+/* }}} */
+
+/* {{{ proto int xml_get_current_column_number(resource parser)
+ Get current column number for an XML parser */
+PHP_FUNCTION(xml_get_current_column_number)
+{
+ xml_parser *parser;
+ zval *pind;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ RETVAL_LONG(XML_GetCurrentColumnNumber(parser->parser));
+}
+/* }}} */
+
+/* {{{ proto int xml_get_current_byte_index(resource parser)
+ Get current byte index for an XML parser */
+PHP_FUNCTION(xml_get_current_byte_index)
+{
+ xml_parser *parser;
+ zval *pind;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ RETVAL_LONG(XML_GetCurrentByteIndex(parser->parser));
+}
+/* }}} */
+
+/* {{{ proto int xml_parser_free(resource parser)
+ Free an XML parser */
+PHP_FUNCTION(xml_parser_free)
+{
+ zval *pind;
+ xml_parser *parser;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ if (parser->isparsing == 1) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Parser cannot be freed while it is parsing.");
+ RETURN_FALSE;
+ }
+
+ if (zend_list_delete(parser->index) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int xml_parser_set_option(resource parser, int option, mixed value)
+ Set options in an XML parser */
+PHP_FUNCTION(xml_parser_set_option)
+{
+ xml_parser *parser;
+ zval *pind, **val;
+ long opt;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlZ", &pind, &opt, &val) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ switch (opt) {
+ case PHP_XML_OPTION_CASE_FOLDING:
+ convert_to_long_ex(val);
+ parser->case_folding = Z_LVAL_PP(val);
+ break;
+ case PHP_XML_OPTION_SKIP_TAGSTART:
+ convert_to_long_ex(val);
+ parser->toffset = Z_LVAL_PP(val);
+ break;
+ case PHP_XML_OPTION_SKIP_WHITE:
+ convert_to_long_ex(val);
+ parser->skipwhite = Z_LVAL_PP(val);
+ break;
+ case PHP_XML_OPTION_TARGET_ENCODING: {
+ xml_encoding *enc;
+ convert_to_string_ex(val);
+ enc = xml_get_encoding(Z_STRVAL_PP(val));
+ if (enc == NULL) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported target encoding \"%s\"", Z_STRVAL_PP(val));
+ RETURN_FALSE;
+ }
+ parser->target_encoding = enc->name;
+ break;
+ }
+ default:
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown option");
+ RETURN_FALSE;
+ break;
+ }
+ RETVAL_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int xml_parser_get_option(resource parser, int option)
+ Get options from an XML parser */
+PHP_FUNCTION(xml_parser_get_option)
+{
+ xml_parser *parser;
+ zval *pind;
+ long opt;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &pind, &opt) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(parser,xml_parser *, &pind, -1, "XML Parser", le_xml_parser);
+
+ switch (opt) {
+ case PHP_XML_OPTION_CASE_FOLDING:
+ RETURN_LONG(parser->case_folding);
+ break;
+ case PHP_XML_OPTION_TARGET_ENCODING:
+ RETURN_STRING(parser->target_encoding, 1);
+ break;
+ default:
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown option");
+ RETURN_FALSE;
+ break;
+ }
+
+ RETVAL_FALSE; /* never reached */
+}
+/* }}} */
+
+/* {{{ proto string utf8_encode(string data)
+ Encodes an ISO-8859-1 string to UTF-8 */
+PHP_FUNCTION(utf8_encode)
+{
+ char *arg;
+ XML_Char *encoded;
+ int arg_len, len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
+ return;
+ }
+
+ encoded = xml_utf8_encode(arg, arg_len, &len, "ISO-8859-1");
+ if (encoded == NULL) {
+ RETURN_FALSE;
+ }
+ RETVAL_STRINGL(encoded, len, 0);
+}
+/* }}} */
+
+/* {{{ proto string utf8_decode(string data)
+ Converts a UTF-8 encoded string to ISO-8859-1 */
+PHP_FUNCTION(utf8_decode)
+{
+ char *arg;
+ XML_Char *decoded;
+ int arg_len, len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
+ return;
+ }
+
+ decoded = xml_utf8_decode(arg, arg_len, &len, "ISO-8859-1");
+ if (decoded == NULL) {
+ RETURN_FALSE;
+ }
+ RETVAL_STRINGL(decoded, len, 0);
+}
+/* }}} */
+
+#endif
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: sw=4 ts=4 fdm=marker
+ * vim<600: sw=4 ts=4
+ */
diff --git a/ext/xml/xml.mak b/ext/xml/xml.mak
new file mode 100644
index 0000000..ab60f28
--- /dev/null
+++ b/ext/xml/xml.mak
@@ -0,0 +1,172 @@
+# Temporarily here -- later may go into some batch file
+# which will set this as an environment variable
+PROJECT_ROOT = ..\..
+
+# Module details
+MODULE_NAME = php_xml
+MODULE_DESC = "PHP 5 - XML Extension"
+VMAJ = 3
+VMIN = 0
+VREV = 0
+
+#include the common settings
+include $(PROJECT_ROOT)/netware/common.mif
+
+# Extensions of all input and output files
+.SUFFIXES:
+.SUFFIXES: .nlm .lib .obj .cpp .c .msg .mlc .mdb .xdc .d
+
+# Source files
+C_SRC = xml.c \
+ start.c
+
+CPP_SRC_NODIR = $(notdir $(CPP_SRC))
+C_SRC_NODIR = $(notdir $(C_SRC))
+SRC_DIR = $(dir $(CPP_SRC) $(C_SRC))
+
+# Library files
+LIBRARY =
+
+# Destination directories and files
+OBJ_DIR = $(BUILD)
+FINAL_DIR = $(BUILD)
+MAP_FILE = $(FINAL_DIR)\$(MODULE_NAME).map
+OBJECTS = $(addprefix $(OBJ_DIR)/,$(CPP_SRC_NODIR:.c=.obj) $(C_SRC_NODIR:.c=.obj))
+DEPDS = $(addprefix $(OBJ_DIR)/,$(CPP_SRC_NODIR:.c=.d) $(C_SRC_NODIR:.c=.d))
+
+# Binary file
+ifndef BINARY
+ BINARY=$(FINAL_DIR)\$(MODULE_NAME).nlm
+endif
+
+# Compile flags
+C_FLAGS += -c -maxerrors 25 -msgstyle gcc
+C_FLAGS += -wchar_t on -bool on
+C_FLAGS += -processor Pentium
+C_FLAGS += -nostdinc -nosyspath
+C_FLAGS += -relax_pointers # To remove type-casting errors
+C_FLAGS += -DNETWARE -DZTS
+C_FLAGS += -DNEW_LIBC
+C_FLAGS += -DCOMPILE_DL_XML -DHAVE_LIBEXPAT=1
+C_FLAGS += -I. -I- -I$(PROJECT_ROOT) -I$(PROJECT_ROOT)/main
+C_FLAGS += -I$(PROJECT_ROOT)/ext/standard -I$(PROJECT_ROOT)/netware
+C_FLAGS += -I$(PROJECT_ROOT)/zend -I$(PROJECT_ROOT)/tsrm
+C_FLAGS += -I$(SDK_DIR)/include -I$(MWCIncludes)
+C_FLAGS += -I$(EXPAT_DIR)/include
+
+ifndef STACK_SIZE
+STACK_SIZE=8192
+endif
+
+# Extra stuff based on debug / release builds
+ifeq '$(BUILD)' 'debug'
+ SYM_FILE = $(FINAL_DIR)\$(MODULE_NAME).sym
+ C_FLAGS += -inline smart -sym on -sym codeview4 -opt off -opt intrinsics -sym internal -DDEBUGGING -DDKFBPON
+ C_FLAGS += -exc cw -DZEND_DEBUG=1
+ LD_FLAGS += -sym on -sym codeview4 -osym $(SYM_FILE)
+ export MWLibraryFiles=$(SDK_DIR)/imports/libcpre.o;mwcrtld.lib
+else
+ C_FLAGS += -opt speed -inline on -inline smart -inline auto -sym off
+ C_FLAGS += -opt intrinsics
+ C_FLAGS += -opt level=4 -DZEND_DEBUG=0
+ LD_FLAGS += -sym off
+ export MWLibraryFiles=$(SDK_DIR)/imports/libcpre.o;mwcrtl.lib
+endif
+
+# Dependencies
+MODULE = LibC \
+ expatlbc \
+ phplib
+IMPORT = @$(SDK_DIR)/imports/libc.imp \
+ @$(SDK_DIR)/imports/ws2nlm.imp \
+ @$(MPK_DIR)/import/mpkOrg.imp \
+ @$(EXPAT_DIR)/imports/expatlbc.imp \
+ @$(PROJECT_ROOT)/netware/phplib.imp
+EXPORT = ($(MODULE_NAME)) get_module
+API = OutputToScreen
+
+
+# Virtual paths
+vpath %.cpp .
+vpath %.c . ..\..\netware
+vpath %.obj $(OBJ_DIR)
+
+
+all: prebuild project
+
+.PHONY: all
+
+prebuild:
+ @if not exist $(OBJ_DIR) md $(OBJ_DIR)
+
+project: $(BINARY)
+ @echo Build complete.
+
+$(OBJ_DIR)/%.d: %.cpp
+ @echo Building Dependencies for $(<F)
+ @$(CC) -M $< $(C_FLAGS) -o $@
+
+$(OBJ_DIR)/%.d: %.c
+ @echo Building Dependencies for $(<F)
+ @$(CC) -M $< $(C_FLAGS) -o $@
+
+$(OBJ_DIR)/%.obj: %.cpp
+ @echo Compiling $?...
+ @$(CC) $< $(C_FLAGS) -o $@
+
+$(OBJ_DIR)/%.obj: %.c
+ @echo Compiling $?...
+ @$(CC) $< $(C_FLAGS) -o $@
+
+
+$(BINARY): $(OBJECTS)
+ @echo Import $(IMPORT) > $(basename $@).def
+ifdef API
+ @echo Import $(API) >> $(basename $@).def
+endif
+ @echo Module $(MODULE) >> $(basename $@).def
+ifdef EXPORT
+ @echo Export $(EXPORT) >> $(basename $@).def
+endif
+ @echo AutoUnload >> $(basename $@).def
+ifeq '$(BUILD)' 'debug'
+ @echo Debug >> $(basename $@).def
+endif
+ @echo Flag_On 0x00000008 >> $(basename $@).def
+ @echo Start _LibCPrelude >> $(basename $@).def
+ @echo Exit _LibCPostlude >> $(basename $@).def
+
+ $(MPKTOOL) $(XDCFLAGS) $(basename $@).xdc
+ @echo xdcdata $(basename $@).xdc >> $(basename $@).def
+
+ @echo Linking $@...
+ @echo $(LD_FLAGS) -commandfile $(basename $@).def > $(basename $@).link
+ @echo $(LIBRARY) $(OBJECTS) >> $(basename $@).link
+
+ @$(LINK) @$(basename $@).link
+
+
+.PHONY: clean
+clean: cleanobj cleanbin
+
+.PHONY: cleand
+cleand:
+ @echo Deleting all dependency files...
+ -@del "$(OBJ_DIR)\*.d"
+
+.PHONY: cleanobj
+cleanobj:
+ @echo Deleting all object files...
+ -@del "$(OBJ_DIR)\*.obj"
+
+.PHONY: cleanbin
+cleanbin:
+ @echo Deleting binary files...
+ -@del "$(FINAL_DIR)\$(MODULE_NAME).nlm"
+ @echo Deleting MAP, DEF files, etc....
+ -@del "$(FINAL_DIR)\$(MODULE_NAME).map"
+ -@del "$(FINAL_DIR)\$(MODULE_NAME).def"
+ -@del "$(FINAL_DIR)\$(MODULE_NAME).link"
+ifeq '$(BUILD)' 'debug'
+ -@del $(FINAL_DIR)\$(MODULE_NAME).sym
+endif