libxml_rs/abi/callbacks.rs
1//! C ABI callback function type definitions — matching upstream callback signatures (§14, §20).
2//!
3//! This module defines all function pointer types used in public upstream structures:
4//! SAX1 callbacks, SAX2 callbacks, error callbacks, validity callbacks, XPath callbacks,
5//! I/O callbacks, resource loader callbacks, encoding callbacks, and the SAX locator.
6//!
7//! # Phase 1 status
8//!
9//! Complete — all callback types from upstream headers are defined.
10//!
11//! # Safety
12//!
13//! All callback types are `unsafe extern "C"` because they are called across the FFI boundary
14//! with C calling conventions. The caller must ensure:
15//! - Function pointers are non-null before invocation (unless nullable per upstream contract)
16//! - Pointers passed to callbacks remain valid for the callback's duration
17//! - Callbacks observe the upstream ownership/lifetime contract
18//! - Thread safety matches upstream expectations
19//!
20//! # Upstream contract
21//!
22//! The parity target is libxml2 2.15.3 (`SRC-LIBXML2-2.15.0-SAX2-C`:
23//! `oracle/historical/src/libxml2-2.15.0/SAX2.c` and `globals.c`). Every `pub
24//! type` here mirrors an upstream `typedef` verbatim so the function-pointer
25//! fields of the `#[repr(C)]` struct mirrors in `structs.rs` line up
26//! byte-for-byte.
27//!
28//! # Conceptual behavior
29//!
30//! This module implements the callback surface of the public headers: SAX1
31//! handlers, SAX2 namespace-aware handlers, error/structured-error callbacks,
32//! validity callbacks, XPath extension callbacks, I/O read/write/close
33//! callbacks, the resource-loader and encoding-conversion callbacks, and the
34//! SAX locator. The callback types are the contract — they define what a C
35//! consumer may register and what the candidate must invoke.
36//!
37//! # Ownership & safety invariants
38//!
39//! Callback user-data pointers are stored and returned verbatim; the caller
40//! keeps them alive and frees them after deregistration, and the candidate
41//! never dereferences user-data (OWNERSHIP_ATLAS section 6). Pointers passed
42//! to callbacks remain valid for the callbacks duration. These typedefs are
43//! `unsafe extern C` because they are invoked across the FFI boundary with
44//! C calling conventions.
45//!
46//! # Historical quirks & epochs
47//!
48//! R-000130 (11.1-G): `xmlResourceLoader` and `xmlCharEncConvImpl` had
49//! non-upstream signatures (the loader used 4 args where upstream parser.h
50//! declares 5 with an `xmlParserInput**` out-param) and were fixed to the
51//! upstream signatures. R-000129 (11.1-G): the `_xmlCharEncodingHandler`
52//! layout mismatch (48 vs 56 bytes) was fixed alongside the encoding
53//! callbacks. Since the 2.5 `sax2` epoch (HISTORY.md) the namespace-aware
54//! SAX2 callbacks are the default parser path.
55//!
56//! # Deliberate oddities
57//!
58//! The two R-000130 callback typedefs are ABI-exact but never invoked by the
59//! candidate (the internal engine does not use C resource loaders or
60//! encoding-conversion impls) — a deliberate parity-only surface: their only
61//! purpose is that downstream code compiling against the headers links and
62//! sees the upstream layout.
63//!
64//! # Proving courts
65//!
66//! The ABI-DATA, ALLOCATOR, GLOBAL-STATE and THREADING court families
67//! exercise this surface; the CALLBACK-001 probe
68//! (`courts/suites/data-abi/callback-family-probe.c`) requires byte-identical
69//! output against the oracle DSO, and the RUST-MIRROR-ABI court measures the
70//! struct mirrors that embed these typedefs.
71//!
72//! # Tempting simplifications that would break parity
73//!
74//! A tempting simplification is to drop the unused-but-ABI-exact callbacks
75//! (R-000130) or to let a Rust `fn` signature substitute for the upstream
76//! typedef — that would change the C header layout downstream code compiles
77//! against and break the CALLBACK-001 / RUST-MIRROR-ABI courts, which must
78//! not be allowed to pass on a smaller surface than the oracle exports.
79
80#![allow(non_camel_case_types)]
81
82use core::ffi::c_void;
83use std::os::raw::{c_char, c_int, c_uchar};
84
85use crate::abi::structs::*;
86
87// ═══════════════════════════════════════════════════════════════════════════════
88// SAX1 Callbacks (xmlSAXHandler)
89// ═══════════════════════════════════════════════════════════════════════════════
90
91/// Callback for internal DTD subset notification.
92///
93/// # UPSTREAM-PARITY
94///
95/// Oracle behavior: Called when `<!DOCTYPE ... [ ... ]>` internal subset is parsed.
96/// Parameters are the DOCTYPE name, external ID (or NULL), system ID (or NULL).
97pub type internalSubsetSAXFunc = unsafe extern "C" fn(
98 ctx: *mut c_void,
99 name: *const crate::abi::types::xmlChar,
100 ExternalID: *const crate::abi::types::xmlChar,
101 SystemID: *const crate::abi::types::xmlChar,
102);
103
104/// Callback for standalone document declaration.
105///
106/// Returns 1 if standalone="yes", 0 if standalone="no", -1 if not declared.
107pub type isStandaloneSAXFunc = unsafe extern "C" fn(ctx: *mut c_void) -> c_int;
108
109/// Callback: does the document have an internal subset?
110pub type hasInternalSubsetSAXFunc = unsafe extern "C" fn(ctx: *mut c_void) -> c_int;
111
112/// Callback: does the document have an external subset?
113pub type hasExternalSubsetSAXFunc = unsafe extern "C" fn(ctx: *mut c_void) -> c_int;
114
115/// Callback to resolve an external entity.
116///
117/// Returns a newly allocated `xmlParserInputPtr` or NULL.
118///
119/// # UPSTREAM-PARITY
120///
121/// Ownership: The returned `xmlParserInputPtr` is owned by the parser context.
122pub type resolveEntitySAXFunc = unsafe extern "C" fn(
123 ctx: *mut c_void,
124 publicId: *const crate::abi::types::xmlChar,
125 systemId: *const crate::abi::types::xmlChar,
126) -> *mut _xmlParserInput;
127
128/// Callback to get an entity.
129///
130/// Returns a pointer to an entity or NULL.
131///
132/// # UPSTREAM-PARITY
133///
134/// Ownership: The returned entity is owned by the document's entity table.
135/// The caller must not free it.
136pub type getEntitySAXFunc = unsafe extern "C" fn(
137 ctx: *mut c_void,
138 name: *const crate::abi::types::xmlChar,
139) -> *mut _xmlEntity;
140
141/// Callback for entity declaration.
142pub type entityDeclSAXFunc = unsafe extern "C" fn(
143 ctx: *mut c_void,
144 name: *const crate::abi::types::xmlChar,
145 type_: c_int,
146 publicId: *const crate::abi::types::xmlChar,
147 systemId: *const crate::abi::types::xmlChar,
148 content: *mut crate::abi::types::xmlChar,
149);
150
151/// Callback for notation declaration.
152pub type notationDeclSAXFunc = unsafe extern "C" fn(
153 ctx: *mut c_void,
154 name: *const crate::abi::types::xmlChar,
155 publicId: *const crate::abi::types::xmlChar,
156 systemId: *const crate::abi::types::xmlChar,
157);
158
159/// Callback for attribute declaration.
160pub type attributeDeclSAXFunc = unsafe extern "C" fn(
161 ctx: *mut c_void,
162 elem: *const crate::abi::types::xmlChar,
163 name: *const crate::abi::types::xmlChar,
164 type_: c_int,
165 def: c_int,
166 defaultValue: *const crate::abi::types::xmlChar,
167 tree: *mut _xmlEnumeration,
168);
169
170/// Callback for element declaration.
171pub type elementDeclSAXFunc = unsafe extern "C" fn(
172 ctx: *mut c_void,
173 name: *const crate::abi::types::xmlChar,
174 type_: c_int,
175 content: *mut _xmlElementContent,
176);
177
178/// Callback for unparsed entity declaration.
179pub type unparsedEntityDeclSAXFunc = unsafe extern "C" fn(
180 ctx: *mut c_void,
181 name: *const crate::abi::types::xmlChar,
182 publicId: *const crate::abi::types::xmlChar,
183 systemId: *const crate::abi::types::xmlChar,
184 notationName: *const crate::abi::types::xmlChar,
185);
186
187/// Callback to set the document locator.
188///
189/// # UPSTREAM-PARITY
190///
191/// The locator is an opaque structure that provides line/column information.
192pub type setDocumentLocatorSAXFunc =
193 unsafe extern "C" fn(ctx: *mut c_void, loc: *mut _xmlSAXLocator);
194
195/// Callback for document start.
196pub type startDocumentSAXFunc = unsafe extern "C" fn(ctx: *mut c_void);
197
198/// Callback for document end.
199pub type endDocumentSAXFunc = unsafe extern "C" fn(ctx: *mut c_void);
200
201/// Callback for element start (SAX1).
202///
203/// # Parameters
204/// - `name`: element name
205/// - `atts`: NULL-terminated array of [name, value, name, value, ..., NULL]
206pub type startElementSAXFunc = unsafe extern "C" fn(
207 ctx: *mut c_void,
208 name: *const crate::abi::types::xmlChar,
209 atts: *mut *const crate::abi::types::xmlChar,
210);
211
212/// Callback for element end (SAX1).
213pub type endElementSAXFunc =
214 unsafe extern "C" fn(ctx: *mut c_void, name: *const crate::abi::types::xmlChar);
215
216/// Callback for entity reference.
217pub type referenceSAXFunc =
218 unsafe extern "C" fn(ctx: *mut c_void, name: *const crate::abi::types::xmlChar);
219
220/// Callback for character data.
221pub type charactersSAXFunc =
222 unsafe extern "C" fn(ctx: *mut c_void, ch: *const crate::abi::types::xmlChar, len: c_int);
223
224/// Callback for ignorable whitespace.
225pub type ignorableWhitespaceSAXFunc =
226 unsafe extern "C" fn(ctx: *mut c_void, ch: *const crate::abi::types::xmlChar, len: c_int);
227
228/// Callback for processing instructions.
229pub type processingInstructionSAXFunc = unsafe extern "C" fn(
230 ctx: *mut c_void,
231 target: *const crate::abi::types::xmlChar,
232 data: *const crate::abi::types::xmlChar,
233);
234
235/// Callback for comments.
236pub type commentSAXFunc =
237 unsafe extern "C" fn(ctx: *mut c_void, value: *const crate::abi::types::xmlChar);
238
239/// Callback for warnings (printf-style, variadic at C call site).
240///
241/// # UPSTREAM-PARITY
242///
243/// The `...` is implicit in C; Rust type cannot express variadic extern "C"
244/// on stable. The function pointer ABI is identical — C callers pass variadic
245/// arguments and the callee uses va_list internally.
246pub type warningSAXFunc = unsafe extern "C" fn(ctx: *mut c_void, msg: *const c_char);
247
248/// Callback for errors (printf-style, variadic at C call site).
249pub type errorSAXFunc = unsafe extern "C" fn(ctx: *mut c_void, msg: *const c_char);
250
251/// Callback for fatal errors (printf-style, variadic at C call site).
252pub type fatalErrorSAXFunc = unsafe extern "C" fn(ctx: *mut c_void, msg: *const c_char);
253
254/// Callback to get a parameter entity.
255///
256/// Returns a pointer to a parameter entity or NULL.
257pub type getParameterEntitySAXFunc = unsafe extern "C" fn(
258 ctx: *mut c_void,
259 name: *const crate::abi::types::xmlChar,
260) -> *mut _xmlEntity;
261
262/// Callback for CDATA block.
263pub type cdataBlockSAXFunc =
264 unsafe extern "C" fn(ctx: *mut c_void, value: *const crate::abi::types::xmlChar, len: c_int);
265
266/// Callback for external subset notification.
267pub type externalSubsetSAXFunc = unsafe extern "C" fn(
268 ctx: *mut c_void,
269 name: *const crate::abi::types::xmlChar,
270 ExternalID: *const crate::abi::types::xmlChar,
271 SystemID: *const crate::abi::types::xmlChar,
272);
273
274/// Callback for initializing the SAX handler.
275///
276/// # UPSTREAM-PARITY
277///
278/// This is a libxml2-internal callback used to set SAX2 callbacks when SAX1 callbacks
279/// are not provided. Not typically set by downstream users.
280pub type initSAXFunc = unsafe extern "C" fn(ctx: *mut c_void, handler: *mut _xmlSAXHandler);
281
282// ═══════════════════════════════════════════════════════════════════════════════
283// SAX2 Callbacks
284// ═══════════════════════════════════════════════════════════════════════════════
285
286/// Callback for element start (SAX2/namespaced).
287///
288/// # Parameters
289/// - `localname`: element local name
290/// - `prefix`: element namespace prefix (or NULL)
291/// - `URI`: element namespace URI (or NULL)
292/// - `nb_namespaces`: number of namespace declarations
293/// - `namespaces`: array of [prefix, URI, prefix, URI, ...] (size 2*nb_namespaces)
294/// - `nb_attributes`: total number of attributes
295/// - `nb_defaulted`: number of defaulted attributes (from DTD)
296/// - `attributes`: array of [localname, prefix, URI, value, value_end, ...]
297/// each attribute is 5 entries, value_end is pointer past last char of value
298pub type startElementNsSAX2Func = unsafe extern "C" fn(
299 ctx: *mut c_void,
300 localname: *const crate::abi::types::xmlChar,
301 prefix: *const crate::abi::types::xmlChar,
302 URI: *const crate::abi::types::xmlChar,
303 nb_namespaces: c_int,
304 namespaces: *mut *const crate::abi::types::xmlChar,
305 nb_attributes: c_int,
306 nb_defaulted: c_int,
307 attributes: *mut *const crate::abi::types::xmlChar,
308);
309
310/// Callback for element end (SAX2/namespaced).
311pub type endElementNsSAX2Func = unsafe extern "C" fn(
312 ctx: *mut c_void,
313 localname: *const crate::abi::types::xmlChar,
314 prefix: *const crate::abi::types::xmlChar,
315 URI: *const crate::abi::types::xmlChar,
316);
317
318// ═══════════════════════════════════════════════════════════════════════════════
319// SAX Locator
320// ═══════════════════════════════════════════════════════════════════════════════
321
322/// The SAX locator structure providing line/column information.
323///
324/// # UPSTREAM-PARITY
325///
326/// This is an opaque structure from the perspective of SAX handlers.
327/// Upstream defines it as:
328/// ```c
329/// typedef struct _xmlSAXLocator xmlSAXLocator;
330/// typedef xmlSAXLocator *xmlSAXLocatorPtr;
331/// struct _xmlSAXLocator {
332/// xmlChar *(*getPublicId)(void *ctx);
333/// xmlChar *(*getSystemId)(void *ctx);
334/// int (*getLineNumber)(void *ctx);
335/// int (*getColumnNumber)(void *ctx);
336/// };
337/// ```
338#[derive(Debug)]
339#[repr(C)]
340pub struct _xmlSAXLocator {
341 /// Get the public ID of the current document position.
342 pub getPublicId:
343 Option<unsafe extern "C" fn(ctx: *mut c_void) -> *const crate::abi::types::xmlChar>,
344 /// Get the system ID of the current document position.
345 pub getSystemId:
346 Option<unsafe extern "C" fn(ctx: *mut c_void) -> *const crate::abi::types::xmlChar>,
347 /// Get the line number of the current document position.
348 pub getLineNumber: Option<unsafe extern "C" fn(ctx: *mut c_void) -> c_int>,
349 /// Get the column number of the current document position.
350 pub getColumnNumber: Option<unsafe extern "C" fn(ctx: *mut c_void) -> c_int>,
351}
352
353/// Pointer to a SAX locator.
354pub type xmlSAXLocatorPtr = *mut _xmlSAXLocator;
355
356// ═══════════════════════════════════════════════════════════════════════════════
357// Error Callbacks
358// ═══════════════════════════════════════════════════════════════════════════════
359
360/// Structured error handler callback.
361///
362/// Called with a pointer to the error structure. The error structure is valid
363/// only during the callback invocation.
364pub type xmlStructuredErrorFunc = unsafe extern "C" fn(ctx: *mut c_void, error: *const _xmlError);
365
366/// Generic error handler callback (printf-style, variadic at C call site).
367///
368/// # UPSTREAM-PARITY
369///
370/// This is the older error reporting mechanism. New code should use the structured
371/// error handler (`xmlStructuredErrorFunc`) instead.
372pub type xmlGenericErrorFunc = unsafe extern "C" fn(ctx: *mut c_void, msg: *const c_char);
373
374// ═══════════════════════════════════════════════════════════════════════════════
375// Validity Callbacks
376// ═══════════════════════════════════════════════════════════════════════════════
377
378/// Validity error handler callback (printf-style, variadic at C call site).
379pub type xmlValidityErrorFunc = unsafe extern "C" fn(ctx: *mut c_void, msg: *const c_char);
380
381/// Validity warning handler callback (printf-style, variadic at C call site).
382pub type xmlValidityWarningFunc = unsafe extern "C" fn(ctx: *mut c_void, msg: *const c_char);
383
384// ═══════════════════════════════════════════════════════════════════════════════
385// I/O Callbacks
386// ═══════════════════════════════════════════════════════════════════════════════
387
388/// Read callback for custom input.
389///
390/// Should fill `buffer` with up to `len` bytes.
391/// Returns the number of bytes read, 0 on EOF, or -1 on error.
392pub type xmlInputReadCallback =
393 unsafe extern "C" fn(context: *mut c_void, buffer: *mut c_char, len: c_int) -> c_int;
394
395/// Close callback for custom input.
396///
397/// Returns 0 on success, -1 on error.
398pub type xmlInputCloseCallback = unsafe extern "C" fn(context: *mut c_void) -> c_int;
399
400/// Write callback for custom output.
401///
402/// Should write up to `len` bytes from `buffer`.
403/// Returns the number of bytes written, or -1 on error.
404pub type xmlOutputWriteCallback =
405 unsafe extern "C" fn(context: *mut c_void, buffer: *const c_char, len: c_int) -> c_int;
406
407/// Close callback for custom output.
408///
409/// Returns 0 on success, -1 on error.
410pub type xmlOutputCloseCallback = unsafe extern "C" fn(context: *mut c_void) -> c_int;
411
412/// Progress callback for incremental regex execution (upstream xmlregexp.h).
413///
414/// ```c
415/// typedef void (*xmlRegExecCallbacks)(xmlRegExecCtxtPtr exec,
416/// const xmlChar *token,
417/// void *transdata, void *inputdata);
418/// ```
419///
420/// Invoked by the automata when a transition with attached data fires; the
421/// candidate's NFA engine retains the callback for ABI parity but does not
422/// currently invoke it (no transition-data concept — documented divergence,
423/// residual R-000176).
424pub type xmlRegExecCallbacks = unsafe extern "C" fn(
425 exec: *mut c_void,
426 token: *const crate::abi::types::xmlChar,
427 transdata: *mut c_void,
428 inputdata: *mut c_void,
429);
430
431/// Visibility callback for `xmlC14NExecute` (upstream c14n.h).
432///
433/// ```c
434/// typedef int (*xmlC14NIsVisibleCallback)(void *user_data, xmlNode *node,
435/// xmlNode *parent);
436/// ```
437///
438/// Returns non-zero when `node` must be included in the canonical output.
439pub type xmlC14NIsVisibleCallback = unsafe extern "C" fn(
440 user_data: *mut c_void,
441 node: *mut crate::abi::structs::_xmlNode,
442 parent: *mut crate::abi::structs::_xmlNode,
443) -> c_int;
444
445// ═══════════════════════════════════════════════════════════════════════════════
446// XPath Callbacks
447// ═══════════════════════════════════════════════════════════════════════════════
448
449/// Variable lookup function for XPath.
450///
451/// Returns an `xmlXPathObjectPtr` representing the variable's value, or NULL.
452///
453/// # UPSTREAM-PARITY
454///
455/// Ownership: The returned object is owned by the caller (must be freed).
456pub type xmlXPathVariableLookupFunc = unsafe extern "C" fn(
457 ctxt: *mut c_void,
458 name: *const crate::abi::types::xmlChar,
459 ns_uri: *const crate::abi::types::xmlChar,
460) -> *mut _xmlXPathObject;
461
462/// Function lookup function for XPath extensions.
463///
464/// Returns a function pointer or NULL.
465pub type xmlXPathFuncLookupFunc = unsafe extern "C" fn(
466 ctxt: *mut c_void,
467 name: *const crate::abi::types::xmlChar,
468 ns_uri: *const crate::abi::types::xmlChar,
469) -> *mut c_void;
470
471// ═══════════════════════════════════════════════════════════════════════════════
472// Resource Loader Callbacks
473// ═══════════════════════════════════════════════════════════════════════════════
474
475/// Resource loader callback.
476///
477/// Loads a resource identified by `url` and returns a parser input.
478///
479/// # UPSTREAM-PARITY
480///
481/// Declared in upstream `parser.h` (2.15+):
482///
483/// ```c
484/// typedef xmlParserErrors
485/// (*xmlResourceLoader)(void *ctxt, const char *url, const char *publicId,
486/// xmlResourceType type, xmlParserInputFlags flags,
487/// xmlParserInput **out);
488/// ```
489///
490/// Note: a different, older `void *(*)(const char*, const char*, int, void*)`
491/// signature appears in very old libxml2 headers; the 2.15 contract wins.
492pub type xmlResourceLoader = unsafe extern "C" fn(
493 ctxt: *mut c_void,
494 url: *const c_char,
495 publicId: *const c_char,
496 type_: c_int, // xmlResourceType
497 flags: c_int, // xmlParserInputFlags
498 out: *mut *mut _xmlParserInput,
499) -> c_int; // xmlParserErrors
500
501// ═══════════════════════════════════════════════════════════════════════════════
502// Encoding Callbacks
503// ═══════════════════════════════════════════════════════════════════════════════
504
505/// Character encoding input conversion function.
506///
507/// Converts from the handler's input encoding to UTF-8.
508/// `in` and `inlen` describe input; `out` and `outlen` describe output buffer.
509/// Returns the number of bytes written, or -1 on error.
510pub type xmlCharEncodingInputFunc = unsafe extern "C" fn(
511 out: *mut c_uchar,
512 outlen: *mut c_int,
513 in_: *const c_uchar,
514 inlen: *mut c_int,
515) -> c_int;
516
517/// Modern character encoding conversion function (upstream encoding.h).
518///
519/// ```c
520/// typedef xmlCharEncError
521/// (*xmlCharEncConvFunc)(void *vctxt, unsigned char *out, int *outlen,
522/// const unsigned char *in, int *inlen, int flush);
523/// ```
524pub type xmlCharEncConvFunc = unsafe extern "C" fn(
525 vctxt: *mut c_void,
526 out: *mut c_uchar,
527 outlen: *mut c_int,
528 in_: *const c_uchar,
529 inlen: *mut c_int,
530 flush: c_int,
531) -> c_int; // xmlCharEncError
532
533/// Conversion-context destructor (upstream encoding.h).
534///
535/// ```c
536/// typedef void (*xmlCharEncConvCtxtDtor)(void *vctxt);
537/// ```
538pub type xmlCharEncConvCtxtDtor = unsafe extern "C" fn(vctxt: *mut c_void);
539
540/// Character encoding output conversion function.
541///
542/// Converts from UTF-8 to the handler's output encoding.
543/// `in` and `inlen` describe input; `out` and `outlen` describe output buffer.
544/// Returns the number of bytes written, or -1 on error.
545pub type xmlCharEncodingOutputFunc = unsafe extern "C" fn(
546 out: *mut c_uchar,
547 outlen: *mut c_int,
548 in_: *const c_uchar,
549 inlen: *mut c_int,
550) -> c_int;
551
552/// Character encoding conversion implementation.
553///
554/// # UPSTREAM-PARITY
555///
556/// Declared in upstream `encoding.h` (2.15+):
557///
558/// ```c
559/// typedef xmlParserErrors
560/// (*xmlCharEncConvImpl)(void *vctxt, const char *name, xmlCharEncFlags flags,
561/// xmlCharEncodingHandler **out);
562/// ```
563///
564/// Returns an xmlParserErrors code; `out` receives a new handler on success.
565pub type xmlCharEncConvImpl = unsafe extern "C" fn(
566 vctxt: *mut c_void,
567 name: *const c_char,
568 flags: c_int, // xmlCharEncFlags
569 out: *mut *mut crate::abi::structs::_xmlCharEncodingHandler,
570) -> c_int; // xmlParserErrors
571
572// ═══════════════════════════════════════════════════════════════════════════════
573// Catalog Callbacks
574// ═══════════════════════════════════════════════════════════════════════════════
575
576/// Catalog preference callback.
577///
578/// Returns 1 if the system prefers XML catalogs, 0 otherwise.
579pub type xmlCatalogPreferFunc = unsafe extern "C" fn() -> c_int;
580
581// ═══════════════════════════════════════════════════════════════════════════════
582// Allocator Callback Types
583// ═══════════════════════════════════════════════════════════════════════════════
584
585/// Free function type for allocator hooks.
586pub type xmlFreeFunc = unsafe extern "C" fn(ptr: *mut c_void);
587
588/// Malloc function type for allocator hooks.
589pub type xmlMallocFunc = unsafe extern "C" fn(size: usize) -> *mut c_void;
590
591/// Realloc function type for allocator hooks.
592pub type xmlReallocFunc = unsafe extern "C" fn(ptr: *mut c_void, size: usize) -> *mut c_void;
593
594/// Strdup function type for allocator hooks.
595pub type xmlStrdupFunc = unsafe extern "C" fn(str: *const c_char) -> *mut c_void;
596
597// ═══════════════════════════════════════════════════════════════════════════════
598// Module Callbacks
599// ═══════════════════════════════════════════════════════════════════════════════
600
601/// Module register/unregister callback.
602pub type xmlModuleRegisterFunc = unsafe extern "C" fn(module: *mut c_void) -> c_int;
603
604// ═══════════════════════════════════════════════════════════════════════════════
605// Pattern Callbacks
606// ═══════════════════════════════════════════════════════════════════════════════
607
608/// Stream callback for pattern matching.
609pub type xmlStreamCtxtPtr = *mut c_void;
610
611// ═══════════════════════════════════════════════════════════════════════════════
612// Hash Table Callbacks
613// ═══════════════════════════════════════════════════════════════════════════════
614
615/// Deallocator function for hash table entries.
616///
617/// Called when removing an entry from a hash table.
618/// The function receives the payload and the name (key) of the entry.
619pub type xmlHashDeallocator =
620 unsafe extern "C" fn(payload: *mut c_void, name: *mut crate::abi::types::xmlChar);
621
622/// Copier function for hash table entries.
623///
624/// Called when copying a hash table. Returns a copy of the payload.
625pub type xmlHashCopier = unsafe extern "C" fn(
626 payload: *mut c_void,
627 name: *const crate::abi::types::xmlChar,
628) -> *mut c_void;
629
630/// Scanner function for hash table entries.
631///
632/// Called for each entry during xmlHashScan.
633pub type xmlHashScanner = unsafe extern "C" fn(
634 payload: *mut c_void,
635 data: *mut c_void,
636 name: *const crate::abi::types::xmlChar,
637);
638
639/// Full scanner function for hash table entries.
640///
641/// Called for each entry during xmlHashScanFull. Includes all three key parts.
642pub type xmlHashScannerFull = unsafe extern "C" fn(
643 payload: *mut c_void,
644 data: *mut c_void,
645 name: *const crate::abi::types::xmlChar,
646 name2: *const crate::abi::types::xmlChar,
647 name3: *const crate::abi::types::xmlChar,
648);