blob: 687201756600af028ec887338a53980980732ee5 [file] [log] [blame]
Daniel Veillardb8478642001-10-12 17:29:10 +00001/*
2 * globals.c: definition and handling of the set of global variables
3 * of the library
4 *
5 * The bottom of this file is automatically generated by build_glob.py
6 * based on the description file global.data
7 *
8 * See Copyright for the status of this software.
9 *
10 * Gary Pennington <Gary.Pennington@uk.sun.com>
11 * daniel@veillard.com
12 */
13
14#include "libxml.h"
15
Daniel Veillardd0463562001-10-13 09:15:48 +000016#include <libxml/xmlmemory.h>
Daniel Veillardb8478642001-10-12 17:29:10 +000017
18/*
19 * Helpful Macro
20 */
21#ifdef WITH_PTHREAD_H
22#if defined(SOLARIS)
23#define THR_MAIN(tid) (-1 == thr_main() || tid == thr_main())
24#else
25#define THR_MAIN(tid) (tid == 0 || tid == 1024)
26#endif
27
28#define IS_MAIN_THREAD (THR_MAIN(pthread_self()))
29#else
30#define IS_MAIN_THREAD 1
31#endif
32
33/************************************************************************
34 * *
35 * All the user accessible global variables of the library *
36 * *
37 ************************************************************************/
38
39const char *xmlParserVersion = LIBXML_VERSION_STRING;
Daniel Veillardd0463562001-10-13 09:15:48 +000040
Daniel Veillardb8478642001-10-12 17:29:10 +000041/*
42 * Memory allocation routines
43 */
44#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
Daniel Veillardd0463562001-10-13 09:15:48 +000045extern void xmlMemFree(void *ptr);
46extern void * xmlMemMalloc(size_t size);
47extern void * xmlMemRealloc(void *ptr,size_t size);
48extern char * xmlMemoryStrdup(const char *str);
49
Daniel Veillardb8478642001-10-12 17:29:10 +000050xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
51xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
52xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
53xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
54#else
55xmlFreeFunc xmlFree = (xmlFreeFunc) free;
56xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc;
57xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc;
58xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) strdup;
59#endif
60
Daniel Veillardd0463562001-10-13 09:15:48 +000061#include <libxml/threads.h>
62#include <libxml/globals.h>
63#include <libxml/SAX.h>
64
65#undef docbDefaultSAXHandler
66#undef htmlDefaultSAXHandler
67#undef oldXMLWDcompatibility
68#undef xmlBufferAllocScheme
69#undef xmlDefaultBufferSize
70#undef xmlDefaultSAXHandler
71#undef xmlDefaultSAXLocator
72#undef xmlDoValidityCheckingDefaultValue
73#undef xmlGenericError
74#undef xmlGenericErrorContext
75#undef xmlGetWarningsDefaultValue
76#undef xmlIndentTreeOutput
77#undef xmlKeepBlanksDefaultValue
78#undef xmlLineNumbersDefaultValue
79#undef xmlLoadExtDtdDefaultValue
80#undef xmlParserDebugEntities
81#undef xmlParserVersion
82#undef xmlPedanticParserDefaultValue
83#undef xmlSaveNoEmptyTags
84#undef xmlSubstituteEntitiesDefaultValue
85
86#undef xmlFree
87#undef xmlMalloc
88#undef xmlMemStrdup
89#undef xmlRealloc
90
Daniel Veillardb8478642001-10-12 17:29:10 +000091/*
92 * Buffers stuff
93 */
94xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
95int xmlDefaultBufferSize = BASE_BUFFER_SIZE;
96
97/*
98 * Parser defaults
99 */
Daniel Veillardd0463562001-10-13 09:15:48 +0000100
Daniel Veillardb8478642001-10-12 17:29:10 +0000101int oldXMLWDcompatibility = 0; /* DEPRECATED */
102int xmlParserDebugEntities = 0;
103int xmlDoValidityCheckingDefaultValue = 0;
104int xmlGetWarningsDefaultValue = 1;
105int xmlLoadExtDtdDefaultValue = 0;
106int xmlPedanticParserDefaultValue = 0;
107int xmlLineNumbersDefaultValue = 0;
108int xmlKeepBlanksDefaultValue = 1;
109int xmlSubstituteEntitiesDefaultValue = 0;
110
111/*
112 * Error handling
113 */
114
115/* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
116/* Must initialize xmlGenericError in xmlInitParser */
117xmlGenericErrorFunc xmlGenericError;
118void *xmlGenericErrorContext = NULL;
119
120/*
121 * output defaults
122 */
123int xmlIndentTreeOutput = 0;
124int xmlSaveNoEmptyTags = 0;
125
126/*
127 * Default handler for XML, builds the DOM tree
128 */
129xmlSAXHandler xmlDefaultSAXHandler = {
130 internalSubset,
131 isStandalone,
132 hasInternalSubset,
133 hasExternalSubset,
134 resolveEntity,
135 getEntity,
136 entityDecl,
137 notationDecl,
138 attributeDecl,
139 elementDecl,
140 unparsedEntityDecl,
141 setDocumentLocator,
142 startDocument,
143 endDocument,
144 startElement,
145 endElement,
146 reference,
147 characters,
148 characters,
149 processingInstruction,
150 comment,
151 xmlParserWarning,
152 xmlParserError,
153 xmlParserError,
154 getParameterEntity,
155 cdataBlock,
156 externalSubset,
157 0
158};
159
160/*
161 * The default SAX Locator.
162 */
163
164xmlSAXLocator xmlDefaultSAXLocator = {
165 getPublicId, getSystemId, getLineNumber, getColumnNumber
166};
167
168#ifdef LIBXML_HTML_ENABLED
169/*
170 * Default handler for HTML, builds the DOM tree
171 */
172xmlSAXHandler htmlDefaultSAXHandler = {
173 internalSubset,
174 NULL,
175 NULL,
176 NULL,
177 NULL,
178 getEntity,
179 NULL,
180 NULL,
181 NULL,
182 NULL,
183 NULL,
184 setDocumentLocator,
185 startDocument,
186 endDocument,
187 startElement,
188 endElement,
189 NULL,
190 characters,
191 ignorableWhitespace,
192 NULL,
193 comment,
194 xmlParserWarning,
195 xmlParserError,
196 xmlParserError,
197 getParameterEntity,
198 cdataBlock,
199 NULL,
200 0
201};
202#endif /* LIBXML_HTML_ENABLED */
203
204#ifdef LIBXML_DOCB_ENABLED
205/*
206 * Default handler for SGML DocBook, builds the DOM tree
207 */
208xmlSAXHandler docbDefaultSAXHandler = {
209 internalSubset,
210 isStandalone,
211 hasInternalSubset,
212 hasExternalSubset,
213 resolveEntity,
214 getEntity,
215 entityDecl,
216 NULL,
217 NULL,
218 NULL,
219 NULL,
220 setDocumentLocator,
221 startDocument,
222 endDocument,
223 startElement,
224 endElement,
225 reference,
226 characters,
227 ignorableWhitespace,
228 NULL,
229 comment,
230 xmlParserWarning,
231 xmlParserError,
232 xmlParserError,
233 getParameterEntity,
234 NULL,
235 NULL,
236 0
237};
238#endif /* LIBXML_DOCB_ENABLED */
239
240/**
241 * xmlInitializeGlobalState:
242 * @gs: a pointer to a newly allocated global state
243 *
244 * xmlInitializeGlobalState() initialize a global state with all the
245 * default values of the library.
246 */
247void
248xmlInitializeGlobalState(xmlGlobalStatePtr gs)
249{
250 /*
251 * Perform initialisation as required by libxml
252 */
253 initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
254 inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
255 gs->oldXMLWDcompatibility = 0;
256 gs->xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
257 gs->xmlDefaultBufferSize = BASE_BUFFER_SIZE;
258 initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
259 gs->xmlDefaultSAXLocator.getPublicId = getPublicId;
260 gs->xmlDefaultSAXLocator.getSystemId = getSystemId;
261 gs->xmlDefaultSAXLocator.getLineNumber = getLineNumber;
262 gs->xmlDefaultSAXLocator.getColumnNumber = getColumnNumber;
263 gs->xmlDoValidityCheckingDefaultValue = 0;
264#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
265 gs->xmlFree = (xmlFreeFunc) xmlMemFree;
266 gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
267 gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
268 gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
269#else
270 gs->xmlFree = (xmlFreeFunc) free;
271 gs->xmlMalloc = (xmlMallocFunc) malloc;
272 gs->xmlRealloc = (xmlReallocFunc) realloc;
273 gs->xmlMemStrdup = (xmlStrdupFunc) strdup;
274#endif
275 initGenericErrorDefaultFunc(&gs->xmlGenericError);
276 gs->xmlGenericErrorContext = NULL;
277 gs->xmlGetWarningsDefaultValue = 1;
278 gs->xmlIndentTreeOutput = 0;
279 gs->xmlKeepBlanksDefaultValue = 1;
280 gs->xmlLineNumbersDefaultValue = 0;
281 gs->xmlLoadExtDtdDefaultValue = 0;
282 gs->xmlParserDebugEntities = 0;
283 gs->xmlParserVersion = LIBXML_VERSION_STRING;
284 gs->xmlPedanticParserDefaultValue = 0;
285 gs->xmlSaveNoEmptyTags = 0;
286 gs->xmlSubstituteEntitiesDefaultValue = 0;
287}
288
289/*
290 * Everything starting from the line below is
291 * Automatically generated by build_glob.py.
292 * Do not modify the previous line.
293 */
294
295
296extern xmlSAXHandler docbDefaultSAXHandler;
297#undef docbDefaultSAXHandler
298xmlSAXHandler *
299__docbDefaultSAXHandler(void) {
300 if (IS_MAIN_THREAD)
301 return (&docbDefaultSAXHandler);
302 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000303 return (&xmlGetGlobalState()->docbDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000304}
305
306extern xmlSAXHandler htmlDefaultSAXHandler;
307#undef htmlDefaultSAXHandler
308xmlSAXHandler *
309__htmlDefaultSAXHandler(void) {
310 if (IS_MAIN_THREAD)
311 return (&htmlDefaultSAXHandler);
312 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000313 return (&xmlGetGlobalState()->htmlDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000314}
315
316extern int oldXMLWDcompatibility;
317#undef oldXMLWDcompatibility
318int *
319__oldXMLWDcompatibility(void) {
320 if (IS_MAIN_THREAD)
321 return (&oldXMLWDcompatibility);
322 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000323 return (&xmlGetGlobalState()->oldXMLWDcompatibility);
Daniel Veillardb8478642001-10-12 17:29:10 +0000324}
325
326extern xmlBufferAllocationScheme xmlBufferAllocScheme;
327#undef xmlBufferAllocScheme
328xmlBufferAllocationScheme *
329__xmlBufferAllocScheme(void) {
330 if (IS_MAIN_THREAD)
331 return (&xmlBufferAllocScheme);
332 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000333 return (&xmlGetGlobalState()->xmlBufferAllocScheme);
Daniel Veillardb8478642001-10-12 17:29:10 +0000334}
335
336extern int xmlDefaultBufferSize;
337#undef xmlDefaultBufferSize
338int *
339__xmlDefaultBufferSize(void) {
340 if (IS_MAIN_THREAD)
341 return (&xmlDefaultBufferSize);
342 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000343 return (&xmlGetGlobalState()->xmlDefaultBufferSize);
Daniel Veillardb8478642001-10-12 17:29:10 +0000344}
345
346extern xmlSAXHandler xmlDefaultSAXHandler;
347#undef xmlDefaultSAXHandler
348xmlSAXHandler *
349__xmlDefaultSAXHandler(void) {
350 if (IS_MAIN_THREAD)
351 return (&xmlDefaultSAXHandler);
352 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000353 return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
Daniel Veillardb8478642001-10-12 17:29:10 +0000354}
355
356extern xmlSAXLocator xmlDefaultSAXLocator;
357#undef xmlDefaultSAXLocator
358xmlSAXLocator *
359__xmlDefaultSAXLocator(void) {
360 if (IS_MAIN_THREAD)
361 return (&xmlDefaultSAXLocator);
362 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000363 return (&xmlGetGlobalState()->xmlDefaultSAXLocator);
Daniel Veillardb8478642001-10-12 17:29:10 +0000364}
365
366extern int xmlDoValidityCheckingDefaultValue;
367#undef xmlDoValidityCheckingDefaultValue
368int *
369__xmlDoValidityCheckingDefaultValue(void) {
370 if (IS_MAIN_THREAD)
371 return (&xmlDoValidityCheckingDefaultValue);
372 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000373 return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000374}
375
376extern xmlFreeFunc xmlFree;
377#undef xmlFree
378xmlFreeFunc *
379__xmlFree(void) {
380 if (IS_MAIN_THREAD)
381 return (&xmlFree);
382 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000383 return (&xmlGetGlobalState()->xmlFree);
Daniel Veillardb8478642001-10-12 17:29:10 +0000384}
385
386extern xmlGenericErrorFunc xmlGenericError;
387#undef xmlGenericError
388xmlGenericErrorFunc *
389__xmlGenericError(void) {
390 if (IS_MAIN_THREAD)
391 return (&xmlGenericError);
392 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000393 return (&xmlGetGlobalState()->xmlGenericError);
Daniel Veillardb8478642001-10-12 17:29:10 +0000394}
395
396extern void * xmlGenericErrorContext;
397#undef xmlGenericErrorContext
398void * *
399__xmlGenericErrorContext(void) {
400 if (IS_MAIN_THREAD)
401 return (&xmlGenericErrorContext);
402 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000403 return (&xmlGetGlobalState()->xmlGenericErrorContext);
Daniel Veillardb8478642001-10-12 17:29:10 +0000404}
405
406extern int xmlGetWarningsDefaultValue;
407#undef xmlGetWarningsDefaultValue
408int *
409__xmlGetWarningsDefaultValue(void) {
410 if (IS_MAIN_THREAD)
411 return (&xmlGetWarningsDefaultValue);
412 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000413 return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000414}
415
416extern int xmlIndentTreeOutput;
417#undef xmlIndentTreeOutput
418int *
419__xmlIndentTreeOutput(void) {
420 if (IS_MAIN_THREAD)
421 return (&xmlIndentTreeOutput);
422 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000423 return (&xmlGetGlobalState()->xmlIndentTreeOutput);
Daniel Veillardb8478642001-10-12 17:29:10 +0000424}
425
426extern int xmlKeepBlanksDefaultValue;
427#undef xmlKeepBlanksDefaultValue
428int *
429__xmlKeepBlanksDefaultValue(void) {
430 if (IS_MAIN_THREAD)
431 return (&xmlKeepBlanksDefaultValue);
432 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000433 return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000434}
435
436extern int xmlLineNumbersDefaultValue;
437#undef xmlLineNumbersDefaultValue
438int *
439__xmlLineNumbersDefaultValue(void) {
440 if (IS_MAIN_THREAD)
441 return (&xmlLineNumbersDefaultValue);
442 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000443 return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000444}
445
446extern int xmlLoadExtDtdDefaultValue;
447#undef xmlLoadExtDtdDefaultValue
448int *
449__xmlLoadExtDtdDefaultValue(void) {
450 if (IS_MAIN_THREAD)
451 return (&xmlLoadExtDtdDefaultValue);
452 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000453 return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000454}
455
456extern xmlMallocFunc xmlMalloc;
457#undef xmlMalloc
458xmlMallocFunc *
459__xmlMalloc(void) {
460 if (IS_MAIN_THREAD)
461 return (&xmlMalloc);
462 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000463 return (&xmlGetGlobalState()->xmlMalloc);
Daniel Veillardb8478642001-10-12 17:29:10 +0000464}
465
466extern xmlStrdupFunc xmlMemStrdup;
467#undef xmlMemStrdup
468xmlStrdupFunc *
469__xmlMemStrdup(void) {
470 if (IS_MAIN_THREAD)
471 return (&xmlMemStrdup);
472 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000473 return (&xmlGetGlobalState()->xmlMemStrdup);
Daniel Veillardb8478642001-10-12 17:29:10 +0000474}
475
476extern int xmlParserDebugEntities;
477#undef xmlParserDebugEntities
478int *
479__xmlParserDebugEntities(void) {
480 if (IS_MAIN_THREAD)
481 return (&xmlParserDebugEntities);
482 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000483 return (&xmlGetGlobalState()->xmlParserDebugEntities);
Daniel Veillardb8478642001-10-12 17:29:10 +0000484}
485
486extern const char * xmlParserVersion;
487#undef xmlParserVersion
488const char * *
489__xmlParserVersion(void) {
490 if (IS_MAIN_THREAD)
491 return (&xmlParserVersion);
492 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000493 return (&xmlGetGlobalState()->xmlParserVersion);
Daniel Veillardb8478642001-10-12 17:29:10 +0000494}
495
496extern int xmlPedanticParserDefaultValue;
497#undef xmlPedanticParserDefaultValue
498int *
499__xmlPedanticParserDefaultValue(void) {
500 if (IS_MAIN_THREAD)
501 return (&xmlPedanticParserDefaultValue);
502 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000503 return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000504}
505
506extern xmlReallocFunc xmlRealloc;
507#undef xmlRealloc
508xmlReallocFunc *
509__xmlRealloc(void) {
510 if (IS_MAIN_THREAD)
511 return (&xmlRealloc);
512 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000513 return (&xmlGetGlobalState()->xmlRealloc);
Daniel Veillardb8478642001-10-12 17:29:10 +0000514}
515
516extern int xmlSaveNoEmptyTags;
517#undef xmlSaveNoEmptyTags
518int *
519__xmlSaveNoEmptyTags(void) {
520 if (IS_MAIN_THREAD)
521 return (&xmlSaveNoEmptyTags);
522 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000523 return (&xmlGetGlobalState()->xmlSaveNoEmptyTags);
Daniel Veillardb8478642001-10-12 17:29:10 +0000524}
525
526extern int xmlSubstituteEntitiesDefaultValue;
527#undef xmlSubstituteEntitiesDefaultValue
528int *
529__xmlSubstituteEntitiesDefaultValue(void) {
530 if (IS_MAIN_THREAD)
531 return (&xmlSubstituteEntitiesDefaultValue);
532 else
Daniel Veillardd0463562001-10-13 09:15:48 +0000533 return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
Daniel Veillardb8478642001-10-12 17:29:10 +0000534}