BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
xmltok.c File Reference
#include "xmldef.h"
#include "xmltok.h"
#include "nametab.h"
#include "xmltok_impl.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 VTABLE1
 
#define VTABLE   VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16)
 
#define UCS2_GET_NAMING(pages, hi, lo)    (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1 << ((lo) & 0x1F)))
 
#define UTF8_GET_NAMING2(pages, byte)
 
#define UTF8_GET_NAMING3(pages, byte)
 
#define UTF8_GET_NAMING(pages, p, n)
 
#define UTF8_INVALID3(p)
 
#define UTF8_INVALID4(p)   ((*p) == 0xF4 && ((p)[1] & 0x30) != 0)
 
#define utf8_isName4   isNever
 
#define utf8_isNmstrt4   isNever
 
#define utf8_isInvalid2   isNever
 
#define STANDARD_VTABLE(E)   /* as nothing */
 
#define NORMAL_VTABLE(E)
 
#define MINBPC(enc)   1
 
#define SB_BYTE_TYPE(enc, p)    (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)])
 
#define BYTE_TYPE(enc, p)   SB_BYTE_TYPE(enc, p)
 
#define BYTE_TO_ASCII(enc, p)   (*p)
 
#define IS_NAME_CHAR(enc, p, n)    (((const struct normal_encoding *)(enc))->isName ## n(enc, p))
 
#define IS_NMSTRT_CHAR(enc, p, n)    (((const struct normal_encoding *)(enc))->isNmstrt ## n(enc, p))
 
#define IS_INVALID_CHAR(enc, p, n)    (((const struct normal_encoding *)(enc))->isInvalid ## n(enc, p))
 
#define IS_NAME_CHAR_MINBPC(enc, p)   (0)
 
#define IS_NMSTRT_CHAR_MINBPC(enc, p)   (0)
 
#define CHAR_MATCHES(enc, p, c)   (*(p) == c)
 
#define PREFIX(ident)   normal_ ## ident
 
#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)    (((ptr)[0] = ((ch) & 0xff)), ((ptr)[1] = ((ch) >> 8)))
 
#define GET_LO(ptr)   ((unsigned char)(ptr)[0])
 
#define GET_HI(ptr)   ((unsigned char)(ptr)[1])
 
#define SET2(ptr, ch)    (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch) & 0xFF)))
 
#define GET_LO(ptr)   ((unsigned char)(ptr)[1])
 
#define GET_HI(ptr)   ((unsigned char)(ptr)[0])
 
#define LITTLE2_BYTE_TYPE(enc, p)
 
#define LITTLE2_BYTE_TO_ASCII(enc, p)   ((p)[1] == 0 ? (p)[0] : -1)
 
#define LITTLE2_CHAR_MATCHES(enc, p, c)   ((p)[1] == 0 && (p)[0] == c)
 
#define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)    UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0])
 
#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)    UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0])
 
#define PREFIX(ident)   little2_ ## ident
 
#define MINBPC(enc)   2
 
#define BYTE_TYPE(enc, p)   LITTLE2_BYTE_TYPE(enc, p)
 
#define BYTE_TO_ASCII(enc, p)   LITTLE2_BYTE_TO_ASCII(enc, p)
 
#define CHAR_MATCHES(enc, p, c)   LITTLE2_CHAR_MATCHES(enc, p, c)
 
#define IS_NAME_CHAR(enc, p, n)   0
 
#define IS_NAME_CHAR_MINBPC(enc, p)   LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)
 
#define IS_NMSTRT_CHAR(enc, p, n)   (0)
 
#define IS_NMSTRT_CHAR_MINBPC(enc, p)   LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)
 
#define BT_COLON   BT_NMSTRT
 
#define BT_COLON   BT_NMSTRT
 
#define BIG2_BYTE_TYPE(enc, p)
 
#define BIG2_BYTE_TO_ASCII(enc, p)   ((p)[0] == 0 ? (p)[1] : -1)
 
#define BIG2_CHAR_MATCHES(enc, p, c)   ((p)[0] == 0 && (p)[1] == c)
 
#define BIG2_IS_NAME_CHAR_MINBPC(enc, p)    UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])
 
#define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)    UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1])
 
#define PREFIX(ident)   big2_ ## ident
 
#define MINBPC(enc)   2
 
#define BYTE_TYPE(enc, p)   BIG2_BYTE_TYPE(enc, p)
 
#define BYTE_TO_ASCII(enc, p)   BIG2_BYTE_TO_ASCII(enc, p)
 
#define CHAR_MATCHES(enc, p, c)   BIG2_CHAR_MATCHES(enc, p, c)
 
#define IS_NAME_CHAR(enc, p, n)   0
 
#define IS_NAME_CHAR_MINBPC(enc, p)   BIG2_IS_NAME_CHAR_MINBPC(enc, p)
 
#define IS_NMSTRT_CHAR(enc, p, n)   (0)
 
#define IS_NMSTRT_CHAR_MINBPC(enc, p)   BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)
 
#define BT_COLON   BT_NMSTRT
 
#define BT_COLON   BT_NMSTRT
 
#define INIT_ENC_INDEX(enc)   ((enc)->initEnc.isUtf16)
 
#define NS(x)   x
 
#define ns(x)   x
 

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

int XmlUtf8Encode (int c, char *buf)
 
int XmlUtf16Encode (int charNum, unsigned short *buf)
 
int XmlSizeOfUnknownEncoding ()
 
ENCODING * XmlInitUnknownEncoding (void *mem, int *table, int(*convert)(void *userData, const char *p), void *userData)
 

Macro Definition Documentation

◆ BIG2_BYTE_TO_ASCII

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

Definition at line 740 of file xmltok.c.

◆ BIG2_BYTE_TYPE

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

Definition at line 736 of file xmltok.c.

◆ BIG2_CHAR_MATCHES

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

Definition at line 741 of file xmltok.c.

◆ BIG2_IS_NAME_CHAR_MINBPC

#define BIG2_IS_NAME_CHAR_MINBPC (   enc,
 
)     UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])

Definition at line 742 of file xmltok.c.

◆ BIG2_IS_NMSTRT_CHAR_MINBPC

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

Definition at line 744 of file xmltok.c.

◆ BT_COLON [1/8]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [2/8]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [3/8]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [4/8]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [5/8]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [6/8]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [7/8]

#define BT_COLON   BT_NMSTRT

◆ BT_COLON [8/8]

#define BT_COLON   BT_NMSTRT

◆ BYTE_TO_ASCII [1/3]

#define BYTE_TO_ASCII (   enc,
 
)    (*p)

Definition at line 789 of file xmltok.c.

◆ BYTE_TO_ASCII [2/3]

#define BYTE_TO_ASCII (   enc,
 
)    LITTLE2_BYTE_TO_ASCII(enc, p)

Definition at line 789 of file xmltok.c.

◆ BYTE_TO_ASCII [3/3]

#define BYTE_TO_ASCII (   enc,
 
)    BIG2_BYTE_TO_ASCII(enc, p)

Definition at line 789 of file xmltok.c.

◆ BYTE_TYPE [1/3]

#define BYTE_TYPE (   enc,
 
)    SB_BYTE_TYPE(enc, p)

Definition at line 788 of file xmltok.c.

◆ BYTE_TYPE [2/3]

#define BYTE_TYPE (   enc,
 
)    LITTLE2_BYTE_TYPE(enc, p)

Definition at line 788 of file xmltok.c.

◆ BYTE_TYPE [3/3]

#define BYTE_TYPE (   enc,
 
)    BIG2_BYTE_TYPE(enc, p)

Definition at line 788 of file xmltok.c.

◆ CHAR_MATCHES [1/3]

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

Definition at line 790 of file xmltok.c.

◆ CHAR_MATCHES [2/3]

#define CHAR_MATCHES (   enc,
  p,
 
)    LITTLE2_CHAR_MATCHES(enc, p, c)

Definition at line 790 of file xmltok.c.

◆ CHAR_MATCHES [3/3]

#define CHAR_MATCHES (   enc,
  p,
 
)    BIG2_CHAR_MATCHES(enc, p, c)

Definition at line 790 of file xmltok.c.

◆ DEFINE_UTF16_TO_UTF16

#define DEFINE_UTF16_TO_UTF16 (   E)
Value:
static \
void E ## toUtf16(const ENCODING *enc, \
const char **fromP, const char *fromLim, \
unsigned short **toP, const unsigned short *toLim) \
{ \
/* 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); \
}
#define GET_HI(ptr)
Definition: xmltok.c:588
#define GET_LO(ptr)
Definition: xmltok.c:587

Definition at line 559 of file xmltok.c.

◆ DEFINE_UTF16_TO_UTF8

#define DEFINE_UTF16_TO_UTF8 (   E)

Definition at line 496 of file xmltok.c.

◆ GET_HI [1/2]

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

Definition at line 588 of file xmltok.c.

◆ GET_HI [2/2]

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

Definition at line 588 of file xmltok.c.

◆ GET_LO [1/2]

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

Definition at line 587 of file xmltok.c.

◆ GET_LO [2/2]

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

Definition at line 587 of file xmltok.c.

◆ INIT_ENC_INDEX

#define INIT_ENC_INDEX (   enc)    ((enc)->initEnc.isUtf16)

Definition at line 1378 of file xmltok.c.

◆ IS_INVALID_CHAR

#define IS_INVALID_CHAR (   enc,
  p,
  n 
)     (((const struct normal_encoding *)(enc))->isInvalid ## n(enc, p))

Definition at line 237 of file xmltok.c.

◆ IS_NAME_CHAR [1/3]

#define IS_NAME_CHAR (   enc,
  p,
  n 
)     (((const struct normal_encoding *)(enc))->isName ## n(enc, p))

Definition at line 791 of file xmltok.c.

◆ IS_NAME_CHAR [2/3]

#define IS_NAME_CHAR (   enc,
  p,
  n 
)    0

Definition at line 791 of file xmltok.c.

◆ IS_NAME_CHAR [3/3]

#define IS_NAME_CHAR (   enc,
  p,
  n 
)    0

Definition at line 791 of file xmltok.c.

◆ IS_NAME_CHAR_MINBPC [1/3]

#define IS_NAME_CHAR_MINBPC (   enc,
 
)    (0)

Definition at line 792 of file xmltok.c.

◆ IS_NAME_CHAR_MINBPC [2/3]

#define IS_NAME_CHAR_MINBPC (   enc,
 
)    LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)

Definition at line 792 of file xmltok.c.

◆ IS_NAME_CHAR_MINBPC [3/3]

#define IS_NAME_CHAR_MINBPC (   enc,
 
)    BIG2_IS_NAME_CHAR_MINBPC(enc, p)

Definition at line 792 of file xmltok.c.

◆ IS_NMSTRT_CHAR [1/3]

#define IS_NMSTRT_CHAR (   enc,
  p,
  n 
)     (((const struct normal_encoding *)(enc))->isNmstrt ## n(enc, p))

Definition at line 793 of file xmltok.c.

◆ IS_NMSTRT_CHAR [2/3]

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

Definition at line 793 of file xmltok.c.

◆ IS_NMSTRT_CHAR [3/3]

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

Definition at line 793 of file xmltok.c.

◆ IS_NMSTRT_CHAR_MINBPC [1/3]

#define IS_NMSTRT_CHAR_MINBPC (   enc,
 
)    (0)

Definition at line 794 of file xmltok.c.

◆ IS_NMSTRT_CHAR_MINBPC [2/3]

#define IS_NMSTRT_CHAR_MINBPC (   enc,
 
)    LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)

Definition at line 794 of file xmltok.c.

◆ IS_NMSTRT_CHAR_MINBPC [3/3]

#define IS_NMSTRT_CHAR_MINBPC (   enc,
 
)    BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)

Definition at line 794 of file xmltok.c.

◆ LITTLE2_BYTE_TO_ASCII

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

Definition at line 601 of file xmltok.c.

◆ LITTLE2_BYTE_TYPE

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

Definition at line 597 of file xmltok.c.

◆ LITTLE2_CHAR_MATCHES

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

Definition at line 602 of file xmltok.c.

◆ LITTLE2_IS_NAME_CHAR_MINBPC

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

Definition at line 603 of file xmltok.c.

◆ LITTLE2_IS_NMSTRT_CHAR_MINBPC

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

Definition at line 605 of file xmltok.c.

◆ MINBPC [1/3]

#define MINBPC (   enc)    1

Definition at line 786 of file xmltok.c.

◆ MINBPC [2/3]

#define MINBPC (   enc)    2

Definition at line 786 of file xmltok.c.

◆ MINBPC [3/3]

#define MINBPC (   enc)    2

Definition at line 786 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 179 of file xmltok.c.

◆ NS

#define NS (   x)    x

Definition at line 1503 of file xmltok.c.

◆ ns

#define ns (   x)    x

Definition at line 1504 of file xmltok.c.

◆ PREFIX [1/3]

#define PREFIX (   ident)    normal_ ## ident

Definition at line 785 of file xmltok.c.

◆ PREFIX [2/3]

#define PREFIX (   ident)    little2_ ## ident

Definition at line 785 of file xmltok.c.

◆ PREFIX [3/3]

#define PREFIX (   ident)    big2_ ## ident

Definition at line 785 of file xmltok.c.

◆ SB_BYTE_TYPE

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

Definition at line 206 of file xmltok.c.

◆ SET2 [1/2]

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

Definition at line 585 of file xmltok.c.

◆ SET2 [2/2]

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

Definition at line 585 of file xmltok.c.

◆ STANDARD_VTABLE

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

Definition at line 175 of file xmltok.c.

◆ UCS2_GET_NAMING

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

Definition at line 54 of file xmltok.c.

◆ UTF8_GET_NAMING

#define UTF8_GET_NAMING (   pages,
  p,
  n 
)
Value:
((n) == 2 \
? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \
: ((n) == 3 \
? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) \
: 0))
const Int_t n
#define UTF8_GET_NAMING3(pages, byte)
Definition: xmltok.c:71
#define UTF8_GET_NAMING2(pages, byte)
Definition: xmltok.c:61

Definition at line 79 of file xmltok.c.

◆ 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)] \
& (1 << (((byte)[1]) & 0x1F)))

Definition at line 61 of file xmltok.c.

◆ 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)] \
& (1 << (((byte)[2]) & 0x1F)))

Definition at line 71 of file xmltok.c.

◆ UTF8_INVALID3

#define UTF8_INVALID3 (   p)
Value:
((*p) == 0xED \
? (((p)[1] & 0x20) != 0) \
: ((*p) == 0xEF \
? ((p)[1] == 0xBF && ((p)[2] == 0xBF || (p)[2] == 0xBE)) \
: 0))

Definition at line 86 of file xmltok.c.

◆ UTF8_INVALID4

#define UTF8_INVALID4 (   p)    ((*p) == 0xF4 && ((p)[1] & 0x30) != 0)

Definition at line 93 of file xmltok.c.

◆ utf8_isInvalid2

#define utf8_isInvalid2   isNever

Definition at line 129 of file xmltok.c.

◆ utf8_isName4

#define utf8_isName4   isNever

Definition at line 113 of file xmltok.c.

◆ utf8_isNmstrt4

#define utf8_isNmstrt4   isNever

Definition at line 127 of file xmltok.c.

◆ VTABLE

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

Definition at line 52 of file xmltok.c.

◆ VTABLE1

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

Definition at line 39 of file xmltok.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UTF8_cval1 
UTF8_cval2 
UTF8_cval3 
UTF8_cval4 

Definition at line 276 of file xmltok.c.

276 { /* UTF8_cvalN is value of masked first byte of N byte sequence */
277 UTF8_cval1 = 0x00,
278 UTF8_cval2 = 0xc0,
279 UTF8_cval3 = 0xe0,
280 UTF8_cval4 = 0xf0
281};
@ UTF8_cval4
Definition: xmltok.c:280
@ UTF8_cval1
Definition: xmltok.c:277
@ UTF8_cval2
Definition: xmltok.c:278
@ UTF8_cval3
Definition: xmltok.c:279

◆ 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 1343 of file xmltok.c.

1343 {
1344 UNKNOWN_ENC = -1,
1345 ISO_8859_1_ENC = 0,
1347 UTF_8_ENC,
1348 UTF_16_ENC,
1351 /* must match encodingNames up to here */
1352 NO_ENC
1353};
@ NO_ENC
Definition: xmltok.c:1352
@ US_ASCII_ENC
Definition: xmltok.c:1346
@ ISO_8859_1_ENC
Definition: xmltok.c:1345
@ UTF_8_ENC
Definition: xmltok.c:1347
@ UTF_16_ENC
Definition: xmltok.c:1348
@ UNKNOWN_ENC
Definition: xmltok.c:1344
@ UTF_16BE_ENC
Definition: xmltok.c:1349
@ UTF_16LE_ENC
Definition: xmltok.c:1350

Function Documentation

◆ XmlInitUnknownEncoding()

ENCODING * XmlInitUnknownEncoding ( void *  mem,
int *  table,
int(*)(void *userData, const char *p)  convert,
void *  userData 
)

Definition at line 1263 of file xmltok.c.

1267{
1268 int i;
1269 struct unknown_encoding *e = mem;
1270 for (i = 0; i < sizeof(struct normal_encoding); i++)
1271 ((char *)mem)[i] = ((char *)&latin1_encoding)[i];
1272 for (i = 0; i < 128; i++)
1273 if (latin1_encoding.type[i] != BT_OTHER
1274 && latin1_encoding.type[i] != BT_NONXML
1275 && table[i] != i)
1276 return 0;
1277 for (i = 0; i < 256; i++) {
1278 int c = table[i];
1279 if (c == -1) {
1280 e->normal.type[i] = BT_MALFORM;
1281 /* This shouldn't really get used. */
1282 e->utf16[i] = 0xFFFF;
1283 e->utf8[i][0] = 1;
1284 e->utf8[i][1] = 0;
1285 }
1286 else if (c < 0) {
1287 if (c < -4)
1288 return 0;
1289 e->normal.type[i] = BT_LEAD2 - (c + 2);
1290 e->utf8[i][0] = 0;
1291 e->utf16[i] = 0;
1292 }
1293 else if (c < 0x80) {
1294 if (latin1_encoding.type[c] != BT_OTHER
1295 && latin1_encoding.type[c] != BT_NONXML
1296 && c != i)
1297 return 0;
1298 e->normal.type[i] = latin1_encoding.type[c];
1299 e->utf8[i][0] = 1;
1300 e->utf8[i][1] = (char)c;
1301 e->utf16[i] = c == 0 ? 0xFFFF : c;
1302 }
1303 else if (checkCharRefNumber(c) < 0) {
1304 e->normal.type[i] = BT_NONXML;
1305 /* This shouldn't really get used. */
1306 e->utf16[i] = 0xFFFF;
1307 e->utf8[i][0] = 1;
1308 e->utf8[i][1] = 0;
1309 }
1310 else {
1311 if (c > 0xFFFF)
1312 return 0;
1313 if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff))
1314 e->normal.type[i] = BT_NMSTRT;
1315 else if (UCS2_GET_NAMING(namePages, c >> 8, c & 0xff))
1316 e->normal.type[i] = BT_NAME;
1317 else
1318 e->normal.type[i] = BT_OTHER;
1319 e->utf8[i][0] = (char)XmlUtf8Encode(c, e->utf8[i] + 1);
1320 e->utf16[i] = c;
1321 }
1322 }
1323 e->userData = userData;
1324 e->convert = convert;
1325 if (convert) {
1326 e->normal.isName2 = unknown_isName;
1327 e->normal.isName3 = unknown_isName;
1328 e->normal.isName4 = unknown_isName;
1329 e->normal.isNmstrt2 = unknown_isNmstrt;
1330 e->normal.isNmstrt3 = unknown_isNmstrt;
1331 e->normal.isNmstrt4 = unknown_isNmstrt;
1332 e->normal.isInvalid2 = unknown_isInvalid;
1333 e->normal.isInvalid3 = unknown_isInvalid;
1334 e->normal.isInvalid4 = unknown_isInvalid;
1335 }
1336 e->normal.enc.utf8Convert = unknown_toUtf8;
1337 e->normal.enc.utf16Convert = unknown_toUtf16;
1338 return &(e->normal.enc);
1339}
uint32_t convert(const uint32_t *src, uint32_t *dest, uint32_t max)
Definition: util24.cxx:248
int(* isInvalid4)(const ENCODING *, const char *)
Definition: xmltok.c:161
int(* isInvalid2)(const ENCODING *, const char *)
Definition: xmltok.c:159
unsigned char type[256]
Definition: xmltok.c:145
int(* isNmstrt4)(const ENCODING *, const char *)
Definition: xmltok.c:158
int(* isName3)(const ENCODING *, const char *)
Definition: xmltok.c:154
int(* isName2)(const ENCODING *, const char *)
Definition: xmltok.c:153
int(* isNmstrt2)(const ENCODING *, const char *)
Definition: xmltok.c:156
int(* isName4)(const ENCODING *, const char *)
Definition: xmltok.c:155
int(* isNmstrt3)(const ENCODING *, const char *)
Definition: xmltok.c:157
int(* isInvalid3)(const ENCODING *, const char *)
Definition: xmltok.c:160
ENCODING enc
Definition: xmltok.c:144
unsigned short utf16[256]
Definition: xmltok.c:1171
int(* convert)(void *userData, const char *p)
Definition: xmltok.c:1169
void * userData
Definition: xmltok.c:1170
char utf8[256][4]
Definition: xmltok.c:1172
struct normal_encoding normal
Definition: xmltok.c:1168
int XmlUtf8Encode(int c, char *buf)
Definition: xmltok.c:1114
#define UCS2_GET_NAMING(pages, hi, lo)
Definition: xmltok.c:54

◆ XmlSizeOfUnknownEncoding()

int XmlSizeOfUnknownEncoding ( )

Definition at line 1175 of file xmltok.c.

1176{
1177 return sizeof(struct unknown_encoding);
1178}

◆ XmlUtf16Encode()

int XmlUtf16Encode ( int  charNum,
unsigned short *  buf 
)

Definition at line 1150 of file xmltok.c.

1151{
1152 if (charNum < 0)
1153 return 0;
1154 if (charNum < 0x10000) {
1155 buf[0] = charNum;
1156 return 1;
1157 }
1158 if (charNum < 0x110000) {
1159 charNum -= 0x10000;
1160 buf[0] = (charNum >> 10) + 0xD800;
1161 buf[1] = (charNum & 0x3FF) + 0xDC00;
1162 return 2;
1163 }
1164 return 0;
1165}

◆ XmlUtf8Encode()

int XmlUtf8Encode ( int  c,
char *  buf 
)

Definition at line 1114 of file xmltok.c.

1115{
1116 enum {
1117 /* minN is minimum legal resulting value for N byte sequence */
1118 min2 = 0x80,
1119 min3 = 0x800,
1120 min4 = 0x10000
1121 };
1122
1123 if (c < 0)
1124 return 0;
1125 if (c < min2) {
1126 buf[0] = (c | UTF8_cval1);
1127 return 1;
1128 }
1129 if (c < min3) {
1130 buf[0] = ((c >> 6) | UTF8_cval2);
1131 buf[1] = ((c & 0x3f) | 0x80);
1132 return 2;
1133 }
1134 if (c < min4) {
1135 buf[0] = ((c >> 12) | UTF8_cval3);
1136 buf[1] = (((c >> 6) & 0x3f) | 0x80);
1137 buf[2] = ((c & 0x3f) | 0x80);
1138 return 3;
1139 }
1140 if (c < 0x110000) {
1141 buf[0] = ((c >> 18) | UTF8_cval4);
1142 buf[1] = (((c >> 12) & 0x3f) | 0x80);
1143 buf[2] = (((c >> 6) & 0x3f) | 0x80);
1144 buf[3] = ((c & 0x3f) | 0x80);
1145 return 4;
1146 }
1147 return 0;
1148}

Referenced by XmlInitUnknownEncoding().