summaryrefslogtreecommitdiff
path: root/ext/xml/expat_compat.h
blob: 1ece0bd60816097501380d2b00657bac548cc7a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
   +----------------------------------------------------------------------+
   | PHP Version 4                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2003 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 2.02 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available at through the world-wide-web at                           |
   | http://www.php.net/license/2_02.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

#if !defined(HAVE_LIBEXPAT) && defined(HAVE_LIBXML)
#define LIBXML_EXPAT_COMPAT 1

#include <libxml.h>
#include <libxml/hash.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/tree.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_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_Parser {
	int namespace;

	xmlHashTablePtr _ns_map;
	xmlHashTablePtr _reverse_ns_map;
	
	void *user;
	xmlParserCtxtPtr parser;

	XML_StartElementHandler          h_start_element;
	XML_EndElementHandler            h_end_element;
	XML_CharacterDataHandler         h_cdata;
	XML_ProcessingInstructionHandler h_pi;
	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;

XML_Parser XML_ParserCreate(const XML_Char *);
XML_Parser XML_ParserCreateNS(const XML_Char *, const XML_Char);
void XML_SetUserData(XML_Parser, void *);
void *XML_GetUserData(XML_Parser);
void XML_SetElementHandler(XML_Parser, XML_StartElementHandler, XML_EndElementHandler);
void XML_SetCharacterDataHandler(XML_Parser, XML_CharacterDataHandler);
void XML_SetProcessingInstructionHandler(XML_Parser, XML_ProcessingInstructionHandler);
void XML_SetDefaultHandler(XML_Parser, XML_DefaultHandler);
void XML_SetUnparsedEntityDeclHandler(XML_Parser, XML_UnparsedEntityDeclHandler);
void XML_SetNotationDeclHandler(XML_Parser, XML_NotationDeclHandler);
void XML_SetExternalEntityRefHandler(XML_Parser, XML_ExternalEntityRefHandler);
void XML_SetStartNamespaceDeclHandler(XML_Parser, XML_StartNamespaceDeclHandler);
void XML_SetEndNamespaceDeclHandler(XML_Parser, XML_EndNamespaceDeclHandler);
int  XML_Parse(XML_Parser, const XML_Char *, int data_len, int is_final);
int  XML_GetErrorCode(XML_Parser);
const XML_Char *XML_ErrorString(int);
int  XML_GetCurrentLineNumber(XML_Parser);
int  XML_GetCurrentColumnNumber(XML_Parser);
int  XML_GetCurrentByteIndex(XML_Parser);
const XML_Char *XML_ExpatVersion(void);
void XML_ParserFree(XML_Parser);

#define XML_ERROR_NONE 0
#define XML_ERROR_NO_MEMORY 0
#define XML_ERROR_SYNTAX 0
#define XML_ERROR_NO_ELEMENTS 0
#define XML_ERROR_INVALID_TOKEN 0
#define XML_ERROR_UNCLOSED_TOKEN 0
#define XML_ERROR_PARTIAL_CHAR 0
#define XML_ERROR_TAG_MISMATCH 0
#define XML_ERROR_DUPLICATE_ATTRIBUTE 0
#define XML_ERROR_JUNK_AFTER_DOC_ELEMENT 0
#define XML_ERROR_PARAM_ENTITY_REF 0
#define XML_ERROR_UNDEFINED_ENTITY 0
#define XML_ERROR_RECURSIVE_ENTITY_REF 0
#define XML_ERROR_ASYNC_ENTITY 0
#define XML_ERROR_BAD_CHAR_REF 0
#define XML_ERROR_BINARY_ENTITY_REF 0
#define XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF 0
#define XML_ERROR_MISPLACED_XML_PI 0
#define XML_ERROR_UNKNOWN_ENCODING 0
#define XML_ERROR_INCORRECT_ENCODING 0
#define XML_ERROR_UNCLOSED_CDATA_SECTION 0
#define XML_ERROR_EXTERNAL_ENTITY_HANDLING 0

#else 
#include <expat.h>
#endif /* HAVE_LIBEXPAT */

#endif /* PHP_EXPAT_COMPAT_H */

/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 */