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