1#![allow(non_snake_case)]
37#![allow(unused_variables)]
38#![allow(clippy::missing_safety_doc)]
39#![allow(clippy::not_unsafe_ptr_arg_deref)]
40
41use core::ffi::c_void;
42use core::ptr;
43use once_cell::sync::Lazy;
44use parking_lot::Mutex;
45use std::collections::HashMap;
46use std::ffi::{CStr, CString};
47use std::mem::size_of;
48use std::os::raw::{c_char, c_int, c_uint, c_ulong};
49
50use crate::xml::xinclude;
51use crate::xml::xpath::ast::CompiledExpr;
52use crate::xml::xpath::context::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 { xmlMalloc(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 { xmlMalloc(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 { xmlRealloc(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 { xmlRealloc(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::xmlMalloc(cap) as *mut xmlChar;
2332 if out.is_null() {
2333 return ptr::null_mut();
2334 }
2335 let mut o = 0usize;
2336 let mut i = 0usize;
2337 while i < len {
2338 let c = *input.add(i);
2339 let rep: &[u8] = match c {
2340 b'<' => b"<",
2341 b'>' => b">",
2342 b'&' => b"&",
2343 b'"' => b""",
2344 b'\r' => b" ",
2345 _ => {
2346 *out.add(o) = c;
2347 o += 1;
2348 i += 1;
2349 continue;
2350 }
2351 };
2352 core::ptr::copy_nonoverlapping(rep.as_ptr(), out.add(o), rep.len());
2353 o += rep.len();
2354 i += 1;
2355 }
2356 *out.add(o) = 0;
2357 out
2358 }
2359}
2360
2361#[no_mangle]
2372pub unsafe extern "C" fn xmlEncodeEntities(
2373 _doc: *mut _xmlDoc,
2374 _input: *const xmlChar,
2375) -> *mut xmlChar {
2376 use core::sync::atomic::{AtomicBool, Ordering};
2377 static WARNED: AtomicBool = AtomicBool::new(false);
2378 if !WARNED.swap(true, Ordering::Relaxed) {
2379 let msg = b"xmlEncodeEntities is deprecated, use xmlEncodeSpecialChars or xmlEncodeEntitiesReentrant\n";
2381 unsafe {
2382 libc::fwrite(
2383 msg.as_ptr() as *const c_void,
2384 1,
2385 msg.len(),
2386 libc::fdopen(2, b"w\0" as *const u8 as *const c_char) as *mut libc::FILE,
2387 );
2388 }
2389 }
2390 ptr::null_mut()
2391}
2392
2393#[no_mangle]
2401pub extern "C" fn xmlGetLineNo(node: *const _xmlNode) -> c_int {
2402 crate::xml::tree::get_line_no(node)
2403}
2404
2405#[no_mangle]
2417pub unsafe extern "C" fn xmlNodeDump(
2418 buf: *mut _xmlBuffer,
2419 doc: *mut _xmlDoc,
2420 cur: *mut _xmlNode,
2421 level: c_int,
2422 format: c_int,
2423) -> c_int {
2424 if buf.is_null() || cur.is_null() {
2425 return -1;
2426 }
2427 crate::xml::tree::xmlNodeDump(buf, doc, cur, level, format)
2428}
2429
2430#[no_mangle]
2438pub unsafe extern "C" fn xmlDocDump(fp: *mut c_void, doc: *mut _xmlDoc) -> c_int {
2439 if fp.is_null() || doc.is_null() {
2440 return -1;
2441 }
2442 crate::xml::tree::xmlDocDump(fp, doc)
2443}
2444
2445#[no_mangle]
2453pub unsafe extern "C" fn xmlDocDumpFormatMemory(
2454 doc: *mut _xmlDoc,
2455 mem: *mut *mut xmlChar,
2456 size: *mut c_int,
2457 format: c_int,
2458) {
2459 if doc.is_null() || mem.is_null() || size.is_null() {
2460 return;
2461 }
2462 crate::xml::tree::xmlDocDumpFormatMemory(doc, mem, size, format)
2463}
2464
2465#[no_mangle]
2473pub unsafe extern "C" fn xmlDocDumpMemory(
2474 doc: *mut _xmlDoc,
2475 mem: *mut *mut xmlChar,
2476 size: *mut c_int,
2477) {
2478 if doc.is_null() || mem.is_null() || size.is_null() {
2479 return;
2480 }
2481 crate::xml::tree::xmlDocDumpMemory(doc, mem, size)
2482}
2483
2484#[no_mangle]
2492pub unsafe extern "C" fn xmlSaveFile(filename: *const c_char, cur: *mut _xmlDoc) -> c_int {
2493 if filename.is_null() || cur.is_null() {
2494 return -1;
2495 }
2496 crate::xml::tree::xmlSaveFile(filename, cur)
2497}
2498
2499#[no_mangle]
2507pub unsafe extern "C" fn xmlSaveFileEnc(
2508 filename: *const c_char,
2509 cur: *mut _xmlDoc,
2510 encoding: *const c_char,
2511) -> c_int {
2512 if filename.is_null() || cur.is_null() {
2513 return -1;
2514 }
2515 crate::xml::tree::xmlSaveFileEnc(filename, cur, encoding)
2516}
2517
2518#[no_mangle]
2526pub unsafe extern "C" fn xmlSaveFormatFile(
2527 filename: *const c_char,
2528 cur: *mut _xmlDoc,
2529 format: c_int,
2530) -> c_int {
2531 if filename.is_null() || cur.is_null() {
2532 return -1;
2533 }
2534 crate::xml::tree::xmlSaveFormatFile(filename, cur, format)
2535}
2536
2537#[no_mangle]
2545pub unsafe extern "C" fn xmlSaveFormatFileEnc(
2546 filename: *const c_char,
2547 cur: *mut _xmlDoc,
2548 encoding: *const c_char,
2549 format: c_int,
2550) -> c_int {
2551 if filename.is_null() || cur.is_null() {
2552 return -1;
2553 }
2554 crate::xml::tree::xmlSaveFormatFileEnc(filename, cur, encoding, format)
2555}
2556
2557#[no_mangle]
2572pub unsafe extern "C" fn xmlReadDoc(
2573 cur: *const xmlChar,
2574 URL: *const c_char,
2575 encoding: *const c_char,
2576 options: c_int,
2577) -> *mut _xmlDoc {
2578 if cur.is_null() {
2580 return ptr::null_mut();
2581 }
2582 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2583 if ctxt.is_null() {
2584 return ptr::null_mut();
2585 }
2586 let len = crate::xml::string::xml_strlen(cur);
2587 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2588 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2589 (*ctxt).options = options;
2590 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2591 let doc = (*ctxt).myDoc;
2592 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2593 return doc;
2594 }
2595 let doc = (*ctxt).myDoc;
2596 if !doc.is_null() {
2597 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2598 }
2599 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2600 doc
2601}
2602
2603#[no_mangle]
2611pub unsafe extern "C" fn xmlReadFile(
2612 URL: *const c_char,
2613 encoding: *const c_char,
2614 options: c_int,
2615) -> *mut _xmlDoc {
2616 if URL.is_null() {
2618 return ptr::null_mut();
2619 }
2620 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2621 if ctxt.is_null() {
2622 return ptr::null_mut();
2623 }
2624 let input = match crate::xml::parser::helpers::input_from_file(URL) {
2625 Ok(input) => input,
2626 Err(_) => {
2627 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2628 return ptr::null_mut();
2629 }
2630 };
2631 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2632 (*ctxt).options = options;
2633 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2634 let doc = (*ctxt).myDoc;
2635 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2636 if options & 1 << 0 != 0 {
2640 return doc;
2641 }
2642 if !doc.is_null() {
2643 crate::xml::tree::free_doc(doc);
2644 }
2645 return ptr::null_mut();
2646 }
2647 let doc = (*ctxt).myDoc;
2648 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2649 doc
2650}
2651
2652#[no_mangle]
2661pub unsafe extern "C" fn xmlRecoverDoc(cur: *const xmlChar) -> *mut _xmlDoc {
2662 unsafe { xmlReadDoc(cur, ptr::null(), ptr::null(), 1 << 0) }
2663}
2664
2665#[no_mangle]
2673pub unsafe extern "C" fn xmlRecoverFile(filename: *const c_char) -> *mut _xmlDoc {
2674 unsafe { xmlReadFile(filename, ptr::null(), 1 << 0) }
2675}
2676
2677#[no_mangle]
2685pub unsafe extern "C" fn xmlRecoverMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
2686 unsafe { xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 1 << 0) }
2687}
2688
2689#[no_mangle]
2698pub unsafe extern "C" fn xmlReadMemory(
2699 buffer: *const c_char,
2700 size: c_int,
2701 URL: *const c_char,
2702 encoding: *const c_char,
2703 options: c_int,
2704) -> *mut _xmlDoc {
2705 if buffer.is_null() || size <= 0 {
2707 return ptr::null_mut();
2708 }
2709 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2710 if ctxt.is_null() {
2711 return ptr::null_mut();
2712 }
2713 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
2714 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2715 (*ctxt).options = options;
2716 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2717 let doc = (*ctxt).myDoc;
2718 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2719 if options & 1 << 0 != 0 {
2723 return doc;
2724 }
2725 if !doc.is_null() {
2726 crate::xml::tree::free_doc(doc);
2727 }
2728 return ptr::null_mut();
2729 }
2730 let doc = (*ctxt).myDoc;
2731 if !doc.is_null() && !URL.is_null() {
2732 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2733 }
2734 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2735 doc
2736}
2737
2738#[no_mangle]
2744pub unsafe extern "C" fn xmlLoadCatalogs(catalogs: *const c_char) {
2745 if !catalogs.is_null() {
2746 crate::xml::catalog::load_catalog(catalogs);
2747 }
2748}
2749
2750#[no_mangle]
2756pub unsafe extern "C" fn xmlLoadCatalog(catalogs: *const c_char) -> *mut c_void {
2757 crate::xml::catalog::load_catalog(catalogs)
2758}
2759
2760#[no_mangle]
2768pub unsafe extern "C" fn xmlReadFd(
2769 fd: c_int,
2770 URL: *const c_char,
2771 encoding: *const c_char,
2772 options: c_int,
2773) -> *mut _xmlDoc {
2774 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2776 if ctxt.is_null() {
2777 return ptr::null_mut();
2778 }
2779 let mut buf = Vec::new();
2781 let mut tmp = [0u8; 4096];
2782 loop {
2783 let n = libc::read(fd, tmp.as_mut_ptr() as *mut c_void, tmp.len());
2784 if n <= 0 {
2785 break;
2786 }
2787 buf.extend_from_slice(&tmp[..n as usize]);
2788 }
2789 let input = crate::xml::parser::helpers::input_from_memory(
2790 buf.as_ptr() as *const c_char,
2791 buf.len() as c_int,
2792 );
2793 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2794 (*ctxt).options = options;
2795 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2796 let doc = (*ctxt).myDoc;
2797 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2798 return doc;
2799 }
2800 let doc = (*ctxt).myDoc;
2801 if !doc.is_null() && !URL.is_null() {
2802 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2803 }
2804 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2805 doc
2806}
2807
2808#[no_mangle]
2817pub unsafe extern "C" fn xmlReadIO(
2818 ioread: Option<xmlInputReadCallback>,
2819 ioclose: Option<xmlInputCloseCallback>,
2820 ioctx: *mut c_void,
2821 URL: *const c_char,
2822 encoding: *const c_char,
2823 options: c_int,
2824) -> *mut _xmlDoc {
2825 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2827 if ctxt.is_null() {
2828 return ptr::null_mut();
2829 }
2830 let input = crate::xml::parser::helpers::input_from_io(ioread, ioclose, ioctx);
2831 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2832 (*ctxt).options = options;
2833 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2834 let doc = (*ctxt).myDoc;
2835 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2836 return doc;
2837 }
2838 let doc = (*ctxt).myDoc;
2839 if !doc.is_null() && !URL.is_null() {
2840 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2841 }
2842 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2843 doc
2844}
2845
2846#[no_mangle]
2854pub unsafe extern "C" fn xmlSAXParseDoc(
2855 sax: *mut _xmlSAXHandler,
2856 cur: *const xmlChar,
2857 recovery: c_int,
2858) -> *mut _xmlDoc {
2859 if cur.is_null() {
2861 return ptr::null_mut();
2862 }
2863 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2864 if ctxt.is_null() {
2865 return ptr::null_mut();
2866 }
2867 if !sax.is_null() {
2868 (*ctxt).sax = sax;
2869 (*ctxt).userData = (*ctxt).sax as *mut c_void;
2870 }
2871 if recovery != 0 {
2872 (*ctxt).recovery = 1;
2873 (*ctxt).options |= 1; }
2875 let len = crate::xml::string::xml_strlen(cur);
2876 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2877 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2878 crate::xml::parser::helpers::parse_document(ctxt);
2879 let doc = (*ctxt).myDoc;
2880 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2881 doc
2882}
2883
2884#[no_mangle]
2894pub unsafe extern "C" fn xmlSAXParseDocWithData(
2895 sax: *mut _xmlSAXHandler,
2896 cur: *const xmlChar,
2897 recovery: c_int,
2898 data: *mut c_void,
2899) -> *mut _xmlDoc {
2900 if cur.is_null() {
2902 return ptr::null_mut();
2903 }
2904 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2905 if ctxt.is_null() {
2906 return ptr::null_mut();
2907 }
2908 if !sax.is_null() {
2909 (*ctxt).sax = sax;
2910 }
2911 (*ctxt).userData = data;
2912 if recovery != 0 {
2913 (*ctxt).recovery = 1;
2914 (*ctxt).options |= 1; }
2916 let len = crate::xml::string::xml_strlen(cur);
2917 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2918 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2919 crate::xml::parser::helpers::parse_document(ctxt);
2920 let doc = (*ctxt).myDoc;
2921 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2922 doc
2923}
2924
2925#[no_mangle]
2935pub unsafe extern "C" fn xmlSAXParseFileWithData(
2936 sax: *mut _xmlSAXHandler,
2937 filename: *const c_char,
2938 recovery: c_int,
2939 data: *mut c_void,
2940) -> *mut _xmlDoc {
2941 if filename.is_null() {
2943 return ptr::null_mut();
2944 }
2945 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2946 if ctxt.is_null() {
2947 return ptr::null_mut();
2948 }
2949 if !sax.is_null() {
2950 (*ctxt).sax = sax;
2951 }
2952 (*ctxt).userData = data;
2953 if recovery != 0 {
2954 (*ctxt).recovery = 1;
2955 (*ctxt).options |= 1; }
2957 let input = match crate::xml::parser::helpers::input_from_file(filename) {
2958 Ok(input) => input,
2959 Err(_) => {
2960 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2961 return ptr::null_mut();
2962 }
2963 };
2964 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2965 crate::xml::parser::helpers::parse_document(ctxt);
2966 let doc = (*ctxt).myDoc;
2967 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2968 doc
2969}
2970
2971#[no_mangle]
2981pub unsafe extern "C" fn xmlSAXParseMemoryWithData(
2982 sax: *mut _xmlSAXHandler,
2983 buffer: *const c_char,
2984 size: c_int,
2985 recovery: c_int,
2986 data: *mut c_void,
2987) -> *mut _xmlDoc {
2988 if buffer.is_null() || size <= 0 {
2990 return ptr::null_mut();
2991 }
2992 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2993 if ctxt.is_null() {
2994 return ptr::null_mut();
2995 }
2996 if !sax.is_null() {
2997 (*ctxt).sax = sax;
2998 }
2999 (*ctxt).userData = data;
3000 if recovery != 0 {
3001 (*ctxt).recovery = 1;
3002 (*ctxt).options |= 1; }
3004 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3005 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3006 crate::xml::parser::helpers::parse_document(ctxt);
3007 let doc = (*ctxt).myDoc;
3008 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3009 doc
3010}
3011
3012#[no_mangle]
3020pub unsafe extern "C" fn xmlSAXParseFile(
3021 sax: *mut _xmlSAXHandler,
3022 filename: *const c_char,
3023 recovery: c_int,
3024) -> *mut _xmlDoc {
3025 if filename.is_null() {
3027 return ptr::null_mut();
3028 }
3029 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3030 if ctxt.is_null() {
3031 return ptr::null_mut();
3032 }
3033 if !sax.is_null() {
3034 (*ctxt).sax = sax;
3035 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3036 }
3037 if recovery != 0 {
3038 (*ctxt).recovery = 1;
3039 (*ctxt).options |= 1;
3040 }
3041 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3042 Ok(input) => input,
3043 Err(_) => {
3044 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3045 return ptr::null_mut();
3046 }
3047 };
3048 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3049 crate::xml::parser::helpers::parse_document(ctxt);
3050 let doc = (*ctxt).myDoc;
3051 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3052 doc
3053}
3054
3055#[no_mangle]
3064pub unsafe extern "C" fn xmlSAXParseMemory(
3065 sax: *mut _xmlSAXHandler,
3066 buffer: *const c_char,
3067 size: c_int,
3068 recovery: c_int,
3069) -> *mut _xmlDoc {
3070 if buffer.is_null() || size <= 0 {
3072 return ptr::null_mut();
3073 }
3074 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3075 if ctxt.is_null() {
3076 return ptr::null_mut();
3077 }
3078 if !sax.is_null() {
3079 (*ctxt).sax = sax;
3080 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3081 }
3082 if recovery != 0 {
3083 (*ctxt).recovery = 1;
3084 (*ctxt).options |= 1;
3085 }
3086 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3087 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3088 crate::xml::parser::helpers::parse_document(ctxt);
3089 let doc = (*ctxt).myDoc;
3090 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3091 doc
3092}
3093
3094#[no_mangle]
3103pub unsafe extern "C" fn xmlSAXUserParseFile(
3104 sax: *mut _xmlSAXHandler,
3105 user_data: *mut c_void,
3106 filename: *const c_char,
3107) -> c_int {
3108 if filename.is_null() {
3110 return -1;
3111 }
3112 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3113 if ctxt.is_null() {
3114 return -1;
3115 }
3116 if !sax.is_null() {
3117 (*ctxt).sax = sax;
3118 }
3119 (*ctxt).userData = if !user_data.is_null() {
3120 user_data
3121 } else {
3122 ctxt as *mut c_void
3123 };
3124 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3125 Ok(input) => input,
3126 Err(_) => {
3127 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3128 return -1;
3129 }
3130 };
3131 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3132 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3133 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3134 ret
3135}
3136
3137#[no_mangle]
3146pub unsafe extern "C" fn xmlSAXUserParseMemory(
3147 sax: *mut _xmlSAXHandler,
3148 user_data: *mut c_void,
3149 buffer: *const c_char,
3150 size: c_int,
3151) -> c_int {
3152 if buffer.is_null() || size <= 0 {
3154 return -1;
3155 }
3156 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3157 if ctxt.is_null() {
3158 return -1;
3159 }
3160 if !sax.is_null() {
3161 (*ctxt).sax = sax;
3162 }
3163 (*ctxt).userData = if !user_data.is_null() {
3164 user_data
3165 } else {
3166 ctxt as *mut c_void
3167 };
3168 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3169 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3170 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3171 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3172 ret
3173}
3174
3175#[no_mangle]
3183pub unsafe extern "C" fn xmlParseDoc(cur: *const xmlChar) -> *mut _xmlDoc {
3184 if cur.is_null() {
3186 return ptr::null_mut();
3187 }
3188 xmlReadDoc(cur, ptr::null(), ptr::null(), 0)
3189}
3190
3191#[no_mangle]
3199pub unsafe extern "C" fn xmlParseFile(filename: *const c_char) -> *mut _xmlDoc {
3200 if filename.is_null() {
3202 return ptr::null_mut();
3203 }
3204 xmlReadFile(filename, ptr::null(), 0)
3205}
3206
3207#[no_mangle]
3215pub unsafe extern "C" fn xmlParseMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
3216 if buffer.is_null() || size <= 0 {
3218 return ptr::null_mut();
3219 }
3220 xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 0)
3221}
3222
3223#[no_mangle]
3231pub unsafe extern "C" fn xmlCreateFileParserCtxt(filename: *const c_char) -> *mut _xmlParserCtxt {
3232 if filename.is_null() {
3234 return ptr::null_mut();
3235 }
3236 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3237 if ctxt.is_null() {
3238 return ptr::null_mut();
3239 }
3240 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3241 Ok(input) => input,
3242 Err(_) => {
3243 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3244 return ptr::null_mut();
3245 }
3246 };
3247 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3248 ctxt
3249}
3250
3251#[no_mangle]
3259pub unsafe extern "C" fn xmlCreateDocParserCtxt(cur: *const xmlChar) -> *mut _xmlParserCtxt {
3260 if cur.is_null() {
3262 return ptr::null_mut();
3263 }
3264 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3265 if ctxt.is_null() {
3266 return ptr::null_mut();
3267 }
3268 let len = crate::xml::string::xml_strlen(cur);
3269 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
3270 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3271 ctxt
3272}
3273
3274#[no_mangle]
3282pub unsafe extern "C" fn xmlParseDocument(ctxt: *mut _xmlParserCtxt) -> c_int {
3283 if ctxt.is_null() {
3285 return -1;
3286 }
3287 crate::xml::parser::helpers::parse_document(ctxt)
3288}
3289
3290#[no_mangle]
3298pub unsafe extern "C" fn xmlFreeParserCtxt(ctxt: *mut _xmlParserCtxt) {
3299 if ctxt.is_null() {
3300 return;
3301 }
3302 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3303}
3304
3305#[no_mangle]
3313pub unsafe extern "C" fn xmlCtxtUseOptions(ctxt: *mut _xmlParserCtxt, options: c_int) -> c_int {
3314 if ctxt.is_null() {
3315 return -1;
3316 }
3317 unsafe {
3319 (*ctxt).options = options;
3320 }
3321 0
3322}
3323
3324#[no_mangle]
3333pub unsafe extern "C" fn xmlParseChunk(
3334 ctxt: *mut _xmlParserCtxt,
3335 chunk: *const c_char,
3336 size: c_int,
3337 terminate: c_int,
3338) -> c_int {
3339 if ctxt.is_null() {
3342 return -1;
3343 }
3344 crate::xml::parser::helpers::parse_chunk(ctxt, chunk, size, terminate)
3345}
3346
3347#[no_mangle]
3355pub unsafe extern "C" fn xmlParserInputBufferCreateMem(
3356 buffer: *const c_char,
3357 size: c_int,
3358 enc: c_int,
3359) -> *mut _xmlParserInputBuffer {
3360 if buffer.is_null() || size <= 0 {
3362 return ptr::null_mut();
3363 }
3364 crate::xml::parser::helpers::alloc_parser_input_buffer()
3365}
3366
3367#[no_mangle]
3375pub unsafe extern "C" fn xmlParserInputBufferCreateFilename(
3376 URI: *const c_char,
3377 enc: c_int,
3378) -> *mut _xmlParserInputBuffer {
3379 if URI.is_null() {
3381 return ptr::null_mut();
3382 }
3383 crate::xml::parser::helpers::alloc_parser_input_buffer()
3384}
3385
3386#[no_mangle]
3396pub unsafe extern "C" fn xmlParserInputBufferCreateIO(
3397 ioread: Option<xmlInputReadCallback>,
3398 ioclose: Option<xmlInputCloseCallback>,
3399 ioctx: *mut c_void,
3400 enc: c_int,
3401) -> *mut _xmlParserInputBuffer {
3402 let buf = crate::xml::parser::helpers::alloc_parser_input_buffer();
3404 if !buf.is_null() {
3405 (*buf).readcallback = ioread;
3406 (*buf).closecallback = ioclose;
3407 (*buf).context = ioctx;
3408 }
3409 buf
3410}
3411
3412#[no_mangle]
3420pub unsafe extern "C" fn xmlFreeParserInputBuffer(buf: *mut _xmlParserInputBuffer) {
3421 if buf.is_null() {
3422 return;
3423 }
3424 crate::xml::parser::helpers::free_parser_input_buffer(buf);
3425}
3426
3427#[no_mangle]
3435pub unsafe extern "C" fn xmlNewInputFromFile(
3436 ctxt: *mut _xmlParserCtxt,
3437 filename: *const c_char,
3438) -> *mut _xmlParserInput {
3439 if filename.is_null() {
3444 return ptr::null_mut();
3445 }
3446 crate::xml::parser::helpers::alloc_parser_input_buffer() as *mut _xmlParserInput
3447}
3448
3449#[no_mangle]
3457pub unsafe extern "C" fn xmlFreeInputStream(input: *mut _xmlParserInput) {
3458 if input.is_null() {
3459 return;
3460 }
3461 crate::xml::parser::helpers::free_parser_input(input);
3462}
3463
3464#[no_mangle]
3478pub unsafe extern "C" fn xmlOutputBufferCreateFilename(
3479 URI: *const c_char,
3480 encoder: *mut c_void,
3481 compression: c_int,
3482) -> *mut _xmlOutputBuffer {
3483 let _ = compression;
3484 if URI.is_null() {
3485 return ptr::null_mut();
3486 }
3487 crate::xml::io::output_buffer_create_filename(
3488 URI,
3489 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3490 0,
3491 )
3492}
3493
3494#[no_mangle]
3503pub unsafe extern "C" fn xmlOutputBufferCreateFd(
3504 fd: c_int,
3505 encoder: *mut c_void,
3506) -> *mut _xmlOutputBuffer {
3507 if fd < 0 {
3508 return ptr::null_mut();
3509 }
3510 crate::xml::io::output_buffer_create_fd(
3511 fd,
3512 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3513 )
3514}
3515
3516#[no_mangle]
3526pub unsafe extern "C" fn xmlOutputBufferCreateIO(
3527 iowrite: Option<xmlOutputWriteCallback>,
3528 ioclose: Option<xmlOutputCloseCallback>,
3529 ioctx: *mut c_void,
3530 encoder: *mut c_void,
3531) -> *mut _xmlOutputBuffer {
3532 crate::xml::io::output_buffer_create_io(
3533 iowrite,
3534 ioclose,
3535 ioctx,
3536 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3537 )
3538}
3539
3540#[no_mangle]
3548pub unsafe extern "C" fn xmlOutputBufferClose(out: *mut _xmlOutputBuffer) -> c_int {
3549 if out.is_null() {
3550 return -1;
3551 }
3552 crate::xml::io::output_buffer_close(out)
3553}
3554
3555#[no_mangle]
3563pub unsafe extern "C" fn xmlOutputBufferFlush(out: *mut _xmlOutputBuffer) -> c_int {
3564 if out.is_null() {
3565 return -1;
3566 }
3567 crate::xml::io::output_buffer_flush(out)
3568}
3569
3570#[no_mangle]
3578pub unsafe extern "C" fn xmlOutputBufferWrite(
3579 out: *mut _xmlOutputBuffer,
3580 len: c_int,
3581 data: *const c_char,
3582) -> c_int {
3583 if out.is_null() || data.is_null() || len <= 0 {
3584 return -1;
3585 }
3586 crate::xml::io::output_buffer_write(out, len, data)
3587}
3588
3589#[no_mangle]
3597pub unsafe extern "C" fn xmlOutputBufferWriteString(
3598 out: *mut _xmlOutputBuffer,
3599 str: *const c_char,
3600) -> c_int {
3601 if str.is_null() {
3602 return 0;
3603 }
3604 unsafe { xmlOutputBufferWrite(out, xmlStrlen(str as *const xmlChar), str) }
3605}
3606
3607#[no_mangle]
3615pub unsafe extern "C" fn xmlAllocOutputBuffer(encoder: *mut c_void) -> *mut _xmlOutputBuffer {
3616 crate::xml::io::output_buffer_create(
3617 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3618 )
3619}
3620
3621#[no_mangle]
3635pub unsafe extern "C" fn xmlOutputBufferCreateBuffer(
3636 buffer: *mut crate::abi::structs::_xmlBuffer,
3637 encoder: *mut c_void,
3638) -> *mut _xmlOutputBuffer {
3639 crate::xml::io::output_buffer_create_buffer(
3640 buffer,
3641 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3642 )
3643}
3644
3645#[no_mangle]
3653pub unsafe extern "C" fn xmlOutputBufferCreateFile(
3654 file: *mut libc::FILE,
3655 encoder: *mut c_void,
3656) -> *mut _xmlOutputBuffer {
3657 crate::xml::io::output_buffer_create_file(
3658 file,
3659 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3660 )
3661}
3662
3663#[no_mangle]
3669pub unsafe extern "C" fn xmlOutputBufferGetContent(out: *mut _xmlOutputBuffer) -> *const c_char {
3670 crate::xml::io::output_buffer_get_content(out) as *const c_char
3671}
3672
3673#[no_mangle]
3680pub unsafe extern "C" fn xmlOutputBufferGetSize(out: *mut _xmlOutputBuffer) -> c_int {
3681 crate::xml::io::output_buffer_get_size(out)
3682}
3683
3684#[no_mangle]
3692pub unsafe extern "C" fn xmlOutputBufferWriteEscape(
3693 out: *mut _xmlOutputBuffer,
3694 str: *const xmlChar,
3695 escaping: Option<xmlCharEncodingOutputFunc>,
3696) -> c_int {
3697 if out.is_null() || str.is_null() {
3698 return -1;
3699 }
3700 crate::xml::io::output_buffer_write_escape(out, str, escaping)
3701}
3702
3703static mut OUTPUT_CREATE_FILENAME_DEFAULT: Option<
3706 unsafe extern "C" fn(
3707 *const c_char,
3708 *mut crate::abi::structs::_xmlCharEncodingHandler,
3709 c_int,
3710 ) -> *mut _xmlOutputBuffer,
3711> = None;
3712
3713#[no_mangle]
3720pub unsafe extern "C" fn xmlOutputBufferCreateFilenameDefault(
3721 func: Option<
3722 unsafe extern "C" fn(
3723 *const c_char,
3724 *mut crate::abi::structs::_xmlCharEncodingHandler,
3725 c_int,
3726 ) -> *mut _xmlOutputBuffer,
3727 >,
3728) -> Option<
3729 unsafe extern "C" fn(
3730 *const c_char,
3731 *mut crate::abi::structs::_xmlCharEncodingHandler,
3732 c_int,
3733 ) -> *mut _xmlOutputBuffer,
3734> {
3735 let old = unsafe { OUTPUT_CREATE_FILENAME_DEFAULT };
3736 if func.is_some() {
3737 unsafe { OUTPUT_CREATE_FILENAME_DEFAULT = func };
3738 }
3739 old
3740}
3741
3742#[no_mangle]
3745pub unsafe extern "C" fn __xmlOutputBufferCreateFilename() -> *mut Option<
3746 unsafe extern "C" fn(
3747 *const c_char,
3748 *mut crate::abi::structs::_xmlCharEncodingHandler,
3749 c_int,
3750 ) -> *mut _xmlOutputBuffer,
3751> {
3752 unsafe { core::ptr::addr_of_mut!(OUTPUT_CREATE_FILENAME_DEFAULT) }
3753}
3754
3755#[no_mangle]
3767pub extern "C" fn xmlDictCreate() -> *mut c_void {
3768 unsafe { crate::xml::dictionary::dict_create() as *mut c_void }
3769}
3770
3771#[no_mangle]
3779pub extern "C" fn xmlDictCreateSub(sub: *mut c_void) -> *mut c_void {
3780 unsafe {
3781 crate::xml::dictionary::dict_create_sub(sub as *mut crate::xml::dictionary::Dict)
3782 as *mut c_void
3783 }
3784}
3785
3786#[no_mangle]
3798pub unsafe extern "C" fn xmlDictLookup(
3799 dict: *mut c_void,
3800 name: *const xmlChar,
3801 len: c_int,
3802) -> *const xmlChar {
3803 unsafe {
3804 crate::xml::dictionary::dict_lookup(dict as *mut crate::xml::dictionary::Dict, name, len)
3805 }
3806}
3807
3808#[no_mangle]
3816pub unsafe extern "C" fn xmlDictExists(
3817 dict: *mut c_void,
3818 name: *const xmlChar,
3819 len: c_int,
3820) -> *const xmlChar {
3821 unsafe {
3822 crate::xml::dictionary::dict_exists(dict as *mut crate::xml::dictionary::Dict, name, len)
3823 }
3824}
3825
3826#[no_mangle]
3834pub extern "C" fn xmlDictSize(dict: *const c_void) -> c_uint {
3835 unsafe {
3836 crate::xml::dictionary::dict_size(dict as *const crate::xml::dictionary::Dict) as c_uint
3837 }
3838}
3839
3840#[no_mangle]
3848pub extern "C" fn xmlDictFree(dict: *mut c_void) {
3849 unsafe { crate::xml::dictionary::dict_free(dict as *mut crate::xml::dictionary::Dict) }
3850}
3851
3852#[no_mangle]
3860pub extern "C" fn xmlDictSetLimit(dict: *mut c_void, limit: c_uint) -> c_uint {
3861 unsafe {
3862 crate::xml::dictionary::dict_set_limit(
3863 dict as *mut crate::xml::dictionary::Dict,
3864 limit as usize,
3865 ) as c_uint
3866 }
3867}
3868
3869#[no_mangle]
3877pub extern "C" fn xmlDictGetUsage(dict: *const c_void) -> c_uint {
3878 unsafe {
3879 crate::xml::dictionary::dict_get_usage(dict as *mut crate::xml::dictionary::Dict) as c_uint
3880 }
3881}
3882
3883#[no_mangle]
3895pub extern "C" fn xmlHashCreate(size: c_int) -> *mut c_void {
3896 unsafe { crate::xml::hash::hash_create(size) as *mut c_void }
3897}
3898
3899#[no_mangle]
3907pub extern "C" fn xmlHashCreateDict(size: c_int, dict: *mut c_void) -> *mut c_void {
3908 unsafe { crate::xml::hash::hash_create_dict(size, dict) as *mut c_void }
3909}
3910
3911#[no_mangle]
3919pub extern "C" fn xmlHashFree(
3920 table: *mut c_void,
3921 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
3922) {
3923 unsafe { crate::xml::hash::hash_free(table as *mut crate::xml::hash::HashTable, f) }
3924}
3925
3926#[no_mangle]
3934pub unsafe extern "C" fn xmlHashAddEntry(
3935 table: *mut c_void,
3936 name: *const xmlChar,
3937 userdata: *mut c_void,
3938) -> c_int {
3939 unsafe {
3940 crate::xml::hash::hash_add_entry(table as *mut crate::xml::hash::HashTable, name, userdata)
3941 }
3942}
3943
3944#[no_mangle]
3953pub unsafe extern "C" fn xmlHashAddEntry2(
3954 table: *mut c_void,
3955 name: *const xmlChar,
3956 name2: *const xmlChar,
3957 userdata: *mut c_void,
3958) -> c_int {
3959 unsafe {
3960 crate::xml::hash::hash_add_entry2(
3961 table as *mut crate::xml::hash::HashTable,
3962 name,
3963 name2,
3964 userdata,
3965 )
3966 }
3967}
3968
3969#[no_mangle]
3978pub unsafe extern "C" fn xmlHashAddEntry3(
3979 table: *mut c_void,
3980 name: *const xmlChar,
3981 name2: *const xmlChar,
3982 name3: *const xmlChar,
3983 userdata: *mut c_void,
3984) -> c_int {
3985 unsafe {
3986 crate::xml::hash::hash_add_entry3(
3987 table as *mut crate::xml::hash::HashTable,
3988 name,
3989 name2,
3990 name3,
3991 userdata,
3992 )
3993 }
3994}
3995
3996#[no_mangle]
4005pub unsafe extern "C" fn xmlHashUpdateEntry(
4006 table: *mut c_void,
4007 name: *const xmlChar,
4008 userdata: *mut c_void,
4009 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4010) -> c_int {
4011 unsafe {
4012 crate::xml::hash::hash_update_entry(
4013 table as *mut crate::xml::hash::HashTable,
4014 name,
4015 userdata,
4016 f,
4017 )
4018 }
4019}
4020
4021#[no_mangle]
4023pub unsafe extern "C" fn xmlHashUpdateEntry2(
4024 table: *mut c_void,
4025 name: *const xmlChar,
4026 name2: *const xmlChar,
4027 userdata: *mut c_void,
4028 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4029) -> c_int {
4030 unsafe {
4031 crate::xml::hash::hash_update_entry2(
4032 table as *mut crate::xml::hash::HashTable,
4033 name,
4034 name2,
4035 userdata,
4036 f,
4037 )
4038 }
4039}
4040
4041#[no_mangle]
4043pub unsafe extern "C" fn xmlHashUpdateEntry3(
4044 table: *mut c_void,
4045 name: *const xmlChar,
4046 name2: *const xmlChar,
4047 name3: *const xmlChar,
4048 userdata: *mut c_void,
4049 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4050) -> c_int {
4051 unsafe {
4052 crate::xml::hash::hash_update_entry3(
4053 table as *mut crate::xml::hash::HashTable,
4054 name,
4055 name2,
4056 name3,
4057 userdata,
4058 f,
4059 )
4060 }
4061}
4062
4063#[no_mangle]
4071pub unsafe extern "C" fn xmlHashLookup(table: *mut c_void, name: *const xmlChar) -> *mut c_void {
4072 unsafe { crate::xml::hash::hash_lookup(table as *mut crate::xml::hash::HashTable, name) }
4073}
4074
4075#[no_mangle]
4077pub unsafe extern "C" fn xmlHashLookup2(
4078 table: *mut c_void,
4079 name: *const xmlChar,
4080 name2: *const xmlChar,
4081) -> *mut c_void {
4082 unsafe {
4083 crate::xml::hash::hash_lookup2(table as *mut crate::xml::hash::HashTable, name, name2)
4084 }
4085}
4086
4087#[no_mangle]
4089pub unsafe extern "C" fn xmlHashLookup3(
4090 table: *mut c_void,
4091 name: *const xmlChar,
4092 name2: *const xmlChar,
4093 name3: *const xmlChar,
4094) -> *mut c_void {
4095 unsafe {
4096 crate::xml::hash::hash_lookup3(
4097 table as *mut crate::xml::hash::HashTable,
4098 name,
4099 name2,
4100 name3,
4101 )
4102 }
4103}
4104
4105#[no_mangle]
4113pub extern "C" fn xmlHashSize(table: *mut c_void) -> c_int {
4114 unsafe { crate::xml::hash::hash_size(table as *mut crate::xml::hash::HashTable) }
4115}
4116
4117#[no_mangle]
4126pub unsafe extern "C" fn xmlHashRemoveEntry(
4127 table: *mut c_void,
4128 name: *const xmlChar,
4129 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4130) -> c_int {
4131 unsafe {
4132 crate::xml::hash::hash_remove_entry(table as *mut crate::xml::hash::HashTable, name, f)
4133 }
4134}
4135
4136#[no_mangle]
4138pub unsafe extern "C" fn xmlHashRemoveEntry2(
4139 table: *mut c_void,
4140 name: *const xmlChar,
4141 name2: *const xmlChar,
4142 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4143) -> c_int {
4144 unsafe {
4145 crate::xml::hash::hash_remove_entry2(
4146 table as *mut crate::xml::hash::HashTable,
4147 name,
4148 name2,
4149 f,
4150 )
4151 }
4152}
4153
4154#[no_mangle]
4156pub unsafe extern "C" fn xmlHashRemoveEntry3(
4157 table: *mut c_void,
4158 name: *const xmlChar,
4159 name2: *const xmlChar,
4160 name3: *const xmlChar,
4161 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4162) -> c_int {
4163 unsafe {
4164 crate::xml::hash::hash_remove_entry3(
4165 table as *mut crate::xml::hash::HashTable,
4166 name,
4167 name2,
4168 name3,
4169 f,
4170 )
4171 }
4172}
4173
4174#[no_mangle]
4182pub extern "C" fn xmlHashScan(table: *mut c_void, f: Option<xmlHashScanner>, data: *mut c_void) {
4183 unsafe { crate::xml::hash::hash_scan(table as *mut crate::xml::hash::HashTable, f, data) }
4184}
4185
4186#[no_mangle]
4188pub extern "C" fn xmlHashScanFull(
4189 table: *mut c_void,
4190 f: Option<xmlHashScannerFull>,
4191 data: *mut c_void,
4192) {
4193 unsafe { crate::xml::hash::hash_scan_full(table as *mut crate::xml::hash::HashTable, f, data) }
4194}
4195
4196#[no_mangle]
4204pub extern "C" fn xmlHashCopy(
4205 table: *mut c_void,
4206 f: Option<unsafe extern "C" fn(*mut c_void, *const xmlChar) -> *mut c_void>,
4207) -> *mut c_void {
4208 unsafe {
4209 crate::xml::hash::hash_copy(table as *mut crate::xml::hash::HashTable, f) as *mut c_void
4210 }
4211}
4212
4213#[no_mangle]
4226pub extern "C" fn xmlListCreate(
4227 deallocator: Option<unsafe extern "C" fn(*mut c_void)>,
4228 compare: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
4229) -> *mut c_void {
4230 unsafe { crate::xml::list::list_create(deallocator, compare) as *mut c_void }
4231}
4232
4233#[no_mangle]
4241pub extern "C" fn xmlListDelete(list: *mut c_void) {
4242 unsafe { crate::xml::list::list_delete(list as *mut crate::xml::list::List) }
4243}
4244
4245#[no_mangle]
4253pub extern "C" fn xmlListSearch(list: *mut c_void, data: *mut c_void) -> *mut c_void {
4254 unsafe { crate::xml::list::list_search(list as *mut crate::xml::list::List, data) }
4255}
4256
4257#[no_mangle]
4265pub extern "C" fn xmlListWalk(
4266 list: *mut c_void,
4267 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4268 data: *mut c_void,
4269) {
4270 unsafe { crate::xml::list::list_walk(list as *mut crate::xml::list::List, walker, data) }
4271}
4272
4273#[no_mangle]
4281pub extern "C" fn xmlListPushBack(list: *mut c_void, data: *mut c_void) -> c_int {
4282 unsafe { crate::xml::list::list_push_back(list as *mut crate::xml::list::List, data) }
4283}
4284
4285#[no_mangle]
4293pub extern "C" fn xmlListPushFront(list: *mut c_void, data: *mut c_void) -> c_int {
4294 unsafe { crate::xml::list::list_push_front(list as *mut crate::xml::list::List, data) }
4295}
4296
4297#[no_mangle]
4299pub extern "C" fn xmlListPopBack(list: *mut c_void) {
4300 unsafe { crate::xml::list::list_pop_back(list as *mut crate::xml::list::List) }
4301}
4302
4303#[no_mangle]
4305pub extern "C" fn xmlListPopFront(list: *mut c_void) {
4306 unsafe { crate::xml::list::list_pop_front(list as *mut crate::xml::list::List) }
4307}
4308
4309#[no_mangle]
4317pub extern "C" fn xmlListInsert(list: *mut c_void, data: *mut c_void) -> c_int {
4318 unsafe { crate::xml::list::list_insert(list as *mut crate::xml::list::List, data) }
4319}
4320
4321#[no_mangle]
4323pub extern "C" fn xmlListAppend(list: *mut c_void, data: *mut c_void) -> c_int {
4324 unsafe { crate::xml::list::list_append(list as *mut crate::xml::list::List, data) }
4325}
4326
4327#[no_mangle]
4329pub extern "C" fn xmlListRemoveFirst(list: *mut c_void, data: *mut c_void) -> c_int {
4330 unsafe { crate::xml::list::list_remove_first(list as *mut crate::xml::list::List, data) }
4331}
4332
4333#[no_mangle]
4335pub extern "C" fn xmlListRemoveLast(list: *mut c_void, data: *mut c_void) -> c_int {
4336 unsafe { crate::xml::list::list_remove_last(list as *mut crate::xml::list::List, data) }
4337}
4338
4339#[no_mangle]
4341pub extern "C" fn xmlListRemoveAll(list: *mut c_void, data: *mut c_void) -> c_int {
4342 unsafe { crate::xml::list::list_remove_all(list as *mut crate::xml::list::List, data) }
4343}
4344
4345#[no_mangle]
4347pub extern "C" fn xmlListClear(list: *mut c_void) {
4348 unsafe { crate::xml::list::list_clear(list as *mut crate::xml::list::List) }
4349}
4350
4351#[no_mangle]
4359pub extern "C" fn xmlListEmpty(list: *mut c_void) -> c_int {
4360 unsafe { crate::xml::list::list_empty(list as *mut crate::xml::list::List) }
4361}
4362
4363#[no_mangle]
4371pub extern "C" fn xmlListFront(list: *mut c_void) -> *mut c_void {
4372 unsafe { crate::xml::list::list_front(list as *mut crate::xml::list::List) }
4373}
4374
4375#[no_mangle]
4383pub extern "C" fn xmlListBack(list: *mut c_void) -> *mut c_void {
4384 unsafe { crate::xml::list::list_back(list as *mut crate::xml::list::List) }
4385}
4386
4387#[no_mangle]
4395pub extern "C" fn xmlListSize(list: *mut c_void) -> c_int {
4396 unsafe { crate::xml::list::list_size(list as *mut crate::xml::list::List) }
4397}
4398
4399#[no_mangle]
4401pub extern "C" fn xmlListSort(list: *mut c_void) {
4402 unsafe { crate::xml::list::list_sort(list as *mut crate::xml::list::List) }
4403}
4404
4405#[no_mangle]
4407pub extern "C" fn xmlListReverse(list: *mut c_void) {
4408 unsafe { crate::xml::list::list_reverse(list as *mut crate::xml::list::List) }
4409}
4410
4411#[no_mangle]
4413pub extern "C" fn xmlListReverseSplice(list: *mut c_void, list2: *mut c_void) {
4414 unsafe {
4415 crate::xml::list::list_reverse_splice(
4416 list as *mut crate::xml::list::List,
4417 list2 as *mut crate::xml::list::List,
4418 )
4419 }
4420}
4421
4422#[no_mangle]
4424pub extern "C" fn xmlListMerge(list: *mut c_void, list2: *mut c_void) {
4425 unsafe {
4426 crate::xml::list::list_merge(
4427 list as *mut crate::xml::list::List,
4428 list2 as *mut crate::xml::list::List,
4429 )
4430 }
4431}
4432#[no_mangle]
4440pub unsafe extern "C" fn xmlListEnd(l: *mut c_void) -> *mut c_void {
4441 crate::xml::list::list_end(l as *mut crate::xml::list::List)
4442}
4443
4444#[no_mangle]
4452pub unsafe extern "C" fn xmlListReverseSearch(l: *mut c_void, data: *mut c_void) -> *mut c_void {
4453 crate::xml::list::list_reverse_search(l as *mut crate::xml::list::List, data)
4454}
4455
4456#[no_mangle]
4464pub unsafe extern "C" fn xmlListReverseWalk(
4465 l: *mut c_void,
4466 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4467 data: *mut c_void,
4468) {
4469 crate::xml::list::list_reverse_walk(l as *mut crate::xml::list::List, walker, data)
4470}
4471
4472#[no_mangle]
4480pub unsafe extern "C" fn xmlListDup(l: *mut c_void) -> *mut c_void {
4481 crate::xml::list::list_dup(l as *mut crate::xml::list::List) as *mut c_void
4482}
4483
4484#[no_mangle]
4492pub unsafe extern "C" fn xmlListCopy(
4493 l: *mut c_void,
4494 copier: Option<unsafe extern "C" fn(*mut c_void) -> *mut c_void>,
4495) -> c_int {
4496 crate::xml::list::list_copy(l as *mut crate::xml::list::List, copier)
4497}
4498
4499#[no_mangle]
4507pub unsafe extern "C" fn xmlLinkGetData(lk: *mut c_void) -> *mut c_void {
4508 crate::xml::list::link_get_data(lk)
4509}
4510
4511#[no_mangle]
4523pub extern "C" fn xmlBufferCreate() -> *mut _xmlBuffer {
4524 crate::xml::io::buf_create(-1)
4525}
4526
4527#[no_mangle]
4535pub extern "C" fn xmlBufferCreateSize(size: usize) -> *mut _xmlBuffer {
4536 crate::xml::io::buf_create(size as c_int)
4537}
4538
4539#[no_mangle]
4547pub extern "C" fn xmlBufferCreateStatic(mem: *mut c_void, size: usize) -> *mut _xmlBuffer {
4548 if mem.is_null() || size == 0 {
4549 return ptr::null_mut();
4550 }
4551 crate::xml::io::buf_create_static(mem as *const xmlChar, size as c_int)
4552}
4553
4554#[no_mangle]
4562pub extern "C" fn xmlBufferFree(buf: *mut _xmlBuffer) {
4563 crate::xml::io::buf_free(buf)
4564}
4565
4566#[no_mangle]
4574pub extern "C" fn xmlBufferEmpty(buf: *mut _xmlBuffer) {
4575 if buf.is_null() {
4576 return;
4577 }
4578 unsafe {
4579 if !(*buf).content.is_null() {
4580 *(*buf).content = 0;
4581 }
4582 (*buf).use_ = 0;
4583 }
4584}
4585
4586#[no_mangle]
4594pub extern "C" fn xmlBufferContent(buf: *const _xmlBuffer) -> *mut xmlChar {
4595 crate::xml::io::buf_content(buf as *mut _xmlBuffer)
4596}
4597
4598#[no_mangle]
4606pub extern "C" fn xmlBufferLength(buf: *const _xmlBuffer) -> c_int {
4607 crate::xml::io::buf_length(buf as *mut _xmlBuffer)
4608}
4609
4610#[no_mangle]
4618pub unsafe extern "C" fn xmlBufferAdd(
4619 buf: *mut _xmlBuffer,
4620 str: *const xmlChar,
4621 len: c_int,
4622) -> c_int {
4623 crate::xml::io::buf_add(buf, str, len)
4624}
4625
4626#[no_mangle]
4634pub unsafe extern "C" fn xmlBufferAddHead(
4635 buf: *mut _xmlBuffer,
4636 str: *const xmlChar,
4637 len: c_int,
4638) -> c_int {
4639 crate::xml::io::buf_add_head(buf, str, len)
4640}
4641
4642#[no_mangle]
4650pub unsafe extern "C" fn xmlBufferCat(buf: *mut _xmlBuffer, str: *const xmlChar) -> c_int {
4651 if str.is_null() {
4652 return -1;
4653 }
4654 let len = crate::xml::string::xml_strlen(str) as c_int;
4655 crate::xml::io::buf_add(buf, str, len)
4656}
4657
4658#[no_mangle]
4667pub extern "C" fn xmlBufferSetAllocationScheme(buf: *mut _xmlBuffer, scheme: c_int) {
4668 if buf.is_null() {
4669 return;
4670 }
4671 unsafe {
4672 (*buf).alloc = scheme;
4673 }
4674}
4675
4676#[no_mangle]
4684pub extern "C" fn xmlBufferShrink(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4685 if buf.is_null() || len <= 0 {
4686 return 0;
4687 }
4688 unsafe {
4689 let b = &mut *buf;
4690 let shrink_len = (len as c_uint).min(b.use_);
4691 if shrink_len > 0 {
4692 let remaining = b.use_ - shrink_len;
4693 if remaining > 0 {
4694 core::ptr::copy(
4695 b.content.add(shrink_len as usize),
4696 b.content,
4697 remaining as usize,
4698 );
4699 }
4700 *b.content.add(remaining as usize) = 0;
4701 b.use_ = remaining;
4702 }
4703 }
4704 len
4705}
4706
4707#[no_mangle]
4715pub extern "C" fn xmlBufferGrow(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4716 if buf.is_null() || len <= 0 {
4717 return 0;
4718 }
4719 let cur_use = unsafe { (*buf).use_ };
4720 let new_size = cur_use + len as c_uint + 1;
4721 crate::xml::io::buf_grow(buf, new_size)
4722}
4723
4724#[no_mangle]
4732pub extern "C" fn xmlBufferReserve(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4733 xmlBufferGrow(buf, len)
4734}
4735
4736#[no_mangle]
4744pub extern "C" fn xmlBufferDetach(buf: *mut _xmlBuffer) -> *mut xmlChar {
4745 if buf.is_null() {
4746 return ptr::null_mut();
4747 }
4748 unsafe {
4749 let content = (*buf).content;
4750 (*buf).content = ptr::null_mut();
4751 (*buf).use_ = 0;
4752 (*buf).size = 0;
4753 content
4754 }
4755}
4756
4757#[no_mangle]
4769pub extern "C" fn xmlGetCharEncoding(name: *const c_char) -> c_int {
4770 if name.is_null() {
4771 return 0; }
4773 let name_bytes = unsafe {
4774 let len = libc::strlen(name);
4775 core::slice::from_raw_parts(name as *const u8, len)
4776 };
4777 crate::xml::encoding::encoding_from_name(name_bytes) as c_int
4778}
4779
4780#[no_mangle]
4788pub extern "C" fn xmlFindCharEncodingHandler(name: *const c_char) -> *mut c_void {
4789 if name.is_null() {
4790 return ptr::null_mut();
4791 }
4792 crate::xml::encoding::find_encoding_handler(name as *const xmlChar) as *mut c_void
4793}
4794
4795#[no_mangle]
4803pub extern "C" fn xmlCharEncCloseFunc(handler: *mut c_void) -> c_int {
4804 if handler.is_null() {
4805 return -1;
4806 }
4807 unsafe {
4809 let h = handler as *mut crate::abi::structs::_xmlCharEncodingHandler;
4810 if !(*h).name.is_null() {
4811 crate::abi::allocator::xmlFree((*h).name as *mut c_void);
4812 }
4813 crate::abi::allocator::xmlFree(handler);
4814 }
4815 0
4816}
4817
4818#[no_mangle]
4826pub extern "C" fn xmlGetCharEncodingName(enc: c_int) -> *const c_char {
4827 if enc < -1 || enc > 22 {
4831 return match enc {
4832 23 => c"UTF-16".as_ptr(),
4833 24 => c"HTML".as_ptr(),
4834 31 => c"windows-1252".as_ptr(),
4835 _ => ptr::null(),
4836 };
4837 }
4838 let e: crate::abi::types::xmlCharEncoding = unsafe { core::mem::transmute(enc) };
4839 crate::xml::encoding::xmlGetCharEncodingName(e)
4840}
4841
4842#[no_mangle]
4852pub extern "C" fn xmlParseCharEncoding(name: *const c_char) -> c_int {
4853 crate::xml::encoding::xmlParseCharEncoding(name)
4854}
4855
4856#[no_mangle]
4864pub extern "C" fn xmlAddEncodingAlias(name: *const c_char, alias: *const c_char) -> c_int {
4865 crate::xml::encoding::add_encoding_alias(name, alias)
4866}
4867
4868#[no_mangle]
4876pub extern "C" fn xmlDelEncodingAlias(alias: *const c_char) -> c_int {
4877 crate::xml::encoding::del_encoding_alias(alias)
4878}
4879
4880#[no_mangle]
4888pub extern "C" fn xmlGetEncodingAlias(alias: *const c_char) -> *const c_char {
4889 crate::xml::encoding::get_encoding_alias(alias)
4890}
4891
4892#[no_mangle]
4900pub extern "C" fn xmlCleanupEncodingAliases() {
4901 crate::xml::encoding::cleanup_encoding_aliases();
4902}
4903
4904#[no_mangle]
4913pub extern "C" fn xmlCharEncInFunc(
4914 handler: *mut c_void,
4915 out: *mut c_void,
4916 in_: *mut c_void,
4917) -> c_int {
4918 crate::xml::encoding::xmlCharEncInFunc(
4919 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
4920 out as *mut crate::abi::structs::_xmlBuffer,
4921 in_ as *mut crate::abi::structs::_xmlBuffer,
4922 )
4923}
4924
4925#[no_mangle]
4934pub extern "C" fn xmlCharEncOutFunc(
4935 handler: *mut c_void,
4936 out: *mut c_void,
4937 in_: *mut c_void,
4938) -> c_int {
4939 crate::xml::encoding::xmlCharEncOutFunc(
4940 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
4941 out as *mut crate::abi::structs::_xmlBuffer,
4942 in_ as *mut crate::abi::structs::_xmlBuffer,
4943 )
4944}
4945
4946#[no_mangle]
4956pub extern "C" fn xmlNewCharEncodingHandler(
4957 name: *const c_char,
4958 input: crate::abi::callbacks::xmlCharEncodingInputFunc,
4959 output: crate::abi::callbacks::xmlCharEncodingOutputFunc,
4960) -> *mut c_void {
4961 crate::xml::encoding::xmlNewCharEncodingHandler(name, input, output) as *mut c_void
4962}
4963
4964#[no_mangle]
4972pub extern "C" fn xmlInitCharEncodingHandlers() {
4973 crate::xml::encoding::xmlInitCharEncodingHandlers();
4974}
4975
4976#[no_mangle]
4984pub extern "C" fn xmlCleanupCharEncodingHandlers() {
4985 crate::xml::encoding::xmlCleanupCharEncodingHandlers();
4986}
4987
4988#[no_mangle]
5000pub extern "C" fn xmlLookupCharEncodingHandler(enc: c_int, out: *mut *mut c_void) -> c_int {
5001 crate::xml::encoding::xmlLookupCharEncodingHandler(enc, out)
5002}
5003
5004#[no_mangle]
5012pub extern "C" fn xmlGetCharEncodingHandler(enc: c_int) -> *mut c_void {
5013 crate::xml::encoding::xmlGetCharEncodingHandler(enc)
5014}
5015
5016#[no_mangle]
5025pub extern "C" fn xmlOpenCharEncodingHandler(
5026 name: *const c_char,
5027 output: c_int,
5028 out: *mut *mut c_void,
5029) -> c_int {
5030 crate::xml::encoding::xmlOpenCharEncodingHandler(name, output, out)
5031}
5032
5033#[no_mangle]
5044pub extern "C" fn xmlCreateCharEncodingHandler(
5045 name: *const c_char,
5046 flags: c_int,
5047 impl_: Option<crate::abi::callbacks::xmlCharEncConvImpl>,
5048 implCtxt: *mut c_void,
5049 out: *mut *mut c_void,
5050) -> c_int {
5051 crate::xml::encoding::xmlCreateCharEncodingHandler(name, flags, impl_, implCtxt, out)
5052}
5053
5054#[no_mangle]
5065pub extern "C" fn xmlCharEncNewCustomHandler(
5066 name: *const c_char,
5067 input: crate::abi::callbacks::xmlCharEncConvFunc,
5068 output: crate::abi::callbacks::xmlCharEncConvFunc,
5069 ctxtDtor: Option<crate::abi::callbacks::xmlCharEncConvCtxtDtor>,
5070 inputCtxt: *mut c_void,
5071 outputCtxt: *mut c_void,
5072 out: *mut *mut c_void,
5073) -> c_int {
5074 crate::xml::encoding::xmlCharEncNewCustomHandler(
5075 name, input, output, ctxtDtor, inputCtxt, outputCtxt, out,
5076 )
5077}
5078
5079#[no_mangle]
5087pub unsafe extern "C" fn xmlCharEncInput(input: *mut _xmlParserInputBuffer, _to: c_int) -> c_int {
5088 if input.is_null() {
5089 return -1;
5090 }
5091 let handler = (*input).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5092 if handler.is_null() {
5093 return -1;
5094 }
5095 let raw = (*input).raw as *mut crate::abi::structs::_xmlBuffer;
5096 let buf = (*input).buffer as *mut crate::abi::structs::_xmlBuffer;
5097 if raw.is_null() || buf.is_null() {
5098 return -1;
5099 }
5100 crate::xml::encoding::char_enc_in(handler, buf, raw)
5101}
5102
5103#[no_mangle]
5111pub unsafe extern "C" fn xmlCharEncOutput(output: *mut _xmlOutputBuffer, _to: c_int) -> c_int {
5112 if output.is_null() {
5113 return -1;
5114 }
5115 let handler = (*output).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5116 if handler.is_null() {
5117 return -1;
5118 }
5119 let buf = (*output).buffer as *mut crate::abi::structs::_xmlBuffer;
5120 let conv = (*output).conv as *mut crate::abi::structs::_xmlBuffer;
5121 if buf.is_null() || conv.is_null() {
5122 return -1;
5123 }
5124 crate::xml::encoding::char_enc_out(handler, conv, buf)
5125}
5126
5127#[no_mangle]
5139pub unsafe extern "C" fn xmlParseURI(str: *const c_char) -> *mut c_void {
5140 crate::xml::uri::xmlParseURI(str)
5141}
5142
5143#[no_mangle]
5151pub unsafe extern "C" fn xmlParseURIRaw(str: *const c_char, raw: c_int) -> *mut c_void {
5152 let _ = raw;
5153 crate::xml::uri::xmlParseURI(str)
5154}
5155
5156#[no_mangle]
5164pub unsafe extern "C" fn xmlFreeURI(uri: *mut c_void) {
5165 crate::xml::uri::xmlFreeURI(uri)
5166}
5167
5168#[no_mangle]
5176pub extern "C" fn xmlCreateURI() -> *mut c_void {
5177 crate::xml::uri::xmlCreateURI()
5178}
5179
5180#[no_mangle]
5188pub unsafe extern "C" fn xmlSaveUri(uri: *mut c_void) -> *mut xmlChar {
5189 crate::xml::uri::xmlSaveUri(uri)
5190}
5191
5192#[no_mangle]
5208pub unsafe extern "C" fn xmlParseURIReference(uri: *mut c_void, str: *const c_char) -> c_int {
5209 crate::xml::uri::xmlParseURIReference(uri, str)
5210}
5211
5212#[no_mangle]
5227pub unsafe extern "C" fn xmlNormalizeURIPath(path: *mut c_char) -> c_int {
5228 crate::xml::uri::xmlNormalizeURIPath(path)
5229}
5230
5231#[no_mangle]
5239pub unsafe extern "C" fn xmlURIEscapeStr(
5240 str: *const xmlChar,
5241 list: *const xmlChar,
5242) -> *mut xmlChar {
5243 crate::xml::uri::xmlURIEscapeStr(str, list)
5244}
5245
5246#[no_mangle]
5254pub unsafe extern "C" fn xmlURIUnescapeString(
5255 str: *const c_char,
5256 len: c_int,
5257 target: *mut c_char,
5258) -> *mut c_char {
5259 crate::xml::uri::xmlURIUnescapeString(str, len, target)
5260}
5261
5262unsafe fn xpath_to_object(val: XPathValue) -> *mut _xmlXPathObject {
5277 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
5278 if obj.is_null() {
5279 return ptr::null_mut();
5280 }
5281 match val {
5282 XPathValue::NodeSet(ns) => {
5283 (*obj).type_ = xmlXPathObjectType::XPATH_NODESET as c_int;
5284 (*obj).nodesetval = ns.to_raw() as *mut c_void;
5285 }
5286 XPathValue::Boolean(b) => {
5287 (*obj).type_ = xmlXPathObjectType::XPATH_BOOLEAN as c_int;
5288 (*obj).boolval = if b { 1 } else { 0 };
5289 }
5290 XPathValue::Number(n) => {
5291 (*obj).type_ = xmlXPathObjectType::XPATH_NUMBER as c_int;
5292 (*obj).floatval = n;
5293 }
5294 XPathValue::String(s) => {
5295 (*obj).type_ = xmlXPathObjectType::XPATH_STRING as c_int;
5296 let bytes = s.as_bytes();
5297 let len = bytes.len();
5298 let buf = xmlMalloc(len + 1) as *mut xmlChar;
5299 if !buf.is_null() {
5300 ptr::copy_nonoverlapping(bytes.as_ptr(), buf, len);
5301 *buf.add(len) = 0; }
5303 (*obj).stringval = buf;
5304 }
5305 }
5306 obj
5307}
5308
5309unsafe fn object_to_xpathvalue(obj: *mut _xmlXPathObject) -> XPathValue {
5316 let typ = (*obj).type_;
5317 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5318 let ns_ptr = (*obj).nodesetval as *mut _xmlNodeSet;
5319 if ns_ptr.is_null() {
5320 return XPathValue::NodeSet(NodeSet::new());
5321 }
5322 let node_nr = (*ns_ptr).nodeNr;
5323 let node_tab = (*ns_ptr).nodeTab;
5324 let mut ns = NodeSet::new();
5325 if !node_tab.is_null() {
5326 for i in 0..node_nr as isize {
5327 let node = *node_tab.add(i as usize);
5328 ns.push(node);
5329 }
5330 }
5331 XPathValue::NodeSet(ns)
5332 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5333 XPathValue::Boolean((*obj).boolval != 0)
5334 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5335 XPathValue::Number((*obj).floatval)
5336 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5337 let s_ptr = (*obj).stringval;
5338 if s_ptr.is_null() {
5339 XPathValue::String(String::new())
5340 } else {
5341 let s = CStr::from_ptr(s_ptr as *const c_char)
5342 .to_string_lossy()
5343 .into_owned();
5344 XPathValue::String(s)
5345 }
5346 } else if typ == xmlXPathObjectType::XPATH_XSLT_TREE as c_int {
5347 let frag_doc = (*obj).nodesetval as *mut _xmlDoc;
5352 if frag_doc.is_null() {
5353 XPathValue::NodeSet(NodeSet::new())
5354 } else {
5355 let mut ns = NodeSet::new();
5356 ns.push(frag_doc as *mut _xmlNode);
5357 XPathValue::NodeSet(ns)
5358 }
5359 } else {
5360 XPathValue::Boolean(false)
5362 }
5363}
5364
5365pub unsafe fn xpath_to_object_pub(val: XPathValue) -> *mut _xmlXPathObject {
5371 xpath_to_object(val)
5372}
5373
5374pub unsafe fn object_to_xpathvalue_pub(obj: *mut _xmlXPathObject) -> XPathValue {
5381 object_to_xpathvalue(obj)
5382}
5383
5384static COMPILED_EXPRS: Lazy<Mutex<HashMap<u64, Box<CompiledExpr>>>> =
5390 Lazy::new(|| Mutex::new(HashMap::new()));
5391static NEXT_COMPILED_KEY: Lazy<Mutex<u64>> = Lazy::new(|| Mutex::new(1));
5392
5393pub(crate) fn xpath_compiled_registry() -> &'static Mutex<HashMap<u64, Box<CompiledExpr>>> {
5396 &COMPILED_EXPRS
5397}
5398
5399type CXPathFunc = unsafe extern "C" fn(*mut c_void, c_int);
5409
5410#[derive(Clone, Copy, PartialEq, Eq, Hash)]
5413struct SendSyncPtr(*mut c_void);
5414unsafe impl Send for SendSyncPtr {}
5415unsafe impl Sync for SendSyncPtr {}
5416
5417static C_FUNCTIONS: Lazy<Mutex<HashMap<(SendSyncPtr, String), CXPathFunc>>> =
5418 Lazy::new(|| Mutex::new(HashMap::new()));
5419
5420pub(crate) fn xpath_cfunc_lookup(extra: *mut c_void, qualified: &str) -> Option<CXPathFunc> {
5424 C_FUNCTIONS
5425 .lock()
5426 .get(&(SendSyncPtr(extra), qualified.to_string()))
5427 .copied()
5428}
5429
5430pub(crate) fn xpath_cfunc_cleanup(extra: *mut c_void) {
5433 C_FUNCTIONS.lock().retain(|(k, _), _| k.0 != extra);
5434}
5435
5436fn c_func_stub(_ctx: &mut XPathContext, _args: &[XPathValue]) -> Result<XPathValue, String> {
5441 Err(
5442 "C extension function cannot be called from Rust evaluator without a parser-context bridge"
5443 .to_string(),
5444 )
5445}
5446
5447#[no_mangle]
5460pub unsafe extern "C" fn xmlXPathNewContext(doc: *mut _xmlDoc) -> *mut _xmlXPathContext {
5461 let ctxt = xmlMallocZero(size_of::<_xmlXPathContext>()) as *mut _xmlXPathContext;
5462 if ctxt.is_null() {
5463 return ptr::null_mut();
5464 }
5465
5466 (*ctxt).doc = doc;
5468 (*ctxt).node = ptr::null_mut();
5469 (*ctxt).contextSize = 1;
5470 (*ctxt).proximityPosition = 1;
5471
5472 let mut internal = Box::new(XPathContext::new(doc));
5474 for (name, func) in crate::xml::xpath::functions::core_functions() {
5479 internal.register_function(&name, func);
5480 }
5481 (*ctxt).extra = Box::into_raw(internal) as *mut c_void;
5482
5483 ctxt
5484}
5485
5486#[no_mangle]
5494pub unsafe extern "C" fn xmlXPathFreeContext(ctxt: *mut _xmlXPathContext) {
5495 if ctxt.is_null() {
5496 return;
5497 }
5498 if !(*ctxt).extra.is_null() {
5500 let _ = Box::from_raw((*ctxt).extra as *mut XPathContext);
5501 (*ctxt).extra = ptr::null_mut();
5502 }
5503 if !(*ctxt).nsHash.is_null() {
5505 drop(Box::from_raw(
5506 (*ctxt).nsHash as *mut HashMap<String, CString>,
5507 ));
5508 (*ctxt).nsHash = ptr::null_mut();
5509 }
5510 xmlFree(ctxt as *mut c_void);
5512}
5513
5514#[no_mangle]
5523pub unsafe extern "C" fn xmlXPathEvalExpression(
5524 str_: *const xmlChar,
5525 ctxt: *mut _xmlXPathContext,
5526) -> *mut _xmlXPathObject {
5527 if str_.is_null() || ctxt.is_null() {
5528 return ptr::null_mut();
5529 }
5530 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
5531 Ok(s) => s,
5532 Err(_) => return ptr::null_mut(),
5533 };
5534 let internal = (*ctxt).extra as *mut XPathContext;
5535 if internal.is_null() {
5536 return ptr::null_mut();
5537 }
5538 let internal = &mut *internal;
5539
5540 match crate::xml::xpath::evaluate_str(expr_str, internal) {
5541 Some(val) => xpath_to_object(val),
5542 None => {
5543 if internal.error.is_none() {
5548 internal.set_error("Invalid expression");
5549 }
5550 ptr::null_mut()
5551 }
5552 }
5553}
5554
5555#[no_mangle]
5563pub unsafe extern "C" fn xmlXPathEval(
5564 str_: *const xmlChar,
5565 ctxt: *mut _xmlXPathContext,
5566) -> *mut _xmlXPathObject {
5567 xmlXPathEvalExpression(str_, ctxt)
5568}
5569
5570#[no_mangle]
5581pub unsafe extern "C" fn xmlXPathFreeObject(obj: *mut _xmlXPathObject) {
5582 if obj.is_null() {
5583 return;
5584 }
5585 let typ = (*obj).type_;
5586 if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5588 if !(*obj).stringval.is_null() {
5589 xmlFree((*obj).stringval as *mut c_void);
5590 (*obj).stringval = ptr::null_mut();
5591 }
5592 }
5593 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5595 let ns = (*obj).nodesetval as *mut _xmlNodeSet;
5596 if !ns.is_null() {
5597 if !(*ns).nodeTab.is_null() {
5598 xmlFree((*ns).nodeTab as *mut c_void);
5599 }
5600 xmlFree(ns as *mut c_void);
5601 }
5602 (*obj).nodesetval = ptr::null_mut();
5603 }
5604 xmlFree(obj as *mut c_void);
5605}
5606
5607#[no_mangle]
5619pub unsafe extern "C" fn xmlXPathObjectCopy(val: *mut _xmlXPathObject) -> *mut _xmlXPathObject {
5620 if val.is_null() {
5621 return ptr::null_mut();
5622 }
5623 let typ = (*val).type_;
5624 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
5625 if obj.is_null() {
5626 return ptr::null_mut();
5627 }
5628 (*obj).type_ = typ;
5629 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5630 let src_ns = (*val).nodesetval as *mut _xmlNodeSet;
5631 if !src_ns.is_null() {
5632 let nr = (*src_ns).nodeNr;
5633 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
5634 if ns.is_null() {
5635 xmlFree(obj as *mut c_void);
5636 return ptr::null_mut();
5637 }
5638 (*ns).nodeNr = nr;
5639 (*ns).nodeMax = nr;
5640 if nr > 0 && !(*src_ns).nodeTab.is_null() {
5641 let tab = xmlMalloc((nr as usize) * core::mem::size_of::<*mut _xmlNode>())
5642 as *mut *mut _xmlNode;
5643 if tab.is_null() {
5644 xmlFree(ns as *mut c_void);
5645 xmlFree(obj as *mut c_void);
5646 return ptr::null_mut();
5647 }
5648 ptr::copy_nonoverlapping((*src_ns).nodeTab, tab, nr as usize);
5649 (*ns).nodeTab = tab;
5650 } else {
5651 (*ns).nodeTab = ptr::null_mut();
5652 }
5653 (*obj).nodesetval = ns as *mut c_void;
5654 }
5655 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5656 (*obj).boolval = (*val).boolval;
5657 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5658 (*obj).floatval = (*val).floatval;
5659 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5660 let src = (*val).stringval;
5661 if !src.is_null() {
5662 let len = libc::strlen(src as *const libc::c_char);
5663 let buf = xmlMalloc(len + 1) as *mut xmlChar;
5664 if !buf.is_null() {
5665 ptr::copy_nonoverlapping(src, buf, len);
5666 *buf.add(len) = 0;
5667 }
5668 (*obj).stringval = buf;
5669 }
5670 }
5671 obj
5672}
5673
5674#[no_mangle]
5684pub unsafe extern "C" fn xmlXPathCastToString(val: *mut _xmlXPathObject) -> *mut xmlChar {
5685 if val.is_null() {
5686 return ptr::null_mut();
5687 }
5688 let typ = (*val).type_;
5689 let mut result: Vec<u8> = Vec::new();
5690 if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5691 if !(*val).stringval.is_null() {
5692 let len = libc::strlen((*val).stringval as *const libc::c_char);
5693 result.extend_from_slice(core::slice::from_raw_parts((*val).stringval, len));
5694 }
5695 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5696 let n = (*val).floatval;
5702 result.extend_from_slice(xml_number_to_string(n).as_bytes());
5703 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5704 result.extend_from_slice(if (*val).boolval != 0 {
5705 b"true"
5706 } else {
5707 b"false"
5708 });
5709 } else if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5710 let ns = (*val).nodesetval as *mut _xmlNodeSet;
5713 if !ns.is_null() && (*ns).nodeNr > 0 && !(*ns).nodeTab.is_null() {
5714 let node = *(*ns).nodeTab;
5715 if !node.is_null() {
5716 let content = crate::xml::tree::node_get_content(node);
5717 if !content.is_null() {
5718 let len = libc::strlen(content as *const libc::c_char);
5719 result.extend_from_slice(core::slice::from_raw_parts(content, len));
5720 xmlFree(content as *mut c_void);
5721 }
5722 }
5723 }
5724 }
5725 let buf = xmlMalloc(result.len() + 1) as *mut xmlChar;
5727 if buf.is_null() {
5728 return ptr::null_mut();
5729 }
5730 if !result.is_empty() {
5731 ptr::copy_nonoverlapping(result.as_ptr(), buf, result.len());
5732 }
5733 *buf.add(result.len()) = 0;
5734 buf
5735}
5736
5737pub fn xml_number_to_string(n: f64) -> String {
5741 if n.is_nan() {
5742 return "NaN".to_string();
5743 }
5744 if n.is_infinite() {
5745 return if n > 0.0 {
5746 "Infinity".to_string()
5747 } else {
5748 "-Infinity".to_string()
5749 };
5750 }
5751 if n == 0.0 {
5752 return "0".to_string();
5754 }
5755 if n.fract() == 0.0 && n.abs() < 1e15 {
5757 return format!("{:.0}", n);
5758 }
5759 let mut s = format!("{:.15}", n);
5763 if s.contains('.') {
5765 while s.ends_with('0') {
5766 s.pop();
5767 }
5768 if s.ends_with('.') {
5769 s.pop();
5770 }
5771 }
5772 if s == "-0" {
5773 return "0".to_string();
5774 }
5775 s
5776}
5777
5778#[no_mangle]
5786pub unsafe extern "C" fn xmlXPathCastStringToNumber(val: *const xmlChar) -> f64 {
5787 if val.is_null() {
5788 return f64::NAN;
5789 }
5790 let len = libc::strlen(val as *const libc::c_char);
5791 let bytes = core::slice::from_raw_parts(val, len);
5792 let mut i = 0;
5794 while i < bytes.len() && matches!(bytes[i], b' ' | b'\t' | b'\n' | b'\r') {
5795 i += 1;
5796 }
5797 let s = &bytes[i..];
5798 if s.is_empty() {
5799 return f64::NAN;
5800 }
5801 let (sign, rest) = match s[0] {
5803 b'+' => (1.0f64, &s[1..]),
5804 b'-' => (-1.0f64, &s[1..]),
5805 _ => (1.0f64, s),
5806 };
5807 if rest.is_empty() {
5808 return f64::NAN;
5809 }
5810 let num_str = core::str::from_utf8(rest);
5813 match num_str {
5814 Ok(s) => {
5815 let valid = is_xpath_number(s);
5818 if !valid {
5819 f64::NAN
5820 } else {
5821 s.trim()
5822 .parse::<f64>()
5823 .map(|v| v * sign)
5824 .unwrap_or(f64::NAN)
5825 }
5826 }
5827 Err(_) => f64::NAN,
5828 }
5829}
5830
5831fn is_xpath_number(s: &str) -> bool {
5833 let b = s.as_bytes();
5834 if b.is_empty() {
5835 return false;
5836 }
5837 let mut i = 0;
5838 let mut saw_digit = false;
5839 while i < b.len() && b[i].is_ascii_digit() {
5840 saw_digit = true;
5841 i += 1;
5842 }
5843 if i < b.len() && b[i] == b'.' {
5844 i += 1;
5845 while i < b.len() && b[i].is_ascii_digit() {
5846 saw_digit = true;
5847 i += 1;
5848 }
5849 }
5850 if !saw_digit {
5851 return false;
5852 }
5853 if i < b.len() && (b[i] == b'e' || b[i] == b'E') {
5854 i += 1;
5855 if i < b.len() && (b[i] == b'+' || b[i] == b'-') {
5856 i += 1;
5857 }
5858 let mut saw_exp = false;
5859 while i < b.len() && b[i].is_ascii_digit() {
5860 saw_exp = true;
5861 i += 1;
5862 }
5863 if !saw_exp {
5864 return false;
5865 }
5866 }
5867 i == b.len()
5868}
5869
5870#[no_mangle]
5885pub unsafe extern "C" fn xmlXPathCmpNodes(node1: *mut _xmlNode, node2: *mut _xmlNode) -> c_int {
5886 if node1.is_null() || node2.is_null() {
5887 return 0;
5888 }
5889 if node1 == node2 {
5890 return 0;
5891 }
5892 let mut chain1: Vec<*mut _xmlNode> = Vec::new();
5894 let mut chain2: Vec<*mut _xmlNode> = Vec::new();
5895 let mut n = node1;
5896 while !n.is_null() {
5897 chain1.push(n);
5898 n = (*n).parent as *mut _xmlNode;
5899 }
5900 let mut n = node2;
5901 while !n.is_null() {
5902 chain2.push(n);
5903 n = (*n).parent as *mut _xmlNode;
5904 }
5905 let mut i = chain1.len();
5907 let mut j = chain2.len();
5908 while i > 0 && j > 0 && chain1[i - 1] == chain2[j - 1] {
5909 i -= 1;
5910 j -= 1;
5911 }
5912 if i == 0 && j == 0 {
5913 return 0; }
5915 if i == 0 {
5916 return -1; }
5918 if j == 0 {
5919 return 1; }
5921 let mut a = chain1[i - 1];
5923 let mut b = chain2[j - 1];
5924 while !a.is_null() && !b.is_null() {
5926 let pa = (*a).parent as *mut _xmlNode;
5927 let pb = (*b).parent as *mut _xmlNode;
5928 if pa == pb {
5929 break;
5930 }
5931 a = pa;
5932 b = pb;
5933 }
5934 let parent = (*a).parent as *mut _xmlNode;
5936 let mut child = if parent.is_null() {
5937 ptr::null_mut()
5938 } else {
5939 (*parent).children
5940 };
5941 while !child.is_null() {
5942 if child == a {
5943 return -1;
5944 }
5945 if child == b {
5946 return 1;
5947 }
5948 child = (*child).next;
5949 }
5950 0
5951}
5952
5953#[no_mangle]
5963pub unsafe extern "C" fn xmlXPathNodeSetCreate(val: *mut _xmlNode) -> *mut _xmlNodeSet {
5964 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
5965 if ns.is_null() {
5966 return ptr::null_mut();
5967 }
5968 if val.is_null() {
5969 return ns;
5970 }
5971 let tab = xmlMalloc(core::mem::size_of::<*mut _xmlNode>()) as *mut *mut _xmlNode;
5972 if tab.is_null() {
5973 xmlFree(ns as *mut c_void);
5974 return ptr::null_mut();
5975 }
5976 *tab = val;
5977 (*ns).nodeTab = tab;
5978 (*ns).nodeNr = 1;
5979 (*ns).nodeMax = 1;
5980 ns
5981}
5982
5983#[no_mangle]
5995pub unsafe extern "C" fn xmlXPathFreeNodeSet(ns: *mut _xmlNodeSet) {
5996 if ns.is_null() {
5997 return;
5998 }
5999 if !(*ns).nodeTab.is_null() {
6000 xmlFree((*ns).nodeTab as *mut c_void);
6001 (*ns).nodeTab = ptr::null_mut();
6002 }
6003 (*ns).nodeNr = 0;
6004 (*ns).nodeMax = 0;
6005 xmlFree(ns as *mut c_void);
6006}
6007
6008#[no_mangle]
6019pub unsafe extern "C" fn xmlXPathCompile(str_: *const xmlChar) -> *mut c_void {
6020 if str_.is_null() {
6021 return ptr::null_mut();
6022 }
6023 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
6024 Ok(s) => s,
6025 Err(_) => return ptr::null_mut(),
6026 };
6027
6028 match crate::xml::xpath::compile(expr_str) {
6029 Some(compiled) => {
6030 let mut map = COMPILED_EXPRS.lock();
6031 let mut counter = NEXT_COMPILED_KEY.lock();
6032 let key = *counter;
6033 *counter += 1;
6034 map.insert(key, Box::new(compiled));
6035 key as *mut c_void
6036 }
6037 None => ptr::null_mut(),
6038 }
6039}
6040
6041#[no_mangle]
6049pub unsafe extern "C" fn xmlXPathFreeCompExpr(comp: *mut c_void) {
6050 if comp.is_null() {
6051 return;
6052 }
6053 let mut map = COMPILED_EXPRS.lock();
6054 map.remove(&(comp as u64));
6055}
6056
6057#[no_mangle]
6066pub unsafe extern "C" fn xmlXPathRegisterNs(
6067 ctxt: *mut _xmlXPathContext,
6068 prefix: *const xmlChar,
6069 ns_uri: *const xmlChar,
6070) -> c_int {
6071 if ctxt.is_null() || prefix.is_null() || ns_uri.is_null() {
6072 return -1;
6073 }
6074 let internal = (*ctxt).extra as *mut XPathContext;
6075 if internal.is_null() {
6076 return -1;
6077 }
6078 let internal = &mut *internal;
6079
6080 let prefix_str = match CStr::from_ptr(prefix as *const c_char).to_str() {
6081 Ok(s) => s,
6082 Err(_) => return -1,
6083 };
6084 let uri_str = match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6085 Ok(s) => s,
6086 Err(_) => return -1,
6087 };
6088
6089 internal.register_namespace(prefix_str, uri_str);
6090
6091 let map: &mut HashMap<String, CString> = if (*ctxt).nsHash.is_null() {
6096 let b: Box<HashMap<String, CString>> = Box::new(HashMap::new());
6097 (*ctxt).nsHash = Box::into_raw(b) as *mut c_void;
6098 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6099 } else {
6100 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6101 };
6102 map.insert(
6103 prefix_str.to_string(),
6104 CString::new(uri_str.as_bytes()).unwrap_or_default(),
6105 );
6106 0
6107}
6108
6109#[no_mangle]
6123pub unsafe extern "C" fn xmlXPathRegisterFunc(
6124 ctxt: *mut _xmlXPathContext,
6125 name: *const xmlChar,
6126 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6127) -> c_int {
6128 if ctxt.is_null() || name.is_null() {
6129 return -1;
6130 }
6131 let internal = (*ctxt).extra as *mut XPathContext;
6132 if internal.is_null() {
6133 return -1;
6134 }
6135 let internal = &mut *internal;
6136
6137 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6138 Ok(s) => s,
6139 Err(_) => return -1,
6140 };
6141
6142 if let Some(func) = f {
6143 let key = (SendSyncPtr((*ctxt).extra), name_str.to_string());
6145 C_FUNCTIONS.lock().insert(key, func);
6146 internal.register_function(name_str, c_func_stub);
6148 }
6149 0
6150}
6151
6152#[no_mangle]
6162pub unsafe extern "C" fn xmlXPathRegisterFuncNS(
6163 ctxt: *mut _xmlXPathContext,
6164 name: *const xmlChar,
6165 ns_uri: *const xmlChar,
6166 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6167) -> c_int {
6168 if ctxt.is_null() || name.is_null() {
6169 return -1;
6170 }
6171 let internal = (*ctxt).extra as *mut XPathContext;
6172 if internal.is_null() {
6173 return -1;
6174 }
6175 let internal = &mut *internal;
6176
6177 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6178 Ok(s) => s,
6179 Err(_) => return -1,
6180 };
6181 let ns_str = if ns_uri.is_null() {
6182 String::new()
6183 } else {
6184 match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6185 Ok(s) => s.to_string(),
6186 Err(_) => return -1,
6187 }
6188 };
6189
6190 let qualified = if ns_str.is_empty() {
6192 name_str.to_string()
6193 } else {
6194 format!("{{{}}}{}", ns_str, name_str)
6195 };
6196
6197 if let Some(func) = f {
6198 let key = (SendSyncPtr((*ctxt).extra), qualified.clone());
6199 C_FUNCTIONS.lock().insert(key, func);
6200 internal.register_function(&qualified, c_func_stub);
6201 }
6202 0
6203}
6204
6205#[no_mangle]
6214pub unsafe extern "C" fn xmlXPathRegisterVariable(
6215 ctxt: *mut _xmlXPathContext,
6216 name: *const xmlChar,
6217 value: *mut _xmlXPathObject,
6218) -> c_int {
6219 if ctxt.is_null() || name.is_null() || value.is_null() {
6220 return -1;
6221 }
6222 let internal = (*ctxt).extra as *mut XPathContext;
6223 if internal.is_null() {
6224 return -1;
6225 }
6226 let internal = &mut *internal;
6227
6228 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6229 Ok(s) => s,
6230 Err(_) => return -1,
6231 };
6232
6233 let xpath_val = object_to_xpathvalue(value);
6234 internal.register_variable(name_str, xpath_val);
6235 0
6236}
6237
6238#[no_mangle]
6246pub unsafe extern "C" fn xmlXPathNewNodeSet(val: *mut _xmlNode) -> *mut _xmlXPathObject {
6247 let ns = if val.is_null() {
6248 NodeSet::new()
6249 } else {
6250 NodeSet::singleton(val)
6251 };
6252 xpath_to_object(XPathValue::NodeSet(ns))
6253}
6254
6255#[no_mangle]
6263pub unsafe extern "C" fn xmlXPathNewCString(val: *const xmlChar) -> *mut _xmlXPathObject {
6264 if val.is_null() {
6265 return xpath_to_object(XPathValue::String(String::new()));
6266 }
6267 let s = match CStr::from_ptr(val as *const c_char).to_str() {
6268 Ok(s) => s.to_string(),
6269 Err(_) => return ptr::null_mut(),
6270 };
6271 xpath_to_object(XPathValue::String(s))
6272}
6273
6274#[no_mangle]
6282pub extern "C" fn xmlXPathNewFloat(val: f64) -> *mut _xmlXPathObject {
6283 unsafe { xpath_to_object(XPathValue::Number(val)) }
6284}
6285
6286#[no_mangle]
6294pub extern "C" fn xmlXPathNewBoolean(val: c_int) -> *mut _xmlXPathObject {
6295 unsafe { xpath_to_object(XPathValue::Boolean(val != 0)) }
6296}
6297
6298#[no_mangle]
6312pub unsafe extern "C" fn xmlXPtrEval(expr: *const c_char, doc: *mut _xmlDoc) -> *mut _xmlNode {
6313 crate::xml::xpointer::xmlXPtrEval(expr, doc)
6314}
6315
6316#[no_mangle]
6328pub unsafe extern "C" fn xmlXIncludeProcess(doc: *mut _xmlDoc) -> c_int {
6329 crate::xml::xinclude::xinclude_process(doc)
6330}
6331
6332#[no_mangle]
6340pub unsafe extern "C" fn xmlXIncludeProcessFlags(doc: *mut _xmlDoc, flags: c_int) -> c_int {
6341 crate::xml::xinclude::xinclude_process_flags(doc, flags)
6342}
6343
6344#[no_mangle]
6356pub extern "C" fn xmlCatalogLoad(catalogs: *const c_char) -> *mut c_void {
6357 if catalogs.is_null() {
6358 return ptr::null_mut();
6359 }
6360 crate::xml::catalog::load_catalog(catalogs)
6361}
6362
6363#[no_mangle]
6371pub unsafe extern "C" fn xmlCatalogResolvePublic(pubID: *const xmlChar) -> *mut xmlChar {
6372 if pubID.is_null() {
6373 return ptr::null_mut();
6374 }
6375 crate::xml::catalog::resolve_public(pubID)
6376}
6377
6378#[no_mangle]
6386pub unsafe extern "C" fn xmlCatalogResolveSystem(sysID: *const xmlChar) -> *mut xmlChar {
6387 if sysID.is_null() {
6388 return ptr::null_mut();
6389 }
6390 crate::xml::catalog::resolve_system(sysID)
6391}
6392
6393#[no_mangle]
6401pub unsafe extern "C" fn xmlCatalogResolveURI(URI: *const xmlChar) -> *mut xmlChar {
6402 if URI.is_null() {
6403 return ptr::null_mut();
6404 }
6405 crate::xml::catalog::resolve_uri(URI)
6406}
6407
6408#[no_mangle]
6416pub extern "C" fn xmlCatalogSetDefaults(allow: c_int) {
6417 crate::xml::catalog::set_defaults(allow)
6418}
6419
6420#[no_mangle]
6428pub extern "C" fn xmlCatalogGetDefaults() -> c_int {
6429 crate::xml::catalog::get_defaults()
6430}
6431
6432#[no_mangle]
6440pub unsafe extern "C" fn xmlCatalogAdd(
6441 type_: *const xmlChar,
6442 orig: *const xmlChar,
6443 replace: *const xmlChar,
6444) -> c_int {
6445 if type_.is_null() || orig.is_null() || replace.is_null() {
6446 return -1;
6447 }
6448 crate::xml::catalog::add(type_, orig, replace)
6449}
6450
6451#[no_mangle]
6459pub unsafe extern "C" fn xmlCatalogRemove(value: *const xmlChar) -> c_int {
6460 if value.is_null() {
6461 return 0;
6462 }
6463 crate::xml::catalog::remove(value)
6464}
6465
6466#[no_mangle]
6474pub unsafe extern "C" fn xmlCatalogDump(output: *mut c_void, _catal: *mut c_void) {
6475 if output.is_null() {
6476 return;
6477 }
6478 let doc = crate::xml::catalog::dump_doc();
6479 if doc.is_null() {
6480 return;
6481 }
6482 let mut mem: *mut xmlChar = ptr::null_mut();
6483 let mut size: c_int = 0;
6484 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6485 if !mem.is_null() {
6486 libc::fwrite(
6487 mem as *const c_void,
6488 1,
6489 size as usize,
6490 output as *mut libc::FILE,
6491 );
6492 xmlFree(mem as *mut c_void);
6493 }
6494 crate::xml::tree::free_doc(doc);
6495}
6496
6497#[no_mangle]
6507pub unsafe extern "C" fn xmlCatalogSave(filename: *const c_char) -> c_int {
6508 if filename.is_null() {
6509 return -1;
6510 }
6511 let doc = crate::xml::catalog::dump_doc();
6512 if doc.is_null() {
6513 return -1;
6514 }
6515 let mut mem: *mut xmlChar = ptr::null_mut();
6516 let mut size: c_int = 0;
6517 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6518 let mut ret: c_int = -1;
6519 if !mem.is_null() {
6520 let fp = libc::fopen(filename, b"w\0".as_ptr() as *const c_char);
6521 if !fp.is_null() {
6522 let written = libc::fwrite(mem as *const c_void, 1, size as usize, fp);
6523 ret = if written == size as usize { 0 } else { -1 };
6524 libc::fclose(fp);
6525 }
6526 xmlFree(mem as *mut c_void);
6527 }
6528 crate::xml::tree::free_doc(doc);
6529 ret
6530}
6531
6532#[no_mangle]
6540pub extern "C" fn xmlCatalogCleanup() {
6541 crate::xml::catalog::cleanup();
6542}
6543
6544#[no_mangle]
6552pub extern "C" fn xmlCatalogConvert() -> *mut _xmlDoc {
6553 unsafe { crate::xml::catalog::convert() }
6555}
6556
6557#[no_mangle]
6569pub unsafe extern "C" fn htmlParseFile(
6570 _filename: *const c_char,
6571 _encoding: *const c_char,
6572) -> *mut _xmlDoc {
6573 ptr::null_mut()
6575}
6576
6577#[no_mangle]
6585pub unsafe extern "C" fn htmlParseMemory(_buffer: *const c_char, _size: c_int) -> *mut _xmlDoc {
6586 ptr::null_mut()
6588}
6589
6590#[no_mangle]
6598pub unsafe extern "C" fn htmlParseDoc(
6599 _cur: *const xmlChar,
6600 _encoding: *const c_char,
6601) -> *mut _xmlDoc {
6602 ptr::null_mut()
6604}
6605
6606#[no_mangle]
6615pub unsafe extern "C" fn htmlCreateFileParserCtxt(
6616 _filename: *const c_char,
6617 _encoding: *const c_char,
6618) -> *mut c_void {
6619 ptr::null_mut()
6621}
6622
6623#[no_mangle]
6631pub extern "C" fn htmlFreeParserCtxt(ctxt: *mut c_void) {
6632 unsafe { crate::xml::html::free_parser_ctxt(ctxt) }
6633}
6634
6635#[no_mangle]
6643pub extern "C" fn htmlInitParser() {
6644 }
6646
6647#[no_mangle]
6655pub extern "C" fn htmlCleanupParser() {
6656 }
6658
6659#[no_mangle]
6671pub unsafe extern "C" fn xmlNewValidCtxt() -> *mut _xmlValidCtxt {
6672 crate::xml::validation::new_valid_ctxt()
6673}
6674
6675#[no_mangle]
6683pub unsafe extern "C" fn xmlFreeValidCtxt(ctxt: *mut _xmlValidCtxt) {
6684 crate::xml::validation::free_valid_ctxt(ctxt);
6685}
6686
6687#[no_mangle]
6698pub unsafe extern "C" fn xmlSetValidErrors(
6699 ctxt: *mut _xmlValidCtxt,
6700 err: Option<xmlGenericErrorFunc>,
6701 warn: Option<xmlGenericErrorFunc>,
6702 data: *mut c_void,
6703) {
6704 crate::xml::validation::set_valid_errors(ctxt, err, warn, data);
6705}
6706
6707#[no_mangle]
6715pub unsafe extern "C" fn xmlValidateDocument(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
6716 crate::xml::validation::validate_document(ctxt, doc)
6717}
6718
6719#[no_mangle]
6727pub unsafe extern "C" fn xmlValidateDocumentFinal(
6728 ctxt: *mut _xmlValidCtxt,
6729 doc: *mut _xmlDoc,
6730) -> c_int {
6731 crate::xml::validation::validate_document_final(ctxt, doc)
6732}
6733
6734#[no_mangle]
6744pub unsafe extern "C" fn xmlValidateElement(
6745 ctxt: *mut _xmlValidCtxt,
6746 doc: *mut _xmlDoc,
6747 elem: *mut _xmlNode,
6748) -> c_int {
6749 crate::xml::validation::validate_element(ctxt, doc, elem)
6750}
6751
6752#[no_mangle]
6763pub unsafe extern "C" fn xmlValidateAttributeDecl(
6764 ctxt: *mut _xmlValidCtxt,
6765 doc: *mut _xmlDoc,
6766 elem: *mut _xmlNode,
6767 attr: *mut _xmlAttribute,
6768) -> c_int {
6769 crate::xml::validation::validate_attribute_decl(ctxt, doc, elem, attr)
6770}
6771
6772#[no_mangle]
6780pub unsafe extern "C" fn xmlValidateAttributeValue(atype: c_int, value: *const xmlChar) -> c_int {
6781 crate::xml::validation::validate_attribute_value(atype, value)
6782}
6783
6784#[no_mangle]
6794pub unsafe extern "C" fn xmlValidateNotationUse(
6795 ctxt: *mut _xmlValidCtxt,
6796 doc: *mut _xmlDoc,
6797 notation_name: *const xmlChar,
6798) -> c_int {
6799 crate::xml::validation::validate_notation_use(ctxt, doc, notation_name)
6800}
6801
6802#[no_mangle]
6813pub unsafe extern "C" fn xmlValidateID(
6814 ctxt: *mut _xmlValidCtxt,
6815 doc: *mut _xmlDoc,
6816 node: *mut _xmlNode,
6817 value: *const xmlChar,
6818) -> c_int {
6819 crate::xml::validation::validate_id(ctxt, doc, node, value)
6820}
6821
6822#[no_mangle]
6833pub unsafe extern "C" fn xmlValidateIDRef(
6834 ctxt: *mut _xmlValidCtxt,
6835 doc: *mut _xmlDoc,
6836 node: *mut _xmlNode,
6837 value: *const xmlChar,
6838) -> c_int {
6839 crate::xml::validation::validate_id_ref(ctxt, doc, node, value)
6840}
6841
6842#[no_mangle]
6853pub unsafe extern "C" fn xmlValidateIDRefs(
6854 ctxt: *mut _xmlValidCtxt,
6855 doc: *mut _xmlDoc,
6856 node: *mut _xmlNode,
6857 value: *const xmlChar,
6858) -> c_int {
6859 crate::xml::validation::validate_id_refs(ctxt, doc, node, value)
6860}
6861
6862#[no_mangle]
6872pub unsafe extern "C" fn xmlValidateNCName(value: *const xmlChar, space: c_int) -> c_int {
6873 crate::xml::validation::validate_ncname(value, space)
6874}
6875
6876#[no_mangle]
6884pub unsafe extern "C" fn xmlValidateQName(value: *const xmlChar, space: c_int) -> c_int {
6885 crate::xml::validation::validate_qname(value, space)
6886}
6887
6888#[no_mangle]
6901pub unsafe extern "C" fn xmlValidateName(value: *const xmlChar, space: c_int) -> c_int {
6902 crate::xml::validation::validate_name_space(value, space)
6903}
6904
6905#[no_mangle]
6913pub unsafe extern "C" fn xmlValidateNMToken(value: *const xmlChar, space: c_int) -> c_int {
6914 crate::xml::validation::validate_nmtoken_space(value, space)
6915}
6916
6917#[no_mangle]
6927pub unsafe extern "C" fn xmlValidateNameValue(value: *const xmlChar) -> c_int {
6928 crate::xml::validation::validate_name_value(value)
6929}
6930
6931#[no_mangle]
6940pub unsafe extern "C" fn xmlValidateNamesValue(value: *const xmlChar) -> c_int {
6941 crate::xml::validation::validate_names_value(value)
6942}
6943
6944#[no_mangle]
6952pub unsafe extern "C" fn xmlValidateNmtokenValue(value: *const xmlChar) -> c_int {
6953 crate::xml::validation::validate_nmtoken_value(value)
6954}
6955
6956#[no_mangle]
6964pub unsafe extern "C" fn xmlValidateNmtokensValue(value: *const xmlChar) -> c_int {
6965 crate::xml::validation::validate_nmtokens_value(value)
6966}
6967
6968#[no_mangle]
6979pub unsafe extern "C" fn xmlValidateElementDecl(
6980 ctxt: *mut _xmlValidCtxt,
6981 doc: *mut _xmlDoc,
6982 elem: *mut _xmlElement,
6983) -> c_int {
6984 crate::xml::validation::validate_element_decl(ctxt, doc, elem)
6985}
6986
6987#[no_mangle]
7000pub unsafe extern "C" fn xmlValidateNotationDecl(
7001 ctxt: *mut _xmlValidCtxt,
7002 doc: *mut _xmlDoc,
7003 nota: *mut _xmlNotation,
7004) -> c_int {
7005 crate::xml::validation::validate_notation_decl(ctxt, doc, nota)
7006}
7007
7008#[no_mangle]
7020pub unsafe extern "C" fn xmlValidateOneAttribute(
7021 ctxt: *mut _xmlValidCtxt,
7022 doc: *mut _xmlDoc,
7023 elem: *mut _xmlNode,
7024 attr: *mut _xmlAttr,
7025 value: *const xmlChar,
7026) -> c_int {
7027 crate::xml::validation::validate_one_attribute(ctxt, doc, elem, attr, value)
7028}
7029
7030#[no_mangle]
7040pub unsafe extern "C" fn xmlValidateOneElement(
7041 ctxt: *mut _xmlValidCtxt,
7042 doc: *mut _xmlDoc,
7043 elem: *mut _xmlNode,
7044) -> c_int {
7045 crate::xml::validation::validate_one_element(ctxt, doc, elem)
7046}
7047
7048#[no_mangle]
7061pub unsafe extern "C" fn xmlValidateOneNamespace(
7062 ctxt: *mut _xmlValidCtxt,
7063 doc: *mut _xmlDoc,
7064 elem: *mut _xmlNode,
7065 prefix: *const xmlChar,
7066 ns: *mut _xmlNs,
7067 value: *const xmlChar,
7068) -> c_int {
7069 crate::xml::validation::validate_one_namespace(ctxt, doc, elem, prefix, ns, value)
7070}
7071
7072#[no_mangle]
7084pub unsafe extern "C" fn xmlValidatePushElement(
7085 ctxt: *mut _xmlValidCtxt,
7086 doc: *mut _xmlDoc,
7087 elem: *mut _xmlNode,
7088 qname: *const xmlChar,
7089) -> c_int {
7090 crate::xml::validation::validate_push_element(ctxt, doc, elem, qname)
7091}
7092
7093#[no_mangle]
7103pub unsafe extern "C" fn xmlValidatePushCData(
7104 ctxt: *mut _xmlValidCtxt,
7105 data: *const xmlChar,
7106 len: c_int,
7107) -> c_int {
7108 crate::xml::validation::validate_push_cdata(ctxt, data, len)
7109}
7110
7111#[no_mangle]
7122pub unsafe extern "C" fn xmlValidatePopElement(
7123 ctxt: *mut _xmlValidCtxt,
7124 doc: *mut _xmlDoc,
7125 elem: *mut _xmlNode,
7126 qname: *const xmlChar,
7127) -> c_int {
7128 crate::xml::validation::validate_pop_element(ctxt, doc, elem, qname)
7129}
7130
7131#[no_mangle]
7140pub unsafe extern "C" fn xmlValidBuildContentModel(
7141 ctxt: *mut _xmlValidCtxt,
7142 elem: *mut _xmlElement,
7143) -> c_int {
7144 crate::xml::validation::validate_build_content_model(ctxt, elem)
7145}
7146
7147#[no_mangle]
7158pub unsafe extern "C" fn xmlAddID(
7159 ctxt: *mut _xmlValidCtxt,
7160 doc: *mut _xmlDoc,
7161 value: *const xmlChar,
7162 attr: *mut _xmlAttr,
7163) -> *mut _xmlID {
7164 crate::xml::validation::add_id(ctxt, doc, value, attr)
7165}
7166
7167#[no_mangle]
7175pub unsafe extern "C" fn xmlRemoveID(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7176 crate::xml::validation::remove_id(doc, attr)
7177}
7178
7179#[no_mangle]
7190pub unsafe extern "C" fn xmlAddRef(
7191 ctxt: *mut _xmlValidCtxt,
7192 doc: *mut _xmlDoc,
7193 value: *const xmlChar,
7194 attr: *mut _xmlAttr,
7195) -> *mut _xmlRef {
7196 crate::xml::validation::add_ref(ctxt, doc, value, attr)
7197}
7198
7199#[no_mangle]
7207pub unsafe extern "C" fn xmlRemoveRef(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7208 crate::xml::validation::remove_ref(doc, attr)
7209}
7210
7211#[no_mangle]
7219pub unsafe extern "C" fn xmlAddIDSafe(attr: *mut _xmlAttr, value: *const xmlChar) -> c_int {
7220 crate::xml::validation::add_id_safe(attr, value)
7221}
7222
7223#[no_mangle]
7231pub unsafe extern "C" fn xmlFreeIDTable(table: *mut c_void) {
7232 crate::xml::validation::free_id_table(table as *mut crate::xml::hash::HashTable);
7233}
7234
7235#[no_mangle]
7243pub unsafe extern "C" fn xmlFreeRefTable(table: *mut c_void) {
7244 crate::xml::validation::free_ref_table(table as *mut crate::xml::hash::HashTable);
7245}
7246
7247#[no_mangle]
7255pub unsafe extern "C" fn xmlGetID(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut _xmlAttr {
7256 crate::xml::validation::get_id(doc, id)
7257}
7258
7259#[no_mangle]
7267pub unsafe extern "C" fn xmlGetRefs(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut c_void {
7268 crate::xml::validation::get_refs(doc, id) as *mut c_void
7269}
7270
7271#[no_mangle]
7279pub unsafe extern "C" fn xmlIsID(
7280 doc: *mut _xmlDoc,
7281 elem: *mut _xmlNode,
7282 attr: *mut _xmlAttr,
7283) -> c_int {
7284 crate::xml::validation::is_id(doc, elem, attr)
7285}
7286
7287#[no_mangle]
7295pub unsafe extern "C" fn xmlIsRef(
7296 doc: *mut _xmlDoc,
7297 elem: *mut _xmlNode,
7298 attr: *mut _xmlAttr,
7299) -> c_int {
7300 crate::xml::validation::is_ref(doc, elem, attr)
7301}
7302
7303#[no_mangle]
7311pub unsafe extern "C" fn xmlGetDtdElementDesc(
7312 dtd: *mut _xmlDtd,
7313 name: *const xmlChar,
7314) -> *mut _xmlElement {
7315 crate::xml::validation::get_dtd_element_desc(dtd, name)
7316}
7317
7318#[no_mangle]
7328pub unsafe extern "C" fn xmlGetDtdAttrDesc(
7329 dtd: *mut _xmlDtd,
7330 elem: *const xmlChar,
7331 name: *const xmlChar,
7332) -> *mut _xmlAttribute {
7333 crate::xml::validation::get_dtd_attr_desc(dtd, elem, name)
7334}
7335
7336#[no_mangle]
7346pub unsafe extern "C" fn xmlGetDtdQElementDesc(
7347 dtd: *mut _xmlDtd,
7348 name: *const xmlChar,
7349 prefix: *const xmlChar,
7350) -> *mut _xmlElement {
7351 crate::xml::validation::get_dtd_qelement_desc(dtd, name, prefix)
7352}
7353
7354#[no_mangle]
7365pub unsafe extern "C" fn xmlGetDtdQAttrDesc(
7366 dtd: *mut _xmlDtd,
7367 elem: *const xmlChar,
7368 name: *const xmlChar,
7369 prefix: *const xmlChar,
7370) -> *mut _xmlAttribute {
7371 crate::xml::validation::get_dtd_qattr_desc(dtd, elem, name, prefix)
7372}
7373
7374#[no_mangle]
7382pub unsafe extern "C" fn xmlGetDtdNotationDesc(
7383 dtd: *mut _xmlDtd,
7384 name: *const xmlChar,
7385) -> *mut _xmlNotation {
7386 crate::xml::validation::get_dtd_notation_desc(dtd, name)
7387}
7388
7389#[no_mangle]
7397pub unsafe extern "C" fn xmlValidateRoot(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7398 crate::xml::validation::validate_root(ctxt, doc)
7399}
7400
7401#[no_mangle]
7411pub unsafe extern "C" fn xmlValidateContent(
7412 ctxt: *mut _xmlValidCtxt,
7413 node: *mut _xmlNode,
7414 doc: *mut _xmlDoc,
7415) -> c_int {
7416 crate::xml::validation::validate_content(ctxt, node, doc)
7417}
7418
7419#[no_mangle]
7427pub unsafe extern "C" fn xmlIsMixedElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7428 crate::xml::validation::is_mixed_element(doc, name)
7429}
7430
7431#[no_mangle]
7439pub unsafe extern "C" fn xmlIsEmptyElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7440 crate::xml::validation::is_empty_element(doc, name)
7441}
7442
7443#[no_mangle]
7453pub unsafe extern "C" fn xmlValidateDtd(
7454 ctxt: *mut _xmlValidCtxt,
7455 doc: *mut _xmlDoc,
7456 dtd: *mut _xmlDtd,
7457) -> c_int {
7458 crate::xml::validation::validate_dtd(ctxt, doc, dtd)
7459}
7460
7461#[no_mangle]
7469pub unsafe extern "C" fn xmlValidateDtdFinal(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7470 crate::xml::validation::validate_dtd_final(ctxt, doc)
7471}
7472
7473#[no_mangle]
7483pub unsafe extern "C" fn xmlValidateEnumeration(
7484 ctxt: *mut _xmlValidCtxt,
7485 value: *const xmlChar,
7486 tree: *mut _xmlEnumeration,
7487) -> c_int {
7488 crate::xml::validation::validate_enumeration(ctxt, value, tree)
7489}
7490
7491#[no_mangle]
7505pub extern "C" fn xmlGetBinaryPath() -> *mut c_char {
7506 ptr::null_mut()
7508}
7509
7510#[no_mangle]
7518pub extern "C" fn xmlGetHomeOfBinary() -> *mut c_char {
7519 ptr::null_mut()
7521}
7522
7523#[no_mangle]
7534pub unsafe extern "C" fn xmlSAX2StartDocument(ctx: *mut c_void) {
7535 crate::xml::sax::default::default_sax_handler::startDocument(ctx)
7536}
7537
7538#[no_mangle]
7540pub unsafe extern "C" fn xmlSAX2EndDocument(ctx: *mut c_void) {
7541 crate::xml::sax::default::default_sax_handler::endDocument(ctx)
7542}
7543
7544#[no_mangle]
7546pub unsafe extern "C" fn xmlSAX2StartElementNs(
7547 ctx: *mut c_void,
7548 localname: *const xmlChar,
7549 prefix: *const xmlChar,
7550 URI: *const xmlChar,
7551 nb_namespaces: c_int,
7552 namespaces: *mut *const xmlChar,
7553 nb_attributes: c_int,
7554 nb_defaulted: c_int,
7555 attributes: *mut *const xmlChar,
7556) {
7557 crate::xml::sax::default::default_sax_handler::startElementNs(
7558 ctx,
7559 localname,
7560 prefix,
7561 URI,
7562 nb_namespaces,
7563 namespaces,
7564 nb_attributes,
7565 nb_defaulted,
7566 attributes,
7567 )
7568}
7569
7570#[no_mangle]
7572pub unsafe extern "C" fn xmlSAX2EndElementNs(
7573 ctx: *mut c_void,
7574 localname: *const xmlChar,
7575 prefix: *const xmlChar,
7576 URI: *const xmlChar,
7577) {
7578 crate::xml::sax::default::default_sax_handler::endElementNs(ctx, localname, prefix, URI)
7579}
7580
7581#[no_mangle]
7583pub unsafe extern "C" fn xmlSAX2Characters(ctx: *mut c_void, ch: *const xmlChar, len: c_int) {
7584 crate::xml::sax::default::default_sax_handler::characters(ctx, ch, len)
7585}
7586
7587#[no_mangle]
7589pub unsafe extern "C" fn xmlSAX2IgnorableWhitespace(
7590 ctx: *mut c_void,
7591 ch: *const xmlChar,
7592 len: c_int,
7593) {
7594 crate::xml::sax::default::default_sax_handler::ignorableWhitespace(ctx, ch, len)
7595}
7596
7597#[no_mangle]
7599pub unsafe extern "C" fn xmlSAX2Comment(ctx: *mut c_void, value: *const xmlChar) {
7600 crate::xml::sax::default::default_sax_handler::comment(ctx, value)
7601}
7602
7603#[no_mangle]
7605pub unsafe extern "C" fn xmlSAX2ProcessingInstruction(
7606 ctx: *mut c_void,
7607 target: *const xmlChar,
7608 data: *const xmlChar,
7609) {
7610 crate::xml::sax::default::default_sax_handler::processingInstruction(ctx, target, data)
7611}
7612
7613#[no_mangle]
7615pub unsafe extern "C" fn xmlSAX2CDataBlock(ctx: *mut c_void, value: *const xmlChar, len: c_int) {
7616 crate::xml::sax::default::default_sax_handler::cdataBlock(ctx, value, len)
7617}
7618
7619#[no_mangle]
7621pub unsafe extern "C" fn xmlSAX2InternalSubset(
7622 ctx: *mut c_void,
7623 name: *const xmlChar,
7624 ExternalID: *const xmlChar,
7625 SystemID: *const xmlChar,
7626) {
7627 crate::xml::sax::default::default_sax_handler::internalSubset(ctx, name, ExternalID, SystemID)
7628}
7629
7630#[no_mangle]
7632pub unsafe extern "C" fn xmlSAX2ExternalSubset(
7633 ctx: *mut c_void,
7634 name: *const xmlChar,
7635 ExternalID: *const xmlChar,
7636 SystemID: *const xmlChar,
7637) {
7638 crate::xml::sax::default::default_sax_handler::externalSubset(ctx, name, ExternalID, SystemID)
7639}
7640
7641#[no_mangle]
7643pub unsafe extern "C" fn xmlSAX2EntityDecl(
7644 ctx: *mut c_void,
7645 name: *const xmlChar,
7646 type_: c_int,
7647 publicId: *const xmlChar,
7648 systemId: *const xmlChar,
7649 content: *mut xmlChar,
7650) {
7651 crate::xml::sax::default::default_sax_handler::entityDecl(
7652 ctx, name, type_, publicId, systemId, content,
7653 )
7654}
7655
7656#[no_mangle]
7658pub unsafe extern "C" fn xmlSAX2AttributeDecl(
7659 ctx: *mut c_void,
7660 elem: *const xmlChar,
7661 fullname: *const xmlChar,
7662 type_: c_int,
7663 def: c_int,
7664 defaultValue: *const xmlChar,
7665 tree: *mut crate::abi::structs::_xmlEnumeration,
7666) {
7667 crate::xml::sax::default::default_sax_handler::attributeDecl(
7668 ctx,
7669 elem,
7670 fullname,
7671 type_,
7672 def,
7673 defaultValue,
7674 tree,
7675 )
7676}
7677
7678#[no_mangle]
7680pub unsafe extern "C" fn xmlSAX2ElementDecl(
7681 ctx: *mut c_void,
7682 name: *const xmlChar,
7683 type_: c_int,
7684 content: *mut crate::abi::structs::_xmlElementContent,
7685) {
7686 crate::xml::sax::default::default_sax_handler::elementDecl(ctx, name, type_, content)
7687}
7688
7689#[no_mangle]
7691pub unsafe extern "C" fn xmlSAX2NotationDecl(
7692 ctx: *mut c_void,
7693 name: *const xmlChar,
7694 publicId: *const xmlChar,
7695 systemId: *const xmlChar,
7696) {
7697 crate::xml::sax::default::default_sax_handler::notationDecl(ctx, name, publicId, systemId)
7698}
7699
7700#[no_mangle]
7702pub unsafe extern "C" fn xmlSAX2UnparsedEntityDecl(
7703 ctx: *mut c_void,
7704 name: *const xmlChar,
7705 publicId: *const xmlChar,
7706 systemId: *const xmlChar,
7707 notationName: *const xmlChar,
7708) {
7709 crate::xml::sax::default::default_sax_handler::unparsedEntityDecl(
7710 ctx,
7711 name,
7712 publicId,
7713 systemId,
7714 notationName,
7715 )
7716}
7717
7718#[no_mangle]
7720pub unsafe extern "C" fn xmlSAX2ResolveEntity(
7721 ctx: *mut c_void,
7722 publicId: *const xmlChar,
7723 systemId: *const xmlChar,
7724) -> *mut crate::abi::structs::_xmlParserInput {
7725 crate::xml::sax::default::default_sax_handler::resolveEntity(ctx, publicId, systemId)
7726}
7727
7728#[no_mangle]
7730pub unsafe extern "C" fn xmlSAX2IsStandalone(ctx: *mut c_void) -> c_int {
7731 crate::xml::sax::default::default_sax_handler::isStandalone(ctx)
7732}
7733
7734#[no_mangle]
7736pub unsafe extern "C" fn xmlSAX2HasInternalSubset(ctx: *mut c_void) -> c_int {
7737 crate::xml::sax::default::default_sax_handler::hasInternalSubset(ctx)
7738}
7739
7740#[no_mangle]
7742pub unsafe extern "C" fn xmlSAX2HasExternalSubset(ctx: *mut c_void) -> c_int {
7743 crate::xml::sax::default::default_sax_handler::hasExternalSubset(ctx)
7744}
7745
7746#[no_mangle]
7748pub unsafe extern "C" fn xmlSAX2GetEntity(
7749 ctx: *mut c_void,
7750 name: *const xmlChar,
7751) -> *mut crate::abi::structs::_xmlEntity {
7752 crate::xml::sax::default::default_sax_handler::getEntity(ctx, name)
7753}
7754
7755#[no_mangle]
7757pub unsafe extern "C" fn xmlSAX2GetParameterEntity(
7758 ctx: *mut c_void,
7759 name: *const xmlChar,
7760) -> *mut crate::abi::structs::_xmlEntity {
7761 crate::xml::sax::default::default_sax_handler::getParameterEntity(ctx, name)
7762}
7763
7764#[no_mangle]
7767pub unsafe extern "C" fn xmlSAX2GetLineNumber(ctx: *mut c_void) -> c_int {
7768 crate::xml::sax::default::default_sax_handler::getLineNumber(ctx)
7769}
7770
7771#[no_mangle]
7773pub unsafe extern "C" fn xmlSAX2GetColumnNumber(ctx: *mut c_void) -> c_int {
7774 crate::xml::sax::default::default_sax_handler::getColumnNumber(ctx)
7775}
7776
7777#[no_mangle]
7779pub unsafe extern "C" fn xmlSAX2GetPublicId(ctx: *mut c_void) -> *const xmlChar {
7780 crate::xml::sax::default::default_sax_handler::getPublicId(ctx)
7781}
7782
7783#[no_mangle]
7785pub unsafe extern "C" fn xmlSAX2GetSystemId(ctx: *mut c_void) -> *const xmlChar {
7786 crate::xml::sax::default::default_sax_handler::getSystemId(ctx)
7787}
7788
7789#[no_mangle]
7793pub unsafe extern "C" fn xmlSAX2StartElement(
7794 ctx: *mut c_void,
7795 name: *const xmlChar,
7796 atts: *mut *const xmlChar,
7797) {
7798 crate::xml::sax::dispatch::SaxDispatcher::sax1_start_element(ctx, name, atts);
7802}
7803
7804#[no_mangle]
7806pub unsafe extern "C" fn xmlSAX2EndElement(ctx: *mut c_void, name: *const xmlChar) {
7807 crate::xml::sax::dispatch::SaxDispatcher::sax1_end_element(ctx, name);
7808}
7809
7810#[no_mangle]
7812pub unsafe extern "C" fn xmlSAX2SetDocumentLocator(
7813 ctx: *mut c_void,
7814 loc: *mut crate::abi::callbacks::_xmlSAXLocator,
7815) {
7816 crate::xml::sax::default::default_sax_handler::setDocumentLocator(ctx, loc)
7817}
7818
7819#[no_mangle]
7821pub unsafe extern "C" fn xmlSAX2Reference(ctx: *mut c_void, name: *const xmlChar) {
7822 crate::xml::sax::default::default_sax_handler::reference(ctx, name)
7823}