|
| 1 | +// Copyright 2023 The Servo Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution. |
| 3 | +// |
| 4 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 5 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 6 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 7 | +// option. This file may not be copied, modified, or distributed |
| 8 | +// except according to those terms. |
| 9 | + |
| 10 | +use std::os::raw::c_void; |
| 11 | + |
| 12 | +use base::{CFOptionFlags, CFIndex, Boolean, CFAllocatorRef, CFTypeID}; |
| 13 | +use xml_node::{CFXMLNodeRef, CFXMLTreeRef, CFXMLExternalID}; |
| 14 | +use data::CFDataRef; |
| 15 | +use string::CFStringRef; |
| 16 | +use url::CFURLRef; |
| 17 | +use dictionary::CFDictionaryRef; |
| 18 | + |
| 19 | +#[repr(C)] |
| 20 | +pub struct __CFXMLParser(c_void); |
| 21 | + |
| 22 | +pub type CFXMLParserRef = *mut __CFXMLParser; |
| 23 | + |
| 24 | +pub type CFXMLParserOptions = CFOptionFlags; |
| 25 | +pub const kCFXMLParserValidateDocument: CFXMLParserOptions = 1 << 0; |
| 26 | +pub const kCFXMLParserSkipMetaData: CFXMLParserOptions = 1 << 1; |
| 27 | +pub const kCFXMLParserReplacePhysicalEntities: CFXMLParserOptions = 1 << 2; |
| 28 | +pub const kCFXMLParserSkipWhitespace: CFXMLParserOptions = 1 << 3; |
| 29 | +pub const kCFXMLParserResolveExternalEntities: CFXMLParserOptions = 1 << 4; |
| 30 | +pub const kCFXMLParserAddImpliedAttributes: CFXMLParserOptions = 1 << 5; |
| 31 | +pub const kCFXMLParserAllOptions: CFXMLParserOptions = 0x00FFFFFF; |
| 32 | +pub const kCFXMLParserNoOptions: CFXMLParserOptions = 0; |
| 33 | + |
| 34 | +pub type CFXMLParserStatusCode = CFIndex; |
| 35 | +pub const kCFXMLStatusParseNotBegun: CFIndex = -2; |
| 36 | +pub const kCFXMLStatusParseInProgress: CFIndex = -1; |
| 37 | +pub const kCFXMLStatusParseSuccessful: CFIndex = 0; |
| 38 | +pub const kCFXMLErrorUnexpectedEOF: CFIndex = 1; |
| 39 | +pub const kCFXMLErrorUnknownEncoding: CFIndex = 2; |
| 40 | +pub const kCFXMLErrorEncodingConversionFailure: CFIndex = 3; |
| 41 | +pub const kCFXMLErrorMalformedProcessingInstruction: CFIndex = 4; |
| 42 | +pub const kCFXMLErrorMalformedDTD: CFIndex = 5; |
| 43 | +pub const kCFXMLErrorMalformedName: CFIndex = 6; |
| 44 | +pub const kCFXMLErrorMalformedCDSect: CFIndex = 7; |
| 45 | +pub const kCFXMLErrorMalformedCloseTag: CFIndex = 8; |
| 46 | +pub const kCFXMLErrorMalformedStartTag: CFIndex = 9; |
| 47 | +pub const kCFXMLErrorMalformedDocument: CFIndex = 10; |
| 48 | +pub const kCFXMLErrorElementlessDocument: CFIndex = 11; |
| 49 | +pub const kCFXMLErrorMalformedComment: CFIndex = 12; |
| 50 | +pub const kCFXMLErrorMalformedCharacterReference: CFIndex = 13; |
| 51 | +pub const kCFXMLErrorMalformedParsedCharacterData: CFIndex = 14; |
| 52 | +pub const kCFXMLErrorNoData: CFIndex = 15; |
| 53 | + |
| 54 | +pub type CFXMLParserCreateXMLStructureCallBack = extern "C" fn (parser: CFXMLParserRef, nodeDesc: CFXMLNodeRef, info: *mut c_void) -> *mut c_void; |
| 55 | +pub type CFXMLParserAddChildCallBack = extern "C" fn (parser: CFXMLParserRef, parent: *mut c_void, child: *mut c_void, info: *mut c_void); |
| 56 | +pub type CFXMLParserEndXMLStructureCallBack = extern "C" fn (parser: CFXMLParserRef, xmlType: *mut c_void, info: *mut c_void); |
| 57 | +pub type CFXMLParserResolveExternalEntityCallBack = extern "C" fn (parser: CFXMLParserRef, extID: *mut CFXMLExternalID, info: *mut c_void) -> CFDataRef; |
| 58 | +pub type CFXMLParserHandleErrorCallBack = extern "C" fn (parser: CFXMLParserRef, error: CFXMLParserStatusCode, info: *mut c_void) -> Boolean; |
| 59 | + |
| 60 | +#[repr(C)] |
| 61 | +#[derive(Debug, Clone, Copy)] |
| 62 | +pub struct CFXMLParserCallBacks { |
| 63 | + pub version: CFIndex, |
| 64 | + pub createXMLStructure: CFXMLParserCreateXMLStructureCallBack, |
| 65 | + pub addChild: CFXMLParserAddChildCallBack, |
| 66 | + pub endXMLStructure: CFXMLParserEndXMLStructureCallBack, |
| 67 | + pub resolveExternalEntity: CFXMLParserResolveExternalEntityCallBack, |
| 68 | + pub handleError: CFXMLParserHandleErrorCallBack, |
| 69 | +} |
| 70 | + |
| 71 | +pub type CFXMLParserRetainCallBack = extern "C" fn(info: *const c_void) -> *const c_void; |
| 72 | +pub type CFXMLParserReleaseCallBack = extern "C" fn (info: *const c_void); |
| 73 | +pub type CFXMLParserCopyDescriptionCallBack = extern "C" fn(info: *const c_void) -> CFStringRef; |
| 74 | + |
| 75 | +#[repr(C)] |
| 76 | +#[derive(Debug, Clone, Copy)] |
| 77 | +pub struct CFXMLParserContext { |
| 78 | + pub version: CFIndex, |
| 79 | + pub info: *mut c_void, |
| 80 | + pub retain: CFXMLParserRetainCallBack, |
| 81 | + pub release: CFXMLParserReleaseCallBack, |
| 82 | + pub copyDescription: CFXMLParserCopyDescriptionCallBack |
| 83 | +} |
| 84 | + |
| 85 | +extern { |
| 86 | + /* |
| 87 | + * CFXMLParser.h |
| 88 | + */ |
| 89 | + |
| 90 | + pub static kCFXMLTreeErrorDescription: CFStringRef; |
| 91 | + pub static kCFXMLTreeErrorLineNumber: CFStringRef; |
| 92 | + pub static kCFXMLTreeErrorLocation: CFStringRef; |
| 93 | + pub static kCFXMLTreeErrorStatusCode: CFStringRef; |
| 94 | + |
| 95 | + pub fn CFXMLParserGetTypeID() -> CFTypeID; |
| 96 | + pub fn CFXMLParserCreate(allocator: CFAllocatorRef, xmlData: CFDataRef, dataSource: CFURLRef, parseOptions: CFOptionFlags, versionOfNodes: CFIndex, callBacks: *mut CFXMLParserCallBacks, context: *mut CFXMLParserContext) -> CFXMLParserRef; |
| 97 | + pub fn CFXMLParserCreateWithDataFromURL(allocator: CFAllocatorRef, dataSource: CFURLRef, parseOptions: CFOptionFlags, versionOfNodes: CFIndex, callBacks: *mut CFXMLParserCallBacks, context: *mut CFXMLParserContext) -> CFXMLParserRef; |
| 98 | + pub fn CFXMLParserGetContext(parser: CFXMLParserRef, context: *mut CFXMLParserContext); |
| 99 | + pub fn CFXMLParserGetCallBacks(parser: CFXMLParserRef, callBacks: *mut CFXMLParserCallBacks); |
| 100 | + pub fn CFXMLParserGetSourceURL(parser: CFXMLParserRef) -> CFURLRef; |
| 101 | + pub fn CFXMLParserGetLocation(parser: CFXMLParserRef) -> CFIndex; |
| 102 | + pub fn CFXMLParserGetLineNumber(parser: CFXMLParserRef) -> CFIndex; |
| 103 | + pub fn CFXMLParserGetDocument(parser: CFXMLParserRef) -> *mut c_void; |
| 104 | + pub fn CFXMLParserGetStatusCode(parser: CFXMLParserRef) -> CFXMLParserStatusCode; |
| 105 | + pub fn CFXMLParserCopyErrorDescription(parser: CFXMLParserRef) -> CFStringRef; |
| 106 | + pub fn CFXMLParserAbort(parser: CFXMLParserRef, errorCode: CFXMLParserStatusCode, errorDescription: CFStringRef); |
| 107 | + pub fn CFXMLParserParse(parser: CFXMLParserRef) -> Boolean; |
| 108 | + pub fn CFXMLTreeCreateFromData(allocator: CFAllocatorRef, xmlData: CFDataRef, dataSource: CFURLRef, parseOptions: CFOptionFlags, versionOfNodes: CFIndex) -> CFXMLTreeRef; |
| 109 | + pub fn CFXMLTreeCreateFromDataWithError(allocator: CFAllocatorRef, xmlData: CFDataRef, dataSource: CFURLRef, parseOptions: CFOptionFlags, versionOfNodes: CFIndex, errorDict: *mut CFDictionaryRef) -> CFXMLTreeRef; |
| 110 | + pub fn CFXMLTreeCreateWithDataFromURL(allocator: CFAllocatorRef, dataSource: CFURLRef, parseOptions: CFOptionFlags, versionOfNodes: CFIndex) -> CFXMLTreeRef; |
| 111 | + pub fn CFXMLTreeCreateXMLData(allocator: CFAllocatorRef, xmlTree: CFXMLTreeRef) -> CFDataRef; |
| 112 | + pub fn CFXMLCreateStringByEscapingEntities(allocator: CFAllocatorRef, string: CFStringRef, entitiesDictionary: CFDictionaryRef) -> CFStringRef; |
| 113 | + pub fn CFXMLCreateStringByUnescapingEntities(allocator: CFAllocatorRef, string: CFStringRef, entitiesDictionary: CFDictionaryRef) -> CFStringRef; |
| 114 | +} |
0 commit comments