Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
xmltok.c File Reference
#include <expat_config.h>
#include <stddef.h>
#include <string.h>
#include <stdbool.h>
#include "expat_external.h"
#include "internal.h"
#include "xmltok.h"
#include "nametab.h"
#include "xmltok_impl.h"
#include "ascii.h"
#include "xmltok_impl.c"
#include "asciitab.h"
#include "utf8tab.h"
#include "iasciitab.h"
#include "latin1tab.h"
#include "xmltok_ns.c"

Go to the source code of this file.

Classes

struct  normal_encoding
 
struct  unknown_encoding
 

Macros

#define IGNORE_SECTION_TOK_VTABLE   , PREFIX(ignoreSectionTok)
 
#define VTABLE1
 
#define VTABLE   VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16)
 
#define UCS2_GET_NAMING(pages, hi, lo)
 
#define UTF8_GET_NAMING2(pages, byte)
 
#define UTF8_GET_NAMING3(pages, byte)
 
#define UTF8_INVALID2(p)
 
#define UTF8_INVALID3(p)
 
#define UTF8_INVALID4(p)
 
#define utf8_isName4   isNever
 
#define utf8_isNmstrt4   isNever
 
#define AS_NORMAL_ENCODING(enc)
 
#define STANDARD_VTABLE(E)
 
#define NORMAL_VTABLE(E)
 
#define NULL_VTABLE
 
#define MINBPC(enc)
 
#define SB_BYTE_TYPE(enc, p)
 
#define BYTE_TYPE(enc, p)
 
#define BYTE_TO_ASCII(enc, p)
 
#define IS_NAME_CHAR(enc, p, n)
 
#define IS_NMSTRT_CHAR(enc, p, n)
 
#define IS_INVALID_CHAR(enc, p, n)
 
#define IS_NAME_CHAR_MINBPC(enc, p)
 
#define IS_NMSTRT_CHAR_MINBPC(enc, p)
 
#define CHAR_MATCHES(enc, p, c)
 
#define PREFIX(ident)
 
#define XML_TOK_IMPL_C
 
#define BT_COLON   BT_NMSTRT
 
#define BT_COLON   BT_NMSTRT
 
#define BT_COLON   BT_NMSTRT
 
#define BT_COLON   BT_NMSTRT
 
#define DEFINE_UTF16_TO_UTF8(E)
 
#define DEFINE_UTF16_TO_UTF16(E)
 
#define SET2(ptr, ch)
 
#define GET_LO(ptr)
 
#define GET_HI(ptr)
 
#define SET2(ptr, ch)
 
#define GET_LO(ptr)
 
#define GET_HI(ptr)
 
#define LITTLE2_BYTE_TYPE(enc, p)
 
#define LITTLE2_BYTE_TO_ASCII(p)
 
#define LITTLE2_CHAR_MATCHES(p, c)
 
#define LITTLE2_IS_NAME_CHAR_MINBPC(p)
 
#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(p)
 
#define PREFIX(ident)
 
#define MINBPC(enc)
 
#define BYTE_TYPE(enc, p)
 
#define BYTE_TO_ASCII(enc, p)
 
#define CHAR_MATCHES(enc, p, c)
 
#define IS_NAME_CHAR(enc, p, n)
 
#define IS_NAME_CHAR_MINBPC(enc, p)
 
#define IS_NMSTRT_CHAR(enc, p, n)
 
#define IS_NMSTRT_CHAR_MINBPC(enc, p)
 
#define XML_TOK_IMPL_C
 
#define BT_COLON   BT_NMSTRT
 
#define BT_COLON   BT_NMSTRT
 
#define BIG2_BYTE_TYPE(enc, p)
 
#define BIG2_BYTE_TO_ASCII(p)
 
#define BIG2_CHAR_MATCHES(p, c)
 
#define BIG2_IS_NAME_CHAR_MINBPC(p)
 
#define BIG2_IS_NMSTRT_CHAR_MINBPC(p)
 
#define PREFIX(ident)
 
#define MINBPC(enc)
 
#define BYTE_TYPE(enc, p)
 
#define BYTE_TO_ASCII(enc, p)
 
#define CHAR_MATCHES(enc, p, c)
 
#define IS_NAME_CHAR(enc, p, n)
 
#define IS_NAME_CHAR_MINBPC(enc, p)
 
#define IS_NMSTRT_CHAR(enc, p, n)
 
#define IS_NMSTRT_CHAR_MINBPC(enc, p)
 
#define XML_TOK_IMPL_C
 
#define BT_COLON   BT_NMSTRT
 
#define AS_UNKNOWN_ENCODING(enc)
 
#define INIT_ENC_INDEX(enc)
 
#define SET_INIT_ENC_INDEX(enc, i)
 
#define NS(x)
 
#define ns(x)
 
#define XML_TOK_NS_C
 
#define NS(x)
 
#define ns(x)
 
#define XML_TOK_NS_C
 

Enumerations

enum  { UTF8_cval1 = 0x00 , UTF8_cval2 = 0xc0 , UTF8_cval3 = 0xe0 , UTF8_cval4 = 0xf0 }
 
enum  {
  UNKNOWN_ENC = -1 , ISO_8859_1_ENC = 0 , US_ASCII_ENC , UTF_8_ENC ,
  UTF_16_ENC , UTF_16BE_ENC , UTF_16LE_ENC , NO_ENC
}
 

Functions

void _INTERNAL_trim_to_complete_utf8_characters (const char *from, const char **fromLimRef)
 
int FASTCALL XmlUtf8Encode (int c, char *buf)
 
int FASTCALL XmlUtf16Encode (int charNum, unsigned short *buf)
 
int XmlSizeOfUnknownEncoding (void)
 
ENCODINGXmlInitUnknownEncoding (void *mem, int *table, CONVERTER convert, void *userData)
 
ENCODINGXmlInitUnknownEncodingNS (void *mem, int *table, CONVERTER convert, void *userData)
 

Macro Definition Documentation

◆ AS_NORMAL_ENCODING

#define AS_NORMAL_ENCODING ( enc)
Value:
((const struct normal_encoding *)(enc))
ENCODING enc
Definition xmltok.c:186

Definition at line 206 of file xmltok.c.

◆ AS_UNKNOWN_ENCODING

#define AS_UNKNOWN_ENCODING ( enc)
Value:
((const struct unknown_encoding *)(enc))

Definition at line 1322 of file xmltok.c.

◆ BIG2_BYTE_TO_ASCII

#define BIG2_BYTE_TO_ASCII ( p)
Value:
((p)[0] == 0 ? (p)[1] : -1)

Definition at line 878 of file xmltok.c.

◆ BIG2_BYTE_TYPE

#define BIG2_BYTE_TYPE ( enc,
p )
Value:
((p)[0] == 0 \
? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \
: unicode_byte_type((p)[0], (p)[1]))

Definition at line 874 of file xmltok.c.

874#define BIG2_BYTE_TYPE(enc, p) \
875 ((p)[0] == 0 \
876 ? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \
877 : unicode_byte_type((p)[0], (p)[1]))

◆ BIG2_CHAR_MATCHES

#define BIG2_CHAR_MATCHES ( p,
c )
Value:
((p)[0] == 0 && (p)[1] == (c))

Definition at line 879 of file xmltok.c.

◆ BIG2_IS_NAME_CHAR_MINBPC

#define BIG2_IS_NAME_CHAR_MINBPC ( p)
Value:
UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])
#define UCS2_GET_NAMING(pages, hi, lo)
Definition xmltok.c:78

Definition at line 880 of file xmltok.c.

880#define BIG2_IS_NAME_CHAR_MINBPC(p) \
881 UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])

◆ BIG2_IS_NMSTRT_CHAR_MINBPC

#define BIG2_IS_NMSTRT_CHAR_MINBPC ( p)
Value:
UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1])

Definition at line 882 of file xmltok.c.

882#define BIG2_IS_NMSTRT_CHAR_MINBPC(p) \
883 UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1])

◆ BT_COLON [1/7]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [2/7]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [3/7]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [4/7]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [5/7]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [6/7]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [7/7]

#define BT_COLON   BT_NMSTRT

◆ BYTE_TO_ASCII [1/3]

#define BYTE_TO_ASCII ( enc,
p )
Value:
(*(p))

Definition at line 266 of file xmltok.c.

◆ BYTE_TO_ASCII [2/3]

#define BYTE_TO_ASCII ( enc,
p )
Value:
#define LITTLE2_BYTE_TO_ASCII(p)
Definition xmltok.c:743

Definition at line 266 of file xmltok.c.

◆ BYTE_TO_ASCII [3/3]

#define BYTE_TO_ASCII ( enc,
p )
Value:
#define BIG2_BYTE_TO_ASCII(p)
Definition xmltok.c:878

Definition at line 266 of file xmltok.c.

◆ BYTE_TYPE [1/3]

#define BYTE_TYPE ( enc,
p )
Value:
SB_BYTE_TYPE(enc, p)
#define SB_BYTE_TYPE(enc, p)
Definition xmltok.c:245

Definition at line 255 of file xmltok.c.

◆ BYTE_TYPE [2/3]

#define BYTE_TYPE ( enc,
p )
Value:
#define LITTLE2_BYTE_TYPE(enc, p)
Definition xmltok.c:740

Definition at line 255 of file xmltok.c.

◆ BYTE_TYPE [3/3]

#define BYTE_TYPE ( enc,
p )
Value:
#define BIG2_BYTE_TYPE(enc, p)
Definition xmltok.c:874

Definition at line 255 of file xmltok.c.

◆ CHAR_MATCHES [1/3]

#define CHAR_MATCHES ( enc,
p,
c )
Value:
(*(p) == (c))

Definition at line 300 of file xmltok.c.

◆ CHAR_MATCHES [2/3]

#define CHAR_MATCHES ( enc,
p,
c )
Value:
#define LITTLE2_CHAR_MATCHES(p, c)
Definition xmltok.c:744

Definition at line 300 of file xmltok.c.

◆ CHAR_MATCHES [3/3]

#define CHAR_MATCHES ( enc,
p,
c )
Value:
#define BIG2_CHAR_MATCHES(p, c)
Definition xmltok.c:879

Definition at line 300 of file xmltok.c.

◆ DEFINE_UTF16_TO_UTF16

#define DEFINE_UTF16_TO_UTF16 ( E)
Value:
static enum XML_Convert_Result PTRCALL E##toUtf16( \
const ENCODING *enc, const char **fromP, const char *fromLim, \
unsigned short **toP, const unsigned short *toLim) { \
UNUSED_P(enc); \
fromLim = *fromP + (((fromLim - *fromP) >> 1) << 1); /* shrink to even */ \
/* Avoid copying first half only of surrogate */ \
if (fromLim - *fromP > ((toLim - *toP) << 1) \
&& (GET_HI(fromLim - 2) & 0xF8) == 0xD8) { \
fromLim -= 2; \
} \
for (; *fromP < fromLim && *toP < toLim; *fromP += 2) \
*(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \
if ((*toP == toLim) && (*fromP < fromLim)) \
else \
return res; \
}
#define PTRCALL
Definition internal.h:85
#define GET_HI(ptr)
Definition xmltok.c:720
#define GET_LO(ptr)
Definition xmltok.c:719
XML_Convert_Result
Definition xmltok.h:163
@ XML_CONVERT_OUTPUT_EXHAUSTED
Definition xmltok.h:166
@ XML_CONVERT_COMPLETED
Definition xmltok.h:164
@ XML_CONVERT_INPUT_INCOMPLETE
Definition xmltok.h:165

Definition at line 697 of file xmltok.c.

697#define DEFINE_UTF16_TO_UTF16(E) \
698 static enum XML_Convert_Result PTRCALL E##toUtf16( \
699 const ENCODING *enc, const char **fromP, const char *fromLim, \
700 unsigned short **toP, const unsigned short *toLim) { \
701 enum XML_Convert_Result res = XML_CONVERT_COMPLETED; \
702 UNUSED_P(enc); \
703 fromLim = *fromP + (((fromLim - *fromP) >> 1) << 1); /* shrink to even */ \
704 /* Avoid copying first half only of surrogate */ \
705 if (fromLim - *fromP > ((toLim - *toP) << 1) \
706 && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) { \
707 fromLim -= 2; \
708 res = XML_CONVERT_INPUT_INCOMPLETE; \
709 } \
710 for (; *fromP < fromLim && *toP < toLim; *fromP += 2) \
711 *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \
712 if ((*toP == toLim) && (*fromP < fromLim)) \
713 return XML_CONVERT_OUTPUT_EXHAUSTED; \
714 else \
715 return res; \
716 }

◆ DEFINE_UTF16_TO_UTF8

#define DEFINE_UTF16_TO_UTF8 ( E)

Definition at line 620 of file xmltok.c.

620#define DEFINE_UTF16_TO_UTF8(E) \
621 static enum XML_Convert_Result PTRCALL E##toUtf8( \
622 const ENCODING *enc, const char **fromP, const char *fromLim, \
623 char **toP, const char *toLim) { \
624 const char *from = *fromP; \
625 UNUSED_P(enc); \
626 fromLim = from + (((fromLim - from) >> 1) << 1); /* shrink to even */ \
627 for (; from < fromLim; from += 2) { \
628 int plane; \
629 unsigned char lo2; \
630 unsigned char lo = GET_LO(from); \
631 unsigned char hi = GET_HI(from); \
632 switch (hi) { \
633 case 0: \
634 if (lo < 0x80) { \
635 if (*toP == toLim) { \
636 *fromP = from; \
637 return XML_CONVERT_OUTPUT_EXHAUSTED; \
638 } \
639 *(*toP)++ = lo; \
640 break; \
641 } \
642 /* fall through */ \
643 case 0x1: \
644 case 0x2: \
645 case 0x3: \
646 case 0x4: \
647 case 0x5: \
648 case 0x6: \
649 case 0x7: \
650 if (toLim - *toP < 2) { \
651 *fromP = from; \
652 return XML_CONVERT_OUTPUT_EXHAUSTED; \
653 } \
654 *(*toP)++ = ((lo >> 6) | (hi << 2) | UTF8_cval2); \
655 *(*toP)++ = ((lo & 0x3f) | 0x80); \
656 break; \
657 default: \
658 if (toLim - *toP < 3) { \
659 *fromP = from; \
660 return XML_CONVERT_OUTPUT_EXHAUSTED; \
661 } \
662 /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \
663 *(*toP)++ = ((hi >> 4) | UTF8_cval3); \
664 *(*toP)++ = (((hi & 0xf) << 2) | (lo >> 6) | 0x80); \
665 *(*toP)++ = ((lo & 0x3f) | 0x80); \
666 break; \
667 case 0xD8: \
668 case 0xD9: \
669 case 0xDA: \
670 case 0xDB: \
671 if (toLim - *toP < 4) { \
672 *fromP = from; \
673 return XML_CONVERT_OUTPUT_EXHAUSTED; \
674 } \
675 if (fromLim - from < 4) { \
676 *fromP = from; \
677 return XML_CONVERT_INPUT_INCOMPLETE; \
678 } \
679 plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \
680 *(*toP)++ = (char)((plane >> 2) | UTF8_cval4); \
681 *(*toP)++ = (((lo >> 2) & 0xF) | ((plane & 0x3) << 4) | 0x80); \
682 from += 2; \
683 lo2 = GET_LO(from); \
684 *(*toP)++ = (((lo & 0x3) << 4) | ((GET_HI(from) & 0x3) << 2) \
685 | (lo2 >> 6) | 0x80); \
686 *(*toP)++ = ((lo2 & 0x3f) | 0x80); \
687 break; \
688 } \
689 } \
690 *fromP = from; \
691 if (from < fromLim) \
692 return XML_CONVERT_INPUT_INCOMPLETE; \
693 else \
694 return XML_CONVERT_COMPLETED; \
695 }

◆ GET_HI [1/2]

#define GET_HI ( ptr)
Value:
((unsigned char)(ptr)[1])

Definition at line 720 of file xmltok.c.

◆ GET_HI [2/2]

#define GET_HI ( ptr)
Value:
((unsigned char)(ptr)[0])

Definition at line 720 of file xmltok.c.

◆ GET_LO [1/2]

#define GET_LO ( ptr)
Value:
((unsigned char)(ptr)[0])

Definition at line 719 of file xmltok.c.

◆ GET_LO [2/2]

#define GET_LO ( ptr)
Value:
((unsigned char)(ptr)[1])

Definition at line 719 of file xmltok.c.

◆ IGNORE_SECTION_TOK_VTABLE

#define IGNORE_SECTION_TOK_VTABLE   , PREFIX(ignoreSectionTok)

Definition at line 63 of file xmltok.c.

◆ INIT_ENC_INDEX

#define INIT_ENC_INDEX ( enc)
Value:
((int)(enc)->initEnc.isUtf16)

Definition at line 1526 of file xmltok.c.

◆ IS_INVALID_CHAR

#define IS_INVALID_CHAR ( enc,
p,
n )
Value:
(AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p))
#define AS_NORMAL_ENCODING(enc)
Definition xmltok.c:206

Definition at line 276 of file xmltok.c.

276# define IS_INVALID_CHAR(enc, p, n) \
277 (AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p))

◆ IS_NAME_CHAR [1/3]

#define IS_NAME_CHAR ( enc,
p,
n )
Value:
(AS_NORMAL_ENCODING(enc)->isName##n(enc, p))

Definition at line 269 of file xmltok.c.

◆ IS_NAME_CHAR [2/3]

#define IS_NAME_CHAR ( enc,
p,
n )
Value:
0

Definition at line 269 of file xmltok.c.

◆ IS_NAME_CHAR [3/3]

#define IS_NAME_CHAR ( enc,
p,
n )
Value:
0

Definition at line 269 of file xmltok.c.

◆ IS_NAME_CHAR_MINBPC [1/3]

#define IS_NAME_CHAR_MINBPC ( enc,
p )
Value:
(0)

Definition at line 286 of file xmltok.c.

◆ IS_NAME_CHAR_MINBPC [2/3]

#define IS_NAME_CHAR_MINBPC ( enc,
p )
Value:
#define LITTLE2_IS_NAME_CHAR_MINBPC(p)
Definition xmltok.c:745

Definition at line 286 of file xmltok.c.

◆ IS_NAME_CHAR_MINBPC [3/3]

#define IS_NAME_CHAR_MINBPC ( enc,
p )
Value:
#define BIG2_IS_NAME_CHAR_MINBPC(p)
Definition xmltok.c:880

Definition at line 286 of file xmltok.c.

◆ IS_NMSTRT_CHAR [1/3]

#define IS_NMSTRT_CHAR ( enc,
p,
n )
Value:
(AS_NORMAL_ENCODING(enc)->isNmstrt##n(enc, p))

Definition at line 270 of file xmltok.c.

◆ IS_NMSTRT_CHAR [2/3]

#define IS_NMSTRT_CHAR ( enc,
p,
n )
Value:
(0)

Definition at line 270 of file xmltok.c.

◆ IS_NMSTRT_CHAR [3/3]

#define IS_NMSTRT_CHAR ( enc,
p,
n )
Value:
(0)

Definition at line 270 of file xmltok.c.

◆ IS_NMSTRT_CHAR_MINBPC [1/3]

#define IS_NMSTRT_CHAR_MINBPC ( enc,
p )
Value:
(0)

Definition at line 287 of file xmltok.c.

◆ IS_NMSTRT_CHAR_MINBPC [2/3]

#define IS_NMSTRT_CHAR_MINBPC ( enc,
p )
Value:
#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(p)
Definition xmltok.c:747

Definition at line 287 of file xmltok.c.

◆ IS_NMSTRT_CHAR_MINBPC [3/3]

#define IS_NMSTRT_CHAR_MINBPC ( enc,
p )
Value:
#define BIG2_IS_NMSTRT_CHAR_MINBPC(p)
Definition xmltok.c:882

Definition at line 287 of file xmltok.c.

◆ LITTLE2_BYTE_TO_ASCII

#define LITTLE2_BYTE_TO_ASCII ( p)
Value:
((p)[1] == 0 ? (p)[0] : -1)

Definition at line 743 of file xmltok.c.

◆ LITTLE2_BYTE_TYPE

#define LITTLE2_BYTE_TYPE ( enc,
p )
Value:
((p)[1] == 0 ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \
: unicode_byte_type((p)[1], (p)[0]))

Definition at line 740 of file xmltok.c.

740#define LITTLE2_BYTE_TYPE(enc, p) \
741 ((p)[1] == 0 ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \
742 : unicode_byte_type((p)[1], (p)[0]))

◆ LITTLE2_CHAR_MATCHES

#define LITTLE2_CHAR_MATCHES ( p,
c )
Value:
((p)[1] == 0 && (p)[0] == (c))

Definition at line 744 of file xmltok.c.

◆ LITTLE2_IS_NAME_CHAR_MINBPC

#define LITTLE2_IS_NAME_CHAR_MINBPC ( p)
Value:
UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0])

Definition at line 745 of file xmltok.c.

745#define LITTLE2_IS_NAME_CHAR_MINBPC(p) \
746 UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0])

◆ LITTLE2_IS_NMSTRT_CHAR_MINBPC

#define LITTLE2_IS_NMSTRT_CHAR_MINBPC ( p)
Value:
UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0])

Definition at line 747 of file xmltok.c.

747#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(p) \
748 UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0])

◆ MINBPC [1/3]

#define MINBPC ( enc)
Value:
1

Definition at line 242 of file xmltok.c.

◆ MINBPC [2/3]

#define MINBPC ( enc)
Value:
2

Definition at line 242 of file xmltok.c.

◆ MINBPC [3/3]

#define MINBPC ( enc)
Value:
2

Definition at line 242 of file xmltok.c.

◆ NORMAL_VTABLE

#define NORMAL_VTABLE ( E)
Value:
E##isName2, E##isName3, E##isName4, E##isNmstrt2, E##isNmstrt3, \
E##isNmstrt4, E##isInvalid2, E##isInvalid3, E##isInvalid4

Definition at line 219 of file xmltok.c.

219#define NORMAL_VTABLE(E) \
220 E##isName2, E##isName3, E##isName4, E##isNmstrt2, E##isNmstrt3, \
221 E##isNmstrt4, E##isInvalid2, E##isInvalid3, E##isInvalid4

◆ NS [1/2]

#define NS ( x)
Value:
x

Definition at line 1648 of file xmltok.c.

◆ NS [2/2]

#define NS ( x)
Value:
x##NS
#define NS(x)
Definition xmltok.c:1648

Definition at line 1648 of file xmltok.c.

◆ ns [1/2]

◆ ns [2/2]

#define ns ( x)
Value:
x##_ns

Definition at line 1649 of file xmltok.c.

◆ NULL_VTABLE

#define NULL_VTABLE
Value:
/* isName2 */ NULL, /* isName3 */ NULL, /* isName4 */ NULL, \
/* isNmstrt2 */ NULL, /* isNmstrt3 */ NULL, /* isNmstrt4 */ NULL, \
/* isInvalid2 */ NULL, /* isInvalid3 */ NULL, /* isInvalid4 */ NULL

Definition at line 223 of file xmltok.c.

223#define NULL_VTABLE \
224 /* isName2 */ NULL, /* isName3 */ NULL, /* isName4 */ NULL, \
225 /* isNmstrt2 */ NULL, /* isNmstrt3 */ NULL, /* isNmstrt4 */ NULL, \
226 /* isInvalid2 */ NULL, /* isInvalid3 */ NULL, /* isInvalid4 */ NULL

◆ PREFIX [1/3]

#define PREFIX ( ident)
Value:
normal_##ident

Definition at line 303 of file xmltok.c.

◆ PREFIX [2/3]

#define PREFIX ( ident)
Value:
little2_##ident

Definition at line 303 of file xmltok.c.

◆ PREFIX [3/3]

#define PREFIX ( ident)
Value:
big2_##ident

Definition at line 303 of file xmltok.c.

◆ SB_BYTE_TYPE

#define SB_BYTE_TYPE ( enc,
p )
Value:
(((struct normal_encoding *)(enc))->type[(unsigned char)*(p)])

Definition at line 245 of file xmltok.c.

245#define SB_BYTE_TYPE(enc, p) \
246 (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)])

◆ SET2 [1/2]

#define SET2 ( ptr,
ch )
Value:
(((ptr)[0] = ((ch)&0xff)), ((ptr)[1] = ((ch) >> 8)))

Definition at line 718 of file xmltok.c.

◆ SET2 [2/2]

#define SET2 ( ptr,
ch )
Value:
(((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch)&0xFF)))

Definition at line 718 of file xmltok.c.

◆ SET_INIT_ENC_INDEX

#define SET_INIT_ENC_INDEX ( enc,
i )
Value:
((enc)->initEnc.isUtf16 = (char)i)

Definition at line 1527 of file xmltok.c.

◆ STANDARD_VTABLE

#define STANDARD_VTABLE ( E)
Value:
/* as nothing */

Definition at line 215 of file xmltok.c.

◆ UCS2_GET_NAMING

#define UCS2_GET_NAMING ( pages,
hi,
lo )
Value:
(namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1u << ((lo)&0x1F)))

Definition at line 78 of file xmltok.c.

78#define UCS2_GET_NAMING(pages, hi, lo) \
79 (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1u << ((lo)&0x1F)))

Referenced by XmlInitUnknownEncoding().

◆ UTF8_GET_NAMING2

#define UTF8_GET_NAMING2 ( pages,
byte )
Value:
(namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \
+ ((((byte)[0]) & 3) << 1) + ((((byte)[1]) >> 5) & 1)] \
& (1u << (((byte)[1]) & 0x1F)))

Definition at line 85 of file xmltok.c.

85#define UTF8_GET_NAMING2(pages, byte) \
86 (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \
87 + ((((byte)[0]) & 3) << 1) + ((((byte)[1]) >> 5) & 1)] \
88 & (1u << (((byte)[1]) & 0x1F)))

◆ UTF8_GET_NAMING3

#define UTF8_GET_NAMING3 ( pages,
byte )
Value:
(namingBitmap \
[((pages)[((((byte)[0]) & 0xF) << 4) + ((((byte)[1]) >> 2) & 0xF)] \
<< 3) \
+ ((((byte)[1]) & 3) << 1) + ((((byte)[2]) >> 5) & 1)] \
& (1u << (((byte)[2]) & 0x1F)))

Definition at line 95 of file xmltok.c.

95#define UTF8_GET_NAMING3(pages, byte) \
96 (namingBitmap \
97 [((pages)[((((byte)[0]) & 0xF) << 4) + ((((byte)[1]) >> 2) & 0xF)] \
98 << 3) \
99 + ((((byte)[1]) & 3) << 1) + ((((byte)[2]) >> 5) & 1)] \
100 & (1u << (((byte)[2]) & 0x1F)))

◆ UTF8_INVALID2

#define UTF8_INVALID2 ( p)
Value:
((*p) < 0xC2 || ((p)[1] & 0x80) == 0 || ((p)[1] & 0xC0) == 0xC0)

Definition at line 112 of file xmltok.c.

112#define UTF8_INVALID2(p) \
113 ((*p) < 0xC2 || ((p)[1] & 0x80) == 0 || ((p)[1] & 0xC0) == 0xC0)

◆ UTF8_INVALID3

#define UTF8_INVALID3 ( p)
Value:
(((p)[2] & 0x80) == 0 \
|| ((*p) == 0xEF && (p)[1] == 0xBF ? (p)[2] > 0xBD \
: ((p)[2] & 0xC0) == 0xC0) \
|| ((*p) == 0xE0 \
? (p)[1] < 0xA0 || ((p)[1] & 0xC0) == 0xC0 \
: ((p)[1] & 0x80) == 0 \
|| ((*p) == 0xED ? (p)[1] > 0x9F : ((p)[1] & 0xC0) == 0xC0)))

Definition at line 115 of file xmltok.c.

115#define UTF8_INVALID3(p) \
116 (((p)[2] & 0x80) == 0 \
117 || ((*p) == 0xEF && (p)[1] == 0xBF ? (p)[2] > 0xBD \
118 : ((p)[2] & 0xC0) == 0xC0) \
119 || ((*p) == 0xE0 \
120 ? (p)[1] < 0xA0 || ((p)[1] & 0xC0) == 0xC0 \
121 : ((p)[1] & 0x80) == 0 \
122 || ((*p) == 0xED ? (p)[1] > 0x9F : ((p)[1] & 0xC0) == 0xC0)))

◆ UTF8_INVALID4

#define UTF8_INVALID4 ( p)
Value:
(((p)[3] & 0x80) == 0 || ((p)[3] & 0xC0) == 0xC0 || ((p)[2] & 0x80) == 0 \
|| ((p)[2] & 0xC0) == 0xC0 \
|| ((*p) == 0xF0 \
? (p)[1] < 0x90 || ((p)[1] & 0xC0) == 0xC0 \
: ((p)[1] & 0x80) == 0 \
|| ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0)))

Definition at line 124 of file xmltok.c.

124#define UTF8_INVALID4(p) \
125 (((p)[3] & 0x80) == 0 || ((p)[3] & 0xC0) == 0xC0 || ((p)[2] & 0x80) == 0 \
126 || ((p)[2] & 0xC0) == 0xC0 \
127 || ((*p) == 0xF0 \
128 ? (p)[1] < 0x90 || ((p)[1] & 0xC0) == 0xC0 \
129 : ((p)[1] & 0x80) == 0 \
130 || ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0)))

◆ utf8_isName4

#define utf8_isName4   isNever

Definition at line 151 of file xmltok.c.

◆ utf8_isNmstrt4

#define utf8_isNmstrt4   isNever

Definition at line 165 of file xmltok.c.

◆ VTABLE

#define VTABLE   VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16)

Definition at line 76 of file xmltok.c.

◆ VTABLE1

#define VTABLE1
Value:
{PREFIX(prologTok), PREFIX(contentTok), \
PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE}, \
{PREFIX(attributeValueTok), PREFIX(entityValueTok)}, \
PREFIX(nameMatchesAscii), PREFIX(nameLength), PREFIX(skipS), \
PREFIX(getAtts), PREFIX(charRefNumber), PREFIX(predefinedEntityName), \
PREFIX(updatePosition), PREFIX(isPublicId)
#define IGNORE_SECTION_TOK_VTABLE
Definition xmltok.c:63
#define PREFIX(ident)
Definition xmltok.c:303

Definition at line 68 of file xmltok.c.

68#define VTABLE1 \
69 {PREFIX(prologTok), PREFIX(contentTok), \
70 PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE}, \
71 {PREFIX(attributeValueTok), PREFIX(entityValueTok)}, \
72 PREFIX(nameMatchesAscii), PREFIX(nameLength), PREFIX(skipS), \
73 PREFIX(getAtts), PREFIX(charRefNumber), PREFIX(predefinedEntityName), \
74 PREFIX(updatePosition), PREFIX(isPublicId)

◆ XML_TOK_IMPL_C [1/3]

#define XML_TOK_IMPL_C

Definition at line 304 of file xmltok.c.

◆ XML_TOK_IMPL_C [2/3]

#define XML_TOK_IMPL_C

Definition at line 304 of file xmltok.c.

◆ XML_TOK_IMPL_C [3/3]

#define XML_TOK_IMPL_C

Definition at line 304 of file xmltok.c.

◆ XML_TOK_NS_C [1/2]

#define XML_TOK_NS_C

Definition at line 1650 of file xmltok.c.

◆ XML_TOK_NS_C [2/2]

#define XML_TOK_NS_C

Definition at line 1650 of file xmltok.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UTF8_cval1 
UTF8_cval2 
UTF8_cval3 
UTF8_cval4 

Definition at line 318 of file xmltok.c.

318 { /* UTF8_cvalN is value of masked first byte of N byte sequence */
319 UTF8_cval1 = 0x00,
320 UTF8_cval2 = 0xc0,
321 UTF8_cval3 = 0xe0,
322 UTF8_cval4 = 0xf0
323};
@ UTF8_cval4
Definition xmltok.c:322
@ UTF8_cval1
Definition xmltok.c:319
@ UTF8_cval2
Definition xmltok.c:320
@ UTF8_cval3
Definition xmltok.c:321

◆ anonymous enum

anonymous enum
Enumerator
UNKNOWN_ENC 
ISO_8859_1_ENC 
US_ASCII_ENC 
UTF_8_ENC 
UTF_16_ENC 
UTF_16BE_ENC 
UTF_16LE_ENC 
NO_ENC 

Definition at line 1479 of file xmltok.c.

1479 {
1480 UNKNOWN_ENC = -1,
1481 ISO_8859_1_ENC = 0,
1483 UTF_8_ENC,
1484 UTF_16_ENC,
1487 /* must match encodingNames up to here */
1488 NO_ENC
1489};
@ NO_ENC
Definition xmltok.c:1488
@ US_ASCII_ENC
Definition xmltok.c:1482
@ ISO_8859_1_ENC
Definition xmltok.c:1481
@ UTF_8_ENC
Definition xmltok.c:1483
@ UTF_16_ENC
Definition xmltok.c:1484
@ UNKNOWN_ENC
Definition xmltok.c:1480
@ UTF_16BE_ENC
Definition xmltok.c:1485
@ UTF_16LE_ENC
Definition xmltok.c:1486

Function Documentation

◆ _INTERNAL_trim_to_complete_utf8_characters()

void _INTERNAL_trim_to_complete_utf8_characters ( const char * from,
const char ** fromLimRef )

Definition at line 326 of file xmltok.c.

327 {
328 const char *fromLim = *fromLimRef;
329 size_t walked = 0;
330 for (; fromLim > from; fromLim--, walked++) {
331 const unsigned char prev = (unsigned char)fromLim[-1];
332 if ((prev & 0xf8u)
333 == 0xf0u) { /* 4-byte character, lead by 0b11110xxx byte */
334 if (walked + 1 >= 4) {
335 fromLim += 4 - 1;
336 break;
337 } else {
338 walked = 0;
339 }
340 } else if ((prev & 0xf0u)
341 == 0xe0u) { /* 3-byte character, lead by 0b1110xxxx byte */
342 if (walked + 1 >= 3) {
343 fromLim += 3 - 1;
344 break;
345 } else {
346 walked = 0;
347 }
348 } else if ((prev & 0xe0u)
349 == 0xc0u) { /* 2-byte character, lead by 0b110xxxxx byte */
350 if (walked + 1 >= 2) {
351 fromLim += 2 - 1;
352 break;
353 } else {
354 walked = 0;
355 }
356 } else if ((prev & 0x80u)
357 == 0x00u) { /* 1-byte character, matching 0b0xxxxxxx */
358 break;
359 }
360 }
361 *fromLimRef = fromLim;
362}

◆ XmlInitUnknownEncoding()

ENCODING * XmlInitUnknownEncoding ( void * mem,
int * table,
CONVERTER convert,
void * userData )

Definition at line 1406 of file xmltok.c.

1407 {
1408 int i;
1409 struct unknown_encoding *e = (struct unknown_encoding *)mem;
1410 memcpy(mem, &latin1_encoding, sizeof(struct normal_encoding));
1411 for (i = 0; i < 128; i++)
1412 if (latin1_encoding.type[i] != BT_OTHER
1413 && latin1_encoding.type[i] != BT_NONXML && table[i] != i)
1414 return 0;
1415 for (i = 0; i < 256; i++) {
1416 int c = table[i];
1417 if (c == -1) {
1418 e->normal.type[i] = BT_MALFORM;
1419 /* This shouldn't really get used. */
1420 e->utf16[i] = 0xFFFF;
1421 e->utf8[i][0] = 1;
1422 e->utf8[i][1] = 0;
1423 } else if (c < 0) {
1424 if (c < -4)
1425 return 0;
1426 /* Multi-byte sequences need a converter function */
1427 if (! convert)
1428 return 0;
1429 e->normal.type[i] = (unsigned char)(BT_LEAD2 - (c + 2));
1430 e->utf8[i][0] = 0;
1431 e->utf16[i] = 0;
1432 } else if (c < 0x80) {
1433 if (latin1_encoding.type[c] != BT_OTHER
1434 && latin1_encoding.type[c] != BT_NONXML && c != i)
1435 return 0;
1436 e->normal.type[i] = latin1_encoding.type[c];
1437 e->utf8[i][0] = 1;
1438 e->utf8[i][1] = (char)c;
1439 e->utf16[i] = (unsigned short)(c == 0 ? 0xFFFF : c);
1440 } else if (checkCharRefNumber(c) < 0) {
1441 e->normal.type[i] = BT_NONXML;
1442 /* This shouldn't really get used. */
1443 e->utf16[i] = 0xFFFF;
1444 e->utf8[i][0] = 1;
1445 e->utf8[i][1] = 0;
1446 } else {
1447 if (c > 0xFFFF)
1448 return 0;
1449 if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff))
1450 e->normal.type[i] = BT_NMSTRT;
1451 else if (UCS2_GET_NAMING(namePages, c >> 8, c & 0xff))
1452 e->normal.type[i] = BT_NAME;
1453 else
1454 e->normal.type[i] = BT_OTHER;
1455 e->utf8[i][0] = (char)XmlUtf8Encode(c, e->utf8[i] + 1);
1456 e->utf16[i] = (unsigned short)c;
1457 }
1458 }
1459 e->userData = userData;
1460 e->convert = convert;
1461 if (convert) {
1462 e->normal.isName2 = unknown_isName;
1463 e->normal.isName3 = unknown_isName;
1464 e->normal.isName4 = unknown_isName;
1465 e->normal.isNmstrt2 = unknown_isNmstrt;
1466 e->normal.isNmstrt3 = unknown_isNmstrt;
1467 e->normal.isNmstrt4 = unknown_isNmstrt;
1468 e->normal.isInvalid2 = unknown_isInvalid;
1469 e->normal.isInvalid3 = unknown_isInvalid;
1470 e->normal.isInvalid4 = unknown_isInvalid;
1471 }
1472 e->normal.enc.utf8Convert = unknown_toUtf8;
1473 e->normal.enc.utf16Convert = unknown_toUtf16;
1474 return &(e->normal.enc);
1475}
BT_OTHER
Definition asciitab.h:44
BT_NMSTRT
Definition asciitab.h:52
BT_NAME
Definition asciitab.h:46
BT_NONXML
Definition asciitab.h:35
unsigned char type[256]
Definition xmltok.c:187
unsigned short utf16[256]
Definition xmltok.c:1318
CONVERTER convert
Definition xmltok.c:1316
void * userData
Definition xmltok.c:1317
char utf8[256][4]
Definition xmltok.c:1319
struct normal_encoding normal
Definition xmltok.c:1315
BT_MALFORM
Definition utf8tab.h:66
BT_LEAD2
Definition utf8tab.h:51
int FASTCALL XmlUtf8Encode(int c, char *buf)
Definition xmltok.c:1262

Referenced by XmlInitUnknownEncodingNS().

◆ XmlInitUnknownEncodingNS()

ENCODING * XmlInitUnknownEncodingNS ( void * mem,
int * table,
CONVERTER convert,
void * userData )

Definition at line 1669 of file xmltok.c.

1670 {
1671 ENCODING *enc = XmlInitUnknownEncoding(mem, table, convert, userData);
1672 if (enc)
1674 return enc;
1675}
#define ASCII_COLON
Definition ascii.h:109
ENCODING * XmlInitUnknownEncoding(void *mem, int *table, CONVERTER convert, void *userData)
Definition xmltok.c:1406
#define BT_COLON

◆ XmlSizeOfUnknownEncoding()

int XmlSizeOfUnknownEncoding ( void )

Definition at line 1325 of file xmltok.c.

1325 {
1326 return sizeof(struct unknown_encoding);
1327}

◆ XmlUtf16Encode()

int FASTCALL XmlUtf16Encode ( int charNum,
unsigned short * buf )

Definition at line 1298 of file xmltok.c.

1298 {
1299 if (charNum < 0)
1300 return 0;
1301 if (charNum < 0x10000) {
1302 buf[0] = (unsigned short)charNum;
1303 return 1;
1304 }
1305 if (charNum < 0x110000) {
1306 charNum -= 0x10000;
1307 buf[0] = (unsigned short)((charNum >> 10) + 0xD800);
1308 buf[1] = (unsigned short)((charNum & 0x3FF) + 0xDC00);
1309 return 2;
1310 }
1311 return 0;
1312}

◆ XmlUtf8Encode()

int FASTCALL XmlUtf8Encode ( int c,
char * buf )

Definition at line 1262 of file xmltok.c.

1262 {
1263 enum {
1264 /* minN is minimum legal resulting value for N byte sequence */
1265 min2 = 0x80,
1266 min3 = 0x800,
1267 min4 = 0x10000
1268 };
1269
1270 if (c < 0)
1271 return 0; /* LCOV_EXCL_LINE: this case is always eliminated beforehand */
1272 if (c < min2) {
1273 buf[0] = (char)(c | UTF8_cval1);
1274 return 1;
1275 }
1276 if (c < min3) {
1277 buf[0] = (char)((c >> 6) | UTF8_cval2);
1278 buf[1] = (char)((c & 0x3f) | 0x80);
1279 return 2;
1280 }
1281 if (c < min4) {
1282 buf[0] = (char)((c >> 12) | UTF8_cval3);
1283 buf[1] = (char)(((c >> 6) & 0x3f) | 0x80);
1284 buf[2] = (char)((c & 0x3f) | 0x80);
1285 return 3;
1286 }
1287 if (c < 0x110000) {
1288 buf[0] = (char)((c >> 18) | UTF8_cval4);
1289 buf[1] = (char)(((c >> 12) & 0x3f) | 0x80);
1290 buf[2] = (char)(((c >> 6) & 0x3f) | 0x80);
1291 buf[3] = (char)((c & 0x3f) | 0x80);
1292 return 4;
1293 }
1294 return 0; /* LCOV_EXCL_LINE: this case too is eliminated before calling */
1295}

Referenced by XmlInitUnknownEncoding().