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_long, 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_long {
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 crate::abi::exports_parser::apply_options(ctxt, options);
2723 let parsed = crate::xml::parser::helpers::parse_document(ctxt);
2724 let doc = (*ctxt).myDoc;
2725 if !doc.is_null() && !URL.is_null() && (*doc).URL.is_null() {
2728 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2729 }
2730 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2731 if parsed != 0 {
2732 if options & 1 << 0 != 0 {
2736 return doc;
2737 }
2738 if !doc.is_null() {
2739 crate::xml::tree::free_doc(doc);
2740 }
2741 return ptr::null_mut();
2742 }
2743 doc
2744}
2745
2746#[no_mangle]
2752pub unsafe extern "C" fn xmlLoadCatalogs(catalogs: *const c_char) {
2753 if !catalogs.is_null() {
2754 crate::xml::catalog::load_catalog(catalogs);
2755 }
2756}
2757
2758#[no_mangle]
2764pub unsafe extern "C" fn xmlLoadCatalog(catalogs: *const c_char) -> c_int {
2765 let handle = crate::xml::catalog::load_catalog(catalogs);
2768 if handle.is_null() {
2769 1
2770 } else {
2771 0
2772 }
2773}
2774
2775#[no_mangle]
2783pub unsafe extern "C" fn xmlReadFd(
2784 fd: c_int,
2785 URL: *const c_char,
2786 encoding: *const c_char,
2787 options: c_int,
2788) -> *mut _xmlDoc {
2789 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2791 if ctxt.is_null() {
2792 return ptr::null_mut();
2793 }
2794 let mut buf = Vec::new();
2796 let mut tmp = [0u8; 4096];
2797 loop {
2798 let n = libc::read(fd, tmp.as_mut_ptr() as *mut c_void, tmp.len());
2799 if n <= 0 {
2800 break;
2801 }
2802 buf.extend_from_slice(&tmp[..n as usize]);
2803 }
2804 let input = crate::xml::parser::helpers::input_from_memory(
2805 buf.as_ptr() as *const c_char,
2806 buf.len() as c_int,
2807 );
2808 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2809 (*ctxt).options = options;
2810 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2811 let doc = (*ctxt).myDoc;
2812 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2813 return doc;
2814 }
2815 let doc = (*ctxt).myDoc;
2816 if !doc.is_null() && !URL.is_null() {
2817 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2818 }
2819 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2820 doc
2821}
2822
2823#[no_mangle]
2832pub unsafe extern "C" fn xmlReadIO(
2833 ioread: Option<xmlInputReadCallback>,
2834 ioclose: Option<xmlInputCloseCallback>,
2835 ioctx: *mut c_void,
2836 URL: *const c_char,
2837 encoding: *const c_char,
2838 options: c_int,
2839) -> *mut _xmlDoc {
2840 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2842 if ctxt.is_null() {
2843 return ptr::null_mut();
2844 }
2845 let input = crate::xml::parser::helpers::input_from_io(ioread, ioclose, ioctx);
2846 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2847 (*ctxt).options = options;
2848 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2849 let doc = (*ctxt).myDoc;
2850 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2851 return doc;
2852 }
2853 let doc = (*ctxt).myDoc;
2854 if !doc.is_null() && !URL.is_null() {
2855 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2856 }
2857 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2858 doc
2859}
2860
2861#[no_mangle]
2869pub unsafe extern "C" fn xmlSAXParseDoc(
2870 sax: *mut _xmlSAXHandler,
2871 cur: *const xmlChar,
2872 recovery: c_int,
2873) -> *mut _xmlDoc {
2874 if cur.is_null() {
2876 return ptr::null_mut();
2877 }
2878 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2879 if ctxt.is_null() {
2880 return ptr::null_mut();
2881 }
2882 if !sax.is_null() {
2883 (*ctxt).sax = sax;
2884 (*ctxt).userData = (*ctxt).sax as *mut c_void;
2885 }
2886 if recovery != 0 {
2887 (*ctxt).recovery = 1;
2888 (*ctxt).options |= 1; }
2890 let len = crate::xml::string::xml_strlen(cur);
2891 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2892 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2893 crate::xml::parser::helpers::parse_document(ctxt);
2894 let doc = (*ctxt).myDoc;
2895 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2896 doc
2897}
2898
2899#[no_mangle]
2909pub unsafe extern "C" fn xmlSAXParseDocWithData(
2910 sax: *mut _xmlSAXHandler,
2911 cur: *const xmlChar,
2912 recovery: c_int,
2913 data: *mut c_void,
2914) -> *mut _xmlDoc {
2915 if cur.is_null() {
2917 return ptr::null_mut();
2918 }
2919 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2920 if ctxt.is_null() {
2921 return ptr::null_mut();
2922 }
2923 if !sax.is_null() {
2924 (*ctxt).sax = sax;
2925 }
2926 (*ctxt).userData = data;
2927 if recovery != 0 {
2928 (*ctxt).recovery = 1;
2929 (*ctxt).options |= 1; }
2931 let len = crate::xml::string::xml_strlen(cur);
2932 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2933 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2934 crate::xml::parser::helpers::parse_document(ctxt);
2935 let doc = (*ctxt).myDoc;
2936 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2937 doc
2938}
2939
2940#[no_mangle]
2950pub unsafe extern "C" fn xmlSAXParseFileWithData(
2951 sax: *mut _xmlSAXHandler,
2952 filename: *const c_char,
2953 recovery: c_int,
2954 data: *mut c_void,
2955) -> *mut _xmlDoc {
2956 if filename.is_null() {
2958 return ptr::null_mut();
2959 }
2960 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2961 if ctxt.is_null() {
2962 return ptr::null_mut();
2963 }
2964 if !sax.is_null() {
2965 (*ctxt).sax = sax;
2966 }
2967 (*ctxt).userData = data;
2968 if recovery != 0 {
2969 (*ctxt).recovery = 1;
2970 (*ctxt).options |= 1; }
2972 let input = match crate::xml::parser::helpers::input_from_file(filename) {
2973 Ok(input) => input,
2974 Err(_) => {
2975 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2976 return ptr::null_mut();
2977 }
2978 };
2979 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2980 crate::xml::parser::helpers::parse_document(ctxt);
2981 let doc = (*ctxt).myDoc;
2982 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2983 doc
2984}
2985
2986#[no_mangle]
2996pub unsafe extern "C" fn xmlSAXParseMemoryWithData(
2997 sax: *mut _xmlSAXHandler,
2998 buffer: *const c_char,
2999 size: c_int,
3000 recovery: c_int,
3001 data: *mut c_void,
3002) -> *mut _xmlDoc {
3003 if buffer.is_null() || size <= 0 {
3005 return ptr::null_mut();
3006 }
3007 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3008 if ctxt.is_null() {
3009 return ptr::null_mut();
3010 }
3011 if !sax.is_null() {
3012 (*ctxt).sax = sax;
3013 }
3014 (*ctxt).userData = data;
3015 if recovery != 0 {
3016 (*ctxt).recovery = 1;
3017 (*ctxt).options |= 1; }
3019 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3020 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3021 crate::xml::parser::helpers::parse_document(ctxt);
3022 let doc = (*ctxt).myDoc;
3023 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3024 doc
3025}
3026
3027#[no_mangle]
3035pub unsafe extern "C" fn xmlSAXParseFile(
3036 sax: *mut _xmlSAXHandler,
3037 filename: *const c_char,
3038 recovery: c_int,
3039) -> *mut _xmlDoc {
3040 if filename.is_null() {
3042 return ptr::null_mut();
3043 }
3044 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3045 if ctxt.is_null() {
3046 return ptr::null_mut();
3047 }
3048 if !sax.is_null() {
3049 (*ctxt).sax = sax;
3050 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3051 }
3052 if recovery != 0 {
3053 (*ctxt).recovery = 1;
3054 (*ctxt).options |= 1;
3055 }
3056 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3057 Ok(input) => input,
3058 Err(_) => {
3059 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3060 return ptr::null_mut();
3061 }
3062 };
3063 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3064 crate::xml::parser::helpers::parse_document(ctxt);
3065 let doc = (*ctxt).myDoc;
3066 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3067 doc
3068}
3069
3070#[no_mangle]
3079pub unsafe extern "C" fn xmlSAXParseMemory(
3080 sax: *mut _xmlSAXHandler,
3081 buffer: *const c_char,
3082 size: c_int,
3083 recovery: c_int,
3084) -> *mut _xmlDoc {
3085 if buffer.is_null() || size <= 0 {
3087 return ptr::null_mut();
3088 }
3089 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3090 if ctxt.is_null() {
3091 return ptr::null_mut();
3092 }
3093 if !sax.is_null() {
3094 (*ctxt).sax = sax;
3095 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3096 }
3097 if recovery != 0 {
3098 (*ctxt).recovery = 1;
3099 (*ctxt).options |= 1;
3100 }
3101 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3102 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3103 crate::xml::parser::helpers::parse_document(ctxt);
3104 let doc = (*ctxt).myDoc;
3105 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3106 doc
3107}
3108
3109#[no_mangle]
3118pub unsafe extern "C" fn xmlSAXUserParseFile(
3119 sax: *mut _xmlSAXHandler,
3120 user_data: *mut c_void,
3121 filename: *const c_char,
3122) -> c_int {
3123 if filename.is_null() {
3125 return -1;
3126 }
3127 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3128 if ctxt.is_null() {
3129 return -1;
3130 }
3131 if !sax.is_null() {
3132 (*ctxt).sax = sax;
3133 }
3134 (*ctxt).userData = if !user_data.is_null() {
3135 user_data
3136 } else {
3137 ctxt as *mut c_void
3138 };
3139 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3140 Ok(input) => input,
3141 Err(_) => {
3142 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3143 return -1;
3144 }
3145 };
3146 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3147 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3148 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3149 ret
3150}
3151
3152#[no_mangle]
3161pub unsafe extern "C" fn xmlSAXUserParseMemory(
3162 sax: *mut _xmlSAXHandler,
3163 user_data: *mut c_void,
3164 buffer: *const c_char,
3165 size: c_int,
3166) -> c_int {
3167 if buffer.is_null() || size <= 0 {
3169 return -1;
3170 }
3171 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3172 if ctxt.is_null() {
3173 return -1;
3174 }
3175 if !sax.is_null() {
3176 (*ctxt).sax = sax;
3177 }
3178 (*ctxt).userData = if !user_data.is_null() {
3179 user_data
3180 } else {
3181 ctxt as *mut c_void
3182 };
3183 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3184 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3185 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3186 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3187 ret
3188}
3189
3190#[no_mangle]
3198pub unsafe extern "C" fn xmlParseDoc(cur: *const xmlChar) -> *mut _xmlDoc {
3199 if cur.is_null() {
3201 return ptr::null_mut();
3202 }
3203 xmlReadDoc(cur, ptr::null(), ptr::null(), 0)
3204}
3205
3206#[no_mangle]
3214pub unsafe extern "C" fn xmlParseFile(filename: *const c_char) -> *mut _xmlDoc {
3215 if filename.is_null() {
3217 return ptr::null_mut();
3218 }
3219 xmlReadFile(filename, ptr::null(), 0)
3220}
3221
3222#[no_mangle]
3230pub unsafe extern "C" fn xmlParseMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
3231 if buffer.is_null() || size <= 0 {
3233 return ptr::null_mut();
3234 }
3235 xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 0)
3236}
3237
3238#[no_mangle]
3246pub unsafe extern "C" fn xmlCreateFileParserCtxt(filename: *const c_char) -> *mut _xmlParserCtxt {
3247 if filename.is_null() {
3249 return ptr::null_mut();
3250 }
3251 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3252 if ctxt.is_null() {
3253 return ptr::null_mut();
3254 }
3255 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3256 Ok(input) => input,
3257 Err(_) => {
3258 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3259 return ptr::null_mut();
3260 }
3261 };
3262 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3263 ctxt
3264}
3265
3266#[no_mangle]
3274pub unsafe extern "C" fn xmlCreateDocParserCtxt(cur: *const xmlChar) -> *mut _xmlParserCtxt {
3275 if cur.is_null() {
3277 return ptr::null_mut();
3278 }
3279 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3280 if ctxt.is_null() {
3281 return ptr::null_mut();
3282 }
3283 let len = crate::xml::string::xml_strlen(cur);
3284 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
3285 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3286 ctxt
3287}
3288
3289#[no_mangle]
3297pub unsafe extern "C" fn xmlParseDocument(ctxt: *mut _xmlParserCtxt) -> c_int {
3298 if ctxt.is_null() {
3300 return -1;
3301 }
3302 crate::xml::parser::helpers::parse_document(ctxt)
3303}
3304
3305#[no_mangle]
3313pub unsafe extern "C" fn xmlFreeParserCtxt(ctxt: *mut _xmlParserCtxt) {
3314 if ctxt.is_null() {
3315 return;
3316 }
3317 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3318}
3319
3320#[no_mangle]
3328pub unsafe extern "C" fn xmlCtxtUseOptions(ctxt: *mut _xmlParserCtxt, options: c_int) -> c_int {
3329 if ctxt.is_null() {
3330 return -1;
3331 }
3332 unsafe {
3334 (*ctxt).options = options;
3335 }
3336 0
3337}
3338
3339#[no_mangle]
3348pub unsafe extern "C" fn xmlParseChunk(
3349 ctxt: *mut _xmlParserCtxt,
3350 chunk: *const c_char,
3351 size: c_int,
3352 terminate: c_int,
3353) -> c_int {
3354 if ctxt.is_null() {
3357 return -1;
3358 }
3359 crate::xml::parser::helpers::parse_chunk(ctxt, chunk, size, terminate)
3360}
3361
3362#[no_mangle]
3370pub unsafe extern "C" fn xmlParserInputBufferCreateMem(
3371 buffer: *const c_char,
3372 size: c_int,
3373 enc: c_int,
3374) -> *mut _xmlParserInputBuffer {
3375 if buffer.is_null() || size <= 0 {
3377 return ptr::null_mut();
3378 }
3379 crate::xml::parser::helpers::alloc_parser_input_buffer()
3380}
3381
3382#[no_mangle]
3390pub unsafe extern "C" fn xmlParserInputBufferCreateFilename(
3391 URI: *const c_char,
3392 enc: c_int,
3393) -> *mut _xmlParserInputBuffer {
3394 if URI.is_null() {
3396 return ptr::null_mut();
3397 }
3398 crate::xml::parser::helpers::alloc_parser_input_buffer()
3399}
3400
3401#[no_mangle]
3411pub unsafe extern "C" fn xmlParserInputBufferCreateIO(
3412 ioread: Option<xmlInputReadCallback>,
3413 ioclose: Option<xmlInputCloseCallback>,
3414 ioctx: *mut c_void,
3415 enc: c_int,
3416) -> *mut _xmlParserInputBuffer {
3417 let buf = crate::xml::parser::helpers::alloc_parser_input_buffer();
3419 if !buf.is_null() {
3420 (*buf).readcallback = ioread;
3421 (*buf).closecallback = ioclose;
3422 (*buf).context = ioctx;
3423 }
3424 buf
3425}
3426
3427#[no_mangle]
3435pub unsafe extern "C" fn xmlFreeParserInputBuffer(buf: *mut _xmlParserInputBuffer) {
3436 if buf.is_null() {
3437 return;
3438 }
3439 crate::xml::parser::helpers::free_parser_input_buffer(buf);
3440}
3441
3442#[no_mangle]
3450pub unsafe extern "C" fn xmlNewInputFromFile(
3451 ctxt: *mut _xmlParserCtxt,
3452 filename: *const c_char,
3453) -> *mut _xmlParserInput {
3454 if filename.is_null() {
3459 return ptr::null_mut();
3460 }
3461 crate::xml::parser::helpers::alloc_parser_input_buffer() as *mut _xmlParserInput
3462}
3463
3464#[no_mangle]
3472pub unsafe extern "C" fn xmlFreeInputStream(input: *mut _xmlParserInput) {
3473 if input.is_null() {
3474 return;
3475 }
3476 crate::xml::parser::helpers::free_parser_input(input);
3477}
3478
3479#[no_mangle]
3493pub unsafe extern "C" fn xmlOutputBufferCreateFilename(
3494 URI: *const c_char,
3495 encoder: *mut c_void,
3496 compression: c_int,
3497) -> *mut _xmlOutputBuffer {
3498 let _ = compression;
3499 if URI.is_null() {
3500 return ptr::null_mut();
3501 }
3502 crate::xml::io::output_buffer_create_filename(
3503 URI,
3504 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3505 0,
3506 )
3507}
3508
3509#[no_mangle]
3518pub unsafe extern "C" fn xmlOutputBufferCreateFd(
3519 fd: c_int,
3520 encoder: *mut c_void,
3521) -> *mut _xmlOutputBuffer {
3522 if fd < 0 {
3523 return ptr::null_mut();
3524 }
3525 crate::xml::io::output_buffer_create_fd(
3526 fd,
3527 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3528 )
3529}
3530
3531#[no_mangle]
3541pub unsafe extern "C" fn xmlOutputBufferCreateIO(
3542 iowrite: Option<xmlOutputWriteCallback>,
3543 ioclose: Option<xmlOutputCloseCallback>,
3544 ioctx: *mut c_void,
3545 encoder: *mut c_void,
3546) -> *mut _xmlOutputBuffer {
3547 crate::xml::io::output_buffer_create_io(
3548 iowrite,
3549 ioclose,
3550 ioctx,
3551 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3552 )
3553}
3554
3555#[no_mangle]
3563pub unsafe extern "C" fn xmlOutputBufferClose(out: *mut _xmlOutputBuffer) -> c_int {
3564 if out.is_null() {
3565 return -1;
3566 }
3567 crate::xml::io::output_buffer_close(out)
3568}
3569
3570#[no_mangle]
3578pub unsafe extern "C" fn xmlOutputBufferFlush(out: *mut _xmlOutputBuffer) -> c_int {
3579 if out.is_null() {
3580 return -1;
3581 }
3582 crate::xml::io::output_buffer_flush(out)
3583}
3584
3585#[no_mangle]
3593pub unsafe extern "C" fn xmlOutputBufferWrite(
3594 out: *mut _xmlOutputBuffer,
3595 len: c_int,
3596 data: *const c_char,
3597) -> c_int {
3598 if out.is_null() || data.is_null() || len <= 0 {
3599 return -1;
3600 }
3601 crate::xml::io::output_buffer_write(out, len, data)
3602}
3603
3604#[no_mangle]
3612pub unsafe extern "C" fn xmlOutputBufferWriteString(
3613 out: *mut _xmlOutputBuffer,
3614 str: *const c_char,
3615) -> c_int {
3616 if str.is_null() {
3617 return 0;
3618 }
3619 unsafe { xmlOutputBufferWrite(out, xmlStrlen(str as *const xmlChar), str) }
3620}
3621
3622#[no_mangle]
3630pub unsafe extern "C" fn xmlAllocOutputBuffer(encoder: *mut c_void) -> *mut _xmlOutputBuffer {
3631 crate::xml::io::output_buffer_create(
3632 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3633 )
3634}
3635
3636#[no_mangle]
3650pub unsafe extern "C" fn xmlOutputBufferCreateBuffer(
3651 buffer: *mut crate::abi::structs::_xmlBuffer,
3652 encoder: *mut c_void,
3653) -> *mut _xmlOutputBuffer {
3654 crate::xml::io::output_buffer_create_buffer(
3655 buffer,
3656 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3657 )
3658}
3659
3660#[no_mangle]
3668pub unsafe extern "C" fn xmlOutputBufferCreateFile(
3669 file: *mut libc::FILE,
3670 encoder: *mut c_void,
3671) -> *mut _xmlOutputBuffer {
3672 crate::xml::io::output_buffer_create_file(
3673 file,
3674 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3675 )
3676}
3677
3678#[no_mangle]
3684pub unsafe extern "C" fn xmlOutputBufferGetContent(out: *mut _xmlOutputBuffer) -> *const c_char {
3685 crate::xml::io::output_buffer_get_content(out) as *const c_char
3686}
3687
3688#[no_mangle]
3695pub unsafe extern "C" fn xmlOutputBufferGetSize(out: *mut _xmlOutputBuffer) -> c_int {
3696 crate::xml::io::output_buffer_get_size(out)
3697}
3698
3699#[no_mangle]
3707pub unsafe extern "C" fn xmlOutputBufferWriteEscape(
3708 out: *mut _xmlOutputBuffer,
3709 str: *const xmlChar,
3710 escaping: Option<xmlCharEncodingOutputFunc>,
3711) -> c_int {
3712 if out.is_null() || str.is_null() {
3713 return -1;
3714 }
3715 crate::xml::io::output_buffer_write_escape(out, str, escaping)
3716}
3717
3718static mut OUTPUT_CREATE_FILENAME_DEFAULT: Option<
3721 unsafe extern "C" fn(
3722 *const c_char,
3723 *mut crate::abi::structs::_xmlCharEncodingHandler,
3724 c_int,
3725 ) -> *mut _xmlOutputBuffer,
3726> = None;
3727
3728#[no_mangle]
3735pub unsafe extern "C" fn xmlOutputBufferCreateFilenameDefault(
3736 func: Option<
3737 unsafe extern "C" fn(
3738 *const c_char,
3739 *mut crate::abi::structs::_xmlCharEncodingHandler,
3740 c_int,
3741 ) -> *mut _xmlOutputBuffer,
3742 >,
3743) -> Option<
3744 unsafe extern "C" fn(
3745 *const c_char,
3746 *mut crate::abi::structs::_xmlCharEncodingHandler,
3747 c_int,
3748 ) -> *mut _xmlOutputBuffer,
3749> {
3750 let old = unsafe { OUTPUT_CREATE_FILENAME_DEFAULT };
3751 if func.is_some() {
3752 unsafe { OUTPUT_CREATE_FILENAME_DEFAULT = func };
3753 }
3754 old
3755}
3756
3757#[no_mangle]
3760pub unsafe extern "C" fn __xmlOutputBufferCreateFilename() -> *mut Option<
3761 unsafe extern "C" fn(
3762 *const c_char,
3763 *mut crate::abi::structs::_xmlCharEncodingHandler,
3764 c_int,
3765 ) -> *mut _xmlOutputBuffer,
3766> {
3767 unsafe { core::ptr::addr_of_mut!(OUTPUT_CREATE_FILENAME_DEFAULT) }
3768}
3769
3770#[no_mangle]
3782pub extern "C" fn xmlDictCreate() -> *mut c_void {
3783 let d = unsafe { crate::xml::dictionary::dict_create() as *mut c_void };
3784 if !d.is_null() {
3785 *crate::abi::exports_hash::DICT_REFS
3789 .lock()
3790 .entry(d as usize)
3791 .or_insert(0) = 1;
3792 }
3793 d
3794}
3795
3796#[no_mangle]
3804pub extern "C" fn xmlDictCreateSub(sub: *mut c_void) -> *mut c_void {
3805 let d = unsafe {
3806 crate::xml::dictionary::dict_create_sub(sub as *mut crate::xml::dictionary::Dict)
3807 as *mut c_void
3808 };
3809 if !d.is_null() {
3810 *crate::abi::exports_hash::DICT_REFS
3811 .lock()
3812 .entry(d as usize)
3813 .or_insert(0) = 1;
3814 }
3815 d
3816}
3817
3818#[no_mangle]
3830pub unsafe extern "C" fn xmlDictLookup(
3831 dict: *mut c_void,
3832 name: *const xmlChar,
3833 len: c_int,
3834) -> *const xmlChar {
3835 unsafe {
3836 crate::xml::dictionary::dict_lookup(dict as *mut crate::xml::dictionary::Dict, name, len)
3837 }
3838}
3839
3840#[no_mangle]
3848pub unsafe extern "C" fn xmlDictExists(
3849 dict: *mut c_void,
3850 name: *const xmlChar,
3851 len: c_int,
3852) -> *const xmlChar {
3853 unsafe {
3854 crate::xml::dictionary::dict_exists(dict as *mut crate::xml::dictionary::Dict, name, len)
3855 }
3856}
3857
3858#[no_mangle]
3866pub extern "C" fn xmlDictSize(dict: *const c_void) -> c_uint {
3867 unsafe {
3868 crate::xml::dictionary::dict_size(dict as *const crate::xml::dictionary::Dict) as c_uint
3869 }
3870}
3871
3872#[no_mangle]
3884pub extern "C" fn xmlDictFree(dict: *mut c_void) {
3885 if dict.is_null() {
3886 return;
3887 }
3888 let mut remaining = 0u32;
3889 {
3890 let mut refs = crate::abi::exports_hash::DICT_REFS.lock();
3891 if let Some(r) = refs.get_mut(&(dict as usize)) {
3892 if *r > 0 {
3893 *r -= 1;
3894 }
3895 remaining = *r;
3896 if remaining == 0 {
3897 refs.remove(&(dict as usize));
3898 }
3899 }
3900 }
3901 if remaining == 0 {
3902 unsafe { crate::xml::dictionary::dict_free(dict as *mut crate::xml::dictionary::Dict) };
3903 }
3904}
3905
3906#[no_mangle]
3914pub extern "C" fn xmlDictSetLimit(dict: *mut c_void, limit: c_uint) -> c_uint {
3915 unsafe {
3916 crate::xml::dictionary::dict_set_limit(
3917 dict as *mut crate::xml::dictionary::Dict,
3918 limit as usize,
3919 ) as c_uint
3920 }
3921}
3922
3923#[no_mangle]
3931pub extern "C" fn xmlDictGetUsage(dict: *const c_void) -> c_uint {
3932 unsafe {
3933 crate::xml::dictionary::dict_get_usage(dict as *mut crate::xml::dictionary::Dict) as c_uint
3934 }
3935}
3936
3937#[no_mangle]
3949pub extern "C" fn xmlHashCreate(size: c_int) -> *mut c_void {
3950 unsafe { crate::xml::hash::hash_create(size) as *mut c_void }
3951}
3952
3953#[no_mangle]
3961pub extern "C" fn xmlHashCreateDict(size: c_int, dict: *mut c_void) -> *mut c_void {
3962 unsafe { crate::xml::hash::hash_create_dict(size, dict) as *mut c_void }
3963}
3964
3965#[no_mangle]
3973pub extern "C" fn xmlHashFree(
3974 table: *mut c_void,
3975 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
3976) {
3977 unsafe { crate::xml::hash::hash_free(table as *mut crate::xml::hash::HashTable, f) }
3978}
3979
3980#[no_mangle]
3988pub unsafe extern "C" fn xmlHashAddEntry(
3989 table: *mut c_void,
3990 name: *const xmlChar,
3991 userdata: *mut c_void,
3992) -> c_int {
3993 unsafe {
3994 crate::xml::hash::hash_add_entry(table as *mut crate::xml::hash::HashTable, name, userdata)
3995 }
3996}
3997
3998#[no_mangle]
4007pub unsafe extern "C" fn xmlHashAddEntry2(
4008 table: *mut c_void,
4009 name: *const xmlChar,
4010 name2: *const xmlChar,
4011 userdata: *mut c_void,
4012) -> c_int {
4013 unsafe {
4014 crate::xml::hash::hash_add_entry2(
4015 table as *mut crate::xml::hash::HashTable,
4016 name,
4017 name2,
4018 userdata,
4019 )
4020 }
4021}
4022
4023#[no_mangle]
4032pub unsafe extern "C" fn xmlHashAddEntry3(
4033 table: *mut c_void,
4034 name: *const xmlChar,
4035 name2: *const xmlChar,
4036 name3: *const xmlChar,
4037 userdata: *mut c_void,
4038) -> c_int {
4039 unsafe {
4040 crate::xml::hash::hash_add_entry3(
4041 table as *mut crate::xml::hash::HashTable,
4042 name,
4043 name2,
4044 name3,
4045 userdata,
4046 )
4047 }
4048}
4049
4050#[no_mangle]
4059pub unsafe extern "C" fn xmlHashUpdateEntry(
4060 table: *mut c_void,
4061 name: *const xmlChar,
4062 userdata: *mut c_void,
4063 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4064) -> c_int {
4065 unsafe {
4066 crate::xml::hash::hash_update_entry(
4067 table as *mut crate::xml::hash::HashTable,
4068 name,
4069 userdata,
4070 f,
4071 )
4072 }
4073}
4074
4075#[no_mangle]
4077pub unsafe extern "C" fn xmlHashUpdateEntry2(
4078 table: *mut c_void,
4079 name: *const xmlChar,
4080 name2: *const xmlChar,
4081 userdata: *mut c_void,
4082 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4083) -> c_int {
4084 unsafe {
4085 crate::xml::hash::hash_update_entry2(
4086 table as *mut crate::xml::hash::HashTable,
4087 name,
4088 name2,
4089 userdata,
4090 f,
4091 )
4092 }
4093}
4094
4095#[no_mangle]
4097pub unsafe extern "C" fn xmlHashUpdateEntry3(
4098 table: *mut c_void,
4099 name: *const xmlChar,
4100 name2: *const xmlChar,
4101 name3: *const xmlChar,
4102 userdata: *mut c_void,
4103 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4104) -> c_int {
4105 unsafe {
4106 crate::xml::hash::hash_update_entry3(
4107 table as *mut crate::xml::hash::HashTable,
4108 name,
4109 name2,
4110 name3,
4111 userdata,
4112 f,
4113 )
4114 }
4115}
4116
4117#[no_mangle]
4125pub unsafe extern "C" fn xmlHashLookup(table: *mut c_void, name: *const xmlChar) -> *mut c_void {
4126 unsafe { crate::xml::hash::hash_lookup(table as *mut crate::xml::hash::HashTable, name) }
4127}
4128
4129#[no_mangle]
4131pub unsafe extern "C" fn xmlHashLookup2(
4132 table: *mut c_void,
4133 name: *const xmlChar,
4134 name2: *const xmlChar,
4135) -> *mut c_void {
4136 unsafe {
4137 crate::xml::hash::hash_lookup2(table as *mut crate::xml::hash::HashTable, name, name2)
4138 }
4139}
4140
4141#[no_mangle]
4143pub unsafe extern "C" fn xmlHashLookup3(
4144 table: *mut c_void,
4145 name: *const xmlChar,
4146 name2: *const xmlChar,
4147 name3: *const xmlChar,
4148) -> *mut c_void {
4149 unsafe {
4150 crate::xml::hash::hash_lookup3(
4151 table as *mut crate::xml::hash::HashTable,
4152 name,
4153 name2,
4154 name3,
4155 )
4156 }
4157}
4158
4159#[no_mangle]
4167pub extern "C" fn xmlHashSize(table: *mut c_void) -> c_int {
4168 unsafe { crate::xml::hash::hash_size(table as *mut crate::xml::hash::HashTable) }
4169}
4170
4171#[no_mangle]
4180pub unsafe extern "C" fn xmlHashRemoveEntry(
4181 table: *mut c_void,
4182 name: *const xmlChar,
4183 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4184) -> c_int {
4185 unsafe {
4186 crate::xml::hash::hash_remove_entry(table as *mut crate::xml::hash::HashTable, name, f)
4187 }
4188}
4189
4190#[no_mangle]
4192pub unsafe extern "C" fn xmlHashRemoveEntry2(
4193 table: *mut c_void,
4194 name: *const xmlChar,
4195 name2: *const xmlChar,
4196 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4197) -> c_int {
4198 unsafe {
4199 crate::xml::hash::hash_remove_entry2(
4200 table as *mut crate::xml::hash::HashTable,
4201 name,
4202 name2,
4203 f,
4204 )
4205 }
4206}
4207
4208#[no_mangle]
4210pub unsafe extern "C" fn xmlHashRemoveEntry3(
4211 table: *mut c_void,
4212 name: *const xmlChar,
4213 name2: *const xmlChar,
4214 name3: *const xmlChar,
4215 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4216) -> c_int {
4217 unsafe {
4218 crate::xml::hash::hash_remove_entry3(
4219 table as *mut crate::xml::hash::HashTable,
4220 name,
4221 name2,
4222 name3,
4223 f,
4224 )
4225 }
4226}
4227
4228#[no_mangle]
4236pub extern "C" fn xmlHashScan(table: *mut c_void, f: Option<xmlHashScanner>, data: *mut c_void) {
4237 unsafe { crate::xml::hash::hash_scan(table as *mut crate::xml::hash::HashTable, f, data) }
4238}
4239
4240#[no_mangle]
4242pub extern "C" fn xmlHashScanFull(
4243 table: *mut c_void,
4244 f: Option<xmlHashScannerFull>,
4245 data: *mut c_void,
4246) {
4247 unsafe { crate::xml::hash::hash_scan_full(table as *mut crate::xml::hash::HashTable, f, data) }
4248}
4249
4250#[no_mangle]
4258pub extern "C" fn xmlHashCopy(
4259 table: *mut c_void,
4260 f: Option<unsafe extern "C" fn(*mut c_void, *const xmlChar) -> *mut c_void>,
4261) -> *mut c_void {
4262 unsafe {
4263 crate::xml::hash::hash_copy(table as *mut crate::xml::hash::HashTable, f) as *mut c_void
4264 }
4265}
4266
4267#[no_mangle]
4280pub extern "C" fn xmlListCreate(
4281 deallocator: Option<unsafe extern "C" fn(*mut c_void)>,
4282 compare: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
4283) -> *mut c_void {
4284 unsafe { crate::xml::list::list_create(deallocator, compare) as *mut c_void }
4285}
4286
4287#[no_mangle]
4295pub extern "C" fn xmlListDelete(list: *mut c_void) {
4296 unsafe { crate::xml::list::list_delete(list as *mut crate::xml::list::List) }
4297}
4298
4299#[no_mangle]
4307pub extern "C" fn xmlListSearch(list: *mut c_void, data: *mut c_void) -> *mut c_void {
4308 unsafe { crate::xml::list::list_search(list as *mut crate::xml::list::List, data) }
4309}
4310
4311#[no_mangle]
4319pub extern "C" fn xmlListWalk(
4320 list: *mut c_void,
4321 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4322 data: *mut c_void,
4323) {
4324 unsafe { crate::xml::list::list_walk(list as *mut crate::xml::list::List, walker, data) }
4325}
4326
4327#[no_mangle]
4335pub extern "C" fn xmlListPushBack(list: *mut c_void, data: *mut c_void) -> c_int {
4336 unsafe { crate::xml::list::list_push_back(list as *mut crate::xml::list::List, data) }
4337}
4338
4339#[no_mangle]
4347pub extern "C" fn xmlListPushFront(list: *mut c_void, data: *mut c_void) -> c_int {
4348 unsafe { crate::xml::list::list_push_front(list as *mut crate::xml::list::List, data) }
4349}
4350
4351#[no_mangle]
4353pub extern "C" fn xmlListPopBack(list: *mut c_void) {
4354 unsafe { crate::xml::list::list_pop_back(list as *mut crate::xml::list::List) }
4355}
4356
4357#[no_mangle]
4359pub extern "C" fn xmlListPopFront(list: *mut c_void) {
4360 unsafe { crate::xml::list::list_pop_front(list as *mut crate::xml::list::List) }
4361}
4362
4363#[no_mangle]
4371pub extern "C" fn xmlListInsert(list: *mut c_void, data: *mut c_void) -> c_int {
4372 unsafe { crate::xml::list::list_insert(list as *mut crate::xml::list::List, data) }
4373}
4374
4375#[no_mangle]
4377pub extern "C" fn xmlListAppend(list: *mut c_void, data: *mut c_void) -> c_int {
4378 unsafe { crate::xml::list::list_append(list as *mut crate::xml::list::List, data) }
4379}
4380
4381#[no_mangle]
4383pub extern "C" fn xmlListRemoveFirst(list: *mut c_void, data: *mut c_void) -> c_int {
4384 unsafe { crate::xml::list::list_remove_first(list as *mut crate::xml::list::List, data) }
4385}
4386
4387#[no_mangle]
4389pub extern "C" fn xmlListRemoveLast(list: *mut c_void, data: *mut c_void) -> c_int {
4390 unsafe { crate::xml::list::list_remove_last(list as *mut crate::xml::list::List, data) }
4391}
4392
4393#[no_mangle]
4395pub extern "C" fn xmlListRemoveAll(list: *mut c_void, data: *mut c_void) -> c_int {
4396 unsafe { crate::xml::list::list_remove_all(list as *mut crate::xml::list::List, data) }
4397}
4398
4399#[no_mangle]
4401pub extern "C" fn xmlListClear(list: *mut c_void) {
4402 unsafe { crate::xml::list::list_clear(list as *mut crate::xml::list::List) }
4403}
4404
4405#[no_mangle]
4413pub extern "C" fn xmlListEmpty(list: *mut c_void) -> c_int {
4414 unsafe { crate::xml::list::list_empty(list as *mut crate::xml::list::List) }
4415}
4416
4417#[no_mangle]
4425pub extern "C" fn xmlListFront(list: *mut c_void) -> *mut c_void {
4426 unsafe { crate::xml::list::list_front(list as *mut crate::xml::list::List) }
4427}
4428
4429#[no_mangle]
4437pub extern "C" fn xmlListBack(list: *mut c_void) -> *mut c_void {
4438 unsafe { crate::xml::list::list_back(list as *mut crate::xml::list::List) }
4439}
4440
4441#[no_mangle]
4449pub extern "C" fn xmlListSize(list: *mut c_void) -> c_int {
4450 unsafe { crate::xml::list::list_size(list as *mut crate::xml::list::List) }
4451}
4452
4453#[no_mangle]
4455pub extern "C" fn xmlListSort(list: *mut c_void) {
4456 unsafe { crate::xml::list::list_sort(list as *mut crate::xml::list::List) }
4457}
4458
4459#[no_mangle]
4461pub extern "C" fn xmlListReverse(list: *mut c_void) {
4462 unsafe { crate::xml::list::list_reverse(list as *mut crate::xml::list::List) }
4463}
4464
4465#[no_mangle]
4467pub extern "C" fn xmlListReverseSplice(list: *mut c_void, list2: *mut c_void) {
4468 unsafe {
4469 crate::xml::list::list_reverse_splice(
4470 list as *mut crate::xml::list::List,
4471 list2 as *mut crate::xml::list::List,
4472 )
4473 }
4474}
4475
4476#[no_mangle]
4478pub extern "C" fn xmlListMerge(list: *mut c_void, list2: *mut c_void) {
4479 unsafe {
4480 crate::xml::list::list_merge(
4481 list as *mut crate::xml::list::List,
4482 list2 as *mut crate::xml::list::List,
4483 )
4484 }
4485}
4486#[no_mangle]
4494pub unsafe extern "C" fn xmlListEnd(l: *mut c_void) -> *mut c_void {
4495 crate::xml::list::list_end(l as *mut crate::xml::list::List)
4496}
4497
4498#[no_mangle]
4506pub unsafe extern "C" fn xmlListReverseSearch(l: *mut c_void, data: *mut c_void) -> *mut c_void {
4507 crate::xml::list::list_reverse_search(l as *mut crate::xml::list::List, data)
4508}
4509
4510#[no_mangle]
4518pub unsafe extern "C" fn xmlListReverseWalk(
4519 l: *mut c_void,
4520 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4521 data: *mut c_void,
4522) {
4523 crate::xml::list::list_reverse_walk(l as *mut crate::xml::list::List, walker, data)
4524}
4525
4526#[no_mangle]
4534pub unsafe extern "C" fn xmlListDup(l: *mut c_void) -> *mut c_void {
4535 crate::xml::list::list_dup(l as *mut crate::xml::list::List) as *mut c_void
4536}
4537
4538#[no_mangle]
4546pub unsafe extern "C" fn xmlListCopy(
4547 l: *mut c_void,
4548 copier: Option<unsafe extern "C" fn(*mut c_void) -> *mut c_void>,
4549) -> c_int {
4550 crate::xml::list::list_copy(l as *mut crate::xml::list::List, copier)
4551}
4552
4553#[no_mangle]
4561pub unsafe extern "C" fn xmlLinkGetData(lk: *mut c_void) -> *mut c_void {
4562 crate::xml::list::link_get_data(lk)
4563}
4564
4565#[no_mangle]
4577pub extern "C" fn xmlBufferCreate() -> *mut _xmlBuffer {
4578 crate::xml::io::buf_create(-1)
4579}
4580
4581#[no_mangle]
4589pub extern "C" fn xmlBufferCreateSize(size: usize) -> *mut _xmlBuffer {
4590 crate::xml::io::buf_create(size as c_int)
4591}
4592
4593#[no_mangle]
4601pub extern "C" fn xmlBufferCreateStatic(mem: *mut c_void, size: usize) -> *mut _xmlBuffer {
4602 if mem.is_null() || size == 0 {
4603 return ptr::null_mut();
4604 }
4605 crate::xml::io::buf_create_static(mem as *const xmlChar, size as c_int)
4606}
4607
4608#[no_mangle]
4616pub extern "C" fn xmlBufferFree(buf: *mut _xmlBuffer) {
4617 crate::xml::io::buf_free(buf)
4618}
4619
4620#[no_mangle]
4628pub extern "C" fn xmlBufferEmpty(buf: *mut _xmlBuffer) {
4629 if buf.is_null() {
4630 return;
4631 }
4632 unsafe {
4633 if !(*buf).content.is_null() {
4634 *(*buf).content = 0;
4635 }
4636 (*buf).use_ = 0;
4637 }
4638}
4639
4640#[no_mangle]
4648pub extern "C" fn xmlBufferContent(buf: *const _xmlBuffer) -> *mut xmlChar {
4649 crate::xml::io::buf_content(buf as *mut _xmlBuffer)
4650}
4651
4652#[no_mangle]
4660pub extern "C" fn xmlBufferLength(buf: *const _xmlBuffer) -> c_int {
4661 crate::xml::io::buf_length(buf as *mut _xmlBuffer)
4662}
4663
4664#[no_mangle]
4672pub unsafe extern "C" fn xmlBufferAdd(
4673 buf: *mut _xmlBuffer,
4674 str: *const xmlChar,
4675 len: c_int,
4676) -> c_int {
4677 crate::xml::io::buf_add(buf, str, len)
4678}
4679
4680#[no_mangle]
4688pub unsafe extern "C" fn xmlBufferAddHead(
4689 buf: *mut _xmlBuffer,
4690 str: *const xmlChar,
4691 len: c_int,
4692) -> c_int {
4693 crate::xml::io::buf_add_head(buf, str, len)
4694}
4695
4696#[no_mangle]
4704pub unsafe extern "C" fn xmlBufferCat(buf: *mut _xmlBuffer, str: *const xmlChar) -> c_int {
4705 if str.is_null() {
4706 return -1;
4707 }
4708 let len = crate::xml::string::xml_strlen(str) as c_int;
4709 crate::xml::io::buf_add(buf, str, len)
4710}
4711
4712#[no_mangle]
4721pub extern "C" fn xmlBufferSetAllocationScheme(buf: *mut _xmlBuffer, scheme: c_int) {
4722 if buf.is_null() {
4723 return;
4724 }
4725 unsafe {
4726 (*buf).alloc = scheme;
4727 }
4728}
4729
4730#[no_mangle]
4738pub extern "C" fn xmlBufferShrink(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4739 if buf.is_null() || len <= 0 {
4740 return 0;
4741 }
4742 unsafe {
4743 let b = &mut *buf;
4744 let shrink_len = (len as c_uint).min(b.use_);
4745 if shrink_len > 0 {
4746 let remaining = b.use_ - shrink_len;
4747 if remaining > 0 {
4748 core::ptr::copy(
4749 b.content.add(shrink_len as usize),
4750 b.content,
4751 remaining as usize,
4752 );
4753 }
4754 *b.content.add(remaining as usize) = 0;
4755 b.use_ = remaining;
4756 }
4757 }
4758 len
4759}
4760
4761#[no_mangle]
4769pub extern "C" fn xmlBufferGrow(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4770 if buf.is_null() || len <= 0 {
4771 return 0;
4772 }
4773 let cur_use = unsafe { (*buf).use_ };
4774 let new_size = cur_use + len as c_uint + 1;
4775 crate::xml::io::buf_grow(buf, new_size)
4776}
4777
4778#[no_mangle]
4786pub extern "C" fn xmlBufferReserve(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4787 xmlBufferGrow(buf, len)
4788}
4789
4790#[no_mangle]
4798pub extern "C" fn xmlBufferDetach(buf: *mut _xmlBuffer) -> *mut xmlChar {
4799 if buf.is_null() {
4800 return ptr::null_mut();
4801 }
4802 unsafe {
4803 let content = (*buf).content;
4804 (*buf).content = ptr::null_mut();
4805 (*buf).use_ = 0;
4806 (*buf).size = 0;
4807 content
4808 }
4809}
4810
4811#[no_mangle]
4823pub extern "C" fn xmlGetCharEncoding(name: *const c_char) -> c_int {
4824 if name.is_null() {
4825 return 0; }
4827 let name_bytes = unsafe {
4828 let len = libc::strlen(name);
4829 core::slice::from_raw_parts(name as *const u8, len)
4830 };
4831 crate::xml::encoding::encoding_from_name(name_bytes) as c_int
4832}
4833
4834#[no_mangle]
4842pub extern "C" fn xmlFindCharEncodingHandler(name: *const c_char) -> *mut c_void {
4843 if name.is_null() {
4844 return ptr::null_mut();
4845 }
4846 crate::xml::encoding::find_encoding_handler(name as *const xmlChar) as *mut c_void
4847}
4848
4849#[no_mangle]
4857pub extern "C" fn xmlCharEncCloseFunc(handler: *mut c_void) -> c_int {
4858 if handler.is_null() {
4859 return -1;
4860 }
4861 unsafe {
4863 let h = handler as *mut crate::abi::structs::_xmlCharEncodingHandler;
4864 if !(*h).name.is_null() {
4865 crate::abi::allocator::xmlFreeImpl((*h).name as *mut c_void);
4866 }
4867 crate::abi::allocator::xmlFreeImpl(handler);
4868 }
4869 0
4870}
4871
4872#[no_mangle]
4880pub extern "C" fn xmlGetCharEncodingName(enc: c_int) -> *const c_char {
4881 if enc < -1 || enc > 22 {
4885 return match enc {
4886 23 => c"UTF-16".as_ptr(),
4887 24 => c"HTML".as_ptr(),
4888 31 => c"windows-1252".as_ptr(),
4889 _ => ptr::null(),
4890 };
4891 }
4892 let e: crate::abi::types::xmlCharEncoding = unsafe { core::mem::transmute(enc) };
4893 crate::xml::encoding::xmlGetCharEncodingName(e)
4894}
4895
4896#[no_mangle]
4906pub extern "C" fn xmlParseCharEncoding(name: *const c_char) -> c_int {
4907 crate::xml::encoding::xmlParseCharEncoding(name)
4908}
4909
4910#[no_mangle]
4918pub extern "C" fn xmlAddEncodingAlias(name: *const c_char, alias: *const c_char) -> c_int {
4919 crate::xml::encoding::add_encoding_alias(name, alias)
4920}
4921
4922#[no_mangle]
4930pub extern "C" fn xmlDelEncodingAlias(alias: *const c_char) -> c_int {
4931 crate::xml::encoding::del_encoding_alias(alias)
4932}
4933
4934#[no_mangle]
4942pub extern "C" fn xmlGetEncodingAlias(alias: *const c_char) -> *const c_char {
4943 crate::xml::encoding::get_encoding_alias(alias)
4944}
4945
4946#[no_mangle]
4954pub extern "C" fn xmlCleanupEncodingAliases() {
4955 crate::xml::encoding::cleanup_encoding_aliases();
4956}
4957
4958#[no_mangle]
4967pub extern "C" fn xmlCharEncInFunc(
4968 handler: *mut c_void,
4969 out: *mut c_void,
4970 in_: *mut c_void,
4971) -> c_int {
4972 crate::xml::encoding::xmlCharEncInFunc(
4973 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
4974 out as *mut crate::abi::structs::_xmlBuffer,
4975 in_ as *mut crate::abi::structs::_xmlBuffer,
4976 )
4977}
4978
4979#[no_mangle]
4988pub extern "C" fn xmlCharEncOutFunc(
4989 handler: *mut c_void,
4990 out: *mut c_void,
4991 in_: *mut c_void,
4992) -> c_int {
4993 crate::xml::encoding::xmlCharEncOutFunc(
4994 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
4995 out as *mut crate::abi::structs::_xmlBuffer,
4996 in_ as *mut crate::abi::structs::_xmlBuffer,
4997 )
4998}
4999
5000#[no_mangle]
5010pub extern "C" fn xmlNewCharEncodingHandler(
5011 name: *const c_char,
5012 input: crate::abi::callbacks::xmlCharEncodingInputFunc,
5013 output: crate::abi::callbacks::xmlCharEncodingOutputFunc,
5014) -> *mut c_void {
5015 crate::xml::encoding::xmlNewCharEncodingHandler(name, input, output) as *mut c_void
5016}
5017
5018#[no_mangle]
5026pub extern "C" fn xmlInitCharEncodingHandlers() {
5027 crate::xml::encoding::xmlInitCharEncodingHandlers();
5028}
5029
5030#[no_mangle]
5038pub extern "C" fn xmlCleanupCharEncodingHandlers() {
5039 crate::xml::encoding::xmlCleanupCharEncodingHandlers();
5040}
5041
5042#[no_mangle]
5054pub extern "C" fn xmlLookupCharEncodingHandler(enc: c_int, out: *mut *mut c_void) -> c_int {
5055 crate::xml::encoding::xmlLookupCharEncodingHandler(enc, out)
5056}
5057
5058#[no_mangle]
5066pub extern "C" fn xmlGetCharEncodingHandler(enc: c_int) -> *mut c_void {
5067 crate::xml::encoding::xmlGetCharEncodingHandler(enc)
5068}
5069
5070#[no_mangle]
5079pub extern "C" fn xmlOpenCharEncodingHandler(
5080 name: *const c_char,
5081 output: c_int,
5082 out: *mut *mut c_void,
5083) -> c_int {
5084 crate::xml::encoding::xmlOpenCharEncodingHandler(name, output, out)
5085}
5086
5087#[no_mangle]
5098pub extern "C" fn xmlCreateCharEncodingHandler(
5099 name: *const c_char,
5100 flags: c_int,
5101 impl_: Option<crate::abi::callbacks::xmlCharEncConvImpl>,
5102 implCtxt: *mut c_void,
5103 out: *mut *mut c_void,
5104) -> c_int {
5105 crate::xml::encoding::xmlCreateCharEncodingHandler(name, flags, impl_, implCtxt, out)
5106}
5107
5108#[no_mangle]
5119pub extern "C" fn xmlCharEncNewCustomHandler(
5120 name: *const c_char,
5121 input: crate::abi::callbacks::xmlCharEncConvFunc,
5122 output: crate::abi::callbacks::xmlCharEncConvFunc,
5123 ctxtDtor: Option<crate::abi::callbacks::xmlCharEncConvCtxtDtor>,
5124 inputCtxt: *mut c_void,
5125 outputCtxt: *mut c_void,
5126 out: *mut *mut c_void,
5127) -> c_int {
5128 crate::xml::encoding::xmlCharEncNewCustomHandler(
5129 name, input, output, ctxtDtor, inputCtxt, outputCtxt, out,
5130 )
5131}
5132
5133#[no_mangle]
5141pub unsafe extern "C" fn xmlCharEncInput(input: *mut _xmlParserInputBuffer, _to: c_int) -> c_int {
5142 if input.is_null() {
5143 return -1;
5144 }
5145 let handler = (*input).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5146 if handler.is_null() {
5147 return -1;
5148 }
5149 let raw = (*input).raw as *mut crate::abi::structs::_xmlBuffer;
5150 let buf = (*input).buffer as *mut crate::abi::structs::_xmlBuffer;
5151 if raw.is_null() || buf.is_null() {
5152 return -1;
5153 }
5154 crate::xml::encoding::char_enc_in(handler, buf, raw)
5155}
5156
5157#[no_mangle]
5165pub unsafe extern "C" fn xmlCharEncOutput(output: *mut _xmlOutputBuffer, _to: c_int) -> c_int {
5166 if output.is_null() {
5167 return -1;
5168 }
5169 let handler = (*output).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5170 if handler.is_null() {
5171 return -1;
5172 }
5173 let buf = (*output).buffer as *mut crate::abi::structs::_xmlBuffer;
5174 let conv = (*output).conv as *mut crate::abi::structs::_xmlBuffer;
5175 if buf.is_null() || conv.is_null() {
5176 return -1;
5177 }
5178 crate::xml::encoding::char_enc_out(handler, conv, buf)
5179}
5180
5181#[no_mangle]
5193pub unsafe extern "C" fn xmlParseURI(str: *const c_char) -> *mut c_void {
5194 crate::xml::uri::xmlParseURI(str)
5195}
5196
5197#[no_mangle]
5205pub unsafe extern "C" fn xmlParseURIRaw(str: *const c_char, raw: c_int) -> *mut c_void {
5206 let _ = raw;
5207 crate::xml::uri::xmlParseURI(str)
5208}
5209
5210#[no_mangle]
5218pub unsafe extern "C" fn xmlFreeURI(uri: *mut c_void) {
5219 crate::xml::uri::xmlFreeURI(uri)
5220}
5221
5222#[no_mangle]
5230pub extern "C" fn xmlCreateURI() -> *mut c_void {
5231 crate::xml::uri::xmlCreateURI()
5232}
5233
5234#[no_mangle]
5242pub unsafe extern "C" fn xmlSaveUri(uri: *mut c_void) -> *mut xmlChar {
5243 crate::xml::uri::xmlSaveUri(uri)
5244}
5245
5246#[no_mangle]
5262pub unsafe extern "C" fn xmlParseURIReference(uri: *mut c_void, str: *const c_char) -> c_int {
5263 crate::xml::uri::xmlParseURIReference(uri, str)
5264}
5265
5266#[no_mangle]
5281pub unsafe extern "C" fn xmlNormalizeURIPath(path: *mut c_char) -> c_int {
5282 crate::xml::uri::xmlNormalizeURIPath(path)
5283}
5284
5285#[no_mangle]
5293pub unsafe extern "C" fn xmlURIEscapeStr(
5294 str: *const xmlChar,
5295 list: *const xmlChar,
5296) -> *mut xmlChar {
5297 crate::xml::uri::xmlURIEscapeStr(str, list)
5298}
5299
5300#[no_mangle]
5308pub unsafe extern "C" fn xmlURIUnescapeString(
5309 str: *const c_char,
5310 len: c_int,
5311 target: *mut c_char,
5312) -> *mut c_char {
5313 crate::xml::uri::xmlURIUnescapeString(str, len, target)
5314}
5315
5316unsafe fn xpath_to_object(val: XPathValue) -> *mut _xmlXPathObject {
5331 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
5332 if obj.is_null() {
5333 return ptr::null_mut();
5334 }
5335 match val {
5336 XPathValue::NodeSet(ns) => {
5337 (*obj).type_ = xmlXPathObjectType::XPATH_NODESET as c_int;
5338 (*obj).nodesetval = ns.to_raw() as *mut c_void;
5339 }
5340 XPathValue::Boolean(b) => {
5341 (*obj).type_ = xmlXPathObjectType::XPATH_BOOLEAN as c_int;
5342 (*obj).boolval = if b { 1 } else { 0 };
5343 }
5344 XPathValue::Number(n) => {
5345 (*obj).type_ = xmlXPathObjectType::XPATH_NUMBER as c_int;
5346 (*obj).floatval = n;
5347 }
5348 XPathValue::String(s) => {
5349 (*obj).type_ = xmlXPathObjectType::XPATH_STRING as c_int;
5350 let bytes = s.as_bytes();
5351 let len = bytes.len();
5352 let buf = xmlMallocImpl(len + 1) as *mut xmlChar;
5353 if !buf.is_null() {
5354 ptr::copy_nonoverlapping(bytes.as_ptr(), buf, len);
5355 *buf.add(len) = 0; }
5357 (*obj).stringval = buf;
5358 }
5359 }
5360 obj
5361}
5362
5363unsafe fn object_to_xpathvalue(obj: *mut _xmlXPathObject) -> XPathValue {
5370 let typ = (*obj).type_;
5371 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5372 let ns_ptr = (*obj).nodesetval as *mut _xmlNodeSet;
5373 if ns_ptr.is_null() {
5374 return XPathValue::NodeSet(NodeSet::new());
5375 }
5376 let node_nr = (*ns_ptr).nodeNr;
5377 let node_tab = (*ns_ptr).nodeTab;
5378 let mut ns = NodeSet::new();
5379 if !node_tab.is_null() {
5380 for i in 0..node_nr as isize {
5381 let node = *node_tab.add(i as usize);
5382 ns.push(node);
5383 }
5384 }
5385 XPathValue::NodeSet(ns)
5386 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5387 XPathValue::Boolean((*obj).boolval != 0)
5388 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5389 XPathValue::Number((*obj).floatval)
5390 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5391 let s_ptr = (*obj).stringval;
5392 if s_ptr.is_null() {
5393 XPathValue::String(String::new())
5394 } else {
5395 let s = CStr::from_ptr(s_ptr as *const c_char)
5396 .to_string_lossy()
5397 .into_owned();
5398 XPathValue::String(s)
5399 }
5400 } else if typ == xmlXPathObjectType::XPATH_XSLT_TREE as c_int {
5401 let frag_doc = (*obj).nodesetval as *mut _xmlDoc;
5406 if frag_doc.is_null() {
5407 XPathValue::NodeSet(NodeSet::new())
5408 } else {
5409 let mut ns = NodeSet::new();
5410 ns.push(frag_doc as *mut _xmlNode);
5411 XPathValue::NodeSet(ns)
5412 }
5413 } else {
5414 XPathValue::Boolean(false)
5416 }
5417}
5418
5419pub unsafe fn xpath_to_object_pub(val: XPathValue) -> *mut _xmlXPathObject {
5425 xpath_to_object(val)
5426}
5427
5428pub unsafe fn object_to_xpathvalue_pub(obj: *mut _xmlXPathObject) -> XPathValue {
5435 object_to_xpathvalue(obj)
5436}
5437
5438static COMPILED_EXPRS: Lazy<Mutex<HashMap<u64, Box<CompiledExpr>>>> =
5444 Lazy::new(|| Mutex::new(HashMap::new()));
5445static NEXT_COMPILED_KEY: Lazy<Mutex<u64>> = Lazy::new(|| Mutex::new(1));
5446
5447pub(crate) fn xpath_compiled_registry() -> &'static Mutex<HashMap<u64, Box<CompiledExpr>>> {
5450 &COMPILED_EXPRS
5451}
5452
5453type CXPathFunc = unsafe extern "C" fn(*mut c_void, c_int);
5463
5464#[derive(Clone, Copy, PartialEq, Eq, Hash)]
5467struct SendSyncPtr(*mut c_void);
5468unsafe impl Send for SendSyncPtr {}
5469unsafe impl Sync for SendSyncPtr {}
5470
5471static C_FUNCTIONS: Lazy<Mutex<HashMap<(SendSyncPtr, String), CXPathFunc>>> =
5472 Lazy::new(|| Mutex::new(HashMap::new()));
5473
5474pub(crate) fn xpath_cfunc_lookup(extra: *mut c_void, qualified: &str) -> Option<CXPathFunc> {
5478 C_FUNCTIONS
5479 .lock()
5480 .get(&(SendSyncPtr(extra), qualified.to_string()))
5481 .copied()
5482}
5483
5484pub(crate) fn xpath_cfunc_cleanup(extra: *mut c_void) {
5487 C_FUNCTIONS.lock().retain(|(k, _), _| k.0 != extra);
5488}
5489
5490fn c_func_bridge_closure(c_ctxt: SendSyncPtr, qualified: String) -> BoxedXPathFunction {
5495 Box::new(move |_ctx: &mut XPathContext, args: &[XPathValue]| {
5496 let cc = c_ctxt;
5497 unsafe { c_func_call_bridge(cc.0 as *mut _xmlXPathContext, &qualified, args) }
5498 })
5499}
5500
5501pub(crate) unsafe fn call_c_xpath_function(
5511 fnptr: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
5512 c_ctxt: *mut _xmlXPathContext,
5513 args: &[XPathValue],
5514) -> Result<XPathValue, String> {
5515 let func = match fnptr {
5516 Some(f) => f,
5517 None => return Err("XPath: missing C function pointer".to_string()),
5518 };
5519 let pc = crate::xml::xpath::parser_context::new_parser_context(ptr::null(), c_ctxt);
5520 if pc.is_null() {
5521 return Err("XPath: parser-context allocation failure".to_string());
5522 }
5523 let mut push_ok = true;
5524 for v in args {
5525 let obj = xpath_to_object(v.clone());
5526 if obj.is_null() || crate::xml::xpath::parser_context::value_push(pc, obj).is_null() {
5527 push_ok = false;
5528 break;
5529 }
5530 }
5531 let result = if push_ok {
5532 unsafe { func(pc as *mut c_void, args.len() as c_int) };
5535 let ret = crate::xml::xpath::parser_context::value_pop(pc);
5536 if ret.is_null() {
5537 Err("XPath: C function returned no value".to_string())
5538 } else {
5539 let v = object_to_xpathvalue(ret);
5540 unsafe { xmlXPathFreeObject(ret) };
5542 Ok(v)
5543 }
5544 } else {
5545 Err("XPath: failed to push arguments to C function".to_string())
5546 };
5547 unsafe {
5549 loop {
5550 let leftover = crate::xml::xpath::parser_context::value_pop(pc);
5551 if leftover.is_null() {
5552 break;
5553 }
5554 xmlXPathFreeObject(leftover);
5555 }
5556 crate::xml::xpath::parser_context::free_parser_context(pc);
5557 }
5558 result
5559}
5560
5561unsafe fn c_func_call_bridge(
5568 c_ctxt: *mut _xmlXPathContext,
5569 qualified: &str,
5570 args: &[XPathValue],
5571) -> Result<XPathValue, String> {
5572 if c_ctxt.is_null() {
5573 return Err("XPath: null context in C function bridge".to_string());
5574 }
5575 let func = xpath_cfunc_lookup((*c_ctxt).extra, qualified);
5576 if func.is_none() {
5577 return Err(format!("XPath: unknown C function '{}'", qualified));
5578 }
5579 unsafe { call_c_xpath_function(func, c_ctxt, args) }
5580}
5581
5582#[no_mangle]
5595pub unsafe extern "C" fn xmlXPathNewContext(doc: *mut _xmlDoc) -> *mut _xmlXPathContext {
5596 let ctxt = xmlMallocZero(size_of::<_xmlXPathContext>()) as *mut _xmlXPathContext;
5597 if ctxt.is_null() {
5598 return ptr::null_mut();
5599 }
5600
5601 (*ctxt).doc = doc;
5603 (*ctxt).node = ptr::null_mut();
5604 (*ctxt).contextSize = 1;
5605 (*ctxt).proximityPosition = 1;
5606
5607 let mut internal = Box::new(XPathContext::new(doc));
5609 for (name, func) in crate::xml::xpath::functions::core_functions() {
5614 internal.register_function(&name, func);
5615 }
5616 (*ctxt).extra = Box::into_raw(internal) as *mut c_void;
5617
5618 ctxt
5619}
5620
5621#[no_mangle]
5629pub unsafe extern "C" fn xmlXPathFreeContext(ctxt: *mut _xmlXPathContext) {
5630 if ctxt.is_null() {
5631 return;
5632 }
5633 if !(*ctxt).extra.is_null() {
5635 let _ = Box::from_raw((*ctxt).extra as *mut XPathContext);
5636 (*ctxt).extra = ptr::null_mut();
5637 }
5638 if !(*ctxt).nsHash.is_null() {
5640 drop(Box::from_raw(
5641 (*ctxt).nsHash as *mut HashMap<String, CString>,
5642 ));
5643 (*ctxt).nsHash = ptr::null_mut();
5644 }
5645 xmlFreeImpl(ctxt as *mut c_void);
5647}
5648
5649#[no_mangle]
5658pub unsafe extern "C" fn xmlXPathEvalExpression(
5659 str_: *const xmlChar,
5660 ctxt: *mut _xmlXPathContext,
5661) -> *mut _xmlXPathObject {
5662 if str_.is_null() || ctxt.is_null() {
5663 return ptr::null_mut();
5664 }
5665 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
5666 Ok(s) => s,
5667 Err(_) => return ptr::null_mut(),
5668 };
5669 let internal = (*ctxt).extra as *mut XPathContext;
5670 if internal.is_null() {
5671 return ptr::null_mut();
5672 }
5673 let internal = &mut *internal;
5674
5675 match crate::xml::xpath::evaluate_str(expr_str, internal) {
5676 Some(val) => xpath_to_object(val),
5677 None => {
5678 if internal.error.is_none() {
5683 internal.set_error("Invalid expression");
5684 }
5685 ptr::null_mut()
5686 }
5687 }
5688}
5689
5690#[no_mangle]
5698pub unsafe extern "C" fn xmlXPathEval(
5699 str_: *const xmlChar,
5700 ctxt: *mut _xmlXPathContext,
5701) -> *mut _xmlXPathObject {
5702 xmlXPathEvalExpression(str_, ctxt)
5703}
5704
5705#[no_mangle]
5716pub unsafe extern "C" fn xmlXPathFreeObject(obj: *mut _xmlXPathObject) {
5717 if obj.is_null() {
5718 return;
5719 }
5720 let typ = (*obj).type_;
5721 if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5723 if !(*obj).stringval.is_null() {
5724 xmlFreeImpl((*obj).stringval as *mut c_void);
5725 (*obj).stringval = ptr::null_mut();
5726 }
5727 }
5728 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5730 let ns = (*obj).nodesetval as *mut _xmlNodeSet;
5731 if !ns.is_null() {
5732 if !(*ns).nodeTab.is_null() {
5733 xmlFreeImpl((*ns).nodeTab as *mut c_void);
5734 }
5735 xmlFreeImpl(ns as *mut c_void);
5736 }
5737 (*obj).nodesetval = ptr::null_mut();
5738 }
5739 xmlFreeImpl(obj as *mut c_void);
5740}
5741
5742#[no_mangle]
5754pub unsafe extern "C" fn xmlXPathObjectCopy(val: *mut _xmlXPathObject) -> *mut _xmlXPathObject {
5755 if val.is_null() {
5756 return ptr::null_mut();
5757 }
5758 let typ = (*val).type_;
5759 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
5760 if obj.is_null() {
5761 return ptr::null_mut();
5762 }
5763 (*obj).type_ = typ;
5764 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5765 let src_ns = (*val).nodesetval as *mut _xmlNodeSet;
5766 if !src_ns.is_null() {
5767 let nr = (*src_ns).nodeNr;
5768 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
5769 if ns.is_null() {
5770 xmlFreeImpl(obj as *mut c_void);
5771 return ptr::null_mut();
5772 }
5773 (*ns).nodeNr = nr;
5774 (*ns).nodeMax = nr;
5775 if nr > 0 && !(*src_ns).nodeTab.is_null() {
5776 let tab = xmlMallocImpl((nr as usize) * core::mem::size_of::<*mut _xmlNode>())
5777 as *mut *mut _xmlNode;
5778 if tab.is_null() {
5779 xmlFreeImpl(ns as *mut c_void);
5780 xmlFreeImpl(obj as *mut c_void);
5781 return ptr::null_mut();
5782 }
5783 ptr::copy_nonoverlapping((*src_ns).nodeTab, tab, nr as usize);
5784 (*ns).nodeTab = tab;
5785 } else {
5786 (*ns).nodeTab = ptr::null_mut();
5787 }
5788 (*obj).nodesetval = ns as *mut c_void;
5789 }
5790 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5791 (*obj).boolval = (*val).boolval;
5792 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5793 (*obj).floatval = (*val).floatval;
5794 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5795 let src = (*val).stringval;
5796 if !src.is_null() {
5797 let len = libc::strlen(src as *const libc::c_char);
5798 let buf = xmlMallocImpl(len + 1) as *mut xmlChar;
5799 if !buf.is_null() {
5800 ptr::copy_nonoverlapping(src, buf, len);
5801 *buf.add(len) = 0;
5802 }
5803 (*obj).stringval = buf;
5804 }
5805 }
5806 obj
5807}
5808
5809#[no_mangle]
5819pub unsafe extern "C" fn xmlXPathCastToString(val: *mut _xmlXPathObject) -> *mut xmlChar {
5820 if val.is_null() {
5821 return ptr::null_mut();
5822 }
5823 let typ = (*val).type_;
5824 let mut result: Vec<u8> = Vec::new();
5825 if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5826 if !(*val).stringval.is_null() {
5827 let len = libc::strlen((*val).stringval as *const libc::c_char);
5828 result.extend_from_slice(core::slice::from_raw_parts((*val).stringval, len));
5829 }
5830 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5831 let n = (*val).floatval;
5837 result.extend_from_slice(xml_number_to_string(n).as_bytes());
5838 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5839 result.extend_from_slice(if (*val).boolval != 0 {
5840 b"true"
5841 } else {
5842 b"false"
5843 });
5844 } else if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5845 let ns = (*val).nodesetval as *mut _xmlNodeSet;
5848 if !ns.is_null() && (*ns).nodeNr > 0 && !(*ns).nodeTab.is_null() {
5849 let node = *(*ns).nodeTab;
5850 if !node.is_null() {
5851 let content = crate::xml::tree::node_get_content(node);
5852 if !content.is_null() {
5853 let len = libc::strlen(content as *const libc::c_char);
5854 result.extend_from_slice(core::slice::from_raw_parts(content, len));
5855 xmlFreeImpl(content as *mut c_void);
5856 }
5857 }
5858 }
5859 }
5860 let buf = xmlMallocImpl(result.len() + 1) as *mut xmlChar;
5862 if buf.is_null() {
5863 return ptr::null_mut();
5864 }
5865 if !result.is_empty() {
5866 ptr::copy_nonoverlapping(result.as_ptr(), buf, result.len());
5867 }
5868 *buf.add(result.len()) = 0;
5869 buf
5870}
5871
5872pub fn xml_number_to_string(n: f64) -> String {
5876 if n.is_nan() {
5877 return "NaN".to_string();
5878 }
5879 if n.is_infinite() {
5880 return if n > 0.0 {
5881 "Infinity".to_string()
5882 } else {
5883 "-Infinity".to_string()
5884 };
5885 }
5886 if n == 0.0 {
5887 return "0".to_string();
5889 }
5890 if n.fract() == 0.0 && n.abs() < 1e15 {
5892 return format!("{:.0}", n);
5893 }
5894 let mut s = format!("{:.15}", n);
5898 if s.contains('.') {
5900 while s.ends_with('0') {
5901 s.pop();
5902 }
5903 if s.ends_with('.') {
5904 s.pop();
5905 }
5906 }
5907 if s == "-0" {
5908 return "0".to_string();
5909 }
5910 s
5911}
5912
5913#[no_mangle]
5921pub unsafe extern "C" fn xmlXPathCastStringToNumber(val: *const xmlChar) -> f64 {
5922 if val.is_null() {
5923 return f64::NAN;
5924 }
5925 let len = libc::strlen(val as *const libc::c_char);
5926 let bytes = core::slice::from_raw_parts(val, len);
5927 let mut i = 0;
5929 while i < bytes.len() && matches!(bytes[i], b' ' | b'\t' | b'\n' | b'\r') {
5930 i += 1;
5931 }
5932 let s = &bytes[i..];
5933 if s.is_empty() {
5934 return f64::NAN;
5935 }
5936 let (sign, rest) = match s[0] {
5938 b'+' => (1.0f64, &s[1..]),
5939 b'-' => (-1.0f64, &s[1..]),
5940 _ => (1.0f64, s),
5941 };
5942 if rest.is_empty() {
5943 return f64::NAN;
5944 }
5945 let num_str = core::str::from_utf8(rest);
5948 match num_str {
5949 Ok(s) => {
5950 let valid = is_xpath_number(s);
5953 if !valid {
5954 f64::NAN
5955 } else {
5956 s.trim()
5957 .parse::<f64>()
5958 .map(|v| v * sign)
5959 .unwrap_or(f64::NAN)
5960 }
5961 }
5962 Err(_) => f64::NAN,
5963 }
5964}
5965
5966fn is_xpath_number(s: &str) -> bool {
5968 let b = s.as_bytes();
5969 if b.is_empty() {
5970 return false;
5971 }
5972 let mut i = 0;
5973 let mut saw_digit = false;
5974 while i < b.len() && b[i].is_ascii_digit() {
5975 saw_digit = true;
5976 i += 1;
5977 }
5978 if i < b.len() && b[i] == b'.' {
5979 i += 1;
5980 while i < b.len() && b[i].is_ascii_digit() {
5981 saw_digit = true;
5982 i += 1;
5983 }
5984 }
5985 if !saw_digit {
5986 return false;
5987 }
5988 if i < b.len() && (b[i] == b'e' || b[i] == b'E') {
5989 i += 1;
5990 if i < b.len() && (b[i] == b'+' || b[i] == b'-') {
5991 i += 1;
5992 }
5993 let mut saw_exp = false;
5994 while i < b.len() && b[i].is_ascii_digit() {
5995 saw_exp = true;
5996 i += 1;
5997 }
5998 if !saw_exp {
5999 return false;
6000 }
6001 }
6002 i == b.len()
6003}
6004
6005#[no_mangle]
6020pub unsafe extern "C" fn xmlXPathCmpNodes(node1: *mut _xmlNode, node2: *mut _xmlNode) -> c_int {
6021 if node1.is_null() || node2.is_null() {
6022 return 0;
6023 }
6024 if node1 == node2 {
6025 return 0;
6026 }
6027 let mut chain1: Vec<*mut _xmlNode> = Vec::new();
6029 let mut chain2: Vec<*mut _xmlNode> = Vec::new();
6030 let mut n = node1;
6031 while !n.is_null() {
6032 chain1.push(n);
6033 n = (*n).parent as *mut _xmlNode;
6034 }
6035 let mut n = node2;
6036 while !n.is_null() {
6037 chain2.push(n);
6038 n = (*n).parent as *mut _xmlNode;
6039 }
6040 let mut i = chain1.len();
6042 let mut j = chain2.len();
6043 while i > 0 && j > 0 && chain1[i - 1] == chain2[j - 1] {
6044 i -= 1;
6045 j -= 1;
6046 }
6047 if i == 0 && j == 0 {
6048 return 0; }
6050 if i == 0 {
6051 return -1; }
6053 if j == 0 {
6054 return 1; }
6056 let mut a = chain1[i - 1];
6058 let mut b = chain2[j - 1];
6059 while !a.is_null() && !b.is_null() {
6061 let pa = (*a).parent as *mut _xmlNode;
6062 let pb = (*b).parent as *mut _xmlNode;
6063 if pa == pb {
6064 break;
6065 }
6066 a = pa;
6067 b = pb;
6068 }
6069 let parent = (*a).parent as *mut _xmlNode;
6071 let mut child = if parent.is_null() {
6072 ptr::null_mut()
6073 } else {
6074 (*parent).children
6075 };
6076 while !child.is_null() {
6077 if child == a {
6078 return -1;
6079 }
6080 if child == b {
6081 return 1;
6082 }
6083 child = (*child).next;
6084 }
6085 0
6086}
6087
6088#[no_mangle]
6098pub unsafe extern "C" fn xmlXPathNodeSetCreate(val: *mut _xmlNode) -> *mut _xmlNodeSet {
6099 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
6100 if ns.is_null() {
6101 return ptr::null_mut();
6102 }
6103 if val.is_null() {
6104 return ns;
6105 }
6106 let tab = xmlMallocImpl(core::mem::size_of::<*mut _xmlNode>()) as *mut *mut _xmlNode;
6107 if tab.is_null() {
6108 xmlFreeImpl(ns as *mut c_void);
6109 return ptr::null_mut();
6110 }
6111 *tab = val;
6112 (*ns).nodeTab = tab;
6113 (*ns).nodeNr = 1;
6114 (*ns).nodeMax = 1;
6115 ns
6116}
6117
6118#[no_mangle]
6130pub unsafe extern "C" fn xmlXPathFreeNodeSet(ns: *mut _xmlNodeSet) {
6131 if ns.is_null() {
6132 return;
6133 }
6134 if !(*ns).nodeTab.is_null() {
6135 xmlFreeImpl((*ns).nodeTab as *mut c_void);
6136 (*ns).nodeTab = ptr::null_mut();
6137 }
6138 (*ns).nodeNr = 0;
6139 (*ns).nodeMax = 0;
6140 xmlFreeImpl(ns as *mut c_void);
6141}
6142
6143#[no_mangle]
6154pub unsafe extern "C" fn xmlXPathCompile(str_: *const xmlChar) -> *mut c_void {
6155 if str_.is_null() {
6156 return ptr::null_mut();
6157 }
6158 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
6159 Ok(s) => s,
6160 Err(_) => return ptr::null_mut(),
6161 };
6162
6163 match crate::xml::xpath::compile(expr_str) {
6164 Some(compiled) => {
6165 let mut map = COMPILED_EXPRS.lock();
6166 let mut counter = NEXT_COMPILED_KEY.lock();
6167 let key = *counter;
6168 *counter += 1;
6169 map.insert(key, Box::new(compiled));
6170 key as *mut c_void
6171 }
6172 None => ptr::null_mut(),
6173 }
6174}
6175
6176#[no_mangle]
6184pub unsafe extern "C" fn xmlXPathFreeCompExpr(comp: *mut c_void) {
6185 if comp.is_null() {
6186 return;
6187 }
6188 let mut map = COMPILED_EXPRS.lock();
6189 map.remove(&(comp as u64));
6190}
6191
6192#[no_mangle]
6201pub unsafe extern "C" fn xmlXPathRegisterNs(
6202 ctxt: *mut _xmlXPathContext,
6203 prefix: *const xmlChar,
6204 ns_uri: *const xmlChar,
6205) -> c_int {
6206 if ctxt.is_null() || prefix.is_null() || ns_uri.is_null() {
6207 return -1;
6208 }
6209 let internal = (*ctxt).extra as *mut XPathContext;
6210 if internal.is_null() {
6211 return -1;
6212 }
6213 let internal = &mut *internal;
6214
6215 let prefix_str = match CStr::from_ptr(prefix as *const c_char).to_str() {
6216 Ok(s) => s,
6217 Err(_) => return -1,
6218 };
6219 let uri_str = match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6220 Ok(s) => s,
6221 Err(_) => return -1,
6222 };
6223
6224 internal.register_namespace(prefix_str, uri_str);
6225
6226 let map: &mut HashMap<String, CString> = if (*ctxt).nsHash.is_null() {
6231 let b: Box<HashMap<String, CString>> = Box::new(HashMap::new());
6232 (*ctxt).nsHash = Box::into_raw(b) as *mut c_void;
6233 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6234 } else {
6235 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6236 };
6237 map.insert(
6238 prefix_str.to_string(),
6239 CString::new(uri_str.as_bytes()).unwrap_or_default(),
6240 );
6241 0
6242}
6243
6244#[no_mangle]
6258pub unsafe extern "C" fn xmlXPathRegisterFunc(
6259 ctxt: *mut _xmlXPathContext,
6260 name: *const xmlChar,
6261 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6262) -> c_int {
6263 if ctxt.is_null() || name.is_null() {
6264 return -1;
6265 }
6266 let internal = (*ctxt).extra as *mut XPathContext;
6267 if internal.is_null() {
6268 return -1;
6269 }
6270 let internal = &mut *internal;
6271
6272 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6273 Ok(s) => s,
6274 Err(_) => return -1,
6275 };
6276
6277 if let Some(func) = f {
6278 let key = (SendSyncPtr((*ctxt).extra), name_str.to_string());
6280 C_FUNCTIONS.lock().insert(key, func);
6281 let c_ctxt = SendSyncPtr(ctxt as *mut c_void);
6284 let name_owned = name_str.to_string();
6285 internal.register_function(name_str, c_func_bridge_closure(c_ctxt, name_owned));
6286 }
6287 0
6288}
6289
6290#[no_mangle]
6300pub unsafe extern "C" fn xmlXPathRegisterFuncNS(
6301 ctxt: *mut _xmlXPathContext,
6302 name: *const xmlChar,
6303 ns_uri: *const xmlChar,
6304 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6305) -> c_int {
6306 if ctxt.is_null() || name.is_null() {
6307 return -1;
6308 }
6309 let internal = (*ctxt).extra as *mut XPathContext;
6310 if internal.is_null() {
6311 return -1;
6312 }
6313 let internal = &mut *internal;
6314
6315 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6316 Ok(s) => s,
6317 Err(_) => return -1,
6318 };
6319 let ns_str = if ns_uri.is_null() {
6320 String::new()
6321 } else {
6322 match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6323 Ok(s) => s.to_string(),
6324 Err(_) => return -1,
6325 }
6326 };
6327
6328 let qualified = if ns_str.is_empty() {
6330 name_str.to_string()
6331 } else {
6332 format!("{{{}}}{}", ns_str, name_str)
6333 };
6334
6335 if let Some(func) = f {
6336 let key = (SendSyncPtr((*ctxt).extra), qualified.clone());
6337 C_FUNCTIONS.lock().insert(key, func);
6338 let c_ctxt = SendSyncPtr(ctxt as *mut c_void);
6339 let qualified_owned = qualified.clone();
6340 internal.register_function(&qualified, c_func_bridge_closure(c_ctxt, qualified_owned));
6341 }
6342 0
6343}
6344
6345#[no_mangle]
6354pub unsafe extern "C" fn xmlXPathRegisterVariable(
6355 ctxt: *mut _xmlXPathContext,
6356 name: *const xmlChar,
6357 value: *mut _xmlXPathObject,
6358) -> c_int {
6359 if ctxt.is_null() || name.is_null() || value.is_null() {
6360 return -1;
6361 }
6362 let internal = (*ctxt).extra as *mut XPathContext;
6363 if internal.is_null() {
6364 return -1;
6365 }
6366 let internal = &mut *internal;
6367
6368 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6369 Ok(s) => s,
6370 Err(_) => return -1,
6371 };
6372
6373 let xpath_val = object_to_xpathvalue(value);
6374 internal.register_variable(name_str, xpath_val);
6375 0
6376}
6377
6378#[no_mangle]
6386pub unsafe extern "C" fn xmlXPathNewNodeSet(val: *mut _xmlNode) -> *mut _xmlXPathObject {
6387 let ns = if val.is_null() {
6388 NodeSet::new()
6389 } else {
6390 NodeSet::singleton(val)
6391 };
6392 xpath_to_object(XPathValue::NodeSet(ns))
6393}
6394
6395#[no_mangle]
6403pub unsafe extern "C" fn xmlXPathNewCString(val: *const xmlChar) -> *mut _xmlXPathObject {
6404 if val.is_null() {
6405 return xpath_to_object(XPathValue::String(String::new()));
6406 }
6407 let s = match CStr::from_ptr(val as *const c_char).to_str() {
6408 Ok(s) => s.to_string(),
6409 Err(_) => return ptr::null_mut(),
6410 };
6411 xpath_to_object(XPathValue::String(s))
6412}
6413
6414#[no_mangle]
6422pub extern "C" fn xmlXPathNewFloat(val: f64) -> *mut _xmlXPathObject {
6423 unsafe { xpath_to_object(XPathValue::Number(val)) }
6424}
6425
6426#[no_mangle]
6434pub extern "C" fn xmlXPathNewBoolean(val: c_int) -> *mut _xmlXPathObject {
6435 unsafe { xpath_to_object(XPathValue::Boolean(val != 0)) }
6436}
6437
6438#[no_mangle]
6452pub unsafe extern "C" fn xmlXPtrEval(expr: *const c_char, doc: *mut _xmlDoc) -> *mut _xmlNode {
6453 crate::xml::xpointer::xmlXPtrEval(expr, doc)
6454}
6455
6456#[no_mangle]
6468pub unsafe extern "C" fn xmlXIncludeProcess(doc: *mut _xmlDoc) -> c_int {
6469 crate::xml::xinclude::xinclude_process(doc)
6470}
6471
6472#[no_mangle]
6480pub unsafe extern "C" fn xmlXIncludeProcessFlags(doc: *mut _xmlDoc, flags: c_int) -> c_int {
6481 crate::xml::xinclude::xinclude_process_flags(doc, flags)
6482}
6483
6484#[no_mangle]
6496pub extern "C" fn xmlCatalogLoad(catalogs: *const c_char) -> *mut c_void {
6497 if catalogs.is_null() {
6498 return ptr::null_mut();
6499 }
6500 crate::xml::catalog::load_catalog(catalogs)
6501}
6502
6503#[no_mangle]
6511pub unsafe extern "C" fn xmlCatalogResolvePublic(pubID: *const xmlChar) -> *mut xmlChar {
6512 if pubID.is_null() {
6513 return ptr::null_mut();
6514 }
6515 crate::xml::catalog::resolve_public(pubID)
6516}
6517
6518#[no_mangle]
6526pub unsafe extern "C" fn xmlCatalogResolveSystem(sysID: *const xmlChar) -> *mut xmlChar {
6527 if sysID.is_null() {
6528 return ptr::null_mut();
6529 }
6530 crate::xml::catalog::resolve_system(sysID)
6531}
6532
6533#[no_mangle]
6541pub unsafe extern "C" fn xmlCatalogResolveURI(URI: *const xmlChar) -> *mut xmlChar {
6542 if URI.is_null() {
6543 return ptr::null_mut();
6544 }
6545 crate::xml::catalog::resolve_uri(URI)
6546}
6547
6548#[no_mangle]
6556pub extern "C" fn xmlCatalogSetDefaults(allow: c_int) {
6557 crate::xml::catalog::set_defaults(allow)
6558}
6559
6560#[no_mangle]
6568pub extern "C" fn xmlCatalogGetDefaults() -> c_int {
6569 crate::xml::catalog::get_defaults()
6570}
6571
6572#[no_mangle]
6580pub unsafe extern "C" fn xmlCatalogAdd(
6581 type_: *const xmlChar,
6582 orig: *const xmlChar,
6583 replace: *const xmlChar,
6584) -> c_int {
6585 if type_.is_null() || orig.is_null() || replace.is_null() {
6586 return -1;
6587 }
6588 crate::xml::catalog::add(type_, orig, replace)
6589}
6590
6591#[no_mangle]
6599pub unsafe extern "C" fn xmlCatalogRemove(value: *const xmlChar) -> c_int {
6600 if value.is_null() {
6601 return 0;
6602 }
6603 crate::xml::catalog::remove(value)
6604}
6605
6606#[no_mangle]
6614pub unsafe extern "C" fn xmlCatalogDump(output: *mut c_void, _catal: *mut c_void) {
6615 if output.is_null() {
6616 return;
6617 }
6618 let doc = crate::xml::catalog::dump_doc();
6619 if doc.is_null() {
6620 return;
6621 }
6622 let mut mem: *mut xmlChar = ptr::null_mut();
6623 let mut size: c_int = 0;
6624 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6625 if !mem.is_null() {
6626 libc::fwrite(
6627 mem as *const c_void,
6628 1,
6629 size as usize,
6630 output as *mut libc::FILE,
6631 );
6632 xmlFreeImpl(mem as *mut c_void);
6633 }
6634 crate::xml::tree::free_doc(doc);
6635}
6636
6637#[no_mangle]
6647pub unsafe extern "C" fn xmlCatalogSave(filename: *const c_char) -> c_int {
6648 if filename.is_null() {
6649 return -1;
6650 }
6651 let doc = crate::xml::catalog::dump_doc();
6652 if doc.is_null() {
6653 return -1;
6654 }
6655 let mut mem: *mut xmlChar = ptr::null_mut();
6656 let mut size: c_int = 0;
6657 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6658 let mut ret: c_int = -1;
6659 if !mem.is_null() {
6660 let fp = libc::fopen(filename, b"w\0".as_ptr() as *const c_char);
6661 if !fp.is_null() {
6662 let written = libc::fwrite(mem as *const c_void, 1, size as usize, fp);
6663 ret = if written == size as usize { 0 } else { -1 };
6664 libc::fclose(fp);
6665 }
6666 xmlFreeImpl(mem as *mut c_void);
6667 }
6668 crate::xml::tree::free_doc(doc);
6669 ret
6670}
6671
6672#[no_mangle]
6680pub extern "C" fn xmlCatalogCleanup() {
6681 crate::xml::catalog::cleanup();
6682}
6683
6684#[no_mangle]
6692pub extern "C" fn xmlCatalogConvert() -> *mut _xmlDoc {
6693 unsafe { crate::xml::catalog::convert() }
6695}
6696
6697#[no_mangle]
6709pub unsafe extern "C" fn htmlParseFile(
6710 _filename: *const c_char,
6711 _encoding: *const c_char,
6712) -> *mut _xmlDoc {
6713 ptr::null_mut()
6715}
6716
6717#[no_mangle]
6725pub unsafe extern "C" fn htmlParseMemory(_buffer: *const c_char, _size: c_int) -> *mut _xmlDoc {
6726 ptr::null_mut()
6728}
6729
6730#[no_mangle]
6738pub unsafe extern "C" fn htmlParseDoc(
6739 _cur: *const xmlChar,
6740 _encoding: *const c_char,
6741) -> *mut _xmlDoc {
6742 ptr::null_mut()
6744}
6745
6746#[no_mangle]
6755pub unsafe extern "C" fn htmlCreateFileParserCtxt(
6756 _filename: *const c_char,
6757 _encoding: *const c_char,
6758) -> *mut c_void {
6759 ptr::null_mut()
6761}
6762
6763#[no_mangle]
6771pub extern "C" fn htmlFreeParserCtxt(ctxt: *mut c_void) {
6772 unsafe { crate::xml::html::free_parser_ctxt(ctxt) }
6773}
6774
6775#[no_mangle]
6783pub extern "C" fn htmlInitParser() {
6784 }
6786
6787#[no_mangle]
6795pub extern "C" fn htmlCleanupParser() {
6796 }
6798
6799#[no_mangle]
6811pub unsafe extern "C" fn xmlNewValidCtxt() -> *mut _xmlValidCtxt {
6812 crate::xml::validation::new_valid_ctxt()
6813}
6814
6815#[no_mangle]
6823pub unsafe extern "C" fn xmlFreeValidCtxt(ctxt: *mut _xmlValidCtxt) {
6824 crate::xml::validation::free_valid_ctxt(ctxt);
6825}
6826
6827#[no_mangle]
6838pub unsafe extern "C" fn xmlSetValidErrors(
6839 ctxt: *mut _xmlValidCtxt,
6840 err: Option<xmlGenericErrorFunc>,
6841 warn: Option<xmlGenericErrorFunc>,
6842 data: *mut c_void,
6843) {
6844 crate::xml::validation::set_valid_errors(ctxt, err, warn, data);
6845}
6846
6847#[no_mangle]
6855pub unsafe extern "C" fn xmlValidateDocument(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
6856 crate::xml::validation::validate_document(ctxt, doc)
6857}
6858
6859#[no_mangle]
6867pub unsafe extern "C" fn xmlValidateDocumentFinal(
6868 ctxt: *mut _xmlValidCtxt,
6869 doc: *mut _xmlDoc,
6870) -> c_int {
6871 crate::xml::validation::validate_document_final(ctxt, doc)
6872}
6873
6874#[no_mangle]
6884pub unsafe extern "C" fn xmlValidateElement(
6885 ctxt: *mut _xmlValidCtxt,
6886 doc: *mut _xmlDoc,
6887 elem: *mut _xmlNode,
6888) -> c_int {
6889 crate::xml::validation::validate_element(ctxt, doc, elem)
6890}
6891
6892#[no_mangle]
6903pub unsafe extern "C" fn xmlValidateAttributeDecl(
6904 ctxt: *mut _xmlValidCtxt,
6905 doc: *mut _xmlDoc,
6906 elem: *mut _xmlNode,
6907 attr: *mut _xmlAttribute,
6908) -> c_int {
6909 crate::xml::validation::validate_attribute_decl(ctxt, doc, elem, attr)
6910}
6911
6912#[no_mangle]
6920pub unsafe extern "C" fn xmlValidateAttributeValue(atype: c_int, value: *const xmlChar) -> c_int {
6921 crate::xml::validation::validate_attribute_value(atype, value)
6922}
6923
6924#[no_mangle]
6934pub unsafe extern "C" fn xmlValidateNotationUse(
6935 ctxt: *mut _xmlValidCtxt,
6936 doc: *mut _xmlDoc,
6937 notation_name: *const xmlChar,
6938) -> c_int {
6939 crate::xml::validation::validate_notation_use(ctxt, doc, notation_name)
6940}
6941
6942#[no_mangle]
6953pub unsafe extern "C" fn xmlValidateID(
6954 ctxt: *mut _xmlValidCtxt,
6955 doc: *mut _xmlDoc,
6956 node: *mut _xmlNode,
6957 value: *const xmlChar,
6958) -> c_int {
6959 crate::xml::validation::validate_id(ctxt, doc, node, value)
6960}
6961
6962#[no_mangle]
6973pub unsafe extern "C" fn xmlValidateIDRef(
6974 ctxt: *mut _xmlValidCtxt,
6975 doc: *mut _xmlDoc,
6976 node: *mut _xmlNode,
6977 value: *const xmlChar,
6978) -> c_int {
6979 crate::xml::validation::validate_id_ref(ctxt, doc, node, value)
6980}
6981
6982#[no_mangle]
6993pub unsafe extern "C" fn xmlValidateIDRefs(
6994 ctxt: *mut _xmlValidCtxt,
6995 doc: *mut _xmlDoc,
6996 node: *mut _xmlNode,
6997 value: *const xmlChar,
6998) -> c_int {
6999 crate::xml::validation::validate_id_refs(ctxt, doc, node, value)
7000}
7001
7002#[no_mangle]
7012pub unsafe extern "C" fn xmlValidateNCName(value: *const xmlChar, space: c_int) -> c_int {
7013 crate::xml::validation::validate_ncname(value, space)
7014}
7015
7016#[no_mangle]
7024pub unsafe extern "C" fn xmlValidateQName(value: *const xmlChar, space: c_int) -> c_int {
7025 crate::xml::validation::validate_qname(value, space)
7026}
7027
7028#[no_mangle]
7041pub unsafe extern "C" fn xmlValidateName(value: *const xmlChar, space: c_int) -> c_int {
7042 crate::xml::validation::validate_name_space(value, space)
7043}
7044
7045#[no_mangle]
7053pub unsafe extern "C" fn xmlValidateNMToken(value: *const xmlChar, space: c_int) -> c_int {
7054 crate::xml::validation::validate_nmtoken_space(value, space)
7055}
7056
7057#[no_mangle]
7067pub unsafe extern "C" fn xmlValidateNameValue(value: *const xmlChar) -> c_int {
7068 crate::xml::validation::validate_name_value(value)
7069}
7070
7071#[no_mangle]
7080pub unsafe extern "C" fn xmlValidateNamesValue(value: *const xmlChar) -> c_int {
7081 crate::xml::validation::validate_names_value(value)
7082}
7083
7084#[no_mangle]
7092pub unsafe extern "C" fn xmlValidateNmtokenValue(value: *const xmlChar) -> c_int {
7093 crate::xml::validation::validate_nmtoken_value(value)
7094}
7095
7096#[no_mangle]
7104pub unsafe extern "C" fn xmlValidateNmtokensValue(value: *const xmlChar) -> c_int {
7105 crate::xml::validation::validate_nmtokens_value(value)
7106}
7107
7108#[no_mangle]
7119pub unsafe extern "C" fn xmlValidateElementDecl(
7120 ctxt: *mut _xmlValidCtxt,
7121 doc: *mut _xmlDoc,
7122 elem: *mut _xmlElement,
7123) -> c_int {
7124 crate::xml::validation::validate_element_decl(ctxt, doc, elem)
7125}
7126
7127#[no_mangle]
7140pub unsafe extern "C" fn xmlValidateNotationDecl(
7141 ctxt: *mut _xmlValidCtxt,
7142 doc: *mut _xmlDoc,
7143 nota: *mut _xmlNotation,
7144) -> c_int {
7145 crate::xml::validation::validate_notation_decl(ctxt, doc, nota)
7146}
7147
7148#[no_mangle]
7160pub unsafe extern "C" fn xmlValidateOneAttribute(
7161 ctxt: *mut _xmlValidCtxt,
7162 doc: *mut _xmlDoc,
7163 elem: *mut _xmlNode,
7164 attr: *mut _xmlAttr,
7165 value: *const xmlChar,
7166) -> c_int {
7167 crate::xml::validation::validate_one_attribute(ctxt, doc, elem, attr, value)
7168}
7169
7170#[no_mangle]
7180pub unsafe extern "C" fn xmlValidateOneElement(
7181 ctxt: *mut _xmlValidCtxt,
7182 doc: *mut _xmlDoc,
7183 elem: *mut _xmlNode,
7184) -> c_int {
7185 crate::xml::validation::validate_one_element(ctxt, doc, elem)
7186}
7187
7188#[no_mangle]
7201pub unsafe extern "C" fn xmlValidateOneNamespace(
7202 ctxt: *mut _xmlValidCtxt,
7203 doc: *mut _xmlDoc,
7204 elem: *mut _xmlNode,
7205 prefix: *const xmlChar,
7206 ns: *mut _xmlNs,
7207 value: *const xmlChar,
7208) -> c_int {
7209 crate::xml::validation::validate_one_namespace(ctxt, doc, elem, prefix, ns, value)
7210}
7211
7212#[no_mangle]
7224pub unsafe extern "C" fn xmlValidatePushElement(
7225 ctxt: *mut _xmlValidCtxt,
7226 doc: *mut _xmlDoc,
7227 elem: *mut _xmlNode,
7228 qname: *const xmlChar,
7229) -> c_int {
7230 crate::xml::validation::validate_push_element(ctxt, doc, elem, qname)
7231}
7232
7233#[no_mangle]
7243pub unsafe extern "C" fn xmlValidatePushCData(
7244 ctxt: *mut _xmlValidCtxt,
7245 data: *const xmlChar,
7246 len: c_int,
7247) -> c_int {
7248 crate::xml::validation::validate_push_cdata(ctxt, data, len)
7249}
7250
7251#[no_mangle]
7262pub unsafe extern "C" fn xmlValidatePopElement(
7263 ctxt: *mut _xmlValidCtxt,
7264 doc: *mut _xmlDoc,
7265 elem: *mut _xmlNode,
7266 qname: *const xmlChar,
7267) -> c_int {
7268 crate::xml::validation::validate_pop_element(ctxt, doc, elem, qname)
7269}
7270
7271#[no_mangle]
7280pub unsafe extern "C" fn xmlValidBuildContentModel(
7281 ctxt: *mut _xmlValidCtxt,
7282 elem: *mut _xmlElement,
7283) -> c_int {
7284 crate::xml::validation::validate_build_content_model(ctxt, elem)
7285}
7286
7287#[no_mangle]
7298pub unsafe extern "C" fn xmlAddID(
7299 ctxt: *mut _xmlValidCtxt,
7300 doc: *mut _xmlDoc,
7301 value: *const xmlChar,
7302 attr: *mut _xmlAttr,
7303) -> *mut _xmlID {
7304 crate::xml::validation::add_id(ctxt, doc, value, attr)
7305}
7306
7307#[no_mangle]
7315pub unsafe extern "C" fn xmlRemoveID(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7316 crate::xml::validation::remove_id(doc, attr)
7317}
7318
7319#[no_mangle]
7330pub unsafe extern "C" fn xmlAddRef(
7331 ctxt: *mut _xmlValidCtxt,
7332 doc: *mut _xmlDoc,
7333 value: *const xmlChar,
7334 attr: *mut _xmlAttr,
7335) -> *mut _xmlRef {
7336 crate::xml::validation::add_ref(ctxt, doc, value, attr)
7337}
7338
7339#[no_mangle]
7347pub unsafe extern "C" fn xmlRemoveRef(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7348 crate::xml::validation::remove_ref(doc, attr)
7349}
7350
7351#[no_mangle]
7359pub unsafe extern "C" fn xmlAddIDSafe(attr: *mut _xmlAttr, value: *const xmlChar) -> c_int {
7360 crate::xml::validation::add_id_safe(attr, value)
7361}
7362
7363#[no_mangle]
7371pub unsafe extern "C" fn xmlFreeIDTable(table: *mut c_void) {
7372 crate::xml::validation::free_id_table(table as *mut crate::xml::hash::HashTable);
7373}
7374
7375#[no_mangle]
7383pub unsafe extern "C" fn xmlFreeRefTable(table: *mut c_void) {
7384 crate::xml::validation::free_ref_table(table as *mut crate::xml::hash::HashTable);
7385}
7386
7387#[no_mangle]
7395pub unsafe extern "C" fn xmlGetID(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut _xmlAttr {
7396 crate::xml::validation::get_id(doc, id)
7397}
7398
7399#[no_mangle]
7407pub unsafe extern "C" fn xmlGetRefs(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut c_void {
7408 crate::xml::validation::get_refs(doc, id) as *mut c_void
7409}
7410
7411#[no_mangle]
7419pub unsafe extern "C" fn xmlIsID(
7420 doc: *mut _xmlDoc,
7421 elem: *mut _xmlNode,
7422 attr: *mut _xmlAttr,
7423) -> c_int {
7424 crate::xml::validation::is_id(doc, elem, attr)
7425}
7426
7427#[no_mangle]
7435pub unsafe extern "C" fn xmlIsRef(
7436 doc: *mut _xmlDoc,
7437 elem: *mut _xmlNode,
7438 attr: *mut _xmlAttr,
7439) -> c_int {
7440 crate::xml::validation::is_ref(doc, elem, attr)
7441}
7442
7443#[no_mangle]
7451pub unsafe extern "C" fn xmlGetDtdElementDesc(
7452 dtd: *mut _xmlDtd,
7453 name: *const xmlChar,
7454) -> *mut _xmlElement {
7455 crate::xml::validation::get_dtd_element_desc(dtd, name)
7456}
7457
7458#[no_mangle]
7468pub unsafe extern "C" fn xmlGetDtdAttrDesc(
7469 dtd: *mut _xmlDtd,
7470 elem: *const xmlChar,
7471 name: *const xmlChar,
7472) -> *mut _xmlAttribute {
7473 crate::xml::validation::get_dtd_attr_desc(dtd, elem, name)
7474}
7475
7476#[no_mangle]
7486pub unsafe extern "C" fn xmlGetDtdQElementDesc(
7487 dtd: *mut _xmlDtd,
7488 name: *const xmlChar,
7489 prefix: *const xmlChar,
7490) -> *mut _xmlElement {
7491 crate::xml::validation::get_dtd_qelement_desc(dtd, name, prefix)
7492}
7493
7494#[no_mangle]
7505pub unsafe extern "C" fn xmlGetDtdQAttrDesc(
7506 dtd: *mut _xmlDtd,
7507 elem: *const xmlChar,
7508 name: *const xmlChar,
7509 prefix: *const xmlChar,
7510) -> *mut _xmlAttribute {
7511 crate::xml::validation::get_dtd_qattr_desc(dtd, elem, name, prefix)
7512}
7513
7514#[no_mangle]
7522pub unsafe extern "C" fn xmlGetDtdNotationDesc(
7523 dtd: *mut _xmlDtd,
7524 name: *const xmlChar,
7525) -> *mut _xmlNotation {
7526 crate::xml::validation::get_dtd_notation_desc(dtd, name)
7527}
7528
7529#[no_mangle]
7537pub unsafe extern "C" fn xmlValidateRoot(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7538 crate::xml::validation::validate_root(ctxt, doc)
7539}
7540
7541#[no_mangle]
7551pub unsafe extern "C" fn xmlValidateContent(
7552 ctxt: *mut _xmlValidCtxt,
7553 node: *mut _xmlNode,
7554 doc: *mut _xmlDoc,
7555) -> c_int {
7556 crate::xml::validation::validate_content(ctxt, node, doc)
7557}
7558
7559#[no_mangle]
7567pub unsafe extern "C" fn xmlIsMixedElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7568 crate::xml::validation::is_mixed_element(doc, name)
7569}
7570
7571#[no_mangle]
7579pub unsafe extern "C" fn xmlIsEmptyElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7580 crate::xml::validation::is_empty_element(doc, name)
7581}
7582
7583#[no_mangle]
7593pub unsafe extern "C" fn xmlValidateDtd(
7594 ctxt: *mut _xmlValidCtxt,
7595 doc: *mut _xmlDoc,
7596 dtd: *mut _xmlDtd,
7597) -> c_int {
7598 crate::xml::validation::validate_dtd(ctxt, doc, dtd)
7599}
7600
7601#[no_mangle]
7609pub unsafe extern "C" fn xmlValidateDtdFinal(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7610 crate::xml::validation::validate_dtd_final(ctxt, doc)
7611}
7612
7613#[no_mangle]
7623pub unsafe extern "C" fn xmlValidateEnumeration(
7624 ctxt: *mut _xmlValidCtxt,
7625 value: *const xmlChar,
7626 tree: *mut _xmlEnumeration,
7627) -> c_int {
7628 crate::xml::validation::validate_enumeration(ctxt, value, tree)
7629}
7630
7631#[no_mangle]
7645pub extern "C" fn xmlGetBinaryPath() -> *mut c_char {
7646 ptr::null_mut()
7648}
7649
7650#[no_mangle]
7658pub extern "C" fn xmlGetHomeOfBinary() -> *mut c_char {
7659 ptr::null_mut()
7661}
7662
7663#[no_mangle]
7674pub unsafe extern "C" fn xmlSAX2StartDocument(ctx: *mut c_void) {
7675 crate::xml::sax::default::default_sax_handler::startDocument(ctx)
7676}
7677
7678#[no_mangle]
7680pub unsafe extern "C" fn xmlSAX2EndDocument(ctx: *mut c_void) {
7681 crate::xml::sax::default::default_sax_handler::endDocument(ctx)
7682}
7683
7684#[no_mangle]
7686pub unsafe extern "C" fn xmlSAX2StartElementNs(
7687 ctx: *mut c_void,
7688 localname: *const xmlChar,
7689 prefix: *const xmlChar,
7690 URI: *const xmlChar,
7691 nb_namespaces: c_int,
7692 namespaces: *mut *const xmlChar,
7693 nb_attributes: c_int,
7694 nb_defaulted: c_int,
7695 attributes: *mut *const xmlChar,
7696) {
7697 crate::xml::sax::default::default_sax_handler::startElementNs(
7698 ctx,
7699 localname,
7700 prefix,
7701 URI,
7702 nb_namespaces,
7703 namespaces,
7704 nb_attributes,
7705 nb_defaulted,
7706 attributes,
7707 )
7708}
7709
7710#[no_mangle]
7712pub unsafe extern "C" fn xmlSAX2EndElementNs(
7713 ctx: *mut c_void,
7714 localname: *const xmlChar,
7715 prefix: *const xmlChar,
7716 URI: *const xmlChar,
7717) {
7718 crate::xml::sax::default::default_sax_handler::endElementNs(ctx, localname, prefix, URI)
7719}
7720
7721#[no_mangle]
7723pub unsafe extern "C" fn xmlSAX2Characters(ctx: *mut c_void, ch: *const xmlChar, len: c_int) {
7724 crate::xml::sax::default::default_sax_handler::characters(ctx, ch, len)
7725}
7726
7727#[no_mangle]
7729pub unsafe extern "C" fn xmlSAX2IgnorableWhitespace(
7730 ctx: *mut c_void,
7731 ch: *const xmlChar,
7732 len: c_int,
7733) {
7734 crate::xml::sax::default::default_sax_handler::ignorableWhitespace(ctx, ch, len)
7735}
7736
7737#[no_mangle]
7739pub unsafe extern "C" fn xmlSAX2Comment(ctx: *mut c_void, value: *const xmlChar) {
7740 crate::xml::sax::default::default_sax_handler::comment(ctx, value)
7741}
7742
7743#[no_mangle]
7745pub unsafe extern "C" fn xmlSAX2ProcessingInstruction(
7746 ctx: *mut c_void,
7747 target: *const xmlChar,
7748 data: *const xmlChar,
7749) {
7750 crate::xml::sax::default::default_sax_handler::processingInstruction(ctx, target, data)
7751}
7752
7753#[no_mangle]
7755pub unsafe extern "C" fn xmlSAX2CDataBlock(ctx: *mut c_void, value: *const xmlChar, len: c_int) {
7756 crate::xml::sax::default::default_sax_handler::cdataBlock(ctx, value, len)
7757}
7758
7759#[no_mangle]
7761pub unsafe extern "C" fn xmlSAX2InternalSubset(
7762 ctx: *mut c_void,
7763 name: *const xmlChar,
7764 ExternalID: *const xmlChar,
7765 SystemID: *const xmlChar,
7766) {
7767 crate::xml::sax::default::default_sax_handler::internalSubset(ctx, name, ExternalID, SystemID)
7768}
7769
7770#[no_mangle]
7772pub unsafe extern "C" fn xmlSAX2ExternalSubset(
7773 ctx: *mut c_void,
7774 name: *const xmlChar,
7775 ExternalID: *const xmlChar,
7776 SystemID: *const xmlChar,
7777) {
7778 crate::xml::sax::default::default_sax_handler::externalSubset(ctx, name, ExternalID, SystemID)
7779}
7780
7781#[no_mangle]
7783pub unsafe extern "C" fn xmlSAX2EntityDecl(
7784 ctx: *mut c_void,
7785 name: *const xmlChar,
7786 type_: c_int,
7787 publicId: *const xmlChar,
7788 systemId: *const xmlChar,
7789 content: *mut xmlChar,
7790) {
7791 crate::xml::sax::default::default_sax_handler::entityDecl(
7792 ctx, name, type_, publicId, systemId, content,
7793 )
7794}
7795
7796#[no_mangle]
7798pub unsafe extern "C" fn xmlSAX2AttributeDecl(
7799 ctx: *mut c_void,
7800 elem: *const xmlChar,
7801 fullname: *const xmlChar,
7802 type_: c_int,
7803 def: c_int,
7804 defaultValue: *const xmlChar,
7805 tree: *mut crate::abi::structs::_xmlEnumeration,
7806) {
7807 crate::xml::sax::default::default_sax_handler::attributeDecl(
7808 ctx,
7809 elem,
7810 fullname,
7811 type_,
7812 def,
7813 defaultValue,
7814 tree,
7815 )
7816}
7817
7818#[no_mangle]
7820pub unsafe extern "C" fn xmlSAX2ElementDecl(
7821 ctx: *mut c_void,
7822 name: *const xmlChar,
7823 type_: c_int,
7824 content: *mut crate::abi::structs::_xmlElementContent,
7825) {
7826 crate::xml::sax::default::default_sax_handler::elementDecl(ctx, name, type_, content)
7827}
7828
7829#[no_mangle]
7831pub unsafe extern "C" fn xmlSAX2NotationDecl(
7832 ctx: *mut c_void,
7833 name: *const xmlChar,
7834 publicId: *const xmlChar,
7835 systemId: *const xmlChar,
7836) {
7837 crate::xml::sax::default::default_sax_handler::notationDecl(ctx, name, publicId, systemId)
7838}
7839
7840#[no_mangle]
7842pub unsafe extern "C" fn xmlSAX2UnparsedEntityDecl(
7843 ctx: *mut c_void,
7844 name: *const xmlChar,
7845 publicId: *const xmlChar,
7846 systemId: *const xmlChar,
7847 notationName: *const xmlChar,
7848) {
7849 crate::xml::sax::default::default_sax_handler::unparsedEntityDecl(
7850 ctx,
7851 name,
7852 publicId,
7853 systemId,
7854 notationName,
7855 )
7856}
7857
7858#[no_mangle]
7860pub unsafe extern "C" fn xmlSAX2ResolveEntity(
7861 ctx: *mut c_void,
7862 publicId: *const xmlChar,
7863 systemId: *const xmlChar,
7864) -> *mut crate::abi::structs::_xmlParserInput {
7865 crate::xml::sax::default::default_sax_handler::resolveEntity(ctx, publicId, systemId)
7866}
7867
7868#[no_mangle]
7870pub unsafe extern "C" fn xmlSAX2IsStandalone(ctx: *mut c_void) -> c_int {
7871 crate::xml::sax::default::default_sax_handler::isStandalone(ctx)
7872}
7873
7874#[no_mangle]
7876pub unsafe extern "C" fn xmlSAX2HasInternalSubset(ctx: *mut c_void) -> c_int {
7877 crate::xml::sax::default::default_sax_handler::hasInternalSubset(ctx)
7878}
7879
7880#[no_mangle]
7882pub unsafe extern "C" fn xmlSAX2HasExternalSubset(ctx: *mut c_void) -> c_int {
7883 crate::xml::sax::default::default_sax_handler::hasExternalSubset(ctx)
7884}
7885
7886#[no_mangle]
7888pub unsafe extern "C" fn xmlSAX2GetEntity(
7889 ctx: *mut c_void,
7890 name: *const xmlChar,
7891) -> *mut crate::abi::structs::_xmlEntity {
7892 crate::xml::sax::default::default_sax_handler::getEntity(ctx, name)
7893}
7894
7895#[no_mangle]
7897pub unsafe extern "C" fn xmlSAX2GetParameterEntity(
7898 ctx: *mut c_void,
7899 name: *const xmlChar,
7900) -> *mut crate::abi::structs::_xmlEntity {
7901 crate::xml::sax::default::default_sax_handler::getParameterEntity(ctx, name)
7902}
7903
7904#[no_mangle]
7907pub unsafe extern "C" fn xmlSAX2GetLineNumber(ctx: *mut c_void) -> c_int {
7908 crate::xml::sax::default::default_sax_handler::getLineNumber(ctx)
7909}
7910
7911#[no_mangle]
7913pub unsafe extern "C" fn xmlSAX2GetColumnNumber(ctx: *mut c_void) -> c_int {
7914 crate::xml::sax::default::default_sax_handler::getColumnNumber(ctx)
7915}
7916
7917#[no_mangle]
7919pub unsafe extern "C" fn xmlSAX2GetPublicId(ctx: *mut c_void) -> *const xmlChar {
7920 crate::xml::sax::default::default_sax_handler::getPublicId(ctx)
7921}
7922
7923#[no_mangle]
7925pub unsafe extern "C" fn xmlSAX2GetSystemId(ctx: *mut c_void) -> *const xmlChar {
7926 crate::xml::sax::default::default_sax_handler::getSystemId(ctx)
7927}
7928
7929#[no_mangle]
7933pub unsafe extern "C" fn xmlSAX2StartElement(
7934 ctx: *mut c_void,
7935 name: *const xmlChar,
7936 atts: *mut *const xmlChar,
7937) {
7938 crate::xml::sax::dispatch::SaxDispatcher::sax1_start_element(ctx, name, atts);
7942}
7943
7944#[no_mangle]
7946pub unsafe extern "C" fn xmlSAX2EndElement(ctx: *mut c_void, name: *const xmlChar) {
7947 crate::xml::sax::dispatch::SaxDispatcher::sax1_end_element(ctx, name);
7948}
7949
7950#[no_mangle]
7952pub unsafe extern "C" fn xmlSAX2SetDocumentLocator(
7953 ctx: *mut c_void,
7954 loc: *mut crate::abi::callbacks::_xmlSAXLocator,
7955) {
7956 crate::xml::sax::default::default_sax_handler::setDocumentLocator(ctx, loc)
7957}
7958
7959#[no_mangle]
7961pub unsafe extern "C" fn xmlSAX2Reference(ctx: *mut c_void, name: *const xmlChar) {
7962 crate::xml::sax::default::default_sax_handler::reference(ctx, name)
7963}