Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Enumerations | Functions | Variables
xmltok.c File Reference
#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

Defines

#define IGNORE_SECTION_TOK_VTABLE   /* as nothing */
#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_INVALID2(p)   ((*p) < 0xC2 || ((p)[1] & 0x80) == 0 || ((p)[1] & 0xC0) == 0xC0)
#define UTF8_INVALID3(p)
#define UTF8_INVALID4(p)
#define utf8_isName4   isNever
#define utf8_isNmstrt4   isNever
#define AS_NORMAL_ENCODING(enc)   ((const struct normal_encoding *) (enc))
#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)   (AS_NORMAL_ENCODING(enc)->isName ## n(enc, p))
#define IS_NMSTRT_CHAR(enc, p, n)   (AS_NORMAL_ENCODING(enc)->isNmstrt ## n(enc, p))
#define IS_INVALID_CHAR(enc, p, n)   (AS_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 AS_UNKNOWN_ENCODING(enc)   ((const struct unknown_encoding *) (enc))
#define INIT_ENC_INDEX(enc)   ((int)(enc)->initEnc.isUtf16)
#define SET_INIT_ENC_INDEX(enc, i)   ((enc)->initEnc.isUtf16 = (char)i)
#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

static int PTRFASTCALL isNever (const ENCODING *enc, const char *p)
static int PTRFASTCALL utf8_isName2 (const ENCODING *enc, const char *p)
static int PTRFASTCALL utf8_isName3 (const ENCODING *enc, const char *p)
static int PTRFASTCALL utf8_isNmstrt2 (const ENCODING *enc, const char *p)
static int PTRFASTCALL utf8_isNmstrt3 (const ENCODING *enc, const char *p)
static int PTRFASTCALL utf8_isInvalid2 (const ENCODING *enc, const char *p)
static int PTRFASTCALL utf8_isInvalid3 (const ENCODING *enc, const char *p)
static int PTRFASTCALL utf8_isInvalid4 (const ENCODING *enc, const char *p)
static int FASTCALL checkCharRefNumber (int)
static void PTRCALL utf8_toUtf8 (const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim)
static void PTRCALL utf8_toUtf16 (const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim)
static void PTRCALL latin1_toUtf8 (const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim)
static void PTRCALL latin1_toUtf16 (const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim)
static void PTRCALL ascii_toUtf8 (const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim)
static int PTRFASTCALL unicode_byte_type (char hi, char lo)
static int FASTCALL streqci (const char *s1, const char *s2)
static void PTRCALL initUpdatePosition (const ENCODING *enc, const char *ptr, const char *end, POSITION *pos)
static int toAscii (const ENCODING *enc, const char *ptr, const char *end)
static int FASTCALL isSpace (int c)
static int parsePseudoAttribute (const ENCODING *enc, const char *ptr, const char *end, const char **namePtr, const char **nameEndPtr, const char **valPtr, const char **nextTokPtr)
static int doParseXmlDecl (const ENCODING *(*encodingFinder)(const ENCODING *, const char *, const char *), int isGeneralTextEntity, const ENCODING *enc, const char *ptr, const char *end, const char **badPtr, const char **versionPtr, const char **versionEndPtr, const char **encodingName, const ENCODING **encoding, int *standalone)
int FASTCALL XmlUtf8Encode (int c, char *buf)
int FASTCALL XmlUtf16Encode (int charNum, unsigned short *buf)
int XmlSizeOfUnknownEncoding (void)
static int PTRFASTCALL unknown_isName (const ENCODING *enc, const char *p)
static int PTRFASTCALL unknown_isNmstrt (const ENCODING *enc, const char *p)
static int PTRFASTCALL unknown_isInvalid (const ENCODING *enc, const char *p)
static void PTRCALL unknown_toUtf8 (const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim)
static void PTRCALL unknown_toUtf16 (const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim)
ENCODINGXmlInitUnknownEncoding (void *mem, int *table, CONVERTER convert, void *userData)
static int FASTCALL getEncodingIndex (const char *name)
static int initScan (const ENCODING **encodingTable, const INIT_ENCODING *enc, int state, const char *ptr, const char *end, const char **nextTokPtr)

Variables

static struct normal_encoding
static const char KW_version []
static const char KW_encoding []
static const char KW_standalone []
static const char KW_yes []
static const char KW_no []
static const char KW_XML_1_0 []
static const char KW_ISO_8859_1 []
static const char KW_US_ASCII []
static const char KW_UTF_8 []
static const char KW_UTF_16 []
static const char KW_UTF_16BE []
static const char KW_UTF_16LE []

Define Documentation

#define AS_NORMAL_ENCODING (   enc)    ((const struct normal_encoding *) (enc))

Definition at line 190 of file xmltok.c.

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

Definition at line 1255 of file xmltok.c.

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

Definition at line 773 of file xmltok.c.

#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 769 of file xmltok.c.

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

Definition at line 774 of file xmltok.c.

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

Definition at line 775 of file xmltok.c.

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

Definition at line 777 of file xmltok.c.

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

Definition at line 822 of file xmltok.c.

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

Definition at line 822 of file xmltok.c.

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

Definition at line 822 of file xmltok.c.

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

Definition at line 821 of file xmltok.c.

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

Definition at line 821 of file xmltok.c.

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

Definition at line 821 of file xmltok.c.

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

Definition at line 823 of file xmltok.c.

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

Definition at line 823 of file xmltok.c.

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

Definition at line 823 of file xmltok.c.

Value:
static void  PTRCALL \
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); \
}

Definition at line 592 of file xmltok.c.

Definition at line 529 of file xmltok.c.

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

Definition at line 621 of file xmltok.c.

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

Definition at line 621 of file xmltok.c.

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

Definition at line 620 of file xmltok.c.

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

Definition at line 620 of file xmltok.c.

#define IGNORE_SECTION_TOK_VTABLE   /* as nothing */

Definition at line 22 of file xmltok.c.

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

Definition at line 1485 of file xmltok.c.

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

Definition at line 266 of file xmltok.c.

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

Definition at line 824 of file xmltok.c.

#define IS_NAME_CHAR (   enc,
  p,
  n 
)    0

Definition at line 824 of file xmltok.c.

#define IS_NAME_CHAR (   enc,
  p,
  n 
)    0

Definition at line 824 of file xmltok.c.

#define IS_NAME_CHAR_MINBPC (   enc,
  p 
)    (0)

Definition at line 825 of file xmltok.c.

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

Definition at line 825 of file xmltok.c.

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

Definition at line 825 of file xmltok.c.

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

Definition at line 826 of file xmltok.c.

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

Definition at line 826 of file xmltok.c.

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

Definition at line 826 of file xmltok.c.

#define IS_NMSTRT_CHAR_MINBPC (   enc,
  p 
)    (0)

Definition at line 827 of file xmltok.c.

Definition at line 827 of file xmltok.c.

Definition at line 827 of file xmltok.c.

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

Definition at line 634 of file xmltok.c.

#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 630 of file xmltok.c.

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

Definition at line 635 of file xmltok.c.

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

Definition at line 636 of file xmltok.c.

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

Definition at line 638 of file xmltok.c.

#define MINBPC (   enc)    1

Definition at line 819 of file xmltok.c.

#define MINBPC (   enc)    2

Definition at line 819 of file xmltok.c.

#define MINBPC (   enc)    2

Definition at line 819 of file xmltok.c.

Value:
E ## isName2, \
 E ## isName3, \
 E ## isName4, \
 E ## isNmstrt2, \
 E ## isNmstrt3, \
 E ## isNmstrt4, \
 E ## isInvalid2, \
 E ## isInvalid3, \
 E ## isInvalid4

Definition at line 207 of file xmltok.c.

#define NS (   x)    x

Definition at line 1619 of file xmltok.c.

#define ns (   x)    x

Definition at line 1620 of file xmltok.c.

#define PREFIX (   ident)    normal_ ## ident

Definition at line 818 of file xmltok.c.

#define PREFIX (   ident)    little2_ ## ident

Definition at line 818 of file xmltok.c.

#define PREFIX (   ident)    big2_ ## ident

Definition at line 818 of file xmltok.c.

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

Definition at line 235 of file xmltok.c.

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

Definition at line 618 of file xmltok.c.

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

Definition at line 618 of file xmltok.c.

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

Definition at line 1486 of file xmltok.c.

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

Definition at line 203 of file xmltok.c.

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

Definition at line 41 of file xmltok.c.

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

Definition at line 67 of file xmltok.c.

#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 48 of file xmltok.c.

#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 59 of file xmltok.c.

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

Definition at line 84 of file xmltok.c.

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

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

Definition at line 135 of file xmltok.c.

Definition at line 149 of file xmltok.c.

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

Definition at line 39 of file xmltok.c.


Enumeration Type Documentation

anonymous enum
Enumerator:
UTF8_cval1 
UTF8_cval2 
UTF8_cval3 
UTF8_cval4 

Definition at line 305 of file xmltok.c.

     {  /* UTF8_cvalN is value of masked first byte of N byte sequence */
  UTF8_cval1 = 0x00,
  UTF8_cval2 = 0xc0,
  UTF8_cval3 = 0xe0,
  UTF8_cval4 = 0xf0
};
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 1426 of file xmltok.c.

     {
  UNKNOWN_ENC = -1,
  ISO_8859_1_ENC = 0,
  US_ASCII_ENC,
  UTF_8_ENC,
  UTF_16_ENC,
  UTF_16BE_ENC,
  UTF_16LE_ENC,
  /* must match encodingNames up to here */
  NO_ENC
};

Function Documentation

static void PTRCALL ascii_toUtf8 ( const ENCODING enc,
const char **  fromP,
const char *  fromLim,
char **  toP,
const char *  toLim 
) [static]

Definition at line 478 of file xmltok.c.

{
  while (*fromP != fromLim && *toP != toLim)
    *(*toP)++ = *(*fromP)++;
}
static int FASTCALL checkCharRefNumber ( int  result) [static]

Definition at line 1174 of file xmltok.c.

{
  switch (result >> 8) {
  case 0xD8: case 0xD9: case 0xDA: case 0xDB:
  case 0xDC: case 0xDD: case 0xDE: case 0xDF:
    return -1;
  case 0:
    if (latin1_encoding.type[result] == BT_NONXML)
      return -1;
    break;
  case 0xFF:
    if (result == 0xFFFE || result == 0xFFFF)
      return -1;
    break;
  }
  return result;
}

Here is the caller graph for this function:

static int doParseXmlDecl ( const ENCODING *(*)(const ENCODING *, const char *, const char *)  encodingFinder,
int  isGeneralTextEntity,
const ENCODING enc,
const char *  ptr,
const char *  end,
const char **  badPtr,
const char **  versionPtr,
const char **  versionEndPtr,
const char **  encodingName,
const ENCODING **  encoding,
int standalone 
) [static]

Definition at line 1075 of file xmltok.c.

{
  const char *val = NULL;
  const char *name = NULL;
  const char *nameEnd = NULL;
  ptr += 5 * enc->minBytesPerChar;
  end -= 2 * enc->minBytesPerChar;
  if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)
      || !name) {
    *badPtr = ptr;
    return 0;
  }
  if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_version)) {
    if (!isGeneralTextEntity) {
      *badPtr = name;
      return 0;
    }
  }
  else {
    if (versionPtr)
      *versionPtr = val;
    if (versionEndPtr)
      *versionEndPtr = ptr;
/* BEGIN MOZILLA CHANGE (http://bugzilla.mozilla.org/show_bug.cgi?id=62157) */
     /* Anything else but a version="1.0" is invalid for us, until we support later versions. */
     if (!XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_XML_1_0)) {
       *badPtr = val;
       return 0;
     }
/* END MOZILLA CHANGE */
    if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) {
      *badPtr = ptr;
      return 0;
    }
    if (!name) {
      if (isGeneralTextEntity) {
        /* a TextDecl must have an EncodingDecl */
        *badPtr = ptr;
        return 0;
      }
      return 1;
    }
  }
  if (XmlNameMatchesAscii(enc, name, nameEnd, KW_encoding)) {
    int c = toAscii(enc, val, end);
    if (!(ASCII_a <= c && c <= ASCII_z) && !(ASCII_A <= c && c <= ASCII_Z)) {
      *badPtr = val;
      return 0;
    }
    if (encodingName)
      *encodingName = val;
    if (encoding)
      *encoding = encodingFinder(enc, val, ptr - enc->minBytesPerChar);
    if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) {
      *badPtr = ptr;
      return 0;
    }
    if (!name)
      return 1;
  }
  if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_standalone)
      || isGeneralTextEntity) {
    *badPtr = name;
    return 0;
  }
  if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_yes)) {
    if (standalone)
      *standalone = 1;
  }
  else if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_no)) {
    if (standalone)
      *standalone = 0;
  }
  else {
    *badPtr = val;
    return 0;
  }
  while (isSpace(toAscii(enc, ptr, end)))
    ptr += enc->minBytesPerChar;
  if (ptr != end) {
    *badPtr = ptr;
    return 0;
  }
  return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int FASTCALL getEncodingIndex ( const char *  name) [static]

Definition at line 1462 of file xmltok.c.

{
  static const char *encodingNames[] = {
    KW_ISO_8859_1,
    KW_US_ASCII,
    KW_UTF_8,
    KW_UTF_16,
    KW_UTF_16BE,
    KW_UTF_16LE,
  };
  int i;
  if (name == NULL)
    return NO_ENC;
  for (i = 0; i < (int)(sizeof(encodingNames)/sizeof(encodingNames[0])); i++)
    if (streqci(name, encodingNames[i]))
      return i;
  return UNKNOWN_ENC;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int initScan ( const ENCODING **  encodingTable,
const INIT_ENCODING enc,
int  state,
const char *  ptr,
const char *  end,
const char **  nextTokPtr 
) [static]

Definition at line 1497 of file xmltok.c.

{
  const ENCODING **encPtr;

  if (ptr == end)
    return XML_TOK_NONE;
  encPtr = enc->encPtr;
  if (ptr + 1 == end) {
    /* only a single byte available for auto-detection */
#ifndef XML_DTD /* FIXME */
    /* a well-formed document entity must have more than one byte */
    if (state != XML_CONTENT_STATE)
      return XML_TOK_PARTIAL;
#endif
    /* so we're parsing an external text entity... */
    /* if UTF-16 was externally specified, then we need at least 2 bytes */
    switch (INIT_ENC_INDEX(enc)) {
    case UTF_16_ENC:
    case UTF_16LE_ENC:
    case UTF_16BE_ENC:
      return XML_TOK_PARTIAL;
    }
    switch ((unsigned char)*ptr) {
    case 0xFE:
    case 0xFF:
    case 0xEF: /* possibly first byte of UTF-8 BOM */
      if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
          && state == XML_CONTENT_STATE)
        break;
      /* fall through */
    case 0x00:
    case 0x3C:
      return XML_TOK_PARTIAL;
    }
  }
  else {
    switch (((unsigned char)ptr[0] << 8) | (unsigned char)ptr[1]) {
    case 0xFEFF:
      if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
          && state == XML_CONTENT_STATE)
        break;
      *nextTokPtr = ptr + 2;
      *encPtr = encodingTable[UTF_16BE_ENC];
      return XML_TOK_BOM;
    /* 00 3C is handled in the default case */
    case 0x3C00:
      if ((INIT_ENC_INDEX(enc) == UTF_16BE_ENC
           || INIT_ENC_INDEX(enc) == UTF_16_ENC)
          && state == XML_CONTENT_STATE)
        break;
      *encPtr = encodingTable[UTF_16LE_ENC];
      return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
    case 0xFFFE:
      if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
          && state == XML_CONTENT_STATE)
        break;
      *nextTokPtr = ptr + 2;
      *encPtr = encodingTable[UTF_16LE_ENC];
      return XML_TOK_BOM;
    case 0xEFBB:
      /* Maybe a UTF-8 BOM (EF BB BF) */
      /* If there's an explicitly specified (external) encoding
         of ISO-8859-1 or some flavour of UTF-16
         and this is an external text entity,
         don't look for the BOM,
         because it might be a legal data.
      */
      if (state == XML_CONTENT_STATE) {
        int e = INIT_ENC_INDEX(enc);
        if (e == ISO_8859_1_ENC || e == UTF_16BE_ENC
            || e == UTF_16LE_ENC || e == UTF_16_ENC)
          break;
      }
      if (ptr + 2 == end)
        return XML_TOK_PARTIAL;
      if ((unsigned char)ptr[2] == 0xBF) {
        *nextTokPtr = ptr + 3;
        *encPtr = encodingTable[UTF_8_ENC];
        return XML_TOK_BOM;
      }
      break;
    default:
      if (ptr[0] == '\0') {
        /* 0 isn't a legal data character. Furthermore a document
           entity can only start with ASCII characters.  So the only
           way this can fail to be big-endian UTF-16 if it it's an
           external parsed general entity that's labelled as
           UTF-16LE.
        */
        if (state == XML_CONTENT_STATE && INIT_ENC_INDEX(enc) == UTF_16LE_ENC)
          break;
        *encPtr = encodingTable[UTF_16BE_ENC];
        return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
      }
      else if (ptr[1] == '\0') {
        /* We could recover here in the case:
            - parsing an external entity
            - second byte is 0
            - no externally specified encoding
            - no encoding declaration
           by assuming UTF-16LE.  But we don't, because this would mean when
           presented just with a single byte, we couldn't reliably determine
           whether we needed further bytes.
        */
        if (state == XML_CONTENT_STATE)
          break;
        *encPtr = encodingTable[UTF_16LE_ENC];
        return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
      }
      break;
    }
  }
  *encPtr = encodingTable[INIT_ENC_INDEX(enc)];
  return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
}

Here is the caller graph for this function:

static void PTRCALL initUpdatePosition ( const ENCODING enc,
const char *  ptr,
const char *  end,
POSITION pos 
) [static]

Definition at line 928 of file xmltok.c.

{
  normal_updatePosition(&utf8_encoding.enc, ptr, end, pos);
}

Here is the caller graph for this function:

static int PTRFASTCALL isNever ( const ENCODING enc,
const char *  p 
) [static]

Definition at line 118 of file xmltok.c.

{
  return 0;
}
static int FASTCALL isSpace ( int  c) [static]

Definition at line 947 of file xmltok.c.

{
  switch (c) {
  case 0x20:
  case 0xD:
  case 0xA:
  case 0x9:
    return 1;
  }
  return 0;
}

Here is the caller graph for this function:

static void PTRCALL latin1_toUtf16 ( const ENCODING enc,
const char **  fromP,
const char *  fromLim,
unsigned short **  toP,
const unsigned short *  toLim 
) [static]

Definition at line 445 of file xmltok.c.

{
  while (*fromP != fromLim && *toP != toLim)
    *(*toP)++ = (unsigned char)*(*fromP)++;
}
static void PTRCALL latin1_toUtf8 ( const ENCODING enc,
const char **  fromP,
const char *  fromLim,
char **  toP,
const char *  toLim 
) [static]

Definition at line 420 of file xmltok.c.

{
  for (;;) {
    unsigned char c;
    if (*fromP == fromLim)
      break;
    c = (unsigned char)**fromP;
    if (c & 0x80) {
      if (toLim - *toP < 2)
        break;
      *(*toP)++ = (char)((c >> 6) | UTF8_cval2);
      *(*toP)++ = (char)((c & 0x3f) | 0x80);
      (*fromP)++;
    }
    else {
      if (*toP == toLim)
        break;
      *(*toP)++ = *(*fromP)++;
    }
  }
}
static int parsePseudoAttribute ( const ENCODING enc,
const char *  ptr,
const char *  end,
const char **  namePtr,
const char **  nameEndPtr,
const char **  valPtr,
const char **  nextTokPtr 
) [static]

Definition at line 963 of file xmltok.c.

{
  int c;
  char open;
  if (ptr == end) {
    *namePtr = NULL;
    return 1;
  }
  if (!isSpace(toAscii(enc, ptr, end))) {
    *nextTokPtr = ptr;
    return 0;
  }
  do {
    ptr += enc->minBytesPerChar;
  } while (isSpace(toAscii(enc, ptr, end)));
  if (ptr == end) {
    *namePtr = NULL;
    return 1;
  }
  *namePtr = ptr;
  for (;;) {
    c = toAscii(enc, ptr, end);
    if (c == -1) {
      *nextTokPtr = ptr;
      return 0;
    }
    if (c == ASCII_EQUALS) {
      *nameEndPtr = ptr;
      break;
    }
    if (isSpace(c)) {
      *nameEndPtr = ptr;
      do {
        ptr += enc->minBytesPerChar;
      } while (isSpace(c = toAscii(enc, ptr, end)));
      if (c != ASCII_EQUALS) {
        *nextTokPtr = ptr;
        return 0;
      }
      break;
    }
    ptr += enc->minBytesPerChar;
  }
  if (ptr == *namePtr) {
    *nextTokPtr = ptr;
    return 0;
  }
  ptr += enc->minBytesPerChar;
  c = toAscii(enc, ptr, end);
  while (isSpace(c)) {
    ptr += enc->minBytesPerChar;
    c = toAscii(enc, ptr, end);
  }
  if (c != ASCII_QUOT && c != ASCII_APOS) {
    *nextTokPtr = ptr;
    return 0;
  }
  open = (char)c;
  ptr += enc->minBytesPerChar;
  *valPtr = ptr;
  for (;; ptr += enc->minBytesPerChar) {
    c = toAscii(enc, ptr, end);
    if (c == open)
      break;
    if (!(ASCII_a <= c && c <= ASCII_z)
        && !(ASCII_A <= c && c <= ASCII_Z)
        && !(ASCII_0 <= c && c <= ASCII_9)
        && c != ASCII_PERIOD
        && c != ASCII_MINUS
        && c != ASCII_UNDERSCORE) {
      *nextTokPtr = ptr;
      return 0;
    }
  }
  *nextTokPtr = ptr + enc->minBytesPerChar;
  return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int FASTCALL streqci ( const char *  s1,
const char *  s2 
) [static]

Definition at line 910 of file xmltok.c.

{
  for (;;) {
    char c1 = *s1++;
    char c2 = *s2++;
    if (ASCII_a <= c1 && c1 <= ASCII_z)
      c1 += ASCII_A - ASCII_a;
    if (ASCII_a <= c2 && c2 <= ASCII_z)
      c2 += ASCII_A - ASCII_a;
    if (c1 != c2)
      return 0;
    if (!c1)
      break;
  }
  return 1;
}

Here is the caller graph for this function:

static int toAscii ( const ENCODING enc,
const char *  ptr,
const char *  end 
) [static]

Definition at line 935 of file xmltok.c.

{
  char buf[1];
  char *p = buf;
  XmlUtf8Convert(enc, &ptr, end, &p, p + 1);
  if (p == buf)
    return -1;
  else
    return buf[0];
}

Here is the caller graph for this function:

static int PTRFASTCALL unicode_byte_type ( char  hi,
char  lo 
) [static]

Definition at line 511 of file xmltok.c.

{
  switch ((unsigned char)hi) {
  case 0xD8: case 0xD9: case 0xDA: case 0xDB:
    return BT_LEAD4;
  case 0xDC: case 0xDD: case 0xDE: case 0xDF:
    return BT_TRAIL;
  case 0xFF:
    switch ((unsigned char)lo) {
    case 0xFF:
    case 0xFE:
      return BT_NONXML;
    }
    break;
  }
  return BT_NONASCII;
}
static int PTRFASTCALL unknown_isInvalid ( const ENCODING enc,
const char *  p 
) [static]

Definition at line 1284 of file xmltok.c.

{
  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
  int c = uenc->convert(uenc->userData, p);
  return (c & ~0xFFFF) || checkCharRefNumber(c) < 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int PTRFASTCALL unknown_isName ( const ENCODING enc,
const char *  p 
) [static]

Definition at line 1264 of file xmltok.c.

{
  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
  int c = uenc->convert(uenc->userData, p);
  if (c & ~0xFFFF)
    return 0;
  return UCS2_GET_NAMING(namePages, c >> 8, c & 0xFF);
}

Here is the caller graph for this function:

static int PTRFASTCALL unknown_isNmstrt ( const ENCODING enc,
const char *  p 
) [static]

Definition at line 1274 of file xmltok.c.

{
  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
  int c = uenc->convert(uenc->userData, p);
  if (c & ~0xFFFF)
    return 0;
  return UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xFF);
}

Here is the caller graph for this function:

static void PTRCALL unknown_toUtf16 ( const ENCODING enc,
const char **  fromP,
const char *  fromLim,
unsigned short **  toP,
const unsigned short *  toLim 
) [static]

Definition at line 1326 of file xmltok.c.

{
  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
  while (*fromP != fromLim && *toP != toLim) {
    unsigned short c = uenc->utf16[(unsigned char)**fromP];
    if (c == 0) {
      c = (unsigned short)
          uenc->convert(uenc->userData, *fromP);
      *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP]
                 - (BT_LEAD2 - 2));
    }
    else
      (*fromP)++;
    *(*toP)++ = c;
  }
}

Here is the caller graph for this function:

static void PTRCALL unknown_toUtf8 ( const ENCODING enc,
const char **  fromP,
const char *  fromLim,
char **  toP,
const char *  toLim 
) [static]

Definition at line 1292 of file xmltok.c.

{
  const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
  char buf[XML_UTF8_ENCODE_MAX];
  for (;;) {
    const char *utf8;
    int n;
    if (*fromP == fromLim)
      break;
    utf8 = uenc->utf8[(unsigned char)**fromP];
    n = *utf8++;
    if (n == 0) {
      int c = uenc->convert(uenc->userData, *fromP);
      n = XmlUtf8Encode(c, buf);
      if (n > toLim - *toP)
        break;
      utf8 = buf;
      *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP]
                 - (BT_LEAD2 - 2));
    }
    else {
      if (n > toLim - *toP)
        break;
      (*fromP)++;
    }
    do {
      *(*toP)++ = *utf8++;
    } while (--n != 0);
  }
}

Here is the caller graph for this function:

static int PTRFASTCALL utf8_isInvalid2 ( const ENCODING enc,
const char *  p 
) [static]

Definition at line 152 of file xmltok.c.

{
  return UTF8_INVALID2((const unsigned char *)p);
}
static int PTRFASTCALL utf8_isInvalid3 ( const ENCODING enc,
const char *  p 
) [static]

Definition at line 158 of file xmltok.c.

{
  return UTF8_INVALID3((const unsigned char *)p);
}
static int PTRFASTCALL utf8_isInvalid4 ( const ENCODING enc,
const char *  p 
) [static]

Definition at line 164 of file xmltok.c.

{
  return UTF8_INVALID4((const unsigned char *)p);
}
static int PTRFASTCALL utf8_isName2 ( const ENCODING enc,
const char *  p 
) [static]

Definition at line 124 of file xmltok.c.

{
  return UTF8_GET_NAMING2(namePages, (const unsigned char *)p);
}
static int PTRFASTCALL utf8_isName3 ( const ENCODING enc,
const char *  p 
) [static]

Definition at line 130 of file xmltok.c.

{
  return UTF8_GET_NAMING3(namePages, (const unsigned char *)p);
}
static int PTRFASTCALL utf8_isNmstrt2 ( const ENCODING enc,
const char *  p 
) [static]

Definition at line 138 of file xmltok.c.

{
  return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p);
}
static int PTRFASTCALL utf8_isNmstrt3 ( const ENCODING enc,
const char *  p 
) [static]

Definition at line 144 of file xmltok.c.

{
  return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p);
}
static void PTRCALL utf8_toUtf16 ( const ENCODING enc,
const char **  fromP,
const char *  fromLim,
unsigned short **  toP,
const unsigned short *  toLim 
) [static]

Definition at line 332 of file xmltok.c.

{
  unsigned short *to = *toP;
  const char *from = *fromP;
  while (from != fromLim && to != toLim) {
    switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) {
    case BT_LEAD2:
      *to++ = (unsigned short)(((from[0] & 0x1f) << 6) | (from[1] & 0x3f));
      from += 2;
      break;
    case BT_LEAD3:
      *to++ = (unsigned short)(((from[0] & 0xf) << 12)
                               | ((from[1] & 0x3f) << 6) | (from[2] & 0x3f));
      from += 3;
      break;
    case BT_LEAD4:
      {
        unsigned long n;
        if (to + 1 == toLim)
          goto after;
        n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12)
            | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f);
        n -= 0x10000;
        to[0] = (unsigned short)((n >> 10) | 0xD800);
        to[1] = (unsigned short)((n & 0x3FF) | 0xDC00);
        to += 2;
        from += 4;
      }
      break;
    default:
      *to++ = *from++;
      break;
    }
  }
after:
  *fromP = from;
  *toP = to;
}
static void PTRCALL utf8_toUtf8 ( const ENCODING enc,
const char **  fromP,
const char *  fromLim,
char **  toP,
const char *  toLim 
) [static]

Definition at line 313 of file xmltok.c.

{
  char *to;
  const char *from;
  if (fromLim - *fromP > toLim - *toP) {
    /* Avoid copying partial characters. */
    for (fromLim = *fromP + (toLim - *toP); fromLim > *fromP; fromLim--)
      if (((unsigned char)fromLim[-1] & 0xc0) != 0x80)
        break;
  }
  for (to = *toP, from = *fromP; from != fromLim; from++, to++)
    *to = *from;
  *fromP = from;
  *toP = to;
}
ENCODING* XmlInitUnknownEncoding ( void mem,
int table,
CONVERTER  convert,
void userData 
)

Definition at line 1346 of file xmltok.c.

{
  int i;
  struct unknown_encoding *e = (struct unknown_encoding *)mem;
  for (i = 0; i < (int)sizeof(struct normal_encoding); i++)
    ((char *)mem)[i] = ((char *)&latin1_encoding)[i];
  for (i = 0; i < 128; i++)
    if (latin1_encoding.type[i] != BT_OTHER
        && latin1_encoding.type[i] != BT_NONXML
        && table[i] != i)
      return 0;
  for (i = 0; i < 256; i++) {
    int c = table[i];
    if (c == -1) {
      e->normal.type[i] = BT_MALFORM;
      /* This shouldn't really get used. */
      e->utf16[i] = 0xFFFF;
      e->utf8[i][0] = 1;
      e->utf8[i][1] = 0;
    }
    else if (c < 0) {
      if (c < -4)
        return 0;
      e->normal.type[i] = (unsigned char)(BT_LEAD2 - (c + 2));
      e->utf8[i][0] = 0;
      e->utf16[i] = 0;
    }
    else if (c < 0x80) {
      if (latin1_encoding.type[c] != BT_OTHER
          && latin1_encoding.type[c] != BT_NONXML
          && c != i)
        return 0;
      e->normal.type[i] = latin1_encoding.type[c];
      e->utf8[i][0] = 1;
      e->utf8[i][1] = (char)c;
      e->utf16[i] = (unsigned short)(c == 0 ? 0xFFFF : c);
    }
    else if (checkCharRefNumber(c) < 0) {
      e->normal.type[i] = BT_NONXML;
      /* This shouldn't really get used. */
      e->utf16[i] = 0xFFFF;
      e->utf8[i][0] = 1;
      e->utf8[i][1] = 0;
    }
    else {
      if (c > 0xFFFF)
        return 0;
      if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff))
        e->normal.type[i] = BT_NMSTRT;
      else if (UCS2_GET_NAMING(namePages, c >> 8, c & 0xff))
        e->normal.type[i] = BT_NAME;
      else
        e->normal.type[i] = BT_OTHER;
      e->utf8[i][0] = (char)XmlUtf8Encode(c, e->utf8[i] + 1);
      e->utf16[i] = (unsigned short)c;
    }
  }
  e->userData = userData;
  e->convert = convert;
  if (convert) {
    e->normal.isName2 = unknown_isName;
    e->normal.isName3 = unknown_isName;
    e->normal.isName4 = unknown_isName;
    e->normal.isNmstrt2 = unknown_isNmstrt;
    e->normal.isNmstrt3 = unknown_isNmstrt;
    e->normal.isNmstrt4 = unknown_isNmstrt;
    e->normal.isInvalid2 = unknown_isInvalid;
    e->normal.isInvalid3 = unknown_isInvalid;
    e->normal.isInvalid4 = unknown_isInvalid;
  }
  e->normal.enc.utf8Convert = unknown_toUtf8;
  e->normal.enc.utf16Convert = unknown_toUtf16;
  return &(e->normal.enc);
}

Here is the call graph for this function:

Definition at line 1258 of file xmltok.c.

{
  return sizeof(struct unknown_encoding);
}
int FASTCALL XmlUtf16Encode ( int  charNum,
unsigned short *  buf 
)

Definition at line 1230 of file xmltok.c.

{
  if (charNum < 0)
    return 0;
  if (charNum < 0x10000) {
    buf[0] = (unsigned short)charNum;
    return 1;
  }
  if (charNum < 0x110000) {
    charNum -= 0x10000;
    buf[0] = (unsigned short)((charNum >> 10) + 0xD800);
    buf[1] = (unsigned short)((charNum & 0x3FF) + 0xDC00);
    return 2;
  }
  return 0;
}
int FASTCALL XmlUtf8Encode ( int  c,
char *  buf 
)

Definition at line 1193 of file xmltok.c.

{
  enum {
    /* minN is minimum legal resulting value for N byte sequence */
    min2 = 0x80,
    min3 = 0x800,
    min4 = 0x10000
  };

  if (c < 0)
    return 0;
  if (c < min2) {
    buf[0] = (char)(c | UTF8_cval1);
    return 1;
  }
  if (c < min3) {
    buf[0] = (char)((c >> 6) | UTF8_cval2);
    buf[1] = (char)((c & 0x3f) | 0x80);
    return 2;
  }
  if (c < min4) {
    buf[0] = (char)((c >> 12) | UTF8_cval3);
    buf[1] = (char)(((c >> 6) & 0x3f) | 0x80);
    buf[2] = (char)((c & 0x3f) | 0x80);
    return 3;
  }
  if (c < 0x110000) {
    buf[0] = (char)((c >> 18) | UTF8_cval4);
    buf[1] = (char)(((c >> 12) & 0x3f) | 0x80);
    buf[2] = (char)(((c >> 6) & 0x3f) | 0x80);
    buf[3] = (char)((c & 0x3f) | 0x80);
    return 4;
  }
  return 0;
}

Variable Documentation

const char KW_encoding[] [static]
Initial value:

Definition at line 1051 of file xmltok.c.

const char KW_ISO_8859_1[] [static]
Initial value:

Definition at line 1438 of file xmltok.c.

const char KW_no[] [static]
Initial value:
 {
  ASCII_n, ASCII_o,  '\0'
}

Definition at line 1064 of file xmltok.c.

const char KW_standalone[] [static]
Initial value:

Definition at line 1055 of file xmltok.c.

const char KW_US_ASCII[] [static]
Initial value:

Definition at line 1442 of file xmltok.c.

const char KW_UTF_16[] [static]
Initial value:

Definition at line 1449 of file xmltok.c.

const char KW_UTF_16BE[] [static]
Initial value:

Definition at line 1452 of file xmltok.c.

const char KW_UTF_16LE[] [static]
Initial value:

Definition at line 1456 of file xmltok.c.

const char KW_UTF_8[] [static]
Initial value:

Definition at line 1446 of file xmltok.c.

const char KW_version[] [static]
Initial value:

Definition at line 1047 of file xmltok.c.

const char KW_XML_1_0[] [static]
Initial value:

Definition at line 1069 of file xmltok.c.

const char KW_yes[] [static]
Initial value:
 {
  ASCII_y, ASCII_e, ASCII_s,  '\0'
}

Definition at line 1060 of file xmltok.c.

static struct normal_encoding [static]

Definition at line 384 of file xmltok.c.