diff options
author | alanh <alanh> | 2003-09-29 23:36:19 +0000 |
---|---|---|
committer | alanh <alanh> | 2003-09-29 23:36:19 +0000 |
commit | 1aae725703dc75634f329bbc3969c408e30f2a94 (patch) | |
tree | 4e91a5c5aef03dcf410ad230b0dfba4d5ad0e951 | |
parent | e2a5a8954a875a1c99e4554a186de12b531a79a8 (diff) |
Import expat 1.95.6expat
63 files changed, 8268 insertions, 2352 deletions
diff --git a/extras/expat/Changes b/extras/expat/Changes index 3ce40cfa5..c5f75d0c8 100644 --- a/extras/expat/Changes +++ b/extras/expat/Changes @@ -1,79 +1,107 @@ +Release 1.95.6 Tue Jan 28 2003 + - Added XML_FreeContentModel(). + - Added XML_MemMalloc(), XML_MemRealloc(), XML_MemFree(). + - Fixed a variety of bugs: see SF issues 615606, 616863, + 618199, 653180, 673791. + - Enhanced the regression test suite. + - Man page improvements: includes SF issue 632146. + +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 Miles. + - 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 + - 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. + - 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. + - 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. + - 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 + - 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 diff --git a/extras/expat/MANIFEST b/extras/expat/MANIFEST index d1c7418d6..deeaf2cfb 100644 --- a/extras/expat/MANIFEST +++ b/extras/expat/MANIFEST @@ -6,6 +6,32 @@ README configure configure.in expat_config.h.in +bcb5/README.txt +bcb5/elements.bpf +bcb5/elements.bpr +bcb5/elements.mak +bcb5/expat.bpf +bcb5/expat.bpr +bcb5/expat.mak +bcb5/expat_static.bpf +bcb5/expat_static.bpr +bcb5/expat_static.mak +bcb5/expatw.bpf +bcb5/expatw.bpr +bcb5/expatw.mak +bcb5/expatw_static.bpf +bcb5/expatw_static.bpr +bcb5/expatw_static.mak +bcb5/libexpat_mtd.def +bcb5/libexpatw_mtd.def +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 @@ -17,6 +43,7 @@ conftools/ltmain.sh conftools/mkinstalldirs doc/reference.html doc/style.css +doc/valid-xhtml10.png doc/xmlwf.1 doc/xmlwf.sgml examples/elements.c @@ -25,6 +52,7 @@ lib/ascii.h lib/asciitab.h lib/expat.h lib/iasciitab.h +lib/internal.h lib/latin1tab.h lib/nametab.h lib/utf8tab.h @@ -45,6 +73,8 @@ 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 diff --git a/extras/expat/Makefile.in b/extras/expat/Makefile.in index a3cfc6720..4c78a6cc1 100644 --- a/extras/expat/Makefile.in +++ b/extras/expat/Makefile.in @@ -55,7 +55,11 @@ 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 - find . -name core | xargs rm -f + cd tests && rm -rf .libs runtests runtests.o chardata.o + rm -rf .libs libexpat.la + rm -f examples/core tests/core xmlwf/core + +clobber: clean distclean: clean rm -f expat_config.h config.status config.log config.cache libtool @@ -114,10 +118,10 @@ $(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 + $(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 + $(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 \ @@ -146,13 +150,14 @@ tests/runtests.o: tests/runtests.c tests/chardata.h tests/runtests: tests/runtests.o tests/chardata.o $(LIBRARY) $(LINK_EXE) $^ -lcheck -tests/xmltest.zip: - cd tests && wget ftp://ftp.jclark.com/pub/xml/xmltest.zip +tests/xmlts.zip: + wget --output-document=tests/xmlts.zip \ + http://www.w3.org/XML/Test/xmlts20020606.zip -tests/xmltest: tests/xmltest.zip - cd tests && unzip -q xmltest.zip +tests/XML-Test-Suite: tests/xmlts.zip + cd tests && unzip -q xmlts.zip -run-xmltest: xmlwf/xmlwf tests/xmltest +run-xmltest: xmlwf/xmlwf tests/XML-Test-Suite tests/xmltest.sh .SUFFIXES: .c .lo .o diff --git a/extras/expat/README b/extras/expat/README index 01f76303f..3bab5a02c 100644 --- a/extras/expat/README +++ b/extras/expat/README @@ -1,5 +1,5 @@ - Expat, Release 1.95.4 + Expat, Release 1.95.6 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 @@ -22,8 +22,19 @@ 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. -To build Expat, you first run the configuration shell script in the -top level distribution directory: +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 @@ -92,10 +103,10 @@ 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@lists.sourceforge.net. +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@lists.sourceforge.net. Archives of this list -may be found at: +place on expat-discuss@mail.libexpat.org. Archives of this list and +other Expat-related lists may be found at: - http://sourceforge.net/mailarchive/forum.php?forum_id=6385 + http://mail.libexpat.org/mailman-21/listinfo/ diff --git a/extras/expat/bcb5/README.txt b/extras/expat/bcb5/README.txt new file mode 100644 index 000000000..50ac811a5 --- /dev/null +++ b/extras/expat/bcb5/README.txt @@ -0,0 +1,86 @@ + + Using a Borland compiler product + +The files in this directory support using both the free Borland command-line +compiler tools and the Borland C++ Builder IDE. The project files have been +tested with both versions 5 and 6 of the C++ Builder product. + + Using the free BCC32 command line compiler + +After downloading and installing the free C++ Builder commandline version, +perform the following steps (assuming it was installed under C:\Borland\BCC55): + +1) Add "C:\Borland\BCC55\BIN" to your path +2) Set the environment variable BCB to "C:\Borland\BCC55". +3) edit makefile.mak: enable or comment out the appropriate commands under + clean & distclean, depending on whether your OS can use deltree /y or + del /s/f/q. + +After that, you should simply cd to the bcb5 directory in your Expat directory +tree (same structure as CVS) and run "make all" or just "make". + + Naming + +The libraries have the base name "libexpat" followed optionally by an "s" +(static) or a "w" (unicode version), then an underscore and optionally +"mt" (multi-threaded) and "d" (dynamic RTL). + +To change the name of the library a project file produces, edit the project +option source (see step 1 under Unicode below) and change the name contained in +the PROJECT tag. In a make file, change the value assigned to the PROJECT +variable. Also, the LIBRARY entry in the .def file has to be changed to +correspond to the new executable name. + + + Unicode Considerations + +There are no facilities in the BCB 5 GUI to create a unicode-enabled +application. Fortunately, it is not hard to do by hand. + +1. The startup .obj system file must be changed to the unicode version. + Go to Project|Edit Option Source, and scroll down to the ALLOBJ tag. Change + c0x32.obj to c0x32w.obj. Editing this file can be quirky, but usually the + following kludge will make the change stick. Close and save the file + (CTRL-F4) then open the options dialog (CTRL-Shift-F11), then click OK on + the dialog immediately without changing anything in it. If this doesn't work, + you will have to close the project completely and edit the .bpr file by hand. + + If you are using a make file, just change the startup .obj file assigned + to the ALLOBJ variable. + +2. Add the macro define XML_UNICODE_WCHAR_T. In the GUI that goes in the options + dialog, Directories/Conditionals tab, in the Conditional define box. In a + make file, put it in the USERDEFINES variable. + +3. Of course, your code has to be written for unicode. As a start, the "main" + function is called "wmain". The tchar macros are an interesting way to + write code that can easily switch between unicode and utf-8. If these macros + are used, then simply adding the conditional define _UNICODE as well as + XML_UNICODE_WCHAR_T will bring in the unicode versions of the tchar macros. + Otherwise the utf-8 versions are used. xmlwf uses its own versions of the + tchar macros which are switched on and off by the XML_UNICODE macro, which + itself is set by the XML_UNICODE_WCHAR_T define. + + Threading + +The libexpat libraries are all built with the multi-threaded dynamic RTL's. +To create single-threaded libs, do the following: + +1. The compiler option for multi-threading must be turned off. Following the + instructions above to edit the option source, remove the -tWM option from + the CFLAG1 tag. In a make file, remove it from the CFLAG1 variable. + +2. The single threaded RTL must be called. change the RTL in the ALLLIB tag or + variable (GUI or makefile repectively) to the version without the "mt" in the + name. For example, change cw32mti.lib to cw32i.lib. + + Static RTL's + +To build the libs with static RTL's do the following, + +1. For the static expatlibs, in the Tlib tab on the options dialog, uncheck the + "Use dynamic RTL" box. For the dynamic expatlibs, in the Linker tab on the + options dialog, uncheck "Use dynamic RTL". If you are using a make file, + remove the _RTLDLL assignment to the SYSDEFINES variable, and change the RTL + to the version without an "i" in the ALLLIB variable. For example, + cw32mti.lib would become cw32mt.lib. diff --git a/extras/expat/bcb5/elements.bpf b/extras/expat/bcb5/elements.bpf new file mode 100644 index 000000000..5c1e878d6 --- /dev/null +++ b/extras/expat/bcb5/elements.bpf @@ -0,0 +1,4 @@ +USEUNIT("..\examples\elements.c"); +USELIB("Release\libexpats_mtd.lib"); +//--------------------------------------------------------------------------- +main diff --git a/extras/expat/bcb5/elements.bpr b/extras/expat/bcb5/elements.bpr new file mode 100644 index 000000000..c21c0f59f --- /dev/null +++ b/extras/expat/bcb5/elements.bpr @@ -0,0 +1,149 @@ +<?xml version='1.0' encoding='utf-8' ?> +<!-- C++Builder XML Project --> +<PROJECT> + <MACROS> + <VERSION value="BCB.05.03"/> + <PROJECT value="Release\elements.exe"/> + <OBJFILES value="Release\obj\examples\elements.obj"/> + <RESFILES value=""/> + <IDLFILES value=""/> + <IDLGENFILES value=""/> + <DEFFILE value=""/> + <RESDEPEN value="$(RESFILES)"/> + <LIBFILES value="Release\libexpats_mtd.lib"/> + <LIBRARIES value=""/> + <SPARELIBS value=""/> + <PACKAGES value="VCL50.bpi VCLX50.bpi bcbsmp50.bpi QRPT50.bpi VCLDB50.bpi VCLBDE50.bpi + ibsmp50.bpi VCLDBX50.bpi TEEUI50.bpi TEEDB50.bpi TEE50.bpi TEEQR50.bpi + VCLIB50.bpi bcbie50.bpi VCLIE50.bpi INETDB50.bpi INET50.bpi NMFAST50.bpi + dclocx50.bpi bcb2kaxserver50.bpi dclusr50.bpi"/> + <PATHCPP value=".;..\examples"/> + <PATHPAS value=".;"/> + <PATHRC value=".;"/> + <PATHASM value=".;"/> + <DEBUGLIBPATH value="$(BCB)\lib\debug"/> + <RELEASELIBPATH value="$(BCB)\lib\release"/> + <LINKER value="ilink32"/> + <USERDEFINES value="WIN32;NDEBUG;_CONSOLE;XML_STATIC"/> + <SYSDEFINES value="_NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL"/> + <MAINSOURCE value="elements.bpf"/> + <INCLUDEPATH value="..\examples;$(BCB)\include"/> + <LIBPATH value="..\examples;$(BCB)\lib;$(RELEASELIBPATH)"/> + <WARNINGS value="-w-par -w-8027 -w-8026"/> + </MACROS> + <OPTIONS> + <IDLCFLAGS value="-I$(BCB)\include"/> + <CFLAG1 value="-O2 -X- -a8 -b -k- -vi -q -tWM -I..\lib -c"/> + <PFLAGS value="-N2Release\obj\examples -N0Release\obj\examples -$Y- -$L- -$D-"/> + <RFLAGS value="/l 0x409 /d "NDEBUG" /i$(BCB)\include"/> + <AFLAGS value="/mx /w2 /zn"/> + <LFLAGS value="-IRelease\obj\examples -D"" -ap -Tpe -x -Gn -q -L..\LIB\RELEASE_STATIC"/> + </OPTIONS> + <LINKER> + <ALLOBJ value="c0x32.obj $(OBJFILES)"/> + <ALLRES value="$(RESFILES)"/> + <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib"/> + </LINKER> + <IDEOPTIONS> +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1033 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=4 +Item0=..\examples;$(BCB)\include +Item1=$(BCB)\include +Item2=$(BCB)\include;$(BCB)\include\mfc;$(BCB)\include\atl +Item3=$(BCB)\include;$(BCB)\include\mfc;$(BCB)\include\atl; + +[HistoryLists\hlLibraryPath] +Count=8 +Item0=..\examples;$(BCB)\lib;$(RELEASELIBPATH) +Item1=..\examples;$(BCB)\lib;..\examples\$(RELEASELIBPATH) +Item2=$(BCB)\lib;$(RELEASELIBPATH) +Item3=$(BCB)\lib;$(RELEASELIBPATH);..\lib\Release-w_static +Item4=$(BCB)\lib;$(RELEASELIBPATH);..\lib\Release_static +Item5=$(BCB)\lib;$(RELEASELIBPATH);C:\src\expat\lib\Release_static +Item6=$(BCB)\lib;$(RELEASELIBPATH);$(BCB)\lib\psdk +Item7=$(BCB)\lib;$(RELEASELIBPATH);;$(BCB)\lib\psdk; + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=17 +Item0=WIN32;NDEBUG;_CONSOLE;XML_STATIC +Item1=WIN32;NDEBUG;_CONSOLE;_DEBUG;XML_STATIC +Item2=WIN32;NDEBUG;_CONSOLE;_DEBUG;XML_UNICODE_WCHAR_T;_UNICODE;XML_STATIC +Item3=WIN32;NDEBUG;_CONSOLE;_DEBUG;XML_UNICODE_WCHAR_T;_UNICODE +Item4=WIN32;NDEBUG;_CONSOLE;_DEBUG +Item5=WIN32;NDEBUG;_CONSOLE;XML_STATIC;_DEBUG +Item6=WIN32;NDEBUG;_CONSOLE;XML_STATIC;_DEBUG;_UNICODE +Item7=WIN32;NDEBUG;_CONSOLE;XML_STATIC;_DEBUG;XML_UNICODE_WCHAR_T +Item8=WIN32;NDEBUG;_CONSOLE;_MBCS;XML_STATIC;_DEBUG;XML_UNICODE_WCHAR_T +Item9=WIN32;NDEBUG;_CONSOLE;_UNICODE;XML_STATIC;_DEBUG;XML_UNICODE_WCHAR_T +Item10=WIN32;NDEBUG;_CONSOLE;_UNICODE;XML_STATIC;_DEBUG;XML_UNICODE +Item11=WIN32;NDEBUG;_CONSOLE;_MBCS;XML_STATIC;_DEBUG;XML_UNICODE_WCHAR_T;__WCHAR_T +Item12=WIN32;NDEBUG;_CONSOLE;_MBCS;XML_STATIC;_DEBUG;XML_UNICODE_WCHAR_T;_UNICODE +Item13=WIN32;NDEBUG;_CONSOLE;_MBCS;XML_STATIC;_DEBUG;XML_UNICODE;_UNICODE +Item14=WIN32;NDEBUG;_CONSOLE;_MBCS;XML_STATIC;_DEBUG;XML_UNICODE +Item15=WIN32;NDEBUG;_CONSOLE;_MBCS;XML_STATIC;_DEBUG +Item16=WIN32;NDEBUG;_CONSOLE;_MBCS;XML_STATIC + +[HistoryLists\hlIntOutputDir] +Count=5 +Item0=Release\obj\examples +Item1=Release\obj\elements +Item2=Release\obj\mts +Item3=..\examples\Release +Item4=Release + +[HistoryLists\hlFinalOutputDir] +Count=1 +Item0=Release\ + +[Debugging] +DebugSourceDirs= + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + </IDEOPTIONS> +</PROJECT>
\ No newline at end of file diff --git a/extras/expat/bcb5/elements.mak b/extras/expat/bcb5/elements.mak new file mode 100644 index 000000000..d4427fd51 --- /dev/null +++ b/extras/expat/bcb5/elements.mak @@ -0,0 +1,186 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.05.03 +# --------------------------------------------------------------------------- +PROJECT = Release\elements.exe +OBJFILES = Release\obj\examples\elements.obj +RESFILES = +MAINSOURCE = elements.bpf +RESDEPEN = $(RESFILES) +LIBFILES = Release\libexpats_mtd.lib +IDLFILES = +IDLGENFILES = +LIBRARIES = +PACKAGES = VCL50.bpi VCLX50.bpi bcbsmp50.bpi QRPT50.bpi VCLDB50.bpi VCLBDE50.bpi \ + ibsmp50.bpi VCLDBX50.bpi TEEUI50.bpi TEEDB50.bpi TEE50.bpi TEEQR50.bpi \ + VCLIB50.bpi bcbie50.bpi VCLIE50.bpi INETDB50.bpi INET50.bpi NMFAST50.bpi \ + dclocx50.bpi bcb2kaxserver50.bpi dclusr50.bpi +SPARELIBS = +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .;..\examples +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = WIN32;NDEBUG;_CONSOLE;XML_STATIC +SYSDEFINES = _NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL +INCLUDEPATH = ..\examples;$(BCB)\include +LIBPATH = ..\examples;$(BCB)\lib;$(RELEASELIBPATH) +WARNINGS= -w-par -w-8027 -w-8026 +# --------------------------------------------------------------------------- +CFLAG1 = -O2 -X- -a8 -b -k- -vi -q -I..\lib -c +IDLCFLAGS = -I$(BCB)\include +PFLAGS = -N2Release\obj\examples -N0Release\obj\examples -$Y- -$L- -$D- +RFLAGS = /l 0x409 /d "NDEBUG" /i$(BCB)\include +AFLAGS = /mx /w2 /zn +LFLAGS = -IRelease\obj\examples -D"" -ap -Tpe -x -Gn -q -L..\LIB\RELEASE_STATIC +# --------------------------------------------------------------------------- +ALLOBJ = c0x32.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +!endif + + + + + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if "$(USERDEFINES)" != "" +AUSERDEFINES = -d$(USERDEFINES:;= -d) +!else +AUSERDEFINES = +!endif + +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(IDLGENFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) -L$(LIBPATH) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) -i$(INCLUDEPATH:;= -i) $(AUSERDEFINES) -d$(SYSDEFINES:;= -d) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $< +# --------------------------------------------------------------------------- + + + + diff --git a/extras/expat/bcb5/expat.bpf b/extras/expat/bcb5/expat.bpf new file mode 100644 index 000000000..2c423283f --- /dev/null +++ b/extras/expat/bcb5/expat.bpf @@ -0,0 +1,6 @@ +USEUNIT("..\lib\xmlparse.c"); +USEUNIT("..\lib\xmlrole.c"); +USEUNIT("..\lib\xmltok.c"); +USEDEF("libexpat_mtd.def"); +//--------------------------------------------------------------------------- +#define DllEntryPoint diff --git a/extras/expat/bcb5/expat.bpr b/extras/expat/bcb5/expat.bpr new file mode 100644 index 000000000..291b8cafc --- /dev/null +++ b/extras/expat/bcb5/expat.bpr @@ -0,0 +1,140 @@ +<?xml version='1.0' encoding='utf-8' ?> +<!-- C++Builder XML Project --> +<PROJECT> + <MACROS> + <VERSION value="BCB.05.03"/> + <PROJECT value="Release\libexpat_mtd.dll"/> + <OBJFILES value="Release\obj\libexpat\xmlparse.obj Release\obj\libexpat\xmlrole.obj + Release\obj\libexpat\xmltok.obj"/> + <RESFILES value=""/> + <IDLFILES value=""/> + <IDLGENFILES value=""/> + <DEFFILE value="libexpat_mtd.def"/> + <RESDEPEN value="$(RESFILES)"/> + <LIBFILES value=""/> + <LIBRARIES value=""/> + <SPARELIBS value=""/> + <PACKAGES value="VCL50.bpi VCLX50.bpi bcbsmp50.bpi QRPT50.bpi VCLDB50.bpi VCLBDE50.bpi + ibsmp50.bpi VCLDBX50.bpi TEEUI50.bpi TEEDB50.bpi TEE50.bpi TEEQR50.bpi + VCLIB50.bpi bcbie50.bpi VCLIE50.bpi INETDB50.bpi INET50.bpi NMFAST50.bpi + dclocx50.bpi bcb2kaxserver50.bpi dclusr50.bpi"/> + <PATHCPP value=".;..\lib"/> + <PATHPAS value=".;"/> + <PATHRC value=".;"/> + <PATHASM value=".;"/> + <DEBUGLIBPATH value="$(BCB)\lib\debug"/> + <RELEASELIBPATH value="$(BCB)\lib\release"/> + <LINKER value="ilink32"/> + <USERDEFINES value="_WINDOWS;WIN32;NDEBUG;_USRDLL;COMPILED_FROM_DSP;EXPAT_EXPORTS"/> + <SYSDEFINES value="_NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL"/> + <MAINSOURCE value="expat.bpf"/> + <INCLUDEPATH value="..\lib;$(BCB)\include"/> + <LIBPATH value="..\lib;$(BCB)\lib;$(RELEASELIBPATH)"/> + <WARNINGS value="-w-rch -w-par -w-8027 -w-8026 -w-ccc"/> + </MACROS> + <OPTIONS> + <IDLCFLAGS value="-I$(BCB)\include"/> + <CFLAG1 value="-WD -O2 -X- -a8 -b -k- -vi -q -tWM -c -tWD"/> + <PFLAGS value="-N2Release\obj\libexpat -N0Release\obj\libexpat -$Y- -$L- -$D-"/> + <RFLAGS value="/l 0x409 /d "NDEBUG" /i$(BCB)\include"/> + <AFLAGS value="/mx /w2 /zn"/> + <LFLAGS value="-IRelease\obj\libexpat -D"" -aa -Tpd -x -Gn -Gi -q"/> + </OPTIONS> + <LINKER> + <ALLOBJ value="c0d32.obj $(OBJFILES)"/> + <ALLRES value="$(RESFILES)"/> + <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib"/> + </LINKER> + <IDEOPTIONS> +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1033 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=4 +Item0=..\lib;$(BCB)\include +Item1=$(BCB)\include +Item2=$(BCB)\include;$(BCB)\include\mfc;$(BCB)\include\atl +Item3=$(BCB)\include;$(BCB)\include\mfc;$(BCB)\include\atl; + +[HistoryLists\hlLibraryPath] +Count=5 +Item0=..\lib;$(BCB)\lib;$(RELEASELIBPATH) +Item1=..\lib;$(BCB)\lib;..\lib\$(RELEASELIBPATH) +Item2=$(BCB)\lib;$(RELEASELIBPATH) +Item3=$(BCB)\lib;$(RELEASELIBPATH);$(BCB)\lib\psdk +Item4=$(BCB)\lib;$(RELEASELIBPATH);;$(BCB)\lib\psdk; + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=8 +Item0=_WINDOWS;WIN32;NDEBUG;_USRDLL;COMPILED_FROM_DSP;EXPAT_EXPORTS +Item1=_WINDOWS;WIN32;NDEBUG;_DEBUG;_USRDLL;COMPILED_FROM_DSP;EXPAT_EXPORTS +Item2=WIN32;_WINDOWS;NDEBUG;_DEBUG;_USRDLL;COMPILED_FROM_DSP;EXPAT_EXPORTS +Item3=WIN32;_WINDOWS;NDEBUG;_DEBUG;_USRDLL;EXPAT_EXPORTS;COMPILED_FROM_DSP +Item4=NDEBUG;WIN32;_WINDOWS;_USRDLL;_DEBUG;EXPAT_EXPORTS;COMPILED_FROM_DSP +Item5=NDEBUG;WIN32;_WINDOWS;_USRDLL;EXPAT_EXPORTS;COMPILED_FROM_DSP;_DEBUG +Item6=NDEBUG;WIN32;_WINDOWS;_MBCS;_USRDLL;EXPAT_EXPORTS;COMPILED_FROM_DSP;_DEBUG +Item7=NDEBUG;WIN32;_WINDOWS;_MBCS;_USRDLL;EXPAT_EXPORTS;COMPILED_FROM_DSP + +[HistoryLists\hlIntOutputDir] +Count=7 +Item0=Release\obj\libexpat +Item1=Release\obj\libexpat_static +Item2=Release\obj\mtd +Item3=Release\obj\mt +Item4=Release\obj +Item5=Release +Item6=..\lib\Release + +[HistoryLists\hlFinalOutputDir] +Count=1 +Item0=Release\ + +[Debugging] +DebugSourceDirs= + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + </IDEOPTIONS> +</PROJECT>
\ No newline at end of file diff --git a/extras/expat/bcb5/expat.mak b/extras/expat/bcb5/expat.mak new file mode 100644 index 000000000..68e19db31 --- /dev/null +++ b/extras/expat/bcb5/expat.mak @@ -0,0 +1,187 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.05.03 +# --------------------------------------------------------------------------- +PROJECT = Release\libexpat_mtd.dll +OBJFILES = Release\obj\libexpat\xmlparse.obj Release\obj\libexpat\xmlrole.obj \ + Release\obj\libexpat\xmltok.obj +RESFILES = +MAINSOURCE = expat.bpf +RESDEPEN = $(RESFILES) +LIBFILES = +IDLFILES = +IDLGENFILES = +LIBRARIES = +PACKAGES = VCL50.bpi VCLX50.bpi bcbsmp50.bpi QRPT50.bpi VCLDB50.bpi VCLBDE50.bpi \ + ibsmp50.bpi VCLDBX50.bpi TEEUI50.bpi TEEDB50.bpi TEE50.bpi TEEQR50.bpi \ + VCLIB50.bpi bcbie50.bpi VCLIE50.bpi INETDB50.bpi INET50.bpi NMFAST50.bpi \ + dclocx50.bpi bcb2kaxserver50.bpi dclusr50.bpi +SPARELIBS = +DEFFILE = libexpat_mtd.def +# --------------------------------------------------------------------------- +PATHCPP = .;..\lib +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = _WINDOWS;WIN32;NDEBUG;_USRDLL;COMPILED_FROM_DSP;EXPAT_EXPORTS +SYSDEFINES = _NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL +INCLUDEPATH = ..\lib;$(BCB)\include +LIBPATH = ..\lib;$(BCB)\lib;$(RELEASELIBPATH) +WARNINGS= -w-rch -w-par -w-8027 -w-8026 -w-ccc +# --------------------------------------------------------------------------- +CFLAG1 = -WD -O2 -X- -a8 -b -k- -vi -q -tWM -c -tWD +IDLCFLAGS = -I$(BCB)\include +PFLAGS = -N2Release\obj\libexpat -N0Release\obj\libexpat -$Y- -$L- -$D- +RFLAGS = /l 0x409 /d "NDEBUG" /i$(BCB)\include +AFLAGS = /mx /w2 /zn +LFLAGS = -IRelease\obj\libexpat -D"" -aa -Tpd -x -Gn -Gi -q +# --------------------------------------------------------------------------- +ALLOBJ = c0d32.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +!endif + + + + + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if "$(USERDEFINES)" != "" +AUSERDEFINES = -d$(USERDEFINES:;= -d) +!else +AUSERDEFINES = +!endif + +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(IDLGENFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) -L$(LIBPATH) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) -i$(INCLUDEPATH:;= -i) $(AUSERDEFINES) -d$(SYSDEFINES:;= -d) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $< +# --------------------------------------------------------------------------- + + + + diff --git a/extras/expat/bcb5/expat_static.bpf b/extras/expat/bcb5/expat_static.bpf new file mode 100644 index 000000000..5ca458edc --- /dev/null +++ b/extras/expat/bcb5/expat_static.bpf @@ -0,0 +1,5 @@ +USEUNIT("..\lib\xmlparse.c"); +USEUNIT("..\lib\xmlrole.c"); +USEUNIT("..\lib\xmltok.c"); +//--------------------------------------------------------------------------- +#define Library diff --git a/extras/expat/bcb5/expat_static.bpr b/extras/expat/bcb5/expat_static.bpr new file mode 100644 index 000000000..2f6ec4d3b --- /dev/null +++ b/extras/expat/bcb5/expat_static.bpr @@ -0,0 +1,143 @@ +<?xml version='1.0' encoding='utf-8' ?> +<!-- C++Builder XML Project --> +<PROJECT> + <MACROS> + <VERSION value="BCB.05.03"/> + <PROJECT value="Release\libexpats_mtd.lib"/> + <OBJFILES value="Release\obj\libexpat_static\xmlparse.obj + Release\obj\libexpat_static\xmlrole.obj + Release\obj\libexpat_static\xmltok.obj"/> + <RESFILES value=""/> + <IDLFILES value=""/> + <IDLGENFILES value=""/> + <DEFFILE value=""/> + <RESDEPEN value="$(RESFILES)"/> + <LIBFILES value=""/> + <LIBRARIES value=""/> + <SPARELIBS value=""/> + <PACKAGES value=""/> + <PATHCPP value=".;..\lib"/> + <PATHPAS value=".;"/> + <PATHRC value=".;"/> + <PATHASM value=".;"/> + <DEBUGLIBPATH value="$(BCB)\lib\debug"/> + <RELEASELIBPATH value="$(BCB)\lib\release"/> + <LINKER value="TLib"/> + <USERDEFINES value="_WINDOWS;WIN32;NDEBUG;_LIB;COMPILED_FROM_DSP;XML_STATIC"/> + <SYSDEFINES value="_NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL"/> + <MAINSOURCE value="expat_static.bpf"/> + <INCLUDEPATH value="..\lib;$(BCB)\include"/> + <LIBPATH value="..\lib;$(BCB)\lib;$(RELEASELIBPATH)"/> + <WARNINGS value="-w-rch -w-par -w-8027 -w-8026 -w-ccc"/> + <LISTFILE value=""/> + </MACROS> + <OPTIONS> + <IDLCFLAGS value="-I$(BCB)\include"/> + <CFLAG1 value="-O2 -X- -a8 -b -k- -vi -q -tWM -c"/> + <PFLAGS value="-N2Release\obj\libexpat_static -N0Release\obj\libexpat_static -$Y- -$L- -$D-"/> + <RFLAGS value="/l 0x409 /d "NDEBUG" /i$(BCB)\include"/> + <AFLAGS value="/mx /w2 /zn"/> + <LFLAGS value=""/> + </OPTIONS> + <LINKER> + <ALLOBJ value="$(OBJFILES)"/> + <ALLRES value="$(RESFILES)"/> + <ALLLIB value="$(LIBFILES) $(LIBRARIES)"/> + </LINKER> + <IDEOPTIONS> +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1033 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=4 +Item0=..\lib;$(BCB)\include +Item1=$(BCB)\include +Item2=$(BCB)\include;$(BCB)\include\mfc;$(BCB)\include\atl +Item3=$(BCB)\include;$(BCB)\include\mfc;$(BCB)\include\atl; + +[HistoryLists\hlLibraryPath] +Count=5 +Item0=..\lib;$(BCB)\lib;$(RELEASELIBPATH) +Item1=..\lib;$(BCB)\lib;..\lib\$(RELEASELIBPATH) +Item2=$(BCB)\lib;$(RELEASELIBPATH) +Item3=$(BCB)\lib;$(RELEASELIBPATH);$(BCB)\lib\psdk +Item4=$(BCB)\lib;$(RELEASELIBPATH);;$(BCB)\lib\psdk; + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=7 +Item0=_WINDOWS;WIN32;NDEBUG;_LIB;COMPILED_FROM_DSP;XML_STATIC +Item1=_WINDOWS;WIN32;NDEBUG;_DEBUG;_LIB;COMPILED_FROM_DSP;XML_STATIC +Item2=WIN32;_WINDOWS;NDEBUG;_DEBUG;_LIB;COMPILED_FROM_DSP;XML_STATIC +Item3=WIN32;_WINDOWS;NDEBUG;_LIB;COMPILED_FROM_DSP;_DEBUG +Item4=WIN32;_WINDOWS;NDEBUG;_LIB;COMPILED_FROM_DSP +Item5=WIN32;_WINDOWS;NDEBUG;_LIB;COMPILED_FROM_DSP;_MBCS +Item6=WIN32;_WINDOWS;NDEBUG;_MBCS;_LIB;COMPILED_FROM_DSP + +[HistoryLists\hlIntOutputDir] +Count=6 +Item0=Release\obj\libexpat_static +Item1=Release\obj\mts +Item2=Release\obj\mt +Item3=Release +Item4=..\lib\Release_static +Item5=Release_static + +[HistoryLists\hlFinalOutputDir] +Count=3 +Item0=Release\ +Item1=Release +Item2=Release_static\ + +[HistoryLists\hlTlibPageSize] +Count=1 +Item0=0x0010 + +[Debugging] +DebugSourceDirs= + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + </IDEOPTIONS> +</PROJECT>
\ No newline at end of file diff --git a/extras/expat/bcb5/expat_static.mak b/extras/expat/bcb5/expat_static.mak new file mode 100644 index 000000000..9137d3b53 --- /dev/null +++ b/extras/expat/bcb5/expat_static.mak @@ -0,0 +1,189 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.05.03 +# --------------------------------------------------------------------------- +PROJECT = Release\libexpats_mtd.lib +OBJFILES = Release\obj\libexpat_static\xmlparse.obj \ + Release\obj\libexpat_static\xmlrole.obj \ + Release\obj\libexpat_static\xmltok.obj +RESFILES = +MAINSOURCE = expat_static.bpf +RESDEPEN = $(RESFILES) +LIBFILES = +IDLFILES = +IDLGENFILES = +LIBRARIES = +PACKAGES = +SPARELIBS = +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .;..\lib +PATHASM = .; +PATHPAS = .; +PATHRC = .; +LINKER = TLib +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = _WINDOWS;WIN32;NDEBUG;_LIB;COMPILED_FROM_DSP;XML_STATIC +SYSDEFINES = _NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL +INCLUDEPATH = ..\lib;$(BCB)\include +LIBPATH = ..\lib;$(BCB)\lib;$(RELEASELIBPATH) +WARNINGS = -w-rch -w-par -w-8027 -w-8026 -w-ccc +LISTFILE = +# --------------------------------------------------------------------------- +CFLAG1 = -O2 -X- -a8 -b -k- -vi -q -tWM -c +IDLCFLAGS = -I$(BCB)\include +PFLAGS = -N2Release\obj\libexpat_static -N0Release\obj\libexpat_static -$Y- -$L- -$D- +RFLAGS = /l 0x409 /d "NDEBUG" /i$(BCB)\include +AFLAGS = /mx /w2 /zn +LFLAGS = +# --------------------------------------------------------------------------- +ALLOBJ = $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +!endif + + + + + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if "$(USERDEFINES)" != "" +AUSERDEFINES = -d$(USERDEFINES:;= -d) +!else +AUSERDEFINES = +!endif + +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = TLib +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +!if "$(LISTFILE)" == "" +COMMA = +!else +COMMA = , +!endif + +$(PROJECT): $(IDLGENFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) /u $@ @&&! + $(LFLAGS) $? $(COMMA) $(LISTFILE) + +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) -i$(INCLUDEPATH:;= -i) $(AUSERDEFINES) -d$(SYSDEFINES:;= -d) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $< +# --------------------------------------------------------------------------- + + + + diff --git a/extras/expat/bcb5/expatw.bpf b/extras/expat/bcb5/expatw.bpf new file mode 100644 index 000000000..188a6d54e --- /dev/null +++ b/extras/expat/bcb5/expatw.bpf @@ -0,0 +1,6 @@ +USEUNIT("..\lib\xmlparse.c"); +USEUNIT("..\lib\xmlrole.c"); +USEUNIT("..\lib\xmltok.c"); +USEDEF("libexpatw_mtd.def"); +//--------------------------------------------------------------------------- +#define DllEntryPoint diff --git a/extras/expat/bcb5/expatw.bpr b/extras/expat/bcb5/expatw.bpr new file mode 100644 index 000000000..9ec50010b --- /dev/null +++ b/extras/expat/bcb5/expatw.bpr @@ -0,0 +1,146 @@ +<?xml version='1.0' encoding='utf-8' ?> +<!-- C++Builder XML Project --> +<PROJECT> + <MACROS> + <VERSION value="BCB.05.03"/> + <PROJECT value="Release\libexpatw_mtd.dll"/> + <OBJFILES value="Release\obj\libexpatw\xmlparse.obj Release\obj\libexpatw\xmlrole.obj + Release\obj\libexpatw\xmltok.obj"/> + <RESFILES value=""/> + <IDLFILES value=""/> + <IDLGENFILES value=""/> + <DEFFILE value="libexpatw_mtd.def"/> + <RESDEPEN value="$(RESFILES)"/> + <LIBFILES value=""/> + <LIBRARIES value=""/> + <SPARELIBS value=""/> + <PACKAGES value="VCL50.bpi VCLX50.bpi bcbsmp50.bpi QRPT50.bpi VCLDB50.bpi VCLBDE50.bpi + ibsmp50.bpi VCLDBX50.bpi TEEUI50.bpi TEEDB50.bpi TEE50.bpi TEEQR50.bpi + VCLIB50.bpi bcbie50.bpi VCLIE50.bpi INETDB50.bpi INET50.bpi NMFAST50.bpi + dclocx50.bpi bcb2kaxserver50.bpi dclusr50.bpi"/> + <PATHCPP value=".;..\lib"/> + <PATHPAS value=".;"/> + <PATHRC value=".;"/> + <PATHASM value=".;"/> + <DEBUGLIBPATH value="$(BCB)\lib\debug"/> + <RELEASELIBPATH value="$(BCB)\lib\release"/> + <LINKER value="ilink32"/> + <USERDEFINES value="_WINDOWS;WIN32;NDEBUG;_USRDLL;COMPILED_FROM_DSP;EXPAT_EXPORTS;XML_UNICODE_WCHAR_T"/> + <SYSDEFINES value="_NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL"/> + <MAINSOURCE value="expatw.bpf"/> + <INCLUDEPATH value="..\lib;$(BCB)\include"/> + <LIBPATH value="..\lib;$(BCB)\lib;$(RELEASELIBPATH)"/> + <WARNINGS value="-w-rch -w-par -w-8027 -w-8026 -w-ccc"/> + </MACROS> + <OPTIONS> + <IDLCFLAGS value="-I$(BCB)\include"/> + <CFLAG1 value="-WD -O2 -X- -a8 -b -k- -vi -q -tWM -c -tWD"/> + <PFLAGS value="-N2Release\obj\libexpatw -N0Release\obj\libexpatw -$Y- -$L- -$D-"/> + <RFLAGS value="/l 0x409 /d "NDEBUG" /i$(BCB)\include"/> + <AFLAGS value="/mx /w2 /zn"/> + <LFLAGS value="-IRelease\obj\libexpatw -D"" -aa -Tpd -x -Gn -Gi -w -q"/> + </OPTIONS> + <LINKER> + <ALLOBJ value="c0d32w.obj $(OBJFILES)"/> + <ALLRES value="$(RESFILES)"/> + <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib"/> + </LINKER> + <IDEOPTIONS> +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1033 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=4 +Item0=..\lib;$(BCB)\include +Item1=$(BCB)\include +Item2=$(BCB)\include;$(BCB)\include\mfc;$(BCB)\include\atl +Item3=$(BCB)\include;$(BCB)\include\mfc;$(BCB)\include\atl; + +[HistoryLists\hlLibraryPath] +Count=5 +Item0=..\lib;$(BCB)\lib;$(RELEASELIBPATH) +Item1=..\lib;$(BCB)\lib;..\lib\$(RELEASELIBPATH) +Item2=$(BCB)\lib;$(RELEASELIBPATH) +Item3=$(BCB)\lib;$(RELEASELIBPATH);$(BCB)\lib\psdk +Item4=$(BCB)\lib;$(RELEASELIBPATH);;$(BCB)\lib\psdk; + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=9 +Item0=_WINDOWS;WIN32;NDEBUG;_USRDLL;COMPILED_FROM_DSP;EXPAT_EXPORTS;XML_UNICODE_WCHAR_T +Item1=_WINDOWS;WIN32;NDEBUG;_DEBUG;_USRDLL;COMPILED_FROM_DSP;EXPAT_EXPORTS;XML_UNICODE_WCHAR_T +Item2=_WINDOWS;WIN32;NDEBUG;_DEBUG;_USRDLL;EXPAT_EXPORTS;COMPILED_FROM_DSP;XML_UNICODE_WCHAR_T +Item3=NDEBUG;COMPILED_FROM_DSP;WIN32;_WINDOWS;_USRDLL;EXPAT_EXPORTS;_DEBUG;XML_UNICODE_WCHAR_T +Item4=NDEBUG;COMPILED_FROM_DSP;WIN32;_WINDOWS;_USRDLL;EXPAT_EXPORTS;XML_UNICODE_WCHAR_T;_DEBUG +Item5=NDEBUG;COMPILED_FROM_DSP;WIN32;_WINDOWS;_UNICODE;_USRDLL;EXPAT_EXPORTS;XML_UNICODE_WCHAR_T;_DEBUG +Item6=NDEBUG;COMPILED_FROM_DSP;WIN32;_WINDOWS;_UNICODE;_USRDLL;EXPAT_EXPORTS;XML_UNICODE_WCHAR_T +Item7=NDEBUG;COMPILED_FROM_DSP;WIN32;_WINDOWS;_MBCS;_USRDLL;EXPAT_EXPORTS;XML_UNICODE_WCHAR_T;XML_UNICODE +Item8=NDEBUG;COMPILED_FROM_DSP;WIN32;_WINDOWS;_MBCS;_USRDLL;EXPAT_EXPORTS;XML_UNICODE_WCHAR_T + +[HistoryLists\hlIntOutputDir] +Count=8 +Item0=Release\obj\libexpatw +Item1=Release\obj\libexpat +Item2=Release\obj\mtd +Item3=Release\obj\mt +Item4=Release_w\obj +Item5=Release-w\obj +Item6=Release-w +Item7=..\lib\Release-w + +[HistoryLists\hlFinalOutputDir] +Count=5 +Item0=Release\ +Item1=Release +Item2=Release_w\ +Item3=Release-w\ +Item4=Release-w + +[Debugging] +DebugSourceDirs= + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + </IDEOPTIONS> +</PROJECT>
\ No newline at end of file diff --git a/extras/expat/bcb5/expatw.mak b/extras/expat/bcb5/expatw.mak new file mode 100644 index 000000000..97f428f4d --- /dev/null +++ b/extras/expat/bcb5/expatw.mak @@ -0,0 +1,187 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.05.03 +# --------------------------------------------------------------------------- +PROJECT = Release\libexpatw_mtd.dll +OBJFILES = Release\obj\libexpatw\xmlparse.obj Release\obj\libexpatw\xmlrole.obj \ + Release\obj\libexpatw\xmltok.obj +RESFILES = +MAINSOURCE = expatw.bpf +RESDEPEN = $(RESFILES) +LIBFILES = +IDLFILES = +IDLGENFILES = +LIBRARIES = +PACKAGES = VCL50.bpi VCLX50.bpi bcbsmp50.bpi QRPT50.bpi VCLDB50.bpi VCLBDE50.bpi \ + ibsmp50.bpi VCLDBX50.bpi TEEUI50.bpi TEEDB50.bpi TEE50.bpi TEEQR50.bpi \ + VCLIB50.bpi bcbie50.bpi VCLIE50.bpi INETDB50.bpi INET50.bpi NMFAST50.bpi \ + dclocx50.bpi bcb2kaxserver50.bpi dclusr50.bpi +SPARELIBS = +DEFFILE = libexpatw_mtd.def +# --------------------------------------------------------------------------- +PATHCPP = .;..\lib +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = _WINDOWS;WIN32;NDEBUG;_USRDLL;COMPILED_FROM_DSP;EXPAT_EXPORTS;XML_UNICODE_WCHAR_T +SYSDEFINES = _NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL +INCLUDEPATH = ..\lib;$(BCB)\include +LIBPATH = ..\lib;$(BCB)\lib;$(RELEASELIBPATH) +WARNINGS= -w-rch -w-par -w-8027 -w-8026 -w-ccc +# --------------------------------------------------------------------------- +CFLAG1 = -WD -O2 -X- -a8 -b -k- -vi -q -tWM -c -tWD +IDLCFLAGS = -I$(BCB)\include +PFLAGS = -N2Release\obj\libexpatw -N0Release\obj\libexpatw -$Y- -$L- -$D- +RFLAGS = /l 0x409 /d "NDEBUG" /i$(BCB)\include +AFLAGS = /mx /w2 /zn +LFLAGS = -IRelease\obj\libexpatw -D"" -aa -Tpd -x -Gn -Gi -w -q +# --------------------------------------------------------------------------- +ALLOBJ = c0d32w.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +!endif + + + + + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if "$(USERDEFINES)" != "" +AUSERDEFINES = -d$(USERDEFINES:;= -d) +!else +AUSERDEFINES = +!endif + +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(IDLGENFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) -L$(LIBPATH) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) -i$(INCLUDEPATH:;= -i) $(AUSERDEFINES) -d$(SYSDEFINES:;= -d) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $< +# --------------------------------------------------------------------------- + + + + diff --git a/extras/expat/bcb5/expatw_static.bpf b/extras/expat/bcb5/expatw_static.bpf new file mode 100644 index 000000000..5ca458edc --- /dev/null +++ b/extras/expat/bcb5/expatw_static.bpf @@ -0,0 +1,5 @@ +USEUNIT("..\lib\xmlparse.c"); +USEUNIT("..\lib\xmlrole.c"); +USEUNIT("..\lib\xmltok.c"); +//--------------------------------------------------------------------------- +#define Library diff --git a/extras/expat/bcb5/expatw_static.bpr b/extras/expat/bcb5/expatw_static.bpr new file mode 100644 index 000000000..3f12644b6 --- /dev/null +++ b/extras/expat/bcb5/expatw_static.bpr @@ -0,0 +1,152 @@ +<?xml version='1.0' encoding='utf-8' ?> +<!-- C++Builder XML Project --> +<PROJECT> + <MACROS> + <VERSION value="BCB.05.03"/> + <PROJECT value="Release\libexpatws_mtd.lib"/> + <OBJFILES value="Release\obj\libexpatw_static\xmlparse.obj + Release\obj\libexpatw_static\xmlrole.obj + Release\obj\libexpatw_static\xmltok.obj"/> + <RESFILES value=""/> + <IDLFILES value=""/> + <IDLGENFILES value=""/> + <DEFFILE value=""/> + <RESDEPEN value="$(RESFILES)"/> + <LIBFILES value=""/> + <LIBRARIES value=""/> + <SPARELIBS value=""/> + <PACKAGES value=""/> + <PATHCPP value=".;..\lib"/> + <PATHPAS value=".;"/> + <PATHRC value=".;"/> + <PATHASM value=".;"/> + <DEBUGLIBPATH value="$(BCB)\lib\debug"/> + <RELEASELIBPATH value="$(BCB)\lib\release"/> + <LINKER value="TLib"/> + <USERDEFINES value="_WINDOWS;WIN32;NDEBUG;_LIB;COMPILED_FROM_DSP;XML_STATIC;XML_UNICODE_WCHAR_T"/> + <SYSDEFINES value="_NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL"/> + <MAINSOURCE value="expatw_static.bpf"/> + <INCLUDEPATH value="..\lib;$(BCB)\include"/> + <LIBPATH value="..\lib;$(BCB)\lib;$(RELEASELIBPATH)"/> + <WARNINGS value="-w-rch -w-par -w-8027 -w-8026 -w-ccc"/> + <LISTFILE value=""/> + </MACROS> + <OPTIONS> + <IDLCFLAGS value="-I$(BCB)\include"/> + <CFLAG1 value="-O2 -X- -a8 -b -k- -vi -q -tWM -c"/> + <PFLAGS value="-N2Release\obj\libexpatw_static -N0Release\obj\libexpatw_static -$Y- -$L- + -$D-"/> + <RFLAGS value="/l 0x409 /d "NDEBUG" /i$(BCB)\include"/> + <AFLAGS value="/mx /w2 /zn"/> + <LFLAGS value=""/> + </OPTIONS> + <LINKER> + <ALLOBJ value="$(OBJFILES)"/> + <ALLRES value="$(RESFILES)"/> + <ALLLIB value="$(LIBFILES) $(LIBRARIES)"/> + </LINKER> + <IDEOPTIONS> +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1033 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=4 +Item0=..\lib;$(BCB)\include +Item1=$(BCB)\include +Item2=$(BCB)\include;$(BCB)\include\mfc;$(BCB)\include\atl +Item3=$(BCB)\include;$(BCB)\include\mfc;$(BCB)\include\atl; + +[HistoryLists\hlLibraryPath] +Count=5 +Item0=..\lib;$(BCB)\lib;$(RELEASELIBPATH) +Item1=..\lib;$(BCB)\lib;..\lib\$(RELEASELIBPATH) +Item2=$(BCB)\lib;$(RELEASELIBPATH) +Item3=$(BCB)\lib;$(RELEASELIBPATH);$(BCB)\lib\psdk +Item4=$(BCB)\lib;$(RELEASELIBPATH);;$(BCB)\lib\psdk; + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=15 +Item0=_WINDOWS;WIN32;NDEBUG;_LIB;COMPILED_FROM_DSP;XML_STATIC;XML_UNICODE_WCHAR_T +Item1=_WINDOWS;WIN32;NDEBUG;_DEBUG;_LIB;COMPILED_FROM_DSP;XML_STATIC;XML_UNICODE_WCHAR_T +Item2=WIN32;_WINDOWS;NDEBUG;_DEBUG;_LIB;COMPILED_FROM_DSP;XML_STATIC;XML_UNICODE_WCHAR_T +Item3=WIN32;_WINDOWS;NDEBUG;_DEBUG;_LIB;XML_STATIC;COMPILED_FROM_DSP;XML_UNICODE_WCHAR_T +Item4=WIN32;_WINDOWS;NDEBUG;_LIB;COMPILED_FROM_DSP;_DEBUG;XML_UNICODE_WCHAR_T +Item5=WIN32;_WINDOWS;NDEBUG;_UNICODE;_LIB;COMPILED_FROM_DSP;XML_UNICODE_WCHAR_T;_DEBUG +Item6=WIN32;_WINDOWS;NDEBUG;_UNICODE;_LIB;COMPILED_FROM_DSP;XML_UNICODE_WCHAR_T;_DEBUG;__cplusplus +Item7=WIN32;_WINDOWS;NDEBUG;_UNICODE;_LIB;COMPILED_FROM_DSP;XML_UNICODE;_DEBUG +Item8=WIN32;_WINDOWS;NDEBUG;_MBCS;_LIB;COMPILED_FROM_DSP;XML_UNICODE;_DEBUG +Item9=WIN32;_WINDOWS;NDEBUG;_MBCS;_LIB;COMPILED_FROM_DSP;XML_UNICODE_WCHAR_T;_DEBUG;__WCHAR_T +Item10=WIN32;_WINDOWS;NDEBUG;_MBCS;_LIB;COMPILED_FROM_DSP;XML_UNICODE_WCHAR_T;_DEBUG;_UNICODE +Item11=WIN32;_WINDOWS;NDEBUG;_MBCS;_LIB;COMPILED_FROM_DSP;XML_UNICODE;_DEBUG;_UNICODE +Item12=WIN32;_WINDOWS;NDEBUG;_MBCS;_LIB;COMPILED_FROM_DSP;XML_UNICODE_WCHAR_T;_DEBUG +Item13=WIN32;_WINDOWS;NDEBUG;_MBCS;_LIB;COMPILED_FROM_DSP;XML_UNICODE_WCHAR_T +Item14=WIN32;_WINDOWS;NDEBUG;_MBCS;_LIB;COMPILED_FROM_DSP;XML_UNICODE_WCHAR_T;XML_UNICODE + +[HistoryLists\hlIntOutputDir] +Count=6 +Item0=Release\obj\libexpatw_static +Item1=Release\obj\libexpat_static +Item2=Release\obj\mts +Item3=Release\obj\mt +Item4=..\lib\Release-w_static +Item5=Release-w_static + +[HistoryLists\hlFinalOutputDir] +Count=3 +Item0=Release\ +Item1=Release +Item2=Release-w_static\ + +[HistoryLists\hlTlibPageSize] +Count=1 +Item0=0x0010 + +[Debugging] +DebugSourceDirs= + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + </IDEOPTIONS> +</PROJECT>
\ No newline at end of file diff --git a/extras/expat/bcb5/expatw_static.mak b/extras/expat/bcb5/expatw_static.mak new file mode 100644 index 000000000..16b7e5b90 --- /dev/null +++ b/extras/expat/bcb5/expatw_static.mak @@ -0,0 +1,190 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.05.03 +# --------------------------------------------------------------------------- +PROJECT = Release\libexpatws_mtd.lib +OBJFILES = Release\obj\libexpatw_static\xmlparse.obj \ + Release\obj\libexpatw_static\xmlrole.obj \ + Release\obj\libexpatw_static\xmltok.obj +RESFILES = +MAINSOURCE = expatw_static.bpf +RESDEPEN = $(RESFILES) +LIBFILES = +IDLFILES = +IDLGENFILES = +LIBRARIES = +PACKAGES = +SPARELIBS = +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .;..\lib +PATHASM = .; +PATHPAS = .; +PATHRC = .; +LINKER = TLib +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = _WINDOWS;WIN32;NDEBUG;_LIB;COMPILED_FROM_DSP;XML_STATIC;XML_UNICODE_WCHAR_T +SYSDEFINES = _NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL +INCLUDEPATH = ..\lib;$(BCB)\include +LIBPATH = ..\lib;$(BCB)\lib;$(RELEASELIBPATH) +WARNINGS = -w-rch -w-par -w-8027 -w-8026 -w-ccc +LISTFILE = +# --------------------------------------------------------------------------- +CFLAG1 = -O2 -X- -a8 -b -k- -vi -q -tWM -c +IDLCFLAGS = -I$(BCB)\include +PFLAGS = -N2Release\obj\libexpatw_static -N0Release\obj\libexpatw_static -$Y- -$L- \ + -$D- +RFLAGS = /l 0x409 /d "NDEBUG" /i$(BCB)\include +AFLAGS = /mx /w2 /zn +LFLAGS = +# --------------------------------------------------------------------------- +ALLOBJ = $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +!endif + + + + + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if "$(USERDEFINES)" != "" +AUSERDEFINES = -d$(USERDEFINES:;= -d) +!else +AUSERDEFINES = +!endif + +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = TLib +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +!if "$(LISTFILE)" == "" +COMMA = +!else +COMMA = , +!endif + +$(PROJECT): $(IDLGENFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) /u $@ @&&! + $(LFLAGS) $? $(COMMA) $(LISTFILE) + +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) -i$(INCLUDEPATH:;= -i) $(AUSERDEFINES) -d$(SYSDEFINES:;= -d) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $< +# --------------------------------------------------------------------------- + + + + diff --git a/extras/expat/bcb5/libexpat_mtd.def b/extras/expat/bcb5/libexpat_mtd.def new file mode 100644 index 000000000..35ebd6b97 --- /dev/null +++ b/extras/expat/bcb5/libexpat_mtd.def @@ -0,0 +1,133 @@ +; DEF file for BCB5 +LIBRARY LIBEXPAT_MTD +DESCRIPTION "Implements an XML parser." +EXPORTS + _XML_DefaultCurrent @1 + _XML_ErrorString @2 + _XML_ExpatVersion @3 + _XML_ExpatVersionInfo @4 + _XML_ExternalEntityParserCreate @5 + _XML_GetBase @6 + _XML_GetBuffer @7 + _XML_GetCurrentByteCount @8 + _XML_GetCurrentByteIndex @9 + _XML_GetCurrentColumnNumber @10 + _XML_GetCurrentLineNumber @11 + _XML_GetErrorCode @12 + _XML_GetIdAttributeIndex @13 + _XML_GetInputContext @14 + _XML_GetSpecifiedAttributeCount @15 + _XML_Parse @16 + _XML_ParseBuffer @17 + _XML_ParserCreate @18 + _XML_ParserCreateNS @19 + _XML_ParserCreate_MM @20 + _XML_ParserFree @21 + _XML_SetAttlistDeclHandler @22 + _XML_SetBase @23 + _XML_SetCdataSectionHandler @24 + _XML_SetCharacterDataHandler @25 + _XML_SetCommentHandler @26 + _XML_SetDefaultHandler @27 + _XML_SetDefaultHandlerExpand @28 + _XML_SetDoctypeDeclHandler @29 + _XML_SetElementDeclHandler @30 + _XML_SetElementHandler @31 + _XML_SetEncoding @32 + _XML_SetEndCdataSectionHandler @33 + _XML_SetEndDoctypeDeclHandler @34 + _XML_SetEndElementHandler @35 + _XML_SetEndNamespaceDeclHandler @36 + _XML_SetEntityDeclHandler @37 + _XML_SetExternalEntityRefHandler @38 + _XML_SetExternalEntityRefHandlerArg @39 + _XML_SetNamespaceDeclHandler @40 + _XML_SetNotStandaloneHandler @41 + _XML_SetNotationDeclHandler @42 + _XML_SetParamEntityParsing @43 + _XML_SetProcessingInstructionHandler @44 + _XML_SetReturnNSTriplet @45 + _XML_SetStartCdataSectionHandler @46 + _XML_SetStartDoctypeDeclHandler @47 + _XML_SetStartElementHandler @48 + _XML_SetStartNamespaceDeclHandler @49 + _XML_SetUnknownEncodingHandler @50 + _XML_SetUnparsedEntityDeclHandler @51 + _XML_SetUserData @52 + _XML_SetXmlDeclHandler @53 + _XML_UseParserAsHandlerArg @54 +; added with version 1.95.3 + _XML_ParserReset @55 + _XML_SetSkippedEntityHandler @56 +; added with version 1.95.5 + _XML_GetFeatureList @57 + _XML_UseForeignDTD @58 +; added with version 1.95.6 + _XML_FreeContentModel @59 + _XML_MemMalloc @60 + _XML_MemRealloc @61 + _XML_MemFree @62 + +; Aliases for MS compatible names + XML_DefaultCurrent = _XML_DefaultCurrent + XML_ErrorString = _XML_ErrorString + XML_ExpatVersion = _XML_ExpatVersion + XML_ExpatVersionInfo = _XML_ExpatVersionInfo + XML_ExternalEntityParserCreate = _XML_ExternalEntityParserCreate + XML_GetBase = _XML_GetBase + XML_GetBuffer = _XML_GetBuffer + XML_GetCurrentByteCount = _XML_GetCurrentByteCount + XML_GetCurrentByteIndex = _XML_GetCurrentByteIndex + XML_GetCurrentColumnNumber = _XML_GetCurrentColumnNumber + XML_GetCurrentLineNumber = _XML_GetCurrentLineNumber + XML_GetErrorCode = _XML_GetErrorCode + XML_GetIdAttributeIndex = _XML_GetIdAttributeIndex + XML_GetInputContext = _XML_GetInputContext + XML_GetSpecifiedAttributeCount = _XML_GetSpecifiedAttributeCount + XML_Parse = _XML_Parse + XML_ParseBuffer = _XML_ParseBuffer + XML_ParserCreate = _XML_ParserCreate + XML_ParserCreateNS = _XML_ParserCreateNS + XML_ParserCreate_MM = _XML_ParserCreate_MM + XML_ParserFree = _XML_ParserFree + XML_SetAttlistDeclHandler = _XML_SetAttlistDeclHandler + XML_SetBase = _XML_SetBase + XML_SetCdataSectionHandler = _XML_SetCdataSectionHandler + XML_SetCharacterDataHandler = _XML_SetCharacterDataHandler + XML_SetCommentHandler = _XML_SetCommentHandler + XML_SetDefaultHandler = _XML_SetDefaultHandler + XML_SetDefaultHandlerExpand = _XML_SetDefaultHandlerExpand + XML_SetDoctypeDeclHandler = _XML_SetDoctypeDeclHandler + XML_SetElementDeclHandler = _XML_SetElementDeclHandler + XML_SetElementHandler = _XML_SetElementHandler + XML_SetEncoding = _XML_SetEncoding + XML_SetEndCdataSectionHandler = _XML_SetEndCdataSectionHandler + XML_SetEndDoctypeDeclHandler = _XML_SetEndDoctypeDeclHandler + XML_SetEndElementHandler = _XML_SetEndElementHandler + XML_SetEndNamespaceDeclHandler = _XML_SetEndNamespaceDeclHandler + XML_SetEntityDeclHandler = _XML_SetEntityDeclHandler + XML_SetExternalEntityRefHandler = _XML_SetExternalEntityRefHandler + XML_SetExternalEntityRefHandlerArg = _XML_SetExternalEntityRefHandlerArg + XML_SetNamespaceDeclHandler = _XML_SetNamespaceDeclHandler + XML_SetNotStandaloneHandler = _XML_SetNotStandaloneHandler + XML_SetNotationDeclHandler = _XML_SetNotationDeclHandler + XML_SetParamEntityParsing = _XML_SetParamEntityParsing + XML_SetProcessingInstructionHandler = _XML_SetProcessingInstructionHandler + XML_SetReturnNSTriplet = _XML_SetReturnNSTriplet + XML_SetStartCdataSectionHandler = _XML_SetStartCdataSectionHandler + XML_SetStartDoctypeDeclHandler = _XML_SetStartDoctypeDeclHandler + XML_SetStartElementHandler = _XML_SetStartElementHandler + XML_SetStartNamespaceDeclHandler = _XML_SetStartNamespaceDeclHandler + XML_SetUnknownEncodingHandler = _XML_SetUnknownEncodingHandler + XML_SetUnparsedEntityDeclHandler = _XML_SetUnparsedEntityDeclHandler + XML_SetUserData = _XML_SetUserData + XML_SetXmlDeclHandler = _XML_SetXmlDeclHandler + XML_UseParserAsHandlerArg = _XML_UseParserAsHandlerArg + XML_ParserReset = _XML_ParserReset + XML_SetSkippedEntityHandler = _XML_SetSkippedEntityHandler + XML_GetFeatureList = _XML_GetFeatureList + XML_UseForeignDTD = _XML_UseForeignDTD + XML_FreeContentModel = _XML_FreeContentModel + XML_MemMalloc = _XML_MemMalloc + XML_MemRealloc = _XML_MemRealloc + XML_MemFree = _XML_MemFree diff --git a/extras/expat/bcb5/libexpatw_mtd.def b/extras/expat/bcb5/libexpatw_mtd.def new file mode 100644 index 000000000..bcb265074 --- /dev/null +++ b/extras/expat/bcb5/libexpatw_mtd.def @@ -0,0 +1,133 @@ +; DEF file for BCB5 +LIBRARY LIBEXPATW_MTD +DESCRIPTION "Implements an XML parser." +EXPORTS + _XML_DefaultCurrent @1 + _XML_ErrorString @2 + _XML_ExpatVersion @3 + _XML_ExpatVersionInfo @4 + _XML_ExternalEntityParserCreate @5 + _XML_GetBase @6 + _XML_GetBuffer @7 + _XML_GetCurrentByteCount @8 + _XML_GetCurrentByteIndex @9 + _XML_GetCurrentColumnNumber @10 + _XML_GetCurrentLineNumber @11 + _XML_GetErrorCode @12 + _XML_GetIdAttributeIndex @13 + _XML_GetInputContext @14 + _XML_GetSpecifiedAttributeCount @15 + _XML_Parse @16 + _XML_ParseBuffer @17 + _XML_ParserCreate @18 + _XML_ParserCreateNS @19 + _XML_ParserCreate_MM @20 + _XML_ParserFree @21 + _XML_SetAttlistDeclHandler @22 + _XML_SetBase @23 + _XML_SetCdataSectionHandler @24 + _XML_SetCharacterDataHandler @25 + _XML_SetCommentHandler @26 + _XML_SetDefaultHandler @27 + _XML_SetDefaultHandlerExpand @28 + _XML_SetDoctypeDeclHandler @29 + _XML_SetElementDeclHandler @30 + _XML_SetElementHandler @31 + _XML_SetEncoding @32 + _XML_SetEndCdataSectionHandler @33 + _XML_SetEndDoctypeDeclHandler @34 + _XML_SetEndElementHandler @35 + _XML_SetEndNamespaceDeclHandler @36 + _XML_SetEntityDeclHandler @37 + _XML_SetExternalEntityRefHandler @38 + _XML_SetExternalEntityRefHandlerArg @39 + _XML_SetNamespaceDeclHandler @40 + _XML_SetNotStandaloneHandler @41 + _XML_SetNotationDeclHandler @42 + _XML_SetParamEntityParsing @43 + _XML_SetProcessingInstructionHandler @44 + _XML_SetReturnNSTriplet @45 + _XML_SetStartCdataSectionHandler @46 + _XML_SetStartDoctypeDeclHandler @47 + _XML_SetStartElementHandler @48 + _XML_SetStartNamespaceDeclHandler @49 + _XML_SetUnknownEncodingHandler @50 + _XML_SetUnparsedEntityDeclHandler @51 + _XML_SetUserData @52 + _XML_SetXmlDeclHandler @53 + _XML_UseParserAsHandlerArg @54 +; added with version 1.95.3 + _XML_ParserReset @55 + _XML_SetSkippedEntityHandler @56 +; added with version 1.95.5 + _XML_GetFeatureList @57 + _XML_UseForeignDTD @58 +; added with version 1.95.6 + _XML_FreeContentModel @59 + _XML_MemMalloc @60 + _XML_MemRealloc @61 + _XML_MemFree @62 + +; Aliases for MS compatible names + XML_DefaultCurrent = _XML_DefaultCurrent + XML_ErrorString = _XML_ErrorString + XML_ExpatVersion = _XML_ExpatVersion + XML_ExpatVersionInfo = _XML_ExpatVersionInfo + XML_ExternalEntityParserCreate = _XML_ExternalEntityParserCreate + XML_GetBase = _XML_GetBase + XML_GetBuffer = _XML_GetBuffer + XML_GetCurrentByteCount = _XML_GetCurrentByteCount + XML_GetCurrentByteIndex = _XML_GetCurrentByteIndex + XML_GetCurrentColumnNumber = _XML_GetCurrentColumnNumber + XML_GetCurrentLineNumber = _XML_GetCurrentLineNumber + XML_GetErrorCode = _XML_GetErrorCode + XML_GetIdAttributeIndex = _XML_GetIdAttributeIndex + XML_GetInputContext = _XML_GetInputContext + XML_GetSpecifiedAttributeCount = _XML_GetSpecifiedAttributeCount + XML_Parse = _XML_Parse + XML_ParseBuffer = _XML_ParseBuffer + XML_ParserCreate = _XML_ParserCreate + XML_ParserCreateNS = _XML_ParserCreateNS + XML_ParserCreate_MM = _XML_ParserCreate_MM + XML_ParserFree = _XML_ParserFree + XML_SetAttlistDeclHandler = _XML_SetAttlistDeclHandler + XML_SetBase = _XML_SetBase + XML_SetCdataSectionHandler = _XML_SetCdataSectionHandler + XML_SetCharacterDataHandler = _XML_SetCharacterDataHandler + XML_SetCommentHandler = _XML_SetCommentHandler + XML_SetDefaultHandler = _XML_SetDefaultHandler + XML_SetDefaultHandlerExpand = _XML_SetDefaultHandlerExpand + XML_SetDoctypeDeclHandler = _XML_SetDoctypeDeclHandler + XML_SetElementDeclHandler = _XML_SetElementDeclHandler + XML_SetElementHandler = _XML_SetElementHandler + XML_SetEncoding = _XML_SetEncoding + XML_SetEndCdataSectionHandler = _XML_SetEndCdataSectionHandler + XML_SetEndDoctypeDeclHandler = _XML_SetEndDoctypeDeclHandler + XML_SetEndElementHandler = _XML_SetEndElementHandler + XML_SetEndNamespaceDeclHandler = _XML_SetEndNamespaceDeclHandler + XML_SetEntityDeclHandler = _XML_SetEntityDeclHandler + XML_SetExternalEntityRefHandler = _XML_SetExternalEntityRefHandler + XML_SetExternalEntityRefHandlerArg = _XML_SetExternalEntityRefHandlerArg + XML_SetNamespaceDeclHandler = _XML_SetNamespaceDeclHandler + XML_SetNotStandaloneHandler = _XML_SetNotStandaloneHandler + XML_SetNotationDeclHandler = _XML_SetNotationDeclHandler + XML_SetParamEntityParsing = _XML_SetParamEntityParsing + XML_SetProcessingInstructionHandler = _XML_SetProcessingInstructionHandler + XML_SetReturnNSTriplet = _XML_SetReturnNSTriplet + XML_SetStartCdataSectionHandler = _XML_SetStartCdataSectionHandler + XML_SetStartDoctypeDeclHandler = _XML_SetStartDoctypeDeclHandler + XML_SetStartElementHandler = _XML_SetStartElementHandler + XML_SetStartNamespaceDeclHandler = _XML_SetStartNamespaceDeclHandler + XML_SetUnknownEncodingHandler = _XML_SetUnknownEncodingHandler + XML_SetUnparsedEntityDeclHandler = _XML_SetUnparsedEntityDeclHandler + XML_SetUserData = _XML_SetUserData + XML_SetXmlDeclHandler = _XML_SetXmlDeclHandler + XML_UseParserAsHandlerArg = _XML_UseParserAsHandlerArg + XML_ParserReset = _XML_ParserReset + XML_SetSkippedEntityHandler = _XML_SetSkippedEntityHandler + XML_GetFeatureList = _XML_GetFeatureList + XML_UseForeignDTD = _XML_UseForeignDTD + XML_FreeContentModel = _XML_FreeContentModel + XML_MemMalloc = _XML_MemMalloc + XML_MemRealloc = _XML_MemRealloc + XML_MemFree = _XML_MemFree diff --git a/extras/expat/bcb5/makefile.mak b/extras/expat/bcb5/makefile.mak new file mode 100644 index 000000000..548815eaf --- /dev/null +++ b/extras/expat/bcb5/makefile.mak @@ -0,0 +1,37 @@ +all: setup expat expatw expat_static expatw_static elements outline xmlwf + +setup: + setup + +expat: + make -l -fexpat.mak + +expatw: + make -l -fexpatw.mak + +expat_static: + make -l -fexpat_static.mak + +expatw_static: + make -l -fexpatw_static.mak + +elements: + make -l -felements.mak + +outline: + make -l -foutline.mak + +xmlwf: + make -l -fxmlwf.mak + +clean: +# works on Win98/ME +# deltree /y release\obj +# works on WinNT/2000 + del /s/f/q release\obj + +distclean: +# works on Win98/ME +# deltree /y release\*.* +# works on WinNT/2000 + del /s/f/q release\* diff --git a/extras/expat/bcb5/outline.bpf b/extras/expat/bcb5/outline.bpf new file mode 100644 index 000000000..52dce8301 --- /dev/null +++ b/extras/expat/bcb5/outline.bpf @@ -0,0 +1,4 @@ +USEUNIT("..\examples\outline.c"); +USELIB("Release\libexpat_mtd.lib"); +//--------------------------------------------------------------------------- +main diff --git a/extras/expat/bcb5/outline.bpr b/extras/expat/bcb5/outline.bpr new file mode 100644 index 000000000..e0ae5cdee --- /dev/null +++ b/extras/expat/bcb5/outline.bpr @@ -0,0 +1,132 @@ +<?xml version='1.0' encoding='utf-8' ?> +<!-- C++Builder XML Project --> +<PROJECT> + <MACROS> + <VERSION value="BCB.05.03"/> + <PROJECT value="Release\outline.exe"/> + <OBJFILES value="Release\obj\examples\outline.obj"/> + <RESFILES value=""/> + <IDLFILES value=""/> + <IDLGENFILES value=""/> + <DEFFILE value=""/> + <RESDEPEN value="$(RESFILES)"/> + <LIBFILES value="Release\libexpat_mtd.lib"/> + <LIBRARIES value=""/> + <SPARELIBS value=""/> + <PACKAGES value="VCL50.bpi VCLX50.bpi bcbsmp50.bpi QRPT50.bpi VCLDB50.bpi VCLBDE50.bpi + ibsmp50.bpi VCLDBX50.bpi TEEUI50.bpi TEEDB50.bpi TEE50.bpi TEEQR50.bpi + VCLIB50.bpi bcbie50.bpi VCLIE50.bpi INETDB50.bpi INET50.bpi NMFAST50.bpi + dclocx50.bpi bcb2kaxserver50.bpi dclusr50.bpi"/> + <PATHCPP value=".;..\examples"/> + <PATHPAS value=".;"/> + <PATHRC value=".;"/> + <PATHASM value=".;"/> + <DEBUGLIBPATH value="$(BCB)\lib\debug"/> + <RELEASELIBPATH value="$(BCB)\lib\release"/> + <LINKER value="ilink32"/> + <USERDEFINES value="WIN32;NDEBUG;_CONSOLE"/> + <SYSDEFINES value="_NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL"/> + <MAINSOURCE value="outline.bpf"/> + <INCLUDEPATH value="..\examples;$(BCB)\include"/> + <LIBPATH value="..\examples;$(BCB)\lib;$(RELEASELIBPATH)"/> + <WARNINGS value="-w-par -w-8027 -w-8026"/> + </MACROS> + <OPTIONS> + <IDLCFLAGS value="-I$(BCB)\include"/> + <CFLAG1 value="-O2 -X- -a8 -b -k- -vi -q -tWM -I..\lib -c"/> + <PFLAGS value="-N2Release\obj\examples -N0Release\obj\examples -$Y- -$L- -$D-"/> + <RFLAGS value="/l 0x409 /d "NDEBUG" /i$(BCB)\include"/> + <AFLAGS value="/mx /w2 /zn"/> + <LFLAGS value="-IRelease\obj\examples -D"" -ap -Tpe -x -Gn -q"/> + </OPTIONS> + <LINKER> + <ALLOBJ value="c0x32.obj $(OBJFILES)"/> + <ALLRES value="$(RESFILES)"/> + <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib"/> + </LINKER> + <IDEOPTIONS> +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1033 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=3 +Item0=..\examples;$(BCB)\include +Item1=$(BCB)\include +Item2=$(BCB)\include;$(BCB)\include\mfc;$(BCB)\include\atl; + +[HistoryLists\hlLibraryPath] +Count=4 +Item0=..\examples;$(BCB)\lib;$(RELEASELIBPATH) +Item1=..\examples;$(BCB)\lib;..\examples\$(RELEASELIBPATH) +Item2=$(BCB)\lib;$(RELEASELIBPATH) +Item3=$(BCB)\lib;$(RELEASELIBPATH);;$(BCB)\lib\psdk; + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=6 +Item0=WIN32;NDEBUG;_CONSOLE +Item1=WIN32;NDEBUG;_CONSOLE;XML_STATIC +Item2=WIN32;NDEBUG;_CONSOLE;_DEBUG;XML_STATIC +Item3=WIN32;NDEBUG;_CONSOLE;_DEBUG;XML_UNICODE_WCHAR_T;_UNICODE;XML_STATIC +Item4=WIN32;NDEBUG;_CONSOLE;_DEBUG;XML_UNICODE_WCHAR_T;_UNICODE +Item5=WIN32;NDEBUG;_CONSOLE;_DEBUG + +[HistoryLists\hlIntOutputDir] +Count=4 +Item0=Release\obj\examples +Item1=Release\obj\outline +Item2=..\examples\Release +Item3=Release + +[HistoryLists\hlFinalOutputDir] +Count=1 +Item0=Release\ + +[Debugging] +DebugSourceDirs= + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + </IDEOPTIONS> +</PROJECT>
\ No newline at end of file diff --git a/extras/expat/bcb5/outline.mak b/extras/expat/bcb5/outline.mak new file mode 100644 index 000000000..510b541f6 --- /dev/null +++ b/extras/expat/bcb5/outline.mak @@ -0,0 +1,186 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.05.03 +# --------------------------------------------------------------------------- +PROJECT = Release\outline.exe +OBJFILES = Release\obj\examples\outline.obj +RESFILES = +MAINSOURCE = outline.bpf +RESDEPEN = $(RESFILES) +LIBFILES = Release\libexpat_mtd.lib +IDLFILES = +IDLGENFILES = +LIBRARIES = +PACKAGES = VCL50.bpi VCLX50.bpi bcbsmp50.bpi QRPT50.bpi VCLDB50.bpi VCLBDE50.bpi \ + ibsmp50.bpi VCLDBX50.bpi TEEUI50.bpi TEEDB50.bpi TEE50.bpi TEEQR50.bpi \ + VCLIB50.bpi bcbie50.bpi VCLIE50.bpi INETDB50.bpi INET50.bpi NMFAST50.bpi \ + dclocx50.bpi bcb2kaxserver50.bpi dclusr50.bpi +SPARELIBS = +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .;..\examples +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = WIN32;NDEBUG;_CONSOLE +SYSDEFINES = _NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL +INCLUDEPATH = ..\examples;$(BCB)\include +LIBPATH = ..\examples;$(BCB)\lib;$(RELEASELIBPATH) +WARNINGS= -w-par -w-8027 -w-8026 +# --------------------------------------------------------------------------- +CFLAG1 = -O2 -X- -a8 -b -k- -vi -q -tWM -I..\lib -c +IDLCFLAGS = -I$(BCB)\include +PFLAGS = -N2Release\obj\examples -N0Release\obj\examples -$Y- -$L- -$D- +RFLAGS = /l 0x409 /d "NDEBUG" /i$(BCB)\include +AFLAGS = /mx /w2 /zn +LFLAGS = -IRelease\obj\examples -D"" -ap -Tpe -x -Gn -q +# --------------------------------------------------------------------------- +ALLOBJ = c0x32.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +!endif + + + + + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if "$(USERDEFINES)" != "" +AUSERDEFINES = -d$(USERDEFINES:;= -d) +!else +AUSERDEFINES = +!endif + +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(IDLGENFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) -L$(LIBPATH) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) -i$(INCLUDEPATH:;= -i) $(AUSERDEFINES) -d$(SYSDEFINES:;= -d) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $< +# --------------------------------------------------------------------------- + + + + diff --git a/extras/expat/bcb5/setup.bat b/extras/expat/bcb5/setup.bat new file mode 100644 index 000000000..6f4b57317 --- /dev/null +++ b/extras/expat/bcb5/setup.bat @@ -0,0 +1,9 @@ +REM CommandInterpreter: $(COMSPEC) +if not exist .\release\nul mkdir release +if not exist .\release\obj\nul mkdir release\obj +if not exist .\release\obj\libexpat\nul mkdir release\obj\libexpat +if not exist .\release\obj\libexpatw\nul mkdir release\obj\libexpatw +if not exist .\release\obj\libexpat_static\nul mkdir release\obj\libexpat_static +if not exist .\release\obj\libexpatw_static\nul mkdir release\obj\libexpatw_static +if not exist .\release\obj\examples\nul mkdir release\obj\examples +if not exist .\release\obj\xmlwf\nul mkdir release\obj\xmlwf diff --git a/extras/expat/bcb5/xmlwf.bpf b/extras/expat/bcb5/xmlwf.bpf new file mode 100644 index 000000000..d06208e81 --- /dev/null +++ b/extras/expat/bcb5/xmlwf.bpf @@ -0,0 +1,7 @@ +USEUNIT("..\xmlwf\codepage.c"); +USEUNIT("..\xmlwf\win32filemap.c"); +USEUNIT("..\xmlwf\xmlfile.c"); +USEUNIT("..\xmlwf\xmlwf.c"); +USELIB("Release\libexpat_mtd.lib"); +//--------------------------------------------------------------------------- +main diff --git a/extras/expat/bcb5/xmlwf.bpr b/extras/expat/bcb5/xmlwf.bpr new file mode 100644 index 000000000..d33a15387 --- /dev/null +++ b/extras/expat/bcb5/xmlwf.bpr @@ -0,0 +1,136 @@ +<?xml version='1.0' encoding='utf-8' ?> +<!-- C++Builder XML Project --> +<PROJECT> + <MACROS> + <VERSION value="BCB.05.03"/> + <PROJECT value="Release\xmlwf.exe"/> + <OBJFILES value="Release\obj\xmlwf\codepage.obj Release\obj\xmlwf\win32filemap.obj + Release\obj\xmlwf\xmlfile.obj Release\obj\xmlwf\xmlwf.obj"/> + <RESFILES value=""/> + <IDLFILES value=""/> + <IDLGENFILES value=""/> + <DEFFILE value=""/> + <RESDEPEN value="$(RESFILES)"/> + <LIBFILES value="Release\libexpat_mtd.lib"/> + <LIBRARIES value=""/> + <SPARELIBS value=""/> + <PACKAGES value="VCL50.bpi VCLX50.bpi bcbsmp50.bpi QRPT50.bpi VCLDB50.bpi VCLBDE50.bpi + ibsmp50.bpi VCLDBX50.bpi TEEUI50.bpi TEEDB50.bpi TEE50.bpi TEEQR50.bpi + VCLIB50.bpi bcbie50.bpi VCLIE50.bpi INETDB50.bpi INET50.bpi NMFAST50.bpi + dclocx50.bpi bcb2kaxserver50.bpi dclusr50.bpi"/> + <PATHCPP value=".;..\xmlwf"/> + <PATHPAS value=".;"/> + <PATHRC value=".;"/> + <PATHASM value=".;"/> + <DEBUGLIBPATH value="$(BCB)\lib\debug"/> + <RELEASELIBPATH value="$(BCB)\lib\release"/> + <LINKER value="ilink32"/> + <USERDEFINES value="NDEBUG;WIN32;_CONSOLE;COMPILED_FROM_DSP"/> + <SYSDEFINES value="_NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL"/> + <MAINSOURCE value="xmlwf.bpf"/> + <INCLUDEPATH value="..\xmlwf;$(BCB)\include"/> + <LIBPATH value="..\xmlwf;$(BCB)\lib;$(RELEASELIBPATH)"/> + <WARNINGS value="-w-8065 -w-par -w-8027 -w-8026"/> + </MACROS> + <OPTIONS> + <IDLCFLAGS value="-I$(BCB)\include"/> + <CFLAG1 value="-O2 -X- -a8 -b -k- -vi -q -tWM -I..\lib -c"/> + <PFLAGS value="-N2Release\obj\xmlwf -N0Release\obj\xmlwf -$Y- -$L- -$D-"/> + <RFLAGS value="/l 0x409 /d "NDEBUG" /i$(BCB)\include"/> + <AFLAGS value="/mx /w2 /zn"/> + <LFLAGS value="-IRelease\obj\xmlwf -D"" -ap -Tpe -x -Gn -q"/> + </OPTIONS> + <LINKER> + <ALLOBJ value="c0x32.obj $(OBJFILES)"/> + <ALLRES value="$(RESFILES)"/> + <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib"/> + </LINKER> + <IDEOPTIONS> +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1033 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=4 +Item0=..\xmlwf;$(BCB)\include +Item1=$(BCB)\include +Item2=$(BCB)\include;$(BCB)\include\mfc;$(BCB)\include\atl +Item3=$(BCB)\include;$(BCB)\include\mfc;$(BCB)\include\atl; + +[HistoryLists\hlLibraryPath] +Count=5 +Item0=..\xmlwf;$(BCB)\lib;$(RELEASELIBPATH) +Item1=..\xmlwf;$(BCB)\lib;..\xmlwf\$(RELEASELIBPATH) +Item2=$(BCB)\lib;$(RELEASELIBPATH) +Item3=$(BCB)\lib;$(RELEASELIBPATH);$(BCB)\lib\psdk +Item4=$(BCB)\lib;$(RELEASELIBPATH);;$(BCB)\lib\psdk; + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=6 +Item0=NDEBUG;WIN32;_CONSOLE;COMPILED_FROM_DSP +Item1=NDEBUG;WIN32;_CONSOLE;COMPILED_FROM_DSP;_DEBUG;XML_UNICODE_WCHAR_T;_UNICODE +Item2=NDEBUG;WIN32;_CONSOLE;COMPILED_FROM_DSP;_DEBUG;XML_UNICODE_WCHAR_T +Item3=NDEBUG;WIN32;_CONSOLE;COMPILED_FROM_DSP;_DEBUG +Item4=NDEBUG;WIN32;_CONSOLE;COMPILED_FROM_DSP;_DEBUG;_UNICODE;XML_UNICODE_WCHAR_T +Item5=NDEBUG;WIN32;_CONSOLE;COMPILED_FROM_DSP;_DEBUG;_UNICODE + +[HistoryLists\hlIntOutputDir] +Count=3 +Item0=Release\obj\xmlwf +Item1=..\xmlwf\Release +Item2=Release + +[HistoryLists\hlFinalOutputDir] +Count=3 +Item0=Release\ +Item1=Release +Item2=.\Release\ + +[Debugging] +DebugSourceDirs= + +[Parameters] +RunParams=sample.xml +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + </IDEOPTIONS> +</PROJECT>
\ No newline at end of file diff --git a/extras/expat/bcb5/xmlwf.mak b/extras/expat/bcb5/xmlwf.mak new file mode 100644 index 000000000..f74126e45 --- /dev/null +++ b/extras/expat/bcb5/xmlwf.mak @@ -0,0 +1,187 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.05.03 +# --------------------------------------------------------------------------- +PROJECT = Release\xmlwf.exe +OBJFILES = Release\obj\xmlwf\codepage.obj Release\obj\xmlwf\win32filemap.obj \ + Release\obj\xmlwf\xmlfile.obj Release\obj\xmlwf\xmlwf.obj +RESFILES = +MAINSOURCE = xmlwf.bpf +RESDEPEN = $(RESFILES) +LIBFILES = Release\libexpat_mtd.lib +IDLFILES = +IDLGENFILES = +LIBRARIES = +PACKAGES = VCL50.bpi VCLX50.bpi bcbsmp50.bpi QRPT50.bpi VCLDB50.bpi VCLBDE50.bpi \ + ibsmp50.bpi VCLDBX50.bpi TEEUI50.bpi TEEDB50.bpi TEE50.bpi TEEQR50.bpi \ + VCLIB50.bpi bcbie50.bpi VCLIE50.bpi INETDB50.bpi INET50.bpi NMFAST50.bpi \ + dclocx50.bpi bcb2kaxserver50.bpi dclusr50.bpi +SPARELIBS = +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .;..\xmlwf +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = NDEBUG;WIN32;_CONSOLE;COMPILED_FROM_DSP +SYSDEFINES = _NO_VCL;_ASSERTE;NO_STRICT;_RTLDLL +INCLUDEPATH = ..\xmlwf;$(BCB)\include +LIBPATH = ..\xmlwf;$(BCB)\lib;$(RELEASELIBPATH) +WARNINGS= -w-8065 -w-par -w-8027 -w-8026 +# --------------------------------------------------------------------------- +CFLAG1 = -O2 -X- -a8 -b -k- -vi -q -tWM -I..\lib -c +IDLCFLAGS = -I$(BCB)\include +PFLAGS = -N2Release\obj\xmlwf -N0Release\obj\xmlwf -$Y- -$L- -$D- +RFLAGS = /l 0x409 /d "NDEBUG" /i$(BCB)\include +AFLAGS = /mx /w2 /zn +LFLAGS = -IRelease\obj\xmlwf -D"" -ap -Tpe -x -Gn -q +# --------------------------------------------------------------------------- +ALLOBJ = c0x32.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +!endif + + + + + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if "$(USERDEFINES)" != "" +AUSERDEFINES = -d$(USERDEFINES:;= -d) +!else +AUSERDEFINES = +!endif + +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(IDLGENFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) -L$(LIBPATH) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) -i$(INCLUDEPATH:;= -i) $(AUSERDEFINES) -d$(SYSDEFINES:;= -d) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $< +# --------------------------------------------------------------------------- + + + + diff --git a/extras/expat/configure b/extras/expat/configure index 4cc0edf2e..a62202b9d 100755 --- a/extras/expat/configure +++ b/extras/expat/configure @@ -1,8 +1,8 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.53 for expat 1.95.4. +# Generated by GNU Autoconf 2.53 for expat 1.95.6. # -# Report bugs to <expat-bugs@lists.sourceforge.net>. +# Report bugs to <expat-bugs@mail.libexpat.org>. # # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 # Free Software Foundation, Inc. @@ -415,9 +415,9 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='expat' PACKAGE_TARNAME='expat' -PACKAGE_VERSION='1.95.4' -PACKAGE_STRING='expat 1.95.4' -PACKAGE_BUGREPORT='expat-bugs@lists.sourceforge.net' +PACKAGE_VERSION='1.95.6' +PACKAGE_STRING='expat 1.95.6' +PACKAGE_BUGREPORT='expat-bugs@mail.libexpat.org' ac_unique_file="Makefile.in" # Factoring default headers for most tests. @@ -921,7 +921,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures expat 1.95.4 to adapt to many kinds of systems. +\`configure' configures expat 1.95.6 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -982,7 +982,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of expat 1.95.4:";; + short | recursive ) echo "Configuration of expat 1.95.6:";; esac cat <<\_ACEOF @@ -1012,7 +1012,7 @@ Some influential environment variables: Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to <expat-bugs@lists.sourceforge.net>. +Report bugs to <expat-bugs@mail.libexpat.org>. _ACEOF fi @@ -1075,7 +1075,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -expat configure 1.95.4 +expat configure 1.95.6 generated by GNU Autoconf 2.53 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 @@ -1090,7 +1090,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by expat $as_me 1.95.4, which was +It was created by expat $as_me 1.95.6, which was generated by GNU Autoconf 2.53. Invocation command line was $ $0 $@ @@ -1399,9 +1399,9 @@ ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. -LIBCURRENT=3 +LIBCURRENT=4 LIBREVISION=0 -LIBAGE=3 +LIBAGE=4 ac_config_headers="$ac_config_headers expat_config.h" @@ -9382,7 +9382,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by expat $as_me 1.95.4, which was +This file was extended by expat $as_me 1.95.6, which was generated by GNU Autoconf 2.53. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -9441,7 +9441,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -expat config.status 1.95.4 +expat config.status 1.95.6 configured by $0, generated by GNU Autoconf 2.53, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" diff --git a/extras/expat/configure.in b/extras/expat/configure.in index 09d6eb643..ae6d441ba 100644 --- a/extras/expat/configure.in +++ b/extras/expat/configure.in @@ -26,7 +26,7 @@ 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@lists.sourceforge.net) +AC_INIT(expat, expat_version, expat-bugs@mail.libexpat.org) undefine([expat_version]) AC_CONFIG_SRCDIR(Makefile.in) @@ -44,9 +44,9 @@ dnl dnl If the API changes incompatibly set LIBAGE back to 0 dnl -LIBCURRENT=3 +LIBCURRENT=4 LIBREVISION=0 -LIBAGE=3 +LIBAGE=4 AC_CONFIG_HEADER(expat_config.h) diff --git a/extras/expat/doc/reference.html b/extras/expat/doc/reference.html index fc4d4c0b1..1d94279e8 100644 --- a/extras/expat/doc/reference.html +++ b/extras/expat/doc/reference.html @@ -1,172 +1,185 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" - "http://www.w3.org/TR/REC-html40/loose.dtd"> +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> - <!-- Copyright 1999,2000 Clark Cooper <coopercc@netheaven.com> All rights reserved. This is free software. You may distribute or modify according to the terms of the MIT/X License --> <title>Expat XML Parser</title> - <meta name="author" content="Clark Cooper, coopercc@netheaven.com"> - <meta http-equiv="Content-Style-Type" content="text/css"> - <link href="style.css" rel="stylesheet" type="text/css"> + <meta name="author" content="Clark Cooper, coopercc@netheaven.com" /> + <meta http-equiv="Content-Style-Type" content="text/css" /> + <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <h1>Expat XML Parser</h1> -<p>Expat is a library, written in C, for parsing XML documents. It's the -underlying XML parser for the open source Mozilla project, perl's -XML::Parser, and other open-source XML parsers.</p> +<p>Expat is a library, written in C, for parsing XML documents. It's +the underlying XML parser for the open source Mozilla project, Perl's +<code>XML::Parser</code>, Python's <code>xml.parsers.expat</code>, and +other open-source XML parsers.</p> <p>This library is the creation of James Clark, who's also given us -groff (an nroff look-alike), Jade (an implemention of ISO's DSSSL stylesheet -language for SGML), XP (a Java XML parser package), XT (a Java XSL engine). -James was also the technical lead on the XML Working Group at W3 that produced -the XML specification.</p> - -<p>This is free software, licensed under the -<a href="../COPYING">MIT/X Consortium license</a>. You may download it from -<a href="http://www.libexpat.org/">the Expat home page</a>. +groff (an nroff look-alike), Jade (an implemention of ISO's DSSSL +stylesheet language for SGML), XP (a Java XML parser package), XT (a +Java XSL engine). James was also the technical lead on the XML +Working Group at W3C that produced the XML specification.</p> + +<p>This is free software, licensed under the <a +href="../COPYING">MIT/X Consortium license</a>. You may download it +from <a href="http://www.libexpat.org/">the Expat home page</a>. </p> <p>The bulk of this document was originally commissioned as an article by -<a href="http://www.xml.com/">XML.com</a>. They graciously allowed me to retain -copyright and to distribute it with expat. +<a href="http://www.xml.com/">XML.com</a>. They graciously allowed +Clark Cooper to retain copyright and to distribute it with Expat.</p> -<hr> +<hr /> <h2>Table of Contents</h2> <ul> <li><a href="#overview">Overview</a></li> <li><a href="#building">Building and Installing</a></li> - <li><a href="#using">Using expat</a></li> - <li><a href="#examples">Some examples</a></li> + <li><a href="#using">Using Expat</a></li> <li><a href="#reference">Reference</a> - <ul> - <li><a href="#creation">Parser Creation Functions</a> - <ul> - <li><a href="#XML_ParserCreate">XML_ParserCreate</a></li> - <li><a href="#XML_ParserCreateNS">XML_ParserCreateNS</a></li> - <li><a href="#XML_ParserCreate_MM">XML_ParserCreate_MM</a></li> - <li><a href="#XML_ExternalEntityParserCreate">XML_ExternalEntityParserCreate</a></li> - <li><a href="#XML_ParserFree">XML_ParserFree</a></li> - </ul> - </li> - <li><a href="#parsing">Parsing Functions</a> - <ul> - <li><a href="#XML_Parse">XML_Parse</a></li> - <li><a href="#XML_ParseBuffer">XML_ParseBuffer</a></li> - <li><a href="#XML_GetBuffer">XML_GetBuffer</a></li> - </ul> - </li> - <li><a href="#setting">Handler Setting Functions</a> - <ul> - <li><a href="#XML_SetStartElementHandler">XML_SetStartElementHandler</a></li> - <li><a href="#XML_SetEndElementHandler">XML_SetEndElementHandler</a></li> - <li><a href="#XML_SetElementHandler">XML_SetElementHandler</a></li> - <li><a href="#XML_SetCharacterDataHandler">XML_SetCharacterDataHandler</a></li> - <li><a href="#XML_SetProcessingInstructionHandler">XML_SetProcessingInstructionHandler</a></li> - <li><a href="#XML_SetCommentHandler">XML_SetCommentHandler</a></li> - <li><a href="#XML_SetStartCdataSectionHandler">XML_SetStartCdataSectionHandler</a></li> - <li><a href="#XML_SetEndCdataSectionHandler">XML_SetEndCdataSectionHandler</a></li> - <li><a href="#XML_SetCdataSectionHandler">XML_SetCdataSectionHandler</a></li> - <li><a href="#XML_SetDefaultHandler">XML_SetDefaultHandler</a></li> - <li><a href="#XML_SetDefaultHandlerExpand">XML_SetDefaultHandlerExpand</a></li> - <li><a href="#XML_SetExternalEntityRefHandler">XML_SetExternalEntityRefHandler</a></li> - <li><a href="#XML_SetSkippedEntityHandler">XML_SetSkippedEntityHandler</a></li> - <li><a href="#XML_SetUnknownEncodingHandler">XML_SetUnknownEncodingHandler</a></li> - <li><a href="#XML_SetStartNamespaceDeclHandler">XML_SetStartNamespaceDeclHandler</a></li> - <li><a href="#XML_SetEndNamespaceDeclHandler">XML_SetEndNamespaceDeclHandler</a></li> - <li><a href="#XML_SetNamespaceDeclHandler">XML_SetNamespaceDeclHandler</a></li> - <li><a href="#XML_SetXmlDeclHandler">XML_SetXmlDeclHandler</a></li> - <li><a href="#XML_SetStartDoctypeDeclHandler">XML_SetStartDoctypeDeclHandler</a></li> - <li><a href="#XML_SetEndDoctypeDeclHandler">XML_SetEndDoctypeDeclHandler</a></li> - <li><a href="#XML_SetDoctypeDeclHandler">XML_SetDoctypeDeclHandler</a></li> - <li><a href="#XML_SetElementDeclHandler">XML_SetElementDeclHandler</a></li> - <li><a href="#XML_SetAttlistDeclHandler">XML_SetAttlistDeclHandler</a></li> - <li><a href="#XML_SetEntityDeclHandler">XML_SetEntityDeclHandler</a></li> - <li><a href="#XML_SetUnparsedEntityDeclHandler">XML_SetUnparsedEntityDeclHandler</a></li> - <li><a href="#XML_SetNotationDeclHandler">XML_SetNotationDeclHandler</a></li> - <li><a href="#XML_SetNotStandaloneHandler">XML_SetNotStandaloneHandler</a></li> - </ul> - </li> - <li><a href="#position">Parse Position and Error Reporting Functions</a> - <ul> - <li><a href="#XML_GetErrorCode">XML_GetErrorCode</a></li> - <li><a href="#XML_ErrorString">XML_ErrorString</a></li> - <li><a href="#XML_GetCurrentByteIndex">XML_GetCurrentByteIndex</a></li> - <li><a href="#XML_GetCurrentLineNumber">XML_GetCurrentLineNumber</a></li> - <li><a href="#XML_GetCurrentColumnNumber">XML_GetCurrentColumnNumber</a></li> - <li><a href="#XML_GetCurrentByteCount">XML_GetCurrentByteCount</a></li> - <li><a href="#XML_GetInputContext">XML_GetInputContext</a></li> - </ul> - </li> - <li><a href="#miscellaneous">Miscellaneous Functions</a> - <ul> - <li><a href="#XML_SetUserData">XML_SetUserData</a></li> - <li><a href="#XML_GetUserData">XML_GetUserData</a></li> - <li><a href="#XML_UseParserAsHandlerArg">XML_UseParserAsHandlerArg</a></li> - <li><a href="#XML_SetBase">XML_SetBase</a></li> - <li><a href="#XML_GetBase">XML_GetBase</a></li> - <li><a href="#XML_GetSpecifiedAttributeCount">XML_GetSpecifiedAttributeCount</a></li> - <li><a href="#XML_GetIdAttributeIndex">XML_GetIdAttributeIndex</a></li> - <li><a href="#XML_SetEncoding">XML_SetEncoding</a></li> - <li><a href="#XML_SetParamEntityParsing">XML_SetParamEntityParsing</a></li> - <li><a href="#XML_SetReturnNSTriplet">XML_SetReturnNSTriplet</a></li> - <li><a href="#XML_ExpatVersion">XML_ExpatVersion</a></li> - <li><a href="#XML_ExpatVersionInfo">XML_ExpatVersionInfo</a></li> - </ul> - </li> - </ul> + <ul> + <li><a href="#creation">Parser Creation Functions</a> + <ul> + <li><a href="#XML_ParserCreate">XML_ParserCreate</a></li> + <li><a href="#XML_ParserCreateNS">XML_ParserCreateNS</a></li> + <li><a href="#XML_ParserCreate_MM">XML_ParserCreate_MM</a></li> + <li><a href="#XML_ExternalEntityParserCreate">XML_ExternalEntityParserCreate</a></li> + <li><a href="#XML_ParserFree">XML_ParserFree</a></li> + <li><a href="#XML_ParserReset">XML_ParserReset</a></li> + </ul> + </li> + <li><a href="#parsing">Parsing Functions</a> + <ul> + <li><a href="#XML_Parse">XML_Parse</a></li> + <li><a href="#XML_ParseBuffer">XML_ParseBuffer</a></li> + <li><a href="#XML_GetBuffer">XML_GetBuffer</a></li> + </ul> + </li> + <li><a href="#setting">Handler Setting Functions</a> + <ul> + <li><a href="#XML_SetStartElementHandler">XML_SetStartElementHandler</a></li> + <li><a href="#XML_SetEndElementHandler">XML_SetEndElementHandler</a></li> + <li><a href="#XML_SetElementHandler">XML_SetElementHandler</a></li> + <li><a href="#XML_SetCharacterDataHandler">XML_SetCharacterDataHandler</a></li> + <li><a href="#XML_SetProcessingInstructionHandler">XML_SetProcessingInstructionHandler</a></li> + <li><a href="#XML_SetCommentHandler">XML_SetCommentHandler</a></li> + <li><a href="#XML_SetStartCdataSectionHandler">XML_SetStartCdataSectionHandler</a></li> + <li><a href="#XML_SetEndCdataSectionHandler">XML_SetEndCdataSectionHandler</a></li> + <li><a href="#XML_SetCdataSectionHandler">XML_SetCdataSectionHandler</a></li> + <li><a href="#XML_SetDefaultHandler">XML_SetDefaultHandler</a></li> + <li><a href="#XML_SetDefaultHandlerExpand">XML_SetDefaultHandlerExpand</a></li> + <li><a href="#XML_SetExternalEntityRefHandler">XML_SetExternalEntityRefHandler</a></li> + <li><a href="#XML_SetExternalEntityRefHandlerArg">XML_SetExternalEntityRefHandlerArg</a></li> + <li><a href="#XML_SetSkippedEntityHandler">XML_SetSkippedEntityHandler</a></li> + <li><a href="#XML_SetUnknownEncodingHandler">XML_SetUnknownEncodingHandler</a></li> + <li><a href="#XML_SetStartNamespaceDeclHandler">XML_SetStartNamespaceDeclHandler</a></li> + <li><a href="#XML_SetEndNamespaceDeclHandler">XML_SetEndNamespaceDeclHandler</a></li> + <li><a href="#XML_SetNamespaceDeclHandler">XML_SetNamespaceDeclHandler</a></li> + <li><a href="#XML_SetXmlDeclHandler">XML_SetXmlDeclHandler</a></li> + <li><a href="#XML_SetStartDoctypeDeclHandler">XML_SetStartDoctypeDeclHandler</a></li> + <li><a href="#XML_SetEndDoctypeDeclHandler">XML_SetEndDoctypeDeclHandler</a></li> + <li><a href="#XML_SetDoctypeDeclHandler">XML_SetDoctypeDeclHandler</a></li> + <li><a href="#XML_SetElementDeclHandler">XML_SetElementDeclHandler</a></li> + <li><a href="#XML_SetAttlistDeclHandler">XML_SetAttlistDeclHandler</a></li> + <li><a href="#XML_SetEntityDeclHandler">XML_SetEntityDeclHandler</a></li> + <li><a href="#XML_SetUnparsedEntityDeclHandler">XML_SetUnparsedEntityDeclHandler</a></li> + <li><a href="#XML_SetNotationDeclHandler">XML_SetNotationDeclHandler</a></li> + <li><a href="#XML_SetNotStandaloneHandler">XML_SetNotStandaloneHandler</a></li> + </ul> + </li> + <li><a href="#position">Parse Position and Error Reporting Functions</a> + <ul> + <li><a href="#XML_GetErrorCode">XML_GetErrorCode</a></li> + <li><a href="#XML_ErrorString">XML_ErrorString</a></li> + <li><a href="#XML_GetCurrentByteIndex">XML_GetCurrentByteIndex</a></li> + <li><a href="#XML_GetCurrentLineNumber">XML_GetCurrentLineNumber</a></li> + <li><a href="#XML_GetCurrentColumnNumber">XML_GetCurrentColumnNumber</a></li> + <li><a href="#XML_GetCurrentByteCount">XML_GetCurrentByteCount</a></li> + <li><a href="#XML_GetInputContext">XML_GetInputContext</a></li> + </ul> + </li> + <li><a href="#miscellaneous">Miscellaneous Functions</a> + <ul> + <li><a href="#XML_SetUserData">XML_SetUserData</a></li> + <li><a href="#XML_GetUserData">XML_GetUserData</a></li> + <li><a href="#XML_UseParserAsHandlerArg">XML_UseParserAsHandlerArg</a></li> + <li><a href="#XML_SetBase">XML_SetBase</a></li> + <li><a href="#XML_GetBase">XML_GetBase</a></li> + <li><a href="#XML_GetSpecifiedAttributeCount">XML_GetSpecifiedAttributeCount</a></li> + <li><a href="#XML_GetIdAttributeIndex">XML_GetIdAttributeIndex</a></li> + <li><a href="#XML_SetEncoding">XML_SetEncoding</a></li> + <li><a href="#XML_SetParamEntityParsing">XML_SetParamEntityParsing</a></li> + <li><a href="#XML_UseForeignDTD">XML_UseForeignDTD</a></li> + <li><a href="#XML_SetReturnNSTriplet">XML_SetReturnNSTriplet</a></li> + <li><a href="#XML_DefaultCurrent">XML_DefaultCurrent</a></li> + <li><a href="#XML_ExpatVersion">XML_ExpatVersion</a></li> + <li><a href="#XML_ExpatVersionInfo">XML_ExpatVersionInfo</a></li> + <li><a href="#XML_GetFeatureList">XML_GetFeatureList</a></li> + <li><a href="#XML_FreeContentModel">XML_FreeContentModel</a></li> + <li><a href="#XML_MemMalloc">XML_MemMalloc</a></li> + <li><a href="#XML_MemRealloc">XML_MemRealloc</a></li> + <li><a href="#XML_MemFree">XML_MemFree</a></li> + </ul> + </li> + </ul> </li> </ul> -<hr> +<hr /> <h2><a name="overview">Overview</a></h2> -<p>Expat is a stream-oriented parser. You register callback (or handler) -functions with -the parser and then start feeding it the document. -As the parser recognizes parts of -the document, it will call the appropriate handler for that part (if you've -registered one.) The document is fed to the parser in pieces, so you can -start parsing before you have all the document. This also allows you to -parse really huge documents that won't fit into memory.</p> - -<p>Expat can be intimidating due to the many kinds of handlers and options -you can set. But you only need to learn four functions in order to do 90% -of what you'll want to do with it:</p> + +<p>Expat is a stream-oriented parser. You register callback (or +handler) functions with the parser and then start feeding it the +document. As the parser recognizes parts of the document, it will +call the appropriate handler for that part (if you've registered one.) +The document is fed to the parser in pieces, so you can start parsing +before you have all the document. This also allows you to parse really +huge documents that won't fit into memory.</p> + +<p>Expat can be intimidating due to the many kinds of handlers and +options you can set. But you only need to learn four functions in +order to do 90% of what you'll want to do with it:</p> <dl> -<dt><code>XML_ParserCreate</code></dt> +<dt><code><a href= "#XML_ParserCreate" + >XML_ParserCreate</a></code></dt> <dd>Create a new parser object.</dd> -<dt><code>XML_SetElementHandler</code></dt> +<dt><code><a href= "#XML_SetElementHandler" + >XML_SetElementHandler</a></code></dt> <dd>Set handlers for start and end tags.</dd> -<dt><code>XML_SetCharacterDataHandler</code></dt> +<dt><code><a href= "#XML_SetCharacterDataHandler" + >XML_SetCharacterDataHandler</a></code></dt> <dd>Set handler for text.</dd> -<dt><code>XML_Parse</code></dt> +<dt><code><a href= "#XML_Parse" + >XML_Parse</a></code></dt> <dd>Pass a buffer full of document to the parser</dd> </dl> -<p>These functions and others are described in the -<a href="#reference">reference</a> part of this document. The reference -section also describes in detail the parameters passed to the different -types of handlers. - -<p>Let's look at a very simple example program that only uses 3 of the above -functions (it doesn't need to set a character handler.) The program -<a href="../examples/outline.c">outline.c</a> -prints an element outline, indenting child elements to distinguish them from -the parent element that contains them. The start handler does all the work. -It prints two indenting spaces for every level of ancestor elements, then -it prints the element and attribute information. Finally it increments the -global Depth variable. - -<div class="eg"> -<pre> +<p>These functions and others are described in the <a +href="#reference">reference</a> part of this document. The reference +section also describes in detail the parameters passed to the +different types of handlers.</p> + +<p>Let's look at a very simple example program that only uses 3 of the +above functions (it doesn't need to set a character handler.) The +program <a href="../examples/outline.c">outline.c</a> prints an +element outline, indenting child elements to distinguish them from the +parent element that contains them. The start handler does all the +work. It prints two indenting spaces for every level of ancestor +elements, then it prints the element and attribute +information. Finally it increments the global <code>Depth</code> +variable.</p> + +<pre class="eg"> int Depth; void @@ -186,98 +199,98 @@ start(void *data, const char *el, const char **attr) { Depth++; } /* End of start handler */ </pre> -</div> -<p>The end tag simply does the bookkeeping work of decrementing the Depth. -<div class="eg"> -<pre> +<p>The end tag simply does the bookkeeping work of decrementing +<code>Depth</code>.</p> +<pre class="eg"> void end(void *data, const char *el) { Depth--; } /* End of end handler */ </pre> -</div> <p>After creating the parser, the main program just has the job of -shoveling the document to the parser so that it can do its work. +shoveling the document to the parser so that it can do its work.</p> + +<hr /> +<h2><a name="building">Building and Installing Expat</a></h2> -<hr> -<h2><a name="building">Building and Installing expat</a></h2> -<p>The expat distribution comes as a compressed (with GNU gzip) tar file. -You may download the latest version from -<a href="http://sourceforge.net/projects/expat/">Source Forge</a>. -After unpacking this, cd into the directory. Then follow either the -Win32 directions or Unix directions below.</p> +<p>The Expat distribution comes as a compressed (with GNU gzip) tar +file. You may download the latest version from <a href= +"http://sourceforge.net/projects/expat/" >Source Forge</a>. After +unpacking this, cd into the directory. Then follow either the Win32 +directions or Unix directions below.</p> <h3>Building under Win32</h3> -<p>If you're using the GNU compiler under cygwin, follow the Unix directions -in the next section. Otherwise if you have Microsoft's Developer Studio -installed, then from Windows Explorer double-click on "expat.dsp" in the -lib directory and build and install in the usual manner.</p> -<p>Alternatively, you may download the win32 binary package that contains -the expat.h include file and a pre-built dll.</p> +<p>If you're using the GNU compiler under cygwin, follow the Unix +directions in the next section. Otherwise if you have Microsoft's +Developer Studio installed, then from Windows Explorer double-click on +"expat.dsp" in the lib directory and build and install in the usual +manner.</p> + +<p>Alternatively, you may download the Win32 binary package that +contains the "expat.h" include file and a pre-built DLL.</p> <h3>Building under Unix (or GNU)</h3> -<p>First you'll need to run the configure shell script in order to configure -the Makefiles and headers for your system.</p> + +<p>First you'll need to run the configure shell script in order to +configure the Makefiles and headers for your system.</p> <p>If you're happy with all the defaults that configure picks for you, -and you have permission on your system to install into /usr/local, you can -install expat with this sequence of commands:</p> +and you have permission on your system to install into /usr/local, you +can install Expat with this sequence of commands:</p> -<pre> +<pre class="eg"> ./configure make make install </pre> <p>There are some options that you can provide to this script, but the -only one we'll mention here is the <code>--prefix</code> option. You can -find out all the options available by running configure with just the -<code>--help</code> option. -</p> +only one we'll mention here is the <code>--prefix</code> option. You +can find out all the options available by running configure with just +the <code>--help</code> option.</p> + +<p>By default, the configure script sets things up so that the library +gets installed in <code>/usr/local/lib</code> and the associated +header file in <code>/usr/local/include</code>. But if you were to +give the option, <code>--prefix=/home/me/mystuff</code>, then the +library and header would get installed in +<code>/home/me/mystuff/lib</code> and +<code>/home/me/mystuff/include</code> respectively.</p> + +<hr /> +<h2><a name="using">Using Expat</a></h2> -By default, the configure script sets things up so that the library gets -installed in <code>/usr/local/lib</code> and the associated header file in -<code>/usr/local/include</code>. -But if you were to give the option, <code>--prefix=/home/me/mystuff</code>, -then the library and header would get installed in -<code>/home/me/mystuff/lib</code> and <code>/home/me/mystuff/include</code> -respectively. -</p> +<h3>Compiling and Linking Against Expat</h3> -<hr> -<h2><a name="using">Using Expat</a></h2> -<h3>Compiling and Linking against expat</h3> -<p>Unless you installed expat in a location not expected by your compiler -and linker, all you have to do to use expat in your programs is to include -the expat header (<code>#include <expat.h></code>) in your files that -make calls to it and to tell the linker -that it needs to link against the expat library. On Unix systems, this would -be the <code>-lexpat</code> argument. -Otherwise, you'll need to tell the compiler where to look for the expat header -and the linker where to find the expat library. You may also need to take -steps to tell the operating system where to find this libary at run time. -</p> -<p>On a Unix based system, here's what a Makefile might look like when expat -is installed in a standard location:</p> +<p>Unless you installed Expat in a location not expected by your +compiler and linker, all you have to do to use Expat in your programs +is to include the Expat header (<code>#include <expat.h></code>) +in your files that make calls to it and to tell the linker that it +needs to link against the Expat library. On Unix systems, this would +usually be done with the <code>-lexpat</code> argument. Otherwise, +you'll need to tell the compiler where to look for the Expat header +and the linker where to find the Expat library. You may also need to +take steps to tell the operating system where to find this libary at +run time.</p> -<div class="eg"> -<pre> +<p>On a Unix-based system, here's what a Makefile might look like when +Expat is installed in a standard location:</p> + +<pre class="eg"> CC=cc LDFLAGS= LIBS= -lexpat xmlapp: xmlapp.o $(CC) $(LDFLAGS) -o xmlapp xmlapp.o $(LIBS) </pre> -</div> -<p>If you installed expat in, say, <code>/home/me/mystuff</code>, then +<p>If you installed Expat in, say, <code>/home/me/mystuff</code>, then the Makefile would look like this:</p> -<div class="eg"> -<pre> +<pre class="eg"> CC=cc CFLAGS= -I/home/me/mystuff/include LDFLAGS= @@ -285,62 +298,61 @@ LIBS= -L/home/me/mystuff/lib -lexpat xmlapp: xmlapp.o $(CC) $(LDFLAGS) -o xmlapp xmlapp.o $(LIBS) </pre> -</div> -<p>You'd also have to set the environment variable <code>LD_LIBRARY_PATH</code> -to <code>/home/me/mystuff/lib</code> (or to -<code>${LD_LIBRARY_PATH}:/home/me/mystuff/lib</code> if LD_LIBRARY_PATH -already has some directories in it) in order to run your application. -</p> +<p>You'd also have to set the environment variable +<code>LD_LIBRARY_PATH</code> to <code>/home/me/mystuff/lib</code> (or +to <code>${LD_LIBRARY_PATH}:/home/me/mystuff/lib</code> if +LD_LIBRARY_PATH already has some directories in it) in order to run +your application.</p> <h3>Expat Basics</h3> -<p>As we saw in the example in the overview, the first step in parsing an -XML document with expat is to create a parser object. There are -<a href="#creation">three functions</a> in the expat API for creating a -parser object. -However, only two of these -(<a href="#XML_ParserCreate"><code>XML_ParserCreate</code></a> and -<a href="#XML_ParserCreateNS"><code>XML_ParserCreateNS</code></a>) -can be used for constructing a parser for a top-level document. -The object returned by these functions is an opaque pointer -(i.e. expat.h declares it as void *) to data with further internal structure. -In order to free the memory associated with this object you must call -<a href="#XML_ParserFree"><code>XML_ParserFree</code></a>. Note that if -you have provided any <a href="userdata">user data</a> that gets stored -in the parser, then your application is responsible for freeing it prior to -calling XML_ParserFree. -</p> + +<p>As we saw in the example in the overview, the first step in parsing +an XML document with Expat is to create a parser object. There are <a +href="#creation">three functions</a> in the Expat API for creating a +parser object. However, only two of these (<code><a href= +"#XML_ParserCreate" >XML_ParserCreate</a></code> and <code><a href= +"#XML_ParserCreateNS" >XML_ParserCreateNS</a></code>) can be used for +constructing a parser for a top-level document. The object returned +by these functions is an opaque pointer (i.e. "expat.h" declares it as +void *) to data with further internal structure. In order to free the +memory associated with this object you must call <code><a href= +"#XML_ParserFree" >XML_ParserFree</a></code>. Note that if you have +provided any <a href="userdata">user data</a> that gets stored in the +parser, then your application is responsible for freeing it prior to +calling <code>XML_ParserFree</code>.</p> <p>The objects returned by the parser creation functions are good for -parsing only one XML document or external parsed entity. If your application -needs to parse many XML documents, then it needs to create a parser object -for each one. The best way to deal with this is to create a higher level -object that contains all the default initialization you want for your parser -objects. - -<p>Walking through a document hierarchy with a stream oriented parser will -require a good stack mechanism in order to keep track of current context. -For instance, to answer the simple question, -"What element does this text belong to?" requires a stack, since the -parser may have descended into other elements that are children of the -current one and has encountered this text on the way out. - -<p>The things you're likely to want to keep on a stack are the currently -opened element and it's attributes. You push this information onto the -stack in the start handler and you pop it off in the end handler. - -<p>For some tasks, it is sufficient to just keep information on what the -depth of the stack is (or would be if you had one.) The outline program shown -above presents one example. Another such task would be skipping over a -complete element. When you see the start tag for the element you want to -skip, you set a skip flag and record the depth at which the element started. -When the end tag handler encounters the same depth, the skipped element has -ended and the flag may be cleared. If you follow the convention that the -root element starts at 1, then you can use the same variable for skip flag -and skip depth. - -<div class="eg"> -<pre> +parsing only one XML document or external parsed entity. If your +application needs to parse many XML documents, then it needs to create +a parser object for each one. The best way to deal with this is to +create a higher level object that contains all the default +initialization you want for your parser objects.</p> + +<p>Walking through a document hierarchy with a stream oriented parser +will require a good stack mechanism in order to keep track of current +context. For instance, to answer the simple question, "What element +does this text belong to?" requires a stack, since the parser may have +descended into other elements that are children of the current one and +has encountered this text on the way out.</p> + +<p>The things you're likely to want to keep on a stack are the +currently opened element and it's attributes. You push this +information onto the stack in the start handler and you pop it off in +the end handler.</p> + +<p>For some tasks, it is sufficient to just keep information on what +the depth of the stack is (or would be if you had one.) The outline +program shown above presents one example. Another such task would be +skipping over a complete element. When you see the start tag for the +element you want to skip, you set a skip flag and record the depth at +which the element started. When the end tag handler encounters the +same depth, the skipped element has ended and the flag may be +cleared. If you follow the convention that the root element starts at +1, then you can use the same variable for skip flag and skip +depth.</p> + +<pre class="eg"> void init_info(Parseinfo *info) { info->skip = 0; @@ -375,119 +387,159 @@ rawend(void *data, const char *el) { if (inf->skip == inf->depth) inf->skip = 0; } /* End rawend */ - </pre> -</div> -<p>Notice in the above example the difference in how depth is manipulated -in the start and end handlers. The end tag handler should be the mirror -image of the start tag handler. This is necessary to properly model -containment. Since, in the start tag handler, we -incremented depth <em>after</em> the main body of start tag code, then in -the end handler, we need to manipulate it <em>before</em> the main body. -If we'd decided to increment it first thing in the start handler, then -we'd have had to decrement it last thing in the end handler. +<p>Notice in the above example the difference in how depth is +manipulated in the start and end handlers. The end tag handler should +be the mirror image of the start tag handler. This is necessary to +properly model containment. Since, in the start tag handler, we +incremented depth <em>after</em> the main body of start tag code, then +in the end handler, we need to manipulate it <em>before</em> the main +body. If we'd decided to increment it first thing in the start +handler, then we'd have had to decrement it last thing in the end +handler.</p> -<h3>Communicating between handlers</h3> +<h3 id="userdata">Communicating between handlers</h3> <p>In order to be able to pass information between different handlers without using globals, you'll need to define a data structure to hold -the shared variables. You can then tell expat (with the XML_SetUserData -function) to pass a pointer to this -structure to the handlers. This is typically the first argument received -by most handlers. +the shared variables. You can then tell Expat (with the <code><a href= +"#XML_SetUserData" >XML_SetUserData</a></code> function) to pass a +pointer to this structure to the handlers. This is typically the first +argument received by most handlers.</p> + +<h3>XML Version</h3> + +<p>Expat is an XML 1.0 parser, and as such never complains based on +the value of the <code>version</code> pseudo-attribute in the XML +declaration, if present.</p> + +<p>If an application needs to check the version number (to support +alternate processing), it should use the <code><a href= +"#XML_SetXmlDeclHandler" >XML_SetXmlDeclHandler</a></code> function to +set a handler that uses the information in the XML declaration to +determine what to do. This example shows how to check that only a +version number of <code>"1.0"</code> is accepted:</p> + +<pre class="eg"> +static int wrong_version; +static XML_Parser parser; + +static void +xmldecl_handler(void *userData, + const XML_Char *version, + const XML_Char *encoding, + int standalone) +{ + static const XML_Char Version_1_0[] = {'1', '.', '0', 0}; + + int i; + + for (i = 0; i < (sizeof(Version_1_0) / sizeof(Version_1_0[0])); ++i) { + if (version[i] != Version_1_0[i]) { + wrong_version = 1; + /* also clear all other handlers: */ + XML_SetCharacterDataHandler(parser, NULL); + ... + return; + } + } + ... +} +</pre> <h3>Namespace Processing</h3> -<p>When the parser is created using the <code>XML_ParserCreateNS</code>, -function, expat performs namespace processing. Under namespace processing, -expat consumes <code>xmlns</code> and <code>xmlns:...</code> attributes, +<p>When the parser is created using the <code><a href= +"#XML_ParserCreateNS" >XML_ParserCreateNS</a></code>, function, Expat +performs namespace processing. Under namespace processing, Expat +consumes <code>xmlns</code> and <code>xmlns:...</code> attributes, which declare namespaces for the scope of the element in which they -occur. This means that your start handler will not see these attributes. -Your application can still be informed of these declarations by setting -namespace declaration handlers with -<a href="#XML_SetNamespaceDeclHandler"> -<code>XML_SetNamespaceDeclHandler</code></a>. - -<p>Element type and attribute names that belong to a given namespace are -passed to the appropriate handler in expanded form. By default this expanded -form is a concatenation of the namespace URI, the separator character (which -is the 2nd argument to <code>XML_ParserCreateNS</code>), and the local -name (i.e. the part after the colon). Names with undeclared prefixes are -passed through to the handlers unchanged, with the prefix and colon still -attached. Unprefixed attribute names are never expanded, and unprefixed -element names are only expanded when they are in the scope of a default -namespace. - -<p>However if <a href="XML_SetReturnNSTriplet">XML_SetReturnNSTriplet</a> -has been called with a non-zero <code>do_nst</code> parameter, then the -expanded form for names with an explicit prefix is a concatenation of: -URI, separator, local name, separator, prefix. -</p> - -<p>You can set handlers for the start of a namespace declaration and for -the end of a scope of a declaration with the -<code>XML_SetNamespaceDeclHandler</code> function. -The StartNamespaceDeclHandler is called prior to the start tag handler -and the EndNamespaceDeclHandler is called before the corresponding end tag -that ends the namespace's scope. -The namespace start handler gets passed the prefix and URI for the namespace. -For a default namespace declaration (xmlns='...'), the prefix will be null. -The URI will be null for the case where the default namespace is being unset. -The namespace end handler just gets the prefix for the closing scope. - -<p>These handlers are called for each declaration. So if, for instance, a -start tag had three namespace declarations, then the StartNamespaceDeclHandler -would be called three times before the start tag handler is called, once for -each declaration. - -<p>The <a href="src/namespace.c">namespace.c</a> example demonstrates the -use of these features. Like outline.c, it produces an outline, but -in addition it annotates when a namespace scope starts and when it ends. -This example also demonstrates use of application user data. +occur. This means that your start handler will not see these +attributes. Your application can still be informed of these +declarations by setting namespace declaration handlers with <a href= +"#XML_SetNamespaceDeclHandler" +><code>XML_SetNamespaceDeclHandler</code></a>.</p> + +<p>Element type and attribute names that belong to a given namespace +are passed to the appropriate handler in expanded form. By default +this expanded form is a concatenation of the namespace URI, the +separator character (which is the 2nd argument to <code><a href= +"#XML_ParserCreateNS" >XML_ParserCreateNS</a></code>), and the local +name (i.e. the part after the colon). Names with undeclared prefixes +are passed through to the handlers unchanged, with the prefix and +colon still attached. Unprefixed attribute names are never expanded, +and unprefixed element names are only expanded when they are in the +scope of a default namespace.</p> + +<p>However if <code><a href= "XML_SetReturnNSTriplet" +>XML_SetReturnNSTriplet</a></code> has been called with a non-zero +<code>do_nst</code> parameter, then the expanded form for names with +an explicit prefix is a concatenation of: URI, separator, local name, +separator, prefix.</p> + +<p>You can set handlers for the start of a namespace declaration and +for the end of a scope of a declaration with the <code><a href= +"#XML_SetNamespaceDeclHandler" >XML_SetNamespaceDeclHandler</a></code> +function. The StartNamespaceDeclHandler is called prior to the start +tag handler and the EndNamespaceDeclHandler is called before the +corresponding end tag that ends the namespace's scope. The namespace +start handler gets passed the prefix and URI for the namespace. For a +default namespace declaration (xmlns='...'), the prefix will be null. +The URI will be null for the case where the default namespace is being +unset. The namespace end handler just gets the prefix for the closing +scope.</p> + +<p>These handlers are called for each declaration. So if, for +instance, a start tag had three namespace declarations, then the +StartNamespaceDeclHandler would be called three times before the start +tag handler is called, once for each declaration.</p> <h3>Character Encodings</h3> -<p>While XML is based on Unicode, and every XML processor is required to -recognized UTF-8 and UTF-16 (1 and 2 byte encodings of Unicode), other -encodings may be declared in XML documents or entities. For the main -document, an XML declaration may contain an encoding declaration: +<p>While XML is based on Unicode, and every XML processor is required +to recognized UTF-8 and UTF-16 (1 and 2 byte encodings of Unicode), +other encodings may be declared in XML documents or entities. For the +main document, an XML declaration may contain an encoding +declaration:</p> <pre> <?xml version="1.0" encoding="ISO-8859-2"?> </pre> <p>External parsed entities may begin with a text declaration, which -looks like an XML declaration with just an encoding declaration: +looks like an XML declaration with just an encoding declaration:</p> <pre> <?xml encoding="Big5"?> </pre> -<p>With expat, you may also specify an encoding at the time of creating a -parser. This is useful when the encoding information may come from a source -outside the document itself (like a higher level protocol.) +<p>With Expat, you may also specify an encoding at the time of +creating a parser. This is useful when the encoding information may +come from a source outside the document itself (like a higher level +protocol.)</p> -<p><a name="builtin_encodings"></a>There are four built-in encodings in expat: +<p><a name="builtin_encodings"></a>There are four built-in encodings +in Expat:</p> <ul> -<li>UTF-8 -<li>UTF-16 -<li>ISO-8859-1 -<li>US-ASCII +<li>UTF-8</li> +<li>UTF-16</li> +<li>ISO-8859-1</li> +<li>US-ASCII</li> </ul> <p>Anything else discovered in an encoding declaration or in the protocol encoding specified in the parser constructor, triggers a call to the <code>UnknownEncodingHandler</code>. This handler gets passed the encoding name and a pointer to an <code>XML_Encoding</code> data -structure. Your handler must fill in this structure and return 1 if -it knows how to deal with the encoding. Otherwise the handler should -return 0. -The handler also gets passed a pointer to an -optional application data structure that you may indicate when you set -the handler. - -<p>Expat places restrictions on character encodings that it can support -by filling in the <code>XML_Encoding</code> structure. -include file: +structure. Your handler must fill in this structure and return +<code>XML_STATUS_OK</code> if it knows how to deal with the +encoding. Otherwise the handler should return +<code>XML_STATUS_ERROR</code>. The handler also gets passed a pointer +to an optional application data structure that you may indicate when +you set the handler.</p> + +<p>Expat places restrictions on character encodings that it can +support by filling in the <code>XML_Encoding</code> structure. +include file:</p> <ol> <li>Every ASCII character that can appear in a well-formed XML document must be represented by a single byte, and that byte must correspond to @@ -500,44 +552,48 @@ for UTF-16 and UTF-8</em></li> bytes</li> </ol> -<p><code>XML_Encoding</code> contains an array of integers that correspond -to the 1st byte of an encoding sequence. If the value in the array for a -byte is zero or positive, then the byte is a single byte encoding that -encodes the Unicode scalar value contained in the array. A -1 in this array -indicates a malformed byte. If the value is --2, -3, or -4, then the byte is the beginning of a 2, 3, or 4 byte sequence -respectively. Multi-byte sequences are sent to the convert function pointed -at in the <code>XML_Encoding</code> structure. This function should return -the Unicode scalar value for the sequence or -1 if the sequence is malformed. - -<p>One pitfall that novice expat users are likely to fall into is that -although expat may accept input in various encodings, the strings that it -passes to the handlers are always encoded in UTF-8. Your application is -responsible for any translation of these strings into other encodings. +<p><code>XML_Encoding</code> contains an array of integers that +correspond to the 1st byte of an encoding sequence. If the value in +the array for a byte is zero or positive, then the byte is a single +byte encoding that encodes the Unicode scalar value contained in the +array. A -1 in this array indicates a malformed byte. If the value is +-2, -3, or -4, then the byte is the beginning of a 2, 3, or 4 byte +sequence respectively. Multi-byte sequences are sent to the convert +function pointed at in the <code>XML_Encoding</code> structure. This +function should return the Unicode scalar value for the sequence or -1 +if the sequence is malformed.</p> + +<p>One pitfall that novice Expat users are likely to fall into is that +although Expat may accept input in various encodings, the strings that +it passes to the handlers are always encoded in UTF-8 or UTF-16 +(depending on how Expat was compiled). Your application is responsible +for any translation of these strings into other encodings.</p> <h3>Handling External Entity References</h3> -<p>Expat does not read or parse external entities directly. Note that any -external DTD is a special case of an external entity. -If you've set no <code>ExternalEntityRefHandler</code>, then external -entity references are silently ignored. Otherwise, it calls your handler with -the information needed to read and parse the external entity. - -<p>Your handler -isn't actually responsible for parsing the entity, but it is responsible -for creating a subsidiary parser with -<code>XML_ExternalEntityParserCreate</code> that will do the job. This returns -an instance of <code>XML_Parser</code> that has handlers and other data -structures initialized from the parent parser. You may then use -<code>XML_Parse</code> or <code>XML_ParseBuffer</code> calls against this -parser. -Since external entities my refer to other external entities, your handler -should be prepared to be called recursively. +<p>Expat does not read or parse external entities directly. Note that +any external DTD is a special case of an external entity. If you've +set no <code>ExternalEntityRefHandler</code>, then external entity +references are silently ignored. Otherwise, it calls your handler with +the information needed to read and parse the external entity.</p> + +<p>Your handler isn't actually responsible for parsing the entity, but +it is responsible for creating a subsidiary parser with <code><a href= +"#XML_ExternalEntityParserCreate" +>XML_ExternalEntityParserCreate</a></code> that will do the job. This +returns an instance of <code>XML_Parser</code> that has handlers and +other data structures initialized from the parent parser. You may then +use <code><a href= "#XML_Parse" >XML_Parse</a></code> or <code><a +href= "#XML_ParseBuffer">XML_ParseBuffer</a></code> calls against this +parser. Since external entities my refer to other external entities, +your handler should be prepared to be called recursively.</p> <h3>Parsing DTDs</h3> -<p>In order to parse parameter entities, before starting the parse, you must -call <code>XML_SetParamEntityParsing</code> with one of the following -arguments: + +<p>In order to parse parameter entities, before starting the parse, +you must call <code><a href= "#XML_SetParamEntityParsing" +>XML_SetParamEntityParsing</a></code> with one of the following +arguments:</p> <dl> <dt><code>XML_PARAM_ENTITY_PARSING_NEVER</code></dt> <dd>Don't parse parameter entities or the external subset</dd> @@ -548,41 +604,38 @@ arguments: <dd>Always parse parameter entities and the external subset</dd> </dl> -<p>In order to read an external DTD, you also have to set an -external entity reference handler as described above. +<p>In order to read an external DTD, you also have to set an external +entity reference handler as described above.</p> -<hr> -<h2><a name="examples">Some expat Examples</a></h2> - -<hr> +<hr /> <!-- ================================================================ --> <h2><a name="reference">Expat Reference</a></h2> <h3><a name="creation">Parser Creation</a></h3> -<div class="fcndec"><a name="XML_ParserCreate"><pre> +<pre class="fcndec" id="XML_ParserCreate"> XML_Parser -XML_ParserCreate(const XML_Char *encoding) -</pre></a></div> +XML_ParserCreate(const XML_Char *encoding); +</pre> <div class="fcndef"> Construct a new parser. If encoding is non-null, it specifies a character encoding to use for the document. This overrides the document encoding declaration. There are four built-in encodings: <ul> -<li>US-ASCII -<li>UTF-8 -<li>UTF-16 -<li>ISO-8859-1 +<li>US-ASCII</li> +<li>UTF-8</li> +<li>UTF-16</li> +<li>ISO-8859-1</li> </ul> Any other value will invoke a call to the UnknownEncodingHandler. </div> -<div class="fcndec"><a name="XML_ParserCreateNS"><pre> +<pre class="fcndec" id="XML_ParserCreateNS"> XML_Parser XML_ParserCreateNS(const XML_Char *encoding, - XML_Char sep) -</pre></a></div> + XML_Char sep); +</pre> <div class="fcndef"> Constructs a new parser that has namespace processing in effect. Namespace expanded element names and attribute names are returned as a concatenation @@ -590,63 +643,94 @@ of the namespace URI, <em>sep</em>, and the local part of the name. This means that you should pick a character for <em>sep</em> that can't be part of a legal URI.</div> -<div class="fcndec"><a name="XML_ParserCreate_MM"><pre> +<pre class="fcndec" id="XML_ParserCreate_MM"> XML_Parser XML_ParserCreate_MM(const XML_Char *encoding, const XML_Memory_Handling_Suite *ms, - const XML_Char *sep) -</pre></a></div> + const XML_Char *sep); +</pre> +<pre class="signature"> +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; +</pre> <div class="fcndef"> <p>Construct a new parser using the suite of memory handling functions specified in <code>ms</code>. If <code>ms</code> is NULL, then use the standard set of memory management functions. If <code>sep</code> is non NULL, then namespace processing is enabled in the created parser and the character pointed at by sep is used as the separator between -the namespace URI and the local part of the name</p> -<div class="eg"><pre> -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; -</pre></div> +the namespace URI and the local part of the name.</p> </div> -<div class="fcndec"><a name="XML_ExternalEntityParserCreate"><pre> +<pre class="fcndec" id="XML_ExternalEntityParserCreate"> XML_Parser XML_ExternalEntityParserCreate(XML_Parser p, const XML_Char *context, - const XML_Char *encoding) -</pre></a></div> + const XML_Char *encoding); +</pre> <div class="fcndef"> -Construct a new XML_Parser object for parsing an external general -entity. Context is the context argument passed in a call to a -ExternalEntityRefHandler. Other state information such as handlers, user data, -namespace processing is inherited from the parser passed as the 1st -argument. So you shouldn't need to call any of the behavior changing -functions on this parser (unless you want it to act differently than the -parent parser.) +Construct a new <code>XML_Parser</code> object for parsing an external +general entity. Context is the context argument passed in a call to a +ExternalEntityRefHandler. Other state information such as handlers, +user data, namespace processing is inherited from the parser passed as +the 1st argument. So you shouldn't need to call any of the behavior +changing functions on this parser (unless you want it to act +differently than the parent parser). </div> -<div class="fcndec"><a name="XML_ParserFree"><pre> +<pre class="fcndec" id="XML_ParserFree"> void -XML_ParserFree(XML_Parser p) -</pre></a></div> +XML_ParserFree(XML_Parser p); +</pre> <div class="fcndef"> Free memory used by the parser. Your application is responsible for -freeing any memory associated with <a href="#userdata">UserData</a>. +freeing any memory associated with <a href="#userdata">user data</a>. </div> -<h3><a name="parsing">Parsing</a></h3> +<pre class="fcndec" id="XML_ParserReset"> +XML_Bool +XML_ParserReset(XML_Parser p); +</pre> +<div class="fcndef"> +Clean up the memory structures maintained by the parser so that it may +be used again. After this has been called, <code>parser</code> is +ready to start parsing a new document. This function may not be used +on a parser created using <code><a href= +"#XML_ExternalEntityParserCreate" >XML_ExternalEntityParserCreate</a +></code>; it will return <code>XML_FALSE</code> in that case. Returns +<code>XML_TRUE</code> on success. Your application is responsible for +dealing with any memory associated with <a href="#userdata">user data</a>. +</div> +<h3><a name="parsing">Parsing</a></h3> -<div class="fcndec"><a name="XML_Parse"><pre> -int +<p>To state the obvious: the three parsing functions <code><a href= +"#XML_Parse" >XML_Parse</a></code>, <code><a href= "#XML_ParseBuffer" +>XML_ParseBuffer</a></code> and <code><a href= "#XML_GetBuffer" +>>XML_GetBuffer</a></code> must not be +called from within a handler unless they operate on a separate parser +instance, that is, one that did not call the handler. For example, it +is OK to call the parsing functions from within an +<code>XML_ExternalEntityRefHandler</code>, if they apply to the parser +created by <code><a href= "#XML_ExternalEntityParserCreate" +>XML_ExternalEntityParserCreate</a></code>.</p> + +<pre class="fcndec" id="XML_Parse"> +XML_Status XML_Parse(XML_Parser p, const char *s, int len, - int isFinal) -</pre></a></div> + int isFinal); +</pre> +<pre class="signature"> +enum XML_Status { + XML_STATUS_ERROR = 0, + XML_STATUS_OK = 1 +}; +</pre> <div class="fcndef"> Parse some more of the document. The string <code>s</code> is a buffer containing part (or perhaps all) of the document. The number of bytes of s @@ -657,35 +741,37 @@ memory that <code>s</code> points at, then a memory fault is likely. The <code>isFinal</code> parameter informs the parser that this is the last piece of the document. Frequently, the last piece is empty (i.e. <code>len</code> is zero.) -If a parse error occurred, it returns 0. Otherwise it returns a non-zero -value. +If a parse error occurred, it returns <code>XML_STATUS_ERROR</code>. +Otherwise it returns <code>XML_STATUS_OK</code> value. </div> -<div class="fcndec"><a name="XML_ParseBuffer"><pre> -int +<pre class="fcndec" id="XML_ParseBuffer"> +XML_Status XML_ParseBuffer(XML_Parser p, int len, - int isFinal) -</pre></a></div> + int isFinal); +</pre> <div class="fcndef"> -This is just like XML_Parse, except in this case expat provides the buffer. -By obtaining the buffer from expat with the <code>XML_GetBuffer</code> -function, the application can avoid double copying of the input. +This is just like <code><a href= "#XML_Parse" >XML_Parse</a></code>, +except in this case Expat provides the buffer. By obtaining the +buffer from Expat with the <code><a href= "#XML_GetBuffer" +>XML_GetBuffer</a></code> function, the application can avoid double +copying of the input. </div> -<div class="fcndec"><a name="XML_GetBuffer"><pre> +<pre class="fcndec" id="XML_GetBuffer"> void * XML_GetBuffer(XML_Parser p, - int len) -</pre></a></div> + int len); +</pre> <div class="fcndef"> Obtain a buffer of size <code>len</code> to read a piece of the document -into. A NULL value is returned if expat can't allocate enough memory for +into. A NULL value is returned if Expat can't allocate enough memory for this buffer. This has to be called prior to every call to -<code>XML_ParseBuffer</code>. A typical use would look like this: +<code><a href= "#XML_ParseBuffer" >XML_ParseBuffer</a></code>. A +typical use would look like this: -<div id="eg"> -<pre> +<pre class="eg"> for (;;) { int bytes_read; void *buff = XML_GetBuffer(p, BUFF_SIZE); @@ -694,7 +780,7 @@ for (;;) { } bytes_read = read(docfd, buff, BUFF_SIZE); - if (bytes_read < 0) { + if (bytes_read < 0) { /* handle error */ } @@ -704,40 +790,40 @@ for (;;) { if (bytes_read == 0) break; -} +} </pre> </div> -</div> <h3><a name="setting">Handler Setting</a></h3> + <p>Although handlers are typically set prior to parsing and left alone, an application may choose to set or change the handler for a parsing event while the parse is in progress. For instance, your application may choose to ignore all text not descended from a <code>para</code> element. One way it could do this is to set the character handler when a para start tag -is seen, and unset it for the corresponding end tag. +is seen, and unset it for the corresponding end tag.</p> <p>A handler may be <em>unset</em> by providing a NULL pointer to the appropriate handler setter. None of the handler setting functions have -a return value. +a return value.</p> <p>Your handlers will be receiving strings in arrays of type -<code>XML_Char</code>. This type is defined in expat.h as <code>char *</code> -and contains bytes encoding UTF-8. -Note that you'll receive them in this form independent of the original -encoding of the document.</p> +<code>XML_Char</code>. This type is defined in expat.h as <code>char +*</code> and contains bytes encoding UTF-8. Note that you'll receive +them in this form independent of the original encoding of the +document.</p> <div class="handler"> -<div class="setter"><a name="XML_SetStartElementHandler"><pre> +<pre class="setter" id="XML_SetStartElementHandler"> XML_SetStartElementHandler(XML_Parser p, XML_StartElementHandler start); -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_StartElementHandler)(void *userData, const XML_Char *name, const XML_Char **atts); -</pre></div> +</pre> <p>Set handler for start (and empty) tags. Attributes are passed to the start handler as a pointer to a vector of char pointers. Each attribute seen in a start (or empty) tag occupies 2 consecutive places in this vector: the @@ -748,41 +834,41 @@ by a null pointer.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetEndElementHandler"><pre> +<pre class="setter" id="XML_SetEndElementHandler"> XML_SetEndElementHandler(XML_Parser p, XML_EndElementHandler); -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_EndElementHandler)(void *userData, const XML_Char *name); -</pre></div> +</pre> <p>Set handler for end (and empty) tags. As noted above, an empty tag generates a call to both start and end handlers.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetElementHandler"><pre> +<pre class="setter" id="XML_SetElementHandler"> XML_SetElementHandler(XML_Parser p, XML_StartElementHandler start, XML_EndElementHandler end); -</pre></a></div> +</pre> <p>Set handlers for start and end tags with one call.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetCharacterDataHandler"><pre> +<pre class="setter" id="XML_SetCharacterDataHandler"> XML_SetCharacterDataHandler(XML_Parser p, XML_CharacterDataHandler charhndl) -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_CharacterDataHandler)(void *userData, const XML_Char *s, int len); -</pre></div> +</pre> <p>Set a text handler. The string your handler receives -is <em>NOT zero terminated</em>. You have to use the length argument +is <em>NOT nul-terminated</em>. You have to use the length argument to deal with the end of the string. A single block of contiguous text free of markup may still result in a sequence of calls to this handler. In other words, if you're searching for a pattern in the text, it may @@ -790,199 +876,251 @@ be split across calls to this handler.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetProcessingInstructionHandler"><pre> +<pre class="setter" id="XML_SetProcessingInstructionHandler"> XML_SetProcessingInstructionHandler(XML_Parser p, XML_ProcessingInstructionHandler proc) -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_ProcessingInstructionHandler)(void *userData, const XML_Char *target, const XML_Char *data); -</pre></div> +</pre> <p>Set a handler for processing instructions. The target is the first word in the processing instruction. The data is the rest of the characters in it after skipping all whitespace after the initial word.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetCommentHandler"><pre> +<pre class="setter" id="XML_SetCommentHandler"> XML_SetCommentHandler(XML_Parser p, XML_CommentHandler cmnt) -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data); -</pre></div> +</pre> <p>Set a handler for comments. The data is all text inside the comment delimiters.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetStartCdataSectionHandler"><pre> +<pre class="setter" id="XML_SetStartCdataSectionHandler"> XML_SetStartCdataSectionHandler(XML_Parser p, XML_StartCdataSectionHandler start); -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_StartCdataSectionHandler)(void *userData); -</pre></div> +</pre> <p>Set a handler that gets called at the beginning of a CDATA section.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetEndCdataSectionHandler"><pre> +<pre class="setter" id="XML_SetEndCdataSectionHandler"> XML_SetEndCdataSectionHandler(XML_Parser p, XML_EndCdataSectionHandler end); -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_EndCdataSectionHandler)(void *userData); -</pre></div> +</pre> <p>Set a handler that gets called at the end of a CDATA section.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetCdataSectionHandler"><pre> +<pre class="setter" id="XML_SetCdataSectionHandler"> XML_SetCdataSectionHandler(XML_Parser p, XML_StartCdataSectionHandler start, XML_EndCdataSectionHandler end) -</pre></a></div> +</pre> <p>Sets both CDATA section handlers with one call.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetDefaultHandler"><pre> +<pre class="setter" id="XML_SetDefaultHandler"> XML_SetDefaultHandler(XML_Parser p, XML_DefaultHandler hndl) -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_DefaultHandler)(void *userData, const XML_Char *s, int len); -</pre></div> +</pre> + <p>Sets a handler for any characters in the document which wouldn't -otherwise be handled. This includes both data for which no handlers can be -set (like some kinds of DTD declarations) and data which could be reported -but which currently has no handler set. Note that a contiguous piece of -data that is destined to be reported to the default handler may actually -be reported over several calls to the handler. Setting the handler with +otherwise be handled. This includes both data for which no handlers +can be set (like some kinds of DTD declarations) and data which could +be reported but which currently has no handler set. The characters +are passed exactly as they were present 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. Setting the handler with this call has the side effect of turning off expansion of references to internally defined general entities. Instead these references are passed to the default handler.</p> + +<p>See also <code><a +href="#XML_DefaultCurrent">XML_DefaultCurrent</a></code>.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetDefaultHandlerExpand"><pre> +<pre class="setter" id="XML_SetDefaultHandlerExpand"> XML_SetDefaultHandlerExpand(XML_Parser p, XML_DefaultHandler hndl) -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_DefaultHandler)(void *userData, const XML_Char *s, int len); -</pre></div> -<p>This sets a default handler, but doesn't affect expansion of internal -entity references.</p> +</pre> +<p>This sets a default handler, but doesn't inhibit the expansion of +internal entity references. The entity reference will not be passed +to the default handler.</p> + +<p>See also <code><a +href="#XML_DefaultCurrent">XML_DefaultCurrent</a></code>.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetExternalEntityRefHandler"><pre> +<pre class="setter" id="XML_SetExternalEntityRefHandler"> XML_SetExternalEntityRefHandler(XML_Parser p, XML_ExternalEntityRefHandler hndl) -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef int (*XML_ExternalEntityRefHandler)(XML_Parser p, const XML_Char *context, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId); -</pre></div> +</pre> <p>Set an external entity reference handler. This handler is also called for processing an external DTD subset if parameter entity parsing is in effect. (See <a href="#XML_SetParamEntityParsing"> <code>XML_SetParamEntityParsing</code></a>.)</p> - -<p>The base parameter is the base to use for relative system identifiers. -It is set by <a href="#XML_SetBase">XML_SetBase</a> and may be null. The -public id parameter is the public id given in the entity declaration and -may be null. The system id is the system identifier specified in the entity -declaration and is never null.</p> - -<p>There are a couple of ways in which this handler differs from others. -First, this handler returns an integer. A non-zero value should be returned -for successful handling of the external entity reference. Returning a zero -indicates failure, and causes the calling parser to return -an <code>XML_ERROR_EXTERNAL_ENTITY_HANDLING</code> error.</p> - -<p>Second, instead of having userData as its first argument, it receives the -parser that encountered the entity reference. This, along with the context -parameter, may be used as arguments to a call to -<a href="#XML_ExternalEntityParserCreate">XML_ExternalEntityParserCreate</a>. -Using the returned parser, the body of the external entity can be recursively -parsed.</p> +<p>The <code>context</code> parameter specifies the parsing context in +the format expected by the <code>context</code> argument to <code><a +href="#XML_ExternalEntityParserCreate" +>XML_ExternalEntityParserCreate</a></code>. <code>code</code> is +valid only until the handler returns, so if the referenced entity is +to be parsed later, it must be copied. <code>context</code> is NULL +only when the entity is a parameter entity, which is how one can +differentiate between general and parameter entities.</p> + +<p>The <code>base</code> parameter is the base to use for relative +system identifiers. It is set by <code><a +href="#XML_SetBase">XML_SetBase</a></code> and may be NULL. The +<code>publicId</code> parameter is the public id given in the entity +declaration and may be NULL. <code>systemId</code> is the system +identifier specified in the entity declaration and is never NULL.</p> + +<p>There are a couple of ways in which this handler differs from +others. First, this handler returns a status indicator (an +integer). <code>XML_STATUS_OK</code> should be returned for successful +handling of the external entity reference. Returning +<code>XML_STATUS_ERROR</code> indicates failure, and causes the +calling parser to return an +<code>XML_ERROR_EXTERNAL_ENTITY_HANDLING</code> error.</p> + +<p>Second, instead of having the user data as its first argument, it +receives the parser that encountered the entity reference. This, along +with the context parameter, may be used as arguments to a call to +<code><a href= "#XML_ExternalEntityParserCreate" +>XML_ExternalEntityParserCreate</a></code>. Using the returned +parser, the body of the external entity can be recursively parsed.</p> <p>Since this handler may be called recursively, it should not be saving information into global or static variables.</p> </div> +<pre class="fcndec" id="XML_SetExternalEntityRefHandlerArg"> +XML_SetExternalEntityRefHandlerArg(XML_Parser p, + void *arg) +</pre> +<div class="fcndef"> +<p>Set the argument passed to the ExternalEntityRefHandler. If +<code>arg</code> is not NULL, it is the new value passed to the +handler set using <code><a href="#XML_SetExternalEntityRefHandler" +>XML_SetExternalEntityRefHandler</a></code>; if <code>arg</code> is +NULL, the argument passed to the handler function will be the parser +object itself.</p> + +<p><strong>Note:</strong> +The type of <code>arg</code> and the type of the first argument to the +ExternalEntityRefHandler do not match. This function takes a +<code>void *</code> to be passed to the handler, while the handler +accepts an <code>XML_Parser</code>. This is a historical accident, +but will not be corrected before Expat 2.0 (at the earliest) to avoid +causing compiler warnings for code that's known to work with this +API. It is the responsibility of the application code to know the +actual type of the argument passed to the handler and to manage it +properly.</p> +</div> + <div class="handler"> -<div class="setter"><a name="XML_SetSkippedEntityHandler"><pre> +<pre class="setter" id="XML_SetSkippedEntityHandler"> XML_SetSkippedEntityHandler(XML_Parser p, XML_SkippedEntityHandler handler) -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_SkippedEntityHandler)(void *userData, const XML_Char *entityName, int is_parameter_entity); -</pre></div> +</pre> <p>Set a skipped entity handler. This is called in two situations:</p> <ol> <li>An entity reference is encountered for which no declaration - has been read *and* this is not an error.</li> + has been read <em>and</em> this is not an error.</li> <li>An internal entity reference is read, but not expanded, because <a href="#XML_SetDefaultHandler"><code>XML_SetDefaultHandler</code></a> has been called.</li> </ol> <p>The <code>is_parameter_entity</code> argument will be non-zero for -a parameter entity and zero for a general entity.</p> -<p>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</p> +a parameter entity and zero for a general entity.</p> <p>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</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetUnknownEncodingHandler"><pre> +<pre class="setter" id="XML_SetUnknownEncodingHandler"> XML_SetUnknownEncodingHandler(XML_Parser p, XML_UnknownEncodingHandler enchandler, - void *encodingHandlerData) -</pre></a></div> -<div class="signature"><pre> + void *encodingHandlerData) +</pre> +<pre class="signature"> typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData, const XML_Char *name, XML_Encoding *info); -</pre></div> -<p>Set a handler to deal with encodings other than the -<a href="#builtin_encodings">built in set</a>. If the handler knows how -to deal with an encoding with the given name, it should fill in the info -data structure and return 1. Otherwise it should return 0.</p> -<pre> - typedef struct { - int map[256]; - void *data; - int (*convert)(void *data, const char *s); - void (*release)(void *data); - } XML_Encoding; +typedef struct { + int map[256]; + void *data; + int (*convert)(void *data, const char *s); + void (*release)(void *data); +} XML_Encoding; </pre> +<p>Set a handler to deal with encodings other than the <a +href="#builtin_encodings">built in set</a>. This should be done before +<code><a href= "#XML_Parse" >XML_Parse</a></code> or <code><a href= +"#XML_ParseBuffer" >XML_ParseBuffer</a></code> have been called on the +given parser.</p> <p>If the handler knows how to deal with an encoding +with the given name, it should fill in the <code>info</code> data +structure and return <code>XML_STATUS_ERROR</code>. Otherwise it +should return <code>XML_STATUS_OK</code>. The handler will be called +at most once per parsed (external) entity. The optional application +data pointer <code>encodingHandlerData</code> will be passed back to +the handler.</p> <p>The map array contains information for every possible possible leading byte in a byte sequence. If the corresponding value is >= 0, then it's @@ -993,89 +1131,110 @@ bytes in the sequence and the actual conversion is accomplished by a call to the function pointed at by convert. This function may return -1 if the sequence itself is invalid. The convert pointer may be null if there are only single byte codes. The data parameter passed to the convert -function is the data pointer from XML_Encoding. The string s is <em>NOT</em> -null terminated and points at the sequence of bytes to be converted.</p> +function is the data pointer from <code>XML_Encoding</code>. The +string s is <em>NOT</em> nul-terminated and points at the sequence of +bytes to be converted.</p> -<p>The function pointed at by release is called by the parser when it is -finished with the encoding. It may be null.</p> +<p>The function pointed at by <code>release</code> is called by the +parser when it is finished with the encoding. It may be NULL.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetStartNamespaceDeclHandler"><pre> +<pre class="setter" id="XML_SetStartNamespaceDeclHandler"> XML_SetStartNamespaceDeclHandler(XML_Parser p, XML_StartNamespaceDeclHandler start); -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_StartNamespaceDeclHandler)(void *userData, const XML_Char *prefix, const XML_Char *uri); -</pre></div> +</pre> <p>Set a handler to be called when a namespace is declared. Namespace declarations occur inside start tags. But the namespace declaration start handler is called before the start tag handler for each namespace declared in that start tag.</p> + +<p><strong>Note:</strong> +Due to limitations of the implementation, the +StartNamespaceDeclHandler is not called unless the StartElementHandler +is also set. The specific value of the StartElementHandler is allowed +to change freely, so long as it is not NULL.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetEndNamespaceDeclHandler"><pre> +<pre class="setter" id="XML_SetEndNamespaceDeclHandler"> XML_SetEndNamespaceDeclHandler(XML_Parser p, XML_EndNamespaceDeclHandler end); -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_EndNamespaceDeclHandler)(void *userData, const XML_Char *prefix); -</pre></div> +</pre> <p>Set a handler to be called when leaving the scope of a namespace -declaration. This will be called, for each namespace declaration, after -the handler for the end tag of the element in which the namespace was declared. -</p> +declaration. This will be called, for each namespace declaration, +after the handler for the end tag of the element in which the +namespace was declared.</p> + +<p><strong>Note:</strong> +Due to limitations of the implementation, the EndNamespaceDeclHandler +is not called unless the StartElementHandler is also set. The +specific value of the StartElementHandler is allowed to change freely, +so long as it is not NULL.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetNamespaceDeclHandler"><pre> +<pre class="setter" id="XML_SetNamespaceDeclHandler"> XML_SetNamespaceDeclHandler(XML_Parser p, XML_StartNamespaceDeclHandler start, XML_EndNamespaceDeclHandler end) -</pre></a></div> -<p>Sets both namespace declaration handlers with a single call</p> +</pre> +<p>Sets both namespace declaration handlers with a single call.</p> + +<p><strong>Note:</strong> +Due to limitations of the implementation, the +StartNamespaceDeclHandler and EndNamespaceDeclHandler are not called +unless the StartElementHandler is also set. The specific value of the +StartElementHandler is allowed to change freely, so long as it is not +NULL.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetXmlDeclHandler"><pre> +<pre class="setter" id="XML_SetXmlDeclHandler"> XML_SetXmlDeclHandler(XML_Parser p, XML_XmlDeclHandler xmldecl); -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_XmlDeclHandler) (void *userData, const XML_Char *version, const XML_Char *encoding, int standalone); -</pre></div> +</pre> <p>Sets a handler that is called for XML declarations and also for -text declarations discovered in external entities. The way to distinguish -is that the <code>version</code> parameter will be NULL for text -declarations. The <code>encoding</code> parameter may be NULL for -an XML declaration. The <code>standalone</code> argument will contain --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.</p> +text declarations discovered in external entities. The way to +distinguish is that the <code>version</code> parameter will be NULL +for text declarations. The <code>encoding</code> parameter may be NULL +for an XML declaration. The <code>standalone</code> argument will +contain -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.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetStartDoctypeDeclHandler"><pre> +<pre class="setter" id="XML_SetStartDoctypeDeclHandler"> XML_SetStartDoctypeDeclHandler(XML_Parser p, XML_StartDoctypeDeclHandler start); -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_StartDoctypeDeclHandler)(void *userData, const XML_Char *doctypeName, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset); -</pre></div> +</pre> <p>Set a handler that is called at the start of a DOCTYPE declaration, before any external or internal subset is parsed. Both <code>sysid</code> and <code>pubid</code> may be NULL. The <code>has_internal_subset</code> @@ -1083,39 +1242,39 @@ will be non-zero if the DOCTYPE declaration has an internal subset.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetEndDoctypeDeclHandler"><pre> +<pre class="setter" id="XML_SetEndDoctypeDeclHandler"> XML_SetEndDoctypeDeclHandler(XML_Parser p, XML_EndDoctypeDeclHandler end); -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_EndDoctypeDeclHandler)(void *userData); -</pre></div> +</pre> <p>Set a handler that is called at the end of a DOCTYPE declaration, after parsing any external subset.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetDoctypeDeclHandler"><pre> +<pre class="setter" id="XML_SetDoctypeDeclHandler"> XML_SetDoctypeDeclHandler(XML_Parser p, XML_StartDoctypeDeclHandler start, XML_EndDoctypeDeclHandler end); -</pre></a></div> +</pre> <p>Set both doctype handlers with one call.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetElementDeclHandler"><pre> +<pre class="setter" id="XML_SetElementDeclHandler"> XML_SetElementDeclHandler(XML_Parser p, XML_ElementDeclHandler eldecl); -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_ElementDeclHandler)(void *userData, const XML_Char *name, XML_Content *model); -</pre></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> enum XML_Content_Type { XML_CTYPE_EMPTY = 1, XML_CTYPE_ANY, @@ -1141,42 +1300,46 @@ struct XML_cp { unsigned int numchildren; XML_Content * children; }; -</pre></div> -<p>Sets a handler for element declarations in a DTD. The handler gets called -with the name of the element in the declaration and a pointer to a structure -that contains the element model. It is the application's responsibility to -free this data structure.</p> +</pre> +<p>Sets a handler for element declarations in a DTD. The handler gets +called with the name of the element in the declaration and a pointer +to a structure that contains the element model. It is the +application's responsibility to free this data structure using +<code><a href="#XML_FreeContentModel" +>XML_FreeContentModel</a></code>.</p> <p>The <code>model</code> argument is the root of a tree of <code>XML_Content</code> nodes. If <code>type</code> equals <code>XML_CTYPE_EMPTY</code> or <code>XML_CTYPE_ANY</code>, then -<code>quant</code> will be <code>XML_CQUANT_NONE</code>, and the other fields -will be zero or NULL. -If <code>type</code> is <code>XML_CTYPE_MIXED</code>, then <code>quant</code> -will be <code>XML_CQUANT_NONE</code> or <code>XML_CQUANT_REP</code> and -<code>numchildren</code> will contain the number of elements that are allowed -to be mixed in and <code>children</code> points to an array of -<code>XML_Content</code> structures that will all have type XML_CTYPE_NAME -with no quantification. -Only the root node can be type <code>XML_CTYPE_EMPTY</code>, <code>XML_CTYPE_ANY</code>, or <code>XML_CTYPE_MIXED</code>.</p> - -<p>For type <code>XML_CTYPE_NAME</code>, the <code>name</code> field points -to the name and the <code>numchildren</code> and <code>children</code> fields -will be zero and NULL. The <code>quant</code> field will indicate any -quantifiers placed on the name.</p> +<code>quant</code> will be <code>XML_CQUANT_NONE</code>, and the other +fields will be zero or NULL. If <code>type</code> is +<code>XML_CTYPE_MIXED</code>, then <code>quant</code> will be +<code>XML_CQUANT_NONE</code> or <code>XML_CQUANT_REP</code> and +<code>numchildren</code> will contain the number of elements that are +allowed to be mixed in and <code>children</code> points to an array of +<code>XML_Content</code> structures that will all have type +XML_CTYPE_NAME with no quantification. Only the root node can be type +<code>XML_CTYPE_EMPTY</code>, <code>XML_CTYPE_ANY</code>, or +<code>XML_CTYPE_MIXED</code>.</p> + +<p>For type <code>XML_CTYPE_NAME</code>, the <code>name</code> field +points to the name and the <code>numchildren</code> and +<code>children</code> fields will be zero and NULL. The +<code>quant</code> field will indicate any quantifiers placed on the +name.</p> <p>Types <code>XML_CTYPE_CHOICE</code> and <code>XML_CTYPE_SEQ</code> -indicate a choice or sequence respectively. The <code>numchildren</code> -field indicates how many nodes in the choice or sequence and -<code>children</code> points to the nodes.</p> +indicate a choice or sequence respectively. The +<code>numchildren</code> field indicates how many nodes in the choice +or sequence and <code>children</code> points to the nodes.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetAttlistDeclHandler"><pre> +<pre class="setter" id="XML_SetAttlistDeclHandler"> XML_SetAttlistDeclHandler(XML_Parser p, XML_AttlistDeclHandler attdecl); -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_AttlistDeclHandler) (void *userData, const XML_Char *elname, @@ -1184,32 +1347,31 @@ typedef void const XML_Char *att_type, const XML_Char *dflt, int isrequired); -</pre></div> -<p>Set a handler for attlist declarations in the DTD. This handler is called -for <em>each</em> attribute. So a single attlist declaration with multiple -attributes declared will generate multiple calls to this handler. The -<code>elname</code> parameter returns the name of the element for which the -attribute is being declared. The attribute name is in the <code>attname</code> -parameter. The attribute type is in the <code>att_type</code> parameter. -It is the string representing the type in the declaration with whitespace -removed.</p> - -<p>The <code>dflt</code> parameter holds the default value. It will -be NULL in the case of "#IMPLIED" or "#REQUIRED" attributes. You can +</pre> +<p>Set a handler for attlist declarations in the DTD. This handler is +called for <em>each</em> attribute. So a single attlist declaration +with multiple attributes declared will generate multiple calls to this +handler. The <code>elname</code> parameter returns the name of the +element for which the attribute is being declared. The attribute name +is in the <code>attname</code> parameter. The attribute type is in the +<code>att_type</code> parameter. It is the string representing the +type in the declaration with whitespace removed.</p> + +<p>The <code>dflt</code> parameter holds the default value. It will be +NULL in the case of "#IMPLIED" or "#REQUIRED" attributes. You can distinguish these two cases by checking the <code>isrequired</code> parameter, which will be true in the case of "#REQUIRED" attributes. Attributes which are "#FIXED" will have also have a true -<code>isrequired</code>, but they will have the non-NULL fixed value in the -<code>dflt</code> parameter. -</p> +<code>isrequired</code>, but they will have the non-NULL fixed value +in the <code>dflt</code> parameter.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetEntityDeclHandler"><pre> +<pre class="setter" id="XML_SetEntityDeclHandler"> XML_SetEntityDeclHandler(XML_Parser p, XML_EntityDeclHandler handler); -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_EntityDeclHandler) (void *userData, const XML_Char *entityName, @@ -1220,28 +1382,29 @@ typedef void const XML_Char *systemId, const XML_Char *publicId, const XML_Char *notationName); -</pre></div> +</pre> <p>Sets a handler that will be called for all entity declarations. -The <code>is_parameter_entity</code> argument will be non-zero in the case -of parameter entities and zero otherwise. -</p> +The <code>is_parameter_entity</code> argument will be non-zero in the +case of parameter entities and zero otherwise.</p> + <p>For internal entities (<code><!ENTITY foo "bar"></code>), <code>value</code> will be non-NULL and <code>systemId</code>, <code>publicId</code>, and <code>notationName</code> will all be NULL. -The value string is <em>not</em> NULL terminated; the length is provided in -the <code>value_length</code> parameter. Do not use <code>value_length</code> -to test for internal entities, since it is legal to have zero-length -values. Instead check for whether or not <code>value</code> is NULL.</p> -<p>The <code>notationName</code> argument will have a non-NULL value only -for unparsed entity declarations.</p> +The value string is <em>not</em> NULL terminated; the length is +provided in the <code>value_length</code> parameter. Do not use +<code>value_length</code> to test for internal entities, since it is +legal to have zero-length values. Instead check for whether or not +<code>value</code> is NULL.</p> <p>The <code>notationName</code> +argument will have a non-NULL value only for unparsed entity +declarations.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetUnparsedEntityDeclHandler"><pre> +<pre class="setter" id="XML_SetUnparsedEntityDeclHandler"> XML_SetUnparsedEntityDeclHandler(XML_Parser p, XML_UnparsedEntityDeclHandler h) -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_UnparsedEntityDeclHandler)(void *userData, const XML_Char *entityName, @@ -1249,109 +1412,112 @@ typedef void const XML_Char *systemId, const XML_Char *publicId, const XML_Char *notationName); -</pre></div> +</pre> <p>Set a handler that receives declarations of unparsed entities. These are entity declarations that have a notation (NDATA) field:</p> <div id="eg"><pre> <!ENTITY logo SYSTEM "images/logo.gif" NDATA gif> </pre></div> - -<p>This handler is obsolete and is provided for backwards compatibility. -Use instead <a href="#XML_SetEntityDeclHandler">XML_SetEntityDeclHandler</a>. -</p> +<p>This handler is obsolete and is provided for backwards +compatibility. Use instead <a href= "#XML_SetEntityDeclHandler" +>XML_SetEntityDeclHandler</a>.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetNotationDeclHandler"><pre> +<pre class="setter" id="XML_SetNotationDeclHandler"> XML_SetNotationDeclHandler(XML_Parser p, XML_NotationDeclHandler h) -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef void (*XML_NotationDeclHandler)(void *userData, const XML_Char *notationName, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId); -</pre></div> +</pre> <p>Set a handler that receives notation declarations.</p> </div> <div class="handler"> -<div class="setter"><a name="XML_SetNotStandaloneHandler"><pre> +<pre class="setter" id="XML_SetNotStandaloneHandler"> XML_SetNotStandaloneHandler(XML_Parser p, XML_NotStandaloneHandler h) -</pre></a></div> -<div class="signature"><pre> +</pre> +<pre class="signature"> typedef int (*XML_NotStandaloneHandler)(void *userData); -</pre></div> +</pre> <p>Set a handler that is called if the document is not "standalone". -This happens when there is an external subset or a reference to a parameter -entity, but does not have standalone set to "yes" in an XML declaration. -If this handler returns 0, then the parser will throw an -<code>XML_ERROR_NOT_STANDALONE</code> error.</p> +This happens when there is an external subset or a reference to a +parameter entity, but does not have standalone set to "yes" in an XML +declaration. If this handler returns <code>XML_STATUS_ERROR</code>, +then the parser will throw an <code>XML_ERROR_NOT_STANDALONE</code> +error.</p> </div> <h3><a name="position">Parse position and error reporting functions</a></h3> -<p>These are the functions you'll want to call when the parse functions -return 0 (i.e. a parse error has ocurred), although the position reporting -functions are useful outside of errors. The position reported is the byte -position (in the original document or entity encoding) of the first of the -sequence of characters that generated the current event (or the error that -caused the parse functions to return 0.)</p> -<p>The position reporting functions are accurate only outside of the DTD. -In other words, they usually return bogus information when called from within -a DTD declaration handler.</p> - -<div class="fcndec"><a name="XML_GetErrorCode"><pre> + +<p>These are the functions you'll want to call when the parse +functions return <code>XML_STATUS_ERROR</code> (a parse error has +ocurred), although the position reporting functions are useful outside +of errors. The position reported is the byte position (in the original +document or entity encoding) of the first of the sequence of +characters that generated the current event (or the error that caused +the parse functions to return <code>XML_STATUS_ERROR</code>.)</p> + +<p>The position reporting functions are accurate only outside of the +DTD. In other words, they usually return bogus information when +called from within a DTD declaration handler.</p> + +<pre class="fcndec" id="XML_GetErrorCode"> enum XML_Error -XML_GetErrorCode(XML_Parser p) -</pre></a></div> +XML_GetErrorCode(XML_Parser p); +</pre> <div class="fcndef"> Return what type of error has occurred. </div> -<div class="fcndec"><a name="XML_ErrorString"><pre> +<pre class="fcndec" id="XML_ErrorString"> const XML_LChar * -XML_ErrorString(int code) -</pre></a></div> +XML_ErrorString(int code); +</pre> <div class="fcndef"> Return a string describing the error corresponding to code. The code should be one of the enums that can be returned from -XML_GetErrorCode. +<code><a href= "#XML_GetErrorCode" >XML_GetErrorCode</a></code>. </div> -<div class="fcndec"><a name="XML_GetCurrentByteIndex"><pre> +<pre class="fcndec" id="XML_GetCurrentByteIndex"> long -XML_GetCurrentByteIndex(XML_Parser p) -</pre></a></div> +XML_GetCurrentByteIndex(XML_Parser p); +</pre> <div class="fcndef"> Return the byte offset of the position. </div> -<div class="fcndec"><a name="XML_GetCurrentLineNumber"><pre> +<pre class="fcndec" id="XML_GetCurrentLineNumber"> int -XML_GetCurrentLineNumber(XML_Parser p) -</pre></a></div> +XML_GetCurrentLineNumber(XML_Parser p); +</pre> <div class="fcndef"> Return the line number of the position. </div> -<div class="fcndec"><a name="XML_GetCurrentColumnNumber"><pre> +<pre class="fcndec" id="XML_GetCurrentColumnNumber"> int -XML_GetCurrentColumnNumber(XML_Parser p) -</pre></a></div> +XML_GetCurrentColumnNumber(XML_Parser p); +</pre> <div class="fcndef"> Return the offset, from the beginning of the current line, of the position. </div> -<div class="fcndec"><a name="XML_GetCurrentByteCount"><pre> +<pre class="fcndec" id="XML_GetCurrentByteCount"> int XML_GetCurrentByteCount(XML_Parser p); -</pre></a></div> +</pre> <div class="fcndef"> Return the number of bytes in the current event. Returns <code>0</code> if the event is inside a reference to an internal @@ -1360,125 +1526,137 @@ be used to distinguish empty-element tags from empty elements using separate start and end tags). </div> -<div class="fcndec"><a name="XML_GetInputContext"><pre> +<pre class="fcndec" id="XML_GetInputContext"> const char * XML_GetInputContext(XML_Parser p, int *offset, int *size); -</pre></a></div> +</pre> <div class="fcndef"> + <p>Returns the parser's input buffer, sets the integer pointed at by <code>offset</code> to the offset within this buffer of the current -parse position, and set the integer pointed at by <code>size</code> -to the size of the returned buffer.</p> +parse position, and set the integer pointed at by <code>size</code> to +the size of the returned buffer.</p> + <p>This should only be called from within a handler during an active parse and the returned buffer should only be referred to from within -the handler that made the call. This input buffer contains the untranslated -bytes of the input.</p> -<p>Only a limited amount of context is kept, so if the event triggering -a call spans over a very large amount of input, the actual parse position -may be before the beginning of the buffer.</p> +the handler that made the call. This input buffer contains the +untranslated bytes of the input.</p> + +<p>Only a limited amount of context is kept, so if the event +triggering a call spans over a very large amount of input, the actual +parse position may be before the beginning of the buffer.</p> </div> <h3><a name="miscellaneous">Miscellaneous functions</a></h3> -<p>The functions in this section either obtain state information from the -parser or can be used to dynamicly set parser options. -<div class="fcndec"><a name="XML_SetUserData"><pre> +<p>The functions in this section either obtain state information from +the parser or can be used to dynamicly set parser options.</p> + +<pre class="fcndec" id="XML_SetUserData"> void XML_SetUserData(XML_Parser p, - void *userData) -</pre></a></div> + void *userData); +</pre> <div class="fcndef"> -This sets the user data pointer that gets passed to handlers. -It overwrites any previous value for this pointer. Note that the +This sets the user data pointer that gets passed to handlers. It +overwrites any previous value for this pointer. Note that the application is responsible for freeing the memory associated with -<code>userData</code> when it is finished with the parser. So if -you call this when there's already a pointer there, and you haven't -freed the memory associated with it, then you've probably just leaked +<code>userData</code> when it is finished with the parser. So if you +call this when there's already a pointer there, and you haven't freed +the memory associated with it, then you've probably just leaked memory. </div> -<div class="fcndec"><a name="XML_GetUserData"><pre> +<pre class="fcndec" id="XML_GetUserData"> void * -XML_GetUserData(XML_Parser p) -</pre></a></div> +XML_GetUserData(XML_Parser p); +</pre> <div class="fcndef"> This returns the user data pointer that gets passed to handlers. It is actually implemented as a macro. </div> -<div class="fcndec"><a name="XML_UseParserAsHandlerArg"><pre> +<pre class="fcndec" id="XML_UseParserAsHandlerArg"> void -XML_UseParserAsHandlerArg(XML_Parser p) -</pre></a></div> +XML_UseParserAsHandlerArg(XML_Parser p); +</pre> <div class="fcndef"> -After this is called, handlers receive the parser in the -userData argument. The userData information can still be obtained using -the XML_GetUserData function. +After this is called, handlers receive the parser in their +<code>userData</code> arguments. The user data can still be obtained +using the <code><a href= "#XML_GetUserData" +>XML_GetUserData</a></code> function. </div> -<div class="fcndec"><a name="XML_SetBase"><pre> -int +<pre class="fcndec" id="XML_SetBase"> +enum XML_Status XML_SetBase(XML_Parser p, - const XML_Char *base) -</pre></a></div> + const XML_Char *base); +</pre> <div class="fcndef"> -Set the base to be used for resolving relative URIs in system identifiers. -The return value is 0 if there's no memory to store base, otherwise it's -non-zero. +Set the base to be used for resolving relative URIs in system +identifiers. The return value is <code>XML_STATUS_ERROR</code> if +there's no memory to store base, otherwise it's +<code>XML_STATUS_OK</code>. </div> -<div class="fcndec"><a name="XML_GetBase"><pre> +<pre class="fcndec" id="XML_GetBase"> const XML_Char * -XML_GetBase(XML_Parser p) -</pre></a></div> +XML_GetBase(XML_Parser p); +</pre> <div class="fcndef"> Return the base for resolving relative URIs. </div> -<div class="fcndec"><a name="XML_GetSpecifiedAttributeCount"><pre> +<pre class="fcndec" id="XML_GetSpecifiedAttributeCount"> int -XML_GetSpecifiedAttributeCount(XML_Parser p) -</pre></a></div> +XML_GetSpecifiedAttributeCount(XML_Parser p); +</pre> <div class="fcndef"> When attributes are reported to the start handler in the atts vector, attributes that were explicitly set in the element occur before any attributes that receive their value from default information in an -ATTLIST declaration. This function returns the number of attributes that -were explicitly set times two, thus giving the offset in the <code>atts</code> -array passed to the start tag handler of the first attribute set -due to defaults. It supplies information for the last call to a start -handler. If called inside a start handler, then that means the current call. +ATTLIST declaration. This function returns the number of attributes +that were explicitly set times two, thus giving the offset in the +<code>atts</code> array passed to the start tag handler of the first +attribute set due to defaults. It supplies information for the last +call to a start handler. If called inside a start handler, then that +means the current call. </div> -<div class="fcndec"><a name="XML_GetIdAttributeIndex"><pre> +<pre class="fcndec" id="XML_GetIdAttributeIndex"> int XML_GetIdAttributeIndex(XML_Parser p); -</pre></a></div> +</pre> <div class="fcndef"> -Returns the index of the ID attribute passed in the atts array -in the last call to XML_StartElementHandler, or -1 if there is no ID -attribute. If called inside a start handler, then that means the current call. +Returns the index of the ID attribute passed in the atts array in the +last call to <code><a href= "#XML_StartElementHandler" +>XML_StartElementHandler</a></code>, or -1 if there is no ID +attribute. If called inside a start handler, then that means the +current call. </div> -<div class="fcndec"><a name="XML_SetEncoding"><pre> -int +<pre class="fcndec" id="XML_SetEncoding"> +enum XML_Status XML_SetEncoding(XML_Parser p, - const XML_Char *encoding) -</pre></a></div> + const XML_Char *encoding); +</pre> <div class="fcndef"> Set the encoding to be used by the parser. It is equivalent to passing a non-null encoding argument to the parser creation functions. -It must not be called after XML_Parser or XML_ParseBuffer have been -called on the given parser. +It must not be called after <code><a href= "#XML_Parse" +>XML_Parse</a></code> or <code><a href= "#XML_ParseBuffer" +>XML_ParseBuffer</a></code> have been called on the given parser. +Returns <code>XML_STATUS_OK</code> on success or +<code>XML_STATUS_ERROR</code> on error. </div> -<div class="fcndec"><a name="XML_SetParamEntityParsing"><pre> +<pre class="fcndec" id="XML_SetParamEntityParsing"> int XML_SetParamEntityParsing(XML_Parser p, - enum XML_ParamEntityParsing code) -</pre></a></div> + enum XML_ParamEntityParsing code); +</pre> <div class="fcndef"> This enables parsing of parameter entities, including the external parameter entity that is the external DTD subset, according to @@ -1491,47 +1669,95 @@ The choices for <code>code</code> are: </ul> </div> -<div class="fcndec"><a name="XML_SetReturnNSTriplet"><pre> +<pre class="fcndec" id="XML_UseForeignDTD"> +enum XML_Error +XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD); +</pre> +<div class="fcndef"> +<p>This function allows an application to provide an external subset +for the document type declaration for documents which do not specify +an external subset of their own. For documents which specify an +external subset in their DOCTYPE declaration, the application-provided +subset will be ignored. If the document does not contain a DOCTYPE +declaration at all and <code>useDTD</code> is true, the +application-provided subset will be parsed, but the +<code>startDoctypeDeclHandler</code> and +<code>endDoctypeDeclHandler</code> functions, if set, will not be +called. The setting of parameter entity parsing, controlled using +<code><a href= "#XML_SetParamEntityParsing" +>XML_SetParamEntityParsing</a></code>, will be honored.</p> + +<p>The application-provided external subset is read by calling the +external entity reference handler set via <code><a href= +"#XML_SetExternalEntityRefHandler" +>XML_SetExternalEntityRefHandler</a></code> with both +<code>publicId</code> and <code>systemId</code> set to NULL.</p> + +<p>If this function is called after parsing has begun, it returns +<code>XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING</code> and ignores +<code>useDTD</code>. If called when Expat has been compiled without +DTD support, it returns +<code>XML_ERROR_FEATURE_REQUIRES_XML_DTD</code>. Otherwise, it +returns <code>XML_ERROR_NONE</code>.</p> +</div> + +<pre class="fcndec" id="XML_SetReturnNSTriplet"> void XML_SetReturnNSTriplet(XML_Parser parser, int do_nst); -</pre></a></div> +</pre> <div class="fcndef"> <p> This function only has an effect when using a parser created with -<a href="#XML_ParserCreateNS">XML_ParserCreateNS</a>, i.e. when namespace -processing is in effect. The <code>do_nst</code> sets whether or not prefixes -are returned with names qualified with a namespace prefix. If this function -is called with <code>do_nst</code> non-zero, then afterwards namespace -qualified names (that is qualified with a prefix as opposed to belonging -to a default namespace) are returned as a triplet with the three parts -separated by the namespace separator specified when the parser was created. -The order of returned parts is URI, local name, and prefix.</p> -<p>If <code>do_nst</code> is zero, then namespaces are reported in the -default manner, URI then local_name separated by the namespace separator.</p> +<code><a href= "#XML_ParserCreateNS" >XML_ParserCreateNS</a></code>, +i.e. when namespace processing is in effect. The <code>do_nst</code> +sets whether or not prefixes are returned with names qualified with a +namespace prefix. If this function is called with <code>do_nst</code> +non-zero, then afterwards namespace qualified names (that is qualified +with a prefix as opposed to belonging to a default namespace) are +returned as a triplet with the three parts separated by the namespace +separator specified when the parser was created. The order of +returned parts is URI, local name, and prefix.</p> <p>If +<code>do_nst</code> is zero, then namespaces are reported in the +default manner, URI then local_name separated by the namespace +separator.</p> </div> -<div class="fcndec"><a name="XML_ExpatVersion"><pre> +<pre class="fcndec" id="XML_DefaultCurrent"> +void +XML_DefaultCurrent(XML_Parser parser); +</pre> +<div class="fcndef"> +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 set by <code><a +href="#XML_SetDefaultHandler" >XML_SetDefaultHandler</a></code> or +<code><a href="#XML_SetDefaultHandlerExpand" +>XML_SetDefaultHandlerExpand</a></code>. It does nothing if there is +not a default handler. +</div> + +<pre class="fcndec" id="XML_ExpatVersion"> XML_LChar * XML_ExpatVersion(); -</pre></a></div> +</pre> <div class="fcndef"> -Return the library version as a string (e.g. "expat_1.95.1"). +Return the library version as a string (e.g. <code>"expat_1.95.1"</code>). </div> -<div class="fcndec"><a name="XML_ExpatVersionInfo"><pre> -struct XML_expat_version +<pre class="fcndec" id="XML_ExpatVersionInfo"> +struct XML_Expat_Version XML_ExpatVersionInfo(); -</pre></a></div> -<div class="fcndef"> -Return the library version information as a structure. -<div class="eg"><pre> +</pre> +<pre class="signature"> typedef struct { int major; int minor; int micro; } XML_Expat_Version; -</pre></div> +</pre> +<div class="fcndef"> +Return the library version information as a structure. Some macros are also defined that support compile-time tests of the library version: <ul> @@ -1542,7 +1768,129 @@ library version: Testing these constants is currently the best way to determine if particular parts of the Expat API are available. </div> + +<pre class="fcndec" id="XML_GetFeatureList"> +const XML_Feature * +XML_GetFeatureList(); +</pre> +<pre class="signature"> +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 +}; + +typedef struct { + enum XML_FeatureEnum feature; + XML_LChar *name; + long int value; +} XML_Feature; +</pre> +<div class="fcndef"> +<p>Returns a list of "feature" records, providing details on how +Expat was configured at compile time. Most applications should not +need to worry about this, but this information is otherwise not +available from Expat. This function allows code that does need to +check these features to do so at runtime.</p> + +<p>The return value is an array of <code>XML_Feature</code>, +terminated by a record with a <code>feature</code> of +<code>XML_FEATURE_END</code> and <code>name</code> of NULL, +identifying the feature-test macros Expat was compiled with. Since an +application that requires this kind of information needs to determine +the type of character the <code>name</code> points to, records for the +<code>XML_FEATURE_SIZEOF_XML_CHAR</code> and +<code>XML_FEATURE_SIZEOF_XML_LCHAR</code> will be located at the +beginning of the list, followed by <code>XML_FEATURE_UNICODE</code> +and <code>XML_FEATURE_UNICODE_WCHAR_T</code>, if they are present at +all.</p> + +<p>Some features have an associated value. If there isn't an +associated value, the <code>value</code> field is set to 0. At this +time, the following features have been defined to have values:</p> + +<dl> + <dt><code>XML_FEATURE_SIZEOF_XML_CHAR</code></dt> + <dd>The number of bytes occupied by one <code>XML_Char</code> + character.</dd> + <dt><code>XML_FEATURE_SIZEOF_XML_LCHAR</code></dt> + <dd>The number of bytes occupied by one <code>XML_LChar</code> + character.</dd> + <dt><code>XML_FEATURE_CONTEXT_BYTES</code></dt> + <dd>The maximum number of characters of context which can be + reported by <code><a href= "#XML_GetInputContext" + >XML_GetInputContext</a></code>.</dd> </dl> +</div> + +<pre class="fcndec" id="XML_FreeContentModel"> +void +XML_FreeContentModel(XML_Parser parser, XML_Content *model); +</pre> +<div class="fcndef"> +Function to deallocate the <code>model</code> argument passed to the +<code>XML_ElementDeclHandler</code> callback set using <code><a +href="#XML_SetElementDeclHandler" >XML_ElementDeclHandler</a></code>. +This function should not be used for any other purpose. +</div> + +<p>The following functions allow external code to share the memory +allocator an <code>XML_Parser</code> has been configured to use. This +is especially useful for third-party libraries that interact with a +parser object created by application code, or heavily layered +applications. This can be essential when using dynamically loaded +libraries which use different C standard libraries (this can happen on +Windows, at least).</p> + +<pre class="fcndec" id="XML_MemMalloc"> +void * +XML_MemMalloc(XML_Parser parser, size_t size); +</pre> +<div class="fcndef"> +Allocate <code>size</code> bytes of memory using the allocator the +<code>parser</code> object has been configured to use. Returns a +pointer to the memory or NULL on failure. Memory allocated in this +way must be freed using <code><a href="#XML_MemFree" +>XML_MemFree</a></code>. +</div> + +<pre class="fcndec" id="XML_MemRealloc"> +void * +XML_MemRealloc(XML_Parser parser, void *ptr, size_t size); +</pre> +<div class="fcndef"> +Allocate <code>size</code> bytes of memory using the allocator the +<code>parser</code> object has been configured to use. +<code>ptr</code> must point to a block of memory allocated by <code><a +href="#XML_MemMalloc" >XML_MemMalloc</a></code> or +<code>XML_MemRealloc</code>, or be NULL. This function tries to +expand the block pointed to by <code>ptr</code> if possible. Returns +a pointer to the memory or NULL on failure. On success, the original +block has either been expanded or freed. On failure, the original +block has not been freed; the caller is responsible for freeing the +original block. Memory allocated in this way must be freed using +<code><a href="#XML_MemFree" +>XML_MemFree</a></code>. +</div> + +<pre class="fcndec" id="XML_MemFree"> +void +XML_MemFree(XML_Parser parser, void *ptr); +</pre> +<div class="fcndef"> +Free a block of memory pointed to by <code>ptr</code>. The block must +have been allocated by <code><a href="#XML_MemMalloc" +>XML_MemMalloc</a></code> or <code>XML_MemRealloc</code>, or be NULL. +</div> +<hr /> +<p><a href="http://validator.w3.org/check/referer"><img + src="valid-xhtml10.png" alt="Valid XHTML 1.0!" + height="31" width="88" class="noborder" /></a></p> </body> </html> diff --git a/extras/expat/doc/style.css b/extras/expat/doc/style.css index 664a7bdfb..6f4886077 100644 --- a/extras/expat/doc/style.css +++ b/extras/expat/doc/style.css @@ -2,25 +2,29 @@ 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: 5%; + margin-left: 2em; margin-right: 10%; } .handler { width: 100%; border-top-width: thin; - margin-left: 5%; margin-bottom: 1em; } .handler p { - margin-left: 3%; + margin-left: 2em; } .setter { @@ -38,7 +42,7 @@ body { } .fcndef { - margin-left: 5%; + margin-left: 2em; margin-bottom: 2em; } diff --git a/extras/expat/doc/valid-xhtml10.png b/extras/expat/doc/valid-xhtml10.png Binary files differnew file mode 100644 index 000000000..2275ee6ea --- /dev/null +++ b/extras/expat/doc/valid-xhtml10.png diff --git a/extras/expat/doc/xmlwf.1 b/extras/expat/doc/xmlwf.1 index b2c561680..907d6c37b 100644 --- a/extras/expat/doc/xmlwf.1 +++ b/extras/expat/doc/xmlwf.1 @@ -3,7 +3,7 @@ .\" <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" "" "" +.TH "XMLWF" "1" "24 January 2003" "" "" .SH NAME xmlwf \- Determines if an XML document is well-formed .SH SYNOPSIS @@ -12,12 +12,13 @@ xmlwf \- Determines if an XML document is well-formed .SH "DESCRIPTION" .PP -\fBxmlwf\fR uses the Expat library to determine -if an XML document is well-formed. It is non-validating. +\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. +If you do not specify any files on the command-line, and you +have a recent version of \fBxmlwf\fR, the +input file will be read from standard input. .SH "WELL-FORMED DOCUMENTS" .PP A well-formed document must adhere to the @@ -26,7 +27,8 @@ following rules: \(bu The file begins with an XML declaration. For instance, <?xml version="1.0" standalone="yes"?>. -\fBNOTE:\fR xmlwf does not currently +\fBNOTE:\fR +\fBxmlwf\fR does not currently check for a valid XML declaration. .TP 0.2i \(bu @@ -48,33 +50,37 @@ 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). +\fBxmlwf\fR is a non-validating parser -- +it does not check the DTD. However, it does support +external entities (see the \fB-x\fR 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. +separately ("\fB-d\fR output") or concatenated with the +option ("\fB-d\fRoutput"). \fBxmlwf\fR +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 +If the input file is well-formed and \fBxmlwf\fR +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. +This implies no namespaces (turns off \fB-n\fR) and +requires \fB-d\fR 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 +By default, \fB-d\fR outputs a canonical representation (described below). -You can select different output formats using -c and -m. +You can select different output formats using \fB-c\fR +and \fB-m\fR. 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 +coming from standard input. 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 +file. Otherwise, \fBxmlwf\fR 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 @@ -86,36 +92,45 @@ 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: +any document encoding declaration. \fBxmlwf\fR +supports four built-in encodings: US-ASCII, UTF-8, UTF-16, and ISO-8859-1. -Also see the -w option. +Also see the \fB-w\fR 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. +Requires \fB-d\fR to specify an output file. .TP \fB-n\fR Turns on namespace processing. (describe namespaces) --c disables namespaces. +\fB-c\fR 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. +Normally \fBxmlwf\fR never parses parameter +entities. \fB-p\fR tells it to always parse them. +\fB-p\fR implies \fB-x\fR. .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. +Normally \fBxmlwf\fR memory-maps the XML file +before parsing; this can result in faster parsing on many +platforms. +\fB-r\fR turns off memory-mapping and uses normal file +IO calls instead. Of course, memory-mapping is automatically turned off -when reading from STDIN. +when reading from standard input. + +Use of memory-mapping can cause some platforms to report +substantially higher memory usage for +\fBxmlwf\fR, but this appears to be a matter of +the operating system reporting memory in a strange way; there is +not a leak in \fBxmlwf\fR. .TP \fB-s\fR Prints an error if the document is not standalone. @@ -127,17 +142,21 @@ 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, ...). +\fB-t\fR turns off most of the output options +(\fB-d\fR, \fB-m\fR, \fB-c\fR, +\&...). .TP \fB-v\fR -Prints the version of the Expat library being used, and then exits. +Prints the version of the Expat library being used, including some +information on the compile-time configuration of the library, 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. +Enables support for Windows code pages. +Normally, \fBxmlwf\fR will throw an error if it +runs across an encoding that it is not equipped to handle itself. With +\fB-w\fR, xmlwf will try to use a Windows code +page. See also \fB-e\fR. .TP \fB-x\fR Turns on parsing external entities. @@ -164,34 +183,48 @@ And here are some examples of external entities: .fi .TP \fB--\fR -For some reason, xmlwf specifically ignores "--" -anywhere it appears on the command line. +(Two hyphens.) +Terminates the list of options. This is only needed if a filename +starts with a hyphen. For example: + +.nf +xmlwf -- -myfile.xml +.fi + +will run \fBxmlwf\fR on the file +\fI-myfile.xml\fR. .PP -Older versions of xmlwf do not support reading from STDIN. +Older versions of \fBxmlwf\fR do not support +reading from standard input. .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. +If an input file is not well-formed, +\fBxmlwf\fR prints a single line describing +the problem to standard output. If a file is well formed, +\fBxmlwf\fR 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. +However, \fBxmlwf\fR 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. +\fBxmlwf\fR returns a 0 - noerr result, +even if the file is not well-formed. There is no good way for +a program to use \fBxmlwf\fR to quickly +check a file -- it must parse \fBxmlwf\fR's +standard output. .PP -The errors should go to STDERR, not stdout. +The errors should go to standard error, not standard output. .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. +There should be a way to get \fB-d\fR to send its +output to standard output 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. +I have no idea why anyone would want to use the +\fB-d\fR, \fB-c\fR, and +\fB-m\fR 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: @@ -201,3 +234,18 @@ 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 +.fi +.SH "SEE ALSO" +.PP + +.nf +The Expat home page: http://www.libexpat.org/ +The W3 XML specification: http://www.w3.org/TR/REC-xml +.fi +.SH "AUTHOR" +.PP +This manual page was written by Scott Bronson <bronson@rinspin.com> for +the Debian GNU/Linux system (but may be used by others). Permission is +granted to copy, distribute and/or modify this document under +the terms of the GNU Free Documentation +License, Version 1.1. diff --git a/extras/expat/doc/xmlwf.sgml b/extras/expat/doc/xmlwf.sgml index 648c9c46c..139c95e1f 100644 --- a/extras/expat/doc/xmlwf.sgml +++ b/extras/expat/doc/xmlwf.sgml @@ -79,14 +79,15 @@ manpage.1: manpage.sgml <title>DESCRIPTION</title> <para> - <command>&dhpackage;</command> uses the Expat library to determine - if an XML document is well-formed. It is non-validating. + <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. + If you do not specify any files on the command-line, and you + have a recent version of <command>&dhpackage;</command>, the + input file will be read from standard input. </para> </refsect1> @@ -103,7 +104,8 @@ manpage.1: manpage.sgml <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 + <emphasis>NOTE:</emphasis> + <command>&dhpackage;</command> does not currently check for a valid XML declaration. </para></listitem> <listitem><para> @@ -128,8 +130,9 @@ manpage.1: manpage.sgml <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). + <command>&dhpackage;</command> is a non-validating parser -- + it does not check the DTD. However, it does support + external entities (see the <option>-x</option> option). </para> </refsect1> @@ -138,7 +141,9 @@ manpage.1: manpage.sgml <para> When an option includes an argument, you may specify the argument either -separate ("d output") or mashed ("-doutput"). &dhpackage; supports both. +separately ("<option>-d</option> output") or concatenated with the +option ("<option>-d</option>output"). <command>&dhpackage;</command> +supports both. </para> <variablelist> @@ -147,11 +152,11 @@ separate ("d output") or mashed ("-doutput"). &dhpackage; supports both. <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 + If the input file is well-formed and <command>&dhpackage;</command> + 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. + This implies no namespaces (turns off <option>-n</option>) and + requires <option>-d</option> to specify an output file. </para> </listitem> </varlistentry> @@ -162,17 +167,18 @@ separate ("d output") or mashed ("-doutput"). &dhpackage; supports both. <para> Specifies a directory to contain transformed representations of the input files. - By default, -d outputs a canonical representation + By default, <option>-d</option> outputs a canonical representation (described below). - You can select different output formats using -c and -m. + You can select different output formats using <option>-c</option> + and <option>-m</option>. </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 + coming from standard input. 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 + file. Otherwise, <command>&dhpackage;</command> will delete the + input file before it generates the output file (just like running <literal>cat < file > file</literal> in most shells). </para> <para> @@ -191,13 +197,13 @@ separate ("d output") or mashed ("-doutput"). &dhpackage; supports both. <listitem> <para> Specifies the character encoding for the document, overriding - any document encoding declaration. &dhpackage; - has four built-in encodings: + any document encoding declaration. <command>&dhpackage;</command> + supports 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. + <literal>ISO-8859-1</literal>. + Also see the <option>-w</option> option. </para> </listitem> </varlistentry> @@ -208,7 +214,7 @@ separate ("d output") or mashed ("-doutput"). &dhpackage; supports both. <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. + Requires <option>-d</option> to specify an output file. </para> </listitem> </varlistentry> @@ -218,7 +224,7 @@ separate ("d output") or mashed ("-doutput"). &dhpackage; supports both. <listitem> <para> Turns on namespace processing. (describe namespaces) - -c disables namespaces. + <option>-c</option> disables namespaces. </para> </listitem> </varlistentry> @@ -231,9 +237,9 @@ separate ("d output") or mashed ("-doutput"). &dhpackage; supports both. entities. </para> <para> - Normally &dhpackage; never parses parameter entities. - -p tells it to always parse them. - -p implies -x. + Normally <command>&dhpackage;</command> never parses parameter + entities. <option>-p</option> tells it to always parse them. + <option>-p</option> implies <option>-x</option>. </para> </listitem> </varlistentry> @@ -242,11 +248,21 @@ separate ("d output") or mashed ("-doutput"). &dhpackage; supports both. <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. + Normally <command>&dhpackage;</command> memory-maps the XML file + before parsing; this can result in faster parsing on many + platforms. + <option>-r</option> turns off memory-mapping and uses normal file + IO calls instead. Of course, memory-mapping is automatically turned off - when reading from STDIN. + when reading from standard input. </para> + <para> + Use of memory-mapping can cause some platforms to report + substantially higher memory usage for + <command>&dhpackage;</command>, but this appears to be a matter of + the operating system reporting memory in a strange way; there is + not a leak in <command>&dhpackage;</command>. + </para> </listitem> </varlistentry> @@ -269,7 +285,9 @@ separate ("d output") or mashed ("-doutput"). &dhpackage; supports both. 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, ...). + <option>-t</option> turns off most of the output options + (<option>-d</option>, <option>-m</option>, <option>-c</option>, + ...). </para> </listitem> </varlistentry> @@ -278,7 +296,9 @@ separate ("d output") or mashed ("-doutput"). &dhpackage; supports both. <term><option>-v</option></term> <listitem> <para> - Prints the version of the Expat library being used, and then exits. + Prints the version of the Expat library being used, including some + information on the compile-time configuration of the library, and + then exits. </para> </listitem> </varlistentry> @@ -287,11 +307,11 @@ separate ("d output") or mashed ("-doutput"). &dhpackage; supports both. <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. + Enables support for Windows code pages. + Normally, <command>&dhpackage;</command> will throw an error if it + runs across an encoding that it is not equipped to handle itself. With + <option>-w</option>, &dhpackage; will try to use a Windows code + page. See also <option>-e</option>. </para> </listitem> </varlistentry> @@ -334,24 +354,34 @@ separate ("d output") or mashed ("-doutput"). &dhpackage; supports both. <term><option>--</option></term> <listitem> <para> - For some reason, &dhpackage; specifically ignores "--" - anywhere it appears on the command line. + (Two hyphens.) + Terminates the list of options. This is only needed if a filename + starts with a hyphen. For example: + </para> +<literallayout> +&dhpackage; -- -myfile.xml +</literallayout> + <para> + will run <command>&dhpackage;</command> on the file + <filename>-myfile.xml</filename>. </para> </listitem> </varlistentry> </variablelist> <para> - Older versions of &dhpackage; do not support reading from STDIN. + Older versions of <command>&dhpackage;</command> do not support + reading from standard input. </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. + If an input file is not well-formed, + <command>&dhpackage;</command> prints a single line describing + the problem to standard output. If a file is well formed, + <command>&dhpackage;</command> outputs nothing. Note that the result code is <emphasis>not</emphasis> set. </para> </refsect1> @@ -361,24 +391,28 @@ separate ("d output") or mashed ("-doutput"). &dhpackage; supports both. <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. + However, <command>&dhpackage;</command> 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. + <command>&dhpackage;</command> returns a 0 - noerr result, + even if the file is not well-formed. There is no good way for + a program to use <command>&dhpackage;</command> to quickly + check a file -- it must parse <command>&dhpackage;</command>'s + standard output. + </para> + <para> + The errors should go to standard error, not standard output. </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. + There should be a way to get <option>-d</option> to send its + output to standard output 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. + I have no idea why anyone would want to use the + <option>-d</option>, <option>-c</option>, and + <option>-m</option> options. If someone could explain it to + me, I'd like to add this information to this manpage. </para> </refsect1> @@ -392,7 +426,6 @@ 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> diff --git a/extras/expat/examples/elements.c b/extras/expat/examples/elements.c index 42f0889e7..4ed4da6a3 100644 --- a/extras/expat/examples/elements.c +++ b/extras/expat/examples/elements.c @@ -37,7 +37,7 @@ main(int argc, char *argv[]) do { size_t len = fread(buf, 1, sizeof(buf), stdin); done = len < sizeof(buf); - if (!XML_Parse(parser, buf, len, done)) { + if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) { fprintf(stderr, "%s at line %d\n", XML_ErrorString(XML_GetErrorCode(parser)), diff --git a/extras/expat/examples/outline.c b/extras/expat/examples/outline.c index 2eeca066c..10f6d1db5 100644 --- a/extras/expat/examples/outline.c +++ b/extras/expat/examples/outline.c @@ -76,7 +76,7 @@ main(int argc, char *argv[]) } done = feof(stdin); - if (! XML_Parse(p, Buff, len, done)) { + 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))); diff --git a/extras/expat/lib/ascii.h b/extras/expat/lib/ascii.h index 073e8a5fb..337e5bb7e 100644 --- a/extras/expat/lib/ascii.h +++ b/extras/expat/lib/ascii.h @@ -68,7 +68,7 @@ #define ASCII_9 0x39 #define ASCII_TAB 0x09 -#define ASCII_SPACE 0x20 +#define ASCII_SPACE 0x20 #define ASCII_EXCL 0x21 #define ASCII_QUOT 0x22 #define ASCII_AMP 0x26 diff --git a/extras/expat/lib/expat.h b/extras/expat/lib/expat.h index a92e7b7af..0b70302db 100644 --- a/extras/expat/lib/expat.h +++ b/extras/expat/lib/expat.h @@ -8,17 +8,21 @@ #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 +#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 XML_STATIC +#define XMLPARSEAPI(type) type __cdecl +#else #define XMLPARSEAPI(type) __declspec(dllimport) type __cdecl +#endif #else #define XMLPARSEAPI(type) type #endif @@ -28,11 +32,12 @@ extern "C" { #endif -#ifdef XML_UNICODE_WCHAR_T +#ifdef XML_UNICODE_WCHAR_T #define XML_UNICODE #endif -typedef void *XML_Parser; +struct XML_ParserStruct; +typedef struct XML_ParserStruct *XML_Parser; #ifdef XML_UNICODE /* Information is UTF-16 encoded. */ #ifdef XML_UNICODE_WCHAR_T @@ -47,6 +52,41 @@ 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, @@ -168,7 +208,7 @@ XMLPARSEAPI(XML_Parser) XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator); -/* Constructs a new parser using the memory management suit referred to +/* Constructs a new parser using the memory management suite 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 @@ -185,11 +225,13 @@ XML_ParserCreate_MM(const XML_Char *encoding, /* 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. + 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(int) +XMLPARSEAPI(XML_Bool) XML_ParserReset(XML_Parser parser, const XML_Char *encoding); /* atts is array of name/value pairs, terminated by 0; @@ -225,8 +267,8 @@ typedef void (*XML_EndCdataSectionHandler)(void *userData); (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. Line - boundaries are not normalized. Note that a byte order mark + 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 @@ -265,6 +307,9 @@ typedef void (*XML_EndDoctypeDeclHandler)(void *userData); 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, @@ -275,7 +320,7 @@ typedef void (*XML_EntityDeclHandler) (void *userData, const XML_Char *systemId, const XML_Char *publicId, const XML_Char *notationName); - + XMLPARSEAPI(void) XML_SetEntityDeclHandler(XML_Parser parser, XML_EntityDeclHandler handler); @@ -319,11 +364,14 @@ typedef void (*XML_StartNamespaceDeclHandler)(void *userData, typedef void (*XML_EndNamespaceDeclHandler)(void *userData, const XML_Char *prefix); -/* This is called if the document is not standalone (it has an +/* 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 + have standalone="yes". If this handler returns XML_STATUS_ERROR, + 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); @@ -351,10 +399,11 @@ typedef int (*XML_NotStandaloneHandler)(void *userData); 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. + context is NULL only when the entity is a parameter entity. - 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 + The handler should return XML_STATUS_ERROR 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, @@ -448,8 +497,8 @@ typedef struct { 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. + fill in the XML_Encoding structure, and return XML_STATUS_OK. + Otherwise it must return XML_STATUS_ERROR. If info does not describe a suitable encoding, then the parser will return an XML_UNKNOWN_ENCODING error. @@ -560,7 +609,7 @@ XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg); XMLPARSEAPI(void) XML_SetSkippedEntityHandler(XML_Parser parser, - XML_SkippedEntityHandler handler); + XML_SkippedEntityHandler handler); XMLPARSEAPI(void) XML_SetUnknownEncodingHandler(XML_Parser parser, @@ -581,8 +630,11 @@ XML_DefaultCurrent(XML_Parser parser); + 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 names + 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) @@ -596,10 +648,12 @@ XML_SetUserData(XML_Parser parser, void *userData); #define XML_GetUserData(parser) (*(void **)(parser)) /* This is equivalent to supplying an encoding argument to - XML_ParserCreate. It must not be called after XML_Parse or - XML_ParseBuffer. + 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 XML_STATUS_ERROR. */ -XMLPARSEAPI(int) +XMLPARSEAPI(enum XML_Status) XML_SetEncoding(XML_Parser parser, const XML_Char *encoding); /* If this function is called, then the parser will be passed as the @@ -609,15 +663,34 @@ XML_SetEncoding(XML_Parser parser, const XML_Char *encoding); 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. + argument will be copied. Returns XML_STATUS_ERROR if out of memory, + XML_STATUS_OK otherwise. */ -XMLPARSEAPI(int) +XMLPARSEAPI(enum XML_Status) XML_SetBase(XML_Parser parser, const XML_Char *base); XMLPARSEAPI(const XML_Char *) @@ -640,17 +713,39 @@ XML_GetSpecifiedAttributeCount(XML_Parser parser); XMLPARSEAPI(int) XML_GetIdAttributeIndex(XML_Parser parser); -/* Parses some input. Returns 0 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). -*/ -XMLPARSEAPI(int) +/* 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(int) +XMLPARSEAPI(enum XML_Status) XML_ParseBuffer(XML_Parser parser, int len, int isFinal); /* Creates an XML_Parser object that can parse an external general @@ -666,7 +761,7 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal); 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. + initialized from the parser argument. Returns NULL if out of memory. Otherwise returns a new XML_Parser object. */ XMLPARSEAPI(XML_Parser) @@ -695,58 +790,34 @@ enum XML_ParamEntityParsing { 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_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); -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 -}; - -/* If XML_Parse or XML_ParseBuffer have returned 0, then +/* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, 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. + location. They may be called from any callback called to report + some parse event; in this case the location is the location of + the first of the sequence of characters that generated the event. + + They may also be called after returning from a call to XML_Parse + or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then + the location is the location of the character at which the error + was detected; otherwise the location is the location of the last + parse event, as described above. */ XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser); XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser); @@ -778,13 +849,27 @@ XML_GetInputContext(XML_Parser parser, #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber #define XML_GetErrorByteIndex XML_GetCurrentByteIndex +/* Frees the content model passed to the element declaration handler */ +XMLPARSEAPI(void) +XML_FreeContentModel(XML_Parser parser, XML_Content *model); + +/* Exposing the memory handling functions used in Expat */ +XMLPARSEAPI(void *) +XML_MemMalloc(XML_Parser parser, size_t size); + +XMLPARSEAPI(void *) +XML_MemRealloc(XML_Parser parser, void *ptr, size_t size); + +XMLPARSEAPI(void) +XML_MemFree(XML_Parser parser, void *ptr); + /* 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(int code); +XML_ErrorString(enum XML_Error code); /* Return a string containing the version number of this expat */ XMLPARSEAPI(const XML_LChar *) @@ -802,6 +887,28 @@ typedef struct { 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; + const 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 @@ -810,7 +917,7 @@ XML_ExpatVersionInfo(void); */ #define XML_MAJOR_VERSION 1 #define XML_MINOR_VERSION 95 -#define XML_MICRO_VERSION 4 +#define XML_MICRO_VERSION 6 #ifdef __cplusplus } diff --git a/extras/expat/lib/internal.h b/extras/expat/lib/internal.h new file mode 100644 index 000000000..1bf6baa54 --- /dev/null +++ b/extras/expat/lib/internal.h @@ -0,0 +1,73 @@ +/* internal.h + + Internal definitions used by Expat. This is not needed to compile + client code. + + The following calling convention macros are defined for frequently + called functions: + + FASTCALL - Used for those internal functions that have a simple + body and a low number of arguments and local variables. + + PTRCALL - Used for functions called though function pointers. + + PTRFASTCALL - Like PTRCALL, but for low number of arguments. + + inline - Used for selected internal functions for which inlining + may improve performance on some platforms. + + Note: Use of these macros is based on judgement, not hard rules, + and therefore subject to change. +*/ + +#if defined(__GNUC__) +/* Instability reported with egcs on a RedHat Linux 7.3. + Let's comment it out: + #define FASTCALL __attribute__((stdcall, regparm(3))) + and let's try this: +*/ +#define FASTCALL __attribute__((regparm(3))) +#define PTRCALL +#define PTRFASTCALL __attribute__((regparm(3))) + +#elif defined(WIN32) +/* Using __fastcall seems to have an unexpected negative effect under + MS VC++, especially for function pointers, so we won't use it for + now on that platform. It may be reconsidered for a future release + if it can be made more effective. + Likely reason: __fastcall on Windows is like stdcall, therefore + the compiler cannot perform stack optimizations for call clusters. +*/ +#define FASTCALL +#define PTRCALL +#define PTRFASTCALL + +#endif + +#ifndef FASTCALL +#define FASTCALL +#endif + +#ifndef PTRCALL +#define PTRCALL +#endif + +#ifndef PTRFASTCALL +#define PTRFASTCALL +#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 diff --git a/extras/expat/lib/xmlparse.c b/extras/expat/lib/xmlparse.c index 95a2dba51..6e0fa1fc5 100644 --- a/extras/expat/lib/xmlparse.c +++ b/extras/expat/lib/xmlparse.c @@ -8,7 +8,7 @@ #ifdef COMPILED_FROM_DSP #include "winconfig.h" -#define XMLPARSEAPI(type) __declspec(dllexport) type __cdecl +#define XMLPARSEAPI(type) type __cdecl #include "expat.h" #undef XMLPARSEAPI @@ -22,7 +22,7 @@ #include <expat_config.h> #ifdef __declspec -#define XMLPARSEAPI(type) __declspec(dllexport) type __cdecl +#define XMLPARSEAPI(type) type __cdecl #endif #include "expat.h" @@ -90,6 +90,7 @@ typedef char ICHAR; #endif /* HAVE_BCOPY */ #endif /* HAVE_MEMMOVE */ +#include "internal.h" #include "xmltok.h" #include "xmlrole.h" @@ -104,7 +105,7 @@ typedef struct { size_t size; size_t used; size_t usedLim; - XML_Memory_Handling_Suite *mem; + const XML_Memory_Handling_Suite *mem; } HASH_TABLE; typedef struct { @@ -139,17 +140,31 @@ typedef struct { const XML_Char *str; const XML_Char *localPart; const XML_Char *prefix; + int strLen; int uriLen; int prefixLen; } TAG_NAME; +/* TAG represents an open element. + The name of the element is stored in both the document and API + encodings. The memory buffer 'buf' is a separately-allocated + memory area which stores the name. During the XML_Parse()/ + XMLParseBuffer() when the element is open, the memory for the 'raw' + version of the name (in the document encoding) is shared with the + document buffer. If the element is open across calls to + XML_Parse()/XML_ParseBuffer(), the buffer is re-allocated to + contain the 'raw' name as well. + + A parser re-uses these structures, maintaining a list of allocated + TAG objects in a free list. +*/ typedef struct tag { - struct tag *parent; - const char *rawName; + struct tag *parent; /* parent of this element */ + const char *rawName; /* tagName in the original encoding */ int rawNameLength; - TAG_NAME name; - char *buf; - char *bufEnd; + TAG_NAME name; /* tagName in the API encoding */ + char *buf; /* buffer for name components */ + char *bufEnd; /* end of the buffer */ BINDING *bindings; } TAG; @@ -161,9 +176,9 @@ typedef struct { const XML_Char *base; const XML_Char *publicId; const XML_Char *notation; - char open; - char is_param; - char is_internal; /* true if declared in internal subset outside any PE */ + XML_Bool open; + XML_Bool is_param; + XML_Bool is_internal; /* true if declared in internal subset outside PE */ } ENTITY; typedef struct { @@ -190,21 +205,21 @@ typedef struct { const XML_Char *end; XML_Char *ptr; XML_Char *start; - XML_Memory_Handling_Suite *mem; + const XML_Memory_Handling_Suite *mem; } STRING_POOL; /* The XML_Char before the name is used to determine whether -an attribute has been specified. */ + an attribute has been specified. */ typedef struct attribute_id { XML_Char *name; PREFIX *prefix; - char maybeTokenized; - char xmlns; + XML_Bool maybeTokenized; + XML_Bool xmlns; } ATTRIBUTE_ID; typedef struct { const ATTRIBUTE_ID *id; - char isCdata; + XML_Bool isCdata; const XML_Char *value; } DEFAULT_ATTRIBUTE; @@ -225,18 +240,19 @@ typedef struct { STRING_POOL pool; STRING_POOL entityValuePool; /* false once a parameter entity reference has been skipped */ - char keepProcessing; - /* indicates if external PE has been read */ - char paramEntityRead; - /* true once an internal or external PE has been read */ - char hasParamEntities; - char standalone; + XML_Bool keepProcessing; + /* true once an internal or external PE reference has been encountered; + this includes the reference to an external subset */ + XML_Bool hasParamEntityRefs; + XML_Bool standalone; #ifdef XML_DTD + /* indicates if external PE has been read */ + XML_Bool paramEntityRead; HASH_TABLE paramEntities; #endif /* XML_DTD */ PREFIX defaultPrefix; /* === scaffolding for building content model === */ - char in_eldecl; + XML_Bool in_eldecl; CONTENT_SCAFFOLD *scaffold; unsigned contentStringLen; unsigned scaffSize; @@ -252,10 +268,10 @@ typedef struct open_internal_entity { ENTITY *entity; } OPEN_INTERNAL_ENTITY; -typedef enum XML_Error Processor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr); +typedef enum XML_Error PTRCALL Processor(XML_Parser parser, + const char *start, + const char *end, + const char **endPtr); static Processor prologProcessor; static Processor prologInitProcessor; @@ -298,23 +314,22 @@ static enum XML_Error doIgnoreSection(XML_Parser parser, const ENCODING *, const char **startPtr, const char *end, const char **nextPtr); #endif /* XML_DTD */ + +static enum XML_Error +storeAtts(XML_Parser parser, const ENCODING *, const char *s, + TAG_NAME *tagNamePtr, BINDING **bindingsPtr); static enum XML_Error -storeAtts(XML_Parser parser, const ENCODING *, - const char *s, TAG_NAME *tagNamePtr, BINDING **bindingsPtr); -static int addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, const XML_Char *uri, BINDING **bindingsPtr); - static int defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, - int isCdata, int isId, const XML_Char *dfltValue, + XML_Bool isCdata, XML_Bool isId, const XML_Char *dfltValue, XML_Parser parser); - static enum XML_Error -storeAttributeValue(XML_Parser parser, const ENCODING *, int isCdata, +storeAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata, const char *, const char *, STRING_POOL *); static enum XML_Error -appendAttributeValue(XML_Parser parser, const ENCODING *, int isCdata, +appendAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata, const char *, const char *, STRING_POOL *); static ATTRIBUTE_ID * getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, @@ -334,52 +349,63 @@ static void reportDefault(XML_Parser parser, const ENCODING *enc, const char *start, const char *end); -static const XML_Char *getContext(XML_Parser parser); -static int setContext(XML_Parser parser, const XML_Char *context); -static void normalizePublicId(XML_Char *s); -static int dtdInit(DTD *, XML_Parser parser); - -static void dtdDestroy(DTD *, XML_Parser parser); - -static int dtdCopy(DTD *newDtd, const DTD *oldDtd, XML_Parser parser); - -static int copyEntityTable(HASH_TABLE *, STRING_POOL *, const HASH_TABLE *, - XML_Parser parser); - -#ifdef XML_DTD -static void dtdSwap(DTD *, DTD *); -#endif /* XML_DTD */ - -static NAMED *lookup(HASH_TABLE *table, KEY name, size_t createSize); +static const XML_Char * getContext(XML_Parser parser); +static XML_Bool +setContext(XML_Parser parser, const XML_Char *context); -static void hashTableInit(HASH_TABLE *, XML_Memory_Handling_Suite *ms); +static void FASTCALL normalizePublicId(XML_Char *s); -static void hashTableDestroy(HASH_TABLE *); -static void hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *); -static NAMED *hashTableIterNext(HASH_TABLE_ITER *); -static void poolInit(STRING_POOL *, XML_Memory_Handling_Suite *ms); -static void poolClear(STRING_POOL *); -static void poolDestroy(STRING_POOL *); -static XML_Char *poolAppend(STRING_POOL *pool, const ENCODING *enc, - const char *ptr, const char *end); -static XML_Char *poolStoreString(STRING_POOL *pool, const ENCODING *enc, - const char *ptr, const char *end); - -static int poolGrow(STRING_POOL *pool); - -static int nextScaffoldPart(XML_Parser parser); -static XML_Content *build_model(XML_Parser parser); +static DTD * dtdCreate(const XML_Memory_Handling_Suite *ms); +/* do not call if parentParser != NULL */ +static void dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms); +static void +dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms); +static int +dtdCopy(DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms); +static int +copyEntityTable(HASH_TABLE *, STRING_POOL *, const HASH_TABLE *); -static const XML_Char *poolCopyString(STRING_POOL *pool, const XML_Char *s); -static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s, - int n); -static const XML_Char *poolAppendString(STRING_POOL *pool, const XML_Char *s); -static ELEMENT_TYPE * getElementType(XML_Parser Paraser, - const ENCODING *enc, - const char *ptr, - const char *end); +static NAMED * +lookup(HASH_TABLE *table, KEY name, size_t createSize); +static void FASTCALL +hashTableInit(HASH_TABLE *, const XML_Memory_Handling_Suite *ms); +static void FASTCALL hashTableClear(HASH_TABLE *); +static void FASTCALL hashTableDestroy(HASH_TABLE *); +static void FASTCALL +hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *); +static NAMED * FASTCALL hashTableIterNext(HASH_TABLE_ITER *); + +static void FASTCALL +poolInit(STRING_POOL *, const XML_Memory_Handling_Suite *ms); +static void FASTCALL poolClear(STRING_POOL *); +static void FASTCALL poolDestroy(STRING_POOL *); +static XML_Char * +poolAppend(STRING_POOL *pool, const ENCODING *enc, + const char *ptr, const char *end); +static XML_Char * +poolStoreString(STRING_POOL *pool, const ENCODING *enc, + const char *ptr, const char *end); +static XML_Bool FASTCALL poolGrow(STRING_POOL *pool); +static const XML_Char * FASTCALL +poolCopyString(STRING_POOL *pool, const XML_Char *s); +static const XML_Char * +poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n); +static const XML_Char * FASTCALL +poolAppendString(STRING_POOL *pool, const XML_Char *s); -static int parserInit(XML_Parser parser, const XML_Char *encodingName); +static int FASTCALL nextScaffoldPart(XML_Parser parser); +static XML_Content * build_model(XML_Parser parser); +static ELEMENT_TYPE * +getElementType(XML_Parser parser, const ENCODING *enc, + const char *ptr, const char *end); + +static XML_Parser +parserCreate(const XML_Char *encodingName, + const XML_Memory_Handling_Suite *memsuite, + const XML_Char *nameSep, + DTD *dtd); +static void +parserInit(XML_Parser parser, const XML_Char *encodingName); #define poolStart(pool) ((pool)->start) #define poolEnd(pool) ((pool)->ptr) @@ -393,13 +419,13 @@ static int parserInit(XML_Parser parser, const XML_Char *encodingName); ? 0 \ : ((*((pool)->ptr)++ = c), 1)) -typedef struct { +struct XML_ParserStruct { /* The first member must be userData so that the XML_GetUserData macro works. */ void *m_userData; void *m_handlerArg; char *m_buffer; - XML_Memory_Handling_Suite m_mem; + const XML_Memory_Handling_Suite m_mem; /* first character to be parsed */ const char *m_bufferPtr; /* past last character to be parsed */ @@ -426,7 +452,7 @@ typedef struct { XML_EndNamespaceDeclHandler m_endNamespaceDeclHandler; XML_NotStandaloneHandler m_notStandaloneHandler; XML_ExternalEntityRefHandler m_externalEntityRefHandler; - void *m_externalEntityRefHandlerArg; + XML_Parser m_externalEntityRefHandlerArg; XML_SkippedEntityHandler m_skippedEntityHandler; XML_UnknownEncodingHandler m_unknownEncodingHandler; XML_ElementDeclHandler m_elementDeclHandler; @@ -437,8 +463,8 @@ typedef struct { INIT_ENCODING m_initEncoding; const ENCODING *m_internalEncoding; const XML_Char *m_protocolEncodingName; - int m_ns; - int m_ns_triplets; + XML_Bool m_ns; + XML_Bool m_ns_triplets; void *m_unknownEncodingMem; void *m_unknownEncodingData; void *m_unknownEncodingHandlerData; @@ -450,7 +476,7 @@ typedef struct { const char *m_eventEndPtr; const char *m_positionPtr; OPEN_INTERNAL_ENTITY *m_openInternalEntities; - int m_defaultExpandInternalEntities; + XML_Bool m_defaultExpandInternalEntities; int m_tagLevel; ENTITY *m_declEntity; const XML_Char *m_doctypeName; @@ -461,9 +487,9 @@ typedef struct { const XML_Char *m_declNotationPublicId; ELEMENT_TYPE *m_declElementType; ATTRIBUTE_ID *m_declAttributeId; - char m_declAttributeIsCdata; - char m_declAttributeIsId; - DTD m_dtd; + XML_Bool m_declAttributeIsCdata; + XML_Bool m_declAttributeIsId; + DTD *m_dtd; const XML_Char *m_curBase; TAG *m_tagStack; TAG *m_freeTagList; @@ -481,118 +507,122 @@ typedef struct { XML_Char m_namespaceSeparator; XML_Parser m_parentParser; #ifdef XML_DTD - int m_isParamEntity; + XML_Bool m_isParamEntity; + XML_Bool m_useForeignDTD; enum XML_ParamEntityParsing m_paramEntityParsing; #endif -} Parser; - -#define MALLOC(s) (((Parser *)parser)->m_mem.malloc_fcn((s))) -#define REALLOC(p,s) (((Parser *)parser)->m_mem.realloc_fcn((p),(s))) -#define FREE(p) (((Parser *)parser)->m_mem.free_fcn((p))) - -#define userData (((Parser *)parser)->m_userData) -#define handlerArg (((Parser *)parser)->m_handlerArg) -#define startElementHandler (((Parser *)parser)->m_startElementHandler) -#define endElementHandler (((Parser *)parser)->m_endElementHandler) -#define characterDataHandler (((Parser *)parser)->m_characterDataHandler) -#define processingInstructionHandler (((Parser *)parser)->m_processingInstructionHandler) -#define commentHandler (((Parser *)parser)->m_commentHandler) -#define startCdataSectionHandler (((Parser *)parser)->m_startCdataSectionHandler) -#define endCdataSectionHandler (((Parser *)parser)->m_endCdataSectionHandler) -#define defaultHandler (((Parser *)parser)->m_defaultHandler) -#define startDoctypeDeclHandler (((Parser *)parser)->m_startDoctypeDeclHandler) -#define endDoctypeDeclHandler (((Parser *)parser)->m_endDoctypeDeclHandler) -#define unparsedEntityDeclHandler (((Parser *)parser)->m_unparsedEntityDeclHandler) -#define notationDeclHandler (((Parser *)parser)->m_notationDeclHandler) -#define startNamespaceDeclHandler (((Parser *)parser)->m_startNamespaceDeclHandler) -#define endNamespaceDeclHandler (((Parser *)parser)->m_endNamespaceDeclHandler) -#define notStandaloneHandler (((Parser *)parser)->m_notStandaloneHandler) -#define externalEntityRefHandler (((Parser *)parser)->m_externalEntityRefHandler) -#define externalEntityRefHandlerArg (((Parser *)parser)->m_externalEntityRefHandlerArg) -#define internalEntityRefHandler (((Parser *)parser)->m_internalEntityRefHandler) -#define skippedEntityHandler (((Parser *)parser)->m_skippedEntityHandler) -#define unknownEncodingHandler (((Parser *)parser)->m_unknownEncodingHandler) -#define elementDeclHandler (((Parser *)parser)->m_elementDeclHandler) -#define attlistDeclHandler (((Parser *)parser)->m_attlistDeclHandler) -#define entityDeclHandler (((Parser *)parser)->m_entityDeclHandler) -#define xmlDeclHandler (((Parser *)parser)->m_xmlDeclHandler) -#define encoding (((Parser *)parser)->m_encoding) -#define initEncoding (((Parser *)parser)->m_initEncoding) -#define internalEncoding (((Parser *)parser)->m_internalEncoding) -#define unknownEncodingMem (((Parser *)parser)->m_unknownEncodingMem) -#define unknownEncodingData (((Parser *)parser)->m_unknownEncodingData) +}; + +#define MALLOC(s) (parser->m_mem.malloc_fcn((s))) +#define REALLOC(p,s) (parser->m_mem.realloc_fcn((p),(s))) +#define FREE(p) (parser->m_mem.free_fcn((p))) + +#define userData (parser->m_userData) +#define handlerArg (parser->m_handlerArg) +#define startElementHandler (parser->m_startElementHandler) +#define endElementHandler (parser->m_endElementHandler) +#define characterDataHandler (parser->m_characterDataHandler) +#define processingInstructionHandler \ + (parser->m_processingInstructionHandler) +#define commentHandler (parser->m_commentHandler) +#define startCdataSectionHandler \ + (parser->m_startCdataSectionHandler) +#define endCdataSectionHandler (parser->m_endCdataSectionHandler) +#define defaultHandler (parser->m_defaultHandler) +#define startDoctypeDeclHandler (parser->m_startDoctypeDeclHandler) +#define endDoctypeDeclHandler (parser->m_endDoctypeDeclHandler) +#define unparsedEntityDeclHandler \ + (parser->m_unparsedEntityDeclHandler) +#define notationDeclHandler (parser->m_notationDeclHandler) +#define startNamespaceDeclHandler \ + (parser->m_startNamespaceDeclHandler) +#define endNamespaceDeclHandler (parser->m_endNamespaceDeclHandler) +#define notStandaloneHandler (parser->m_notStandaloneHandler) +#define externalEntityRefHandler \ + (parser->m_externalEntityRefHandler) +#define externalEntityRefHandlerArg \ + (parser->m_externalEntityRefHandlerArg) +#define internalEntityRefHandler \ + (parser->m_internalEntityRefHandler) +#define skippedEntityHandler (parser->m_skippedEntityHandler) +#define unknownEncodingHandler (parser->m_unknownEncodingHandler) +#define elementDeclHandler (parser->m_elementDeclHandler) +#define attlistDeclHandler (parser->m_attlistDeclHandler) +#define entityDeclHandler (parser->m_entityDeclHandler) +#define xmlDeclHandler (parser->m_xmlDeclHandler) +#define encoding (parser->m_encoding) +#define initEncoding (parser->m_initEncoding) +#define internalEncoding (parser->m_internalEncoding) +#define unknownEncodingMem (parser->m_unknownEncodingMem) +#define unknownEncodingData (parser->m_unknownEncodingData) #define unknownEncodingHandlerData \ - (((Parser *)parser)->m_unknownEncodingHandlerData) -#define unknownEncodingRelease (((Parser *)parser)->m_unknownEncodingRelease) -#define protocolEncodingName (((Parser *)parser)->m_protocolEncodingName) -#define ns (((Parser *)parser)->m_ns) -#define ns_triplets (((Parser *)parser)->m_ns_triplets) -#define prologState (((Parser *)parser)->m_prologState) -#define processor (((Parser *)parser)->m_processor) -#define errorCode (((Parser *)parser)->m_errorCode) -#define eventPtr (((Parser *)parser)->m_eventPtr) -#define eventEndPtr (((Parser *)parser)->m_eventEndPtr) -#define positionPtr (((Parser *)parser)->m_positionPtr) -#define position (((Parser *)parser)->m_position) -#define openInternalEntities (((Parser *)parser)->m_openInternalEntities) -#define defaultExpandInternalEntities (((Parser *)parser)->m_defaultExpandInternalEntities) -#define tagLevel (((Parser *)parser)->m_tagLevel) -#define buffer (((Parser *)parser)->m_buffer) -#define bufferPtr (((Parser *)parser)->m_bufferPtr) -#define bufferEnd (((Parser *)parser)->m_bufferEnd) -#define parseEndByteIndex (((Parser *)parser)->m_parseEndByteIndex) -#define parseEndPtr (((Parser *)parser)->m_parseEndPtr) -#define bufferLim (((Parser *)parser)->m_bufferLim) -#define dataBuf (((Parser *)parser)->m_dataBuf) -#define dataBufEnd (((Parser *)parser)->m_dataBufEnd) -#define dtd (((Parser *)parser)->m_dtd) -#define curBase (((Parser *)parser)->m_curBase) -#define declEntity (((Parser *)parser)->m_declEntity) -#define doctypeName (((Parser *)parser)->m_doctypeName) -#define doctypeSysid (((Parser *)parser)->m_doctypeSysid) -#define doctypePubid (((Parser *)parser)->m_doctypePubid) -#define declAttributeType (((Parser *)parser)->m_declAttributeType) -#define declNotationName (((Parser *)parser)->m_declNotationName) -#define declNotationPublicId (((Parser *)parser)->m_declNotationPublicId) -#define declElementType (((Parser *)parser)->m_declElementType) -#define declAttributeId (((Parser *)parser)->m_declAttributeId) -#define declAttributeIsCdata (((Parser *)parser)->m_declAttributeIsCdata) -#define declAttributeIsId (((Parser *)parser)->m_declAttributeIsId) -#define freeTagList (((Parser *)parser)->m_freeTagList) -#define freeBindingList (((Parser *)parser)->m_freeBindingList) -#define inheritedBindings (((Parser *)parser)->m_inheritedBindings) -#define tagStack (((Parser *)parser)->m_tagStack) -#define atts (((Parser *)parser)->m_atts) -#define attsSize (((Parser *)parser)->m_attsSize) -#define nSpecifiedAtts (((Parser *)parser)->m_nSpecifiedAtts) -#define idAttIndex (((Parser *)parser)->m_idAttIndex) -#define tempPool (((Parser *)parser)->m_tempPool) -#define temp2Pool (((Parser *)parser)->m_temp2Pool) -#define groupConnector (((Parser *)parser)->m_groupConnector) -#define groupSize (((Parser *)parser)->m_groupSize) -#define namespaceSeparator (((Parser *)parser)->m_namespaceSeparator) -#define parentParser (((Parser *)parser)->m_parentParser) + (parser->m_unknownEncodingHandlerData) +#define unknownEncodingRelease (parser->m_unknownEncodingRelease) +#define protocolEncodingName (parser->m_protocolEncodingName) +#define ns (parser->m_ns) +#define ns_triplets (parser->m_ns_triplets) +#define prologState (parser->m_prologState) +#define processor (parser->m_processor) +#define errorCode (parser->m_errorCode) +#define eventPtr (parser->m_eventPtr) +#define eventEndPtr (parser->m_eventEndPtr) +#define positionPtr (parser->m_positionPtr) +#define position (parser->m_position) +#define openInternalEntities (parser->m_openInternalEntities) +#define defaultExpandInternalEntities \ + (parser->m_defaultExpandInternalEntities) +#define tagLevel (parser->m_tagLevel) +#define buffer (parser->m_buffer) +#define bufferPtr (parser->m_bufferPtr) +#define bufferEnd (parser->m_bufferEnd) +#define parseEndByteIndex (parser->m_parseEndByteIndex) +#define parseEndPtr (parser->m_parseEndPtr) +#define bufferLim (parser->m_bufferLim) +#define dataBuf (parser->m_dataBuf) +#define dataBufEnd (parser->m_dataBufEnd) +#define _dtd (parser->m_dtd) +#define curBase (parser->m_curBase) +#define declEntity (parser->m_declEntity) +#define doctypeName (parser->m_doctypeName) +#define doctypeSysid (parser->m_doctypeSysid) +#define doctypePubid (parser->m_doctypePubid) +#define declAttributeType (parser->m_declAttributeType) +#define declNotationName (parser->m_declNotationName) +#define declNotationPublicId (parser->m_declNotationPublicId) +#define declElementType (parser->m_declElementType) +#define declAttributeId (parser->m_declAttributeId) +#define declAttributeIsCdata (parser->m_declAttributeIsCdata) +#define declAttributeIsId (parser->m_declAttributeIsId) +#define freeTagList (parser->m_freeTagList) +#define freeBindingList (parser->m_freeBindingList) +#define inheritedBindings (parser->m_inheritedBindings) +#define tagStack (parser->m_tagStack) +#define atts (parser->m_atts) +#define attsSize (parser->m_attsSize) +#define nSpecifiedAtts (parser->m_nSpecifiedAtts) +#define idAttIndex (parser->m_idAttIndex) +#define tempPool (parser->m_tempPool) +#define temp2Pool (parser->m_temp2Pool) +#define groupConnector (parser->m_groupConnector) +#define groupSize (parser->m_groupSize) +#define namespaceSeparator (parser->m_namespaceSeparator) +#define parentParser (parser->m_parentParser) #ifdef XML_DTD -#define isParamEntity (((Parser *)parser)->m_isParamEntity) -#define paramEntityParsing (((Parser *)parser)->m_paramEntityParsing) +#define isParamEntity (parser->m_isParamEntity) +#define useForeignDTD (parser->m_useForeignDTD) +#define paramEntityParsing (parser->m_paramEntityParsing) #endif /* XML_DTD */ -#ifdef COMPILED_FROM_DSP -BOOL WINAPI -DllMain(HINSTANCE h, DWORD r, LPVOID p) { - return TRUE; -} -#endif /* def COMPILED_FROM_DSP */ - -#ifdef _MSC_VER -#ifdef _DEBUG -Parser * -asParser(XML_Parser parser) -{ - return parser; -} -#endif -#endif +#define parsing \ + (parentParser \ + ? \ + (isParamEntity \ + ? \ + (processor != externalParEntInitProcessor) \ + : \ + (processor != externalEntityInitProcessor)) \ + : \ + (processor != prologInitProcessor)) XML_Parser XML_ParserCreate(const XML_Char *encodingName) @@ -608,24 +638,45 @@ XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) return XML_ParserCreate_MM(encodingName, NULL, tmp); } +static const XML_Char implicitContext[] = { + 'x', 'm', 'l', '=', 'h', 't', 't', 'p', ':', '/', '/', + 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', + 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', + 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' +}; + XML_Parser XML_ParserCreate_MM(const XML_Char *encodingName, const XML_Memory_Handling_Suite *memsuite, - const XML_Char *nameSep) { - XML_Parser parser; - static const XML_Char implicitContext[] = { - 'x', 'm', 'l', '=', 'h', 't', 't', 'p', ':', '/', '/', - 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', - 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', - 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' - }; + const XML_Char *nameSep) +{ + XML_Parser parser = parserCreate(encodingName, memsuite, nameSep, NULL); + if (parser != NULL && ns) { + /* implicit context only set for root parser, since child + parsers (i.e. external entity parsers) will inherit it + */ + if (!setContext(parser, implicitContext)) { + XML_ParserFree(parser); + return NULL; + } + } + return parser; +} +static XML_Parser +parserCreate(const XML_Char *encodingName, + const XML_Memory_Handling_Suite *memsuite, + const XML_Char *nameSep, + DTD *dtd) +{ + XML_Parser parser; if (memsuite) { XML_Memory_Handling_Suite *mtemp; - parser = memsuite->malloc_fcn(sizeof(Parser)); + parser = (XML_Parser) + memsuite->malloc_fcn(sizeof(struct XML_ParserStruct)); if (parser != NULL) { - mtemp = &(((Parser *) parser)->m_mem); + mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem); mtemp->malloc_fcn = memsuite->malloc_fcn; mtemp->realloc_fcn = memsuite->realloc_fcn; mtemp->free_fcn = memsuite->free_fcn; @@ -633,9 +684,9 @@ XML_ParserCreate_MM(const XML_Char *encodingName, } else { XML_Memory_Handling_Suite *mtemp; - parser = malloc(sizeof(Parser)); + parser = (XML_Parser)malloc(sizeof(struct XML_ParserStruct)); if (parser != NULL) { - mtemp = &(((Parser *) parser)->m_mem); + mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem); mtemp->malloc_fcn = malloc; mtemp->realloc_fcn = realloc; mtemp->free_fcn = free; @@ -649,43 +700,57 @@ XML_ParserCreate_MM(const XML_Char *encodingName, bufferLim = NULL; attsSize = INIT_ATTS_SIZE; - atts = MALLOC(attsSize * sizeof(ATTRIBUTE)); + atts = (ATTRIBUTE *)MALLOC(attsSize * sizeof(ATTRIBUTE)); if (atts == NULL) { FREE(parser); return NULL; } - dataBuf = MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char)); + dataBuf = (XML_Char *)MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char)); if (dataBuf == NULL) { FREE(atts); FREE(parser); return NULL; } dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE; + + if (dtd) + _dtd = dtd; + else { + _dtd = dtdCreate(&parser->m_mem); + if (_dtd == NULL) { + FREE(dataBuf); + FREE(atts); + FREE(parser); + return NULL; + } + } + freeBindingList = NULL; - inheritedBindings = NULL; freeTagList = NULL; + groupSize = 0; + groupConnector = NULL; + + unknownEncodingHandler = NULL; + unknownEncodingHandlerData = NULL; + namespaceSeparator = '!'; - ns = 0; - ns_triplets = 0; - poolInit(&tempPool, &(((Parser *) parser)->m_mem)); - poolInit(&temp2Pool, &(((Parser *) parser)->m_mem)); + ns = XML_FALSE; + ns_triplets = XML_FALSE; + + poolInit(&tempPool, &(parser->m_mem)); + poolInit(&temp2Pool, &(parser->m_mem)); + parserInit(parser, encodingName); - if (!parserInit(parser, encodingName) || !atts - || !dataBuf || (encodingName && !protocolEncodingName)) { + if (encodingName && !protocolEncodingName) { XML_ParserFree(parser); return NULL; } if (nameSep) { - ns = 1; + ns = XML_TRUE; internalEncoding = XmlGetInternalEncodingNS(); namespaceSeparator = *nameSep; - - if (!setContext(parser, implicitContext)) { - XML_ParserFree(parser); - return NULL; - } } else { internalEncoding = XmlGetInternalEncoding(); @@ -694,7 +759,7 @@ XML_ParserCreate_MM(const XML_Char *encodingName, return parser; } -static int +static void parserInit(XML_Parser parser, const XML_Char *encodingName) { processor = prologInitProcessor; @@ -724,7 +789,6 @@ parserInit(XML_Parser parser, const XML_Char *encodingName) externalEntityRefHandler = NULL; externalEntityRefHandlerArg = parser; skippedEntityHandler = NULL; - unknownEncodingHandler = NULL; elementDeclHandler = NULL; attlistDeclHandler = NULL; entityDeclHandler = NULL; @@ -742,57 +806,87 @@ parserInit(XML_Parser parser, const XML_Char *encodingName) declAttributeType = NULL; declNotationName = NULL; declNotationPublicId = NULL; - declAttributeIsCdata = 0; - declAttributeIsId = 0; + declAttributeIsCdata = XML_FALSE; + declAttributeIsId = XML_FALSE; memset(&position, 0, sizeof(POSITION)); errorCode = XML_ERROR_NONE; eventPtr = NULL; eventEndPtr = NULL; positionPtr = NULL; openInternalEntities = 0; - defaultExpandInternalEntities = 1; + defaultExpandInternalEntities = XML_TRUE; tagLevel = 0; - tagStack = 0; + tagStack = NULL; + inheritedBindings = NULL; nSpecifiedAtts = 0; - groupSize = 0; - groupConnector = NULL; unknownEncodingMem = NULL; unknownEncodingRelease = NULL; unknownEncodingData = NULL; - unknownEncodingHandlerData = NULL; parentParser = NULL; #ifdef XML_DTD - isParamEntity = 0; + isParamEntity = XML_FALSE; + useForeignDTD = XML_FALSE; paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; - return dtdInit(&dtd, parser); -#else - return 1; #endif } -int +/* moves list of bindings to freeBindingList */ +static void FASTCALL +moveToFreeBindingList(XML_Parser parser, BINDING *bindings) +{ + while (bindings) { + BINDING *b = bindings; + bindings = bindings->nextTagBinding; + b->nextTagBinding = freeBindingList; + freeBindingList = b; + } +} + +XML_Bool XML_ParserReset(XML_Parser parser, const XML_Char *encodingName) { - if (parentParser) return 0; -#ifdef XML_DTD - if (dtd.scaffold) dtdDestroy(&dtd, parser); -#endif + TAG *tStk; + if (parentParser) + return XML_FALSE; + /* move tagStack to freeTagList */ + tStk = tagStack; + while (tStk) { + TAG *tag = tStk; + tStk = tStk->parent; + tag->parent = freeTagList; + moveToFreeBindingList(parser, tag->bindings); + tag->bindings = NULL; + freeTagList = tag; + } + moveToFreeBindingList(parser, inheritedBindings); + if (unknownEncodingMem) + FREE(unknownEncodingMem); + if (unknownEncodingRelease) + unknownEncodingRelease(unknownEncodingData); poolClear(&tempPool); poolClear(&temp2Pool); - return parserInit(parser, encodingName); + parserInit(parser, encodingName); + dtdReset(_dtd, &parser->m_mem); + return setContext(parser, implicitContext); } -int +enum XML_Status XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName) { + /* Block after XML_Parse()/XML_ParseBuffer() has been called. + XXX There's no way for the caller to determine which of the + XXX possible error cases caused the XML_STATUS_ERROR return. + */ + if (parsing) + return XML_STATUS_ERROR; if (encodingName == NULL) protocolEncodingName = NULL; else { protocolEncodingName = poolCopyString(&tempPool, encodingName); if (!protocolEncodingName) - return 0; + return XML_STATUS_ERROR; } - return 1; + return XML_STATUS_OK; } XML_Parser @@ -801,23 +895,32 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, const XML_Char *encodingName) { XML_Parser parser = oldParser; - DTD *oldDtd = &dtd; + DTD *newDtd = NULL; + DTD *oldDtd = _dtd; XML_StartElementHandler oldStartElementHandler = startElementHandler; XML_EndElementHandler oldEndElementHandler = endElementHandler; XML_CharacterDataHandler oldCharacterDataHandler = characterDataHandler; - XML_ProcessingInstructionHandler oldProcessingInstructionHandler = processingInstructionHandler; + XML_ProcessingInstructionHandler oldProcessingInstructionHandler + = processingInstructionHandler; XML_CommentHandler oldCommentHandler = commentHandler; - XML_StartCdataSectionHandler oldStartCdataSectionHandler = startCdataSectionHandler; - XML_EndCdataSectionHandler oldEndCdataSectionHandler = endCdataSectionHandler; + XML_StartCdataSectionHandler oldStartCdataSectionHandler + = startCdataSectionHandler; + XML_EndCdataSectionHandler oldEndCdataSectionHandler + = endCdataSectionHandler; XML_DefaultHandler oldDefaultHandler = defaultHandler; - XML_UnparsedEntityDeclHandler oldUnparsedEntityDeclHandler = unparsedEntityDeclHandler; + XML_UnparsedEntityDeclHandler oldUnparsedEntityDeclHandler + = unparsedEntityDeclHandler; XML_NotationDeclHandler oldNotationDeclHandler = notationDeclHandler; - XML_StartNamespaceDeclHandler oldStartNamespaceDeclHandler = startNamespaceDeclHandler; - XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler = endNamespaceDeclHandler; + XML_StartNamespaceDeclHandler oldStartNamespaceDeclHandler + = startNamespaceDeclHandler; + XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler + = endNamespaceDeclHandler; XML_NotStandaloneHandler oldNotStandaloneHandler = notStandaloneHandler; - XML_ExternalEntityRefHandler oldExternalEntityRefHandler = externalEntityRefHandler; + XML_ExternalEntityRefHandler oldExternalEntityRefHandler + = externalEntityRefHandler; XML_SkippedEntityHandler oldSkippedEntityHandler = skippedEntityHandler; - XML_UnknownEncodingHandler oldUnknownEncodingHandler = unknownEncodingHandler; + XML_UnknownEncodingHandler oldUnknownEncodingHandler + = unknownEncodingHandler; XML_ElementDeclHandler oldElementDeclHandler = elementDeclHandler; XML_AttlistDeclHandler oldAttlistDeclHandler = attlistDeclHandler; XML_EntityDeclHandler oldEntityDeclHandler = entityDeclHandler; @@ -826,24 +929,31 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, void *oldUserData = userData; void *oldHandlerArg = handlerArg; - int oldDefaultExpandInternalEntities = defaultExpandInternalEntities; - void *oldExternalEntityRefHandlerArg = externalEntityRefHandlerArg; + XML_Bool oldDefaultExpandInternalEntities = defaultExpandInternalEntities; + XML_Parser oldExternalEntityRefHandlerArg = externalEntityRefHandlerArg; #ifdef XML_DTD - int oldParamEntityParsing = paramEntityParsing; + enum XML_ParamEntityParsing oldParamEntityParsing = paramEntityParsing; int oldInEntityValue = prologState.inEntityValue; #endif - int oldns_triplets = ns_triplets; + XML_Bool oldns_triplets = ns_triplets; +#ifdef XML_DTD + if (!context) + newDtd = oldDtd; +#endif /* XML_DTD */ + + /* Note that the magical uses of the pre-processor to make field + access look more like C++ require that `parser' be overwritten + here. This makes this function more painful to follow than it + would be otherwise. + */ if (ns) { XML_Char tmp[2]; - *tmp = namespaceSeparator; - parser = XML_ParserCreate_MM(encodingName, &((Parser *)parser)->m_mem, - tmp); + parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd); } else { - parser = XML_ParserCreate_MM(encodingName, &((Parser *)parser)->m_mem, - NULL); + parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd); } if (!parser) @@ -885,7 +995,8 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, prologState.inEntityValue = oldInEntityValue; if (context) { #endif /* XML_DTD */ - if (!dtdCopy(&dtd, oldDtd, parser) || !setContext(parser, context)) { + if (!dtdCopy(_dtd, oldDtd, &parser->m_mem) + || !setContext(parser, context)) { XML_ParserFree(parser); return NULL; } @@ -893,8 +1004,14 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, #ifdef XML_DTD } else { - dtdSwap(&dtd, oldDtd); - isParamEntity = 1; + /* The DTD instance referenced by _dtd is shared between the document's + root parser and external PE parsers, therefore one does not need to + call setContext. In addition, one also *must* not call setContext, + because this would overwrite existing prefix->binding pointers in + _dtd with ones that get destroyed with the external PE parser. + This would leave those prefixes with dangling pointers. + */ + isParamEntity = XML_TRUE; XmlPrologStateInitExternalEntity(&prologState); processor = externalParEntInitProcessor; } @@ -902,7 +1019,7 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, return parser; } -static void +static void FASTCALL destroyBindings(BINDING *bindings, XML_Parser parser) { for (;;) { @@ -920,7 +1037,7 @@ XML_ParserFree(XML_Parser parser) { for (;;) { TAG *p; - if (tagStack == 0) { + if (tagStack == NULL) { if (freeTagList == NULL) break; tagStack = freeTagList; @@ -937,10 +1054,14 @@ XML_ParserFree(XML_Parser parser) poolDestroy(&tempPool); poolDestroy(&temp2Pool); #ifdef XML_DTD - if (isParamEntity) - dtdSwap(&dtd, &((Parser *)parentParser)->m_dtd); + /* external parameter entity parsers share the DTD structure + parser->m_dtd with the root parser, so we must not destroy it + */ + if (!isParamEntity && _dtd) +#else + if (_dtd) #endif /* XML_DTD */ - dtdDestroy(&dtd, parser); + dtdDestroy(_dtd, (XML_Bool)!parentParser, &parser->m_mem); FREE((void *)atts); if (groupConnector) FREE(groupConnector); @@ -960,9 +1081,27 @@ XML_UseParserAsHandlerArg(XML_Parser parser) handlerArg = parser; } +enum XML_Error +XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD) +{ +#ifdef XML_DTD + /* block after XML_Parse()/XML_ParseBuffer() has been called */ + if (parsing) + return XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING; + useForeignDTD = useDTD; + return XML_ERROR_NONE; +#else + return XML_ERROR_FEATURE_REQUIRES_XML_DTD; +#endif +} + void -XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) { - ns_triplets = do_nst; +XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) +{ + /* block after XML_Parse()/XML_ParseBuffer() has been called */ + if (parsing) + return; + ns_triplets = do_nst ? XML_TRUE : XML_FALSE; } void @@ -974,18 +1113,18 @@ XML_SetUserData(XML_Parser parser, void *p) userData = p; } -int +enum XML_Status XML_SetBase(XML_Parser parser, const XML_Char *p) { if (p) { - p = poolCopyString(&dtd.pool, p); + p = poolCopyString(&_dtd->pool, p); if (!p) - return 0; + return XML_STATUS_ERROR; curBase = p; } else curBase = NULL; - return 1; + return XML_STATUS_OK; } const XML_Char * @@ -1074,7 +1213,7 @@ XML_SetDefaultHandler(XML_Parser parser, XML_DefaultHandler handler) { defaultHandler = handler; - defaultExpandInternalEntities = 0; + defaultExpandInternalEntities = XML_FALSE; } void @@ -1082,7 +1221,7 @@ XML_SetDefaultHandlerExpand(XML_Parser parser, XML_DefaultHandler handler) { defaultHandler = handler; - defaultExpandInternalEntities = 1; + defaultExpandInternalEntities = XML_TRUE; } void @@ -1159,7 +1298,7 @@ void XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg) { if (arg) - externalEntityRefHandlerArg = arg; + externalEntityRefHandlerArg = (XML_Parser)arg; else externalEntityRefHandlerArg = parser; } @@ -1209,29 +1348,32 @@ XML_SetXmlDeclHandler(XML_Parser parser, int XML_SetParamEntityParsing(XML_Parser parser, - enum XML_ParamEntityParsing parsing) + enum XML_ParamEntityParsing peParsing) { + /* block after XML_Parse()/XML_ParseBuffer() has been called */ + if (parsing) + return 0; #ifdef XML_DTD - paramEntityParsing = parsing; + paramEntityParsing = peParsing; return 1; #else - return parsing == XML_PARAM_ENTITY_PARSING_NEVER; + return peParsing == XML_PARAM_ENTITY_PARSING_NEVER; #endif } -int +enum XML_Status XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) { if (len == 0) { if (!isFinal) - return 1; + return XML_STATUS_OK; positionPtr = bufferPtr; errorCode = processor(parser, bufferPtr, parseEndPtr = bufferEnd, 0); if (errorCode == XML_ERROR_NONE) - return 1; + return XML_STATUS_OK; eventEndPtr = eventPtr; processor = errorProcessor; - return 0; + return XML_STATUS_ERROR; } #ifndef XML_CONTEXT_BYTES else if (bufferPtr == bufferEnd) { @@ -1242,34 +1384,37 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) if (isFinal) { errorCode = processor(parser, s, parseEndPtr = s + len, 0); if (errorCode == XML_ERROR_NONE) - return 1; + return XML_STATUS_OK; eventEndPtr = eventPtr; processor = errorProcessor; - return 0; + return XML_STATUS_ERROR; } errorCode = processor(parser, s, parseEndPtr = s + len, &end); if (errorCode != XML_ERROR_NONE) { eventEndPtr = eventPtr; processor = errorProcessor; - return 0; + return XML_STATUS_ERROR; } XmlUpdatePosition(encoding, positionPtr, end, &position); + positionPtr = end; nLeftOver = s + len - end; if (nLeftOver) { - if (buffer == 0 || nLeftOver > bufferLim - buffer) { + if (buffer == NULL || nLeftOver > bufferLim - buffer) { /* FIXME avoid integer overflow */ char *temp; - temp = buffer == 0 ? MALLOC(len * 2) : REALLOC(buffer, len * 2); + temp = (buffer == NULL + ? (char *)MALLOC(len * 2) + : (char *)REALLOC(buffer, len * 2)); if (temp == NULL) { errorCode = XML_ERROR_NO_MEMORY; - return 0; + return XML_STATUS_ERROR; } buffer = temp; if (!buffer) { errorCode = XML_ERROR_NO_MEMORY; eventPtr = eventEndPtr = NULL; processor = errorProcessor; - return 0; + return XML_STATUS_ERROR; } bufferLim = buffer + len * 2; } @@ -1277,13 +1422,13 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) bufferPtr = buffer; bufferEnd = buffer + nLeftOver; } - return 1; + return XML_STATUS_OK; } #endif /* not defined XML_CONTEXT_BYTES */ else { void *buff = XML_GetBuffer(parser, len); if (buff == NULL) - return 0; + return XML_STATUS_ERROR; else { memcpy(buff, s, len); return XML_ParseBuffer(parser, len, isFinal); @@ -1291,7 +1436,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) } } -int +enum XML_Status XML_ParseBuffer(XML_Parser parser, int len, int isFinal) { const char *start = bufferPtr; @@ -1299,16 +1444,18 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal) bufferEnd += len; parseEndByteIndex += len; errorCode = processor(parser, start, parseEndPtr = bufferEnd, - isFinal ? (const char **)0 : &bufferPtr); + isFinal ? (const char **)NULL : &bufferPtr); if (errorCode == XML_ERROR_NONE) { - if (!isFinal) + if (!isFinal) { XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); - return 1; + positionPtr = bufferPtr; + } + return XML_STATUS_OK; } else { eventEndPtr = eventPtr; processor = errorProcessor; - return 0; + return XML_STATUS_ERROR; } } @@ -1347,7 +1494,7 @@ XML_GetBuffer(XML_Parser parser, int len) do { bufferSize *= 2; } while (bufferSize < neededSize); - newBuf = MALLOC(bufferSize); + newBuf = (char *)MALLOC(bufferSize); if (newBuf == 0) { errorCode = XML_ERROR_NO_MEMORY; return NULL; @@ -1437,6 +1584,30 @@ XML_GetCurrentColumnNumber(XML_Parser parser) } void +XML_FreeContentModel(XML_Parser parser, XML_Content *model) +{ + FREE(model); +} + +void * +XML_MemMalloc(XML_Parser parser, size_t size) +{ + return MALLOC(size); +} + +void * +XML_MemRealloc(XML_Parser parser, void *ptr, size_t size) +{ + return REALLOC(ptr, size); +} + +void +XML_MemFree(XML_Parser parser, void *ptr) +{ + FREE(ptr); +} + +void XML_DefaultCurrent(XML_Parser parser) { if (defaultHandler) { @@ -1451,7 +1622,7 @@ XML_DefaultCurrent(XML_Parser parser) } const XML_LChar * -XML_ErrorString(int code) +XML_ErrorString(enum XML_Error code) { static const XML_LChar *message[] = { 0, @@ -1471,14 +1642,16 @@ XML_ErrorString(int code) XML_L("reference to invalid character number"), XML_L("reference to binary entity"), XML_L("reference to external entity in attribute"), - XML_L("xml processing instruction not at start of external entity"), + XML_L("xml declaration not at start of external entity"), XML_L("unknown encoding"), XML_L("encoding specified in XML declaration is incorrect"), XML_L("unclosed CDATA section"), XML_L("error in processing external entity reference"), XML_L("document is not standalone"), XML_L("unexpected parser state - please send a bug report"), - XML_L("entity declared in parameter entity") + XML_L("entity declared in parameter entity"), + XML_L("requested feature requires XML_DTD support in Expat"), + XML_L("cannot change setting once parsing has begun") }; if (code > 0 && code < sizeof(message)/sizeof(message[0])) return message[code]; @@ -1496,8 +1669,8 @@ XML_ExpatVersion(void) { with the correct numerals. */ /* ### I'm assuming cpp is portable in this respect... */ -#define V1(a,b,c) XML_L("expat_")XML_L(#a)XML_L(".")XML_L(#b)XML_L(".")XML_L(#c) -#define V2(a,b,c) V1(a,b,c) +#define V1(a,b,c) XML_L(#a)XML_L(".")XML_L(#b)XML_L(".")XML_L(#c) +#define V2(a,b,c) XML_L("expat_")V1(a,b,c) return V2(XML_MAJOR_VERSION, XML_MINOR_VERSION, XML_MICRO_VERSION); @@ -1506,7 +1679,8 @@ XML_ExpatVersion(void) { } XML_Expat_Version -XML_ExpatVersionInfo(void) { +XML_ExpatVersionInfo(void) +{ XML_Expat_Version version; version.major = XML_MAJOR_VERSION; @@ -1516,16 +1690,102 @@ XML_ExpatVersionInfo(void) { return version; } -static -enum XML_Error contentProcessor(XML_Parser parser, - const char *start, - const char *end, - const char **endPtr) +const XML_Feature * +XML_GetFeatureList(void) { - return doContent(parser, 0, encoding, start, end, endPtr); + static XML_Feature features[] = { + {XML_FEATURE_SIZEOF_XML_CHAR, XML_L("sizeof(XML_Char)")}, + {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)")}, +#ifdef XML_UNICODE + {XML_FEATURE_UNICODE, XML_L("XML_UNICODE")}, +#endif +#ifdef XML_UNICODE_WCHAR_T + {XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T")}, +#endif +#ifdef XML_DTD + {XML_FEATURE_DTD, XML_L("XML_DTD")}, +#endif +#ifdef XML_CONTEXT_BYTES + {XML_FEATURE_CONTEXT_BYTES, XML_L("XML_CONTEXT_BYTES"), + XML_CONTEXT_BYTES}, +#endif +#ifdef XML_MIN_SIZE + {XML_FEATURE_MIN_SIZE, XML_L("XML_MIN_SIZE")}, +#endif + {XML_FEATURE_END, NULL} + }; + + features[0].value = sizeof(XML_Char); + features[1].value = sizeof(XML_LChar); + return features; } -static enum XML_Error +/* Initially tag->rawName always points into the parse buffer; + for those TAG instances opened while the current parse buffer was + processed, and not yet closed, we need to store tag->rawName in a more + permanent location, since the parse buffer is about to be discarded. +*/ +static XML_Bool +storeRawNames(XML_Parser parser) +{ + TAG *tag = tagStack; + while (tag) { + int bufSize; + int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1); + char *rawNameBuf = tag->buf + nameLen; + /* Stop if already stored. Since tagStack is a stack, we can stop + at the first entry that has already been copied; everything + below it in the stack is already been accounted for in a + previous call to this function. + */ + if (tag->rawName == rawNameBuf) + break; + /* For re-use purposes we need to ensure that the + size of tag->buf is a multiple of sizeof(XML_Char). + */ + bufSize = nameLen + ROUND_UP(tag->rawNameLength, sizeof(XML_Char)); + if (bufSize > tag->bufEnd - tag->buf) { + char *temp = (char *)REALLOC(tag->buf, bufSize); + if (temp == NULL) + return XML_FALSE; + /* if tag->name.str points to tag->buf (only when namespace + processing is off) then we have to update it + */ + if (tag->name.str == (XML_Char *)tag->buf) + tag->name.str = (XML_Char *)temp; + /* if tag->name.localPart is set (when namespace processing is on) + then update it as well, since it will always point into tag->buf + */ + if (tag->name.localPart) + tag->name.localPart = (XML_Char *)temp + (tag->name.localPart - + (XML_Char *)tag->buf); + tag->buf = temp; + tag->bufEnd = temp + bufSize; + rawNameBuf = temp + nameLen; + } + memcpy(rawNameBuf, tag->rawName, tag->rawNameLength); + tag->rawName = rawNameBuf; + tag = tag->parent; + } + return XML_TRUE; +} + +static enum XML_Error PTRCALL +contentProcessor(XML_Parser parser, + const char *start, + const char *end, + const char **endPtr) +{ + enum XML_Error result = + doContent(parser, 0, encoding, start, end, endPtr); + if (result != XML_ERROR_NONE) + return result; + if (!storeRawNames(parser)) + return XML_ERROR_NO_MEMORY; + return result; +} + +static enum XML_Error PTRCALL externalEntityInitProcessor(XML_Parser parser, const char *start, const char *end, @@ -1538,7 +1798,7 @@ externalEntityInitProcessor(XML_Parser parser, return externalEntityInitProcessor2(parser, start, end, endPtr); } -static enum XML_Error +static enum XML_Error PTRCALL externalEntityInitProcessor2(XML_Parser parser, const char *start, const char *end, @@ -1578,7 +1838,7 @@ externalEntityInitProcessor2(XML_Parser parser, return externalEntityInitProcessor3(parser, start, end, endPtr); } -static enum XML_Error +static enum XML_Error PTRCALL externalEntityInitProcessor3(XML_Parser parser, const char *start, const char *end, @@ -1612,16 +1872,22 @@ externalEntityInitProcessor3(XML_Parser parser, } processor = externalEntityContentProcessor; tagLevel = 1; - return doContent(parser, 1, encoding, start, end, endPtr); + return externalEntityContentProcessor(parser, start, end, endPtr); } -static enum XML_Error +static enum XML_Error PTRCALL externalEntityContentProcessor(XML_Parser parser, const char *start, const char *end, const char **endPtr) { - return doContent(parser, 1, encoding, start, end, endPtr); + enum XML_Error result = + doContent(parser, 1, encoding, start, end, endPtr); + if (result != XML_ERROR_NONE) + return result; + if (!storeRawNames(parser)) + return XML_ERROR_NO_MEMORY; + return result; } static enum XML_Error @@ -1632,6 +1898,7 @@ doContent(XML_Parser parser, const char *end, const char **nextPtr) { + DTD * const dtd = _dtd; /* save one level of indirection */ const char **eventPP; const char **eventEndPP; if (enc == encoding) { @@ -1705,18 +1972,18 @@ doContent(XML_Parser parser, reportDefault(parser, enc, s, next); break; } - name = poolStoreString(&dtd.pool, enc, + name = poolStoreString(&dtd->pool, enc, s + enc->minBytesPerChar, next - enc->minBytesPerChar); if (!name) return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(&dtd.generalEntities, name, 0); - poolDiscard(&dtd.pool); + entity = (ENTITY *)lookup(&dtd->generalEntities, name, 0); + poolDiscard(&dtd->pool); /* First, determine if a check for an existing declaration is needed; if yes, check that the entity exists, and that it is internal, otherwise call the skipped entity or default handler. */ - if (!dtd.hasParamEntities || dtd.standalone) { + if (!dtd->hasParamEntityRefs || dtd->standalone) { if (!entity) return XML_ERROR_UNDEFINED_ENTITY; else if (!entity->is_internal) @@ -1743,7 +2010,7 @@ doContent(XML_Parser parser, reportDefault(parser, enc, s, next); break; } - entity->open = 1; + entity->open = XML_TRUE; openEntity.next = openInternalEntities; openInternalEntities = &openEntity; openEntity.entity = entity; @@ -1755,19 +2022,19 @@ doContent(XML_Parser parser, (char *)entity->textPtr, (char *)(entity->textPtr + entity->textLen), 0); - entity->open = 0; + entity->open = XML_FALSE; openInternalEntities = openEntity.next; if (result) return result; } else if (externalEntityRefHandler) { const XML_Char *context; - entity->open = 1; + entity->open = XML_TRUE; context = getContext(parser); - entity->open = 0; + entity->open = XML_FALSE; if (!context) return XML_ERROR_NO_MEMORY; - if (!externalEntityRefHandler(externalEntityRefHandlerArg, + if (!externalEntityRefHandler((XML_Parser)externalEntityRefHandlerArg, context, entity->base, entity->systemId, @@ -1779,14 +2046,9 @@ doContent(XML_Parser parser, reportDefault(parser, enc, s, next); break; } - case XML_TOK_START_TAG_WITH_ATTS: - if (!startElementHandler) { - enum XML_Error result = storeAtts(parser, enc, s, 0, 0); - if (result) - return result; - } - /* fall through */ case XML_TOK_START_TAG_NO_ATTS: + /* fall through */ + case XML_TOK_START_TAG_WITH_ATTS: { TAG *tag; enum XML_Error result; @@ -1796,10 +2058,10 @@ doContent(XML_Parser parser, freeTagList = freeTagList->parent; } else { - tag = MALLOC(sizeof(TAG)); + tag = (TAG *)MALLOC(sizeof(TAG)); if (!tag) return XML_ERROR_NO_MEMORY; - tag->buf = MALLOC(INIT_TAG_BUF_SIZE); + tag->buf = (char *)MALLOC(INIT_TAG_BUF_SIZE); if (!tag->buf) { FREE(tag); return XML_ERROR_NO_MEMORY; @@ -1813,77 +2075,54 @@ doContent(XML_Parser parser, tag->name.prefix = NULL; tag->rawName = s + enc->minBytesPerChar; tag->rawNameLength = XmlNameLength(enc, tag->rawName); - if (nextPtr) { - /* Need to guarantee that: - tag->buf + ROUND_UP(tag->rawNameLength, sizeof(XML_Char)) - <= tag->bufEnd - sizeof(XML_Char) */ - if (tag->rawNameLength + (int)(sizeof(XML_Char) - 1) - + (int)sizeof(XML_Char) > tag->bufEnd - tag->buf) { - int bufSize = tag->rawNameLength * 4; - bufSize = ROUND_UP(bufSize, sizeof(XML_Char)); + ++tagLevel; + { + const char *rawNameEnd = tag->rawName + tag->rawNameLength; + const char *fromPtr = tag->rawName; + toPtr = (XML_Char *)tag->buf; + for (;;) { + int bufSize; + int convLen; + XmlConvert(enc, + &fromPtr, rawNameEnd, + (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1); + convLen = toPtr - (XML_Char *)tag->buf; + if (fromPtr == rawNameEnd) { + tag->name.strLen = convLen; + break; + } + bufSize = (tag->bufEnd - tag->buf) << 1; { - char *temp = REALLOC(tag->buf, bufSize); + char *temp = (char *)REALLOC(tag->buf, bufSize); if (temp == NULL) return XML_ERROR_NO_MEMORY; tag->buf = temp; + tag->bufEnd = temp + bufSize; + toPtr = (XML_Char *)temp + convLen; } - tag->bufEnd = tag->buf + bufSize; - } - memcpy(tag->buf, tag->rawName, tag->rawNameLength); - tag->rawName = tag->buf; - } - ++tagLevel; - for (;;) { - const char *rawNameEnd = tag->rawName + tag->rawNameLength; - const char *fromPtr = tag->rawName; - int bufSize; - if (nextPtr) - toPtr = (XML_Char *)(tag->buf + ROUND_UP(tag->rawNameLength, - sizeof(XML_Char))); - else - toPtr = (XML_Char *)tag->buf; - tag->name.str = toPtr; - XmlConvert(enc, - &fromPtr, rawNameEnd, - (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1); - if (fromPtr == rawNameEnd) - break; - bufSize = (tag->bufEnd - tag->buf) << 1; - { - char *temp = REALLOC(tag->buf, bufSize); - if (temp == NULL) - return XML_ERROR_NO_MEMORY; - tag->buf = temp; } - tag->bufEnd = tag->buf + bufSize; - if (nextPtr) - tag->rawName = tag->buf; } + tag->name.str = (XML_Char *)tag->buf; *toPtr = XML_T('\0'); - if (startElementHandler) { - result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings)); - if (result) - return result; + result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings)); + if (result) + return result; + if (startElementHandler) startElementHandler(handlerArg, tag->name.str, (const XML_Char **)atts); - } else if (defaultHandler) reportDefault(parser, enc, s, next); poolClear(&tempPool); break; } - case XML_TOK_EMPTY_ELEMENT_WITH_ATTS: - if (!startElementHandler) { - enum XML_Error result = storeAtts(parser, enc, s, 0, 0); - if (result) - return result; - } - /* fall through */ case XML_TOK_EMPTY_ELEMENT_NO_ATTS: - if (startElementHandler || endElementHandler) { + /* fall through */ + case XML_TOK_EMPTY_ELEMENT_WITH_ATTS: + { const char *rawName = s + enc->minBytesPerChar; enum XML_Error result; BINDING *bindings = NULL; + XML_Bool noElmHandlers = XML_TRUE; TAG_NAME name; name.str = poolStoreString(&tempPool, enc, rawName, rawName + XmlNameLength(enc, rawName)); @@ -1894,13 +2133,18 @@ doContent(XML_Parser parser, if (result) return result; poolFinish(&tempPool); - if (startElementHandler) + if (startElementHandler) { startElementHandler(handlerArg, name.str, (const XML_Char **)atts); + noElmHandlers = XML_FALSE; + } if (endElementHandler) { if (startElementHandler) *eventPP = *eventEndPP; endElementHandler(handlerArg, name.str); + noElmHandlers = XML_FALSE; } + if (noElmHandlers && defaultHandler) + reportDefault(parser, enc, s, next); poolClear(&tempPool); while (bindings) { BINDING *b = bindings; @@ -1912,8 +2156,6 @@ doContent(XML_Parser parser, b->prefix->binding = b->prevPrefixBinding; } } - else if (defaultHandler) - reportDefault(parser, enc, s, next); if (tagLevel == 0) return epilogProcessor(parser, next, end, nextPtr); break; @@ -2093,14 +2335,22 @@ doContent(XML_Parser parser, /* not reached */ } -/* If tagNamePtr is non-null, build a real list of attributes, - otherwise just check the attributes for well-formedness. +/* Precondition: all arguments must be non-NULL; + Purpose: + - normalize attributes + - check attributes for well-formedness + - generate namespace aware attribute names (URI, prefix) + - build list of attributes for startElementHandler + - default attributes + - process namespace declarations (check and report them) + - generate namespace aware element name (URI, prefix) */ static enum XML_Error storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr, TAG_NAME *tagNamePtr, BINDING **bindingsPtr) { + DTD * const dtd = _dtd; /* save one level of indirection */ ELEMENT_TYPE *elementType = NULL; int nDefaultAtts = 0; const XML_Char **appAtts; /* the attribute list for the application */ @@ -2114,34 +2364,34 @@ storeAtts(XML_Parser parser, const ENCODING *enc, const XML_Char *localPart; /* lookup the element type name */ - if (tagNamePtr) { - elementType = (ELEMENT_TYPE *)lookup(&dtd.elementTypes, tagNamePtr->str,0); - if (!elementType) { - tagNamePtr->str = poolCopyString(&dtd.pool, tagNamePtr->str); - if (!tagNamePtr->str) - return XML_ERROR_NO_MEMORY; - elementType = (ELEMENT_TYPE *)lookup(&dtd.elementTypes, tagNamePtr->str, - sizeof(ELEMENT_TYPE)); - if (!elementType) - return XML_ERROR_NO_MEMORY; - if (ns && !setElementTypePrefix(parser, elementType)) - return XML_ERROR_NO_MEMORY; - } - nDefaultAtts = elementType->nDefaultAtts; + elementType = (ELEMENT_TYPE *)lookup(&dtd->elementTypes, tagNamePtr->str,0); + if (!elementType) { + const XML_Char *name = poolCopyString(&dtd->pool, tagNamePtr->str); + if (!name) + return XML_ERROR_NO_MEMORY; + elementType = (ELEMENT_TYPE *)lookup(&dtd->elementTypes, name, + sizeof(ELEMENT_TYPE)); + if (!elementType) + return XML_ERROR_NO_MEMORY; + if (ns && !setElementTypePrefix(parser, elementType)) + return XML_ERROR_NO_MEMORY; } + nDefaultAtts = elementType->nDefaultAtts; + /* get the attributes from the tokenizer */ n = XmlGetAttributes(enc, attStr, attsSize, atts); if (n + nDefaultAtts > attsSize) { int oldAttsSize = attsSize; ATTRIBUTE *temp; attsSize = n + nDefaultAtts + INIT_ATTS_SIZE; - temp = REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE)); + temp = (ATTRIBUTE *)REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE)); if (temp == NULL) return XML_ERROR_NO_MEMORY; atts = temp; if (n > oldAttsSize) XmlGetAttributes(enc, attStr, n, atts); } + appAtts = (const XML_Char **)atts; for (i = 0; i < n; i++) { /* add the name and value to the attribute list */ @@ -2160,7 +2410,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc, appAtts[attIndex++] = attId->name; if (!atts[i].normalized) { enum XML_Error result; - int isCdata = 1; + XML_Bool isCdata = XML_TRUE; /* figure out whether declared as other than CDATA */ if (attId->maybeTokenized) { @@ -2179,14 +2429,10 @@ storeAtts(XML_Parser parser, const ENCODING *enc, &tempPool); if (result) return result; - if (tagNamePtr) { - appAtts[attIndex] = poolStart(&tempPool); - poolFinish(&tempPool); - } - else - poolDiscard(&tempPool); + appAtts[attIndex] = poolStart(&tempPool); + poolFinish(&tempPool); } - else if (tagNamePtr) { + else { /* the value did not need normalizing */ appAtts[attIndex] = poolStoreString(&tempPool, enc, atts[i].valuePtr, atts[i].valueEnd); @@ -2195,12 +2441,13 @@ storeAtts(XML_Parser parser, const ENCODING *enc, poolFinish(&tempPool); } /* handle prefixed attribute names */ - if (attId->prefix && tagNamePtr) { + if (attId->prefix) { if (attId->xmlns) { /* deal with namespace declarations here */ - if (!addBinding(parser, attId->prefix, attId, appAtts[attIndex], - bindingsPtr)) - return XML_ERROR_NO_MEMORY; + enum XML_Error result = addBinding(parser, attId->prefix, attId, + appAtts[attIndex], bindingsPtr); + if (result) + return result; --attIndex; } else { @@ -2213,44 +2460,46 @@ storeAtts(XML_Parser parser, const ENCODING *enc, else attIndex++; } - if (tagNamePtr) { - int j; - nSpecifiedAtts = attIndex; - if (elementType->idAtt && (elementType->idAtt->name)[-1]) { - for (i = 0; i < attIndex; i += 2) - if (appAtts[i] == elementType->idAtt->name) { - idAttIndex = i; - break; - } - } - else - idAttIndex = -1; - /* do attribute defaulting */ - for (j = 0; j < nDefaultAtts; j++) { - const DEFAULT_ATTRIBUTE *da = elementType->defaultAtts + j; - if (!(da->id->name)[-1] && da->value) { - if (da->id->prefix) { - if (da->id->xmlns) { - if (!addBinding(parser, da->id->prefix, da->id, da->value, - bindingsPtr)) - return XML_ERROR_NO_MEMORY; - } - else { - (da->id->name)[-1] = 2; - nPrefixes++; - appAtts[attIndex++] = da->id->name; - appAtts[attIndex++] = da->value; - } + + /* set-up for XML_GetSpecifiedAttributeCount and XML_GetIdAttributeIndex */ + nSpecifiedAtts = attIndex; + if (elementType->idAtt && (elementType->idAtt->name)[-1]) { + for (i = 0; i < attIndex; i += 2) + if (appAtts[i] == elementType->idAtt->name) { + idAttIndex = i; + break; + } + } + else + idAttIndex = -1; + + /* do attribute defaulting */ + for (i = 0; i < nDefaultAtts; i++) { + const DEFAULT_ATTRIBUTE *da = elementType->defaultAtts + i; + if (!(da->id->name)[-1] && da->value) { + if (da->id->prefix) { + if (da->id->xmlns) { + enum XML_Error result = addBinding(parser, da->id->prefix, da->id, + da->value, bindingsPtr); + if (result) + return result; } else { - (da->id->name)[-1] = 1; + (da->id->name)[-1] = 2; + nPrefixes++; appAtts[attIndex++] = da->id->name; appAtts[attIndex++] = da->value; } } + else { + (da->id->name)[-1] = 1; + appAtts[attIndex++] = da->id->name; + appAtts[attIndex++] = da->value; + } } - appAtts[attIndex] = 0; } + appAtts[attIndex] = 0; + i = 0; if (nPrefixes) { /* expand prefixed attribute names */ @@ -2258,7 +2507,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc, if (appAtts[i][-1] == 2) { ATTRIBUTE_ID *id; ((XML_Char *)(appAtts[i]))[-1] = 0; - id = (ATTRIBUTE_ID *)lookup(&dtd.attributeIds, appAtts[i], 0); + id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, appAtts[i], 0); if (id->prefix->binding) { int j; const BINDING *b = id->prefix->binding; @@ -2295,10 +2544,9 @@ storeAtts(XML_Parser parser, const ENCODING *enc, /* clear the flags that say whether attributes were specified */ for (; i < attIndex; i += 2) ((XML_Char *)(appAtts[i]))[-1] = 0; - if (!tagNamePtr) - return XML_ERROR_NONE; for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding) binding->attId->name[-1] = 0; + /* expand the element type name */ if (elementType->prefix) { binding = elementType->prefix->binding; @@ -2308,8 +2556,8 @@ storeAtts(XML_Parser parser, const ENCODING *enc, while (*localPart++ != XML_T(':')) ; } - else if (dtd.defaultPrefix.binding) { - binding = dtd.defaultPrefix.binding; + else if (dtd->defaultPrefix.binding) { + binding = dtd->defaultPrefix.binding; localPart = tagNamePtr->str; } else @@ -2328,7 +2576,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc, n = i + binding->uriLen + prefixLen; if (n > binding->uriAlloc) { TAG *p; - uri = MALLOC((n + EXPAND_SPARE) * sizeof(XML_Char)); + uri = (XML_Char *)MALLOC((n + EXPAND_SPARE) * sizeof(XML_Char)); if (!uri) return XML_ERROR_NO_MEMORY; binding->uriAlloc = n + EXPAND_SPARE; @@ -2350,12 +2598,20 @@ storeAtts(XML_Parser parser, const ENCODING *enc, return XML_ERROR_NONE; } -static int +/* addBinding() overwrites the value of prefix->binding without checking. + Therefore one must keep track of the old value outside of addBinding(). +*/ +static enum XML_Error addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, const XML_Char *uri, BINDING **bindingsPtr) { BINDING *b; int len; + + /* empty string is only valid when there is no prefix per XML NS 1.0 */ + if (*uri == XML_T('\0') && prefix->name) + return XML_ERROR_SYNTAX; + for (len = 0; uri[len]; len++) ; if (namespaceSeparator) @@ -2363,23 +2619,23 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, if (freeBindingList) { b = freeBindingList; if (len > b->uriAlloc) { - XML_Char *temp = REALLOC(b->uri, - sizeof(XML_Char) * (len + EXPAND_SPARE)); + XML_Char *temp = (XML_Char *)REALLOC(b->uri, + sizeof(XML_Char) * (len + EXPAND_SPARE)); if (temp == NULL) - return 0; + return XML_ERROR_NO_MEMORY; b->uri = temp; b->uriAlloc = len + EXPAND_SPARE; } freeBindingList = b->nextTagBinding; } else { - b = MALLOC(sizeof(BINDING)); + b = (BINDING *)MALLOC(sizeof(BINDING)); if (!b) - return 0; - b->uri = MALLOC(sizeof(XML_Char) * (len + EXPAND_SPARE)); + return XML_ERROR_NO_MEMORY; + b->uri = (XML_Char *)MALLOC(sizeof(XML_Char) * (len + EXPAND_SPARE)); if (!b->uri) { FREE(b); - return 0; + return XML_ERROR_NO_MEMORY; } b->uriAlloc = len + EXPAND_SPARE; } @@ -2390,7 +2646,7 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, b->prefix = prefix; b->attId = attId; b->prevPrefixBinding = prefix->binding; - if (*uri == XML_T('\0') && prefix == &dtd.defaultPrefix) + if (*uri == XML_T('\0') && prefix == &_dtd->defaultPrefix) prefix->binding = NULL; else prefix->binding = b; @@ -2399,13 +2655,13 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, if (startNamespaceDeclHandler) startNamespaceDeclHandler(handlerArg, prefix->name, prefix->binding ? uri : 0); - return 1; + return XML_ERROR_NONE; } /* The idea here is to avoid using stack for each CDATA section when the whole file is parsed with one call. */ -static enum XML_Error +static enum XML_Error PTRCALL cdataSectionProcessor(XML_Parser parser, const char *start, const char *end, @@ -2527,7 +2783,7 @@ doCdataSection(XML_Parser parser, /* The idea here is to avoid using stack for each IGNORE section when the whole file is parsed with one call. */ -static enum XML_Error +static enum XML_Error PTRCALL ignoreSectionProcessor(XML_Parser parser, const char *start, const char *end, @@ -2655,7 +2911,7 @@ processXmlDecl(XML_Parser parser, int isGeneralTextEntity, &standalone)) return XML_ERROR_SYNTAX; if (!isGeneralTextEntity && standalone == 1) { - dtd.standalone = 1; + _dtd->standalone = XML_TRUE; #ifdef XML_DTD if (paramEntityParsing == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; @@ -2702,7 +2958,7 @@ processXmlDecl(XML_Parser parser, int isGeneralTextEntity, return XML_ERROR_NO_MEMORY; } result = handleUnknownEncoding(parser, storedEncName); - poolClear(&tempPool); + poolClear(&temp2Pool); if (result == XML_ERROR_UNKNOWN_ENCODING) eventPtr = encodingName; return result; @@ -2754,7 +3010,7 @@ handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) return XML_ERROR_UNKNOWN_ENCODING; } -static enum XML_Error +static enum XML_Error PTRCALL prologInitProcessor(XML_Parser parser, const char *s, const char *end, @@ -2769,20 +3025,19 @@ prologInitProcessor(XML_Parser parser, #ifdef XML_DTD -static enum XML_Error +static enum XML_Error PTRCALL externalParEntInitProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) + const char *s, + const char *end, + const char **nextPtr) { enum XML_Error result = initializeEncoding(parser); if (result != XML_ERROR_NONE) return result; /* we know now that XML_Parse(Buffer) has been called, - so we assume we actually have an external parameter entity */ - dtd.hasParamEntities = 1; - dtd.paramEntityRead = 1; + so we consider the external parameter entity read */ + _dtd->paramEntityRead = XML_TRUE; if (prologState.inEntityValue) { processor = entityValueInitProcessor; @@ -2794,11 +3049,11 @@ externalParEntInitProcessor(XML_Parser parser, } } -static enum XML_Error +static enum XML_Error PTRCALL entityValueInitProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) + const char *s, + const char *end, + const char **nextPtr) { const char *start = s; const char *next = s; @@ -2848,11 +3103,11 @@ entityValueInitProcessor(XML_Parser parser, } } -static enum XML_Error +static enum XML_Error PTRCALL externalParEntProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) + const char *s, + const char *end, + const char **nextPtr) { const char *start = s; const char *next = s; @@ -2889,11 +3144,11 @@ externalParEntProcessor(XML_Parser parser, return doProlog(parser, encoding, s, end, tok, next, nextPtr); } -static enum XML_Error +static enum XML_Error PTRCALL entityValueProcessor(XML_Parser parser, - const char *s, - const char *end, - const char **nextPtr) + const char *s, + const char *end, + const char **nextPtr) { const char *start = s; const char *next = s; @@ -2926,7 +3181,7 @@ entityValueProcessor(XML_Parser parser, #endif /* XML_DTD */ -static enum XML_Error +static enum XML_Error PTRCALL prologProcessor(XML_Parser parser, const char *s, const char *end, @@ -2954,13 +3209,19 @@ doProlog(XML_Parser parser, static const XML_Char atypeIDREF[] = { 'I', 'D', 'R', 'E', 'F', '\0' }; static const XML_Char atypeIDREFS[] = { 'I', 'D', 'R', 'E', 'F', 'S', '\0' }; static const XML_Char atypeENTITY[] = { 'E', 'N', 'T', 'I', 'T', 'Y', '\0' }; - static const XML_Char atypeENTITIES[] = { 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S', '\0' }; - static const XML_Char atypeNMTOKEN[] = { 'N', 'M', 'T', 'O', 'K', 'E', 'N', '\0' }; - static const XML_Char atypeNMTOKENS[] = { 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S', '\0' }; - static const XML_Char notationPrefix[] = { 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N', '(', '\0' }; + static const XML_Char atypeENTITIES[] = + { 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S', '\0' }; + static const XML_Char atypeNMTOKEN[] = { + 'N', 'M', 'T', 'O', 'K', 'E', 'N', '\0' }; + static const XML_Char atypeNMTOKENS[] = { + 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S', '\0' }; + static const XML_Char notationPrefix[] = { + 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N', '(', '\0' }; static const XML_Char enumValueSep[] = { '|', '\0' }; static const XML_Char enumValueStart[] = { '(', '\0' }; + DTD * const dtd = _dtd; /* save one level of indirection */ + const char **eventPP; const char **eventEndPP; enum XML_Content_Quant quant; @@ -2975,6 +3236,7 @@ doProlog(XML_Parser parser, } for (;;) { int role; + XML_Bool handleDefault = XML_TRUE; *eventPP = s; *eventEndPP = next; if (tok <= 0) { @@ -3016,6 +3278,7 @@ doProlog(XML_Parser parser, if (result != XML_ERROR_NONE) return result; enc = encoding; + handleDefault = XML_FALSE; } break; case XML_ROLE_DOCTYPE_NAME: @@ -3025,6 +3288,7 @@ doProlog(XML_Parser parser, return XML_ERROR_NO_MEMORY; poolFinish(&tempPool); doctypePubid = NULL; + handleDefault = XML_FALSE; } doctypeSysid = NULL; /* always initialize to NULL */ break; @@ -3034,6 +3298,7 @@ doProlog(XML_Parser parser, doctypePubid, 1); doctypeName = NULL; poolClear(&tempPool); + handleDefault = XML_FALSE; } break; #ifdef XML_DTD @@ -3043,10 +3308,15 @@ doProlog(XML_Parser parser, if (result != XML_ERROR_NONE) return result; enc = encoding; + handleDefault = XML_FALSE; } break; #endif /* XML_DTD */ case XML_ROLE_DOCTYPE_PUBLIC_ID: +#ifdef XML_DTD + useForeignDTD = XML_FALSE; +#endif /* XML_DTD */ + dtd->hasParamEntityRefs = XML_TRUE; if (startDoctypeDeclHandler) { doctypePubid = poolStoreString(&tempPool, enc, s + enc->minBytesPerChar, @@ -3054,9 +3324,10 @@ doProlog(XML_Parser parser, if (!doctypePubid) return XML_ERROR_NO_MEMORY; poolFinish(&tempPool); + handleDefault = XML_FALSE; } #ifdef XML_DTD - declEntity = (ENTITY *)lookup(&dtd.paramEntities, + declEntity = (ENTITY *)lookup(&dtd->paramEntities, externalSubsetName, sizeof(ENTITY)); if (!declEntity) @@ -3066,8 +3337,8 @@ doProlog(XML_Parser parser, case XML_ROLE_ENTITY_PUBLIC_ID: if (!XmlIsPublicId(enc, s, next, eventPP)) return XML_ERROR_SYNTAX; - if (declEntity) { - XML_Char *tem = poolStoreString(&dtd.pool, + if (dtd->keepProcessing && declEntity) { + XML_Char *tem = poolStoreString(&dtd->pool, enc, s + enc->minBytesPerChar, next - enc->minBytesPerChar); @@ -3075,7 +3346,9 @@ doProlog(XML_Parser parser, return XML_ERROR_NO_MEMORY; normalizePublicId(tem); declEntity->publicId = tem; - poolFinish(&dtd.pool); + poolFinish(&dtd->pool); + if (entityDeclHandler) + handleDefault = XML_FALSE; } break; case XML_ROLE_DOCTYPE_CLOSE: @@ -3083,84 +3356,122 @@ doProlog(XML_Parser parser, startDoctypeDeclHandler(handlerArg, doctypeName, doctypeSysid, doctypePubid, 0); poolClear(&tempPool); + handleDefault = XML_FALSE; } - /* doctypeSysid will be non-NULL in the case of + /* doctypeSysid will be non-NULL in the case of a previous XML_ROLE_DOCTYPE_SYSTEM_ID, even if startDoctypeDeclHandler was not set, indicating an external subset */ - if ((dtd.keepProcessing || dtd.standalone) && doctypeSysid) { #ifdef XML_DTD + if (doctypeSysid || useForeignDTD) { + dtd->hasParamEntityRefs = XML_TRUE; /* when docTypeSysid == NULL */ if (paramEntityParsing && externalEntityRefHandler) { - ENTITY *entity = (ENTITY *)lookup(&dtd.paramEntities, + ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, externalSubsetName, - 0); - dtd.paramEntityRead = 0; + sizeof(ENTITY)); + if (!entity) + return XML_ERROR_NO_MEMORY; + if (useForeignDTD) + entity->base = curBase; + dtd->paramEntityRead = XML_FALSE; if (!externalEntityRefHandler(externalEntityRefHandlerArg, 0, entity->base, entity->systemId, entity->publicId)) return XML_ERROR_EXTERNAL_ENTITY_HANDLING; - if (!dtd.paramEntityRead) - dtd.keepProcessing = 0; + if (dtd->paramEntityRead && + !dtd->standalone && + notStandaloneHandler && + !notStandaloneHandler(handlerArg)) + return XML_ERROR_NOT_STANDALONE; + /* end of DTD - no need to update dtd->keepProcessing */ } - else - dtd.keepProcessing = 0; -#endif /* XML_DTD */ - if (dtd.paramEntityRead - && !dtd.standalone - && notStandaloneHandler - && !notStandaloneHandler(handlerArg)) - return XML_ERROR_NOT_STANDALONE; + useForeignDTD = XML_FALSE; } - if (endDoctypeDeclHandler) +#endif /* XML_DTD */ + if (endDoctypeDeclHandler) { endDoctypeDeclHandler(handlerArg); + handleDefault = XML_FALSE; + } break; case XML_ROLE_INSTANCE_START: +#ifdef XML_DTD + /* if there is no DOCTYPE declaration then now is the + last chance to read the foreign DTD + */ + if (useForeignDTD) { + dtd->hasParamEntityRefs = XML_TRUE; + if (paramEntityParsing && externalEntityRefHandler) { + ENTITY *entity = (ENTITY *)lookup(&dtd->paramEntities, + externalSubsetName, + sizeof(ENTITY)); + if (!entity) + return XML_ERROR_NO_MEMORY; + entity->base = curBase; + dtd->paramEntityRead = XML_FALSE; + if (!externalEntityRefHandler(externalEntityRefHandlerArg, + 0, + entity->base, + entity->systemId, + entity->publicId)) + return XML_ERROR_EXTERNAL_ENTITY_HANDLING; + if (dtd->paramEntityRead && + !dtd->standalone && + notStandaloneHandler && + !notStandaloneHandler(handlerArg)) + return XML_ERROR_NOT_STANDALONE; + /* end of DTD - no need to update dtd->keepProcessing */ + } + } +#endif /* XML_DTD */ processor = contentProcessor; return contentProcessor(parser, s, end, nextPtr); case XML_ROLE_ATTLIST_ELEMENT_NAME: declElementType = getElementType(parser, enc, s, next); if (!declElementType) return XML_ERROR_NO_MEMORY; - break; + goto checkAttListDeclHandler; case XML_ROLE_ATTRIBUTE_NAME: declAttributeId = getAttributeId(parser, enc, s, next); if (!declAttributeId) return XML_ERROR_NO_MEMORY; - declAttributeIsCdata = 0; + declAttributeIsCdata = XML_FALSE; declAttributeType = NULL; - declAttributeIsId = 0; - break; + declAttributeIsId = XML_FALSE; + goto checkAttListDeclHandler; case XML_ROLE_ATTRIBUTE_TYPE_CDATA: - declAttributeIsCdata = 1; + declAttributeIsCdata = XML_TRUE; declAttributeType = atypeCDATA; - break; + goto checkAttListDeclHandler; case XML_ROLE_ATTRIBUTE_TYPE_ID: - declAttributeIsId = 1; + declAttributeIsId = XML_TRUE; declAttributeType = atypeID; - break; + goto checkAttListDeclHandler; case XML_ROLE_ATTRIBUTE_TYPE_IDREF: declAttributeType = atypeIDREF; - break; + goto checkAttListDeclHandler; case XML_ROLE_ATTRIBUTE_TYPE_IDREFS: declAttributeType = atypeIDREFS; - break; + goto checkAttListDeclHandler; case XML_ROLE_ATTRIBUTE_TYPE_ENTITY: declAttributeType = atypeENTITY; - break; + goto checkAttListDeclHandler; case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES: declAttributeType = atypeENTITIES; - break; + goto checkAttListDeclHandler; case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN: declAttributeType = atypeNMTOKEN; - break; + goto checkAttListDeclHandler; case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS: declAttributeType = atypeNMTOKENS; + checkAttListDeclHandler: + if (dtd->keepProcessing && attlistDeclHandler) + handleDefault = XML_FALSE; break; case XML_ROLE_ATTRIBUTE_ENUM_VALUE: case XML_ROLE_ATTRIBUTE_NOTATION_VALUE: - if (attlistDeclHandler) { + if (dtd->keepProcessing && attlistDeclHandler) { const XML_Char *prefix; if (declAttributeType) { prefix = enumValueSep; @@ -3175,11 +3486,12 @@ doProlog(XML_Parser parser, if (!poolAppend(&tempPool, enc, s, next)) return XML_ERROR_NO_MEMORY; declAttributeType = tempPool.start; + handleDefault = XML_FALSE; } break; case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE: case XML_ROLE_REQUIRED_ATTRIBUTE_VALUE: - if (dtd.keepProcessing || dtd.standalone) { + if (dtd->keepProcessing) { if (!defineAttribute(declElementType, declAttributeId, declAttributeIsCdata, declAttributeIsId, 0, parser)) @@ -3200,25 +3512,26 @@ doProlog(XML_Parser parser, declAttributeId->name, declAttributeType, 0, role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE); poolClear(&tempPool); + handleDefault = XML_FALSE; } } break; case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE: case XML_ROLE_FIXED_ATTRIBUTE_VALUE: - if (dtd.keepProcessing || dtd.standalone) { + if (dtd->keepProcessing) { const XML_Char *attVal; enum XML_Error result = storeAttributeValue(parser, enc, declAttributeIsCdata, s + enc->minBytesPerChar, next - enc->minBytesPerChar, - &dtd.pool); + &dtd->pool); if (result) return result; - attVal = poolStart(&dtd.pool); - poolFinish(&dtd.pool); + attVal = poolStart(&dtd->pool); + poolFinish(&dtd->pool); /* ID attributes aren't allowed to have a default */ if (!defineAttribute(declElementType, declAttributeId, - declAttributeIsCdata, 0, attVal, parser)) + declAttributeIsCdata, XML_FALSE, attVal, parser)) return XML_ERROR_NO_MEMORY; if (attlistDeclHandler && declAttributeType) { if (*declAttributeType == XML_T('(') @@ -3237,18 +3550,19 @@ doProlog(XML_Parser parser, attVal, role == XML_ROLE_FIXED_ATTRIBUTE_VALUE); poolClear(&tempPool); + handleDefault = XML_FALSE; } } break; case XML_ROLE_ENTITY_VALUE: - { + if (dtd->keepProcessing) { enum XML_Error result = storeEntityValue(parser, enc, - s + enc->minBytesPerChar, - next - enc->minBytesPerChar); + s + enc->minBytesPerChar, + next - enc->minBytesPerChar); if (declEntity) { - declEntity->textPtr = poolStart(&dtd.entityValuePool); - declEntity->textLen = poolLength(&dtd.entityValuePool); - poolFinish(&dtd.entityValuePool); + declEntity->textPtr = poolStart(&dtd->entityValuePool); + declEntity->textLen = poolLength(&dtd->entityValuePool); + poolFinish(&dtd->entityValuePool); if (entityDeclHandler) { *eventEndPP = s; entityDeclHandler(handlerArg, @@ -3257,15 +3571,20 @@ doProlog(XML_Parser parser, declEntity->textPtr, declEntity->textLen, curBase, 0, 0, 0); + handleDefault = XML_FALSE; } } else - poolDiscard(&dtd.entityValuePool); + poolDiscard(&dtd->entityValuePool); if (result != XML_ERROR_NONE) return result; } break; case XML_ROLE_DOCTYPE_SYSTEM_ID: +#ifdef XML_DTD + useForeignDTD = XML_FALSE; +#endif /* XML_DTD */ + dtd->hasParamEntityRefs = XML_TRUE; if (startDoctypeDeclHandler) { doctypeSysid = poolStoreString(&tempPool, enc, s + enc->minBytesPerChar, @@ -3273,14 +3592,15 @@ doProlog(XML_Parser parser, if (doctypeSysid == NULL) return XML_ERROR_NO_MEMORY; poolFinish(&tempPool); + handleDefault = XML_FALSE; } - else #ifdef XML_DTD + else /* use externalSubsetName to make doctypeSysid non-NULL for the case where no startDoctypeDeclHandler is set */ doctypeSysid = externalSubsetName; #endif /* XML_DTD */ - if (!dtd.standalone + if (!dtd->standalone #ifdef XML_DTD && !paramEntityParsing #endif /* XML_DTD */ @@ -3291,7 +3611,7 @@ doProlog(XML_Parser parser, break; #else /* XML_DTD */ if (!declEntity) { - declEntity = (ENTITY *)lookup(&dtd.paramEntities, + declEntity = (ENTITY *)lookup(&dtd->paramEntities, externalSubsetName, sizeof(ENTITY)); if (!declEntity) @@ -3301,18 +3621,20 @@ doProlog(XML_Parser parser, /* fall through */ #endif /* XML_DTD */ case XML_ROLE_ENTITY_SYSTEM_ID: - if (declEntity) { - declEntity->systemId = poolStoreString(&dtd.pool, enc, + if (dtd->keepProcessing && declEntity) { + declEntity->systemId = poolStoreString(&dtd->pool, enc, s + enc->minBytesPerChar, next - enc->minBytesPerChar); if (!declEntity->systemId) return XML_ERROR_NO_MEMORY; declEntity->base = curBase; - poolFinish(&dtd.pool); + poolFinish(&dtd->pool); + if (entityDeclHandler) + handleDefault = XML_FALSE; } break; case XML_ROLE_ENTITY_COMPLETE: - if (declEntity && entityDeclHandler) { + if (dtd->keepProcessing && declEntity && entityDeclHandler) { *eventEndPP = s; entityDeclHandler(handlerArg, declEntity->name, @@ -3322,14 +3644,15 @@ doProlog(XML_Parser parser, declEntity->systemId, declEntity->publicId, 0); + handleDefault = XML_FALSE; } break; case XML_ROLE_ENTITY_NOTATION_NAME: - if (declEntity) { - declEntity->notation = poolStoreString(&dtd.pool, enc, s, next); + if (dtd->keepProcessing && declEntity) { + declEntity->notation = poolStoreString(&dtd->pool, enc, s, next); if (!declEntity->notation) return XML_ERROR_NO_MEMORY; - poolFinish(&dtd.pool); + poolFinish(&dtd->pool); if (unparsedEntityDeclHandler) { *eventEndPP = s; unparsedEntityDeclHandler(handlerArg, @@ -3338,6 +3661,7 @@ doProlog(XML_Parser parser, declEntity->systemId, declEntity->publicId, declEntity->notation); + handleDefault = XML_FALSE; } else if (entityDeclHandler) { *eventEndPP = s; @@ -3348,6 +3672,7 @@ doProlog(XML_Parser parser, declEntity->systemId, declEntity->publicId, declEntity->notation); + handleDefault = XML_FALSE; } } break; @@ -3357,60 +3682,64 @@ doProlog(XML_Parser parser, declEntity = NULL; break; } - if (dtd.keepProcessing || dtd.standalone) { - const XML_Char *name = poolStoreString(&dtd.pool, enc, s, next); + if (dtd->keepProcessing) { + const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); if (!name) return XML_ERROR_NO_MEMORY; - declEntity = (ENTITY *)lookup(&dtd.generalEntities, name, + declEntity = (ENTITY *)lookup(&dtd->generalEntities, name, sizeof(ENTITY)); if (!declEntity) return XML_ERROR_NO_MEMORY; if (declEntity->name != name) { - poolDiscard(&dtd.pool); + poolDiscard(&dtd->pool); declEntity = NULL; } else { - poolFinish(&dtd.pool); + poolFinish(&dtd->pool); declEntity->publicId = NULL; - declEntity->is_param = 0; + declEntity->is_param = XML_FALSE; /* if we have a parent parser or are reading an internal parameter entity, then the entity declaration is not considered "internal" */ declEntity->is_internal = !(parentParser || openInternalEntities); + if (entityDeclHandler) + handleDefault = XML_FALSE; } } else { - poolDiscard(&dtd.pool); + poolDiscard(&dtd->pool); declEntity = NULL; } } break; case XML_ROLE_PARAM_ENTITY_NAME: #ifdef XML_DTD - if (dtd.keepProcessing || dtd.standalone) { - const XML_Char *name = poolStoreString(&dtd.pool, enc, s, next); + if (dtd->keepProcessing) { + const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); if (!name) return XML_ERROR_NO_MEMORY; - declEntity = (ENTITY *)lookup(&dtd.paramEntities, + declEntity = (ENTITY *)lookup(&dtd->paramEntities, name, sizeof(ENTITY)); if (!declEntity) return XML_ERROR_NO_MEMORY; if (declEntity->name != name) { - poolDiscard(&dtd.pool); - declEntity = 0; + poolDiscard(&dtd->pool); + declEntity = NULL; } else { - poolFinish(&dtd.pool); - declEntity->publicId = 0; - declEntity->is_param = 1; + poolFinish(&dtd->pool); + declEntity->publicId = NULL; + declEntity->is_param = XML_TRUE; /* if we have a parent parser or are reading an internal parameter entity, then the entity declaration is not considered "internal" */ declEntity->is_internal = !(parentParser || openInternalEntities); + if (entityDeclHandler) + handleDefault = XML_FALSE; } } else { - poolDiscard(&dtd.pool); + poolDiscard(&dtd->pool); declEntity = NULL; } #else /* not XML_DTD */ @@ -3425,12 +3754,13 @@ doProlog(XML_Parser parser, if (!declNotationName) return XML_ERROR_NO_MEMORY; poolFinish(&tempPool); + handleDefault = XML_FALSE; } break; case XML_ROLE_NOTATION_PUBLIC_ID: if (!XmlIsPublicId(enc, s, next, eventPP)) return XML_ERROR_SYNTAX; - if (declNotationName) { + if (declNotationName) { /* means notationDeclHandler != NULL */ XML_Char *tem = poolStoreString(&tempPool, enc, s + enc->minBytesPerChar, @@ -3440,6 +3770,7 @@ doProlog(XML_Parser parser, normalizePublicId(tem); declNotationPublicId = tem; poolFinish(&tempPool); + handleDefault = XML_FALSE; } break; case XML_ROLE_NOTATION_SYSTEM_ID: @@ -3456,6 +3787,7 @@ doProlog(XML_Parser parser, curBase, systemId, declNotationPublicId); + handleDefault = XML_FALSE; } poolClear(&tempPool); break; @@ -3467,6 +3799,7 @@ doProlog(XML_Parser parser, curBase, 0, declNotationPublicId); + handleDefault = XML_FALSE; } poolClear(&tempPool); break; @@ -3485,6 +3818,7 @@ doProlog(XML_Parser parser, enum XML_Error result; if (defaultHandler) reportDefault(parser, enc, s, next); + handleDefault = XML_FALSE; result = doIgnoreSection(parser, enc, &next, end, nextPtr); if (!next) { processor = ignoreSectionProcessor; @@ -3496,48 +3830,55 @@ doProlog(XML_Parser parser, case XML_ROLE_GROUP_OPEN: if (prologState.level >= groupSize) { if (groupSize) { - char *temp = REALLOC(groupConnector, groupSize *= 2); + char *temp = (char *)REALLOC(groupConnector, groupSize *= 2); if (temp == NULL) return XML_ERROR_NO_MEMORY; groupConnector = temp; - if (dtd.scaffIndex) { - int *temp = REALLOC(dtd.scaffIndex, groupSize * sizeof(int)); + if (dtd->scaffIndex) { + int *temp = (int *)REALLOC(dtd->scaffIndex, + groupSize * sizeof(int)); if (temp == NULL) return XML_ERROR_NO_MEMORY; - dtd.scaffIndex = temp; + dtd->scaffIndex = temp; } } else { - groupConnector = MALLOC(groupSize = 32); + groupConnector = (char *)MALLOC(groupSize = 32); if (!groupConnector) return XML_ERROR_NO_MEMORY; } } groupConnector[prologState.level] = 0; - if (dtd.in_eldecl) { + if (dtd->in_eldecl) { int myindex = nextScaffoldPart(parser); if (myindex < 0) return XML_ERROR_NO_MEMORY; - dtd.scaffIndex[dtd.scaffLevel] = myindex; - dtd.scaffLevel++; - dtd.scaffold[myindex].type = XML_CTYPE_SEQ; + dtd->scaffIndex[dtd->scaffLevel] = myindex; + dtd->scaffLevel++; + dtd->scaffold[myindex].type = XML_CTYPE_SEQ; + if (elementDeclHandler) + handleDefault = XML_FALSE; } break; case XML_ROLE_GROUP_SEQUENCE: if (groupConnector[prologState.level] == '|') return XML_ERROR_SYNTAX; groupConnector[prologState.level] = ','; + if (dtd->in_eldecl && elementDeclHandler) + handleDefault = XML_FALSE; break; case XML_ROLE_GROUP_CHOICE: if (groupConnector[prologState.level] == ',') return XML_ERROR_SYNTAX; - if (dtd.in_eldecl + if (dtd->in_eldecl && !groupConnector[prologState.level] - && (dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel - 1]].type + && (dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type != XML_CTYPE_MIXED) ) { - dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel - 1]].type + dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type = XML_CTYPE_CHOICE; + if (elementDeclHandler) + handleDefault = XML_FALSE; } groupConnector[prologState.level] = '|'; break; @@ -3549,34 +3890,39 @@ doProlog(XML_Parser parser, if (prologState.documentEntity && role == XML_ROLE_INNER_PARAM_ENTITY_REF) return XML_ERROR_PARAM_ENTITY_REF; + dtd->hasParamEntityRefs = XML_TRUE; if (!paramEntityParsing) - dtd.keepProcessing = 0; + dtd->keepProcessing = dtd->standalone; else { const XML_Char *name; ENTITY *entity; - name = poolStoreString(&dtd.pool, enc, + name = poolStoreString(&dtd->pool, enc, s + enc->minBytesPerChar, next - enc->minBytesPerChar); if (!name) return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(&dtd.paramEntities, name, 0); - poolDiscard(&dtd.pool); + entity = (ENTITY *)lookup(&dtd->paramEntities, name, 0); + poolDiscard(&dtd->pool); /* first, determine if a check for an existing declaration is needed; if yes, check that the entity exists, and that it is internal, otherwise call the skipped entity handler */ if (prologState.documentEntity && - (dtd.standalone ? !openInternalEntities : !dtd.hasParamEntities)) { + (dtd->standalone + ? !openInternalEntities + : !dtd->hasParamEntityRefs)) { if (!entity) return XML_ERROR_UNDEFINED_ENTITY; else if (!entity->is_internal) return XML_ERROR_ENTITY_DECLARED_IN_PE; } else if (!entity) { - dtd.keepProcessing = 0; + dtd->keepProcessing = dtd->standalone; /* cannot report skipped entities in declarations */ - if ((role == XML_ROLE_PARAM_ENTITY_REF) && skippedEntityHandler) + if ((role == XML_ROLE_PARAM_ENTITY_REF) && skippedEntityHandler) { skippedEntityHandler(handlerArg, name, 1); + handleDefault = XML_FALSE; + } break; } if (entity->open) @@ -3586,55 +3932,56 @@ doProlog(XML_Parser parser, result = processInternalParamEntity(parser, entity); if (result != XML_ERROR_NONE) return result; + handleDefault = XML_FALSE; break; } if (externalEntityRefHandler) { - dtd.paramEntityRead = 0; - entity->open = 1; + dtd->paramEntityRead = XML_FALSE; + entity->open = XML_TRUE; if (!externalEntityRefHandler(externalEntityRefHandlerArg, 0, entity->base, entity->systemId, entity->publicId)) { - entity->open = 0; + entity->open = XML_FALSE; return XML_ERROR_EXTERNAL_ENTITY_HANDLING; } - entity->open = 0; - if (!dtd.paramEntityRead) { - dtd.keepProcessing = 0; + entity->open = XML_FALSE; + handleDefault = XML_FALSE; + if (!dtd->paramEntityRead) { + dtd->keepProcessing = dtd->standalone; break; } } + else { + dtd->keepProcessing = dtd->standalone; + break; + } } #endif /* XML_DTD */ - if (!dtd.standalone - && notStandaloneHandler - && !notStandaloneHandler(handlerArg)) + if (!dtd->standalone && + notStandaloneHandler && + !notStandaloneHandler(handlerArg)) return XML_ERROR_NOT_STANDALONE; - if ( -#ifdef XML_DTD - !paramEntityParsing && -#endif /* XML_DTD */ - defaultHandler) - reportDefault(parser, enc, s, next); break; - /* Element declaration stuff */ + /* Element declaration stuff */ case XML_ROLE_ELEMENT_NAME: if (elementDeclHandler) { - declElementType = getElementType(parser, enc, s, next); + declElementType = getElementType(parser, enc, s, next); if (!declElementType) - return XML_ERROR_NO_MEMORY; - dtd.scaffLevel = 0; - dtd.scaffCount = 0; - dtd.in_eldecl = 1; + return XML_ERROR_NO_MEMORY; + dtd->scaffLevel = 0; + dtd->scaffCount = 0; + dtd->in_eldecl = XML_TRUE; + handleDefault = XML_FALSE; } break; case XML_ROLE_CONTENT_ANY: case XML_ROLE_CONTENT_EMPTY: - if (dtd.in_eldecl) { + if (dtd->in_eldecl) { if (elementDeclHandler) { XML_Content * content = (XML_Content *) MALLOC(sizeof(XML_Content)); if (!content) @@ -3648,15 +3995,18 @@ doProlog(XML_Parser parser, XML_CTYPE_EMPTY); *eventEndPP = s; elementDeclHandler(handlerArg, declElementType->name, content); + handleDefault = XML_FALSE; } - dtd.in_eldecl = 0; + dtd->in_eldecl = XML_FALSE; } break; case XML_ROLE_CONTENT_PCDATA: - if (dtd.in_eldecl) { - dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel - 1]].type + if (dtd->in_eldecl) { + dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type = XML_CTYPE_MIXED; + if (elementDeclHandler) + handleDefault = XML_FALSE; } break; @@ -3672,7 +4022,7 @@ doProlog(XML_Parser parser, case XML_ROLE_CONTENT_ELEMENT_PLUS: quant = XML_CQUANT_PLUS; elementContent: - if (dtd.in_eldecl) { + if (dtd->in_eldecl) { ELEMENT_TYPE *el; const XML_Char *name; int nameLen; @@ -3682,16 +4032,18 @@ doProlog(XML_Parser parser, int myindex = nextScaffoldPart(parser); if (myindex < 0) return XML_ERROR_NO_MEMORY; - dtd.scaffold[myindex].type = XML_CTYPE_NAME; - dtd.scaffold[myindex].quant = quant; + dtd->scaffold[myindex].type = XML_CTYPE_NAME; + dtd->scaffold[myindex].quant = quant; el = getElementType(parser, enc, s, nxt); if (!el) return XML_ERROR_NO_MEMORY; name = el->name; - dtd.scaffold[myindex].name = name; + dtd->scaffold[myindex].name = name; nameLen = 0; for (; name[nameLen++]; ); - dtd.contentStringLen += nameLen; + dtd->contentStringLen += nameLen; + if (elementDeclHandler) + handleDefault = XML_FALSE; } break; @@ -3707,56 +4059,67 @@ doProlog(XML_Parser parser, case XML_ROLE_GROUP_CLOSE_PLUS: quant = XML_CQUANT_PLUS; closeGroup: - if (dtd.in_eldecl) { - dtd.scaffLevel--; - dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel]].quant = quant; - if (dtd.scaffLevel == 0) { - if (elementDeclHandler) { + if (dtd->in_eldecl) { + if (elementDeclHandler) + handleDefault = XML_FALSE; + dtd->scaffLevel--; + dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel]].quant = quant; + if (dtd->scaffLevel == 0) { + if (!handleDefault) { XML_Content *model = build_model(parser); if (!model) return XML_ERROR_NO_MEMORY; *eventEndPP = s; elementDeclHandler(handlerArg, declElementType->name, model); } - dtd.in_eldecl = 0; - dtd.contentStringLen = 0; + dtd->in_eldecl = XML_FALSE; + dtd->contentStringLen = 0; } } break; /* End element declaration stuff */ + case XML_ROLE_PI: + if (!reportProcessingInstruction(parser, enc, s, next)) + return XML_ERROR_NO_MEMORY; + handleDefault = XML_FALSE; + break; + case XML_ROLE_COMMENT: + if (!reportComment(parser, enc, s, next)) + return XML_ERROR_NO_MEMORY; + handleDefault = XML_FALSE; + break; case XML_ROLE_NONE: switch (tok) { - case XML_TOK_PI: - if (!reportProcessingInstruction(parser, enc, s, next)) - return XML_ERROR_NO_MEMORY; - break; - case XML_TOK_COMMENT: - if (!reportComment(parser, enc, s, next)) - return XML_ERROR_NO_MEMORY; + case XML_TOK_BOM: + handleDefault = XML_FALSE; break; } break; + case XML_ROLE_DOCTYPE_NONE: + if (startDoctypeDeclHandler) + handleDefault = XML_FALSE; + break; + case XML_ROLE_ENTITY_NONE: + if (dtd->keepProcessing && entityDeclHandler) + handleDefault = XML_FALSE; + break; + case XML_ROLE_NOTATION_NONE: + if (notationDeclHandler) + handleDefault = XML_FALSE; + break; + case XML_ROLE_ATTLIST_NONE: + if (dtd->keepProcessing && attlistDeclHandler) + handleDefault = XML_FALSE; + break; + case XML_ROLE_ELEMENT_NONE: + if (elementDeclHandler) + handleDefault = XML_FALSE; + break; } /* end of big switch */ - if (defaultHandler) { - switch (tok) { - case XML_TOK_PI: - case XML_TOK_COMMENT: - case XML_TOK_BOM: - case XML_TOK_XML_DECL: -#ifdef XML_DTD - case XML_TOK_IGNORE_SECT: -#endif /* XML_DTD */ - case XML_TOK_PARAM_ENTITY_REF: - break; - default: -#ifdef XML_DTD - if (role != XML_ROLE_IGNORE_SECT) -#endif /* XML_DTD */ - reportDefault(parser, enc, s, next); - } - } + if (handleDefault && defaultHandler) + reportDefault(parser, enc, s, next); s = next; tok = XmlPrologTok(enc, s, end, &next); @@ -3764,7 +4127,7 @@ doProlog(XML_Parser parser, /* not reached */ } -static enum XML_Error +static enum XML_Error PTRCALL epilogProcessor(XML_Parser parser, const char *s, const char *end, @@ -3777,15 +4140,18 @@ epilogProcessor(XML_Parser parser, int tok = XmlPrologTok(encoding, s, end, &next); eventEndPtr = next; switch (tok) { + /* report partial linebreak - it might be the last token */ case -XML_TOK_PROLOG_S: if (defaultHandler) { - eventEndPtr = end; - reportDefault(parser, encoding, s, end); + eventEndPtr = next; + reportDefault(parser, encoding, s, next); } - /* fall through */ + if (nextPtr) + *nextPtr = next; + return XML_ERROR_NONE; case XML_TOK_NONE: if (nextPtr) - *nextPtr = end; + *nextPtr = s; return XML_ERROR_NONE; case XML_TOK_PROLOG_S: if (defaultHandler) @@ -3830,7 +4196,7 @@ processInternalParamEntity(XML_Parser parser, ENTITY *entity) int tok; enum XML_Error result; OPEN_INTERNAL_ENTITY openEntity; - entity->open = 1; + entity->open = XML_TRUE; openEntity.next = openInternalEntities; openInternalEntities = &openEntity; openEntity.entity = entity; @@ -3838,17 +4204,16 @@ processInternalParamEntity(XML_Parser parser, ENTITY *entity) openEntity.internalEventEndPtr = NULL; s = (char *)entity->textPtr; end = (char *)(entity->textPtr + entity->textLen); - dtd.hasParamEntities = 1; tok = XmlPrologTok(internalEncoding, s, end, &next); result = doProlog(parser, internalEncoding, s, end, tok, next, 0); - entity->open = 0; + entity->open = XML_FALSE; openInternalEntities = openEntity.next; return result; } #endif /* XML_DTD */ -static enum XML_Error +static enum XML_Error PTRCALL errorProcessor(XML_Parser parser, const char *s, const char *end, @@ -3858,7 +4223,7 @@ errorProcessor(XML_Parser parser, } static enum XML_Error -storeAttributeValue(XML_Parser parser, const ENCODING *enc, int isCdata, +storeAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, const char *ptr, const char *end, STRING_POOL *pool) { @@ -3874,10 +4239,11 @@ storeAttributeValue(XML_Parser parser, const ENCODING *enc, int isCdata, } static enum XML_Error -appendAttributeValue(XML_Parser parser, const ENCODING *enc, int isCdata, +appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, const char *ptr, const char *end, STRING_POOL *pool) { + DTD * const dtd = _dtd; /* save one level of indirection */ for (;;) { const char *next; int tok = XmlAttributeValueTok(enc, ptr, end, &next); @@ -3950,20 +4316,22 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, int isCdata, next - enc->minBytesPerChar); if (!name) return XML_ERROR_NO_MEMORY; - entity = (ENTITY *)lookup(&dtd.generalEntities, name, 0); + entity = (ENTITY *)lookup(&dtd->generalEntities, name, 0); poolDiscard(&temp2Pool); /* first, determine if a check for an existing declaration is needed; if yes, check that the entity exists, and that it is internal, otherwise call the default handler (if called from content) */ - if (pool == &dtd.pool) /* are we called from prolog? */ + if (pool == &dtd->pool) /* are we called from prolog? */ checkEntityDecl = #ifdef XML_DTD prologState.documentEntity && #endif /* XML_DTD */ - (dtd.standalone ? !openInternalEntities : !dtd.hasParamEntities); + (dtd->standalone + ? !openInternalEntities + : !dtd->hasParamEntityRefs); else /* if (pool == &tempPool): we are called from content */ - checkEntityDecl = !dtd.hasParamEntities || dtd.standalone; + checkEntityDecl = !dtd->hasParamEntityRefs || dtd->standalone; if (checkEntityDecl) { if (!entity) return XML_ERROR_UNDEFINED_ENTITY; @@ -3998,11 +4366,11 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, int isCdata, else { enum XML_Error result; const XML_Char *textEnd = entity->textPtr + entity->textLen; - entity->open = 1; + entity->open = XML_TRUE; result = appendAttributeValue(parser, internalEncoding, isCdata, (char *)entity->textPtr, (char *)textEnd, pool); - entity->open = 0; + entity->open = XML_FALSE; if (result) return result; } @@ -4024,7 +4392,8 @@ storeEntityValue(XML_Parser parser, const char *entityTextPtr, const char *entityTextEnd) { - STRING_POOL *pool = &(dtd.entityValuePool); + DTD * const dtd = _dtd; /* save one level of indirection */ + STRING_POOL *pool = &(dtd->entityValuePool); enum XML_Error result = XML_ERROR_NONE; #ifdef XML_DTD int oldInEntityValue = prologState.inEntityValue; @@ -4054,7 +4423,7 @@ storeEntityValue(XML_Parser parser, result = XML_ERROR_NO_MEMORY; goto endEntityValue; } - entity = (ENTITY *)lookup(&dtd.paramEntities, name, 0); + entity = (ENTITY *)lookup(&dtd->paramEntities, name, 0); poolDiscard(&tempPool); if (!entity) { /* not a well-formedness error - see XML 1.0: WFC Entity Declared */ @@ -4063,7 +4432,7 @@ storeEntityValue(XML_Parser parser, if (skippedEntityHandler) skippedEntityHandler(handlerArg, name, 0); */ - dtd.keepProcessing = 0; + dtd->keepProcessing = dtd->standalone; goto endEntityValue; } if (entity->open) { @@ -4074,30 +4443,32 @@ storeEntityValue(XML_Parser parser, } if (entity->systemId) { if (externalEntityRefHandler) { - dtd.paramEntityRead = 0; - entity->open = 1; + dtd->paramEntityRead = XML_FALSE; + entity->open = XML_TRUE; if (!externalEntityRefHandler(externalEntityRefHandlerArg, 0, entity->base, entity->systemId, entity->publicId)) { - entity->open = 0; + entity->open = XML_FALSE; result = XML_ERROR_EXTERNAL_ENTITY_HANDLING; goto endEntityValue; } - entity->open = 0; - if (!dtd.paramEntityRead) - dtd.keepProcessing = 0; + entity->open = XML_FALSE; + if (!dtd->paramEntityRead) + dtd->keepProcessing = dtd->standalone; } + else + dtd->keepProcessing = dtd->standalone; } else { - entity->open = 1; + entity->open = XML_TRUE; result = storeEntityValue(parser, internalEncoding, (char *)entity->textPtr, (char *)(entity->textPtr + entity->textLen)); - entity->open = 0; + entity->open = XML_FALSE; if (result) goto endEntityValue; } @@ -4181,7 +4552,7 @@ endEntityValue: return result; } -static void +static void FASTCALL normalizeLines(XML_Char *s) { XML_Char *p; @@ -4284,8 +4655,8 @@ reportDefault(XML_Parser parser, const ENCODING *enc, static int -defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, int isCdata, - int isId, const XML_Char *value, XML_Parser parser) +defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata, + XML_Bool isId, const XML_Char *value, XML_Parser parser) { DEFAULT_ATTRIBUTE *att; if (value || isId) { @@ -4301,15 +4672,16 @@ defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, int isCdata, if (type->nDefaultAtts == type->allocDefaultAtts) { if (type->allocDefaultAtts == 0) { type->allocDefaultAtts = 8; - type->defaultAtts = MALLOC(type->allocDefaultAtts - * sizeof(DEFAULT_ATTRIBUTE)); + type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(type->allocDefaultAtts + * sizeof(DEFAULT_ATTRIBUTE)); if (!type->defaultAtts) return 0; } else { DEFAULT_ATTRIBUTE *temp; int count = type->allocDefaultAtts * 2; - temp = REALLOC(type->defaultAtts, (count * sizeof(DEFAULT_ATTRIBUTE))); + temp = (DEFAULT_ATTRIBUTE *) + REALLOC(type->defaultAtts, (count * sizeof(DEFAULT_ATTRIBUTE))); if (temp == NULL) return 0; type->allocDefaultAtts = count; @@ -4319,9 +4691,9 @@ defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, int isCdata, att = type->defaultAtts + type->nDefaultAtts; att->id = attId; att->value = value; - att->isCdata = (char)isCdata; + att->isCdata = isCdata; if (!isCdata) - attId->maybeTokenized = 1; + attId->maybeTokenized = XML_TRUE; type->nDefaultAtts += 1; return 1; } @@ -4329,25 +4701,26 @@ defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, int isCdata, static int setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) { + DTD * const dtd = _dtd; /* save one level of indirection */ const XML_Char *name; for (name = elementType->name; *name; name++) { if (*name == XML_T(':')) { PREFIX *prefix; const XML_Char *s; for (s = elementType->name; s != name; s++) { - if (!poolAppendChar(&dtd.pool, *s)) + if (!poolAppendChar(&dtd->pool, *s)) return 0; } - if (!poolAppendChar(&dtd.pool, XML_T('\0'))) + if (!poolAppendChar(&dtd->pool, XML_T('\0'))) return 0; - prefix = (PREFIX *)lookup(&dtd.prefixes, poolStart(&dtd.pool), + prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&dtd->pool), sizeof(PREFIX)); if (!prefix) return 0; - if (prefix->name == poolStart(&dtd.pool)) - poolFinish(&dtd.pool); + if (prefix->name == poolStart(&dtd->pool)) + poolFinish(&dtd->pool); else - poolDiscard(&dtd.pool); + poolDiscard(&dtd->pool); elementType->prefix = prefix; } @@ -4359,34 +4732,35 @@ static ATTRIBUTE_ID * getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, const char *end) { + DTD * const dtd = _dtd; /* save one level of indirection */ ATTRIBUTE_ID *id; const XML_Char *name; - if (!poolAppendChar(&dtd.pool, XML_T('\0'))) + if (!poolAppendChar(&dtd->pool, XML_T('\0'))) return NULL; - name = poolStoreString(&dtd.pool, enc, start, end); + name = poolStoreString(&dtd->pool, enc, start, end); if (!name) return NULL; ++name; - id = (ATTRIBUTE_ID *)lookup(&dtd.attributeIds, name, sizeof(ATTRIBUTE_ID)); + id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, name, sizeof(ATTRIBUTE_ID)); if (!id) return NULL; if (id->name != name) - poolDiscard(&dtd.pool); + poolDiscard(&dtd->pool); else { - poolFinish(&dtd.pool); + poolFinish(&dtd->pool); if (!ns) ; - else if (name[0] == 'x' - && name[1] == 'm' - && name[2] == 'l' - && name[3] == 'n' - && name[4] == 's' + else if (name[0] == XML_T('x') + && name[1] == XML_T('m') + && name[2] == XML_T('l') + && name[3] == XML_T('n') + && name[4] == XML_T('s') && (name[5] == XML_T('\0') || name[5] == XML_T(':'))) { - if (name[5] == '\0') - id->prefix = &dtd.defaultPrefix; + if (name[5] == XML_T('\0')) + id->prefix = &dtd->defaultPrefix; else - id->prefix = (PREFIX *)lookup(&dtd.prefixes, name + 6, sizeof(PREFIX)); - id->xmlns = 1; + id->prefix = (PREFIX *)lookup(&dtd->prefixes, name + 6, sizeof(PREFIX)); + id->xmlns = XML_TRUE; } else { int i; @@ -4394,17 +4768,17 @@ getAttributeId(XML_Parser parser, const ENCODING *enc, if (name[i] == XML_T(':')) { int j; for (j = 0; j < i; j++) { - if (!poolAppendChar(&dtd.pool, name[j])) + if (!poolAppendChar(&dtd->pool, name[j])) return NULL; } - if (!poolAppendChar(&dtd.pool, XML_T('\0'))) + if (!poolAppendChar(&dtd->pool, XML_T('\0'))) return NULL; - id->prefix = (PREFIX *)lookup(&dtd.prefixes, poolStart(&dtd.pool), + id->prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&dtd->pool), sizeof(PREFIX)); - if (id->prefix->name == poolStart(&dtd.pool)) - poolFinish(&dtd.pool); + if (id->prefix->name == poolStart(&dtd->pool)) + poolFinish(&dtd->pool); else - poolDiscard(&dtd.pool); + poolDiscard(&dtd->pool); break; } } @@ -4418,24 +4792,25 @@ getAttributeId(XML_Parser parser, const ENCODING *enc, static const XML_Char * getContext(XML_Parser parser) { + DTD * const dtd = _dtd; /* save one level of indirection */ HASH_TABLE_ITER iter; - int needSep = 0; + XML_Bool needSep = XML_FALSE; - if (dtd.defaultPrefix.binding) { + if (dtd->defaultPrefix.binding) { int i; int len; if (!poolAppendChar(&tempPool, XML_T('='))) return NULL; - len = dtd.defaultPrefix.binding->uriLen; + len = dtd->defaultPrefix.binding->uriLen; if (namespaceSeparator != XML_T('\0')) len--; for (i = 0; i < len; i++) - if (!poolAppendChar(&tempPool, dtd.defaultPrefix.binding->uri[i])) + if (!poolAppendChar(&tempPool, dtd->defaultPrefix.binding->uri[i])) return NULL; - needSep = 1; + needSep = XML_TRUE; } - hashTableIterInit(&iter, &(dtd.prefixes)); + hashTableIterInit(&iter, &(dtd->prefixes)); for (;;) { int i; int len; @@ -4458,11 +4833,11 @@ getContext(XML_Parser parser) for (i = 0; i < len; i++) if (!poolAppendChar(&tempPool, prefix->binding->uri[i])) return NULL; - needSep = 1; + needSep = XML_TRUE; } - hashTableIterInit(&iter, &(dtd.generalEntities)); + hashTableIterInit(&iter, &(dtd->generalEntities)); for (;;) { const XML_Char *s; ENTITY *e = (ENTITY *)hashTableIterNext(&iter); @@ -4475,7 +4850,7 @@ getContext(XML_Parser parser) for (s = e->name; *s; s++) if (!poolAppendChar(&tempPool, *s)) return 0; - needSep = 1; + needSep = XML_TRUE; } if (!poolAppendChar(&tempPool, XML_T('\0'))) @@ -4483,19 +4858,20 @@ getContext(XML_Parser parser) return tempPool.start; } -static int +static XML_Bool setContext(XML_Parser parser, const XML_Char *context) { + DTD * const dtd = _dtd; /* save one level of indirection */ const XML_Char *s = context; while (*context != XML_T('\0')) { if (*s == CONTEXT_SEP || *s == XML_T('\0')) { ENTITY *e; if (!poolAppendChar(&tempPool, XML_T('\0'))) - return 0; - e = (ENTITY *)lookup(&dtd.generalEntities, poolStart(&tempPool), 0); + return XML_FALSE; + e = (ENTITY *)lookup(&dtd->generalEntities, poolStart(&tempPool), 0); if (e) - e->open = 1; + e->open = XML_TRUE; if (*s != XML_T('\0')) s++; context = s; @@ -4504,18 +4880,18 @@ setContext(XML_Parser parser, const XML_Char *context) else if (*s == XML_T('=')) { PREFIX *prefix; if (poolLength(&tempPool) == 0) - prefix = &dtd.defaultPrefix; + prefix = &dtd->defaultPrefix; else { if (!poolAppendChar(&tempPool, XML_T('\0'))) - return 0; - prefix = (PREFIX *)lookup(&dtd.prefixes, poolStart(&tempPool), + return XML_FALSE; + prefix = (PREFIX *)lookup(&dtd->prefixes, poolStart(&tempPool), sizeof(PREFIX)); if (!prefix) - return 0; + return XML_FALSE; if (prefix->name == poolStart(&tempPool)) { - prefix->name = poolCopyString(&dtd.pool, prefix->name); + prefix->name = poolCopyString(&dtd->pool, prefix->name); if (!prefix->name) - return 0; + return XML_FALSE; } poolDiscard(&tempPool); } @@ -4523,12 +4899,12 @@ setContext(XML_Parser parser, const XML_Char *context) *context != CONTEXT_SEP && *context != XML_T('\0'); context++) if (!poolAppendChar(&tempPool, *context)) - return 0; + return XML_FALSE; if (!poolAppendChar(&tempPool, XML_T('\0'))) - return 0; - if (!addBinding(parser, prefix, 0, poolStart(&tempPool), - &inheritedBindings)) - return 0; + return XML_FALSE; + if (addBinding(parser, prefix, 0, poolStart(&tempPool), + &inheritedBindings) != XML_ERROR_NONE) + return XML_FALSE; poolDiscard(&tempPool); if (*context != XML_T('\0')) ++context; @@ -4536,14 +4912,14 @@ setContext(XML_Parser parser, const XML_Char *context) } else { if (!poolAppendChar(&tempPool, *s)) - return 0; + return XML_FALSE; s++; } } - return 1; + return XML_TRUE; } -static void +static void FASTCALL normalizePublicId(XML_Char *publicId) { XML_Char *p = publicId; @@ -4565,10 +4941,12 @@ normalizePublicId(XML_Char *publicId) *p = XML_T('\0'); } -static int -dtdInit(DTD *p, XML_Parser parser) +static DTD * +dtdCreate(const XML_Memory_Handling_Suite *ms) { - XML_Memory_Handling_Suite *ms = &((Parser *) parser)->m_mem; + DTD *p = (DTD *)ms->malloc_fcn(sizeof(DTD)); + if (p == NULL) + return p; poolInit(&(p->pool), ms); #ifdef XML_DTD poolInit(&(p->entityValuePool), ms); @@ -4577,42 +4955,75 @@ dtdInit(DTD *p, XML_Parser parser) hashTableInit(&(p->elementTypes), ms); hashTableInit(&(p->attributeIds), ms); hashTableInit(&(p->prefixes), ms); - p->keepProcessing = 1; - p->paramEntityRead = 0; - p->hasParamEntities = 0; - p->standalone = 0; #ifdef XML_DTD + p->paramEntityRead = XML_FALSE; hashTableInit(&(p->paramEntities), ms); #endif /* XML_DTD */ p->defaultPrefix.name = NULL; p->defaultPrefix.binding = NULL; - p->in_eldecl = 0; - p->scaffIndex = 0; - p->scaffLevel = 0; + p->in_eldecl = XML_FALSE; + p->scaffIndex = NULL; p->scaffold = NULL; - p->contentStringLen = 0; + p->scaffLevel = 0; p->scaffSize = 0; p->scaffCount = 0; + p->contentStringLen = 0; - return 1; + p->keepProcessing = XML_TRUE; + p->hasParamEntityRefs = XML_FALSE; + p->standalone = XML_FALSE; + return p; } -#ifdef XML_DTD - static void -dtdSwap(DTD *p1, DTD *p2) +dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms) { - DTD tem; - memcpy(&tem, p1, sizeof(DTD)); - memcpy(p1, p2, sizeof(DTD)); - memcpy(p2, &tem, sizeof(DTD)); -} - + HASH_TABLE_ITER iter; + hashTableIterInit(&iter, &(p->elementTypes)); + for (;;) { + ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); + if (!e) + break; + if (e->allocDefaultAtts != 0) + ms->free_fcn(e->defaultAtts); + } + hashTableClear(&(p->generalEntities)); +#ifdef XML_DTD + p->paramEntityRead = XML_FALSE; + hashTableClear(&(p->paramEntities)); +#endif /* XML_DTD */ + hashTableClear(&(p->elementTypes)); + hashTableClear(&(p->attributeIds)); + hashTableClear(&(p->prefixes)); + poolClear(&(p->pool)); +#ifdef XML_DTD + poolClear(&(p->entityValuePool)); #endif /* XML_DTD */ + p->defaultPrefix.name = NULL; + p->defaultPrefix.binding = NULL; + + p->in_eldecl = XML_FALSE; + if (p->scaffIndex) { + ms->free_fcn(p->scaffIndex); + p->scaffIndex = NULL; + } + if (p->scaffold) { + ms->free_fcn(p->scaffold); + p->scaffold = NULL; + } + p->scaffLevel = 0; + p->scaffSize = 0; + p->scaffCount = 0; + p->contentStringLen = 0; + + p->keepProcessing = XML_TRUE; + p->hasParamEntityRefs = XML_FALSE; + p->standalone = XML_FALSE; +} static void -dtdDestroy(DTD *p, XML_Parser parser) +dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms) { HASH_TABLE_ITER iter; hashTableIterInit(&iter, &(p->elementTypes)); @@ -4621,7 +5032,7 @@ dtdDestroy(DTD *p, XML_Parser parser) if (!e) break; if (e->allocDefaultAtts != 0) - FREE(e->defaultAtts); + ms->free_fcn(e->defaultAtts); } hashTableDestroy(&(p->generalEntities)); #ifdef XML_DTD @@ -4634,19 +5045,20 @@ dtdDestroy(DTD *p, XML_Parser parser) #ifdef XML_DTD poolDestroy(&(p->entityValuePool)); #endif /* XML_DTD */ - if (!parentParser) { + if (isDocEntity) { if (p->scaffIndex) - FREE(p->scaffIndex); + ms->free_fcn(p->scaffIndex); if (p->scaffold) - FREE(p->scaffold); + ms->free_fcn(p->scaffold); } + ms->free_fcn(p); } -/* Do a deep copy of the DTD. Return 0 for out of memory; non-zero otherwise. +/* Do a deep copy of the DTD. Return 0 for out of memory, non-zero otherwise. The new DTD has already been initialized. */ static int -dtdCopy(DTD *newDtd, const DTD *oldDtd, XML_Parser parser) +dtdCopy(DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms) { HASH_TABLE_ITER iter; @@ -4718,9 +5130,9 @@ dtdCopy(DTD *newDtd, const DTD *oldDtd, XML_Parser parser) return 0; if (oldE->nDefaultAtts) { newE->defaultAtts = (DEFAULT_ATTRIBUTE *) - MALLOC(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE)); + ms->malloc_fcn(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE)); if (!newE->defaultAtts) { - FREE(newE); + ms->free_fcn(newE); return 0; } } @@ -4749,19 +5161,19 @@ dtdCopy(DTD *newDtd, const DTD *oldDtd, XML_Parser parser) /* Copy the entity tables. */ if (!copyEntityTable(&(newDtd->generalEntities), &(newDtd->pool), - &(oldDtd->generalEntities), parser)) + &(oldDtd->generalEntities))) return 0; #ifdef XML_DTD if (!copyEntityTable(&(newDtd->paramEntities), &(newDtd->pool), - &(oldDtd->paramEntities), parser)) + &(oldDtd->paramEntities))) return 0; + newDtd->paramEntityRead = oldDtd->paramEntityRead; #endif /* XML_DTD */ newDtd->keepProcessing = oldDtd->keepProcessing; - newDtd->paramEntityRead = oldDtd->paramEntityRead; - newDtd->hasParamEntities = oldDtd->hasParamEntities; + newDtd->hasParamEntityRefs = oldDtd->hasParamEntityRefs; newDtd->standalone = oldDtd->standalone; /* Don't want deep copying for scaffolding */ @@ -4778,8 +5190,7 @@ dtdCopy(DTD *newDtd, const DTD *oldDtd, XML_Parser parser) static int copyEntityTable(HASH_TABLE *newTable, STRING_POOL *newPool, - const HASH_TABLE *oldTable, - XML_Parser parser) + const HASH_TABLE *oldTable) { HASH_TABLE_ITER iter; const XML_Char *cachedOldBase = NULL; @@ -4844,7 +5255,7 @@ copyEntityTable(HASH_TABLE *newTable, #define INIT_SIZE 64 -static int +static int FASTCALL keyeq(KEY s1, KEY s2) { for (; *s1 == *s2; s1++, s2++) @@ -4853,7 +5264,7 @@ keyeq(KEY s1, KEY s2) return 0; } -static unsigned long +static unsigned long FASTCALL hash(KEY s) { unsigned long h = 0; @@ -4872,7 +5283,7 @@ lookup(HASH_TABLE *table, KEY name, size_t createSize) if (!createSize) return NULL; tsize = INIT_SIZE * sizeof(NAMED *); - table->v = table->mem->malloc_fcn(tsize); + table->v = (NAMED **)table->mem->malloc_fcn(tsize); if (!table->v) return NULL; memset(table->v, 0, tsize); @@ -4894,7 +5305,7 @@ lookup(HASH_TABLE *table, KEY name, size_t createSize) /* check for overflow */ size_t newSize = table->size * 2; size_t tsize = newSize * sizeof(NAMED *); - NAMED **newV = table->mem->malloc_fcn(tsize); + NAMED **newV = (NAMED **)table->mem->malloc_fcn(tsize); if (!newV) return NULL; memset(newV, 0, tsize); @@ -4917,7 +5328,7 @@ lookup(HASH_TABLE *table, KEY name, size_t createSize) ; } } - table->v[i] = table->mem->malloc_fcn(createSize); + table->v[i] = (NAMED *)table->mem->malloc_fcn(createSize); if (!table->v[i]) return NULL; memset(table->v[i], 0, createSize); @@ -4926,7 +5337,22 @@ lookup(HASH_TABLE *table, KEY name, size_t createSize) return table->v[i]; } -static void +static void FASTCALL +hashTableClear(HASH_TABLE *table) +{ + size_t i; + for (i = 0; i < table->size; i++) { + NAMED *p = table->v[i]; + if (p) { + table->mem->free_fcn(p); + table->v[i] = NULL; + } + } + table->usedLim = table->size / 2; + table->used = 0; +} + +static void FASTCALL hashTableDestroy(HASH_TABLE *table) { size_t i; @@ -4939,24 +5365,24 @@ hashTableDestroy(HASH_TABLE *table) table->mem->free_fcn(table->v); } -static void -hashTableInit(HASH_TABLE *p, XML_Memory_Handling_Suite *ms) +static void FASTCALL +hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms) { p->size = 0; p->usedLim = 0; p->used = 0; - p->v = 0; + p->v = NULL; p->mem = ms; } -static void +static void FASTCALL hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table) { iter->p = table->v; iter->end = iter->p + table->size; } -static NAMED * +static NAMED * FASTCALL hashTableIterNext(HASH_TABLE_ITER *iter) { while (iter->p != iter->end) { @@ -4967,18 +5393,18 @@ hashTableIterNext(HASH_TABLE_ITER *iter) return NULL; } -static void -poolInit(STRING_POOL *pool, XML_Memory_Handling_Suite *ms) +static void FASTCALL +poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms) { - pool->blocks = 0; - pool->freeBlocks = 0; - pool->start = 0; - pool->ptr = 0; - pool->end = 0; + pool->blocks = NULL; + pool->freeBlocks = NULL; + pool->start = NULL; + pool->ptr = NULL; + pool->end = NULL; pool->mem = ms; } -static void +static void FASTCALL poolClear(STRING_POOL *pool) { if (!pool->freeBlocks) @@ -4992,13 +5418,13 @@ poolClear(STRING_POOL *pool) p = tem; } } - pool->blocks = 0; - pool->start = 0; - pool->ptr = 0; - pool->end = 0; + pool->blocks = NULL; + pool->start = NULL; + pool->ptr = NULL; + pool->end = NULL; } -static void +static void FASTCALL poolDestroy(STRING_POOL *pool) { BLOCK *p = pool->blocks; @@ -5007,17 +5433,12 @@ poolDestroy(STRING_POOL *pool) pool->mem->free_fcn(p); p = tem; } - pool->blocks = 0; p = pool->freeBlocks; while (p) { BLOCK *tem = p->next; pool->mem->free_fcn(p); p = tem; } - pool->freeBlocks = 0; - pool->ptr = 0; - pool->start = 0; - pool->end = 0; } static XML_Char * @@ -5036,7 +5457,7 @@ poolAppend(STRING_POOL *pool, const ENCODING *enc, return pool->start; } -static const XML_Char * +static const XML_Char * FASTCALL poolCopyString(STRING_POOL *pool, const XML_Char *s) { do { @@ -5062,7 +5483,7 @@ poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) return s; } -static const XML_Char * +static const XML_Char * FASTCALL poolAppendString(STRING_POOL *pool, const XML_Char *s) { while (*s) { @@ -5085,7 +5506,7 @@ poolStoreString(STRING_POOL *pool, const ENCODING *enc, return pool->start; } -static int +static XML_Bool FASTCALL poolGrow(STRING_POOL *pool) { if (pool->freeBlocks) { @@ -5096,7 +5517,7 @@ poolGrow(STRING_POOL *pool) pool->start = pool->blocks->s; pool->end = pool->start + pool->blocks->size; pool->ptr = pool->start; - return 1; + return XML_TRUE; } if (pool->end - pool->start < pool->freeBlocks->size) { BLOCK *tem = pool->freeBlocks->next; @@ -5108,16 +5529,17 @@ poolGrow(STRING_POOL *pool) pool->ptr = pool->blocks->s + (pool->ptr - pool->start); pool->start = pool->blocks->s; pool->end = pool->start + pool->blocks->size; - return 1; + return XML_TRUE; } } if (pool->blocks && pool->start == pool->blocks->s) { int blockSize = (pool->end - pool->start)*2; - pool->blocks = pool->mem->realloc_fcn(pool->blocks, - offsetof(BLOCK, s) - + blockSize * sizeof(XML_Char)); - if (!pool->blocks) - return 0; + pool->blocks = (BLOCK *) + pool->mem->realloc_fcn(pool->blocks, + (offsetof(BLOCK, s) + + blockSize * sizeof(XML_Char))); + if (pool->blocks == NULL) + return XML_FALSE; pool->blocks->size = blockSize; pool->ptr = pool->blocks->s + (pool->ptr - pool->start); pool->start = pool->blocks->s; @@ -5130,10 +5552,10 @@ poolGrow(STRING_POOL *pool) blockSize = INIT_BLOCK_SIZE; else blockSize *= 2; - tem = pool->mem->malloc_fcn(offsetof(BLOCK, s) - + blockSize * sizeof(XML_Char)); + tem = (BLOCK *)pool->mem->malloc_fcn(offsetof(BLOCK, s) + + blockSize * sizeof(XML_Char)); if (!tem) - return 0; + return XML_FALSE; tem->size = blockSize; tem->next = pool->blocks; pool->blocks = tem; @@ -5144,45 +5566,47 @@ poolGrow(STRING_POOL *pool) pool->start = tem->s; pool->end = tem->s + blockSize; } - return 1; + return XML_TRUE; } -static int +static int FASTCALL nextScaffoldPart(XML_Parser parser) { + DTD * const dtd = _dtd; /* save one level of indirection */ CONTENT_SCAFFOLD * me; int next; - if (!dtd.scaffIndex) { - dtd.scaffIndex = MALLOC(groupSize * sizeof(int)); - if (!dtd.scaffIndex) + if (!dtd->scaffIndex) { + dtd->scaffIndex = (int *)MALLOC(groupSize * sizeof(int)); + if (!dtd->scaffIndex) return -1; - dtd.scaffIndex[0] = 0; + dtd->scaffIndex[0] = 0; } - if (dtd.scaffCount >= dtd.scaffSize) { + if (dtd->scaffCount >= dtd->scaffSize) { CONTENT_SCAFFOLD *temp; - if (dtd.scaffold) { + if (dtd->scaffold) { temp = (CONTENT_SCAFFOLD *) - REALLOC(dtd.scaffold, dtd.scaffSize * 2 * sizeof(CONTENT_SCAFFOLD)); + REALLOC(dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD)); if (temp == NULL) return -1; - dtd.scaffSize *= 2; + dtd->scaffSize *= 2; } else { - temp = MALLOC(INIT_SCAFFOLD_ELEMENTS * sizeof(CONTENT_SCAFFOLD)); + temp = (CONTENT_SCAFFOLD *)MALLOC(INIT_SCAFFOLD_ELEMENTS + * sizeof(CONTENT_SCAFFOLD)); if (temp == NULL) return -1; - dtd.scaffSize = INIT_SCAFFOLD_ELEMENTS; + dtd->scaffSize = INIT_SCAFFOLD_ELEMENTS; } - dtd.scaffold = temp; + dtd->scaffold = temp; } - next = dtd.scaffCount++; - me = &dtd.scaffold[next]; - if (dtd.scaffLevel) { - CONTENT_SCAFFOLD *parent = &dtd.scaffold[dtd.scaffIndex[dtd.scaffLevel-1]]; + next = dtd->scaffCount++; + me = &dtd->scaffold[next]; + if (dtd->scaffLevel) { + CONTENT_SCAFFOLD *parent = &dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel-1]]; if (parent->lastchild) { - dtd.scaffold[parent->lastchild].nextsib = next; + dtd->scaffold[parent->lastchild].nextsib = next; } if (!parent->childcnt) parent->firstchild = next; @@ -5200,12 +5624,13 @@ build_node(XML_Parser parser, XML_Content **contpos, XML_Char **strpos) { - dest->type = dtd.scaffold[src_node].type; - dest->quant = dtd.scaffold[src_node].quant; + DTD * const dtd = _dtd; /* save one level of indirection */ + dest->type = dtd->scaffold[src_node].type; + dest->quant = dtd->scaffold[src_node].quant; if (dest->type == XML_CTYPE_NAME) { const XML_Char *src; dest->name = *strpos; - src = dtd.scaffold[src_node].name; + src = dtd->scaffold[src_node].name; for (;;) { *(*strpos)++ = *src; if (!*src) @@ -5218,12 +5643,12 @@ build_node(XML_Parser parser, else { unsigned int i; int cn; - dest->numchildren = dtd.scaffold[src_node].childcnt; + dest->numchildren = dtd->scaffold[src_node].childcnt; dest->children = *contpos; *contpos += dest->numchildren; - for (i = 0, cn = dtd.scaffold[src_node].firstchild; + for (i = 0, cn = dtd->scaffold[src_node].firstchild; i < dest->numchildren; - i++, cn = dtd.scaffold[cn].nextsib) { + i++, cn = dtd->scaffold[cn].nextsib) { build_node(parser, cn, &(dest->children[i]), contpos, strpos); } dest->name = NULL; @@ -5233,17 +5658,18 @@ build_node(XML_Parser parser, static XML_Content * build_model (XML_Parser parser) { + DTD * const dtd = _dtd; /* save one level of indirection */ XML_Content *ret; XML_Content *cpos; XML_Char * str; - int allocsize = (dtd.scaffCount * sizeof(XML_Content) - + (dtd.contentStringLen * sizeof(XML_Char))); + int allocsize = (dtd->scaffCount * sizeof(XML_Content) + + (dtd->contentStringLen * sizeof(XML_Char))); - ret = MALLOC(allocsize); + ret = (XML_Content *)MALLOC(allocsize); if (!ret) return NULL; - str = (XML_Char *) (&ret[dtd.scaffCount]); + str = (XML_Char *) (&ret[dtd->scaffCount]); cpos = &ret[1]; build_node(parser, 0, ret, &cpos, &str); @@ -5256,18 +5682,19 @@ getElementType(XML_Parser parser, const char *ptr, const char *end) { - const XML_Char *name = poolStoreString(&dtd.pool, enc, ptr, end); + DTD * const dtd = _dtd; /* save one level of indirection */ + const XML_Char *name = poolStoreString(&dtd->pool, enc, ptr, end); ELEMENT_TYPE *ret; if (!name) return NULL; - ret = (ELEMENT_TYPE *) lookup(&dtd.elementTypes, name, sizeof(ELEMENT_TYPE)); + ret = (ELEMENT_TYPE *) lookup(&dtd->elementTypes, name, sizeof(ELEMENT_TYPE)); if (!ret) return NULL; if (ret->name != name) - poolDiscard(&dtd.pool); + poolDiscard(&dtd->pool); else { - poolFinish(&dtd.pool); + poolFinish(&dtd->pool); if (!setElementTypePrefix(parser, ret)) return NULL; } diff --git a/extras/expat/lib/xmlrole.c b/extras/expat/lib/xmlrole.c index 30b87fd2d..8ef185d54 100644 --- a/extras/expat/lib/xmlrole.c +++ b/extras/expat/lib/xmlrole.c @@ -10,6 +10,7 @@ #include <expat_config.h> #endif /* ndef COMPILED_FROM_DSP */ +#include "internal.h" #include "xmlrole.h" #include "ascii.h" @@ -20,29 +21,56 @@ */ -static const char KW_ANY[] = { ASCII_A, ASCII_N, ASCII_Y, '\0' }; -static const char KW_ATTLIST[] = { ASCII_A, ASCII_T, ASCII_T, ASCII_L, ASCII_I, ASCII_S, ASCII_T, '\0' }; -static const char KW_CDATA[] = { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; -static const char KW_DOCTYPE[] = { ASCII_D, ASCII_O, ASCII_C, ASCII_T, ASCII_Y, ASCII_P, ASCII_E, '\0' }; -static const char KW_ELEMENT[] = { ASCII_E, ASCII_L, ASCII_E, ASCII_M, ASCII_E, ASCII_N, ASCII_T, '\0' }; -static const char KW_EMPTY[] = { ASCII_E, ASCII_M, ASCII_P, ASCII_T, ASCII_Y, '\0' }; -static const char KW_ENTITIES[] = { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, '\0' }; -static const char KW_ENTITY[] = { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' }; -static const char KW_FIXED[] = { ASCII_F, ASCII_I, ASCII_X, ASCII_E, ASCII_D, '\0' }; -static const char KW_ID[] = { ASCII_I, ASCII_D, '\0' }; -static const char KW_IDREF[] = { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' }; -static const char KW_IDREFS[] = { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; -static const char KW_IGNORE[] = { ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' }; -static const char KW_IMPLIED[] = { ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' }; -static const char KW_INCLUDE[] = { ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' }; -static const char KW_NDATA[] = { ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; -static const char KW_NMTOKEN[] = { ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' }; -static const char KW_NMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' }; -static const char KW_NOTATION[] = { ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, '\0' }; -static const char KW_PCDATA[] = { ASCII_P, ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; -static const char KW_PUBLIC[] = { ASCII_P, ASCII_U, ASCII_B, ASCII_L, ASCII_I, ASCII_C, '\0' }; -static const char KW_REQUIRED[] = { ASCII_R, ASCII_E, ASCII_Q, ASCII_U, ASCII_I, ASCII_R, ASCII_E, ASCII_D, '\0' }; -static const char KW_SYSTEM[] = { ASCII_S, ASCII_Y, ASCII_S, ASCII_T, ASCII_E, ASCII_M, '\0' }; +static const char KW_ANY[] = { + ASCII_A, ASCII_N, ASCII_Y, '\0' }; +static const char KW_ATTLIST[] = { + ASCII_A, ASCII_T, ASCII_T, ASCII_L, ASCII_I, ASCII_S, ASCII_T, '\0' }; +static const char KW_CDATA[] = { + ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; +static const char KW_DOCTYPE[] = { + ASCII_D, ASCII_O, ASCII_C, ASCII_T, ASCII_Y, ASCII_P, ASCII_E, '\0' }; +static const char KW_ELEMENT[] = { + ASCII_E, ASCII_L, ASCII_E, ASCII_M, ASCII_E, ASCII_N, ASCII_T, '\0' }; +static const char KW_EMPTY[] = { + ASCII_E, ASCII_M, ASCII_P, ASCII_T, ASCII_Y, '\0' }; +static const char KW_ENTITIES[] = { + ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, + '\0' }; +static const char KW_ENTITY[] = { + ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' }; +static const char KW_FIXED[] = { + ASCII_F, ASCII_I, ASCII_X, ASCII_E, ASCII_D, '\0' }; +static const char KW_ID[] = { + ASCII_I, ASCII_D, '\0' }; +static const char KW_IDREF[] = { + ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' }; +static const char KW_IDREFS[] = { + ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; +static const char KW_IGNORE[] = { + ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' }; +static const char KW_IMPLIED[] = { + ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' }; +static const char KW_INCLUDE[] = { + ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' }; +static const char KW_NDATA[] = { + ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; +static const char KW_NMTOKEN[] = { + ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' }; +static const char KW_NMTOKENS[] = { + ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, + '\0' }; +static const char KW_NOTATION[] = + { ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, + '\0' }; +static const char KW_PCDATA[] = { + ASCII_P, ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; +static const char KW_PUBLIC[] = { + ASCII_P, ASCII_U, ASCII_B, ASCII_L, ASCII_I, ASCII_C, '\0' }; +static const char KW_REQUIRED[] = { + ASCII_R, ASCII_E, ASCII_Q, ASCII_U, ASCII_I, ASCII_R, ASCII_E, ASCII_D, + '\0' }; +static const char KW_SYSTEM[] = { + ASCII_S, ASCII_Y, ASCII_S, ASCII_T, ASCII_E, ASCII_M, '\0' }; #ifndef MIN_BYTES_PER_CHAR #define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar) @@ -57,11 +85,11 @@ static const char KW_SYSTEM[] = { ASCII_S, ASCII_Y, ASCII_S, ASCII_T, ASCII_E, A #define setTopLevel(state) ((state)->handler = internalSubset) #endif /* not XML_DTD */ -typedef int PROLOG_HANDLER(PROLOG_STATE *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc); +typedef int PTRCALL PROLOG_HANDLER(PROLOG_STATE *state, + int tok, + const char *ptr, + const char *end, + const ENCODING *enc); static PROLOG_HANDLER prolog0, prolog1, prolog2, @@ -81,9 +109,9 @@ static PROLOG_HANDLER declClose, error; -static int common(PROLOG_STATE *state, int tok); +static int FASTCALL common(PROLOG_STATE *state, int tok); -static int +static int PTRCALL prolog0(PROLOG_STATE *state, int tok, const char *ptr, @@ -99,9 +127,10 @@ prolog0(PROLOG_STATE *state, return XML_ROLE_XML_DECL; case XML_TOK_PI: state->handler = prolog1; - return XML_ROLE_NONE; + return XML_ROLE_PI; case XML_TOK_COMMENT: state->handler = prolog1; + return XML_ROLE_COMMENT; case XML_TOK_BOM: return XML_ROLE_NONE; case XML_TOK_DECL_OPEN: @@ -111,7 +140,7 @@ prolog0(PROLOG_STATE *state, KW_DOCTYPE)) break; state->handler = doctype0; - return XML_ROLE_NONE; + return XML_ROLE_DOCTYPE_NONE; case XML_TOK_INSTANCE_START: state->handler = error; return XML_ROLE_INSTANCE_START; @@ -119,7 +148,7 @@ prolog0(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL prolog1(PROLOG_STATE *state, int tok, const char *ptr, @@ -130,7 +159,9 @@ prolog1(PROLOG_STATE *state, case XML_TOK_PROLOG_S: return XML_ROLE_NONE; case XML_TOK_PI: + return XML_ROLE_PI; case XML_TOK_COMMENT: + return XML_ROLE_COMMENT; case XML_TOK_BOM: return XML_ROLE_NONE; case XML_TOK_DECL_OPEN: @@ -140,7 +171,7 @@ prolog1(PROLOG_STATE *state, KW_DOCTYPE)) break; state->handler = doctype0; - return XML_ROLE_NONE; + return XML_ROLE_DOCTYPE_NONE; case XML_TOK_INSTANCE_START: state->handler = error; return XML_ROLE_INSTANCE_START; @@ -148,7 +179,7 @@ prolog1(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL prolog2(PROLOG_STATE *state, int tok, const char *ptr, @@ -159,8 +190,9 @@ prolog2(PROLOG_STATE *state, case XML_TOK_PROLOG_S: return XML_ROLE_NONE; case XML_TOK_PI: + return XML_ROLE_PI; case XML_TOK_COMMENT: - return XML_ROLE_NONE; + return XML_ROLE_COMMENT; case XML_TOK_INSTANCE_START: state->handler = error; return XML_ROLE_INSTANCE_START; @@ -168,7 +200,7 @@ prolog2(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL doctype0(PROLOG_STATE *state, int tok, const char *ptr, @@ -177,7 +209,7 @@ doctype0(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_DOCTYPE_NONE; case XML_TOK_NAME: case XML_TOK_PREFIXED_NAME: state->handler = doctype1; @@ -186,7 +218,7 @@ doctype0(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL doctype1(PROLOG_STATE *state, int tok, const char *ptr, @@ -195,7 +227,7 @@ doctype1(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_DOCTYPE_NONE; case XML_TOK_OPEN_BRACKET: state->handler = internalSubset; return XML_ROLE_DOCTYPE_INTERNAL_SUBSET; @@ -205,18 +237,18 @@ doctype1(PROLOG_STATE *state, case XML_TOK_NAME: if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { state->handler = doctype3; - return XML_ROLE_NONE; + return XML_ROLE_DOCTYPE_NONE; } if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { state->handler = doctype2; - return XML_ROLE_NONE; + return XML_ROLE_DOCTYPE_NONE; } break; } return common(state, tok); } -static int +static int PTRCALL doctype2(PROLOG_STATE *state, int tok, const char *ptr, @@ -225,7 +257,7 @@ doctype2(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_DOCTYPE_NONE; case XML_TOK_LITERAL: state->handler = doctype3; return XML_ROLE_DOCTYPE_PUBLIC_ID; @@ -233,7 +265,7 @@ doctype2(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL doctype3(PROLOG_STATE *state, int tok, const char *ptr, @@ -242,7 +274,7 @@ doctype3(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_DOCTYPE_NONE; case XML_TOK_LITERAL: state->handler = doctype4; return XML_ROLE_DOCTYPE_SYSTEM_ID; @@ -250,7 +282,7 @@ doctype3(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL doctype4(PROLOG_STATE *state, int tok, const char *ptr, @@ -259,7 +291,7 @@ doctype4(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_DOCTYPE_NONE; case XML_TOK_OPEN_BRACKET: state->handler = internalSubset; return XML_ROLE_DOCTYPE_INTERNAL_SUBSET; @@ -270,7 +302,7 @@ doctype4(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL doctype5(PROLOG_STATE *state, int tok, const char *ptr, @@ -279,7 +311,7 @@ doctype5(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_DOCTYPE_NONE; case XML_TOK_DECL_CLOSE: state->handler = prolog2; return XML_ROLE_DOCTYPE_CLOSE; @@ -287,7 +319,7 @@ doctype5(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL internalSubset(PROLOG_STATE *state, int tok, const char *ptr, @@ -303,45 +335,46 @@ internalSubset(PROLOG_STATE *state, end, KW_ENTITY)) { state->handler = entity0; - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; } if (XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end, KW_ATTLIST)) { state->handler = attlist0; - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; } if (XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end, KW_ELEMENT)) { state->handler = element0; - return XML_ROLE_NONE; + return XML_ROLE_ELEMENT_NONE; } if (XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end, KW_NOTATION)) { state->handler = notation0; - return XML_ROLE_NONE; + return XML_ROLE_NOTATION_NONE; } break; case XML_TOK_PI: + return XML_ROLE_PI; case XML_TOK_COMMENT: - return XML_ROLE_NONE; + return XML_ROLE_COMMENT; case XML_TOK_PARAM_ENTITY_REF: return XML_ROLE_PARAM_ENTITY_REF; case XML_TOK_CLOSE_BRACKET: state->handler = doctype5; - return XML_ROLE_NONE; + return XML_ROLE_DOCTYPE_NONE; } return common(state, tok); } #ifdef XML_DTD -static int +static int PTRCALL externalSubset0(PROLOG_STATE *state, int tok, const char *ptr, @@ -354,7 +387,7 @@ externalSubset0(PROLOG_STATE *state, return externalSubset1(state, tok, ptr, end, enc); } -static int +static int PTRCALL externalSubset1(PROLOG_STATE *state, int tok, const char *ptr, @@ -386,7 +419,7 @@ externalSubset1(PROLOG_STATE *state, #endif /* XML_DTD */ -static int +static int PTRCALL entity0(PROLOG_STATE *state, int tok, const char *ptr, @@ -395,10 +428,10 @@ entity0(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; case XML_TOK_PERCENT: state->handler = entity1; - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; case XML_TOK_NAME: state->handler = entity2; return XML_ROLE_GENERAL_ENTITY_NAME; @@ -406,7 +439,7 @@ entity0(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL entity1(PROLOG_STATE *state, int tok, const char *ptr, @@ -415,7 +448,7 @@ entity1(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; case XML_TOK_NAME: state->handler = entity7; return XML_ROLE_PARAM_ENTITY_NAME; @@ -423,7 +456,7 @@ entity1(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL entity2(PROLOG_STATE *state, int tok, const char *ptr, @@ -432,25 +465,26 @@ entity2(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; case XML_TOK_NAME: if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { state->handler = entity4; - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; } if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { state->handler = entity3; - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; } break; case XML_TOK_LITERAL: state->handler = declClose; + state->role_none = XML_ROLE_ENTITY_NONE; return XML_ROLE_ENTITY_VALUE; } return common(state, tok); } -static int +static int PTRCALL entity3(PROLOG_STATE *state, int tok, const char *ptr, @@ -459,7 +493,7 @@ entity3(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; case XML_TOK_LITERAL: state->handler = entity4; return XML_ROLE_ENTITY_PUBLIC_ID; @@ -467,7 +501,7 @@ entity3(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL entity4(PROLOG_STATE *state, int tok, const char *ptr, @@ -476,7 +510,7 @@ entity4(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; case XML_TOK_LITERAL: state->handler = entity5; return XML_ROLE_ENTITY_SYSTEM_ID; @@ -484,7 +518,7 @@ entity4(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL entity5(PROLOG_STATE *state, int tok, const char *ptr, @@ -493,21 +527,21 @@ entity5(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; case XML_TOK_DECL_CLOSE: setTopLevel(state); return XML_ROLE_ENTITY_COMPLETE; case XML_TOK_NAME: if (XmlNameMatchesAscii(enc, ptr, end, KW_NDATA)) { state->handler = entity6; - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; } break; } return common(state, tok); } -static int +static int PTRCALL entity6(PROLOG_STATE *state, int tok, const char *ptr, @@ -516,15 +550,16 @@ entity6(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; case XML_TOK_NAME: state->handler = declClose; + state->role_none = XML_ROLE_ENTITY_NONE; return XML_ROLE_ENTITY_NOTATION_NAME; } return common(state, tok); } -static int +static int PTRCALL entity7(PROLOG_STATE *state, int tok, const char *ptr, @@ -533,25 +568,26 @@ entity7(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; case XML_TOK_NAME: if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { state->handler = entity9; - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; } if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { state->handler = entity8; - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; } break; case XML_TOK_LITERAL: state->handler = declClose; + state->role_none = XML_ROLE_ENTITY_NONE; return XML_ROLE_ENTITY_VALUE; } return common(state, tok); } -static int +static int PTRCALL entity8(PROLOG_STATE *state, int tok, const char *ptr, @@ -560,7 +596,7 @@ entity8(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; case XML_TOK_LITERAL: state->handler = entity9; return XML_ROLE_ENTITY_PUBLIC_ID; @@ -568,7 +604,7 @@ entity8(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL entity9(PROLOG_STATE *state, int tok, const char *ptr, @@ -577,7 +613,7 @@ entity9(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; case XML_TOK_LITERAL: state->handler = entity10; return XML_ROLE_ENTITY_SYSTEM_ID; @@ -585,7 +621,7 @@ entity9(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL entity10(PROLOG_STATE *state, int tok, const char *ptr, @@ -594,7 +630,7 @@ entity10(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ENTITY_NONE; case XML_TOK_DECL_CLOSE: setTopLevel(state); return XML_ROLE_ENTITY_COMPLETE; @@ -602,7 +638,7 @@ entity10(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL notation0(PROLOG_STATE *state, int tok, const char *ptr, @@ -611,7 +647,7 @@ notation0(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_NOTATION_NONE; case XML_TOK_NAME: state->handler = notation1; return XML_ROLE_NOTATION_NAME; @@ -619,7 +655,7 @@ notation0(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL notation1(PROLOG_STATE *state, int tok, const char *ptr, @@ -628,22 +664,22 @@ notation1(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_NOTATION_NONE; case XML_TOK_NAME: if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) { state->handler = notation3; - return XML_ROLE_NONE; + return XML_ROLE_NOTATION_NONE; } if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) { state->handler = notation2; - return XML_ROLE_NONE; + return XML_ROLE_NOTATION_NONE; } break; } return common(state, tok); } -static int +static int PTRCALL notation2(PROLOG_STATE *state, int tok, const char *ptr, @@ -652,7 +688,7 @@ notation2(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_NOTATION_NONE; case XML_TOK_LITERAL: state->handler = notation4; return XML_ROLE_NOTATION_PUBLIC_ID; @@ -660,7 +696,7 @@ notation2(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL notation3(PROLOG_STATE *state, int tok, const char *ptr, @@ -669,15 +705,16 @@ notation3(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_NOTATION_NONE; case XML_TOK_LITERAL: state->handler = declClose; + state->role_none = XML_ROLE_NOTATION_NONE; return XML_ROLE_NOTATION_SYSTEM_ID; } return common(state, tok); } -static int +static int PTRCALL notation4(PROLOG_STATE *state, int tok, const char *ptr, @@ -686,9 +723,10 @@ notation4(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_NOTATION_NONE; case XML_TOK_LITERAL: state->handler = declClose; + state->role_none = XML_ROLE_NOTATION_NONE; return XML_ROLE_NOTATION_SYSTEM_ID; case XML_TOK_DECL_CLOSE: setTopLevel(state); @@ -697,7 +735,7 @@ notation4(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL attlist0(PROLOG_STATE *state, int tok, const char *ptr, @@ -706,7 +744,7 @@ attlist0(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; case XML_TOK_NAME: case XML_TOK_PREFIXED_NAME: state->handler = attlist1; @@ -715,7 +753,7 @@ attlist0(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL attlist1(PROLOG_STATE *state, int tok, const char *ptr, @@ -724,10 +762,10 @@ attlist1(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; case XML_TOK_DECL_CLOSE: setTopLevel(state); - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; case XML_TOK_NAME: case XML_TOK_PREFIXED_NAME: state->handler = attlist2; @@ -736,7 +774,7 @@ attlist1(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL attlist2(PROLOG_STATE *state, int tok, const char *ptr, @@ -745,7 +783,7 @@ attlist2(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; case XML_TOK_NAME: { static const char *types[] = { @@ -767,17 +805,17 @@ attlist2(PROLOG_STATE *state, } if (XmlNameMatchesAscii(enc, ptr, end, KW_NOTATION)) { state->handler = attlist5; - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; } break; case XML_TOK_OPEN_PAREN: state->handler = attlist3; - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; } return common(state, tok); } -static int +static int PTRCALL attlist3(PROLOG_STATE *state, int tok, const char *ptr, @@ -786,7 +824,7 @@ attlist3(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; case XML_TOK_NMTOKEN: case XML_TOK_NAME: case XML_TOK_PREFIXED_NAME: @@ -796,7 +834,7 @@ attlist3(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL attlist4(PROLOG_STATE *state, int tok, const char *ptr, @@ -805,18 +843,18 @@ attlist4(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; case XML_TOK_CLOSE_PAREN: state->handler = attlist8; - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; case XML_TOK_OR: state->handler = attlist3; - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; } return common(state, tok); } -static int +static int PTRCALL attlist5(PROLOG_STATE *state, int tok, const char *ptr, @@ -825,15 +863,15 @@ attlist5(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; case XML_TOK_OPEN_PAREN: state->handler = attlist6; - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; } return common(state, tok); } -static int +static int PTRCALL attlist6(PROLOG_STATE *state, int tok, const char *ptr, @@ -842,7 +880,7 @@ attlist6(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; case XML_TOK_NAME: state->handler = attlist7; return XML_ROLE_ATTRIBUTE_NOTATION_VALUE; @@ -850,7 +888,7 @@ attlist6(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL attlist7(PROLOG_STATE *state, int tok, const char *ptr, @@ -859,19 +897,19 @@ attlist7(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; case XML_TOK_CLOSE_PAREN: state->handler = attlist8; - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; case XML_TOK_OR: state->handler = attlist6; - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; } return common(state, tok); } /* default value */ -static int +static int PTRCALL attlist8(PROLOG_STATE *state, int tok, const char *ptr, @@ -880,7 +918,7 @@ attlist8(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; case XML_TOK_POUND_NAME: if (XmlNameMatchesAscii(enc, ptr + MIN_BYTES_PER_CHAR(enc), @@ -901,7 +939,7 @@ attlist8(PROLOG_STATE *state, end, KW_FIXED)) { state->handler = attlist9; - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; } break; case XML_TOK_LITERAL: @@ -911,7 +949,7 @@ attlist8(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL attlist9(PROLOG_STATE *state, int tok, const char *ptr, @@ -920,7 +958,7 @@ attlist9(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ATTLIST_NONE; case XML_TOK_LITERAL: state->handler = attlist1; return XML_ROLE_FIXED_ATTRIBUTE_VALUE; @@ -928,7 +966,7 @@ attlist9(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL element0(PROLOG_STATE *state, int tok, const char *ptr, @@ -937,7 +975,7 @@ element0(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ELEMENT_NONE; case XML_TOK_NAME: case XML_TOK_PREFIXED_NAME: state->handler = element1; @@ -946,7 +984,7 @@ element0(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL element1(PROLOG_STATE *state, int tok, const char *ptr, @@ -955,14 +993,16 @@ element1(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ELEMENT_NONE; case XML_TOK_NAME: if (XmlNameMatchesAscii(enc, ptr, end, KW_EMPTY)) { state->handler = declClose; + state->role_none = XML_ROLE_ELEMENT_NONE; return XML_ROLE_CONTENT_EMPTY; } if (XmlNameMatchesAscii(enc, ptr, end, KW_ANY)) { state->handler = declClose; + state->role_none = XML_ROLE_ELEMENT_NONE; return XML_ROLE_CONTENT_ANY; } break; @@ -974,7 +1014,7 @@ element1(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL element2(PROLOG_STATE *state, int tok, const char *ptr, @@ -983,7 +1023,7 @@ element2(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ELEMENT_NONE; case XML_TOK_POUND_NAME: if (XmlNameMatchesAscii(enc, ptr + MIN_BYTES_PER_CHAR(enc), @@ -1014,7 +1054,7 @@ element2(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL element3(PROLOG_STATE *state, int tok, const char *ptr, @@ -1023,21 +1063,23 @@ element3(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ELEMENT_NONE; case XML_TOK_CLOSE_PAREN: state->handler = declClose; + state->role_none = XML_ROLE_ELEMENT_NONE; return XML_ROLE_GROUP_CLOSE; case XML_TOK_CLOSE_PAREN_ASTERISK: state->handler = declClose; + state->role_none = XML_ROLE_ELEMENT_NONE; return XML_ROLE_GROUP_CLOSE_REP; case XML_TOK_OR: state->handler = element4; - return XML_ROLE_NONE; + return XML_ROLE_ELEMENT_NONE; } return common(state, tok); } -static int +static int PTRCALL element4(PROLOG_STATE *state, int tok, const char *ptr, @@ -1046,7 +1088,7 @@ element4(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ELEMENT_NONE; case XML_TOK_NAME: case XML_TOK_PREFIXED_NAME: state->handler = element5; @@ -1055,7 +1097,7 @@ element4(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL element5(PROLOG_STATE *state, int tok, const char *ptr, @@ -1064,18 +1106,19 @@ element5(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ELEMENT_NONE; case XML_TOK_CLOSE_PAREN_ASTERISK: state->handler = declClose; + state->role_none = XML_ROLE_ELEMENT_NONE; return XML_ROLE_GROUP_CLOSE_REP; case XML_TOK_OR: state->handler = element4; - return XML_ROLE_NONE; + return XML_ROLE_ELEMENT_NONE; } return common(state, tok); } -static int +static int PTRCALL element6(PROLOG_STATE *state, int tok, const char *ptr, @@ -1084,7 +1127,7 @@ element6(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ELEMENT_NONE; case XML_TOK_OPEN_PAREN: state->level += 1; return XML_ROLE_GROUP_OPEN; @@ -1105,7 +1148,7 @@ element6(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL element7(PROLOG_STATE *state, int tok, const char *ptr, @@ -1114,26 +1157,34 @@ element7(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return XML_ROLE_ELEMENT_NONE; case XML_TOK_CLOSE_PAREN: state->level -= 1; - if (state->level == 0) + if (state->level == 0) { state->handler = declClose; + state->role_none = XML_ROLE_ELEMENT_NONE; + } return XML_ROLE_GROUP_CLOSE; case XML_TOK_CLOSE_PAREN_ASTERISK: state->level -= 1; - if (state->level == 0) + if (state->level == 0) { state->handler = declClose; + state->role_none = XML_ROLE_ELEMENT_NONE; + } return XML_ROLE_GROUP_CLOSE_REP; case XML_TOK_CLOSE_PAREN_QUESTION: state->level -= 1; - if (state->level == 0) + if (state->level == 0) { state->handler = declClose; + state->role_none = XML_ROLE_ELEMENT_NONE; + } return XML_ROLE_GROUP_CLOSE_OPT; case XML_TOK_CLOSE_PAREN_PLUS: state->level -= 1; - if (state->level == 0) + if (state->level == 0) { state->handler = declClose; + state->role_none = XML_ROLE_ELEMENT_NONE; + } return XML_ROLE_GROUP_CLOSE_PLUS; case XML_TOK_COMMA: state->handler = element6; @@ -1147,7 +1198,7 @@ element7(PROLOG_STATE *state, #ifdef XML_DTD -static int +static int PTRCALL condSect0(PROLOG_STATE *state, int tok, const char *ptr, @@ -1171,7 +1222,7 @@ condSect0(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL condSect1(PROLOG_STATE *state, int tok, const char *ptr, @@ -1189,7 +1240,7 @@ condSect1(PROLOG_STATE *state, return common(state, tok); } -static int +static int PTRCALL condSect2(PROLOG_STATE *state, int tok, const char *ptr, @@ -1208,7 +1259,7 @@ condSect2(PROLOG_STATE *state, #endif /* XML_DTD */ -static int +static int PTRCALL declClose(PROLOG_STATE *state, int tok, const char *ptr, @@ -1217,15 +1268,15 @@ declClose(PROLOG_STATE *state, { switch (tok) { case XML_TOK_PROLOG_S: - return XML_ROLE_NONE; + return state->role_none; case XML_TOK_DECL_CLOSE: setTopLevel(state); - return XML_ROLE_NONE; + return state->role_none; } return common(state, tok); } -static int +static int PTRCALL error(PROLOG_STATE *state, int tok, const char *ptr, @@ -1235,7 +1286,7 @@ error(PROLOG_STATE *state, return XML_ROLE_NONE; } -static int +static int FASTCALL common(PROLOG_STATE *state, int tok) { #ifdef XML_DTD diff --git a/extras/expat/lib/xmlrole.h b/extras/expat/lib/xmlrole.h index 1549c1865..4dd9f06f9 100644 --- a/extras/expat/lib/xmlrole.h +++ b/extras/expat/lib/xmlrole.h @@ -8,7 +8,7 @@ #ifdef __VMS /* 0 1 2 3 0 1 2 3 1234567890123456789012345678901 1234567890123456789012345678901 */ -#define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt +#define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt #endif #include "xmltok.h" @@ -22,6 +22,7 @@ enum { 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, @@ -29,11 +30,13 @@ enum { 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, @@ -49,11 +52,13 @@ enum { 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, @@ -69,6 +74,8 @@ enum { 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, @@ -78,12 +85,13 @@ enum { }; typedef struct prolog_state { - int (*handler)(struct prolog_state *state, - int tok, - const char *ptr, - const char *end, - const ENCODING *enc); + int (PTRCALL *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; diff --git a/extras/expat/lib/xmltok.c b/extras/expat/lib/xmltok.c index cf69c0bb1..5f101afe8 100644 --- a/extras/expat/lib/xmltok.c +++ b/extras/expat/lib/xmltok.c @@ -10,6 +10,7 @@ #include <expat_config.h> #endif /* ndef COMPILED_FROM_DSP */ +#include "internal.h" #include "xmltok.h" #include "nametab.h" @@ -84,7 +85,11 @@ #define UTF8_INVALID3(p) \ (((p)[2] & 0x80) == 0 \ || \ - ((*p) == 0xEF ? (p)[2] > 0xBD : ((p)[2] & 0xC0) == 0xC0) \ + ((*p) == 0xEF && (p)[1] == 0xBF \ + ? \ + (p)[2] > 0xBD \ + : \ + ((p)[2] & 0xC0) == 0xC0) \ || \ ((*p) == 0xE0 \ ? \ @@ -107,19 +112,19 @@ || \ ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0))) -static int +static int PTRFASTCALL isNever(const ENCODING *enc, const char *p) { return 0; } -static int +static int PTRFASTCALL utf8_isName2(const ENCODING *enc, const char *p) { return UTF8_GET_NAMING2(namePages, (const unsigned char *)p); } -static int +static int PTRFASTCALL utf8_isName3(const ENCODING *enc, const char *p) { return UTF8_GET_NAMING3(namePages, (const unsigned char *)p); @@ -127,13 +132,13 @@ utf8_isName3(const ENCODING *enc, const char *p) #define utf8_isName4 isNever -static int +static int PTRFASTCALL utf8_isNmstrt2(const ENCODING *enc, const char *p) { return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p); } -static int +static int PTRFASTCALL utf8_isNmstrt3(const ENCODING *enc, const char *p) { return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p); @@ -141,19 +146,19 @@ utf8_isNmstrt3(const ENCODING *enc, const char *p) #define utf8_isNmstrt4 isNever -static int +static int PTRFASTCALL utf8_isInvalid2(const ENCODING *enc, const char *p) { return UTF8_INVALID2((const unsigned char *)p); } -static int +static int PTRFASTCALL utf8_isInvalid3(const ENCODING *enc, const char *p) { return UTF8_INVALID3((const unsigned char *)p); } -static int +static int PTRFASTCALL utf8_isInvalid4(const ENCODING *enc, const char *p) { return UTF8_INVALID4((const unsigned char *)p); @@ -163,23 +168,25 @@ struct normal_encoding { ENCODING enc; unsigned char type[256]; #ifdef XML_MIN_SIZE - int (*byteType)(const ENCODING *, const char *); - int (*isNameMin)(const ENCODING *, const char *); - int (*isNmstrtMin)(const ENCODING *, const char *); - int (*byteToAscii)(const ENCODING *, const char *); - int (*charMatches)(const ENCODING *, const char *, int); + int (PTRFASTCALL *byteType)(const ENCODING *, const char *); + int (PTRFASTCALL *isNameMin)(const ENCODING *, const char *); + int (PTRFASTCALL *isNmstrtMin)(const ENCODING *, const char *); + int (PTRFASTCALL *byteToAscii)(const ENCODING *, const char *); + int (PTRCALL *charMatches)(const ENCODING *, const char *, int); #endif /* XML_MIN_SIZE */ - int (*isName2)(const ENCODING *, const char *); - int (*isName3)(const ENCODING *, const char *); - int (*isName4)(const ENCODING *, const char *); - int (*isNmstrt2)(const ENCODING *, const char *); - int (*isNmstrt3)(const ENCODING *, const char *); - int (*isNmstrt4)(const ENCODING *, const char *); - int (*isInvalid2)(const ENCODING *, const char *); - int (*isInvalid3)(const ENCODING *, const char *); - int (*isInvalid4)(const ENCODING *, const char *); + int (PTRFASTCALL *isName2)(const ENCODING *, const char *); + int (PTRFASTCALL *isName3)(const ENCODING *, const char *); + int (PTRFASTCALL *isName4)(const ENCODING *, const char *); + int (PTRFASTCALL *isNmstrt2)(const ENCODING *, const char *); + int (PTRFASTCALL *isNmstrt3)(const ENCODING *, const char *); + int (PTRFASTCALL *isNmstrt4)(const ENCODING *, const char *); + int (PTRFASTCALL *isInvalid2)(const ENCODING *, const char *); + int (PTRFASTCALL *isInvalid3)(const ENCODING *, const char *); + int (PTRFASTCALL *isInvalid4)(const ENCODING *, const char *); }; +#define AS_NORMAL_ENCODING(enc) ((const struct normal_encoding *) (enc)) + #ifdef XML_MIN_SIZE #define STANDARD_VTABLE(E) \ @@ -206,7 +213,7 @@ struct normal_encoding { E ## isInvalid3, \ E ## isInvalid4 -static int checkCharRefNumber(int); +static int FASTCALL checkCharRefNumber(int); #include "xmltok_impl.h" #include "ascii.h" @@ -227,21 +234,21 @@ static int checkCharRefNumber(int); (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)]) #ifdef XML_MIN_SIZE -static int +static int PTRFASTCALL sb_byteType(const ENCODING *enc, const char *p) { return SB_BYTE_TYPE(enc, p); } #define BYTE_TYPE(enc, p) \ - (((const struct normal_encoding *)(enc))->byteType(enc, p)) + (AS_NORMAL_ENCODING(enc)->byteType(enc, p)) #else #define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p) #endif #ifdef XML_MIN_SIZE #define BYTE_TO_ASCII(enc, p) \ - (((const struct normal_encoding *)(enc))->byteToAscii(enc, p)) -static int + (AS_NORMAL_ENCODING(enc)->byteToAscii(enc, p)) +static int PTRFASTCALL sb_byteToAscii(const ENCODING *enc, const char *p) { return *p; @@ -251,17 +258,17 @@ sb_byteToAscii(const ENCODING *enc, const char *p) #endif #define IS_NAME_CHAR(enc, p, n) \ - (((const struct normal_encoding *)(enc))->isName ## n(enc, p)) + (AS_NORMAL_ENCODING(enc)->isName ## n(enc, p)) #define IS_NMSTRT_CHAR(enc, p, n) \ - (((const struct normal_encoding *)(enc))->isNmstrt ## n(enc, p)) + (AS_NORMAL_ENCODING(enc)->isNmstrt ## n(enc, p)) #define IS_INVALID_CHAR(enc, p, n) \ - (((const struct normal_encoding *)(enc))->isInvalid ## n(enc, p)) + (AS_NORMAL_ENCODING(enc)->isInvalid ## n(enc, p)) #ifdef XML_MIN_SIZE #define IS_NAME_CHAR_MINBPC(enc, p) \ - (((const struct normal_encoding *)(enc))->isNameMin(enc, p)) + (AS_NORMAL_ENCODING(enc)->isNameMin(enc, p)) #define IS_NMSTRT_CHAR_MINBPC(enc, p) \ - (((const struct normal_encoding *)(enc))->isNmstrtMin(enc, p)) + (AS_NORMAL_ENCODING(enc)->isNmstrtMin(enc, p)) #else #define IS_NAME_CHAR_MINBPC(enc, p) (0) #define IS_NMSTRT_CHAR_MINBPC(enc, p) (0) @@ -269,8 +276,8 @@ sb_byteToAscii(const ENCODING *enc, const char *p) #ifdef XML_MIN_SIZE #define CHAR_MATCHES(enc, p, c) \ - (((const struct normal_encoding *)(enc))->charMatches(enc, p, c)) -static int + (AS_NORMAL_ENCODING(enc)->charMatches(enc, p, c)) +static int PTRCALL sb_charMatches(const ENCODING *enc, const char *p, int c) { return *p == c; @@ -300,7 +307,7 @@ enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */ UTF8_cval4 = 0xf0 }; -static void +static void PTRCALL utf8_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim) @@ -319,7 +326,7 @@ utf8_toUtf8(const ENCODING *enc, *toP = to; } -static void +static void PTRCALL utf8_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim) @@ -341,7 +348,7 @@ utf8_toUtf16(const ENCODING *enc, { unsigned long n; if (to + 1 == toLim) - break; + goto after; n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12) | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f); n -= 0x10000; @@ -356,6 +363,7 @@ utf8_toUtf16(const ENCODING *enc, break; } } +after: *fromP = from; *toP = to; } @@ -406,7 +414,7 @@ static const struct normal_encoding internal_utf8_encoding = { STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) }; -static void +static void PTRCALL latin1_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim) @@ -431,7 +439,7 @@ latin1_toUtf8(const ENCODING *enc, } } -static void +static void PTRCALL latin1_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim) @@ -464,7 +472,7 @@ static const struct normal_encoding latin1_encoding = { STANDARD_VTABLE(sb_) }; -static void +static void PTRCALL ascii_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim) @@ -497,7 +505,7 @@ static const struct normal_encoding ascii_encoding = { STANDARD_VTABLE(sb_) }; -static int +static int PTRFASTCALL unicode_byte_type(char hi, char lo) { switch ((unsigned char)hi) { @@ -517,7 +525,7 @@ unicode_byte_type(char hi, char lo) } #define DEFINE_UTF16_TO_UTF8(E) \ -static void \ +static void PTRCALL \ E ## toUtf8(const ENCODING *enc, \ const char **fromP, const char *fromLim, \ char **toP, const char *toLim) \ @@ -580,7 +588,7 @@ E ## toUtf8(const ENCODING *enc, \ } #define DEFINE_UTF16_TO_UTF16(E) \ -static void \ +static void PTRCALL \ E ## toUtf16(const ENCODING *enc, \ const char **fromP, const char *fromLim, \ unsigned short **toP, const unsigned short *toLim) \ @@ -630,31 +638,31 @@ DEFINE_UTF16_TO_UTF16(big2_) #ifdef XML_MIN_SIZE -static int +static int PTRFASTCALL little2_byteType(const ENCODING *enc, const char *p) { return LITTLE2_BYTE_TYPE(enc, p); } -static int +static int PTRFASTCALL little2_byteToAscii(const ENCODING *enc, const char *p) { return LITTLE2_BYTE_TO_ASCII(enc, p); } -static int +static int PTRCALL little2_charMatches(const ENCODING *enc, const char *p, int c) { return LITTLE2_CHAR_MATCHES(enc, p, c); } -static int +static int PTRFASTCALL little2_isNameMin(const ENCODING *enc, const char *p) { return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p); } -static int +static int PTRFASTCALL little2_isNmstrtMin(const ENCODING *enc, const char *p) { return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p); @@ -670,7 +678,7 @@ little2_isNmstrtMin(const ENCODING *enc, const char *p) #define MINBPC(enc) 2 /* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ #define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p) -#define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p) +#define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p) #define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c) #define IS_NAME_CHAR(enc, p, n) 0 #define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) @@ -693,7 +701,7 @@ little2_isNmstrtMin(const ENCODING *enc, const char *p) #ifdef XML_NS -static const struct normal_encoding little2_encoding_ns = { +static const struct normal_encoding little2_encoding_ns = { { VTABLE, 2, 0, #if BYTEORDER == 1234 1 @@ -710,7 +718,7 @@ static const struct normal_encoding little2_encoding_ns = { #endif -static const struct normal_encoding little2_encoding = { +static const struct normal_encoding little2_encoding = { { VTABLE, 2, 0, #if BYTEORDER == 1234 1 @@ -731,7 +739,7 @@ static const struct normal_encoding little2_encoding = { #ifdef XML_NS -static const struct normal_encoding internal_little2_encoding_ns = { +static const struct normal_encoding internal_little2_encoding_ns = { { VTABLE, 2, 0, 1 }, { #include "iasciitab.h" @@ -742,7 +750,7 @@ static const struct normal_encoding internal_little2_encoding_ns = { #endif -static const struct normal_encoding internal_little2_encoding = { +static const struct normal_encoding internal_little2_encoding = { { VTABLE, 2, 0, 1 }, { #define BT_COLON BT_NMSTRT @@ -769,31 +777,31 @@ static const struct normal_encoding internal_little2_encoding = { #ifdef XML_MIN_SIZE -static int +static int PTRFASTCALL big2_byteType(const ENCODING *enc, const char *p) { return BIG2_BYTE_TYPE(enc, p); } -static int +static int PTRFASTCALL big2_byteToAscii(const ENCODING *enc, const char *p) { return BIG2_BYTE_TO_ASCII(enc, p); } -static int +static int PTRCALL big2_charMatches(const ENCODING *enc, const char *p, int c) { return BIG2_CHAR_MATCHES(enc, p, c); } -static int +static int PTRFASTCALL big2_isNameMin(const ENCODING *enc, const char *p) { return BIG2_IS_NAME_CHAR_MINBPC(enc, p); } -static int +static int PTRFASTCALL big2_isNmstrtMin(const ENCODING *enc, const char *p) { return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p); @@ -809,7 +817,7 @@ big2_isNmstrtMin(const ENCODING *enc, const char *p) #define MINBPC(enc) 2 /* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ #define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p) -#define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p) +#define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p) #define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c) #define IS_NAME_CHAR(enc, p, n) 0 #define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p) @@ -896,7 +904,7 @@ static const struct normal_encoding internal_big2_encoding = { #undef PREFIX -static int +static int FASTCALL streqci(const char *s1, const char *s2) { for (;;) { @@ -914,7 +922,7 @@ streqci(const char *s1, const char *s2) return 1; } -static void +static void PTRCALL initUpdatePosition(const ENCODING *enc, const char *ptr, const char *end, POSITION *pos) { @@ -933,14 +941,14 @@ toAscii(const ENCODING *enc, const char *ptr, const char *end) return buf[0]; } -static int +static int FASTCALL isSpace(int c) { switch (c) { case 0x20: case 0xD: case 0xA: - case 0x9: + case 0x9: return 1; } return 0; @@ -1147,7 +1155,7 @@ doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *, return 1; } -static int +static int FASTCALL checkCharRefNumber(int result) { switch (result >> 8) { @@ -1166,7 +1174,7 @@ checkCharRefNumber(int result) return result; } -int +int FASTCALL XmlUtf8Encode(int c, char *buf) { enum { @@ -1203,7 +1211,7 @@ XmlUtf8Encode(int c, char *buf) return 0; } -int +int FASTCALL XmlUtf16Encode(int charNum, unsigned short *buf) { if (charNum < 0) @@ -1229,63 +1237,64 @@ struct unknown_encoding { char utf8[256][4]; }; +#define AS_UNKNOWN_ENCODING(enc) ((const struct unknown_encoding *) (enc)) + int XmlSizeOfUnknownEncoding(void) { return sizeof(struct unknown_encoding); } -static int +static int PTRFASTCALL unknown_isName(const ENCODING *enc, const char *p) { - int c = ((const struct unknown_encoding *)enc) - ->convert(((const struct unknown_encoding *)enc)->userData, p); + const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); + int c = uenc->convert(uenc->userData, p); if (c & ~0xFFFF) return 0; return UCS2_GET_NAMING(namePages, c >> 8, c & 0xFF); } -static int +static int PTRFASTCALL unknown_isNmstrt(const ENCODING *enc, const char *p) { - int c = ((const struct unknown_encoding *)enc) - ->convert(((const struct unknown_encoding *)enc)->userData, p); + const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); + int c = uenc->convert(uenc->userData, p); if (c & ~0xFFFF) return 0; return UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xFF); } -static int +static int PTRFASTCALL unknown_isInvalid(const ENCODING *enc, const char *p) { - int c = ((const struct unknown_encoding *)enc) - ->convert(((const struct unknown_encoding *)enc)->userData, p); + const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); + int c = uenc->convert(uenc->userData, p); return (c & ~0xFFFF) || checkCharRefNumber(c) < 0; } -static void +static void PTRCALL unknown_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim) { + const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); char buf[XML_UTF8_ENCODE_MAX]; for (;;) { const char *utf8; int n; if (*fromP == fromLim) break; - utf8 = ((const struct unknown_encoding *)enc)->utf8[(unsigned char)**fromP]; + utf8 = uenc->utf8[(unsigned char)**fromP]; n = *utf8++; if (n == 0) { - int c = ((const struct unknown_encoding *)enc) - ->convert(((const struct unknown_encoding *)enc)->userData, - *fromP); + int c = uenc->convert(uenc->userData, *fromP); n = XmlUtf8Encode(c, buf); if (n > toLim - *toP) break; utf8 = buf; - *fromP += ((const struct normal_encoding *)enc)->type[(unsigned char)**fromP] - - (BT_LEAD2 - 2); + *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] + - (BT_LEAD2 - 2)); } else { if (n > toLim - *toP) @@ -1298,19 +1307,19 @@ unknown_toUtf8(const ENCODING *enc, } } -static void +static void PTRCALL unknown_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim) { + const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); while (*fromP != fromLim && *toP != toLim) { - unsigned short c - = ((const struct unknown_encoding *)enc)->utf16[(unsigned char)**fromP]; + unsigned short c = uenc->utf16[(unsigned char)**fromP]; if (c == 0) { - c = (unsigned short)((const struct unknown_encoding *)enc) - ->convert(((const struct unknown_encoding *)enc)->userData, *fromP); - *fromP += ((const struct normal_encoding *)enc)->type[(unsigned char)**fromP] - - (BT_LEAD2 - 2); + c = (unsigned short) + uenc->convert(uenc->userData, *fromP); + *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] + - (BT_LEAD2 - 2)); } else (*fromP)++; @@ -1321,11 +1330,11 @@ unknown_toUtf16(const ENCODING *enc, ENCODING * XmlInitUnknownEncoding(void *mem, int *table, - int (*convert)(void *userData, const char *p), + CONVERTER convert, void *userData) { int i; - struct unknown_encoding *e = mem; + struct unknown_encoding *e = (struct unknown_encoding *)mem; for (i = 0; i < (int)sizeof(struct normal_encoding); i++) ((char *)mem)[i] = ((char *)&latin1_encoding)[i]; for (i = 0; i < 128; i++) @@ -1434,7 +1443,7 @@ static const char KW_UTF_16LE[] = { '\0' }; -static int +static int FASTCALL getEncodingIndex(const char *name) { static const char *encodingNames[] = { @@ -1611,7 +1620,7 @@ initScan(const ENCODING **encodingTable, ENCODING * XmlInitUnknownEncodingNS(void *mem, int *table, - int (*convert)(void *userData, const char *p), + CONVERTER convert, void *userData) { ENCODING *enc = XmlInitUnknownEncoding(mem, table, convert, userData); diff --git a/extras/expat/lib/xmltok.h b/extras/expat/lib/xmltok.h index 6f94dec6b..3d776be71 100644 --- a/extras/expat/lib/xmltok.h +++ b/extras/expat/lib/xmltok.h @@ -17,7 +17,7 @@ extern "C" { */ #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 */ + 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 @@ -125,41 +125,49 @@ typedef struct { struct encoding; typedef struct encoding ENCODING; +typedef int (PTRCALL *SCANNER)(const ENCODING *, + const char *, + const char *, + const char **); + struct encoding { - int (*scanners[XML_N_STATES])(const ENCODING *, - const char *, - const char *, - const char **); - int (*literalScanners[XML_N_LITERAL_TYPES])(const ENCODING *, - const char *, - const char *, - const char **); - int (*sameName)(const ENCODING *, - const char *, const char *); - int (*nameMatchesAscii)(const ENCODING *, - const char *, const char *, const char *); - int (*nameLength)(const ENCODING *, const char *); - const char *(*skipS)(const ENCODING *, const char *); - int (*getAtts)(const ENCODING *enc, const char *ptr, - int attsMax, ATTRIBUTE *atts); - int (*charRefNumber)(const ENCODING *enc, const char *ptr); - int (*predefinedEntityName)(const ENCODING *, const char *, const char *); - void (*updatePosition)(const ENCODING *, + SCANNER scanners[XML_N_STATES]; + SCANNER literalScanners[XML_N_LITERAL_TYPES]; + int (PTRCALL *sameName)(const ENCODING *, + const char *, + const char *); + int (PTRCALL *nameMatchesAscii)(const ENCODING *, + const char *, + const char *, + const char *); + int (PTRFASTCALL *nameLength)(const ENCODING *, const char *); + const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *); + int (PTRCALL *getAtts)(const ENCODING *enc, const char *ptr, - const char *end, - POSITION *); - int (*isPublicId)(const ENCODING *enc, const char *ptr, const char *end, - const char **badPtr); - void (*utf8Convert)(const ENCODING *enc, - const char **fromP, - const char *fromLim, - char **toP, - const char *toLim); - void (*utf16Convert)(const ENCODING *enc, - const char **fromP, - const char *fromLim, - unsigned short **toP, - const unsigned short *toLim); + int attsMax, + ATTRIBUTE *atts); + int (PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr); + int (PTRCALL *predefinedEntityName)(const ENCODING *, + const char *, + const char *); + void (PTRCALL *updatePosition)(const ENCODING *, + const char *ptr, + const char *end, + POSITION *); + int (PTRCALL *isPublicId)(const ENCODING *enc, + const char *ptr, + const char *end, + const char **badPtr); + void (PTRCALL *utf8Convert)(const ENCODING *enc, + const char **fromP, + const char *fromLim, + char **toP, + const char *toLim); + void (PTRCALL *utf16Convert)(const ENCODING *enc, + const char **fromP, + const char *fromLim, + unsigned short **toP, + const unsigned short *toLim); int minBytesPerChar; char isUtf8; char isUtf16; @@ -255,47 +263,50 @@ typedef struct { 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 * +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 FASTCALL XmlUtf8Encode(int charNumber, char *buf); +int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf); +int XmlSizeOfUnknownEncoding(void); + +typedef int (*CONVERTER)(void *userData, const char *p); + +ENCODING * XmlInitUnknownEncoding(void *mem, int *table, - int (*conv)(void *userData, const char *p), + CONVERTER convert, 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 * +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), + CONVERTER convert, void *userData); #ifdef __cplusplus } diff --git a/extras/expat/lib/xmltok_impl.c b/extras/expat/lib/xmltok_impl.c index 29c546af2..84a326792 100644 --- a/extras/expat/lib/xmltok_impl.c +++ b/extras/expat/lib/xmltok_impl.c @@ -86,9 +86,9 @@ /* ptr points to character following "<!-" */ -static int -PREFIX(scanComment)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) +static int PTRCALL +PREFIX(scanComment)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) { if (ptr != end) { if (!CHAR_MATCHES(enc, ptr, ASCII_MINUS)) { @@ -124,9 +124,9 @@ PREFIX(scanComment)(const ENCODING *enc, const char *ptr, const char *end, /* ptr points to character following "<!" */ -static int -PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) +static int PTRCALL +PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) { if (ptr == end) return XML_TOK_PARTIAL; @@ -171,7 +171,7 @@ PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, const char *end, return XML_TOK_PARTIAL; } -static int +static int PTRCALL PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, const char *end, int *tokPtr) { @@ -216,9 +216,9 @@ PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, /* ptr points to character following "<?" */ -static int -PREFIX(scanPi)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) +static int PTRCALL +PREFIX(scanPi)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) { int tok; const char *target = ptr; @@ -278,9 +278,9 @@ PREFIX(scanPi)(const ENCODING *enc, const char *ptr, const char *end, return XML_TOK_PARTIAL; } -static int -PREFIX(scanCdataSection)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) +static int PTRCALL +PREFIX(scanCdataSection)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) { static const char CDATA_LSQB[] = { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, ASCII_LSQB }; @@ -298,9 +298,9 @@ PREFIX(scanCdataSection)(const ENCODING *enc, const char *ptr, const char *end, return XML_TOK_CDATA_SECT_OPEN; } -static int -PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) +static int PTRCALL +PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) { if (ptr == end) return XML_TOK_NONE; @@ -376,9 +376,9 @@ PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, const char *end, /* ptr points to character following "</" */ -static int -PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) +static int PTRCALL +PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) { if (ptr == end) return XML_TOK_PARTIAL; @@ -425,9 +425,9 @@ PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, const char *end, /* ptr points to character following "&#X" */ -static int -PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) +static int PTRCALL +PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) { if (ptr != end) { switch (BYTE_TYPE(enc, ptr)) { @@ -457,9 +457,9 @@ PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, const char *end, /* ptr points to character following "&#" */ -static int -PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) +static int PTRCALL +PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) { if (ptr != end) { if (CHAR_MATCHES(enc, ptr, ASCII_x)) @@ -489,7 +489,7 @@ PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, const char *end, /* ptr points to character following "&" */ -static int +static int PTRCALL PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { @@ -519,7 +519,7 @@ PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end, /* ptr points to character following first character of attribute name */ -static int +static int PTRCALL PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { @@ -678,7 +678,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end, /* ptr points to character following "<" */ -static int +static int PTRCALL PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { @@ -696,7 +696,8 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end, case BT_MINUS: return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr); case BT_LSQB: - return PREFIX(scanCdataSection)(enc, ptr + MINBPC(enc), end, nextTokPtr); + return PREFIX(scanCdataSection)(enc, ptr + MINBPC(enc), + end, nextTokPtr); } *nextTokPtr = ptr; return XML_TOK_INVALID; @@ -777,7 +778,7 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end, return XML_TOK_PARTIAL; } -static int +static int PTRCALL PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { @@ -876,7 +877,7 @@ PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end, /* ptr points to character following "%" */ -static int +static int PTRCALL PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { @@ -905,7 +906,7 @@ PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end, return XML_TOK_PARTIAL; } -static int +static int PTRCALL PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { @@ -932,7 +933,7 @@ PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end, return -XML_TOK_POUND_NAME; } -static int +static int PTRCALL PREFIX(scanLit)(int open, const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) @@ -964,7 +965,7 @@ PREFIX(scanLit)(int open, const ENCODING *enc, return XML_TOK_PARTIAL; } -static int +static int PTRCALL PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { @@ -1008,8 +1009,11 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, return XML_TOK_INVALID; } case BT_CR: - if (ptr + MINBPC(enc) == end) + if (ptr + MINBPC(enc) == end) { + *nextTokPtr = end; + /* indicate that this might be part of a CR/LF pair */ return -XML_TOK_PROLOG_S; + } /* fall through */ case BT_S: case BT_LF: for (;;) { @@ -1192,7 +1196,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, return -tok; } -static int +static int PTRCALL PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { @@ -1250,9 +1254,9 @@ PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, return XML_TOK_DATA_CHARS; } -static int -PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) +static int PTRCALL +PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) { const char *start; if (ptr == end) @@ -1307,9 +1311,9 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end, #ifdef XML_DTD -static int -PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, const char *end, - const char **nextTokPtr) +static int PTRCALL +PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, + const char *end, const char **nextTokPtr) { int level = 0; if (MINBPC(enc) > 1) { @@ -1360,7 +1364,7 @@ PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, const char *end, #endif /* XML_DTD */ -static int +static int PTRCALL PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end, const char **badPtr) { @@ -1420,7 +1424,7 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end, first attsMax attributes are stored in atts. */ -static int +static int PTRCALL PREFIX(getAtts)(const ENCODING *enc, const char *ptr, int attsMax, ATTRIBUTE *atts) { @@ -1513,14 +1517,16 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr, /* not reached */ } -static int +static int PTRFASTCALL PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr) { int result = 0; /* skip &# */ ptr += 2*MINBPC(enc); if (CHAR_MATCHES(enc, ptr, ASCII_x)) { - for (ptr += MINBPC(enc); !CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) { + for (ptr += MINBPC(enc); + !CHAR_MATCHES(enc, ptr, ASCII_SEMI); + ptr += MINBPC(enc)) { int c = BYTE_TO_ASCII(enc, ptr); switch (c) { case ASCII_0: case ASCII_1: case ASCII_2: case ASCII_3: case ASCII_4: @@ -1528,11 +1534,13 @@ PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr) result <<= 4; result |= (c - ASCII_0); break; - case ASCII_A: case ASCII_B: case ASCII_C: case ASCII_D: case ASCII_E: case ASCII_F: + case ASCII_A: case ASCII_B: case ASCII_C: + case ASCII_D: case ASCII_E: case ASCII_F: result <<= 4; result += 10 + (c - ASCII_A); break; - case ASCII_a: case ASCII_b: case ASCII_c: case ASCII_d: case ASCII_e: case ASCII_f: + case ASCII_a: case ASCII_b: case ASCII_c: + case ASCII_d: case ASCII_e: case ASCII_f: result <<= 4; result += 10 + (c - ASCII_a); break; @@ -1553,7 +1561,7 @@ PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr) return checkCharRefNumber(result); } -static int +static int PTRCALL PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr, const char *end) { @@ -1607,7 +1615,7 @@ PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr, return 0; } -static int +static int PTRCALL PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2) { for (;;) { @@ -1671,7 +1679,7 @@ PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2) /* not reached */ } -static int +static int PTRCALL PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1, const char *end1, const char *ptr2) { @@ -1684,7 +1692,7 @@ PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1, return ptr1 == end1; } -static int +static int PTRFASTCALL PREFIX(nameLength)(const ENCODING *enc, const char *ptr) { const char *start = ptr; @@ -1711,7 +1719,7 @@ PREFIX(nameLength)(const ENCODING *enc, const char *ptr) } } -static const char * +static const char * PTRFASTCALL PREFIX(skipS)(const ENCODING *enc, const char *ptr) { for (;;) { @@ -1727,7 +1735,7 @@ PREFIX(skipS)(const ENCODING *enc, const char *ptr) } } -static void +static void PTRCALL PREFIX(updatePosition)(const ENCODING *enc, const char *ptr, const char *end, @@ -1768,3 +1776,4 @@ PREFIX(updatePosition)(const ENCODING *enc, #undef CHECK_NAME_CASES #undef CHECK_NMSTRT_CASE #undef CHECK_NMSTRT_CASES + diff --git a/extras/expat/lib/xmltok_ns.c b/extras/expat/lib/xmltok_ns.c index 65a3d4228..5610eb95b 100644 --- a/extras/expat/lib/xmltok_ns.c +++ b/extras/expat/lib/xmltok_ns.c @@ -29,7 +29,7 @@ static const ENCODING *NS(encodings)[] = { &ns(utf8_encoding).enc /* NO_ENC */ }; -static int +static int PTRCALL NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { @@ -37,7 +37,7 @@ NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end, XML_PROLOG_STATE, ptr, end, nextTokPtr); } -static int +static int PTRCALL NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end, const char **nextTokPtr) { diff --git a/extras/expat/tests/README.txt b/extras/expat/tests/README.txt new file mode 100644 index 000000000..1ee72edc5 --- /dev/null +++ b/extras/expat/tests/README.txt @@ -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. diff --git a/extras/expat/tests/chardata.c b/extras/expat/tests/chardata.c new file mode 100644 index 000000000..4a228a7a1 --- /dev/null +++ b/extras/expat/tests/chardata.c @@ -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; +} diff --git a/extras/expat/tests/chardata.h b/extras/expat/tests/chardata.h new file mode 100644 index 000000000..0f33c0dac --- /dev/null +++ b/extras/expat/tests/chardata.h @@ -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 */ diff --git a/extras/expat/tests/runtests.c b/extras/expat/tests/runtests.c new file mode 100644 index 000000000..4da96dd4d --- /dev/null +++ b/extras/expat/tests/runtests.c @@ -0,0 +1,1364 @@ +#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_unless(0, file, line, 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), XML_TRUE) == XML_STATUS_OK) + /* Hackish use of _fail_unless() macro, but let's us report + the right filename and line number. */ + _fail_unless(0, file, lineno, errorMessage); + if (XML_GetErrorCode(parser) != errorCode) + _xml_failure(parser, file, lineno); +} + +#define expect_failure(text, errorCode, errorMessage) \ + _expect_failure((text), (errorCode), (errorMessage), \ + __FILE__, __LINE__) + +/* Dummy handlers for when we need to set a handler to tickle a bug, + but it doesn't need to do anything. +*/ + +static void +dummy_start_doctype_handler(void *userData, + const XML_Char *doctypeName, + const XML_Char *sysid, + const XML_Char *pubid, + int has_internal_subset) +{} + +static void +dummy_end_doctype_handler(void *userData) +{} + +static void +dummy_entity_decl_handler(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) +{} + +static void +dummy_notation_decl_handler(void *userData, + const XML_Char *notationName, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId) +{} + +static void +dummy_element_decl_handler(void *userData, + const XML_Char *name, + XML_Content *model) +{} + +static void +dummy_attlist_decl_handler(void *userData, + const XML_Char *elname, + const XML_Char *attname, + const XML_Char *att_type, + const XML_Char *dflt, + int isrequired) +{} + +static void +dummy_comment_handler(void *userData, const XML_Char *data) +{} + +static void +dummy_pi_handler(void *userData, const XML_Char *target, const XML_Char *data) +{} + +static void +dummy_start_element(void *userData, + const XML_Char *name, const XML_Char **atts) +{} + + +/* + * 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, XML_TRUE) == 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), XML_TRUE) == 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, XML_TRUE) == 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, XML_TRUE) == 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, + const char *file, int line) +{ + CharData storage; + + CharData_Init(&storage); + XML_SetUserData(parser, &storage); + XML_SetCharacterDataHandler(parser, accumulate_characters); + if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR) + _xml_failure(parser, file, line); + CharData_CheckXMLChars(&storage, expected); +} + +#define run_character_check(text, expected) \ + _run_character_check(text, expected, __FILE__, __LINE__) + +static void +_run_attribute_check(XML_Char *text, XML_Char *expected, + const char *file, int line) +{ + CharData storage; + + CharData_Init(&storage); + XML_SetUserData(parser, &storage); + XML_SetStartElementHandler(parser, accumulate_attribute); + if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR) + _xml_failure(parser, file, line); + CharData_CheckXMLChars(&storage, expected); +} + +#define run_attribute_check(text, expected) \ + _run_attribute_check(text, expected, __FILE__, __LINE__) + +/* 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), XML_TRUE) == 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, XML_TRUE) == 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, XML_FALSE) + == 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, XML_TRUE); + 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 #1 for SF bug #653180. */ +START_TEST(test_line_number_after_parse) +{ + char *text = + "<tag>\n" + "\n" + "\n</tag>"; + int lineno; + + if (XML_Parse(parser, text, strlen(text), XML_FALSE) == XML_STATUS_ERROR) + xml_failure(parser); + lineno = XML_GetCurrentLineNumber(parser); + if (lineno != 4) { + char buffer[100]; + sprintf(buffer, "expected 4 lines, saw %d", lineno); + fail(buffer); + } +} +END_TEST + +/* Regression test #2 for SF bug #653180. */ +START_TEST(test_column_number_after_parse) +{ + char *text = "<tag></tag>"; + int colno; + + if (XML_Parse(parser, text, strlen(text), XML_FALSE) == XML_STATUS_ERROR) + xml_failure(parser); + colno = XML_GetCurrentColumnNumber(parser); + if (colno != 11) { + char buffer[100]; + sprintf(buffer, "expected 11 columns, saw %d", colno); + fail(buffer); + } +} +END_TEST + +static void +start_element_event_handler2(void *userData, const XML_Char *name, + const XML_Char **attr) +{ + CharData *storage = (CharData *) userData; + char buffer[100]; + + sprintf(buffer, "<%s> at col:%d line:%d\n", name, + XML_GetCurrentColumnNumber(parser), + XML_GetCurrentLineNumber(parser)); + CharData_AppendString(storage, buffer); +} + +static void +end_element_event_handler2(void *userData, const XML_Char *name) +{ + CharData *storage = (CharData *) userData; + char buffer[100]; + + sprintf(buffer, "</%s> at col:%d line:%d\n", name, + XML_GetCurrentColumnNumber(parser), + XML_GetCurrentLineNumber(parser)); + CharData_AppendString(storage, buffer); +} + +/* Regression test #3 for SF bug #653180. */ +START_TEST(test_line_and_column_numbers_inside_handlers) +{ + char *text = + "<a>\n" /* Unix end-of-line */ + " <b>\r\n" /* Windows end-of-line */ + " <c/>\r" /* Mac OS end-of-line */ + " </b>\n" + " <d>\n" + " <f/>\n" + " </d>\n" + "</a>"; + char *expected = + "<a> at col:0 line:1\n" + "<b> at col:2 line:2\n" + "<c> at col:4 line:3\n" + "</c> at col:8 line:3\n" + "</b> at col:2 line:4\n" + "<d> at col:2 line:5\n" + "<f> at col:4 line:6\n" + "</f> at col:8 line:6\n" + "</d> at col:2 line:7\n" + "</a> at col:0 line:8\n"; + CharData storage; + + CharData_Init(&storage); + XML_SetUserData(parser, &storage); + XML_SetStartElementHandler(parser, start_element_event_handler2); + XML_SetEndElementHandler(parser, end_element_event_handler2); + if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR) + xml_failure(parser); + + CharData_CheckString(&storage, expected); +} +END_TEST + +/* Regression test #4 for SF bug #653180. */ +START_TEST(test_line_number_after_error) +{ + char *text = + "<a>\n" + " <b>\n" + " </a>"; /* missing </b> */ + int lineno; + if (XML_Parse(parser, text, strlen(text), XML_FALSE) != XML_STATUS_ERROR) + fail("Expected a parse error"); + + lineno = XML_GetCurrentLineNumber(parser); + if (lineno != 3) { + char buffer[100]; + sprintf(buffer, "expected 3 lines, saw %d", lineno); + fail(buffer); + } +} +END_TEST + +/* Regression test #5 for SF bug #653180. */ +START_TEST(test_column_number_after_error) +{ + char *text = + "<a>\n" + " <b>\n" + " </a>"; /* missing </b> */ + int colno; + if (XML_Parse(parser, text, strlen(text), XML_FALSE) != XML_STATUS_ERROR) + fail("Expected a parse error"); + + colno = XML_GetCurrentColumnNumber(parser); + if (colno != 4) { + char buffer[100]; + sprintf(buffer, "expected 4 columns, saw %d", colno); + 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), XML_TRUE) == 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), XML_TRUE) == 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), XML_TRUE) == 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 XML_STATUS_OK; + } + return XML_STATUS_ERROR; +} + +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), XML_TRUE) == XML_STATUS_ERROR) + xml_failure(parser); +} +END_TEST + +/* Regression test for SF bug #620106. */ +static int +external_entity_loader_set_encoding(XML_Parser parser, + const XML_Char *context, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId) +{ + /* This text says it's an unsupported encoding, but it's really + UTF-8, which we tell Expat using XML_SetEncoding(). + */ + char *text = + "<?xml encoding='iso-8859-3'?>" + "\xC3\xA9"; + XML_Parser extparser; + + extparser = XML_ExternalEntityParserCreate(parser, context, NULL); + if (extparser == NULL) + fail("Could not create external entity parser."); + if (!XML_SetEncoding(extparser, "utf-8")) + fail("XML_SetEncoding() ignored for external entity"); + if ( XML_Parse(extparser, text, strlen(text), XML_TRUE) + == XML_STATUS_ERROR) { + xml_failure(parser); + return 0; + } + return 1; +} + +START_TEST(test_ext_entity_set_encoding) +{ + char *text = + "<!DOCTYPE doc [\n" + " <!ENTITY en SYSTEM 'http://xml.libexpat.org/dummy.ent'>\n" + "]>\n" + "<doc>&en;</doc>"; + + XML_SetExternalEntityRefHandler(parser, + external_entity_loader_set_encoding); + run_character_check(text, "\xC3\xA9"); +} +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), XML_TRUE) == 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), XML_TRUE) + == XML_STATUS_ERROR) { + xml_failure(parser); + return XML_STATUS_ERROR; + } + return XML_STATUS_OK; +} + +/* Test that an error is reported for unknown entities if we have read + an external subset, and standalone is true. +*/ +START_TEST(test_wfc_undeclared_entity_with_external_subset_standalone) { + char *text = + "<?xml version='1.0' encoding='us-ascii' standalone='yes'?>\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 (external DTD)."); +} +END_TEST + +/* Test that no error is reported for unknown entities if we have read + an external subset, and standalone is false. +*/ +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); + if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR) + xml_failure(parser); +} +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 + +/* Regression test for SF bug #483514. */ +START_TEST(test_dtd_default_handling) +{ + char *text = + "<!DOCTYPE doc [\n" + "<!ENTITY e SYSTEM 'http://xml.libexpat.org/e'>\n" + "<!NOTATION n SYSTEM 'http://xml.libexpat.org/n'>\n" + "<!ELEMENT doc EMPTY>\n" + "<!ATTLIST doc a CDATA #IMPLIED>\n" + "<?pi in dtd?>\n" + "<!--comment in dtd-->\n" + "]><doc/>"; + + XML_SetDefaultHandler(parser, accumulate_characters); + XML_SetDoctypeDeclHandler(parser, + dummy_start_doctype_handler, + dummy_end_doctype_handler); + XML_SetEntityDeclHandler(parser, dummy_entity_decl_handler); + XML_SetNotationDeclHandler(parser, dummy_notation_decl_handler); + XML_SetElementDeclHandler(parser, dummy_element_decl_handler); + XML_SetAttlistDeclHandler(parser, dummy_attlist_decl_handler); + XML_SetProcessingInstructionHandler(parser, dummy_pi_handler); + XML_SetCommentHandler(parser, dummy_comment_handler); + run_character_check(text, "\n\n\n\n\n\n\n<doc/>"); +} +END_TEST + +/* See related SF bug #673791. + When namespace processing is enabled, setting the namespace URI for + a prefix is not allowed; this test ensures that it *is* allowed + when namespace processing is not enabled. + (See Namespaces in XML, section 2.) +*/ +START_TEST(test_empty_ns_without_namespaces) +{ + char *text = + "<doc xmlns:prefix='http://www.example.com/'>\n" + " <e xmlns:prefix=''/>\n" + "</doc>"; + + if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR) + xml_failure(parser); +} +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, XML_TRUE); + XML_SetUserData(parser, elemstr); + XML_SetElementHandler(parser, triplet_start_checker, triplet_end_checker); + if (XML_Parse(parser, text, strlen(text), XML_TRUE) == 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), XML_TRUE) == 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, XML_TRUE); + run_ns_tagname_overwrite_test(text, result); +} +END_TEST + + +/* Regression test for SF bug #620343. */ +static void +start_element_fail(void *userData, + const XML_Char *name, const XML_Char **atts) +{ + /* We should never get here. */ + fail("should never reach start_element_fail()"); +} + +static void +start_ns_clearing_start_element(void *userData, + const XML_Char *prefix, + const XML_Char *uri) +{ + XML_SetStartElementHandler((XML_Parser) userData, NULL); +} + +START_TEST(test_start_ns_clears_start_element) +{ + /* This needs to use separate start/end tags; using the empty tag + syntax doesn't cause the problematic path through Expat to be + taken. + */ + char *text = "<e xmlns='http://xml.libexpat.org/'></e>"; + + XML_SetStartElementHandler(parser, start_element_fail); + XML_SetStartNamespaceDeclHandler(parser, start_ns_clearing_start_element); + XML_UseParserAsHandlerArg(parser); + if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR) + xml_failure(parser); +} +END_TEST + +/* Regression test for SF bug #616863. */ +static int +external_entity_handler(XML_Parser parser, + const XML_Char *context, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId) +{ + int callno = 1 + (int)XML_GetUserData(parser); + char *text; + XML_Parser p2; + + if (callno == 1) + text = ("<!ELEMENT doc (e+)>\n" + "<!ATTLIST doc xmlns CDATA #IMPLIED>\n" + "<!ELEMENT e EMPTY>\n"); + else + text = ("<?xml version='1.0' encoding='us-ascii'?>" + "<e/>"); + + XML_SetUserData(parser, (void *) callno); + p2 = XML_ExternalEntityParserCreate(parser, context, NULL); + if (XML_Parse(p2, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR) { + xml_failure(p2); + return 0; + } + XML_ParserFree(p2); + return 1; +} + +START_TEST(test_default_ns_from_ext_subset_and_ext_ge) +{ + char *text = + "<?xml version='1.0'?>\n" + "<!DOCTYPE doc SYSTEM 'http://xml.libexpat.org/doc.dtd' [\n" + " <!ENTITY en SYSTEM 'http://xml.libexpat.org/entity.ent'>\n" + "]>\n" + "<doc xmlns='http://xml.libexpat.org/ns1'>\n" + "&en;\n" + "</doc>"; + + XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS); + XML_SetExternalEntityRefHandler(parser, external_entity_handler); + /* We actually need to set this handler to tickle this bug. */ + XML_SetStartElementHandler(parser, dummy_start_element); + XML_SetUserData(parser, NULL); + if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR) + xml_failure(parser); +} +END_TEST + +/* Regression test #1 for SF bug #673791. */ +START_TEST(test_ns_prefix_with_empty_uri_1) +{ + char *text = + "<doc xmlns:prefix='http://xml.libexpat.org/'>\n" + " <e xmlns:prefix=''/>\n" + "</doc>"; + + expect_failure(text, + XML_ERROR_SYNTAX, + "Did not report re-setting namespace" + " URI with prefix to ''."); +} +END_TEST + +/* Regression test #2 for SF bug #673791. */ +START_TEST(test_ns_prefix_with_empty_uri_2) +{ + char *text = + "<?xml version='1.0'?>\n" + "<docelem xmlns:pre=''/>"; + + expect_failure(text, + XML_ERROR_SYNTAX, + "Did not report setting namespace URI with prefix to ''."); +} +END_TEST + +/* Regression test #3 for SF bug #673791. */ +START_TEST(test_ns_prefix_with_empty_uri_3) +{ + char *text = + "<!DOCTYPE doc [\n" + " <!ELEMENT doc EMPTY>\n" + " <!ATTLIST doc\n" + " xmlns:prefix CDATA ''>\n" + "]>\n" + "<doc/>"; + + expect_failure(text, + XML_ERROR_SYNTAX, + "Didn't report attr default setting NS w/ prefix to ''."); +} +END_TEST + +/* Regression test #4 for SF bug #673791. */ +START_TEST(test_ns_prefix_with_empty_uri_4) +{ + char *text = + "<!DOCTYPE doc [\n" + " <!ELEMENT prefix:doc EMPTY>\n" + " <!ATTLIST prefix:doc\n" + " xmlns:prefix CDATA 'http://xml.libexpat.org/'>\n" + "]>\n" + "<prefix:doc/>"; + /* Packaged info expected by the end element handler; + the weird structuring lets us re-use the triplet_end_checker() + function also used for another test. */ + char *elemstr[] = { + "http://xml.libexpat.org/ doc prefix" + }; + XML_SetReturnNSTriplet(parser, XML_TRUE); + XML_SetUserData(parser, elemstr); + XML_SetEndElementHandler(parser, triplet_end_checker); + if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR) + xml_failure(parser); +} +END_TEST + +START_TEST(test_ns_default_with_empty_uri) +{ + char *text = + "<doc xmlns='http://xml.libexpat.org/'>\n" + " <e xmlns=''/>\n" + "</doc>"; + if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR) + xml_failure(parser); +} +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_number_after_parse); + tcase_add_test(tc_basic, test_column_number_after_parse); + tcase_add_test(tc_basic, test_line_and_column_numbers_inside_handlers); + tcase_add_test(tc_basic, test_line_number_after_error); + tcase_add_test(tc_basic, test_column_number_after_error); + 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_undeclared_entity_with_external_subset_standalone); + tcase_add_test(tc_basic, test_wfc_no_recursive_entity_refs); + tcase_add_test(tc_basic, test_ext_entity_set_encoding); + tcase_add_test(tc_basic, test_dtd_default_handling); + tcase_add_test(tc_basic, test_empty_ns_without_namespaces); + + 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); + tcase_add_test(tc_namespace, test_start_ns_clears_start_element); + tcase_add_test(tc_namespace, test_default_ns_from_ext_subset_and_ext_ge); + tcase_add_test(tc_namespace, test_ns_prefix_with_empty_uri_1); + tcase_add_test(tc_namespace, test_ns_prefix_with_empty_uri_2); + tcase_add_test(tc_namespace, test_ns_prefix_with_empty_uri_3); + tcase_add_test(tc_namespace, test_ns_prefix_with_empty_uri_4); + tcase_add_test(tc_namespace, test_ns_default_with_empty_uri); + + 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); + if (verbosity != CK_SILENT) + printf("Expat version: %s\n", XML_ExpatVersion()); + srunner_run_all(sr, verbosity); + nf = srunner_ntests_failed(sr); + srunner_free(sr); + suite_free(s); + + return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/extras/expat/tests/xmltest.sh b/extras/expat/tests/xmltest.sh new file mode 100755 index 000000000..ecb163715 --- /dev/null +++ b/extras/expat/tests/xmltest.sh @@ -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" diff --git a/extras/expat/vms/README.vms b/extras/expat/vms/README.vms new file mode 100644 index 000000000..3dd2ca73f --- /dev/null +++ b/extras/expat/vms/README.vms @@ -0,0 +1,23 @@ +4-jun-2002 Craig A. Berry + Added rudimentary build procedures for + OpenVMS based on work by Martin Vorlaender. + + +You'll need MMS or its freeware equivalent MMK. Just go to the +top-level directory and type + +$ MMS/DESCRIPTION=[.vms] + + or + +$ MMK/DESCRIPTION=[.vms] + +You'll end up with the object library expat.olb. For now, installation +consists merely of copying the object library, include files, and +documentation to a suitable location. + +To-do list: + + -- create a shareable image + -- build and run the tests and build the xmlwf utility + -- create an install target diff --git a/extras/expat/vms/descrip.mms b/extras/expat/vms/descrip.mms new file mode 100644 index 000000000..9e5d2ad87 --- /dev/null +++ b/extras/expat/vms/descrip.mms @@ -0,0 +1,69 @@ +# Bare bones description file (Makefile) for OpenVMS + +PACKAGE = expat +VERSION = 1.95.3 +EXPAT_MAJOR_VERSION=1 +EXPAT_MINOR_VERSION=95 +EXPAT_EDIT=3 + +O = .obj +OLB = .olb + +LIBRARY = expat$(OLB) +LIBDIR = [.lib] +SOURCES = $(LIBDIR)xmlparse.c $(LIBDIR)xmltok.c $(LIBDIR)xmlrole.c +OBJECTS = xmlparse$(O) xmltok$(O) xmlrole$(O) + +TEMPLATES = xmltok_impl.c xmltok_ns.c +APIHEADER = $(LIBDIR)expat.h +HEADERS = $(LIBDIR)ascii.h $(LIBDIR)iasciitab.h $(LIBDIR)utf8tab.h $(LIBDIR)xmltok.h \ + $(LIBDIR)asciitab.h $(LIBDIR)latin1tab.h \ + $(LIBDIR)nametab.h $(LIBDIR)xmldef.h $(LIBDIR)xmlrole.h $(LIBDIR)xmltok_impl.h + +CONFIG_HEADER = expat_config.h +INCLUDES = /INCLUDE=([],[.lib]) +DEFS = /DEFINE=(PACKAGE="""$(PACKAGE)""",VERSION="""$(PACKAGE)_$(VERSION)""") +LIBREVISION = 0 +LIBCURRENT = 1 +LIBAGE = 0 +# +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +# +# DISTFILES = $(DIST_COMMON) $(SOURCES) $(TEMPLATES) $(APIHEADER) $(HEADERS) +# +# TAR = gtar +# GZIP_ENV = --best +# +.FIRST : + IF F$SEARCH("$(LIBRARY)") .EQS. "" THEN $(LIBR) /CREATE /OBJECT $(LIBRARY) + +all : $(LIBRARY) + +.SUFFIXES : +.SUFFIXES : $(OLB) $(O) .C .H + +.c$(O) : + $(COMPILE) $(MMS$SOURCE) + +$(O)$(OLB) : + @ IF F$SEARCH("$(MMS$TARGET)") .EQS. "" - + THEN LIBRARY/CREATE/LOG $(MMS$TARGET) + @ LIBRARY /REPLACE /LOG $(MMS$TARGET) $(MMS$SOURCE) + +clean : + DELETE $(LIBRARY);*,*$(O);* + +$(LIBRARY) : $(LIBRARY)( $(OBJECTS) ) + $(LIBR) /COMPRESS $(MMS$TARGET) + +$(CONFIG_HEADER) : [.vms]expat_config.h + COPY/LOG $(MMS$SOURCE) $(MMS$TARGET) + +xmlparse$(O) : $(LIBDIR)xmlparse.c $(LIBDIR)expat.h $(LIBDIR)xmlrole.h $(LIBDIR)xmltok.h $(CONFIG_HEADER) + +xmlrole$(O) : $(LIBDIR)xmlrole.c $(LIBDIR)ascii.h $(LIBDIR)xmlrole.h $(CONFIG_HEADER) + +xmltok$(O) : $(LIBDIR)xmltok.c $(LIBDIR)xmltok_impl.c $(LIBDIR)xmltok_ns.c \ + $(LIBDIR)ascii.h $(LIBDIR)asciitab.h $(LIBDIR)iasciitab.h $(LIBDIR)latin1tab.h \ + $(LIBDIR)nametab.h $(LIBDIR)utf8tab.h $(LIBDIR)xmltok.h $(LIBDIR)xmltok_impl.h $(CONFIG_HEADER) + diff --git a/extras/expat/vms/expat_config.h b/extras/expat/vms/expat_config.h new file mode 100644 index 000000000..b7da6eeaa --- /dev/null +++ b/extras/expat/vms/expat_config.h @@ -0,0 +1,61 @@ +/* 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.) +*/ + +/* Define to empty if the keyword does not work. */ +#undef const + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define to `long' if <sys/types.h> doesn't define. */ +#undef off_t + +/* Define to `unsigned' if <sys/types.h> doesn't define. */ +#undef size_t + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if your processor stores words with the most significant + byte first (like Motorola and SPARC, unlike Intel and VAX). */ +#undef WORDS_BIGENDIAN + +/* Define if you have the bcopy function. */ +#undef HAVE_BCOPY + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE 1 + +/* Define if you have the <fcntl.h> header file. */ +#undef HAVE_FCNTL_H + +/* Define if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +#define XML_NS +#define XML_DTD + +#ifdef WORDS_BIGENDIAN +#define XML_BYTE_ORDER 21 +#else +#define XML_BYTE_ORDER 12 +#endif + +#define XML_CONTEXT_BYTES 1024 + +#ifndef HAVE_MEMMOVE +#ifdef HAVE_BCOPY +#define memmove(d,s,l) bcopy((s),(d),(l)) +#else +#define memmove(d,s,l) ;punting on memmove; +#endif + +#endif diff --git a/extras/expat/win32/MANIFEST.txt b/extras/expat/win32/MANIFEST.txt new file mode 100644 index 000000000..66b780ed3 --- /dev/null +++ b/extras/expat/win32/MANIFEST.txt @@ -0,0 +1,29 @@ + Overview of the Expat distribution + +The Expat distribution creates several subdirectories on your system. +Some of these directories contain components of interest to all Expat +users, and some contain material of interest to developers who wish to +use Expat in their applications. In the list below, <top> is the +directory you specified to the installer. + + Directory Contents + -------------------------------------------------------------------- + <top>\ The XML well-formedness checker and some general + information files. + + <top>\Doc\ API documentation for developers. + + <top>\Libs\ Pre-compiled dynamic libraries for developers. + + <top>\StaticLibs\ Pre-compiled static libraries for developers. + + <top>\Source\ Source code, which may interest some developers, + including a workspace for Microsft Visual C++. + The source code includes the parser, the well- + formedness checker, and a couple of small sample + applications. + + <top>\Source\bcb5\ Project files for Borland C++ Builder 5 and BCC + 5.5. + + <top>\Unistall\ The uninstaller and its data files. diff --git a/extras/expat/win32/expat.iss b/extras/expat/win32/expat.iss new file mode 100644 index 000000000..1ad7398cc --- /dev/null +++ b/extras/expat/win32/expat.iss @@ -0,0 +1,61 @@ +; Basic setup script for the Inno Setep installer builder. For more +; information on the free installer builder, see www.jrsoftware.org. +; +; This script was contributed by Tim Peters. +; The current version is used with Inno Setup 2.0.19. + +[Setup] +AppName=expat +AppId=expat +AppVersion=1.95.6 +AppVerName=expat 1.95.6 +AppCopyright=Copyright © 1998-2002 Thai Open Source Software Center, Clark Cooper, and the Expat maintainers +DefaultDirName={sd}\Expat-1.95.6 +AppPublisher=The Expat Developers +AppPublisherURL=http://www.libexpat.org/ +AppSupportURL=http://www.libexpat.org/ +AppUpdatesURL=http://www.libexpat.org/ +UninstallDisplayName=Expat XML Parser (version 1.95.6) +UninstallFilesDir={app}\Uninstall + +Compression=bzip/9 +SourceDir=.. +OutputDir=win32 +DisableStartupPrompt=yes +AllowNoIcons=yes +DisableProgramGroupPage=yes +DisableReadyPage=yes + +[Files] +CopyMode: alwaysoverwrite; Source: xmlwf\Release\*.exe; DestDir: "{app}" +CopyMode: alwaysoverwrite; Source: win32\MANIFEST.txt; DestDir: "{app}" +CopyMode: alwaysoverwrite; Source: Changes; DestDir: "{app}"; DestName: Changes.txt +CopyMode: alwaysoverwrite; Source: COPYING; DestDir: "{app}"; DestName: COPYING.txt +CopyMode: alwaysoverwrite; Source: README; DestDir: "{app}"; DestName: README.txt +CopyMode: alwaysoverwrite; Source: doc\*.html; DestDir: "{app}\Doc" +CopyMode: alwaysoverwrite; Source: doc\*.css; DestDir: "{app}\Doc" +CopyMode: alwaysoverwrite; Source: doc\*.png; DestDir: "{app}\Doc" +CopyMode: alwaysoverwrite; Source: lib\Release\*.dll; DestDir: "{app}\Libs" +CopyMode: alwaysoverwrite; Source: lib\Release\*.lib; DestDir: "{app}\Libs" +CopyMode: alwaysoverwrite; Source: lib\Release-w\*.dll; DestDir: "{app}\Libs" +CopyMode: alwaysoverwrite; Source: lib\Release-w\*.lib; DestDir: "{app}\Libs" +CopyMode: alwaysoverwrite; Source: lib\Release_static\*.lib; DestDir: "{app}\StaticLibs" +CopyMode: alwaysoverwrite; Source: lib\Release-w_static\*.lib; DestDir: "{app}\StaticLibs" +CopyMode: alwaysoverwrite; Source: expat.dsw; DestDir: "{app}\Source" +CopyMode: alwaysoverwrite; Source: bcb5\*.*; DestDir: "{app}\Source\bcb5" +CopyMode: alwaysoverwrite; Source: lib\*.c; DestDir: "{app}\Source\lib" +CopyMode: alwaysoverwrite; Source: lib\*.h; DestDir: "{app}\Source\lib" +CopyMode: alwaysoverwrite; Source: lib\*.def; DestDir: "{app}\Source\lib" +CopyMode: alwaysoverwrite; Source: lib\*.dsp; DestDir: "{app}\Source\lib" +CopyMode: alwaysoverwrite; Source: examples\*.c; DestDir: "{app}\Source\examples" +CopyMode: alwaysoverwrite; Source: examples\*.dsp; DestDir: "{app}\Source\examples" +CopyMode: alwaysoverwrite; Source: tests\*.c; DestDir: "{app}\Source\tests" +CopyMode: alwaysoverwrite; Source: tests\*.h; DestDir: "{app}\Source\tests" +CopyMode: alwaysoverwrite; Source: tests\README.txt; DestDir: "{app}\Source\tests" +CopyMode: alwaysoverwrite; Source: xmlwf\*.c*; DestDir: "{app}\Source\xmlwf" +CopyMode: alwaysoverwrite; Source: xmlwf\*.h; DestDir: "{app}\Source\xmlwf" +CopyMode: alwaysoverwrite; Source: xmlwf\*.dsp; DestDir: "{app}\Source\xmlwf" + +[Messages] +WelcomeLabel1=Welcome to the Expat XML Parser Setup Wizard +WelcomeLabel2=This will install [name/ver] on your computer.%n%nExpat is an XML parser with a C-language API, and is primarily made available to allow developers to build applications which use XML using a portable API and fast implementation.%n%nIt is strongly recommended that you close all other applications you have running before continuing. This will help prevent any conflicts during the installation process. diff --git a/extras/expat/xmlwf/readfilemap.c b/extras/expat/xmlwf/readfilemap.c index b68b2ce06..64c69850c 100644 --- a/extras/expat/xmlwf/readfilemap.c +++ b/extras/expat/xmlwf/readfilemap.c @@ -61,11 +61,13 @@ filemap(const char *name, n = read(fd, p, nbytes); if (n < 0) { perror(name); + free(p); close(fd); return 0; } if (n != nbytes) { fprintf(stderr, "%s: read unexpected number of bytes\n", name); + free(p); close(fd); return 0; } diff --git a/extras/expat/xmlwf/xmlfile.c b/extras/expat/xmlwf/xmlfile.c index 6bf1535fa..690be5230 100644 --- a/extras/expat/xmlwf/xmlfile.c +++ b/extras/expat/xmlwf/xmlfile.c @@ -66,7 +66,7 @@ processFile(const void *data, size_t size, { XML_Parser parser = ((PROCESS_ARGS *)args)->parser; int *retPtr = ((PROCESS_ARGS *)args)->retPtr; - if (!XML_Parse(parser, data, size, 1)) { + if (XML_Parse(parser, data, size, 1) == XML_STATUS_ERROR) { reportError(parser, filename); *retPtr = 0; } @@ -167,7 +167,7 @@ processStream(const XML_Char *filename, XML_Parser parser) close(fd); return 0; } - if (!XML_ParseBuffer(parser, nread, nread == 0)) { + if (XML_ParseBuffer(parser, nread, nread == 0) == XML_STATUS_ERROR) { reportError(parser, filename != NULL ? filename : "STDIN"); if (filename != NULL) close(fd); diff --git a/extras/expat/xmlwf/xmlwf.c b/extras/expat/xmlwf/xmlwf.c index 70ee4a03e..8a8056e55 100644 --- a/extras/expat/xmlwf/xmlwf.c +++ b/extras/expat/xmlwf/xmlwf.c @@ -244,56 +244,56 @@ processingInstruction(void *userData, const XML_Char *target, #endif /* not W3C14N */ static void -defaultCharacterData(XML_Parser parser, const XML_Char *s, int len) +defaultCharacterData(void *userData, const XML_Char *s, int len) { - XML_DefaultCurrent(parser); + XML_DefaultCurrent((XML_Parser) userData); } static void -defaultStartElement(XML_Parser parser, const XML_Char *name, +defaultStartElement(void *userData, const XML_Char *name, const XML_Char **atts) { - XML_DefaultCurrent(parser); + XML_DefaultCurrent((XML_Parser) userData); } static void -defaultEndElement(XML_Parser parser, const XML_Char *name) +defaultEndElement(void *userData, const XML_Char *name) { - XML_DefaultCurrent(parser); + XML_DefaultCurrent((XML_Parser) userData); } static void -defaultProcessingInstruction(XML_Parser parser, const XML_Char *target, +defaultProcessingInstruction(void *userData, const XML_Char *target, const XML_Char *data) { - XML_DefaultCurrent(parser); + XML_DefaultCurrent((XML_Parser) userData); } static void -nopCharacterData(XML_Parser parser, const XML_Char *s, int len) +nopCharacterData(void *userData, const XML_Char *s, int len) { } static void -nopStartElement(XML_Parser parser, const XML_Char *name, const XML_Char **atts) +nopStartElement(void *userData, const XML_Char *name, const XML_Char **atts) { } static void -nopEndElement(XML_Parser parser, const XML_Char *name) +nopEndElement(void *userData, const XML_Char *name) { } static void -nopProcessingInstruction(XML_Parser parser, const XML_Char *target, +nopProcessingInstruction(void *userData, const XML_Char *target, const XML_Char *data) { } static void -markup(XML_Parser parser, const XML_Char *s, int len) +markup(void *userData, const XML_Char *s, int len) { - FILE *fp = XML_GetUserData(parser); + FILE *fp = XML_GetUserData((XML_Parser) userData); for (; len > 0; --len, ++s) puttc(*s, fp); } @@ -313,21 +313,22 @@ metaLocation(XML_Parser parser) } static void -metaStartDocument(XML_Parser parser) +metaStartDocument(void *userData) { - fputts(T("<document>\n"), XML_GetUserData(parser)); + fputts(T("<document>\n"), XML_GetUserData((XML_Parser) userData)); } static void -metaEndDocument(XML_Parser parser) +metaEndDocument(void *userData) { - fputts(T("</document>\n"), XML_GetUserData(parser)); + fputts(T("</document>\n"), XML_GetUserData((XML_Parser) userData)); } static void -metaStartElement(XML_Parser parser, const XML_Char *name, +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); @@ -359,8 +360,9 @@ metaStartElement(XML_Parser parser, const XML_Char *name, } static void -metaEndElement(XML_Parser parser, const XML_Char *name) +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); @@ -368,9 +370,10 @@ metaEndElement(XML_Parser parser, const XML_Char *name) } static void -metaProcessingInstruction(XML_Parser parser, const XML_Char *target, +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)); @@ -380,8 +383,9 @@ metaProcessingInstruction(XML_Parser parser, const XML_Char *target, } static void -metaComment(XML_Parser parser, const XML_Char *data) +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)); @@ -391,8 +395,9 @@ metaComment(XML_Parser parser, const XML_Char *data) } static void -metaStartCdataSection(XML_Parser parser) +metaStartCdataSection(void *userData) { + XML_Parser parser = (XML_Parser) userData; FILE *fp = XML_GetUserData(parser); fputts(T("<startcdata"), fp); metaLocation(parser); @@ -400,8 +405,9 @@ metaStartCdataSection(XML_Parser parser) } static void -metaEndCdataSection(XML_Parser parser) +metaEndCdataSection(void *userData) { + XML_Parser parser = (XML_Parser) userData; FILE *fp = XML_GetUserData(parser); fputts(T("<endcdata"), fp); metaLocation(parser); @@ -409,8 +415,9 @@ metaEndCdataSection(XML_Parser parser) } static void -metaCharacterData(XML_Parser parser, const XML_Char *s, int len) +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); @@ -420,12 +427,13 @@ metaCharacterData(XML_Parser parser, const XML_Char *s, int len) } static void -metaStartDoctypeDecl(XML_Parser parser, +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); @@ -433,8 +441,9 @@ metaStartDoctypeDecl(XML_Parser parser, } static void -metaEndDoctypeDecl(XML_Parser parser) +metaEndDoctypeDecl(void *userData) { + XML_Parser parser = (XML_Parser) userData; FILE *fp = XML_GetUserData(parser); fputts(T("<enddoctype"), fp); metaLocation(parser); @@ -442,12 +451,13 @@ metaEndDoctypeDecl(XML_Parser parser) } static void -metaNotationDecl(XML_Parser parser, +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) @@ -463,7 +473,7 @@ metaNotationDecl(XML_Parser parser, static void -metaEntityDecl(XML_Parser parser, +metaEntityDecl(void *userData, const XML_Char *entityName, int is_param, const XML_Char *value, @@ -473,6 +483,7 @@ metaEntityDecl(XML_Parser parser, const XML_Char *publicId, const XML_Char *notationName) { + XML_Parser parser = (XML_Parser) userData; FILE *fp = XML_GetUserData(parser); if (value) { @@ -506,10 +517,11 @@ metaEntityDecl(XML_Parser parser, } static void -metaStartNamespaceDecl(XML_Parser parser, +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) @@ -524,8 +536,9 @@ metaStartNamespaceDecl(XML_Parser parser, } static void -metaEndNamespaceDecl(XML_Parser parser, const XML_Char *prefix) +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); @@ -586,12 +599,30 @@ showVersion(XML_Char *prog) { XML_Char *s = prog; XML_Char ch; + const XML_Feature *features = XML_GetFeatureList(); while ((ch = *s) != 0) { - if (ch == '/' || ch == '\\') + 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 diff --git a/extras/expat/xmlwf/xmlwin32url.cxx b/extras/expat/xmlwf/xmlwin32url.cxx index 4f33aa8e7..bbfcce22c 100644 --- a/extras/expat/xmlwf/xmlwin32url.cxx +++ b/extras/expat/xmlwf/xmlwin32url.cxx @@ -1,4 +1,4 @@ -#include "xmlparse.h" +#include "expat.h" #ifdef XML_UNICODE #define UNICODE #endif @@ -10,8 +10,8 @@ #include "xmlurl.h" #include "xmlmime.h" -static -int processURL(XML_Parser parser, IMoniker *baseMoniker, const XML_Char *url); +static int +processURL(XML_Parser parser, IMoniker *baseMoniker, const XML_Char *url); typedef void (*StopHandler)(void *, HRESULT); @@ -32,7 +32,8 @@ public: 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); + int externalEntityRef(const XML_Char *context, + const XML_Char *systemId, const XML_Char *publicId); private: XML_Parser parser_; IMoniker *baseMoniker_; @@ -43,12 +44,14 @@ private: void *stopArg_; }; -STDMETHODIMP_(ULONG) Callback::AddRef() +STDMETHODIMP_(ULONG) +Callback::AddRef() { return ref_++; } -STDMETHODIMP_(ULONG) Callback::Release() +STDMETHODIMP_(ULONG) +Callback::Release() { if (--ref_ == 0) { delete this; @@ -57,7 +60,8 @@ STDMETHODIMP_(ULONG) Callback::Release() return ref_; } -STDMETHODIMP Callback::QueryInterface(REFIID riid, void** ppv) +STDMETHODIMP +Callback::QueryInterface(REFIID riid, void** ppv) { if (IsEqualGUID(riid, IID_IUnknown)) *ppv = (IUnknown *)this; @@ -69,29 +73,34 @@ STDMETHODIMP Callback::QueryInterface(REFIID riid, void** ppv) return S_OK; } -STDMETHODIMP Callback::OnStartBinding(DWORD, IBinding* pBinding) +STDMETHODIMP +Callback::OnStartBinding(DWORD, IBinding* pBinding) { pBinding_ = pBinding; pBinding->AddRef(); return S_OK; } -STDMETHODIMP Callback::GetPriority(LONG *) +STDMETHODIMP +Callback::GetPriority(LONG *) { return E_NOTIMPL; } -STDMETHODIMP Callback::OnLowResource(DWORD) +STDMETHODIMP +Callback::OnLowResource(DWORD) { return E_NOTIMPL; } -STDMETHODIMP Callback::OnProgress(ULONG, ULONG, ULONG, LPCWSTR) +STDMETHODIMP +Callback::OnProgress(ULONG, ULONG, ULONG, LPCWSTR) { return S_OK; } -STDMETHODIMP Callback::OnStopBinding(HRESULT hr, LPCWSTR szError) +STDMETHODIMP +Callback::OnStopBinding(HRESULT hr, LPCWSTR szError) { if (pBinding_) { pBinding_->Release(); @@ -105,14 +114,15 @@ STDMETHODIMP Callback::OnStopBinding(HRESULT hr, LPCWSTR szError) return S_OK; } -STDMETHODIMP Callback::GetBindInfo(DWORD* pgrfBINDF, BINDINFO* pbindinfo) +STDMETHODIMP +Callback::GetBindInfo(DWORD* pgrfBINDF, BINDINFO* pbindinfo) { *pgrfBINDF = BINDF_ASYNCHRONOUS; return S_OK; } -static -void reportError(XML_Parser parser) +static void +reportError(XML_Parser parser) { int code = XML_GetErrorCode(parser); const XML_Char *message = XML_ErrorString(code); @@ -123,23 +133,27 @@ void reportError(XML_Parser parser) XML_GetErrorColumnNumber(parser), message); else - _ftprintf(stderr, _T("%s: (unknown message %d)\n"), XML_GetBase(parser), code); + _ftprintf(stderr, _T("%s: (unknown message %d)\n"), + XML_GetBase(parser), code); } -STDMETHODIMP Callback::OnDataAvailable(DWORD grfBSCF, - DWORD dwSize, - FORMATETC *pfmtetc, - STGMEDIUM* pstgmed) +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); + 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); + hr = hp->QueryInfo(HTTP_QUERY_CONTENT_TYPE, contentType, + &bufSize, 0, NULL); if (SUCCEEDED(hr)) { char charset[CHARSET_MAX]; getXMLCharset(contentType, charset); @@ -189,12 +203,16 @@ STDMETHODIMP Callback::OnDataAvailable(DWORD grfBSCF, return S_OK; } -STDMETHODIMP Callback::OnObjectAvailable(REFIID, IUnknown *) +STDMETHODIMP +Callback::OnObjectAvailable(REFIID, IUnknown *) { return S_OK; } -int Callback::externalEntityRef(const XML_Char *context, const XML_Char *systemId, const XML_Char *publicId) +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); @@ -203,7 +221,8 @@ int Callback::externalEntityRef(const XML_Char *context, const XML_Char *systemI return ret; } -Callback::Callback(XML_Parser parser, IMoniker *baseMoniker, StopHandler stopHandler, void *stopArg) +Callback::Callback(XML_Parser parser, IMoniker *baseMoniker, + StopHandler stopHandler, void *stopArg) : parser_(parser), baseMoniker_(baseMoniker), ref_(0), @@ -224,22 +243,22 @@ Callback::~Callback() baseMoniker_->Release(); } -static -int externalEntityRef(void *arg, - const XML_Char *context, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId) +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) +static HRESULT +openStream(XML_Parser parser, + IMoniker *baseMoniker, + const XML_Char *uri, + StopHandler stopHandler, void *stopArg) { if (!XML_SetBase(parser, uri)) return E_OUTOFMEMORY; @@ -289,8 +308,8 @@ struct QuitInfo { int stop; }; -static -void winPerror(const XML_Char *url, HRESULT hr) +static void +winPerror(const XML_Char *url, HRESULT hr) { LPVOID buf; if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER @@ -318,7 +337,8 @@ void winPerror(const XML_Char *url, HRESULT hr) _ftprintf(stderr, _T("%s: error %x\n"), url, hr); } -static void threadQuit(void *p, HRESULT hr) +static void +threadQuit(void *p, HRESULT hr) { QuitInfo *qi = (QuitInfo *)p; qi->hr = hr; @@ -326,19 +346,22 @@ static void threadQuit(void *p, HRESULT hr) } extern "C" -int XML_URLInit() +int +XML_URLInit(void) { return SUCCEEDED(CoInitialize(0)); } extern "C" -void XML_URLUninit() +void +XML_URLUninit(void) { CoUninitialize(); } -static -int processURL(XML_Parser parser, IMoniker *baseMoniker, const XML_Char *url) +static int +processURL(XML_Parser parser, IMoniker *baseMoniker, + const XML_Char *url) { QuitInfo qi; qi.stop = 0; @@ -363,9 +386,10 @@ int processURL(XML_Parser parser, IMoniker *baseMoniker, const XML_Char *url) } extern "C" -int XML_ProcessURL(XML_Parser parser, - const XML_Char *url, - unsigned flags) +int +XML_ProcessURL(XML_Parser parser, + const XML_Char *url, + unsigned flags) { return processURL(parser, 0, url); } |