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]
935pub unsafe extern "C" fn xmlSplitQName3(name: *const xmlChar, len: *mut c_int) -> c_int {
936 crate::xml::string::split_qname3(name, len)
937}
938
939#[no_mangle]
941pub unsafe extern "C" fn xmlSplitQName(
942 name: *const xmlChar,
943 prefix: *mut *mut xmlChar,
944) -> *mut xmlChar {
945 crate::xml::string::split_qname2(name, prefix)
946}
947
948#[no_mangle]
956pub const unsafe extern "C" fn xmlUTF8Strlen(utf: *const xmlChar) -> c_int {
957 crate::xml::string::utf8_strlen(utf)
958}
959
960#[no_mangle]
968pub const unsafe extern "C" fn xmlUTF8Size(utf: *const xmlChar) -> c_int {
969 crate::xml::string::utf8_size(utf)
970}
971
972#[no_mangle]
980pub const unsafe extern "C" fn xmlCheckUTF8(utf: *const xmlChar) -> c_int {
981 crate::xml::string::check_utf8(utf)
982}
983
984#[no_mangle]
995pub unsafe extern "C" fn xmlStrQEqual(
996 pref: *const xmlChar,
997 name: *const xmlChar,
998 str: *const xmlChar,
999) -> c_int {
1000 if name.is_null() || str.is_null() {
1001 return 0;
1002 }
1003 if pref.is_null() {
1004 return unsafe { xmlStrEqual(name, str) };
1005 }
1006 let pref_len = unsafe { xmlStrlen(pref) };
1008 let name_len = unsafe { xmlStrlen(name) };
1009 let total_len = pref_len + 1 + name_len;
1010 let str_len = unsafe { xmlStrlen(str) };
1011 if total_len != str_len {
1012 return 0;
1013 }
1014 if unsafe {
1016 libc::strncmp(
1017 pref as *const c_char,
1018 str as *const c_char,
1019 pref_len as usize,
1020 )
1021 } != 0
1022 {
1023 return 0;
1024 }
1025 if unsafe { *str.add(pref_len as usize) } != b':' as xmlChar {
1027 return 0;
1028 }
1029 (unsafe {
1031 libc::strncmp(
1032 name as *const c_char,
1033 str.add((pref_len + 1) as usize) as *const c_char,
1034 name_len as usize,
1035 ) == 0
1036 }) as c_int
1037}
1038
1039#[no_mangle]
1053pub unsafe extern "C" fn xmlStrcat(cur: *mut xmlChar, add: *const xmlChar) -> *mut xmlChar {
1054 if add.is_null() {
1055 return cur;
1056 }
1057 if cur.is_null() {
1058 return unsafe { xmlStrdup(add) };
1059 }
1060 let cur_len = unsafe { xmlStrlen(cur) } as usize;
1061 let add_len = unsafe { xmlStrlen(add) } as usize;
1062 let new_size = cur_len + add_len + 1;
1063 let new_ptr = unsafe { xmlReallocImpl(cur as *mut c_void, new_size) };
1064 if new_ptr.is_null() {
1065 return ptr::null_mut();
1066 }
1067 unsafe {
1068 ptr::copy_nonoverlapping(add, (new_ptr as *mut u8).add(cur_len), add_len);
1069 *((new_ptr as *mut u8).add(cur_len + add_len)) = 0;
1070 }
1071 new_ptr as *mut xmlChar
1072}
1073
1074#[no_mangle]
1086pub unsafe extern "C" fn xmlStrncat(
1087 cur: *mut xmlChar,
1088 add: *const xmlChar,
1089 len: c_int,
1090) -> *mut xmlChar {
1091 if add.is_null() || len <= 0 {
1092 return cur;
1093 }
1094 let len = len as usize;
1095 if cur.is_null() {
1096 return unsafe { xmlStrndup(add, len as c_int) };
1097 }
1098 let cur_len = unsafe { xmlStrlen(cur) } as usize;
1099 let new_size = cur_len + len + 1;
1100 let new_ptr = unsafe { xmlReallocImpl(cur as *mut c_void, new_size) };
1101 if new_ptr.is_null() {
1102 return ptr::null_mut();
1103 }
1104 unsafe {
1105 ptr::copy_nonoverlapping(add, (new_ptr as *mut u8).add(cur_len), len);
1106 *((new_ptr as *mut u8).add(cur_len + len)) = 0;
1107 }
1108 new_ptr as *mut xmlChar
1109}
1110
1111#[no_mangle]
1119pub unsafe extern "C" fn xmlStrncatNew(
1120 str1: *const xmlChar,
1121 str2: *const xmlChar,
1122 len: c_int,
1123) -> *mut xmlChar {
1124 let mut result: *mut xmlChar = ptr::null_mut();
1125 if !str1.is_null() {
1126 result = unsafe { xmlStrdup(str1) };
1127 }
1128 if !str2.is_null() && len > 0 {
1129 result = unsafe { xmlStrncat(result, str2, len) };
1130 }
1131 result
1132}
1133
1134#[no_mangle]
1147pub unsafe extern "C" fn xmlStrcpy(dst: *mut xmlChar, src: *const xmlChar) -> *mut xmlChar {
1148 if dst.is_null() || src.is_null() {
1149 return dst;
1150 }
1151 let len = unsafe { xmlStrlen(src) } as usize + 1;
1152 unsafe {
1153 ptr::copy_nonoverlapping(src, dst, len);
1154 }
1155 dst
1156}
1157
1158#[no_mangle]
1166pub unsafe extern "C" fn xmlStrncpy(
1167 dst: *mut xmlChar,
1168 src: *const xmlChar,
1169 len: c_int,
1170) -> *mut xmlChar {
1171 if dst.is_null() || src.is_null() || len <= 0 {
1172 return dst;
1173 }
1174 let len = len as usize;
1175 let src_len = unsafe { xmlStrlen(src) } as usize;
1176 let copy_len = if src_len < len { src_len } else { len - 1 };
1177 unsafe {
1178 ptr::copy_nonoverlapping(src, dst, copy_len);
1179 *dst.add(copy_len) = 0;
1180 }
1181 dst
1182}
1183
1184#[no_mangle]
1194pub unsafe extern "C" fn xmlStrsub(str: *const xmlChar, start: c_int, len: c_int) -> *mut xmlChar {
1195 if str.is_null() || start < 0 || len < 0 {
1196 return ptr::null_mut();
1197 }
1198 let str_len = unsafe { xmlStrlen(str) };
1199 if start >= str_len {
1200 return unsafe { xmlStrdup(b"\0" as *const u8 as *const xmlChar) };
1201 }
1202 let actual_len = if start + len > str_len {
1203 str_len - start
1204 } else {
1205 len
1206 };
1207 unsafe { xmlStrndup(str.add(start as usize), actual_len) }
1208}
1209
1210#[no_mangle]
1227pub unsafe extern "C" fn xmlNewDoc(version: *const xmlChar) -> *mut _xmlDoc {
1228 crate::xml::tree::new_doc(version)
1229}
1230
1231#[no_mangle]
1243pub unsafe extern "C" fn xmlFreeDoc(doc: *mut _xmlDoc) {
1244 crate::xml::tree::free_doc(doc);
1245}
1246
1247#[no_mangle]
1257pub unsafe extern "C" fn xmlGetDocCompressMode(doc: *mut _xmlDoc) -> c_int {
1258 crate::xml::tree::xmlGetDocCompressMode(doc)
1259}
1260
1261#[no_mangle]
1269pub unsafe extern "C" fn xmlSetDocCompressMode(doc: *mut _xmlDoc, mode: c_int) {
1270 crate::xml::tree::xmlSetDocCompressMode(doc, mode);
1271}
1272
1273#[no_mangle]
1287pub unsafe extern "C" fn xmlNewNode(ns: *mut _xmlNs, name: *const xmlChar) -> *mut _xmlNode {
1288 crate::xml::tree::new_node(ns, name)
1289}
1290
1291#[no_mangle]
1304pub unsafe extern "C" fn xmlFreeNode(node: *mut _xmlNode) {
1305 crate::xml::tree::free_node(node);
1306}
1307
1308#[no_mangle]
1325pub unsafe extern "C" fn xmlFreeNodeList(node: *mut _xmlNode) {
1326 crate::xml::tree::free_node_list(node);
1327}
1328
1329#[no_mangle]
1341pub unsafe extern "C" fn xmlUnlinkNode(node: *mut _xmlNode) {
1342 crate::xml::tree::unlink_node(node);
1343}
1344
1345#[no_mangle]
1361pub unsafe extern "C" fn xmlSAX2InitDefaultSAXHandler(
1362 handler: *mut crate::abi::structs::_xmlSAXHandler,
1363 _warning: c_int,
1364) {
1365 crate::xml::sax::dispatch::xmlSAX2InitDefaultSAXHandler(handler);
1366}
1367
1368#[no_mangle]
1387pub unsafe extern "C" fn xmlSAX2InitHtmlDefaultSAXHandler(
1388 handler: *mut crate::abi::structs::_xmlSAXHandler,
1389) {
1390 if handler.is_null() {
1391 return;
1392 }
1393 unsafe {
1395 if (*handler).initialized != 0 {
1397 return;
1398 }
1399 crate::xml::sax::dispatch::xmlSAX2InitDefaultSAXHandler(handler);
1400 let h = &mut *handler;
1401 h.resolveEntity = None;
1402 h.getParameterEntity = None;
1403 h.entityDecl = None;
1404 h.attributeDecl = None;
1405 h.elementDecl = None;
1406 h.notationDecl = None;
1407 h.unparsedEntityDecl = None;
1408 h.reference = None;
1409 h.externalSubset = None;
1410 h.initialized = 1;
1411 }
1412}
1413
1414#[no_mangle]
1428pub unsafe extern "C" fn xmlAddChild(parent: *mut _xmlNode, cur: *mut _xmlNode) -> *mut _xmlNode {
1429 crate::xml::tree::add_child(parent, cur)
1430}
1431
1432#[no_mangle]
1444pub unsafe extern "C" fn xmlAddSibling(
1445 cur: *mut _xmlNode,
1446 sibling: *mut _xmlNode,
1447) -> *mut _xmlNode {
1448 crate::xml::tree::add_sibling(cur, sibling)
1449}
1450
1451#[no_mangle]
1470pub unsafe extern "C" fn xmlNewChild(
1471 parent: *mut _xmlNode,
1472 ns: *mut _xmlNs,
1473 name: *const xmlChar,
1474 content: *const xmlChar,
1475) -> *mut _xmlNode {
1476 crate::xml::tree::new_child(parent, ns, name)
1477}
1478
1479#[no_mangle]
1494pub unsafe extern "C" fn xmlDocSetRootElement(
1495 doc: *mut _xmlDoc,
1496 root: *mut _xmlNode,
1497) -> *mut _xmlNode {
1498 crate::xml::tree::doc_set_root_element(doc, root)
1499}
1500
1501#[no_mangle]
1511pub extern "C" fn xmlDocGetRootElement(doc: *const _xmlDoc) -> *mut _xmlNode {
1512 crate::xml::tree::doc_get_root_element(doc as *mut _xmlDoc)
1513}
1514
1515#[no_mangle]
1528pub unsafe extern "C" fn xmlCopyNode(node: *const _xmlNode, extended: c_int) -> *mut _xmlNode {
1529 crate::xml::tree::copy_node(node, extended)
1530}
1531
1532#[no_mangle]
1542pub unsafe extern "C" fn xmlCopyDoc(doc: *const _xmlDoc, recursive: c_int) -> *mut _xmlDoc {
1543 crate::xml::tree::copy_doc(doc, recursive)
1544}
1545
1546#[no_mangle]
1557pub unsafe extern "C" fn xmlNewText(content: *const xmlChar) -> *mut _xmlNode {
1558 crate::xml::tree::new_text(content)
1559}
1560
1561#[no_mangle]
1569pub unsafe extern "C" fn xmlNewComment(content: *const xmlChar) -> *mut _xmlNode {
1570 crate::xml::tree::new_comment(content)
1571}
1572
1573#[no_mangle]
1581pub unsafe extern "C" fn xmlNewPI(name: *const xmlChar, content: *const xmlChar) -> *mut _xmlNode {
1582 crate::xml::tree::new_pi(name, content)
1583}
1584
1585#[no_mangle]
1593pub unsafe extern "C" fn xmlNewCDataBlock(
1594 doc: *mut _xmlDoc,
1595 content: *const xmlChar,
1596 len: c_int,
1597) -> *mut _xmlNode {
1598 crate::xml::tree::new_cdata_block(doc, content, len)
1599}
1600
1601#[no_mangle]
1615pub unsafe extern "C" fn xmlNewNs(
1616 node: *mut _xmlNode,
1617 href: *const xmlChar,
1618 prefix: *const xmlChar,
1619) -> *mut _xmlNs {
1620 crate::xml::tree::new_ns(node, href, prefix)
1621}
1622
1623#[no_mangle]
1631pub unsafe extern "C" fn xmlSetNs(node: *mut _xmlNode, ns: *mut _xmlNs) {
1632 crate::xml::tree::set_ns(node, ns);
1633}
1634
1635#[no_mangle]
1643pub unsafe extern "C" fn xmlGetNsList(
1644 doc: *mut _xmlDoc,
1645 node: *const _xmlNode,
1646) -> *mut *mut _xmlNs {
1647 crate::xml::tree::get_ns_list(doc, node as *mut _xmlNode)
1648}
1649
1650#[no_mangle]
1658pub unsafe extern "C" fn xmlSearchNs(
1659 doc: *mut _xmlDoc,
1660 node: *mut _xmlNode,
1661 nameSpace: *const xmlChar,
1662) -> *mut _xmlNs {
1663 crate::xml::tree::search_ns(doc, node, nameSpace)
1664}
1665
1666#[no_mangle]
1674pub unsafe extern "C" fn xmlSearchNsByHref(
1675 doc: *mut _xmlDoc,
1676 node: *mut _xmlNode,
1677 href: *const xmlChar,
1678) -> *mut _xmlNs {
1679 crate::xml::tree::search_ns_by_href(doc, node, href)
1680}
1681
1682#[no_mangle]
1699pub unsafe extern "C" fn xmlSetProp(
1700 node: *mut _xmlNode,
1701 name: *const xmlChar,
1702 value: *const xmlChar,
1703) -> *mut _xmlAttr {
1704 crate::xml::tree::set_prop(node, name, value)
1705}
1706
1707#[no_mangle]
1717pub unsafe extern "C" fn xmlGetProp(node: *const _xmlNode, name: *const xmlChar) -> *mut xmlChar {
1718 crate::xml::tree::get_prop(node as *mut _xmlNode, name)
1719}
1720
1721#[no_mangle]
1729pub unsafe extern "C" fn xmlGetNsProp(
1730 node: *const _xmlNode,
1731 name: *const xmlChar,
1732 nameSpace: *const xmlChar,
1733) -> *mut xmlChar {
1734 crate::xml::tree::get_ns_prop(node as *mut _xmlNode, name, nameSpace)
1735}
1736
1737#[no_mangle]
1746pub unsafe extern "C" fn xmlSetNsProp(
1747 node: *mut _xmlNode,
1748 ns: *mut _xmlNs,
1749 name: *const xmlChar,
1750 value: *const xmlChar,
1751) -> *mut _xmlAttr {
1752 crate::xml::tree::set_ns_prop(node, ns, name, value)
1753}
1754
1755#[no_mangle]
1765pub unsafe extern "C" fn xmlRemoveProp(attr: *mut _xmlAttr) -> c_int {
1766 crate::xml::tree::remove_prop(attr)
1767}
1768
1769#[no_mangle]
1779pub unsafe extern "C" fn xmlHasProp(node: *const _xmlNode, name: *const xmlChar) -> *mut _xmlAttr {
1780 crate::xml::tree::has_prop(node as *mut _xmlNode, name)
1781}
1782
1783#[no_mangle]
1792pub unsafe extern "C" fn xmlHasNsProp(
1793 node: *const _xmlNode,
1794 name: *const xmlChar,
1795 nameSpace: *const xmlChar,
1796) -> *mut _xmlAttr {
1797 crate::xml::tree::has_ns_prop(node as *mut _xmlNode, name, nameSpace)
1798}
1799
1800#[no_mangle]
1810pub unsafe extern "C" fn xmlUnsetProp(node: *mut _xmlNode, name: *const xmlChar) -> c_int {
1811 crate::xml::tree::unset_prop(node, name)
1812}
1813
1814#[no_mangle]
1823pub unsafe extern "C" fn xmlUnsetNsProp(
1824 node: *mut _xmlNode,
1825 name: *const xmlChar,
1826 nameSpace: *const xmlChar,
1827) -> c_int {
1828 crate::xml::tree::unset_ns_prop(node, name, nameSpace)
1829}
1830
1831#[no_mangle]
1839pub unsafe extern "C" fn xmlFirstElementChild(parent: *mut _xmlNode) -> *mut _xmlNode {
1840 crate::xml::tree::first_element_child(parent)
1841}
1842
1843#[no_mangle]
1845pub unsafe extern "C" fn xmlLastElementChild(parent: *mut _xmlNode) -> *mut _xmlNode {
1846 crate::xml::tree::last_element_child(parent)
1847}
1848
1849#[no_mangle]
1851pub unsafe extern "C" fn xmlNextElementSibling(node: *mut _xmlNode) -> *mut _xmlNode {
1852 crate::xml::tree::next_element_sibling(node)
1853}
1854
1855#[no_mangle]
1857pub unsafe extern "C" fn xmlPreviousElementSibling(node: *mut _xmlNode) -> *mut _xmlNode {
1858 crate::xml::tree::previous_element_sibling(node)
1859}
1860
1861#[no_mangle]
1869pub unsafe extern "C" fn xmlChildElementCount(parent: *mut _xmlNode) -> c_ulong {
1870 crate::xml::tree::child_element_count(parent)
1871}
1872
1873#[no_mangle]
1881pub unsafe extern "C" fn xmlTextConcat(
1882 node: *mut _xmlNode,
1883 content: *const xmlChar,
1884 len: c_int,
1885) -> c_int {
1886 crate::xml::tree::text_concat(node, content, len)
1887}
1888
1889#[no_mangle]
1897pub unsafe extern "C" fn xmlTextMerge(
1898 first: *mut _xmlNode,
1899 second: *mut _xmlNode,
1900) -> *mut _xmlNode {
1901 crate::xml::tree::text_merge(first, second)
1902}
1903
1904#[no_mangle]
1912pub const extern "C" fn xmlGetIntSubset(doc: *const _xmlDoc) -> *mut _xmlDtd {
1913 crate::xml::tree::get_int_subset(doc)
1914}
1915
1916#[no_mangle]
1925pub unsafe extern "C" fn xmlNewDtd(
1926 doc: *mut _xmlDoc,
1927 name: *const xmlChar,
1928 ExternalID: *const xmlChar,
1929 SystemID: *const xmlChar,
1930) -> *mut _xmlDtd {
1931 crate::xml::tree::new_dtd(doc, name, ExternalID, SystemID)
1932}
1933
1934#[no_mangle]
1944pub unsafe extern "C" fn xmlNewEntity(
1945 doc: *mut _xmlDoc,
1946 name: *const xmlChar,
1947 type_: c_int,
1948 ExternalID: *const xmlChar,
1949 SystemID: *const xmlChar,
1950 content: *const xmlChar,
1951) -> *mut _xmlEntity {
1952 crate::xml::tree::new_entity(doc, name, type_, ExternalID, SystemID, content)
1953}
1954
1955#[no_mangle]
1963pub unsafe extern "C" fn xmlGetDocEntity(
1964 doc: *const _xmlDoc,
1965 name: *const xmlChar,
1966) -> *mut _xmlEntity {
1967 crate::xml::tree::get_doc_entity(doc, name)
1968}
1969
1970#[no_mangle]
1978pub unsafe extern "C" fn xmlGetParameterEntity(
1979 doc: *const _xmlDoc,
1980 name: *const xmlChar,
1981) -> *mut _xmlEntity {
1982 crate::xml::tree::get_parameter_entity(doc, name)
1983}
1984
1985#[no_mangle]
1996pub unsafe extern "C" fn xmlCreateIntSubset(
1997 doc: *mut _xmlDoc,
1998 name: *const xmlChar,
1999 ExternalID: *const xmlChar,
2000 SystemID: *const xmlChar,
2001) -> *mut _xmlDtd {
2002 crate::xml::dtd::create_int_subset(doc, name, ExternalID, SystemID)
2003}
2004
2005#[no_mangle]
2013pub unsafe extern "C" fn xmlFreeDtd(dtd: *mut _xmlDtd) {
2014 crate::xml::dtd::free_dtd(dtd);
2015}
2016
2017#[no_mangle]
2027pub unsafe extern "C" fn xmlAddNotationDecl(
2028 dtd: *mut _xmlDtd,
2029 name: *const xmlChar,
2030 PublicID: *const xmlChar,
2031 SystemID: *const xmlChar,
2032) -> *mut _xmlNotation {
2033 crate::xml::dtd::add_notation_decl(dtd, name, PublicID, SystemID)
2034}
2035
2036#[no_mangle]
2044pub unsafe extern "C" fn xmlGetNotationDecl(
2045 dtd: *mut _xmlDtd,
2046 name: *const xmlChar,
2047) -> *mut _xmlNotation {
2048 crate::xml::dtd::get_notation_decl(dtd, name)
2049}
2050
2051#[no_mangle]
2059pub unsafe extern "C" fn xmlCopyNotation(notation: *mut _xmlNotation) -> *mut _xmlNotation {
2060 crate::xml::dtd::copy_notation(notation)
2061}
2062
2063#[no_mangle]
2071pub unsafe extern "C" fn xmlFreeNotation(notation: *mut _xmlNotation) {
2072 crate::xml::dtd::free_notation(notation);
2073}
2074
2075#[no_mangle]
2084pub unsafe extern "C" fn xmlAddElementDecl(
2085 dtd: *mut _xmlDtd,
2086 name: *const xmlChar,
2087 type_: c_int,
2088 content: *mut _xmlElementContent,
2089) -> *mut _xmlElement {
2090 crate::xml::dtd::add_element_decl(dtd, name, type_, content)
2091}
2092
2093#[no_mangle]
2101pub unsafe extern "C" fn xmlGetElementDecl(
2102 dtd: *mut _xmlDtd,
2103 name: *const xmlChar,
2104) -> *mut _xmlElement {
2105 crate::xml::dtd::get_element_decl(dtd, name)
2106}
2107
2108#[no_mangle]
2116pub unsafe extern "C" fn xmlCopyElement(elem: *mut _xmlElement) -> *mut _xmlElement {
2117 crate::xml::dtd::copy_element(elem)
2118}
2119
2120#[no_mangle]
2128pub unsafe extern "C" fn xmlFreeElement(elem: *mut _xmlElement) {
2129 crate::xml::dtd::free_element(elem);
2130}
2131
2132#[no_mangle]
2143pub unsafe extern "C" fn xmlAddAttributeDecl(
2144 dtd: *mut _xmlDtd,
2145 elem: *mut _xmlElement,
2146 name: *const xmlChar,
2147 type_: c_int,
2148 def: c_int,
2149 defaultValue: *const xmlChar,
2150 tree: *mut _xmlEnumeration,
2151) -> *mut _xmlAttribute {
2152 crate::xml::dtd::add_attribute_decl(dtd, elem, name, type_, def, defaultValue, tree)
2153}
2154
2155#[no_mangle]
2164pub unsafe extern "C" fn xmlGetAttributeDecl(
2165 dtd: *mut _xmlDtd,
2166 elem: *mut _xmlElement,
2167 name: *const xmlChar,
2168 namePrefix: c_int,
2169) -> *mut _xmlAttribute {
2170 crate::xml::dtd::get_attribute_decl(dtd, elem, name, namePrefix)
2171}
2172
2173#[no_mangle]
2181pub unsafe extern "C" fn xmlCopyAttribute(attr: *mut _xmlAttribute) -> *mut _xmlAttribute {
2182 crate::xml::dtd::copy_attribute_decl(attr)
2183}
2184
2185#[no_mangle]
2193pub unsafe extern "C" fn xmlFreeAttribute(attr: *mut _xmlAttribute) {
2194 crate::xml::dtd::free_attribute(attr);
2195}
2196
2197#[no_mangle]
2205pub unsafe extern "C" fn xmlNewElementContent(
2206 name: *const xmlChar,
2207 type_: c_int,
2208) -> *mut _xmlElementContent {
2209 crate::xml::dtd::create_content_model(name, type_)
2210}
2211
2212#[no_mangle]
2220pub unsafe extern "C" fn xmlCopyElementContent(
2221 content: *mut _xmlElementContent,
2222) -> *mut _xmlElementContent {
2223 crate::xml::dtd::copy_content_model(content)
2224}
2225
2226#[no_mangle]
2234pub unsafe extern "C" fn xmlFreeElementContent(cur: *mut _xmlElementContent) {
2235 crate::xml::dtd::free_content_model(cur);
2236}
2237
2238#[no_mangle]
2250pub unsafe extern "C" fn xmlAddEntity(
2251 dtd: *mut _xmlDtd,
2252 name: *const xmlChar,
2253 type_: c_int,
2254 ExternalID: *const xmlChar,
2255 SystemID: *const xmlChar,
2256 content: *const xmlChar,
2257) -> *mut _xmlEntity {
2258 crate::xml::entities::add_entity(dtd, name, type_, ExternalID, SystemID, content)
2259}
2260
2261#[no_mangle]
2273pub unsafe extern "C" fn xmlAddDocEntity(
2274 doc: *mut _xmlDoc,
2275 name: *const xmlChar,
2276 type_: c_int,
2277 ExternalID: *const xmlChar,
2278 SystemID: *const xmlChar,
2279 content: *const xmlChar,
2280) -> *mut _xmlEntity {
2281 crate::xml::tree::add_doc_entity(doc, name, type_, ExternalID, SystemID, content)
2282}
2283
2284#[no_mangle]
2295pub unsafe extern "C" fn xmlAddDtdEntity(
2296 doc: *mut _xmlDoc,
2297 name: *const xmlChar,
2298 type_: c_int,
2299 ExternalID: *const xmlChar,
2300 SystemID: *const xmlChar,
2301 content: *const xmlChar,
2302) -> *mut _xmlEntity {
2303 crate::xml::tree::add_dtd_entity(doc, name, type_, ExternalID, SystemID, content)
2304}
2305
2306#[no_mangle]
2315pub unsafe extern "C" fn xmlGetDtdEntity(
2316 doc: *mut _xmlDoc,
2317 name: *const xmlChar,
2318) -> *mut _xmlEntity {
2319 crate::xml::tree::get_dtd_entity(doc, name)
2320}
2321
2322#[no_mangle]
2330pub unsafe extern "C" fn xmlGetEntity(doc: *mut _xmlDoc, name: *const xmlChar) -> *mut _xmlEntity {
2331 crate::xml::entities::get_entity(doc, name)
2332}
2333
2334#[no_mangle]
2342pub unsafe extern "C" fn xmlCopyEntity(entity: *mut _xmlEntity) -> *mut _xmlEntity {
2343 crate::xml::entities::copy_entity(entity)
2344}
2345
2346#[no_mangle]
2354pub unsafe extern "C" fn xmlFreeEntity(entity: *mut _xmlEntity) {
2355 crate::xml::entities::free_entity(entity);
2356}
2357
2358#[no_mangle]
2366pub unsafe extern "C" fn xmlEncodeEntitiesReentrant(
2367 doc: *mut _xmlDoc,
2368 input: *const xmlChar,
2369) -> *mut xmlChar {
2370 crate::xml::entities::encode_entities_reentrant(doc, input)
2371}
2372
2373#[no_mangle]
2384pub unsafe extern "C" fn xmlEncodeSpecialChars(
2385 _doc: *const _xmlDoc,
2386 input: *const xmlChar,
2387) -> *mut xmlChar {
2388 if input.is_null() {
2389 return ptr::null_mut();
2390 }
2391 unsafe {
2392 let len = crate::xml::string::xml_strlen(input);
2393 let cap = len * 6 + 1;
2396 let out = crate::abi::allocator::xmlMallocImpl(cap) as *mut xmlChar;
2397 if out.is_null() {
2398 return ptr::null_mut();
2399 }
2400 let mut o = 0usize;
2401 let mut i = 0usize;
2402 while i < len {
2403 let c = *input.add(i);
2404 let rep: &[u8] = match c {
2405 b'<' => b"<",
2406 b'>' => b">",
2407 b'&' => b"&",
2408 b'"' => b""",
2409 b'\r' => b" ",
2410 _ => {
2411 *out.add(o) = c;
2412 o += 1;
2413 i += 1;
2414 continue;
2415 }
2416 };
2417 core::ptr::copy_nonoverlapping(rep.as_ptr(), out.add(o), rep.len());
2418 o += rep.len();
2419 i += 1;
2420 }
2421 *out.add(o) = 0;
2422 out
2423 }
2424}
2425
2426#[no_mangle]
2437pub unsafe extern "C" fn xmlEncodeEntities(
2438 _doc: *mut _xmlDoc,
2439 _input: *const xmlChar,
2440) -> *mut xmlChar {
2441 use core::sync::atomic::{AtomicBool, Ordering};
2442 static WARNED: AtomicBool = AtomicBool::new(false);
2443 if !WARNED.swap(true, Ordering::Relaxed) {
2444 let msg = b"xmlEncodeEntities is deprecated, use xmlEncodeSpecialChars or xmlEncodeEntitiesReentrant\n";
2446 unsafe {
2447 libc::fwrite(
2448 msg.as_ptr() as *const c_void,
2449 1,
2450 msg.len(),
2451 libc::fdopen(2, b"w\0" as *const u8 as *const c_char),
2452 );
2453 }
2454 }
2455 ptr::null_mut()
2456}
2457
2458#[no_mangle]
2466pub extern "C" fn xmlGetLineNo(node: *const _xmlNode) -> c_long {
2467 crate::xml::tree::get_line_no(node)
2468}
2469
2470#[no_mangle]
2482pub unsafe extern "C" fn xmlNodeDump(
2483 buf: *mut _xmlBuffer,
2484 doc: *mut _xmlDoc,
2485 cur: *mut _xmlNode,
2486 level: c_int,
2487 format: c_int,
2488) -> c_int {
2489 if buf.is_null() || cur.is_null() {
2490 return -1;
2491 }
2492 crate::xml::tree::xmlNodeDump(buf, doc, cur, level, format)
2493}
2494
2495#[no_mangle]
2503pub unsafe extern "C" fn xmlDocDump(fp: *mut c_void, doc: *mut _xmlDoc) -> c_int {
2504 if fp.is_null() || doc.is_null() {
2505 return -1;
2506 }
2507 crate::xml::tree::xmlDocDump(fp, doc)
2508}
2509
2510#[no_mangle]
2518pub unsafe extern "C" fn xmlDocDumpFormatMemory(
2519 doc: *mut _xmlDoc,
2520 mem: *mut *mut xmlChar,
2521 size: *mut c_int,
2522 format: c_int,
2523) {
2524 if doc.is_null() || mem.is_null() || size.is_null() {
2525 return;
2526 }
2527 crate::xml::tree::xmlDocDumpFormatMemory(doc, mem, size, format)
2528}
2529
2530#[no_mangle]
2538pub unsafe extern "C" fn xmlDocDumpMemory(
2539 doc: *mut _xmlDoc,
2540 mem: *mut *mut xmlChar,
2541 size: *mut c_int,
2542) {
2543 if doc.is_null() || mem.is_null() || size.is_null() {
2544 return;
2545 }
2546 crate::xml::tree::xmlDocDumpMemory(doc, mem, size)
2547}
2548
2549#[no_mangle]
2557pub unsafe extern "C" fn xmlSaveFile(filename: *const c_char, cur: *mut _xmlDoc) -> c_int {
2558 if filename.is_null() || cur.is_null() {
2559 return -1;
2560 }
2561 crate::xml::tree::xmlSaveFile(filename, cur)
2562}
2563
2564#[no_mangle]
2572pub unsafe extern "C" fn xmlSaveFileEnc(
2573 filename: *const c_char,
2574 cur: *mut _xmlDoc,
2575 encoding: *const c_char,
2576) -> c_int {
2577 if filename.is_null() || cur.is_null() {
2578 return -1;
2579 }
2580 crate::xml::tree::xmlSaveFileEnc(filename, cur, encoding)
2581}
2582
2583#[no_mangle]
2591pub unsafe extern "C" fn xmlSaveFormatFile(
2592 filename: *const c_char,
2593 cur: *mut _xmlDoc,
2594 format: c_int,
2595) -> c_int {
2596 if filename.is_null() || cur.is_null() {
2597 return -1;
2598 }
2599 crate::xml::tree::xmlSaveFormatFile(filename, cur, format)
2600}
2601
2602#[no_mangle]
2610pub unsafe extern "C" fn xmlSaveFormatFileEnc(
2611 filename: *const c_char,
2612 cur: *mut _xmlDoc,
2613 encoding: *const c_char,
2614 format: c_int,
2615) -> c_int {
2616 if filename.is_null() || cur.is_null() {
2617 return -1;
2618 }
2619 crate::xml::tree::xmlSaveFormatFileEnc(filename, cur, encoding, format)
2620}
2621
2622#[no_mangle]
2637pub unsafe extern "C" fn xmlReadDoc(
2638 cur: *const xmlChar,
2639 URL: *const c_char,
2640 encoding: *const c_char,
2641 options: c_int,
2642) -> *mut _xmlDoc {
2643 if cur.is_null() {
2645 return ptr::null_mut();
2646 }
2647 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2648 if ctxt.is_null() {
2649 return ptr::null_mut();
2650 }
2651 let len = crate::xml::string::xml_strlen(cur);
2652 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2653 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2654 (*ctxt).options = options;
2655 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2656 let doc = (*ctxt).myDoc;
2657 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2658 return doc;
2659 }
2660 let doc = (*ctxt).myDoc;
2661 if !doc.is_null() {
2662 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2663 }
2664 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2665 doc
2666}
2667
2668#[no_mangle]
2676pub unsafe extern "C" fn xmlReadFile(
2677 URL: *const c_char,
2678 encoding: *const c_char,
2679 options: c_int,
2680) -> *mut _xmlDoc {
2681 if URL.is_null() {
2683 return ptr::null_mut();
2684 }
2685 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2686 if ctxt.is_null() {
2687 return ptr::null_mut();
2688 }
2689 let input = match crate::xml::parser::helpers::input_from_file(URL) {
2690 Ok(input) => input,
2691 Err(_) => {
2692 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2693 return ptr::null_mut();
2694 }
2695 };
2696 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2697 (*ctxt).options = options;
2698 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2699 let doc = (*ctxt).myDoc;
2700 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2701 if options & 1 << 0 != 0 {
2705 return doc;
2706 }
2707 if !doc.is_null() {
2708 crate::xml::tree::free_doc(doc);
2709 }
2710 return ptr::null_mut();
2711 }
2712 let doc = (*ctxt).myDoc;
2713 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2714 doc
2715}
2716
2717#[no_mangle]
2726pub unsafe extern "C" fn xmlRecoverDoc(cur: *const xmlChar) -> *mut _xmlDoc {
2727 unsafe { xmlReadDoc(cur, ptr::null(), ptr::null(), 1 << 0) }
2728}
2729
2730#[no_mangle]
2738pub unsafe extern "C" fn xmlRecoverFile(filename: *const c_char) -> *mut _xmlDoc {
2739 unsafe { xmlReadFile(filename, ptr::null(), 1 << 0) }
2740}
2741
2742#[no_mangle]
2750pub unsafe extern "C" fn xmlRecoverMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
2751 unsafe { xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 1 << 0) }
2752}
2753
2754#[no_mangle]
2763pub unsafe extern "C" fn xmlReadMemory(
2764 buffer: *const c_char,
2765 size: c_int,
2766 URL: *const c_char,
2767 encoding: *const c_char,
2768 options: c_int,
2769) -> *mut _xmlDoc {
2770 if buffer.is_null() || size < 0 {
2774 return ptr::null_mut();
2775 }
2776 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2777 if ctxt.is_null() {
2778 return ptr::null_mut();
2779 }
2780 let input = crate::xml::parser::helpers::input_from_memory_named(buffer, size, URL);
2783 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2784 crate::abi::exports_parser::apply_options(ctxt, options);
2788 let parsed = crate::xml::parser::helpers::parse_document(ctxt);
2789 let doc = (*ctxt).myDoc;
2790 if !doc.is_null() && !URL.is_null() && (*doc).URL.is_null() {
2793 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2794 }
2795 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2796 if parsed != 0 {
2797 if options & 1 << 0 != 0 {
2801 return doc;
2802 }
2803 if !doc.is_null() {
2804 crate::xml::tree::free_doc(doc);
2805 }
2806 return ptr::null_mut();
2807 }
2808 doc
2809}
2810
2811#[no_mangle]
2817pub unsafe extern "C" fn xmlLoadCatalogs(catalogs: *const c_char) {
2818 if !catalogs.is_null() {
2819 crate::xml::catalog::load_catalog(catalogs);
2820 }
2821}
2822
2823#[no_mangle]
2829pub unsafe extern "C" fn xmlLoadCatalog(catalogs: *const c_char) -> c_int {
2830 let handle = crate::xml::catalog::load_catalog(catalogs);
2833 if handle.is_null() {
2834 1
2835 } else {
2836 0
2837 }
2838}
2839
2840#[no_mangle]
2848pub unsafe extern "C" fn xmlReadFd(
2849 fd: c_int,
2850 URL: *const c_char,
2851 encoding: *const c_char,
2852 options: c_int,
2853) -> *mut _xmlDoc {
2854 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2856 if ctxt.is_null() {
2857 return ptr::null_mut();
2858 }
2859 let mut buf = Vec::new();
2861 let mut tmp = [0u8; 4096];
2862 loop {
2863 let n = libc::read(fd, tmp.as_mut_ptr() as *mut c_void, tmp.len());
2864 if n <= 0 {
2865 break;
2866 }
2867 buf.extend_from_slice(&tmp[..n as usize]);
2868 }
2869 let input = crate::xml::parser::helpers::input_from_memory(
2870 buf.as_ptr() as *const c_char,
2871 buf.len() as c_int,
2872 );
2873 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2874 (*ctxt).options = options;
2875 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2876 let doc = (*ctxt).myDoc;
2877 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2878 return doc;
2879 }
2880 let doc = (*ctxt).myDoc;
2881 if !doc.is_null() && !URL.is_null() {
2882 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2883 }
2884 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2885 doc
2886}
2887
2888#[no_mangle]
2897pub unsafe extern "C" fn xmlReadIO(
2898 ioread: Option<xmlInputReadCallback>,
2899 ioclose: Option<xmlInputCloseCallback>,
2900 ioctx: *mut c_void,
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 input = crate::xml::parser::helpers::input_from_io(ioread, ioclose, ioctx);
2911 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2912 (*ctxt).options = options;
2913 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2914 let doc = (*ctxt).myDoc;
2915 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2916 return doc;
2917 }
2918 let doc = (*ctxt).myDoc;
2919 if !doc.is_null() && !URL.is_null() {
2920 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2921 }
2922 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2923 doc
2924}
2925
2926#[no_mangle]
2934pub unsafe extern "C" fn xmlSAXParseDoc(
2935 sax: *mut _xmlSAXHandler,
2936 cur: *const xmlChar,
2937 recovery: c_int,
2938) -> *mut _xmlDoc {
2939 if cur.is_null() {
2941 return ptr::null_mut();
2942 }
2943 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2944 if ctxt.is_null() {
2945 return ptr::null_mut();
2946 }
2947 if !sax.is_null() {
2948 (*ctxt).sax = sax;
2949 (*ctxt).userData = (*ctxt).sax as *mut c_void;
2950 }
2951 if recovery != 0 {
2952 (*ctxt).recovery = 1;
2953 (*ctxt).options |= 1; }
2955 let len = crate::xml::string::xml_strlen(cur);
2956 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2957 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2958 crate::xml::parser::helpers::parse_document(ctxt);
2959 let doc = (*ctxt).myDoc;
2960 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2961 doc
2962}
2963
2964#[no_mangle]
2974pub unsafe extern "C" fn xmlSAXParseDocWithData(
2975 sax: *mut _xmlSAXHandler,
2976 cur: *const xmlChar,
2977 recovery: c_int,
2978 data: *mut c_void,
2979) -> *mut _xmlDoc {
2980 if cur.is_null() {
2982 return ptr::null_mut();
2983 }
2984 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2985 if ctxt.is_null() {
2986 return ptr::null_mut();
2987 }
2988 if !sax.is_null() {
2989 (*ctxt).sax = sax;
2990 }
2991 (*ctxt).userData = data;
2992 if recovery != 0 {
2993 (*ctxt).recovery = 1;
2994 (*ctxt).options |= 1; }
2996 let len = crate::xml::string::xml_strlen(cur);
2997 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2998 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2999 crate::xml::parser::helpers::parse_document(ctxt);
3000 let doc = (*ctxt).myDoc;
3001 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3002 doc
3003}
3004
3005#[no_mangle]
3015pub unsafe extern "C" fn xmlSAXParseFileWithData(
3016 sax: *mut _xmlSAXHandler,
3017 filename: *const c_char,
3018 recovery: c_int,
3019 data: *mut c_void,
3020) -> *mut _xmlDoc {
3021 if filename.is_null() {
3023 return ptr::null_mut();
3024 }
3025 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3026 if ctxt.is_null() {
3027 return ptr::null_mut();
3028 }
3029 if !sax.is_null() {
3030 (*ctxt).sax = sax;
3031 }
3032 (*ctxt).userData = data;
3033 if recovery != 0 {
3034 (*ctxt).recovery = 1;
3035 (*ctxt).options |= 1; }
3037 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3038 Ok(input) => input,
3039 Err(_) => {
3040 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3041 return ptr::null_mut();
3042 }
3043 };
3044 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3045 crate::xml::parser::helpers::parse_document(ctxt);
3046 let doc = (*ctxt).myDoc;
3047 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3048 doc
3049}
3050
3051#[no_mangle]
3061pub unsafe extern "C" fn xmlSAXParseMemoryWithData(
3062 sax: *mut _xmlSAXHandler,
3063 buffer: *const c_char,
3064 size: c_int,
3065 recovery: c_int,
3066 data: *mut c_void,
3067) -> *mut _xmlDoc {
3068 if buffer.is_null() || size <= 0 {
3070 return ptr::null_mut();
3071 }
3072 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3073 if ctxt.is_null() {
3074 return ptr::null_mut();
3075 }
3076 if !sax.is_null() {
3077 (*ctxt).sax = sax;
3078 }
3079 (*ctxt).userData = data;
3080 if recovery != 0 {
3081 (*ctxt).recovery = 1;
3082 (*ctxt).options |= 1; }
3084 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3085 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3086 crate::xml::parser::helpers::parse_document(ctxt);
3087 let doc = (*ctxt).myDoc;
3088 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3089 doc
3090}
3091
3092#[no_mangle]
3100pub unsafe extern "C" fn xmlSAXParseFile(
3101 sax: *mut _xmlSAXHandler,
3102 filename: *const c_char,
3103 recovery: c_int,
3104) -> *mut _xmlDoc {
3105 if filename.is_null() {
3107 return ptr::null_mut();
3108 }
3109 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3110 if ctxt.is_null() {
3111 return ptr::null_mut();
3112 }
3113 if !sax.is_null() {
3114 (*ctxt).sax = sax;
3115 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3116 }
3117 if recovery != 0 {
3118 (*ctxt).recovery = 1;
3119 (*ctxt).options |= 1;
3120 }
3121 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3122 Ok(input) => input,
3123 Err(_) => {
3124 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3125 return ptr::null_mut();
3126 }
3127 };
3128 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3129 crate::xml::parser::helpers::parse_document(ctxt);
3130 let doc = (*ctxt).myDoc;
3131 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3132 doc
3133}
3134
3135#[no_mangle]
3144pub unsafe extern "C" fn xmlSAXParseMemory(
3145 sax: *mut _xmlSAXHandler,
3146 buffer: *const c_char,
3147 size: c_int,
3148 recovery: c_int,
3149) -> *mut _xmlDoc {
3150 if buffer.is_null() || size <= 0 {
3152 return ptr::null_mut();
3153 }
3154 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3155 if ctxt.is_null() {
3156 return ptr::null_mut();
3157 }
3158 if !sax.is_null() {
3159 (*ctxt).sax = sax;
3160 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3161 }
3162 if recovery != 0 {
3163 (*ctxt).recovery = 1;
3164 (*ctxt).options |= 1;
3165 }
3166 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3167 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3168 crate::xml::parser::helpers::parse_document(ctxt);
3169 let doc = (*ctxt).myDoc;
3170 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3171 doc
3172}
3173
3174#[no_mangle]
3183pub unsafe extern "C" fn xmlSAXUserParseFile(
3184 sax: *mut _xmlSAXHandler,
3185 user_data: *mut c_void,
3186 filename: *const c_char,
3187) -> c_int {
3188 if filename.is_null() {
3190 return -1;
3191 }
3192 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3193 if ctxt.is_null() {
3194 return -1;
3195 }
3196 if !sax.is_null() {
3197 (*ctxt).sax = sax;
3198 }
3199 (*ctxt).userData = if !user_data.is_null() {
3200 user_data
3201 } else {
3202 ctxt as *mut c_void
3203 };
3204 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3205 Ok(input) => input,
3206 Err(_) => {
3207 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3208 return -1;
3209 }
3210 };
3211 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3212 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3213 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3214 ret
3215}
3216
3217#[no_mangle]
3226pub unsafe extern "C" fn xmlSAXUserParseMemory(
3227 sax: *mut _xmlSAXHandler,
3228 user_data: *mut c_void,
3229 buffer: *const c_char,
3230 size: c_int,
3231) -> c_int {
3232 if buffer.is_null() || size <= 0 {
3234 return -1;
3235 }
3236 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3237 if ctxt.is_null() {
3238 return -1;
3239 }
3240 if !sax.is_null() {
3241 (*ctxt).sax = sax;
3242 }
3243 (*ctxt).userData = if !user_data.is_null() {
3244 user_data
3245 } else {
3246 ctxt as *mut c_void
3247 };
3248 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3249 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3250 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3251 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3252 ret
3253}
3254
3255#[no_mangle]
3263pub unsafe extern "C" fn xmlParseDoc(cur: *const xmlChar) -> *mut _xmlDoc {
3264 if cur.is_null() {
3266 return ptr::null_mut();
3267 }
3268 xmlReadDoc(cur, ptr::null(), ptr::null(), 0)
3269}
3270
3271#[no_mangle]
3279pub unsafe extern "C" fn xmlParseFile(filename: *const c_char) -> *mut _xmlDoc {
3280 if filename.is_null() {
3282 return ptr::null_mut();
3283 }
3284 xmlReadFile(filename, ptr::null(), 0)
3285}
3286
3287#[no_mangle]
3295pub unsafe extern "C" fn xmlParseMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
3296 if buffer.is_null() || size <= 0 {
3298 return ptr::null_mut();
3299 }
3300 xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 0)
3301}
3302
3303#[no_mangle]
3311pub unsafe extern "C" fn xmlCreateFileParserCtxt(filename: *const c_char) -> *mut _xmlParserCtxt {
3312 if filename.is_null() {
3314 return ptr::null_mut();
3315 }
3316 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3317 if ctxt.is_null() {
3318 return ptr::null_mut();
3319 }
3320 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3321 Ok(input) => input,
3322 Err(_) => {
3323 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3324 return ptr::null_mut();
3325 }
3326 };
3327 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3328 ctxt
3329}
3330
3331#[no_mangle]
3339pub unsafe extern "C" fn xmlCreateDocParserCtxt(cur: *const xmlChar) -> *mut _xmlParserCtxt {
3340 if cur.is_null() {
3342 return ptr::null_mut();
3343 }
3344 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3345 if ctxt.is_null() {
3346 return ptr::null_mut();
3347 }
3348 let len = crate::xml::string::xml_strlen(cur);
3349 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
3350 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3351 ctxt
3352}
3353
3354#[no_mangle]
3362pub unsafe extern "C" fn xmlParseDocument(ctxt: *mut _xmlParserCtxt) -> c_int {
3363 if ctxt.is_null() {
3365 return -1;
3366 }
3367 crate::xml::parser::helpers::parse_document(ctxt)
3368}
3369
3370#[no_mangle]
3378pub unsafe extern "C" fn xmlFreeParserCtxt(ctxt: *mut _xmlParserCtxt) {
3379 if ctxt.is_null() {
3380 return;
3381 }
3382 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3383}
3384
3385#[no_mangle]
3393pub unsafe extern "C" fn xmlCtxtUseOptions(ctxt: *mut _xmlParserCtxt, options: c_int) -> c_int {
3394 if ctxt.is_null() {
3395 return -1;
3396 }
3397 unsafe {
3399 (*ctxt).options = options;
3400 }
3401 0
3402}
3403
3404#[no_mangle]
3413pub unsafe extern "C" fn xmlParseChunk(
3414 ctxt: *mut _xmlParserCtxt,
3415 chunk: *const c_char,
3416 size: c_int,
3417 terminate: c_int,
3418) -> c_int {
3419 if ctxt.is_null() {
3422 return -1;
3423 }
3424 crate::xml::parser::helpers::parse_chunk(ctxt, chunk, size, terminate)
3425}
3426
3427#[no_mangle]
3435pub unsafe extern "C" fn xmlParserInputBufferCreateMem(
3436 buffer: *const c_char,
3437 size: c_int,
3438 enc: c_int,
3439) -> *mut _xmlParserInputBuffer {
3440 if buffer.is_null() || size <= 0 {
3442 return ptr::null_mut();
3443 }
3444 crate::xml::parser::helpers::alloc_parser_input_buffer()
3445}
3446
3447#[no_mangle]
3455pub unsafe extern "C" fn xmlParserInputBufferCreateFilename(
3456 URI: *const c_char,
3457 enc: c_int,
3458) -> *mut _xmlParserInputBuffer {
3459 if URI.is_null() {
3461 return ptr::null_mut();
3462 }
3463 crate::xml::parser::helpers::alloc_parser_input_buffer()
3464}
3465
3466#[no_mangle]
3476pub unsafe extern "C" fn xmlParserInputBufferCreateIO(
3477 ioread: Option<xmlInputReadCallback>,
3478 ioclose: Option<xmlInputCloseCallback>,
3479 ioctx: *mut c_void,
3480 enc: c_int,
3481) -> *mut _xmlParserInputBuffer {
3482 let buf = crate::xml::parser::helpers::alloc_parser_input_buffer();
3484 if !buf.is_null() {
3485 (*buf).readcallback = ioread;
3486 (*buf).closecallback = ioclose;
3487 (*buf).context = ioctx;
3488 }
3489 buf
3490}
3491
3492#[no_mangle]
3500pub unsafe extern "C" fn xmlFreeParserInputBuffer(buf: *mut _xmlParserInputBuffer) {
3501 if buf.is_null() {
3502 return;
3503 }
3504 crate::xml::parser::helpers::free_parser_input_buffer(buf);
3505}
3506
3507#[no_mangle]
3515pub unsafe extern "C" fn xmlNewInputFromFile(
3516 ctxt: *mut _xmlParserCtxt,
3517 filename: *const c_char,
3518) -> *mut _xmlParserInput {
3519 if filename.is_null() {
3524 return ptr::null_mut();
3525 }
3526 crate::xml::parser::helpers::alloc_parser_input_buffer() as *mut _xmlParserInput
3527}
3528
3529#[no_mangle]
3537pub unsafe extern "C" fn xmlFreeInputStream(input: *mut _xmlParserInput) {
3538 if input.is_null() {
3539 return;
3540 }
3541 crate::xml::parser::helpers::free_parser_input(input);
3542}
3543
3544#[no_mangle]
3558pub unsafe extern "C" fn xmlOutputBufferCreateFilename(
3559 URI: *const c_char,
3560 encoder: *mut c_void,
3561 compression: c_int,
3562) -> *mut _xmlOutputBuffer {
3563 let _ = compression;
3564 if URI.is_null() {
3565 return ptr::null_mut();
3566 }
3567 crate::xml::io::output_buffer_create_filename(
3568 URI,
3569 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3570 0,
3571 )
3572}
3573
3574#[no_mangle]
3583pub unsafe extern "C" fn xmlOutputBufferCreateFd(
3584 fd: c_int,
3585 encoder: *mut c_void,
3586) -> *mut _xmlOutputBuffer {
3587 if fd < 0 {
3588 return ptr::null_mut();
3589 }
3590 crate::xml::io::output_buffer_create_fd(
3591 fd,
3592 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3593 )
3594}
3595
3596#[no_mangle]
3606pub unsafe extern "C" fn xmlOutputBufferCreateIO(
3607 iowrite: Option<xmlOutputWriteCallback>,
3608 ioclose: Option<xmlOutputCloseCallback>,
3609 ioctx: *mut c_void,
3610 encoder: *mut c_void,
3611) -> *mut _xmlOutputBuffer {
3612 crate::xml::io::output_buffer_create_io(
3613 iowrite,
3614 ioclose,
3615 ioctx,
3616 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3617 )
3618}
3619
3620#[no_mangle]
3628pub unsafe extern "C" fn xmlOutputBufferClose(out: *mut _xmlOutputBuffer) -> c_int {
3629 if out.is_null() {
3630 return -1;
3631 }
3632 crate::xml::io::output_buffer_close(out)
3633}
3634
3635#[no_mangle]
3643pub unsafe extern "C" fn xmlOutputBufferFlush(out: *mut _xmlOutputBuffer) -> c_int {
3644 if out.is_null() {
3645 return -1;
3646 }
3647 crate::xml::io::output_buffer_flush(out)
3648}
3649
3650#[no_mangle]
3658pub unsafe extern "C" fn xmlOutputBufferWrite(
3659 out: *mut _xmlOutputBuffer,
3660 len: c_int,
3661 data: *const c_char,
3662) -> c_int {
3663 if out.is_null() || data.is_null() || len <= 0 {
3664 return -1;
3665 }
3666 crate::xml::io::output_buffer_write(out, len, data)
3667}
3668
3669#[no_mangle]
3677pub unsafe extern "C" fn xmlOutputBufferWriteString(
3678 out: *mut _xmlOutputBuffer,
3679 str: *const c_char,
3680) -> c_int {
3681 if str.is_null() {
3682 return 0;
3683 }
3684 unsafe { xmlOutputBufferWrite(out, xmlStrlen(str as *const xmlChar), str) }
3685}
3686
3687#[no_mangle]
3695pub unsafe extern "C" fn xmlAllocOutputBuffer(encoder: *mut c_void) -> *mut _xmlOutputBuffer {
3696 crate::xml::io::output_buffer_create(
3697 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3698 )
3699}
3700
3701#[no_mangle]
3715pub unsafe extern "C" fn xmlOutputBufferCreateBuffer(
3716 buffer: *mut crate::abi::structs::_xmlBuffer,
3717 encoder: *mut c_void,
3718) -> *mut _xmlOutputBuffer {
3719 crate::xml::io::output_buffer_create_buffer(
3720 buffer,
3721 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3722 )
3723}
3724
3725#[no_mangle]
3733pub unsafe extern "C" fn xmlOutputBufferCreateFile(
3734 file: *mut libc::FILE,
3735 encoder: *mut c_void,
3736) -> *mut _xmlOutputBuffer {
3737 crate::xml::io::output_buffer_create_file(
3738 file,
3739 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3740 )
3741}
3742
3743#[no_mangle]
3749pub unsafe extern "C" fn xmlOutputBufferGetContent(out: *mut _xmlOutputBuffer) -> *const c_char {
3750 crate::xml::io::output_buffer_get_content(out) as *const c_char
3751}
3752
3753#[no_mangle]
3760pub unsafe extern "C" fn xmlOutputBufferGetSize(out: *mut _xmlOutputBuffer) -> c_int {
3761 crate::xml::io::output_buffer_get_size(out)
3762}
3763
3764#[no_mangle]
3772pub unsafe extern "C" fn xmlOutputBufferWriteEscape(
3773 out: *mut _xmlOutputBuffer,
3774 str: *const xmlChar,
3775 escaping: Option<xmlCharEncodingOutputFunc>,
3776) -> c_int {
3777 if out.is_null() || str.is_null() {
3778 return -1;
3779 }
3780 crate::xml::io::output_buffer_write_escape(out, str, escaping)
3781}
3782
3783static mut OUTPUT_CREATE_FILENAME_DEFAULT: Option<
3786 unsafe extern "C" fn(
3787 *const c_char,
3788 *mut crate::abi::structs::_xmlCharEncodingHandler,
3789 c_int,
3790 ) -> *mut _xmlOutputBuffer,
3791> = None;
3792
3793#[no_mangle]
3800pub unsafe extern "C" fn xmlOutputBufferCreateFilenameDefault(
3801 func: Option<
3802 unsafe extern "C" fn(
3803 *const c_char,
3804 *mut crate::abi::structs::_xmlCharEncodingHandler,
3805 c_int,
3806 ) -> *mut _xmlOutputBuffer,
3807 >,
3808) -> Option<
3809 unsafe extern "C" fn(
3810 *const c_char,
3811 *mut crate::abi::structs::_xmlCharEncodingHandler,
3812 c_int,
3813 ) -> *mut _xmlOutputBuffer,
3814> {
3815 let old = unsafe { OUTPUT_CREATE_FILENAME_DEFAULT };
3816 if func.is_some() {
3817 unsafe { OUTPUT_CREATE_FILENAME_DEFAULT = func };
3818 }
3819 old
3820}
3821
3822#[no_mangle]
3825pub unsafe extern "C" fn __xmlOutputBufferCreateFilename() -> *mut Option<
3826 unsafe extern "C" fn(
3827 *const c_char,
3828 *mut crate::abi::structs::_xmlCharEncodingHandler,
3829 c_int,
3830 ) -> *mut _xmlOutputBuffer,
3831> {
3832 core::ptr::addr_of_mut!(OUTPUT_CREATE_FILENAME_DEFAULT)
3833}
3834
3835#[no_mangle]
3847pub extern "C" fn xmlDictCreate() -> *mut c_void {
3848 let d = { crate::xml::dictionary::dict_create() as *mut c_void };
3849 if !d.is_null() {
3850 *crate::abi::exports_hash::DICT_REFS
3854 .lock()
3855 .entry(d as usize)
3856 .or_insert(0) = 1;
3857 }
3858 d
3859}
3860
3861#[no_mangle]
3869pub extern "C" fn xmlDictCreateSub(sub: *mut c_void) -> *mut c_void {
3870 let d = unsafe {
3871 crate::xml::dictionary::dict_create_sub(sub as *mut crate::xml::dictionary::Dict)
3872 as *mut c_void
3873 };
3874 if !d.is_null() {
3875 *crate::abi::exports_hash::DICT_REFS
3876 .lock()
3877 .entry(d as usize)
3878 .or_insert(0) = 1;
3879 }
3880 d
3881}
3882
3883#[no_mangle]
3895pub unsafe extern "C" fn xmlDictLookup(
3896 dict: *mut c_void,
3897 name: *const xmlChar,
3898 len: c_int,
3899) -> *const xmlChar {
3900 unsafe {
3901 crate::xml::dictionary::dict_lookup(dict as *mut crate::xml::dictionary::Dict, name, len)
3902 }
3903}
3904
3905#[no_mangle]
3913pub unsafe extern "C" fn xmlDictExists(
3914 dict: *mut c_void,
3915 name: *const xmlChar,
3916 len: c_int,
3917) -> *const xmlChar {
3918 unsafe {
3919 crate::xml::dictionary::dict_exists(dict as *mut crate::xml::dictionary::Dict, name, len)
3920 }
3921}
3922
3923#[no_mangle]
3931pub const extern "C" fn xmlDictSize(dict: *const c_void) -> c_uint {
3932 {
3933 crate::xml::dictionary::dict_size(dict as *const crate::xml::dictionary::Dict) as c_uint
3934 }
3935}
3936
3937#[no_mangle]
3949pub extern "C" fn xmlDictFree(dict: *mut c_void) {
3950 if dict.is_null() {
3951 return;
3952 }
3953 let mut remaining = 0u32;
3954 {
3955 let mut refs = crate::abi::exports_hash::DICT_REFS.lock();
3956 if let Some(r) = refs.get_mut(&(dict as usize)) {
3957 if *r > 0 {
3958 *r -= 1;
3959 }
3960 remaining = *r;
3961 if remaining == 0 {
3962 refs.remove(&(dict as usize));
3963 }
3964 }
3965 }
3966 if remaining == 0 {
3967 unsafe { crate::xml::dictionary::dict_free(dict as *mut crate::xml::dictionary::Dict) };
3968 }
3969}
3970
3971#[no_mangle]
3979pub extern "C" fn xmlDictSetLimit(dict: *mut c_void, limit: c_uint) -> c_uint {
3980 {
3981 crate::xml::dictionary::dict_set_limit(
3982 dict as *mut crate::xml::dictionary::Dict,
3983 limit as usize,
3984 ) as c_uint
3985 }
3986}
3987
3988#[no_mangle]
3996pub extern "C" fn xmlDictGetUsage(dict: *const c_void) -> c_uint {
3997 {
3998 crate::xml::dictionary::dict_get_usage(dict as *mut crate::xml::dictionary::Dict) as c_uint
3999 }
4000}
4001
4002#[no_mangle]
4014pub extern "C" fn xmlHashCreate(size: c_int) -> *mut c_void {
4015 crate::xml::hash::hash_create(size) as *mut c_void
4016}
4017
4018#[no_mangle]
4026pub extern "C" fn xmlHashCreateDict(size: c_int, dict: *mut c_void) -> *mut c_void {
4027 crate::xml::hash::hash_create_dict(size, dict) as *mut c_void
4028}
4029
4030#[no_mangle]
4038pub extern "C" fn xmlHashFree(
4039 table: *mut c_void,
4040 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4041) {
4042 unsafe { crate::xml::hash::hash_free(table as *mut crate::xml::hash::HashTable, f) }
4043}
4044
4045#[no_mangle]
4053pub unsafe extern "C" fn xmlHashAddEntry(
4054 table: *mut c_void,
4055 name: *const xmlChar,
4056 userdata: *mut c_void,
4057) -> c_int {
4058 unsafe {
4059 crate::xml::hash::hash_add_entry(table as *mut crate::xml::hash::HashTable, name, userdata)
4060 }
4061}
4062
4063#[no_mangle]
4072pub unsafe extern "C" fn xmlHashAddEntry2(
4073 table: *mut c_void,
4074 name: *const xmlChar,
4075 name2: *const xmlChar,
4076 userdata: *mut c_void,
4077) -> c_int {
4078 unsafe {
4079 crate::xml::hash::hash_add_entry2(
4080 table as *mut crate::xml::hash::HashTable,
4081 name,
4082 name2,
4083 userdata,
4084 )
4085 }
4086}
4087
4088#[no_mangle]
4097pub unsafe extern "C" fn xmlHashAddEntry3(
4098 table: *mut c_void,
4099 name: *const xmlChar,
4100 name2: *const xmlChar,
4101 name3: *const xmlChar,
4102 userdata: *mut c_void,
4103) -> c_int {
4104 unsafe {
4105 crate::xml::hash::hash_add_entry3(
4106 table as *mut crate::xml::hash::HashTable,
4107 name,
4108 name2,
4109 name3,
4110 userdata,
4111 )
4112 }
4113}
4114
4115#[no_mangle]
4124pub unsafe extern "C" fn xmlHashUpdateEntry(
4125 table: *mut c_void,
4126 name: *const xmlChar,
4127 userdata: *mut c_void,
4128 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4129) -> c_int {
4130 unsafe {
4131 crate::xml::hash::hash_update_entry(
4132 table as *mut crate::xml::hash::HashTable,
4133 name,
4134 userdata,
4135 f,
4136 )
4137 }
4138}
4139
4140#[no_mangle]
4142pub unsafe extern "C" fn xmlHashUpdateEntry2(
4143 table: *mut c_void,
4144 name: *const xmlChar,
4145 name2: *const xmlChar,
4146 userdata: *mut c_void,
4147 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4148) -> c_int {
4149 unsafe {
4150 crate::xml::hash::hash_update_entry2(
4151 table as *mut crate::xml::hash::HashTable,
4152 name,
4153 name2,
4154 userdata,
4155 f,
4156 )
4157 }
4158}
4159
4160#[no_mangle]
4162pub unsafe extern "C" fn xmlHashUpdateEntry3(
4163 table: *mut c_void,
4164 name: *const xmlChar,
4165 name2: *const xmlChar,
4166 name3: *const xmlChar,
4167 userdata: *mut c_void,
4168 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4169) -> c_int {
4170 unsafe {
4171 crate::xml::hash::hash_update_entry3(
4172 table as *mut crate::xml::hash::HashTable,
4173 name,
4174 name2,
4175 name3,
4176 userdata,
4177 f,
4178 )
4179 }
4180}
4181
4182#[no_mangle]
4190pub unsafe extern "C" fn xmlHashLookup(table: *mut c_void, name: *const xmlChar) -> *mut c_void {
4191 unsafe { crate::xml::hash::hash_lookup(table as *mut crate::xml::hash::HashTable, name) }
4192}
4193
4194#[no_mangle]
4196pub unsafe extern "C" fn xmlHashLookup2(
4197 table: *mut c_void,
4198 name: *const xmlChar,
4199 name2: *const xmlChar,
4200) -> *mut c_void {
4201 unsafe {
4202 crate::xml::hash::hash_lookup2(table as *mut crate::xml::hash::HashTable, name, name2)
4203 }
4204}
4205
4206#[no_mangle]
4208pub unsafe extern "C" fn xmlHashLookup3(
4209 table: *mut c_void,
4210 name: *const xmlChar,
4211 name2: *const xmlChar,
4212 name3: *const xmlChar,
4213) -> *mut c_void {
4214 unsafe {
4215 crate::xml::hash::hash_lookup3(
4216 table as *mut crate::xml::hash::HashTable,
4217 name,
4218 name2,
4219 name3,
4220 )
4221 }
4222}
4223
4224#[no_mangle]
4232pub extern "C" fn xmlHashSize(table: *mut c_void) -> c_int {
4233 crate::xml::hash::hash_size(table as *mut crate::xml::hash::HashTable)
4234}
4235
4236#[no_mangle]
4245pub unsafe extern "C" fn xmlHashRemoveEntry(
4246 table: *mut c_void,
4247 name: *const xmlChar,
4248 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4249) -> c_int {
4250 unsafe {
4251 crate::xml::hash::hash_remove_entry(table as *mut crate::xml::hash::HashTable, name, f)
4252 }
4253}
4254
4255#[no_mangle]
4257pub unsafe extern "C" fn xmlHashRemoveEntry2(
4258 table: *mut c_void,
4259 name: *const xmlChar,
4260 name2: *const xmlChar,
4261 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4262) -> c_int {
4263 unsafe {
4264 crate::xml::hash::hash_remove_entry2(
4265 table as *mut crate::xml::hash::HashTable,
4266 name,
4267 name2,
4268 f,
4269 )
4270 }
4271}
4272
4273#[no_mangle]
4275pub unsafe extern "C" fn xmlHashRemoveEntry3(
4276 table: *mut c_void,
4277 name: *const xmlChar,
4278 name2: *const xmlChar,
4279 name3: *const xmlChar,
4280 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4281) -> c_int {
4282 unsafe {
4283 crate::xml::hash::hash_remove_entry3(
4284 table as *mut crate::xml::hash::HashTable,
4285 name,
4286 name2,
4287 name3,
4288 f,
4289 )
4290 }
4291}
4292
4293#[no_mangle]
4301pub extern "C" fn xmlHashScan(table: *mut c_void, f: Option<xmlHashScanner>, data: *mut c_void) {
4302 unsafe { crate::xml::hash::hash_scan(table as *mut crate::xml::hash::HashTable, f, data) }
4303}
4304
4305#[no_mangle]
4307pub extern "C" fn xmlHashScanFull(
4308 table: *mut c_void,
4309 f: Option<xmlHashScannerFull>,
4310 data: *mut c_void,
4311) {
4312 unsafe { crate::xml::hash::hash_scan_full(table as *mut crate::xml::hash::HashTable, f, data) }
4313}
4314
4315#[no_mangle]
4323pub extern "C" fn xmlHashCopy(
4324 table: *mut c_void,
4325 f: Option<unsafe extern "C" fn(*mut c_void, *const xmlChar) -> *mut c_void>,
4326) -> *mut c_void {
4327 unsafe {
4328 crate::xml::hash::hash_copy(table as *mut crate::xml::hash::HashTable, f) as *mut c_void
4329 }
4330}
4331
4332#[no_mangle]
4345pub extern "C" fn xmlListCreate(
4346 deallocator: Option<unsafe extern "C" fn(*mut c_void)>,
4347 compare: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
4348) -> *mut c_void {
4349 crate::xml::list::list_create(deallocator, compare) as *mut c_void
4350}
4351
4352#[no_mangle]
4360pub extern "C" fn xmlListDelete(list: *mut c_void) {
4361 unsafe { crate::xml::list::list_delete(list as *mut crate::xml::list::List) }
4362}
4363
4364#[no_mangle]
4372pub extern "C" fn xmlListSearch(list: *mut c_void, data: *mut c_void) -> *mut c_void {
4373 unsafe { crate::xml::list::list_search(list as *mut crate::xml::list::List, data) }
4374}
4375
4376#[no_mangle]
4384pub extern "C" fn xmlListWalk(
4385 list: *mut c_void,
4386 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4387 data: *mut c_void,
4388) {
4389 unsafe { crate::xml::list::list_walk(list as *mut crate::xml::list::List, walker, data) }
4390}
4391
4392#[no_mangle]
4400pub extern "C" fn xmlListPushBack(list: *mut c_void, data: *mut c_void) -> c_int {
4401 unsafe { crate::xml::list::list_push_back(list as *mut crate::xml::list::List, data) }
4402}
4403
4404#[no_mangle]
4412pub extern "C" fn xmlListPushFront(list: *mut c_void, data: *mut c_void) -> c_int {
4413 unsafe { crate::xml::list::list_push_front(list as *mut crate::xml::list::List, data) }
4414}
4415
4416#[no_mangle]
4418pub extern "C" fn xmlListPopBack(list: *mut c_void) {
4419 unsafe { crate::xml::list::list_pop_back(list as *mut crate::xml::list::List) }
4420}
4421
4422#[no_mangle]
4424pub extern "C" fn xmlListPopFront(list: *mut c_void) {
4425 unsafe { crate::xml::list::list_pop_front(list as *mut crate::xml::list::List) }
4426}
4427
4428#[no_mangle]
4436pub extern "C" fn xmlListInsert(list: *mut c_void, data: *mut c_void) -> c_int {
4437 unsafe { crate::xml::list::list_insert(list as *mut crate::xml::list::List, data) }
4438}
4439
4440#[no_mangle]
4442pub extern "C" fn xmlListAppend(list: *mut c_void, data: *mut c_void) -> c_int {
4443 unsafe { crate::xml::list::list_append(list as *mut crate::xml::list::List, data) }
4444}
4445
4446#[no_mangle]
4448pub extern "C" fn xmlListRemoveFirst(list: *mut c_void, data: *mut c_void) -> c_int {
4449 unsafe { crate::xml::list::list_remove_first(list as *mut crate::xml::list::List, data) }
4450}
4451
4452#[no_mangle]
4454pub extern "C" fn xmlListRemoveLast(list: *mut c_void, data: *mut c_void) -> c_int {
4455 unsafe { crate::xml::list::list_remove_last(list as *mut crate::xml::list::List, data) }
4456}
4457
4458#[no_mangle]
4460pub extern "C" fn xmlListRemoveAll(list: *mut c_void, data: *mut c_void) -> c_int {
4461 unsafe { crate::xml::list::list_remove_all(list as *mut crate::xml::list::List, data) }
4462}
4463
4464#[no_mangle]
4466pub extern "C" fn xmlListClear(list: *mut c_void) {
4467 unsafe { crate::xml::list::list_clear(list as *mut crate::xml::list::List) }
4468}
4469
4470#[no_mangle]
4478pub extern "C" fn xmlListEmpty(list: *mut c_void) -> c_int {
4479 crate::xml::list::list_empty(list as *mut crate::xml::list::List)
4480}
4481
4482#[no_mangle]
4490pub extern "C" fn xmlListFront(list: *mut c_void) -> *mut c_void {
4491 crate::xml::list::list_front(list as *mut crate::xml::list::List)
4492}
4493
4494#[no_mangle]
4502pub extern "C" fn xmlListBack(list: *mut c_void) -> *mut c_void {
4503 crate::xml::list::list_back(list as *mut crate::xml::list::List)
4504}
4505
4506#[no_mangle]
4514pub extern "C" fn xmlListSize(list: *mut c_void) -> c_int {
4515 crate::xml::list::list_size(list as *mut crate::xml::list::List)
4516}
4517
4518#[no_mangle]
4520pub extern "C" fn xmlListSort(list: *mut c_void) {
4521 unsafe { crate::xml::list::list_sort(list as *mut crate::xml::list::List) }
4522}
4523
4524#[no_mangle]
4526pub extern "C" fn xmlListReverse(list: *mut c_void) {
4527 unsafe { crate::xml::list::list_reverse(list as *mut crate::xml::list::List) }
4528}
4529
4530#[no_mangle]
4532pub extern "C" fn xmlListReverseSplice(list: *mut c_void, list2: *mut c_void) {
4533 unsafe {
4534 crate::xml::list::list_reverse_splice(
4535 list as *mut crate::xml::list::List,
4536 list2 as *mut crate::xml::list::List,
4537 )
4538 }
4539}
4540
4541#[no_mangle]
4543pub extern "C" fn xmlListMerge(list: *mut c_void, list2: *mut c_void) {
4544 unsafe {
4545 crate::xml::list::list_merge(
4546 list as *mut crate::xml::list::List,
4547 list2 as *mut crate::xml::list::List,
4548 )
4549 }
4550}
4551#[no_mangle]
4559pub unsafe extern "C" fn xmlListEnd(l: *mut c_void) -> *mut c_void {
4560 crate::xml::list::list_end(l as *mut crate::xml::list::List)
4561}
4562
4563#[no_mangle]
4571pub unsafe extern "C" fn xmlListReverseSearch(l: *mut c_void, data: *mut c_void) -> *mut c_void {
4572 crate::xml::list::list_reverse_search(l as *mut crate::xml::list::List, data)
4573}
4574
4575#[no_mangle]
4583pub unsafe extern "C" fn xmlListReverseWalk(
4584 l: *mut c_void,
4585 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4586 data: *mut c_void,
4587) {
4588 crate::xml::list::list_reverse_walk(l as *mut crate::xml::list::List, walker, data)
4589}
4590
4591#[no_mangle]
4599pub unsafe extern "C" fn xmlListDup(l: *mut c_void) -> *mut c_void {
4600 crate::xml::list::list_dup(l as *mut crate::xml::list::List) as *mut c_void
4601}
4602
4603#[no_mangle]
4611pub unsafe extern "C" fn xmlListCopy(
4612 l: *mut c_void,
4613 copier: Option<unsafe extern "C" fn(*mut c_void) -> *mut c_void>,
4614) -> c_int {
4615 crate::xml::list::list_copy(l as *mut crate::xml::list::List, copier)
4616}
4617
4618#[no_mangle]
4626pub unsafe extern "C" fn xmlLinkGetData(lk: *mut c_void) -> *mut c_void {
4627 crate::xml::list::link_get_data(lk)
4628}
4629
4630#[no_mangle]
4642pub extern "C" fn xmlBufferCreate() -> *mut _xmlBuffer {
4643 crate::xml::io::buf_create(-1)
4644}
4645
4646#[no_mangle]
4654pub extern "C" fn xmlBufferCreateSize(size: usize) -> *mut _xmlBuffer {
4655 crate::xml::io::buf_create(size as c_int)
4656}
4657
4658#[no_mangle]
4666pub extern "C" fn xmlBufferCreateStatic(mem: *mut c_void, size: usize) -> *mut _xmlBuffer {
4667 if mem.is_null() || size == 0 {
4668 return ptr::null_mut();
4669 }
4670 crate::xml::io::buf_create_static(mem as *const xmlChar, size as c_int)
4671}
4672
4673#[no_mangle]
4681pub extern "C" fn xmlBufferFree(buf: *mut _xmlBuffer) {
4682 crate::xml::io::buf_free(buf)
4683}
4684
4685#[no_mangle]
4693pub extern "C" fn xmlBufferEmpty(buf: *mut _xmlBuffer) {
4694 if buf.is_null() {
4695 return;
4696 }
4697 unsafe {
4698 if !(*buf).content.is_null() {
4699 *(*buf).content = 0;
4700 }
4701 (*buf).use_ = 0;
4702 }
4703}
4704
4705#[no_mangle]
4713pub extern "C" fn xmlBufferContent(buf: *const _xmlBuffer) -> *mut xmlChar {
4714 crate::xml::io::buf_content(buf as *mut _xmlBuffer)
4715}
4716
4717#[no_mangle]
4725pub extern "C" fn xmlBufferLength(buf: *const _xmlBuffer) -> c_int {
4726 crate::xml::io::buf_length(buf as *mut _xmlBuffer)
4727}
4728
4729#[no_mangle]
4737pub unsafe extern "C" fn xmlBufferAdd(
4738 buf: *mut _xmlBuffer,
4739 str: *const xmlChar,
4740 len: c_int,
4741) -> c_int {
4742 crate::xml::io::buf_add(buf, str, len)
4743}
4744
4745#[no_mangle]
4753pub unsafe extern "C" fn xmlBufferAddHead(
4754 buf: *mut _xmlBuffer,
4755 str: *const xmlChar,
4756 len: c_int,
4757) -> c_int {
4758 crate::xml::io::buf_add_head(buf, str, len)
4759}
4760
4761#[no_mangle]
4769pub unsafe extern "C" fn xmlBufferCat(buf: *mut _xmlBuffer, str: *const xmlChar) -> c_int {
4770 if str.is_null() {
4771 return -1;
4772 }
4773 let len = crate::xml::string::xml_strlen(str) as c_int;
4774 crate::xml::io::buf_add(buf, str, len)
4775}
4776
4777#[no_mangle]
4786pub extern "C" fn xmlBufferSetAllocationScheme(buf: *mut _xmlBuffer, scheme: c_int) {
4787 if buf.is_null() {
4788 return;
4789 }
4790 unsafe {
4791 (*buf).alloc = scheme;
4792 }
4793}
4794
4795#[no_mangle]
4803pub extern "C" fn xmlBufferShrink(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4804 if buf.is_null() || len <= 0 {
4805 return 0;
4806 }
4807 unsafe {
4808 let b = &mut *buf;
4809 let shrink_len = (len as c_uint).min(b.use_);
4810 if shrink_len > 0 {
4811 let remaining = b.use_ - shrink_len;
4812 if remaining > 0 {
4813 core::ptr::copy(
4814 b.content.add(shrink_len as usize),
4815 b.content,
4816 remaining as usize,
4817 );
4818 }
4819 *b.content.add(remaining as usize) = 0;
4820 b.use_ = remaining;
4821 }
4822 }
4823 len
4824}
4825
4826#[no_mangle]
4834pub extern "C" fn xmlBufferGrow(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4835 if buf.is_null() || len <= 0 {
4836 return 0;
4837 }
4838 let cur_use = unsafe { (*buf).use_ };
4839 let new_size = cur_use + len as c_uint + 1;
4840 crate::xml::io::buf_grow(buf, new_size)
4841}
4842
4843#[no_mangle]
4851pub extern "C" fn xmlBufferReserve(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4852 xmlBufferGrow(buf, len)
4853}
4854
4855#[no_mangle]
4863pub extern "C" fn xmlBufferDetach(buf: *mut _xmlBuffer) -> *mut xmlChar {
4864 if buf.is_null() {
4865 return ptr::null_mut();
4866 }
4867 unsafe {
4868 let content = (*buf).content;
4869 (*buf).content = ptr::null_mut();
4870 (*buf).use_ = 0;
4871 (*buf).size = 0;
4872 content
4873 }
4874}
4875
4876#[no_mangle]
4888pub extern "C" fn xmlGetCharEncoding(name: *const c_char) -> c_int {
4889 if name.is_null() {
4890 return 0; }
4892 let name_bytes = unsafe {
4893 let len = libc::strlen(name);
4894 core::slice::from_raw_parts(name as *const u8, len)
4895 };
4896 crate::xml::encoding::encoding_from_name(name_bytes) as c_int
4897}
4898
4899#[no_mangle]
4907pub extern "C" fn xmlFindCharEncodingHandler(name: *const c_char) -> *mut c_void {
4908 if name.is_null() {
4909 return ptr::null_mut();
4910 }
4911 crate::xml::encoding::find_encoding_handler(name as *const xmlChar) as *mut c_void
4912}
4913
4914#[no_mangle]
4922pub extern "C" fn xmlCharEncCloseFunc(handler: *mut c_void) -> c_int {
4923 if handler.is_null() {
4924 return -1;
4925 }
4926 unsafe {
4928 let h = handler as *mut crate::abi::structs::_xmlCharEncodingHandler;
4929 if !(*h).name.is_null() {
4930 crate::abi::allocator::xmlFreeImpl((*h).name as *mut c_void);
4931 }
4932 crate::abi::allocator::xmlFreeImpl(handler);
4933 }
4934 0
4935}
4936
4937#[no_mangle]
4947pub unsafe extern "C" fn xmlIsolat1ToUTF8(
4948 out: *mut u8,
4949 outlen: *mut c_int,
4950 input: *const u8,
4951 inlen: *mut c_int,
4952) -> c_int {
4953 const XML_ENC_ERR_SPACE: c_int = -2;
4955 const XML_ENC_ERR_INTERNAL: c_int = -1;
4956 unsafe {
4957 if out.is_null() || input.is_null() || outlen.is_null() || inlen.is_null() {
4958 return XML_ENC_ERR_INTERNAL;
4959 }
4960 let outstart = out;
4961 let instart = input;
4962 let outend = out.add(*outlen as usize);
4963 let inend = input.add(*inlen as usize);
4964 let mut cur = input;
4965 let mut o = out;
4966 while cur < inend {
4967 let c = *cur;
4968 if c < 0x80 {
4969 if o >= outend {
4970 break;
4971 }
4972 *o = c;
4973 o = o.add(1);
4974 } else {
4975 if (outend as usize) - (o as usize) < 2 {
4976 break;
4977 }
4978 *o = (c >> 6) | 0xC0;
4979 *o.add(1) = (c & 0x3F) | 0x80;
4980 o = o.add(2);
4981 }
4982 cur = cur.add(1);
4983 }
4984 let mut ret = XML_ENC_ERR_SPACE;
4985 if cur == inend {
4986 ret = (o as usize - outstart as usize) as c_int;
4987 }
4988 *outlen = (o as usize - outstart as usize) as c_int;
4989 *inlen = (cur as usize - instart as usize) as c_int;
4990 ret
4991 }
4992}
4993
4994#[no_mangle]
5001pub unsafe extern "C" fn xmlUTF8ToIsolat1(
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;
5008 const XML_ENC_ERR_INTERNAL: c_int = -1;
5009 const XML_ENC_ERR_INPUT: c_int = -3;
5010 const XML_ENC_ERR_SUCCESS: c_int = 0;
5011 unsafe {
5012 if out.is_null() || outlen.is_null() || inlen.is_null() {
5013 return XML_ENC_ERR_INTERNAL;
5014 }
5015 if input.is_null() {
5016 *inlen = 0;
5017 *outlen = 0;
5018 return XML_ENC_ERR_SUCCESS;
5019 }
5020 let outstart = out;
5021 let instart = input;
5022 let outend = out.add(*outlen as usize);
5023 let inend = input.add(*inlen as usize);
5024 let mut cur = input;
5025 let mut o = out;
5026 let mut ret = XML_ENC_ERR_SPACE;
5027 while cur < inend {
5028 if o >= outend {
5029 break;
5030 }
5031 let c = *cur;
5032 if c < 0x80 {
5033 *o = c;
5034 o = o.add(1);
5035 } else if (0xC2..=0xC3).contains(&c) {
5036 if (inend as usize) - (cur as usize) < 2 {
5037 break;
5038 }
5039 cur = cur.add(1);
5040 *o = (c << 6) | (*cur & 0x3F);
5041 o = o.add(1);
5042 } else {
5043 ret = XML_ENC_ERR_INPUT;
5044 break;
5045 }
5046 cur = cur.add(1);
5047 }
5048 if ret != XML_ENC_ERR_INPUT {
5049 ret = (o as usize - outstart as usize) as c_int;
5050 }
5051 *outlen = (o as usize - outstart as usize) as c_int;
5052 *inlen = (cur as usize - instart as usize) as c_int;
5053 ret
5054 }
5055}
5056
5057#[no_mangle]
5065pub extern "C" fn xmlGetCharEncodingName(enc: c_int) -> *const c_char {
5066 if !(-1..=22).contains(&enc) {
5070 return match enc {
5071 23 => c"UTF-16".as_ptr(),
5072 24 => c"HTML".as_ptr(),
5073 31 => c"windows-1252".as_ptr(),
5074 _ => ptr::null(),
5075 };
5076 }
5077 let e: crate::abi::types::xmlCharEncoding = unsafe { core::mem::transmute(enc) };
5078 crate::xml::encoding::xmlGetCharEncodingName(e)
5079}
5080
5081#[no_mangle]
5091pub extern "C" fn xmlParseCharEncoding(name: *const c_char) -> c_int {
5092 crate::xml::encoding::xmlParseCharEncoding(name)
5093}
5094
5095#[no_mangle]
5103pub extern "C" fn xmlAddEncodingAlias(name: *const c_char, alias: *const c_char) -> c_int {
5104 crate::xml::encoding::add_encoding_alias(name, alias)
5105}
5106
5107#[no_mangle]
5115pub extern "C" fn xmlDelEncodingAlias(alias: *const c_char) -> c_int {
5116 crate::xml::encoding::del_encoding_alias(alias)
5117}
5118
5119#[no_mangle]
5127pub extern "C" fn xmlGetEncodingAlias(alias: *const c_char) -> *const c_char {
5128 crate::xml::encoding::get_encoding_alias(alias)
5129}
5130
5131#[no_mangle]
5139pub extern "C" fn xmlCleanupEncodingAliases() {
5140 crate::xml::encoding::cleanup_encoding_aliases();
5141}
5142
5143#[no_mangle]
5152pub extern "C" fn xmlCharEncInFunc(
5153 handler: *mut c_void,
5154 out: *mut c_void,
5155 in_: *mut c_void,
5156) -> c_int {
5157 crate::xml::encoding::xmlCharEncInFunc(
5158 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
5159 out as *mut crate::abi::structs::_xmlBuffer,
5160 in_ as *mut crate::abi::structs::_xmlBuffer,
5161 )
5162}
5163
5164#[no_mangle]
5173pub extern "C" fn xmlCharEncOutFunc(
5174 handler: *mut c_void,
5175 out: *mut c_void,
5176 in_: *mut c_void,
5177) -> c_int {
5178 crate::xml::encoding::xmlCharEncOutFunc(
5179 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
5180 out as *mut crate::abi::structs::_xmlBuffer,
5181 in_ as *mut crate::abi::structs::_xmlBuffer,
5182 )
5183}
5184
5185#[no_mangle]
5195pub extern "C" fn xmlNewCharEncodingHandler(
5196 name: *const c_char,
5197 input: crate::abi::callbacks::xmlCharEncodingInputFunc,
5198 output: crate::abi::callbacks::xmlCharEncodingOutputFunc,
5199) -> *mut c_void {
5200 crate::xml::encoding::xmlNewCharEncodingHandler(name, input, output) as *mut c_void
5201}
5202
5203#[no_mangle]
5211pub extern "C" fn xmlInitCharEncodingHandlers() {
5212 crate::xml::encoding::xmlInitCharEncodingHandlers();
5213}
5214
5215#[no_mangle]
5223pub extern "C" fn xmlCleanupCharEncodingHandlers() {
5224 crate::xml::encoding::xmlCleanupCharEncodingHandlers();
5225}
5226
5227#[no_mangle]
5239pub extern "C" fn xmlLookupCharEncodingHandler(enc: c_int, out: *mut *mut c_void) -> c_int {
5240 crate::xml::encoding::xmlLookupCharEncodingHandler(enc, out)
5241}
5242
5243#[no_mangle]
5251pub extern "C" fn xmlGetCharEncodingHandler(enc: c_int) -> *mut c_void {
5252 crate::xml::encoding::xmlGetCharEncodingHandler(enc)
5253}
5254
5255#[no_mangle]
5264pub extern "C" fn xmlOpenCharEncodingHandler(
5265 name: *const c_char,
5266 output: c_int,
5267 out: *mut *mut c_void,
5268) -> c_int {
5269 crate::xml::encoding::xmlOpenCharEncodingHandler(name, output, out)
5270}
5271
5272#[no_mangle]
5283pub extern "C" fn xmlCreateCharEncodingHandler(
5284 name: *const c_char,
5285 flags: c_int,
5286 impl_: Option<crate::abi::callbacks::xmlCharEncConvImpl>,
5287 implCtxt: *mut c_void,
5288 out: *mut *mut c_void,
5289) -> c_int {
5290 crate::xml::encoding::xmlCreateCharEncodingHandler(name, flags, impl_, implCtxt, out)
5291}
5292
5293#[no_mangle]
5304pub extern "C" fn xmlCharEncNewCustomHandler(
5305 name: *const c_char,
5306 input: crate::abi::callbacks::xmlCharEncConvFunc,
5307 output: crate::abi::callbacks::xmlCharEncConvFunc,
5308 ctxtDtor: Option<crate::abi::callbacks::xmlCharEncConvCtxtDtor>,
5309 inputCtxt: *mut c_void,
5310 outputCtxt: *mut c_void,
5311 out: *mut *mut c_void,
5312) -> c_int {
5313 crate::xml::encoding::xmlCharEncNewCustomHandler(
5314 name, input, output, ctxtDtor, inputCtxt, outputCtxt, out,
5315 )
5316}
5317
5318#[no_mangle]
5326pub unsafe extern "C" fn xmlCharEncInput(input: *mut _xmlParserInputBuffer, _to: c_int) -> c_int {
5327 if input.is_null() {
5328 return -1;
5329 }
5330 let handler = (*input).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5331 if handler.is_null() {
5332 return -1;
5333 }
5334 let raw = (*input).raw as *mut crate::abi::structs::_xmlBuffer;
5335 let buf = (*input).buffer as *mut crate::abi::structs::_xmlBuffer;
5336 if raw.is_null() || buf.is_null() {
5337 return -1;
5338 }
5339 crate::xml::encoding::char_enc_in(handler, buf, raw)
5340}
5341
5342#[no_mangle]
5350pub unsafe extern "C" fn xmlCharEncOutput(output: *mut _xmlOutputBuffer, _to: c_int) -> c_int {
5351 if output.is_null() {
5352 return -1;
5353 }
5354 let handler = (*output).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5355 if handler.is_null() {
5356 return -1;
5357 }
5358 let buf = (*output).buffer as *mut crate::abi::structs::_xmlBuffer;
5359 let conv = (*output).conv as *mut crate::abi::structs::_xmlBuffer;
5360 if buf.is_null() || conv.is_null() {
5361 return -1;
5362 }
5363 crate::xml::encoding::char_enc_out(handler, conv, buf)
5364}
5365
5366#[no_mangle]
5378pub unsafe extern "C" fn xmlParseURI(str: *const c_char) -> *mut c_void {
5379 crate::xml::uri::xmlParseURI(str)
5380}
5381
5382#[no_mangle]
5390pub unsafe extern "C" fn xmlParseURIRaw(str: *const c_char, raw: c_int) -> *mut c_void {
5391 let _ = raw;
5392 crate::xml::uri::xmlParseURI(str)
5393}
5394
5395#[no_mangle]
5403pub unsafe extern "C" fn xmlFreeURI(uri: *mut c_void) {
5404 crate::xml::uri::xmlFreeURI(uri)
5405}
5406
5407#[no_mangle]
5415pub extern "C" fn xmlCreateURI() -> *mut c_void {
5416 crate::xml::uri::xmlCreateURI()
5417}
5418
5419#[no_mangle]
5427pub unsafe extern "C" fn xmlSaveUri(uri: *mut c_void) -> *mut xmlChar {
5428 crate::xml::uri::xmlSaveUri(uri)
5429}
5430
5431#[no_mangle]
5447pub unsafe extern "C" fn xmlParseURIReference(uri: *mut c_void, str: *const c_char) -> c_int {
5448 crate::xml::uri::xmlParseURIReference(uri, str)
5449}
5450
5451#[no_mangle]
5466pub unsafe extern "C" fn xmlNormalizeURIPath(path: *mut c_char) -> c_int {
5467 crate::xml::uri::xmlNormalizeURIPath(path)
5468}
5469
5470#[no_mangle]
5478pub unsafe extern "C" fn xmlURIEscapeStr(
5479 str: *const xmlChar,
5480 list: *const xmlChar,
5481) -> *mut xmlChar {
5482 crate::xml::uri::xmlURIEscapeStr(str, list)
5483}
5484
5485#[no_mangle]
5493pub unsafe extern "C" fn xmlURIUnescapeString(
5494 str: *const c_char,
5495 len: c_int,
5496 target: *mut c_char,
5497) -> *mut c_char {
5498 crate::xml::uri::xmlURIUnescapeString(str, len, target)
5499}
5500
5501unsafe fn xpath_to_object(val: XPathValue) -> *mut _xmlXPathObject {
5516 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
5517 if obj.is_null() {
5518 return ptr::null_mut();
5519 }
5520 match val {
5521 XPathValue::NodeSet(ns) => {
5522 (*obj).type_ = xmlXPathObjectType::XPATH_NODESET as c_int;
5523 (*obj).nodesetval = ns.to_raw() as *mut c_void;
5524 }
5525 XPathValue::Boolean(b) => {
5526 (*obj).type_ = xmlXPathObjectType::XPATH_BOOLEAN as c_int;
5527 (*obj).boolval = if b { 1 } else { 0 };
5528 }
5529 XPathValue::Number(n) => {
5530 (*obj).type_ = xmlXPathObjectType::XPATH_NUMBER as c_int;
5531 (*obj).floatval = n;
5532 }
5533 XPathValue::String(s) => {
5534 (*obj).type_ = xmlXPathObjectType::XPATH_STRING as c_int;
5535 let bytes = s.as_bytes();
5536 let len = bytes.len();
5537 let buf = xmlMallocImpl(len + 1) as *mut xmlChar;
5538 if !buf.is_null() {
5539 ptr::copy_nonoverlapping(bytes.as_ptr(), buf, len);
5540 *buf.add(len) = 0; }
5542 (*obj).stringval = buf;
5543 }
5544 }
5545 obj
5546}
5547
5548unsafe fn object_to_xpathvalue(obj: *mut _xmlXPathObject) -> XPathValue {
5555 let typ = (*obj).type_;
5556 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5557 let ns_ptr = (*obj).nodesetval as *mut _xmlNodeSet;
5558 if ns_ptr.is_null() {
5559 return XPathValue::NodeSet(NodeSet::new());
5560 }
5561 let node_nr = (*ns_ptr).nodeNr;
5562 let node_tab = (*ns_ptr).nodeTab;
5563 let mut ns = NodeSet::new();
5564 if !node_tab.is_null() {
5565 for i in 0..node_nr as isize {
5566 let node = *node_tab.add(i as usize);
5567 ns.push(node);
5568 }
5569 }
5570 XPathValue::NodeSet(ns)
5571 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5572 XPathValue::Boolean((*obj).boolval != 0)
5573 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5574 XPathValue::Number((*obj).floatval)
5575 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5576 let s_ptr = (*obj).stringval;
5577 if s_ptr.is_null() {
5578 XPathValue::String(String::new())
5579 } else {
5580 let s = CStr::from_ptr(s_ptr as *const c_char)
5581 .to_string_lossy()
5582 .into_owned();
5583 XPathValue::String(s)
5584 }
5585 } else if typ == xmlXPathObjectType::XPATH_XSLT_TREE as c_int {
5586 let frag_doc = (*obj).nodesetval as *mut _xmlDoc;
5591 if frag_doc.is_null() {
5592 XPathValue::NodeSet(NodeSet::new())
5593 } else {
5594 let mut ns = NodeSet::new();
5595 ns.push(frag_doc as *mut _xmlNode);
5596 XPathValue::NodeSet(ns)
5597 }
5598 } else {
5599 XPathValue::Boolean(false)
5601 }
5602}
5603
5604pub unsafe fn xpath_to_object_pub(val: XPathValue) -> *mut _xmlXPathObject {
5610 xpath_to_object(val)
5611}
5612
5613pub unsafe fn object_to_xpathvalue_pub(obj: *mut _xmlXPathObject) -> XPathValue {
5620 object_to_xpathvalue(obj)
5621}
5622
5623static COMPILED_EXPRS: Lazy<Mutex<HashMap<u64, Box<CompiledExpr>>>> =
5629 Lazy::new(|| Mutex::new(HashMap::new()));
5630static NEXT_COMPILED_KEY: Lazy<Mutex<u64>> = Lazy::new(|| Mutex::new(1));
5631
5632pub(crate) fn xpath_compiled_registry() -> &'static Mutex<HashMap<u64, Box<CompiledExpr>>> {
5635 &COMPILED_EXPRS
5636}
5637
5638type CXPathFunc = unsafe extern "C" fn(*mut c_void, c_int);
5648
5649#[derive(Clone, Copy, PartialEq, Eq, Hash)]
5652struct SendSyncPtr(*mut c_void);
5653unsafe impl Send for SendSyncPtr {}
5654unsafe impl Sync for SendSyncPtr {}
5655
5656static C_FUNCTIONS: Lazy<Mutex<HashMap<(SendSyncPtr, String), CXPathFunc>>> =
5657 Lazy::new(|| Mutex::new(HashMap::new()));
5658
5659pub(crate) fn xpath_cfunc_lookup(extra: *mut c_void, qualified: &str) -> Option<CXPathFunc> {
5663 C_FUNCTIONS
5664 .lock()
5665 .get(&(SendSyncPtr(extra), qualified.to_string()))
5666 .copied()
5667}
5668
5669pub(crate) fn xpath_cfunc_cleanup(extra: *mut c_void) {
5672 C_FUNCTIONS.lock().retain(|(k, _), _| k.0 != extra);
5673}
5674
5675fn c_func_bridge_closure(c_ctxt: SendSyncPtr, qualified: String) -> BoxedXPathFunction {
5680 Box::new(move |_ctx: &mut XPathContext, args: &[XPathValue]| {
5681 let cc = c_ctxt;
5682 unsafe { c_func_call_bridge(cc.0 as *mut _xmlXPathContext, &qualified, args) }
5683 })
5684}
5685
5686pub(crate) unsafe fn call_c_xpath_function(
5696 fnptr: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
5697 c_ctxt: *mut _xmlXPathContext,
5698 args: &[XPathValue],
5699) -> Result<XPathValue, String> {
5700 let func = match fnptr {
5701 Some(f) => f,
5702 None => return Err("XPath: missing C function pointer".to_string()),
5703 };
5704 let pc = crate::xml::xpath::parser_context::new_parser_context(ptr::null(), c_ctxt);
5705 if pc.is_null() {
5706 return Err("XPath: parser-context allocation failure".to_string());
5707 }
5708 let mut push_ok = true;
5709 for v in args {
5710 let obj = xpath_to_object(v.clone());
5711 if obj.is_null() || crate::xml::xpath::parser_context::value_push(pc, obj).is_null() {
5712 push_ok = false;
5713 break;
5714 }
5715 }
5716 let result = if push_ok {
5717 unsafe { func(pc as *mut c_void, args.len() as c_int) };
5720 let ret = crate::xml::xpath::parser_context::value_pop(pc);
5721 if ret.is_null() {
5722 Err("XPath: C function returned no value".to_string())
5723 } else {
5724 let v = object_to_xpathvalue(ret);
5725 unsafe { xmlXPathFreeObject(ret) };
5727 Ok(v)
5728 }
5729 } else {
5730 Err("XPath: failed to push arguments to C function".to_string())
5731 };
5732 unsafe {
5734 loop {
5735 let leftover = crate::xml::xpath::parser_context::value_pop(pc);
5736 if leftover.is_null() {
5737 break;
5738 }
5739 xmlXPathFreeObject(leftover);
5740 }
5741 crate::xml::xpath::parser_context::free_parser_context(pc);
5742 }
5743 result
5744}
5745
5746unsafe fn c_func_call_bridge(
5753 c_ctxt: *mut _xmlXPathContext,
5754 qualified: &str,
5755 args: &[XPathValue],
5756) -> Result<XPathValue, String> {
5757 if c_ctxt.is_null() {
5758 return Err("XPath: null context in C function bridge".to_string());
5759 }
5760 let func = xpath_cfunc_lookup((*c_ctxt).extra, qualified);
5761 if func.is_none() {
5762 return Err(format!("XPath: unknown C function '{}'", qualified));
5763 }
5764 unsafe { call_c_xpath_function(func, c_ctxt, args) }
5765}
5766
5767#[no_mangle]
5780pub unsafe extern "C" fn xmlXPathNewContext(doc: *mut _xmlDoc) -> *mut _xmlXPathContext {
5781 let ctxt = xmlMallocZero(size_of::<_xmlXPathContext>()) as *mut _xmlXPathContext;
5782 if ctxt.is_null() {
5783 return ptr::null_mut();
5784 }
5785
5786 (*ctxt).doc = doc;
5788 (*ctxt).node = ptr::null_mut();
5789 (*ctxt).contextSize = 1;
5790 (*ctxt).proximityPosition = 1;
5791
5792 let mut internal = Box::new(XPathContext::new(doc));
5794 for (name, func) in crate::xml::xpath::functions::core_functions() {
5799 internal.register_function(&name, func);
5800 }
5801 (*ctxt).extra = Box::into_raw(internal) as *mut c_void;
5802
5803 ctxt
5804}
5805
5806#[no_mangle]
5814pub unsafe extern "C" fn xmlXPathFreeContext(ctxt: *mut _xmlXPathContext) {
5815 if ctxt.is_null() {
5816 return;
5817 }
5818 if !(*ctxt).extra.is_null() {
5820 let _ = Box::from_raw((*ctxt).extra as *mut XPathContext);
5821 (*ctxt).extra = ptr::null_mut();
5822 }
5823 if !(*ctxt).nsHash.is_null() {
5825 drop(Box::from_raw(
5826 (*ctxt).nsHash as *mut HashMap<String, CString>,
5827 ));
5828 (*ctxt).nsHash = ptr::null_mut();
5829 }
5830 xmlFreeImpl(ctxt as *mut c_void);
5832}
5833
5834#[no_mangle]
5843pub unsafe extern "C" fn xmlXPathEvalExpression(
5844 str_: *const xmlChar,
5845 ctxt: *mut _xmlXPathContext,
5846) -> *mut _xmlXPathObject {
5847 if str_.is_null() || ctxt.is_null() {
5848 return ptr::null_mut();
5849 }
5850 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
5851 Ok(s) => s,
5852 Err(_) => return ptr::null_mut(),
5853 };
5854 let internal = (*ctxt).extra as *mut XPathContext;
5855 if internal.is_null() {
5856 return ptr::null_mut();
5857 }
5858 let internal = &mut *internal;
5859 internal.clear_error();
5862
5863 match crate::xml::xpath::evaluate_str(expr_str, internal) {
5864 Some(val) => xpath_to_object(val),
5865 None => {
5866 if internal.error.is_none() {
5871 internal.set_error("Invalid expression");
5872 }
5873 ptr::null_mut()
5874 }
5875 }
5876}
5877
5878#[no_mangle]
5886pub unsafe extern "C" fn xmlXPathEval(
5887 str_: *const xmlChar,
5888 ctxt: *mut _xmlXPathContext,
5889) -> *mut _xmlXPathObject {
5890 xmlXPathEvalExpression(str_, ctxt)
5891}
5892
5893#[no_mangle]
5904pub unsafe extern "C" fn xmlXPathFreeObject(obj: *mut _xmlXPathObject) {
5905 if obj.is_null() {
5906 return;
5907 }
5908 let typ = (*obj).type_;
5909 if typ == xmlXPathObjectType::XPATH_STRING as c_int && !(*obj).stringval.is_null() {
5911 xmlFreeImpl((*obj).stringval as *mut c_void);
5912 (*obj).stringval = ptr::null_mut();
5913 }
5914 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5916 let ns = (*obj).nodesetval as *mut _xmlNodeSet;
5917 if !ns.is_null() {
5918 if !(*ns).nodeTab.is_null() {
5919 xmlFreeImpl((*ns).nodeTab as *mut c_void);
5920 }
5921 xmlFreeImpl(ns as *mut c_void);
5922 }
5923 (*obj).nodesetval = ptr::null_mut();
5924 }
5925 xmlFreeImpl(obj as *mut c_void);
5926}
5927
5928#[no_mangle]
5940pub unsafe extern "C" fn xmlXPathObjectCopy(val: *mut _xmlXPathObject) -> *mut _xmlXPathObject {
5941 if val.is_null() {
5942 return ptr::null_mut();
5943 }
5944 let typ = (*val).type_;
5945 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
5946 if obj.is_null() {
5947 return ptr::null_mut();
5948 }
5949 (*obj).type_ = typ;
5950 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5951 let src_ns = (*val).nodesetval as *mut _xmlNodeSet;
5952 if !src_ns.is_null() {
5953 let nr = (*src_ns).nodeNr;
5954 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
5955 if ns.is_null() {
5956 xmlFreeImpl(obj as *mut c_void);
5957 return ptr::null_mut();
5958 }
5959 (*ns).nodeNr = nr;
5960 (*ns).nodeMax = nr;
5961 if nr > 0 && !(*src_ns).nodeTab.is_null() {
5962 let tab = xmlMallocImpl((nr as usize) * core::mem::size_of::<*mut _xmlNode>())
5963 as *mut *mut _xmlNode;
5964 if tab.is_null() {
5965 xmlFreeImpl(ns as *mut c_void);
5966 xmlFreeImpl(obj as *mut c_void);
5967 return ptr::null_mut();
5968 }
5969 ptr::copy_nonoverlapping((*src_ns).nodeTab, tab, nr as usize);
5970 (*ns).nodeTab = tab;
5971 } else {
5972 (*ns).nodeTab = ptr::null_mut();
5973 }
5974 (*obj).nodesetval = ns as *mut c_void;
5975 }
5976 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5977 (*obj).boolval = (*val).boolval;
5978 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5979 (*obj).floatval = (*val).floatval;
5980 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5981 let src = (*val).stringval;
5982 if !src.is_null() {
5983 let len = libc::strlen(src as *const libc::c_char);
5984 let buf = xmlMallocImpl(len + 1) as *mut xmlChar;
5985 if !buf.is_null() {
5986 ptr::copy_nonoverlapping(src, buf, len);
5987 *buf.add(len) = 0;
5988 }
5989 (*obj).stringval = buf;
5990 }
5991 }
5992 obj
5993}
5994
5995#[no_mangle]
6005pub unsafe extern "C" fn xmlXPathCastToString(val: *mut _xmlXPathObject) -> *mut xmlChar {
6006 if val.is_null() {
6007 return ptr::null_mut();
6008 }
6009 let typ = (*val).type_;
6010 let mut result: Vec<u8> = Vec::new();
6011 if typ == xmlXPathObjectType::XPATH_STRING as c_int {
6012 if !(*val).stringval.is_null() {
6013 let len = libc::strlen((*val).stringval as *const libc::c_char);
6014 result.extend_from_slice(core::slice::from_raw_parts((*val).stringval, len));
6015 }
6016 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
6017 let n = (*val).floatval;
6023 result.extend_from_slice(xml_number_to_string(n).as_bytes());
6024 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
6025 result.extend_from_slice(if (*val).boolval != 0 {
6026 b"true"
6027 } else {
6028 b"false"
6029 });
6030 } else if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
6031 let ns = (*val).nodesetval as *mut _xmlNodeSet;
6034 if !ns.is_null() && (*ns).nodeNr > 0 && !(*ns).nodeTab.is_null() {
6035 let node = *(*ns).nodeTab;
6036 if !node.is_null() {
6037 let content = crate::xml::tree::node_get_content(node);
6038 if !content.is_null() {
6039 let len = libc::strlen(content as *const libc::c_char);
6040 result.extend_from_slice(core::slice::from_raw_parts(content, len));
6041 xmlFreeImpl(content as *mut c_void);
6042 }
6043 }
6044 }
6045 }
6046 let buf = xmlMallocImpl(result.len() + 1) as *mut xmlChar;
6048 if buf.is_null() {
6049 return ptr::null_mut();
6050 }
6051 if !result.is_empty() {
6052 ptr::copy_nonoverlapping(result.as_ptr(), buf, result.len());
6053 }
6054 *buf.add(result.len()) = 0;
6055 buf
6056}
6057
6058pub fn xml_number_to_string(n: f64) -> String {
6065 crate::xml::xpath::types::number_to_string(n)
6066}
6067
6068fn xpath_string_eval_number(bytes: &[u8]) -> f64 {
6076 crate::xml::xpath::types::string_bytes_to_number(bytes)
6077}
6078
6079#[no_mangle]
6087pub unsafe extern "C" fn xmlXPathCastStringToNumber(val: *const xmlChar) -> f64 {
6088 if val.is_null() {
6089 return f64::NAN;
6090 }
6091 let len = libc::strlen(val as *const libc::c_char);
6092 let bytes = core::slice::from_raw_parts(val, len);
6093 xpath_string_eval_number(bytes)
6094}
6095
6096#[no_mangle]
6110pub unsafe extern "C" fn xmlXPathCmpNodes(node1: *mut _xmlNode, node2: *mut _xmlNode) -> c_int {
6111 if node1.is_null() || node2.is_null() {
6112 return -2;
6113 }
6114 if node1 == node2 {
6115 return 0;
6116 }
6117 let mut chain1: Vec<*mut _xmlNode> = Vec::new();
6119 let mut chain2: Vec<*mut _xmlNode> = Vec::new();
6120 let mut n = node1;
6121 while !n.is_null() {
6122 chain1.push(n);
6123 n = (*n).parent;
6124 }
6125 let mut n = node2;
6126 while !n.is_null() {
6127 chain2.push(n);
6128 n = (*n).parent;
6129 }
6130 if chain1[chain1.len() - 1] != chain2[chain2.len() - 1] {
6132 return -2;
6133 }
6134 let mut i = chain1.len();
6136 let mut j = chain2.len();
6137 while i > 0 && j > 0 && chain1[i - 1] == chain2[j - 1] {
6138 i -= 1;
6139 j -= 1;
6140 }
6141 if i == 0 {
6143 return 1;
6144 }
6145 if j == 0 {
6147 return -1;
6148 }
6149 let mut a = chain1[i - 1];
6151 let mut b = chain2[j - 1];
6152 while !a.is_null() && !b.is_null() {
6154 let pa = (*a).parent;
6155 let pb = (*b).parent;
6156 if pa == pb {
6157 break;
6158 }
6159 a = pa;
6160 b = pb;
6161 }
6162 let parent = (*a).parent;
6164 let mut child = if parent.is_null() {
6165 ptr::null_mut()
6166 } else {
6167 (*parent).children
6168 };
6169 while !child.is_null() {
6170 if child == a {
6171 return 1; }
6173 if child == b {
6174 return -1; }
6176 child = (*child).next;
6177 }
6178 0
6179}
6180
6181#[no_mangle]
6191pub unsafe extern "C" fn xmlXPathNodeSetCreate(val: *mut _xmlNode) -> *mut _xmlNodeSet {
6192 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
6193 if ns.is_null() {
6194 return ptr::null_mut();
6195 }
6196 if val.is_null() {
6197 return ns;
6198 }
6199 let tab = xmlMallocImpl(core::mem::size_of::<*mut _xmlNode>()) as *mut *mut _xmlNode;
6200 if tab.is_null() {
6201 xmlFreeImpl(ns as *mut c_void);
6202 return ptr::null_mut();
6203 }
6204 *tab = val;
6205 (*ns).nodeTab = tab;
6206 (*ns).nodeNr = 1;
6207 (*ns).nodeMax = 1;
6208 ns
6209}
6210
6211#[no_mangle]
6223pub unsafe extern "C" fn xmlXPathFreeNodeSet(ns: *mut _xmlNodeSet) {
6224 if ns.is_null() {
6225 return;
6226 }
6227 if !(*ns).nodeTab.is_null() {
6228 xmlFreeImpl((*ns).nodeTab as *mut c_void);
6229 (*ns).nodeTab = ptr::null_mut();
6230 }
6231 (*ns).nodeNr = 0;
6232 (*ns).nodeMax = 0;
6233 xmlFreeImpl(ns as *mut c_void);
6234}
6235
6236#[no_mangle]
6247pub unsafe extern "C" fn xmlXPathCompile(str_: *const xmlChar) -> *mut c_void {
6248 if str_.is_null() {
6249 return ptr::null_mut();
6250 }
6251 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
6252 Ok(s) => s,
6253 Err(_) => return ptr::null_mut(),
6254 };
6255
6256 match crate::xml::xpath::compile(expr_str) {
6257 Some(compiled) => {
6258 let mut map = COMPILED_EXPRS.lock();
6259 let mut counter = NEXT_COMPILED_KEY.lock();
6260 let key = *counter;
6261 *counter += 1;
6262 map.insert(key, Box::new(compiled));
6263 key as *mut c_void
6264 }
6265 None => ptr::null_mut(),
6266 }
6267}
6268
6269#[no_mangle]
6277pub unsafe extern "C" fn xmlXPathFreeCompExpr(comp: *mut c_void) {
6278 if comp.is_null() {
6279 return;
6280 }
6281 let mut map = COMPILED_EXPRS.lock();
6282 map.remove(&(comp as u64));
6283}
6284
6285#[no_mangle]
6294pub unsafe extern "C" fn xmlXPathRegisterNs(
6295 ctxt: *mut _xmlXPathContext,
6296 prefix: *const xmlChar,
6297 ns_uri: *const xmlChar,
6298) -> c_int {
6299 if ctxt.is_null() || prefix.is_null() || ns_uri.is_null() {
6300 return -1;
6301 }
6302 let internal = (*ctxt).extra as *mut XPathContext;
6303 if internal.is_null() {
6304 return -1;
6305 }
6306 let internal = &mut *internal;
6307
6308 let prefix_str = match CStr::from_ptr(prefix as *const c_char).to_str() {
6309 Ok(s) => s,
6310 Err(_) => return -1,
6311 };
6312 let uri_str = match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6313 Ok(s) => s,
6314 Err(_) => return -1,
6315 };
6316
6317 internal.register_namespace(prefix_str, uri_str);
6318
6319 let map: &mut HashMap<String, CString> = if (*ctxt).nsHash.is_null() {
6324 let b: Box<HashMap<String, CString>> = Box::default();
6325 (*ctxt).nsHash = Box::into_raw(b) as *mut c_void;
6326 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6327 } else {
6328 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6329 };
6330 map.insert(
6331 prefix_str.to_string(),
6332 CString::new(uri_str.as_bytes()).unwrap_or_default(),
6333 );
6334 0
6335}
6336
6337#[no_mangle]
6351pub unsafe extern "C" fn xmlXPathRegisterFunc(
6352 ctxt: *mut _xmlXPathContext,
6353 name: *const xmlChar,
6354 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6355) -> c_int {
6356 if ctxt.is_null() || name.is_null() {
6357 return -1;
6358 }
6359 let internal = (*ctxt).extra as *mut XPathContext;
6360 if internal.is_null() {
6361 return -1;
6362 }
6363 let internal = &mut *internal;
6364
6365 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6366 Ok(s) => s,
6367 Err(_) => return -1,
6368 };
6369
6370 if let Some(func) = f {
6371 let key = (SendSyncPtr((*ctxt).extra), name_str.to_string());
6373 C_FUNCTIONS.lock().insert(key, func);
6374 let c_ctxt = SendSyncPtr(ctxt as *mut c_void);
6377 let name_owned = name_str.to_string();
6378 internal.register_function(name_str, c_func_bridge_closure(c_ctxt, name_owned));
6379 }
6380 0
6381}
6382
6383#[no_mangle]
6393pub unsafe extern "C" fn xmlXPathRegisterFuncNS(
6394 ctxt: *mut _xmlXPathContext,
6395 name: *const xmlChar,
6396 ns_uri: *const xmlChar,
6397 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6398) -> c_int {
6399 if ctxt.is_null() || name.is_null() {
6400 return -1;
6401 }
6402 let internal = (*ctxt).extra as *mut XPathContext;
6403 if internal.is_null() {
6404 return -1;
6405 }
6406 let internal = &mut *internal;
6407
6408 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6409 Ok(s) => s,
6410 Err(_) => return -1,
6411 };
6412 let ns_str = if ns_uri.is_null() {
6413 String::new()
6414 } else {
6415 match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6416 Ok(s) => s.to_string(),
6417 Err(_) => return -1,
6418 }
6419 };
6420
6421 let qualified = if ns_str.is_empty() {
6423 name_str.to_string()
6424 } else {
6425 format!("{{{}}}{}", ns_str, name_str)
6426 };
6427
6428 if let Some(func) = f {
6429 let key = (SendSyncPtr((*ctxt).extra), qualified.clone());
6430 C_FUNCTIONS.lock().insert(key, func);
6431 let c_ctxt = SendSyncPtr(ctxt as *mut c_void);
6432 let qualified_owned = qualified.clone();
6433 internal.register_function(&qualified, c_func_bridge_closure(c_ctxt, qualified_owned));
6434 }
6435 0
6436}
6437
6438#[no_mangle]
6447pub unsafe extern "C" fn xmlXPathRegisterVariable(
6448 ctxt: *mut _xmlXPathContext,
6449 name: *const xmlChar,
6450 value: *mut _xmlXPathObject,
6451) -> c_int {
6452 if ctxt.is_null() || name.is_null() || value.is_null() {
6453 return -1;
6454 }
6455 let internal = (*ctxt).extra as *mut XPathContext;
6456 if internal.is_null() {
6457 return -1;
6458 }
6459 let internal = &mut *internal;
6460
6461 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6462 Ok(s) => s,
6463 Err(_) => return -1,
6464 };
6465
6466 let xpath_val = object_to_xpathvalue(value);
6467 internal.register_variable(name_str, xpath_val);
6468 0
6469}
6470
6471#[no_mangle]
6479pub unsafe extern "C" fn xmlXPathNewNodeSet(val: *mut _xmlNode) -> *mut _xmlXPathObject {
6480 let ns = if val.is_null() {
6481 NodeSet::new()
6482 } else {
6483 NodeSet::singleton(val)
6484 };
6485 xpath_to_object(XPathValue::NodeSet(ns))
6486}
6487
6488#[no_mangle]
6496pub unsafe extern "C" fn xmlXPathNewCString(val: *const xmlChar) -> *mut _xmlXPathObject {
6497 if val.is_null() {
6498 return xpath_to_object(XPathValue::String(String::new()));
6499 }
6500 let s = match CStr::from_ptr(val as *const c_char).to_str() {
6501 Ok(s) => s.to_string(),
6502 Err(_) => return ptr::null_mut(),
6503 };
6504 xpath_to_object(XPathValue::String(s))
6505}
6506
6507#[no_mangle]
6515pub extern "C" fn xmlXPathNewFloat(val: f64) -> *mut _xmlXPathObject {
6516 unsafe { xpath_to_object(XPathValue::Number(val)) }
6517}
6518
6519#[no_mangle]
6527pub extern "C" fn xmlXPathNewBoolean(val: c_int) -> *mut _xmlXPathObject {
6528 unsafe { xpath_to_object(XPathValue::Boolean(val != 0)) }
6529}
6530
6531#[no_mangle]
6545pub unsafe extern "C" fn xmlXPtrEval(expr: *const c_char, doc: *mut _xmlDoc) -> *mut _xmlNode {
6546 crate::xml::xpointer::xmlXPtrEval(expr, doc)
6547}
6548
6549#[no_mangle]
6561pub unsafe extern "C" fn xmlXIncludeProcess(doc: *mut _xmlDoc) -> c_int {
6562 crate::xml::xinclude::xinclude_process(doc)
6563}
6564
6565#[no_mangle]
6573pub unsafe extern "C" fn xmlXIncludeProcessFlags(doc: *mut _xmlDoc, flags: c_int) -> c_int {
6574 crate::xml::xinclude::xinclude_process_flags(doc, flags)
6575}
6576
6577#[no_mangle]
6589pub extern "C" fn xmlCatalogLoad(catalogs: *const c_char) -> *mut c_void {
6590 if catalogs.is_null() {
6591 return ptr::null_mut();
6592 }
6593 crate::xml::catalog::load_catalog(catalogs)
6594}
6595
6596#[no_mangle]
6604pub unsafe extern "C" fn xmlCatalogResolvePublic(pubID: *const xmlChar) -> *mut xmlChar {
6605 if pubID.is_null() {
6606 return ptr::null_mut();
6607 }
6608 crate::xml::catalog::resolve_public(pubID)
6609}
6610
6611#[no_mangle]
6619pub unsafe extern "C" fn xmlCatalogResolveSystem(sysID: *const xmlChar) -> *mut xmlChar {
6620 if sysID.is_null() {
6621 return ptr::null_mut();
6622 }
6623 crate::xml::catalog::resolve_system(sysID)
6624}
6625
6626#[no_mangle]
6634pub unsafe extern "C" fn xmlCatalogResolveURI(URI: *const xmlChar) -> *mut xmlChar {
6635 if URI.is_null() {
6636 return ptr::null_mut();
6637 }
6638 crate::xml::catalog::resolve_uri(URI)
6639}
6640
6641#[no_mangle]
6649pub extern "C" fn xmlCatalogSetDefaults(allow: c_int) {
6650 crate::xml::catalog::set_defaults(allow)
6651}
6652
6653#[no_mangle]
6661pub extern "C" fn xmlCatalogGetDefaults() -> c_int {
6662 crate::xml::catalog::get_defaults()
6663}
6664
6665#[no_mangle]
6673pub unsafe extern "C" fn xmlCatalogAdd(
6674 type_: *const xmlChar,
6675 orig: *const xmlChar,
6676 replace: *const xmlChar,
6677) -> c_int {
6678 if type_.is_null() || orig.is_null() || replace.is_null() {
6679 return -1;
6680 }
6681 crate::xml::catalog::add(type_, orig, replace)
6682}
6683
6684#[no_mangle]
6692pub unsafe extern "C" fn xmlCatalogRemove(value: *const xmlChar) -> c_int {
6693 if value.is_null() {
6694 return 0;
6695 }
6696 crate::xml::catalog::remove(value)
6697}
6698
6699#[no_mangle]
6707pub unsafe extern "C" fn xmlCatalogDump(output: *mut c_void, _catal: *mut c_void) {
6708 if output.is_null() {
6709 return;
6710 }
6711 let doc = crate::xml::catalog::dump_doc();
6712 if doc.is_null() {
6713 return;
6714 }
6715 let mut mem: *mut xmlChar = ptr::null_mut();
6716 let mut size: c_int = 0;
6717 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6718 if !mem.is_null() {
6719 libc::fwrite(
6720 mem as *const c_void,
6721 1,
6722 size as usize,
6723 output as *mut libc::FILE,
6724 );
6725 xmlFreeImpl(mem as *mut c_void);
6726 }
6727 crate::xml::tree::free_doc(doc);
6728}
6729
6730#[no_mangle]
6740pub unsafe extern "C" fn xmlCatalogSave(filename: *const c_char) -> c_int {
6741 if filename.is_null() {
6742 return -1;
6743 }
6744 let doc = crate::xml::catalog::dump_doc();
6745 if doc.is_null() {
6746 return -1;
6747 }
6748 let mut mem: *mut xmlChar = ptr::null_mut();
6749 let mut size: c_int = 0;
6750 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6751 let mut ret: c_int = -1;
6752 if !mem.is_null() {
6753 let fp = libc::fopen(filename, c"w".as_ptr() as *const c_char);
6754 if !fp.is_null() {
6755 let written = libc::fwrite(mem as *const c_void, 1, size as usize, fp);
6756 ret = if written == size as usize { 0 } else { -1 };
6757 libc::fclose(fp);
6758 }
6759 xmlFreeImpl(mem as *mut c_void);
6760 }
6761 crate::xml::tree::free_doc(doc);
6762 ret
6763}
6764
6765#[no_mangle]
6773pub extern "C" fn xmlCatalogCleanup() {
6774 crate::xml::catalog::cleanup();
6775}
6776
6777#[no_mangle]
6785pub extern "C" fn xmlCatalogConvert() -> *mut _xmlDoc {
6786 unsafe { crate::xml::catalog::convert() }
6788}
6789
6790#[no_mangle]
6802pub const unsafe extern "C" fn htmlParseFile(
6803 _filename: *const c_char,
6804 _encoding: *const c_char,
6805) -> *mut _xmlDoc {
6806 ptr::null_mut()
6808}
6809
6810#[no_mangle]
6818pub const unsafe extern "C" fn htmlParseMemory(
6819 _buffer: *const c_char,
6820 _size: c_int,
6821) -> *mut _xmlDoc {
6822 ptr::null_mut()
6824}
6825
6826#[no_mangle]
6834pub const unsafe extern "C" fn htmlParseDoc(
6835 _cur: *const xmlChar,
6836 _encoding: *const c_char,
6837) -> *mut _xmlDoc {
6838 ptr::null_mut()
6840}
6841
6842#[no_mangle]
6851pub const unsafe extern "C" fn htmlCreateFileParserCtxt(
6852 _filename: *const c_char,
6853 _encoding: *const c_char,
6854) -> *mut c_void {
6855 ptr::null_mut()
6857}
6858
6859#[no_mangle]
6867pub extern "C" fn htmlFreeParserCtxt(ctxt: *mut c_void) {
6868 unsafe { crate::xml::html::free_parser_ctxt(ctxt) }
6869}
6870
6871#[no_mangle]
6879pub const extern "C" fn htmlInitParser() {
6880 }
6882
6883#[no_mangle]
6891pub const extern "C" fn htmlCleanupParser() {
6892 }
6894
6895#[no_mangle]
6907pub unsafe extern "C" fn xmlNewValidCtxt() -> *mut _xmlValidCtxt {
6908 crate::xml::validation::new_valid_ctxt()
6909}
6910
6911#[no_mangle]
6919pub unsafe extern "C" fn xmlFreeValidCtxt(ctxt: *mut _xmlValidCtxt) {
6920 crate::xml::validation::free_valid_ctxt(ctxt);
6921}
6922
6923#[no_mangle]
6934pub unsafe extern "C" fn xmlSetValidErrors(
6935 ctxt: *mut _xmlValidCtxt,
6936 err: Option<xmlGenericErrorFunc>,
6937 warn: Option<xmlGenericErrorFunc>,
6938 data: *mut c_void,
6939) {
6940 crate::xml::validation::set_valid_errors(ctxt, err, warn, data);
6941}
6942
6943#[no_mangle]
6951pub unsafe extern "C" fn xmlValidateDocument(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
6952 crate::xml::validation::validate_document(ctxt, doc)
6953}
6954
6955#[no_mangle]
6963pub unsafe extern "C" fn xmlValidateDocumentFinal(
6964 ctxt: *mut _xmlValidCtxt,
6965 doc: *mut _xmlDoc,
6966) -> c_int {
6967 crate::xml::validation::validate_document_final(ctxt, doc)
6968}
6969
6970#[no_mangle]
6980pub unsafe extern "C" fn xmlValidateElement(
6981 ctxt: *mut _xmlValidCtxt,
6982 doc: *mut _xmlDoc,
6983 elem: *mut _xmlNode,
6984) -> c_int {
6985 crate::xml::validation::validate_element(ctxt, doc, elem)
6986}
6987
6988#[no_mangle]
6999pub unsafe extern "C" fn xmlValidateAttributeDecl(
7000 ctxt: *mut _xmlValidCtxt,
7001 doc: *mut _xmlDoc,
7002 elem: *mut _xmlNode,
7003 attr: *mut _xmlAttribute,
7004) -> c_int {
7005 crate::xml::validation::validate_attribute_decl(ctxt, doc, elem, attr)
7006}
7007
7008#[no_mangle]
7016pub unsafe extern "C" fn xmlValidateAttributeValue(atype: c_int, value: *const xmlChar) -> c_int {
7017 crate::xml::validation::validate_attribute_value(atype, value)
7018}
7019
7020#[no_mangle]
7030pub unsafe extern "C" fn xmlValidateNotationUse(
7031 ctxt: *mut _xmlValidCtxt,
7032 doc: *mut _xmlDoc,
7033 notation_name: *const xmlChar,
7034) -> c_int {
7035 crate::xml::validation::validate_notation_use(ctxt, doc, notation_name)
7036}
7037
7038#[no_mangle]
7049pub unsafe extern "C" fn xmlValidateID(
7050 ctxt: *mut _xmlValidCtxt,
7051 doc: *mut _xmlDoc,
7052 node: *mut _xmlNode,
7053 value: *const xmlChar,
7054) -> c_int {
7055 crate::xml::validation::validate_id(ctxt, doc, node, value)
7056}
7057
7058#[no_mangle]
7069pub unsafe extern "C" fn xmlValidateIDRef(
7070 ctxt: *mut _xmlValidCtxt,
7071 doc: *mut _xmlDoc,
7072 node: *mut _xmlNode,
7073 value: *const xmlChar,
7074) -> c_int {
7075 crate::xml::validation::validate_id_ref(ctxt, doc, node, value)
7076}
7077
7078#[no_mangle]
7089pub unsafe extern "C" fn xmlValidateIDRefs(
7090 ctxt: *mut _xmlValidCtxt,
7091 doc: *mut _xmlDoc,
7092 node: *mut _xmlNode,
7093 value: *const xmlChar,
7094) -> c_int {
7095 crate::xml::validation::validate_id_refs(ctxt, doc, node, value)
7096}
7097
7098#[no_mangle]
7108pub unsafe extern "C" fn xmlValidateNCName(value: *const xmlChar, space: c_int) -> c_int {
7109 crate::xml::validation::validate_ncname(value, space)
7110}
7111
7112#[no_mangle]
7120pub unsafe extern "C" fn xmlValidateQName(value: *const xmlChar, space: c_int) -> c_int {
7121 crate::xml::validation::validate_qname(value, space)
7122}
7123
7124#[no_mangle]
7137pub unsafe extern "C" fn xmlValidateName(value: *const xmlChar, space: c_int) -> c_int {
7138 crate::xml::validation::validate_name_space(value, space)
7139}
7140
7141#[no_mangle]
7149pub unsafe extern "C" fn xmlValidateNMToken(value: *const xmlChar, space: c_int) -> c_int {
7150 crate::xml::validation::validate_nmtoken_space(value, space)
7151}
7152
7153#[no_mangle]
7163pub unsafe extern "C" fn xmlValidateNameValue(value: *const xmlChar) -> c_int {
7164 crate::xml::validation::validate_name_value(value)
7165}
7166
7167#[no_mangle]
7176pub unsafe extern "C" fn xmlValidateNamesValue(value: *const xmlChar) -> c_int {
7177 crate::xml::validation::validate_names_value(value)
7178}
7179
7180#[no_mangle]
7188pub unsafe extern "C" fn xmlValidateNmtokenValue(value: *const xmlChar) -> c_int {
7189 crate::xml::validation::validate_nmtoken_value(value)
7190}
7191
7192#[no_mangle]
7200pub unsafe extern "C" fn xmlValidateNmtokensValue(value: *const xmlChar) -> c_int {
7201 crate::xml::validation::validate_nmtokens_value(value)
7202}
7203
7204#[no_mangle]
7215pub unsafe extern "C" fn xmlValidateElementDecl(
7216 ctxt: *mut _xmlValidCtxt,
7217 doc: *mut _xmlDoc,
7218 elem: *mut _xmlElement,
7219) -> c_int {
7220 crate::xml::validation::validate_element_decl(ctxt, doc, elem)
7221}
7222
7223#[no_mangle]
7236pub const unsafe extern "C" fn xmlValidateNotationDecl(
7237 ctxt: *mut _xmlValidCtxt,
7238 doc: *mut _xmlDoc,
7239 nota: *mut _xmlNotation,
7240) -> c_int {
7241 crate::xml::validation::validate_notation_decl(ctxt, doc, nota)
7242}
7243
7244#[no_mangle]
7256pub unsafe extern "C" fn xmlValidateOneAttribute(
7257 ctxt: *mut _xmlValidCtxt,
7258 doc: *mut _xmlDoc,
7259 elem: *mut _xmlNode,
7260 attr: *mut _xmlAttr,
7261 value: *const xmlChar,
7262) -> c_int {
7263 crate::xml::validation::validate_one_attribute(ctxt, doc, elem, attr, value)
7264}
7265
7266#[no_mangle]
7276pub unsafe extern "C" fn xmlValidateOneElement(
7277 ctxt: *mut _xmlValidCtxt,
7278 doc: *mut _xmlDoc,
7279 elem: *mut _xmlNode,
7280) -> c_int {
7281 crate::xml::validation::validate_one_element(ctxt, doc, elem)
7282}
7283
7284#[no_mangle]
7297pub unsafe extern "C" fn xmlValidateOneNamespace(
7298 ctxt: *mut _xmlValidCtxt,
7299 doc: *mut _xmlDoc,
7300 elem: *mut _xmlNode,
7301 prefix: *const xmlChar,
7302 ns: *mut _xmlNs,
7303 value: *const xmlChar,
7304) -> c_int {
7305 crate::xml::validation::validate_one_namespace(ctxt, doc, elem, prefix, ns, value)
7306}
7307
7308#[no_mangle]
7320pub unsafe extern "C" fn xmlValidatePushElement(
7321 ctxt: *mut _xmlValidCtxt,
7322 doc: *mut _xmlDoc,
7323 elem: *mut _xmlNode,
7324 qname: *const xmlChar,
7325) -> c_int {
7326 crate::xml::validation::validate_push_element(ctxt, doc, elem, qname)
7327}
7328
7329#[no_mangle]
7339pub unsafe extern "C" fn xmlValidatePushCData(
7340 ctxt: *mut _xmlValidCtxt,
7341 data: *const xmlChar,
7342 len: c_int,
7343) -> c_int {
7344 crate::xml::validation::validate_push_cdata(ctxt, data, len)
7345}
7346
7347#[no_mangle]
7358pub unsafe extern "C" fn xmlValidatePopElement(
7359 ctxt: *mut _xmlValidCtxt,
7360 doc: *mut _xmlDoc,
7361 elem: *mut _xmlNode,
7362 qname: *const xmlChar,
7363) -> c_int {
7364 crate::xml::validation::validate_pop_element(ctxt, doc, elem, qname)
7365}
7366
7367#[no_mangle]
7376pub unsafe extern "C" fn xmlValidBuildContentModel(
7377 ctxt: *mut _xmlValidCtxt,
7378 elem: *mut _xmlElement,
7379) -> c_int {
7380 crate::xml::validation::validate_build_content_model(ctxt, elem)
7381}
7382
7383#[no_mangle]
7394pub unsafe extern "C" fn xmlAddID(
7395 ctxt: *mut _xmlValidCtxt,
7396 doc: *mut _xmlDoc,
7397 value: *const xmlChar,
7398 attr: *mut _xmlAttr,
7399) -> *mut _xmlID {
7400 crate::xml::validation::add_id(ctxt, doc, value, attr)
7401}
7402
7403#[no_mangle]
7411pub unsafe extern "C" fn xmlRemoveID(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7412 crate::xml::validation::remove_id(doc, attr)
7413}
7414
7415#[no_mangle]
7426pub unsafe extern "C" fn xmlAddRef(
7427 ctxt: *mut _xmlValidCtxt,
7428 doc: *mut _xmlDoc,
7429 value: *const xmlChar,
7430 attr: *mut _xmlAttr,
7431) -> *mut _xmlRef {
7432 crate::xml::validation::add_ref(ctxt, doc, value, attr)
7433}
7434
7435#[no_mangle]
7443pub unsafe extern "C" fn xmlRemoveRef(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7444 crate::xml::validation::remove_ref(doc, attr)
7445}
7446
7447#[no_mangle]
7455pub unsafe extern "C" fn xmlAddIDSafe(attr: *mut _xmlAttr, value: *const xmlChar) -> c_int {
7456 crate::xml::validation::add_id_safe(attr, value)
7457}
7458
7459#[no_mangle]
7467pub unsafe extern "C" fn xmlFreeIDTable(table: *mut c_void) {
7468 crate::xml::validation::free_id_table(table as *mut crate::xml::hash::HashTable);
7469}
7470
7471#[no_mangle]
7479pub unsafe extern "C" fn xmlFreeRefTable(table: *mut c_void) {
7480 crate::xml::validation::free_ref_table(table as *mut crate::xml::hash::HashTable);
7481}
7482
7483#[no_mangle]
7491pub unsafe extern "C" fn xmlGetID(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut _xmlAttr {
7492 crate::xml::validation::get_id(doc, id)
7493}
7494
7495#[no_mangle]
7503pub unsafe extern "C" fn xmlGetRefs(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut c_void {
7504 crate::xml::validation::get_refs(doc, id) as *mut c_void
7505}
7506
7507#[no_mangle]
7515pub unsafe extern "C" fn xmlIsID(
7516 doc: *mut _xmlDoc,
7517 elem: *mut _xmlNode,
7518 attr: *mut _xmlAttr,
7519) -> c_int {
7520 crate::xml::validation::is_id(doc, elem, attr)
7521}
7522
7523#[no_mangle]
7531pub unsafe extern "C" fn xmlIsRef(
7532 doc: *mut _xmlDoc,
7533 elem: *mut _xmlNode,
7534 attr: *mut _xmlAttr,
7535) -> c_int {
7536 crate::xml::validation::is_ref(doc, elem, attr)
7537}
7538
7539#[no_mangle]
7547pub unsafe extern "C" fn xmlGetDtdElementDesc(
7548 dtd: *mut _xmlDtd,
7549 name: *const xmlChar,
7550) -> *mut _xmlElement {
7551 crate::xml::validation::get_dtd_element_desc(dtd, name)
7552}
7553
7554#[no_mangle]
7564pub unsafe extern "C" fn xmlGetDtdAttrDesc(
7565 dtd: *mut _xmlDtd,
7566 elem: *const xmlChar,
7567 name: *const xmlChar,
7568) -> *mut _xmlAttribute {
7569 crate::xml::validation::get_dtd_attr_desc(dtd, elem, name)
7570}
7571
7572#[no_mangle]
7582pub unsafe extern "C" fn xmlGetDtdQElementDesc(
7583 dtd: *mut _xmlDtd,
7584 name: *const xmlChar,
7585 prefix: *const xmlChar,
7586) -> *mut _xmlElement {
7587 crate::xml::validation::get_dtd_qelement_desc(dtd, name, prefix)
7588}
7589
7590#[no_mangle]
7601pub unsafe extern "C" fn xmlGetDtdQAttrDesc(
7602 dtd: *mut _xmlDtd,
7603 elem: *const xmlChar,
7604 name: *const xmlChar,
7605 prefix: *const xmlChar,
7606) -> *mut _xmlAttribute {
7607 crate::xml::validation::get_dtd_qattr_desc(dtd, elem, name, prefix)
7608}
7609
7610#[no_mangle]
7618pub unsafe extern "C" fn xmlGetDtdNotationDesc(
7619 dtd: *mut _xmlDtd,
7620 name: *const xmlChar,
7621) -> *mut _xmlNotation {
7622 crate::xml::validation::get_dtd_notation_desc(dtd, name)
7623}
7624
7625#[no_mangle]
7633pub unsafe extern "C" fn xmlValidateRoot(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7634 crate::xml::validation::validate_root(ctxt, doc)
7635}
7636
7637#[no_mangle]
7647pub unsafe extern "C" fn xmlValidateContent(
7648 ctxt: *mut _xmlValidCtxt,
7649 node: *mut _xmlNode,
7650 doc: *mut _xmlDoc,
7651) -> c_int {
7652 crate::xml::validation::validate_content(ctxt, node, doc)
7653}
7654
7655#[no_mangle]
7663pub unsafe extern "C" fn xmlIsMixedElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7664 crate::xml::validation::is_mixed_element(doc, name)
7665}
7666
7667#[no_mangle]
7675pub unsafe extern "C" fn xmlIsEmptyElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7676 crate::xml::validation::is_empty_element(doc, name)
7677}
7678
7679#[no_mangle]
7689pub unsafe extern "C" fn xmlValidateDtd(
7690 ctxt: *mut _xmlValidCtxt,
7691 doc: *mut _xmlDoc,
7692 dtd: *mut _xmlDtd,
7693) -> c_int {
7694 crate::xml::validation::validate_dtd(ctxt, doc, dtd)
7695}
7696
7697#[no_mangle]
7705pub unsafe extern "C" fn xmlValidateDtdFinal(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7706 crate::xml::validation::validate_dtd_final(ctxt, doc)
7707}
7708
7709#[no_mangle]
7719pub unsafe extern "C" fn xmlValidateEnumeration(
7720 ctxt: *mut _xmlValidCtxt,
7721 value: *const xmlChar,
7722 tree: *mut _xmlEnumeration,
7723) -> c_int {
7724 crate::xml::validation::validate_enumeration(ctxt, value, tree)
7725}
7726
7727#[no_mangle]
7740pub const extern "C" fn xmlGetBinaryPath() -> *mut c_char {
7741 ptr::null_mut()
7743}
7744
7745#[no_mangle]
7753pub const extern "C" fn xmlGetHomeOfBinary() -> *mut c_char {
7754 ptr::null_mut()
7756}
7757
7758#[no_mangle]
7769pub unsafe extern "C" fn xmlSAX2StartDocument(ctx: *mut c_void) {
7770 crate::xml::sax::default::default_sax_handler::startDocument(ctx)
7771}
7772
7773#[no_mangle]
7775pub unsafe extern "C" fn xmlSAX2EndDocument(ctx: *mut c_void) {
7776 crate::xml::sax::default::default_sax_handler::endDocument(ctx)
7777}
7778
7779#[no_mangle]
7781pub unsafe extern "C" fn xmlSAX2StartElementNs(
7782 ctx: *mut c_void,
7783 localname: *const xmlChar,
7784 prefix: *const xmlChar,
7785 URI: *const xmlChar,
7786 nb_namespaces: c_int,
7787 namespaces: *mut *const xmlChar,
7788 nb_attributes: c_int,
7789 nb_defaulted: c_int,
7790 attributes: *mut *const xmlChar,
7791) {
7792 crate::xml::sax::default::default_sax_handler::startElementNs(
7793 ctx,
7794 localname,
7795 prefix,
7796 URI,
7797 nb_namespaces,
7798 namespaces,
7799 nb_attributes,
7800 nb_defaulted,
7801 attributes,
7802 )
7803}
7804
7805#[no_mangle]
7807pub unsafe extern "C" fn xmlSAX2EndElementNs(
7808 ctx: *mut c_void,
7809 localname: *const xmlChar,
7810 prefix: *const xmlChar,
7811 URI: *const xmlChar,
7812) {
7813 crate::xml::sax::default::default_sax_handler::endElementNs(ctx, localname, prefix, URI)
7814}
7815
7816#[no_mangle]
7818pub unsafe extern "C" fn xmlSAX2Characters(ctx: *mut c_void, ch: *const xmlChar, len: c_int) {
7819 crate::xml::sax::default::default_sax_handler::characters(ctx, ch, len)
7820}
7821
7822#[no_mangle]
7824pub unsafe extern "C" fn xmlSAX2IgnorableWhitespace(
7825 ctx: *mut c_void,
7826 ch: *const xmlChar,
7827 len: c_int,
7828) {
7829 crate::xml::sax::default::default_sax_handler::ignorableWhitespace(ctx, ch, len)
7830}
7831
7832#[no_mangle]
7834pub unsafe extern "C" fn xmlSAX2Comment(ctx: *mut c_void, value: *const xmlChar) {
7835 crate::xml::sax::default::default_sax_handler::comment(ctx, value)
7836}
7837
7838#[no_mangle]
7840pub unsafe extern "C" fn xmlSAX2ProcessingInstruction(
7841 ctx: *mut c_void,
7842 target: *const xmlChar,
7843 data: *const xmlChar,
7844) {
7845 crate::xml::sax::default::default_sax_handler::processingInstruction(ctx, target, data)
7846}
7847
7848#[no_mangle]
7850pub unsafe extern "C" fn xmlSAX2CDataBlock(ctx: *mut c_void, value: *const xmlChar, len: c_int) {
7851 crate::xml::sax::default::default_sax_handler::cdataBlock(ctx, value, len)
7852}
7853
7854#[no_mangle]
7856pub unsafe extern "C" fn xmlSAX2InternalSubset(
7857 ctx: *mut c_void,
7858 name: *const xmlChar,
7859 ExternalID: *const xmlChar,
7860 SystemID: *const xmlChar,
7861) {
7862 crate::xml::sax::default::default_sax_handler::internalSubset(ctx, name, ExternalID, SystemID)
7863}
7864
7865#[no_mangle]
7867pub unsafe extern "C" fn xmlSAX2ExternalSubset(
7868 ctx: *mut c_void,
7869 name: *const xmlChar,
7870 ExternalID: *const xmlChar,
7871 SystemID: *const xmlChar,
7872) {
7873 crate::xml::sax::default::default_sax_handler::externalSubset(ctx, name, ExternalID, SystemID)
7874}
7875
7876#[no_mangle]
7878pub unsafe extern "C" fn xmlSAX2EntityDecl(
7879 ctx: *mut c_void,
7880 name: *const xmlChar,
7881 type_: c_int,
7882 publicId: *const xmlChar,
7883 systemId: *const xmlChar,
7884 content: *mut xmlChar,
7885) {
7886 crate::xml::sax::default::default_sax_handler::entityDecl(
7887 ctx, name, type_, publicId, systemId, content,
7888 )
7889}
7890
7891#[no_mangle]
7893pub const unsafe extern "C" fn xmlSAX2AttributeDecl(
7894 ctx: *mut c_void,
7895 elem: *const xmlChar,
7896 fullname: *const xmlChar,
7897 type_: c_int,
7898 def: c_int,
7899 defaultValue: *const xmlChar,
7900 tree: *mut crate::abi::structs::_xmlEnumeration,
7901) {
7902 crate::xml::sax::default::default_sax_handler::attributeDecl(
7903 ctx,
7904 elem,
7905 fullname,
7906 type_,
7907 def,
7908 defaultValue,
7909 tree,
7910 )
7911}
7912
7913#[no_mangle]
7915pub const unsafe extern "C" fn xmlSAX2ElementDecl(
7916 ctx: *mut c_void,
7917 name: *const xmlChar,
7918 type_: c_int,
7919 content: *mut crate::abi::structs::_xmlElementContent,
7920) {
7921 crate::xml::sax::default::default_sax_handler::elementDecl(ctx, name, type_, content)
7922}
7923
7924#[no_mangle]
7926pub const unsafe extern "C" fn xmlSAX2NotationDecl(
7927 ctx: *mut c_void,
7928 name: *const xmlChar,
7929 publicId: *const xmlChar,
7930 systemId: *const xmlChar,
7931) {
7932 crate::xml::sax::default::default_sax_handler::notationDecl(ctx, name, publicId, systemId)
7933}
7934
7935#[no_mangle]
7937pub const unsafe extern "C" fn xmlSAX2UnparsedEntityDecl(
7938 ctx: *mut c_void,
7939 name: *const xmlChar,
7940 publicId: *const xmlChar,
7941 systemId: *const xmlChar,
7942 notationName: *const xmlChar,
7943) {
7944 crate::xml::sax::default::default_sax_handler::unparsedEntityDecl(
7945 ctx,
7946 name,
7947 publicId,
7948 systemId,
7949 notationName,
7950 )
7951}
7952
7953#[no_mangle]
7955pub const unsafe extern "C" fn xmlSAX2ResolveEntity(
7956 ctx: *mut c_void,
7957 publicId: *const xmlChar,
7958 systemId: *const xmlChar,
7959) -> *mut crate::abi::structs::_xmlParserInput {
7960 crate::xml::sax::default::default_sax_handler::resolveEntity(ctx, publicId, systemId)
7961}
7962
7963#[no_mangle]
7965pub const unsafe extern "C" fn xmlSAX2IsStandalone(ctx: *mut c_void) -> c_int {
7966 crate::xml::sax::default::default_sax_handler::isStandalone(ctx)
7967}
7968
7969#[no_mangle]
7971pub unsafe extern "C" fn xmlSAX2HasInternalSubset(ctx: *mut c_void) -> c_int {
7972 crate::xml::sax::default::default_sax_handler::hasInternalSubset(ctx)
7973}
7974
7975#[no_mangle]
7977pub unsafe extern "C" fn xmlSAX2HasExternalSubset(ctx: *mut c_void) -> c_int {
7978 crate::xml::sax::default::default_sax_handler::hasExternalSubset(ctx)
7979}
7980
7981#[no_mangle]
7983pub unsafe extern "C" fn xmlSAX2GetEntity(
7984 ctx: *mut c_void,
7985 name: *const xmlChar,
7986) -> *mut crate::abi::structs::_xmlEntity {
7987 crate::xml::sax::default::default_sax_handler::getEntity(ctx, name)
7988}
7989
7990#[no_mangle]
7992pub unsafe extern "C" fn xmlSAX2GetParameterEntity(
7993 ctx: *mut c_void,
7994 name: *const xmlChar,
7995) -> *mut crate::abi::structs::_xmlEntity {
7996 crate::xml::sax::default::default_sax_handler::getParameterEntity(ctx, name)
7997}
7998
7999#[no_mangle]
8002pub unsafe extern "C" fn xmlSAX2GetLineNumber(ctx: *mut c_void) -> c_int {
8003 crate::xml::sax::default::default_sax_handler::getLineNumber(ctx)
8004}
8005
8006#[no_mangle]
8008pub unsafe extern "C" fn xmlSAX2GetColumnNumber(ctx: *mut c_void) -> c_int {
8009 crate::xml::sax::default::default_sax_handler::getColumnNumber(ctx)
8010}
8011
8012#[no_mangle]
8014pub const unsafe extern "C" fn xmlSAX2GetPublicId(ctx: *mut c_void) -> *const xmlChar {
8015 crate::xml::sax::default::default_sax_handler::getPublicId(ctx)
8016}
8017
8018#[no_mangle]
8020pub unsafe extern "C" fn xmlSAX2GetSystemId(ctx: *mut c_void) -> *const xmlChar {
8021 crate::xml::sax::default::default_sax_handler::getSystemId(ctx)
8022}
8023
8024#[no_mangle]
8028pub unsafe extern "C" fn xmlSAX2StartElement(
8029 ctx: *mut c_void,
8030 name: *const xmlChar,
8031 atts: *mut *const xmlChar,
8032) {
8033 crate::xml::sax::dispatch::SaxDispatcher::sax1_start_element(ctx, name, atts);
8037}
8038
8039#[no_mangle]
8041pub unsafe extern "C" fn xmlSAX2EndElement(ctx: *mut c_void, name: *const xmlChar) {
8042 crate::xml::sax::dispatch::SaxDispatcher::sax1_end_element(ctx, name);
8043}
8044
8045#[no_mangle]
8047pub const unsafe extern "C" fn xmlSAX2SetDocumentLocator(
8048 ctx: *mut c_void,
8049 loc: *mut crate::abi::callbacks::_xmlSAXLocator,
8050) {
8051 crate::xml::sax::default::default_sax_handler::setDocumentLocator(ctx, loc)
8052}
8053
8054#[no_mangle]
8056pub unsafe extern "C" fn xmlSAX2Reference(ctx: *mut c_void, name: *const xmlChar) {
8057 crate::xml::sax::default::default_sax_handler::reference(ctx, name)
8058}
8059
8060#[cfg(test)]
8061mod tests {
8062 use super::xml_number_to_string;
8063
8064 #[allow(clippy::approx_constant)]
8070 #[test]
8071 fn test_xml_number_to_string_parity_cases() {
8072 let cases: &[(f64, &str)] = &[
8073 (1234567.891, "1234567.891"),
8074 (0.1 + 0.2, "0.3"),
8075 (1.0 / 3.0, "0.333333333333333"),
8076 (1e20, "1e+20"),
8077 (1e-5, "0.00001"),
8078 (123456789012345678901234567890.0, "1.23456789012346e+29"),
8079 (1e100, "1e+100"),
8080 (-1e100, "-1e+100"),
8081 (1.5e-100, "1.5e-100"),
8082 (1e9, "1000000000"),
8083 (0.00001, "0.00001"),
8084 (9.99e-6, "9.99e-06"),
8085 (2147483646.0, "2147483646"),
8086 (2147483648.0, "2.147483648e+09"),
8087 (-2147483647.0, "-2147483647"),
8088 (-2147483649.0, "-2.147483649e+09"),
8089 (0.5, "0.5"),
8090 (1.0 / 7.0, "0.142857142857143"),
8091 (2.675, "2.675"),
8092 (3.141592653589793, "3.141592653589793"),
8093 (-0.0, "0"),
8094 (0.0, "0"),
8095 (f64::INFINITY, "Infinity"),
8096 (f64::NEG_INFINITY, "-Infinity"),
8097 (f64::NAN, "NaN"),
8098 (0.30000000000000004, "0.3"),
8099 (2.2250738585072014e-308, "2.2250738585072e-308"),
8100 (5e-324, "4.94065645841247e-324"),
8101 ];
8102 for (n, expected) in cases {
8103 assert_eq!(&xml_number_to_string(*n), expected, "value: {}", n);
8104 }
8105 }
8106}