mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-18 02:19:39 +00:00
Virgin import (trimmed) of eXpat version 1.95.5
This commit is contained in:
commit
5bb6a25f8f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/expat/dist/; revision=104349 svn path=/vendor/expat/1.95.5/; revision=104351; tag=vendor/expat/1.95.5
22
contrib/expat/COPYING
Normal file
22
contrib/expat/COPYING
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||||
|
and Clark Cooper
|
||||||
|
Copyright (c) 2001, 2002 Expat maintainers.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included
|
||||||
|
in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
99
contrib/expat/Changes
Normal file
99
contrib/expat/Changes
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
Release 1.95.5 Fri Sep 6 2002
|
||||||
|
- Added XML_UseForeignDTD() for improved SAX2 support.
|
||||||
|
- Added XML_GetFeatureList().
|
||||||
|
- Defined XML_Bool type and the values XML_TRUE and XML_FALSE.
|
||||||
|
- Use an incomplete struct instead of a void* for the parser
|
||||||
|
(may not retain).
|
||||||
|
- Fixed UTF-8 decoding bug that caused legal UTF-8 to be rejected.
|
||||||
|
- Finally fixed bug where default handler would report DTD
|
||||||
|
events that were already handled by another handler.
|
||||||
|
Initial patch contributed by Darryl Miller.
|
||||||
|
- Removed unnecessary DllMain() function that caused static
|
||||||
|
linking into a DLL to be difficult.
|
||||||
|
- Added VC++ projects for building static libraries.
|
||||||
|
- Reduced line-length for all source code and headers to be
|
||||||
|
no longer than 80 characters, to help with AS/400 support.
|
||||||
|
- Reduced memory copying during parsing (SF patch #600964).
|
||||||
|
- Fixed a variety of bugs: see SF issues 580793, 434664,
|
||||||
|
483514, 580503, 581069, 584041, 584183, 584832, 585537,
|
||||||
|
596555, 596678, 598352, 598944, 599715, 600479, 600971.
|
||||||
|
|
||||||
|
Release 1.95.4 Fri Jul 12 2002
|
||||||
|
- Added support for VMS, contributed by Craig Berry. See
|
||||||
|
vms/README.vms for more information.
|
||||||
|
- Added Mac OS (classic) support, with a makefile for MPW,
|
||||||
|
contributed by Thomas Wegner and Daryle Walker.
|
||||||
|
- Added Borland C++ Builder 5 / BCC 5.5 support, contributed
|
||||||
|
by Patrick McConnell (SF patch #538032).
|
||||||
|
- Fixed a variety of bugs: see SF issues 441449, 563184,
|
||||||
|
564342, 566334, 566901, 569461, 570263, 575168, 579196.
|
||||||
|
- Made skippedEntityHandler conform to SAX2 (see source comment)
|
||||||
|
- Re-implemented WFC: Entity Declared from XML 1.0 spec and
|
||||||
|
added a new error "entity declared in parameter entity":
|
||||||
|
see SF bug report 569461 and SF patch 578161
|
||||||
|
- Re-implemented section 5.1 from XML 1.0 spec:
|
||||||
|
see SF bug report 570263 and SF patch 578161
|
||||||
|
|
||||||
|
Release 1.95.3 Mon Jun 3 2002
|
||||||
|
- Added a project to the MSVC workspace to create a wchar_t
|
||||||
|
version of the library; the DLLs are named libexpatw.dll.
|
||||||
|
- Changed the name of the Windows DLLs from expat.dll to
|
||||||
|
libexpat.dll; this fixes SF bug #432456.
|
||||||
|
- Added the XML_ParserReset() API function.
|
||||||
|
- Fixed XML_SetReturnNSTriplet() to work for element names.
|
||||||
|
- Made the XML_UNICODE builds usable (thanks, Karl!).
|
||||||
|
- Allow xmlwf to read from standard input.
|
||||||
|
- Install a man page for xmlwf on Unix systems.
|
||||||
|
- Fixed many bugs; see SF bug reports 231864, 461380, 464837,
|
||||||
|
466885, 469226, 477667, 484419, 487840, 494749, 496505,
|
||||||
|
547350. Other bugs which we can't test as easily may also
|
||||||
|
have been fixed, especially in the area of build support.
|
||||||
|
|
||||||
|
Release 1.95.2 Fri Jul 27 2001
|
||||||
|
- More changes to make MSVC happy with the build; add a single
|
||||||
|
workspace to support both the library and xmlwf application.
|
||||||
|
- Added a Windows installer for Windows users; includes
|
||||||
|
xmlwf.exe.
|
||||||
|
- Added compile-time constants that can be used to determine the
|
||||||
|
Expat version
|
||||||
|
- Removed a lot of GNU-specific dependencies to aide portability
|
||||||
|
among the various Unix flavors.
|
||||||
|
- Fix the UTF-8 BOM bug.
|
||||||
|
- Cleaned up warning messages for several compilers.
|
||||||
|
- Added the -Wall, -Wstrict-prototypes options for GCC.
|
||||||
|
|
||||||
|
Release 1.95.1 Sun Oct 22 15:11:36 EDT 2000
|
||||||
|
- Changes to get expat to build under Microsoft compiler
|
||||||
|
- Removed all aborts and instead return an UNEXPECTED_STATE error.
|
||||||
|
- Fixed a bug where a stray '%' in an entity value would cause an
|
||||||
|
abort.
|
||||||
|
- Defined XML_SetEndNamespaceDeclHandler. Thanks to Darryl Miles for
|
||||||
|
finding this oversight.
|
||||||
|
- Changed default patterns in lib/Makefile.in to fit non-GNU makes
|
||||||
|
Thanks to robin@unrated.net for reporting and providing an
|
||||||
|
account to test on.
|
||||||
|
- The reference had the wrong label for XML_SetStartNamespaceDecl.
|
||||||
|
Reported by an anonymous user.
|
||||||
|
|
||||||
|
Release 1.95.0 Fri Sep 29 2000
|
||||||
|
- XML_ParserCreate_MM
|
||||||
|
Allows you to set a memory management suite to replace the
|
||||||
|
standard malloc,realloc, and free.
|
||||||
|
- XML_SetReturnNSTriplet
|
||||||
|
If you turn this feature on when namespace processing is in
|
||||||
|
effect, then qualified, prefixed element and attribute names
|
||||||
|
are returned as "uri|name|prefix" where '|' is whatever
|
||||||
|
separator character is used in namespace processing.
|
||||||
|
- Merged in features from perl-expat
|
||||||
|
o XML_SetElementDeclHandler
|
||||||
|
o XML_SetAttlistDeclHandler
|
||||||
|
o XML_SetXmlDeclHandler
|
||||||
|
o XML_SetEntityDeclHandler
|
||||||
|
o StartDoctypeDeclHandler takes 3 additional parameters:
|
||||||
|
sysid, pubid, has_internal_subset
|
||||||
|
o Many paired handler setters (like XML_SetElementHandler)
|
||||||
|
now have corresponding individual handler setters
|
||||||
|
o XML_GetInputContext for getting the input context of
|
||||||
|
the current parse position.
|
||||||
|
- Added reference material
|
||||||
|
- Packaged into a distribution that builds a sharable library
|
16
contrib/expat/FREEBSD-upgrade
Normal file
16
contrib/expat/FREEBSD-upgrade
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
$FreeBSD$
|
||||||
|
|
||||||
|
eXpat from www.libexpat.org
|
||||||
|
|
||||||
|
Imported by:
|
||||||
|
|
||||||
|
tar zxvf expat-1.95.5.tar.gz
|
||||||
|
cd expat-1.95.5
|
||||||
|
rm -rf bcb5 win32 vms conftools doc/valid-xhtml10.png
|
||||||
|
vi FREEBSD-upgrade
|
||||||
|
cvs import -m "Virgin import (trimmed) of eXpat version 1.95.5" \
|
||||||
|
src/contrib/expat EXPAT v1_95_5
|
||||||
|
|
||||||
|
phk@FreeBSD.org
|
||||||
|
|
||||||
|
|
85
contrib/expat/MANIFEST
Normal file
85
contrib/expat/MANIFEST
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
Changes
|
||||||
|
COPYING
|
||||||
|
MANIFEST
|
||||||
|
Makefile.in
|
||||||
|
README
|
||||||
|
configure
|
||||||
|
configure.in
|
||||||
|
expat_config.h.in
|
||||||
|
bcb5/ExpatGroup.bpg
|
||||||
|
bcb5/ReadMe.txt
|
||||||
|
bcb5/elements.bpf
|
||||||
|
bcb5/elements.bpr
|
||||||
|
bcb5/elements.mak
|
||||||
|
bcb5/libexpat.bpf
|
||||||
|
bcb5/libexpat.bpr
|
||||||
|
bcb5/libexpat.mak
|
||||||
|
bcb5/libexpatw.bpf
|
||||||
|
bcb5/libexpatw.bpr
|
||||||
|
bcb5/libexpatw.mak
|
||||||
|
bcb5/makefile.mak
|
||||||
|
bcb5/outline.bpf
|
||||||
|
bcb5/outline.bpr
|
||||||
|
bcb5/outline.mak
|
||||||
|
bcb5/setup.bat
|
||||||
|
bcb5/xmlwf.bpf
|
||||||
|
bcb5/xmlwf.bpr
|
||||||
|
bcb5/xmlwf.mak
|
||||||
|
conftools/PrintPath
|
||||||
|
conftools/ac_c_bigendian_cross.m4
|
||||||
|
conftools/config.guess
|
||||||
|
conftools/config.sub
|
||||||
|
conftools/expat.m4
|
||||||
|
conftools/install-sh
|
||||||
|
conftools/libtool.m4
|
||||||
|
conftools/ltmain.sh
|
||||||
|
conftools/mkinstalldirs
|
||||||
|
doc/reference.html
|
||||||
|
doc/style.css
|
||||||
|
doc/valid-xhtml10.png
|
||||||
|
doc/xmlwf.1
|
||||||
|
doc/xmlwf.sgml
|
||||||
|
examples/elements.c
|
||||||
|
examples/outline.c
|
||||||
|
lib/ascii.h
|
||||||
|
lib/asciitab.h
|
||||||
|
lib/expat.h
|
||||||
|
lib/iasciitab.h
|
||||||
|
lib/internal.h
|
||||||
|
lib/latin1tab.h
|
||||||
|
lib/nametab.h
|
||||||
|
lib/utf8tab.h
|
||||||
|
lib/xmlparse.c
|
||||||
|
lib/xmlrole.c
|
||||||
|
lib/xmlrole.h
|
||||||
|
lib/xmltok.c
|
||||||
|
lib/xmltok.h
|
||||||
|
lib/xmltok_impl.c
|
||||||
|
lib/xmltok_impl.h
|
||||||
|
lib/xmltok_ns.c
|
||||||
|
lib/winconfig.h
|
||||||
|
tests/README.txt
|
||||||
|
tests/chardata.c
|
||||||
|
tests/chardata.h
|
||||||
|
tests/runtests.c
|
||||||
|
tests/xmltest.sh
|
||||||
|
vms/descrip.mms
|
||||||
|
vms/expat_config.h
|
||||||
|
vms/README.vms
|
||||||
|
win32/expat.iss
|
||||||
|
win32/MANIFEST.txt
|
||||||
|
xmlwf/codepage.c
|
||||||
|
xmlwf/codepage.h
|
||||||
|
xmlwf/ct.c
|
||||||
|
xmlwf/filemap.h
|
||||||
|
xmlwf/readfilemap.c
|
||||||
|
xmlwf/unixfilemap.c
|
||||||
|
xmlwf/win32filemap.c
|
||||||
|
xmlwf/xmlfile.c
|
||||||
|
xmlwf/xmlfile.h
|
||||||
|
xmlwf/xmlmime.c
|
||||||
|
xmlwf/xmlmime.h
|
||||||
|
xmlwf/xmltchar.h
|
||||||
|
xmlwf/xmlurl.h
|
||||||
|
xmlwf/xmlwf.c
|
||||||
|
xmlwf/xmlwin32url.cxx
|
171
contrib/expat/Makefile.in
Normal file
171
contrib/expat/Makefile.in
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
################################################################
|
||||||
|
# Process this file with top-level configure script to produce Makefile
|
||||||
|
#
|
||||||
|
# Copyright 2000 Clark Cooper
|
||||||
|
#
|
||||||
|
# This file is part of EXPAT.
|
||||||
|
#
|
||||||
|
# EXPAT is free software; you can redistribute it and/or modify it
|
||||||
|
# under the terms of the License (based on the MIT/X license) contained
|
||||||
|
# in the file COPYING that comes with this distribution.
|
||||||
|
#
|
||||||
|
# EXPAT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
# SOFTWARE OR THE USE OR OTHER DEALINGS IN EXPAT.
|
||||||
|
#
|
||||||
|
|
||||||
|
SHELL = @SHELL@
|
||||||
|
|
||||||
|
srcdir = @srcdir@
|
||||||
|
top_srcdir = @top_srcdir@
|
||||||
|
VPATH = @srcdir@
|
||||||
|
|
||||||
|
prefix = @prefix@
|
||||||
|
exec_prefix = @exec_prefix@
|
||||||
|
|
||||||
|
bindir = @bindir@
|
||||||
|
libdir = @libdir@
|
||||||
|
includedir = @includedir@
|
||||||
|
mandir = ${prefix}/man/man1
|
||||||
|
|
||||||
|
top_builddir = .
|
||||||
|
|
||||||
|
|
||||||
|
INSTALL = @INSTALL@
|
||||||
|
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||||
|
INSTALL_DATA = @INSTALL_DATA@
|
||||||
|
mkinstalldirs = $(SHELL) $(top_srcdir)/conftools/mkinstalldirs
|
||||||
|
|
||||||
|
MANFILE = $(srcdir)/doc/xmlwf.1
|
||||||
|
APIHEADER = $(srcdir)/lib/expat.h
|
||||||
|
LIBRARY = libexpat.la
|
||||||
|
|
||||||
|
|
||||||
|
default: buildlib xmlwf/xmlwf
|
||||||
|
|
||||||
|
buildlib: $(LIBRARY)
|
||||||
|
|
||||||
|
all: $(LIBRARY) xmlwf/xmlwf examples/elements examples/outline
|
||||||
|
|
||||||
|
clean:
|
||||||
|
cd lib && rm -f $(LIBRARY) *.o *.lo && rm -rf .libs _libs
|
||||||
|
cd xmlwf && rm -f xmlwf *.o *.lo && rm -rf .libs _libs
|
||||||
|
cd examples && rm -f elements outline *.o *.lo && rm -rf .libs _libs
|
||||||
|
cd tests && rm -rf .libs runtests runtests.o chardata.o
|
||||||
|
rm -rf .libs libexpat.la
|
||||||
|
find . -name core | xargs rm -f
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
rm -f expat_config.h config.status config.log config.cache libtool
|
||||||
|
rm -f Makefile
|
||||||
|
|
||||||
|
extraclean: distclean
|
||||||
|
rm -f expat_config.h.in configure
|
||||||
|
rm -f conftools/ltconfig conftools/ltmain.sh conftools/libtool.m4
|
||||||
|
|
||||||
|
check: tests/runtests
|
||||||
|
tests/runtests
|
||||||
|
|
||||||
|
install: xmlwf/xmlwf installlib
|
||||||
|
$(mkinstalldirs) $(bindir) $(mandir)
|
||||||
|
$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) xmlwf/xmlwf $(bindir)/xmlwf
|
||||||
|
$(INSTALL_DATA) $(MANFILE) $(mandir)
|
||||||
|
|
||||||
|
installlib: $(LIBRARY) $(APIHEADER)
|
||||||
|
$(mkinstalldirs) $(libdir) $(includedir)
|
||||||
|
$(LIBTOOL) --mode=install $(INSTALL) $(LIBRARY) $(libdir)/$(LIBRARY)
|
||||||
|
$(INSTALL_DATA) $(APIHEADER) $(includedir)
|
||||||
|
|
||||||
|
uninstall: uninstalllib
|
||||||
|
$(LIBTOOL) --mode=uninstall rm -f $(bindir)/xmlwf
|
||||||
|
rm -f $(mandir)/xmlwf.1
|
||||||
|
|
||||||
|
uninstalllib:
|
||||||
|
$(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(LIBRARY)
|
||||||
|
rm -f $(includedir)/$(APIHEADER)
|
||||||
|
|
||||||
|
# for VPATH builds (invoked by configure)
|
||||||
|
mkdir-init:
|
||||||
|
@for d in lib xmlwf examples tests ; do \
|
||||||
|
(mkdir $$d 2> /dev/null || test 1) ; \
|
||||||
|
done
|
||||||
|
|
||||||
|
CC = @CC@
|
||||||
|
LIBTOOL = @LIBTOOL@
|
||||||
|
|
||||||
|
INCLUDES = -I$(srcdir)/lib -I.
|
||||||
|
LDFLAGS = @LDFLAGS@
|
||||||
|
CPPFLAGS = @CPPFLAGS@
|
||||||
|
CFLAGS = @CFLAGS@
|
||||||
|
VSNFLAG = -version-info @LIBCURRENT@:@LIBREVISION@:@LIBAGE@
|
||||||
|
|
||||||
|
### autoconf this?
|
||||||
|
LTFLAGS = --silent
|
||||||
|
|
||||||
|
COMPILE = $(CC) $(CFLAGS) $(DEFS) $(CPPFLAGS) $(INCLUDES)
|
||||||
|
LTCOMPILE = $(LIBTOOL) $(LTFLAGS) --mode=compile $(COMPILE)
|
||||||
|
LINK_LIB = $(LIBTOOL) $(LTFLAGS) --mode=link $(COMPILE) -no-undefined $(VSNFLAG) -rpath $(libdir) $(LDFLAGS) -o $@
|
||||||
|
LINK_EXE = $(LIBTOOL) $(LTFLAGS) --mode=link $(COMPILE) $(LDFLAGS) -o $@
|
||||||
|
|
||||||
|
LIB_OBJS = lib/xmlparse.lo lib/xmltok.lo lib/xmlrole.lo
|
||||||
|
$(LIBRARY): $(LIB_OBJS)
|
||||||
|
$(LINK_LIB) $(LIB_OBJS)
|
||||||
|
|
||||||
|
lib/xmlparse.lo: lib/xmlparse.c lib/expat.h lib/xmlrole.h lib/xmltok.h \
|
||||||
|
$(top_builddir)/expat_config.h lib/internal.h
|
||||||
|
|
||||||
|
lib/xmlrole.lo: lib/xmlrole.c lib/ascii.h lib/xmlrole.h \
|
||||||
|
$(top_builddir)/expat_config.h lib/internal.h
|
||||||
|
|
||||||
|
lib/xmltok.lo: lib/xmltok.c lib/xmltok_impl.c lib/xmltok_ns.c \
|
||||||
|
lib/ascii.h lib/asciitab.h lib/iasciitab.h lib/latin1tab.h \
|
||||||
|
lib/nametab.h lib/utf8tab.h lib/xmltok.h lib/xmltok_impl.h \
|
||||||
|
$(top_builddir)/expat_config.h
|
||||||
|
|
||||||
|
|
||||||
|
XMLWF_OBJS = xmlwf/xmlwf.o xmlwf/xmlfile.o xmlwf/codepage.o xmlwf/@FILEMAP@.o
|
||||||
|
xmlwf/xmlwf.o: xmlwf/xmlwf.c
|
||||||
|
xmlwf/xmlfile.o: xmlwf/xmlfile.c
|
||||||
|
xmlwf/codepage.o: xmlwf/codepage.c
|
||||||
|
xmlwf/@FILEMAP@.o: xmlwf/@FILEMAP@.c
|
||||||
|
xmlwf/xmlwf: $(XMLWF_OBJS) $(LIBRARY)
|
||||||
|
$(LINK_EXE) $(XMLWF_OBJS) $(LIBRARY)
|
||||||
|
|
||||||
|
examples/elements.o: examples/elements.c
|
||||||
|
examples/elements: examples/elements.o $(LIBRARY)
|
||||||
|
$(LINK_EXE) $< $(LIBRARY)
|
||||||
|
|
||||||
|
examples/outline.o: examples/outline.c
|
||||||
|
examples/outline: examples/outline.o $(LIBRARY)
|
||||||
|
$(LINK_EXE) $< $(LIBRARY)
|
||||||
|
|
||||||
|
tests/chardata.o: tests/chardata.c tests/chardata.h
|
||||||
|
tests/runtests.o: tests/runtests.c tests/chardata.h
|
||||||
|
tests/runtests: tests/runtests.o tests/chardata.o $(LIBRARY)
|
||||||
|
$(LINK_EXE) $^ -lcheck
|
||||||
|
|
||||||
|
tests/xmlts.zip:
|
||||||
|
wget --output-document=tests/xmlts.zip \
|
||||||
|
http://www.w3.org/XML/Test/xmlts20020606.zip
|
||||||
|
|
||||||
|
tests/XML-Test-Suite: tests/xmlts.zip
|
||||||
|
cd tests && unzip -q xmlts.zip
|
||||||
|
|
||||||
|
run-xmltest: xmlwf/xmlwf tests/XML-Test-Suite
|
||||||
|
tests/xmltest.sh
|
||||||
|
|
||||||
|
.SUFFIXES: .c .lo .o
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(COMPILE) -o $@ -c $<
|
||||||
|
.c.lo:
|
||||||
|
$(LTCOMPILE) -o $@ -c $<
|
||||||
|
|
||||||
|
.PHONY: buildlib all \
|
||||||
|
clean distclean extraclean maintainer-clean \
|
||||||
|
dist distdir \
|
||||||
|
install uninstall
|
112
contrib/expat/README
Normal file
112
contrib/expat/README
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
|
||||||
|
Expat, Release 1.95.5
|
||||||
|
|
||||||
|
This is Expat, a C library for parsing XML, written by James Clark.
|
||||||
|
Expat is a stream-oriented XML parser. This means that you register
|
||||||
|
handlers with the parser before starting the parse. These handlers
|
||||||
|
are called when the parser discovers the associated structures in the
|
||||||
|
document being parsed. A start tag is an example of the kind of
|
||||||
|
structures for which you may register handlers.
|
||||||
|
|
||||||
|
Windows users should use the expat_win32bin package, which includes
|
||||||
|
both precompiled libraries and executalbes, and source code for
|
||||||
|
developers.
|
||||||
|
|
||||||
|
Expat is free software. You may copy, distribute, and modify it under
|
||||||
|
the terms of the License contained in the file COPYING distributed
|
||||||
|
with this package. This license is the same as the MIT/X Consortium
|
||||||
|
license.
|
||||||
|
|
||||||
|
Versions of Expat that have an odd minor version (the middle number in
|
||||||
|
the release above), are development releases and should be considered
|
||||||
|
as beta software. Releases with even minor version numbers are
|
||||||
|
intended to be production grade software.
|
||||||
|
|
||||||
|
If you are building Expat from a check-out from the CVS repository,
|
||||||
|
you need to run a script that generates the configure script using the
|
||||||
|
GNU autoconf and libtool tools. To do this, you need to have
|
||||||
|
autoconf 2.52 or newer and libtool 1.4 or newer. Run the script like
|
||||||
|
this:
|
||||||
|
|
||||||
|
./buildconf.sh
|
||||||
|
|
||||||
|
Once this has been done, follow the same instructions as for building
|
||||||
|
from a source distribution.
|
||||||
|
|
||||||
|
To build Expat from a source distribution, you first run the
|
||||||
|
configuration shell script in the top level distribution directory:
|
||||||
|
|
||||||
|
./configure
|
||||||
|
|
||||||
|
There are many options which you may provide to configure (which you
|
||||||
|
can discover by running configure with the --help option). But the
|
||||||
|
one of most interest is the one that sets the installation directory.
|
||||||
|
By default, the configure script will set things up to install
|
||||||
|
libexpat into /usr/local/lib, expat.h into /usr/local/include, and
|
||||||
|
xmlwf into /usr/local/bin. If, for example, you'd prefer to install
|
||||||
|
into /home/me/mystuff/lib, /home/me/mystuff/include, and
|
||||||
|
/home/me/mystuff/bin, you can tell configure about that with:
|
||||||
|
|
||||||
|
./configure --prefix=/home/me/mystuff
|
||||||
|
|
||||||
|
After running the configure script, the "make" command will build
|
||||||
|
things and "make install" will install things into their proper
|
||||||
|
location. Note that you need to have write permission into the
|
||||||
|
directories into which things will be installed.
|
||||||
|
|
||||||
|
If you are interested in building Expat to provide document
|
||||||
|
information in UTF-16 rather than the default UTF-8, following these
|
||||||
|
instructions:
|
||||||
|
|
||||||
|
1. For UTF-16 output as unsigned short (and version/error
|
||||||
|
strings as char), run:
|
||||||
|
|
||||||
|
./configure CPPFLAGS=-DXML_UNICODE
|
||||||
|
|
||||||
|
For UTF-16 output as wchar_t (incl. version/error strings),
|
||||||
|
run:
|
||||||
|
|
||||||
|
./configure CFLAGS="-g -O2 -fshort-wchar" \
|
||||||
|
CPPFLAGS=-DXML_UNICODE_WCHAR_T
|
||||||
|
|
||||||
|
2. Edit the MakeFile, changing:
|
||||||
|
|
||||||
|
LIBRARY = libexpat.la
|
||||||
|
|
||||||
|
to:
|
||||||
|
|
||||||
|
LIBRARY = libexpatw.la
|
||||||
|
|
||||||
|
(Note the additional "w" in the library name.)
|
||||||
|
|
||||||
|
3. Run "make buildlib" (which builds the library only).
|
||||||
|
|
||||||
|
4. Run "make installlib" (which installs the library only).
|
||||||
|
|
||||||
|
Note for Solaris users: The "ar" command is usually located in
|
||||||
|
"/usr/ccs/bin", which is not in the default PATH. You will need to
|
||||||
|
add this to your path for the "make" command, and probably also switch
|
||||||
|
to GNU make (the "make" found in /usr/ccs/bin does not seem to work
|
||||||
|
properly -- appearantly it does not understand .PHONY directives). If
|
||||||
|
you're using ksh or bash, use this command to build:
|
||||||
|
|
||||||
|
PATH=/usr/ccs/bin:$PATH make
|
||||||
|
|
||||||
|
When using Expat with a project using autoconf for configuration, you
|
||||||
|
can use the probing macro in conftools/expat.m4 to determine how to
|
||||||
|
include Expat. See the comments at the top of that file for more
|
||||||
|
information.
|
||||||
|
|
||||||
|
A reference manual is available in the file doc/reference.html in this
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
The homepage for this project is http://www.libexpat.org/. There
|
||||||
|
are links there to connect you to the bug reports page. If you need
|
||||||
|
to report a bug when you don't have access to a browser, you may also
|
||||||
|
send a bug report by email to expat-bugs@mail.libexpat.org.
|
||||||
|
|
||||||
|
Discussion related to the direction of future expat development takes
|
||||||
|
place on expat-discuss@mail.libexpat.org. Archives of this list and
|
||||||
|
other Expat-related lists may be found at:
|
||||||
|
|
||||||
|
http://mail.libexpat.org/mailman-21/listinfo/
|
10094
contrib/expat/configure
vendored
Executable file
10094
contrib/expat/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
124
contrib/expat/configure.in
Normal file
124
contrib/expat/configure.in
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
dnl configuration script for expat
|
||||||
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
|
dnl
|
||||||
|
dnl Copyright 2000 Clark Cooper
|
||||||
|
dnl
|
||||||
|
dnl This file is part of EXPAT.
|
||||||
|
dnl
|
||||||
|
dnl EXPAT is free software; you can redistribute it and/or modify it
|
||||||
|
dnl under the terms of the License (based on the MIT/X license) contained
|
||||||
|
dnl in the file COPYING that comes with this distribution.
|
||||||
|
dnl
|
||||||
|
|
||||||
|
dnl Ensure that Expat is configured with autoconf 2.52 or newer
|
||||||
|
AC_PREREQ(2.52)
|
||||||
|
|
||||||
|
dnl Get the version number of Expat, using m4's esyscmd() command to run
|
||||||
|
dnl the command at m4-generation time. This allows us to create an m4
|
||||||
|
dnl symbol holding the correct version number. AC_INIT() requires the
|
||||||
|
dnl version number at m4-time, rather than when ./configure is run, so
|
||||||
|
dnl all this must happen as part of m4, not as part of the shell code
|
||||||
|
dnl contained in ./configure.
|
||||||
|
dnl
|
||||||
|
dnl NOTE: esyscmd() is a GNU M4 extension. Thus, we wrap it in an appropriate
|
||||||
|
dnl test. I believe this test will work, but I don't have a place with non-
|
||||||
|
dnl GNU M4 to test it right now.
|
||||||
|
define([expat_version], ifdef([__gnu__],
|
||||||
|
[esyscmd(conftools/get-version.sh lib/expat.h)],
|
||||||
|
[1.95.x]))
|
||||||
|
AC_INIT(expat, expat_version, expat-bugs@mail.libexpat.org)
|
||||||
|
undefine([expat_version])
|
||||||
|
|
||||||
|
AC_CONFIG_SRCDIR(Makefile.in)
|
||||||
|
AC_CONFIG_AUX_DIR(conftools)
|
||||||
|
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Increment LIBREVISION if source code has changed at all
|
||||||
|
dnl
|
||||||
|
dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0
|
||||||
|
dnl
|
||||||
|
dnl If the API changes compatibly (i.e. simply adding a new function
|
||||||
|
dnl without changing or removing earlier interfaces), then increment LIBAGE.
|
||||||
|
dnl
|
||||||
|
dnl If the API changes incompatibly set LIBAGE back to 0
|
||||||
|
dnl
|
||||||
|
|
||||||
|
LIBCURRENT=4
|
||||||
|
LIBREVISION=0
|
||||||
|
LIBAGE=4
|
||||||
|
|
||||||
|
AC_CONFIG_HEADER(expat_config.h)
|
||||||
|
|
||||||
|
sinclude(conftools/libtool.m4)
|
||||||
|
sinclude(conftools/ac_c_bigendian_cross.m4)
|
||||||
|
|
||||||
|
AC_LIBTOOL_WIN32_DLL
|
||||||
|
AC_PROG_LIBTOOL
|
||||||
|
|
||||||
|
AC_SUBST(LIBCURRENT)
|
||||||
|
AC_SUBST(LIBREVISION)
|
||||||
|
AC_SUBST(LIBAGE)
|
||||||
|
|
||||||
|
dnl Checks for programs.
|
||||||
|
AC_PROG_CC
|
||||||
|
AC_PROG_INSTALL
|
||||||
|
|
||||||
|
if test "$GCC" = yes ; then
|
||||||
|
dnl
|
||||||
|
dnl Be careful about adding the -fexceptions option; some versions of
|
||||||
|
dnl GCC don't support it and it causes extra warnings that are only
|
||||||
|
dnl distracting; avoid.
|
||||||
|
dnl
|
||||||
|
OLDCFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wstrict-prototypes"
|
||||||
|
CFLAGS="$OLDCFLAGS -fexceptions"
|
||||||
|
AC_MSG_CHECKING(whether gcc accepts -fexceptions)
|
||||||
|
AC_TRY_COMPILE(,(void)1,
|
||||||
|
AC_MSG_RESULT(yes),
|
||||||
|
AC_MSG_RESULT(no); CFLAGS="$OLDCFLAGS")
|
||||||
|
fi
|
||||||
|
|
||||||
|
dnl Checks for header files.
|
||||||
|
AC_HEADER_STDC
|
||||||
|
AC_CHECK_HEADERS(fcntl.h unistd.h)
|
||||||
|
|
||||||
|
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||||
|
|
||||||
|
dnl Note: Avoid using AC_C_BIGENDIAN because it does not
|
||||||
|
dnl work in a cross compile.
|
||||||
|
AC_C_BIGENDIAN_CROSS
|
||||||
|
|
||||||
|
AC_C_CONST
|
||||||
|
AC_TYPE_OFF_T
|
||||||
|
AC_TYPE_SIZE_T
|
||||||
|
|
||||||
|
dnl Checks for library functions.
|
||||||
|
|
||||||
|
AC_FUNC_MEMCMP
|
||||||
|
AC_FUNC_MMAP
|
||||||
|
|
||||||
|
if test "$ac_cv_func_mmap_fixed_mapped" = "yes"; then
|
||||||
|
FILEMAP=unixfilemap
|
||||||
|
else
|
||||||
|
FILEMAP=readfilemap
|
||||||
|
fi
|
||||||
|
AC_SUBST(FILEMAP)
|
||||||
|
|
||||||
|
AC_CHECK_FUNCS(memmove bcopy)
|
||||||
|
|
||||||
|
dnl some basic configuration
|
||||||
|
AC_DEFINE([XML_NS], 1,
|
||||||
|
[Define to make XML Namespaces functionality available.])
|
||||||
|
AC_DEFINE([XML_DTD], 1,
|
||||||
|
[Define to make parameter entity parsing functionality available.])
|
||||||
|
AC_DEFINE([XML_CONTEXT_BYTES], 1024,
|
||||||
|
[Define to specify how much context to retain around the current parse point.])
|
||||||
|
|
||||||
|
AC_CONFIG_FILES(Makefile)
|
||||||
|
AC_OUTPUT
|
||||||
|
|
||||||
|
abs_srcdir="`cd $srcdir && pwd`"
|
||||||
|
abs_builddir="`pwd`"
|
||||||
|
if test "$abs_srcdir" != "$abs_builddir"; then
|
||||||
|
make mkdir-init
|
||||||
|
fi
|
1770
contrib/expat/doc/reference.html
Normal file
1770
contrib/expat/doc/reference.html
Normal file
File diff suppressed because it is too large
Load Diff
51
contrib/expat/doc/style.css
Normal file
51
contrib/expat/doc/style.css
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
body {
|
||||||
|
background-color: white
|
||||||
|
}
|
||||||
|
|
||||||
|
.noborder {
|
||||||
|
border-width: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.eg {
|
||||||
|
padding-left: 1em;
|
||||||
|
padding-top: .5em;
|
||||||
|
padding-bottom: .5em;
|
||||||
|
border: solid thin;
|
||||||
|
margin: 1em 0;
|
||||||
|
background-color: tan;
|
||||||
|
margin-left: 2em;
|
||||||
|
margin-right: 10%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.handler {
|
||||||
|
width: 100%;
|
||||||
|
border-top-width: thin;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.handler p {
|
||||||
|
margin-left: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setter {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.signature {
|
||||||
|
color: navy;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fcndec {
|
||||||
|
width: 100%;
|
||||||
|
border-top-width: thin;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fcndef {
|
||||||
|
margin-left: 2em;
|
||||||
|
margin-bottom: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
dd {
|
||||||
|
margin-bottom: 2em;
|
||||||
|
}
|
203
contrib/expat/doc/xmlwf.1
Normal file
203
contrib/expat/doc/xmlwf.1
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
.\" This manpage has been automatically generated by docbook2man
|
||||||
|
.\" from a DocBook document. This tool can be found at:
|
||||||
|
.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/>
|
||||||
|
.\" Please send any bug reports, improvements, comments, patches,
|
||||||
|
.\" etc. to Steve Cheng <steve@ggi-project.org>.
|
||||||
|
.TH "XMLWF" "1" "22 April 2002" "" ""
|
||||||
|
.SH NAME
|
||||||
|
xmlwf \- Determines if an XML document is well-formed
|
||||||
|
.SH SYNOPSIS
|
||||||
|
|
||||||
|
\fBxmlwf\fR [ \fB-s\fR] [ \fB-n\fR] [ \fB-p\fR] [ \fB-x\fR] [ \fB-e \fIencoding\fB\fR] [ \fB-w\fR] [ \fB-d \fIoutput-dir\fB\fR] [ \fB-c\fR] [ \fB-m\fR] [ \fB-r\fR] [ \fB-t\fR] [ \fB-v\fR] [ \fBfile ...\fR]
|
||||||
|
|
||||||
|
.SH "DESCRIPTION"
|
||||||
|
.PP
|
||||||
|
\fBxmlwf\fR uses the Expat library to determine
|
||||||
|
if an XML document is well-formed. It is non-validating.
|
||||||
|
.PP
|
||||||
|
If you do not specify any files on the command-line,
|
||||||
|
and you have a recent version of xmlwf, the input
|
||||||
|
file will be read from stdin.
|
||||||
|
.SH "WELL-FORMED DOCUMENTS"
|
||||||
|
.PP
|
||||||
|
A well-formed document must adhere to the
|
||||||
|
following rules:
|
||||||
|
.TP 0.2i
|
||||||
|
\(bu
|
||||||
|
The file begins with an XML declaration. For instance,
|
||||||
|
<?xml version="1.0" standalone="yes"?>.
|
||||||
|
\fBNOTE:\fR xmlwf does not currently
|
||||||
|
check for a valid XML declaration.
|
||||||
|
.TP 0.2i
|
||||||
|
\(bu
|
||||||
|
Every start tag is either empty (<tag/>)
|
||||||
|
or has a corresponding end tag.
|
||||||
|
.TP 0.2i
|
||||||
|
\(bu
|
||||||
|
There is exactly one root element. This element must contain
|
||||||
|
all other elements in the document. Only comments, white
|
||||||
|
space, and processing instructions may come after the close
|
||||||
|
of the root element.
|
||||||
|
.TP 0.2i
|
||||||
|
\(bu
|
||||||
|
All elements nest properly.
|
||||||
|
.TP 0.2i
|
||||||
|
\(bu
|
||||||
|
All attribute values are enclosed in quotes (either single
|
||||||
|
or double).
|
||||||
|
.PP
|
||||||
|
If the document has a DTD, and it strictly complies with that
|
||||||
|
DTD, then the document is also considered \fBvalid\fR.
|
||||||
|
xmlwf is a non-validating parser -- it does not check the DTD.
|
||||||
|
However, it does support external entities (see the -x option).
|
||||||
|
.SH "OPTIONS"
|
||||||
|
.PP
|
||||||
|
When an option includes an argument, you may specify the argument either
|
||||||
|
separate ("d output") or mashed ("-doutput"). xmlwf supports both.
|
||||||
|
.TP
|
||||||
|
\fB-c\fR
|
||||||
|
If the input file is well-formed and xmlwf doesn't
|
||||||
|
encounter any errors, the input file is simply copied to
|
||||||
|
the output directory unchanged.
|
||||||
|
This implies no namespaces (turns off -n) and
|
||||||
|
requires -d to specify an output file.
|
||||||
|
.TP
|
||||||
|
\fB-d output-dir\fR
|
||||||
|
Specifies a directory to contain transformed
|
||||||
|
representations of the input files.
|
||||||
|
By default, -d outputs a canonical representation
|
||||||
|
(described below).
|
||||||
|
You can select different output formats using -c and -m.
|
||||||
|
|
||||||
|
The output filenames will
|
||||||
|
be exactly the same as the input filenames or "STDIN" if the input is
|
||||||
|
coming from STDIN. Therefore, you must be careful that the
|
||||||
|
output file does not go into the same directory as the input
|
||||||
|
file. Otherwise, xmlwf will delete the input file before
|
||||||
|
it generates the output file (just like running
|
||||||
|
cat < file > file in most shells).
|
||||||
|
|
||||||
|
Two structurally equivalent XML documents have a byte-for-byte
|
||||||
|
identical canonical XML representation.
|
||||||
|
Note that ignorable white space is considered significant and
|
||||||
|
is treated equivalently to data.
|
||||||
|
More on canonical XML can be found at
|
||||||
|
http://www.jclark.com/xml/canonxml.html .
|
||||||
|
.TP
|
||||||
|
\fB-e encoding\fR
|
||||||
|
Specifies the character encoding for the document, overriding
|
||||||
|
any document encoding declaration. xmlwf
|
||||||
|
has four built-in encodings:
|
||||||
|
US-ASCII,
|
||||||
|
UTF-8,
|
||||||
|
UTF-16, and
|
||||||
|
ISO-8859-1.
|
||||||
|
Also see the -w option.
|
||||||
|
.TP
|
||||||
|
\fB-m\fR
|
||||||
|
Outputs some strange sort of XML file that completely
|
||||||
|
describes the the input file, including character postitions.
|
||||||
|
Requires -d to specify an output file.
|
||||||
|
.TP
|
||||||
|
\fB-n\fR
|
||||||
|
Turns on namespace processing. (describe namespaces)
|
||||||
|
-c disables namespaces.
|
||||||
|
.TP
|
||||||
|
\fB-p\fR
|
||||||
|
Tells xmlwf to process external DTDs and parameter
|
||||||
|
entities.
|
||||||
|
|
||||||
|
Normally xmlwf never parses parameter entities.
|
||||||
|
-p tells it to always parse them.
|
||||||
|
-p implies -x.
|
||||||
|
.TP
|
||||||
|
\fB-r\fR
|
||||||
|
Normally xmlwf memory-maps the XML file before parsing.
|
||||||
|
-r turns off memory-mapping and uses normal file IO calls instead.
|
||||||
|
Of course, memory-mapping is automatically turned off
|
||||||
|
when reading from STDIN.
|
||||||
|
.TP
|
||||||
|
\fB-s\fR
|
||||||
|
Prints an error if the document is not standalone.
|
||||||
|
A document is standalone if it has no external subset and no
|
||||||
|
references to parameter entities.
|
||||||
|
.TP
|
||||||
|
\fB-t\fR
|
||||||
|
Turns on timings. This tells Expat to parse the entire file,
|
||||||
|
but not perform any processing.
|
||||||
|
This gives a fairly accurate idea of the raw speed of Expat itself
|
||||||
|
without client overhead.
|
||||||
|
-t turns off most of the output options (-d, -m -c, ...).
|
||||||
|
.TP
|
||||||
|
\fB-v\fR
|
||||||
|
Prints the version of the Expat library being used, and then exits.
|
||||||
|
.TP
|
||||||
|
\fB-w\fR
|
||||||
|
Enables Windows code pages.
|
||||||
|
Normally, xmlwf will throw an error if it runs across
|
||||||
|
an encoding that it is not equipped to handle itself. With
|
||||||
|
-w, xmlwf will try to use a Windows code page. See
|
||||||
|
also -e.
|
||||||
|
.TP
|
||||||
|
\fB-x\fR
|
||||||
|
Turns on parsing external entities.
|
||||||
|
|
||||||
|
Non-validating parsers are not required to resolve external
|
||||||
|
entities, or even expand entities at all.
|
||||||
|
Expat always expands internal entities (?),
|
||||||
|
but external entity parsing must be enabled explicitly.
|
||||||
|
|
||||||
|
External entities are simply entities that obtain their
|
||||||
|
data from outside the XML file currently being parsed.
|
||||||
|
|
||||||
|
This is an example of an internal entity:
|
||||||
|
|
||||||
|
.nf
|
||||||
|
<!ENTITY vers '1.0.2'>
|
||||||
|
.fi
|
||||||
|
|
||||||
|
And here are some examples of external entities:
|
||||||
|
|
||||||
|
.nf
|
||||||
|
<!ENTITY header SYSTEM "header-&vers;.xml"> (parsed)
|
||||||
|
<!ENTITY logo SYSTEM "logo.png" PNG> (unparsed)
|
||||||
|
.fi
|
||||||
|
.TP
|
||||||
|
\fB--\fR
|
||||||
|
For some reason, xmlwf specifically ignores "--"
|
||||||
|
anywhere it appears on the command line.
|
||||||
|
.PP
|
||||||
|
Older versions of xmlwf do not support reading from STDIN.
|
||||||
|
.SH "OUTPUT"
|
||||||
|
.PP
|
||||||
|
If an input file is not well-formed, xmlwf outputs
|
||||||
|
a single line describing the problem to STDOUT.
|
||||||
|
If a file is well formed, xmlwf outputs nothing.
|
||||||
|
Note that the result code is \fBnot\fR set.
|
||||||
|
.SH "BUGS"
|
||||||
|
.PP
|
||||||
|
According to the W3C standard, an XML file without a
|
||||||
|
declaration at the beginning is not considered well-formed.
|
||||||
|
However, xmlwf allows this to pass.
|
||||||
|
.PP
|
||||||
|
xmlwf returns a 0 - noerr result, even if the file is
|
||||||
|
not well-formed. There is no good way for a program to use
|
||||||
|
xmlwf to quickly check a file -- it must parse xmlwf's STDOUT.
|
||||||
|
.PP
|
||||||
|
The errors should go to STDERR, not stdout.
|
||||||
|
.PP
|
||||||
|
There should be a way to get -d to send its output to STDOUT
|
||||||
|
rather than forcing the user to send it to a file.
|
||||||
|
.PP
|
||||||
|
I have no idea why anyone would want to use the -d, -c
|
||||||
|
and -m options. If someone could explain it to me, I'd
|
||||||
|
like to add this information to this manpage.
|
||||||
|
.SH "ALTERNATIVES"
|
||||||
|
.PP
|
||||||
|
Here are some XML validators on the web:
|
||||||
|
|
||||||
|
.nf
|
||||||
|
http://www.hcrc.ed.ac.uk/~richard/xml-check.html
|
||||||
|
http://www.stg.brown.edu/service/xmlvalid/
|
||||||
|
http://www.scripting.com/frontier5/xml/code/xmlValidator.html
|
||||||
|
http://www.xml.com/pub/a/tools/ruwf/check.html
|
440
contrib/expat/doc/xmlwf.sgml
Normal file
440
contrib/expat/doc/xmlwf.sgml
Normal file
@ -0,0 +1,440 @@
|
|||||||
|
<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
|
||||||
|
|
||||||
|
<!-- Process this file with docbook-to-man to generate an nroff manual
|
||||||
|
page: `docbook-to-man manpage.sgml > manpage.1'. You may view
|
||||||
|
the manual page with: `docbook-to-man manpage.sgml | nroff -man |
|
||||||
|
less'. A typical entry in a Makefile or Makefile.am is:
|
||||||
|
|
||||||
|
manpage.1: manpage.sgml
|
||||||
|
docbook-to-man $< > $@
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Fill in your name for FIRSTNAME and SURNAME. -->
|
||||||
|
<!ENTITY dhfirstname "<firstname>Scott</firstname>">
|
||||||
|
<!ENTITY dhsurname "<surname>Bronson</surname>">
|
||||||
|
<!-- Please adjust the date whenever revising the manpage. -->
|
||||||
|
<!ENTITY dhdate "<date>December 5, 2001</date>">
|
||||||
|
<!-- SECTION should be 1-8, maybe w/ subsection other parameters are
|
||||||
|
allowed: see man(7), man(1). -->
|
||||||
|
<!ENTITY dhsection "<manvolnum>1</manvolnum>">
|
||||||
|
<!ENTITY dhemail "<email>bronson@rinspin.com</email>">
|
||||||
|
<!ENTITY dhusername "Scott Bronson">
|
||||||
|
<!ENTITY dhucpackage "<refentrytitle>XMLWF</refentrytitle>">
|
||||||
|
<!ENTITY dhpackage "xmlwf">
|
||||||
|
|
||||||
|
<!ENTITY debian "<productname>Debian GNU/Linux</productname>">
|
||||||
|
<!ENTITY gnu "<acronym>GNU</acronym>">
|
||||||
|
]>
|
||||||
|
|
||||||
|
<refentry>
|
||||||
|
<refentryinfo>
|
||||||
|
<address>
|
||||||
|
&dhemail;
|
||||||
|
</address>
|
||||||
|
<author>
|
||||||
|
&dhfirstname;
|
||||||
|
&dhsurname;
|
||||||
|
</author>
|
||||||
|
<copyright>
|
||||||
|
<year>2001</year>
|
||||||
|
<holder>&dhusername;</holder>
|
||||||
|
</copyright>
|
||||||
|
&dhdate;
|
||||||
|
</refentryinfo>
|
||||||
|
<refmeta>
|
||||||
|
&dhucpackage;
|
||||||
|
|
||||||
|
&dhsection;
|
||||||
|
</refmeta>
|
||||||
|
<refnamediv>
|
||||||
|
<refname>&dhpackage;</refname>
|
||||||
|
|
||||||
|
<refpurpose>Determines if an XML document is well-formed</refpurpose>
|
||||||
|
</refnamediv>
|
||||||
|
<refsynopsisdiv>
|
||||||
|
<cmdsynopsis>
|
||||||
|
<command>&dhpackage;</command>
|
||||||
|
<arg><option>-s</option></arg>
|
||||||
|
<arg><option>-n</option></arg>
|
||||||
|
<arg><option>-p</option></arg>
|
||||||
|
<arg><option>-x</option></arg>
|
||||||
|
|
||||||
|
<arg><option>-e <replaceable>encoding</replaceable></option></arg>
|
||||||
|
<arg><option>-w</option></arg>
|
||||||
|
|
||||||
|
<arg><option>-d <replaceable>output-dir</replaceable></option></arg>
|
||||||
|
<arg><option>-c</option></arg>
|
||||||
|
<arg><option>-m</option></arg>
|
||||||
|
|
||||||
|
<arg><option>-r</option></arg>
|
||||||
|
<arg><option>-t</option></arg>
|
||||||
|
|
||||||
|
<arg><option>-v</option></arg>
|
||||||
|
|
||||||
|
<arg>file ...</arg>
|
||||||
|
</cmdsynopsis>
|
||||||
|
</refsynopsisdiv>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>DESCRIPTION</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<command>&dhpackage;</command> uses the Expat library to determine
|
||||||
|
if an XML document is well-formed. It is non-validating.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
If you do not specify any files on the command-line,
|
||||||
|
and you have a recent version of &dhpackage;, the input
|
||||||
|
file will be read from stdin.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>WELL-FORMED DOCUMENTS</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
A well-formed document must adhere to the
|
||||||
|
following rules:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem><para>
|
||||||
|
The file begins with an XML declaration. For instance,
|
||||||
|
<literal><?xml version="1.0" standalone="yes"?></literal>.
|
||||||
|
<emphasis>NOTE:</emphasis> &dhpackage; does not currently
|
||||||
|
check for a valid XML declaration.
|
||||||
|
</para></listitem>
|
||||||
|
<listitem><para>
|
||||||
|
Every start tag is either empty (<tag/>)
|
||||||
|
or has a corresponding end tag.
|
||||||
|
</para></listitem>
|
||||||
|
<listitem><para>
|
||||||
|
There is exactly one root element. This element must contain
|
||||||
|
all other elements in the document. Only comments, white
|
||||||
|
space, and processing instructions may come after the close
|
||||||
|
of the root element.
|
||||||
|
</para></listitem>
|
||||||
|
<listitem><para>
|
||||||
|
All elements nest properly.
|
||||||
|
</para></listitem>
|
||||||
|
<listitem><para>
|
||||||
|
All attribute values are enclosed in quotes (either single
|
||||||
|
or double).
|
||||||
|
</para></listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
If the document has a DTD, and it strictly complies with that
|
||||||
|
DTD, then the document is also considered <emphasis>valid</emphasis>.
|
||||||
|
&dhpackage; is a non-validating parser -- it does not check the DTD.
|
||||||
|
However, it does support external entities (see the -x option).
|
||||||
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>OPTIONS</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
When an option includes an argument, you may specify the argument either
|
||||||
|
separate ("d output") or mashed ("-doutput"). &dhpackage; supports both.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-c</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
If the input file is well-formed and &dhpackage; doesn't
|
||||||
|
encounter any errors, the input file is simply copied to
|
||||||
|
the output directory unchanged.
|
||||||
|
This implies no namespaces (turns off -n) and
|
||||||
|
requires -d to specify an output file.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-d output-dir</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Specifies a directory to contain transformed
|
||||||
|
representations of the input files.
|
||||||
|
By default, -d outputs a canonical representation
|
||||||
|
(described below).
|
||||||
|
You can select different output formats using -c and -m.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
The output filenames will
|
||||||
|
be exactly the same as the input filenames or "STDIN" if the input is
|
||||||
|
coming from STDIN. Therefore, you must be careful that the
|
||||||
|
output file does not go into the same directory as the input
|
||||||
|
file. Otherwise, &dhpackage; will delete the input file before
|
||||||
|
it generates the output file (just like running
|
||||||
|
<literal>cat < file > file</literal> in most shells).
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Two structurally equivalent XML documents have a byte-for-byte
|
||||||
|
identical canonical XML representation.
|
||||||
|
Note that ignorable white space is considered significant and
|
||||||
|
is treated equivalently to data.
|
||||||
|
More on canonical XML can be found at
|
||||||
|
http://www.jclark.com/xml/canonxml.html .
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-e encoding</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Specifies the character encoding for the document, overriding
|
||||||
|
any document encoding declaration. &dhpackage;
|
||||||
|
has four built-in encodings:
|
||||||
|
<literal>US-ASCII</literal>,
|
||||||
|
<literal>UTF-8</literal>,
|
||||||
|
<literal>UTF-16</literal>, and
|
||||||
|
<literal>ISO-8859-1</literal>.
|
||||||
|
Also see the -w option.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-m</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Outputs some strange sort of XML file that completely
|
||||||
|
describes the the input file, including character postitions.
|
||||||
|
Requires -d to specify an output file.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-n</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Turns on namespace processing. (describe namespaces)
|
||||||
|
-c disables namespaces.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-p</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Tells xmlwf to process external DTDs and parameter
|
||||||
|
entities.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Normally &dhpackage; never parses parameter entities.
|
||||||
|
-p tells it to always parse them.
|
||||||
|
-p implies -x.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-r</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Normally &dhpackage; memory-maps the XML file before parsing.
|
||||||
|
-r turns off memory-mapping and uses normal file IO calls instead.
|
||||||
|
Of course, memory-mapping is automatically turned off
|
||||||
|
when reading from STDIN.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-s</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Prints an error if the document is not standalone.
|
||||||
|
A document is standalone if it has no external subset and no
|
||||||
|
references to parameter entities.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-t</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Turns on timings. This tells Expat to parse the entire file,
|
||||||
|
but not perform any processing.
|
||||||
|
This gives a fairly accurate idea of the raw speed of Expat itself
|
||||||
|
without client overhead.
|
||||||
|
-t turns off most of the output options (-d, -m -c, ...).
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-v</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Prints the version of the Expat library being used, and then exits.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-w</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Enables Windows code pages.
|
||||||
|
Normally, &dhpackage; will throw an error if it runs across
|
||||||
|
an encoding that it is not equipped to handle itself. With
|
||||||
|
-w, &dhpackage; will try to use a Windows code page. See
|
||||||
|
also -e.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-x</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Turns on parsing external entities.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Non-validating parsers are not required to resolve external
|
||||||
|
entities, or even expand entities at all.
|
||||||
|
Expat always expands internal entities (?),
|
||||||
|
but external entity parsing must be enabled explicitly.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
External entities are simply entities that obtain their
|
||||||
|
data from outside the XML file currently being parsed.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
This is an example of an internal entity:
|
||||||
|
<literallayout>
|
||||||
|
<!ENTITY vers '1.0.2'>
|
||||||
|
</literallayout>
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
And here are some examples of external entities:
|
||||||
|
|
||||||
|
<literallayout>
|
||||||
|
<!ENTITY header SYSTEM "header-&vers;.xml"> (parsed)
|
||||||
|
<!ENTITY logo SYSTEM "logo.png" PNG> (unparsed)
|
||||||
|
</literallayout>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
For some reason, &dhpackage; specifically ignores "--"
|
||||||
|
anywhere it appears on the command line.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Older versions of &dhpackage; do not support reading from STDIN.
|
||||||
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>OUTPUT</title>
|
||||||
|
<para>
|
||||||
|
If an input file is not well-formed, &dhpackage; outputs
|
||||||
|
a single line describing the problem to STDOUT.
|
||||||
|
If a file is well formed, &dhpackage; outputs nothing.
|
||||||
|
Note that the result code is <emphasis>not</emphasis> set.
|
||||||
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>BUGS</title>
|
||||||
|
<para>
|
||||||
|
According to the W3C standard, an XML file without a
|
||||||
|
declaration at the beginning is not considered well-formed.
|
||||||
|
However, &dhpackage; allows this to pass.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
&dhpackage; returns a 0 - noerr result, even if the file is
|
||||||
|
not well-formed. There is no good way for a program to use
|
||||||
|
xmlwf to quickly check a file -- it must parse xmlwf's STDOUT.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
The errors should go to STDERR, not stdout.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
There should be a way to get -d to send its output to STDOUT
|
||||||
|
rather than forcing the user to send it to a file.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
I have no idea why anyone would want to use the -d, -c
|
||||||
|
and -m options. If someone could explain it to me, I'd
|
||||||
|
like to add this information to this manpage.
|
||||||
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>ALTERNATIVES</title>
|
||||||
|
<para>
|
||||||
|
Here are some XML validators on the web:
|
||||||
|
|
||||||
|
<literallayout>
|
||||||
|
http://www.hcrc.ed.ac.uk/~richard/xml-check.html
|
||||||
|
http://www.stg.brown.edu/service/xmlvalid/
|
||||||
|
http://www.scripting.com/frontier5/xml/code/xmlValidator.html
|
||||||
|
http://www.xml.com/pub/a/tools/ruwf/check.html
|
||||||
|
(on a page with no less than 15 ads! Shame!)
|
||||||
|
</literallayout>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>SEE ALSO</title>
|
||||||
|
<para>
|
||||||
|
|
||||||
|
<literallayout>
|
||||||
|
The Expat home page: http://www.libexpat.org/
|
||||||
|
The W3 XML specification: http://www.w3.org/TR/REC-xml
|
||||||
|
</literallayout>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>AUTHOR</title>
|
||||||
|
<para>
|
||||||
|
This manual page was written by &dhusername; &dhemail; for
|
||||||
|
the &debian; system (but may be used by others). Permission is
|
||||||
|
granted to copy, distribute and/or modify this document under
|
||||||
|
the terms of the <acronym>GNU</acronym> Free Documentation
|
||||||
|
License, Version 1.1.
|
||||||
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
</refentry>
|
||||||
|
|
||||||
|
<!-- Keep this comment at the end of the file
|
||||||
|
Local variables:
|
||||||
|
mode: sgml
|
||||||
|
sgml-omittag:t
|
||||||
|
sgml-shorttag:t
|
||||||
|
sgml-minimize-attributes:nil
|
||||||
|
sgml-always-quote-attributes:t
|
||||||
|
sgml-indent-step:2
|
||||||
|
sgml-indent-data:t
|
||||||
|
sgml-parent-document:nil
|
||||||
|
sgml-default-dtd-file:nil
|
||||||
|
sgml-exposed-tags:nil
|
||||||
|
sgml-local-catalogs:nil
|
||||||
|
sgml-local-ecat-files:nil
|
||||||
|
End:
|
||||||
|
-->
|
50
contrib/expat/examples/elements.c
Normal file
50
contrib/expat/examples/elements.c
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/* This is simple demonstration of how to use expat. This program
|
||||||
|
reads an XML document from standard input and writes a line with
|
||||||
|
the name of each element to standard output indenting child
|
||||||
|
elements by one tab stop more than their parent element.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "expat.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
startElement(void *userData, const char *name, const char **atts)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int *depthPtr = userData;
|
||||||
|
for (i = 0; i < *depthPtr; i++)
|
||||||
|
putchar('\t');
|
||||||
|
puts(name);
|
||||||
|
*depthPtr += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
endElement(void *userData, const char *name)
|
||||||
|
{
|
||||||
|
int *depthPtr = userData;
|
||||||
|
*depthPtr -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char buf[BUFSIZ];
|
||||||
|
XML_Parser parser = XML_ParserCreate(NULL);
|
||||||
|
int done;
|
||||||
|
int depth = 0;
|
||||||
|
XML_SetUserData(parser, &depth);
|
||||||
|
XML_SetElementHandler(parser, startElement, endElement);
|
||||||
|
do {
|
||||||
|
size_t len = fread(buf, 1, sizeof(buf), stdin);
|
||||||
|
done = len < sizeof(buf);
|
||||||
|
if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s at line %d\n",
|
||||||
|
XML_ErrorString(XML_GetErrorCode(parser)),
|
||||||
|
XML_GetCurrentLineNumber(parser));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
} while (!done);
|
||||||
|
XML_ParserFree(parser);
|
||||||
|
return 0;
|
||||||
|
}
|
90
contrib/expat/examples/outline.c
Normal file
90
contrib/expat/examples/outline.c
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/*****************************************************************
|
||||||
|
* outline.c
|
||||||
|
*
|
||||||
|
* Copyright 1999, Clark Cooper
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the license contained in the
|
||||||
|
* COPYING file that comes with the expat distribution.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* Read an XML document from standard input and print an element
|
||||||
|
* outline on standard output.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <expat.h>
|
||||||
|
|
||||||
|
#define BUFFSIZE 8192
|
||||||
|
|
||||||
|
char Buff[BUFFSIZE];
|
||||||
|
|
||||||
|
int Depth;
|
||||||
|
|
||||||
|
static void
|
||||||
|
start(void *data, const char *el, const char **attr)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < Depth; i++)
|
||||||
|
printf(" ");
|
||||||
|
|
||||||
|
printf("%s", el);
|
||||||
|
|
||||||
|
for (i = 0; attr[i]; i += 2) {
|
||||||
|
printf(" %s='%s'", attr[i], attr[i + 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
Depth++;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
end(void *data, const char *el)
|
||||||
|
{
|
||||||
|
Depth--;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
XML_Parser p = XML_ParserCreate(NULL);
|
||||||
|
if (! p) {
|
||||||
|
fprintf(stderr, "Couldn't allocate memory for parser\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
XML_SetElementHandler(p, start, end);
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
int done;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = fread(Buff, 1, BUFFSIZE, stdin);
|
||||||
|
if (ferror(stdin)) {
|
||||||
|
fprintf(stderr, "Read error\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
done = feof(stdin);
|
||||||
|
|
||||||
|
if (XML_Parse(p, Buff, len, done) == XML_STATUS_ERROR) {
|
||||||
|
fprintf(stderr, "Parse error at line %d:\n%s\n",
|
||||||
|
XML_GetCurrentLineNumber(p),
|
||||||
|
XML_ErrorString(XML_GetErrorCode(p)));
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (done)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
89
contrib/expat/expat_config.h.in
Normal file
89
contrib/expat/expat_config.h.in
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/* expat_config.h.in. Generated from configure.in by autoheader. */
|
||||||
|
|
||||||
|
/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
|
||||||
|
#undef BYTEORDER
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `bcopy' function. */
|
||||||
|
#undef HAVE_BCOPY
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
|
#undef HAVE_DLFCN_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||||
|
#undef HAVE_FCNTL_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `getpagesize' function. */
|
||||||
|
#undef HAVE_GETPAGESIZE
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
#undef HAVE_INTTYPES_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `memmove' function. */
|
||||||
|
#undef HAVE_MEMMOVE
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
|
#undef HAVE_MEMORY_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have a working `mmap' system call. */
|
||||||
|
#undef HAVE_MMAP
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
#undef HAVE_STDINT_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
#undef HAVE_STDLIB_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
#undef HAVE_STRINGS_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
#undef HAVE_STRING_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
#undef HAVE_SYS_STAT_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
#undef HAVE_SYS_TYPES_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
#undef HAVE_UNISTD_H
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#undef PACKAGE_BUGREPORT
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#undef PACKAGE_NAME
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#undef PACKAGE_STRING
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#undef PACKAGE_TARNAME
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#undef PACKAGE_VERSION
|
||||||
|
|
||||||
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
|
#undef STDC_HEADERS
|
||||||
|
|
||||||
|
/* whether byteorder is bigendian */
|
||||||
|
#undef WORDS_BIGENDIAN
|
||||||
|
|
||||||
|
/* Define to specify how much context to retain around the current parse
|
||||||
|
point. */
|
||||||
|
#undef XML_CONTEXT_BYTES
|
||||||
|
|
||||||
|
/* Define to make parameter entity parsing functionality available. */
|
||||||
|
#undef XML_DTD
|
||||||
|
|
||||||
|
/* Define to make XML Namespaces functionality available. */
|
||||||
|
#undef XML_NS
|
||||||
|
|
||||||
|
/* Define to empty if `const' does not conform to ANSI C. */
|
||||||
|
#undef const
|
||||||
|
|
||||||
|
/* Define to `long' if <sys/types.h> does not define. */
|
||||||
|
#undef off_t
|
||||||
|
|
||||||
|
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||||
|
#undef size_t
|
85
contrib/expat/lib/ascii.h
Normal file
85
contrib/expat/lib/ascii.h
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define ASCII_A 0x41
|
||||||
|
#define ASCII_B 0x42
|
||||||
|
#define ASCII_C 0x43
|
||||||
|
#define ASCII_D 0x44
|
||||||
|
#define ASCII_E 0x45
|
||||||
|
#define ASCII_F 0x46
|
||||||
|
#define ASCII_G 0x47
|
||||||
|
#define ASCII_H 0x48
|
||||||
|
#define ASCII_I 0x49
|
||||||
|
#define ASCII_J 0x4A
|
||||||
|
#define ASCII_K 0x4B
|
||||||
|
#define ASCII_L 0x4C
|
||||||
|
#define ASCII_M 0x4D
|
||||||
|
#define ASCII_N 0x4E
|
||||||
|
#define ASCII_O 0x4F
|
||||||
|
#define ASCII_P 0x50
|
||||||
|
#define ASCII_Q 0x51
|
||||||
|
#define ASCII_R 0x52
|
||||||
|
#define ASCII_S 0x53
|
||||||
|
#define ASCII_T 0x54
|
||||||
|
#define ASCII_U 0x55
|
||||||
|
#define ASCII_V 0x56
|
||||||
|
#define ASCII_W 0x57
|
||||||
|
#define ASCII_X 0x58
|
||||||
|
#define ASCII_Y 0x59
|
||||||
|
#define ASCII_Z 0x5A
|
||||||
|
|
||||||
|
#define ASCII_a 0x61
|
||||||
|
#define ASCII_b 0x62
|
||||||
|
#define ASCII_c 0x63
|
||||||
|
#define ASCII_d 0x64
|
||||||
|
#define ASCII_e 0x65
|
||||||
|
#define ASCII_f 0x66
|
||||||
|
#define ASCII_g 0x67
|
||||||
|
#define ASCII_h 0x68
|
||||||
|
#define ASCII_i 0x69
|
||||||
|
#define ASCII_j 0x6A
|
||||||
|
#define ASCII_k 0x6B
|
||||||
|
#define ASCII_l 0x6C
|
||||||
|
#define ASCII_m 0x6D
|
||||||
|
#define ASCII_n 0x6E
|
||||||
|
#define ASCII_o 0x6F
|
||||||
|
#define ASCII_p 0x70
|
||||||
|
#define ASCII_q 0x71
|
||||||
|
#define ASCII_r 0x72
|
||||||
|
#define ASCII_s 0x73
|
||||||
|
#define ASCII_t 0x74
|
||||||
|
#define ASCII_u 0x75
|
||||||
|
#define ASCII_v 0x76
|
||||||
|
#define ASCII_w 0x77
|
||||||
|
#define ASCII_x 0x78
|
||||||
|
#define ASCII_y 0x79
|
||||||
|
#define ASCII_z 0x7A
|
||||||
|
|
||||||
|
#define ASCII_0 0x30
|
||||||
|
#define ASCII_1 0x31
|
||||||
|
#define ASCII_2 0x32
|
||||||
|
#define ASCII_3 0x33
|
||||||
|
#define ASCII_4 0x34
|
||||||
|
#define ASCII_5 0x35
|
||||||
|
#define ASCII_6 0x36
|
||||||
|
#define ASCII_7 0x37
|
||||||
|
#define ASCII_8 0x38
|
||||||
|
#define ASCII_9 0x39
|
||||||
|
|
||||||
|
#define ASCII_TAB 0x09
|
||||||
|
#define ASCII_SPACE 0x20
|
||||||
|
#define ASCII_EXCL 0x21
|
||||||
|
#define ASCII_QUOT 0x22
|
||||||
|
#define ASCII_AMP 0x26
|
||||||
|
#define ASCII_APOS 0x27
|
||||||
|
#define ASCII_MINUS 0x2D
|
||||||
|
#define ASCII_PERIOD 0x2E
|
||||||
|
#define ASCII_COLON 0x3A
|
||||||
|
#define ASCII_SEMI 0x3B
|
||||||
|
#define ASCII_LT 0x3C
|
||||||
|
#define ASCII_EQUALS 0x3D
|
||||||
|
#define ASCII_GT 0x3E
|
||||||
|
#define ASCII_LSQB 0x5B
|
||||||
|
#define ASCII_RSQB 0x5D
|
||||||
|
#define ASCII_UNDERSCORE 0x5F
|
36
contrib/expat/lib/asciitab.h
Normal file
36
contrib/expat/lib/asciitab.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||||
|
/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||||
|
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||||
|
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||||
|
/* 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_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,
|
||||||
|
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||||
|
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||||
|
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||||
|
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||||
|
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||||
|
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
909
contrib/expat/lib/expat.h
Normal file
909
contrib/expat/lib/expat.h
Normal file
@ -0,0 +1,909 @@
|
|||||||
|
/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XmlParse_INCLUDED
|
||||||
|
#define XmlParse_INCLUDED 1
|
||||||
|
|
||||||
|
#ifdef __VMS
|
||||||
|
/* 0 1 2 3 0 1 2 3
|
||||||
|
1234567890123456789012345678901 1234567890123456789012345678901 */
|
||||||
|
#define XML_SetProcessingInstructionHandler XML_SetProcessingInstrHandler
|
||||||
|
#define XML_SetUnparsedEntityDeclHandler XML_SetUnparsedEntDeclHandler
|
||||||
|
#define XML_SetStartNamespaceDeclHandler XML_SetStartNamespcDeclHandler
|
||||||
|
#define XML_SetExternalEntityRefHandlerArg XML_SetExternalEntRefHandlerArg
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifndef XMLPARSEAPI
|
||||||
|
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
|
||||||
|
#ifdef _STATIC
|
||||||
|
#define XMLPARSEAPI(type) type __cdecl
|
||||||
|
#else
|
||||||
|
#define XMLPARSEAPI(type) __declspec(dllimport) type __cdecl
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define XMLPARSEAPI(type) type
|
||||||
|
#endif
|
||||||
|
#endif /* not defined XMLPARSEAPI */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef XML_UNICODE_WCHAR_T
|
||||||
|
#define XML_UNICODE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct XML_ParserStruct;
|
||||||
|
typedef struct XML_ParserStruct *XML_Parser;
|
||||||
|
|
||||||
|
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
|
||||||
|
#ifdef XML_UNICODE_WCHAR_T
|
||||||
|
typedef wchar_t XML_Char;
|
||||||
|
typedef wchar_t XML_LChar;
|
||||||
|
#else
|
||||||
|
typedef unsigned short XML_Char;
|
||||||
|
typedef char XML_LChar;
|
||||||
|
#endif /* XML_UNICODE_WCHAR_T */
|
||||||
|
#else /* Information is UTF-8 encoded. */
|
||||||
|
typedef char XML_Char;
|
||||||
|
typedef char XML_LChar;
|
||||||
|
#endif /* XML_UNICODE */
|
||||||
|
|
||||||
|
/* Should this be defined using stdbool.h when C99 is available? */
|
||||||
|
typedef unsigned char XML_Bool;
|
||||||
|
#define XML_TRUE ((XML_Bool) 1)
|
||||||
|
#define XML_FALSE ((XML_Bool) 0)
|
||||||
|
|
||||||
|
enum XML_Error {
|
||||||
|
XML_ERROR_NONE,
|
||||||
|
XML_ERROR_NO_MEMORY,
|
||||||
|
XML_ERROR_SYNTAX,
|
||||||
|
XML_ERROR_NO_ELEMENTS,
|
||||||
|
XML_ERROR_INVALID_TOKEN,
|
||||||
|
XML_ERROR_UNCLOSED_TOKEN,
|
||||||
|
XML_ERROR_PARTIAL_CHAR,
|
||||||
|
XML_ERROR_TAG_MISMATCH,
|
||||||
|
XML_ERROR_DUPLICATE_ATTRIBUTE,
|
||||||
|
XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
|
||||||
|
XML_ERROR_PARAM_ENTITY_REF,
|
||||||
|
XML_ERROR_UNDEFINED_ENTITY,
|
||||||
|
XML_ERROR_RECURSIVE_ENTITY_REF,
|
||||||
|
XML_ERROR_ASYNC_ENTITY,
|
||||||
|
XML_ERROR_BAD_CHAR_REF,
|
||||||
|
XML_ERROR_BINARY_ENTITY_REF,
|
||||||
|
XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
|
||||||
|
XML_ERROR_MISPLACED_XML_PI,
|
||||||
|
XML_ERROR_UNKNOWN_ENCODING,
|
||||||
|
XML_ERROR_INCORRECT_ENCODING,
|
||||||
|
XML_ERROR_UNCLOSED_CDATA_SECTION,
|
||||||
|
XML_ERROR_EXTERNAL_ENTITY_HANDLING,
|
||||||
|
XML_ERROR_NOT_STANDALONE,
|
||||||
|
XML_ERROR_UNEXPECTED_STATE,
|
||||||
|
XML_ERROR_ENTITY_DECLARED_IN_PE,
|
||||||
|
XML_ERROR_FEATURE_REQUIRES_XML_DTD,
|
||||||
|
XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING
|
||||||
|
};
|
||||||
|
|
||||||
|
enum XML_Content_Type {
|
||||||
|
XML_CTYPE_EMPTY = 1,
|
||||||
|
XML_CTYPE_ANY,
|
||||||
|
XML_CTYPE_MIXED,
|
||||||
|
XML_CTYPE_NAME,
|
||||||
|
XML_CTYPE_CHOICE,
|
||||||
|
XML_CTYPE_SEQ
|
||||||
|
};
|
||||||
|
|
||||||
|
enum XML_Content_Quant {
|
||||||
|
XML_CQUANT_NONE,
|
||||||
|
XML_CQUANT_OPT,
|
||||||
|
XML_CQUANT_REP,
|
||||||
|
XML_CQUANT_PLUS
|
||||||
|
};
|
||||||
|
|
||||||
|
/* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
|
||||||
|
XML_CQUANT_NONE, and the other fields will be zero or NULL.
|
||||||
|
If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
|
||||||
|
numchildren will contain number of elements that may be mixed in
|
||||||
|
and children point to an array of XML_Content cells that will be
|
||||||
|
all of XML_CTYPE_NAME type with no quantification.
|
||||||
|
|
||||||
|
If type == XML_CTYPE_NAME, then the name points to the name, and
|
||||||
|
the numchildren field will be zero and children will be NULL. The
|
||||||
|
quant fields indicates any quantifiers placed on the name.
|
||||||
|
|
||||||
|
CHOICE and SEQ will have name NULL, the number of children in
|
||||||
|
numchildren and children will point, recursively, to an array
|
||||||
|
of XML_Content cells.
|
||||||
|
|
||||||
|
The EMPTY, ANY, and MIXED types will only occur at top level.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct XML_cp XML_Content;
|
||||||
|
|
||||||
|
struct XML_cp {
|
||||||
|
enum XML_Content_Type type;
|
||||||
|
enum XML_Content_Quant quant;
|
||||||
|
XML_Char * name;
|
||||||
|
unsigned int numchildren;
|
||||||
|
XML_Content * children;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* This is called for an element declaration. See above for
|
||||||
|
description of the model argument. It's the caller's responsibility
|
||||||
|
to free model when finished with it.
|
||||||
|
*/
|
||||||
|
typedef void (*XML_ElementDeclHandler) (void *userData,
|
||||||
|
const XML_Char *name,
|
||||||
|
XML_Content *model);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetElementDeclHandler(XML_Parser parser,
|
||||||
|
XML_ElementDeclHandler eldecl);
|
||||||
|
|
||||||
|
/* The Attlist declaration handler is called for *each* attribute. So
|
||||||
|
a single Attlist declaration with multiple attributes declared will
|
||||||
|
generate multiple calls to this handler. The "default" parameter
|
||||||
|
may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
|
||||||
|
keyword. The "isrequired" parameter will be true and the default
|
||||||
|
value will be NULL in the case of "#REQUIRED". If "isrequired" is
|
||||||
|
true and default is non-NULL, then this is a "#FIXED" default.
|
||||||
|
*/
|
||||||
|
typedef void (*XML_AttlistDeclHandler) (void *userData,
|
||||||
|
const XML_Char *elname,
|
||||||
|
const XML_Char *attname,
|
||||||
|
const XML_Char *att_type,
|
||||||
|
const XML_Char *dflt,
|
||||||
|
int isrequired);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetAttlistDeclHandler(XML_Parser parser,
|
||||||
|
XML_AttlistDeclHandler attdecl);
|
||||||
|
|
||||||
|
/* The XML declaration handler is called for *both* XML declarations
|
||||||
|
and text declarations. The way to distinguish is that the version
|
||||||
|
parameter will be NULL for text declarations. The encoding
|
||||||
|
parameter may be NULL for XML declarations. The standalone
|
||||||
|
parameter will be -1, 0, or 1 indicating respectively that there
|
||||||
|
was no standalone parameter in the declaration, that it was given
|
||||||
|
as no, or that it was given as yes.
|
||||||
|
*/
|
||||||
|
typedef void (*XML_XmlDeclHandler) (void *userData,
|
||||||
|
const XML_Char *version,
|
||||||
|
const XML_Char *encoding,
|
||||||
|
int standalone);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetXmlDeclHandler(XML_Parser parser,
|
||||||
|
XML_XmlDeclHandler xmldecl);
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
void *(*malloc_fcn)(size_t size);
|
||||||
|
void *(*realloc_fcn)(void *ptr, size_t size);
|
||||||
|
void (*free_fcn)(void *ptr);
|
||||||
|
} XML_Memory_Handling_Suite;
|
||||||
|
|
||||||
|
/* Constructs a new parser; encoding is the encoding specified by the
|
||||||
|
external protocol or NULL if there is none specified.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(XML_Parser)
|
||||||
|
XML_ParserCreate(const XML_Char *encoding);
|
||||||
|
|
||||||
|
/* Constructs a new parser and namespace processor. Element type
|
||||||
|
names and attribute names that belong to a namespace will be
|
||||||
|
expanded; unprefixed attribute names are never expanded; unprefixed
|
||||||
|
element type names are expanded only if there is a default
|
||||||
|
namespace. The expanded name is the concatenation of the namespace
|
||||||
|
URI, the namespace separator character, and the local part of the
|
||||||
|
name. If the namespace separator is '\0' then the namespace URI
|
||||||
|
and the local part will be concatenated without any separator.
|
||||||
|
When a namespace is not declared, the name and prefix will be
|
||||||
|
passed through without expansion.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(XML_Parser)
|
||||||
|
XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
|
||||||
|
|
||||||
|
|
||||||
|
/* Constructs a new parser using the memory management suit referred to
|
||||||
|
by memsuite. If memsuite is NULL, then use the standard library memory
|
||||||
|
suite. If namespaceSeparator is non-NULL it creates a parser with
|
||||||
|
namespace processing as described above. The character pointed at
|
||||||
|
will serve as the namespace separator.
|
||||||
|
|
||||||
|
All further memory operations used for the created parser will come from
|
||||||
|
the given suite.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(XML_Parser)
|
||||||
|
XML_ParserCreate_MM(const XML_Char *encoding,
|
||||||
|
const XML_Memory_Handling_Suite *memsuite,
|
||||||
|
const XML_Char *namespaceSeparator);
|
||||||
|
|
||||||
|
/* Prepare a parser object to be re-used. This is particularly
|
||||||
|
valuable when memory allocation overhead is disproportionatly high,
|
||||||
|
such as when a large number of small documnents need to be parsed.
|
||||||
|
All handlers are cleared from the parser, except for the
|
||||||
|
unknownEncodingHandler. The parser's external state is re-initialized
|
||||||
|
except for the values of ns and ns_triplets.
|
||||||
|
|
||||||
|
Added in Expat 1.95.3.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(XML_Bool)
|
||||||
|
XML_ParserReset(XML_Parser parser, const XML_Char *encoding);
|
||||||
|
|
||||||
|
/* atts is array of name/value pairs, terminated by 0;
|
||||||
|
names and values are 0 terminated.
|
||||||
|
*/
|
||||||
|
typedef void (*XML_StartElementHandler)(void *userData,
|
||||||
|
const XML_Char *name,
|
||||||
|
const XML_Char **atts);
|
||||||
|
|
||||||
|
typedef void (*XML_EndElementHandler)(void *userData,
|
||||||
|
const XML_Char *name);
|
||||||
|
|
||||||
|
|
||||||
|
/* s is not 0 terminated. */
|
||||||
|
typedef void (*XML_CharacterDataHandler)(void *userData,
|
||||||
|
const XML_Char *s,
|
||||||
|
int len);
|
||||||
|
|
||||||
|
/* target and data are 0 terminated */
|
||||||
|
typedef void (*XML_ProcessingInstructionHandler)(void *userData,
|
||||||
|
const XML_Char *target,
|
||||||
|
const XML_Char *data);
|
||||||
|
|
||||||
|
/* data is 0 terminated */
|
||||||
|
typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data);
|
||||||
|
|
||||||
|
typedef void (*XML_StartCdataSectionHandler)(void *userData);
|
||||||
|
typedef void (*XML_EndCdataSectionHandler)(void *userData);
|
||||||
|
|
||||||
|
/* This is called for any characters in the XML document for which
|
||||||
|
there is no applicable handler. This includes both characters that
|
||||||
|
are part of markup which is of a kind that is not reported
|
||||||
|
(comments, markup declarations), or characters that are part of a
|
||||||
|
construct which could be reported but for which no handler has been
|
||||||
|
supplied. The characters are passed exactly as they were in the XML
|
||||||
|
document except that they will be encoded in UTF-8 or UTF-16.
|
||||||
|
Line boundaries are not normalized. Note that a byte order mark
|
||||||
|
character is not passed to the default handler. There are no
|
||||||
|
guarantees about how characters are divided between calls to the
|
||||||
|
default handler: for example, a comment might be split between
|
||||||
|
multiple calls.
|
||||||
|
*/
|
||||||
|
typedef void (*XML_DefaultHandler)(void *userData,
|
||||||
|
const XML_Char *s,
|
||||||
|
int len);
|
||||||
|
|
||||||
|
/* This is called for the start of the DOCTYPE declaration, before
|
||||||
|
any DTD or internal subset is parsed.
|
||||||
|
*/
|
||||||
|
typedef void (*XML_StartDoctypeDeclHandler)(void *userData,
|
||||||
|
const XML_Char *doctypeName,
|
||||||
|
const XML_Char *sysid,
|
||||||
|
const XML_Char *pubid,
|
||||||
|
int has_internal_subset);
|
||||||
|
|
||||||
|
/* This is called for the start of the DOCTYPE declaration when the
|
||||||
|
closing > is encountered, but after processing any external
|
||||||
|
subset.
|
||||||
|
*/
|
||||||
|
typedef void (*XML_EndDoctypeDeclHandler)(void *userData);
|
||||||
|
|
||||||
|
/* This is called for entity declarations. The is_parameter_entity
|
||||||
|
argument will be non-zero if the entity is a parameter entity, zero
|
||||||
|
otherwise.
|
||||||
|
|
||||||
|
For internal entities (<!ENTITY foo "bar">), value will
|
||||||
|
be non-NULL and systemId, publicID, and notationName will be NULL.
|
||||||
|
The value string is NOT nul-terminated; the length is provided in
|
||||||
|
the value_length argument. Since it is legal to have zero-length
|
||||||
|
values, do not use this argument to test for internal entities.
|
||||||
|
|
||||||
|
For external entities, value will be NULL and systemId will be
|
||||||
|
non-NULL. The publicId argument will be NULL unless a public
|
||||||
|
identifier was provided. The notationName argument will have a
|
||||||
|
non-NULL value only for unparsed entity declarations.
|
||||||
|
|
||||||
|
Note that is_parameter_entity can't be changed to XML_Bool, since
|
||||||
|
that would break binary compatibility.
|
||||||
|
*/
|
||||||
|
typedef void (*XML_EntityDeclHandler) (void *userData,
|
||||||
|
const XML_Char *entityName,
|
||||||
|
int is_parameter_entity,
|
||||||
|
const XML_Char *value,
|
||||||
|
int value_length,
|
||||||
|
const XML_Char *base,
|
||||||
|
const XML_Char *systemId,
|
||||||
|
const XML_Char *publicId,
|
||||||
|
const XML_Char *notationName);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetEntityDeclHandler(XML_Parser parser,
|
||||||
|
XML_EntityDeclHandler handler);
|
||||||
|
|
||||||
|
/* OBSOLETE -- OBSOLETE -- OBSOLETE
|
||||||
|
This handler has been superceded by the EntityDeclHandler above.
|
||||||
|
It is provided here for backward compatibility.
|
||||||
|
|
||||||
|
This is called for a declaration of an unparsed (NDATA) entity.
|
||||||
|
The base argument is whatever was set by XML_SetBase. The
|
||||||
|
entityName, systemId and notationName arguments will never be
|
||||||
|
NULL. The other arguments may be.
|
||||||
|
*/
|
||||||
|
typedef void (*XML_UnparsedEntityDeclHandler)(void *userData,
|
||||||
|
const XML_Char *entityName,
|
||||||
|
const XML_Char *base,
|
||||||
|
const XML_Char *systemId,
|
||||||
|
const XML_Char *publicId,
|
||||||
|
const XML_Char *notationName);
|
||||||
|
|
||||||
|
/* This is called for a declaration of notation. The base argument is
|
||||||
|
whatever was set by XML_SetBase. The notationName will never be
|
||||||
|
NULL. The other arguments can be.
|
||||||
|
*/
|
||||||
|
typedef void (*XML_NotationDeclHandler)(void *userData,
|
||||||
|
const XML_Char *notationName,
|
||||||
|
const XML_Char *base,
|
||||||
|
const XML_Char *systemId,
|
||||||
|
const XML_Char *publicId);
|
||||||
|
|
||||||
|
/* When namespace processing is enabled, these are called once for
|
||||||
|
each namespace declaration. The call to the start and end element
|
||||||
|
handlers occur between the calls to the start and end namespace
|
||||||
|
declaration handlers. For an xmlns attribute, prefix will be
|
||||||
|
NULL. For an xmlns="" attribute, uri will be NULL.
|
||||||
|
*/
|
||||||
|
typedef void (*XML_StartNamespaceDeclHandler)(void *userData,
|
||||||
|
const XML_Char *prefix,
|
||||||
|
const XML_Char *uri);
|
||||||
|
|
||||||
|
typedef void (*XML_EndNamespaceDeclHandler)(void *userData,
|
||||||
|
const XML_Char *prefix);
|
||||||
|
|
||||||
|
/* This is called if the document is not standalone, that is, it has an
|
||||||
|
external subset or a reference to a parameter entity, but does not
|
||||||
|
have standalone="yes". If this handler returns 0, then processing
|
||||||
|
will not continue, and the parser will return a
|
||||||
|
XML_ERROR_NOT_STANDALONE error.
|
||||||
|
If parameter entity parsing is enabled, then in addition to the
|
||||||
|
conditions above this handler will only be called if the referenced
|
||||||
|
entity was actually read.
|
||||||
|
*/
|
||||||
|
typedef int (*XML_NotStandaloneHandler)(void *userData);
|
||||||
|
|
||||||
|
/* This is called for a reference to an external parsed general
|
||||||
|
entity. The referenced entity is not automatically parsed. The
|
||||||
|
application can parse it immediately or later using
|
||||||
|
XML_ExternalEntityParserCreate.
|
||||||
|
|
||||||
|
The parser argument is the parser parsing the entity containing the
|
||||||
|
reference; it can be passed as the parser argument to
|
||||||
|
XML_ExternalEntityParserCreate. The systemId argument is the
|
||||||
|
system identifier as specified in the entity declaration; it will
|
||||||
|
not be NULL.
|
||||||
|
|
||||||
|
The base argument is the system identifier that should be used as
|
||||||
|
the base for resolving systemId if systemId was relative; this is
|
||||||
|
set by XML_SetBase; it may be NULL.
|
||||||
|
|
||||||
|
The publicId argument is the public identifier as specified in the
|
||||||
|
entity declaration, or NULL if none was specified; the whitespace
|
||||||
|
in the public identifier will have been normalized as required by
|
||||||
|
the XML spec.
|
||||||
|
|
||||||
|
The context argument specifies the parsing context in the format
|
||||||
|
expected by the context argument to XML_ExternalEntityParserCreate;
|
||||||
|
context is valid only until the handler returns, so if the
|
||||||
|
referenced entity is to be parsed later, it must be copied.
|
||||||
|
|
||||||
|
The handler should return 0 if processing should not continue
|
||||||
|
because of a fatal error in the handling of the external entity.
|
||||||
|
In this case the calling parser will return an
|
||||||
|
XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
|
||||||
|
|
||||||
|
Note that unlike other handlers the first argument is the parser,
|
||||||
|
not userData.
|
||||||
|
*/
|
||||||
|
typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
|
||||||
|
const XML_Char *context,
|
||||||
|
const XML_Char *base,
|
||||||
|
const XML_Char *systemId,
|
||||||
|
const XML_Char *publicId);
|
||||||
|
|
||||||
|
/* This is called in two situations:
|
||||||
|
1) An entity reference is encountered for which no declaration
|
||||||
|
has been read *and* this is not an error.
|
||||||
|
2) An internal entity reference is read, but not expanded, because
|
||||||
|
XML_SetDefaultHandler has been called.
|
||||||
|
Note: skipped parameter entities in declarations and skipped general
|
||||||
|
entities in attribute values cannot be reported, because
|
||||||
|
the event would be out of sync with the reporting of the
|
||||||
|
declarations or attribute values
|
||||||
|
*/
|
||||||
|
typedef void (*XML_SkippedEntityHandler)(void *userData,
|
||||||
|
const XML_Char *entityName,
|
||||||
|
int is_parameter_entity);
|
||||||
|
|
||||||
|
/* This structure is filled in by the XML_UnknownEncodingHandler to
|
||||||
|
provide information to the parser about encodings that are unknown
|
||||||
|
to the parser.
|
||||||
|
|
||||||
|
The map[b] member gives information about byte sequences whose
|
||||||
|
first byte is b.
|
||||||
|
|
||||||
|
If map[b] is c where c is >= 0, then b by itself encodes the
|
||||||
|
Unicode scalar value c.
|
||||||
|
|
||||||
|
If map[b] is -1, then the byte sequence is malformed.
|
||||||
|
|
||||||
|
If map[b] is -n, where n >= 2, then b is the first byte of an
|
||||||
|
n-byte sequence that encodes a single Unicode scalar value.
|
||||||
|
|
||||||
|
The data member will be passed as the first argument to the convert
|
||||||
|
function.
|
||||||
|
|
||||||
|
The convert function is used to convert multibyte sequences; s will
|
||||||
|
point to a n-byte sequence where map[(unsigned char)*s] == -n. The
|
||||||
|
convert function must return the Unicode scalar value represented
|
||||||
|
by this byte sequence or -1 if the byte sequence is malformed.
|
||||||
|
|
||||||
|
The convert function may be NULL if the encoding is a single-byte
|
||||||
|
encoding, that is if map[b] >= -1 for all bytes b.
|
||||||
|
|
||||||
|
When the parser is finished with the encoding, then if release is
|
||||||
|
not NULL, it will call release passing it the data member; once
|
||||||
|
release has been called, the convert function will not be called
|
||||||
|
again.
|
||||||
|
|
||||||
|
Expat places certain restrictions on the encodings that are supported
|
||||||
|
using this mechanism.
|
||||||
|
|
||||||
|
1. Every ASCII character that can appear in a well-formed XML document,
|
||||||
|
other than the characters
|
||||||
|
|
||||||
|
$@\^`{}~
|
||||||
|
|
||||||
|
must be represented by a single byte, and that byte must be the
|
||||||
|
same byte that represents that character in ASCII.
|
||||||
|
|
||||||
|
2. No character may require more than 4 bytes to encode.
|
||||||
|
|
||||||
|
3. All characters encoded must have Unicode scalar values <=
|
||||||
|
0xFFFF, (i.e., characters that would be encoded by surrogates in
|
||||||
|
UTF-16 are not allowed). Note that this restriction doesn't
|
||||||
|
apply to the built-in support for UTF-8 and UTF-16.
|
||||||
|
|
||||||
|
4. No Unicode character may be encoded by more than one distinct
|
||||||
|
sequence of bytes.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
int map[256];
|
||||||
|
void *data;
|
||||||
|
int (*convert)(void *data, const char *s);
|
||||||
|
void (*release)(void *data);
|
||||||
|
} XML_Encoding;
|
||||||
|
|
||||||
|
/* This is called for an encoding that is unknown to the parser.
|
||||||
|
|
||||||
|
The encodingHandlerData argument is that which was passed as the
|
||||||
|
second argument to XML_SetUnknownEncodingHandler.
|
||||||
|
|
||||||
|
The name argument gives the name of the encoding as specified in
|
||||||
|
the encoding declaration.
|
||||||
|
|
||||||
|
If the callback can provide information about the encoding, it must
|
||||||
|
fill in the XML_Encoding structure, and return 1. Otherwise it
|
||||||
|
must return 0.
|
||||||
|
|
||||||
|
If info does not describe a suitable encoding, then the parser will
|
||||||
|
return an XML_UNKNOWN_ENCODING error.
|
||||||
|
*/
|
||||||
|
typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData,
|
||||||
|
const XML_Char *name,
|
||||||
|
XML_Encoding *info);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetElementHandler(XML_Parser parser,
|
||||||
|
XML_StartElementHandler start,
|
||||||
|
XML_EndElementHandler end);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetCharacterDataHandler(XML_Parser parser,
|
||||||
|
XML_CharacterDataHandler handler);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetProcessingInstructionHandler(XML_Parser parser,
|
||||||
|
XML_ProcessingInstructionHandler handler);
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetCommentHandler(XML_Parser parser,
|
||||||
|
XML_CommentHandler handler);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetCdataSectionHandler(XML_Parser parser,
|
||||||
|
XML_StartCdataSectionHandler start,
|
||||||
|
XML_EndCdataSectionHandler end);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetStartCdataSectionHandler(XML_Parser parser,
|
||||||
|
XML_StartCdataSectionHandler start);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetEndCdataSectionHandler(XML_Parser parser,
|
||||||
|
XML_EndCdataSectionHandler end);
|
||||||
|
|
||||||
|
/* This sets the default handler and also inhibits expansion of
|
||||||
|
internal entities. These entity references will be passed to the
|
||||||
|
default handler, or to the skipped entity handler, if one is set.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetDefaultHandler(XML_Parser parser,
|
||||||
|
XML_DefaultHandler handler);
|
||||||
|
|
||||||
|
/* This sets the default handler but does not inhibit expansion of
|
||||||
|
internal entities. The entity reference will not be passed to the
|
||||||
|
default handler.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetDefaultHandlerExpand(XML_Parser parser,
|
||||||
|
XML_DefaultHandler handler);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetDoctypeDeclHandler(XML_Parser parser,
|
||||||
|
XML_StartDoctypeDeclHandler start,
|
||||||
|
XML_EndDoctypeDeclHandler end);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetStartDoctypeDeclHandler(XML_Parser parser,
|
||||||
|
XML_StartDoctypeDeclHandler start);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetEndDoctypeDeclHandler(XML_Parser parser,
|
||||||
|
XML_EndDoctypeDeclHandler end);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
|
||||||
|
XML_UnparsedEntityDeclHandler handler);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetNotationDeclHandler(XML_Parser parser,
|
||||||
|
XML_NotationDeclHandler handler);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetNamespaceDeclHandler(XML_Parser parser,
|
||||||
|
XML_StartNamespaceDeclHandler start,
|
||||||
|
XML_EndNamespaceDeclHandler end);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetStartNamespaceDeclHandler(XML_Parser parser,
|
||||||
|
XML_StartNamespaceDeclHandler start);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetEndNamespaceDeclHandler(XML_Parser parser,
|
||||||
|
XML_EndNamespaceDeclHandler end);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetNotStandaloneHandler(XML_Parser parser,
|
||||||
|
XML_NotStandaloneHandler handler);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetExternalEntityRefHandler(XML_Parser parser,
|
||||||
|
XML_ExternalEntityRefHandler handler);
|
||||||
|
|
||||||
|
/* If a non-NULL value for arg is specified here, then it will be
|
||||||
|
passed as the first argument to the external entity ref handler
|
||||||
|
instead of the parser object.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetSkippedEntityHandler(XML_Parser parser,
|
||||||
|
XML_SkippedEntityHandler handler);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetUnknownEncodingHandler(XML_Parser parser,
|
||||||
|
XML_UnknownEncodingHandler handler,
|
||||||
|
void *encodingHandlerData);
|
||||||
|
|
||||||
|
/* This can be called within a handler for a start element, end
|
||||||
|
element, processing instruction or character data. It causes the
|
||||||
|
corresponding markup to be passed to the default handler.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_DefaultCurrent(XML_Parser parser);
|
||||||
|
|
||||||
|
/* If do_nst is non-zero, and namespace processing is in effect, and
|
||||||
|
a name has a prefix (i.e. an explicit namespace qualifier) then
|
||||||
|
that name is returned as a triplet in a single string separated by
|
||||||
|
the separator character specified when the parser was created: URI
|
||||||
|
+ sep + local_name + sep + prefix.
|
||||||
|
|
||||||
|
If do_nst is zero, then namespace information is returned in the
|
||||||
|
default manner (URI + sep + local_name) whether or not the name
|
||||||
|
has a prefix.
|
||||||
|
|
||||||
|
Note: Calling XML_SetReturnNSTriplet after XML_Parse or
|
||||||
|
XML_ParseBuffer has no effect.
|
||||||
|
*/
|
||||||
|
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
|
||||||
|
|
||||||
|
/* This value is passed as the userData argument to callbacks. */
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_SetUserData(XML_Parser parser, void *userData);
|
||||||
|
|
||||||
|
/* Returns the last value set by XML_SetUserData or NULL. */
|
||||||
|
#define XML_GetUserData(parser) (*(void **)(parser))
|
||||||
|
|
||||||
|
/* This is equivalent to supplying an encoding argument to
|
||||||
|
XML_ParserCreate. On success XML_SetEncoding returns non-zero,
|
||||||
|
zero otherwise.
|
||||||
|
Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer
|
||||||
|
has no effect and returns zero.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(int)
|
||||||
|
XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
|
||||||
|
|
||||||
|
/* If this function is called, then the parser will be passed as the
|
||||||
|
first argument to callbacks instead of userData. The userData will
|
||||||
|
still be accessible using XML_GetUserData.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_UseParserAsHandlerArg(XML_Parser parser);
|
||||||
|
|
||||||
|
/* If useDTD == XML_TRUE is passed to this function, then the parser
|
||||||
|
will assume that there is an external subset, even if none is
|
||||||
|
specified in the document. In such a case the parser will call the
|
||||||
|
externalEntityRefHandler with a value of NULL for the systemId
|
||||||
|
argument (the publicId and context arguments will be NULL as well).
|
||||||
|
Note: If this function is called, then this must be done before
|
||||||
|
the first call to XML_Parse or XML_ParseBuffer, since it will
|
||||||
|
have no effect after that. Returns
|
||||||
|
XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING.
|
||||||
|
Note: If the document does not have a DOCTYPE declaration at all,
|
||||||
|
then startDoctypeDeclHandler and endDoctypeDeclHandler will not
|
||||||
|
be called, despite an external subset being parsed.
|
||||||
|
Note: If XML_DTD is not defined when Expat is compiled, returns
|
||||||
|
XML_ERROR_FEATURE_REQUIRES_XML_DTD.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(enum XML_Error)
|
||||||
|
XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
|
||||||
|
|
||||||
|
|
||||||
|
/* Sets the base to be used for resolving relative URIs in system
|
||||||
|
identifiers in declarations. Resolving relative identifiers is
|
||||||
|
left to the application: this value will be passed through as the
|
||||||
|
base argument to the XML_ExternalEntityRefHandler,
|
||||||
|
XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base
|
||||||
|
argument will be copied. Returns zero if out of memory, non-zero
|
||||||
|
otherwise.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(int)
|
||||||
|
XML_SetBase(XML_Parser parser, const XML_Char *base);
|
||||||
|
|
||||||
|
XMLPARSEAPI(const XML_Char *)
|
||||||
|
XML_GetBase(XML_Parser parser);
|
||||||
|
|
||||||
|
/* Returns the number of the attribute/value pairs passed in last call
|
||||||
|
to the XML_StartElementHandler that were specified in the start-tag
|
||||||
|
rather than defaulted. Each attribute/value pair counts as 2; thus
|
||||||
|
this correspondds to an index into the atts array passed to the
|
||||||
|
XML_StartElementHandler.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(int)
|
||||||
|
XML_GetSpecifiedAttributeCount(XML_Parser parser);
|
||||||
|
|
||||||
|
/* Returns the index of the ID attribute passed in the last call to
|
||||||
|
XML_StartElementHandler, or -1 if there is no ID attribute. Each
|
||||||
|
attribute/value pair counts as 2; thus this correspondds to an
|
||||||
|
index into the atts array passed to the XML_StartElementHandler.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(int)
|
||||||
|
XML_GetIdAttributeIndex(XML_Parser parser);
|
||||||
|
|
||||||
|
/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
|
||||||
|
detected. The last call to XML_Parse must have isFinal true; len
|
||||||
|
may be zero for this call (or any other).
|
||||||
|
|
||||||
|
The XML_Status enum gives the possible return values for the
|
||||||
|
XML_Parse and XML_ParseBuffer functions. Though the return values
|
||||||
|
for these functions has always been described as a Boolean value,
|
||||||
|
the implementation, at least for the 1.95.x series, has always
|
||||||
|
returned exactly one of these values. The preprocessor #defines
|
||||||
|
are included so this stanza can be added to code that still needs
|
||||||
|
to support older versions of Expat 1.95.x:
|
||||||
|
|
||||||
|
#ifndef XML_STATUS_OK
|
||||||
|
#define XML_STATUS_OK 1
|
||||||
|
#define XML_STATUS_ERROR 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Otherwise, the #define hackery is quite ugly and would have been dropped.
|
||||||
|
*/
|
||||||
|
enum XML_Status {
|
||||||
|
XML_STATUS_ERROR = 0,
|
||||||
|
#define XML_STATUS_ERROR XML_STATUS_ERROR
|
||||||
|
XML_STATUS_OK = 1
|
||||||
|
#define XML_STATUS_OK XML_STATUS_OK
|
||||||
|
};
|
||||||
|
|
||||||
|
XMLPARSEAPI(enum XML_Status)
|
||||||
|
XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
|
||||||
|
|
||||||
|
XMLPARSEAPI(void *)
|
||||||
|
XML_GetBuffer(XML_Parser parser, int len);
|
||||||
|
|
||||||
|
XMLPARSEAPI(enum XML_Status)
|
||||||
|
XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
|
||||||
|
|
||||||
|
/* Creates an XML_Parser object that can parse an external general
|
||||||
|
entity; context is a '\0'-terminated string specifying the parse
|
||||||
|
context; encoding is a '\0'-terminated string giving the name of
|
||||||
|
the externally specified encoding, or NULL if there is no
|
||||||
|
externally specified encoding. The context string consists of a
|
||||||
|
sequence of tokens separated by formfeeds (\f); a token consisting
|
||||||
|
of a name specifies that the general entity of the name is open; a
|
||||||
|
token of the form prefix=uri specifies the namespace for a
|
||||||
|
particular prefix; a token of the form =uri specifies the default
|
||||||
|
namespace. This can be called at any point after the first call to
|
||||||
|
an ExternalEntityRefHandler so longer as the parser has not yet
|
||||||
|
been freed. The new parser is completely independent and may
|
||||||
|
safely be used in a separate thread. The handlers and userData are
|
||||||
|
initialized from the parser argument. Returns 0 if out of memory.
|
||||||
|
Otherwise returns a new XML_Parser object.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(XML_Parser)
|
||||||
|
XML_ExternalEntityParserCreate(XML_Parser parser,
|
||||||
|
const XML_Char *context,
|
||||||
|
const XML_Char *encoding);
|
||||||
|
|
||||||
|
enum XML_ParamEntityParsing {
|
||||||
|
XML_PARAM_ENTITY_PARSING_NEVER,
|
||||||
|
XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
|
||||||
|
XML_PARAM_ENTITY_PARSING_ALWAYS
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Controls parsing of parameter entities (including the external DTD
|
||||||
|
subset). If parsing of parameter entities is enabled, then
|
||||||
|
references to external parameter entities (including the external
|
||||||
|
DTD subset) will be passed to the handler set with
|
||||||
|
XML_SetExternalEntityRefHandler. The context passed will be 0.
|
||||||
|
|
||||||
|
Unlike external general entities, external parameter entities can
|
||||||
|
only be parsed synchronously. If the external parameter entity is
|
||||||
|
to be parsed, it must be parsed during the call to the external
|
||||||
|
entity ref handler: the complete sequence of
|
||||||
|
XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
|
||||||
|
XML_ParserFree calls must be made during this call. After
|
||||||
|
XML_ExternalEntityParserCreate has been called to create the parser
|
||||||
|
for the external parameter entity (context must be 0 for this
|
||||||
|
call), it is illegal to make any calls on the old parser until
|
||||||
|
XML_ParserFree has been called on the newly created parser.
|
||||||
|
If the library has been compiled without support for parameter
|
||||||
|
entity parsing (ie without XML_DTD being defined), then
|
||||||
|
XML_SetParamEntityParsing will return 0 if parsing of parameter
|
||||||
|
entities is requested; otherwise it will return non-zero.
|
||||||
|
Note: If XML_SetParamEntityParsing is called after XML_Parse or
|
||||||
|
XML_ParseBuffer, then it has no effect and will always return 0.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(int)
|
||||||
|
XML_SetParamEntityParsing(XML_Parser parser,
|
||||||
|
enum XML_ParamEntityParsing parsing);
|
||||||
|
|
||||||
|
/* If XML_Parse or XML_ParseBuffer have returned 0, then
|
||||||
|
XML_GetErrorCode returns information about the error.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(enum XML_Error)
|
||||||
|
XML_GetErrorCode(XML_Parser parser);
|
||||||
|
|
||||||
|
/* These functions return information about the current parse
|
||||||
|
location. They may be called when XML_Parse or XML_ParseBuffer
|
||||||
|
return 0; in this case the location is the location of the
|
||||||
|
character at which the error was detected.
|
||||||
|
|
||||||
|
They may also be called from any other callback called to report
|
||||||
|
some parse event; in this the location is the location of the first
|
||||||
|
of the sequence of characters that generated the event.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser);
|
||||||
|
XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser);
|
||||||
|
XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser);
|
||||||
|
|
||||||
|
/* Return the number of bytes in the current event.
|
||||||
|
Returns 0 if the event is in an internal entity.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(int)
|
||||||
|
XML_GetCurrentByteCount(XML_Parser parser);
|
||||||
|
|
||||||
|
/* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
|
||||||
|
the integer pointed to by offset to the offset within this buffer
|
||||||
|
of the current parse position, and sets the integer pointed to by size
|
||||||
|
to the size of this buffer (the number of input bytes). Otherwise
|
||||||
|
returns a NULL pointer. Also returns a NULL pointer if a parse isn't
|
||||||
|
active.
|
||||||
|
|
||||||
|
NOTE: The character pointer returned should not be used outside
|
||||||
|
the handler that makes the call.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(const char *)
|
||||||
|
XML_GetInputContext(XML_Parser parser,
|
||||||
|
int *offset,
|
||||||
|
int *size);
|
||||||
|
|
||||||
|
/* For backwards compatibility with previous versions. */
|
||||||
|
#define XML_GetErrorLineNumber XML_GetCurrentLineNumber
|
||||||
|
#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
|
||||||
|
#define XML_GetErrorByteIndex XML_GetCurrentByteIndex
|
||||||
|
|
||||||
|
/* Frees memory used by the parser. */
|
||||||
|
XMLPARSEAPI(void)
|
||||||
|
XML_ParserFree(XML_Parser parser);
|
||||||
|
|
||||||
|
/* Returns a string describing the error. */
|
||||||
|
XMLPARSEAPI(const XML_LChar *)
|
||||||
|
XML_ErrorString(enum XML_Error code);
|
||||||
|
|
||||||
|
/* Return a string containing the version number of this expat */
|
||||||
|
XMLPARSEAPI(const XML_LChar *)
|
||||||
|
XML_ExpatVersion(void);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int major;
|
||||||
|
int minor;
|
||||||
|
int micro;
|
||||||
|
} XML_Expat_Version;
|
||||||
|
|
||||||
|
/* Return an XML_Expat_Version structure containing numeric version
|
||||||
|
number information for this version of expat.
|
||||||
|
*/
|
||||||
|
XMLPARSEAPI(XML_Expat_Version)
|
||||||
|
XML_ExpatVersionInfo(void);
|
||||||
|
|
||||||
|
/* Added in Expat 1.95.5. */
|
||||||
|
enum XML_FeatureEnum {
|
||||||
|
XML_FEATURE_END = 0,
|
||||||
|
XML_FEATURE_UNICODE,
|
||||||
|
XML_FEATURE_UNICODE_WCHAR_T,
|
||||||
|
XML_FEATURE_DTD,
|
||||||
|
XML_FEATURE_CONTEXT_BYTES,
|
||||||
|
XML_FEATURE_MIN_SIZE,
|
||||||
|
XML_FEATURE_SIZEOF_XML_CHAR,
|
||||||
|
XML_FEATURE_SIZEOF_XML_LCHAR
|
||||||
|
/* Additional features must be added to the end of this enum. */
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
enum XML_FeatureEnum feature;
|
||||||
|
XML_LChar *name;
|
||||||
|
long int value;
|
||||||
|
} XML_Feature;
|
||||||
|
|
||||||
|
XMLPARSEAPI(const XML_Feature *)
|
||||||
|
XML_GetFeatureList(void);
|
||||||
|
|
||||||
|
|
||||||
|
/* Expat follows the GNU/Linux convention of odd number minor version for
|
||||||
|
beta/development releases and even number minor version for stable
|
||||||
|
releases. Micro is bumped with each release, and set to 0 with each
|
||||||
|
change to major or minor version.
|
||||||
|
*/
|
||||||
|
#define XML_MAJOR_VERSION 1
|
||||||
|
#define XML_MINOR_VERSION 95
|
||||||
|
#define XML_MICRO_VERSION 5
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* not XmlParse_INCLUDED */
|
37
contrib/expat/lib/iasciitab.h
Normal file
37
contrib/expat/lib/iasciitab.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
|
||||||
|
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||||
|
/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||||
|
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||||
|
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||||
|
/* 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_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,
|
||||||
|
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||||
|
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||||
|
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||||
|
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||||
|
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||||
|
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
46
contrib/expat/lib/internal.h
Normal file
46
contrib/expat/lib/internal.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/* internal.h
|
||||||
|
|
||||||
|
Internal definitions used by Expat. This is not needed to compile
|
||||||
|
client code.
|
||||||
|
|
||||||
|
The following definitions are made:
|
||||||
|
|
||||||
|
FASTCALL -- Used for most internal functions to specify that the
|
||||||
|
fastest possible calling convention be used.
|
||||||
|
|
||||||
|
inline -- Used for selected internal functions for which inlining
|
||||||
|
may improve performance on some platforms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
/* Last minute instability reported with egcs on a RedHat Linux 7.3
|
||||||
|
box; argh!
|
||||||
|
*/
|
||||||
|
/* #define FASTCALL __attribute__((stdcall, regparm(3))) */
|
||||||
|
#elif defined(WIN32)
|
||||||
|
/* XXX This seems to have an unexpected negative effect on Windows so
|
||||||
|
we'll disable it for now on that platform. It may be reconsidered
|
||||||
|
for a future release if it can be made more effective.
|
||||||
|
*/
|
||||||
|
/* #define FASTCALL __fastcall */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FASTCALL
|
||||||
|
#define FASTCALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef XML_MIN_SIZE
|
||||||
|
#if !defined(__cplusplus) && !defined(inline)
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define inline __inline
|
||||||
|
#endif /* __GNUC__ */
|
||||||
|
#endif
|
||||||
|
#endif /* XML_MIN_SIZE */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define inline inline
|
||||||
|
#else
|
||||||
|
#ifndef inline
|
||||||
|
#define inline
|
||||||
|
#endif
|
||||||
|
#endif
|
36
contrib/expat/lib/latin1tab.h
Normal file
36
contrib/expat/lib/latin1tab.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||||
|
/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||||
|
/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||||
|
/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||||
|
/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||||
|
/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||||
|
/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||||
|
/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||||
|
/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||||
|
/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||||
|
/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||||
|
/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||||
|
/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||||
|
/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
|
||||||
|
/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||||
|
/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||||
|
/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||||
|
/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||||
|
/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||||
|
/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
150
contrib/expat/lib/nametab.h
Normal file
150
contrib/expat/lib/nametab.h
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
static const unsigned namingBitmap[] = {
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||||
|
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||||
|
0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE,
|
||||||
|
0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||||
|
0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF,
|
||||||
|
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF,
|
||||||
|
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||||
|
0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||||
|
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||||
|
0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
|
||||||
|
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||||
|
0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF,
|
||||||
|
0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000,
|
||||||
|
0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
|
||||||
|
0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003,
|
||||||
|
0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003,
|
||||||
|
0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
|
||||||
|
0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001,
|
||||||
|
0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003,
|
||||||
|
0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
|
||||||
|
0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003,
|
||||||
|
0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003,
|
||||||
|
0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000,
|
||||||
|
0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
|
||||||
|
0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
|
||||||
|
0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB,
|
||||||
|
0x40000000, 0xF580C900, 0x00000007, 0x02010800,
|
||||||
|
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||||
|
0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
|
||||||
|
0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
|
||||||
|
0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
|
||||||
|
0x00000000, 0x00004C40, 0x00000000, 0x00000000,
|
||||||
|
0x00000007, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
|
||||||
|
0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
|
||||||
|
0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||||
|
0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
|
||||||
|
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||||
|
0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
|
||||||
|
0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
|
||||||
|
0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||||
|
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||||
|
0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
|
||||||
|
0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
|
||||||
|
0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||||
|
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||||
|
0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
|
||||||
|
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||||
|
0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
|
||||||
|
0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
|
||||||
|
0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
|
||||||
|
0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
|
||||||
|
0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
|
||||||
|
0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
|
||||||
|
0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
|
||||||
|
0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
|
||||||
|
0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
|
||||||
|
0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
|
||||||
|
0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
|
||||||
|
0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
|
||||||
|
0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000,
|
||||||
|
0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
|
||||||
|
0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
|
||||||
|
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
|
||||||
|
0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
|
||||||
|
0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF,
|
||||||
|
};
|
||||||
|
static const unsigned char nmstrtPages[] = {
|
||||||
|
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00,
|
||||||
|
0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||||
|
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
|
||||||
|
0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
};
|
||||||
|
static const unsigned char namePages[] = {
|
||||||
|
0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00,
|
||||||
|
0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
|
||||||
|
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
|
||||||
|
0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
};
|
37
contrib/expat/lib/utf8tab.h
Normal file
37
contrib/expat/lib/utf8tab.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||||
|
/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||||
|
/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||||
|
/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||||
|
/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||||
|
/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||||
|
/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||||
|
/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||||
|
/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||||
|
/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||||
|
/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||||
|
/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||||
|
/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||||
|
/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
|
||||||
|
/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||||
|
/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
|
30
contrib/expat/lib/winconfig.h
Normal file
30
contrib/expat/lib/winconfig.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*================================================================
|
||||||
|
** Copyright 2000, Clark Cooper
|
||||||
|
** All rights reserved.
|
||||||
|
**
|
||||||
|
** This is free software. You are permitted to copy, distribute, or modify
|
||||||
|
** it under the terms of the MIT/X license (contained in the COPYING file
|
||||||
|
** with this distribution.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WINCONFIG_H
|
||||||
|
#define WINCONFIG_H
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#undef WIN32_LEAN_AND_MEAN
|
||||||
|
|
||||||
|
#include <memory.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define XML_NS 1
|
||||||
|
#define XML_DTD 1
|
||||||
|
#define XML_CONTEXT_BYTES 1024
|
||||||
|
|
||||||
|
/* we will assume all Windows platforms are little endian */
|
||||||
|
#define BYTEORDER 1234
|
||||||
|
|
||||||
|
/* Windows has memmove() available. */
|
||||||
|
#define HAVE_MEMMOVE
|
||||||
|
|
||||||
|
#endif /* ndef WINCONFIG_H */
|
5600
contrib/expat/lib/xmlparse.c
Normal file
5600
contrib/expat/lib/xmlparse.c
Normal file
File diff suppressed because it is too large
Load Diff
1321
contrib/expat/lib/xmlrole.c
Normal file
1321
contrib/expat/lib/xmlrole.c
Normal file
File diff suppressed because it is too large
Load Diff
114
contrib/expat/lib/xmlrole.h
Normal file
114
contrib/expat/lib/xmlrole.h
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XmlRole_INCLUDED
|
||||||
|
#define XmlRole_INCLUDED 1
|
||||||
|
|
||||||
|
#ifdef __VMS
|
||||||
|
/* 0 1 2 3 0 1 2 3
|
||||||
|
1234567890123456789012345678901 1234567890123456789012345678901 */
|
||||||
|
#define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "xmltok.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
enum {
|
||||||
|
XML_ROLE_ERROR = -1,
|
||||||
|
XML_ROLE_NONE = 0,
|
||||||
|
XML_ROLE_XML_DECL,
|
||||||
|
XML_ROLE_INSTANCE_START,
|
||||||
|
XML_ROLE_DOCTYPE_NONE,
|
||||||
|
XML_ROLE_DOCTYPE_NAME,
|
||||||
|
XML_ROLE_DOCTYPE_SYSTEM_ID,
|
||||||
|
XML_ROLE_DOCTYPE_PUBLIC_ID,
|
||||||
|
XML_ROLE_DOCTYPE_INTERNAL_SUBSET,
|
||||||
|
XML_ROLE_DOCTYPE_CLOSE,
|
||||||
|
XML_ROLE_GENERAL_ENTITY_NAME,
|
||||||
|
XML_ROLE_PARAM_ENTITY_NAME,
|
||||||
|
XML_ROLE_ENTITY_NONE,
|
||||||
|
XML_ROLE_ENTITY_VALUE,
|
||||||
|
XML_ROLE_ENTITY_SYSTEM_ID,
|
||||||
|
XML_ROLE_ENTITY_PUBLIC_ID,
|
||||||
|
XML_ROLE_ENTITY_COMPLETE,
|
||||||
|
XML_ROLE_ENTITY_NOTATION_NAME,
|
||||||
|
XML_ROLE_NOTATION_NONE,
|
||||||
|
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,
|
||||||
|
XML_ROLE_ATTRIBUTE_TYPE_ID,
|
||||||
|
XML_ROLE_ATTRIBUTE_TYPE_IDREF,
|
||||||
|
XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
|
||||||
|
XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
|
||||||
|
XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
|
||||||
|
XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
|
||||||
|
XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
|
||||||
|
XML_ROLE_ATTRIBUTE_ENUM_VALUE,
|
||||||
|
XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
|
||||||
|
XML_ROLE_ATTLIST_NONE,
|
||||||
|
XML_ROLE_ATTLIST_ELEMENT_NAME,
|
||||||
|
XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
|
||||||
|
XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
|
||||||
|
XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
|
||||||
|
XML_ROLE_FIXED_ATTRIBUTE_VALUE,
|
||||||
|
XML_ROLE_ELEMENT_NONE,
|
||||||
|
XML_ROLE_ELEMENT_NAME,
|
||||||
|
XML_ROLE_CONTENT_ANY,
|
||||||
|
XML_ROLE_CONTENT_EMPTY,
|
||||||
|
XML_ROLE_CONTENT_PCDATA,
|
||||||
|
XML_ROLE_GROUP_OPEN,
|
||||||
|
XML_ROLE_GROUP_CLOSE,
|
||||||
|
XML_ROLE_GROUP_CLOSE_REP,
|
||||||
|
XML_ROLE_GROUP_CLOSE_OPT,
|
||||||
|
XML_ROLE_GROUP_CLOSE_PLUS,
|
||||||
|
XML_ROLE_GROUP_CHOICE,
|
||||||
|
XML_ROLE_GROUP_SEQUENCE,
|
||||||
|
XML_ROLE_CONTENT_ELEMENT,
|
||||||
|
XML_ROLE_CONTENT_ELEMENT_REP,
|
||||||
|
XML_ROLE_CONTENT_ELEMENT_OPT,
|
||||||
|
XML_ROLE_CONTENT_ELEMENT_PLUS,
|
||||||
|
XML_ROLE_PI,
|
||||||
|
XML_ROLE_COMMENT,
|
||||||
|
#ifdef XML_DTD
|
||||||
|
XML_ROLE_TEXT_DECL,
|
||||||
|
XML_ROLE_IGNORE_SECT,
|
||||||
|
XML_ROLE_INNER_PARAM_ENTITY_REF,
|
||||||
|
#endif /* XML_DTD */
|
||||||
|
XML_ROLE_PARAM_ENTITY_REF
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct prolog_state {
|
||||||
|
int (FASTCALL *handler) (struct prolog_state *state,
|
||||||
|
int tok,
|
||||||
|
const char *ptr,
|
||||||
|
const char *end,
|
||||||
|
const ENCODING *enc);
|
||||||
|
unsigned level;
|
||||||
|
int role_none;
|
||||||
|
#ifdef XML_DTD
|
||||||
|
unsigned includeLevel;
|
||||||
|
int documentEntity;
|
||||||
|
int inEntityValue;
|
||||||
|
#endif /* XML_DTD */
|
||||||
|
} PROLOG_STATE;
|
||||||
|
|
||||||
|
void XmlPrologStateInit(PROLOG_STATE *);
|
||||||
|
#ifdef XML_DTD
|
||||||
|
void XmlPrologStateInitExternalEntity(PROLOG_STATE *);
|
||||||
|
#endif /* XML_DTD */
|
||||||
|
|
||||||
|
#define XmlTokenRole(state, tok, ptr, end, enc) \
|
||||||
|
(((state)->handler)(state, tok, ptr, end, enc))
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* not XmlRole_INCLUDED */
|
1632
contrib/expat/lib/xmltok.c
Normal file
1632
contrib/expat/lib/xmltok.c
Normal file
File diff suppressed because it is too large
Load Diff
312
contrib/expat/lib/xmltok.h
Normal file
312
contrib/expat/lib/xmltok.h
Normal file
@ -0,0 +1,312 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XmlTok_INCLUDED
|
||||||
|
#define XmlTok_INCLUDED 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#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;
|
||||||
|
might be part of CRLF sequence */
|
||||||
|
#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
|
||||||
|
#define XML_TOK_PARTIAL -1 /* only part of a token */
|
||||||
|
#define XML_TOK_INVALID 0
|
||||||
|
|
||||||
|
/* The following tokens are returned by XmlContentTok; some are also
|
||||||
|
returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok.
|
||||||
|
*/
|
||||||
|
#define XML_TOK_START_TAG_WITH_ATTS 1
|
||||||
|
#define XML_TOK_START_TAG_NO_ATTS 2
|
||||||
|
#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */
|
||||||
|
#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
|
||||||
|
#define XML_TOK_END_TAG 5
|
||||||
|
#define XML_TOK_DATA_CHARS 6
|
||||||
|
#define XML_TOK_DATA_NEWLINE 7
|
||||||
|
#define XML_TOK_CDATA_SECT_OPEN 8
|
||||||
|
#define XML_TOK_ENTITY_REF 9
|
||||||
|
#define XML_TOK_CHAR_REF 10 /* numeric character reference */
|
||||||
|
|
||||||
|
/* The following tokens may be returned by both XmlPrologTok and
|
||||||
|
XmlContentTok.
|
||||||
|
*/
|
||||||
|
#define XML_TOK_PI 11 /* processing instruction */
|
||||||
|
#define XML_TOK_XML_DECL 12 /* XML decl or text decl */
|
||||||
|
#define XML_TOK_COMMENT 13
|
||||||
|
#define XML_TOK_BOM 14 /* Byte order mark */
|
||||||
|
|
||||||
|
/* The following tokens are returned only by XmlPrologTok */
|
||||||
|
#define XML_TOK_PROLOG_S 15
|
||||||
|
#define XML_TOK_DECL_OPEN 16 /* <!foo */
|
||||||
|
#define XML_TOK_DECL_CLOSE 17 /* > */
|
||||||
|
#define XML_TOK_NAME 18
|
||||||
|
#define XML_TOK_NMTOKEN 19
|
||||||
|
#define XML_TOK_POUND_NAME 20 /* #name */
|
||||||
|
#define XML_TOK_OR 21 /* | */
|
||||||
|
#define XML_TOK_PERCENT 22
|
||||||
|
#define XML_TOK_OPEN_PAREN 23
|
||||||
|
#define XML_TOK_CLOSE_PAREN 24
|
||||||
|
#define XML_TOK_OPEN_BRACKET 25
|
||||||
|
#define XML_TOK_CLOSE_BRACKET 26
|
||||||
|
#define XML_TOK_LITERAL 27
|
||||||
|
#define XML_TOK_PARAM_ENTITY_REF 28
|
||||||
|
#define XML_TOK_INSTANCE_START 29
|
||||||
|
|
||||||
|
/* The following occur only in element type declarations */
|
||||||
|
#define XML_TOK_NAME_QUESTION 30 /* name? */
|
||||||
|
#define XML_TOK_NAME_ASTERISK 31 /* name* */
|
||||||
|
#define XML_TOK_NAME_PLUS 32 /* name+ */
|
||||||
|
#define XML_TOK_COND_SECT_OPEN 33 /* <![ */
|
||||||
|
#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */
|
||||||
|
#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
|
||||||
|
#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
|
||||||
|
#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
|
||||||
|
#define XML_TOK_COMMA 38
|
||||||
|
|
||||||
|
/* The following token is returned only by XmlAttributeValueTok */
|
||||||
|
#define XML_TOK_ATTRIBUTE_VALUE_S 39
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
|
||||||
|
#ifdef XML_DTD
|
||||||
|
#define XML_TOK_IGNORE_SECT 42
|
||||||
|
#endif /* XML_DTD */
|
||||||
|
|
||||||
|
#ifdef XML_DTD
|
||||||
|
#define XML_N_STATES 4
|
||||||
|
#else /* not XML_DTD */
|
||||||
|
#define XML_N_STATES 3
|
||||||
|
#endif /* not XML_DTD */
|
||||||
|
|
||||||
|
#define XML_PROLOG_STATE 0
|
||||||
|
#define XML_CONTENT_STATE 1
|
||||||
|
#define XML_CDATA_SECTION_STATE 2
|
||||||
|
#ifdef XML_DTD
|
||||||
|
#define XML_IGNORE_SECTION_STATE 3
|
||||||
|
#endif /* XML_DTD */
|
||||||
|
|
||||||
|
#define XML_N_LITERAL_TYPES 2
|
||||||
|
#define XML_ATTRIBUTE_VALUE_LITERAL 0
|
||||||
|
#define XML_ENTITY_VALUE_LITERAL 1
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
unsigned long lineNumber;
|
||||||
|
unsigned long columnNumber;
|
||||||
|
} POSITION;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *name;
|
||||||
|
const char *valuePtr;
|
||||||
|
const char *valueEnd;
|
||||||
|
char normalized;
|
||||||
|
} ATTRIBUTE;
|
||||||
|
|
||||||
|
struct encoding;
|
||||||
|
typedef struct encoding ENCODING;
|
||||||
|
|
||||||
|
typedef int (FASTCALL *SCANNER)(const ENCODING *,
|
||||||
|
const char *,
|
||||||
|
const char *,
|
||||||
|
const char **);
|
||||||
|
|
||||||
|
struct encoding {
|
||||||
|
SCANNER scanners[XML_N_STATES];
|
||||||
|
SCANNER literalScanners[XML_N_LITERAL_TYPES];
|
||||||
|
int (FASTCALL *sameName)(const ENCODING *,
|
||||||
|
const char *,
|
||||||
|
const char *);
|
||||||
|
int (FASTCALL *nameMatchesAscii)(const ENCODING *,
|
||||||
|
const char *,
|
||||||
|
const char *,
|
||||||
|
const char *);
|
||||||
|
int (FASTCALL *nameLength)(const ENCODING *, const char *);
|
||||||
|
const char *(FASTCALL *skipS)(const ENCODING *, const char *);
|
||||||
|
int (FASTCALL *getAtts)(const ENCODING *enc,
|
||||||
|
const char *ptr,
|
||||||
|
int attsMax,
|
||||||
|
ATTRIBUTE *atts);
|
||||||
|
int (FASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr);
|
||||||
|
int (FASTCALL *predefinedEntityName)(const ENCODING *,
|
||||||
|
const char *,
|
||||||
|
const char *);
|
||||||
|
void (FASTCALL *updatePosition)(const ENCODING *,
|
||||||
|
const char *ptr,
|
||||||
|
const char *end,
|
||||||
|
POSITION *);
|
||||||
|
int (FASTCALL *isPublicId)(const ENCODING *enc,
|
||||||
|
const char *ptr,
|
||||||
|
const char *end,
|
||||||
|
const char **badPtr);
|
||||||
|
void (FASTCALL *utf8Convert)(const ENCODING *enc,
|
||||||
|
const char **fromP,
|
||||||
|
const char *fromLim,
|
||||||
|
char **toP,
|
||||||
|
const char *toLim);
|
||||||
|
void (FASTCALL *utf16Convert)(const ENCODING *enc,
|
||||||
|
const char **fromP,
|
||||||
|
const char *fromLim,
|
||||||
|
unsigned short **toP,
|
||||||
|
const unsigned short *toLim);
|
||||||
|
int minBytesPerChar;
|
||||||
|
char isUtf8;
|
||||||
|
char isUtf16;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Scan the string starting at ptr until the end of the next complete
|
||||||
|
token, but do not scan past eptr. Return an integer giving the
|
||||||
|
type of token.
|
||||||
|
|
||||||
|
Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.
|
||||||
|
|
||||||
|
Return XML_TOK_PARTIAL when the string does not contain a complete
|
||||||
|
token; nextTokPtr will not be set.
|
||||||
|
|
||||||
|
Return XML_TOK_INVALID when the string does not start a valid
|
||||||
|
token; nextTokPtr will be set to point to the character which made
|
||||||
|
the token invalid.
|
||||||
|
|
||||||
|
Otherwise the string starts with a valid token; nextTokPtr will be
|
||||||
|
set to point to the character following the end of that token.
|
||||||
|
|
||||||
|
Each data character counts as a single token, but adjacent data
|
||||||
|
characters may be returned together. Similarly for characters in
|
||||||
|
the prolog outside literals, comments and processing instructions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define XmlTok(enc, state, ptr, end, nextTokPtr) \
|
||||||
|
(((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
|
||||||
|
|
||||||
|
#define XmlPrologTok(enc, ptr, end, nextTokPtr) \
|
||||||
|
XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
|
||||||
|
|
||||||
|
#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)
|
||||||
|
|
||||||
|
#ifdef XML_DTD
|
||||||
|
|
||||||
|
#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \
|
||||||
|
XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr)
|
||||||
|
|
||||||
|
#endif /* XML_DTD */
|
||||||
|
|
||||||
|
/* This is used for performing a 2nd-level tokenization on the content
|
||||||
|
of a literal that has already been returned by XmlTok.
|
||||||
|
*/
|
||||||
|
#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
|
||||||
|
(((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
|
||||||
|
|
||||||
|
#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
|
||||||
|
XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||||
|
|
||||||
|
#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
|
||||||
|
XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||||
|
|
||||||
|
#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
|
||||||
|
|
||||||
|
#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
|
||||||
|
(((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
|
||||||
|
|
||||||
|
#define XmlNameLength(enc, ptr) \
|
||||||
|
(((enc)->nameLength)(enc, ptr))
|
||||||
|
|
||||||
|
#define XmlSkipS(enc, ptr) \
|
||||||
|
(((enc)->skipS)(enc, ptr))
|
||||||
|
|
||||||
|
#define XmlGetAttributes(enc, ptr, attsMax, atts) \
|
||||||
|
(((enc)->getAtts)(enc, ptr, attsMax, atts))
|
||||||
|
|
||||||
|
#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 XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
|
||||||
|
(((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
|
||||||
|
|
||||||
|
#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
|
||||||
|
(((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ENCODING initEnc;
|
||||||
|
const ENCODING **encPtr;
|
||||||
|
} INIT_ENCODING;
|
||||||
|
|
||||||
|
int XmlParseXmlDecl(int isGeneralTextEntity,
|
||||||
|
const ENCODING *enc,
|
||||||
|
const char *ptr,
|
||||||
|
const char *end,
|
||||||
|
const char **badPtr,
|
||||||
|
const char **versionPtr,
|
||||||
|
const char **versionEndPtr,
|
||||||
|
const char **encodingNamePtr,
|
||||||
|
const ENCODING **namedEncodingPtr,
|
||||||
|
int *standalonePtr);
|
||||||
|
|
||||||
|
int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||||
|
const ENCODING *XmlGetUtf8InternalEncoding(void);
|
||||||
|
const ENCODING *XmlGetUtf16InternalEncoding(void);
|
||||||
|
int XmlUtf8Encode(int charNumber, char *buf);
|
||||||
|
int XmlUtf16Encode(int charNumber, unsigned short *buf);
|
||||||
|
|
||||||
|
int XmlSizeOfUnknownEncoding(void);
|
||||||
|
ENCODING *
|
||||||
|
XmlInitUnknownEncoding(void *mem,
|
||||||
|
int *table,
|
||||||
|
int (*conv)(void *userData, const char *p),
|
||||||
|
void *userData);
|
||||||
|
|
||||||
|
int XmlParseXmlDeclNS(int isGeneralTextEntity,
|
||||||
|
const ENCODING *enc,
|
||||||
|
const char *ptr,
|
||||||
|
const char *end,
|
||||||
|
const char **badPtr,
|
||||||
|
const char **versionPtr,
|
||||||
|
const char **versionEndPtr,
|
||||||
|
const char **encodingNamePtr,
|
||||||
|
const ENCODING **namedEncodingPtr,
|
||||||
|
int *standalonePtr);
|
||||||
|
int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||||
|
const ENCODING *XmlGetUtf8InternalEncodingNS(void);
|
||||||
|
const ENCODING *XmlGetUtf16InternalEncodingNS(void);
|
||||||
|
ENCODING *
|
||||||
|
XmlInitUnknownEncodingNS(void *mem,
|
||||||
|
int *table,
|
||||||
|
int (*conv)(void *userData, const char *p),
|
||||||
|
void *userData);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* not XmlTok_INCLUDED */
|
1778
contrib/expat/lib/xmltok_impl.c
Normal file
1778
contrib/expat/lib/xmltok_impl.c
Normal file
File diff suppressed because it is too large
Load Diff
46
contrib/expat/lib/xmltok_impl.h
Normal file
46
contrib/expat/lib/xmltok_impl.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum {
|
||||||
|
BT_NONXML,
|
||||||
|
BT_MALFORM,
|
||||||
|
BT_LT,
|
||||||
|
BT_AMP,
|
||||||
|
BT_RSQB,
|
||||||
|
BT_LEAD2,
|
||||||
|
BT_LEAD3,
|
||||||
|
BT_LEAD4,
|
||||||
|
BT_TRAIL,
|
||||||
|
BT_CR,
|
||||||
|
BT_LF,
|
||||||
|
BT_GT,
|
||||||
|
BT_QUOT,
|
||||||
|
BT_APOS,
|
||||||
|
BT_EQUALS,
|
||||||
|
BT_QUEST,
|
||||||
|
BT_EXCL,
|
||||||
|
BT_SOL,
|
||||||
|
BT_SEMI,
|
||||||
|
BT_NUM,
|
||||||
|
BT_LSQB,
|
||||||
|
BT_S,
|
||||||
|
BT_NMSTRT,
|
||||||
|
BT_COLON,
|
||||||
|
BT_HEX,
|
||||||
|
BT_DIGIT,
|
||||||
|
BT_NAME,
|
||||||
|
BT_MINUS,
|
||||||
|
BT_OTHER, /* known not to be a name or name start character */
|
||||||
|
BT_NONASCII, /* might be a name or name start character */
|
||||||
|
BT_PERCNT,
|
||||||
|
BT_LPAR,
|
||||||
|
BT_RPAR,
|
||||||
|
BT_AST,
|
||||||
|
BT_PLUS,
|
||||||
|
BT_COMMA,
|
||||||
|
BT_VERBAR
|
||||||
|
};
|
||||||
|
|
||||||
|
#include <stddef.h>
|
106
contrib/expat/lib/xmltok_ns.c
Normal file
106
contrib/expat/lib/xmltok_ns.c
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
const ENCODING *
|
||||||
|
NS(XmlGetUtf8InternalEncoding)(void)
|
||||||
|
{
|
||||||
|
return &ns(internal_utf8_encoding).enc;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ENCODING *
|
||||||
|
NS(XmlGetUtf16InternalEncoding)(void)
|
||||||
|
{
|
||||||
|
#if BYTEORDER == 1234
|
||||||
|
return &ns(internal_little2_encoding).enc;
|
||||||
|
#elif BYTEORDER == 4321
|
||||||
|
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 FASTCALL
|
||||||
|
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 FASTCALL
|
||||||
|
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;
|
||||||
|
SET_INIT_ENC_INDEX(p, 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, KW_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 **versionEndPtr,
|
||||||
|
const char **encodingName,
|
||||||
|
const ENCODING **encoding,
|
||||||
|
int *standalone)
|
||||||
|
{
|
||||||
|
return doParseXmlDecl(NS(findEncoding),
|
||||||
|
isGeneralTextEntity,
|
||||||
|
enc,
|
||||||
|
ptr,
|
||||||
|
end,
|
||||||
|
badPtr,
|
||||||
|
versionPtr,
|
||||||
|
versionEndPtr,
|
||||||
|
encodingName,
|
||||||
|
encoding,
|
||||||
|
standalone);
|
||||||
|
}
|
14
contrib/expat/tests/README.txt
Normal file
14
contrib/expat/tests/README.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
This directory contains the (fledgling) test suite for Expat. The
|
||||||
|
tests provide general unit testing and regression coverage. The tests
|
||||||
|
are not expected to be useful examples of Expat usage; see the
|
||||||
|
examples/ directory for that.
|
||||||
|
|
||||||
|
The Expat tests use the "Check" unit testing framework for C. More
|
||||||
|
information on Check can be found at:
|
||||||
|
|
||||||
|
http://check.sourceforge.net/
|
||||||
|
|
||||||
|
Check 0.8 must be installed before the unit tests can be compiled & run.
|
||||||
|
|
||||||
|
Since both Check and this test suite are young, it can all change in a
|
||||||
|
later version.
|
122
contrib/expat/tests/chardata.c
Normal file
122
contrib/expat/tests/chardata.c
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
/* chardata.c
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <check.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "chardata.h"
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
xmlstrlen(const XML_Char *s)
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
assert(s != NULL);
|
||||||
|
while (s[len] != 0)
|
||||||
|
++len;
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CharData_Init(CharData *storage)
|
||||||
|
{
|
||||||
|
assert(storage != NULL);
|
||||||
|
storage->count = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CharData_AppendString(CharData *storage, const char *s)
|
||||||
|
{
|
||||||
|
int maxchars = sizeof(storage->data) / sizeof(storage->data[0]);
|
||||||
|
int len;
|
||||||
|
|
||||||
|
assert(s != NULL);
|
||||||
|
len = strlen(s);
|
||||||
|
if (storage->count < 0)
|
||||||
|
storage->count = 0;
|
||||||
|
if ((len + storage->count) > maxchars) {
|
||||||
|
len = (maxchars - storage->count);
|
||||||
|
}
|
||||||
|
if (len + storage->count < sizeof(storage->data)) {
|
||||||
|
memcpy(storage->data + storage->count, s, len);
|
||||||
|
storage->count += len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CharData_AppendXMLChars(CharData *storage, const XML_Char *s, int len)
|
||||||
|
{
|
||||||
|
int maxchars;
|
||||||
|
|
||||||
|
assert(storage != NULL);
|
||||||
|
assert(s != NULL);
|
||||||
|
maxchars = sizeof(storage->data) / sizeof(storage->data[0]);
|
||||||
|
if (storage->count < 0)
|
||||||
|
storage->count = 0;
|
||||||
|
if (len < 0)
|
||||||
|
len = xmlstrlen(s);
|
||||||
|
if ((len + storage->count) > maxchars) {
|
||||||
|
len = (maxchars - storage->count);
|
||||||
|
}
|
||||||
|
if (len + storage->count < sizeof(storage->data)) {
|
||||||
|
memcpy(storage->data + storage->count, s,
|
||||||
|
len * sizeof(storage->data[0]));
|
||||||
|
storage->count += len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
CharData_CheckString(CharData *storage, const char *expected)
|
||||||
|
{
|
||||||
|
char buffer[1280];
|
||||||
|
int len;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
assert(storage != NULL);
|
||||||
|
assert(expected != NULL);
|
||||||
|
count = (storage->count < 0) ? 0 : storage->count;
|
||||||
|
len = strlen(expected);
|
||||||
|
if (len != count) {
|
||||||
|
if (sizeof(XML_Char) == 1)
|
||||||
|
sprintf(buffer, "wrong number of data characters:"
|
||||||
|
" got %d, expected %d:\n%s", count, len, storage->data);
|
||||||
|
else
|
||||||
|
sprintf(buffer,
|
||||||
|
"wrong number of data characters: got %d, expected %d",
|
||||||
|
count, len);
|
||||||
|
fail(buffer);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (memcmp(expected, storage->data, len) != 0) {
|
||||||
|
fail("got bad data bytes");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
CharData_CheckXMLChars(CharData *storage, const XML_Char *expected)
|
||||||
|
{
|
||||||
|
char buffer[1024];
|
||||||
|
int len = xmlstrlen(expected);
|
||||||
|
int count;
|
||||||
|
|
||||||
|
assert(storage != NULL);
|
||||||
|
count = (storage->count < 0) ? 0 : storage->count;
|
||||||
|
if (len != count) {
|
||||||
|
sprintf(buffer, "wrong number of data characters: got %d, expected %d",
|
||||||
|
count, len);
|
||||||
|
fail(buffer);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (memcmp(expected, storage->data, len * sizeof(storage->data[0])) != 0) {
|
||||||
|
fail("got bad data bytes");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
32
contrib/expat/tests/chardata.h
Normal file
32
contrib/expat/tests/chardata.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/* chardata.h
|
||||||
|
|
||||||
|
Interface to some helper routines used to accumulate and check text
|
||||||
|
and attribute content.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XML_CHARDATA_H
|
||||||
|
#define XML_CHARDATA_H 1
|
||||||
|
|
||||||
|
#ifndef XML_VERSION
|
||||||
|
#include "expat.h" /* need XML_Char */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int count; /* # of chars, < 0 if not set */
|
||||||
|
XML_Char data[1024];
|
||||||
|
} CharData;
|
||||||
|
|
||||||
|
|
||||||
|
void CharData_Init(CharData *storage);
|
||||||
|
|
||||||
|
void CharData_AppendString(CharData *storage, const char *s);
|
||||||
|
|
||||||
|
void CharData_AppendXMLChars(CharData *storage, const XML_Char *s, int len);
|
||||||
|
|
||||||
|
int CharData_CheckString(CharData *storage, const char *s);
|
||||||
|
|
||||||
|
int CharData_CheckXMLChars(CharData *storage, const XML_Char *s);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XML_CHARDATA_H */
|
882
contrib/expat/tests/runtests.c
Normal file
882
contrib/expat/tests/runtests.c
Normal file
@ -0,0 +1,882 @@
|
|||||||
|
#include <assert.h>
|
||||||
|
#include <check.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "expat.h"
|
||||||
|
#include "chardata.h"
|
||||||
|
|
||||||
|
|
||||||
|
static XML_Parser parser;
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
basic_setup(void)
|
||||||
|
{
|
||||||
|
parser = XML_ParserCreate(NULL);
|
||||||
|
if (parser == NULL)
|
||||||
|
fail("Parser not created.");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
basic_teardown(void)
|
||||||
|
{
|
||||||
|
if (parser != NULL)
|
||||||
|
XML_ParserFree(parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Generate a failure using the parser state to create an error message;
|
||||||
|
this should be used when the parser reports an error we weren't
|
||||||
|
expecting.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
_xml_failure(XML_Parser parser, const char *file, int line)
|
||||||
|
{
|
||||||
|
char buffer[1024];
|
||||||
|
sprintf(buffer,
|
||||||
|
"\n %s (line %d, offset %d)\n reported from %s, line %d",
|
||||||
|
XML_ErrorString(XML_GetErrorCode(parser)),
|
||||||
|
XML_GetCurrentLineNumber(parser),
|
||||||
|
XML_GetCurrentColumnNumber(parser),
|
||||||
|
file, line);
|
||||||
|
fail(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define xml_failure(parser) _xml_failure((parser), __FILE__, __LINE__)
|
||||||
|
|
||||||
|
static void
|
||||||
|
_expect_failure(char *text, enum XML_Error errorCode, char *errorMessage,
|
||||||
|
char *file, int lineno)
|
||||||
|
{
|
||||||
|
if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_OK)
|
||||||
|
fail(errorMessage);
|
||||||
|
if (XML_GetErrorCode(parser) != errorCode)
|
||||||
|
_xml_failure(parser, file, lineno);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define expect_failure(text, errorCode, errorMessage) \
|
||||||
|
_expect_failure((text), (errorCode), (errorMessage), \
|
||||||
|
__FILE__, __LINE__)
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Character & encoding tests.
|
||||||
|
*/
|
||||||
|
|
||||||
|
START_TEST(test_nul_byte)
|
||||||
|
{
|
||||||
|
char text[] = "<doc>\0</doc>";
|
||||||
|
|
||||||
|
/* test that a NUL byte (in US-ASCII data) is an error */
|
||||||
|
if (XML_Parse(parser, text, sizeof(text) - 1, 1) == XML_STATUS_OK)
|
||||||
|
fail("Parser did not report error on NUL-byte.");
|
||||||
|
if (XML_GetErrorCode(parser) != XML_ERROR_INVALID_TOKEN)
|
||||||
|
xml_failure(parser);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
|
||||||
|
START_TEST(test_u0000_char)
|
||||||
|
{
|
||||||
|
/* test that a NUL byte (in US-ASCII data) is an error */
|
||||||
|
expect_failure("<doc>�</doc>",
|
||||||
|
XML_ERROR_BAD_CHAR_REF,
|
||||||
|
"Parser did not report error on NUL-byte.");
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(test_bom_utf8)
|
||||||
|
{
|
||||||
|
/* This test is really just making sure we don't core on a UTF-8 BOM. */
|
||||||
|
char *text = "\357\273\277<e/>";
|
||||||
|
|
||||||
|
if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(test_bom_utf16_be)
|
||||||
|
{
|
||||||
|
char text[] = "\376\377\0<\0e\0/\0>";
|
||||||
|
|
||||||
|
if (XML_Parse(parser, text, sizeof(text) - 1, 1) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(test_bom_utf16_le)
|
||||||
|
{
|
||||||
|
char text[] = "\377\376<\0e\0/\0>\0";
|
||||||
|
|
||||||
|
if (XML_Parse(parser, text, sizeof(text) - 1, 1) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
accumulate_characters(void *userData, const XML_Char *s, int len)
|
||||||
|
{
|
||||||
|
CharData_AppendXMLChars((CharData *)userData, s, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
accumulate_attribute(void *userData, const XML_Char *name,
|
||||||
|
const XML_Char **atts)
|
||||||
|
{
|
||||||
|
CharData *storage = (CharData *)userData;
|
||||||
|
if (storage->count < 0 && atts != NULL && atts[0] != NULL) {
|
||||||
|
/* "accumulate" the value of the first attribute we see */
|
||||||
|
CharData_AppendXMLChars(storage, atts[1], -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
run_character_check(XML_Char *text, XML_Char *expected)
|
||||||
|
{
|
||||||
|
CharData storage;
|
||||||
|
|
||||||
|
CharData_Init(&storage);
|
||||||
|
XML_SetUserData(parser, &storage);
|
||||||
|
XML_SetCharacterDataHandler(parser, accumulate_characters);
|
||||||
|
if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
CharData_CheckXMLChars(&storage, expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
run_attribute_check(XML_Char *text, XML_Char *expected)
|
||||||
|
{
|
||||||
|
CharData storage;
|
||||||
|
|
||||||
|
CharData_Init(&storage);
|
||||||
|
XML_SetUserData(parser, &storage);
|
||||||
|
XML_SetStartElementHandler(parser, accumulate_attribute);
|
||||||
|
if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
CharData_CheckXMLChars(&storage, expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Regression test for SF bug #491986. */
|
||||||
|
START_TEST(test_danish_latin1)
|
||||||
|
{
|
||||||
|
char *text =
|
||||||
|
"<?xml version='1.0' encoding='iso-8859-1'?>\n"
|
||||||
|
"<e>Jørgen æøåÆØÅ</e>";
|
||||||
|
run_character_check(text,
|
||||||
|
"J\xC3\xB8rgen \xC3\xA6\xC3\xB8\xC3\xA5\xC3\x86\xC3\x98\xC3\x85");
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
|
||||||
|
/* Regression test for SF bug #514281. */
|
||||||
|
START_TEST(test_french_charref_hexidecimal)
|
||||||
|
{
|
||||||
|
char *text =
|
||||||
|
"<?xml version='1.0' encoding='iso-8859-1'?>\n"
|
||||||
|
"<doc>éèàçêÈ</doc>";
|
||||||
|
run_character_check(text,
|
||||||
|
"\xC3\xA9\xC3\xA8\xC3\xA0\xC3\xA7\xC3\xAA\xC3\x88");
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(test_french_charref_decimal)
|
||||||
|
{
|
||||||
|
char *text =
|
||||||
|
"<?xml version='1.0' encoding='iso-8859-1'?>\n"
|
||||||
|
"<doc>éèàçêÈ</doc>";
|
||||||
|
run_character_check(text,
|
||||||
|
"\xC3\xA9\xC3\xA8\xC3\xA0\xC3\xA7\xC3\xAA\xC3\x88");
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(test_french_latin1)
|
||||||
|
{
|
||||||
|
char *text =
|
||||||
|
"<?xml version='1.0' encoding='iso-8859-1'?>\n"
|
||||||
|
"<doc>\xE9\xE8\xE0\xE7\xEa\xC8</doc>";
|
||||||
|
run_character_check(text,
|
||||||
|
"\xC3\xA9\xC3\xA8\xC3\xA0\xC3\xA7\xC3\xAA\xC3\x88");
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(test_french_utf8)
|
||||||
|
{
|
||||||
|
char *text =
|
||||||
|
"<?xml version='1.0' encoding='utf-8'?>\n"
|
||||||
|
"<doc>\xC3\xA9</doc>";
|
||||||
|
run_character_check(text, "\xC3\xA9");
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
/* Regression test for SF bug #600479.
|
||||||
|
XXX There should be a test that exercises all legal XML Unicode
|
||||||
|
characters as PCDATA and attribute value content, and XML Name
|
||||||
|
characters as part of element and attribute names.
|
||||||
|
*/
|
||||||
|
START_TEST(test_utf8_false_rejection)
|
||||||
|
{
|
||||||
|
char *text = "<doc>\xEF\xBA\xBF</doc>";
|
||||||
|
run_character_check(text, "\xEF\xBA\xBF");
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
/* Regression test for SF bug #477667.
|
||||||
|
This test assures that any 8-bit character followed by a 7-bit
|
||||||
|
character will not be mistakenly interpreted as a valid UTF-8
|
||||||
|
sequence.
|
||||||
|
*/
|
||||||
|
START_TEST(test_illegal_utf8)
|
||||||
|
{
|
||||||
|
char text[100];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 128; i <= 255; ++i) {
|
||||||
|
sprintf(text, "<e>%ccd</e>", i);
|
||||||
|
if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_OK) {
|
||||||
|
sprintf(text,
|
||||||
|
"expected token error for '%c' (ordinal %d) in UTF-8 text",
|
||||||
|
i, i);
|
||||||
|
fail(text);
|
||||||
|
}
|
||||||
|
else if (XML_GetErrorCode(parser) != XML_ERROR_INVALID_TOKEN)
|
||||||
|
xml_failure(parser);
|
||||||
|
/* Reset the parser since we use the same parser repeatedly. */
|
||||||
|
XML_ParserReset(parser, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(test_utf16)
|
||||||
|
{
|
||||||
|
/* <?xml version="1.0" encoding="UTF-16"?>
|
||||||
|
<doc a='123'>some text</doc>
|
||||||
|
*/
|
||||||
|
char text[] =
|
||||||
|
"\000<\000?\000x\000m\000\154\000 \000v\000e\000r\000s\000i\000o"
|
||||||
|
"\000n\000=\000'\0001\000.\000\060\000'\000 \000e\000n\000c\000o"
|
||||||
|
"\000d\000i\000n\000g\000=\000'\000U\000T\000F\000-\0001\000\066"
|
||||||
|
"\000'\000?\000>\000\n"
|
||||||
|
"\000<\000d\000o\000c\000 \000a\000=\000'\0001\0002\0003\000'"
|
||||||
|
"\000>\000s\000o\000m\000e\000 \000t\000e\000x\000t\000<\000/"
|
||||||
|
"\000d\000o\000c\000>";
|
||||||
|
if (XML_Parse(parser, text, sizeof(text) - 1, 1) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(test_utf16_le_epilog_newline)
|
||||||
|
{
|
||||||
|
int first_chunk_bytes = 17;
|
||||||
|
char text[] =
|
||||||
|
"\xFF\xFE" /* BOM */
|
||||||
|
"<\000e\000/\000>\000" /* document element */
|
||||||
|
"\r\000\n\000\r\000\n\000"; /* epilog */
|
||||||
|
|
||||||
|
if (first_chunk_bytes >= sizeof(text) - 1)
|
||||||
|
fail("bad value of first_chunk_bytes");
|
||||||
|
if (XML_Parse(parser, text, first_chunk_bytes, 0) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
else {
|
||||||
|
enum XML_Status rc;
|
||||||
|
rc = XML_Parse(parser, text + first_chunk_bytes,
|
||||||
|
sizeof(text) - first_chunk_bytes - 1, 1);
|
||||||
|
if (rc == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
/* Regression test for SF bug #481609. */
|
||||||
|
START_TEST(test_latin1_umlauts)
|
||||||
|
{
|
||||||
|
char *text =
|
||||||
|
"<?xml version='1.0' encoding='iso-8859-1'?>\n"
|
||||||
|
"<e a='ä ö ü ä ö ü ä ö ü'\n"
|
||||||
|
" >ä ö ü ä ö ü ä ö ü</e>";
|
||||||
|
char *utf8 =
|
||||||
|
"\xC3\xA4 \xC3\xB6 \xC3\xBC "
|
||||||
|
"\xC3\xA4 \xC3\xB6 \xC3\xBC "
|
||||||
|
"\xC3\xA4 \xC3\xB6 \xC3\xBC";
|
||||||
|
run_character_check(text, utf8);
|
||||||
|
XML_ParserReset(parser, NULL);
|
||||||
|
run_attribute_check(text, utf8);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
/* Regression test for SF bug #422239 (maybe).
|
||||||
|
It's not clear that this reproduces enough of the context
|
||||||
|
of the reported bug.
|
||||||
|
*/
|
||||||
|
START_TEST(test_line_count)
|
||||||
|
{
|
||||||
|
char *text =
|
||||||
|
"<e>\n"
|
||||||
|
" <e/>\n"
|
||||||
|
"</e>";
|
||||||
|
int lineno;
|
||||||
|
if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
lineno = XML_GetCurrentLineNumber(parser);
|
||||||
|
if (lineno != 3) {
|
||||||
|
char buffer[100];
|
||||||
|
sprintf(buffer, "expected 3 lines, saw %d", lineno);
|
||||||
|
fail(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
/* Regression test for SF bug #478332. */
|
||||||
|
START_TEST(test_really_long_lines)
|
||||||
|
{
|
||||||
|
/* This parses an input line longer than INIT_DATA_BUF_SIZE
|
||||||
|
characters long (defined to be 1024 in xmlparse.c). We take a
|
||||||
|
really cheesy approach to building the input buffer, because
|
||||||
|
this avoids writing bugs in buffer-filling code.
|
||||||
|
*/
|
||||||
|
char *text =
|
||||||
|
"<e>"
|
||||||
|
/* 64 chars */
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
/* until we have at least 1024 characters on the line: */
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
|
||||||
|
"</e>";
|
||||||
|
if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Element event tests.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
end_element_event_handler(void *userData, const XML_Char *name)
|
||||||
|
{
|
||||||
|
CharData *storage = (CharData *) userData;
|
||||||
|
CharData_AppendString(storage, "/");
|
||||||
|
CharData_AppendXMLChars(storage, name, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(test_end_element_events)
|
||||||
|
{
|
||||||
|
char *text = "<a><b><c/></b><d><f/></d></a>";
|
||||||
|
char *expected = "/c/b/f/d/a";
|
||||||
|
CharData storage;
|
||||||
|
|
||||||
|
CharData_Init(&storage);
|
||||||
|
XML_SetUserData(parser, &storage);
|
||||||
|
XML_SetEndElementHandler(parser, end_element_event_handler);
|
||||||
|
if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
CharData_CheckString(&storage, expected);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Attribute tests.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Helpers used by the following test; this checks any "attr" and "refs"
|
||||||
|
attributes to make sure whitespace has been normalized.
|
||||||
|
|
||||||
|
Return true if whitespace has been normalized in a string, using
|
||||||
|
the rules for attribute value normalization. The 'is_cdata' flag
|
||||||
|
is needed since CDATA attributes don't need to have multiple
|
||||||
|
whitespace characters collapsed to a single space, while other
|
||||||
|
attribute data types do. (Section 3.3.3 of the recommendation.)
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
is_whitespace_normalized(const XML_Char *s, int is_cdata)
|
||||||
|
{
|
||||||
|
int blanks = 0;
|
||||||
|
int at_start = 1;
|
||||||
|
while (*s) {
|
||||||
|
if (*s == ' ')
|
||||||
|
++blanks;
|
||||||
|
else if (*s == '\t' || *s == '\n' || *s == '\r')
|
||||||
|
return 0;
|
||||||
|
else {
|
||||||
|
if (at_start) {
|
||||||
|
at_start = 0;
|
||||||
|
if (blanks && !is_cdata)
|
||||||
|
/* illegal leading blanks */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (blanks > 1 && !is_cdata)
|
||||||
|
return 0;
|
||||||
|
blanks = 0;
|
||||||
|
}
|
||||||
|
++s;
|
||||||
|
}
|
||||||
|
if (blanks && !is_cdata)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check the attribute whitespace checker: */
|
||||||
|
static void
|
||||||
|
testhelper_is_whitespace_normalized(void)
|
||||||
|
{
|
||||||
|
assert(is_whitespace_normalized("abc", 0));
|
||||||
|
assert(is_whitespace_normalized("abc", 1));
|
||||||
|
assert(is_whitespace_normalized("abc def ghi", 0));
|
||||||
|
assert(is_whitespace_normalized("abc def ghi", 1));
|
||||||
|
assert(!is_whitespace_normalized(" abc def ghi", 0));
|
||||||
|
assert(is_whitespace_normalized(" abc def ghi", 1));
|
||||||
|
assert(!is_whitespace_normalized("abc def ghi", 0));
|
||||||
|
assert(is_whitespace_normalized("abc def ghi", 1));
|
||||||
|
assert(!is_whitespace_normalized("abc def ghi ", 0));
|
||||||
|
assert(is_whitespace_normalized("abc def ghi ", 1));
|
||||||
|
assert(!is_whitespace_normalized(" ", 0));
|
||||||
|
assert(is_whitespace_normalized(" ", 1));
|
||||||
|
assert(!is_whitespace_normalized("\t", 0));
|
||||||
|
assert(!is_whitespace_normalized("\t", 1));
|
||||||
|
assert(!is_whitespace_normalized("\n", 0));
|
||||||
|
assert(!is_whitespace_normalized("\n", 1));
|
||||||
|
assert(!is_whitespace_normalized("\r", 0));
|
||||||
|
assert(!is_whitespace_normalized("\r", 1));
|
||||||
|
assert(!is_whitespace_normalized("abc\t def", 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
check_attr_contains_normalized_whitespace(void *userData,
|
||||||
|
const XML_Char *name,
|
||||||
|
const XML_Char **atts)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; atts[i] != NULL; i += 2) {
|
||||||
|
const XML_Char *attrname = atts[i];
|
||||||
|
const XML_Char *value = atts[i + 1];
|
||||||
|
if (strcmp("attr", attrname) == 0
|
||||||
|
|| strcmp("ents", attrname) == 0
|
||||||
|
|| strcmp("refs", attrname) == 0) {
|
||||||
|
if (!is_whitespace_normalized(value, 0)) {
|
||||||
|
char buffer[256];
|
||||||
|
sprintf(buffer, "attribute value not normalized: %s='%s'",
|
||||||
|
attrname, value);
|
||||||
|
fail(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(test_attr_whitespace_normalization)
|
||||||
|
{
|
||||||
|
char *text =
|
||||||
|
"<!DOCTYPE doc [\n"
|
||||||
|
" <!ATTLIST doc\n"
|
||||||
|
" attr NMTOKENS #REQUIRED\n"
|
||||||
|
" ents ENTITIES #REQUIRED\n"
|
||||||
|
" refs IDREFS #REQUIRED>\n"
|
||||||
|
"]>\n"
|
||||||
|
"<doc attr=' a b c\t\td\te\t' refs=' id-1 \t id-2\t\t' \n"
|
||||||
|
" ents=' ent-1 \t\r\n"
|
||||||
|
" ent-2 ' >\n"
|
||||||
|
" <e id='id-1'/>\n"
|
||||||
|
" <e id='id-2'/>\n"
|
||||||
|
"</doc>";
|
||||||
|
|
||||||
|
XML_SetStartElementHandler(parser,
|
||||||
|
check_attr_contains_normalized_whitespace);
|
||||||
|
if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XML declaration tests.
|
||||||
|
*/
|
||||||
|
|
||||||
|
START_TEST(test_xmldecl_misplaced)
|
||||||
|
{
|
||||||
|
expect_failure("\n"
|
||||||
|
"<?xml version='1.0'?>\n"
|
||||||
|
"<a/>",
|
||||||
|
XML_ERROR_MISPLACED_XML_PI,
|
||||||
|
"failed to report misplaced XML declaration");
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
/* Regression test for SF bug #584832. */
|
||||||
|
static int
|
||||||
|
UnknownEncodingHandler(void *data,const XML_Char *encoding,XML_Encoding *info)
|
||||||
|
{
|
||||||
|
if (strcmp(encoding,"unsupported-encoding") == 0) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 256; ++i)
|
||||||
|
info->map[i] = i;
|
||||||
|
info->data=NULL;
|
||||||
|
info->convert=NULL;
|
||||||
|
info->release=NULL;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(test_unknown_encoding_internal_entity)
|
||||||
|
{
|
||||||
|
char *text =
|
||||||
|
"<?xml version='1.0' encoding='unsupported-encoding'?>\n"
|
||||||
|
"<!DOCTYPE test [<!ENTITY foo 'bar'>]>\n"
|
||||||
|
"<test a='&foo;'/>";
|
||||||
|
|
||||||
|
XML_SetUnknownEncodingHandler(parser, UnknownEncodingHandler, NULL);
|
||||||
|
if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
/* Test that no error is reported for unknown entities if we don't
|
||||||
|
read an external subset. This was fixed in Expat 1.95.5.
|
||||||
|
*/
|
||||||
|
START_TEST(test_wfc_undeclared_entity_unread_external_subset) {
|
||||||
|
char *text =
|
||||||
|
"<!DOCTYPE doc SYSTEM 'foo'>\n"
|
||||||
|
"<doc>&entity;</doc>";
|
||||||
|
|
||||||
|
if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
/* Test that an error is reported for unknown entities if we don't
|
||||||
|
have an external subset.
|
||||||
|
*/
|
||||||
|
START_TEST(test_wfc_undeclared_entity_no_external_subset) {
|
||||||
|
expect_failure("<doc>&entity;</doc>",
|
||||||
|
XML_ERROR_UNDEFINED_ENTITY,
|
||||||
|
"Parser did not report undefined entity w/out a DTD.");
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
/* Test that an error is reported for unknown entities if we don't
|
||||||
|
read an external subset, but have been declared standalone.
|
||||||
|
*/
|
||||||
|
START_TEST(test_wfc_undeclared_entity_standalone) {
|
||||||
|
char *text =
|
||||||
|
"<?xml version='1.0' encoding='us-ascii' standalone='yes'?>\n"
|
||||||
|
"<!DOCTYPE doc SYSTEM 'foo'>\n"
|
||||||
|
"<doc>&entity;</doc>";
|
||||||
|
|
||||||
|
expect_failure(text,
|
||||||
|
XML_ERROR_UNDEFINED_ENTITY,
|
||||||
|
"Parser did not report undefined entity (standalone).");
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static int
|
||||||
|
external_entity_loader(XML_Parser parser,
|
||||||
|
const XML_Char *context,
|
||||||
|
const XML_Char *base,
|
||||||
|
const XML_Char *systemId,
|
||||||
|
const XML_Char *publicId)
|
||||||
|
{
|
||||||
|
char *text = (char *)XML_GetUserData(parser);
|
||||||
|
XML_Parser extparser;
|
||||||
|
|
||||||
|
extparser = XML_ExternalEntityParserCreate(parser, context, NULL);
|
||||||
|
if (extparser == NULL)
|
||||||
|
fail("Could not create external entity parser.");
|
||||||
|
if (XML_Parse(extparser, text, strlen(text), 1) == XML_STATUS_ERROR) {
|
||||||
|
xml_failure(parser);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test that an error is reported for unknown entities if we have read
|
||||||
|
an external subset.
|
||||||
|
*/
|
||||||
|
START_TEST(test_wfc_undeclared_entity_with_external_subset) {
|
||||||
|
char *text =
|
||||||
|
"<?xml version='1.0' encoding='us-ascii'?>\n"
|
||||||
|
"<!DOCTYPE doc SYSTEM 'foo'>\n"
|
||||||
|
"<doc>&entity;</doc>";
|
||||||
|
char *foo_text =
|
||||||
|
"<!ELEMENT doc (#PCDATA)*>";
|
||||||
|
|
||||||
|
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
|
||||||
|
XML_SetUserData(parser, foo_text);
|
||||||
|
XML_SetExternalEntityRefHandler(parser, external_entity_loader);
|
||||||
|
expect_failure(text,
|
||||||
|
XML_ERROR_UNDEFINED_ENTITY,
|
||||||
|
"Parser did not report undefined entity with DTD.");
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(test_wfc_no_recursive_entity_refs)
|
||||||
|
{
|
||||||
|
char *text =
|
||||||
|
"<!DOCTYPE doc [\n"
|
||||||
|
" <!ENTITY entity '&entity;'>\n"
|
||||||
|
"]>\n"
|
||||||
|
"<doc>&entity;</doc>";
|
||||||
|
|
||||||
|
expect_failure(text,
|
||||||
|
XML_ERROR_RECURSIVE_ENTITY_REF,
|
||||||
|
"Parser did not report recursive entity reference.");
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Namespaces tests.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
namespace_setup(void)
|
||||||
|
{
|
||||||
|
parser = XML_ParserCreateNS(NULL, ' ');
|
||||||
|
if (parser == NULL)
|
||||||
|
fail("Parser not created.");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
namespace_teardown(void)
|
||||||
|
{
|
||||||
|
basic_teardown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check that an element name and attribute name match the expected values.
|
||||||
|
The expected values are passed as an array reference of string pointers
|
||||||
|
provided as the userData argument; the first is the expected
|
||||||
|
element name, and the second is the expected attribute name.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
triplet_start_checker(void *userData, const XML_Char *name,
|
||||||
|
const XML_Char **atts)
|
||||||
|
{
|
||||||
|
char **elemstr = (char **)userData;
|
||||||
|
char buffer[1024];
|
||||||
|
if (strcmp(elemstr[0], name) != 0) {
|
||||||
|
sprintf(buffer, "unexpected start string: '%s'", name);
|
||||||
|
fail(buffer);
|
||||||
|
}
|
||||||
|
if (strcmp(elemstr[1], atts[0]) != 0) {
|
||||||
|
sprintf(buffer, "unexpected attribute string: '%s'", atts[0]);
|
||||||
|
fail(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check that the element name passed to the end-element handler matches
|
||||||
|
the expected value. The expected value is passed as the first element
|
||||||
|
in an array of strings passed as the userData argument.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
triplet_end_checker(void *userData, const XML_Char *name)
|
||||||
|
{
|
||||||
|
char **elemstr = (char **)userData;
|
||||||
|
if (strcmp(elemstr[0], name) != 0) {
|
||||||
|
char buffer[1024];
|
||||||
|
sprintf(buffer, "unexpected end string: '%s'", name);
|
||||||
|
fail(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(test_return_ns_triplet)
|
||||||
|
{
|
||||||
|
char *text =
|
||||||
|
"<foo:e xmlns:foo='http://expat.sf.net/' bar:a='12'\n"
|
||||||
|
" xmlns:bar='http://expat.sf.net/'></foo:e>";
|
||||||
|
char *elemstr[] = {
|
||||||
|
"http://expat.sf.net/ e foo",
|
||||||
|
"http://expat.sf.net/ a bar"
|
||||||
|
};
|
||||||
|
XML_SetReturnNSTriplet(parser, 1);
|
||||||
|
XML_SetUserData(parser, elemstr);
|
||||||
|
XML_SetElementHandler(parser, triplet_start_checker, triplet_end_checker);
|
||||||
|
if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static void
|
||||||
|
overwrite_start_checker(void *userData, const XML_Char *name,
|
||||||
|
const XML_Char **atts)
|
||||||
|
{
|
||||||
|
CharData *storage = (CharData *) userData;
|
||||||
|
CharData_AppendString(storage, "start ");
|
||||||
|
CharData_AppendXMLChars(storage, name, -1);
|
||||||
|
while (*atts != NULL) {
|
||||||
|
CharData_AppendString(storage, "\nattribute ");
|
||||||
|
CharData_AppendXMLChars(storage, *atts, -1);
|
||||||
|
atts += 2;
|
||||||
|
}
|
||||||
|
CharData_AppendString(storage, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
overwrite_end_checker(void *userData, const XML_Char *name)
|
||||||
|
{
|
||||||
|
CharData *storage = (CharData *) userData;
|
||||||
|
CharData_AppendString(storage, "end ");
|
||||||
|
CharData_AppendXMLChars(storage, name, -1);
|
||||||
|
CharData_AppendString(storage, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
run_ns_tagname_overwrite_test(char *text, char *result)
|
||||||
|
{
|
||||||
|
CharData storage;
|
||||||
|
CharData_Init(&storage);
|
||||||
|
XML_SetUserData(parser, &storage);
|
||||||
|
XML_SetElementHandler(parser,
|
||||||
|
overwrite_start_checker, overwrite_end_checker);
|
||||||
|
if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
|
||||||
|
xml_failure(parser);
|
||||||
|
CharData_CheckString(&storage, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Regression test for SF bug #566334. */
|
||||||
|
START_TEST(test_ns_tagname_overwrite)
|
||||||
|
{
|
||||||
|
char *text =
|
||||||
|
"<n:e xmlns:n='http://xml.libexpat.org/'>\n"
|
||||||
|
" <n:f n:attr='foo'/>\n"
|
||||||
|
" <n:g n:attr2='bar'/>\n"
|
||||||
|
"</n:e>";
|
||||||
|
char *result =
|
||||||
|
"start http://xml.libexpat.org/ e\n"
|
||||||
|
"start http://xml.libexpat.org/ f\n"
|
||||||
|
"attribute http://xml.libexpat.org/ attr\n"
|
||||||
|
"end http://xml.libexpat.org/ f\n"
|
||||||
|
"start http://xml.libexpat.org/ g\n"
|
||||||
|
"attribute http://xml.libexpat.org/ attr2\n"
|
||||||
|
"end http://xml.libexpat.org/ g\n"
|
||||||
|
"end http://xml.libexpat.org/ e\n";
|
||||||
|
run_ns_tagname_overwrite_test(text, result);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
/* Regression test for SF bug #566334. */
|
||||||
|
START_TEST(test_ns_tagname_overwrite_triplet)
|
||||||
|
{
|
||||||
|
char *text =
|
||||||
|
"<n:e xmlns:n='http://xml.libexpat.org/'>\n"
|
||||||
|
" <n:f n:attr='foo'/>\n"
|
||||||
|
" <n:g n:attr2='bar'/>\n"
|
||||||
|
"</n:e>";
|
||||||
|
char *result =
|
||||||
|
"start http://xml.libexpat.org/ e n\n"
|
||||||
|
"start http://xml.libexpat.org/ f n\n"
|
||||||
|
"attribute http://xml.libexpat.org/ attr n\n"
|
||||||
|
"end http://xml.libexpat.org/ f n\n"
|
||||||
|
"start http://xml.libexpat.org/ g n\n"
|
||||||
|
"attribute http://xml.libexpat.org/ attr2 n\n"
|
||||||
|
"end http://xml.libexpat.org/ g n\n"
|
||||||
|
"end http://xml.libexpat.org/ e n\n";
|
||||||
|
XML_SetReturnNSTriplet(parser, 1);
|
||||||
|
run_ns_tagname_overwrite_test(text, result);
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
static Suite *
|
||||||
|
make_basic_suite(void)
|
||||||
|
{
|
||||||
|
Suite *s = suite_create("basic");
|
||||||
|
TCase *tc_basic = tcase_create("basic tests");
|
||||||
|
TCase *tc_namespace = tcase_create("XML namespaces");
|
||||||
|
|
||||||
|
suite_add_tcase(s, tc_basic);
|
||||||
|
tcase_add_checked_fixture(tc_basic, basic_setup, basic_teardown);
|
||||||
|
tcase_add_test(tc_basic, test_nul_byte);
|
||||||
|
tcase_add_test(tc_basic, test_u0000_char);
|
||||||
|
tcase_add_test(tc_basic, test_bom_utf8);
|
||||||
|
tcase_add_test(tc_basic, test_bom_utf16_be);
|
||||||
|
tcase_add_test(tc_basic, test_bom_utf16_le);
|
||||||
|
tcase_add_test(tc_basic, test_illegal_utf8);
|
||||||
|
tcase_add_test(tc_basic, test_utf16);
|
||||||
|
tcase_add_test(tc_basic, test_utf16_le_epilog_newline);
|
||||||
|
tcase_add_test(tc_basic, test_latin1_umlauts);
|
||||||
|
/* Regression test for SF bug #491986. */
|
||||||
|
tcase_add_test(tc_basic, test_danish_latin1);
|
||||||
|
/* Regression test for SF bug #514281. */
|
||||||
|
tcase_add_test(tc_basic, test_french_charref_hexidecimal);
|
||||||
|
tcase_add_test(tc_basic, test_french_charref_decimal);
|
||||||
|
tcase_add_test(tc_basic, test_french_latin1);
|
||||||
|
tcase_add_test(tc_basic, test_french_utf8);
|
||||||
|
tcase_add_test(tc_basic, test_utf8_false_rejection);
|
||||||
|
tcase_add_test(tc_basic, test_line_count);
|
||||||
|
tcase_add_test(tc_basic, test_really_long_lines);
|
||||||
|
tcase_add_test(tc_basic, test_end_element_events);
|
||||||
|
tcase_add_test(tc_basic, test_attr_whitespace_normalization);
|
||||||
|
tcase_add_test(tc_basic, test_xmldecl_misplaced);
|
||||||
|
tcase_add_test(tc_basic, test_unknown_encoding_internal_entity);
|
||||||
|
tcase_add_test(tc_basic,
|
||||||
|
test_wfc_undeclared_entity_unread_external_subset);
|
||||||
|
tcase_add_test(tc_basic, test_wfc_undeclared_entity_no_external_subset);
|
||||||
|
tcase_add_test(tc_basic, test_wfc_undeclared_entity_standalone);
|
||||||
|
tcase_add_test(tc_basic, test_wfc_undeclared_entity_with_external_subset);
|
||||||
|
tcase_add_test(tc_basic, test_wfc_no_recursive_entity_refs);
|
||||||
|
|
||||||
|
suite_add_tcase(s, tc_namespace);
|
||||||
|
tcase_add_checked_fixture(tc_namespace,
|
||||||
|
namespace_setup, namespace_teardown);
|
||||||
|
tcase_add_test(tc_namespace, test_return_ns_triplet);
|
||||||
|
tcase_add_test(tc_namespace, test_ns_tagname_overwrite);
|
||||||
|
tcase_add_test(tc_namespace, test_ns_tagname_overwrite_triplet);
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int i, nf;
|
||||||
|
int forking = 0, forking_set = 0;
|
||||||
|
int verbosity = CK_NORMAL;
|
||||||
|
Suite *s = make_basic_suite();
|
||||||
|
SRunner *sr = srunner_create(s);
|
||||||
|
|
||||||
|
/* run the tests for internal helper functions */
|
||||||
|
testhelper_is_whitespace_normalized();
|
||||||
|
|
||||||
|
for (i = 1; i < argc; ++i) {
|
||||||
|
char *opt = argv[i];
|
||||||
|
if (strcmp(opt, "-v") == 0 || strcmp(opt, "--verbose") == 0)
|
||||||
|
verbosity = CK_VERBOSE;
|
||||||
|
else if (strcmp(opt, "-q") == 0 || strcmp(opt, "--quiet") == 0)
|
||||||
|
verbosity = CK_SILENT;
|
||||||
|
else if (strcmp(opt, "-f") == 0 || strcmp(opt, "--fork") == 0) {
|
||||||
|
forking = 1;
|
||||||
|
forking_set = 1;
|
||||||
|
}
|
||||||
|
else if (strcmp(opt, "-n") == 0 || strcmp(opt, "--no-fork") == 0) {
|
||||||
|
forking = 0;
|
||||||
|
forking_set = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stderr, "runtests: unknown option '%s'\n", opt);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (forking_set)
|
||||||
|
srunner_set_fork_status(sr, forking ? CK_FORK : CK_NOFORK);
|
||||||
|
srunner_run_all(sr, verbosity);
|
||||||
|
nf = srunner_ntests_failed(sr);
|
||||||
|
srunner_free(sr);
|
||||||
|
suite_free(s);
|
||||||
|
|
||||||
|
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
}
|
137
contrib/expat/tests/xmltest.sh
Executable file
137
contrib/expat/tests/xmltest.sh
Executable file
@ -0,0 +1,137 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
# EXPAT TEST SCRIPT FOR W3C XML TEST SUITE
|
||||||
|
|
||||||
|
# This script can be used to exercise Expat against the
|
||||||
|
# w3c.org xml test suite, available from
|
||||||
|
# http://www.w3.org/XML/Test/xmlts20020606.zip.
|
||||||
|
|
||||||
|
# To run this script, first set XMLWF so that xmlwf can be
|
||||||
|
# found, then set the output directory with OUTPUT.
|
||||||
|
|
||||||
|
# The script lists all test cases where Expat shows a discrepancy
|
||||||
|
# from the expected result. Test cases where only the canonical
|
||||||
|
# output differs are prefixed with "Output differs:", and a diff file
|
||||||
|
# is generated in the appropriate subdirectory under $OUTPUT.
|
||||||
|
|
||||||
|
# If there are output files provided, the script will use
|
||||||
|
# output from xmlwf and compare the desired output against it.
|
||||||
|
# However, one has to take into account that the canonical output
|
||||||
|
# produced by xmlwf conforms to an older definition of canonical XML
|
||||||
|
# and does not generate notation declarations.
|
||||||
|
|
||||||
|
MYDIR="`dirname \"$0\"`"
|
||||||
|
cd "$MYDIR"
|
||||||
|
MYDIR="`pwd`"
|
||||||
|
XMLWF="`dirname \"$MYDIR\"`/xmlwf/xmlwf"
|
||||||
|
# XMLWF=/usr/local/bin/xmlwf
|
||||||
|
TS="$MYDIR/XML-Test-Suite"
|
||||||
|
# OUTPUT must terminate with the directory separator.
|
||||||
|
OUTPUT="$TS/out/"
|
||||||
|
# OUTPUT=/home/tmp/xml-testsuite-out/
|
||||||
|
|
||||||
|
|
||||||
|
RunXmlwfNotWF() {
|
||||||
|
$XMLWF $1 $2 > outfile || return $?
|
||||||
|
read outdata < outfile
|
||||||
|
if test "$outdata" = "" ; then
|
||||||
|
echo "Well formed: $3$2"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
RunXmlwfWF() {
|
||||||
|
$XMLWF $1 -d "$OUTPUT$3" $2 > outfile || return $?
|
||||||
|
read outdata < outfile
|
||||||
|
if test "$outdata" = "" ; then
|
||||||
|
if [ -f out/$2 ] ; then
|
||||||
|
diff "$OUTPUT$3$2" out/$2 > outfile
|
||||||
|
if [ -s outfile ] ; then
|
||||||
|
cp outfile $OUTPUT$3${2}.diff
|
||||||
|
echo "Output differs: $3$2"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "In $3: $outdata"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
SUCCESS=0
|
||||||
|
ERROR=0
|
||||||
|
|
||||||
|
##########################
|
||||||
|
# well-formed test cases #
|
||||||
|
##########################
|
||||||
|
|
||||||
|
cd "$TS/xmlconf"
|
||||||
|
for xmldir in ibm/valid/P*/ \
|
||||||
|
ibm/invalid/P*/ \
|
||||||
|
xmltest/valid/ext-sa/ \
|
||||||
|
xmltest/valid/not-sa/ \
|
||||||
|
xmltest/invalid/ \
|
||||||
|
xmltest/invalid/not-sa/ \
|
||||||
|
xmltest/valid/sa/ \
|
||||||
|
sun/valid/ \
|
||||||
|
sun/invalid/ ; do
|
||||||
|
cd "$TS/xmlconf/$xmldir"
|
||||||
|
mkdir -p "$OUTPUT$xmldir"
|
||||||
|
for xmlfile in *.xml ; do
|
||||||
|
if RunXmlwfWF -p "$xmlfile" "$xmldir" ; then
|
||||||
|
SUCCESS=`expr $SUCCESS + 1`
|
||||||
|
else
|
||||||
|
ERROR=`expr $ERROR + 1`
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
rm outfile
|
||||||
|
done
|
||||||
|
|
||||||
|
cd "$TS/xmlconf/oasis"
|
||||||
|
mkdir -p "$OUTPUT"oasis/
|
||||||
|
for xmlfile in *pass*.xml ; do
|
||||||
|
if RunXmlwfWF -p "$xmlfile" "oasis/" ; then
|
||||||
|
SUCCESS=`expr $SUCCESS + 1`
|
||||||
|
else
|
||||||
|
ERROR=`expr $ERROR + 1`
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
rm outfile
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# not well-formed test cases #
|
||||||
|
##############################
|
||||||
|
|
||||||
|
cd "$TS/xmlconf"
|
||||||
|
for xmldir in ibm/not-wf/P*/ \
|
||||||
|
ibm/not-wf/misc/ \
|
||||||
|
xmltest/not-wf/ext-sa/ \
|
||||||
|
xmltest/not-wf/not-sa/ \
|
||||||
|
xmltest/not-wf/sa/ \
|
||||||
|
sun/not-wf/ ; do
|
||||||
|
cd "$TS/xmlconf/$xmldir"
|
||||||
|
for xmlfile in *.xml ; do
|
||||||
|
if RunXmlwfNotWF -p "$xmlfile" "$xmldir" ; then
|
||||||
|
SUCCESS=`expr $SUCCESS + 1`
|
||||||
|
else
|
||||||
|
ERROR=`expr $ERROR + 1`
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
rm outfile
|
||||||
|
done
|
||||||
|
|
||||||
|
cd "$TS/xmlconf/oasis"
|
||||||
|
for xmlfile in *fail*.xml ; do
|
||||||
|
if RunXmlwfNotWF -p "$xmlfile" "oasis/" ; then
|
||||||
|
SUCCESS=`expr $SUCCESS + 1`
|
||||||
|
else
|
||||||
|
ERROR=`expr $ERROR + 1`
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
rm outfile
|
||||||
|
|
||||||
|
echo "Passed: $SUCCESS"
|
||||||
|
echo "Failed: $ERROR"
|
68
contrib/expat/xmlwf/codepage.c
Executable file
68
contrib/expat/xmlwf/codepage.c
Executable file
@ -0,0 +1,68 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "codepage.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define STRICT 1
|
||||||
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
codepageMap(int cp, int *map)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
CPINFO info;
|
||||||
|
if (!GetCPInfo(cp, &info) || info.MaxCharSize > 2)
|
||||||
|
return 0;
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
|
map[i] = -1;
|
||||||
|
if (info.MaxCharSize > 1) {
|
||||||
|
for (i = 0; i < MAX_LEADBYTES; i++) {
|
||||||
|
int j, lim;
|
||||||
|
if (info.LeadByte[i] == 0 && info.LeadByte[i + 1] == 0)
|
||||||
|
break;
|
||||||
|
lim = info.LeadByte[i + 1];
|
||||||
|
for (j = info.LeadByte[i]; j < lim; j++)
|
||||||
|
map[j] = -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = 0; i < 256; i++) {
|
||||||
|
if (map[i] == -1) {
|
||||||
|
char c = (char)i;
|
||||||
|
unsigned short n;
|
||||||
|
if (MultiByteToWideChar(cp, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
|
||||||
|
&c, 1, &n, 1) == 1)
|
||||||
|
map[i] = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
codepageConvert(int cp, const char *p)
|
||||||
|
{
|
||||||
|
unsigned short c;
|
||||||
|
if (MultiByteToWideChar(cp, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
|
||||||
|
p, 2, &c, 1) == 1)
|
||||||
|
return c;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* not WIN32 */
|
||||||
|
|
||||||
|
int
|
||||||
|
codepageMap(int cp, int *map)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
codepageConvert(int cp, const char *p)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* not WIN32 */
|
6
contrib/expat/xmlwf/codepage.h
Executable file
6
contrib/expat/xmlwf/codepage.h
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int codepageMap(int cp, int *map);
|
||||||
|
int codepageConvert(int cp, const char *p);
|
147
contrib/expat/xmlwf/ct.c
Executable file
147
contrib/expat/xmlwf/ct.c
Executable file
@ -0,0 +1,147 @@
|
|||||||
|
#define CHARSET_MAX 41
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
getTok(const char **pp)
|
||||||
|
{
|
||||||
|
enum { inAtom, inString, init, inComment };
|
||||||
|
int state = init;
|
||||||
|
const char *tokStart = 0;
|
||||||
|
for (;;) {
|
||||||
|
switch (**pp) {
|
||||||
|
case '\0':
|
||||||
|
return 0;
|
||||||
|
case ' ':
|
||||||
|
case '\r':
|
||||||
|
case '\t':
|
||||||
|
case '\n':
|
||||||
|
if (state == inAtom)
|
||||||
|
return tokStart;
|
||||||
|
break;
|
||||||
|
case '(':
|
||||||
|
if (state == inAtom)
|
||||||
|
return tokStart;
|
||||||
|
if (state != inString)
|
||||||
|
state++;
|
||||||
|
break;
|
||||||
|
case ')':
|
||||||
|
if (state > init)
|
||||||
|
--state;
|
||||||
|
else if (state != inString)
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case ';':
|
||||||
|
case '/':
|
||||||
|
case '=':
|
||||||
|
if (state == inAtom)
|
||||||
|
return tokStart;
|
||||||
|
if (state == init)
|
||||||
|
return (*pp)++;
|
||||||
|
break;
|
||||||
|
case '\\':
|
||||||
|
++*pp;
|
||||||
|
if (**pp == '\0')
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case '"':
|
||||||
|
switch (state) {
|
||||||
|
case inString:
|
||||||
|
++*pp;
|
||||||
|
return tokStart;
|
||||||
|
case inAtom:
|
||||||
|
return tokStart;
|
||||||
|
case init:
|
||||||
|
tokStart = *pp;
|
||||||
|
state = inString;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (state == init) {
|
||||||
|
tokStart = *pp;
|
||||||
|
state = inAtom;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++*pp;
|
||||||
|
}
|
||||||
|
/* not reached */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* key must be lowercase ASCII */
|
||||||
|
|
||||||
|
static int
|
||||||
|
matchkey(const char *start, const char *end, const char *key)
|
||||||
|
{
|
||||||
|
if (!start)
|
||||||
|
return 0;
|
||||||
|
for (; start != end; start++, key++)
|
||||||
|
if (*start != *key && *start != 'A' + (*key - 'a'))
|
||||||
|
return 0;
|
||||||
|
return *key == '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
getXMLCharset(const char *buf, char *charset)
|
||||||
|
{
|
||||||
|
const char *next, *p;
|
||||||
|
|
||||||
|
charset[0] = '\0';
|
||||||
|
next = buf;
|
||||||
|
p = getTok(&next);
|
||||||
|
if (matchkey(p, next, "text"))
|
||||||
|
strcpy(charset, "us-ascii");
|
||||||
|
else if (!matchkey(p, next, "application"))
|
||||||
|
return;
|
||||||
|
p = getTok(&next);
|
||||||
|
if (!p || *p != '/')
|
||||||
|
return;
|
||||||
|
p = getTok(&next);
|
||||||
|
if (matchkey(p, next, "xml"))
|
||||||
|
isXml = 1;
|
||||||
|
p = getTok(&next);
|
||||||
|
while (p) {
|
||||||
|
if (*p == ';') {
|
||||||
|
p = getTok(&next);
|
||||||
|
if (matchkey(p, next, "charset")) {
|
||||||
|
p = getTok(&next);
|
||||||
|
if (p && *p == '=') {
|
||||||
|
p = getTok(&next);
|
||||||
|
if (p) {
|
||||||
|
char *s = charset;
|
||||||
|
if (*p == '"') {
|
||||||
|
while (++p != next - 1) {
|
||||||
|
if (*p == '\\')
|
||||||
|
++p;
|
||||||
|
if (s == charset + CHARSET_MAX - 1) {
|
||||||
|
charset[0] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*s++ = *p;
|
||||||
|
}
|
||||||
|
*s++ = '\0';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (next - p > CHARSET_MAX - 1)
|
||||||
|
break;
|
||||||
|
while (p != next)
|
||||||
|
*s++ = *p++;
|
||||||
|
*s = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
p = getTok(&next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
char buf[CHARSET_MAX];
|
||||||
|
getXMLCharset(argv[1], buf);
|
||||||
|
printf("charset = \"%s\"\n", buf);
|
||||||
|
return 0;
|
||||||
|
}
|
17
contrib/expat/xmlwf/filemap.h
Executable file
17
contrib/expat/xmlwf/filemap.h
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#ifdef XML_UNICODE
|
||||||
|
int filemap(const wchar_t *name,
|
||||||
|
void (*processor)(const void *, size_t,
|
||||||
|
const wchar_t *, void *arg),
|
||||||
|
void *arg);
|
||||||
|
#else
|
||||||
|
int filemap(const char *name,
|
||||||
|
void (*processor)(const void *, size_t,
|
||||||
|
const char *, void *arg),
|
||||||
|
void *arg);
|
||||||
|
#endif
|
76
contrib/expat/xmlwf/readfilemap.c
Executable file
76
contrib/expat/xmlwf/readfilemap.c
Executable file
@ -0,0 +1,76 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifndef S_ISREG
|
||||||
|
#ifndef S_IFREG
|
||||||
|
#define S_IFREG _S_IFREG
|
||||||
|
#endif
|
||||||
|
#ifndef S_IFMT
|
||||||
|
#define S_IFMT _S_IFMT
|
||||||
|
#endif
|
||||||
|
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||||
|
#endif /* not S_ISREG */
|
||||||
|
|
||||||
|
#ifndef O_BINARY
|
||||||
|
#ifdef _O_BINARY
|
||||||
|
#define O_BINARY _O_BINARY
|
||||||
|
#else
|
||||||
|
#define O_BINARY 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "filemap.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
filemap(const char *name,
|
||||||
|
void (*processor)(const void *, size_t, const char *, void *arg),
|
||||||
|
void *arg)
|
||||||
|
{
|
||||||
|
size_t nbytes;
|
||||||
|
int fd;
|
||||||
|
int n;
|
||||||
|
struct stat sb;
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
fd = open(name, O_RDONLY|O_BINARY);
|
||||||
|
if (fd < 0) {
|
||||||
|
perror(name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (fstat(fd, &sb) < 0) {
|
||||||
|
perror(name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!S_ISREG(sb.st_mode)) {
|
||||||
|
fprintf(stderr, "%s: not a regular file\n", name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
nbytes = sb.st_size;
|
||||||
|
p = malloc(nbytes);
|
||||||
|
if (!p) {
|
||||||
|
fprintf(stderr, "%s: out of memory\n", name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
n = read(fd, p, nbytes);
|
||||||
|
if (n < 0) {
|
||||||
|
perror(name);
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (n != nbytes) {
|
||||||
|
fprintf(stderr, "%s: read unexpected number of bytes\n", name);
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
processor(p, nbytes, name, arg);
|
||||||
|
free(p);
|
||||||
|
close(fd);
|
||||||
|
return 1;
|
||||||
|
}
|
58
contrib/expat/xmlwf/unixfilemap.c
Executable file
58
contrib/expat/xmlwf/unixfilemap.c
Executable file
@ -0,0 +1,58 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifndef MAP_FILE
|
||||||
|
#define MAP_FILE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "filemap.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
filemap(const char *name,
|
||||||
|
void (*processor)(const void *, size_t, const char *, void *arg),
|
||||||
|
void *arg)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
size_t nbytes;
|
||||||
|
struct stat sb;
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
fd = open(name, O_RDONLY);
|
||||||
|
if (fd < 0) {
|
||||||
|
perror(name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (fstat(fd, &sb) < 0) {
|
||||||
|
perror(name);
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!S_ISREG(sb.st_mode)) {
|
||||||
|
close(fd);
|
||||||
|
fprintf(stderr, "%s: not a regular file\n", name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nbytes = sb.st_size;
|
||||||
|
p = (void *)mmap((caddr_t)0, (size_t)nbytes, PROT_READ,
|
||||||
|
MAP_FILE|MAP_PRIVATE, fd, (off_t)0);
|
||||||
|
if (p == (void *)-1) {
|
||||||
|
perror(name);
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
processor(p, nbytes, name, arg);
|
||||||
|
munmap((caddr_t)p, nbytes);
|
||||||
|
close(fd);
|
||||||
|
return 1;
|
||||||
|
}
|
96
contrib/expat/xmlwf/win32filemap.c
Executable file
96
contrib/expat/xmlwf/win32filemap.c
Executable file
@ -0,0 +1,96 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define STRICT 1
|
||||||
|
#define WIN32_LEAN_AND_MEAN 1
|
||||||
|
|
||||||
|
#ifdef XML_UNICODE_WCHAR_T
|
||||||
|
#ifndef XML_UNICODE
|
||||||
|
#define XML_UNICODE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef XML_UNICODE
|
||||||
|
#define UNICODE
|
||||||
|
#define _UNICODE
|
||||||
|
#endif /* XML_UNICODE */
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
#include "filemap.h"
|
||||||
|
|
||||||
|
static void win32perror(const TCHAR *);
|
||||||
|
|
||||||
|
int
|
||||||
|
filemap(const TCHAR *name,
|
||||||
|
void (*processor)(const void *, size_t, const TCHAR *, void *arg),
|
||||||
|
void *arg)
|
||||||
|
{
|
||||||
|
HANDLE f;
|
||||||
|
HANDLE m;
|
||||||
|
DWORD size;
|
||||||
|
DWORD sizeHi;
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
f = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
||||||
|
FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||||
|
if (f == INVALID_HANDLE_VALUE) {
|
||||||
|
win32perror(name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
size = GetFileSize(f, &sizeHi);
|
||||||
|
if (size == (DWORD)-1) {
|
||||||
|
win32perror(name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (sizeHi) {
|
||||||
|
_ftprintf(stderr, _T("%s: bigger than 2Gb\n"), name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* CreateFileMapping barfs on zero length files */
|
||||||
|
if (size == 0) {
|
||||||
|
static const char c = '\0';
|
||||||
|
processor(&c, 0, name, arg);
|
||||||
|
CloseHandle(f);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
m = CreateFileMapping(f, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||||
|
if (m == NULL) {
|
||||||
|
win32perror(name);
|
||||||
|
CloseHandle(f);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
p = MapViewOfFile(m, FILE_MAP_READ, 0, 0, 0);
|
||||||
|
if (p == NULL) {
|
||||||
|
win32perror(name);
|
||||||
|
CloseHandle(m);
|
||||||
|
CloseHandle(f);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
processor(p, size, name, arg);
|
||||||
|
UnmapViewOfFile(p);
|
||||||
|
CloseHandle(m);
|
||||||
|
CloseHandle(f);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
win32perror(const TCHAR *s)
|
||||||
|
{
|
||||||
|
LPVOID buf;
|
||||||
|
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||||
|
| FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
|
NULL,
|
||||||
|
GetLastError(),
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
(LPTSTR) &buf,
|
||||||
|
0,
|
||||||
|
NULL)) {
|
||||||
|
_ftprintf(stderr, _T("%s: %s"), s, buf);
|
||||||
|
fflush(stderr);
|
||||||
|
LocalFree(buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_ftprintf(stderr, _T("%s: unknown Windows error\n"), s);
|
||||||
|
}
|
231
contrib/expat/xmlwf/xmlfile.c
Executable file
231
contrib/expat/xmlwf/xmlfile.c
Executable file
@ -0,0 +1,231 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#ifdef COMPILED_FROM_DSP
|
||||||
|
#include "winconfig.h"
|
||||||
|
#else
|
||||||
|
#include "expat_config.h"
|
||||||
|
#endif
|
||||||
|
#include "expat.h"
|
||||||
|
#include "xmlfile.h"
|
||||||
|
#include "xmltchar.h"
|
||||||
|
#include "filemap.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_BINARY
|
||||||
|
#ifdef _O_BINARY
|
||||||
|
#define O_BINARY _O_BINARY
|
||||||
|
#else
|
||||||
|
#define O_BINARY 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#define READ_SIZE 16
|
||||||
|
#else
|
||||||
|
#define READ_SIZE (1024*8)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
XML_Parser parser;
|
||||||
|
int *retPtr;
|
||||||
|
} PROCESS_ARGS;
|
||||||
|
|
||||||
|
static void
|
||||||
|
reportError(XML_Parser parser, const XML_Char *filename)
|
||||||
|
{
|
||||||
|
int code = XML_GetErrorCode(parser);
|
||||||
|
const XML_Char *message = XML_ErrorString(code);
|
||||||
|
if (message)
|
||||||
|
ftprintf(stdout, T("%s:%d:%d: %s\n"),
|
||||||
|
filename,
|
||||||
|
XML_GetErrorLineNumber(parser),
|
||||||
|
XML_GetErrorColumnNumber(parser),
|
||||||
|
message);
|
||||||
|
else
|
||||||
|
ftprintf(stderr, T("%s: (unknown message %d)\n"), filename, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
processFile(const void *data, size_t size,
|
||||||
|
const XML_Char *filename, void *args)
|
||||||
|
{
|
||||||
|
XML_Parser parser = ((PROCESS_ARGS *)args)->parser;
|
||||||
|
int *retPtr = ((PROCESS_ARGS *)args)->retPtr;
|
||||||
|
if (XML_Parse(parser, data, size, 1) == XML_STATUS_ERROR) {
|
||||||
|
reportError(parser, filename);
|
||||||
|
*retPtr = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*retPtr = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
|
static int
|
||||||
|
isAsciiLetter(XML_Char c)
|
||||||
|
{
|
||||||
|
return (T('a') <= c && c <= T('z')) || (T('A') <= c && c <= T('Z'));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* WIN32 */
|
||||||
|
|
||||||
|
static const XML_Char *
|
||||||
|
resolveSystemId(const XML_Char *base, const XML_Char *systemId,
|
||||||
|
XML_Char **toFree)
|
||||||
|
{
|
||||||
|
XML_Char *s;
|
||||||
|
*toFree = 0;
|
||||||
|
if (!base
|
||||||
|
|| *systemId == T('/')
|
||||||
|
#ifdef WIN32
|
||||||
|
|| *systemId == T('\\')
|
||||||
|
|| (isAsciiLetter(systemId[0]) && systemId[1] == T(':'))
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
return systemId;
|
||||||
|
*toFree = (XML_Char *)malloc((tcslen(base) + tcslen(systemId) + 2)
|
||||||
|
* sizeof(XML_Char));
|
||||||
|
if (!*toFree)
|
||||||
|
return systemId;
|
||||||
|
tcscpy(*toFree, base);
|
||||||
|
s = *toFree;
|
||||||
|
if (tcsrchr(s, T('/')))
|
||||||
|
s = tcsrchr(s, T('/')) + 1;
|
||||||
|
#ifdef WIN32
|
||||||
|
if (tcsrchr(s, T('\\')))
|
||||||
|
s = tcsrchr(s, T('\\')) + 1;
|
||||||
|
#endif
|
||||||
|
tcscpy(s, systemId);
|
||||||
|
return *toFree;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
externalEntityRefFilemap(XML_Parser parser,
|
||||||
|
const XML_Char *context,
|
||||||
|
const XML_Char *base,
|
||||||
|
const XML_Char *systemId,
|
||||||
|
const XML_Char *publicId)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
XML_Char *s;
|
||||||
|
const XML_Char *filename;
|
||||||
|
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, context, 0);
|
||||||
|
PROCESS_ARGS args;
|
||||||
|
args.retPtr = &result;
|
||||||
|
args.parser = entParser;
|
||||||
|
filename = resolveSystemId(base, systemId, &s);
|
||||||
|
XML_SetBase(entParser, filename);
|
||||||
|
if (!filemap(filename, processFile, &args))
|
||||||
|
result = 0;
|
||||||
|
free(s);
|
||||||
|
XML_ParserFree(entParser);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
processStream(const XML_Char *filename, XML_Parser parser)
|
||||||
|
{
|
||||||
|
/* passing NULL for filename means read intput from stdin */
|
||||||
|
int fd = 0; /* 0 is the fileno for stdin */
|
||||||
|
|
||||||
|
if (filename != NULL) {
|
||||||
|
fd = topen(filename, O_BINARY|O_RDONLY);
|
||||||
|
if (fd < 0) {
|
||||||
|
tperror(filename);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (;;) {
|
||||||
|
int nread;
|
||||||
|
char *buf = XML_GetBuffer(parser, READ_SIZE);
|
||||||
|
if (!buf) {
|
||||||
|
if (filename != NULL)
|
||||||
|
close(fd);
|
||||||
|
ftprintf(stderr, T("%s: out of memory\n"),
|
||||||
|
filename != NULL ? filename : "xmlwf");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
nread = read(fd, buf, READ_SIZE);
|
||||||
|
if (nread < 0) {
|
||||||
|
tperror(filename != NULL ? filename : "STDIN");
|
||||||
|
if (filename != NULL)
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (XML_ParseBuffer(parser, nread, nread == 0) == XML_STATUS_ERROR) {
|
||||||
|
reportError(parser, filename != NULL ? filename : "STDIN");
|
||||||
|
if (filename != NULL)
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (nread == 0) {
|
||||||
|
if (filename != NULL)
|
||||||
|
close(fd);
|
||||||
|
break;;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
externalEntityRefStream(XML_Parser parser,
|
||||||
|
const XML_Char *context,
|
||||||
|
const XML_Char *base,
|
||||||
|
const XML_Char *systemId,
|
||||||
|
const XML_Char *publicId)
|
||||||
|
{
|
||||||
|
XML_Char *s;
|
||||||
|
const XML_Char *filename;
|
||||||
|
int ret;
|
||||||
|
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, context, 0);
|
||||||
|
filename = resolveSystemId(base, systemId, &s);
|
||||||
|
XML_SetBase(entParser, filename);
|
||||||
|
ret = processStream(filename, entParser);
|
||||||
|
free(s);
|
||||||
|
XML_ParserFree(entParser);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
XML_ProcessFile(XML_Parser parser,
|
||||||
|
const XML_Char *filename,
|
||||||
|
unsigned flags)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
if (!XML_SetBase(parser, filename)) {
|
||||||
|
ftprintf(stderr, T("%s: out of memory"), filename);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & XML_EXTERNAL_ENTITIES)
|
||||||
|
XML_SetExternalEntityRefHandler(parser,
|
||||||
|
(flags & XML_MAP_FILE)
|
||||||
|
? externalEntityRefFilemap
|
||||||
|
: externalEntityRefStream);
|
||||||
|
if (flags & XML_MAP_FILE) {
|
||||||
|
PROCESS_ARGS args;
|
||||||
|
args.retPtr = &result;
|
||||||
|
args.parser = parser;
|
||||||
|
if (!filemap(filename, processFile, &args))
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
result = processStream(filename, parser);
|
||||||
|
return result;
|
||||||
|
}
|
10
contrib/expat/xmlwf/xmlfile.h
Executable file
10
contrib/expat/xmlwf/xmlfile.h
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define XML_MAP_FILE 01
|
||||||
|
#define XML_EXTERNAL_ENTITIES 02
|
||||||
|
|
||||||
|
extern int XML_ProcessFile(XML_Parser parser,
|
||||||
|
const XML_Char *filename,
|
||||||
|
unsigned flags);
|
163
contrib/expat/xmlwf/xmlmime.c
Executable file
163
contrib/expat/xmlwf/xmlmime.c
Executable file
@ -0,0 +1,163 @@
|
|||||||
|
#include <string.h>
|
||||||
|
#include "xmlmime.h"
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
getTok(const char **pp)
|
||||||
|
{
|
||||||
|
/* inComment means one level of nesting; inComment+1 means two levels etc */
|
||||||
|
enum { inAtom, inString, init, inComment };
|
||||||
|
int state = init;
|
||||||
|
const char *tokStart = 0;
|
||||||
|
for (;;) {
|
||||||
|
switch (**pp) {
|
||||||
|
case '\0':
|
||||||
|
if (state == inAtom)
|
||||||
|
return tokStart;
|
||||||
|
return 0;
|
||||||
|
case ' ':
|
||||||
|
case '\r':
|
||||||
|
case '\t':
|
||||||
|
case '\n':
|
||||||
|
if (state == inAtom)
|
||||||
|
return tokStart;
|
||||||
|
break;
|
||||||
|
case '(':
|
||||||
|
if (state == inAtom)
|
||||||
|
return tokStart;
|
||||||
|
if (state != inString)
|
||||||
|
state++;
|
||||||
|
break;
|
||||||
|
case ')':
|
||||||
|
if (state > init)
|
||||||
|
--state;
|
||||||
|
else if (state != inString)
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case ';':
|
||||||
|
case '/':
|
||||||
|
case '=':
|
||||||
|
if (state == inAtom)
|
||||||
|
return tokStart;
|
||||||
|
if (state == init)
|
||||||
|
return (*pp)++;
|
||||||
|
break;
|
||||||
|
case '\\':
|
||||||
|
++*pp;
|
||||||
|
if (**pp == '\0')
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case '"':
|
||||||
|
switch (state) {
|
||||||
|
case inString:
|
||||||
|
++*pp;
|
||||||
|
return tokStart;
|
||||||
|
case inAtom:
|
||||||
|
return tokStart;
|
||||||
|
case init:
|
||||||
|
tokStart = *pp;
|
||||||
|
state = inString;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (state == init) {
|
||||||
|
tokStart = *pp;
|
||||||
|
state = inAtom;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++*pp;
|
||||||
|
}
|
||||||
|
/* not reached */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* key must be lowercase ASCII */
|
||||||
|
|
||||||
|
static int
|
||||||
|
matchkey(const char *start, const char *end, const char *key)
|
||||||
|
{
|
||||||
|
if (!start)
|
||||||
|
return 0;
|
||||||
|
for (; start != end; start++, key++)
|
||||||
|
if (*start != *key && *start != 'A' + (*key - 'a'))
|
||||||
|
return 0;
|
||||||
|
return *key == '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
getXMLCharset(const char *buf, char *charset)
|
||||||
|
{
|
||||||
|
const char *next, *p;
|
||||||
|
|
||||||
|
charset[0] = '\0';
|
||||||
|
next = buf;
|
||||||
|
p = getTok(&next);
|
||||||
|
if (matchkey(p, next, "text"))
|
||||||
|
strcpy(charset, "us-ascii");
|
||||||
|
else if (!matchkey(p, next, "application"))
|
||||||
|
return;
|
||||||
|
p = getTok(&next);
|
||||||
|
if (!p || *p != '/')
|
||||||
|
return;
|
||||||
|
p = getTok(&next);
|
||||||
|
#if 0
|
||||||
|
if (!matchkey(p, next, "xml") && charset[0] == '\0')
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
p = getTok(&next);
|
||||||
|
while (p) {
|
||||||
|
if (*p == ';') {
|
||||||
|
p = getTok(&next);
|
||||||
|
if (matchkey(p, next, "charset")) {
|
||||||
|
p = getTok(&next);
|
||||||
|
if (p && *p == '=') {
|
||||||
|
p = getTok(&next);
|
||||||
|
if (p) {
|
||||||
|
char *s = charset;
|
||||||
|
if (*p == '"') {
|
||||||
|
while (++p != next - 1) {
|
||||||
|
if (*p == '\\')
|
||||||
|
++p;
|
||||||
|
if (s == charset + CHARSET_MAX - 1) {
|
||||||
|
charset[0] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*s++ = *p;
|
||||||
|
}
|
||||||
|
*s++ = '\0';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (next - p > CHARSET_MAX - 1)
|
||||||
|
break;
|
||||||
|
while (p != next)
|
||||||
|
*s++ = *p++;
|
||||||
|
*s = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
p = getTok(&next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TEST
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char buf[CHARSET_MAX];
|
||||||
|
if (argc <= 1)
|
||||||
|
return 1;
|
||||||
|
printf("%s\n", argv[1]);
|
||||||
|
getXMLCharset(argv[1], buf);
|
||||||
|
printf("charset=\"%s\"\n", buf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* TEST */
|
19
contrib/expat/xmlwf/xmlmime.h
Executable file
19
contrib/expat/xmlwf/xmlmime.h
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Registered charset names are at most 40 characters long. */
|
||||||
|
|
||||||
|
#define CHARSET_MAX 41
|
||||||
|
|
||||||
|
/* Figure out the charset to use from the ContentType.
|
||||||
|
buf contains the body of the header field (the part after "Content-Type:").
|
||||||
|
charset gets the charset to use. It must be at least CHARSET_MAX chars
|
||||||
|
long. charset will be empty if the default charset should be used.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void getXMLCharset(const char *buf, char *charset);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
36
contrib/expat/xmlwf/xmltchar.h
Executable file
36
contrib/expat/xmlwf/xmltchar.h
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
#ifdef XML_UNICODE
|
||||||
|
#ifndef XML_UNICODE_WCHAR_T
|
||||||
|
#error xmlwf requires a 16-bit Unicode-compatible wchar_t
|
||||||
|
#endif
|
||||||
|
#define T(x) L ## x
|
||||||
|
#define ftprintf fwprintf
|
||||||
|
#define tfopen _wfopen
|
||||||
|
#define fputts fputws
|
||||||
|
#define puttc putwc
|
||||||
|
#define tcscmp wcscmp
|
||||||
|
#define tcscpy wcscpy
|
||||||
|
#define tcscat wcscat
|
||||||
|
#define tcschr wcschr
|
||||||
|
#define tcsrchr wcsrchr
|
||||||
|
#define tcslen wcslen
|
||||||
|
#define tperror _wperror
|
||||||
|
#define topen _wopen
|
||||||
|
#define tmain wmain
|
||||||
|
#define tremove _wremove
|
||||||
|
#else /* not XML_UNICODE */
|
||||||
|
#define T(x) x
|
||||||
|
#define ftprintf fprintf
|
||||||
|
#define tfopen fopen
|
||||||
|
#define fputts fputs
|
||||||
|
#define puttc putc
|
||||||
|
#define tcscmp strcmp
|
||||||
|
#define tcscpy strcpy
|
||||||
|
#define tcscat strcat
|
||||||
|
#define tcschr strchr
|
||||||
|
#define tcsrchr strrchr
|
||||||
|
#define tcslen strlen
|
||||||
|
#define tperror perror
|
||||||
|
#define topen open
|
||||||
|
#define tmain main
|
||||||
|
#define tremove remove
|
||||||
|
#endif /* not XML_UNICODE */
|
13
contrib/expat/xmlwf/xmlurl.h
Executable file
13
contrib/expat/xmlwf/xmlurl.h
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int XML_URLInit();
|
||||||
|
void XML_URLUninit();
|
||||||
|
int XML_ProcessURL(XML_Parser parser,
|
||||||
|
const XML_Char *url,
|
||||||
|
unsigned flags);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
842
contrib/expat/xmlwf/xmlwf.c
Executable file
842
contrib/expat/xmlwf/xmlwf.c
Executable file
@ -0,0 +1,842 @@
|
|||||||
|
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||||
|
See the file COPYING for copying permission.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "expat.h"
|
||||||
|
#include "codepage.h"
|
||||||
|
#include "xmlfile.h"
|
||||||
|
#include "xmltchar.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <crtdbg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This ensures proper sorting. */
|
||||||
|
|
||||||
|
#define NSSEP T('\001')
|
||||||
|
|
||||||
|
static void
|
||||||
|
characterData(void *userData, const XML_Char *s, int len)
|
||||||
|
{
|
||||||
|
FILE *fp = userData;
|
||||||
|
for (; len > 0; --len, ++s) {
|
||||||
|
switch (*s) {
|
||||||
|
case T('&'):
|
||||||
|
fputts(T("&"), fp);
|
||||||
|
break;
|
||||||
|
case T('<'):
|
||||||
|
fputts(T("<"), fp);
|
||||||
|
break;
|
||||||
|
case T('>'):
|
||||||
|
fputts(T(">"), fp);
|
||||||
|
break;
|
||||||
|
#ifdef W3C14N
|
||||||
|
case 13:
|
||||||
|
fputts(T("
"), fp);
|
||||||
|
break;
|
||||||
|
#else
|
||||||
|
case T('"'):
|
||||||
|
fputts(T("""), fp);
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
case 10:
|
||||||
|
case 13:
|
||||||
|
ftprintf(fp, T("&#%d;"), *s);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
puttc(*s, fp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
attributeValue(FILE *fp, const XML_Char *s)
|
||||||
|
{
|
||||||
|
puttc(T('='), fp);
|
||||||
|
puttc(T('"'), fp);
|
||||||
|
for (;;) {
|
||||||
|
switch (*s) {
|
||||||
|
case 0:
|
||||||
|
case NSSEP:
|
||||||
|
puttc(T('"'), fp);
|
||||||
|
return;
|
||||||
|
case T('&'):
|
||||||
|
fputts(T("&"), fp);
|
||||||
|
break;
|
||||||
|
case T('<'):
|
||||||
|
fputts(T("<"), fp);
|
||||||
|
break;
|
||||||
|
case T('"'):
|
||||||
|
fputts(T("""), fp);
|
||||||
|
break;
|
||||||
|
#ifdef W3C14N
|
||||||
|
case 9:
|
||||||
|
fputts(T("	"), fp);
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
fputts(T("
"), fp);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
fputts(T("
"), fp);
|
||||||
|
break;
|
||||||
|
#else
|
||||||
|
case T('>'):
|
||||||
|
fputts(T(">"), fp);
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
case 10:
|
||||||
|
case 13:
|
||||||
|
ftprintf(fp, T("&#%d;"), *s);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
puttc(*s, fp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Lexicographically comparing UTF-8 encoded attribute values,
|
||||||
|
is equivalent to lexicographically comparing based on the character number. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
attcmp(const void *att1, const void *att2)
|
||||||
|
{
|
||||||
|
return tcscmp(*(const XML_Char **)att1, *(const XML_Char **)att2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
startElement(void *userData, const XML_Char *name, const XML_Char **atts)
|
||||||
|
{
|
||||||
|
int nAtts;
|
||||||
|
const XML_Char **p;
|
||||||
|
FILE *fp = userData;
|
||||||
|
puttc(T('<'), fp);
|
||||||
|
fputts(name, fp);
|
||||||
|
|
||||||
|
p = atts;
|
||||||
|
while (*p)
|
||||||
|
++p;
|
||||||
|
nAtts = (p - atts) >> 1;
|
||||||
|
if (nAtts > 1)
|
||||||
|
qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, attcmp);
|
||||||
|
while (*atts) {
|
||||||
|
puttc(T(' '), fp);
|
||||||
|
fputts(*atts++, fp);
|
||||||
|
attributeValue(fp, *atts);
|
||||||
|
atts++;
|
||||||
|
}
|
||||||
|
puttc(T('>'), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
endElement(void *userData, const XML_Char *name)
|
||||||
|
{
|
||||||
|
FILE *fp = userData;
|
||||||
|
puttc(T('<'), fp);
|
||||||
|
puttc(T('/'), fp);
|
||||||
|
fputts(name, fp);
|
||||||
|
puttc(T('>'), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
nsattcmp(const void *p1, const void *p2)
|
||||||
|
{
|
||||||
|
const XML_Char *att1 = *(const XML_Char **)p1;
|
||||||
|
const XML_Char *att2 = *(const XML_Char **)p2;
|
||||||
|
int sep1 = (tcsrchr(att1, NSSEP) != 0);
|
||||||
|
int sep2 = (tcsrchr(att1, NSSEP) != 0);
|
||||||
|
if (sep1 != sep2)
|
||||||
|
return sep1 - sep2;
|
||||||
|
return tcscmp(att1, att2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
startElementNS(void *userData, const XML_Char *name, const XML_Char **atts)
|
||||||
|
{
|
||||||
|
int nAtts;
|
||||||
|
int nsi;
|
||||||
|
const XML_Char **p;
|
||||||
|
FILE *fp = userData;
|
||||||
|
const XML_Char *sep;
|
||||||
|
puttc(T('<'), fp);
|
||||||
|
|
||||||
|
sep = tcsrchr(name, NSSEP);
|
||||||
|
if (sep) {
|
||||||
|
fputts(T("n1:"), fp);
|
||||||
|
fputts(sep + 1, fp);
|
||||||
|
fputts(T(" xmlns:n1"), fp);
|
||||||
|
attributeValue(fp, name);
|
||||||
|
nsi = 2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fputts(name, fp);
|
||||||
|
nsi = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = atts;
|
||||||
|
while (*p)
|
||||||
|
++p;
|
||||||
|
nAtts = (p - atts) >> 1;
|
||||||
|
if (nAtts > 1)
|
||||||
|
qsort((void *)atts, nAtts, sizeof(XML_Char *) * 2, nsattcmp);
|
||||||
|
while (*atts) {
|
||||||
|
name = *atts++;
|
||||||
|
sep = tcsrchr(name, NSSEP);
|
||||||
|
puttc(T(' '), fp);
|
||||||
|
if (sep) {
|
||||||
|
ftprintf(fp, T("n%d:"), nsi);
|
||||||
|
fputts(sep + 1, fp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fputts(name, fp);
|
||||||
|
attributeValue(fp, *atts);
|
||||||
|
if (sep) {
|
||||||
|
ftprintf(fp, T(" xmlns:n%d"), nsi++);
|
||||||
|
attributeValue(fp, name);
|
||||||
|
}
|
||||||
|
atts++;
|
||||||
|
}
|
||||||
|
puttc(T('>'), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
endElementNS(void *userData, const XML_Char *name)
|
||||||
|
{
|
||||||
|
FILE *fp = userData;
|
||||||
|
const XML_Char *sep;
|
||||||
|
puttc(T('<'), fp);
|
||||||
|
puttc(T('/'), fp);
|
||||||
|
sep = tcsrchr(name, NSSEP);
|
||||||
|
if (sep) {
|
||||||
|
fputts(T("n1:"), fp);
|
||||||
|
fputts(sep + 1, fp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fputts(name, fp);
|
||||||
|
puttc(T('>'), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef W3C14N
|
||||||
|
|
||||||
|
static void
|
||||||
|
processingInstruction(void *userData, const XML_Char *target,
|
||||||
|
const XML_Char *data)
|
||||||
|
{
|
||||||
|
FILE *fp = userData;
|
||||||
|
puttc(T('<'), fp);
|
||||||
|
puttc(T('?'), fp);
|
||||||
|
fputts(target, fp);
|
||||||
|
puttc(T(' '), fp);
|
||||||
|
fputts(data, fp);
|
||||||
|
puttc(T('?'), fp);
|
||||||
|
puttc(T('>'), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* not W3C14N */
|
||||||
|
|
||||||
|
static void
|
||||||
|
defaultCharacterData(void *userData, const XML_Char *s, int len)
|
||||||
|
{
|
||||||
|
XML_DefaultCurrent((XML_Parser) userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
defaultStartElement(void *userData, const XML_Char *name,
|
||||||
|
const XML_Char **atts)
|
||||||
|
{
|
||||||
|
XML_DefaultCurrent((XML_Parser) userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
defaultEndElement(void *userData, const XML_Char *name)
|
||||||
|
{
|
||||||
|
XML_DefaultCurrent((XML_Parser) userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
defaultProcessingInstruction(void *userData, const XML_Char *target,
|
||||||
|
const XML_Char *data)
|
||||||
|
{
|
||||||
|
XML_DefaultCurrent((XML_Parser) userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nopCharacterData(void *userData, const XML_Char *s, int len)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nopStartElement(void *userData, const XML_Char *name, const XML_Char **atts)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nopEndElement(void *userData, const XML_Char *name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nopProcessingInstruction(void *userData, const XML_Char *target,
|
||||||
|
const XML_Char *data)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
markup(void *userData, const XML_Char *s, int len)
|
||||||
|
{
|
||||||
|
FILE *fp = XML_GetUserData((XML_Parser) userData);
|
||||||
|
for (; len > 0; --len, ++s)
|
||||||
|
puttc(*s, fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaLocation(XML_Parser parser)
|
||||||
|
{
|
||||||
|
const XML_Char *uri = XML_GetBase(parser);
|
||||||
|
if (uri)
|
||||||
|
ftprintf(XML_GetUserData(parser), T(" uri=\"%s\""), uri);
|
||||||
|
ftprintf(XML_GetUserData(parser),
|
||||||
|
T(" byte=\"%ld\" nbytes=\"%d\" line=\"%d\" col=\"%d\""),
|
||||||
|
XML_GetCurrentByteIndex(parser),
|
||||||
|
XML_GetCurrentByteCount(parser),
|
||||||
|
XML_GetCurrentLineNumber(parser),
|
||||||
|
XML_GetCurrentColumnNumber(parser));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaStartDocument(void *userData)
|
||||||
|
{
|
||||||
|
fputts(T("<document>\n"), XML_GetUserData((XML_Parser) userData));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaEndDocument(void *userData)
|
||||||
|
{
|
||||||
|
fputts(T("</document>\n"), XML_GetUserData((XML_Parser) userData));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaStartElement(void *userData, const XML_Char *name,
|
||||||
|
const XML_Char **atts)
|
||||||
|
{
|
||||||
|
XML_Parser parser = (XML_Parser) userData;
|
||||||
|
FILE *fp = XML_GetUserData(parser);
|
||||||
|
const XML_Char **specifiedAttsEnd
|
||||||
|
= atts + XML_GetSpecifiedAttributeCount(parser);
|
||||||
|
const XML_Char **idAttPtr;
|
||||||
|
int idAttIndex = XML_GetIdAttributeIndex(parser);
|
||||||
|
if (idAttIndex < 0)
|
||||||
|
idAttPtr = 0;
|
||||||
|
else
|
||||||
|
idAttPtr = atts + idAttIndex;
|
||||||
|
|
||||||
|
ftprintf(fp, T("<starttag name=\"%s\""), name);
|
||||||
|
metaLocation(parser);
|
||||||
|
if (*atts) {
|
||||||
|
fputts(T(">\n"), fp);
|
||||||
|
do {
|
||||||
|
ftprintf(fp, T("<attribute name=\"%s\" value=\""), atts[0]);
|
||||||
|
characterData(fp, atts[1], tcslen(atts[1]));
|
||||||
|
if (atts >= specifiedAttsEnd)
|
||||||
|
fputts(T("\" defaulted=\"yes\"/>\n"), fp);
|
||||||
|
else if (atts == idAttPtr)
|
||||||
|
fputts(T("\" id=\"yes\"/>\n"), fp);
|
||||||
|
else
|
||||||
|
fputts(T("\"/>\n"), fp);
|
||||||
|
} while (*(atts += 2));
|
||||||
|
fputts(T("</starttag>\n"), fp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fputts(T("/>\n"), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaEndElement(void *userData, const XML_Char *name)
|
||||||
|
{
|
||||||
|
XML_Parser parser = (XML_Parser) userData;
|
||||||
|
FILE *fp = XML_GetUserData(parser);
|
||||||
|
ftprintf(fp, T("<endtag name=\"%s\""), name);
|
||||||
|
metaLocation(parser);
|
||||||
|
fputts(T("/>\n"), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaProcessingInstruction(void *userData, const XML_Char *target,
|
||||||
|
const XML_Char *data)
|
||||||
|
{
|
||||||
|
XML_Parser parser = (XML_Parser) userData;
|
||||||
|
FILE *fp = XML_GetUserData(parser);
|
||||||
|
ftprintf(fp, T("<pi target=\"%s\" data=\""), target);
|
||||||
|
characterData(fp, data, tcslen(data));
|
||||||
|
puttc(T('"'), fp);
|
||||||
|
metaLocation(parser);
|
||||||
|
fputts(T("/>\n"), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaComment(void *userData, const XML_Char *data)
|
||||||
|
{
|
||||||
|
XML_Parser parser = (XML_Parser) userData;
|
||||||
|
FILE *fp = XML_GetUserData(parser);
|
||||||
|
fputts(T("<comment data=\""), fp);
|
||||||
|
characterData(fp, data, tcslen(data));
|
||||||
|
puttc(T('"'), fp);
|
||||||
|
metaLocation(parser);
|
||||||
|
fputts(T("/>\n"), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaStartCdataSection(void *userData)
|
||||||
|
{
|
||||||
|
XML_Parser parser = (XML_Parser) userData;
|
||||||
|
FILE *fp = XML_GetUserData(parser);
|
||||||
|
fputts(T("<startcdata"), fp);
|
||||||
|
metaLocation(parser);
|
||||||
|
fputts(T("/>\n"), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaEndCdataSection(void *userData)
|
||||||
|
{
|
||||||
|
XML_Parser parser = (XML_Parser) userData;
|
||||||
|
FILE *fp = XML_GetUserData(parser);
|
||||||
|
fputts(T("<endcdata"), fp);
|
||||||
|
metaLocation(parser);
|
||||||
|
fputts(T("/>\n"), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaCharacterData(void *userData, const XML_Char *s, int len)
|
||||||
|
{
|
||||||
|
XML_Parser parser = (XML_Parser) userData;
|
||||||
|
FILE *fp = XML_GetUserData(parser);
|
||||||
|
fputts(T("<chars str=\""), fp);
|
||||||
|
characterData(fp, s, len);
|
||||||
|
puttc(T('"'), fp);
|
||||||
|
metaLocation(parser);
|
||||||
|
fputts(T("/>\n"), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaStartDoctypeDecl(void *userData,
|
||||||
|
const XML_Char *doctypeName,
|
||||||
|
const XML_Char *sysid,
|
||||||
|
const XML_Char *pubid,
|
||||||
|
int has_internal_subset)
|
||||||
|
{
|
||||||
|
XML_Parser parser = (XML_Parser) userData;
|
||||||
|
FILE *fp = XML_GetUserData(parser);
|
||||||
|
ftprintf(fp, T("<startdoctype name=\"%s\""), doctypeName);
|
||||||
|
metaLocation(parser);
|
||||||
|
fputts(T("/>\n"), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaEndDoctypeDecl(void *userData)
|
||||||
|
{
|
||||||
|
XML_Parser parser = (XML_Parser) userData;
|
||||||
|
FILE *fp = XML_GetUserData(parser);
|
||||||
|
fputts(T("<enddoctype"), fp);
|
||||||
|
metaLocation(parser);
|
||||||
|
fputts(T("/>\n"), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaNotationDecl(void *userData,
|
||||||
|
const XML_Char *notationName,
|
||||||
|
const XML_Char *base,
|
||||||
|
const XML_Char *systemId,
|
||||||
|
const XML_Char *publicId)
|
||||||
|
{
|
||||||
|
XML_Parser parser = (XML_Parser) userData;
|
||||||
|
FILE *fp = XML_GetUserData(parser);
|
||||||
|
ftprintf(fp, T("<notation name=\"%s\""), notationName);
|
||||||
|
if (publicId)
|
||||||
|
ftprintf(fp, T(" public=\"%s\""), publicId);
|
||||||
|
if (systemId) {
|
||||||
|
fputts(T(" system=\""), fp);
|
||||||
|
characterData(fp, systemId, tcslen(systemId));
|
||||||
|
puttc(T('"'), fp);
|
||||||
|
}
|
||||||
|
metaLocation(parser);
|
||||||
|
fputts(T("/>\n"), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaEntityDecl(void *userData,
|
||||||
|
const XML_Char *entityName,
|
||||||
|
int is_param,
|
||||||
|
const XML_Char *value,
|
||||||
|
int value_length,
|
||||||
|
const XML_Char *base,
|
||||||
|
const XML_Char *systemId,
|
||||||
|
const XML_Char *publicId,
|
||||||
|
const XML_Char *notationName)
|
||||||
|
{
|
||||||
|
XML_Parser parser = (XML_Parser) userData;
|
||||||
|
FILE *fp = XML_GetUserData(parser);
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
ftprintf(fp, T("<entity name=\"%s\""), entityName);
|
||||||
|
metaLocation(parser);
|
||||||
|
puttc(T('>'), fp);
|
||||||
|
characterData(fp, value, value_length);
|
||||||
|
fputts(T("</entity/>\n"), fp);
|
||||||
|
}
|
||||||
|
else if (notationName) {
|
||||||
|
ftprintf(fp, T("<entity name=\"%s\""), entityName);
|
||||||
|
if (publicId)
|
||||||
|
ftprintf(fp, T(" public=\"%s\""), publicId);
|
||||||
|
fputts(T(" system=\""), fp);
|
||||||
|
characterData(fp, systemId, tcslen(systemId));
|
||||||
|
puttc(T('"'), fp);
|
||||||
|
ftprintf(fp, T(" notation=\"%s\""), notationName);
|
||||||
|
metaLocation(parser);
|
||||||
|
fputts(T("/>\n"), fp);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ftprintf(fp, T("<entity name=\"%s\""), entityName);
|
||||||
|
if (publicId)
|
||||||
|
ftprintf(fp, T(" public=\"%s\""), publicId);
|
||||||
|
fputts(T(" system=\""), fp);
|
||||||
|
characterData(fp, systemId, tcslen(systemId));
|
||||||
|
puttc(T('"'), fp);
|
||||||
|
metaLocation(parser);
|
||||||
|
fputts(T("/>\n"), fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaStartNamespaceDecl(void *userData,
|
||||||
|
const XML_Char *prefix,
|
||||||
|
const XML_Char *uri)
|
||||||
|
{
|
||||||
|
XML_Parser parser = (XML_Parser) userData;
|
||||||
|
FILE *fp = XML_GetUserData(parser);
|
||||||
|
fputts(T("<startns"), fp);
|
||||||
|
if (prefix)
|
||||||
|
ftprintf(fp, T(" prefix=\"%s\""), prefix);
|
||||||
|
if (uri) {
|
||||||
|
fputts(T(" ns=\""), fp);
|
||||||
|
characterData(fp, uri, tcslen(uri));
|
||||||
|
fputts(T("\"/>\n"), fp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fputts(T("/>\n"), fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
metaEndNamespaceDecl(void *userData, const XML_Char *prefix)
|
||||||
|
{
|
||||||
|
XML_Parser parser = (XML_Parser) userData;
|
||||||
|
FILE *fp = XML_GetUserData(parser);
|
||||||
|
if (!prefix)
|
||||||
|
fputts(T("<endns/>\n"), fp);
|
||||||
|
else
|
||||||
|
ftprintf(fp, T("<endns prefix=\"%s\"/>\n"), prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
unknownEncodingConvert(void *data, const char *p)
|
||||||
|
{
|
||||||
|
return codepageConvert(*(int *)data, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
unknownEncoding(void *userData, const XML_Char *name, XML_Encoding *info)
|
||||||
|
{
|
||||||
|
int cp;
|
||||||
|
static const XML_Char prefixL[] = T("windows-");
|
||||||
|
static const XML_Char prefixU[] = T("WINDOWS-");
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; prefixU[i]; i++)
|
||||||
|
if (name[i] != prefixU[i] && name[i] != prefixL[i])
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
cp = 0;
|
||||||
|
for (; name[i]; i++) {
|
||||||
|
static const XML_Char digits[] = T("0123456789");
|
||||||
|
const XML_Char *s = tcschr(digits, name[i]);
|
||||||
|
if (!s)
|
||||||
|
return 0;
|
||||||
|
cp *= 10;
|
||||||
|
cp += s - digits;
|
||||||
|
if (cp >= 0x10000)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!codepageMap(cp, info->map))
|
||||||
|
return 0;
|
||||||
|
info->convert = unknownEncodingConvert;
|
||||||
|
/* We could just cast the code page integer to a void *,
|
||||||
|
and avoid the use of release. */
|
||||||
|
info->release = free;
|
||||||
|
info->data = malloc(sizeof(int));
|
||||||
|
if (!info->data)
|
||||||
|
return 0;
|
||||||
|
*(int *)info->data = cp;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
notStandalone(void *userData)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
showVersion(XML_Char *prog)
|
||||||
|
{
|
||||||
|
XML_Char *s = prog;
|
||||||
|
XML_Char ch;
|
||||||
|
const XML_Feature *features = XML_GetFeatureList();
|
||||||
|
while ((ch = *s) != 0) {
|
||||||
|
if (ch == '/'
|
||||||
|
#ifdef WIN32
|
||||||
|
|| ch == '\\'
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
prog = s + 1;
|
||||||
|
++s;
|
||||||
|
}
|
||||||
|
ftprintf(stdout, T("%s using %s\n"), prog, XML_ExpatVersion());
|
||||||
|
if (features != NULL && features[0].feature != XML_FEATURE_END) {
|
||||||
|
int i = 1;
|
||||||
|
ftprintf(stdout, T("%s"), features[0].name);
|
||||||
|
if (features[0].value)
|
||||||
|
ftprintf(stdout, T("=%ld"), features[0].value);
|
||||||
|
while (features[i].feature != XML_FEATURE_END) {
|
||||||
|
ftprintf(stdout, T(", %s"), features[i].name);
|
||||||
|
if (features[i].value)
|
||||||
|
ftprintf(stdout, T("=%ld"), features[i].value);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
ftprintf(stdout, T("\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(const XML_Char *prog, int rc)
|
||||||
|
{
|
||||||
|
ftprintf(stderr,
|
||||||
|
T("usage: %s [-n] [-p] [-r] [-s] [-w] [-x] [-d output-dir] "
|
||||||
|
"[-e encoding] file ...\n"), prog);
|
||||||
|
exit(rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
tmain(int argc, XML_Char **argv)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
const XML_Char *outputDir = NULL;
|
||||||
|
const XML_Char *encoding = NULL;
|
||||||
|
unsigned processFlags = XML_MAP_FILE;
|
||||||
|
int windowsCodePages = 0;
|
||||||
|
int outputType = 0;
|
||||||
|
int useNamespaces = 0;
|
||||||
|
int requireStandalone = 0;
|
||||||
|
int paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
|
||||||
|
int useStdin = 0;
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
i = 1;
|
||||||
|
j = 0;
|
||||||
|
while (i < argc) {
|
||||||
|
if (j == 0) {
|
||||||
|
if (argv[i][0] != T('-'))
|
||||||
|
break;
|
||||||
|
if (argv[i][1] == T('-') && argv[i][2] == T('\0')) {
|
||||||
|
i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
switch (argv[i][j]) {
|
||||||
|
case T('r'):
|
||||||
|
processFlags &= ~XML_MAP_FILE;
|
||||||
|
j++;
|
||||||
|
break;
|
||||||
|
case T('s'):
|
||||||
|
requireStandalone = 1;
|
||||||
|
j++;
|
||||||
|
break;
|
||||||
|
case T('n'):
|
||||||
|
useNamespaces = 1;
|
||||||
|
j++;
|
||||||
|
break;
|
||||||
|
case T('p'):
|
||||||
|
paramEntityParsing = XML_PARAM_ENTITY_PARSING_ALWAYS;
|
||||||
|
/* fall through */
|
||||||
|
case T('x'):
|
||||||
|
processFlags |= XML_EXTERNAL_ENTITIES;
|
||||||
|
j++;
|
||||||
|
break;
|
||||||
|
case T('w'):
|
||||||
|
windowsCodePages = 1;
|
||||||
|
j++;
|
||||||
|
break;
|
||||||
|
case T('m'):
|
||||||
|
outputType = 'm';
|
||||||
|
j++;
|
||||||
|
break;
|
||||||
|
case T('c'):
|
||||||
|
outputType = 'c';
|
||||||
|
useNamespaces = 0;
|
||||||
|
j++;
|
||||||
|
break;
|
||||||
|
case T('t'):
|
||||||
|
outputType = 't';
|
||||||
|
j++;
|
||||||
|
break;
|
||||||
|
case T('d'):
|
||||||
|
if (argv[i][j + 1] == T('\0')) {
|
||||||
|
if (++i == argc)
|
||||||
|
usage(argv[0], 2);
|
||||||
|
outputDir = argv[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
outputDir = argv[i] + j + 1;
|
||||||
|
i++;
|
||||||
|
j = 0;
|
||||||
|
break;
|
||||||
|
case T('e'):
|
||||||
|
if (argv[i][j + 1] == T('\0')) {
|
||||||
|
if (++i == argc)
|
||||||
|
usage(argv[0], 2);
|
||||||
|
encoding = argv[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
encoding = argv[i] + j + 1;
|
||||||
|
i++;
|
||||||
|
j = 0;
|
||||||
|
break;
|
||||||
|
case T('h'):
|
||||||
|
usage(argv[0], 0);
|
||||||
|
return 0;
|
||||||
|
case T('v'):
|
||||||
|
showVersion(argv[0]);
|
||||||
|
return 0;
|
||||||
|
case T('\0'):
|
||||||
|
if (j > 1) {
|
||||||
|
i++;
|
||||||
|
j = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* fall through */
|
||||||
|
default:
|
||||||
|
usage(argv[0], 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == argc) {
|
||||||
|
useStdin = 1;
|
||||||
|
processFlags &= ~XML_MAP_FILE;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
for (; i < argc; i++) {
|
||||||
|
FILE *fp = 0;
|
||||||
|
XML_Char *outName = 0;
|
||||||
|
int result;
|
||||||
|
XML_Parser parser;
|
||||||
|
if (useNamespaces)
|
||||||
|
parser = XML_ParserCreateNS(encoding, NSSEP);
|
||||||
|
else
|
||||||
|
parser = XML_ParserCreate(encoding);
|
||||||
|
if (requireStandalone)
|
||||||
|
XML_SetNotStandaloneHandler(parser, notStandalone);
|
||||||
|
XML_SetParamEntityParsing(parser, paramEntityParsing);
|
||||||
|
if (outputType == 't') {
|
||||||
|
/* This is for doing timings; this gives a more realistic estimate of
|
||||||
|
the parsing time. */
|
||||||
|
outputDir = 0;
|
||||||
|
XML_SetElementHandler(parser, nopStartElement, nopEndElement);
|
||||||
|
XML_SetCharacterDataHandler(parser, nopCharacterData);
|
||||||
|
XML_SetProcessingInstructionHandler(parser, nopProcessingInstruction);
|
||||||
|
}
|
||||||
|
else if (outputDir) {
|
||||||
|
const XML_Char *file = useStdin ? T("STDIN") : argv[i];
|
||||||
|
if (tcsrchr(file, T('/')))
|
||||||
|
file = tcsrchr(file, T('/')) + 1;
|
||||||
|
#ifdef WIN32
|
||||||
|
if (tcsrchr(file, T('\\')))
|
||||||
|
file = tcsrchr(file, T('\\')) + 1;
|
||||||
|
#endif
|
||||||
|
outName = malloc((tcslen(outputDir) + tcslen(file) + 2)
|
||||||
|
* sizeof(XML_Char));
|
||||||
|
tcscpy(outName, outputDir);
|
||||||
|
tcscat(outName, T("/"));
|
||||||
|
tcscat(outName, file);
|
||||||
|
fp = tfopen(outName, T("wb"));
|
||||||
|
if (!fp) {
|
||||||
|
tperror(outName);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
setvbuf(fp, NULL, _IOFBF, 16384);
|
||||||
|
#ifdef XML_UNICODE
|
||||||
|
puttc(0xFEFF, fp);
|
||||||
|
#endif
|
||||||
|
XML_SetUserData(parser, fp);
|
||||||
|
switch (outputType) {
|
||||||
|
case 'm':
|
||||||
|
XML_UseParserAsHandlerArg(parser);
|
||||||
|
XML_SetElementHandler(parser, metaStartElement, metaEndElement);
|
||||||
|
XML_SetProcessingInstructionHandler(parser, metaProcessingInstruction);
|
||||||
|
XML_SetCommentHandler(parser, metaComment);
|
||||||
|
XML_SetCdataSectionHandler(parser, metaStartCdataSection,
|
||||||
|
metaEndCdataSection);
|
||||||
|
XML_SetCharacterDataHandler(parser, metaCharacterData);
|
||||||
|
XML_SetDoctypeDeclHandler(parser, metaStartDoctypeDecl,
|
||||||
|
metaEndDoctypeDecl);
|
||||||
|
XML_SetEntityDeclHandler(parser, metaEntityDecl);
|
||||||
|
XML_SetNotationDeclHandler(parser, metaNotationDecl);
|
||||||
|
XML_SetNamespaceDeclHandler(parser, metaStartNamespaceDecl,
|
||||||
|
metaEndNamespaceDecl);
|
||||||
|
metaStartDocument(parser);
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
XML_UseParserAsHandlerArg(parser);
|
||||||
|
XML_SetDefaultHandler(parser, markup);
|
||||||
|
XML_SetElementHandler(parser, defaultStartElement, defaultEndElement);
|
||||||
|
XML_SetCharacterDataHandler(parser, defaultCharacterData);
|
||||||
|
XML_SetProcessingInstructionHandler(parser,
|
||||||
|
defaultProcessingInstruction);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (useNamespaces)
|
||||||
|
XML_SetElementHandler(parser, startElementNS, endElementNS);
|
||||||
|
else
|
||||||
|
XML_SetElementHandler(parser, startElement, endElement);
|
||||||
|
XML_SetCharacterDataHandler(parser, characterData);
|
||||||
|
#ifndef W3C14N
|
||||||
|
XML_SetProcessingInstructionHandler(parser, processingInstruction);
|
||||||
|
#endif /* not W3C14N */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (windowsCodePages)
|
||||||
|
XML_SetUnknownEncodingHandler(parser, unknownEncoding, 0);
|
||||||
|
result = XML_ProcessFile(parser, useStdin ? NULL : argv[i], processFlags);
|
||||||
|
if (outputDir) {
|
||||||
|
if (outputType == 'm')
|
||||||
|
metaEndDocument(parser);
|
||||||
|
fclose(fp);
|
||||||
|
if (!result)
|
||||||
|
tremove(outName);
|
||||||
|
free(outName);
|
||||||
|
}
|
||||||
|
XML_ParserFree(parser);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
395
contrib/expat/xmlwf/xmlwin32url.cxx
Executable file
395
contrib/expat/xmlwf/xmlwin32url.cxx
Executable file
@ -0,0 +1,395 @@
|
|||||||
|
#include "expat.h"
|
||||||
|
#ifdef XML_UNICODE
|
||||||
|
#define UNICODE
|
||||||
|
#endif
|
||||||
|
#include <windows.h>
|
||||||
|
#include <urlmon.h>
|
||||||
|
#include <wininet.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
#include "xmlurl.h"
|
||||||
|
#include "xmlmime.h"
|
||||||
|
|
||||||
|
static int
|
||||||
|
processURL(XML_Parser parser, IMoniker *baseMoniker, const XML_Char *url);
|
||||||
|
|
||||||
|
typedef void (*StopHandler)(void *, HRESULT);
|
||||||
|
|
||||||
|
class Callback : public IBindStatusCallback {
|
||||||
|
public:
|
||||||
|
// IUnknown methods
|
||||||
|
STDMETHODIMP QueryInterface(REFIID,void **);
|
||||||
|
STDMETHODIMP_(ULONG) AddRef();
|
||||||
|
STDMETHODIMP_(ULONG) Release();
|
||||||
|
// IBindStatusCallback methods
|
||||||
|
STDMETHODIMP OnStartBinding(DWORD, IBinding *);
|
||||||
|
STDMETHODIMP GetPriority(LONG *);
|
||||||
|
STDMETHODIMP OnLowResource(DWORD);
|
||||||
|
STDMETHODIMP OnProgress(ULONG, ULONG, ULONG, LPCWSTR);
|
||||||
|
STDMETHODIMP OnStopBinding(HRESULT, LPCWSTR);
|
||||||
|
STDMETHODIMP GetBindInfo(DWORD *, BINDINFO *);
|
||||||
|
STDMETHODIMP OnDataAvailable(DWORD, DWORD, FORMATETC *, STGMEDIUM *);
|
||||||
|
STDMETHODIMP OnObjectAvailable(REFIID, IUnknown *);
|
||||||
|
Callback(XML_Parser, IMoniker *, StopHandler, void *);
|
||||||
|
~Callback();
|
||||||
|
int externalEntityRef(const XML_Char *context,
|
||||||
|
const XML_Char *systemId, const XML_Char *publicId);
|
||||||
|
private:
|
||||||
|
XML_Parser parser_;
|
||||||
|
IMoniker *baseMoniker_;
|
||||||
|
DWORD totalRead_;
|
||||||
|
ULONG ref_;
|
||||||
|
IBinding *pBinding_;
|
||||||
|
StopHandler stopHandler_;
|
||||||
|
void *stopArg_;
|
||||||
|
};
|
||||||
|
|
||||||
|
STDMETHODIMP_(ULONG)
|
||||||
|
Callback::AddRef()
|
||||||
|
{
|
||||||
|
return ref_++;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP_(ULONG)
|
||||||
|
Callback::Release()
|
||||||
|
{
|
||||||
|
if (--ref_ == 0) {
|
||||||
|
delete this;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ref_;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
Callback::QueryInterface(REFIID riid, void** ppv)
|
||||||
|
{
|
||||||
|
if (IsEqualGUID(riid, IID_IUnknown))
|
||||||
|
*ppv = (IUnknown *)this;
|
||||||
|
else if (IsEqualGUID(riid, IID_IBindStatusCallback))
|
||||||
|
*ppv = (IBindStatusCallback *)this;
|
||||||
|
else
|
||||||
|
return E_NOINTERFACE;
|
||||||
|
((LPUNKNOWN)*ppv)->AddRef();
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
Callback::OnStartBinding(DWORD, IBinding* pBinding)
|
||||||
|
{
|
||||||
|
pBinding_ = pBinding;
|
||||||
|
pBinding->AddRef();
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
Callback::GetPriority(LONG *)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
Callback::OnLowResource(DWORD)
|
||||||
|
{
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
Callback::OnProgress(ULONG, ULONG, ULONG, LPCWSTR)
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
Callback::OnStopBinding(HRESULT hr, LPCWSTR szError)
|
||||||
|
{
|
||||||
|
if (pBinding_) {
|
||||||
|
pBinding_->Release();
|
||||||
|
pBinding_ = 0;
|
||||||
|
}
|
||||||
|
if (baseMoniker_) {
|
||||||
|
baseMoniker_->Release();
|
||||||
|
baseMoniker_ = 0;
|
||||||
|
}
|
||||||
|
stopHandler_(stopArg_, hr);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
Callback::GetBindInfo(DWORD* pgrfBINDF, BINDINFO* pbindinfo)
|
||||||
|
{
|
||||||
|
*pgrfBINDF = BINDF_ASYNCHRONOUS;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
reportError(XML_Parser parser)
|
||||||
|
{
|
||||||
|
int code = XML_GetErrorCode(parser);
|
||||||
|
const XML_Char *message = XML_ErrorString(code);
|
||||||
|
if (message)
|
||||||
|
_ftprintf(stderr, _T("%s:%d:%ld: %s\n"),
|
||||||
|
XML_GetBase(parser),
|
||||||
|
XML_GetErrorLineNumber(parser),
|
||||||
|
XML_GetErrorColumnNumber(parser),
|
||||||
|
message);
|
||||||
|
else
|
||||||
|
_ftprintf(stderr, _T("%s: (unknown message %d)\n"),
|
||||||
|
XML_GetBase(parser), code);
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
Callback::OnDataAvailable(DWORD grfBSCF,
|
||||||
|
DWORD dwSize,
|
||||||
|
FORMATETC *pfmtetc,
|
||||||
|
STGMEDIUM* pstgmed)
|
||||||
|
{
|
||||||
|
if (grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
|
||||||
|
IWinInetHttpInfo *hp;
|
||||||
|
HRESULT hr = pBinding_->QueryInterface(IID_IWinInetHttpInfo,
|
||||||
|
(void **)&hp);
|
||||||
|
if (SUCCEEDED(hr)) {
|
||||||
|
char contentType[1024];
|
||||||
|
DWORD bufSize = sizeof(contentType);
|
||||||
|
DWORD flags = 0;
|
||||||
|
contentType[0] = 0;
|
||||||
|
hr = hp->QueryInfo(HTTP_QUERY_CONTENT_TYPE, contentType,
|
||||||
|
&bufSize, 0, NULL);
|
||||||
|
if (SUCCEEDED(hr)) {
|
||||||
|
char charset[CHARSET_MAX];
|
||||||
|
getXMLCharset(contentType, charset);
|
||||||
|
if (charset[0]) {
|
||||||
|
#ifdef XML_UNICODE
|
||||||
|
XML_Char wcharset[CHARSET_MAX];
|
||||||
|
XML_Char *p1 = wcharset;
|
||||||
|
const char *p2 = charset;
|
||||||
|
while ((*p1++ = (unsigned char)*p2++) != 0)
|
||||||
|
;
|
||||||
|
XML_SetEncoding(parser_, wcharset);
|
||||||
|
#else
|
||||||
|
XML_SetEncoding(parser_, charset);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hp->Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!parser_)
|
||||||
|
return E_ABORT;
|
||||||
|
if (pstgmed->tymed == TYMED_ISTREAM) {
|
||||||
|
while (totalRead_ < dwSize) {
|
||||||
|
#define READ_MAX (64*1024)
|
||||||
|
DWORD nToRead = dwSize - totalRead_;
|
||||||
|
if (nToRead > READ_MAX)
|
||||||
|
nToRead = READ_MAX;
|
||||||
|
void *buf = XML_GetBuffer(parser_, nToRead);
|
||||||
|
if (!buf) {
|
||||||
|
_ftprintf(stderr, _T("out of memory\n"));
|
||||||
|
return E_ABORT;
|
||||||
|
}
|
||||||
|
DWORD nRead;
|
||||||
|
HRESULT hr = pstgmed->pstm->Read(buf, nToRead, &nRead);
|
||||||
|
if (SUCCEEDED(hr)) {
|
||||||
|
totalRead_ += nRead;
|
||||||
|
if (!XML_ParseBuffer(parser_,
|
||||||
|
nRead,
|
||||||
|
(grfBSCF & BSCF_LASTDATANOTIFICATION) != 0
|
||||||
|
&& totalRead_ == dwSize)) {
|
||||||
|
reportError(parser_);
|
||||||
|
return E_ABORT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP
|
||||||
|
Callback::OnObjectAvailable(REFIID, IUnknown *)
|
||||||
|
{
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Callback::externalEntityRef(const XML_Char *context,
|
||||||
|
const XML_Char *systemId,
|
||||||
|
const XML_Char *publicId)
|
||||||
|
{
|
||||||
|
XML_Parser entParser = XML_ExternalEntityParserCreate(parser_, context, 0);
|
||||||
|
XML_SetBase(entParser, systemId);
|
||||||
|
int ret = processURL(entParser, baseMoniker_, systemId);
|
||||||
|
XML_ParserFree(entParser);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
Callback::Callback(XML_Parser parser, IMoniker *baseMoniker,
|
||||||
|
StopHandler stopHandler, void *stopArg)
|
||||||
|
: parser_(parser),
|
||||||
|
baseMoniker_(baseMoniker),
|
||||||
|
ref_(0),
|
||||||
|
pBinding_(0),
|
||||||
|
totalRead_(0),
|
||||||
|
stopHandler_(stopHandler),
|
||||||
|
stopArg_(stopArg)
|
||||||
|
{
|
||||||
|
if (baseMoniker_)
|
||||||
|
baseMoniker_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
Callback::~Callback()
|
||||||
|
{
|
||||||
|
if (pBinding_)
|
||||||
|
pBinding_->Release();
|
||||||
|
if (baseMoniker_)
|
||||||
|
baseMoniker_->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
externalEntityRef(void *arg,
|
||||||
|
const XML_Char *context,
|
||||||
|
const XML_Char *base,
|
||||||
|
const XML_Char *systemId,
|
||||||
|
const XML_Char *publicId)
|
||||||
|
{
|
||||||
|
return ((Callback *)arg)->externalEntityRef(context, systemId, publicId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static HRESULT
|
||||||
|
openStream(XML_Parser parser,
|
||||||
|
IMoniker *baseMoniker,
|
||||||
|
const XML_Char *uri,
|
||||||
|
StopHandler stopHandler, void *stopArg)
|
||||||
|
{
|
||||||
|
if (!XML_SetBase(parser, uri))
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
HRESULT hr;
|
||||||
|
IMoniker *m;
|
||||||
|
#ifdef XML_UNICODE
|
||||||
|
hr = CreateURLMoniker(0, uri, &m);
|
||||||
|
#else
|
||||||
|
LPWSTR uriw = new wchar_t[strlen(uri) + 1];
|
||||||
|
for (int i = 0;; i++) {
|
||||||
|
uriw[i] = uri[i];
|
||||||
|
if (uriw[i] == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
hr = CreateURLMoniker(baseMoniker, uriw, &m);
|
||||||
|
delete [] uriw;
|
||||||
|
#endif
|
||||||
|
if (FAILED(hr))
|
||||||
|
return hr;
|
||||||
|
IBindStatusCallback *cb = new Callback(parser, m, stopHandler, stopArg);
|
||||||
|
XML_SetExternalEntityRefHandler(parser, externalEntityRef);
|
||||||
|
XML_SetExternalEntityRefHandlerArg(parser, cb);
|
||||||
|
cb->AddRef();
|
||||||
|
IBindCtx *b;
|
||||||
|
if (FAILED(hr = CreateAsyncBindCtx(0, cb, 0, &b))) {
|
||||||
|
cb->Release();
|
||||||
|
m->Release();
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
cb->Release();
|
||||||
|
IStream *pStream;
|
||||||
|
hr = m->BindToStorage(b, 0, IID_IStream, (void **)&pStream);
|
||||||
|
if (SUCCEEDED(hr)) {
|
||||||
|
if (pStream)
|
||||||
|
pStream->Release();
|
||||||
|
}
|
||||||
|
if (hr == MK_S_ASYNCHRONOUS)
|
||||||
|
hr = S_OK;
|
||||||
|
m->Release();
|
||||||
|
b->Release();
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct QuitInfo {
|
||||||
|
const XML_Char *url;
|
||||||
|
HRESULT hr;
|
||||||
|
int stop;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
winPerror(const XML_Char *url, HRESULT hr)
|
||||||
|
{
|
||||||
|
LPVOID buf;
|
||||||
|
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||||
|
| FORMAT_MESSAGE_FROM_HMODULE,
|
||||||
|
GetModuleHandleA("urlmon.dll"),
|
||||||
|
hr,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
(LPTSTR) &buf,
|
||||||
|
0,
|
||||||
|
NULL)
|
||||||
|
|| FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||||
|
| FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
|
0,
|
||||||
|
hr,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
(LPTSTR) &buf,
|
||||||
|
0,
|
||||||
|
NULL)) {
|
||||||
|
/* The system error messages seem to end with a newline. */
|
||||||
|
_ftprintf(stderr, _T("%s: %s"), url, buf);
|
||||||
|
fflush(stderr);
|
||||||
|
LocalFree(buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_ftprintf(stderr, _T("%s: error %x\n"), url, hr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
threadQuit(void *p, HRESULT hr)
|
||||||
|
{
|
||||||
|
QuitInfo *qi = (QuitInfo *)p;
|
||||||
|
qi->hr = hr;
|
||||||
|
qi->stop = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
int
|
||||||
|
XML_URLInit(void)
|
||||||
|
{
|
||||||
|
return SUCCEEDED(CoInitialize(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
void
|
||||||
|
XML_URLUninit(void)
|
||||||
|
{
|
||||||
|
CoUninitialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
processURL(XML_Parser parser, IMoniker *baseMoniker,
|
||||||
|
const XML_Char *url)
|
||||||
|
{
|
||||||
|
QuitInfo qi;
|
||||||
|
qi.stop = 0;
|
||||||
|
qi.url = url;
|
||||||
|
|
||||||
|
XML_SetBase(parser, url);
|
||||||
|
HRESULT hr = openStream(parser, baseMoniker, url, threadQuit, &qi);
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
winPerror(url, hr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (FAILED(qi.hr)) {
|
||||||
|
winPerror(url, qi.hr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
MSG msg;
|
||||||
|
while (!qi.stop && GetMessage (&msg, NULL, 0, 0)) {
|
||||||
|
TranslateMessage (&msg);
|
||||||
|
DispatchMessage (&msg);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
int
|
||||||
|
XML_ProcessURL(XML_Parser parser,
|
||||||
|
const XML_Char *url,
|
||||||
|
unsigned flags)
|
||||||
|
{
|
||||||
|
return processURL(parser, 0, url);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user