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