1#![allow(non_snake_case)]
98#![allow(unused_variables)]
99#![allow(clippy::missing_safety_doc)]
100#![allow(clippy::not_unsafe_ptr_arg_deref)]
101
102use core::ffi::c_void;
103use core::ptr;
104use once_cell::sync::Lazy;
105use parking_lot::Mutex;
106use std::collections::HashMap;
107use std::ffi::{CStr, CString};
108use std::mem::size_of;
109use std::os::raw::{c_char, c_int, c_long, c_uint, c_ulong};
110
111use crate::xml::xpath::ast::CompiledExpr;
112use crate::xml::xpath::context::{BoxedXPathFunction, XPathContext};
113use crate::xml::xpath::types::{NodeSet, XPathValue};
114
115use crate::abi::allocator::*;
116use crate::abi::callbacks::*;
117use crate::abi::structs::*;
118use crate::abi::types::*;
119
120#[no_mangle]
135pub unsafe extern "C" fn xmlInitParser() {
136 crate::internal::globals::init_parser();
137}
138
139#[no_mangle]
152pub const unsafe extern "C" fn xmlInitGlobals() {
153 }
155
156#[no_mangle]
166pub const unsafe extern "C" fn xmlInitializeGlobalState(_gs: *mut c_void) {
167 }
171
172#[no_mangle]
181pub const extern "C" fn xmlInitializeDict() -> c_int {
182 0
185}
186
187#[no_mangle]
197pub const extern "C" fn xmlInitializePredefinedEntities() {
198 }
200
201#[no_mangle]
210pub const extern "C" fn xmlCleanupPredefinedEntities() {
211 }
213
214#[no_mangle]
225pub const extern "C" fn xmlDefaultSAXHandlerInit() {
226 }
229
230static SAX2_DEFAULT_VERSION: core::sync::atomic::AtomicI32 = core::sync::atomic::AtomicI32::new(2);
233#[no_mangle]
242pub extern "C" fn xmlSAXDefaultVersion(version: c_int) -> c_int {
243 use core::sync::atomic::Ordering;
244 let ret = SAX2_DEFAULT_VERSION.load(Ordering::Relaxed);
245 if version != 1 && version != 2 {
246 return -1;
247 }
248 SAX2_DEFAULT_VERSION.store(version, Ordering::Relaxed);
249 ret
250}
251
252#[no_mangle]
262pub unsafe extern "C" fn xmlSAXVersion(
263 hdlr: *mut crate::abi::structs::_xmlSAXHandler,
264 version: c_int,
265) -> c_int {
266 if hdlr.is_null() {
267 return -1;
268 }
269 if version != 1 && version != 2 {
270 return -1;
271 }
272 unsafe {
274 crate::xml::sax::dispatch::xmlSAX2InitDefaultSAXHandler(hdlr);
275 let h = &mut *hdlr;
276 if version == 2 {
277 h.initialized = crate::abi::constants::XML_SAX2_MAGIC as c_uint;
278 } else {
279 h.initialized = 1;
280 }
281 }
282 0
283}
284
285#[no_mangle]
296pub extern "C" fn xmlHasFeature(feature: c_int) -> c_int {
297 if (1..=24).contains(&feature) {
300 1
301 } else {
302 0
303 }
304}
305
306#[no_mangle]
318pub const unsafe extern "C" fn xmlCleanupGlobals() {
319 }
321
322#[no_mangle]
332pub unsafe extern "C" fn xmlCleanupParser() {
333 crate::internal::globals::cleanup_parser();
334}
335
336#[no_mangle]
344pub extern "C" fn xmlNewMutex() -> *mut c_void {
345 crate::xml::threads::new_mutex()
346}
347
348#[no_mangle]
356pub unsafe extern "C" fn xmlFreeMutex(tok: *mut c_void) {
357 crate::xml::threads::free_mutex(tok);
358}
359
360#[no_mangle]
368pub unsafe extern "C" fn xmlMutexLock(tok: *mut c_void) {
369 crate::xml::threads::mutex_lock(tok);
370}
371
372#[no_mangle]
380pub unsafe extern "C" fn xmlMutexUnlock(tok: *mut c_void) {
381 crate::xml::threads::mutex_unlock(tok);
382}
383
384#[no_mangle]
392pub extern "C" fn xmlNewRMutex() -> *mut c_void {
393 crate::xml::threads::new_rmutex()
394}
395
396#[no_mangle]
404pub unsafe extern "C" fn xmlFreeRMutex(tok: *mut c_void) {
405 crate::xml::threads::free_rmutex(tok);
406}
407
408#[no_mangle]
416pub unsafe extern "C" fn xmlRMutexLock(tok: *mut c_void) {
417 crate::xml::threads::rmutex_lock(tok);
418}
419
420#[no_mangle]
428pub unsafe extern "C" fn xmlRMutexUnlock(tok: *mut c_void) {
429 crate::xml::threads::rmutex_unlock(tok);
430}
431
432#[no_mangle]
442pub const extern "C" fn xmlCheckThreadLocalStorage() -> c_int {
443 0
446}
447
448#[no_mangle]
458pub unsafe extern "C" fn xmlInitThreads() -> c_int {
459 crate::internal::globals::init_threads()
460}
461
462#[no_mangle]
470pub unsafe extern "C" fn xmlCleanupThreads() {
471 crate::xml::threads::cleanup_threads();
472}
473
474#[no_mangle]
482pub extern "C" fn xmlIsInitialized() -> c_int {
483 if crate::abi::versioning::is_initialized() {
484 1
485 } else {
486 0
487 }
488}
489
490#[no_mangle]
499pub const unsafe extern "C" fn xmlLockLibrary() {
500 crate::xml::threads::lock_library();
501}
502
503#[no_mangle]
511pub const unsafe extern "C" fn xmlUnlockLibrary() {
512 crate::xml::threads::unlock_library();
513}
514
515#[no_mangle]
532pub unsafe extern "C" fn xmlSetGenericErrorFunc(
533 ctx: *mut c_void,
534 handler: Option<xmlGenericErrorFunc>,
535) {
536 unsafe { crate::xml::errors::set_generic_error_func(ctx, handler) };
538}
539
540#[no_mangle]
552pub unsafe extern "C" fn xmlSetStructuredErrorFunc(
553 ctx: *mut c_void,
554 handler: Option<xmlStructuredErrorFunc>,
555) {
556 unsafe { crate::xml::errors::set_structured_error_func(ctx, handler) };
558}
559
560#[no_mangle]
571pub extern "C" fn xmlGetLastError() -> *mut _xmlError {
572 crate::xml::errors::get_last_error()
573}
574
575#[no_mangle]
589pub const unsafe extern "C" fn xmlCopyError(from: *const _xmlError, to: *mut _xmlError) -> c_int {
590 unsafe { crate::xml::errors::copy_error(from, to) }
592}
593
594#[no_mangle]
606pub const unsafe extern "C" fn xmlResetError(err: *mut _xmlError) {
607 unsafe { crate::xml::errors::reset_error(err) };
609}
610
611#[no_mangle]
624pub unsafe extern "C" fn xmlRaiseError(
625 ctxt: *mut c_void,
626 ctxt2: *mut c_void,
627 ctxt3: *mut c_void,
628 ctxt4: *mut c_void,
629 ctxt5: *mut c_void,
630 domain: c_int,
631 code: c_int,
632 level: c_int,
633 file: *const c_char,
634 line: c_int,
635 str1: *const c_char,
636 str2: *const c_char,
637 str3: *const c_char,
638 int1: c_int,
639 int2: c_int,
640 msg: *const c_char,
641) {
642 unsafe {
644 crate::xml::errors::raise_error(
645 ctxt, ctxt2, ctxt3, ctxt4, ctxt5, domain, code, level, file, line, str1, str2, str3,
646 int1, int2, msg,
647 );
648 }
649}
650
651#[no_mangle]
659pub extern "C" fn xmlResetLastError() {
660 crate::xml::errors::reset_last_error();
661}
662
663#[no_mangle]
679pub unsafe extern "C" fn xmlStrdup(cur: *const xmlChar) -> *mut xmlChar {
680 if cur.is_null() {
681 return ptr::null_mut();
682 }
683 let len = unsafe { xmlStrlen(cur) };
684 let size = len + 1;
685 let new_ptr = unsafe { xmlMallocImpl(size as usize) };
686 if new_ptr.is_null() {
687 return ptr::null_mut();
688 }
689 unsafe {
690 ptr::copy_nonoverlapping(cur, new_ptr as *mut u8, size as usize);
691 }
692 new_ptr as *mut xmlChar
693}
694
695#[no_mangle]
707pub unsafe extern "C" fn xmlStrndup(cur: *const xmlChar, len: c_int) -> *mut xmlChar {
708 if cur.is_null() || len <= 0 {
709 return ptr::null_mut();
710 }
711 let size = len as usize + 1;
712 let new_ptr = unsafe { xmlMallocImpl(size) };
713 if new_ptr.is_null() {
714 return ptr::null_mut();
715 }
716 unsafe {
717 ptr::copy_nonoverlapping(cur, new_ptr as *mut u8, len as usize);
718 *(new_ptr.add(len as usize) as *mut u8) = 0;
719 }
720 new_ptr as *mut xmlChar
721}
722
723#[no_mangle]
735pub unsafe extern "C" fn xmlStrlen(str: *const xmlChar) -> c_int {
736 if str.is_null() {
737 return 0;
738 }
739 unsafe { libc::strlen(str as *const c_char) as c_int }
740}
741
742#[no_mangle]
755pub const unsafe extern "C" fn xmlStrchr(str: *const xmlChar, val: xmlChar) -> *const xmlChar {
756 if str.is_null() {
757 return ptr::null();
758 }
759 unsafe {
760 let mut cur = str;
761 while *cur != 0 {
762 if *cur == val {
763 return cur;
764 }
765 cur = cur.add(1);
766 }
767 ptr::null()
768 }
769}
770
771#[no_mangle]
782pub unsafe extern "C" fn xmlStrcmp(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
783 if str1.is_null() && str2.is_null() {
784 return 0;
785 }
786 if str1.is_null() {
787 return -1;
788 }
789 if str2.is_null() {
790 return 1;
791 }
792 unsafe { libc::strcmp(str1 as *const c_char, str2 as *const c_char) as c_int }
793}
794
795#[no_mangle]
803pub unsafe extern "C" fn xmlStrncmp(
804 str1: *const xmlChar,
805 str2: *const xmlChar,
806 len: c_int,
807) -> c_int {
808 if len <= 0 {
809 return 0;
810 }
811 if str1.is_null() && str2.is_null() {
812 return 0;
813 }
814 if str1.is_null() {
815 return -1;
816 }
817 if str2.is_null() {
818 return 1;
819 }
820 unsafe { libc::strncmp(str1 as *const c_char, str2 as *const c_char, len as usize) as c_int }
821}
822
823#[no_mangle]
831pub unsafe extern "C" fn xmlStrcasecmp(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
832 if str1.is_null() && str2.is_null() {
833 return 0;
834 }
835 if str1.is_null() {
836 return -1;
837 }
838 if str2.is_null() {
839 return 1;
840 }
841 unsafe { libc::strcasecmp(str1 as *const c_char, str2 as *const c_char) as c_int }
842}
843
844#[no_mangle]
852pub unsafe extern "C" fn xmlStrncasecmp(
853 str1: *const xmlChar,
854 str2: *const xmlChar,
855 len: c_int,
856) -> c_int {
857 if len <= 0 {
858 return 0;
859 }
860 if str1.is_null() && str2.is_null() {
861 return 0;
862 }
863 if str1.is_null() {
864 return -1;
865 }
866 if str2.is_null() {
867 return 1;
868 }
869 unsafe {
870 libc::strncasecmp(str1 as *const c_char, str2 as *const c_char, len as usize) as c_int
871 }
872}
873
874#[no_mangle]
884pub unsafe extern "C" fn xmlStrEqual(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
885 if str1.is_null() && str2.is_null() {
886 return 1;
887 }
888 if str1.is_null() || str2.is_null() {
889 return 0;
890 }
891 unsafe { (libc::strcmp(str1 as *const c_char, str2 as *const c_char) == 0) as c_int }
892}
893
894#[no_mangle]
903pub unsafe extern "C" fn xmlBuildQName(
904 ncname: *const xmlChar,
905 prefix: *const xmlChar,
906 memory: *mut xmlChar,
907 len: c_int,
908) -> *mut xmlChar {
909 crate::xml::string::build_qname(ncname, prefix, memory, len)
910}
911
912#[no_mangle]
920pub unsafe extern "C" fn xmlSplitQName2(
921 name: *const xmlChar,
922 prefix: *mut *mut xmlChar,
923) -> *mut xmlChar {
924 crate::xml::string::split_qname2(name, prefix)
925}
926
927#[no_mangle]
937pub unsafe extern "C" fn xmlSplitQName3(name: *const xmlChar, len: *mut c_int) -> *mut xmlChar {
938 crate::xml::string::split_qname3(name, len)
939}
940
941#[no_mangle]
956pub unsafe extern "C" fn xmlSplitQName(
957 _ctxt: *mut _xmlParserCtxt,
958 name: *const xmlChar,
959 prefix: *mut *mut xmlChar,
960) -> *mut xmlChar {
961 crate::xml::string::split_qname2(name, prefix)
962}
963
964#[no_mangle]
972pub const unsafe extern "C" fn xmlUTF8Strlen(utf: *const xmlChar) -> c_int {
973 crate::xml::string::utf8_strlen(utf)
974}
975
976#[no_mangle]
984pub const unsafe extern "C" fn xmlUTF8Size(utf: *const xmlChar) -> c_int {
985 crate::xml::string::utf8_size(utf)
986}
987
988#[no_mangle]
996pub const unsafe extern "C" fn xmlCheckUTF8(utf: *const xmlChar) -> c_int {
997 crate::xml::string::check_utf8(utf)
998}
999
1000#[no_mangle]
1011pub unsafe extern "C" fn xmlStrQEqual(
1012 pref: *const xmlChar,
1013 name: *const xmlChar,
1014 str: *const xmlChar,
1015) -> c_int {
1016 if name.is_null() || str.is_null() {
1017 return 0;
1018 }
1019 if pref.is_null() {
1020 return unsafe { xmlStrEqual(name, str) };
1021 }
1022 let pref_len = unsafe { xmlStrlen(pref) };
1024 let name_len = unsafe { xmlStrlen(name) };
1025 let total_len = pref_len + 1 + name_len;
1026 let str_len = unsafe { xmlStrlen(str) };
1027 if total_len != str_len {
1028 return 0;
1029 }
1030 if unsafe {
1032 libc::strncmp(
1033 pref as *const c_char,
1034 str as *const c_char,
1035 pref_len as usize,
1036 )
1037 } != 0
1038 {
1039 return 0;
1040 }
1041 if unsafe { *str.add(pref_len as usize) } != b':' as xmlChar {
1043 return 0;
1044 }
1045 (unsafe {
1047 libc::strncmp(
1048 name as *const c_char,
1049 str.add((pref_len + 1) as usize) as *const c_char,
1050 name_len as usize,
1051 ) == 0
1052 }) as c_int
1053}
1054
1055#[no_mangle]
1069pub unsafe extern "C" fn xmlStrcat(cur: *mut xmlChar, add: *const xmlChar) -> *mut xmlChar {
1070 if add.is_null() {
1071 return cur;
1072 }
1073 if cur.is_null() {
1074 return unsafe { xmlStrdup(add) };
1075 }
1076 let cur_len = unsafe { xmlStrlen(cur) } as usize;
1077 let add_len = unsafe { xmlStrlen(add) } as usize;
1078 let new_size = cur_len + add_len + 1;
1079 let new_ptr = unsafe { xmlReallocImpl(cur as *mut c_void, new_size) };
1080 if new_ptr.is_null() {
1081 return ptr::null_mut();
1082 }
1083 unsafe {
1084 ptr::copy_nonoverlapping(add, (new_ptr as *mut u8).add(cur_len), add_len);
1085 *((new_ptr as *mut u8).add(cur_len + add_len)) = 0;
1086 }
1087 new_ptr as *mut xmlChar
1088}
1089
1090#[no_mangle]
1102pub unsafe extern "C" fn xmlStrncat(
1103 cur: *mut xmlChar,
1104 add: *const xmlChar,
1105 len: c_int,
1106) -> *mut xmlChar {
1107 if add.is_null() || len <= 0 {
1108 return cur;
1109 }
1110 let len = len as usize;
1111 if cur.is_null() {
1112 return unsafe { xmlStrndup(add, len as c_int) };
1113 }
1114 let cur_len = unsafe { xmlStrlen(cur) } as usize;
1115 let new_size = cur_len + len + 1;
1116 let new_ptr = unsafe { xmlReallocImpl(cur as *mut c_void, new_size) };
1117 if new_ptr.is_null() {
1118 return ptr::null_mut();
1119 }
1120 unsafe {
1121 ptr::copy_nonoverlapping(add, (new_ptr as *mut u8).add(cur_len), len);
1122 *((new_ptr as *mut u8).add(cur_len + len)) = 0;
1123 }
1124 new_ptr as *mut xmlChar
1125}
1126
1127#[no_mangle]
1135pub unsafe extern "C" fn xmlStrncatNew(
1136 str1: *const xmlChar,
1137 str2: *const xmlChar,
1138 len: c_int,
1139) -> *mut xmlChar {
1140 let mut result: *mut xmlChar = ptr::null_mut();
1141 if !str1.is_null() {
1142 result = unsafe { xmlStrdup(str1) };
1143 }
1144 if !str2.is_null() && len > 0 {
1145 result = unsafe { xmlStrncat(result, str2, len) };
1146 }
1147 result
1148}
1149
1150#[no_mangle]
1163pub unsafe extern "C" fn xmlStrcpy(dst: *mut xmlChar, src: *const xmlChar) -> *mut xmlChar {
1164 if dst.is_null() || src.is_null() {
1165 return dst;
1166 }
1167 let len = unsafe { xmlStrlen(src) } as usize + 1;
1168 unsafe {
1169 ptr::copy_nonoverlapping(src, dst, len);
1170 }
1171 dst
1172}
1173
1174#[no_mangle]
1182pub unsafe extern "C" fn xmlStrncpy(
1183 dst: *mut xmlChar,
1184 src: *const xmlChar,
1185 len: c_int,
1186) -> *mut xmlChar {
1187 if dst.is_null() || src.is_null() || len <= 0 {
1188 return dst;
1189 }
1190 let len = len as usize;
1191 let src_len = unsafe { xmlStrlen(src) } as usize;
1192 let copy_len = if src_len < len { src_len } else { len - 1 };
1193 unsafe {
1194 ptr::copy_nonoverlapping(src, dst, copy_len);
1195 *dst.add(copy_len) = 0;
1196 }
1197 dst
1198}
1199
1200#[no_mangle]
1210pub unsafe extern "C" fn xmlStrsub(str: *const xmlChar, start: c_int, len: c_int) -> *mut xmlChar {
1211 if str.is_null() || start < 0 || len < 0 {
1212 return ptr::null_mut();
1213 }
1214 let str_len = unsafe { xmlStrlen(str) };
1215 if start >= str_len {
1216 return unsafe { xmlStrdup(b"\0" as *const u8 as *const xmlChar) };
1217 }
1218 let actual_len = if start + len > str_len {
1219 str_len - start
1220 } else {
1221 len
1222 };
1223 unsafe { xmlStrndup(str.add(start as usize), actual_len) }
1224}
1225
1226#[no_mangle]
1243pub unsafe extern "C" fn xmlNewDoc(version: *const xmlChar) -> *mut _xmlDoc {
1244 crate::xml::tree::new_doc(version)
1245}
1246
1247#[no_mangle]
1259pub unsafe extern "C" fn xmlFreeDoc(doc: *mut _xmlDoc) {
1260 crate::xml::tree::free_doc(doc);
1261}
1262
1263#[no_mangle]
1273pub unsafe extern "C" fn xmlGetDocCompressMode(doc: *mut _xmlDoc) -> c_int {
1274 crate::xml::tree::xmlGetDocCompressMode(doc)
1275}
1276
1277#[no_mangle]
1285pub unsafe extern "C" fn xmlSetDocCompressMode(doc: *mut _xmlDoc, mode: c_int) {
1286 crate::xml::tree::xmlSetDocCompressMode(doc, mode);
1287}
1288
1289#[no_mangle]
1303pub unsafe extern "C" fn xmlNewNode(ns: *mut _xmlNs, name: *const xmlChar) -> *mut _xmlNode {
1304 crate::xml::tree::new_node(ns, name)
1305}
1306
1307#[no_mangle]
1320pub unsafe extern "C" fn xmlFreeNode(node: *mut _xmlNode) {
1321 crate::xml::tree::free_node(node);
1322}
1323
1324#[no_mangle]
1341pub unsafe extern "C" fn xmlFreeNodeList(node: *mut _xmlNode) {
1342 crate::xml::tree::free_node_list(node);
1343}
1344
1345#[no_mangle]
1357pub unsafe extern "C" fn xmlUnlinkNode(node: *mut _xmlNode) {
1358 crate::xml::tree::unlink_node(node);
1359}
1360
1361#[no_mangle]
1377pub unsafe extern "C" fn xmlSAX2InitDefaultSAXHandler(
1378 handler: *mut crate::abi::structs::_xmlSAXHandler,
1379 _warning: c_int,
1380) {
1381 crate::xml::sax::dispatch::xmlSAX2InitDefaultSAXHandler(handler);
1382}
1383
1384#[no_mangle]
1403pub unsafe extern "C" fn xmlSAX2InitHtmlDefaultSAXHandler(
1404 handler: *mut crate::abi::structs::_xmlSAXHandler,
1405) {
1406 if handler.is_null() {
1407 return;
1408 }
1409 unsafe {
1411 if (*handler).initialized != 0 {
1413 return;
1414 }
1415 crate::xml::sax::dispatch::xmlSAX2InitDefaultSAXHandler(handler);
1416 let h = &mut *handler;
1417 h.resolveEntity = None;
1418 h.getParameterEntity = None;
1419 h.entityDecl = None;
1420 h.attributeDecl = None;
1421 h.elementDecl = None;
1422 h.notationDecl = None;
1423 h.unparsedEntityDecl = None;
1424 h.reference = None;
1425 h.externalSubset = None;
1426 h.initialized = 1;
1427 }
1428}
1429
1430#[no_mangle]
1444pub unsafe extern "C" fn xmlAddChild(parent: *mut _xmlNode, cur: *mut _xmlNode) -> *mut _xmlNode {
1445 crate::xml::tree::add_child(parent, cur)
1446}
1447
1448#[no_mangle]
1460pub unsafe extern "C" fn xmlAddSibling(
1461 cur: *mut _xmlNode,
1462 sibling: *mut _xmlNode,
1463) -> *mut _xmlNode {
1464 crate::xml::tree::add_sibling(cur, sibling)
1465}
1466
1467#[no_mangle]
1486pub unsafe extern "C" fn xmlNewChild(
1487 parent: *mut _xmlNode,
1488 ns: *mut _xmlNs,
1489 name: *const xmlChar,
1490 content: *const xmlChar,
1491) -> *mut _xmlNode {
1492 crate::xml::tree::new_child(parent, ns, name)
1493}
1494
1495#[no_mangle]
1510pub unsafe extern "C" fn xmlDocSetRootElement(
1511 doc: *mut _xmlDoc,
1512 root: *mut _xmlNode,
1513) -> *mut _xmlNode {
1514 crate::xml::tree::doc_set_root_element(doc, root)
1515}
1516
1517#[no_mangle]
1527pub extern "C" fn xmlDocGetRootElement(doc: *const _xmlDoc) -> *mut _xmlNode {
1528 crate::xml::tree::doc_get_root_element(doc as *mut _xmlDoc)
1529}
1530
1531#[no_mangle]
1544pub unsafe extern "C" fn xmlCopyNode(node: *const _xmlNode, extended: c_int) -> *mut _xmlNode {
1545 crate::xml::tree::copy_node(node, extended)
1546}
1547
1548#[no_mangle]
1558pub unsafe extern "C" fn xmlCopyDoc(doc: *const _xmlDoc, recursive: c_int) -> *mut _xmlDoc {
1559 crate::xml::tree::copy_doc(doc, recursive)
1560}
1561
1562#[no_mangle]
1573pub unsafe extern "C" fn xmlNewText(content: *const xmlChar) -> *mut _xmlNode {
1574 crate::xml::tree::new_text(content)
1575}
1576
1577#[no_mangle]
1585pub unsafe extern "C" fn xmlNewComment(content: *const xmlChar) -> *mut _xmlNode {
1586 crate::xml::tree::new_comment(content)
1587}
1588
1589#[no_mangle]
1597pub unsafe extern "C" fn xmlNewPI(name: *const xmlChar, content: *const xmlChar) -> *mut _xmlNode {
1598 crate::xml::tree::new_pi(name, content)
1599}
1600
1601#[no_mangle]
1609pub unsafe extern "C" fn xmlNewCDataBlock(
1610 doc: *mut _xmlDoc,
1611 content: *const xmlChar,
1612 len: c_int,
1613) -> *mut _xmlNode {
1614 crate::xml::tree::new_cdata_block(doc, content, len)
1615}
1616
1617#[no_mangle]
1631pub unsafe extern "C" fn xmlNewNs(
1632 node: *mut _xmlNode,
1633 href: *const xmlChar,
1634 prefix: *const xmlChar,
1635) -> *mut _xmlNs {
1636 crate::xml::tree::new_ns(node, href, prefix)
1637}
1638
1639#[no_mangle]
1647pub unsafe extern "C" fn xmlSetNs(node: *mut _xmlNode, ns: *mut _xmlNs) {
1648 crate::xml::tree::set_ns(node, ns);
1649}
1650
1651#[no_mangle]
1659pub unsafe extern "C" fn xmlGetNsList(
1660 doc: *mut _xmlDoc,
1661 node: *const _xmlNode,
1662) -> *mut *mut _xmlNs {
1663 crate::xml::tree::get_ns_list(doc, node as *mut _xmlNode)
1664}
1665
1666#[no_mangle]
1674pub unsafe extern "C" fn xmlSearchNs(
1675 doc: *mut _xmlDoc,
1676 node: *mut _xmlNode,
1677 nameSpace: *const xmlChar,
1678) -> *mut _xmlNs {
1679 crate::xml::tree::search_ns(doc, node, nameSpace)
1680}
1681
1682#[no_mangle]
1690pub unsafe extern "C" fn xmlSearchNsByHref(
1691 doc: *mut _xmlDoc,
1692 node: *mut _xmlNode,
1693 href: *const xmlChar,
1694) -> *mut _xmlNs {
1695 crate::xml::tree::search_ns_by_href(doc, node, href)
1696}
1697
1698#[no_mangle]
1715pub unsafe extern "C" fn xmlSetProp(
1716 node: *mut _xmlNode,
1717 name: *const xmlChar,
1718 value: *const xmlChar,
1719) -> *mut _xmlAttr {
1720 crate::xml::tree::set_prop(node, name, value)
1721}
1722
1723#[no_mangle]
1733pub unsafe extern "C" fn xmlGetProp(node: *const _xmlNode, name: *const xmlChar) -> *mut xmlChar {
1734 crate::xml::tree::get_prop(node as *mut _xmlNode, name)
1735}
1736
1737#[no_mangle]
1745pub unsafe extern "C" fn xmlGetNsProp(
1746 node: *const _xmlNode,
1747 name: *const xmlChar,
1748 nameSpace: *const xmlChar,
1749) -> *mut xmlChar {
1750 crate::xml::tree::get_ns_prop(node as *mut _xmlNode, name, nameSpace)
1751}
1752
1753#[no_mangle]
1762pub unsafe extern "C" fn xmlSetNsProp(
1763 node: *mut _xmlNode,
1764 ns: *mut _xmlNs,
1765 name: *const xmlChar,
1766 value: *const xmlChar,
1767) -> *mut _xmlAttr {
1768 crate::xml::tree::set_ns_prop(node, ns, name, value)
1769}
1770
1771#[no_mangle]
1781pub unsafe extern "C" fn xmlRemoveProp(attr: *mut _xmlAttr) -> c_int {
1782 crate::xml::tree::remove_prop(attr)
1783}
1784
1785#[no_mangle]
1795pub unsafe extern "C" fn xmlHasProp(node: *const _xmlNode, name: *const xmlChar) -> *mut _xmlAttr {
1796 crate::xml::tree::has_prop(node as *mut _xmlNode, name)
1797}
1798
1799#[no_mangle]
1808pub unsafe extern "C" fn xmlHasNsProp(
1809 node: *const _xmlNode,
1810 name: *const xmlChar,
1811 nameSpace: *const xmlChar,
1812) -> *mut _xmlAttr {
1813 crate::xml::tree::has_ns_prop(node as *mut _xmlNode, name, nameSpace)
1814}
1815
1816#[no_mangle]
1826pub unsafe extern "C" fn xmlUnsetProp(node: *mut _xmlNode, name: *const xmlChar) -> c_int {
1827 crate::xml::tree::unset_prop(node, name)
1828}
1829
1830#[no_mangle]
1839pub unsafe extern "C" fn xmlUnsetNsProp(
1840 node: *mut _xmlNode,
1841 name: *const xmlChar,
1842 nameSpace: *const xmlChar,
1843) -> c_int {
1844 crate::xml::tree::unset_ns_prop(node, name, nameSpace)
1845}
1846
1847#[no_mangle]
1855pub unsafe extern "C" fn xmlFirstElementChild(parent: *mut _xmlNode) -> *mut _xmlNode {
1856 crate::xml::tree::first_element_child(parent)
1857}
1858
1859#[no_mangle]
1861pub unsafe extern "C" fn xmlLastElementChild(parent: *mut _xmlNode) -> *mut _xmlNode {
1862 crate::xml::tree::last_element_child(parent)
1863}
1864
1865#[no_mangle]
1867pub unsafe extern "C" fn xmlNextElementSibling(node: *mut _xmlNode) -> *mut _xmlNode {
1868 crate::xml::tree::next_element_sibling(node)
1869}
1870
1871#[no_mangle]
1873pub unsafe extern "C" fn xmlPreviousElementSibling(node: *mut _xmlNode) -> *mut _xmlNode {
1874 crate::xml::tree::previous_element_sibling(node)
1875}
1876
1877#[no_mangle]
1885pub unsafe extern "C" fn xmlChildElementCount(parent: *mut _xmlNode) -> c_ulong {
1886 crate::xml::tree::child_element_count(parent)
1887}
1888
1889#[no_mangle]
1897pub unsafe extern "C" fn xmlTextConcat(
1898 node: *mut _xmlNode,
1899 content: *const xmlChar,
1900 len: c_int,
1901) -> c_int {
1902 crate::xml::tree::text_concat(node, content, len)
1903}
1904
1905#[no_mangle]
1913pub unsafe extern "C" fn xmlTextMerge(
1914 first: *mut _xmlNode,
1915 second: *mut _xmlNode,
1916) -> *mut _xmlNode {
1917 crate::xml::tree::text_merge(first, second)
1918}
1919
1920#[no_mangle]
1928pub const extern "C" fn xmlGetIntSubset(doc: *const _xmlDoc) -> *mut _xmlDtd {
1929 crate::xml::tree::get_int_subset(doc)
1930}
1931
1932#[no_mangle]
1941pub unsafe extern "C" fn xmlNewDtd(
1942 doc: *mut _xmlDoc,
1943 name: *const xmlChar,
1944 ExternalID: *const xmlChar,
1945 SystemID: *const xmlChar,
1946) -> *mut _xmlDtd {
1947 crate::xml::tree::new_dtd(doc, name, ExternalID, SystemID)
1948}
1949
1950#[no_mangle]
1960pub unsafe extern "C" fn xmlNewEntity(
1961 doc: *mut _xmlDoc,
1962 name: *const xmlChar,
1963 type_: c_int,
1964 ExternalID: *const xmlChar,
1965 SystemID: *const xmlChar,
1966 content: *const xmlChar,
1967) -> *mut _xmlEntity {
1968 crate::xml::tree::new_entity(doc, name, type_, ExternalID, SystemID, content)
1969}
1970
1971#[no_mangle]
1979pub unsafe extern "C" fn xmlGetDocEntity(
1980 doc: *const _xmlDoc,
1981 name: *const xmlChar,
1982) -> *mut _xmlEntity {
1983 crate::xml::tree::get_doc_entity(doc, name)
1984}
1985
1986#[no_mangle]
1994pub unsafe extern "C" fn xmlGetParameterEntity(
1995 doc: *const _xmlDoc,
1996 name: *const xmlChar,
1997) -> *mut _xmlEntity {
1998 crate::xml::tree::get_parameter_entity(doc, name)
1999}
2000
2001#[no_mangle]
2012pub unsafe extern "C" fn xmlCreateIntSubset(
2013 doc: *mut _xmlDoc,
2014 name: *const xmlChar,
2015 ExternalID: *const xmlChar,
2016 SystemID: *const xmlChar,
2017) -> *mut _xmlDtd {
2018 crate::xml::dtd::create_int_subset(doc, name, ExternalID, SystemID)
2019}
2020
2021#[no_mangle]
2029pub unsafe extern "C" fn xmlFreeDtd(dtd: *mut _xmlDtd) {
2030 crate::xml::dtd::free_dtd(dtd);
2031}
2032
2033#[no_mangle]
2049pub unsafe extern "C" fn xmlAddNotationDecl(
2050 _ctxt: *mut _xmlValidCtxt,
2051 dtd: *mut _xmlDtd,
2052 name: *const xmlChar,
2053 PublicID: *const xmlChar,
2054 SystemID: *const xmlChar,
2055) -> *mut _xmlNotation {
2056 crate::xml::dtd::add_notation_decl(dtd, name, PublicID, SystemID)
2057}
2058
2059#[no_mangle]
2067pub unsafe extern "C" fn xmlGetNotationDecl(
2068 dtd: *mut _xmlDtd,
2069 name: *const xmlChar,
2070) -> *mut _xmlNotation {
2071 crate::xml::dtd::get_notation_decl(dtd, name)
2072}
2073
2074#[no_mangle]
2082pub unsafe extern "C" fn xmlCopyNotation(notation: *mut _xmlNotation) -> *mut _xmlNotation {
2083 crate::xml::dtd::copy_notation(notation)
2084}
2085
2086#[no_mangle]
2094pub unsafe extern "C" fn xmlFreeNotation(notation: *mut _xmlNotation) {
2095 crate::xml::dtd::free_notation(notation);
2096}
2097
2098#[no_mangle]
2112pub unsafe extern "C" fn xmlAddElementDecl(
2113 _ctxt: *mut _xmlValidCtxt,
2114 dtd: *mut _xmlDtd,
2115 name: *const xmlChar,
2116 type_: c_int,
2117 content: *mut _xmlElementContent,
2118) -> *mut _xmlElement {
2119 crate::xml::dtd::add_element_decl(dtd, name, type_, content)
2120}
2121
2122#[no_mangle]
2130pub unsafe extern "C" fn xmlGetElementDecl(
2131 dtd: *mut _xmlDtd,
2132 name: *const xmlChar,
2133) -> *mut _xmlElement {
2134 crate::xml::dtd::get_element_decl(dtd, name)
2135}
2136
2137#[no_mangle]
2145pub unsafe extern "C" fn xmlCopyElement(elem: *mut _xmlElement) -> *mut _xmlElement {
2146 crate::xml::dtd::copy_element(elem)
2147}
2148
2149#[no_mangle]
2157pub unsafe extern "C" fn xmlFreeElement(elem: *mut _xmlElement) {
2158 crate::xml::dtd::free_element(elem);
2159}
2160
2161#[no_mangle]
2180pub unsafe extern "C" fn xmlAddAttributeDecl(
2181 _ctxt: *mut _xmlValidCtxt,
2182 dtd: *mut _xmlDtd,
2183 elem: *mut _xmlElement,
2184 name: *const xmlChar,
2185 ns: *const xmlChar,
2186 type_: c_int,
2187 def: c_int,
2188 defaultValue: *const xmlChar,
2189 tree: *mut _xmlEnumeration,
2190) -> *mut _xmlAttribute {
2191 crate::xml::dtd::add_attribute_decl(dtd, elem, name, ns, type_, def, defaultValue, tree)
2192}
2193
2194#[no_mangle]
2203pub unsafe extern "C" fn xmlGetAttributeDecl(
2204 dtd: *mut _xmlDtd,
2205 elem: *mut _xmlElement,
2206 name: *const xmlChar,
2207 namePrefix: c_int,
2208) -> *mut _xmlAttribute {
2209 crate::xml::dtd::get_attribute_decl(dtd, elem, name, namePrefix)
2210}
2211
2212#[no_mangle]
2220pub unsafe extern "C" fn xmlCopyAttribute(attr: *mut _xmlAttribute) -> *mut _xmlAttribute {
2221 crate::xml::dtd::copy_attribute_decl(attr)
2222}
2223
2224#[no_mangle]
2232pub unsafe extern "C" fn xmlFreeAttribute(attr: *mut _xmlAttribute) {
2233 crate::xml::dtd::free_attribute(attr);
2234}
2235
2236#[no_mangle]
2244pub unsafe extern "C" fn xmlNewElementContent(
2245 name: *const xmlChar,
2246 type_: c_int,
2247) -> *mut _xmlElementContent {
2248 crate::xml::dtd::create_content_model(name, type_)
2249}
2250
2251#[no_mangle]
2259pub unsafe extern "C" fn xmlCopyElementContent(
2260 content: *mut _xmlElementContent,
2261) -> *mut _xmlElementContent {
2262 crate::xml::dtd::copy_content_model(content)
2263}
2264
2265#[no_mangle]
2273pub unsafe extern "C" fn xmlFreeElementContent(cur: *mut _xmlElementContent) {
2274 crate::xml::dtd::free_content_model(cur);
2275}
2276
2277#[no_mangle]
2297pub unsafe extern "C" fn xmlAddEntity(
2298 doc: *mut _xmlDoc,
2299 extSubset: c_int,
2300 name: *const xmlChar,
2301 type_: c_int,
2302 publicId: *const xmlChar,
2303 systemId: *const xmlChar,
2304 content: *const xmlChar,
2305 out: *mut *mut _xmlEntity,
2306) -> c_int {
2307 crate::xml::entities::add_entity_doc(
2308 doc, extSubset, name, type_, publicId, systemId, content, out,
2309 )
2310}
2311
2312#[no_mangle]
2324pub unsafe extern "C" fn xmlAddDocEntity(
2325 doc: *mut _xmlDoc,
2326 name: *const xmlChar,
2327 type_: c_int,
2328 ExternalID: *const xmlChar,
2329 SystemID: *const xmlChar,
2330 content: *const xmlChar,
2331) -> *mut _xmlEntity {
2332 crate::xml::tree::add_doc_entity(doc, name, type_, ExternalID, SystemID, content)
2333}
2334
2335#[no_mangle]
2346pub unsafe extern "C" fn xmlAddDtdEntity(
2347 doc: *mut _xmlDoc,
2348 name: *const xmlChar,
2349 type_: c_int,
2350 ExternalID: *const xmlChar,
2351 SystemID: *const xmlChar,
2352 content: *const xmlChar,
2353) -> *mut _xmlEntity {
2354 crate::xml::tree::add_dtd_entity(doc, name, type_, ExternalID, SystemID, content)
2355}
2356
2357#[no_mangle]
2366pub unsafe extern "C" fn xmlGetDtdEntity(
2367 doc: *mut _xmlDoc,
2368 name: *const xmlChar,
2369) -> *mut _xmlEntity {
2370 crate::xml::tree::get_dtd_entity(doc, name)
2371}
2372
2373#[no_mangle]
2381pub unsafe extern "C" fn xmlGetEntity(doc: *mut _xmlDoc, name: *const xmlChar) -> *mut _xmlEntity {
2382 crate::xml::entities::get_entity(doc, name)
2383}
2384
2385#[no_mangle]
2393pub unsafe extern "C" fn xmlCopyEntity(entity: *mut _xmlEntity) -> *mut _xmlEntity {
2394 crate::xml::entities::copy_entity(entity)
2395}
2396
2397#[no_mangle]
2405pub unsafe extern "C" fn xmlFreeEntity(entity: *mut _xmlEntity) {
2406 crate::xml::entities::free_entity(entity);
2407}
2408
2409#[no_mangle]
2417pub unsafe extern "C" fn xmlEncodeEntitiesReentrant(
2418 doc: *mut _xmlDoc,
2419 input: *const xmlChar,
2420) -> *mut xmlChar {
2421 crate::xml::entities::encode_entities_reentrant(doc, input)
2422}
2423
2424#[no_mangle]
2435pub unsafe extern "C" fn xmlEncodeSpecialChars(
2436 _doc: *const _xmlDoc,
2437 input: *const xmlChar,
2438) -> *mut xmlChar {
2439 if input.is_null() {
2440 return ptr::null_mut();
2441 }
2442 unsafe {
2443 let len = crate::xml::string::xml_strlen(input);
2444 let cap = len * 6 + 1;
2447 let out = crate::abi::allocator::xmlMallocImpl(cap) as *mut xmlChar;
2448 if out.is_null() {
2449 return ptr::null_mut();
2450 }
2451 let mut o = 0usize;
2452 let mut i = 0usize;
2453 while i < len {
2454 let c = *input.add(i);
2455 let rep: &[u8] = match c {
2456 b'<' => b"<",
2457 b'>' => b">",
2458 b'&' => b"&",
2459 b'"' => b""",
2460 b'\r' => b" ",
2461 _ => {
2462 *out.add(o) = c;
2463 o += 1;
2464 i += 1;
2465 continue;
2466 }
2467 };
2468 core::ptr::copy_nonoverlapping(rep.as_ptr(), out.add(o), rep.len());
2469 o += rep.len();
2470 i += 1;
2471 }
2472 *out.add(o) = 0;
2473 out
2474 }
2475}
2476
2477#[no_mangle]
2488pub unsafe extern "C" fn xmlEncodeEntities(
2489 _doc: *mut _xmlDoc,
2490 _input: *const xmlChar,
2491) -> *mut xmlChar {
2492 use core::sync::atomic::{AtomicBool, Ordering};
2493 static WARNED: AtomicBool = AtomicBool::new(false);
2494 if !WARNED.swap(true, Ordering::Relaxed) {
2495 let msg = b"xmlEncodeEntities is deprecated, use xmlEncodeSpecialChars or xmlEncodeEntitiesReentrant\n";
2497 unsafe {
2498 libc::fwrite(
2499 msg.as_ptr() as *const c_void,
2500 1,
2501 msg.len(),
2502 libc::fdopen(2, b"w\0" as *const u8 as *const c_char),
2503 );
2504 }
2505 }
2506 ptr::null_mut()
2507}
2508
2509#[no_mangle]
2517pub extern "C" fn xmlGetLineNo(node: *const _xmlNode) -> c_long {
2518 crate::xml::tree::get_line_no(node)
2519}
2520
2521#[no_mangle]
2533pub unsafe extern "C" fn xmlNodeDump(
2534 buf: *mut _xmlBuffer,
2535 doc: *mut _xmlDoc,
2536 cur: *mut _xmlNode,
2537 level: c_int,
2538 format: c_int,
2539) -> c_int {
2540 if buf.is_null() || cur.is_null() {
2541 return -1;
2542 }
2543 crate::xml::tree::xmlNodeDump(buf, doc, cur, level, format)
2544}
2545
2546#[no_mangle]
2554pub unsafe extern "C" fn xmlDocDump(fp: *mut c_void, doc: *mut _xmlDoc) -> c_int {
2555 if fp.is_null() || doc.is_null() {
2556 return -1;
2557 }
2558 crate::xml::tree::xmlDocDump(fp, doc)
2559}
2560
2561#[no_mangle]
2569pub unsafe extern "C" fn xmlDocDumpFormatMemory(
2570 doc: *mut _xmlDoc,
2571 mem: *mut *mut xmlChar,
2572 size: *mut c_int,
2573 format: c_int,
2574) {
2575 if doc.is_null() || mem.is_null() || size.is_null() {
2576 return;
2577 }
2578 crate::xml::tree::xmlDocDumpFormatMemory(doc, mem, size, format)
2579}
2580
2581#[no_mangle]
2589pub unsafe extern "C" fn xmlDocDumpMemory(
2590 doc: *mut _xmlDoc,
2591 mem: *mut *mut xmlChar,
2592 size: *mut c_int,
2593) {
2594 if doc.is_null() || mem.is_null() || size.is_null() {
2595 return;
2596 }
2597 crate::xml::tree::xmlDocDumpMemory(doc, mem, size)
2598}
2599
2600#[no_mangle]
2608pub unsafe extern "C" fn xmlSaveFile(filename: *const c_char, cur: *mut _xmlDoc) -> c_int {
2609 if filename.is_null() || cur.is_null() {
2610 return -1;
2611 }
2612 crate::xml::tree::xmlSaveFile(filename, cur)
2613}
2614
2615#[no_mangle]
2623pub unsafe extern "C" fn xmlSaveFileEnc(
2624 filename: *const c_char,
2625 cur: *mut _xmlDoc,
2626 encoding: *const c_char,
2627) -> c_int {
2628 if filename.is_null() || cur.is_null() {
2629 return -1;
2630 }
2631 crate::xml::tree::xmlSaveFileEnc(filename, cur, encoding)
2632}
2633
2634#[no_mangle]
2642pub unsafe extern "C" fn xmlSaveFormatFile(
2643 filename: *const c_char,
2644 cur: *mut _xmlDoc,
2645 format: c_int,
2646) -> c_int {
2647 if filename.is_null() || cur.is_null() {
2648 return -1;
2649 }
2650 crate::xml::tree::xmlSaveFormatFile(filename, cur, format)
2651}
2652
2653#[no_mangle]
2661pub unsafe extern "C" fn xmlSaveFormatFileEnc(
2662 filename: *const c_char,
2663 cur: *mut _xmlDoc,
2664 encoding: *const c_char,
2665 format: c_int,
2666) -> c_int {
2667 if filename.is_null() || cur.is_null() {
2668 return -1;
2669 }
2670 crate::xml::tree::xmlSaveFormatFileEnc(filename, cur, encoding, format)
2671}
2672
2673#[no_mangle]
2688pub unsafe extern "C" fn xmlReadDoc(
2689 cur: *const xmlChar,
2690 URL: *const c_char,
2691 encoding: *const c_char,
2692 options: c_int,
2693) -> *mut _xmlDoc {
2694 if cur.is_null() {
2696 return ptr::null_mut();
2697 }
2698 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2699 if ctxt.is_null() {
2700 return ptr::null_mut();
2701 }
2702 let len = crate::xml::string::xml_strlen(cur);
2703 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2704 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2705 (*ctxt).options = options;
2706 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2707 let doc = (*ctxt).myDoc;
2708 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2709 return doc;
2710 }
2711 let doc = (*ctxt).myDoc;
2712 if !doc.is_null() {
2713 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2714 }
2715 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2716 doc
2717}
2718
2719#[no_mangle]
2727pub unsafe extern "C" fn xmlReadFile(
2728 URL: *const c_char,
2729 encoding: *const c_char,
2730 options: c_int,
2731) -> *mut _xmlDoc {
2732 if URL.is_null() {
2734 return ptr::null_mut();
2735 }
2736 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2737 if ctxt.is_null() {
2738 return ptr::null_mut();
2739 }
2740 let input = match crate::xml::parser::helpers::input_from_file(URL) {
2741 Ok(input) => input,
2742 Err(_) => {
2743 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2744 return ptr::null_mut();
2745 }
2746 };
2747 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2748 (*ctxt).options = options;
2749 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2750 let doc = (*ctxt).myDoc;
2751 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2752 if options & 1 << 0 != 0 {
2756 return doc;
2757 }
2758 if !doc.is_null() {
2759 crate::xml::tree::free_doc(doc);
2760 }
2761 return ptr::null_mut();
2762 }
2763 let doc = (*ctxt).myDoc;
2764 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2765 doc
2766}
2767
2768#[no_mangle]
2777pub unsafe extern "C" fn xmlRecoverDoc(cur: *const xmlChar) -> *mut _xmlDoc {
2778 unsafe { xmlReadDoc(cur, ptr::null(), ptr::null(), 1 << 0) }
2779}
2780
2781#[no_mangle]
2789pub unsafe extern "C" fn xmlRecoverFile(filename: *const c_char) -> *mut _xmlDoc {
2790 unsafe { xmlReadFile(filename, ptr::null(), 1 << 0) }
2791}
2792
2793#[no_mangle]
2801pub unsafe extern "C" fn xmlRecoverMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
2802 unsafe { xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 1 << 0) }
2803}
2804
2805#[no_mangle]
2814pub unsafe extern "C" fn xmlReadMemory(
2815 buffer: *const c_char,
2816 size: c_int,
2817 URL: *const c_char,
2818 encoding: *const c_char,
2819 options: c_int,
2820) -> *mut _xmlDoc {
2821 if buffer.is_null() || size < 0 {
2825 return ptr::null_mut();
2826 }
2827 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2828 if ctxt.is_null() {
2829 return ptr::null_mut();
2830 }
2831 let input = crate::xml::parser::helpers::input_from_memory_named(buffer, size, URL);
2834 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2835 crate::abi::exports_parser::apply_options(ctxt, options);
2839 let parsed = crate::xml::parser::helpers::parse_document(ctxt);
2840 let doc = (*ctxt).myDoc;
2841 if !doc.is_null() && !URL.is_null() && (*doc).URL.is_null() {
2844 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2845 }
2846 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2847 if parsed != 0 {
2848 if options & 1 << 0 != 0 {
2852 return doc;
2853 }
2854 if !doc.is_null() {
2855 crate::xml::tree::free_doc(doc);
2856 }
2857 return ptr::null_mut();
2858 }
2859 doc
2860}
2861
2862#[no_mangle]
2868pub unsafe extern "C" fn xmlLoadCatalogs(catalogs: *const c_char) {
2869 if !catalogs.is_null() {
2870 crate::xml::catalog::load_catalog(catalogs);
2871 }
2872}
2873
2874#[no_mangle]
2880pub unsafe extern "C" fn xmlLoadCatalog(catalogs: *const c_char) -> c_int {
2881 let handle = crate::xml::catalog::load_catalog(catalogs);
2884 if handle.is_null() {
2885 1
2886 } else {
2887 0
2888 }
2889}
2890
2891#[no_mangle]
2899pub unsafe extern "C" fn xmlReadFd(
2900 fd: c_int,
2901 URL: *const c_char,
2902 encoding: *const c_char,
2903 options: c_int,
2904) -> *mut _xmlDoc {
2905 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2907 if ctxt.is_null() {
2908 return ptr::null_mut();
2909 }
2910 let mut buf = Vec::new();
2912 let mut tmp = [0u8; 4096];
2913 loop {
2914 let n = libc::read(fd, tmp.as_mut_ptr() as *mut c_void, tmp.len());
2915 if n <= 0 {
2916 break;
2917 }
2918 buf.extend_from_slice(&tmp[..n as usize]);
2919 }
2920 let input = crate::xml::parser::helpers::input_from_memory(
2921 buf.as_ptr() as *const c_char,
2922 buf.len() as c_int,
2923 );
2924 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2925 (*ctxt).options = options;
2926 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2927 let doc = (*ctxt).myDoc;
2928 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2929 return doc;
2930 }
2931 let doc = (*ctxt).myDoc;
2932 if !doc.is_null() && !URL.is_null() {
2933 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2934 }
2935 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2936 doc
2937}
2938
2939#[no_mangle]
2948pub unsafe extern "C" fn xmlReadIO(
2949 ioread: Option<xmlInputReadCallback>,
2950 ioclose: Option<xmlInputCloseCallback>,
2951 ioctx: *mut c_void,
2952 URL: *const c_char,
2953 encoding: *const c_char,
2954 options: c_int,
2955) -> *mut _xmlDoc {
2956 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2958 if ctxt.is_null() {
2959 return ptr::null_mut();
2960 }
2961 let input = crate::xml::parser::helpers::input_from_io(ioread, ioclose, ioctx);
2962 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2963 (*ctxt).options = options;
2964 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2965 let doc = (*ctxt).myDoc;
2966 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2967 return doc;
2968 }
2969 let doc = (*ctxt).myDoc;
2970 if !doc.is_null() && !URL.is_null() {
2971 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2972 }
2973 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2974 doc
2975}
2976
2977#[no_mangle]
2985pub unsafe extern "C" fn xmlSAXParseDoc(
2986 sax: *mut _xmlSAXHandler,
2987 cur: *const xmlChar,
2988 recovery: c_int,
2989) -> *mut _xmlDoc {
2990 if cur.is_null() {
2992 return ptr::null_mut();
2993 }
2994 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2995 if ctxt.is_null() {
2996 return ptr::null_mut();
2997 }
2998 if !sax.is_null() {
2999 (*ctxt).sax = sax;
3000 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3001 }
3002 if recovery != 0 {
3003 (*ctxt).recovery = 1;
3004 (*ctxt).options |= 1; }
3006 let len = crate::xml::string::xml_strlen(cur);
3007 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
3008 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3009 crate::xml::parser::helpers::parse_document(ctxt);
3010 let doc = (*ctxt).myDoc;
3011 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3012 doc
3013}
3014
3015#[no_mangle]
3025pub unsafe extern "C" fn xmlSAXParseDocWithData(
3026 sax: *mut _xmlSAXHandler,
3027 cur: *const xmlChar,
3028 recovery: c_int,
3029 data: *mut c_void,
3030) -> *mut _xmlDoc {
3031 if cur.is_null() {
3033 return ptr::null_mut();
3034 }
3035 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3036 if ctxt.is_null() {
3037 return ptr::null_mut();
3038 }
3039 if !sax.is_null() {
3040 (*ctxt).sax = sax;
3041 }
3042 (*ctxt).userData = data;
3043 if recovery != 0 {
3044 (*ctxt).recovery = 1;
3045 (*ctxt).options |= 1; }
3047 let len = crate::xml::string::xml_strlen(cur);
3048 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
3049 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3050 crate::xml::parser::helpers::parse_document(ctxt);
3051 let doc = (*ctxt).myDoc;
3052 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3053 doc
3054}
3055
3056#[no_mangle]
3066pub unsafe extern "C" fn xmlSAXParseFileWithData(
3067 sax: *mut _xmlSAXHandler,
3068 filename: *const c_char,
3069 recovery: c_int,
3070 data: *mut c_void,
3071) -> *mut _xmlDoc {
3072 if filename.is_null() {
3074 return ptr::null_mut();
3075 }
3076 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3077 if ctxt.is_null() {
3078 return ptr::null_mut();
3079 }
3080 if !sax.is_null() {
3081 (*ctxt).sax = sax;
3082 }
3083 (*ctxt).userData = data;
3084 if recovery != 0 {
3085 (*ctxt).recovery = 1;
3086 (*ctxt).options |= 1; }
3088 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3089 Ok(input) => input,
3090 Err(_) => {
3091 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3092 return ptr::null_mut();
3093 }
3094 };
3095 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3096 crate::xml::parser::helpers::parse_document(ctxt);
3097 let doc = (*ctxt).myDoc;
3098 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3099 doc
3100}
3101
3102#[no_mangle]
3112pub unsafe extern "C" fn xmlSAXParseMemoryWithData(
3113 sax: *mut _xmlSAXHandler,
3114 buffer: *const c_char,
3115 size: c_int,
3116 recovery: c_int,
3117 data: *mut c_void,
3118) -> *mut _xmlDoc {
3119 if buffer.is_null() || size <= 0 {
3121 return ptr::null_mut();
3122 }
3123 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3124 if ctxt.is_null() {
3125 return ptr::null_mut();
3126 }
3127 if !sax.is_null() {
3128 (*ctxt).sax = sax;
3129 }
3130 (*ctxt).userData = data;
3131 if recovery != 0 {
3132 (*ctxt).recovery = 1;
3133 (*ctxt).options |= 1; }
3135 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3136 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3137 crate::xml::parser::helpers::parse_document(ctxt);
3138 let doc = (*ctxt).myDoc;
3139 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3140 doc
3141}
3142
3143#[no_mangle]
3151pub unsafe extern "C" fn xmlSAXParseFile(
3152 sax: *mut _xmlSAXHandler,
3153 filename: *const c_char,
3154 recovery: c_int,
3155) -> *mut _xmlDoc {
3156 if filename.is_null() {
3158 return ptr::null_mut();
3159 }
3160 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3161 if ctxt.is_null() {
3162 return ptr::null_mut();
3163 }
3164 if !sax.is_null() {
3165 (*ctxt).sax = sax;
3166 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3167 }
3168 if recovery != 0 {
3169 (*ctxt).recovery = 1;
3170 (*ctxt).options |= 1;
3171 }
3172 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3173 Ok(input) => input,
3174 Err(_) => {
3175 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3176 return ptr::null_mut();
3177 }
3178 };
3179 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3180 crate::xml::parser::helpers::parse_document(ctxt);
3181 let doc = (*ctxt).myDoc;
3182 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3183 doc
3184}
3185
3186#[no_mangle]
3195pub unsafe extern "C" fn xmlSAXParseMemory(
3196 sax: *mut _xmlSAXHandler,
3197 buffer: *const c_char,
3198 size: c_int,
3199 recovery: c_int,
3200) -> *mut _xmlDoc {
3201 if buffer.is_null() || size <= 0 {
3203 return ptr::null_mut();
3204 }
3205 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3206 if ctxt.is_null() {
3207 return ptr::null_mut();
3208 }
3209 if !sax.is_null() {
3210 (*ctxt).sax = sax;
3211 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3212 }
3213 if recovery != 0 {
3214 (*ctxt).recovery = 1;
3215 (*ctxt).options |= 1;
3216 }
3217 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3218 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3219 crate::xml::parser::helpers::parse_document(ctxt);
3220 let doc = (*ctxt).myDoc;
3221 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3222 doc
3223}
3224
3225#[no_mangle]
3234pub unsafe extern "C" fn xmlSAXUserParseFile(
3235 sax: *mut _xmlSAXHandler,
3236 user_data: *mut c_void,
3237 filename: *const c_char,
3238) -> c_int {
3239 if filename.is_null() {
3241 return -1;
3242 }
3243 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3244 if ctxt.is_null() {
3245 return -1;
3246 }
3247 if !sax.is_null() {
3248 (*ctxt).sax = sax;
3249 }
3250 (*ctxt).userData = if !user_data.is_null() {
3251 user_data
3252 } else {
3253 ctxt as *mut c_void
3254 };
3255 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3256 Ok(input) => input,
3257 Err(_) => {
3258 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3259 return -1;
3260 }
3261 };
3262 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3263 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3264 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3265 ret
3266}
3267
3268#[no_mangle]
3277pub unsafe extern "C" fn xmlSAXUserParseMemory(
3278 sax: *mut _xmlSAXHandler,
3279 user_data: *mut c_void,
3280 buffer: *const c_char,
3281 size: c_int,
3282) -> c_int {
3283 if buffer.is_null() || size <= 0 {
3285 return -1;
3286 }
3287 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3288 if ctxt.is_null() {
3289 return -1;
3290 }
3291 if !sax.is_null() {
3292 (*ctxt).sax = sax;
3293 }
3294 (*ctxt).userData = if !user_data.is_null() {
3295 user_data
3296 } else {
3297 ctxt as *mut c_void
3298 };
3299 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3300 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3301 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3302 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3303 ret
3304}
3305
3306#[no_mangle]
3314pub unsafe extern "C" fn xmlParseDoc(cur: *const xmlChar) -> *mut _xmlDoc {
3315 if cur.is_null() {
3317 return ptr::null_mut();
3318 }
3319 xmlReadDoc(cur, ptr::null(), ptr::null(), 0)
3320}
3321
3322#[no_mangle]
3330pub unsafe extern "C" fn xmlParseFile(filename: *const c_char) -> *mut _xmlDoc {
3331 if filename.is_null() {
3333 return ptr::null_mut();
3334 }
3335 xmlReadFile(filename, ptr::null(), 0)
3336}
3337
3338#[no_mangle]
3346pub unsafe extern "C" fn xmlParseMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
3347 if buffer.is_null() || size <= 0 {
3349 return ptr::null_mut();
3350 }
3351 xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 0)
3352}
3353
3354#[no_mangle]
3362pub unsafe extern "C" fn xmlCreateFileParserCtxt(filename: *const c_char) -> *mut _xmlParserCtxt {
3363 if filename.is_null() {
3365 return ptr::null_mut();
3366 }
3367 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3368 if ctxt.is_null() {
3369 return ptr::null_mut();
3370 }
3371 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3372 Ok(input) => input,
3373 Err(_) => {
3374 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3375 return ptr::null_mut();
3376 }
3377 };
3378 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3379 ctxt
3380}
3381
3382#[no_mangle]
3390pub unsafe extern "C" fn xmlCreateDocParserCtxt(cur: *const xmlChar) -> *mut _xmlParserCtxt {
3391 if cur.is_null() {
3393 return ptr::null_mut();
3394 }
3395 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3396 if ctxt.is_null() {
3397 return ptr::null_mut();
3398 }
3399 let len = crate::xml::string::xml_strlen(cur);
3400 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
3401 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3402 ctxt
3403}
3404
3405#[no_mangle]
3413pub unsafe extern "C" fn xmlParseDocument(ctxt: *mut _xmlParserCtxt) -> c_int {
3414 if ctxt.is_null() {
3416 return -1;
3417 }
3418 crate::xml::parser::helpers::parse_document(ctxt)
3419}
3420
3421#[no_mangle]
3429pub unsafe extern "C" fn xmlFreeParserCtxt(ctxt: *mut _xmlParserCtxt) {
3430 if ctxt.is_null() {
3431 return;
3432 }
3433 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3434}
3435
3436#[no_mangle]
3444pub unsafe extern "C" fn xmlCtxtUseOptions(ctxt: *mut _xmlParserCtxt, options: c_int) -> c_int {
3445 if ctxt.is_null() {
3446 return -1;
3447 }
3448 unsafe {
3450 (*ctxt).options = options;
3451 }
3452 0
3453}
3454
3455#[no_mangle]
3464pub unsafe extern "C" fn xmlParseChunk(
3465 ctxt: *mut _xmlParserCtxt,
3466 chunk: *const c_char,
3467 size: c_int,
3468 terminate: c_int,
3469) -> c_int {
3470 if ctxt.is_null() {
3473 return -1;
3474 }
3475 crate::xml::parser::helpers::parse_chunk(ctxt, chunk, size, terminate)
3476}
3477
3478#[no_mangle]
3486pub unsafe extern "C" fn xmlParserInputBufferCreateMem(
3487 buffer: *const c_char,
3488 size: c_int,
3489 enc: c_int,
3490) -> *mut _xmlParserInputBuffer {
3491 if buffer.is_null() || size <= 0 {
3493 return ptr::null_mut();
3494 }
3495 crate::xml::parser::helpers::alloc_parser_input_buffer()
3496}
3497
3498#[no_mangle]
3506pub unsafe extern "C" fn xmlParserInputBufferCreateFilename(
3507 URI: *const c_char,
3508 enc: c_int,
3509) -> *mut _xmlParserInputBuffer {
3510 if URI.is_null() {
3512 return ptr::null_mut();
3513 }
3514 crate::xml::parser::helpers::alloc_parser_input_buffer()
3515}
3516
3517#[no_mangle]
3527pub unsafe extern "C" fn xmlParserInputBufferCreateIO(
3528 ioread: Option<xmlInputReadCallback>,
3529 ioclose: Option<xmlInputCloseCallback>,
3530 ioctx: *mut c_void,
3531 enc: c_int,
3532) -> *mut _xmlParserInputBuffer {
3533 let buf = crate::xml::parser::helpers::alloc_parser_input_buffer();
3535 if !buf.is_null() {
3536 (*buf).readcallback = ioread;
3537 (*buf).closecallback = ioclose;
3538 (*buf).context = ioctx;
3539 }
3540 buf
3541}
3542
3543#[no_mangle]
3551pub unsafe extern "C" fn xmlFreeParserInputBuffer(buf: *mut _xmlParserInputBuffer) {
3552 if buf.is_null() {
3553 return;
3554 }
3555 crate::xml::parser::helpers::free_parser_input_buffer(buf);
3556}
3557
3558#[no_mangle]
3566pub unsafe extern "C" fn xmlNewInputFromFile(
3567 ctxt: *mut _xmlParserCtxt,
3568 filename: *const c_char,
3569) -> *mut _xmlParserInput {
3570 if filename.is_null() {
3575 return ptr::null_mut();
3576 }
3577 crate::xml::parser::helpers::alloc_parser_input_buffer() as *mut _xmlParserInput
3578}
3579
3580#[no_mangle]
3588pub unsafe extern "C" fn xmlFreeInputStream(input: *mut _xmlParserInput) {
3589 if input.is_null() {
3590 return;
3591 }
3592 crate::xml::parser::helpers::free_parser_input(input);
3593}
3594
3595#[no_mangle]
3609pub unsafe extern "C" fn xmlOutputBufferCreateFilename(
3610 URI: *const c_char,
3611 encoder: *mut c_void,
3612 compression: c_int,
3613) -> *mut _xmlOutputBuffer {
3614 let _ = compression;
3615 if URI.is_null() {
3616 return ptr::null_mut();
3617 }
3618 crate::xml::io::output_buffer_create_filename(
3619 URI,
3620 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3621 0,
3622 )
3623}
3624
3625#[no_mangle]
3634pub unsafe extern "C" fn xmlOutputBufferCreateFd(
3635 fd: c_int,
3636 encoder: *mut c_void,
3637) -> *mut _xmlOutputBuffer {
3638 if fd < 0 {
3639 return ptr::null_mut();
3640 }
3641 crate::xml::io::output_buffer_create_fd(
3642 fd,
3643 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3644 )
3645}
3646
3647#[no_mangle]
3657pub unsafe extern "C" fn xmlOutputBufferCreateIO(
3658 iowrite: Option<xmlOutputWriteCallback>,
3659 ioclose: Option<xmlOutputCloseCallback>,
3660 ioctx: *mut c_void,
3661 encoder: *mut c_void,
3662) -> *mut _xmlOutputBuffer {
3663 crate::xml::io::output_buffer_create_io(
3664 iowrite,
3665 ioclose,
3666 ioctx,
3667 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3668 )
3669}
3670
3671#[no_mangle]
3679pub unsafe extern "C" fn xmlOutputBufferClose(out: *mut _xmlOutputBuffer) -> c_int {
3680 if out.is_null() {
3681 return -1;
3682 }
3683 crate::xml::io::output_buffer_close(out)
3684}
3685
3686#[no_mangle]
3694pub unsafe extern "C" fn xmlOutputBufferFlush(out: *mut _xmlOutputBuffer) -> c_int {
3695 if out.is_null() {
3696 return -1;
3697 }
3698 crate::xml::io::output_buffer_flush(out)
3699}
3700
3701#[no_mangle]
3709pub unsafe extern "C" fn xmlOutputBufferWrite(
3710 out: *mut _xmlOutputBuffer,
3711 len: c_int,
3712 data: *const c_char,
3713) -> c_int {
3714 if out.is_null() || data.is_null() || len <= 0 {
3715 return -1;
3716 }
3717 crate::xml::io::output_buffer_write(out, len, data)
3718}
3719
3720#[no_mangle]
3728pub unsafe extern "C" fn xmlOutputBufferWriteString(
3729 out: *mut _xmlOutputBuffer,
3730 str: *const c_char,
3731) -> c_int {
3732 if str.is_null() {
3733 return 0;
3734 }
3735 unsafe { xmlOutputBufferWrite(out, xmlStrlen(str as *const xmlChar), str) }
3736}
3737
3738#[no_mangle]
3746pub unsafe extern "C" fn xmlAllocOutputBuffer(encoder: *mut c_void) -> *mut _xmlOutputBuffer {
3747 crate::xml::io::output_buffer_create(
3748 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3749 )
3750}
3751
3752#[no_mangle]
3766pub unsafe extern "C" fn xmlOutputBufferCreateBuffer(
3767 buffer: *mut crate::abi::structs::_xmlBuffer,
3768 encoder: *mut c_void,
3769) -> *mut _xmlOutputBuffer {
3770 crate::xml::io::output_buffer_create_buffer(
3771 buffer,
3772 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3773 )
3774}
3775
3776#[no_mangle]
3784pub unsafe extern "C" fn xmlOutputBufferCreateFile(
3785 file: *mut libc::FILE,
3786 encoder: *mut c_void,
3787) -> *mut _xmlOutputBuffer {
3788 crate::xml::io::output_buffer_create_file(
3789 file,
3790 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3791 )
3792}
3793
3794#[no_mangle]
3800pub unsafe extern "C" fn xmlOutputBufferGetContent(out: *mut _xmlOutputBuffer) -> *const c_char {
3801 crate::xml::io::output_buffer_get_content(out) as *const c_char
3802}
3803
3804#[no_mangle]
3811pub unsafe extern "C" fn xmlOutputBufferGetSize(out: *mut _xmlOutputBuffer) -> c_int {
3812 crate::xml::io::output_buffer_get_size(out)
3813}
3814
3815#[no_mangle]
3823pub unsafe extern "C" fn xmlOutputBufferWriteEscape(
3824 out: *mut _xmlOutputBuffer,
3825 str: *const xmlChar,
3826 escaping: Option<xmlCharEncodingOutputFunc>,
3827) -> c_int {
3828 if out.is_null() || str.is_null() {
3829 return -1;
3830 }
3831 crate::xml::io::output_buffer_write_escape(out, str, escaping)
3832}
3833
3834static mut OUTPUT_CREATE_FILENAME_DEFAULT: Option<
3837 unsafe extern "C" fn(
3838 *const c_char,
3839 *mut crate::abi::structs::_xmlCharEncodingHandler,
3840 c_int,
3841 ) -> *mut _xmlOutputBuffer,
3842> = None;
3843
3844#[no_mangle]
3851pub unsafe extern "C" fn xmlOutputBufferCreateFilenameDefault(
3852 func: Option<
3853 unsafe extern "C" fn(
3854 *const c_char,
3855 *mut crate::abi::structs::_xmlCharEncodingHandler,
3856 c_int,
3857 ) -> *mut _xmlOutputBuffer,
3858 >,
3859) -> Option<
3860 unsafe extern "C" fn(
3861 *const c_char,
3862 *mut crate::abi::structs::_xmlCharEncodingHandler,
3863 c_int,
3864 ) -> *mut _xmlOutputBuffer,
3865> {
3866 let old = unsafe { OUTPUT_CREATE_FILENAME_DEFAULT };
3867 if func.is_some() {
3868 unsafe { OUTPUT_CREATE_FILENAME_DEFAULT = func };
3869 }
3870 old
3871}
3872
3873#[no_mangle]
3876pub unsafe extern "C" fn __xmlOutputBufferCreateFilename() -> *mut Option<
3877 unsafe extern "C" fn(
3878 *const c_char,
3879 *mut crate::abi::structs::_xmlCharEncodingHandler,
3880 c_int,
3881 ) -> *mut _xmlOutputBuffer,
3882> {
3883 core::ptr::addr_of_mut!(OUTPUT_CREATE_FILENAME_DEFAULT)
3884}
3885
3886#[no_mangle]
3898pub extern "C" fn xmlDictCreate() -> *mut c_void {
3899 let d = { crate::xml::dictionary::dict_create() as *mut c_void };
3900 if !d.is_null() {
3901 *crate::abi::exports_hash::DICT_REFS
3905 .lock()
3906 .entry(d as usize)
3907 .or_insert(0) = 1;
3908 }
3909 d
3910}
3911
3912#[no_mangle]
3920pub extern "C" fn xmlDictCreateSub(sub: *mut c_void) -> *mut c_void {
3921 let d = unsafe {
3922 crate::xml::dictionary::dict_create_sub(sub as *mut crate::xml::dictionary::Dict)
3923 as *mut c_void
3924 };
3925 if !d.is_null() {
3926 *crate::abi::exports_hash::DICT_REFS
3927 .lock()
3928 .entry(d as usize)
3929 .or_insert(0) = 1;
3930 }
3931 d
3932}
3933
3934#[no_mangle]
3946pub unsafe extern "C" fn xmlDictLookup(
3947 dict: *mut c_void,
3948 name: *const xmlChar,
3949 len: c_int,
3950) -> *const xmlChar {
3951 unsafe {
3952 crate::xml::dictionary::dict_lookup(dict as *mut crate::xml::dictionary::Dict, name, len)
3953 }
3954}
3955
3956#[no_mangle]
3964pub unsafe extern "C" fn xmlDictExists(
3965 dict: *mut c_void,
3966 name: *const xmlChar,
3967 len: c_int,
3968) -> *const xmlChar {
3969 unsafe {
3970 crate::xml::dictionary::dict_exists(dict as *mut crate::xml::dictionary::Dict, name, len)
3971 }
3972}
3973
3974#[no_mangle]
3982pub const extern "C" fn xmlDictSize(dict: *const c_void) -> c_uint {
3983 {
3984 crate::xml::dictionary::dict_size(dict as *const crate::xml::dictionary::Dict) as c_uint
3985 }
3986}
3987
3988#[no_mangle]
4000pub extern "C" fn xmlDictFree(dict: *mut c_void) {
4001 if dict.is_null() {
4002 return;
4003 }
4004 let mut remaining = 0u32;
4005 {
4006 let mut refs = crate::abi::exports_hash::DICT_REFS.lock();
4007 if let Some(r) = refs.get_mut(&(dict as usize)) {
4008 if *r > 0 {
4009 *r -= 1;
4010 }
4011 remaining = *r;
4012 if remaining == 0 {
4013 refs.remove(&(dict as usize));
4014 }
4015 }
4016 }
4017 if remaining == 0 {
4018 unsafe { crate::xml::dictionary::dict_free(dict as *mut crate::xml::dictionary::Dict) };
4019 }
4020}
4021
4022#[no_mangle]
4030pub extern "C" fn xmlDictSetLimit(dict: *mut c_void, limit: c_uint) -> c_uint {
4031 {
4032 crate::xml::dictionary::dict_set_limit(
4033 dict as *mut crate::xml::dictionary::Dict,
4034 limit as usize,
4035 ) as c_uint
4036 }
4037}
4038
4039#[no_mangle]
4047pub extern "C" fn xmlDictGetUsage(dict: *const c_void) -> c_uint {
4048 {
4049 crate::xml::dictionary::dict_get_usage(dict as *mut crate::xml::dictionary::Dict) as c_uint
4050 }
4051}
4052
4053#[no_mangle]
4065pub extern "C" fn xmlHashCreate(size: c_int) -> *mut c_void {
4066 crate::xml::hash::hash_create(size) as *mut c_void
4067}
4068
4069#[no_mangle]
4077pub extern "C" fn xmlHashCreateDict(size: c_int, dict: *mut c_void) -> *mut c_void {
4078 crate::xml::hash::hash_create_dict(size, dict) as *mut c_void
4079}
4080
4081#[no_mangle]
4089pub extern "C" fn xmlHashFree(
4090 table: *mut c_void,
4091 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4092) {
4093 unsafe { crate::xml::hash::hash_free(table as *mut crate::xml::hash::HashTable, f) }
4094}
4095
4096#[no_mangle]
4104pub unsafe extern "C" fn xmlHashAddEntry(
4105 table: *mut c_void,
4106 name: *const xmlChar,
4107 userdata: *mut c_void,
4108) -> c_int {
4109 unsafe {
4110 crate::xml::hash::hash_add_entry(table as *mut crate::xml::hash::HashTable, name, userdata)
4111 }
4112}
4113
4114#[no_mangle]
4123pub unsafe extern "C" fn xmlHashAddEntry2(
4124 table: *mut c_void,
4125 name: *const xmlChar,
4126 name2: *const xmlChar,
4127 userdata: *mut c_void,
4128) -> c_int {
4129 unsafe {
4130 crate::xml::hash::hash_add_entry2(
4131 table as *mut crate::xml::hash::HashTable,
4132 name,
4133 name2,
4134 userdata,
4135 )
4136 }
4137}
4138
4139#[no_mangle]
4148pub unsafe extern "C" fn xmlHashAddEntry3(
4149 table: *mut c_void,
4150 name: *const xmlChar,
4151 name2: *const xmlChar,
4152 name3: *const xmlChar,
4153 userdata: *mut c_void,
4154) -> c_int {
4155 unsafe {
4156 crate::xml::hash::hash_add_entry3(
4157 table as *mut crate::xml::hash::HashTable,
4158 name,
4159 name2,
4160 name3,
4161 userdata,
4162 )
4163 }
4164}
4165
4166#[no_mangle]
4175pub unsafe extern "C" fn xmlHashUpdateEntry(
4176 table: *mut c_void,
4177 name: *const xmlChar,
4178 userdata: *mut c_void,
4179 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4180) -> c_int {
4181 unsafe {
4182 crate::xml::hash::hash_update_entry(
4183 table as *mut crate::xml::hash::HashTable,
4184 name,
4185 userdata,
4186 f,
4187 )
4188 }
4189}
4190
4191#[no_mangle]
4193pub unsafe extern "C" fn xmlHashUpdateEntry2(
4194 table: *mut c_void,
4195 name: *const xmlChar,
4196 name2: *const xmlChar,
4197 userdata: *mut c_void,
4198 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4199) -> c_int {
4200 unsafe {
4201 crate::xml::hash::hash_update_entry2(
4202 table as *mut crate::xml::hash::HashTable,
4203 name,
4204 name2,
4205 userdata,
4206 f,
4207 )
4208 }
4209}
4210
4211#[no_mangle]
4213pub unsafe extern "C" fn xmlHashUpdateEntry3(
4214 table: *mut c_void,
4215 name: *const xmlChar,
4216 name2: *const xmlChar,
4217 name3: *const xmlChar,
4218 userdata: *mut c_void,
4219 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4220) -> c_int {
4221 unsafe {
4222 crate::xml::hash::hash_update_entry3(
4223 table as *mut crate::xml::hash::HashTable,
4224 name,
4225 name2,
4226 name3,
4227 userdata,
4228 f,
4229 )
4230 }
4231}
4232
4233#[no_mangle]
4241pub unsafe extern "C" fn xmlHashLookup(table: *mut c_void, name: *const xmlChar) -> *mut c_void {
4242 unsafe { crate::xml::hash::hash_lookup(table as *mut crate::xml::hash::HashTable, name) }
4243}
4244
4245#[no_mangle]
4247pub unsafe extern "C" fn xmlHashLookup2(
4248 table: *mut c_void,
4249 name: *const xmlChar,
4250 name2: *const xmlChar,
4251) -> *mut c_void {
4252 unsafe {
4253 crate::xml::hash::hash_lookup2(table as *mut crate::xml::hash::HashTable, name, name2)
4254 }
4255}
4256
4257#[no_mangle]
4259pub unsafe extern "C" fn xmlHashLookup3(
4260 table: *mut c_void,
4261 name: *const xmlChar,
4262 name2: *const xmlChar,
4263 name3: *const xmlChar,
4264) -> *mut c_void {
4265 unsafe {
4266 crate::xml::hash::hash_lookup3(
4267 table as *mut crate::xml::hash::HashTable,
4268 name,
4269 name2,
4270 name3,
4271 )
4272 }
4273}
4274
4275#[no_mangle]
4283pub extern "C" fn xmlHashSize(table: *mut c_void) -> c_int {
4284 crate::xml::hash::hash_size(table as *mut crate::xml::hash::HashTable)
4285}
4286
4287#[no_mangle]
4296pub unsafe extern "C" fn xmlHashRemoveEntry(
4297 table: *mut c_void,
4298 name: *const xmlChar,
4299 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4300) -> c_int {
4301 unsafe {
4302 crate::xml::hash::hash_remove_entry(table as *mut crate::xml::hash::HashTable, name, f)
4303 }
4304}
4305
4306#[no_mangle]
4308pub unsafe extern "C" fn xmlHashRemoveEntry2(
4309 table: *mut c_void,
4310 name: *const xmlChar,
4311 name2: *const xmlChar,
4312 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4313) -> c_int {
4314 unsafe {
4315 crate::xml::hash::hash_remove_entry2(
4316 table as *mut crate::xml::hash::HashTable,
4317 name,
4318 name2,
4319 f,
4320 )
4321 }
4322}
4323
4324#[no_mangle]
4326pub unsafe extern "C" fn xmlHashRemoveEntry3(
4327 table: *mut c_void,
4328 name: *const xmlChar,
4329 name2: *const xmlChar,
4330 name3: *const xmlChar,
4331 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4332) -> c_int {
4333 unsafe {
4334 crate::xml::hash::hash_remove_entry3(
4335 table as *mut crate::xml::hash::HashTable,
4336 name,
4337 name2,
4338 name3,
4339 f,
4340 )
4341 }
4342}
4343
4344#[no_mangle]
4352pub extern "C" fn xmlHashScan(table: *mut c_void, f: Option<xmlHashScanner>, data: *mut c_void) {
4353 unsafe { crate::xml::hash::hash_scan(table as *mut crate::xml::hash::HashTable, f, data) }
4354}
4355
4356#[no_mangle]
4358pub extern "C" fn xmlHashScanFull(
4359 table: *mut c_void,
4360 f: Option<xmlHashScannerFull>,
4361 data: *mut c_void,
4362) {
4363 unsafe { crate::xml::hash::hash_scan_full(table as *mut crate::xml::hash::HashTable, f, data) }
4364}
4365
4366#[no_mangle]
4374pub extern "C" fn xmlHashCopy(
4375 table: *mut c_void,
4376 f: Option<unsafe extern "C" fn(*mut c_void, *const xmlChar) -> *mut c_void>,
4377) -> *mut c_void {
4378 unsafe {
4379 crate::xml::hash::hash_copy(table as *mut crate::xml::hash::HashTable, f) as *mut c_void
4380 }
4381}
4382
4383#[no_mangle]
4396pub extern "C" fn xmlListCreate(
4397 deallocator: Option<unsafe extern "C" fn(*mut c_void)>,
4398 compare: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
4399) -> *mut c_void {
4400 crate::xml::list::list_create(deallocator, compare) as *mut c_void
4401}
4402
4403#[no_mangle]
4411pub extern "C" fn xmlListDelete(list: *mut c_void) {
4412 unsafe { crate::xml::list::list_delete(list as *mut crate::xml::list::List) }
4413}
4414
4415#[no_mangle]
4423pub extern "C" fn xmlListSearch(list: *mut c_void, data: *mut c_void) -> *mut c_void {
4424 unsafe { crate::xml::list::list_search(list as *mut crate::xml::list::List, data) }
4425}
4426
4427#[no_mangle]
4435pub extern "C" fn xmlListWalk(
4436 list: *mut c_void,
4437 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4438 data: *mut c_void,
4439) {
4440 unsafe { crate::xml::list::list_walk(list as *mut crate::xml::list::List, walker, data) }
4441}
4442
4443#[no_mangle]
4451pub extern "C" fn xmlListPushBack(list: *mut c_void, data: *mut c_void) -> c_int {
4452 unsafe { crate::xml::list::list_push_back(list as *mut crate::xml::list::List, data) }
4453}
4454
4455#[no_mangle]
4463pub extern "C" fn xmlListPushFront(list: *mut c_void, data: *mut c_void) -> c_int {
4464 unsafe { crate::xml::list::list_push_front(list as *mut crate::xml::list::List, data) }
4465}
4466
4467#[no_mangle]
4469pub extern "C" fn xmlListPopBack(list: *mut c_void) {
4470 unsafe { crate::xml::list::list_pop_back(list as *mut crate::xml::list::List) }
4471}
4472
4473#[no_mangle]
4475pub extern "C" fn xmlListPopFront(list: *mut c_void) {
4476 unsafe { crate::xml::list::list_pop_front(list as *mut crate::xml::list::List) }
4477}
4478
4479#[no_mangle]
4487pub extern "C" fn xmlListInsert(list: *mut c_void, data: *mut c_void) -> c_int {
4488 unsafe { crate::xml::list::list_insert(list as *mut crate::xml::list::List, data) }
4489}
4490
4491#[no_mangle]
4493pub extern "C" fn xmlListAppend(list: *mut c_void, data: *mut c_void) -> c_int {
4494 unsafe { crate::xml::list::list_append(list as *mut crate::xml::list::List, data) }
4495}
4496
4497#[no_mangle]
4499pub extern "C" fn xmlListRemoveFirst(list: *mut c_void, data: *mut c_void) -> c_int {
4500 unsafe { crate::xml::list::list_remove_first(list as *mut crate::xml::list::List, data) }
4501}
4502
4503#[no_mangle]
4505pub extern "C" fn xmlListRemoveLast(list: *mut c_void, data: *mut c_void) -> c_int {
4506 unsafe { crate::xml::list::list_remove_last(list as *mut crate::xml::list::List, data) }
4507}
4508
4509#[no_mangle]
4511pub extern "C" fn xmlListRemoveAll(list: *mut c_void, data: *mut c_void) -> c_int {
4512 unsafe { crate::xml::list::list_remove_all(list as *mut crate::xml::list::List, data) }
4513}
4514
4515#[no_mangle]
4517pub extern "C" fn xmlListClear(list: *mut c_void) {
4518 unsafe { crate::xml::list::list_clear(list as *mut crate::xml::list::List) }
4519}
4520
4521#[no_mangle]
4529pub extern "C" fn xmlListEmpty(list: *mut c_void) -> c_int {
4530 crate::xml::list::list_empty(list as *mut crate::xml::list::List)
4531}
4532
4533#[no_mangle]
4541pub extern "C" fn xmlListFront(list: *mut c_void) -> *mut c_void {
4542 crate::xml::list::list_front(list as *mut crate::xml::list::List)
4543}
4544
4545#[no_mangle]
4553pub extern "C" fn xmlListBack(list: *mut c_void) -> *mut c_void {
4554 crate::xml::list::list_back(list as *mut crate::xml::list::List)
4555}
4556
4557#[no_mangle]
4565pub extern "C" fn xmlListSize(list: *mut c_void) -> c_int {
4566 crate::xml::list::list_size(list as *mut crate::xml::list::List)
4567}
4568
4569#[no_mangle]
4571pub extern "C" fn xmlListSort(list: *mut c_void) {
4572 unsafe { crate::xml::list::list_sort(list as *mut crate::xml::list::List) }
4573}
4574
4575#[no_mangle]
4577pub extern "C" fn xmlListReverse(list: *mut c_void) {
4578 unsafe { crate::xml::list::list_reverse(list as *mut crate::xml::list::List) }
4579}
4580
4581#[no_mangle]
4583pub extern "C" fn xmlListReverseSplice(list: *mut c_void, list2: *mut c_void) {
4584 unsafe {
4585 crate::xml::list::list_reverse_splice(
4586 list as *mut crate::xml::list::List,
4587 list2 as *mut crate::xml::list::List,
4588 )
4589 }
4590}
4591
4592#[no_mangle]
4594pub extern "C" fn xmlListMerge(list: *mut c_void, list2: *mut c_void) {
4595 unsafe {
4596 crate::xml::list::list_merge(
4597 list as *mut crate::xml::list::List,
4598 list2 as *mut crate::xml::list::List,
4599 )
4600 }
4601}
4602#[no_mangle]
4610pub unsafe extern "C" fn xmlListEnd(l: *mut c_void) -> *mut c_void {
4611 crate::xml::list::list_end(l as *mut crate::xml::list::List)
4612}
4613
4614#[no_mangle]
4622pub unsafe extern "C" fn xmlListReverseSearch(l: *mut c_void, data: *mut c_void) -> *mut c_void {
4623 crate::xml::list::list_reverse_search(l as *mut crate::xml::list::List, data)
4624}
4625
4626#[no_mangle]
4634pub unsafe extern "C" fn xmlListReverseWalk(
4635 l: *mut c_void,
4636 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4637 data: *mut c_void,
4638) {
4639 crate::xml::list::list_reverse_walk(l as *mut crate::xml::list::List, walker, data)
4640}
4641
4642#[no_mangle]
4650pub unsafe extern "C" fn xmlListDup(l: *mut c_void) -> *mut c_void {
4651 crate::xml::list::list_dup(l as *mut crate::xml::list::List) as *mut c_void
4652}
4653
4654#[no_mangle]
4665pub unsafe extern "C" fn xmlListCopy(cur: *mut c_void, old: *mut c_void) -> c_int {
4666 crate::xml::list::list_copy(
4667 cur as *mut crate::xml::list::List,
4668 old as *mut crate::xml::list::List,
4669 )
4670}
4671
4672#[no_mangle]
4680pub unsafe extern "C" fn xmlLinkGetData(lk: *mut c_void) -> *mut c_void {
4681 crate::xml::list::link_get_data(lk)
4682}
4683
4684#[no_mangle]
4696pub extern "C" fn xmlBufferCreate() -> *mut _xmlBuffer {
4697 crate::xml::io::buf_create(-1)
4698}
4699
4700#[no_mangle]
4708pub extern "C" fn xmlBufferCreateSize(size: usize) -> *mut _xmlBuffer {
4709 crate::xml::io::buf_create(size as c_int)
4710}
4711
4712#[no_mangle]
4720pub extern "C" fn xmlBufferCreateStatic(mem: *mut c_void, size: usize) -> *mut _xmlBuffer {
4721 if mem.is_null() || size == 0 {
4722 return ptr::null_mut();
4723 }
4724 crate::xml::io::buf_create_static(mem as *const xmlChar, size as c_int)
4725}
4726
4727#[no_mangle]
4735pub extern "C" fn xmlBufferFree(buf: *mut _xmlBuffer) {
4736 crate::xml::io::buf_free(buf)
4737}
4738
4739#[no_mangle]
4747pub extern "C" fn xmlBufferEmpty(buf: *mut _xmlBuffer) {
4748 if buf.is_null() {
4749 return;
4750 }
4751 unsafe {
4752 if !(*buf).content.is_null() {
4753 *(*buf).content = 0;
4754 }
4755 (*buf).use_ = 0;
4756 }
4757}
4758
4759#[no_mangle]
4767pub extern "C" fn xmlBufferContent(buf: *const _xmlBuffer) -> *mut xmlChar {
4768 crate::xml::io::buf_content(buf as *mut _xmlBuffer)
4769}
4770
4771#[no_mangle]
4779pub extern "C" fn xmlBufferLength(buf: *const _xmlBuffer) -> c_int {
4780 crate::xml::io::buf_length(buf as *mut _xmlBuffer)
4781}
4782
4783#[no_mangle]
4791pub unsafe extern "C" fn xmlBufferAdd(
4792 buf: *mut _xmlBuffer,
4793 str: *const xmlChar,
4794 len: c_int,
4795) -> c_int {
4796 crate::xml::io::buf_add(buf, str, len)
4797}
4798
4799#[no_mangle]
4807pub unsafe extern "C" fn xmlBufferAddHead(
4808 buf: *mut _xmlBuffer,
4809 str: *const xmlChar,
4810 len: c_int,
4811) -> c_int {
4812 crate::xml::io::buf_add_head(buf, str, len)
4813}
4814
4815#[no_mangle]
4823pub unsafe extern "C" fn xmlBufferCat(buf: *mut _xmlBuffer, str: *const xmlChar) -> c_int {
4824 if str.is_null() {
4825 return -1;
4826 }
4827 let len = crate::xml::string::xml_strlen(str) as c_int;
4828 crate::xml::io::buf_add(buf, str, len)
4829}
4830
4831#[no_mangle]
4840pub extern "C" fn xmlBufferSetAllocationScheme(buf: *mut _xmlBuffer, scheme: c_int) {
4841 if buf.is_null() {
4842 return;
4843 }
4844 unsafe {
4845 (*buf).alloc = scheme;
4846 }
4847}
4848
4849#[no_mangle]
4857pub extern "C" fn xmlBufferShrink(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4858 if buf.is_null() || len <= 0 {
4859 return 0;
4860 }
4861 unsafe {
4862 let b = &mut *buf;
4863 let shrink_len = (len as c_uint).min(b.use_);
4864 if shrink_len > 0 {
4865 let remaining = b.use_ - shrink_len;
4866 if remaining > 0 {
4867 core::ptr::copy(
4868 b.content.add(shrink_len as usize),
4869 b.content,
4870 remaining as usize,
4871 );
4872 }
4873 *b.content.add(remaining as usize) = 0;
4874 b.use_ = remaining;
4875 }
4876 }
4877 len
4878}
4879
4880#[no_mangle]
4888pub extern "C" fn xmlBufferGrow(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4889 if buf.is_null() || len <= 0 {
4890 return 0;
4891 }
4892 let cur_use = unsafe { (*buf).use_ };
4893 let new_size = cur_use + len as c_uint + 1;
4894 crate::xml::io::buf_grow(buf, new_size)
4895}
4896
4897#[no_mangle]
4905pub extern "C" fn xmlBufferReserve(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4906 xmlBufferGrow(buf, len)
4907}
4908
4909#[no_mangle]
4917pub extern "C" fn xmlBufferDetach(buf: *mut _xmlBuffer) -> *mut xmlChar {
4918 if buf.is_null() {
4919 return ptr::null_mut();
4920 }
4921 unsafe {
4922 let content = (*buf).content;
4923 (*buf).content = ptr::null_mut();
4924 (*buf).use_ = 0;
4925 (*buf).size = 0;
4926 content
4927 }
4928}
4929
4930#[no_mangle]
4942pub extern "C" fn xmlGetCharEncoding(name: *const c_char) -> c_int {
4943 if name.is_null() {
4944 return 0; }
4946 let name_bytes = unsafe {
4947 let len = libc::strlen(name);
4948 core::slice::from_raw_parts(name as *const u8, len)
4949 };
4950 crate::xml::encoding::encoding_from_name(name_bytes) as c_int
4951}
4952
4953#[no_mangle]
4961pub extern "C" fn xmlFindCharEncodingHandler(name: *const c_char) -> *mut c_void {
4962 if name.is_null() {
4963 return ptr::null_mut();
4964 }
4965 crate::xml::encoding::find_encoding_handler(name as *const xmlChar) as *mut c_void
4966}
4967
4968#[no_mangle]
4976pub extern "C" fn xmlCharEncCloseFunc(handler: *mut c_void) -> c_int {
4977 if handler.is_null() {
4978 return -1;
4979 }
4980 unsafe {
4982 let h = handler as *mut crate::abi::structs::_xmlCharEncodingHandler;
4983 if !(*h).name.is_null() {
4984 crate::abi::allocator::xmlFreeImpl((*h).name as *mut c_void);
4985 }
4986 crate::abi::allocator::xmlFreeImpl(handler);
4987 }
4988 0
4989}
4990
4991#[no_mangle]
5001pub unsafe extern "C" fn xmlIsolat1ToUTF8(
5002 out: *mut u8,
5003 outlen: *mut c_int,
5004 input: *const u8,
5005 inlen: *mut c_int,
5006) -> c_int {
5007 const XML_ENC_ERR_SPACE: c_int = -2;
5009 const XML_ENC_ERR_INTERNAL: c_int = -1;
5010 unsafe {
5011 if out.is_null() || input.is_null() || outlen.is_null() || inlen.is_null() {
5012 return XML_ENC_ERR_INTERNAL;
5013 }
5014 let outstart = out;
5015 let instart = input;
5016 let outend = out.add(*outlen as usize);
5017 let inend = input.add(*inlen as usize);
5018 let mut cur = input;
5019 let mut o = out;
5020 while cur < inend {
5021 let c = *cur;
5022 if c < 0x80 {
5023 if o >= outend {
5024 break;
5025 }
5026 *o = c;
5027 o = o.add(1);
5028 } else {
5029 if (outend as usize) - (o as usize) < 2 {
5030 break;
5031 }
5032 *o = (c >> 6) | 0xC0;
5033 *o.add(1) = (c & 0x3F) | 0x80;
5034 o = o.add(2);
5035 }
5036 cur = cur.add(1);
5037 }
5038 let mut ret = XML_ENC_ERR_SPACE;
5039 if cur == inend {
5040 ret = (o as usize - outstart as usize) as c_int;
5041 }
5042 *outlen = (o as usize - outstart as usize) as c_int;
5043 *inlen = (cur as usize - instart as usize) as c_int;
5044 ret
5045 }
5046}
5047
5048#[no_mangle]
5055pub unsafe extern "C" fn xmlUTF8ToIsolat1(
5056 out: *mut u8,
5057 outlen: *mut c_int,
5058 input: *const u8,
5059 inlen: *mut c_int,
5060) -> c_int {
5061 const XML_ENC_ERR_SPACE: c_int = -2;
5062 const XML_ENC_ERR_INTERNAL: c_int = -1;
5063 const XML_ENC_ERR_INPUT: c_int = -3;
5064 const XML_ENC_ERR_SUCCESS: c_int = 0;
5065 unsafe {
5066 if out.is_null() || outlen.is_null() || inlen.is_null() {
5067 return XML_ENC_ERR_INTERNAL;
5068 }
5069 if input.is_null() {
5070 *inlen = 0;
5071 *outlen = 0;
5072 return XML_ENC_ERR_SUCCESS;
5073 }
5074 let outstart = out;
5075 let instart = input;
5076 let outend = out.add(*outlen as usize);
5077 let inend = input.add(*inlen as usize);
5078 let mut cur = input;
5079 let mut o = out;
5080 let mut ret = XML_ENC_ERR_SPACE;
5081 while cur < inend {
5082 if o >= outend {
5083 break;
5084 }
5085 let c = *cur;
5086 if c < 0x80 {
5087 *o = c;
5088 o = o.add(1);
5089 } else if (0xC2..=0xC3).contains(&c) {
5090 if (inend as usize) - (cur as usize) < 2 {
5091 break;
5092 }
5093 cur = cur.add(1);
5094 *o = (c << 6) | (*cur & 0x3F);
5095 o = o.add(1);
5096 } else {
5097 ret = XML_ENC_ERR_INPUT;
5098 break;
5099 }
5100 cur = cur.add(1);
5101 }
5102 if ret != XML_ENC_ERR_INPUT {
5103 ret = (o as usize - outstart as usize) as c_int;
5104 }
5105 *outlen = (o as usize - outstart as usize) as c_int;
5106 *inlen = (cur as usize - instart as usize) as c_int;
5107 ret
5108 }
5109}
5110
5111#[no_mangle]
5119pub extern "C" fn xmlGetCharEncodingName(enc: c_int) -> *const c_char {
5120 if !(-1..=22).contains(&enc) {
5124 return match enc {
5125 23 => c"UTF-16".as_ptr(),
5126 24 => c"HTML".as_ptr(),
5127 31 => c"windows-1252".as_ptr(),
5128 _ => ptr::null(),
5129 };
5130 }
5131 let e: crate::abi::types::xmlCharEncoding = unsafe { core::mem::transmute(enc) };
5132 crate::xml::encoding::xmlGetCharEncodingName(e)
5133}
5134
5135#[no_mangle]
5145pub extern "C" fn xmlParseCharEncoding(name: *const c_char) -> c_int {
5146 crate::xml::encoding::xmlParseCharEncoding(name)
5147}
5148
5149#[no_mangle]
5157pub extern "C" fn xmlAddEncodingAlias(name: *const c_char, alias: *const c_char) -> c_int {
5158 crate::xml::encoding::add_encoding_alias(name, alias)
5159}
5160
5161#[no_mangle]
5169pub extern "C" fn xmlDelEncodingAlias(alias: *const c_char) -> c_int {
5170 crate::xml::encoding::del_encoding_alias(alias)
5171}
5172
5173#[no_mangle]
5181pub extern "C" fn xmlGetEncodingAlias(alias: *const c_char) -> *const c_char {
5182 crate::xml::encoding::get_encoding_alias(alias)
5183}
5184
5185#[no_mangle]
5193pub extern "C" fn xmlCleanupEncodingAliases() {
5194 crate::xml::encoding::cleanup_encoding_aliases();
5195}
5196
5197#[no_mangle]
5206pub extern "C" fn xmlCharEncInFunc(
5207 handler: *mut c_void,
5208 out: *mut c_void,
5209 in_: *mut c_void,
5210) -> c_int {
5211 crate::xml::encoding::xmlCharEncInFunc(
5212 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
5213 out as *mut crate::abi::structs::_xmlBuffer,
5214 in_ as *mut crate::abi::structs::_xmlBuffer,
5215 )
5216}
5217
5218#[no_mangle]
5227pub extern "C" fn xmlCharEncOutFunc(
5228 handler: *mut c_void,
5229 out: *mut c_void,
5230 in_: *mut c_void,
5231) -> c_int {
5232 crate::xml::encoding::xmlCharEncOutFunc(
5233 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
5234 out as *mut crate::abi::structs::_xmlBuffer,
5235 in_ as *mut crate::abi::structs::_xmlBuffer,
5236 )
5237}
5238
5239#[no_mangle]
5249pub extern "C" fn xmlNewCharEncodingHandler(
5250 name: *const c_char,
5251 input: crate::abi::callbacks::xmlCharEncodingInputFunc,
5252 output: crate::abi::callbacks::xmlCharEncodingOutputFunc,
5253) -> *mut c_void {
5254 crate::xml::encoding::xmlNewCharEncodingHandler(name, input, output) as *mut c_void
5255}
5256
5257#[no_mangle]
5265pub extern "C" fn xmlInitCharEncodingHandlers() {
5266 crate::xml::encoding::xmlInitCharEncodingHandlers();
5267}
5268
5269#[no_mangle]
5277pub extern "C" fn xmlCleanupCharEncodingHandlers() {
5278 crate::xml::encoding::xmlCleanupCharEncodingHandlers();
5279}
5280
5281#[no_mangle]
5293pub extern "C" fn xmlLookupCharEncodingHandler(enc: c_int, out: *mut *mut c_void) -> c_int {
5294 crate::xml::encoding::xmlLookupCharEncodingHandler(enc, out)
5295}
5296
5297#[no_mangle]
5305pub extern "C" fn xmlGetCharEncodingHandler(enc: c_int) -> *mut c_void {
5306 crate::xml::encoding::xmlGetCharEncodingHandler(enc)
5307}
5308
5309#[no_mangle]
5318pub extern "C" fn xmlOpenCharEncodingHandler(
5319 name: *const c_char,
5320 output: c_int,
5321 out: *mut *mut c_void,
5322) -> c_int {
5323 crate::xml::encoding::xmlOpenCharEncodingHandler(name, output, out)
5324}
5325
5326#[no_mangle]
5337pub extern "C" fn xmlCreateCharEncodingHandler(
5338 name: *const c_char,
5339 flags: c_int,
5340 impl_: Option<crate::abi::callbacks::xmlCharEncConvImpl>,
5341 implCtxt: *mut c_void,
5342 out: *mut *mut c_void,
5343) -> c_int {
5344 crate::xml::encoding::xmlCreateCharEncodingHandler(name, flags, impl_, implCtxt, out)
5345}
5346
5347#[no_mangle]
5358pub extern "C" fn xmlCharEncNewCustomHandler(
5359 name: *const c_char,
5360 input: crate::abi::callbacks::xmlCharEncConvFunc,
5361 output: crate::abi::callbacks::xmlCharEncConvFunc,
5362 ctxtDtor: Option<crate::abi::callbacks::xmlCharEncConvCtxtDtor>,
5363 inputCtxt: *mut c_void,
5364 outputCtxt: *mut c_void,
5365 out: *mut *mut c_void,
5366) -> c_int {
5367 crate::xml::encoding::xmlCharEncNewCustomHandler(
5368 name, input, output, ctxtDtor, inputCtxt, outputCtxt, out,
5369 )
5370}
5371
5372#[no_mangle]
5380pub unsafe extern "C" fn xmlCharEncInput(input: *mut _xmlParserInputBuffer, _to: c_int) -> c_int {
5381 if input.is_null() {
5382 return -1;
5383 }
5384 let handler = (*input).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5385 if handler.is_null() {
5386 return -1;
5387 }
5388 let raw = (*input).raw as *mut crate::abi::structs::_xmlBuffer;
5389 let buf = (*input).buffer as *mut crate::abi::structs::_xmlBuffer;
5390 if raw.is_null() || buf.is_null() {
5391 return -1;
5392 }
5393 crate::xml::encoding::char_enc_in(handler, buf, raw)
5394}
5395
5396#[no_mangle]
5404pub unsafe extern "C" fn xmlCharEncOutput(output: *mut _xmlOutputBuffer, _to: c_int) -> c_int {
5405 if output.is_null() {
5406 return -1;
5407 }
5408 let handler = (*output).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5409 if handler.is_null() {
5410 return -1;
5411 }
5412 let buf = (*output).buffer as *mut crate::abi::structs::_xmlBuffer;
5413 let conv = (*output).conv as *mut crate::abi::structs::_xmlBuffer;
5414 if buf.is_null() || conv.is_null() {
5415 return -1;
5416 }
5417 crate::xml::encoding::char_enc_out(handler, conv, buf)
5418}
5419
5420#[no_mangle]
5432pub unsafe extern "C" fn xmlParseURI(str: *const c_char) -> *mut c_void {
5433 crate::xml::uri::xmlParseURI(str)
5434}
5435
5436#[no_mangle]
5444pub unsafe extern "C" fn xmlParseURIRaw(str: *const c_char, raw: c_int) -> *mut c_void {
5445 let _ = raw;
5446 crate::xml::uri::xmlParseURI(str)
5447}
5448
5449#[no_mangle]
5457pub unsafe extern "C" fn xmlFreeURI(uri: *mut c_void) {
5458 crate::xml::uri::xmlFreeURI(uri)
5459}
5460
5461#[no_mangle]
5469pub extern "C" fn xmlCreateURI() -> *mut c_void {
5470 crate::xml::uri::xmlCreateURI()
5471}
5472
5473#[no_mangle]
5481pub unsafe extern "C" fn xmlSaveUri(uri: *mut c_void) -> *mut xmlChar {
5482 crate::xml::uri::xmlSaveUri(uri)
5483}
5484
5485#[no_mangle]
5501pub unsafe extern "C" fn xmlParseURIReference(uri: *mut c_void, str: *const c_char) -> c_int {
5502 crate::xml::uri::xmlParseURIReference(uri, str)
5503}
5504
5505#[no_mangle]
5520pub unsafe extern "C" fn xmlNormalizeURIPath(path: *mut c_char) -> c_int {
5521 crate::xml::uri::xmlNormalizeURIPath(path)
5522}
5523
5524#[no_mangle]
5532pub unsafe extern "C" fn xmlURIEscapeStr(
5533 str: *const xmlChar,
5534 list: *const xmlChar,
5535) -> *mut xmlChar {
5536 crate::xml::uri::xmlURIEscapeStr(str, list)
5537}
5538
5539#[no_mangle]
5547pub unsafe extern "C" fn xmlURIUnescapeString(
5548 str: *const c_char,
5549 len: c_int,
5550 target: *mut c_char,
5551) -> *mut c_char {
5552 crate::xml::uri::xmlURIUnescapeString(str, len, target)
5553}
5554
5555unsafe fn xpath_to_object(val: XPathValue) -> *mut _xmlXPathObject {
5570 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
5571 if obj.is_null() {
5572 return ptr::null_mut();
5573 }
5574 match val {
5575 XPathValue::NodeSet(ns) => {
5576 (*obj).type_ = xmlXPathObjectType::XPATH_NODESET as c_int;
5577 (*obj).nodesetval = ns.to_raw() as *mut c_void;
5578 }
5579 XPathValue::Boolean(b) => {
5580 (*obj).type_ = xmlXPathObjectType::XPATH_BOOLEAN as c_int;
5581 (*obj).boolval = if b { 1 } else { 0 };
5582 }
5583 XPathValue::Number(n) => {
5584 (*obj).type_ = xmlXPathObjectType::XPATH_NUMBER as c_int;
5585 (*obj).floatval = n;
5586 }
5587 XPathValue::String(s) => {
5588 (*obj).type_ = xmlXPathObjectType::XPATH_STRING as c_int;
5589 let bytes = s.as_bytes();
5590 let len = bytes.len();
5591 let buf = xmlMallocImpl(len + 1) as *mut xmlChar;
5592 if !buf.is_null() {
5593 ptr::copy_nonoverlapping(bytes.as_ptr(), buf, len);
5594 *buf.add(len) = 0; }
5596 (*obj).stringval = buf;
5597 }
5598 }
5599 obj
5600}
5601
5602unsafe fn object_to_xpathvalue(obj: *mut _xmlXPathObject) -> XPathValue {
5609 let typ = (*obj).type_;
5610 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5611 let ns_ptr = (*obj).nodesetval as *mut _xmlNodeSet;
5612 if ns_ptr.is_null() {
5613 return XPathValue::NodeSet(NodeSet::new());
5614 }
5615 let node_nr = (*ns_ptr).nodeNr;
5616 let node_tab = (*ns_ptr).nodeTab;
5617 let mut ns = NodeSet::new();
5618 if !node_tab.is_null() {
5619 for i in 0..node_nr as isize {
5620 let node = *node_tab.add(i as usize);
5621 ns.push(node);
5622 }
5623 }
5624 XPathValue::NodeSet(ns)
5625 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5626 XPathValue::Boolean((*obj).boolval != 0)
5627 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5628 XPathValue::Number((*obj).floatval)
5629 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5630 let s_ptr = (*obj).stringval;
5631 if s_ptr.is_null() {
5632 XPathValue::String(String::new())
5633 } else {
5634 let s = CStr::from_ptr(s_ptr as *const c_char)
5635 .to_string_lossy()
5636 .into_owned();
5637 XPathValue::String(s)
5638 }
5639 } else if typ == xmlXPathObjectType::XPATH_XSLT_TREE as c_int {
5640 let frag_doc = (*obj).nodesetval as *mut _xmlDoc;
5645 if frag_doc.is_null() {
5646 XPathValue::NodeSet(NodeSet::new())
5647 } else {
5648 let mut ns = NodeSet::new();
5649 ns.push(frag_doc as *mut _xmlNode);
5650 XPathValue::NodeSet(ns)
5651 }
5652 } else {
5653 XPathValue::Boolean(false)
5655 }
5656}
5657
5658pub unsafe fn xpath_to_object_pub(val: XPathValue) -> *mut _xmlXPathObject {
5664 xpath_to_object(val)
5665}
5666
5667pub unsafe fn object_to_xpathvalue_pub(obj: *mut _xmlXPathObject) -> XPathValue {
5674 object_to_xpathvalue(obj)
5675}
5676
5677static COMPILED_EXPRS: Lazy<Mutex<HashMap<u64, Box<CompiledExpr>>>> =
5683 Lazy::new(|| Mutex::new(HashMap::new()));
5684static NEXT_COMPILED_KEY: Lazy<Mutex<u64>> = Lazy::new(|| Mutex::new(1));
5685
5686pub(crate) fn xpath_compiled_registry() -> &'static Mutex<HashMap<u64, Box<CompiledExpr>>> {
5689 &COMPILED_EXPRS
5690}
5691
5692type CXPathFunc = unsafe extern "C" fn(*mut c_void, c_int);
5702
5703#[derive(Clone, Copy, PartialEq, Eq, Hash)]
5706struct SendSyncPtr(*mut c_void);
5707unsafe impl Send for SendSyncPtr {}
5708unsafe impl Sync for SendSyncPtr {}
5709
5710static C_FUNCTIONS: Lazy<Mutex<HashMap<(SendSyncPtr, String), CXPathFunc>>> =
5711 Lazy::new(|| Mutex::new(HashMap::new()));
5712
5713pub(crate) fn xpath_cfunc_lookup(extra: *mut c_void, qualified: &str) -> Option<CXPathFunc> {
5717 C_FUNCTIONS
5718 .lock()
5719 .get(&(SendSyncPtr(extra), qualified.to_string()))
5720 .copied()
5721}
5722
5723pub(crate) fn xpath_cfunc_cleanup(extra: *mut c_void) {
5726 C_FUNCTIONS.lock().retain(|(k, _), _| k.0 != extra);
5727}
5728
5729fn c_func_bridge_closure(c_ctxt: SendSyncPtr, qualified: String) -> BoxedXPathFunction {
5734 Box::new(move |_ctx: &mut XPathContext, args: &[XPathValue]| {
5735 let cc = c_ctxt;
5736 unsafe { c_func_call_bridge(cc.0 as *mut _xmlXPathContext, &qualified, args) }
5737 })
5738}
5739
5740pub(crate) unsafe fn call_c_xpath_function(
5750 fnptr: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
5751 c_ctxt: *mut _xmlXPathContext,
5752 args: &[XPathValue],
5753) -> Result<XPathValue, String> {
5754 let func = match fnptr {
5755 Some(f) => f,
5756 None => return Err("XPath: missing C function pointer".to_string()),
5757 };
5758 let pc = crate::xml::xpath::parser_context::new_parser_context(ptr::null(), c_ctxt);
5759 if pc.is_null() {
5760 return Err("XPath: parser-context allocation failure".to_string());
5761 }
5762 let mut push_ok = true;
5763 for v in args {
5764 let obj = xpath_to_object(v.clone());
5765 if obj.is_null() || crate::xml::xpath::parser_context::value_push(pc, obj).is_null() {
5766 push_ok = false;
5767 break;
5768 }
5769 }
5770 let result = if push_ok {
5771 unsafe { func(pc as *mut c_void, args.len() as c_int) };
5774 let ret = crate::xml::xpath::parser_context::value_pop(pc);
5775 if ret.is_null() {
5776 Err("XPath: C function returned no value".to_string())
5777 } else {
5778 let v = object_to_xpathvalue(ret);
5779 unsafe { xmlXPathFreeObject(ret) };
5781 Ok(v)
5782 }
5783 } else {
5784 Err("XPath: failed to push arguments to C function".to_string())
5785 };
5786 unsafe {
5788 loop {
5789 let leftover = crate::xml::xpath::parser_context::value_pop(pc);
5790 if leftover.is_null() {
5791 break;
5792 }
5793 xmlXPathFreeObject(leftover);
5794 }
5795 crate::xml::xpath::parser_context::free_parser_context(pc);
5796 }
5797 result
5798}
5799
5800unsafe fn c_func_call_bridge(
5807 c_ctxt: *mut _xmlXPathContext,
5808 qualified: &str,
5809 args: &[XPathValue],
5810) -> Result<XPathValue, String> {
5811 if c_ctxt.is_null() {
5812 return Err("XPath: null context in C function bridge".to_string());
5813 }
5814 let func = xpath_cfunc_lookup((*c_ctxt).extra, qualified);
5815 if func.is_none() {
5816 return Err(format!("XPath: unknown C function '{}'", qualified));
5817 }
5818 unsafe { call_c_xpath_function(func, c_ctxt, args) }
5819}
5820
5821#[no_mangle]
5834pub unsafe extern "C" fn xmlXPathNewContext(doc: *mut _xmlDoc) -> *mut _xmlXPathContext {
5835 let ctxt = xmlMallocZero(size_of::<_xmlXPathContext>()) as *mut _xmlXPathContext;
5836 if ctxt.is_null() {
5837 return ptr::null_mut();
5838 }
5839
5840 (*ctxt).doc = doc;
5842 (*ctxt).node = ptr::null_mut();
5843 (*ctxt).contextSize = 1;
5844 (*ctxt).proximityPosition = 1;
5845
5846 let mut internal = Box::new(XPathContext::new(doc));
5848 for (name, func) in crate::xml::xpath::functions::core_functions() {
5853 internal.register_function(&name, func);
5854 }
5855 (*ctxt).extra = Box::into_raw(internal) as *mut c_void;
5856
5857 ctxt
5858}
5859
5860#[no_mangle]
5868pub unsafe extern "C" fn xmlXPathFreeContext(ctxt: *mut _xmlXPathContext) {
5869 if ctxt.is_null() {
5870 return;
5871 }
5872 if !(*ctxt).extra.is_null() {
5874 let _ = Box::from_raw((*ctxt).extra as *mut XPathContext);
5875 (*ctxt).extra = ptr::null_mut();
5876 }
5877 if !(*ctxt).nsHash.is_null() {
5879 drop(Box::from_raw(
5880 (*ctxt).nsHash as *mut HashMap<String, CString>,
5881 ));
5882 (*ctxt).nsHash = ptr::null_mut();
5883 }
5884 xmlFreeImpl(ctxt as *mut c_void);
5886}
5887
5888#[no_mangle]
5897pub unsafe extern "C" fn xmlXPathEvalExpression(
5898 str_: *const xmlChar,
5899 ctxt: *mut _xmlXPathContext,
5900) -> *mut _xmlXPathObject {
5901 if str_.is_null() || ctxt.is_null() {
5902 return ptr::null_mut();
5903 }
5904 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
5905 Ok(s) => s,
5906 Err(_) => return ptr::null_mut(),
5907 };
5908 let internal = (*ctxt).extra as *mut XPathContext;
5909 if internal.is_null() {
5910 return ptr::null_mut();
5911 }
5912 let internal = &mut *internal;
5913 internal.clear_error();
5916
5917 match crate::xml::xpath::evaluate_str(expr_str, internal) {
5918 Some(val) => xpath_to_object(val),
5919 None => {
5920 if internal.error.is_none() {
5925 internal.set_error("Invalid expression");
5926 }
5927 ptr::null_mut()
5928 }
5929 }
5930}
5931
5932#[no_mangle]
5940pub unsafe extern "C" fn xmlXPathEval(
5941 str_: *const xmlChar,
5942 ctxt: *mut _xmlXPathContext,
5943) -> *mut _xmlXPathObject {
5944 xmlXPathEvalExpression(str_, ctxt)
5945}
5946
5947#[no_mangle]
5958pub unsafe extern "C" fn xmlXPathFreeObject(obj: *mut _xmlXPathObject) {
5959 if obj.is_null() {
5960 return;
5961 }
5962 let typ = (*obj).type_;
5963 if typ == xmlXPathObjectType::XPATH_STRING as c_int && !(*obj).stringval.is_null() {
5965 xmlFreeImpl((*obj).stringval as *mut c_void);
5966 (*obj).stringval = ptr::null_mut();
5967 }
5968 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5970 let ns = (*obj).nodesetval as *mut _xmlNodeSet;
5971 if !ns.is_null() {
5972 if !(*ns).nodeTab.is_null() {
5973 xmlFreeImpl((*ns).nodeTab as *mut c_void);
5974 }
5975 xmlFreeImpl(ns as *mut c_void);
5976 }
5977 (*obj).nodesetval = ptr::null_mut();
5978 }
5979 xmlFreeImpl(obj as *mut c_void);
5980}
5981
5982#[no_mangle]
5994pub unsafe extern "C" fn xmlXPathObjectCopy(val: *mut _xmlXPathObject) -> *mut _xmlXPathObject {
5995 if val.is_null() {
5996 return ptr::null_mut();
5997 }
5998 let typ = (*val).type_;
5999 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
6000 if obj.is_null() {
6001 return ptr::null_mut();
6002 }
6003 (*obj).type_ = typ;
6004 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
6005 let src_ns = (*val).nodesetval as *mut _xmlNodeSet;
6006 if !src_ns.is_null() {
6007 let nr = (*src_ns).nodeNr;
6008 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
6009 if ns.is_null() {
6010 xmlFreeImpl(obj as *mut c_void);
6011 return ptr::null_mut();
6012 }
6013 (*ns).nodeNr = nr;
6014 (*ns).nodeMax = nr;
6015 if nr > 0 && !(*src_ns).nodeTab.is_null() {
6016 let tab = xmlMallocImpl((nr as usize) * core::mem::size_of::<*mut _xmlNode>())
6017 as *mut *mut _xmlNode;
6018 if tab.is_null() {
6019 xmlFreeImpl(ns as *mut c_void);
6020 xmlFreeImpl(obj as *mut c_void);
6021 return ptr::null_mut();
6022 }
6023 ptr::copy_nonoverlapping((*src_ns).nodeTab, tab, nr as usize);
6024 (*ns).nodeTab = tab;
6025 } else {
6026 (*ns).nodeTab = ptr::null_mut();
6027 }
6028 (*obj).nodesetval = ns as *mut c_void;
6029 }
6030 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
6031 (*obj).boolval = (*val).boolval;
6032 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
6033 (*obj).floatval = (*val).floatval;
6034 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
6035 let src = (*val).stringval;
6036 if !src.is_null() {
6037 let len = libc::strlen(src as *const libc::c_char);
6038 let buf = xmlMallocImpl(len + 1) as *mut xmlChar;
6039 if !buf.is_null() {
6040 ptr::copy_nonoverlapping(src, buf, len);
6041 *buf.add(len) = 0;
6042 }
6043 (*obj).stringval = buf;
6044 }
6045 }
6046 obj
6047}
6048
6049#[no_mangle]
6059pub unsafe extern "C" fn xmlXPathCastToString(val: *mut _xmlXPathObject) -> *mut xmlChar {
6060 if val.is_null() {
6061 return ptr::null_mut();
6062 }
6063 let typ = (*val).type_;
6064 let mut result: Vec<u8> = Vec::new();
6065 if typ == xmlXPathObjectType::XPATH_STRING as c_int {
6066 if !(*val).stringval.is_null() {
6067 let len = libc::strlen((*val).stringval as *const libc::c_char);
6068 result.extend_from_slice(core::slice::from_raw_parts((*val).stringval, len));
6069 }
6070 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
6071 let n = (*val).floatval;
6077 result.extend_from_slice(xml_number_to_string(n).as_bytes());
6078 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
6079 result.extend_from_slice(if (*val).boolval != 0 {
6080 b"true"
6081 } else {
6082 b"false"
6083 });
6084 } else if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
6085 let ns = (*val).nodesetval as *mut _xmlNodeSet;
6088 if !ns.is_null() && (*ns).nodeNr > 0 && !(*ns).nodeTab.is_null() {
6089 let node = *(*ns).nodeTab;
6090 if !node.is_null() {
6091 let content = crate::xml::tree::node_get_content(node);
6092 if !content.is_null() {
6093 let len = libc::strlen(content as *const libc::c_char);
6094 result.extend_from_slice(core::slice::from_raw_parts(content, len));
6095 xmlFreeImpl(content as *mut c_void);
6096 }
6097 }
6098 }
6099 }
6100 let buf = xmlMallocImpl(result.len() + 1) as *mut xmlChar;
6102 if buf.is_null() {
6103 return ptr::null_mut();
6104 }
6105 if !result.is_empty() {
6106 ptr::copy_nonoverlapping(result.as_ptr(), buf, result.len());
6107 }
6108 *buf.add(result.len()) = 0;
6109 buf
6110}
6111
6112pub fn xml_number_to_string(n: f64) -> String {
6119 crate::xml::xpath::types::number_to_string(n)
6120}
6121
6122fn xpath_string_eval_number(bytes: &[u8]) -> f64 {
6130 crate::xml::xpath::types::string_bytes_to_number(bytes)
6131}
6132
6133#[no_mangle]
6141pub unsafe extern "C" fn xmlXPathCastStringToNumber(val: *const xmlChar) -> f64 {
6142 if val.is_null() {
6143 return f64::NAN;
6144 }
6145 let len = libc::strlen(val as *const libc::c_char);
6146 let bytes = core::slice::from_raw_parts(val, len);
6147 xpath_string_eval_number(bytes)
6148}
6149
6150#[no_mangle]
6164pub unsafe extern "C" fn xmlXPathCmpNodes(node1: *mut _xmlNode, node2: *mut _xmlNode) -> c_int {
6165 if node1.is_null() || node2.is_null() {
6166 return -2;
6167 }
6168 if node1 == node2 {
6169 return 0;
6170 }
6171 let mut chain1: Vec<*mut _xmlNode> = Vec::new();
6173 let mut chain2: Vec<*mut _xmlNode> = Vec::new();
6174 let mut n = node1;
6175 while !n.is_null() {
6176 chain1.push(n);
6177 n = (*n).parent;
6178 }
6179 let mut n = node2;
6180 while !n.is_null() {
6181 chain2.push(n);
6182 n = (*n).parent;
6183 }
6184 if chain1[chain1.len() - 1] != chain2[chain2.len() - 1] {
6186 return -2;
6187 }
6188 let mut i = chain1.len();
6190 let mut j = chain2.len();
6191 while i > 0 && j > 0 && chain1[i - 1] == chain2[j - 1] {
6192 i -= 1;
6193 j -= 1;
6194 }
6195 if i == 0 {
6197 return 1;
6198 }
6199 if j == 0 {
6201 return -1;
6202 }
6203 let mut a = chain1[i - 1];
6205 let mut b = chain2[j - 1];
6206 while !a.is_null() && !b.is_null() {
6208 let pa = (*a).parent;
6209 let pb = (*b).parent;
6210 if pa == pb {
6211 break;
6212 }
6213 a = pa;
6214 b = pb;
6215 }
6216 let parent = (*a).parent;
6218 let mut child = if parent.is_null() {
6219 ptr::null_mut()
6220 } else {
6221 (*parent).children
6222 };
6223 while !child.is_null() {
6224 if child == a {
6225 return 1; }
6227 if child == b {
6228 return -1; }
6230 child = (*child).next;
6231 }
6232 0
6233}
6234
6235#[no_mangle]
6245pub unsafe extern "C" fn xmlXPathNodeSetCreate(val: *mut _xmlNode) -> *mut _xmlNodeSet {
6246 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
6247 if ns.is_null() {
6248 return ptr::null_mut();
6249 }
6250 if val.is_null() {
6251 return ns;
6252 }
6253 let tab = xmlMallocImpl(core::mem::size_of::<*mut _xmlNode>()) as *mut *mut _xmlNode;
6254 if tab.is_null() {
6255 xmlFreeImpl(ns as *mut c_void);
6256 return ptr::null_mut();
6257 }
6258 *tab = val;
6259 (*ns).nodeTab = tab;
6260 (*ns).nodeNr = 1;
6261 (*ns).nodeMax = 1;
6262 ns
6263}
6264
6265#[no_mangle]
6277pub unsafe extern "C" fn xmlXPathFreeNodeSet(ns: *mut _xmlNodeSet) {
6278 if ns.is_null() {
6279 return;
6280 }
6281 if !(*ns).nodeTab.is_null() {
6282 xmlFreeImpl((*ns).nodeTab as *mut c_void);
6283 (*ns).nodeTab = ptr::null_mut();
6284 }
6285 (*ns).nodeNr = 0;
6286 (*ns).nodeMax = 0;
6287 xmlFreeImpl(ns as *mut c_void);
6288}
6289
6290#[no_mangle]
6301pub unsafe extern "C" fn xmlXPathCompile(str_: *const xmlChar) -> *mut c_void {
6302 if str_.is_null() {
6303 return ptr::null_mut();
6304 }
6305 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
6306 Ok(s) => s,
6307 Err(_) => return ptr::null_mut(),
6308 };
6309
6310 match crate::xml::xpath::compile(expr_str) {
6311 Some(compiled) => {
6312 let mut map = COMPILED_EXPRS.lock();
6313 let mut counter = NEXT_COMPILED_KEY.lock();
6314 let key = *counter;
6315 *counter += 1;
6316 map.insert(key, Box::new(compiled));
6317 key as *mut c_void
6318 }
6319 None => ptr::null_mut(),
6320 }
6321}
6322
6323#[no_mangle]
6331pub unsafe extern "C" fn xmlXPathFreeCompExpr(comp: *mut c_void) {
6332 if comp.is_null() {
6333 return;
6334 }
6335 let mut map = COMPILED_EXPRS.lock();
6336 map.remove(&(comp as u64));
6337}
6338
6339#[no_mangle]
6348pub unsafe extern "C" fn xmlXPathRegisterNs(
6349 ctxt: *mut _xmlXPathContext,
6350 prefix: *const xmlChar,
6351 ns_uri: *const xmlChar,
6352) -> c_int {
6353 if ctxt.is_null() || prefix.is_null() || ns_uri.is_null() {
6354 return -1;
6355 }
6356 let internal = (*ctxt).extra as *mut XPathContext;
6357 if internal.is_null() {
6358 return -1;
6359 }
6360 let internal = &mut *internal;
6361
6362 let prefix_str = match CStr::from_ptr(prefix as *const c_char).to_str() {
6363 Ok(s) => s,
6364 Err(_) => return -1,
6365 };
6366 let uri_str = match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6367 Ok(s) => s,
6368 Err(_) => return -1,
6369 };
6370
6371 internal.register_namespace(prefix_str, uri_str);
6372
6373 let map: &mut HashMap<String, CString> = if (*ctxt).nsHash.is_null() {
6378 let b: Box<HashMap<String, CString>> = Box::default();
6379 (*ctxt).nsHash = Box::into_raw(b) as *mut c_void;
6380 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6381 } else {
6382 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6383 };
6384 map.insert(
6385 prefix_str.to_string(),
6386 CString::new(uri_str.as_bytes()).unwrap_or_default(),
6387 );
6388 0
6389}
6390
6391#[no_mangle]
6405pub unsafe extern "C" fn xmlXPathRegisterFunc(
6406 ctxt: *mut _xmlXPathContext,
6407 name: *const xmlChar,
6408 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6409) -> c_int {
6410 if ctxt.is_null() || name.is_null() {
6411 return -1;
6412 }
6413 let internal = (*ctxt).extra as *mut XPathContext;
6414 if internal.is_null() {
6415 return -1;
6416 }
6417 let internal = &mut *internal;
6418
6419 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6420 Ok(s) => s,
6421 Err(_) => return -1,
6422 };
6423
6424 if let Some(func) = f {
6425 let key = (SendSyncPtr((*ctxt).extra), name_str.to_string());
6427 C_FUNCTIONS.lock().insert(key, func);
6428 let c_ctxt = SendSyncPtr(ctxt as *mut c_void);
6431 let name_owned = name_str.to_string();
6432 internal.register_function(name_str, c_func_bridge_closure(c_ctxt, name_owned));
6433 }
6434 0
6435}
6436
6437#[no_mangle]
6447pub unsafe extern "C" fn xmlXPathRegisterFuncNS(
6448 ctxt: *mut _xmlXPathContext,
6449 name: *const xmlChar,
6450 ns_uri: *const xmlChar,
6451 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6452) -> c_int {
6453 if ctxt.is_null() || name.is_null() {
6454 return -1;
6455 }
6456 let internal = (*ctxt).extra as *mut XPathContext;
6457 if internal.is_null() {
6458 return -1;
6459 }
6460 let internal = &mut *internal;
6461
6462 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6463 Ok(s) => s,
6464 Err(_) => return -1,
6465 };
6466 let ns_str = if ns_uri.is_null() {
6467 String::new()
6468 } else {
6469 match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6470 Ok(s) => s.to_string(),
6471 Err(_) => return -1,
6472 }
6473 };
6474
6475 let qualified = if ns_str.is_empty() {
6477 name_str.to_string()
6478 } else {
6479 format!("{{{}}}{}", ns_str, name_str)
6480 };
6481
6482 if let Some(func) = f {
6483 let key = (SendSyncPtr((*ctxt).extra), qualified.clone());
6484 C_FUNCTIONS.lock().insert(key, func);
6485 let c_ctxt = SendSyncPtr(ctxt as *mut c_void);
6486 let qualified_owned = qualified.clone();
6487 internal.register_function(&qualified, c_func_bridge_closure(c_ctxt, qualified_owned));
6488 }
6489 0
6490}
6491
6492#[no_mangle]
6501pub unsafe extern "C" fn xmlXPathRegisterVariable(
6502 ctxt: *mut _xmlXPathContext,
6503 name: *const xmlChar,
6504 value: *mut _xmlXPathObject,
6505) -> c_int {
6506 if ctxt.is_null() || name.is_null() || value.is_null() {
6507 return -1;
6508 }
6509 let internal = (*ctxt).extra as *mut XPathContext;
6510 if internal.is_null() {
6511 return -1;
6512 }
6513 let internal = &mut *internal;
6514
6515 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6516 Ok(s) => s,
6517 Err(_) => return -1,
6518 };
6519
6520 let xpath_val = object_to_xpathvalue(value);
6521 internal.register_variable(name_str, xpath_val);
6522 0
6523}
6524
6525#[no_mangle]
6533pub unsafe extern "C" fn xmlXPathNewNodeSet(val: *mut _xmlNode) -> *mut _xmlXPathObject {
6534 let ns = if val.is_null() {
6535 NodeSet::new()
6536 } else {
6537 NodeSet::singleton(val)
6538 };
6539 xpath_to_object(XPathValue::NodeSet(ns))
6540}
6541
6542#[no_mangle]
6550pub unsafe extern "C" fn xmlXPathNewCString(val: *const xmlChar) -> *mut _xmlXPathObject {
6551 if val.is_null() {
6552 return xpath_to_object(XPathValue::String(String::new()));
6553 }
6554 let s = match CStr::from_ptr(val as *const c_char).to_str() {
6555 Ok(s) => s.to_string(),
6556 Err(_) => return ptr::null_mut(),
6557 };
6558 xpath_to_object(XPathValue::String(s))
6559}
6560
6561#[no_mangle]
6569pub extern "C" fn xmlXPathNewFloat(val: f64) -> *mut _xmlXPathObject {
6570 unsafe { xpath_to_object(XPathValue::Number(val)) }
6571}
6572
6573#[no_mangle]
6581pub extern "C" fn xmlXPathNewBoolean(val: c_int) -> *mut _xmlXPathObject {
6582 unsafe { xpath_to_object(XPathValue::Boolean(val != 0)) }
6583}
6584
6585#[no_mangle]
6599pub unsafe extern "C" fn xmlXPtrEval(expr: *const c_char, doc: *mut _xmlDoc) -> *mut _xmlNode {
6600 crate::xml::xpointer::xmlXPtrEval(expr, doc)
6601}
6602
6603#[no_mangle]
6615pub unsafe extern "C" fn xmlXIncludeProcess(doc: *mut _xmlDoc) -> c_int {
6616 crate::xml::xinclude::xinclude_process(doc)
6617}
6618
6619#[no_mangle]
6627pub unsafe extern "C" fn xmlXIncludeProcessFlags(doc: *mut _xmlDoc, flags: c_int) -> c_int {
6628 crate::xml::xinclude::xinclude_process_flags(doc, flags)
6629}
6630
6631#[no_mangle]
6643pub extern "C" fn xmlCatalogLoad(catalogs: *const c_char) -> *mut c_void {
6644 if catalogs.is_null() {
6645 return ptr::null_mut();
6646 }
6647 crate::xml::catalog::load_catalog(catalogs)
6648}
6649
6650#[no_mangle]
6658pub unsafe extern "C" fn xmlCatalogResolvePublic(pubID: *const xmlChar) -> *mut xmlChar {
6659 if pubID.is_null() {
6660 return ptr::null_mut();
6661 }
6662 crate::xml::catalog::resolve_public(pubID)
6663}
6664
6665#[no_mangle]
6673pub unsafe extern "C" fn xmlCatalogResolveSystem(sysID: *const xmlChar) -> *mut xmlChar {
6674 if sysID.is_null() {
6675 return ptr::null_mut();
6676 }
6677 crate::xml::catalog::resolve_system(sysID)
6678}
6679
6680#[no_mangle]
6688pub unsafe extern "C" fn xmlCatalogResolveURI(URI: *const xmlChar) -> *mut xmlChar {
6689 if URI.is_null() {
6690 return ptr::null_mut();
6691 }
6692 crate::xml::catalog::resolve_uri(URI)
6693}
6694
6695#[no_mangle]
6703pub extern "C" fn xmlCatalogSetDefaults(allow: c_int) {
6704 crate::xml::catalog::set_defaults(allow)
6705}
6706
6707#[no_mangle]
6715pub extern "C" fn xmlCatalogGetDefaults() -> c_int {
6716 crate::xml::catalog::get_defaults()
6717}
6718
6719#[no_mangle]
6727pub unsafe extern "C" fn xmlCatalogAdd(
6728 type_: *const xmlChar,
6729 orig: *const xmlChar,
6730 replace: *const xmlChar,
6731) -> c_int {
6732 if type_.is_null() || orig.is_null() || replace.is_null() {
6733 return -1;
6734 }
6735 crate::xml::catalog::add(type_, orig, replace)
6736}
6737
6738#[no_mangle]
6746pub unsafe extern "C" fn xmlCatalogRemove(value: *const xmlChar) -> c_int {
6747 if value.is_null() {
6748 return 0;
6749 }
6750 crate::xml::catalog::remove(value)
6751}
6752
6753#[no_mangle]
6763pub unsafe extern "C" fn xmlCatalogDump(output: *mut c_void) {
6764 if output.is_null() {
6765 return;
6766 }
6767 let doc = crate::xml::catalog::dump_doc();
6768 if doc.is_null() {
6769 return;
6770 }
6771 let mut mem: *mut xmlChar = ptr::null_mut();
6772 let mut size: c_int = 0;
6773 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6774 if !mem.is_null() {
6775 libc::fwrite(
6776 mem as *const c_void,
6777 1,
6778 size as usize,
6779 output as *mut libc::FILE,
6780 );
6781 xmlFreeImpl(mem as *mut c_void);
6782 }
6783 crate::xml::tree::free_doc(doc);
6784}
6785
6786#[no_mangle]
6796pub unsafe extern "C" fn xmlCatalogSave(filename: *const c_char) -> c_int {
6797 if filename.is_null() {
6798 return -1;
6799 }
6800 let doc = crate::xml::catalog::dump_doc();
6801 if doc.is_null() {
6802 return -1;
6803 }
6804 let mut mem: *mut xmlChar = ptr::null_mut();
6805 let mut size: c_int = 0;
6806 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6807 let mut ret: c_int = -1;
6808 if !mem.is_null() {
6809 let fp = libc::fopen(filename, c"w".as_ptr() as *const c_char);
6810 if !fp.is_null() {
6811 let written = libc::fwrite(mem as *const c_void, 1, size as usize, fp);
6812 ret = if written == size as usize { 0 } else { -1 };
6813 libc::fclose(fp);
6814 }
6815 xmlFreeImpl(mem as *mut c_void);
6816 }
6817 crate::xml::tree::free_doc(doc);
6818 ret
6819}
6820
6821#[no_mangle]
6829pub extern "C" fn xmlCatalogCleanup() {
6830 crate::xml::catalog::cleanup();
6831}
6832
6833#[no_mangle]
6848pub extern "C" fn xmlCatalogConvert() -> c_int {
6849 if !crate::xml::catalog::is_initialized() {
6850 return -1;
6851 }
6852 0
6853}
6854
6855#[no_mangle]
6867pub const unsafe extern "C" fn htmlParseFile(
6868 _filename: *const c_char,
6869 _encoding: *const c_char,
6870) -> *mut _xmlDoc {
6871 ptr::null_mut()
6873}
6874
6875#[no_mangle]
6883pub const unsafe extern "C" fn htmlParseMemory(
6884 _buffer: *const c_char,
6885 _size: c_int,
6886) -> *mut _xmlDoc {
6887 ptr::null_mut()
6889}
6890
6891#[no_mangle]
6899pub const unsafe extern "C" fn htmlParseDoc(
6900 _cur: *const xmlChar,
6901 _encoding: *const c_char,
6902) -> *mut _xmlDoc {
6903 ptr::null_mut()
6905}
6906
6907#[no_mangle]
6916pub const unsafe extern "C" fn htmlCreateFileParserCtxt(
6917 _filename: *const c_char,
6918 _encoding: *const c_char,
6919) -> *mut c_void {
6920 ptr::null_mut()
6922}
6923
6924#[no_mangle]
6932pub extern "C" fn htmlFreeParserCtxt(ctxt: *mut c_void) {
6933 unsafe { crate::xml::html::free_parser_ctxt(ctxt) }
6934}
6935
6936#[no_mangle]
6944pub const extern "C" fn htmlInitParser() {
6945 }
6947
6948#[no_mangle]
6956pub const extern "C" fn htmlCleanupParser() {
6957 }
6959
6960#[no_mangle]
6972pub unsafe extern "C" fn xmlNewValidCtxt() -> *mut _xmlValidCtxt {
6973 crate::xml::validation::new_valid_ctxt()
6974}
6975
6976#[no_mangle]
6984pub unsafe extern "C" fn xmlFreeValidCtxt(ctxt: *mut _xmlValidCtxt) {
6985 crate::xml::validation::free_valid_ctxt(ctxt);
6986}
6987
6988#[no_mangle]
6999pub unsafe extern "C" fn xmlSetValidErrors(
7000 ctxt: *mut _xmlValidCtxt,
7001 err: Option<xmlGenericErrorFunc>,
7002 warn: Option<xmlGenericErrorFunc>,
7003 data: *mut c_void,
7004) {
7005 crate::xml::validation::set_valid_errors(ctxt, err, warn, data);
7006}
7007
7008#[no_mangle]
7016pub unsafe extern "C" fn xmlValidateDocument(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7017 crate::xml::validation::validate_document(ctxt, doc)
7018}
7019
7020#[no_mangle]
7028pub unsafe extern "C" fn xmlValidateDocumentFinal(
7029 ctxt: *mut _xmlValidCtxt,
7030 doc: *mut _xmlDoc,
7031) -> c_int {
7032 crate::xml::validation::validate_document_final(ctxt, doc)
7033}
7034
7035#[no_mangle]
7045pub unsafe extern "C" fn xmlValidateElement(
7046 ctxt: *mut _xmlValidCtxt,
7047 doc: *mut _xmlDoc,
7048 elem: *mut _xmlNode,
7049) -> c_int {
7050 crate::xml::validation::validate_element(ctxt, doc, elem)
7051}
7052
7053#[no_mangle]
7064pub unsafe extern "C" fn xmlValidateAttributeDecl(
7065 ctxt: *mut _xmlValidCtxt,
7066 doc: *mut _xmlDoc,
7067 elem: *mut _xmlNode,
7068 attr: *mut _xmlAttribute,
7069) -> c_int {
7070 crate::xml::validation::validate_attribute_decl(ctxt, doc, elem, attr)
7071}
7072
7073#[no_mangle]
7081pub unsafe extern "C" fn xmlValidateAttributeValue(atype: c_int, value: *const xmlChar) -> c_int {
7082 crate::xml::validation::validate_attribute_value(atype, value)
7083}
7084
7085#[no_mangle]
7095pub unsafe extern "C" fn xmlValidateNotationUse(
7096 ctxt: *mut _xmlValidCtxt,
7097 doc: *mut _xmlDoc,
7098 notation_name: *const xmlChar,
7099) -> c_int {
7100 crate::xml::validation::validate_notation_use(ctxt, doc, notation_name)
7101}
7102
7103#[no_mangle]
7114pub unsafe extern "C" fn xmlValidateID(
7115 ctxt: *mut _xmlValidCtxt,
7116 doc: *mut _xmlDoc,
7117 node: *mut _xmlNode,
7118 value: *const xmlChar,
7119) -> c_int {
7120 crate::xml::validation::validate_id(ctxt, doc, node, value)
7121}
7122
7123#[no_mangle]
7133pub unsafe extern "C" fn xmlValidateIDRef(
7134 ctxt: *mut _xmlValidCtxt,
7135 doc: *mut _xmlDoc,
7136 value: *const xmlChar,
7137) -> c_int {
7138 crate::xml::validation::validate_id_ref(ctxt, doc, ptr::null_mut(), value)
7139}
7140
7141#[no_mangle]
7151pub unsafe extern "C" fn xmlValidateIDRefs(
7152 ctxt: *mut _xmlValidCtxt,
7153 doc: *mut _xmlDoc,
7154 value: *const xmlChar,
7155) -> c_int {
7156 crate::xml::validation::validate_id_refs(ctxt, doc, ptr::null_mut(), value)
7157}
7158
7159#[no_mangle]
7169pub unsafe extern "C" fn xmlValidateNCName(value: *const xmlChar, space: c_int) -> c_int {
7170 crate::xml::validation::validate_ncname(value, space)
7171}
7172
7173#[no_mangle]
7181pub unsafe extern "C" fn xmlValidateQName(value: *const xmlChar, space: c_int) -> c_int {
7182 crate::xml::validation::validate_qname(value, space)
7183}
7184
7185#[no_mangle]
7198pub unsafe extern "C" fn xmlValidateName(value: *const xmlChar, space: c_int) -> c_int {
7199 crate::xml::validation::validate_name_space(value, space)
7200}
7201
7202#[no_mangle]
7210pub unsafe extern "C" fn xmlValidateNMToken(value: *const xmlChar, space: c_int) -> c_int {
7211 crate::xml::validation::validate_nmtoken_space(value, space)
7212}
7213
7214#[no_mangle]
7224pub unsafe extern "C" fn xmlValidateNameValue(value: *const xmlChar) -> c_int {
7225 crate::xml::validation::validate_name_value(value)
7226}
7227
7228#[no_mangle]
7237pub unsafe extern "C" fn xmlValidateNamesValue(value: *const xmlChar) -> c_int {
7238 crate::xml::validation::validate_names_value(value)
7239}
7240
7241#[no_mangle]
7249pub unsafe extern "C" fn xmlValidateNmtokenValue(value: *const xmlChar) -> c_int {
7250 crate::xml::validation::validate_nmtoken_value(value)
7251}
7252
7253#[no_mangle]
7261pub unsafe extern "C" fn xmlValidateNmtokensValue(value: *const xmlChar) -> c_int {
7262 crate::xml::validation::validate_nmtokens_value(value)
7263}
7264
7265#[no_mangle]
7276pub unsafe extern "C" fn xmlValidateElementDecl(
7277 ctxt: *mut _xmlValidCtxt,
7278 doc: *mut _xmlDoc,
7279 elem: *mut _xmlElement,
7280) -> c_int {
7281 crate::xml::validation::validate_element_decl(ctxt, doc, elem)
7282}
7283
7284#[no_mangle]
7297pub const unsafe extern "C" fn xmlValidateNotationDecl(
7298 ctxt: *mut _xmlValidCtxt,
7299 doc: *mut _xmlDoc,
7300 nota: *mut _xmlNotation,
7301) -> c_int {
7302 crate::xml::validation::validate_notation_decl(ctxt, doc, nota)
7303}
7304
7305#[no_mangle]
7317pub unsafe extern "C" fn xmlValidateOneAttribute(
7318 ctxt: *mut _xmlValidCtxt,
7319 doc: *mut _xmlDoc,
7320 elem: *mut _xmlNode,
7321 attr: *mut _xmlAttr,
7322 value: *const xmlChar,
7323) -> c_int {
7324 crate::xml::validation::validate_one_attribute(ctxt, doc, elem, attr, value)
7325}
7326
7327#[no_mangle]
7337pub unsafe extern "C" fn xmlValidateOneElement(
7338 ctxt: *mut _xmlValidCtxt,
7339 doc: *mut _xmlDoc,
7340 elem: *mut _xmlNode,
7341) -> c_int {
7342 crate::xml::validation::validate_one_element(ctxt, doc, elem)
7343}
7344
7345#[no_mangle]
7358pub unsafe extern "C" fn xmlValidateOneNamespace(
7359 ctxt: *mut _xmlValidCtxt,
7360 doc: *mut _xmlDoc,
7361 elem: *mut _xmlNode,
7362 prefix: *const xmlChar,
7363 ns: *mut _xmlNs,
7364 value: *const xmlChar,
7365) -> c_int {
7366 crate::xml::validation::validate_one_namespace(ctxt, doc, elem, prefix, ns, value)
7367}
7368
7369#[no_mangle]
7381pub unsafe extern "C" fn xmlValidatePushElement(
7382 ctxt: *mut _xmlValidCtxt,
7383 doc: *mut _xmlDoc,
7384 elem: *mut _xmlNode,
7385 qname: *const xmlChar,
7386) -> c_int {
7387 crate::xml::validation::validate_push_element(ctxt, doc, elem, qname)
7388}
7389
7390#[no_mangle]
7400pub unsafe extern "C" fn xmlValidatePushCData(
7401 ctxt: *mut _xmlValidCtxt,
7402 data: *const xmlChar,
7403 len: c_int,
7404) -> c_int {
7405 crate::xml::validation::validate_push_cdata(ctxt, data, len)
7406}
7407
7408#[no_mangle]
7419pub unsafe extern "C" fn xmlValidatePopElement(
7420 ctxt: *mut _xmlValidCtxt,
7421 doc: *mut _xmlDoc,
7422 elem: *mut _xmlNode,
7423 qname: *const xmlChar,
7424) -> c_int {
7425 crate::xml::validation::validate_pop_element(ctxt, doc, elem, qname)
7426}
7427
7428#[no_mangle]
7437pub unsafe extern "C" fn xmlValidBuildContentModel(
7438 ctxt: *mut _xmlValidCtxt,
7439 elem: *mut _xmlElement,
7440) -> c_int {
7441 crate::xml::validation::validate_build_content_model(ctxt, elem)
7442}
7443
7444#[no_mangle]
7455pub unsafe extern "C" fn xmlAddID(
7456 ctxt: *mut _xmlValidCtxt,
7457 doc: *mut _xmlDoc,
7458 value: *const xmlChar,
7459 attr: *mut _xmlAttr,
7460) -> *mut _xmlID {
7461 crate::xml::validation::add_id(ctxt, doc, value, attr)
7462}
7463
7464#[no_mangle]
7472pub unsafe extern "C" fn xmlRemoveID(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7473 crate::xml::validation::remove_id(doc, attr)
7474}
7475
7476#[no_mangle]
7487pub unsafe extern "C" fn xmlAddRef(
7488 ctxt: *mut _xmlValidCtxt,
7489 doc: *mut _xmlDoc,
7490 value: *const xmlChar,
7491 attr: *mut _xmlAttr,
7492) -> *mut _xmlRef {
7493 crate::xml::validation::add_ref(ctxt, doc, value, attr)
7494}
7495
7496#[no_mangle]
7504pub unsafe extern "C" fn xmlRemoveRef(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7505 crate::xml::validation::remove_ref(doc, attr)
7506}
7507
7508#[no_mangle]
7516pub unsafe extern "C" fn xmlAddIDSafe(attr: *mut _xmlAttr, value: *const xmlChar) -> c_int {
7517 crate::xml::validation::add_id_safe(attr, value)
7518}
7519
7520#[no_mangle]
7528pub unsafe extern "C" fn xmlFreeIDTable(table: *mut c_void) {
7529 crate::xml::validation::free_id_table(table as *mut crate::xml::hash::HashTable);
7530}
7531
7532#[no_mangle]
7540pub unsafe extern "C" fn xmlFreeRefTable(table: *mut c_void) {
7541 crate::xml::validation::free_ref_table(table as *mut crate::xml::hash::HashTable);
7542}
7543
7544#[no_mangle]
7552pub unsafe extern "C" fn xmlGetID(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut _xmlAttr {
7553 crate::xml::validation::get_id(doc, id)
7554}
7555
7556#[no_mangle]
7564pub unsafe extern "C" fn xmlGetRefs(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut c_void {
7565 crate::xml::validation::get_refs(doc, id) as *mut c_void
7566}
7567
7568#[no_mangle]
7576pub unsafe extern "C" fn xmlIsID(
7577 doc: *mut _xmlDoc,
7578 elem: *mut _xmlNode,
7579 attr: *mut _xmlAttr,
7580) -> c_int {
7581 crate::xml::validation::is_id(doc, elem, attr)
7582}
7583
7584#[no_mangle]
7592pub unsafe extern "C" fn xmlIsRef(
7593 doc: *mut _xmlDoc,
7594 elem: *mut _xmlNode,
7595 attr: *mut _xmlAttr,
7596) -> c_int {
7597 crate::xml::validation::is_ref(doc, elem, attr)
7598}
7599
7600#[no_mangle]
7608pub unsafe extern "C" fn xmlGetDtdElementDesc(
7609 dtd: *mut _xmlDtd,
7610 name: *const xmlChar,
7611) -> *mut _xmlElement {
7612 crate::xml::validation::get_dtd_element_desc(dtd, name)
7613}
7614
7615#[no_mangle]
7625pub unsafe extern "C" fn xmlGetDtdAttrDesc(
7626 dtd: *mut _xmlDtd,
7627 elem: *const xmlChar,
7628 name: *const xmlChar,
7629) -> *mut _xmlAttribute {
7630 crate::xml::validation::get_dtd_attr_desc(dtd, elem, name)
7631}
7632
7633#[no_mangle]
7643pub unsafe extern "C" fn xmlGetDtdQElementDesc(
7644 dtd: *mut _xmlDtd,
7645 name: *const xmlChar,
7646 prefix: *const xmlChar,
7647) -> *mut _xmlElement {
7648 crate::xml::validation::get_dtd_qelement_desc(dtd, name, prefix)
7649}
7650
7651#[no_mangle]
7662pub unsafe extern "C" fn xmlGetDtdQAttrDesc(
7663 dtd: *mut _xmlDtd,
7664 elem: *const xmlChar,
7665 name: *const xmlChar,
7666 prefix: *const xmlChar,
7667) -> *mut _xmlAttribute {
7668 crate::xml::validation::get_dtd_qattr_desc(dtd, elem, name, prefix)
7669}
7670
7671#[no_mangle]
7679pub unsafe extern "C" fn xmlGetDtdNotationDesc(
7680 dtd: *mut _xmlDtd,
7681 name: *const xmlChar,
7682) -> *mut _xmlNotation {
7683 crate::xml::validation::get_dtd_notation_desc(dtd, name)
7684}
7685
7686#[no_mangle]
7694pub unsafe extern "C" fn xmlValidateRoot(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7695 crate::xml::validation::validate_root(ctxt, doc)
7696}
7697
7698#[no_mangle]
7708pub unsafe extern "C" fn xmlValidateContent(
7709 ctxt: *mut _xmlValidCtxt,
7710 node: *mut _xmlNode,
7711 doc: *mut _xmlDoc,
7712) -> c_int {
7713 crate::xml::validation::validate_content(ctxt, node, doc)
7714}
7715
7716#[no_mangle]
7724pub unsafe extern "C" fn xmlIsMixedElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7725 crate::xml::validation::is_mixed_element(doc, name)
7726}
7727
7728#[no_mangle]
7736pub unsafe extern "C" fn xmlIsEmptyElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7737 crate::xml::validation::is_empty_element(doc, name)
7738}
7739
7740#[no_mangle]
7750pub unsafe extern "C" fn xmlValidateDtd(
7751 ctxt: *mut _xmlValidCtxt,
7752 doc: *mut _xmlDoc,
7753 dtd: *mut _xmlDtd,
7754) -> c_int {
7755 crate::xml::validation::validate_dtd(ctxt, doc, dtd)
7756}
7757
7758#[no_mangle]
7766pub unsafe extern "C" fn xmlValidateDtdFinal(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7767 crate::xml::validation::validate_dtd_final(ctxt, doc)
7768}
7769
7770#[no_mangle]
7780pub unsafe extern "C" fn xmlValidateEnumeration(
7781 ctxt: *mut _xmlValidCtxt,
7782 value: *const xmlChar,
7783 tree: *mut _xmlEnumeration,
7784) -> c_int {
7785 crate::xml::validation::validate_enumeration(ctxt, value, tree)
7786}
7787
7788#[no_mangle]
7801pub const extern "C" fn xmlGetBinaryPath() -> *mut c_char {
7802 ptr::null_mut()
7804}
7805
7806#[no_mangle]
7814pub const extern "C" fn xmlGetHomeOfBinary() -> *mut c_char {
7815 ptr::null_mut()
7817}
7818
7819#[no_mangle]
7830pub unsafe extern "C" fn xmlSAX2StartDocument(ctx: *mut c_void) {
7831 crate::xml::sax::default::default_sax_handler::startDocument(ctx)
7832}
7833
7834#[no_mangle]
7836pub unsafe extern "C" fn xmlSAX2EndDocument(ctx: *mut c_void) {
7837 crate::xml::sax::default::default_sax_handler::endDocument(ctx)
7838}
7839
7840#[no_mangle]
7842pub unsafe extern "C" fn xmlSAX2StartElementNs(
7843 ctx: *mut c_void,
7844 localname: *const xmlChar,
7845 prefix: *const xmlChar,
7846 URI: *const xmlChar,
7847 nb_namespaces: c_int,
7848 namespaces: *mut *const xmlChar,
7849 nb_attributes: c_int,
7850 nb_defaulted: c_int,
7851 attributes: *mut *const xmlChar,
7852) {
7853 crate::xml::sax::default::default_sax_handler::startElementNs(
7854 ctx,
7855 localname,
7856 prefix,
7857 URI,
7858 nb_namespaces,
7859 namespaces,
7860 nb_attributes,
7861 nb_defaulted,
7862 attributes,
7863 )
7864}
7865
7866#[no_mangle]
7868pub unsafe extern "C" fn xmlSAX2EndElementNs(
7869 ctx: *mut c_void,
7870 localname: *const xmlChar,
7871 prefix: *const xmlChar,
7872 URI: *const xmlChar,
7873) {
7874 crate::xml::sax::default::default_sax_handler::endElementNs(ctx, localname, prefix, URI)
7875}
7876
7877#[no_mangle]
7879pub unsafe extern "C" fn xmlSAX2Characters(ctx: *mut c_void, ch: *const xmlChar, len: c_int) {
7880 crate::xml::sax::default::default_sax_handler::characters(ctx, ch, len)
7881}
7882
7883#[no_mangle]
7885pub unsafe extern "C" fn xmlSAX2IgnorableWhitespace(
7886 ctx: *mut c_void,
7887 ch: *const xmlChar,
7888 len: c_int,
7889) {
7890 crate::xml::sax::default::default_sax_handler::ignorableWhitespace(ctx, ch, len)
7891}
7892
7893#[no_mangle]
7895pub unsafe extern "C" fn xmlSAX2Comment(ctx: *mut c_void, value: *const xmlChar) {
7896 crate::xml::sax::default::default_sax_handler::comment(ctx, value)
7897}
7898
7899#[no_mangle]
7901pub unsafe extern "C" fn xmlSAX2ProcessingInstruction(
7902 ctx: *mut c_void,
7903 target: *const xmlChar,
7904 data: *const xmlChar,
7905) {
7906 crate::xml::sax::default::default_sax_handler::processingInstruction(ctx, target, data)
7907}
7908
7909#[no_mangle]
7911pub unsafe extern "C" fn xmlSAX2CDataBlock(ctx: *mut c_void, value: *const xmlChar, len: c_int) {
7912 crate::xml::sax::default::default_sax_handler::cdataBlock(ctx, value, len)
7913}
7914
7915#[no_mangle]
7917pub unsafe extern "C" fn xmlSAX2InternalSubset(
7918 ctx: *mut c_void,
7919 name: *const xmlChar,
7920 ExternalID: *const xmlChar,
7921 SystemID: *const xmlChar,
7922) {
7923 crate::xml::sax::default::default_sax_handler::internalSubset(ctx, name, ExternalID, SystemID)
7924}
7925
7926#[no_mangle]
7928pub unsafe extern "C" fn xmlSAX2ExternalSubset(
7929 ctx: *mut c_void,
7930 name: *const xmlChar,
7931 ExternalID: *const xmlChar,
7932 SystemID: *const xmlChar,
7933) {
7934 crate::xml::sax::default::default_sax_handler::externalSubset(ctx, name, ExternalID, SystemID)
7935}
7936
7937#[no_mangle]
7939pub unsafe extern "C" fn xmlSAX2EntityDecl(
7940 ctx: *mut c_void,
7941 name: *const xmlChar,
7942 type_: c_int,
7943 publicId: *const xmlChar,
7944 systemId: *const xmlChar,
7945 content: *mut xmlChar,
7946) {
7947 crate::xml::sax::default::default_sax_handler::entityDecl(
7948 ctx, name, type_, publicId, systemId, content,
7949 )
7950}
7951
7952#[no_mangle]
7954pub const unsafe extern "C" fn xmlSAX2AttributeDecl(
7955 ctx: *mut c_void,
7956 elem: *const xmlChar,
7957 fullname: *const xmlChar,
7958 type_: c_int,
7959 def: c_int,
7960 defaultValue: *const xmlChar,
7961 tree: *mut crate::abi::structs::_xmlEnumeration,
7962) {
7963 crate::xml::sax::default::default_sax_handler::attributeDecl(
7964 ctx,
7965 elem,
7966 fullname,
7967 type_,
7968 def,
7969 defaultValue,
7970 tree,
7971 )
7972}
7973
7974#[no_mangle]
7976pub const unsafe extern "C" fn xmlSAX2ElementDecl(
7977 ctx: *mut c_void,
7978 name: *const xmlChar,
7979 type_: c_int,
7980 content: *mut crate::abi::structs::_xmlElementContent,
7981) {
7982 crate::xml::sax::default::default_sax_handler::elementDecl(ctx, name, type_, content)
7983}
7984
7985#[no_mangle]
7987pub const unsafe extern "C" fn xmlSAX2NotationDecl(
7988 ctx: *mut c_void,
7989 name: *const xmlChar,
7990 publicId: *const xmlChar,
7991 systemId: *const xmlChar,
7992) {
7993 crate::xml::sax::default::default_sax_handler::notationDecl(ctx, name, publicId, systemId)
7994}
7995
7996#[no_mangle]
7998pub const unsafe extern "C" fn xmlSAX2UnparsedEntityDecl(
7999 ctx: *mut c_void,
8000 name: *const xmlChar,
8001 publicId: *const xmlChar,
8002 systemId: *const xmlChar,
8003 notationName: *const xmlChar,
8004) {
8005 crate::xml::sax::default::default_sax_handler::unparsedEntityDecl(
8006 ctx,
8007 name,
8008 publicId,
8009 systemId,
8010 notationName,
8011 )
8012}
8013
8014#[no_mangle]
8016pub const unsafe extern "C" fn xmlSAX2ResolveEntity(
8017 ctx: *mut c_void,
8018 publicId: *const xmlChar,
8019 systemId: *const xmlChar,
8020) -> *mut crate::abi::structs::_xmlParserInput {
8021 crate::xml::sax::default::default_sax_handler::resolveEntity(ctx, publicId, systemId)
8022}
8023
8024#[no_mangle]
8026pub const unsafe extern "C" fn xmlSAX2IsStandalone(ctx: *mut c_void) -> c_int {
8027 crate::xml::sax::default::default_sax_handler::isStandalone(ctx)
8028}
8029
8030#[no_mangle]
8032pub unsafe extern "C" fn xmlSAX2HasInternalSubset(ctx: *mut c_void) -> c_int {
8033 crate::xml::sax::default::default_sax_handler::hasInternalSubset(ctx)
8034}
8035
8036#[no_mangle]
8038pub unsafe extern "C" fn xmlSAX2HasExternalSubset(ctx: *mut c_void) -> c_int {
8039 crate::xml::sax::default::default_sax_handler::hasExternalSubset(ctx)
8040}
8041
8042#[no_mangle]
8044pub unsafe extern "C" fn xmlSAX2GetEntity(
8045 ctx: *mut c_void,
8046 name: *const xmlChar,
8047) -> *mut crate::abi::structs::_xmlEntity {
8048 crate::xml::sax::default::default_sax_handler::getEntity(ctx, name)
8049}
8050
8051#[no_mangle]
8053pub unsafe extern "C" fn xmlSAX2GetParameterEntity(
8054 ctx: *mut c_void,
8055 name: *const xmlChar,
8056) -> *mut crate::abi::structs::_xmlEntity {
8057 crate::xml::sax::default::default_sax_handler::getParameterEntity(ctx, name)
8058}
8059
8060#[no_mangle]
8063pub unsafe extern "C" fn xmlSAX2GetLineNumber(ctx: *mut c_void) -> c_int {
8064 crate::xml::sax::default::default_sax_handler::getLineNumber(ctx)
8065}
8066
8067#[no_mangle]
8069pub unsafe extern "C" fn xmlSAX2GetColumnNumber(ctx: *mut c_void) -> c_int {
8070 crate::xml::sax::default::default_sax_handler::getColumnNumber(ctx)
8071}
8072
8073#[no_mangle]
8075pub const unsafe extern "C" fn xmlSAX2GetPublicId(ctx: *mut c_void) -> *const xmlChar {
8076 crate::xml::sax::default::default_sax_handler::getPublicId(ctx)
8077}
8078
8079#[no_mangle]
8081pub unsafe extern "C" fn xmlSAX2GetSystemId(ctx: *mut c_void) -> *const xmlChar {
8082 crate::xml::sax::default::default_sax_handler::getSystemId(ctx)
8083}
8084
8085#[no_mangle]
8089pub unsafe extern "C" fn xmlSAX2StartElement(
8090 ctx: *mut c_void,
8091 name: *const xmlChar,
8092 atts: *mut *const xmlChar,
8093) {
8094 crate::xml::sax::dispatch::SaxDispatcher::sax1_start_element(ctx, name, atts);
8098}
8099
8100#[no_mangle]
8102pub unsafe extern "C" fn xmlSAX2EndElement(ctx: *mut c_void, name: *const xmlChar) {
8103 crate::xml::sax::dispatch::SaxDispatcher::sax1_end_element(ctx, name);
8104}
8105
8106#[no_mangle]
8108pub const unsafe extern "C" fn xmlSAX2SetDocumentLocator(
8109 ctx: *mut c_void,
8110 loc: *mut crate::abi::callbacks::_xmlSAXLocator,
8111) {
8112 crate::xml::sax::default::default_sax_handler::setDocumentLocator(ctx, loc)
8113}
8114
8115#[no_mangle]
8117pub unsafe extern "C" fn xmlSAX2Reference(ctx: *mut c_void, name: *const xmlChar) {
8118 crate::xml::sax::default::default_sax_handler::reference(ctx, name)
8119}
8120
8121#[cfg(test)]
8122mod tests {
8123 use super::xml_number_to_string;
8124
8125 #[allow(clippy::approx_constant)]
8131 #[test]
8132 fn test_xml_number_to_string_parity_cases() {
8133 let cases: &[(f64, &str)] = &[
8134 (1234567.891, "1234567.891"),
8135 (0.1 + 0.2, "0.3"),
8136 (1.0 / 3.0, "0.333333333333333"),
8137 (1e20, "1e+20"),
8138 (1e-5, "0.00001"),
8139 (123456789012345678901234567890.0, "1.23456789012346e+29"),
8140 (1e100, "1e+100"),
8141 (-1e100, "-1e+100"),
8142 (1.5e-100, "1.5e-100"),
8143 (1e9, "1000000000"),
8144 (0.00001, "0.00001"),
8145 (9.99e-6, "9.99e-06"),
8146 (2147483646.0, "2147483646"),
8147 (2147483648.0, "2.147483648e+09"),
8148 (-2147483647.0, "-2147483647"),
8149 (-2147483649.0, "-2.147483649e+09"),
8150 (0.5, "0.5"),
8151 (1.0 / 7.0, "0.142857142857143"),
8152 (2.675, "2.675"),
8153 (3.141592653589793, "3.141592653589793"),
8154 (-0.0, "0"),
8155 (0.0, "0"),
8156 (f64::INFINITY, "Infinity"),
8157 (f64::NEG_INFINITY, "-Infinity"),
8158 (f64::NAN, "NaN"),
8159 (0.30000000000000004, "0.3"),
8160 (2.2250738585072014e-308, "2.2250738585072e-308"),
8161 (5e-324, "4.94065645841247e-324"),
8162 ];
8163 for (n, expected) in cases {
8164 assert_eq!(&xml_number_to_string(*n), expected, "value: {}", n);
8165 }
8166 }
8167}