1 /* 2 +----------------------------------------------------------------------+ 3 | PHP Version 5 | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) 1997-2014 The PHP Group | 6 +----------------------------------------------------------------------+ 7 | This source file is subject to version 3.01 of the PHP license, | 8 | that is bundled with this package in the file LICENSE, and is | 9 | available through the world-wide-web at the following url: | 10 | http://www.php.net/license/3_01.txt | 11 | If you did not receive a copy of the PHP license and are unable to | 12 | obtain it through the world-wide-web, please send a note to | 13 | license@php.net so we can mail you a copy immediately. | 14 +----------------------------------------------------------------------+ 15 | Authors: Sterling Hughes <sterling@php.net> | 16 +----------------------------------------------------------------------+ 17 */ 18 19 /* $Id$ */ 20 21 #ifndef PHP_EXPAT_COMPAT_H 22 #define PHP_EXPAT_COMPAT_H 23 24 #ifdef PHP_WIN32 25 #include "config.w32.h" 26 #else 27 #include <php_config.h> 28 #endif 29 30 #if !defined(HAVE_LIBEXPAT) && defined(HAVE_LIBXML) 31 #define LIBXML_EXPAT_COMPAT 1 32 33 #include "php.h" 34 #include "php_compat.h" 35 36 #include <libxml/parser.h> 37 #include <libxml/parserInternals.h> 38 #include <libxml/tree.h> 39 #include <libxml/hash.h> 40 41 typedef xmlChar XML_Char; 42 43 typedef void (*XML_StartElementHandler)(void *, const XML_Char *, const XML_Char **); 44 typedef void (*XML_EndElementHandler)(void *, const XML_Char *); 45 typedef void (*XML_CharacterDataHandler)(void *, const XML_Char *, int); 46 typedef void (*XML_ProcessingInstructionHandler)(void *, const XML_Char *, const XML_Char *); 47 typedef void (*XML_CommentHandler)(void *, const XML_Char *); 48 typedef void (*XML_DefaultHandler)(void *, const XML_Char *, int); 49 typedef void (*XML_UnparsedEntityDeclHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *); 50 typedef void (*XML_NotationDeclHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *); 51 typedef int (*XML_ExternalEntityRefHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *); 52 typedef void (*XML_StartNamespaceDeclHandler)(void *, const XML_Char *, const XML_Char *); 53 typedef void (*XML_EndNamespaceDeclHandler)(void *, const XML_Char *); 54 55 typedef struct _XML_Memory_Handling_Suite { 56 void *(*malloc_fcn)(size_t size); 57 void *(*realloc_fcn)(void *ptr, size_t size); 58 void (*free_fcn)(void *ptr); 59 } XML_Memory_Handling_Suite; 60 61 typedef struct _XML_Parser { 62 int use_namespace; 63 64 xmlChar *_ns_seperator; 65 66 void *user; 67 xmlParserCtxtPtr parser; 68 69 XML_StartElementHandler h_start_element; 70 XML_EndElementHandler h_end_element; 71 XML_CharacterDataHandler h_cdata; 72 XML_ProcessingInstructionHandler h_pi; 73 XML_CommentHandler h_comment; 74 XML_DefaultHandler h_default; 75 XML_UnparsedEntityDeclHandler h_unparsed_entity_decl; 76 XML_NotationDeclHandler h_notation_decl; 77 XML_ExternalEntityRefHandler h_external_entity_ref; 78 XML_StartNamespaceDeclHandler h_start_ns; 79 XML_EndNamespaceDeclHandler h_end_ns; 80 } *XML_Parser; 81 82 enum XML_Error { 83 XML_ERROR_NONE, 84 XML_ERROR_NO_MEMORY, 85 XML_ERROR_SYNTAX, 86 XML_ERROR_NO_ELEMENTS, 87 XML_ERROR_INVALID_TOKEN, 88 XML_ERROR_UNCLOSED_TOKEN, 89 XML_ERROR_PARTIAL_CHAR, 90 XML_ERROR_TAG_MISMATCH, 91 XML_ERROR_DUPLICATE_ATTRIBUTE, 92 XML_ERROR_JUNK_AFTER_DOC_ELEMENT, 93 XML_ERROR_PARAM_ENTITY_REF, 94 XML_ERROR_UNDEFINED_ENTITY, 95 XML_ERROR_RECURSIVE_ENTITY_REF, 96 XML_ERROR_ASYNC_ENTITY, 97 XML_ERROR_BAD_CHAR_REF, 98 XML_ERROR_BINARY_ENTITY_REF, 99 XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, 100 XML_ERROR_MISPLACED_XML_PI, 101 XML_ERROR_UNKNOWN_ENCODING, 102 XML_ERROR_INCORRECT_ENCODING, 103 XML_ERROR_UNCLOSED_CDATA_SECTION, 104 XML_ERROR_EXTERNAL_ENTITY_HANDLING, 105 XML_ERROR_NOT_STANDALONE, 106 XML_ERROR_UNEXPECTED_STATE, 107 XML_ERROR_ENTITY_DECLARED_IN_PE, 108 XML_ERROR_FEATURE_REQUIRES_XML_DTD, 109 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING 110 }; 111 112 enum XML_Content_Type { 113 XML_CTYPE_EMPTY = 1, 114 XML_CTYPE_ANY, 115 XML_CTYPE_MIXED, 116 XML_CTYPE_NAME, 117 XML_CTYPE_CHOICE, 118 XML_CTYPE_SEQ 119 }; 120 121 PHPAPI XML_Parser XML_ParserCreate(const XML_Char *); 122 PHPAPI XML_Parser XML_ParserCreateNS(const XML_Char *, const XML_Char); 123 PHPAPI XML_Parser XML_ParserCreate_MM(const XML_Char *, const XML_Memory_Handling_Suite *, const XML_Char *); 124 PHPAPI void XML_SetUserData(XML_Parser, void *); 125 PHPAPI void *XML_GetUserData(XML_Parser); 126 PHPAPI void XML_SetElementHandler(XML_Parser, XML_StartElementHandler, XML_EndElementHandler); 127 PHPAPI void XML_SetCharacterDataHandler(XML_Parser, XML_CharacterDataHandler); 128 PHPAPI void XML_SetProcessingInstructionHandler(XML_Parser, XML_ProcessingInstructionHandler); 129 PHPAPI void XML_SetDefaultHandler(XML_Parser, XML_DefaultHandler); 130 PHPAPI void XML_SetUnparsedEntityDeclHandler(XML_Parser, XML_UnparsedEntityDeclHandler); 131 PHPAPI void XML_SetNotationDeclHandler(XML_Parser, XML_NotationDeclHandler); 132 PHPAPI void XML_SetExternalEntityRefHandler(XML_Parser, XML_ExternalEntityRefHandler); 133 PHPAPI void XML_SetStartNamespaceDeclHandler(XML_Parser, XML_StartNamespaceDeclHandler); 134 PHPAPI void XML_SetEndNamespaceDeclHandler(XML_Parser, XML_EndNamespaceDeclHandler); 135 PHPAPI int XML_Parse(XML_Parser, const XML_Char *, int data_len, int is_final); 136 PHPAPI int XML_GetErrorCode(XML_Parser); 137 PHPAPI const XML_Char *XML_ErrorString(int); 138 PHPAPI int XML_GetCurrentLineNumber(XML_Parser); 139 PHPAPI int XML_GetCurrentColumnNumber(XML_Parser); 140 PHPAPI int XML_GetCurrentByteIndex(XML_Parser); 141 PHPAPI int XML_GetCurrentByteCount(XML_Parser); 142 PHPAPI const XML_Char *XML_ExpatVersion(void); 143 PHPAPI void XML_ParserFree(XML_Parser); 144 145 #elif defined(HAVE_LIBEXPAT) 146 #include <expat.h> 147 #endif /* HAVE_LIBEXPAT */ 148 149 #endif /* PHP_EXPAT_COMPAT_H */ 150 151 /* 152 * Local variables: 153 * tab-width: 4 154 * c-basic-offset: 4 155 * End: 156 */ 157