ENH: deps: update some import libraries

1. update openssl to 3.1
2. update zlib to 1.2.13
3. update expat to 2.5

Change-Id: I46ac38f8e5acab4abae42645a56eec7d9381865e
(cherry picked from commit 34013820d325c41e1514d0f334f3c2be53145852)
This commit is contained in:
lane.wei 2023-08-11 21:37:12 +08:00 committed by Lane.Wei
parent 716285bd48
commit b6a2dcc057
29 changed files with 8617 additions and 5673 deletions

View File

@ -2,6 +2,65 @@ cmake_minimum_required(VERSION 3.0)
project(EXPAT) project(EXPAT)
include(${CMAKE_CURRENT_LIST_DIR}/ConfigureChecks.cmake)
macro(expat_shy_set var default cache type desc)
# Macro expat_shy_set came into life because:
# - Expat was previously using an inconsistent mix of CMake's native set()
# and option() to define public build time options.
# - option() is more friendly than set() with regard to configuring an
# external project that is pulled in by means of add_subdirectory() --
# see comments in issue #597 -- so we wanted to get away from set().
# - option() auto-converts non-bool values to bool when writing to the CMake
# cache, so we needed something that supports non-bool better and hence
# wanted to get away from plain option(), too.
#
# As a result, this function serves as a hybrid between CMake's regular set()
# and option(): from set() it takes support for non-bool types and the function
# name and signature whereas from option() (with policy CMP0077 mode NEW) it
# takes being shy when a value has previously been defined for that variable.
#
# So that resolves all need for set(.. FORCE) when pulling in Expat by means of
# add_subdirectory().
#
if(NOT ${cache} STREQUAL "CACHE")
message(SEND_ERROR "Macro usage is: expat_shy_set(var default CACHE type desc)")
endif()
if(DEFINED ${var})
# NOTE: The idea is to (ideally) only add to the cache if
# there is no cache entry, yet. "if(DEFINED CACHE{var})"
# requires CMake >=3.14.
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.14" AND NOT DEFINED "CACHE{${var}}")
set("${var}" "${${var}}" CACHE "${type}" "${desc}")
endif()
else()
set("${var}" "${default}" CACHE "${type}" "${desc}")
endif()
endmacro()
if(NOT WIN32)
expat_shy_set(EXPAT_WITH_GETRANDOM "AUTO" CACHE STRING "Make use of getrandom function (ON|OFF|AUTO) [default=AUTO]")
expat_shy_set(EXPAT_WITH_SYS_GETRANDOM "AUTO" CACHE STRING "Make use of syscall SYS_getrandom (ON|OFF|AUTO) [default=AUTO]")
endif()
macro(evaluate_detection_results use_ref have_ref thing_lower thing_title)
if(${use_ref} AND NOT (${use_ref} STREQUAL "AUTO") AND NOT ${have_ref})
message(SEND_ERROR
"Use of ${thing_lower} was enforced by ${use_ref}=ON but it could not be found.")
elseif(NOT ${use_ref} AND ${have_ref})
message("${thing_title} was found but it will not be used due to ${use_ref}=OFF.")
set(${have_ref} 0)
endif()
endmacro()
if(NOT WIN32)
evaluate_detection_results(EXPAT_WITH_GETRANDOM HAVE_GETRANDOM "function getrandom" "Function getrandom")
evaluate_detection_results(EXPAT_WITH_SYS_GETRANDOM HAVE_SYSCALL_GETRANDOM "syscall SYS_getrandom" "Syscall SYS_getrandom")
endif()
configure_file(expat_configure.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/expat_configure.h")
if (BUILD_SHARED_LIBS AND MSVC) if (BUILD_SHARED_LIBS AND MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif() endif()
@ -12,7 +71,7 @@ add_library(expat
xmltok.c xmltok.c
) )
target_include_directories(expat PRIVATE ${PROJECT_SOURCE_DIR}) target_include_directories(expat PRIVATE ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
include(GNUInstallDirs) include(GNUInstallDirs)

View File

@ -1,5 +1,5 @@
Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper
Copyright (c) 2001-2016 Expat maintainers Copyright (c) 2001-2022 Expat maintainers
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

69
deps/EXPAT/expat/ConfigureChecks.cmake vendored Normal file
View File

@ -0,0 +1,69 @@
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CheckSymbolExists)
include(TestBigEndian)
check_include_file("dlfcn.h" HAVE_DLFCN_H)
check_include_file("fcntl.h" HAVE_FCNTL_H)
check_include_file("inttypes.h" HAVE_INTTYPES_H)
check_include_file("memory.h" HAVE_MEMORY_H)
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("stdlib.h" HAVE_STDLIB_H)
check_include_file("strings.h" HAVE_STRINGS_H)
check_include_file("string.h" HAVE_STRING_H)
check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
check_include_file("unistd.h" HAVE_UNISTD_H)
check_symbol_exists("getpagesize" "unistd.h" HAVE_GETPAGESIZE)
check_symbol_exists("mmap" "sys/mman.h" HAVE_MMAP)
check_symbol_exists("getrandom" "sys/random.h" HAVE_GETRANDOM)
if(EXPAT_WITH_LIBBSD)
set(CMAKE_REQUIRED_LIBRARIES "${LIB_BSD}")
set(_bsd "bsd/")
else()
set(_bsd "")
endif()
check_symbol_exists("arc4random_buf" "${_bsd}stdlib.h" HAVE_ARC4RANDOM_BUF)
if(NOT HAVE_ARC4RANDOM_BUF)
check_symbol_exists("arc4random" "${_bsd}stdlib.h" HAVE_ARC4RANDOM)
endif()
set(CMAKE_REQUIRED_LIBRARIES)
#/* Define to 1 if you have the ANSI C header files. */
check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
test_big_endian(WORDS_BIGENDIAN)
#/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
if(WORDS_BIGENDIAN)
set(BYTEORDER 4321)
else(WORDS_BIGENDIAN)
set(BYTEORDER 1234)
endif(WORDS_BIGENDIAN)
if(HAVE_SYS_TYPES_H)
check_symbol_exists("off_t" "sys/types.h" OFF_T)
check_symbol_exists("size_t" "sys/types.h" SIZE_T)
else(HAVE_SYS_TYPES_H)
set(OFF_T "long")
set(SIZE_T "unsigned")
endif(HAVE_SYS_TYPES_H)
check_c_source_compiles("
#include <stdlib.h> /* for NULL */
#include <unistd.h> /* for syscall */
#include <sys/syscall.h> /* for SYS_getrandom */
int main() {
syscall(SYS_getrandom, NULL, 0, 0);
return 0;
}"
HAVE_SYSCALL_GETRANDOM)
check_c_compiler_flag("-fno-strict-aliasing" FLAG_NO_STRICT_ALIASING)
check_c_compiler_flag("-fvisibility=hidden" FLAG_VISIBILITY)
check_library_exists(m cos "" _EXPAT_LIBM_FOUND)

View File

@ -1,146 +0,0 @@
Expat, Release 2.2.0, stripped and modified for inclusion into Slic3r.
Only the library sources needed for static linking were left.
The original README follows:
---------------------------------------------------------------------
Expat, Release 2.2.0
This is Expat, a C library for parsing XML, written by James Clark.
Expat is a stream-oriented XML parser. This means that you register
handlers with the parser before starting the parse. These handlers
are called when the parser discovers the associated structures in the
document being parsed. A start tag is an example of the kind of
structures for which you may register handlers.
Windows users should use the expat_win32bin package, which includes
both precompiled libraries and executables, and source code for
developers.
Expat is free software. You may copy, distribute, and modify it under
the terms of the License contained in the file COPYING distributed
with this package. This license is the same as the MIT/X Consortium
license.
Versions of Expat that have an odd minor version (the middle number in
the release above), are development releases and should be considered
as beta software. Releases with even minor version numbers are
intended to be production grade software.
If you are building Expat from a check-out from the CVS repository,
you need to run a script that generates the configure script using the
GNU autoconf and libtool tools. To do this, you need to have
autoconf 2.58 or newer. Run the script like this:
./buildconf.sh
Once this has been done, follow the same instructions as for building
from a source distribution.
To build Expat from a source distribution, you first run the
configuration shell script in the top level distribution directory:
./configure
There are many options which you may provide to configure (which you
can discover by running configure with the --help option). But the
one of most interest is the one that sets the installation directory.
By default, the configure script will set things up to install
libexpat into /usr/local/lib, expat.h into /usr/local/include, and
xmlwf into /usr/local/bin. If, for example, you'd prefer to install
into /home/me/mystuff/lib, /home/me/mystuff/include, and
/home/me/mystuff/bin, you can tell configure about that with:
./configure --prefix=/home/me/mystuff
Another interesting option is to enable 64-bit integer support for
line and column numbers and the over-all byte index:
./configure CPPFLAGS=-DXML_LARGE_SIZE
However, such a modification would be a breaking change to the ABI
and is therefore not recommended for general use - e.g. as part of
a Linux distribution - but rather for builds with special requirements.
After running the configure script, the "make" command will build
things and "make install" will install things into their proper
location. Have a look at the "Makefile" to learn about additional
"make" options. Note that you need to have write permission into
the directories into which things will be installed.
If you are interested in building Expat to provide document
information in UTF-16 encoding rather than the default UTF-8, follow
these instructions (after having run "make distclean"):
1. For UTF-16 output as unsigned short (and version/error
strings as char), run:
./configure CPPFLAGS=-DXML_UNICODE
For UTF-16 output as wchar_t (incl. version/error strings),
run:
./configure CFLAGS="-g -O2 -fshort-wchar" \
CPPFLAGS=-DXML_UNICODE_WCHAR_T
2. Edit the MakeFile, changing:
LIBRARY = libexpat.la
to:
LIBRARY = libexpatw.la
(Note the additional "w" in the library name.)
3. Run "make buildlib" (which builds the library only).
Or, to save step 2, run "make buildlib LIBRARY=libexpatw.la".
4. Run "make installlib" (which installs the library only).
Or, if step 2 was omitted, run "make installlib LIBRARY=libexpatw.la".
Using DESTDIR or INSTALL_ROOT is enabled, with INSTALL_ROOT being the default
value for DESTDIR, and the rest of the make file using only DESTDIR.
It works as follows:
$ make install DESTDIR=/path/to/image
overrides the in-makefile set DESTDIR, while both
$ INSTALL_ROOT=/path/to/image make install
$ make install INSTALL_ROOT=/path/to/image
use DESTDIR=$(INSTALL_ROOT), even if DESTDIR eventually is defined in the
environment, because variable-setting priority is
1) commandline
2) in-makefile
3) environment
Note: This only applies to the Expat library itself, building UTF-16 versions
of xmlwf and the tests is currently not supported.
Note for Solaris users: The "ar" command is usually located in
"/usr/ccs/bin", which is not in the default PATH. You will need to
add this to your path for the "make" command, and probably also switch
to GNU make (the "make" found in /usr/ccs/bin does not seem to work
properly -- apparently it does not understand .PHONY directives). If
you're using ksh or bash, use this command to build:
PATH=/usr/ccs/bin:$PATH make
When using Expat with a project using autoconf for configuration, you
can use the probing macro in conftools/expat.m4 to determine how to
include Expat. See the comments at the top of that file for more
information.
A reference manual is available in the file doc/reference.html in this
distribution.
The homepage for this project is http://www.libexpat.org/. There
are links there to connect you to the bug reports page. If you need
to report a bug when you don't have access to a browser, you may also
send a bug report by email to expat-bugs@mail.libexpat.org.
Discussion related to the direction of future expat development takes
place on expat-discuss@mail.libexpat.org. Archives of this list and
other Expat-related lists may be found at:
http://mail.libexpat.org/mailman/listinfo/

274
deps/EXPAT/expat/README.md vendored Normal file
View File

@ -0,0 +1,274 @@
Expat, Release 2.5.0, only picked the lib related files into Bambu Studio, built as static library
The original README:
---------------------------------------------------------------------
[![Run Linux Travis CI tasks](https://github.com/libexpat/libexpat/actions/workflows/linux.yml/badge.svg)](https://github.com/libexpat/libexpat/actions/workflows/linux.yml)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/libexpat/libexpat?svg=true)](https://ci.appveyor.com/project/libexpat/libexpat)
[![Packaging status](https://repology.org/badge/tiny-repos/expat.svg)](https://repology.org/metapackage/expat/versions)
[![Downloads SourceForge](https://img.shields.io/sourceforge/dt/expat?label=Downloads%20SourceForge)](https://sourceforge.net/projects/expat/files/)
[![Downloads GitHub](https://img.shields.io/github/downloads/libexpat/libexpat/total?label=Downloads%20GitHub)](https://github.com/libexpat/libexpat/releases)
# Expat, Release 2.5.0
This is Expat, a C library for parsing XML, started by
[James Clark](https://en.wikipedia.org/wiki/James_Clark_%28programmer%29) in 1997.
Expat is a stream-oriented XML parser. This means that you register
handlers with the parser before starting the parse. These handlers
are called when the parser discovers the associated structures in the
document being parsed. A start tag is an example of the kind of
structures for which you may register handlers.
Expat supports the following compilers:
- GNU GCC >=4.5
- LLVM Clang >=3.5
- Microsoft Visual Studio >=15.0/2017 (rolling `${today} minus 5 years`)
Windows users can use the
[`expat-win32bin-*.*.*.{exe,zip}` download](https://github.com/libexpat/libexpat/releases),
which includes both pre-compiled libraries and executables, and source code for
developers.
Expat is [free software](https://www.gnu.org/philosophy/free-sw.en.html).
You may copy, distribute, and modify it under the terms of the License
contained in the file
[`COPYING`](https://github.com/libexpat/libexpat/blob/master/expat/COPYING)
distributed with this package.
This license is the same as the MIT/X Consortium license.
## Using libexpat in your CMake-Based Project
There are two ways of using libexpat with CMake:
### a) Module Mode
This approach leverages CMake's own [module `FindEXPAT`](https://cmake.org/cmake/help/latest/module/FindEXPAT.html).
Notice the *uppercase* `EXPAT` in the following example:
```cmake
cmake_minimum_required(VERSION 3.0) # or 3.10, see below
project(hello VERSION 1.0.0)
find_package(EXPAT 2.2.8 MODULE REQUIRED)
add_executable(hello
hello.c
)
# a) for CMake >=3.10 (see CMake's FindEXPAT docs)
target_link_libraries(hello PUBLIC EXPAT::EXPAT)
# b) for CMake >=3.0
target_include_directories(hello PRIVATE ${EXPAT_INCLUDE_DIRS})
target_link_libraries(hello PUBLIC ${EXPAT_LIBRARIES})
```
### b) Config Mode
This approach requires files from…
- libexpat >=2.2.8 where packaging uses the CMake build system
or
- libexpat >=2.3.0 where packaging uses the GNU Autotools build system
on Linux
or
- libexpat >=2.4.0 where packaging uses the GNU Autotools build system
on macOS or MinGW.
Notice the *lowercase* `expat` in the following example:
```cmake
cmake_minimum_required(VERSION 3.0)
project(hello VERSION 1.0.0)
find_package(expat 2.2.8 CONFIG REQUIRED char dtd ns)
add_executable(hello
hello.c
)
target_link_libraries(hello PUBLIC expat::expat)
```
## Building from a Git Clone
If you are building Expat from a check-out from the
[Git repository](https://github.com/libexpat/libexpat/),
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.58 or newer. Run the script like this:
```console
./buildconf.sh
```
Once this has been done, follow the same instructions as for building
from a source distribution.
## Building from a Source Distribution
### a) Building with the configure script (i.e. GNU Autotools)
To build Expat from a source distribution, you first run the
configuration shell script in the top level distribution directory:
```console
./configure
```
There are many options which you may provide to configure (which you
can discover by running configure with the `--help` option). But the
one of most interest is the one that sets the installation directory.
By default, the configure script will set things up to install
libexpat into `/usr/local/lib`, `expat.h` into `/usr/local/include`, and
`xmlwf` into `/usr/local/bin`. If, for example, you'd prefer to install
into `/home/me/mystuff/lib`, `/home/me/mystuff/include`, and
`/home/me/mystuff/bin`, you can tell `configure` about that with:
```console
./configure --prefix=/home/me/mystuff
```
Another interesting option is to enable 64-bit integer support for
line and column numbers and the over-all byte index:
```console
./configure CPPFLAGS=-DXML_LARGE_SIZE
```
However, such a modification would be a breaking change to the ABI
and is therefore not recommended for general use &mdash; e.g. as part of
a Linux distribution &mdash; but rather for builds with special requirements.
After running the configure script, the `make` command will build
things and `make install` will install things into their proper
location. Have a look at the `Makefile` to learn about additional
`make` options. Note that you need to have write permission into
the directories into which things will be installed.
If you are interested in building Expat to provide document
information in UTF-16 encoding rather than the default UTF-8, follow
these instructions (after having run `make distclean`).
Please note that we configure with `--without-xmlwf` as xmlwf does not
support this mode of compilation (yet):
1. Mass-patch `Makefile.am` files to use `libexpatw.la` for a library name:
<br/>
`find -name Makefile.am -exec sed
-e 's,libexpat\.la,libexpatw.la,'
-e 's,libexpat_la,libexpatw_la,'
-i {} +`
1. Run `automake` to re-write `Makefile.in` files:<br/>
`automake`
1. For UTF-16 output as unsigned short (and version/error strings as char),
run:<br/>
`./configure CPPFLAGS=-DXML_UNICODE --without-xmlwf`<br/>
For UTF-16 output as `wchar_t` (incl. version/error strings), run:<br/>
`./configure CFLAGS="-g -O2 -fshort-wchar" CPPFLAGS=-DXML_UNICODE_WCHAR_T
--without-xmlwf`
<br/>Note: The latter requires libc compiled with `-fshort-wchar`, as well.
1. Run `make` (which excludes xmlwf).
1. Run `make install` (again, excludes xmlwf).
Using `DESTDIR` is supported. It works as follows:
```console
make install DESTDIR=/path/to/image
```
overrides the in-makefile set `DESTDIR`, because variable-setting priority is
1. commandline
1. in-makefile
1. environment
Note: This only applies to the Expat library itself, building UTF-16 versions
of xmlwf and the tests is currently not supported.
When using Expat with a project using autoconf for configuration, you
can use the probing macro in `conftools/expat.m4` to determine how to
include Expat. See the comments at the top of that file for more
information.
A reference manual is available in the file `doc/reference.html` in this
distribution.
### b) Building with CMake
The CMake build system is still *experimental* and may replace the primary
build system based on GNU Autotools at some point when it is ready.
#### Available Options
For an idea of the available (non-advanced) options for building with CMake:
```console
# rm -f CMakeCache.txt ; cmake -D_EXPAT_HELP=ON -LH . | grep -B1 ':.*=' | sed 's,^--$,,'
// Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ...
CMAKE_BUILD_TYPE:STRING=
// Install path prefix, prepended onto install directories.
CMAKE_INSTALL_PREFIX:PATH=/usr/local
// Path to a program.
DOCBOOK_TO_MAN:FILEPATH=/usr/bin/docbook2x-man
// Build man page for xmlwf
EXPAT_BUILD_DOCS:BOOL=ON
// Build the examples for expat library
EXPAT_BUILD_EXAMPLES:BOOL=ON
// Build fuzzers for the expat library
EXPAT_BUILD_FUZZERS:BOOL=OFF
// Build pkg-config file
EXPAT_BUILD_PKGCONFIG:BOOL=ON
// Build the tests for expat library
EXPAT_BUILD_TESTS:BOOL=ON
// Build the xmlwf tool for expat library
EXPAT_BUILD_TOOLS:BOOL=ON
// Character type to use (char|ushort|wchar_t) [default=char]
EXPAT_CHAR_TYPE:STRING=char
// Install expat files in cmake install target
EXPAT_ENABLE_INSTALL:BOOL=ON
// Use /MT flag (static CRT) when compiling in MSVC
EXPAT_MSVC_STATIC_CRT:BOOL=OFF
// Build fuzzers via ossfuzz for the expat library
EXPAT_OSSFUZZ_BUILD:BOOL=OFF
// Build a shared expat library
EXPAT_SHARED_LIBS:BOOL=ON
// Treat all compiler warnings as errors
EXPAT_WARNINGS_AS_ERRORS:BOOL=OFF
// Make use of getrandom function (ON|OFF|AUTO) [default=AUTO]
EXPAT_WITH_GETRANDOM:STRING=AUTO
// Utilize libbsd (for arc4random_buf)
EXPAT_WITH_LIBBSD:BOOL=OFF
// Make use of syscall SYS_getrandom (ON|OFF|AUTO) [default=AUTO]
EXPAT_WITH_SYS_GETRANDOM:STRING=AUTO
```

View File

@ -1,5 +1,36 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd /*
See the file COPYING for copying permission. __ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1999-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2007 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#define ASCII_A 0x41 #define ASCII_A 0x41

View File

@ -1,5 +1,35 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd /*
See the file COPYING for copying permission. __ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, /* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,

View File

@ -1,19 +1,46 @@
/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd /*
See the file COPYING for copying permission. __ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2000-2005 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org>
Copyright (c) 2016 Thomas Beutlich <tc@tbeu.de>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2022 Thijs Schreijer <thijs@thijsschreijer.nl>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef Expat_INCLUDED #ifndef Expat_INCLUDED
#define Expat_INCLUDED 1 #define Expat_INCLUDED 1
#ifdef __VMS
/* 0 1 2 3 0 1 2 3
1234567890123456789012345678901 1234567890123456789012345678901 */
#define XML_SetProcessingInstructionHandler XML_SetProcessingInstrHandler
#define XML_SetUnparsedEntityDeclHandler XML_SetUnparsedEntDeclHandler
#define XML_SetStartNamespaceDeclHandler XML_SetStartNamespcDeclHandler
#define XML_SetExternalEntityRefHandlerArg XML_SetExternalEntRefHandlerArg
#endif
#include <stdlib.h> #include <stdlib.h>
#include "expat_external.h" #include "expat_external.h"
@ -24,7 +51,6 @@ extern "C" {
struct XML_ParserStruct; struct XML_ParserStruct;
typedef struct XML_ParserStruct *XML_Parser; typedef struct XML_ParserStruct *XML_Parser;
/* Should this be defined using stdbool.h when C99 is available? */
typedef unsigned char XML_Bool; typedef unsigned char XML_Bool;
#define XML_TRUE ((XML_Bool)1) #define XML_TRUE ((XML_Bool)1)
#define XML_FALSE ((XML_Bool)0) #define XML_FALSE ((XML_Bool)0)
@ -95,7 +121,13 @@ enum XML_Error {
/* Added in 2.0. */ /* Added in 2.0. */
XML_ERROR_RESERVED_PREFIX_XML, XML_ERROR_RESERVED_PREFIX_XML,
XML_ERROR_RESERVED_PREFIX_XMLNS, XML_ERROR_RESERVED_PREFIX_XMLNS,
XML_ERROR_RESERVED_NAMESPACE_URI XML_ERROR_RESERVED_NAMESPACE_URI,
/* Added in 2.2.1. */
XML_ERROR_INVALID_ARGUMENT,
/* Added in 2.3.0. */
XML_ERROR_NO_BUFFER,
/* Added in 2.4.0. */
XML_ERROR_AMPLIFICATION_LIMIT_BREACH
}; };
enum XML_Content_Type { enum XML_Content_Type {
@ -142,18 +174,18 @@ struct XML_cp {
XML_Content *children; XML_Content *children;
}; };
/* This is called for an element declaration. See above for /* This is called for an element declaration. See above for
description of the model argument. It's the caller's responsibility description of the model argument. It's the user code's responsibility
to free model when finished with it. to free model when finished with it. See XML_FreeContentModel.
There is no need to free the model from the handler, it can be kept
around and freed at a later stage.
*/ */
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData, typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData,
const XML_Char *name, const XML_Char *name,
XML_Content *model); XML_Content *model);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetElementDeclHandler(XML_Parser parser, XML_SetElementDeclHandler(XML_Parser parser, XML_ElementDeclHandler eldecl);
XML_ElementDeclHandler eldecl);
/* The Attlist declaration handler is called for *each* attribute. So /* The Attlist declaration handler is called for *each* attribute. So
a single Attlist declaration with multiple attributes declared will a single Attlist declaration with multiple attributes declared will
@ -164,16 +196,11 @@ XML_SetElementDeclHandler(XML_Parser parser,
true and default is non-NULL, then this is a "#FIXED" default. true and default is non-NULL, then this is a "#FIXED" default.
*/ */
typedef void(XMLCALL *XML_AttlistDeclHandler)( typedef void(XMLCALL *XML_AttlistDeclHandler)(
void *userData, void *userData, const XML_Char *elname, const XML_Char *attname,
const XML_Char *elname, const XML_Char *att_type, const XML_Char *dflt, int isrequired);
const XML_Char *attname,
const XML_Char *att_type,
const XML_Char *dflt,
int isrequired);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetAttlistDeclHandler(XML_Parser parser, XML_SetAttlistDeclHandler(XML_Parser parser, XML_AttlistDeclHandler attdecl);
XML_AttlistDeclHandler attdecl);
/* The XML declaration handler is called for *both* XML declarations /* The XML declaration handler is called for *both* XML declarations
and text declarations. The way to distinguish is that the version and text declarations. The way to distinguish is that the version
@ -189,9 +216,7 @@ typedef void (XMLCALL *XML_XmlDeclHandler) (void *userData,
int standalone); int standalone);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetXmlDeclHandler(XML_Parser parser, XML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler xmldecl);
XML_XmlDeclHandler xmldecl);
typedef struct { typedef struct {
void *(*malloc_fcn)(size_t size); void *(*malloc_fcn)(size_t size);
@ -215,11 +240,21 @@ XML_ParserCreate(const XML_Char *encoding);
and the local part will be concatenated without any separator. and the local part will be concatenated without any separator.
It is a programming error to use the separator '\0' with namespace It is a programming error to use the separator '\0' with namespace
triplets (see XML_SetReturnNSTriplet). triplets (see XML_SetReturnNSTriplet).
If a namespace separator is chosen that can be part of a URI or
part of an XML name, splitting an expanded name back into its
1, 2 or 3 original parts on application level in the element handler
may end up vulnerable, so these are advised against; sane choices for
a namespace separator are e.g. '\n' (line feed) and '|' (pipe).
Note that Expat does not validate namespace URIs (beyond encoding)
against RFC 3986 today (and is not required to do so with regard to
the XML 1.0 namespaces specification) but it may start doing that
in future releases. Before that, an application using Expat must
be ready to receive namespace URIs containing non-URI characters.
*/ */
XMLPARSEAPI(XML_Parser) XMLPARSEAPI(XML_Parser)
XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator); XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
/* Constructs a new parser using the memory management suite 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 by memsuite. If memsuite is NULL, then use the standard library memory
suite. If namespaceSeparator is non-NULL it creates a parser with suite. If namespaceSeparator is non-NULL it creates a parser with
@ -235,7 +270,7 @@ XML_ParserCreate_MM(const XML_Char *encoding,
const XML_Char *namespaceSeparator); const XML_Char *namespaceSeparator);
/* Prepare a parser object to be re-used. This is particularly /* Prepare a parser object to be re-used. This is particularly
valuable when memory allocation overhead is disproportionatly high, valuable when memory allocation overhead is disproportionately high,
such as when a large number of small documnents need to be parsed. such as when a large number of small documnents need to be parsed.
All handlers are cleared from the parser, except for the All handlers are cleared from the parser, except for the
unknownEncodingHandler. The parser's external state is re-initialized unknownEncodingHandler. The parser's external state is re-initialized
@ -256,21 +291,17 @@ typedef void (XMLCALL *XML_StartElementHandler) (void *userData,
typedef void(XMLCALL *XML_EndElementHandler)(void *userData, typedef void(XMLCALL *XML_EndElementHandler)(void *userData,
const XML_Char *name); const XML_Char *name);
/* s is not 0 terminated. */ /* s is not 0 terminated. */
typedef void(XMLCALL *XML_CharacterDataHandler)(void *userData, typedef void(XMLCALL *XML_CharacterDataHandler)(void *userData,
const XML_Char *s, const XML_Char *s, int len);
int len);
/* target and data are 0 terminated */ /* target and data are 0 terminated */
typedef void (XMLCALL *XML_ProcessingInstructionHandler) ( typedef void(XMLCALL *XML_ProcessingInstructionHandler)(void *userData,
void *userData,
const XML_Char *target, const XML_Char *target,
const XML_Char *data); const XML_Char *data);
/* data is 0 terminated */ /* data is 0 terminated */
typedef void (XMLCALL *XML_CommentHandler) (void *userData, typedef void(XMLCALL *XML_CommentHandler)(void *userData, const XML_Char *data);
const XML_Char *data);
typedef void(XMLCALL *XML_StartCdataSectionHandler)(void *userData); typedef void(XMLCALL *XML_StartCdataSectionHandler)(void *userData);
typedef void(XMLCALL *XML_EndCdataSectionHandler)(void *userData); typedef void(XMLCALL *XML_EndCdataSectionHandler)(void *userData);
@ -288,21 +319,19 @@ typedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData);
default handler: for example, a comment might be split between default handler: for example, a comment might be split between
multiple calls. multiple calls.
*/ */
typedef void (XMLCALL *XML_DefaultHandler) (void *userData, typedef void(XMLCALL *XML_DefaultHandler)(void *userData, const XML_Char *s,
const XML_Char *s,
int len); int len);
/* This is called for the start of the DOCTYPE declaration, before /* This is called for the start of the DOCTYPE declaration, before
any DTD or internal subset is parsed. any DTD or internal subset is parsed.
*/ */
typedef void (XMLCALL *XML_StartDoctypeDeclHandler) ( typedef void(XMLCALL *XML_StartDoctypeDeclHandler)(void *userData,
void *userData,
const XML_Char *doctypeName, const XML_Char *doctypeName,
const XML_Char *sysid, const XML_Char *sysid,
const XML_Char *pubid, const XML_Char *pubid,
int has_internal_subset); int has_internal_subset);
/* This is called for the start of the DOCTYPE declaration when the /* This is called for the end of the DOCTYPE declaration when the
closing > is encountered, but after processing any external closing > is encountered, but after processing any external
subset. subset.
*/ */
@ -314,7 +343,7 @@ typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
For internal entities (<!ENTITY foo "bar">), value will For internal entities (<!ENTITY foo "bar">), value will
be non-NULL and systemId, publicID, and notationName will be NULL. be non-NULL and systemId, publicID, and notationName will be NULL.
The value string is NOT nul-terminated; the length is provided in The value string is NOT null-terminated; the length is provided in
the value_length argument. Since it is legal to have zero-length the value_length argument. Since it is legal to have zero-length
values, do not use this argument to test for internal entities. values, do not use this argument to test for internal entities.
@ -327,19 +356,13 @@ typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
that would break binary compatibility. that would break binary compatibility.
*/ */
typedef void(XMLCALL *XML_EntityDeclHandler)( typedef void(XMLCALL *XML_EntityDeclHandler)(
void *userData, void *userData, const XML_Char *entityName, int is_parameter_entity,
const XML_Char *entityName, const XML_Char *value, int value_length, const XML_Char *base,
int is_parameter_entity, const XML_Char *systemId, const XML_Char *publicId,
const XML_Char *value,
int value_length,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId,
const XML_Char *notationName); const XML_Char *notationName);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetEntityDeclHandler(XML_Parser parser, XML_SetEntityDeclHandler(XML_Parser parser, XML_EntityDeclHandler handler);
XML_EntityDeclHandler handler);
/* OBSOLETE -- OBSOLETE -- OBSOLETE /* OBSOLETE -- OBSOLETE -- OBSOLETE
This handler has been superseded by the EntityDeclHandler above. This handler has been superseded by the EntityDeclHandler above.
@ -351,19 +374,15 @@ XML_SetEntityDeclHandler(XML_Parser parser,
NULL. The other arguments may be. NULL. The other arguments may be.
*/ */
typedef void(XMLCALL *XML_UnparsedEntityDeclHandler)( typedef void(XMLCALL *XML_UnparsedEntityDeclHandler)(
void *userData, void *userData, const XML_Char *entityName, const XML_Char *base,
const XML_Char *entityName, const XML_Char *systemId, const XML_Char *publicId,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId,
const XML_Char *notationName); const XML_Char *notationName);
/* This is called for a declaration of notation. The base argument is /* This is called for a declaration of notation. The base argument is
whatever was set by XML_SetBase. The notationName will never be whatever was set by XML_SetBase. The notationName will never be
NULL. The other arguments can be. NULL. The other arguments can be.
*/ */
typedef void (XMLCALL *XML_NotationDeclHandler) ( typedef void(XMLCALL *XML_NotationDeclHandler)(void *userData,
void *userData,
const XML_Char *notationName, const XML_Char *notationName,
const XML_Char *base, const XML_Char *base,
const XML_Char *systemId, const XML_Char *systemId,
@ -375,13 +394,11 @@ typedef void (XMLCALL *XML_NotationDeclHandler) (
declaration handlers. For an xmlns attribute, prefix will be declaration handlers. For an xmlns attribute, prefix will be
NULL. For an xmlns="" attribute, uri will be NULL. NULL. For an xmlns="" attribute, uri will be NULL.
*/ */
typedef void (XMLCALL *XML_StartNamespaceDeclHandler) ( typedef void(XMLCALL *XML_StartNamespaceDeclHandler)(void *userData,
void *userData,
const XML_Char *prefix, const XML_Char *prefix,
const XML_Char *uri); const XML_Char *uri);
typedef void (XMLCALL *XML_EndNamespaceDeclHandler) ( typedef void(XMLCALL *XML_EndNamespaceDeclHandler)(void *userData,
void *userData,
const XML_Char *prefix); const XML_Char *prefix);
/* This is called if the document is not standalone, that is, it has an /* This is called if the document is not standalone, that is, it has an
@ -429,8 +446,7 @@ typedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData);
Note that unlike other handlers the first argument is the parser, Note that unlike other handlers the first argument is the parser,
not userData. not userData.
*/ */
typedef int (XMLCALL *XML_ExternalEntityRefHandler) ( typedef int(XMLCALL *XML_ExternalEntityRefHandler)(XML_Parser parser,
XML_Parser parser,
const XML_Char *context, const XML_Char *context,
const XML_Char *base, const XML_Char *base,
const XML_Char *systemId, const XML_Char *systemId,
@ -446,8 +462,7 @@ typedef int (XMLCALL *XML_ExternalEntityRefHandler) (
the event would be out of sync with the reporting of the the event would be out of sync with the reporting of the
declarations or attribute values declarations or attribute values
*/ */
typedef void (XMLCALL *XML_SkippedEntityHandler) ( typedef void(XMLCALL *XML_SkippedEntityHandler)(void *userData,
void *userData,
const XML_Char *entityName, const XML_Char *entityName,
int is_parameter_entity); int is_parameter_entity);
@ -523,25 +538,21 @@ typedef struct {
Otherwise it must return XML_STATUS_ERROR. Otherwise it must return XML_STATUS_ERROR.
If info does not describe a suitable encoding, then the parser will If info does not describe a suitable encoding, then the parser will
return an XML_UNKNOWN_ENCODING error. return an XML_ERROR_UNKNOWN_ENCODING error.
*/ */
typedef int (XMLCALL *XML_UnknownEncodingHandler) ( typedef int(XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData,
void *encodingHandlerData,
const XML_Char *name, const XML_Char *name,
XML_Encoding *info); XML_Encoding *info);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetElementHandler(XML_Parser parser, XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start,
XML_StartElementHandler start,
XML_EndElementHandler end); XML_EndElementHandler end);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetStartElementHandler(XML_Parser parser, XML_SetStartElementHandler(XML_Parser parser, XML_StartElementHandler handler);
XML_StartElementHandler handler);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetEndElementHandler(XML_Parser parser, XML_SetEndElementHandler(XML_Parser parser, XML_EndElementHandler handler);
XML_EndElementHandler handler);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetCharacterDataHandler(XML_Parser parser, XML_SetCharacterDataHandler(XML_Parser parser,
@ -551,8 +562,7 @@ XMLPARSEAPI(void)
XML_SetProcessingInstructionHandler(XML_Parser parser, XML_SetProcessingInstructionHandler(XML_Parser parser,
XML_ProcessingInstructionHandler handler); XML_ProcessingInstructionHandler handler);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetCommentHandler(XML_Parser parser, XML_SetCommentHandler(XML_Parser parser, XML_CommentHandler handler);
XML_CommentHandler handler);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetCdataSectionHandler(XML_Parser parser, XML_SetCdataSectionHandler(XML_Parser parser,
@ -572,20 +582,17 @@ XML_SetEndCdataSectionHandler(XML_Parser parser,
default handler, or to the skipped entity handler, if one is set. default handler, or to the skipped entity handler, if one is set.
*/ */
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetDefaultHandler(XML_Parser parser, XML_SetDefaultHandler(XML_Parser parser, XML_DefaultHandler handler);
XML_DefaultHandler handler);
/* This sets the default handler but does not inhibit expansion of /* This sets the default handler but does not inhibit expansion of
internal entities. The entity reference will not be passed to the internal entities. The entity reference will not be passed to the
default handler. default handler.
*/ */
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetDefaultHandlerExpand(XML_Parser parser, XML_SetDefaultHandlerExpand(XML_Parser parser, XML_DefaultHandler handler);
XML_DefaultHandler handler);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetDoctypeDeclHandler(XML_Parser parser, XML_SetDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start,
XML_StartDoctypeDeclHandler start,
XML_EndDoctypeDeclHandler end); XML_EndDoctypeDeclHandler end);
XMLPARSEAPI(void) XMLPARSEAPI(void)
@ -593,16 +600,14 @@ XML_SetStartDoctypeDeclHandler(XML_Parser parser,
XML_StartDoctypeDeclHandler start); XML_StartDoctypeDeclHandler start);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetEndDoctypeDeclHandler(XML_Parser parser, XML_SetEndDoctypeDeclHandler(XML_Parser parser, XML_EndDoctypeDeclHandler end);
XML_EndDoctypeDeclHandler end);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetUnparsedEntityDeclHandler(XML_Parser parser, XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
XML_UnparsedEntityDeclHandler handler); XML_UnparsedEntityDeclHandler handler);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetNotationDeclHandler(XML_Parser parser, XML_SetNotationDeclHandler(XML_Parser parser, XML_NotationDeclHandler handler);
XML_NotationDeclHandler handler);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetNamespaceDeclHandler(XML_Parser parser, XML_SetNamespaceDeclHandler(XML_Parser parser,
@ -630,8 +635,7 @@ XML_SetExternalEntityRefHandler(XML_Parser parser,
instead of the parser object. instead of the parser object.
*/ */
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetExternalEntityRefHandlerArg(XML_Parser parser, XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg);
void *arg);
XMLPARSEAPI(void) XMLPARSEAPI(void)
XML_SetSkippedEntityHandler(XML_Parser parser, XML_SetSkippedEntityHandler(XML_Parser parser,
@ -706,11 +710,11 @@ XML_UseParserAsHandlerArg(XML_Parser parser);
be called, despite an external subset being parsed. be called, despite an external subset being parsed.
Note: If XML_DTD is not defined when Expat is compiled, returns Note: If XML_DTD is not defined when Expat is compiled, returns
XML_ERROR_FEATURE_REQUIRES_XML_DTD. XML_ERROR_FEATURE_REQUIRES_XML_DTD.
Note: If parser == NULL, returns XML_ERROR_INVALID_ARGUMENT.
*/ */
XMLPARSEAPI(enum XML_Error) XMLPARSEAPI(enum XML_Error)
XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD); XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
/* Sets the base to be used for resolving relative URIs in system /* Sets the base to be used for resolving relative URIs in system
identifiers in declarations. Resolving relative identifiers is identifiers in declarations. Resolving relative identifiers is
left to the application: this value will be passed through as the left to the application: this value will be passed through as the
@ -728,16 +732,17 @@ XML_GetBase(XML_Parser parser);
/* Returns the number of the attribute/value pairs passed in last call /* Returns the number of the attribute/value pairs passed in last call
to the XML_StartElementHandler that were specified in the start-tag to the XML_StartElementHandler that were specified in the start-tag
rather than defaulted. Each attribute/value pair counts as 2; thus rather than defaulted. Each attribute/value pair counts as 2; thus
this correspondds to an index into the atts array passed to the this corresponds to an index into the atts array passed to the
XML_StartElementHandler. XML_StartElementHandler. Returns -1 if parser == NULL.
*/ */
XMLPARSEAPI(int) XMLPARSEAPI(int)
XML_GetSpecifiedAttributeCount(XML_Parser parser); XML_GetSpecifiedAttributeCount(XML_Parser parser);
/* Returns the index of the ID attribute passed in the last call to /* Returns the index of the ID attribute passed in the last call to
XML_StartElementHandler, or -1 if there is no ID attribute. Each XML_StartElementHandler, or -1 if there is no ID attribute or
attribute/value pair counts as 2; thus this correspondds to an parser == NULL. Each attribute/value pair counts as 2; thus this
index into the atts array passed to the XML_StartElementHandler. corresponds to an index into the atts array passed to the
XML_StartElementHandler.
*/ */
XMLPARSEAPI(int) XMLPARSEAPI(int)
XML_GetIdAttributeIndex(XML_Parser parser); XML_GetIdAttributeIndex(XML_Parser parser);
@ -832,12 +837,7 @@ XML_StopParser(XML_Parser parser, XML_Bool resumable);
XMLPARSEAPI(enum XML_Status) XMLPARSEAPI(enum XML_Status)
XML_ResumeParser(XML_Parser parser); XML_ResumeParser(XML_Parser parser);
enum XML_Parsing { enum XML_Parsing { XML_INITIALIZED, XML_PARSING, XML_FINISHED, XML_SUSPENDED };
XML_INITIALIZED,
XML_PARSING,
XML_FINISHED,
XML_SUSPENDED
};
typedef struct { typedef struct {
enum XML_Parsing parsing; enum XML_Parsing parsing;
@ -869,8 +869,7 @@ XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status);
Otherwise returns a new XML_Parser object. Otherwise returns a new XML_Parser object.
*/ */
XMLPARSEAPI(XML_Parser) XMLPARSEAPI(XML_Parser)
XML_ExternalEntityParserCreate(XML_Parser parser, XML_ExternalEntityParserCreate(XML_Parser parser, const XML_Char *context,
const XML_Char *context,
const XML_Char *encoding); const XML_Char *encoding);
enum XML_ParamEntityParsing { enum XML_ParamEntityParsing {
@ -901,6 +900,7 @@ enum XML_ParamEntityParsing {
entities is requested; otherwise it will return non-zero. entities is requested; otherwise it will return non-zero.
Note: If XML_SetParamEntityParsing is called after XML_Parse or Note: If XML_SetParamEntityParsing is called after XML_Parse or
XML_ParseBuffer, then it has no effect and will always return 0. XML_ParseBuffer, then it has no effect and will always return 0.
Note: If parser == NULL, the function will do nothing and return 0.
*/ */
XMLPARSEAPI(int) XMLPARSEAPI(int)
XML_SetParamEntityParsing(XML_Parser parser, XML_SetParamEntityParsing(XML_Parser parser,
@ -910,10 +910,10 @@ XML_SetParamEntityParsing(XML_Parser parser,
Helps in preventing DoS attacks based on predicting hash Helps in preventing DoS attacks based on predicting hash
function behavior. This must be called before parsing is started. function behavior. This must be called before parsing is started.
Returns 1 if successful, 0 when called after parsing has started. Returns 1 if successful, 0 when called after parsing has started.
Note: If parser == NULL, the function will do nothing and return 0.
*/ */
XMLPARSEAPI(int) XMLPARSEAPI(int)
XML_SetHashSalt(XML_Parser parser, XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt);
unsigned long hash_salt);
/* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then /* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
XML_GetErrorCode returns information about the error. XML_GetErrorCode returns information about the error.
@ -936,6 +936,10 @@ XML_GetErrorCode(XML_Parser parser);
the location is the location of the character at which the error the location is the location of the character at which the error
was detected; otherwise the location is the location of the last was detected; otherwise the location is the location of the last
parse event, as described above. parse event, as described above.
Note: XML_GetCurrentLineNumber and XML_GetCurrentColumnNumber
return 0 to indicate an error.
Note: XML_GetCurrentByteIndex returns -1 to indicate an error.
*/ */
XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser); XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser);
XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser); XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser);
@ -958,9 +962,7 @@ XML_GetCurrentByteCount(XML_Parser parser);
the handler that makes the call. the handler that makes the call.
*/ */
XMLPARSEAPI(const char *) XMLPARSEAPI(const char *)
XML_GetInputContext(XML_Parser parser, XML_GetInputContext(XML_Parser parser, int *offset, int *size);
int *offset,
int *size);
/* For backwards compatibility with previous versions. */ /* For backwards compatibility with previous versions. */
#define XML_GetErrorLineNumber XML_GetCurrentLineNumber #define XML_GetErrorLineNumber XML_GetCurrentLineNumber
@ -1020,7 +1022,10 @@ enum XML_FeatureEnum {
XML_FEATURE_SIZEOF_XML_LCHAR, XML_FEATURE_SIZEOF_XML_LCHAR,
XML_FEATURE_NS, XML_FEATURE_NS,
XML_FEATURE_LARGE_SIZE, XML_FEATURE_LARGE_SIZE,
XML_FEATURE_ATTR_INFO XML_FEATURE_ATTR_INFO,
/* Added in Expat 2.4.0. */
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT,
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT
/* Additional features must be added to the end of this enum. */ /* Additional features must be added to the end of this enum. */
}; };
@ -1033,12 +1038,23 @@ typedef struct {
XMLPARSEAPI(const XML_Feature *) XMLPARSEAPI(const XML_Feature *)
XML_GetFeatureList(void); XML_GetFeatureList(void);
#ifdef XML_DTD
/* Added in Expat 2.4.0. */
XMLPARSEAPI(XML_Bool)
XML_SetBillionLaughsAttackProtectionMaximumAmplification(
XML_Parser parser, float maximumAmplificationFactor);
/* Added in Expat 2.4.0. */
XMLPARSEAPI(XML_Bool)
XML_SetBillionLaughsAttackProtectionActivationThreshold(
XML_Parser parser, unsigned long long activationThresholdBytes);
#endif
/* Expat follows the semantic versioning convention. /* Expat follows the semantic versioning convention.
See http://semver.org. See http://semver.org.
*/ */
#define XML_MAJOR_VERSION 2 #define XML_MAJOR_VERSION 2
#define XML_MINOR_VERSION 2 #define XML_MINOR_VERSION 5
#define XML_MICRO_VERSION 0 #define XML_MICRO_VERSION 0
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,28 +1,40 @@
/*================================================================ /*
** 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.) |_| XML parser
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2005 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2017-2021 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef EXPATCONFIG_H #ifndef EXPATCONFIG_H
#define EXPATCONFIG_H #define EXPATCONFIG_H
#include <memory.h>
#include <string.h>
#define XML_NS 1
#define XML_DTD 1
#define XML_CONTEXT_BYTES 1024
/* we will assume all Windows platforms are little endian */
#define BYTEORDER 1234
/* Windows has memmove() available. */
#define HAVE_MEMMOVE
#ifdef WIN32 #ifdef WIN32
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
@ -30,4 +42,8 @@
#else #else
#endif #endif
#endif /* ifndef EXPATCONFIG_H */ #include "expat_configure.h"
#include <memory.h>
#include <string.h>
#endif /* ndef EXPATCONFIG_H */

120
deps/EXPAT/expat/expat_configure.h.cmake vendored Normal file
View File

@ -0,0 +1,120 @@
/* expat_config.h.cmake. Based upon generated expat_config.h.in. */
#ifndef EXPAT_CONFIG_H
#define EXPAT_CONFIG_H 1
/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
#cmakedefine BYTEORDER @BYTEORDER@
/* Define to 1 if you have the `arc4random' function. */
#cmakedefine HAVE_ARC4RANDOM
/* Define to 1 if you have the `arc4random_buf' function. */
#cmakedefine HAVE_ARC4RANDOM_BUF
/* Define to 1 if you have the <dlfcn.h> header file. */
#cmakedefine HAVE_DLFCN_H
/* Define to 1 if you have the <fcntl.h> header file. */
#cmakedefine HAVE_FCNTL_H
/* Define to 1 if you have the `getpagesize' function. */
#cmakedefine HAVE_GETPAGESIZE
/* Define to 1 if you have the `getrandom' function. */
#cmakedefine HAVE_GETRANDOM
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H
/* Define to 1 if you have the `bsd' library (-lbsd). */
#cmakedefine HAVE_LIBBSD
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H
/* Define to 1 if you have a working `mmap' system call. */
#cmakedefine HAVE_MMAP
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#cmakedefine HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H
/* Define to 1 if you have `syscall' and `SYS_getrandom'. */
#cmakedefine HAVE_SYSCALL_GETRANDOM
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#cmakedefine HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H
/* Name of package */
#define PACKAGE "@PACKAGE_NAME@"
/* Define to the address where bug reports for this package should be sent. */
#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
/* Define to the full name of this package. */
#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@"
/* Define to the full name and version of this package. */
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"
/* Define to the one symbol short name of this package. */
#cmakedefine PACKAGE_TARNAME "@PACKAGE_TARNAME@"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"
/* Define to 1 if you have the ANSI C header files. */
#cmakedefine STDC_HEADERS
/* whether byteorder is bigendian */
#cmakedefine WORDS_BIGENDIAN
/* Define to allow retrieving the byte offsets for attribute names and values.
*/
#cmakedefine XML_ATTR_INFO
/* Define to specify how much context to retain around the current parse
point. */
#cmakedefine XML_CONTEXT_BYTES @XML_CONTEXT_BYTES@
#if ! defined(_WIN32)
/* Define to include code reading entropy from `/dev/urandom'. */
#cmakedefine XML_DEV_URANDOM
#endif
/* Define to make parameter entity parsing functionality available. */
#cmakedefine XML_DTD
/* Define to make XML Namespaces functionality available. */
#cmakedefine XML_NS
/* Define to __FUNCTION__ or "" if `__func__' does not conform to ANSI C. */
#ifdef _MSC_VER
# define __func__ __FUNCTION__
#endif
/* Define to `long' if <sys/types.h> does not define. */
#cmakedefine off_t @OFF_T@
/* Define to `unsigned' if <sys/types.h> does not define. */
#cmakedefine size_t @SIZE_T@
#endif // ndef EXPAT_CONFIG_H

View File

@ -1,5 +1,40 @@
/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd /*
See the file COPYING for copying permission. __ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2000-2004 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org>
Copyright (c) 2016-2019 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef Expat_External_INCLUDED #ifndef Expat_External_INCLUDED
@ -7,10 +42,6 @@
/* External API definitions */ /* External API definitions */
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
#define XML_USE_MSC_EXTENSIONS 1
#endif
/* Expat tries very hard to make the API boundary very specifically /* Expat tries very hard to make the API boundary very specifically
defined. There are two macros defined to control this boundary; defined. There are two macros defined to control this boundary;
each of these can be defined before including this header to each of these can be defined before including this header to
@ -53,19 +84,22 @@
# endif # endif
#endif /* not defined XMLCALL */ #endif /* not defined XMLCALL */
#if ! defined(XML_STATIC) && ! defined(XMLIMPORT) #if ! defined(XML_STATIC) && ! defined(XMLIMPORT)
# ifndef XML_BUILDING_EXPAT # ifndef XML_BUILDING_EXPAT
/* using Expat from an application */ /* using Expat from an application */
#ifdef XML_USE_MSC_EXTENSIONS # if defined(_MSC_EXTENSIONS) && ! defined(__BEOS__) && ! defined(__CYGWIN__)
//# define XMLIMPORT __declspec(dllimport) //# define XMLIMPORT __declspec(dllimport)
# endif # endif
# endif # endif
#endif /* not defined XML_STATIC */ #endif /* not defined XML_STATIC */
#if !defined(XMLIMPORT) && defined(__GNUC__) && (__GNUC__ >= 4) #ifndef XML_ENABLE_VISIBILITY
# define XML_ENABLE_VISIBILITY 0
#endif
#if ! defined(XMLIMPORT) && XML_ENABLE_VISIBILITY
# define XMLIMPORT __attribute__((visibility("default"))) # define XMLIMPORT __attribute__((visibility("default")))
#endif #endif
@ -74,13 +108,15 @@
# define XMLIMPORT # define XMLIMPORT
#endif #endif
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)) #if defined(__GNUC__) \
&& (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
# define XML_ATTR_MALLOC __attribute__((__malloc__)) # define XML_ATTR_MALLOC __attribute__((__malloc__))
#else #else
# define XML_ATTR_MALLOC # define XML_ATTR_MALLOC
#endif #endif
#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #if defined(__GNUC__) \
&& ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
# define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x))) # define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
#else #else
# define XML_ATTR_ALLOC_SIZE(x) # define XML_ATTR_ALLOC_SIZE(x)
@ -93,8 +129,13 @@ extern "C" {
#endif #endif
#ifdef XML_UNICODE_WCHAR_T #ifdef XML_UNICODE_WCHAR_T
# ifndef XML_UNICODE
# define XML_UNICODE # define XML_UNICODE
# endif # endif
# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
# endif
#endif
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */ #ifdef XML_UNICODE /* Information is UTF-16 encoded. */
# ifdef XML_UNICODE_WCHAR_T # ifdef XML_UNICODE_WCHAR_T
@ -110,13 +151,8 @@ typedef char XML_LChar;
#endif /* XML_UNICODE */ #endif /* XML_UNICODE */
#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */ #ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
typedef __int64 XML_Index;
typedef unsigned __int64 XML_Size;
#else
typedef long long XML_Index; typedef long long XML_Index;
typedef unsigned long long XML_Size; typedef unsigned long long XML_Size;
#endif
#else #else
typedef long XML_Index; typedef long XML_Index;
typedef unsigned long XML_Size; typedef unsigned long XML_Size;

View File

@ -1,5 +1,35 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd /*
See the file COPYING for copying permission. __ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */ /* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */

View File

@ -18,6 +18,39 @@
Note: Use of these macros is based on judgement, not hard rules, Note: Use of these macros is based on judgement, not hard rules,
and therefore subject to change. and therefore subject to change.
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2003 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#if defined(__GNUC__) && defined(__i386__) && ! defined(__MINGW32__) #if defined(__GNUC__) && defined(__i386__) && ! defined(__MINGW32__)
@ -72,23 +105,60 @@
# endif # endif
#endif #endif
#ifndef UNUSED_P #include <limits.h> // ULONG_MAX
# ifdef __GNUC__
# define UNUSED_P(p) UNUSED_ ## p __attribute__((__unused__)) #if defined(_WIN32) \
&& (! defined(__USE_MINGW_ANSI_STDIO) \
|| (1 - __USE_MINGW_ANSI_STDIO - 1 == 0))
# define EXPAT_FMT_ULL(midpart) "%" midpart "I64u"
# if defined(_WIN64) // Note: modifiers "td" and "zu" do not work for MinGW
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "I64d"
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "I64u"
# else # else
# define UNUSED_P(p) UNUSED_ ## p # define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
# endif
#else
# define EXPAT_FMT_ULL(midpart) "%" midpart "llu"
# if ! defined(ULONG_MAX)
# error Compiler did not define ULONG_MAX for us
# elif ULONG_MAX == 18446744073709551615u // 2^64-1
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu"
# else
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
# endif # endif
#endif #endif
#ifndef UNUSED_P
# define UNUSED_P(p) (void)p
#endif
/* NOTE BEGIN If you ever patch these defaults to greater values
for non-attack XML payload in your environment,
please file a bug report with libexpat. Thank you!
*/
#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT \
100.0f
#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT \
8388608 // 8 MiB, 2^23
/* NOTE END */
#include "expat.h" // so we can use type XML_Parser below
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void _INTERNAL_trim_to_complete_utf8_characters(const char *from,
const char **fromLimRef);
void #if defined(XML_DTD)
align_limit_to_full_utf8_characters(const char * from, const char ** fromLimRef); unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser);
unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser);
const char *unsignedCharToPrintable(unsigned char c);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,5 +1,35 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd /*
See the file COPYING for copying permission. __ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, /* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,

View File

@ -1,150 +1,136 @@
/*
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
static const unsigned namingBitmap[] = { static const unsigned namingBitmap[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x04000000,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x87FFFFFE, 0x07FFFFFE, 0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE, 0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF, 0xFFFFE00F, 0xFC31FFFF, 0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF, 0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF, 0x00000000, 0x00000000, 0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, 0xFFFF0003, 0xFFFFFFFF,
0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000, 0xFFFF199F, 0x033FCFFF, 0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF, 0x00000000, 0x07FFFFFE,
0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD, 0x000007FE, 0xFFFE0000, 0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, 0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003, 0xFFF99FE0, 0x03C5FDFF,
0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, 0xB0000000, 0x00030003, 0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE, 0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001, 0xFFF99FE0, 0x23CDFDFF,
0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF, 0xB0000000, 0x00000003, 0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000, 0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003, 0xFFFDDFE0, 0x03EFFDFF,
0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060, 0x40000000, 0x00000003, 0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFE, 0x000D7FFF,
0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003, 0x0000003F, 0x00000000, 0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000, 0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF, 0x00000000, 0x00000000,
0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003, 0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF, 0x0007DAED, 0x50000000,
0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000, 0x82315001, 0x002C62AB, 0x40000000, 0xF580C900, 0x00000007, 0x02010800,
0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0FFFFFFF, 0xFFFFFFFF,
0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003, 0xFFFFFFFF, 0x03FFFFFF, 0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003, 0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF, 0x00000000, 0x00004C40,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000007, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000, 0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF, 0x001FFFFF, 0xFFFFFFFE,
0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000, 0xFFFFFFFF, 0x07FFFFFF, 0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000000F,
0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF, 0x00000000, 0x00000000, 0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB, 0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF, 0x00FFFFFF, 0x00000000,
0x40000000, 0xF580C900, 0x00000007, 0x02010800, 0xFFFF0000, 0xFFFFFFFF, 0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003, 0xFFFFD7C0, 0xFFFFFFFB,
0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF, 0x547F7FFF, 0x000FFFFD, 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF, 0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, 0x00000000, 0xFFFE0000,
0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF, 0x027FFFFF, 0xFFFFFFFE, 0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
0x00000000, 0x00004C40, 0x00000000, 0x00000000, 0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF, 0xFFFFFFFF, 0x7CFFFFFF,
0x00000007, 0x00000000, 0x00000000, 0x00000000, 0xFFEF7FFF, 0x03FF3DFF, 0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF, 0xFFF987E4, 0xD36DFDFF,
0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF, 0x5E003987, 0x001FFFC0, 0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000, 0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3, 0xD63DC7EC, 0xC3BFC718,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00803DC7, 0x0000FF80, 0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3, 0xFFFDDFEC, 0xC3FFFDFF,
0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000, 0x00803DCF, 0x0000FFC3, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000, 0xFEF02596, 0x3BFF6CAE,
0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000, 0x03FF3F5F, 0x00000000, 0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE, 0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF, 0x661FFFFF, 0xFFFFFFFE,
0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000, 0xFFFFFFFF, 0x77FFFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000,
0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF,
}; };
static const unsigned char nmstrtPages[] = { static const unsigned char nmstrtPages[] = {
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x09, 0x0A, 0x0B,
0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x00, 0x14, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}; };
static const unsigned char namePages[] = { static const unsigned char namePages[] = {
0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00, 0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00, 0x00, 0x1F, 0x20, 0x21,
0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x22, 0x23, 0x24, 0x25, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x26, 0x14, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}; };

393
deps/EXPAT/expat/siphash.h vendored Normal file
View File

@ -0,0 +1,393 @@
/* ==========================================================================
* siphash.h - SipHash-2-4 in a single header file
* --------------------------------------------------------------------------
* Derived by William Ahern from the reference implementation[1] published[2]
* by Jean-Philippe Aumasson and Daniel J. Berstein.
* Minimal changes by Sebastian Pipping and Victor Stinner on top, see below.
* Licensed under the CC0 Public Domain Dedication license.
*
* 1. https://www.131002.net/siphash/siphash24.c
* 2. https://www.131002.net/siphash/
* --------------------------------------------------------------------------
* HISTORY:
*
* 2020-10-03 (Sebastian Pipping)
* - Drop support for Visual Studio 9.0/2008 and earlier
*
* 2019-08-03 (Sebastian Pipping)
* - Mark part of sip24_valid as to be excluded from clang-format
* - Re-format code using clang-format 9
*
* 2018-07-08 (Anton Maklakov)
* - Add "fall through" markers for GCC's -Wimplicit-fallthrough
*
* 2017-11-03 (Sebastian Pipping)
* - Hide sip_tobin and sip_binof unless SIPHASH_TOBIN macro is defined
*
* 2017-07-25 (Vadim Zeitlin)
* - Fix use of SIPHASH_MAIN macro
*
* 2017-07-05 (Sebastian Pipping)
* - Use _SIP_ULL macro to not require a C++11 compiler if compiled as C++
* - Add const qualifiers at two places
* - Ensure <=80 characters line length (assuming tab width 4)
*
* 2017-06-23 (Victor Stinner)
* - Address Win64 compile warnings
*
* 2017-06-18 (Sebastian Pipping)
* - Clarify license note in the header
* - Address C89 issues:
* - Stop using inline keyword (and let compiler decide)
* - Replace _Bool by int
* - Turn macro siphash24 into a function
* - Address invalid conversion (void pointer) by explicit cast
* - Address lack of stdint.h for Visual Studio 2003 to 2008
* - Always expose sip24_valid (for self-tests)
*
* 2012-11-04 - Born. (William Ahern)
* --------------------------------------------------------------------------
* USAGE:
*
* SipHash-2-4 takes as input two 64-bit words as the key, some number of
* message bytes, and outputs a 64-bit word as the message digest. This
* implementation employs two data structures: a struct sipkey for
* representing the key, and a struct siphash for representing the hash
* state.
*
* For converting a 16-byte unsigned char array to a key, use either the
* macro sip_keyof or the routine sip_tokey. The former instantiates a
* compound literal key, while the latter requires a key object as a
* parameter.
*
* unsigned char secret[16];
* arc4random_buf(secret, sizeof secret);
* struct sipkey *key = sip_keyof(secret);
*
* For hashing a message, use either the convenience macro siphash24 or the
* routines sip24_init, sip24_update, and sip24_final.
*
* struct siphash state;
* void *msg;
* size_t len;
* uint64_t hash;
*
* sip24_init(&state, key);
* sip24_update(&state, msg, len);
* hash = sip24_final(&state);
*
* or
*
* hash = siphash24(msg, len, key);
*
* To convert the 64-bit hash value to a canonical 8-byte little-endian
* binary representation, use either the macro sip_binof or the routine
* sip_tobin. The former instantiates and returns a compound literal array,
* while the latter requires an array object as a parameter.
* --------------------------------------------------------------------------
* NOTES:
*
* o Neither sip_keyof, sip_binof, nor siphash24 will work with compilers
* lacking compound literal support. Instead, you must use the lower-level
* interfaces which take as parameters the temporary state objects.
*
* o Uppercase macros may evaluate parameters more than once. Lowercase
* macros should not exhibit any such side effects.
* ==========================================================================
*/
#ifndef SIPHASH_H
#define SIPHASH_H
#include <stddef.h> /* size_t */
#include <stdint.h> /* uint64_t uint32_t uint8_t */
/*
* Workaround to not require a C++11 compiler for using ULL suffix
* if this code is included and compiled as C++; related GCC warning is:
* warning: use of C++11 long long integer constant [-Wlong-long]
*/
#define _SIP_ULL(high, low) ((((uint64_t)high) << 32) | (low))
#define SIP_ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
#define SIP_U32TO8_LE(p, v) \
(p)[0] = (uint8_t)((v) >> 0); \
(p)[1] = (uint8_t)((v) >> 8); \
(p)[2] = (uint8_t)((v) >> 16); \
(p)[3] = (uint8_t)((v) >> 24);
#define SIP_U64TO8_LE(p, v) \
SIP_U32TO8_LE((p) + 0, (uint32_t)((v) >> 0)); \
SIP_U32TO8_LE((p) + 4, (uint32_t)((v) >> 32));
#define SIP_U8TO64_LE(p) \
(((uint64_t)((p)[0]) << 0) | ((uint64_t)((p)[1]) << 8) \
| ((uint64_t)((p)[2]) << 16) | ((uint64_t)((p)[3]) << 24) \
| ((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) \
| ((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56))
#define SIPHASH_INITIALIZER \
{ 0, 0, 0, 0, {0}, 0, 0 }
struct siphash {
uint64_t v0, v1, v2, v3;
unsigned char buf[8], *p;
uint64_t c;
}; /* struct siphash */
#define SIP_KEYLEN 16
struct sipkey {
uint64_t k[2];
}; /* struct sipkey */
#define sip_keyof(k) sip_tokey(&(struct sipkey){{0}}, (k))
static struct sipkey *
sip_tokey(struct sipkey *key, const void *src) {
key->k[0] = SIP_U8TO64_LE((const unsigned char *)src);
key->k[1] = SIP_U8TO64_LE((const unsigned char *)src + 8);
return key;
} /* sip_tokey() */
#ifdef SIPHASH_TOBIN
# define sip_binof(v) sip_tobin((unsigned char[8]){0}, (v))
static void *
sip_tobin(void *dst, uint64_t u64) {
SIP_U64TO8_LE((unsigned char *)dst, u64);
return dst;
} /* sip_tobin() */
#endif /* SIPHASH_TOBIN */
static void
sip_round(struct siphash *H, const int rounds) {
int i;
for (i = 0; i < rounds; i++) {
H->v0 += H->v1;
H->v1 = SIP_ROTL(H->v1, 13);
H->v1 ^= H->v0;
H->v0 = SIP_ROTL(H->v0, 32);
H->v2 += H->v3;
H->v3 = SIP_ROTL(H->v3, 16);
H->v3 ^= H->v2;
H->v0 += H->v3;
H->v3 = SIP_ROTL(H->v3, 21);
H->v3 ^= H->v0;
H->v2 += H->v1;
H->v1 = SIP_ROTL(H->v1, 17);
H->v1 ^= H->v2;
H->v2 = SIP_ROTL(H->v2, 32);
}
} /* sip_round() */
static struct siphash *
sip24_init(struct siphash *H, const struct sipkey *key) {
H->v0 = _SIP_ULL(0x736f6d65U, 0x70736575U) ^ key->k[0];
H->v1 = _SIP_ULL(0x646f7261U, 0x6e646f6dU) ^ key->k[1];
H->v2 = _SIP_ULL(0x6c796765U, 0x6e657261U) ^ key->k[0];
H->v3 = _SIP_ULL(0x74656462U, 0x79746573U) ^ key->k[1];
H->p = H->buf;
H->c = 0;
return H;
} /* sip24_init() */
#define sip_endof(a) (&(a)[sizeof(a) / sizeof *(a)])
static struct siphash *
sip24_update(struct siphash *H, const void *src, size_t len) {
const unsigned char *p = (const unsigned char *)src, *pe = p + len;
uint64_t m;
do {
while (p < pe && H->p < sip_endof(H->buf))
*H->p++ = *p++;
if (H->p < sip_endof(H->buf))
break;
m = SIP_U8TO64_LE(H->buf);
H->v3 ^= m;
sip_round(H, 2);
H->v0 ^= m;
H->p = H->buf;
H->c += 8;
} while (p < pe);
return H;
} /* sip24_update() */
static uint64_t
sip24_final(struct siphash *H) {
const char left = (char)(H->p - H->buf);
uint64_t b = (H->c + left) << 56;
switch (left) {
case 7:
b |= (uint64_t)H->buf[6] << 48;
/* fall through */
case 6:
b |= (uint64_t)H->buf[5] << 40;
/* fall through */
case 5:
b |= (uint64_t)H->buf[4] << 32;
/* fall through */
case 4:
b |= (uint64_t)H->buf[3] << 24;
/* fall through */
case 3:
b |= (uint64_t)H->buf[2] << 16;
/* fall through */
case 2:
b |= (uint64_t)H->buf[1] << 8;
/* fall through */
case 1:
b |= (uint64_t)H->buf[0] << 0;
/* fall through */
case 0:
break;
}
H->v3 ^= b;
sip_round(H, 2);
H->v0 ^= b;
H->v2 ^= 0xff;
sip_round(H, 4);
return H->v0 ^ H->v1 ^ H->v2 ^ H->v3;
} /* sip24_final() */
static uint64_t
siphash24(const void *src, size_t len, const struct sipkey *key) {
struct siphash state = SIPHASH_INITIALIZER;
return sip24_final(sip24_update(sip24_init(&state, key), src, len));
} /* siphash24() */
/*
* SipHash-2-4 output with
* k = 00 01 02 ...
* and
* in = (empty string)
* in = 00 (1 byte)
* in = 00 01 (2 bytes)
* in = 00 01 02 (3 bytes)
* ...
* in = 00 01 02 ... 3e (63 bytes)
*/
static int
sip24_valid(void) {
/* clang-format off */
static const unsigned char vectors[64][8] = {
{ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, },
{ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, },
{ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, },
{ 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85, },
{ 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf, },
{ 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18, },
{ 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb, },
{ 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab, },
{ 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93, },
{ 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e, },
{ 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a, },
{ 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4, },
{ 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75, },
{ 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14, },
{ 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7, },
{ 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1, },
{ 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f, },
{ 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69, },
{ 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b, },
{ 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb, },
{ 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe, },
{ 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0, },
{ 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93, },
{ 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8, },
{ 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8, },
{ 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc, },
{ 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17, },
{ 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f, },
{ 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde, },
{ 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6, },
{ 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad, },
{ 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32, },
{ 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71, },
{ 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7, },
{ 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12, },
{ 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15, },
{ 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31, },
{ 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02, },
{ 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca, },
{ 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a, },
{ 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e, },
{ 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad, },
{ 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18, },
{ 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4, },
{ 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9, },
{ 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9, },
{ 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb, },
{ 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0, },
{ 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6, },
{ 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7, },
{ 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee, },
{ 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1, },
{ 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a, },
{ 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81, },
{ 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f, },
{ 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24, },
{ 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7, },
{ 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea, },
{ 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60, },
{ 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66, },
{ 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c, },
{ 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f, },
{ 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5, },
{ 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, }
};
/* clang-format on */
unsigned char in[64];
struct sipkey k;
size_t i;
sip_tokey(&k, "\000\001\002\003\004\005\006\007\010\011"
"\012\013\014\015\016\017");
for (i = 0; i < sizeof in; ++i) {
in[i] = (unsigned char)i;
if (siphash24(in, i, &k) != SIP_U8TO64_LE(vectors[i]))
return 0;
}
return 1;
} /* sip24_valid() */
#ifdef SIPHASH_MAIN
# include <stdio.h>
int
main(void) {
const int ok = sip24_valid();
if (ok)
puts("OK");
else
puts("FAIL");
return ! ok;
} /* main() */
#endif /* SIPHASH_MAIN */
#endif /* SIPHASH_H */

View File

@ -1,7 +1,36 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd /*
See the file COPYING for copying permission. __ __ _
*/ ___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, /* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, /* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,36 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd /*
See the file COPYING for copying permission. __ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef XmlRole_INCLUDED #ifndef XmlRole_INCLUDED
@ -85,11 +116,8 @@ enum {
}; };
typedef struct prolog_state { typedef struct prolog_state {
int (PTRCALL *handler) (struct prolog_state *state, int(PTRCALL *handler)(struct prolog_state *state, int tok, const char *ptr,
int tok, const char *end, const ENCODING *enc);
const char *ptr,
const char *end,
const ENCODING *enc);
unsigned level; unsigned level;
int role_none; int role_none;
#ifdef XML_DTD #ifdef XML_DTD

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,37 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd /*
See the file COPYING for copying permission. __ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002-2005 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2017 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef XmlTok_INCLUDED #ifndef XmlTok_INCLUDED
@ -10,13 +42,15 @@ extern "C" {
#endif #endif
/* The following token may be returned by XmlContentTok */ /* The following token may be returned by XmlContentTok */
#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be #define XML_TOK_TRAILING_RSQB \
-5 /* ] or ]] at the end of the scan; might be \
start of illegal ]]> sequence */ start of illegal ]]> sequence */
/* The following tokens may be returned by both XmlPrologTok and /* The following tokens may be returned by both XmlPrologTok and
XmlContentTok. XmlContentTok.
*/ */
#define XML_TOK_NONE -4 /* The string to be scanned is empty */ #define XML_TOK_NONE -4 /* The string to be scanned is empty */
#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan; #define XML_TOK_TRAILING_CR \
-3 /* A CR at the end of the scan; \
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_CHAR -2 /* only part of a multibyte sequence */
#define XML_TOK_PARTIAL -1 /* only part of a token */ #define XML_TOK_PARTIAL -1 /* only part of a token */
@ -125,49 +159,35 @@ typedef struct {
struct encoding; struct encoding;
typedef struct encoding ENCODING; typedef struct encoding ENCODING;
typedef int (PTRCALL *SCANNER)(const ENCODING *, typedef int(PTRCALL *SCANNER)(const ENCODING *, const char *, const char *,
const char *,
const char *,
const char **); const char **);
enum XML_Convert_Result { enum XML_Convert_Result {
XML_CONVERT_COMPLETED = 0, XML_CONVERT_COMPLETED = 0,
XML_CONVERT_INPUT_INCOMPLETE = 1, XML_CONVERT_INPUT_INCOMPLETE = 1,
XML_CONVERT_OUTPUT_EXHAUSTED = 2 /* and therefore potentially input remaining as well */ XML_CONVERT_OUTPUT_EXHAUSTED
= 2 /* and therefore potentially input remaining as well */
}; };
struct encoding { struct encoding {
SCANNER scanners[XML_N_STATES]; SCANNER scanners[XML_N_STATES];
SCANNER literalScanners[XML_N_LITERAL_TYPES]; SCANNER literalScanners[XML_N_LITERAL_TYPES];
int (PTRCALL *sameName)(const ENCODING *, int(PTRCALL *nameMatchesAscii)(const ENCODING *, const char *, const char *,
const char *,
const char *);
int (PTRCALL *nameMatchesAscii)(const ENCODING *,
const char *,
const char *,
const char *); const char *);
int(PTRFASTCALL *nameLength)(const ENCODING *, const char *); int(PTRFASTCALL *nameLength)(const ENCODING *, const char *);
const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *); const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *);
int (PTRCALL *getAtts)(const ENCODING *enc, int(PTRCALL *getAtts)(const ENCODING *enc, const char *ptr, int attsMax,
const char *ptr,
int attsMax,
ATTRIBUTE *atts); ATTRIBUTE *atts);
int(PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr); int(PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr);
int (PTRCALL *predefinedEntityName)(const ENCODING *, int(PTRCALL *predefinedEntityName)(const ENCODING *, const char *,
const char *,
const char *); const char *);
void (PTRCALL *updatePosition)(const ENCODING *, void(PTRCALL *updatePosition)(const ENCODING *, const char *ptr,
const char *ptr, const char *end, POSITION *);
const char *end, int(PTRCALL *isPublicId)(const ENCODING *enc, const char *ptr,
POSITION *); const char *end, const char **badPtr);
int (PTRCALL *isPublicId)(const ENCODING *enc,
const char *ptr,
const char *end,
const char **badPtr);
enum XML_Convert_Result(PTRCALL *utf8Convert)(const ENCODING *enc, enum XML_Convert_Result(PTRCALL *utf8Convert)(const ENCODING *enc,
const char **fromP, const char **fromP,
const char *fromLim, const char *fromLim, char **toP,
char **toP,
const char *toLim); const char *toLim);
enum XML_Convert_Result(PTRCALL *utf16Convert)(const ENCODING *enc, enum XML_Convert_Result(PTRCALL *utf16Convert)(const ENCODING *enc,
const char **fromP, const char **fromP,
@ -200,7 +220,6 @@ struct encoding {
the prolog outside literals, comments and processing instructions. the prolog outside literals, comments and processing instructions.
*/ */
#define XmlTok(enc, state, ptr, end, nextTokPtr) \ #define XmlTok(enc, state, ptr, end, nextTokPtr) \
(((enc)->scanners[state])(enc, ptr, end, nextTokPtr)) (((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
@ -232,22 +251,17 @@ struct encoding {
#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \ #define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr) XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \ #define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
(((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2)) (((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
#define XmlNameLength(enc, ptr) \ #define XmlNameLength(enc, ptr) (((enc)->nameLength)(enc, ptr))
(((enc)->nameLength)(enc, ptr))
#define XmlSkipS(enc, ptr) \ #define XmlSkipS(enc, ptr) (((enc)->skipS)(enc, ptr))
(((enc)->skipS)(enc, ptr))
#define XmlGetAttributes(enc, ptr, attsMax, atts) \ #define XmlGetAttributes(enc, ptr, attsMax, atts) \
(((enc)->getAtts)(enc, ptr, attsMax, atts)) (((enc)->getAtts)(enc, ptr, attsMax, atts))
#define XmlCharRefNumber(enc, ptr) \ #define XmlCharRefNumber(enc, ptr) (((enc)->charRefNumber)(enc, ptr))
(((enc)->charRefNumber)(enc, ptr))
#define XmlPredefinedEntityName(enc, ptr, end) \ #define XmlPredefinedEntityName(enc, ptr, end) \
(((enc)->predefinedEntityName)(enc, ptr, end)) (((enc)->predefinedEntityName)(enc, ptr, end))
@ -269,16 +283,11 @@ typedef struct {
const ENCODING **encPtr; const ENCODING **encPtr;
} INIT_ENCODING; } INIT_ENCODING;
int XmlParseXmlDecl(int isGeneralTextEntity, int XmlParseXmlDecl(int isGeneralTextEntity, const ENCODING *enc,
const ENCODING *enc, const char *ptr, const char *end, const char **badPtr,
const char *ptr, const char **versionPtr, const char **versionEndPtr,
const char *end,
const char **badPtr,
const char **versionPtr,
const char **versionEndPtr,
const char **encodingNamePtr, const char **encodingNamePtr,
const ENCODING **namedEncodingPtr, const ENCODING **namedEncodingPtr, int *standalonePtr);
int *standalonePtr);
int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name); int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
const ENCODING *XmlGetUtf8InternalEncoding(void); const ENCODING *XmlGetUtf8InternalEncoding(void);
@ -287,33 +296,21 @@ int FASTCALL XmlUtf8Encode(int charNumber, char *buf);
int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf); int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf);
int XmlSizeOfUnknownEncoding(void); int XmlSizeOfUnknownEncoding(void);
typedef int(XMLCALL *CONVERTER)(void *userData, const char *p); typedef int(XMLCALL *CONVERTER)(void *userData, const char *p);
ENCODING * ENCODING *XmlInitUnknownEncoding(void *mem, int *table, CONVERTER convert,
XmlInitUnknownEncoding(void *mem,
int *table,
CONVERTER convert,
void *userData); void *userData);
int XmlParseXmlDeclNS(int isGeneralTextEntity, int XmlParseXmlDeclNS(int isGeneralTextEntity, const ENCODING *enc,
const ENCODING *enc, const char *ptr, const char *end, const char **badPtr,
const char *ptr, const char **versionPtr, const char **versionEndPtr,
const char *end,
const char **badPtr,
const char **versionPtr,
const char **versionEndPtr,
const char **encodingNamePtr, const char **encodingNamePtr,
const ENCODING **namedEncodingPtr, const ENCODING **namedEncodingPtr, int *standalonePtr);
int *standalonePtr);
int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name); int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
const ENCODING *XmlGetUtf8InternalEncodingNS(void); const ENCODING *XmlGetUtf8InternalEncodingNS(void);
const ENCODING *XmlGetUtf16InternalEncodingNS(void); const ENCODING *XmlGetUtf16InternalEncodingNS(void);
ENCODING * ENCODING *XmlInitUnknownEncodingNS(void *mem, int *table, CONVERTER convert,
XmlInitUnknownEncodingNS(void *mem,
int *table,
CONVERTER convert,
void *userData); void *userData);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,46 +1,74 @@
/* /*
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd __ __ _
See the file COPYING for copying permission. ___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2017-2019 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
enum { enum {
BT_NONXML, BT_NONXML, /* e.g. noncharacter-FFFF */
BT_MALFORM, BT_MALFORM, /* illegal, with regard to encoding */
BT_LT, BT_LT, /* less than = "<" */
BT_AMP, BT_AMP, /* ampersand = "&" */
BT_RSQB, BT_RSQB, /* right square bracket = "[" */
BT_LEAD2, BT_LEAD2, /* lead byte of a 2-byte UTF-8 character */
BT_LEAD3, BT_LEAD3, /* lead byte of a 3-byte UTF-8 character */
BT_LEAD4, BT_LEAD4, /* lead byte of a 4-byte UTF-8 character */
BT_TRAIL, BT_TRAIL, /* trailing unit, e.g. second 16-bit unit of a 4-byte char. */
BT_CR, BT_CR, /* carriage return = "\r" */
BT_LF, BT_LF, /* line feed = "\n" */
BT_GT, BT_GT, /* greater than = ">" */
BT_QUOT, BT_QUOT, /* quotation character = "\"" */
BT_APOS, BT_APOS, /* apostrophe = "'" */
BT_EQUALS, BT_EQUALS, /* equal sign = "=" */
BT_QUEST, BT_QUEST, /* question mark = "?" */
BT_EXCL, BT_EXCL, /* exclamation mark = "!" */
BT_SOL, BT_SOL, /* solidus, slash = "/" */
BT_SEMI, BT_SEMI, /* semicolon = ";" */
BT_NUM, BT_NUM, /* number sign = "#" */
BT_LSQB, BT_LSQB, /* left square bracket = "[" */
BT_S, BT_S, /* white space, e.g. "\t", " "[, "\r"] */
BT_NMSTRT, BT_NMSTRT, /* non-hex name start letter = "G".."Z" + "g".."z" + "_" */
BT_COLON, BT_COLON, /* colon = ":" */
BT_HEX, BT_HEX, /* hex letter = "A".."F" + "a".."f" */
BT_DIGIT, BT_DIGIT, /* digit = "0".."9" */
BT_NAME, BT_NAME, /* dot and middle dot = "." + chr(0xb7) */
BT_MINUS, BT_MINUS, /* minus = "-" */
BT_OTHER, /* known not to be a name or name start character */ BT_OTHER, /* known not to be a name or name start character */
BT_NONASCII, /* might be a name or name start character */ BT_NONASCII, /* might be a name or name start character */
BT_PERCNT, BT_PERCNT, /* percent sign = "%" */
BT_LPAR, BT_LPAR, /* left parenthesis = "(" */
BT_RPAR, BT_RPAR, /* right parenthesis = "(" */
BT_AST, BT_AST, /* asterisk = "*" */
BT_PLUS, BT_PLUS, /* plus sign = "+" */
BT_COMMA, BT_COMMA, /* comma = "," */
BT_VERBAR BT_VERBAR /* vertical bar = "|" */
}; };
#include <stddef.h> #include <stddef.h>

View File

@ -1,11 +1,47 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd /* This file is included (from xmltok.c, 1-3 times depending on XML_MIN_SIZE)!
See the file COPYING for copying permission. __ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2018 Benjamin Peterson <benjamin@python.org>
Copyright (c) 2018 Anton Maklakov <antmak.pub@gmail.com>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Copyright (c) 2020 Boris Kolpackov <boris@codesynthesis.com>
Copyright (c) 2022 Martin Ettl <ettl.martin78@googlemail.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
/* This file is included! */
#ifdef XML_TOK_IMPL_C #ifdef XML_TOK_IMPL_C
#ifndef IS_INVALID_CHAR # ifndef IS_INVALID_CHAR // i.e. for UTF-16 and XML_MIN_SIZE not defined
# define IS_INVALID_CHAR(enc, ptr, n) (0) # define IS_INVALID_CHAR(enc, ptr, n) (0)
# endif # endif
@ -34,7 +70,7 @@
case BT_LEAD##n: \ case BT_LEAD##n: \
if (end - ptr < n) \ if (end - ptr < n) \
return XML_TOK_PARTIAL_CHAR; \ return XML_TOK_PARTIAL_CHAR; \
if (!IS_NAME_CHAR(enc, ptr, n)) { \ if (IS_INVALID_CHAR(enc, ptr, n) || ! IS_NAME_CHAR(enc, ptr, n)) { \
*nextTokPtr = ptr; \ *nextTokPtr = ptr; \
return XML_TOK_INVALID; \ return XML_TOK_INVALID; \
} \ } \
@ -47,6 +83,7 @@
*nextTokPtr = ptr; \ *nextTokPtr = ptr; \
return XML_TOK_INVALID; \ return XML_TOK_INVALID; \
} \ } \
/* fall through */ \
case BT_NMSTRT: \ case BT_NMSTRT: \
case BT_HEX: \ case BT_HEX: \
case BT_DIGIT: \ case BT_DIGIT: \
@ -60,9 +97,9 @@
# define CHECK_NMSTRT_CASE(n, enc, ptr, end, nextTokPtr) \ # define CHECK_NMSTRT_CASE(n, enc, ptr, end, nextTokPtr) \
case BT_LEAD##n: \ case BT_LEAD##n: \
if (end - ptr < n) \ if ((end) - (ptr) < (n)) \
return XML_TOK_PARTIAL_CHAR; \ return XML_TOK_PARTIAL_CHAR; \
if (!IS_NMSTRT_CHAR(enc, ptr, n)) { \ if (IS_INVALID_CHAR(enc, ptr, n) || ! IS_NMSTRT_CHAR(enc, ptr, n)) { \
*nextTokPtr = ptr; \ *nextTokPtr = ptr; \
return XML_TOK_INVALID; \ return XML_TOK_INVALID; \
} \ } \
@ -75,6 +112,7 @@
*nextTokPtr = ptr; \ *nextTokPtr = ptr; \
return XML_TOK_INVALID; \ return XML_TOK_INVALID; \
} \ } \
/* fall through */ \
case BT_NMSTRT: \ case BT_NMSTRT: \
case BT_HEX: \ case BT_HEX: \
ptr += MINBPC(enc); \ ptr += MINBPC(enc); \
@ -87,12 +125,10 @@
# define PREFIX(ident) ident # define PREFIX(ident) ident
# endif # endif
# define HAS_CHARS(enc, ptr, end, count) \ # define HAS_CHARS(enc, ptr, end, count) \
(end - ptr >= count * MINBPC(enc)) ((end) - (ptr) >= ((count)*MINBPC(enc)))
#define HAS_CHAR(enc, ptr, end) \ # define HAS_CHAR(enc, ptr, end) HAS_CHARS(enc, ptr, end, 1)
HAS_CHARS(enc, ptr, end, 1)
# define REQUIRE_CHARS(enc, ptr, end, count) \ # define REQUIRE_CHARS(enc, ptr, end, count) \
{ \ { \
@ -101,16 +137,13 @@
} \ } \
} }
#define REQUIRE_CHAR(enc, ptr, end) \ # define REQUIRE_CHAR(enc, ptr, end) REQUIRE_CHARS(enc, ptr, end, 1)
REQUIRE_CHARS(enc, ptr, end, 1)
/* ptr points to character following "<!-" */ /* ptr points to character following "<!-" */
static int PTRCALL static int PTRCALL
PREFIX(scanComment)(const ENCODING *enc, const char *ptr, PREFIX(scanComment)(const ENCODING *enc, const char *ptr, const char *end,
const char *end, const char **nextTokPtr) const char **nextTokPtr) {
{
if (HAS_CHAR(enc, ptr, end)) { if (HAS_CHAR(enc, ptr, end)) {
if (! CHAR_MATCHES(enc, ptr, ASCII_MINUS)) { if (! CHAR_MATCHES(enc, ptr, ASCII_MINUS)) {
*nextTokPtr = ptr; *nextTokPtr = ptr;
@ -146,9 +179,8 @@ PREFIX(scanComment)(const ENCODING *enc, const char *ptr,
/* ptr points to character following "<!" */ /* ptr points to character following "<!" */
static int PTRCALL static int PTRCALL
PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, const char *end,
const char *end, const char **nextTokPtr) const char **nextTokPtr) {
{
REQUIRE_CHAR(enc, ptr, end); REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
case BT_MINUS: case BT_MINUS:
@ -170,12 +202,17 @@ PREFIX(scanDecl)(const ENCODING *enc, const char *ptr,
REQUIRE_CHARS(enc, ptr, end, 2); REQUIRE_CHARS(enc, ptr, end, 2);
/* don't allow <!ENTITY% foo "whatever"> */ /* don't allow <!ENTITY% foo "whatever"> */
switch (BYTE_TYPE(enc, ptr + MINBPC(enc))) { switch (BYTE_TYPE(enc, ptr + MINBPC(enc))) {
case BT_S: case BT_CR: case BT_LF: case BT_PERCNT: case BT_S:
case BT_CR:
case BT_LF:
case BT_PERCNT:
*nextTokPtr = ptr; *nextTokPtr = ptr;
return XML_TOK_INVALID; return XML_TOK_INVALID;
} }
/* fall through */ /* fall through */
case BT_S: case BT_CR: case BT_LF: case BT_S:
case BT_CR:
case BT_LF:
*nextTokPtr = ptr; *nextTokPtr = ptr;
return XML_TOK_DECL_OPEN; return XML_TOK_DECL_OPEN;
case BT_NMSTRT: case BT_NMSTRT:
@ -191,10 +228,10 @@ PREFIX(scanDecl)(const ENCODING *enc, const char *ptr,
} }
static int PTRCALL static int PTRCALL
PREFIX(checkPiTarget)(const ENCODING *UNUSED_P(enc), const char *ptr, PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, const char *end,
const char *end, int *tokPtr) int *tokPtr) {
{
int upper = 0; int upper = 0;
UNUSED_P(enc);
*tokPtr = XML_TOK_PI; *tokPtr = XML_TOK_PI;
if (end - ptr != MINBPC(enc) * 3) if (end - ptr != MINBPC(enc) * 3)
return 1; return 1;
@ -236,9 +273,8 @@ PREFIX(checkPiTarget)(const ENCODING *UNUSED_P(enc), const char *ptr,
/* ptr points to character following "<?" */ /* ptr points to character following "<?" */
static int PTRCALL static int PTRCALL
PREFIX(scanPi)(const ENCODING *enc, const char *ptr, PREFIX(scanPi)(const ENCODING *enc, const char *ptr, const char *end,
const char *end, const char **nextTokPtr) const char **nextTokPtr) {
{
int tok; int tok;
const char *target = ptr; const char *target = ptr;
REQUIRE_CHAR(enc, ptr, end); REQUIRE_CHAR(enc, ptr, end);
@ -251,7 +287,9 @@ PREFIX(scanPi)(const ENCODING *enc, const char *ptr,
while (HAS_CHAR(enc, ptr, end)) { while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
case BT_S: case BT_CR: case BT_LF: case BT_S:
case BT_CR:
case BT_LF:
if (! PREFIX(checkPiTarget)(enc, target, ptr, &tok)) { if (! PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
*nextTokPtr = ptr; *nextTokPtr = ptr;
return XML_TOK_INVALID; return XML_TOK_INVALID;
@ -295,12 +333,12 @@ PREFIX(scanPi)(const ENCODING *enc, const char *ptr,
} }
static int PTRCALL static int PTRCALL
PREFIX(scanCdataSection)(const ENCODING *UNUSED_P(enc), const char *ptr, PREFIX(scanCdataSection)(const ENCODING *enc, const char *ptr, const char *end,
const char *end, const char **nextTokPtr) const char **nextTokPtr) {
{ static const char CDATA_LSQB[]
static const char CDATA_LSQB[] = { ASCII_C, ASCII_D, ASCII_A, = {ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, ASCII_LSQB};
ASCII_T, ASCII_A, ASCII_LSQB };
int i; int i;
UNUSED_P(enc);
/* CDATA[ */ /* CDATA[ */
REQUIRE_CHARS(enc, ptr, end, 6); REQUIRE_CHARS(enc, ptr, end, 6);
for (i = 0; i < 6; i++, ptr += MINBPC(enc)) { for (i = 0; i < 6; i++, ptr += MINBPC(enc)) {
@ -314,9 +352,8 @@ PREFIX(scanCdataSection)(const ENCODING *UNUSED_P(enc), const char *ptr,
} }
static int PTRCALL static int PTRCALL
PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, const char *end,
const char *end, const char **nextTokPtr) const char **nextTokPtr) {
{
if (ptr >= end) if (ptr >= end)
return XML_TOK_NONE; return XML_TOK_NONE;
if (MINBPC(enc) > 1) { if (MINBPC(enc) > 1) {
@ -367,7 +404,9 @@ PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr,
} \ } \
ptr += n; \ ptr += n; \
break; break;
LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) LEAD_CASE(2)
LEAD_CASE(3)
LEAD_CASE(4)
# undef LEAD_CASE # undef LEAD_CASE
case BT_NONXML: case BT_NONXML:
case BT_MALFORM: case BT_MALFORM:
@ -389,9 +428,8 @@ PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr,
/* ptr points to character following "</" */ /* ptr points to character following "</" */
static int PTRCALL static int PTRCALL
PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, const char *end,
const char *end, const char **nextTokPtr) const char **nextTokPtr) {
{
REQUIRE_CHAR(enc, ptr, end); REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
@ -402,10 +440,14 @@ PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr,
while (HAS_CHAR(enc, ptr, end)) { while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
case BT_S: case BT_CR: case BT_LF: case BT_S:
case BT_CR:
case BT_LF:
for (ptr += MINBPC(enc); HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) { for (ptr += MINBPC(enc); HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) {
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
case BT_S: case BT_CR: case BT_LF: case BT_S:
case BT_CR:
case BT_LF:
break; break;
case BT_GT: case BT_GT:
*nextTokPtr = ptr + MINBPC(enc); *nextTokPtr = ptr + MINBPC(enc);
@ -437,9 +479,8 @@ PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr,
/* ptr points to character following "&#X" */ /* ptr points to character following "&#X" */
static int PTRCALL static int PTRCALL
PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, const char *end,
const char *end, const char **nextTokPtr) const char **nextTokPtr) {
{
if (HAS_CHAR(enc, ptr, end)) { if (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
case BT_DIGIT: case BT_DIGIT:
@ -469,9 +510,8 @@ PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr,
/* ptr points to character following "&#" */ /* ptr points to character following "&#" */
static int PTRCALL static int PTRCALL
PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, const char *end,
const char *end, const char **nextTokPtr) const char **nextTokPtr) {
{
if (HAS_CHAR(enc, ptr, end)) { if (HAS_CHAR(enc, ptr, end)) {
if (CHAR_MATCHES(enc, ptr, ASCII_x)) if (CHAR_MATCHES(enc, ptr, ASCII_x))
return PREFIX(scanHexCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr); return PREFIX(scanHexCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
@ -502,8 +542,7 @@ PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr,
static int PTRCALL static int PTRCALL
PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end, PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr) const char **nextTokPtr) {
{
REQUIRE_CHAR(enc, ptr, end); REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
@ -531,8 +570,7 @@ PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end,
static int PTRCALL static int PTRCALL
PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end, PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr) const char **nextTokPtr) {
{
# ifdef XML_NS # ifdef XML_NS
int hadColon = 0; int hadColon = 0;
# endif # endif
@ -556,7 +594,9 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
} }
break; break;
# endif # endif
case BT_S: case BT_CR: case BT_LF: case BT_S:
case BT_CR:
case BT_LF:
for (;;) { for (;;) {
int t; int t;
@ -576,8 +616,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
} }
} }
/* fall through */ /* fall through */
case BT_EQUALS: case BT_EQUALS: {
{
int open; int open;
# ifdef XML_NS # ifdef XML_NS
hadColon = 0; hadColon = 0;
@ -608,8 +647,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
break; break;
switch (t) { switch (t) {
INVALID_CASES(ptr, nextTokPtr) INVALID_CASES(ptr, nextTokPtr)
case BT_AMP: case BT_AMP: {
{
int tok = PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, &ptr); int tok = PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, &ptr);
if (tok <= 0) { if (tok <= 0) {
if (tok == XML_TOK_INVALID) if (tok == XML_TOK_INVALID)
@ -647,7 +685,9 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
REQUIRE_CHAR(enc, ptr, end); REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
case BT_S: case BT_CR: case BT_LF: case BT_S:
case BT_CR:
case BT_LF:
continue; continue;
case BT_GT: case BT_GT:
gt: gt:
@ -683,8 +723,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
static int PTRCALL static int PTRCALL
PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end, PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr) const char **nextTokPtr) {
{
# ifdef XML_NS # ifdef XML_NS
int hadColon; int hadColon;
# endif # endif
@ -698,8 +737,7 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
case BT_MINUS: case BT_MINUS:
return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr); return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr);
case BT_LSQB: case BT_LSQB:
return PREFIX(scanCdataSection)(enc, ptr + MINBPC(enc), return PREFIX(scanCdataSection)(enc, ptr + MINBPC(enc), end, nextTokPtr);
end, nextTokPtr);
} }
*nextTokPtr = ptr; *nextTokPtr = ptr;
return XML_TOK_INVALID; return XML_TOK_INVALID;
@ -735,8 +773,9 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
} }
break; break;
# endif # endif
case BT_S: case BT_CR: case BT_LF: case BT_S:
{ case BT_CR:
case BT_LF: {
ptr += MINBPC(enc); ptr += MINBPC(enc);
while (HAS_CHAR(enc, ptr, end)) { while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
@ -745,7 +784,9 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
goto gt; goto gt;
case BT_SOL: case BT_SOL:
goto sol; goto sol;
case BT_S: case BT_CR: case BT_LF: case BT_S:
case BT_CR:
case BT_LF:
ptr += MINBPC(enc); ptr += MINBPC(enc);
continue; continue;
default: default:
@ -780,8 +821,7 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
static int PTRCALL static int PTRCALL
PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end, PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr) const char **nextTokPtr) {
{
if (ptr >= end) if (ptr >= end)
return XML_TOK_NONE; return XML_TOK_NONE;
if (MINBPC(enc) > 1) { if (MINBPC(enc) > 1) {
@ -839,7 +879,9 @@ PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
} \ } \
ptr += n; \ ptr += n; \
break; break;
LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) LEAD_CASE(2)
LEAD_CASE(3)
LEAD_CASE(4)
# undef LEAD_CASE # undef LEAD_CASE
case BT_RSQB: case BT_RSQB:
if (HAS_CHARS(enc, ptr, end, 2)) { if (HAS_CHARS(enc, ptr, end, 2)) {
@ -879,12 +921,14 @@ PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
static int PTRCALL static int PTRCALL
PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end, PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr) const char **nextTokPtr) {
{
REQUIRE_CHAR(enc, ptr, end); REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
case BT_S: case BT_LF: case BT_CR: case BT_PERCNT: case BT_S:
case BT_LF:
case BT_CR:
case BT_PERCNT:
*nextTokPtr = ptr; *nextTokPtr = ptr;
return XML_TOK_PERCENT; return XML_TOK_PERCENT;
default: default:
@ -907,8 +951,7 @@ PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end,
static int PTRCALL static int PTRCALL
PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end, PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr) const char **nextTokPtr) {
{
REQUIRE_CHAR(enc, ptr, end); REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
@ -919,8 +962,13 @@ PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end,
while (HAS_CHAR(enc, ptr, end)) { while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
case BT_CR: case BT_LF: case BT_S: case BT_CR:
case BT_RPAR: case BT_GT: case BT_PERCNT: case BT_VERBAR: case BT_LF:
case BT_S:
case BT_RPAR:
case BT_GT:
case BT_PERCNT:
case BT_VERBAR:
*nextTokPtr = ptr; *nextTokPtr = ptr;
return XML_TOK_POUND_NAME; return XML_TOK_POUND_NAME;
default: default:
@ -932,10 +980,8 @@ PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end,
} }
static int PTRCALL static int PTRCALL
PREFIX(scanLit)(int open, const ENCODING *enc, PREFIX(scanLit)(int open, const ENCODING *enc, const char *ptr, const char *end,
const char *ptr, const char *end, const char **nextTokPtr) {
const char **nextTokPtr)
{
while (HAS_CHAR(enc, ptr, end)) { while (HAS_CHAR(enc, ptr, end)) {
int t = BYTE_TYPE(enc, ptr); int t = BYTE_TYPE(enc, ptr);
switch (t) { switch (t) {
@ -949,8 +995,12 @@ PREFIX(scanLit)(int open, const ENCODING *enc,
return -XML_TOK_LITERAL; return -XML_TOK_LITERAL;
*nextTokPtr = ptr; *nextTokPtr = ptr;
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
case BT_S: case BT_CR: case BT_LF: case BT_S:
case BT_GT: case BT_PERCNT: case BT_LSQB: case BT_CR:
case BT_LF:
case BT_GT:
case BT_PERCNT:
case BT_LSQB:
return XML_TOK_LITERAL; return XML_TOK_LITERAL;
default: default:
return XML_TOK_INVALID; return XML_TOK_INVALID;
@ -965,8 +1015,7 @@ PREFIX(scanLit)(int open, const ENCODING *enc,
static int PTRCALL static int PTRCALL
PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end, PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr) const char **nextTokPtr) {
{
int tok; int tok;
if (ptr >= end) if (ptr >= end)
return XML_TOK_NONE; return XML_TOK_NONE;
@ -984,8 +1033,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
return PREFIX(scanLit)(BT_QUOT, enc, ptr + MINBPC(enc), end, nextTokPtr); return PREFIX(scanLit)(BT_QUOT, enc, ptr + MINBPC(enc), end, nextTokPtr);
case BT_APOS: case BT_APOS:
return PREFIX(scanLit)(BT_APOS, enc, ptr + MINBPC(enc), end, nextTokPtr); return PREFIX(scanLit)(BT_APOS, enc, ptr + MINBPC(enc), end, nextTokPtr);
case BT_LT: case BT_LT: {
{
ptr += MINBPC(enc); ptr += MINBPC(enc);
REQUIRE_CHAR(enc, ptr, end); REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
@ -1012,13 +1060,15 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
return -XML_TOK_PROLOG_S; return -XML_TOK_PROLOG_S;
} }
/* fall through */ /* fall through */
case BT_S: case BT_LF: case BT_S:
case BT_LF:
for (;;) { for (;;) {
ptr += MINBPC(enc); ptr += MINBPC(enc);
if (! HAS_CHAR(enc, ptr, end)) if (! HAS_CHAR(enc, ptr, end))
break; break;
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
case BT_S: case BT_LF: case BT_S:
case BT_LF:
break; break;
case BT_CR: case BT_CR:
/* don't split CR/LF pair */ /* don't split CR/LF pair */
@ -1070,8 +1120,12 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
case BT_PLUS: case BT_PLUS:
*nextTokPtr = ptr + MINBPC(enc); *nextTokPtr = ptr + MINBPC(enc);
return XML_TOK_CLOSE_PAREN_PLUS; return XML_TOK_CLOSE_PAREN_PLUS;
case BT_CR: case BT_LF: case BT_S: case BT_CR:
case BT_GT: case BT_COMMA: case BT_VERBAR: case BT_LF:
case BT_S:
case BT_GT:
case BT_COMMA:
case BT_VERBAR:
case BT_RPAR: case BT_RPAR:
*nextTokPtr = ptr; *nextTokPtr = ptr;
return XML_TOK_CLOSE_PAREN; return XML_TOK_CLOSE_PAREN;
@ -1090,6 +1144,10 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
case BT_LEAD##n: \ case BT_LEAD##n: \
if (end - ptr < n) \ if (end - ptr < n) \
return XML_TOK_PARTIAL_CHAR; \ return XML_TOK_PARTIAL_CHAR; \
if (IS_INVALID_CHAR(enc, ptr, n)) { \
*nextTokPtr = ptr; \
return XML_TOK_INVALID; \
} \
if (IS_NMSTRT_CHAR(enc, ptr, n)) { \ if (IS_NMSTRT_CHAR(enc, ptr, n)) { \
ptr += n; \ ptr += n; \
tok = XML_TOK_NAME; \ tok = XML_TOK_NAME; \
@ -1102,7 +1160,9 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
} \ } \
*nextTokPtr = ptr; \ *nextTokPtr = ptr; \
return XML_TOK_INVALID; return XML_TOK_INVALID;
LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) LEAD_CASE(2)
LEAD_CASE(3)
LEAD_CASE(4)
# undef LEAD_CASE # undef LEAD_CASE
case BT_NMSTRT: case BT_NMSTRT:
case BT_HEX: case BT_HEX:
@ -1137,9 +1197,15 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
while (HAS_CHAR(enc, ptr, end)) { while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
case BT_GT: case BT_RPAR: case BT_COMMA: case BT_GT:
case BT_VERBAR: case BT_LSQB: case BT_PERCNT: case BT_RPAR:
case BT_S: case BT_CR: case BT_LF: case BT_COMMA:
case BT_VERBAR:
case BT_LSQB:
case BT_PERCNT:
case BT_S:
case BT_CR:
case BT_LF:
*nextTokPtr = ptr; *nextTokPtr = ptr;
return tok; return tok;
# ifdef XML_NS # ifdef XML_NS
@ -1192,20 +1258,29 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
} }
static int PTRCALL static int PTRCALL
PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end,
const char *end, const char **nextTokPtr) const char **nextTokPtr) {
{
const char *start; const char *start;
if (ptr >= end) if (ptr >= end)
return XML_TOK_NONE; return XML_TOK_NONE;
else if (! HAS_CHAR(enc, ptr, end)) else if (! HAS_CHAR(enc, ptr, end)) {
return XML_TOK_PARTIAL; /* This line cannot be executed. The incoming data has already
* been tokenized once, so incomplete characters like this have
* already been eliminated from the input. Retaining the paranoia
* check is still valuable, however.
*/
return XML_TOK_PARTIAL; /* LCOV_EXCL_LINE */
}
start = ptr; start = ptr;
while (HAS_CHAR(enc, ptr, end)) { while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
# define LEAD_CASE(n) \ # define LEAD_CASE(n) \
case BT_LEAD ## n: ptr += n; break; case BT_LEAD##n: \
LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) ptr += n; /* NOTE: The encoding has already been validated. */ \
break;
LEAD_CASE(2)
LEAD_CASE(3)
LEAD_CASE(4)
# undef LEAD_CASE # undef LEAD_CASE
case BT_AMP: case BT_AMP:
if (ptr == start) if (ptr == start)
@ -1252,20 +1327,29 @@ PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr,
} }
static int PTRCALL static int PTRCALL
PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end,
const char *end, const char **nextTokPtr) const char **nextTokPtr) {
{
const char *start; const char *start;
if (ptr >= end) if (ptr >= end)
return XML_TOK_NONE; return XML_TOK_NONE;
else if (! HAS_CHAR(enc, ptr, end)) else if (! HAS_CHAR(enc, ptr, end)) {
return XML_TOK_PARTIAL; /* This line cannot be executed. The incoming data has already
* been tokenized once, so incomplete characters like this have
* already been eliminated from the input. Retaining the paranoia
* check is still valuable, however.
*/
return XML_TOK_PARTIAL; /* LCOV_EXCL_LINE */
}
start = ptr; start = ptr;
while (HAS_CHAR(enc, ptr, end)) { while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
# define LEAD_CASE(n) \ # define LEAD_CASE(n) \
case BT_LEAD ## n: ptr += n; break; case BT_LEAD##n: \
LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) ptr += n; /* NOTE: The encoding has already been validated. */ \
break;
LEAD_CASE(2)
LEAD_CASE(3)
LEAD_CASE(4)
# undef LEAD_CASE # undef LEAD_CASE
case BT_AMP: case BT_AMP:
if (ptr == start) if (ptr == start)
@ -1274,8 +1358,7 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr,
return XML_TOK_DATA_CHARS; return XML_TOK_DATA_CHARS;
case BT_PERCNT: case BT_PERCNT:
if (ptr == start) { if (ptr == start) {
int tok = PREFIX(scanPercent)(enc, ptr + MINBPC(enc), int tok = PREFIX(scanPercent)(enc, ptr + MINBPC(enc), end, nextTokPtr);
end, nextTokPtr);
return (tok == XML_TOK_PERCENT) ? XML_TOK_INVALID : tok; return (tok == XML_TOK_PERCENT) ? XML_TOK_INVALID : tok;
} }
*nextTokPtr = ptr; *nextTokPtr = ptr;
@ -1311,9 +1394,8 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr,
# ifdef XML_DTD # ifdef XML_DTD
static int PTRCALL static int PTRCALL
PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, const char *end,
const char *end, const char **nextTokPtr) const char **nextTokPtr) {
{
int level = 0; int level = 0;
if (MINBPC(enc) > 1) { if (MINBPC(enc) > 1) {
size_t n = end - ptr; size_t n = end - ptr;
@ -1365,8 +1447,7 @@ PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr,
static int PTRCALL static int PTRCALL
PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end, PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
const char **badPtr) const char **badPtr) {
{
ptr += MINBPC(enc); ptr += MINBPC(enc);
end -= MINBPC(enc); end -= MINBPC(enc);
for (; HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) { for (; HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) {
@ -1403,6 +1484,7 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
case BT_NMSTRT: case BT_NMSTRT:
if (! (BYTE_TO_ASCII(enc, ptr) & ~0x7f)) if (! (BYTE_TO_ASCII(enc, ptr) & ~0x7f))
break; break;
/* fall through */
default: default:
switch (BYTE_TO_ASCII(enc, ptr)) { switch (BYTE_TO_ASCII(enc, ptr)) {
case 0x24: /* $ */ case 0x24: /* $ */
@ -1424,9 +1506,8 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
*/ */
static int PTRCALL static int PTRCALL
PREFIX(getAtts)(const ENCODING *enc, const char *ptr, PREFIX(getAtts)(const ENCODING *enc, const char *ptr, int attsMax,
int attsMax, ATTRIBUTE *atts) ATTRIBUTE *atts) {
{
enum { other, inName, inValue } state = inName; enum { other, inName, inValue } state = inName;
int nAtts = 0; int nAtts = 0;
int open = 0; /* defined when state == inValue; int open = 0; /* defined when state == inValue;
@ -1443,8 +1524,12 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
state = inName; \ state = inName; \
} }
# define LEAD_CASE(n) \ # define LEAD_CASE(n) \
case BT_LEAD ## n: START_NAME ptr += (n - MINBPC(enc)); break; case BT_LEAD##n: /* NOTE: The encoding has already been validated. */ \
LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) START_NAME ptr += (n - MINBPC(enc)); \
break;
LEAD_CASE(2)
LEAD_CASE(3)
LEAD_CASE(4)
# undef LEAD_CASE # undef LEAD_CASE
case BT_NONASCII: case BT_NONASCII:
case BT_NMSTRT: case BT_NMSTRT:
@ -1458,8 +1543,7 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
atts[nAtts].valuePtr = ptr + MINBPC(enc); atts[nAtts].valuePtr = ptr + MINBPC(enc);
state = inValue; state = inValue;
open = BT_QUOT; open = BT_QUOT;
} } else if (open == BT_QUOT) {
else if (open == BT_QUOT) {
state = other; state = other;
if (nAtts < attsMax) if (nAtts < attsMax)
atts[nAtts].valueEnd = ptr; atts[nAtts].valueEnd = ptr;
@ -1472,8 +1556,7 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
atts[nAtts].valuePtr = ptr + MINBPC(enc); atts[nAtts].valuePtr = ptr + MINBPC(enc);
state = inValue; state = inValue;
open = BT_APOS; open = BT_APOS;
} } else if (open == BT_APOS) {
else if (open == BT_APOS) {
state = other; state = other;
if (nAtts < attsMax) if (nAtts < attsMax)
atts[nAtts].valueEnd = ptr; atts[nAtts].valueEnd = ptr;
@ -1487,16 +1570,15 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
case BT_S: case BT_S:
if (state == inName) if (state == inName)
state = other; state = other;
else if (state == inValue else if (state == inValue && nAtts < attsMax && atts[nAtts].normalized
&& nAtts < attsMax
&& atts[nAtts].normalized
&& (ptr == atts[nAtts].valuePtr && (ptr == atts[nAtts].valuePtr
|| BYTE_TO_ASCII(enc, ptr) != ASCII_SPACE || BYTE_TO_ASCII(enc, ptr) != ASCII_SPACE
|| BYTE_TO_ASCII(enc, ptr + MINBPC(enc)) == ASCII_SPACE || BYTE_TO_ASCII(enc, ptr + MINBPC(enc)) == ASCII_SPACE
|| BYTE_TYPE(enc, ptr + MINBPC(enc)) == open)) || BYTE_TYPE(enc, ptr + MINBPC(enc)) == open))
atts[nAtts].normalized = 0; atts[nAtts].normalized = 0;
break; break;
case BT_CR: case BT_LF: case BT_CR:
case BT_LF:
/* This case ensures that the first attribute name is counted /* This case ensures that the first attribute name is counted
Apart from that we could just change state on the quote. */ Apart from that we could just change state on the quote. */
if (state == inName) if (state == inName)
@ -1517,29 +1599,44 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
} }
static int PTRFASTCALL static int PTRFASTCALL
PREFIX(charRefNumber)(const ENCODING *UNUSED_P(enc), const char *ptr) PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr) {
{
int result = 0; int result = 0;
/* skip &# */ /* skip &# */
UNUSED_P(enc);
ptr += 2 * MINBPC(enc); ptr += 2 * MINBPC(enc);
if (CHAR_MATCHES(enc, ptr, ASCII_x)) { if (CHAR_MATCHES(enc, ptr, ASCII_x)) {
for (ptr += MINBPC(enc); for (ptr += MINBPC(enc); ! CHAR_MATCHES(enc, ptr, ASCII_SEMI);
!CHAR_MATCHES(enc, ptr, ASCII_SEMI);
ptr += MINBPC(enc)) { ptr += MINBPC(enc)) {
int c = BYTE_TO_ASCII(enc, ptr); int c = BYTE_TO_ASCII(enc, ptr);
switch (c) { switch (c) {
case ASCII_0: case ASCII_1: case ASCII_2: case ASCII_3: case ASCII_4: case ASCII_0:
case ASCII_5: case ASCII_6: case ASCII_7: case ASCII_8: case ASCII_9: case ASCII_1:
case ASCII_2:
case ASCII_3:
case ASCII_4:
case ASCII_5:
case ASCII_6:
case ASCII_7:
case ASCII_8:
case ASCII_9:
result <<= 4; result <<= 4;
result |= (c - ASCII_0); result |= (c - ASCII_0);
break; break;
case ASCII_A: case ASCII_B: case ASCII_C: case ASCII_A:
case ASCII_D: case ASCII_E: case ASCII_F: case ASCII_B:
case ASCII_C:
case ASCII_D:
case ASCII_E:
case ASCII_F:
result <<= 4; result <<= 4;
result += 10 + (c - ASCII_A); result += 10 + (c - ASCII_A);
break; break;
case ASCII_a: case ASCII_b: case ASCII_c: case ASCII_a:
case ASCII_d: case ASCII_e: case ASCII_f: case ASCII_b:
case ASCII_c:
case ASCII_d:
case ASCII_e:
case ASCII_f:
result <<= 4; result <<= 4;
result += 10 + (c - ASCII_a); result += 10 + (c - ASCII_a);
break; break;
@ -1547,8 +1644,7 @@ PREFIX(charRefNumber)(const ENCODING *UNUSED_P(enc), const char *ptr)
if (result >= 0x110000) if (result >= 0x110000)
return -1; return -1;
} }
} } else {
else {
for (; ! CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) { for (; ! CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) {
int c = BYTE_TO_ASCII(enc, ptr); int c = BYTE_TO_ASCII(enc, ptr);
result *= 10; result *= 10;
@ -1561,9 +1657,9 @@ PREFIX(charRefNumber)(const ENCODING *UNUSED_P(enc), const char *ptr)
} }
static int PTRCALL static int PTRCALL
PREFIX(predefinedEntityName)(const ENCODING *UNUSED_P(enc), const char *ptr, PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr,
const char *end) const char *end) {
{ UNUSED_P(enc);
switch ((end - ptr) / MINBPC(enc)) { switch ((end - ptr) / MINBPC(enc)) {
case 2: case 2:
if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_t)) { if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_t)) {
@ -1615,76 +1711,18 @@ PREFIX(predefinedEntityName)(const ENCODING *UNUSED_P(enc), const char *ptr,
} }
static int PTRCALL static int PTRCALL
PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2) PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1,
{ const char *end1, const char *ptr2) {
for (;;) { UNUSED_P(enc);
switch (BYTE_TYPE(enc, ptr1)) {
#define LEAD_CASE(n) \
case BT_LEAD ## n: \
if (*ptr1++ != *ptr2++) \
return 0;
LEAD_CASE(4) LEAD_CASE(3) LEAD_CASE(2)
#undef LEAD_CASE
/* fall through */
if (*ptr1++ != *ptr2++)
return 0;
break;
case BT_NONASCII:
case BT_NMSTRT:
#ifdef XML_NS
case BT_COLON:
#endif
case BT_HEX:
case BT_DIGIT:
case BT_NAME:
case BT_MINUS:
if (*ptr2++ != *ptr1++)
return 0;
if (MINBPC(enc) > 1) {
if (*ptr2++ != *ptr1++)
return 0;
if (MINBPC(enc) > 2) {
if (*ptr2++ != *ptr1++)
return 0;
if (MINBPC(enc) > 3) {
if (*ptr2++ != *ptr1++)
return 0;
}
}
}
break;
default:
if (MINBPC(enc) == 1 && *ptr1 == *ptr2)
return 1;
switch (BYTE_TYPE(enc, ptr2)) {
case BT_LEAD2:
case BT_LEAD3:
case BT_LEAD4:
case BT_NONASCII:
case BT_NMSTRT:
#ifdef XML_NS
case BT_COLON:
#endif
case BT_HEX:
case BT_DIGIT:
case BT_NAME:
case BT_MINUS:
return 0;
default:
return 1;
}
}
}
/* not reached */
}
static int PTRCALL
PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1,
const char *end1, const char *ptr2)
{
for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) { for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) {
if (end1 - ptr1 < MINBPC(enc)) if (end1 - ptr1 < MINBPC(enc)) {
return 0; /* This line cannot be executed. The incoming data has already
* been tokenized once, so incomplete characters like this have
* already been eliminated from the input. Retaining the
* paranoia check is still valuable, however.
*/
return 0; /* LCOV_EXCL_LINE */
}
if (! CHAR_MATCHES(enc, ptr1, *ptr2)) if (! CHAR_MATCHES(enc, ptr1, *ptr2))
return 0; return 0;
} }
@ -1692,14 +1730,17 @@ PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1,
} }
static int PTRFASTCALL static int PTRFASTCALL
PREFIX(nameLength)(const ENCODING *enc, const char *ptr) PREFIX(nameLength)(const ENCODING *enc, const char *ptr) {
{
const char *start = ptr; const char *start = ptr;
for (;;) { for (;;) {
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
# define LEAD_CASE(n) \ # define LEAD_CASE(n) \
case BT_LEAD ## n: ptr += n; break; case BT_LEAD##n: \
LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) ptr += n; /* NOTE: The encoding has already been validated. */ \
break;
LEAD_CASE(2)
LEAD_CASE(3)
LEAD_CASE(4)
# undef LEAD_CASE # undef LEAD_CASE
case BT_NONASCII: case BT_NONASCII:
case BT_NMSTRT: case BT_NMSTRT:
@ -1719,8 +1760,7 @@ PREFIX(nameLength)(const ENCODING *enc, const char *ptr)
} }
static const char *PTRFASTCALL static const char *PTRFASTCALL
PREFIX(skipS)(const ENCODING *enc, const char *ptr) PREFIX(skipS)(const ENCODING *enc, const char *ptr) {
{
for (;;) { for (;;) {
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
case BT_LF: case BT_LF:
@ -1735,21 +1775,21 @@ PREFIX(skipS)(const ENCODING *enc, const char *ptr)
} }
static void PTRCALL static void PTRCALL
PREFIX(updatePosition)(const ENCODING *enc, PREFIX(updatePosition)(const ENCODING *enc, const char *ptr, const char *end,
const char *ptr, POSITION *pos) {
const char *end,
POSITION *pos)
{
while (HAS_CHAR(enc, ptr, end)) { while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) { switch (BYTE_TYPE(enc, ptr)) {
# define LEAD_CASE(n) \ # define LEAD_CASE(n) \
case BT_LEAD##n: \ case BT_LEAD##n: \
ptr += n; \ ptr += n; /* NOTE: The encoding has already been validated. */ \
pos->columnNumber++; \
break; break;
LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4) LEAD_CASE(2)
LEAD_CASE(3)
LEAD_CASE(4)
# undef LEAD_CASE # undef LEAD_CASE
case BT_LF: case BT_LF:
pos->columnNumber = (XML_Size)-1; pos->columnNumber = 0;
pos->lineNumber++; pos->lineNumber++;
ptr += MINBPC(enc); ptr += MINBPC(enc);
break; break;
@ -1758,13 +1798,13 @@ PREFIX(updatePosition)(const ENCODING *enc,
ptr += MINBPC(enc); ptr += MINBPC(enc);
if (HAS_CHAR(enc, ptr, end) && BYTE_TYPE(enc, ptr) == BT_LF) if (HAS_CHAR(enc, ptr, end) && BYTE_TYPE(enc, ptr) == BT_LF)
ptr += MINBPC(enc); ptr += MINBPC(enc);
pos->columnNumber = (XML_Size)-1; pos->columnNumber = 0;
break; break;
default: default:
ptr += MINBPC(enc); ptr += MINBPC(enc);
pos->columnNumber++;
break; break;
} }
pos->columnNumber++;
} }
} }

View File

@ -1,61 +1,83 @@
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd /* This file is included!
See the file COPYING for copying permission. __ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2017-2021 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
/* This file is included! */
#ifdef XML_TOK_NS_C #ifdef XML_TOK_NS_C
const ENCODING * const ENCODING *
NS(XmlGetUtf8InternalEncoding)(void) NS(XmlGetUtf8InternalEncoding)(void) {
{
return &ns(internal_utf8_encoding).enc; return &ns(internal_utf8_encoding).enc;
} }
const ENCODING * const ENCODING *
NS(XmlGetUtf16InternalEncoding)(void) NS(XmlGetUtf16InternalEncoding)(void) {
{
# if BYTEORDER == 1234 # if BYTEORDER == 1234
return &ns(internal_little2_encoding).enc; return &ns(internal_little2_encoding).enc;
# elif BYTEORDER == 4321 # elif BYTEORDER == 4321
return &ns(internal_big2_encoding).enc; return &ns(internal_big2_encoding).enc;
# else # else
const short n = 1; const short n = 1;
return (*(const char *)&n return (*(const char *)&n ? &ns(internal_little2_encoding).enc
? &ns(internal_little2_encoding).enc
: &ns(internal_big2_encoding).enc); : &ns(internal_big2_encoding).enc);
# endif # endif
} }
static const ENCODING *const NS(encodings)[] = { static const ENCODING *const NS(encodings)[] = {
&ns(latin1_encoding).enc, &ns(latin1_encoding).enc, &ns(ascii_encoding).enc,
&ns(ascii_encoding).enc, &ns(utf8_encoding).enc, &ns(big2_encoding).enc,
&ns(utf8_encoding).enc, &ns(big2_encoding).enc, &ns(little2_encoding).enc,
&ns(big2_encoding).enc,
&ns(big2_encoding).enc,
&ns(little2_encoding).enc,
&ns(utf8_encoding).enc /* NO_ENC */ &ns(utf8_encoding).enc /* NO_ENC */
}; };
static int PTRCALL static int PTRCALL
NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end, NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr) const char **nextTokPtr) {
{ return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE,
return initScan(NS(encodings), (const INIT_ENCODING *)enc, ptr, end, nextTokPtr);
XML_PROLOG_STATE, ptr, end, nextTokPtr);
} }
static int PTRCALL static int PTRCALL
NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end, NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr) const char **nextTokPtr) {
{ return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE,
return initScan(NS(encodings), (const INIT_ENCODING *)enc, ptr, end, nextTokPtr);
XML_CONTENT_STATE, ptr, end, nextTokPtr);
} }
int int
NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
const char *name) const char *name) {
{
int i = getEncodingIndex(name); int i = getEncodingIndex(name);
if (i == UNKNOWN_ENC) if (i == UNKNOWN_ENC)
return 0; return 0;
@ -69,10 +91,9 @@ NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
} }
static const ENCODING * static const ENCODING *
NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) {
{
# define ENCODING_MAX 128 # define ENCODING_MAX 128
char buf[ENCODING_MAX]; char buf[ENCODING_MAX] = "";
char *p = buf; char *p = buf;
int i; int i;
XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1); XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
@ -88,28 +109,14 @@ NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
} }
int int
NS(XmlParseXmlDecl)(int isGeneralTextEntity, NS(XmlParseXmlDecl)(int isGeneralTextEntity, const ENCODING *enc,
const ENCODING *enc, const char *ptr, const char *end, const char **badPtr,
const char *ptr, const char **versionPtr, const char **versionEndPtr,
const char *end, const char **encodingName, const ENCODING **encoding,
const char **badPtr, int *standalone) {
const char **versionPtr, return doParseXmlDecl(NS(findEncoding), isGeneralTextEntity, enc, ptr, end,
const char **versionEndPtr, badPtr, versionPtr, versionEndPtr, encodingName,
const char **encodingName, encoding, standalone);
const ENCODING **encoding,
int *standalone)
{
return doParseXmlDecl(NS(findEncoding),
isGeneralTextEntity,
enc,
ptr,
end,
badPtr,
versionPtr,
versionEndPtr,
encodingName,
encoding,
standalone);
} }
#endif /* XML_TOK_NS_C */ #endif /* XML_TOK_NS_C */

View File

@ -40,8 +40,10 @@ endif()
ExternalProject_Add(dep_OpenSSL ExternalProject_Add(dep_OpenSSL
#EXCLUDE_FROM_ALL ON #EXCLUDE_FROM_ALL ON
URL "https://github.com/openssl/openssl/archive/OpenSSL_1_1_1k.tar.gz" #URL "https://github.com/openssl/openssl/archive/OpenSSL_1_1_1k.tar.gz"
URL_HASH SHA256=b92f9d3d12043c02860e5e602e50a73ed21a69947bcc74d391f41148e9f6aa95 URL "https://github.com/openssl/openssl/archive/refs/tags/openssl-3.1.2.tar.gz"
#URL_HASH SHA256=b92f9d3d12043c02860e5e602e50a73ed21a69947bcc74d391f41148e9f6aa95
URL_HASH SHA256=8c776993154652d0bb393f506d850b811517c8bd8d24b1008aef57fbe55d3f31
DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/OpenSSL DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/OpenSSL
CONFIGURE_COMMAND ${_conf_cmd} ${_cross_arch} CONFIGURE_COMMAND ${_conf_cmd} ${_cross_arch}
"--openssldir=${DESTDIR}/usr/local" "--openssldir=${DESTDIR}/usr/local"

View File

@ -1,16 +1,16 @@
Common subdirectories: ../zlib-1.2.11/amiga and ./amiga diff --git a/CMakeLists.txt b/CMakeLists.txt
diff -u ../zlib-1.2.11/CMakeLists.txt ./CMakeLists.txt index b412dc7..5ca7fa8 100644
--- ../zlib-1.2.11/CMakeLists.txt 2017-01-15 09:29:40.000000000 +0100 --- a/CMakeLists.txt
+++ ./CMakeLists.txt 2021-03-24 15:24:48.190291072 +0100 +++ b/CMakeLists.txt
@@ -183,10 +183,12 @@ @@ -147,10 +147,12 @@ if(MINGW)
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif(MINGW) endif(MINGW)
-add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
-set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) -set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
-set_target_properties(zlib PROPERTIES SOVERSION 1) -set_target_properties(zlib PROPERTIES SOVERSION 1)
+add_library(zlib ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +add_library(zlib ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
+if (BUILD_SHARED_LIBS) +if (BUILD_SHARED_LIBS)
+ target_sources(zlib PRIVATE ${ZLIB_DLL_SRCS}) + target_sources(zlib PRIVATE ${ZLIB_DLL_SRCS})
+ set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) + set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
@ -19,7 +19,7 @@ diff -u ../zlib-1.2.11/CMakeLists.txt ./CMakeLists.txt
if(NOT CYGWIN) if(NOT CYGWIN)
# This property causes shared libraries on Linux to have the full version # This property causes shared libraries on Linux to have the full version
@@ -201,7 +203,7 @@ @@ -165,7 +167,7 @@ endif()
if(UNIX) if(UNIX)
# On unix-like platforms the library is almost always called libz # On unix-like platforms the library is almost always called libz
@ -28,7 +28,7 @@ diff -u ../zlib-1.2.11/CMakeLists.txt ./CMakeLists.txt
if(NOT APPLE) if(NOT APPLE)
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
endif() endif()
@@ -211,7 +213,7 @@ @@ -175,7 +177,7 @@ elseif(BUILD_SHARED_LIBS AND WIN32)
endif() endif()
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
@ -37,15 +37,3 @@ diff -u ../zlib-1.2.11/CMakeLists.txt ./CMakeLists.txt
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
Common subdirectories: ../zlib-1.2.11/contrib and ./contrib
Common subdirectories: ../zlib-1.2.11/doc and ./doc
Common subdirectories: ../zlib-1.2.11/examples and ./examples
Common subdirectories: ../zlib-1.2.11/msdos and ./msdos
Common subdirectories: ../zlib-1.2.11/nintendods and ./nintendods
Common subdirectories: ../zlib-1.2.11/old and ./old
Common subdirectories: ../zlib-1.2.11/os400 and ./os400
Common subdirectories: ../zlib-1.2.11/qnx and ./qnx
Common subdirectories: ../zlib-1.2.11/test and ./test
Common subdirectories: ../zlib-1.2.11/watcom and ./watcom
Common subdirectories: ../zlib-1.2.11/win32 and ./win32
Only in ./: ZLIB.patch

10
deps/ZLIB/ZLIB.cmake vendored
View File

@ -1,9 +1,13 @@
set(patch_command git init && ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/0001-Respect-BUILD_SHARED_LIBS.patch)
bambustudio_add_cmake_project(ZLIB bambustudio_add_cmake_project(ZLIB
# GIT_REPOSITORY https://github.com/madler/zlib.git # GIT_REPOSITORY https://github.com/madler/zlib.git
# GIT_TAG v1.2.11 # GIT_TAG v1.2.11
URL https://github.com/madler/zlib/archive/refs/tags/v1.2.11.zip #URL https://github.com/madler/zlib/archive/refs/tags/v1.2.11.zip
URL_HASH SHA256=f5cc4ab910db99b2bdbba39ebbdc225ffc2aa04b4057bc2817f1b94b6978cfc3 URL https://github.com/madler/zlib/archive/refs/tags/v1.2.13.zip
PATCH_COMMAND ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/0001-Respect-BUILD_SHARED_LIBS.patch #URL_HASH SHA256=f5cc4ab910db99b2bdbba39ebbdc225ffc2aa04b4057bc2817f1b94b6978cfc3
URL_HASH SHA256=c2856951bbf30e30861ace3765595d86ba13f2cf01279d901f6c62258c57f4ff
PATCH_COMMAND ${patch_command}
CMAKE_ARGS CMAKE_ARGS
-DSKIP_INSTALL_FILES=ON # Prevent installation of man pages et al. -DSKIP_INSTALL_FILES=ON # Prevent installation of man pages et al.
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON