Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
basics.c
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 * *************************************************************************************/
34 #include "callbacks.h"
35 
36 #define CLOSE_BRACKET 62
37 #define HYPHEN 45
38 
39 static const uint32_t s_uiAmp = 38;
40 static const uint32_t s_uiSemi = 59;
41 static const char* s_cpLineFoundFmt = "line: %2"PRIuMAX" offset: %2"PRIuMAX"(0x%02"PRIXMAX"): %s";
42 static const char* s_cpLineNotFoundFmt = "line: %2"PRIuMAX" offset: %2"PRIuMAX"(0x%02"PRIXMAX")(EOF): %s";
43 
44 /*********************************************************
45  * HELPER FUNCTIONS ++++++++++++++++++++++++++++++++++++++
46  ********************************************************/
47 void vThrowError(xml* spXml, const char* cpMsg, aint uiOffset, unsigned int uiLine, const char* cpFile, const char* cpFunc){
48  aint uiXmlLine, uiRelOffset;
49  char caBuf[CABUF_LEN];
50  if(!bLinesFindLine(spXml->vpLines, uiOffset, &uiXmlLine, & uiRelOffset)){
51  uiXmlLine = uiLinesCount(spXml->vpLines);
52  uiRelOffset = uiLinesLength(spXml->vpLines);
53  snprintf(caBuf, CABUF_LEN, s_cpLineNotFoundFmt,
54  (luint)uiXmlLine, (luint)uiRelOffset, (luint)uiRelOffset, cpMsg);
55  }else{
56  snprintf(caBuf, CABUF_LEN, s_cpLineFoundFmt,
57  (luint)uiXmlLine, (luint)uiRelOffset, (luint)uiRelOffset, cpMsg);
58  }
59  vExThrow(spXml->spException, caBuf, uiLine, cpFile, cpFunc);
60 }
61 void vLogMsg(xml* spXml, aint uiOffset, char* cpTitle){
62  // log an error message noting its location in the document
63  aint uiXmlLine, uiRelOffset;
64  char caBuf[PATH_MAX + CABUF_LEN];
65  size_t uiSize = PATH_MAX + CABUF_LEN;
66  if(bLinesFindLine(spXml->vpLines, uiOffset, &uiXmlLine, &uiRelOffset)){
67  snprintf(caBuf, uiSize, s_cpLineFoundFmt, (luint)uiXmlLine, (luint)uiRelOffset, (luint)uiRelOffset, cpTitle);
68  }else{
69  uiXmlLine = uiLinesCount(spXml->vpLines);
70  uiRelOffset = uiLinesLength(spXml->vpLines);
71  snprintf(caBuf, CABUF_LEN, s_cpLineNotFoundFmt,
72  (luint)uiXmlLine, (luint)uiRelOffset, (luint)uiRelOffset, cpTitle);
73  }
74  vMsgsLog(spXml->vpMsgs, caBuf);
75 }
76 // push an element frame on the stack for each new element opened
77 void vPushFrame(callback_data* spData){
78  xml* spXml = (xml*)spData->vpUserData;
79  spXml->spCurrentFrame = (element_frame*)vpVecPush(spXml->vpVecFrame, NULL);
80  memset((void*)spXml->spCurrentFrame, 0, sizeof(element_frame));
81  spXml->spCurrentFrame->uiBase32 = uiVecLen(spXml->vpVec32);
82  spXml->spCurrentFrame->uiBaseAtt = uiVecLen(spXml->vpVecAttList);
83 }
84 
85 // return remaining number of frames on the stack
86 void vPopFrame(callback_data* spData){
87  xml* spXml = (xml*)spData->vpUserData;
88  if(spXml->spCurrentFrame){
89  vpVecPopi(spXml->vpVec32, spXml->spCurrentFrame->uiBase32);
90  vpVecPopi(spXml->vpVecAttList, spXml->spCurrentFrame->uiBaseAtt);
91  element_frame* spFrame = (element_frame*)vpVecPop(spXml->vpVecFrame);
92  // sanity check
93  if(spFrame != spXml->spCurrentFrame){
94  XML_THROW("popped frame not same as current frame");
95  }
96  spXml->spCurrentFrame = (element_frame*)vpVecLast(spXml->vpVecFrame);
97  }
98 }
99 
100 // convert two UTF-8 bytes to one UTF-32 code point
101 uint32_t ui2byte(const achar* acpBytes){
102  uint32_t uiChar = 0;
103  uiChar = ((uint32_t)acpBytes[0] & 0x1f) << 6;
104  uiChar += (uint32_t)acpBytes[1] & 0x3f;
105  return uiChar;
106 }
107 // convert three UTF-8 bytes to one UTF-32 code point
108 uint32_t ui3byte(const achar* acpBytes){
109  uint32_t uiChar = 0;
110  uiChar = ((uint32_t)acpBytes[0] & 0xf) << 12;
111  uiChar += ((uint32_t)acpBytes[1] & 0x3f) << 6;
112  uiChar += (uint32_t)acpBytes[2] & 0x3f;
113  return uiChar;
114 }
115 // convert four UTF-8 bytes to one UTF-32 code point
116 uint32_t ui4byte(const achar* acpBytes){
117  uint32_t uiChar = 0;
118  uiChar = ((uint32_t)acpBytes[0] & 0x7) << 18;
119  uiChar += ((uint32_t)acpBytes[1] & 0x3f) << 12;
120  uiChar += ((uint32_t)acpBytes[2] & 0x3f) << 6;
121  uiChar += (uint32_t)acpBytes[3] & 0x3f;
122  return uiChar;
123 }
124 abool bValidateChar(uint32_t uiChar){
125  abool bReturn = APG_FALSE;
126  while(APG_TRUE){
127  if(uiChar >= 0 && uiChar < 9){
128  break; // disallowed ASCII control characters
129  }
130  if(uiChar > 10 && uiChar < 13){
131  break; // disallowed ASCII control characters
132  }
133  if(uiChar > 13 && uiChar < 32){
134  break; // disallowed ASCII control characters
135  }
136  if(uiChar >= 0xD800 && uiChar < 0xE000){
137  break; // surrogate pairs block
138  }
139  if(uiChar == 0xFFFE || uiChar == 0xFFFF){
140  break; // Unicode Standard D14
141  // Noncharacter: A code point that is permanently reserved for internal use.
142  }
143  if(uiChar > 0x10FFFF){
144  break; // beyond Unicode range
145  }
146  bReturn = APG_TRUE;
147  break;
148  }
149  return bReturn;
150 }
151 
152 // convert an array of 32-bit code points (XML Chars) to a u32_phrase struct for user consumption
153 // assumes the code points are in the vector vpVeUint
154 // places ASCII strings in the vector vpVecString
155 // string data is transient
156 void vMakeCDataDisplay(xml* spXml, cdata_id* spDataId, u32_phrase* spCData, aint uiOffset){
157  spCData->uiLength = spDataId->uiLength;
158  spCData->uipPhrase = NULL;
159  if(spDataId->uiLength){
160  spCData->uipPhrase = (uint32_t*)vpVecAt(spXml->vpVec32, spDataId->uiOffset);
161  if(!spCData->uipPhrase){
162  vThrowError(spXml, "vector index unexpectedly out of range",
163  uiOffset, __LINE__, __FILE__, __func__);
164  }
165  }
166 }
167 void vMakeCDataIdFromInput(xml* spXml, const achar* acpInput, aint uiLen, aint uiOffset, cdata_id* spCDataId){
168  // get some work space
169  aint uiCheckPoint = uiVecLen(spXml->vpVec8);
170  uint8_t* ucpData = (uint8_t*)vpVecPushn(spXml->vpVec8, NULL, uiLen);
171 
172  // convert from achar to uint8_t
173  aint ui;
174  for(ui = 0; ui < uiLen; ui++){
175  ucpData[ui] = (uint8_t)acpInput[ui];
176  }
177 
178  // decode UTF-8
179  conv_src sSrc = {UTF_8, ucpData, uiLen};
180  vConvDecode(spXml->vpConv, &sSrc);
181 
182  // get a copy of the UTF-32 code points
183  spCDataId->uiOffset = (uint32_t)uiVecLen(spXml->vpVec32);
184  vConvGetCodePoints(spXml->vpConv, NULL, &spCDataId->uiLength);
185  uint32_t* uip32 = (uint32_t*)vpVecPushn(spXml->vpVec32, NULL, spCDataId->uiLength);
186  vConvGetCodePoints(spXml->vpConv, uip32, &spCDataId->uiLength);
187 
188  // restore the work space
189  vpVecPopi(spXml->vpVec8, uiCheckPoint);
190 }
191 // capture a parsed phrase and save it as UTF-32 code points
192 cdata_id sCapturePhrase(xml* spXml, achar* acpPhrase, aint uiPhraseLength, aint uiOffset){
193  cdata_id sId = {uiVecLen(spXml->vpVec32), 0};
194  if(uiPhraseLength){
195 
196  // allocate temporary work space on vpVecUnit8
197  aint uiCheckPoint = uiVecLen(spXml->vpVec8);
198  uint8_t* ucpBuf = (uint8_t*)vpVecPushn(spXml->vpVec8, NULL, uiPhraseLength);
199 
200  // intermediate conversion - convert parsed phrase from achar (the parser's alphabet characters)
201  // to a byte stream.
202  // NOTE: achar may vary from app to app, but the input characters will always be < 256;
203  aint ui;
204  for(ui = 0; ui < uiPhraseLength; ui++){
205  ucpBuf[ui] = (uint8_t)acpPhrase[ui];
206  }
207 
208  // convert the parsed byte stream to UTF-32 code points
209  conv_src sSrc = {UTF_8, ucpBuf, uiPhraseLength};
210  vConvDecode(spXml->vpConv, &sSrc);
211 
212  // allocate space to save the code points in vpVec32
213  vConvGetCodePoints(spXml->vpConv, NULL, &sId.uiLength);
214  uint32_t* uipCode = (uint32_t*)vpVecPushn(spXml->vpVec32, NULL, sId.uiLength);
215 
216  // copy the code points to vpVec32
217  vConvGetCodePoints(spXml->vpConv, uipCode, &sId.uiLength);
218 
219  // release the work space on vpVec8
220  vpVecPopi(spXml->vpVec8, uiCheckPoint);
221  }
222  return sId;
223 }
224 
234 void vConvertParsedData(xml* spXml, const achar* acpData, aint uiDataLen, uint32_t* uipOffset, uint32_t* uipLength){
235  if(!acpData || !uiDataLen){
236  *uipOffset = uiVecLen(spXml->vpVec32);
237  *uipLength = 0;
238  return;
239  }
240  aint ui;
241  conv_src sSrc;
242  uint32_t* uipCodePoints;
243  uint8_t* ucpData = (uint8_t*)acpData;
244  if(sizeof(achar) != sizeof(uint8_t)){
245  vVecClear(spXml->vpVec8);
246  ucpData = (uint8_t*)vpVecPushn(spXml->vpVec8, NULL, uiDataLen);
247  for(ui = 0; ui < uiDataLen; ui++){
248  ucpData[ui] = (uint8_t)acpData[ui];
249  }
250  }
251  sSrc.uiDataType = UTF_8;
252  sSrc.ucpData = ucpData;
253  sSrc.uiDataLen = uiDataLen;
254  vConvDecode(spXml->vpConv, &sSrc);
255  vConvGetCodePoints(spXml->vpConv, NULL, uipLength);
256  *uipOffset = uiVecLen(spXml->vpVec32);
257  uipCodePoints = (uint32_t*)vpVecPushn(spXml->vpVec32, NULL, *uipLength);
258  vConvGetCodePoints(spXml->vpConv, uipCodePoints, uipLength);
259 }
260 /*********************************************************
261  * HELPER FUNCTIONS --------------------------------------
262  ********************************************************/
263 
264 /*********************************************************
265  * COMMENTS ++++++++++++++++++++++++++++++++++++++++++++++
266  ********************************************************/
267 void vDoubleh(callback_data* spData){
268  if(spData->uiParserState == ID_MATCH){
269  xml* spXml = (xml*)spData->vpUserData;
270  XML_THROW("double hyphens ('--' or '--->') not allowed in comments");
271  }
272 }
273 void vComment(callback_data* spData){
274  if(spData->uiParserState == ID_MATCH){
275  xml* spXml = (xml*)spData->vpUserData;
276  if(spXml->pfnCommentCallback){
277  uint8_t* ucpComment = (uint8_t*)spData->acpString + spData->uiParserOffset;
278  if(sizeof(achar) != sizeof(uint8_t)){
279  // convert the alphabet characters to uint8_t bytes
280  vVecClear(spXml->vpVec8);
281  ucpComment = (uint8_t*)vpVecPushn(spXml->vpVec8, NULL, spData->uiParserPhraseLength);
282  aint ui = 0;
283  aint uj = spData->uiParserOffset;
284  for(; ui < spData->uiParserPhraseLength; ui++, uj++){
285  ucpComment[ui] = (uint8_t)spData->acpString[uj];
286  }
287  }
288 
289  // convert the UTF-8 comment to UTF-32
290  conv_src sSrc;
291  sSrc.uiDataType = UTF_8;
292  sSrc.ucpData = ucpComment;
293  sSrc.uiDataLen = spData->uiParserPhraseLength;
294  vConvDecode(spXml->vpConv, &sSrc);
295  aint uiIndex = uiVecLen(spXml->vpVec32);
296  uint32_t uiComLen;
297  vConvGetCodePoints(spXml->vpConv, NULL, &uiComLen);
298  uint32_t* uipCom = (uint32_t*)vpVecPushn(spXml->vpVec32, NULL, uiComLen);
299  vConvGetCodePoints(spXml->vpConv, uipCom, &uiComLen);
300 
301  // make display data and call the user's callback function
302  u32_phrase sComData;
303  cdata_id sComId = {uiIndex, (aint)uiComLen};
304  vMakeCDataDisplay(spXml, &sComId, &sComData, spData->uiParserOffset);
305  spXml->pfnCommentCallback(&sComData, spXml->vpCommentData);
306 
307  // clean up
308  vpVecPopi(spXml->vpVec32, uiIndex);
309  vVecClear(spXml->vpVec8);
310 
311  spData->uiCallbackState = ID_MATCH;
313  }
314  }
315 }
316 // UDT - handwritten comment callback function
317 /*********************************************************
318  * COMMENTS ----------------------------------------------
319  ********************************************************/
320 
321 /*********************************************************
322  * PROCESSING INSTRUCTIONS +++++++++++++++++++++++++++++++
323  ********************************************************/
324 void vPIOpen(callback_data* spData){
325  if(spData->uiParserState == ID_MATCH){
326  // NOTE: Processing Instructions use an element frame.
327  // The PI target is stored in the frame start tage name.
328  // the PI information is store in the frame end tag name
329  vPushFrame(spData);
330  }
331 }
332 void vPIClose(callback_data* spData){
333  xml* spXml = (xml*)spData->vpUserData;
334  if(spData->uiParserState == ID_MATCH){
335  if(spXml->pfnPICallback){
336  u32_phrase sTarget, sInfo;
337  vMakeCDataDisplay(spXml, &spXml->spCurrentFrame->sSName, &sTarget, spData->uiParserOffset);
338  vMakeCDataDisplay(spXml, &spXml->spCurrentFrame->sEName, &sInfo, spData->uiParserOffset);
339  spXml->pfnPICallback(&sTarget, &sInfo, spXml->vpPIData);
340  }
341  vPopFrame(spData);
342  }else if(spData->uiParserState == ID_NOMATCH){
343  XML_THROW("expected close of processing instruction not found");
344  }
345 }
346 void vPITarget(callback_data* spData){
347  if(spData->uiParserState == ID_MATCH){
348  xml* spXml = (xml*)spData->vpUserData;
349  // swap sName and sSName;
350  aint uiLen = uiVecLen(spXml->vpVecName);
351  uint32_t* uipName = (uint32_t*)vpVecFirst(spXml->vpVecName);
352  spXml->spCurrentFrame->sSName.uiOffset = uiVecLen(spXml->vpVec32);
353  spXml->spCurrentFrame->sSName.uiLength = uiLen;
354  vpVecPushn(spXml->vpVec32, (void*)uipName, uiLen);
355  }else if(spData->uiParserState == ID_NOMATCH){
356  xml* spXml = (xml*)spData->vpUserData;
357  XML_THROW("processing instruction target is invalid");
358  }
359 }
360 void vPIInfo(callback_data* spData){
361  if(spData->uiParserState == ID_ACTIVE){
362  xml* spXml = (xml*)spData->vpUserData;
363  spXml->spCurrentFrame->sEName.uiOffset = uiVecLen(spXml->vpVec32);
364  spXml->spCurrentFrame->sEName.uiLength = 0;
365  }
366 }
367 void vPIInfoq(callback_data* spData){
368  if(spData->uiParserState == ID_MATCH){
369  xml* spXml = (xml*)spData->vpUserData;
370  uint32_t uiChars[2] = {63, spXml->uiChar};
371  vpVecPushn(spXml->vpVec32, uiChars, 2);
372  spXml->spCurrentFrame->sEName.uiLength += 2;
373  }
374 }
375 //static void vPIInfo8(callback_data* spData){} same as vPIInfoa
376 void vPIInfoa(callback_data* spData){
377  if(spData->uiParserState == ID_MATCH){
378  xml* spXml = (xml*)spData->vpUserData;
379  vpVecPush(spXml->vpVec32, &spXml->uiChar);
380  spXml->spCurrentFrame->sEName.uiLength += 1;
381  }
382 }
384  if(spData->uiParserState == ID_MATCH){
385  xml* spXml = (xml*)spData->vpUserData;
386  XML_THROW("Processing Instruction name \"xml\" is forbidden - see https://www.w3.org/XML/xml-V10-5e-errata");
387  }
388 }
390  if(spData->uiParserState == ID_MATCH){
391  xml* spXml = (xml*)spData->vpUserData;
392  XML_THROW("Processing Instruction names beginning with \"xml-\" are reserved - see https://www.w3.org/XML/xml-V10-5e-errata");
393  }
394 }
395 /*********************************************************
396  * PROCESSING INSTRUCTIONS -------------------------------
397  ********************************************************/
398 
399 /*********************************************************
400  * BASICS ++++++++++++++++++++++++++++++++++++++++++++++++
401  ********************************************************/
402 void vAscii(callback_data* spData){
403  if(spData->uiParserState == ID_MATCH){
404  xml* spXml = (xml*)spData->vpUserData;
405  spXml->uiChar = (uint32_t)spData->acpString[spData->uiParserOffset];
406  }
407 }
408 void vUtf82(callback_data* spData){
409  if(spData->uiParserState == ID_MATCH){
410  xml* spXml = (xml*)spData->vpUserData;
411  spXml->uiChar = ui2byte(&spData->acpString[spData->uiParserOffset]);
412  }
413 }
414 void vUtf83(callback_data* spData){
415  if(spData->uiParserState == ID_MATCH){
416  xml* spXml = (xml*)spData->vpUserData;
417  spXml->uiChar = ui3byte(&spData->acpString[spData->uiParserOffset]);
418  }
419 }
420 void vUtf84(callback_data* spData){
421  if(spData->uiParserState == ID_MATCH){
422  xml* spXml = (xml*)spData->vpUserData;
423  spXml->uiChar = ui4byte(&spData->acpString[spData->uiParserOffset]);
424  }
425 }
426 void vName(callback_data* spData){
427  xml* spXml = (xml*)spData->vpUserData;
428  if(spData->uiParserState == ID_ACTIVE){
429  vVecClear(spXml->vpVecName);
430  }
431 }
433  if(spData->uiParserState == ID_MATCH){
434  xml* spXml = (xml*)spData->vpUserData;
435 
436  // validate - must be in range
437  // https://www.w3.org/TR/REC-xml/
438  // Extensible Markup Language (XML) 1.0 (Fifth Edition)
439  // W3C Recommendation 26 November 2008
440  // [4] NameStartChar
441  // ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] |
442  //[#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] |
443  //[#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
444  aint uiFound = APG_TRUE;
445  uint32_t ui = spXml->uiChar;
446  while(APG_TRUE){
447  if(ui >= 65 && ui <= 90){
448  break;
449  }
450  if(ui >= 97 && ui <= 122){
451  break;
452  }
453  if(ui == 58 || ui == 95){
454  break;
455  }
456  if(ui >= 0xC0 && ui <= 0xD6){
457  break;
458  }
459  if(ui >= 0xD8 && ui <= 0xF6){
460  break;
461  }
462  if(ui >= 0xF8 && ui <= 0x2FF){
463  break;
464  }
465  if(ui >= 0x370 && ui <= 0x37D){
466  break;
467  }
468  if(ui >= 0x37F && ui <= 0x1FFF){
469  break;
470  }
471  if(ui >= 0x200C && ui <= 0x200D){
472  break;
473  }
474  if(ui >= 0x2070 && ui <= 0x218F){
475  break;
476  }
477  if(ui >= 0x2C00 && ui <= 0x2FEF){
478  break;
479  }
480  if(ui >= 0x3001 && ui <= 0xD7FF){
481  break;
482  }
483  if(ui >= 0xF900 && ui <= 0xFDCF){
484  break;
485  }
486  if(ui >= 0xFDF0 && ui <= 0xFFFD){
487  break;
488  }
489  if(ui >= 0x10000 && ui <= 0xEFFFF){
490  break;
491  }
492  uiFound = APG_FALSE;
493  break;
494  }
495  if(uiFound){
496  vpVecPush(spXml->vpVecName, &spXml->uiChar);
497  }else{
498  // Name fails because first character is not a NameStartChar
499  spData->uiCallbackState = ID_NOMATCH;
500  }
501  }
502 }
504  if(spData->uiParserState == ID_MATCH){
505  xml* spXml = (xml*)spData->vpUserData;
506 
507  // validate
508  // | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
509  // https://www.w3.org/TR/REC-xml/
510  // Extensible Markup Language (XML) 1.0 (Fifth Edition)
511  // W3C Recommendation 26 November 2008
512  // [4a] NameChar
513  aint uiFound = APG_TRUE;
514  uint32_t ui = spXml->uiChar;
515  while(APG_TRUE){
516  if(ui >= 48 && ui <= 57){
517  break;
518  }
519  if(ui == 45 || ui == 46){
520  break;
521  }
522 
523  if(ui == 0xB7){
524  break;
525  }
526  if(ui >= 0x300 && ui <= 0x36F){
527  break;
528  }
529  if(ui >= 0x203F && ui <= 0x2040){
530  break;
531  }
532  uiFound = APG_FALSE;
533  break;
534  }
535  if(uiFound){
536  vpVecPush(spXml->vpVecName, &spXml->uiChar);
537  }else{
538  // note a valid name char
539  spData->uiCallbackState = ID_NOMATCH;
540  }
541  }
542 }
543 
544 uint32_t uiHexValue32(xml* spXml, aint uiOffset, uint32_t* uipChars, uint32_t uiCount){
545  uint32_t ui;
546  uint32_t uiSum = 0;
547  uint32_t uiDigit = 0;
548  char caBuf[CABUF_LEN];
549  for(ui = 0; ui < uiCount; ui++){
550  if(uipChars[ui] >= 48 && uipChars[ui] <= 57){
551  uiDigit = uipChars[ui] - 48;
552  }else if(uipChars[ui] >= 65 && uipChars[ui] <= 70){
553  uiDigit = uipChars[ui] - 55;
554  }else if(uipChars[ui] >= 97 && uipChars[ui] <= 102){
555  uiDigit = uipChars[ui] - 87;
556  }else{
557  snprintf(caBuf, CABUF_LEN, "illegal hex digit in Reference: %c", (char)uipChars[ui]);
558  vThrowError(spXml, caBuf,
559  uiOffset, __LINE__, __FILE__, __func__);
560  }
561  if(!bMultiply32(uiSum, 16, &uiSum)){
562  vThrowError(spXml, "decimal value in Reference is too large: causes uint32_t overflow",
563  uiOffset, __LINE__, __FILE__, __func__);
564  }
565  if(!bSum32(uiSum, uiDigit, &uiSum)){
566  vThrowError(spXml, "decimal value in Reference is too large: causes uint32_t overflow",
567  uiOffset, __LINE__, __FILE__, __func__);
568  }
569  }
570  if(!bValidateChar(uiSum)){
571  char caBuf[CABUF_LEN];
572  snprintf(caBuf, CABUF_LEN, "Well-formedness Constraint: Legal Character\n"
573  "Characters referred to using character references MUST match the production for Char\n"
574  "https://www.w3.org/TR/REC-xml/#sec-references\n"
575  "hex character: 0x%X", uiSum);
576  vThrowError(spXml, caBuf,
577  uiOffset, __LINE__, __FILE__, __func__);
578  }
579  return uiSum;
580 }
581 uint32_t uiDecValue32(xml* spXml, aint uiOffset, uint32_t* uipChars, uint32_t uiCount){
582  uint32_t ui, uiSum, uiDigit;
583  uiSum = 0;
584  for(ui = 0; ui < uiCount; ui++){
585  uiDigit = uipChars[ui] - 48;
586  if(!bMultiply32(uiSum, 10, &uiSum)){
587  vThrowError(spXml, "decimal value in Reference is too large: causes uint32_t overflow",
588  uiOffset, __LINE__, __FILE__, __func__);
589  }
590  if(!bSum32(uiSum, uiDigit, &uiSum)){
591  vThrowError(spXml, "decimal value in Reference is too large: causes uint32_t overflow",
592  uiOffset, __LINE__, __FILE__, __func__);
593  }
594  }
595  if(!bValidateChar(uiSum)){
596  char caBuf[CABUF_LEN];
597  snprintf(caBuf, CABUF_LEN, "Well-formedness Constraint: Legal Character\n"
598  "Characters referred to using character references MUST match the production for Char\n"
599  "https://www.w3.org/TR/REC-xml/#sec-references\n"
600  "decimal character: %u", uiSum);
601  vThrowError(spXml, caBuf,
602  uiOffset, __LINE__, __FILE__, __func__);
603  }
604  return uiSum;
605 }
606 att_decl* spLeftMostElement(xml* spXml, att_decl* spAttList){
607  att_decl* spReturn = NULL;
608  att_decl* spNamed = (att_decl*)vpVecFirst(spXml->vpVecAttDecls);
609  aint uiCount = uiVecLen(spXml->vpVecAttDecls);
610  att_decl* spAm;
611  aint uiL, uiR, uiM;
612  int i;
613  if(spNamed && uiCount){
614  uint32_t* uipChar32 = (uint32_t*)vpVecFirst(spXml->vpVec32);
615  uint32_t* uipName = uipChar32 + spAttList->sElementName.uiOffset;
616  uint32_t uiNameLen = spAttList->sElementName.uiLength;
617  uiL = 0;
618  uiR = uiCount;
619  while(uiL < uiR){
620  uiM = uiL + (uiR - uiL)/2;
621  spAm = &spNamed[uiM];
622  i = iCompNames(&uipChar32[spAm->sElementName.uiOffset], spAm->sElementName.uiLength, uipName, uiNameLen);
623  if(i < 0){
624  uiL = uiM + 1;
625  }else{
626  uiR = uiM;
627  }
628  }
629  if((uiL < uiCount)){
630  spAm = &spNamed[uiL];
631  i = iCompNames(&uipChar32[spAm->sElementName.uiOffset], spAm->sElementName.uiLength, uipName, uiNameLen);
632  if( i == 0){
633  spReturn = spAm;
634  }
635  }
636  }
637  return spReturn;
638 }
645 entity_decl* spEntityNameLookup(xml* spXml, aint uiOffset, uint32_t* uipName, uint32_t uiNameLen){
646  entity_decl* spReturn = NULL;
647  entity_decl* spNamed = (entity_decl*)vpVecFirst(spXml->vpVecGEDefs);
648  aint uiCount = uiVecLen(spXml->vpVecGEDefs);
649  entity_decl* spAm;
650  aint uiL, uiR, uiM;
651  int i;
652  if(spNamed && uiCount){
653  uint32_t* uipChar32 = (uint32_t*)vpVecFirst(spXml->vpVec32);
654  uiL = 0;
655  uiR = uiCount;
656  while(uiL < uiR){
657  uiM = uiL + (uiR - uiL)/2;
658  spAm = &spNamed[uiM];
659  i = iCompNames(&uipChar32[spAm->sName.uiOffset], spAm->sName.uiLength, uipName, uiNameLen);
660  if(i < 0){
661  uiL = uiM + 1;
662  }else{
663  uiR = uiM;
664  }
665  }
666  if((uiL < uiCount)){
667  spAm = &spNamed[uiL];
668  i = iCompNames(&uipChar32[spAm->sName.uiOffset], spAm->sName.uiLength, uipName, uiNameLen);
669  if( i == 0){
670  spReturn = spAm;
671  }
672  }
673  }
674  return spReturn;
675 }
676 abool bCompNames(const uint32_t* uipLName, uint32_t uiLLen, const uint32_t* uipRName, uint32_t uiRLen){
677  if(0 == iCompNames(uipLName, uiLLen, uipRName, uiRLen)){
678  return APG_TRUE;
679  }
680  return APG_FALSE;
681 }
682 cdata_id sNormalizeAttributeValue(xml* spXml, aint uiOffset, uint32_t* uipAttValue, uint32_t uiLength, abool bIsCDATA){
683  cdata_id sReturn = {};
684  uint32_t* uipData, *uipDataEnd;;
685  vVecClear(spXml->vpVecAttWork);
686  uint32_t ui, uiInc, uiChar, uiLastChar, uiRef;
687  uint32_t uiSp = 32;
688  ui = 0;
689  uiInc = 0;
690  while(ui < uiLength){
691  if(uipAttValue[ui] == ATT_AMP){
692  for(uiInc = ui + 1; uiInc < uiLength; uiInc++){
693  if(uipAttValue[uiInc] == ATT_SEMI){
694  goto found;
695  } }
696  vThrowError(spXml, "attribute value has & (begins character or entity reference) with no closing ;",
697  uiOffset, __LINE__, __FILE__, __func__);
698  found:;
699  if(uipAttValue[ui+1] == ATT_HASH){
700  if(uipAttValue[ui+2] == ATT_X){
701  // handle hex ref
702  uiRef = ui + 3;
703  uiChar = uiHexValue32(spXml, uiOffset, &uipAttValue[uiRef], uiInc-uiRef);
704  }else{
705  //handle dec ref
706  uiRef = ui + 2;
707  uiChar = uiDecValue32(spXml, uiOffset, &uipAttValue[uiRef], uiInc-uiRef);
708  }
709  vpVecPush(spXml->vpVecAttWork, &uiChar);
710  }else{
711  // handle entity ref
712  uiRef = ui + 1;
713  entity_decl* spEntity = spEntityNameLookup(spXml, uiOffset, &uipAttValue[uiRef], uiInc-uiRef);
714  if(!spEntity){
715  vThrowError(spXml, "undeclared entity name in attribute list value",
716  uiOffset, __LINE__, __FILE__, __func__);
717  }
718  if(!spEntity->bExpanded){
719  vExpandEntity(spXml, uiOffset, spEntity);
720  }
721  uipData = (uint32_t*)vpVecPushn(spXml->vpVecAttWork, vpVecAt(spXml->vpVec32, spEntity->sValue.uiOffset),
722  spEntity->sValue.uiLength);
723  uipDataEnd = uipData + spEntity->sValue.uiLength;
724  for(; uipData < uipDataEnd; uipData++){
725  if(*uipData == 9 || *uipData == 10 || *uipData == 13){
726  *uipData = 32;
727  }
728  }
729  }
730  ui = uiInc + 1;
731  }else{
732  // handle char
733  uiChar = uipAttValue[ui++];
734  if(uiChar == 9 || uiChar == 10 || uiChar == 13){
735  vpVecPush(spXml->vpVecAttWork, &uiSp);
736  }else{
737  vpVecPush(spXml->vpVecAttWork, &uiChar);
738  }
739  }
740  }
741  // check for <
742  uipData = vpVecFirst(spXml->vpVecAttWork);
743  uiInc = (uint32_t)uiVecLen(spXml->vpVecAttWork);
744  for(ui = 0; ui < uiInc; ui ++){
745  if(uipData[ui] == 60){
746  vLogMsg(spXml, uiOffset, "Well-formedness constraint: No \"<\" in Attribute Values\n"
747  "The replacement text of any entity referred to directly or indirectly in an attribute value MUST NOT contain a <.");
748  break;
749  }
750  }
751  //replace attribute value with normalized value in work vector
752  if(bIsCDATA){
753  // copy as is
754  sReturn.uiOffset = (uint32_t)uiVecLen(spXml->vpVec32);
755  sReturn.uiLength = (uint32_t)uiVecLen(spXml->vpVecAttWork);
756  vpVecPushn(spXml->vpVec32, vpVecFirst(spXml->vpVecAttWork), uiVecLen(spXml->vpVecAttWork));
757  return sReturn;
758  }
759  // Not CDATA: therefore remove leading, trailing and multiple interior whitespace
760  // (set white space to remove to zero (0 is not a valid XML character), then skip zeros when copying
761  uint32_t* uipChar = (uint32_t*)vpVecFirst(spXml->vpVecAttWork);
762  uint32_t* uipEnd = uipChar + (uint32_t)uiVecLen(spXml->vpVecAttWork);
763  uint32_t uiState = STATE_BEGIN;
764  for(; uipChar < uipEnd; uipChar++){
765  if(uiState == STATE_BEGIN){
766  if(*uipChar == 32){
767  *uipChar = 0;
768  }else{
769  uiState = STATE_TEXT;
770  }
771  }else if(uiState == STATE_TEXT){
772  if(*uipChar == 32){
773  uiState = STATE_WSP;
774  }
775  }else if(uiState == STATE_WSP){
776  if(*uipChar == 32){
777  *uipChar = 0;
778  }else{
779  uiState = STATE_TEXT;
780  }
781  }else{
782  // error
783  vThrowError(spXml, "attribute value normalization: should never get here",
784  uiOffset, __LINE__, __FILE__, __func__);
785  }
786  }
787 
788  // remove excess white space (leading, trailing and multiple occurrences in between)
789  uipChar = (uint32_t*)vpVecFirst(spXml->vpVecAttWork);
790  uiLength = (uint32_t)uiVecLen(spXml->vpVecAttWork);
791  sReturn.uiOffset = (uint32_t)uiVecLen(spXml->vpVec32);
792  sReturn.uiLength = 0;
793  uiLastChar = 0;
794  for(ui = 0; ui < uiLength; ui++){
795  uiChar = uipChar[ui];
796  if(uiChar != 0){
797  vpVecPush(spXml->vpVec32, &uiChar);
798  sReturn.uiLength++;
799  uiLastChar = uiChar;
800  }
801  }
802  if(uiLastChar == 32){
803  vpVecPop(spXml->vpVec32);
804  sReturn.uiLength--;
805  }
806  return sReturn;
807 }
808 int iAttComp(const void* vpL, const void* vpR){
809  const att_decl* spLeft = (att_decl*)vpL;
810  const att_decl* spRight = (att_decl*)vpR;
811  uint32_t uiLen = spLeft->sElementName.uiLength < spRight->sElementName.uiLength ?
812  spLeft->sElementName.uiLength : spRight->sElementName.uiLength;
813  uint32_t ui = 0;
814  uint32_t *uipLeft = (uint32_t*)vpVecFirst(spLeft->spXml->vpVec32) + spLeft->sElementName.uiOffset;
815  uint32_t *uipRight = (uint32_t*)vpVecFirst(spLeft->spXml->vpVec32) + spRight->sElementName.uiOffset;
816  for(; ui < uiLen; ui++){
817  if(uipLeft[ui] < uipRight[ui]){
818  return -1;
819  }
820  if(uipLeft[ui] > uipRight[ui]){
821  return 1;
822  }
823  }
824  if(spLeft->sElementName.uiLength < spRight->sElementName.uiLength){
825  return -1;
826  }
827  if(spLeft->sElementName.uiLength > spRight->sElementName.uiLength){
828  return 1;
829  }
830  return 0;
831 }
832 int iEntityComp(const void* vpL, const void* vpR){
833  const entity_decl* spLeft = (entity_decl*)vpL;
834  const entity_decl* spRight = (entity_decl*)vpR;
835  uint32_t uiLen = spLeft->sName.uiLength < spRight->sName.uiLength ? spLeft->sName.uiLength : spRight->sName.uiLength;
836  uint32_t ui = 0;
837  uint32_t *uipLeft = (uint32_t*)vpVecFirst(spLeft->spXml->vpVec32) + spLeft->sName.uiOffset;
838  uint32_t *uipRight = (uint32_t*)vpVecFirst(spLeft->spXml->vpVec32) + spRight->sName.uiOffset;
839  for(; ui < uiLen; ui++){
840  if(uipLeft[ui] < uipRight[ui]){
841  return -1;
842  }
843  if(uipLeft[ui] > uipRight[ui]){
844  return 1;
845  }
846  }
847  if(spLeft->sName.uiLength < spRight->sName.uiLength){
848  return -1;
849  }
850  if(spLeft->sName.uiLength > spRight->sName.uiLength){
851  return 1;
852  }
853  return 0;
854 }
855 void vExpandEntity(xml* spXml, aint uiOffset, entity_decl* spThisEntity){
856  if(!spThisEntity->bExpanded){
857  uint32_t* uipChars32, *uipTemp;
858  entity_frame* spFrame = NULL;
859  uint32_t uiEntityOffset, uiEntityLength;
860  uint32_t uiFromOffset, uiRemainingChars, uiCopyChars;
861  uint32_t ui;
862  aint uiFrames, uiReplacementBegin;
863  entity_decl* spEntityFound;
864  uiFromOffset = spThisEntity->sValue.uiOffset;
865  uiRemainingChars = spThisEntity->sValue.uiLength;
866  uipChars32 = (uint32_t*)vpVecFirst(spXml->vpVec32);
867  while(bHasEntity(&uipChars32[uiFromOffset], uiRemainingChars, &uiEntityOffset, &uiEntityLength)){
868  // look up the name and make sure it has been declared
869  spEntityFound = spEntityNameLookup(spXml, uiOffset,
870  &uipChars32[uiFromOffset + uiEntityOffset + 1], (uiEntityLength - 2));
871  if(!spEntityFound){
872  vThrowError(spXml, "General Entity refers to undeclared entity",
873  spThisEntity->uiInputOffset, __LINE__, __FILE__, __func__);
874  }
875  // see if it is referring to itself indirectly
876  uiFrames = uiVecLen(spXml->vpVecEntityFrames);
877  if(uiFrames > 1){
878  entity_frame* spParent = (entity_frame*)vpVecFirst(spXml->vpVecEntityFrames);
879  entity_frame* spEnd = spParent + uiFrames - 1;
880  for(; spParent < spEnd; spParent++){
881  if(spParent->uiNameOffset == spThisEntity->sName.uiOffset){
882  vThrowError(spXml, "General Entity refers to itself indirectly",
883  spThisEntity->uiInputOffset, __LINE__, __FILE__, __func__);
884  }
885  }
886  }
887  if(!spFrame){
888  // push a frame on the stack for this entity expansion
889  spFrame = (entity_frame*)vpVecPush(spXml->vpVecEntityFrames, NULL);
890  spFrame->uiNameOffset = spThisEntity->sName.uiOffset;
891  uiReplacementBegin = uiVecLen(spXml->vpVec32);
892  }
893  // copy the prefix
894  if(uiEntityOffset){
895  uipTemp = (uint32_t*)vpVecPushn(spXml->vpVec32, NULL, uiEntityOffset);
896  uipChars32 = (uint32_t*)vpVecFirst(spXml->vpVec32);
897  for(ui = 0; ui < uiEntityOffset; ui++){
898  uipTemp[ui] = uipChars32[uiFromOffset + ui];
899  }
900  }
901 
902  // update the "copy from" info to just past the found entity - ready to search for another
903  uiCopyChars = uiEntityOffset + uiEntityLength;
904  uiFromOffset += uiCopyChars;
905  uiRemainingChars = (uiCopyChars < uiRemainingChars) ? (uiRemainingChars - uiCopyChars) : 0;
906  if(spEntityFound->bExpanded){
907  // it has been expanded, just use it
908  uiCopyChars = spEntityFound->sValue.uiLength;
909  uipTemp = (uint32_t*)vpVecPushn(spXml->vpVec32, NULL, uiCopyChars);
910  uipChars32 = (uint32_t*)vpVecFirst(spXml->vpVec32);
911  for(ui = 0; ui < uiCopyChars; ui++){
912  uipTemp[ui] = uipChars32[spEntityFound->sValue.uiOffset + ui];
913  }
914  }else if(bHasEntity(&uipChars32[spEntityFound->sValue.uiOffset],
915  spEntityFound->sValue.uiLength, &uiEntityOffset, &uiEntityLength)){
916  // expand the found entity (note that its expanded value will be put at the end of our work so far)
917  vExpandEntity(spXml, uiOffset, spEntityFound);
918  }else{
919  // just copy the entity from its original place to here
920  spEntityFound->bExpanded = APG_TRUE;
921  uiEntityOffset = spEntityFound->sValue.uiOffset;
922  uiEntityLength = spEntityFound->sValue.uiLength;
923  uipTemp = (uint32_t*)vpVecPushn(spXml->vpVec32, NULL, uiEntityLength);
924  uipChars32 = (uint32_t*)vpVecFirst(spXml->vpVec32);
925  for(ui = 0; ui < uiEntityLength; ui++){
926  uipTemp[ui] = uipChars32[uiEntityOffset + ui];
927  }
928  }
929  }
930  if(spFrame){
931  // copy the tail
932  if(uiRemainingChars){
933  uipTemp = (uint32_t*)vpVecPushn(spXml->vpVec32, NULL, uiRemainingChars);
934  uipChars32 = (uint32_t*)vpVecFirst(spXml->vpVec32);
935  for(ui = 0; ui < uiRemainingChars; ui++){
936  uipTemp[ui] = uipChars32[uiFromOffset + ui];
937  }
938  }
939  spThisEntity->sValue.uiOffset = uiReplacementBegin;
940  spThisEntity->sValue.uiLength = (uint32_t)uiVecLen(spXml->vpVec32) - uiReplacementBegin;
941  vpVecPop(spXml->vpVecEntityFrames);
942  }
943  spThisEntity->bExpanded = APG_TRUE;
944  }
945 }
946 abool bHasEntity(uint32_t* uipChars, uint32_t uiLen, uint32_t* uipEntityOffset, uint32_t* uipEntityLen){
947  abool bReturn = APG_FALSE;
948  uint32_t ui = 0;
949  uint32_t uiFoundLen = 0;
950  *uipEntityOffset = 0;
951  for(; ui < uiLen; ui++){
952  if(uipChars[ui] == s_uiAmp){
953  *uipEntityOffset = ui;
954  uiFoundLen = 0;
955  }
956  if(uipChars[ui] == s_uiSemi){
957  bReturn = APG_TRUE;
958  uiFoundLen++;
959  goto found;
960  }
961  uiFoundLen++;
962  }
963  uiFoundLen = 0;
964  found:;
965  *uipEntityLen = uiFoundLen;
966  return bReturn;
967 
968 }
969 int iCompNames(const uint32_t* uipLName, uint32_t uiLLen, const uint32_t* uipRName, uint32_t uiRLen){
970  uint32_t uiLen = (uiLLen < uiRLen) ? uiLLen : uiRLen;
971  uint32_t ui = 0;
972  for(; ui < uiLen; ui++){
973  if(uipLName[ui] < uipRName[ui]){
974  return -1;
975  }
976  if(uipLName[ui] > uipRName[ui]){
977  return 1;
978  }
979  }
980  if(uiLLen < uiRLen){
981  return -1;
982  }
983  if(uiLLen > uiRLen){
984  return 1;
985  }
986  return 0;
987 }
988 
989 /*********************************************************
990  * BASICS ------------------------------------------------
991  ********************************************************/
992 
993 void vXmlgrammarRuleCallbacks(void* vpParserCtx){
994  aint ui;
996  memset((void*)cb, 0, sizeof(cb));
1000  cb[XMLGRAMMAR_ANOTLA] = vAscii;
1001  cb[XMLGRAMMAR_ANOTQ] = vAscii;
1002  cb[XMLGRAMMAR_ASCII] = vAscii;
1003  cb[XMLGRAMMAR_ANOTPAQ] = vAscii;
1004  cb[XMLGRAMMAR_ANOTPAA] = vAscii;
1006  cb[XMLGRAMMAR_ANOTRB] = vAscii;
1014  cb[XMLGRAMMAR_ATTDEF] = vAttDef;
1019  cb[XMLGRAMMAR_CDEND] = vCDEnd;
1020  cb[XMLGRAMMAR_CDRB] = vCDRb;
1021  cb[XMLGRAMMAR_CD2RB] = vCD2Rb;
1034  cb[XMLGRAMMAR_DCHAR] = vDChar;
1035  cb[XMLGRAMMAR_DVALUE] = vDvalue;
1039  cb[XMLGRAMMAR_ENCDEF] = vEncDef;
1041  cb[XMLGRAMMAR_EOPEN] = vEOpen;
1043  cb[XMLGRAMMAR_ESTART] = vEStart;
1053  cb[XMLGRAMMAR_GEREF] = vGERef;
1057  cb[XMLGRAMMAR_NAME] = vName;
1064  cb[XMLGRAMMAR_PEDEF] = NULL;
1071  cb[XMLGRAMMAR_PIINFO] = vPIInfo;
1073  cb[XMLGRAMMAR_PIINFOCHAR] = NULL;
1075  cb[XMLGRAMMAR_PIOPEN] = vPIOpen;
1082  cb[XMLGRAMMAR_SCHAR] = vDChar;
1083  cb[XMLGRAMMAR_SVALUE] = vDvalue;
1084  cb[XMLGRAMMAR_UTF82] = vUtf82;
1085  cb[XMLGRAMMAR_UTF83] = vUtf83;
1086  cb[XMLGRAMMAR_UTF84] = vUtf84;
1091 
1092  for(ui = 0; ui < (aint)RULE_COUNT_XMLGRAMMAR; ui++){
1093  vParserSetRuleCallback(vpParserCtx, ui, cb[ui]);
1094  }
1095 }
vGEDefEx
void vGEDefEx(callback_data *spData)
Definition: declarations.c:447
vMsgsLog
void vMsgsLog(void *vpCtx, const char *cpMsg)
Logs a message.
Definition: msglog.c:141
XMLGRAMMAR_GEREF
#define XMLGRAMMAR_GEREF
Definition: xmlgrammar.h:128
vGEDeclClose
void vGEDeclClose(callback_data *spData)
Definition: declarations.c:454
conv_src::uiDataType
aint uiDataType
One of the encoding type identifiers, UTF_8, etc. If or'ed (|) with BASE64, the source data stream is...
Definition: conv.h:110
vThrowError
void vThrowError(xml *spXml, const char *cpMsg, aint uiOffset, unsigned int uiLine, const char *cpFile, const char *cpFunc)
Definition: basics.c:47
vNotationClose
void vNotationClose(callback_data *spData)
Definition: declarations.c:710
xml_tag::vpVec32
void * vpVec32
A 32-bit work vector of all most parsed data, names, attributes and content.
Definition: xmlp.h:135
XMLGRAMMAR_NAMESTARTCHAR
#define XMLGRAMMAR_NAMESTARTCHAR
Definition: xmlgrammar.h:139
XMLGRAMMAR_ANOTAPOS
#define XMLGRAMMAR_ANOTAPOS
Definition: xmlgrammar.h:39
vAttlistClose
void vAttlistClose(callback_data *spData)
Definition: declarations.c:666
XMLGRAMMAR_PEDECLOPEN
#define XMLGRAMMAR_PEDECLOPEN
Definition: xmlgrammar.h:151
entity_frame
Definition: xmlp.h:107
vRefClose
void vRefClose(callback_data *spData)
Definition: declarations.c:737
XMLGRAMMAR_SDECLOTHER
#define XMLGRAMMAR_SDECLOTHER
Definition: xmlgrammar.h:176
XMLGRAMMAR_EXTSUBSET
#define XMLGRAMMAR_EXTSUBSET
Definition: xmlgrammar.h:120
vExpandEntity
void vExpandEntity(xml *spXml, aint uiOffset, entity_decl *spThisEntity)
Definition: basics.c:855
vXmlDeclOpen
void vXmlDeclOpen(callback_data *spData)
Definition: declarations.c:69
bHasEntity
abool bHasEntity(uint32_t *uipChars, uint32_t uiLen, uint32_t *uipEntityOffset, uint32_t *uipEntityLen)
Definition: basics.c:946
XMLGRAMMAR_EXTERNALID
#define XMLGRAMMAR_EXTERNALID
Definition: xmlgrammar.h:117
vGERef
void vGERef(callback_data *spData)
Definition: declarations.c:513
vDvalue
void vDvalue(callback_data *spData)
Definition: elements.c:194
cdata_id::uiLength
uint32_t uiLength
The number of 32-bit data characters.
Definition: xmlp.h:44
vEncName
void vEncName(callback_data *spData)
Definition: declarations.c:180
vDChar
void vDChar(callback_data *spData)
Definition: elements.c:200
XMLGRAMMAR_GEDECLCLOSE
#define XMLGRAMMAR_GEDECLCLOSE
Definition: xmlgrammar.h:122
vNameStartChar
void vNameStartChar(callback_data *spData)
Definition: basics.c:432
STATE_BEGIN
#define STATE_BEGIN
Definition: callbacks.h:44
XMLGRAMMAR_CONTENTREF
#define XMLGRAMMAR_CONTENTREF
Definition: xmlgrammar.h:78
ui2byte
uint32_t ui2byte(const achar *acpBytes)
Definition: basics.c:101
XMLGRAMMAR_ENCNAME
#define XMLGRAMMAR_ENCNAME
Definition: xmlgrammar.h:102
callback_data::uiParserOffset
aint uiParserOffset
[read only] Offset from acpString to the first character to match
Definition: parser.h:160
XMLGRAMMAR_CHARDATA
#define XMLGRAMMAR_CHARDATA
Definition: xmlgrammar.h:71
vSDeclNo
void vSDeclNo(callback_data *spData)
Definition: declarations.c:207
vPopFrame
void vPopFrame(callback_data *spData)
Definition: basics.c:86
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
callback_data::acpString
const achar * acpString
[read only] Pointer to the input sub-string,
Definition: parser.h:156
bCompNames
abool bCompNames(const uint32_t *uipLName, uint32_t uiLLen, const uint32_t *uipRName, uint32_t uiRLen)
Definition: basics.c:676
vAttType
void vAttType(callback_data *spData)
Definition: declarations.c:575
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
u32_phrase::uiLength
uint32_t uiLength
The number of integers in the array.
Definition: lib.h:75
xml
This is the encapsulated data for the xml component. The component context or handle is an opaque poi...
callback_data::uiParserState
aint uiParserState
[read only] ID_ACTIVE if the parser is going down the tree. ID_MATCH or ID_NOMATCH if coming up the t...
Definition: parser.h:158
XMLGRAMMAR_PIINFOQ
#define XMLGRAMMAR_PIINFOQ
Definition: xmlgrammar.h:162
uiLinesLength
aint uiLinesLength(void *vpCtx)
Returns the number of text characters.
Definition: lines.c:218
XMLGRAMMAR_CLOSEQUOT
#define XMLGRAMMAR_CLOSEQUOT
Definition: xmlgrammar.h:75
XMLGRAMMAR_ANOTLA
#define XMLGRAMMAR_ANOTLA
Definition: xmlgrammar.h:42
vSDeclOther
void vSDeclOther(callback_data *spData)
Definition: declarations.c:194
vHexValue
void vHexValue(callback_data *spData)
Definition: elements.c:259
bLinesFindLine
abool bLinesFindLine(void *vpCtx, aint uiOffset, aint *uipLine, aint *uipRelOffset)
Find the line that the given character is in.
Definition: lines.c:146
XMLGRAMMAR_REFCLOSE
#define XMLGRAMMAR_REFCLOSE
Definition: xmlgrammar.h:170
vUtf82
void vUtf82(callback_data *spData)
Definition: basics.c:408
XMLGRAMMAR_UTF82
#define XMLGRAMMAR_UTF82
Definition: xmlgrammar.h:188
achar
uint_fast8_t achar
achar is the type for the parser's alphabet characters.
Definition: apg.h:91
vUtf83
void vUtf83(callback_data *spData)
Definition: basics.c:414
XMLGRAMMAR_ATTTYPE
#define XMLGRAMMAR_ATTTYPE
Definition: xmlgrammar.h:62
vCharData
void vCharData(callback_data *spData)
Definition: elements.c:341
XMLGRAMMAR_ATTLISTVALUE
#define XMLGRAMMAR_ATTLISTVALUE
Definition: xmlgrammar.h:59
vPushFrame
void vPushFrame(callback_data *spData)
Definition: basics.c:77
XMLGRAMMAR_ANOTPAQ
#define XMLGRAMMAR_ANOTPAQ
Definition: xmlgrammar.h:47
XMLGRAMMAR_PEDEF
#define XMLGRAMMAR_PEDEF
Definition: xmlgrammar.h:152
vGEDeclName
void vGEDeclName(callback_data *spData)
Definition: declarations.c:417
vParserSetRuleCallback
void vParserSetRuleCallback(void *vpCtx, aint uiRuleId, parser_callback pfnCallback)
Set a call back function for a specific rule.
Definition: parser.c:386
vDecValue
void vDecValue(callback_data *spData)
Definition: elements.c:229
vComment
void vComment(callback_data *spData)
Definition: basics.c:273
iCompNames
int iCompNames(const uint32_t *uipLName, uint32_t uiLLen, const uint32_t *uipRName, uint32_t uiRLen)
Definition: basics.c:969
entity_decl
Provides the offset into the general 32-bit vector and length of a name and value pair.
Definition: xmlp.h:80
vDtdName
void vDtdName(callback_data *spData)
Definition: declarations.c:233
vVersionNum
void vVersionNum(callback_data *spData)
Definition: declarations.c:158
vpVecAt
void * vpVecAt(void *vpCtx, aint uiIndex)
Get a the indexed vector element. The vector is not altered.
Definition: vector.c:362
vSDeclYes
void vSDeclYes(callback_data *spData)
Definition: declarations.c:200
XMLGRAMMAR_GEDEFEX
#define XMLGRAMMAR_GEDEFEX
Definition: xmlgrammar.h:126
vXmlDeclClose
void vXmlDeclClose(callback_data *spData)
Definition: declarations.c:86
vVersionInfo
void vVersionInfo(callback_data *spData)
Definition: declarations.c:152
u32_phrase::uipPhrase
const uint32_t * uipPhrase
Pointer to an array of 32-bit unsigned integers.
Definition: lib.h:74
ATT_HASH
#define ATT_HASH
Definition: callbacks.h:48
ATT_AMP
#define ATT_AMP
Definition: callbacks.h:47
XMLGRAMMAR_STAGCLOSE
#define XMLGRAMMAR_STAGCLOSE
Definition: xmlgrammar.h:181
parser_callback
void(* parser_callback)(callback_data *spData)
User-written callback function prototype.
Definition: parser.h:178
XMLGRAMMAR_PICLOSE
#define XMLGRAMMAR_PICLOSE
Definition: xmlgrammar.h:157
vPEDeclOpen
void vPEDeclOpen(callback_data *spData)
Definition: declarations.c:390
XMLGRAMMAR_ANOTGT
#define XMLGRAMMAR_ANOTGT
Definition: xmlgrammar.h:40
ATT_X
#define ATT_X
Definition: callbacks.h:49
vPIInfoa
void vPIInfoa(callback_data *spData)
Definition: basics.c:376
ATT_SEMI
#define ATT_SEMI
Definition: callbacks.h:50
conv_src::ucpData
uint8_t * ucpData
Pointer to the byte stream to decode,.
Definition: conv.h:113
vXmlgrammarRuleCallbacks
void vXmlgrammarRuleCallbacks(void *vpParserCtx)
Definition: basics.c:993
spLeftMostElement
att_decl * spLeftMostElement(xml *spXml, att_decl *spAttList)
Definition: basics.c:606
iEntityComp
int iEntityComp(const void *vpL, const void *vpR)
Definition: basics.c:832
vpVecPop
void * vpVecPop(void *vpCtx)
Pops one element from the end of the array.
Definition: vector.c:250
vName
void vName(callback_data *spData)
Definition: basics.c:426
XMLGRAMMAR_NAMEOTHERCHAR
#define XMLGRAMMAR_NAMEOTHERCHAR
Definition: xmlgrammar.h:138
XMLGRAMMAR_PIINFOCHAR
#define XMLGRAMMAR_PIINFOCHAR
Definition: xmlgrammar.h:161
XMLGRAMMAR_NOTATIONOPEN
#define XMLGRAMMAR_NOTATIONOPEN
Definition: xmlgrammar.h:146
XMLGRAMMAR_ENTITYCHARA
#define XMLGRAMMAR_ENTITYCHARA
Definition: xmlgrammar.h:104
aint
uint_fast32_t aint
The APG parser's unsigned integer type.
Definition: apg.h:79
vConvGetCodePoints
void vConvGetCodePoints(void *vpCtx, uint32_t *uipData, uint32_t *uipDataLen)
Access the intermediate 32-bit data following a call to vConvDecode() or vConvUseCodePoints().
Definition: conv.c:361
vpVecLast
void * vpVecLast(void *vpCtx)
Get the last element one the vector. The vector is not altered.
Definition: vector.c:343
ui3byte
uint32_t ui3byte(const achar *acpBytes)
Definition: basics.c:108
vDocument
void vDocument(callback_data *spData)
Definition: declarations.c:51
vCloseQuote
void vCloseQuote(callback_data *spData)
Definition: declarations.c:501
vEStart
void vEStart(callback_data *spData)
Definition: elements.c:50
XMLGRAMMAR_ASCII
#define XMLGRAMMAR_ASCII
Definition: xmlgrammar.h:52
entity_decl::sValue
cdata_id sValue
The offset (into vpVec32) and length of the value.
Definition: xmlp.h:83
callbacks.h
Declaration for all of the XML Component parser callback functions.
entity_decl::bExpanded
abool bExpanded
True if this entity value has been expanded.
Definition: xmlp.h:88
XMLGRAMMAR_ANOTLAA
#define XMLGRAMMAR_ANOTLAA
Definition: xmlgrammar.h:43
callback_data::uiParserPhraseLength
aint uiParserPhraseLength
[read only] The parser's matched phrase length if uiParserState is ID_MATCH or ID_NOMATCH....
Definition: parser.h:161
cdata_id::uiOffset
uint32_t uiOffset
The offset into vpVec32 array for the start of the data.
Definition: xmlp.h:43
STATE_TEXT
#define STATE_TEXT
Definition: callbacks.h:45
vPEReference
void vPEReference(callback_data *spData)
Definition: declarations.c:402
XMLGRAMMAR_ANOTRB
#define XMLGRAMMAR_ANOTRB
Definition: xmlgrammar.h:51
callback_data::uiCallbackState
aint uiCallbackState
[input/output] Rule name (RNM) callback functions: If ID_ACTIVE, the parser takes no action....
Definition: parser.h:139
vAttName
void vAttName(callback_data *spData)
Definition: declarations.c:557
XMLGRAMMAR_ATTVALUE
#define XMLGRAMMAR_ATTVALUE
Definition: xmlgrammar.h:63
bMultiply32
abool bMultiply32(uint32_t uiL, uint32_t uiR, uint32_t *uipA)
Multiply two 32-bit unsigned integers with overflow notification.
Definition: tools.c:150
iAttComp
int iAttComp(const void *vpL, const void *vpR)
Definition: basics.c:808
att_decl::sElementName
cdata_id sElementName
The element name, offset and length.
Definition: xmlp.h:62
XMLGRAMMAR_DVALUE
#define XMLGRAMMAR_DVALUE
Definition: xmlgrammar.h:94
XMLGRAMMAR_HEXVALUE
#define XMLGRAMMAR_HEXVALUE
Definition: xmlgrammar.h:131
XMLGRAMMAR_CDEND
#define XMLGRAMMAR_CDEND
Definition: xmlgrammar.h:66
vPITarget
void vPITarget(callback_data *spData)
Definition: basics.c:346
sNormalizeAttributeValue
cdata_id sNormalizeAttributeValue(xml *spXml, aint uiOffset, uint32_t *uipAttValue, uint32_t uiLength, abool bIsCDATA)
Definition: basics.c:682
vCDEnd
void vCDEnd(callback_data *spData)
Definition: elements.c:375
vExtSubset
void vExtSubset(callback_data *spData)
Definition: declarations.c:367
uiVecLen
aint uiVecLen(void *vpCtx)
Get the vector length. That is, the number of elements on the vector.
Definition: vector.c:385
XMLGRAMMAR_NEXTERNALID
#define XMLGRAMMAR_NEXTERNALID
Definition: xmlgrammar.h:141
XMLGRAMMAR_SVALUE
#define XMLGRAMMAR_SVALUE
Definition: xmlgrammar.h:183
XMLGRAMMAR_EMPTYCLOSE
#define XMLGRAMMAR_EMPTYCLOSE
Definition: xmlgrammar.h:100
XMLGRAMMAR_ATTLISTCLOSE
#define XMLGRAMMAR_ATTLISTCLOSE
Definition: xmlgrammar.h:56
vEncDef
void vEncDef(callback_data *spData)
Definition: declarations.c:174
XMLGRAMMAR_DCHAR
#define XMLGRAMMAR_DCHAR
Definition: xmlgrammar.h:81
vAttValue
void vAttValue(callback_data *spData)
Definition: elements.c:176
vPIInfoq
void vPIInfoq(callback_data *spData)
Definition: basics.c:367
XMLGRAMMAR_ENTITYCHARD
#define XMLGRAMMAR_ENTITYCHARD
Definition: xmlgrammar.h:105
entity_decl::sName
cdata_id sName
The offset (into vpVec32) and length of the name.
Definition: xmlp.h:82
vCDSectEnd
void vCDSectEnd(callback_data *spData)
Definition: elements.c:347
vMakeCDataDisplay
void vMakeCDataDisplay(xml *spXml, cdata_id *spDataId, u32_phrase *spCData, aint uiOffset)
Definition: basics.c:156
vPERefError
void vPERefError(callback_data *spData)
Definition: declarations.c:408
XMLGRAMMAR_PIINFO
#define XMLGRAMMAR_PIINFO
Definition: xmlgrammar.h:159
XMLGRAMMAR_ANOTLAQ
#define XMLGRAMMAR_ANOTLAQ
Definition: xmlgrammar.h:44
vElementOpen
void vElementOpen(callback_data *spData)
Definition: declarations.c:717
ID_ACTIVE
#define ID_ACTIVE
indicates active parser state, parser has just entered the node and is moving down the parse tree
Definition: parser.h:72
conv_src::uiDataLen
aint uiDataLen
Number of bytes in the byte stream.
Definition: conv.h:114
vExternalID
void vExternalID(callback_data *spData)
Definition: declarations.c:375
XMLGRAMMAR_SDECLYES
#define XMLGRAMMAR_SDECLYES
Definition: xmlgrammar.h:177
callback_data::uiCallbackPhraseLength
aint uiCallbackPhraseLength
[input/output] The phrase length of the matched phrase if the callback function returns ID_MATCH.
Definition: parser.h:145
XMLGRAMMAR_PITARGET
#define XMLGRAMMAR_PITARGET
Definition: xmlgrammar.h:165
XMLGRAMMAR_COMMENT
#define XMLGRAMMAR_COMMENT
Definition: xmlgrammar.h:76
ID_MATCH
#define ID_MATCH
indicates a matched phrase parser state on return from parse tree below this node
Definition: parser.h:73
luint
uintmax_t luint
luint is used to cast integers suitable for the %"PRIuMAX" printf format.
Definition: apg.h:133
callback_data
The data struct passed to each callback function.
Definition: parser.h:134
XMLGRAMMAR_ATTCHARD
#define XMLGRAMMAR_ATTCHARD
Definition: xmlgrammar.h:54
XMLGRAMMAR_SDECLNO
#define XMLGRAMMAR_SDECLNO
Definition: xmlgrammar.h:175
spEntityNameLookup
entity_decl * spEntityNameLookup(xml *spXml, aint uiOffset, uint32_t *uipName, uint32_t uiNameLen)
Find the left-most occurrence of the given entity name.
Definition: basics.c:645
vCDRb
void vCDRb(callback_data *spData)
Definition: elements.c:381
XML_THROW
#define XML_THROW(msg)
Definition: callbacks.h:53
vEOpen
void vEOpen(callback_data *spData)
Definition: elements.c:74
XMLGRAMMAR_PIINFOA
#define XMLGRAMMAR_PIINFOA
Definition: xmlgrammar.h:160
vNotationOpen
void vNotationOpen(callback_data *spData)
Definition: declarations.c:675
XMLGRAMMAR_GEDECLNAME
#define XMLGRAMMAR_GEDECLNAME
Definition: xmlgrammar.h:123
vConvDecode
void vConvDecode(void *vpCtx, conv_src *spSrc)
Decode a source byte stream to 32-bit Unicode code points.
Definition: conv.c:205
XMLGRAMMAR_DOCOPEN
#define XMLGRAMMAR_DOCOPEN
Definition: xmlgrammar.h:90
XMLGRAMMAR_XMLDECLCLOSE
#define XMLGRAMMAR_XMLDECLCLOSE
Definition: xmlgrammar.h:194
vpVecFirst
void * vpVecFirst(void *vpCtx)
Get the first element one the vector. The vector is not altered.
Definition: vector.c:326
XMLGRAMMAR_CDSECTEND
#define XMLGRAMMAR_CDSECTEND
Definition: xmlgrammar.h:69
vpVecPushn
void * vpVecPushn(void *vpCtx, void *vpElement, aint uiCount)
Adds one or more elements to the end of the array.
Definition: vector.c:221
vETagClose
void vETagClose(callback_data *spData)
Definition: elements.c:120
XMLGRAMMAR_ELATTNAME
#define XMLGRAMMAR_ELATTNAME
Definition: xmlgrammar.h:95
vNameOtherChar
void vNameOtherChar(callback_data *spData)
Definition: basics.c:503
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
XMLGRAMMAR_CDRB
#define XMLGRAMMAR_CDRB
Definition: xmlgrammar.h:67
vDoubleh
void vDoubleh(callback_data *spData)
Definition: basics.c:267
XMLGRAMMAR_ANOTPAA
#define XMLGRAMMAR_ANOTPAA
Definition: xmlgrammar.h:46
XMLGRAMMAR_ATTDEF
#define XMLGRAMMAR_ATTDEF
Definition: xmlgrammar.h:55
bValidateChar
abool bValidateChar(uint32_t uiChar)
Definition: basics.c:124
XMLGRAMMAR_ANOTQ
#define XMLGRAMMAR_ANOTQ
Definition: xmlgrammar.h:49
STATE_WSP
#define STATE_WSP
Definition: callbacks.h:46
vElementClose
void vElementClose(callback_data *spData)
Definition: declarations.c:724
XMLGRAMMAR_PIRESERVED
#define XMLGRAMMAR_PIRESERVED
Definition: xmlgrammar.h:164
vPIReserved
void vPIReserved(callback_data *spData)
Definition: basics.c:389
callback_data::vpUserData
void * vpUserData
[input/output] User-defined data passed to to the parser in parser_config.
Definition: parser.h:136
vAttlistValue
void vAttlistValue(callback_data *spData)
Definition: declarations.c:600
XMLGRAMMAR_ERESERVED
#define XMLGRAMMAR_ERESERVED
Definition: xmlgrammar.h:113
XMLGRAMMAR_PEREFERENCE
#define XMLGRAMMAR_PEREFERENCE
Definition: xmlgrammar.h:154
XMLGRAMMAR_PIOPEN
#define XMLGRAMMAR_PIOPEN
Definition: xmlgrammar.h:163
APG_TRUE
#define APG_TRUE
Definition: apg.h:291
vAttlistOpen
void vAttlistOpen(callback_data *spData)
Definition: declarations.c:535
XMLGRAMMAR_DECVALUE
#define XMLGRAMMAR_DECVALUE
Definition: xmlgrammar.h:85
XMLGRAMMAR_ETAGCLOSE
#define XMLGRAMMAR_ETAGCLOSE
Definition: xmlgrammar.h:116
vPIClose
void vPIClose(callback_data *spData)
Definition: basics.c:332
vElAttName
void vElAttName(callback_data *spData)
Definition: elements.c:157
vGEPERef
void vGEPERef(callback_data *spData)
Definition: declarations.c:440
XMLGRAMMAR_XMLDECLOPEN
#define XMLGRAMMAR_XMLDECLOPEN
Definition: xmlgrammar.h:196
RULE_COUNT_XMLGRAMMAR
#define RULE_COUNT_XMLGRAMMAR
Definition: xmlgrammar.h:197
vCD2Rb
void vCD2Rb(callback_data *spData)
Definition: elements.c:388
XMLGRAMMAR_ANOTQUOT
#define XMLGRAMMAR_ANOTQUOT
Definition: xmlgrammar.h:50
XMLGRAMMAR_CLOSEAPOS
#define XMLGRAMMAR_CLOSEAPOS
Definition: xmlgrammar.h:74
vNotationDef
void vNotationDef(callback_data *spData)
Definition: declarations.c:697
XMLGRAMMAR_ESTART
#define XMLGRAMMAR_ESTART
Definition: xmlgrammar.h:114
vPIInfo
void vPIInfo(callback_data *spData)
Definition: basics.c:360
UTF_8
#define UTF_8
Data type macro for UTF-8 encoding/decoding.
Definition: conv.h:77
vSTagClose
void vSTagClose(callback_data *spData)
Definition: elements.c:103
XMLGRAMMAR_DOCNAME
#define XMLGRAMMAR_DOCNAME
Definition: xmlgrammar.h:89
vDtdOpen
void vDtdOpen(callback_data *spData)
Definition: declarations.c:221
abool
uint8_t abool
abool is the APG bool type.
Definition: apg.h:140
XMLGRAMMAR_VERSIONINFO
#define XMLGRAMMAR_VERSIONINFO
Definition: xmlgrammar.h:191
XMLGRAMMAR_PIFORBIDDEN
#define XMLGRAMMAR_PIFORBIDDEN
Definition: xmlgrammar.h:158
XMLGRAMMAR_VERSIONNUM
#define XMLGRAMMAR_VERSIONNUM
Definition: xmlgrammar.h:192
vPIOpen
void vPIOpen(callback_data *spData)
Definition: basics.c:324
XMLGRAMMAR_ATTCHARA
#define XMLGRAMMAR_ATTCHARA
Definition: xmlgrammar.h:53
vDtdClose
void vDtdClose(callback_data *spData)
Definition: declarations.c:241
vpVecPopi
void * vpVecPopi(void *vpCtx, aint uiIndex)
Pops the element at the given zero-based index and all higher indexes.
Definition: vector.c:306
XMLGRAMMAR_CD2RB
#define XMLGRAMMAR_CD2RB
Definition: xmlgrammar.h:64
XMLGRAMMAR_DOCCLOSE
#define XMLGRAMMAR_DOCCLOSE
Definition: xmlgrammar.h:87
ID_NOMATCH
#define ID_NOMATCH
indicates that no phrase was matched on return from parse tree below this node
Definition: parser.h:74
conv_src
Defines the input data type, location and length.
Definition: conv.h:109
XMLGRAMMAR_DOUBLEH
#define XMLGRAMMAR_DOUBLEH
Definition: xmlgrammar.h:93
vPEDeclClose
void vPEDeclClose(callback_data *spData)
Definition: declarations.c:396
XMLGRAMMAR_EOPEN
#define XMLGRAMMAR_EOPEN
Definition: xmlgrammar.h:111
XMLGRAMMAR_SCHAR
#define XMLGRAMMAR_SCHAR
Definition: xmlgrammar.h:173
XMLGRAMMAR_ENTITYREF
#define XMLGRAMMAR_ENTITYREF
Definition: xmlgrammar.h:107
XMLGRAMMAR_ATTNAME
#define XMLGRAMMAR_ATTNAME
Definition: xmlgrammar.h:60
vEntityRef
void vEntityRef(callback_data *spData)
Definition: elements.c:209
vEmptyClose
void vEmptyClose(callback_data *spData)
Definition: elements.c:92
vEReserved
void vEReserved(callback_data *spData)
Definition: elements.c:85
vAttDef
void vAttDef(callback_data *spData)
Definition: declarations.c:614
XMLGRAMMAR_DOCUMENT
#define XMLGRAMMAR_DOCUMENT
Definition: xmlgrammar.h:92
XMLGRAMMAR_NOTATIONCLOSE
#define XMLGRAMMAR_NOTATIONCLOSE
Definition: xmlgrammar.h:143
XMLGRAMMAR_ENCDEF
#define XMLGRAMMAR_ENCDEF
Definition: xmlgrammar.h:101
XMLGRAMMAR_UTF84
#define XMLGRAMMAR_UTF84
Definition: xmlgrammar.h:190
XMLGRAMMAR_GEPEREF
#define XMLGRAMMAR_GEPEREF
Definition: xmlgrammar.h:127
XMLGRAMMAR_ATTLISTOPEN
#define XMLGRAMMAR_ATTLISTOPEN
Definition: xmlgrammar.h:58
bSum32
abool bSum32(uint32_t uiL, uint32_t uiR, uint32_t *uipA)
Sum two 32-bit unsigned integers with overflow notification.
Definition: tools.c:170
vUtf84
void vUtf84(callback_data *spData)
Definition: basics.c:420
u32_phrase
Defines a pointer to an array of 32-bit unsigned integers plus its length. Typically needed by Unicod...
Definition: lib.h:73
vEntityChar
void vEntityChar(callback_data *spData)
Definition: declarations.c:507
vMakeCDataIdFromInput
void vMakeCDataIdFromInput(xml *spXml, const achar *acpInput, aint uiLen, aint uiOffset, cdata_id *spCDataId)
Definition: basics.c:167
uiDecValue32
uint32_t uiDecValue32(xml *spXml, aint uiOffset, uint32_t *uipChars, uint32_t uiCount)
Definition: basics.c:581
XMLGRAMMAR_PEREFERROR
#define XMLGRAMMAR_PEREFERROR
Definition: xmlgrammar.h:155
XMLGRAMMAR_NOTATIONDEF
#define XMLGRAMMAR_NOTATIONDEF
Definition: xmlgrammar.h:145
sCapturePhrase
cdata_id sCapturePhrase(xml *spXml, achar *acpPhrase, aint uiPhraseLength, aint uiOffset)
Definition: basics.c:192
XMLGRAMMAR_PEDECLCLOSE
#define XMLGRAMMAR_PEDECLCLOSE
Definition: xmlgrammar.h:150
XMLGRAMMAR_ELEMENTOPEN
#define XMLGRAMMAR_ELEMENTOPEN
Definition: xmlgrammar.h:99
att_decl
Identifies the element name, attribute name and default attribute value of attribute list declaration...
Definition: xmlp.h:60
CABUF_LEN
#define CABUF_LEN
Definition: callbacks.h:51
ui4byte
uint32_t ui4byte(const achar *acpBytes)
Definition: basics.c:116
vNExternalID
void vNExternalID(callback_data *spData)
Definition: declarations.c:382
XMLGRAMMAR_CDCHAR
#define XMLGRAMMAR_CDCHAR
Definition: xmlgrammar.h:65
cdata_id
Parsed character data definition.
Definition: xmlp.h:42
XMLGRAMMAR_NAME
#define XMLGRAMMAR_NAME
Definition: xmlgrammar.h:136
vpVecPush
void * vpVecPush(void *vpCtx, void *vpElement)
Adds one element to the end of the array.
Definition: vector.c:193
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
vConvertParsedData
void vConvertParsedData(xml *spXml, const achar *acpData, aint uiDataLen, uint32_t *uipOffset, uint32_t *uipLength)
Converts parsed UTF-8 data to UTF-32 code points.
Definition: basics.c:234
vVecClear
void vVecClear(void *vpCtx)
Clears all used elements in a vector component.
Definition: vector.c:420
vExThrow
void vExThrow(exception *spEx, const char *cpMsg, unsigned int uiLine, const char *cpFile, const char *cpFunc)
Throws an exception.
Definition: exception.c:87
vLogMsg
void vLogMsg(xml *spXml, aint uiOffset, char *cpTitle)
Definition: basics.c:61
uiHexValue32
uint32_t uiHexValue32(xml *spXml, aint uiOffset, uint32_t *uipChars, uint32_t uiCount)
Definition: basics.c:544
XMLGRAMMAR_ELEMENTCLOSE
#define XMLGRAMMAR_ELEMENTCLOSE
Definition: xmlgrammar.h:97
vPIForbidden
void vPIForbidden(callback_data *spData)
Definition: basics.c:383
vAscii
void vAscii(callback_data *spData)
Definition: basics.c:402
APG_FALSE
#define APG_FALSE
Definition: apg.h:292
XMLGRAMMAR_UTF83
#define XMLGRAMMAR_UTF83
Definition: xmlgrammar.h:189
uiLinesCount
aint uiLinesCount(void *vpCtx)
Returns the number of lines of text.
Definition: lines.c:202
APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.