expat_compat.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 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. /* $Id$ */
  19. #ifndef PHP_EXPAT_COMPAT_H
  20. #define PHP_EXPAT_COMPAT_H
  21. #ifdef PHP_WIN32
  22. #include "config.w32.h"
  23. #else
  24. #include <php_config.h>
  25. #endif
  26. #if !defined(HAVE_LIBEXPAT) && defined(HAVE_LIBXML)
  27. #define LIBXML_EXPAT_COMPAT 1
  28. #include "php.h"
  29. #include "php_compat.h"
  30. #include <libxml/parser.h>
  31. #include <libxml/parserInternals.h>
  32. #include <libxml/tree.h>
  33. #include <libxml/hash.h>
  34. /* For compatibility with the misspelled version. */
  35. #define _ns_seperator _ns_separator
  36. typedef xmlChar XML_Char;
  37. typedef void (*XML_StartElementHandler)(void *, const XML_Char *, const XML_Char **);
  38. typedef void (*XML_EndElementHandler)(void *, const XML_Char *);
  39. typedef void (*XML_CharacterDataHandler)(void *, const XML_Char *, int);
  40. typedef void (*XML_ProcessingInstructionHandler)(void *, const XML_Char *, const XML_Char *);
  41. typedef void (*XML_CommentHandler)(void *, const XML_Char *);
  42. typedef void (*XML_DefaultHandler)(void *, const XML_Char *, int);
  43. typedef void (*XML_UnparsedEntityDeclHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
  44. typedef void (*XML_NotationDeclHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
  45. typedef int (*XML_ExternalEntityRefHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
  46. typedef void (*XML_StartNamespaceDeclHandler)(void *, const XML_Char *, const XML_Char *);
  47. typedef void (*XML_EndNamespaceDeclHandler)(void *, const XML_Char *);
  48. typedef struct _XML_Memory_Handling_Suite {
  49. void *(*malloc_fcn)(size_t size);
  50. void *(*realloc_fcn)(void *ptr, size_t size);
  51. void (*free_fcn)(void *ptr);
  52. } XML_Memory_Handling_Suite;
  53. typedef struct _XML_Parser {
  54. int use_namespace;
  55. xmlChar *_ns_separator;
  56. void *user;
  57. xmlParserCtxtPtr parser;
  58. XML_StartElementHandler h_start_element;
  59. XML_EndElementHandler h_end_element;
  60. XML_CharacterDataHandler h_cdata;
  61. XML_ProcessingInstructionHandler h_pi;
  62. XML_CommentHandler h_comment;
  63. XML_DefaultHandler h_default;
  64. XML_UnparsedEntityDeclHandler h_unparsed_entity_decl;
  65. XML_NotationDeclHandler h_notation_decl;
  66. XML_ExternalEntityRefHandler h_external_entity_ref;
  67. XML_StartNamespaceDeclHandler h_start_ns;
  68. XML_EndNamespaceDeclHandler h_end_ns;
  69. } *XML_Parser;
  70. enum XML_Error {
  71. XML_ERROR_NONE,
  72. XML_ERROR_NO_MEMORY,
  73. XML_ERROR_SYNTAX,
  74. XML_ERROR_NO_ELEMENTS,
  75. XML_ERROR_INVALID_TOKEN,
  76. XML_ERROR_UNCLOSED_TOKEN,
  77. XML_ERROR_PARTIAL_CHAR,
  78. XML_ERROR_TAG_MISMATCH,
  79. XML_ERROR_DUPLICATE_ATTRIBUTE,
  80. XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
  81. XML_ERROR_PARAM_ENTITY_REF,
  82. XML_ERROR_UNDEFINED_ENTITY,
  83. XML_ERROR_RECURSIVE_ENTITY_REF,
  84. XML_ERROR_ASYNC_ENTITY,
  85. XML_ERROR_BAD_CHAR_REF,
  86. XML_ERROR_BINARY_ENTITY_REF,
  87. XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
  88. XML_ERROR_MISPLACED_XML_PI,
  89. XML_ERROR_UNKNOWN_ENCODING,
  90. XML_ERROR_INCORRECT_ENCODING,
  91. XML_ERROR_UNCLOSED_CDATA_SECTION,
  92. XML_ERROR_EXTERNAL_ENTITY_HANDLING,
  93. XML_ERROR_NOT_STANDALONE,
  94. XML_ERROR_UNEXPECTED_STATE,
  95. XML_ERROR_ENTITY_DECLARED_IN_PE,
  96. XML_ERROR_FEATURE_REQUIRES_XML_DTD,
  97. XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING
  98. };
  99. enum XML_Content_Type {
  100. XML_CTYPE_EMPTY = 1,
  101. XML_CTYPE_ANY,
  102. XML_CTYPE_MIXED,
  103. XML_CTYPE_NAME,
  104. XML_CTYPE_CHOICE,
  105. XML_CTYPE_SEQ
  106. };
  107. PHPAPI XML_Parser XML_ParserCreate(const XML_Char *);
  108. PHPAPI XML_Parser XML_ParserCreateNS(const XML_Char *, const XML_Char);
  109. PHPAPI XML_Parser XML_ParserCreate_MM(const XML_Char *, const XML_Memory_Handling_Suite *, const XML_Char *);
  110. PHPAPI void XML_SetUserData(XML_Parser, void *);
  111. PHPAPI void *XML_GetUserData(XML_Parser);
  112. PHPAPI void XML_SetElementHandler(XML_Parser, XML_StartElementHandler, XML_EndElementHandler);
  113. PHPAPI void XML_SetCharacterDataHandler(XML_Parser, XML_CharacterDataHandler);
  114. PHPAPI void XML_SetProcessingInstructionHandler(XML_Parser, XML_ProcessingInstructionHandler);
  115. PHPAPI void XML_SetDefaultHandler(XML_Parser, XML_DefaultHandler);
  116. PHPAPI void XML_SetUnparsedEntityDeclHandler(XML_Parser, XML_UnparsedEntityDeclHandler);
  117. PHPAPI void XML_SetNotationDeclHandler(XML_Parser, XML_NotationDeclHandler);
  118. PHPAPI void XML_SetExternalEntityRefHandler(XML_Parser, XML_ExternalEntityRefHandler);
  119. PHPAPI void XML_SetStartNamespaceDeclHandler(XML_Parser, XML_StartNamespaceDeclHandler);
  120. PHPAPI void XML_SetEndNamespaceDeclHandler(XML_Parser, XML_EndNamespaceDeclHandler);
  121. PHPAPI int XML_Parse(XML_Parser, const XML_Char *, int data_len, int is_final);
  122. PHPAPI int XML_GetErrorCode(XML_Parser);
  123. PHPAPI const XML_Char *XML_ErrorString(int);
  124. PHPAPI int XML_GetCurrentLineNumber(XML_Parser);
  125. PHPAPI int XML_GetCurrentColumnNumber(XML_Parser);
  126. PHPAPI int XML_GetCurrentByteIndex(XML_Parser);
  127. PHPAPI int XML_GetCurrentByteCount(XML_Parser);
  128. PHPAPI const XML_Char *XML_ExpatVersion(void);
  129. PHPAPI void XML_ParserFree(XML_Parser);
  130. #elif defined(HAVE_LIBEXPAT)
  131. #include <expat.h>
  132. #endif /* HAVE_LIBEXPAT */
  133. #endif /* PHP_EXPAT_COMPAT_H */
  134. /*
  135. * Local variables:
  136. * tab-width: 4
  137. * c-basic-offset: 4
  138. * End:
  139. */