blob: c509287b0a931e70a8533ae48bd450fdabe044c5 [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
16#include <libxml/threads.h>
17#include <libxml/globals.h>
18
19/*
20 * Helpful Macro
21 */
22#ifdef WITH_PTHREAD_H
23#if defined(SOLARIS)
24#define THR_MAIN(tid) (-1 == thr_main() || tid == thr_main())
25#else
26#define THR_MAIN(tid) (tid == 0 || tid == 1024)
27#endif
28
29#define IS_MAIN_THREAD (THR_MAIN(pthread_self()))
30#else
31#define IS_MAIN_THREAD 1
32#endif
33
34/************************************************************************
35 * *
36 * All the user accessible global variables of the library *
37 * *
38 ************************************************************************/
39
40const char *xmlParserVersion = LIBXML_VERSION_STRING;
41/*
42 * Memory allocation routines
43 */
44#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
45xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
46xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
47xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
48xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
49#else
50xmlFreeFunc xmlFree = (xmlFreeFunc) free;
51xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc;
52xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc;
53xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) strdup;
54#endif
55
56/*
57 * Buffers stuff
58 */
59xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
60int xmlDefaultBufferSize = BASE_BUFFER_SIZE;
61
62/*
63 * Parser defaults
64 */
65int oldXMLWDcompatibility = 0; /* DEPRECATED */
66int xmlParserDebugEntities = 0;
67int xmlDoValidityCheckingDefaultValue = 0;
68int xmlGetWarningsDefaultValue = 1;
69int xmlLoadExtDtdDefaultValue = 0;
70int xmlPedanticParserDefaultValue = 0;
71int xmlLineNumbersDefaultValue = 0;
72int xmlKeepBlanksDefaultValue = 1;
73int xmlSubstituteEntitiesDefaultValue = 0;
74
75/*
76 * Error handling
77 */
78
79/* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
80/* Must initialize xmlGenericError in xmlInitParser */
81xmlGenericErrorFunc xmlGenericError;
82void *xmlGenericErrorContext = NULL;
83
84/*
85 * output defaults
86 */
87int xmlIndentTreeOutput = 0;
88int xmlSaveNoEmptyTags = 0;
89
90/*
91 * Default handler for XML, builds the DOM tree
92 */
93xmlSAXHandler xmlDefaultSAXHandler = {
94 internalSubset,
95 isStandalone,
96 hasInternalSubset,
97 hasExternalSubset,
98 resolveEntity,
99 getEntity,
100 entityDecl,
101 notationDecl,
102 attributeDecl,
103 elementDecl,
104 unparsedEntityDecl,
105 setDocumentLocator,
106 startDocument,
107 endDocument,
108 startElement,
109 endElement,
110 reference,
111 characters,
112 characters,
113 processingInstruction,
114 comment,
115 xmlParserWarning,
116 xmlParserError,
117 xmlParserError,
118 getParameterEntity,
119 cdataBlock,
120 externalSubset,
121 0
122};
123
124/*
125 * The default SAX Locator.
126 */
127
128xmlSAXLocator xmlDefaultSAXLocator = {
129 getPublicId, getSystemId, getLineNumber, getColumnNumber
130};
131
132#ifdef LIBXML_HTML_ENABLED
133/*
134 * Default handler for HTML, builds the DOM tree
135 */
136xmlSAXHandler htmlDefaultSAXHandler = {
137 internalSubset,
138 NULL,
139 NULL,
140 NULL,
141 NULL,
142 getEntity,
143 NULL,
144 NULL,
145 NULL,
146 NULL,
147 NULL,
148 setDocumentLocator,
149 startDocument,
150 endDocument,
151 startElement,
152 endElement,
153 NULL,
154 characters,
155 ignorableWhitespace,
156 NULL,
157 comment,
158 xmlParserWarning,
159 xmlParserError,
160 xmlParserError,
161 getParameterEntity,
162 cdataBlock,
163 NULL,
164 0
165};
166#endif /* LIBXML_HTML_ENABLED */
167
168#ifdef LIBXML_DOCB_ENABLED
169/*
170 * Default handler for SGML DocBook, builds the DOM tree
171 */
172xmlSAXHandler docbDefaultSAXHandler = {
173 internalSubset,
174 isStandalone,
175 hasInternalSubset,
176 hasExternalSubset,
177 resolveEntity,
178 getEntity,
179 entityDecl,
180 NULL,
181 NULL,
182 NULL,
183 NULL,
184 setDocumentLocator,
185 startDocument,
186 endDocument,
187 startElement,
188 endElement,
189 reference,
190 characters,
191 ignorableWhitespace,
192 NULL,
193 comment,
194 xmlParserWarning,
195 xmlParserError,
196 xmlParserError,
197 getParameterEntity,
198 NULL,
199 NULL,
200 0
201};
202#endif /* LIBXML_DOCB_ENABLED */
203
204/**
205 * xmlInitializeGlobalState:
206 * @gs: a pointer to a newly allocated global state
207 *
208 * xmlInitializeGlobalState() initialize a global state with all the
209 * default values of the library.
210 */
211void
212xmlInitializeGlobalState(xmlGlobalStatePtr gs)
213{
214 /*
215 * Perform initialisation as required by libxml
216 */
217 initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
218 inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
219 gs->oldXMLWDcompatibility = 0;
220 gs->xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
221 gs->xmlDefaultBufferSize = BASE_BUFFER_SIZE;
222 initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
223 gs->xmlDefaultSAXLocator.getPublicId = getPublicId;
224 gs->xmlDefaultSAXLocator.getSystemId = getSystemId;
225 gs->xmlDefaultSAXLocator.getLineNumber = getLineNumber;
226 gs->xmlDefaultSAXLocator.getColumnNumber = getColumnNumber;
227 gs->xmlDoValidityCheckingDefaultValue = 0;
228#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
229 gs->xmlFree = (xmlFreeFunc) xmlMemFree;
230 gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
231 gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
232 gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
233#else
234 gs->xmlFree = (xmlFreeFunc) free;
235 gs->xmlMalloc = (xmlMallocFunc) malloc;
236 gs->xmlRealloc = (xmlReallocFunc) realloc;
237 gs->xmlMemStrdup = (xmlStrdupFunc) strdup;
238#endif
239 initGenericErrorDefaultFunc(&gs->xmlGenericError);
240 gs->xmlGenericErrorContext = NULL;
241 gs->xmlGetWarningsDefaultValue = 1;
242 gs->xmlIndentTreeOutput = 0;
243 gs->xmlKeepBlanksDefaultValue = 1;
244 gs->xmlLineNumbersDefaultValue = 0;
245 gs->xmlLoadExtDtdDefaultValue = 0;
246 gs->xmlParserDebugEntities = 0;
247 gs->xmlParserVersion = LIBXML_VERSION_STRING;
248 gs->xmlPedanticParserDefaultValue = 0;
249 gs->xmlSaveNoEmptyTags = 0;
250 gs->xmlSubstituteEntitiesDefaultValue = 0;
251}
252
253/*
254 * Everything starting from the line below is
255 * Automatically generated by build_glob.py.
256 * Do not modify the previous line.
257 */
258
259
260extern xmlSAXHandler docbDefaultSAXHandler;
261#undef docbDefaultSAXHandler
262xmlSAXHandler *
263__docbDefaultSAXHandler(void) {
264 if (IS_MAIN_THREAD)
265 return (&docbDefaultSAXHandler);
266 else
267 return (&get_glob_struct()->docbDefaultSAXHandler);
268}
269
270extern xmlSAXHandler htmlDefaultSAXHandler;
271#undef htmlDefaultSAXHandler
272xmlSAXHandler *
273__htmlDefaultSAXHandler(void) {
274 if (IS_MAIN_THREAD)
275 return (&htmlDefaultSAXHandler);
276 else
277 return (&get_glob_struct()->htmlDefaultSAXHandler);
278}
279
280extern int oldXMLWDcompatibility;
281#undef oldXMLWDcompatibility
282int *
283__oldXMLWDcompatibility(void) {
284 if (IS_MAIN_THREAD)
285 return (&oldXMLWDcompatibility);
286 else
287 return (&get_glob_struct()->oldXMLWDcompatibility);
288}
289
290extern xmlBufferAllocationScheme xmlBufferAllocScheme;
291#undef xmlBufferAllocScheme
292xmlBufferAllocationScheme *
293__xmlBufferAllocScheme(void) {
294 if (IS_MAIN_THREAD)
295 return (&xmlBufferAllocScheme);
296 else
297 return (&get_glob_struct()->xmlBufferAllocScheme);
298}
299
300extern int xmlDefaultBufferSize;
301#undef xmlDefaultBufferSize
302int *
303__xmlDefaultBufferSize(void) {
304 if (IS_MAIN_THREAD)
305 return (&xmlDefaultBufferSize);
306 else
307 return (&get_glob_struct()->xmlDefaultBufferSize);
308}
309
310extern xmlSAXHandler xmlDefaultSAXHandler;
311#undef xmlDefaultSAXHandler
312xmlSAXHandler *
313__xmlDefaultSAXHandler(void) {
314 if (IS_MAIN_THREAD)
315 return (&xmlDefaultSAXHandler);
316 else
317 return (&get_glob_struct()->xmlDefaultSAXHandler);
318}
319
320extern xmlSAXLocator xmlDefaultSAXLocator;
321#undef xmlDefaultSAXLocator
322xmlSAXLocator *
323__xmlDefaultSAXLocator(void) {
324 if (IS_MAIN_THREAD)
325 return (&xmlDefaultSAXLocator);
326 else
327 return (&get_glob_struct()->xmlDefaultSAXLocator);
328}
329
330extern int xmlDoValidityCheckingDefaultValue;
331#undef xmlDoValidityCheckingDefaultValue
332int *
333__xmlDoValidityCheckingDefaultValue(void) {
334 if (IS_MAIN_THREAD)
335 return (&xmlDoValidityCheckingDefaultValue);
336 else
337 return (&get_glob_struct()->xmlDoValidityCheckingDefaultValue);
338}
339
340extern xmlFreeFunc xmlFree;
341#undef xmlFree
342xmlFreeFunc *
343__xmlFree(void) {
344 if (IS_MAIN_THREAD)
345 return (&xmlFree);
346 else
347 return (&get_glob_struct()->xmlFree);
348}
349
350extern xmlGenericErrorFunc xmlGenericError;
351#undef xmlGenericError
352xmlGenericErrorFunc *
353__xmlGenericError(void) {
354 if (IS_MAIN_THREAD)
355 return (&xmlGenericError);
356 else
357 return (&get_glob_struct()->xmlGenericError);
358}
359
360extern void * xmlGenericErrorContext;
361#undef xmlGenericErrorContext
362void * *
363__xmlGenericErrorContext(void) {
364 if (IS_MAIN_THREAD)
365 return (&xmlGenericErrorContext);
366 else
367 return (&get_glob_struct()->xmlGenericErrorContext);
368}
369
370extern int xmlGetWarningsDefaultValue;
371#undef xmlGetWarningsDefaultValue
372int *
373__xmlGetWarningsDefaultValue(void) {
374 if (IS_MAIN_THREAD)
375 return (&xmlGetWarningsDefaultValue);
376 else
377 return (&get_glob_struct()->xmlGetWarningsDefaultValue);
378}
379
380extern int xmlIndentTreeOutput;
381#undef xmlIndentTreeOutput
382int *
383__xmlIndentTreeOutput(void) {
384 if (IS_MAIN_THREAD)
385 return (&xmlIndentTreeOutput);
386 else
387 return (&get_glob_struct()->xmlIndentTreeOutput);
388}
389
390extern int xmlKeepBlanksDefaultValue;
391#undef xmlKeepBlanksDefaultValue
392int *
393__xmlKeepBlanksDefaultValue(void) {
394 if (IS_MAIN_THREAD)
395 return (&xmlKeepBlanksDefaultValue);
396 else
397 return (&get_glob_struct()->xmlKeepBlanksDefaultValue);
398}
399
400extern int xmlLineNumbersDefaultValue;
401#undef xmlLineNumbersDefaultValue
402int *
403__xmlLineNumbersDefaultValue(void) {
404 if (IS_MAIN_THREAD)
405 return (&xmlLineNumbersDefaultValue);
406 else
407 return (&get_glob_struct()->xmlLineNumbersDefaultValue);
408}
409
410extern int xmlLoadExtDtdDefaultValue;
411#undef xmlLoadExtDtdDefaultValue
412int *
413__xmlLoadExtDtdDefaultValue(void) {
414 if (IS_MAIN_THREAD)
415 return (&xmlLoadExtDtdDefaultValue);
416 else
417 return (&get_glob_struct()->xmlLoadExtDtdDefaultValue);
418}
419
420extern xmlMallocFunc xmlMalloc;
421#undef xmlMalloc
422xmlMallocFunc *
423__xmlMalloc(void) {
424 if (IS_MAIN_THREAD)
425 return (&xmlMalloc);
426 else
427 return (&get_glob_struct()->xmlMalloc);
428}
429
430extern xmlStrdupFunc xmlMemStrdup;
431#undef xmlMemStrdup
432xmlStrdupFunc *
433__xmlMemStrdup(void) {
434 if (IS_MAIN_THREAD)
435 return (&xmlMemStrdup);
436 else
437 return (&get_glob_struct()->xmlMemStrdup);
438}
439
440extern int xmlParserDebugEntities;
441#undef xmlParserDebugEntities
442int *
443__xmlParserDebugEntities(void) {
444 if (IS_MAIN_THREAD)
445 return (&xmlParserDebugEntities);
446 else
447 return (&get_glob_struct()->xmlParserDebugEntities);
448}
449
450extern const char * xmlParserVersion;
451#undef xmlParserVersion
452const char * *
453__xmlParserVersion(void) {
454 if (IS_MAIN_THREAD)
455 return (&xmlParserVersion);
456 else
457 return (&get_glob_struct()->xmlParserVersion);
458}
459
460extern int xmlPedanticParserDefaultValue;
461#undef xmlPedanticParserDefaultValue
462int *
463__xmlPedanticParserDefaultValue(void) {
464 if (IS_MAIN_THREAD)
465 return (&xmlPedanticParserDefaultValue);
466 else
467 return (&get_glob_struct()->xmlPedanticParserDefaultValue);
468}
469
470extern xmlReallocFunc xmlRealloc;
471#undef xmlRealloc
472xmlReallocFunc *
473__xmlRealloc(void) {
474 if (IS_MAIN_THREAD)
475 return (&xmlRealloc);
476 else
477 return (&get_glob_struct()->xmlRealloc);
478}
479
480extern int xmlSaveNoEmptyTags;
481#undef xmlSaveNoEmptyTags
482int *
483__xmlSaveNoEmptyTags(void) {
484 if (IS_MAIN_THREAD)
485 return (&xmlSaveNoEmptyTags);
486 else
487 return (&get_glob_struct()->xmlSaveNoEmptyTags);
488}
489
490extern int xmlSubstituteEntitiesDefaultValue;
491#undef xmlSubstituteEntitiesDefaultValue
492int *
493__xmlSubstituteEntitiesDefaultValue(void) {
494 if (IS_MAIN_THREAD)
495 return (&xmlSubstituteEntitiesDefaultValue);
496 else
497 return (&get_glob_struct()->xmlSubstituteEntitiesDefaultValue);
498}