Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
|
Go to the documentation of this file.
103 #define LINE_LEN12 12
105 #define CHARS_LINE_LEN 8
106 #define CHAR_BUF_LEN 256
118 static const void* s_vpMagicNumber = (
const void*)
"xml";
120 static void vClear(
xml* spXml);
122 static void vDisplayXml(
xml* spXml,
abool bShowLines,
void* vpVecChars);
123 static abool bIsUtf8(uint8_t* ucpData);
124 static abool bIsUtf16be(uint8_t* ucpData);
125 static abool bIsUtf16le(uint8_t* ucpData);
128 uint32_t uiAttrCount,
void* vpUserData);
130 uint32_t uiAttrCount,
void* vpUserData);
133 static void vXmlDeclDisplay(
xmldecl_info* spInfo,
void* vpUserData);
134 static void vDTDDisplay(
dtd_info* spInfo,
void* vpUserData);
135 static void vCommentDisplay(
u32_phrase* spComment,
void* vpUserData);
136 static void vDisplayUnicode(
void* vpFmt,
const uint32_t* uipChars, uint32_t uiLength);
137 static void vGetData(
xml* spXml, uint8_t* ucpData,
aint uiDataLen,
char* cpBuf,
size_t uiBufBeg,
size_t uiBufLen);
138 static void vDisplayCData(
char* cpName,
u32_phrase* spData,
void* vpFmt);
168 "On this system, length of char is %d bits. This XML processor requires length of char to be 8 bits.",
174 memset((
void*)spXml, 0,
sizeof(
xml));
175 spXml->vpMem = vpMem;
176 spXml->spException = spEx;
180 spXml->vpVecChars =
vpVecCtor(vpMem,
sizeof(uint8_t), 4096);
181 spXml->vpVec32 =
vpVecCtor(vpMem,
sizeof(uint32_t), 4096);
182 spXml->vpVec8 =
vpVecCtor(vpMem,
sizeof(uint8_t), 4096);
183 spXml->vpVecString =
vpVecCtor(vpMem,
sizeof(
char), 4096);
184 spXml->vpVecName =
vpVecCtor(vpMem,
sizeof(uint32_t), 4096);
190 spXml->vpVecAttWork =
vpVecCtor(vpMem,
sizeof(uint32_t), 4096);
193 spXml->vpValidate = s_vpMagicNumber;
197 static void vClear(
xml* spXml){
200 spXml->vpLines = NULL;
202 spXml->vpParser = NULL;
204 vMemFree(spXml->vpMem, spXml->ucpData);
205 spXml->ucpData = NULL;
208 vMemFree(spXml->vpMem, spXml->acpChars);
209 spXml->acpChars = NULL;
213 spXml->uiExternalIds = 0;
214 spXml->uiPEDecls = 0;
216 spXml->uiGEDeclsNotProcessed = 0;
217 spXml->uiAttListsNotProcessed = 0;
244 if(vpCtx && (spXml->vpValidate == s_vpMagicNumber)){
251 vpMem = spXml->vpMem;
252 memset((
void*)spXml, 0,
sizeof(
xml));
263 if(vpCtx && (spXml->vpValidate == s_vpMagicNumber)){
279 if(vpCtx && (spXml->vpValidate == s_vpMagicNumber)){
282 size_t uiBufLen, uiBufBeg;
286 spXml->ucpData = (uint8_t*)
vpMemAlloc(spXml->vpMem, uiLen);
287 vUtilFileRead(spXml->vpMem, cpFileName, spXml->ucpData, &uiLen);
288 uiBufBeg = (size_t)snprintf(caBuf, uiBufSize,
"file: %s: ", cpFileName);
289 if(uiBufBeg >= uiBufSize){
291 snprintf(caBuf, uiBufSize,
"file name \"%s\" too long", cpFileName);
292 XTHROW(spXml->spException, caBuf);
294 uiBufLen = uiBufSize - uiBufBeg;
295 vGetData(spXml, spXml->ucpData, uiLen, caBuf, uiBufBeg, uiBufLen);
296 vMemFree(spXml->vpMem, spXml->ucpData);
297 spXml->ucpData = NULL;
303 static void vGetData(
xml* spXml, uint8_t* ucpData,
aint uiDataLen,
char* cpBuf,
size_t uiBufBeg,
size_t uiBufLen){
309 spXml->vpLines = NULL;
311 snprintf(cpBuf, uiBufLen,
"input error: data has too few bytes (< 3)");
312 XTHROW(spXml->spException, cpBuf);
316 if(!bUtfType(ucpData, &uiStartByte, &uiTrueType, &sInfo)){
319 snprintf(&cpBuf[uiBufBeg], uiBufLen,
320 "input error: data begins with %s encoding type BOM but invalid XML characters follows",
cpType);
321 XTHROW(spXml->spException, cpBuf);
326 snprintf(&cpBuf[uiBufBeg], uiBufLen,
327 "unexpected input error: type is UTF-8 an no errors are expected at this stage");
330 snprintf(&cpBuf[uiBufBeg], uiBufLen,
331 "input error: encoding type appears to be UTF-16BE but required BOM not present");
334 snprintf(&cpBuf[uiBufBeg], uiBufLen,
335 "input error: encoding type appears to be UTF-16LE but required BOM not present");
338 snprintf(&cpBuf[uiBufBeg], uiBufLen,
339 "input error: unrecognized encoding type - invalid XML document");
343 XTHROW(spXml->spException, cpBuf);
346 spXml->uiTrueType = uiTrueType;
347 ucpData += uiStartByte;
348 uiDataLen -= uiStartByte;
349 conv_src sSrc = {uiTrueType, ucpData, uiDataLen};
356 uint32_t uiCodeLen = 0;
357 uint32_t* uipCode, *uipTrans;
360 uipCode = (uint32_t*)
vpVecPushn(spXml->vpVec32, NULL, (
aint)((2 * uiCodeLen) + 2));
361 uipTrans = uipCode + uiCodeLen + 2;
363 uipCode[uiCodeLen] = 0;
365 uint32_t uiCount = 0;
367 for(; ui < uiCodeLen; ui++){
368 uiPoint = uipCode[ui];
370 if((uiPoint < 9) || (uiPoint == 11) || (uiPoint ==12) || ((uiPoint > 13) && (uiPoint < 32))){
371 snprintf(&cpBuf[uiBufBeg], uiBufLen,
372 "code point 0x%02X at offset %"PRIuMAX
" is disallowed control character",
374 XTHROW(spXml->spException, cpBuf);
376 if((uiPoint == 0xFFFE) || (uiPoint == 0xFFFF)){
377 snprintf(&cpBuf[uiBufBeg], uiBufLen,
378 "code point 0x%X at offset %"PRIuMAX
" is disallowed (characters 0xFFFE & 0xFFFF are forbidden)",
380 XTHROW(spXml->spException, cpBuf);
384 uipTrans[uiCount++] = 10;
385 if(uipCode[ui + 1] == 10){
389 uipTrans[uiCount++] = uiPoint;
420 if(!vpCtx || (spXml->vpValidate != s_vpMagicNumber)){
426 vGetData(spXml, ucpData, uiDataLen, caBuf, 0,
CHAR_BUF_LEN);
430 static void vPreDefinedEntities(
xml* spXml){
431 static uint32_t uiAmp = 38;
432 static uint32_t uiApos = 39;
433 static uint32_t uiGt = 62;
434 static uint32_t uiLt = 60;
435 static uint32_t uiQuot = 34;
436 static uint32_t uiAmpName[] = {97,109,112};
437 static uint32_t uiAposName[] = {97,112,111,115};
438 static uint32_t uiGtName[] = {103,116};
439 static uint32_t uiLtName[] = {108,116};
440 static uint32_t uiQuotName[] = {113,117,111,116};
445 spValue->
spXml = spXml;
455 spValue->
spXml = spXml;
465 spValue->
spXml = spXml;
475 spValue->
spXml = spXml;
485 spValue->
spXml = spXml;
492 spXml->uiGEDeclsTotal = 5;
502 if(!vpCtx || (spXml->vpValidate != s_vpMagicNumber)){
509 uint8_t* uipInputChars = (uint8_t*)
vpVecFirst(spXml->vpVecChars);
510 if(!uipInputChars || !uiCharCount){
511 XTHROW(spXml->spException,
"no XML input");
515 vPreDefinedEntities(spXml);
525 if(
sizeof(
achar) !=
sizeof(uint8_t)){
527 vMemFree(spXml->vpMem, spXml->acpChars);
530 for(ui = 0; ui < uiCharCount; ui++){
531 spXml->acpChars[ui] = (
achar)uipInputChars[ui];
533 acpInput = spXml->acpChars;
537 memset((
void*)&sInput, 0,
sizeof(sInput));
538 sInput.acpInput = acpInput;
539 sInput.uiInputLength = uiCharCount;
541 sInput.vpUserData = (
void*)spXml;
548 XTHROW(spXml->spException,
"XML parser failed: invalid XML input");
551 vMemFree(spXml->vpMem, spXml->acpChars);
552 spXml->acpChars = NULL;
567 if(!vpCtx || (spXml->vpValidate != s_vpMagicNumber)){
581 if(!vpCtx || (spXml->vpValidate != s_vpMagicNumber)){
584 return spXml->vpMsgs;
602 if(vpCtx && (spXml->vpValidate == s_vpMagicNumber)){
604 spXml->pfnStartTagCallback = vStartTagDisplay;
605 spXml->vpStartTagData = (
void*)spXml;
607 spXml->pfnStartTagCallback = pfnCallback;
608 spXml->vpStartTagData = vpUserData;
634 if(vpCtx && (spXml->vpValidate == s_vpMagicNumber)){
636 spXml->pfnEmptyTagCallback = vEmptyTagDisplay;
637 spXml->vpEmptyTagData = (
void*)spXml;
639 spXml->pfnEmptyTagCallback = pfnCallback;
640 spXml->vpEmptyTagData = vpUserData;
658 if(vpCtx && (spXml->vpValidate == s_vpMagicNumber)){
660 spXml->pfnEndTagCallback = vEndTagDisplay;
661 spXml->vpEndTagData = (
void*)spXml;
663 spXml->pfnEndTagCallback = pfnCallback;
664 spXml->vpEndTagData = vpUserData;
683 if(vpCtx && (spXml->vpValidate == s_vpMagicNumber)){
685 spXml->pfnPICallback = vPIDisplay;
686 spXml->vpPIData = (
void*)spXml;
688 spXml->pfnPICallback = pfnCallback;
689 spXml->vpPIData = vpUserData;
708 if(vpCtx && (spXml->vpValidate == s_vpMagicNumber)){
710 spXml->pfnXmlDeclCallback = vXmlDeclDisplay;
711 spXml->vpXmlDeclData = (
void*)spXml;
713 spXml->pfnXmlDeclCallback = pfnCallback;
714 spXml->vpXmlDeclData = vpUserData;
733 if(vpCtx && (spXml->vpValidate == s_vpMagicNumber)){
735 spXml->pfnDTDCallback = vDTDDisplay;
736 spXml->vpDTDData = (
void*)spXml;
738 spXml->pfnDTDCallback = pfnCallback;
739 spXml->vpDTDData = vpUserData;
758 if(vpCtx && (spXml->vpValidate == s_vpMagicNumber)){
760 spXml->pfnCommentCallback = vCommentDisplay;
761 spXml->vpCommentData = (
void*)spXml;
763 spXml->pfnCommentCallback = pfnCallback;
764 spXml->vpCommentData = vpUserData;
783 if(vpCtx && (spXml->vpValidate == s_vpMagicNumber)){
784 vDisplayXml(spXml, bShowLines, spXml->vpVecChars);
791 static void vDisplayCData(
char* cpName,
u32_phrase* spData,
void* vpUserData){
792 xml* spXml = (
xml*)vpUserData;
797 printf(
"%10s: '%s'\n", cpName, cpStr);
800 printf(
"%10s: (some or all characters non-ASCII)\n", cpName);
805 static void vDisplayUnicode(
void* vpFmt,
const uint32_t* uipChars, uint32_t uiLength){
808 printf(
"%s", cpNext);
826 uint32_t uiAttCount,
void* vpUserData){
827 printf(
"Start Tag\n");
828 vDisplayCData(
"name", spName, vpUserData);
829 printf(
"Attributes (%u)\n", uiAttCount);
831 for(; ui < uiAttCount; ui++){
832 vDisplayCData(
"name", &spAttNames[ui], vpUserData);
833 vDisplayCData(
"value", &spAttValues[ui], vpUserData);
850 vDisplayCData(
"name", spName, vpUserData);
851 vDisplayCData(
"content", spContent, vpUserData);
867 printf(
"Processing Instruction\n");
868 vDisplayCData(
"target", spTarget, vpUserData);
869 vDisplayCData(
"info", spInfo, vpUserData);
873 static void vXmlDeclDisplay(
xmldecl_info* spInfo,
void* vpUserData){
874 printf(
"INFORMATION: XML DECLARATION\n");
875 static char* cpFormat =
""
883 static void vCommentDisplay(
u32_phrase* spComment,
void* vpUserData){
884 vDisplayCData(
"comment", spComment, vpUserData);
888 static void vDTDDisplay(
dtd_info* spInfo,
void* vpUserData){
889 static char* cpYes =
"yes";
890 static char* cpNo =
"no";
891 printf(
"INFORMATION: DOCUMENT TYPE DECLARATION (DTD)\n");
893 printf(
"%3s: %s\n", cpYes,
"DTD exists");
894 printf(
"%3s: %s\n", (spInfo->
bStandalone ? cpYes : cpNo),
"Document is standalone");
895 printf(
"%3s: %s\n", (spInfo->
bExtSubset ? cpYes : cpNo),
"DTD has external subset");
896 printf(
"%3d: %s\n", (
int)spInfo->
uiExternalIds,
"external ids");
897 printf(
"%3d: %s\n", (
int)spInfo->
uiPEDecls,
"Parameter Entity declarations");
898 printf(
"%3d: %s\n", (
int)spInfo->
uiPERefs,
"Parameter Entity references");
900 "General Entity declarations: all declarations (includes pre-defined & not processed)");
901 printf(
"%3d: %s\n", (
int)spInfo->
uiGEDeclsNotProcessed,
"General Entity declarations: not processed");
902 printf(
"%3d: %s\n", (
int)spInfo->
uiGEDeclsUnique,
"General Entity declarations: unique processed (includes pre-defined)");
903 printf(
"%3d: %s\n", (
int)spInfo->
uiAttListsDeclared,
"Attribute List declarations: all declarations");
904 printf(
"%3d: %s\n", (
int)spInfo->
uiAttListsUnique,
"Attribute List declarations: unique element/attribute name combinations");
906 printf(
"%3d: %s\n", (
int)spInfo->
uiElementDecls,
"Element declarations");
907 printf(
"%3d: %s\n", (
int)spInfo->
uiNotationDecls,
"Notation declarations");
910 vDisplayCData(
"document name", spInfo->
spName, vpUserData);
913 printf(
"General Entity names and values\n");
916 vDisplayCData(
"entity name", &spInfo->
spGENames[ui], vpUserData);
917 vDisplayCData(
"entity value", &spInfo->
spGEValues[ui], vpUserData);
922 printf(
"Attribute List element names, attribute names and attribute values\n");
926 vDisplayCData(
"attribute name", &spInfo->
spAttNames[ui], vpUserData);
927 vDisplayCData(
"attribute type", &spInfo->
spAttTypes[ui], vpUserData);
928 vDisplayCData(
"attribute value", &spInfo->
spAttValues[ui], vpUserData);
933 printf(
"Notation names and values\n");
936 vDisplayCData(
"notation name", &spInfo->
spNotationNames[ui], vpUserData);
941 printf(
"%3s: %s\n", cpNo,
"DTD exists");
958 uint32_t uiAttCount,
void* vpUserData){
959 printf(
"Empty Tag\n");
960 vDisplayCData(
"name", spName, vpUserData);
961 printf(
"Attributes (%u)\n", uiAttCount);
963 for(; ui < uiAttCount; ui++){
964 vDisplayCData(
"name", &spAttNames[ui], vpUserData);
965 vDisplayCData(
"value", &spAttValues[ui], vpUserData);
995 static aint uiCountDigits(
aint uiValue){
997 uiValue = uiValue/10;
1000 uiValue = uiValue/10;
1004 static void vDisplayXml(
xml* spXml,
abool bShowLines,
void* vpVecChars){
1006 uint8_t* ucpChars = (uint8_t*)
vpVecFirst(vpVecChars);
1008 static char* cpFmt1 =
"%d: %s";
1009 static char* cpFmt2 =
"%02d: %s";
1010 static char* cpFmt3 =
"%03d: %s";
1011 static char* cpFmt4 =
"%04d: %s";
1012 static char* cpAlt1 =
" : %s";
1013 static char* cpAlt2 =
" : %s";;
1014 static char* cpAlt3 =
" : %s";;
1015 static char* cpAlt4 =
" : %s";;
1016 char* cpFmt, *cpAlt;
1020 printf(
"00000000 no data\n");
1025 int iLineNo, iPartial;
1027 printf(
"00000000 no lines\n");
1038 aint uiDigits = uiCountDigits((
aint)iLineNo);
1066 printf(cpFmt, iLineNo, cpNext);
1068 printf(cpAlt, cpNext);
1079 printf(
"%s", cpNext);
1088 static abool bIsUtf8(uint8_t* ucpData){
1091 if(ucpData[0] == 0x3C &&
1092 ucpData[1] == 0x3F &&
1093 ucpData[1] == 0x78 &&
1094 ucpData[1] == 0x6D &&
1095 ucpData[1] == 0x6C){
1099 if((ucpData[0] == 0x3C) && (ucpData[1] != 0)){
1103 if((ucpData[0] == 0x20) && (ucpData[1] != 0)){
1107 if((ucpData[0] == 0x09) && (ucpData[1] != 0)){
1111 if((ucpData[0] == 0x0A) && (ucpData[1] != 0)){
1115 if((ucpData[0] == 0x0D) && (ucpData[1] != 0)){
1124 static abool bIsUtf16be(uint8_t* ucpData){
1127 if(ucpData[0] == 0x00 && ucpData[1] == 0x3C &&
1128 ucpData[2] == 0x00 && ucpData[3] == 0x3F &&
1129 ucpData[4] == 0x00 && ucpData[5] == 0x78 &&
1130 ucpData[6] == 0x00 && ucpData[7] == 0x6D &&
1131 ucpData[8] == 0x00 && ucpData[9] == 0x6C){
1135 if(ucpData[0] == 0x00 && ucpData[1] == 0x3C){
1139 if(ucpData[0] == 0x00 && ucpData[1] == 0x20){
1143 if(ucpData[0] == 0x00 && ucpData[1] == 0x09){
1147 if(ucpData[0] == 0x00 && ucpData[1] == 0x0A){
1151 if(ucpData[0] == 0x00 && ucpData[1] == 0x0D){
1160 static abool bIsUtf16le(uint8_t* ucpData){
1163 if(ucpData[0] == 0x3C && ucpData[1] == 0x00 &&
1164 ucpData[2] == 0x3F && ucpData[3] == 0x00 &&
1165 ucpData[4] == 0x78 && ucpData[5] == 0x00 &&
1166 ucpData[6] == 0x6D && ucpData[7] == 0x00 &&
1167 ucpData[8] == 0x6C && ucpData[9] == 0x00){
1171 if(ucpData[0] == 0x3C && ucpData[1] == 0x00){
1175 if(ucpData[0] == 0x20 && ucpData[1] == 0x00){
1179 if(ucpData[0] == 0x09 && ucpData[1] == 0x00){
1183 if(ucpData[0] == 0x0A && ucpData[1] == 0x00){
1187 if(ucpData[0] == 0x0D && ucpData[1] == 0x00){
1201 if(ucpData[0] == 0xEF && ucpData[1] == 0xBB && ucpData[2] == 0xBF){
1204 *uipTrueType =
UTF_8;
1207 spInfo->
bValid = bIsUtf8(&ucpData[3]);
1210 if((ucpData[0] == 0xFE && ucpData[1] == 0xFF) && !(ucpData[2] == 0 && ucpData[3] == 0)){
1216 spInfo->
bValid = bIsUtf16be(&ucpData[2]);
1219 if((ucpData[0] == 0xFF && ucpData[1] == 0xFE) && !(ucpData[2] == 0 && ucpData[3] == 0)){
1225 spInfo->
bValid = bIsUtf16le(&ucpData[2]);
1231 if(bIsUtf8(ucpData)){
1233 *uipTrueType =
UTF_8;
1239 if(bIsUtf16be(ucpData)){
1247 if(bIsUtf16le(ucpData)){
aint uiLineLength
The number of characters in the line, including the line end characters.
void vXmlParse(void *vpCtx)
Parse the XML data from vXmlGetFile or vXmlGetArray.
u32_phrase * spNotationValues
A list of the Notation values, if any.
u32_phrase * spGEValues
A list of (uiGEDeclsUnique) declared General Entity Declaration values, if any.
u32_phrase * spAttNames
A list of (uiAttListsUnique) names of declared attribute defaults.
void(* pfnEmptyTagCallback)(u32_phrase *spName, u32_phrase *spAttrNames, u32_phrase *spAttrValues, uint32_t uiAttrCount, void *vpUserData)
Defines the function type that is called after an empty tag has been found.
void * vpParserCtor(exception *spException, void *vpParserInit)
The parser's constructor for file initialization data.
void vUtilFileRead(void *vpMem, const char *cpFileName, uint8_t *ucpData, aint *uipLen)
Read a file into the caller's data area.
void * vpXmlCtor(exception *spEx)
The XML Parser constructor.
void vXmlDisplayInput(void *vpCtx, abool bShowLines)
Display input file.
void * vpLinesCtor(exception *spEx, const char *cpInput, aint uiLength)
The lines object constructor.
aint uiSuccess
True (>0) if the input string was matched in its entirety, false (0) otherwise.
void vMemDtor(void *vpCtx)
Destroys a Memory component. Frees all memory allocated.
u32_phrase * spName
The DTD name (name of the root element).
uint32_t uiLength
The number of 32-bit data characters.
void(* pfnEndTagCallback)(u32_phrase *spName, u32_phrase *spContent, void *vpUserData)
Defines the function type that is called after an element's end tag has been found.
#define DEFAULT_CALLBACK
Indicator for a pre-defined, default callback function.
aint uiMsgsCount(void *vpCtx)
Get the number of logged messages.
void vXmlSetEmptyTagCallback(void *vpCtx, pfnEmptyTagCallback pfnCallback, void *vpUserData)
Set the user's callback function for the empty tags (<name attr="10"/>).
A stack is used to track which element is currently being parsed. This frame struct contains all of t...
uint32_t uiLength
The number of integers in the array.
This is the encapsulated data for the xml component. The component context or handle is an opaque poi...
aint uiPERefs
The number of Parameter Entity references.
void vUtilPrintMsgs(void *vpMsgs)
Display the list of messages in a message object to stdout.
void vExContext()
Handles bad context pointers.
void vXmlSetCommentCallback(void *vpCtx, pfnCommentCallback pfnCallback, void *vpUserData)
Set the user's callback function for comments.
uint_fast8_t achar
achar is the type for the parser's alphabet characters.
void * vpConvCtor(exception *spEx)
The data conversion object constructor.
abool bXmlValidate(void *vpCtx)
Validate an XML context pointer.
Provides the offset into the general 32-bit vector and length of a name and value pair.
abool bExtSubset
True if an external subset is declared.
aint uiExternalIds
The number of external IDs declared.
aint uiAttListsDeclared
The number of ALL Attribute declarations.
u32_phrase * spAttElementNames
A list of (uiAttListsUnique) element names of declared attribute defaults.
Public header file for the APG XML parser API..
const char * cpExists
"yes" if the XML declaration exists, "no" otherwise.
const char * cpStandalone
The value of the standalone declaration.
const uint32_t * uipPhrase
Pointer to an array of 32-bit unsigned integers.
#define XTHROW(ctx, msg)
Exception throw macro.
const char * cpType(aint uiId)
Convert an attribute type ID to an ASCII string.
void(* pfnStartTagCallback)(u32_phrase *spName, u32_phrase *spAttNames, u32_phrase *spAttValues, uint32_t uiAttCount, void *vpUserData)
Defines the function type that is called after an element's start tag has been found.
void vXmlGetArray(void *vpCtx, uint8_t *ucpData, aint uiDataLen)
Gets the XML byte stream from a byte array.
void(* pfnCommentCallback)(u32_phrase *spComment, void *vpUserData)
Defines the function type that is called after a comment is found.
aint uiGEDeclsUnique
A count of the unique and valid General Entities declared.
void vXmlgrammarRuleCallbacks(void *vpParserCtx)
#define UTF_16BE
Data type macro for UTF-16BE encoding/decoding.
uint_fast32_t aint
The APG parser's unsigned integer type.
void vConvGetCodePoints(void *vpCtx, uint32_t *uipData, uint32_t *uipDataLen)
Access the intermediate 32-bit data following a call to vConvDecode() or vConvUseCodePoints().
void * vpXmlGetMsgs(void *vpCtx)
Give the user a handle to the message log.
void(* pfnXmlDeclCallback)(xmldecl_info *spInfo, void *vpUserData)
Defines the function type that is called after parsing the XML declaration.
cdata_id sValue
The offset (into vpVec32) and length of the value.
u32_phrase * spAttValues
A list of (uiAttListsUnique) normalized values of declared attribute defaults.
void vXmlGetFile(void *vpCtx, const char *cpFileName)
Gets the XML byte stream from a file.
Defines the input string and other configuration parameters for the parser,.
uint32_t uiOffset
The offset into vpVec32 array for the start of the data.
void * vpMsgsCtor(exception *spEx)
The Message Log constructor.
void vMsgsClear(void *vpCtx)
Clears the object of all messages.
Private header for the APG XML parser's component context. Not needed by application programs.
void * vpMemAlloc(void *vpCtx, aint uiBytes)
Allocates memory.
aint uiVecLen(void *vpCtx)
Get the vector length. That is, the number of elements on the vector.
Provides offsets and lengths in the vpVec32 array for a name and value pair.
void * vpVecCtor(void *vpMem, aint uiElementSize, aint uiInitialAlloc)
The vector object constructor.
Defines the output data type, location, length and whether or not to preface with a Byte Order Mark (...
u32_phrase * spNotationNames
A list of the Notation names, if any.
aint uiGEDeclsNotProcessed
The number of General Entity declarations not processed because of condition:
The parser's final state.
Information about the Document Type Declaration.
const char * cpUtilUtfTypeName(aint uiType)
Convert a conversion type identifier to a readable, printable ASCII string. Conversion type identifie...
cdata_id sName
The offset (into vpVec32) and length of the name.
A structure to describe the type and location of a caught exception.
void vMemFree(void *vpCtx, const void *vpData)
Free memory previously allocated with vpMemAlloc().
void vXmlSetStartTagCallback(void *vpCtx, pfnStartTagCallback pfnCallback, void *vpUserData)
Set the user's callback function for the start tags (<name attr="10">).
void vMsgsDtor(void *vpCtx)
The object destructor.
uintmax_t luint
luint is used to cast integers suitable for the %"PRIuMAX" printf format.
Information about the XML declaration.
abool bExValidate(exception *spException)
Test an exception structure for validity.
#define UTF_16LE
Data type macro for UTF-16LE encoding/decoding.
void vXmlSetDTDCallback(void *vpCtx, pfnDTDCallback pfnCallback, void *vpUserData)
Set the user's callback function for the Processing Instruction tags(<?target instructions?...
void vConvDecode(void *vpCtx, conv_src *spSrc)
Decode a source byte stream to 32-bit Unicode code points.
abool bExists
True if the DTD exists, false otherwise.
void * vpVecFirst(void *vpCtx)
Get the first element one the vector. The vector is not altered.
void * vpVecPushn(void *vpCtx, void *vpElement, aint uiCount)
Adds one or more elements to the end of the array.
aint uiGEDeclsDeclared
A count of ALL General Entities declared.
Defines the characteristics of a single line.
void * vpMemCtor(exception *spException)
Construct a memory component.
void vXmlSetEndTagCallback(void *vpCtx, pfnEndTagCallback pfnCallback, void *vpUserData)
Set the user's callback function for the end tags (</name>).
line * spLinesNext(void *vpCtx)
Returns the next line of text from the iterator.
void vConvEncode(void *vpCtx, conv_dst *spDst)
Encode the 32-bit Unicode code points to a byte stream.
void(* pfnDTDCallback)(dtd_info *spInfo, void *vpUserData)
Defines the function type that is called after parsing the Document Type Declaration (DTD).
void vXmlDisplayMsgs(void *vpCtx)
Display the parser's messages on stdout, if any.
#define UTF_UNKNOWN
Data type macro for unknown encoding type.
const char * cpVersion
The value of version="1.ddd". Default is 1.0. Any other value is a fatal error.
line * spLinesFirst(void *vpCtx)
Initialize an iterator over the lines.
u32_phrase * spAttTypes
A list of (uiAttListsUnique) types of declared attribute defaults.
void vLinesDtor(void *vpCtx)
The lines object destructor.
void vParserDtor(void *vpCtx)
Clears the parser component's context and frees all heap memory associated with this parser.
void vXmlSetXmlDeclCallback(void *vpCtx, pfnXmlDeclCallback pfnCallback, void *vpUserData)
Set the user's callback function for the XML declaration.
aint uiAttListsUnique
The number of unique and valid Attribute declarations.
#define UTF_8
Data type macro for UTF-8 encoding/decoding.
aint uiDataLen
[out] Number of bytes in the byte stream.
uint8_t abool
abool is the APG bool type.
aint uiElementDecls
The number of element declarations found.
Defines the input data type, location and length.
const char * cpEncoding
If present must be UTF-8 or UTF-16. It is a fatal error if the data is not in the specified format....
#define XMLGRAMMAR_DOCUMENT
aint uiAttListsNotProcessed
The number of Attribute List declarations not processed because of above condition:
abool bStandalone
True if standalone = "yes", false if standalone = "no".
void vXmlSetPICallback(void *vpCtx, pfnPICallback pfnCallback, void *vpUserData)
Set the user's callback function for the Processing Instruction tags(<?target instructions?...
Defines a pointer to an array of 32-bit unsigned integers plus its length. Typically needed by Unicod...
void vXmlDtor(void *vpCtx)
The XML Parser component destructor.
void vConvDtor(void *vpCtx)
Conversion object destructor.
Identifies the element name, attribute name and default attribute value of attribute list declaration...
aint uiPEDecls
The number of Parameter Entities declared.
uint8_t * ucpData
[out] Pointer to the output byte stream. Valid until another function call on the context handle.
void * vpVecPush(void *vpCtx, void *vpElement)
Adds one element to the end of the array.
void(* pfnPICallback)(u32_phrase *spTarget, u32_phrase *spInfo, void *vpUserData)
Defines the function type that is called after a Processing Instruction has been found.
aint uiNotationDecls
The number of notation declarations found.
void vConvUseCodePoints(void *vpCtx, uint32_t *uipSrc, aint uiSrcLen)
Insert a stream of 32-bit Unicode code points as the intermediate data.
struct xml_tag * spXml
A copy of the XML object context pointer. Needed for quick sort and quick look up.
#define BINARY
Alias for ISO_8895_1.
void vVecClear(void *vpCtx)
Clears all used elements in a vector component.
u32_phrase * spGENames
A list of (uiGEDeclsUnique) declared General Entity names, if any.
aint uiCharIndex
The zero-based index of the first character of the line.
#define NOBOM
The "false" macro for destination BOM flag.
void vParserParse(void *vpCtx, parser_config *spConfig, parser_state *spState)
Parse an input string of alphabet characters.
aint uiLinesCount(void *vpCtx)
Returns the number of lines of text.
APG Version 7.0 is licensed under the
2-Clause BSD License,
an Open Source Initiative Approved License.