globals.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127
  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 *
  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"