globals.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126
  1. /*
  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. #define IN_LIBXML
  14. #include "libxml.h"
  15. #ifdef HAVE_STDLIB_H
  16. #include <stdlib.h>
  17. #endif
  18. #include <string.h>
  19. #include <libxml/globals.h>
  20. #include <libxml/xmlmemory.h>
  21. #include <libxml/threads.h>
  22. /* #define DEBUG_GLOBALS */
  23. /*
  24. * Helpful Macro
  25. */
  26. #ifdef LIBXML_THREAD_ENABLED
  27. #define IS_MAIN_THREAD (xmlIsMainThread())
  28. #else
  29. #define IS_MAIN_THREAD 1
  30. #endif
  31. /*
  32. * Mutex to protect "ForNewThreads" variables
  33. */
  34. static xmlMutexPtr xmlThrDefMutex = NULL;
  35. /**
  36. * xmlInitGlobals:
  37. *
  38. * Additional initialisation for multi-threading
  39. */
  40. void xmlInitGlobals(void)
  41. {
  42. if (xmlThrDefMutex == NULL)
  43. xmlThrDefMutex = xmlNewMutex();
  44. }
  45. /**
  46. * xmlCleanupGlobals:
  47. *
  48. * Additional cleanup for multi-threading
  49. */
  50. void xmlCleanupGlobals(void)
  51. {
  52. if (xmlThrDefMutex != NULL) {
  53. xmlFreeMutex(xmlThrDefMutex);
  54. xmlThrDefMutex = NULL;
  55. }
  56. __xmlGlobalInitMutexDestroy();
  57. }
  58. /************************************************************************
  59. * *
  60. * All the user accessible global variables of the library *
  61. * *
  62. ************************************************************************/
  63. /*
  64. * Memory allocation routines
  65. */
  66. #undef xmlFree
  67. #undef xmlMalloc
  68. #undef xmlMallocAtomic
  69. #undef xmlMemStrdup
  70. #undef xmlRealloc
  71. #if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY)
  72. xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
  73. xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
  74. xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
  75. xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
  76. xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
  77. #else
  78. /**
  79. * xmlFree:
  80. * @mem: an already allocated block of memory
  81. *
  82. * The variable holding the libxml free() implementation
  83. */
  84. xmlFreeFunc xmlFree = free;
  85. /**
  86. * xmlMalloc:
  87. * @size: the size requested in bytes
  88. *
  89. * The variable holding the libxml malloc() implementation
  90. *
  91. * Returns a pointer to the newly allocated block or NULL in case of error
  92. */
  93. xmlMallocFunc xmlMalloc = malloc;
  94. /**
  95. * xmlMallocAtomic:
  96. * @size: the size requested in bytes
  97. *
  98. * The variable holding the libxml malloc() implementation for atomic
  99. * data (i.e. blocks not containing pointers), useful when using a
  100. * garbage collecting allocator.
  101. *
  102. * Returns a pointer to the newly allocated block or NULL in case of error
  103. */
  104. xmlMallocFunc xmlMallocAtomic = malloc;
  105. /**
  106. * xmlRealloc:
  107. * @mem: an already allocated block of memory
  108. * @size: the new size requested in bytes
  109. *
  110. * The variable holding the libxml realloc() implementation
  111. *
  112. * Returns a pointer to the newly reallocated block or NULL in case of error
  113. */
  114. xmlReallocFunc xmlRealloc = realloc;
  115. /**
  116. * xmlPosixStrdup
  117. * @cur: the input char *
  118. *
  119. * a strdup implementation with a type signature matching POSIX
  120. *
  121. * Returns a new xmlChar * or NULL
  122. */
  123. static char *
  124. xmlPosixStrdup(const char *cur) {
  125. return((char*) xmlCharStrdup(cur));
  126. }
  127. /**
  128. * xmlMemStrdup:
  129. * @str: a zero terminated string
  130. *
  131. * The variable holding the libxml strdup() implementation
  132. *
  133. * Returns the copy of the string or NULL in case of error
  134. */
  135. xmlStrdupFunc xmlMemStrdup = xmlPosixStrdup;
  136. #endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */
  137. #include <libxml/threads.h>
  138. #include <libxml/globals.h>
  139. #include <libxml/SAX.h>
  140. #undef docbDefaultSAXHandler
  141. #undef htmlDefaultSAXHandler
  142. #undef oldXMLWDcompatibility
  143. #undef xmlBufferAllocScheme
  144. #undef xmlDefaultBufferSize
  145. #undef xmlDefaultSAXHandler
  146. #undef xmlDefaultSAXLocator
  147. #undef xmlDoValidityCheckingDefaultValue
  148. #undef xmlGenericError
  149. #undef xmlStructuredError
  150. #undef xmlGenericErrorContext
  151. #undef xmlStructuredErrorContext
  152. #undef xmlGetWarningsDefaultValue
  153. #undef xmlIndentTreeOutput
  154. #undef xmlTreeIndentString
  155. #undef xmlKeepBlanksDefaultValue
  156. #undef xmlLineNumbersDefaultValue
  157. #undef xmlLoadExtDtdDefaultValue
  158. #undef xmlParserDebugEntities
  159. #undef xmlParserVersion
  160. #undef xmlPedanticParserDefaultValue
  161. #undef xmlSaveNoEmptyTags
  162. #undef xmlSubstituteEntitiesDefaultValue
  163. #undef xmlRegisterNodeDefaultValue
  164. #undef xmlDeregisterNodeDefaultValue
  165. #undef xmlLastError
  166. #undef xmlParserInputBufferCreateFilenameValue
  167. #undef xmlOutputBufferCreateFilenameValue
  168. /**
  169. * xmlParserVersion:
  170. *
  171. * Constant string describing the internal version of the library
  172. */
  173. const char *xmlParserVersion = LIBXML_VERSION_STRING LIBXML_VERSION_EXTRA;
  174. /**
  175. * xmlBufferAllocScheme:
  176. *
  177. * Global setting, default allocation policy for buffers, default is
  178. * XML_BUFFER_ALLOC_EXACT
  179. */
  180. xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT;
  181. static xmlBufferAllocationScheme xmlBufferAllocSchemeThrDef = XML_BUFFER_ALLOC_EXACT;
  182. /**
  183. * xmlDefaultBufferSize:
  184. *
  185. * Global setting, default buffer size. Default value is BASE_BUFFER_SIZE
  186. */
  187. int xmlDefaultBufferSize = BASE_BUFFER_SIZE;
  188. static int xmlDefaultBufferSizeThrDef = BASE_BUFFER_SIZE;
  189. /*
  190. * Parser defaults
  191. */
  192. /**
  193. * oldXMLWDcompatibility:
  194. *
  195. * Global setting, DEPRECATED.
  196. */
  197. int oldXMLWDcompatibility = 0; /* DEPRECATED */
  198. /**
  199. * xmlParserDebugEntities:
  200. *
  201. * Global setting, asking the parser to print out debugging information.
  202. * while handling entities.
  203. * Disabled by default
  204. */
  205. int xmlParserDebugEntities = 0;
  206. static int xmlParserDebugEntitiesThrDef = 0;
  207. /**
  208. * xmlDoValidityCheckingDefaultValue:
  209. *
  210. * Global setting, indicate that the parser should work in validating mode.
  211. * Disabled by default.
  212. */
  213. int xmlDoValidityCheckingDefaultValue = 0;
  214. static int xmlDoValidityCheckingDefaultValueThrDef = 0;
  215. /**
  216. * xmlGetWarningsDefaultValue:
  217. *
  218. * Global setting, indicate that the parser should provide warnings.
  219. * Activated by default.
  220. */
  221. int xmlGetWarningsDefaultValue = 1;
  222. static int xmlGetWarningsDefaultValueThrDef = 1;
  223. /**
  224. * xmlLoadExtDtdDefaultValue:
  225. *
  226. * Global setting, indicate that the parser should load DTD while not
  227. * validating.
  228. * Disabled by default.
  229. */
  230. int xmlLoadExtDtdDefaultValue = 0;
  231. static int xmlLoadExtDtdDefaultValueThrDef = 0;
  232. /**
  233. * xmlPedanticParserDefaultValue:
  234. *
  235. * Global setting, indicate that the parser be pedantic
  236. * Disabled by default.
  237. */
  238. int xmlPedanticParserDefaultValue = 0;
  239. static int xmlPedanticParserDefaultValueThrDef = 0;
  240. /**
  241. * xmlLineNumbersDefaultValue:
  242. *
  243. * Global setting, indicate that the parser should store the line number
  244. * in the content field of elements in the DOM tree.
  245. * Disabled by default since this may not be safe for old classes of
  246. * application.
  247. */
  248. int xmlLineNumbersDefaultValue = 0;
  249. static int xmlLineNumbersDefaultValueThrDef = 0;
  250. /**
  251. * xmlKeepBlanksDefaultValue:
  252. *
  253. * Global setting, indicate that the parser should keep all blanks
  254. * nodes found in the content
  255. * Activated by default, this is actually needed to have the parser
  256. * conformant to the XML Recommendation, however the option is kept
  257. * for some applications since this was libxml1 default behaviour.
  258. */
  259. int xmlKeepBlanksDefaultValue = 1;
  260. static int xmlKeepBlanksDefaultValueThrDef = 1;
  261. /**
  262. * xmlSubstituteEntitiesDefaultValue:
  263. *
  264. * Global setting, indicate that the parser should not generate entity
  265. * references but replace them with the actual content of the entity
  266. * Disabled by default, this should be activated when using XPath since
  267. * the XPath data model requires entities replacement and the XPath
  268. * engine does not handle entities references transparently.
  269. */
  270. int xmlSubstituteEntitiesDefaultValue = 0;
  271. static int xmlSubstituteEntitiesDefaultValueThrDef = 0;
  272. xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL;
  273. static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL;
  274. xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
  275. static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL;
  276. xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue = NULL;
  277. static xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValueThrDef = NULL;
  278. xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue = NULL;
  279. static xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValueThrDef = NULL;
  280. /*
  281. * Error handling
  282. */
  283. /* xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc; */
  284. /* Must initialize xmlGenericError in xmlInitParser */
  285. void XMLCDECL xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
  286. const char *msg,
  287. ...);
  288. /**
  289. * xmlGenericError:
  290. *
  291. * Global setting: function used for generic error callbacks
  292. */
  293. xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
  294. static xmlGenericErrorFunc xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
  295. /**
  296. * xmlStructuredError:
  297. *
  298. * Global setting: function used for structured error callbacks
  299. */
  300. xmlStructuredErrorFunc xmlStructuredError = NULL;
  301. static xmlStructuredErrorFunc xmlStructuredErrorThrDef = NULL;
  302. /**
  303. * xmlGenericErrorContext:
  304. *
  305. * Global setting passed to generic error callbacks
  306. */
  307. void *xmlGenericErrorContext = NULL;
  308. static void *xmlGenericErrorContextThrDef = NULL;
  309. /**
  310. * xmlStructuredErrorContext:
  311. *
  312. * Global setting passed to structured error callbacks
  313. */
  314. void *xmlStructuredErrorContext = NULL;
  315. static void *xmlStructuredErrorContextThrDef = NULL;
  316. xmlError xmlLastError;
  317. /*
  318. * output defaults
  319. */
  320. /**
  321. * xmlIndentTreeOutput:
  322. *
  323. * Global setting, asking the serializer to indent the output tree by default
  324. * Enabled by default
  325. */
  326. int xmlIndentTreeOutput = 1;
  327. static int xmlIndentTreeOutputThrDef = 1;
  328. /**
  329. * xmlTreeIndentString:
  330. *
  331. * The string used to do one-level indent. By default is equal to " " (two spaces)
  332. */
  333. const char *xmlTreeIndentString = " ";
  334. static const char *xmlTreeIndentStringThrDef = " ";
  335. /**
  336. * xmlSaveNoEmptyTags:
  337. *
  338. * Global setting, asking the serializer to not output empty tags
  339. * as <empty/> but <empty></empty>. those two forms are indistinguishable
  340. * once parsed.
  341. * Disabled by default
  342. */
  343. int xmlSaveNoEmptyTags = 0;
  344. static int xmlSaveNoEmptyTagsThrDef = 0;
  345. #ifdef LIBXML_SAX1_ENABLED
  346. /**
  347. * xmlDefaultSAXHandler:
  348. *
  349. * Default SAX version1 handler for XML, builds the DOM tree
  350. */
  351. xmlSAXHandlerV1 xmlDefaultSAXHandler = {
  352. xmlSAX2InternalSubset,
  353. xmlSAX2IsStandalone,
  354. xmlSAX2HasInternalSubset,
  355. xmlSAX2HasExternalSubset,
  356. xmlSAX2ResolveEntity,
  357. xmlSAX2GetEntity,
  358. xmlSAX2EntityDecl,
  359. xmlSAX2NotationDecl,
  360. xmlSAX2AttributeDecl,
  361. xmlSAX2ElementDecl,
  362. xmlSAX2UnparsedEntityDecl,
  363. xmlSAX2SetDocumentLocator,
  364. xmlSAX2StartDocument,
  365. xmlSAX2EndDocument,
  366. xmlSAX2StartElement,
  367. xmlSAX2EndElement,
  368. xmlSAX2Reference,
  369. xmlSAX2Characters,
  370. xmlSAX2Characters,
  371. xmlSAX2ProcessingInstruction,
  372. xmlSAX2Comment,
  373. xmlParserWarning,
  374. xmlParserError,
  375. xmlParserError,
  376. xmlSAX2GetParameterEntity,
  377. xmlSAX2CDataBlock,
  378. xmlSAX2ExternalSubset,
  379. 0,
  380. };
  381. #endif /* LIBXML_SAX1_ENABLED */
  382. /**
  383. * xmlDefaultSAXLocator:
  384. *
  385. * The default SAX Locator
  386. * { getPublicId, getSystemId, getLineNumber, getColumnNumber}
  387. */
  388. xmlSAXLocator xmlDefaultSAXLocator = {
  389. xmlSAX2GetPublicId,
  390. xmlSAX2GetSystemId,
  391. xmlSAX2GetLineNumber,
  392. xmlSAX2GetColumnNumber
  393. };
  394. #ifdef LIBXML_HTML_ENABLED
  395. /**
  396. * htmlDefaultSAXHandler:
  397. *
  398. * Default old SAX v1 handler for HTML, builds the DOM tree
  399. */
  400. xmlSAXHandlerV1 htmlDefaultSAXHandler = {
  401. xmlSAX2InternalSubset,
  402. NULL,
  403. NULL,
  404. NULL,
  405. NULL,
  406. xmlSAX2GetEntity,
  407. NULL,
  408. NULL,
  409. NULL,
  410. NULL,
  411. NULL,
  412. xmlSAX2SetDocumentLocator,
  413. xmlSAX2StartDocument,
  414. xmlSAX2EndDocument,
  415. xmlSAX2StartElement,
  416. xmlSAX2EndElement,
  417. NULL,
  418. xmlSAX2Characters,
  419. xmlSAX2IgnorableWhitespace,
  420. xmlSAX2ProcessingInstruction,
  421. xmlSAX2Comment,
  422. xmlParserWarning,
  423. xmlParserError,
  424. xmlParserError,
  425. xmlSAX2GetParameterEntity,
  426. xmlSAX2CDataBlock,
  427. NULL,
  428. 0,
  429. };
  430. #endif /* LIBXML_HTML_ENABLED */
  431. #ifdef LIBXML_DOCB_ENABLED
  432. /**
  433. * docbDefaultSAXHandler:
  434. *
  435. * Default old SAX v1 handler for SGML DocBook, builds the DOM tree
  436. */
  437. xmlSAXHandlerV1 docbDefaultSAXHandler = {
  438. xmlSAX2InternalSubset,
  439. xmlSAX2IsStandalone,
  440. xmlSAX2HasInternalSubset,
  441. xmlSAX2HasExternalSubset,
  442. xmlSAX2ResolveEntity,
  443. xmlSAX2GetEntity,
  444. xmlSAX2EntityDecl,
  445. NULL,
  446. NULL,
  447. NULL,
  448. NULL,
  449. xmlSAX2SetDocumentLocator,
  450. xmlSAX2StartDocument,
  451. xmlSAX2EndDocument,
  452. xmlSAX2StartElement,
  453. xmlSAX2EndElement,
  454. xmlSAX2Reference,
  455. xmlSAX2Characters,
  456. xmlSAX2IgnorableWhitespace,
  457. NULL,
  458. xmlSAX2Comment,
  459. xmlParserWarning,
  460. xmlParserError,
  461. xmlParserError,
  462. xmlSAX2GetParameterEntity,
  463. NULL,
  464. NULL,
  465. 0,
  466. };
  467. #endif /* LIBXML_DOCB_ENABLED */
  468. /**
  469. * xmlInitializeGlobalState:
  470. * @gs: a pointer to a newly allocated global state
  471. *
  472. * xmlInitializeGlobalState() initialize a global state with all the
  473. * default values of the library.
  474. */
  475. void
  476. xmlInitializeGlobalState(xmlGlobalStatePtr gs)
  477. {
  478. #ifdef DEBUG_GLOBALS
  479. fprintf(stderr, "Initializing globals at %lu for thread %d\n",
  480. (unsigned long) gs, xmlGetThreadId());
  481. #endif
  482. /*
  483. * Perform initialization as required by libxml
  484. */
  485. if (xmlThrDefMutex == NULL)
  486. xmlInitGlobals();
  487. xmlMutexLock(xmlThrDefMutex);
  488. #if defined(LIBXML_DOCB_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
  489. initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
  490. #endif
  491. #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
  492. inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
  493. #endif
  494. gs->oldXMLWDcompatibility = 0;
  495. gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
  496. gs->xmlDefaultBufferSize = xmlDefaultBufferSizeThrDef;
  497. #if defined(LIBXML_SAX1_ENABLED) && defined(LIBXML_LEGACY_ENABLED)
  498. initxmlDefaultSAXHandler(&gs->xmlDefaultSAXHandler, 1);
  499. #endif /* LIBXML_SAX1_ENABLED */
  500. gs->xmlDefaultSAXLocator.getPublicId = xmlSAX2GetPublicId;
  501. gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
  502. gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
  503. gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
  504. gs->xmlDoValidityCheckingDefaultValue =
  505. xmlDoValidityCheckingDefaultValueThrDef;
  506. #if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
  507. gs->xmlFree = (xmlFreeFunc) xmlMemFree;
  508. gs->xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
  509. gs->xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
  510. gs->xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
  511. gs->xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
  512. #else
  513. gs->xmlFree = (xmlFreeFunc) free;
  514. gs->xmlMalloc = (xmlMallocFunc) malloc;
  515. gs->xmlMallocAtomic = (xmlMallocFunc) malloc;
  516. gs->xmlRealloc = (xmlReallocFunc) realloc;
  517. gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
  518. #endif
  519. gs->xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef;
  520. gs->xmlIndentTreeOutput = xmlIndentTreeOutputThrDef;
  521. gs->xmlTreeIndentString = xmlTreeIndentStringThrDef;
  522. gs->xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
  523. gs->xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
  524. gs->xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
  525. gs->xmlParserDebugEntities = xmlParserDebugEntitiesThrDef;
  526. gs->xmlParserVersion = LIBXML_VERSION_STRING;
  527. gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
  528. gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
  529. gs->xmlSubstituteEntitiesDefaultValue =
  530. xmlSubstituteEntitiesDefaultValueThrDef;
  531. gs->xmlGenericError = xmlGenericErrorThrDef;
  532. gs->xmlStructuredError = xmlStructuredErrorThrDef;
  533. gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
  534. gs->xmlStructuredErrorContext = xmlStructuredErrorContextThrDef;
  535. gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
  536. gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
  537. gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef;
  538. gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef;
  539. memset(&gs->xmlLastError, 0, sizeof(xmlError));
  540. xmlMutexUnlock(xmlThrDefMutex);
  541. }
  542. /**
  543. * DOC_DISABLE : we ignore missing doc for the xmlThrDef functions,
  544. * those are really internal work
  545. */
  546. void
  547. xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
  548. xmlMutexLock(xmlThrDefMutex);
  549. xmlGenericErrorContextThrDef = ctx;
  550. if (handler != NULL)
  551. xmlGenericErrorThrDef = handler;
  552. else
  553. xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
  554. xmlMutexUnlock(xmlThrDefMutex);
  555. }
  556. void
  557. xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
  558. xmlMutexLock(xmlThrDefMutex);
  559. xmlStructuredErrorContextThrDef = ctx;
  560. xmlStructuredErrorThrDef = handler;
  561. xmlMutexUnlock(xmlThrDefMutex);
  562. }
  563. /**
  564. * xmlRegisterNodeDefault:
  565. * @func: function pointer to the new RegisterNodeFunc
  566. *
  567. * Registers a callback for node creation
  568. *
  569. * Returns the old value of the registration function
  570. */
  571. xmlRegisterNodeFunc
  572. xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
  573. {
  574. xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
  575. __xmlRegisterCallbacks = 1;
  576. xmlRegisterNodeDefaultValue = func;
  577. return(old);
  578. }
  579. xmlRegisterNodeFunc
  580. xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
  581. {
  582. xmlRegisterNodeFunc old;
  583. xmlMutexLock(xmlThrDefMutex);
  584. old = xmlRegisterNodeDefaultValueThrDef;
  585. __xmlRegisterCallbacks = 1;
  586. xmlRegisterNodeDefaultValueThrDef = func;
  587. xmlMutexUnlock(xmlThrDefMutex);
  588. return(old);
  589. }
  590. /**
  591. * xmlDeregisterNodeDefault:
  592. * @func: function pointer to the new DeregisterNodeFunc
  593. *
  594. * Registers a callback for node destruction
  595. *
  596. * Returns the previous value of the deregistration function
  597. */
  598. xmlDeregisterNodeFunc
  599. xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
  600. {
  601. xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
  602. __xmlRegisterCallbacks = 1;
  603. xmlDeregisterNodeDefaultValue = func;
  604. return(old);
  605. }
  606. xmlDeregisterNodeFunc
  607. xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
  608. {
  609. xmlDeregisterNodeFunc old;
  610. xmlMutexLock(xmlThrDefMutex);
  611. old = xmlDeregisterNodeDefaultValueThrDef;
  612. __xmlRegisterCallbacks = 1;
  613. xmlDeregisterNodeDefaultValueThrDef = func;
  614. xmlMutexUnlock(xmlThrDefMutex);
  615. return(old);
  616. }
  617. xmlParserInputBufferCreateFilenameFunc
  618. xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
  619. {
  620. xmlParserInputBufferCreateFilenameFunc old;
  621. xmlMutexLock(xmlThrDefMutex);
  622. old = xmlParserInputBufferCreateFilenameValueThrDef;
  623. if (old == NULL) {
  624. old = __xmlParserInputBufferCreateFilename;
  625. }
  626. xmlParserInputBufferCreateFilenameValueThrDef = func;
  627. xmlMutexUnlock(xmlThrDefMutex);
  628. return(old);
  629. }
  630. xmlOutputBufferCreateFilenameFunc
  631. xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
  632. {
  633. xmlOutputBufferCreateFilenameFunc old;
  634. xmlMutexLock(xmlThrDefMutex);
  635. old = xmlOutputBufferCreateFilenameValueThrDef;
  636. #ifdef LIBXML_OUTPUT_ENABLED
  637. if (old == NULL) {
  638. old = __xmlOutputBufferCreateFilename;
  639. }
  640. #endif
  641. xmlOutputBufferCreateFilenameValueThrDef = func;
  642. xmlMutexUnlock(xmlThrDefMutex);
  643. return(old);
  644. }
  645. #ifdef LIBXML_DOCB_ENABLED
  646. #undef docbDefaultSAXHandler
  647. xmlSAXHandlerV1 *
  648. __docbDefaultSAXHandler(void) {
  649. if (IS_MAIN_THREAD)
  650. return (&docbDefaultSAXHandler);
  651. else
  652. return (&xmlGetGlobalState()->docbDefaultSAXHandler);
  653. }
  654. #endif
  655. #ifdef LIBXML_HTML_ENABLED
  656. #undef htmlDefaultSAXHandler
  657. xmlSAXHandlerV1 *
  658. __htmlDefaultSAXHandler(void) {
  659. if (IS_MAIN_THREAD)
  660. return (&htmlDefaultSAXHandler);
  661. else
  662. return (&xmlGetGlobalState()->htmlDefaultSAXHandler);
  663. }
  664. #endif
  665. #undef xmlLastError
  666. xmlError *
  667. __xmlLastError(void) {
  668. if (IS_MAIN_THREAD)
  669. return (&xmlLastError);
  670. else
  671. return (&xmlGetGlobalState()->xmlLastError);
  672. }
  673. /*
  674. * The following memory routines were apparently lost at some point,
  675. * and were re-inserted at this point on June 10, 2004. Hope it's
  676. * the right place for them :-)
  677. */
  678. #if defined(LIBXML_THREAD_ALLOC_ENABLED) && defined(LIBXML_THREAD_ENABLED)
  679. #undef xmlMalloc
  680. xmlMallocFunc *
  681. __xmlMalloc(void){
  682. if (IS_MAIN_THREAD)
  683. return (&xmlMalloc);
  684. else
  685. return (&xmlGetGlobalState()->xmlMalloc);
  686. }
  687. #undef xmlMallocAtomic
  688. xmlMallocFunc *
  689. __xmlMallocAtomic(void){
  690. if (IS_MAIN_THREAD)
  691. return (&xmlMallocAtomic);
  692. else
  693. return (&xmlGetGlobalState()->xmlMallocAtomic);
  694. }
  695. #undef xmlRealloc
  696. xmlReallocFunc *
  697. __xmlRealloc(void){
  698. if (IS_MAIN_THREAD)
  699. return (&xmlRealloc);
  700. else
  701. return (&xmlGetGlobalState()->xmlRealloc);
  702. }
  703. #undef xmlFree
  704. xmlFreeFunc *
  705. __xmlFree(void){
  706. if (IS_MAIN_THREAD)
  707. return (&xmlFree);
  708. else
  709. return (&xmlGetGlobalState()->xmlFree);
  710. }
  711. xmlStrdupFunc *
  712. __xmlMemStrdup(void){
  713. if (IS_MAIN_THREAD)
  714. return (&xmlMemStrdup);
  715. else
  716. return (&xmlGetGlobalState()->xmlMemStrdup);
  717. }
  718. #endif
  719. /*
  720. * Everything starting from the line below is
  721. * Automatically generated by build_glob.py.
  722. * Do not modify the previous line.
  723. */
  724. #undef oldXMLWDcompatibility
  725. int *
  726. __oldXMLWDcompatibility(void) {
  727. if (IS_MAIN_THREAD)
  728. return (&oldXMLWDcompatibility);
  729. else
  730. return (&xmlGetGlobalState()->oldXMLWDcompatibility);
  731. }
  732. #undef xmlBufferAllocScheme
  733. xmlBufferAllocationScheme *
  734. __xmlBufferAllocScheme(void) {
  735. if (IS_MAIN_THREAD)
  736. return (&xmlBufferAllocScheme);
  737. else
  738. return (&xmlGetGlobalState()->xmlBufferAllocScheme);
  739. }
  740. xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) {
  741. xmlBufferAllocationScheme ret;
  742. xmlMutexLock(xmlThrDefMutex);
  743. ret = xmlBufferAllocSchemeThrDef;
  744. xmlBufferAllocSchemeThrDef = v;
  745. xmlMutexUnlock(xmlThrDefMutex);
  746. return ret;
  747. }
  748. #undef xmlDefaultBufferSize
  749. int *
  750. __xmlDefaultBufferSize(void) {
  751. if (IS_MAIN_THREAD)
  752. return (&xmlDefaultBufferSize);
  753. else
  754. return (&xmlGetGlobalState()->xmlDefaultBufferSize);
  755. }
  756. int xmlThrDefDefaultBufferSize(int v) {
  757. int ret;
  758. xmlMutexLock(xmlThrDefMutex);
  759. ret = xmlDefaultBufferSizeThrDef;
  760. xmlDefaultBufferSizeThrDef = v;
  761. xmlMutexUnlock(xmlThrDefMutex);
  762. return ret;
  763. }
  764. #ifdef LIBXML_SAX1_ENABLED
  765. #undef xmlDefaultSAXHandler
  766. xmlSAXHandlerV1 *
  767. __xmlDefaultSAXHandler(void) {
  768. if (IS_MAIN_THREAD)
  769. return (&xmlDefaultSAXHandler);
  770. else
  771. return (&xmlGetGlobalState()->xmlDefaultSAXHandler);
  772. }
  773. #endif /* LIBXML_SAX1_ENABLED */
  774. #undef xmlDefaultSAXLocator
  775. xmlSAXLocator *
  776. __xmlDefaultSAXLocator(void) {
  777. if (IS_MAIN_THREAD)
  778. return (&xmlDefaultSAXLocator);
  779. else
  780. return (&xmlGetGlobalState()->xmlDefaultSAXLocator);
  781. }
  782. #undef xmlDoValidityCheckingDefaultValue
  783. int *
  784. __xmlDoValidityCheckingDefaultValue(void) {
  785. if (IS_MAIN_THREAD)
  786. return (&xmlDoValidityCheckingDefaultValue);
  787. else
  788. return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue);
  789. }
  790. int xmlThrDefDoValidityCheckingDefaultValue(int v) {
  791. int ret;
  792. xmlMutexLock(xmlThrDefMutex);
  793. ret = xmlDoValidityCheckingDefaultValueThrDef;
  794. xmlDoValidityCheckingDefaultValueThrDef = v;
  795. xmlMutexUnlock(xmlThrDefMutex);
  796. return ret;
  797. }
  798. #undef xmlGenericError
  799. xmlGenericErrorFunc * XMLCALL
  800. __xmlGenericError(void) {
  801. if (IS_MAIN_THREAD)
  802. return (&xmlGenericError);
  803. else
  804. return (&xmlGetGlobalState()->xmlGenericError);
  805. }
  806. #undef xmlStructuredError
  807. xmlStructuredErrorFunc *
  808. __xmlStructuredError(void) {
  809. if (IS_MAIN_THREAD)
  810. return (&xmlStructuredError);
  811. else
  812. return (&xmlGetGlobalState()->xmlStructuredError);
  813. }
  814. #undef xmlGenericErrorContext
  815. void * *
  816. __xmlGenericErrorContext(void) {
  817. if (IS_MAIN_THREAD)
  818. return (&xmlGenericErrorContext);
  819. else
  820. return (&xmlGetGlobalState()->xmlGenericErrorContext);
  821. }
  822. #undef xmlStructuredErrorContext
  823. void * *
  824. __xmlStructuredErrorContext(void) {
  825. if (IS_MAIN_THREAD)
  826. return (&xmlStructuredErrorContext);
  827. else
  828. return (&xmlGetGlobalState()->xmlStructuredErrorContext);
  829. }
  830. #undef xmlGetWarningsDefaultValue
  831. int *
  832. __xmlGetWarningsDefaultValue(void) {
  833. if (IS_MAIN_THREAD)
  834. return (&xmlGetWarningsDefaultValue);
  835. else
  836. return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue);
  837. }
  838. int xmlThrDefGetWarningsDefaultValue(int v) {
  839. int ret;
  840. xmlMutexLock(xmlThrDefMutex);
  841. ret = xmlGetWarningsDefaultValueThrDef;
  842. xmlGetWarningsDefaultValueThrDef = v;
  843. xmlMutexUnlock(xmlThrDefMutex);
  844. return ret;
  845. }
  846. #undef xmlIndentTreeOutput
  847. int *
  848. __xmlIndentTreeOutput(void) {
  849. if (IS_MAIN_THREAD)
  850. return (&xmlIndentTreeOutput);
  851. else
  852. return (&xmlGetGlobalState()->xmlIndentTreeOutput);
  853. }
  854. int xmlThrDefIndentTreeOutput(int v) {
  855. int ret;
  856. xmlMutexLock(xmlThrDefMutex);
  857. ret = xmlIndentTreeOutputThrDef;
  858. xmlIndentTreeOutputThrDef = v;
  859. xmlMutexUnlock(xmlThrDefMutex);
  860. return ret;
  861. }
  862. #undef xmlTreeIndentString
  863. const char * *
  864. __xmlTreeIndentString(void) {
  865. if (IS_MAIN_THREAD)
  866. return (&xmlTreeIndentString);
  867. else
  868. return (&xmlGetGlobalState()->xmlTreeIndentString);
  869. }
  870. const char * xmlThrDefTreeIndentString(const char * v) {
  871. const char * ret;
  872. xmlMutexLock(xmlThrDefMutex);
  873. ret = xmlTreeIndentStringThrDef;
  874. xmlTreeIndentStringThrDef = v;
  875. xmlMutexUnlock(xmlThrDefMutex);
  876. return ret;
  877. }
  878. #undef xmlKeepBlanksDefaultValue
  879. int *
  880. __xmlKeepBlanksDefaultValue(void) {
  881. if (IS_MAIN_THREAD)
  882. return (&xmlKeepBlanksDefaultValue);
  883. else
  884. return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue);
  885. }
  886. int xmlThrDefKeepBlanksDefaultValue(int v) {
  887. int ret;
  888. xmlMutexLock(xmlThrDefMutex);
  889. ret = xmlKeepBlanksDefaultValueThrDef;
  890. xmlKeepBlanksDefaultValueThrDef = v;
  891. xmlMutexUnlock(xmlThrDefMutex);
  892. return ret;
  893. }
  894. #undef xmlLineNumbersDefaultValue
  895. int *
  896. __xmlLineNumbersDefaultValue(void) {
  897. if (IS_MAIN_THREAD)
  898. return (&xmlLineNumbersDefaultValue);
  899. else
  900. return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue);
  901. }
  902. int xmlThrDefLineNumbersDefaultValue(int v) {
  903. int ret;
  904. xmlMutexLock(xmlThrDefMutex);
  905. ret = xmlLineNumbersDefaultValueThrDef;
  906. xmlLineNumbersDefaultValueThrDef = v;
  907. xmlMutexUnlock(xmlThrDefMutex);
  908. return ret;
  909. }
  910. #undef xmlLoadExtDtdDefaultValue
  911. int *
  912. __xmlLoadExtDtdDefaultValue(void) {
  913. if (IS_MAIN_THREAD)
  914. return (&xmlLoadExtDtdDefaultValue);
  915. else
  916. return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue);
  917. }
  918. int xmlThrDefLoadExtDtdDefaultValue(int v) {
  919. int ret;
  920. xmlMutexLock(xmlThrDefMutex);
  921. ret = xmlLoadExtDtdDefaultValueThrDef;
  922. xmlLoadExtDtdDefaultValueThrDef = v;
  923. xmlMutexUnlock(xmlThrDefMutex);
  924. return ret;
  925. }
  926. #undef xmlParserDebugEntities
  927. int *
  928. __xmlParserDebugEntities(void) {
  929. if (IS_MAIN_THREAD)
  930. return (&xmlParserDebugEntities);
  931. else
  932. return (&xmlGetGlobalState()->xmlParserDebugEntities);
  933. }
  934. int xmlThrDefParserDebugEntities(int v) {
  935. int ret;
  936. xmlMutexLock(xmlThrDefMutex);
  937. ret = xmlParserDebugEntitiesThrDef;
  938. xmlParserDebugEntitiesThrDef = v;
  939. xmlMutexUnlock(xmlThrDefMutex);
  940. return ret;
  941. }
  942. #undef xmlParserVersion
  943. const char * *
  944. __xmlParserVersion(void) {
  945. if (IS_MAIN_THREAD)
  946. return (&xmlParserVersion);
  947. else
  948. return (&xmlGetGlobalState()->xmlParserVersion);
  949. }
  950. #undef xmlPedanticParserDefaultValue
  951. int *
  952. __xmlPedanticParserDefaultValue(void) {
  953. if (IS_MAIN_THREAD)
  954. return (&xmlPedanticParserDefaultValue);
  955. else
  956. return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue);
  957. }
  958. int xmlThrDefPedanticParserDefaultValue(int v) {
  959. int ret;
  960. xmlMutexLock(xmlThrDefMutex);
  961. ret = xmlPedanticParserDefaultValueThrDef;
  962. xmlPedanticParserDefaultValueThrDef = v;
  963. xmlMutexUnlock(xmlThrDefMutex);
  964. return ret;
  965. }
  966. #undef xmlSaveNoEmptyTags
  967. int *
  968. __xmlSaveNoEmptyTags(void) {
  969. if (IS_MAIN_THREAD)
  970. return (&xmlSaveNoEmptyTags);
  971. else
  972. return (&xmlGetGlobalState()->xmlSaveNoEmptyTags);
  973. }
  974. int xmlThrDefSaveNoEmptyTags(int v) {
  975. int ret;
  976. xmlMutexLock(xmlThrDefMutex);
  977. ret = xmlSaveNoEmptyTagsThrDef;
  978. xmlSaveNoEmptyTagsThrDef = v;
  979. xmlMutexUnlock(xmlThrDefMutex);
  980. return ret;
  981. }
  982. #undef xmlSubstituteEntitiesDefaultValue
  983. int *
  984. __xmlSubstituteEntitiesDefaultValue(void) {
  985. if (IS_MAIN_THREAD)
  986. return (&xmlSubstituteEntitiesDefaultValue);
  987. else
  988. return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
  989. }
  990. int xmlThrDefSubstituteEntitiesDefaultValue(int v) {
  991. int ret;
  992. xmlMutexLock(xmlThrDefMutex);
  993. ret = xmlSubstituteEntitiesDefaultValueThrDef;
  994. xmlSubstituteEntitiesDefaultValueThrDef = v;
  995. xmlMutexUnlock(xmlThrDefMutex);
  996. return ret;
  997. }
  998. #undef xmlRegisterNodeDefaultValue
  999. xmlRegisterNodeFunc * XMLCALL
  1000. __xmlRegisterNodeDefaultValue(void) {
  1001. if (IS_MAIN_THREAD)
  1002. return (&xmlRegisterNodeDefaultValue);
  1003. else
  1004. return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue);
  1005. }
  1006. #undef xmlDeregisterNodeDefaultValue
  1007. xmlDeregisterNodeFunc * XMLCALL
  1008. __xmlDeregisterNodeDefaultValue(void) {
  1009. if (IS_MAIN_THREAD)
  1010. return (&xmlDeregisterNodeDefaultValue);
  1011. else
  1012. return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
  1013. }
  1014. #undef xmlParserInputBufferCreateFilenameValue
  1015. xmlParserInputBufferCreateFilenameFunc * XMLCALL
  1016. __xmlParserInputBufferCreateFilenameValue(void) {
  1017. if (IS_MAIN_THREAD)
  1018. return (&xmlParserInputBufferCreateFilenameValue);
  1019. else
  1020. return (&xmlGetGlobalState()->xmlParserInputBufferCreateFilenameValue);
  1021. }
  1022. #undef xmlOutputBufferCreateFilenameValue
  1023. xmlOutputBufferCreateFilenameFunc * XMLCALL
  1024. __xmlOutputBufferCreateFilenameValue(void) {
  1025. if (IS_MAIN_THREAD)
  1026. return (&xmlOutputBufferCreateFilenameValue);
  1027. else
  1028. return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
  1029. }
  1030. #define bottom_globals
  1031. #include "elfgcchack.h"