BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
xmltok.c File Reference
#include "nametab.h"
#include "xmldef.h"
#include "xmltok.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 655 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 652 of file xmltok.c.

652#define BIG2_BYTE_TYPE( enc, p ) \
653 ( ( p )[0] == 0 ? ( (struct normal_encoding*)( enc ) )->type[(unsigned char)( p )[1]] \
654 : 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 656 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:48

Definition at line 657 of file xmltok.c.

657#define BIG2_IS_NAME_CHAR_MINBPC( enc, p ) \
658 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 659 of file xmltok.c.

659#define BIG2_IS_NMSTRT_CHAR_MINBPC( enc, p ) \
660 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:
#define BIG2_BYTE_TO_ASCII(enc, p)
Definition xmltok.c:655

Definition at line 184 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:534

Definition at line 184 of file xmltok.c.

◆ BYTE_TO_ASCII [3/3]

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

Definition at line 184 of file xmltok.c.

◆ BYTE_TYPE [1/3]

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

Definition at line 176 of file xmltok.c.

◆ BYTE_TYPE [2/3]

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

Definition at line 176 of file xmltok.c.

◆ BYTE_TYPE [3/3]

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

Definition at line 176 of file xmltok.c.

◆ CHAR_MATCHES [1/3]

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

Definition at line 210 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:535

Definition at line 210 of file xmltok.c.

◆ CHAR_MATCHES [3/3]

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

Definition at line 210 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:510
#define GET_LO(ptr)
Definition xmltok.c:509

Definition at line 496 of file xmltok.c.

496#define DEFINE_UTF16_TO_UTF16( E ) \
497 static void E##toUtf16( const ENCODING* enc, const char** fromP, const char* fromLim, \
498 unsigned short** toP, const unsigned short* toLim ) { \
499 /* Avoid copying first half only of surrogate */ \
500 if ( fromLim - *fromP > ( ( toLim - *toP ) << 1 ) && \
501 ( GET_HI( fromLim - 2 ) & 0xF8 ) == 0xD8 ) \
502 fromLim -= 2; \
503 for ( ; *fromP != fromLim && *toP != toLim; *fromP += 2 ) \
504 *( *toP )++ = ( GET_HI( *fromP ) << 8 ) | GET_LO( *fromP ); \
505 }

◆ DEFINE_UTF16_TO_UTF8

#define DEFINE_UTF16_TO_UTF8 ( E)

Definition at line 423 of file xmltok.c.

423#define DEFINE_UTF16_TO_UTF8( E ) \
424 static void E##toUtf8( const ENCODING* enc, const char** fromP, const char* fromLim, \
425 char** toP, const char* toLim ) { \
426 const char* from; \
427 for ( from = *fromP; from != fromLim; from += 2 ) \
428 { \
429 int plane; \
430 unsigned char lo2; \
431 unsigned char lo = GET_LO( from ); \
432 unsigned char hi = GET_HI( from ); \
433 switch ( hi ) \
434 { \
435 case 0: \
436 if ( lo < 0x80 ) \
437 { \
438 if ( *toP == toLim ) \
439 { \
440 *fromP = from; \
441 return; \
442 } \
443 *( *toP )++ = lo; \
444 break; \
445 } \
446 /* fall through */ \
447 case 0x1: \
448 case 0x2: \
449 case 0x3: \
450 case 0x4: \
451 case 0x5: \
452 case 0x6: \
453 case 0x7: \
454 if ( toLim - *toP < 2 ) \
455 { \
456 *fromP = from; \
457 return; \
458 } \
459 *( *toP )++ = ( ( lo >> 6 ) | ( hi << 2 ) | UTF8_cval2 ); \
460 *( *toP )++ = ( ( lo & 0x3f ) | 0x80 ); \
461 break; \
462 default: \
463 if ( toLim - *toP < 3 ) \
464 { \
465 *fromP = from; \
466 return; \
467 } \
468 /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \
469 *( *toP )++ = ( ( hi >> 4 ) | UTF8_cval3 ); \
470 *( *toP )++ = ( ( ( hi & 0xf ) << 2 ) | ( lo >> 6 ) | 0x80 ); \
471 *( *toP )++ = ( ( lo & 0x3f ) | 0x80 ); \
472 break; \
473 case 0xD8: \
474 case 0xD9: \
475 case 0xDA: \
476 case 0xDB: \
477 if ( toLim - *toP < 4 ) \
478 { \
479 *fromP = from; \
480 return; \
481 } \
482 plane = ( ( ( hi & 0x3 ) << 2 ) | ( ( lo >> 6 ) & 0x3 ) ) + 1; \
483 *( *toP )++ = ( ( plane >> 2 ) | UTF8_cval4 ); \
484 *( *toP )++ = ( ( ( lo >> 2 ) & 0xF ) | ( ( plane & 0x3 ) << 4 ) | 0x80 ); \
485 from += 2; \
486 lo2 = GET_LO( from ); \
487 *( *toP )++ = ( ( ( lo & 0x3 ) << 4 ) | ( ( GET_HI( from ) & 0x3 ) << 2 ) | \
488 ( lo2 >> 6 ) | 0x80 ); \
489 *( *toP )++ = ( ( lo2 & 0x3f ) | 0x80 ); \
490 break; \
491 } \
492 } \
493 *fromP = from; \
494 }

◆ GET_HI [1/2]

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

Definition at line 510 of file xmltok.c.

◆ GET_HI [2/2]

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

Definition at line 510 of file xmltok.c.

◆ GET_LO [1/2]

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

Definition at line 509 of file xmltok.c.

◆ GET_LO [2/2]

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

Definition at line 509 of file xmltok.c.

◆ INIT_ENC_INDEX

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

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

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

◆ IS_NAME_CHAR [1/3]

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

Definition at line 187 of file xmltok.c.

187#define IS_NAME_CHAR( enc, p, n ) \
188 ( ( (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 187 of file xmltok.c.

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

◆ IS_NAME_CHAR [3/3]

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

Definition at line 187 of file xmltok.c.

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

◆ IS_NAME_CHAR_MINBPC [1/3]

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

Definition at line 200 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:536

Definition at line 200 of file xmltok.c.

◆ IS_NAME_CHAR_MINBPC [3/3]

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

Definition at line 200 of file xmltok.c.

◆ IS_NMSTRT_CHAR [1/3]

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

Definition at line 189 of file xmltok.c.

189#define IS_NMSTRT_CHAR( enc, p, n ) \
190 ( ( (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 189 of file xmltok.c.

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

◆ IS_NMSTRT_CHAR [3/3]

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

Definition at line 189 of file xmltok.c.

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

◆ IS_NMSTRT_CHAR_MINBPC [1/3]

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

Definition at line 201 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:538

Definition at line 201 of file xmltok.c.

◆ IS_NMSTRT_CHAR_MINBPC [3/3]

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

Definition at line 201 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 534 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 531 of file xmltok.c.

531#define LITTLE2_BYTE_TYPE( enc, p ) \
532 ( ( p )[1] == 0 ? ( (struct normal_encoding*)( enc ) )->type[(unsigned char)*( p )] \
533 : 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 535 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 536 of file xmltok.c.

536#define LITTLE2_IS_NAME_CHAR_MINBPC( enc, p ) \
537 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 538 of file xmltok.c.

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

◆ MINBPC [1/3]

#define MINBPC ( enc)
Value:
2

Definition at line 165 of file xmltok.c.

◆ MINBPC [2/3]

#define MINBPC ( enc)
Value:
2

Definition at line 165 of file xmltok.c.

◆ MINBPC [3/3]

#define MINBPC ( enc)
Value:
1

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

148#define NORMAL_VTABLE( E ) \
149 E##isName2, E##isName3, E##isName4, E##isNmstrt2, E##isNmstrt3, E##isNmstrt4, \
150 E##isInvalid2, E##isInvalid3, E##isInvalid4

◆ NS

#define NS ( x)
Value:
x

Definition at line 1354 of file xmltok.c.

Referenced by XmlInitEncoding(), and XmlParseXmlDecl().

◆ ns

◆ PREFIX [1/3]

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

Definition at line 213 of file xmltok.c.

◆ PREFIX [2/3]

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

Definition at line 213 of file xmltok.c.

◆ PREFIX [3/3]

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

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

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

◆ SET2 [1/2]

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

Definition at line 507 of file xmltok.c.

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

◆ SET2 [2/2]

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

Definition at line 507 of file xmltok.c.

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

◆ STANDARD_VTABLE

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

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

48#define UCS2_GET_NAMING( pages, hi, lo ) \
49 ( 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:64
#define UTF8_GET_NAMING2(pages, byte)
Definition xmltok.c:55

Definition at line 71 of file xmltok.c.

71#define UTF8_GET_NAMING( pages, p, n ) \
72 ( ( n ) == 2 \
73 ? UTF8_GET_NAMING2( pages, (const unsigned char*)( p ) ) \
74 : ( ( n ) == 3 ? UTF8_GET_NAMING3( pages, (const unsigned char*)( p ) ) : 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 55 of file xmltok.c.

55#define UTF8_GET_NAMING2( pages, byte ) \
56 ( namingBitmap[( ( pages )[( ( ( byte )[0] ) >> 2 ) & 7] << 3 ) + \
57 ( ( ( ( byte )[0] ) & 3 ) << 1 ) + ( ( ( ( byte )[1] ) >> 5 ) & 1 )] & \
58 ( 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 64 of file xmltok.c.

64#define UTF8_GET_NAMING3( pages, byte ) \
65 ( namingBitmap[( ( pages )[( ( ( ( byte )[0] ) & 0xF ) << 4 ) + \
66 ( ( ( ( byte )[1] ) >> 2 ) & 0xF )] \
67 << 3 ) + \
68 ( ( ( ( byte )[1] ) & 3 ) << 1 ) + ( ( ( ( byte )[2] ) >> 5 ) & 1 )] & \
69 ( 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 76 of file xmltok.c.

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

◆ UTF8_INVALID4

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

Definition at line 82 of file xmltok.c.

◆ utf8_isInvalid2

#define utf8_isInvalid2   isNever

Definition at line 106 of file xmltok.c.

◆ utf8_isName4

#define utf8_isName4   isNever

Definition at line 94 of file xmltok.c.

◆ utf8_isNmstrt4

#define utf8_isNmstrt4   isNever

Definition at line 104 of file xmltok.c.

◆ VTABLE

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

Definition at line 46 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:213

Definition at line 39 of file xmltok.c.

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

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UTF8_cval1 
UTF8_cval2 
UTF8_cval3 
UTF8_cval4 

Definition at line 226 of file xmltok.c.

226 { /* UTF8_cvalN is value of masked first byte of N byte sequence */
227 UTF8_cval1 = 0x00,
228 UTF8_cval2 = 0xc0,
229 UTF8_cval3 = 0xe0,
230 UTF8_cval4 = 0xf0
231};
@ UTF8_cval4
Definition xmltok.c:230
@ UTF8_cval1
Definition xmltok.c:227
@ UTF8_cval2
Definition xmltok.c:228
@ UTF8_cval3
Definition xmltok.c:229

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

1211 {
1212 UNKNOWN_ENC = -1,
1213 ISO_8859_1_ENC = 0,
1215 UTF_8_ENC,
1216 UTF_16_ENC,
1219 /* must match encodingNames up to here */
1220 NO_ENC
1221};
@ NO_ENC
Definition xmltok.c:1220
@ US_ASCII_ENC
Definition xmltok.c:1214
@ ISO_8859_1_ENC
Definition xmltok.c:1213
@ UTF_8_ENC
Definition xmltok.c:1215
@ UTF_16_ENC
Definition xmltok.c:1216
@ UNKNOWN_ENC
Definition xmltok.c:1212
@ UTF_16BE_ENC
Definition xmltok.c:1217
@ UTF_16LE_ENC
Definition xmltok.c:1218

Function Documentation

◆ XmlInitUnknownEncoding()

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

Definition at line 1133 of file xmltok.c.

1135 {
1136 int i;
1137 struct unknown_encoding* e = mem;
1138 for ( i = 0; i < sizeof( struct normal_encoding ); i++ )
1139 ( (char*)mem )[i] = ( (char*)&latin1_encoding )[i];
1140 for ( i = 0; i < 128; i++ )
1141 if ( latin1_encoding.type[i] != BT_OTHER && latin1_encoding.type[i] != BT_NONXML &&
1142 table[i] != i )
1143 return 0;
1144 for ( i = 0; i < 256; i++ )
1145 {
1146 int c = table[i];
1147 if ( c == -1 )
1148 {
1149 e->normal.type[i] = BT_MALFORM;
1150 /* This shouldn't really get used. */
1151 e->utf16[i] = 0xFFFF;
1152 e->utf8[i][0] = 1;
1153 e->utf8[i][1] = 0;
1154 }
1155 else if ( c < 0 )
1156 {
1157 if ( c < -4 ) return 0;
1158 e->normal.type[i] = BT_LEAD2 - ( c + 2 );
1159 e->utf8[i][0] = 0;
1160 e->utf16[i] = 0;
1161 }
1162 else if ( c < 0x80 )
1163 {
1164 if ( latin1_encoding.type[c] != BT_OTHER && latin1_encoding.type[c] != BT_NONXML &&
1165 c != i )
1166 return 0;
1167 e->normal.type[i] = latin1_encoding.type[c];
1168 e->utf8[i][0] = 1;
1169 e->utf8[i][1] = (char)c;
1170 e->utf16[i] = c == 0 ? 0xFFFF : c;
1171 }
1172 else if ( checkCharRefNumber( c ) < 0 )
1173 {
1174 e->normal.type[i] = BT_NONXML;
1175 /* This shouldn't really get used. */
1176 e->utf16[i] = 0xFFFF;
1177 e->utf8[i][0] = 1;
1178 e->utf8[i][1] = 0;
1179 }
1180 else
1181 {
1182 if ( c > 0xFFFF ) return 0;
1183 if ( UCS2_GET_NAMING( nmstrtPages, c >> 8, c & 0xff ) ) e->normal.type[i] = BT_NMSTRT;
1184 else if ( UCS2_GET_NAMING( namePages, c >> 8, c & 0xff ) ) e->normal.type[i] = BT_NAME;
1185 else e->normal.type[i] = BT_OTHER;
1186 e->utf8[i][0] = (char)XmlUtf8Encode( c, e->utf8[i] + 1 );
1187 e->utf16[i] = c;
1188 }
1189 }
1190 e->userData = userData;
1191 e->convert = convert;
1192 if ( convert )
1193 {
1194 e->normal.isName2 = unknown_isName;
1195 e->normal.isName3 = unknown_isName;
1196 e->normal.isName4 = unknown_isName;
1197 e->normal.isNmstrt2 = unknown_isNmstrt;
1198 e->normal.isNmstrt3 = unknown_isNmstrt;
1199 e->normal.isNmstrt4 = unknown_isNmstrt;
1200 e->normal.isInvalid2 = unknown_isInvalid;
1201 e->normal.isInvalid3 = unknown_isInvalid;
1202 e->normal.isInvalid4 = unknown_isInvalid;
1203 }
1204 e->normal.enc.utf8Convert = unknown_toUtf8;
1205 e->normal.enc.utf16Convert = unknown_toUtf16;
1206 return &( e->normal.enc );
1207}
uint32_t convert(const uint32_t *src, uint32_t *dest, uint32_t max)
Definition util24.cxx:244
int(* isInvalid4)(const ENCODING *, const char *)
Definition xmltok.c:134
int(* isInvalid2)(const ENCODING *, const char *)
Definition xmltok.c:132
unsigned char type[256]
Definition xmltok.c:118
int(* isNmstrt4)(const ENCODING *, const char *)
Definition xmltok.c:131
int(* isName3)(const ENCODING *, const char *)
Definition xmltok.c:127
int(* isName2)(const ENCODING *, const char *)
Definition xmltok.c:126
int(* isNmstrt2)(const ENCODING *, const char *)
Definition xmltok.c:129
int(* isName4)(const ENCODING *, const char *)
Definition xmltok.c:128
int(* isNmstrt3)(const ENCODING *, const char *)
Definition xmltok.c:130
int(* isInvalid3)(const ENCODING *, const char *)
Definition xmltok.c:133
ENCODING enc
Definition xmltok.c:117
unsigned short utf16[256]
Definition xmltok.c:1059
int(* convert)(void *userData, const char *p)
Definition xmltok.c:1057
void * userData
Definition xmltok.c:1058
char utf8[256][4]
Definition xmltok.c:1060
struct normal_encoding normal
Definition xmltok.c:1056
int XmlUtf8Encode(int c, char *buf)
Definition xmltok.c:1000

◆ XmlSizeOfUnknownEncoding()

int XmlSizeOfUnknownEncoding ( )

Definition at line 1063 of file xmltok.c.

1063{ return sizeof( struct unknown_encoding ); }

◆ XmlUtf16Encode()

int XmlUtf16Encode ( int charNum,
unsigned short * buf )

Definition at line 1038 of file xmltok.c.

1038 {
1039 if ( charNum < 0 ) return 0;
1040 if ( charNum < 0x10000 )
1041 {
1042 buf[0] = charNum;
1043 return 1;
1044 }
1045 if ( charNum < 0x110000 )
1046 {
1047 charNum -= 0x10000;
1048 buf[0] = ( charNum >> 10 ) + 0xD800;
1049 buf[1] = ( charNum & 0x3FF ) + 0xDC00;
1050 return 2;
1051 }
1052 return 0;
1053}

◆ XmlUtf8Encode()

int XmlUtf8Encode ( int c,
char * buf )

Definition at line 1000 of file xmltok.c.

1000 {
1001 enum {
1002 /* minN is minimum legal resulting value for N byte sequence */
1003 min2 = 0x80,
1004 min3 = 0x800,
1005 min4 = 0x10000
1006 };
1007
1008 if ( c < 0 ) return 0;
1009 if ( c < min2 )
1010 {
1011 buf[0] = ( c | UTF8_cval1 );
1012 return 1;
1013 }
1014 if ( c < min3 )
1015 {
1016 buf[0] = ( ( c >> 6 ) | UTF8_cval2 );
1017 buf[1] = ( ( c & 0x3f ) | 0x80 );
1018 return 2;
1019 }
1020 if ( c < min4 )
1021 {
1022 buf[0] = ( ( c >> 12 ) | UTF8_cval3 );
1023 buf[1] = ( ( ( c >> 6 ) & 0x3f ) | 0x80 );
1024 buf[2] = ( ( c & 0x3f ) | 0x80 );
1025 return 3;
1026 }
1027 if ( c < 0x110000 )
1028 {
1029 buf[0] = ( ( c >> 18 ) | UTF8_cval4 );
1030 buf[1] = ( ( ( c >> 12 ) & 0x3f ) | 0x80 );
1031 buf[2] = ( ( ( c >> 6 ) & 0x3f ) | 0x80 );
1032 buf[3] = ( ( c & 0x3f ) | 0x80 );
1033 return 4;
1034 }
1035 return 0;
1036}

Referenced by XmlInitUnknownEncoding().