BOSS 7.1.1
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)
 
#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)
 
#define utf8_isName4   isNever
 
#define utf8_isNmstrt4   isNever
 
#define utf8_isInvalid2   isNever
 
#define STANDARD_VTABLE(E)
 
#define NORMAL_VTABLE(E)
 
#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 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(enc, p)
 
#define LITTLE2_CHAR_MATCHES(enc, p, c)
 
#define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)
 
#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, 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 BT_COLON   BT_NMSTRT
 
#define BT_COLON   BT_NMSTRT
 
#define BIG2_BYTE_TYPE(enc, p)
 
#define BIG2_BYTE_TO_ASCII(enc, p)
 
#define BIG2_CHAR_MATCHES(enc, p, c)
 
#define BIG2_IS_NAME_CHAR_MINBPC(enc, p)
 
#define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, 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 BT_COLON   BT_NMSTRT
 
#define BT_COLON   BT_NMSTRT
 
#define INIT_ENC_INDEX(enc)
 
#define NS(x)
 
#define ns(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 )
Value:
((p)[0] == 0 ? (p)[1] : -1)

Definition at line 740 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]))
ENCODING enc
Definition xmltok.c:144

Definition at line 736 of file xmltok.c.

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

◆ BIG2_CHAR_MATCHES

#define BIG2_CHAR_MATCHES ( enc,
p,
c )
Value:
((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,
p )
Value:
UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])
#define UCS2_GET_NAMING(pages, hi, lo)
Definition xmltok.c:54

Definition at line 742 of file xmltok.c.

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

◆ BIG2_IS_NMSTRT_CHAR_MINBPC

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

Definition at line 744 of file xmltok.c.

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

◆ 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 )
Value:
(*p)

Definition at line 230 of file xmltok.c.

◆ BYTE_TO_ASCII [2/3]

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

Definition at line 230 of file xmltok.c.

◆ BYTE_TO_ASCII [3/3]

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

Definition at line 230 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:206

Definition at line 218 of file xmltok.c.

◆ BYTE_TYPE [2/3]

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

Definition at line 218 of file xmltok.c.

◆ BYTE_TYPE [3/3]

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

Definition at line 218 of file xmltok.c.

◆ CHAR_MATCHES [1/3]

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

Definition at line 260 of file xmltok.c.

◆ CHAR_MATCHES [2/3]

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

Definition at line 260 of file xmltok.c.

◆ CHAR_MATCHES [3/3]

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

Definition at line 260 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:576
#define GET_LO(ptr)
Definition xmltok.c:575

Definition at line 559 of file xmltok.c.

559#define DEFINE_UTF16_TO_UTF16(E) \
560static \
561void E ## toUtf16(const ENCODING *enc, \
562 const char **fromP, const char *fromLim, \
563 unsigned short **toP, const unsigned short *toLim) \
564{ \
565 /* Avoid copying first half only of surrogate */ \
566 if (fromLim - *fromP > ((toLim - *toP) << 1) \
567 && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) \
568 fromLim -= 2; \
569 for (; *fromP != fromLim && *toP != toLim; *fromP += 2) \
570 *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \
571}

◆ DEFINE_UTF16_TO_UTF8

#define DEFINE_UTF16_TO_UTF8 ( E)

Definition at line 496 of file xmltok.c.

496#define DEFINE_UTF16_TO_UTF8(E) \
497static \
498void E ## toUtf8(const ENCODING *enc, \
499 const char **fromP, const char *fromLim, \
500 char **toP, const char *toLim) \
501{ \
502 const char *from; \
503 for (from = *fromP; from != fromLim; from += 2) { \
504 int plane; \
505 unsigned char lo2; \
506 unsigned char lo = GET_LO(from); \
507 unsigned char hi = GET_HI(from); \
508 switch (hi) { \
509 case 0: \
510 if (lo < 0x80) { \
511 if (*toP == toLim) { \
512 *fromP = from; \
513 return; \
514 } \
515 *(*toP)++ = lo; \
516 break; \
517 } \
518 /* fall through */ \
519 case 0x1: case 0x2: case 0x3: \
520 case 0x4: case 0x5: case 0x6: case 0x7: \
521 if (toLim - *toP < 2) { \
522 *fromP = from; \
523 return; \
524 } \
525 *(*toP)++ = ((lo >> 6) | (hi << 2) | UTF8_cval2); \
526 *(*toP)++ = ((lo & 0x3f) | 0x80); \
527 break; \
528 default: \
529 if (toLim - *toP < 3) { \
530 *fromP = from; \
531 return; \
532 } \
533 /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \
534 *(*toP)++ = ((hi >> 4) | UTF8_cval3); \
535 *(*toP)++ = (((hi & 0xf) << 2) | (lo >> 6) | 0x80); \
536 *(*toP)++ = ((lo & 0x3f) | 0x80); \
537 break; \
538 case 0xD8: case 0xD9: case 0xDA: case 0xDB: \
539 if (toLim - *toP < 4) { \
540 *fromP = from; \
541 return; \
542 } \
543 plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \
544 *(*toP)++ = ((plane >> 2) | UTF8_cval4); \
545 *(*toP)++ = (((lo >> 2) & 0xF) | ((plane & 0x3) << 4) | 0x80); \
546 from += 2; \
547 lo2 = GET_LO(from); \
548 *(*toP)++ = (((lo & 0x3) << 4) \
549 | ((GET_HI(from) & 0x3) << 2) \
550 | (lo2 >> 6) \
551 | 0x80); \
552 *(*toP)++ = ((lo2 & 0x3f) | 0x80); \
553 break; \
554 } \
555 } \
556 *fromP = from; \
557}

◆ GET_HI [1/2]

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

Definition at line 576 of file xmltok.c.

◆ GET_HI [2/2]

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

Definition at line 576 of file xmltok.c.

◆ GET_LO [1/2]

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

Definition at line 575 of file xmltok.c.

◆ GET_LO [2/2]

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

Definition at line 575 of file xmltok.c.

◆ INIT_ENC_INDEX

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

Definition at line 1378 of file xmltok.c.

Referenced by XmlInitEncoding().

◆ IS_INVALID_CHAR

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

Definition at line 237 of file xmltok.c.

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

◆ IS_NAME_CHAR [1/3]

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

Definition at line 233 of file xmltok.c.

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

◆ IS_NAME_CHAR [2/3]

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

Definition at line 233 of file xmltok.c.

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

◆ IS_NAME_CHAR [3/3]

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

Definition at line 233 of file xmltok.c.

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

◆ IS_NAME_CHAR_MINBPC [1/3]

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

Definition at line 246 of file xmltok.c.

◆ IS_NAME_CHAR_MINBPC [2/3]

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

Definition at line 246 of file xmltok.c.

◆ IS_NAME_CHAR_MINBPC [3/3]

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

Definition at line 246 of file xmltok.c.

◆ IS_NMSTRT_CHAR [1/3]

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

Definition at line 235 of file xmltok.c.

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

◆ IS_NMSTRT_CHAR [2/3]

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

Definition at line 235 of file xmltok.c.

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

◆ IS_NMSTRT_CHAR [3/3]

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

Definition at line 235 of file xmltok.c.

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

◆ IS_NMSTRT_CHAR_MINBPC [1/3]

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

Definition at line 247 of file xmltok.c.

◆ IS_NMSTRT_CHAR_MINBPC [2/3]

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

Definition at line 247 of file xmltok.c.

◆ IS_NMSTRT_CHAR_MINBPC [3/3]

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

Definition at line 247 of file xmltok.c.

◆ LITTLE2_BYTE_TO_ASCII

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

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

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

◆ LITTLE2_CHAR_MATCHES

#define LITTLE2_CHAR_MATCHES ( enc,
p,
c )
Value:
((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,
p )
Value:
UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0])

Definition at line 603 of file xmltok.c.

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

◆ LITTLE2_IS_NMSTRT_CHAR_MINBPC

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

Definition at line 605 of file xmltok.c.

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

◆ MINBPC [1/3]

#define MINBPC ( enc)
Value:
1

Definition at line 203 of file xmltok.c.

◆ MINBPC [2/3]

#define MINBPC ( enc)
Value:
2

Definition at line 203 of file xmltok.c.

◆ MINBPC [3/3]

#define MINBPC ( enc)
Value:
2

Definition at line 203 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.

179#define NORMAL_VTABLE(E) \
180 E ## isName2, \
181 E ## isName3, \
182 E ## isName4, \
183 E ## isNmstrt2, \
184 E ## isNmstrt3, \
185 E ## isNmstrt4, \
186 E ## isInvalid2, \
187 E ## isInvalid3, \
188 E ## isInvalid4

◆ NS

#define NS ( x)
Value:
Double_t x[10]

Definition at line 1503 of file xmltok.c.

Referenced by XmlInitEncoding(), and XmlParseXmlDecl().

◆ ns

◆ PREFIX [1/3]

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

Definition at line 263 of file xmltok.c.

◆ PREFIX [2/3]

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

Definition at line 263 of file xmltok.c.

◆ PREFIX [3/3]

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

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

206#define SB_BYTE_TYPE(enc, p) \
207 (((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 573 of file xmltok.c.

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

◆ SET2 [2/2]

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

Definition at line 573 of file xmltok.c.

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

◆ STANDARD_VTABLE

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

Definition at line 175 of file xmltok.c.

◆ UCS2_GET_NAMING

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

Definition at line 54 of file xmltok.c.

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

Referenced by XmlInitUnknownEncoding().

◆ 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))
#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.

79#define UTF8_GET_NAMING(pages, p, n) \
80 ((n) == 2 \
81 ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \
82 : ((n) == 3 \
83 ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) \
84 : 0))

◆ 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.

61#define UTF8_GET_NAMING2(pages, byte) \
62 (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \
63 + ((((byte)[0]) & 3) << 1) \
64 + ((((byte)[1]) >> 5) & 1)] \
65 & (1 << (((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)] \
& (1 << (((byte)[2]) & 0x1F)))

Definition at line 71 of file xmltok.c.

71#define UTF8_GET_NAMING3(pages, byte) \
72 (namingBitmap[((pages)[((((byte)[0]) & 0xF) << 4) \
73 + ((((byte)[1]) >> 2) & 0xF)] \
74 << 3) \
75 + ((((byte)[1]) & 3) << 1) \
76 + ((((byte)[2]) >> 5) & 1)] \
77 & (1 << (((byte)[2]) & 0x1F)))

◆ 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.

86#define UTF8_INVALID3(p) \
87 ((*p) == 0xED \
88 ? (((p)[1] & 0x20) != 0) \
89 : ((*p) == 0xEF \
90 ? ((p)[1] == 0xBF && ((p)[2] == 0xBF || (p)[2] == 0xBE)) \
91 : 0))

◆ UTF8_INVALID4

#define UTF8_INVALID4 ( p)
Value:
((*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:263

Definition at line 39 of file xmltok.c.

39#define VTABLE1 \
40 { PREFIX(prologTok), PREFIX(contentTok), PREFIX(cdataSectionTok) }, \
41 { PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \
42 PREFIX(sameName), \
43 PREFIX(nameMatchesAscii), \
44 PREFIX(nameLength), \
45 PREFIX(skipS), \
46 PREFIX(getAtts), \
47 PREFIX(charRefNumber), \
48 PREFIX(predefinedEntityName), \
49 PREFIX(updatePosition), \
50 PREFIX(isPublicId)

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(* convert )(void *userData, const char *p),
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
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

◆ 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().