1#![allow(non_snake_case)]
96#![allow(unused_variables)]
97#![allow(clippy::missing_safety_doc)]
98#![allow(clippy::not_unsafe_ptr_arg_deref)]
99
100use core::ffi::c_void;
101use core::ptr;
102use once_cell::sync::Lazy;
103use parking_lot::Mutex;
104use std::collections::HashMap;
105use std::ffi::{CStr, CString};
106use std::mem::size_of;
107use std::os::raw::{c_char, c_int, c_long, c_uint, c_ulong};
108
109use crate::xml::xpath::ast::CompiledExpr;
110use crate::xml::xpath::context::{BoxedXPathFunction, XPathContext};
111use crate::xml::xpath::types::{NodeSet, XPathValue};
112
113use crate::abi::allocator::*;
114use crate::abi::callbacks::*;
115use crate::abi::structs::*;
116use crate::abi::types::*;
117
118#[no_mangle]
133pub unsafe extern "C" fn xmlInitParser() {
134 crate::internal::globals::init_parser();
135}
136
137#[no_mangle]
150pub const unsafe extern "C" fn xmlInitGlobals() {
151 }
153
154#[no_mangle]
164pub const unsafe extern "C" fn xmlInitializeGlobalState(_gs: *mut c_void) {
165 }
169
170#[no_mangle]
179pub const extern "C" fn xmlInitializeDict() -> c_int {
180 0
183}
184
185#[no_mangle]
195pub const extern "C" fn xmlInitializePredefinedEntities() {
196 }
198
199#[no_mangle]
208pub const extern "C" fn xmlCleanupPredefinedEntities() {
209 }
211
212#[no_mangle]
223pub const extern "C" fn xmlDefaultSAXHandlerInit() {
224 }
227
228static SAX2_DEFAULT_VERSION: core::sync::atomic::AtomicI32 = core::sync::atomic::AtomicI32::new(2);
231#[no_mangle]
240pub extern "C" fn xmlSAXDefaultVersion(version: c_int) -> c_int {
241 use core::sync::atomic::Ordering;
242 let ret = SAX2_DEFAULT_VERSION.load(Ordering::Relaxed);
243 if version != 1 && version != 2 {
244 return -1;
245 }
246 SAX2_DEFAULT_VERSION.store(version, Ordering::Relaxed);
247 ret
248}
249
250#[no_mangle]
260pub unsafe extern "C" fn xmlSAXVersion(
261 hdlr: *mut crate::abi::structs::_xmlSAXHandler,
262 version: c_int,
263) -> c_int {
264 if hdlr.is_null() {
265 return -1;
266 }
267 if version != 1 && version != 2 {
268 return -1;
269 }
270 unsafe {
272 crate::xml::sax::dispatch::xmlSAX2InitDefaultSAXHandler(hdlr);
273 let h = &mut *hdlr;
274 if version == 2 {
275 h.initialized = crate::abi::constants::XML_SAX2_MAGIC as c_uint;
276 } else {
277 h.initialized = 1;
278 }
279 }
280 0
281}
282
283#[no_mangle]
294pub extern "C" fn xmlHasFeature(feature: c_int) -> c_int {
295 if (1..=24).contains(&feature) {
298 1
299 } else {
300 0
301 }
302}
303
304#[no_mangle]
316pub const unsafe extern "C" fn xmlCleanupGlobals() {
317 }
319
320#[no_mangle]
330pub unsafe extern "C" fn xmlCleanupParser() {
331 crate::internal::globals::cleanup_parser();
332}
333
334#[no_mangle]
342pub extern "C" fn xmlNewMutex() -> *mut c_void {
343 crate::xml::threads::new_mutex()
344}
345
346#[no_mangle]
354pub unsafe extern "C" fn xmlFreeMutex(tok: *mut c_void) {
355 crate::xml::threads::free_mutex(tok);
356}
357
358#[no_mangle]
366pub unsafe extern "C" fn xmlMutexLock(tok: *mut c_void) {
367 crate::xml::threads::mutex_lock(tok);
368}
369
370#[no_mangle]
378pub unsafe extern "C" fn xmlMutexUnlock(tok: *mut c_void) {
379 crate::xml::threads::mutex_unlock(tok);
380}
381
382#[no_mangle]
390pub extern "C" fn xmlNewRMutex() -> *mut c_void {
391 crate::xml::threads::new_rmutex()
392}
393
394#[no_mangle]
402pub unsafe extern "C" fn xmlFreeRMutex(tok: *mut c_void) {
403 crate::xml::threads::free_rmutex(tok);
404}
405
406#[no_mangle]
414pub unsafe extern "C" fn xmlRMutexLock(tok: *mut c_void) {
415 crate::xml::threads::rmutex_lock(tok);
416}
417
418#[no_mangle]
426pub unsafe extern "C" fn xmlRMutexUnlock(tok: *mut c_void) {
427 crate::xml::threads::rmutex_unlock(tok);
428}
429
430#[no_mangle]
440pub const extern "C" fn xmlCheckThreadLocalStorage() -> c_int {
441 0
444}
445
446#[no_mangle]
456pub unsafe extern "C" fn xmlInitThreads() -> c_int {
457 crate::internal::globals::init_threads()
458}
459
460#[no_mangle]
468pub unsafe extern "C" fn xmlCleanupThreads() {
469 crate::xml::threads::cleanup_threads();
470}
471
472#[no_mangle]
480pub extern "C" fn xmlIsInitialized() -> c_int {
481 if crate::abi::versioning::is_initialized() {
482 1
483 } else {
484 0
485 }
486}
487
488#[no_mangle]
497pub const unsafe extern "C" fn xmlLockLibrary() {
498 crate::xml::threads::lock_library();
499}
500
501#[no_mangle]
509pub const unsafe extern "C" fn xmlUnlockLibrary() {
510 crate::xml::threads::unlock_library();
511}
512
513#[no_mangle]
530pub unsafe extern "C" fn xmlSetGenericErrorFunc(
531 ctx: *mut c_void,
532 handler: Option<xmlGenericErrorFunc>,
533) {
534 unsafe { crate::xml::errors::set_generic_error_func(ctx, handler) };
536}
537
538#[no_mangle]
550pub unsafe extern "C" fn xmlSetStructuredErrorFunc(
551 ctx: *mut c_void,
552 handler: Option<xmlStructuredErrorFunc>,
553) {
554 unsafe { crate::xml::errors::set_structured_error_func(ctx, handler) };
556}
557
558#[no_mangle]
569pub extern "C" fn xmlGetLastError() -> *mut _xmlError {
570 crate::xml::errors::get_last_error()
571}
572
573#[no_mangle]
587pub const unsafe extern "C" fn xmlCopyError(from: *const _xmlError, to: *mut _xmlError) -> c_int {
588 unsafe { crate::xml::errors::copy_error(from, to) }
590}
591
592#[no_mangle]
604pub const unsafe extern "C" fn xmlResetError(err: *mut _xmlError) {
605 unsafe { crate::xml::errors::reset_error(err) };
607}
608
609#[no_mangle]
622pub unsafe extern "C" fn xmlRaiseError(
623 ctxt: *mut c_void,
624 ctxt2: *mut c_void,
625 ctxt3: *mut c_void,
626 ctxt4: *mut c_void,
627 ctxt5: *mut c_void,
628 domain: c_int,
629 code: c_int,
630 level: c_int,
631 file: *const c_char,
632 line: c_int,
633 str1: *const c_char,
634 str2: *const c_char,
635 str3: *const c_char,
636 int1: c_int,
637 int2: c_int,
638 msg: *const c_char,
639) {
640 unsafe {
642 crate::xml::errors::raise_error(
643 ctxt, ctxt2, ctxt3, ctxt4, ctxt5, domain, code, level, file, line, str1, str2, str3,
644 int1, int2, msg,
645 );
646 }
647}
648
649#[no_mangle]
657pub extern "C" fn xmlResetLastError() {
658 crate::xml::errors::reset_last_error();
659}
660
661#[no_mangle]
677pub unsafe extern "C" fn xmlStrdup(cur: *const xmlChar) -> *mut xmlChar {
678 if cur.is_null() {
679 return ptr::null_mut();
680 }
681 let len = unsafe { xmlStrlen(cur) };
682 let size = len + 1;
683 let new_ptr = unsafe { xmlMallocImpl(size as usize) };
684 if new_ptr.is_null() {
685 return ptr::null_mut();
686 }
687 unsafe {
688 ptr::copy_nonoverlapping(cur, new_ptr as *mut u8, size as usize);
689 }
690 new_ptr as *mut xmlChar
691}
692
693#[no_mangle]
705pub unsafe extern "C" fn xmlStrndup(cur: *const xmlChar, len: c_int) -> *mut xmlChar {
706 if cur.is_null() || len <= 0 {
707 return ptr::null_mut();
708 }
709 let size = len as usize + 1;
710 let new_ptr = unsafe { xmlMallocImpl(size) };
711 if new_ptr.is_null() {
712 return ptr::null_mut();
713 }
714 unsafe {
715 ptr::copy_nonoverlapping(cur, new_ptr as *mut u8, len as usize);
716 *(new_ptr.add(len as usize) as *mut u8) = 0;
717 }
718 new_ptr as *mut xmlChar
719}
720
721#[no_mangle]
733pub unsafe extern "C" fn xmlStrlen(str: *const xmlChar) -> c_int {
734 if str.is_null() {
735 return 0;
736 }
737 unsafe { libc::strlen(str as *const c_char) as c_int }
738}
739
740#[no_mangle]
753pub const unsafe extern "C" fn xmlStrchr(str: *const xmlChar, val: xmlChar) -> *const xmlChar {
754 if str.is_null() {
755 return ptr::null();
756 }
757 unsafe {
758 let mut cur = str;
759 while *cur != 0 {
760 if *cur == val {
761 return cur;
762 }
763 cur = cur.add(1);
764 }
765 ptr::null()
766 }
767}
768
769#[no_mangle]
780pub unsafe extern "C" fn xmlStrcmp(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
781 if str1.is_null() && str2.is_null() {
782 return 0;
783 }
784 if str1.is_null() {
785 return -1;
786 }
787 if str2.is_null() {
788 return 1;
789 }
790 unsafe { libc::strcmp(str1 as *const c_char, str2 as *const c_char) as c_int }
791}
792
793#[no_mangle]
801pub unsafe extern "C" fn xmlStrncmp(
802 str1: *const xmlChar,
803 str2: *const xmlChar,
804 len: c_int,
805) -> c_int {
806 if len <= 0 {
807 return 0;
808 }
809 if str1.is_null() && str2.is_null() {
810 return 0;
811 }
812 if str1.is_null() {
813 return -1;
814 }
815 if str2.is_null() {
816 return 1;
817 }
818 unsafe { libc::strncmp(str1 as *const c_char, str2 as *const c_char, len as usize) as c_int }
819}
820
821#[no_mangle]
829pub unsafe extern "C" fn xmlStrcasecmp(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
830 if str1.is_null() && str2.is_null() {
831 return 0;
832 }
833 if str1.is_null() {
834 return -1;
835 }
836 if str2.is_null() {
837 return 1;
838 }
839 unsafe { libc::strcasecmp(str1 as *const c_char, str2 as *const c_char) as c_int }
840}
841
842#[no_mangle]
850pub unsafe extern "C" fn xmlStrncasecmp(
851 str1: *const xmlChar,
852 str2: *const xmlChar,
853 len: c_int,
854) -> c_int {
855 if len <= 0 {
856 return 0;
857 }
858 if str1.is_null() && str2.is_null() {
859 return 0;
860 }
861 if str1.is_null() {
862 return -1;
863 }
864 if str2.is_null() {
865 return 1;
866 }
867 unsafe {
868 libc::strncasecmp(str1 as *const c_char, str2 as *const c_char, len as usize) as c_int
869 }
870}
871
872#[no_mangle]
882pub unsafe extern "C" fn xmlStrEqual(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
883 if str1.is_null() && str2.is_null() {
884 return 1;
885 }
886 if str1.is_null() || str2.is_null() {
887 return 0;
888 }
889 unsafe { (libc::strcmp(str1 as *const c_char, str2 as *const c_char) == 0) as c_int }
890}
891
892#[no_mangle]
901pub unsafe extern "C" fn xmlBuildQName(
902 ncname: *const xmlChar,
903 prefix: *const xmlChar,
904 memory: *mut xmlChar,
905 len: c_int,
906) -> *mut xmlChar {
907 crate::xml::string::build_qname(ncname, prefix, memory, len)
908}
909
910#[no_mangle]
918pub unsafe extern "C" fn xmlSplitQName2(
919 name: *const xmlChar,
920 prefix: *mut *mut xmlChar,
921) -> *mut xmlChar {
922 crate::xml::string::split_qname2(name, prefix)
923}
924
925#[no_mangle]
933pub unsafe extern "C" fn xmlSplitQName3(name: *const xmlChar, len: *mut c_int) -> c_int {
934 crate::xml::string::split_qname3(name, len)
935}
936
937#[no_mangle]
939pub unsafe extern "C" fn xmlSplitQName(
940 name: *const xmlChar,
941 prefix: *mut *mut xmlChar,
942) -> *mut xmlChar {
943 crate::xml::string::split_qname2(name, prefix)
944}
945
946#[no_mangle]
954pub const unsafe extern "C" fn xmlUTF8Strlen(utf: *const xmlChar) -> c_int {
955 crate::xml::string::utf8_strlen(utf)
956}
957
958#[no_mangle]
966pub const unsafe extern "C" fn xmlUTF8Size(utf: *const xmlChar) -> c_int {
967 crate::xml::string::utf8_size(utf)
968}
969
970#[no_mangle]
978pub const unsafe extern "C" fn xmlCheckUTF8(utf: *const xmlChar) -> c_int {
979 crate::xml::string::check_utf8(utf)
980}
981
982#[no_mangle]
993pub unsafe extern "C" fn xmlStrQEqual(
994 pref: *const xmlChar,
995 name: *const xmlChar,
996 str: *const xmlChar,
997) -> c_int {
998 if name.is_null() || str.is_null() {
999 return 0;
1000 }
1001 if pref.is_null() {
1002 return unsafe { xmlStrEqual(name, str) };
1003 }
1004 let pref_len = unsafe { xmlStrlen(pref) };
1006 let name_len = unsafe { xmlStrlen(name) };
1007 let total_len = pref_len + 1 + name_len;
1008 let str_len = unsafe { xmlStrlen(str) };
1009 if total_len != str_len {
1010 return 0;
1011 }
1012 if unsafe {
1014 libc::strncmp(
1015 pref as *const c_char,
1016 str as *const c_char,
1017 pref_len as usize,
1018 )
1019 } != 0
1020 {
1021 return 0;
1022 }
1023 if unsafe { *str.add(pref_len as usize) } != b':' as xmlChar {
1025 return 0;
1026 }
1027 (unsafe {
1029 libc::strncmp(
1030 name as *const c_char,
1031 str.add((pref_len + 1) as usize) as *const c_char,
1032 name_len as usize,
1033 ) == 0
1034 }) as c_int
1035}
1036
1037#[no_mangle]
1051pub unsafe extern "C" fn xmlStrcat(cur: *mut xmlChar, add: *const xmlChar) -> *mut xmlChar {
1052 if add.is_null() {
1053 return cur;
1054 }
1055 if cur.is_null() {
1056 return unsafe { xmlStrdup(add) };
1057 }
1058 let cur_len = unsafe { xmlStrlen(cur) } as usize;
1059 let add_len = unsafe { xmlStrlen(add) } as usize;
1060 let new_size = cur_len + add_len + 1;
1061 let new_ptr = unsafe { xmlReallocImpl(cur as *mut c_void, new_size) };
1062 if new_ptr.is_null() {
1063 return ptr::null_mut();
1064 }
1065 unsafe {
1066 ptr::copy_nonoverlapping(add, (new_ptr as *mut u8).add(cur_len), add_len);
1067 *((new_ptr as *mut u8).add(cur_len + add_len)) = 0;
1068 }
1069 new_ptr as *mut xmlChar
1070}
1071
1072#[no_mangle]
1084pub unsafe extern "C" fn xmlStrncat(
1085 cur: *mut xmlChar,
1086 add: *const xmlChar,
1087 len: c_int,
1088) -> *mut xmlChar {
1089 if add.is_null() || len <= 0 {
1090 return cur;
1091 }
1092 let len = len as usize;
1093 if cur.is_null() {
1094 return unsafe { xmlStrndup(add, len as c_int) };
1095 }
1096 let cur_len = unsafe { xmlStrlen(cur) } as usize;
1097 let new_size = cur_len + len + 1;
1098 let new_ptr = unsafe { xmlReallocImpl(cur as *mut c_void, new_size) };
1099 if new_ptr.is_null() {
1100 return ptr::null_mut();
1101 }
1102 unsafe {
1103 ptr::copy_nonoverlapping(add, (new_ptr as *mut u8).add(cur_len), len);
1104 *((new_ptr as *mut u8).add(cur_len + len)) = 0;
1105 }
1106 new_ptr as *mut xmlChar
1107}
1108
1109#[no_mangle]
1117pub unsafe extern "C" fn xmlStrncatNew(
1118 str1: *const xmlChar,
1119 str2: *const xmlChar,
1120 len: c_int,
1121) -> *mut xmlChar {
1122 let mut result: *mut xmlChar = ptr::null_mut();
1123 if !str1.is_null() {
1124 result = unsafe { xmlStrdup(str1) };
1125 }
1126 if !str2.is_null() && len > 0 {
1127 result = unsafe { xmlStrncat(result, str2, len) };
1128 }
1129 result
1130}
1131
1132#[no_mangle]
1145pub unsafe extern "C" fn xmlStrcpy(dst: *mut xmlChar, src: *const xmlChar) -> *mut xmlChar {
1146 if dst.is_null() || src.is_null() {
1147 return dst;
1148 }
1149 let len = unsafe { xmlStrlen(src) } as usize + 1;
1150 unsafe {
1151 ptr::copy_nonoverlapping(src, dst, len);
1152 }
1153 dst
1154}
1155
1156#[no_mangle]
1164pub unsafe extern "C" fn xmlStrncpy(
1165 dst: *mut xmlChar,
1166 src: *const xmlChar,
1167 len: c_int,
1168) -> *mut xmlChar {
1169 if dst.is_null() || src.is_null() || len <= 0 {
1170 return dst;
1171 }
1172 let len = len as usize;
1173 let src_len = unsafe { xmlStrlen(src) } as usize;
1174 let copy_len = if src_len < len { src_len } else { len - 1 };
1175 unsafe {
1176 ptr::copy_nonoverlapping(src, dst, copy_len);
1177 *dst.add(copy_len) = 0;
1178 }
1179 dst
1180}
1181
1182#[no_mangle]
1192pub unsafe extern "C" fn xmlStrsub(str: *const xmlChar, start: c_int, len: c_int) -> *mut xmlChar {
1193 if str.is_null() || start < 0 || len < 0 {
1194 return ptr::null_mut();
1195 }
1196 let str_len = unsafe { xmlStrlen(str) };
1197 if start >= str_len {
1198 return unsafe { xmlStrdup(b"\0" as *const u8 as *const xmlChar) };
1199 }
1200 let actual_len = if start + len > str_len {
1201 str_len - start
1202 } else {
1203 len
1204 };
1205 unsafe { xmlStrndup(str.add(start as usize), actual_len) }
1206}
1207
1208#[no_mangle]
1225pub unsafe extern "C" fn xmlNewDoc(version: *const xmlChar) -> *mut _xmlDoc {
1226 crate::xml::tree::new_doc(version)
1227}
1228
1229#[no_mangle]
1241pub unsafe extern "C" fn xmlFreeDoc(doc: *mut _xmlDoc) {
1242 crate::xml::tree::free_doc(doc);
1243}
1244
1245#[no_mangle]
1255pub unsafe extern "C" fn xmlGetDocCompressMode(doc: *mut _xmlDoc) -> c_int {
1256 crate::xml::tree::xmlGetDocCompressMode(doc)
1257}
1258
1259#[no_mangle]
1267pub unsafe extern "C" fn xmlSetDocCompressMode(doc: *mut _xmlDoc, mode: c_int) {
1268 crate::xml::tree::xmlSetDocCompressMode(doc, mode);
1269}
1270
1271#[no_mangle]
1285pub unsafe extern "C" fn xmlNewNode(ns: *mut _xmlNs, name: *const xmlChar) -> *mut _xmlNode {
1286 crate::xml::tree::new_node(ns, name)
1287}
1288
1289#[no_mangle]
1302pub unsafe extern "C" fn xmlFreeNode(node: *mut _xmlNode) {
1303 crate::xml::tree::free_node(node);
1304}
1305
1306#[no_mangle]
1323pub unsafe extern "C" fn xmlFreeNodeList(node: *mut _xmlNode) {
1324 crate::xml::tree::free_node_list(node);
1325}
1326
1327#[no_mangle]
1339pub unsafe extern "C" fn xmlUnlinkNode(node: *mut _xmlNode) {
1340 crate::xml::tree::unlink_node(node);
1341}
1342
1343#[no_mangle]
1359pub unsafe extern "C" fn xmlSAX2InitDefaultSAXHandler(
1360 handler: *mut crate::abi::structs::_xmlSAXHandler,
1361 _warning: c_int,
1362) {
1363 crate::xml::sax::dispatch::xmlSAX2InitDefaultSAXHandler(handler);
1364}
1365
1366#[no_mangle]
1385pub unsafe extern "C" fn xmlSAX2InitHtmlDefaultSAXHandler(
1386 handler: *mut crate::abi::structs::_xmlSAXHandler,
1387) {
1388 if handler.is_null() {
1389 return;
1390 }
1391 unsafe {
1393 if (*handler).initialized != 0 {
1395 return;
1396 }
1397 crate::xml::sax::dispatch::xmlSAX2InitDefaultSAXHandler(handler);
1398 let h = &mut *handler;
1399 h.resolveEntity = None;
1400 h.getParameterEntity = None;
1401 h.entityDecl = None;
1402 h.attributeDecl = None;
1403 h.elementDecl = None;
1404 h.notationDecl = None;
1405 h.unparsedEntityDecl = None;
1406 h.reference = None;
1407 h.externalSubset = None;
1408 h.initialized = 1;
1409 }
1410}
1411
1412#[no_mangle]
1426pub unsafe extern "C" fn xmlAddChild(parent: *mut _xmlNode, cur: *mut _xmlNode) -> *mut _xmlNode {
1427 crate::xml::tree::add_child(parent, cur)
1428}
1429
1430#[no_mangle]
1442pub unsafe extern "C" fn xmlAddSibling(
1443 cur: *mut _xmlNode,
1444 sibling: *mut _xmlNode,
1445) -> *mut _xmlNode {
1446 crate::xml::tree::add_sibling(cur, sibling)
1447}
1448
1449#[no_mangle]
1468pub unsafe extern "C" fn xmlNewChild(
1469 parent: *mut _xmlNode,
1470 ns: *mut _xmlNs,
1471 name: *const xmlChar,
1472 content: *const xmlChar,
1473) -> *mut _xmlNode {
1474 crate::xml::tree::new_child(parent, ns, name)
1475}
1476
1477#[no_mangle]
1492pub unsafe extern "C" fn xmlDocSetRootElement(
1493 doc: *mut _xmlDoc,
1494 root: *mut _xmlNode,
1495) -> *mut _xmlNode {
1496 crate::xml::tree::doc_set_root_element(doc, root)
1497}
1498
1499#[no_mangle]
1509pub extern "C" fn xmlDocGetRootElement(doc: *const _xmlDoc) -> *mut _xmlNode {
1510 crate::xml::tree::doc_get_root_element(doc as *mut _xmlDoc)
1511}
1512
1513#[no_mangle]
1526pub unsafe extern "C" fn xmlCopyNode(node: *const _xmlNode, extended: c_int) -> *mut _xmlNode {
1527 crate::xml::tree::copy_node(node, extended)
1528}
1529
1530#[no_mangle]
1540pub unsafe extern "C" fn xmlCopyDoc(doc: *const _xmlDoc, recursive: c_int) -> *mut _xmlDoc {
1541 crate::xml::tree::copy_doc(doc, recursive)
1542}
1543
1544#[no_mangle]
1555pub unsafe extern "C" fn xmlNewText(content: *const xmlChar) -> *mut _xmlNode {
1556 crate::xml::tree::new_text(content)
1557}
1558
1559#[no_mangle]
1567pub unsafe extern "C" fn xmlNewComment(content: *const xmlChar) -> *mut _xmlNode {
1568 crate::xml::tree::new_comment(content)
1569}
1570
1571#[no_mangle]
1579pub unsafe extern "C" fn xmlNewPI(name: *const xmlChar, content: *const xmlChar) -> *mut _xmlNode {
1580 crate::xml::tree::new_pi(name, content)
1581}
1582
1583#[no_mangle]
1591pub unsafe extern "C" fn xmlNewCDataBlock(
1592 doc: *mut _xmlDoc,
1593 content: *const xmlChar,
1594 len: c_int,
1595) -> *mut _xmlNode {
1596 crate::xml::tree::new_cdata_block(doc, content, len)
1597}
1598
1599#[no_mangle]
1613pub unsafe extern "C" fn xmlNewNs(
1614 node: *mut _xmlNode,
1615 href: *const xmlChar,
1616 prefix: *const xmlChar,
1617) -> *mut _xmlNs {
1618 crate::xml::tree::new_ns(node, href, prefix)
1619}
1620
1621#[no_mangle]
1629pub unsafe extern "C" fn xmlSetNs(node: *mut _xmlNode, ns: *mut _xmlNs) {
1630 crate::xml::tree::set_ns(node, ns);
1631}
1632
1633#[no_mangle]
1641pub unsafe extern "C" fn xmlGetNsList(
1642 doc: *mut _xmlDoc,
1643 node: *const _xmlNode,
1644) -> *mut *mut _xmlNs {
1645 crate::xml::tree::get_ns_list(doc, node as *mut _xmlNode)
1646}
1647
1648#[no_mangle]
1656pub unsafe extern "C" fn xmlSearchNs(
1657 doc: *mut _xmlDoc,
1658 node: *mut _xmlNode,
1659 nameSpace: *const xmlChar,
1660) -> *mut _xmlNs {
1661 crate::xml::tree::search_ns(doc, node, nameSpace)
1662}
1663
1664#[no_mangle]
1672pub unsafe extern "C" fn xmlSearchNsByHref(
1673 doc: *mut _xmlDoc,
1674 node: *mut _xmlNode,
1675 href: *const xmlChar,
1676) -> *mut _xmlNs {
1677 crate::xml::tree::search_ns_by_href(doc, node, href)
1678}
1679
1680#[no_mangle]
1697pub unsafe extern "C" fn xmlSetProp(
1698 node: *mut _xmlNode,
1699 name: *const xmlChar,
1700 value: *const xmlChar,
1701) -> *mut _xmlAttr {
1702 crate::xml::tree::set_prop(node, name, value)
1703}
1704
1705#[no_mangle]
1715pub unsafe extern "C" fn xmlGetProp(node: *const _xmlNode, name: *const xmlChar) -> *mut xmlChar {
1716 crate::xml::tree::get_prop(node as *mut _xmlNode, name)
1717}
1718
1719#[no_mangle]
1727pub unsafe extern "C" fn xmlGetNsProp(
1728 node: *const _xmlNode,
1729 name: *const xmlChar,
1730 nameSpace: *const xmlChar,
1731) -> *mut xmlChar {
1732 crate::xml::tree::get_ns_prop(node as *mut _xmlNode, name, nameSpace)
1733}
1734
1735#[no_mangle]
1744pub unsafe extern "C" fn xmlSetNsProp(
1745 node: *mut _xmlNode,
1746 ns: *mut _xmlNs,
1747 name: *const xmlChar,
1748 value: *const xmlChar,
1749) -> *mut _xmlAttr {
1750 crate::xml::tree::set_ns_prop(node, ns, name, value)
1751}
1752
1753#[no_mangle]
1763pub unsafe extern "C" fn xmlRemoveProp(attr: *mut _xmlAttr) -> c_int {
1764 crate::xml::tree::remove_prop(attr)
1765}
1766
1767#[no_mangle]
1777pub unsafe extern "C" fn xmlHasProp(node: *const _xmlNode, name: *const xmlChar) -> *mut _xmlAttr {
1778 crate::xml::tree::has_prop(node as *mut _xmlNode, name)
1779}
1780
1781#[no_mangle]
1790pub unsafe extern "C" fn xmlHasNsProp(
1791 node: *const _xmlNode,
1792 name: *const xmlChar,
1793 nameSpace: *const xmlChar,
1794) -> *mut _xmlAttr {
1795 crate::xml::tree::has_ns_prop(node as *mut _xmlNode, name, nameSpace)
1796}
1797
1798#[no_mangle]
1808pub unsafe extern "C" fn xmlUnsetProp(node: *mut _xmlNode, name: *const xmlChar) -> c_int {
1809 crate::xml::tree::unset_prop(node, name)
1810}
1811
1812#[no_mangle]
1821pub unsafe extern "C" fn xmlUnsetNsProp(
1822 node: *mut _xmlNode,
1823 name: *const xmlChar,
1824 nameSpace: *const xmlChar,
1825) -> c_int {
1826 crate::xml::tree::unset_ns_prop(node, name, nameSpace)
1827}
1828
1829#[no_mangle]
1837pub unsafe extern "C" fn xmlFirstElementChild(parent: *mut _xmlNode) -> *mut _xmlNode {
1838 crate::xml::tree::first_element_child(parent)
1839}
1840
1841#[no_mangle]
1843pub unsafe extern "C" fn xmlLastElementChild(parent: *mut _xmlNode) -> *mut _xmlNode {
1844 crate::xml::tree::last_element_child(parent)
1845}
1846
1847#[no_mangle]
1849pub unsafe extern "C" fn xmlNextElementSibling(node: *mut _xmlNode) -> *mut _xmlNode {
1850 crate::xml::tree::next_element_sibling(node)
1851}
1852
1853#[no_mangle]
1855pub unsafe extern "C" fn xmlPreviousElementSibling(node: *mut _xmlNode) -> *mut _xmlNode {
1856 crate::xml::tree::previous_element_sibling(node)
1857}
1858
1859#[no_mangle]
1867pub unsafe extern "C" fn xmlChildElementCount(parent: *mut _xmlNode) -> c_ulong {
1868 crate::xml::tree::child_element_count(parent)
1869}
1870
1871#[no_mangle]
1879pub unsafe extern "C" fn xmlTextConcat(
1880 node: *mut _xmlNode,
1881 content: *const xmlChar,
1882 len: c_int,
1883) -> c_int {
1884 crate::xml::tree::text_concat(node, content, len)
1885}
1886
1887#[no_mangle]
1895pub unsafe extern "C" fn xmlTextMerge(
1896 first: *mut _xmlNode,
1897 second: *mut _xmlNode,
1898) -> *mut _xmlNode {
1899 crate::xml::tree::text_merge(first, second)
1900}
1901
1902#[no_mangle]
1910pub const extern "C" fn xmlGetIntSubset(doc: *const _xmlDoc) -> *mut _xmlDtd {
1911 crate::xml::tree::get_int_subset(doc)
1912}
1913
1914#[no_mangle]
1923pub unsafe extern "C" fn xmlNewDtd(
1924 doc: *mut _xmlDoc,
1925 name: *const xmlChar,
1926 ExternalID: *const xmlChar,
1927 SystemID: *const xmlChar,
1928) -> *mut _xmlDtd {
1929 crate::xml::tree::new_dtd(doc, name, ExternalID, SystemID)
1930}
1931
1932#[no_mangle]
1942pub unsafe extern "C" fn xmlNewEntity(
1943 doc: *mut _xmlDoc,
1944 name: *const xmlChar,
1945 type_: c_int,
1946 ExternalID: *const xmlChar,
1947 SystemID: *const xmlChar,
1948 content: *const xmlChar,
1949) -> *mut _xmlEntity {
1950 crate::xml::tree::new_entity(doc, name, type_, ExternalID, SystemID, content)
1951}
1952
1953#[no_mangle]
1961pub unsafe extern "C" fn xmlGetDocEntity(
1962 doc: *const _xmlDoc,
1963 name: *const xmlChar,
1964) -> *mut _xmlEntity {
1965 crate::xml::tree::get_doc_entity(doc, name)
1966}
1967
1968#[no_mangle]
1976pub unsafe extern "C" fn xmlGetParameterEntity(
1977 doc: *const _xmlDoc,
1978 name: *const xmlChar,
1979) -> *mut _xmlEntity {
1980 crate::xml::tree::get_parameter_entity(doc, name)
1981}
1982
1983#[no_mangle]
1994pub unsafe extern "C" fn xmlCreateIntSubset(
1995 doc: *mut _xmlDoc,
1996 name: *const xmlChar,
1997 ExternalID: *const xmlChar,
1998 SystemID: *const xmlChar,
1999) -> *mut _xmlDtd {
2000 crate::xml::dtd::create_int_subset(doc, name, ExternalID, SystemID)
2001}
2002
2003#[no_mangle]
2011pub unsafe extern "C" fn xmlFreeDtd(dtd: *mut _xmlDtd) {
2012 crate::xml::dtd::free_dtd(dtd);
2013}
2014
2015#[no_mangle]
2025pub unsafe extern "C" fn xmlAddNotationDecl(
2026 dtd: *mut _xmlDtd,
2027 name: *const xmlChar,
2028 PublicID: *const xmlChar,
2029 SystemID: *const xmlChar,
2030) -> *mut _xmlNotation {
2031 crate::xml::dtd::add_notation_decl(dtd, name, PublicID, SystemID)
2032}
2033
2034#[no_mangle]
2042pub unsafe extern "C" fn xmlGetNotationDecl(
2043 dtd: *mut _xmlDtd,
2044 name: *const xmlChar,
2045) -> *mut _xmlNotation {
2046 crate::xml::dtd::get_notation_decl(dtd, name)
2047}
2048
2049#[no_mangle]
2057pub unsafe extern "C" fn xmlCopyNotation(notation: *mut _xmlNotation) -> *mut _xmlNotation {
2058 crate::xml::dtd::copy_notation(notation)
2059}
2060
2061#[no_mangle]
2069pub unsafe extern "C" fn xmlFreeNotation(notation: *mut _xmlNotation) {
2070 crate::xml::dtd::free_notation(notation);
2071}
2072
2073#[no_mangle]
2082pub unsafe extern "C" fn xmlAddElementDecl(
2083 dtd: *mut _xmlDtd,
2084 name: *const xmlChar,
2085 type_: c_int,
2086 content: *mut _xmlElementContent,
2087) -> *mut _xmlElement {
2088 crate::xml::dtd::add_element_decl(dtd, name, type_, content)
2089}
2090
2091#[no_mangle]
2099pub unsafe extern "C" fn xmlGetElementDecl(
2100 dtd: *mut _xmlDtd,
2101 name: *const xmlChar,
2102) -> *mut _xmlElement {
2103 crate::xml::dtd::get_element_decl(dtd, name)
2104}
2105
2106#[no_mangle]
2114pub unsafe extern "C" fn xmlCopyElement(elem: *mut _xmlElement) -> *mut _xmlElement {
2115 crate::xml::dtd::copy_element(elem)
2116}
2117
2118#[no_mangle]
2126pub unsafe extern "C" fn xmlFreeElement(elem: *mut _xmlElement) {
2127 crate::xml::dtd::free_element(elem);
2128}
2129
2130#[no_mangle]
2141pub unsafe extern "C" fn xmlAddAttributeDecl(
2142 dtd: *mut _xmlDtd,
2143 elem: *mut _xmlElement,
2144 name: *const xmlChar,
2145 type_: c_int,
2146 def: c_int,
2147 defaultValue: *const xmlChar,
2148 tree: *mut _xmlEnumeration,
2149) -> *mut _xmlAttribute {
2150 crate::xml::dtd::add_attribute_decl(dtd, elem, name, type_, def, defaultValue, tree)
2151}
2152
2153#[no_mangle]
2162pub unsafe extern "C" fn xmlGetAttributeDecl(
2163 dtd: *mut _xmlDtd,
2164 elem: *mut _xmlElement,
2165 name: *const xmlChar,
2166 namePrefix: c_int,
2167) -> *mut _xmlAttribute {
2168 crate::xml::dtd::get_attribute_decl(dtd, elem, name, namePrefix)
2169}
2170
2171#[no_mangle]
2179pub unsafe extern "C" fn xmlCopyAttribute(attr: *mut _xmlAttribute) -> *mut _xmlAttribute {
2180 crate::xml::dtd::copy_attribute_decl(attr)
2181}
2182
2183#[no_mangle]
2191pub unsafe extern "C" fn xmlFreeAttribute(attr: *mut _xmlAttribute) {
2192 crate::xml::dtd::free_attribute(attr);
2193}
2194
2195#[no_mangle]
2203pub unsafe extern "C" fn xmlNewElementContent(
2204 name: *const xmlChar,
2205 type_: c_int,
2206) -> *mut _xmlElementContent {
2207 crate::xml::dtd::create_content_model(name, type_)
2208}
2209
2210#[no_mangle]
2218pub unsafe extern "C" fn xmlCopyElementContent(
2219 content: *mut _xmlElementContent,
2220) -> *mut _xmlElementContent {
2221 crate::xml::dtd::copy_content_model(content)
2222}
2223
2224#[no_mangle]
2232pub unsafe extern "C" fn xmlFreeElementContent(cur: *mut _xmlElementContent) {
2233 crate::xml::dtd::free_content_model(cur);
2234}
2235
2236#[no_mangle]
2248pub unsafe extern "C" fn xmlAddEntity(
2249 dtd: *mut _xmlDtd,
2250 name: *const xmlChar,
2251 type_: c_int,
2252 ExternalID: *const xmlChar,
2253 SystemID: *const xmlChar,
2254 content: *const xmlChar,
2255) -> *mut _xmlEntity {
2256 crate::xml::entities::add_entity(dtd, name, type_, ExternalID, SystemID, content)
2257}
2258
2259#[no_mangle]
2271pub unsafe extern "C" fn xmlAddDocEntity(
2272 doc: *mut _xmlDoc,
2273 name: *const xmlChar,
2274 type_: c_int,
2275 ExternalID: *const xmlChar,
2276 SystemID: *const xmlChar,
2277 content: *const xmlChar,
2278) -> *mut _xmlEntity {
2279 crate::xml::tree::add_doc_entity(doc, name, type_, ExternalID, SystemID, content)
2280}
2281
2282#[no_mangle]
2293pub unsafe extern "C" fn xmlAddDtdEntity(
2294 doc: *mut _xmlDoc,
2295 name: *const xmlChar,
2296 type_: c_int,
2297 ExternalID: *const xmlChar,
2298 SystemID: *const xmlChar,
2299 content: *const xmlChar,
2300) -> *mut _xmlEntity {
2301 crate::xml::tree::add_dtd_entity(doc, name, type_, ExternalID, SystemID, content)
2302}
2303
2304#[no_mangle]
2313pub unsafe extern "C" fn xmlGetDtdEntity(
2314 doc: *mut _xmlDoc,
2315 name: *const xmlChar,
2316) -> *mut _xmlEntity {
2317 crate::xml::tree::get_dtd_entity(doc, name)
2318}
2319
2320#[no_mangle]
2328pub unsafe extern "C" fn xmlGetEntity(doc: *mut _xmlDoc, name: *const xmlChar) -> *mut _xmlEntity {
2329 crate::xml::entities::get_entity(doc, name)
2330}
2331
2332#[no_mangle]
2340pub unsafe extern "C" fn xmlCopyEntity(entity: *mut _xmlEntity) -> *mut _xmlEntity {
2341 crate::xml::entities::copy_entity(entity)
2342}
2343
2344#[no_mangle]
2352pub unsafe extern "C" fn xmlFreeEntity(entity: *mut _xmlEntity) {
2353 crate::xml::entities::free_entity(entity);
2354}
2355
2356#[no_mangle]
2364pub unsafe extern "C" fn xmlEncodeEntitiesReentrant(
2365 doc: *mut _xmlDoc,
2366 input: *const xmlChar,
2367) -> *mut xmlChar {
2368 crate::xml::entities::encode_entities_reentrant(doc, input)
2369}
2370
2371#[no_mangle]
2382pub unsafe extern "C" fn xmlEncodeSpecialChars(
2383 _doc: *const _xmlDoc,
2384 input: *const xmlChar,
2385) -> *mut xmlChar {
2386 if input.is_null() {
2387 return ptr::null_mut();
2388 }
2389 unsafe {
2390 let len = crate::xml::string::xml_strlen(input);
2391 let cap = len * 6 + 1;
2394 let out = crate::abi::allocator::xmlMallocImpl(cap) as *mut xmlChar;
2395 if out.is_null() {
2396 return ptr::null_mut();
2397 }
2398 let mut o = 0usize;
2399 let mut i = 0usize;
2400 while i < len {
2401 let c = *input.add(i);
2402 let rep: &[u8] = match c {
2403 b'<' => b"<",
2404 b'>' => b">",
2405 b'&' => b"&",
2406 b'"' => b""",
2407 b'\r' => b" ",
2408 _ => {
2409 *out.add(o) = c;
2410 o += 1;
2411 i += 1;
2412 continue;
2413 }
2414 };
2415 core::ptr::copy_nonoverlapping(rep.as_ptr(), out.add(o), rep.len());
2416 o += rep.len();
2417 i += 1;
2418 }
2419 *out.add(o) = 0;
2420 out
2421 }
2422}
2423
2424#[no_mangle]
2435pub unsafe extern "C" fn xmlEncodeEntities(
2436 _doc: *mut _xmlDoc,
2437 _input: *const xmlChar,
2438) -> *mut xmlChar {
2439 use core::sync::atomic::{AtomicBool, Ordering};
2440 static WARNED: AtomicBool = AtomicBool::new(false);
2441 if !WARNED.swap(true, Ordering::Relaxed) {
2442 let msg = b"xmlEncodeEntities is deprecated, use xmlEncodeSpecialChars or xmlEncodeEntitiesReentrant\n";
2444 unsafe {
2445 libc::fwrite(
2446 msg.as_ptr() as *const c_void,
2447 1,
2448 msg.len(),
2449 libc::fdopen(2, b"w\0" as *const u8 as *const c_char),
2450 );
2451 }
2452 }
2453 ptr::null_mut()
2454}
2455
2456#[no_mangle]
2464pub extern "C" fn xmlGetLineNo(node: *const _xmlNode) -> c_long {
2465 crate::xml::tree::get_line_no(node)
2466}
2467
2468#[no_mangle]
2480pub unsafe extern "C" fn xmlNodeDump(
2481 buf: *mut _xmlBuffer,
2482 doc: *mut _xmlDoc,
2483 cur: *mut _xmlNode,
2484 level: c_int,
2485 format: c_int,
2486) -> c_int {
2487 if buf.is_null() || cur.is_null() {
2488 return -1;
2489 }
2490 crate::xml::tree::xmlNodeDump(buf, doc, cur, level, format)
2491}
2492
2493#[no_mangle]
2501pub unsafe extern "C" fn xmlDocDump(fp: *mut c_void, doc: *mut _xmlDoc) -> c_int {
2502 if fp.is_null() || doc.is_null() {
2503 return -1;
2504 }
2505 crate::xml::tree::xmlDocDump(fp, doc)
2506}
2507
2508#[no_mangle]
2516pub unsafe extern "C" fn xmlDocDumpFormatMemory(
2517 doc: *mut _xmlDoc,
2518 mem: *mut *mut xmlChar,
2519 size: *mut c_int,
2520 format: c_int,
2521) {
2522 if doc.is_null() || mem.is_null() || size.is_null() {
2523 return;
2524 }
2525 crate::xml::tree::xmlDocDumpFormatMemory(doc, mem, size, format)
2526}
2527
2528#[no_mangle]
2536pub unsafe extern "C" fn xmlDocDumpMemory(
2537 doc: *mut _xmlDoc,
2538 mem: *mut *mut xmlChar,
2539 size: *mut c_int,
2540) {
2541 if doc.is_null() || mem.is_null() || size.is_null() {
2542 return;
2543 }
2544 crate::xml::tree::xmlDocDumpMemory(doc, mem, size)
2545}
2546
2547#[no_mangle]
2555pub unsafe extern "C" fn xmlSaveFile(filename: *const c_char, cur: *mut _xmlDoc) -> c_int {
2556 if filename.is_null() || cur.is_null() {
2557 return -1;
2558 }
2559 crate::xml::tree::xmlSaveFile(filename, cur)
2560}
2561
2562#[no_mangle]
2570pub unsafe extern "C" fn xmlSaveFileEnc(
2571 filename: *const c_char,
2572 cur: *mut _xmlDoc,
2573 encoding: *const c_char,
2574) -> c_int {
2575 if filename.is_null() || cur.is_null() {
2576 return -1;
2577 }
2578 crate::xml::tree::xmlSaveFileEnc(filename, cur, encoding)
2579}
2580
2581#[no_mangle]
2589pub unsafe extern "C" fn xmlSaveFormatFile(
2590 filename: *const c_char,
2591 cur: *mut _xmlDoc,
2592 format: c_int,
2593) -> c_int {
2594 if filename.is_null() || cur.is_null() {
2595 return -1;
2596 }
2597 crate::xml::tree::xmlSaveFormatFile(filename, cur, format)
2598}
2599
2600#[no_mangle]
2608pub unsafe extern "C" fn xmlSaveFormatFileEnc(
2609 filename: *const c_char,
2610 cur: *mut _xmlDoc,
2611 encoding: *const c_char,
2612 format: c_int,
2613) -> c_int {
2614 if filename.is_null() || cur.is_null() {
2615 return -1;
2616 }
2617 crate::xml::tree::xmlSaveFormatFileEnc(filename, cur, encoding, format)
2618}
2619
2620#[no_mangle]
2635pub unsafe extern "C" fn xmlReadDoc(
2636 cur: *const xmlChar,
2637 URL: *const c_char,
2638 encoding: *const c_char,
2639 options: c_int,
2640) -> *mut _xmlDoc {
2641 if cur.is_null() {
2643 return ptr::null_mut();
2644 }
2645 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2646 if ctxt.is_null() {
2647 return ptr::null_mut();
2648 }
2649 let len = crate::xml::string::xml_strlen(cur);
2650 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2651 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2652 (*ctxt).options = options;
2653 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2654 let doc = (*ctxt).myDoc;
2655 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2656 return doc;
2657 }
2658 let doc = (*ctxt).myDoc;
2659 if !doc.is_null() {
2660 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2661 }
2662 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2663 doc
2664}
2665
2666#[no_mangle]
2674pub unsafe extern "C" fn xmlReadFile(
2675 URL: *const c_char,
2676 encoding: *const c_char,
2677 options: c_int,
2678) -> *mut _xmlDoc {
2679 if URL.is_null() {
2681 return ptr::null_mut();
2682 }
2683 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2684 if ctxt.is_null() {
2685 return ptr::null_mut();
2686 }
2687 let input = match crate::xml::parser::helpers::input_from_file(URL) {
2688 Ok(input) => input,
2689 Err(_) => {
2690 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2691 return ptr::null_mut();
2692 }
2693 };
2694 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2695 (*ctxt).options = options;
2696 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2697 let doc = (*ctxt).myDoc;
2698 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2699 if options & 1 << 0 != 0 {
2703 return doc;
2704 }
2705 if !doc.is_null() {
2706 crate::xml::tree::free_doc(doc);
2707 }
2708 return ptr::null_mut();
2709 }
2710 let doc = (*ctxt).myDoc;
2711 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2712 doc
2713}
2714
2715#[no_mangle]
2724pub unsafe extern "C" fn xmlRecoverDoc(cur: *const xmlChar) -> *mut _xmlDoc {
2725 unsafe { xmlReadDoc(cur, ptr::null(), ptr::null(), 1 << 0) }
2726}
2727
2728#[no_mangle]
2736pub unsafe extern "C" fn xmlRecoverFile(filename: *const c_char) -> *mut _xmlDoc {
2737 unsafe { xmlReadFile(filename, ptr::null(), 1 << 0) }
2738}
2739
2740#[no_mangle]
2748pub unsafe extern "C" fn xmlRecoverMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
2749 unsafe { xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 1 << 0) }
2750}
2751
2752#[no_mangle]
2761pub unsafe extern "C" fn xmlReadMemory(
2762 buffer: *const c_char,
2763 size: c_int,
2764 URL: *const c_char,
2765 encoding: *const c_char,
2766 options: c_int,
2767) -> *mut _xmlDoc {
2768 if buffer.is_null() || size < 0 {
2772 return ptr::null_mut();
2773 }
2774 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2775 if ctxt.is_null() {
2776 return ptr::null_mut();
2777 }
2778 let input = crate::xml::parser::helpers::input_from_memory_named(buffer, size, URL);
2781 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2782 crate::abi::exports_parser::apply_options(ctxt, options);
2786 let parsed = crate::xml::parser::helpers::parse_document(ctxt);
2787 let doc = (*ctxt).myDoc;
2788 if !doc.is_null() && !URL.is_null() && (*doc).URL.is_null() {
2791 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2792 }
2793 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2794 if parsed != 0 {
2795 if options & 1 << 0 != 0 {
2799 return doc;
2800 }
2801 if !doc.is_null() {
2802 crate::xml::tree::free_doc(doc);
2803 }
2804 return ptr::null_mut();
2805 }
2806 doc
2807}
2808
2809#[no_mangle]
2815pub unsafe extern "C" fn xmlLoadCatalogs(catalogs: *const c_char) {
2816 if !catalogs.is_null() {
2817 crate::xml::catalog::load_catalog(catalogs);
2818 }
2819}
2820
2821#[no_mangle]
2827pub unsafe extern "C" fn xmlLoadCatalog(catalogs: *const c_char) -> c_int {
2828 let handle = crate::xml::catalog::load_catalog(catalogs);
2831 if handle.is_null() {
2832 1
2833 } else {
2834 0
2835 }
2836}
2837
2838#[no_mangle]
2846pub unsafe extern "C" fn xmlReadFd(
2847 fd: c_int,
2848 URL: *const c_char,
2849 encoding: *const c_char,
2850 options: c_int,
2851) -> *mut _xmlDoc {
2852 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2854 if ctxt.is_null() {
2855 return ptr::null_mut();
2856 }
2857 let mut buf = Vec::new();
2859 let mut tmp = [0u8; 4096];
2860 loop {
2861 let n = libc::read(fd, tmp.as_mut_ptr() as *mut c_void, tmp.len());
2862 if n <= 0 {
2863 break;
2864 }
2865 buf.extend_from_slice(&tmp[..n as usize]);
2866 }
2867 let input = crate::xml::parser::helpers::input_from_memory(
2868 buf.as_ptr() as *const c_char,
2869 buf.len() as c_int,
2870 );
2871 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2872 (*ctxt).options = options;
2873 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2874 let doc = (*ctxt).myDoc;
2875 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2876 return doc;
2877 }
2878 let doc = (*ctxt).myDoc;
2879 if !doc.is_null() && !URL.is_null() {
2880 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2881 }
2882 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2883 doc
2884}
2885
2886#[no_mangle]
2895pub unsafe extern "C" fn xmlReadIO(
2896 ioread: Option<xmlInputReadCallback>,
2897 ioclose: Option<xmlInputCloseCallback>,
2898 ioctx: *mut c_void,
2899 URL: *const c_char,
2900 encoding: *const c_char,
2901 options: c_int,
2902) -> *mut _xmlDoc {
2903 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2905 if ctxt.is_null() {
2906 return ptr::null_mut();
2907 }
2908 let input = crate::xml::parser::helpers::input_from_io(ioread, ioclose, ioctx);
2909 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2910 (*ctxt).options = options;
2911 if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
2912 let doc = (*ctxt).myDoc;
2913 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2914 return doc;
2915 }
2916 let doc = (*ctxt).myDoc;
2917 if !doc.is_null() && !URL.is_null() {
2918 (*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
2919 }
2920 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2921 doc
2922}
2923
2924#[no_mangle]
2932pub unsafe extern "C" fn xmlSAXParseDoc(
2933 sax: *mut _xmlSAXHandler,
2934 cur: *const xmlChar,
2935 recovery: c_int,
2936) -> *mut _xmlDoc {
2937 if cur.is_null() {
2939 return ptr::null_mut();
2940 }
2941 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2942 if ctxt.is_null() {
2943 return ptr::null_mut();
2944 }
2945 if !sax.is_null() {
2946 (*ctxt).sax = sax;
2947 (*ctxt).userData = (*ctxt).sax as *mut c_void;
2948 }
2949 if recovery != 0 {
2950 (*ctxt).recovery = 1;
2951 (*ctxt).options |= 1; }
2953 let len = crate::xml::string::xml_strlen(cur);
2954 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2955 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2956 crate::xml::parser::helpers::parse_document(ctxt);
2957 let doc = (*ctxt).myDoc;
2958 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
2959 doc
2960}
2961
2962#[no_mangle]
2972pub unsafe extern "C" fn xmlSAXParseDocWithData(
2973 sax: *mut _xmlSAXHandler,
2974 cur: *const xmlChar,
2975 recovery: c_int,
2976 data: *mut c_void,
2977) -> *mut _xmlDoc {
2978 if cur.is_null() {
2980 return ptr::null_mut();
2981 }
2982 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
2983 if ctxt.is_null() {
2984 return ptr::null_mut();
2985 }
2986 if !sax.is_null() {
2987 (*ctxt).sax = sax;
2988 }
2989 (*ctxt).userData = data;
2990 if recovery != 0 {
2991 (*ctxt).recovery = 1;
2992 (*ctxt).options |= 1; }
2994 let len = crate::xml::string::xml_strlen(cur);
2995 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
2996 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
2997 crate::xml::parser::helpers::parse_document(ctxt);
2998 let doc = (*ctxt).myDoc;
2999 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3000 doc
3001}
3002
3003#[no_mangle]
3013pub unsafe extern "C" fn xmlSAXParseFileWithData(
3014 sax: *mut _xmlSAXHandler,
3015 filename: *const c_char,
3016 recovery: c_int,
3017 data: *mut c_void,
3018) -> *mut _xmlDoc {
3019 if filename.is_null() {
3021 return ptr::null_mut();
3022 }
3023 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3024 if ctxt.is_null() {
3025 return ptr::null_mut();
3026 }
3027 if !sax.is_null() {
3028 (*ctxt).sax = sax;
3029 }
3030 (*ctxt).userData = data;
3031 if recovery != 0 {
3032 (*ctxt).recovery = 1;
3033 (*ctxt).options |= 1; }
3035 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3036 Ok(input) => input,
3037 Err(_) => {
3038 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3039 return ptr::null_mut();
3040 }
3041 };
3042 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3043 crate::xml::parser::helpers::parse_document(ctxt);
3044 let doc = (*ctxt).myDoc;
3045 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3046 doc
3047}
3048
3049#[no_mangle]
3059pub unsafe extern "C" fn xmlSAXParseMemoryWithData(
3060 sax: *mut _xmlSAXHandler,
3061 buffer: *const c_char,
3062 size: c_int,
3063 recovery: c_int,
3064 data: *mut c_void,
3065) -> *mut _xmlDoc {
3066 if buffer.is_null() || size <= 0 {
3068 return ptr::null_mut();
3069 }
3070 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3071 if ctxt.is_null() {
3072 return ptr::null_mut();
3073 }
3074 if !sax.is_null() {
3075 (*ctxt).sax = sax;
3076 }
3077 (*ctxt).userData = data;
3078 if recovery != 0 {
3079 (*ctxt).recovery = 1;
3080 (*ctxt).options |= 1; }
3082 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3083 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3084 crate::xml::parser::helpers::parse_document(ctxt);
3085 let doc = (*ctxt).myDoc;
3086 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3087 doc
3088}
3089
3090#[no_mangle]
3098pub unsafe extern "C" fn xmlSAXParseFile(
3099 sax: *mut _xmlSAXHandler,
3100 filename: *const c_char,
3101 recovery: c_int,
3102) -> *mut _xmlDoc {
3103 if filename.is_null() {
3105 return ptr::null_mut();
3106 }
3107 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3108 if ctxt.is_null() {
3109 return ptr::null_mut();
3110 }
3111 if !sax.is_null() {
3112 (*ctxt).sax = sax;
3113 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3114 }
3115 if recovery != 0 {
3116 (*ctxt).recovery = 1;
3117 (*ctxt).options |= 1;
3118 }
3119 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3120 Ok(input) => input,
3121 Err(_) => {
3122 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3123 return ptr::null_mut();
3124 }
3125 };
3126 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3127 crate::xml::parser::helpers::parse_document(ctxt);
3128 let doc = (*ctxt).myDoc;
3129 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3130 doc
3131}
3132
3133#[no_mangle]
3142pub unsafe extern "C" fn xmlSAXParseMemory(
3143 sax: *mut _xmlSAXHandler,
3144 buffer: *const c_char,
3145 size: c_int,
3146 recovery: c_int,
3147) -> *mut _xmlDoc {
3148 if buffer.is_null() || size <= 0 {
3150 return ptr::null_mut();
3151 }
3152 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3153 if ctxt.is_null() {
3154 return ptr::null_mut();
3155 }
3156 if !sax.is_null() {
3157 (*ctxt).sax = sax;
3158 (*ctxt).userData = (*ctxt).sax as *mut c_void;
3159 }
3160 if recovery != 0 {
3161 (*ctxt).recovery = 1;
3162 (*ctxt).options |= 1;
3163 }
3164 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3165 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3166 crate::xml::parser::helpers::parse_document(ctxt);
3167 let doc = (*ctxt).myDoc;
3168 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3169 doc
3170}
3171
3172#[no_mangle]
3181pub unsafe extern "C" fn xmlSAXUserParseFile(
3182 sax: *mut _xmlSAXHandler,
3183 user_data: *mut c_void,
3184 filename: *const c_char,
3185) -> c_int {
3186 if filename.is_null() {
3188 return -1;
3189 }
3190 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3191 if ctxt.is_null() {
3192 return -1;
3193 }
3194 if !sax.is_null() {
3195 (*ctxt).sax = sax;
3196 }
3197 (*ctxt).userData = if !user_data.is_null() {
3198 user_data
3199 } else {
3200 ctxt as *mut c_void
3201 };
3202 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3203 Ok(input) => input,
3204 Err(_) => {
3205 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3206 return -1;
3207 }
3208 };
3209 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3210 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3211 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3212 ret
3213}
3214
3215#[no_mangle]
3224pub unsafe extern "C" fn xmlSAXUserParseMemory(
3225 sax: *mut _xmlSAXHandler,
3226 user_data: *mut c_void,
3227 buffer: *const c_char,
3228 size: c_int,
3229) -> c_int {
3230 if buffer.is_null() || size <= 0 {
3232 return -1;
3233 }
3234 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3235 if ctxt.is_null() {
3236 return -1;
3237 }
3238 if !sax.is_null() {
3239 (*ctxt).sax = sax;
3240 }
3241 (*ctxt).userData = if !user_data.is_null() {
3242 user_data
3243 } else {
3244 ctxt as *mut c_void
3245 };
3246 let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
3247 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3248 let ret = crate::xml::parser::helpers::parse_document(ctxt);
3249 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3250 ret
3251}
3252
3253#[no_mangle]
3261pub unsafe extern "C" fn xmlParseDoc(cur: *const xmlChar) -> *mut _xmlDoc {
3262 if cur.is_null() {
3264 return ptr::null_mut();
3265 }
3266 xmlReadDoc(cur, ptr::null(), ptr::null(), 0)
3267}
3268
3269#[no_mangle]
3277pub unsafe extern "C" fn xmlParseFile(filename: *const c_char) -> *mut _xmlDoc {
3278 if filename.is_null() {
3280 return ptr::null_mut();
3281 }
3282 xmlReadFile(filename, ptr::null(), 0)
3283}
3284
3285#[no_mangle]
3293pub unsafe extern "C" fn xmlParseMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
3294 if buffer.is_null() || size <= 0 {
3296 return ptr::null_mut();
3297 }
3298 xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 0)
3299}
3300
3301#[no_mangle]
3309pub unsafe extern "C" fn xmlCreateFileParserCtxt(filename: *const c_char) -> *mut _xmlParserCtxt {
3310 if filename.is_null() {
3312 return ptr::null_mut();
3313 }
3314 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3315 if ctxt.is_null() {
3316 return ptr::null_mut();
3317 }
3318 let input = match crate::xml::parser::helpers::input_from_file(filename) {
3319 Ok(input) => input,
3320 Err(_) => {
3321 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3322 return ptr::null_mut();
3323 }
3324 };
3325 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3326 ctxt
3327}
3328
3329#[no_mangle]
3337pub unsafe extern "C" fn xmlCreateDocParserCtxt(cur: *const xmlChar) -> *mut _xmlParserCtxt {
3338 if cur.is_null() {
3340 return ptr::null_mut();
3341 }
3342 let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
3343 if ctxt.is_null() {
3344 return ptr::null_mut();
3345 }
3346 let len = crate::xml::string::xml_strlen(cur);
3347 let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
3348 crate::xml::parser::helpers::setup_parser_input(ctxt, input);
3349 ctxt
3350}
3351
3352#[no_mangle]
3360pub unsafe extern "C" fn xmlParseDocument(ctxt: *mut _xmlParserCtxt) -> c_int {
3361 if ctxt.is_null() {
3363 return -1;
3364 }
3365 crate::xml::parser::helpers::parse_document(ctxt)
3366}
3367
3368#[no_mangle]
3376pub unsafe extern "C" fn xmlFreeParserCtxt(ctxt: *mut _xmlParserCtxt) {
3377 if ctxt.is_null() {
3378 return;
3379 }
3380 crate::xml::parser::helpers::free_parser_ctxt(ctxt);
3381}
3382
3383#[no_mangle]
3391pub unsafe extern "C" fn xmlCtxtUseOptions(ctxt: *mut _xmlParserCtxt, options: c_int) -> c_int {
3392 if ctxt.is_null() {
3393 return -1;
3394 }
3395 unsafe {
3397 (*ctxt).options = options;
3398 }
3399 0
3400}
3401
3402#[no_mangle]
3411pub unsafe extern "C" fn xmlParseChunk(
3412 ctxt: *mut _xmlParserCtxt,
3413 chunk: *const c_char,
3414 size: c_int,
3415 terminate: c_int,
3416) -> c_int {
3417 if ctxt.is_null() {
3420 return -1;
3421 }
3422 crate::xml::parser::helpers::parse_chunk(ctxt, chunk, size, terminate)
3423}
3424
3425#[no_mangle]
3433pub unsafe extern "C" fn xmlParserInputBufferCreateMem(
3434 buffer: *const c_char,
3435 size: c_int,
3436 enc: c_int,
3437) -> *mut _xmlParserInputBuffer {
3438 if buffer.is_null() || size <= 0 {
3440 return ptr::null_mut();
3441 }
3442 crate::xml::parser::helpers::alloc_parser_input_buffer()
3443}
3444
3445#[no_mangle]
3453pub unsafe extern "C" fn xmlParserInputBufferCreateFilename(
3454 URI: *const c_char,
3455 enc: c_int,
3456) -> *mut _xmlParserInputBuffer {
3457 if URI.is_null() {
3459 return ptr::null_mut();
3460 }
3461 crate::xml::parser::helpers::alloc_parser_input_buffer()
3462}
3463
3464#[no_mangle]
3474pub unsafe extern "C" fn xmlParserInputBufferCreateIO(
3475 ioread: Option<xmlInputReadCallback>,
3476 ioclose: Option<xmlInputCloseCallback>,
3477 ioctx: *mut c_void,
3478 enc: c_int,
3479) -> *mut _xmlParserInputBuffer {
3480 let buf = crate::xml::parser::helpers::alloc_parser_input_buffer();
3482 if !buf.is_null() {
3483 (*buf).readcallback = ioread;
3484 (*buf).closecallback = ioclose;
3485 (*buf).context = ioctx;
3486 }
3487 buf
3488}
3489
3490#[no_mangle]
3498pub unsafe extern "C" fn xmlFreeParserInputBuffer(buf: *mut _xmlParserInputBuffer) {
3499 if buf.is_null() {
3500 return;
3501 }
3502 crate::xml::parser::helpers::free_parser_input_buffer(buf);
3503}
3504
3505#[no_mangle]
3513pub unsafe extern "C" fn xmlNewInputFromFile(
3514 ctxt: *mut _xmlParserCtxt,
3515 filename: *const c_char,
3516) -> *mut _xmlParserInput {
3517 if filename.is_null() {
3522 return ptr::null_mut();
3523 }
3524 crate::xml::parser::helpers::alloc_parser_input_buffer() as *mut _xmlParserInput
3525}
3526
3527#[no_mangle]
3535pub unsafe extern "C" fn xmlFreeInputStream(input: *mut _xmlParserInput) {
3536 if input.is_null() {
3537 return;
3538 }
3539 crate::xml::parser::helpers::free_parser_input(input);
3540}
3541
3542#[no_mangle]
3556pub unsafe extern "C" fn xmlOutputBufferCreateFilename(
3557 URI: *const c_char,
3558 encoder: *mut c_void,
3559 compression: c_int,
3560) -> *mut _xmlOutputBuffer {
3561 let _ = compression;
3562 if URI.is_null() {
3563 return ptr::null_mut();
3564 }
3565 crate::xml::io::output_buffer_create_filename(
3566 URI,
3567 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3568 0,
3569 )
3570}
3571
3572#[no_mangle]
3581pub unsafe extern "C" fn xmlOutputBufferCreateFd(
3582 fd: c_int,
3583 encoder: *mut c_void,
3584) -> *mut _xmlOutputBuffer {
3585 if fd < 0 {
3586 return ptr::null_mut();
3587 }
3588 crate::xml::io::output_buffer_create_fd(
3589 fd,
3590 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3591 )
3592}
3593
3594#[no_mangle]
3604pub unsafe extern "C" fn xmlOutputBufferCreateIO(
3605 iowrite: Option<xmlOutputWriteCallback>,
3606 ioclose: Option<xmlOutputCloseCallback>,
3607 ioctx: *mut c_void,
3608 encoder: *mut c_void,
3609) -> *mut _xmlOutputBuffer {
3610 crate::xml::io::output_buffer_create_io(
3611 iowrite,
3612 ioclose,
3613 ioctx,
3614 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3615 )
3616}
3617
3618#[no_mangle]
3626pub unsafe extern "C" fn xmlOutputBufferClose(out: *mut _xmlOutputBuffer) -> c_int {
3627 if out.is_null() {
3628 return -1;
3629 }
3630 crate::xml::io::output_buffer_close(out)
3631}
3632
3633#[no_mangle]
3641pub unsafe extern "C" fn xmlOutputBufferFlush(out: *mut _xmlOutputBuffer) -> c_int {
3642 if out.is_null() {
3643 return -1;
3644 }
3645 crate::xml::io::output_buffer_flush(out)
3646}
3647
3648#[no_mangle]
3656pub unsafe extern "C" fn xmlOutputBufferWrite(
3657 out: *mut _xmlOutputBuffer,
3658 len: c_int,
3659 data: *const c_char,
3660) -> c_int {
3661 if out.is_null() || data.is_null() || len <= 0 {
3662 return -1;
3663 }
3664 crate::xml::io::output_buffer_write(out, len, data)
3665}
3666
3667#[no_mangle]
3675pub unsafe extern "C" fn xmlOutputBufferWriteString(
3676 out: *mut _xmlOutputBuffer,
3677 str: *const c_char,
3678) -> c_int {
3679 if str.is_null() {
3680 return 0;
3681 }
3682 unsafe { xmlOutputBufferWrite(out, xmlStrlen(str as *const xmlChar), str) }
3683}
3684
3685#[no_mangle]
3693pub unsafe extern "C" fn xmlAllocOutputBuffer(encoder: *mut c_void) -> *mut _xmlOutputBuffer {
3694 crate::xml::io::output_buffer_create(
3695 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3696 )
3697}
3698
3699#[no_mangle]
3713pub unsafe extern "C" fn xmlOutputBufferCreateBuffer(
3714 buffer: *mut crate::abi::structs::_xmlBuffer,
3715 encoder: *mut c_void,
3716) -> *mut _xmlOutputBuffer {
3717 crate::xml::io::output_buffer_create_buffer(
3718 buffer,
3719 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3720 )
3721}
3722
3723#[no_mangle]
3731pub unsafe extern "C" fn xmlOutputBufferCreateFile(
3732 file: *mut libc::FILE,
3733 encoder: *mut c_void,
3734) -> *mut _xmlOutputBuffer {
3735 crate::xml::io::output_buffer_create_file(
3736 file,
3737 encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
3738 )
3739}
3740
3741#[no_mangle]
3747pub unsafe extern "C" fn xmlOutputBufferGetContent(out: *mut _xmlOutputBuffer) -> *const c_char {
3748 crate::xml::io::output_buffer_get_content(out) as *const c_char
3749}
3750
3751#[no_mangle]
3758pub unsafe extern "C" fn xmlOutputBufferGetSize(out: *mut _xmlOutputBuffer) -> c_int {
3759 crate::xml::io::output_buffer_get_size(out)
3760}
3761
3762#[no_mangle]
3770pub unsafe extern "C" fn xmlOutputBufferWriteEscape(
3771 out: *mut _xmlOutputBuffer,
3772 str: *const xmlChar,
3773 escaping: Option<xmlCharEncodingOutputFunc>,
3774) -> c_int {
3775 if out.is_null() || str.is_null() {
3776 return -1;
3777 }
3778 crate::xml::io::output_buffer_write_escape(out, str, escaping)
3779}
3780
3781static mut OUTPUT_CREATE_FILENAME_DEFAULT: Option<
3784 unsafe extern "C" fn(
3785 *const c_char,
3786 *mut crate::abi::structs::_xmlCharEncodingHandler,
3787 c_int,
3788 ) -> *mut _xmlOutputBuffer,
3789> = None;
3790
3791#[no_mangle]
3798pub unsafe extern "C" fn xmlOutputBufferCreateFilenameDefault(
3799 func: Option<
3800 unsafe extern "C" fn(
3801 *const c_char,
3802 *mut crate::abi::structs::_xmlCharEncodingHandler,
3803 c_int,
3804 ) -> *mut _xmlOutputBuffer,
3805 >,
3806) -> Option<
3807 unsafe extern "C" fn(
3808 *const c_char,
3809 *mut crate::abi::structs::_xmlCharEncodingHandler,
3810 c_int,
3811 ) -> *mut _xmlOutputBuffer,
3812> {
3813 let old = unsafe { OUTPUT_CREATE_FILENAME_DEFAULT };
3814 if func.is_some() {
3815 unsafe { OUTPUT_CREATE_FILENAME_DEFAULT = func };
3816 }
3817 old
3818}
3819
3820#[no_mangle]
3823pub unsafe extern "C" fn __xmlOutputBufferCreateFilename() -> *mut Option<
3824 unsafe extern "C" fn(
3825 *const c_char,
3826 *mut crate::abi::structs::_xmlCharEncodingHandler,
3827 c_int,
3828 ) -> *mut _xmlOutputBuffer,
3829> {
3830 core::ptr::addr_of_mut!(OUTPUT_CREATE_FILENAME_DEFAULT)
3831}
3832
3833#[no_mangle]
3845pub extern "C" fn xmlDictCreate() -> *mut c_void {
3846 let d = { crate::xml::dictionary::dict_create() as *mut c_void };
3847 if !d.is_null() {
3848 *crate::abi::exports_hash::DICT_REFS
3852 .lock()
3853 .entry(d as usize)
3854 .or_insert(0) = 1;
3855 }
3856 d
3857}
3858
3859#[no_mangle]
3867pub extern "C" fn xmlDictCreateSub(sub: *mut c_void) -> *mut c_void {
3868 let d = unsafe {
3869 crate::xml::dictionary::dict_create_sub(sub as *mut crate::xml::dictionary::Dict)
3870 as *mut c_void
3871 };
3872 if !d.is_null() {
3873 *crate::abi::exports_hash::DICT_REFS
3874 .lock()
3875 .entry(d as usize)
3876 .or_insert(0) = 1;
3877 }
3878 d
3879}
3880
3881#[no_mangle]
3893pub unsafe extern "C" fn xmlDictLookup(
3894 dict: *mut c_void,
3895 name: *const xmlChar,
3896 len: c_int,
3897) -> *const xmlChar {
3898 unsafe {
3899 crate::xml::dictionary::dict_lookup(dict as *mut crate::xml::dictionary::Dict, name, len)
3900 }
3901}
3902
3903#[no_mangle]
3911pub unsafe extern "C" fn xmlDictExists(
3912 dict: *mut c_void,
3913 name: *const xmlChar,
3914 len: c_int,
3915) -> *const xmlChar {
3916 unsafe {
3917 crate::xml::dictionary::dict_exists(dict as *mut crate::xml::dictionary::Dict, name, len)
3918 }
3919}
3920
3921#[no_mangle]
3929pub const extern "C" fn xmlDictSize(dict: *const c_void) -> c_uint {
3930 {
3931 crate::xml::dictionary::dict_size(dict as *const crate::xml::dictionary::Dict) as c_uint
3932 }
3933}
3934
3935#[no_mangle]
3947pub extern "C" fn xmlDictFree(dict: *mut c_void) {
3948 if dict.is_null() {
3949 return;
3950 }
3951 let mut remaining = 0u32;
3952 {
3953 let mut refs = crate::abi::exports_hash::DICT_REFS.lock();
3954 if let Some(r) = refs.get_mut(&(dict as usize)) {
3955 if *r > 0 {
3956 *r -= 1;
3957 }
3958 remaining = *r;
3959 if remaining == 0 {
3960 refs.remove(&(dict as usize));
3961 }
3962 }
3963 }
3964 if remaining == 0 {
3965 unsafe { crate::xml::dictionary::dict_free(dict as *mut crate::xml::dictionary::Dict) };
3966 }
3967}
3968
3969#[no_mangle]
3977pub extern "C" fn xmlDictSetLimit(dict: *mut c_void, limit: c_uint) -> c_uint {
3978 {
3979 crate::xml::dictionary::dict_set_limit(
3980 dict as *mut crate::xml::dictionary::Dict,
3981 limit as usize,
3982 ) as c_uint
3983 }
3984}
3985
3986#[no_mangle]
3994pub extern "C" fn xmlDictGetUsage(dict: *const c_void) -> c_uint {
3995 {
3996 crate::xml::dictionary::dict_get_usage(dict as *mut crate::xml::dictionary::Dict) as c_uint
3997 }
3998}
3999
4000#[no_mangle]
4012pub extern "C" fn xmlHashCreate(size: c_int) -> *mut c_void {
4013 crate::xml::hash::hash_create(size) as *mut c_void
4014}
4015
4016#[no_mangle]
4024pub extern "C" fn xmlHashCreateDict(size: c_int, dict: *mut c_void) -> *mut c_void {
4025 crate::xml::hash::hash_create_dict(size, dict) as *mut c_void
4026}
4027
4028#[no_mangle]
4036pub extern "C" fn xmlHashFree(
4037 table: *mut c_void,
4038 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4039) {
4040 unsafe { crate::xml::hash::hash_free(table as *mut crate::xml::hash::HashTable, f) }
4041}
4042
4043#[no_mangle]
4051pub unsafe extern "C" fn xmlHashAddEntry(
4052 table: *mut c_void,
4053 name: *const xmlChar,
4054 userdata: *mut c_void,
4055) -> c_int {
4056 unsafe {
4057 crate::xml::hash::hash_add_entry(table as *mut crate::xml::hash::HashTable, name, userdata)
4058 }
4059}
4060
4061#[no_mangle]
4070pub unsafe extern "C" fn xmlHashAddEntry2(
4071 table: *mut c_void,
4072 name: *const xmlChar,
4073 name2: *const xmlChar,
4074 userdata: *mut c_void,
4075) -> c_int {
4076 unsafe {
4077 crate::xml::hash::hash_add_entry2(
4078 table as *mut crate::xml::hash::HashTable,
4079 name,
4080 name2,
4081 userdata,
4082 )
4083 }
4084}
4085
4086#[no_mangle]
4095pub unsafe extern "C" fn xmlHashAddEntry3(
4096 table: *mut c_void,
4097 name: *const xmlChar,
4098 name2: *const xmlChar,
4099 name3: *const xmlChar,
4100 userdata: *mut c_void,
4101) -> c_int {
4102 unsafe {
4103 crate::xml::hash::hash_add_entry3(
4104 table as *mut crate::xml::hash::HashTable,
4105 name,
4106 name2,
4107 name3,
4108 userdata,
4109 )
4110 }
4111}
4112
4113#[no_mangle]
4122pub unsafe extern "C" fn xmlHashUpdateEntry(
4123 table: *mut c_void,
4124 name: *const xmlChar,
4125 userdata: *mut c_void,
4126 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4127) -> c_int {
4128 unsafe {
4129 crate::xml::hash::hash_update_entry(
4130 table as *mut crate::xml::hash::HashTable,
4131 name,
4132 userdata,
4133 f,
4134 )
4135 }
4136}
4137
4138#[no_mangle]
4140pub unsafe extern "C" fn xmlHashUpdateEntry2(
4141 table: *mut c_void,
4142 name: *const xmlChar,
4143 name2: *const xmlChar,
4144 userdata: *mut c_void,
4145 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4146) -> c_int {
4147 unsafe {
4148 crate::xml::hash::hash_update_entry2(
4149 table as *mut crate::xml::hash::HashTable,
4150 name,
4151 name2,
4152 userdata,
4153 f,
4154 )
4155 }
4156}
4157
4158#[no_mangle]
4160pub unsafe extern "C" fn xmlHashUpdateEntry3(
4161 table: *mut c_void,
4162 name: *const xmlChar,
4163 name2: *const xmlChar,
4164 name3: *const xmlChar,
4165 userdata: *mut c_void,
4166 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4167) -> c_int {
4168 unsafe {
4169 crate::xml::hash::hash_update_entry3(
4170 table as *mut crate::xml::hash::HashTable,
4171 name,
4172 name2,
4173 name3,
4174 userdata,
4175 f,
4176 )
4177 }
4178}
4179
4180#[no_mangle]
4188pub unsafe extern "C" fn xmlHashLookup(table: *mut c_void, name: *const xmlChar) -> *mut c_void {
4189 unsafe { crate::xml::hash::hash_lookup(table as *mut crate::xml::hash::HashTable, name) }
4190}
4191
4192#[no_mangle]
4194pub unsafe extern "C" fn xmlHashLookup2(
4195 table: *mut c_void,
4196 name: *const xmlChar,
4197 name2: *const xmlChar,
4198) -> *mut c_void {
4199 unsafe {
4200 crate::xml::hash::hash_lookup2(table as *mut crate::xml::hash::HashTable, name, name2)
4201 }
4202}
4203
4204#[no_mangle]
4206pub unsafe extern "C" fn xmlHashLookup3(
4207 table: *mut c_void,
4208 name: *const xmlChar,
4209 name2: *const xmlChar,
4210 name3: *const xmlChar,
4211) -> *mut c_void {
4212 unsafe {
4213 crate::xml::hash::hash_lookup3(
4214 table as *mut crate::xml::hash::HashTable,
4215 name,
4216 name2,
4217 name3,
4218 )
4219 }
4220}
4221
4222#[no_mangle]
4230pub extern "C" fn xmlHashSize(table: *mut c_void) -> c_int {
4231 crate::xml::hash::hash_size(table as *mut crate::xml::hash::HashTable)
4232}
4233
4234#[no_mangle]
4243pub unsafe extern "C" fn xmlHashRemoveEntry(
4244 table: *mut c_void,
4245 name: *const xmlChar,
4246 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4247) -> c_int {
4248 unsafe {
4249 crate::xml::hash::hash_remove_entry(table as *mut crate::xml::hash::HashTable, name, f)
4250 }
4251}
4252
4253#[no_mangle]
4255pub unsafe extern "C" fn xmlHashRemoveEntry2(
4256 table: *mut c_void,
4257 name: *const xmlChar,
4258 name2: *const xmlChar,
4259 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4260) -> c_int {
4261 unsafe {
4262 crate::xml::hash::hash_remove_entry2(
4263 table as *mut crate::xml::hash::HashTable,
4264 name,
4265 name2,
4266 f,
4267 )
4268 }
4269}
4270
4271#[no_mangle]
4273pub unsafe extern "C" fn xmlHashRemoveEntry3(
4274 table: *mut c_void,
4275 name: *const xmlChar,
4276 name2: *const xmlChar,
4277 name3: *const xmlChar,
4278 f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
4279) -> c_int {
4280 unsafe {
4281 crate::xml::hash::hash_remove_entry3(
4282 table as *mut crate::xml::hash::HashTable,
4283 name,
4284 name2,
4285 name3,
4286 f,
4287 )
4288 }
4289}
4290
4291#[no_mangle]
4299pub extern "C" fn xmlHashScan(table: *mut c_void, f: Option<xmlHashScanner>, data: *mut c_void) {
4300 unsafe { crate::xml::hash::hash_scan(table as *mut crate::xml::hash::HashTable, f, data) }
4301}
4302
4303#[no_mangle]
4305pub extern "C" fn xmlHashScanFull(
4306 table: *mut c_void,
4307 f: Option<xmlHashScannerFull>,
4308 data: *mut c_void,
4309) {
4310 unsafe { crate::xml::hash::hash_scan_full(table as *mut crate::xml::hash::HashTable, f, data) }
4311}
4312
4313#[no_mangle]
4321pub extern "C" fn xmlHashCopy(
4322 table: *mut c_void,
4323 f: Option<unsafe extern "C" fn(*mut c_void, *const xmlChar) -> *mut c_void>,
4324) -> *mut c_void {
4325 unsafe {
4326 crate::xml::hash::hash_copy(table as *mut crate::xml::hash::HashTable, f) as *mut c_void
4327 }
4328}
4329
4330#[no_mangle]
4343pub extern "C" fn xmlListCreate(
4344 deallocator: Option<unsafe extern "C" fn(*mut c_void)>,
4345 compare: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
4346) -> *mut c_void {
4347 crate::xml::list::list_create(deallocator, compare) as *mut c_void
4348}
4349
4350#[no_mangle]
4358pub extern "C" fn xmlListDelete(list: *mut c_void) {
4359 unsafe { crate::xml::list::list_delete(list as *mut crate::xml::list::List) }
4360}
4361
4362#[no_mangle]
4370pub extern "C" fn xmlListSearch(list: *mut c_void, data: *mut c_void) -> *mut c_void {
4371 unsafe { crate::xml::list::list_search(list as *mut crate::xml::list::List, data) }
4372}
4373
4374#[no_mangle]
4382pub extern "C" fn xmlListWalk(
4383 list: *mut c_void,
4384 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4385 data: *mut c_void,
4386) {
4387 unsafe { crate::xml::list::list_walk(list as *mut crate::xml::list::List, walker, data) }
4388}
4389
4390#[no_mangle]
4398pub extern "C" fn xmlListPushBack(list: *mut c_void, data: *mut c_void) -> c_int {
4399 unsafe { crate::xml::list::list_push_back(list as *mut crate::xml::list::List, data) }
4400}
4401
4402#[no_mangle]
4410pub extern "C" fn xmlListPushFront(list: *mut c_void, data: *mut c_void) -> c_int {
4411 unsafe { crate::xml::list::list_push_front(list as *mut crate::xml::list::List, data) }
4412}
4413
4414#[no_mangle]
4416pub extern "C" fn xmlListPopBack(list: *mut c_void) {
4417 unsafe { crate::xml::list::list_pop_back(list as *mut crate::xml::list::List) }
4418}
4419
4420#[no_mangle]
4422pub extern "C" fn xmlListPopFront(list: *mut c_void) {
4423 unsafe { crate::xml::list::list_pop_front(list as *mut crate::xml::list::List) }
4424}
4425
4426#[no_mangle]
4434pub extern "C" fn xmlListInsert(list: *mut c_void, data: *mut c_void) -> c_int {
4435 unsafe { crate::xml::list::list_insert(list as *mut crate::xml::list::List, data) }
4436}
4437
4438#[no_mangle]
4440pub extern "C" fn xmlListAppend(list: *mut c_void, data: *mut c_void) -> c_int {
4441 unsafe { crate::xml::list::list_append(list as *mut crate::xml::list::List, data) }
4442}
4443
4444#[no_mangle]
4446pub extern "C" fn xmlListRemoveFirst(list: *mut c_void, data: *mut c_void) -> c_int {
4447 unsafe { crate::xml::list::list_remove_first(list as *mut crate::xml::list::List, data) }
4448}
4449
4450#[no_mangle]
4452pub extern "C" fn xmlListRemoveLast(list: *mut c_void, data: *mut c_void) -> c_int {
4453 unsafe { crate::xml::list::list_remove_last(list as *mut crate::xml::list::List, data) }
4454}
4455
4456#[no_mangle]
4458pub extern "C" fn xmlListRemoveAll(list: *mut c_void, data: *mut c_void) -> c_int {
4459 unsafe { crate::xml::list::list_remove_all(list as *mut crate::xml::list::List, data) }
4460}
4461
4462#[no_mangle]
4464pub extern "C" fn xmlListClear(list: *mut c_void) {
4465 unsafe { crate::xml::list::list_clear(list as *mut crate::xml::list::List) }
4466}
4467
4468#[no_mangle]
4476pub extern "C" fn xmlListEmpty(list: *mut c_void) -> c_int {
4477 crate::xml::list::list_empty(list as *mut crate::xml::list::List)
4478}
4479
4480#[no_mangle]
4488pub extern "C" fn xmlListFront(list: *mut c_void) -> *mut c_void {
4489 crate::xml::list::list_front(list as *mut crate::xml::list::List)
4490}
4491
4492#[no_mangle]
4500pub extern "C" fn xmlListBack(list: *mut c_void) -> *mut c_void {
4501 crate::xml::list::list_back(list as *mut crate::xml::list::List)
4502}
4503
4504#[no_mangle]
4512pub extern "C" fn xmlListSize(list: *mut c_void) -> c_int {
4513 crate::xml::list::list_size(list as *mut crate::xml::list::List)
4514}
4515
4516#[no_mangle]
4518pub extern "C" fn xmlListSort(list: *mut c_void) {
4519 unsafe { crate::xml::list::list_sort(list as *mut crate::xml::list::List) }
4520}
4521
4522#[no_mangle]
4524pub extern "C" fn xmlListReverse(list: *mut c_void) {
4525 unsafe { crate::xml::list::list_reverse(list as *mut crate::xml::list::List) }
4526}
4527
4528#[no_mangle]
4530pub extern "C" fn xmlListReverseSplice(list: *mut c_void, list2: *mut c_void) {
4531 unsafe {
4532 crate::xml::list::list_reverse_splice(
4533 list as *mut crate::xml::list::List,
4534 list2 as *mut crate::xml::list::List,
4535 )
4536 }
4537}
4538
4539#[no_mangle]
4541pub extern "C" fn xmlListMerge(list: *mut c_void, list2: *mut c_void) {
4542 unsafe {
4543 crate::xml::list::list_merge(
4544 list as *mut crate::xml::list::List,
4545 list2 as *mut crate::xml::list::List,
4546 )
4547 }
4548}
4549#[no_mangle]
4557pub unsafe extern "C" fn xmlListEnd(l: *mut c_void) -> *mut c_void {
4558 crate::xml::list::list_end(l as *mut crate::xml::list::List)
4559}
4560
4561#[no_mangle]
4569pub unsafe extern "C" fn xmlListReverseSearch(l: *mut c_void, data: *mut c_void) -> *mut c_void {
4570 crate::xml::list::list_reverse_search(l as *mut crate::xml::list::List, data)
4571}
4572
4573#[no_mangle]
4581pub unsafe extern "C" fn xmlListReverseWalk(
4582 l: *mut c_void,
4583 walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
4584 data: *mut c_void,
4585) {
4586 crate::xml::list::list_reverse_walk(l as *mut crate::xml::list::List, walker, data)
4587}
4588
4589#[no_mangle]
4597pub unsafe extern "C" fn xmlListDup(l: *mut c_void) -> *mut c_void {
4598 crate::xml::list::list_dup(l as *mut crate::xml::list::List) as *mut c_void
4599}
4600
4601#[no_mangle]
4609pub unsafe extern "C" fn xmlListCopy(
4610 l: *mut c_void,
4611 copier: Option<unsafe extern "C" fn(*mut c_void) -> *mut c_void>,
4612) -> c_int {
4613 crate::xml::list::list_copy(l as *mut crate::xml::list::List, copier)
4614}
4615
4616#[no_mangle]
4624pub unsafe extern "C" fn xmlLinkGetData(lk: *mut c_void) -> *mut c_void {
4625 crate::xml::list::link_get_data(lk)
4626}
4627
4628#[no_mangle]
4640pub extern "C" fn xmlBufferCreate() -> *mut _xmlBuffer {
4641 crate::xml::io::buf_create(-1)
4642}
4643
4644#[no_mangle]
4652pub extern "C" fn xmlBufferCreateSize(size: usize) -> *mut _xmlBuffer {
4653 crate::xml::io::buf_create(size as c_int)
4654}
4655
4656#[no_mangle]
4664pub extern "C" fn xmlBufferCreateStatic(mem: *mut c_void, size: usize) -> *mut _xmlBuffer {
4665 if mem.is_null() || size == 0 {
4666 return ptr::null_mut();
4667 }
4668 crate::xml::io::buf_create_static(mem as *const xmlChar, size as c_int)
4669}
4670
4671#[no_mangle]
4679pub extern "C" fn xmlBufferFree(buf: *mut _xmlBuffer) {
4680 crate::xml::io::buf_free(buf)
4681}
4682
4683#[no_mangle]
4691pub extern "C" fn xmlBufferEmpty(buf: *mut _xmlBuffer) {
4692 if buf.is_null() {
4693 return;
4694 }
4695 unsafe {
4696 if !(*buf).content.is_null() {
4697 *(*buf).content = 0;
4698 }
4699 (*buf).use_ = 0;
4700 }
4701}
4702
4703#[no_mangle]
4711pub extern "C" fn xmlBufferContent(buf: *const _xmlBuffer) -> *mut xmlChar {
4712 crate::xml::io::buf_content(buf as *mut _xmlBuffer)
4713}
4714
4715#[no_mangle]
4723pub extern "C" fn xmlBufferLength(buf: *const _xmlBuffer) -> c_int {
4724 crate::xml::io::buf_length(buf as *mut _xmlBuffer)
4725}
4726
4727#[no_mangle]
4735pub unsafe extern "C" fn xmlBufferAdd(
4736 buf: *mut _xmlBuffer,
4737 str: *const xmlChar,
4738 len: c_int,
4739) -> c_int {
4740 crate::xml::io::buf_add(buf, str, len)
4741}
4742
4743#[no_mangle]
4751pub unsafe extern "C" fn xmlBufferAddHead(
4752 buf: *mut _xmlBuffer,
4753 str: *const xmlChar,
4754 len: c_int,
4755) -> c_int {
4756 crate::xml::io::buf_add_head(buf, str, len)
4757}
4758
4759#[no_mangle]
4767pub unsafe extern "C" fn xmlBufferCat(buf: *mut _xmlBuffer, str: *const xmlChar) -> c_int {
4768 if str.is_null() {
4769 return -1;
4770 }
4771 let len = crate::xml::string::xml_strlen(str) as c_int;
4772 crate::xml::io::buf_add(buf, str, len)
4773}
4774
4775#[no_mangle]
4784pub extern "C" fn xmlBufferSetAllocationScheme(buf: *mut _xmlBuffer, scheme: c_int) {
4785 if buf.is_null() {
4786 return;
4787 }
4788 unsafe {
4789 (*buf).alloc = scheme;
4790 }
4791}
4792
4793#[no_mangle]
4801pub extern "C" fn xmlBufferShrink(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4802 if buf.is_null() || len <= 0 {
4803 return 0;
4804 }
4805 unsafe {
4806 let b = &mut *buf;
4807 let shrink_len = (len as c_uint).min(b.use_);
4808 if shrink_len > 0 {
4809 let remaining = b.use_ - shrink_len;
4810 if remaining > 0 {
4811 core::ptr::copy(
4812 b.content.add(shrink_len as usize),
4813 b.content,
4814 remaining as usize,
4815 );
4816 }
4817 *b.content.add(remaining as usize) = 0;
4818 b.use_ = remaining;
4819 }
4820 }
4821 len
4822}
4823
4824#[no_mangle]
4832pub extern "C" fn xmlBufferGrow(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4833 if buf.is_null() || len <= 0 {
4834 return 0;
4835 }
4836 let cur_use = unsafe { (*buf).use_ };
4837 let new_size = cur_use + len as c_uint + 1;
4838 crate::xml::io::buf_grow(buf, new_size)
4839}
4840
4841#[no_mangle]
4849pub extern "C" fn xmlBufferReserve(buf: *mut _xmlBuffer, len: c_int) -> c_int {
4850 xmlBufferGrow(buf, len)
4851}
4852
4853#[no_mangle]
4861pub extern "C" fn xmlBufferDetach(buf: *mut _xmlBuffer) -> *mut xmlChar {
4862 if buf.is_null() {
4863 return ptr::null_mut();
4864 }
4865 unsafe {
4866 let content = (*buf).content;
4867 (*buf).content = ptr::null_mut();
4868 (*buf).use_ = 0;
4869 (*buf).size = 0;
4870 content
4871 }
4872}
4873
4874#[no_mangle]
4886pub extern "C" fn xmlGetCharEncoding(name: *const c_char) -> c_int {
4887 if name.is_null() {
4888 return 0; }
4890 let name_bytes = unsafe {
4891 let len = libc::strlen(name);
4892 core::slice::from_raw_parts(name as *const u8, len)
4893 };
4894 crate::xml::encoding::encoding_from_name(name_bytes) as c_int
4895}
4896
4897#[no_mangle]
4905pub extern "C" fn xmlFindCharEncodingHandler(name: *const c_char) -> *mut c_void {
4906 if name.is_null() {
4907 return ptr::null_mut();
4908 }
4909 crate::xml::encoding::find_encoding_handler(name as *const xmlChar) as *mut c_void
4910}
4911
4912#[no_mangle]
4920pub extern "C" fn xmlCharEncCloseFunc(handler: *mut c_void) -> c_int {
4921 if handler.is_null() {
4922 return -1;
4923 }
4924 unsafe {
4926 let h = handler as *mut crate::abi::structs::_xmlCharEncodingHandler;
4927 if !(*h).name.is_null() {
4928 crate::abi::allocator::xmlFreeImpl((*h).name as *mut c_void);
4929 }
4930 crate::abi::allocator::xmlFreeImpl(handler);
4931 }
4932 0
4933}
4934
4935#[no_mangle]
4945pub unsafe extern "C" fn xmlIsolat1ToUTF8(
4946 out: *mut u8,
4947 outlen: *mut c_int,
4948 input: *const u8,
4949 inlen: *mut c_int,
4950) -> c_int {
4951 const XML_ENC_ERR_SPACE: c_int = -2;
4953 const XML_ENC_ERR_INTERNAL: c_int = -1;
4954 unsafe {
4955 if out.is_null() || input.is_null() || outlen.is_null() || inlen.is_null() {
4956 return XML_ENC_ERR_INTERNAL;
4957 }
4958 let outstart = out;
4959 let instart = input;
4960 let outend = out.add(*outlen as usize);
4961 let inend = input.add(*inlen as usize);
4962 let mut cur = input;
4963 let mut o = out;
4964 while cur < inend {
4965 let c = *cur;
4966 if c < 0x80 {
4967 if o >= outend {
4968 break;
4969 }
4970 *o = c;
4971 o = o.add(1);
4972 } else {
4973 if (outend as usize) - (o as usize) < 2 {
4974 break;
4975 }
4976 *o = (c >> 6) | 0xC0;
4977 *o.add(1) = (c & 0x3F) | 0x80;
4978 o = o.add(2);
4979 }
4980 cur = cur.add(1);
4981 }
4982 let mut ret = XML_ENC_ERR_SPACE;
4983 if cur == inend {
4984 ret = (o as usize - outstart as usize) as c_int;
4985 }
4986 *outlen = (o as usize - outstart as usize) as c_int;
4987 *inlen = (cur as usize - instart as usize) as c_int;
4988 ret
4989 }
4990}
4991
4992#[no_mangle]
4999pub unsafe extern "C" fn xmlUTF8ToIsolat1(
5000 out: *mut u8,
5001 outlen: *mut c_int,
5002 input: *const u8,
5003 inlen: *mut c_int,
5004) -> c_int {
5005 const XML_ENC_ERR_SPACE: c_int = -2;
5006 const XML_ENC_ERR_INTERNAL: c_int = -1;
5007 const XML_ENC_ERR_INPUT: c_int = -3;
5008 const XML_ENC_ERR_SUCCESS: c_int = 0;
5009 unsafe {
5010 if out.is_null() || outlen.is_null() || inlen.is_null() {
5011 return XML_ENC_ERR_INTERNAL;
5012 }
5013 if input.is_null() {
5014 *inlen = 0;
5015 *outlen = 0;
5016 return XML_ENC_ERR_SUCCESS;
5017 }
5018 let outstart = out;
5019 let instart = input;
5020 let outend = out.add(*outlen as usize);
5021 let inend = input.add(*inlen as usize);
5022 let mut cur = input;
5023 let mut o = out;
5024 let mut ret = XML_ENC_ERR_SPACE;
5025 while cur < inend {
5026 if o >= outend {
5027 break;
5028 }
5029 let c = *cur;
5030 if c < 0x80 {
5031 *o = c;
5032 o = o.add(1);
5033 } else if (0xC2..=0xC3).contains(&c) {
5034 if (inend as usize) - (cur as usize) < 2 {
5035 break;
5036 }
5037 cur = cur.add(1);
5038 *o = (c << 6) | (*cur & 0x3F);
5039 o = o.add(1);
5040 } else {
5041 ret = XML_ENC_ERR_INPUT;
5042 break;
5043 }
5044 cur = cur.add(1);
5045 }
5046 if ret != XML_ENC_ERR_INPUT {
5047 ret = (o as usize - outstart as usize) as c_int;
5048 }
5049 *outlen = (o as usize - outstart as usize) as c_int;
5050 *inlen = (cur as usize - instart as usize) as c_int;
5051 ret
5052 }
5053}
5054
5055#[no_mangle]
5063pub extern "C" fn xmlGetCharEncodingName(enc: c_int) -> *const c_char {
5064 if !(-1..=22).contains(&enc) {
5068 return match enc {
5069 23 => c"UTF-16".as_ptr(),
5070 24 => c"HTML".as_ptr(),
5071 31 => c"windows-1252".as_ptr(),
5072 _ => ptr::null(),
5073 };
5074 }
5075 let e: crate::abi::types::xmlCharEncoding = unsafe { core::mem::transmute(enc) };
5076 crate::xml::encoding::xmlGetCharEncodingName(e)
5077}
5078
5079#[no_mangle]
5089pub extern "C" fn xmlParseCharEncoding(name: *const c_char) -> c_int {
5090 crate::xml::encoding::xmlParseCharEncoding(name)
5091}
5092
5093#[no_mangle]
5101pub extern "C" fn xmlAddEncodingAlias(name: *const c_char, alias: *const c_char) -> c_int {
5102 crate::xml::encoding::add_encoding_alias(name, alias)
5103}
5104
5105#[no_mangle]
5113pub extern "C" fn xmlDelEncodingAlias(alias: *const c_char) -> c_int {
5114 crate::xml::encoding::del_encoding_alias(alias)
5115}
5116
5117#[no_mangle]
5125pub extern "C" fn xmlGetEncodingAlias(alias: *const c_char) -> *const c_char {
5126 crate::xml::encoding::get_encoding_alias(alias)
5127}
5128
5129#[no_mangle]
5137pub extern "C" fn xmlCleanupEncodingAliases() {
5138 crate::xml::encoding::cleanup_encoding_aliases();
5139}
5140
5141#[no_mangle]
5150pub extern "C" fn xmlCharEncInFunc(
5151 handler: *mut c_void,
5152 out: *mut c_void,
5153 in_: *mut c_void,
5154) -> c_int {
5155 crate::xml::encoding::xmlCharEncInFunc(
5156 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
5157 out as *mut crate::abi::structs::_xmlBuffer,
5158 in_ as *mut crate::abi::structs::_xmlBuffer,
5159 )
5160}
5161
5162#[no_mangle]
5171pub extern "C" fn xmlCharEncOutFunc(
5172 handler: *mut c_void,
5173 out: *mut c_void,
5174 in_: *mut c_void,
5175) -> c_int {
5176 crate::xml::encoding::xmlCharEncOutFunc(
5177 handler as *mut crate::abi::structs::_xmlCharEncodingHandler,
5178 out as *mut crate::abi::structs::_xmlBuffer,
5179 in_ as *mut crate::abi::structs::_xmlBuffer,
5180 )
5181}
5182
5183#[no_mangle]
5193pub extern "C" fn xmlNewCharEncodingHandler(
5194 name: *const c_char,
5195 input: crate::abi::callbacks::xmlCharEncodingInputFunc,
5196 output: crate::abi::callbacks::xmlCharEncodingOutputFunc,
5197) -> *mut c_void {
5198 crate::xml::encoding::xmlNewCharEncodingHandler(name, input, output) as *mut c_void
5199}
5200
5201#[no_mangle]
5209pub extern "C" fn xmlInitCharEncodingHandlers() {
5210 crate::xml::encoding::xmlInitCharEncodingHandlers();
5211}
5212
5213#[no_mangle]
5221pub extern "C" fn xmlCleanupCharEncodingHandlers() {
5222 crate::xml::encoding::xmlCleanupCharEncodingHandlers();
5223}
5224
5225#[no_mangle]
5237pub extern "C" fn xmlLookupCharEncodingHandler(enc: c_int, out: *mut *mut c_void) -> c_int {
5238 crate::xml::encoding::xmlLookupCharEncodingHandler(enc, out)
5239}
5240
5241#[no_mangle]
5249pub extern "C" fn xmlGetCharEncodingHandler(enc: c_int) -> *mut c_void {
5250 crate::xml::encoding::xmlGetCharEncodingHandler(enc)
5251}
5252
5253#[no_mangle]
5262pub extern "C" fn xmlOpenCharEncodingHandler(
5263 name: *const c_char,
5264 output: c_int,
5265 out: *mut *mut c_void,
5266) -> c_int {
5267 crate::xml::encoding::xmlOpenCharEncodingHandler(name, output, out)
5268}
5269
5270#[no_mangle]
5281pub extern "C" fn xmlCreateCharEncodingHandler(
5282 name: *const c_char,
5283 flags: c_int,
5284 impl_: Option<crate::abi::callbacks::xmlCharEncConvImpl>,
5285 implCtxt: *mut c_void,
5286 out: *mut *mut c_void,
5287) -> c_int {
5288 crate::xml::encoding::xmlCreateCharEncodingHandler(name, flags, impl_, implCtxt, out)
5289}
5290
5291#[no_mangle]
5302pub extern "C" fn xmlCharEncNewCustomHandler(
5303 name: *const c_char,
5304 input: crate::abi::callbacks::xmlCharEncConvFunc,
5305 output: crate::abi::callbacks::xmlCharEncConvFunc,
5306 ctxtDtor: Option<crate::abi::callbacks::xmlCharEncConvCtxtDtor>,
5307 inputCtxt: *mut c_void,
5308 outputCtxt: *mut c_void,
5309 out: *mut *mut c_void,
5310) -> c_int {
5311 crate::xml::encoding::xmlCharEncNewCustomHandler(
5312 name, input, output, ctxtDtor, inputCtxt, outputCtxt, out,
5313 )
5314}
5315
5316#[no_mangle]
5324pub unsafe extern "C" fn xmlCharEncInput(input: *mut _xmlParserInputBuffer, _to: c_int) -> c_int {
5325 if input.is_null() {
5326 return -1;
5327 }
5328 let handler = (*input).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5329 if handler.is_null() {
5330 return -1;
5331 }
5332 let raw = (*input).raw as *mut crate::abi::structs::_xmlBuffer;
5333 let buf = (*input).buffer as *mut crate::abi::structs::_xmlBuffer;
5334 if raw.is_null() || buf.is_null() {
5335 return -1;
5336 }
5337 crate::xml::encoding::char_enc_in(handler, buf, raw)
5338}
5339
5340#[no_mangle]
5348pub unsafe extern "C" fn xmlCharEncOutput(output: *mut _xmlOutputBuffer, _to: c_int) -> c_int {
5349 if output.is_null() {
5350 return -1;
5351 }
5352 let handler = (*output).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
5353 if handler.is_null() {
5354 return -1;
5355 }
5356 let buf = (*output).buffer as *mut crate::abi::structs::_xmlBuffer;
5357 let conv = (*output).conv as *mut crate::abi::structs::_xmlBuffer;
5358 if buf.is_null() || conv.is_null() {
5359 return -1;
5360 }
5361 crate::xml::encoding::char_enc_out(handler, conv, buf)
5362}
5363
5364#[no_mangle]
5376pub unsafe extern "C" fn xmlParseURI(str: *const c_char) -> *mut c_void {
5377 crate::xml::uri::xmlParseURI(str)
5378}
5379
5380#[no_mangle]
5388pub unsafe extern "C" fn xmlParseURIRaw(str: *const c_char, raw: c_int) -> *mut c_void {
5389 let _ = raw;
5390 crate::xml::uri::xmlParseURI(str)
5391}
5392
5393#[no_mangle]
5401pub unsafe extern "C" fn xmlFreeURI(uri: *mut c_void) {
5402 crate::xml::uri::xmlFreeURI(uri)
5403}
5404
5405#[no_mangle]
5413pub extern "C" fn xmlCreateURI() -> *mut c_void {
5414 crate::xml::uri::xmlCreateURI()
5415}
5416
5417#[no_mangle]
5425pub unsafe extern "C" fn xmlSaveUri(uri: *mut c_void) -> *mut xmlChar {
5426 crate::xml::uri::xmlSaveUri(uri)
5427}
5428
5429#[no_mangle]
5445pub unsafe extern "C" fn xmlParseURIReference(uri: *mut c_void, str: *const c_char) -> c_int {
5446 crate::xml::uri::xmlParseURIReference(uri, str)
5447}
5448
5449#[no_mangle]
5464pub unsafe extern "C" fn xmlNormalizeURIPath(path: *mut c_char) -> c_int {
5465 crate::xml::uri::xmlNormalizeURIPath(path)
5466}
5467
5468#[no_mangle]
5476pub unsafe extern "C" fn xmlURIEscapeStr(
5477 str: *const xmlChar,
5478 list: *const xmlChar,
5479) -> *mut xmlChar {
5480 crate::xml::uri::xmlURIEscapeStr(str, list)
5481}
5482
5483#[no_mangle]
5491pub unsafe extern "C" fn xmlURIUnescapeString(
5492 str: *const c_char,
5493 len: c_int,
5494 target: *mut c_char,
5495) -> *mut c_char {
5496 crate::xml::uri::xmlURIUnescapeString(str, len, target)
5497}
5498
5499unsafe fn xpath_to_object(val: XPathValue) -> *mut _xmlXPathObject {
5514 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
5515 if obj.is_null() {
5516 return ptr::null_mut();
5517 }
5518 match val {
5519 XPathValue::NodeSet(ns) => {
5520 (*obj).type_ = xmlXPathObjectType::XPATH_NODESET as c_int;
5521 (*obj).nodesetval = ns.to_raw() as *mut c_void;
5522 }
5523 XPathValue::Boolean(b) => {
5524 (*obj).type_ = xmlXPathObjectType::XPATH_BOOLEAN as c_int;
5525 (*obj).boolval = if b { 1 } else { 0 };
5526 }
5527 XPathValue::Number(n) => {
5528 (*obj).type_ = xmlXPathObjectType::XPATH_NUMBER as c_int;
5529 (*obj).floatval = n;
5530 }
5531 XPathValue::String(s) => {
5532 (*obj).type_ = xmlXPathObjectType::XPATH_STRING as c_int;
5533 let bytes = s.as_bytes();
5534 let len = bytes.len();
5535 let buf = xmlMallocImpl(len + 1) as *mut xmlChar;
5536 if !buf.is_null() {
5537 ptr::copy_nonoverlapping(bytes.as_ptr(), buf, len);
5538 *buf.add(len) = 0; }
5540 (*obj).stringval = buf;
5541 }
5542 }
5543 obj
5544}
5545
5546unsafe fn object_to_xpathvalue(obj: *mut _xmlXPathObject) -> XPathValue {
5553 let typ = (*obj).type_;
5554 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5555 let ns_ptr = (*obj).nodesetval as *mut _xmlNodeSet;
5556 if ns_ptr.is_null() {
5557 return XPathValue::NodeSet(NodeSet::new());
5558 }
5559 let node_nr = (*ns_ptr).nodeNr;
5560 let node_tab = (*ns_ptr).nodeTab;
5561 let mut ns = NodeSet::new();
5562 if !node_tab.is_null() {
5563 for i in 0..node_nr as isize {
5564 let node = *node_tab.add(i as usize);
5565 ns.push(node);
5566 }
5567 }
5568 XPathValue::NodeSet(ns)
5569 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5570 XPathValue::Boolean((*obj).boolval != 0)
5571 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5572 XPathValue::Number((*obj).floatval)
5573 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5574 let s_ptr = (*obj).stringval;
5575 if s_ptr.is_null() {
5576 XPathValue::String(String::new())
5577 } else {
5578 let s = CStr::from_ptr(s_ptr as *const c_char)
5579 .to_string_lossy()
5580 .into_owned();
5581 XPathValue::String(s)
5582 }
5583 } else if typ == xmlXPathObjectType::XPATH_XSLT_TREE as c_int {
5584 let frag_doc = (*obj).nodesetval as *mut _xmlDoc;
5589 if frag_doc.is_null() {
5590 XPathValue::NodeSet(NodeSet::new())
5591 } else {
5592 let mut ns = NodeSet::new();
5593 ns.push(frag_doc as *mut _xmlNode);
5594 XPathValue::NodeSet(ns)
5595 }
5596 } else {
5597 XPathValue::Boolean(false)
5599 }
5600}
5601
5602pub unsafe fn xpath_to_object_pub(val: XPathValue) -> *mut _xmlXPathObject {
5608 xpath_to_object(val)
5609}
5610
5611pub unsafe fn object_to_xpathvalue_pub(obj: *mut _xmlXPathObject) -> XPathValue {
5618 object_to_xpathvalue(obj)
5619}
5620
5621static COMPILED_EXPRS: Lazy<Mutex<HashMap<u64, Box<CompiledExpr>>>> =
5627 Lazy::new(|| Mutex::new(HashMap::new()));
5628static NEXT_COMPILED_KEY: Lazy<Mutex<u64>> = Lazy::new(|| Mutex::new(1));
5629
5630pub(crate) fn xpath_compiled_registry() -> &'static Mutex<HashMap<u64, Box<CompiledExpr>>> {
5633 &COMPILED_EXPRS
5634}
5635
5636type CXPathFunc = unsafe extern "C" fn(*mut c_void, c_int);
5646
5647#[derive(Clone, Copy, PartialEq, Eq, Hash)]
5650struct SendSyncPtr(*mut c_void);
5651unsafe impl Send for SendSyncPtr {}
5652unsafe impl Sync for SendSyncPtr {}
5653
5654static C_FUNCTIONS: Lazy<Mutex<HashMap<(SendSyncPtr, String), CXPathFunc>>> =
5655 Lazy::new(|| Mutex::new(HashMap::new()));
5656
5657pub(crate) fn xpath_cfunc_lookup(extra: *mut c_void, qualified: &str) -> Option<CXPathFunc> {
5661 C_FUNCTIONS
5662 .lock()
5663 .get(&(SendSyncPtr(extra), qualified.to_string()))
5664 .copied()
5665}
5666
5667pub(crate) fn xpath_cfunc_cleanup(extra: *mut c_void) {
5670 C_FUNCTIONS.lock().retain(|(k, _), _| k.0 != extra);
5671}
5672
5673fn c_func_bridge_closure(c_ctxt: SendSyncPtr, qualified: String) -> BoxedXPathFunction {
5678 Box::new(move |_ctx: &mut XPathContext, args: &[XPathValue]| {
5679 let cc = c_ctxt;
5680 unsafe { c_func_call_bridge(cc.0 as *mut _xmlXPathContext, &qualified, args) }
5681 })
5682}
5683
5684pub(crate) unsafe fn call_c_xpath_function(
5694 fnptr: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
5695 c_ctxt: *mut _xmlXPathContext,
5696 args: &[XPathValue],
5697) -> Result<XPathValue, String> {
5698 let func = match fnptr {
5699 Some(f) => f,
5700 None => return Err("XPath: missing C function pointer".to_string()),
5701 };
5702 let pc = crate::xml::xpath::parser_context::new_parser_context(ptr::null(), c_ctxt);
5703 if pc.is_null() {
5704 return Err("XPath: parser-context allocation failure".to_string());
5705 }
5706 let mut push_ok = true;
5707 for v in args {
5708 let obj = xpath_to_object(v.clone());
5709 if obj.is_null() || crate::xml::xpath::parser_context::value_push(pc, obj).is_null() {
5710 push_ok = false;
5711 break;
5712 }
5713 }
5714 let result = if push_ok {
5715 unsafe { func(pc as *mut c_void, args.len() as c_int) };
5718 let ret = crate::xml::xpath::parser_context::value_pop(pc);
5719 if ret.is_null() {
5720 Err("XPath: C function returned no value".to_string())
5721 } else {
5722 let v = object_to_xpathvalue(ret);
5723 unsafe { xmlXPathFreeObject(ret) };
5725 Ok(v)
5726 }
5727 } else {
5728 Err("XPath: failed to push arguments to C function".to_string())
5729 };
5730 unsafe {
5732 loop {
5733 let leftover = crate::xml::xpath::parser_context::value_pop(pc);
5734 if leftover.is_null() {
5735 break;
5736 }
5737 xmlXPathFreeObject(leftover);
5738 }
5739 crate::xml::xpath::parser_context::free_parser_context(pc);
5740 }
5741 result
5742}
5743
5744unsafe fn c_func_call_bridge(
5751 c_ctxt: *mut _xmlXPathContext,
5752 qualified: &str,
5753 args: &[XPathValue],
5754) -> Result<XPathValue, String> {
5755 if c_ctxt.is_null() {
5756 return Err("XPath: null context in C function bridge".to_string());
5757 }
5758 let func = xpath_cfunc_lookup((*c_ctxt).extra, qualified);
5759 if func.is_none() {
5760 return Err(format!("XPath: unknown C function '{}'", qualified));
5761 }
5762 unsafe { call_c_xpath_function(func, c_ctxt, args) }
5763}
5764
5765#[no_mangle]
5778pub unsafe extern "C" fn xmlXPathNewContext(doc: *mut _xmlDoc) -> *mut _xmlXPathContext {
5779 let ctxt = xmlMallocZero(size_of::<_xmlXPathContext>()) as *mut _xmlXPathContext;
5780 if ctxt.is_null() {
5781 return ptr::null_mut();
5782 }
5783
5784 (*ctxt).doc = doc;
5786 (*ctxt).node = ptr::null_mut();
5787 (*ctxt).contextSize = 1;
5788 (*ctxt).proximityPosition = 1;
5789
5790 let mut internal = Box::new(XPathContext::new(doc));
5792 for (name, func) in crate::xml::xpath::functions::core_functions() {
5797 internal.register_function(&name, func);
5798 }
5799 (*ctxt).extra = Box::into_raw(internal) as *mut c_void;
5800
5801 ctxt
5802}
5803
5804#[no_mangle]
5812pub unsafe extern "C" fn xmlXPathFreeContext(ctxt: *mut _xmlXPathContext) {
5813 if ctxt.is_null() {
5814 return;
5815 }
5816 if !(*ctxt).extra.is_null() {
5818 let _ = Box::from_raw((*ctxt).extra as *mut XPathContext);
5819 (*ctxt).extra = ptr::null_mut();
5820 }
5821 if !(*ctxt).nsHash.is_null() {
5823 drop(Box::from_raw(
5824 (*ctxt).nsHash as *mut HashMap<String, CString>,
5825 ));
5826 (*ctxt).nsHash = ptr::null_mut();
5827 }
5828 xmlFreeImpl(ctxt as *mut c_void);
5830}
5831
5832#[no_mangle]
5841pub unsafe extern "C" fn xmlXPathEvalExpression(
5842 str_: *const xmlChar,
5843 ctxt: *mut _xmlXPathContext,
5844) -> *mut _xmlXPathObject {
5845 if str_.is_null() || ctxt.is_null() {
5846 return ptr::null_mut();
5847 }
5848 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
5849 Ok(s) => s,
5850 Err(_) => return ptr::null_mut(),
5851 };
5852 let internal = (*ctxt).extra as *mut XPathContext;
5853 if internal.is_null() {
5854 return ptr::null_mut();
5855 }
5856 let internal = &mut *internal;
5857 internal.clear_error();
5860
5861 match crate::xml::xpath::evaluate_str(expr_str, internal) {
5862 Some(val) => xpath_to_object(val),
5863 None => {
5864 if internal.error.is_none() {
5869 internal.set_error("Invalid expression");
5870 }
5871 ptr::null_mut()
5872 }
5873 }
5874}
5875
5876#[no_mangle]
5884pub unsafe extern "C" fn xmlXPathEval(
5885 str_: *const xmlChar,
5886 ctxt: *mut _xmlXPathContext,
5887) -> *mut _xmlXPathObject {
5888 xmlXPathEvalExpression(str_, ctxt)
5889}
5890
5891#[no_mangle]
5902pub unsafe extern "C" fn xmlXPathFreeObject(obj: *mut _xmlXPathObject) {
5903 if obj.is_null() {
5904 return;
5905 }
5906 let typ = (*obj).type_;
5907 if typ == xmlXPathObjectType::XPATH_STRING as c_int && !(*obj).stringval.is_null() {
5909 xmlFreeImpl((*obj).stringval as *mut c_void);
5910 (*obj).stringval = ptr::null_mut();
5911 }
5912 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5914 let ns = (*obj).nodesetval as *mut _xmlNodeSet;
5915 if !ns.is_null() {
5916 if !(*ns).nodeTab.is_null() {
5917 xmlFreeImpl((*ns).nodeTab as *mut c_void);
5918 }
5919 xmlFreeImpl(ns as *mut c_void);
5920 }
5921 (*obj).nodesetval = ptr::null_mut();
5922 }
5923 xmlFreeImpl(obj as *mut c_void);
5924}
5925
5926#[no_mangle]
5938pub unsafe extern "C" fn xmlXPathObjectCopy(val: *mut _xmlXPathObject) -> *mut _xmlXPathObject {
5939 if val.is_null() {
5940 return ptr::null_mut();
5941 }
5942 let typ = (*val).type_;
5943 let obj = xmlMallocZero(size_of::<_xmlXPathObject>()) as *mut _xmlXPathObject;
5944 if obj.is_null() {
5945 return ptr::null_mut();
5946 }
5947 (*obj).type_ = typ;
5948 if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
5949 let src_ns = (*val).nodesetval as *mut _xmlNodeSet;
5950 if !src_ns.is_null() {
5951 let nr = (*src_ns).nodeNr;
5952 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
5953 if ns.is_null() {
5954 xmlFreeImpl(obj as *mut c_void);
5955 return ptr::null_mut();
5956 }
5957 (*ns).nodeNr = nr;
5958 (*ns).nodeMax = nr;
5959 if nr > 0 && !(*src_ns).nodeTab.is_null() {
5960 let tab = xmlMallocImpl((nr as usize) * core::mem::size_of::<*mut _xmlNode>())
5961 as *mut *mut _xmlNode;
5962 if tab.is_null() {
5963 xmlFreeImpl(ns as *mut c_void);
5964 xmlFreeImpl(obj as *mut c_void);
5965 return ptr::null_mut();
5966 }
5967 ptr::copy_nonoverlapping((*src_ns).nodeTab, tab, nr as usize);
5968 (*ns).nodeTab = tab;
5969 } else {
5970 (*ns).nodeTab = ptr::null_mut();
5971 }
5972 (*obj).nodesetval = ns as *mut c_void;
5973 }
5974 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
5975 (*obj).boolval = (*val).boolval;
5976 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
5977 (*obj).floatval = (*val).floatval;
5978 } else if typ == xmlXPathObjectType::XPATH_STRING as c_int {
5979 let src = (*val).stringval;
5980 if !src.is_null() {
5981 let len = libc::strlen(src as *const libc::c_char);
5982 let buf = xmlMallocImpl(len + 1) as *mut xmlChar;
5983 if !buf.is_null() {
5984 ptr::copy_nonoverlapping(src, buf, len);
5985 *buf.add(len) = 0;
5986 }
5987 (*obj).stringval = buf;
5988 }
5989 }
5990 obj
5991}
5992
5993#[no_mangle]
6003pub unsafe extern "C" fn xmlXPathCastToString(val: *mut _xmlXPathObject) -> *mut xmlChar {
6004 if val.is_null() {
6005 return ptr::null_mut();
6006 }
6007 let typ = (*val).type_;
6008 let mut result: Vec<u8> = Vec::new();
6009 if typ == xmlXPathObjectType::XPATH_STRING as c_int {
6010 if !(*val).stringval.is_null() {
6011 let len = libc::strlen((*val).stringval as *const libc::c_char);
6012 result.extend_from_slice(core::slice::from_raw_parts((*val).stringval, len));
6013 }
6014 } else if typ == xmlXPathObjectType::XPATH_NUMBER as c_int {
6015 let n = (*val).floatval;
6021 result.extend_from_slice(xml_number_to_string(n).as_bytes());
6022 } else if typ == xmlXPathObjectType::XPATH_BOOLEAN as c_int {
6023 result.extend_from_slice(if (*val).boolval != 0 {
6024 b"true"
6025 } else {
6026 b"false"
6027 });
6028 } else if typ == xmlXPathObjectType::XPATH_NODESET as c_int {
6029 let ns = (*val).nodesetval as *mut _xmlNodeSet;
6032 if !ns.is_null() && (*ns).nodeNr > 0 && !(*ns).nodeTab.is_null() {
6033 let node = *(*ns).nodeTab;
6034 if !node.is_null() {
6035 let content = crate::xml::tree::node_get_content(node);
6036 if !content.is_null() {
6037 let len = libc::strlen(content as *const libc::c_char);
6038 result.extend_from_slice(core::slice::from_raw_parts(content, len));
6039 xmlFreeImpl(content as *mut c_void);
6040 }
6041 }
6042 }
6043 }
6044 let buf = xmlMallocImpl(result.len() + 1) as *mut xmlChar;
6046 if buf.is_null() {
6047 return ptr::null_mut();
6048 }
6049 if !result.is_empty() {
6050 ptr::copy_nonoverlapping(result.as_ptr(), buf, result.len());
6051 }
6052 *buf.add(result.len()) = 0;
6053 buf
6054}
6055
6056pub fn xml_number_to_string(n: f64) -> String {
6063 crate::xml::xpath::types::number_to_string(n)
6064}
6065
6066fn xpath_string_eval_number(bytes: &[u8]) -> f64 {
6074 crate::xml::xpath::types::string_bytes_to_number(bytes)
6075}
6076
6077#[no_mangle]
6085pub unsafe extern "C" fn xmlXPathCastStringToNumber(val: *const xmlChar) -> f64 {
6086 if val.is_null() {
6087 return f64::NAN;
6088 }
6089 let len = libc::strlen(val as *const libc::c_char);
6090 let bytes = core::slice::from_raw_parts(val, len);
6091 xpath_string_eval_number(bytes)
6092}
6093
6094#[no_mangle]
6108pub unsafe extern "C" fn xmlXPathCmpNodes(node1: *mut _xmlNode, node2: *mut _xmlNode) -> c_int {
6109 if node1.is_null() || node2.is_null() {
6110 return -2;
6111 }
6112 if node1 == node2 {
6113 return 0;
6114 }
6115 let mut chain1: Vec<*mut _xmlNode> = Vec::new();
6117 let mut chain2: Vec<*mut _xmlNode> = Vec::new();
6118 let mut n = node1;
6119 while !n.is_null() {
6120 chain1.push(n);
6121 n = (*n).parent;
6122 }
6123 let mut n = node2;
6124 while !n.is_null() {
6125 chain2.push(n);
6126 n = (*n).parent;
6127 }
6128 if chain1[chain1.len() - 1] != chain2[chain2.len() - 1] {
6130 return -2;
6131 }
6132 let mut i = chain1.len();
6134 let mut j = chain2.len();
6135 while i > 0 && j > 0 && chain1[i - 1] == chain2[j - 1] {
6136 i -= 1;
6137 j -= 1;
6138 }
6139 if i == 0 {
6141 return 1;
6142 }
6143 if j == 0 {
6145 return -1;
6146 }
6147 let mut a = chain1[i - 1];
6149 let mut b = chain2[j - 1];
6150 while !a.is_null() && !b.is_null() {
6152 let pa = (*a).parent;
6153 let pb = (*b).parent;
6154 if pa == pb {
6155 break;
6156 }
6157 a = pa;
6158 b = pb;
6159 }
6160 let parent = (*a).parent;
6162 let mut child = if parent.is_null() {
6163 ptr::null_mut()
6164 } else {
6165 (*parent).children
6166 };
6167 while !child.is_null() {
6168 if child == a {
6169 return 1; }
6171 if child == b {
6172 return -1; }
6174 child = (*child).next;
6175 }
6176 0
6177}
6178
6179#[no_mangle]
6189pub unsafe extern "C" fn xmlXPathNodeSetCreate(val: *mut _xmlNode) -> *mut _xmlNodeSet {
6190 let ns = xmlMallocZero(size_of::<_xmlNodeSet>()) as *mut _xmlNodeSet;
6191 if ns.is_null() {
6192 return ptr::null_mut();
6193 }
6194 if val.is_null() {
6195 return ns;
6196 }
6197 let tab = xmlMallocImpl(core::mem::size_of::<*mut _xmlNode>()) as *mut *mut _xmlNode;
6198 if tab.is_null() {
6199 xmlFreeImpl(ns as *mut c_void);
6200 return ptr::null_mut();
6201 }
6202 *tab = val;
6203 (*ns).nodeTab = tab;
6204 (*ns).nodeNr = 1;
6205 (*ns).nodeMax = 1;
6206 ns
6207}
6208
6209#[no_mangle]
6221pub unsafe extern "C" fn xmlXPathFreeNodeSet(ns: *mut _xmlNodeSet) {
6222 if ns.is_null() {
6223 return;
6224 }
6225 if !(*ns).nodeTab.is_null() {
6226 xmlFreeImpl((*ns).nodeTab as *mut c_void);
6227 (*ns).nodeTab = ptr::null_mut();
6228 }
6229 (*ns).nodeNr = 0;
6230 (*ns).nodeMax = 0;
6231 xmlFreeImpl(ns as *mut c_void);
6232}
6233
6234#[no_mangle]
6245pub unsafe extern "C" fn xmlXPathCompile(str_: *const xmlChar) -> *mut c_void {
6246 if str_.is_null() {
6247 return ptr::null_mut();
6248 }
6249 let expr_str = match CStr::from_ptr(str_ as *const c_char).to_str() {
6250 Ok(s) => s,
6251 Err(_) => return ptr::null_mut(),
6252 };
6253
6254 match crate::xml::xpath::compile(expr_str) {
6255 Some(compiled) => {
6256 let mut map = COMPILED_EXPRS.lock();
6257 let mut counter = NEXT_COMPILED_KEY.lock();
6258 let key = *counter;
6259 *counter += 1;
6260 map.insert(key, Box::new(compiled));
6261 key as *mut c_void
6262 }
6263 None => ptr::null_mut(),
6264 }
6265}
6266
6267#[no_mangle]
6275pub unsafe extern "C" fn xmlXPathFreeCompExpr(comp: *mut c_void) {
6276 if comp.is_null() {
6277 return;
6278 }
6279 let mut map = COMPILED_EXPRS.lock();
6280 map.remove(&(comp as u64));
6281}
6282
6283#[no_mangle]
6292pub unsafe extern "C" fn xmlXPathRegisterNs(
6293 ctxt: *mut _xmlXPathContext,
6294 prefix: *const xmlChar,
6295 ns_uri: *const xmlChar,
6296) -> c_int {
6297 if ctxt.is_null() || prefix.is_null() || ns_uri.is_null() {
6298 return -1;
6299 }
6300 let internal = (*ctxt).extra as *mut XPathContext;
6301 if internal.is_null() {
6302 return -1;
6303 }
6304 let internal = &mut *internal;
6305
6306 let prefix_str = match CStr::from_ptr(prefix as *const c_char).to_str() {
6307 Ok(s) => s,
6308 Err(_) => return -1,
6309 };
6310 let uri_str = match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6311 Ok(s) => s,
6312 Err(_) => return -1,
6313 };
6314
6315 internal.register_namespace(prefix_str, uri_str);
6316
6317 let map: &mut HashMap<String, CString> = if (*ctxt).nsHash.is_null() {
6322 let b: Box<HashMap<String, CString>> = Box::default();
6323 (*ctxt).nsHash = Box::into_raw(b) as *mut c_void;
6324 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6325 } else {
6326 &mut *((*ctxt).nsHash as *mut HashMap<String, CString>)
6327 };
6328 map.insert(
6329 prefix_str.to_string(),
6330 CString::new(uri_str.as_bytes()).unwrap_or_default(),
6331 );
6332 0
6333}
6334
6335#[no_mangle]
6349pub unsafe extern "C" fn xmlXPathRegisterFunc(
6350 ctxt: *mut _xmlXPathContext,
6351 name: *const xmlChar,
6352 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6353) -> c_int {
6354 if ctxt.is_null() || name.is_null() {
6355 return -1;
6356 }
6357 let internal = (*ctxt).extra as *mut XPathContext;
6358 if internal.is_null() {
6359 return -1;
6360 }
6361 let internal = &mut *internal;
6362
6363 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6364 Ok(s) => s,
6365 Err(_) => return -1,
6366 };
6367
6368 if let Some(func) = f {
6369 let key = (SendSyncPtr((*ctxt).extra), name_str.to_string());
6371 C_FUNCTIONS.lock().insert(key, func);
6372 let c_ctxt = SendSyncPtr(ctxt as *mut c_void);
6375 let name_owned = name_str.to_string();
6376 internal.register_function(name_str, c_func_bridge_closure(c_ctxt, name_owned));
6377 }
6378 0
6379}
6380
6381#[no_mangle]
6391pub unsafe extern "C" fn xmlXPathRegisterFuncNS(
6392 ctxt: *mut _xmlXPathContext,
6393 name: *const xmlChar,
6394 ns_uri: *const xmlChar,
6395 f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
6396) -> c_int {
6397 if ctxt.is_null() || name.is_null() {
6398 return -1;
6399 }
6400 let internal = (*ctxt).extra as *mut XPathContext;
6401 if internal.is_null() {
6402 return -1;
6403 }
6404 let internal = &mut *internal;
6405
6406 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6407 Ok(s) => s,
6408 Err(_) => return -1,
6409 };
6410 let ns_str = if ns_uri.is_null() {
6411 String::new()
6412 } else {
6413 match CStr::from_ptr(ns_uri as *const c_char).to_str() {
6414 Ok(s) => s.to_string(),
6415 Err(_) => return -1,
6416 }
6417 };
6418
6419 let qualified = if ns_str.is_empty() {
6421 name_str.to_string()
6422 } else {
6423 format!("{{{}}}{}", ns_str, name_str)
6424 };
6425
6426 if let Some(func) = f {
6427 let key = (SendSyncPtr((*ctxt).extra), qualified.clone());
6428 C_FUNCTIONS.lock().insert(key, func);
6429 let c_ctxt = SendSyncPtr(ctxt as *mut c_void);
6430 let qualified_owned = qualified.clone();
6431 internal.register_function(&qualified, c_func_bridge_closure(c_ctxt, qualified_owned));
6432 }
6433 0
6434}
6435
6436#[no_mangle]
6445pub unsafe extern "C" fn xmlXPathRegisterVariable(
6446 ctxt: *mut _xmlXPathContext,
6447 name: *const xmlChar,
6448 value: *mut _xmlXPathObject,
6449) -> c_int {
6450 if ctxt.is_null() || name.is_null() || value.is_null() {
6451 return -1;
6452 }
6453 let internal = (*ctxt).extra as *mut XPathContext;
6454 if internal.is_null() {
6455 return -1;
6456 }
6457 let internal = &mut *internal;
6458
6459 let name_str = match CStr::from_ptr(name as *const c_char).to_str() {
6460 Ok(s) => s,
6461 Err(_) => return -1,
6462 };
6463
6464 let xpath_val = object_to_xpathvalue(value);
6465 internal.register_variable(name_str, xpath_val);
6466 0
6467}
6468
6469#[no_mangle]
6477pub unsafe extern "C" fn xmlXPathNewNodeSet(val: *mut _xmlNode) -> *mut _xmlXPathObject {
6478 let ns = if val.is_null() {
6479 NodeSet::new()
6480 } else {
6481 NodeSet::singleton(val)
6482 };
6483 xpath_to_object(XPathValue::NodeSet(ns))
6484}
6485
6486#[no_mangle]
6494pub unsafe extern "C" fn xmlXPathNewCString(val: *const xmlChar) -> *mut _xmlXPathObject {
6495 if val.is_null() {
6496 return xpath_to_object(XPathValue::String(String::new()));
6497 }
6498 let s = match CStr::from_ptr(val as *const c_char).to_str() {
6499 Ok(s) => s.to_string(),
6500 Err(_) => return ptr::null_mut(),
6501 };
6502 xpath_to_object(XPathValue::String(s))
6503}
6504
6505#[no_mangle]
6513pub extern "C" fn xmlXPathNewFloat(val: f64) -> *mut _xmlXPathObject {
6514 unsafe { xpath_to_object(XPathValue::Number(val)) }
6515}
6516
6517#[no_mangle]
6525pub extern "C" fn xmlXPathNewBoolean(val: c_int) -> *mut _xmlXPathObject {
6526 unsafe { xpath_to_object(XPathValue::Boolean(val != 0)) }
6527}
6528
6529#[no_mangle]
6543pub unsafe extern "C" fn xmlXPtrEval(expr: *const c_char, doc: *mut _xmlDoc) -> *mut _xmlNode {
6544 crate::xml::xpointer::xmlXPtrEval(expr, doc)
6545}
6546
6547#[no_mangle]
6559pub unsafe extern "C" fn xmlXIncludeProcess(doc: *mut _xmlDoc) -> c_int {
6560 crate::xml::xinclude::xinclude_process(doc)
6561}
6562
6563#[no_mangle]
6571pub unsafe extern "C" fn xmlXIncludeProcessFlags(doc: *mut _xmlDoc, flags: c_int) -> c_int {
6572 crate::xml::xinclude::xinclude_process_flags(doc, flags)
6573}
6574
6575#[no_mangle]
6587pub extern "C" fn xmlCatalogLoad(catalogs: *const c_char) -> *mut c_void {
6588 if catalogs.is_null() {
6589 return ptr::null_mut();
6590 }
6591 crate::xml::catalog::load_catalog(catalogs)
6592}
6593
6594#[no_mangle]
6602pub unsafe extern "C" fn xmlCatalogResolvePublic(pubID: *const xmlChar) -> *mut xmlChar {
6603 if pubID.is_null() {
6604 return ptr::null_mut();
6605 }
6606 crate::xml::catalog::resolve_public(pubID)
6607}
6608
6609#[no_mangle]
6617pub unsafe extern "C" fn xmlCatalogResolveSystem(sysID: *const xmlChar) -> *mut xmlChar {
6618 if sysID.is_null() {
6619 return ptr::null_mut();
6620 }
6621 crate::xml::catalog::resolve_system(sysID)
6622}
6623
6624#[no_mangle]
6632pub unsafe extern "C" fn xmlCatalogResolveURI(URI: *const xmlChar) -> *mut xmlChar {
6633 if URI.is_null() {
6634 return ptr::null_mut();
6635 }
6636 crate::xml::catalog::resolve_uri(URI)
6637}
6638
6639#[no_mangle]
6647pub extern "C" fn xmlCatalogSetDefaults(allow: c_int) {
6648 crate::xml::catalog::set_defaults(allow)
6649}
6650
6651#[no_mangle]
6659pub extern "C" fn xmlCatalogGetDefaults() -> c_int {
6660 crate::xml::catalog::get_defaults()
6661}
6662
6663#[no_mangle]
6671pub unsafe extern "C" fn xmlCatalogAdd(
6672 type_: *const xmlChar,
6673 orig: *const xmlChar,
6674 replace: *const xmlChar,
6675) -> c_int {
6676 if type_.is_null() || orig.is_null() || replace.is_null() {
6677 return -1;
6678 }
6679 crate::xml::catalog::add(type_, orig, replace)
6680}
6681
6682#[no_mangle]
6690pub unsafe extern "C" fn xmlCatalogRemove(value: *const xmlChar) -> c_int {
6691 if value.is_null() {
6692 return 0;
6693 }
6694 crate::xml::catalog::remove(value)
6695}
6696
6697#[no_mangle]
6705pub unsafe extern "C" fn xmlCatalogDump(output: *mut c_void, _catal: *mut c_void) {
6706 if output.is_null() {
6707 return;
6708 }
6709 let doc = crate::xml::catalog::dump_doc();
6710 if doc.is_null() {
6711 return;
6712 }
6713 let mut mem: *mut xmlChar = ptr::null_mut();
6714 let mut size: c_int = 0;
6715 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6716 if !mem.is_null() {
6717 libc::fwrite(
6718 mem as *const c_void,
6719 1,
6720 size as usize,
6721 output as *mut libc::FILE,
6722 );
6723 xmlFreeImpl(mem as *mut c_void);
6724 }
6725 crate::xml::tree::free_doc(doc);
6726}
6727
6728#[no_mangle]
6738pub unsafe extern "C" fn xmlCatalogSave(filename: *const c_char) -> c_int {
6739 if filename.is_null() {
6740 return -1;
6741 }
6742 let doc = crate::xml::catalog::dump_doc();
6743 if doc.is_null() {
6744 return -1;
6745 }
6746 let mut mem: *mut xmlChar = ptr::null_mut();
6747 let mut size: c_int = 0;
6748 crate::xml::tree::xmlDocDumpFormatMemory(doc, &mut mem, &mut size, 1);
6749 let mut ret: c_int = -1;
6750 if !mem.is_null() {
6751 let fp = libc::fopen(filename, c"w".as_ptr() as *const c_char);
6752 if !fp.is_null() {
6753 let written = libc::fwrite(mem as *const c_void, 1, size as usize, fp);
6754 ret = if written == size as usize { 0 } else { -1 };
6755 libc::fclose(fp);
6756 }
6757 xmlFreeImpl(mem as *mut c_void);
6758 }
6759 crate::xml::tree::free_doc(doc);
6760 ret
6761}
6762
6763#[no_mangle]
6771pub extern "C" fn xmlCatalogCleanup() {
6772 crate::xml::catalog::cleanup();
6773}
6774
6775#[no_mangle]
6783pub extern "C" fn xmlCatalogConvert() -> *mut _xmlDoc {
6784 unsafe { crate::xml::catalog::convert() }
6786}
6787
6788#[no_mangle]
6800pub const unsafe extern "C" fn htmlParseFile(
6801 _filename: *const c_char,
6802 _encoding: *const c_char,
6803) -> *mut _xmlDoc {
6804 ptr::null_mut()
6806}
6807
6808#[no_mangle]
6816pub const unsafe extern "C" fn htmlParseMemory(
6817 _buffer: *const c_char,
6818 _size: c_int,
6819) -> *mut _xmlDoc {
6820 ptr::null_mut()
6822}
6823
6824#[no_mangle]
6832pub const unsafe extern "C" fn htmlParseDoc(
6833 _cur: *const xmlChar,
6834 _encoding: *const c_char,
6835) -> *mut _xmlDoc {
6836 ptr::null_mut()
6838}
6839
6840#[no_mangle]
6849pub const unsafe extern "C" fn htmlCreateFileParserCtxt(
6850 _filename: *const c_char,
6851 _encoding: *const c_char,
6852) -> *mut c_void {
6853 ptr::null_mut()
6855}
6856
6857#[no_mangle]
6865pub extern "C" fn htmlFreeParserCtxt(ctxt: *mut c_void) {
6866 unsafe { crate::xml::html::free_parser_ctxt(ctxt) }
6867}
6868
6869#[no_mangle]
6877pub const extern "C" fn htmlInitParser() {
6878 }
6880
6881#[no_mangle]
6889pub const extern "C" fn htmlCleanupParser() {
6890 }
6892
6893#[no_mangle]
6905pub unsafe extern "C" fn xmlNewValidCtxt() -> *mut _xmlValidCtxt {
6906 crate::xml::validation::new_valid_ctxt()
6907}
6908
6909#[no_mangle]
6917pub unsafe extern "C" fn xmlFreeValidCtxt(ctxt: *mut _xmlValidCtxt) {
6918 crate::xml::validation::free_valid_ctxt(ctxt);
6919}
6920
6921#[no_mangle]
6932pub unsafe extern "C" fn xmlSetValidErrors(
6933 ctxt: *mut _xmlValidCtxt,
6934 err: Option<xmlGenericErrorFunc>,
6935 warn: Option<xmlGenericErrorFunc>,
6936 data: *mut c_void,
6937) {
6938 crate::xml::validation::set_valid_errors(ctxt, err, warn, data);
6939}
6940
6941#[no_mangle]
6949pub unsafe extern "C" fn xmlValidateDocument(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
6950 crate::xml::validation::validate_document(ctxt, doc)
6951}
6952
6953#[no_mangle]
6961pub unsafe extern "C" fn xmlValidateDocumentFinal(
6962 ctxt: *mut _xmlValidCtxt,
6963 doc: *mut _xmlDoc,
6964) -> c_int {
6965 crate::xml::validation::validate_document_final(ctxt, doc)
6966}
6967
6968#[no_mangle]
6978pub unsafe extern "C" fn xmlValidateElement(
6979 ctxt: *mut _xmlValidCtxt,
6980 doc: *mut _xmlDoc,
6981 elem: *mut _xmlNode,
6982) -> c_int {
6983 crate::xml::validation::validate_element(ctxt, doc, elem)
6984}
6985
6986#[no_mangle]
6997pub unsafe extern "C" fn xmlValidateAttributeDecl(
6998 ctxt: *mut _xmlValidCtxt,
6999 doc: *mut _xmlDoc,
7000 elem: *mut _xmlNode,
7001 attr: *mut _xmlAttribute,
7002) -> c_int {
7003 crate::xml::validation::validate_attribute_decl(ctxt, doc, elem, attr)
7004}
7005
7006#[no_mangle]
7014pub unsafe extern "C" fn xmlValidateAttributeValue(atype: c_int, value: *const xmlChar) -> c_int {
7015 crate::xml::validation::validate_attribute_value(atype, value)
7016}
7017
7018#[no_mangle]
7028pub unsafe extern "C" fn xmlValidateNotationUse(
7029 ctxt: *mut _xmlValidCtxt,
7030 doc: *mut _xmlDoc,
7031 notation_name: *const xmlChar,
7032) -> c_int {
7033 crate::xml::validation::validate_notation_use(ctxt, doc, notation_name)
7034}
7035
7036#[no_mangle]
7047pub unsafe extern "C" fn xmlValidateID(
7048 ctxt: *mut _xmlValidCtxt,
7049 doc: *mut _xmlDoc,
7050 node: *mut _xmlNode,
7051 value: *const xmlChar,
7052) -> c_int {
7053 crate::xml::validation::validate_id(ctxt, doc, node, value)
7054}
7055
7056#[no_mangle]
7067pub unsafe extern "C" fn xmlValidateIDRef(
7068 ctxt: *mut _xmlValidCtxt,
7069 doc: *mut _xmlDoc,
7070 node: *mut _xmlNode,
7071 value: *const xmlChar,
7072) -> c_int {
7073 crate::xml::validation::validate_id_ref(ctxt, doc, node, value)
7074}
7075
7076#[no_mangle]
7087pub unsafe extern "C" fn xmlValidateIDRefs(
7088 ctxt: *mut _xmlValidCtxt,
7089 doc: *mut _xmlDoc,
7090 node: *mut _xmlNode,
7091 value: *const xmlChar,
7092) -> c_int {
7093 crate::xml::validation::validate_id_refs(ctxt, doc, node, value)
7094}
7095
7096#[no_mangle]
7106pub unsafe extern "C" fn xmlValidateNCName(value: *const xmlChar, space: c_int) -> c_int {
7107 crate::xml::validation::validate_ncname(value, space)
7108}
7109
7110#[no_mangle]
7118pub unsafe extern "C" fn xmlValidateQName(value: *const xmlChar, space: c_int) -> c_int {
7119 crate::xml::validation::validate_qname(value, space)
7120}
7121
7122#[no_mangle]
7135pub unsafe extern "C" fn xmlValidateName(value: *const xmlChar, space: c_int) -> c_int {
7136 crate::xml::validation::validate_name_space(value, space)
7137}
7138
7139#[no_mangle]
7147pub unsafe extern "C" fn xmlValidateNMToken(value: *const xmlChar, space: c_int) -> c_int {
7148 crate::xml::validation::validate_nmtoken_space(value, space)
7149}
7150
7151#[no_mangle]
7161pub unsafe extern "C" fn xmlValidateNameValue(value: *const xmlChar) -> c_int {
7162 crate::xml::validation::validate_name_value(value)
7163}
7164
7165#[no_mangle]
7174pub unsafe extern "C" fn xmlValidateNamesValue(value: *const xmlChar) -> c_int {
7175 crate::xml::validation::validate_names_value(value)
7176}
7177
7178#[no_mangle]
7186pub unsafe extern "C" fn xmlValidateNmtokenValue(value: *const xmlChar) -> c_int {
7187 crate::xml::validation::validate_nmtoken_value(value)
7188}
7189
7190#[no_mangle]
7198pub unsafe extern "C" fn xmlValidateNmtokensValue(value: *const xmlChar) -> c_int {
7199 crate::xml::validation::validate_nmtokens_value(value)
7200}
7201
7202#[no_mangle]
7213pub unsafe extern "C" fn xmlValidateElementDecl(
7214 ctxt: *mut _xmlValidCtxt,
7215 doc: *mut _xmlDoc,
7216 elem: *mut _xmlElement,
7217) -> c_int {
7218 crate::xml::validation::validate_element_decl(ctxt, doc, elem)
7219}
7220
7221#[no_mangle]
7234pub const unsafe extern "C" fn xmlValidateNotationDecl(
7235 ctxt: *mut _xmlValidCtxt,
7236 doc: *mut _xmlDoc,
7237 nota: *mut _xmlNotation,
7238) -> c_int {
7239 crate::xml::validation::validate_notation_decl(ctxt, doc, nota)
7240}
7241
7242#[no_mangle]
7254pub unsafe extern "C" fn xmlValidateOneAttribute(
7255 ctxt: *mut _xmlValidCtxt,
7256 doc: *mut _xmlDoc,
7257 elem: *mut _xmlNode,
7258 attr: *mut _xmlAttr,
7259 value: *const xmlChar,
7260) -> c_int {
7261 crate::xml::validation::validate_one_attribute(ctxt, doc, elem, attr, value)
7262}
7263
7264#[no_mangle]
7274pub unsafe extern "C" fn xmlValidateOneElement(
7275 ctxt: *mut _xmlValidCtxt,
7276 doc: *mut _xmlDoc,
7277 elem: *mut _xmlNode,
7278) -> c_int {
7279 crate::xml::validation::validate_one_element(ctxt, doc, elem)
7280}
7281
7282#[no_mangle]
7295pub unsafe extern "C" fn xmlValidateOneNamespace(
7296 ctxt: *mut _xmlValidCtxt,
7297 doc: *mut _xmlDoc,
7298 elem: *mut _xmlNode,
7299 prefix: *const xmlChar,
7300 ns: *mut _xmlNs,
7301 value: *const xmlChar,
7302) -> c_int {
7303 crate::xml::validation::validate_one_namespace(ctxt, doc, elem, prefix, ns, value)
7304}
7305
7306#[no_mangle]
7318pub unsafe extern "C" fn xmlValidatePushElement(
7319 ctxt: *mut _xmlValidCtxt,
7320 doc: *mut _xmlDoc,
7321 elem: *mut _xmlNode,
7322 qname: *const xmlChar,
7323) -> c_int {
7324 crate::xml::validation::validate_push_element(ctxt, doc, elem, qname)
7325}
7326
7327#[no_mangle]
7337pub unsafe extern "C" fn xmlValidatePushCData(
7338 ctxt: *mut _xmlValidCtxt,
7339 data: *const xmlChar,
7340 len: c_int,
7341) -> c_int {
7342 crate::xml::validation::validate_push_cdata(ctxt, data, len)
7343}
7344
7345#[no_mangle]
7356pub unsafe extern "C" fn xmlValidatePopElement(
7357 ctxt: *mut _xmlValidCtxt,
7358 doc: *mut _xmlDoc,
7359 elem: *mut _xmlNode,
7360 qname: *const xmlChar,
7361) -> c_int {
7362 crate::xml::validation::validate_pop_element(ctxt, doc, elem, qname)
7363}
7364
7365#[no_mangle]
7374pub unsafe extern "C" fn xmlValidBuildContentModel(
7375 ctxt: *mut _xmlValidCtxt,
7376 elem: *mut _xmlElement,
7377) -> c_int {
7378 crate::xml::validation::validate_build_content_model(ctxt, elem)
7379}
7380
7381#[no_mangle]
7392pub unsafe extern "C" fn xmlAddID(
7393 ctxt: *mut _xmlValidCtxt,
7394 doc: *mut _xmlDoc,
7395 value: *const xmlChar,
7396 attr: *mut _xmlAttr,
7397) -> *mut _xmlID {
7398 crate::xml::validation::add_id(ctxt, doc, value, attr)
7399}
7400
7401#[no_mangle]
7409pub unsafe extern "C" fn xmlRemoveID(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7410 crate::xml::validation::remove_id(doc, attr)
7411}
7412
7413#[no_mangle]
7424pub unsafe extern "C" fn xmlAddRef(
7425 ctxt: *mut _xmlValidCtxt,
7426 doc: *mut _xmlDoc,
7427 value: *const xmlChar,
7428 attr: *mut _xmlAttr,
7429) -> *mut _xmlRef {
7430 crate::xml::validation::add_ref(ctxt, doc, value, attr)
7431}
7432
7433#[no_mangle]
7441pub unsafe extern "C" fn xmlRemoveRef(doc: *mut _xmlDoc, attr: *mut _xmlAttr) -> c_int {
7442 crate::xml::validation::remove_ref(doc, attr)
7443}
7444
7445#[no_mangle]
7453pub unsafe extern "C" fn xmlAddIDSafe(attr: *mut _xmlAttr, value: *const xmlChar) -> c_int {
7454 crate::xml::validation::add_id_safe(attr, value)
7455}
7456
7457#[no_mangle]
7465pub unsafe extern "C" fn xmlFreeIDTable(table: *mut c_void) {
7466 crate::xml::validation::free_id_table(table as *mut crate::xml::hash::HashTable);
7467}
7468
7469#[no_mangle]
7477pub unsafe extern "C" fn xmlFreeRefTable(table: *mut c_void) {
7478 crate::xml::validation::free_ref_table(table as *mut crate::xml::hash::HashTable);
7479}
7480
7481#[no_mangle]
7489pub unsafe extern "C" fn xmlGetID(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut _xmlAttr {
7490 crate::xml::validation::get_id(doc, id)
7491}
7492
7493#[no_mangle]
7501pub unsafe extern "C" fn xmlGetRefs(doc: *mut _xmlDoc, id: *const xmlChar) -> *mut c_void {
7502 crate::xml::validation::get_refs(doc, id) as *mut c_void
7503}
7504
7505#[no_mangle]
7513pub unsafe extern "C" fn xmlIsID(
7514 doc: *mut _xmlDoc,
7515 elem: *mut _xmlNode,
7516 attr: *mut _xmlAttr,
7517) -> c_int {
7518 crate::xml::validation::is_id(doc, elem, attr)
7519}
7520
7521#[no_mangle]
7529pub unsafe extern "C" fn xmlIsRef(
7530 doc: *mut _xmlDoc,
7531 elem: *mut _xmlNode,
7532 attr: *mut _xmlAttr,
7533) -> c_int {
7534 crate::xml::validation::is_ref(doc, elem, attr)
7535}
7536
7537#[no_mangle]
7545pub unsafe extern "C" fn xmlGetDtdElementDesc(
7546 dtd: *mut _xmlDtd,
7547 name: *const xmlChar,
7548) -> *mut _xmlElement {
7549 crate::xml::validation::get_dtd_element_desc(dtd, name)
7550}
7551
7552#[no_mangle]
7562pub unsafe extern "C" fn xmlGetDtdAttrDesc(
7563 dtd: *mut _xmlDtd,
7564 elem: *const xmlChar,
7565 name: *const xmlChar,
7566) -> *mut _xmlAttribute {
7567 crate::xml::validation::get_dtd_attr_desc(dtd, elem, name)
7568}
7569
7570#[no_mangle]
7580pub unsafe extern "C" fn xmlGetDtdQElementDesc(
7581 dtd: *mut _xmlDtd,
7582 name: *const xmlChar,
7583 prefix: *const xmlChar,
7584) -> *mut _xmlElement {
7585 crate::xml::validation::get_dtd_qelement_desc(dtd, name, prefix)
7586}
7587
7588#[no_mangle]
7599pub unsafe extern "C" fn xmlGetDtdQAttrDesc(
7600 dtd: *mut _xmlDtd,
7601 elem: *const xmlChar,
7602 name: *const xmlChar,
7603 prefix: *const xmlChar,
7604) -> *mut _xmlAttribute {
7605 crate::xml::validation::get_dtd_qattr_desc(dtd, elem, name, prefix)
7606}
7607
7608#[no_mangle]
7616pub unsafe extern "C" fn xmlGetDtdNotationDesc(
7617 dtd: *mut _xmlDtd,
7618 name: *const xmlChar,
7619) -> *mut _xmlNotation {
7620 crate::xml::validation::get_dtd_notation_desc(dtd, name)
7621}
7622
7623#[no_mangle]
7631pub unsafe extern "C" fn xmlValidateRoot(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7632 crate::xml::validation::validate_root(ctxt, doc)
7633}
7634
7635#[no_mangle]
7645pub unsafe extern "C" fn xmlValidateContent(
7646 ctxt: *mut _xmlValidCtxt,
7647 node: *mut _xmlNode,
7648 doc: *mut _xmlDoc,
7649) -> c_int {
7650 crate::xml::validation::validate_content(ctxt, node, doc)
7651}
7652
7653#[no_mangle]
7661pub unsafe extern "C" fn xmlIsMixedElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7662 crate::xml::validation::is_mixed_element(doc, name)
7663}
7664
7665#[no_mangle]
7673pub unsafe extern "C" fn xmlIsEmptyElement(doc: *mut _xmlDoc, name: *const xmlChar) -> c_int {
7674 crate::xml::validation::is_empty_element(doc, name)
7675}
7676
7677#[no_mangle]
7687pub unsafe extern "C" fn xmlValidateDtd(
7688 ctxt: *mut _xmlValidCtxt,
7689 doc: *mut _xmlDoc,
7690 dtd: *mut _xmlDtd,
7691) -> c_int {
7692 crate::xml::validation::validate_dtd(ctxt, doc, dtd)
7693}
7694
7695#[no_mangle]
7703pub unsafe extern "C" fn xmlValidateDtdFinal(ctxt: *mut _xmlValidCtxt, doc: *mut _xmlDoc) -> c_int {
7704 crate::xml::validation::validate_dtd_final(ctxt, doc)
7705}
7706
7707#[no_mangle]
7717pub unsafe extern "C" fn xmlValidateEnumeration(
7718 ctxt: *mut _xmlValidCtxt,
7719 value: *const xmlChar,
7720 tree: *mut _xmlEnumeration,
7721) -> c_int {
7722 crate::xml::validation::validate_enumeration(ctxt, value, tree)
7723}
7724
7725#[no_mangle]
7738pub const extern "C" fn xmlGetBinaryPath() -> *mut c_char {
7739 ptr::null_mut()
7741}
7742
7743#[no_mangle]
7751pub const extern "C" fn xmlGetHomeOfBinary() -> *mut c_char {
7752 ptr::null_mut()
7754}
7755
7756#[no_mangle]
7767pub unsafe extern "C" fn xmlSAX2StartDocument(ctx: *mut c_void) {
7768 crate::xml::sax::default::default_sax_handler::startDocument(ctx)
7769}
7770
7771#[no_mangle]
7773pub unsafe extern "C" fn xmlSAX2EndDocument(ctx: *mut c_void) {
7774 crate::xml::sax::default::default_sax_handler::endDocument(ctx)
7775}
7776
7777#[no_mangle]
7779pub unsafe extern "C" fn xmlSAX2StartElementNs(
7780 ctx: *mut c_void,
7781 localname: *const xmlChar,
7782 prefix: *const xmlChar,
7783 URI: *const xmlChar,
7784 nb_namespaces: c_int,
7785 namespaces: *mut *const xmlChar,
7786 nb_attributes: c_int,
7787 nb_defaulted: c_int,
7788 attributes: *mut *const xmlChar,
7789) {
7790 crate::xml::sax::default::default_sax_handler::startElementNs(
7791 ctx,
7792 localname,
7793 prefix,
7794 URI,
7795 nb_namespaces,
7796 namespaces,
7797 nb_attributes,
7798 nb_defaulted,
7799 attributes,
7800 )
7801}
7802
7803#[no_mangle]
7805pub unsafe extern "C" fn xmlSAX2EndElementNs(
7806 ctx: *mut c_void,
7807 localname: *const xmlChar,
7808 prefix: *const xmlChar,
7809 URI: *const xmlChar,
7810) {
7811 crate::xml::sax::default::default_sax_handler::endElementNs(ctx, localname, prefix, URI)
7812}
7813
7814#[no_mangle]
7816pub unsafe extern "C" fn xmlSAX2Characters(ctx: *mut c_void, ch: *const xmlChar, len: c_int) {
7817 crate::xml::sax::default::default_sax_handler::characters(ctx, ch, len)
7818}
7819
7820#[no_mangle]
7822pub unsafe extern "C" fn xmlSAX2IgnorableWhitespace(
7823 ctx: *mut c_void,
7824 ch: *const xmlChar,
7825 len: c_int,
7826) {
7827 crate::xml::sax::default::default_sax_handler::ignorableWhitespace(ctx, ch, len)
7828}
7829
7830#[no_mangle]
7832pub unsafe extern "C" fn xmlSAX2Comment(ctx: *mut c_void, value: *const xmlChar) {
7833 crate::xml::sax::default::default_sax_handler::comment(ctx, value)
7834}
7835
7836#[no_mangle]
7838pub unsafe extern "C" fn xmlSAX2ProcessingInstruction(
7839 ctx: *mut c_void,
7840 target: *const xmlChar,
7841 data: *const xmlChar,
7842) {
7843 crate::xml::sax::default::default_sax_handler::processingInstruction(ctx, target, data)
7844}
7845
7846#[no_mangle]
7848pub unsafe extern "C" fn xmlSAX2CDataBlock(ctx: *mut c_void, value: *const xmlChar, len: c_int) {
7849 crate::xml::sax::default::default_sax_handler::cdataBlock(ctx, value, len)
7850}
7851
7852#[no_mangle]
7854pub unsafe extern "C" fn xmlSAX2InternalSubset(
7855 ctx: *mut c_void,
7856 name: *const xmlChar,
7857 ExternalID: *const xmlChar,
7858 SystemID: *const xmlChar,
7859) {
7860 crate::xml::sax::default::default_sax_handler::internalSubset(ctx, name, ExternalID, SystemID)
7861}
7862
7863#[no_mangle]
7865pub unsafe extern "C" fn xmlSAX2ExternalSubset(
7866 ctx: *mut c_void,
7867 name: *const xmlChar,
7868 ExternalID: *const xmlChar,
7869 SystemID: *const xmlChar,
7870) {
7871 crate::xml::sax::default::default_sax_handler::externalSubset(ctx, name, ExternalID, SystemID)
7872}
7873
7874#[no_mangle]
7876pub unsafe extern "C" fn xmlSAX2EntityDecl(
7877 ctx: *mut c_void,
7878 name: *const xmlChar,
7879 type_: c_int,
7880 publicId: *const xmlChar,
7881 systemId: *const xmlChar,
7882 content: *mut xmlChar,
7883) {
7884 crate::xml::sax::default::default_sax_handler::entityDecl(
7885 ctx, name, type_, publicId, systemId, content,
7886 )
7887}
7888
7889#[no_mangle]
7891pub const unsafe extern "C" fn xmlSAX2AttributeDecl(
7892 ctx: *mut c_void,
7893 elem: *const xmlChar,
7894 fullname: *const xmlChar,
7895 type_: c_int,
7896 def: c_int,
7897 defaultValue: *const xmlChar,
7898 tree: *mut crate::abi::structs::_xmlEnumeration,
7899) {
7900 crate::xml::sax::default::default_sax_handler::attributeDecl(
7901 ctx,
7902 elem,
7903 fullname,
7904 type_,
7905 def,
7906 defaultValue,
7907 tree,
7908 )
7909}
7910
7911#[no_mangle]
7913pub const unsafe extern "C" fn xmlSAX2ElementDecl(
7914 ctx: *mut c_void,
7915 name: *const xmlChar,
7916 type_: c_int,
7917 content: *mut crate::abi::structs::_xmlElementContent,
7918) {
7919 crate::xml::sax::default::default_sax_handler::elementDecl(ctx, name, type_, content)
7920}
7921
7922#[no_mangle]
7924pub const unsafe extern "C" fn xmlSAX2NotationDecl(
7925 ctx: *mut c_void,
7926 name: *const xmlChar,
7927 publicId: *const xmlChar,
7928 systemId: *const xmlChar,
7929) {
7930 crate::xml::sax::default::default_sax_handler::notationDecl(ctx, name, publicId, systemId)
7931}
7932
7933#[no_mangle]
7935pub const unsafe extern "C" fn xmlSAX2UnparsedEntityDecl(
7936 ctx: *mut c_void,
7937 name: *const xmlChar,
7938 publicId: *const xmlChar,
7939 systemId: *const xmlChar,
7940 notationName: *const xmlChar,
7941) {
7942 crate::xml::sax::default::default_sax_handler::unparsedEntityDecl(
7943 ctx,
7944 name,
7945 publicId,
7946 systemId,
7947 notationName,
7948 )
7949}
7950
7951#[no_mangle]
7953pub const unsafe extern "C" fn xmlSAX2ResolveEntity(
7954 ctx: *mut c_void,
7955 publicId: *const xmlChar,
7956 systemId: *const xmlChar,
7957) -> *mut crate::abi::structs::_xmlParserInput {
7958 crate::xml::sax::default::default_sax_handler::resolveEntity(ctx, publicId, systemId)
7959}
7960
7961#[no_mangle]
7963pub const unsafe extern "C" fn xmlSAX2IsStandalone(ctx: *mut c_void) -> c_int {
7964 crate::xml::sax::default::default_sax_handler::isStandalone(ctx)
7965}
7966
7967#[no_mangle]
7969pub unsafe extern "C" fn xmlSAX2HasInternalSubset(ctx: *mut c_void) -> c_int {
7970 crate::xml::sax::default::default_sax_handler::hasInternalSubset(ctx)
7971}
7972
7973#[no_mangle]
7975pub unsafe extern "C" fn xmlSAX2HasExternalSubset(ctx: *mut c_void) -> c_int {
7976 crate::xml::sax::default::default_sax_handler::hasExternalSubset(ctx)
7977}
7978
7979#[no_mangle]
7981pub unsafe extern "C" fn xmlSAX2GetEntity(
7982 ctx: *mut c_void,
7983 name: *const xmlChar,
7984) -> *mut crate::abi::structs::_xmlEntity {
7985 crate::xml::sax::default::default_sax_handler::getEntity(ctx, name)
7986}
7987
7988#[no_mangle]
7990pub unsafe extern "C" fn xmlSAX2GetParameterEntity(
7991 ctx: *mut c_void,
7992 name: *const xmlChar,
7993) -> *mut crate::abi::structs::_xmlEntity {
7994 crate::xml::sax::default::default_sax_handler::getParameterEntity(ctx, name)
7995}
7996
7997#[no_mangle]
8000pub unsafe extern "C" fn xmlSAX2GetLineNumber(ctx: *mut c_void) -> c_int {
8001 crate::xml::sax::default::default_sax_handler::getLineNumber(ctx)
8002}
8003
8004#[no_mangle]
8006pub unsafe extern "C" fn xmlSAX2GetColumnNumber(ctx: *mut c_void) -> c_int {
8007 crate::xml::sax::default::default_sax_handler::getColumnNumber(ctx)
8008}
8009
8010#[no_mangle]
8012pub const unsafe extern "C" fn xmlSAX2GetPublicId(ctx: *mut c_void) -> *const xmlChar {
8013 crate::xml::sax::default::default_sax_handler::getPublicId(ctx)
8014}
8015
8016#[no_mangle]
8018pub unsafe extern "C" fn xmlSAX2GetSystemId(ctx: *mut c_void) -> *const xmlChar {
8019 crate::xml::sax::default::default_sax_handler::getSystemId(ctx)
8020}
8021
8022#[no_mangle]
8026pub unsafe extern "C" fn xmlSAX2StartElement(
8027 ctx: *mut c_void,
8028 name: *const xmlChar,
8029 atts: *mut *const xmlChar,
8030) {
8031 crate::xml::sax::dispatch::SaxDispatcher::sax1_start_element(ctx, name, atts);
8035}
8036
8037#[no_mangle]
8039pub unsafe extern "C" fn xmlSAX2EndElement(ctx: *mut c_void, name: *const xmlChar) {
8040 crate::xml::sax::dispatch::SaxDispatcher::sax1_end_element(ctx, name);
8041}
8042
8043#[no_mangle]
8045pub const unsafe extern "C" fn xmlSAX2SetDocumentLocator(
8046 ctx: *mut c_void,
8047 loc: *mut crate::abi::callbacks::_xmlSAXLocator,
8048) {
8049 crate::xml::sax::default::default_sax_handler::setDocumentLocator(ctx, loc)
8050}
8051
8052#[no_mangle]
8054pub unsafe extern "C" fn xmlSAX2Reference(ctx: *mut c_void, name: *const xmlChar) {
8055 crate::xml::sax::default::default_sax_handler::reference(ctx, name)
8056}
8057
8058#[cfg(test)]
8059mod tests {
8060 use super::xml_number_to_string;
8061
8062 #[allow(clippy::approx_constant)]
8068 #[test]
8069 fn test_xml_number_to_string_parity_cases() {
8070 let cases: &[(f64, &str)] = &[
8071 (1234567.891, "1234567.891"),
8072 (0.1 + 0.2, "0.3"),
8073 (1.0 / 3.0, "0.333333333333333"),
8074 (1e20, "1e+20"),
8075 (1e-5, "0.00001"),
8076 (123456789012345678901234567890.0, "1.23456789012346e+29"),
8077 (1e100, "1e+100"),
8078 (-1e100, "-1e+100"),
8079 (1.5e-100, "1.5e-100"),
8080 (1e9, "1000000000"),
8081 (0.00001, "0.00001"),
8082 (9.99e-6, "9.99e-06"),
8083 (2147483646.0, "2147483646"),
8084 (2147483648.0, "2.147483648e+09"),
8085 (-2147483647.0, "-2147483647"),
8086 (-2147483649.0, "-2.147483649e+09"),
8087 (0.5, "0.5"),
8088 (1.0 / 7.0, "0.142857142857143"),
8089 (2.675, "2.675"),
8090 (3.141592653589793, "3.141592653589793"),
8091 (-0.0, "0"),
8092 (0.0, "0"),
8093 (f64::INFINITY, "Infinity"),
8094 (f64::NEG_INFINITY, "-Infinity"),
8095 (f64::NAN, "NaN"),
8096 (0.30000000000000004, "0.3"),
8097 (2.2250738585072014e-308, "2.2250738585072e-308"),
8098 (5e-324, "4.94065645841247e-324"),
8099 ];
8100 for (n, expected) in cases {
8101 assert_eq!(&xml_number_to_string(*n), expected, "value: {}", n);
8102 }
8103 }
8104}