1#![allow(non_snake_case)]
37#![allow(unused_variables)]
38#![allow(clippy::missing_safety_doc)]
39#![allow(clippy::not_unsafe_ptr_arg_deref)]
40
41use core::ffi::c_void;
42use core::ptr;
43use once_cell::sync::Lazy;
44use parking_lot::Mutex;
45use std::collections::HashMap;
46use std::ffi::{CStr, CString};
47use std::mem::size_of;
48use std::os::raw::{c_char, c_int, c_uint, c_ulong};
49
50use crate::xml::xinclude;
51use crate::xml::xpath::ast::CompiledExpr;
52use crate::xml::xpath::context::{BoxedXPathFunction, XPathContext};
53use crate::xml::xpath::types::{NodeSet, XPathValue};
54use crate::xml::xpointer;
55
56use crate::abi::allocator::*;
57use crate::abi::callbacks::*;
58use crate::abi::structs::*;
59use crate::abi::types::*;
60
61#[no_mangle]
76pub unsafe extern "C" fn xmlInitParser() {
77 crate::internal::globals::init_parser();
78}
79
80#[no_mangle]
93pub unsafe extern "C" fn xmlInitGlobals() {
94 }
96
97#[no_mangle]
107pub unsafe extern "C" fn xmlInitializeGlobalState(_gs: *mut c_void) {
108 }
110
111#[no_mangle]
120pub extern "C" fn xmlInitializeDict() -> c_int {
121 0
122}
123
124#[no_mangle]
134pub extern "C" fn xmlInitializePredefinedEntities() {
135 }
137
138#[no_mangle]
147pub extern "C" fn xmlCleanupPredefinedEntities() {
148 }
150
151#[no_mangle]
162pub extern "C" fn xmlDefaultSAXHandlerInit() {
163 }
166
167static SAX2_DEFAULT_VERSION: core::sync::atomic::AtomicI32 = core::sync::atomic::AtomicI32::new(2);
176#[no_mangle]
177pub extern "C" fn xmlSAXDefaultVersion(version: c_int) -> c_int {
178 use core::sync::atomic::Ordering;
179 let ret = SAX2_DEFAULT_VERSION.load(Ordering::Relaxed);
180 if version != 1 && version != 2 {
181 return -1;
182 }
183 SAX2_DEFAULT_VERSION.store(version, Ordering::Relaxed);
184 ret
185}
186
187#[no_mangle]
197pub unsafe extern "C" fn xmlSAXVersion(
198 hdlr: *mut crate::abi::structs::_xmlSAXHandler,
199 version: c_int,
200) -> c_int {
201 if hdlr.is_null() {
202 return -1;
203 }
204 if version != 1 && version != 2 {
205 return -1;
206 }
207 unsafe {
209 crate::xml::sax::dispatch::xmlSAX2InitDefaultSAXHandler(hdlr);
210 let h = &mut *hdlr;
211 if version == 2 {
212 h.initialized = crate::abi::constants::XML_SAX2_MAGIC as c_uint;
213 } else {
214 h.initialized = 1;
215 }
216 }
217 0
218}
219
220#[no_mangle]
231pub extern "C" fn xmlHasFeature(feature: c_int) -> c_int {
232 if (1..=24).contains(&feature) {
235 1
236 } else {
237 0
238 }
239}
240
241#[no_mangle]
253pub unsafe extern "C" fn xmlCleanupGlobals() {
254 }
256
257#[no_mangle]
267pub unsafe extern "C" fn xmlCleanupParser() {
268 crate::internal::globals::cleanup_parser();
269}
270
271#[no_mangle]
279pub extern "C" fn xmlNewMutex() -> *mut c_void {
280 crate::xml::threads::new_mutex()
281}
282
283#[no_mangle]
291pub unsafe extern "C" fn xmlFreeMutex(tok: *mut c_void) {
292 crate::xml::threads::free_mutex(tok);
293}
294
295#[no_mangle]
303pub unsafe extern "C" fn xmlMutexLock(tok: *mut c_void) {
304 crate::xml::threads::mutex_lock(tok);
305}
306
307#[no_mangle]
315pub unsafe extern "C" fn xmlMutexUnlock(tok: *mut c_void) {
316 crate::xml::threads::mutex_unlock(tok);
317}
318
319#[no_mangle]
327pub extern "C" fn xmlNewRMutex() -> *mut c_void {
328 crate::xml::threads::new_rmutex()
329}
330
331#[no_mangle]
339pub unsafe extern "C" fn xmlFreeRMutex(tok: *mut c_void) {
340 crate::xml::threads::free_rmutex(tok);
341}
342
343#[no_mangle]
351pub unsafe extern "C" fn xmlRMutexLock(tok: *mut c_void) {
352 crate::xml::threads::rmutex_lock(tok);
353}
354
355#[no_mangle]
363pub unsafe extern "C" fn xmlRMutexUnlock(tok: *mut c_void) {
364 crate::xml::threads::rmutex_unlock(tok);
365}
366
367#[no_mangle]
377pub extern "C" fn xmlCheckThreadLocalStorage() -> c_int {
378 0
379}
380
381#[no_mangle]
391pub unsafe extern "C" fn xmlInitThreads() -> c_int {
392 crate::internal::globals::init_threads()
393}
394
395#[no_mangle]
403pub unsafe extern "C" fn xmlCleanupThreads() {
404 crate::xml::threads::cleanup_threads();
405}
406
407#[no_mangle]
415pub extern "C" fn xmlIsInitialized() -> c_int {
416 if crate::abi::versioning::is_initialized() {
417 1
418 } else {
419 0
420 }
421}
422
423#[no_mangle]
432pub unsafe extern "C" fn xmlLockLibrary() {
433 crate::xml::threads::lock_library();
434}
435
436#[no_mangle]
444pub unsafe extern "C" fn xmlUnlockLibrary() {
445 crate::xml::threads::unlock_library();
446}
447
448#[no_mangle]
465pub unsafe extern "C" fn xmlSetGenericErrorFunc(
466 ctx: *mut c_void,
467 handler: Option<xmlGenericErrorFunc>,
468) {
469 unsafe { crate::xml::errors::set_generic_error_func(ctx, handler) };
471}
472
473#[no_mangle]
485pub unsafe extern "C" fn xmlSetStructuredErrorFunc(
486 ctx: *mut c_void,
487 handler: Option<xmlStructuredErrorFunc>,
488) {
489 unsafe { crate::xml::errors::set_structured_error_func(ctx, handler) };
491}
492
493#[no_mangle]
504pub extern "C" fn xmlGetLastError() -> *mut _xmlError {
505 crate::xml::errors::get_last_error()
506}
507
508#[no_mangle]
522pub unsafe extern "C" fn xmlCopyError(from: *const _xmlError, to: *mut _xmlError) -> c_int {
523 unsafe { crate::xml::errors::copy_error(from, to) }
525}
526
527#[no_mangle]
539pub unsafe extern "C" fn xmlResetError(err: *mut _xmlError) {
540 unsafe { crate::xml::errors::reset_error(err) };
542}
543
544#[no_mangle]
557pub unsafe extern "C" fn xmlRaiseError(
558 ctxt: *mut c_void,
559 ctxt2: *mut c_void,
560 ctxt3: *mut c_void,
561 ctxt4: *mut c_void,
562 ctxt5: *mut c_void,
563 domain: c_int,
564 code: c_int,
565 level: c_int,
566 file: *const c_char,
567 line: c_int,
568 str1: *const c_char,
569 str2: *const c_char,
570 str3: *const c_char,
571 int1: c_int,
572 int2: c_int,
573 msg: *const c_char,
574) {
575 unsafe {
577 crate::xml::errors::raise_error(
578 ctxt, ctxt2, ctxt3, ctxt4, ctxt5, domain, code, level, file, line, str1, str2, str3,
579 int1, int2, msg,
580 );
581 }
582}
583
584#[no_mangle]
592pub extern "C" fn xmlResetLastError() {
593 crate::xml::errors::reset_last_error();
594}
595
596#[no_mangle]
612pub unsafe extern "C" fn xmlStrdup(cur: *const xmlChar) -> *mut xmlChar {
613 if cur.is_null() {
614 return ptr::null_mut();
615 }
616 let len = unsafe { xmlStrlen(cur) };
617 let size = len + 1;
618 let new_ptr = unsafe { xmlMallocImpl(size as usize) };
619 if new_ptr.is_null() {
620 return ptr::null_mut();
621 }
622 unsafe {
623 ptr::copy_nonoverlapping(cur as *const u8, new_ptr as *mut u8, size as usize);
624 }
625 new_ptr as *mut xmlChar
626}
627
628#[no_mangle]
640pub unsafe extern "C" fn xmlStrndup(cur: *const xmlChar, len: c_int) -> *mut xmlChar {
641 if cur.is_null() || len <= 0 {
642 return ptr::null_mut();
643 }
644 let size = len as usize + 1;
645 let new_ptr = unsafe { xmlMallocImpl(size) };
646 if new_ptr.is_null() {
647 return ptr::null_mut();
648 }
649 unsafe {
650 ptr::copy_nonoverlapping(cur as *const u8, new_ptr as *mut u8, len as usize);
651 *(new_ptr.add(len as usize) as *mut u8) = 0;
652 }
653 new_ptr as *mut xmlChar
654}
655
656#[no_mangle]
668pub unsafe extern "C" fn xmlStrlen(str: *const xmlChar) -> c_int {
669 if str.is_null() {
670 return 0;
671 }
672 unsafe { libc::strlen(str as *const c_char) as c_int }
673}
674
675#[no_mangle]
688pub unsafe extern "C" fn xmlStrchr(str: *const xmlChar, val: xmlChar) -> *const xmlChar {
689 if str.is_null() {
690 return ptr::null();
691 }
692 unsafe {
693 let mut cur = str;
694 while *cur != 0 {
695 if *cur == val {
696 return cur;
697 }
698 cur = cur.add(1);
699 }
700 ptr::null()
701 }
702}
703
704#[no_mangle]
715pub unsafe extern "C" fn xmlStrcmp(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
716 if str1.is_null() && str2.is_null() {
717 return 0;
718 }
719 if str1.is_null() {
720 return -1;
721 }
722 if str2.is_null() {
723 return 1;
724 }
725 unsafe { libc::strcmp(str1 as *const c_char, str2 as *const c_char) as c_int }
726}
727
728#[no_mangle]
736pub unsafe extern "C" fn xmlStrncmp(
737 str1: *const xmlChar,
738 str2: *const xmlChar,
739 len: c_int,
740) -> c_int {
741 if len <= 0 {
742 return 0;
743 }
744 if str1.is_null() && str2.is_null() {
745 return 0;
746 }
747 if str1.is_null() {
748 return -1;
749 }
750 if str2.is_null() {
751 return 1;
752 }
753 unsafe { libc::strncmp(str1 as *const c_char, str2 as *const c_char, len as usize) as c_int }
754}
755
756#[no_mangle]
764pub unsafe extern "C" fn xmlStrcasecmp(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
765 if str1.is_null() && str2.is_null() {
766 return 0;
767 }
768 if str1.is_null() {
769 return -1;
770 }
771 if str2.is_null() {
772 return 1;
773 }
774 unsafe { libc::strcasecmp(str1 as *const c_char, str2 as *const c_char) as c_int }
775}
776
777#[no_mangle]
785pub unsafe extern "C" fn xmlStrncasecmp(
786 str1: *const xmlChar,
787 str2: *const xmlChar,
788 len: c_int,
789) -> c_int {
790 if len <= 0 {
791 return 0;
792 }
793 if str1.is_null() && str2.is_null() {
794 return 0;
795 }
796 if str1.is_null() {
797 return -1;
798 }
799 if str2.is_null() {
800 return 1;
801 }
802 unsafe {
803 libc::strncasecmp(str1 as *const c_char, str2 as *const c_char, len as usize) as c_int
804 }
805}
806
807#[no_mangle]
817pub unsafe extern "C" fn xmlStrEqual(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
818 if str1.is_null() && str2.is_null() {
819 return 1;
820 }
821 if str1.is_null() || str2.is_null() {
822 return 0;
823 }
824 unsafe { (libc::strcmp(str1 as *const c_char, str2 as *const c_char) == 0) as c_int }
825}
826
827#[no_mangle]
836pub unsafe extern "C" fn xmlBuildQName(
837 ncname: *const xmlChar,
838 prefix: *const xmlChar,
839 memory: *mut xmlChar,
840 len: c_int,
841) -> *mut xmlChar {
842 crate::xml::string::build_qname(ncname, prefix, memory, len)
843}
844
845#[no_mangle]
853pub unsafe extern "C" fn xmlSplitQName2(
854 name: *const xmlChar,
855 prefix: *mut *mut xmlChar,
856) -> *mut xmlChar {
857 crate::xml::string::split_qname2(name, prefix)
858}
859
860#[no_mangle]
868pub unsafe extern "C" fn xmlSplitQName3(name: *const xmlChar, len: *mut c_int) -> c_int {
869 crate::xml::string::split_qname3(name, len)
870}
871
872#[no_mangle]
874pub unsafe extern "C" fn xmlSplitQName(
875 name: *const xmlChar,
876 prefix: *mut *mut xmlChar,
877) -> *mut xmlChar {
878 crate::xml::string::split_qname2(name, prefix)
879}
880
881#[no_mangle]
889pub unsafe extern "C" fn xmlUTF8Strlen(utf: *const xmlChar) -> c_int {
890 crate::xml::string::utf8_strlen(utf)
891}
892
893#[no_mangle]
901pub unsafe extern "C" fn xmlUTF8Size(utf: *const xmlChar) -> c_int {
902 crate::xml::string::utf8_size(utf)
903}
904
905#[no_mangle]
913pub unsafe extern "C" fn xmlCheckUTF8(utf: *const xmlChar) -> c_int {
914 crate::xml::string::check_utf8(utf)
915}
916
917#[no_mangle]
928pub unsafe extern "C" fn xmlStrQEqual(
929 pref: *const xmlChar,
930 name: *const xmlChar,
931 str: *const xmlChar,
932) -> c_int {
933 if name.is_null() || str.is_null() {
934 return 0;
935 }
936 if pref.is_null() {
937 return unsafe { xmlStrEqual(name, str) };
938 }
939 let pref_len = unsafe { xmlStrlen(pref) };
941 let name_len = unsafe { xmlStrlen(name) };
942 let total_len = pref_len + 1 + name_len;
943 let str_len = unsafe { xmlStrlen(str) };
944 if total_len != str_len {
945 return 0;
946 }
947 if unsafe {
949 libc::strncmp(
950 pref as *const c_char,
951 str as *const c_char,
952 pref_len as usize,
953 )
954 } != 0
955 {
956 return 0;
957 }
958 if unsafe { *str.add(pref_len as usize) } != b':' as xmlChar {
960 return 0;
961 }
962 (unsafe {
964 libc::strncmp(
965 name as *const c_char,
966 str.add((pref_len + 1) as usize) as *const c_char,
967 name_len as usize,
968 ) == 0
969 }) as c_int
970}
971
972#[no_mangle]
986pub unsafe extern "C" fn xmlStrcat(cur: *mut xmlChar, add: *const xmlChar) -> *mut xmlChar {
987 if add.is_null() {
988 return cur;
989 }
990 if cur.is_null() {
991 return unsafe { xmlStrdup(add) };
992 }
993 let cur_len = unsafe { xmlStrlen(cur) } as usize;
994 let add_len = unsafe { xmlStrlen(add) } as usize;
995 let new_size = cur_len + add_len + 1;
996 let new_ptr = unsafe { xmlReallocImpl(cur as *mut c_void, new_size) };
997 if new_ptr.is_null() {
998 return ptr::null_mut();
999 }
1000 unsafe {
1001 ptr::copy_nonoverlapping(add as *const u8, (new_ptr as *mut u8).add(cur_len), add_len);
1002 *((new_ptr as *mut u8).add(cur_len + add_len)) = 0;
1003 }
1004 new_ptr as *mut xmlChar
1005}
1006
1007#[no_mangle]
1019pub unsafe extern "C" fn xmlStrncat(
1020 cur: *mut xmlChar,
1021 add: *const xmlChar,
1022 len: c_int,
1023) -> *mut xmlChar {
1024 if add.is_null() || len <= 0 {
1025 return cur;
1026 }
1027 let len = len as usize;
1028 if cur.is_null() {
1029 return unsafe { xmlStrndup(add, len as c_int) };
1030 }
1031 let cur_len = unsafe { xmlStrlen(cur) } as usize;
1032 let new_size = cur_len + len + 1;
1033 let new_ptr = unsafe { xmlReallocImpl(cur as *mut c_void, new_size) };
1034 if new_ptr.is_null() {
1035 return ptr::null_mut();
1036 }
1037 unsafe {
1038 ptr::copy_nonoverlapping(add as *const u8, (new_ptr as *mut u8).add(cur_len), len);
1039 *((new_ptr as *mut u8).add(cur_len + len)) = 0;
1040 }
1041 new_ptr as *mut xmlChar
1042}
1043
1044#[no_mangle]
1052pub unsafe extern "C" fn xmlStrncatNew(
1053 str1: *const xmlChar,
1054 str2: *const xmlChar,
1055 len: c_int,
1056) -> *mut xmlChar {
1057 let mut result: *mut xmlChar = ptr::null_mut();
1058 if !str1.is_null() {
1059 result = unsafe { xmlStrdup(str1) };
1060 }
1061 if !str2.is_null() && len > 0 {
1062 result = unsafe { xmlStrncat(result, str2, len) };
1063 }
1064 result
1065}
1066
1067#[no_mangle]
1080pub unsafe extern "C" fn xmlStrcpy(dst: *mut xmlChar, src: *const xmlChar) -> *mut xmlChar {
1081 if dst.is_null() || src.is_null() {
1082 return dst;
1083 }
1084 let len = unsafe { xmlStrlen(src) } as usize + 1;
1085 unsafe {
1086 ptr::copy_nonoverlapping(src as *const u8, dst as *mut u8, len);
1087 }
1088 dst
1089}
1090
1091#[no_mangle]
1099pub unsafe extern "C" fn xmlStrncpy(
1100 dst: *mut xmlChar,
1101 src: *const xmlChar,
1102 len: c_int,
1103) -> *mut xmlChar {
1104 if dst.is_null() || src.is_null() || len <= 0 {
1105 return dst;
1106 }
1107 let len = len as usize;
1108 let src_len = unsafe { xmlStrlen(src) } as usize;
1109 let copy_len = if src_len < len { src_len } else { len - 1 };
1110 unsafe {
1111 ptr::copy_nonoverlapping(src as *const u8, dst as *mut u8, copy_len);
1112 *dst.add(copy_len) = 0;
1113 }
1114 dst
1115}
1116
1117#[no_mangle]
1127pub unsafe extern "C" fn xmlStrsub(str: *const xmlChar, start: c_int, len: c_int) -> *mut xmlChar {
1128 if str.is_null() || start < 0 || len < 0 {
1129 return ptr::null_mut();
1130 }
1131 let str_len = unsafe { xmlStrlen(str) };
1132 if start >= str_len {
1133 return unsafe { xmlStrdup(b"\0" as *const u8 as *const xmlChar) };
1134 }
1135 let actual_len = if start + len > str_len {
1136 str_len - start
1137 } else {
1138 len
1139 };
1140 unsafe { xmlStrndup(str.add(start as usize), actual_len) }
1141}
1142
1143#[no_mangle]
1160pub unsafe extern "C" fn xmlNewDoc(version: *const xmlChar) -> *mut _xmlDoc {
1161 crate::xml::tree::new_doc(version)
1162}
1163
1164#[no_mangle]
1176pub unsafe extern "C" fn xmlFreeDoc(doc: *mut _xmlDoc) {
1177 crate::xml::tree::free_doc(doc);
1178}
1179
1180#[no_mangle]
1190pub unsafe extern "C" fn xmlGetDocCompressMode(doc: *mut _xmlDoc) -> c_int {
1191 crate::xml::tree::xmlGetDocCompressMode(doc)
1192}
1193
1194#[no_mangle]
1202pub unsafe extern "C" fn xmlSetDocCompressMode(doc: *mut _xmlDoc, mode: c_int) {
1203 crate::xml::tree::xmlSetDocCompressMode(doc, mode);
1204}
1205
1206#[no_mangle]
1220pub unsafe extern "C" fn xmlNewNode(ns: *mut _xmlNs, name: *const xmlChar) -> *mut _xmlNode {
1221 crate::xml::tree::new_node(ns, name)
1222}
1223
1224#[no_mangle]
1237pub unsafe extern "C" fn xmlFreeNode(node: *mut _xmlNode) {
1238 crate::xml::tree::free_node(node);
1239}
1240
1241#[no_mangle]
1258pub unsafe extern "C" fn xmlFreeNodeList(node: *mut _xmlNode) {
1259 crate::xml::tree::free_node_list(node);
1260}
1261
1262#[no_mangle]
1274pub unsafe extern "C" fn xmlUnlinkNode(node: *mut _xmlNode) {
1275 crate::xml::tree::unlink_node(node);
1276}
1277
1278#[no_mangle]
1294pub unsafe extern "C" fn xmlSAX2InitDefaultSAXHandler(
1295 handler: *mut crate::abi::structs::_xmlSAXHandler,
1296 _warning: c_int,
1297) {
1298 crate::xml::sax::dispatch::xmlSAX2InitDefaultSAXHandler(handler);
1299}
1300
1301#[no_mangle]
1320pub unsafe extern "C" fn xmlSAX2InitHtmlDefaultSAXHandler(
1321 handler: *mut crate::abi::structs::_xmlSAXHandler,
1322) {
1323 use crate::abi::callbacks::*;
1324 use crate::abi::structs::_xmlSAXHandler;
1325 if handler.is_null() {
1326 return;
1327 }
1328 unsafe {
1330 if (*handler).initialized != 0 {
1332 return;
1333 }
1334 crate::xml::sax::dispatch::xmlSAX2InitDefaultSAXHandler(handler);
1335 let h = &mut *handler;
1336 h.resolveEntity = None;
1337 h.getParameterEntity = None;
1338 h.entityDecl = None;
1339 h.attributeDecl = None;
1340 h.elementDecl = None;
1341 h.notationDecl = None;
1342 h.unparsedEntityDecl = None;
1343 h.reference = None;
1344 h.externalSubset = None;
1345 h.initialized = 1;
1346 }
1347}
1348
1349#[no_mangle]
1363pub unsafe extern "C" fn xmlAddChild(parent: *mut _xmlNode, cur: *mut _xmlNode) -> *mut _xmlNode {
1364 crate::xml::tree::add_child(parent, cur)
1365}
1366
1367#[no_mangle]
1379pub unsafe extern "C" fn xmlAddSibling(
1380 cur: *mut _xmlNode,
1381 sibling: *mut _xmlNode,
1382) -> *mut _xmlNode {
1383 crate::xml::tree::add_sibling(cur, sibling)
1384}
1385
1386#[no_mangle]
1405pub unsafe extern "C" fn xmlNewChild(
1406 parent: *mut _xmlNode,
1407 ns: *mut _xmlNs,
1408 name: *const xmlChar,
1409 content: *const xmlChar,
1410) -> *mut _xmlNode {
1411 crate::xml::tree::new_child(parent, ns, name)
1412}
1413
1414#[no_mangle]
1429pub unsafe extern "C" fn xmlDocSetRootElement(
1430 doc: *mut _xmlDoc,
1431 root: *mut _xmlNode,
1432) -> *mut _xmlNode {
1433 crate::xml::tree::doc_set_root_element(doc, root)
1434}
1435
1436#[no_mangle]
1446pub extern "C" fn xmlDocGetRootElement(doc: *const _xmlDoc) -> *mut _xmlNode {
1447 crate::xml::tree::doc_get_root_element(doc as *mut _xmlDoc)
1448}
1449
1450#[no_mangle]
1463pub unsafe extern "C" fn xmlCopyNode(node: *const _xmlNode, extended: c_int) -> *mut _xmlNode {
1464 crate::xml::tree::copy_node(node, extended)
1465}
1466
1467#[no_mangle]
1477pub unsafe extern "C" fn xmlCopyDoc(doc: *const _xmlDoc, recursive: c_int) -> *mut _xmlDoc {
1478 crate::xml::tree::copy_doc(doc, recursive)
1479}
1480
1481#[no_mangle]
1492pub unsafe extern "C" fn xmlNewText(content: *const xmlChar) -> *mut _xmlNode {
1493 crate::xml::tree::new_text(content)
1494}
1495
1496#[no_mangle]
1504pub unsafe extern "C" fn xmlNewComment(content: *const xmlChar) -> *mut _xmlNode {
1505 crate::xml::tree::new_comment(content)
1506}
1507
1508#[no_mangle]
1516pub unsafe extern "C" fn xmlNewPI(name: *const xmlChar, content: *const xmlChar) -> *mut _xmlNode {
1517 crate::xml::tree::new_pi(name, content)
1518}
1519
1520#[no_mangle]
1528pub unsafe extern "C" fn xmlNewCDataBlock(
1529 doc: *mut _xmlDoc,
1530 content: *const xmlChar,
1531 len: c_int,
1532) -> *mut _xmlNode {
1533 crate::xml::tree::new_cdata_block(doc, content, len)
1534}
1535
1536#[no_mangle]
1550pub unsafe extern "C" fn xmlNewNs(
1551 node: *mut _xmlNode,
1552 href: *const xmlChar,
1553 prefix: *const xmlChar,
1554) -> *mut _xmlNs {
1555 crate::xml::tree::new_ns(node, href, prefix)
1556}
1557
1558#[no_mangle]
1566pub unsafe extern "C" fn xmlSetNs(node: *mut _xmlNode, ns: *mut _xmlNs) {
1567 crate::xml::tree::set_ns(node, ns);
1568}
1569
1570#[no_mangle]
1578pub unsafe extern "C" fn xmlGetNsList(
1579 doc: *mut _xmlDoc,
1580 node: *const _xmlNode,
1581) -> *mut *mut _xmlNs {
1582 crate::xml::tree::get_ns_list(doc, node as *mut _xmlNode)
1583}
1584
1585#[no_mangle]
1593pub unsafe extern "C" fn xmlSearchNs(
1594 doc: *mut _xmlDoc,
1595 node: *mut _xmlNode,
1596 nameSpace: *const xmlChar,
1597) -> *mut _xmlNs {
1598 crate::xml::tree::search_ns(doc, node, nameSpace)
1599}
1600
1601#[no_mangle]
1609pub unsafe extern "C" fn xmlSearchNsByHref(
1610 doc: *mut _xmlDoc,
1611 node: *mut _xmlNode,
1612 href: *const xmlChar,
1613) -> *mut _xmlNs {
1614 crate::xml::tree::search_ns_by_href(doc, node, href)
1615}
1616
1617#[no_mangle]
1634pub unsafe extern "C" fn xmlSetProp(
1635 node: *mut _xmlNode,
1636 name: *const xmlChar,
1637 value: *const xmlChar,
1638) -> *mut _xmlAttr {
1639 crate::xml::tree::set_prop(node, name, value)
1640}
1641
1642#[no_mangle]
1652pub unsafe extern "C" fn xmlGetProp(node: *const _xmlNode, name: *const xmlChar) -> *mut xmlChar {
1653 crate::xml::tree::get_prop(node as *mut _xmlNode, name)
1654}
1655
1656#[no_mangle]
1664pub unsafe extern "C" fn xmlGetNsProp(
1665 node: *const _xmlNode,
1666 name: *const xmlChar,
1667 nameSpace: *const xmlChar,
1668) -> *mut xmlChar {
1669 crate::xml::tree::get_ns_prop(node as *mut _xmlNode, name, nameSpace)
1670}
1671
1672#[no_mangle]
1681pub unsafe extern "C" fn xmlSetNsProp(
1682 node: *mut _xmlNode,
1683 ns: *mut _xmlNs,
1684 name: *const xmlChar,
1685 value: *const xmlChar,
1686) -> *mut _xmlAttr {
1687 crate::xml::tree::set_ns_prop(node, ns, name, value)
1688}
1689
1690#[no_mangle]
1700pub unsafe extern "C" fn xmlRemoveProp(attr: *mut _xmlAttr) -> c_int {
1701 crate::xml::tree::remove_prop(attr)
1702}
1703
1704#[no_mangle]
1714pub unsafe extern "C" fn xmlHasProp(node: *const _xmlNode, name: *const xmlChar) -> *mut _xmlAttr {
1715 crate::xml::tree::has_prop(node as *mut _xmlNode, name)
1716}
1717
1718#[no_mangle]
1727pub unsafe extern "C" fn xmlHasNsProp(
1728 node: *const _xmlNode,
1729 name: *const xmlChar,
1730 nameSpace: *const xmlChar,
1731) -> *mut _xmlAttr {
1732 crate::xml::tree::has_ns_prop(node as *mut _xmlNode, name, nameSpace)
1733}
1734
1735#[no_mangle]
1745pub unsafe extern "C" fn xmlUnsetProp(node: *mut _xmlNode, name: *const xmlChar) -> c_int {
1746 crate::xml::tree::unset_prop(node, name)
1747}
1748
1749#[no_mangle]
1758pub unsafe extern "C" fn xmlUnsetNsProp(
1759 node: *mut _xmlNode,
1760 name: *const xmlChar,
1761 nameSpace: *const xmlChar,
1762) -> c_int {
1763 crate::xml::tree::unset_ns_prop(node, name, nameSpace)
1764}
1765
1766#[no_mangle]
1774pub unsafe extern "C" fn xmlFirstElementChild(parent: *mut _xmlNode) -> *mut _xmlNode {
1775 crate::xml::tree::first_element_child(parent)
1776}
1777
1778#[no_mangle]
1780pub unsafe extern "C" fn xmlLastElementChild(parent: *mut _xmlNode) -> *mut _xmlNode {
1781 crate::xml::tree::last_element_child(parent)
1782}
1783
1784#[no_mangle]
1786pub unsafe extern "C" fn xmlNextElementSibling(node: *mut _xmlNode) -> *mut _xmlNode {
1787 crate::xml::tree::next_element_sibling(node)
1788}
1789
1790#[no_mangle]
1792pub unsafe extern "C" fn xmlPreviousElementSibling(node: *mut _xmlNode) -> *mut _xmlNode {
1793 crate::xml::tree::previous_element_sibling(node)
1794}
1795
1796#[no_mangle]
1804pub unsafe extern "C" fn xmlChildElementCount(parent: *mut _xmlNode) -> c_ulong {
1805 crate::xml::tree::child_element_count(parent)
1806}
1807
1808#[no_mangle]
1816pub unsafe extern "C" fn xmlTextConcat(
1817 node: *mut _xmlNode,
1818 content: *const xmlChar,
1819 len: c_int,
1820) -> c_int {
1821 crate::xml::tree::text_concat(node, content, len)
1822}
1823
1824#[no_mangle]
1832pub unsafe extern "C" fn xmlTextMerge(
1833 first: *mut _xmlNode,
1834 second: *mut _xmlNode,
1835) -> *mut _xmlNode {
1836 crate::xml::tree::text_merge(first, second)
1837}
1838
1839#[no_mangle]
1847pub extern "C" fn xmlGetIntSubset(doc: *const _xmlDoc) -> *mut _xmlDtd {
1848 crate::xml::tree::get_int_subset(doc)
1849}
1850
1851#[no_mangle]
1860pub unsafe extern "C" fn xmlNewDtd(
1861 doc: *mut _xmlDoc,
1862 name: *const xmlChar,
1863 ExternalID: *const xmlChar,
1864 SystemID: *const xmlChar,
1865) -> *mut _xmlDtd {
1866 crate::xml::tree::new_dtd(doc, name, ExternalID, SystemID)
1867}
1868
1869#[no_mangle]
1879pub unsafe extern "C" fn xmlNewEntity(
1880 doc: *mut _xmlDoc,
1881 name: *const xmlChar,
1882 type_: c_int,
1883 ExternalID: *const xmlChar,
1884 SystemID: *const xmlChar,
1885 content: *const xmlChar,
1886) -> *mut _xmlEntity {
1887 crate::xml::tree::new_entity(doc, name, type_, ExternalID, SystemID, content)
1888}
1889
1890#[no_mangle]
1898pub unsafe extern "C" fn xmlGetDocEntity(
1899 doc: *const _xmlDoc,
1900 name: *const xmlChar,
1901) -> *mut _xmlEntity {
1902 crate::xml::tree::get_doc_entity(doc, name)
1903}
1904
1905#[no_mangle]
1913pub unsafe extern "C" fn xmlGetParameterEntity(
1914 doc: *const _xmlDoc,
1915 name: *const xmlChar,
1916) -> *mut _xmlEntity {
1917 crate::xml::tree::get_parameter_entity(doc, name)
1918}
1919
1920#[no_mangle]
1931pub unsafe extern "C" fn xmlCreateIntSubset(
1932 doc: *mut _xmlDoc,
1933 name: *const xmlChar,
1934 ExternalID: *const xmlChar,
1935 SystemID: *const xmlChar,
1936) -> *mut _xmlDtd {
1937 crate::xml::dtd::create_int_subset(doc, name, ExternalID, SystemID)
1938}
1939
1940#[no_mangle]
1948pub unsafe extern "C" fn xmlFreeDtd(dtd: *mut _xmlDtd) {
1949 crate::xml::dtd::free_dtd(dtd);
1950}
1951
1952#[no_mangle]
1962pub unsafe extern "C" fn xmlAddNotationDecl(
1963 dtd: *mut _xmlDtd,
1964 name: *const xmlChar,
1965 PublicID: *const xmlChar,
1966 SystemID: *const xmlChar,
1967) -> *mut _xmlNotation {
1968 crate::xml::dtd::add_notation_decl(dtd, name, PublicID, SystemID)
1969}
1970
1971#[no_mangle]
1979pub unsafe extern "C" fn xmlGetNotationDecl(
1980 dtd: *mut _xmlDtd,
1981 name: *const xmlChar,
1982) -> *mut _xmlNotation {
1983 crate::xml::dtd::get_notation_decl(dtd, name)
1984}
1985
1986#[no_mangle]
1994pub unsafe extern "C" fn xmlCopyNotation(notation: *mut _xmlNotation) -> *mut _xmlNotation {
1995 crate::xml::dtd::copy_notation(notation)
1996}
1997
1998#[no_mangle]
2006pub unsafe extern "C" fn xmlFreeNotation(notation: *mut _xmlNotation) {
2007 crate::xml::dtd::free_notation(notation);
2008}
2009
2010#[no_mangle]
2019pub unsafe extern "C" fn xmlAddElementDecl(
2020 dtd: *mut _xmlDtd,
2021 name: *const xmlChar,
2022 type_: c_int,
2023 content: *mut _xmlElementContent,
2024) -> *mut _xmlElement {
2025 crate::xml::dtd::add_element_decl(dtd, name, type_, content)
2026}
2027
2028#[no_mangle]
2036pub unsafe extern "C" fn xmlGetElementDecl(
2037 dtd: *mut _xmlDtd,
2038 name: *const xmlChar,
2039) -> *mut _xmlElement {
2040 crate::xml::dtd::get_element_decl(dtd, name)
2041}
2042
2043#[no_mangle]
2051pub unsafe extern "C" fn xmlCopyElement(elem: *mut _xmlElement) -> *mut _xmlElement {
2052 crate::xml::dtd::copy_element(elem)
2053}
2054
2055#[no_mangle]
2063pub unsafe extern "C" fn xmlFreeElement(elem: *mut _xmlElement) {
2064 crate::xml::dtd::free_element(elem);
2065}
2066
2067#[no_mangle]
2078pub unsafe extern "C" fn xmlAddAttributeDecl(
2079 dtd: *mut _xmlDtd,
2080 elem: *mut _xmlElement,
2081 name: *const xmlChar,
2082 type_: c_int,
2083 def: c_int,
2084 defaultValue: *const xmlChar,
2085 tree: *mut _xmlEnumeration,
2086) -> *mut _xmlAttribute {
2087 crate::xml::dtd::add_attribute_decl(dtd, elem, name, type_, def, defaultValue, tree)
2088}
2089
2090#[no_mangle]
2099pub unsafe extern "C" fn xmlGetAttributeDecl(
2100 dtd: *mut _xmlDtd,
2101 elem: *mut _xmlElement,
2102 name: *const xmlChar,
2103 namePrefix: c_int,
2104) -> *mut _xmlAttribute {
2105 crate::xml::dtd::get_attribute_decl(dtd, elem, name, namePrefix)
2106}
2107
2108#[no_mangle]
2116pub unsafe extern "C" fn xmlCopyAttribute(attr: *mut _xmlAttribute) -> *mut _xmlAttribute {
2117 crate::xml::dtd::copy_attribute_decl(attr)
2118}
2119
2120#[no_mangle]
2128pub unsafe extern "C" fn xmlFreeAttribute(attr: *mut _xmlAttribute) {
2129 crate::xml::dtd::free_attribute(attr);
2130}
2131
2132#[no_mangle]
2140pub unsafe extern "C" fn xmlNewElementContent(
2141 name: *const xmlChar,
2142 type_: c_int,
2143) -> *mut _xmlElementContent {
2144 crate::xml::dtd::create_content_model(name, type_)
2145}
2146
2147#[no_mangle]
2155pub unsafe extern "C" fn xmlCopyElementContent(
2156 content: *mut _xmlElementContent,
2157) -> *mut _xmlElementContent {
2158 crate::xml::dtd::copy_content_model(content)
2159}
2160
2161#[no_mangle]
2169pub unsafe extern "C" fn xmlFreeElementContent(cur: *mut _xmlElementContent) {
2170 crate::xml::dtd::free_content_model(cur);
2171}
2172
2173#[no_mangle]
2185pub unsafe extern "C" fn xmlAddEntity(
2186 dtd: *mut _xmlDtd,
2187 name: *const xmlChar,
2188 type_: c_int,
2189 ExternalID: *const xmlChar,
2190 SystemID: *const xmlChar,
2191 content: *const xmlChar,
2192) -> *mut _xmlEntity {
2193 crate::xml::entities::add_entity(dtd, name, type_, ExternalID, SystemID, content)
2194}
2195
2196#[no_mangle]
2208pub unsafe extern "C" fn xmlAddDocEntity(
2209 doc: *mut _xmlDoc,
2210 name: *const xmlChar,
2211 type_: c_int,
2212 ExternalID: *const xmlChar,
2213 SystemID: *const xmlChar,
2214 content: *const xmlChar,
2215) -> *mut _xmlEntity {
2216 crate::xml::tree::add_doc_entity(doc, name, type_, ExternalID, SystemID, content)
2217}
2218
2219#[no_mangle]
2230pub unsafe extern "C" fn xmlAddDtdEntity(
2231 doc: *mut _xmlDoc,
2232 name: *const xmlChar,
2233 type_: c_int,
2234 ExternalID: *const xmlChar,
2235 SystemID: *const xmlChar,
2236 content: *const xmlChar,
2237) -> *mut _xmlEntity {
2238 crate::xml::tree::add_dtd_entity(doc, name, type_, ExternalID, SystemID, content)
2239}
2240
2241#[no_mangle]
2250pub unsafe extern "C" fn xmlGetDtdEntity(
2251 doc: *mut _xmlDoc,
2252 name: *const xmlChar,
2253) -> *mut _xmlEntity {
2254 crate::xml::tree::get_dtd_entity(doc, name)
2255}
2256
2257#[no_mangle]
2265pub unsafe extern "C" fn xmlGetEntity(doc: *mut _xmlDoc, name: *const xmlChar) -> *mut _xmlEntity {
2266 crate::xml::entities::get_entity(doc, name)
2267}
2268
2269#[no_mangle]
2277pub unsafe extern "C" fn xmlCopyEntity(entity: *mut _xmlEntity) -> *mut _xmlEntity {
2278 crate::xml::entities::copy_entity(entity)
2279}
2280
2281#[no_mangle]
2289pub unsafe extern "C" fn xmlFreeEntity(entity: *mut _xmlEntity) {
2290 crate::xml::entities::free_entity(entity);
2291}
2292
2293#[no_mangle]
2301pub unsafe extern "C" fn xmlEncodeEntitiesReentrant(
2302 doc: *mut _xmlDoc,
2303 input: *const xmlChar,
2304) -> *mut xmlChar {
2305 crate::xml::entities::encode_entities_reentrant(doc, input)
2306}
2307
2308#[no_mangle]
2319pub unsafe extern "C" fn xmlEncodeSpecialChars(
2320 _doc: *const _xmlDoc,
2321 input: *const xmlChar,
2322) -> *mut xmlChar {
2323 if input.is_null() {
2324 return ptr::null_mut();
2325 }
2326 unsafe {
2327 let len = crate::xml::string::xml_strlen(input);
2328 let cap = len * 6 + 1;
2331 let out = crate::abi::allocator::xmlMallocImpl(cap) as *mut xmlChar;
2332 if out.is_null() {
2333 return ptr::null_mut();
2334 }
2335 let mut o = 0usize;
2336 let mut i = 0usize;
2337 while i < len {
2338 let c = *input.add(i);
2339 let rep: &[u8] = match c {
2340 b'<' => b"<",
2341 b'>' => b">",
2342 b'&' => b"&",
2343 b'"' => b""",
2344 b'\r' => b" ",
2345 _ => {
2346 *out.add(o) = c;
2347 o += 1;
2348 i += 1;
2349 continue;
2350 }
2351 };
2352 core::ptr::copy_nonoverlapping(rep.as_ptr(), out.add(o), rep.len());
2353 o += rep.len();
2354 i += 1;
2355 }
2356 *out.add(o) = 0;
2357 out
2358 }
2359}
2360
2361#[no_mangle]
2372pub unsafe extern "C" fn xmlEncodeEntities(
2373 _doc: *mut _xmlDoc,
2374 _input: *const xmlChar,
2375) -> *mut xmlChar {
2376 use core::sync::atomic::{AtomicBool, Ordering};
2377 static WARNED: AtomicBool = AtomicBool::new(false);
2378 if !WARNED.swap(true, Ordering::Relaxed) {
2379 let msg = b"xmlEncodeEntities is deprecated, use xmlEncodeSpecialChars or xmlEncodeEntitiesReentrant\n";
2381 unsafe {
2382 libc::fwrite(
2383 msg.as_ptr() as *const c_void,
2384 1,
2385 msg.len(),
2386 libc::fdopen(2, b"w\0" as *const u8 as *const c_char) as *mut libc::FILE,
2387 );
2388 }
2389 }
2390 ptr::null_mut()
2391}
2392
2393#[no_mangle]
2401pub extern "C" fn xmlGetLineNo(node: *const _xmlNode) -> c_int {
2402 crate::xml::tree::get_line_no(node)
2403}
2404
2405#[no_mangle]
2417pub unsafe extern "C" fn xmlNodeDump(
2418 buf: *mut _xmlBuffer,
2419 doc: *mut _xmlDoc,
2420 cur: *mut _xmlNode,
2421 level: c_int,
2422 format: c_int,
2423) -> c_int {
2424 if buf.is_null() || cur.is_null() {
2425 return -1;
2426 }
2427 crate::xml::tree::xmlNodeDump(buf, doc, cur, level, format)
2428}
2429
2430#[no_mangle]
2438pub unsafe extern "C" fn xmlDocDump(fp: *mut c_void, doc: *mut _xmlDoc) -> c_int {
2439 if fp.is_null() || doc.is_null() {
2440 return -1;
2441 }
2442 crate::xml::tree::xmlDocDump(fp, doc)
2443}
2444
2445#[no_mangle]
2453pub unsafe extern "C" fn xmlDocDumpFormatMemory(
2454 doc: *mut _xmlDoc,
2455 mem: *mut *mut xmlChar,
2456 size: *mut c_int,
2457 format: c_int,
2458) {
2459 if doc.is_null() || mem.is_null() || size.is_null() {
2460 return;
2461 }
2462 crate::xml::tree::xmlDocDumpFormatMemory(doc, mem, size, format)
2463}
2464
2465#[no_mangle]
2473pub unsafe extern "C" fn xmlDocDumpMemory(
2474 doc: *mut _xmlDoc,
2475 mem: *mut *mut xmlChar,
2476 size: *mut c_int,
2477) {
2478 if doc.is_null() || mem.is_null() || size.is_null() {
2479 return;
2480 }
2481 crate::xml::tree::xmlDocDumpMemory(doc, mem, size)
2482}
2483
2484#[no_mangle]
2492pub unsafe extern "C" fn xmlSaveFile(filename: *const c_char, cur: *mut _xmlDoc) -> c_int {
2493 if filename.is_null() || cur.is_null() {
2494 return -1;
2495 }
2496 crate::xml::tree::xmlSaveFile(filename, cur)
2497}
2498
2499#[no_mangle]
2507pub unsafe extern "C" fn xmlSaveFileEnc(
2508 filename: *const c_char,
2509 cur: *mut _xmlDoc,
2510 encoding: *const c_char,
2511) -> c_int {
2512 if filename.is_null() || cur.is_null() {
2513 return -1;
2514 }
2515 crate::xml::tree::xmlSaveFileEnc(filename, cur, encoding)
2516}
2517
2518#[no_mangle]
2526pub unsafe extern "C" fn xmlSaveFormatFile(
2527 filename: *const c_char,
2528 cur: *mut _xmlDoc,
2529 format: c_int,
2530) -> c_int {
2531 if filename.is_null() || cur.is_null() {
2532 return -1;
2533 }
2534 crate::xml::tree::xmlSaveFormatFile(filename, cur, format)
2535}
2536
2537#[no_mangle]
2545pub unsafe extern "C" fn xmlSaveFormatFileEnc(
2546 filename: *const c_char,
2547 cur: *mut _xmlDoc,
2548 encoding: *const c_char,
2549 format: c_int,
2550) -> c_int {
2551 if filename.is_null() || cur.is_null() {
2552 return -1;
2553 }
2554 crate::xml::tree::xmlSaveFormatFileEnc(filename, cur, encoding, format)
2555}
2556
2557#[no_mangle]
2572pub unsafe extern "C" fn xmlReadDoc(
2573 cur: *const xmlChar,
2574 URL: *const c_char,
2575 encoding: *const c_char,
2576 options: c_int,
2577) -> *mut _xmlDoc {
2578 if cur.is_null() {
2580 return ptr::null_mut();
2581 }
2582 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2583 if ctxt.is_null() {
2584 return ptr::null_mut();
2585 }
2586 let len = crate::xml::string::xml_strlen(cur);
2587 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2588 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2589 (*ctxt).options = options;
2590 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2591 let doc = (*ctxt).myDoc;
2592 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2593 return doc;
2594 }
2595 let doc = (*ctxt).myDoc;
2596 if !doc.is_null() {
2597 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2598 }
2599 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2600 doc
2601}
2602
2603#[no_mangle]
2611pub unsafe extern "C" fn xmlReadFile(
2612 URL: *const c_char,
2613 encoding: *const c_char,
2614 options: c_int,
2615) -> *mut _xmlDoc {
2616 if URL.is_null() {
2618 return ptr::null_mut();
2619 }
2620 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2621 if ctxt.is_null() {
2622 return ptr::null_mut();
2623 }
2624 let input = match crate::xml::parser::helpers::input_from_file(URL) {
2625 Ok(input) => input,
2626 Err(_) => {
2627 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2628 return ptr::null_mut();
2629 }
2630 };
2631 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2632 (*ctxt).options = options;
2633 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2634 let doc = (*ctxt).myDoc;
2635 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2636 if options & 1 << 0 != 0 {
2640 return doc;
2641 }
2642 if !doc.is_null() {
2643 crate::xml::tree::free_doc(doc);
2644 }
2645 return ptr::null_mut();
2646 }
2647 let doc = (*ctxt).myDoc;
2648 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2649 doc
2650}
2651
2652#[no_mangle]
2661pub unsafe extern "C" fn xmlRecoverDoc(cur: *const xmlChar) -> *mut _xmlDoc {
2662 unsafe { xmlReadDoc(cur, ptr::null(), ptr::null(), 1 << 0) }
2663}
2664
2665#[no_mangle]
2673pub unsafe extern "C" fn xmlRecoverFile(filename: *const c_char) -> *mut _xmlDoc {
2674 unsafe { xmlReadFile(filename, ptr::null(), 1 << 0) }
2675}
2676
2677#[no_mangle]
2685pub unsafe extern "C" fn xmlRecoverMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
2686 unsafe { xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 1 << 0) }
2687}
2688
2689#[no_mangle]
2698pub unsafe extern "C" fn xmlReadMemory(
2699 buffer: *const c_char,
2700 size: c_int,
2701 URL: *const c_char,
2702 encoding: *const c_char,
2703 options: c_int,
2704) -> *mut _xmlDoc {
2705 if buffer.is_null() || size < 0 {
2709 return ptr::null_mut();
2710 }
2711 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2712 if ctxt.is_null() {
2713 return ptr::null_mut();
2714 }
2715 let input = crate::xml::parser::helpers::input_from_memory_named(buffer, size, URL);
2718 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2719 (*ctxt).options = options;
2720 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2721 let doc = (*ctxt).myDoc;
2722 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2723 if options & 1 << 0 != 0 {
2727 return doc;
2728 }
2729 if !doc.is_null() {
2730 crate::xml::tree::free_doc(doc);
2731 }
2732 return ptr::null_mut();
2733 }
2734 let doc = (*ctxt).myDoc;
2735 if !doc.is_null() && !URL.is_null() {
2736 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2737 }
2738 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2739 doc
2740}
2741
2742#[no_mangle]
2748pub unsafe extern "C" fn xmlLoadCatalogs(catalogs: *const c_char) {
2749 if !catalogs.is_null() {
2750 crate::xml::catalog::load_catalog(catalogs);
2751 }
2752}
2753
2754#[no_mangle]
2760pub unsafe extern "C" fn xmlLoadCatalog(catalogs: *const c_char) -> *mut c_void {
2761 crate::xml::catalog::load_catalog(catalogs)
2762}
2763
2764#[no_mangle]
2772pub unsafe extern "C" fn xmlReadFd(
2773 fd: c_int,
2774 URL: *const c_char,
2775 encoding: *const c_char,
2776 options: c_int,
2777) -> *mut _xmlDoc {
2778 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2780 if ctxt.is_null() {
2781 return ptr::null_mut();
2782 }
2783 let mut buf = Vec::new();
2785 let mut tmp = [0u8; 4096];
2786 loop {
2787 let n = libc::read(fd, tmp.as_mut_ptr() as *mut c_void, tmp.len());
2788 if n <= 0 {
2789 break;
2790 }
2791 buf.extend_from_slice(&tmp[..n as usize]);
2792 }
2793 let input = crate::xml::parser::helpers::input_from_memory(
2794 buf.as_ptr() as *const c_char,
2795 buf.len() as c_int,
2796 );
2797 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2798 (*ctxt).options = options;
2799 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2800 let doc = (*ctxt).myDoc;
2801 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2802 return doc;
2803 }
2804 let doc = (*ctxt).myDoc;
2805 if !doc.is_null() && !URL.is_null() {
2806 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2807 }
2808 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2809 doc
2810}
2811
2812#[no_mangle]
2821pub unsafe extern "C" fn xmlReadIO(
2822 ioread: Option<xmlInputReadCallback>,
2823 ioclose: Option<xmlInputCloseCallback>,
2824 ioctx: *mut c_void,
2825 URL: *const c_char,
2826 encoding: *const c_char,
2827 options: c_int,
2828) -> *mut _xmlDoc {
2829 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2831 if ctxt.is_null() {
2832 return ptr::null_mut();
2833 }
2834 let input = crate::xml::parser::helpers::input_from_io(ioread, ioclose, ioctx);
2835 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2836 (*ctxt).options = options;
2837 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2838 let doc = (*ctxt).myDoc;
2839 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2840 return doc;
2841 }
2842 let doc = (*ctxt).myDoc;
2843 if !doc.is_null() && !URL.is_null() {
2844 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2845 }
2846 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2847 doc
2848}
2849
2850#[no_mangle]
2858pub unsafe extern "C" fn xmlSAXParseDoc(
2859 sax: *mut _xmlSAXHandler,
2860 cur: *const xmlChar,
2861 recovery: c_int,
2862) -> *mut _xmlDoc {
2863 if cur.is_null() {
2865 return ptr::null_mut();
2866 }
2867 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2868 if ctxt.is_null() {
2869 return ptr::null_mut();
2870 }
2871 if !sax.is_null() {
2872 (*ctxt).sax = sax;
2873 (*ctxt).userData = (*ctxt).sax as *mut c_void;
2874 }
2875 if recovery != 0 {
2876 (*ctxt).recovery = 1;
2877 (*ctxt).options |= 1; }
2879 let len = crate::xml::string::xml_strlen(cur);
2880 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2881 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2882 crate::xml::parser::helpers::parse_document(ctxt);
2883 let doc = (*ctxt).myDoc;
2884 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2885 doc
2886}
2887
2888#[no_mangle]
2898pub unsafe extern "C" fn xmlSAXParseDocWithData(
2899 sax: *mut _xmlSAXHandler,
2900 cur: *const xmlChar,
2901 recovery: c_int,
2902 data: *mut c_void,
2903) -> *mut _xmlDoc {
2904 if cur.is_null() {
2906 return ptr::null_mut();
2907 }
2908 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2909 if ctxt.is_null() {
2910 return ptr::null_mut();
2911 }
2912 if !sax.is_null() {
2913 (*ctxt).sax = sax;
2914 }
2915 (*ctxt).userData = data;
2916 if recovery != 0 {
2917 (*ctxt).recovery = 1;
2918 (*ctxt).options |= 1; }
2920 let len = crate::xml::string::xml_strlen(cur);
2921 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2922 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2923 crate::xml::parser::helpers::parse_document(ctxt);
2924 let doc = (*ctxt).myDoc;
2925 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2926 doc
2927}
2928
2929#[no_mangle]
2939pub unsafe extern "C" fn xmlSAXParseFileWithData(
2940 sax: *mut _xmlSAXHandler,
2941 filename: *const c_char,
2942 recovery: c_int,
2943 data: *mut c_void,
2944) -> *mut _xmlDoc {
2945 if filename.is_null() {
2947 return ptr::null_mut();
2948 }
2949 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2950 if ctxt.is_null() {
2951 return ptr::null_mut();
2952 }
2953 if !sax.is_null() {
2954 (*ctxt).sax = sax;
2955 }
2956 (*ctxt).userData = data;
2957 if recovery != 0 {
2958 (*ctxt).recovery = 1;
2959 (*ctxt).options |= 1; }
2961 let input = match crate::xml::parser::helpers::input_from_file(filename) {
2962 Ok(input) => input,
2963 Err(_) => {
2964 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2965 return ptr::null_mut();
2966 }
2967 };
2968 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2969 crate::xml::parser::helpers::parse_document(ctxt);
2970 let doc = (*ctxt).myDoc;
2971 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2972 doc
2973}
2974
2975#[no_mangle]
2985pub unsafe extern "C" fn xmlSAXParseMemoryWithData(
2986 sax: *mut _xmlSAXHandler,
2987 buffer: *const c_char,
2988 size: c_int,
2989 recovery: c_int,
2990 data: *mut c_void,
2991) -> *mut _xmlDoc {
2992 if buffer.is_null() || size <= 0 {
2994 return ptr::null_mut();
2995 }
2996 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2997 if ctxt.is_null() {
2998 return ptr::null_mut();
2999 }
3000 if !sax.is_null() {
3001 (*ctxt).sax = sax;
3002 }
3003 (*ctxt).userData = data;
3004 if recovery != 0 {
3005 (*ctxt).recovery = 1;
3006 (*ctxt).options |= 1; }
3008 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3009 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3010 crate::xml::parser::helpers::parse_document(ctxt);
3011 let doc = (*ctxt).myDoc;
3012 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3013 doc
3014}
3015
3016#[no_mangle]
3024pub unsafe extern "C" fn xmlSAXParseFile(
3025 sax: *mut _xmlSAXHandler,
3026 filename: *const c_char,
3027 recovery: c_int,
3028) -> *mut _xmlDoc {
3029 if filename.is_null() {
3031 return ptr::null_mut();
3032 }
3033 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3034 if ctxt.is_null() {
3035 return ptr::null_mut();
3036 }
3037 if !sax.is_null() {
3038 (*ctxt).sax = sax;
3039 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3040 }
3041 if recovery != 0 {
3042 (*ctxt).recovery = 1;
3043 (*ctxt).options |= 1;
3044 }
3045 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3046 Ok(input) => input,
3047 Err(_) => {
3048 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3049 return ptr::null_mut();
3050 }
3051 };
3052 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3053 crate::xml::parser::helpers::parse_document(ctxt);
3054 let doc = (*ctxt).myDoc;
3055 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3056 doc
3057}
3058
3059#[no_mangle]
3068pub unsafe extern "C" fn xmlSAXParseMemory(
3069 sax: *mut _xmlSAXHandler,
3070 buffer: *const c_char,
3071 size: c_int,
3072 recovery: c_int,
3073) -> *mut _xmlDoc {
3074 if buffer.is_null() || size <= 0 {
3076 return ptr::null_mut();
3077 }
3078 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3079 if ctxt.is_null() {
3080 return ptr::null_mut();
3081 }
3082 if !sax.is_null() {
3083 (*ctxt).sax = sax;
3084 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3085 }
3086 if recovery != 0 {
3087 (*ctxt).recovery = 1;
3088 (*ctxt).options |= 1;
3089 }
3090 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3091 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3092 crate::xml::parser::helpers::parse_document(ctxt);
3093 let doc = (*ctxt).myDoc;
3094 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3095 doc
3096}
3097
3098#[no_mangle]
3107pub unsafe extern "C" fn xmlSAXUserParseFile(
3108 sax: *mut _xmlSAXHandler,
3109 user_data: *mut c_void,
3110 filename: *const c_char,
3111) -> c_int {
3112 if filename.is_null() {
3114 return -1;
3115 }
3116 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3117 if ctxt.is_null() {
3118 return -1;
3119 }
3120 if !sax.is_null() {
3121 (*ctxt).sax = sax;
3122 }
3123 (*ctxt).userData = if !user_data.is_null() {
3124 user_data
3125 } else {
3126 ctxt as *mut c_void
3127 };
3128 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3129 Ok(input) => input,
3130 Err(_) => {
3131 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3132 return -1;
3133 }
3134 };
3135 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3136 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3137 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3138 ret
3139}
3140
3141#[no_mangle]
3150pub unsafe extern "C" fn xmlSAXUserParseMemory(
3151 sax: *mut _xmlSAXHandler,
3152 user_data: *mut c_void,
3153 buffer: *const c_char,
3154 size: c_int,
3155) -> c_int {
3156 if buffer.is_null() || size <= 0 {
3158 return -1;
3159 }
3160 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3161 if ctxt.is_null() {
3162 return -1;
3163 }
3164 if !sax.is_null() {
3165 (*ctxt).sax = sax;
3166 }
3167 (*ctxt).userData = if !user_data.is_null() {
3168 user_data
3169 } else {
3170 ctxt as *mut c_void
3171 };
3172 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3173 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3174 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3175 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3176 ret
3177}
3178
3179#[no_mangle]
3187pub unsafe extern "C" fn xmlParseDoc(cur: *const xmlChar) -> *mut _xmlDoc {
3188 if cur.is_null() {
3190 return ptr::null_mut();
3191 }
3192 xmlReadDoc(cur, ptr::null(), ptr::null(), 0)
3193}
3194
3195#[no_mangle]
3203pub unsafe extern "C" fn xmlParseFile(filename: *const c_char) -> *mut _xmlDoc {
3204 if filename.is_null() {
3206 return ptr::null_mut();
3207 }
3208 xmlReadFile(filename, ptr::null(), 0)
3209}
3210
3211#[no_mangle]
3219pub unsafe extern "C" fn xmlParseMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
3220 if buffer.is_null() || size <= 0 {
3222 return ptr::null_mut();
3223 }
3224 xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 0)
3225}
3226
3227#[no_mangle]
3235pub unsafe extern "C" fn xmlCreateFileParserCtxt(filename: *const c_char) -> *mut _xmlParserCtxt {
3236 if filename.is_null() {
3238 return ptr::null_mut();
3239 }
3240 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3241 if ctxt.is_null() {
3242 return ptr::null_mut();
3243 }
3244 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3245 Ok(input) => input,
3246 Err(_) => {
3247 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3248 return ptr::null_mut();
3249 }
3250 };
3251 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3252 ctxt
3253}
3254
3255#[no_mangle]
3263pub unsafe extern "C" fn xmlCreateDocParserCtxt(cur: *const xmlChar) -> *mut _xmlParserCtxt {
3264 if cur.is_null() {
3266 return ptr::null_mut();
3267 }
3268 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3269 if ctxt.is_null() {
3270 return ptr::null_mut();
3271 }
3272 let len = crate::xml::string::xml_strlen(cur);
3273 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
3274 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3275 ctxt
3276}
3277
3278#[no_mangle]
3286pub unsafe extern "C" fn xmlParseDocument(ctxt: *mut _xmlParserCtxt) -> c_int {
3287 if ctxt.is_null() {
3289 return -1;
3290 }
3291 crate::xml::parser::helpers::parse_document(ctxt)
3292}
3293
3294#[no_mangle]
3302pub unsafe extern "C" fn xmlFreeParserCtxt(ctxt: *mut _xmlParserCtxt) {
3303 if ctxt.is_null() {
3304 return;
3305 }
3306 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3307}
3308
3309#[no_mangle]
3317pub unsafe extern "C" fn xmlCtxtUseOptions(ctxt: *mut _xmlParserCtxt, options: c_int) -> c_int {
3318 if ctxt.is_null() {
3319 return -1;
3320 }
3321 unsafe {
3323 (*ctxt).options = options;
3324 }
3325 0
3326}
3327
3328#[no_mangle]
3337pub unsafe extern "C" fn xmlParseChunk(
3338 ctxt: *mut _xmlParserCtxt,
3339 chunk: *const c_char,
3340 size: c_int,
3341 terminate: c_int,
3342) -> c_int {
3343 if ctxt.is_null() {
3346 return -1;
3347 }
3348 crate::xml::parser::helpers::parse_chunk(ctxt, chunk, size, terminate)
3349}
3350
3351#[no_mangle]
3359pub unsafe extern "C" fn xmlParserInputBufferCreateMem(
3360 buffer: *const c_char,
3361 size: c_int,
3362 enc: c_int,
3363) -> *mut _xmlParserInputBuffer {
3364 if buffer.is_null() || size <= 0 {
3366 return ptr::null_mut();
3367 }
3368 crate::xml::parser::helpers::alloc_parser_input_buffer()
3369}
3370
3371#[no_mangle]
3379pub unsafe extern "C" fn xmlParserInputBufferCreateFilename(
3380 URI: *const c_char,
3381 enc: c_int,
3382) -> *mut _xmlParserInputBuffer {
3383 if URI.is_null() {
3385 return ptr::null_mut();
3386 }
3387 crate::xml::parser::helpers::alloc_parser_input_buffer()
3388}
3389
3390#[no_mangle]
3400pub unsafe extern "C" fn xmlParserInputBufferCreateIO(
3401 ioread: Option<xmlInputReadCallback>,
3402 ioclose: Option<xmlInputCloseCallback>,
3403 ioctx: *mut c_void,
3404 enc: c_int,
3405) -> *mut _xmlParserInputBuffer {
3406 let buf = crate::xml::parser::helpers::alloc_parser_input_buffer();
3408 if !buf.is_null() {
3409 (*buf).readcallback = ioread;
3410 (*buf).closecallback = ioclose;
3411 (*buf).context = ioctx;
3412 }
3413 buf
3414}
3415
3416#[no_mangle]
3424pub unsafe extern "C" fn xmlFreeParserInputBuffer(buf: *mut _xmlParserInputBuffer) {
3425 if buf.is_null() {
3426 return;
3427 }
3428 crate::xml::parser::helpers::free_parser_input_buffer(buf);
3429}
3430
3431#[no_mangle]
3439pub unsafe extern "C" fn xmlNewInputFromFile(
3440 ctxt: *mut _xmlParserCtxt,
3441 filename: *const c_char,
3442) -> *mut _xmlParserInput {
3443 if filename.is_null() {
3448 return ptr::null_mut();
3449 }
3450 crate::xml::parser::helpers::alloc_parser_input_buffer() as *mut _xmlParserInput
3451}
3452
3453#[no_mangle]
3461pub unsafe extern "C" fn xmlFreeInputStream(input: *mut _xmlParserInput) {
3462 if input.is_null() {
3463 return;
3464 }
3465 crate::xml::parser::helpers::free_parser_input(input);
3466}
3467
3468#[no_mangle]
3482pub unsafe extern "C" fn xmlOutputBufferCreateFilename(
3483 URI: *const c_char,
3484 encoder: *mut c_void,
3485 compression: c_int,
3486) -> *mut _xmlOutputBuffer {
3487 let _ = compression;
3488 if URI.is_null() {
3489 return ptr::null_mut();
3490 }
3491 crate::xml::io::output_buffer_create_filename(
3492 URI,
3493 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3494 0,
3495 )
3496}
3497
3498#[no_mangle]
3507pub unsafe extern "C" fn xmlOutputBufferCreateFd(
3508 fd: c_int,
3509 encoder: *mut c_void,
3510) -> *mut _xmlOutputBuffer {
3511 if fd < 0 {
3512 return ptr::null_mut();
3513 }
3514 crate::xml::io::output_buffer_create_fd(
3515 fd,
3516 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3517 )
3518}
3519
3520#[no_mangle]
3530pub unsafe extern "C" fn xmlOutputBufferCreateIO(
3531 iowrite: Option<xmlOutputWriteCallback>,
3532 ioclose: Option<xmlOutputCloseCallback>,
3533 ioctx: *mut c_void,
3534 encoder: *mut c_void,
3535) -> *mut _xmlOutputBuffer {
3536 crate::xml::io::output_buffer_create_io(
3537 iowrite,
3538 ioclose,
3539 ioctx,
3540 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3541 )
3542}
3543
3544#[no_mangle]
3552pub unsafe extern "C" fn xmlOutputBufferClose(out: *mut _xmlOutputBuffer) -> c_int {
3553 if out.is_null() {
3554 return -1;
3555 }
3556 crate::xml::io::output_buffer_close(out)
3557}
3558
3559#[no_mangle]
3567pub unsafe extern "C" fn xmlOutputBufferFlush(out: *mut _xmlOutputBuffer) -> c_int {
3568 if out.is_null() {
3569 return -1;
3570 }
3571 crate::xml::io::output_buffer_flush(out)
3572}
3573
3574#[no_mangle]
3582pub unsafe extern "C" fn xmlOutputBufferWrite(
3583 out: *mut _xmlOutputBuffer,
3584 len: c_int,
3585 data: *const c_char,
3586) -> c_int {
3587 if out.is_null() || data.is_null() || len <= 0 {
3588 return -1;
3589 }
3590 crate::xml::io::output_buffer_write(out, len, data)
3591}
3592
3593#[no_mangle]
3601pub unsafe extern "C" fn xmlOutputBufferWriteString(
3602 out: *mut _xmlOutputBuffer,
3603 str: *const c_char,
3604) -> c_int {
3605 if str.is_null() {
3606 return 0;
3607 }
3608 unsafe { xmlOutputBufferWrite(out, xmlStrlen(str as *const xmlChar), str) }
3609}
3610
3611#[no_mangle]
3619pub unsafe extern "C" fn xmlAllocOutputBuffer(encoder: *mut c_void) -> *mut _xmlOutputBuffer {
3620 crate::xml::io::output_buffer_create(
3621 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3622 )
3623}
3624
3625#[no_mangle]
3639pub unsafe extern "C" fn xmlOutputBufferCreateBuffer(
3640 buffer: *mut crate::abi::structs::_xmlBuffer,
3641 encoder: *mut c_void,
3642) -> *mut _xmlOutputBuffer {
3643 crate::xml::io::output_buffer_create_buffer(
3644 buffer,
3645 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3646 )
3647}
3648
3649#[no_mangle]
3657pub unsafe extern "C" fn xmlOutputBufferCreateFile(
3658 file: *mut libc::FILE,
3659 encoder: *mut c_void,
3660) -> *mut _xmlOutputBuffer {
3661 crate::xml::io::output_buffer_create_file(
3662 file,
3663 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3664 )
3665}
3666
3667#[no_mangle]
3673pub unsafe extern "C" fn xmlOutputBufferGetContent(out: *mut _xmlOutputBuffer) -> *const c_char {
3674 crate::xml::io::output_buffer_get_content(out) as *const c_char
3675}
3676
3677#[no_mangle]
3684pub unsafe extern "C" fn xmlOutputBufferGetSize(out: *mut _xmlOutputBuffer) -> c_int {
3685 crate::xml::io::output_buffer_get_size(out)
3686}
3687
3688#[no_mangle]
3696pub unsafe extern "C" fn xmlOutputBufferWriteEscape(
3697 out: *mut _xmlOutputBuffer,
3698 str: *const xmlChar,
3699 escaping: Option<xmlCharEncodingOutputFunc>,
3700) -> c_int {
3701 if out.is_null() || str.is_null() {
3702 return -1;
3703 }
3704 crate::xml::io::output_buffer_write_escape(out, str, escaping)
3705}
3706
3707static mut OUTPUT_CREATE_FILENAME_DEFAULT: Option<
3710 unsafe extern "C" fn(
3711 *const c_char,
3712 *mut crate::abi::structs::_xmlCharEncodingHandler,
3713 c_int,
3714 ) -> *mut _xmlOutputBuffer,
3715> = None;
3716
3717#[no_mangle]
3724pub unsafe extern "C" fn xmlOutputBufferCreateFilenameDefault(
3725 func: Option<
3726 unsafe extern "C" fn(
3727 *const c_char,
3728 *mut crate::abi::structs::_xmlCharEncodingHandler,
3729 c_int,
3730 ) -> *mut _xmlOutputBuffer,
3731 >,
3732) -> Option<
3733 unsafe extern "C" fn(
3734 *const c_char,
3735 *mut crate::abi::structs::_xmlCharEncodingHandler,
3736 c_int,
3737 ) -> *mut _xmlOutputBuffer,
3738> {
3739 let old = unsafe { OUTPUT_CREATE_FILENAME_DEFAULT };
3740 if func.is_some() {
3741 unsafe { OUTPUT_CREATE_FILENAME_DEFAULT = func };
3742 }
3743 old
3744}
3745
3746#[no_mangle]
3749pub unsafe extern "C" fn __xmlOutputBufferCreateFilename() -> *mut Option<
3750 unsafe extern "C" fn(
3751 *const c_char,
3752 *mut crate::abi::structs::_xmlCharEncodingHandler,
3753 c_int,
3754 ) -> *mut _xmlOutputBuffer,
3755> {
3756 unsafe { core::ptr::addr_of_mut!(OUTPUT_CREATE_FILENAME_DEFAULT) }
3757}
3758
3759#[no_mangle]
3771pub extern "C" fn xmlDictCreate() -> *mut c_void {
3772 unsafe { crate::xml::dictionary::dict_create() as *mut c_void }
3773}
3774
3775#[no_mangle]
3783pub extern "C" fn xmlDictCreateSub(sub: *mut c_void) -> *mut c_void {
3784 unsafe {
3785 crate::xml::dictionary::dict_create_sub(sub as *mut crate::xml::dictionary::Dict)
3786 as *mut c_void
3787 }
3788}
3789
3790#[no_mangle]
3802pub unsafe extern "C" fn xmlDictLookup(
3803 dict: *mut c_void,
3804 name: *const xmlChar,
3805 len: c_int,
3806) -> *const xmlChar {
3807 unsafe {
3808 crate::xml::dictionary::dict_lookup(dict as *mut crate::xml::dictionary::Dict, name, len)
3809 }
3810}
3811
3812#[no_mangle]
3820pub unsafe extern "C" fn xmlDictExists(
3821 dict: *mut c_void,
3822 name: *const xmlChar,
3823 len: c_int,
3824) -> *const xmlChar {
3825 unsafe {
3826 crate::xml::dictionary::dict_exists(dict as *mut crate::xml::dictionary::Dict, name, len)
3827 }
3828}
3829
3830#[no_mangle]
3838pub extern "C" fn xmlDictSize(dict: *const c_void) -> c_uint {
3839 unsafe {
3840 crate::xml::dictionary::dict_size(dict as *const crate::xml::dictionary::Dict) as c_uint
3841 }
3842}
3843
3844#[no_mangle]
3852pub extern "C" fn xmlDictFree(dict: *mut c_void) {
3853 unsafe { crate::xml::dictionary::dict_free(dict as *mut crate::xml::dictionary::Dict) }
3854}
3855
3856#[no_mangle]
3864pub extern "C" fn xmlDictSetLimit(dict: *mut c_void, limit: c_uint) -> c_uint {
3865 unsafe {
3866 crate::xml::dictionary::dict_set_limit(
3867 dict as *mut crate::xml::dictionary::Dict,
3868 limit as usize,
3869 ) as c_uint
3870 }
3871}
3872
3873#[no_mangle]
3881pub extern "C" fn xmlDictGetUsage(dict: *const c_void) -> c_uint {
3882 unsafe {
3883 crate::xml::dictionary::dict_get_usage(dict as *mut crate::xml::dictionary::Dict) as c_uint
3884 }
3885}
3886
3887#[no_mangle]
3899pub extern "C" fn xmlHashCreate(size: c_int) -> *mut c_void {
3900 unsafe { crate::xml::hash::hash_create(size) as *mut c_void }
3901}
3902
3903#[no_mangle]
3911pub extern "C" fn xmlHashCreateDict(size: c_int, dict: *mut c_void) -> *mut c_void {
3912 unsafe { crate::xml::hash::hash_create_dict(size, dict) as *mut c_void }
3913}
3914
3915#[no_mangle]
3923pub extern "C" fn xmlHashFree(
3924 table: *mut c_void,
3925 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
3926) {
3927 unsafe { crate::xml::hash::hash_free(table as *mut crate::xml::hash::HashTable, f) }
3928}
3929
3930#[no_mangle]
3938pub unsafe extern "C" fn xmlHashAddEntry(
3939 table: *mut c_void,
3940 name: *const xmlChar,
3941 userdata: *mut c_void,
3942) -> c_int {
3943 unsafe {
3944 crate::xml::hash::hash_add_entry(table as *mut crate::xml::hash::HashTable, name, userdata)
3945 }
3946}
3947
3948#[no_mangle]
3957pub unsafe extern "C" fn xmlHashAddEntry2(
3958 table: *mut c_void,
3959 name: *const xmlChar,
3960 name2: *const xmlChar,
3961 userdata: *mut c_void,
3962) -> c_int {
3963 unsafe {
3964 crate::xml::hash::hash_add_entry2(
3965 table as *mut crate::xml::hash::HashTable,
3966 name,
3967 name2,
3968 userdata,
3969 )
3970 }
3971}
3972
3973#[no_mangle]
3982pub unsafe extern "C" fn xmlHashAddEntry3(
3983 table: *mut c_void,
3984 name: *const xmlChar,
3985 name2: *const xmlChar,
3986 name3: *const xmlChar,
3987 userdata: *mut c_void,
3988) -> c_int {
3989 unsafe {
3990 crate::xml::hash::hash_add_entry3(
3991 table as *mut crate::xml::hash::HashTable,
3992 name,
3993 name2,
3994 name3,
3995 userdata,
3996 )
3997 }
3998}
3999
4000#[no_mangle]
4009pub unsafe extern "C" fn xmlHashUpdateEntry(
4010 table: *mut c_void,
4011 name: *const xmlChar,
4012 userdata: *mut c_void,
4013 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4014) -> c_int {
4015 unsafe {
4016 crate::xml::hash::hash_update_entry(
4017 table as *mut crate::xml::hash::HashTable,
4018 name,
4019 userdata,
4020 f,
4021 )
4022 }
4023}
4024
4025#[no_mangle]
4027pub unsafe extern "C" fn xmlHashUpdateEntry2(
4028 table: *mut c_void,
4029 name: *const xmlChar,
4030 name2: *const xmlChar,
4031 userdata: *mut c_void,
4032 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4033) -> c_int {
4034 unsafe {
4035 crate::xml::hash::hash_update_entry2(
4036 table as *mut crate::xml::hash::HashTable,
4037 name,
4038 name2,
4039 userdata,
4040 f,
4041 )
4042 }
4043}
4044
4045#[no_mangle]
4047pub unsafe extern "C" fn xmlHashUpdateEntry3(
4048 table: *mut c_void,
4049 name: *const xmlChar,
4050 name2: *const xmlChar,
4051 name3: *const xmlChar,
4052 userdata: *mut c_void,
4053 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4054) -> c_int {
4055 unsafe {
4056 crate::xml::hash::hash_update_entry3(
4057 table as *mut crate::xml::hash::HashTable,
4058 name,
4059 name2,
4060 name3,
4061 userdata,
4062 f,
4063 )
4064 }
4065}
4066
4067#[no_mangle]
4075pub unsafe extern "C" fn xmlHashLookup(table: *mut c_void, name: *const xmlChar) -> *mut c_void {
4076 unsafe { crate::xml::hash::hash_lookup(table as *mut crate::xml::hash::HashTable, name) }
4077}
4078
4079#[no_mangle]
4081pub unsafe extern "C" fn xmlHashLookup2(
4082 table: *mut c_void,
4083 name: *const xmlChar,
4084 name2: *const xmlChar,
4085) -> *mut c_void {
4086 unsafe {
4087 crate::xml::hash::hash_lookup2(table as *mut crate::xml::hash::HashTable, name, name2)
4088 }
4089}
4090
4091#[no_mangle]
4093pub unsafe extern "C" fn xmlHashLookup3(
4094 table: *mut c_void,
4095 name: *const xmlChar,
4096 name2: *const xmlChar,
4097 name3: *const xmlChar,
4098) -> *mut c_void {
4099 unsafe {
4100 crate::xml::hash::hash_lookup3(
4101 table as *mut crate::xml::hash::HashTable,
4102 name,
4103 name2,
4104 name3,
4105 )
4106 }
4107}
4108
4109#[no_mangle]
4117pub extern "C" fn xmlHashSize(table: *mut c_void) -> c_int {
4118 unsafe { crate::xml::hash::hash_size(table as *mut crate::xml::hash::HashTable) }
4119}
4120
4121#[no_mangle]
4130pub unsafe extern "C" fn xmlHashRemoveEntry(
4131 table: *mut c_void,
4132 name: *const xmlChar,
4133 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4134) -> c_int {
4135 unsafe {
4136 crate::xml::hash::hash_remove_entry(table as *mut crate::xml::hash::HashTable, name, f)
4137 }
4138}
4139
4140#[no_mangle]
4142pub unsafe extern "C" fn xmlHashRemoveEntry2(
4143 table: *mut c_void,
4144 name: *const xmlChar,
4145 name2: *const xmlChar,
4146 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4147) -> c_int {
4148 unsafe {
4149 crate::xml::hash::hash_remove_entry2(
4150 table as *mut crate::xml::hash::HashTable,
4151 name,
4152 name2,
4153 f,
4154 )
4155 }
4156}
4157
4158#[no_mangle]
4160pub unsafe extern "C" fn xmlHashRemoveEntry3(
4161 table: *mut c_void,
4162 name: *const xmlChar,
4163 name2: *const xmlChar,
4164 name3: *const xmlChar,
4165 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4166) -> c_int {
4167 unsafe {
4168 crate::xml::hash::hash_remove_entry3(
4169 table as *mut crate::xml::hash::HashTable,
4170 name,
4171 name2,
4172 name3,
4173 f,
4174 )
4175 }
4176}
4177
4178#[no_mangle]
4186pub extern "C" fn xmlHashScan(table: *mut c_void, f: Option<xmlHashScanner>, data: *mut c_void) {
4187 unsafe { crate::xml::hash::hash_scan(table as *mut crate::xml::hash::HashTable, f, data) }
4188}
4189
4190#[no_mangle]
4192pub extern "C" fn xmlHashScanFull(
4193 table: *mut c_void,
4194 f: Option<xmlHashScannerFull>,
4195 data: *mut c_void,
4196) {
4197 unsafe { crate::xml::hash::hash_scan_full(table as *mut crate::xml::hash::HashTable, f, data) }
4198}
4199
4200#[no_mangle]
4208pub extern "C" fn xmlHashCopy(
4209 table: *mut c_void,
4210 f: Option<unsafe extern "C" fn(*mut c_void, *const xmlChar) -> *mut c_void>,
4211) -> *mut c_void {
4212 unsafe {
4213 crate::xml::hash::hash_copy(table as *mut crate::xml::hash::HashTable, f) as *mut c_void
4214 }
4215}
4216
4217#[no_mangle]
4230pub extern "C" fn xmlListCreate(
4231 deallocator: Option<unsafe extern "C" fn(*mut c_void)>,
4232 compare: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
4233) -> *mut c_void {
4234 unsafe { crate::xml::list::list_create(deallocator, compare) as *mut c_void }
4235}
4236
4237#[no_mangle]
4245pub extern "C" fn xmlListDelete(list: *mut c_void) {
4246 unsafe { crate::xml::list::list_delete(list as *mut crate::xml::list::List) }
4247}
4248
4249#[no_mangle]
4257pub extern "C" fn xmlListSearch(list: *mut c_void, data: *mut c_void) -> *mut c_void {
4258 unsafe { crate::xml::list::list_search(list as *mut crate::xml::list::List, data) }
4259}
4260
4261#[no_mangle]
4269pub extern "C" fn xmlListWalk(
4270 list: *mut c_void,
4271 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4272 data: *mut c_void,
4273) {
4274 unsafe { crate::xml::list::list_walk(list as *mut crate::xml::list::List, walker, data) }
4275}
4276
4277#[no_mangle]
4285pub extern "C" fn xmlListPushBack(list: *mut c_void, data: *mut c_void) -> c_int {
4286 unsafe { crate::xml::list::list_push_back(list as *mut crate::xml::list::List, data) }
4287}
4288
4289#[no_mangle]
4297pub extern "C" fn xmlListPushFront(list: *mut c_void, data: *mut c_void) -> c_int {
4298 unsafe { crate::xml::list::list_push_front(list as *mut crate::xml::list::List, data) }
4299}
4300
4301#[no_mangle]
4303pub extern "C" fn xmlListPopBack(list: *mut c_void) {
4304 unsafe { crate::xml::list::list_pop_back(list as *mut crate::xml::list::List) }
4305}
4306
4307#[no_mangle]
4309pub extern "C" fn xmlListPopFront(list: *mut c_void) {
4310 unsafe { crate::xml::list::list_pop_front(list as *mut crate::xml::list::List) }
4311}
4312
4313#[no_mangle]
4321pub extern "C" fn xmlListInsert(list: *mut c_void, data: *mut c_void) -> c_int {
4322 unsafe { crate::xml::list::list_insert(list as *mut crate::xml::list::List, data) }
4323}
4324
4325#[no_mangle]
4327pub extern "C" fn xmlListAppend(list: *mut c_void, data: *mut c_void) -> c_int {
4328 unsafe { crate::xml::list::list_append(list as *mut crate::xml::list::List, data) }
4329}
4330
4331#[no_mangle]
4333pub extern "C" fn xmlListRemoveFirst(list: *mut c_void, data: *mut c_void) -> c_int {
4334 unsafe { crate::xml::list::list_remove_first(list as *mut crate::xml::list::List, data) }
4335}
4336
4337#[no_mangle]
4339pub extern "C" fn xmlListRemoveLast(list: *mut c_void, data: *mut c_void) -> c_int {
4340 unsafe { crate::xml::list::list_remove_last(list as *mut crate::xml::list::List, data) }
4341}
4342
4343#[no_mangle]
4345pub extern "C" fn xmlListRemoveAll(list: *mut c_void, data: *mut c_void) -> c_int {
4346 unsafe { crate::xml::list::list_remove_all(list as *mut crate::xml::list::List, data) }
4347}
4348
4349#[no_mangle]
4351pub extern "C" fn xmlListClear(list: *mut c_void) {
4352 unsafe { crate::xml::list::list_clear(list as *mut crate::xml::list::List) }
4353}
4354
4355#[no_mangle]
4363pub extern "C" fn xmlListEmpty(list: *mut c_void) -> c_int {
4364 unsafe { crate::xml::list::list_empty(list as *mut crate::xml::list::List) }
4365}
4366
4367#[no_mangle]
4375pub extern "C" fn xmlListFront(list: *mut c_void) -> *mut c_void {
4376 unsafe { crate::xml::list::list_front(list as *mut crate::xml::list::List) }
4377}
4378
4379#[no_mangle]
4387pub extern "C" fn xmlListBack(list: *mut c_void) -> *mut c_void {
4388 unsafe { crate::xml::list::list_back(list as *mut crate::xml::list::List) }
4389}
4390
4391#[no_mangle]
4399pub extern "C" fn xmlListSize(list: *mut c_void) -> c_int {
4400 unsafe { crate::xml::list::list_size(list as *mut crate::xml::list::List) }
4401}
4402
4403#[no_mangle]
4405pub extern "C" fn xmlListSort(list: *mut c_void) {
4406 unsafe { crate::xml::list::list_sort(list as *mut crate::xml::list::List) }
4407}
4408
4409#[no_mangle]
4411pub extern "C" fn xmlListReverse(list: *mut c_void) {
4412 unsafe { crate::xml::list::list_reverse(list as *mut crate::xml::list::List) }
4413}
4414
4415#[no_mangle]
4417pub extern "C" fn xmlListReverseSplice(list: *mut c_void, list2: *mut c_void) {
4418 unsafe {
4419 crate::xml::list::list_reverse_splice(
4420 list as *mut crate::xml::list::List,
4421 list2 as *mut crate::xml::list::List,
4422 )
4423 }
4424}
4425
4426#[no_mangle]
4428pub extern "C" fn xmlListMerge(list: *mut c_void, list2: *mut c_void) {
4429 unsafe {
4430 crate::xml::list::list_merge(
4431 list as *mut crate::xml::list::List,
4432 list2 as *mut crate::xml::list::List,
4433 )
4434 }
4435}
4436#[no_mangle]
4444pub unsafe extern "C" fn xmlListEnd(l: *mut c_void) -> *mut c_void {
4445 crate::xml::list::list_end(l as *mut crate::xml::list::List)
4446}
4447
4448#[no_mangle]
4456pub unsafe extern "C" fn xmlListReverseSearch(l: *mut c_void, data: *mut c_void) -> *mut c_void {
4457 crate::xml::list::list_reverse_search(l as *mut crate::xml::list::List, data)
4458}
4459
4460#[no_mangle]
4468pub unsafe extern "C" fn xmlListReverseWalk(
4469 l: *mut c_void,
4470 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4471 data: *mut c_void,
4472) {
4473 crate::xml::list::list_reverse_walk(l as *mut crate::xml::list::List, walker, data)
4474}
4475
4476#[no_mangle]
4484pub unsafe extern "C" fn xmlListDup(l: *mut c_void) -> *mut c_void {
4485 crate::xml::list::list_dup(l as *mut crate::xml::list::List) as *mut c_void
4486}
4487
4488#[no_mangle]
4496pub unsafe extern "C" fn xmlListCopy(
4497 l: *mut c_void,
4498 copier: Option<unsafe extern "C" fn(*mut c_void) -> *mut c_void>,
4499) -> c_int {
4500 crate::xml::list::list_copy(l as *mut crate::xml::list::List, copier)
4501}
4502
4503#[no_mangle]
4511pub unsafe extern "C" fn xmlLinkGetData(lk: *mut c_void) -> *mut c_void {
4512 crate::xml::list::link_get_data(lk)
4513}
4514
4515#[no_mangle]
4527pub extern "C" fn xmlBufferCreate() -> *mut _xmlBuffer {
4528 crate::xml::io::buf_create(-1)
4529}
4530
4531#[no_mangle]
4539pub extern "C" fn xmlBufferCreateSize(size: usize) -> *mut _xmlBuffer {
4540 crate::xml::io::buf_create(size as c_int)
4541}
4542
4543#[no_mangle]
4551pub extern "C" fn xmlBufferCreateStatic(mem: *mut c_void, size: usize) -> *mut _xmlBuffer {
4552 if mem.is_null() || size == 0 {
4553 return ptr::null_mut();
4554 }
4555 crate::xml::io::buf_create_static(mem as *const xmlChar, size as c_int)
4556}
4557
4558#[no_mangle]
4566pub extern "C" fn xmlBufferFree(buf: *mut _xmlBuffer) {
4567 crate::xml::io::buf_free(buf)
4568}
4569
4570#[no_mangle]
4578pub extern "C" fn xmlBufferEmpty(buf: *mut _xmlBuffer) {
4579 if buf.is_null() {
4580 return;
4581 }
4582 unsafe {
4583 if !(*buf).content.is_null() {
4584 *(*buf).content = 0;
4585 }
4586 (*buf).use_ = 0;
4587 }
4588}
4589
4590#[no_mangle]
4598pub extern "C" fn xmlBufferContent(buf: *const _xmlBuffer) -> *mut xmlChar {
4599 crate::xml::io::buf_content(buf as *mut _xmlBuffer)
4600}
4601
4602#[no_mangle]
4610pub extern "C" fn xmlBufferLength(buf: *const _xmlBuffer) -> c_int {
4611 crate::xml::io::buf_length(buf as *mut _xmlBuffer)
4612}
4613
4614#[no_mangle]
4622pub unsafe extern "C" fn xmlBufferAdd(
4623 buf: *mut _xmlBuffer,
4624 str: *const xmlChar,
4625 len: c_int,
4626) -> c_int {
4627 crate::xml::io::buf_add(buf, str, len)
4628}
4629
4630#[no_mangle]
4638pub unsafe extern "C" fn xmlBufferAddHead(
4639 buf: *mut _xmlBuffer,
4640 str: *const xmlChar,
4641 len: c_int,
4642) -> c_int {
4643 crate::xml::io::buf_add_head(buf, str, len)
4644}
4645
4646#[no_mangle]
4654pub unsafe extern "C" fn xmlBufferCat(buf: *mut _xmlBuffer, str: *const xmlChar) -> c_int {
4655 if str.is_null() {
4656 return -1;
4657 }
4658 let len = crate::xml::string::xml_strlen(str) as c_int;
4659 crate::xml::io::buf_add(buf, str, len)
4660}
4661
4662#[no_mangle]
4671pub extern "C" fn xmlBufferSetAllocationScheme(buf: *mut _xmlBuffer, scheme: c_int) {
4672 if buf.is_null() {
4673 return;
4674 }
4675 unsafe {
4676 (*buf).alloc = scheme;
4677 }
4678}
4679
4680#[no_mangle]
4688pub extern "C" fn xmlBufferShrink(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4689 if buf.is_null() || len <= 0 {
4690 return 0;
4691 }
4692 unsafe {
4693 let b = &mut *buf;
4694 let shrink_len = (len as c_uint).min(b.use_);
4695 if shrink_len > 0 {
4696 let remaining = b.use_ - shrink_len;
4697 if remaining > 0 {
4698 core::ptr::copy(
4699 b.content.add(shrink_len as usize),
4700 b.content,
4701 remaining as usize,
4702 );
4703 }
4704 *b.content.add(remaining as usize) = 0;
4705 b.use_ = remaining;
4706 }
4707 }
4708 len
4709}
4710
4711#[no_mangle]
4719pub extern "C" fn xmlBufferGrow(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4720 if buf.is_null() || len <= 0 {
4721 return 0;
4722 }
4723 let cur_use = unsafe { (*buf).use_ };
4724 let new_size = cur_use + len as c_uint + 1;
4725 crate::xml::io::buf_grow(buf, new_size)
4726}
4727
4728#[no_mangle]
4736pub extern "C" fn xmlBufferReserve(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4737 xmlBufferGrow(buf, len)
4738}
4739
4740#[no_mangle]
4748pub extern "C" fn xmlBufferDetach(buf: *mut _xmlBuffer) -> *mut xmlChar {
4749 if buf.is_null() {
4750 return ptr::null_mut();
4751 }
4752 unsafe {
4753 let content = (*buf).content;
4754 (*buf).content = ptr::null_mut();
4755 (*buf).use_ = 0;
4756 (*buf).size = 0;
4757 content
4758 }
4759}
4760
4761#[no_mangle]
4773pub extern "C" fn xmlGetCharEncoding(name: *const c_char) -> c_int {
4774 if name.is_null() {
4775 return 0; }
4777 let name_bytes = unsafe {
4778 let len = libc::strlen(name);
4779 core::slice::from_raw_parts(name as *const u8, len)
4780 };
4781 crate::xml::encoding::encoding_from_name(name_bytes) as c_int
4782}
4783
4784#[no_mangle]
4792pub extern "C" fn xmlFindCharEncodingHandler(name: *const c_char) -> *mut c_void {
4793 if name.is_null() {
4794 return ptr::null_mut();
4795 }
4796 crate::xml::encoding::find_encoding_handler(name as *const xmlChar) as *mut c_void
4797}
4798
4799#[no_mangle]
4807pub extern "C" fn xmlCharEncCloseFunc(handler: *mut c_void) -> c_int {
4808 if handler.is_null() {
4809 return -1;
4810 }
4811 unsafe {
4813 let h = handler as *mut crate::abi::structs::_xmlCharEncodingHandler;
4814 if !(*h).name.is_null() {
4815 crate::abi::allocator::xmlFreeImpl((*h).name as *mut c_void);
4816 }
4817 crate::abi::allocator::xmlFreeImpl(handler);
4818 }
4819 0
4820}
4821
4822#[no_mangle]
4830pub extern "C" fn xmlGetCharEncodingName(enc: c_int) -> *const c_char {
4831 if enc < -1 || enc > 22 {
4835 return match enc {
4836 23 => c"UTF-16".as_ptr(),
4837 24 => c"HTML".as_ptr(),
4838 31 => c"windows-1252".as_ptr(),
4839 _ => ptr::null(),
4840 };
4841 }
4842 let e: crate::abi::types::xmlCharEncoding = unsafe { core::mem::transmute(enc) };
4843 crate::xml::encoding::xmlGetCharEncodingName(e)
4844}
4845
4846#[no_mangle]
4856pub extern "C" fn xmlParseCharEncoding(name: *const c_char) -> c_int {
4857 crate::xml::encoding::xmlParseCharEncoding(name)
4858}
4859
4860#[no_mangle]
4868pub extern "C" fn xmlAddEncodingAlias(name: *const c_char, alias: *const c_char) -> c_int {
4869 crate::xml::encoding::add_encoding_alias(name, alias)
4870}
4871
4872#[no_mangle]
4880pub extern "C" fn xmlDelEncodingAlias(alias: *const c_char) -> c_int {
4881 crate::xml::encoding::del_encoding_alias(alias)
4882}
4883
4884#[no_mangle]
4892pub extern "C" fn xmlGetEncodingAlias(alias: *const c_char) -> *const c_char {
4893 crate::xml::encoding::get_encoding_alias(alias)
4894}
4895
4896#[no_mangle]
4904pub extern "C" fn xmlCleanupEncodingAliases() {
4905 crate::xml::encoding::cleanup_encoding_aliases();
4906}
4907
4908#[no_mangle]
4917pub extern "C" fn xmlCharEncInFunc(
4918 handler: *mut c_void,
4919 out: *mut c_void,
4920 in_: *mut c_void,
4921) -> c_int {
4922 crate::xml::encoding::xmlCharEncInFunc(
4923 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
4924 out as *mut crate::abi::structs::_xmlBuffer,
4925 in_ as *mut crate::abi::structs::_xmlBuffer,
4926 )
4927}
4928
4929#[no_mangle]
4938pub extern "C" fn xmlCharEncOutFunc(
4939 handler: *mut c_void,
4940 out: *mut c_void,
4941 in_: *mut c_void,
4942) -> c_int {
4943 crate::xml::encoding::xmlCharEncOutFunc(
4944 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
4945 out as *mut crate::abi::structs::_xmlBuffer,
4946 in_ as *mut crate::abi::structs::_xmlBuffer,
4947 )
4948}
4949
4950#[no_mangle]
4960pub extern "C" fn xmlNewCharEncodingHandler(
4961 name: *const c_char,
4962 input: crate::abi::callbacks::xmlCharEncodingInputFunc,
4963 output: crate::abi::callbacks::xmlCharEncodingOutputFunc,
4964) -> *mut c_void {
4965 crate::xml::encoding::xmlNewCharEncodingHandler(name, input, output) as *mut c_void
4966}
4967
4968#[no_mangle]
4976pub extern "C" fn xmlInitCharEncodingHandlers() {
4977 crate::xml::encoding::xmlInitCharEncodingHandlers();
4978}
4979
4980#[no_mangle]
4988pub extern "C" fn xmlCleanupCharEncodingHandlers() {
4989 crate::xml::encoding::xmlCleanupCharEncodingHandlers();
4990}
4991
4992#[no_mangle]
5004pub extern "C" fn xmlLookupCharEncodingHandler(enc: c_int, out: *mut *mut c_void) -> c_int {
5005 crate::xml::encoding::xmlLookupCharEncodingHandler(enc, out)
5006}
5007
5008#[no_mangle]
5016pub extern "C" fn xmlGetCharEncodingHandler(enc: c_int) -> *mut c_void {
5017 crate::xml::encoding::xmlGetCharEncodingHandler(enc)
5018}
5019
5020#[no_mangle]
5029pub extern "C" fn xmlOpenCharEncodingHandler(
5030 name: *const c_char,
5031 output: c_int,
5032 out: *mut *mut c_void,
5033) -> c_int {
5034 crate::xml::encoding::xmlOpenCharEncodingHandler(name, output, out)
5035}
5036
5037#[no_mangle]
5048pub extern "C" fn xmlCreateCharEncodingHandler(
5049 name: *const c_char,
5050 flags: c_int,
5051 impl_: Option<crate::abi::callbacks::xmlCharEncConvImpl>,
5052 implCtxt: *mut c_void,
5053 out: *mut *mut c_void,
5054) -> c_int {
5055 crate::xml::encoding::xmlCreateCharEncodingHandler(name, flags, impl_, implCtxt, out)
5056}
5057
5058#[no_mangle]
5069pub extern "C" fn xmlCharEncNewCustomHandler(
5070 name: *const c_char,
5071 input: crate::abi::callbacks::xmlCharEncConvFunc,
5072 output: crate::abi::callbacks::xmlCharEncConvFunc,
5073 ctxtDtor: Option<crate::abi::callbacks::xmlCharEncConvCtxtDtor>,
5074 inputCtxt: *mut c_void,
5075 outputCtxt: *mut c_void,
5076 out: *mut *mut c_void,
5077) -> c_int {
5078 crate::xml::encoding::xmlCharEncNewCustomHandler(
5079 name, input, output, ctxtDtor, inputCtxt, outputCtxt, out,
5080 )
5081}
5082
5083#[no_mangle]
5091pub unsafe extern "C" fn xmlCharEncInput(input: *mut _xmlParserInputBuffer, _to: c_int) -> c_int {
5092 if input.is_null() {
5093 return -1;
5094 }
5095 let handler = (*input).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5096 if handler.is_null() {
5097 return -1;
5098 }
5099 let raw = (*input).raw as *mut crate::abi::structs::_xmlBuffer;
5100 let buf = (*input).buffer as *mut crate::abi::structs::_xmlBuffer;
5101 if raw.is_null() || buf.is_null() {
5102 return -1;
5103 }
5104 crate::xml::encoding::char_enc_in(handler, buf, raw)
5105}
5106
5107#[no_mangle]
5115pub unsafe extern "C" fn xmlCharEncOutput(output: *mut _xmlOutputBuffer, _to: c_int) -> c_int {
5116 if output.is_null() {
5117 return -1;
5118 }
5119 let handler = (*output).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5120 if handler.is_null() {
5121 return -1;
5122 }
5123 let buf = (*output).buffer as *mut crate::abi::structs::_xmlBuffer;
5124 let conv = (*output).conv as *mut crate::abi::structs::_xmlBuffer;
5125 if buf.is_null() || conv.is_null() {
5126 return -1;
5127 }
5128 crate::xml::encoding::char_enc_out(handler, conv, buf)
5129}
5130
5131#[no_mangle]
5143pub unsafe extern "C" fn xmlParseURI(str: *const c_char) -> *mut c_void {
5144 crate::xml::uri::xmlParseURI(str)
5145}
5146
5147#[no_mangle]
5155pub unsafe extern "C" fn xmlParseURIRaw(str: *const c_char, raw: c_int) -> *mut c_void {
5156 let _ = raw;
5157 crate::xml::uri::xmlParseURI(str)
5158}
5159
5160#[no_mangle]
5168pub unsafe extern "C" fn xmlFreeURI(uri: *mut c_void) {
5169 crate::xml::uri::xmlFreeURI(uri)
5170}
5171
5172#[no_mangle]
5180pub extern "C" fn xmlCreateURI() -> *mut c_void {
5181 crate::xml::uri::xmlCreateURI()
5182}
5183
5184#[no_mangle]
5192pub unsafe extern "C" fn xmlSaveUri(uri: *mut c_void) -> *mut xmlChar {
5193 crate::xml::uri::xmlSaveUri(uri)
5194}
5195
5196#[no_mangle]
5212pub unsafe extern "C" fn xmlParseURIReference(uri: *mut c_void, str: *const c_char) -> c_int {
5213 crate::xml::uri::xmlParseURIReference(uri, str)
5214}
5215
5216#[no_mangle]
5231pub unsafe extern "C" fn xmlNormalizeURIPath(path: *mut c_char) -> c_int {
5232 crate::xml::uri::xmlNormalizeURIPath(path)
5233}
5234
5235#[no_mangle]
5243pub unsafe extern "C" fn xmlURIEscapeStr(
5244 str: *const xmlChar,
5245 list: *const xmlChar,
5246) -> *mut xmlChar {
5247 crate::xml::uri::xmlURIEscapeStr(str, list)
5248}
5249
5250#[no_mangle]
5258pub unsafe extern "C" fn xmlURIUnescapeString(
5259 str: *const c_char,
5260 len: c_int,
5261 target: *mut c_char,
5262) -> *mut c_char {
5263 crate::xml::uri::xmlURIUnescapeString(str, len, target)
5264}
5265
5266unsafe fn xpath_to_object(val: XPathValue) -> *mut _xmlXPathObject {
5281 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
5282 if obj.is_null() {
5283 return ptr::null_mut();
5284 }
5285 match val {
5286 XPathValue::NodeSet(ns) => {
5287 (*obj).type_ = xmlXPathObjectType::XPATH_NODESET as c_int;
5288 (*obj).nodesetval = ns.to_raw() as *mut c_void;
5289 }
5290 XPathValue::Boolean(b) => {
5291 (*obj).type_ = xmlXPathObjectType::XPATH_BOOLEAN as c_int;
5292 (*obj).boolval = if b { 1 } else { 0 };
5293 }
5294 XPathValue::Number(n) => {
5295 (*obj).type_ = xmlXPathObjectType::XPATH_NUMBER as c_int;
5296 (*obj).floatval = n;
5297 }
5298 XPathValue::String(s) => {
5299 (*obj).type_ = xmlXPathObjectType::XPATH_STRING as c_int;
5300 let bytes = s.as_bytes();
5301 let len = bytes.len();
5302 let buf = xmlMallocImpl(len + 1) as *mut xmlChar;
5303 if !buf.is_null() {
5304 ptr::copy_nonoverlapping(bytes.as_ptr(), buf, len);
5305 *buf.add(len) = 0; }
5307 (*obj).stringval = buf;
5308 }
5309 }
5310 obj
5311}
5312
5313unsafe fn object_to_xpathvalue(obj: *mut _xmlXPathObject) -> XPathValue {
5320 let typ = (*obj).type_;
5321 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5322 let ns_ptr = (*obj).nodesetval as *mut _xmlNodeSet;
5323 if ns_ptr.is_null() {
5324 return XPathValue::NodeSet(NodeSet::new());
5325 }
5326 let node_nr = (*ns_ptr).nodeNr;
5327 let node_tab = (*ns_ptr).nodeTab;
5328 let mut ns = NodeSet::new();
5329 if !node_tab.is_null() {
5330 for i in 0..node_nr as isize {
5331 let node = *node_tab.add(i as usize);
5332 ns.push(node);
5333 }
5334 }
5335 XPathValue::NodeSet(ns)
5336 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5337 XPathValue::Boolean((*obj).boolval != 0)
5338 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5339 XPathValue::Number((*obj).floatval)
5340 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5341 let s_ptr = (*obj).stringval;
5342 if s_ptr.is_null() {
5343 XPathValue::String(String::new())
5344 } else {
5345 let s = CStr::from_ptr(s_ptr as *const c_char)
5346 .to_string_lossy()
5347 .into_owned();
5348 XPathValue::String(s)
5349 }
5350 } else if typ == xmlXPathObjectType::XPATH_XSLT_TREE as c_int {
5351 let frag_doc = (*obj).nodesetval as *mut _xmlDoc;
5356 if frag_doc.is_null() {
5357 XPathValue::NodeSet(NodeSet::new())
5358 } else {
5359 let mut ns = NodeSet::new();
5360 ns.push(frag_doc as *mut _xmlNode);
5361 XPathValue::NodeSet(ns)
5362 }
5363 } else {
5364 XPathValue::Boolean(false)
5366 }
5367}
5368
5369pub unsafe fn xpath_to_object_pub(val: XPathValue) -> *mut _xmlXPathObject {
5375 xpath_to_object(val)
5376}
5377
5378pub unsafe fn object_to_xpathvalue_pub(obj: *mut _xmlXPathObject) -> XPathValue {
5385 object_to_xpathvalue(obj)
5386}
5387
5388static COMPILED_EXPRS: Lazy<Mutex<HashMap<u64, Box<CompiledExpr>>>> =
5394 Lazy::new(|| Mutex::new(HashMap::new()));
5395static NEXT_COMPILED_KEY: Lazy<Mutex<u64>> = Lazy::new(|| Mutex::new(1));
5396
5397pub(crate) fn xpath_compiled_registry() -> &'static Mutex<HashMap<u64, Box<CompiledExpr>>> {
5400 &COMPILED_EXPRS
5401}
5402
5403type CXPathFunc = unsafe extern "C" fn(*mut c_void, c_int);
5413
5414#[derive(Clone, Copy, PartialEq, Eq, Hash)]
5417struct SendSyncPtr(*mut c_void);
5418unsafe impl Send for SendSyncPtr {}
5419unsafe impl Sync for SendSyncPtr {}
5420
5421static C_FUNCTIONS: Lazy<Mutex<HashMap<(SendSyncPtr, String), CXPathFunc>>> =
5422 Lazy::new(|| Mutex::new(HashMap::new()));
5423
5424pub(crate) fn xpath_cfunc_lookup(extra: *mut c_void, qualified: &str) -> Option<CXPathFunc> {
5428 C_FUNCTIONS
5429 .lock()
5430 .get(&(SendSyncPtr(extra), qualified.to_string()))
5431 .copied()
5432}
5433
5434pub(crate) fn xpath_cfunc_cleanup(extra: *mut c_void) {
5437 C_FUNCTIONS.lock().retain(|(k, _), _| k.0 != extra);
5438}
5439
5440fn c_func_bridge_closure(c_ctxt: SendSyncPtr, qualified: String) -> BoxedXPathFunction {
5445 Box::new(move |_ctx: &mut XPathContext, args: &[XPathValue]| {
5446 let cc = c_ctxt;
5447 unsafe { c_func_call_bridge(cc.0 as *mut _xmlXPathContext, &qualified, args) }
5448 })
5449}
5450
5451pub(crate) unsafe fn call_c_xpath_function(
5461 fnptr: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
5462 c_ctxt: *mut _xmlXPathContext,
5463 args: &[XPathValue],
5464) -> Result<XPathValue, String> {
5465 let func = match fnptr {
5466 Some(f) => f,
5467 None => return Err("XPath: missing C function pointer".to_string()),
5468 };
5469 let pc = crate::xml::xpath::parser_context::new_parser_context(ptr::null(), c_ctxt);
5470 if pc.is_null() {
5471 return Err("XPath: parser-context allocation failure".to_string());
5472 }
5473 let mut push_ok = true;
5474 for v in args {
5475 let obj = xpath_to_object(v.clone());
5476 if obj.is_null() || crate::xml::xpath::parser_context::value_push(pc, obj).is_null() {
5477 push_ok = false;
5478 break;
5479 }
5480 }
5481 let result = if push_ok {
5482 unsafe { func(pc as *mut c_void, args.len() as c_int) };
5485 let ret = crate::xml::xpath::parser_context::value_pop(pc);
5486 if ret.is_null() {
5487 Err("XPath: C function returned no value".to_string())
5488 } else {
5489 let v = object_to_xpathvalue(ret);
5490 unsafe { xmlXPathFreeObject(ret) };
5492 Ok(v)
5493 }
5494 } else {
5495 Err("XPath: failed to push arguments to C function".to_string())
5496 };
5497 unsafe {
5499 loop {
5500 let leftover = crate::xml::xpath::parser_context::value_pop(pc);
5501 if leftover.is_null() {
5502 break;
5503 }
5504 xmlXPathFreeObject(leftover);
5505 }
5506 crate::xml::xpath::parser_context::free_parser_context(pc);
5507 }
5508 result
5509}
5510
5511unsafe fn c_func_call_bridge(
5518 c_ctxt: *mut _xmlXPathContext,
5519 qualified: &str,
5520 args: &[XPathValue],
5521) -> Result<XPathValue, String> {
5522 if c_ctxt.is_null() {
5523 return Err("XPath: null context in C function bridge".to_string());
5524 }
5525 let func = xpath_cfunc_lookup((*c_ctxt).extra, qualified);
5526 if func.is_none() {
5527 return Err(format!("XPath: unknown C function '{}'", qualified));
5528 }
5529 unsafe { call_c_xpath_function(func, c_ctxt, args) }
5530}
5531
5532#[no_mangle]
5545pub unsafe extern "C" fn xmlXPathNewContext(doc: *mut _xmlDoc) -> *mut _xmlXPathContext {
5546 let ctxt = xmlMallocZero(size_of::<_xmlXPathContext>()) as *mut _xmlXPathContext;
5547 if ctxt.is_null() {
5548 return ptr::null_mut();
5549 }
5550
5551 (*ctxt).doc = doc;
5553 (*ctxt).node = ptr::null_mut();
5554 (*ctxt).contextSize = 1;
5555 (*ctxt).proximityPosition = 1;
5556
5557 let mut internal = Box::new(XPathContext::new(doc));
5559 for (name, func) in crate::xml::xpath::functions::core_functions() {
5564 internal.register_function(&name, func);
5565 }
5566 (*ctxt).extra = Box::into_raw(internal) as *mut c_void;
5567
5568 ctxt
5569}
5570
5571#[no_mangle]
5579pub unsafe extern "C" fn xmlXPathFreeContext(ctxt: *mut _xmlXPathContext) {
5580 if ctxt.is_null() {
5581 return;
5582 }
5583 if !(*ctxt).extra.is_null() {
5585 let _ = Box::from_raw((*ctxt).extra as *mut XPathContext);
5586 (*ctxt).extra = ptr::null_mut();
5587 }
5588 if !(*ctxt).nsHash.is_null() {
5590 drop(Box::from_raw(
5591 (*ctxt).nsHash as *mut HashMap<String, CString>,
5592 ));
5593 (*ctxt).nsHash = ptr::null_mut();
5594 }
5595 xmlFreeImpl(ctxt as *mut c_void);
5597}
5598
5599#[no_mangle]
5608pub unsafe extern "C" fn xmlXPathEvalExpression(
5609 str_: *const xmlChar,
5610 ctxt: *mut _xmlXPathContext,
5611) -> *mut _xmlXPathObject {
5612 if str_.is_null() || ctxt.is_null() {
5613 return ptr::null_mut();
5614 }
5615 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
5616 Ok(s) => s,
5617 Err(_) => return ptr::null_mut(),
5618 };
5619 let internal = (*ctxt).extra as *mut XPathContext;
5620 if internal.is_null() {
5621 return ptr::null_mut();
5622 }
5623 let internal = &mut *internal;
5624
5625 match crate::xml::xpath::evaluate_str(expr_str, internal) {
5626 Some(val) => xpath_to_object(val),
5627 None => {
5628 if internal.error.is_none() {
5633 internal.set_error("Invalid expression");
5634 }
5635 ptr::null_mut()
5636 }
5637 }
5638}
5639
5640#[no_mangle]
5648pub unsafe extern "C" fn xmlXPathEval(
5649 str_: *const xmlChar,
5650 ctxt: *mut _xmlXPathContext,
5651) -> *mut _xmlXPathObject {
5652 xmlXPathEvalExpression(str_, ctxt)
5653}
5654
5655#[no_mangle]
5666pub unsafe extern "C" fn xmlXPathFreeObject(obj: *mut _xmlXPathObject) {
5667 if obj.is_null() {
5668 return;
5669 }
5670 let typ = (*obj).type_;
5671 if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5673 if !(*obj).stringval.is_null() {
5674 xmlFreeImpl((*obj).stringval as *mut c_void);
5675 (*obj).stringval = ptr::null_mut();
5676 }
5677 }
5678 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5680 let ns = (*obj).nodesetval as *mut _xmlNodeSet;
5681 if !ns.is_null() {
5682 if !(*ns).nodeTab.is_null() {
5683 xmlFreeImpl((*ns).nodeTab as *mut c_void);
5684 }
5685 xmlFreeImpl(ns as *mut c_void);
5686 }
5687 (*obj).nodesetval = ptr::null_mut();
5688 }
5689 xmlFreeImpl(obj as *mut c_void);
5690}
5691
5692#[no_mangle]
5704pub unsafe extern "C" fn xmlXPathObjectCopy(val: *mut _xmlXPathObject) -> *mut _xmlXPathObject {
5705 if val.is_null() {
5706 return ptr::null_mut();
5707 }
5708 let typ = (*val).type_;
5709 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
5710 if obj.is_null() {
5711 return ptr::null_mut();
5712 }
5713 (*obj).type_ = typ;
5714 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5715 let src_ns = (*val).nodesetval as *mut _xmlNodeSet;
5716 if !src_ns.is_null() {
5717 let nr = (*src_ns).nodeNr;
5718 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
5719 if ns.is_null() {
5720 xmlFreeImpl(obj as *mut c_void);
5721 return ptr::null_mut();
5722 }
5723 (*ns).nodeNr = nr;
5724 (*ns).nodeMax = nr;
5725 if nr > 0 && !(*src_ns).nodeTab.is_null() {
5726 let tab = xmlMallocImpl((nr as usize) * core::mem::size_of::<*mut _xmlNode>())
5727 as *mut *mut _xmlNode;
5728 if tab.is_null() {
5729 xmlFreeImpl(ns as *mut c_void);
5730 xmlFreeImpl(obj as *mut c_void);
5731 return ptr::null_mut();
5732 }
5733 ptr::copy_nonoverlapping((*src_ns).nodeTab, tab, nr as usize);
5734 (*ns).nodeTab = tab;
5735 } else {
5736 (*ns).nodeTab = ptr::null_mut();
5737 }
5738 (*obj).nodesetval = ns as *mut c_void;
5739 }
5740 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5741 (*obj).boolval = (*val).boolval;
5742 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5743 (*obj).floatval = (*val).floatval;
5744 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5745 let src = (*val).stringval;
5746 if !src.is_null() {
5747 let len = libc::strlen(src as *const libc::c_char);
5748 let buf = xmlMallocImpl(len + 1) as *mut xmlChar;
5749 if !buf.is_null() {
5750 ptr::copy_nonoverlapping(src, buf, len);
5751 *buf.add(len) = 0;
5752 }
5753 (*obj).stringval = buf;
5754 }
5755 }
5756 obj
5757}
5758
5759#[no_mangle]
5769pub unsafe extern "C" fn xmlXPathCastToString(val: *mut _xmlXPathObject) -> *mut xmlChar {
5770 if val.is_null() {
5771 return ptr::null_mut();
5772 }
5773 let typ = (*val).type_;
5774 let mut result: Vec<u8> = Vec::new();
5775 if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5776 if !(*val).stringval.is_null() {
5777 let len = libc::strlen((*val).stringval as *const libc::c_char);
5778 result.extend_from_slice(core::slice::from_raw_parts((*val).stringval, len));
5779 }
5780 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5781 let n = (*val).floatval;
5787 result.extend_from_slice(xml_number_to_string(n).as_bytes());
5788 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5789 result.extend_from_slice(if (*val).boolval != 0 {
5790 b"true"
5791 } else {
5792 b"false"
5793 });
5794 } else if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5795 let ns = (*val).nodesetval as *mut _xmlNodeSet;
5798 if !ns.is_null() && (*ns).nodeNr > 0 && !(*ns).nodeTab.is_null() {
5799 let node = *(*ns).nodeTab;
5800 if !node.is_null() {
5801 let content = crate::xml::tree::node_get_content(node);
5802 if !content.is_null() {
5803 let len = libc::strlen(content as *const libc::c_char);
5804 result.extend_from_slice(core::slice::from_raw_parts(content, len));
5805 xmlFreeImpl(content as *mut c_void);
5806 }
5807 }
5808 }
5809 }
5810 let buf = xmlMallocImpl(result.len() + 1) as *mut xmlChar;
5812 if buf.is_null() {
5813 return ptr::null_mut();
5814 }
5815 if !result.is_empty() {
5816 ptr::copy_nonoverlapping(result.as_ptr(), buf, result.len());
5817 }
5818 *buf.add(result.len()) = 0;
5819 buf
5820}
5821
5822pub fn xml_number_to_string(n: f64) -> String {
5826 if n.is_nan() {
5827 return "NaN".to_string();
5828 }
5829 if n.is_infinite() {
5830 return if n > 0.0 {
5831 "Infinity".to_string()
5832 } else {
5833 "-Infinity".to_string()
5834 };
5835 }
5836 if n == 0.0 {
5837 return "0".to_string();
5839 }
5840 if n.fract() == 0.0 && n.abs() < 1e15 {
5842 return format!("{:.0}", n);
5843 }
5844 let mut s = format!("{:.15}", n);
5848 if s.contains('.') {
5850 while s.ends_with('0') {
5851 s.pop();
5852 }
5853 if s.ends_with('.') {
5854 s.pop();
5855 }
5856 }
5857 if s == "-0" {
5858 return "0".to_string();
5859 }
5860 s
5861}
5862
5863#[no_mangle]
5871pub unsafe extern "C" fn xmlXPathCastStringToNumber(val: *const xmlChar) -> f64 {
5872 if val.is_null() {
5873 return f64::NAN;
5874 }
5875 let len = libc::strlen(val as *const libc::c_char);
5876 let bytes = core::slice::from_raw_parts(val, len);
5877 let mut i = 0;
5879 while i < bytes.len() && matches!(bytes[i], b' ' | b'\t' | b'\n' | b'\r') {
5880 i += 1;
5881 }
5882 let s = &bytes[i..];
5883 if s.is_empty() {
5884 return f64::NAN;
5885 }
5886 let (sign, rest) = match s[0] {
5888 b'+' => (1.0f64, &s[1..]),
5889 b'-' => (-1.0f64, &s[1..]),
5890 _ => (1.0f64, s),
5891 };
5892 if rest.is_empty() {
5893 return f64::NAN;
5894 }
5895 let num_str = core::str::from_utf8(rest);
5898 match num_str {
5899 Ok(s) => {
5900 let valid = is_xpath_number(s);
5903 if !valid {
5904 f64::NAN
5905 } else {
5906 s.trim()
5907 .parse::<f64>()
5908 .map(|v| v * sign)
5909 .unwrap_or(f64::NAN)
5910 }
5911 }
5912 Err(_) => f64::NAN,
5913 }
5914}
5915
5916fn is_xpath_number(s: &str) -> bool {
5918 let b = s.as_bytes();
5919 if b.is_empty() {
5920 return false;
5921 }
5922 let mut i = 0;
5923 let mut saw_digit = false;
5924 while i < b.len() && b[i].is_ascii_digit() {
5925 saw_digit = true;
5926 i += 1;
5927 }
5928 if i < b.len() && b[i] == b'.' {
5929 i += 1;
5930 while i < b.len() && b[i].is_ascii_digit() {
5931 saw_digit = true;
5932 i += 1;
5933 }
5934 }
5935 if !saw_digit {
5936 return false;
5937 }
5938 if i < b.len() && (b[i] == b'e' || b[i] == b'E') {
5939 i += 1;
5940 if i < b.len() && (b[i] == b'+' || b[i] == b'-') {
5941 i += 1;
5942 }
5943 let mut saw_exp = false;
5944 while i < b.len() && b[i].is_ascii_digit() {
5945 saw_exp = true;
5946 i += 1;
5947 }
5948 if !saw_exp {
5949 return false;
5950 }
5951 }
5952 i == b.len()
5953}
5954
5955#[no_mangle]
5970pub unsafe extern "C" fn xmlXPathCmpNodes(node1: *mut _xmlNode, node2: *mut _xmlNode) -> c_int {
5971 if node1.is_null() || node2.is_null() {
5972 return 0;
5973 }
5974 if node1 == node2 {
5975 return 0;
5976 }
5977 let mut chain1: Vec<*mut _xmlNode> = Vec::new();
5979 let mut chain2: Vec<*mut _xmlNode> = Vec::new();
5980 let mut n = node1;
5981 while !n.is_null() {
5982 chain1.push(n);
5983 n = (*n).parent as *mut _xmlNode;
5984 }
5985 let mut n = node2;
5986 while !n.is_null() {
5987 chain2.push(n);
5988 n = (*n).parent as *mut _xmlNode;
5989 }
5990 let mut i = chain1.len();
5992 let mut j = chain2.len();
5993 while i > 0 && j > 0 && chain1[i - 1] == chain2[j - 1] {
5994 i -= 1;
5995 j -= 1;
5996 }
5997 if i == 0 && j == 0 {
5998 return 0; }
6000 if i == 0 {
6001 return -1; }
6003 if j == 0 {
6004 return 1; }
6006 let mut a = chain1[i - 1];
6008 let mut b = chain2[j - 1];
6009 while !a.is_null() && !b.is_null() {
6011 let pa = (*a).parent as *mut _xmlNode;
6012 let pb = (*b).parent as *mut _xmlNode;
6013 if pa == pb {
6014 break;
6015 }
6016 a = pa;
6017 b = pb;
6018 }
6019 let parent = (*a).parent as *mut _xmlNode;
6021 let mut child = if parent.is_null() {
6022 ptr::null_mut()
6023 } else {
6024 (*parent).children
6025 };
6026 while !child.is_null() {
6027 if child == a {
6028 return -1;
6029 }
6030 if child == b {
6031 return 1;
6032 }
6033 child = (*child).next;
6034 }
6035 0
6036}
6037
6038#[no_mangle]
6048pub unsafe extern "C" fn xmlXPathNodeSetCreate(val: *mut _xmlNode) -> *mut _xmlNodeSet {
6049 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
6050 if ns.is_null() {
6051 return ptr::null_mut();
6052 }
6053 if val.is_null() {
6054 return ns;
6055 }
6056 let tab = xmlMallocImpl(core::mem::size_of::<*mut _xmlNode>()) as *mut *mut _xmlNode;
6057 if tab.is_null() {
6058 xmlFreeImpl(ns as *mut c_void);
6059 return ptr::null_mut();
6060 }
6061 *tab = val;
6062 (*ns).nodeTab = tab;
6063 (*ns).nodeNr = 1;
6064 (*ns).nodeMax = 1;
6065 ns
6066}
6067
6068#[no_mangle]
6080pub unsafe extern "C" fn xmlXPathFreeNodeSet(ns: *mut _xmlNodeSet) {
6081 if ns.is_null() {
6082 return;
6083 }
6084 if !(*ns).nodeTab.is_null() {
6085 xmlFreeImpl((*ns).nodeTab as *mut c_void);
6086 (*ns).nodeTab = ptr::null_mut();
6087 }
6088 (*ns).nodeNr = 0;
6089 (*ns).nodeMax = 0;
6090 xmlFreeImpl(ns as *mut c_void);
6091}
6092
6093#[no_mangle]
6104pub unsafe extern "C" fn xmlXPathCompile(str_: *const xmlChar) -> *mut c_void {
6105 if str_.is_null() {
6106 return ptr::null_mut();
6107 }
6108 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
6109 Ok(s) => s,
6110 Err(_) => return ptr::null_mut(),
6111 };
6112
6113 match crate::xml::xpath::compile(expr_str) {
6114 Some(compiled) => {
6115 let mut map = COMPILED_EXPRS.lock();
6116 let mut counter = NEXT_COMPILED_KEY.lock();
6117 let key = *counter;
6118 *counter += 1;
6119 map.insert(key, Box::new(compiled));
6120 key as *mut c_void
6121 }
6122 None => ptr::null_mut(),
6123 }
6124}
6125
6126#[no_mangle]
6134pub unsafe extern "C" fn xmlXPathFreeCompExpr(comp: *mut c_void) {
6135 if comp.is_null() {
6136 return;
6137 }
6138 let mut map = COMPILED_EXPRS.lock();
6139 map.remove(&(comp as u64));
6140}
6141
6142#[no_mangle]
6151pub unsafe extern "C" fn xmlXPathRegisterNs(
6152 ctxt: *mut _xmlXPathContext,
6153 prefix: *const xmlChar,
6154 ns_uri: *const xmlChar,
6155) -> c_int {
6156 if ctxt.is_null() || prefix.is_null() || ns_uri.is_null() {
6157 return -1;
6158 }
6159 let internal = (*ctxt).extra as *mut XPathContext;
6160 if internal.is_null() {
6161 return -1;
6162 }
6163 let internal = &mut *internal;
6164
6165 let prefix_str = match CStr::from_ptr(prefix as *const c_char).to_str() {
6166 Ok(s) => s,
6167 Err(_) => return -1,
6168 };
6169 let uri_str = match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6170 Ok(s) => s,
6171 Err(_) => return -1,
6172 };
6173
6174 internal.register_namespace(prefix_str, uri_str);
6175
6176 let map: &mut HashMap<String, CString> = if (*ctxt).nsHash.is_null() {
6181 let b: Box<HashMap<String, CString>> = Box::new(HashMap::new());
6182 (*ctxt).nsHash = Box::into_raw(b) as *mut c_void;
6183 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6184 } else {
6185 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6186 };
6187 map.insert(
6188 prefix_str.to_string(),
6189 CString::new(uri_str.as_bytes()).unwrap_or_default(),
6190 );
6191 0
6192}
6193
6194#[no_mangle]
6208pub unsafe extern "C" fn xmlXPathRegisterFunc(
6209 ctxt: *mut _xmlXPathContext,
6210 name: *const xmlChar,
6211 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6212) -> c_int {
6213 if ctxt.is_null() || name.is_null() {
6214 return -1;
6215 }
6216 let internal = (*ctxt).extra as *mut XPathContext;
6217 if internal.is_null() {
6218 return -1;
6219 }
6220 let internal = &mut *internal;
6221
6222 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6223 Ok(s) => s,
6224 Err(_) => return -1,
6225 };
6226
6227 if let Some(func) = f {
6228 let key = (SendSyncPtr((*ctxt).extra), name_str.to_string());
6230 C_FUNCTIONS.lock().insert(key, func);
6231 let c_ctxt = SendSyncPtr(ctxt as *mut c_void);
6234 let name_owned = name_str.to_string();
6235 internal.register_function(name_str, c_func_bridge_closure(c_ctxt, name_owned));
6236 }
6237 0
6238}
6239
6240#[no_mangle]
6250pub unsafe extern "C" fn xmlXPathRegisterFuncNS(
6251 ctxt: *mut _xmlXPathContext,
6252 name: *const xmlChar,
6253 ns_uri: *const xmlChar,
6254 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6255) -> c_int {
6256 if ctxt.is_null() || name.is_null() {
6257 return -1;
6258 }
6259 let internal = (*ctxt).extra as *mut XPathContext;
6260 if internal.is_null() {
6261 return -1;
6262 }
6263 let internal = &mut *internal;
6264
6265 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6266 Ok(s) => s,
6267 Err(_) => return -1,
6268 };
6269 let ns_str = if ns_uri.is_null() {
6270 String::new()
6271 } else {
6272 match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6273 Ok(s) => s.to_string(),
6274 Err(_) => return -1,
6275 }
6276 };
6277
6278 let qualified = if ns_str.is_empty() {
6280 name_str.to_string()
6281 } else {
6282 format!("{{{}}}{}", ns_str, name_str)
6283 };
6284
6285 if let Some(func) = f {
6286 let key = (SendSyncPtr((*ctxt).extra), qualified.clone());
6287 C_FUNCTIONS.lock().insert(key, func);
6288 let c_ctxt = SendSyncPtr(ctxt as *mut c_void);
6289 let qualified_owned = qualified.clone();
6290 internal.register_function(&qualified, c_func_bridge_closure(c_ctxt, qualified_owned));
6291 }
6292 0
6293}
6294
6295#[no_mangle]
6304pub unsafe extern "C" fn xmlXPathRegisterVariable(
6305 ctxt: *mut _xmlXPathContext,
6306 name: *const xmlChar,
6307 value: *mut _xmlXPathObject,
6308) -> c_int {
6309 if ctxt.is_null() || name.is_null() || value.is_null() {
6310 return -1;
6311 }
6312 let internal = (*ctxt).extra as *mut XPathContext;
6313 if internal.is_null() {
6314 return -1;
6315 }
6316 let internal = &mut *internal;
6317
6318 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6319 Ok(s) => s,
6320 Err(_) => return -1,
6321 };
6322
6323 let xpath_val = object_to_xpathvalue(value);
6324 internal.register_variable(name_str, xpath_val);
6325 0
6326}
6327
6328#[no_mangle]
6336pub unsafe extern "C" fn xmlXPathNewNodeSet(val: *mut _xmlNode) -> *mut _xmlXPathObject {
6337 let ns = if val.is_null() {
6338 NodeSet::new()
6339 } else {
6340 NodeSet::singleton(val)
6341 };
6342 xpath_to_object(XPathValue::NodeSet(ns))
6343}
6344
6345#[no_mangle]
6353pub unsafe extern "C" fn xmlXPathNewCString(val: *const xmlChar) -> *mut _xmlXPathObject {
6354 if val.is_null() {
6355 return xpath_to_object(XPathValue::String(String::new()));
6356 }
6357 let s = match CStr::from_ptr(val as *const c_char).to_str() {
6358 Ok(s) => s.to_string(),
6359 Err(_) => return ptr::null_mut(),
6360 };
6361 xpath_to_object(XPathValue::String(s))
6362}
6363
6364#[no_mangle]
6372pub extern "C" fn xmlXPathNewFloat(val: f64) -> *mut _xmlXPathObject {
6373 unsafe { xpath_to_object(XPathValue::Number(val)) }
6374}
6375
6376#[no_mangle]
6384pub extern "C" fn xmlXPathNewBoolean(val: c_int) -> *mut _xmlXPathObject {
6385 unsafe { xpath_to_object(XPathValue::Boolean(val != 0)) }
6386}
6387
6388#[no_mangle]
6402pub unsafe extern "C" fn xmlXPtrEval(expr: *const c_char, doc: *mut _xmlDoc) -> *mut _xmlNode {
6403 crate::xml::xpointer::xmlXPtrEval(expr, doc)
6404}
6405
6406#[no_mangle]
6418pub unsafe extern "C" fn xmlXIncludeProcess(doc: *mut _xmlDoc) -> c_int {
6419 crate::xml::xinclude::xinclude_process(doc)
6420}
6421
6422#[no_mangle]
6430pub unsafe extern "C" fn xmlXIncludeProcessFlags(doc: *mut _xmlDoc, flags: c_int) -> c_int {
6431 crate::xml::xinclude::xinclude_process_flags(doc, flags)
6432}
6433
6434#[no_mangle]
6446pub extern "C" fn xmlCatalogLoad(catalogs: *const c_char) -> *mut c_void {
6447 if catalogs.is_null() {
6448 return ptr::null_mut();
6449 }
6450 crate::xml::catalog::load_catalog(catalogs)
6451}
6452
6453#[no_mangle]
6461pub unsafe extern "C" fn xmlCatalogResolvePublic(pubID: *const xmlChar) -> *mut xmlChar {
6462 if pubID.is_null() {
6463 return ptr::null_mut();
6464 }
6465 crate::xml::catalog::resolve_public(pubID)
6466}
6467
6468#[no_mangle]
6476pub unsafe extern "C" fn xmlCatalogResolveSystem(sysID: *const xmlChar) -> *mut xmlChar {
6477 if sysID.is_null() {
6478 return ptr::null_mut();
6479 }
6480 crate::xml::catalog::resolve_system(sysID)
6481}
6482
6483#[no_mangle]
6491pub unsafe extern "C" fn xmlCatalogResolveURI(URI: *const xmlChar) -> *mut xmlChar {
6492 if URI.is_null() {
6493 return ptr::null_mut();
6494 }
6495 crate::xml::catalog::resolve_uri(URI)
6496}
6497
6498#[no_mangle]
6506pub extern "C" fn xmlCatalogSetDefaults(allow: c_int) {
6507 crate::xml::catalog::set_defaults(allow)
6508}
6509
6510#[no_mangle]
6518pub extern "C" fn xmlCatalogGetDefaults() -> c_int {
6519 crate::xml::catalog::get_defaults()
6520}
6521
6522#[no_mangle]
6530pub unsafe extern "C" fn xmlCatalogAdd(
6531 type_: *const xmlChar,
6532 orig: *const xmlChar,
6533 replace: *const xmlChar,
6534) -> c_int {
6535 if type_.is_null() || orig.is_null() || replace.is_null() {
6536 return -1;
6537 }
6538 crate::xml::catalog::add(type_, orig, replace)
6539}
6540
6541#[no_mangle]
6549pub unsafe extern "C" fn xmlCatalogRemove(value: *const xmlChar) -> c_int {
6550 if value.is_null() {
6551 return 0;
6552 }
6553 crate::xml::catalog::remove(value)
6554}
6555
6556#[no_mangle]
6564pub unsafe extern "C" fn xmlCatalogDump(output: *mut c_void, _catal: *mut c_void) {
6565 if output.is_null() {
6566 return;
6567 }
6568 let doc = crate::xml::catalog::dump_doc();
6569 if doc.is_null() {
6570 return;
6571 }
6572 let mut mem: *mut xmlChar = ptr::null_mut();
6573 let mut size: c_int = 0;
6574 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6575 if !mem.is_null() {
6576 libc::fwrite(
6577 mem as *const c_void,
6578 1,
6579 size as usize,
6580 output as *mut libc::FILE,
6581 );
6582 xmlFreeImpl(mem as *mut c_void);
6583 }
6584 crate::xml::tree::free_doc(doc);
6585}
6586
6587#[no_mangle]
6597pub unsafe extern "C" fn xmlCatalogSave(filename: *const c_char) -> c_int {
6598 if filename.is_null() {
6599 return -1;
6600 }
6601 let doc = crate::xml::catalog::dump_doc();
6602 if doc.is_null() {
6603 return -1;
6604 }
6605 let mut mem: *mut xmlChar = ptr::null_mut();
6606 let mut size: c_int = 0;
6607 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6608 let mut ret: c_int = -1;
6609 if !mem.is_null() {
6610 let fp = libc::fopen(filename, b"w\0".as_ptr() as *const c_char);
6611 if !fp.is_null() {
6612 let written = libc::fwrite(mem as *const c_void, 1, size as usize, fp);
6613 ret = if written == size as usize { 0 } else { -1 };
6614 libc::fclose(fp);
6615 }
6616 xmlFreeImpl(mem as *mut c_void);
6617 }
6618 crate::xml::tree::free_doc(doc);
6619 ret
6620}
6621
6622#[no_mangle]
6630pub extern "C" fn xmlCatalogCleanup() {
6631 crate::xml::catalog::cleanup();
6632}
6633
6634#[no_mangle]
6642pub extern "C" fn xmlCatalogConvert() -> *mut _xmlDoc {
6643 unsafe { crate::xml::catalog::convert() }
6645}
6646
6647#[no_mangle]
6659pub unsafe extern "C" fn htmlParseFile(
6660 _filename: *const c_char,
6661 _encoding: *const c_char,
6662) -> *mut _xmlDoc {
6663 ptr::null_mut()
6665}
6666
6667#[no_mangle]
6675pub unsafe extern "C" fn htmlParseMemory(_buffer: *const c_char, _size: c_int) -> *mut _xmlDoc {
6676 ptr::null_mut()
6678}
6679
6680#[no_mangle]
6688pub unsafe extern "C" fn htmlParseDoc(
6689 _cur: *const xmlChar,
6690 _encoding: *const c_char,
6691) -> *mut _xmlDoc {
6692 ptr::null_mut()
6694}
6695
6696#[no_mangle]
6705pub unsafe extern "C" fn htmlCreateFileParserCtxt(
6706 _filename: *const c_char,
6707 _encoding: *const c_char,
6708) -> *mut c_void {
6709 ptr::null_mut()
6711}
6712
6713#[no_mangle]
6721pub extern "C" fn htmlFreeParserCtxt(ctxt: *mut c_void) {
6722 unsafe { crate::xml::html::free_parser_ctxt(ctxt) }
6723}
6724
6725#[no_mangle]
6733pub extern "C" fn htmlInitParser() {
6734 }
6736
6737#[no_mangle]
6745pub extern "C" fn htmlCleanupParser() {
6746 }
6748
6749#[no_mangle]
6761pub unsafe extern "C" fn xmlNewValidCtxt() -> *mut _xmlValidCtxt {
6762 crate::xml::validation::new_valid_ctxt()
6763}
6764
6765#[no_mangle]
6773pub unsafe extern "C" fn xmlFreeValidCtxt(ctxt: *mut _xmlValidCtxt) {
6774 crate::xml::validation::free_valid_ctxt(ctxt);
6775}
6776
6777#[no_mangle]
6788pub unsafe extern "C" fn xmlSetValidErrors(
6789 ctxt: *mut _xmlValidCtxt,
6790 err: Option<xmlGenericErrorFunc>,
6791 warn: Option<xmlGenericErrorFunc>,
6792 data: *mut c_void,
6793) {
6794 crate::xml::validation::set_valid_errors(ctxt, err, warn, data);
6795}
6796
6797#[no_mangle]
6805pub unsafe extern "C" fn xmlValidateDocument(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
6806 crate::xml::validation::validate_document(ctxt, doc)
6807}
6808
6809#[no_mangle]
6817pub unsafe extern "C" fn xmlValidateDocumentFinal(
6818 ctxt: *mut _xmlValidCtxt,
6819 doc: *mut _xmlDoc,
6820) -> c_int {
6821 crate::xml::validation::validate_document_final(ctxt, doc)
6822}
6823
6824#[no_mangle]
6834pub unsafe extern "C" fn xmlValidateElement(
6835 ctxt: *mut _xmlValidCtxt,
6836 doc: *mut _xmlDoc,
6837 elem: *mut _xmlNode,
6838) -> c_int {
6839 crate::xml::validation::validate_element(ctxt, doc, elem)
6840}
6841
6842#[no_mangle]
6853pub unsafe extern "C" fn xmlValidateAttributeDecl(
6854 ctxt: *mut _xmlValidCtxt,
6855 doc: *mut _xmlDoc,
6856 elem: *mut _xmlNode,
6857 attr: *mut _xmlAttribute,
6858) -> c_int {
6859 crate::xml::validation::validate_attribute_decl(ctxt, doc, elem, attr)
6860}
6861
6862#[no_mangle]
6870pub unsafe extern "C" fn xmlValidateAttributeValue(atype: c_int, value: *const xmlChar) -> c_int {
6871 crate::xml::validation::validate_attribute_value(atype, value)
6872}
6873
6874#[no_mangle]
6884pub unsafe extern "C" fn xmlValidateNotationUse(
6885 ctxt: *mut _xmlValidCtxt,
6886 doc: *mut _xmlDoc,
6887 notation_name: *const xmlChar,
6888) -> c_int {
6889 crate::xml::validation::validate_notation_use(ctxt, doc, notation_name)
6890}
6891
6892#[no_mangle]
6903pub unsafe extern "C" fn xmlValidateID(
6904 ctxt: *mut _xmlValidCtxt,
6905 doc: *mut _xmlDoc,
6906 node: *mut _xmlNode,
6907 value: *const xmlChar,
6908) -> c_int {
6909 crate::xml::validation::validate_id(ctxt, doc, node, value)
6910}
6911
6912#[no_mangle]
6923pub unsafe extern "C" fn xmlValidateIDRef(
6924 ctxt: *mut _xmlValidCtxt,
6925 doc: *mut _xmlDoc,
6926 node: *mut _xmlNode,
6927 value: *const xmlChar,
6928) -> c_int {
6929 crate::xml::validation::validate_id_ref(ctxt, doc, node, value)
6930}
6931
6932#[no_mangle]
6943pub unsafe extern "C" fn xmlValidateIDRefs(
6944 ctxt: *mut _xmlValidCtxt,
6945 doc: *mut _xmlDoc,
6946 node: *mut _xmlNode,
6947 value: *const xmlChar,
6948) -> c_int {
6949 crate::xml::validation::validate_id_refs(ctxt, doc, node, value)
6950}
6951
6952#[no_mangle]
6962pub unsafe extern "C" fn xmlValidateNCName(value: *const xmlChar, space: c_int) -> c_int {
6963 crate::xml::validation::validate_ncname(value, space)
6964}
6965
6966#[no_mangle]
6974pub unsafe extern "C" fn xmlValidateQName(value: *const xmlChar, space: c_int) -> c_int {
6975 crate::xml::validation::validate_qname(value, space)
6976}
6977
6978#[no_mangle]
6991pub unsafe extern "C" fn xmlValidateName(value: *const xmlChar, space: c_int) -> c_int {
6992 crate::xml::validation::validate_name_space(value, space)
6993}
6994
6995#[no_mangle]
7003pub unsafe extern "C" fn xmlValidateNMToken(value: *const xmlChar, space: c_int) -> c_int {
7004 crate::xml::validation::validate_nmtoken_space(value, space)
7005}
7006
7007#[no_mangle]
7017pub unsafe extern "C" fn xmlValidateNameValue(value: *const xmlChar) -> c_int {
7018 crate::xml::validation::validate_name_value(value)
7019}
7020
7021#[no_mangle]
7030pub unsafe extern "C" fn xmlValidateNamesValue(value: *const xmlChar) -> c_int {
7031 crate::xml::validation::validate_names_value(value)
7032}
7033
7034#[no_mangle]
7042pub unsafe extern "C" fn xmlValidateNmtokenValue(value: *const xmlChar) -> c_int {
7043 crate::xml::validation::validate_nmtoken_value(value)
7044}
7045
7046#[no_mangle]
7054pub unsafe extern "C" fn xmlValidateNmtokensValue(value: *const xmlChar) -> c_int {
7055 crate::xml::validation::validate_nmtokens_value(value)
7056}
7057
7058#[no_mangle]
7069pub unsafe extern "C" fn xmlValidateElementDecl(
7070 ctxt: *mut _xmlValidCtxt,
7071 doc: *mut _xmlDoc,
7072 elem: *mut _xmlElement,
7073) -> c_int {
7074 crate::xml::validation::validate_element_decl(ctxt, doc, elem)
7075}
7076
7077#[no_mangle]
7090pub unsafe extern "C" fn xmlValidateNotationDecl(
7091 ctxt: *mut _xmlValidCtxt,
7092 doc: *mut _xmlDoc,
7093 nota: *mut _xmlNotation,
7094) -> c_int {
7095 crate::xml::validation::validate_notation_decl(ctxt, doc, nota)
7096}
7097
7098#[no_mangle]
7110pub unsafe extern "C" fn xmlValidateOneAttribute(
7111 ctxt: *mut _xmlValidCtxt,
7112 doc: *mut _xmlDoc,
7113 elem: *mut _xmlNode,
7114 attr: *mut _xmlAttr,
7115 value: *const xmlChar,
7116) -> c_int {
7117 crate::xml::validation::validate_one_attribute(ctxt, doc, elem, attr, value)
7118}
7119
7120#[no_mangle]
7130pub unsafe extern "C" fn xmlValidateOneElement(
7131 ctxt: *mut _xmlValidCtxt,
7132 doc: *mut _xmlDoc,
7133 elem: *mut _xmlNode,
7134) -> c_int {
7135 crate::xml::validation::validate_one_element(ctxt, doc, elem)
7136}
7137
7138#[no_mangle]
7151pub unsafe extern "C" fn xmlValidateOneNamespace(
7152 ctxt: *mut _xmlValidCtxt,
7153 doc: *mut _xmlDoc,
7154 elem: *mut _xmlNode,
7155 prefix: *const xmlChar,
7156 ns: *mut _xmlNs,
7157 value: *const xmlChar,
7158) -> c_int {
7159 crate::xml::validation::validate_one_namespace(ctxt, doc, elem, prefix, ns, value)
7160}
7161
7162#[no_mangle]
7174pub unsafe extern "C" fn xmlValidatePushElement(
7175 ctxt: *mut _xmlValidCtxt,
7176 doc: *mut _xmlDoc,
7177 elem: *mut _xmlNode,
7178 qname: *const xmlChar,
7179) -> c_int {
7180 crate::xml::validation::validate_push_element(ctxt, doc, elem, qname)
7181}
7182
7183#[no_mangle]
7193pub unsafe extern "C" fn xmlValidatePushCData(
7194 ctxt: *mut _xmlValidCtxt,
7195 data: *const xmlChar,
7196 len: c_int,
7197) -> c_int {
7198 crate::xml::validation::validate_push_cdata(ctxt, data, len)
7199}
7200
7201#[no_mangle]
7212pub unsafe extern "C" fn xmlValidatePopElement(
7213 ctxt: *mut _xmlValidCtxt,
7214 doc: *mut _xmlDoc,
7215 elem: *mut _xmlNode,
7216 qname: *const xmlChar,
7217) -> c_int {
7218 crate::xml::validation::validate_pop_element(ctxt, doc, elem, qname)
7219}
7220
7221#[no_mangle]
7230pub unsafe extern "C" fn xmlValidBuildContentModel(
7231 ctxt: *mut _xmlValidCtxt,
7232 elem: *mut _xmlElement,
7233) -> c_int {
7234 crate::xml::validation::validate_build_content_model(ctxt, elem)
7235}
7236
7237#[no_mangle]
7248pub unsafe extern "C" fn xmlAddID(
7249 ctxt: *mut _xmlValidCtxt,
7250 doc: *mut _xmlDoc,
7251 value: *const xmlChar,
7252 attr: *mut _xmlAttr,
7253) -> *mut _xmlID {
7254 crate::xml::validation::add_id(ctxt, doc, value, attr)
7255}
7256
7257#[no_mangle]
7265pub unsafe extern "C" fn xmlRemoveID(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7266 crate::xml::validation::remove_id(doc, attr)
7267}
7268
7269#[no_mangle]
7280pub unsafe extern "C" fn xmlAddRef(
7281 ctxt: *mut _xmlValidCtxt,
7282 doc: *mut _xmlDoc,
7283 value: *const xmlChar,
7284 attr: *mut _xmlAttr,
7285) -> *mut _xmlRef {
7286 crate::xml::validation::add_ref(ctxt, doc, value, attr)
7287}
7288
7289#[no_mangle]
7297pub unsafe extern "C" fn xmlRemoveRef(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7298 crate::xml::validation::remove_ref(doc, attr)
7299}
7300
7301#[no_mangle]
7309pub unsafe extern "C" fn xmlAddIDSafe(attr: *mut _xmlAttr, value: *const xmlChar) -> c_int {
7310 crate::xml::validation::add_id_safe(attr, value)
7311}
7312
7313#[no_mangle]
7321pub unsafe extern "C" fn xmlFreeIDTable(table: *mut c_void) {
7322 crate::xml::validation::free_id_table(table as *mut crate::xml::hash::HashTable);
7323}
7324
7325#[no_mangle]
7333pub unsafe extern "C" fn xmlFreeRefTable(table: *mut c_void) {
7334 crate::xml::validation::free_ref_table(table as *mut crate::xml::hash::HashTable);
7335}
7336
7337#[no_mangle]
7345pub unsafe extern "C" fn xmlGetID(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut _xmlAttr {
7346 crate::xml::validation::get_id(doc, id)
7347}
7348
7349#[no_mangle]
7357pub unsafe extern "C" fn xmlGetRefs(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut c_void {
7358 crate::xml::validation::get_refs(doc, id) as *mut c_void
7359}
7360
7361#[no_mangle]
7369pub unsafe extern "C" fn xmlIsID(
7370 doc: *mut _xmlDoc,
7371 elem: *mut _xmlNode,
7372 attr: *mut _xmlAttr,
7373) -> c_int {
7374 crate::xml::validation::is_id(doc, elem, attr)
7375}
7376
7377#[no_mangle]
7385pub unsafe extern "C" fn xmlIsRef(
7386 doc: *mut _xmlDoc,
7387 elem: *mut _xmlNode,
7388 attr: *mut _xmlAttr,
7389) -> c_int {
7390 crate::xml::validation::is_ref(doc, elem, attr)
7391}
7392
7393#[no_mangle]
7401pub unsafe extern "C" fn xmlGetDtdElementDesc(
7402 dtd: *mut _xmlDtd,
7403 name: *const xmlChar,
7404) -> *mut _xmlElement {
7405 crate::xml::validation::get_dtd_element_desc(dtd, name)
7406}
7407
7408#[no_mangle]
7418pub unsafe extern "C" fn xmlGetDtdAttrDesc(
7419 dtd: *mut _xmlDtd,
7420 elem: *const xmlChar,
7421 name: *const xmlChar,
7422) -> *mut _xmlAttribute {
7423 crate::xml::validation::get_dtd_attr_desc(dtd, elem, name)
7424}
7425
7426#[no_mangle]
7436pub unsafe extern "C" fn xmlGetDtdQElementDesc(
7437 dtd: *mut _xmlDtd,
7438 name: *const xmlChar,
7439 prefix: *const xmlChar,
7440) -> *mut _xmlElement {
7441 crate::xml::validation::get_dtd_qelement_desc(dtd, name, prefix)
7442}
7443
7444#[no_mangle]
7455pub unsafe extern "C" fn xmlGetDtdQAttrDesc(
7456 dtd: *mut _xmlDtd,
7457 elem: *const xmlChar,
7458 name: *const xmlChar,
7459 prefix: *const xmlChar,
7460) -> *mut _xmlAttribute {
7461 crate::xml::validation::get_dtd_qattr_desc(dtd, elem, name, prefix)
7462}
7463
7464#[no_mangle]
7472pub unsafe extern "C" fn xmlGetDtdNotationDesc(
7473 dtd: *mut _xmlDtd,
7474 name: *const xmlChar,
7475) -> *mut _xmlNotation {
7476 crate::xml::validation::get_dtd_notation_desc(dtd, name)
7477}
7478
7479#[no_mangle]
7487pub unsafe extern "C" fn xmlValidateRoot(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7488 crate::xml::validation::validate_root(ctxt, doc)
7489}
7490
7491#[no_mangle]
7501pub unsafe extern "C" fn xmlValidateContent(
7502 ctxt: *mut _xmlValidCtxt,
7503 node: *mut _xmlNode,
7504 doc: *mut _xmlDoc,
7505) -> c_int {
7506 crate::xml::validation::validate_content(ctxt, node, doc)
7507}
7508
7509#[no_mangle]
7517pub unsafe extern "C" fn xmlIsMixedElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7518 crate::xml::validation::is_mixed_element(doc, name)
7519}
7520
7521#[no_mangle]
7529pub unsafe extern "C" fn xmlIsEmptyElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7530 crate::xml::validation::is_empty_element(doc, name)
7531}
7532
7533#[no_mangle]
7543pub unsafe extern "C" fn xmlValidateDtd(
7544 ctxt: *mut _xmlValidCtxt,
7545 doc: *mut _xmlDoc,
7546 dtd: *mut _xmlDtd,
7547) -> c_int {
7548 crate::xml::validation::validate_dtd(ctxt, doc, dtd)
7549}
7550
7551#[no_mangle]
7559pub unsafe extern "C" fn xmlValidateDtdFinal(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7560 crate::xml::validation::validate_dtd_final(ctxt, doc)
7561}
7562
7563#[no_mangle]
7573pub unsafe extern "C" fn xmlValidateEnumeration(
7574 ctxt: *mut _xmlValidCtxt,
7575 value: *const xmlChar,
7576 tree: *mut _xmlEnumeration,
7577) -> c_int {
7578 crate::xml::validation::validate_enumeration(ctxt, value, tree)
7579}
7580
7581#[no_mangle]
7595pub extern "C" fn xmlGetBinaryPath() -> *mut c_char {
7596 ptr::null_mut()
7598}
7599
7600#[no_mangle]
7608pub extern "C" fn xmlGetHomeOfBinary() -> *mut c_char {
7609 ptr::null_mut()
7611}
7612
7613#[no_mangle]
7624pub unsafe extern "C" fn xmlSAX2StartDocument(ctx: *mut c_void) {
7625 crate::xml::sax::default::default_sax_handler::startDocument(ctx)
7626}
7627
7628#[no_mangle]
7630pub unsafe extern "C" fn xmlSAX2EndDocument(ctx: *mut c_void) {
7631 crate::xml::sax::default::default_sax_handler::endDocument(ctx)
7632}
7633
7634#[no_mangle]
7636pub unsafe extern "C" fn xmlSAX2StartElementNs(
7637 ctx: *mut c_void,
7638 localname: *const xmlChar,
7639 prefix: *const xmlChar,
7640 URI: *const xmlChar,
7641 nb_namespaces: c_int,
7642 namespaces: *mut *const xmlChar,
7643 nb_attributes: c_int,
7644 nb_defaulted: c_int,
7645 attributes: *mut *const xmlChar,
7646) {
7647 crate::xml::sax::default::default_sax_handler::startElementNs(
7648 ctx,
7649 localname,
7650 prefix,
7651 URI,
7652 nb_namespaces,
7653 namespaces,
7654 nb_attributes,
7655 nb_defaulted,
7656 attributes,
7657 )
7658}
7659
7660#[no_mangle]
7662pub unsafe extern "C" fn xmlSAX2EndElementNs(
7663 ctx: *mut c_void,
7664 localname: *const xmlChar,
7665 prefix: *const xmlChar,
7666 URI: *const xmlChar,
7667) {
7668 crate::xml::sax::default::default_sax_handler::endElementNs(ctx, localname, prefix, URI)
7669}
7670
7671#[no_mangle]
7673pub unsafe extern "C" fn xmlSAX2Characters(ctx: *mut c_void, ch: *const xmlChar, len: c_int) {
7674 crate::xml::sax::default::default_sax_handler::characters(ctx, ch, len)
7675}
7676
7677#[no_mangle]
7679pub unsafe extern "C" fn xmlSAX2IgnorableWhitespace(
7680 ctx: *mut c_void,
7681 ch: *const xmlChar,
7682 len: c_int,
7683) {
7684 crate::xml::sax::default::default_sax_handler::ignorableWhitespace(ctx, ch, len)
7685}
7686
7687#[no_mangle]
7689pub unsafe extern "C" fn xmlSAX2Comment(ctx: *mut c_void, value: *const xmlChar) {
7690 crate::xml::sax::default::default_sax_handler::comment(ctx, value)
7691}
7692
7693#[no_mangle]
7695pub unsafe extern "C" fn xmlSAX2ProcessingInstruction(
7696 ctx: *mut c_void,
7697 target: *const xmlChar,
7698 data: *const xmlChar,
7699) {
7700 crate::xml::sax::default::default_sax_handler::processingInstruction(ctx, target, data)
7701}
7702
7703#[no_mangle]
7705pub unsafe extern "C" fn xmlSAX2CDataBlock(ctx: *mut c_void, value: *const xmlChar, len: c_int) {
7706 crate::xml::sax::default::default_sax_handler::cdataBlock(ctx, value, len)
7707}
7708
7709#[no_mangle]
7711pub unsafe extern "C" fn xmlSAX2InternalSubset(
7712 ctx: *mut c_void,
7713 name: *const xmlChar,
7714 ExternalID: *const xmlChar,
7715 SystemID: *const xmlChar,
7716) {
7717 crate::xml::sax::default::default_sax_handler::internalSubset(ctx, name, ExternalID, SystemID)
7718}
7719
7720#[no_mangle]
7722pub unsafe extern "C" fn xmlSAX2ExternalSubset(
7723 ctx: *mut c_void,
7724 name: *const xmlChar,
7725 ExternalID: *const xmlChar,
7726 SystemID: *const xmlChar,
7727) {
7728 crate::xml::sax::default::default_sax_handler::externalSubset(ctx, name, ExternalID, SystemID)
7729}
7730
7731#[no_mangle]
7733pub unsafe extern "C" fn xmlSAX2EntityDecl(
7734 ctx: *mut c_void,
7735 name: *const xmlChar,
7736 type_: c_int,
7737 publicId: *const xmlChar,
7738 systemId: *const xmlChar,
7739 content: *mut xmlChar,
7740) {
7741 crate::xml::sax::default::default_sax_handler::entityDecl(
7742 ctx, name, type_, publicId, systemId, content,
7743 )
7744}
7745
7746#[no_mangle]
7748pub unsafe extern "C" fn xmlSAX2AttributeDecl(
7749 ctx: *mut c_void,
7750 elem: *const xmlChar,
7751 fullname: *const xmlChar,
7752 type_: c_int,
7753 def: c_int,
7754 defaultValue: *const xmlChar,
7755 tree: *mut crate::abi::structs::_xmlEnumeration,
7756) {
7757 crate::xml::sax::default::default_sax_handler::attributeDecl(
7758 ctx,
7759 elem,
7760 fullname,
7761 type_,
7762 def,
7763 defaultValue,
7764 tree,
7765 )
7766}
7767
7768#[no_mangle]
7770pub unsafe extern "C" fn xmlSAX2ElementDecl(
7771 ctx: *mut c_void,
7772 name: *const xmlChar,
7773 type_: c_int,
7774 content: *mut crate::abi::structs::_xmlElementContent,
7775) {
7776 crate::xml::sax::default::default_sax_handler::elementDecl(ctx, name, type_, content)
7777}
7778
7779#[no_mangle]
7781pub unsafe extern "C" fn xmlSAX2NotationDecl(
7782 ctx: *mut c_void,
7783 name: *const xmlChar,
7784 publicId: *const xmlChar,
7785 systemId: *const xmlChar,
7786) {
7787 crate::xml::sax::default::default_sax_handler::notationDecl(ctx, name, publicId, systemId)
7788}
7789
7790#[no_mangle]
7792pub unsafe extern "C" fn xmlSAX2UnparsedEntityDecl(
7793 ctx: *mut c_void,
7794 name: *const xmlChar,
7795 publicId: *const xmlChar,
7796 systemId: *const xmlChar,
7797 notationName: *const xmlChar,
7798) {
7799 crate::xml::sax::default::default_sax_handler::unparsedEntityDecl(
7800 ctx,
7801 name,
7802 publicId,
7803 systemId,
7804 notationName,
7805 )
7806}
7807
7808#[no_mangle]
7810pub unsafe extern "C" fn xmlSAX2ResolveEntity(
7811 ctx: *mut c_void,
7812 publicId: *const xmlChar,
7813 systemId: *const xmlChar,
7814) -> *mut crate::abi::structs::_xmlParserInput {
7815 crate::xml::sax::default::default_sax_handler::resolveEntity(ctx, publicId, systemId)
7816}
7817
7818#[no_mangle]
7820pub unsafe extern "C" fn xmlSAX2IsStandalone(ctx: *mut c_void) -> c_int {
7821 crate::xml::sax::default::default_sax_handler::isStandalone(ctx)
7822}
7823
7824#[no_mangle]
7826pub unsafe extern "C" fn xmlSAX2HasInternalSubset(ctx: *mut c_void) -> c_int {
7827 crate::xml::sax::default::default_sax_handler::hasInternalSubset(ctx)
7828}
7829
7830#[no_mangle]
7832pub unsafe extern "C" fn xmlSAX2HasExternalSubset(ctx: *mut c_void) -> c_int {
7833 crate::xml::sax::default::default_sax_handler::hasExternalSubset(ctx)
7834}
7835
7836#[no_mangle]
7838pub unsafe extern "C" fn xmlSAX2GetEntity(
7839 ctx: *mut c_void,
7840 name: *const xmlChar,
7841) -> *mut crate::abi::structs::_xmlEntity {
7842 crate::xml::sax::default::default_sax_handler::getEntity(ctx, name)
7843}
7844
7845#[no_mangle]
7847pub unsafe extern "C" fn xmlSAX2GetParameterEntity(
7848 ctx: *mut c_void,
7849 name: *const xmlChar,
7850) -> *mut crate::abi::structs::_xmlEntity {
7851 crate::xml::sax::default::default_sax_handler::getParameterEntity(ctx, name)
7852}
7853
7854#[no_mangle]
7857pub unsafe extern "C" fn xmlSAX2GetLineNumber(ctx: *mut c_void) -> c_int {
7858 crate::xml::sax::default::default_sax_handler::getLineNumber(ctx)
7859}
7860
7861#[no_mangle]
7863pub unsafe extern "C" fn xmlSAX2GetColumnNumber(ctx: *mut c_void) -> c_int {
7864 crate::xml::sax::default::default_sax_handler::getColumnNumber(ctx)
7865}
7866
7867#[no_mangle]
7869pub unsafe extern "C" fn xmlSAX2GetPublicId(ctx: *mut c_void) -> *const xmlChar {
7870 crate::xml::sax::default::default_sax_handler::getPublicId(ctx)
7871}
7872
7873#[no_mangle]
7875pub unsafe extern "C" fn xmlSAX2GetSystemId(ctx: *mut c_void) -> *const xmlChar {
7876 crate::xml::sax::default::default_sax_handler::getSystemId(ctx)
7877}
7878
7879#[no_mangle]
7883pub unsafe extern "C" fn xmlSAX2StartElement(
7884 ctx: *mut c_void,
7885 name: *const xmlChar,
7886 atts: *mut *const xmlChar,
7887) {
7888 crate::xml::sax::dispatch::SaxDispatcher::sax1_start_element(ctx, name, atts);
7892}
7893
7894#[no_mangle]
7896pub unsafe extern "C" fn xmlSAX2EndElement(ctx: *mut c_void, name: *const xmlChar) {
7897 crate::xml::sax::dispatch::SaxDispatcher::sax1_end_element(ctx, name);
7898}
7899
7900#[no_mangle]
7902pub unsafe extern "C" fn xmlSAX2SetDocumentLocator(
7903 ctx: *mut c_void,
7904 loc: *mut crate::abi::callbacks::_xmlSAXLocator,
7905) {
7906 crate::xml::sax::default::default_sax_handler::setDocumentLocator(ctx, loc)
7907}
7908
7909#[no_mangle]
7911pub unsafe extern "C" fn xmlSAX2Reference(ctx: *mut c_void, name: *const xmlChar) {
7912 crate::xml::sax::default::default_sax_handler::reference(ctx, name)
7913}