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) -> *mut c_void {
2765 crate::xml::catalog::load_catalog(catalogs)
2766}
2767
2768#[no_mangle]
2776pub unsafe extern "C" fn xmlReadFd(
2777 fd: c_int,
2778 URL: *const c_char,
2779 encoding: *const c_char,
2780 options: c_int,
2781) -> *mut _xmlDoc {
2782 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2784 if ctxt.is_null() {
2785 return ptr::null_mut();
2786 }
2787 let mut buf = Vec::new();
2789 let mut tmp = [0u8; 4096];
2790 loop {
2791 let n = libc::read(fd, tmp.as_mut_ptr() as *mut c_void, tmp.len());
2792 if n <= 0 {
2793 break;
2794 }
2795 buf.extend_from_slice(&tmp[..n as usize]);
2796 }
2797 let input = crate::xml::parser::helpers::input_from_memory(
2798 buf.as_ptr() as *const c_char,
2799 buf.len() as c_int,
2800 );
2801 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2802 (*ctxt).options = options;
2803 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2804 let doc = (*ctxt).myDoc;
2805 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2806 return doc;
2807 }
2808 let doc = (*ctxt).myDoc;
2809 if !doc.is_null() && !URL.is_null() {
2810 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2811 }
2812 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2813 doc
2814}
2815
2816#[no_mangle]
2825pub unsafe extern "C" fn xmlReadIO(
2826 ioread: Option<xmlInputReadCallback>,
2827 ioclose: Option<xmlInputCloseCallback>,
2828 ioctx: *mut c_void,
2829 URL: *const c_char,
2830 encoding: *const c_char,
2831 options: c_int,
2832) -> *mut _xmlDoc {
2833 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2835 if ctxt.is_null() {
2836 return ptr::null_mut();
2837 }
2838 let input = crate::xml::parser::helpers::input_from_io(ioread, ioclose, ioctx);
2839 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2840 (*ctxt).options = options;
2841 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2842 let doc = (*ctxt).myDoc;
2843 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2844 return doc;
2845 }
2846 let doc = (*ctxt).myDoc;
2847 if !doc.is_null() && !URL.is_null() {
2848 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2849 }
2850 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2851 doc
2852}
2853
2854#[no_mangle]
2862pub unsafe extern "C" fn xmlSAXParseDoc(
2863 sax: *mut _xmlSAXHandler,
2864 cur: *const xmlChar,
2865 recovery: c_int,
2866) -> *mut _xmlDoc {
2867 if cur.is_null() {
2869 return ptr::null_mut();
2870 }
2871 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2872 if ctxt.is_null() {
2873 return ptr::null_mut();
2874 }
2875 if !sax.is_null() {
2876 (*ctxt).sax = sax;
2877 (*ctxt).userData = (*ctxt).sax as *mut c_void;
2878 }
2879 if recovery != 0 {
2880 (*ctxt).recovery = 1;
2881 (*ctxt).options |= 1; }
2883 let len = crate::xml::string::xml_strlen(cur);
2884 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2885 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2886 crate::xml::parser::helpers::parse_document(ctxt);
2887 let doc = (*ctxt).myDoc;
2888 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2889 doc
2890}
2891
2892#[no_mangle]
2902pub unsafe extern "C" fn xmlSAXParseDocWithData(
2903 sax: *mut _xmlSAXHandler,
2904 cur: *const xmlChar,
2905 recovery: c_int,
2906 data: *mut c_void,
2907) -> *mut _xmlDoc {
2908 if cur.is_null() {
2910 return ptr::null_mut();
2911 }
2912 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2913 if ctxt.is_null() {
2914 return ptr::null_mut();
2915 }
2916 if !sax.is_null() {
2917 (*ctxt).sax = sax;
2918 }
2919 (*ctxt).userData = data;
2920 if recovery != 0 {
2921 (*ctxt).recovery = 1;
2922 (*ctxt).options |= 1; }
2924 let len = crate::xml::string::xml_strlen(cur);
2925 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2926 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2927 crate::xml::parser::helpers::parse_document(ctxt);
2928 let doc = (*ctxt).myDoc;
2929 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2930 doc
2931}
2932
2933#[no_mangle]
2943pub unsafe extern "C" fn xmlSAXParseFileWithData(
2944 sax: *mut _xmlSAXHandler,
2945 filename: *const c_char,
2946 recovery: c_int,
2947 data: *mut c_void,
2948) -> *mut _xmlDoc {
2949 if filename.is_null() {
2951 return ptr::null_mut();
2952 }
2953 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2954 if ctxt.is_null() {
2955 return ptr::null_mut();
2956 }
2957 if !sax.is_null() {
2958 (*ctxt).sax = sax;
2959 }
2960 (*ctxt).userData = data;
2961 if recovery != 0 {
2962 (*ctxt).recovery = 1;
2963 (*ctxt).options |= 1; }
2965 let input = match crate::xml::parser::helpers::input_from_file(filename) {
2966 Ok(input) => input,
2967 Err(_) => {
2968 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2969 return ptr::null_mut();
2970 }
2971 };
2972 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2973 crate::xml::parser::helpers::parse_document(ctxt);
2974 let doc = (*ctxt).myDoc;
2975 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2976 doc
2977}
2978
2979#[no_mangle]
2989pub unsafe extern "C" fn xmlSAXParseMemoryWithData(
2990 sax: *mut _xmlSAXHandler,
2991 buffer: *const c_char,
2992 size: c_int,
2993 recovery: c_int,
2994 data: *mut c_void,
2995) -> *mut _xmlDoc {
2996 if buffer.is_null() || size <= 0 {
2998 return ptr::null_mut();
2999 }
3000 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3001 if ctxt.is_null() {
3002 return ptr::null_mut();
3003 }
3004 if !sax.is_null() {
3005 (*ctxt).sax = sax;
3006 }
3007 (*ctxt).userData = data;
3008 if recovery != 0 {
3009 (*ctxt).recovery = 1;
3010 (*ctxt).options |= 1; }
3012 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3013 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3014 crate::xml::parser::helpers::parse_document(ctxt);
3015 let doc = (*ctxt).myDoc;
3016 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3017 doc
3018}
3019
3020#[no_mangle]
3028pub unsafe extern "C" fn xmlSAXParseFile(
3029 sax: *mut _xmlSAXHandler,
3030 filename: *const c_char,
3031 recovery: c_int,
3032) -> *mut _xmlDoc {
3033 if filename.is_null() {
3035 return ptr::null_mut();
3036 }
3037 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3038 if ctxt.is_null() {
3039 return ptr::null_mut();
3040 }
3041 if !sax.is_null() {
3042 (*ctxt).sax = sax;
3043 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3044 }
3045 if recovery != 0 {
3046 (*ctxt).recovery = 1;
3047 (*ctxt).options |= 1;
3048 }
3049 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3050 Ok(input) => input,
3051 Err(_) => {
3052 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3053 return ptr::null_mut();
3054 }
3055 };
3056 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3057 crate::xml::parser::helpers::parse_document(ctxt);
3058 let doc = (*ctxt).myDoc;
3059 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3060 doc
3061}
3062
3063#[no_mangle]
3072pub unsafe extern "C" fn xmlSAXParseMemory(
3073 sax: *mut _xmlSAXHandler,
3074 buffer: *const c_char,
3075 size: c_int,
3076 recovery: c_int,
3077) -> *mut _xmlDoc {
3078 if buffer.is_null() || size <= 0 {
3080 return ptr::null_mut();
3081 }
3082 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3083 if ctxt.is_null() {
3084 return ptr::null_mut();
3085 }
3086 if !sax.is_null() {
3087 (*ctxt).sax = sax;
3088 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3089 }
3090 if recovery != 0 {
3091 (*ctxt).recovery = 1;
3092 (*ctxt).options |= 1;
3093 }
3094 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3095 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3096 crate::xml::parser::helpers::parse_document(ctxt);
3097 let doc = (*ctxt).myDoc;
3098 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3099 doc
3100}
3101
3102#[no_mangle]
3111pub unsafe extern "C" fn xmlSAXUserParseFile(
3112 sax: *mut _xmlSAXHandler,
3113 user_data: *mut c_void,
3114 filename: *const c_char,
3115) -> c_int {
3116 if filename.is_null() {
3118 return -1;
3119 }
3120 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3121 if ctxt.is_null() {
3122 return -1;
3123 }
3124 if !sax.is_null() {
3125 (*ctxt).sax = sax;
3126 }
3127 (*ctxt).userData = if !user_data.is_null() {
3128 user_data
3129 } else {
3130 ctxt as *mut c_void
3131 };
3132 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3133 Ok(input) => input,
3134 Err(_) => {
3135 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3136 return -1;
3137 }
3138 };
3139 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3140 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3141 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3142 ret
3143}
3144
3145#[no_mangle]
3154pub unsafe extern "C" fn xmlSAXUserParseMemory(
3155 sax: *mut _xmlSAXHandler,
3156 user_data: *mut c_void,
3157 buffer: *const c_char,
3158 size: c_int,
3159) -> c_int {
3160 if buffer.is_null() || size <= 0 {
3162 return -1;
3163 }
3164 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3165 if ctxt.is_null() {
3166 return -1;
3167 }
3168 if !sax.is_null() {
3169 (*ctxt).sax = sax;
3170 }
3171 (*ctxt).userData = if !user_data.is_null() {
3172 user_data
3173 } else {
3174 ctxt as *mut c_void
3175 };
3176 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3177 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3178 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3179 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3180 ret
3181}
3182
3183#[no_mangle]
3191pub unsafe extern "C" fn xmlParseDoc(cur: *const xmlChar) -> *mut _xmlDoc {
3192 if cur.is_null() {
3194 return ptr::null_mut();
3195 }
3196 xmlReadDoc(cur, ptr::null(), ptr::null(), 0)
3197}
3198
3199#[no_mangle]
3207pub unsafe extern "C" fn xmlParseFile(filename: *const c_char) -> *mut _xmlDoc {
3208 if filename.is_null() {
3210 return ptr::null_mut();
3211 }
3212 xmlReadFile(filename, ptr::null(), 0)
3213}
3214
3215#[no_mangle]
3223pub unsafe extern "C" fn xmlParseMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
3224 if buffer.is_null() || size <= 0 {
3226 return ptr::null_mut();
3227 }
3228 xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 0)
3229}
3230
3231#[no_mangle]
3239pub unsafe extern "C" fn xmlCreateFileParserCtxt(filename: *const c_char) -> *mut _xmlParserCtxt {
3240 if filename.is_null() {
3242 return ptr::null_mut();
3243 }
3244 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3245 if ctxt.is_null() {
3246 return ptr::null_mut();
3247 }
3248 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3249 Ok(input) => input,
3250 Err(_) => {
3251 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3252 return ptr::null_mut();
3253 }
3254 };
3255 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3256 ctxt
3257}
3258
3259#[no_mangle]
3267pub unsafe extern "C" fn xmlCreateDocParserCtxt(cur: *const xmlChar) -> *mut _xmlParserCtxt {
3268 if cur.is_null() {
3270 return ptr::null_mut();
3271 }
3272 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3273 if ctxt.is_null() {
3274 return ptr::null_mut();
3275 }
3276 let len = crate::xml::string::xml_strlen(cur);
3277 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
3278 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3279 ctxt
3280}
3281
3282#[no_mangle]
3290pub unsafe extern "C" fn xmlParseDocument(ctxt: *mut _xmlParserCtxt) -> c_int {
3291 if ctxt.is_null() {
3293 return -1;
3294 }
3295 crate::xml::parser::helpers::parse_document(ctxt)
3296}
3297
3298#[no_mangle]
3306pub unsafe extern "C" fn xmlFreeParserCtxt(ctxt: *mut _xmlParserCtxt) {
3307 if ctxt.is_null() {
3308 return;
3309 }
3310 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3311}
3312
3313#[no_mangle]
3321pub unsafe extern "C" fn xmlCtxtUseOptions(ctxt: *mut _xmlParserCtxt, options: c_int) -> c_int {
3322 if ctxt.is_null() {
3323 return -1;
3324 }
3325 unsafe {
3327 (*ctxt).options = options;
3328 }
3329 0
3330}
3331
3332#[no_mangle]
3341pub unsafe extern "C" fn xmlParseChunk(
3342 ctxt: *mut _xmlParserCtxt,
3343 chunk: *const c_char,
3344 size: c_int,
3345 terminate: c_int,
3346) -> c_int {
3347 if ctxt.is_null() {
3350 return -1;
3351 }
3352 crate::xml::parser::helpers::parse_chunk(ctxt, chunk, size, terminate)
3353}
3354
3355#[no_mangle]
3363pub unsafe extern "C" fn xmlParserInputBufferCreateMem(
3364 buffer: *const c_char,
3365 size: c_int,
3366 enc: c_int,
3367) -> *mut _xmlParserInputBuffer {
3368 if buffer.is_null() || size <= 0 {
3370 return ptr::null_mut();
3371 }
3372 crate::xml::parser::helpers::alloc_parser_input_buffer()
3373}
3374
3375#[no_mangle]
3383pub unsafe extern "C" fn xmlParserInputBufferCreateFilename(
3384 URI: *const c_char,
3385 enc: c_int,
3386) -> *mut _xmlParserInputBuffer {
3387 if URI.is_null() {
3389 return ptr::null_mut();
3390 }
3391 crate::xml::parser::helpers::alloc_parser_input_buffer()
3392}
3393
3394#[no_mangle]
3404pub unsafe extern "C" fn xmlParserInputBufferCreateIO(
3405 ioread: Option<xmlInputReadCallback>,
3406 ioclose: Option<xmlInputCloseCallback>,
3407 ioctx: *mut c_void,
3408 enc: c_int,
3409) -> *mut _xmlParserInputBuffer {
3410 let buf = crate::xml::parser::helpers::alloc_parser_input_buffer();
3412 if !buf.is_null() {
3413 (*buf).readcallback = ioread;
3414 (*buf).closecallback = ioclose;
3415 (*buf).context = ioctx;
3416 }
3417 buf
3418}
3419
3420#[no_mangle]
3428pub unsafe extern "C" fn xmlFreeParserInputBuffer(buf: *mut _xmlParserInputBuffer) {
3429 if buf.is_null() {
3430 return;
3431 }
3432 crate::xml::parser::helpers::free_parser_input_buffer(buf);
3433}
3434
3435#[no_mangle]
3443pub unsafe extern "C" fn xmlNewInputFromFile(
3444 ctxt: *mut _xmlParserCtxt,
3445 filename: *const c_char,
3446) -> *mut _xmlParserInput {
3447 if filename.is_null() {
3452 return ptr::null_mut();
3453 }
3454 crate::xml::parser::helpers::alloc_parser_input_buffer() as *mut _xmlParserInput
3455}
3456
3457#[no_mangle]
3465pub unsafe extern "C" fn xmlFreeInputStream(input: *mut _xmlParserInput) {
3466 if input.is_null() {
3467 return;
3468 }
3469 crate::xml::parser::helpers::free_parser_input(input);
3470}
3471
3472#[no_mangle]
3486pub unsafe extern "C" fn xmlOutputBufferCreateFilename(
3487 URI: *const c_char,
3488 encoder: *mut c_void,
3489 compression: c_int,
3490) -> *mut _xmlOutputBuffer {
3491 let _ = compression;
3492 if URI.is_null() {
3493 return ptr::null_mut();
3494 }
3495 crate::xml::io::output_buffer_create_filename(
3496 URI,
3497 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3498 0,
3499 )
3500}
3501
3502#[no_mangle]
3511pub unsafe extern "C" fn xmlOutputBufferCreateFd(
3512 fd: c_int,
3513 encoder: *mut c_void,
3514) -> *mut _xmlOutputBuffer {
3515 if fd < 0 {
3516 return ptr::null_mut();
3517 }
3518 crate::xml::io::output_buffer_create_fd(
3519 fd,
3520 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3521 )
3522}
3523
3524#[no_mangle]
3534pub unsafe extern "C" fn xmlOutputBufferCreateIO(
3535 iowrite: Option<xmlOutputWriteCallback>,
3536 ioclose: Option<xmlOutputCloseCallback>,
3537 ioctx: *mut c_void,
3538 encoder: *mut c_void,
3539) -> *mut _xmlOutputBuffer {
3540 crate::xml::io::output_buffer_create_io(
3541 iowrite,
3542 ioclose,
3543 ioctx,
3544 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3545 )
3546}
3547
3548#[no_mangle]
3556pub unsafe extern "C" fn xmlOutputBufferClose(out: *mut _xmlOutputBuffer) -> c_int {
3557 if out.is_null() {
3558 return -1;
3559 }
3560 crate::xml::io::output_buffer_close(out)
3561}
3562
3563#[no_mangle]
3571pub unsafe extern "C" fn xmlOutputBufferFlush(out: *mut _xmlOutputBuffer) -> c_int {
3572 if out.is_null() {
3573 return -1;
3574 }
3575 crate::xml::io::output_buffer_flush(out)
3576}
3577
3578#[no_mangle]
3586pub unsafe extern "C" fn xmlOutputBufferWrite(
3587 out: *mut _xmlOutputBuffer,
3588 len: c_int,
3589 data: *const c_char,
3590) -> c_int {
3591 if out.is_null() || data.is_null() || len <= 0 {
3592 return -1;
3593 }
3594 crate::xml::io::output_buffer_write(out, len, data)
3595}
3596
3597#[no_mangle]
3605pub unsafe extern "C" fn xmlOutputBufferWriteString(
3606 out: *mut _xmlOutputBuffer,
3607 str: *const c_char,
3608) -> c_int {
3609 if str.is_null() {
3610 return 0;
3611 }
3612 unsafe { xmlOutputBufferWrite(out, xmlStrlen(str as *const xmlChar), str) }
3613}
3614
3615#[no_mangle]
3623pub unsafe extern "C" fn xmlAllocOutputBuffer(encoder: *mut c_void) -> *mut _xmlOutputBuffer {
3624 crate::xml::io::output_buffer_create(
3625 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3626 )
3627}
3628
3629#[no_mangle]
3643pub unsafe extern "C" fn xmlOutputBufferCreateBuffer(
3644 buffer: *mut crate::abi::structs::_xmlBuffer,
3645 encoder: *mut c_void,
3646) -> *mut _xmlOutputBuffer {
3647 crate::xml::io::output_buffer_create_buffer(
3648 buffer,
3649 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3650 )
3651}
3652
3653#[no_mangle]
3661pub unsafe extern "C" fn xmlOutputBufferCreateFile(
3662 file: *mut libc::FILE,
3663 encoder: *mut c_void,
3664) -> *mut _xmlOutputBuffer {
3665 crate::xml::io::output_buffer_create_file(
3666 file,
3667 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3668 )
3669}
3670
3671#[no_mangle]
3677pub unsafe extern "C" fn xmlOutputBufferGetContent(out: *mut _xmlOutputBuffer) -> *const c_char {
3678 crate::xml::io::output_buffer_get_content(out) as *const c_char
3679}
3680
3681#[no_mangle]
3688pub unsafe extern "C" fn xmlOutputBufferGetSize(out: *mut _xmlOutputBuffer) -> c_int {
3689 crate::xml::io::output_buffer_get_size(out)
3690}
3691
3692#[no_mangle]
3700pub unsafe extern "C" fn xmlOutputBufferWriteEscape(
3701 out: *mut _xmlOutputBuffer,
3702 str: *const xmlChar,
3703 escaping: Option<xmlCharEncodingOutputFunc>,
3704) -> c_int {
3705 if out.is_null() || str.is_null() {
3706 return -1;
3707 }
3708 crate::xml::io::output_buffer_write_escape(out, str, escaping)
3709}
3710
3711static mut OUTPUT_CREATE_FILENAME_DEFAULT: Option<
3714 unsafe extern "C" fn(
3715 *const c_char,
3716 *mut crate::abi::structs::_xmlCharEncodingHandler,
3717 c_int,
3718 ) -> *mut _xmlOutputBuffer,
3719> = None;
3720
3721#[no_mangle]
3728pub unsafe extern "C" fn xmlOutputBufferCreateFilenameDefault(
3729 func: Option<
3730 unsafe extern "C" fn(
3731 *const c_char,
3732 *mut crate::abi::structs::_xmlCharEncodingHandler,
3733 c_int,
3734 ) -> *mut _xmlOutputBuffer,
3735 >,
3736) -> Option<
3737 unsafe extern "C" fn(
3738 *const c_char,
3739 *mut crate::abi::structs::_xmlCharEncodingHandler,
3740 c_int,
3741 ) -> *mut _xmlOutputBuffer,
3742> {
3743 let old = unsafe { OUTPUT_CREATE_FILENAME_DEFAULT };
3744 if func.is_some() {
3745 unsafe { OUTPUT_CREATE_FILENAME_DEFAULT = func };
3746 }
3747 old
3748}
3749
3750#[no_mangle]
3753pub unsafe extern "C" fn __xmlOutputBufferCreateFilename() -> *mut Option<
3754 unsafe extern "C" fn(
3755 *const c_char,
3756 *mut crate::abi::structs::_xmlCharEncodingHandler,
3757 c_int,
3758 ) -> *mut _xmlOutputBuffer,
3759> {
3760 unsafe { core::ptr::addr_of_mut!(OUTPUT_CREATE_FILENAME_DEFAULT) }
3761}
3762
3763#[no_mangle]
3775pub extern "C" fn xmlDictCreate() -> *mut c_void {
3776 let d = unsafe { crate::xml::dictionary::dict_create() as *mut c_void };
3777 if !d.is_null() {
3778 *crate::abi::exports_hash::DICT_REFS
3782 .lock()
3783 .entry(d as usize)
3784 .or_insert(0) = 1;
3785 }
3786 d
3787}
3788
3789#[no_mangle]
3797pub extern "C" fn xmlDictCreateSub(sub: *mut c_void) -> *mut c_void {
3798 let d = unsafe {
3799 crate::xml::dictionary::dict_create_sub(sub as *mut crate::xml::dictionary::Dict)
3800 as *mut c_void
3801 };
3802 if !d.is_null() {
3803 *crate::abi::exports_hash::DICT_REFS
3804 .lock()
3805 .entry(d as usize)
3806 .or_insert(0) = 1;
3807 }
3808 d
3809}
3810
3811#[no_mangle]
3823pub unsafe extern "C" fn xmlDictLookup(
3824 dict: *mut c_void,
3825 name: *const xmlChar,
3826 len: c_int,
3827) -> *const xmlChar {
3828 unsafe {
3829 crate::xml::dictionary::dict_lookup(dict as *mut crate::xml::dictionary::Dict, name, len)
3830 }
3831}
3832
3833#[no_mangle]
3841pub unsafe extern "C" fn xmlDictExists(
3842 dict: *mut c_void,
3843 name: *const xmlChar,
3844 len: c_int,
3845) -> *const xmlChar {
3846 unsafe {
3847 crate::xml::dictionary::dict_exists(dict as *mut crate::xml::dictionary::Dict, name, len)
3848 }
3849}
3850
3851#[no_mangle]
3859pub extern "C" fn xmlDictSize(dict: *const c_void) -> c_uint {
3860 unsafe {
3861 crate::xml::dictionary::dict_size(dict as *const crate::xml::dictionary::Dict) as c_uint
3862 }
3863}
3864
3865#[no_mangle]
3877pub extern "C" fn xmlDictFree(dict: *mut c_void) {
3878 if dict.is_null() {
3879 return;
3880 }
3881 let mut remaining = 0u32;
3882 {
3883 let mut refs = crate::abi::exports_hash::DICT_REFS.lock();
3884 if let Some(r) = refs.get_mut(&(dict as usize)) {
3885 if *r > 0 {
3886 *r -= 1;
3887 }
3888 remaining = *r;
3889 if remaining == 0 {
3890 refs.remove(&(dict as usize));
3891 }
3892 }
3893 }
3894 if remaining == 0 {
3895 unsafe { crate::xml::dictionary::dict_free(dict as *mut crate::xml::dictionary::Dict) };
3896 }
3897}
3898
3899#[no_mangle]
3907pub extern "C" fn xmlDictSetLimit(dict: *mut c_void, limit: c_uint) -> c_uint {
3908 unsafe {
3909 crate::xml::dictionary::dict_set_limit(
3910 dict as *mut crate::xml::dictionary::Dict,
3911 limit as usize,
3912 ) as c_uint
3913 }
3914}
3915
3916#[no_mangle]
3924pub extern "C" fn xmlDictGetUsage(dict: *const c_void) -> c_uint {
3925 unsafe {
3926 crate::xml::dictionary::dict_get_usage(dict as *mut crate::xml::dictionary::Dict) as c_uint
3927 }
3928}
3929
3930#[no_mangle]
3942pub extern "C" fn xmlHashCreate(size: c_int) -> *mut c_void {
3943 unsafe { crate::xml::hash::hash_create(size) as *mut c_void }
3944}
3945
3946#[no_mangle]
3954pub extern "C" fn xmlHashCreateDict(size: c_int, dict: *mut c_void) -> *mut c_void {
3955 unsafe { crate::xml::hash::hash_create_dict(size, dict) as *mut c_void }
3956}
3957
3958#[no_mangle]
3966pub extern "C" fn xmlHashFree(
3967 table: *mut c_void,
3968 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
3969) {
3970 unsafe { crate::xml::hash::hash_free(table as *mut crate::xml::hash::HashTable, f) }
3971}
3972
3973#[no_mangle]
3981pub unsafe extern "C" fn xmlHashAddEntry(
3982 table: *mut c_void,
3983 name: *const xmlChar,
3984 userdata: *mut c_void,
3985) -> c_int {
3986 unsafe {
3987 crate::xml::hash::hash_add_entry(table as *mut crate::xml::hash::HashTable, name, userdata)
3988 }
3989}
3990
3991#[no_mangle]
4000pub unsafe extern "C" fn xmlHashAddEntry2(
4001 table: *mut c_void,
4002 name: *const xmlChar,
4003 name2: *const xmlChar,
4004 userdata: *mut c_void,
4005) -> c_int {
4006 unsafe {
4007 crate::xml::hash::hash_add_entry2(
4008 table as *mut crate::xml::hash::HashTable,
4009 name,
4010 name2,
4011 userdata,
4012 )
4013 }
4014}
4015
4016#[no_mangle]
4025pub unsafe extern "C" fn xmlHashAddEntry3(
4026 table: *mut c_void,
4027 name: *const xmlChar,
4028 name2: *const xmlChar,
4029 name3: *const xmlChar,
4030 userdata: *mut c_void,
4031) -> c_int {
4032 unsafe {
4033 crate::xml::hash::hash_add_entry3(
4034 table as *mut crate::xml::hash::HashTable,
4035 name,
4036 name2,
4037 name3,
4038 userdata,
4039 )
4040 }
4041}
4042
4043#[no_mangle]
4052pub unsafe extern "C" fn xmlHashUpdateEntry(
4053 table: *mut c_void,
4054 name: *const xmlChar,
4055 userdata: *mut c_void,
4056 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4057) -> c_int {
4058 unsafe {
4059 crate::xml::hash::hash_update_entry(
4060 table as *mut crate::xml::hash::HashTable,
4061 name,
4062 userdata,
4063 f,
4064 )
4065 }
4066}
4067
4068#[no_mangle]
4070pub unsafe extern "C" fn xmlHashUpdateEntry2(
4071 table: *mut c_void,
4072 name: *const xmlChar,
4073 name2: *const xmlChar,
4074 userdata: *mut c_void,
4075 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4076) -> c_int {
4077 unsafe {
4078 crate::xml::hash::hash_update_entry2(
4079 table as *mut crate::xml::hash::HashTable,
4080 name,
4081 name2,
4082 userdata,
4083 f,
4084 )
4085 }
4086}
4087
4088#[no_mangle]
4090pub unsafe extern "C" fn xmlHashUpdateEntry3(
4091 table: *mut c_void,
4092 name: *const xmlChar,
4093 name2: *const xmlChar,
4094 name3: *const xmlChar,
4095 userdata: *mut c_void,
4096 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4097) -> c_int {
4098 unsafe {
4099 crate::xml::hash::hash_update_entry3(
4100 table as *mut crate::xml::hash::HashTable,
4101 name,
4102 name2,
4103 name3,
4104 userdata,
4105 f,
4106 )
4107 }
4108}
4109
4110#[no_mangle]
4118pub unsafe extern "C" fn xmlHashLookup(table: *mut c_void, name: *const xmlChar) -> *mut c_void {
4119 unsafe { crate::xml::hash::hash_lookup(table as *mut crate::xml::hash::HashTable, name) }
4120}
4121
4122#[no_mangle]
4124pub unsafe extern "C" fn xmlHashLookup2(
4125 table: *mut c_void,
4126 name: *const xmlChar,
4127 name2: *const xmlChar,
4128) -> *mut c_void {
4129 unsafe {
4130 crate::xml::hash::hash_lookup2(table as *mut crate::xml::hash::HashTable, name, name2)
4131 }
4132}
4133
4134#[no_mangle]
4136pub unsafe extern "C" fn xmlHashLookup3(
4137 table: *mut c_void,
4138 name: *const xmlChar,
4139 name2: *const xmlChar,
4140 name3: *const xmlChar,
4141) -> *mut c_void {
4142 unsafe {
4143 crate::xml::hash::hash_lookup3(
4144 table as *mut crate::xml::hash::HashTable,
4145 name,
4146 name2,
4147 name3,
4148 )
4149 }
4150}
4151
4152#[no_mangle]
4160pub extern "C" fn xmlHashSize(table: *mut c_void) -> c_int {
4161 unsafe { crate::xml::hash::hash_size(table as *mut crate::xml::hash::HashTable) }
4162}
4163
4164#[no_mangle]
4173pub unsafe extern "C" fn xmlHashRemoveEntry(
4174 table: *mut c_void,
4175 name: *const xmlChar,
4176 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4177) -> c_int {
4178 unsafe {
4179 crate::xml::hash::hash_remove_entry(table as *mut crate::xml::hash::HashTable, name, f)
4180 }
4181}
4182
4183#[no_mangle]
4185pub unsafe extern "C" fn xmlHashRemoveEntry2(
4186 table: *mut c_void,
4187 name: *const xmlChar,
4188 name2: *const xmlChar,
4189 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4190) -> c_int {
4191 unsafe {
4192 crate::xml::hash::hash_remove_entry2(
4193 table as *mut crate::xml::hash::HashTable,
4194 name,
4195 name2,
4196 f,
4197 )
4198 }
4199}
4200
4201#[no_mangle]
4203pub unsafe extern "C" fn xmlHashRemoveEntry3(
4204 table: *mut c_void,
4205 name: *const xmlChar,
4206 name2: *const xmlChar,
4207 name3: *const xmlChar,
4208 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4209) -> c_int {
4210 unsafe {
4211 crate::xml::hash::hash_remove_entry3(
4212 table as *mut crate::xml::hash::HashTable,
4213 name,
4214 name2,
4215 name3,
4216 f,
4217 )
4218 }
4219}
4220
4221#[no_mangle]
4229pub extern "C" fn xmlHashScan(table: *mut c_void, f: Option<xmlHashScanner>, data: *mut c_void) {
4230 unsafe { crate::xml::hash::hash_scan(table as *mut crate::xml::hash::HashTable, f, data) }
4231}
4232
4233#[no_mangle]
4235pub extern "C" fn xmlHashScanFull(
4236 table: *mut c_void,
4237 f: Option<xmlHashScannerFull>,
4238 data: *mut c_void,
4239) {
4240 unsafe { crate::xml::hash::hash_scan_full(table as *mut crate::xml::hash::HashTable, f, data) }
4241}
4242
4243#[no_mangle]
4251pub extern "C" fn xmlHashCopy(
4252 table: *mut c_void,
4253 f: Option<unsafe extern "C" fn(*mut c_void, *const xmlChar) -> *mut c_void>,
4254) -> *mut c_void {
4255 unsafe {
4256 crate::xml::hash::hash_copy(table as *mut crate::xml::hash::HashTable, f) as *mut c_void
4257 }
4258}
4259
4260#[no_mangle]
4273pub extern "C" fn xmlListCreate(
4274 deallocator: Option<unsafe extern "C" fn(*mut c_void)>,
4275 compare: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
4276) -> *mut c_void {
4277 unsafe { crate::xml::list::list_create(deallocator, compare) as *mut c_void }
4278}
4279
4280#[no_mangle]
4288pub extern "C" fn xmlListDelete(list: *mut c_void) {
4289 unsafe { crate::xml::list::list_delete(list as *mut crate::xml::list::List) }
4290}
4291
4292#[no_mangle]
4300pub extern "C" fn xmlListSearch(list: *mut c_void, data: *mut c_void) -> *mut c_void {
4301 unsafe { crate::xml::list::list_search(list as *mut crate::xml::list::List, data) }
4302}
4303
4304#[no_mangle]
4312pub extern "C" fn xmlListWalk(
4313 list: *mut c_void,
4314 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4315 data: *mut c_void,
4316) {
4317 unsafe { crate::xml::list::list_walk(list as *mut crate::xml::list::List, walker, data) }
4318}
4319
4320#[no_mangle]
4328pub extern "C" fn xmlListPushBack(list: *mut c_void, data: *mut c_void) -> c_int {
4329 unsafe { crate::xml::list::list_push_back(list as *mut crate::xml::list::List, data) }
4330}
4331
4332#[no_mangle]
4340pub extern "C" fn xmlListPushFront(list: *mut c_void, data: *mut c_void) -> c_int {
4341 unsafe { crate::xml::list::list_push_front(list as *mut crate::xml::list::List, data) }
4342}
4343
4344#[no_mangle]
4346pub extern "C" fn xmlListPopBack(list: *mut c_void) {
4347 unsafe { crate::xml::list::list_pop_back(list as *mut crate::xml::list::List) }
4348}
4349
4350#[no_mangle]
4352pub extern "C" fn xmlListPopFront(list: *mut c_void) {
4353 unsafe { crate::xml::list::list_pop_front(list as *mut crate::xml::list::List) }
4354}
4355
4356#[no_mangle]
4364pub extern "C" fn xmlListInsert(list: *mut c_void, data: *mut c_void) -> c_int {
4365 unsafe { crate::xml::list::list_insert(list as *mut crate::xml::list::List, data) }
4366}
4367
4368#[no_mangle]
4370pub extern "C" fn xmlListAppend(list: *mut c_void, data: *mut c_void) -> c_int {
4371 unsafe { crate::xml::list::list_append(list as *mut crate::xml::list::List, data) }
4372}
4373
4374#[no_mangle]
4376pub extern "C" fn xmlListRemoveFirst(list: *mut c_void, data: *mut c_void) -> c_int {
4377 unsafe { crate::xml::list::list_remove_first(list as *mut crate::xml::list::List, data) }
4378}
4379
4380#[no_mangle]
4382pub extern "C" fn xmlListRemoveLast(list: *mut c_void, data: *mut c_void) -> c_int {
4383 unsafe { crate::xml::list::list_remove_last(list as *mut crate::xml::list::List, data) }
4384}
4385
4386#[no_mangle]
4388pub extern "C" fn xmlListRemoveAll(list: *mut c_void, data: *mut c_void) -> c_int {
4389 unsafe { crate::xml::list::list_remove_all(list as *mut crate::xml::list::List, data) }
4390}
4391
4392#[no_mangle]
4394pub extern "C" fn xmlListClear(list: *mut c_void) {
4395 unsafe { crate::xml::list::list_clear(list as *mut crate::xml::list::List) }
4396}
4397
4398#[no_mangle]
4406pub extern "C" fn xmlListEmpty(list: *mut c_void) -> c_int {
4407 unsafe { crate::xml::list::list_empty(list as *mut crate::xml::list::List) }
4408}
4409
4410#[no_mangle]
4418pub extern "C" fn xmlListFront(list: *mut c_void) -> *mut c_void {
4419 unsafe { crate::xml::list::list_front(list as *mut crate::xml::list::List) }
4420}
4421
4422#[no_mangle]
4430pub extern "C" fn xmlListBack(list: *mut c_void) -> *mut c_void {
4431 unsafe { crate::xml::list::list_back(list as *mut crate::xml::list::List) }
4432}
4433
4434#[no_mangle]
4442pub extern "C" fn xmlListSize(list: *mut c_void) -> c_int {
4443 unsafe { crate::xml::list::list_size(list as *mut crate::xml::list::List) }
4444}
4445
4446#[no_mangle]
4448pub extern "C" fn xmlListSort(list: *mut c_void) {
4449 unsafe { crate::xml::list::list_sort(list as *mut crate::xml::list::List) }
4450}
4451
4452#[no_mangle]
4454pub extern "C" fn xmlListReverse(list: *mut c_void) {
4455 unsafe { crate::xml::list::list_reverse(list as *mut crate::xml::list::List) }
4456}
4457
4458#[no_mangle]
4460pub extern "C" fn xmlListReverseSplice(list: *mut c_void, list2: *mut c_void) {
4461 unsafe {
4462 crate::xml::list::list_reverse_splice(
4463 list as *mut crate::xml::list::List,
4464 list2 as *mut crate::xml::list::List,
4465 )
4466 }
4467}
4468
4469#[no_mangle]
4471pub extern "C" fn xmlListMerge(list: *mut c_void, list2: *mut c_void) {
4472 unsafe {
4473 crate::xml::list::list_merge(
4474 list as *mut crate::xml::list::List,
4475 list2 as *mut crate::xml::list::List,
4476 )
4477 }
4478}
4479#[no_mangle]
4487pub unsafe extern "C" fn xmlListEnd(l: *mut c_void) -> *mut c_void {
4488 crate::xml::list::list_end(l as *mut crate::xml::list::List)
4489}
4490
4491#[no_mangle]
4499pub unsafe extern "C" fn xmlListReverseSearch(l: *mut c_void, data: *mut c_void) -> *mut c_void {
4500 crate::xml::list::list_reverse_search(l as *mut crate::xml::list::List, data)
4501}
4502
4503#[no_mangle]
4511pub unsafe extern "C" fn xmlListReverseWalk(
4512 l: *mut c_void,
4513 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4514 data: *mut c_void,
4515) {
4516 crate::xml::list::list_reverse_walk(l as *mut crate::xml::list::List, walker, data)
4517}
4518
4519#[no_mangle]
4527pub unsafe extern "C" fn xmlListDup(l: *mut c_void) -> *mut c_void {
4528 crate::xml::list::list_dup(l as *mut crate::xml::list::List) as *mut c_void
4529}
4530
4531#[no_mangle]
4539pub unsafe extern "C" fn xmlListCopy(
4540 l: *mut c_void,
4541 copier: Option<unsafe extern "C" fn(*mut c_void) -> *mut c_void>,
4542) -> c_int {
4543 crate::xml::list::list_copy(l as *mut crate::xml::list::List, copier)
4544}
4545
4546#[no_mangle]
4554pub unsafe extern "C" fn xmlLinkGetData(lk: *mut c_void) -> *mut c_void {
4555 crate::xml::list::link_get_data(lk)
4556}
4557
4558#[no_mangle]
4570pub extern "C" fn xmlBufferCreate() -> *mut _xmlBuffer {
4571 crate::xml::io::buf_create(-1)
4572}
4573
4574#[no_mangle]
4582pub extern "C" fn xmlBufferCreateSize(size: usize) -> *mut _xmlBuffer {
4583 crate::xml::io::buf_create(size as c_int)
4584}
4585
4586#[no_mangle]
4594pub extern "C" fn xmlBufferCreateStatic(mem: *mut c_void, size: usize) -> *mut _xmlBuffer {
4595 if mem.is_null() || size == 0 {
4596 return ptr::null_mut();
4597 }
4598 crate::xml::io::buf_create_static(mem as *const xmlChar, size as c_int)
4599}
4600
4601#[no_mangle]
4609pub extern "C" fn xmlBufferFree(buf: *mut _xmlBuffer) {
4610 crate::xml::io::buf_free(buf)
4611}
4612
4613#[no_mangle]
4621pub extern "C" fn xmlBufferEmpty(buf: *mut _xmlBuffer) {
4622 if buf.is_null() {
4623 return;
4624 }
4625 unsafe {
4626 if !(*buf).content.is_null() {
4627 *(*buf).content = 0;
4628 }
4629 (*buf).use_ = 0;
4630 }
4631}
4632
4633#[no_mangle]
4641pub extern "C" fn xmlBufferContent(buf: *const _xmlBuffer) -> *mut xmlChar {
4642 crate::xml::io::buf_content(buf as *mut _xmlBuffer)
4643}
4644
4645#[no_mangle]
4653pub extern "C" fn xmlBufferLength(buf: *const _xmlBuffer) -> c_int {
4654 crate::xml::io::buf_length(buf as *mut _xmlBuffer)
4655}
4656
4657#[no_mangle]
4665pub unsafe extern "C" fn xmlBufferAdd(
4666 buf: *mut _xmlBuffer,
4667 str: *const xmlChar,
4668 len: c_int,
4669) -> c_int {
4670 crate::xml::io::buf_add(buf, str, len)
4671}
4672
4673#[no_mangle]
4681pub unsafe extern "C" fn xmlBufferAddHead(
4682 buf: *mut _xmlBuffer,
4683 str: *const xmlChar,
4684 len: c_int,
4685) -> c_int {
4686 crate::xml::io::buf_add_head(buf, str, len)
4687}
4688
4689#[no_mangle]
4697pub unsafe extern "C" fn xmlBufferCat(buf: *mut _xmlBuffer, str: *const xmlChar) -> c_int {
4698 if str.is_null() {
4699 return -1;
4700 }
4701 let len = crate::xml::string::xml_strlen(str) as c_int;
4702 crate::xml::io::buf_add(buf, str, len)
4703}
4704
4705#[no_mangle]
4714pub extern "C" fn xmlBufferSetAllocationScheme(buf: *mut _xmlBuffer, scheme: c_int) {
4715 if buf.is_null() {
4716 return;
4717 }
4718 unsafe {
4719 (*buf).alloc = scheme;
4720 }
4721}
4722
4723#[no_mangle]
4731pub extern "C" fn xmlBufferShrink(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4732 if buf.is_null() || len <= 0 {
4733 return 0;
4734 }
4735 unsafe {
4736 let b = &mut *buf;
4737 let shrink_len = (len as c_uint).min(b.use_);
4738 if shrink_len > 0 {
4739 let remaining = b.use_ - shrink_len;
4740 if remaining > 0 {
4741 core::ptr::copy(
4742 b.content.add(shrink_len as usize),
4743 b.content,
4744 remaining as usize,
4745 );
4746 }
4747 *b.content.add(remaining as usize) = 0;
4748 b.use_ = remaining;
4749 }
4750 }
4751 len
4752}
4753
4754#[no_mangle]
4762pub extern "C" fn xmlBufferGrow(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4763 if buf.is_null() || len <= 0 {
4764 return 0;
4765 }
4766 let cur_use = unsafe { (*buf).use_ };
4767 let new_size = cur_use + len as c_uint + 1;
4768 crate::xml::io::buf_grow(buf, new_size)
4769}
4770
4771#[no_mangle]
4779pub extern "C" fn xmlBufferReserve(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4780 xmlBufferGrow(buf, len)
4781}
4782
4783#[no_mangle]
4791pub extern "C" fn xmlBufferDetach(buf: *mut _xmlBuffer) -> *mut xmlChar {
4792 if buf.is_null() {
4793 return ptr::null_mut();
4794 }
4795 unsafe {
4796 let content = (*buf).content;
4797 (*buf).content = ptr::null_mut();
4798 (*buf).use_ = 0;
4799 (*buf).size = 0;
4800 content
4801 }
4802}
4803
4804#[no_mangle]
4816pub extern "C" fn xmlGetCharEncoding(name: *const c_char) -> c_int {
4817 if name.is_null() {
4818 return 0; }
4820 let name_bytes = unsafe {
4821 let len = libc::strlen(name);
4822 core::slice::from_raw_parts(name as *const u8, len)
4823 };
4824 crate::xml::encoding::encoding_from_name(name_bytes) as c_int
4825}
4826
4827#[no_mangle]
4835pub extern "C" fn xmlFindCharEncodingHandler(name: *const c_char) -> *mut c_void {
4836 if name.is_null() {
4837 return ptr::null_mut();
4838 }
4839 crate::xml::encoding::find_encoding_handler(name as *const xmlChar) as *mut c_void
4840}
4841
4842#[no_mangle]
4850pub extern "C" fn xmlCharEncCloseFunc(handler: *mut c_void) -> c_int {
4851 if handler.is_null() {
4852 return -1;
4853 }
4854 unsafe {
4856 let h = handler as *mut crate::abi::structs::_xmlCharEncodingHandler;
4857 if !(*h).name.is_null() {
4858 crate::abi::allocator::xmlFreeImpl((*h).name as *mut c_void);
4859 }
4860 crate::abi::allocator::xmlFreeImpl(handler);
4861 }
4862 0
4863}
4864
4865#[no_mangle]
4873pub extern "C" fn xmlGetCharEncodingName(enc: c_int) -> *const c_char {
4874 if enc < -1 || enc > 22 {
4878 return match enc {
4879 23 => c"UTF-16".as_ptr(),
4880 24 => c"HTML".as_ptr(),
4881 31 => c"windows-1252".as_ptr(),
4882 _ => ptr::null(),
4883 };
4884 }
4885 let e: crate::abi::types::xmlCharEncoding = unsafe { core::mem::transmute(enc) };
4886 crate::xml::encoding::xmlGetCharEncodingName(e)
4887}
4888
4889#[no_mangle]
4899pub extern "C" fn xmlParseCharEncoding(name: *const c_char) -> c_int {
4900 crate::xml::encoding::xmlParseCharEncoding(name)
4901}
4902
4903#[no_mangle]
4911pub extern "C" fn xmlAddEncodingAlias(name: *const c_char, alias: *const c_char) -> c_int {
4912 crate::xml::encoding::add_encoding_alias(name, alias)
4913}
4914
4915#[no_mangle]
4923pub extern "C" fn xmlDelEncodingAlias(alias: *const c_char) -> c_int {
4924 crate::xml::encoding::del_encoding_alias(alias)
4925}
4926
4927#[no_mangle]
4935pub extern "C" fn xmlGetEncodingAlias(alias: *const c_char) -> *const c_char {
4936 crate::xml::encoding::get_encoding_alias(alias)
4937}
4938
4939#[no_mangle]
4947pub extern "C" fn xmlCleanupEncodingAliases() {
4948 crate::xml::encoding::cleanup_encoding_aliases();
4949}
4950
4951#[no_mangle]
4960pub extern "C" fn xmlCharEncInFunc(
4961 handler: *mut c_void,
4962 out: *mut c_void,
4963 in_: *mut c_void,
4964) -> c_int {
4965 crate::xml::encoding::xmlCharEncInFunc(
4966 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
4967 out as *mut crate::abi::structs::_xmlBuffer,
4968 in_ as *mut crate::abi::structs::_xmlBuffer,
4969 )
4970}
4971
4972#[no_mangle]
4981pub extern "C" fn xmlCharEncOutFunc(
4982 handler: *mut c_void,
4983 out: *mut c_void,
4984 in_: *mut c_void,
4985) -> c_int {
4986 crate::xml::encoding::xmlCharEncOutFunc(
4987 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
4988 out as *mut crate::abi::structs::_xmlBuffer,
4989 in_ as *mut crate::abi::structs::_xmlBuffer,
4990 )
4991}
4992
4993#[no_mangle]
5003pub extern "C" fn xmlNewCharEncodingHandler(
5004 name: *const c_char,
5005 input: crate::abi::callbacks::xmlCharEncodingInputFunc,
5006 output: crate::abi::callbacks::xmlCharEncodingOutputFunc,
5007) -> *mut c_void {
5008 crate::xml::encoding::xmlNewCharEncodingHandler(name, input, output) as *mut c_void
5009}
5010
5011#[no_mangle]
5019pub extern "C" fn xmlInitCharEncodingHandlers() {
5020 crate::xml::encoding::xmlInitCharEncodingHandlers();
5021}
5022
5023#[no_mangle]
5031pub extern "C" fn xmlCleanupCharEncodingHandlers() {
5032 crate::xml::encoding::xmlCleanupCharEncodingHandlers();
5033}
5034
5035#[no_mangle]
5047pub extern "C" fn xmlLookupCharEncodingHandler(enc: c_int, out: *mut *mut c_void) -> c_int {
5048 crate::xml::encoding::xmlLookupCharEncodingHandler(enc, out)
5049}
5050
5051#[no_mangle]
5059pub extern "C" fn xmlGetCharEncodingHandler(enc: c_int) -> *mut c_void {
5060 crate::xml::encoding::xmlGetCharEncodingHandler(enc)
5061}
5062
5063#[no_mangle]
5072pub extern "C" fn xmlOpenCharEncodingHandler(
5073 name: *const c_char,
5074 output: c_int,
5075 out: *mut *mut c_void,
5076) -> c_int {
5077 crate::xml::encoding::xmlOpenCharEncodingHandler(name, output, out)
5078}
5079
5080#[no_mangle]
5091pub extern "C" fn xmlCreateCharEncodingHandler(
5092 name: *const c_char,
5093 flags: c_int,
5094 impl_: Option<crate::abi::callbacks::xmlCharEncConvImpl>,
5095 implCtxt: *mut c_void,
5096 out: *mut *mut c_void,
5097) -> c_int {
5098 crate::xml::encoding::xmlCreateCharEncodingHandler(name, flags, impl_, implCtxt, out)
5099}
5100
5101#[no_mangle]
5112pub extern "C" fn xmlCharEncNewCustomHandler(
5113 name: *const c_char,
5114 input: crate::abi::callbacks::xmlCharEncConvFunc,
5115 output: crate::abi::callbacks::xmlCharEncConvFunc,
5116 ctxtDtor: Option<crate::abi::callbacks::xmlCharEncConvCtxtDtor>,
5117 inputCtxt: *mut c_void,
5118 outputCtxt: *mut c_void,
5119 out: *mut *mut c_void,
5120) -> c_int {
5121 crate::xml::encoding::xmlCharEncNewCustomHandler(
5122 name, input, output, ctxtDtor, inputCtxt, outputCtxt, out,
5123 )
5124}
5125
5126#[no_mangle]
5134pub unsafe extern "C" fn xmlCharEncInput(input: *mut _xmlParserInputBuffer, _to: c_int) -> c_int {
5135 if input.is_null() {
5136 return -1;
5137 }
5138 let handler = (*input).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5139 if handler.is_null() {
5140 return -1;
5141 }
5142 let raw = (*input).raw as *mut crate::abi::structs::_xmlBuffer;
5143 let buf = (*input).buffer as *mut crate::abi::structs::_xmlBuffer;
5144 if raw.is_null() || buf.is_null() {
5145 return -1;
5146 }
5147 crate::xml::encoding::char_enc_in(handler, buf, raw)
5148}
5149
5150#[no_mangle]
5158pub unsafe extern "C" fn xmlCharEncOutput(output: *mut _xmlOutputBuffer, _to: c_int) -> c_int {
5159 if output.is_null() {
5160 return -1;
5161 }
5162 let handler = (*output).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5163 if handler.is_null() {
5164 return -1;
5165 }
5166 let buf = (*output).buffer as *mut crate::abi::structs::_xmlBuffer;
5167 let conv = (*output).conv as *mut crate::abi::structs::_xmlBuffer;
5168 if buf.is_null() || conv.is_null() {
5169 return -1;
5170 }
5171 crate::xml::encoding::char_enc_out(handler, conv, buf)
5172}
5173
5174#[no_mangle]
5186pub unsafe extern "C" fn xmlParseURI(str: *const c_char) -> *mut c_void {
5187 crate::xml::uri::xmlParseURI(str)
5188}
5189
5190#[no_mangle]
5198pub unsafe extern "C" fn xmlParseURIRaw(str: *const c_char, raw: c_int) -> *mut c_void {
5199 let _ = raw;
5200 crate::xml::uri::xmlParseURI(str)
5201}
5202
5203#[no_mangle]
5211pub unsafe extern "C" fn xmlFreeURI(uri: *mut c_void) {
5212 crate::xml::uri::xmlFreeURI(uri)
5213}
5214
5215#[no_mangle]
5223pub extern "C" fn xmlCreateURI() -> *mut c_void {
5224 crate::xml::uri::xmlCreateURI()
5225}
5226
5227#[no_mangle]
5235pub unsafe extern "C" fn xmlSaveUri(uri: *mut c_void) -> *mut xmlChar {
5236 crate::xml::uri::xmlSaveUri(uri)
5237}
5238
5239#[no_mangle]
5255pub unsafe extern "C" fn xmlParseURIReference(uri: *mut c_void, str: *const c_char) -> c_int {
5256 crate::xml::uri::xmlParseURIReference(uri, str)
5257}
5258
5259#[no_mangle]
5274pub unsafe extern "C" fn xmlNormalizeURIPath(path: *mut c_char) -> c_int {
5275 crate::xml::uri::xmlNormalizeURIPath(path)
5276}
5277
5278#[no_mangle]
5286pub unsafe extern "C" fn xmlURIEscapeStr(
5287 str: *const xmlChar,
5288 list: *const xmlChar,
5289) -> *mut xmlChar {
5290 crate::xml::uri::xmlURIEscapeStr(str, list)
5291}
5292
5293#[no_mangle]
5301pub unsafe extern "C" fn xmlURIUnescapeString(
5302 str: *const c_char,
5303 len: c_int,
5304 target: *mut c_char,
5305) -> *mut c_char {
5306 crate::xml::uri::xmlURIUnescapeString(str, len, target)
5307}
5308
5309unsafe fn xpath_to_object(val: XPathValue) -> *mut _xmlXPathObject {
5324 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
5325 if obj.is_null() {
5326 return ptr::null_mut();
5327 }
5328 match val {
5329 XPathValue::NodeSet(ns) => {
5330 (*obj).type_ = xmlXPathObjectType::XPATH_NODESET as c_int;
5331 (*obj).nodesetval = ns.to_raw() as *mut c_void;
5332 }
5333 XPathValue::Boolean(b) => {
5334 (*obj).type_ = xmlXPathObjectType::XPATH_BOOLEAN as c_int;
5335 (*obj).boolval = if b { 1 } else { 0 };
5336 }
5337 XPathValue::Number(n) => {
5338 (*obj).type_ = xmlXPathObjectType::XPATH_NUMBER as c_int;
5339 (*obj).floatval = n;
5340 }
5341 XPathValue::String(s) => {
5342 (*obj).type_ = xmlXPathObjectType::XPATH_STRING as c_int;
5343 let bytes = s.as_bytes();
5344 let len = bytes.len();
5345 let buf = xmlMallocImpl(len + 1) as *mut xmlChar;
5346 if !buf.is_null() {
5347 ptr::copy_nonoverlapping(bytes.as_ptr(), buf, len);
5348 *buf.add(len) = 0; }
5350 (*obj).stringval = buf;
5351 }
5352 }
5353 obj
5354}
5355
5356unsafe fn object_to_xpathvalue(obj: *mut _xmlXPathObject) -> XPathValue {
5363 let typ = (*obj).type_;
5364 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5365 let ns_ptr = (*obj).nodesetval as *mut _xmlNodeSet;
5366 if ns_ptr.is_null() {
5367 return XPathValue::NodeSet(NodeSet::new());
5368 }
5369 let node_nr = (*ns_ptr).nodeNr;
5370 let node_tab = (*ns_ptr).nodeTab;
5371 let mut ns = NodeSet::new();
5372 if !node_tab.is_null() {
5373 for i in 0..node_nr as isize {
5374 let node = *node_tab.add(i as usize);
5375 ns.push(node);
5376 }
5377 }
5378 XPathValue::NodeSet(ns)
5379 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5380 XPathValue::Boolean((*obj).boolval != 0)
5381 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5382 XPathValue::Number((*obj).floatval)
5383 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5384 let s_ptr = (*obj).stringval;
5385 if s_ptr.is_null() {
5386 XPathValue::String(String::new())
5387 } else {
5388 let s = CStr::from_ptr(s_ptr as *const c_char)
5389 .to_string_lossy()
5390 .into_owned();
5391 XPathValue::String(s)
5392 }
5393 } else if typ == xmlXPathObjectType::XPATH_XSLT_TREE as c_int {
5394 let frag_doc = (*obj).nodesetval as *mut _xmlDoc;
5399 if frag_doc.is_null() {
5400 XPathValue::NodeSet(NodeSet::new())
5401 } else {
5402 let mut ns = NodeSet::new();
5403 ns.push(frag_doc as *mut _xmlNode);
5404 XPathValue::NodeSet(ns)
5405 }
5406 } else {
5407 XPathValue::Boolean(false)
5409 }
5410}
5411
5412pub unsafe fn xpath_to_object_pub(val: XPathValue) -> *mut _xmlXPathObject {
5418 xpath_to_object(val)
5419}
5420
5421pub unsafe fn object_to_xpathvalue_pub(obj: *mut _xmlXPathObject) -> XPathValue {
5428 object_to_xpathvalue(obj)
5429}
5430
5431static COMPILED_EXPRS: Lazy<Mutex<HashMap<u64, Box<CompiledExpr>>>> =
5437 Lazy::new(|| Mutex::new(HashMap::new()));
5438static NEXT_COMPILED_KEY: Lazy<Mutex<u64>> = Lazy::new(|| Mutex::new(1));
5439
5440pub(crate) fn xpath_compiled_registry() -> &'static Mutex<HashMap<u64, Box<CompiledExpr>>> {
5443 &COMPILED_EXPRS
5444}
5445
5446type CXPathFunc = unsafe extern "C" fn(*mut c_void, c_int);
5456
5457#[derive(Clone, Copy, PartialEq, Eq, Hash)]
5460struct SendSyncPtr(*mut c_void);
5461unsafe impl Send for SendSyncPtr {}
5462unsafe impl Sync for SendSyncPtr {}
5463
5464static C_FUNCTIONS: Lazy<Mutex<HashMap<(SendSyncPtr, String), CXPathFunc>>> =
5465 Lazy::new(|| Mutex::new(HashMap::new()));
5466
5467pub(crate) fn xpath_cfunc_lookup(extra: *mut c_void, qualified: &str) -> Option<CXPathFunc> {
5471 C_FUNCTIONS
5472 .lock()
5473 .get(&(SendSyncPtr(extra), qualified.to_string()))
5474 .copied()
5475}
5476
5477pub(crate) fn xpath_cfunc_cleanup(extra: *mut c_void) {
5480 C_FUNCTIONS.lock().retain(|(k, _), _| k.0 != extra);
5481}
5482
5483fn c_func_bridge_closure(c_ctxt: SendSyncPtr, qualified: String) -> BoxedXPathFunction {
5488 Box::new(move |_ctx: &mut XPathContext, args: &[XPathValue]| {
5489 let cc = c_ctxt;
5490 unsafe { c_func_call_bridge(cc.0 as *mut _xmlXPathContext, &qualified, args) }
5491 })
5492}
5493
5494pub(crate) unsafe fn call_c_xpath_function(
5504 fnptr: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
5505 c_ctxt: *mut _xmlXPathContext,
5506 args: &[XPathValue],
5507) -> Result<XPathValue, String> {
5508 let func = match fnptr {
5509 Some(f) => f,
5510 None => return Err("XPath: missing C function pointer".to_string()),
5511 };
5512 let pc = crate::xml::xpath::parser_context::new_parser_context(ptr::null(), c_ctxt);
5513 if pc.is_null() {
5514 return Err("XPath: parser-context allocation failure".to_string());
5515 }
5516 let mut push_ok = true;
5517 for v in args {
5518 let obj = xpath_to_object(v.clone());
5519 if obj.is_null() || crate::xml::xpath::parser_context::value_push(pc, obj).is_null() {
5520 push_ok = false;
5521 break;
5522 }
5523 }
5524 let result = if push_ok {
5525 unsafe { func(pc as *mut c_void, args.len() as c_int) };
5528 let ret = crate::xml::xpath::parser_context::value_pop(pc);
5529 if ret.is_null() {
5530 Err("XPath: C function returned no value".to_string())
5531 } else {
5532 let v = object_to_xpathvalue(ret);
5533 unsafe { xmlXPathFreeObject(ret) };
5535 Ok(v)
5536 }
5537 } else {
5538 Err("XPath: failed to push arguments to C function".to_string())
5539 };
5540 unsafe {
5542 loop {
5543 let leftover = crate::xml::xpath::parser_context::value_pop(pc);
5544 if leftover.is_null() {
5545 break;
5546 }
5547 xmlXPathFreeObject(leftover);
5548 }
5549 crate::xml::xpath::parser_context::free_parser_context(pc);
5550 }
5551 result
5552}
5553
5554unsafe fn c_func_call_bridge(
5561 c_ctxt: *mut _xmlXPathContext,
5562 qualified: &str,
5563 args: &[XPathValue],
5564) -> Result<XPathValue, String> {
5565 if c_ctxt.is_null() {
5566 return Err("XPath: null context in C function bridge".to_string());
5567 }
5568 let func = xpath_cfunc_lookup((*c_ctxt).extra, qualified);
5569 if func.is_none() {
5570 return Err(format!("XPath: unknown C function '{}'", qualified));
5571 }
5572 unsafe { call_c_xpath_function(func, c_ctxt, args) }
5573}
5574
5575#[no_mangle]
5588pub unsafe extern "C" fn xmlXPathNewContext(doc: *mut _xmlDoc) -> *mut _xmlXPathContext {
5589 let ctxt = xmlMallocZero(size_of::<_xmlXPathContext>()) as *mut _xmlXPathContext;
5590 if ctxt.is_null() {
5591 return ptr::null_mut();
5592 }
5593
5594 (*ctxt).doc = doc;
5596 (*ctxt).node = ptr::null_mut();
5597 (*ctxt).contextSize = 1;
5598 (*ctxt).proximityPosition = 1;
5599
5600 let mut internal = Box::new(XPathContext::new(doc));
5602 for (name, func) in crate::xml::xpath::functions::core_functions() {
5607 internal.register_function(&name, func);
5608 }
5609 (*ctxt).extra = Box::into_raw(internal) as *mut c_void;
5610
5611 ctxt
5612}
5613
5614#[no_mangle]
5622pub unsafe extern "C" fn xmlXPathFreeContext(ctxt: *mut _xmlXPathContext) {
5623 if ctxt.is_null() {
5624 return;
5625 }
5626 if !(*ctxt).extra.is_null() {
5628 let _ = Box::from_raw((*ctxt).extra as *mut XPathContext);
5629 (*ctxt).extra = ptr::null_mut();
5630 }
5631 if !(*ctxt).nsHash.is_null() {
5633 drop(Box::from_raw(
5634 (*ctxt).nsHash as *mut HashMap<String, CString>,
5635 ));
5636 (*ctxt).nsHash = ptr::null_mut();
5637 }
5638 xmlFreeImpl(ctxt as *mut c_void);
5640}
5641
5642#[no_mangle]
5651pub unsafe extern "C" fn xmlXPathEvalExpression(
5652 str_: *const xmlChar,
5653 ctxt: *mut _xmlXPathContext,
5654) -> *mut _xmlXPathObject {
5655 if str_.is_null() || ctxt.is_null() {
5656 return ptr::null_mut();
5657 }
5658 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
5659 Ok(s) => s,
5660 Err(_) => return ptr::null_mut(),
5661 };
5662 let internal = (*ctxt).extra as *mut XPathContext;
5663 if internal.is_null() {
5664 return ptr::null_mut();
5665 }
5666 let internal = &mut *internal;
5667
5668 match crate::xml::xpath::evaluate_str(expr_str, internal) {
5669 Some(val) => xpath_to_object(val),
5670 None => {
5671 if internal.error.is_none() {
5676 internal.set_error("Invalid expression");
5677 }
5678 ptr::null_mut()
5679 }
5680 }
5681}
5682
5683#[no_mangle]
5691pub unsafe extern "C" fn xmlXPathEval(
5692 str_: *const xmlChar,
5693 ctxt: *mut _xmlXPathContext,
5694) -> *mut _xmlXPathObject {
5695 xmlXPathEvalExpression(str_, ctxt)
5696}
5697
5698#[no_mangle]
5709pub unsafe extern "C" fn xmlXPathFreeObject(obj: *mut _xmlXPathObject) {
5710 if obj.is_null() {
5711 return;
5712 }
5713 let typ = (*obj).type_;
5714 if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5716 if !(*obj).stringval.is_null() {
5717 xmlFreeImpl((*obj).stringval as *mut c_void);
5718 (*obj).stringval = ptr::null_mut();
5719 }
5720 }
5721 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5723 let ns = (*obj).nodesetval as *mut _xmlNodeSet;
5724 if !ns.is_null() {
5725 if !(*ns).nodeTab.is_null() {
5726 xmlFreeImpl((*ns).nodeTab as *mut c_void);
5727 }
5728 xmlFreeImpl(ns as *mut c_void);
5729 }
5730 (*obj).nodesetval = ptr::null_mut();
5731 }
5732 xmlFreeImpl(obj as *mut c_void);
5733}
5734
5735#[no_mangle]
5747pub unsafe extern "C" fn xmlXPathObjectCopy(val: *mut _xmlXPathObject) -> *mut _xmlXPathObject {
5748 if val.is_null() {
5749 return ptr::null_mut();
5750 }
5751 let typ = (*val).type_;
5752 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
5753 if obj.is_null() {
5754 return ptr::null_mut();
5755 }
5756 (*obj).type_ = typ;
5757 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5758 let src_ns = (*val).nodesetval as *mut _xmlNodeSet;
5759 if !src_ns.is_null() {
5760 let nr = (*src_ns).nodeNr;
5761 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
5762 if ns.is_null() {
5763 xmlFreeImpl(obj as *mut c_void);
5764 return ptr::null_mut();
5765 }
5766 (*ns).nodeNr = nr;
5767 (*ns).nodeMax = nr;
5768 if nr > 0 && !(*src_ns).nodeTab.is_null() {
5769 let tab = xmlMallocImpl((nr as usize) * core::mem::size_of::<*mut _xmlNode>())
5770 as *mut *mut _xmlNode;
5771 if tab.is_null() {
5772 xmlFreeImpl(ns as *mut c_void);
5773 xmlFreeImpl(obj as *mut c_void);
5774 return ptr::null_mut();
5775 }
5776 ptr::copy_nonoverlapping((*src_ns).nodeTab, tab, nr as usize);
5777 (*ns).nodeTab = tab;
5778 } else {
5779 (*ns).nodeTab = ptr::null_mut();
5780 }
5781 (*obj).nodesetval = ns as *mut c_void;
5782 }
5783 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5784 (*obj).boolval = (*val).boolval;
5785 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5786 (*obj).floatval = (*val).floatval;
5787 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5788 let src = (*val).stringval;
5789 if !src.is_null() {
5790 let len = libc::strlen(src as *const libc::c_char);
5791 let buf = xmlMallocImpl(len + 1) as *mut xmlChar;
5792 if !buf.is_null() {
5793 ptr::copy_nonoverlapping(src, buf, len);
5794 *buf.add(len) = 0;
5795 }
5796 (*obj).stringval = buf;
5797 }
5798 }
5799 obj
5800}
5801
5802#[no_mangle]
5812pub unsafe extern "C" fn xmlXPathCastToString(val: *mut _xmlXPathObject) -> *mut xmlChar {
5813 if val.is_null() {
5814 return ptr::null_mut();
5815 }
5816 let typ = (*val).type_;
5817 let mut result: Vec<u8> = Vec::new();
5818 if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5819 if !(*val).stringval.is_null() {
5820 let len = libc::strlen((*val).stringval as *const libc::c_char);
5821 result.extend_from_slice(core::slice::from_raw_parts((*val).stringval, len));
5822 }
5823 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5824 let n = (*val).floatval;
5830 result.extend_from_slice(xml_number_to_string(n).as_bytes());
5831 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5832 result.extend_from_slice(if (*val).boolval != 0 {
5833 b"true"
5834 } else {
5835 b"false"
5836 });
5837 } else if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5838 let ns = (*val).nodesetval as *mut _xmlNodeSet;
5841 if !ns.is_null() && (*ns).nodeNr > 0 && !(*ns).nodeTab.is_null() {
5842 let node = *(*ns).nodeTab;
5843 if !node.is_null() {
5844 let content = crate::xml::tree::node_get_content(node);
5845 if !content.is_null() {
5846 let len = libc::strlen(content as *const libc::c_char);
5847 result.extend_from_slice(core::slice::from_raw_parts(content, len));
5848 xmlFreeImpl(content as *mut c_void);
5849 }
5850 }
5851 }
5852 }
5853 let buf = xmlMallocImpl(result.len() + 1) as *mut xmlChar;
5855 if buf.is_null() {
5856 return ptr::null_mut();
5857 }
5858 if !result.is_empty() {
5859 ptr::copy_nonoverlapping(result.as_ptr(), buf, result.len());
5860 }
5861 *buf.add(result.len()) = 0;
5862 buf
5863}
5864
5865pub fn xml_number_to_string(n: f64) -> String {
5869 if n.is_nan() {
5870 return "NaN".to_string();
5871 }
5872 if n.is_infinite() {
5873 return if n > 0.0 {
5874 "Infinity".to_string()
5875 } else {
5876 "-Infinity".to_string()
5877 };
5878 }
5879 if n == 0.0 {
5880 return "0".to_string();
5882 }
5883 if n.fract() == 0.0 && n.abs() < 1e15 {
5885 return format!("{:.0}", n);
5886 }
5887 let mut s = format!("{:.15}", n);
5891 if s.contains('.') {
5893 while s.ends_with('0') {
5894 s.pop();
5895 }
5896 if s.ends_with('.') {
5897 s.pop();
5898 }
5899 }
5900 if s == "-0" {
5901 return "0".to_string();
5902 }
5903 s
5904}
5905
5906#[no_mangle]
5914pub unsafe extern "C" fn xmlXPathCastStringToNumber(val: *const xmlChar) -> f64 {
5915 if val.is_null() {
5916 return f64::NAN;
5917 }
5918 let len = libc::strlen(val as *const libc::c_char);
5919 let bytes = core::slice::from_raw_parts(val, len);
5920 let mut i = 0;
5922 while i < bytes.len() && matches!(bytes[i], b' ' | b'\t' | b'\n' | b'\r') {
5923 i += 1;
5924 }
5925 let s = &bytes[i..];
5926 if s.is_empty() {
5927 return f64::NAN;
5928 }
5929 let (sign, rest) = match s[0] {
5931 b'+' => (1.0f64, &s[1..]),
5932 b'-' => (-1.0f64, &s[1..]),
5933 _ => (1.0f64, s),
5934 };
5935 if rest.is_empty() {
5936 return f64::NAN;
5937 }
5938 let num_str = core::str::from_utf8(rest);
5941 match num_str {
5942 Ok(s) => {
5943 let valid = is_xpath_number(s);
5946 if !valid {
5947 f64::NAN
5948 } else {
5949 s.trim()
5950 .parse::<f64>()
5951 .map(|v| v * sign)
5952 .unwrap_or(f64::NAN)
5953 }
5954 }
5955 Err(_) => f64::NAN,
5956 }
5957}
5958
5959fn is_xpath_number(s: &str) -> bool {
5961 let b = s.as_bytes();
5962 if b.is_empty() {
5963 return false;
5964 }
5965 let mut i = 0;
5966 let mut saw_digit = false;
5967 while i < b.len() && b[i].is_ascii_digit() {
5968 saw_digit = true;
5969 i += 1;
5970 }
5971 if i < b.len() && b[i] == b'.' {
5972 i += 1;
5973 while i < b.len() && b[i].is_ascii_digit() {
5974 saw_digit = true;
5975 i += 1;
5976 }
5977 }
5978 if !saw_digit {
5979 return false;
5980 }
5981 if i < b.len() && (b[i] == b'e' || b[i] == b'E') {
5982 i += 1;
5983 if i < b.len() && (b[i] == b'+' || b[i] == b'-') {
5984 i += 1;
5985 }
5986 let mut saw_exp = false;
5987 while i < b.len() && b[i].is_ascii_digit() {
5988 saw_exp = true;
5989 i += 1;
5990 }
5991 if !saw_exp {
5992 return false;
5993 }
5994 }
5995 i == b.len()
5996}
5997
5998#[no_mangle]
6013pub unsafe extern "C" fn xmlXPathCmpNodes(node1: *mut _xmlNode, node2: *mut _xmlNode) -> c_int {
6014 if node1.is_null() || node2.is_null() {
6015 return 0;
6016 }
6017 if node1 == node2 {
6018 return 0;
6019 }
6020 let mut chain1: Vec<*mut _xmlNode> = Vec::new();
6022 let mut chain2: Vec<*mut _xmlNode> = Vec::new();
6023 let mut n = node1;
6024 while !n.is_null() {
6025 chain1.push(n);
6026 n = (*n).parent as *mut _xmlNode;
6027 }
6028 let mut n = node2;
6029 while !n.is_null() {
6030 chain2.push(n);
6031 n = (*n).parent as *mut _xmlNode;
6032 }
6033 let mut i = chain1.len();
6035 let mut j = chain2.len();
6036 while i > 0 && j > 0 && chain1[i - 1] == chain2[j - 1] {
6037 i -= 1;
6038 j -= 1;
6039 }
6040 if i == 0 && j == 0 {
6041 return 0; }
6043 if i == 0 {
6044 return -1; }
6046 if j == 0 {
6047 return 1; }
6049 let mut a = chain1[i - 1];
6051 let mut b = chain2[j - 1];
6052 while !a.is_null() && !b.is_null() {
6054 let pa = (*a).parent as *mut _xmlNode;
6055 let pb = (*b).parent as *mut _xmlNode;
6056 if pa == pb {
6057 break;
6058 }
6059 a = pa;
6060 b = pb;
6061 }
6062 let parent = (*a).parent as *mut _xmlNode;
6064 let mut child = if parent.is_null() {
6065 ptr::null_mut()
6066 } else {
6067 (*parent).children
6068 };
6069 while !child.is_null() {
6070 if child == a {
6071 return -1;
6072 }
6073 if child == b {
6074 return 1;
6075 }
6076 child = (*child).next;
6077 }
6078 0
6079}
6080
6081#[no_mangle]
6091pub unsafe extern "C" fn xmlXPathNodeSetCreate(val: *mut _xmlNode) -> *mut _xmlNodeSet {
6092 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
6093 if ns.is_null() {
6094 return ptr::null_mut();
6095 }
6096 if val.is_null() {
6097 return ns;
6098 }
6099 let tab = xmlMallocImpl(core::mem::size_of::<*mut _xmlNode>()) as *mut *mut _xmlNode;
6100 if tab.is_null() {
6101 xmlFreeImpl(ns as *mut c_void);
6102 return ptr::null_mut();
6103 }
6104 *tab = val;
6105 (*ns).nodeTab = tab;
6106 (*ns).nodeNr = 1;
6107 (*ns).nodeMax = 1;
6108 ns
6109}
6110
6111#[no_mangle]
6123pub unsafe extern "C" fn xmlXPathFreeNodeSet(ns: *mut _xmlNodeSet) {
6124 if ns.is_null() {
6125 return;
6126 }
6127 if !(*ns).nodeTab.is_null() {
6128 xmlFreeImpl((*ns).nodeTab as *mut c_void);
6129 (*ns).nodeTab = ptr::null_mut();
6130 }
6131 (*ns).nodeNr = 0;
6132 (*ns).nodeMax = 0;
6133 xmlFreeImpl(ns as *mut c_void);
6134}
6135
6136#[no_mangle]
6147pub unsafe extern "C" fn xmlXPathCompile(str_: *const xmlChar) -> *mut c_void {
6148 if str_.is_null() {
6149 return ptr::null_mut();
6150 }
6151 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
6152 Ok(s) => s,
6153 Err(_) => return ptr::null_mut(),
6154 };
6155
6156 match crate::xml::xpath::compile(expr_str) {
6157 Some(compiled) => {
6158 let mut map = COMPILED_EXPRS.lock();
6159 let mut counter = NEXT_COMPILED_KEY.lock();
6160 let key = *counter;
6161 *counter += 1;
6162 map.insert(key, Box::new(compiled));
6163 key as *mut c_void
6164 }
6165 None => ptr::null_mut(),
6166 }
6167}
6168
6169#[no_mangle]
6177pub unsafe extern "C" fn xmlXPathFreeCompExpr(comp: *mut c_void) {
6178 if comp.is_null() {
6179 return;
6180 }
6181 let mut map = COMPILED_EXPRS.lock();
6182 map.remove(&(comp as u64));
6183}
6184
6185#[no_mangle]
6194pub unsafe extern "C" fn xmlXPathRegisterNs(
6195 ctxt: *mut _xmlXPathContext,
6196 prefix: *const xmlChar,
6197 ns_uri: *const xmlChar,
6198) -> c_int {
6199 if ctxt.is_null() || prefix.is_null() || ns_uri.is_null() {
6200 return -1;
6201 }
6202 let internal = (*ctxt).extra as *mut XPathContext;
6203 if internal.is_null() {
6204 return -1;
6205 }
6206 let internal = &mut *internal;
6207
6208 let prefix_str = match CStr::from_ptr(prefix as *const c_char).to_str() {
6209 Ok(s) => s,
6210 Err(_) => return -1,
6211 };
6212 let uri_str = match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6213 Ok(s) => s,
6214 Err(_) => return -1,
6215 };
6216
6217 internal.register_namespace(prefix_str, uri_str);
6218
6219 let map: &mut HashMap<String, CString> = if (*ctxt).nsHash.is_null() {
6224 let b: Box<HashMap<String, CString>> = Box::new(HashMap::new());
6225 (*ctxt).nsHash = Box::into_raw(b) as *mut c_void;
6226 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6227 } else {
6228 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6229 };
6230 map.insert(
6231 prefix_str.to_string(),
6232 CString::new(uri_str.as_bytes()).unwrap_or_default(),
6233 );
6234 0
6235}
6236
6237#[no_mangle]
6251pub unsafe extern "C" fn xmlXPathRegisterFunc(
6252 ctxt: *mut _xmlXPathContext,
6253 name: *const xmlChar,
6254 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6255) -> c_int {
6256 if ctxt.is_null() || name.is_null() {
6257 return -1;
6258 }
6259 let internal = (*ctxt).extra as *mut XPathContext;
6260 if internal.is_null() {
6261 return -1;
6262 }
6263 let internal = &mut *internal;
6264
6265 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6266 Ok(s) => s,
6267 Err(_) => return -1,
6268 };
6269
6270 if let Some(func) = f {
6271 let key = (SendSyncPtr((*ctxt).extra), name_str.to_string());
6273 C_FUNCTIONS.lock().insert(key, func);
6274 let c_ctxt = SendSyncPtr(ctxt as *mut c_void);
6277 let name_owned = name_str.to_string();
6278 internal.register_function(name_str, c_func_bridge_closure(c_ctxt, name_owned));
6279 }
6280 0
6281}
6282
6283#[no_mangle]
6293pub unsafe extern "C" fn xmlXPathRegisterFuncNS(
6294 ctxt: *mut _xmlXPathContext,
6295 name: *const xmlChar,
6296 ns_uri: *const xmlChar,
6297 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6298) -> c_int {
6299 if ctxt.is_null() || name.is_null() {
6300 return -1;
6301 }
6302 let internal = (*ctxt).extra as *mut XPathContext;
6303 if internal.is_null() {
6304 return -1;
6305 }
6306 let internal = &mut *internal;
6307
6308 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6309 Ok(s) => s,
6310 Err(_) => return -1,
6311 };
6312 let ns_str = if ns_uri.is_null() {
6313 String::new()
6314 } else {
6315 match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6316 Ok(s) => s.to_string(),
6317 Err(_) => return -1,
6318 }
6319 };
6320
6321 let qualified = if ns_str.is_empty() {
6323 name_str.to_string()
6324 } else {
6325 format!("{{{}}}{}", ns_str, name_str)
6326 };
6327
6328 if let Some(func) = f {
6329 let key = (SendSyncPtr((*ctxt).extra), qualified.clone());
6330 C_FUNCTIONS.lock().insert(key, func);
6331 let c_ctxt = SendSyncPtr(ctxt as *mut c_void);
6332 let qualified_owned = qualified.clone();
6333 internal.register_function(&qualified, c_func_bridge_closure(c_ctxt, qualified_owned));
6334 }
6335 0
6336}
6337
6338#[no_mangle]
6347pub unsafe extern "C" fn xmlXPathRegisterVariable(
6348 ctxt: *mut _xmlXPathContext,
6349 name: *const xmlChar,
6350 value: *mut _xmlXPathObject,
6351) -> c_int {
6352 if ctxt.is_null() || name.is_null() || value.is_null() {
6353 return -1;
6354 }
6355 let internal = (*ctxt).extra as *mut XPathContext;
6356 if internal.is_null() {
6357 return -1;
6358 }
6359 let internal = &mut *internal;
6360
6361 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6362 Ok(s) => s,
6363 Err(_) => return -1,
6364 };
6365
6366 let xpath_val = object_to_xpathvalue(value);
6367 internal.register_variable(name_str, xpath_val);
6368 0
6369}
6370
6371#[no_mangle]
6379pub unsafe extern "C" fn xmlXPathNewNodeSet(val: *mut _xmlNode) -> *mut _xmlXPathObject {
6380 let ns = if val.is_null() {
6381 NodeSet::new()
6382 } else {
6383 NodeSet::singleton(val)
6384 };
6385 xpath_to_object(XPathValue::NodeSet(ns))
6386}
6387
6388#[no_mangle]
6396pub unsafe extern "C" fn xmlXPathNewCString(val: *const xmlChar) -> *mut _xmlXPathObject {
6397 if val.is_null() {
6398 return xpath_to_object(XPathValue::String(String::new()));
6399 }
6400 let s = match CStr::from_ptr(val as *const c_char).to_str() {
6401 Ok(s) => s.to_string(),
6402 Err(_) => return ptr::null_mut(),
6403 };
6404 xpath_to_object(XPathValue::String(s))
6405}
6406
6407#[no_mangle]
6415pub extern "C" fn xmlXPathNewFloat(val: f64) -> *mut _xmlXPathObject {
6416 unsafe { xpath_to_object(XPathValue::Number(val)) }
6417}
6418
6419#[no_mangle]
6427pub extern "C" fn xmlXPathNewBoolean(val: c_int) -> *mut _xmlXPathObject {
6428 unsafe { xpath_to_object(XPathValue::Boolean(val != 0)) }
6429}
6430
6431#[no_mangle]
6445pub unsafe extern "C" fn xmlXPtrEval(expr: *const c_char, doc: *mut _xmlDoc) -> *mut _xmlNode {
6446 crate::xml::xpointer::xmlXPtrEval(expr, doc)
6447}
6448
6449#[no_mangle]
6461pub unsafe extern "C" fn xmlXIncludeProcess(doc: *mut _xmlDoc) -> c_int {
6462 crate::xml::xinclude::xinclude_process(doc)
6463}
6464
6465#[no_mangle]
6473pub unsafe extern "C" fn xmlXIncludeProcessFlags(doc: *mut _xmlDoc, flags: c_int) -> c_int {
6474 crate::xml::xinclude::xinclude_process_flags(doc, flags)
6475}
6476
6477#[no_mangle]
6489pub extern "C" fn xmlCatalogLoad(catalogs: *const c_char) -> *mut c_void {
6490 if catalogs.is_null() {
6491 return ptr::null_mut();
6492 }
6493 crate::xml::catalog::load_catalog(catalogs)
6494}
6495
6496#[no_mangle]
6504pub unsafe extern "C" fn xmlCatalogResolvePublic(pubID: *const xmlChar) -> *mut xmlChar {
6505 if pubID.is_null() {
6506 return ptr::null_mut();
6507 }
6508 crate::xml::catalog::resolve_public(pubID)
6509}
6510
6511#[no_mangle]
6519pub unsafe extern "C" fn xmlCatalogResolveSystem(sysID: *const xmlChar) -> *mut xmlChar {
6520 if sysID.is_null() {
6521 return ptr::null_mut();
6522 }
6523 crate::xml::catalog::resolve_system(sysID)
6524}
6525
6526#[no_mangle]
6534pub unsafe extern "C" fn xmlCatalogResolveURI(URI: *const xmlChar) -> *mut xmlChar {
6535 if URI.is_null() {
6536 return ptr::null_mut();
6537 }
6538 crate::xml::catalog::resolve_uri(URI)
6539}
6540
6541#[no_mangle]
6549pub extern "C" fn xmlCatalogSetDefaults(allow: c_int) {
6550 crate::xml::catalog::set_defaults(allow)
6551}
6552
6553#[no_mangle]
6561pub extern "C" fn xmlCatalogGetDefaults() -> c_int {
6562 crate::xml::catalog::get_defaults()
6563}
6564
6565#[no_mangle]
6573pub unsafe extern "C" fn xmlCatalogAdd(
6574 type_: *const xmlChar,
6575 orig: *const xmlChar,
6576 replace: *const xmlChar,
6577) -> c_int {
6578 if type_.is_null() || orig.is_null() || replace.is_null() {
6579 return -1;
6580 }
6581 crate::xml::catalog::add(type_, orig, replace)
6582}
6583
6584#[no_mangle]
6592pub unsafe extern "C" fn xmlCatalogRemove(value: *const xmlChar) -> c_int {
6593 if value.is_null() {
6594 return 0;
6595 }
6596 crate::xml::catalog::remove(value)
6597}
6598
6599#[no_mangle]
6607pub unsafe extern "C" fn xmlCatalogDump(output: *mut c_void, _catal: *mut c_void) {
6608 if output.is_null() {
6609 return;
6610 }
6611 let doc = crate::xml::catalog::dump_doc();
6612 if doc.is_null() {
6613 return;
6614 }
6615 let mut mem: *mut xmlChar = ptr::null_mut();
6616 let mut size: c_int = 0;
6617 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6618 if !mem.is_null() {
6619 libc::fwrite(
6620 mem as *const c_void,
6621 1,
6622 size as usize,
6623 output as *mut libc::FILE,
6624 );
6625 xmlFreeImpl(mem as *mut c_void);
6626 }
6627 crate::xml::tree::free_doc(doc);
6628}
6629
6630#[no_mangle]
6640pub unsafe extern "C" fn xmlCatalogSave(filename: *const c_char) -> c_int {
6641 if filename.is_null() {
6642 return -1;
6643 }
6644 let doc = crate::xml::catalog::dump_doc();
6645 if doc.is_null() {
6646 return -1;
6647 }
6648 let mut mem: *mut xmlChar = ptr::null_mut();
6649 let mut size: c_int = 0;
6650 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6651 let mut ret: c_int = -1;
6652 if !mem.is_null() {
6653 let fp = libc::fopen(filename, b"w\0".as_ptr() as *const c_char);
6654 if !fp.is_null() {
6655 let written = libc::fwrite(mem as *const c_void, 1, size as usize, fp);
6656 ret = if written == size as usize { 0 } else { -1 };
6657 libc::fclose(fp);
6658 }
6659 xmlFreeImpl(mem as *mut c_void);
6660 }
6661 crate::xml::tree::free_doc(doc);
6662 ret
6663}
6664
6665#[no_mangle]
6673pub extern "C" fn xmlCatalogCleanup() {
6674 crate::xml::catalog::cleanup();
6675}
6676
6677#[no_mangle]
6685pub extern "C" fn xmlCatalogConvert() -> *mut _xmlDoc {
6686 unsafe { crate::xml::catalog::convert() }
6688}
6689
6690#[no_mangle]
6702pub unsafe extern "C" fn htmlParseFile(
6703 _filename: *const c_char,
6704 _encoding: *const c_char,
6705) -> *mut _xmlDoc {
6706 ptr::null_mut()
6708}
6709
6710#[no_mangle]
6718pub unsafe extern "C" fn htmlParseMemory(_buffer: *const c_char, _size: c_int) -> *mut _xmlDoc {
6719 ptr::null_mut()
6721}
6722
6723#[no_mangle]
6731pub unsafe extern "C" fn htmlParseDoc(
6732 _cur: *const xmlChar,
6733 _encoding: *const c_char,
6734) -> *mut _xmlDoc {
6735 ptr::null_mut()
6737}
6738
6739#[no_mangle]
6748pub unsafe extern "C" fn htmlCreateFileParserCtxt(
6749 _filename: *const c_char,
6750 _encoding: *const c_char,
6751) -> *mut c_void {
6752 ptr::null_mut()
6754}
6755
6756#[no_mangle]
6764pub extern "C" fn htmlFreeParserCtxt(ctxt: *mut c_void) {
6765 unsafe { crate::xml::html::free_parser_ctxt(ctxt) }
6766}
6767
6768#[no_mangle]
6776pub extern "C" fn htmlInitParser() {
6777 }
6779
6780#[no_mangle]
6788pub extern "C" fn htmlCleanupParser() {
6789 }
6791
6792#[no_mangle]
6804pub unsafe extern "C" fn xmlNewValidCtxt() -> *mut _xmlValidCtxt {
6805 crate::xml::validation::new_valid_ctxt()
6806}
6807
6808#[no_mangle]
6816pub unsafe extern "C" fn xmlFreeValidCtxt(ctxt: *mut _xmlValidCtxt) {
6817 crate::xml::validation::free_valid_ctxt(ctxt);
6818}
6819
6820#[no_mangle]
6831pub unsafe extern "C" fn xmlSetValidErrors(
6832 ctxt: *mut _xmlValidCtxt,
6833 err: Option<xmlGenericErrorFunc>,
6834 warn: Option<xmlGenericErrorFunc>,
6835 data: *mut c_void,
6836) {
6837 crate::xml::validation::set_valid_errors(ctxt, err, warn, data);
6838}
6839
6840#[no_mangle]
6848pub unsafe extern "C" fn xmlValidateDocument(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
6849 crate::xml::validation::validate_document(ctxt, doc)
6850}
6851
6852#[no_mangle]
6860pub unsafe extern "C" fn xmlValidateDocumentFinal(
6861 ctxt: *mut _xmlValidCtxt,
6862 doc: *mut _xmlDoc,
6863) -> c_int {
6864 crate::xml::validation::validate_document_final(ctxt, doc)
6865}
6866
6867#[no_mangle]
6877pub unsafe extern "C" fn xmlValidateElement(
6878 ctxt: *mut _xmlValidCtxt,
6879 doc: *mut _xmlDoc,
6880 elem: *mut _xmlNode,
6881) -> c_int {
6882 crate::xml::validation::validate_element(ctxt, doc, elem)
6883}
6884
6885#[no_mangle]
6896pub unsafe extern "C" fn xmlValidateAttributeDecl(
6897 ctxt: *mut _xmlValidCtxt,
6898 doc: *mut _xmlDoc,
6899 elem: *mut _xmlNode,
6900 attr: *mut _xmlAttribute,
6901) -> c_int {
6902 crate::xml::validation::validate_attribute_decl(ctxt, doc, elem, attr)
6903}
6904
6905#[no_mangle]
6913pub unsafe extern "C" fn xmlValidateAttributeValue(atype: c_int, value: *const xmlChar) -> c_int {
6914 crate::xml::validation::validate_attribute_value(atype, value)
6915}
6916
6917#[no_mangle]
6927pub unsafe extern "C" fn xmlValidateNotationUse(
6928 ctxt: *mut _xmlValidCtxt,
6929 doc: *mut _xmlDoc,
6930 notation_name: *const xmlChar,
6931) -> c_int {
6932 crate::xml::validation::validate_notation_use(ctxt, doc, notation_name)
6933}
6934
6935#[no_mangle]
6946pub unsafe extern "C" fn xmlValidateID(
6947 ctxt: *mut _xmlValidCtxt,
6948 doc: *mut _xmlDoc,
6949 node: *mut _xmlNode,
6950 value: *const xmlChar,
6951) -> c_int {
6952 crate::xml::validation::validate_id(ctxt, doc, node, value)
6953}
6954
6955#[no_mangle]
6966pub unsafe extern "C" fn xmlValidateIDRef(
6967 ctxt: *mut _xmlValidCtxt,
6968 doc: *mut _xmlDoc,
6969 node: *mut _xmlNode,
6970 value: *const xmlChar,
6971) -> c_int {
6972 crate::xml::validation::validate_id_ref(ctxt, doc, node, value)
6973}
6974
6975#[no_mangle]
6986pub unsafe extern "C" fn xmlValidateIDRefs(
6987 ctxt: *mut _xmlValidCtxt,
6988 doc: *mut _xmlDoc,
6989 node: *mut _xmlNode,
6990 value: *const xmlChar,
6991) -> c_int {
6992 crate::xml::validation::validate_id_refs(ctxt, doc, node, value)
6993}
6994
6995#[no_mangle]
7005pub unsafe extern "C" fn xmlValidateNCName(value: *const xmlChar, space: c_int) -> c_int {
7006 crate::xml::validation::validate_ncname(value, space)
7007}
7008
7009#[no_mangle]
7017pub unsafe extern "C" fn xmlValidateQName(value: *const xmlChar, space: c_int) -> c_int {
7018 crate::xml::validation::validate_qname(value, space)
7019}
7020
7021#[no_mangle]
7034pub unsafe extern "C" fn xmlValidateName(value: *const xmlChar, space: c_int) -> c_int {
7035 crate::xml::validation::validate_name_space(value, space)
7036}
7037
7038#[no_mangle]
7046pub unsafe extern "C" fn xmlValidateNMToken(value: *const xmlChar, space: c_int) -> c_int {
7047 crate::xml::validation::validate_nmtoken_space(value, space)
7048}
7049
7050#[no_mangle]
7060pub unsafe extern "C" fn xmlValidateNameValue(value: *const xmlChar) -> c_int {
7061 crate::xml::validation::validate_name_value(value)
7062}
7063
7064#[no_mangle]
7073pub unsafe extern "C" fn xmlValidateNamesValue(value: *const xmlChar) -> c_int {
7074 crate::xml::validation::validate_names_value(value)
7075}
7076
7077#[no_mangle]
7085pub unsafe extern "C" fn xmlValidateNmtokenValue(value: *const xmlChar) -> c_int {
7086 crate::xml::validation::validate_nmtoken_value(value)
7087}
7088
7089#[no_mangle]
7097pub unsafe extern "C" fn xmlValidateNmtokensValue(value: *const xmlChar) -> c_int {
7098 crate::xml::validation::validate_nmtokens_value(value)
7099}
7100
7101#[no_mangle]
7112pub unsafe extern "C" fn xmlValidateElementDecl(
7113 ctxt: *mut _xmlValidCtxt,
7114 doc: *mut _xmlDoc,
7115 elem: *mut _xmlElement,
7116) -> c_int {
7117 crate::xml::validation::validate_element_decl(ctxt, doc, elem)
7118}
7119
7120#[no_mangle]
7133pub unsafe extern "C" fn xmlValidateNotationDecl(
7134 ctxt: *mut _xmlValidCtxt,
7135 doc: *mut _xmlDoc,
7136 nota: *mut _xmlNotation,
7137) -> c_int {
7138 crate::xml::validation::validate_notation_decl(ctxt, doc, nota)
7139}
7140
7141#[no_mangle]
7153pub unsafe extern "C" fn xmlValidateOneAttribute(
7154 ctxt: *mut _xmlValidCtxt,
7155 doc: *mut _xmlDoc,
7156 elem: *mut _xmlNode,
7157 attr: *mut _xmlAttr,
7158 value: *const xmlChar,
7159) -> c_int {
7160 crate::xml::validation::validate_one_attribute(ctxt, doc, elem, attr, value)
7161}
7162
7163#[no_mangle]
7173pub unsafe extern "C" fn xmlValidateOneElement(
7174 ctxt: *mut _xmlValidCtxt,
7175 doc: *mut _xmlDoc,
7176 elem: *mut _xmlNode,
7177) -> c_int {
7178 crate::xml::validation::validate_one_element(ctxt, doc, elem)
7179}
7180
7181#[no_mangle]
7194pub unsafe extern "C" fn xmlValidateOneNamespace(
7195 ctxt: *mut _xmlValidCtxt,
7196 doc: *mut _xmlDoc,
7197 elem: *mut _xmlNode,
7198 prefix: *const xmlChar,
7199 ns: *mut _xmlNs,
7200 value: *const xmlChar,
7201) -> c_int {
7202 crate::xml::validation::validate_one_namespace(ctxt, doc, elem, prefix, ns, value)
7203}
7204
7205#[no_mangle]
7217pub unsafe extern "C" fn xmlValidatePushElement(
7218 ctxt: *mut _xmlValidCtxt,
7219 doc: *mut _xmlDoc,
7220 elem: *mut _xmlNode,
7221 qname: *const xmlChar,
7222) -> c_int {
7223 crate::xml::validation::validate_push_element(ctxt, doc, elem, qname)
7224}
7225
7226#[no_mangle]
7236pub unsafe extern "C" fn xmlValidatePushCData(
7237 ctxt: *mut _xmlValidCtxt,
7238 data: *const xmlChar,
7239 len: c_int,
7240) -> c_int {
7241 crate::xml::validation::validate_push_cdata(ctxt, data, len)
7242}
7243
7244#[no_mangle]
7255pub unsafe extern "C" fn xmlValidatePopElement(
7256 ctxt: *mut _xmlValidCtxt,
7257 doc: *mut _xmlDoc,
7258 elem: *mut _xmlNode,
7259 qname: *const xmlChar,
7260) -> c_int {
7261 crate::xml::validation::validate_pop_element(ctxt, doc, elem, qname)
7262}
7263
7264#[no_mangle]
7273pub unsafe extern "C" fn xmlValidBuildContentModel(
7274 ctxt: *mut _xmlValidCtxt,
7275 elem: *mut _xmlElement,
7276) -> c_int {
7277 crate::xml::validation::validate_build_content_model(ctxt, elem)
7278}
7279
7280#[no_mangle]
7291pub unsafe extern "C" fn xmlAddID(
7292 ctxt: *mut _xmlValidCtxt,
7293 doc: *mut _xmlDoc,
7294 value: *const xmlChar,
7295 attr: *mut _xmlAttr,
7296) -> *mut _xmlID {
7297 crate::xml::validation::add_id(ctxt, doc, value, attr)
7298}
7299
7300#[no_mangle]
7308pub unsafe extern "C" fn xmlRemoveID(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7309 crate::xml::validation::remove_id(doc, attr)
7310}
7311
7312#[no_mangle]
7323pub unsafe extern "C" fn xmlAddRef(
7324 ctxt: *mut _xmlValidCtxt,
7325 doc: *mut _xmlDoc,
7326 value: *const xmlChar,
7327 attr: *mut _xmlAttr,
7328) -> *mut _xmlRef {
7329 crate::xml::validation::add_ref(ctxt, doc, value, attr)
7330}
7331
7332#[no_mangle]
7340pub unsafe extern "C" fn xmlRemoveRef(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7341 crate::xml::validation::remove_ref(doc, attr)
7342}
7343
7344#[no_mangle]
7352pub unsafe extern "C" fn xmlAddIDSafe(attr: *mut _xmlAttr, value: *const xmlChar) -> c_int {
7353 crate::xml::validation::add_id_safe(attr, value)
7354}
7355
7356#[no_mangle]
7364pub unsafe extern "C" fn xmlFreeIDTable(table: *mut c_void) {
7365 crate::xml::validation::free_id_table(table as *mut crate::xml::hash::HashTable);
7366}
7367
7368#[no_mangle]
7376pub unsafe extern "C" fn xmlFreeRefTable(table: *mut c_void) {
7377 crate::xml::validation::free_ref_table(table as *mut crate::xml::hash::HashTable);
7378}
7379
7380#[no_mangle]
7388pub unsafe extern "C" fn xmlGetID(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut _xmlAttr {
7389 crate::xml::validation::get_id(doc, id)
7390}
7391
7392#[no_mangle]
7400pub unsafe extern "C" fn xmlGetRefs(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut c_void {
7401 crate::xml::validation::get_refs(doc, id) as *mut c_void
7402}
7403
7404#[no_mangle]
7412pub unsafe extern "C" fn xmlIsID(
7413 doc: *mut _xmlDoc,
7414 elem: *mut _xmlNode,
7415 attr: *mut _xmlAttr,
7416) -> c_int {
7417 crate::xml::validation::is_id(doc, elem, attr)
7418}
7419
7420#[no_mangle]
7428pub unsafe extern "C" fn xmlIsRef(
7429 doc: *mut _xmlDoc,
7430 elem: *mut _xmlNode,
7431 attr: *mut _xmlAttr,
7432) -> c_int {
7433 crate::xml::validation::is_ref(doc, elem, attr)
7434}
7435
7436#[no_mangle]
7444pub unsafe extern "C" fn xmlGetDtdElementDesc(
7445 dtd: *mut _xmlDtd,
7446 name: *const xmlChar,
7447) -> *mut _xmlElement {
7448 crate::xml::validation::get_dtd_element_desc(dtd, name)
7449}
7450
7451#[no_mangle]
7461pub unsafe extern "C" fn xmlGetDtdAttrDesc(
7462 dtd: *mut _xmlDtd,
7463 elem: *const xmlChar,
7464 name: *const xmlChar,
7465) -> *mut _xmlAttribute {
7466 crate::xml::validation::get_dtd_attr_desc(dtd, elem, name)
7467}
7468
7469#[no_mangle]
7479pub unsafe extern "C" fn xmlGetDtdQElementDesc(
7480 dtd: *mut _xmlDtd,
7481 name: *const xmlChar,
7482 prefix: *const xmlChar,
7483) -> *mut _xmlElement {
7484 crate::xml::validation::get_dtd_qelement_desc(dtd, name, prefix)
7485}
7486
7487#[no_mangle]
7498pub unsafe extern "C" fn xmlGetDtdQAttrDesc(
7499 dtd: *mut _xmlDtd,
7500 elem: *const xmlChar,
7501 name: *const xmlChar,
7502 prefix: *const xmlChar,
7503) -> *mut _xmlAttribute {
7504 crate::xml::validation::get_dtd_qattr_desc(dtd, elem, name, prefix)
7505}
7506
7507#[no_mangle]
7515pub unsafe extern "C" fn xmlGetDtdNotationDesc(
7516 dtd: *mut _xmlDtd,
7517 name: *const xmlChar,
7518) -> *mut _xmlNotation {
7519 crate::xml::validation::get_dtd_notation_desc(dtd, name)
7520}
7521
7522#[no_mangle]
7530pub unsafe extern "C" fn xmlValidateRoot(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7531 crate::xml::validation::validate_root(ctxt, doc)
7532}
7533
7534#[no_mangle]
7544pub unsafe extern "C" fn xmlValidateContent(
7545 ctxt: *mut _xmlValidCtxt,
7546 node: *mut _xmlNode,
7547 doc: *mut _xmlDoc,
7548) -> c_int {
7549 crate::xml::validation::validate_content(ctxt, node, doc)
7550}
7551
7552#[no_mangle]
7560pub unsafe extern "C" fn xmlIsMixedElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7561 crate::xml::validation::is_mixed_element(doc, name)
7562}
7563
7564#[no_mangle]
7572pub unsafe extern "C" fn xmlIsEmptyElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7573 crate::xml::validation::is_empty_element(doc, name)
7574}
7575
7576#[no_mangle]
7586pub unsafe extern "C" fn xmlValidateDtd(
7587 ctxt: *mut _xmlValidCtxt,
7588 doc: *mut _xmlDoc,
7589 dtd: *mut _xmlDtd,
7590) -> c_int {
7591 crate::xml::validation::validate_dtd(ctxt, doc, dtd)
7592}
7593
7594#[no_mangle]
7602pub unsafe extern "C" fn xmlValidateDtdFinal(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7603 crate::xml::validation::validate_dtd_final(ctxt, doc)
7604}
7605
7606#[no_mangle]
7616pub unsafe extern "C" fn xmlValidateEnumeration(
7617 ctxt: *mut _xmlValidCtxt,
7618 value: *const xmlChar,
7619 tree: *mut _xmlEnumeration,
7620) -> c_int {
7621 crate::xml::validation::validate_enumeration(ctxt, value, tree)
7622}
7623
7624#[no_mangle]
7638pub extern "C" fn xmlGetBinaryPath() -> *mut c_char {
7639 ptr::null_mut()
7641}
7642
7643#[no_mangle]
7651pub extern "C" fn xmlGetHomeOfBinary() -> *mut c_char {
7652 ptr::null_mut()
7654}
7655
7656#[no_mangle]
7667pub unsafe extern "C" fn xmlSAX2StartDocument(ctx: *mut c_void) {
7668 crate::xml::sax::default::default_sax_handler::startDocument(ctx)
7669}
7670
7671#[no_mangle]
7673pub unsafe extern "C" fn xmlSAX2EndDocument(ctx: *mut c_void) {
7674 crate::xml::sax::default::default_sax_handler::endDocument(ctx)
7675}
7676
7677#[no_mangle]
7679pub unsafe extern "C" fn xmlSAX2StartElementNs(
7680 ctx: *mut c_void,
7681 localname: *const xmlChar,
7682 prefix: *const xmlChar,
7683 URI: *const xmlChar,
7684 nb_namespaces: c_int,
7685 namespaces: *mut *const xmlChar,
7686 nb_attributes: c_int,
7687 nb_defaulted: c_int,
7688 attributes: *mut *const xmlChar,
7689) {
7690 crate::xml::sax::default::default_sax_handler::startElementNs(
7691 ctx,
7692 localname,
7693 prefix,
7694 URI,
7695 nb_namespaces,
7696 namespaces,
7697 nb_attributes,
7698 nb_defaulted,
7699 attributes,
7700 )
7701}
7702
7703#[no_mangle]
7705pub unsafe extern "C" fn xmlSAX2EndElementNs(
7706 ctx: *mut c_void,
7707 localname: *const xmlChar,
7708 prefix: *const xmlChar,
7709 URI: *const xmlChar,
7710) {
7711 crate::xml::sax::default::default_sax_handler::endElementNs(ctx, localname, prefix, URI)
7712}
7713
7714#[no_mangle]
7716pub unsafe extern "C" fn xmlSAX2Characters(ctx: *mut c_void, ch: *const xmlChar, len: c_int) {
7717 crate::xml::sax::default::default_sax_handler::characters(ctx, ch, len)
7718}
7719
7720#[no_mangle]
7722pub unsafe extern "C" fn xmlSAX2IgnorableWhitespace(
7723 ctx: *mut c_void,
7724 ch: *const xmlChar,
7725 len: c_int,
7726) {
7727 crate::xml::sax::default::default_sax_handler::ignorableWhitespace(ctx, ch, len)
7728}
7729
7730#[no_mangle]
7732pub unsafe extern "C" fn xmlSAX2Comment(ctx: *mut c_void, value: *const xmlChar) {
7733 crate::xml::sax::default::default_sax_handler::comment(ctx, value)
7734}
7735
7736#[no_mangle]
7738pub unsafe extern "C" fn xmlSAX2ProcessingInstruction(
7739 ctx: *mut c_void,
7740 target: *const xmlChar,
7741 data: *const xmlChar,
7742) {
7743 crate::xml::sax::default::default_sax_handler::processingInstruction(ctx, target, data)
7744}
7745
7746#[no_mangle]
7748pub unsafe extern "C" fn xmlSAX2CDataBlock(ctx: *mut c_void, value: *const xmlChar, len: c_int) {
7749 crate::xml::sax::default::default_sax_handler::cdataBlock(ctx, value, len)
7750}
7751
7752#[no_mangle]
7754pub unsafe extern "C" fn xmlSAX2InternalSubset(
7755 ctx: *mut c_void,
7756 name: *const xmlChar,
7757 ExternalID: *const xmlChar,
7758 SystemID: *const xmlChar,
7759) {
7760 crate::xml::sax::default::default_sax_handler::internalSubset(ctx, name, ExternalID, SystemID)
7761}
7762
7763#[no_mangle]
7765pub unsafe extern "C" fn xmlSAX2ExternalSubset(
7766 ctx: *mut c_void,
7767 name: *const xmlChar,
7768 ExternalID: *const xmlChar,
7769 SystemID: *const xmlChar,
7770) {
7771 crate::xml::sax::default::default_sax_handler::externalSubset(ctx, name, ExternalID, SystemID)
7772}
7773
7774#[no_mangle]
7776pub unsafe extern "C" fn xmlSAX2EntityDecl(
7777 ctx: *mut c_void,
7778 name: *const xmlChar,
7779 type_: c_int,
7780 publicId: *const xmlChar,
7781 systemId: *const xmlChar,
7782 content: *mut xmlChar,
7783) {
7784 crate::xml::sax::default::default_sax_handler::entityDecl(
7785 ctx, name, type_, publicId, systemId, content,
7786 )
7787}
7788
7789#[no_mangle]
7791pub unsafe extern "C" fn xmlSAX2AttributeDecl(
7792 ctx: *mut c_void,
7793 elem: *const xmlChar,
7794 fullname: *const xmlChar,
7795 type_: c_int,
7796 def: c_int,
7797 defaultValue: *const xmlChar,
7798 tree: *mut crate::abi::structs::_xmlEnumeration,
7799) {
7800 crate::xml::sax::default::default_sax_handler::attributeDecl(
7801 ctx,
7802 elem,
7803 fullname,
7804 type_,
7805 def,
7806 defaultValue,
7807 tree,
7808 )
7809}
7810
7811#[no_mangle]
7813pub unsafe extern "C" fn xmlSAX2ElementDecl(
7814 ctx: *mut c_void,
7815 name: *const xmlChar,
7816 type_: c_int,
7817 content: *mut crate::abi::structs::_xmlElementContent,
7818) {
7819 crate::xml::sax::default::default_sax_handler::elementDecl(ctx, name, type_, content)
7820}
7821
7822#[no_mangle]
7824pub unsafe extern "C" fn xmlSAX2NotationDecl(
7825 ctx: *mut c_void,
7826 name: *const xmlChar,
7827 publicId: *const xmlChar,
7828 systemId: *const xmlChar,
7829) {
7830 crate::xml::sax::default::default_sax_handler::notationDecl(ctx, name, publicId, systemId)
7831}
7832
7833#[no_mangle]
7835pub unsafe extern "C" fn xmlSAX2UnparsedEntityDecl(
7836 ctx: *mut c_void,
7837 name: *const xmlChar,
7838 publicId: *const xmlChar,
7839 systemId: *const xmlChar,
7840 notationName: *const xmlChar,
7841) {
7842 crate::xml::sax::default::default_sax_handler::unparsedEntityDecl(
7843 ctx,
7844 name,
7845 publicId,
7846 systemId,
7847 notationName,
7848 )
7849}
7850
7851#[no_mangle]
7853pub unsafe extern "C" fn xmlSAX2ResolveEntity(
7854 ctx: *mut c_void,
7855 publicId: *const xmlChar,
7856 systemId: *const xmlChar,
7857) -> *mut crate::abi::structs::_xmlParserInput {
7858 crate::xml::sax::default::default_sax_handler::resolveEntity(ctx, publicId, systemId)
7859}
7860
7861#[no_mangle]
7863pub unsafe extern "C" fn xmlSAX2IsStandalone(ctx: *mut c_void) -> c_int {
7864 crate::xml::sax::default::default_sax_handler::isStandalone(ctx)
7865}
7866
7867#[no_mangle]
7869pub unsafe extern "C" fn xmlSAX2HasInternalSubset(ctx: *mut c_void) -> c_int {
7870 crate::xml::sax::default::default_sax_handler::hasInternalSubset(ctx)
7871}
7872
7873#[no_mangle]
7875pub unsafe extern "C" fn xmlSAX2HasExternalSubset(ctx: *mut c_void) -> c_int {
7876 crate::xml::sax::default::default_sax_handler::hasExternalSubset(ctx)
7877}
7878
7879#[no_mangle]
7881pub unsafe extern "C" fn xmlSAX2GetEntity(
7882 ctx: *mut c_void,
7883 name: *const xmlChar,
7884) -> *mut crate::abi::structs::_xmlEntity {
7885 crate::xml::sax::default::default_sax_handler::getEntity(ctx, name)
7886}
7887
7888#[no_mangle]
7890pub unsafe extern "C" fn xmlSAX2GetParameterEntity(
7891 ctx: *mut c_void,
7892 name: *const xmlChar,
7893) -> *mut crate::abi::structs::_xmlEntity {
7894 crate::xml::sax::default::default_sax_handler::getParameterEntity(ctx, name)
7895}
7896
7897#[no_mangle]
7900pub unsafe extern "C" fn xmlSAX2GetLineNumber(ctx: *mut c_void) -> c_int {
7901 crate::xml::sax::default::default_sax_handler::getLineNumber(ctx)
7902}
7903
7904#[no_mangle]
7906pub unsafe extern "C" fn xmlSAX2GetColumnNumber(ctx: *mut c_void) -> c_int {
7907 crate::xml::sax::default::default_sax_handler::getColumnNumber(ctx)
7908}
7909
7910#[no_mangle]
7912pub unsafe extern "C" fn xmlSAX2GetPublicId(ctx: *mut c_void) -> *const xmlChar {
7913 crate::xml::sax::default::default_sax_handler::getPublicId(ctx)
7914}
7915
7916#[no_mangle]
7918pub unsafe extern "C" fn xmlSAX2GetSystemId(ctx: *mut c_void) -> *const xmlChar {
7919 crate::xml::sax::default::default_sax_handler::getSystemId(ctx)
7920}
7921
7922#[no_mangle]
7926pub unsafe extern "C" fn xmlSAX2StartElement(
7927 ctx: *mut c_void,
7928 name: *const xmlChar,
7929 atts: *mut *const xmlChar,
7930) {
7931 crate::xml::sax::dispatch::SaxDispatcher::sax1_start_element(ctx, name, atts);
7935}
7936
7937#[no_mangle]
7939pub unsafe extern "C" fn xmlSAX2EndElement(ctx: *mut c_void, name: *const xmlChar) {
7940 crate::xml::sax::dispatch::SaxDispatcher::sax1_end_element(ctx, name);
7941}
7942
7943#[no_mangle]
7945pub unsafe extern "C" fn xmlSAX2SetDocumentLocator(
7946 ctx: *mut c_void,
7947 loc: *mut crate::abi::callbacks::_xmlSAXLocator,
7948) {
7949 crate::xml::sax::default::default_sax_handler::setDocumentLocator(ctx, loc)
7950}
7951
7952#[no_mangle]
7954pub unsafe extern "C" fn xmlSAX2Reference(ctx: *mut c_void, name: *const xmlChar) {
7955 crate::xml::sax::default::default_sax_handler::reference(ctx, name)
7956}