Commit c1aa3d82 authored by Jim Fulton's avatar Jim Fulton

major update with expat 1.1 and new pyexpat

parent 773b9f8b
*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
CFLAGS=-O2 -Ixmltok -Ixmlparse
CC=gcc
# 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.
FILEMAP_OBJ=xmlwf/unixfilemap.o
#FILEMAP_OBJ=xmlwf/readfilemap.o
OBJS=xmltok/xmltok.o \
xmltok/xmlrole.o \
xmlwf/xmlwf.o \
xmlwf/xmlfile.o \
xmlwf/codepage.o \
xmlparse/xmlparse.o \
xmlparse/hashtable.o \
$(FILEMAP_OBJ)
EXE=
all: xmlwf/xmlwf$(EXE)
libexpat.a: $(OBJS)
ar cr libexpat.a $(OBJS)
xmlwf/xmlwf$(EXE): $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS)
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<TITLE>expat</TITLE>
<BODY>
<H1>expat - XML Parser Toolkit</H1>
<H3>Version 19980405</H3>
<P>
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
not use expat except in compliance with this license. Please contact
me if you wish to negotiate an alternative license.</P><P>
Expat is an <A HREF="http://www.w3.org/TR/1998/REC-xml-19980210">XML
1.0</A> parser written in C. It aims to be fully conforming. It is
currently not a validating XML processor.
Expat can be downloaded from <A href =
"ftp://ftp.jclark.com/pub/xml/expat.zip">ftp://ftp.jclark.com/pub/xml/expat.zip</A>.
This is a beta-test version.</P>
<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
<H3>Version 1.1</H3>
<P>Copyright (c) 1998, 1999 James Clark. Expat is subject to the <A
HREF="http://www.mozilla.org/NPL/NPL-1_1Final.html">Mozilla Public
License Version 1.1</A>. Alternatively you may use expat under the <A
href="http://www.gnu.org/copyleft/gpl.html">GNU General Public
License</A> instead. Please contact me if you wish to negotiate an
alternative license.</P>
<P>Expat is an <A
HREF="http://www.w3.org/TR/1998/REC-xml-19980210">XML 1.0</A> parser
written in C. It aims to be fully conforming. It is currently not a
validating XML processor. The current production version of 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>
<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
interface is documented in <SAMP>xmlparse/xmlparse.h</SAMP>.</P>
<P>
The directory <SAMP>xmlwf</SAMP> contains the <SAMP>xmlwf</SAMP>
interface is documented in <SAMP>xmlparse/xmlparse.h</SAMP>. The
directory <SAMP>sample</SAMP> contains a simple example program using
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
arguments to <SAMP>xmlwf</SAMP> are one or more files which are each
to be checked for well-formedness. An option <SAMP>-d
......@@ -33,10 +45,29 @@ file the corresponding <A
href="http://www.jclark.com/xml/canonxml.html">canonical XML</A> will
be written to <SAMP>dir/<VAR>f</VAR></SAMP>, where
<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>
<ADDRESS>
<A HREF="mailto:jjc@jclark.com">James Clark</A>
</ADDRESS>
</BODY>
</HTML>
/*
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
compliance with the License. You may obtain a copy of the License at
Version 1.1 (the "License"); you may not use this file except in
csompliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS"
......@@ -12,21 +12,45 @@ under the License.
The Original Code is expat.
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.
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"
#ifdef XML_UNICODE_WCHAR_T
#ifndef XML_UNICODE
#define XML_UNICODE
#endif
#endif
#include "hashtable.h"
#include <stdlib.h>
#include <string.h>
#define INIT_SIZE 64
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;
while (*s)
......@@ -34,7 +58,7 @@ unsigned long hash(const char *s)
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;
if (table->size == 0) {
......@@ -52,7 +76,7 @@ NAMED *lookup(HASH_TABLE *table, const char *name, size_t createSize)
for (i = h & (table->size - 1);
table->v[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];
}
if (!createSize)
......
/*
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
http://www.mozilla.org/MPL/
......@@ -12,17 +12,41 @@ under the License.
The Original Code is expat.
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.
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>
#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 {
const char *name;
KEY name;
} NAMED;
typedef struct {
......@@ -32,7 +56,7 @@ typedef struct {
size_t usedLim;
} 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 hashTableDestroy(HASH_TABLE *);
......
/*
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
http://www.mozilla.org/MPL/
......@@ -12,10 +12,20 @@ under the License.
The Original Code is expat.
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.
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,
......@@ -32,7 +42,7 @@ Contributor(s):
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
/* 0x30 */ 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,
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
......
/*
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
http://www.mozilla.org/MPL/
......@@ -12,12 +12,25 @@ under the License.
The Original Code is expat.
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.
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>
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
......
/*
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
http://www.mozilla.org/MPL/
......@@ -12,10 +12,20 @@ under the License.
The Original Code is expat.
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.
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 */
......@@ -33,7 +43,7 @@ Contributor(s):
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
/* 0x30 */ 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,
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
......
/*
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
http://www.mozilla.org/MPL/
......@@ -12,10 +12,20 @@ under the License.
The Original Code is expat.
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.
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,
......
/*
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
http://www.mozilla.org/MPL/
......@@ -12,10 +12,20 @@ under the License.
The Original Code is expat.
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.
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
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
http://www.mozilla.org/MPL/
......@@ -12,19 +12,50 @@ under the License.
The Original Code is expat.
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.
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
particular environments. */
#ifdef MOZILLA
#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 free(x) PR_Free(x)
#define int int32
......
/*
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
http://www.mozilla.org/MPL/
......@@ -12,10 +12,20 @@ under the License.
The Original Code is expat.
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.
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"
......@@ -149,6 +159,7 @@ int doctype0(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = doctype1;
return XML_ROLE_DOCTYPE_NAME;
}
......@@ -594,7 +605,7 @@ int notation4(PROLOG_STATE *state,
return XML_ROLE_NOTATION_SYSTEM_ID;
case XML_TOK_DECL_CLOSE:
state->handler = internalSubset;
return XML_ROLE_NONE;
return XML_ROLE_NOTATION_NO_SYSTEM_ID;
}
return syntaxError(state);
}
......@@ -610,6 +621,7 @@ int attlist0(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = attlist1;
return XML_ROLE_ATTLIST_ELEMENT_NAME;
}
......@@ -630,6 +642,7 @@ int attlist1(PROLOG_STATE *state,
state->handler = internalSubset;
return XML_ROLE_NONE;
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = attlist2;
return XML_ROLE_ATTRIBUTE_NAME;
}
......@@ -689,6 +702,7 @@ int attlist3(PROLOG_STATE *state,
return XML_ROLE_NONE;
case XML_TOK_NMTOKEN:
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = attlist4;
return XML_ROLE_ATTRIBUTE_ENUM_VALUE;
}
......@@ -836,6 +850,7 @@ int element0(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = element1;
return XML_ROLE_ELEMENT_NAME;
}
......@@ -893,6 +908,7 @@ int element2(PROLOG_STATE *state,
state->handler = element6;
return XML_ROLE_GROUP_OPEN;
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = element7;
return XML_ROLE_CONTENT_ELEMENT;
case XML_TOK_NAME_QUESTION:
......@@ -940,6 +956,7 @@ int element4(PROLOG_STATE *state,
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = element5;
return XML_ROLE_CONTENT_ELEMENT;
}
......@@ -980,6 +997,7 @@ int element6(PROLOG_STATE *state,
state->level += 1;
return XML_ROLE_GROUP_OPEN;
case XML_TOK_NAME:
case XML_TOK_PREFIXED_NAME:
state->handler = element7;
return XML_ROLE_CONTENT_ELEMENT;
case XML_TOK_NAME_QUESTION:
......
/*
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
http://www.mozilla.org/MPL/
......@@ -12,10 +12,20 @@ under the License.
The Original Code is expat.
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.
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
......@@ -44,6 +54,7 @@ enum {
XML_ROLE_ENTITY_NOTATION_NAME,
XML_ROLE_NOTATION_NAME,
XML_ROLE_NOTATION_SYSTEM_ID,
XML_ROLE_NOTATION_NO_SYSTEM_ID,
XML_ROLE_NOTATION_PUBLIC_ID,
XML_ROLE_ATTRIBUTE_NAME,
XML_ROLE_ATTRIBUTE_TYPE_CDATA,
......
/*
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
http://www.mozilla.org/MPL/
......@@ -12,10 +12,20 @@ under the License.
The Original Code is expat.
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.
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
......@@ -29,6 +39,9 @@ extern "C" {
#define XMLTOKAPI /* as nothing */
#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 */
#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;
......@@ -38,7 +51,7 @@ extern "C" {
#define XML_TOK_INVALID 0
/* 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_NO_ATTS 2
......@@ -47,7 +60,7 @@ extern "C" {
#define XML_TOK_END_TAG 5
#define XML_TOK_DATA_CHARS 6
#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_CHAR_REF 10 /* numeric character reference */
......@@ -85,25 +98,29 @@ extern "C" {
#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
#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_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_CONTENT_STATE 1
#define XML_CDATA_SECTION_STATE 2
#define XML_N_LITERAL_TYPES 2
#define XML_ATTRIBUTE_VALUE_LITERAL 0
#define XML_ENTITY_VALUE_LITERAL 1
#define XML_N_INTERNAL_ENCODINGS 1
#define XML_UTF8_ENCODING 0
#if 0
#define XML_UTF16_ENCODING 1
#define XML_UCS4_ENCODING 2
#endif
#define XML_MAX_BYTES_PER_CHAR 4
/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
#define XML_UTF8_ENCODE_MAX 4
/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
#define XML_UTF16_ENCODE_MAX 2
typedef struct position {
/* first line and first column are 0 not 1 */
......@@ -139,21 +156,26 @@ struct encoding {
int (*getAtts)(const ENCODING *enc, const char *ptr,
int attsMax, ATTRIBUTE *atts);
int (*charRefNumber)(const ENCODING *enc, const char *ptr);
int (*predefinedEntityName)(const ENCODING *, const char *, const char *);
void (*updatePosition)(const ENCODING *,
const char *ptr,
const char *end,
POSITION *);
int (*isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
const char **badPtr);
int (*encode)(const ENCODING *enc,
int charNum,
char *buf);
void (*convert[XML_N_INTERNAL_ENCODINGS])(const ENCODING *enc,
const char **fromP,
const char *fromLim,
char **toP,
const char *toLim);
void (*utf8Convert)(const ENCODING *enc,
const char **fromP,
const char *fromLim,
char **toP,
const char *toLim);
void (*utf16Convert)(const ENCODING *enc,
const char **fromP,
const char *fromLim,
unsigned short **toP,
const unsigned short *toLim);
int minBytesPerChar;
char isUtf8;
char isUtf16;
};
/*
......@@ -186,6 +208,9 @@ literals, comments and processing instructions.
#define XmlContentTok(enc, 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
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) \
(((enc)->charRefNumber)(enc, ptr))
#define XmlPredefinedEntityName(enc, ptr, end) \
(((enc)->predefinedEntityName)(enc, ptr, end))
#define XmlUpdatePosition(enc, ptr, end, pos) \
(((enc)->updatePosition)(enc, ptr, end, pos))
#define XmlIsPublicId(enc, ptr, end, badPtr) \
(((enc)->isPublicId)(enc, ptr, end, badPtr))
#define XmlEncode(enc, ch, buf) \
(((enc)->encode)(enc, ch, buf))
#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
(((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
#define XmlConvert(enc, targetEnc, fromP, fromLim, toP, toLim) \
(((enc)->convert[targetEnc])(enc, fromP, fromLim, toP, toLim))
#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
(((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
typedef struct {
ENCODING initEnc;
......@@ -243,8 +271,35 @@ int XMLTOKAPI XmlParseXmlDecl(int isGeneralTextEntity,
int *standalonePtr);
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
}
#endif
......
/*
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
http://www.mozilla.org/MPL/
......@@ -12,10 +12,20 @@ under the License.
The Original Code is expat.
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.
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 {
......@@ -42,6 +52,7 @@ enum {
BT_LSQB,
BT_S,
BT_NMSTRT,
BT_COLON,
BT_HEX,
BT_DIGIT,
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