core_foundation_sys/
xml_node.rs

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
10use std::os::raw::{c_char, c_void};
11
12use crate::array::CFArrayRef;
13use crate::base::{Boolean, CFAllocatorRef, CFIndex, CFTypeID};
14use crate::dictionary::CFDictionaryRef;
15use crate::string::{CFStringEncoding, CFStringRef};
16use crate::tree::CFTreeRef;
17use crate::url::CFURLRef;
18
19#[repr(C)]
20pub struct __CFXMLNode(c_void);
21
22pub type CFXMLNodeRef = *mut __CFXMLNode;
23pub type CFXMLTreeRef = CFTreeRef;
24
25pub const kCFXMLNodeCurrentVersion: CFIndex = 1;
26
27pub type CFXMLNodeTypeCode = CFIndex;
28pub const kCFXMLNodeTypeDocument: CFXMLNodeTypeCode = 1;
29pub const kCFXMLNodeTypeElement: CFXMLNodeTypeCode = 2;
30pub const kCFXMLNodeTypeAttribute: CFXMLNodeTypeCode = 3;
31pub const kCFXMLNodeTypeProcessingInstruction: CFXMLNodeTypeCode = 4;
32pub const kCFXMLNodeTypeComment: CFXMLNodeTypeCode = 5;
33pub const kCFXMLNodeTypeText: CFXMLNodeTypeCode = 6;
34pub const kCFXMLNodeTypeCDATASection: CFXMLNodeTypeCode = 7;
35pub const kCFXMLNodeTypeDocumentFragment: CFXMLNodeTypeCode = 8;
36pub const kCFXMLNodeTypeEntity: CFXMLNodeTypeCode = 9;
37pub const kCFXMLNodeTypeEntityReference: CFXMLNodeTypeCode = 10;
38pub const kCFXMLNodeTypeDocumentType: CFXMLNodeTypeCode = 11;
39pub const kCFXMLNodeTypeWhitespace: CFXMLNodeTypeCode = 12;
40pub const kCFXMLNodeTypeNotation: CFXMLNodeTypeCode = 13;
41pub const kCFXMLNodeTypeElementTypeDeclaration: CFXMLNodeTypeCode = 14;
42pub const kCFXMLNodeTypeAttributeListDeclaration: CFXMLNodeTypeCode = 15;
43
44#[repr(C)]
45#[derive(Debug, Clone, Copy)]
46pub struct CFXMLElementInfo {
47    pub attributes: CFDictionaryRef,
48    pub attributeOrder: CFArrayRef,
49    pub isEmpty: Boolean,
50    pub _reserved: [c_char; 3],
51}
52
53#[repr(C)]
54#[derive(Debug, Clone, Copy)]
55pub struct CFXMLProcessingInstructionInfo {
56    pub dataString: CFStringRef,
57}
58
59#[repr(C)]
60#[derive(Debug, Clone, Copy)]
61pub struct CFXMLDocumentInfo {
62    pub sourceURL: CFURLRef,
63    pub encoding: CFStringEncoding,
64}
65
66#[repr(C)]
67#[derive(Debug, Clone, Copy)]
68pub struct CFXMLExternalID {
69    pub systemID: CFURLRef,
70    pub publicID: CFStringRef,
71}
72
73#[repr(C)]
74#[derive(Debug, Clone, Copy)]
75pub struct CFXMLDocumentTypeInfo {
76    pub externalID: CFXMLExternalID,
77}
78
79#[repr(C)]
80#[derive(Debug, Clone, Copy)]
81pub struct CFXMLNotationInfo {
82    pub externalID: CFXMLExternalID,
83}
84
85#[repr(C)]
86#[derive(Debug, Clone, Copy)]
87pub struct CFXMLElementTypeDeclarationInfo {
88    pub contentDescription: CFStringRef,
89}
90
91#[repr(C)]
92#[derive(Debug, Clone, Copy)]
93pub struct CFXMLAttributeDeclarationInfo {
94    pub attributeName: CFStringRef,
95    pub typeString: CFStringRef,
96    pub defaultString: CFStringRef,
97}
98
99#[repr(C)]
100#[derive(Debug, Clone, Copy)]
101pub struct CFXMLAttributeListDeclarationInfo {
102    pub numberOfAttributes: CFIndex,
103    pub attributes: *mut CFXMLAttributeDeclarationInfo,
104}
105
106pub type CFXMLEntityTypeCode = CFIndex;
107pub const kCFXMLEntityTypeParameter: CFXMLEntityTypeCode = 0;
108pub const kCFXMLEntityTypeParsedInternal: CFXMLEntityTypeCode = 1;
109pub const kCFXMLEntityTypeParsedExternal: CFXMLEntityTypeCode = 2;
110pub const kCFXMLEntityTypeUnparsed: CFXMLEntityTypeCode = 3;
111pub const kCFXMLEntityTypeCharacter: CFXMLEntityTypeCode = 4;
112
113#[repr(C)]
114#[derive(Debug, Clone, Copy)]
115pub struct CFXMLEntityInfo {
116    pub entityType: CFXMLEntityTypeCode,
117    pub replacementText: CFStringRef,
118    pub entityID: CFXMLExternalID,
119    pub notationName: CFStringRef,
120}
121
122#[repr(C)]
123#[derive(Debug, Clone, Copy)]
124pub struct CFXMLEntityReferenceInfo {
125    pub entityType: CFXMLEntityTypeCode,
126}
127
128extern "C" {
129    /*
130     * CFXMLNode.h
131     */
132    pub fn CFXMLNodeGetTypeID() -> CFTypeID;
133    pub fn CFXMLNodeCreate(
134        alloc: CFAllocatorRef,
135        xmlType: CFXMLNodeTypeCode,
136        dataString: CFStringRef,
137        additionalInfoPtr: *const c_void,
138        version: CFIndex,
139    ) -> CFXMLNodeRef;
140    pub fn CFXMLNodeCreateCopy(alloc: CFAllocatorRef, origNode: CFXMLNodeRef) -> CFXMLNodeRef;
141    pub fn CFXMLNodeGetTypeCode(node: CFXMLNodeRef) -> CFXMLNodeTypeCode;
142    pub fn CFXMLNodeGetString(node: CFXMLNodeRef) -> CFStringRef;
143    pub fn CFXMLNodeGetInfoPtr(node: CFXMLNodeRef) -> *const c_void;
144    pub fn CFXMLNodeGetVersion(node: CFXMLNodeRef) -> CFIndex;
145    pub fn CFXMLTreeCreateWithNode(alloc: CFAllocatorRef, node: CFXMLNodeRef) -> CFXMLTreeRef;
146    pub fn CFXMLTreeGetNode(xmlTree: CFXMLTreeRef) -> CFXMLNodeRef;
147}