summaryrefslogtreecommitdiff
path: root/ext/xml
diff options
context:
space:
mode:
Diffstat (limited to 'ext/xml')
-rw-r--r--ext/xml/CREDITS2
-rw-r--r--ext/xml/compat.c721
-rw-r--r--ext/xml/config.m459
-rw-r--r--ext/xml/config.w3215
-rw-r--r--ext/xml/expat_compat.h156
-rw-r--r--ext/xml/package.xml74
-rw-r--r--ext/xml/php_xml.h163
-rw-r--r--ext/xml/tests/bug25666.phpt35
-rw-r--r--ext/xml/tests/bug26528.phpt31
-rw-r--r--ext/xml/tests/bug26614.phpt93
-rwxr-xr-xext/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
-rwxr-xr-xext/xml/tests/bug32001b.phpt184
-rw-r--r--ext/xml/tests/bug35447.phpt49
-rw-r--r--ext/xml/tests/inc.ent1
-rw-r--r--ext/xml/tests/skipif.inc10
-rw-r--r--ext/xml/tests/xml001.phpt99
-rw-r--r--ext/xml/tests/xml002.phpt100
-rw-r--r--ext/xml/tests/xml003.phpt98
-rw-r--r--ext/xml/tests/xml004.phpt64
-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/xmltest.xml20
-rw-r--r--ext/xml/xml.c1645
-rw-r--r--ext/xml/xml.mak172
30 files changed, 0 insertions, 4575 deletions
diff --git a/ext/xml/CREDITS b/ext/xml/CREDITS
deleted file mode 100644
index b9cbfdd5af..0000000000
--- a/ext/xml/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-XML
-Stig Bakken, Thies C. Arntzen, Sterling Hughes
diff --git a/ext/xml/compat.c b/ext/xml/compat.c
deleted file mode 100644
index cfa56e1b55..0000000000
--- a/ext/xml/compat.c
+++ /dev/null
@@ -1,721 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 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, strlen(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 && parser->h_default == NULL) {
- 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) {
- 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, xmlStrlen(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
-
- 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",
- "Internal error",
- "No memory",
- "Invalid document start",
- "Empty document",
- "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
deleted file mode 100644
index 65f22915b9..0000000000
--- a/ext/xml/config.m4
+++ /dev/null
@@ -1,59 +0,0 @@
-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
deleted file mode 100644
index 08d25ffe57..0000000000
--- a/ext/xml/config.w32
+++ /dev/null
@@ -1,15 +0,0 @@
-// $Id$
-// vim:ft=javascript
-
-ARG_WITH("xml", "XML support", "yes");
-
-if (PHP_XML == "yes" && PHP_LIBXML == "yes") {
- EXTENSION("xml", "xml.c compat.c");
- AC_DEFINE("HAVE_XML", 1, "XML support");
- if (!PHP_XML_SHARED) {
- ADD_FLAG("CFLAGS_XML", "/D LIBXML_STATIC ");
- }
- ADD_EXTENSION_DEP('xml', 'libxml');
-}
-
-
diff --git a/ext/xml/expat_compat.h b/ext/xml/expat_compat.h
deleted file mode 100644
index c2c8cdcda3..0000000000
--- a/ext/xml/expat_compat.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 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
deleted file mode 100644
index f7f4ce62b5..0000000000
--- a/ext/xml/package.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?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 intallation 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
deleted file mode 100644
index 21b328d5cb..0000000000
--- a/ext/xml/php_xml.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 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 PHP_WIN32
-#define PHP_XML_API __declspec(dllexport)
-#else
-#define PHP_XML_API
-#endif
-
-
-#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
deleted file mode 100644
index e162d5a2bd..0000000000
--- a/ext/xml/tests/bug25666.phpt
+++ /dev/null
@@ -1,35 +0,0 @@
---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
deleted file mode 100644
index 40a1c53c9b..0000000000
--- a/ext/xml/tests/bug26528.phpt
+++ /dev/null
@@ -1,31 +0,0 @@
---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
deleted file mode 100644
index e1df1bbfde..0000000000
--- a/ext/xml/tests/bug26614.phpt
+++ /dev/null
@@ -1,93 +0,0 @@
---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
deleted file mode 100755
index 782bdb1936..0000000000
--- a/ext/xml/tests/bug26614_libxml.phpt
+++ /dev/null
@@ -1,93 +0,0 @@
---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
deleted file mode 100644
index e60466fa19..0000000000
--- a/ext/xml/tests/bug27908.phpt
+++ /dev/null
@@ -1,23 +0,0 @@
---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
deleted file mode 100644
index 0a3a5ca46b..0000000000
--- a/ext/xml/tests/bug30266.phpt
+++ /dev/null
@@ -1,52 +0,0 @@
---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
deleted file mode 100644
index 0853b3ab1c..0000000000
--- a/ext/xml/tests/bug32001.phpt
+++ /dev/null
@@ -1,406 +0,0 @@
---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
deleted file mode 100755
index f4aea08e5d..0000000000
--- a/ext/xml/tests/bug32001b.phpt
+++ /dev/null
@@ -1,184 +0,0 @@
---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') {
- $php = getenv('TEST_PHP_EXECUTABLE');
- preg_match("/^libxml2 Version.*\$/im", `$php -i`, $match);
- echo $match[0], "\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
deleted file mode 100644
index 8cbb5e5193..0000000000
--- a/ext/xml/tests/bug35447.phpt
+++ /dev/null
@@ -1,49 +0,0 @@
---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/inc.ent b/ext/xml/tests/inc.ent
deleted file mode 100644
index 8f86465c2a..0000000000
--- a/ext/xml/tests/inc.ent
+++ /dev/null
@@ -1 +0,0 @@
-<!ENTITY included-entity "This is text included from an entity">
diff --git a/ext/xml/tests/skipif.inc b/ext/xml/tests/skipif.inc
deleted file mode 100644
index 44898f3da6..0000000000
--- a/ext/xml/tests/skipif.inc
+++ /dev/null
@@ -1,10 +0,0 @@
-<?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/xml001.phpt b/ext/xml/tests/xml001.phpt
deleted file mode 100644
index 62d597c5f8..0000000000
--- a/ext/xml/tests/xml001.phpt
+++ /dev/null
@@ -1,99 +0,0 @@
---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');
-?>
---INI--
-magic_quotes_runtime=0
---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
deleted file mode 100644
index 8ae8dfbe66..0000000000
--- a/ext/xml/tests/xml002.phpt
+++ /dev/null
@@ -1,100 +0,0 @@
---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');
-?>
---INI--
-magic_quotes_runtime=0
---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
deleted file mode 100644
index 311c81acfb..0000000000
--- a/ext/xml/tests/xml003.phpt
+++ /dev/null
@@ -1,98 +0,0 @@
---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');
-?>
---INI--
-magic_quotes_runtime=0
---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
deleted file mode 100644
index 78840ee122..0000000000
--- a/ext/xml/tests/xml004.phpt
+++ /dev/null
@@ -1,64 +0,0 @@
---TEST--
-XML parser case folding test
---SKIPIF--
-<?php include("skipif.inc"); ?>
---INI--
-magic_quotes_runtime=0
---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
deleted file mode 100644
index c714e85913..0000000000
--- a/ext/xml/tests/xml006.phpt
+++ /dev/null
@@ -1,12 +0,0 @@
---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
deleted file mode 100644
index 377475bb1c..0000000000
--- a/ext/xml/tests/xml007.phpt
+++ /dev/null
@@ -1,53 +0,0 @@
---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
deleted file mode 100644
index 84b89bb488..0000000000
--- a/ext/xml/tests/xml009.phpt
+++ /dev/null
@@ -1,35 +0,0 @@
---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
deleted file mode 100644
index e968442123..0000000000
--- a/ext/xml/tests/xml010.phpt
+++ /dev/null
@@ -1,39 +0,0 @@
---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
deleted file mode 100644
index 9c4cfca8f1..0000000000
--- a/ext/xml/tests/xml011.phpt
+++ /dev/null
@@ -1,71 +0,0 @@
---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/xmltest.xml b/ext/xml/tests/xmltest.xml
deleted file mode 100644
index c15d6ea1ab..0000000000
--- a/ext/xml/tests/xmltest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?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
deleted file mode 100644
index 9c8d842176..0000000000
--- a/ext/xml/xml.c
+++ /dev/null
@@ -1,1645 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 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"
-
-#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)
-# ifdef PHP_WIN32
-# include "zend_arg_defs.c"
-# endif
-#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 */
-static
- ZEND_BEGIN_ARG_INFO(third_and_fourth_args_force_ref, 0)
- ZEND_ARG_PASS_INFO(0)
- ZEND_ARG_PASS_INFO(0)
- ZEND_ARG_PASS_INFO(1)
- ZEND_ARG_PASS_INFO(1)
- ZEND_END_ARG_INFO();
-
-zend_function_entry xml_functions[] = {
- PHP_FE(xml_parser_create, NULL)
- PHP_FE(xml_parser_create_ns, NULL)
- PHP_FE(xml_set_object, second_arg_force_ref)
- PHP_FE(xml_set_element_handler, NULL)
- PHP_FE(xml_set_character_data_handler, NULL)
- PHP_FE(xml_set_processing_instruction_handler, NULL)
- PHP_FE(xml_set_default_handler, NULL)
- PHP_FE(xml_set_unparsed_entity_decl_handler, NULL)
- PHP_FE(xml_set_notation_decl_handler, NULL)
- PHP_FE(xml_set_external_entity_ref_handler, NULL)
- PHP_FE(xml_set_start_namespace_decl_handler, NULL)
- PHP_FE(xml_set_end_namespace_decl_handler, NULL)
- PHP_FE(xml_parse, NULL)
- PHP_FE(xml_parse_into_struct, third_and_fourth_args_force_ref)
- PHP_FE(xml_get_error_code, NULL)
- PHP_FE(xml_error_string, NULL)
- PHP_FE(xml_get_current_line_number, NULL)
- PHP_FE(xml_get_current_column_number, NULL)
- PHP_FE(xml_get_current_byte_index, NULL)
- PHP_FE(xml_parser_free, NULL)
- PHP_FE(xml_parser_set_option, NULL)
- PHP_FE(xml_parser_get_option, NULL)
- PHP_FE(utf8_encode, NULL)
- PHP_FE(utf8_decode, NULL)
- {NULL, NULL, NULL}
-};
-
-#ifdef LIBXML_EXPAT_COMPAT
-static zend_module_dep xml_deps[] = {
- ZEND_MOD_REQUIRED("libxml")
- {NULL, NULL, NULL}
-};
-#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) {
-
- 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_pp = &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)
-{
- int pos = len;
- char *newbuf = emalloc(len + 1);
- unsigned short 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 > 0) {
- c = (unsigned char)(*s);
- if (c >= 0xf0) { /* four bytes encoded, 21 bits */
- c = ((s[0]&7)<<18) | ((s[1]&63)<<12) | ((s[2]&63)<<6) | (s[3]&63);
- s += 4;
- pos -= 4;
- } else if (c >= 0xe0) { /* three bytes encoded, 16 bits */
- c = ((s[0]&63)<<12) | ((s[1]&63)<<6) | (s[2]&63);
- s += 3;
- pos -= 3;
- } else if (c >= 0xc0) { /* two bytes encoded, 11 bits */
- c = ((s[0]&63)<<6) | (s[1]&63);
- s += 2;
- pos -= 2;
- } else {
- s++;
- pos--;
- }
- 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(tag_name);
- 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(tag_name);
-
- 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);
- strcpy(Z_STRVAL_PP(myval) + Z_STRLEN_PP(myval),decoded_value);
- 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);
- strcpy(Z_STRVAL_PP(myval) + Z_STRLEN_PP(myval),decoded_value);
- 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(sizeof(xml_parser), 1);
- 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_NUM_ARGS() != 2 ||
- zend_get_parameters_ex(2, &pind, &mythis) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- if (Z_TYPE_PP(mythis) != IS_OBJECT) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument 2 has wrong type");
- RETURN_FALSE;
- }
-
- 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);
- *parser->object = **mythis;
- zval_copy_ctor(parser->object);
- INIT_PZVAL(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_NUM_ARGS() != 3 ||
- zend_get_parameters_ex(3, &pind, &shdl, &ehdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- 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_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &pind, &hdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- 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_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &pind, &hdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- 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_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &pind, &hdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- 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_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &pind, &hdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- 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_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &pind, &hdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- 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_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &pind, &hdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- 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_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &pind, &hdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- 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_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &pind, &hdl) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- 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, **data, **final;
- int argc, isFinal, ret;
-
- argc = ZEND_NUM_ARGS();
- if (argc < 2 || argc > 3 || zend_get_parameters_ex(argc, &pind, &data, &final) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_string_ex(data);
-
- if (argc == 3) {
- convert_to_long_ex(final);
- isFinal = Z_LVAL_PP(final);
- } else {
- isFinal = 0;
- }
-
- parser->isparsing = 1;
- ret = XML_Parse(parser->parser, Z_STRVAL_PP(data), Z_STRLEN_PP(data), isFinal);
- parser->isparsing = 0;
- RETVAL_LONG(ret);
-}
-
-/* }}} */
-
-/* {{{ proto int xml_parse_into_struct(resource parser, string data, array &struct, array &index)
- Parsing a XML document */
-
-PHP_FUNCTION(xml_parse_into_struct)
-{
- xml_parser *parser;
- zval **pind, **data, **xdata, **info = 0;
- int ret;
-
- if (zend_get_parameters_ex(4, &pind, &data, &xdata,&info) == SUCCESS) {
- zval_dtor(*info);
- array_init(*info);
- } else if (zend_get_parameters_ex(3, &pind, &data, &xdata) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_string_ex(data);
- 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, Z_STRVAL_PP(data), Z_STRLEN_PP(data), 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_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &pind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- 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)
-{
- zval **code;
- char *str;
-
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &code) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_long_ex(code);
- str = (char *)XML_ErrorString((int)Z_LVAL_PP(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_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &pind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- 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_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &pind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- 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_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &pind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- 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_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &pind) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
-
- 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, **opt, **val;
-
- if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &pind, &opt, &val) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_long_ex(opt);
-
- switch (Z_LVAL_PP(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, **opt;
-
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &pind, &opt) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser);
-
- convert_to_long_ex(opt);
-
- switch (Z_LVAL_PP(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)
-{
- zval **arg;
- XML_Char *encoded;
- int len;
-
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string_ex(arg);
- encoded = xml_utf8_encode(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &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)
-{
- zval **arg;
- XML_Char *decoded;
- int len;
-
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
- convert_to_string_ex(arg);
- decoded = xml_utf8_decode(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &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
deleted file mode 100644
index ab60f28eed..0000000000
--- a/ext/xml/xml.mak
+++ /dev/null
@@ -1,172 +0,0 @@
-# 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