Commit c1aa3d82 authored by Jim Fulton's avatar Jim Fulton

major update with expat 1.1 and new pyexpat

parent 773b9f8b
*shared* *shared*
pyexpat pyexpat.o expat/libexpat.a -Iexpat/xmlparse pyexpat pyexpat.c -DXML_NS -Iexpat/xmlparse -Iexpat/xmltok expat/xmlparse/xmlparse.c expat/xmlparse/hashtable.c expat/xmltok/xmlrole.c expat/xmltok/xmltok.c
CC=cc CC=gcc
CFLAGS=-O2 -Ixmltok -Ixmlparse # If you know what your system's byte order is, define XML_BYTE_ORDER:
# use -DXML_BYTE_ORDER=12 for little-endian byte order;
# use -DXML_BYTE_ORDER=21 for big-endian (network) byte order.
# -DXML_NS adds support for checking of lexical aspects of XML namespaces spec
# -DXML_MIN_SIZE makes a smaller but slower parser
CFLAGS=-O2 -Ixmltok -Ixmlparse -DXML_NS
# Use one of the next two lines; unixfilemap is better if it works. # Use one of the next two lines; unixfilemap is better if it works.
FILEMAP_OBJ=xmlwf/unixfilemap.o FILEMAP_OBJ=xmlwf/unixfilemap.o
#FILEMAP_OBJ=xmlwf/readfilemap.o #FILEMAP_OBJ=xmlwf/readfilemap.o
OBJS=xmltok/xmltok.o \ OBJS=xmltok/xmltok.o \
xmltok/xmlrole.o \ xmltok/xmlrole.o \
xmlwf/xmlwf.o \ xmlwf/xmlwf.o \
xmlwf/xmlfile.o \
xmlwf/codepage.o \
xmlparse/xmlparse.o \ xmlparse/xmlparse.o \
xmlparse/hashtable.o \ xmlparse/hashtable.o \
$(FILEMAP_OBJ) $(FILEMAP_OBJ)
EXE= EXE=
all: xmlwf/xmlwf$(EXE) all: xmlwf/xmlwf$(EXE)
libexpat.a: $(OBJS)
ar cr libexpat.a $(OBJS)
xmlwf/xmlwf$(EXE): $(OBJS) xmlwf/xmlwf$(EXE): $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(CC) $(CFLAGS) -o $@ $(OBJS)
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd"> "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML> <HTML>
<TITLE>expat</TITLE> <TITLE>expat</TITLE>
<BODY> <BODY>
<H1>expat - XML Parser Toolkit</H1> <H1>expat - XML Parser Toolkit</H1>
<H3>Version 19980405</H3>
<P> <H3>Version 1.1</H3>
Copyright (c) 1998 James Clark. Expat is subject to the <A
HREF="MPL-1_0.html">Mozilla Public License Version 1.0</A>. You may <P>Copyright (c) 1998, 1999 James Clark. Expat is subject to the <A
not use expat except in compliance with this license. Please contact HREF="http://www.mozilla.org/NPL/NPL-1_1Final.html">Mozilla Public
me if you wish to negotiate an alternative license.</P><P> License Version 1.1</A>. Alternatively you may use expat under the <A
Expat is an <A HREF="http://www.w3.org/TR/1998/REC-xml-19980210">XML href="http://www.gnu.org/copyleft/gpl.html">GNU General Public
1.0</A> parser written in C. It aims to be fully conforming. It is License</A> instead. Please contact me if you wish to negotiate an
currently not a validating XML processor. alternative license.</P>
Expat can be downloaded from <A href =
"ftp://ftp.jclark.com/pub/xml/expat.zip">ftp://ftp.jclark.com/pub/xml/expat.zip</A>. <P>Expat is an <A
This is a beta-test version.</P> HREF="http://www.w3.org/TR/1998/REC-xml-19980210">XML 1.0</A> parser
<P> written in C. It aims to be fully conforming. It is currently not a
The directory <SAMP>xmltok</SAMP> contains a low-level library for validating XML processor. The current production version of expat can
tokenizing XML. The interface is documented in <SAMP>xmltok/xmltok.h</SAMP>.</P> be downloaded from <A href = "ftp://ftp.jclark.com/pub/xml/expat.zip"
<P> >ftp://ftp.jclark.com/pub/xml/expat.zip</A>.</P>
The directory <SAMP>xmlparse</SAMP> contains an XML parser library
<P>The directory <SAMP>xmltok</SAMP> contains a low-level library for
tokenizing XML. The interface is documented in
<SAMP>xmltok/xmltok.h</SAMP>.</P>
<P>The directory <SAMP>xmlparse</SAMP> contains an XML parser library
which is built on top of the <SAMP>xmltok</SAMP> library. The which is built on top of the <SAMP>xmltok</SAMP> library. The
interface is documented in <SAMP>xmlparse/xmlparse.h</SAMP>.</P> interface is documented in <SAMP>xmlparse/xmlparse.h</SAMP>. The
<P> directory <SAMP>sample</SAMP> contains a simple example program using
The directory <SAMP>xmlwf</SAMP> contains the <SAMP>xmlwf</SAMP> this interface; <SAMP>sample/build.bat</SAMP> is a batch file to build
the example using Visual C++.</P>
<P>The directory <SAMP>xmlwf</SAMP> contains the <SAMP>xmlwf</SAMP>
application, which uses the <SAMP>xmlparse</SAMP> library. The application, which uses the <SAMP>xmlparse</SAMP> library. The
arguments to <SAMP>xmlwf</SAMP> are one or more files which are each arguments to <SAMP>xmlwf</SAMP> are one or more files which are each
to be checked for well-formedness. An option <SAMP>-d to be checked for well-formedness. An option <SAMP>-d
...@@ -33,10 +45,29 @@ file the corresponding <A ...@@ -33,10 +45,29 @@ file the corresponding <A
href="http://www.jclark.com/xml/canonxml.html">canonical XML</A> will href="http://www.jclark.com/xml/canonxml.html">canonical XML</A> will
be written to <SAMP>dir/<VAR>f</VAR></SAMP>, where be written to <SAMP>dir/<VAR>f</VAR></SAMP>, where
<SAMP><VAR>f</VAR></SAMP> is the filename (without any path) of the <SAMP><VAR>f</VAR></SAMP> is the filename (without any path) of the
input file.</P> input file. A <CODE>-x</CODE> option will cause references to
external general entities to be processed. A <CODE>-s</CODE> option
will make documents that are not standalone cause an error (a document
is considered standalone if either it is intrinsically standalone
because it has no external subset and no references to parameter
entities in the internal subset or it is declared as standalone in the
XML declaration).</P>
<P>The <SAMP>bin</SAMP> directory contains Win32 executables. The
<SAMP>lib</SAMP> directory contains Win32 import libraries.</P>
<P>Answers to some frequently asked questions about expat can be found
in the <A HREF="http://www.jclark.com/xml/expatfaq.html">expat
FAQ</A>.</P>
<P></P> <P></P>
<ADDRESS> <ADDRESS>
<A HREF="mailto:jjc@jclark.com">James Clark</A> <A HREF="mailto:jjc@jclark.com">James Clark</A>
</ADDRESS> </ADDRESS>
</BODY> </BODY>
</HTML> </HTML>
/* /*
The contents of this file are subject to the Mozilla Public License The contents of this file are subject to the Mozilla Public License
Version 1.0 (the "License"); you may not use this file except in Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at csompliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" Software distributed under the License is distributed on an "AS IS"
...@@ -12,21 +12,45 @@ under the License. ...@@ -12,21 +12,45 @@ under the License.
The Original Code is expat. The Original Code is expat.
The Initial Developer of the Original Code is James Clark. The Initial Developer of the Original Code is James Clark.
Portions created by James Clark are Copyright (C) 1998 Portions created by James Clark are Copyright (C) 1998, 1999
James Clark. All Rights Reserved. James Clark. All Rights Reserved.
Contributor(s): Contributor(s):
Alternatively, the contents of this file may be used under the terms
of the GNU General Public License (the "GPL"), in which case the
provisions of the GPL are applicable instead of those above. If you
wish to allow use of your version of this file only under the terms of
the GPL and not to allow others to use your version of this file under
the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the
GPL. If you do not delete the provisions above, a recipient may use
your version of this file under either the MPL or the GPL.
*/ */
#include "xmldef.h" #include "xmldef.h"
#ifdef XML_UNICODE_WCHAR_T
#ifndef XML_UNICODE
#define XML_UNICODE
#endif
#endif
#include "hashtable.h" #include "hashtable.h"
#include <stdlib.h>
#include <string.h>
#define INIT_SIZE 64 #define INIT_SIZE 64
static static
unsigned long hash(const char *s) int keyeq(KEY s1, KEY s2)
{
for (; *s1 == *s2; s1++, s2++)
if (*s1 == 0)
return 1;
return 0;
}
static
unsigned long hash(KEY s)
{ {
unsigned long h = 0; unsigned long h = 0;
while (*s) while (*s)
...@@ -34,7 +58,7 @@ unsigned long hash(const char *s) ...@@ -34,7 +58,7 @@ unsigned long hash(const char *s)
return h; return h;
} }
NAMED *lookup(HASH_TABLE *table, const char *name, size_t createSize) NAMED *lookup(HASH_TABLE *table, KEY name, size_t createSize)
{ {
size_t i; size_t i;
if (table->size == 0) { if (table->size == 0) {
...@@ -52,7 +76,7 @@ NAMED *lookup(HASH_TABLE *table, const char *name, size_t createSize) ...@@ -52,7 +76,7 @@ NAMED *lookup(HASH_TABLE *table, const char *name, size_t createSize)
for (i = h & (table->size - 1); for (i = h & (table->size - 1);
table->v[i]; table->v[i];
i == 0 ? i = table->size - 1 : --i) { i == 0 ? i = table->size - 1 : --i) {
if (strcmp(name, table->v[i]->name) == 0) if (keyeq(name, table->v[i]->name))
return table->v[i]; return table->v[i];
} }
if (!createSize) if (!createSize)
......
/* /*
The contents of this file are subject to the Mozilla Public License The contents of this file are subject to the Mozilla Public License
Version 1.0 (the "License"); you may not use this file except in Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
...@@ -12,17 +12,41 @@ under the License. ...@@ -12,17 +12,41 @@ under the License.
The Original Code is expat. The Original Code is expat.
The Initial Developer of the Original Code is James Clark. The Initial Developer of the Original Code is James Clark.
Portions created by James Clark are Copyright (C) 1998 Portions created by James Clark are Copyright (C) 1998, 1999
James Clark. All Rights Reserved. James Clark. All Rights Reserved.
Contributor(s): Contributor(s):
Alternatively, the contents of this file may be used under the terms
of the GNU General Public License (the "GPL"), in which case the
provisions of the GPL are applicable instead of those above. If you
wish to allow use of your version of this file only under the terms of
the GPL and not to allow others to use your version of this file under
the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the
GPL. If you do not delete the provisions above, a recipient may use
your version of this file under either the MPL or the GPL.
*/ */
#include <stddef.h> #include <stddef.h>
#ifdef XML_UNICODE
#ifdef XML_UNICODE_WCHAR_T
typedef const wchar_t *KEY;
#else /* not XML_UNICODE_WCHAR_T */
typedef const unsigned short *KEY;
#endif /* not XML_UNICODE_WCHAR_T */
#else /* not XML_UNICODE */
typedef const char *KEY;
#endif /* not XML_UNICODE */
typedef struct { typedef struct {
const char *name; KEY name;
} NAMED; } NAMED;
typedef struct { typedef struct {
...@@ -32,7 +56,7 @@ typedef struct { ...@@ -32,7 +56,7 @@ typedef struct {
size_t usedLim; size_t usedLim;
} HASH_TABLE; } HASH_TABLE;
NAMED *lookup(HASH_TABLE *table, const char *name, size_t createSize); NAMED *lookup(HASH_TABLE *table, KEY name, size_t createSize);
void hashTableInit(HASH_TABLE *); void hashTableInit(HASH_TABLE *);
void hashTableDestroy(HASH_TABLE *); void hashTableDestroy(HASH_TABLE *);
......
/* /*
The contents of this file are subject to the Mozilla Public License The contents of this file are subject to the Mozilla Public License
Version 1.0 (the "License"); you may not use this file except in Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
...@@ -12,10 +12,20 @@ under the License. ...@@ -12,10 +12,20 @@ under the License.
The Original Code is expat. The Original Code is expat.
The Initial Developer of the Original Code is James Clark. The Initial Developer of the Original Code is James Clark.
Portions created by James Clark are Copyright (C) 1998 Portions created by James Clark are Copyright (C) 1998, 1999
James Clark. All Rights Reserved. James Clark. All Rights Reserved.
Contributor(s): Contributor(s):
Alternatively, the contents of this file may be used under the terms
of the GNU General Public License (the "GPL"), in which case the
provisions of the GPL are applicable instead of those above. If you
wish to allow use of your version of this file only under the terms of
the GPL and not to allow others to use your version of this file under
the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the
GPL. If you do not delete the provisions above, a recipient may use
your version of this file under either the MPL or the GPL.
*/ */
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, /* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
...@@ -32,7 +42,7 @@ Contributor(s): ...@@ -32,7 +42,7 @@ Contributor(s):
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL, /* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, /* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, /* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_NMSTRT, BT_SEMI, /* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST, /* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, /* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, /* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
......
/* /*
The contents of this file are subject to the Mozilla Public License The contents of this file are subject to the Mozilla Public License
Version 1.0 (the "License"); you may not use this file except in Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
...@@ -12,12 +12,25 @@ under the License. ...@@ -12,12 +12,25 @@ under the License.
The Original Code is expat. The Original Code is expat.
The Initial Developer of the Original Code is James Clark. The Initial Developer of the Original Code is James Clark.
Portions created by James Clark are Copyright (C) 1998 Portions created by James Clark are Copyright (C) 1998, 1999
James Clark. All Rights Reserved. James Clark. All Rights Reserved.
Contributor(s): Contributor(s):
Alternatively, the contents of this file may be used under the terms
of the GNU General Public License (the "GPL"), in which case the
provisions of the GPL are applicable instead of those above. If you
wish to allow use of your version of this file only under the terms of
the GPL and not to allow others to use your version of this file under
the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the
GPL. If you do not delete the provisions above, a recipient may use
your version of this file under either the MPL or the GPL.
*/ */
#define STRICT 1
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h> #include <windows.h>
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
......
/* /*
The contents of this file are subject to the Mozilla Public License The contents of this file are subject to the Mozilla Public License
Version 1.0 (the "License"); you may not use this file except in Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
...@@ -12,10 +12,20 @@ under the License. ...@@ -12,10 +12,20 @@ under the License.
The Original Code is expat. The Original Code is expat.
The Initial Developer of the Original Code is James Clark. The Initial Developer of the Original Code is James Clark.
Portions created by James Clark are Copyright (C) 1998 Portions created by James Clark are Copyright (C) 1998, 1999
James Clark. All Rights Reserved. James Clark. All Rights Reserved.
Contributor(s): Contributor(s):
Alternatively, the contents of this file may be used under the terms
of the GNU General Public License (the "GPL"), in which case the
provisions of the GPL are applicable instead of those above. If you
wish to allow use of your version of this file only under the terms of
the GPL and not to allow others to use your version of this file under
the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the
GPL. If you do not delete the provisions above, a recipient may use
your version of this file under either the MPL or the GPL.
*/ */
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */ /* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
...@@ -33,7 +43,7 @@ Contributor(s): ...@@ -33,7 +43,7 @@ Contributor(s):
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL, /* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, /* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT, /* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_NMSTRT, BT_SEMI, /* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST, /* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX, /* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT, /* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
......
/* /*
The contents of this file are subject to the Mozilla Public License The contents of this file are subject to the Mozilla Public License
Version 1.0 (the "License"); you may not use this file except in Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
...@@ -12,10 +12,20 @@ under the License. ...@@ -12,10 +12,20 @@ under the License.
The Original Code is expat. The Original Code is expat.
The Initial Developer of the Original Code is James Clark. The Initial Developer of the Original Code is James Clark.
Portions created by James Clark are Copyright (C) 1998 Portions created by James Clark are Copyright (C) 1998, 1999
James Clark. All Rights Reserved. James Clark. All Rights Reserved.
Contributor(s): Contributor(s):
Alternatively, the contents of this file may be used under the terms
of the GNU General Public License (the "GPL"), in which case the
provisions of the GPL are applicable instead of those above. If you
wish to allow use of your version of this file only under the terms of
the GPL and not to allow others to use your version of this file under
the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the
GPL. If you do not delete the provisions above, a recipient may use
your version of this file under either the MPL or the GPL.
*/ */
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, /* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
......
/* /*
The contents of this file are subject to the Mozilla Public License The contents of this file are subject to the Mozilla Public License
Version 1.0 (the "License"); you may not use this file except in Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
...@@ -12,10 +12,20 @@ under the License. ...@@ -12,10 +12,20 @@ under the License.
The Original Code is expat. The Original Code is expat.
The Initial Developer of the Original Code is James Clark. The Initial Developer of the Original Code is James Clark.
Portions created by James Clark are Copyright (C) 1998 Portions created by James Clark are Copyright (C) 1998, 1999
James Clark. All Rights Reserved. James Clark. All Rights Reserved.
Contributor(s): Contributor(s):
Alternatively, the contents of this file may be used under the terms
of the GNU General Public License (the "GPL"), in which case the
provisions of the GPL are applicable instead of those above. If you
wish to allow use of your version of this file only under the terms of
the GPL and not to allow others to use your version of this file under
the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the
GPL. If you do not delete the provisions above, a recipient may use
your version of this file under either the MPL or the GPL.
*/ */
......
/* /*
The contents of this file are subject to the Mozilla Public License The contents of this file are subject to the Mozilla Public License
Version 1.0 (the "License"); you may not use this file except in Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
...@@ -12,19 +12,50 @@ under the License. ...@@ -12,19 +12,50 @@ under the License.
The Original Code is expat. The Original Code is expat.
The Initial Developer of the Original Code is James Clark. The Initial Developer of the Original Code is James Clark.
Portions created by James Clark are Copyright (C) 1998 Portions created by James Clark are Copyright (C) 1998, 1999
James Clark. All Rights Reserved. James Clark. All Rights Reserved.
Contributor(s): Contributor(s):
Alternatively, the contents of this file may be used under the terms
of the GNU General Public License (the "GPL"), in which case the
provisions of the GPL are applicable instead of those above. If you
wish to allow use of your version of this file only under the terms of
the GPL and not to allow others to use your version of this file under
the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the
GPL. If you do not delete the provisions above, a recipient may use
your version of this file under either the MPL or the GPL.
*/ */
#include <string.h>
#ifdef XML_WINLIB
#define WIN32_LEAN_AND_MEAN
#define STRICT
#include <windows.h>
#define malloc(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define calloc(x, y) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (x)*(y))
#define free(x) HeapFree(GetProcessHeap(), 0, (x))
#define realloc(x, y) HeapReAlloc(GetProcessHeap(), 0, x, y)
#define abort() /* as nothing */
#else /* not XML_WINLIB */
#include <stdlib.h>
#endif /* not XML_WINLIB */
/* This file can be used for any definitions needed in /* This file can be used for any definitions needed in
particular environments. */ particular environments. */
#ifdef MOZILLA #ifdef MOZILLA
#include "nspr.h" #include "nspr.h"
#define malloc(x) PR_Calloc(1,(x)) #define malloc(x) PR_Malloc(x)
#define realloc(x, y) PR_Realloc((x), (y))
#define calloc(x, y) PR_Calloc((x),(y)) #define calloc(x, y) PR_Calloc((x),(y))
#define free(x) PR_Free(x) #define free(x) PR_Free(x)
#define int int32 #define int int32
......
/* /*
The contents of this file are subject to the Mozilla Public License The contents of this file are subject to the Mozilla Public License
Version 1.0 (the "License"); you may not use this file except in Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
...@@ -12,10 +12,20 @@ under the License. ...@@ -12,10 +12,20 @@ under the License.
The Original Code is expat. The Original Code is expat.
The Initial Developer of the Original Code is James Clark. The Initial Developer of the Original Code is James Clark.
Portions created by James Clark are Copyright (C) 1998 Portions created by James Clark are Copyright (C) 1998, 1999
James Clark. All Rights Reserved. James Clark. All Rights Reserved.
Contributor(s): Contributor(s):
Alternatively, the contents of this file may be used under the terms
of the GNU General Public License (the "GPL"), in which case the
provisions of the GPL are applicable instead of those above. If you
wish to allow use of your version of this file only under the terms of
the GPL and not to allow others to use your version of this file under
the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the
GPL. If you do not delete the provisions above, a recipient may use
your version of this file under either the MPL or the GPL.
*/ */
#include "xmldef.h" #include "xmldef.h"
...@@ -149,6 +159,7 @@ int doctype0(PROLOG_STATE *state, ...@@ -149,6 +159,7 @@ int doctype0(PROLOG_STATE *state,
case XML_TOK_PROLOG_S: case XML_TOK_PROLOG_S:
return XML_ROLE_NONE; return XML_ROLE_NONE;
case XML_TOK_NAME: case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = doctype1; state->handler = doctype1;
return XML_ROLE_DOCTYPE_NAME; return XML_ROLE_DOCTYPE_NAME;
} }
...@@ -594,7 +605,7 @@ int notation4(PROLOG_STATE *state, ...@@ -594,7 +605,7 @@ int notation4(PROLOG_STATE *state,
return XML_ROLE_NOTATION_SYSTEM_ID; return XML_ROLE_NOTATION_SYSTEM_ID;
case XML_TOK_DECL_CLOSE: case XML_TOK_DECL_CLOSE:
state->handler = internalSubset; state->handler = internalSubset;
return XML_ROLE_NONE; return XML_ROLE_NOTATION_NO_SYSTEM_ID;
} }
return syntaxError(state); return syntaxError(state);
} }
...@@ -610,6 +621,7 @@ int attlist0(PROLOG_STATE *state, ...@@ -610,6 +621,7 @@ int attlist0(PROLOG_STATE *state,
case XML_TOK_PROLOG_S: case XML_TOK_PROLOG_S:
return XML_ROLE_NONE; return XML_ROLE_NONE;
case XML_TOK_NAME: case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = attlist1; state->handler = attlist1;
return XML_ROLE_ATTLIST_ELEMENT_NAME; return XML_ROLE_ATTLIST_ELEMENT_NAME;
} }
...@@ -630,6 +642,7 @@ int attlist1(PROLOG_STATE *state, ...@@ -630,6 +642,7 @@ int attlist1(PROLOG_STATE *state,
state->handler = internalSubset; state->handler = internalSubset;
return XML_ROLE_NONE; return XML_ROLE_NONE;
case XML_TOK_NAME: case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = attlist2; state->handler = attlist2;
return XML_ROLE_ATTRIBUTE_NAME; return XML_ROLE_ATTRIBUTE_NAME;
} }
...@@ -689,6 +702,7 @@ int attlist3(PROLOG_STATE *state, ...@@ -689,6 +702,7 @@ int attlist3(PROLOG_STATE *state,
return XML_ROLE_NONE; return XML_ROLE_NONE;
case XML_TOK_NMTOKEN: case XML_TOK_NMTOKEN:
case XML_TOK_NAME: case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = attlist4; state->handler = attlist4;
return XML_ROLE_ATTRIBUTE_ENUM_VALUE; return XML_ROLE_ATTRIBUTE_ENUM_VALUE;
} }
...@@ -836,6 +850,7 @@ int element0(PROLOG_STATE *state, ...@@ -836,6 +850,7 @@ int element0(PROLOG_STATE *state,
case XML_TOK_PROLOG_S: case XML_TOK_PROLOG_S:
return XML_ROLE_NONE; return XML_ROLE_NONE;
case XML_TOK_NAME: case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = element1; state->handler = element1;
return XML_ROLE_ELEMENT_NAME; return XML_ROLE_ELEMENT_NAME;
} }
...@@ -893,6 +908,7 @@ int element2(PROLOG_STATE *state, ...@@ -893,6 +908,7 @@ int element2(PROLOG_STATE *state,
state->handler = element6; state->handler = element6;
return XML_ROLE_GROUP_OPEN; return XML_ROLE_GROUP_OPEN;
case XML_TOK_NAME: case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = element7; state->handler = element7;
return XML_ROLE_CONTENT_ELEMENT; return XML_ROLE_CONTENT_ELEMENT;
case XML_TOK_NAME_QUESTION: case XML_TOK_NAME_QUESTION:
...@@ -940,6 +956,7 @@ int element4(PROLOG_STATE *state, ...@@ -940,6 +956,7 @@ int element4(PROLOG_STATE *state,
case XML_TOK_PROLOG_S: case XML_TOK_PROLOG_S:
return XML_ROLE_NONE; return XML_ROLE_NONE;
case XML_TOK_NAME: case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = element5; state->handler = element5;
return XML_ROLE_CONTENT_ELEMENT; return XML_ROLE_CONTENT_ELEMENT;
} }
...@@ -980,6 +997,7 @@ int element6(PROLOG_STATE *state, ...@@ -980,6 +997,7 @@ int element6(PROLOG_STATE *state,
state->level += 1; state->level += 1;
return XML_ROLE_GROUP_OPEN; return XML_ROLE_GROUP_OPEN;
case XML_TOK_NAME: case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = element7; state->handler = element7;
return XML_ROLE_CONTENT_ELEMENT; return XML_ROLE_CONTENT_ELEMENT;
case XML_TOK_NAME_QUESTION: case XML_TOK_NAME_QUESTION:
......
/* /*
The contents of this file are subject to the Mozilla Public License The contents of this file are subject to the Mozilla Public License
Version 1.0 (the "License"); you may not use this file except in Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
...@@ -12,10 +12,20 @@ under the License. ...@@ -12,10 +12,20 @@ under the License.
The Original Code is expat. The Original Code is expat.
The Initial Developer of the Original Code is James Clark. The Initial Developer of the Original Code is James Clark.
Portions created by James Clark are Copyright (C) 1998 Portions created by James Clark are Copyright (C) 1998, 1999
James Clark. All Rights Reserved. James Clark. All Rights Reserved.
Contributor(s): Contributor(s):
Alternatively, the contents of this file may be used under the terms
of the GNU General Public License (the "GPL"), in which case the
provisions of the GPL are applicable instead of those above. If you
wish to allow use of your version of this file only under the terms of
the GPL and not to allow others to use your version of this file under
the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the
GPL. If you do not delete the provisions above, a recipient may use
your version of this file under either the MPL or the GPL.
*/ */
#ifndef XmlRole_INCLUDED #ifndef XmlRole_INCLUDED
...@@ -44,6 +54,7 @@ enum { ...@@ -44,6 +54,7 @@ enum {
XML_ROLE_ENTITY_NOTATION_NAME, XML_ROLE_ENTITY_NOTATION_NAME,
XML_ROLE_NOTATION_NAME, XML_ROLE_NOTATION_NAME,
XML_ROLE_NOTATION_SYSTEM_ID, XML_ROLE_NOTATION_SYSTEM_ID,
XML_ROLE_NOTATION_NO_SYSTEM_ID,
XML_ROLE_NOTATION_PUBLIC_ID, XML_ROLE_NOTATION_PUBLIC_ID,
XML_ROLE_ATTRIBUTE_NAME, XML_ROLE_ATTRIBUTE_NAME,
XML_ROLE_ATTRIBUTE_TYPE_CDATA, XML_ROLE_ATTRIBUTE_TYPE_CDATA,
......
/* /*
The contents of this file are subject to the Mozilla Public License The contents of this file are subject to the Mozilla Public License
Version 1.0 (the "License"); you may not use this file except in Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
...@@ -12,10 +12,20 @@ under the License. ...@@ -12,10 +12,20 @@ under the License.
The Original Code is expat. The Original Code is expat.
The Initial Developer of the Original Code is James Clark. The Initial Developer of the Original Code is James Clark.
Portions created by James Clark are Copyright (C) 1998 Portions created by James Clark are Copyright (C) 1998, 1999
James Clark. All Rights Reserved. James Clark. All Rights Reserved.
Contributor(s): Contributor(s):
Alternatively, the contents of this file may be used under the terms
of the GNU General Public License (the "GPL"), in which case the
provisions of the GPL are applicable instead of those above. If you
wish to allow use of your version of this file only under the terms of
the GPL and not to allow others to use your version of this file under
the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the
GPL. If you do not delete the provisions above, a recipient may use
your version of this file under either the MPL or the GPL.
*/ */
#ifndef XmlTok_INCLUDED #ifndef XmlTok_INCLUDED
...@@ -29,6 +39,9 @@ extern "C" { ...@@ -29,6 +39,9 @@ extern "C" {
#define XMLTOKAPI /* as nothing */ #define XMLTOKAPI /* as nothing */
#endif #endif
/* The following token may be returned by XmlContentTok */
#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be start of
illegal ]]> sequence */
/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */ /* The following tokens may be returned by both XmlPrologTok and XmlContentTok */
#define XML_TOK_NONE -4 /* The string to be scanned is empty */ #define XML_TOK_NONE -4 /* The string to be scanned is empty */
#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan; #define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan;
...@@ -38,7 +51,7 @@ extern "C" { ...@@ -38,7 +51,7 @@ extern "C" {
#define XML_TOK_INVALID 0 #define XML_TOK_INVALID 0
/* The following tokens are returned by XmlContentTok; some are also /* The following tokens are returned by XmlContentTok; some are also
returned by XmlAttributeValueTok and XmlEntityTok */ returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok */
#define XML_TOK_START_TAG_WITH_ATTS 1 #define XML_TOK_START_TAG_WITH_ATTS 1
#define XML_TOK_START_TAG_NO_ATTS 2 #define XML_TOK_START_TAG_NO_ATTS 2
...@@ -47,7 +60,7 @@ extern "C" { ...@@ -47,7 +60,7 @@ extern "C" {
#define XML_TOK_END_TAG 5 #define XML_TOK_END_TAG 5
#define XML_TOK_DATA_CHARS 6 #define XML_TOK_DATA_CHARS 6
#define XML_TOK_DATA_NEWLINE 7 #define XML_TOK_DATA_NEWLINE 7
#define XML_TOK_CDATA_SECTION 8 #define XML_TOK_CDATA_SECT_OPEN 8
#define XML_TOK_ENTITY_REF 9 #define XML_TOK_ENTITY_REF 9
#define XML_TOK_CHAR_REF 10 /* numeric character reference */ #define XML_TOK_CHAR_REF 10 /* numeric character reference */
...@@ -85,25 +98,29 @@ extern "C" { ...@@ -85,25 +98,29 @@ extern "C" {
#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */ #define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
#define XML_TOK_COMMA 38 #define XML_TOK_COMMA 38
/* The following tokens is returned only by XmlAttributeValueTok */ /* The following token is returned only by XmlAttributeValueTok */
#define XML_TOK_ATTRIBUTE_VALUE_S 39 #define XML_TOK_ATTRIBUTE_VALUE_S 39
#define XML_N_STATES 2 /* The following token is returned only by XmlCdataSectionTok */
#define XML_TOK_CDATA_SECT_CLOSE 40
/* With namespace processing this is returned by XmlPrologTok
for a name with a colon. */
#define XML_TOK_PREFIXED_NAME 41
#define XML_N_STATES 3
#define XML_PROLOG_STATE 0 #define XML_PROLOG_STATE 0
#define XML_CONTENT_STATE 1 #define XML_CONTENT_STATE 1
#define XML_CDATA_SECTION_STATE 2
#define XML_N_LITERAL_TYPES 2 #define XML_N_LITERAL_TYPES 2
#define XML_ATTRIBUTE_VALUE_LITERAL 0 #define XML_ATTRIBUTE_VALUE_LITERAL 0
#define XML_ENTITY_VALUE_LITERAL 1 #define XML_ENTITY_VALUE_LITERAL 1
#define XML_N_INTERNAL_ENCODINGS 1 /* The size of the buffer passed to XmlUtf8Encode must be at least this. */
#define XML_UTF8_ENCODING 0 #define XML_UTF8_ENCODE_MAX 4
#if 0 /* The size of the buffer passed to XmlUtf16Encode must be at least this. */
#define XML_UTF16_ENCODING 1 #define XML_UTF16_ENCODE_MAX 2
#define XML_UCS4_ENCODING 2
#endif
#define XML_MAX_BYTES_PER_CHAR 4
typedef struct position { typedef struct position {
/* first line and first column are 0 not 1 */ /* first line and first column are 0 not 1 */
...@@ -139,21 +156,26 @@ struct encoding { ...@@ -139,21 +156,26 @@ struct encoding {
int (*getAtts)(const ENCODING *enc, const char *ptr, int (*getAtts)(const ENCODING *enc, const char *ptr,
int attsMax, ATTRIBUTE *atts); int attsMax, ATTRIBUTE *atts);
int (*charRefNumber)(const ENCODING *enc, const char *ptr); int (*charRefNumber)(const ENCODING *enc, const char *ptr);
int (*predefinedEntityName)(const ENCODING *, const char *, const char *);
void (*updatePosition)(const ENCODING *, void (*updatePosition)(const ENCODING *,
const char *ptr, const char *ptr,
const char *end, const char *end,
POSITION *); POSITION *);
int (*isPublicId)(const ENCODING *enc, const char *ptr, const char *end, int (*isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
const char **badPtr); const char **badPtr);
int (*encode)(const ENCODING *enc, void (*utf8Convert)(const ENCODING *enc,
int charNum, const char **fromP,
char *buf); const char *fromLim,
void (*convert[XML_N_INTERNAL_ENCODINGS])(const ENCODING *enc, char **toP,
const char **fromP, const char *toLim);
const char *fromLim, void (*utf16Convert)(const ENCODING *enc,
char **toP, const char **fromP,
const char *toLim); const char *fromLim,
unsigned short **toP,
const unsigned short *toLim);
int minBytesPerChar; int minBytesPerChar;
char isUtf8;
char isUtf16;
}; };
/* /*
...@@ -186,6 +208,9 @@ literals, comments and processing instructions. ...@@ -186,6 +208,9 @@ literals, comments and processing instructions.
#define XmlContentTok(enc, ptr, end, nextTokPtr) \ #define XmlContentTok(enc, ptr, end, nextTokPtr) \
XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr) XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
/* This is used for performing a 2nd-level tokenization on /* This is used for performing a 2nd-level tokenization on
the content of a literal that has already been returned by XmlTok. */ the content of a literal that has already been returned by XmlTok. */
...@@ -215,17 +240,20 @@ the content of a literal that has already been returned by XmlTok. */ ...@@ -215,17 +240,20 @@ the content of a literal that has already been returned by XmlTok. */
#define XmlCharRefNumber(enc, ptr) \ #define XmlCharRefNumber(enc, ptr) \
(((enc)->charRefNumber)(enc, ptr)) (((enc)->charRefNumber)(enc, ptr))
#define XmlPredefinedEntityName(enc, ptr, end) \
(((enc)->predefinedEntityName)(enc, ptr, end))
#define XmlUpdatePosition(enc, ptr, end, pos) \ #define XmlUpdatePosition(enc, ptr, end, pos) \
(((enc)->updatePosition)(enc, ptr, end, pos)) (((enc)->updatePosition)(enc, ptr, end, pos))
#define XmlIsPublicId(enc, ptr, end, badPtr) \ #define XmlIsPublicId(enc, ptr, end, badPtr) \
(((enc)->isPublicId)(enc, ptr, end, badPtr)) (((enc)->isPublicId)(enc, ptr, end, badPtr))
#define XmlEncode(enc, ch, buf) \ #define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
(((enc)->encode)(enc, ch, buf)) (((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
#define XmlConvert(enc, targetEnc, fromP, fromLim, toP, toLim) \ #define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
(((enc)->convert[targetEnc])(enc, fromP, fromLim, toP, toLim)) (((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
typedef struct { typedef struct {
ENCODING initEnc; ENCODING initEnc;
...@@ -243,8 +271,35 @@ int XMLTOKAPI XmlParseXmlDecl(int isGeneralTextEntity, ...@@ -243,8 +271,35 @@ int XMLTOKAPI XmlParseXmlDecl(int isGeneralTextEntity,
int *standalonePtr); int *standalonePtr);
int XMLTOKAPI XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name); int XMLTOKAPI XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
const ENCODING XMLTOKAPI *XmlGetInternalEncoding(int); const ENCODING XMLTOKAPI *XmlGetUtf8InternalEncoding();
const ENCODING XMLTOKAPI *XmlGetUtf16InternalEncoding();
int XMLTOKAPI XmlUtf8Encode(int charNumber, char *buf);
int XMLTOKAPI XmlUtf16Encode(int charNumber, unsigned short *buf);
int XMLTOKAPI XmlSizeOfUnknownEncoding();
ENCODING XMLTOKAPI *
XmlInitUnknownEncoding(void *mem,
int *table,
int (*conv)(void *userData, const char *p),
void *userData);
int XMLTOKAPI XmlParseXmlDeclNS(int isGeneralTextEntity,
const ENCODING *enc,
const char *ptr,
const char *end,
const char **badPtr,
const char **versionPtr,
const char **encodingNamePtr,
const ENCODING **namedEncodingPtr,
int *standalonePtr);
int XMLTOKAPI XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
const ENCODING XMLTOKAPI *XmlGetUtf8InternalEncodingNS();
const ENCODING XMLTOKAPI *XmlGetUtf16InternalEncodingNS();
ENCODING XMLTOKAPI *
XmlInitUnknownEncodingNS(void *mem,
int *table,
int (*conv)(void *userData, const char *p),
void *userData);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
/* /*
The contents of this file are subject to the Mozilla Public License The contents of this file are subject to the Mozilla Public License
Version 1.0 (the "License"); you may not use this file except in Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
...@@ -12,10 +12,20 @@ under the License. ...@@ -12,10 +12,20 @@ under the License.
The Original Code is expat. The Original Code is expat.
The Initial Developer of the Original Code is James Clark. The Initial Developer of the Original Code is James Clark.
Portions created by James Clark are Copyright (C) 1998 Portions created by James Clark are Copyright (C) 1998, 1999
James Clark. All Rights Reserved. James Clark. All Rights Reserved.
Contributor(s): Contributor(s):
Alternatively, the contents of this file may be used under the terms
of the GNU General Public License (the "GPL"), in which case the
provisions of the GPL are applicable instead of those above. If you
wish to allow use of your version of this file only under the terms of
the GPL and not to allow others to use your version of this file under
the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the
GPL. If you do not delete the provisions above, a recipient may use
your version of this file under either the MPL or the GPL.
*/ */
enum { enum {
...@@ -42,6 +52,7 @@ enum { ...@@ -42,6 +52,7 @@ enum {
BT_LSQB, BT_LSQB,
BT_S, BT_S,
BT_NMSTRT, BT_NMSTRT,
BT_COLON,
BT_HEX, BT_HEX,
BT_DIGIT, BT_DIGIT,
BT_NAME, BT_NAME,
......
const ENCODING *NS(XmlGetUtf8InternalEncoding)()
{
return &ns(internal_utf8_encoding).enc;
}
const ENCODING *NS(XmlGetUtf16InternalEncoding)()
{
#if XML_BYTE_ORDER == 12
return &ns(internal_little2_encoding).enc;
#elif XML_BYTE_ORDER == 21
return &ns(internal_big2_encoding).enc;
#else
const short n = 1;
return *(const char *)&n ? &ns(internal_little2_encoding).enc : &ns(internal_big2_encoding).enc;
#endif
}
static
const ENCODING *NS(encodings)[] = {
&ns(latin1_encoding).enc,
&ns(ascii_encoding).enc,
&ns(utf8_encoding).enc,
&ns(big2_encoding).enc,
&ns(big2_encoding).enc,
&ns(little2_encoding).enc,
&ns(utf8_encoding).enc /* NO_ENC */
};
static
int NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr)
{
return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE, ptr, end, nextTokPtr);
}
static
int NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr)
{
return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE, ptr, end, nextTokPtr);
}
int NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, const char *name)
{
int i = getEncodingIndex(name);
if (i == UNKNOWN_ENC)
return 0;
INIT_ENC_INDEX(p) = (char)i;
p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
p->initEnc.updatePosition = initUpdatePosition;
p->encPtr = encPtr;
*encPtr = &(p->initEnc);
return 1;
}
static
const ENCODING *NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
{
#define ENCODING_MAX 128
char buf[ENCODING_MAX];
char *p = buf;
int i;
XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
if (ptr != end)
return 0;
*p = 0;
if (streqci(buf, "UTF-16") && enc->minBytesPerChar == 2)
return enc;
i = getEncodingIndex(buf);
if (i == UNKNOWN_ENC)
return 0;
return NS(encodings)[i];
}
int NS(XmlParseXmlDecl)(int isGeneralTextEntity,
const ENCODING *enc,
const char *ptr,
const char *end,
const char **badPtr,
const char **versionPtr,
const char **encodingName,
const ENCODING **encoding,
int *standalone)
{
return doParseXmlDecl(NS(findEncoding),
isGeneralTextEntity,
enc,
ptr,
end,
badPtr,
versionPtr,
encodingName,
encoding,
standalone);
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment