Skip to main content

libxml_rs/abi/
structs.rs

1//! C ABI struct definitions — exact upstream layout (§14, §17).
2//!
3//! Every struct in this module is laid out to match the corresponding
4//! upstream C struct byte-for-byte on the target platform.
5//!
6//! # Upstream structs
7//!
8//! All structs derived from SRC-LIBXML2-2.15.3-TREE-H and related headers.
9//! See the sub-agent extraction output for complete field-level archaeology.
10//!
11//! # Safety
12//!
13//! These structs are `#[repr(C)]` and may be passed across the FFI boundary.
14//! Fields marked `_deprecated_*` or `_unused_*` are retained for ABI
15//! compatibility even when the upstream has deprecated them.
16//!
17//! # Phase 1 status
18//!
19//! All core tree structs, error struct, parser context, SAX handler,
20//! XPath context/object, and I/O structs are defined.
21//!
22//! # ABI verification
23//!
24//! Each struct must be verified with `offsetof`/`sizeof` probes compiled
25//! from upstream headers. See courts/abi-struct-*.json for receipts.
26
27use crate::abi::callbacks::*;
28use crate::abi::types::*;
29use std::os::raw::{c_char, c_int, c_long, c_uint, c_ulong, c_ushort, c_void};
30
31// ── Forward declarations ────────────────────────────────────────────────
32//
33// These are the internal struct tags. In C, these are typedef'd to
34// pointer types. We define them as opaque handles or full structs
35// depending on whether the struct is public or opaque.
36
37// Opaque types (defined in .c files, not exposed in headers):
38//   _xmlDict, _xmlHashTable, _xmlList, _xmlRegexp, _xmlCatalog,
39//   _xmlXPathCompExpr, _xmlAutomata, _xmlPattern
40
41// ── xmlBuffer ───────────────────────────────────────────────────────────
42//
43// Source: tree.h lines 109-126
44
45/// Buffer structure. Deprecated in favor of xmlBuf.
46#[repr(C)]
47pub struct _xmlBuffer {
48    pub content: *mut xmlChar,   // The buffer content UTF8 (deprecated)
49    pub use_: c_uint,            // The buffer size used (deprecated)
50    pub size: c_uint,            // The buffer size (deprecated)
51    pub alloc: c_int,            // The realloc method (deprecated)
52    pub contentIO: *mut xmlChar, // In IO mode may have different base (deprecated)
53}
54
55// ── xmlNotation ─────────────────────────────────────────────────────────
56//
57// Source: tree.h lines 297-305
58
59/// Notation declaration.
60#[repr(C)]
61pub struct _xmlNotation {
62    pub name: *const xmlChar,     // Notation name
63    pub PublicID: *const xmlChar, // Public identifier, if any
64    pub SystemID: *const xmlChar, // System identifier, if any
65}
66
67// ── xmlEnumeration ──────────────────────────────────────────────────────
68//
69// Source: tree.h lines 341-345
70
71/// Enumeration value for attribute declarations.
72#[repr(C)]
73pub struct _xmlEnumeration {
74    pub next: *mut _xmlEnumeration, // Next in enumeration (deprecated)
75    pub name: *const xmlChar,       // Enumeration value
76}
77
78// ── xmlAttribute (declaration) ──────────────────────────────────────────
79//
80// Source: tree.h lines 357-391
81// NOTE: This is the ATTRIBUTE DECLARATION struct, not attribute node.
82// Attribute node is _xmlAttr below.
83
84/// Attribute declaration from DTD.
85#[repr(C)]
86pub struct _xmlAttribute {
87    pub _private: *mut c_void,   // Application data
88    pub type_: c_int,            // XML_ATTRIBUTE_DECL
89    pub name: *const xmlChar,    // Attribute name
90    pub children: *mut _xmlNode, // NULL
91    pub last: *mut _xmlNode,     // NULL
92    pub parent: *mut _xmlDtd,    // DTD
93    pub next: *mut _xmlNode,     // Next sibling
94    pub prev: *mut _xmlNode,     // Previous sibling
95    pub doc: *mut _xmlDoc,       // Containing document
96
97    pub nexth: *mut _xmlAttribute,  // Next in hash table
98    pub atype: c_int,               // Attribute type
99    pub def: c_int,                 // Attribute default
100    pub defaultValue: *mut xmlChar, // Default value
101    pub tree: *mut _xmlEnumeration, // Enumeration tree (deprecated)
102    pub prefix: *const xmlChar,     // Namespace prefix
103    pub elem: *const xmlChar,       // Element name
104}
105
106// ── xmlElementContent ───────────────────────────────────────────────────
107//
108// Source: tree.h lines 423-438
109
110/// Element content model.
111#[repr(C)]
112pub struct _xmlElementContent {
113    pub type_: c_int,                    // PCDATA, ELEMENT, SEQ or OR (deprecated)
114    pub ocur: c_int,                     // ONCE, OPT, MULT or PLUS (deprecated)
115    pub name: *const xmlChar,            // Element name (deprecated)
116    pub c1: *mut _xmlElementContent,     // First child (deprecated)
117    pub c2: *mut _xmlElementContent,     // Second child (deprecated)
118    pub parent: *mut _xmlElementContent, // Parent (deprecated)
119    pub prefix: *const xmlChar,          // Namespace prefix (deprecated)
120}
121
122// ── xmlElement (declaration) ────────────────────────────────────────────
123//
124// Source: tree.h lines 447-474
125
126/// Element declaration from DTD.
127#[repr(C)]
128pub struct _xmlElement {
129    pub name: *const xmlChar,             // Element name
130    pub type_: c_int,                     // xmlElementTypeVal
131    pub content: *mut _xmlElementContent, // Content model
132    pub attributes: *mut _xmlAttribute,   // Linked list of attribute declarations
133    pub prefix: *const xmlChar,           // Namespace prefix
134    pub next: *mut _xmlElement,           // Next in hash chain
135    pub _private: c_int,                  // Application data
136}
137
138// ── xmlNs ───────────────────────────────────────────────────────────────
139//
140// Source: tree.h lines 501-512
141
142/// Namespace declaration or XPath namespace node.
143#[repr(C)]
144pub struct _xmlNs {
145    pub next: *mut _xmlNs,      // Next namespace
146    pub type_: c_int,           // XML_NAMESPACE_DECL
147    pub href: *const xmlChar,   // Namespace URI
148    pub prefix: *const xmlChar, // Namespace prefix
149    pub _private: *mut c_void,  // Application data
150    pub context: *mut _xmlDoc,  // Normally an xmlDoc (deprecated)
151}
152
153// ── xmlDtd ──────────────────────────────────────────────────────────────
154//
155// Source: tree.h lines 538-564
156
157/// DTD (Document Type Definition).
158#[repr(C)]
159pub struct _xmlDtd {
160    pub _private: *mut c_void,   // Application data
161    pub type_: c_int,            // XML_DTD_NODE
162    pub name: *const xmlChar,    // Name of the DTD
163    pub children: *mut _xmlNode, // First child
164    pub last: *mut _xmlNode,     // Last child
165    pub parent: *mut _xmlDoc,    // Parent node (document)
166    pub next: *mut _xmlNode,     // Next sibling
167    pub prev: *mut _xmlNode,     // Previous sibling
168    pub doc: *mut _xmlDoc,       // Containing document
169    // End of common part
170    pub notations: *mut c_void,   // Hash table for notations
171    pub elements: *mut c_void,    // Hash table for elements
172    pub attributes: *mut c_void,  // Hash table for attributes
173    pub entities: *mut c_void,    // Hash table for entities
174    pub ExternalID: *mut xmlChar, // Public identifier
175    pub SystemID: *mut xmlChar,   // System identifier
176    pub pentities: *mut c_void,   // Hash table for parameter entities
177}
178
179// ── xmlAttr ─────────────────────────────────────────────────────────────
180//
181// Source: tree.h lines 595-615
182
183/// Attribute node.
184#[repr(C)]
185pub struct _xmlAttr {
186    pub _private: *mut c_void,   // Application data
187    pub type_: c_int,            // XML_ATTRIBUTE_NODE
188    pub name: *const xmlChar,    // Local name
189    pub children: *mut _xmlNode, // First child (text value)
190    pub last: *mut _xmlNode,     // Last child
191    pub parent: *mut _xmlNode,   // Parent node
192    pub next: *mut _xmlAttr,     // Next sibling (attribute)
193    pub prev: *mut _xmlAttr,     // Previous sibling (attribute)
194    pub doc: *mut _xmlDoc,       // Containing document
195    pub ns: *mut _xmlNs,         // Namespace if any
196    pub atype: c_int,            // Attribute type
197    pub psvi: *mut c_void,       // Type/PSVI information
198    pub id: *mut c_void,         // ID struct (deprecated)
199}
200
201// ── xmlNode ─────────────────────────────────────────────────────────────
202//
203// Source: tree.h lines 645-688
204
205/// XML node — the core tree structure.
206#[repr(C)]
207pub struct _xmlNode {
208    pub _private: *mut c_void,   // Application data
209    pub type_: c_int,            // Type enum
210    pub name: *const xmlChar,    // Node name
211    pub children: *mut _xmlNode, // First child
212    pub last: *mut _xmlNode,     // Last child
213    pub parent: *mut _xmlNode,   // Parent node (NULL for documents)
214    pub next: *mut _xmlNode,     // Next sibling
215    pub prev: *mut _xmlNode,     // Previous sibling
216    pub doc: *mut _xmlDoc,       // Associated document
217    // End of common part
218    pub ns: *mut _xmlNs,           // Namespace of element
219    pub content: *mut xmlChar,     // Content (text/comment/PI)
220    pub properties: *mut _xmlAttr, // First attribute of element
221    pub nsDef: *mut _xmlNs,        // First namespace definition
222    pub psvi: *mut c_void,         // Type/PSVI information
223    pub line: c_ushort,            // Line number
224    pub extra: c_ushort,           // Extra data for XPath/XSLT
225}
226
227// ── xmlDoc ──────────────────────────────────────────────────────────────
228//
229// Source: tree.h lines 787-845
230
231/// XML Document.
232#[repr(C)]
233pub struct _xmlDoc {
234    pub _private: *mut c_void,   // Application data
235    pub type_: c_int,            // XML_DOCUMENT_NODE or XML_HTML_DOCUMENT_NODE
236    pub name: *mut c_char,       // NULL
237    pub children: *mut _xmlNode, // First child (root element)
238    pub last: *mut _xmlNode,     // Last child
239    pub parent: *mut _xmlNode,   // Parent node
240    pub next: *mut _xmlNode,     // Next sibling
241    pub prev: *mut _xmlNode,     // Previous sibling
242    pub doc: *mut _xmlDoc,       // Reference to itself
243    // End of common part
244    pub compression: c_int,      // Level of zlib compression
245    pub standalone: c_int,       // Standalone document status
246    pub intSubset: *mut _xmlDtd, // Internal subset
247    pub extSubset: *mut _xmlDtd, // External subset
248    pub oldNs: *mut _xmlNs,      // Old namespace (used during parsing)
249    pub version: *mut xmlChar,   // Version string from XML declaration
250    pub encoding: *mut xmlChar,  // Actual encoding
251    pub ids: *mut c_void,        // Hash table for ID attributes
252    pub refs: *mut c_void,       // Hash table for IDREFs (deprecated)
253    pub URL: *mut xmlChar,       // URI of the document
254    pub charset: c_int,          // Unused (encoding indicator)
255    pub dict: *mut c_void,       // Dictionary for names (opaque _xmlDict)
256    pub psvi: *mut c_void,       // Type/PSVI information
257    pub parseFlags: c_int,       // Parser options used
258    pub properties: c_int,       // Document properties flags
259}
260
261// ── xmlEntity ───────────────────────────────────────────────────────────
262//
263// Source: entities.h lines 42-74
264
265/// Entity declaration.
266#[repr(C)]
267pub struct _xmlEntity {
268    pub _private: *mut c_void,      // Application data
269    pub type_: c_int,               // XML_ENTITY_DECL (must be second!)
270    pub name: *const xmlChar,       // Entity name
271    pub children: *mut _xmlNode,    // First child link
272    pub last: *mut _xmlNode,        // Last child link
273    pub parent: *mut _xmlDtd,       // -> DTD
274    pub next: *mut _xmlNode,        // Next sibling link
275    pub prev: *mut _xmlNode,        // Previous sibling link
276    pub doc: *mut _xmlDoc,          // The containing document
277    pub orig: *mut xmlChar,         // Content without ref substitution
278    pub content: *mut xmlChar,      // Content or ndata if unparsed
279    pub length: c_int,              // The content length
280    pub etype: c_int,               // The entity type
281    pub ExternalID: *const xmlChar, // External identifier for PUBLIC
282    pub SystemID: *const xmlChar,   // URI for SYSTEM or PUBLIC Entity
283    pub nexte: *mut _xmlEntity,     // Unused
284    pub URI: *const xmlChar,        // The full URI as computed
285    pub owner: c_int,               // Unused
286    pub flags: c_int,               // Various flags
287    pub expandedSize: c_ulong,      // Expanded size
288}
289
290// ── xmlError ────────────────────────────────────────────────────────────
291//
292// Source: xmlerror.h
293
294/// Structured error information.
295#[repr(C)]
296pub struct _xmlError {
297    pub domain: c_int,        // Error domain
298    pub code: c_int,          // Error code
299    pub message: *mut c_char, // Human-readable error message
300    pub level: c_int,         // Error level
301    pub file: *mut c_char,    // Filename if available
302    pub line: c_int,          // Line number if available
303    pub str1: *mut c_char,    // Extra string information
304    pub str2: *mut c_char,    // Extra string information
305    pub str3: *mut c_char,    // Extra string information
306    pub int1: c_int,          // Extra number information
307    pub int2: c_int,          // Column number if available
308    pub ctxt: *mut c_void,    // Parser context if available
309    pub node: *mut c_void,    // Node if available
310}
311
312// ── xmlParserInput ──────────────────────────────────────────────────────
313//
314// Source: parser.h
315
316/// Parser input stream.
317#[repr(C)]
318pub struct _xmlParserInput {
319    pub buf: *mut _xmlParserInputBuffer, // Input buffer (deprecated)
320    pub filename: *const c_char,         // The filename or URI (deprecated)
321    pub directory: *const c_char,        // Unused (deprecated)
322    pub base: *const xmlChar,            // Base of the array to parse
323    pub cur: *const xmlChar,             // Current char being parsed (deprecated)
324    pub end: *const xmlChar,             // End of the array to parse
325    pub length: c_int,                   // Unused (deprecated)
326    pub line: c_int,                     // Current line (deprecated)
327    pub col: c_int,                      // Current column (deprecated)
328    pub consumed: c_ulong,               // How many xmlChars consumed (deprecated)
329    pub free: Option<unsafe extern "C" fn(*mut c_char)>, // Deallocation func (deprecated)
330    pub encoding: *const xmlChar,        // Unused (deprecated)
331    pub version: *const xmlChar,         // The version string for entity (deprecated)
332    pub flags: c_int,                    // Flags (deprecated)
333    pub id: c_int,                       // Unique identifier (deprecated)
334    pub parentConsumed: c_ulong,         // Unused (deprecated)
335    pub entity: *mut _xmlEntity,         // Entity if any (deprecated)
336}
337
338// ── xmlParserInputBuffer ────────────────────────────────────────────────
339//
340// Source: xmlIO.h
341
342/// Parser input buffer.
343#[repr(C)]
344pub struct _xmlParserInputBuffer {
345    pub context: *mut c_void,                         // (deprecated)
346    pub readcallback: Option<xmlInputReadCallback>,   // (deprecated)
347    pub closecallback: Option<xmlInputCloseCallback>, // (deprecated)
348    pub encoder: *mut c_void,                         // I18N converter (deprecated)
349    pub buffer: *mut c_void,                          // Local buffer (deprecated)
350    pub raw: *mut c_void,                             // Raw input buffer (deprecated)
351    pub compressed: c_int,                            // Compression flag (deprecated)
352    pub error: c_int,                                 // (deprecated)
353    pub rawconsumed: c_ulong,                         // (deprecated)
354}
355
356// ── xmlOutputBuffer ─────────────────────────────────────────────────────
357//
358// Source: xmlIO.h
359
360/// Output buffer.
361#[repr(C)]
362pub struct _xmlOutputBuffer {
363    pub context: *mut c_void,                          // (deprecated)
364    pub writecallback: Option<xmlOutputWriteCallback>, // (deprecated)
365    pub closecallback: Option<xmlOutputCloseCallback>, // (deprecated)
366    pub encoder: *mut c_void,                          // I18N converter
367    pub buffer: *mut c_void,                           // Local buffer
368    pub conv: *mut c_void,                             // Output conversion buffer
369    pub written: c_int,                                // Total bytes written
370    pub error: c_int,                                  // Error flag
371}
372
373// ── xmlCharEncodingHandler ───────────────────────────────────────────────
374//
375// Source: encoding.h
376
377/// Character encoding conversion handler.
378#[repr(C)]
379pub struct _xmlCharEncodingHandler {
380    pub name: *mut c_char,                              // Encoding name
381    pub input: c_int,                                   // Input xmlCharEncoding
382    pub output: c_int,                                  // Output xmlCharEncoding
383    pub input_func: Option<xmlCharEncodingInputFunc>,   // Input conversion func
384    pub output_func: Option<xmlCharEncodingOutputFunc>, // Output conversion func
385    pub iconv_in: *mut c_void,                          // Iconv descriptor for input
386    pub iconv_out: *mut c_void,                         // Iconv descriptor for output
387}
388
389// ── xmlBuf ──────────────────────────────────────────────────────────────
390//
391// Source: tree.h
392
393/// Buffer structure (modern replacement for xmlBuffer).
394#[repr(C)]
395pub struct _xmlBuf {
396    pub content: *mut xmlChar, // The buffer content UTF8
397    pub use_: c_uint,          // The buffer size used
398    pub size: c_uint,          // The buffer size
399    pub alloc: c_int,          // The realloc method
400    pub error: c_int,          // Error flag
401    pub buffer: c_int,         // Is this a buffer from xmlBuffer?
402    pub io: c_int,             // In IO mode?
403}
404
405// ── xmlSAXHandler ───────────────────────────────────────────────────────
406//
407// Source: parser.h
408
409/// SAX event handler structure.
410#[repr(C)]
411pub struct _xmlSAXHandler {
412    pub internalSubset: Option<internalSubsetSAXFunc>,
413    pub isStandalone: Option<isStandaloneSAXFunc>,
414    pub hasInternalSubset: Option<hasInternalSubsetSAXFunc>,
415    pub hasExternalSubset: Option<hasExternalSubsetSAXFunc>,
416    pub resolveEntity: Option<resolveEntitySAXFunc>,
417    pub getEntity: Option<getEntitySAXFunc>,
418    pub entityDecl: Option<entityDeclSAXFunc>,
419    pub notationDecl: Option<notationDeclSAXFunc>,
420    pub attributeDecl: Option<attributeDeclSAXFunc>,
421    pub elementDecl: Option<elementDeclSAXFunc>,
422    pub unparsedEntityDecl: Option<unparsedEntityDeclSAXFunc>,
423    pub setDocumentLocator: Option<setDocumentLocatorSAXFunc>,
424    pub startDocument: Option<startDocumentSAXFunc>,
425    pub endDocument: Option<endDocumentSAXFunc>,
426    pub startElement: Option<startElementSAXFunc>,
427    pub endElement: Option<endElementSAXFunc>,
428    pub reference: Option<referenceSAXFunc>,
429    pub characters: Option<charactersSAXFunc>,
430    pub ignorableWhitespace: Option<ignorableWhitespaceSAXFunc>,
431    pub processingInstruction: Option<processingInstructionSAXFunc>,
432    pub comment: Option<commentSAXFunc>,
433    pub warning: Option<warningSAXFunc>,
434    pub error: Option<errorSAXFunc>,
435    pub fatalError: Option<fatalErrorSAXFunc>,
436    pub getParameterEntity: Option<getParameterEntitySAXFunc>,
437    pub cdataBlock: Option<cdataBlockSAXFunc>,
438    pub externalSubset: Option<externalSubsetSAXFunc>,
439    pub initialized: c_uint,
440    pub _private: *mut c_void,
441    pub startElementNs: Option<startElementNsSAX2Func>,
442    pub endElementNs: Option<endElementNsSAX2Func>,
443    pub serror: Option<xmlStructuredErrorFunc>,
444}
445
446// ── xmlParserCtxt ───────────────────────────────────────────────────────
447//
448// Source: parser.h
449
450/// Parser context — the primary parsing state structure.
451#[repr(C)]
452pub struct _xmlParserCtxt {
453    pub sax: *mut _xmlSAXHandler, // SAX handler (deprecated)
454    pub userData: *mut c_void,    // User data (deprecated)
455    pub myDoc: *mut _xmlDoc,      // Document being built (deprecated)
456    pub wellFormed: c_int,        // Is document well formed? (deprecated)
457    pub replaceEntities: c_int,   // Replace entities? (deprecated)
458    pub version: *mut xmlChar,    // XML version string (deprecated)
459    pub encoding: *mut xmlChar,   // Declared encoding (deprecated)
460    pub standalone: c_int,        // Standalone document (deprecated)
461    pub html: c_int,              // HTML document (deprecated)
462    // Input stream stack
463    pub input: *mut _xmlParserInput,         // Current input stream
464    pub inputNr: c_int,                      // Number of current input streams
465    pub inputMax: c_int,                     // Max number of input streams (deprecated)
466    pub inputTab: *mut *mut _xmlParserInput, // Stack of inputs
467    // Node analysis stack
468    pub node: *mut _xmlNode,         // Current element (deprecated)
469    pub nodeNr: c_int,               // Depth of parsing stack (deprecated)
470    pub nodeMax: c_int,              // Max depth (deprecated)
471    pub nodeTab: *mut *mut _xmlNode, // Array of nodes (deprecated)
472    // Node info
473    pub record_info: c_int,             // Whether node info should be kept
474    pub node_seq: xmlParserNodeInfoSeq, // Info about each node parsed (deprecated)
475    // Error
476    pub errNo: c_int, // Error code (deprecated)
477    // Reference and external subset
478    pub hasExternalSubset: c_int, // (deprecated)
479    pub hasPErefs: c_int,         // (deprecated)
480    pub external: c_int,          // (deprecated)
481    pub valid: c_int,             // Is document valid? (deprecated)
482    pub validate: c_int,          // Validate flag (deprecated)
483    pub vctxt: _xmlValidCtxt,     // Validity context
484    // Push parser state
485    pub instate: c_int,         // (deprecated)
486    pub token: c_int,           // (deprecated)
487    pub directory: *mut c_char, // Document directory (deprecated)
488    // Node name stack
489    pub name: *const xmlChar,         // Current parsed Node (deprecated)
490    pub nameNr: c_int,                // (deprecated)
491    pub nameMax: c_int,               // (deprecated)
492    pub nameTab: *mut *const xmlChar, // (deprecated)
493    // Misc
494    pub nbChars: c_long,            // (deprecated)
495    pub checkIndex: c_long,         // (deprecated)
496    pub keepBlanks: c_int,          // (deprecated)
497    pub disableSAX: c_int,          // (deprecated)
498    pub inSubset: c_int,            // DTD parsing state (deprecated)
499    pub intSubName: *const xmlChar, // Internal subset name (deprecated)
500    pub extSubURI: *mut xmlChar,    // External subset URI (deprecated)
501    pub extSubSystem: *mut xmlChar, // External subset public ID (deprecated)
502    // xml:space values
503    pub space: *mut c_int,    // (deprecated)
504    pub spaceNr: c_int,       // (deprecated)
505    pub spaceMax: c_int,      // (deprecated)
506    pub spaceTab: *mut c_int, // (deprecated)
507    // Entity loop prevention
508    pub depth: c_int,                 // (deprecated)
509    pub entity: *mut _xmlParserInput, // (deprecated)
510    pub charset: c_int,               // (deprecated)
511    pub nodelen: c_int,               // (deprecated)
512    pub nodemem: c_int,               // (deprecated)
513    pub pedantic: c_int,              // (deprecated)
514    pub _private: *mut c_void,        // User data (deprecated)
515    pub loadsubset: c_int,            // Load external subset (deprecated)
516    pub linenumbers: c_int,           // (deprecated)
517    pub catalogs: *mut c_void,        // (deprecated)
518    pub recovery: c_int,              // Recovery mode (deprecated)
519    pub progressive: c_int,           // (deprecated)
520    pub dict: *mut c_void,            // Dictionary (deprecated)
521    pub atts: *mut *const xmlChar,    // Attributes array (deprecated)
522    pub maxatts: c_int,               // (deprecated)
523    pub docdict: c_int,               // (deprecated)
524    // Pre-interned strings
525    pub str_xml: *const xmlChar,    // (deprecated)
526    pub str_xmlns: *const xmlChar,  // (deprecated)
527    pub str_xml_ns: *const xmlChar, // (deprecated)
528    // New SAX mode
529    pub sax2: c_int,                // (deprecated)
530    pub nsNr: c_int,                // (deprecated)
531    pub nsMax: c_int,               // (deprecated)
532    pub nsTab: *mut *const xmlChar, // (deprecated)
533    pub attallocs: *mut c_uint,     // (deprecated)
534    pub pushTab: *mut c_void,       // xmlStartTag (deprecated)
535    pub attsDefault: *mut c_void,   // (deprecated)
536    pub attsSpecial: *mut c_void,   // (deprecated)
537    pub nsWellFormed: c_int,        // (deprecated)
538    pub options: c_int,             // Extra options (deprecated)
539    pub dictNames: c_int,           // (deprecated)
540    // Streaming
541    pub freeElemsNr: c_int,       // (deprecated)
542    pub freeElems: *mut _xmlNode, // (deprecated)
543    pub freeAttrsNr: c_int,       // (deprecated)
544    pub freeAttrs: *mut _xmlAttr, // (deprecated)
545    pub lastError: _xmlError,     // Last error info (deprecated)
546    pub parseMode: c_int,         // (deprecated)
547    pub nbentities: c_ulong,      // (deprecated)
548    pub sizeentities: c_ulong,    // (deprecated)
549    // HTML non-recursive parser
550    pub nodeInfo: *mut c_void,    // (deprecated)
551    pub nodeInfoNr: c_int,        // (deprecated)
552    pub nodeInfoMax: c_int,       // (deprecated)
553    pub nodeInfoTab: *mut c_void, // (deprecated)
554    pub input_id: c_int,          // (deprecated)
555    pub sizeentcopy: c_ulong,     // (deprecated)
556    pub endCheckState: c_int,     // (deprecated)
557    pub nbErrors: c_ushort,       // (deprecated)
558    pub nbWarnings: c_ushort,     // (deprecated)
559    pub maxAmpl: c_uint,          // (deprecated)
560    // Namespace database
561    pub nsdb: *mut c_void,     // (deprecated)
562    pub attrHashMax: c_uint,   // (deprecated)
563    pub attrHash: *mut c_void, // (deprecated)
564    // Error handler
565    pub errorHandler: Option<xmlStructuredErrorFunc>, // (deprecated)
566    pub errorCtxt: *mut c_void,                       // (deprecated)
567    // Resource loader
568    pub resourceLoader: Option<xmlResourceLoader>, // (deprecated)
569    pub resourceCtxt: *mut c_void,                 // (deprecated)
570    // Encoding conversion
571    pub convImpl: Option<xmlCharEncConvImpl>, // (deprecated)
572    pub convCtxt: *mut c_void,                // (deprecated)
573}
574
575// ── xmlValidCtxt ────────────────────────────────────────────────────────
576//
577// Source: valid.h
578
579/// Validation context.
580#[repr(C)]
581pub struct _xmlValidCtxt {
582    pub userData: *mut c_void,                   // User specific data
583    pub error: Option<xmlValidityErrorFunc>,     // Error callback
584    pub warning: Option<xmlValidityWarningFunc>, // Warning callback
585    pub node: *mut _xmlNode,                     // Current parsed Node
586    pub nodeNr: c_int,                           // Depth of the parsing stack
587    pub nodeMax: c_int,                          // Max depth
588    pub nodeTab: *mut *mut _xmlNode,             // Array of nodes
589    pub flags: c_uint,                           // Internal flags
590    pub doc: *mut _xmlDoc,                       // The document
591    pub valid: c_int,                            // Temporary validity check result
592    pub vstate: *mut c_void,                     // Current validation state
593    pub vstateNr: c_int,                         // Depth of validation stack
594    pub vstateMax: c_int,                        // Max depth
595    pub vstateTab: *mut c_void,                  // Array of validation states
596    pub am: *mut c_void,                         // Automata
597    pub state: *mut c_void,                      // Automata state
598}
599
600// ── xmlParserNodeInfo ───────────────────────────────────────────────────
601
602/// Node info for parser tracking.
603#[repr(C)]
604pub struct _xmlParserNodeInfo {
605    pub node: *const _xmlNode,
606    pub begin_pos: c_ulong,
607    pub begin_line: c_ulong,
608    pub end_pos: c_ulong,
609    pub end_line: c_ulong,
610}
611
612/// Node info sequence.
613#[repr(C)]
614pub struct _xmlParserNodeInfoSeq {
615    pub block: *mut _xmlParserNodeInfo,
616    pub index: *mut c_int,
617    pub block_max: c_int,
618    pub size: c_int,
619}
620
621/// Typedef alias for `_xmlParserNodeInfoSeq`.
622pub type xmlParserNodeInfoSeq = _xmlParserNodeInfoSeq;
623
624// ── xmlXPathContext ─────────────────────────────────────────────────────
625//
626// Source: xpath.h
627
628/// XPath evaluation context.
629#[repr(C)]
630pub struct _xmlXPathContext {
631    pub doc: *mut _xmlDoc,                                 // The current document
632    pub node: *mut _xmlNode,                               // The current node
633    pub nb_variables_unused: c_int,                        // (unused)
634    pub max_variables_unused: c_int,                       // (unused)
635    pub varHash: *mut c_void,                              // Hash table of defined variables
636    pub nb_types: c_int,                                   // Number of defined types
637    pub max_types: c_int,                                  // Max number of types
638    pub types: *mut c_void,                                // Array of defined types (xmlXPathType)
639    pub nb_funcs_unused: c_int,                            // (unused)
640    pub max_funcs_unused: c_int,                           // (unused)
641    pub funcHash: *mut c_void,                             // Hash table of defined funcs
642    pub nb_axis: c_int,                                    // Number of defined axis
643    pub max_axis: c_int,                                   // Max number of axis
644    pub axis: *mut c_void,                                 // Array of defined axis (xmlXPathAxis)
645    pub namespaces: *mut *mut _xmlNs,                      // Array of namespaces
646    pub nsNr: c_int,                                       // Number of namespaces in scope
647    pub user: *mut c_void,                                 // Function to free
648    pub contextSize: c_int,                                // Context size
649    pub proximityPosition: c_int,                          // Proximity position
650    pub xptr: c_int,                                       // XPointer context?
651    pub here: *mut _xmlNode,                               // For here()
652    pub origin: *mut _xmlNode,                             // For origin()
653    pub nsHash: *mut c_void,                               // Namespaces hash table
654    pub varLookupFunc: Option<xmlXPathVariableLookupFunc>, // Variable lookup func
655    pub varLookupData: *mut c_void,                        // Variable lookup data
656    pub extra: *mut c_void,                                // Needed for XSLT
657    pub function: *const xmlChar,                          // Function name when calling a function
658    pub functionURI: *const xmlChar,                       // Function namespace URI
659    pub funcLookupFunc: Option<xmlXPathFuncLookupFunc>,    // Function lookup func
660    pub funcLookupData: *mut c_void,                       // Function lookup data
661    pub tmpNsList: *mut *mut _xmlNs,                       // Array of temp namespaces
662    pub tmpNsNr: c_int,                                    // Number of temp namespaces
663    pub userData: *mut c_void,                             // User specific data
664    pub error: Option<xmlStructuredErrorFunc>,             // Error callback
665    pub lastError: _xmlError,                              // Last error
666    pub debugNode: *mut _xmlNode,                          // Source node (XSLT)
667    pub dict: *mut c_void,                                 // Dictionary
668    pub flags: c_int,                                      // Compilation flags
669    pub cache: *mut c_void,                                // Cache for XPath objects
670    pub opLimit: c_ulong,                                  // Resource limits
671    pub opCount: c_ulong,
672    pub depth: c_int,
673}
674
675// ── xmlXPathObject ──────────────────────────────────────────────────────
676//
677// Source: xpath.h
678
679/// XPath evaluated object.
680#[repr(C)]
681pub struct _xmlXPathObject {
682    pub type_: c_int,            // Object type
683    pub nodesetval: *mut c_void, // Node set (xmlNodeSet)
684    pub boolval: c_int,          // Boolean value
685    pub floatval: f64,           // Number value
686    pub stringval: *mut xmlChar, // String value
687    pub user: *mut c_void,       // User pointer
688    pub index: c_int,            // Index
689    pub user2: *mut c_void,      // User pointer 2
690    pub index2: c_int,           // Index 2
691}
692
693// ── Node set (contained within XPath objects) ───────────────────────────
694
695/// XPath node set.
696#[repr(C)]
697pub struct _xmlNodeSet {
698    pub nodeNr: c_int,               // Number of nodes
699    pub nodeMax: c_int,              // Max number of nodes
700    pub nodeTab: *mut *mut _xmlNode, // Array of nodes
701}
702
703// ── XSLT types ──────────────────────────────────────────────────────────
704//
705// Source: xslt.h, xsltInternals.h (from libxslt)
706
707/// XSLT stylesheet (opaque, forward declaration).
708#[repr(C)]
709pub struct _xsltStylesheet {
710    // Filled in when libxslt module is implemented (Phase 8)
711    _unused: [u8; 0],
712}
713
714/// XSLT transform context (opaque, forward declaration).
715#[repr(C)]
716pub struct _xsltTransformContext {
717    // Filled in when libxslt module is implemented (Phase 8)
718    _unused: [u8; 0],
719}
720
721// ── Type aliases for pointer types ──────────────────────────────────────
722
723pub type xmlNodePtr = *mut _xmlNode;
724pub type xmlDocPtr = *mut _xmlDoc;
725pub type xmlNsPtr = *mut _xmlNs;
726pub type xmlAttrPtr = *mut _xmlAttr;
727pub type xmlDtdPtr = *mut _xmlDtd;
728pub type xmlEntityPtr = *mut _xmlEntity;
729pub type xmlErrorPtr = *mut _xmlError;
730pub type xmlParserCtxtPtr = *mut _xmlParserCtxt;
731pub type xmlParserInputPtr = *mut _xmlParserInput;
732pub type xmlParserInputBufferPtr = *mut _xmlParserInputBuffer;
733pub type xmlOutputBufferPtr = *mut _xmlOutputBuffer;
734pub type xmlSAXHandlerPtr = *mut _xmlSAXHandler;
735pub type xmlValidCtxtPtr = *mut _xmlValidCtxt;
736pub type xmlBufferPtr = *mut _xmlBuffer;
737pub type xmlElementPtr = *mut _xmlElement;
738pub type xmlElementContentPtr = *mut _xmlElementContent;
739pub type xmlNotationPtr = *mut _xmlNotation;
740pub type xmlEnumerationPtr = *mut _xmlEnumeration;
741pub type xmlAttributeDeclPtr = *mut _xmlAttribute;
742pub type xmlXPathContextPtr = *mut _xmlXPathContext;
743pub type xmlXPathObjectPtr = *mut _xmlXPathObject;
744pub type xmlNodeSetPtr = *mut _xmlNodeSet;
745pub type xmlCharEncodingHandlerPtr = *mut _xmlCharEncodingHandler;
746pub type xmlBufPtr = *mut _xmlBuf;
747pub type xsltStylesheetPtr = *mut _xsltStylesheet;
748pub type xsltTransformContextPtr = *mut _xsltTransformContext;