Skip to main content

libxml_rs/abi/
data_globals.rs

1//! Exported C data globals — the classic libxml2/libxslt public variables
2//! (11.1-G data-ABI closure, residual R-000135).
3//!
4//! Downstream C code reads and writes these symbols directly
5//! (e.g. `xmlDoValidityCheckingDefaultValue = 1;`), so they must exist with
6//! upstream names, types and defaults. The parser-default accessors in
7//! `src/xml/globals/mod.rs` read and write the SAME statics (single source
8//! of truth): a C write is immediately observable by the candidate parser.
9//!
10//! Defaults match upstream `globals.c` (libxml2 2.15.3) and `xslt.c`
11//! (libxslt 1.1.45).
12//!
13//! # SAFETY
14//!
15//! `static mut` globals are unsafe to touch from Rust; every access goes
16//! through the accessor functions in `crate::xml::globals` (or directly
17//! here with an explicit safety note). C accesses are inherently racy in
18//! upstream too — upstream documents these globals as deprecated and
19//! not thread-safe.
20
21use core::ffi::c_void;
22use std::os::raw::{c_char, c_int, c_uint};
23
24use crate::abi::callbacks::{xmlGenericErrorFunc, xmlStructuredErrorFunc};
25use crate::abi::types::xmlChar;
26
27// ═══════════════════════════════════════════════════════════════════════════════
28// Parser defaults (upstream globals.c)
29// ═══════════════════════════════════════════════════════════════════════════════
30
31/// `int xmlDoValidityCheckingDefaultValue` (default 0)
32#[no_mangle]
33pub static mut xmlDoValidityCheckingDefaultValue: c_int = 0;
34
35/// `int xmlGetWarningsDefaultValue` (default 1)
36#[no_mangle]
37pub static mut xmlGetWarningsDefaultValue: c_int = 1;
38
39/// `int xmlLoadExtDtdDefaultValue` (default 0)
40#[no_mangle]
41pub static mut xmlLoadExtDtdDefaultValue: c_int = 0;
42
43/// `int xmlPedanticParserDefaultValue` (default 0)
44#[no_mangle]
45pub static mut xmlPedanticParserDefaultValue: c_int = 0;
46
47/// `int xmlLineNumbersDefaultValue` (default 1 — upstream globals.c
48/// `xmlLineNumbersDefaultValueThrDef = 1`)
49#[no_mangle]
50pub static mut xmlLineNumbersDefaultValue: c_int = 1;
51
52/// `int xmlKeepBlanksDefaultValue` (default 1)
53#[no_mangle]
54pub static mut xmlKeepBlanksDefaultValue: c_int = 1;
55
56/// `int xmlSubstituteEntitiesDefaultValue` (default 0)
57#[no_mangle]
58pub static mut xmlSubstituteEntitiesDefaultValue: c_int = 0;
59
60/// `int xmlParserDebugEntities` (default 0)
61#[no_mangle]
62pub static mut xmlParserDebugEntities: c_int = 0;
63
64/// `int xmlIndentTreeOutput` (default 1 — upstream globals.c
65/// `xmlIndentTreeOutputThrDef = 1`)
66#[no_mangle]
67pub static mut xmlIndentTreeOutput: c_int = 1;
68
69/// `const xmlChar *xmlTreeIndentString` (default "  " — upstream globals.c
70/// `xmlTreeIndentStringThrDef = "  "`)
71#[no_mangle]
72pub static mut xmlTreeIndentString: *const xmlChar = {
73    static S: [u8; 3] = *b"  \0";
74    S.as_ptr()
75};
76
77/// `int xmlSaveNoEmptyTags` (default 0)
78#[no_mangle]
79pub static mut xmlSaveNoEmptyTags: c_int = 0;
80
81/// Upstream `xmlRegisterNodeFunc xmlRegisterNodeDefaultValue` (default NULL)
82#[no_mangle]
83pub static mut xmlRegisterNodeDefaultValue: Option<
84    unsafe extern "C" fn(*mut crate::abi::structs::_xmlNode),
85> = None;
86
87/// Upstream static `xmlRegisterCallbacks` (tree.c): the gate that arms the
88/// node register/deregister hooks once a callback has been registered.
89pub static XML_REGISTER_CALLBACKS: core::sync::atomic::AtomicBool =
90    core::sync::atomic::AtomicBool::new(false);
91
92/// Upstream `xmlRegisterNodeCallback(node)` — invoke the registered node
93/// hook, gated by `xmlRegisterCallbacks` (tree.c).
94///
95/// # SAFETY
96///
97/// - `node` must be a valid, fully-initialised node or NULL.
98pub fn register_node_hook(node: *mut crate::abi::structs::_xmlNode) {
99    if !XML_REGISTER_CALLBACKS.load(core::sync::atomic::Ordering::Relaxed) {
100        return;
101    }
102    let hook = unsafe { xmlRegisterNodeDefaultValue };
103    if let Some(h) = hook {
104        if !node.is_null() {
105            // SAFETY: the hook is a valid C callback registered by the user.
106            unsafe { h(node) };
107        }
108    }
109}
110
111/// Upstream `xmlDeregisterNodeCallback(node)` — invoke the registered node
112/// deregister hook, gated by `xmlRegisterCallbacks` (tree.c).
113///
114/// # SAFETY
115///
116/// - `node` must be a valid node about to be freed, or NULL.
117pub fn deregister_node_hook(node: *mut crate::abi::structs::_xmlNode) {
118    if !XML_REGISTER_CALLBACKS.load(core::sync::atomic::Ordering::Relaxed) {
119        return;
120    }
121    let hook = unsafe { xmlDeregisterNodeDefaultValue };
122    if let Some(h) = hook {
123        if !node.is_null() {
124            // SAFETY: the hook is a valid C callback registered by the user.
125            unsafe { h(node) };
126        }
127    }
128}
129
130/// `xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue` (default NULL)
131#[no_mangle]
132pub static mut xmlDeregisterNodeDefaultValue: Option<
133    unsafe extern "C" fn(*mut crate::abi::structs::_xmlNode),
134> = None;
135
136/// `const char *xmlParserVersion` — matched to the system oracle build
137/// (libxml2 2.15.3 GIT build: LIBXML_VERSION_STRING "21503" plus the
138/// upstream version extra "-GITv2.15.3").
139///
140/// SAFETY: the pointed-to string is a static, immutable, null-terminated
141/// literal; `static mut` is used because C raw pointers are not `Sync`.
142/// Reads/writes of the pointer itself are racy only if C code mutates it
143/// (upstream treats it as a constant).
144#[no_mangle]
145pub static mut xmlParserVersion: *const c_char = {
146    static V: [u8; 17] = *b"21503-GITv2.15.3\0";
147    V.as_ptr() as *const c_char
148};
149
150/// `int xmlParserMaxDepth` (default 256)
151#[no_mangle]
152pub static mut xmlParserMaxDepth: c_int = 256;
153
154// ═══════════════════════════════════════════════════════════════════════════════
155// Buffer globals (upstream tree.h / xmlIO.c)
156// ═══════════════════════════════════════════════════════════════════════════════
157
158/// `int xmlDefaultBufferSize` (default 4096)
159#[no_mangle]
160pub static mut xmlDefaultBufferSize: c_int = 4096;
161
162/// `xmlBufferAllocationScheme xmlBufferAllocScheme` (default XML_BUFFER_ALLOC_EXACT = 1;
163/// upstream globals.c `xmlBufferAllocSchemeThrDef = XML_BUFFER_ALLOC_EXACT`)
164#[no_mangle]
165pub static mut xmlBufferAllocScheme: c_int = 1;
166
167// ═══════════════════════════════════════════════════════════════════════════════
168// Error callback globals (upstream xmlerror.h)
169// ═══════════════════════════════════════════════════════════════════════════════
170
171/// `xmlGenericErrorFunc xmlGenericError` — the generic error callback.
172///
173/// Upstream defaults to `xmlGenericErrorDefaultFunc` (a variadic stderr
174/// printer, error.c); the candidate's shim below reproduces it, so a
175/// freshly-initialized library routes errors to stderr exactly like upstream.
176#[cfg(target_arch = "x86_64")]
177#[no_mangle]
178pub static mut xmlGenericError: Option<xmlGenericErrorFunc> = Some(XML_GENERIC_ERROR_DEFAULT);
179
180#[cfg(not(target_arch = "x86_64"))]
181#[no_mangle]
182pub static mut xmlGenericError: Option<xmlGenericErrorFunc> = None;
183
184/// `void *xmlGenericErrorContext` — context for the generic error callback.
185#[no_mangle]
186pub static mut xmlGenericErrorContext: *mut c_void = core::ptr::null_mut();
187
188/// `xmlStructuredErrorFunc xmlStructuredError` — the structured error callback.
189#[no_mangle]
190pub static mut xmlStructuredError: Option<xmlStructuredErrorFunc> = None;
191
192/// `void *xmlStructuredErrorContext` — context for the structured callback.
193#[no_mangle]
194pub static mut xmlStructuredErrorContext: *mut c_void = core::ptr::null_mut();
195
196// ═══════════════════════════════════════════════════════════════════════════════
197// Variadic default error handlers (upstream error.c / xsltutils.c)
198// ═══════════════════════════════════════════════════════════════════════════════
199//
200// Upstream `xmlGenericErrorDefaultFunc(void *ctx, const char *msg, ...)`
201// prints the formatted message to `xmlGenericErrorContext` (stderr when
202// NULL). Stable Rust cannot define a variadic extern fn body, so the ABI
203// entry is an x86_64 SysV inline-asm shim that materialises the caller's
204// register/stack arguments into a `va_list` and forwards to a non-variadic
205// receiver — the same pattern as `xsltTransformError`
206// (exports_xslt_util.rs) and the writer's `vfmt_shim!`. Neither default
207// function is a dynamic export upstream (both are internal); the exported
208// data globals merely point at them.
209
210/// System V AMD64 `__va_list_tag` (24 bytes) — same layout as the writer's
211/// shims and `exports_xslt_util.rs`.
212#[cfg(target_arch = "x86_64")]
213#[repr(C)]
214#[derive(Clone, Copy)]
215struct VaListTag {
216    gp_offset: c_uint,
217    fp_offset: c_uint,
218    overflow_arg_area: *mut c_void,
219    reg_save_area: *mut c_void,
220}
221
222#[cfg(target_arch = "x86_64")]
223unsafe extern "C" {
224    fn vfprintf(stream: *mut c_void, format: *const c_char, ap: *mut VaListTag) -> c_int;
225}
226
227/// The `stderr` FILE* (the libc crate exposes no `stderr` value) — upstream
228/// `xmlGenericErrorDefaultFunc` defaults the error context to stderr.
229#[cfg(target_arch = "x86_64")]
230unsafe fn stderr_file() -> *mut c_void {
231    static mut STDERR_FILE: *mut c_void = core::ptr::null_mut();
232    unsafe {
233        if STDERR_FILE.is_null() {
234            STDERR_FILE = libc::fdopen(2, b"w\0".as_ptr() as *const c_char) as *mut c_void;
235        }
236        STDERR_FILE
237    }
238}
239
240/// Variadic receiver for the `xmlGenericErrorDefaultFunc` shim (upstream
241/// error.c semantics: default the context to stderr, then `vfprintf`).
242#[cfg(target_arch = "x86_64")]
243#[no_mangle]
244pub unsafe extern "C" fn xmlGenericErrorDefaultFuncV(
245    _ctx: *mut c_void,
246    msg: *const c_char,
247    ap: *mut VaListTag,
248) -> c_int {
249    unsafe {
250        if crate::abi::data_globals::xmlGenericErrorContext.is_null() {
251            crate::abi::data_globals::xmlGenericErrorContext = stderr_file();
252        }
253        let stream = crate::abi::data_globals::xmlGenericErrorContext;
254        if msg.is_null() || stream.is_null() {
255            return 0;
256        }
257        vfprintf(stream, msg, ap)
258    }
259}
260
261/// `xmlGenericErrorDefaultFunc(void *ctx, const char *msg, ...)` — the
262/// upstream default generic error handler. Not exported dynamically (matches
263/// upstream, where the symbol is internal).
264///
265/// 2 fixed args (ctx=rdi, msg=rsi) → `gp_offset` 16; the va_list pointer is
266/// passed as the 3rd arg (rdx) of the receiver.
267#[cfg(target_arch = "x86_64")]
268pub unsafe extern "C" fn xmlGenericErrorDefaultFunc() -> c_int {
269    unsafe {
270        core::arch::asm!(
271            "sub rsp, 240",
272            "mov [rsp+0], rdi",
273            "mov [rsp+8], rsi",
274            "mov [rsp+16], rdx",
275            "mov [rsp+24], rcx",
276            "mov [rsp+32], r8",
277            "mov [rsp+40], r9",
278            "movaps [rsp+48], xmm0",
279            "movaps [rsp+64], xmm1",
280            "movaps [rsp+80], xmm2",
281            "movaps [rsp+96], xmm3",
282            "movaps [rsp+112], xmm4",
283            "movaps [rsp+128], xmm5",
284            "movaps [rsp+144], xmm6",
285            "movaps [rsp+160], xmm7",
286            "mov dword ptr [rsp+176], 16",
287            "mov dword ptr [rsp+180], 48",
288            "lea rax, [rsp+256]",
289            "mov [rsp+184], rax",
290            "lea rax, [rsp]",
291            "mov [rsp+192], rax",
292            "lea rdx, [rsp+176]",
293            "call xmlGenericErrorDefaultFuncV",
294            "add rsp, 240",
295            "add rsp, 8",
296            "ret",
297            options(noreturn),
298        );
299    }
300}
301
302/// Default value of the exported `xmlGenericError` data global.
303#[cfg(target_arch = "x86_64")]
304const XML_GENERIC_ERROR_DEFAULT: xmlGenericErrorFunc = unsafe {
305    // SAFETY: the shim and the function-pointer type have identical ABI
306    // (a code pointer); the declared arity is a Rust-side fiction required
307    // to store a variadic entry in the non-variadic pointer type.
308    core::mem::transmute::<
309        unsafe extern "C" fn() -> c_int,
310        unsafe extern "C" fn(*mut c_void, *const c_char),
311    >(xmlGenericErrorDefaultFunc)
312};
313
314/// Variadic receiver for the `xsltGenericErrorDefaultFunc` shim (upstream
315/// xsltutils.c semantics: default the context to stderr, then `vfprintf`).
316#[cfg(target_arch = "x86_64")]
317#[no_mangle]
318pub unsafe extern "C" fn xsltGenericErrorDefaultFuncV(
319    _ctx: *mut c_void,
320    msg: *const c_char,
321    ap: *mut VaListTag,
322) -> c_int {
323    unsafe {
324        if crate::abi::data_globals::xsltGenericErrorContext.is_null() {
325            crate::abi::data_globals::xsltGenericErrorContext = stderr_file();
326        }
327        let stream = crate::abi::data_globals::xsltGenericErrorContext;
328        if msg.is_null() || stream.is_null() {
329            return 0;
330        }
331        vfprintf(stream, msg, ap)
332    }
333}
334
335/// `xsltGenericErrorDefaultFunc(void *ctx, const char *msg, ...)` — the
336/// upstream default XSLT error handler (xsltutils.c).
337#[cfg(target_arch = "x86_64")]
338pub unsafe extern "C" fn xsltGenericErrorDefaultFunc() -> c_int {
339    unsafe {
340        core::arch::asm!(
341            "sub rsp, 240",
342            "mov [rsp+0], rdi",
343            "mov [rsp+8], rsi",
344            "mov [rsp+16], rdx",
345            "mov [rsp+24], rcx",
346            "mov [rsp+32], r8",
347            "mov [rsp+40], r9",
348            "movaps [rsp+48], xmm0",
349            "movaps [rsp+64], xmm1",
350            "movaps [rsp+80], xmm2",
351            "movaps [rsp+96], xmm3",
352            "movaps [rsp+112], xmm4",
353            "movaps [rsp+128], xmm5",
354            "movaps [rsp+144], xmm6",
355            "movaps [rsp+160], xmm7",
356            "mov dword ptr [rsp+176], 16",
357            "mov dword ptr [rsp+180], 48",
358            "lea rax, [rsp+256]",
359            "mov [rsp+184], rax",
360            "lea rax, [rsp]",
361            "mov [rsp+192], rax",
362            "lea rdx, [rsp+176]",
363            "call xsltGenericErrorDefaultFuncV",
364            "add rsp, 240",
365            "add rsp, 8",
366            "ret",
367            options(noreturn),
368        );
369    }
370}
371
372/// Default value of the exported `xsltGenericError` data global.
373#[cfg(target_arch = "x86_64")]
374const XSLT_GENERIC_ERROR_DEFAULT: xmlGenericErrorFunc = unsafe {
375    // SAFETY: as above — ABI-identical code pointer.
376    core::mem::transmute::<
377        unsafe extern "C" fn() -> c_int,
378        unsafe extern "C" fn(*mut c_void, *const c_char),
379    >(xsltGenericErrorDefaultFunc)
380};
381
382/// The built-in default generic error handler (upstream
383/// `xmlGenericErrorDefaultFunc`), for use when a caller resets the handler
384/// with NULL. Only available on x86_64 (the variadic shim is SysV-specific);
385/// on other targets there is no default (resets leave the handler unset).
386pub fn default_generic_error_func() -> Option<xmlGenericErrorFunc> {
387    #[cfg(target_arch = "x86_64")]
388    {
389        Some(XML_GENERIC_ERROR_DEFAULT)
390    }
391    #[cfg(not(target_arch = "x86_64"))]
392    {
393        None
394    }
395}
396
397// ═══════════════════════════════════════════════════════════════════════════════
398// Static strings (upstream xmlstring.h / tree.c)
399// ═══════════════════════════════════════════════════════════════════════════════
400
401/// `const xmlChar xmlStringText[]` — "text"
402#[no_mangle]
403pub static xmlStringText: [xmlChar; 5] = [b't', b'e', b'x', b't', 0];
404
405/// `const xmlChar xmlStringTextNoenc[]` — "textnoenc"
406#[no_mangle]
407pub static xmlStringTextNoenc: [xmlChar; 9] =
408    [b't', b'e', b'x', b't', b'n', b'o', b'e', b'n', b'c'];
409
410/// `const xmlChar xmlStringComment[]` — "comment"
411#[no_mangle]
412pub static xmlStringComment: [xmlChar; 8] = [b'c', b'o', b'm', b'm', b'e', b'n', b't', 0];
413
414// ═══════════════════════════════════════════════════════════════════════════════
415// XPath numeric constants (upstream xpath.c)
416// ═══════════════════════════════════════════════════════════════════════════════
417
418/// `double xmlXPathNAN` — NaN
419#[no_mangle]
420pub static xmlXPathNAN: f64 = f64::NAN;
421
422/// `double xmlXPathPINF` — +infinity
423#[no_mangle]
424pub static xmlXPathPINF: f64 = f64::INFINITY;
425
426/// `double xmlXPathNINF` — -infinity
427#[no_mangle]
428pub static xmlXPathNINF: f64 = f64::NEG_INFINITY;
429
430// ═══════════════════════════════════════════════════════════════════════════════
431// libxslt globals (upstream xslt.c / xsltutils.c / documents.c / xslt.h)
432// ═══════════════════════════════════════════════════════════════════════════════
433// xsltMaxDepth / xsltMaxVars are exported from src/xslt/transform/mod.rs
434// (they are read by the transform engine).
435
436/// `const int xsltLibxmlVersion` = LIBXML_VERSION (21503) — the libxml2
437/// version libxslt was built against (upstream xslt.c).
438#[no_mangle]
439pub static xsltLibxmlVersion: c_int = 21503;
440
441/// `xmlGenericErrorFunc xsltGenericError` — the libxslt error callback.
442/// Upstream defaults to `xsltGenericErrorDefaultFunc` (xsltutils.c, a variadic
443/// stderr printer); the candidate's shim below reproduces it (R-000135
444/// divergence now closed).
445#[cfg(target_arch = "x86_64")]
446#[no_mangle]
447pub static mut xsltGenericError: Option<xmlGenericErrorFunc> = Some(XSLT_GENERIC_ERROR_DEFAULT);
448
449#[cfg(not(target_arch = "x86_64"))]
450#[no_mangle]
451pub static mut xsltGenericError: Option<xmlGenericErrorFunc> = None;
452
453/// `void *xsltGenericErrorContext` (default NULL)
454#[no_mangle]
455pub static mut xsltGenericErrorContext: *mut c_void = core::ptr::null_mut();
456
457/// `void *xsltGenericDebugContext` (default NULL)
458#[no_mangle]
459pub static mut xsltGenericDebugContext: *mut c_void = core::ptr::null_mut();
460
461/// `const xmlChar xsltExtMarker[]` — empty string used to mark extension
462/// nodes (upstream transform.c).
463#[no_mangle]
464pub static xsltExtMarker: [xmlChar; 1] = [0];
465
466/// `xsltDocLoaderFunc xsltDocDefaultLoader` — the document loader callback.
467/// Upstream defaults to `xsltDocDefaultLoaderFunc`; the candidate defaults
468/// to NULL and its internal loader path is used — documented safe
469/// divergence (residual R-000135).
470#[no_mangle]
471pub static mut xsltDocDefaultLoader: Option<
472    unsafe extern "C" fn(
473        *const xmlChar,
474        *mut c_void,
475        c_int,
476        *mut crate::abi::structs::_xsltStylesheet,
477        *mut crate::abi::structs::_xsltTransformContext,
478    ) -> *mut crate::abi::structs::_xmlDoc,
479> = None;
480
481// ═══════════════════════════════════════════════════════════════════════════════
482// I/O filename callback globals (upstream xmlIO.h)
483// ═══════════════════════════════════════════════════════════════════════════════
484
485/// `xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue`
486#[no_mangle]
487pub static mut xmlParserInputBufferCreateFilenameValue: Option<
488    unsafe extern "C" fn(*const c_char, c_int) -> *mut crate::abi::structs::_xmlParserInputBuffer,
489> = None;
490
491/// `xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue`
492#[no_mangle]
493pub static mut xmlOutputBufferCreateFilenameValue: Option<
494    unsafe extern "C" fn(
495        *const c_char,
496        crate::abi::structs::xmlCharEncodingHandlerPtr,
497        c_int,
498    ) -> *mut crate::abi::structs::_xmlOutputBuffer,
499> = None;
500
501// ═══════════════════════════════════════════════════════════════════════════════
502// Default SAX v1 handler structs + locator (upstream globals.c 2.15.3)
503// ═══════════════════════════════════════════════════════════════════════════════
504//
505// `const xmlSAXHandlerV1 xmlDefaultSAXHandler` and `htmlDefaultSAXHandler`
506// (parser.h / HTMLparser.h), plus `const xmlSAXLocator xmlDefaultSAXLocator`.
507// The handler instances reproduce the upstream initializer lists exactly
508// (globals.c); every referenced xmlSAX2* entry point is a real candidate
509// export.
510
511/// `const xmlSAXHandlerV1 xmlDefaultSAXHandler` (globals.c 2.15.3).
512#[no_mangle]
513pub static xmlDefaultSAXHandler: crate::abi::structs::_xmlSAXHandlerV1 =
514    crate::abi::structs::_xmlSAXHandlerV1 {
515        internalSubset: Some(crate::abi::exports_xml2::xmlSAX2InternalSubset),
516        isStandalone: Some(crate::abi::exports_xml2::xmlSAX2IsStandalone),
517        hasInternalSubset: Some(crate::abi::exports_xml2::xmlSAX2HasInternalSubset),
518        hasExternalSubset: Some(crate::abi::exports_xml2::xmlSAX2HasExternalSubset),
519        resolveEntity: Some(crate::abi::exports_xml2::xmlSAX2ResolveEntity),
520        getEntity: Some(crate::abi::exports_xml2::xmlSAX2GetEntity),
521        entityDecl: Some(crate::abi::exports_xml2::xmlSAX2EntityDecl),
522        notationDecl: Some(crate::abi::exports_xml2::xmlSAX2NotationDecl),
523        attributeDecl: Some(crate::abi::exports_xml2::xmlSAX2AttributeDecl),
524        elementDecl: Some(crate::abi::exports_xml2::xmlSAX2ElementDecl),
525        unparsedEntityDecl: Some(crate::abi::exports_xml2::xmlSAX2UnparsedEntityDecl),
526        setDocumentLocator: Some(crate::abi::exports_xml2::xmlSAX2SetDocumentLocator),
527        startDocument: Some(crate::abi::exports_xml2::xmlSAX2StartDocument),
528        endDocument: Some(crate::abi::exports_xml2::xmlSAX2EndDocument),
529        startElement: Some(crate::abi::exports_xml2::xmlSAX2StartElement),
530        endElement: Some(crate::abi::exports_xml2::xmlSAX2EndElement),
531        reference: Some(crate::abi::exports_xml2::xmlSAX2Reference),
532        characters: Some(crate::abi::exports_xml2::xmlSAX2Characters),
533        ignorableWhitespace: Some(crate::abi::exports_xml2::xmlSAX2IgnorableWhitespace),
534        processingInstruction: Some(crate::abi::exports_xml2::xmlSAX2ProcessingInstruction),
535        comment: Some(crate::abi::exports_xml2::xmlSAX2Comment),
536        warning: Some(crate::xml::errors::xmlParserWarning),
537        error: Some(crate::xml::errors::xmlParserError),
538        fatalError: Some(crate::xml::errors::xmlParserError),
539        getParameterEntity: Some(crate::abi::exports_xml2::xmlSAX2GetParameterEntity),
540        cdataBlock: Some(crate::abi::exports_xml2::xmlSAX2CDataBlock),
541        externalSubset: Some(crate::abi::exports_xml2::xmlSAX2ExternalSubset),
542        initialized: 1,
543    };
544
545/// `const xmlSAXHandlerV1 htmlDefaultSAXHandler` (globals.c 2.15.3).
546#[no_mangle]
547pub static htmlDefaultSAXHandler: crate::abi::structs::_xmlSAXHandlerV1 =
548    crate::abi::structs::_xmlSAXHandlerV1 {
549        internalSubset: Some(crate::abi::exports_xml2::xmlSAX2InternalSubset),
550        isStandalone: None,
551        hasInternalSubset: None,
552        hasExternalSubset: None,
553        resolveEntity: None,
554        getEntity: Some(crate::abi::exports_xml2::xmlSAX2GetEntity),
555        entityDecl: None,
556        notationDecl: None,
557        attributeDecl: None,
558        elementDecl: None,
559        unparsedEntityDecl: None,
560        setDocumentLocator: Some(crate::abi::exports_xml2::xmlSAX2SetDocumentLocator),
561        startDocument: Some(crate::abi::exports_xml2::xmlSAX2StartDocument),
562        endDocument: Some(crate::abi::exports_xml2::xmlSAX2EndDocument),
563        startElement: Some(crate::abi::exports_xml2::xmlSAX2StartElement),
564        endElement: Some(crate::abi::exports_xml2::xmlSAX2EndElement),
565        reference: None,
566        characters: Some(crate::abi::exports_xml2::xmlSAX2Characters),
567        ignorableWhitespace: Some(crate::abi::exports_xml2::xmlSAX2IgnorableWhitespace),
568        processingInstruction: Some(crate::abi::exports_xml2::xmlSAX2ProcessingInstruction),
569        comment: Some(crate::abi::exports_xml2::xmlSAX2Comment),
570        warning: Some(crate::xml::errors::xmlParserWarning),
571        error: Some(crate::xml::errors::xmlParserError),
572        fatalError: Some(crate::xml::errors::xmlParserError),
573        getParameterEntity: None,
574        cdataBlock: Some(crate::abi::exports_xml2::xmlSAX2CDataBlock),
575        externalSubset: None,
576        initialized: 1,
577    };
578
579/// `const xmlSAXLocator xmlDefaultSAXLocator` (globals.c 2.15.3).
580#[no_mangle]
581pub static xmlDefaultSAXLocator: crate::abi::callbacks::_xmlSAXLocator =
582    crate::abi::callbacks::_xmlSAXLocator {
583        getPublicId: Some(crate::abi::exports_xml2::xmlSAX2GetPublicId),
584        getSystemId: Some(crate::abi::exports_xml2::xmlSAX2GetSystemId),
585        getLineNumber: Some(crate::abi::exports_xml2::xmlSAX2GetLineNumber),
586        getColumnNumber: Some(crate::abi::exports_xml2::xmlSAX2GetColumnNumber),
587    };
588
589// ═══════════════════════════════════════════════════════════════════════════════
590// xmlLastError — the exported C global mirror of the thread-local error state
591// ═══════════════════════════════════════════════════════════════════════════════
592//
593// Upstream `XMLPUBVAR xmlError xmlLastError` (xmlerror.h). The candidate's
594// internal error state is thread-local (safe divergence, more correct than
595// upstream's racy global); this mirror is deep-copied on every error raise
596// and freed on reset, so C consumers observe upstream-equivalent lifetime
597// semantics. Residual R-000135.
598
599/// `xmlError xmlLastError` — most recent error (mirror).
600#[no_mangle]
601pub static mut xmlLastError: crate::abi::structs::_xmlError = crate::abi::structs::_xmlError {
602    domain: 0,
603    code: 0,
604    message: core::ptr::null_mut(),
605    level: 0,
606    file: core::ptr::null_mut(),
607    line: 0,
608    str1: core::ptr::null_mut(),
609    str2: core::ptr::null_mut(),
610    str3: core::ptr::null_mut(),
611    int1: 0,
612    int2: 0,
613    ctxt: core::ptr::null_mut(),
614    node: core::ptr::null_mut(),
615};
616
617/// Deep-copy `err` into the exported `xmlLastError` global.
618///
619/// The string fields are copied with `libc::malloc`/`memcpy` so the mirror
620/// owns them (previous mirror strings are freed first — upstream
621/// xmlResetError semantics).
622///
623/// # SAFETY
624///
625/// - `err` must point to a valid `_xmlError` whose string fields are
626///   NUL-terminated or NULL.
627pub unsafe fn sync_xml_last_error(err: *const crate::abi::structs::_xmlError) {
628    if err.is_null() {
629        return;
630    }
631    unsafe {
632        reset_xml_last_error();
633        let src = &*err;
634        let dst = core::ptr::addr_of_mut!(xmlLastError);
635        (*dst).domain = src.domain;
636        (*dst).code = src.code;
637        (*dst).level = src.level;
638        (*dst).line = src.line;
639        (*dst).int1 = src.int1;
640        (*dst).int2 = src.int2;
641        (*dst).ctxt = src.ctxt;
642        (*dst).node = src.node;
643        (*dst).message = dup_cstr(src.message as *const u8);
644        (*dst).file = dup_cstr(src.file as *const u8);
645        (*dst).str1 = dup_cstr(src.str1 as *const u8);
646        (*dst).str2 = dup_cstr(src.str2 as *const u8);
647        (*dst).str3 = dup_cstr(src.str3 as *const u8);
648    }
649}
650
651/// Reset the exported `xmlLastError` global, freeing owned strings
652/// (upstream xmlResetError).
653///
654/// # SAFETY
655///
656/// Only call while no other thread is reading the global (upstream has the
657/// same race; documented).
658pub unsafe fn reset_xml_last_error() {
659    unsafe {
660        let dst = core::ptr::addr_of_mut!(xmlLastError);
661        if !(*dst).message.is_null() {
662            libc::free((*dst).message as *mut libc::c_void);
663        }
664        if !(*dst).file.is_null() {
665            libc::free((*dst).file as *mut libc::c_void);
666        }
667        if !(*dst).str1.is_null() {
668            libc::free((*dst).str1 as *mut libc::c_void);
669        }
670        if !(*dst).str2.is_null() {
671            libc::free((*dst).str2 as *mut libc::c_void);
672        }
673        if !(*dst).str3.is_null() {
674            libc::free((*dst).str3 as *mut libc::c_void);
675        }
676        *dst = crate::abi::structs::_xmlError {
677            domain: 0,
678            code: 0,
679            message: core::ptr::null_mut(),
680            level: 0,
681            file: core::ptr::null_mut(),
682            line: 0,
683            str1: core::ptr::null_mut(),
684            str2: core::ptr::null_mut(),
685            str3: core::ptr::null_mut(),
686            int1: 0,
687            int2: 0,
688            ctxt: core::ptr::null_mut(),
689            node: core::ptr::null_mut(),
690        };
691    }
692}
693
694/// Heap-copy a NUL-terminated string (NULL-safe).
695unsafe fn dup_cstr(s: *const u8) -> *mut c_char {
696    if s.is_null() {
697        return core::ptr::null_mut();
698    }
699    unsafe {
700        let len = libc::strlen(s as *const libc::c_char) as usize;
701        let p = libc::malloc(len + 1) as *mut u8;
702        if p.is_null() {
703            return core::ptr::null_mut();
704        }
705        libc::memcpy(p as *mut libc::c_void, s as *const libc::c_void, len + 1);
706        p as *mut c_char
707    }
708}
709
710// ═══════════════════════════════════════════════════════════════════════════════
711// Default accessor functions (upstream parser.h / tree.h / xmlsave.h)
712// ═══════════════════════════════════════════════════════════════════════════════
713//
714// The deprecated `xmlXxxDefault(v)` accessors set the corresponding global
715// when `v != 0` and return the (new) value — upstream semantics (they
716// predate the plain globals; the modern behavior is conditional-set-and-
717// return, see upstream globals.c / parser.c).
718
719/// Upstream `xmlKeepBlanksDefault(int v)`.
720#[no_mangle]
721pub unsafe extern "C" fn xmlKeepBlanksDefault(v: c_int) -> c_int {
722    unsafe {
723        if v != 0 {
724            xmlKeepBlanksDefaultValue = v;
725        }
726        xmlKeepBlanksDefaultValue
727    }
728}
729
730/// Upstream `xmlLineNumbersDefault(int v)`.
731#[no_mangle]
732pub unsafe extern "C" fn xmlLineNumbersDefault(v: c_int) -> c_int {
733    unsafe {
734        if v != 0 {
735            xmlLineNumbersDefaultValue = v;
736        }
737        xmlLineNumbersDefaultValue
738    }
739}
740
741/// Upstream `xmlSubstituteEntitiesDefault(int v)`.
742#[no_mangle]
743pub unsafe extern "C" fn xmlSubstituteEntitiesDefault(v: c_int) -> c_int {
744    unsafe {
745        if v != 0 {
746            xmlSubstituteEntitiesDefaultValue = v;
747        }
748        xmlSubstituteEntitiesDefaultValue
749    }
750}
751
752/// Upstream `xmlPedanticParserDefault(int v)`.
753#[no_mangle]
754pub unsafe extern "C" fn xmlPedanticParserDefault(v: c_int) -> c_int {
755    unsafe {
756        if v != 0 {
757            xmlPedanticParserDefaultValue = v;
758        }
759        xmlPedanticParserDefaultValue
760    }
761}
762
763/// Upstream `xmlDoValidityCheckingDefaultValue` accessor is the global
764/// itself; `xmlGetWarningsDefaultValue` likewise (no accessor functions
765/// exist for those in upstream 2.15).
766
767/// Upstream `xmlRegisterNodeDefault(xmlRegisterNodeFunc func)`.
768#[no_mangle]
769pub unsafe extern "C" fn xmlRegisterNodeDefault(
770    func: Option<unsafe extern "C" fn(*mut crate::abi::structs::_xmlNode)>,
771) -> Option<unsafe extern "C" fn(*mut crate::abi::structs::_xmlNode)> {
772    unsafe {
773        // UPSTREAM-PARITY (tree.c): registering any callback arms the
774        // xmlRegisterCallbacks gate.
775        XML_REGISTER_CALLBACKS.store(true, core::sync::atomic::Ordering::Relaxed);
776        if func.is_some() {
777            xmlRegisterNodeDefaultValue = func;
778        }
779        xmlRegisterNodeDefaultValue
780    }
781}
782
783/// Upstream `xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)`.
784#[no_mangle]
785pub unsafe extern "C" fn xmlDeregisterNodeDefault(
786    func: Option<unsafe extern "C" fn(*mut crate::abi::structs::_xmlNode)>,
787) -> Option<unsafe extern "C" fn(*mut crate::abi::structs::_xmlNode)> {
788    unsafe {
789        // UPSTREAM-PARITY (tree.c): registering any callback arms the
790        // xmlRegisterCallbacks gate.
791        XML_REGISTER_CALLBACKS.store(true, core::sync::atomic::Ordering::Relaxed);
792        if func.is_some() {
793            xmlDeregisterNodeDefaultValue = func;
794        }
795        xmlDeregisterNodeDefaultValue
796    }
797}
798
799/// Upstream `__xmlIndentTreeOutput(void)` (parser.h) — returns a pointer to
800/// the `xmlIndentTreeOutput` global.
801#[no_mangle]
802pub unsafe extern "C" fn __xmlIndentTreeOutput() -> *mut c_int {
803    unsafe { core::ptr::addr_of_mut!(xmlIndentTreeOutput) }
804}
805
806/// Upstream `__xmlSaveNoEmptyTags(void)` (parser.h) — returns a pointer to
807/// the `xmlSaveNoEmptyTags` global.
808#[no_mangle]
809pub unsafe extern "C" fn __xmlSaveNoEmptyTags() -> *mut c_int {
810    unsafe { core::ptr::addr_of_mut!(xmlSaveNoEmptyTags) }
811}
812
813/// Upstream `__xmlTreeIndentString(void)` (parser.h) — returns a pointer to
814/// the `xmlTreeIndentString` global.
815#[no_mangle]
816pub unsafe extern "C" fn __xmlTreeIndentString() -> *mut *const xmlChar {
817    unsafe { core::ptr::addr_of_mut!(xmlTreeIndentString) }
818}
819
820// ═══════════════════════════════════════════════════════════════════════════════
821// xmlThrDef* accessors (upstream threads.c / globals.c)
822// ═══════════════════════════════════════════════════════════════════════════════
823//
824// The deprecated `xmlThrDef*` family reads/writes the public globals with
825// the upstream semantics: when `v != 0` the global is set, and the (new)
826// value is returned. In upstream these were thread-local definitions before
827// the globals became plain variables; the modern behavior is exactly this
828// conditional-set-and-return on the global (see upstream globals.c).
829
830/// Upstream `xmlThrDefDoValidityCheckingDefaultValue(int v)`.
831#[no_mangle]
832pub unsafe extern "C" fn xmlThrDefDoValidityCheckingDefaultValue(v: c_int) -> c_int {
833    unsafe {
834        if v != 0 {
835            xmlDoValidityCheckingDefaultValue = v;
836        }
837        xmlDoValidityCheckingDefaultValue
838    }
839}
840
841/// Upstream `xmlThrDefGetWarningsDefaultValue(int v)`.
842#[no_mangle]
843pub unsafe extern "C" fn xmlThrDefGetWarningsDefaultValue(v: c_int) -> c_int {
844    unsafe {
845        if v != 0 {
846            xmlGetWarningsDefaultValue = v;
847        }
848        xmlGetWarningsDefaultValue
849    }
850}
851
852/// Upstream `xmlThrDefLoadExtDtdDefaultValue(int v)`.
853#[no_mangle]
854pub unsafe extern "C" fn xmlThrDefLoadExtDtdDefaultValue(v: c_int) -> c_int {
855    unsafe {
856        if v != 0 {
857            xmlLoadExtDtdDefaultValue = v;
858        }
859        xmlLoadExtDtdDefaultValue
860    }
861}
862
863/// Upstream `xmlThrDefPedanticParserDefaultValue(int v)`.
864#[no_mangle]
865pub unsafe extern "C" fn xmlThrDefPedanticParserDefaultValue(v: c_int) -> c_int {
866    unsafe {
867        if v != 0 {
868            xmlPedanticParserDefaultValue = v;
869        }
870        xmlPedanticParserDefaultValue
871    }
872}
873
874/// Upstream `xmlThrDefLineNumbersDefaultValue(int v)`.
875#[no_mangle]
876pub unsafe extern "C" fn xmlThrDefLineNumbersDefaultValue(v: c_int) -> c_int {
877    unsafe {
878        if v != 0 {
879            xmlLineNumbersDefaultValue = v;
880        }
881        xmlLineNumbersDefaultValue
882    }
883}
884
885/// Upstream `xmlThrDefKeepBlanksDefaultValue(int v)`.
886#[no_mangle]
887pub unsafe extern "C" fn xmlThrDefKeepBlanksDefaultValue(v: c_int) -> c_int {
888    unsafe {
889        if v != 0 {
890            xmlKeepBlanksDefaultValue = v;
891        }
892        xmlKeepBlanksDefaultValue
893    }
894}
895
896/// Upstream `xmlThrDefSubstituteEntitiesDefaultValue(int v)`.
897#[no_mangle]
898pub unsafe extern "C" fn xmlThrDefSubstituteEntitiesDefaultValue(v: c_int) -> c_int {
899    unsafe {
900        if v != 0 {
901            xmlSubstituteEntitiesDefaultValue = v;
902        }
903        xmlSubstituteEntitiesDefaultValue
904    }
905}
906
907/// Upstream `xmlThrDefParserDebugEntities(int v)`.
908#[no_mangle]
909pub unsafe extern "C" fn xmlThrDefParserDebugEntities(v: c_int) -> c_int {
910    unsafe {
911        if v != 0 {
912            xmlParserDebugEntities = v;
913        }
914        xmlParserDebugEntities
915    }
916}
917
918/// Upstream `xmlThrDefIndentTreeOutput(int v)`.
919#[no_mangle]
920pub unsafe extern "C" fn xmlThrDefIndentTreeOutput(v: c_int) -> c_int {
921    unsafe {
922        if v != 0 {
923            xmlIndentTreeOutput = v;
924        }
925        xmlIndentTreeOutput
926    }
927}
928
929/// Upstream `xmlThrDefTreeIndentString(const char *v)` — sets the indent
930/// string when non-NULL and returns the current pointer.
931#[no_mangle]
932pub unsafe extern "C" fn xmlThrDefTreeIndentString(v: *const c_char) -> *const c_char {
933    unsafe {
934        if !v.is_null() {
935            xmlTreeIndentString = v as *const xmlChar;
936        }
937        xmlTreeIndentString as *const c_char
938    }
939}
940
941/// Upstream `xmlThrDefSaveNoEmptyTags(int v)`.
942#[no_mangle]
943pub unsafe extern "C" fn xmlThrDefSaveNoEmptyTags(v: c_int) -> c_int {
944    unsafe {
945        if v != 0 {
946            xmlSaveNoEmptyTags = v;
947        }
948        xmlSaveNoEmptyTags
949    }
950}
951
952/// Upstream `xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)`.
953#[no_mangle]
954pub unsafe extern "C" fn xmlThrDefRegisterNodeDefault(
955    func: Option<unsafe extern "C" fn(*mut crate::abi::structs::_xmlNode)>,
956) -> Option<unsafe extern "C" fn(*mut crate::abi::structs::_xmlNode)> {
957    unsafe {
958        if func.is_some() {
959            xmlRegisterNodeDefaultValue = func;
960        }
961        xmlRegisterNodeDefaultValue
962    }
963}
964
965/// Upstream `xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)`.
966#[no_mangle]
967pub unsafe extern "C" fn xmlThrDefDeregisterNodeDefault(
968    func: Option<unsafe extern "C" fn(*mut crate::abi::structs::_xmlNode)>,
969) -> Option<unsafe extern "C" fn(*mut crate::abi::structs::_xmlNode)> {
970    unsafe {
971        if func.is_some() {
972            xmlDeregisterNodeDefaultValue = func;
973        }
974        xmlDeregisterNodeDefaultValue
975    }
976}
977
978/// Upstream `xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc func)`.
979#[no_mangle]
980pub unsafe extern "C" fn xmlThrDefSetGenericErrorFunc(
981    ctx: *mut c_void,
982    func: Option<xmlGenericErrorFunc>,
983) {
984    unsafe {
985        xmlGenericErrorContext = ctx;
986        xmlGenericError = func;
987    }
988}
989
990/// Upstream `xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc func)`.
991#[no_mangle]
992pub unsafe extern "C" fn xmlThrDefSetStructuredErrorFunc(
993    ctx: *mut c_void,
994    func: Option<xmlStructuredErrorFunc>,
995) {
996    unsafe {
997        xmlStructuredErrorContext = ctx;
998        xmlStructuredError = func;
999    }
1000}
1001
1002/// Upstream `xmlThrDefDefaultBufferSize(int v)`.
1003#[no_mangle]
1004pub unsafe extern "C" fn xmlThrDefDefaultBufferSize(v: c_int) -> c_int {
1005    unsafe {
1006        if v != 0 {
1007            xmlDefaultBufferSize = v;
1008        }
1009        xmlDefaultBufferSize
1010    }
1011}
1012
1013/// Upstream `xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v)`.
1014#[no_mangle]
1015pub unsafe extern "C" fn xmlThrDefBufferAllocScheme(v: c_int) -> c_int {
1016    unsafe {
1017        if v != 0 {
1018            xmlBufferAllocScheme = v;
1019        }
1020        xmlBufferAllocScheme
1021    }
1022}
1023
1024/// Upstream `xmlThrDefParserInputBufferCreateFilenameDefault(...)`.
1025#[no_mangle]
1026pub unsafe extern "C" fn xmlThrDefParserInputBufferCreateFilenameDefault(
1027    func: Option<
1028        unsafe extern "C" fn(
1029            *const c_char,
1030            c_int,
1031        ) -> *mut crate::abi::structs::_xmlParserInputBuffer,
1032    >,
1033) -> Option<
1034    unsafe extern "C" fn(*const c_char, c_int) -> *mut crate::abi::structs::_xmlParserInputBuffer,
1035> {
1036    unsafe {
1037        if func.is_some() {
1038            xmlParserInputBufferCreateFilenameValue = func;
1039        }
1040        xmlParserInputBufferCreateFilenameValue
1041    }
1042}
1043
1044/// Upstream `xmlThrDefOutputBufferCreateFilenameDefault(...)`.
1045#[no_mangle]
1046pub unsafe extern "C" fn xmlThrDefOutputBufferCreateFilenameDefault(
1047    func: Option<
1048        unsafe extern "C" fn(
1049            *const c_char,
1050            crate::abi::structs::xmlCharEncodingHandlerPtr,
1051            c_int,
1052        ) -> *mut crate::abi::structs::_xmlOutputBuffer,
1053    >,
1054) -> Option<
1055    unsafe extern "C" fn(
1056        *const c_char,
1057        crate::abi::structs::xmlCharEncodingHandlerPtr,
1058        c_int,
1059    ) -> *mut crate::abi::structs::_xmlOutputBuffer,
1060> {
1061    unsafe {
1062        if func.is_some() {
1063            xmlOutputBufferCreateFilenameValue = func;
1064        }
1065        xmlOutputBufferCreateFilenameValue
1066    }
1067}
1068
1069// ═══════════════════════════════════════════════════════════════════════════════
1070// __xmlXxx() pointer accessors (upstream threads.c / globals.c)
1071// ═══════════════════════════════════════════════════════════════════════════════
1072// The deprecated thread-local API exports one `__xmlXxx(void)` accessor per
1073// global; each returns a pointer to the global so callers can read/write it.
1074
1075/// Upstream `__xmlBufferAllocScheme(void)` — returns a pointer to `xmlBufferAllocScheme`.
1076#[no_mangle]
1077pub unsafe extern "C" fn __xmlBufferAllocScheme() -> *mut c_int {
1078    // SAFETY: returning a pointer to an exported static; the caller may
1079    // read/write it exactly as with upstream's deprecated accessor.
1080    unsafe { core::ptr::addr_of_mut!(xmlBufferAllocScheme) }
1081}
1082
1083/// Upstream `__xmlDefaultBufferSize(void)` — returns a pointer to `xmlDefaultBufferSize`.
1084#[no_mangle]
1085pub unsafe extern "C" fn __xmlDefaultBufferSize() -> *mut c_int {
1086    // SAFETY: returning a pointer to an exported static; the caller may
1087    // read/write it exactly as with upstream's deprecated accessor.
1088    unsafe { core::ptr::addr_of_mut!(xmlDefaultBufferSize) }
1089}
1090
1091/// Upstream `__xmlDeregisterNodeDefaultValue(void)` — returns a pointer to `xmlDeregisterNodeDefaultValue`.
1092#[no_mangle]
1093pub unsafe extern "C" fn __xmlDeregisterNodeDefaultValue(
1094) -> *mut Option<unsafe extern "C" fn(*mut crate::abi::structs::_xmlNode)> {
1095    // SAFETY: returning a pointer to an exported static; the caller may
1096    // read/write it exactly as with upstream's deprecated accessor.
1097    unsafe { core::ptr::addr_of_mut!(xmlDeregisterNodeDefaultValue) }
1098}
1099
1100/// Upstream `__xmlDoValidityCheckingDefaultValue(void)` — returns a pointer to `xmlDoValidityCheckingDefaultValue`.
1101#[no_mangle]
1102pub unsafe extern "C" fn __xmlDoValidityCheckingDefaultValue() -> *mut c_int {
1103    // SAFETY: returning a pointer to an exported static; the caller may
1104    // read/write it exactly as with upstream's deprecated accessor.
1105    unsafe { core::ptr::addr_of_mut!(xmlDoValidityCheckingDefaultValue) }
1106}
1107
1108/// Upstream `__xmlGenericError(void)` — returns a pointer to `xmlGenericError`.
1109#[no_mangle]
1110pub unsafe extern "C" fn __xmlGenericError() -> *mut Option<xmlGenericErrorFunc> {
1111    // SAFETY: returning a pointer to an exported static; the caller may
1112    // read/write it exactly as with upstream's deprecated accessor.
1113    unsafe { core::ptr::addr_of_mut!(xmlGenericError) }
1114}
1115
1116/// Upstream `__xmlGenericErrorContext(void)` — returns a pointer to `xmlGenericErrorContext`.
1117#[no_mangle]
1118pub unsafe extern "C" fn __xmlGenericErrorContext() -> *mut *mut c_void {
1119    // SAFETY: returning a pointer to an exported static; the caller may
1120    // read/write it exactly as with upstream's deprecated accessor.
1121    unsafe { core::ptr::addr_of_mut!(xmlGenericErrorContext) }
1122}
1123
1124/// Upstream `__xmlGetWarningsDefaultValue(void)` — returns a pointer to `xmlGetWarningsDefaultValue`.
1125#[no_mangle]
1126pub unsafe extern "C" fn __xmlGetWarningsDefaultValue() -> *mut c_int {
1127    // SAFETY: returning a pointer to an exported static; the caller may
1128    // read/write it exactly as with upstream's deprecated accessor.
1129    unsafe { core::ptr::addr_of_mut!(xmlGetWarningsDefaultValue) }
1130}
1131
1132/// Upstream `__xmlKeepBlanksDefaultValue(void)` — returns a pointer to `xmlKeepBlanksDefaultValue`.
1133#[no_mangle]
1134pub unsafe extern "C" fn __xmlKeepBlanksDefaultValue() -> *mut c_int {
1135    // SAFETY: returning a pointer to an exported static; the caller may
1136    // read/write it exactly as with upstream's deprecated accessor.
1137    unsafe { core::ptr::addr_of_mut!(xmlKeepBlanksDefaultValue) }
1138}
1139
1140/// Upstream `__xmlLineNumbersDefaultValue(void)` — returns a pointer to `xmlLineNumbersDefaultValue`.
1141#[no_mangle]
1142pub unsafe extern "C" fn __xmlLineNumbersDefaultValue() -> *mut c_int {
1143    // SAFETY: returning a pointer to an exported static; the caller may
1144    // read/write it exactly as with upstream's deprecated accessor.
1145    unsafe { core::ptr::addr_of_mut!(xmlLineNumbersDefaultValue) }
1146}
1147
1148/// Upstream `__xmlLoadExtDtdDefaultValue(void)` — returns a pointer to `xmlLoadExtDtdDefaultValue`.
1149#[no_mangle]
1150pub unsafe extern "C" fn __xmlLoadExtDtdDefaultValue() -> *mut c_int {
1151    // SAFETY: returning a pointer to an exported static; the caller may
1152    // read/write it exactly as with upstream's deprecated accessor.
1153    unsafe { core::ptr::addr_of_mut!(xmlLoadExtDtdDefaultValue) }
1154}
1155
1156/// Upstream `__xmlOutputBufferCreateFilenameValue(void)` — returns a pointer to `xmlOutputBufferCreateFilenameValue`.
1157#[no_mangle]
1158pub unsafe extern "C" fn __xmlOutputBufferCreateFilenameValue() -> *mut Option<
1159    unsafe extern "C" fn(
1160        *const c_char,
1161        crate::abi::structs::xmlCharEncodingHandlerPtr,
1162        c_int,
1163    ) -> *mut crate::abi::structs::_xmlOutputBuffer,
1164> {
1165    // SAFETY: returning a pointer to an exported static; the caller may
1166    // read/write it exactly as with upstream's deprecated accessor.
1167    unsafe { core::ptr::addr_of_mut!(xmlOutputBufferCreateFilenameValue) }
1168}
1169
1170/// Upstream `__xmlParserDebugEntities(void)` — returns a pointer to `xmlParserDebugEntities`.
1171#[no_mangle]
1172pub unsafe extern "C" fn __xmlParserDebugEntities() -> *mut c_int {
1173    // SAFETY: returning a pointer to an exported static; the caller may
1174    // read/write it exactly as with upstream's deprecated accessor.
1175    unsafe { core::ptr::addr_of_mut!(xmlParserDebugEntities) }
1176}
1177
1178/// Upstream `__xmlParserInputBufferCreateFilenameValue(void)` — returns a pointer to `xmlParserInputBufferCreateFilenameValue`.
1179#[no_mangle]
1180pub unsafe extern "C" fn __xmlParserInputBufferCreateFilenameValue() -> *mut Option<
1181    unsafe extern "C" fn(*const c_char, c_int) -> *mut crate::abi::structs::_xmlParserInputBuffer,
1182> {
1183    // SAFETY: returning a pointer to an exported static; the caller may
1184    // read/write it exactly as with upstream's deprecated accessor.
1185    unsafe { core::ptr::addr_of_mut!(xmlParserInputBufferCreateFilenameValue) }
1186}
1187
1188/// Upstream `__xmlParserVersion(void)` — returns a pointer to `xmlParserVersion`.
1189#[no_mangle]
1190pub unsafe extern "C" fn __xmlParserVersion() -> *mut *const c_char {
1191    // SAFETY: returning a pointer to an exported static; the caller may
1192    // read/write it exactly as with upstream's deprecated accessor.
1193    unsafe { core::ptr::addr_of_mut!(xmlParserVersion) }
1194}
1195
1196/// Upstream `__xmlPedanticParserDefaultValue(void)` — returns a pointer to `xmlPedanticParserDefaultValue`.
1197#[no_mangle]
1198pub unsafe extern "C" fn __xmlPedanticParserDefaultValue() -> *mut c_int {
1199    // SAFETY: returning a pointer to an exported static; the caller may
1200    // read/write it exactly as with upstream's deprecated accessor.
1201    unsafe { core::ptr::addr_of_mut!(xmlPedanticParserDefaultValue) }
1202}
1203
1204/// Upstream `__xmlRegisterNodeDefaultValue(void)` — returns a pointer to `xmlRegisterNodeDefaultValue`.
1205#[no_mangle]
1206pub unsafe extern "C" fn __xmlRegisterNodeDefaultValue(
1207) -> *mut Option<unsafe extern "C" fn(*mut crate::abi::structs::_xmlNode)> {
1208    // SAFETY: returning a pointer to an exported static; the caller may
1209    // read/write it exactly as with upstream's deprecated accessor.
1210    unsafe { core::ptr::addr_of_mut!(xmlRegisterNodeDefaultValue) }
1211}
1212
1213/// Upstream `__xmlStructuredError(void)` — returns a pointer to `xmlStructuredError`.
1214#[no_mangle]
1215pub unsafe extern "C" fn __xmlStructuredError() -> *mut Option<xmlStructuredErrorFunc> {
1216    // SAFETY: returning a pointer to an exported static; the caller may
1217    // read/write it exactly as with upstream's deprecated accessor.
1218    unsafe { core::ptr::addr_of_mut!(xmlStructuredError) }
1219}
1220
1221/// Upstream `__xmlStructuredErrorContext(void)` — returns a pointer to `xmlStructuredErrorContext`.
1222#[no_mangle]
1223pub unsafe extern "C" fn __xmlStructuredErrorContext() -> *mut *mut c_void {
1224    // SAFETY: returning a pointer to an exported static; the caller may
1225    // read/write it exactly as with upstream's deprecated accessor.
1226    unsafe { core::ptr::addr_of_mut!(xmlStructuredErrorContext) }
1227}
1228
1229/// Upstream `__xmlSubstituteEntitiesDefaultValue(void)` — returns a pointer to `xmlSubstituteEntitiesDefaultValue`.
1230#[no_mangle]
1231pub unsafe extern "C" fn __xmlSubstituteEntitiesDefaultValue() -> *mut c_int {
1232    // SAFETY: returning a pointer to an exported static; the caller may
1233    // read/write it exactly as with upstream's deprecated accessor.
1234    unsafe { core::ptr::addr_of_mut!(xmlSubstituteEntitiesDefaultValue) }
1235}