Debian Codegraph @

include/private/parser.h

raw
1 #ifndef XML_PARSER_H_PRIVATE__
2 #define XML_PARSER_H_PRIVATE__
3
4 #include <limits.h>
5
6 #include <libxml/parser.h>
7 #include <libxml/xmlversion.h>
8
9 #define XML_INVALID_CHAR 0x200000
10
11 #define XML_MAX_URI_LENGTH 2000
12
13 /**
14 * Set after xmlValidateDtdFinal was called.
15 */
16 #define XML_VCTXT_DTD_VALIDATED (1u << 0)
17 /**
18 * Set if the validation context is part of a parser context.
19 */
20 #define XML_VCTXT_USE_PCTXT (1u << 1)
21 /**
22 * Set if the validation is enabled.
23 */
24 #define XML_VCTXT_VALIDATE (1u << 2)
25 /**
26 * Set when parsing entities.
27 */
28 #define XML_VCTXT_IN_ENTITY (1u << 3)
29
30 /*
31 * TODO: Rename to avoid confusion with xmlParserInputFlags
32 */
33 #define XML_INPUT_HAS_ENCODING (1u << 0)
34 #define XML_INPUT_AUTO_ENCODING (7u << 1)
35 #define XML_INPUT_AUTO_UTF8 (1u << 1)
36 #define XML_INPUT_AUTO_UTF16LE (2u << 1)
37 #define XML_INPUT_AUTO_UTF16BE (3u << 1)
38 #define XML_INPUT_AUTO_OTHER (4u << 1)
39 #define XML_INPUT_USES_ENC_DECL (1u << 4)
40 #define XML_INPUT_ENCODING_ERROR (1u << 5)
41 #define XML_INPUT_PROGRESSIVE (1u << 6)
42 #define XML_INPUT_MARKUP_DECL (1u << 7)
43
44 #define PARSER_STOPPED(ctxt) ((ctxt)->disableSAX > 1)
45
46 #define PARSER_PROGRESSIVE(ctxt) \
47 ((ctxt)->input->flags & XML_INPUT_PROGRESSIVE)
48
49 #define PARSER_IN_PE(ctxt) \
50 (((ctxt)->input->entity != NULL) && \
51 (((ctxt)->input->entity->etype == XML_INTERNAL_PARAMETER_ENTITY) || \
52 ((ctxt)->input->entity->etype == XML_EXTERNAL_PARAMETER_ENTITY)))
53
54 #define PARSER_EXTERNAL(ctxt) \
55 (((ctxt)->inSubset == 2) || \
56 (((ctxt)->input->entity != NULL) && \
57 ((ctxt)->input->entity->etype == XML_EXTERNAL_PARAMETER_ENTITY)))
58
59 /**
60 * The parser tries to always have that amount of input ready.
61 * One of the point is providing context when reporting errors.
62 */
63 #define INPUT_CHUNK 250
64
65 struct _xmlAttrHashBucket {
66 int index;
67 };
68
69 #define XML_SCAN_NC 1
70 #define XML_SCAN_NMTOKEN 2
71 #define XML_SCAN_OLD10 4
72
73 XML_HIDDEN const xmlChar *
74 xmlScanName(const xmlChar *buf, size_t maxSize, int flags);
75
76 XML_HIDDEN void
77 xmlCtxtVErr(xmlParserCtxt *ctxt, xmlNode *node, xmlErrorDomain domain,
78 xmlParserErrors code, xmlErrorLevel level,
79 const xmlChar *str1, const xmlChar *str2, const xmlChar *str3,
80 int int1, const char *msg, va_list ap);
81 XML_HIDDEN void
82 xmlCtxtErr(xmlParserCtxt *ctxt, xmlNode *node, xmlErrorDomain domain,
83 xmlParserErrors code, xmlErrorLevel level,
84 const xmlChar *str1, const xmlChar *str2, const xmlChar *str3,
85 int int1, const char *msg, ...);
86 XML_HIDDEN void
87 xmlFatalErr(xmlParserCtxt *ctxt, xmlParserErrors error, const char *info);
88 XML_HIDDEN void LIBXML_ATTR_FORMAT(3,0)
89 xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
90 const char *msg, const xmlChar *str1, const xmlChar *str2);
91 XML_HIDDEN void
92 xmlCtxtErrIO(xmlParserCtxt *ctxt, int code, const char *uri);
93 XML_HIDDEN int
94 xmlCtxtIsCatastrophicError(xmlParserCtxt *ctxt);
95
96 XML_HIDDEN int
97 xmlParserGrow(xmlParserCtxt *ctxt);
98 XML_HIDDEN void
99 xmlParserShrink(xmlParserCtxt *ctxt);
100
101 XML_HIDDEN void
102 xmlDetectEncoding(xmlParserCtxt *ctxt);
103 XML_HIDDEN void
104 xmlSetDeclaredEncoding(xmlParserCtxt *ctxt, xmlChar *encoding);
105 XML_HIDDEN const xmlChar *
106 xmlGetActualEncoding(xmlParserCtxt *ctxt);
107
108 XML_HIDDEN int
109 nodePush(xmlParserCtxt *ctxt, xmlNode *value);
110 XML_HIDDEN xmlNode *
111 nodePop(xmlParserCtxt *ctxt);
112
113 XML_HIDDEN xmlParserNsData *
114 xmlParserNsCreate(void);
115 XML_HIDDEN void
116 xmlParserNsFree(xmlParserNsData *nsdb);
117 /*
118 * These functions allow SAX handlers to attach extra data to namespaces
119 * efficiently and should be made public.
120 */
121 XML_HIDDEN int
122 xmlParserNsUpdateSax(xmlParserCtxt *ctxt, const xmlChar *prefix,
123 void *saxData);
124 XML_HIDDEN void *
125 xmlParserNsLookupSax(xmlParserCtxt *ctxt, const xmlChar *prefix);
126
127 XML_HIDDEN xmlParserInput *
128 xmlLoadResource(xmlParserCtxt *ctxt, const char *url, const char *publicId,
129 xmlResourceType type);
130 XML_HIDDEN xmlParserInput *
131 xmlCtxtNewInputFromUrl(xmlParserCtxt *ctxt, const char *url,
132 const char *publicId, const char *encoding,
133 xmlParserInputFlags flags);
134 XML_HIDDEN xmlParserInput *
135 xmlCtxtNewInputFromMemory(xmlParserCtxt *ctxt, const char *url,
136 const void *mem, size_t size,
137 const char *encoding,
138 xmlParserInputFlags flags);
139 XML_HIDDEN xmlParserInput *
140 xmlCtxtNewInputFromString(xmlParserCtxt *ctxt, const char *url,
141 const char *str, const char *encoding,
142 xmlParserInputFlags flags);
143 XML_HIDDEN xmlParserInput *
144 xmlCtxtNewInputFromFd(xmlParserCtxt *ctxt, const char *filename, int fd,
145 const char *encoding, xmlParserInputFlags flags);
146 XML_HIDDEN xmlParserInput *
147 xmlCtxtNewInputFromIO(xmlParserCtxt *ctxt, const char *url,
148 xmlInputReadCallback ioRead,
149 xmlInputCloseCallback ioClose,
150 void *ioCtxt,
151 const char *encoding, xmlParserInputFlags flags);
152 XML_HIDDEN xmlParserInput *
153 xmlNewPushInput(const char *url, const char *chunk, int size);
154
155 XML_HIDDEN xmlChar *
156 xmlExpandEntitiesInAttValue(xmlParserCtxt *ctxt, const xmlChar *str,
157 int normalize);
158
159 XML_HIDDEN void
160 xmlParserCheckEOF(xmlParserCtxt *ctxt, xmlParserErrors code);
161
162 XML_HIDDEN void
163 xmlParserInputGetWindow(xmlParserInput *input, const xmlChar **startOut,
164 int *sizeInOut, int *offsetOut);
165
166 static XML_INLINE void
167 xmlSaturatedAdd(unsigned long *dst, unsigned long val) {
168 if (val > ULONG_MAX - *dst)
169 *dst = ULONG_MAX;
170 else
171 *dst += val;
172 }
173
174 static XML_INLINE void
175 xmlSaturatedAddSizeT(unsigned long *dst, size_t val) {
176 if (val > ULONG_MAX - *dst)
177 *dst = ULONG_MAX;
178 else
179 *dst += val;
180 }
181
182 #endif /* XML_PARSER_H_PRIVATE__ */