libxml_rs/abi/constants.rs
1//! C ABI constants — supplementary ABI constants not defined as enum variants or flag bits in `types.rs` (§14).
2//!
3//! This module contains additional constants that appear as `#define` macros in upstream headers
4//! but are not naturally represented as Rust enum variants. The primary type/enum definitions
5//! live in `types.rs` — this module holds the rest.
6//!
7//! # Phase 1 status
8//!
9//! Complete — all key upstream `#define` constants are present.
10//!
11//! # Upstream header mapping
12//!
13//! | Constant | Header | Purpose |
14//! |---|---|---|
15//! | `XML_DEFAULT_VERSION` | parser.h | Default XML version string |
16//! | `XML_DETECT_IDS` | parser.h | Flag for xmlLoadExtDtdDefaultValue |
17//! | `XML_COMPLETE_ATTRS` | parser.h | Flag for xmlLoadExtDtdDefaultValue |
18//! | `XML_SKIP_IDS` | parser.h | Flag for xmlLoadExtDtdDefaultValue |
19//! | `XML_SUBSTITUTE_*` | parserInternals.h | Entity substitution flags |
20//! | `XML_DOCB_DOCUMENT_NODE` | tree.h | DocBook document node type value |
21//! | `XML_XML_NAMESPACE` | tree.h | The XML namespace URI |
22//! | `XML_XPATH_CHECKNS` | xpath.h | XPath evaluation flag |
23//! | `XML_XPATH_NOVAR` | xpath.h | XPath evaluation flag |
24//! | `XML_CATALOGS_NAMESPACE` | catalog.h | Catalog namespace URI |
25//! | `XML_CATALOG_PI` | catalog.h | Catalog PI target |
26//! | `XML_SAX2_MAGIC` | parser.h | SAX2 initialization marker |
27
28#![allow(non_upper_case_globals)]
29
30use std::os::raw::c_int;
31
32// ═══════════════════════════════════════════════════════════════════════════════
33// XML Version Constants (parser.h)
34// ═══════════════════════════════════════════════════════════════════════════════
35
36/// Default XML version string.
37/// #define XML_DEFAULT_VERSION "1.0"
38pub const XML_DEFAULT_VERSION: &[u8] = b"1.0\0";
39
40// ═══════════════════════════════════════════════════════════════════════════════
41// Parser Load Subset Flags (parser.h)
42// ═══════════════════════════════════════════════════════════════════════════════
43
44/// Flag for xmlLoadExtDtdDefaultValue: detect ID/IDREF attributes.
45pub const XML_DETECT_IDS: c_int = 2;
46
47/// Flag for xmlLoadExtDtdDefaultValue: complete attributes from DTD.
48pub const XML_COMPLETE_ATTRS: c_int = 4;
49
50/// Flag for xmlLoadExtDtdDefaultValue: skip ID processing.
51pub const XML_SKIP_IDS: c_int = 8;
52
53// ═══════════════════════════════════════════════════════════════════════════════
54// Entity Substitution Flags (parserInternals.h)
55// ═══════════════════════════════════════════════════════════════════════════════
56
57/// Do not substitute entities.
58pub const XML_SUBSTITUTE_NONE: c_int = 0;
59
60/// Substitute general entities.
61pub const XML_SUBSTITUTE_REF: c_int = 1;
62
63/// Substitute parameter entities.
64pub const XML_SUBSTITUTE_PEREF: c_int = 2;
65
66/// Substitute both general and parameter entities.
67pub const XML_SUBSTITUTE_BOTH: c_int = 3;
68
69// ═══════════════════════════════════════════════════════════════════════════════
70// Tree Constants (tree.h)
71// ═══════════════════════════════════════════════════════════════════════════════
72
73/// DocBook document node type (value 21).
74///
75/// # UPSTREAM-PARITY
76///
77/// DocBook is largely deprecated in modern libxml2 but the constant value
78/// is preserved for ABI compatibility.
79pub const XML_DOCB_DOCUMENT_NODE: c_int = 21;
80
81/// The XML namespace URI.
82///
83/// ```c
84/// #define XML_XML_NAMESPACE \
85/// (const xmlChar *) "http://www.w3.org/XML/1998/namespace"
86/// ```
87///
88/// # UPSTREAM-PARITY
89///
90/// This is the standard `xml` namespace URI, hard-coded in upstream.
91pub const XML_XML_NAMESPACE: &[u8] = b"http://www.w3.org/XML/1998/namespace\0";
92
93// ═══════════════════════════════════════════════════════════════════════════════
94// XPath Constants (xpath.h)
95// ═══════════════════════════════════════════════════════════════════════════════
96
97/// Check namespaces during XPath evaluation.
98pub const XML_XPATH_CHECKNS: c_int = 1 << 0;
99
100/// Do not use default variable resolution.
101pub const XML_XPATH_NOVAR: c_int = 1 << 1;
102
103// ═══════════════════════════════════════════════════════════════════════════════
104// Catalog Constants (catalog.h)
105// ═══════════════════════════════════════════════════════════════════════════════
106
107/// The XML Catalogs namespace URI.
108///
109/// ```c
110/// #define XML_CATALOGS_NAMESPACE \
111/// (const xmlChar *) "urn:oasis:names:tc:entity:xmlns:xml:catalog"
112/// ```
113pub const XML_CATALOGS_NAMESPACE: &[u8] = b"urn:oasis:names:tc:entity:xmlns:xml:catalog\0";
114
115/// The XML Catalogs PI target string.
116///
117/// ```c
118/// #define XML_CATALOG_PI \
119/// (const xmlChar *) "oasis-xml-catalog"
120/// ```
121pub const XML_CATALOG_PI: &[u8] = b"oasis-xml-catalog\0";
122
123// ═══════════════════════════════════════════════════════════════════════════════
124// SAX2 Magic Marker (parser.h)
125// ═══════════════════════════════════════════════════════════════════════════════
126
127/// Magic value for SAX2 initialization in xmlSAXHandler.initialized.
128///
129/// ```c
130/// #define XML_SAX2_MAGIC 0xDEEDBEAF
131/// ```
132///
133/// # UPSTREAM-PARITY
134///
135/// When `_xmlSAXHandler.initialized` is set to `XML_SAX2_MAGIC`,
136/// the handler uses SAX2 callbacks (startElementNs/endElementNs)
137/// instead of SAX1 callbacks.
138pub const XML_SAX2_MAGIC: c_int = 0xDEEDBEAFu32 as i32;
139
140// ═══════════════════════════════════════════════════════════════════════════════
141// Well-known Namespace URIs (tree.h, namespaces.h)
142// ═══════════════════════════════════════════════════════════════════════════════
143
144/// The xmlns namespace URI.
145///
146/// ```c
147/// #define XML_XMLNS_NAMESPACE \
148/// (const xmlChar *) "http://www.w3.org/2000/xmlns/"
149/// ```
150///
151/// # UPSTREAM-PARITY
152///
153/// This is the namespace URI for `xmlns` declarations.
154pub const XML_XMLNS_NAMESPACE: &[u8] = b"http://www.w3.org/2000/xmlns/\0";
155
156/// The xmlns prefix.
157///
158/// ```c
159/// #define XML_XMLNS_PREFIX (const xmlChar *) "xmlns"
160/// ```
161pub const XML_XMLNS_PREFIX: &[u8] = b"xmlns\0";
162
163/// The xml prefix.
164///
165/// ```c
166/// #define XML_XML_PREFIX (const xmlChar *) "xml"
167/// ```
168pub const XML_XML_PREFIX: &[u8] = b"xml\0";
169
170// ═══════════════════════════════════════════════════════════════════════════════
171// Encoding Constants (encoding.h)
172// ═══════════════════════════════════════════════════════════════════════════════
173
174/// Maximum encoding name length.
175pub const XML_MAX_ENCODING_NAME_LEN: c_int = 50;
176
177/// Maximum conversion buffer length.
178pub const XML_MAX_CONV_BUF_LEN: c_int = 4096;
179
180// ═══════════════════════════════════════════════════════════════════════════════
181// HTML Parser Constants (HTMLparser.h)
182// ═══════════════════════════════════════════════════════════════════════════════
183
184/// HTML parser status: no problem.
185pub const HTML_PARSE_NO_FLAGS: c_int = 0;
186
187/// HTML parser option: suppress error reports.
188pub const HTML_PARSE_NOERROR: c_int = 1 << 5;
189
190/// HTML parser option: suppress warning reports.
191pub const HTML_PARSE_NOWARNING: c_int = 1 << 6;
192
193/// HTML parser option: pedantic error reporting.
194pub const HTML_PARSE_PEDANTIC: c_int = 1 << 7;
195
196/// HTML parser option: remove blank nodes.
197pub const HTML_PARSE_NOBLANKS: c_int = 1 << 8;
198
199/// HTML parser option: do not load external entities.
200pub const HTML_PARSE_NONET: c_int = 1 << 11;
201
202/// HTML parser option: do not generate XInclude nodes.
203pub const HTML_PARSE_NOXINCNODE: c_int = 1 << 15;
204
205/// HTML parser option: compact text nodes.
206pub const HTML_PARSE_COMPACT: c_int = 1 << 16;
207
208/// HTML parser option: ignore encoding declaration.
209pub const HTML_PARSE_IGNORE_ENC: c_int = 1 << 21;
210
211// ═══════════════════════════════════════════════════════════════════════════════
212// Writer Constants (xmlwriter.h)
213// ═══════════════════════════════════════════════════════════════════════════════
214
215/// Writer type: no writer.
216pub const XML_TEXTWRITER_NONE: c_int = 0;
217
218/// Writer type: XML writer.
219pub const XML_TEXTWRITER_NAME: c_int = 1;
220
221/// Writer type: DOM writer (tree-based).
222pub const XML_TEXTWRITER_ATTRIBUTE_NAME: c_int = 2;
223
224/// Writer type: text content.
225pub const XML_TEXTWRITER_TEXT: c_int = 3;
226
227/// Writer type: CDATA content.
228pub const XML_TEXTWRITER_CDATA: c_int = 4;
229
230/// Writer type: entity reference.
231pub const XML_TEXTWRITER_ENTITY_REF: c_int = 5;
232
233/// Writer type: PI node.
234pub const XML_TEXTWRITER_PI: c_int = 6;
235
236/// Writer type: comment node.
237pub const XML_TEXTWRITER_COMMENT: c_int = 7;
238
239/// Writer type: DTD node.
240pub const XML_TEXTWRITER_DTD: c_int = 8;
241
242/// Writer type: DTD element.
243pub const XML_TEXTWRITER_DTD_ELEM: c_int = 9;
244
245/// Writer type: DTD attribute.
246pub const XML_TEXTWRITER_DTD_ATTL: c_int = 10;
247
248/// Writer type: DTD entity.
249pub const XML_TEXTWRITER_DTD_ENTY: c_int = 11;
250
251/// Writer type: DTD notation.
252pub const XML_TEXTWRITER_DTD_NOTA: c_int = 12;
253
254/// Writer type: namespace declaration.
255pub const XML_TEXTWRITER_NAMESPACE: c_int = 13;
256
257/// Writer type: element with no content.
258pub const XML_TEXTWRITER_NO_CONTENT: c_int = 14;
259
260/// Writer type: attribute value (content only).
261pub const XML_TEXTWRITER_ATTRIBUTE_VALUE: c_int = 15;
262
263/// Writer type: XML declaration.
264pub const XML_TEXTWRITER_XML_DECLARATION: c_int = 16;