10 #ifndef _CRT_SECURE_NO_DEPRECATE 11 #define _CRT_SECURE_NO_DEPRECATE 13 #undef _UNICODE // JLBC 16 #define WIN32_LEAN_AND_MEAN 37 inline int mmin(
const int t1,
const int t2) {
return t1 < t2 ? t1 : t2; }
55 {
nullptr, 0,
nullptr}};
72 {
_CXML(
"'"), 6,
_CXML(
'\'')}, {
nullptr, 0,
'\0'}};
78 #define INDENTCHAR _CXML('\t') 88 return _CXML(
"No error");
90 return _CXML(
"Warning: Unmatched end tag");
92 return _CXML(
"Warning: No XML tag found");
94 return _CXML(
"Error: No XML data");
96 return _CXML(
"Error: Missing start tag name");
98 return _CXML(
"Error: Missing end tag name");
100 return _CXML(
"Error: Unmatched end tag");
102 return _CXML(
"Error: Unmatched clear tag end");
104 return _CXML(
"Error: Unexpected token found");
106 return _CXML(
"Error: No elements found");
108 return _CXML(
"Error: File not found");
110 return _CXML(
"Error: First Tag not found");
112 return _CXML(
"Error: Unknown character entity");
115 "Error: Character code above 255 is forbidden in MultiByte " 119 "Error: unable to convert between WideChar and MultiByte " 122 return _CXML(
"Error: unable to open file for writing");
124 return _CXML(
"Error: cannot write into file");
128 "Warning: Base64-string length is not a multiple of 4");
130 return _CXML(
"Warning: Base64-string is truncated");
132 return _CXML(
"Error: Base64-string contains an illegal character");
134 return _CXML(
"Error: Base64 decode output buffer is too small");
136 return _CXML(
"Unknown");
151 #ifdef XML_NO_WIDE_CHAR 154 #if defined(UNDER_CE) || !defined(_XMLWINDOWS) 156 const void*
b,
int len)
161 if ((((
unsigned long)
b) %
sizeof(
wchar_t)) != 0)
return FALSE;
163 const auto*
s = (
const wchar_t*)
b;
166 if (
len < (
int)
sizeof(wchar_t))
return FALSE;
175 if (*((
unsigned short*)
s) == 0xFFFE)
177 if (*((
unsigned short*)
s) == 0xFEFF)
182 for (i = 0; i <
len; i++)
183 if (
s[i] <= (
unsigned short)255) stats++;
184 if (stats >
len / 2)
return TRUE;
187 for (i = 0; i <
len; i++)
188 if (!
s[i])
return TRUE;
195 return (
char)IsTextUnicode((CONST LPVOID)
b, l,
nullptr);
208 i = (int)MultiByteToWideChar(CP_UTF8, 0,
s, -1,
nullptr, 0);
210 i = (int)MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
s, -1,
nullptr, 0);
211 if (i < 0)
return nullptr;
212 wchar_t* d = (
wchar_t*)malloc((i + 1) *
sizeof(
XMLCHAR));
214 i = (int)MultiByteToWideChar(CP_UTF8, 0,
s, -1, d, i);
216 i = (int)MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
s, -1, d, i);
222 return _wfopen(filename,
mode);
227 return _wcsnicmp(c1, c2, l);
231 return wcsncmp(c1, c2, l);
236 return (
XMLSTR)wcsstr(c1, c2);
240 return (
XMLSTR)wcscpy(c1, c2);
245 UINT codePage = CP_ACP;
247 int i = (int)WideCharToMultiByte(
257 if (i < 0)
return nullptr;
258 char* d = (
char*)malloc(i + 1);
280 return strnicmp(c1, c2, l);
292 return strncmp(c1, c2, l);
296 return (
XMLSTR)strstr(c1, c2);
305 #ifdef XML_NO_WIDE_CHAR 310 const wchar_t* ss =
s;
311 int i = (int)wcsrtombs(
nullptr, &ss, 0,
nullptr);
312 if (i < 0)
return nullptr;
313 char* d = (
char*)malloc(i + 1);
314 wcsrtombs(d, &
s, i,
nullptr);
323 int i = (int)mbsrtowcs(
nullptr, &ss, 0,
nullptr);
324 if (i < 0)
return nullptr;
325 wchar_t* d = (
wchar_t*)malloc((i + 1) *
sizeof(wchar_t));
326 mbsrtowcs(d, &
s, i,
nullptr);
336 return wsncasecmp(c1, c2, l);
340 return wsncmp(c1, c2, l);
347 return wcsncasecmp(c1, c2, l);
351 return wcsncmp(c1, c2, l);
355 return wcscasecmp(c1, c2);
360 return (
XMLSTR)wcsstr(c1, c2);
364 return (
XMLSTR)wcscpy(c1, c2);
371 f =
fopen(filenameAscii,
"rb");
373 f =
fopen(filenameAscii,
"wb");
385 return strncasecmp(c1, c2, l);
389 return strncmp(c1, c2, l);
393 return strcasecmp(c1, c2);
397 return (
XMLSTR)strstr(c1, c2);
405 #pragma clang diagnostic push 406 #pragma clang diagnostic ignored "-Wunused-function" 407 static inline int _strnicmp(
const char* c1,
const char* c2,
int l)
409 return strncasecmp(c1, c2, l);
411 #pragma clang diagnostic pop 427 if (
t && (*
t))
return (
char)_wtoi(
t);
432 if (
t && (*
t))
return _wtoi(
t);
437 if (
t && (*
t))
return _wtol(
t);
442 if (
t && (*
t)) wscanf(
t,
"%f", &
v);
451 if (
t)
return (
char)wstol(
t,
nullptr, 10);
456 if (
t)
return (
int)wstol(
t,
nullptr, 10);
461 if (
t)
return wstol(
t,
nullptr, 10);
468 if (
t)
return (
char)wcstol(
t,
nullptr, 10);
473 if (
t)
return (
int)wcstol(
t,
nullptr, 10);
478 if (
t)
return wcstol(
t,
nullptr, 10);
484 if (
t && (*
t)) wscanf(
t,
"%f", &
v);
491 if (
t && (*
t))
return (
char)atoi(
t);
496 if (
t && (*
t))
return atoi(
t);
501 if (
t && (*
t))
return atol(
t);
506 if (
t && (*
t))
return atof(
t);
517 if (
t && (*
t))
return *
t;
537 int l = (int)fread(bb, 1, 200, f);
552 char message[2000], *s1 = (
char*)
"", *s3 = (
char*)
"";
556 s1 = (
char*)
"First Tag should be '";
563 "XML Parsing error inside file '%S'.\n%S\nAt line %i, column " 566 "XML Parsing error inside file '%s'.\n%s\nAt line %i, column " 574 #if defined(_XMLWINDOWS) && !defined(UNDER_CE) && \ 575 !defined(_XMLPARSER_NO_MESSAGEBOX_) 577 nullptr, message,
"XML Parsing error",
578 MB_OK | MB_ICONERROR | MB_TOPMOST);
580 printf(
"%s", message);
606 0, 1, 1, 1, 1, 1, 1, 1,
607 1, 1, 1, 1, 1, 1, 1, 1,
608 1, 1, 1, 1, 1, 1, 1, 1,
609 1, 1, 1, 1, 1, 1, 1, 1,
610 1, 1, 1, 1, 1, 1, 1, 1,
611 1, 1, 1, 1, 1, 1, 1, 1,
612 1, 1, 1, 1, 1, 1, 1, 1,
613 1, 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 1, 1, 1, 1, 1, 1, 1, 1
723 0, 1, 1, 1, 1, 1, 1, 1,
724 1, 1, 1, 1, 1, 1, 1, 1,
725 1, 1, 1, 1, 1, 1, 1, 1,
726 1, 1, 1, 1, 1, 1, 1, 1,
727 1, 1, 1, 1, 1, 1, 1, 1,
728 1, 1, 1, 1, 1, 1, 1, 1,
729 1, 1, 1, 1, 1, 1, 1, 1,
730 1, 1, 1, 1, 1, 1, 1, 1,
731 1, 1, 1, 1, 1, 1, 1, 1,
732 1, 1, 1, 1, 1, 1, 1, 1,
733 1, 1, 1, 1, 1, 1, 1, 1,
734 1, 1, 1, 1, 1, 1, 1, 1,
735 1, 1, 1, 1, 1, 1, 1, 1,
736 1, 1, 1, 1, 1, 1, 1, 1,
737 1, 1, 1, 1, 1, 1, 1, 1,
738 1, 1, 1, 1, 1, 1, 1, 1,
739 1, 2, 2, 2, 2, 2, 2, 2,
740 2, 2, 2, 2, 2, 2, 2, 2,
741 2, 2, 2, 2, 2, 2, 2, 2,
742 2, 2, 2, 2, 2, 2, 2, 2,
743 2, 2, 2, 2, 2, 2, 2, 2,
744 2, 2, 2, 2, 2, 2, 2, 2,
745 2, 2, 2, 2, 2, 2, 2, 2,
746 2, 2, 2, 2, 2, 2, 2, 2,
747 2, 2, 2, 2, 2, 2, 2, 2,
748 2, 2, 2, 2, 2, 2, 2, 2,
749 2, 2, 2, 2, 2, 2, 2, 2,
750 2, 2, 2, 2, 2, 2, 2, 2,
751 2, 2, 2, 2, 2, 2, 2, 2,
752 2, 2, 2, 2, 2, 2, 2, 2,
753 2, 2, 2, 2, 2, 2, 2, 2,
754 2, 2, 2, 2, 2, 2, 2, 1
801 using Attrib =
enum Attrib { eAttribName = 0, eAttribEquals, eAttribValue };
808 XMLCSTR filename,
const char* encoding,
char nFormat)
const 814 unsigned char h[2] = {0xFF, 0xFE};
820 L
"<?xml version=\"1.0\" encoding=\"utf-16\"?>\n",
821 sizeof(
wchar_t) * 40, 1, f))
831 unsigned char h[3] = {0xEF, 0xBB, 0xBF};
836 encoding =
"SHIFT-JIS";
838 if (!encoding) encoding =
"ISO-8859-1";
839 if (
fprintf(f,
"<?xml version=\"1.0\" encoding=\"%s\"?>\n", encoding) <
847 unsigned char h[3] = {0xEF, 0xBB, 0xBF};
863 if (lpszData ==
nullptr)
return nullptr;
866 if (cbData == -1) cbData = (int)
xstrlen(lpszData);
871 lpszNew[cbData] = (
XMLCHAR)NULL;
881 while ((ch = *
source) !=
'\0')
926 while ((ch = *
source) !=
'\0')
983 if (!
s)
return nullptr;
989 while ((lo > 0) && (*
s))
993 if ((lo > 2) && (
s[1] ==
_CXML(
'#')))
1002 while ((*
s) && (*
s !=
_CXML(
';')) && ((lo--) > 0))
s++;
1016 if ((lo >= entity->
l) &&
1024 }
while (entity->
s);
1051 if (*ss ==
_CXML(
'&'))
1053 if (ss[1] ==
_CXML(
'#'))
1057 if ((*ss ==
_CXML(
'X')) || (*ss ==
_CXML(
'x')))
1060 while (*ss !=
_CXML(
';'))
1062 if ((*ss >=
_CXML(
'0')) && (*ss <=
_CXML(
'9')))
1063 j = (j << 4) + *ss -
_CXML(
'0');
1064 else if ((*ss >=
_CXML(
'A')) && (*ss <=
_CXML(
'F')))
1065 j = (j << 4) + *ss -
_CXML(
'A') + 10;
1066 else if ((*ss >=
_CXML(
'a')) && (*ss <=
_CXML(
'f')))
1067 j = (j << 4) + *ss -
_CXML(
'a') + 10;
1079 while (*ss !=
_CXML(
';'))
1081 if ((*ss >=
_CXML(
'0')) && (*ss <=
_CXML(
'9')))
1082 j = (j * 10) + *ss -
_CXML(
'0');
1092 #ifndef _XMLWIDECHAR 1115 }
while (entity->
s);
1148 #define XML_isSPACECHAR(ch) \ 1149 ((ch == _CXML('\n')) || (ch == _CXML(' ')) || (ch == _CXML('\t')) || \ 1150 (ch == _CXML('\r'))) 1158 if (!cclose)
return 1;
1160 if (
xstrnicmp(cclose, copen, l) != 0)
return 1;
1173 if (ch != 0) pXML->
nIndex++;
1188 int indexStart, nFoundMatch, nIsText =
FALSE;
1189 result.
pClr =
nullptr;
1194 indexStart = pXML->
nIndex;
1229 nFoundMatch =
FALSE;
1239 if (ch ==
_CXML(
'<'))
break;
1243 if (nFoundMatch ==
FALSE)
1245 pXML->
nIndex = indexStart + 1;
1273 if (chTemp ==
_CXML(
'/'))
1281 else if (chTemp ==
_CXML(
'?'))
1303 if (chTemp ==
_CXML(
'>'))
1333 else if (ch ==
_CXML(
'/'))
1342 if (ch ==
_CXML(
'>'))
1357 *pcbToken = pXML->
nIndex - indexStart;
1364 result.
pStr =
nullptr;
1377 if (
d->lpszName && (lpszName !=
d->lpszName)) free((
void*)
d->lpszName);
1378 d->lpszName = lpszName;
1393 d->lpszName =
nullptr;
1401 d->pParent = pParent;
1402 d->pChild =
nullptr;
1404 d->pClear =
nullptr;
1405 d->pAttribute =
nullptr;
1406 d->pOrder =
nullptr;
1420 #define MEMORYINCREASE 50 1426 static inline void*
myRealloc(
void*
p,
int newsize,
int memInc,
int sizeofElem)
1430 if (memInc)
return malloc(memInc * sizeofElem);
1431 return malloc(sizeofElem);
1433 if ((memInc == 0) || ((newsize % memInc) == 0))
1434 p = realloc(
p, (newsize + memInc) * sizeofElem);
1447 if (
index < 0)
return -1;
1448 int i = 0, j = (int)((
index << 2) + xxtype), *o =
d->pOrder;
1449 while (o[i] != j) i++;
1457 int n =
d->nChild +
d->nText +
d->nClear, *o =
d->pOrder,
1459 memmove(o + i, o + i + 1, (
n - i) *
sizeof(
int));
1461 if ((o[i] & 3) == (
int)
t) o[i] -= 4;
1470 int memoryIncrease,
int* _pos,
int nc,
void*
p,
int size,
1476 int n =
d->nChild +
d->nText +
d->nClear;
1478 (
int*)
myRealloc(
d->pOrder,
n + 1, memoryIncrease * 3,
sizeof(
int));
1479 int pos = *_pos, *o =
d->pOrder;
1481 if ((pos < 0) || (pos >=
n))
1484 o[
n] = (int)((nc << 2) + xtype);
1489 memmove(o + i + 1, o + i, (
n - i) *
sizeof(
int));
1491 while ((pos <
n) && ((o[pos] & 3) != (
int)xtype)) pos++;
1495 o[
n] = (int)((nc << 2) + xtype);
1500 for (i = pos + 1; i <=
n; i++)
1501 if ((o[i] & 3) == (int)xtype) o[i] += 4;
1503 *_pos = pos = o[pos] >> 2;
1505 ((
char*)
p) + (pos + 1) *
size, ((
char*)
p) + pos *
size,
1513 int memoryIncrease,
XMLSTR lpszName,
char isDeclaration,
int pos)
1517 memoryIncrease, &pos,
d->nChild,
d->pChild,
sizeof(
XMLNode),
1519 d->pChild[pos].d =
nullptr;
1522 return d->pChild[pos];
1527 int memoryIncrease,
XMLSTR lpszName,
XMLSTR lpszValuev)
1536 int nc =
d->nAttribute;
1538 d->pAttribute, (nc + 1), memoryIncrease,
sizeof(
XMLAttribute));
1549 if (!lpszValue)
return nullptr;
1557 d->pText[pos] = lpszValue;
1574 memoryIncrease, &pos,
d->nClear,
d->pClear,
sizeof(
XMLClear),
1604 if (*pCh ==
_CXML(
'<'))
1607 lpszTemp =
xstrstr(lpXML, docTypeEnd);
1610 else if (*pCh ==
_CXML(
'>'))
1628 cbTemp = (int)(lpszTemp - lpXML);
1647 d->pOrder = (
int*)realloc(
1648 d->pOrder, (
d->nChild +
d->nText +
d->nClear) *
sizeof(int));
1664 if (!lpszText)
return 0;
1668 int cbText = (int)(tokenPStr - lpszText);
1693 int n =
d->nChild +
d->nText +
d->nClear - 1, *o =
d->pOrder;
1703 d->pText[i] = (
XMLSTR)realloc(
1704 (
void*)
d->pText[i], (
n + n2) *
sizeof(
XMLCHAR));
1705 if (!
d->pText[i])
return 1;
1728 enum Attrib attrib = eAttribName;
1798 #ifdef APPROXIMATE_PARSING 1925 lpszTemp = token.
pStr;
1942 #ifdef STRICT_PARSING 1994 lpszTemp = token.
pStr;
1996 attrib = eAttribEquals;
2044 lpszTemp = token.
pStr;
2058 if (
d->isDeclaration &&
2059 (lpszTemp[cbTemp - 1]) ==
_CXML(
'?'))
2062 if (
d->pParent &&
d->pParent->pParent)
2094 attrib = eAttribValue;
2125 if (
d->isDeclaration &&
2126 (token.
pStr[cbToken - 1]) ==
_CXML(
'?'))
2143 attrVal, cbToken, pXML);
2144 if (!attrVal)
return FALSE;
2154 attrib = eAttribName;
2177 if ((!
d->isDeclaration) && (
d->pParent))
2179 #ifdef STRICT_PARSING 2200 nullptr, 0,
nullptr, 0,
TRUE};
2202 pResults->
nLine = 1;
2204 while (xml.
nIndex < nUpto)
2207 if (ch !=
_CXML(
'\n'))
2225 pResults->
nLine = 0;
2233 nullptr, 0,
nullptr, 0,
TRUE};
2255 pResults->
nLine = 0;
2289 pResults->
nLine = 0;
2299 int l = ftell(f), headerSz = 0;
2307 auto* buf = (
unsigned char*)malloc(l + 4);
2308 int really_read = (int)fread(buf, 1, l, f);
2309 if (really_read != l) buf[0] =
'\0';
2321 if ((buf[0] == 0xef) && (buf[1] == 0xbb) && (buf[2] == 0xbf))
2327 myMultiByteToWideChar((
const char*)(buf + headerSz), ce);
2329 buf = (
unsigned char*)
b2;
2334 if ((buf[0] == 0xef) && (buf[1] == 0xff)) headerSz = 2;
2335 if ((buf[0] == 0xff) && (buf[1] == 0xfe)) headerSz = 2;
2343 if ((buf[0] == 0xef) && (buf[1] == 0xff)) headerSz = 2;
2344 if ((buf[0] == 0xff) && (buf[1] == 0xfe)) headerSz = 2;
2347 buf = (
unsigned char*)
b2;
2352 if ((buf[0] == 0xef) && (buf[1] == 0xbb) && (buf[2] == 0xbf))
2370 while (l--) *(dest++) =
c;
2382 int cb = nFormat < 0 ? 0 : nFormat;
2384 int nChildFormat = -1;
2385 int nElementI = pEntry->nChild + pEntry->nText + pEntry->nClear;
2387 if ((nFormat >= 0) && (nElementI == 1) && (pEntry->nText == 1) &&
2388 (!pEntry->isDeclaration))
2393 #define LENSTR(lpsz) (lpsz ? xstrlen(lpsz) : 0) 2396 cbElement = (int)
LENSTR(pEntry->lpszName);
2405 lpszMarker[nResult++] =
_CXML(
'<');
2406 if (pEntry->isDeclaration) lpszMarker[nResult++] =
_CXML(
'?');
2407 xstrcpy(&lpszMarker[nResult], pEntry->lpszName);
2408 nResult += cbElement;
2409 lpszMarker[nResult++] =
_CXML(
' ');
2413 nResult += cbElement + 2 + cb;
2414 if (pEntry->isDeclaration) nResult++;
2419 for (i = 0; i < pEntry->nAttribute; i++)
2434 lpszMarker[nResult] =
_CXML(
'=');
2435 lpszMarker[nResult + 1] =
_CXML(
'"');
2438 &lpszMarker[nResult + 2], pAttr->
lpszValue);
2439 lpszMarker[nResult + cb + 2] =
_CXML(
'"');
2443 if (lpszMarker) lpszMarker[nResult] =
_CXML(
' ');
2449 if (pEntry->isDeclaration)
2453 lpszMarker[nResult - 1] =
_CXML(
'?');
2454 lpszMarker[nResult] =
_CXML(
'>');
2459 if (lpszMarker) lpszMarker[nResult] =
_CXML(
'\n');
2467 if (lpszMarker) lpszMarker[nResult - 1] =
_CXML(
'>');
2470 if (lpszMarker) lpszMarker[nResult] =
_CXML(
'\n');
2482 if (cbElement && (!pEntry->isDeclaration))
2483 nChildFormat = nFormat + 1;
2485 nChildFormat = nFormat;
2489 for (i = 0; i < nElementI; i++)
2491 j = pEntry->pOrder[i];
2498 XMLCSTR pChild = pEntry->pText[j >> 2];
2507 &lpszMarker[nResult],
INDENTCHAR, nFormat + 1);
2509 &lpszMarker[nResult + nFormat + 1], pChild);
2510 lpszMarker[nResult + nFormat + 1 + cb] =
2513 nResult += cb + nFormat + 2;
2519 &lpszMarker[nResult], pChild);
2529 XMLClear* pChild = pEntry->pClear + (j >> 2);
2539 &lpszMarker[nResult],
INDENTCHAR, nFormat + 1);
2541 &lpszMarker[nResult + nFormat + 1],
2544 nResult += cb + nFormat + 1;
2574 if (lpszMarker) lpszMarker[nResult] =
_CXML(
'\n');
2585 pEntry->pChild[j >> 2].d,
2586 lpszMarker ? lpszMarker + nResult :
nullptr, nChildFormat);
2594 if ((cbElement) && (!pEntry->isDeclaration))
2609 lpszMarker[nResult] =
_CXML(
'<');
2610 lpszMarker[nResult + 1] =
_CXML(
'/');
2612 xstrcpy(&lpszMarker[nResult], pEntry->lpszName);
2613 nResult += cbElement;
2615 lpszMarker[nResult] =
_CXML(
'>');
2620 lpszMarker[nResult + 1] =
_CXML(
'\n');
2627 nResult += cbElement + 4 + nFormat;
2628 else if (nFormat == -1)
2629 nResult += cbElement + 3;
2631 nResult += cbElement + 4;
2641 lpszMarker[nResult] =
_CXML(
'/');
2642 lpszMarker[nResult + 1] =
_CXML(
'>');
2643 if (nFormat != -1) lpszMarker[nResult + 2] =
_CXML(
'\n');
2645 nResult += nFormat == -1 ? 2 : 3;
2667 if (pnSize) *pnSize = 0;
2671 XMLSTR lpszResult =
nullptr;
2676 nFormat = nFormat ? 0 : -1;
2682 lpszResult[cbStr] =
_CXML(
'\0');
2683 if (pnSize) *pnSize = cbStr;
2691 while (((
void*)(pa[i].
d)) != ((
void*)
d)) i++;
2692 d->pParent->nChild--;
2693 if (
d->pParent->nChild)
2694 memmove(pa + i, pa + i + 1, (
d->pParent->nChild - i) *
sizeof(
XMLNode));
2698 d->pParent->pChild =
nullptr;
2715 d->pParent =
nullptr;
2723 if ((dd->ref_count == 0) || force)
2728 for (i = 0; i < dd->nChild; i++)
2730 pc = dd->pChild + i;
2731 pc->
d->pParent =
nullptr;
2736 for (i = 0; i < dd->nText; i++) free((
void*)dd->pText[i]);
2738 for (i = 0; i < dd->nClear; i++) free((
void*)dd->pClear[i].lpszValue);
2740 for (i = 0; i < dd->nAttribute; i++)
2742 free((
void*)dd->pAttribute[i].lpszName);
2743 if (dd->pAttribute[i].lpszValue)
2744 free((
void*)dd->pAttribute[i].lpszValue);
2748 myFree((
void*)dd->lpszName);
2753 dd->pChild =
nullptr;
2754 dd->pText =
nullptr;
2755 dd->pClear =
nullptr;
2756 dd->pAttribute =
nullptr;
2757 dd->pOrder =
nullptr;
2758 dd->lpszName =
nullptr;
2759 dd->pParent =
nullptr;
2761 if (dd->ref_count == 0)
2779 if (
d) (
d->ref_count)++;
2788 if (
d) (
d->ref_count)++;
2796 int n =
d->nAttribute;
2803 p->pAttribute[
n].lpszName =
stringDup(
d->pAttribute[
n].lpszName);
2804 p->pAttribute[
n].lpszValue =
stringDup(
d->pAttribute[
n].lpszValue);
2809 n = (
d->nChild +
d->nText +
d->nClear) *
sizeof(
int);
2810 p->pOrder = (
int*)malloc(
n);
2827 p->pClear[
n].lpszCloseTag =
d->pClear[
n].lpszCloseTag;
2828 p->pClear[
n].lpszOpenTag =
d->pClear[
n].lpszOpenTag;
2839 p->pChild[
n].d =
nullptr;
2840 p->pChild[
n] =
d->pChild[
n].deepCopy();
2841 p->pChild[
n].d->pParent =
p;
2850 if ((!dc) || (!
d))
return childNode;
2873 d->pChild[pos].d = dc;
2880 if ((!
d) || (i < 0) || (i >=
d->nAttribute))
return;
2883 free((
void*)
p->lpszName);
2884 if (
p->lpszValue) free((
void*)
p->lpszValue);
2890 d->pAttribute =
nullptr;
2910 if (lpszNewValue) free(lpszNewValue);
2911 if (lpszNewName) free(lpszNewName);
2914 if (i >=
d->nAttribute)
2920 if (
p->lpszValue &&
p->lpszValue != lpszNewValue) free((
void*)
p->lpszValue);
2921 p->lpszValue = lpszNewValue;
2922 if (lpszNewName &&
p->lpszName != lpszNewName)
2924 free((
void*)
p->lpszName);
2925 p->lpszName = lpszNewName;
2960 int i, l =
d->nText;
2967 for (i = 0; i < l; i++)
2968 if (lpszValue ==
p[i])
return i;
2974 if ((!
d) || (i < 0) || (i >=
d->nText))
return;
2979 memmove(
p,
p + 1, (
d->nText - i) *
sizeof(
XMLCSTR));
2997 if (lpszNewValue) free(lpszNewValue);
3002 if (*
p != lpszNewValue)
3007 return lpszNewValue;
3014 if (lpszNewValue) free(lpszNewValue);
3024 if ((!
d) || (i < 0) || (i >=
d->nClear))
return;
3027 free((
void*)
p->lpszValue);
3029 memmove(
p,
p + 1, (
d->nClear - i) *
sizeof(
XMLClear));
3033 d->pClear =
nullptr;
3041 int i, l =
d->nClear;
3048 for (i = 0; i < l; i++)
3049 if (lpszValue ==
p[i].lpszValue)
return i;
3066 if (lpszNewContent) free(lpszNewContent);
3071 if (lpszNewContent !=
p->lpszValue)
3073 free((
void*)
p->lpszValue);
3074 p->lpszValue = lpszNewContent;
3083 if (lpszNewContent) free(lpszNewContent);
3102 int i, j = 0,
n =
d->nChild;
3104 for (i = 0; i <
n; i++)
3115 int i = 0,
n =
d->nChild;
3151 if (path) free(path);
3158 if ((!path) || (!(*path)))
return *
this;
3163 tend1 =
xstrstr(path, sepString);
3170 if (createIfMissing)
3177 tend1 =
xstrstr(path, sepString);
3186 if (i >=
d->nText) i =
d->nText - 1;
3191 if (i >=
d->nClear) i =
d->nClear - 1;
3196 if (i >=
d->nChild) i =
d->nChild - 1;
3214 if ((!
d) || (!
x.d))
return -1;
3229 if (j < 0)
return -1;
3251 t =
x.getAttribute(attributeName, &j);
3261 if (
x.isAttributeSet(attributeName))
3268 }
while (!
x.isEmpty());
3275 if (!
d)
return nullptr;
3276 int i = 0,
n =
d->nAttribute;
3294 int i,
n =
d->nAttribute;
3296 for (i = 0; i <
n; i++)
3309 if (!
d)
return nullptr;
3326 c.attrib =
d->pAttribute[i];
3331 i = (
d->pOrder[i]) >> 2;
3335 c.child =
d->pChild[i];
3338 c.text =
d->pText[i];
3341 c.clear =
d->pClear[i];
3351 if (!
d)
return nullptr;
3367 return d->nAttribute;
3377 return d->nAttribute +
d->nChild +
d->nText +
d->nClear;
3382 return d->pClear[i];
3387 return d->pAttribute[i];
3391 if ((!
d) || (i >=
d->nAttribute))
return nullptr;
3392 return d->pAttribute[i].lpszName;
3396 if ((!
d) || (i >=
d->nAttribute))
return nullptr;
3397 return d->pAttribute[i].lpszValue;
3401 if ((!
d) || (i >=
d->nText))
return nullptr;
3407 return d->pChild[i];
3417 return d->isDeclaration;
3457 return addClear_priv(0, lpszValue, lpszOpen, lpszClose, pos);
3505 char _dropWhiteSpace,
char _removeCommentsInMiddleOfText)
3513 switch (_characterEncoding)
3544 void* buf,
int l,
char useXMLEncodingAttribute)
3552 auto*
b = (
unsigned char*)buf;
3553 if ((
b[0] == 0xef) && (
b[1] == 0xbb) && (
b[2] == 0xbf))
3563 if ((i < l) && (
b[i] & 0xC0) != 0x80)
3571 if ((i < l) && (
b[i] & 0xC0) != 0x80)
3579 if ((i < l) && (
b[i] & 0xC0) != 0x80)
3592 if (!useXMLEncodingAttribute)
return bestGuess;
3599 b = (
unsigned char*)strstr(bb,
"encoding");
3600 if (!
b)
return bestGuess;
3604 if (*
b !=
'=')
return bestGuess;
3608 if ((*
b !=
'\'') && (*
b !=
'"'))
return bestGuess;
3613 if ((
xstrnicmp((
char*)
b,
"utf-8", 5) == 0) ||
3620 if ((
xstrnicmp((
char*)
b,
"shiftjis", 8) == 0) ||
3621 (
xstrnicmp((
char*)
b,
"shift-jis", 9) == 0) ||
3632 #undef XML_isSPACECHAR 3643 _CXML(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
3649 99, 98, 98, 98, 98, 98, 98, 98, 98, 97, 97, 98, 98, 97, 98, 98,
3650 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
3651 98, 98, 97, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 62, 98, 98,
3652 98, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 98, 98,
3653 98, 96, 98, 98, 98, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
3654 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
3655 25, 98, 98, 98, 98, 98, 98, 26, 27, 28, 29, 30, 31, 32, 33, 34,
3656 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
3657 49, 50, 51, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
3658 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
3659 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
3660 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
3661 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
3662 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
3663 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
3664 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
3665 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98
3678 unsigned int i = ((inlen - 1) / 3 * 4 + 4 + 1);
3679 if (formatted) i += inlen / 54;
3684 unsigned char* inbuf,
unsigned int inlen,
char formatted)
3686 int i =
encodeLength(inlen, formatted), k = 17, eLen = inlen / 3, j;
3689 for (i = 0; i < eLen; i++)
3693 j = (inbuf[0] << 16) | (inbuf[1] << 8) | inbuf[2];
3704 *(curr++) =
_CXML(
'\n');
3710 eLen = inlen - eLen * 3;
3720 j = (inbuf[0] << 8) | inbuf[1];
3756 if (
size == 0)
return 0;
3763 return (
unsigned int)((
size * 3) / 4);
3775 #define BASE64DECODE_READ_NEXT_CHAR(c) \ 3778 if (data[i] > 255) \ 3783 c = base64DecodeTable[(unsigned char)data[i++]]; \ 3784 } while (c == 97); \ 3787 if (xe) *xe = eXMLErrorBase64DecodeIllegalCharacter; \ 3791 #define BASE64DECODE_READ_NEXT_CHAR(c) \ 3794 c = base64DecodeTable[(unsigned char)data[i++]]; \ 3795 } while (c == 97); \ 3798 if (xe) *xe = eXMLErrorBase64DecodeIllegalCharacter; \ 3810 if (
p == (
int)
len)
return 2;
3816 if ((d == 99) || (d == 96))
3826 buf[
p++] = (
unsigned char)((
c << 2) | ((d >> 4) & 0x3));
3836 if (
c == 96)
return 2;
3845 buf[
p++] = (
unsigned char)(((d << 4) & 0xf0) | ((
c >> 2) & 0xf));
3855 if (d == 96)
return 2;
3864 buf[
p++] = (
unsigned char)(((
c << 6) & 0xc0) | d);
3867 #undef BASE64DECODE_READ_NEXT_CHAR 3871 if ((!
buf) && (newsize))
3873 buf = malloc(newsize);
3879 buf = realloc(
buf, newsize);
3889 if (outlen) *outlen =
len;
3890 if (!
len)
return nullptr;
3896 return (
unsigned char*)
buf;
static XMLCSTR getVersion()
Return the XMLParser library version number.
XMLNode getChildNodeWithAttribute(XMLCSTR tagName, XMLCSTR attributeName, XMLCSTR attributeValue=nullptr, int *i=nullptr) const
next child node with specific name (return an empty node if failing)
int nAttribute() const
next attribute content with specific name (return a nullptr if failing)
char isAttributeSet(XMLCSTR name) const
test if an attribute with a specific name is given
static const char XML_gbk_big5_ByteTable[256]
GLuint GLuint GLsizei count
XMLCSTR updateName_WOSD(XMLSTR lpszName)
change node's name
XMLNode getParentNode() const
return the parent node
XMLElementType
Enumeration used to manage type of data.
XMLCSTR base64EncodeTable
XMLCHAR xmltoc(XMLCSTR t, XMLCHAR v)
static ALLXMLClearTag XMLClearTags[]
enum Attrib { eAttribName=0, eAttribEquals, eAttribValue } Attrib
char maybeAddTxT(void *pa, XMLCSTR tokenPStr)
void deleteAttribute(int i=0)
Delete the ith attribute of the current XMLNode.
Main Class representing a XML node.
static void myFree(void *p)
static XMLSTR xstrstr(XMLCSTR c1, XMLCSTR c2)
XMLClear * updateClear(XMLCSTR lpszNewContent, int i=0)
text to update is missing, a new one will be added
XMLError writeToFile(XMLCSTR filename, const char *encoding=nullptr, char nFormat=1) const
Save the content of an xmlNode inside a file.
int void fclose(FILE *f)
An OS-independent version of fclose.
XMLClear * addClear(XMLCSTR lpszValue, XMLCSTR lpszOpen=nullptr, XMLCSTR lpszClose=nullptr, XMLElementPosition pos=-1)
Add a new clear tag.
XMLCharEncoding
childNode with the specified name if (name==nullptr) return the position of the ith childNode ...
int _strnicmp(const char *str, const char *subStr, size_t count) noexcept
An OS-independent version of strnicmp.
static XMLNode parseString(XMLCSTR lpXMLString, XMLCSTR tag=nullptr, XMLResults *pResults=nullptr)
Parse an XML string and return the root of a XMLNode tree representing the string.
XMLNode getChildNodeByPath(XMLSTR path, char createNodeIfMissing=0, XMLCHAR sep='/')
name/attribute (return an empty node if failing)
XMLCSTR updateText(XMLCSTR lpszNewValue, int i=0)
change the name of the attribute if the attribute to update is missing, a new one will be added ...
Structure for XML clear (unformatted) node (usually comments)
void * addToOrder(int memInc, int *_pos, int nc, void *p, int size, XMLElementType xtype)
char isEmpty() const
is this node Empty?
This structure is given by the function XMLNode::enumContents.
static int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l)
XMLSTR stringDup(XMLCSTR lpszData, int cbData)
Duplicate (copy in a new allocated buffer) the source string.
static XMLNode createXMLTopNode(XMLCSTR lpszName, char isDeclaration=FALSE)
Create the top node of an XMLNode structure.
int nClear() const
nbr of clear field
XMLClear * addClear_WOSD(XMLSTR lpszValue, XMLCSTR lpszOpen=nullptr, XMLCSTR lpszClose=nullptr, XMLElementPosition pos=-1)
Add a new clear Tag.
XMLNode addChild_priv(int, XMLSTR, char, int)
static void * myRealloc(void *p, int newsize, int memInc, int sizeofElem)
XMLAttribute * addAttribute_priv(int, XMLSTR, XMLSTR)
static int removeOrderElement(XMLNodeData *d, XMLElementType t, int index)
XMLElementPosition positionOfChildNode(int i=0) const
static const char XML_gb2312ByteTable[256]
static int xstrncmp(XMLCSTR c1, XMLCSTR c2, int l)
static XMLClear emptyXMLClear
void deleteText(int i=0)
with the name "anAttribute->lpszName" (the "strcmp" function is used to find the right attribute) ...
#define BASE64DECODE_READ_NEXT_CHAR(c)
XMLNode & operator=(const XMLNode &A)
to allow shallow/fast copy:
int ParseXMLElement(void *pXML)
static XMLCSTR getError(XMLError error)
this gives you a
int mmin(const int t1, const int t2)
int nChildNode() const
nbr of child node
XMLCSTR getText(int i=0) const
return ith text field
struct XMLAttribute XMLAttribute
Structure for XML attribute.
int nText() const
nbr of text field
static XMLNode createXMLTopNode_WOSD(XMLSTR lpszName, char isDeclaration=FALSE)
Create the top node of an XMLNode structure.
XMLCSTR addText_WOSD(XMLSTR lpszValue, XMLElementPosition pos=-1)
Add a new text content.
XMLAttribute getAttribute(int i=0) const
return ith attribute
static NextToken GetNextToken(XML *pXML, int *pcbToken, enum XMLTokenTypeTag *pType)
XMLCSTR addText_priv(int, XMLSTR, int)
int nElement() const
clear) of the current XMLNode.
static XMLCHAR getNextChar(XML *pXML)
XMLNode addChild_WOSD(XMLSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1)
Add a new child node.
void emptyTheNode(char force)
XMLError
Enumeration for XML parse errors.
XMLCSTR xmltoa(XMLCSTR t, XMLCSTR v)
void deleteNodeContent()
The "deleteNodeContent" function forces the deletion of the content of this XMLNode and the subtree...
static int detachFromParent(XMLNodeData *d)
int indexClear(XMLCSTR lpszValue) const
static XMLNode::XMLCharEncoding characterEncoding
static char setGlobalOptions(XMLCharEncoding characterEncoding=XMLNode::char_encoding_UTF8, char guessWideCharChars=1, char dropWhiteSpace=1, char removeCommentsInMiddleOfText=1)
Sets the global options for the conversions.
XMLAttribute * updateAttribute_WOSD(XMLAttribute *newAttribute, XMLAttribute *oldAttribute)
if the attribute to update is
XMLCSTR updateName(XMLCSTR lpszName)
change node's name
XMLNodeContents enumContents(XMLElementPosition i) const
enumerate all the different contents (attribute,child,text,
static XMLNode emptyNode()
return XMLNode::emptyXMLNode;
#define XML_isSPACECHAR(ch)
XMLElementPosition positionOfText(int i=0) const
XMLElementPosition positionOfClear(int i=0) const
enum Status { eInsideTag=0, eOutsideTag } Status
static void charmemset(XMLSTR dest, XMLCHAR c, int l)
static char dropWhiteSpace
static void CountLinesAndColumns(XMLCSTR lpXML, int nUpto, XMLResults *pResults)
static XMLElementPosition findPosition(XMLNodeData *d, int index, XMLElementType xtype)
static int xstricmp(XMLCSTR c1, XMLCSTR c2)
struct XMLNode::XMLNodeDataTag XMLNodeData
static XMLAttribute emptyXMLAttribute
static XMLSTR xstrcpy(XMLSTR c1, XMLCSTR c2)
static const char XML_sjisByteTable[256]
static XMLCharacterEntity XMLEntities[]
static void exactMemory(XMLNodeData *d)
static FILE * xfopen(XMLCSTR filename, XMLCSTR mode)
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
static XMLCharEncoding guessCharEncoding(void *buffer, int bufLen, char useXMLEncodingAttribute=1)
Guess the character encoding of the string (ascii, utf8 or shift-JIS)
static XMLNode parseFile(XMLCSTR filename, XMLCSTR tag=nullptr, XMLResults *pResults=nullptr)
Parse an XML file and return the root of a XMLNode tree representing the file.
XMLAttribute * updateAttribute(XMLAttribute *newAttribute, XMLAttribute *oldAttribute)
if the attribute to update is
XMLCSTR addText(XMLCSTR lpszValue, XMLElementPosition pos=-1)
Add a new text content.
int indexText(XMLCSTR lpszValue) const
XMLSTR createXMLString(int nFormat=1, int *pnSize=nullptr) const
user-friendly explanation of the parsing error
XMLAttribute * addAttribute_WOSD(XMLSTR lpszName, XMLSTR lpszValue)
Add a new attribute.
XMLCSTR updateText_WOSD(XMLSTR lpszNewValue, int i=0)
change the name of the attribute if the attribute to update is missing, a new one will be added ...
int XMLElementPosition
XMLElementPosition are not interchangeable with simple indexes.
GLdouble GLdouble GLdouble r
char parseClearTag(void *px, void *pa)
static const char * XML_ByteTable
static const char base64Fillchar
static const char XML_utf8ByteTable[256]
XMLClear * updateClear_WOSD(XMLSTR lpszNewContent, int i=0)
is missing, a new one will be added
char myTagCompare(XMLCSTR cclose, XMLCSTR copen)
char xmltob(XMLCSTR t, char v)
GLuint const GLchar * name
GLsizei GLsizei GLchar * source
Structure for XML attribute.
const unsigned char base64DecodeTable[]
static char guessWideCharChars
char myIsTextWideChar(const void *b, int l)
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
XMLNode addChild(XMLCSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1)
Add a new child node.
static int CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nFormat)
long xmltol(XMLCSTR t, long v)
enum XMLTokenTypeTag XMLTokenType
XMLClear getClear(int i=0) const
return ith clear field (comments)
static char removeCommentsInMiddleOfText
char * strcpy(char *dest, size_t destSize, const char *source) noexcept
An OS-independent version of strcpy.
XMLCSTR getAttributeValue(int i=0) const
return ith attribute value
static XMLNode emptyXMLNode
char isDeclaration() const
is this node a declaration <? .... ?>
char * myWideCharToMultiByte(const wchar_t *s)
GLsizei GLsizei GLenum GLenum const GLvoid * data
GLubyte GLubyte GLubyte a
XMLCSTR getAttributeName(int i=0) const
return ith attribute name
void freeXMLString(XMLSTR t)
to free the string allocated inside the "stringDup" function or the "createXMLString" function...
void deleteClear(int i=0)
"lpszValue" inside the current XMLNode (direct "pointer-to-pointer" comparison is used to find the ri...
int nChildNode(XMLCSTR name) const
return the number of child node with specific name
XMLNode deepCopy() const
deep copy (duplicate/clone) a XMLNode
Structure used to obtain error details if the parse fails.
double xmltof(XMLCSTR t, double v)
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
static int xstrlen(XMLCSTR c)
int xmltoi(XMLCSTR t, int v)
XMLSTR fromXMLString(XMLCSTR s, int lo, XML *pXML)
XMLCSTR getName() const
name of the node
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".
XMLNode getChildNode(int i=0) const
return ith child node
XMLAttribute * addAttribute(XMLCSTR lpszName, XMLCSTR lpszValuev)
it will be detached from it's parents before being attached to the current XMLNode ...
static const char XML_legacyByteTable[256]
XMLClear * addClear_priv(int, XMLSTR, XMLCSTR, XMLCSTR, int)
static XMLNode openFileHelper(XMLCSTR filename, XMLCSTR tag=nullptr)
Parse an XML file and return the root of a XMLNode tree representing the file.