use std::{ffi::c_void, ptr::drop_in_place, rc::Rc};
#[cfg(feature = "libxml_regexp")]
use crate::libxml::xmlregexp::XmlRegexp;
use crate::{
tree::XmlNodePtr,
xmlschemas::{
item_list::{XmlSchemaItemListPtr, xml_schema_item_list_free},
items::{XmlSchemaAttribute, XmlSchemaTypePtr},
},
};
use super::{
globals::xml_free,
xmlschemastypes::{XmlSchemaValPtr, xml_schema_free_facet},
};
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum XmlSchemaValType {
XmlSchemasUnknown = 0,
XmlSchemasString = 1,
XmlSchemasNormString = 2,
XmlSchemasDecimal = 3,
XmlSchemasTime = 4,
XmlSchemasGDay = 5,
XmlSchemasGMonth = 6,
XmlSchemasGMonthDay = 7,
XmlSchemasGYear = 8,
XmlSchemasGYearMonth = 9,
XmlSchemasDate = 10,
XmlSchemasDatetime = 11,
XmlSchemasDuration = 12,
XmlSchemasFloat = 13,
XmlSchemasDouble = 14,
XmlSchemasBoolean = 15,
XmlSchemasToken = 16,
XmlSchemasLanguage = 17,
XmlSchemasNmtoken = 18,
XmlSchemasNmtokens = 19,
XmlSchemasName = 20,
XmlSchemasQName = 21,
XmlSchemasNCName = 22,
XmlSchemasID = 23,
XmlSchemasIDREF = 24,
XmlSchemasIDREFS = 25,
XmlSchemasEntity = 26,
XmlSchemasEntities = 27,
XmlSchemasNotation = 28,
XmlSchemasAnyURI = 29,
XmlSchemasInteger = 30,
XmlSchemasNPInteger = 31,
XmlSchemasNInteger = 32,
XmlSchemasNNInteger = 33,
XmlSchemasPInteger = 34,
XmlSchemasInt = 35,
XmlSchemasUInt = 36,
XmlSchemasLong = 37,
XmlSchemasULong = 38,
XmlSchemasShort = 39,
XmlSchemasUShort = 40,
XmlSchemasByte = 41,
XmlSchemasUByte = 42,
XmlSchemasHexbinary = 43,
XmlSchemasBase64binary = 44,
XmlSchemasAnytype = 45,
XmlSchemasAnySimpletype = 46,
}
#[doc(alias = "xmlSchemaTypeType")]
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum XmlSchemaTypeType {
XmlSchemaTypeBasic = 1,
XmlSchemaTypeAny,
XmlSchemaTypeFacet,
XmlSchemaTypeSimple,
XmlSchemaTypeComplex,
XmlSchemaTypeSequence = 6,
XmlSchemaTypeChoice,
XmlSchemaTypeAll,
XmlSchemaTypeSimpleContent,
XmlSchemaTypeComplexContent,
XmlSchemaTypeUr,
XmlSchemaTypeRestriction,
XmlSchemaTypeExtension,
XmlSchemaTypeElement,
XmlSchemaTypeAttribute,
XmlSchemaTypeAttributeGroup,
XmlSchemaTypeGroup,
XmlSchemaTypeNotation,
XmlSchemaTypeList,
XmlSchemaTypeUnion,
XmlSchemaTypeAnyAttribute,
XmlSchemaTypeIDCUnique,
XmlSchemaTypeIDCKey,
XmlSchemaTypeIDCKeyref,
XmlSchemaTypeParticle = 25,
XmlSchemaTypeAttributeUse,
XmlSchemaFacetMinInclusive = 1000,
XmlSchemaFacetMinExclusive,
XmlSchemaFacetMaxInclusive,
XmlSchemaFacetMaxExclusive,
XmlSchemaFacetTotalDigits,
XmlSchemaFacetFractionDigits,
XmlSchemaFacetPattern,
XmlSchemaFacetEnumeration,
XmlSchemaFacetWhitespace,
XmlSchemaFacetLength,
XmlSchemaFacetMaxLength,
XmlSchemaFacetMinLength,
XmlSchemaExtraQNameRef = 2000,
XmlSchemaExtraAttrUseProhib,
}
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum XmlSchemaContentType {
XmlSchemaContentUnknown = 0,
XmlSchemaContentEmpty = 1,
XmlSchemaContentElements,
XmlSchemaContentMixed,
XmlSchemaContentSimple,
XmlSchemaContentMixedOrElements,
XmlSchemaContentBasic,
XmlSchemaContentAny,
}
pub type XmlSchemaAnnotPtr = *mut XmlSchemaAnnot;
#[repr(C)]
pub struct XmlSchemaAnnot {
pub(crate) next: *mut XmlSchemaAnnot,
pub(crate) content: XmlNodePtr,
}
pub(crate) const XML_SCHEMAS_ANY_SKIP: i32 = 1;
pub(crate) const XML_SCHEMAS_ANY_LAX: i32 = 2;
pub(crate) const XML_SCHEMAS_ANY_STRICT: i32 = 3;
pub(crate) const XML_SCHEMAS_ATTR_USE_PROHIBITED: i32 = 0;
pub(crate) const XML_SCHEMAS_ATTR_USE_REQUIRED: i32 = 1;
pub(crate) const XML_SCHEMAS_ATTR_USE_OPTIONAL: i32 = 2;
pub(crate) const XML_SCHEMAS_ATTR_GLOBAL: i32 = 1 << 0;
pub(crate) const XML_SCHEMAS_ATTR_INTERNAL_RESOLVED: i32 = 1 << 8;
pub(crate) const XML_SCHEMAS_ATTR_FIXED: i32 = 1 << 9;
pub type XmlSchemaAttributeLinkPtr = *mut XmlSchemaAttributeLink;
#[doc(alias = "xmlSchemaAttributeLink")]
#[repr(C)]
pub struct XmlSchemaAttributeLink {
next: *mut XmlSchemaAttributeLink,
attr: *mut XmlSchemaAttribute,
}
pub type XmlSchemaWildcardNsPtr = *mut XmlSchemaWildcardNs;
#[doc(alias = "xmlSchemaCharValueLink")]
#[repr(C)]
pub struct XmlSchemaWildcardNs {
pub(crate) next: *mut XmlSchemaWildcardNs,
pub(crate) value: *const u8,
}
#[doc(alias = "xmlSchemaWildcard")]
pub type XmlSchemaWildcardPtr = *mut XmlSchemaWildcard;
#[repr(C)]
pub struct XmlSchemaWildcard {
pub(crate) typ: XmlSchemaTypeType,
pub(crate) annot: XmlSchemaAnnotPtr,
pub(crate) node: Option<XmlNodePtr>,
pub(crate) process_contents: i32,
pub(crate) any: i32,
pub(crate) ns_set: XmlSchemaWildcardNsPtr,
pub(crate) neg_ns_set: XmlSchemaWildcardNsPtr,
pub(crate) flags: i32,
}
pub(crate) const XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED: i32 = 1 << 0;
pub(crate) const XML_SCHEMAS_ATTRGROUP_GLOBAL: i32 = 1 << 1;
pub(crate) const XML_SCHEMAS_ATTRGROUP_MARKED: i32 = 1 << 2;
pub(crate) const XML_SCHEMAS_ATTRGROUP_REDEFINED: i32 = 1 << 3;
pub(crate) const XML_SCHEMAS_ATTRGROUP_HAS_REFS: i32 = 1 << 4;
pub type XmlSchemaTypeLinkPtr = *mut XmlSchemaTypeLink;
#[doc(alias = "xmlSchemaTypeLink")]
#[repr(C)]
pub struct XmlSchemaTypeLink {
pub(crate) next: *mut XmlSchemaTypeLink,
pub(crate) typ: XmlSchemaTypePtr,
}
pub type XmlSchemaFacetLinkPtr = *mut XmlSchemaFacetLink;
#[doc(alias = "xmlSchemaFacetLink")]
#[repr(C)]
pub struct XmlSchemaFacetLink {
pub(crate) next: *mut XmlSchemaFacetLink,
pub(crate) facet: XmlSchemaFacetPtr,
}
pub(crate) const XML_SCHEMAS_TYPE_MIXED: i32 = 1 << 0;
pub(crate) const XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION: i32 = 1 << 1;
pub(crate) const XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION: i32 = 1 << 2;
pub(crate) const XML_SCHEMAS_TYPE_GLOBAL: i32 = 1 << 3;
pub(crate) const XML_SCHEMAS_TYPE_VARIETY_LIST: i32 = 1 << 6;
pub(crate) const XML_SCHEMAS_TYPE_VARIETY_UNION: i32 = 1 << 7;
pub(crate) const XML_SCHEMAS_TYPE_VARIETY_ATOMIC: i32 = 1 << 8;
pub(crate) const XML_SCHEMAS_TYPE_FINAL_EXTENSION: i32 = 1 << 9;
pub(crate) const XML_SCHEMAS_TYPE_FINAL_RESTRICTION: i32 = 1 << 10;
pub(crate) const XML_SCHEMAS_TYPE_FINAL_LIST: i32 = 1 << 11;
pub(crate) const XML_SCHEMAS_TYPE_FINAL_UNION: i32 = 1 << 12;
pub(crate) const XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE: i32 = 1 << 14;
pub(crate) const XML_SCHEMAS_TYPE_MARKED: i32 = 1 << 16;
pub(crate) const XML_SCHEMAS_TYPE_BLOCK_EXTENSION: i32 = 1 << 18;
pub(crate) const XML_SCHEMAS_TYPE_BLOCK_RESTRICTION: i32 = 1 << 19;
pub(crate) const XML_SCHEMAS_TYPE_ABSTRACT: i32 = 1 << 20;
pub(crate) const XML_SCHEMAS_TYPE_FACETSNEEDVALUE: i32 = 1 << 21;
pub(crate) const XML_SCHEMAS_TYPE_INTERNAL_RESOLVED: i32 = 1 << 22;
pub(crate) const XML_SCHEMAS_TYPE_INTERNAL_INVALID: i32 = 1 << 23;
pub(crate) const XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE: i32 = 1 << 24;
pub(crate) const XML_SCHEMAS_TYPE_WHITESPACE_REPLACE: i32 = 1 << 25;
pub(crate) const XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE: i32 = 1 << 26;
pub(crate) const XML_SCHEMAS_TYPE_HAS_FACETS: i32 = 1 << 27;
pub(crate) const XML_SCHEMAS_TYPE_NORMVALUENEEDED: i32 = 1 << 28;
pub(crate) const XML_SCHEMAS_TYPE_FIXUP_1: i32 = 1 << 29;
pub(crate) const XML_SCHEMAS_TYPE_REDEFINED: i32 = 1 << 30;
pub(crate) const XML_SCHEMAS_ELEM_NILLABLE: i32 = 1 << 0;
pub(crate) const XML_SCHEMAS_ELEM_GLOBAL: i32 = 1 << 1;
pub(crate) const XML_SCHEMAS_ELEM_DEFAULT: i32 = 1 << 2;
pub(crate) const XML_SCHEMAS_ELEM_FIXED: i32 = 1 << 3;
pub(crate) const XML_SCHEMAS_ELEM_ABSTRACT: i32 = 1 << 4;
pub(crate) const XML_SCHEMAS_ELEM_TOPLEVEL: i32 = 1 << 5;
pub(crate) const XML_SCHEMAS_ELEM_INTERNAL_RESOLVED: i32 = 1 << 8;
pub(crate) const XML_SCHEMAS_ELEM_CIRCULAR: i32 = 1 << 9;
pub(crate) const XML_SCHEMAS_ELEM_BLOCK_EXTENSION: i32 = 1 << 11;
pub(crate) const XML_SCHEMAS_ELEM_BLOCK_RESTRICTION: i32 = 1 << 12;
pub(crate) const XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION: i32 = 1 << 13;
pub(crate) const XML_SCHEMAS_ELEM_FINAL_EXTENSION: i32 = 1 << 15;
pub(crate) const XML_SCHEMAS_ELEM_FINAL_RESTRICTION: i32 = 1 << 16;
pub(crate) const XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD: i32 = 1 << 17;
pub(crate) const XML_SCHEMAS_ELEM_INTERNAL_CHECKED: i32 = 1 << 18;
pub(crate) const XML_SCHEMAS_FACET_PRESERVE: i32 = 1;
pub(crate) const XML_SCHEMAS_FACET_REPLACE: i32 = 2;
pub(crate) const XML_SCHEMAS_FACET_COLLAPSE: i32 = 3;
pub type XmlSchemaFacetPtr = *mut XmlSchemaFacet;
#[repr(C)]
pub struct XmlSchemaFacet {
pub(crate) typ: XmlSchemaTypeType,
pub(crate) next: *mut XmlSchemaFacet,
pub(crate) value: *const u8,
pub(crate) id: *const u8,
pub(crate) annot: XmlSchemaAnnotPtr,
pub(crate) node: Option<XmlNodePtr>,
pub(crate) fixed: i32,
pub(crate) whitespace: i32,
pub(crate) val: XmlSchemaValPtr,
pub(crate) regexp: Option<Rc<XmlRegexp>>,
}
pub(crate) const XML_SCHEMAS_QUALIF_ELEM: i32 = 1 << 0;
pub(crate) const XML_SCHEMAS_QUALIF_ATTR: i32 = 1 << 1;
pub(crate) const XML_SCHEMAS_FINAL_DEFAULT_EXTENSION: i32 = 1 << 2;
pub(crate) const XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION: i32 = 1 << 3;
pub(crate) const XML_SCHEMAS_FINAL_DEFAULT_LIST: i32 = 1 << 4;
pub(crate) const XML_SCHEMAS_FINAL_DEFAULT_UNION: i32 = 1 << 5;
pub(crate) const XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION: i32 = 1 << 6;
pub(crate) const XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION: i32 = 1 << 7;
pub(crate) const XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION: i32 = 1 << 8;
pub(crate) const XML_SCHEMAS_INCLUDING_CONVERT_NS: i32 = 1 << 9;
#[doc(alias = "xmlSchemaFreeAnnot")]
pub(crate) unsafe fn xml_schema_free_annot(mut annot: XmlSchemaAnnotPtr) {
unsafe {
if annot.is_null() {
return;
}
if (*annot).next.is_null() {
xml_free(annot as _);
} else {
let mut prev: XmlSchemaAnnotPtr;
while {
prev = annot;
annot = (*annot).next;
xml_free(prev as _);
!annot.is_null()
} {}
}
}
}
#[doc(alias = "xmlSchemaFreeTypeLinkList")]
unsafe fn xml_schema_free_type_link_list(mut link: XmlSchemaTypeLinkPtr) {
unsafe {
let mut next: XmlSchemaTypeLinkPtr;
while !link.is_null() {
next = (*link).next;
xml_free(link as _);
link = next;
}
}
}
#[doc(alias = "xmlSchemaFreeType")]
pub unsafe fn xml_schema_free_type(typ: XmlSchemaTypePtr) {
unsafe {
if typ.is_null() {
return;
}
if !(*typ).annot.is_null() {
xml_schema_free_annot((*typ).annot);
}
if !(*typ).facets.is_null() {
let mut facet: XmlSchemaFacetPtr;
let mut next: XmlSchemaFacetPtr;
facet = (*typ).facets;
while !facet.is_null() {
next = (*facet).next;
xml_schema_free_facet(facet);
facet = next;
}
}
if !(*typ).attr_uses.is_null() {
xml_schema_item_list_free((*typ).attr_uses as XmlSchemaItemListPtr<*mut c_void>);
}
if !(*typ).member_types.is_null() {
xml_schema_free_type_link_list((*typ).member_types);
}
if !(*typ).facet_set.is_null() {
let mut next: XmlSchemaFacetLinkPtr;
let mut link: XmlSchemaFacetLinkPtr;
link = (*typ).facet_set;
while {
next = (*link).next;
xml_free(link as _);
link = next;
!link.is_null()
} {}
}
(*typ).cont_model.take();
drop_in_place(typ);
xml_free(typ as _);
}
}
#[doc(alias = "xmlSchemaFreeWildcardNsSet")]
pub(crate) unsafe fn xml_schema_free_wildcard_ns_set(mut set: XmlSchemaWildcardNsPtr) {
unsafe {
let mut next: XmlSchemaWildcardNsPtr;
while !set.is_null() {
next = (*set).next;
xml_free(set as _);
set = next;
}
}
}
#[doc(alias = "xmlSchemaFreeWildcard")]
pub unsafe fn xml_schema_free_wildcard(wildcard: XmlSchemaWildcardPtr) {
unsafe {
if wildcard.is_null() {
return;
}
if !(*wildcard).annot.is_null() {
xml_schema_free_annot((*wildcard).annot);
}
if !(*wildcard).ns_set.is_null() {
xml_schema_free_wildcard_ns_set((*wildcard).ns_set);
}
if !(*wildcard).neg_ns_set.is_null() {
xml_free((*wildcard).neg_ns_set as _);
}
xml_free(wildcard as _);
}
}