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