|
1 /* |
|
2 * libxml2_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 * Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
13 */ |
|
14 #define IN_LIBXML |
|
15 #define UNDEF_IMPORT_C_IN_DATA |
|
16 |
|
17 #include <assert.h> |
|
18 #include <errno.h> |
|
19 #include <stdlib.h> |
|
20 #include <string.h> |
|
21 |
|
22 #include "xmlenglibxml.h" |
|
23 |
|
24 #include <stdapis/libxml2/libxml2_globals.h> |
|
25 #include "libxml2_xmlschemastypes.h" |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 const xeGlobalConstData xeGlobalConsts = |
|
31 { |
|
32 LIBXML_VERSION_STRING // xmlParserVersion field |
|
33 }; |
|
34 |
|
35 const xeGlobalConstData* xeGetGlobalConsts() |
|
36 { |
|
37 return &xeGlobalConsts; |
|
38 } |
|
39 |
|
40 /** |
|
41 * xmlParserVersion: |
|
42 * |
|
43 * Constant string describing the internal version of the library |
|
44 */ |
|
45 XMLPUBFUNEXPORT const char* const xmlParserVersion = LIBXML_VERSION_STRING; |
|
46 |
|
47 |
|
48 /* |
|
49 This function creates and initializes new xmlGlobalState structure |
|
50 and stores pointer to it into Thread-Local Storage of this DLL. |
|
51 |
|
52 If TLS is not NULL, then nothing happens and pointer to existing global data is returned |
|
53 |
|
54 This function is used once prior any use of libxml2 code! |
|
55 It called from XmlEngine::XmlEngineAttachL() function |
|
56 and must be called by any other client of libxml2's API if XmlEngineAttachL() |
|
57 is not used. |
|
58 */ |
|
59 XMLPUBFUNEXPORT xmlGlobalStatePtr xmlCreateAndInitializeGlobalState() |
|
60 { |
|
61 xmlGlobalStatePtr gs = xeGetTLS(); |
|
62 if(gs) |
|
63 return gs; // already initialized; |
|
64 |
|
65 gs = (xmlGlobalStatePtr) malloc(sizeof(xmlGlobalState)); |
|
66 if(gs) |
|
67 { |
|
68 memset(gs, 0, sizeof(xmlGlobalState)); |
|
69 xeSetTLS(gs); |
|
70 xmlInitializeGlobalState(gs); |
|
71 } |
|
72 return gs; |
|
73 } |
|
74 |
|
75 /* |
|
76 Performs complete cleanup of the resource allocated for Libxml2. |
|
77 Global state data is destroyed. |
|
78 |
|
79 On Symbian: |
|
80 Thread-Local Storage is set to NULL after the cleanup finished. |
|
81 |
|
82 @note XmlEngine::XmlEngineCleanup(TAny*) calls this function |
|
83 as part of XML Engine shutdown sequence; but it also adds |
|
84 counter for multi-user (within one thread) processing support. |
|
85 |
|
86 @note This function should not be directly used by Symbian applications; |
|
87 the only exception for this rule is usage of libxml2 by other |
|
88 open-source libraries [XmlEngine::XmlEngineCleanup(TAny*) is preferred] |
|
89 */ |
|
90 XMLPUBFUNEXPORT void xmlCleanupGlobalData() |
|
91 { |
|
92 DEFINE_GS_PROXY /* NOTE: Initialize GS proxy initialize before using any GS member */ |
|
93 xmlGlobalStatePtr gs = xeGetTLS(); |
|
94 |
|
95 if(!gs) |
|
96 return; |
|
97 SET_GS_PROXY(gs); |
|
98 |
|
99 xmlSchemaCleanupTypes(); |
|
100 xmlResetLastError(); |
|
101 xmlCleanupCharEncodingHandlers(); |
|
102 xmlCleanupParser(); |
|
103 xeXPathCleanup(); |
|
104 xeCleanupDOMStringConverter(); |
|
105 #ifdef XMLENGINE_XSLT |
|
106 if(xsltGlobalsCleanupFunc) |
|
107 ((void(*)())xsltGlobalsCleanupFunc)(); |
|
108 #endif |
|
109 free(gs); //using xmlFree(gs) is not right: GS was not initialized with xmlMalloc() ! |
|
110 xeSetTLS(NULL); |
|
111 } |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 XMLPUBFUNEXPORT int xmlOOMFlag() |
|
118 { |
|
119 LOAD_GS_DIRECT |
|
120 #ifdef _DEBUG |
|
121 int f = OOM_FLAG; |
|
122 if(f) |
|
123 { |
|
124 f |= 0; // SET BREAKPOINT HERE |
|
125 } |
|
126 return f; |
|
127 #else |
|
128 return OOM_FLAG; |
|
129 #endif |
|
130 } |
|
131 |
|
132 void XMLCALL xeCheckErrno() |
|
133 { |
|
134 int err = errno; |
|
135 if (err == ENOMEM) |
|
136 { |
|
137 SET_OOM_FLAG; |
|
138 } |
|
139 #ifdef _DEBUG |
|
140 else if (err) |
|
141 { |
|
142 // some other error!!! |
|
143 err ^=err; |
|
144 } |
|
145 #endif |
|
146 } |
|
147 |
|
148 XMLPUBFUNEXPORT void xmlSetOOM() |
|
149 { |
|
150 DEFINE_GS_PROXY //note: ensure GS proxy initialize before any GS member access |
|
151 xmlGlobalStatePtr gs = xeGetTLS(); |
|
152 SET_GS_PROXY(gs) |
|
153 // Should be sure that globals state (contains the OOM flag) is initialized |
|
154 if(gs) |
|
155 { |
|
156 OOM_FLAG = 1; |
|
157 } |
|
158 } |
|
159 |
|
160 XMLPUBFUNEXPORT void xmlResetOOM() |
|
161 { |
|
162 DEFINE_GS_PROXY //note: ensure GS proxy initialize before any GS member access |
|
163 xmlGlobalStatePtr gs = xeGetTLS(); |
|
164 SET_GS_PROXY(gs) |
|
165 // We need this in case OOM happened during initialization of the 'global state' |
|
166 if (!gs) |
|
167 return; |
|
168 OOM_FLAG = 0; |
|
169 } |
|
170 |
|
171 |
|
172 #define __lookup_ALLOC_ADDRES_ 0 |
|
173 |
|
174 #ifdef XMLENGINE_MEM_DEBUG |
|
175 void __catchAllocatedAddress() |
|
176 { |
|
177 // Set breakpoint here |
|
178 } |
|
179 void __catchFreedAddress() |
|
180 { |
|
181 // Set breakpoint here |
|
182 } |
|
183 #endif |
|
184 |
|
185 #ifdef XMLENGINE_MEM_DEBUG |
|
186 //#define XMLENGINE_MEM_DEBUG_SIZE |
|
187 #endif |
|
188 |
|
189 /* |
|
190 NOTE: XMLENGINE_MEM_DEBUG option is defined only in debug builds |
|
191 */ |
|
192 XMLPUBFUNEXPORT void* XMLCALL malloc_impl(size_t size) |
|
193 { |
|
194 #ifdef XMLENGINE_MEM_DEBUG |
|
195 LOAD_GS_DIRECT |
|
196 #endif |
|
197 #ifndef XMLENGINE_MEM_DEBUG_SIZE |
|
198 void* mem = malloc(size); |
|
199 |
|
200 #ifdef XMLENGINE_MEM_DEBUG |
|
201 if((int)mem == __lookup_ALLOC_ADDRES_) { |
|
202 __catchAllocatedAddress(); |
|
203 } |
|
204 #endif |
|
205 #else |
|
206 // when defined XMLENGINE_MEM_DEBUG_SIZE |
|
207 // |
|
208 // the previous 4 bytes before returned pointer is the size of a block |
|
209 void *hdr; |
|
210 void *mem; |
|
211 |
|
212 hdr = malloc(size + sizeof(size_t)); |
|
213 if(hdr) |
|
214 { |
|
215 mem = ((char*)hdr) + sizeof(size_t); |
|
216 *((size_t*)hdr) = size; |
|
217 } |
|
218 else |
|
219 mem = NULL; |
|
220 |
|
221 if((int)hdr == __lookup_ALLOC_ADDRES_) { |
|
222 __catchAllocatedAddress(); |
|
223 } |
|
224 #endif |
|
225 |
|
226 if(mem) |
|
227 { |
|
228 #ifdef XMLENGINE_MEM_DEBUG |
|
229 xmlGlobalStatePtr gs = xeGetTLS(); |
|
230 if(gs && !xmlOOM) // do not count "after allocations" during error-handling |
|
231 { |
|
232 gs->allocCount++; |
|
233 gs->allocTotal += size; |
|
234 #ifdef XMLENGINE_MEM_DEBUG_SIZE |
|
235 gs->allocMemSize += size; |
|
236 if(gs->allocMemSize > gs->allocMemSizeMax) |
|
237 gs->allocMemSizeMax = gs->allocMemSize; |
|
238 #endif |
|
239 } |
|
240 #endif |
|
241 return mem; |
|
242 } |
|
243 else |
|
244 { |
|
245 SET_OOM_FLAG; |
|
246 return NULL; // NULL |
|
247 } |
|
248 } |
|
249 |
|
250 XMLPUBFUNEXPORT void* XMLCALL realloc_impl(void *ptr, size_t size) |
|
251 { |
|
252 #ifdef XMLENGINE_MEM_DEBUG |
|
253 LOAD_GS_DIRECT |
|
254 #endif |
|
255 #ifndef XMLENGINE_MEM_DEBUG_SIZE |
|
256 void* mem = realloc(ptr, size); |
|
257 |
|
258 # ifdef XMLENGINE_MEM_DEBUG |
|
259 if((int)mem == __lookup_ALLOC_ADDRES_) { |
|
260 __catchAllocatedAddress(); |
|
261 } |
|
262 # endif |
|
263 #else |
|
264 // XMLENGINE_MEM_DEBUG_SIZE is defined |
|
265 void* hdr; |
|
266 void* mem; |
|
267 size_t prevSize; |
|
268 |
|
269 hdr = (((size_t*)ptr) - 1); |
|
270 prevSize = *((size_t*)hdr); |
|
271 |
|
272 hdr = realloc(hdr, size + sizeof(size_t)); |
|
273 if(hdr) |
|
274 { |
|
275 mem = ((size_t*)hdr) + 1; |
|
276 *((size_t*)hdr) = size; |
|
277 } |
|
278 else |
|
279 mem = NULL; |
|
280 |
|
281 if((int)hdr == __lookup_ALLOC_ADDRES_) { |
|
282 __catchAllocatedAddress(); |
|
283 } |
|
284 #endif /* XMLENGINE_MEM_DEBUG_SIZE */ |
|
285 |
|
286 if(mem) |
|
287 { |
|
288 #ifdef XMLENGINE_MEM_DEBUG |
|
289 xmlGlobalStatePtr gs = xeGetTLS(); |
|
290 if(gs && !xmlOOM) // do not count "after allocations" during error-handling |
|
291 { |
|
292 gs->reallocCount++; |
|
293 #ifdef XMLENGINE_MEM_DEBUG_SIZE |
|
294 gs->allocMemSize += size - prevSize; |
|
295 if(gs->allocMemSize > gs->allocMemSizeMax) |
|
296 gs->allocMemSizeMax = gs->allocMemSize; |
|
297 #endif |
|
298 } |
|
299 #endif |
|
300 return mem; |
|
301 } |
|
302 else |
|
303 { |
|
304 SET_OOM_FLAG; |
|
305 return NULL; |
|
306 } |
|
307 } |
|
308 |
|
309 // |
|
310 // NOTE: in release builds free() is used directly |
|
311 void free_debug(void* mem) |
|
312 { |
|
313 #ifdef XMLENGINE_MEM_DEBUG |
|
314 xmlGlobalStatePtr gs; |
|
315 |
|
316 #ifndef XMLENGINE_MEM_DEBUG_SIZE |
|
317 if((int)mem == __lookup_ALLOC_ADDRES_) { |
|
318 __catchFreedAddress(); |
|
319 } |
|
320 |
|
321 free(mem); |
|
322 #else |
|
323 void* hdr; |
|
324 size_t size; |
|
325 |
|
326 hdr = (((size_t*)mem) - 1); |
|
327 |
|
328 if((int)hdr == __lookup_ALLOC_ADDRES_) { |
|
329 __catchFreedAddress(); |
|
330 } |
|
331 size = *((size_t*)hdr); |
|
332 free(hdr); |
|
333 #endif /* XMLENGINE_MEM_DEBUG_SIZE */ |
|
334 |
|
335 gs = xeGetTLS(); |
|
336 if(gs) |
|
337 { |
|
338 gs->deallocCount++; |
|
339 #ifdef XMLENGINE_MEM_DEBUG_SIZE |
|
340 gs->allocMemSize -=size; |
|
341 #endif |
|
342 } |
|
343 #endif /* XMLENGINE_MEM_DEBUG */ |
|
344 } |
|
345 // |
|
346 |
|
347 #ifdef XMLENGINE_EXCLUDE_EMBED_MSG |
|
348 const char* const __embedded_errtxt_replacement = "DISABLED ERROR STRING\n"; |
|
349 #endif |
|
350 |
|
351 void xeCleanupDOMStringConverter() |
|
352 { |
|
353 DOMStringConverterData* data = &xmlGetGlobalState()->xeStringArgs; |
|
354 char** buf; |
|
355 int i; |
|
356 for(i=0; i<4; i++){ |
|
357 buf = &data->cleanupItem[i]; |
|
358 if(*buf){ |
|
359 xmlFree(*buf); |
|
360 *buf = 0; |
|
361 } |
|
362 } |
|
363 } |
|
364 |
|
365 int symbian_vsnprintf(char *str, size_t size, const char *format, va_list ap) |
|
366 { |
|
367 int ret = 0; |
|
368 |
|
369 ret = vsprintf(str, format, ap); |
|
370 |
|
371 assert((size_t)ret < size); |
|
372 return ret; |
|
373 } |
|
374 |
|
375 int symbian_snprintf(char *str, size_t size, const char *format, ...) |
|
376 { |
|
377 int ret = 0; |
|
378 va_list args; |
|
379 va_start(args, format); |
|
380 symbian_vsnprintf(str, size, format, args); |
|
381 va_end(args); |
|
382 |
|
383 assert((size_t)ret < size); |
|
384 |
|
385 return ret; |
|
386 } |
|
387 |
|
388 #include <stdapis/libxml2/libxml2_sax.h> |
|
389 |
|
390 /** |
|
391 * xmlTreeIndentString: |
|
392 * |
|
393 * The string used to do one-level indent. By default is equal to " " (two spaces) |
|
394 */ |
|
395 XMLPUBFUNEXPORT const char* const xmlTreeIndentString = " "; |
|
396 const char* const xmlTreeIndentStringThrDef = " "; |
|
397 |
|
398 |
|
399 XMLPUBFUNEXPORT xmlRegisterNodeFunc |
|
400 xmlRegisterNodeDefault(xmlRegisterNodeFunc func) |
|
401 { |
|
402 LOAD_GS_DIRECT |
|
403 xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue; |
|
404 |
|
405 __xmlRegisterCallbacks = 1; |
|
406 xmlRegisterNodeDefaultValue = func; |
|
407 return(old); |
|
408 } |
|
409 |
|
410 XMLPUBFUNEXPORT xmlDeregisterNodeFunc |
|
411 xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func) |
|
412 { |
|
413 LOAD_GS_DIRECT |
|
414 xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue; |
|
415 |
|
416 __xmlRegisterCallbacks = 1; |
|
417 xmlDeregisterNodeDefaultValue = func; |
|
418 return(old); |
|
419 } |
|
420 |
|
421 |
|
422 #define xmlBufferAllocSchemeThrDef XML_BUFFER_ALLOC_EXACT |
|
423 #define xmlDefaultBufferSizeThrDef BASE_BUFFER_SIZE |
|
424 #define xmlParserDebugEntitiesThrDef 0 |
|
425 #define xmlDoValidityCheckingDefaultValueThrDef 0 |
|
426 #define xmlGetWarningsDefaultValueThrDef 1 |
|
427 #define xmlLoadExtDtdDefaultValueThrDef 0 |
|
428 #define xmlPedanticParserDefaultValueThrDef 0 |
|
429 #define xmlLineNumbersDefaultValueThrDef 0 |
|
430 #define xmlKeepBlanksDefaultValueThrDef 1 |
|
431 #define xmlSubstituteEntitiesDefaultValueThrDef 0 |
|
432 #define xmlRegisterNodeDefaultValueThrDef NULL |
|
433 #define xmlDeregisterNodeDefaultValueThrDef NULL |
|
434 |
|
435 void xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED, const char *msg, ...); |
|
436 |
|
437 #define xmlGenericErrorThrDef xmlGenericErrorDefaultFunc |
|
438 #define xmlStructuredErrorThrDef NULL |
|
439 #define xmlGenericErrorContextThrDef NULL |
|
440 #define xmlIndentTreeOutputThrDef 1 |
|
441 #define xmlTreeIndentStringThrDef " " |
|
442 #define xmlSaveNoEmptyTagsThrDef 0 |
|
443 |
|
444 #undef docbDefaultSAXHandler |
|
445 #undef htmlDefaultSAXHandler |
|
446 #undef xmlBufferAllocScheme |
|
447 #undef xmlDefaultBufferSize |
|
448 #undef xmlDefaultSAXHandler |
|
449 #undef xmlDefaultSAXLocator |
|
450 #undef xmlDoValidityCheckingDefaultValue |
|
451 #undef xmlGenericError |
|
452 #undef xmlStructuredError |
|
453 #undef xmlGenericErrorContext |
|
454 #undef xmlGetWarningsDefaultValue |
|
455 #undef xmlIndentTreeOutput |
|
456 //#undef xmlTreeIndentString |
|
457 #undef xmlKeepBlanksDefaultValue |
|
458 #undef xmlLineNumbersDefaultValue |
|
459 #undef xmlLoadExtDtdDefaultValue |
|
460 #undef xmlParserDebugEntities |
|
461 #undef xmlPedanticParserDefaultValue |
|
462 #undef xmlSaveNoEmptyTags |
|
463 #undef xmlSubstituteEntitiesDefaultValue |
|
464 #undef xmlRegisterNodeDefaultValue |
|
465 #undef xmlDeregisterNodeDefaultValue |
|
466 #undef xmlLastError |
|
467 |
|
468 #undef xmlFree |
|
469 #undef xmlMalloc |
|
470 #undef xmlMallocAtomic |
|
471 #undef xmlMemStrdup |
|
472 #undef xmlRealloc |
|
473 |
|
474 /* html */ |
|
475 #undef htmlStartCloseIndex |
|
476 #undef htmlStartCloseIndexinitialized |
|
477 |
|
478 /* tree */ |
|
479 #undef __xmlRegisterCallbacks |
|
480 #undef xmlCompressMode |
|
481 #undef xmlCheckDTD |
|
482 |
|
483 /* xmlmemory */ |
|
484 #undef xmlMemInitialized |
|
485 #undef debugMemSize |
|
486 #undef debugMaxMemSize |
|
487 #undef xmlMemMutex |
|
488 #undef g_block |
|
489 #undef xmlMemStopAtBlock |
|
490 #undef xmlMemTraceBlockAt |
|
491 |
|
492 /* catalog */ |
|
493 #undef xmlDebugCatalogs |
|
494 #undef xmlCatalogDefaultAllow |
|
495 #undef xmlCatalogDefaultPrefer |
|
496 #undef xmlCatalogXMLFiles |
|
497 #undef xmlDefaultCatalog |
|
498 #undef xmlCatalogMutex |
|
499 #undef xmlCatalogInitialized |
|
500 |
|
501 #undef xmlInputCallbackTable |
|
502 #undef xmlInputCallbackNr |
|
503 #undef xmlInputCallbackInitialized |
|
504 #undef xmlOutputCallbackTable |
|
505 #undef xmlOutputCallbackNr |
|
506 #undef xmlOutputCallbackInitialized |
|
507 #undef xmlCurrentExternalEntityLoader |
|
508 |
|
509 #undef xmlSAX2DefaultVersionValue |
|
510 |
|
511 #undef xmlParserMaxDepth |
|
512 #undef xmlW3CPIs |
|
513 #undef xmlParserInitialized |
|
514 #undef xeStackLimit |
|
515 // Now these are global constants |
|
516 //#undef xmlEntityLt |
|
517 //#undef xmlEntityGt |
|
518 //#undef xmlEntityAmp |
|
519 //#undef xmlEntityQuot |
|
520 //#undef xmlEntityApos |
|
521 |
|
522 #undef xmlUTF16LEHandler |
|
523 #undef xmlUTF16BEHandler |
|
524 #undef xmlCharEncodingAliases |
|
525 #undef xmlCharEncodingAliasesNb |
|
526 #undef xmlCharEncodingAliasesMax |
|
527 #undef xmlLittleEndian |
|
528 #undef handlers |
|
529 #undef nbCharEncodingHandler |
|
530 #undef xmlDefaultCharEncodingHandler |
|
531 |
|
532 #undef xmlXPathNAN |
|
533 #undef xmlXPathPINF |
|
534 #undef xmlXPathNINF |
|
535 #undef xmlXPathNZERO |
|
536 #undef xmlXPathInitialized |
|
537 |
|
538 #ifndef LIBXML_THREAD_ENABLED |
|
539 # undef xmlXPathDisableOptimizer |
|
540 #endif |
|
541 |
|
542 #undef xmlXPathDefineExtensionFunctionsGlobally |
|
543 #undef xmlXPathDefaultFunctionsHash |
|
544 #undef xmlXPathIntermediaryExtensionFunctionsHash |
|
545 |
|
546 #undef xlinkDefaultHandler |
|
547 #undef xlinkDefaultDetect |
|
548 |
|
549 #undef had_info |
|
550 #undef xmlInputStreamId |
|
551 |
|
552 #undef xeUserCount |
|
553 |
|
554 /* XMLENGINE_XSLT */ |
|
555 #undef g_calibration |
|
556 //#undef default_token |
|
557 #undef xsltExtensionsHash |
|
558 #undef xsltFunctionsHash |
|
559 #undef xsltElementsHash |
|
560 #undef xsltGlobalsCleanupFunc |
|
561 #undef xsltTopLevelsHash |
|
562 #undef xsltDebuggerCurrentCallbacks |
|
563 |
|
564 #ifdef LIBXML_SAX1_ENABLED |
|
565 /** |
|
566 * xmlDefaultSAXHandler: |
|
567 * |
|
568 * Default SAX version1 handler for XML, builds the DOM tree |
|
569 */ |
|
570 const xmlSAXHandlerV1 xmlDefaultSAXHandler = { |
|
571 xmlSAX2InternalSubset, |
|
572 xmlSAX2IsStandalone, |
|
573 xmlSAX2HasInternalSubset, |
|
574 xmlSAX2HasExternalSubset, |
|
575 xmlSAX2ResolveEntity, |
|
576 xmlSAX2GetEntity, |
|
577 xmlSAX2EntityDecl, |
|
578 xmlSAX2NotationDecl, |
|
579 xmlSAX2AttributeDecl, |
|
580 xmlSAX2ElementDecl, |
|
581 xmlSAX2UnparsedEntityDecl, |
|
582 xmlSAX2SetDocumentLocator, |
|
583 xmlSAX2StartDocument, |
|
584 xmlSAX2EndDocument, |
|
585 xmlSAX2StartElement, |
|
586 xmlSAX2EndElement, |
|
587 xmlSAX2Reference, |
|
588 xmlSAX2Characters, |
|
589 xmlSAX2Characters, |
|
590 xmlSAX2ProcessingInstruction, |
|
591 xmlSAX2Comment, |
|
592 xmlParserWarning, |
|
593 xmlParserError, |
|
594 xmlParserError, |
|
595 xmlSAX2GetParameterEntity, |
|
596 xmlSAX2CDataBlock, |
|
597 xmlSAX2ExternalSubset, |
|
598 0, |
|
599 }; |
|
600 #endif /* LIBXML_SAX1_ENABLED */ |
|
601 |
|
602 /** |
|
603 * xmlDefaultSAXLocator: |
|
604 * |
|
605 * The default SAX Locator |
|
606 * { getPublicId, getSystemId, getLineNumber, getColumnNumber} |
|
607 */ |
|
608 const xmlSAXLocator xmlDefaultSAXLocator = { |
|
609 xmlSAX2GetPublicId, |
|
610 xmlSAX2GetSystemId, |
|
611 xmlSAX2GetLineNumber, |
|
612 xmlSAX2GetColumnNumber |
|
613 }; |
|
614 |
|
615 #ifdef LIBXML_HTML_ENABLED |
|
616 /** |
|
617 * htmlDefaultSAXHandler: |
|
618 * |
|
619 * Default old SAX v1 handler for HTML, builds the DOM tree |
|
620 */ |
|
621 const xmlSAXHandlerV1 htmlDefaultSAXHandler = { |
|
622 xmlSAX2InternalSubset, |
|
623 NULL, |
|
624 NULL, |
|
625 NULL, |
|
626 NULL, |
|
627 xmlSAX2GetEntity, |
|
628 NULL, |
|
629 NULL, |
|
630 NULL, |
|
631 NULL, |
|
632 NULL, |
|
633 xmlSAX2SetDocumentLocator, |
|
634 xmlSAX2StartDocument, |
|
635 xmlSAX2EndDocument, |
|
636 xmlSAX2StartElement, |
|
637 xmlSAX2EndElement, |
|
638 NULL, |
|
639 xmlSAX2Characters, |
|
640 xmlSAX2IgnorableWhitespace, |
|
641 NULL, |
|
642 xmlSAX2Comment, |
|
643 xmlParserWarning, |
|
644 xmlParserError, |
|
645 xmlParserError, |
|
646 xmlSAX2GetParameterEntity, |
|
647 xmlSAX2CDataBlock, |
|
648 NULL, |
|
649 0, |
|
650 }; |
|
651 #endif /* LIBXML_HTML_ENABLED */ |
|
652 |
|
653 #ifdef LIBXML_DOCB_ENABLED |
|
654 /** |
|
655 * docbDefaultSAXHandler: |
|
656 * |
|
657 * Default old SAX v1 handler for SGML DocBook, builds the DOM tree |
|
658 */ |
|
659 const xmlSAXHandlerV1 docbDefaultSAXHandler = { |
|
660 xmlSAX2InternalSubset, |
|
661 xmlSAX2IsStandalone, |
|
662 xmlSAX2HasInternalSubset, |
|
663 xmlSAX2HasExternalSubset, |
|
664 xmlSAX2ResolveEntity, |
|
665 xmlSAX2GetEntity, |
|
666 xmlSAX2EntityDecl, |
|
667 NULL, |
|
668 NULL, |
|
669 NULL, |
|
670 NULL, |
|
671 xmlSAX2SetDocumentLocator, |
|
672 xmlSAX2StartDocument, |
|
673 xmlSAX2EndDocument, |
|
674 xmlSAX2StartElement, |
|
675 xmlSAX2EndElement, |
|
676 xmlSAX2Reference, |
|
677 xmlSAX2Characters, |
|
678 xmlSAX2IgnorableWhitespace, |
|
679 NULL, |
|
680 xmlSAX2Comment, |
|
681 xmlParserWarning, |
|
682 xmlParserError, |
|
683 xmlParserError, |
|
684 xmlSAX2GetParameterEntity, |
|
685 NULL, |
|
686 NULL, |
|
687 0, |
|
688 }; |
|
689 #endif /* LIBXML_DOCB_ENABLED */ |
|
690 |
|
691 |
|
692 |
|
693 /** |
|
694 * xmlInitializeGlobalState: |
|
695 * @param gs a pointer to a newly allocated global state |
|
696 * |
|
697 * xmlInitializeGlobalState() initialize a global state with all the |
|
698 * default values of the library. |
|
699 */ |
|
700 XMLPUBFUNEXPORT void |
|
701 xmlInitializeGlobalState(xmlGlobalStatePtr gs) |
|
702 { |
|
703 |
|
704 #ifdef DEBUG_GLOBALS |
|
705 fprintf(stderr, "Initializing globals at %lu for thread %d\n", |
|
706 (unsigned long) gs, xmlGetThreadId()); |
|
707 #endif |
|
708 |
|
709 /* |
|
710 * Perform initialization as required by libxml |
|
711 */ |
|
712 if (xmlThrDefMutex == NULL) |
|
713 xmlInitGlobals(); |
|
714 |
|
715 xmlMutexLock(xmlThrDefMutex); |
|
716 |
|
717 #ifdef LIBXML_DOCB_ENABLED |
|
718 xmlSAX2InitDocbDefaultSAXHandler(&gs->docbDefaultSAXHandler); |
|
719 #endif |
|
720 #ifdef LIBXML_HTML_ENABLED |
|
721 |
|
722 //xmlSAX2InitHtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler); |
|
723 #endif |
|
724 // merge: agathe: I had removed this code for libxslt... |
|
725 //#ifdef LIBXML_DOCB_ENABLED |
|
726 // initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler); |
|
727 //#endif |
|
728 |
|
729 //#ifdef LIBXML_HTML_ENABLED |
|
730 //inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler); |
|
731 //#endif |
|
732 |
|
733 gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef; |
|
734 gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef; |
|
735 #ifdef LIBXML_SAX1_ENABLED |
|
736 initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1); |
|
737 #endif /* LIBXML_SAX1_ENABLED */ |
|
738 gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId; |
|
739 gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId; |
|
740 gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber; |
|
741 gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber; |
|
742 gs->xmlDoValidityCheckingDefaultValue = xmlDoValidityCheckingDefaultValueThrDef; |
|
743 |
|
744 gs->xeStackLimit = xeStackLimitAddress(); |
|
745 |
|
746 gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef; |
|
747 gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef; |
|
748 |
|
749 gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef; |
|
750 #ifdef LIBXML_ENABLE_NODE_LINEINFO |
|
751 gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef; |
|
752 #endif |
|
753 gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef; |
|
754 gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef; |
|
755 gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef; |
|
756 gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef; |
|
757 gs->xmlSubstituteEntitiesDefaultValue = xmlSubstituteEntitiesDefaultValueThrDef; |
|
758 |
|
759 gs->xmlGenericError = xmlGenericErrorThrDef; |
|
760 gs->xmlStructuredError = xmlStructuredErrorThrDef; |
|
761 gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef; |
|
762 gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef; |
|
763 gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef; |
|
764 memset(&gs->xmlLastError, 0, sizeof(xmlError)); |
|
765 |
|
766 // ================================================== |
|
767 // XMLENEGINE: NOTE: All zero values are commented, |
|
768 // since the whole structure is set to zeros prior |
|
769 // initialization |
|
770 // ================================================== |
|
771 |
|
772 // gs->had_info = 0; |
|
773 |
|
774 // gs->xmlInputStreamId = 0; |
|
775 |
|
776 // gs->xmlUTF16LEHandler = NULL; |
|
777 // gs->xmlUTF16BEHandler = NULL; |
|
778 // gs->xmlCharEncodingAliases = NULL; |
|
779 // gs->xmlCharEncodingAliasesNb = 0; |
|
780 // gs->xmlCharEncodingAliasesMax = 0; |
|
781 gs->xmlLittleEndian = 1; |
|
782 // gs->handlers = NULL; |
|
783 // gs->nbCharEncodingHandler = 0; |
|
784 // gs->xmlDefaultCharEncodingHandler = NULL; |
|
785 |
|
786 gs->xmlParserMaxDepth = 1024; |
|
787 gs->xmlW3CPIs[0] = "xml-stylesheet"; |
|
788 gs->xmlW3CPIs[1] = NULL; |
|
789 // gs->xmlParserInitialized = 0; |
|
790 |
|
791 gs->xmlSAX2DefaultVersionValue = 2; |
|
792 |
|
793 // gs->xmlInputCallbackNr = 0; |
|
794 // gs->xmlInputCallbackInitialized = 0; |
|
795 |
|
796 #ifdef LIBXML_OUTPUT_ENABLED |
|
797 // gs->xmlOutputCallbackNr = 0; |
|
798 // gs->xmlOutputCallbackInitialized = 0; |
|
799 #endif /* LIBXML_OUTPUT_ENABLED*/ |
|
800 |
|
801 gs->xmlCurrentExternalEntityLoader = xmlDefaultExternalEntityLoader; |
|
802 |
|
803 // gs->xmlMemInitialized = 0; |
|
804 // gs->debugMemSize = 0; |
|
805 // gs->debugMaxMemSize = 0; |
|
806 // gs->xmlMemMutex = NULL; |
|
807 // gs->block = 0; |
|
808 // gs->xmlMemStopAtBlock = 0; |
|
809 // gs->xmlMemTraceBlockAt = NULL; |
|
810 |
|
811 //#ifdef LIBXML_TREE_ENABLED |
|
812 // gs->__xmlRegisterCallbacks = 0; |
|
813 //#endif |
|
814 #ifdef LIBXML_TREE_ENABLED |
|
815 |
|
816 // gs->xmlCompressMode = 0; |
|
817 gs->xmlCheckDTD = 1; |
|
818 #endif |
|
819 |
|
820 #ifdef LIBXML_CATALOG_ENABLED |
|
821 // gs->xmlDebugCatalogs = 0; |
|
822 gs->xmlCatalogDefaultAllow = XML_CATA_ALLOW_ALL; |
|
823 gs->xmlCatalogDefaultPrefer = XML_CATA_PREFER_PUBLIC; |
|
824 // gs->xmlCatalogXMLFiles = NULL; |
|
825 // gs->xmlDefaultCatalog = NULL; |
|
826 // xmlCatalogMutex = NULL; |
|
827 // gs->xmlCatalogInitialized = 0; |
|
828 #endif |
|
829 |
|
830 #ifdef LIBXML_XPATH_ENABLED |
|
831 // gs->xmlXPathNAN = 0; |
|
832 gs->xmlXPathPINF = 1; |
|
833 gs->xmlXPathNINF = -1; |
|
834 // gs->xmlXPathNZERO = 0; |
|
835 // gs->xmlXPathInitialized = 0; |
|
836 #ifndef LIBXML_THREAD_ENABLED |
|
837 // gs->xmlXPathDisableOptimizer = 0; |
|
838 #endif |
|
839 gs->xmlXPathDefineExtensionFunctionsGlobally = 1; |
|
840 // gs->xmlXPathDefaultFunctionsHash = NULL; |
|
841 // gs->xmlXPathIntermediaryExtensionFunctionsHash = NULL; |
|
842 #endif /* LIBXML_XPATH_ENABLED */ |
|
843 |
|
844 #ifdef LIBXML_XPTR_ENABLED |
|
845 // gs->xlinkDefaultHandler = NULL; |
|
846 // gs->xlinkDefaultDetect = NULL; |
|
847 #endif |
|
848 |
|
849 xmlMutexUnlock(xmlThrDefMutex); |
|
850 |
|
851 // gs->xmlOOM = gs->xeUserCount = 0; // |
|
852 } |