head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.42; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.02.00; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.54.06; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.22.04; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

# xmltok_ns.c

    00001 const ENCODING *NS(XmlGetUtf8InternalEncoding)()
    00002 {
    00003   return &ns(internal_utf8_encoding).enc;
    00004 }
    00005
    00006 const ENCODING *NS(XmlGetUtf16InternalEncoding)()
    00007 {
    00008 #if XML_BYTE_ORDER == 12
    00009   return &ns(internal_little2_encoding).enc;
    00010 #elif XML_BYTE_ORDER == 21
    00011   return &ns(internal_big2_encoding).enc;
    00012 #else
    00013   const short n = 1;
    00014   return *(const char *)&n ? &ns(internal_little2_encoding).enc : &ns(internal_big2_encoding).enc;
    00015 #endif
    00016 }
    00017
    00018 static
    00019 const ENCODING *NS(encodings)[] = {
    00020   &ns(latin1_encoding).enc,
    00021   &ns(ascii_encoding).enc,
    00022   &ns(utf8_encoding).enc,
    00023   &ns(big2_encoding).enc,
    00024   &ns(big2_encoding).enc,
    00025   &ns(little2_encoding).enc,
    00026   &ns(utf8_encoding).enc /* NO_ENC */
    00027 };
    00028
    00029 static
    00030 int NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
    00031                        const char **nextTokPtr)
    00032 {
    00033   return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE, ptr, end, nextTokPtr);
    00034 }
    00035
    00036 static
    00037 int NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
    00038                        const char **nextTokPtr)
    00039 {
    00040   return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE, ptr, end, nextTokPtr);
    00041 }
    00042
    00043 int NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, const char *name)
    00044 {
    00045   int i = getEncodingIndex(name);
    00046   if (i == UNKNOWN_ENC)
    00047     return 0;
    00048   INIT_ENC_INDEX(p) = (char)i;
    00049   p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
    00050   p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
    00051   p->initEnc.updatePosition = initUpdatePosition;
    00052   p->encPtr = encPtr;
    00053   *encPtr = &(p->initEnc);
    00054   return 1;
    00055 }
    00056
    00057 static
    00058 const ENCODING *NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
    00059 {
    00060 #define ENCODING_MAX 128
    00061   char buf[ENCODING_MAX];
    00062   char *p = buf;
    00063   int i;
    00064   XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
    00065   if (ptr != end)
    00066     return 0;
    00067   *p = 0;
    00068   if (streqci(buf, "UTF-16") && enc->minBytesPerChar == 2)
    00069     return enc;
    00070   i = getEncodingIndex(buf);
    00071   if (i == UNKNOWN_ENC)
    00072     return 0;
    00073   return NS(encodings)[i];
    00074 }
    00075
    00076 int NS(XmlParseXmlDecl)(int isGeneralTextEntity,
    00077                         const ENCODING *enc,
    00078                         const char *ptr,
    00079                         const char *end,
    00080                         const char **badPtr,
    00081                         const char **versionPtr,
    00082                         const char **encodingName,
    00083                         const ENCODING **encoding,
    00084                         int *standalone)
    00085 {
    00086   return doParseXmlDecl(NS(findEncoding),
    00087                         isGeneralTextEntity,
    00088                         enc,
    00089                         ptr,
    00090                         end,
    00091                         badPtr,
    00092                         versionPtr,
    00093                         encodingName,
    00094                         encoding,
    00095                         standalone);
    00096 }

@ 1.3 log @Oops, try again. @ text @d105 1 a105 1