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;
113use core::ptr;
114use once_cell::sync::Lazy;
115use parking_lot::Mutex;
116use std::collections::HashMap;
117use std::ffi::{CStr, CString};
118use std::mem::size_of;
119use std::os::raw::{c_char, c_int, c_long, c_uint, c_ulong};
120
121use crate::xml::xpath::ast::CompiledExpr;
122use crate::xml::xpath::context::{BoxedXPathFunction, XPathContext};
123use crate::xml::xpath::types::{NodeSet, XPathValue};
124
125use crate::abi::allocator::*;
126use crate::abi::callbacks::*;
127use crate::abi::structs::*;
128use crate::abi::types::*;
129
130#[no_mangle]
145pub unsafe extern "C" fn xmlInitParser() {
146 crate::internal::globals::init_parser();
147}
148
149#[no_mangle]
162pub const unsafe extern "C" fn xmlInitGlobals() {
163 }
165
166#[no_mangle]
176pub const unsafe extern "C" fn xmlInitializeGlobalState(_gs: *mut c_void) {
177 }
181
182#[no_mangle]
191pub const extern "C" fn xmlInitializeDict() -> c_int {
192 0
195}
196
197#[no_mangle]
207pub const extern "C" fn xmlInitializePredefinedEntities() {
208 }
210
211#[no_mangle]
220pub const extern "C" fn xmlCleanupPredefinedEntities() {
221 }
223
224#[no_mangle]
235pub const extern "C" fn xmlDefaultSAXHandlerInit() {
236 }
239
240static SAX2_DEFAULT_VERSION: core::sync::atomic::AtomicI32 = core::sync::atomic::AtomicI32::new(2);
243#[no_mangle]
252pub extern "C" fn xmlSAXDefaultVersion(version: c_int) -> c_int {
253 use core::sync::atomic::Ordering;
254 let ret = SAX2_DEFAULT_VERSION.load(Ordering::Relaxed);
255 if version != 1 && version != 2 {
256 return -1;
257 }
258 SAX2_DEFAULT_VERSION.store(version, Ordering::Relaxed);
259 ret
260}
261
262#[no_mangle]
272pub unsafe extern "C" fn xmlSAXVersion(
273 hdlr: *mut crate::abi::structs::_xmlSAXHandler,
274 version: c_int,
275) -> c_int {
276 if hdlr.is_null() {
277 return -1;
278 }
279 if version != 1 && version != 2 {
280 return -1;
281 }
282 unsafe {
284 crate::xml::sax::dispatch::xmlSAX2InitDefaultSAXHandler(hdlr);
285 let h = &mut *hdlr;
286 if version == 2 {
287 h.initialized = crate::abi::constants::XML_SAX2_MAGIC as c_uint;
288 } else {
289 h.initialized = 1;
290 }
291 }
292 0
293}
294
295#[no_mangle]
306pub extern "C" fn xmlHasFeature(feature: c_int) -> c_int {
307 if (1..=24).contains(&feature) {
310 1
311 } else {
312 0
313 }
314}
315
316#[no_mangle]
328pub const unsafe extern "C" fn xmlCleanupGlobals() {
329 }
331
332#[no_mangle]
342pub unsafe extern "C" fn xmlCleanupParser() {
343 crate::internal::globals::cleanup_parser();
344}
345
346#[no_mangle]
354pub extern "C" fn xmlNewMutex() -> *mut c_void {
355 crate::xml::threads::new_mutex()
356}
357
358#[no_mangle]
366pub unsafe extern "C" fn xmlFreeMutex(tok: *mut c_void) {
367 crate::xml::threads::free_mutex(tok);
368}
369
370#[no_mangle]
378pub unsafe extern "C" fn xmlMutexLock(tok: *mut c_void) {
379 crate::xml::threads::mutex_lock(tok);
380}
381
382#[no_mangle]
390pub unsafe extern "C" fn xmlMutexUnlock(tok: *mut c_void) {
391 crate::xml::threads::mutex_unlock(tok);
392}
393
394#[no_mangle]
402pub extern "C" fn xmlNewRMutex() -> *mut c_void {
403 crate::xml::threads::new_rmutex()
404}
405
406#[no_mangle]
414pub unsafe extern "C" fn xmlFreeRMutex(tok: *mut c_void) {
415 crate::xml::threads::free_rmutex(tok);
416}
417
418#[no_mangle]
426pub unsafe extern "C" fn xmlRMutexLock(tok: *mut c_void) {
427 crate::xml::threads::rmutex_lock(tok);
428}
429
430#[no_mangle]
438pub unsafe extern "C" fn xmlRMutexUnlock(tok: *mut c_void) {
439 crate::xml::threads::rmutex_unlock(tok);
440}
441
442#[no_mangle]
452pub const extern "C" fn xmlCheckThreadLocalStorage() -> c_int {
453 0
456}
457
458#[no_mangle]
469pub unsafe extern "C" fn xmlInitThreads() {
470 let _ = unsafe { crate::internal::globals::init_threads() };
471}
472
473#[no_mangle]
481pub unsafe extern "C" fn xmlCleanupThreads() {
482 crate::xml::threads::cleanup_threads();
483}
484
485#[no_mangle]
493pub extern "C" fn xmlIsInitialized() -> c_int {
494 if crate::abi::versioning::is_initialized() {
495 1
496 } else {
497 0
498 }
499}
500
501#[no_mangle]
510pub const unsafe extern "C" fn xmlLockLibrary() {
511 crate::xml::threads::lock_library();
512}
513
514#[no_mangle]
522pub const unsafe extern "C" fn xmlUnlockLibrary() {
523 crate::xml::threads::unlock_library();
524}
525
526#[no_mangle]
543pub unsafe extern "C" fn xmlSetGenericErrorFunc(
544 ctx: *mut c_void,
545 handler: Option<xmlGenericErrorFunc>,
546) {
547 unsafe { crate::xml::errors::set_generic_error_func(ctx, handler) };
549}
550
551#[no_mangle]
563pub unsafe extern "C" fn xmlSetStructuredErrorFunc(
564 ctx: *mut c_void,
565 handler: Option<xmlStructuredErrorFunc>,
566) {
567 unsafe { crate::xml::errors::set_structured_error_func(ctx, handler) };
569}
570
571#[no_mangle]
582pub extern "C" fn xmlGetLastError() -> *mut _xmlError {
583 crate::xml::errors::get_last_error()
584}
585
586#[no_mangle]
600pub const unsafe extern "C" fn xmlCopyError(from: *const _xmlError, to: *mut _xmlError) -> c_int {
601 unsafe { crate::xml::errors::copy_error(from, to) }
603}
604
605#[no_mangle]
617pub const unsafe extern "C" fn xmlResetError(err: *mut _xmlError) {
618 unsafe { crate::xml::errors::reset_error(err) };
620}
621
622#[no_mangle]
635pub unsafe extern "C" fn xmlRaiseError(
636 ctxt: *mut c_void,
637 ctxt2: *mut c_void,
638 ctxt3: *mut c_void,
639 ctxt4: *mut c_void,
640 ctxt5: *mut c_void,
641 domain: c_int,
642 code: c_int,
643 level: c_int,
644 file: *const c_char,
645 line: c_int,
646 str1: *const c_char,
647 str2: *const c_char,
648 str3: *const c_char,
649 int1: c_int,
650 int2: c_int,
651 msg: *const c_char,
652) {
653 unsafe {
655 crate::xml::errors::raise_error(
656 ctxt, ctxt2, ctxt3, ctxt4, ctxt5, domain, code, level, file, line, str1, str2, str3,
657 int1, int2, msg,
658 );
659 }
660}
661
662#[no_mangle]
670pub extern "C" fn xmlResetLastError() {
671 crate::xml::errors::reset_last_error();
672}
673
674#[no_mangle]
690pub unsafe extern "C" fn xmlStrdup(cur: *const xmlChar) -> *mut xmlChar {
691 if cur.is_null() {
692 return ptr::null_mut();
693 }
694 let len = unsafe { xmlStrlen(cur) };
695 let size = len + 1;
696 let new_ptr = unsafe { xmlMallocImpl(size as usize) };
697 if new_ptr.is_null() {
698 return ptr::null_mut();
699 }
700 unsafe {
701 ptr::copy_nonoverlapping(cur, new_ptr as *mut u8, size as usize);
702 }
703 new_ptr as *mut xmlChar
704}
705
706#[no_mangle]
718pub unsafe extern "C" fn xmlStrndup(cur: *const xmlChar, len: c_int) -> *mut xmlChar {
719 if cur.is_null() || len <= 0 {
720 return ptr::null_mut();
721 }
722 let size = len as usize + 1;
723 let new_ptr = unsafe { xmlMallocImpl(size) };
724 if new_ptr.is_null() {
725 return ptr::null_mut();
726 }
727 unsafe {
728 ptr::copy_nonoverlapping(cur, new_ptr as *mut u8, len as usize);
729 *(new_ptr.add(len as usize) as *mut u8) = 0;
730 }
731 new_ptr as *mut xmlChar
732}
733
734#[no_mangle]
746pub unsafe extern "C" fn xmlStrlen(str: *const xmlChar) -> c_int {
747 if str.is_null() {
748 return 0;
749 }
750 unsafe { libc::strlen(str as *const c_char) as c_int }
751}
752
753#[no_mangle]
766pub const unsafe extern "C" fn xmlStrchr(str: *const xmlChar, val: xmlChar) -> *const xmlChar {
767 if str.is_null() {
768 return ptr::null();
769 }
770 unsafe {
771 let mut cur = str;
772 while *cur != 0 {
773 if *cur == val {
774 return cur;
775 }
776 cur = cur.add(1);
777 }
778 ptr::null()
779 }
780}
781
782#[no_mangle]
793pub unsafe extern "C" fn xmlStrcmp(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
794 if str1.is_null() && str2.is_null() {
795 return 0;
796 }
797 if str1.is_null() {
798 return -1;
799 }
800 if str2.is_null() {
801 return 1;
802 }
803 unsafe { libc::strcmp(str1 as *const c_char, str2 as *const c_char) as c_int }
804}
805
806#[no_mangle]
814pub unsafe extern "C" fn xmlStrncmp(
815 str1: *const xmlChar,
816 str2: *const xmlChar,
817 len: c_int,
818) -> c_int {
819 if len <= 0 {
820 return 0;
821 }
822 if str1.is_null() && str2.is_null() {
823 return 0;
824 }
825 if str1.is_null() {
826 return -1;
827 }
828 if str2.is_null() {
829 return 1;
830 }
831 unsafe { libc::strncmp(str1 as *const c_char, str2 as *const c_char, len as usize) as c_int }
832}
833
834#[no_mangle]
842pub unsafe extern "C" fn xmlStrcasecmp(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
843 if str1.is_null() && str2.is_null() {
844 return 0;
845 }
846 if str1.is_null() {
847 return -1;
848 }
849 if str2.is_null() {
850 return 1;
851 }
852 unsafe { libc::strcasecmp(str1 as *const c_char, str2 as *const c_char) as c_int }
853}
854
855#[no_mangle]
863pub unsafe extern "C" fn xmlStrncasecmp(
864 str1: *const xmlChar,
865 str2: *const xmlChar,
866 len: c_int,
867) -> c_int {
868 if len <= 0 {
869 return 0;
870 }
871 if str1.is_null() && str2.is_null() {
872 return 0;
873 }
874 if str1.is_null() {
875 return -1;
876 }
877 if str2.is_null() {
878 return 1;
879 }
880 unsafe {
881 libc::strncasecmp(str1 as *const c_char, str2 as *const c_char, len as usize) as c_int
882 }
883}
884
885#[no_mangle]
895pub unsafe extern "C" fn xmlStrEqual(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
896 if str1.is_null() && str2.is_null() {
897 return 1;
898 }
899 if str1.is_null() || str2.is_null() {
900 return 0;
901 }
902 unsafe { (libc::strcmp(str1 as *const c_char, str2 as *const c_char) == 0) as c_int }
903}
904
905#[no_mangle]
914pub unsafe extern "C" fn xmlBuildQName(
915 ncname: *const xmlChar,
916 prefix: *const xmlChar,
917 memory: *mut xmlChar,
918 len: c_int,
919) -> *mut xmlChar {
920 crate::xml::string::build_qname(ncname, prefix, memory, len)
921}
922
923#[no_mangle]
931pub unsafe extern "C" fn xmlSplitQName2(
932 name: *const xmlChar,
933 prefix: *mut *mut xmlChar,
934) -> *mut xmlChar {
935 crate::xml::string::split_qname2(name, prefix)
936}
937
938#[no_mangle]
948pub unsafe extern "C" fn xmlSplitQName3(name: *const xmlChar, len: *mut c_int) -> *mut xmlChar {
949 crate::xml::string::split_qname3(name, len)
950}
951
952#[no_mangle]
967pub unsafe extern "C" fn xmlSplitQName(
968 _ctxt: *mut _xmlParserCtxt,
969 name: *const xmlChar,
970 prefix: *mut *mut xmlChar,
971) -> *mut xmlChar {
972 crate::xml::string::split_qname2(name, prefix)
973}
974
975#[no_mangle]
983pub const unsafe extern "C" fn xmlUTF8Strlen(utf: *const xmlChar) -> c_int {
984 crate::xml::string::utf8_strlen(utf)
985}
986
987#[no_mangle]
995pub const unsafe extern "C" fn xmlUTF8Size(utf: *const xmlChar) -> c_int {
996 crate::xml::string::utf8_size(utf)
997}
998
999#[no_mangle]
1007pub const unsafe extern "C" fn xmlCheckUTF8(utf: *const xmlChar) -> c_int {
1008 crate::xml::string::check_utf8(utf)
1009}
1010
1011#[no_mangle]
1022pub unsafe extern "C" fn xmlStrQEqual(
1023 pref: *const xmlChar,
1024 name: *const xmlChar,
1025 str: *const xmlChar,
1026) -> c_int {
1027 if name.is_null() || str.is_null() {
1028 return 0;
1029 }
1030 if pref.is_null() {
1031 return unsafe { xmlStrEqual(name, str) };
1032 }
1033 let pref_len = unsafe { xmlStrlen(pref) };
1035 let name_len = unsafe { xmlStrlen(name) };
1036 let total_len = pref_len + 1 + name_len;
1037 let str_len = unsafe { xmlStrlen(str) };
1038 if total_len != str_len {
1039 return 0;
1040 }
1041 if unsafe {
1043 libc::strncmp(
1044 pref as *const c_char,
1045 str as *const c_char,
1046 pref_len as usize,
1047 )
1048 } != 0
1049 {
1050 return 0;
1051 }
1052 if unsafe { *str.add(pref_len as usize) } != b':' as xmlChar {
1054 return 0;
1055 }
1056 (unsafe {
1058 libc::strncmp(
1059 name as *const c_char,
1060 str.add((pref_len + 1) as usize) as *const c_char,
1061 name_len as usize,
1062 ) == 0
1063 }) as c_int
1064}
1065
1066#[no_mangle]
1080pub unsafe extern "C" fn xmlStrcat(cur: *mut xmlChar, add: *const xmlChar) -> *mut xmlChar {
1081 if add.is_null() {
1082 return cur;
1083 }
1084 if cur.is_null() {
1085 return unsafe { xmlStrdup(add) };
1086 }
1087 let cur_len = unsafe { xmlStrlen(cur) } as usize;
1088 let add_len = unsafe { xmlStrlen(add) } as usize;
1089 let new_size = cur_len + add_len + 1;
1090 let new_ptr = unsafe { xmlReallocImpl(cur as *mut c_void, new_size) };
1091 if new_ptr.is_null() {
1092 return ptr::null_mut();
1093 }
1094 unsafe {
1095 ptr::copy_nonoverlapping(add, (new_ptr as *mut u8).add(cur_len), add_len);
1096 *((new_ptr as *mut u8).add(cur_len + add_len)) = 0;
1097 }
1098 new_ptr as *mut xmlChar
1099}
1100
1101#[no_mangle]
1113pub unsafe extern "C" fn xmlStrncat(
1114 cur: *mut xmlChar,
1115 add: *const xmlChar,
1116 len: c_int,
1117) -> *mut xmlChar {
1118 if add.is_null() || len <= 0 {
1119 return cur;
1120 }
1121 let len = len as usize;
1122 if cur.is_null() {
1123 return unsafe { xmlStrndup(add, len as c_int) };
1124 }
1125 let cur_len = unsafe { xmlStrlen(cur) } as usize;
1126 let new_size = cur_len + len + 1;
1127 let new_ptr = unsafe { xmlReallocImpl(cur as *mut c_void, new_size) };
1128 if new_ptr.is_null() {
1129 return ptr::null_mut();
1130 }
1131 unsafe {
1132 ptr::copy_nonoverlapping(add, (new_ptr as *mut u8).add(cur_len), len);
1133 *((new_ptr as *mut u8).add(cur_len + len)) = 0;
1134 }
1135 new_ptr as *mut xmlChar
1136}
1137
1138#[no_mangle]
1146pub unsafe extern "C" fn xmlStrncatNew(
1147 str1: *const xmlChar,
1148 str2: *const xmlChar,
1149 len: c_int,
1150) -> *mut xmlChar {
1151 let mut result: *mut xmlChar = ptr::null_mut();
1152 if !str1.is_null() {
1153 result = unsafe { xmlStrdup(str1) };
1154 }
1155 if !str2.is_null() && len > 0 {
1156 result = unsafe { xmlStrncat(result, str2, len) };
1157 }
1158 result
1159}
1160
1161#[no_mangle]
1174pub unsafe extern "C" fn xmlStrcpy(dst: *mut xmlChar, src: *const xmlChar) -> *mut xmlChar {
1175 if dst.is_null() || src.is_null() {
1176 return dst;
1177 }
1178 let len = unsafe { xmlStrlen(src) } as usize + 1;
1179 unsafe {
1180 ptr::copy_nonoverlapping(src, dst, len);
1181 }
1182 dst
1183}
1184
1185#[no_mangle]
1193pub unsafe extern "C" fn xmlStrncpy(
1194 dst: *mut xmlChar,
1195 src: *const xmlChar,
1196 len: c_int,
1197) -> *mut xmlChar {
1198 if dst.is_null() || src.is_null() || len <= 0 {
1199 return dst;
1200 }
1201 let len = len as usize;
1202 let src_len = unsafe { xmlStrlen(src) } as usize;
1203 let copy_len = if src_len < len { src_len } else { len - 1 };
1204 unsafe {
1205 ptr::copy_nonoverlapping(src, dst, copy_len);
1206 *dst.add(copy_len) = 0;
1207 }
1208 dst
1209}
1210
1211#[no_mangle]
1221pub unsafe extern "C" fn xmlStrsub(str: *const xmlChar, start: c_int, len: c_int) -> *mut xmlChar {
1222 if str.is_null() || start < 0 || len < 0 {
1223 return ptr::null_mut();
1224 }
1225 let str_len = unsafe { xmlStrlen(str) };
1226 if start >= str_len {
1227 return unsafe { xmlStrdup(b"\0" as *const u8 as *const xmlChar) };
1228 }
1229 let actual_len = if start + len > str_len {
1230 str_len - start
1231 } else {
1232 len
1233 };
1234 unsafe { xmlStrndup(str.add(start as usize), actual_len) }
1235}
1236
1237#[no_mangle]
1254pub unsafe extern "C" fn xmlNewDoc(version: *const xmlChar) -> *mut _xmlDoc {
1255 crate::xml::tree::new_doc(version)
1256}
1257
1258#[no_mangle]
1270pub unsafe extern "C" fn xmlFreeDoc(doc: *mut _xmlDoc) {
1271 crate::xml::tree::free_doc(doc);
1272}
1273
1274#[no_mangle]
1284pub unsafe extern "C" fn xmlGetDocCompressMode(doc: *mut _xmlDoc) -> c_int {
1285 crate::xml::tree::xmlGetDocCompressMode(doc)
1286}
1287
1288#[no_mangle]
1296pub unsafe extern "C" fn xmlSetDocCompressMode(doc: *mut _xmlDoc, mode: c_int) {
1297 crate::xml::tree::xmlSetDocCompressMode(doc, mode);
1298}
1299
1300#[no_mangle]
1314pub unsafe extern "C" fn xmlNewNode(ns: *mut _xmlNs, name: *const xmlChar) -> *mut _xmlNode {
1315 crate::xml::tree::new_node(ns, name)
1316}
1317
1318#[no_mangle]
1331pub unsafe extern "C" fn xmlFreeNode(node: *mut _xmlNode) {
1332 crate::xml::tree::free_node(node);
1333}
1334
1335#[no_mangle]
1352pub unsafe extern "C" fn xmlFreeNodeList(node: *mut _xmlNode) {
1353 crate::xml::tree::free_node_list(node);
1354}
1355
1356#[no_mangle]
1368pub unsafe extern "C" fn xmlUnlinkNode(node: *mut _xmlNode) {
1369 crate::xml::tree::unlink_node(node);
1370}
1371
1372#[no_mangle]
1388pub unsafe extern "C" fn xmlSAX2InitDefaultSAXHandler(
1389 handler: *mut crate::abi::structs::_xmlSAXHandler,
1390 _warning: c_int,
1391) {
1392 crate::xml::sax::dispatch::xmlSAX2InitDefaultSAXHandler(handler);
1393}
1394
1395#[no_mangle]
1414pub unsafe extern "C" fn xmlSAX2InitHtmlDefaultSAXHandler(
1415 handler: *mut crate::abi::structs::_xmlSAXHandler,
1416) {
1417 if handler.is_null() {
1418 return;
1419 }
1420 unsafe {
1422 if (*handler).initialized != 0 {
1424 return;
1425 }
1426 crate::xml::sax::dispatch::xmlSAX2InitDefaultSAXHandler(handler);
1427 let h = &mut *handler;
1428 h.resolveEntity = None;
1429 h.getParameterEntity = None;
1430 h.entityDecl = None;
1431 h.attributeDecl = None;
1432 h.elementDecl = None;
1433 h.notationDecl = None;
1434 h.unparsedEntityDecl = None;
1435 h.reference = None;
1436 h.externalSubset = None;
1437 h.initialized = 1;
1438 }
1439}
1440
1441#[no_mangle]
1455pub unsafe extern "C" fn xmlAddChild(parent: *mut _xmlNode, cur: *mut _xmlNode) -> *mut _xmlNode {
1456 crate::xml::tree::add_child(parent, cur)
1457}
1458
1459#[no_mangle]
1471pub unsafe extern "C" fn xmlAddSibling(
1472 cur: *mut _xmlNode,
1473 sibling: *mut _xmlNode,
1474) -> *mut _xmlNode {
1475 crate::xml::tree::add_sibling(cur, sibling)
1476}
1477
1478#[no_mangle]
1497pub unsafe extern "C" fn xmlNewChild(
1498 parent: *mut _xmlNode,
1499 ns: *mut _xmlNs,
1500 name: *const xmlChar,
1501 content: *const xmlChar,
1502) -> *mut _xmlNode {
1503 if parent.is_null() || name.is_null() {
1507 return ptr::null_mut();
1508 }
1509 let node = crate::xml::tree::new_child(parent, ns, name);
1510 if node.is_null() {
1511 return ptr::null_mut();
1512 }
1513 if !content.is_null() {
1514 let text = crate::xml::tree::new_text(content);
1515 if !text.is_null() {
1516 crate::xml::tree::add_child(node, text);
1517 }
1518 }
1519 node
1520}
1521
1522#[no_mangle]
1537pub unsafe extern "C" fn xmlDocSetRootElement(
1538 doc: *mut _xmlDoc,
1539 root: *mut _xmlNode,
1540) -> *mut _xmlNode {
1541 crate::xml::tree::doc_set_root_element(doc, root)
1542}
1543
1544#[no_mangle]
1554pub extern "C" fn xmlDocGetRootElement(doc: *const _xmlDoc) -> *mut _xmlNode {
1555 crate::xml::tree::doc_get_root_element(doc as *mut _xmlDoc)
1556}
1557
1558#[no_mangle]
1571pub unsafe extern "C" fn xmlCopyNode(node: *const _xmlNode, extended: c_int) -> *mut _xmlNode {
1572 crate::xml::tree::copy_node(node, extended)
1573}
1574
1575#[no_mangle]
1585pub unsafe extern "C" fn xmlCopyDoc(doc: *const _xmlDoc, recursive: c_int) -> *mut _xmlDoc {
1586 crate::xml::tree::copy_doc(doc, recursive)
1587}
1588
1589#[no_mangle]
1600pub unsafe extern "C" fn xmlNewText(content: *const xmlChar) -> *mut _xmlNode {
1601 crate::xml::tree::new_text(content)
1602}
1603
1604#[no_mangle]
1612pub unsafe extern "C" fn xmlNewComment(content: *const xmlChar) -> *mut _xmlNode {
1613 crate::xml::tree::new_comment(content)
1614}
1615
1616#[no_mangle]
1624pub unsafe extern "C" fn xmlNewPI(name: *const xmlChar, content: *const xmlChar) -> *mut _xmlNode {
1625 crate::xml::tree::new_pi(name, content)
1626}
1627
1628#[no_mangle]
1636pub unsafe extern "C" fn xmlNewCDataBlock(
1637 doc: *mut _xmlDoc,
1638 content: *const xmlChar,
1639 len: c_int,
1640) -> *mut _xmlNode {
1641 crate::xml::tree::new_cdata_block(doc, content, len)
1642}
1643
1644#[no_mangle]
1658pub unsafe extern "C" fn xmlNewNs(
1659 node: *mut _xmlNode,
1660 href: *const xmlChar,
1661 prefix: *const xmlChar,
1662) -> *mut _xmlNs {
1663 crate::xml::tree::new_ns(node, href, prefix)
1664}
1665
1666#[no_mangle]
1674pub unsafe extern "C" fn xmlSetNs(node: *mut _xmlNode, ns: *mut _xmlNs) {
1675 crate::xml::tree::set_ns(node, ns);
1676}
1677
1678#[no_mangle]
1686pub unsafe extern "C" fn xmlGetNsList(
1687 doc: *mut _xmlDoc,
1688 node: *const _xmlNode,
1689) -> *mut *mut _xmlNs {
1690 crate::xml::tree::get_ns_list(doc, node as *mut _xmlNode)
1691}
1692
1693#[no_mangle]
1701pub unsafe extern "C" fn xmlSearchNs(
1702 doc: *mut _xmlDoc,
1703 node: *mut _xmlNode,
1704 nameSpace: *const xmlChar,
1705) -> *mut _xmlNs {
1706 crate::xml::tree::search_ns(doc, node, nameSpace)
1707}
1708
1709#[no_mangle]
1717pub unsafe extern "C" fn xmlSearchNsByHref(
1718 doc: *mut _xmlDoc,
1719 node: *mut _xmlNode,
1720 href: *const xmlChar,
1721) -> *mut _xmlNs {
1722 crate::xml::tree::search_ns_by_href(doc, node, href)
1723}
1724
1725#[no_mangle]
1742pub unsafe extern "C" fn xmlSetProp(
1743 node: *mut _xmlNode,
1744 name: *const xmlChar,
1745 value: *const xmlChar,
1746) -> *mut _xmlAttr {
1747 crate::xml::tree::set_prop(node, name, value)
1748}
1749
1750#[no_mangle]
1760pub unsafe extern "C" fn xmlGetProp(node: *const _xmlNode, name: *const xmlChar) -> *mut xmlChar {
1761 crate::xml::tree::get_prop(node as *mut _xmlNode, name)
1762}
1763
1764#[no_mangle]
1772pub unsafe extern "C" fn xmlGetNsProp(
1773 node: *const _xmlNode,
1774 name: *const xmlChar,
1775 nameSpace: *const xmlChar,
1776) -> *mut xmlChar {
1777 crate::xml::tree::get_ns_prop(node as *mut _xmlNode, name, nameSpace)
1778}
1779
1780#[no_mangle]
1789pub unsafe extern "C" fn xmlSetNsProp(
1790 node: *mut _xmlNode,
1791 ns: *mut _xmlNs,
1792 name: *const xmlChar,
1793 value: *const xmlChar,
1794) -> *mut _xmlAttr {
1795 crate::xml::tree::set_ns_prop(node, ns, name, value)
1796}
1797
1798#[no_mangle]
1808pub unsafe extern "C" fn xmlRemoveProp(attr: *mut _xmlAttr) -> c_int {
1809 crate::xml::tree::remove_prop(attr)
1810}
1811
1812#[no_mangle]
1822pub unsafe extern "C" fn xmlHasProp(node: *const _xmlNode, name: *const xmlChar) -> *mut _xmlAttr {
1823 crate::xml::tree::has_prop(node as *mut _xmlNode, name)
1824}
1825
1826#[no_mangle]
1835pub unsafe extern "C" fn xmlHasNsProp(
1836 node: *const _xmlNode,
1837 name: *const xmlChar,
1838 nameSpace: *const xmlChar,
1839) -> *mut _xmlAttr {
1840 crate::xml::tree::has_ns_prop(node as *mut _xmlNode, name, nameSpace)
1841}
1842
1843#[no_mangle]
1853pub unsafe extern "C" fn xmlUnsetProp(node: *mut _xmlNode, name: *const xmlChar) -> c_int {
1854 crate::xml::tree::unset_prop(node, name)
1855}
1856
1857#[no_mangle]
1866pub unsafe extern "C" fn xmlUnsetNsProp(
1867 node: *mut _xmlNode,
1868 name: *const xmlChar,
1869 nameSpace: *const xmlChar,
1870) -> c_int {
1871 crate::xml::tree::unset_ns_prop(node, name, nameSpace)
1872}
1873
1874#[no_mangle]
1882pub unsafe extern "C" fn xmlFirstElementChild(parent: *mut _xmlNode) -> *mut _xmlNode {
1883 crate::xml::tree::first_element_child(parent)
1884}
1885
1886#[no_mangle]
1888pub unsafe extern "C" fn xmlLastElementChild(parent: *mut _xmlNode) -> *mut _xmlNode {
1889 crate::xml::tree::last_element_child(parent)
1890}
1891
1892#[no_mangle]
1894pub unsafe extern "C" fn xmlNextElementSibling(node: *mut _xmlNode) -> *mut _xmlNode {
1895 crate::xml::tree::next_element_sibling(node)
1896}
1897
1898#[no_mangle]
1900pub unsafe extern "C" fn xmlPreviousElementSibling(node: *mut _xmlNode) -> *mut _xmlNode {
1901 crate::xml::tree::previous_element_sibling(node)
1902}
1903
1904#[no_mangle]
1912pub unsafe extern "C" fn xmlChildElementCount(parent: *mut _xmlNode) -> c_ulong {
1913 crate::xml::tree::child_element_count(parent)
1914}
1915
1916#[no_mangle]
1924pub unsafe extern "C" fn xmlTextConcat(
1925 node: *mut _xmlNode,
1926 content: *const xmlChar,
1927 len: c_int,
1928) -> c_int {
1929 crate::xml::tree::text_concat(node, content, len)
1930}
1931
1932#[no_mangle]
1940pub unsafe extern "C" fn xmlTextMerge(
1941 first: *mut _xmlNode,
1942 second: *mut _xmlNode,
1943) -> *mut _xmlNode {
1944 crate::xml::tree::text_merge(first, second)
1945}
1946
1947#[no_mangle]
1955pub const extern "C" fn xmlGetIntSubset(doc: *const _xmlDoc) -> *mut _xmlDtd {
1956 crate::xml::tree::get_int_subset(doc)
1957}
1958
1959#[no_mangle]
1968pub unsafe extern "C" fn xmlNewDtd(
1969 doc: *mut _xmlDoc,
1970 name: *const xmlChar,
1971 ExternalID: *const xmlChar,
1972 SystemID: *const xmlChar,
1973) -> *mut _xmlDtd {
1974 crate::xml::tree::new_dtd(doc, name, ExternalID, SystemID)
1975}
1976
1977#[no_mangle]
1987pub unsafe extern "C" fn xmlNewEntity(
1988 doc: *mut _xmlDoc,
1989 name: *const xmlChar,
1990 type_: c_int,
1991 ExternalID: *const xmlChar,
1992 SystemID: *const xmlChar,
1993 content: *const xmlChar,
1994) -> *mut _xmlEntity {
1995 crate::xml::tree::new_entity(doc, name, type_, ExternalID, SystemID, content)
1996}
1997
1998#[no_mangle]
2006pub unsafe extern "C" fn xmlGetDocEntity(
2007 doc: *const _xmlDoc,
2008 name: *const xmlChar,
2009) -> *mut _xmlEntity {
2010 crate::xml::tree::get_doc_entity(doc, name)
2011}
2012
2013#[no_mangle]
2021pub unsafe extern "C" fn xmlGetParameterEntity(
2022 doc: *const _xmlDoc,
2023 name: *const xmlChar,
2024) -> *mut _xmlEntity {
2025 crate::xml::tree::get_parameter_entity(doc, name)
2026}
2027
2028#[no_mangle]
2039pub unsafe extern "C" fn xmlCreateIntSubset(
2040 doc: *mut _xmlDoc,
2041 name: *const xmlChar,
2042 ExternalID: *const xmlChar,
2043 SystemID: *const xmlChar,
2044) -> *mut _xmlDtd {
2045 crate::xml::dtd::create_int_subset(doc, name, ExternalID, SystemID)
2046}
2047
2048#[no_mangle]
2056pub unsafe extern "C" fn xmlFreeDtd(dtd: *mut _xmlDtd) {
2057 crate::xml::dtd::free_dtd(dtd);
2058}
2059
2060#[no_mangle]
2076pub unsafe extern "C" fn xmlAddNotationDecl(
2077 _ctxt: *mut _xmlValidCtxt,
2078 dtd: *mut _xmlDtd,
2079 name: *const xmlChar,
2080 PublicID: *const xmlChar,
2081 SystemID: *const xmlChar,
2082) -> *mut _xmlNotation {
2083 crate::xml::dtd::add_notation_decl(dtd, name, PublicID, SystemID)
2084}
2085
2086#[no_mangle]
2094pub unsafe extern "C" fn xmlGetNotationDecl(
2095 dtd: *mut _xmlDtd,
2096 name: *const xmlChar,
2097) -> *mut _xmlNotation {
2098 crate::xml::dtd::get_notation_decl(dtd, name)
2099}
2100
2101#[no_mangle]
2109pub unsafe extern "C" fn xmlCopyNotation(notation: *mut _xmlNotation) -> *mut _xmlNotation {
2110 crate::xml::dtd::copy_notation(notation)
2111}
2112
2113#[no_mangle]
2121pub unsafe extern "C" fn xmlFreeNotation(notation: *mut _xmlNotation) {
2122 crate::xml::dtd::free_notation(notation);
2123}
2124
2125#[no_mangle]
2139pub unsafe extern "C" fn xmlAddElementDecl(
2140 _ctxt: *mut _xmlValidCtxt,
2141 dtd: *mut _xmlDtd,
2142 name: *const xmlChar,
2143 type_: c_int,
2144 content: *mut _xmlElementContent,
2145) -> *mut _xmlElement {
2146 crate::xml::dtd::add_element_decl(dtd, name, type_, content)
2147}
2148
2149#[no_mangle]
2157pub unsafe extern "C" fn xmlGetElementDecl(
2158 dtd: *mut _xmlDtd,
2159 name: *const xmlChar,
2160) -> *mut _xmlElement {
2161 crate::xml::dtd::get_element_decl(dtd, name)
2162}
2163
2164#[no_mangle]
2172pub unsafe extern "C" fn xmlCopyElement(elem: *mut _xmlElement) -> *mut _xmlElement {
2173 crate::xml::dtd::copy_element(elem)
2174}
2175
2176#[no_mangle]
2184pub unsafe extern "C" fn xmlFreeElement(elem: *mut _xmlElement) {
2185 crate::xml::dtd::free_element(elem);
2186}
2187
2188#[no_mangle]
2207pub unsafe extern "C" fn xmlAddAttributeDecl(
2208 _ctxt: *mut _xmlValidCtxt,
2209 dtd: *mut _xmlDtd,
2210 elem: *mut _xmlElement,
2211 name: *const xmlChar,
2212 ns: *const xmlChar,
2213 type_: c_int,
2214 def: c_int,
2215 defaultValue: *const xmlChar,
2216 tree: *mut _xmlEnumeration,
2217) -> *mut _xmlAttribute {
2218 crate::xml::dtd::add_attribute_decl(dtd, elem, name, ns, type_, def, defaultValue, tree)
2219}
2220
2221#[no_mangle]
2230pub unsafe extern "C" fn xmlGetAttributeDecl(
2231 dtd: *mut _xmlDtd,
2232 elem: *mut _xmlElement,
2233 name: *const xmlChar,
2234 namePrefix: c_int,
2235) -> *mut _xmlAttribute {
2236 crate::xml::dtd::get_attribute_decl(dtd, elem, name, namePrefix)
2237}
2238
2239#[no_mangle]
2247pub unsafe extern "C" fn xmlCopyAttribute(attr: *mut _xmlAttribute) -> *mut _xmlAttribute {
2248 crate::xml::dtd::copy_attribute_decl(attr)
2249}
2250
2251#[no_mangle]
2259pub unsafe extern "C" fn xmlFreeAttribute(attr: *mut _xmlAttribute) {
2260 crate::xml::dtd::free_attribute(attr);
2261}
2262
2263#[no_mangle]
2271pub unsafe extern "C" fn xmlNewElementContent(
2272 name: *const xmlChar,
2273 type_: c_int,
2274) -> *mut _xmlElementContent {
2275 crate::xml::dtd::create_content_model(name, type_)
2276}
2277
2278#[no_mangle]
2286pub unsafe extern "C" fn xmlCopyElementContent(
2287 content: *mut _xmlElementContent,
2288) -> *mut _xmlElementContent {
2289 crate::xml::dtd::copy_content_model(content)
2290}
2291
2292#[no_mangle]
2300pub unsafe extern "C" fn xmlFreeElementContent(cur: *mut _xmlElementContent) {
2301 crate::xml::dtd::free_content_model(cur);
2302}
2303
2304#[no_mangle]
2324pub unsafe extern "C" fn xmlAddEntity(
2325 doc: *mut _xmlDoc,
2326 extSubset: c_int,
2327 name: *const xmlChar,
2328 type_: c_int,
2329 publicId: *const xmlChar,
2330 systemId: *const xmlChar,
2331 content: *const xmlChar,
2332 out: *mut *mut _xmlEntity,
2333) -> c_int {
2334 crate::xml::entities::add_entity_doc(
2335 doc, extSubset, name, type_, publicId, systemId, content, out,
2336 )
2337}
2338
2339#[no_mangle]
2351pub unsafe extern "C" fn xmlAddDocEntity(
2352 doc: *mut _xmlDoc,
2353 name: *const xmlChar,
2354 type_: c_int,
2355 ExternalID: *const xmlChar,
2356 SystemID: *const xmlChar,
2357 content: *const xmlChar,
2358) -> *mut _xmlEntity {
2359 crate::xml::tree::add_doc_entity(doc, name, type_, ExternalID, SystemID, content)
2360}
2361
2362#[no_mangle]
2373pub unsafe extern "C" fn xmlAddDtdEntity(
2374 doc: *mut _xmlDoc,
2375 name: *const xmlChar,
2376 type_: c_int,
2377 ExternalID: *const xmlChar,
2378 SystemID: *const xmlChar,
2379 content: *const xmlChar,
2380) -> *mut _xmlEntity {
2381 crate::xml::tree::add_dtd_entity(doc, name, type_, ExternalID, SystemID, content)
2382}
2383
2384#[no_mangle]
2393pub unsafe extern "C" fn xmlGetDtdEntity(
2394 doc: *mut _xmlDoc,
2395 name: *const xmlChar,
2396) -> *mut _xmlEntity {
2397 crate::xml::tree::get_dtd_entity(doc, name)
2398}
2399
2400#[no_mangle]
2408pub unsafe extern "C" fn xmlGetEntity(doc: *mut _xmlDoc, name: *const xmlChar) -> *mut _xmlEntity {
2409 crate::xml::entities::get_entity(doc, name)
2410}
2411
2412#[no_mangle]
2420pub unsafe extern "C" fn xmlCopyEntity(entity: *mut _xmlEntity) -> *mut _xmlEntity {
2421 crate::xml::entities::copy_entity(entity)
2422}
2423
2424#[no_mangle]
2432pub unsafe extern "C" fn xmlFreeEntity(entity: *mut _xmlEntity) {
2433 crate::xml::entities::free_entity(entity);
2434}
2435
2436#[no_mangle]
2444pub unsafe extern "C" fn xmlEncodeEntitiesReentrant(
2445 doc: *mut _xmlDoc,
2446 input: *const xmlChar,
2447) -> *mut xmlChar {
2448 crate::xml::entities::encode_entities_reentrant(doc, input)
2449}
2450
2451#[no_mangle]
2462pub unsafe extern "C" fn xmlEncodeSpecialChars(
2463 _doc: *const _xmlDoc,
2464 input: *const xmlChar,
2465) -> *mut xmlChar {
2466 if input.is_null() {
2467 return ptr::null_mut();
2468 }
2469 unsafe {
2470 let len = crate::xml::string::xml_strlen(input);
2471 let cap = len * 6 + 1;
2474 let out = crate::abi::allocator::xmlMallocImpl(cap) as *mut xmlChar;
2475 if out.is_null() {
2476 return ptr::null_mut();
2477 }
2478 let mut o = 0usize;
2479 let mut i = 0usize;
2480 while i < len {
2481 let c = *input.add(i);
2482 let rep: &[u8] = match c {
2483 b'<' => b"<",
2484 b'>' => b">",
2485 b'&' => b"&",
2486 b'"' => b""",
2487 b'\r' => b" ",
2488 _ => {
2489 *out.add(o) = c;
2490 o += 1;
2491 i += 1;
2492 continue;
2493 }
2494 };
2495 core::ptr::copy_nonoverlapping(rep.as_ptr(), out.add(o), rep.len());
2496 o += rep.len();
2497 i += 1;
2498 }
2499 *out.add(o) = 0;
2500 out
2501 }
2502}
2503
2504#[no_mangle]
2515pub unsafe extern "C" fn xmlEncodeEntities(
2516 _doc: *mut _xmlDoc,
2517 _input: *const xmlChar,
2518) -> *mut xmlChar {
2519 use core::sync::atomic::{AtomicBool, Ordering};
2520 static WARNED: AtomicBool = AtomicBool::new(false);
2521 if !WARNED.swap(true, Ordering::Relaxed) {
2522 let msg = b"xmlEncodeEntities is deprecated, use xmlEncodeSpecialChars or xmlEncodeEntitiesReentrant\n";
2524 unsafe {
2525 libc::fwrite(
2526 msg.as_ptr() as *const c_void,
2527 1,
2528 msg.len(),
2529 libc::fdopen(2, b"w\0" as *const u8 as *const c_char),
2530 );
2531 }
2532 }
2533 ptr::null_mut()
2534}
2535
2536#[no_mangle]
2544pub extern "C" fn xmlGetLineNo(node: *const _xmlNode) -> c_long {
2545 crate::xml::tree::get_line_no(node)
2546}
2547
2548#[no_mangle]
2560pub unsafe extern "C" fn xmlNodeDump(
2561 buf: *mut _xmlBuffer,
2562 doc: *mut _xmlDoc,
2563 cur: *mut _xmlNode,
2564 level: c_int,
2565 format: c_int,
2566) -> c_int {
2567 if buf.is_null() || cur.is_null() {
2568 return -1;
2569 }
2570 crate::xml::tree::xmlNodeDump(buf, doc, cur, level, format)
2571}
2572
2573#[no_mangle]
2581pub unsafe extern "C" fn xmlDocDump(fp: *mut c_void, doc: *mut _xmlDoc) -> c_int {
2582 if fp.is_null() || doc.is_null() {
2583 return -1;
2584 }
2585 crate::xml::tree::xmlDocDump(fp, doc)
2586}
2587
2588#[no_mangle]
2596pub unsafe extern "C" fn xmlDocDumpFormatMemory(
2597 doc: *mut _xmlDoc,
2598 mem: *mut *mut xmlChar,
2599 size: *mut c_int,
2600 format: c_int,
2601) {
2602 if doc.is_null() || mem.is_null() || size.is_null() {
2603 return;
2604 }
2605 crate::xml::tree::xmlDocDumpFormatMemory(doc, mem, size, format)
2606}
2607
2608#[no_mangle]
2616pub unsafe extern "C" fn xmlDocDumpMemory(
2617 doc: *mut _xmlDoc,
2618 mem: *mut *mut xmlChar,
2619 size: *mut c_int,
2620) {
2621 if doc.is_null() || mem.is_null() || size.is_null() {
2622 return;
2623 }
2624 crate::xml::tree::xmlDocDumpMemory(doc, mem, size)
2625}
2626
2627#[no_mangle]
2635pub unsafe extern "C" fn xmlSaveFile(filename: *const c_char, cur: *mut _xmlDoc) -> c_int {
2636 if filename.is_null() || cur.is_null() {
2637 return -1;
2638 }
2639 crate::xml::tree::xmlSaveFile(filename, cur)
2640}
2641
2642#[no_mangle]
2650pub unsafe extern "C" fn xmlSaveFileEnc(
2651 filename: *const c_char,
2652 cur: *mut _xmlDoc,
2653 encoding: *const c_char,
2654) -> c_int {
2655 if filename.is_null() || cur.is_null() {
2656 return -1;
2657 }
2658 crate::xml::tree::xmlSaveFileEnc(filename, cur, encoding)
2659}
2660
2661#[no_mangle]
2669pub unsafe extern "C" fn xmlSaveFormatFile(
2670 filename: *const c_char,
2671 cur: *mut _xmlDoc,
2672 format: c_int,
2673) -> c_int {
2674 if filename.is_null() || cur.is_null() {
2675 return -1;
2676 }
2677 crate::xml::tree::xmlSaveFormatFile(filename, cur, format)
2678}
2679
2680#[no_mangle]
2688pub unsafe extern "C" fn xmlSaveFormatFileEnc(
2689 filename: *const c_char,
2690 cur: *mut _xmlDoc,
2691 encoding: *const c_char,
2692 format: c_int,
2693) -> c_int {
2694 if filename.is_null() || cur.is_null() {
2695 return -1;
2696 }
2697 crate::xml::tree::xmlSaveFormatFileEnc(filename, cur, encoding, format)
2698}
2699
2700#[no_mangle]
2715pub unsafe extern "C" fn xmlReadDoc(
2716 cur: *const xmlChar,
2717 URL: *const c_char,
2718 encoding: *const c_char,
2719 options: c_int,
2720) -> *mut _xmlDoc {
2721 if cur.is_null() {
2723 return ptr::null_mut();
2724 }
2725 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2726 if ctxt.is_null() {
2727 return ptr::null_mut();
2728 }
2729 let len = crate::xml::string::xml_strlen(cur);
2730 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2731 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2732 (*ctxt).options = options;
2733 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2734 let doc = (*ctxt).myDoc;
2735 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2736 return doc;
2737 }
2738 let doc = (*ctxt).myDoc;
2739 if !doc.is_null() {
2740 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2741 }
2742 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2743 doc
2744}
2745
2746#[no_mangle]
2754pub unsafe extern "C" fn xmlReadFile(
2755 URL: *const c_char,
2756 encoding: *const c_char,
2757 options: c_int,
2758) -> *mut _xmlDoc {
2759 if URL.is_null() {
2761 return ptr::null_mut();
2762 }
2763 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2764 if ctxt.is_null() {
2765 return ptr::null_mut();
2766 }
2767 let input = match crate::xml::parser::helpers::input_from_file(URL) {
2768 Ok(input) => input,
2769 Err(_) => {
2770 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2771 return ptr::null_mut();
2772 }
2773 };
2774 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2775 (*ctxt).options = options;
2776 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2777 let doc = (*ctxt).myDoc;
2778 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2779 if options & 1 << 0 != 0 {
2783 return doc;
2784 }
2785 if !doc.is_null() {
2786 crate::xml::tree::free_doc(doc);
2787 }
2788 return ptr::null_mut();
2789 }
2790 let doc = (*ctxt).myDoc;
2791 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2792 doc
2793}
2794
2795#[no_mangle]
2804pub unsafe extern "C" fn xmlRecoverDoc(cur: *const xmlChar) -> *mut _xmlDoc {
2805 unsafe { xmlReadDoc(cur, ptr::null(), ptr::null(), 1 << 0) }
2806}
2807
2808#[no_mangle]
2816pub unsafe extern "C" fn xmlRecoverFile(filename: *const c_char) -> *mut _xmlDoc {
2817 unsafe { xmlReadFile(filename, ptr::null(), 1 << 0) }
2818}
2819
2820#[no_mangle]
2828pub unsafe extern "C" fn xmlRecoverMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
2829 unsafe { xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 1 << 0) }
2830}
2831
2832#[no_mangle]
2841pub unsafe extern "C" fn xmlReadMemory(
2842 buffer: *const c_char,
2843 size: c_int,
2844 URL: *const c_char,
2845 encoding: *const c_char,
2846 options: c_int,
2847) -> *mut _xmlDoc {
2848 if buffer.is_null() || size < 0 {
2852 return ptr::null_mut();
2853 }
2854 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2855 if ctxt.is_null() {
2856 return ptr::null_mut();
2857 }
2858 let input = crate::xml::parser::helpers::input_from_memory_named(buffer, size, URL);
2861 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2862 crate::abi::exports_parser::apply_options(ctxt, options);
2866 let parsed = crate::xml::parser::helpers::parse_document(ctxt);
2867 let doc = (*ctxt).myDoc;
2868 if !doc.is_null() && !URL.is_null() && (*doc).URL.is_null() {
2871 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2872 }
2873 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2874 if parsed != 0 {
2875 if options & 1 << 0 != 0 {
2879 return doc;
2880 }
2881 if !doc.is_null() {
2882 crate::xml::tree::free_doc(doc);
2883 }
2884 return ptr::null_mut();
2885 }
2886 doc
2887}
2888
2889#[no_mangle]
2895pub unsafe extern "C" fn xmlLoadCatalogs(catalogs: *const c_char) {
2896 if !catalogs.is_null() {
2897 crate::xml::catalog::load_catalog(catalogs);
2898 }
2899}
2900
2901#[no_mangle]
2907pub unsafe extern "C" fn xmlLoadCatalog(catalogs: *const c_char) -> c_int {
2908 let handle = crate::xml::catalog::load_catalog(catalogs);
2911 if handle.is_null() {
2912 1
2913 } else {
2914 0
2915 }
2916}
2917
2918#[no_mangle]
2926pub unsafe extern "C" fn xmlReadFd(
2927 fd: c_int,
2928 URL: *const c_char,
2929 encoding: *const c_char,
2930 options: c_int,
2931) -> *mut _xmlDoc {
2932 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2934 if ctxt.is_null() {
2935 return ptr::null_mut();
2936 }
2937 let mut buf = Vec::new();
2939 let mut tmp = [0u8; 4096];
2940 loop {
2941 let n = libc::read(fd, tmp.as_mut_ptr() as *mut c_void, tmp.len());
2942 if n <= 0 {
2943 break;
2944 }
2945 buf.extend_from_slice(&tmp[..n as usize]);
2946 }
2947 let input = crate::xml::parser::helpers::input_from_memory(
2948 buf.as_ptr() as *const c_char,
2949 buf.len() as c_int,
2950 );
2951 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2952 (*ctxt).options = options;
2953 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2954 let doc = (*ctxt).myDoc;
2955 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2956 return doc;
2957 }
2958 let doc = (*ctxt).myDoc;
2959 if !doc.is_null() && !URL.is_null() {
2960 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2961 }
2962 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2963 doc
2964}
2965
2966#[no_mangle]
2975pub unsafe extern "C" fn xmlReadIO(
2976 ioread: Option<xmlInputReadCallback>,
2977 ioclose: Option<xmlInputCloseCallback>,
2978 ioctx: *mut c_void,
2979 URL: *const c_char,
2980 encoding: *const c_char,
2981 options: c_int,
2982) -> *mut _xmlDoc {
2983 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2985 if ctxt.is_null() {
2986 return ptr::null_mut();
2987 }
2988 let input = crate::xml::parser::helpers::input_from_io(ioread, ioclose, ioctx);
2989 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2990 (*ctxt).options = options;
2991 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2992 let doc = (*ctxt).myDoc;
2993 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2994 return doc;
2995 }
2996 let doc = (*ctxt).myDoc;
2997 if !doc.is_null() && !URL.is_null() {
2998 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2999 }
3000 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3001 doc
3002}
3003
3004#[no_mangle]
3012pub unsafe extern "C" fn xmlSAXParseDoc(
3013 sax: *mut _xmlSAXHandler,
3014 cur: *const xmlChar,
3015 recovery: c_int,
3016) -> *mut _xmlDoc {
3017 if cur.is_null() {
3019 return ptr::null_mut();
3020 }
3021 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3022 if ctxt.is_null() {
3023 return ptr::null_mut();
3024 }
3025 if !sax.is_null() {
3026 (*ctxt).sax = sax;
3027 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3028 }
3029 if recovery != 0 {
3030 (*ctxt).recovery = 1;
3031 (*ctxt).options |= 1; }
3033 let len = crate::xml::string::xml_strlen(cur);
3034 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
3035 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3036 crate::xml::parser::helpers::parse_document(ctxt);
3037 let doc = (*ctxt).myDoc;
3038 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3039 doc
3040}
3041
3042#[no_mangle]
3052pub unsafe extern "C" fn xmlSAXParseDocWithData(
3053 sax: *mut _xmlSAXHandler,
3054 cur: *const xmlChar,
3055 recovery: c_int,
3056 data: *mut c_void,
3057) -> *mut _xmlDoc {
3058 if cur.is_null() {
3060 return ptr::null_mut();
3061 }
3062 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3063 if ctxt.is_null() {
3064 return ptr::null_mut();
3065 }
3066 if !sax.is_null() {
3067 (*ctxt).sax = sax;
3068 }
3069 (*ctxt).userData = data;
3070 if recovery != 0 {
3071 (*ctxt).recovery = 1;
3072 (*ctxt).options |= 1; }
3074 let len = crate::xml::string::xml_strlen(cur);
3075 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
3076 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3077 crate::xml::parser::helpers::parse_document(ctxt);
3078 let doc = (*ctxt).myDoc;
3079 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3080 doc
3081}
3082
3083#[no_mangle]
3093pub unsafe extern "C" fn xmlSAXParseFileWithData(
3094 sax: *mut _xmlSAXHandler,
3095 filename: *const c_char,
3096 recovery: c_int,
3097 data: *mut c_void,
3098) -> *mut _xmlDoc {
3099 if filename.is_null() {
3101 return ptr::null_mut();
3102 }
3103 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3104 if ctxt.is_null() {
3105 return ptr::null_mut();
3106 }
3107 if !sax.is_null() {
3108 (*ctxt).sax = sax;
3109 }
3110 (*ctxt).userData = data;
3111 if recovery != 0 {
3112 (*ctxt).recovery = 1;
3113 (*ctxt).options |= 1; }
3115 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3116 Ok(input) => input,
3117 Err(_) => {
3118 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3119 return ptr::null_mut();
3120 }
3121 };
3122 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3123 crate::xml::parser::helpers::parse_document(ctxt);
3124 let doc = (*ctxt).myDoc;
3125 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3126 doc
3127}
3128
3129#[no_mangle]
3139pub unsafe extern "C" fn xmlSAXParseMemoryWithData(
3140 sax: *mut _xmlSAXHandler,
3141 buffer: *const c_char,
3142 size: c_int,
3143 recovery: c_int,
3144 data: *mut c_void,
3145) -> *mut _xmlDoc {
3146 if buffer.is_null() || size <= 0 {
3148 return ptr::null_mut();
3149 }
3150 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3151 if ctxt.is_null() {
3152 return ptr::null_mut();
3153 }
3154 if !sax.is_null() {
3155 (*ctxt).sax = sax;
3156 }
3157 (*ctxt).userData = data;
3158 if recovery != 0 {
3159 (*ctxt).recovery = 1;
3160 (*ctxt).options |= 1; }
3162 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3163 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3164 crate::xml::parser::helpers::parse_document(ctxt);
3165 let doc = (*ctxt).myDoc;
3166 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3167 doc
3168}
3169
3170#[no_mangle]
3178pub unsafe extern "C" fn xmlSAXParseFile(
3179 sax: *mut _xmlSAXHandler,
3180 filename: *const c_char,
3181 recovery: c_int,
3182) -> *mut _xmlDoc {
3183 if filename.is_null() {
3185 return ptr::null_mut();
3186 }
3187 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3188 if ctxt.is_null() {
3189 return ptr::null_mut();
3190 }
3191 if !sax.is_null() {
3192 (*ctxt).sax = sax;
3193 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3194 }
3195 if recovery != 0 {
3196 (*ctxt).recovery = 1;
3197 (*ctxt).options |= 1;
3198 }
3199 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3200 Ok(input) => input,
3201 Err(_) => {
3202 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3203 return ptr::null_mut();
3204 }
3205 };
3206 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3207 crate::xml::parser::helpers::parse_document(ctxt);
3208 let doc = (*ctxt).myDoc;
3209 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3210 doc
3211}
3212
3213#[no_mangle]
3222pub unsafe extern "C" fn xmlSAXParseMemory(
3223 sax: *mut _xmlSAXHandler,
3224 buffer: *const c_char,
3225 size: c_int,
3226 recovery: c_int,
3227) -> *mut _xmlDoc {
3228 if buffer.is_null() || size <= 0 {
3230 return ptr::null_mut();
3231 }
3232 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3233 if ctxt.is_null() {
3234 return ptr::null_mut();
3235 }
3236 if !sax.is_null() {
3237 (*ctxt).sax = sax;
3238 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3239 }
3240 if recovery != 0 {
3241 (*ctxt).recovery = 1;
3242 (*ctxt).options |= 1;
3243 }
3244 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3245 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3246 crate::xml::parser::helpers::parse_document(ctxt);
3247 let doc = (*ctxt).myDoc;
3248 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3249 doc
3250}
3251
3252#[no_mangle]
3261pub unsafe extern "C" fn xmlSAXUserParseFile(
3262 sax: *mut _xmlSAXHandler,
3263 user_data: *mut c_void,
3264 filename: *const c_char,
3265) -> c_int {
3266 if filename.is_null() {
3268 return -1;
3269 }
3270 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3271 if ctxt.is_null() {
3272 return -1;
3273 }
3274 if !sax.is_null() {
3275 (*ctxt).sax = sax;
3276 }
3277 (*ctxt).userData = if !user_data.is_null() {
3278 user_data
3279 } else {
3280 ctxt as *mut c_void
3281 };
3282 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3283 Ok(input) => input,
3284 Err(_) => {
3285 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3286 return -1;
3287 }
3288 };
3289 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3290 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3291 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3292 ret
3293}
3294
3295#[no_mangle]
3304pub unsafe extern "C" fn xmlSAXUserParseMemory(
3305 sax: *mut _xmlSAXHandler,
3306 user_data: *mut c_void,
3307 buffer: *const c_char,
3308 size: c_int,
3309) -> c_int {
3310 if buffer.is_null() || size <= 0 {
3312 return -1;
3313 }
3314 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3315 if ctxt.is_null() {
3316 return -1;
3317 }
3318 if !sax.is_null() {
3319 (*ctxt).sax = sax;
3320 }
3321 (*ctxt).userData = if !user_data.is_null() {
3322 user_data
3323 } else {
3324 ctxt as *mut c_void
3325 };
3326 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3327 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3328 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3329 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3330 ret
3331}
3332
3333#[no_mangle]
3341pub unsafe extern "C" fn xmlParseDoc(cur: *const xmlChar) -> *mut _xmlDoc {
3342 if cur.is_null() {
3344 return ptr::null_mut();
3345 }
3346 xmlReadDoc(cur, ptr::null(), ptr::null(), 0)
3347}
3348
3349#[no_mangle]
3357pub unsafe extern "C" fn xmlParseFile(filename: *const c_char) -> *mut _xmlDoc {
3358 if filename.is_null() {
3360 return ptr::null_mut();
3361 }
3362 xmlReadFile(filename, ptr::null(), 0)
3363}
3364
3365#[no_mangle]
3373pub unsafe extern "C" fn xmlParseMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
3374 if buffer.is_null() || size <= 0 {
3376 return ptr::null_mut();
3377 }
3378 xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 0)
3379}
3380
3381#[no_mangle]
3389pub unsafe extern "C" fn xmlCreateFileParserCtxt(filename: *const c_char) -> *mut _xmlParserCtxt {
3390 if filename.is_null() {
3392 return ptr::null_mut();
3393 }
3394 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3395 if ctxt.is_null() {
3396 return ptr::null_mut();
3397 }
3398 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3399 Ok(input) => input,
3400 Err(_) => {
3401 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3402 return ptr::null_mut();
3403 }
3404 };
3405 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3406 ctxt
3407}
3408
3409#[no_mangle]
3417pub unsafe extern "C" fn xmlCreateDocParserCtxt(cur: *const xmlChar) -> *mut _xmlParserCtxt {
3418 if cur.is_null() {
3420 return ptr::null_mut();
3421 }
3422 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3423 if ctxt.is_null() {
3424 return ptr::null_mut();
3425 }
3426 let len = crate::xml::string::xml_strlen(cur);
3427 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
3428 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3429 ctxt
3430}
3431
3432#[no_mangle]
3440pub unsafe extern "C" fn xmlParseDocument(ctxt: *mut _xmlParserCtxt) -> c_int {
3441 if ctxt.is_null() {
3443 return -1;
3444 }
3445 crate::xml::parser::helpers::parse_document(ctxt)
3446}
3447
3448#[no_mangle]
3456pub unsafe extern "C" fn xmlFreeParserCtxt(ctxt: *mut _xmlParserCtxt) {
3457 if ctxt.is_null() {
3458 return;
3459 }
3460 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3461}
3462
3463#[no_mangle]
3471pub unsafe extern "C" fn xmlCtxtUseOptions(ctxt: *mut _xmlParserCtxt, options: c_int) -> c_int {
3472 if ctxt.is_null() {
3473 return -1;
3474 }
3475 unsafe {
3477 (*ctxt).options = options;
3478 }
3479 0
3480}
3481
3482#[no_mangle]
3491pub unsafe extern "C" fn xmlParseChunk(
3492 ctxt: *mut _xmlParserCtxt,
3493 chunk: *const c_char,
3494 size: c_int,
3495 terminate: c_int,
3496) -> c_int {
3497 if ctxt.is_null() {
3500 return -1;
3501 }
3502 crate::xml::parser::helpers::parse_chunk(ctxt, chunk, size, terminate)
3503}
3504
3505#[no_mangle]
3513pub unsafe extern "C" fn xmlParserInputBufferCreateMem(
3514 buffer: *const c_char,
3515 size: c_int,
3516 enc: c_int,
3517) -> *mut _xmlParserInputBuffer {
3518 if buffer.is_null() || size <= 0 {
3520 return ptr::null_mut();
3521 }
3522 crate::xml::parser::helpers::alloc_parser_input_buffer()
3523}
3524
3525#[no_mangle]
3533pub unsafe extern "C" fn xmlParserInputBufferCreateFilename(
3534 URI: *const c_char,
3535 enc: c_int,
3536) -> *mut _xmlParserInputBuffer {
3537 if URI.is_null() {
3539 return ptr::null_mut();
3540 }
3541 crate::xml::parser::helpers::alloc_parser_input_buffer()
3542}
3543
3544#[no_mangle]
3554pub unsafe extern "C" fn xmlParserInputBufferCreateIO(
3555 ioread: Option<xmlInputReadCallback>,
3556 ioclose: Option<xmlInputCloseCallback>,
3557 ioctx: *mut c_void,
3558 enc: c_int,
3559) -> *mut _xmlParserInputBuffer {
3560 let buf = crate::xml::parser::helpers::alloc_parser_input_buffer();
3562 if !buf.is_null() {
3563 (*buf).readcallback = ioread;
3564 (*buf).closecallback = ioclose;
3565 (*buf).context = ioctx;
3566 }
3567 buf
3568}
3569
3570#[no_mangle]
3578pub unsafe extern "C" fn xmlFreeParserInputBuffer(buf: *mut _xmlParserInputBuffer) {
3579 if buf.is_null() {
3580 return;
3581 }
3582 crate::xml::parser::helpers::free_parser_input_buffer(buf);
3583}
3584
3585#[no_mangle]
3593pub unsafe extern "C" fn xmlNewInputFromFile(
3594 ctxt: *mut _xmlParserCtxt,
3595 filename: *const c_char,
3596) -> *mut _xmlParserInput {
3597 if filename.is_null() {
3602 return ptr::null_mut();
3603 }
3604 crate::xml::parser::helpers::alloc_parser_input_buffer() as *mut _xmlParserInput
3605}
3606
3607#[no_mangle]
3615pub unsafe extern "C" fn xmlFreeInputStream(input: *mut _xmlParserInput) {
3616 if input.is_null() {
3617 return;
3618 }
3619 crate::xml::parser::helpers::free_parser_input(input);
3620}
3621
3622#[no_mangle]
3636pub unsafe extern "C" fn xmlOutputBufferCreateFilename(
3637 URI: *const c_char,
3638 encoder: *mut c_void,
3639 compression: c_int,
3640) -> *mut _xmlOutputBuffer {
3641 let _ = compression;
3642 if URI.is_null() {
3643 return ptr::null_mut();
3644 }
3645 crate::xml::io::output_buffer_create_filename(
3646 URI,
3647 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3648 0,
3649 )
3650}
3651
3652#[no_mangle]
3661pub unsafe extern "C" fn xmlOutputBufferCreateFd(
3662 fd: c_int,
3663 encoder: *mut c_void,
3664) -> *mut _xmlOutputBuffer {
3665 if fd < 0 {
3666 return ptr::null_mut();
3667 }
3668 crate::xml::io::output_buffer_create_fd(
3669 fd,
3670 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3671 )
3672}
3673
3674#[no_mangle]
3684pub unsafe extern "C" fn xmlOutputBufferCreateIO(
3685 iowrite: Option<xmlOutputWriteCallback>,
3686 ioclose: Option<xmlOutputCloseCallback>,
3687 ioctx: *mut c_void,
3688 encoder: *mut c_void,
3689) -> *mut _xmlOutputBuffer {
3690 crate::xml::io::output_buffer_create_io(
3691 iowrite,
3692 ioclose,
3693 ioctx,
3694 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3695 )
3696}
3697
3698#[no_mangle]
3706pub unsafe extern "C" fn xmlOutputBufferClose(out: *mut _xmlOutputBuffer) -> c_int {
3707 if out.is_null() {
3708 return -1;
3709 }
3710 crate::xml::io::output_buffer_close(out)
3711}
3712
3713#[no_mangle]
3721pub unsafe extern "C" fn xmlOutputBufferFlush(out: *mut _xmlOutputBuffer) -> c_int {
3722 if out.is_null() {
3723 return -1;
3724 }
3725 crate::xml::io::output_buffer_flush(out)
3726}
3727
3728#[no_mangle]
3736pub unsafe extern "C" fn xmlOutputBufferWrite(
3737 out: *mut _xmlOutputBuffer,
3738 len: c_int,
3739 data: *const c_char,
3740) -> c_int {
3741 if out.is_null() || data.is_null() || len <= 0 {
3742 return -1;
3743 }
3744 crate::xml::io::output_buffer_write(out, len, data)
3745}
3746
3747#[no_mangle]
3755pub unsafe extern "C" fn xmlOutputBufferWriteString(
3756 out: *mut _xmlOutputBuffer,
3757 str: *const c_char,
3758) -> c_int {
3759 if str.is_null() {
3760 return 0;
3761 }
3762 unsafe { xmlOutputBufferWrite(out, xmlStrlen(str as *const xmlChar), str) }
3763}
3764
3765#[no_mangle]
3773pub unsafe extern "C" fn xmlAllocOutputBuffer(encoder: *mut c_void) -> *mut _xmlOutputBuffer {
3774 crate::xml::io::output_buffer_create(
3775 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3776 )
3777}
3778
3779#[no_mangle]
3793pub unsafe extern "C" fn xmlOutputBufferCreateBuffer(
3794 buffer: *mut crate::abi::structs::_xmlBuffer,
3795 encoder: *mut c_void,
3796) -> *mut _xmlOutputBuffer {
3797 crate::xml::io::output_buffer_create_buffer(
3798 buffer,
3799 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3800 )
3801}
3802
3803#[no_mangle]
3811pub unsafe extern "C" fn xmlOutputBufferCreateFile(
3812 file: *mut libc::FILE,
3813 encoder: *mut c_void,
3814) -> *mut _xmlOutputBuffer {
3815 crate::xml::io::output_buffer_create_file(
3816 file,
3817 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3818 )
3819}
3820
3821#[no_mangle]
3827pub unsafe extern "C" fn xmlOutputBufferGetContent(out: *mut _xmlOutputBuffer) -> *const c_char {
3828 crate::xml::io::output_buffer_get_content(out) as *const c_char
3829}
3830
3831#[no_mangle]
3839pub unsafe extern "C" fn xmlOutputBufferGetSize(out: *mut _xmlOutputBuffer) -> usize {
3840 crate::xml::io::output_buffer_get_size(out)
3841}
3842
3843#[no_mangle]
3851pub unsafe extern "C" fn xmlOutputBufferWriteEscape(
3852 out: *mut _xmlOutputBuffer,
3853 str: *const xmlChar,
3854 escaping: Option<xmlCharEncodingOutputFunc>,
3855) -> c_int {
3856 if out.is_null() || str.is_null() {
3857 return -1;
3858 }
3859 crate::xml::io::output_buffer_write_escape(out, str, escaping)
3860}
3861
3862static mut OUTPUT_CREATE_FILENAME_DEFAULT: Option<
3865 unsafe extern "C" fn(
3866 *const c_char,
3867 *mut crate::abi::structs::_xmlCharEncodingHandler,
3868 c_int,
3869 ) -> *mut _xmlOutputBuffer,
3870> = None;
3871
3872#[no_mangle]
3879pub unsafe extern "C" fn xmlOutputBufferCreateFilenameDefault(
3880 func: Option<
3881 unsafe extern "C" fn(
3882 *const c_char,
3883 *mut crate::abi::structs::_xmlCharEncodingHandler,
3884 c_int,
3885 ) -> *mut _xmlOutputBuffer,
3886 >,
3887) -> Option<
3888 unsafe extern "C" fn(
3889 *const c_char,
3890 *mut crate::abi::structs::_xmlCharEncodingHandler,
3891 c_int,
3892 ) -> *mut _xmlOutputBuffer,
3893> {
3894 let old = unsafe { OUTPUT_CREATE_FILENAME_DEFAULT };
3895 if func.is_some() {
3896 unsafe { OUTPUT_CREATE_FILENAME_DEFAULT = func };
3897 }
3898 old
3899}
3900
3901#[no_mangle]
3904pub unsafe extern "C" fn __xmlOutputBufferCreateFilename() -> *mut Option<
3905 unsafe extern "C" fn(
3906 *const c_char,
3907 *mut crate::abi::structs::_xmlCharEncodingHandler,
3908 c_int,
3909 ) -> *mut _xmlOutputBuffer,
3910> {
3911 core::ptr::addr_of_mut!(OUTPUT_CREATE_FILENAME_DEFAULT)
3912}
3913
3914#[no_mangle]
3926pub extern "C" fn xmlDictCreate() -> *mut c_void {
3927 let d = { crate::xml::dictionary::dict_create() as *mut c_void };
3928 if !d.is_null() {
3929 *crate::abi::exports_hash::DICT_REFS
3933 .lock()
3934 .entry(d as usize)
3935 .or_insert(0) = 1;
3936 }
3937 d
3938}
3939
3940#[no_mangle]
3948pub extern "C" fn xmlDictCreateSub(sub: *mut c_void) -> *mut c_void {
3949 let d = unsafe {
3950 crate::xml::dictionary::dict_create_sub(sub as *mut crate::xml::dictionary::Dict)
3951 as *mut c_void
3952 };
3953 if !d.is_null() {
3954 *crate::abi::exports_hash::DICT_REFS
3955 .lock()
3956 .entry(d as usize)
3957 .or_insert(0) = 1;
3958 }
3959 d
3960}
3961
3962#[no_mangle]
3974pub unsafe extern "C" fn xmlDictLookup(
3975 dict: *mut c_void,
3976 name: *const xmlChar,
3977 len: c_int,
3978) -> *const xmlChar {
3979 unsafe {
3980 crate::xml::dictionary::dict_lookup(dict as *mut crate::xml::dictionary::Dict, name, len)
3981 }
3982}
3983
3984#[no_mangle]
3992pub unsafe extern "C" fn xmlDictExists(
3993 dict: *mut c_void,
3994 name: *const xmlChar,
3995 len: c_int,
3996) -> *const xmlChar {
3997 unsafe {
3998 crate::xml::dictionary::dict_exists(dict as *mut crate::xml::dictionary::Dict, name, len)
3999 }
4000}
4001
4002#[no_mangle]
4010pub const extern "C" fn xmlDictSize(dict: *const c_void) -> c_int {
4011 {
4012 crate::xml::dictionary::dict_size(dict as *const crate::xml::dictionary::Dict)
4013 }
4014}
4015
4016#[no_mangle]
4028pub extern "C" fn xmlDictFree(dict: *mut c_void) {
4029 if dict.is_null() {
4030 return;
4031 }
4032 let mut remaining = 0u32;
4033 {
4034 let mut refs = crate::abi::exports_hash::DICT_REFS.lock();
4035 if let Some(r) = refs.get_mut(&(dict as usize)) {
4036 if *r > 0 {
4037 *r -= 1;
4038 }
4039 remaining = *r;
4040 if remaining == 0 {
4041 refs.remove(&(dict as usize));
4042 }
4043 }
4044 }
4045 if remaining == 0 {
4046 unsafe { crate::xml::dictionary::dict_free(dict as *mut crate::xml::dictionary::Dict) };
4047 }
4048}
4049
4050#[no_mangle]
4058pub extern "C" fn xmlDictSetLimit(dict: *mut c_void, limit: usize) -> usize {
4059 {
4060 crate::xml::dictionary::dict_set_limit(dict as *mut crate::xml::dictionary::Dict, limit)
4061 }
4062}
4063
4064#[no_mangle]
4072pub extern "C" fn xmlDictGetUsage(dict: *const c_void) -> usize {
4073 {
4074 crate::xml::dictionary::dict_get_usage(dict as *mut crate::xml::dictionary::Dict)
4075 }
4076}
4077
4078#[no_mangle]
4090pub extern "C" fn xmlHashCreate(size: c_int) -> *mut c_void {
4091 crate::xml::hash::hash_create(size) as *mut c_void
4092}
4093
4094#[no_mangle]
4102pub extern "C" fn xmlHashCreateDict(size: c_int, dict: *mut c_void) -> *mut c_void {
4103 crate::xml::hash::hash_create_dict(size, dict) as *mut c_void
4104}
4105
4106#[no_mangle]
4114pub extern "C" fn xmlHashFree(
4115 table: *mut c_void,
4116 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4117) {
4118 unsafe { crate::xml::hash::hash_free(table as *mut crate::xml::hash::HashTable, f) }
4119}
4120
4121#[no_mangle]
4129pub unsafe extern "C" fn xmlHashAddEntry(
4130 table: *mut c_void,
4131 name: *const xmlChar,
4132 userdata: *mut c_void,
4133) -> c_int {
4134 unsafe {
4135 crate::xml::hash::hash_add_entry(table as *mut crate::xml::hash::HashTable, name, userdata)
4136 }
4137}
4138
4139#[no_mangle]
4148pub unsafe extern "C" fn xmlHashAddEntry2(
4149 table: *mut c_void,
4150 name: *const xmlChar,
4151 name2: *const xmlChar,
4152 userdata: *mut c_void,
4153) -> c_int {
4154 unsafe {
4155 crate::xml::hash::hash_add_entry2(
4156 table as *mut crate::xml::hash::HashTable,
4157 name,
4158 name2,
4159 userdata,
4160 )
4161 }
4162}
4163
4164#[no_mangle]
4173pub unsafe extern "C" fn xmlHashAddEntry3(
4174 table: *mut c_void,
4175 name: *const xmlChar,
4176 name2: *const xmlChar,
4177 name3: *const xmlChar,
4178 userdata: *mut c_void,
4179) -> c_int {
4180 unsafe {
4181 crate::xml::hash::hash_add_entry3(
4182 table as *mut crate::xml::hash::HashTable,
4183 name,
4184 name2,
4185 name3,
4186 userdata,
4187 )
4188 }
4189}
4190
4191#[no_mangle]
4200pub unsafe extern "C" fn xmlHashUpdateEntry(
4201 table: *mut c_void,
4202 name: *const xmlChar,
4203 userdata: *mut c_void,
4204 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4205) -> c_int {
4206 unsafe {
4207 crate::xml::hash::hash_update_entry(
4208 table as *mut crate::xml::hash::HashTable,
4209 name,
4210 userdata,
4211 f,
4212 )
4213 }
4214}
4215
4216#[no_mangle]
4218pub unsafe extern "C" fn xmlHashUpdateEntry2(
4219 table: *mut c_void,
4220 name: *const xmlChar,
4221 name2: *const xmlChar,
4222 userdata: *mut c_void,
4223 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4224) -> c_int {
4225 unsafe {
4226 crate::xml::hash::hash_update_entry2(
4227 table as *mut crate::xml::hash::HashTable,
4228 name,
4229 name2,
4230 userdata,
4231 f,
4232 )
4233 }
4234}
4235
4236#[no_mangle]
4238pub unsafe extern "C" fn xmlHashUpdateEntry3(
4239 table: *mut c_void,
4240 name: *const xmlChar,
4241 name2: *const xmlChar,
4242 name3: *const xmlChar,
4243 userdata: *mut c_void,
4244 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4245) -> c_int {
4246 unsafe {
4247 crate::xml::hash::hash_update_entry3(
4248 table as *mut crate::xml::hash::HashTable,
4249 name,
4250 name2,
4251 name3,
4252 userdata,
4253 f,
4254 )
4255 }
4256}
4257
4258#[no_mangle]
4266pub unsafe extern "C" fn xmlHashLookup(table: *mut c_void, name: *const xmlChar) -> *mut c_void {
4267 unsafe { crate::xml::hash::hash_lookup(table as *mut crate::xml::hash::HashTable, name) }
4268}
4269
4270#[no_mangle]
4272pub unsafe extern "C" fn xmlHashLookup2(
4273 table: *mut c_void,
4274 name: *const xmlChar,
4275 name2: *const xmlChar,
4276) -> *mut c_void {
4277 unsafe {
4278 crate::xml::hash::hash_lookup2(table as *mut crate::xml::hash::HashTable, name, name2)
4279 }
4280}
4281
4282#[no_mangle]
4284pub unsafe extern "C" fn xmlHashLookup3(
4285 table: *mut c_void,
4286 name: *const xmlChar,
4287 name2: *const xmlChar,
4288 name3: *const xmlChar,
4289) -> *mut c_void {
4290 unsafe {
4291 crate::xml::hash::hash_lookup3(
4292 table as *mut crate::xml::hash::HashTable,
4293 name,
4294 name2,
4295 name3,
4296 )
4297 }
4298}
4299
4300#[no_mangle]
4308pub extern "C" fn xmlHashSize(table: *mut c_void) -> c_int {
4309 crate::xml::hash::hash_size(table as *mut crate::xml::hash::HashTable)
4310}
4311
4312#[no_mangle]
4321pub unsafe extern "C" fn xmlHashRemoveEntry(
4322 table: *mut c_void,
4323 name: *const xmlChar,
4324 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4325) -> c_int {
4326 unsafe {
4327 crate::xml::hash::hash_remove_entry(table as *mut crate::xml::hash::HashTable, name, f)
4328 }
4329}
4330
4331#[no_mangle]
4333pub unsafe extern "C" fn xmlHashRemoveEntry2(
4334 table: *mut c_void,
4335 name: *const xmlChar,
4336 name2: *const xmlChar,
4337 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4338) -> c_int {
4339 unsafe {
4340 crate::xml::hash::hash_remove_entry2(
4341 table as *mut crate::xml::hash::HashTable,
4342 name,
4343 name2,
4344 f,
4345 )
4346 }
4347}
4348
4349#[no_mangle]
4351pub unsafe extern "C" fn xmlHashRemoveEntry3(
4352 table: *mut c_void,
4353 name: *const xmlChar,
4354 name2: *const xmlChar,
4355 name3: *const xmlChar,
4356 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4357) -> c_int {
4358 unsafe {
4359 crate::xml::hash::hash_remove_entry3(
4360 table as *mut crate::xml::hash::HashTable,
4361 name,
4362 name2,
4363 name3,
4364 f,
4365 )
4366 }
4367}
4368
4369#[no_mangle]
4377pub extern "C" fn xmlHashScan(table: *mut c_void, f: Option<xmlHashScanner>, data: *mut c_void) {
4378 unsafe { crate::xml::hash::hash_scan(table as *mut crate::xml::hash::HashTable, f, data) }
4379}
4380
4381#[no_mangle]
4383pub extern "C" fn xmlHashScanFull(
4384 table: *mut c_void,
4385 f: Option<xmlHashScannerFull>,
4386 data: *mut c_void,
4387) {
4388 unsafe { crate::xml::hash::hash_scan_full(table as *mut crate::xml::hash::HashTable, f, data) }
4389}
4390
4391#[no_mangle]
4399pub extern "C" fn xmlHashCopy(
4400 table: *mut c_void,
4401 f: Option<unsafe extern "C" fn(*mut c_void, *const xmlChar) -> *mut c_void>,
4402) -> *mut c_void {
4403 unsafe {
4404 crate::xml::hash::hash_copy(table as *mut crate::xml::hash::HashTable, f) as *mut c_void
4405 }
4406}
4407
4408#[no_mangle]
4421pub extern "C" fn xmlListCreate(
4422 deallocator: Option<unsafe extern "C" fn(*mut c_void)>,
4423 compare: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
4424) -> *mut c_void {
4425 crate::xml::list::list_create(deallocator, compare) as *mut c_void
4426}
4427
4428#[no_mangle]
4436pub extern "C" fn xmlListDelete(list: *mut c_void) {
4437 unsafe { crate::xml::list::list_delete(list as *mut crate::xml::list::List) }
4438}
4439
4440#[no_mangle]
4448pub extern "C" fn xmlListSearch(list: *mut c_void, data: *mut c_void) -> *mut c_void {
4449 unsafe { crate::xml::list::list_search(list as *mut crate::xml::list::List, data) }
4450}
4451
4452#[no_mangle]
4460pub extern "C" fn xmlListWalk(
4461 list: *mut c_void,
4462 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4463 data: *mut c_void,
4464) {
4465 unsafe { crate::xml::list::list_walk(list as *mut crate::xml::list::List, walker, data) }
4466}
4467
4468#[no_mangle]
4476pub extern "C" fn xmlListPushBack(list: *mut c_void, data: *mut c_void) -> c_int {
4477 unsafe { crate::xml::list::list_push_back(list as *mut crate::xml::list::List, data) }
4478}
4479
4480#[no_mangle]
4488pub extern "C" fn xmlListPushFront(list: *mut c_void, data: *mut c_void) -> c_int {
4489 unsafe { crate::xml::list::list_push_front(list as *mut crate::xml::list::List, data) }
4490}
4491
4492#[no_mangle]
4494pub extern "C" fn xmlListPopBack(list: *mut c_void) {
4495 unsafe { crate::xml::list::list_pop_back(list as *mut crate::xml::list::List) }
4496}
4497
4498#[no_mangle]
4500pub extern "C" fn xmlListPopFront(list: *mut c_void) {
4501 unsafe { crate::xml::list::list_pop_front(list as *mut crate::xml::list::List) }
4502}
4503
4504#[no_mangle]
4512pub extern "C" fn xmlListInsert(list: *mut c_void, data: *mut c_void) -> c_int {
4513 unsafe { crate::xml::list::list_insert(list as *mut crate::xml::list::List, data) }
4514}
4515
4516#[no_mangle]
4518pub extern "C" fn xmlListAppend(list: *mut c_void, data: *mut c_void) -> c_int {
4519 unsafe { crate::xml::list::list_append(list as *mut crate::xml::list::List, data) }
4520}
4521
4522#[no_mangle]
4524pub extern "C" fn xmlListRemoveFirst(list: *mut c_void, data: *mut c_void) -> c_int {
4525 unsafe { crate::xml::list::list_remove_first(list as *mut crate::xml::list::List, data) }
4526}
4527
4528#[no_mangle]
4530pub extern "C" fn xmlListRemoveLast(list: *mut c_void, data: *mut c_void) -> c_int {
4531 unsafe { crate::xml::list::list_remove_last(list as *mut crate::xml::list::List, data) }
4532}
4533
4534#[no_mangle]
4536pub extern "C" fn xmlListRemoveAll(list: *mut c_void, data: *mut c_void) -> c_int {
4537 unsafe { crate::xml::list::list_remove_all(list as *mut crate::xml::list::List, data) }
4538}
4539
4540#[no_mangle]
4542pub extern "C" fn xmlListClear(list: *mut c_void) {
4543 unsafe { crate::xml::list::list_clear(list as *mut crate::xml::list::List) }
4544}
4545
4546#[no_mangle]
4554pub extern "C" fn xmlListEmpty(list: *mut c_void) -> c_int {
4555 crate::xml::list::list_empty(list as *mut crate::xml::list::List)
4556}
4557
4558#[no_mangle]
4566pub extern "C" fn xmlListFront(list: *mut c_void) -> *mut c_void {
4567 crate::xml::list::list_front(list as *mut crate::xml::list::List)
4568}
4569
4570#[no_mangle]
4578pub extern "C" fn xmlListBack(list: *mut c_void) -> *mut c_void {
4579 crate::xml::list::list_back(list as *mut crate::xml::list::List)
4580}
4581
4582#[no_mangle]
4590pub extern "C" fn xmlListSize(list: *mut c_void) -> c_int {
4591 crate::xml::list::list_size(list as *mut crate::xml::list::List)
4592}
4593
4594#[no_mangle]
4596pub extern "C" fn xmlListSort(list: *mut c_void) {
4597 unsafe { crate::xml::list::list_sort(list as *mut crate::xml::list::List) }
4598}
4599
4600#[no_mangle]
4602pub extern "C" fn xmlListReverse(list: *mut c_void) {
4603 unsafe { crate::xml::list::list_reverse(list as *mut crate::xml::list::List) }
4604}
4605
4606#[no_mangle]
4608pub extern "C" fn xmlListReverseSplice(list: *mut c_void, list2: *mut c_void) {
4609 unsafe {
4610 crate::xml::list::list_reverse_splice(
4611 list as *mut crate::xml::list::List,
4612 list2 as *mut crate::xml::list::List,
4613 )
4614 }
4615}
4616
4617#[no_mangle]
4619pub extern "C" fn xmlListMerge(list: *mut c_void, list2: *mut c_void) {
4620 unsafe {
4621 crate::xml::list::list_merge(
4622 list as *mut crate::xml::list::List,
4623 list2 as *mut crate::xml::list::List,
4624 )
4625 }
4626}
4627#[no_mangle]
4635pub unsafe extern "C" fn xmlListEnd(l: *mut c_void) -> *mut c_void {
4636 crate::xml::list::list_end(l as *mut crate::xml::list::List)
4637}
4638
4639#[no_mangle]
4647pub unsafe extern "C" fn xmlListReverseSearch(l: *mut c_void, data: *mut c_void) -> *mut c_void {
4648 crate::xml::list::list_reverse_search(l as *mut crate::xml::list::List, data)
4649}
4650
4651#[no_mangle]
4659pub unsafe extern "C" fn xmlListReverseWalk(
4660 l: *mut c_void,
4661 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4662 data: *mut c_void,
4663) {
4664 crate::xml::list::list_reverse_walk(l as *mut crate::xml::list::List, walker, data)
4665}
4666
4667#[no_mangle]
4675pub unsafe extern "C" fn xmlListDup(l: *mut c_void) -> *mut c_void {
4676 crate::xml::list::list_dup(l as *mut crate::xml::list::List) as *mut c_void
4677}
4678
4679#[no_mangle]
4690pub unsafe extern "C" fn xmlListCopy(cur: *mut c_void, old: *mut c_void) -> c_int {
4691 crate::xml::list::list_copy(
4692 cur as *mut crate::xml::list::List,
4693 old as *mut crate::xml::list::List,
4694 )
4695}
4696
4697#[no_mangle]
4705pub unsafe extern "C" fn xmlLinkGetData(lk: *mut c_void) -> *mut c_void {
4706 crate::xml::list::link_get_data(lk)
4707}
4708
4709#[no_mangle]
4721pub extern "C" fn xmlBufferCreate() -> *mut _xmlBuffer {
4722 crate::xml::io::buf_create(-1)
4723}
4724
4725#[no_mangle]
4733pub extern "C" fn xmlBufferCreateSize(size: usize) -> *mut _xmlBuffer {
4734 crate::xml::io::buf_create(size as c_int)
4735}
4736
4737#[no_mangle]
4745pub extern "C" fn xmlBufferCreateStatic(mem: *mut c_void, size: usize) -> *mut _xmlBuffer {
4746 if mem.is_null() || size == 0 {
4747 return ptr::null_mut();
4748 }
4749 crate::xml::io::buf_create_static(mem as *const xmlChar, size as c_int)
4750}
4751
4752#[no_mangle]
4760pub extern "C" fn xmlBufferFree(buf: *mut _xmlBuffer) {
4761 crate::xml::io::buf_free(buf)
4762}
4763
4764#[no_mangle]
4772pub extern "C" fn xmlBufferEmpty(buf: *mut _xmlBuffer) {
4773 if buf.is_null() {
4774 return;
4775 }
4776 unsafe {
4777 if !(*buf).content.is_null() {
4778 *(*buf).content = 0;
4779 }
4780 (*buf).use_ = 0;
4781 }
4782}
4783
4784#[no_mangle]
4792pub extern "C" fn xmlBufferContent(buf: *const _xmlBuffer) -> *mut xmlChar {
4793 crate::xml::io::buf_content(buf as *mut _xmlBuffer)
4794}
4795
4796#[no_mangle]
4804pub extern "C" fn xmlBufferLength(buf: *const _xmlBuffer) -> c_int {
4805 crate::xml::io::buf_length(buf as *mut _xmlBuffer)
4806}
4807
4808#[no_mangle]
4816pub unsafe extern "C" fn xmlBufferAdd(
4817 buf: *mut _xmlBuffer,
4818 str: *const xmlChar,
4819 len: c_int,
4820) -> c_int {
4821 crate::xml::io::buf_add(buf, str, len)
4822}
4823
4824#[no_mangle]
4832pub unsafe extern "C" fn xmlBufferAddHead(
4833 buf: *mut _xmlBuffer,
4834 str: *const xmlChar,
4835 len: c_int,
4836) -> c_int {
4837 crate::xml::io::buf_add_head(buf, str, len)
4838}
4839
4840#[no_mangle]
4848pub unsafe extern "C" fn xmlBufferCat(buf: *mut _xmlBuffer, str: *const xmlChar) -> c_int {
4849 if str.is_null() {
4850 return -1;
4851 }
4852 let len = crate::xml::string::xml_strlen(str) as c_int;
4853 crate::xml::io::buf_add(buf, str, len)
4854}
4855
4856#[no_mangle]
4865pub extern "C" fn xmlBufferSetAllocationScheme(buf: *mut _xmlBuffer, scheme: c_int) {
4866 if buf.is_null() {
4867 return;
4868 }
4869 unsafe {
4870 (*buf).alloc = scheme;
4871 }
4872}
4873
4874#[no_mangle]
4885pub extern "C" fn xmlBufferShrink(buf: *mut _xmlBuffer, len: c_uint) -> c_int {
4886 if buf.is_null() {
4887 return -1;
4888 }
4889 if len == 0 {
4890 return 0;
4891 }
4892 unsafe {
4893 let b = &mut *buf;
4894 if len > b.use_ {
4895 return -1;
4896 }
4897 let remaining = b.use_ - len;
4898 if remaining > 0 {
4899 core::ptr::copy(b.content.add(len as usize), b.content, remaining as usize);
4900 }
4901 *b.content.add(remaining as usize) = 0;
4902 b.use_ = remaining;
4903 }
4904 len as c_int
4905}
4906
4907#[no_mangle]
4915pub extern "C" fn xmlBufferGrow(buf: *mut _xmlBuffer, len: c_uint) -> c_int {
4916 if buf.is_null() || len == 0 {
4917 return 0;
4918 }
4919 let cur_use = unsafe { (*buf).use_ };
4920 let new_size = cur_use + len + 1;
4921 crate::xml::io::buf_grow(buf, new_size)
4922}
4923
4924#[no_mangle]
4932pub extern "C" fn xmlBufferReserve(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4933 xmlBufferGrow(buf, len as c_uint)
4934}
4935
4936#[no_mangle]
4944pub extern "C" fn xmlBufferDetach(buf: *mut _xmlBuffer) -> *mut xmlChar {
4945 if buf.is_null() {
4946 return ptr::null_mut();
4947 }
4948 unsafe {
4949 let content = (*buf).content;
4950 (*buf).content = ptr::null_mut();
4951 (*buf).use_ = 0;
4952 (*buf).size = 0;
4953 content
4954 }
4955}
4956
4957#[no_mangle]
4969pub extern "C" fn xmlGetCharEncoding(name: *const c_char) -> c_int {
4970 if name.is_null() {
4971 return 0; }
4973 let name_bytes = unsafe {
4974 let len = libc::strlen(name);
4975 core::slice::from_raw_parts(name as *const u8, len)
4976 };
4977 crate::xml::encoding::encoding_from_name(name_bytes) as c_int
4978}
4979
4980#[no_mangle]
4988pub extern "C" fn xmlFindCharEncodingHandler(name: *const c_char) -> *mut c_void {
4989 if name.is_null() {
4990 return ptr::null_mut();
4991 }
4992 crate::xml::encoding::find_encoding_handler(name as *const xmlChar) as *mut c_void
4993}
4994
4995#[no_mangle]
5003pub extern "C" fn xmlCharEncCloseFunc(handler: *mut c_void) -> c_int {
5004 if handler.is_null() {
5005 return -1;
5006 }
5007 unsafe {
5009 let h = handler as *mut crate::abi::structs::_xmlCharEncodingHandler;
5010 if !(*h).name.is_null() {
5011 crate::abi::allocator::xmlFreeImpl((*h).name as *mut c_void);
5012 }
5013 crate::abi::allocator::xmlFreeImpl(handler);
5014 }
5015 0
5016}
5017
5018#[no_mangle]
5028pub unsafe extern "C" fn xmlIsolat1ToUTF8(
5029 out: *mut u8,
5030 outlen: *mut c_int,
5031 input: *const u8,
5032 inlen: *mut c_int,
5033) -> c_int {
5034 const XML_ENC_ERR_SPACE: c_int = -2;
5036 const XML_ENC_ERR_INTERNAL: c_int = -1;
5037 unsafe {
5038 if out.is_null() || input.is_null() || outlen.is_null() || inlen.is_null() {
5039 return XML_ENC_ERR_INTERNAL;
5040 }
5041 let outstart = out;
5042 let instart = input;
5043 let outend = out.add(*outlen as usize);
5044 let inend = input.add(*inlen as usize);
5045 let mut cur = input;
5046 let mut o = out;
5047 while cur < inend {
5048 let c = *cur;
5049 if c < 0x80 {
5050 if o >= outend {
5051 break;
5052 }
5053 *o = c;
5054 o = o.add(1);
5055 } else {
5056 if (outend as usize) - (o as usize) < 2 {
5057 break;
5058 }
5059 *o = (c >> 6) | 0xC0;
5060 *o.add(1) = (c & 0x3F) | 0x80;
5061 o = o.add(2);
5062 }
5063 cur = cur.add(1);
5064 }
5065 let mut ret = XML_ENC_ERR_SPACE;
5066 if cur == inend {
5067 ret = (o as usize - outstart as usize) as c_int;
5068 }
5069 *outlen = (o as usize - outstart as usize) as c_int;
5070 *inlen = (cur as usize - instart as usize) as c_int;
5071 ret
5072 }
5073}
5074
5075#[no_mangle]
5082pub unsafe extern "C" fn xmlUTF8ToIsolat1(
5083 out: *mut u8,
5084 outlen: *mut c_int,
5085 input: *const u8,
5086 inlen: *mut c_int,
5087) -> c_int {
5088 const XML_ENC_ERR_SPACE: c_int = -2;
5089 const XML_ENC_ERR_INTERNAL: c_int = -1;
5090 const XML_ENC_ERR_INPUT: c_int = -3;
5091 const XML_ENC_ERR_SUCCESS: c_int = 0;
5092 unsafe {
5093 if out.is_null() || outlen.is_null() || inlen.is_null() {
5094 return XML_ENC_ERR_INTERNAL;
5095 }
5096 if input.is_null() {
5097 *inlen = 0;
5098 *outlen = 0;
5099 return XML_ENC_ERR_SUCCESS;
5100 }
5101 let outstart = out;
5102 let instart = input;
5103 let outend = out.add(*outlen as usize);
5104 let inend = input.add(*inlen as usize);
5105 let mut cur = input;
5106 let mut o = out;
5107 let mut ret = XML_ENC_ERR_SPACE;
5108 while cur < inend {
5109 if o >= outend {
5110 break;
5111 }
5112 let c = *cur;
5113 if c < 0x80 {
5114 *o = c;
5115 o = o.add(1);
5116 } else if (0xC2..=0xC3).contains(&c) {
5117 if (inend as usize) - (cur as usize) < 2 {
5118 break;
5119 }
5120 cur = cur.add(1);
5121 *o = (c << 6) | (*cur & 0x3F);
5122 o = o.add(1);
5123 } else {
5124 ret = XML_ENC_ERR_INPUT;
5125 break;
5126 }
5127 cur = cur.add(1);
5128 }
5129 if ret != XML_ENC_ERR_INPUT {
5130 ret = (o as usize - outstart as usize) as c_int;
5131 }
5132 *outlen = (o as usize - outstart as usize) as c_int;
5133 *inlen = (cur as usize - instart as usize) as c_int;
5134 ret
5135 }
5136}
5137
5138#[no_mangle]
5146pub extern "C" fn xmlGetCharEncodingName(enc: c_int) -> *const c_char {
5147 if !(-1..=22).contains(&enc) {
5151 return match enc {
5152 23 => c"UTF-16".as_ptr(),
5153 24 => c"HTML".as_ptr(),
5154 31 => c"windows-1252".as_ptr(),
5155 _ => ptr::null(),
5156 };
5157 }
5158 let e: crate::abi::types::xmlCharEncoding = unsafe { core::mem::transmute(enc) };
5159 crate::xml::encoding::xmlGetCharEncodingName(e)
5160}
5161
5162#[no_mangle]
5172pub extern "C" fn xmlParseCharEncoding(name: *const c_char) -> c_int {
5173 crate::xml::encoding::xmlParseCharEncoding(name)
5174}
5175
5176#[no_mangle]
5184pub extern "C" fn xmlAddEncodingAlias(name: *const c_char, alias: *const c_char) -> c_int {
5185 crate::xml::encoding::add_encoding_alias(name, alias)
5186}
5187
5188#[no_mangle]
5196pub extern "C" fn xmlDelEncodingAlias(alias: *const c_char) -> c_int {
5197 crate::xml::encoding::del_encoding_alias(alias)
5198}
5199
5200#[no_mangle]
5208pub extern "C" fn xmlGetEncodingAlias(alias: *const c_char) -> *const c_char {
5209 crate::xml::encoding::get_encoding_alias(alias)
5210}
5211
5212#[no_mangle]
5220pub extern "C" fn xmlCleanupEncodingAliases() {
5221 crate::xml::encoding::cleanup_encoding_aliases();
5222}
5223
5224#[no_mangle]
5233pub extern "C" fn xmlCharEncInFunc(
5234 handler: *mut c_void,
5235 out: *mut c_void,
5236 in_: *mut c_void,
5237) -> c_int {
5238 crate::xml::encoding::xmlCharEncInFunc(
5239 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
5240 out as *mut crate::abi::structs::_xmlBuffer,
5241 in_ as *mut crate::abi::structs::_xmlBuffer,
5242 )
5243}
5244
5245#[no_mangle]
5254pub extern "C" fn xmlCharEncOutFunc(
5255 handler: *mut c_void,
5256 out: *mut c_void,
5257 in_: *mut c_void,
5258) -> c_int {
5259 crate::xml::encoding::xmlCharEncOutFunc(
5260 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
5261 out as *mut crate::abi::structs::_xmlBuffer,
5262 in_ as *mut crate::abi::structs::_xmlBuffer,
5263 )
5264}
5265
5266#[no_mangle]
5276pub extern "C" fn xmlNewCharEncodingHandler(
5277 name: *const c_char,
5278 input: crate::abi::callbacks::xmlCharEncodingInputFunc,
5279 output: crate::abi::callbacks::xmlCharEncodingOutputFunc,
5280) -> *mut c_void {
5281 crate::xml::encoding::xmlNewCharEncodingHandler(name, input, output) as *mut c_void
5282}
5283
5284#[no_mangle]
5292pub extern "C" fn xmlInitCharEncodingHandlers() {
5293 crate::xml::encoding::xmlInitCharEncodingHandlers();
5294}
5295
5296#[no_mangle]
5304pub extern "C" fn xmlCleanupCharEncodingHandlers() {
5305 crate::xml::encoding::xmlCleanupCharEncodingHandlers();
5306}
5307
5308#[no_mangle]
5320pub extern "C" fn xmlLookupCharEncodingHandler(enc: c_int, out: *mut *mut c_void) -> c_int {
5321 crate::xml::encoding::xmlLookupCharEncodingHandler(enc, out)
5322}
5323
5324#[no_mangle]
5332pub extern "C" fn xmlGetCharEncodingHandler(enc: c_int) -> *mut c_void {
5333 crate::xml::encoding::xmlGetCharEncodingHandler(enc)
5334}
5335
5336#[no_mangle]
5345pub extern "C" fn xmlOpenCharEncodingHandler(
5346 name: *const c_char,
5347 output: c_int,
5348 out: *mut *mut c_void,
5349) -> c_int {
5350 crate::xml::encoding::xmlOpenCharEncodingHandler(name, output, out)
5351}
5352
5353#[no_mangle]
5364pub extern "C" fn xmlCreateCharEncodingHandler(
5365 name: *const c_char,
5366 flags: c_int,
5367 impl_: Option<crate::abi::callbacks::xmlCharEncConvImpl>,
5368 implCtxt: *mut c_void,
5369 out: *mut *mut c_void,
5370) -> c_int {
5371 crate::xml::encoding::xmlCreateCharEncodingHandler(name, flags, impl_, implCtxt, out)
5372}
5373
5374#[no_mangle]
5385pub extern "C" fn xmlCharEncNewCustomHandler(
5386 name: *const c_char,
5387 input: crate::abi::callbacks::xmlCharEncConvFunc,
5388 output: crate::abi::callbacks::xmlCharEncConvFunc,
5389 ctxtDtor: Option<crate::abi::callbacks::xmlCharEncConvCtxtDtor>,
5390 inputCtxt: *mut c_void,
5391 outputCtxt: *mut c_void,
5392 out: *mut *mut c_void,
5393) -> c_int {
5394 crate::xml::encoding::xmlCharEncNewCustomHandler(
5395 name, input, output, ctxtDtor, inputCtxt, outputCtxt, out,
5396 )
5397}
5398
5399#[no_mangle]
5407pub unsafe extern "C" fn xmlCharEncInput(input: *mut _xmlParserInputBuffer, _to: c_int) -> c_int {
5408 if input.is_null() {
5409 return -1;
5410 }
5411 let handler = (*input).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5412 if handler.is_null() {
5413 return -1;
5414 }
5415 let raw = (*input).raw as *mut crate::abi::structs::_xmlBuffer;
5416 let buf = (*input).buffer as *mut crate::abi::structs::_xmlBuffer;
5417 if raw.is_null() || buf.is_null() {
5418 return -1;
5419 }
5420 crate::xml::encoding::char_enc_in(handler, buf, raw)
5421}
5422
5423#[no_mangle]
5431pub unsafe extern "C" fn xmlCharEncOutput(output: *mut _xmlOutputBuffer, _to: c_int) -> c_int {
5432 if output.is_null() {
5433 return -1;
5434 }
5435 let handler = (*output).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5436 if handler.is_null() {
5437 return -1;
5438 }
5439 let buf = (*output).buffer as *mut crate::abi::structs::_xmlBuffer;
5440 let conv = (*output).conv as *mut crate::abi::structs::_xmlBuffer;
5441 if buf.is_null() || conv.is_null() {
5442 return -1;
5443 }
5444 crate::xml::encoding::char_enc_out(handler, conv, buf)
5445}
5446
5447#[no_mangle]
5459pub unsafe extern "C" fn xmlParseURI(str: *const c_char) -> *mut c_void {
5460 crate::xml::uri::xmlParseURI(str)
5461}
5462
5463#[no_mangle]
5471pub unsafe extern "C" fn xmlParseURIRaw(str: *const c_char, raw: c_int) -> *mut c_void {
5472 let _ = raw;
5473 crate::xml::uri::xmlParseURI(str)
5474}
5475
5476#[no_mangle]
5484pub unsafe extern "C" fn xmlFreeURI(uri: *mut c_void) {
5485 crate::xml::uri::xmlFreeURI(uri)
5486}
5487
5488#[no_mangle]
5496pub extern "C" fn xmlCreateURI() -> *mut c_void {
5497 crate::xml::uri::xmlCreateURI()
5498}
5499
5500#[no_mangle]
5508pub unsafe extern "C" fn xmlSaveUri(uri: *mut c_void) -> *mut xmlChar {
5509 crate::xml::uri::xmlSaveUri(uri)
5510}
5511
5512#[no_mangle]
5528pub unsafe extern "C" fn xmlParseURIReference(uri: *mut c_void, str: *const c_char) -> c_int {
5529 crate::xml::uri::xmlParseURIReference(uri, str)
5530}
5531
5532#[no_mangle]
5547pub unsafe extern "C" fn xmlNormalizeURIPath(path: *mut c_char) -> c_int {
5548 crate::xml::uri::xmlNormalizeURIPath(path)
5549}
5550
5551#[no_mangle]
5559pub unsafe extern "C" fn xmlURIEscapeStr(
5560 str: *const xmlChar,
5561 list: *const xmlChar,
5562) -> *mut xmlChar {
5563 crate::xml::uri::xmlURIEscapeStr(str, list)
5564}
5565
5566#[no_mangle]
5574pub unsafe extern "C" fn xmlURIUnescapeString(
5575 str: *const c_char,
5576 len: c_int,
5577 target: *mut c_char,
5578) -> *mut c_char {
5579 crate::xml::uri::xmlURIUnescapeString(str, len, target)
5580}
5581
5582unsafe fn xpath_to_object(val: XPathValue) -> *mut _xmlXPathObject {
5597 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
5598 if obj.is_null() {
5599 return ptr::null_mut();
5600 }
5601 match val {
5602 XPathValue::NodeSet(ns) => {
5603 (*obj).type_ = xmlXPathObjectType::XPATH_NODESET as c_int;
5604 (*obj).nodesetval = ns.to_raw() as *mut c_void;
5605 }
5606 XPathValue::Boolean(b) => {
5607 (*obj).type_ = xmlXPathObjectType::XPATH_BOOLEAN as c_int;
5608 (*obj).boolval = if b { 1 } else { 0 };
5609 }
5610 XPathValue::Number(n) => {
5611 (*obj).type_ = xmlXPathObjectType::XPATH_NUMBER as c_int;
5612 (*obj).floatval = n;
5613 }
5614 XPathValue::String(s) => {
5615 (*obj).type_ = xmlXPathObjectType::XPATH_STRING as c_int;
5616 let bytes = s.as_bytes();
5617 let len = bytes.len();
5618 let buf = xmlMallocImpl(len + 1) as *mut xmlChar;
5619 if !buf.is_null() {
5620 ptr::copy_nonoverlapping(bytes.as_ptr(), buf, len);
5621 *buf.add(len) = 0; }
5623 (*obj).stringval = buf;
5624 }
5625 }
5626 obj
5627}
5628
5629unsafe fn object_to_xpathvalue(obj: *mut _xmlXPathObject) -> XPathValue {
5636 let typ = (*obj).type_;
5637 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5638 let ns_ptr = (*obj).nodesetval as *mut _xmlNodeSet;
5639 if ns_ptr.is_null() {
5640 return XPathValue::NodeSet(NodeSet::new());
5641 }
5642 let node_nr = (*ns_ptr).nodeNr;
5643 let node_tab = (*ns_ptr).nodeTab;
5644 let mut ns = NodeSet::new();
5645 if !node_tab.is_null() {
5646 for i in 0..node_nr as isize {
5647 let node = *node_tab.add(i as usize);
5648 ns.push(node);
5649 }
5650 }
5651 XPathValue::NodeSet(ns)
5652 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5653 XPathValue::Boolean((*obj).boolval != 0)
5654 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5655 XPathValue::Number((*obj).floatval)
5656 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5657 let s_ptr = (*obj).stringval;
5658 if s_ptr.is_null() {
5659 XPathValue::String(String::new())
5660 } else {
5661 let s = CStr::from_ptr(s_ptr as *const c_char)
5662 .to_string_lossy()
5663 .into_owned();
5664 XPathValue::String(s)
5665 }
5666 } else if typ == xmlXPathObjectType::XPATH_XSLT_TREE as c_int {
5667 let frag_doc = (*obj).nodesetval as *mut _xmlDoc;
5672 if frag_doc.is_null() {
5673 XPathValue::NodeSet(NodeSet::new())
5674 } else {
5675 let mut ns = NodeSet::new();
5676 ns.push(frag_doc as *mut _xmlNode);
5677 XPathValue::NodeSet(ns)
5678 }
5679 } else {
5680 XPathValue::Boolean(false)
5682 }
5683}
5684
5685pub unsafe fn xpath_to_object_pub(val: XPathValue) -> *mut _xmlXPathObject {
5691 xpath_to_object(val)
5692}
5693
5694pub unsafe fn object_to_xpathvalue_pub(obj: *mut _xmlXPathObject) -> XPathValue {
5701 object_to_xpathvalue(obj)
5702}
5703
5704static COMPILED_EXPRS: Lazy<Mutex<HashMap<u64, Box<CompiledExpr>>>> =
5710 Lazy::new(|| Mutex::new(HashMap::new()));
5711static NEXT_COMPILED_KEY: Lazy<Mutex<u64>> = Lazy::new(|| Mutex::new(1));
5712
5713pub(crate) fn xpath_compiled_registry() -> &'static Mutex<HashMap<u64, Box<CompiledExpr>>> {
5716 &COMPILED_EXPRS
5717}
5718
5719type CXPathFunc = unsafe extern "C" fn(*mut c_void, c_int);
5729
5730#[derive(Clone, Copy, PartialEq, Eq, Hash)]
5733struct SendSyncPtr(*mut c_void);
5734unsafe impl Send for SendSyncPtr {}
5735unsafe impl Sync for SendSyncPtr {}
5736
5737static C_FUNCTIONS: Lazy<Mutex<HashMap<(SendSyncPtr, String), CXPathFunc>>> =
5738 Lazy::new(|| Mutex::new(HashMap::new()));
5739
5740pub(crate) fn xpath_cfunc_lookup(extra: *mut c_void, qualified: &str) -> Option<CXPathFunc> {
5744 C_FUNCTIONS
5745 .lock()
5746 .get(&(SendSyncPtr(extra), qualified.to_string()))
5747 .copied()
5748}
5749
5750pub(crate) fn xpath_cfunc_cleanup(extra: *mut c_void) {
5753 C_FUNCTIONS.lock().retain(|(k, _), _| k.0 != extra);
5754}
5755
5756fn c_func_bridge_closure(c_ctxt: SendSyncPtr, qualified: String) -> BoxedXPathFunction {
5761 Box::new(move |_ctx: &mut XPathContext, args: &[XPathValue]| {
5762 let cc = c_ctxt;
5763 unsafe { c_func_call_bridge(cc.0 as *mut _xmlXPathContext, &qualified, args) }
5764 })
5765}
5766
5767pub(crate) unsafe fn call_c_xpath_function(
5777 fnptr: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
5778 c_ctxt: *mut _xmlXPathContext,
5779 args: &[XPathValue],
5780) -> Result<XPathValue, String> {
5781 let func = match fnptr {
5782 Some(f) => f,
5783 None => return Err("XPath: missing C function pointer".to_string()),
5784 };
5785 let pc = crate::xml::xpath::parser_context::new_parser_context(ptr::null(), c_ctxt);
5786 if pc.is_null() {
5787 return Err("XPath: parser-context allocation failure".to_string());
5788 }
5789 let mut push_ok = true;
5790 for v in args {
5791 let obj = xpath_to_object(v.clone());
5792 if obj.is_null() || crate::xml::xpath::parser_context::value_push(pc, obj).is_null() {
5793 push_ok = false;
5794 break;
5795 }
5796 }
5797 let result = if push_ok {
5798 unsafe { func(pc as *mut c_void, args.len() as c_int) };
5801 let ret = crate::xml::xpath::parser_context::value_pop(pc);
5802 if ret.is_null() {
5803 Err("XPath: C function returned no value".to_string())
5804 } else {
5805 let v = object_to_xpathvalue(ret);
5806 unsafe { xmlXPathFreeObject(ret) };
5808 Ok(v)
5809 }
5810 } else {
5811 Err("XPath: failed to push arguments to C function".to_string())
5812 };
5813 unsafe {
5815 loop {
5816 let leftover = crate::xml::xpath::parser_context::value_pop(pc);
5817 if leftover.is_null() {
5818 break;
5819 }
5820 xmlXPathFreeObject(leftover);
5821 }
5822 crate::xml::xpath::parser_context::free_parser_context(pc);
5823 }
5824 result
5825}
5826
5827unsafe fn c_func_call_bridge(
5834 c_ctxt: *mut _xmlXPathContext,
5835 qualified: &str,
5836 args: &[XPathValue],
5837) -> Result<XPathValue, String> {
5838 if c_ctxt.is_null() {
5839 return Err("XPath: null context in C function bridge".to_string());
5840 }
5841 let func = xpath_cfunc_lookup((*c_ctxt).extra, qualified);
5842 if func.is_none() {
5843 return Err(format!("XPath: unknown C function '{}'", qualified));
5844 }
5845 unsafe { call_c_xpath_function(func, c_ctxt, args) }
5846}
5847
5848#[no_mangle]
5861pub unsafe extern "C" fn xmlXPathNewContext(doc: *mut _xmlDoc) -> *mut _xmlXPathContext {
5862 let ctxt = xmlMallocZero(size_of::<_xmlXPathContext>()) as *mut _xmlXPathContext;
5863 if ctxt.is_null() {
5864 return ptr::null_mut();
5865 }
5866
5867 (*ctxt).doc = doc;
5869 (*ctxt).node = ptr::null_mut();
5870 (*ctxt).contextSize = 1;
5871 (*ctxt).proximityPosition = 1;
5872
5873 let mut internal = Box::new(XPathContext::new(doc));
5875 for (name, func) in crate::xml::xpath::functions::core_functions() {
5880 internal.register_function(&name, func);
5881 }
5882 (*ctxt).extra = Box::into_raw(internal) as *mut c_void;
5883
5884 ctxt
5885}
5886
5887#[no_mangle]
5895pub unsafe extern "C" fn xmlXPathFreeContext(ctxt: *mut _xmlXPathContext) {
5896 if ctxt.is_null() {
5897 return;
5898 }
5899 if !(*ctxt).extra.is_null() {
5901 let _ = Box::from_raw((*ctxt).extra as *mut XPathContext);
5902 (*ctxt).extra = ptr::null_mut();
5903 }
5904 if !(*ctxt).nsHash.is_null() {
5906 drop(Box::from_raw(
5907 (*ctxt).nsHash as *mut HashMap<String, CString>,
5908 ));
5909 (*ctxt).nsHash = ptr::null_mut();
5910 }
5911 xmlFreeImpl(ctxt as *mut c_void);
5913}
5914
5915#[no_mangle]
5924pub unsafe extern "C" fn xmlXPathEvalExpression(
5925 str_: *const xmlChar,
5926 ctxt: *mut _xmlXPathContext,
5927) -> *mut _xmlXPathObject {
5928 if str_.is_null() || ctxt.is_null() {
5929 return ptr::null_mut();
5930 }
5931 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
5932 Ok(s) => s,
5933 Err(_) => return ptr::null_mut(),
5934 };
5935 let internal = (*ctxt).extra as *mut XPathContext;
5936 if internal.is_null() {
5937 return ptr::null_mut();
5938 }
5939 let internal = &mut *internal;
5940 internal.clear_error();
5943
5944 match crate::xml::xpath::evaluate_str(expr_str, internal) {
5945 Some(val) => xpath_to_object(val),
5946 None => {
5947 if internal.error.is_none() {
5952 internal.set_error("Invalid expression");
5953 }
5954 ptr::null_mut()
5955 }
5956 }
5957}
5958
5959#[no_mangle]
5967pub unsafe extern "C" fn xmlXPathEval(
5968 str_: *const xmlChar,
5969 ctxt: *mut _xmlXPathContext,
5970) -> *mut _xmlXPathObject {
5971 xmlXPathEvalExpression(str_, ctxt)
5972}
5973
5974#[no_mangle]
5985pub unsafe extern "C" fn xmlXPathFreeObject(obj: *mut _xmlXPathObject) {
5986 if obj.is_null() {
5987 return;
5988 }
5989 let typ = (*obj).type_;
5990 if typ == xmlXPathObjectType::XPATH_STRING as c_int && !(*obj).stringval.is_null() {
5992 xmlFreeImpl((*obj).stringval as *mut c_void);
5993 (*obj).stringval = ptr::null_mut();
5994 }
5995 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5997 let ns = (*obj).nodesetval as *mut _xmlNodeSet;
5998 if !ns.is_null() {
5999 if !(*ns).nodeTab.is_null() {
6000 xmlFreeImpl((*ns).nodeTab as *mut c_void);
6001 }
6002 xmlFreeImpl(ns as *mut c_void);
6003 }
6004 (*obj).nodesetval = ptr::null_mut();
6005 }
6006 xmlFreeImpl(obj as *mut c_void);
6007}
6008
6009#[no_mangle]
6021pub unsafe extern "C" fn xmlXPathObjectCopy(val: *mut _xmlXPathObject) -> *mut _xmlXPathObject {
6022 if val.is_null() {
6023 return ptr::null_mut();
6024 }
6025 let typ = (*val).type_;
6026 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
6027 if obj.is_null() {
6028 return ptr::null_mut();
6029 }
6030 (*obj).type_ = typ;
6031 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
6032 let src_ns = (*val).nodesetval as *mut _xmlNodeSet;
6033 if !src_ns.is_null() {
6034 let nr = (*src_ns).nodeNr;
6035 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
6036 if ns.is_null() {
6037 xmlFreeImpl(obj as *mut c_void);
6038 return ptr::null_mut();
6039 }
6040 (*ns).nodeNr = nr;
6041 (*ns).nodeMax = nr;
6042 if nr > 0 && !(*src_ns).nodeTab.is_null() {
6043 let tab = xmlMallocImpl((nr as usize) * core::mem::size_of::<*mut _xmlNode>())
6044 as *mut *mut _xmlNode;
6045 if tab.is_null() {
6046 xmlFreeImpl(ns as *mut c_void);
6047 xmlFreeImpl(obj as *mut c_void);
6048 return ptr::null_mut();
6049 }
6050 ptr::copy_nonoverlapping((*src_ns).nodeTab, tab, nr as usize);
6051 (*ns).nodeTab = tab;
6052 } else {
6053 (*ns).nodeTab = ptr::null_mut();
6054 }
6055 (*obj).nodesetval = ns as *mut c_void;
6056 }
6057 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
6058 (*obj).boolval = (*val).boolval;
6059 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
6060 (*obj).floatval = (*val).floatval;
6061 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
6062 let src = (*val).stringval;
6063 if !src.is_null() {
6064 let len = libc::strlen(src as *const libc::c_char);
6065 let buf = xmlMallocImpl(len + 1) as *mut xmlChar;
6066 if !buf.is_null() {
6067 ptr::copy_nonoverlapping(src, buf, len);
6068 *buf.add(len) = 0;
6069 }
6070 (*obj).stringval = buf;
6071 }
6072 }
6073 obj
6074}
6075
6076#[no_mangle]
6086pub unsafe extern "C" fn xmlXPathCastToString(val: *mut _xmlXPathObject) -> *mut xmlChar {
6087 if val.is_null() {
6088 return ptr::null_mut();
6089 }
6090 let typ = (*val).type_;
6091 let mut result: Vec<u8> = Vec::new();
6092 if typ == xmlXPathObjectType::XPATH_STRING as c_int {
6093 if !(*val).stringval.is_null() {
6094 let len = libc::strlen((*val).stringval as *const libc::c_char);
6095 result.extend_from_slice(core::slice::from_raw_parts((*val).stringval, len));
6096 }
6097 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
6098 let n = (*val).floatval;
6104 result.extend_from_slice(xml_number_to_string(n).as_bytes());
6105 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
6106 result.extend_from_slice(if (*val).boolval != 0 {
6107 b"true"
6108 } else {
6109 b"false"
6110 });
6111 } else if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
6112 let ns = (*val).nodesetval as *mut _xmlNodeSet;
6115 if !ns.is_null() && (*ns).nodeNr > 0 && !(*ns).nodeTab.is_null() {
6116 let node = *(*ns).nodeTab;
6117 if !node.is_null() {
6118 let content = crate::xml::tree::node_get_content(node);
6119 if !content.is_null() {
6120 let len = libc::strlen(content as *const libc::c_char);
6121 result.extend_from_slice(core::slice::from_raw_parts(content, len));
6122 xmlFreeImpl(content as *mut c_void);
6123 }
6124 }
6125 }
6126 }
6127 let buf = xmlMallocImpl(result.len() + 1) as *mut xmlChar;
6129 if buf.is_null() {
6130 return ptr::null_mut();
6131 }
6132 if !result.is_empty() {
6133 ptr::copy_nonoverlapping(result.as_ptr(), buf, result.len());
6134 }
6135 *buf.add(result.len()) = 0;
6136 buf
6137}
6138
6139pub fn xml_number_to_string(n: f64) -> String {
6146 crate::xml::xpath::types::number_to_string(n)
6147}
6148
6149fn xpath_string_eval_number(bytes: &[u8]) -> f64 {
6157 crate::xml::xpath::types::string_bytes_to_number(bytes)
6158}
6159
6160#[no_mangle]
6168pub unsafe extern "C" fn xmlXPathCastStringToNumber(val: *const xmlChar) -> f64 {
6169 if val.is_null() {
6170 return f64::NAN;
6171 }
6172 let len = libc::strlen(val as *const libc::c_char);
6173 let bytes = core::slice::from_raw_parts(val, len);
6174 xpath_string_eval_number(bytes)
6175}
6176
6177#[no_mangle]
6191pub unsafe extern "C" fn xmlXPathCmpNodes(node1: *mut _xmlNode, node2: *mut _xmlNode) -> c_int {
6192 if node1.is_null() || node2.is_null() {
6193 return -2;
6194 }
6195 if node1 == node2 {
6196 return 0;
6197 }
6198 let mut chain1: Vec<*mut _xmlNode> = Vec::new();
6200 let mut chain2: Vec<*mut _xmlNode> = Vec::new();
6201 let mut n = node1;
6202 while !n.is_null() {
6203 chain1.push(n);
6204 n = (*n).parent;
6205 }
6206 let mut n = node2;
6207 while !n.is_null() {
6208 chain2.push(n);
6209 n = (*n).parent;
6210 }
6211 if chain1[chain1.len() - 1] != chain2[chain2.len() - 1] {
6213 return -2;
6214 }
6215 let mut i = chain1.len();
6217 let mut j = chain2.len();
6218 while i > 0 && j > 0 && chain1[i - 1] == chain2[j - 1] {
6219 i -= 1;
6220 j -= 1;
6221 }
6222 if i == 0 {
6224 return 1;
6225 }
6226 if j == 0 {
6228 return -1;
6229 }
6230 let mut a = chain1[i - 1];
6232 let mut b = chain2[j - 1];
6233 while !a.is_null() && !b.is_null() {
6235 let pa = (*a).parent;
6236 let pb = (*b).parent;
6237 if pa == pb {
6238 break;
6239 }
6240 a = pa;
6241 b = pb;
6242 }
6243 let parent = (*a).parent;
6245 let mut child = if parent.is_null() {
6246 ptr::null_mut()
6247 } else {
6248 (*parent).children
6249 };
6250 while !child.is_null() {
6251 if child == a {
6252 return 1; }
6254 if child == b {
6255 return -1; }
6257 child = (*child).next;
6258 }
6259 0
6260}
6261
6262#[no_mangle]
6272pub unsafe extern "C" fn xmlXPathNodeSetCreate(val: *mut _xmlNode) -> *mut _xmlNodeSet {
6273 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
6274 if ns.is_null() {
6275 return ptr::null_mut();
6276 }
6277 if val.is_null() {
6278 return ns;
6279 }
6280 let tab = xmlMallocImpl(core::mem::size_of::<*mut _xmlNode>()) as *mut *mut _xmlNode;
6281 if tab.is_null() {
6282 xmlFreeImpl(ns as *mut c_void);
6283 return ptr::null_mut();
6284 }
6285 *tab = val;
6286 (*ns).nodeTab = tab;
6287 (*ns).nodeNr = 1;
6288 (*ns).nodeMax = 1;
6289 ns
6290}
6291
6292#[no_mangle]
6304pub unsafe extern "C" fn xmlXPathFreeNodeSet(ns: *mut _xmlNodeSet) {
6305 if ns.is_null() {
6306 return;
6307 }
6308 if !(*ns).nodeTab.is_null() {
6309 xmlFreeImpl((*ns).nodeTab as *mut c_void);
6310 (*ns).nodeTab = ptr::null_mut();
6311 }
6312 (*ns).nodeNr = 0;
6313 (*ns).nodeMax = 0;
6314 xmlFreeImpl(ns as *mut c_void);
6315}
6316
6317#[no_mangle]
6328pub unsafe extern "C" fn xmlXPathCompile(str_: *const xmlChar) -> *mut c_void {
6329 if str_.is_null() {
6330 return ptr::null_mut();
6331 }
6332 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
6333 Ok(s) => s,
6334 Err(_) => return ptr::null_mut(),
6335 };
6336
6337 match crate::xml::xpath::compile(expr_str) {
6338 Some(compiled) => {
6339 let mut map = COMPILED_EXPRS.lock();
6340 let mut counter = NEXT_COMPILED_KEY.lock();
6341 let key = *counter;
6342 *counter += 1;
6343 map.insert(key, Box::new(compiled));
6344 key as *mut c_void
6345 }
6346 None => ptr::null_mut(),
6347 }
6348}
6349
6350#[no_mangle]
6358pub unsafe extern "C" fn xmlXPathFreeCompExpr(comp: *mut c_void) {
6359 if comp.is_null() {
6360 return;
6361 }
6362 let mut map = COMPILED_EXPRS.lock();
6363 map.remove(&(comp as u64));
6364}
6365
6366#[no_mangle]
6375pub unsafe extern "C" fn xmlXPathRegisterNs(
6376 ctxt: *mut _xmlXPathContext,
6377 prefix: *const xmlChar,
6378 ns_uri: *const xmlChar,
6379) -> c_int {
6380 if ctxt.is_null() || prefix.is_null() || ns_uri.is_null() {
6381 return -1;
6382 }
6383 let internal = (*ctxt).extra as *mut XPathContext;
6384 if internal.is_null() {
6385 return -1;
6386 }
6387 let internal = &mut *internal;
6388
6389 let prefix_str = match CStr::from_ptr(prefix as *const c_char).to_str() {
6390 Ok(s) => s,
6391 Err(_) => return -1,
6392 };
6393 let uri_str = match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6394 Ok(s) => s,
6395 Err(_) => return -1,
6396 };
6397
6398 internal.register_namespace(prefix_str, uri_str);
6399
6400 let map: &mut HashMap<String, CString> = if (*ctxt).nsHash.is_null() {
6405 let b: Box<HashMap<String, CString>> = Box::default();
6406 (*ctxt).nsHash = Box::into_raw(b) as *mut c_void;
6407 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6408 } else {
6409 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6410 };
6411 map.insert(
6412 prefix_str.to_string(),
6413 CString::new(uri_str.as_bytes()).unwrap_or_default(),
6414 );
6415 0
6416}
6417
6418#[no_mangle]
6432pub unsafe extern "C" fn xmlXPathRegisterFunc(
6433 ctxt: *mut _xmlXPathContext,
6434 name: *const xmlChar,
6435 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6436) -> c_int {
6437 if ctxt.is_null() || name.is_null() {
6438 return -1;
6439 }
6440 let internal = (*ctxt).extra as *mut XPathContext;
6441 if internal.is_null() {
6442 return -1;
6443 }
6444 let internal = &mut *internal;
6445
6446 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6447 Ok(s) => s,
6448 Err(_) => return -1,
6449 };
6450
6451 if let Some(func) = f {
6452 let key = (SendSyncPtr((*ctxt).extra), name_str.to_string());
6454 C_FUNCTIONS.lock().insert(key, func);
6455 let c_ctxt = SendSyncPtr(ctxt as *mut c_void);
6458 let name_owned = name_str.to_string();
6459 internal.register_function(name_str, c_func_bridge_closure(c_ctxt, name_owned));
6460 }
6461 0
6462}
6463
6464#[no_mangle]
6474pub unsafe extern "C" fn xmlXPathRegisterFuncNS(
6475 ctxt: *mut _xmlXPathContext,
6476 name: *const xmlChar,
6477 ns_uri: *const xmlChar,
6478 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6479) -> c_int {
6480 if ctxt.is_null() || name.is_null() {
6481 return -1;
6482 }
6483 let internal = (*ctxt).extra as *mut XPathContext;
6484 if internal.is_null() {
6485 return -1;
6486 }
6487 let internal = &mut *internal;
6488
6489 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6490 Ok(s) => s,
6491 Err(_) => return -1,
6492 };
6493 let ns_str = if ns_uri.is_null() {
6494 String::new()
6495 } else {
6496 match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6497 Ok(s) => s.to_string(),
6498 Err(_) => return -1,
6499 }
6500 };
6501
6502 let qualified = if ns_str.is_empty() {
6504 name_str.to_string()
6505 } else {
6506 format!("{{{}}}{}", ns_str, name_str)
6507 };
6508
6509 if let Some(func) = f {
6510 let key = (SendSyncPtr((*ctxt).extra), qualified.clone());
6511 C_FUNCTIONS.lock().insert(key, func);
6512 let c_ctxt = SendSyncPtr(ctxt as *mut c_void);
6513 let qualified_owned = qualified.clone();
6514 internal.register_function(&qualified, c_func_bridge_closure(c_ctxt, qualified_owned));
6515 }
6516 0
6517}
6518
6519#[no_mangle]
6528pub unsafe extern "C" fn xmlXPathRegisterVariable(
6529 ctxt: *mut _xmlXPathContext,
6530 name: *const xmlChar,
6531 value: *mut _xmlXPathObject,
6532) -> c_int {
6533 if ctxt.is_null() || name.is_null() || value.is_null() {
6534 return -1;
6535 }
6536 let internal = (*ctxt).extra as *mut XPathContext;
6537 if internal.is_null() {
6538 return -1;
6539 }
6540 let internal = &mut *internal;
6541
6542 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6543 Ok(s) => s,
6544 Err(_) => return -1,
6545 };
6546
6547 let xpath_val = object_to_xpathvalue(value);
6548 internal.register_variable(name_str, xpath_val);
6549 0
6550}
6551
6552#[no_mangle]
6560pub unsafe extern "C" fn xmlXPathNewNodeSet(val: *mut _xmlNode) -> *mut _xmlXPathObject {
6561 let ns = if val.is_null() {
6562 NodeSet::new()
6563 } else {
6564 NodeSet::singleton(val)
6565 };
6566 xpath_to_object(XPathValue::NodeSet(ns))
6567}
6568
6569#[no_mangle]
6577pub unsafe extern "C" fn xmlXPathNewCString(val: *const xmlChar) -> *mut _xmlXPathObject {
6578 if val.is_null() {
6579 return xpath_to_object(XPathValue::String(String::new()));
6580 }
6581 let s = match CStr::from_ptr(val as *const c_char).to_str() {
6582 Ok(s) => s.to_string(),
6583 Err(_) => return ptr::null_mut(),
6584 };
6585 xpath_to_object(XPathValue::String(s))
6586}
6587
6588#[no_mangle]
6596pub extern "C" fn xmlXPathNewFloat(val: f64) -> *mut _xmlXPathObject {
6597 unsafe { xpath_to_object(XPathValue::Number(val)) }
6598}
6599
6600#[no_mangle]
6608pub extern "C" fn xmlXPathNewBoolean(val: c_int) -> *mut _xmlXPathObject {
6609 unsafe { xpath_to_object(XPathValue::Boolean(val != 0)) }
6610}
6611
6612#[no_mangle]
6626pub unsafe extern "C" fn xmlXPtrEval(expr: *const c_char, doc: *mut _xmlDoc) -> *mut _xmlNode {
6627 crate::xml::xpointer::xmlXPtrEval(expr, doc)
6628}
6629
6630#[no_mangle]
6642pub unsafe extern "C" fn xmlXIncludeProcess(doc: *mut _xmlDoc) -> c_int {
6643 crate::xml::xinclude::xinclude_process(doc)
6644}
6645
6646#[no_mangle]
6654pub unsafe extern "C" fn xmlXIncludeProcessFlags(doc: *mut _xmlDoc, flags: c_int) -> c_int {
6655 crate::xml::xinclude::xinclude_process_flags(doc, flags)
6656}
6657
6658#[no_mangle]
6670pub extern "C" fn xmlCatalogLoad(catalogs: *const c_char) -> *mut c_void {
6671 if catalogs.is_null() {
6672 return ptr::null_mut();
6673 }
6674 crate::xml::catalog::load_catalog(catalogs)
6675}
6676
6677#[no_mangle]
6685pub unsafe extern "C" fn xmlCatalogResolvePublic(pubID: *const xmlChar) -> *mut xmlChar {
6686 if pubID.is_null() {
6687 return ptr::null_mut();
6688 }
6689 crate::xml::catalog::resolve_public(pubID)
6690}
6691
6692#[no_mangle]
6700pub unsafe extern "C" fn xmlCatalogResolveSystem(sysID: *const xmlChar) -> *mut xmlChar {
6701 if sysID.is_null() {
6702 return ptr::null_mut();
6703 }
6704 crate::xml::catalog::resolve_system(sysID)
6705}
6706
6707#[no_mangle]
6715pub unsafe extern "C" fn xmlCatalogResolveURI(URI: *const xmlChar) -> *mut xmlChar {
6716 if URI.is_null() {
6717 return ptr::null_mut();
6718 }
6719 crate::xml::catalog::resolve_uri(URI)
6720}
6721
6722#[no_mangle]
6730pub extern "C" fn xmlCatalogSetDefaults(allow: c_int) {
6731 crate::xml::catalog::set_defaults(allow)
6732}
6733
6734#[no_mangle]
6742pub extern "C" fn xmlCatalogGetDefaults() -> c_int {
6743 crate::xml::catalog::get_defaults()
6744}
6745
6746#[no_mangle]
6754pub unsafe extern "C" fn xmlCatalogAdd(
6755 type_: *const xmlChar,
6756 orig: *const xmlChar,
6757 replace: *const xmlChar,
6758) -> c_int {
6759 if type_.is_null() || orig.is_null() || replace.is_null() {
6760 return -1;
6761 }
6762 crate::xml::catalog::add(type_, orig, replace)
6763}
6764
6765#[no_mangle]
6773pub unsafe extern "C" fn xmlCatalogRemove(value: *const xmlChar) -> c_int {
6774 if value.is_null() {
6775 return 0;
6776 }
6777 crate::xml::catalog::remove(value)
6778}
6779
6780#[no_mangle]
6790pub unsafe extern "C" fn xmlCatalogDump(output: *mut c_void) {
6791 if output.is_null() {
6792 return;
6793 }
6794 let doc = crate::xml::catalog::dump_doc();
6795 if doc.is_null() {
6796 return;
6797 }
6798 let mut mem: *mut xmlChar = ptr::null_mut();
6799 let mut size: c_int = 0;
6800 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6801 if !mem.is_null() {
6802 libc::fwrite(
6803 mem as *const c_void,
6804 1,
6805 size as usize,
6806 output as *mut libc::FILE,
6807 );
6808 xmlFreeImpl(mem as *mut c_void);
6809 }
6810 crate::xml::tree::free_doc(doc);
6811}
6812
6813#[no_mangle]
6823pub unsafe extern "C" fn xmlCatalogSave(filename: *const c_char) -> c_int {
6824 if filename.is_null() {
6825 return -1;
6826 }
6827 let doc = crate::xml::catalog::dump_doc();
6828 if doc.is_null() {
6829 return -1;
6830 }
6831 let mut mem: *mut xmlChar = ptr::null_mut();
6832 let mut size: c_int = 0;
6833 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6834 let mut ret: c_int = -1;
6835 if !mem.is_null() {
6836 let fp = libc::fopen(filename, c"w".as_ptr() as *const c_char);
6837 if !fp.is_null() {
6838 let written = libc::fwrite(mem as *const c_void, 1, size as usize, fp);
6839 ret = if written == size as usize { 0 } else { -1 };
6840 libc::fclose(fp);
6841 }
6842 xmlFreeImpl(mem as *mut c_void);
6843 }
6844 crate::xml::tree::free_doc(doc);
6845 ret
6846}
6847
6848#[no_mangle]
6856pub extern "C" fn xmlCatalogCleanup() {
6857 crate::xml::catalog::cleanup();
6858}
6859
6860#[no_mangle]
6875pub extern "C" fn xmlCatalogConvert() -> c_int {
6876 if !crate::xml::catalog::is_initialized() {
6877 return -1;
6878 }
6879 0
6880}
6881
6882#[no_mangle]
6894pub const unsafe extern "C" fn htmlParseFile(
6895 _filename: *const c_char,
6896 _encoding: *const c_char,
6897) -> *mut _xmlDoc {
6898 ptr::null_mut()
6900}
6901
6902#[no_mangle]
6910pub const unsafe extern "C" fn htmlParseMemory(
6911 _buffer: *const c_char,
6912 _size: c_int,
6913) -> *mut _xmlDoc {
6914 ptr::null_mut()
6916}
6917
6918#[no_mangle]
6926pub const unsafe extern "C" fn htmlParseDoc(
6927 _cur: *const xmlChar,
6928 _encoding: *const c_char,
6929) -> *mut _xmlDoc {
6930 ptr::null_mut()
6932}
6933
6934#[no_mangle]
6943pub const unsafe extern "C" fn htmlCreateFileParserCtxt(
6944 _filename: *const c_char,
6945 _encoding: *const c_char,
6946) -> *mut c_void {
6947 ptr::null_mut()
6949}
6950
6951#[no_mangle]
6959pub extern "C" fn htmlFreeParserCtxt(ctxt: *mut c_void) {
6960 unsafe { crate::xml::html::free_parser_ctxt(ctxt) }
6961}
6962
6963#[no_mangle]
6971pub const extern "C" fn htmlInitParser() {
6972 }
6974
6975#[no_mangle]
6983pub const extern "C" fn htmlCleanupParser() {
6984 }
6986
6987#[no_mangle]
6999pub unsafe extern "C" fn xmlNewValidCtxt() -> *mut _xmlValidCtxt {
7000 crate::xml::validation::new_valid_ctxt()
7001}
7002
7003#[no_mangle]
7011pub unsafe extern "C" fn xmlFreeValidCtxt(ctxt: *mut _xmlValidCtxt) {
7012 crate::xml::validation::free_valid_ctxt(ctxt);
7013}
7014
7015#[no_mangle]
7026pub unsafe extern "C" fn xmlSetValidErrors(
7027 ctxt: *mut _xmlValidCtxt,
7028 err: Option<xmlGenericErrorFunc>,
7029 warn: Option<xmlGenericErrorFunc>,
7030 data: *mut c_void,
7031) {
7032 crate::xml::validation::set_valid_errors(ctxt, err, warn, data);
7033}
7034
7035#[no_mangle]
7043pub unsafe extern "C" fn xmlValidateDocument(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7044 crate::xml::validation::validate_document(ctxt, doc)
7045}
7046
7047#[no_mangle]
7055pub unsafe extern "C" fn xmlValidateDocumentFinal(
7056 ctxt: *mut _xmlValidCtxt,
7057 doc: *mut _xmlDoc,
7058) -> c_int {
7059 crate::xml::validation::validate_document_final(ctxt, doc)
7060}
7061
7062#[no_mangle]
7072pub unsafe extern "C" fn xmlValidateElement(
7073 ctxt: *mut _xmlValidCtxt,
7074 doc: *mut _xmlDoc,
7075 elem: *mut _xmlNode,
7076) -> c_int {
7077 crate::xml::validation::validate_element(ctxt, doc, elem)
7078}
7079
7080#[no_mangle]
7093pub unsafe extern "C" fn xmlValidateAttributeDecl(
7094 ctxt: *mut _xmlValidCtxt,
7095 doc: *mut _xmlDoc,
7096 attr: *mut _xmlAttribute,
7097) -> c_int {
7098 crate::xml::validation::validate_attribute_decl(ctxt, doc, attr)
7099}
7100
7101#[no_mangle]
7109pub unsafe extern "C" fn xmlValidateAttributeValue(atype: c_int, value: *const xmlChar) -> c_int {
7110 crate::xml::validation::validate_attribute_value(atype, value)
7111}
7112
7113#[no_mangle]
7123pub unsafe extern "C" fn xmlValidateNotationUse(
7124 ctxt: *mut _xmlValidCtxt,
7125 doc: *mut _xmlDoc,
7126 notation_name: *const xmlChar,
7127) -> c_int {
7128 crate::xml::validation::validate_notation_use(ctxt, doc, notation_name)
7129}
7130
7131#[no_mangle]
7142pub unsafe extern "C" fn xmlValidateID(
7143 ctxt: *mut _xmlValidCtxt,
7144 doc: *mut _xmlDoc,
7145 node: *mut _xmlNode,
7146 value: *const xmlChar,
7147) -> c_int {
7148 crate::xml::validation::validate_id(ctxt, doc, node, value)
7149}
7150
7151#[no_mangle]
7161pub unsafe extern "C" fn xmlValidateIDRef(
7162 ctxt: *mut _xmlValidCtxt,
7163 doc: *mut _xmlDoc,
7164 value: *const xmlChar,
7165) -> c_int {
7166 crate::xml::validation::validate_id_ref(ctxt, doc, ptr::null_mut(), value)
7167}
7168
7169#[no_mangle]
7179pub unsafe extern "C" fn xmlValidateIDRefs(
7180 ctxt: *mut _xmlValidCtxt,
7181 doc: *mut _xmlDoc,
7182 value: *const xmlChar,
7183) -> c_int {
7184 crate::xml::validation::validate_id_refs(ctxt, doc, ptr::null_mut(), value)
7185}
7186
7187#[no_mangle]
7197pub unsafe extern "C" fn xmlValidateNCName(value: *const xmlChar, space: c_int) -> c_int {
7198 crate::xml::validation::validate_ncname(value, space)
7199}
7200
7201#[no_mangle]
7209pub unsafe extern "C" fn xmlValidateQName(value: *const xmlChar, space: c_int) -> c_int {
7210 crate::xml::validation::validate_qname(value, space)
7211}
7212
7213#[no_mangle]
7226pub unsafe extern "C" fn xmlValidateName(value: *const xmlChar, space: c_int) -> c_int {
7227 crate::xml::validation::validate_name_space(value, space)
7228}
7229
7230#[no_mangle]
7238pub unsafe extern "C" fn xmlValidateNMToken(value: *const xmlChar, space: c_int) -> c_int {
7239 crate::xml::validation::validate_nmtoken_space(value, space)
7240}
7241
7242#[no_mangle]
7252pub unsafe extern "C" fn xmlValidateNameValue(value: *const xmlChar) -> c_int {
7253 crate::xml::validation::validate_name_value(value)
7254}
7255
7256#[no_mangle]
7265pub unsafe extern "C" fn xmlValidateNamesValue(value: *const xmlChar) -> c_int {
7266 crate::xml::validation::validate_names_value(value)
7267}
7268
7269#[no_mangle]
7277pub unsafe extern "C" fn xmlValidateNmtokenValue(value: *const xmlChar) -> c_int {
7278 crate::xml::validation::validate_nmtoken_value(value)
7279}
7280
7281#[no_mangle]
7289pub unsafe extern "C" fn xmlValidateNmtokensValue(value: *const xmlChar) -> c_int {
7290 crate::xml::validation::validate_nmtokens_value(value)
7291}
7292
7293#[no_mangle]
7304pub unsafe extern "C" fn xmlValidateElementDecl(
7305 ctxt: *mut _xmlValidCtxt,
7306 doc: *mut _xmlDoc,
7307 elem: *mut _xmlElement,
7308) -> c_int {
7309 crate::xml::validation::validate_element_decl(ctxt, doc, elem)
7310}
7311
7312#[no_mangle]
7325pub const unsafe extern "C" fn xmlValidateNotationDecl(
7326 ctxt: *mut _xmlValidCtxt,
7327 doc: *mut _xmlDoc,
7328 nota: *mut _xmlNotation,
7329) -> c_int {
7330 crate::xml::validation::validate_notation_decl(ctxt, doc, nota)
7331}
7332
7333#[no_mangle]
7345pub unsafe extern "C" fn xmlValidateOneAttribute(
7346 ctxt: *mut _xmlValidCtxt,
7347 doc: *mut _xmlDoc,
7348 elem: *mut _xmlNode,
7349 attr: *mut _xmlAttr,
7350 value: *const xmlChar,
7351) -> c_int {
7352 crate::xml::validation::validate_one_attribute(ctxt, doc, elem, attr, value)
7353}
7354
7355#[no_mangle]
7365pub unsafe extern "C" fn xmlValidateOneElement(
7366 ctxt: *mut _xmlValidCtxt,
7367 doc: *mut _xmlDoc,
7368 elem: *mut _xmlNode,
7369) -> c_int {
7370 crate::xml::validation::validate_one_element(ctxt, doc, elem)
7371}
7372
7373#[no_mangle]
7386pub unsafe extern "C" fn xmlValidateOneNamespace(
7387 ctxt: *mut _xmlValidCtxt,
7388 doc: *mut _xmlDoc,
7389 elem: *mut _xmlNode,
7390 prefix: *const xmlChar,
7391 ns: *mut _xmlNs,
7392 value: *const xmlChar,
7393) -> c_int {
7394 crate::xml::validation::validate_one_namespace(ctxt, doc, elem, prefix, ns, value)
7395}
7396
7397#[no_mangle]
7409pub unsafe extern "C" fn xmlValidatePushElement(
7410 ctxt: *mut _xmlValidCtxt,
7411 doc: *mut _xmlDoc,
7412 elem: *mut _xmlNode,
7413 qname: *const xmlChar,
7414) -> c_int {
7415 crate::xml::validation::validate_push_element(ctxt, doc, elem, qname)
7416}
7417
7418#[no_mangle]
7428pub unsafe extern "C" fn xmlValidatePushCData(
7429 ctxt: *mut _xmlValidCtxt,
7430 data: *const xmlChar,
7431 len: c_int,
7432) -> c_int {
7433 crate::xml::validation::validate_push_cdata(ctxt, data, len)
7434}
7435
7436#[no_mangle]
7447pub unsafe extern "C" fn xmlValidatePopElement(
7448 ctxt: *mut _xmlValidCtxt,
7449 doc: *mut _xmlDoc,
7450 elem: *mut _xmlNode,
7451 qname: *const xmlChar,
7452) -> c_int {
7453 crate::xml::validation::validate_pop_element(ctxt, doc, elem, qname)
7454}
7455
7456#[no_mangle]
7465pub unsafe extern "C" fn xmlValidBuildContentModel(
7466 ctxt: *mut _xmlValidCtxt,
7467 elem: *mut _xmlElement,
7468) -> c_int {
7469 crate::xml::validation::validate_build_content_model(ctxt, elem)
7470}
7471
7472#[no_mangle]
7483pub unsafe extern "C" fn xmlAddID(
7484 ctxt: *mut _xmlValidCtxt,
7485 doc: *mut _xmlDoc,
7486 value: *const xmlChar,
7487 attr: *mut _xmlAttr,
7488) -> *mut _xmlID {
7489 crate::xml::validation::add_id(ctxt, doc, value, attr)
7490}
7491
7492#[no_mangle]
7500pub unsafe extern "C" fn xmlRemoveID(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7501 crate::xml::validation::remove_id(doc, attr)
7502}
7503
7504#[no_mangle]
7515pub unsafe extern "C" fn xmlAddRef(
7516 ctxt: *mut _xmlValidCtxt,
7517 doc: *mut _xmlDoc,
7518 value: *const xmlChar,
7519 attr: *mut _xmlAttr,
7520) -> *mut _xmlRef {
7521 crate::xml::validation::add_ref(ctxt, doc, value, attr)
7522}
7523
7524#[no_mangle]
7532pub unsafe extern "C" fn xmlRemoveRef(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7533 crate::xml::validation::remove_ref(doc, attr)
7534}
7535
7536#[no_mangle]
7544pub unsafe extern "C" fn xmlAddIDSafe(attr: *mut _xmlAttr, value: *const xmlChar) -> c_int {
7545 crate::xml::validation::add_id_safe(attr, value)
7546}
7547
7548#[no_mangle]
7556pub unsafe extern "C" fn xmlFreeIDTable(table: *mut c_void) {
7557 crate::xml::validation::free_id_table(table as *mut crate::xml::hash::HashTable);
7558}
7559
7560#[no_mangle]
7568pub unsafe extern "C" fn xmlFreeRefTable(table: *mut c_void) {
7569 crate::xml::validation::free_ref_table(table as *mut crate::xml::hash::HashTable);
7570}
7571
7572#[no_mangle]
7580pub unsafe extern "C" fn xmlGetID(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut _xmlAttr {
7581 crate::xml::validation::get_id(doc, id)
7582}
7583
7584#[no_mangle]
7592pub unsafe extern "C" fn xmlGetRefs(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut c_void {
7593 crate::xml::validation::get_refs(doc, id) as *mut c_void
7594}
7595
7596#[no_mangle]
7604pub unsafe extern "C" fn xmlIsID(
7605 doc: *mut _xmlDoc,
7606 elem: *mut _xmlNode,
7607 attr: *mut _xmlAttr,
7608) -> c_int {
7609 crate::xml::validation::is_id(doc, elem, attr)
7610}
7611
7612#[no_mangle]
7620pub unsafe extern "C" fn xmlIsRef(
7621 doc: *mut _xmlDoc,
7622 elem: *mut _xmlNode,
7623 attr: *mut _xmlAttr,
7624) -> c_int {
7625 crate::xml::validation::is_ref(doc, elem, attr)
7626}
7627
7628#[no_mangle]
7636pub unsafe extern "C" fn xmlGetDtdElementDesc(
7637 dtd: *mut _xmlDtd,
7638 name: *const xmlChar,
7639) -> *mut _xmlElement {
7640 crate::xml::validation::get_dtd_element_desc(dtd, name)
7641}
7642
7643#[no_mangle]
7653pub unsafe extern "C" fn xmlGetDtdAttrDesc(
7654 dtd: *mut _xmlDtd,
7655 elem: *const xmlChar,
7656 name: *const xmlChar,
7657) -> *mut _xmlAttribute {
7658 crate::xml::validation::get_dtd_attr_desc(dtd, elem, name)
7659}
7660
7661#[no_mangle]
7671pub unsafe extern "C" fn xmlGetDtdQElementDesc(
7672 dtd: *mut _xmlDtd,
7673 name: *const xmlChar,
7674 prefix: *const xmlChar,
7675) -> *mut _xmlElement {
7676 crate::xml::validation::get_dtd_qelement_desc(dtd, name, prefix)
7677}
7678
7679#[no_mangle]
7690pub unsafe extern "C" fn xmlGetDtdQAttrDesc(
7691 dtd: *mut _xmlDtd,
7692 elem: *const xmlChar,
7693 name: *const xmlChar,
7694 prefix: *const xmlChar,
7695) -> *mut _xmlAttribute {
7696 crate::xml::validation::get_dtd_qattr_desc(dtd, elem, name, prefix)
7697}
7698
7699#[no_mangle]
7707pub unsafe extern "C" fn xmlGetDtdNotationDesc(
7708 dtd: *mut _xmlDtd,
7709 name: *const xmlChar,
7710) -> *mut _xmlNotation {
7711 crate::xml::validation::get_dtd_notation_desc(dtd, name)
7712}
7713
7714#[no_mangle]
7722pub unsafe extern "C" fn xmlValidateRoot(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7723 crate::xml::validation::validate_root(ctxt, doc)
7724}
7725
7726#[no_mangle]
7736pub unsafe extern "C" fn xmlValidateContent(
7737 ctxt: *mut _xmlValidCtxt,
7738 node: *mut _xmlNode,
7739 doc: *mut _xmlDoc,
7740) -> c_int {
7741 crate::xml::validation::validate_content(ctxt, node, doc)
7742}
7743
7744#[no_mangle]
7752pub unsafe extern "C" fn xmlIsMixedElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7753 crate::xml::validation::is_mixed_element(doc, name)
7754}
7755
7756#[no_mangle]
7764pub unsafe extern "C" fn xmlIsEmptyElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7765 crate::xml::validation::is_empty_element(doc, name)
7766}
7767
7768#[no_mangle]
7778pub unsafe extern "C" fn xmlValidateDtd(
7779 ctxt: *mut _xmlValidCtxt,
7780 doc: *mut _xmlDoc,
7781 dtd: *mut _xmlDtd,
7782) -> c_int {
7783 crate::xml::validation::validate_dtd(ctxt, doc, dtd)
7784}
7785
7786#[no_mangle]
7794pub unsafe extern "C" fn xmlValidateDtdFinal(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7795 crate::xml::validation::validate_dtd_final(ctxt, doc)
7796}
7797
7798#[no_mangle]
7808pub unsafe extern "C" fn xmlValidateEnumeration(
7809 ctxt: *mut _xmlValidCtxt,
7810 value: *const xmlChar,
7811 tree: *mut _xmlEnumeration,
7812) -> c_int {
7813 crate::xml::validation::validate_enumeration(ctxt, value, tree)
7814}
7815
7816#[no_mangle]
7829pub const extern "C" fn xmlGetBinaryPath() -> *mut c_char {
7830 ptr::null_mut()
7832}
7833
7834#[no_mangle]
7842pub const extern "C" fn xmlGetHomeOfBinary() -> *mut c_char {
7843 ptr::null_mut()
7845}
7846
7847#[no_mangle]
7858pub unsafe extern "C" fn xmlSAX2StartDocument(ctx: *mut c_void) {
7859 crate::xml::sax::default::default_sax_handler::startDocument(ctx)
7860}
7861
7862#[no_mangle]
7864pub unsafe extern "C" fn xmlSAX2EndDocument(ctx: *mut c_void) {
7865 crate::xml::sax::default::default_sax_handler::endDocument(ctx)
7866}
7867
7868#[no_mangle]
7870pub unsafe extern "C" fn xmlSAX2StartElementNs(
7871 ctx: *mut c_void,
7872 localname: *const xmlChar,
7873 prefix: *const xmlChar,
7874 URI: *const xmlChar,
7875 nb_namespaces: c_int,
7876 namespaces: *mut *const xmlChar,
7877 nb_attributes: c_int,
7878 nb_defaulted: c_int,
7879 attributes: *mut *const xmlChar,
7880) {
7881 crate::xml::sax::default::default_sax_handler::startElementNs(
7882 ctx,
7883 localname,
7884 prefix,
7885 URI,
7886 nb_namespaces,
7887 namespaces,
7888 nb_attributes,
7889 nb_defaulted,
7890 attributes,
7891 )
7892}
7893
7894#[no_mangle]
7896pub unsafe extern "C" fn xmlSAX2EndElementNs(
7897 ctx: *mut c_void,
7898 localname: *const xmlChar,
7899 prefix: *const xmlChar,
7900 URI: *const xmlChar,
7901) {
7902 crate::xml::sax::default::default_sax_handler::endElementNs(ctx, localname, prefix, URI)
7903}
7904
7905#[no_mangle]
7907pub unsafe extern "C" fn xmlSAX2Characters(ctx: *mut c_void, ch: *const xmlChar, len: c_int) {
7908 crate::xml::sax::default::default_sax_handler::characters(ctx, ch, len)
7909}
7910
7911#[no_mangle]
7913pub unsafe extern "C" fn xmlSAX2IgnorableWhitespace(
7914 ctx: *mut c_void,
7915 ch: *const xmlChar,
7916 len: c_int,
7917) {
7918 crate::xml::sax::default::default_sax_handler::ignorableWhitespace(ctx, ch, len)
7919}
7920
7921#[no_mangle]
7923pub unsafe extern "C" fn xmlSAX2Comment(ctx: *mut c_void, value: *const xmlChar) {
7924 crate::xml::sax::default::default_sax_handler::comment(ctx, value)
7925}
7926
7927#[no_mangle]
7929pub unsafe extern "C" fn xmlSAX2ProcessingInstruction(
7930 ctx: *mut c_void,
7931 target: *const xmlChar,
7932 data: *const xmlChar,
7933) {
7934 crate::xml::sax::default::default_sax_handler::processingInstruction(ctx, target, data)
7935}
7936
7937#[no_mangle]
7939pub unsafe extern "C" fn xmlSAX2CDataBlock(ctx: *mut c_void, value: *const xmlChar, len: c_int) {
7940 crate::xml::sax::default::default_sax_handler::cdataBlock(ctx, value, len)
7941}
7942
7943#[no_mangle]
7945pub unsafe extern "C" fn xmlSAX2InternalSubset(
7946 ctx: *mut c_void,
7947 name: *const xmlChar,
7948 ExternalID: *const xmlChar,
7949 SystemID: *const xmlChar,
7950) {
7951 crate::xml::sax::default::default_sax_handler::internalSubset(ctx, name, ExternalID, SystemID)
7952}
7953
7954#[no_mangle]
7956pub unsafe extern "C" fn xmlSAX2ExternalSubset(
7957 ctx: *mut c_void,
7958 name: *const xmlChar,
7959 ExternalID: *const xmlChar,
7960 SystemID: *const xmlChar,
7961) {
7962 crate::xml::sax::default::default_sax_handler::externalSubset(ctx, name, ExternalID, SystemID)
7963}
7964
7965#[no_mangle]
7967pub unsafe extern "C" fn xmlSAX2EntityDecl(
7968 ctx: *mut c_void,
7969 name: *const xmlChar,
7970 type_: c_int,
7971 publicId: *const xmlChar,
7972 systemId: *const xmlChar,
7973 content: *mut xmlChar,
7974) {
7975 crate::xml::sax::default::default_sax_handler::entityDecl(
7976 ctx, name, type_, publicId, systemId, content,
7977 )
7978}
7979
7980#[no_mangle]
7982pub const unsafe extern "C" fn xmlSAX2AttributeDecl(
7983 ctx: *mut c_void,
7984 elem: *const xmlChar,
7985 fullname: *const xmlChar,
7986 type_: c_int,
7987 def: c_int,
7988 defaultValue: *const xmlChar,
7989 tree: *mut crate::abi::structs::_xmlEnumeration,
7990) {
7991 crate::xml::sax::default::default_sax_handler::attributeDecl(
7992 ctx,
7993 elem,
7994 fullname,
7995 type_,
7996 def,
7997 defaultValue,
7998 tree,
7999 )
8000}
8001
8002#[no_mangle]
8004pub const unsafe extern "C" fn xmlSAX2ElementDecl(
8005 ctx: *mut c_void,
8006 name: *const xmlChar,
8007 type_: c_int,
8008 content: *mut crate::abi::structs::_xmlElementContent,
8009) {
8010 crate::xml::sax::default::default_sax_handler::elementDecl(ctx, name, type_, content)
8011}
8012
8013#[no_mangle]
8015pub const unsafe extern "C" fn xmlSAX2NotationDecl(
8016 ctx: *mut c_void,
8017 name: *const xmlChar,
8018 publicId: *const xmlChar,
8019 systemId: *const xmlChar,
8020) {
8021 crate::xml::sax::default::default_sax_handler::notationDecl(ctx, name, publicId, systemId)
8022}
8023
8024#[no_mangle]
8026pub const unsafe extern "C" fn xmlSAX2UnparsedEntityDecl(
8027 ctx: *mut c_void,
8028 name: *const xmlChar,
8029 publicId: *const xmlChar,
8030 systemId: *const xmlChar,
8031 notationName: *const xmlChar,
8032) {
8033 crate::xml::sax::default::default_sax_handler::unparsedEntityDecl(
8034 ctx,
8035 name,
8036 publicId,
8037 systemId,
8038 notationName,
8039 )
8040}
8041
8042#[no_mangle]
8044pub const unsafe extern "C" fn xmlSAX2ResolveEntity(
8045 ctx: *mut c_void,
8046 publicId: *const xmlChar,
8047 systemId: *const xmlChar,
8048) -> *mut crate::abi::structs::_xmlParserInput {
8049 crate::xml::sax::default::default_sax_handler::resolveEntity(ctx, publicId, systemId)
8050}
8051
8052#[no_mangle]
8054pub const unsafe extern "C" fn xmlSAX2IsStandalone(ctx: *mut c_void) -> c_int {
8055 crate::xml::sax::default::default_sax_handler::isStandalone(ctx)
8056}
8057
8058#[no_mangle]
8060pub unsafe extern "C" fn xmlSAX2HasInternalSubset(ctx: *mut c_void) -> c_int {
8061 crate::xml::sax::default::default_sax_handler::hasInternalSubset(ctx)
8062}
8063
8064#[no_mangle]
8066pub unsafe extern "C" fn xmlSAX2HasExternalSubset(ctx: *mut c_void) -> c_int {
8067 crate::xml::sax::default::default_sax_handler::hasExternalSubset(ctx)
8068}
8069
8070#[no_mangle]
8072pub unsafe extern "C" fn xmlSAX2GetEntity(
8073 ctx: *mut c_void,
8074 name: *const xmlChar,
8075) -> *mut crate::abi::structs::_xmlEntity {
8076 crate::xml::sax::default::default_sax_handler::getEntity(ctx, name)
8077}
8078
8079#[no_mangle]
8081pub unsafe extern "C" fn xmlSAX2GetParameterEntity(
8082 ctx: *mut c_void,
8083 name: *const xmlChar,
8084) -> *mut crate::abi::structs::_xmlEntity {
8085 crate::xml::sax::default::default_sax_handler::getParameterEntity(ctx, name)
8086}
8087
8088#[no_mangle]
8091pub unsafe extern "C" fn xmlSAX2GetLineNumber(ctx: *mut c_void) -> c_int {
8092 crate::xml::sax::default::default_sax_handler::getLineNumber(ctx)
8093}
8094
8095#[no_mangle]
8097pub unsafe extern "C" fn xmlSAX2GetColumnNumber(ctx: *mut c_void) -> c_int {
8098 crate::xml::sax::default::default_sax_handler::getColumnNumber(ctx)
8099}
8100
8101#[no_mangle]
8103pub const unsafe extern "C" fn xmlSAX2GetPublicId(ctx: *mut c_void) -> *const xmlChar {
8104 crate::xml::sax::default::default_sax_handler::getPublicId(ctx)
8105}
8106
8107#[no_mangle]
8109pub unsafe extern "C" fn xmlSAX2GetSystemId(ctx: *mut c_void) -> *const xmlChar {
8110 crate::xml::sax::default::default_sax_handler::getSystemId(ctx)
8111}
8112
8113#[no_mangle]
8117pub unsafe extern "C" fn xmlSAX2StartElement(
8118 ctx: *mut c_void,
8119 name: *const xmlChar,
8120 atts: *mut *const xmlChar,
8121) {
8122 crate::xml::sax::dispatch::SaxDispatcher::sax1_start_element(ctx, name, atts);
8126}
8127
8128#[no_mangle]
8130pub unsafe extern "C" fn xmlSAX2EndElement(ctx: *mut c_void, name: *const xmlChar) {
8131 crate::xml::sax::dispatch::SaxDispatcher::sax1_end_element(ctx, name);
8132}
8133
8134#[no_mangle]
8136pub const unsafe extern "C" fn xmlSAX2SetDocumentLocator(
8137 ctx: *mut c_void,
8138 loc: *mut crate::abi::callbacks::_xmlSAXLocator,
8139) {
8140 crate::xml::sax::default::default_sax_handler::setDocumentLocator(ctx, loc)
8141}
8142
8143#[no_mangle]
8145pub unsafe extern "C" fn xmlSAX2Reference(ctx: *mut c_void, name: *const xmlChar) {
8146 crate::xml::sax::default::default_sax_handler::reference(ctx, name)
8147}
8148
8149#[cfg(test)]
8150mod tests {
8151 use super::xml_number_to_string;
8152
8153 #[allow(clippy::approx_constant)]
8159 #[test]
8160 fn test_xml_number_to_string_parity_cases() {
8161 let cases: &[(f64, &str)] = &[
8162 (1234567.891, "1234567.891"),
8163 (0.1 + 0.2, "0.3"),
8164 (1.0 / 3.0, "0.333333333333333"),
8165 (1e20, "1e+20"),
8166 (1e-5, "0.00001"),
8167 (123456789012345678901234567890.0, "1.23456789012346e+29"),
8168 (1e100, "1e+100"),
8169 (-1e100, "-1e+100"),
8170 (1.5e-100, "1.5e-100"),
8171 (1e9, "1000000000"),
8172 (0.00001, "0.00001"),
8173 (9.99e-6, "9.99e-06"),
8174 (2147483646.0, "2147483646"),
8175 (2147483648.0, "2.147483648e+09"),
8176 (-2147483647.0, "-2147483647"),
8177 (-2147483649.0, "-2.147483649e+09"),
8178 (0.5, "0.5"),
8179 (1.0 / 7.0, "0.142857142857143"),
8180 (2.675, "2.675"),
8181 (3.141592653589793, "3.141592653589793"),
8182 (-0.0, "0"),
8183 (0.0, "0"),
8184 (f64::INFINITY, "Infinity"),
8185 (f64::NEG_INFINITY, "-Infinity"),
8186 (f64::NAN, "NaN"),
8187 (0.30000000000000004, "0.3"),
8188 (2.2250738585072014e-308, "2.2250738585072e-308"),
8189 (5e-324, "4.94065645841247e-324"),
8190 ];
8191 for (n, expected) in cases {
8192 assert_eq!(&xml_number_to_string(*n), expected, "value: {}", n);
8193 }
8194 }
8195
8196 #[test]
8206 fn test_xml_new_child_with_content() {
8207 unsafe {
8208 let doc =
8209 crate::xml::tree::new_doc(c"1.0".as_ptr() as *const crate::abi::types::xmlChar);
8210 assert!(!doc.is_null());
8211 let root = crate::xml::tree::new_node(
8212 core::ptr::null_mut(),
8213 c"root".as_ptr() as *const crate::abi::types::xmlChar,
8214 );
8215 assert!(!root.is_null());
8216 crate::xml::tree::doc_set_root_element(doc, root);
8217
8218 let child = super::xmlNewChild(
8219 root,
8220 core::ptr::null_mut(),
8221 c"node1".as_ptr() as *const crate::abi::types::xmlChar,
8222 c"content of node 1".as_ptr() as *const crate::abi::types::xmlChar,
8223 );
8224 assert!(!child.is_null());
8225 assert!(
8226 !(*child).children.is_null(),
8227 "content must become a text child"
8228 );
8229 assert_eq!(
8230 crate::abi::types::xmlElementType::XML_TEXT_NODE as i32,
8231 (*(*child).children).type_
8232 );
8233 let text = crate::xml::string::xmlstr_to_bytes((*(*child).children).content);
8234 assert_eq!(text, b"content of node 1");
8235
8236 let empty = super::xmlNewChild(
8238 root,
8239 core::ptr::null_mut(),
8240 c"node2".as_ptr() as *const crate::abi::types::xmlChar,
8241 core::ptr::null(),
8242 );
8243 assert!(!empty.is_null());
8244 assert!((*empty).children.is_null());
8245
8246 crate::xml::tree::free_doc(doc);
8247 }
8248 }
8249}