Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
xmlp.h
Go to the documentation of this file.
1 /* *************************************************************************************
2  Copyright (c) 2021, Lowell D. Thomas
3  All rights reserved.
4 
5  This file is part of APG Version 7.0.
6  APG Version 7.0 may be used under the terms of the BSD 2-Clause License.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  1. Redistributions of source code must retain the above copyright notice, this
12  list of conditions and the following disclaimer.
13 
14  2. Redistributions in binary form must reproduce the above copyright notice,
15  this list of conditions and the following disclaimer in the documentation
16  and/or other materials provided with the distribution.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 * *************************************************************************************/
33 #ifndef APG_XMLP_H_
34 #define APG_XMLP_H_
35 
42 typedef struct {
43  uint32_t uiOffset;
44  uint32_t uiLength;
45 } cdata_id;
46 
50 typedef struct{
53 } named_value;
54 
60 typedef struct{
61  struct xml_tag* spXml;
70 } att_decl;
71 
80 typedef struct {
81  struct xml_tag* spXml;
89 } entity_decl;
90 
95 typedef struct {
105 } element_frame;
106 
107 typedef struct{
108  uint32_t uiNameOffset;
109 } entity_frame;
110 
114 typedef struct xml_tag{
115  const void* vpValidate;
117  void* vpMem;
118  void* vpFmt;
119  void* vpParser;
120  void* vpConv;
121  void* vpMsgs;
124  void* vpLines;
125 
126  // input
128  void* vpVecChars;
130  uint8_t* ucpData;
131 
132  // working memory for parsed values
133  uint32_t uiChar;
134  void* vpVecName;
135  void* vpVec32;
136  void* vpVec8;
137  void* vpVecString;
138  void* vpVecCData;
140 
141  // XML declarations info
143 
144  // DTD declarations info
149  void* vpVecGEDefs;
161 
163  // element handling
164  void* vpVecFrame;
168  // attribute handling
170  void* vpVecAttWork;
173  void* vpVecAttList;
176 
177  // user call functions
187  void* vpEndTagData;
190  void* vpPIData;
199  void* vpDTDData;
200 } xml;
201 
202 
203 void vXmlgrammarRuleCallbacks(void* vpParser);
204 //void vXmlgrammarUdtCallbacks(void* vpParserCtx);
205 
206 #endif /* APG_XMLP_H_ */
xml_tag::vpDTDData
void * vpDTDData
An opaque pointer available for user's use.
Definition: xmlp.h:199
xml_tag::pfnXmlDeclCallback
pfnXmlDeclCallback pfnXmlDeclCallback
Pointer to the user's function for the XML declaration information.
Definition: xmlp.h:192
xml_tag::vpVec32
void * vpVec32
A 32-bit work vector of all most parsed data, names, attributes and content.
Definition: xmlp.h:135
xml_tag::vpConv
void * vpConv
A UTF conversion component. Reused in several places.
Definition: xmlp.h:120
xml_tag::bExtSubset
abool bExtSubset
True if an external subset is found, False otherwise.
Definition: xmlp.h:146
entity_frame
Definition: xmlp.h:107
element_frame::uiAttributeOffset
aint uiAttributeOffset
Parser offset to beginning of the current attribute. For error reporting.
Definition: xmlp.h:97
xml_tag::vpVecEntityFrames
void * vpVecEntityFrames
Vector of General Entities stack frames for walking the tree of entity replacement values.
Definition: xmlp.h:150
cdata_id::uiLength
uint32_t uiLength
The number of 32-bit data characters.
Definition: xmlp.h:44
xml_tag::uiChar
uint32_t uiChar
A working value for a single character. Gets overwritten by each Char rule.
Definition: xmlp.h:133
xml_tag::uiGEDeclsTotal
aint uiGEDeclsTotal
The total number of General Entity declarations. This includes declarations with multiply-defined nam...
Definition: xmlp.h:155
xml_tag::uiPEDecls
aint uiPEDecls
The number of Parameter Entity declarations found.
Definition: xmlp.h:153
att_decl::spXml
struct xml_tag * spXml
A copy of the XML object context pointer. Needed for quick sort and quick look up.
Definition: xmlp.h:61
element_frame
A stack is used to track which element is currently being parsed. This frame struct contains all of t...
Definition: xmlp.h:95
xml
This is the encapsulated data for the xml component. The component context or handle is an opaque poi...
att_decl::sAttValue
cdata_id sAttValue
The attribute normalized value, offset and length.
Definition: xmlp.h:65
xml_tag::vpEndTagData
void * vpEndTagData
An opaque pointer available for user's use.
Definition: xmlp.h:187
element_frame::sContent
cdata_id sContent
Identifies the location of the element's character data.
Definition: xmlp.h:104
xml_tag
Definition: xmlp.h:114
xml_tag::pfnDTDCallback
pfnDTDCallback pfnDTDCallback
Pointer to the user's function for the DTD information.
Definition: xmlp.h:195
entity_decl::bEntityDeclaredError
abool bEntityDeclaredError
True if the General Entity declaration contains a logged error.
Definition: xmlp.h:87
achar
uint_fast8_t achar
achar is the type for the parser's alphabet characters.
Definition: apg.h:91
xml_tag::uiSavedOffset
aint uiSavedOffset
Offset to the beginning of the declaration being processed. Used for error reporting.
Definition: xmlp.h:139
element_frame::sSName
cdata_id sSName
Identifies the location of the start tag name.
Definition: xmlp.h:102
xml_tag::uiAttListsDeclared
aint uiAttListsDeclared
The number of Attribute List declarations including empty and not processed.
Definition: xmlp.h:175
entity_decl
Provides the offset into the general 32-bit vector and length of a name and value pair.
Definition: xmlp.h:80
element_frame::sEName
cdata_id sEName
Identifies the location of the end tag name.
Definition: xmlp.h:103
xml_tag::pfnPICallback
pfnPICallback pfnPICallback
Pointer to the user's function for Processing Instruction processing.
Definition: xmlp.h:189
aint
uint_fast32_t aint
The APG parser's unsigned integer type.
Definition: apg.h:79
xml_tag::vpLines
void * vpLines
A lines object context pointer. Used to report the line number location of errors.
Definition: xmlp.h:124
entity_decl::sValue
cdata_id sValue
The offset (into vpVec32) and length of the value.
Definition: xmlp.h:83
entity_decl::bExpanded
abool bExpanded
True if this entity value has been expanded.
Definition: xmlp.h:88
cdata_id::uiOffset
uint32_t uiOffset
The offset into vpVec32 array for the start of the data.
Definition: xmlp.h:43
xml_tag::uiElementDecls
aint uiElementDecls
The number of element declarations.
Definition: xmlp.h:159
vXmlgrammarRuleCallbacks
void vXmlgrammarRuleCallbacks(void *vpParser)
Definition: basics.c:993
element_frame::uiElementOffset
aint uiElementOffset
Parser offset to beginning of this element. For error reporting.
Definition: xmlp.h:96
att_decl::sElementName
cdata_id sElementName
The element name, offset and length.
Definition: xmlp.h:62
xml_tag::vpVecCData
void * vpVecCData
Temp vector of u32_phrase info for presentation to the caller.
Definition: xmlp.h:138
named_value
Provides offsets and lengths in the vpVec32 array for a name and value pair.
Definition: xmlp.h:50
xml_tag::sCurrentEntity
entity_decl sCurrentEntity
Holds the current entity declaration information.
Definition: xmlp.h:160
xml_tag::pfnEmptyTagCallback
pfnEmptyTagCallback pfnEmptyTagCallback
Pointer to the user's callback function for empty tag porcessing. May be the same as the start tag ca...
Definition: xmlp.h:178
xml_tag::vpParser
void * vpParser
APG parser context pointer. Kept here for memory clean up use.
Definition: xmlp.h:119
entity_decl::bGEDefEx
abool bGEDefEx
True if the General Entity declaration contains an external ID.
Definition: xmlp.h:86
entity_decl::sName
cdata_id sName
The offset (into vpVec32) and length of the name.
Definition: xmlp.h:82
exception
A structure to describe the type and location of a caught exception.
Definition: exception.h:47
xml_tag::vpVecAttList
void * vpVecAttList
A vector of attribute named values.
Definition: xmlp.h:173
element_frame::uiBaseAtt
aint uiBaseAtt
Base index in vpVecAttList for this element. Pop to uiBaseAtt at end of element.
Definition: xmlp.h:100
xml_tag::vpPIData
void * vpPIData
An opaque pointer available for user's use.
Definition: xmlp.h:190
xml_tag::vpVecFrame
void * vpVecFrame
A vector for a stack of frames. A frame is pushed for each new element encountered and popped when th...
Definition: xmlp.h:164
xmldecl_info
Information about the XML declaration.
Definition: xml.h:58
xml_tag::vpVecString
void * vpVecString
A work vector for representing ASCII-only character data as a null-terminated string.
Definition: xmlp.h:137
xml_tag::sCurrentAttList
att_decl sCurrentAttList
Holds the current attribute list information.
Definition: xmlp.h:169
xml_tag::vpCommentData
void * vpCommentData
An opaque pointer available for user's use.
Definition: xmlp.h:196
att_decl::uiAttCount
aint uiAttCount
The number of different attribute names associated with this element name.
Definition: xmlp.h:66
xml_tag::vpVecAttWork
void * vpVecAttWork
A vector of work space for normalization of attribute balues.
Definition: xmlp.h:171
xml_tag::vpMem
void * vpMem
Handle to the memory component which keeps track of all memory allocations by this xml component.
Definition: xmlp.h:117
xml_tag::bStandalone
abool bStandalone
True if standalone = "yes", false if standalone = "no".
Definition: xmlp.h:145
xml_tag::vpVec8
void * vpVec8
A work vector for byte-stream data.
Definition: xmlp.h:136
xml_tag::acpChars
achar * acpChars
Pointer to input characters converted to achar, which in general is not 8-bit characters.
Definition: xmlp.h:129
xml_tag::sXmlDecl
xmldecl_info sXmlDecl
For collecting and reporting the XML declaration info.
Definition: xmlp.h:142
xml_tag::vpValidate
const void * vpValidate
Set to the context handle as a "magic number" for validating component member function calls.
Definition: xmlp.h:115
xml_tag::uiPERefs
aint uiPERefs
The number of Parameter Entity references found.
Definition: xmlp.h:154
entity_frame::uiNameOffset
uint32_t uiNameOffset
This is a unique identifier for the name. Used to check for entities that refer to themselves indirec...
Definition: xmlp.h:108
xml_tag::pfnStartTagCallback
pfnStartTagCallback pfnStartTagCallback
Pointer to the user's callback function for start tag processing. May be the same as the empty tag ca...
Definition: xmlp.h:182
att_decl::bIsCDATA
abool bIsCDATA
True if the attribute typ is CDATA.
Definition: xmlp.h:67
xml_tag::vpXmlDeclData
void * vpXmlDeclData
An opaque pointer available for user's use.
Definition: xmlp.h:193
element_frame::uiEntityOffset
aint uiEntityOffset
Parser offset to beginning of the current entity reference. For error reporting.
Definition: xmlp.h:98
named_value::sName
cdata_id sName
Points to offset and length of the datum's name.
Definition: xmlp.h:51
entity_decl::bGEPERef
abool bGEPERef
True if the General Entity declaration contains a Parameter Entity.
Definition: xmlp.h:85
xml_tag::uiTrueType
aint uiTrueType
Used to record the actual data type of the XML input (UTF-8, UTF-16BE or UTF-16LE)
Definition: xmlp.h:127
att_decl::bInvalidValue
abool bInvalidValue
True if the attribute value is invalid.
Definition: xmlp.h:69
xml_tag::uiDTDOffset
aint uiDTDOffset
Parser offset to the beginning of the DTD. Used for error reporting.
Definition: xmlp.h:147
named_value::sValue
cdata_id sValue
Points to offset and length of the datum's value.
Definition: xmlp.h:52
xml_tag::vpVecChars
void * vpVecChars
Vector of the XML input characters.
Definition: xmlp.h:128
xml_tag::uiAttListsNotProcessed
aint uiAttListsNotProcessed
The number of Attribute List declarations not processed because of the PE conditionals.
Definition: xmlp.h:174
xml_tag::vpEmptyTagData
void * vpEmptyTagData
An opaque pointer available for user's use.
Definition: xmlp.h:180
xml_tag::ucpData
uint8_t * ucpData
Points to the data read from an input file, if any. Otherwise, NULL. Needed for vXmlDtor().
Definition: xmlp.h:130
att_decl::sAttName
cdata_id sAttName
The attribute name, offset and length.
Definition: xmlp.h:63
att_decl::sAttType
cdata_id sAttType
attribute type, offset and length.
Definition: xmlp.h:64
abool
uint8_t abool
abool is the APG bool type.
Definition: apg.h:140
xml_tag::sDtdName
cdata_id sDtdName
Offset & length of the DTD name.
Definition: xmlp.h:148
xml_tag::vpMsgs
void * vpMsgs
During DTD parsing, this collects errors, all to be reported at the close of the DTD....
Definition: xmlp.h:121
element_frame::uiAttCount
aint uiAttCount
The number of attributes found in the start tag.
Definition: xmlp.h:101
xml_tag::pfnCommentCallback
pfnCommentCallback pfnCommentCallback
Pointer to the user's function for the DTD information.
Definition: xmlp.h:198
xml_tag::spException
exception * spException
Definition: xmlp.h:116
xml_tag::pfnEndTagCallback
pfnEndTagCallback pfnEndTagCallback
Pointer to the user's callback function for end tag processing.
Definition: xmlp.h:186
xml_tag::vpVecAttDecls
void * vpVecAttDecls
The list of attribute declarations.
Definition: xmlp.h:172
element_frame::uiBase32
aint uiBase32
Base index in vpVec32 for all data for this element. Pop to uiBase32 at end of element.
Definition: xmlp.h:99
xml_tag::vpFmt
void * vpFmt
Context pointer to a format object used to display printing and non-printing code points.
Definition: xmlp.h:118
xml_tag::uiExternalIds
aint uiExternalIds
The number of external IDs found.
Definition: xmlp.h:152
att_decl
Identifies the element name, attribute name and default attribute value of attribute list declaration...
Definition: xmlp.h:60
xml_tag::uiGEDeclsNotProcessed
aint uiGEDeclsNotProcessed
The number of General Entity declarations not processed because of conditionals. Condition: Unread Pa...
Definition: xmlp.h:157
xml_tag::vpVecGEDefs
void * vpVecGEDefs
Vector of named_values for the General Entities declared.
Definition: xmlp.h:149
cdata_id
Parsed character data definition.
Definition: xmlp.h:42
xml_tag::vpVecNotationDecls
void * vpVecNotationDecls
Vector of Notations declared.
Definition: xmlp.h:151
att_decl::bHasData
abool bHasData
True if the attribute declaration defines default data.
Definition: xmlp.h:68
entity_decl::spXml
struct xml_tag * spXml
A copy of the XML object context pointer. Needed for quick sort and quick look up.
Definition: xmlp.h:81
entity_decl::uiInputOffset
aint uiInputOffset
Offset to the first input character of the "<!ENTITY" declaration.
Definition: xmlp.h:84
xml_tag::spCurrentFrame
element_frame * spCurrentFrame
Holds a pointer to the current frame for the element being parsed.
Definition: xmlp.h:166
xml_tag::vpStartTagData
void * vpStartTagData
An opaque pointer available for user's use.
Definition: xmlp.h:184
xml_tag::vpVecName
void * vpVecName
Hold the name from the Name rule. Gets overwritten for each new Name instance.
Definition: xmlp.h:134
APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.