#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::not_unsafe_ptr_arg_deref)]
use core::ffi::c_void;
use core::ptr;
use std::mem::size_of;
use std::os::raw::{c_char, c_int, c_uint};
use crate::abi::allocator::*;
use crate::abi::callbacks::*;
use crate::abi::ownership::*;
use crate::abi::structs::*;
use crate::abi::types::xmlAttributeType::XML_ATTRIBUTE_CDATA;
use crate::abi::types::xmlElementType::*;
use crate::abi::types::xmlErrorLevel::XML_ERR_NONE;
use crate::abi::types::*;
use crate::abi::versioning::*;
#[no_mangle]
pub unsafe extern "C" fn xmlInitParser() {
crate::internal::globals::init_parser();
}
#[no_mangle]
pub unsafe extern "C" fn xmlCleanupParser() {
crate::internal::globals::cleanup_parser();
}
#[no_mangle]
pub unsafe extern "C" fn xmlInitThreads() -> c_int {
crate::internal::globals::init_threads()
}
#[no_mangle]
pub unsafe extern "C" fn xmlCleanupThreads() {
crate::xml::threads::cleanup_threads();
}
#[no_mangle]
pub extern "C" fn xmlIsInitialized() -> c_int {
if crate::abi::versioning::is_initialized() {
1
} else {
0
}
}
#[no_mangle]
pub unsafe extern "C" fn xmlLockLibrary() {
crate::xml::threads::lock_library();
}
#[no_mangle]
pub unsafe extern "C" fn xmlUnlockLibrary() {
crate::xml::threads::unlock_library();
}
#[no_mangle]
pub unsafe extern "C" fn xmlSetGenericErrorFunc(
ctx: *mut c_void,
handler: Option<xmlGenericErrorFunc>,
) {
unsafe { crate::xml::errors::set_generic_error_func(ctx, handler) };
}
#[no_mangle]
pub unsafe extern "C" fn xmlSetStructuredErrorFunc(
ctx: *mut c_void,
handler: Option<xmlStructuredErrorFunc>,
) {
unsafe { crate::xml::errors::set_structured_error_func(ctx, handler) };
}
#[no_mangle]
pub extern "C" fn xmlGetLastError() -> *mut _xmlError {
crate::xml::errors::get_last_error()
}
#[no_mangle]
pub unsafe extern "C" fn xmlCopyError(from: *const _xmlError, to: *mut _xmlError) -> c_int {
unsafe { crate::xml::errors::copy_error(from, to) }
}
#[no_mangle]
pub unsafe extern "C" fn xmlResetError(err: *mut _xmlError) {
unsafe { crate::xml::errors::reset_error(err) };
}
#[no_mangle]
pub unsafe extern "C" fn xmlRaiseError(
ctxt: *mut c_void,
ctxt2: *mut c_void,
ctxt3: *mut c_void,
ctxt4: *mut c_void,
ctxt5: *mut c_void,
domain: c_int,
code: c_int,
level: c_int,
file: *const c_char,
line: c_int,
str1: *const c_char,
str2: *const c_char,
str3: *const c_char,
int1: c_int,
int2: c_int,
msg: *const c_char,
) {
unsafe {
crate::xml::errors::raise_error(
ctxt, ctxt2, ctxt3, ctxt4, ctxt5, domain, code, level, file, line, str1, str2, str3,
int1, int2, msg,
);
}
}
#[no_mangle]
pub extern "C" fn xmlResetLastError() {
crate::xml::errors::reset_last_error();
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrdup(cur: *const xmlChar) -> *mut xmlChar {
if cur.is_null() {
return ptr::null_mut();
}
let len = unsafe { xmlStrlen(cur) };
let size = len + 1;
let new_ptr = unsafe { xmlMalloc(size as usize) };
if new_ptr.is_null() {
return ptr::null_mut();
}
unsafe {
ptr::copy_nonoverlapping(cur as *const u8, new_ptr as *mut u8, size as usize);
}
new_ptr as *mut xmlChar
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrndup(cur: *const xmlChar, len: c_int) -> *mut xmlChar {
if cur.is_null() || len <= 0 {
return ptr::null_mut();
}
let size = len as usize + 1;
let new_ptr = unsafe { xmlMalloc(size) };
if new_ptr.is_null() {
return ptr::null_mut();
}
unsafe {
ptr::copy_nonoverlapping(cur as *const u8, new_ptr as *mut u8, len as usize);
*(new_ptr.add(len as usize) as *mut u8) = 0;
}
new_ptr as *mut xmlChar
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrlen(str: *const xmlChar) -> c_int {
if str.is_null() {
return 0;
}
unsafe { libc::strlen(str as *const c_char) as c_int }
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrcmp(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
if str1.is_null() && str2.is_null() {
return 0;
}
if str1.is_null() {
return -1;
}
if str2.is_null() {
return 1;
}
unsafe { libc::strcmp(str1 as *const c_char, str2 as *const c_char) as c_int }
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrncmp(
str1: *const xmlChar,
str2: *const xmlChar,
len: c_int,
) -> c_int {
if len <= 0 {
return 0;
}
if str1.is_null() && str2.is_null() {
return 0;
}
if str1.is_null() {
return -1;
}
if str2.is_null() {
return 1;
}
unsafe { libc::strncmp(str1 as *const c_char, str2 as *const c_char, len as usize) as c_int }
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrcasecmp(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
if str1.is_null() && str2.is_null() {
return 0;
}
if str1.is_null() {
return -1;
}
if str2.is_null() {
return 1;
}
unsafe { libc::strcasecmp(str1 as *const c_char, str2 as *const c_char) as c_int }
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrncasecmp(
str1: *const xmlChar,
str2: *const xmlChar,
len: c_int,
) -> c_int {
if len <= 0 {
return 0;
}
if str1.is_null() && str2.is_null() {
return 0;
}
if str1.is_null() {
return -1;
}
if str2.is_null() {
return 1;
}
unsafe {
libc::strncasecmp(str1 as *const c_char, str2 as *const c_char, len as usize) as c_int
}
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrEqual(str1: *const xmlChar, str2: *const xmlChar) -> c_int {
if str1.is_null() && str2.is_null() {
return 1;
}
if str1.is_null() || str2.is_null() {
return 0;
}
unsafe { (libc::strcmp(str1 as *const c_char, str2 as *const c_char) == 0) as c_int }
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrQEqual(
pref: *const xmlChar,
name: *const xmlChar,
str: *const xmlChar,
) -> c_int {
if name.is_null() || str.is_null() {
return 0;
}
if pref.is_null() {
return unsafe { xmlStrEqual(name, str) };
}
let pref_len = unsafe { xmlStrlen(pref) };
let name_len = unsafe { xmlStrlen(name) };
let total_len = pref_len + 1 + name_len;
let str_len = unsafe { xmlStrlen(str) };
if total_len != str_len {
return 0;
}
if unsafe {
libc::strncmp(
pref as *const c_char,
str as *const c_char,
pref_len as usize,
)
} != 0
{
return 0;
}
if unsafe { *str.add(pref_len as usize) } != b':' as xmlChar {
return 0;
}
(unsafe {
libc::strncmp(
name as *const c_char,
str.add((pref_len + 1) as usize) as *const c_char,
name_len as usize,
) == 0
}) as c_int
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrcat(cur: *mut xmlChar, add: *const xmlChar) -> *mut xmlChar {
if add.is_null() {
return cur;
}
if cur.is_null() {
return unsafe { xmlStrdup(add) };
}
let cur_len = unsafe { xmlStrlen(cur) } as usize;
let add_len = unsafe { xmlStrlen(add) } as usize;
let new_size = cur_len + add_len + 1;
let new_ptr = unsafe { xmlRealloc(cur as *mut c_void, new_size) };
if new_ptr.is_null() {
return ptr::null_mut();
}
unsafe {
ptr::copy_nonoverlapping(add as *const u8, (new_ptr as *mut u8).add(cur_len), add_len);
*((new_ptr as *mut u8).add(cur_len + add_len)) = 0;
}
new_ptr as *mut xmlChar
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrncat(
cur: *mut xmlChar,
add: *const xmlChar,
len: c_int,
) -> *mut xmlChar {
if add.is_null() || len <= 0 {
return cur;
}
let len = len as usize;
if cur.is_null() {
return unsafe { xmlStrndup(add, len as c_int) };
}
let cur_len = unsafe { xmlStrlen(cur) } as usize;
let new_size = cur_len + len + 1;
let new_ptr = unsafe { xmlRealloc(cur as *mut c_void, new_size) };
if new_ptr.is_null() {
return ptr::null_mut();
}
unsafe {
ptr::copy_nonoverlapping(add as *const u8, (new_ptr as *mut u8).add(cur_len), len);
*((new_ptr as *mut u8).add(cur_len + len)) = 0;
}
new_ptr as *mut xmlChar
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrncatNew(
str1: *const xmlChar,
str2: *const xmlChar,
len: c_int,
) -> *mut xmlChar {
let mut result: *mut xmlChar = ptr::null_mut();
if !str1.is_null() {
result = unsafe { xmlStrdup(str1) };
}
if !str2.is_null() && len > 0 {
result = unsafe { xmlStrncat(result, str2, len) };
}
result
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrcpy(dst: *mut xmlChar, src: *const xmlChar) -> *mut xmlChar {
if dst.is_null() || src.is_null() {
return dst;
}
let len = unsafe { xmlStrlen(src) } as usize + 1;
unsafe {
ptr::copy_nonoverlapping(src as *const u8, dst as *mut u8, len);
}
dst
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrncpy(
dst: *mut xmlChar,
src: *const xmlChar,
len: c_int,
) -> *mut xmlChar {
if dst.is_null() || src.is_null() || len <= 0 {
return dst;
}
let len = len as usize;
let src_len = unsafe { xmlStrlen(src) } as usize;
let copy_len = if src_len < len { src_len } else { len - 1 };
unsafe {
ptr::copy_nonoverlapping(src as *const u8, dst as *mut u8, copy_len);
*dst.add(copy_len) = 0;
}
dst
}
#[no_mangle]
pub unsafe extern "C" fn xmlStrsub(str: *const xmlChar, start: c_int, len: c_int) -> *mut xmlChar {
if str.is_null() || start < 0 || len < 0 {
return ptr::null_mut();
}
let str_len = unsafe { xmlStrlen(str) };
if start >= str_len {
return unsafe { xmlStrdup(b"\0" as *const u8 as *const xmlChar) };
}
let actual_len = if start + len > str_len {
str_len - start
} else {
len
};
unsafe { xmlStrndup(str.add(start as usize), actual_len) }
}
#[no_mangle]
pub unsafe extern "C" fn xmlNewDoc(version: *const xmlChar) -> *mut _xmlDoc {
crate::xml::tree::new_doc(version)
}
#[no_mangle]
pub unsafe extern "C" fn xmlFreeDoc(doc: *mut _xmlDoc) {
crate::xml::tree::free_doc(doc);
}
#[no_mangle]
pub unsafe extern "C" fn xmlNewNode(ns: *mut _xmlNs, name: *const xmlChar) -> *mut _xmlNode {
crate::xml::tree::new_node(ns, name)
}
#[no_mangle]
pub unsafe extern "C" fn xmlFreeNode(node: *mut _xmlNode) {
crate::xml::tree::free_node(node);
}
#[no_mangle]
pub unsafe extern "C" fn xmlUnlinkNode(node: *mut _xmlNode) {
crate::xml::tree::unlink_node(node);
}
#[no_mangle]
pub unsafe extern "C" fn xmlAddChild(parent: *mut _xmlNode, cur: *mut _xmlNode) -> *mut _xmlNode {
crate::xml::tree::add_child(parent, cur)
}
#[no_mangle]
pub unsafe extern "C" fn xmlAddSibling(
cur: *mut _xmlNode,
sibling: *mut _xmlNode,
) -> *mut _xmlNode {
crate::xml::tree::add_sibling(cur, sibling)
}
#[no_mangle]
pub unsafe extern "C" fn xmlNewChild(
parent: *mut _xmlNode,
ns: *mut _xmlNs,
name: *const xmlChar,
content: *const xmlChar,
) -> *mut _xmlNode {
crate::xml::tree::new_child(parent, ns, name)
}
#[no_mangle]
pub unsafe extern "C" fn xmlDocSetRootElement(
doc: *mut _xmlDoc,
root: *mut _xmlNode,
) -> *mut _xmlNode {
crate::xml::tree::doc_set_root_element(doc, root)
}
#[no_mangle]
pub extern "C" fn xmlDocGetRootElement(doc: *const _xmlDoc) -> *mut _xmlNode {
crate::xml::tree::doc_get_root_element(doc as *mut _xmlDoc)
}
#[no_mangle]
pub unsafe extern "C" fn xmlCopyNode(node: *const _xmlNode, extended: c_int) -> *mut _xmlNode {
crate::xml::tree::copy_node(node, extended)
}
#[no_mangle]
pub unsafe extern "C" fn xmlCopyDoc(doc: *const _xmlDoc, recursive: c_int) -> *mut _xmlDoc {
crate::xml::tree::copy_doc(doc, recursive)
}
#[no_mangle]
pub unsafe extern "C" fn xmlNewText(content: *const xmlChar) -> *mut _xmlNode {
crate::xml::tree::new_text(content)
}
#[no_mangle]
pub unsafe extern "C" fn xmlNewComment(content: *const xmlChar) -> *mut _xmlNode {
crate::xml::tree::new_comment(content)
}
#[no_mangle]
pub unsafe extern "C" fn xmlNewPI(name: *const xmlChar, content: *const xmlChar) -> *mut _xmlNode {
crate::xml::tree::new_pi(name, content)
}
#[no_mangle]
pub unsafe extern "C" fn xmlNewCDataBlock(
doc: *mut _xmlDoc,
content: *const xmlChar,
len: c_int,
) -> *mut _xmlNode {
crate::xml::tree::new_cdata_block(doc, content, len)
}
#[no_mangle]
pub unsafe extern "C" fn xmlNewNs(
node: *mut _xmlNode,
href: *const xmlChar,
prefix: *const xmlChar,
) -> *mut _xmlNs {
crate::xml::tree::new_ns(node, href, prefix)
}
#[no_mangle]
pub unsafe extern "C" fn xmlSetNs(node: *mut _xmlNode, ns: *mut _xmlNs) {
crate::xml::tree::set_ns(node, ns);
}
#[no_mangle]
pub unsafe extern "C" fn xmlGetNsList(
doc: *mut _xmlDoc,
node: *const _xmlNode,
) -> *mut *mut _xmlNs {
crate::xml::tree::get_ns_list(doc, node as *mut _xmlNode)
}
#[no_mangle]
pub unsafe extern "C" fn xmlSearchNs(
doc: *mut _xmlDoc,
node: *mut _xmlNode,
nameSpace: *const xmlChar,
) -> *mut _xmlNs {
crate::xml::tree::search_ns(doc, node, nameSpace)
}
#[no_mangle]
pub unsafe extern "C" fn xmlSearchNsByHref(
doc: *mut _xmlDoc,
node: *mut _xmlNode,
href: *const xmlChar,
) -> *mut _xmlNs {
crate::xml::tree::search_ns_by_href(doc, node, href)
}
#[no_mangle]
pub unsafe extern "C" fn xmlSetProp(
node: *mut _xmlNode,
name: *const xmlChar,
value: *const xmlChar,
) -> *mut _xmlAttr {
crate::xml::tree::set_prop(node, name, value)
}
#[no_mangle]
pub unsafe extern "C" fn xmlGetProp(node: *const _xmlNode, name: *const xmlChar) -> *mut xmlChar {
crate::xml::tree::get_prop(node as *mut _xmlNode, name)
}
#[no_mangle]
pub unsafe extern "C" fn xmlGetNsProp(
node: *const _xmlNode,
name: *const xmlChar,
nameSpace: *const xmlChar,
) -> *mut xmlChar {
crate::xml::tree::get_ns_prop(node as *mut _xmlNode, name, nameSpace)
}
#[no_mangle]
pub unsafe extern "C" fn xmlSetNsProp(
node: *mut _xmlNode,
ns: *mut _xmlNs,
name: *const xmlChar,
value: *const xmlChar,
) -> *mut _xmlAttr {
crate::xml::tree::set_ns_prop(node, ns, name, value)
}
#[no_mangle]
pub unsafe extern "C" fn xmlRemoveProp(attr: *mut _xmlAttr) -> c_int {
crate::xml::tree::remove_prop(attr)
}
#[no_mangle]
pub extern "C" fn xmlGetIntSubset(doc: *const _xmlDoc) -> *mut _xmlDtd {
crate::xml::tree::get_int_subset(doc)
}
#[no_mangle]
pub unsafe extern "C" fn xmlNewDtd(
doc: *mut _xmlDoc,
name: *const xmlChar,
ExternalID: *const xmlChar,
SystemID: *const xmlChar,
) -> *mut _xmlDtd {
crate::xml::tree::new_dtd(doc, name, ExternalID, SystemID)
}
#[no_mangle]
pub unsafe extern "C" fn xmlNewEntity(
doc: *mut _xmlDoc,
name: *const xmlChar,
type_: c_int,
ExternalID: *const xmlChar,
SystemID: *const xmlChar,
content: *const xmlChar,
) -> *mut _xmlEntity {
crate::xml::tree::new_entity(doc, name, type_, ExternalID, SystemID, content)
}
#[no_mangle]
pub unsafe extern "C" fn xmlGetDocEntity(
doc: *const _xmlDoc,
name: *const xmlChar,
) -> *mut _xmlEntity {
crate::xml::tree::get_doc_entity(doc, name)
}
#[no_mangle]
pub unsafe extern "C" fn xmlGetParameterEntity(
doc: *const _xmlDoc,
name: *const xmlChar,
) -> *mut _xmlEntity {
crate::xml::tree::get_parameter_entity(doc, name)
}
#[no_mangle]
pub extern "C" fn xmlGetLineNo(node: *const _xmlNode) -> c_int {
crate::xml::tree::get_line_no(node)
}
#[no_mangle]
pub unsafe extern "C" fn xmlNodeDump(
buf: *mut _xmlBuffer,
doc: *mut _xmlDoc,
cur: *mut _xmlNode,
level: c_int,
format: c_int,
) -> c_int {
if buf.is_null() || cur.is_null() {
return -1;
}
crate::xml::tree::xmlNodeDump(buf, doc, cur, level, format)
}
#[no_mangle]
pub unsafe extern "C" fn xmlDocDump(fp: *mut c_void, doc: *mut _xmlDoc) -> c_int {
if fp.is_null() || doc.is_null() {
return -1;
}
crate::xml::tree::xmlDocDump(fp, doc)
}
#[no_mangle]
pub unsafe extern "C" fn xmlDocDumpFormatMemory(
doc: *mut _xmlDoc,
mem: *mut *mut xmlChar,
size: *mut c_int,
format: c_int,
) {
if doc.is_null() || mem.is_null() || size.is_null() {
return;
}
crate::xml::tree::xmlDocDumpFormatMemory(doc, mem, size, format)
}
#[no_mangle]
pub unsafe extern "C" fn xmlDocDumpMemory(
doc: *mut _xmlDoc,
mem: *mut *mut xmlChar,
size: *mut c_int,
) {
if doc.is_null() || mem.is_null() || size.is_null() {
return;
}
crate::xml::tree::xmlDocDumpMemory(doc, mem, size)
}
#[no_mangle]
pub unsafe extern "C" fn xmlSaveFile(filename: *const c_char, cur: *mut _xmlDoc) -> c_int {
if filename.is_null() || cur.is_null() {
return -1;
}
crate::xml::tree::xmlSaveFile(filename, cur)
}
#[no_mangle]
pub unsafe extern "C" fn xmlSaveFileEnc(
filename: *const c_char,
cur: *mut _xmlDoc,
encoding: *const c_char,
) -> c_int {
if filename.is_null() || cur.is_null() {
return -1;
}
crate::xml::tree::xmlSaveFileEnc(filename, cur, encoding)
}
#[no_mangle]
pub unsafe extern "C" fn xmlSaveFormatFile(
filename: *const c_char,
cur: *mut _xmlDoc,
format: c_int,
) -> c_int {
if filename.is_null() || cur.is_null() {
return -1;
}
crate::xml::tree::xmlSaveFormatFile(filename, cur, format)
}
#[no_mangle]
pub unsafe extern "C" fn xmlSaveFormatFileEnc(
filename: *const c_char,
cur: *mut _xmlDoc,
encoding: *const c_char,
format: c_int,
) -> c_int {
if filename.is_null() || cur.is_null() {
return -1;
}
crate::xml::tree::xmlSaveFormatFileEnc(filename, cur, encoding, format)
}
#[no_mangle]
pub unsafe extern "C" fn xmlReadDoc(
cur: *const xmlChar,
URL: *const c_char,
encoding: *const c_char,
options: c_int,
) -> *mut _xmlDoc {
if cur.is_null() {
return ptr::null_mut();
}
let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
if ctxt.is_null() {
return ptr::null_mut();
}
let len = crate::xml::string::xml_strlen(cur);
let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
crate::xml::parser::helpers::setup_parser_input(ctxt, input);
(*ctxt).options = options;
if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
let doc = (*ctxt).myDoc;
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
return doc;
}
let doc = (*ctxt).myDoc;
if !doc.is_null() {
(*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
}
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
doc
}
#[no_mangle]
pub unsafe extern "C" fn xmlReadFile(
URL: *const c_char,
encoding: *const c_char,
options: c_int,
) -> *mut _xmlDoc {
if URL.is_null() {
return ptr::null_mut();
}
let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
if ctxt.is_null() {
return ptr::null_mut();
}
let input = match crate::xml::parser::helpers::input_from_file(URL) {
Ok(input) => input,
Err(_) => {
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
return ptr::null_mut();
}
};
crate::xml::parser::helpers::setup_parser_input(ctxt, input);
(*ctxt).options = options;
if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
let doc = (*ctxt).myDoc;
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
return doc;
}
let doc = (*ctxt).myDoc;
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
doc
}
#[no_mangle]
pub unsafe extern "C" fn xmlReadMemory(
buffer: *const c_char,
size: c_int,
URL: *const c_char,
encoding: *const c_char,
options: c_int,
) -> *mut _xmlDoc {
if buffer.is_null() || size <= 0 {
return ptr::null_mut();
}
let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
if ctxt.is_null() {
return ptr::null_mut();
}
let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
crate::xml::parser::helpers::setup_parser_input(ctxt, input);
(*ctxt).options = options;
if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
let doc = (*ctxt).myDoc;
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
return doc;
}
let doc = (*ctxt).myDoc;
if !doc.is_null() && !URL.is_null() {
(*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
}
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
doc
}
#[no_mangle]
pub unsafe extern "C" fn xmlReadFd(
fd: c_int,
URL: *const c_char,
encoding: *const c_char,
options: c_int,
) -> *mut _xmlDoc {
let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
if ctxt.is_null() {
return ptr::null_mut();
}
let mut buf = Vec::new();
let mut tmp = [0u8; 4096];
loop {
let n = libc::read(fd, tmp.as_mut_ptr() as *mut c_void, tmp.len());
if n <= 0 {
break;
}
buf.extend_from_slice(&tmp[..n as usize]);
}
let input = crate::xml::parser::helpers::input_from_memory(
buf.as_ptr() as *const c_char,
buf.len() as c_int,
);
crate::xml::parser::helpers::setup_parser_input(ctxt, input);
(*ctxt).options = options;
if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
let doc = (*ctxt).myDoc;
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
return doc;
}
let doc = (*ctxt).myDoc;
if !doc.is_null() && !URL.is_null() {
(*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
}
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
doc
}
#[no_mangle]
pub unsafe extern "C" fn xmlReadIO(
ioread: Option<xmlInputReadCallback>,
ioclose: Option<xmlInputCloseCallback>,
ioctx: *mut c_void,
URL: *const c_char,
encoding: *const c_char,
options: c_int,
) -> *mut _xmlDoc {
let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
if ctxt.is_null() {
return ptr::null_mut();
}
let input = crate::xml::parser::helpers::input_from_io(ioread, ioclose, ioctx);
crate::xml::parser::helpers::setup_parser_input(ctxt, input);
(*ctxt).options = options;
if crate::xml::parser::helpers::parse_document(ctxt) != 0 {
let doc = (*ctxt).myDoc;
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
return doc;
}
let doc = (*ctxt).myDoc;
if !doc.is_null() && !URL.is_null() {
(*doc).URL = crate::xml::string::xml_strdup(URL as *const xmlChar);
}
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
doc
}
#[no_mangle]
pub unsafe extern "C" fn xmlSAXParseDoc(
sax: *mut _xmlSAXHandler,
cur: *const xmlChar,
recovery: c_int,
) -> *mut _xmlDoc {
if cur.is_null() {
return ptr::null_mut();
}
let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
if ctxt.is_null() {
return ptr::null_mut();
}
if !sax.is_null() {
(*ctxt).sax = sax;
(*ctxt).userData = (*ctxt).sax as *mut c_void;
}
if recovery != 0 {
(*ctxt).recovery = 1;
(*ctxt).options |= 1; }
let len = crate::xml::string::xml_strlen(cur);
let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
crate::xml::parser::helpers::setup_parser_input(ctxt, input);
crate::xml::parser::helpers::parse_document(ctxt);
let doc = (*ctxt).myDoc;
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
doc
}
#[no_mangle]
pub unsafe extern "C" fn xmlSAXParseFile(
sax: *mut _xmlSAXHandler,
filename: *const c_char,
recovery: c_int,
) -> *mut _xmlDoc {
if filename.is_null() {
return ptr::null_mut();
}
let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
if ctxt.is_null() {
return ptr::null_mut();
}
if !sax.is_null() {
(*ctxt).sax = sax;
(*ctxt).userData = (*ctxt).sax as *mut c_void;
}
if recovery != 0 {
(*ctxt).recovery = 1;
(*ctxt).options |= 1;
}
let input = match crate::xml::parser::helpers::input_from_file(filename) {
Ok(input) => input,
Err(_) => {
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
return ptr::null_mut();
}
};
crate::xml::parser::helpers::setup_parser_input(ctxt, input);
crate::xml::parser::helpers::parse_document(ctxt);
let doc = (*ctxt).myDoc;
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
doc
}
#[no_mangle]
pub unsafe extern "C" fn xmlSAXParseMemory(
sax: *mut _xmlSAXHandler,
buffer: *const c_char,
size: c_int,
recovery: c_int,
) -> *mut _xmlDoc {
if buffer.is_null() || size <= 0 {
return ptr::null_mut();
}
let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
if ctxt.is_null() {
return ptr::null_mut();
}
if !sax.is_null() {
(*ctxt).sax = sax;
(*ctxt).userData = (*ctxt).sax as *mut c_void;
}
if recovery != 0 {
(*ctxt).recovery = 1;
(*ctxt).options |= 1;
}
let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
crate::xml::parser::helpers::setup_parser_input(ctxt, input);
crate::xml::parser::helpers::parse_document(ctxt);
let doc = (*ctxt).myDoc;
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
doc
}
#[no_mangle]
pub unsafe extern "C" fn xmlSAXUserParseFile(
sax: *mut _xmlSAXHandler,
user_data: *mut c_void,
filename: *const c_char,
) -> c_int {
if filename.is_null() {
return -1;
}
let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
if ctxt.is_null() {
return -1;
}
if !sax.is_null() {
(*ctxt).sax = sax;
}
(*ctxt).userData = if !user_data.is_null() {
user_data
} else {
ctxt as *mut c_void
};
let input = match crate::xml::parser::helpers::input_from_file(filename) {
Ok(input) => input,
Err(_) => {
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
return -1;
}
};
crate::xml::parser::helpers::setup_parser_input(ctxt, input);
let ret = crate::xml::parser::helpers::parse_document(ctxt);
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
ret
}
#[no_mangle]
pub unsafe extern "C" fn xmlSAXUserParseMemory(
sax: *mut _xmlSAXHandler,
user_data: *mut c_void,
buffer: *const c_char,
size: c_int,
) -> c_int {
if buffer.is_null() || size <= 0 {
return -1;
}
let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
if ctxt.is_null() {
return -1;
}
if !sax.is_null() {
(*ctxt).sax = sax;
}
(*ctxt).userData = if !user_data.is_null() {
user_data
} else {
ctxt as *mut c_void
};
let input = crate::xml::parser::helpers::input_from_memory(buffer, size);
crate::xml::parser::helpers::setup_parser_input(ctxt, input);
let ret = crate::xml::parser::helpers::parse_document(ctxt);
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
ret
}
#[no_mangle]
pub unsafe extern "C" fn xmlParseDoc(cur: *const xmlChar) -> *mut _xmlDoc {
if cur.is_null() {
return ptr::null_mut();
}
xmlReadDoc(cur, ptr::null(), ptr::null(), 0)
}
#[no_mangle]
pub unsafe extern "C" fn xmlParseFile(filename: *const c_char) -> *mut _xmlDoc {
if filename.is_null() {
return ptr::null_mut();
}
xmlReadFile(filename, ptr::null(), 0)
}
#[no_mangle]
pub unsafe extern "C" fn xmlParseMemory(buffer: *const c_char, size: c_int) -> *mut _xmlDoc {
if buffer.is_null() || size <= 0 {
return ptr::null_mut();
}
xmlReadMemory(buffer, size, ptr::null(), ptr::null(), 0)
}
#[no_mangle]
pub unsafe extern "C" fn xmlCreateFileParserCtxt(filename: *const c_char) -> *mut _xmlParserCtxt {
if filename.is_null() {
return ptr::null_mut();
}
let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
if ctxt.is_null() {
return ptr::null_mut();
}
let input = match crate::xml::parser::helpers::input_from_file(filename) {
Ok(input) => input,
Err(_) => {
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
return ptr::null_mut();
}
};
crate::xml::parser::helpers::setup_parser_input(ctxt, input);
ctxt
}
#[no_mangle]
pub unsafe extern "C" fn xmlCreateDocParserCtxt(cur: *const xmlChar) -> *mut _xmlParserCtxt {
if cur.is_null() {
return ptr::null_mut();
}
let ctxt = crate::xml::parser::helpers::create_parser_ctxt();
if ctxt.is_null() {
return ptr::null_mut();
}
let len = crate::xml::string::xml_strlen(cur);
let input = crate::xml::parser::helpers::input_from_memory(cur as *const c_char, len as c_int);
crate::xml::parser::helpers::setup_parser_input(ctxt, input);
ctxt
}
#[no_mangle]
pub unsafe extern "C" fn xmlParseDocument(ctxt: *mut _xmlParserCtxt) -> c_int {
if ctxt.is_null() {
return -1;
}
crate::xml::parser::helpers::parse_document(ctxt)
}
#[no_mangle]
pub unsafe extern "C" fn xmlFreeParserCtxt(ctxt: *mut _xmlParserCtxt) {
if ctxt.is_null() {
return;
}
crate::xml::parser::helpers::free_parser_ctxt(ctxt);
}
#[no_mangle]
pub unsafe extern "C" fn xmlCtxtUseOptions(ctxt: *mut _xmlParserCtxt, options: c_int) -> c_int {
if ctxt.is_null() {
return -1;
}
unsafe {
(*ctxt).options = options;
}
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlParseChunk(
ctxt: *mut _xmlParserCtxt,
chunk: *const c_char,
size: c_int,
terminate: c_int,
) -> c_int {
if ctxt.is_null() {
return -1;
}
crate::xml::parser::helpers::parse_chunk(ctxt, chunk, size, terminate)
}
#[no_mangle]
pub unsafe extern "C" fn xmlParserInputBufferCreateMem(
buffer: *const c_char,
size: c_int,
enc: c_int,
) -> *mut _xmlParserInputBuffer {
if buffer.is_null() || size <= 0 {
return ptr::null_mut();
}
crate::xml::parser::helpers::alloc_parser_input_buffer()
}
#[no_mangle]
pub unsafe extern "C" fn xmlParserInputBufferCreateFilename(
URI: *const c_char,
enc: c_int,
) -> *mut _xmlParserInputBuffer {
if URI.is_null() {
return ptr::null_mut();
}
crate::xml::parser::helpers::alloc_parser_input_buffer()
}
#[no_mangle]
pub unsafe extern "C" fn xmlParserInputBufferCreateIO(
ioread: Option<xmlInputReadCallback>,
ioclose: Option<xmlInputCloseCallback>,
ioctx: *mut c_void,
enc: c_int,
) -> *mut _xmlParserInputBuffer {
let buf = crate::xml::parser::helpers::alloc_parser_input_buffer();
if !buf.is_null() {
(*buf).readcallback = ioread;
(*buf).closecallback = ioclose;
(*buf).context = ioctx;
}
buf
}
#[no_mangle]
pub unsafe extern "C" fn xmlFreeParserInputBuffer(buf: *mut _xmlParserInputBuffer) {
if buf.is_null() {
return;
}
crate::xml::parser::helpers::free_parser_input_buffer(buf);
}
#[no_mangle]
pub unsafe extern "C" fn xmlNewInputFromFile(
ctxt: *mut _xmlParserCtxt,
filename: *const c_char,
) -> *mut _xmlParserInput {
if filename.is_null() {
return ptr::null_mut();
}
crate::xml::parser::helpers::alloc_parser_input_buffer() as *mut _xmlParserInput
}
#[no_mangle]
pub unsafe extern "C" fn xmlFreeInputStream(input: *mut _xmlParserInput) {
if input.is_null() {
return;
}
crate::xml::parser::helpers::free_parser_input(input);
}
#[no_mangle]
pub unsafe extern "C" fn xmlOutputBufferCreateFilename(
URI: *const c_char,
encoder: *mut c_void,
compression: c_int,
) -> *mut _xmlOutputBuffer {
let _ = compression;
if URI.is_null() {
return ptr::null_mut();
}
crate::xml::io::output_buffer_create_filename(
URI,
encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
0,
)
}
#[no_mangle]
pub unsafe extern "C" fn xmlOutputBufferCreateFd(
fd: c_int,
encoder: *mut c_void,
) -> *mut _xmlOutputBuffer {
if fd < 0 {
return ptr::null_mut();
}
crate::xml::io::output_buffer_create_fd(
fd,
encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
)
}
#[no_mangle]
pub unsafe extern "C" fn xmlOutputBufferCreateIO(
iowrite: Option<xmlOutputWriteCallback>,
ioclose: Option<xmlOutputCloseCallback>,
ioctx: *mut c_void,
encoder: *mut c_void,
) -> *mut _xmlOutputBuffer {
crate::xml::io::output_buffer_create_io(
iowrite,
ioclose,
ioctx,
encoder as *mut crate::abi::structs::_xmlCharEncodingHandler,
)
}
#[no_mangle]
pub unsafe extern "C" fn xmlOutputBufferClose(out: *mut _xmlOutputBuffer) -> c_int {
if out.is_null() {
return -1;
}
crate::xml::io::output_buffer_close(out)
}
#[no_mangle]
pub unsafe extern "C" fn xmlOutputBufferFlush(out: *mut _xmlOutputBuffer) -> c_int {
if out.is_null() {
return -1;
}
crate::xml::io::output_buffer_flush(out)
}
#[no_mangle]
pub unsafe extern "C" fn xmlOutputBufferWrite(
out: *mut _xmlOutputBuffer,
len: c_int,
data: *const c_char,
) -> c_int {
if out.is_null() || data.is_null() || len <= 0 {
return -1;
}
crate::xml::io::output_buffer_write(out, len, data)
}
#[no_mangle]
pub unsafe extern "C" fn xmlOutputBufferWriteString(
out: *mut _xmlOutputBuffer,
str: *const c_char,
) -> c_int {
if str.is_null() {
return 0;
}
unsafe { xmlOutputBufferWrite(out, xmlStrlen(str as *const xmlChar), str) }
}
#[no_mangle]
pub extern "C" fn xmlDictCreate() -> *mut c_void {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlDictCreateSub(_sub: *mut c_void) -> *mut c_void {
ptr::null_mut()
}
#[no_mangle]
pub unsafe extern "C" fn xmlDictLookup(
dict: *mut c_void,
name: *const xmlChar,
len: c_int,
) -> *const xmlChar {
name
}
#[no_mangle]
pub unsafe extern "C" fn xmlDictExists(
dict: *mut c_void,
name: *const xmlChar,
len: c_int,
) -> *const xmlChar {
ptr::null()
}
#[no_mangle]
pub extern "C" fn xmlDictSize(dict: *const c_void) -> c_uint {
0
}
#[no_mangle]
pub extern "C" fn xmlDictFree(_dict: *mut c_void) {
}
#[no_mangle]
pub extern "C" fn xmlDictSetLimit(_dict: *mut c_void, _limit: c_uint) -> c_uint {
0
}
#[no_mangle]
pub extern "C" fn xmlDictGetUsage(_dict: *const c_void) -> c_uint {
0
}
#[no_mangle]
pub extern "C" fn xmlHashCreate(_size: c_int) -> *mut c_void {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlHashCreateDict(_size: c_int, _dict: *mut c_void) -> *mut c_void {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlHashFree(
_table: *mut c_void,
_f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
) {
}
#[no_mangle]
pub unsafe extern "C" fn xmlHashAddEntry(
_table: *mut c_void,
_name: *const xmlChar,
_userdata: *mut c_void,
) -> c_int {
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlHashAddEntry2(
_table: *mut c_void,
_name: *const xmlChar,
_name2: *const xmlChar,
_userdata: *mut c_void,
) -> c_int {
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlHashAddEntry3(
_table: *mut c_void,
_name: *const xmlChar,
_name2: *const xmlChar,
_name3: *const xmlChar,
_userdata: *mut c_void,
) -> c_int {
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlHashUpdateEntry(
_table: *mut c_void,
_name: *const xmlChar,
_userdata: *mut c_void,
_f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
) -> c_int {
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlHashUpdateEntry2(
_table: *mut c_void,
_name: *const xmlChar,
_name2: *const xmlChar,
_userdata: *mut c_void,
_f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
) -> c_int {
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlHashUpdateEntry3(
_table: *mut c_void,
_name: *const xmlChar,
_name2: *const xmlChar,
_name3: *const xmlChar,
_userdata: *mut c_void,
_f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
) -> c_int {
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlHashLookup(_table: *mut c_void, _name: *const xmlChar) -> *mut c_void {
ptr::null_mut()
}
#[no_mangle]
pub unsafe extern "C" fn xmlHashLookup2(
_table: *mut c_void,
_name: *const xmlChar,
_name2: *const xmlChar,
) -> *mut c_void {
ptr::null_mut()
}
#[no_mangle]
pub unsafe extern "C" fn xmlHashLookup3(
_table: *mut c_void,
_name: *const xmlChar,
_name2: *const xmlChar,
_name3: *const xmlChar,
) -> *mut c_void {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlHashSize(_table: *mut c_void) -> c_int {
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlHashRemoveEntry(
_table: *mut c_void,
_name: *const xmlChar,
_f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
) -> c_int {
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlHashRemoveEntry2(
_table: *mut c_void,
_name: *const xmlChar,
_name2: *const xmlChar,
_f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
) -> c_int {
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlHashRemoveEntry3(
_table: *mut c_void,
_name: *const xmlChar,
_name2: *const xmlChar,
_name3: *const xmlChar,
_f: Option<unsafe extern "C" fn(*mut c_void, *mut xmlChar)>,
) -> c_int {
0
}
#[no_mangle]
pub extern "C" fn xmlHashScan(
_table: *mut c_void,
_f: Option<unsafe extern "C" fn(*mut c_void, *const xmlChar, *mut c_void)>,
_data: *mut c_void,
) {
}
#[no_mangle]
pub extern "C" fn xmlHashScanFull(
_table: *mut c_void,
_f: Option<unsafe extern "C" fn(*mut c_void, *const xmlChar, *mut c_void, *mut c_void)>,
_data: *mut c_void,
) {
}
#[no_mangle]
pub extern "C" fn xmlHashCopy(
_table: *mut c_void,
_f: Option<unsafe extern "C" fn(*mut c_void, *const xmlChar) -> *mut c_void>,
) -> *mut c_void {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlListCreate(
_deallocator: Option<unsafe extern "C" fn(*mut c_void)>,
_compare: Option<unsafe extern "C" fn(*const c_void, *const c_void) -> c_int>,
) -> *mut c_void {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlListDelete(_list: *mut c_void) {
}
#[no_mangle]
pub extern "C" fn xmlListSearch(_list: *mut c_void, _data: *mut c_void) -> *mut c_void {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlListWalk(
_list: *mut c_void,
_walker: Option<unsafe extern "C" fn(*mut c_void, *mut c_void) -> c_int>,
_data: *mut c_void,
) {
}
#[no_mangle]
pub extern "C" fn xmlListPushBack(_list: *mut c_void, _data: *mut c_void) -> c_int {
0
}
#[no_mangle]
pub extern "C" fn xmlListPushFront(_list: *mut c_void, _data: *mut c_void) -> c_int {
0
}
#[no_mangle]
pub extern "C" fn xmlListPopBack(_list: *mut c_void) {
}
#[no_mangle]
pub extern "C" fn xmlListPopFront(_list: *mut c_void) {
}
#[no_mangle]
pub extern "C" fn xmlListInsert(_list: *mut c_void, _data: *mut c_void) -> c_int {
0
}
#[no_mangle]
pub extern "C" fn xmlListAppend(_list: *mut c_void, _data: *mut c_void) -> c_int {
0
}
#[no_mangle]
pub extern "C" fn xmlListRemoveFirst(_list: *mut c_void, _data: *mut c_void) -> c_int {
0
}
#[no_mangle]
pub extern "C" fn xmlListRemoveLast(_list: *mut c_void, _data: *mut c_void) -> c_int {
0
}
#[no_mangle]
pub extern "C" fn xmlListRemoveAll(_list: *mut c_void, _data: *mut c_void) -> c_int {
0
}
#[no_mangle]
pub extern "C" fn xmlListClear(_list: *mut c_void) {
}
#[no_mangle]
pub extern "C" fn xmlListEmpty(_list: *mut c_void) -> c_int {
1
}
#[no_mangle]
pub extern "C" fn xmlListFront(_list: *mut c_void) -> *mut c_void {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlListBack(_list: *mut c_void) -> *mut c_void {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlListSize(_list: *mut c_void) -> c_int {
0
}
#[no_mangle]
pub extern "C" fn xmlListSort(_list: *mut c_void) {
}
#[no_mangle]
pub extern "C" fn xmlListReverse(_list: *mut c_void) {
}
#[no_mangle]
pub extern "C" fn xmlListReverseSplice(_list: *mut c_void, _list2: *mut c_void) {
}
#[no_mangle]
pub extern "C" fn xmlListMerge(_list: *mut c_void, _list2: *mut c_void) {
}
#[no_mangle]
pub extern "C" fn xmlBufferCreate() -> *mut _xmlBuffer {
crate::xml::io::buf_create(-1)
}
#[no_mangle]
pub extern "C" fn xmlBufferCreateSize(size: usize) -> *mut _xmlBuffer {
crate::xml::io::buf_create(size as c_int)
}
#[no_mangle]
pub extern "C" fn xmlBufferCreateStatic(mem: *mut c_void, size: usize) -> *mut _xmlBuffer {
if mem.is_null() || size == 0 {
return ptr::null_mut();
}
crate::xml::io::buf_create_static(mem as *const xmlChar, size as c_int)
}
#[no_mangle]
pub extern "C" fn xmlBufferFree(buf: *mut _xmlBuffer) {
crate::xml::io::buf_free(buf)
}
#[no_mangle]
pub extern "C" fn xmlBufferEmpty(buf: *mut _xmlBuffer) {
if buf.is_null() {
return;
}
unsafe {
if !(*buf).content.is_null() {
*(*buf).content = 0;
}
(*buf).use_ = 0;
}
}
#[no_mangle]
pub extern "C" fn xmlBufferContent(buf: *const _xmlBuffer) -> *mut xmlChar {
crate::xml::io::buf_content(buf as *mut _xmlBuffer)
}
#[no_mangle]
pub extern "C" fn xmlBufferLength(buf: *const _xmlBuffer) -> c_int {
crate::xml::io::buf_length(buf as *mut _xmlBuffer)
}
#[no_mangle]
pub unsafe extern "C" fn xmlBufferAdd(
buf: *mut _xmlBuffer,
str: *const xmlChar,
len: c_int,
) -> c_int {
crate::xml::io::buf_add(buf, str, len)
}
#[no_mangle]
pub unsafe extern "C" fn xmlBufferAddHead(
buf: *mut _xmlBuffer,
str: *const xmlChar,
len: c_int,
) -> c_int {
crate::xml::io::buf_add_head(buf, str, len)
}
#[no_mangle]
pub unsafe extern "C" fn xmlBufferCat(buf: *mut _xmlBuffer, str: *const xmlChar) -> c_int {
if str.is_null() {
return -1;
}
let len = crate::xml::string::xml_strlen(str) as c_int;
crate::xml::io::buf_add(buf, str, len)
}
#[no_mangle]
pub extern "C" fn xmlBufferSetAllocationScheme(buf: *mut _xmlBuffer, scheme: c_int) {
if buf.is_null() {
return;
}
unsafe {
(*buf).alloc = scheme;
}
}
#[no_mangle]
pub extern "C" fn xmlBufferShrink(buf: *mut _xmlBuffer, len: c_int) -> c_int {
if buf.is_null() || len <= 0 {
return 0;
}
unsafe {
let b = &mut *buf;
let shrink_len = (len as c_uint).min(b.use_);
if shrink_len > 0 {
let remaining = b.use_ - shrink_len;
if remaining > 0 {
core::ptr::copy(
b.content.add(shrink_len as usize),
b.content,
remaining as usize,
);
}
*b.content.add(remaining as usize) = 0;
b.use_ = remaining;
}
}
len
}
#[no_mangle]
pub extern "C" fn xmlBufferGrow(buf: *mut _xmlBuffer, len: c_int) -> c_int {
if buf.is_null() || len <= 0 {
return 0;
}
let cur_use = unsafe { (*buf).use_ };
let new_size = cur_use + len as c_uint + 1;
crate::xml::io::buf_grow(buf, new_size)
}
#[no_mangle]
pub extern "C" fn xmlBufferReserve(buf: *mut _xmlBuffer, len: c_int) -> c_int {
xmlBufferGrow(buf, len)
}
#[no_mangle]
pub extern "C" fn xmlBufferDetach(buf: *mut _xmlBuffer) -> *mut xmlChar {
if buf.is_null() {
return ptr::null_mut();
}
unsafe {
let content = (*buf).content;
(*buf).content = ptr::null_mut();
(*buf).use_ = 0;
(*buf).size = 0;
content
}
}
#[no_mangle]
pub extern "C" fn xmlGetCharEncoding(name: *const c_char) -> c_int {
if name.is_null() {
return 0; }
let name_bytes = unsafe {
let len = libc::strlen(name);
core::slice::from_raw_parts(name as *const u8, len)
};
crate::xml::encoding::encoding_from_name(name_bytes) as c_int
}
#[no_mangle]
pub extern "C" fn xmlFindCharEncodingHandler(name: *const c_char) -> *mut c_void {
if name.is_null() {
return ptr::null_mut();
}
crate::xml::encoding::find_encoding_handler(name as *const xmlChar) as *mut c_void
}
#[no_mangle]
pub extern "C" fn xmlCharEncCloseFunc(handler: *mut c_void) -> c_int {
if handler.is_null() {
return -1;
}
unsafe {
let h = handler as *mut crate::abi::structs::_xmlCharEncodingHandler;
if !(*h).name.is_null() {
crate::abi::allocator::xmlFree((*h).name as *mut c_void);
}
crate::abi::allocator::xmlFree(handler);
}
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlCharEncInput(input: *mut _xmlParserInputBuffer, _to: c_int) -> c_int {
if input.is_null() {
return -1;
}
let handler = (*input).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
if handler.is_null() {
return -1;
}
let raw = (*input).raw as *mut crate::abi::structs::_xmlBuffer;
let buf = (*input).buffer as *mut crate::abi::structs::_xmlBuffer;
if raw.is_null() || buf.is_null() {
return -1;
}
crate::xml::encoding::char_enc_in(handler, buf, raw)
}
#[no_mangle]
pub unsafe extern "C" fn xmlCharEncOutput(output: *mut _xmlOutputBuffer, _to: c_int) -> c_int {
if output.is_null() {
return -1;
}
let handler = (*output).encoder as *mut crate::abi::structs::_xmlCharEncodingHandler;
if handler.is_null() {
return -1;
}
let buf = (*output).buffer as *mut crate::abi::structs::_xmlBuffer;
let conv = (*output).conv as *mut crate::abi::structs::_xmlBuffer;
if buf.is_null() || conv.is_null() {
return -1;
}
crate::xml::encoding::char_enc_out(handler, conv, buf)
}
#[no_mangle]
pub unsafe extern "C" fn xmlParseURI(str: *const c_char) -> *mut c_void {
crate::xml::uri::xmlParseURI(str)
}
#[no_mangle]
pub unsafe extern "C" fn xmlParseURIRaw(str: *const c_char, raw: c_int) -> *mut c_void {
let _ = raw;
crate::xml::uri::xmlParseURI(str)
}
#[no_mangle]
pub unsafe extern "C" fn xmlFreeURI(uri: *mut c_void) {
crate::xml::uri::xmlFreeURI(uri)
}
#[no_mangle]
pub extern "C" fn xmlCreateURI() -> *mut c_void {
crate::xml::uri::xmlCreateURI()
}
#[no_mangle]
pub unsafe extern "C" fn xmlSaveUri(uri: *mut c_void) -> *mut xmlChar {
crate::xml::uri::xmlSaveUri(uri)
}
#[no_mangle]
pub unsafe extern "C" fn xmlURIEscapeStr(
str: *const xmlChar,
list: *const xmlChar,
) -> *mut xmlChar {
crate::xml::uri::xmlURIEscapeStr(str, list)
}
#[no_mangle]
pub unsafe extern "C" fn xmlURIUnescapeString(
str: *const c_char,
len: c_int,
target: *mut c_char,
) -> *mut c_char {
crate::xml::uri::xmlURIUnescapeString(str, len, target)
}
#[no_mangle]
pub unsafe extern "C" fn xmlXPathNewContext(_doc: *mut _xmlDoc) -> *mut _xmlXPathContext {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlXPathFreeContext(_ctxt: *mut _xmlXPathContext) {
}
#[no_mangle]
pub unsafe extern "C" fn xmlXPathEvalExpression(
_str: *const xmlChar,
_ctxt: *mut _xmlXPathContext,
) -> *mut _xmlXPathObject {
ptr::null_mut()
}
#[no_mangle]
pub unsafe extern "C" fn xmlXPathEval(
_str: *const xmlChar,
_ctxt: *mut _xmlXPathContext,
) -> *mut _xmlXPathObject {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlXPathFreeObject(_obj: *mut _xmlXPathObject) {
}
#[no_mangle]
pub unsafe extern "C" fn xmlXPathCompile(_str: *const xmlChar) -> *mut c_void {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlXPathFreeCompExpr(_comp: *mut c_void) {
}
#[no_mangle]
pub unsafe extern "C" fn xmlXPathRegisterNs(
_ctxt: *mut _xmlXPathContext,
_prefix: *const xmlChar,
_ns_uri: *const xmlChar,
) -> c_int {
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlXPathRegisterFunc(
_ctxt: *mut _xmlXPathContext,
_name: *const xmlChar,
_f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
) -> c_int {
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlXPathRegisterFuncNS(
_ctxt: *mut _xmlXPathContext,
_name: *const xmlChar,
_ns_uri: *const xmlChar,
_f: Option<unsafe extern "C" fn(*mut c_void, c_int)>,
) -> c_int {
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlXPathRegisterVariable(
_ctxt: *mut _xmlXPathContext,
_name: *const xmlChar,
_value: *mut _xmlXPathObject,
) -> c_int {
0
}
#[no_mangle]
pub unsafe extern "C" fn xmlXPathNewNodeSet(_val: *mut _xmlNode) -> *mut _xmlXPathObject {
ptr::null_mut()
}
#[no_mangle]
pub unsafe extern "C" fn xmlXPathNewCString(_val: *const xmlChar) -> *mut _xmlXPathObject {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlXPathNewFloat(_val: f64) -> *mut _xmlXPathObject {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlXPathNewBoolean(_val: c_int) -> *mut _xmlXPathObject {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlXIncludeProcess(_doc: *mut _xmlDoc) -> c_int {
-1
}
#[no_mangle]
pub extern "C" fn xmlXIncludeProcessFlags(_doc: *mut _xmlDoc, _flags: c_int) -> c_int {
-1
}
#[no_mangle]
pub extern "C" fn xmlCatalogLoad(catalogs: *const c_char) -> *mut c_void {
if catalogs.is_null() {
return ptr::null_mut();
}
crate::xml::catalog::load_catalog(catalogs)
}
#[no_mangle]
pub unsafe extern "C" fn xmlCatalogResolvePublic(pubID: *const xmlChar) -> *mut xmlChar {
if pubID.is_null() {
return ptr::null_mut();
}
crate::xml::catalog::resolve_public(pubID)
}
#[no_mangle]
pub unsafe extern "C" fn xmlCatalogResolveSystem(sysID: *const xmlChar) -> *mut xmlChar {
if sysID.is_null() {
return ptr::null_mut();
}
crate::xml::catalog::resolve_system(sysID)
}
#[no_mangle]
pub unsafe extern "C" fn xmlCatalogResolveURI(URI: *const xmlChar) -> *mut xmlChar {
if URI.is_null() {
return ptr::null_mut();
}
crate::xml::catalog::resolve_uri(URI)
}
#[no_mangle]
pub extern "C" fn xmlCatalogSetDefaults(allow: c_int) {
crate::xml::catalog::set_defaults(allow)
}
#[no_mangle]
pub extern "C" fn xmlCatalogGetDefaults() -> c_int {
crate::xml::catalog::get_defaults()
}
#[no_mangle]
pub unsafe extern "C" fn xmlCatalogAdd(
type_: *const xmlChar,
orig: *const xmlChar,
replace: *const xmlChar,
) -> c_int {
if type_.is_null() || orig.is_null() || replace.is_null() {
return -1;
}
crate::xml::catalog::add(type_, orig, replace)
}
#[no_mangle]
pub unsafe extern "C" fn xmlCatalogRemove(value: *const xmlChar) -> c_int {
if value.is_null() {
return 0;
}
crate::xml::catalog::remove(value)
}
#[no_mangle]
pub extern "C" fn xmlCatalogCleanup() {
crate::xml::catalog::cleanup();
}
#[no_mangle]
pub extern "C" fn xmlCatalogConvert() -> *mut _xmlDoc {
unsafe { crate::xml::catalog::convert() }
}
#[no_mangle]
pub unsafe extern "C" fn htmlParseFile(
_filename: *const c_char,
_encoding: *const c_char,
) -> *mut _xmlDoc {
ptr::null_mut()
}
#[no_mangle]
pub unsafe extern "C" fn htmlParseMemory(_buffer: *const c_char, _size: c_int) -> *mut _xmlDoc {
ptr::null_mut()
}
#[no_mangle]
pub unsafe extern "C" fn htmlParseDoc(
_cur: *const xmlChar,
_encoding: *const c_char,
) -> *mut _xmlDoc {
ptr::null_mut()
}
#[no_mangle]
pub unsafe extern "C" fn htmlCreateFileParserCtxt(
_filename: *const c_char,
_encoding: *const c_char,
) -> *mut c_void {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn htmlFreeParserCtxt(_ctxt: *mut c_void) {
}
#[no_mangle]
pub extern "C" fn htmlInitParser() {
}
#[no_mangle]
pub extern "C" fn htmlCleanupParser() {
}
#[no_mangle]
pub unsafe extern "C" fn xmlDebugDumpDocument(_output: *mut c_void, _doc: *mut _xmlDoc) {
}
#[no_mangle]
pub unsafe extern "C" fn xmlDebugDumpNode(_output: *mut c_void, _node: *mut _xmlNode) {
}
#[no_mangle]
pub unsafe extern "C" fn xmlDebugDumpNodeList(_output: *mut c_void, _node: *mut _xmlNode) {
}
#[no_mangle]
pub extern "C" fn xmlGetBinaryPath() -> *mut c_char {
ptr::null_mut()
}
#[no_mangle]
pub extern "C" fn xmlGetHomeOfBinary() -> *mut c_char {
ptr::null_mut()
}