1 /* libxml2 - Library for parsing XML documents
2 * Copyright (C) 2006-2019 Free Software Foundation, Inc.
3 *
4 * This file is not part of the GNU gettext program, but is used with
5 * GNU gettext.
6 *
7 * The original copyright notice is as follows:
8 */
9
10 /*
11 * Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved.
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a copy
14 * of this software and associated documentation files (the "Software"), to deal
15 * in the Software without restriction, including without limitation the rights
16 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 * copies of the Software, and to permit persons to whom the Software is fur-
18 * nished to do so, subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included in
21 * all copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
25 * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 * THE SOFTWARE.
30 *
31 * Author: Gary Pennington <Gary.Pennington@uk.sun.com>, Daniel Veillard
32 */
33
34 /*
35 * Summary: interface for all global variables of the library
36 * Description: all the global variables and thread handling for
37 * those variables is handled by this module.
38 *
39 * The bottom of this file is automatically generated by build_glob.py
40 * based on the description file global.data
41 */
42
43 #ifndef __XML_GLOBALS_H
44 #define __XML_GLOBALS_H
45
46 #include <libxml/xmlversion.h>
47 #include <libxml/parser.h>
48 #include <libxml/xmlerror.h>
49 #include <libxml/SAX2.h>
50 #include <libxml/xmlmemory.h>
51
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55
56 XMLPUBFUN void XMLCALL xmlInitGlobals(void);
57 XMLPUBFUN void XMLCALL xmlCleanupGlobals(void);
58
59 /**
60 * xmlParserInputBufferCreateFilenameFunc:
61 * @URI: the URI to read from
62 * @enc: the requested source encoding
63 *
64 * Signature for the function doing the lookup for a suitable input method
65 * corresponding to an URI.
66 *
67 * Returns the new xmlParserInputBufferPtr in case of success or NULL if no
68 * method was found.
69 */
70 typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI,
71 xmlCharEncoding enc);
72
73
74 /**
75 * xmlOutputBufferCreateFilenameFunc:
76 * @URI: the URI to write to
77 * @enc: the requested target encoding
78 *
79 * Signature for the function doing the lookup for a suitable output method
80 * corresponding to an URI.
81 *
82 * Returns the new xmlOutputBufferPtr in case of success or NULL if no
83 * method was found.
84 */
85 typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI,
86 xmlCharEncodingHandlerPtr encoder,
87 int compression);
88
89 XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
90 XMLCALL xmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFunc func);
91 XMLPUBFUN xmlOutputBufferCreateFilenameFunc
92 XMLCALL xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc func);
93
94 #if !defined IN_LIBTEXTSTYLE
95
96 /*
97 * Externally global symbols which need to be protected for backwards
98 * compatibility support.
99 */
100
101 #undef docbDefaultSAXHandler
102 #undef htmlDefaultSAXHandler
103 #undef oldXMLWDcompatibility
104 #undef xmlBufferAllocScheme
105 #undef xmlDefaultBufferSize
106 #undef xmlDefaultSAXHandler
107 #undef xmlDefaultSAXLocator
108 #undef xmlDoValidityCheckingDefaultValue
109 #undef xmlFree
110 #undef xmlGenericError
111 #undef xmlStructuredError
112 #undef xmlGenericErrorContext
113 #undef xmlStructuredErrorContext
114 #undef xmlGetWarningsDefaultValue
115 #undef xmlIndentTreeOutput
116 #undef xmlTreeIndentString
117 #undef xmlKeepBlanksDefaultValue
118 #undef xmlLineNumbersDefaultValue
119 #undef xmlLoadExtDtdDefaultValue
120 #undef xmlMalloc
121 #undef xmlMallocAtomic
122 #undef xmlMemStrdup
123 #undef xmlParserDebugEntities
124 #undef xmlParserVersion
125 #undef xmlPedanticParserDefaultValue
126 #undef xmlRealloc
127 #undef xmlSaveNoEmptyTags
128 #undef xmlSubstituteEntitiesDefaultValue
129 #undef xmlRegisterNodeDefaultValue
130 #undef xmlDeregisterNodeDefaultValue
131 #undef xmlLastError
132 #undef xmlParserInputBufferCreateFilenameValue
133 #undef xmlOutputBufferCreateFilenameValue
134
135 #endif
136
137 /**
138 * xmlRegisterNodeFunc:
139 * @node: the current node
140 *
141 * Signature for the registration callback of a created node
142 */
143 typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node);
144 /**
145 * xmlDeregisterNodeFunc:
146 * @node: the current node
147 *
148 * Signature for the deregistration callback of a discarded node
149 */
150 typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);
151
152 typedef struct _xmlGlobalState xmlGlobalState;
153 typedef xmlGlobalState *xmlGlobalStatePtr;
154 struct _xmlGlobalState
155 {
156 const char *xmlParserVersion;
157
158 xmlSAXLocator xmlDefaultSAXLocator;
159 xmlSAXHandlerV1 xmlDefaultSAXHandler;
160 xmlSAXHandlerV1 docbDefaultSAXHandler;
161 xmlSAXHandlerV1 htmlDefaultSAXHandler;
162
163 xmlFreeFunc xmlFree;
164 xmlMallocFunc xmlMalloc;
165 xmlStrdupFunc xmlMemStrdup;
166 xmlReallocFunc xmlRealloc;
167
168 xmlGenericErrorFunc xmlGenericError;
169 xmlStructuredErrorFunc xmlStructuredError;
170 void *xmlGenericErrorContext;
171
172 int oldXMLWDcompatibility;
173
174 xmlBufferAllocationScheme xmlBufferAllocScheme;
175 int xmlDefaultBufferSize;
176
177 int xmlSubstituteEntitiesDefaultValue;
178 int xmlDoValidityCheckingDefaultValue;
179 int xmlGetWarningsDefaultValue;
180 int xmlKeepBlanksDefaultValue;
181 int xmlLineNumbersDefaultValue;
182 int xmlLoadExtDtdDefaultValue;
183 int xmlParserDebugEntities;
184 int xmlPedanticParserDefaultValue;
185
186 int xmlSaveNoEmptyTags;
187 int xmlIndentTreeOutput;
188 const char *xmlTreeIndentString;
189
190 xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
191 xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
192
193 xmlMallocFunc xmlMallocAtomic;
194 xmlError xmlLastError;
195
196 xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
197 xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
198
199 void *xmlStructuredErrorContext;
200 };
201
202 #ifdef __cplusplus
203 }
204 #endif
205 #include <libxml/threads.h>
206 #ifdef __cplusplus
207 extern "C" {
208 #endif
209
210 XMLPUBFUN void XMLCALL xmlInitializeGlobalState(xmlGlobalStatePtr gs);
211
212 XMLPUBFUN void XMLCALL xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler);
213
214 XMLPUBFUN void XMLCALL xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler);
215
216 XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlRegisterNodeDefault(xmlRegisterNodeFunc func);
217 XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func);
218 XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func);
219 XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func);
220
221 XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL
222 xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func);
223 XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL
224 xmlThrDefParserInputBufferCreateFilenameDefault(
225 xmlParserInputBufferCreateFilenameFunc func);
226
227 /** DOC_DISABLE */
228 /*
229 * In general the memory allocation entry points are not kept
230 * thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED
231 * - xmlMalloc
232 * - xmlMallocAtomic
233 * - xmlRealloc
234 * - xmlMemStrdup
235 * - xmlFree
236 */
237
238 #ifdef LIBXML_THREAD_ALLOC_ENABLED
239 #ifdef LIBXML_THREAD_ENABLED
240 XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMalloc(void);
241 #define xmlMalloc \
242 (*(__xmlMalloc()))
243 #else
244 XMLPUBVAR xmlMallocFunc xmlMalloc;
245 #endif
246
247 #ifdef LIBXML_THREAD_ENABLED
248 XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMallocAtomic(void);
249 #define xmlMallocAtomic \
250 (*(__xmlMallocAtomic()))
251 #else
252 XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
253 #endif
254
255 #ifdef LIBXML_THREAD_ENABLED
256 XMLPUBFUN xmlReallocFunc * XMLCALL __xmlRealloc(void);
257 #define xmlRealloc \
258 (*(__xmlRealloc()))
259 #else
260 XMLPUBVAR xmlReallocFunc xmlRealloc;
261 #endif
262
263 #ifdef LIBXML_THREAD_ENABLED
264 XMLPUBFUN xmlFreeFunc * XMLCALL __xmlFree(void);
265 #define xmlFree \
266 (*(__xmlFree()))
267 #else
268 XMLPUBVAR xmlFreeFunc xmlFree;
269 #endif
270
271 #ifdef LIBXML_THREAD_ENABLED
272 XMLPUBFUN xmlStrdupFunc * XMLCALL __xmlMemStrdup(void);
273 #define xmlMemStrdup \
274 (*(__xmlMemStrdup()))
275 #else
276 XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
277 #endif
278
279 #else /* !LIBXML_THREAD_ALLOC_ENABLED */
280 XMLPUBVAR xmlMallocFunc xmlMalloc;
281 XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
282 XMLPUBVAR xmlReallocFunc xmlRealloc;
283 XMLPUBVAR xmlFreeFunc xmlFree;
284 XMLPUBVAR xmlStrdupFunc xmlMemStrdup;
285 #endif /* LIBXML_THREAD_ALLOC_ENABLED */
286
287 #ifdef LIBXML_DOCB_ENABLED
288 XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __docbDefaultSAXHandler(void);
289 #ifdef LIBXML_THREAD_ENABLED
290 #define docbDefaultSAXHandler \
291 (*(__docbDefaultSAXHandler()))
292 #else
293 XMLPUBVAR xmlSAXHandlerV1 docbDefaultSAXHandler;
294 #endif
295 #endif
296
297 #ifdef LIBXML_HTML_ENABLED
298 XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __htmlDefaultSAXHandler(void);
299 #ifdef LIBXML_THREAD_ENABLED
300 #define htmlDefaultSAXHandler \
301 (*(__htmlDefaultSAXHandler()))
302 #else
303 XMLPUBVAR xmlSAXHandlerV1 htmlDefaultSAXHandler;
304 #endif
305 #endif
306
307 XMLPUBFUN xmlError * XMLCALL __xmlLastError(void);
308 #ifdef LIBXML_THREAD_ENABLED
309 #define xmlLastError \
310 (*(__xmlLastError()))
311 #else
312 XMLPUBVAR xmlError xmlLastError;
313 #endif
314
315 /*
316 * Everything starting from the line below is
317 * Automatically generated by build_glob.py.
318 * Do not modify the previous line.
319 */
320
321
322 XMLPUBFUN int * XMLCALL __oldXMLWDcompatibility(void);
323 #ifdef LIBXML_THREAD_ENABLED
324 #define oldXMLWDcompatibility \
325 (*(__oldXMLWDcompatibility()))
326 #else
327 XMLPUBVAR int oldXMLWDcompatibility;
328 #endif
329
330 XMLPUBFUN xmlBufferAllocationScheme * XMLCALL __xmlBufferAllocScheme(void);
331 #ifdef LIBXML_THREAD_ENABLED
332 #define xmlBufferAllocScheme \
333 (*(__xmlBufferAllocScheme()))
334 #else
335 XMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme;
336 #endif
337 XMLPUBFUN xmlBufferAllocationScheme XMLCALL
338 xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v);
339
340 XMLPUBFUN int * XMLCALL __xmlDefaultBufferSize(void);
341 #ifdef LIBXML_THREAD_ENABLED
342 #define xmlDefaultBufferSize \
343 (*(__xmlDefaultBufferSize()))
344 #else
345 XMLPUBVAR int xmlDefaultBufferSize;
346 #endif
347 XMLPUBFUN int XMLCALL xmlThrDefDefaultBufferSize(int v);
348
349 XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __xmlDefaultSAXHandler(void);
350 #ifdef LIBXML_THREAD_ENABLED
351 #define xmlDefaultSAXHandler \
352 (*(__xmlDefaultSAXHandler()))
353 #else
354 XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler;
355 #endif
356
357 XMLPUBFUN xmlSAXLocator * XMLCALL __xmlDefaultSAXLocator(void);
358 #ifdef LIBXML_THREAD_ENABLED
359 #define xmlDefaultSAXLocator \
360 (*(__xmlDefaultSAXLocator()))
361 #else
362 XMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator;
363 #endif
364
365 XMLPUBFUN int * XMLCALL __xmlDoValidityCheckingDefaultValue(void);
366 #ifdef LIBXML_THREAD_ENABLED
367 #define xmlDoValidityCheckingDefaultValue \
368 (*(__xmlDoValidityCheckingDefaultValue()))
369 #else
370 XMLPUBVAR int xmlDoValidityCheckingDefaultValue;
371 #endif
372 XMLPUBFUN int XMLCALL xmlThrDefDoValidityCheckingDefaultValue(int v);
373
374 XMLPUBFUN xmlGenericErrorFunc * XMLCALL __xmlGenericError(void);
375 #ifdef LIBXML_THREAD_ENABLED
376 #define xmlGenericError \
377 (*(__xmlGenericError()))
378 #else
379 XMLPUBVAR xmlGenericErrorFunc xmlGenericError;
380 #endif
381
382 XMLPUBFUN xmlStructuredErrorFunc * XMLCALL __xmlStructuredError(void);
383 #ifdef LIBXML_THREAD_ENABLED
384 #define xmlStructuredError \
385 (*(__xmlStructuredError()))
386 #else
387 XMLPUBVAR xmlStructuredErrorFunc xmlStructuredError;
388 #endif
389
390 XMLPUBFUN void * * XMLCALL __xmlGenericErrorContext(void);
391 #ifdef LIBXML_THREAD_ENABLED
392 #define xmlGenericErrorContext \
393 (*(__xmlGenericErrorContext()))
394 #else
395 XMLPUBVAR void * xmlGenericErrorContext;
396 #endif
397
398 XMLPUBFUN void * * XMLCALL __xmlStructuredErrorContext(void);
399 #ifdef LIBXML_THREAD_ENABLED
400 #define xmlStructuredErrorContext \
401 (*(__xmlStructuredErrorContext()))
402 #else
403 XMLPUBVAR void * xmlStructuredErrorContext;
404 #endif
405
406 XMLPUBFUN int * XMLCALL __xmlGetWarningsDefaultValue(void);
407 #ifdef LIBXML_THREAD_ENABLED
408 #define xmlGetWarningsDefaultValue \
409 (*(__xmlGetWarningsDefaultValue()))
410 #else
411 XMLPUBVAR int xmlGetWarningsDefaultValue;
412 #endif
413 XMLPUBFUN int XMLCALL xmlThrDefGetWarningsDefaultValue(int v);
414
415 XMLPUBFUN int * XMLCALL __xmlIndentTreeOutput(void);
416 #ifdef LIBXML_THREAD_ENABLED
417 #define xmlIndentTreeOutput \
418 (*(__xmlIndentTreeOutput()))
419 #else
420 XMLPUBVAR int xmlIndentTreeOutput;
421 #endif
422 XMLPUBFUN int XMLCALL xmlThrDefIndentTreeOutput(int v);
423
424 XMLPUBFUN const char * * XMLCALL __xmlTreeIndentString(void);
425 #ifdef LIBXML_THREAD_ENABLED
426 #define xmlTreeIndentString \
427 (*(__xmlTreeIndentString()))
428 #else
429 XMLPUBVAR const char * xmlTreeIndentString;
430 #endif
431 XMLPUBFUN const char * XMLCALL xmlThrDefTreeIndentString(const char * v);
432
433 XMLPUBFUN int * XMLCALL __xmlKeepBlanksDefaultValue(void);
434 #ifdef LIBXML_THREAD_ENABLED
435 #define xmlKeepBlanksDefaultValue \
436 (*(__xmlKeepBlanksDefaultValue()))
437 #else
438 XMLPUBVAR int xmlKeepBlanksDefaultValue;
439 #endif
440 XMLPUBFUN int XMLCALL xmlThrDefKeepBlanksDefaultValue(int v);
441
442 XMLPUBFUN int * XMLCALL __xmlLineNumbersDefaultValue(void);
443 #ifdef LIBXML_THREAD_ENABLED
444 #define xmlLineNumbersDefaultValue \
445 (*(__xmlLineNumbersDefaultValue()))
446 #else
447 XMLPUBVAR int xmlLineNumbersDefaultValue;
448 #endif
449 XMLPUBFUN int XMLCALL xmlThrDefLineNumbersDefaultValue(int v);
450
451 XMLPUBFUN int * XMLCALL __xmlLoadExtDtdDefaultValue(void);
452 #ifdef LIBXML_THREAD_ENABLED
453 #define xmlLoadExtDtdDefaultValue \
454 (*(__xmlLoadExtDtdDefaultValue()))
455 #else
456 XMLPUBVAR int xmlLoadExtDtdDefaultValue;
457 #endif
458 XMLPUBFUN int XMLCALL xmlThrDefLoadExtDtdDefaultValue(int v);
459
460 XMLPUBFUN int * XMLCALL __xmlParserDebugEntities(void);
461 #ifdef LIBXML_THREAD_ENABLED
462 #define xmlParserDebugEntities \
463 (*(__xmlParserDebugEntities()))
464 #else
465 XMLPUBVAR int xmlParserDebugEntities;
466 #endif
467 XMLPUBFUN int XMLCALL xmlThrDefParserDebugEntities(int v);
468
469 XMLPUBFUN const char * * XMLCALL __xmlParserVersion(void);
470 #ifdef LIBXML_THREAD_ENABLED
471 #define xmlParserVersion \
472 (*(__xmlParserVersion()))
473 #else
474 XMLPUBVAR const char * xmlParserVersion;
475 #endif
476
477 XMLPUBFUN int * XMLCALL __xmlPedanticParserDefaultValue(void);
478 #ifdef LIBXML_THREAD_ENABLED
479 #define xmlPedanticParserDefaultValue \
480 (*(__xmlPedanticParserDefaultValue()))
481 #else
482 XMLPUBVAR int xmlPedanticParserDefaultValue;
483 #endif
484 XMLPUBFUN int XMLCALL xmlThrDefPedanticParserDefaultValue(int v);
485
486 XMLPUBFUN int * XMLCALL __xmlSaveNoEmptyTags(void);
487 #ifdef LIBXML_THREAD_ENABLED
488 #define xmlSaveNoEmptyTags \
489 (*(__xmlSaveNoEmptyTags()))
490 #else
491 XMLPUBVAR int xmlSaveNoEmptyTags;
492 #endif
493 XMLPUBFUN int XMLCALL xmlThrDefSaveNoEmptyTags(int v);
494
495 XMLPUBFUN int * XMLCALL __xmlSubstituteEntitiesDefaultValue(void);
496 #ifdef LIBXML_THREAD_ENABLED
497 #define xmlSubstituteEntitiesDefaultValue \
498 (*(__xmlSubstituteEntitiesDefaultValue()))
499 #else
500 XMLPUBVAR int xmlSubstituteEntitiesDefaultValue;
501 #endif
502 XMLPUBFUN int XMLCALL xmlThrDefSubstituteEntitiesDefaultValue(int v);
503
504 XMLPUBFUN xmlRegisterNodeFunc * XMLCALL __xmlRegisterNodeDefaultValue(void);
505 #ifdef LIBXML_THREAD_ENABLED
506 #define xmlRegisterNodeDefaultValue \
507 (*(__xmlRegisterNodeDefaultValue()))
508 #else
509 XMLPUBVAR xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
510 #endif
511
512 XMLPUBFUN xmlDeregisterNodeFunc * XMLCALL __xmlDeregisterNodeDefaultValue(void);
513 #ifdef LIBXML_THREAD_ENABLED
514 #define xmlDeregisterNodeDefaultValue \
515 (*(__xmlDeregisterNodeDefaultValue()))
516 #else
517 XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
518 #endif
519
520 XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL \
521 __xmlParserInputBufferCreateFilenameValue(void);
522 #ifdef LIBXML_THREAD_ENABLED
523 #define xmlParserInputBufferCreateFilenameValue \
524 (*(__xmlParserInputBufferCreateFilenameValue()))
525 #else
526 XMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
527 #endif
528
529 XMLPUBFUN xmlOutputBufferCreateFilenameFunc * XMLCALL __xmlOutputBufferCreateFilenameValue(void);
530 #ifdef LIBXML_THREAD_ENABLED
531 #define xmlOutputBufferCreateFilenameValue \
532 (*(__xmlOutputBufferCreateFilenameValue()))
533 #else
534 XMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
535 #endif
536
537 #ifdef __cplusplus
538 }
539 #endif
540
541 #endif /* __XML_GLOBALS_H */