├── .gitignore
├── .gitattributes
├── upstream.txt
├── upstream
├── fuzz
│ ├── uri.options
│ ├── xml.options
│ ├── html.options
│ ├── regexp.options
│ ├── schema.options
│ ├── xpath.options
│ ├── valid.options
│ ├── xinclude.options
│ ├── .gitignore
│ ├── README
│ ├── regexp.c
│ ├── schema.c
│ ├── xpath.c
│ ├── uri.c
│ ├── xpath.dict
│ ├── schema.dict
│ ├── xinclude.c
│ ├── fuzz.h
│ ├── html.c
│ ├── xml.dict
│ ├── xml.c
│ └── valid.c
├── python
│ ├── tests
│ │ ├── test.dtd
│ │ ├── tst.xml
│ │ ├── valid.xml
│ │ ├── indexes.py
│ │ ├── reader.py
│ │ ├── invalid.xml
│ │ ├── inbuf.py
│ │ ├── xpathns.py
│ │ ├── tst.py
│ │ ├── dtdvalid.py
│ │ ├── reader8.py
│ │ ├── regexp.py
│ │ ├── push.py
│ │ ├── attribs.py
│ │ ├── tstmem.py
│ │ ├── resolver.py
│ │ ├── tstURI.py
│ │ ├── error.py
│ │ ├── xpathext.py
│ │ ├── xpathleak.py
│ │ ├── reader4.py
│ │ ├── relaxng.py
│ │ ├── xpath.py
│ │ ├── validDTD.py
│ │ ├── cutnpaste.py
│ │ ├── readererr.py
│ │ ├── schema.py
│ │ ├── reader5.py
│ │ ├── ctxterror.py
│ │ ├── xpathret.py
│ │ ├── compareNodes.py
│ │ ├── tstxpath.py
│ │ ├── pushSAX.py
│ │ ├── build.py
│ │ ├── nsdel.py
│ │ ├── pushSAXhtml.py
│ │ ├── Makefile.am
│ │ ├── validate.py
│ │ ├── validRNG.py
│ │ ├── reader7.py
│ │ ├── validSchemas.py
│ │ ├── thread2.py
│ │ ├── readernext.py
│ │ ├── walker.py
│ │ ├── tstLastError.py
│ │ └── reader6.py
│ ├── drv_libxml2.py
│ ├── .gitignore
│ ├── README
│ └── Makefile.am
├── .gitattributes
├── xstc
│ └── .gitignore
├── os400
│ ├── libxmlrpg
│ │ ├── c14n.rpgle
│ │ ├── xmlexports.rpgle
│ │ ├── xmlTypesC.rpgle
│ │ ├── xmlstdarg.rpgle
│ │ ├── xmlmodule.rpgle
│ │ └── threads.rpgle
│ ├── iconv
│ │ ├── bldcsndfa
│ │ │ └── ccsid_mibenum.dtd
│ │ ├── iconv.h
│ │ └── README.iconv
│ ├── dlfcn
│ │ └── dlfcn.h
│ ├── make-bldcsndfa.sh
│ ├── transcode.h
│ ├── wrappers.h
│ ├── make-include.sh
│ ├── make.sh
│ └── make-rpg.sh
├── include
│ ├── Makefile.am
│ ├── private
│ │ ├── xpath.h
│ │ ├── memory.h
│ │ ├── string.h
│ │ ├── globals.h
│ │ ├── regexp.h
│ │ ├── xinclude.h
│ │ ├── dict.h
│ │ ├── html.h
│ │ ├── Makefile.am
│ │ ├── save.h
│ │ ├── enc.h
│ │ ├── io.h
│ │ ├── tree.h
│ │ ├── entities.h
│ │ ├── error.h
│ │ ├── xzlib.h
│ │ ├── parser.h
│ │ ├── threads.h
│ │ └── buf.h
│ ├── win32config.h
│ ├── libxml
│ │ ├── Makefile.am
│ │ ├── xmlexports.h
│ │ ├── xmlmodule.h
│ │ ├── dict.h
│ │ ├── nanohttp.h
│ │ ├── threads.h
│ │ ├── xmlsave.h
│ │ ├── uri.h
│ │ └── pattern.h
│ └── wsockcompat.h
├── example
│ ├── Makefile.am
│ └── gjobs.xml
├── .gitlab-ci
│ ├── test.sh
│ ├── llvm-symbolizer
│ ├── setup_mingw.sh
│ ├── test_cmake.sh
│ ├── Dockerfile
│ └── Test-Msvc.ps1
├── testdso.c
├── .editorconfig
├── libxml-2.0-uninstalled.pc.in
├── libxml-2.0.pc.in
├── libxml.m4
├── testOOMlib.h
├── m4
│ ├── ac_try_compile2.m4
│ ├── ax_require_defined.m4
│ ├── ax_append_flag.m4
│ ├── ax_append_link_flags.m4
│ └── ax_check_link_flag.m4
├── .gitignore
├── global.data
├── win32
│ └── libxml2.rc
├── Copyright
├── dbgenattr.pl
├── dbgen.pl
├── libxml.h
├── libxml2.doap
├── MAINTAINERS.md
├── testModule.c
├── trionan.h
├── xml2-config.in
└── autogen.sh
├── .envrc
├── shell.nix
├── override
├── config
│ ├── win32
│ │ └── config.h
│ └── posix
│ │ └── config.h
└── include
│ └── libxml
│ └── xmlversion.h
├── update.sh
├── .github
└── workflows
│ └── build.yml
├── verify.sh
├── LICENSE
├── flake.nix
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | zig-cache
2 | zig-out
3 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | upstream/* linguist-vendored
2 |
--------------------------------------------------------------------------------
/upstream.txt:
--------------------------------------------------------------------------------
1 | 58de9d31da4d0e8cb6bcf7f5e99714f9df2c4411
2 |
--------------------------------------------------------------------------------
/upstream/fuzz/uri.options:
--------------------------------------------------------------------------------
1 | [libfuzzer]
2 | timeout = 2
3 |
--------------------------------------------------------------------------------
/upstream/fuzz/xml.options:
--------------------------------------------------------------------------------
1 | [libfuzzer]
2 | timeout = 20
3 |
--------------------------------------------------------------------------------
/upstream/python/tests/test.dtd:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/upstream/.gitattributes:
--------------------------------------------------------------------------------
1 | /result/** -text
2 | /test/** -text
3 |
--------------------------------------------------------------------------------
/upstream/fuzz/html.options:
--------------------------------------------------------------------------------
1 | [libfuzzer]
2 | timeout = 10
3 |
--------------------------------------------------------------------------------
/upstream/fuzz/regexp.options:
--------------------------------------------------------------------------------
1 | [libfuzzer]
2 | timeout = 5
3 |
--------------------------------------------------------------------------------
/upstream/fuzz/schema.options:
--------------------------------------------------------------------------------
1 | [libfuzzer]
2 | timeout = 20
3 |
--------------------------------------------------------------------------------
/upstream/fuzz/xpath.options:
--------------------------------------------------------------------------------
1 | [libfuzzer]
2 | timeout = 20
3 |
--------------------------------------------------------------------------------
/upstream/python/tests/tst.xml:
--------------------------------------------------------------------------------
1 | bar
2 |
--------------------------------------------------------------------------------
/upstream/xstc/.gitignore:
--------------------------------------------------------------------------------
1 | /*-test.py
2 | /Tests
3 | /xsts-*.tar.gz
4 |
--------------------------------------------------------------------------------
/upstream/fuzz/valid.options:
--------------------------------------------------------------------------------
1 | [libfuzzer]
2 | dict = xml.dict
3 | timeout = 20
4 |
--------------------------------------------------------------------------------
/upstream/fuzz/xinclude.options:
--------------------------------------------------------------------------------
1 | [libfuzzer]
2 | dict = xml.dict
3 | timeout = 20
4 |
--------------------------------------------------------------------------------
/upstream/python/tests/valid.xml:
--------------------------------------------------------------------------------
1 |
3 | ]>
4 |
5 |
--------------------------------------------------------------------------------
/upstream/python/drv_libxml2.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitchellh/zig-build-libxml2/HEAD/upstream/python/drv_libxml2.py
--------------------------------------------------------------------------------
/upstream/python/tests/indexes.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitchellh/zig-build-libxml2/HEAD/upstream/python/tests/indexes.py
--------------------------------------------------------------------------------
/upstream/python/tests/reader.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitchellh/zig-build-libxml2/HEAD/upstream/python/tests/reader.py
--------------------------------------------------------------------------------
/upstream/os400/libxmlrpg/c14n.rpgle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitchellh/zig-build-libxml2/HEAD/upstream/os400/libxmlrpg/c14n.rpgle
--------------------------------------------------------------------------------
/upstream/python/tests/invalid.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | ]>
6 |
7 |
--------------------------------------------------------------------------------
/upstream/fuzz/.gitignore:
--------------------------------------------------------------------------------
1 | corpus/
2 | genSeed
3 | html
4 | regexp
5 | schema
6 | seed/
7 | testFuzzer
8 | uri
9 | valid
10 | xinclude
11 | xml
12 | xpath
13 |
--------------------------------------------------------------------------------
/upstream/include/Makefile.am:
--------------------------------------------------------------------------------
1 | ## Process this file with automake to produce Makefile.in
2 | SUBDIRS=libxml private
3 |
4 | EXTRA_DIST = win32config.h wsockcompat.h
5 |
6 |
--------------------------------------------------------------------------------
/.envrc:
--------------------------------------------------------------------------------
1 | # If we are a computer with nix-shell available, then use that to setup
2 | # the build environment with exactly what we need.
3 | if has nix; then
4 | use nix
5 | fi
6 |
--------------------------------------------------------------------------------
/upstream/include/private/xpath.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_XPATH_H_PRIVATE__
2 | #define XML_XPATH_H_PRIVATE__
3 |
4 | XML_HIDDEN void
5 | xmlInitXPathInternal(void);
6 |
7 | #endif /* XML_XPATH_H_PRIVATE__ */
8 |
--------------------------------------------------------------------------------
/upstream/python/.gitignore:
--------------------------------------------------------------------------------
1 | /gen_prog
2 | /libxml2-export.c
3 | /libxml2-py.c
4 | /libxml2-py.h
5 | /libxml2.py
6 | /libxml2class.py
7 | /libxml2class.txt
8 | /setup.py
9 | /tests/tmp.xml
10 |
--------------------------------------------------------------------------------
/upstream/example/Makefile.am:
--------------------------------------------------------------------------------
1 | check_PROGRAMS = gjobread
2 |
3 | AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
4 | LDADD = $(top_builddir)/libxml2.la
5 |
6 | gjobread_SOURCES=gjobread.c
7 |
--------------------------------------------------------------------------------
/upstream/.gitlab-ci/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 |
5 | cd libxml2-build
6 | sh ../autogen.sh $BASE_CONFIG $CONFIG
7 | make -j$(nproc) V=1 CFLAGS="$CFLAGS -Werror"
8 | make CFLAGS="$CFLAGS -Werror" check
9 |
--------------------------------------------------------------------------------
/upstream/testdso.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #define IN_LIBXML
4 | #include "libxml/xmlexports.h"
5 |
6 | XMLPUBFUN int hello_world(void);
7 |
8 | int hello_world(void)
9 | {
10 | printf("Success!\n");
11 | return 0;
12 | }
13 |
--------------------------------------------------------------------------------
/upstream/include/private/memory.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_MEMORY_H_PRIVATE__
2 | #define XML_MEMORY_H_PRIVATE__
3 |
4 | XML_HIDDEN void
5 | xmlInitMemoryInternal(void);
6 | XML_HIDDEN void
7 | xmlCleanupMemoryInternal(void);
8 |
9 | #endif /* XML_MEMORY_H_PRIVATE__ */
10 |
--------------------------------------------------------------------------------
/upstream/include/private/string.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_STRING_H_PRIVATE__
2 | #define XML_STRING_H_PRIVATE__
3 |
4 | #include
5 |
6 | XML_HIDDEN xmlChar *
7 | xmlEscapeFormatString(xmlChar **msg);
8 |
9 | #endif /* XML_STRING_H_PRIVATE__ */
10 |
--------------------------------------------------------------------------------
/upstream/include/private/globals.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_GLOBALS_H_PRIVATE__
2 | #define XML_GLOBALS_H_PRIVATE__
3 |
4 | XML_HIDDEN void
5 | xmlInitGlobalsInternal(void);
6 | XML_HIDDEN void
7 | xmlCleanupGlobalsInternal(void);
8 |
9 | #endif /* XML_GLOBALS_H_PRIVATE__ */
10 |
--------------------------------------------------------------------------------
/upstream/include/private/regexp.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_REGEXP_H_PRIVATE__
2 | #define XML_REGEXP_H_PRIVATE__
3 |
4 | #include
5 |
6 | XML_HIDDEN void
7 | xmlAutomataSetFlags(xmlAutomataPtr am, int flags);
8 |
9 | #endif /* XML_REGEXP_H_PRIVATE__ */
10 |
--------------------------------------------------------------------------------
/upstream/include/private/xinclude.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_INCLUDE_H_PRIVATE__
2 | #define XML_INCLUDE_H_PRIVATE__
3 |
4 | #include
5 |
6 | XML_HIDDEN int
7 | xmlXIncludeSetStreamingMode(xmlXIncludeCtxtPtr ctxt, int mode);
8 |
9 | #endif /* XML_INCLUDE_H_PRIVATE__ */
10 |
--------------------------------------------------------------------------------
/upstream/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig : http://EditorConfig.org
2 |
3 | root = true
4 |
5 | [Makefile*]
6 | indent_style = tab
7 |
8 | [CMakeLists.txt]
9 | indent_style = tab
10 | indent_size = 4
11 |
12 | [*.{c,h}]
13 | indent_style = space
14 | indent_size = 4
15 | tab_width = 8
16 |
--------------------------------------------------------------------------------
/upstream/include/private/dict.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_DICT_H_PRIVATE__
2 | #define XML_DICT_H_PRIVATE__
3 |
4 | XML_HIDDEN int
5 | __xmlInitializeDict(void);
6 | XML_HIDDEN void
7 | xmlCleanupDictInternal(void);
8 | XML_HIDDEN int
9 | __xmlRandom(void);
10 |
11 | #endif /* XML_DICT_H_PRIVATE__ */
12 |
--------------------------------------------------------------------------------
/upstream/include/private/html.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_HTML_H_PRIVATE__
2 | #define XML_HTML_H_PRIVATE__
3 |
4 | #include
5 |
6 | #ifdef LIBXML_HTML_ENABLED
7 |
8 | XML_HIDDEN void
9 | __htmlParseContent(void *ctx);
10 |
11 | #endif /* LIBXML_HTML_ENABLED */
12 |
13 | #endif /* XML_HTML_H_PRIVATE__ */
14 |
15 |
--------------------------------------------------------------------------------
/upstream/include/private/Makefile.am:
--------------------------------------------------------------------------------
1 | EXTRA_DIST = \
2 | buf.h \
3 | dict.h \
4 | enc.h \
5 | entities.h \
6 | error.h \
7 | globals.h \
8 | html.h \
9 | io.h \
10 | memory.h \
11 | parser.h \
12 | regexp.h \
13 | save.h \
14 | string.h \
15 | threads.h \
16 | tree.h \
17 | xinclude.h \
18 | xpath.h \
19 | xzlib.h
20 |
--------------------------------------------------------------------------------
/upstream/libxml-2.0-uninstalled.pc.in:
--------------------------------------------------------------------------------
1 | prefix=
2 | exec_prefix=
3 | libdir=${pcfiledir}
4 | includedir=${pcfiledir}/include
5 | modules=@WITH_MODULES@
6 |
7 | Name: libXML
8 | Version: @VERSION@
9 | Description: libXML library version2.
10 | Requires:
11 | Libs: -L${libdir} @XML_LIBS@
12 | Libs.private: @XML_PRIVATE_LIBS@ @LIBS@
13 | Cflags: @XML_INCLUDEDIR@ @XML_CFLAGS@
14 |
--------------------------------------------------------------------------------
/upstream/libxml-2.0.pc.in:
--------------------------------------------------------------------------------
1 | prefix=@prefix@
2 | exec_prefix=@exec_prefix@
3 | libdir=@libdir@
4 | includedir=@includedir@
5 | modules=@WITH_MODULES@
6 |
7 | Name: libXML
8 | Version: @VERSION@
9 | Description: libXML library version2.
10 | Requires:
11 | Libs: -L${libdir} @XML_LIBS@
12 | Libs.private: @XML_PRIVATE_LIBS@ @LIBS@
13 | Cflags: @XML_INCLUDEDIR@ @XML_CFLAGS@
14 |
--------------------------------------------------------------------------------
/shell.nix:
--------------------------------------------------------------------------------
1 | (import
2 | (
3 | let
4 | flake-compat = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.flake-compat;
5 | in
6 | fetchTarball {
7 | url = "https://github.com/edolstra/flake-compat/archive/${flake-compat.locked.rev}.tar.gz";
8 | sha256 = flake-compat.locked.narHash;
9 | }
10 | )
11 | {src = ./.;})
12 | .shellNix
13 |
--------------------------------------------------------------------------------
/upstream/.gitlab-ci/llvm-symbolizer:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Newer versions of llvm-symbolizer require libxml2 themselves. Running
4 | # a test program with LD_LIBRARY_PATH set to .libs makes llvm-symbolizer
5 | # pick up the tested development version of libxml2 which breaks
6 | # completely if the build is instrumented with ASan. This wrapper script
7 | # invokes llvm-symbolizer with an empty LD_LIBRARY_PATH.
8 |
9 | LD_LIBRARY_PATH='' llvm-symbolizer "$@"
10 |
--------------------------------------------------------------------------------
/upstream/.gitlab-ci/setup_mingw.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | pacman --noconfirm -Syu
4 |
5 | prefix=
6 | if [ -n "$MINGW_PACKAGE_PREFIX" ]; then
7 | prefix="${MINGW_PACKAGE_PREFIX}-"
8 | fi
9 | for module in libiconv python xz zlib "$@"; do
10 | pacman --noconfirm -S --needed ${prefix}$module
11 | done
12 |
13 | if [ ! -e libxml2-build/xmlconf ]; then
14 | mkdir -p libxml2-build
15 | wget https://www.w3.org/XML/Test/xmlts20080827.tar -O - |
16 | tar -x -C libxml2-build
17 | fi
18 |
--------------------------------------------------------------------------------
/upstream/fuzz/README:
--------------------------------------------------------------------------------
1 | libFuzzer instructions for libxml2
2 | ==================================
3 |
4 | Set compiler and options:
5 |
6 | export CC=clang
7 | export CFLAGS="-g -fsanitize=fuzzer-no-link,address,undefined \
8 | -fno-sanitize-recover=all \
9 | -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION"
10 |
11 | Build libxml2 with instrumentation:
12 |
13 | ./configure --without-python
14 | make
15 |
16 | Run fuzzers:
17 |
18 | make -C fuzz fuzz-xml
19 |
20 |
--------------------------------------------------------------------------------
/upstream/os400/iconv/bldcsndfa/ccsid_mibenum.dtd:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
15 |
16 |
--------------------------------------------------------------------------------
/upstream/libxml.m4:
--------------------------------------------------------------------------------
1 | dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
2 | dnl Test for XML, and define XML_CPPFLAGS and XML_LIBS
3 | dnl
4 | AC_DEFUN([AM_PATH_XML2],[
5 | m4_warn([obsolete], [AM_PATH_XML2 is deprecated, use PKG_CHECK_MODULES instead])
6 | AC_REQUIRE([PKG_PROG_PKG_CONFIG])
7 |
8 | verdep=ifelse([$1], [], [], [">= $1"])
9 | PKG_CHECK_MODULES(XML, [libxml-2.0 $verdep], [$2], [$3])
10 |
11 | XML_CPPFLAGS=$XML_CFLAGS
12 | AC_SUBST(XML_CPPFLAGS)
13 | AC_SUBST(XML_LIBS)
14 | ])
15 |
--------------------------------------------------------------------------------
/override/config/win32/config.h:
--------------------------------------------------------------------------------
1 | #ifndef __LIBXML_WIN32_CONFIG__
2 | #define __LIBXML_WIN32_CONFIG__
3 |
4 | #define SEND_ARG2_CAST
5 | #define GETHOSTBYNAME_ARG_CAST
6 |
7 | #define HAVE_SYS_STAT_H
8 | #define HAVE_STAT
9 | #define HAVE_FCNTL_H
10 |
11 | #if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER >= 1600)
12 | #define HAVE_STDINT_H
13 | #endif
14 |
15 | #if defined(_MSC_VER) && _MSC_VER < 1900
16 | #define snprintf _snprintf
17 | #define vsnprintf _vsnprintf
18 | #endif
19 |
20 | #endif /* __LIBXML_WIN32_CONFIG__ */
21 |
--------------------------------------------------------------------------------
/upstream/include/private/save.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_SAVE_H_PRIVATE__
2 | #define XML_SAVE_H_PRIVATE__
3 |
4 | #include
5 | #include
6 |
7 | #ifdef LIBXML_OUTPUT_ENABLED
8 |
9 | XML_HIDDEN void
10 | xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc,
11 | xmlAttrPtr attr, const xmlChar * string);
12 | XML_HIDDEN void
13 | xmlNsListDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur);
14 |
15 | #endif /* LIBXML_OUTPUT_ENABLED */
16 |
17 | #endif /* XML_SAVE_H_PRIVATE__ */
18 |
19 |
--------------------------------------------------------------------------------
/update.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Update the upstream to a specific commit. If this fails then it may leave
4 | # your working tree in a bad state. You can recover by using Git to reset:
5 | # git reset --hard HEAD.
6 | set -e
7 |
8 | ref=${1:-HEAD}
9 | out=${2:-upstream}
10 |
11 | rm -rf $out
12 | git clone https://github.com/GNOME/libxml2.git $out
13 | git -C $out checkout $ref
14 | git -C $out rev-parse HEAD > ${out}.txt
15 | rm -rf $out/.git
16 |
17 | # Lower file size
18 | rm -rf $out/doc
19 | rm -rf $out/result
20 | rm -rf $out/test
21 |
--------------------------------------------------------------------------------
/upstream/include/win32config.h:
--------------------------------------------------------------------------------
1 | #ifndef __LIBXML_WIN32_CONFIG__
2 | #define __LIBXML_WIN32_CONFIG__
3 |
4 | #define HAVE_SYS_STAT_H
5 | #define HAVE_STAT
6 | #define HAVE_FCNTL_H
7 |
8 | #if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER >= 1600)
9 | #define HAVE_STDINT_H
10 | #endif
11 |
12 | #if defined(_MSC_VER)
13 | #if _MSC_VER < 1900
14 | #define snprintf _snprintf
15 | #endif
16 | #if _MSC_VER < 1500
17 | #define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
18 | #endif
19 | #endif
20 |
21 | #endif /* __LIBXML_WIN32_CONFIG__ */
22 |
23 |
--------------------------------------------------------------------------------
/upstream/.gitlab-ci/test_cmake.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 |
5 | CFLAGS="-Werror $CFLAGS" \
6 | cmake "$@" \
7 | -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS \
8 | -DCMAKE_INSTALL_PREFIX=libxml2-install \
9 | -DCMAKE_BUILD_TYPE=RelWithDebInfo \
10 | -S . -B libxml2-build
11 | cmake --build libxml2-build --target install
12 |
13 | (cd libxml2-build && ctest -VV)
14 |
15 | mkdir -p libxml2-install/share/libxml2
16 | cp Copyright libxml2-install/share/libxml2
17 | (cd libxml2-install &&
18 | tar -czf ../libxml2-$CI_COMMIT_SHORT_SHA-$SUFFIX.tar.gz *)
19 |
--------------------------------------------------------------------------------
/upstream/include/private/enc.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_ENC_H_PRIVATE__
2 | #define XML_ENC_H_PRIVATE__
3 |
4 | #include
5 | #include
6 |
7 | XML_HIDDEN void
8 | xmlInitEncodingInternal(void);
9 |
10 | XML_HIDDEN int
11 | xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
12 | int *outlen, const unsigned char *in, int *inlen, int flush);
13 | XML_HIDDEN int
14 | xmlCharEncInput(xmlParserInputBufferPtr input, int flush);
15 | XML_HIDDEN int
16 | xmlCharEncOutput(xmlOutputBufferPtr output, int init);
17 |
18 | #endif /* XML_ENC_H_PRIVATE__ */
19 |
--------------------------------------------------------------------------------
/upstream/include/private/io.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_IO_H_PRIVATE__
2 | #define XML_IO_H_PRIVATE__
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | XML_HIDDEN void
9 | __xmlIOErr(int domain, int code, const char *extra);
10 | XML_HIDDEN void
11 | __xmlLoaderErr(void *ctx, const char *msg,
12 | const char *filename) LIBXML_ATTR_FORMAT(2,0);
13 |
14 | #ifdef LIBXML_OUTPUT_ENABLED
15 | XML_HIDDEN xmlOutputBufferPtr
16 | xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder);
17 | #endif
18 |
19 | #endif /* XML_IO_H_PRIVATE__ */
20 |
--------------------------------------------------------------------------------
/upstream/.gitlab-ci/Dockerfile:
--------------------------------------------------------------------------------
1 | # The image is also used for libxslt, that's why we need git and
2 | # libgcrypt-dev.
3 |
4 | FROM ubuntu:22.10
5 | ENV DEBIAN_FRONTEND=noninteractive
6 | RUN apt-get update && \
7 | apt-get upgrade -y && \
8 | apt-get install -y --no-install-recommends \
9 | curl git ca-certificates \
10 | autoconf automake libtool pkg-config \
11 | make gcc clang llvm \
12 | zlib1g-dev liblzma-dev libgcrypt-dev \
13 | python2-dev python3-dev \
14 | cmake
15 | WORKDIR /tests
16 | RUN curl https://www.w3.org/XML/Test/xmlts20080827.tar.gz |tar xz
17 |
--------------------------------------------------------------------------------
/override/include/libxml/xmlversion.h:
--------------------------------------------------------------------------------
1 | // This recreates parts of the generated libxml/xmlversion.h.in that we need
2 | // to build libxml2 without actually templating the header file. We define most
3 | // of the defines in that file using flags to the compiler in libxml2.zig
4 |
5 | #ifndef __XML_VERSION_H__
6 | #define __XML_VERSION_H__
7 |
8 | #include
9 |
10 | // We are not GCC.
11 | #define XML_IGNORE_FPTR_CAST_WARNINGS
12 | #define XML_POP_WARNINGS
13 | #define LIBXML_ATTR_FORMAT(fmt,args)
14 | #define LIBXML_ATTR_ALLOC_SIZE(x)
15 | #define ATTRIBUTE_UNUSED
16 | #define XML_DEPRECATED
17 |
18 | #endif
19 |
--------------------------------------------------------------------------------
/upstream/python/tests/inbuf.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | import libxml2
4 | try:
5 | import StringIO
6 | str_io = StringIO.StringIO
7 | except:
8 | import io
9 | str_io = io.StringIO
10 |
11 | # Memory debug specific
12 | libxml2.debugMemory(1)
13 |
14 | i = 0
15 | while i < 5000:
16 | f = str_io("foobar")
17 | buf = libxml2.inputBuffer(f)
18 | i = i + 1
19 |
20 | del f
21 | del buf
22 |
23 | # Memory debug specific
24 | libxml2.cleanupParser()
25 | if libxml2.debugMemory(1) == 0:
26 | print("OK")
27 | else:
28 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
29 |
30 |
--------------------------------------------------------------------------------
/upstream/include/private/tree.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_TREE_H_PRIVATE__
2 | #define XML_TREE_H_PRIVATE__
3 |
4 | /*
5 | * Internal variable indicating if a callback has been registered for
6 | * node creation/destruction. It avoids spending a lot of time in locking
7 | * function while checking if the callback exists.
8 | */
9 | XML_HIDDEN extern int
10 | __xmlRegisterCallbacks;
11 |
12 | XML_HIDDEN xmlNodePtr
13 | xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
14 | int extended);
15 | XML_HIDDEN xmlNodePtr
16 | xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent);
17 |
18 | #endif /* XML_TREE_H_PRIVATE__ */
19 |
--------------------------------------------------------------------------------
/upstream/python/tests/xpathns.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | import libxml2
4 |
5 | expect=' xmlns:a="urn:whatevar"'
6 |
7 | # Memory debug specific
8 | libxml2.debugMemory(1)
9 |
10 | d = libxml2.parseDoc("")
11 | res=""
12 | for n in d.xpathEval("//namespace::*"):
13 | res = res + n.serialize()
14 | del n
15 | d.freeDoc()
16 |
17 | if res != expect:
18 | print("test5 failed: unexpected output")
19 | print(res)
20 | del res
21 | del d
22 | # Memory debug specific
23 | libxml2.cleanupParser()
24 |
25 | if libxml2.debugMemory(1) == 0:
26 | print("OK")
27 | else:
28 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
29 |
--------------------------------------------------------------------------------
/upstream/testOOMlib.h:
--------------------------------------------------------------------------------
1 | #ifndef TEST_OOM_LIB_H
2 | #define TEST_OOM_LIB_H
3 |
4 | #include
5 |
6 | void* test_malloc (size_t bytes);
7 | void* test_realloc (void *memory,
8 | size_t bytes);
9 | void test_free (void *memory);
10 | char* test_strdup (const char *str);
11 |
12 | /* returns true on success */
13 | typedef int (* TestMemoryFunction) (void *data);
14 |
15 | /* returns true on success */
16 | int test_oom_handling (TestMemoryFunction func,
17 | void *data);
18 |
19 | /* get number of blocks leaked */
20 | int test_get_malloc_blocks_outstanding (void);
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------
/upstream/os400/libxmlrpg/xmlexports.rpgle:
--------------------------------------------------------------------------------
1 | * Summary: macros for marking symbols as exportable/importable.
2 | * Description: macros for marking symbols as exportable/importable.
3 | *
4 | * Copy: See Copyright for the status of this software.
5 | *
6 | * Author: Patrick Monnerat , DATASPHERE S.A.
7 |
8 | /if not defined(XML_EXPORTS_H__)
9 | /define XML_EXPORTS_H__
10 |
11 | * The definition in the original C header file are not applicable to
12 | * ILE/RPG.
13 | * Therefore this file is intentionally empty.
14 |
15 | /endif XML_EXPORTS_H__
16 |
--------------------------------------------------------------------------------
/upstream/python/tests/tst.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | import libxml2
4 |
5 | # Memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | doc = libxml2.parseFile("tst.xml")
9 | if doc.name != "tst.xml":
10 | print("doc.name failed")
11 | sys.exit(1)
12 | root = doc.children
13 | if root.name != "doc":
14 | print("root.name failed")
15 | sys.exit(1)
16 | child = root.children
17 | if child.name != "foo":
18 | print("child.name failed")
19 | sys.exit(1)
20 | doc.freeDoc()
21 |
22 | # Memory debug specific
23 | libxml2.cleanupParser()
24 | if libxml2.debugMemory(1) == 0:
25 | print("OK")
26 | else:
27 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
28 |
--------------------------------------------------------------------------------
/upstream/include/private/entities.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_ENTITIES_H_PRIVATE__
2 | #define XML_ENTITIES_H_PRIVATE__
3 |
4 | #include
5 | #include
6 |
7 | /*
8 | * Entity flags
9 | *
10 | * XML_ENT_PARSED: The entity was parsed and `children` points to the
11 | * content.
12 | * XML_ENT_CHECKED: The entity was checked for loops.
13 | */
14 | #define XML_ENT_PARSED (1<<0)
15 | #define XML_ENT_CHECKED (1<<1)
16 | #define XML_ENT_EXPANDING (1<<2)
17 | #define XML_ENT_CHECKED_LT (1<<3)
18 | #define XML_ENT_CONTAINS_LT (1<<4)
19 |
20 | XML_HIDDEN xmlChar *
21 | xmlEncodeAttributeEntities(xmlDocPtr doc, const xmlChar *input);
22 |
23 | #endif /* XML_ENTITIES_H_PRIVATE__ */
24 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 | on:
3 | - push
4 | - pull_request
5 | jobs:
6 | x86_64-linux:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - name: Checkout code
10 | uses: actions/checkout@v3
11 | - uses: cachix/install-nix-action@v22
12 | with:
13 | nix_path: nixpkgs=channel:nixos-unstable
14 | - run: nix flake check
15 | - run: nix develop -c zig build
16 |
17 | x86_64-macos:
18 | runs-on: macos-12
19 | steps:
20 | - name: Checkout code
21 | uses: actions/checkout@v3
22 | - uses: cachix/install-nix-action@v22
23 | with:
24 | nix_path: nixpkgs=channel:nixos-unstable
25 | - run: nix flake check
26 | - run: nix develop -c zig build
27 |
--------------------------------------------------------------------------------
/upstream/python/tests/dtdvalid.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import libxml2
3 | import sys
4 |
5 | # Memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | dtd=""""""
9 | instance="""
10 | """
11 |
12 | dtd = libxml2.parseDTD(None, 'test.dtd')
13 | ctxt = libxml2.newValidCtxt()
14 | doc = libxml2.parseDoc(instance)
15 | ret = doc.validateDtd(ctxt, dtd)
16 | if ret != 1:
17 | print("error doing DTD validation")
18 | sys.exit(1)
19 |
20 | doc.freeDoc()
21 | dtd.freeDtd()
22 | del dtd
23 | del ctxt
24 |
25 | # Memory debug specific
26 | libxml2.cleanupParser()
27 | if libxml2.debugMemory(1) == 0:
28 | print("OK")
29 | else:
30 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
31 |
32 |
--------------------------------------------------------------------------------
/verify.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #
3 | # Verify the contents of the upstream. This compares to the "upstream.txt"
4 | # file for the upstream ref.
5 | set -e
6 |
7 | # Checksum a directory. This ignores timestamps and user/group info.
8 | function checksum {
9 | tar -C $1 \
10 | --sort=name \
11 | --mtime='1970-12-31 16:00:00' \
12 | --group=0 --owner=0 --numeric-owner \
13 | -cf - . | shasum -a256
14 | }
15 |
16 | out=upstream
17 | ref=$(cat ${out}.txt | tr -d "[:space:]")
18 | tmp=$(mktemp -d)
19 |
20 | ./update.sh $ref $tmp
21 | rm -f ${tmp}.txt
22 |
23 | actual=$(checksum $out)
24 | expected=$(checksum $tmp)
25 | if [ "$actual" != "$expected" ]; then
26 | echo "Upstream verification failed!"
27 | echo "Expected: $expected"
28 | echo "Actual: $actual"
29 | exit 1
30 | fi
31 |
32 | exit 0
33 |
--------------------------------------------------------------------------------
/upstream/os400/dlfcn/dlfcn.h:
--------------------------------------------------------------------------------
1 | /**
2 | *** dlopen(), dlclose() dlsym(), dlerror() emulation for OS/400.
3 | ***
4 | *** See Copyright for the status of this software.
5 | ***
6 | *** Author: Patrick Monnerat , DATASPHERE S.A.
7 | **/
8 |
9 | #ifndef _DLFCN_H_
10 | #define _DLFCN_H_
11 |
12 |
13 | /**
14 | *** Flags for dlopen().
15 | *** Ignored for OS400.
16 | **/
17 |
18 | #define RTLD_LAZY 000
19 | #define RTLD_NOW 001
20 | #define RTLD_GLOBAL 010
21 |
22 |
23 | /**
24 | *** Prototypes.
25 | **/
26 |
27 | extern void * dlopen(const char * filename, int flag);
28 | extern void * dlsym(void * handle, const char * symbol);
29 | extern const char * dlerror(void);
30 | extern int dlclose(void * handle);
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/upstream/python/tests/reader8.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # this tests the entities substitutions with the XmlTextReader interface
4 | #
5 | import sys
6 | import libxml2
7 |
8 | # Memory debug specific
9 | libxml2.debugMemory(1)
10 |
11 | #
12 | # Parse a document testing the Close() API
13 | #
14 | docstr="""
15 |
16 | - 100
17 | """
18 |
19 | reader = libxml2.readerForDoc(docstr, "test1", None, 0)
20 | ret = reader.Read()
21 | ret = reader.Read()
22 | ret = reader.Close()
23 |
24 | if ret != 0:
25 | print("Error closing the document test1")
26 | sys.exit(1)
27 |
28 | del reader
29 |
30 | # Memory debug specific
31 | libxml2.cleanupParser()
32 | if libxml2.debugMemory(1) == 0:
33 | print("OK")
34 | else:
35 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
36 |
--------------------------------------------------------------------------------
/upstream/python/tests/regexp.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import libxml2
3 |
4 | # Memory debug specific
5 | libxml2.debugMemory(1)
6 |
7 | re = libxml2.regexpCompile("a|b")
8 | if re.regexpExec("a") != 1:
9 | print("error checking 'a'")
10 | sys.exit(1)
11 | if re.regexpExec("b") != 1:
12 | print("error checking 'b'")
13 | sys.exit(1)
14 | if re.regexpExec("ab") != 0:
15 | print("error checking 'ab'")
16 | sys.exit(1)
17 | if re.regexpExec("") != 0:
18 | print("error checking 'ab'")
19 | sys.exit(1)
20 | if re.regexpIsDeterminist() != 1:
21 | print("error checking determinism")
22 | sys.exit(1)
23 | del re
24 |
25 |
26 | # Memory debug specific
27 | libxml2.cleanupParser()
28 | if libxml2.debugMemory(1) == 0:
29 | print("OK")
30 | else:
31 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
32 |
--------------------------------------------------------------------------------
/upstream/python/tests/push.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | import libxml2
4 |
5 | # Memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | ctxt = libxml2.createPushParser(None, "", 2, 1)
10 | doc = ctxt.doc()
11 | ctxt=None
12 | if doc.name != "test.xml":
13 | print("document name error")
14 | sys.exit(1)
15 | root = doc.children
16 | if root.name != "foo":
17 | print("root element name error")
18 | sys.exit(1)
19 | doc.freeDoc()
20 | i = 10000
21 | while i > 0:
22 | ctxt = libxml2.createPushParser(None, "", 2, 1)
24 | doc = ctxt.doc()
25 | doc.freeDoc()
26 | i = i -1
27 | ctxt=None
28 |
29 | # Memory debug specific
30 | libxml2.cleanupParser()
31 | if libxml2.debugMemory(1) == 0:
32 | print("OK")
33 | else:
34 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
35 |
--------------------------------------------------------------------------------
/upstream/include/private/error.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_ERROR_H_PRIVATE__
2 | #define XML_ERROR_H_PRIVATE__
3 |
4 | #include
5 | #include
6 |
7 | XML_HIDDEN void
8 | __xmlRaiseError(xmlStructuredErrorFunc schannel,
9 | xmlGenericErrorFunc channel, void *data, void *ctx,
10 | void *nod, int domain, int code, xmlErrorLevel level,
11 | const char *file, int line, const char *str1,
12 | const char *str2, const char *str3, int int1, int col,
13 | const char *msg, ...) LIBXML_ATTR_FORMAT(16,17);
14 | XML_HIDDEN void
15 | __xmlSimpleError(int domain, int code, xmlNodePtr node,
16 | const char *msg, const char *extra) LIBXML_ATTR_FORMAT(4,0);
17 | XML_HIDDEN void
18 | xmlGenericErrorDefaultFunc(void *ctx, const char *msg,
19 | ...) LIBXML_ATTR_FORMAT(2,3);
20 |
21 | #endif /* XML_ERROR_H_PRIVATE__ */
22 |
--------------------------------------------------------------------------------
/upstream/include/private/xzlib.h:
--------------------------------------------------------------------------------
1 | /**
2 | * xzlib.h: header for the front end for the transparent support of lzma
3 | * compression at the I/O layer
4 | *
5 | * See Copyright for the status of this software.
6 | *
7 | * Anders F Bjorklund
8 | */
9 |
10 | #ifndef LIBXML2_XZLIB_H
11 | #define LIBXML2_XZLIB_H
12 |
13 | #include
14 |
15 | #ifdef LIBXML_LZMA_ENABLED
16 |
17 | typedef void *xzFile; /* opaque lzma file descriptor */
18 |
19 | XML_HIDDEN xzFile
20 | __libxml2_xzopen(const char *path, const char *mode);
21 | XML_HIDDEN xzFile
22 | __libxml2_xzdopen(int fd, const char *mode);
23 | XML_HIDDEN int
24 | __libxml2_xzread(xzFile file, void *buf, unsigned len);
25 | XML_HIDDEN int
26 | __libxml2_xzclose(xzFile file);
27 | XML_HIDDEN int
28 | __libxml2_xzcompressed(xzFile f);
29 |
30 | #endif /* LIBXML_LZMA_ENABLED */
31 |
32 | #endif /* LIBXML2_XZLIB_H */
33 |
--------------------------------------------------------------------------------
/upstream/m4/ac_try_compile2.m4:
--------------------------------------------------------------------------------
1 | dnl Like AC_TRY_EVAL but also errors out if the compiler generates
2 | dnl _any_ output. Some compilers might issue warnings which we want
3 | dnl to catch.
4 | AC_DEFUN([AC_TRY_EVAL2],
5 | [{ (eval echo configure:__oline__: \"[$]$1\") 1>&AS_MESSAGE_LOG_FD; dnl
6 | (eval [$]$1) 2>&AS_MESSAGE_LOG_FD; _out=`eval [$]$1 2>&1` && test "x$_out" = x; }])
7 |
8 | dnl Like AC_TRY_COMPILE but calls AC_TRY_EVAL2 instead of AC_TRY_EVAL
9 | AC_DEFUN([AC_TRY_COMPILE2],
10 | [cat > conftest.$ac_ext <&AS_MESSAGE_LOG_FD
23 | cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
24 | ifelse([$4], , , [ rm -rf conftest*
25 | $4
26 | ])dnl
27 | fi
28 | rm -f conftest*])
29 |
--------------------------------------------------------------------------------
/upstream/python/tests/attribs.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | import libxml2
4 |
5 | # Memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | #
9 | # Testing XML document serialization
10 | #
11 | doc = libxml2.parseDoc(
12 | """
13 |
15 |
16 |
17 | ]>
18 |
19 | """)
20 | elem = doc.getRootElement()
21 | attr = elem.hasNsProp('attr', 'http://abc.org')
22 | if attr == None or attr.serialize()[:-1] != """""":
23 | print("Failed to find defaulted attribute abc:attr")
24 | sys.exit(1)
25 |
26 | doc.freeDoc()
27 |
28 | # Memory debug specific
29 | libxml2.cleanupParser()
30 | if libxml2.debugMemory(1) == 0:
31 | print("OK")
32 | else:
33 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
34 |
--------------------------------------------------------------------------------
/upstream/python/tests/tstmem.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import libxml2
3 |
4 | try:
5 | import libxml2mod
6 | except ModuleNotFoundError:
7 | from libxmlmods import libxml2mod
8 |
9 | import sys
10 |
11 | def error(msg, data):
12 | pass
13 |
14 | # Memory debug specific
15 | libxml2.debugMemory(1)
16 |
17 | dtd=""""""
18 | instance="""
19 | """
20 |
21 | dtd = libxml2.parseDTD(None, 'test.dtd')
22 | ctxt = libxml2.newValidCtxt()
23 | libxml2mod.xmlSetValidErrors(ctxt._o, error, error)
24 | doc = libxml2.parseDoc(instance)
25 | ret = doc.validateDtd(ctxt, dtd)
26 | if ret != 1:
27 | print("error doing DTD validation")
28 | sys.exit(1)
29 |
30 | doc.freeDoc()
31 | dtd.freeDtd()
32 | del dtd
33 | del ctxt
34 |
35 | # Memory debug specific
36 | libxml2.cleanupParser()
37 | if libxml2.debugMemory(1) == 0:
38 | print("OK")
39 | else:
40 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
41 |
--------------------------------------------------------------------------------
/upstream/os400/iconv/iconv.h:
--------------------------------------------------------------------------------
1 | /**
2 | *** Declarations for the iconv wrappers.
3 | ***
4 | *** See Copyright for the status of this software.
5 | ***
6 | *** Author: Patrick Monnerat , DATASPHERE S.A.
7 | **/
8 |
9 | #ifndef __ICONV_H_
10 | #define __ICONV_H_
11 |
12 | #ifdef __cplusplus
13 | extern "C" {
14 | #endif
15 |
16 | #include /* For size_t. */
17 |
18 |
19 | typedef void * Iconv_t;
20 |
21 |
22 | Iconv_t IconvOpen(const char * tocode, const char * fromcode);
23 | size_t Iconv(Iconv_t cd, char * * inbuf, size_t * inbytesleft,
24 | char * * outbuf, size_t * outbytesleft);
25 | int IconvClose(Iconv_t cd);
26 |
27 |
28 | #ifndef USE_SYSTEM_ICONV
29 | #define iconv_t Iconv_t
30 | #define iconv_open IconvOpen
31 | #define iconv Iconv
32 | #define iconv_close IconvClose
33 | #endif
34 |
35 |
36 | #ifdef __cplusplus
37 | }
38 | #endif
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/upstream/.gitignore:
--------------------------------------------------------------------------------
1 | *.exe
2 | *.o
3 | *.la
4 | *.lo
5 | *.pyc
6 |
7 | # Executables
8 | /example/gjobread
9 | /xmlcatalog
10 | /xmllint
11 |
12 | # Test executables
13 | /runsuite
14 | /runtest
15 | /runxmlconf
16 | /testModule
17 | /testThreads
18 | /testapi
19 | /testchar
20 | /testdict
21 | /testlimits
22 | /testrecurse
23 |
24 | # Tests
25 | /dba100000.xml
26 | /missing.lst
27 | /runsuite.log
28 | /runxmlconf.log
29 | /test.out
30 | /xmlconf
31 |
32 | # Generated by build system
33 | /config.h
34 | /include/libxml/xmlversion.h
35 | /libxml-2.0-uninstalled.pc
36 | /libxml-2.0.pc
37 | /libxml2-config.cmake
38 | /xml2-config
39 |
40 | # Autotools
41 | .deps
42 | .libs
43 | Makefile
44 | Makefile.in
45 | /INSTALL
46 | /aclocal.m4
47 | /autom4te.cache
48 | /compile
49 | /config.guess
50 | /config.h.in
51 | /config.h.in~
52 | /config.log
53 | /config.status
54 | /config.sub
55 | /configure
56 | /configure~
57 | /depcomp
58 | /install-sh
59 | /libtool
60 | /ltmain.sh
61 | /missing
62 | /m4/libtool.m4
63 | /m4/lt*.m4
64 | /py-compile
65 | /stamp-h1
66 |
--------------------------------------------------------------------------------
/upstream/python/tests/resolver.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | import libxml2
4 | try:
5 | import StringIO
6 | str_io = StringIO.StringIO
7 | except:
8 | import io
9 | str_io = io.StringIO
10 |
11 | # Memory debug specific
12 | libxml2.debugMemory(1)
13 |
14 | def myResolver(URL, ID, ctxt):
15 | return(str_io(""))
16 |
17 | libxml2.setEntityLoader(myResolver)
18 |
19 | doc = libxml2.parseFile("doesnotexist.xml")
20 | root = doc.children
21 | if root.name != "foo":
22 | print("root element name error")
23 | sys.exit(1)
24 | doc.freeDoc()
25 |
26 | i = 0
27 | while i < 5000:
28 | doc = libxml2.parseFile("doesnotexist.xml")
29 | root = doc.children
30 | if root.name != "foo":
31 | print("root element name error")
32 | sys.exit(1)
33 | doc.freeDoc()
34 | i = i + 1
35 |
36 |
37 | # Memory debug specific
38 | libxml2.cleanupParser()
39 | if libxml2.debugMemory(1) == 0:
40 | print("OK")
41 | else:
42 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
43 |
44 |
--------------------------------------------------------------------------------
/upstream/include/libxml/Makefile.am:
--------------------------------------------------------------------------------
1 | ## Process this file with automake to produce Makefile.in
2 |
3 | xmlincdir = $(includedir)/libxml2/libxml
4 |
5 | xmlinc_HEADERS = \
6 | SAX.h \
7 | entities.h \
8 | encoding.h \
9 | parser.h \
10 | parserInternals.h \
11 | xmlerror.h \
12 | HTMLparser.h \
13 | HTMLtree.h \
14 | debugXML.h \
15 | tree.h \
16 | list.h \
17 | hash.h \
18 | xpath.h \
19 | xpathInternals.h \
20 | xpointer.h \
21 | xinclude.h \
22 | xmlIO.h \
23 | xmlmemory.h \
24 | nanohttp.h \
25 | nanoftp.h \
26 | uri.h \
27 | valid.h \
28 | xlink.h \
29 | catalog.h \
30 | threads.h \
31 | globals.h \
32 | c14n.h \
33 | xmlautomata.h \
34 | xmlregexp.h \
35 | xmlmodule.h \
36 | xmlschemas.h \
37 | schemasInternals.h \
38 | xmlschemastypes.h \
39 | xmlstring.h \
40 | xmlunicode.h \
41 | xmlreader.h \
42 | relaxng.h \
43 | dict.h \
44 | SAX2.h \
45 | xmlexports.h \
46 | xmlwriter.h \
47 | chvalid.h \
48 | pattern.h \
49 | xmlsave.h \
50 | schematron.h
51 |
52 | nodist_xmlinc_HEADERS = xmlversion.h
53 |
54 | EXTRA_DIST = xmlversion.h.in
55 |
--------------------------------------------------------------------------------
/upstream/include/private/parser.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_PARSER_H_PRIVATE__
2 | #define XML_PARSER_H_PRIVATE__
3 |
4 | #include
5 | #include
6 |
7 | /**
8 | * XML_VCTXT_DTD_VALIDATED:
9 | *
10 | * Set after xmlValidateDtdFinal was called.
11 | */
12 | #define XML_VCTXT_DTD_VALIDATED (1u << 0)
13 | /**
14 | * XML_VCTXT_USE_PCTXT:
15 | *
16 | * Set if the validation context is part of a parser context.
17 | */
18 | #define XML_VCTXT_USE_PCTXT (1u << 1)
19 |
20 | XML_HIDDEN void
21 | xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra);
22 | XML_HIDDEN void
23 | xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info);
24 | XML_HIDDEN void
25 | __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr,
26 | const char *msg, const xmlChar *str1,
27 | const xmlChar *str2) LIBXML_ATTR_FORMAT(3,0);
28 | XML_HIDDEN void
29 | xmlHaltParser(xmlParserCtxtPtr ctxt);
30 | XML_HIDDEN int
31 | xmlParserGrow(xmlParserCtxtPtr ctxt);
32 | XML_HIDDEN void
33 | xmlParserShrink(xmlParserCtxtPtr ctxt);
34 |
35 | #endif /* XML_PARSER_H_PRIVATE__ */
36 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Mitchell Hashimoto
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/upstream/include/libxml/xmlexports.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Summary: macros for marking symbols as exportable/importable.
3 | * Description: macros for marking symbols as exportable/importable.
4 | *
5 | * Copy: See Copyright for the status of this software.
6 | */
7 |
8 | #ifndef __XML_EXPORTS_H__
9 | #define __XML_EXPORTS_H__
10 |
11 | /** DOC_DISABLE */
12 | #if defined(_WIN32) || defined(__CYGWIN__)
13 | #ifdef LIBXML_STATIC
14 | #define XMLPUBLIC
15 | #elif defined(IN_LIBXML)
16 | #define XMLPUBLIC __declspec(dllexport)
17 | #else
18 | #define XMLPUBLIC __declspec(dllimport)
19 | #endif
20 | #else /* not Windows */
21 | #define XMLPUBLIC
22 | #endif /* platform switch */
23 | /** DOC_ENABLE */
24 |
25 | /*
26 | * XMLPUBFUN:
27 | *
28 | * Macro which declares an exportable function
29 | */
30 | #define XMLPUBFUN XMLPUBLIC
31 |
32 | /**
33 | * XMLPUBVAR:
34 | *
35 | * Macro which declares an exportable variable
36 | */
37 | #define XMLPUBVAR XMLPUBLIC extern
38 |
39 | /** DOC_DISABLE */
40 | /* Compatibility */
41 | #define XMLCALL
42 | #define XMLCDECL
43 | #if !defined(LIBXML_DLL_IMPORT)
44 | #define LIBXML_DLL_IMPORT XMLPUBVAR
45 | #endif
46 | /** DOC_ENABLE */
47 |
48 | #endif /* __XML_EXPORTS_H__ */
49 |
50 |
51 |
--------------------------------------------------------------------------------
/upstream/include/private/threads.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_THREADS_H_PRIVATE__
2 | #define XML_THREADS_H_PRIVATE__
3 |
4 | #include
5 |
6 | #ifdef LIBXML_THREAD_ENABLED
7 | #ifdef HAVE_PTHREAD_H
8 | #include
9 | #define HAVE_POSIX_THREADS
10 | #elif defined(_WIN32)
11 | #define WIN32_LEAN_AND_MEAN
12 | #include
13 | #ifndef HAVE_COMPILER_TLS
14 | #include
15 | #endif
16 | #define HAVE_WIN32_THREADS
17 | #endif
18 | #endif
19 |
20 | /*
21 | * xmlMutex are a simple mutual exception locks
22 | */
23 | struct _xmlMutex {
24 | #ifdef HAVE_POSIX_THREADS
25 | pthread_mutex_t lock;
26 | #elif defined HAVE_WIN32_THREADS
27 | CRITICAL_SECTION cs;
28 | #else
29 | int empty;
30 | #endif
31 | };
32 |
33 | XML_HIDDEN void
34 | __xmlGlobalInitMutexLock(void);
35 | XML_HIDDEN void
36 | __xmlGlobalInitMutexUnlock(void);
37 | XML_HIDDEN void
38 | __xmlGlobalInitMutexDestroy(void);
39 |
40 | XML_HIDDEN void
41 | xmlInitThreadsInternal(void);
42 | XML_HIDDEN void
43 | xmlCleanupThreadsInternal(void);
44 |
45 | XML_HIDDEN void
46 | xmlInitMutex(xmlMutexPtr mutex);
47 | XML_HIDDEN void
48 | xmlCleanupMutex(xmlMutexPtr mutex);
49 |
50 | #endif /* XML_THREADS_H_PRIVATE__ */
51 |
--------------------------------------------------------------------------------
/upstream/python/tests/tstURI.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | import libxml2
4 |
5 | # Memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | uri = libxml2.parseURI("http://example.org:8088/foo/bar?query=simple#fragid")
9 | if uri.scheme() != 'http':
10 | print("Error parsing URI: wrong scheme")
11 | sys.exit(1)
12 | if uri.server() != 'example.org':
13 | print("Error parsing URI: wrong server")
14 | sys.exit(1)
15 | if uri.port() != 8088:
16 | print("Error parsing URI: wrong port")
17 | sys.exit(1)
18 | if uri.path() != '/foo/bar':
19 | print("Error parsing URI: wrong path")
20 | sys.exit(1)
21 | if uri.query() != 'query=simple':
22 | print("Error parsing URI: wrong query")
23 | sys.exit(1)
24 | if uri.fragment() != 'fragid':
25 | print("Error parsing URI: wrong query")
26 | sys.exit(1)
27 | uri.setScheme("https")
28 | uri.setPort(223)
29 | uri.setFragment(None)
30 | result=uri.saveUri()
31 | if result != "https://example.org:223/foo/bar?query=simple":
32 | print("Error modifying or saving the URI")
33 | uri = None
34 |
35 | # Memory debug specific
36 | libxml2.cleanupParser()
37 | if libxml2.debugMemory(1) == 0:
38 | print("OK")
39 | else:
40 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
41 |
--------------------------------------------------------------------------------
/upstream/global.data:
--------------------------------------------------------------------------------
1 | #type,name,array?,threadGlobalDefault accessor?
2 | int,oldXMLWDcompatibility,,
3 | xmlBufferAllocationScheme,xmlBufferAllocScheme,,1
4 | int,xmlDefaultBufferSize,,1
5 | xmlSAXHandlerV1,xmlDefaultSAXHandler,,
6 | xmlSAXLocator,xmlDefaultSAXLocator,,
7 | int,xmlDoValidityCheckingDefaultValue,,1
8 | xmlGenericErrorFunc,xmlGenericError,,
9 | xmlStructuredErrorFunc,xmlStructuredError,,
10 | void *,xmlGenericErrorContext,,
11 | void *,xmlStructuredErrorContext,,
12 | int,xmlGetWarningsDefaultValue,,1
13 | int,xmlIndentTreeOutput,,1
14 | const char *,xmlTreeIndentString,,1
15 | int,xmlKeepBlanksDefaultValue,,1
16 | int,xmlLineNumbersDefaultValue,,1
17 | int,xmlLoadExtDtdDefaultValue,,1
18 | int,xmlParserDebugEntities,,1
19 | const char *,xmlParserVersion,,
20 | int,xmlPedanticParserDefaultValue,,1
21 | int,xmlSaveNoEmptyTags,,1
22 | #const xmlChar,xmlStringComment,[],1
23 | #const xmlChar,xmlStringText,[],1
24 | #const xmlChar,xmlStringTextNoenc,[],1
25 | int,xmlSubstituteEntitiesDefaultValue,,1
26 | xmlRegisterNodeFunc,xmlRegisterNodeDefaultValue,,
27 | xmlDeregisterNodeFunc,xmlDeregisterNodeDefaultValue,,
28 | xmlParserInputBufferCreateFilenameFunc,xmlParserInputBufferCreateFilenameValue,,
29 | xmlOutputBufferCreateFilenameFunc,xmlOutputBufferCreateFilenameValue,,
30 |
--------------------------------------------------------------------------------
/upstream/python/tests/error.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # This test exercise the redirection of error messages with a
4 | # functions defined in Python.
5 | #
6 | import sys
7 | import libxml2
8 |
9 | # Memory debug specific
10 | libxml2.debugMemory(1)
11 |
12 | expect='--> I/O --> warning : --> failed to load external entity "missing.xml"\n'
13 | err=""
14 | def callback(ctx, str):
15 | global err
16 |
17 | err = err + "%s %s" % (ctx, str)
18 |
19 | got_exc = 0
20 | libxml2.registerErrorHandler(callback, "-->")
21 | try:
22 | doc = libxml2.parseFile("missing.xml")
23 | except libxml2.parserError:
24 | got_exc = 1
25 |
26 | if got_exc == 0:
27 | print("Failed to get a parser exception")
28 | sys.exit(1)
29 |
30 | if err != expect:
31 | print("error")
32 | print("received %s" %(err))
33 | print("expected %s" %(expect))
34 | sys.exit(1)
35 |
36 | i = 10000
37 | while i > 0:
38 | try:
39 | doc = libxml2.parseFile("missing.xml")
40 | except libxml2.parserError:
41 | got_exc = 1
42 | err = ""
43 | i = i - 1
44 |
45 | # Memory debug specific
46 | libxml2.cleanupParser()
47 | if libxml2.debugMemory(1) == 0:
48 | print("OK")
49 | else:
50 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
51 |
--------------------------------------------------------------------------------
/flake.nix:
--------------------------------------------------------------------------------
1 | {
2 | description = "An empty project that uses Zig.";
3 |
4 | inputs = {
5 | nixpkgs.url = "github:nixos/nixpkgs/release-23.05";
6 | flake-utils.url = "github:numtide/flake-utils";
7 | zig.url = "github:mitchellh/zig-overlay";
8 |
9 | # Used for shell.nix
10 | flake-compat = {
11 | url = github:edolstra/flake-compat;
12 | flake = false;
13 | };
14 | };
15 |
16 | outputs = {
17 | self,
18 | nixpkgs,
19 | flake-utils,
20 | ...
21 | } @ inputs: let
22 | overlays = [
23 | # Other overlays
24 | (final: prev: {
25 | zigpkgs = inputs.zig.packages.${prev.system};
26 | })
27 | ];
28 |
29 | # Our supported systems are the same supported systems as the Zig binaries
30 | systems = builtins.attrNames inputs.zig.packages;
31 | in
32 | flake-utils.lib.eachSystem systems (
33 | system: let
34 | pkgs = import nixpkgs {inherit overlays system;};
35 | in rec {
36 | devShells.default = pkgs.mkShell {
37 | nativeBuildInputs = with pkgs; [
38 | zigpkgs.master
39 | ];
40 | };
41 |
42 | # For compatibility with older versions of the `nix` binary
43 | devShell = self.devShells.${system}.default;
44 | }
45 | );
46 | }
47 |
--------------------------------------------------------------------------------
/upstream/win32/libxml2.rc:
--------------------------------------------------------------------------------
1 | #include
2 | #include "rcVersion.h"
3 |
4 | VS_VERSION_INFO VERSIONINFO
5 | FILEVERSION LIBXML_MAJOR_VERSION,LIBXML_MINOR_VERSION,LIBXML_MICRO_VERSION,0
6 | PRODUCTVERSION LIBXML_MAJOR_VERSION,LIBXML_MINOR_VERSION,LIBXML_MICRO_VERSION,0
7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
8 | #ifdef _DEBUG
9 | FILEFLAGS VS_FF_DEBUG
10 | #else
11 | FILEFLAGS 0
12 | #endif
13 | FILEOS VOS__WINDOWS32
14 | FILETYPE VFT_DLL
15 | FILESUBTYPE VFT2_UNKNOWN // not used
16 | BEGIN
17 | BLOCK "StringFileInfo"
18 | BEGIN
19 | BLOCK "04090000" /* Lang = US English, Charset = ASCII */
20 | BEGIN
21 | VALUE "FileDescription", "libxml2 library\0"
22 | VALUE "FileVersion", LIBXML_DOTTED_VERSION "\0"
23 | VALUE "InternalName", "libxml2.dll\0"
24 | VALUE "LegalCopyright", "Copyright (C) Daniel Veillard\0"
25 | VALUE "LegalTrademarks", "\0"
26 | VALUE "OriginalFilename", "libxml2.dll\0"
27 | VALUE "ProductName", "libxml2\0"
28 | VALUE "ProductVersion", LIBXML_DOTTED_VERSION "\0"
29 | VALUE "Comments", "For more information visit https://gitlab.gnome.org/GNOME/libxml2\0"
30 | END
31 | END
32 | BLOCK "VarFileInfo"
33 | BEGIN
34 | VALUE "Translation", 0x0409, 0 /* US English, ASCII */
35 | END
36 | END
37 |
--------------------------------------------------------------------------------
/upstream/include/wsockcompat.h:
--------------------------------------------------------------------------------
1 | /* include/wsockcompat.h
2 | * Windows -> Berkeley Sockets compatibility things.
3 | */
4 |
5 | #if !defined __XML_WSOCKCOMPAT_H__
6 | #define __XML_WSOCKCOMPAT_H__
7 |
8 | #include
9 | #include
10 |
11 | /* Fix for old MinGW. */
12 | #ifndef _WINSOCKAPI_
13 | #define _WINSOCKAPI_
14 | #endif
15 |
16 | /* the following is a workaround a problem for 'inline' keyword in said
17 | header when compiled with Borland C++ 6 */
18 | #if defined(__BORLANDC__) && !defined(__cplusplus)
19 | #define inline __inline
20 | #define _inline __inline
21 | #endif
22 |
23 | #include
24 |
25 | /* Check if ws2tcpip.h is a recent version which provides getaddrinfo() */
26 | #if defined(GetAddrInfo)
27 | #include
28 | #ifndef SUPPORT_IP6
29 | #define SUPPORT_IP6
30 | #endif
31 | #endif
32 |
33 | #ifndef XML_SOCKLEN_T
34 | #define XML_SOCKLEN_T int
35 | #endif
36 |
37 | #ifndef ECONNRESET
38 | #define ECONNRESET WSAECONNRESET
39 | #endif
40 | #ifndef EINPROGRESS
41 | #define EINPROGRESS WSAEINPROGRESS
42 | #endif
43 | #ifndef EINTR
44 | #define EINTR WSAEINTR
45 | #endif
46 | #ifndef ESHUTDOWN
47 | #define ESHUTDOWN WSAESHUTDOWN
48 | #endif
49 | #ifndef EWOULDBLOCK
50 | #define EWOULDBLOCK WSAEWOULDBLOCK
51 | #endif
52 |
53 | #endif /* __XML_WSOCKCOMPAT_H__ */
54 |
--------------------------------------------------------------------------------
/upstream/python/tests/xpathext.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | import libxml2
4 |
5 | # Memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | def foo(ctx, x):
9 | return x + 1
10 |
11 | def bar(ctx, x):
12 | return "%d" % (x + 2)
13 |
14 | doc = libxml2.parseFile("tst.xml")
15 | ctxt = doc.xpathNewContext()
16 | res = ctxt.xpathEval("//*")
17 | if len(res) != 2:
18 | print("xpath query: wrong node set size")
19 | sys.exit(1)
20 | if res[0].name != "doc" or res[1].name != "foo":
21 | print("xpath query: wrong node set value")
22 | sys.exit(1)
23 |
24 | libxml2.registerXPathFunction(ctxt._o, "foo", None, foo)
25 | libxml2.registerXPathFunction(ctxt._o, "bar", None, bar)
26 | i = 10000
27 | while i > 0:
28 | res = ctxt.xpathEval("foo(1)")
29 | if res != 2:
30 | print("xpath extension failure")
31 | sys.exit(1)
32 | i = i - 1
33 | i = 10000
34 | while i > 0:
35 | res = ctxt.xpathEval("bar(1)")
36 | if res != "3":
37 | print("xpath extension failure got %s expecting '3'")
38 | sys.exit(1)
39 | i = i - 1
40 | doc.freeDoc()
41 | ctxt.xpathFreeContext()
42 |
43 | # Memory debug specific
44 | libxml2.cleanupParser()
45 | if libxml2.debugMemory(1) == 0:
46 | print("OK")
47 | else:
48 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
49 |
--------------------------------------------------------------------------------
/upstream/fuzz/regexp.c:
--------------------------------------------------------------------------------
1 | /*
2 | * regexp.c: a libFuzzer target to test the regexp module.
3 | *
4 | * See Copyright for the status of this software.
5 | */
6 |
7 | #include
8 | #include "fuzz.h"
9 |
10 | int
11 | LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
12 | char ***argv ATTRIBUTE_UNUSED) {
13 | xmlFuzzMemSetup();
14 | xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
15 |
16 | return 0;
17 | }
18 |
19 | int
20 | LLVMFuzzerTestOneInput(const char *data, size_t size) {
21 | xmlRegexpPtr regexp;
22 | size_t maxAlloc;
23 | const char *str1;
24 |
25 | if (size > 200)
26 | return(0);
27 |
28 | xmlFuzzDataInit(data, size);
29 | maxAlloc = xmlFuzzReadInt(4) % (size * 8 + 1);
30 | str1 = xmlFuzzReadString(NULL);
31 |
32 | /* CUR_SCHAR doesn't handle invalid UTF-8 and may cause infinite loops. */
33 | if (xmlCheckUTF8(BAD_CAST str1) != 0) {
34 | xmlFuzzMemSetLimit(maxAlloc);
35 | regexp = xmlRegexpCompile(BAD_CAST str1);
36 | /* xmlRegexpExec has pathological performance in too many cases. */
37 | #if 0
38 | xmlRegexpExec(regexp, BAD_CAST str2);
39 | #endif
40 | xmlRegFreeRegexp(regexp);
41 | }
42 |
43 | xmlFuzzMemSetLimit(0);
44 | xmlFuzzDataCleanup();
45 | xmlResetLastError();
46 |
47 | return 0;
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/upstream/os400/make-bldcsndfa.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Compilation script for the iconv names DFA builer.
4 | #
5 | # See Copyright for the status of this software.
6 | #
7 | # Author: Patrick Monnerat , DATASPHERE S.A.
8 | #
9 |
10 | SCRIPTDIR=`dirname "${0}"`
11 | . "${SCRIPTDIR}/initscript.sh"
12 | cd "${TOPDIR}/os400/iconv/bldcsndfa"
13 |
14 |
15 | # This is for old XML library (bootstrapping).
16 | #rm -rf xml.h xml
17 | #ln -s /QSYS.LIB/XML.LIB/H.FILE/XML.MBR xml.h
18 | #mkdir xml
19 | #mkdir xml/h
20 | #ln -s /QSYS.LIB/XML.LIB/H.FILE/UTF8.MBR xml/h/utf8
21 |
22 |
23 | # Compile.
24 |
25 | CMD="CRTCMOD MODULE(${TARGETLIB}/BLDCSNDFA) SRCSTMF('bldcsndfa.c')"
26 | CMD="${CMD} SYSIFCOPT(*IFS64IO) LANGLVL(*EXTENDED) LOCALETYPE(*LOCALE)"
27 | CMD="${CMD} INCDIR("
28 | CMD="${CMD} '${IFSDIR}/include' ${INCLUDES})"
29 | CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
30 | CMD="${CMD} OUTPUT(${OUTPUT})"
31 | CMD="${CMD} OPTIMIZE(10)"
32 | CMD="${CMD} DBGVIEW(${DEBUG})"
33 | #CMD="${CMD} DEFINE('OLDXML' 'xmlXPathSetContextNode=xmlXPathSetCurrentNode')"
34 |
35 | system "${CMD}"
36 |
37 | # Link
38 |
39 | CMD="CRTPGM PGM(${TARGETLIB}/BLDCSNDFA) MODULE(${TARGETLIB}/BLDCSNDFA)"
40 | CMD="${CMD} BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
41 | #CMD="${CMD} BNDDIR(XML/XML)"
42 | CMD="${CMD} TGTRLS(${TGTRLS})"
43 | system "${CMD}"
44 |
--------------------------------------------------------------------------------
/upstream/python/tests/xpathleak.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys, libxml2
3 |
4 | libxml2.debugMemory(True)
5 |
6 | expect="""--> Invalid expression
7 | --> Invalid expression
8 | --> Invalid expression
9 | --> Invalid expression
10 | --> Invalid expression
11 | --> Invalid expression
12 | --> Invalid expression
13 | --> Invalid expression
14 | --> Invalid expression
15 | --> Invalid expression
16 | """
17 | err=""
18 | def callback(ctx, str):
19 | global err
20 |
21 | err = err + "%s %s" % (ctx, str)
22 |
23 | libxml2.registerErrorHandler(callback, "-->")
24 |
25 | doc = libxml2.parseDoc("")
26 | ctxt = doc.xpathNewContext()
27 | ctxt.setContextNode(doc)
28 | badexprs = (
29 | ":false()", "bad:()", "bad(:)", ":bad(:)", "bad:(:)", "bad:bad(:)",
30 | "a:/b", "/c:/d", "//e:/f", "g://h"
31 | )
32 | for expr in badexprs:
33 | try:
34 | ctxt.xpathEval(expr)
35 | except libxml2.xpathError:
36 | pass
37 | else:
38 | print("Unexpectedly legal expression:", expr)
39 | ctxt.xpathFreeContext()
40 | doc.freeDoc()
41 |
42 | if err != expect:
43 | print("error")
44 | print("received %s" %(err))
45 | print("expected %s" %(expect))
46 | sys.exit(1)
47 |
48 | libxml2.cleanupParser()
49 | leakedbytes = libxml2.debugMemory(True)
50 | if leakedbytes == 0:
51 | print("OK")
52 | else:
53 | print("Memory leak", leakedbytes, "bytes")
54 |
--------------------------------------------------------------------------------
/upstream/Copyright:
--------------------------------------------------------------------------------
1 | Except where otherwise noted in the source code (e.g. the files hash.c,
2 | list.c and the trio files, which are covered by a similar licence but
3 | with different Copyright notices) all the files are:
4 |
5 | Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved.
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is fur-
12 | nished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
19 | NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
--------------------------------------------------------------------------------
/upstream/fuzz/schema.c:
--------------------------------------------------------------------------------
1 | /*
2 | * schema.c: a libFuzzer target to test the XML Schema processor.
3 | *
4 | * See Copyright for the status of this software.
5 | */
6 |
7 | #include
8 | #include
9 | #include "fuzz.h"
10 |
11 | int
12 | LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
13 | char ***argv ATTRIBUTE_UNUSED) {
14 | xmlFuzzMemSetup();
15 | xmlInitParser();
16 | #ifdef LIBXML_CATALOG_ENABLED
17 | xmlInitializeCatalog();
18 | #endif
19 | xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
20 | xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
21 |
22 | return 0;
23 | }
24 |
25 | int
26 | LLVMFuzzerTestOneInput(const char *data, size_t size) {
27 | xmlSchemaParserCtxtPtr pctxt;
28 | size_t maxAlloc;
29 |
30 | if (size > 50000)
31 | return(0);
32 |
33 | maxAlloc = xmlFuzzReadInt(4) % (size + 1);
34 |
35 | xmlFuzzDataInit(data, size);
36 | xmlFuzzReadEntities();
37 |
38 | xmlFuzzMemSetLimit(maxAlloc);
39 | pctxt = xmlSchemaNewParserCtxt(xmlFuzzMainUrl());
40 | xmlSchemaSetParserErrors(pctxt, xmlFuzzErrorFunc, xmlFuzzErrorFunc, NULL);
41 | xmlSchemaFree(xmlSchemaParse(pctxt));
42 | xmlSchemaFreeParserCtxt(pctxt);
43 |
44 | xmlFuzzMemSetLimit(0);
45 | xmlFuzzDataCleanup();
46 | xmlResetLastError();
47 |
48 | return(0);
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/upstream/m4/ax_require_defined.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_require_defined.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_REQUIRE_DEFINED(MACRO)
8 | #
9 | # DESCRIPTION
10 | #
11 | # AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
12 | # been defined and thus are available for use. This avoids random issues
13 | # where a macro isn't expanded. Instead the configure script emits a
14 | # non-fatal:
15 | #
16 | # ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
17 | #
18 | # It's like AC_REQUIRE except it doesn't expand the required macro.
19 | #
20 | # Here's an example:
21 | #
22 | # AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
23 | #
24 | # LICENSE
25 | #
26 | # Copyright (c) 2014 Mike Frysinger
27 | #
28 | # Copying and distribution of this file, with or without modification, are
29 | # permitted in any medium without royalty provided the copyright notice
30 | # and this notice are preserved. This file is offered as-is, without any
31 | # warranty.
32 |
33 | #serial 2
34 |
35 | AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
36 | m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
37 | ])dnl AX_REQUIRE_DEFINED
38 |
--------------------------------------------------------------------------------
/upstream/python/tests/reader4.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # this tests the basic APIs of the XmlTextReader interface
4 | #
5 | import libxml2
6 | import sys
7 | try:
8 | import StringIO
9 | str_io = StringIO.StringIO
10 | except:
11 | import io
12 | str_io = io.StringIO
13 |
14 | # Memory debug specific
15 | libxml2.debugMemory(1)
16 |
17 | def tst_reader(s):
18 | f = str_io(s)
19 | input = libxml2.inputBuffer(f)
20 | reader = input.newTextReader("tst")
21 | res = ""
22 | while reader.Read():
23 | res=res + "%s (%s) [%s] %d\n" % (reader.NodeType(),reader.Name(),
24 | reader.Value(), reader.IsEmptyElement())
25 | if reader.NodeType() == 1: # Element
26 | while reader.MoveToNextAttribute():
27 | res = res + "-- %s (%s) [%s]\n" % (reader.NodeType(),
28 | reader.Name(),reader.Value())
29 | return res
30 |
31 | expect="""1 (test) [None] 0
32 | 1 (b) [None] 1
33 | 1 (c) [None] 1
34 | 15 (test) [None] 0
35 | """
36 |
37 | res = tst_reader("""""")
38 |
39 | if res != expect:
40 | print("Did not get the expected error message:")
41 | print(res)
42 | sys.exit(1)
43 |
44 | # Memory debug specific
45 | libxml2.cleanupParser()
46 | if libxml2.debugMemory(1) == 0:
47 | print("OK")
48 | else:
49 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
50 |
--------------------------------------------------------------------------------
/upstream/python/tests/relaxng.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import libxml2
3 | import sys
4 |
5 | # Memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | schema="""
9 |
14 | A foo element.
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | """
23 | instance="""
24 | """
25 |
26 | rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
27 | rngs = rngp.relaxNGParse()
28 | ctxt = rngs.relaxNGNewValidCtxt()
29 | doc = libxml2.parseDoc(instance)
30 | ret = doc.relaxNGValidateDoc(ctxt)
31 | if ret != 0:
32 | print("error doing RelaxNG validation")
33 | sys.exit(1)
34 |
35 | doc.freeDoc()
36 | del rngp
37 | del rngs
38 | del ctxt
39 | libxml2.relaxNGCleanupTypes()
40 |
41 | # Memory debug specific
42 | libxml2.cleanupParser()
43 | if libxml2.debugMemory(1) == 0:
44 | print("OK")
45 | else:
46 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
47 |
48 |
--------------------------------------------------------------------------------
/upstream/python/tests/xpath.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # this test exercise the XPath basic engine, parser, etc, and
4 | # allows to detect memory leaks
5 | #
6 | import sys
7 | import libxml2
8 |
9 | # Memory debug specific
10 | libxml2.debugMemory(1)
11 |
12 | doc = libxml2.parseFile("tst.xml")
13 | if doc.name != "tst.xml":
14 | print("doc.name error")
15 | sys.exit(1);
16 |
17 | ctxt = doc.xpathNewContext()
18 | res = ctxt.xpathEval("//*")
19 | if len(res) != 2:
20 | print("xpath query: wrong node set size")
21 | sys.exit(1)
22 | if res[0].name != "doc" or res[1].name != "foo":
23 | print("xpath query: wrong node set value")
24 | sys.exit(1)
25 | ctxt.setContextNode(res[0])
26 | res = ctxt.xpathEval("foo")
27 | if len(res) != 1:
28 | print("xpath query: wrong node set size")
29 | sys.exit(1)
30 | if res[0].name != "foo":
31 | print("xpath query: wrong node set value")
32 | sys.exit(1)
33 | doc.freeDoc()
34 | ctxt.xpathFreeContext()
35 | i = 1000
36 | while i > 0:
37 | doc = libxml2.parseFile("tst.xml")
38 | ctxt = doc.xpathNewContext()
39 | res = ctxt.xpathEval("//*")
40 | doc.freeDoc()
41 | ctxt.xpathFreeContext()
42 | i = i -1
43 | del ctxt
44 |
45 | # Memory debug specific
46 | libxml2.cleanupParser()
47 | if libxml2.debugMemory(1) == 0:
48 | print("OK")
49 | else:
50 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
51 |
--------------------------------------------------------------------------------
/upstream/include/libxml/xmlmodule.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Summary: dynamic module loading
3 | * Description: basic API for dynamic module loading, used by
4 | * libexslt added in 2.6.17
5 | *
6 | * Copy: See Copyright for the status of this software.
7 | *
8 | * Author: Joel W. Reed
9 | */
10 |
11 | #ifndef __XML_MODULE_H__
12 | #define __XML_MODULE_H__
13 |
14 | #include
15 |
16 | #ifdef LIBXML_MODULES_ENABLED
17 |
18 | #ifdef __cplusplus
19 | extern "C" {
20 | #endif
21 |
22 | /**
23 | * xmlModulePtr:
24 | *
25 | * A handle to a dynamically loaded module
26 | */
27 | typedef struct _xmlModule xmlModule;
28 | typedef xmlModule *xmlModulePtr;
29 |
30 | /**
31 | * xmlModuleOption:
32 | *
33 | * enumeration of options that can be passed down to xmlModuleOpen()
34 | */
35 | typedef enum {
36 | XML_MODULE_LAZY = 1, /* lazy binding */
37 | XML_MODULE_LOCAL= 2 /* local binding */
38 | } xmlModuleOption;
39 |
40 | XMLPUBFUN xmlModulePtr xmlModuleOpen (const char *filename,
41 | int options);
42 |
43 | XMLPUBFUN int xmlModuleSymbol (xmlModulePtr module,
44 | const char* name,
45 | void **result);
46 |
47 | XMLPUBFUN int xmlModuleClose (xmlModulePtr module);
48 |
49 | XMLPUBFUN int xmlModuleFree (xmlModulePtr module);
50 |
51 | #ifdef __cplusplus
52 | }
53 | #endif
54 |
55 | #endif /* LIBXML_MODULES_ENABLED */
56 |
57 | #endif /*__XML_MODULE_H__ */
58 |
--------------------------------------------------------------------------------
/upstream/os400/libxmlrpg/xmlTypesC.rpgle:
--------------------------------------------------------------------------------
1 | * Equivalent of C data types.
2 | *
3 | * Copy: See Copyright for the status of this software.
4 | *
5 | * Author: Patrick Monnerat , DATASPHERE S.A.
6 |
7 | /if not defined(XMLTYPESC_H__)
8 | /define XMLTYPESC_H__
9 |
10 | d xmlCchar s 3i 0 based(######typedef######)
11 | d xmlCuchar s 3u 0 based(######typedef######)
12 | d xmlCshort s 5i 0 based(######typedef######)
13 | d xmlCushort s 5u 0 based(######typedef######)
14 | d xmlCint s 10i 0 based(######typedef######)
15 | d xmlCuInt s 10u 0 based(######typedef######)
16 | d xmlClong s 10i 0 based(######typedef######)
17 | d xmlCulong s 10u 0 based(######typedef######)
18 | d xmlClonglong s 20i 0 based(######typedef######)
19 | d xmlCulonglong s 20u 0 based(######typedef######)
20 | d xmlCenum s 10i 0 based(######typedef######)
21 | d xmlCssize_t s 10i 0 based(######typedef######)
22 | d xmlCsize_t s 10u 0 based(######typedef######)
23 | d xmlCfloat s 4f based(######typedef######)
24 | d xmlCdouble s 8f based(######typedef######)
25 |
26 | /endif
27 |
--------------------------------------------------------------------------------
/upstream/dbgenattr.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 |
3 | $size = shift;
4 |
5 | if ($size eq "")
6 | {
7 | die "usage: dbgen.pl [size]\n";
8 | }
9 |
10 | @firstnames = ("Al", "Bob", "Charles", "David", "Egon", "Farbood",
11 | "George", "Hank", "Inki", "James");
12 | @lastnames = ("Aranow", "Barker", "Corsetti", "Dershowitz", "Engleman",
13 | "Franklin", "Grice", "Haverford", "Ilvedson", "Jones");
14 | @states = ("AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA",
15 | "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD",
16 | "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ",
17 | "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC",
18 | "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY");
19 |
20 | print "\n";
21 | print "\n";
22 | print "\n";
23 |
24 | for ($i=0; $i<$size; $i++)
25 | {
26 | $first = $firstnames [$i % 10];
27 | $last = $lastnames [($i / 10) % 10];
28 | $state = $states [($i / 100) % 50];
29 | $zip = 22000 + $i / 5000;
30 |
31 | printf "
\n", $zip;
39 | }
40 |
41 | print "
\n";
42 |
43 |
--------------------------------------------------------------------------------
/upstream/os400/libxmlrpg/xmlstdarg.rpgle:
--------------------------------------------------------------------------------
1 | * Summary: va_list support for ILE/RPG.
2 | *
3 | * Copy: See Copyright for the status of this software.
4 | *
5 | * Author: Patrick Monnerat , DATASPHERE S.A.
6 |
7 | /if not defined(XML_STDARG_H__)
8 | /define XML_STDARG_H__
9 |
10 | /include "libxmlrpg/xmlversion"
11 | /include "libxmlrpg/xmlTypesC"
12 |
13 | * The va_list object.
14 |
15 | d xmlVaList ds based(######typedef######)
16 | d align qualified
17 | d current *
18 | d next *
19 |
20 | * Procedures.
21 |
22 | d xmlVaStart pr extproc('__xmlVaStart')
23 | d list likeds(xmlVaList)
24 | d lastargaddr * value
25 | d lastargsize value like(xmlCsize_t)
26 |
27 | d xmlVaArg pr * extproc('__xmlVaArg')
28 | d list likeds(xmlVaList)
29 | d dest * value
30 | d argsize value like(xmlCsize_t)
31 |
32 | d xmlVaEnd pr extproc('__xmlVaEnd')
33 | d list likeds(xmlVaList)
34 |
35 | /endif XML_STDARG_H__
36 |
--------------------------------------------------------------------------------
/upstream/python/tests/validDTD.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import libxml2
3 | import sys
4 |
5 | ARG = 'test string'
6 |
7 | class ErrorHandler:
8 |
9 | def __init__(self):
10 | self.errors = []
11 |
12 | def handler(self, msg, data):
13 | if data != ARG:
14 | raise Exception("Error handler did not receive correct argument")
15 | self.errors.append(msg)
16 |
17 |
18 | # Memory debug specific
19 | libxml2.debugMemory(1)
20 |
21 | dtd=""""""
22 | valid="""
23 | """
24 |
25 | invalid="""
26 | """
27 |
28 | dtd = libxml2.parseDTD(None, 'test.dtd')
29 | ctxt = libxml2.newValidCtxt()
30 | e = ErrorHandler()
31 | ctxt.setValidityErrorHandler(e.handler, e.handler, ARG)
32 |
33 | # Test valid document
34 | doc = libxml2.parseDoc(valid)
35 | ret = doc.validateDtd(ctxt, dtd)
36 | if ret != 1 or e.errors:
37 | print("error doing DTD validation")
38 | sys.exit(1)
39 | doc.freeDoc()
40 |
41 | # Test invalid document
42 | doc = libxml2.parseDoc(invalid)
43 | ret = doc.validateDtd(ctxt, dtd)
44 | if ret != 0 or not e.errors:
45 | print("Error: document supposed to be invalid")
46 | doc.freeDoc()
47 |
48 | dtd.freeDtd()
49 | del dtd
50 | del ctxt
51 |
52 | # Memory debug specific
53 | libxml2.cleanupParser()
54 | if libxml2.debugMemory(1) == 0:
55 | print("OK")
56 | else:
57 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
58 |
59 |
--------------------------------------------------------------------------------
/upstream/python/tests/cutnpaste.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | import libxml2
4 |
5 | # Memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | #
9 | # Testing XML document serialization
10 | #
11 | source = libxml2.parseDoc("""
12 |
14 |
15 |
16 |
17 |
18 | """)
19 |
20 | target = libxml2.parseDoc("""
21 | """)
22 |
23 | fragment = source.xpathEval("//*[name()='fragment']")[0]
24 | dest = target.getRootElement()
25 |
26 | # do a cut and paste operation
27 | fragment.unlinkNode()
28 | dest.addChild(fragment)
29 | # do the namespace fixup
30 | dest.reconciliateNs(target)
31 |
32 | # The source tree can be freed at that point
33 | source.freeDoc()
34 |
35 | # check the resulting tree
36 | str = dest.serialize()
37 | if str != """""":
38 | print("reconciliateNs() failed")
39 | sys.exit(1)
40 | target.freeDoc()
41 |
42 | # Memory debug specific
43 | libxml2.cleanupParser()
44 | if libxml2.debugMemory(1) == 0:
45 | print("OK")
46 | else:
47 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
48 |
--------------------------------------------------------------------------------
/upstream/python/README:
--------------------------------------------------------------------------------
1 | Module libxml2-python
2 | =====================
3 |
4 | This is the libxml2 python module, providing access to the
5 | libxml2 and libxslt (if available) libraries. For general
6 | informationss on those XML and XSLT libraries check their
7 | web pages at:
8 | https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home
9 | and
10 | https://gitlab.gnome.org/GNOME/libxslt/-/wikis/home
11 |
12 | The latest version of the sources for this module and the
13 | associated libraries can be found at:
14 | https://gitlab.gnome.org/GNOME/libxml2/-/releases
15 |
16 | Binaries packages of the libxml2 and libxslt libraries can
17 | be found either on the FTP site for Linux, from external
18 | sources linked from the web pages, or as part of your set of
19 | packages provided with your operating system.
20 |
21 | NOTE:
22 | this module distribution is not the primary distribution
23 | of the libxml2 and libxslt Python binding code, but as
24 | the Python way of packaging those for non-Linux systems.
25 | The main sources are the libxml2 and libxslt tar.gz found on
26 | the site. One side effect is that the official RPM packages for
27 | those modules are not generated from the libxml2-python
28 | distributions but as part of the normal RPM packaging of
29 | those two libraries.
30 | The RPM packages can be found at:
31 | http://rpmfind.net/linux/rpm2html/search.php?query=libxml2-python
32 | http://rpmfind.net/linux/rpm2html/search.php?query=libxslt-python
33 |
34 | Daniel Veillard
35 |
--------------------------------------------------------------------------------
/upstream/python/tests/readererr.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # this tests the basic APIs of the XmlTextReader interface
4 | #
5 | import libxml2
6 | import sys
7 | try:
8 | import StringIO
9 | str_io = StringIO.StringIO
10 | except:
11 | import io
12 | str_io = io.StringIO
13 |
14 | # Memory debug specific
15 | libxml2.debugMemory(1)
16 |
17 | expect="""--> (3) test1:1:xmlns: URI foo is not absolute
18 | --> (4) test1:1:Opening and ending tag mismatch: c line 1 and a
19 | """
20 | err=""
21 | def myErrorHandler(arg,msg,severity,locator):
22 | global err
23 | err = err + "%s (%d) %s:%d:%s" % (arg,severity,locator.BaseURI(),locator.LineNumber(),msg)
24 |
25 | f = str_io("""content of c""")
26 | input = libxml2.inputBuffer(f)
27 | reader = input.newTextReader("test1")
28 | reader.SetErrorHandler(myErrorHandler,"-->")
29 | while reader.Read() == 1:
30 | pass
31 |
32 | if err != expect:
33 | print("error")
34 | print("received %s" %(err))
35 | print("expected %s" %(expect))
36 | sys.exit(1)
37 |
38 | reader.SetErrorHandler(None,None)
39 | if reader.GetErrorHandler() != (None,None):
40 | print("GetErrorHandler failed")
41 | sys.exit(1)
42 |
43 | #
44 | # cleanup for memory allocation counting
45 | #
46 | del f
47 | del input
48 | del reader
49 |
50 | # Memory debug specific
51 | libxml2.cleanupParser()
52 | if libxml2.debugMemory(1) == 0:
53 | print("OK")
54 | else:
55 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
56 |
--------------------------------------------------------------------------------
/upstream/python/tests/schema.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import libxml2
3 | import sys
4 |
5 | # Memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | schema="""
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | """
21 |
22 | instance="""
23 |
24 | Raymond
25 | G
26 | Bayliss
27 |
28 | """
29 |
30 | ctxt_parser = libxml2.schemaNewMemParserCtxt(schema, len(schema))
31 | ctxt_schema = ctxt_parser.schemaParse()
32 | ctxt_valid = ctxt_schema.schemaNewValidCtxt()
33 | doc = libxml2.parseDoc(instance)
34 | ret = doc.schemaValidateDoc(ctxt_valid)
35 | if ret != 0:
36 | print("error doing schema validation")
37 | sys.exit(1)
38 |
39 | doc.freeDoc()
40 | del ctxt_parser
41 | del ctxt_schema
42 | del ctxt_valid
43 | libxml2.schemaCleanupTypes()
44 |
45 | # Memory debug specific
46 | libxml2.cleanupParser()
47 | if libxml2.debugMemory(1) == 0:
48 | print("OK")
49 | else:
50 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
51 |
52 |
--------------------------------------------------------------------------------
/upstream/python/tests/reader5.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # this tests the Expand() API of the xmlTextReader interface
4 | # this extract the Dragon bibliography entries from the XML specification
5 | #
6 | import libxml2
7 | import os
8 | import sys
9 |
10 | # Memory debug specific
11 | libxml2.debugMemory(1)
12 |
13 | expect="""Aho, Alfred V.,
14 | Ravi Sethi, and Jeffrey D. Ullman.
15 | Compilers: Principles, Techniques, and Tools.
16 | Reading: Addison-Wesley, 1986, rpt. corr. 1988."""
17 |
18 | basedir = os.path.dirname(os.path.realpath(__file__))
19 | f = open(os.path.join(basedir, '../../test/valid/REC-xml-19980210.xml'), 'rb')
20 | input = libxml2.inputBuffer(f)
21 | reader = input.newTextReader("REC")
22 | res=""
23 | while reader.Read() > 0:
24 | while reader.Name() == 'bibl':
25 | node = reader.Expand() # expand the subtree
26 | if node.xpathEval("@id = 'Aho'"): # use XPath on it
27 | res = res + node.serialize()
28 | if reader.Next() != 1: # skip the subtree
29 | break;
30 |
31 | if res != expect:
32 | print("Error: didn't get the expected output")
33 | print("got '%s'" % (res))
34 | print("expected '%s'" % (expect))
35 |
36 |
37 | #
38 | # cleanup
39 | #
40 | del input
41 | del reader
42 |
43 | # Memory debug specific
44 | libxml2.cleanupParser()
45 | if libxml2.debugMemory(1) == 0:
46 | print("OK")
47 | else:
48 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
49 |
--------------------------------------------------------------------------------
/upstream/os400/transcode.h:
--------------------------------------------------------------------------------
1 | /**
2 | *** Transcoding support declarations.
3 | ***
4 | *** See Copyright for the status of this software.
5 | ***
6 | *** Author: Patrick Monnerat , DATASPHERE S.A.
7 | **/
8 |
9 | #ifndef _TRANSCODE_H_
10 | #define _TRANSCODE_H_
11 |
12 | #include
13 | #include
14 |
15 |
16 | XMLPUBFUN void xmlZapDict(xmlDictPtr * dict);
17 | XMLPUBFUN const char * xmlTranscodeResult(const xmlChar * s,
18 | const char * encoding, xmlDictPtr * dict,
19 | void (*freeproc)(const void *));
20 | XMLPUBFUN const xmlChar * xmlTranscodeString(const char * s,
21 | const char * encoding, xmlDictPtr * dict);
22 | XMLPUBFUN const xmlChar * xmlTranscodeWString(const char * s,
23 | const char * encoding, xmlDictPtr * dict);
24 | XMLPUBFUN const xmlChar * xmlTranscodeHString(const char * s,
25 | const char * encoding, xmlDictPtr * dict);
26 |
27 | #ifndef XML_NO_SHORT_NAMES
28 | /**
29 | *** Since the above functions are generally called "inline" (i.e.: several
30 | *** times nested in a single expression), define shorthand names
31 | *** to minimize calling statement length.
32 | **/
33 |
34 | #define xmlTR xmlTranscodeResult
35 | #define xmlTS xmlTranscodeString
36 | #define xmlTW xmlTranscodeWString
37 | #define xmlTH xmlTranscodeHstring
38 | #endif
39 |
40 | XMLPUBFUN const char * xmlVasprintf(xmlDictPtr * dict, const char * encoding,
41 | const xmlChar * fmt, va_list args);
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/upstream/dbgen.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 |
3 | $size = shift;
4 |
5 | if ($size eq "")
6 | {
7 | die "usage: dbgen.pl [size]\n";
8 | }
9 |
10 | @firstnames = ("Al", "Bob", "Charles", "David", "Egon", "Farbood",
11 | "George", "Hank", "Inki", "James");
12 | @lastnames = ("Aranow", "Barker", "Corsetti", "Dershowitz", "Engleman",
13 | "Franklin", "Grice", "Haverford", "Ilvedson", "Jones");
14 | @states = ("AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA",
15 | "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD",
16 | "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ",
17 | "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC",
18 | "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY");
19 |
20 | print "\n";
21 | print "\n";
22 | print "\n";
23 |
24 | for ($i=0; $i<$size; $i++)
25 | {
26 | $first = $firstnames [$i % 10];
27 | $last = $lastnames [($i / 10) % 10];
28 | $state = $states [($i / 100) % 50];
29 | $zip = 22000 + $i / 5000;
30 |
31 | printf " \n";
32 | printf " %04d\n", $i;
33 | printf " $first\n", $i;
34 | printf " $last\n", $i;
35 | printf " %d Any St.\n", ($i % 100) + 1;
36 | printf " Anytown\n";
37 | printf " $state\n";
38 | printf " %d\n", $zip;
39 | printf "
\n";
40 | }
41 |
42 | print "
\n";
43 |
44 |
--------------------------------------------------------------------------------
/upstream/python/Makefile.am:
--------------------------------------------------------------------------------
1 | # Makefile for libxml2 python library
2 |
3 | # We use a rule with multiple output files which creates problems with
4 | # parallel builds.
5 | .NOTPARALLEL:
6 |
7 | SUBDIRS = . tests
8 |
9 | EXTRA_DIST = \
10 | generator.py \
11 | libxml.py \
12 | libxml2-python-api.xml
13 |
14 | if WITH_PYTHON
15 | AM_CPPFLAGS = \
16 | -I$(top_builddir)/include \
17 | -I$(top_srcdir)/include \
18 | $(PYTHON_CFLAGS)
19 |
20 | pyexec_LTLIBRARIES = libxml2mod.la
21 |
22 | libxml2mod_la_SOURCES = libxml.c libxml_wrap.h types.c
23 | nodist_libxml2mod_la_SOURCES = libxml2-py.h libxml2-py.c
24 | libxml2mod_la_LDFLAGS = $(AM_LDFLAGS) $(PYTHON_LDFLAGS) -module -avoid-version
25 | libxml2mod_la_LIBADD = $(top_builddir)/libxml2.la $(PYTHON_LIBS)
26 |
27 | BUILT_SOURCES = libxml2-export.c libxml2-py.h libxml2-py.c
28 |
29 | python_PYTHON = drv_libxml2.py
30 | nodist_python_PYTHON = libxml2.py
31 |
32 | API_DESC = $(top_srcdir)/doc/libxml2-api.xml $(srcdir)/libxml2-python-api.xml
33 | GENERATED = libxml2class.py libxml2class.txt $(BUILT_SOURCES)
34 | CLEANFILES = libxml2.py $(GENERATED)
35 |
36 | all-local: libxml2.py
37 |
38 | $(GENERATED): $(srcdir)/generator.py $(API_DESC)
39 | $(PYTHON) $(srcdir)/generator.py $(srcdir)
40 |
41 | # libxml.c #includes libxml2-export.c
42 | libxml.$(OBJEXT): libxml2-export.c
43 |
44 | libxml2.py: $(srcdir)/libxml.py libxml2class.py
45 | cat $(srcdir)/libxml.py `test -f libxml2class.py || echo $(srcdir)/`libxml2class.py > $@
46 |
47 | clean-local:
48 | rm -rf __pycache__ *.pyc
49 |
50 | endif
51 |
--------------------------------------------------------------------------------
/upstream/python/tests/ctxterror.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # This test exercise the redirection of error messages with a
4 | # functions defined in Python.
5 | #
6 | import sys
7 | import libxml2
8 |
9 | # Memory debug specific
10 | libxml2.debugMemory(1)
11 |
12 | expect="""--> (3) xmlns: URI foo is not absolute
13 | --> (4) Opening and ending tag mismatch: x line 1 and y
14 | """
15 |
16 | err=""
17 | def callback(arg,msg,severity,reserved):
18 | global err
19 | err = err + "%s (%d) %s" % (arg,severity,msg)
20 |
21 | s = """"""
22 |
23 | parserCtxt = libxml2.createPushParser(None,"",0,"test.xml")
24 | parserCtxt.setErrorHandler(callback, "-->")
25 | if parserCtxt.getErrorHandler() != (callback,"-->"):
26 | print("getErrorHandler failed")
27 | sys.exit(1)
28 | parserCtxt.parseChunk(s,len(s),1)
29 | doc = parserCtxt.doc()
30 | doc.freeDoc()
31 | parserCtxt = None
32 |
33 | if err != expect:
34 | print("error")
35 | print("received %s" %(err))
36 | print("expected %s" %(expect))
37 | sys.exit(1)
38 |
39 | i = 10000
40 | while i > 0:
41 | parserCtxt = libxml2.createPushParser(None,"",0,"test.xml")
42 | parserCtxt.setErrorHandler(callback, "-->")
43 | parserCtxt.parseChunk(s,len(s),1)
44 | doc = parserCtxt.doc()
45 | doc.freeDoc()
46 | parserCtxt = None
47 | err = ""
48 | i = i - 1
49 |
50 | # Memory debug specific
51 | libxml2.cleanupParser()
52 | if libxml2.debugMemory(1) == 0:
53 | print("OK")
54 | else:
55 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
56 |
--------------------------------------------------------------------------------
/upstream/python/tests/xpathret.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | import libxml2
4 |
5 | #memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | #
9 | # A document hosting the nodes returned from the extension function
10 | #
11 | mydoc = libxml2.newDoc("1.0")
12 |
13 | def foo(ctx, str):
14 | global mydoc
15 |
16 | #
17 | # test returning a node set works as expected
18 | #
19 | parent = mydoc.newDocNode(None, 'p', None)
20 | mydoc.addChild(parent)
21 | node = mydoc.newDocText(str)
22 | parent.addChild(node)
23 | return [parent]
24 |
25 | doc = libxml2.parseFile("tst.xml")
26 | ctxt = doc.xpathNewContext()
27 | libxml2.registerXPathFunction(ctxt._o, "foo", None, foo)
28 | res = ctxt.xpathEval("foo('hello')")
29 | if type(res) != type([]):
30 | print("Failed to return a nodeset")
31 | sys.exit(1)
32 | if len(res) != 1:
33 | print("Unexpected nodeset size")
34 | sys.exit(1)
35 | node = res[0]
36 | if node.name != 'p':
37 | print("Unexpected nodeset element result")
38 | sys.exit(1)
39 | node = node.children
40 | if node.type != 'text':
41 | print("Unexpected nodeset element children type")
42 | sys.exit(1)
43 | if node.content != 'hello':
44 | print("Unexpected nodeset element children content")
45 | sys.exit(1)
46 |
47 | doc.freeDoc()
48 | mydoc.freeDoc()
49 | ctxt.xpathFreeContext()
50 |
51 | #memory debug specific
52 | libxml2.cleanupParser()
53 | if libxml2.debugMemory(1) == 0:
54 | print("OK")
55 | else:
56 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
57 |
--------------------------------------------------------------------------------
/upstream/fuzz/xpath.c:
--------------------------------------------------------------------------------
1 | /*
2 | * xpath.c: a libFuzzer target to test XPath and XPointer expressions.
3 | *
4 | * See Copyright for the status of this software.
5 | */
6 |
7 | #include
8 | #include
9 | #include "fuzz.h"
10 |
11 | int
12 | LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
13 | char ***argv ATTRIBUTE_UNUSED) {
14 | xmlFuzzMemSetup();
15 | xmlInitParser();
16 | xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
17 |
18 | return 0;
19 | }
20 |
21 | int
22 | LLVMFuzzerTestOneInput(const char *data, size_t size) {
23 | xmlDocPtr doc;
24 | const char *expr, *xml;
25 | size_t maxAlloc, exprSize, xmlSize;
26 |
27 | if (size > 10000)
28 | return(0);
29 |
30 | xmlFuzzDataInit(data, size);
31 |
32 | maxAlloc = xmlFuzzReadInt(4) % (size + 1);
33 | expr = xmlFuzzReadString(&exprSize);
34 | xml = xmlFuzzReadString(&xmlSize);
35 |
36 | /* Recovery mode allows more input to be fuzzed. */
37 | doc = xmlReadMemory(xml, xmlSize, NULL, NULL, XML_PARSE_RECOVER);
38 | if (doc != NULL) {
39 | xmlXPathContextPtr xpctxt;
40 |
41 | xmlFuzzMemSetLimit(maxAlloc);
42 |
43 | xpctxt = xmlXPathNewContext(doc);
44 | if (xpctxt != NULL) {
45 | /* Operation limit to avoid timeout */
46 | xpctxt->opLimit = 500000;
47 |
48 | xmlXPathFreeObject(xmlXPtrEval(BAD_CAST expr, xpctxt));
49 | xmlXPathFreeContext(xpctxt);
50 | }
51 |
52 | xmlFuzzMemSetLimit(0);
53 | xmlFreeDoc(doc);
54 | }
55 |
56 | xmlFuzzDataCleanup();
57 | xmlResetLastError();
58 |
59 | return(0);
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/upstream/fuzz/uri.c:
--------------------------------------------------------------------------------
1 | /*
2 | * uri.c: a libFuzzer target to test the URI module.
3 | *
4 | * See Copyright for the status of this software.
5 | */
6 |
7 | #include
8 | #include "fuzz.h"
9 |
10 | int
11 | LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
12 | char ***argv ATTRIBUTE_UNUSED) {
13 | xmlFuzzMemSetup();
14 | xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
15 |
16 | return 0;
17 | }
18 |
19 | int
20 | LLVMFuzzerTestOneInput(const char *data, size_t size) {
21 | xmlURIPtr uri;
22 | size_t maxAlloc;
23 | const char *str1, *str2;
24 | char *copy;
25 |
26 | if (size > 10000)
27 | return(0);
28 |
29 | xmlFuzzDataInit(data, size);
30 | maxAlloc = xmlFuzzReadInt(4) % (size * 8 + 1);
31 | str1 = xmlFuzzReadString(NULL);
32 | str2 = xmlFuzzReadString(NULL);
33 |
34 | xmlFuzzMemSetLimit(maxAlloc);
35 |
36 | uri = xmlParseURI(str1);
37 | xmlFree(xmlSaveUri(uri));
38 | xmlFreeURI(uri);
39 |
40 | uri = xmlParseURIRaw(str1, 1);
41 | xmlFree(xmlSaveUri(uri));
42 | xmlFreeURI(uri);
43 |
44 | xmlFree(xmlURIUnescapeString(str1, -1, NULL));
45 | xmlFree(xmlURIEscape(BAD_CAST str1));
46 | xmlFree(xmlCanonicPath(BAD_CAST str1));
47 | xmlFree(xmlPathToURI(BAD_CAST str1));
48 |
49 | xmlFree(xmlBuildURI(BAD_CAST str2, BAD_CAST str1));
50 | xmlFree(xmlBuildRelativeURI(BAD_CAST str2, BAD_CAST str1));
51 | xmlFree(xmlURIEscapeStr(BAD_CAST str1, BAD_CAST str2));
52 |
53 | copy = (char *) xmlCharStrdup(str1);
54 | xmlNormalizeURIPath(copy);
55 | xmlFree(copy);
56 |
57 | xmlFuzzMemSetLimit(0);
58 | xmlFuzzDataCleanup();
59 |
60 | return 0;
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/upstream/libxml.h:
--------------------------------------------------------------------------------
1 | /*
2 | * libxml.h: internal header only used during the compilation of libxml
3 | *
4 | * See COPYRIGHT for the status of this software
5 | *
6 | * Author: breese@users.sourceforge.net
7 | */
8 |
9 | #ifndef __XML_LIBXML_H__
10 | #define __XML_LIBXML_H__
11 |
12 | /*
13 | * These macros must be defined before including system headers.
14 | * Do not add any #include directives above this block.
15 | */
16 | #ifndef NO_LARGEFILE_SOURCE
17 | #ifndef _LARGEFILE_SOURCE
18 | #define _LARGEFILE_SOURCE
19 | #endif
20 | #ifndef _FILE_OFFSET_BITS
21 | #define _FILE_OFFSET_BITS 64
22 | #endif
23 | #endif
24 |
25 | /*
26 | * These files are generated by the build system and contain private
27 | * and public build configuration.
28 | */
29 | #include "config.h"
30 | #include
31 |
32 | /*
33 | * Due to some Autotools limitations, this variable must be passed as
34 | * compiler flag. Define a default value if the macro wasn't set by the
35 | * build system.
36 | */
37 | #ifndef SYSCONFDIR
38 | #define SYSCONFDIR "/etc"
39 | #endif
40 |
41 | #ifdef WITH_TRIO
42 | #define TRIO_REPLACE_STDIO
43 | #include "trio.h"
44 | #endif
45 |
46 | #if !defined(_WIN32) && \
47 | !defined(__CYGWIN__) && \
48 | (defined(__clang__) || \
49 | (defined(__GNUC__) && (__GNUC__ >= 4)))
50 | #define XML_HIDDEN __attribute__((visibility("hidden")))
51 | #else
52 | #define XML_HIDDEN
53 | #endif
54 |
55 | #if defined(__clang__) || \
56 | (defined(__GNUC__) && (__GNUC__ >= 8))
57 | #define ATTRIBUTE_NO_SANITIZE(arg) __attribute__((no_sanitize(arg)))
58 | #else
59 | #define ATTRIBUTE_NO_SANITIZE(arg)
60 | #endif
61 |
62 | #endif /* ! __XML_LIBXML_H__ */
63 |
--------------------------------------------------------------------------------
/upstream/python/tests/compareNodes.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | import libxml2
4 |
5 | # Memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | #
9 | # Testing XML Node comparison and Node hash-value
10 | #
11 | doc = libxml2.parseDoc("""""")
12 | root = doc.getRootElement()
13 |
14 | # Create two different objects which point to foo
15 | foonode1 = root.children
16 | foonode2 = root.children
17 |
18 | # Now check that [in]equality tests work ok
19 | if not ( foonode1 == foonode2 ):
20 | print("Error comparing nodes with ==, nodes should be equal but are unequal")
21 | sys.exit(1)
22 | if not ( foonode1 != root ):
23 | print("Error comparing nodes with ==, nodes should not be equal but are equal")
24 | sys.exit(1)
25 | if not ( foonode1 != root ):
26 | print("Error comparing nodes with !=, nodes should not be equal but are equal")
27 | if ( foonode1 != foonode2 ):
28 | print("Error comparing nodes with !=, nodes should be equal but are unequal")
29 |
30 | # Next check that the hash function for the objects also works ok
31 | if not (hash(foonode1) == hash(foonode2)):
32 | print("Error hash values for two equal nodes are different")
33 | sys.exit(1)
34 | if not (hash(foonode1) != hash(root)):
35 | print("Error hash values for two unequal nodes are not different")
36 | sys.exit(1)
37 | if hash(foonode1) == hash(root):
38 | print("Error hash values for two unequal nodes are equal")
39 | sys.exit(1)
40 |
41 | # Basic tests successful
42 | doc.freeDoc()
43 |
44 | # Memory debug specific
45 | libxml2.cleanupParser()
46 | if libxml2.debugMemory(1) == 0:
47 | print("OK")
48 | else:
49 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
50 |
--------------------------------------------------------------------------------
/upstream/python/tests/tstxpath.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | import libxml2
4 |
5 | #memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | called = ""
9 |
10 | def foo(ctx, x):
11 | global called
12 |
13 | #
14 | # test that access to the XPath evaluation contexts
15 | #
16 | pctxt = libxml2.xpathParserContext(_obj=ctx)
17 | ctxt = pctxt.context()
18 | called = ctxt.function()
19 | return x + 1
20 |
21 | def bar(ctxt, x):
22 | return "%d" % (x + 2)
23 |
24 | doc = libxml2.parseFile("tst.xml")
25 | ctxt = doc.xpathNewContext()
26 | res = ctxt.xpathEval("//*")
27 | if len(res) != 2:
28 | print("xpath query: wrong node set size")
29 | sys.exit(1)
30 | if res[0].name != "doc" or res[1].name != "foo":
31 | print("xpath query: wrong node set value")
32 | sys.exit(1)
33 | libxml2.registerXPathFunction(ctxt._o, "foo", None, foo)
34 | libxml2.registerXPathFunction(ctxt._o, "bar", None, bar)
35 | i = 10000
36 | while i > 0:
37 | res = ctxt.xpathEval("foo(1)")
38 | if res != 2:
39 | print("xpath extension failure")
40 | sys.exit(1)
41 | i = i - 1
42 | i = 10000
43 | while i > 0:
44 | res = ctxt.xpathEval("bar(1)")
45 | if res != "3":
46 | print("xpath extension failure got %s expecting '3'")
47 | sys.exit(1)
48 | i = i - 1
49 | doc.freeDoc()
50 | ctxt.xpathFreeContext()
51 |
52 | if called != "foo":
53 | print("xpath function: failed to access the context")
54 | print("xpath function: %s" % (called))
55 | sys.exit(1)
56 |
57 | #memory debug specific
58 | libxml2.cleanupParser()
59 | if libxml2.debugMemory(1) == 0:
60 | print("OK")
61 | else:
62 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
63 |
--------------------------------------------------------------------------------
/upstream/python/tests/pushSAX.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | import libxml2
4 |
5 | # Memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | log = ""
9 |
10 | class callback:
11 | def startDocument(self):
12 | global log
13 | log = log + "startDocument:"
14 |
15 | def endDocument(self):
16 | global log
17 | log = log + "endDocument:"
18 |
19 | def startElement(self, tag, attrs):
20 | global log
21 | log = log + "startElement %s %s:" % (tag, attrs)
22 |
23 | def endElement(self, tag):
24 | global log
25 | log = log + "endElement %s:" % (tag)
26 |
27 | def characters(self, data):
28 | global log
29 | log = log + "characters: %s:" % (data)
30 |
31 | def warning(self, msg):
32 | global log
33 | log = log + "warning: %s:" % (msg)
34 |
35 | def error(self, msg):
36 | global log
37 | log = log + "error: %s:" % (msg)
38 |
39 | def fatalError(self, msg):
40 | global log
41 | log = log + "fatalError: %s:" % (msg)
42 |
43 | handler = callback()
44 |
45 | ctxt = libxml2.createPushParser(handler, "
24 | # Copyright (c) 2011 Maarten Bosmans
25 | #
26 | # Copying and distribution of this file, with or without modification, are
27 | # permitted in any medium without royalty provided the copyright notice
28 | # and this notice are preserved. This file is offered as-is, without any
29 | # warranty.
30 |
31 | #serial 8
32 |
33 | AC_DEFUN([AX_APPEND_FLAG],
34 | [dnl
35 | AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
36 | AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
37 | AS_VAR_SET_IF(FLAGS,[
38 | AS_CASE([" AS_VAR_GET(FLAGS) "],
39 | [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
40 | [
41 | AS_VAR_APPEND(FLAGS,[" $1"])
42 | AC_RUN_LOG([: FLAGS="$FLAGS"])
43 | ])
44 | ],
45 | [
46 | AS_VAR_SET(FLAGS,[$1])
47 | AC_RUN_LOG([: FLAGS="$FLAGS"])
48 | ])
49 | AS_VAR_POPDEF([FLAGS])dnl
50 | ])dnl AX_APPEND_FLAG
51 |
--------------------------------------------------------------------------------
/upstream/python/tests/build.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import libxml2
3 | import sys
4 |
5 | # Memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | doc = libxml2.newDoc("1.0")
9 | comment = doc.newDocComment("This is a generated document")
10 | doc.addChild(comment)
11 | pi = libxml2.newPI("test", "PI content")
12 | doc.addChild(pi)
13 | root = doc.newChild(None, "doc", None)
14 | ns = root.newNs("http://example.com/doc", "my")
15 | root.setNs(ns)
16 | elem = root.newChild(None, "foo", "bar")
17 | elem.setBase("http://example.com/imgs")
18 | elem.setProp("img", "image.gif")
19 | doc.saveFile("tmp.xml")
20 | doc.freeDoc()
21 |
22 | doc = libxml2.parseFile("tmp.xml")
23 | comment = doc.children
24 | if comment.type != "comment" or \
25 | comment.content != "This is a generated document":
26 | print("error rereading comment")
27 | sys.exit(1)
28 | pi = comment.next
29 | if pi.type != "pi" or pi.name != "test" or pi.content != "PI content":
30 | print("error rereading PI")
31 | sys.exit(1)
32 | root = pi.next
33 | if root.name != "doc":
34 | print("error rereading root")
35 | sys.exit(1)
36 | ns = root.ns()
37 | if ns.name != "my" or ns.content != "http://example.com/doc":
38 | print("error rereading namespace")
39 | sys.exit(1)
40 | elem = root.children
41 | if elem.name != "foo":
42 | print("error rereading elem")
43 | sys.exit(1)
44 | if elem.getBase(None) != "http://example.com/imgs":
45 | print("error rereading base")
46 | sys.exit(1)
47 | if elem.prop("img") != "image.gif":
48 | print("error rereading property")
49 | sys.exit(1)
50 |
51 | doc.freeDoc()
52 |
53 | # Memory debug specific
54 | libxml2.cleanupParser()
55 | if libxml2.debugMemory(1) == 0:
56 | print("OK")
57 | else:
58 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
59 |
--------------------------------------------------------------------------------
/upstream/libxml2.doap:
--------------------------------------------------------------------------------
1 |
6 |
7 | libxml2
8 | XML parser and markup toolkit
9 | Libxml2 is the XML C parser and toolkit developed for the Gnome
10 | project (but usable outside of the Gnome platform), it is free software
11 | available under the MIT License. XML itself is a metalanguage to design markup
12 | languages, i.e. text language where semantic and structure are added to the
13 | content using extra "markup" information enclosed between angle brackets. HTML
14 | is the most well-known markup language. Though the library is written in C a
15 | variety of language bindings make it available in other environments.
16 |
17 | Libxml2 is known to be very portable, the library should build and work
18 | without serious troubles on a variety of systems (Linux, Unix, Windows,
19 | CygWin, MacOS X, RISC Os, OS/2, VMS, QNX, MVS,
20 | ...)
21 |
22 |
23 | C
24 |
25 |
26 |
27 | Daniel Veillard
28 | veillard
29 |
30 |
31 |
32 |
33 | Nick Wellnhofer
34 | nwellnhof
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/upstream/python/tests/nsdel.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # this test exercise the XPath basic engine, parser, etc, and
4 | # allows to detect memory leaks
5 | #
6 | import sys
7 | import libxml2
8 |
9 | instance="""
10 | """
11 |
12 | def namespaceDefs(node):
13 | n = node.nsDefs()
14 | while n:
15 | yield n
16 | n = n.next
17 |
18 | def checkNamespaceDefs(node, count):
19 | nsList = list(namespaceDefs(node))
20 | #print nsList
21 | if len(nsList) != count :
22 | raise Exception("Error: saw %d namespace declarations. Expected %d" % (len(nsList), count))
23 |
24 | # Memory debug specific
25 | libxml2.debugMemory(1)
26 |
27 | # Remove single namespace
28 | doc = libxml2.parseDoc(instance)
29 | node = doc.getRootElement()
30 | checkNamespaceDefs(node, 3)
31 | ns = node.removeNsDef('urn:bar')
32 | checkNamespaceDefs(node, 2)
33 | ns.freeNsList()
34 | doc.freeDoc()
35 |
36 | # Remove all namespaces
37 | doc = libxml2.parseDoc(instance)
38 | node = doc.getRootElement()
39 | checkNamespaceDefs(node, 3)
40 | ns = node.removeNsDef(None)
41 | checkNamespaceDefs(node, 0)
42 | ns.freeNsList()
43 | doc.freeDoc()
44 |
45 | # Remove a namespace referred to by a child
46 | doc = libxml2.newDoc("1.0")
47 | root = doc.newChild(None, "root", None)
48 | namespace = root.newNs("http://example.com/sample", "s")
49 | child = root.newChild(namespace, "child", None)
50 | root.removeNsDef("http://example.com/sample")
51 | doc.reconciliateNs(root)
52 | namespace.freeNsList()
53 | doc.serialize() # This should not segfault
54 | doc.freeDoc()
55 |
56 | # Memory debug specific
57 | libxml2.cleanupParser()
58 | if libxml2.debugMemory(1) == 0:
59 | print("OK")
60 | else:
61 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
62 |
--------------------------------------------------------------------------------
/upstream/MAINTAINERS.md:
--------------------------------------------------------------------------------
1 | # Maintainer's Guide
2 |
3 | ## Making a release
4 |
5 | ### Rebuild generated files and documentation
6 |
7 | The documentation and some generated files can be rebuilt by running
8 |
9 | make -C doc rebuild
10 |
11 | This requires `xsltproc` and the libxml2 Python bindings to be installed.
12 |
13 | ### Update the NEWS file
14 |
15 | You can get started by running
16 |
17 | git log --format='- %s (%an)' [previous-release-tag]..
18 |
19 | ### Bump the version number
20 |
21 | Edit the version number in `configure.ac` if you haven't done so already.
22 |
23 | ### Build the tarball
24 |
25 | I'd recommend to build the tarball by running
26 |
27 | make distcheck
28 |
29 | which performs some useful checks as well.
30 |
31 | ### Upload the tarball
32 |
33 | Follow the instructions at
34 | :
35 |
36 | scp libxml2-[version].tar.xz master.gnome.org:
37 | ssh master.gnome.org ftpadmin install libxml2-[version].tar.xz
38 |
39 | ### Tag the release
40 |
41 | Create an annotated tag and push it:
42 |
43 | git tag -a [version] -m 'Release [version]'
44 | git push origin [version]
45 |
46 | ### Create a GitLab release
47 |
48 | Create a new GitLab release on
49 | .
50 |
51 | ### Announce the release
52 |
53 | Announce the release by sending an email to the mailing list at
54 | xml@gnome.org.
55 |
56 | ## Updating the CI Docker image
57 |
58 | Note that the CI image is used for libxslt as well. Run the following
59 | commands with the Dockerfile in the .gitlab-ci directory:
60 |
61 | docker login registry.gitlab.gnome.org
62 | docker build -t registry.gitlab.gnome.org/gnome/libxml2 - \
63 | < .gitlab-ci/Dockerfile
64 | docker push registry.gitlab.gnome.org/gnome/libxml2
65 |
66 |
--------------------------------------------------------------------------------
/upstream/example/gjobs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | GBackup
8 | Development
9 |
10 |
11 | Open
12 | Mon, 07 Jun 1999 20:27:45 -0400 MET DST
13 | USD 0.00
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Nathan Clemons
23 | nathan@windsofstorm.net
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | The program should be released as free software, under the GPL.
38 |
39 |
40 |
41 |
42 |
43 |
44 | A GNOME based system that will allow a superuser to configure
45 | compressed and uncompressed files and/or file systems to be backed
46 | up with a supported media in the system. This should be able to
47 | perform via find commands generating a list of files that are passed
48 | to tar, dd, cpio, cp, gzip, etc., to be directed to the tape machine
49 | or via operations performed on the filesystem itself. Email
50 | notification and GUI status display very important.
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/upstream/python/tests/pushSAXhtml.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | import libxml2
4 |
5 | # Memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | log = ""
9 |
10 | class callback:
11 | def startDocument(self):
12 | global log
13 | log = log + "startDocument:"
14 |
15 | def endDocument(self):
16 | global log
17 | log = log + "endDocument:"
18 |
19 | def startElement(self, tag, attrs):
20 | global log
21 | log = log + "startElement %s %s:" % (tag, attrs)
22 |
23 | def endElement(self, tag):
24 | global log
25 | log = log + "endElement %s:" % (tag)
26 |
27 | def characters(self, data):
28 | global log
29 | log = log + "characters: %s:" % (data)
30 |
31 | def warning(self, msg):
32 | global log
33 | log = log + "warning: %s:" % (msg)
34 |
35 | def error(self, msg):
36 | global log
37 | log = log + "error: %s:" % (msg)
38 |
39 | def fatalError(self, msg):
40 | global log
41 | log = log + "fatalError: %s:" % (msg)
42 |
43 | handler = callback()
44 |
45 | ctxt = libxml2.htmlCreatePushParser(handler, "
30 | #
31 | # Copying and distribution of this file, with or without modification, are
32 | # permitted in any medium without royalty provided the copyright notice
33 | # and this notice are preserved. This file is offered as-is, without any
34 | # warranty.
35 |
36 | #serial 7
37 |
38 | AC_DEFUN([AX_APPEND_LINK_FLAGS],
39 | [AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
40 | AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
41 | for flag in $1; do
42 | AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3], [$4])
43 | done
44 | ])dnl AX_APPEND_LINK_FLAGS
45 |
--------------------------------------------------------------------------------
/upstream/.gitlab-ci/Test-Msvc.ps1:
--------------------------------------------------------------------------------
1 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
2 |
3 | if (-not (Test-Path cmake-$Env:CMAKE_VERSION-win64-x64)) {
4 | Invoke-WebRequest `
5 | -Uri http://github.com/Kitware/CMake/releases/download/v$Env:CMAKE_VERSION/cmake-$Env:CMAKE_VERSION-win64-x64.zip `
6 | -OutFile cmake-$Env:CMAKE_VERSION-win64-x64.zip
7 | Expand-Archive cmake-$Env:CMAKE_VERSION-win64-x64.zip -DestinationPath .
8 | }
9 | $Env:Path="$Env:CI_PROJECT_DIR\cmake-$Env:CMAKE_VERSION-win64-x64\bin;$Env:Path"
10 |
11 | if (-not (Test-Path 7za.exe)) {
12 | Invoke-WebRequest `
13 | -Uri https://www.7-zip.org/a/7z1900-extra.7z `
14 | -OutFile 7z1900-extra.7z
15 | cmake -E tar xf 7z1900-extra.7z 7za.exe
16 | }
17 |
18 | if (-not (Test-Path libxml2-build/xmlconf)) {
19 | Invoke-WebRequest `
20 | -Uri https://www.w3.org/XML/Test/xmlts20080827.tar.gz `
21 | -OutFile xmlts20080827.tar.gz ;
22 | .\7za.exe x xmlts20080827.tar.gz -olibxml2-build
23 | }
24 |
25 | cmake `
26 | -DBUILD_SHARED_LIBS="$Env:BUILD_SHARED_LIBS" `
27 | -DCMAKE_INSTALL_PREFIX=libxml2-install `
28 | -DLIBXML2_WITH_ICONV=OFF `
29 | -DLIBXML2_WITH_LZMA=OFF `
30 | -DLIBXML2_WITH_PYTHON=OFF `
31 | -DLIBXML2_WITH_ZLIB=OFF `
32 | -S . -B libxml2-build
33 | cmake --build libxml2-build --config Debug --target install
34 | cmake --build libxml2-build --config Release --target install
35 | New-Item -ItemType Directory libxml2-install\share\libxml2
36 | Copy-Item Copyright libxml2-install\share\libxml2
37 |
38 | cd libxml2-build
39 | ctest -C Debug -VV
40 | if ($LastExitCode -ne 0) {
41 | throw "ctest failed"
42 | }
43 | ctest -C Release -VV
44 | if ($LastExitCode -ne 0) {
45 | throw "ctest failed"
46 | }
47 | cd ..
48 |
49 | .\7za.exe a libxml2-$Env:CI_COMMIT_SHORT_SHA-$Env:CMAKE_GENERATOR_TOOLSET-$Env:CMAKE_GENERATOR_PLATFORM-$Env:SUFFIX.7z .\libxml2-install\*
50 |
--------------------------------------------------------------------------------
/upstream/python/tests/Makefile.am:
--------------------------------------------------------------------------------
1 | exampledir = $(docdir)/python/examples
2 | dist_example_DATA = $(PYTESTS) $(XMLS)
3 |
4 | PYTESTS= \
5 | build.py \
6 | attribs.py \
7 | tst.py \
8 | tstxpath.py \
9 | xpathext.py \
10 | push.py \
11 | pushSAX.py \
12 | pushSAXhtml.py \
13 | error.py \
14 | serialize.py\
15 | validate.py \
16 | tstURI.py \
17 | cutnpaste.py\
18 | xpathret.py \
19 | xpath.py \
20 | outbuf.py \
21 | inbuf.py \
22 | input_callback.py \
23 | resolver.py \
24 | regexp.py \
25 | reader.py \
26 | reader2.py \
27 | reader3.py \
28 | reader4.py \
29 | reader5.py \
30 | reader6.py \
31 | reader7.py \
32 | reader8.py \
33 | readernext.py \
34 | walker.py \
35 | nsdel.py \
36 | ctxterror.py\
37 | readererr.py\
38 | relaxng.py \
39 | schema.py \
40 | thread2.py \
41 | sync.py \
42 | tstLastError.py \
43 | indexes.py \
44 | dtdvalid.py \
45 | tstmem.py \
46 | validDTD.py \
47 | validSchemas.py \
48 | validRNG.py \
49 | compareNodes.py \
50 | xpathns.py \
51 | xpathleak.py
52 |
53 | XMLS= \
54 | tst.xml \
55 | valid.xml \
56 | invalid.xml \
57 | test.dtd
58 |
59 | CLEANFILES = core tmp.xml *.pyc
60 |
61 | if WITH_PYTHON
62 | check-local:
63 | @for f in $(XMLS) ; do test -f $$f || $(LN_S) $(srcdir)/$$f . ; done
64 | @echo "## running Python regression tests"
65 | @(export PYTHONPATH="..:../.libs:$(srcdir)/..:$$PYTHONPATH" ; \
66 | export LD_LIBRARY_PATH="$(top_builddir)/.libs:$$LD_LIBRARY_PATH" ; \
67 | export DYLD_LIBRARY_PATH="$(top_builddir)/.libs:$$DYLD_LIBRARY_PATH" ; \
68 | export PATH="$(top_builddir)/.libs:$$PATH" ; \
69 | for test in $(PYTESTS) ; do \
70 | log=`$(PYTHON) $(srcdir)/$$test` ; \
71 | if [ "$$?" -ne 0 ] ; then \
72 | echo "-- $$test" ; \
73 | echo "$$log" ; \
74 | exit 1 ; \
75 | fi ; \
76 | done)
77 | endif
78 |
--------------------------------------------------------------------------------
/upstream/os400/wrappers.h:
--------------------------------------------------------------------------------
1 | /**
2 | *** Replace system/C library calls by EBCDIC wrappers.
3 | *** This is a layer inserted between libxml2 itself and the EBCDIC
4 | *** environment.
5 | ***
6 | *** See Copyright for the status of this software.
7 | ***
8 | *** Author: Patrick Monnerat , DATASPHERE S.A.
9 | **/
10 |
11 | #ifndef __WRAPPERS_H_
12 | #define __WRAPPERS_H_
13 |
14 | /**
15 | *** OS/400 specific defines.
16 | **/
17 |
18 | #define __cplusplus__strings__
19 |
20 | /**
21 | *** Force header inclusions before renaming procedures to UTF-8 wrappers.
22 | **/
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | #include "dlfcn.h"
30 |
31 |
32 | /**
33 | *** UTF-8 wrappers prototypes.
34 | **/
35 |
36 | extern int _lx_getaddrinfo(const char * node, const char * service,
37 | const struct addrinfo * hints, struct addrinfo * * res);
38 | extern const char *
39 | _lx_inet_ntop(int af,
40 | const void * src, char * dst, socklen_t size);
41 | extern void * _lx_dlopen(const char * filename, int flag);
42 | extern void * _lx_dlsym(void * handle, const char * symbol);
43 | extern char * _lx_dlerror(void);
44 |
45 |
46 | #ifdef LIBXML_ZLIB_ENABLED
47 |
48 | #include
49 |
50 | extern gzFile _lx_gzopen(const char * path, const char * mode);
51 | extern gzFile _lx_gzdopen(int fd, const char * mode);
52 |
53 | #endif
54 |
55 |
56 | /**
57 | *** Rename data/procedures to UTF-8 wrappers.
58 | **/
59 |
60 | #define getaddrinfo _lx_getaddrinfo
61 | #define inet_ntop _lx_inet_ntop
62 | #define dlopen _lx_dlopen
63 | #define dlsym _lx_dlsym
64 | #define dlerror _lx_dlerror
65 | #define gzopen _lx_gzopen
66 | #define gzdopen _lx_gzdopen
67 | #define inflateInit2_ _lx_inflateInit2_
68 | #define deflateInit2_ _lx_deflateInit2_
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/upstream/fuzz/xpath.dict:
--------------------------------------------------------------------------------
1 | # XML
2 |
3 | elem_a=""
4 | elem_b=""
5 | elem_c=""
6 | elem_d=""
7 | elem_empty=""
8 | elem_ns_a=""
9 | elem_ns_b=""
10 |
11 | attr_a=" a='a'"
12 | attr_b=" b='b'"
13 |
14 | ns_decl=" xmlns:a='a'"
15 | ns_default=" xmlns='a'"
16 | ns_prefix_a="a:"
17 | ns_prefix_b="b:"
18 |
19 | cdata_section=""
20 |
21 | comment=""
22 |
23 | pi=""
24 |
25 | # XPath
26 |
27 | axis_ancestor="ancestor::"
28 | axis_ancestor_or_self="ancestor-or-self::"
29 | axis_attribute="attribute::"
30 | axis_attribute_abbrev="@"
31 | axis_child="child::"
32 | axis_descendant="descendant::"
33 | axis_descendant_or_self="descendant-or-self::"
34 | axis_following="following::"
35 | axis_following_sibling="following-sibling::"
36 | axis_namespace="namespace::"
37 | axis_parent="parent::"
38 | axis_preceding="preceding::"
39 | axis_preceding_siblings="preceding-sibling::"
40 | axis_self="self::"
41 |
42 | node_test_ns="a:"
43 |
44 | val_num="=(1.0)"
45 | val_str_sq="=('a')"
46 | val_str_dq="=(\"a\")"
47 | val_node_set="=(*)"
48 | val_elem="=(b)"
49 |
50 | step_root="/"
51 | step_descendant="//"
52 | step_any="//*"
53 | step_any_l="*//"
54 | step_elem="//b"
55 | step_ns_elem="//a:a"
56 | step_comment="//comment()"
57 | step_node="//node()"
58 | step_node_l="node()//"
59 | step_pi="//processing-instruction()"
60 | step_text="//text()"
61 | step_parent="../"
62 |
63 | op_plus="+1"
64 | op_minus=" - 1"
65 | op_neg="-"
66 | op_mul="*1"
67 | op_div=" div 1"
68 | op_mod=" mod 1"
69 | op_and=" and 1"
70 | op_or=" or 1"
71 | op_ne="!=1"
72 | op_lt="<1"
73 | op_gt=">1"
74 | op_le="<=1"
75 | op_ge=">=1"
76 | op_predicate_num="[1]"
77 | op_predicate_last="[last()]"
78 | op_predicate_str="['a']"
79 | op_predicate="[1=1]"
80 | op_arg_num=",1"
81 | op_arg_str=",'a'"
82 | op_arg_node=",*"
83 | op_union="|//b"
84 |
85 | var_num="=$f"
86 | var_bool="=$b"
87 | var_str="=$s"
88 | var_node_set="=$n"
89 |
90 | # Unicode
91 |
92 | utf8_2="\xC3\x84"
93 | utf8_3="\xE2\x80\x9C"
94 | utf8_4="\xF0\x9F\x98\x80"
95 |
--------------------------------------------------------------------------------
/upstream/python/tests/validate.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import sys
3 | import libxml2
4 |
5 | # Memory debug specific
6 | libxml2.debugMemory(1)
7 |
8 | ctxt = libxml2.createFileParserCtxt("valid.xml")
9 | ctxt.validate(1)
10 | ctxt.parseDocument()
11 | doc = ctxt.doc()
12 | valid = ctxt.isValid()
13 |
14 | if doc.name != "valid.xml":
15 | print("doc.name failed")
16 | sys.exit(1)
17 | root = doc.children
18 | if root.name != "doc":
19 | print("root.name failed")
20 | sys.exit(1)
21 | if valid != 1:
22 | print("validity chec failed")
23 | sys.exit(1)
24 | doc.freeDoc()
25 |
26 | i = 1000
27 | while i > 0:
28 | ctxt = libxml2.createFileParserCtxt("valid.xml")
29 | ctxt.validate(1)
30 | ctxt.parseDocument()
31 | doc = ctxt.doc()
32 | valid = ctxt.isValid()
33 | doc.freeDoc()
34 | if valid != 1:
35 | print("validity check failed")
36 | sys.exit(1)
37 | i = i - 1
38 |
39 | #deactivate error messages from the validation
40 | def noerr(ctx, str):
41 | pass
42 |
43 | libxml2.registerErrorHandler(noerr, None)
44 |
45 | ctxt = libxml2.createFileParserCtxt("invalid.xml")
46 | ctxt.validate(1)
47 | ctxt.parseDocument()
48 | doc = ctxt.doc()
49 | valid = ctxt.isValid()
50 | if doc.name != "invalid.xml":
51 | print("doc.name failed")
52 | sys.exit(1)
53 | root = doc.children
54 | if root.name != "doc":
55 | print("root.name failed")
56 | sys.exit(1)
57 | if valid != 0:
58 | print("validity chec failed")
59 | sys.exit(1)
60 | doc.freeDoc()
61 |
62 | i = 1000
63 | while i > 0:
64 | ctxt = libxml2.createFileParserCtxt("invalid.xml")
65 | ctxt.validate(1)
66 | ctxt.parseDocument()
67 | doc = ctxt.doc()
68 | valid = ctxt.isValid()
69 | doc.freeDoc()
70 | if valid != 0:
71 | print("validity check failed")
72 | sys.exit(1)
73 | i = i - 1
74 | del ctxt
75 |
76 | # Memory debug specific
77 | libxml2.cleanupParser()
78 | if libxml2.debugMemory(1) == 0:
79 | print("OK")
80 | else:
81 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
82 |
--------------------------------------------------------------------------------
/upstream/include/libxml/dict.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Summary: string dictionary
3 | * Description: dictionary of reusable strings, just used to avoid allocation
4 | * and freeing operations.
5 | *
6 | * Copy: See Copyright for the status of this software.
7 | *
8 | * Author: Daniel Veillard
9 | */
10 |
11 | #ifndef __XML_DICT_H__
12 | #define __XML_DICT_H__
13 |
14 | #include
15 | #include
16 |
17 | #ifdef __cplusplus
18 | extern "C" {
19 | #endif
20 |
21 | /*
22 | * The dictionary.
23 | */
24 | typedef struct _xmlDict xmlDict;
25 | typedef xmlDict *xmlDictPtr;
26 |
27 | /*
28 | * Initializer
29 | */
30 | XML_DEPRECATED
31 | XMLPUBFUN int xmlInitializeDict(void);
32 |
33 | /*
34 | * Constructor and destructor.
35 | */
36 | XMLPUBFUN xmlDictPtr
37 | xmlDictCreate (void);
38 | XMLPUBFUN size_t
39 | xmlDictSetLimit (xmlDictPtr dict,
40 | size_t limit);
41 | XMLPUBFUN size_t
42 | xmlDictGetUsage (xmlDictPtr dict);
43 | XMLPUBFUN xmlDictPtr
44 | xmlDictCreateSub(xmlDictPtr sub);
45 | XMLPUBFUN int
46 | xmlDictReference(xmlDictPtr dict);
47 | XMLPUBFUN void
48 | xmlDictFree (xmlDictPtr dict);
49 |
50 | /*
51 | * Lookup of entry in the dictionary.
52 | */
53 | XMLPUBFUN const xmlChar *
54 | xmlDictLookup (xmlDictPtr dict,
55 | const xmlChar *name,
56 | int len);
57 | XMLPUBFUN const xmlChar *
58 | xmlDictExists (xmlDictPtr dict,
59 | const xmlChar *name,
60 | int len);
61 | XMLPUBFUN const xmlChar *
62 | xmlDictQLookup (xmlDictPtr dict,
63 | const xmlChar *prefix,
64 | const xmlChar *name);
65 | XMLPUBFUN int
66 | xmlDictOwns (xmlDictPtr dict,
67 | const xmlChar *str);
68 | XMLPUBFUN int
69 | xmlDictSize (xmlDictPtr dict);
70 |
71 | /*
72 | * Cleanup function
73 | */
74 | XML_DEPRECATED
75 | XMLPUBFUN void
76 | xmlDictCleanup (void);
77 |
78 | #ifdef __cplusplus
79 | }
80 | #endif
81 | #endif /* ! __XML_DICT_H__ */
82 |
--------------------------------------------------------------------------------
/upstream/include/private/buf.h:
--------------------------------------------------------------------------------
1 | #ifndef XML_BUF_H_PRIVATE__
2 | #define XML_BUF_H_PRIVATE__
3 |
4 | #include
5 |
6 | XML_HIDDEN xmlBufPtr
7 | xmlBufCreate(void);
8 | XML_HIDDEN xmlBufPtr
9 | xmlBufCreateSize(size_t size);
10 |
11 | XML_HIDDEN int
12 | xmlBufSetAllocationScheme(xmlBufPtr buf, xmlBufferAllocationScheme scheme);
13 | XML_HIDDEN int
14 | xmlBufGetAllocationScheme(xmlBufPtr buf);
15 |
16 | XML_HIDDEN void
17 | xmlBufFree(xmlBufPtr buf);
18 | XML_HIDDEN void
19 | xmlBufEmpty(xmlBufPtr buf);
20 |
21 | /* size_t xmlBufShrink(xmlBufPtr buf, size_t len); */
22 | XML_HIDDEN int
23 | xmlBufGrow(xmlBufPtr buf, int len);
24 | XML_HIDDEN int
25 | xmlBufResize(xmlBufPtr buf, size_t len);
26 |
27 | XML_HIDDEN int
28 | xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len);
29 | XML_HIDDEN int
30 | xmlBufCat(xmlBufPtr buf, const xmlChar *str);
31 | XML_HIDDEN int
32 | xmlBufCCat(xmlBufPtr buf, const char *str);
33 | XML_HIDDEN int
34 | xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string);
35 |
36 | XML_HIDDEN size_t
37 | xmlBufAvail(const xmlBufPtr buf);
38 | XML_HIDDEN size_t
39 | xmlBufLength(const xmlBufPtr buf);
40 | /* size_t xmlBufUse(const xmlBufPtr buf); */
41 | XML_HIDDEN int
42 | xmlBufIsEmpty(const xmlBufPtr buf);
43 | XML_HIDDEN int
44 | xmlBufAddLen(xmlBufPtr buf, size_t len);
45 |
46 | /* const xmlChar * xmlBufContent(const xmlBuf *buf); */
47 | /* const xmlChar * xmlBufEnd(xmlBufPtr buf); */
48 |
49 | XML_HIDDEN xmlChar *
50 | xmlBufDetach(xmlBufPtr buf);
51 |
52 | XML_HIDDEN size_t
53 | xmlBufDump(FILE *file, xmlBufPtr buf);
54 |
55 | XML_HIDDEN xmlBufPtr
56 | xmlBufFromBuffer(xmlBufferPtr buffer);
57 | XML_HIDDEN xmlBufferPtr
58 | xmlBufBackToBuffer(xmlBufPtr buf);
59 | XML_HIDDEN int
60 | xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer);
61 |
62 | XML_HIDDEN int
63 | xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input);
64 | XML_HIDDEN size_t
65 | xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input);
66 | XML_HIDDEN int
67 | xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input,
68 | size_t base, size_t cur);
69 |
70 | #endif /* XML_BUF_H_PRIVATE__ */
71 |
--------------------------------------------------------------------------------
/upstream/m4/ax_check_link_flag.m4:
--------------------------------------------------------------------------------
1 | # ===========================================================================
2 | # https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
3 | # ===========================================================================
4 | #
5 | # SYNOPSIS
6 | #
7 | # AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
8 | #
9 | # DESCRIPTION
10 | #
11 | # Check whether the given FLAG works with the linker or gives an error.
12 | # (Warnings, however, are ignored)
13 | #
14 | # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
15 | # success/failure.
16 | #
17 | # If EXTRA-FLAGS is defined, it is added to the linker's default flags
18 | # when the check is done. The check is thus made with the flags: "LDFLAGS
19 | # EXTRA-FLAGS FLAG". This can for example be used to force the linker to
20 | # issue an error when a bad flag is given.
21 | #
22 | # INPUT gives an alternative input source to AC_LINK_IFELSE.
23 | #
24 | # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
25 | # macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
26 | #
27 | # LICENSE
28 | #
29 | # Copyright (c) 2008 Guido U. Draheim
30 | # Copyright (c) 2011 Maarten Bosmans
31 | #
32 | # Copying and distribution of this file, with or without modification, are
33 | # permitted in any medium without royalty provided the copyright notice
34 | # and this notice are preserved. This file is offered as-is, without any
35 | # warranty.
36 |
37 | #serial 6
38 |
39 | AC_DEFUN([AX_CHECK_LINK_FLAG],
40 | [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
41 | AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
42 | AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
43 | ax_check_save_flags=$LDFLAGS
44 | LDFLAGS="$LDFLAGS $4 $1"
45 | AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
46 | [AS_VAR_SET(CACHEVAR,[yes])],
47 | [AS_VAR_SET(CACHEVAR,[no])])
48 | LDFLAGS=$ax_check_save_flags])
49 | AS_VAR_IF(CACHEVAR,yes,
50 | [m4_default([$2], :)],
51 | [m4_default([$3], :)])
52 | AS_VAR_POPDEF([CACHEVAR])dnl
53 | ])dnl AX_CHECK_LINK_FLAGS
54 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # libxml2 built with Zig
2 |
3 | This project builds [libxml2](https://github.com/GNOME/libxml2.git)
4 | with Zig. These are _not Zig language bindings_ to the project. The goal of
5 | this project is to enable the upstream project to be used with the Zig
6 | package manager. Downstream users may also not be Zig language users, they
7 | may just be using Zig as a build system.
8 |
9 | This is not strictly a fork (the source for the upstream project is copied
10 | into the "upstream" directory unmodified unless noted). For security reasons,
11 | you can verify the contents using the `verify.sh` script. Please read the
12 | shell script contents, it is written in a plain way.
13 |
14 | I implore that you do not blindly trust me -- pin this repository to a
15 | specific version and verify the checksums match yourself.
16 |
17 | ## Usage
18 |
19 | Create a `build.zig.zon` like so:
20 |
21 | ```zig
22 | .{
23 | .name = "my-project",
24 | .version = "0.0.0",
25 | .dependencies = .{
26 | .libxml2 = .{
27 | .url = "https://github.com/mitchellh/zig-build-libxml2/archive/.tar.gz",
28 | .hash = "12208070233b17de6be05e32af096a6760682b48598323234824def41789e993432c",
29 | },
30 | },
31 | }
32 | ```
33 |
34 | And in your `build.zig`:
35 |
36 | ```zig
37 | const libxml2 = b.dependency("libxml2", .{ .target = target, .optimize = optimize });
38 | exe.linkLibrary(libxml2.artifact("xml2"));
39 | ```
40 |
41 | In your code you can now `@cImport` the project.
42 |
43 | ## Versions
44 |
45 | This project makes no guarantee to stay up to date with every released
46 | version of the upstream project. If you'd like to contribute a new version,
47 | please do and we will tag it accordingly.
48 |
49 | **The current version is always available in `upstream.txt`.** This is
50 | the Git commit hash of the "upstream" folder.
51 |
52 | ### Updating
53 |
54 | You can update to any arbitrary upstream Git ref using `update.sh`:
55 |
56 | ```
57 | $ ./update.sh HEAD
58 | ```
59 |
60 | ### Verify
61 |
62 | You can verify that the contents match upstream by running `verify.sh`:
63 |
64 | ```
65 | $ ./verify.sh
66 | ```
67 |
68 | An exit status of 0 means it was successful.
69 |
--------------------------------------------------------------------------------
/upstream/testModule.c:
--------------------------------------------------------------------------------
1 | /*
2 | * testModule.c : a small tester program for xmlModule
3 | *
4 | * See Copyright for the status of this software.
5 | *
6 | * joelwreed@comcast.net
7 | */
8 |
9 | #include "libxml.h"
10 | #ifdef LIBXML_MODULES_ENABLED
11 | #include
12 |
13 | #include
14 | #include
15 | #include
16 | #include
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #ifdef _WIN32
23 | #define MODULE_PATH "."
24 | #include /* for _MAX_PATH */
25 | #ifndef __MINGW32__
26 | #define PATH_MAX _MAX_PATH
27 | #endif
28 | #else
29 | #define MODULE_PATH ".libs"
30 | #endif
31 |
32 | /* Used for SCO Openserver*/
33 | #ifndef PATH_MAX
34 | #ifdef _POSIX_PATH_MAX
35 | #define PATH_MAX _POSIX_PATH_MAX
36 | #else
37 | #define PATH_MAX 4096
38 | #endif
39 | #endif
40 |
41 | typedef int (*hello_world_t)(void);
42 |
43 | int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
44 | xmlChar filename[PATH_MAX];
45 | xmlModulePtr module = NULL;
46 | hello_world_t hello_world = NULL;
47 |
48 | /* build the module filename, and confirm the module exists */
49 | xmlStrPrintf(filename, sizeof(filename),
50 | "%s/testdso%s",
51 | (const xmlChar*)MODULE_PATH,
52 | (const xmlChar*)LIBXML_MODULE_EXTENSION);
53 |
54 | module = xmlModuleOpen((const char*)filename, 0);
55 | if (module == NULL) {
56 | fprintf(stderr, "Failed to open module\n");
57 | return(1);
58 | }
59 |
60 | if (xmlModuleSymbol(module, "hello_world", (void **) &hello_world)) {
61 | fprintf(stderr, "Failure to lookup\n");
62 | return(1);
63 | }
64 | if (hello_world == NULL) {
65 | fprintf(stderr, "Lookup returned NULL\n");
66 | return(1);
67 | }
68 |
69 | (*hello_world)();
70 |
71 | xmlModuleClose(module);
72 |
73 | return(0);
74 | }
75 |
76 | #else
77 | #include
78 | int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
79 | printf("%s : Module support not compiled in\n", argv[0]);
80 | return(0);
81 | }
82 | #endif /* LIBXML_SCHEMAS_ENABLED */
83 |
--------------------------------------------------------------------------------
/upstream/include/libxml/nanohttp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Summary: minimal HTTP implementation
3 | * Description: minimal HTTP implementation allowing to fetch resources
4 | * like external subset.
5 | *
6 | * Copy: See Copyright for the status of this software.
7 | *
8 | * Author: Daniel Veillard
9 | */
10 |
11 | #ifndef __NANO_HTTP_H__
12 | #define __NANO_HTTP_H__
13 |
14 | #include
15 |
16 | #ifdef LIBXML_HTTP_ENABLED
17 |
18 | #ifdef __cplusplus
19 | extern "C" {
20 | #endif
21 | XMLPUBFUN void
22 | xmlNanoHTTPInit (void);
23 | XMLPUBFUN void
24 | xmlNanoHTTPCleanup (void);
25 | XMLPUBFUN void
26 | xmlNanoHTTPScanProxy (const char *URL);
27 | XMLPUBFUN int
28 | xmlNanoHTTPFetch (const char *URL,
29 | const char *filename,
30 | char **contentType);
31 | XMLPUBFUN void *
32 | xmlNanoHTTPMethod (const char *URL,
33 | const char *method,
34 | const char *input,
35 | char **contentType,
36 | const char *headers,
37 | int ilen);
38 | XMLPUBFUN void *
39 | xmlNanoHTTPMethodRedir (const char *URL,
40 | const char *method,
41 | const char *input,
42 | char **contentType,
43 | char **redir,
44 | const char *headers,
45 | int ilen);
46 | XMLPUBFUN void *
47 | xmlNanoHTTPOpen (const char *URL,
48 | char **contentType);
49 | XMLPUBFUN void *
50 | xmlNanoHTTPOpenRedir (const char *URL,
51 | char **contentType,
52 | char **redir);
53 | XMLPUBFUN int
54 | xmlNanoHTTPReturnCode (void *ctx);
55 | XMLPUBFUN const char *
56 | xmlNanoHTTPAuthHeader (void *ctx);
57 | XMLPUBFUN const char *
58 | xmlNanoHTTPRedir (void *ctx);
59 | XMLPUBFUN int
60 | xmlNanoHTTPContentLength( void * ctx );
61 | XMLPUBFUN const char *
62 | xmlNanoHTTPEncoding (void *ctx);
63 | XMLPUBFUN const char *
64 | xmlNanoHTTPMimeType (void *ctx);
65 | XMLPUBFUN int
66 | xmlNanoHTTPRead (void *ctx,
67 | void *dest,
68 | int len);
69 | #ifdef LIBXML_OUTPUT_ENABLED
70 | XMLPUBFUN int
71 | xmlNanoHTTPSave (void *ctxt,
72 | const char *filename);
73 | #endif /* LIBXML_OUTPUT_ENABLED */
74 | XMLPUBFUN void
75 | xmlNanoHTTPClose (void *ctx);
76 | #ifdef __cplusplus
77 | }
78 | #endif
79 |
80 | #endif /* LIBXML_HTTP_ENABLED */
81 | #endif /* __NANO_HTTP_H__ */
82 |
--------------------------------------------------------------------------------
/upstream/python/tests/validRNG.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import libxml2
3 | import sys
4 |
5 | ARG = 'test string'
6 |
7 | class ErrorHandler:
8 |
9 | def __init__(self):
10 | self.errors = []
11 |
12 | def handler(self, msg, data):
13 | if data != ARG:
14 | raise Exception("Error handler did not receive correct argument")
15 | self.errors.append(msg)
16 |
17 | # Memory debug specific
18 | libxml2.debugMemory(1)
19 |
20 | schema="""
21 |
26 | A foo element.
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | """
35 |
36 | valid="""
37 | """
38 |
39 | invalid="""
40 | bad"""
41 |
42 | rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
43 | rngs = rngp.relaxNGParse()
44 | ctxt = rngs.relaxNGNewValidCtxt()
45 | e = ErrorHandler()
46 | ctxt.setValidityErrorHandler(e.handler, e.handler, ARG)
47 |
48 | # Test valid document
49 | doc = libxml2.parseDoc(valid)
50 | ret = doc.relaxNGValidateDoc(ctxt)
51 | if ret != 0 or e.errors:
52 | print("error doing RelaxNG validation")
53 | sys.exit(1)
54 | doc.freeDoc()
55 |
56 | # Test invalid document
57 | doc = libxml2.parseDoc(invalid)
58 | ret = doc.relaxNGValidateDoc(ctxt)
59 | if ret == 0 or not e.errors:
60 | print("Error: document supposed to be RelaxNG invalid")
61 | sys.exit(1)
62 | doc.freeDoc()
63 |
64 | del rngp
65 | del rngs
66 | del ctxt
67 | libxml2.relaxNGCleanupTypes()
68 |
69 | # Memory debug specific
70 | libxml2.cleanupParser()
71 | if libxml2.debugMemory(1) == 0:
72 | print("OK")
73 | else:
74 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
75 |
76 |
--------------------------------------------------------------------------------
/upstream/fuzz/schema.dict:
--------------------------------------------------------------------------------
1 | # TODO: Add more language elements
2 |
3 | xs_annotation=""
4 |
5 | xs_attribute=""
6 | xs_attribute_required=""
7 | xs_element=""
8 |
9 | # Primitive datatypes
10 | type_string=" type='xs:string'"
11 | type_boolean=" type='xs:boolean'"
12 | type_decimal=" type='xs:decimal'"
13 | type_float=" type='xs:float'"
14 | type_double=" type='xs:double'"
15 | type_date_time=" type='xs:dateTime'"
16 | type_time=" type='xs:time'"
17 | type_date=" type='xs:date'"
18 | type_g_year_month=" type='xs:gYearMonth'"
19 | type_g_year=" type='xs:gYear'"
20 | type_g_month_day=" type='xs:gMonthDay'"
21 | type_g_day=" type='xs:gDay'"
22 | type_g_month=" type='xs:gMonth'"
23 | type_hex_binary=" type='xs:hexBinary'"
24 | type_base64_binary=" type='xs:base64Binary'"
25 | type_any_uri=" type='xs:anyURI'"
26 | type_qname=" type='xs:QName'"
27 | type_notation=" type='xs:NOTATION'"
28 |
29 | # Occurs
30 | occurs_min=" minOccurs='1'"
31 | occurs_max=" maxOccurs='9'"
32 | occurs_max_unbounded=" maxOccurs='unbounded'"
33 |
34 | # Simple type
35 | xs_restriction_integer=""
36 | xs_restriction_string=""
37 | xs_list=""
38 | xs_union=""
39 |
40 | # Restrictions
41 | xs_min_exclusive=""
42 | xs_min_inclusive=""
43 | xs_max_exclusive=""
44 | xs_max_inclusive=""
45 | xs_total_digits=""
46 | xs_fraction_digits=""
47 | xs_length=""
48 | xs_min_length=""
49 | xs_max_length=""
50 | xs_enumeration=""
51 | xs_white_space_collapse=""
52 | xs_white_space_preserve=""
53 | xs_white_space_replace=""
54 | xs_pattern=""
55 |
56 |
--------------------------------------------------------------------------------
/upstream/python/tests/reader7.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # this tests the entities substitutions with the XmlTextReader interface
4 | #
5 | import sys
6 | import libxml2
7 |
8 | # Memory debug specific
9 | libxml2.debugMemory(1)
10 |
11 | result = ""
12 | def processNode(reader):
13 | global result
14 |
15 | result = result + "%d %d %s %d\n" % (reader.Depth(), reader.NodeType(),
16 | reader.Name(), reader.IsEmptyElement())
17 |
18 | #
19 | # Parse a document testing the readerForxxx API
20 | #
21 | docstr="""
22 |
23 | - 100
24 | """
25 | expect="""0 1 foo 0
26 | 1 14 #text 0
27 | 1 1 label 0
28 | 2 3 #text 0
29 | 1 15 label 0
30 | 1 14 #text 0
31 | 1 1 item 0
32 | 2 3 #text 0
33 | 1 15 item 0
34 | 1 14 #text 0
35 | 0 15 foo 0
36 | """
37 | result = ""
38 |
39 | reader = libxml2.readerForDoc(docstr, "test1", None, 0)
40 | ret = reader.Read()
41 | while ret == 1:
42 | processNode(reader)
43 | ret = reader.Read()
44 |
45 | if ret != 0:
46 | print("Error parsing the document test1")
47 | sys.exit(1)
48 |
49 | if result != expect:
50 | print("Unexpected result for test1")
51 | print(result)
52 | sys.exit(1)
53 |
54 | #
55 | # Reuse the reader for another document testing the ReaderNewxxx API
56 | #
57 | docstr="""
58 |
59 | - 1000
60 | """
61 | expect="""0 1 foo 0
62 | 1 14 #text 0
63 | 1 1 label 0
64 | 2 3 #text 0
65 | 1 15 label 0
66 | 1 14 #text 0
67 | 1 1 item 0
68 | 2 3 #text 0
69 | 1 15 item 0
70 | 1 14 #text 0
71 | 0 15 foo 0
72 | """
73 | result = ""
74 |
75 | reader.NewDoc(docstr, "test2", None, 0)
76 | ret = reader.Read()
77 | while ret == 1:
78 | processNode(reader)
79 | ret = reader.Read()
80 |
81 | if ret != 0:
82 | print("Error parsing the document test2")
83 | sys.exit(1)
84 |
85 | if result != expect:
86 | print("Unexpected result for test2")
87 | print(result)
88 | sys.exit(1)
89 |
90 | #
91 | # cleanup
92 | #
93 | del reader
94 |
95 | # Memory debug specific
96 | libxml2.cleanupParser()
97 | if libxml2.debugMemory(1) == 0:
98 | print("OK")
99 | else:
100 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
101 |
--------------------------------------------------------------------------------
/upstream/include/libxml/threads.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Summary: interfaces for thread handling
3 | * Description: set of generic threading related routines
4 | * should work with pthreads, Windows native or TLS threads
5 | *
6 | * Copy: See Copyright for the status of this software.
7 | *
8 | * Author: Daniel Veillard
9 | */
10 |
11 | #ifndef __XML_THREADS_H__
12 | #define __XML_THREADS_H__
13 |
14 | #include
15 |
16 | #ifdef __cplusplus
17 | extern "C" {
18 | #endif
19 |
20 | /*
21 | * xmlMutex are a simple mutual exception locks.
22 | */
23 | typedef struct _xmlMutex xmlMutex;
24 | typedef xmlMutex *xmlMutexPtr;
25 |
26 | /*
27 | * xmlRMutex are reentrant mutual exception locks.
28 | */
29 | typedef struct _xmlRMutex xmlRMutex;
30 | typedef xmlRMutex *xmlRMutexPtr;
31 |
32 | #ifdef __cplusplus
33 | }
34 | #endif
35 | #include
36 | #ifdef __cplusplus
37 | extern "C" {
38 | #endif
39 | XMLPUBFUN xmlMutexPtr
40 | xmlNewMutex (void);
41 | XMLPUBFUN void
42 | xmlMutexLock (xmlMutexPtr tok);
43 | XMLPUBFUN void
44 | xmlMutexUnlock (xmlMutexPtr tok);
45 | XMLPUBFUN void
46 | xmlFreeMutex (xmlMutexPtr tok);
47 |
48 | XMLPUBFUN xmlRMutexPtr
49 | xmlNewRMutex (void);
50 | XMLPUBFUN void
51 | xmlRMutexLock (xmlRMutexPtr tok);
52 | XMLPUBFUN void
53 | xmlRMutexUnlock (xmlRMutexPtr tok);
54 | XMLPUBFUN void
55 | xmlFreeRMutex (xmlRMutexPtr tok);
56 |
57 | /*
58 | * Library wide APIs.
59 | */
60 | XML_DEPRECATED
61 | XMLPUBFUN void
62 | xmlInitThreads (void);
63 | XMLPUBFUN void
64 | xmlLockLibrary (void);
65 | XMLPUBFUN void
66 | xmlUnlockLibrary(void);
67 | XML_DEPRECATED
68 | XMLPUBFUN int
69 | xmlGetThreadId (void);
70 | XML_DEPRECATED
71 | XMLPUBFUN int
72 | xmlIsMainThread (void);
73 | XML_DEPRECATED
74 | XMLPUBFUN void
75 | xmlCleanupThreads(void);
76 | XML_DEPRECATED
77 | XMLPUBFUN xmlGlobalStatePtr
78 | xmlGetGlobalState(void);
79 |
80 | /** DOC_DISABLE */
81 | #if defined(LIBXML_THREAD_ENABLED) && defined(_WIN32) && \
82 | !defined(HAVE_COMPILER_TLS) && defined(LIBXML_STATIC_FOR_DLL)
83 | int
84 | xmlDllMain(void *hinstDLL, unsigned long fdwReason,
85 | void *lpvReserved);
86 | #endif
87 | /** DOC_ENABLE */
88 |
89 | #ifdef __cplusplus
90 | }
91 | #endif
92 |
93 |
94 | #endif /* __XML_THREADS_H__ */
95 |
--------------------------------------------------------------------------------
/upstream/os400/make-include.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Installation of the C header files in the OS/400 library.
4 | #
5 | # See Copyright for the status of this software.
6 | #
7 | # Author: Patrick Monnerat , DATASPHERE S.A.
8 | #
9 |
10 | SCRIPTDIR=`dirname "${0}"`
11 | . "${SCRIPTDIR}/initscript.sh"
12 | cd "${TOPDIR}/include"
13 |
14 |
15 | # Create the OS/400 source program file for the C header files.
16 |
17 | SRCPF="${LIBIFSNAME}/LIBXML.FILE"
18 |
19 | if action_needed "${SRCPF}"
20 | then CMD="CRTSRCPF FILE(${TARGETLIB}/LIBXML) RCDLEN(112)"
21 | CMD="${CMD} CCSID(${TGTCCSID}) TEXT('libxml2: C/C++ header files')"
22 | system "${CMD}"
23 | fi
24 |
25 |
26 | # Create the IFS directory for the C header files.
27 |
28 | if action_needed "${IFSDIR}/include/libxml"
29 | then mkdir -p "${IFSDIR}/include/libxml"
30 | fi
31 |
32 |
33 |
34 | # Enumeration values may be used as va_arg tagfields, so they MUST be
35 | # integers.
36 |
37 | copy_hfile()
38 |
39 | {
40 | sed -e '1i\
41 | #pragma enum(int)\
42 | ' "${@}" -e '$a\
43 | #pragma enum(pop)\
44 | '
45 | }
46 |
47 | # Copy the header files to DB2 library. Link from IFS include directory.
48 |
49 | for HFILE in "${TOPDIR}/os400/transcode.h" libxml/*.h libxml/*.h.in
50 | do CMD="cat \"${HFILE}\""
51 | DEST="${SRCPF}/`db2_name \"${HFILE}\" nomangle`.MBR"
52 |
53 | case "`basename \"${HFILE}\"`" in
54 |
55 | *.in) CMD="${CMD} | versioned_copy";;
56 |
57 | xmlschemastypes.h) # Special case: rename colliding file.
58 | DEST="${SRCPF}/SCHMTYPES.MBR";;
59 |
60 | esac
61 |
62 | if action_needed "${DEST}" "${HFILE}"
63 | then eval "${CMD}" | copy_hfile > tmphdrfile
64 |
65 | # Need to translate to target CCSID.
66 |
67 | CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DEST}')"
68 | CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
69 | system "${CMD}"
70 | fi
71 |
72 | IFSFILE="${IFSDIR}/include/libxml/`basename \"${HFILE}\" .in`"
73 |
74 | if action_needed "${IFSFILE}" "${DEST}"
75 | then rm -f "${IFSFILE}"
76 | ln -s "${DEST}" "${IFSFILE}"
77 | fi
78 | done
79 |
--------------------------------------------------------------------------------
/upstream/fuzz/xinclude.c:
--------------------------------------------------------------------------------
1 | /*
2 | * xinclude.c: a libFuzzer target to test the XInclude engine.
3 | *
4 | * See Copyright for the status of this software.
5 | */
6 |
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include "fuzz.h"
14 |
15 | int
16 | LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
17 | char ***argv ATTRIBUTE_UNUSED) {
18 | xmlFuzzMemSetup();
19 | xmlInitParser();
20 | #ifdef LIBXML_CATALOG_ENABLED
21 | xmlInitializeCatalog();
22 | #endif
23 | xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
24 | xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
25 |
26 | return 0;
27 | }
28 |
29 | int
30 | LLVMFuzzerTestOneInput(const char *data, size_t size) {
31 | xmlDocPtr doc;
32 | xmlTextReaderPtr reader;
33 | const char *docBuffer, *docUrl;
34 | size_t maxAlloc, docSize;
35 | int opts;
36 |
37 | xmlFuzzDataInit(data, size);
38 | opts = (int) xmlFuzzReadInt(4);
39 | opts &= ~XML_PARSE_DTDVALID;
40 | opts |= XML_PARSE_XINCLUDE;
41 | maxAlloc = xmlFuzzReadInt(4) % (size + 1);
42 |
43 | xmlFuzzReadEntities();
44 | docBuffer = xmlFuzzMainEntity(&docSize);
45 | docUrl = xmlFuzzMainUrl();
46 | if (docBuffer == NULL)
47 | goto exit;
48 |
49 | /* Pull parser */
50 |
51 | xmlFuzzMemSetLimit(maxAlloc);
52 | doc = xmlReadMemory(docBuffer, docSize, docUrl, NULL, opts);
53 | xmlXIncludeProcessFlags(doc, opts);
54 | xmlFreeDoc(doc);
55 |
56 | /* Reader */
57 |
58 | xmlFuzzMemSetLimit(maxAlloc);
59 | reader = xmlReaderForMemory(docBuffer, docSize, NULL, NULL, opts);
60 | if (reader == NULL)
61 | goto exit;
62 | while (xmlTextReaderRead(reader) == 1) {
63 | if (xmlTextReaderNodeType(reader) == XML_ELEMENT_NODE) {
64 | int i, n = xmlTextReaderAttributeCount(reader);
65 | for (i=0; i
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | """
33 |
34 | valid="""
35 |
36 | Raymond
37 | G
38 | Bayliss
39 |
40 | """
41 |
42 | invalid="""
43 |
44 | G
45 | Bayliss
46 |
47 | """
48 |
49 | e = ErrorHandler()
50 | ctxt_parser = libxml2.schemaNewMemParserCtxt(schema, len(schema))
51 | ctxt_schema = ctxt_parser.schemaParse()
52 | ctxt_valid = ctxt_schema.schemaNewValidCtxt()
53 | ctxt_valid.setValidityErrorHandler(e.handler, e.handler, ARG)
54 |
55 | # Test valid document
56 | doc = libxml2.parseDoc(valid)
57 | ret = doc.schemaValidateDoc(ctxt_valid)
58 | if ret != 0 or e.errors:
59 | print("error doing schema validation")
60 | sys.exit(1)
61 | doc.freeDoc()
62 |
63 | # Test invalid document
64 | doc = libxml2.parseDoc(invalid)
65 | ret = doc.schemaValidateDoc(ctxt_valid)
66 | if ret == 0 or not e.errors:
67 | print("Error: document supposer to be schema invalid")
68 | sys.exit(1)
69 | doc.freeDoc()
70 |
71 | del ctxt_parser
72 | del ctxt_schema
73 | del ctxt_valid
74 | libxml2.schemaCleanupTypes()
75 |
76 | # Memory debug specific
77 | libxml2.cleanupParser()
78 | if libxml2.debugMemory(1) == 0:
79 | print("OK")
80 | else:
81 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
82 |
83 |
--------------------------------------------------------------------------------
/upstream/trionan.h:
--------------------------------------------------------------------------------
1 | /*************************************************************************
2 | *
3 | * $Id$
4 | *
5 | * Copyright (C) 2001 Bjorn Reese
6 | *
7 | * Permission to use, copy, modify, and distribute this software for any
8 | * purpose with or without fee is hereby granted, provided that the above
9 | * copyright notice and this permission notice appear in all copies.
10 | *
11 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
12 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
13 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
14 | * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
15 | *
16 | ************************************************************************/
17 |
18 | #ifndef TRIO_NAN_H
19 | #define TRIO_NAN_H
20 |
21 | #include "triodef.h"
22 |
23 | #ifdef __cplusplus
24 | extern "C" {
25 | #endif
26 |
27 | enum {
28 | TRIO_FP_INFINITE,
29 | TRIO_FP_NAN,
30 | TRIO_FP_NORMAL,
31 | TRIO_FP_SUBNORMAL,
32 | TRIO_FP_ZERO
33 | };
34 |
35 | /*
36 | * Return NaN (Not-a-Number).
37 | */
38 | TRIO_PUBLIC double trio_nan TRIO_PROTO((void));
39 |
40 | /*
41 | * Return positive infinity.
42 | */
43 | TRIO_PUBLIC double trio_pinf TRIO_PROTO((void));
44 |
45 | /*
46 | * Return negative infinity.
47 | */
48 | TRIO_PUBLIC double trio_ninf TRIO_PROTO((void));
49 |
50 | /*
51 | * Return negative zero.
52 | */
53 | TRIO_PUBLIC double trio_nzero TRIO_PROTO((TRIO_NOARGS));
54 |
55 | /*
56 | * If number is a NaN return non-zero, otherwise return zero.
57 | */
58 | TRIO_PUBLIC int trio_isnan TRIO_PROTO((double number));
59 |
60 | /*
61 | * If number is positive infinity return 1, if number is negative
62 | * infinity return -1, otherwise return 0.
63 | */
64 | TRIO_PUBLIC int trio_isinf TRIO_PROTO((double number));
65 |
66 | /*
67 | * If number is finite return non-zero, otherwise return zero.
68 | */
69 | #if 0
70 | /* Temporary fix - these 2 routines not used in libxml */
71 | TRIO_PUBLIC int trio_isfinite TRIO_PROTO((double number));
72 |
73 | TRIO_PUBLIC int trio_fpclassify TRIO_PROTO((double number));
74 | #endif
75 |
76 | TRIO_PUBLIC int trio_signbit TRIO_PROTO((double number));
77 |
78 | TRIO_PUBLIC int trio_fpclassify_and_signbit TRIO_PROTO((double number, int *is_negative));
79 |
80 | #ifdef __cplusplus
81 | }
82 | #endif
83 |
84 | #endif /* TRIO_NAN_H */
85 |
--------------------------------------------------------------------------------
/upstream/xml2-config.in:
--------------------------------------------------------------------------------
1 | #! /bin/sh
2 |
3 | prefix=@prefix@
4 | exec_prefix=@exec_prefix@
5 | includedir=@includedir@
6 | libdir=@libdir@
7 | cflags=
8 | libs=
9 |
10 | usage()
11 | {
12 | cat < header file. */
9 | #define HAVE_DLFCN_H 1
10 |
11 | /* Have dlopen based dso */
12 | #define HAVE_DLOPEN 1
13 |
14 | /* Define to 1 if you have the header file. */
15 | #define HAVE_FCNTL_H 1
16 |
17 | /* Define to 1 if you have the `ftime' function. */
18 | #define HAVE_FTIME 1
19 |
20 | /* Define if getaddrinfo is there */
21 | #define HAVE_GETADDRINFO 1
22 |
23 | /* Define to 1 if you have the `gettimeofday' function. */
24 | #define HAVE_GETTIMEOFDAY 1
25 |
26 | /* Define to 1 if you have the header file. */
27 | #define HAVE_INTTYPES_H 1
28 |
29 | /* Define to 1 if you have the `isascii' function. */
30 | #define HAVE_ISASCII 1
31 |
32 | /* Define to 1 if you have the `mmap' function. */
33 | #define HAVE_MMAP 1
34 |
35 | /* Define to 1 if you have the `munmap' function. */
36 | #define HAVE_MUNMAP 1
37 |
38 | /* mmap() is no good without munmap() */
39 | #if defined(HAVE_MMAP) && !defined(HAVE_MUNMAP)
40 | # undef /**/ HAVE_MMAP
41 | #endif
42 |
43 | /* Define to 1 if you have the header file. */
44 | #define HAVE_POLL_H 1
45 |
46 | /* Define to 1 if you have the `putenv' function. */
47 | #define HAVE_PUTENV 1
48 |
49 | /* Define to 1 if you have the `rand_r' function. */
50 | #define HAVE_RAND_R 1
51 |
52 | /* Define to 1 if you have the header file. */
53 | #define HAVE_RESOLV_H 1
54 |
55 | /* Define to 1 if you have the `stat' function. */
56 | #define HAVE_STAT 1
57 |
58 | /* Define to 1 if you have the header file. */
59 | #define HAVE_STDINT_H 1
60 |
61 | /* Define to 1 if you have the header file. */
62 | #define HAVE_SYS_STAT_H 1
63 |
64 | /* Define to 1 if you have the header file. */
65 | #define HAVE_UNISTD_H 1
66 |
67 | /* Whether va_copy() is available */
68 | #define HAVE_VA_COPY 1
69 |
70 | /* Define to 1 if you have the header file. */
71 | #define HAVE_ZLIB_H 1
72 |
73 | /* Whether __va_copy() is available */
74 | #define HAVE___VA_COPY 1
75 |
76 | /* Support for IPv6 */
77 | #define SUPPORT_IP6 1
78 |
79 | /* Define if va_list is an array type */
80 | #define VA_LIST_IS_ARRAY 1
81 |
--------------------------------------------------------------------------------
/upstream/fuzz/fuzz.h:
--------------------------------------------------------------------------------
1 | /*
2 | * fuzz.h: Common functions and macros for fuzzing.
3 | *
4 | * See Copyright for the status of this software.
5 | */
6 |
7 | #ifndef __XML_FUZZERCOMMON_H__
8 | #define __XML_FUZZERCOMMON_H__
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #ifdef __cplusplus
15 | extern "C" {
16 | #endif
17 |
18 | #if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
19 | #define HAVE_HTML_FUZZER
20 | #endif
21 | #if defined(LIBXML_REGEXP_ENABLED)
22 | #define HAVE_REGEXP_FUZZER
23 | #endif
24 | #if defined(LIBXML_SCHEMAS_ENABLED)
25 | #define HAVE_SCHEMA_FUZZER
26 | #endif
27 | #if 1
28 | #define HAVE_URI_FUZZER
29 | #endif
30 | #if defined(LIBXML_VALID_ENABLED) && \
31 | defined(LIBXML_READER_ENABLED)
32 | #define HAVE_VALID_FUZZER
33 | #endif
34 | #if defined(LIBXML_XINCLUDE_ENABLED) && \
35 | defined(LIBXML_READER_ENABLED)
36 | #define HAVE_XINCLUDE_FUZZER
37 | #endif
38 | #if defined(LIBXML_OUTPUT_ENABLED) && \
39 | defined(LIBXML_READER_ENABLED)
40 | #define HAVE_XML_FUZZER
41 | #endif
42 | #if defined(LIBXML_XPATH_ENABLED)
43 | #define HAVE_XPATH_FUZZER
44 | #endif
45 |
46 | int
47 | LLVMFuzzerInitialize(int *argc, char ***argv);
48 |
49 | int
50 | LLVMFuzzerTestOneInput(const char *data, size_t size);
51 |
52 | void
53 | xmlFuzzErrorFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg ATTRIBUTE_UNUSED,
54 | ...);
55 |
56 | void
57 | xmlFuzzMemSetup(void);
58 |
59 | void
60 | xmlFuzzMemSetLimit(size_t limit);
61 |
62 | void
63 | xmlFuzzDataInit(const char *data, size_t size);
64 |
65 | void
66 | xmlFuzzDataCleanup(void);
67 |
68 | void
69 | xmlFuzzWriteInt(FILE *out, size_t v, int size);
70 |
71 | size_t
72 | xmlFuzzReadInt(int size);
73 |
74 | const char *
75 | xmlFuzzReadRemaining(size_t *size);
76 |
77 | void
78 | xmlFuzzWriteString(FILE *out, const char *str);
79 |
80 | const char *
81 | xmlFuzzReadString(size_t *size);
82 |
83 | void
84 | xmlFuzzReadEntities(void);
85 |
86 | const char *
87 | xmlFuzzMainUrl(void);
88 |
89 | const char *
90 | xmlFuzzMainEntity(size_t *size);
91 |
92 | xmlParserInputPtr
93 | xmlFuzzEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt);
94 |
95 | char *
96 | xmlSlurpFile(const char *path, size_t *size);
97 |
98 | #ifdef __cplusplus
99 | }
100 | #endif
101 |
102 | #endif /* __XML_FUZZERCOMMON_H__ */
103 |
104 |
--------------------------------------------------------------------------------
/upstream/include/libxml/xmlsave.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Summary: the XML document serializer
3 | * Description: API to save document or subtree of document
4 | *
5 | * Copy: See Copyright for the status of this software.
6 | *
7 | * Author: Daniel Veillard
8 | */
9 |
10 | #ifndef __XML_XMLSAVE_H__
11 | #define __XML_XMLSAVE_H__
12 |
13 | #include
14 | #include
15 | #include
16 | #include
17 |
18 | #ifdef LIBXML_OUTPUT_ENABLED
19 | #ifdef __cplusplus
20 | extern "C" {
21 | #endif
22 |
23 | /**
24 | * xmlSaveOption:
25 | *
26 | * This is the set of XML save options that can be passed down
27 | * to the xmlSaveToFd() and similar calls.
28 | */
29 | typedef enum {
30 | XML_SAVE_FORMAT = 1<<0, /* format save output */
31 | XML_SAVE_NO_DECL = 1<<1, /* drop the xml declaration */
32 | XML_SAVE_NO_EMPTY = 1<<2, /* no empty tags */
33 | XML_SAVE_NO_XHTML = 1<<3, /* disable XHTML1 specific rules */
34 | XML_SAVE_XHTML = 1<<4, /* force XHTML1 specific rules */
35 | XML_SAVE_AS_XML = 1<<5, /* force XML serialization on HTML doc */
36 | XML_SAVE_AS_HTML = 1<<6, /* force HTML serialization on XML doc */
37 | XML_SAVE_WSNONSIG = 1<<7 /* format with non-significant whitespace */
38 | } xmlSaveOption;
39 |
40 |
41 | typedef struct _xmlSaveCtxt xmlSaveCtxt;
42 | typedef xmlSaveCtxt *xmlSaveCtxtPtr;
43 |
44 | XMLPUBFUN xmlSaveCtxtPtr
45 | xmlSaveToFd (int fd,
46 | const char *encoding,
47 | int options);
48 | XMLPUBFUN xmlSaveCtxtPtr
49 | xmlSaveToFilename (const char *filename,
50 | const char *encoding,
51 | int options);
52 |
53 | XMLPUBFUN xmlSaveCtxtPtr
54 | xmlSaveToBuffer (xmlBufferPtr buffer,
55 | const char *encoding,
56 | int options);
57 |
58 | XMLPUBFUN xmlSaveCtxtPtr
59 | xmlSaveToIO (xmlOutputWriteCallback iowrite,
60 | xmlOutputCloseCallback ioclose,
61 | void *ioctx,
62 | const char *encoding,
63 | int options);
64 |
65 | XMLPUBFUN long
66 | xmlSaveDoc (xmlSaveCtxtPtr ctxt,
67 | xmlDocPtr doc);
68 | XMLPUBFUN long
69 | xmlSaveTree (xmlSaveCtxtPtr ctxt,
70 | xmlNodePtr node);
71 |
72 | XMLPUBFUN int
73 | xmlSaveFlush (xmlSaveCtxtPtr ctxt);
74 | XMLPUBFUN int
75 | xmlSaveClose (xmlSaveCtxtPtr ctxt);
76 | XMLPUBFUN int
77 | xmlSaveSetEscape (xmlSaveCtxtPtr ctxt,
78 | xmlCharEncodingOutputFunc escape);
79 | XMLPUBFUN int
80 | xmlSaveSetAttrEscape (xmlSaveCtxtPtr ctxt,
81 | xmlCharEncodingOutputFunc escape);
82 | #ifdef __cplusplus
83 | }
84 | #endif
85 | #endif /* LIBXML_OUTPUT_ENABLED */
86 | #endif /* __XML_XMLSAVE_H__ */
87 |
88 |
89 |
--------------------------------------------------------------------------------
/upstream/fuzz/html.c:
--------------------------------------------------------------------------------
1 | /*
2 | * html.c: a libFuzzer target to test several HTML parser interfaces.
3 | *
4 | * See Copyright for the status of this software.
5 | */
6 |
7 | #include
8 | #include
9 | #include
10 | #include "fuzz.h"
11 |
12 | int
13 | LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
14 | char ***argv ATTRIBUTE_UNUSED) {
15 | xmlFuzzMemSetup();
16 | xmlInitParser();
17 | #ifdef LIBXML_CATALOG_ENABLED
18 | xmlInitializeCatalog();
19 | #endif
20 | xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
21 |
22 | return 0;
23 | }
24 |
25 | int
26 | LLVMFuzzerTestOneInput(const char *data, size_t size) {
27 | static const size_t maxChunkSize = 128;
28 | htmlDocPtr doc;
29 | htmlParserCtxtPtr ctxt;
30 | xmlOutputBufferPtr out;
31 | const char *docBuffer;
32 | size_t maxAlloc, docSize, consumed, chunkSize;
33 | int opts;
34 |
35 | xmlFuzzDataInit(data, size);
36 | opts = (int) xmlFuzzReadInt(4);
37 | maxAlloc = xmlFuzzReadInt(4) % (size + 1);
38 |
39 | docBuffer = xmlFuzzReadRemaining(&docSize);
40 | if (docBuffer == NULL) {
41 | xmlFuzzDataCleanup();
42 | return(0);
43 | }
44 |
45 | /* Pull parser */
46 |
47 | xmlFuzzMemSetLimit(maxAlloc);
48 | doc = htmlReadMemory(docBuffer, docSize, NULL, NULL, opts);
49 |
50 | /*
51 | * Also test the serializer. Call htmlDocContentDumpOutput with our
52 | * own buffer to avoid encoding the output. The HTML encoding is
53 | * excruciatingly slow (see htmlEntityValueLookup).
54 | */
55 | out = xmlAllocOutputBuffer(NULL);
56 | htmlDocContentDumpOutput(out, doc, NULL);
57 | xmlOutputBufferClose(out);
58 |
59 | xmlFreeDoc(doc);
60 |
61 | /* Push parser */
62 |
63 | xmlFuzzMemSetLimit(maxAlloc);
64 | ctxt = htmlCreatePushParserCtxt(NULL, NULL, NULL, 0, NULL,
65 | XML_CHAR_ENCODING_NONE);
66 |
67 | if (ctxt != NULL) {
68 | htmlCtxtUseOptions(ctxt, opts);
69 |
70 | for (consumed = 0; consumed < docSize; consumed += chunkSize) {
71 | chunkSize = docSize - consumed;
72 | if (chunkSize > maxChunkSize)
73 | chunkSize = maxChunkSize;
74 | htmlParseChunk(ctxt, docBuffer + consumed, chunkSize, 0);
75 | }
76 |
77 | htmlParseChunk(ctxt, NULL, 0, 1);
78 | xmlFreeDoc(ctxt->myDoc);
79 | htmlFreeParserCtxt(ctxt);
80 | }
81 |
82 | /* Cleanup */
83 |
84 | xmlFuzzMemSetLimit(0);
85 | xmlFuzzDataCleanup();
86 | xmlResetLastError();
87 |
88 | return(0);
89 | }
90 |
91 |
--------------------------------------------------------------------------------
/upstream/os400/libxmlrpg/xmlmodule.rpgle:
--------------------------------------------------------------------------------
1 | * Summary: dynamic module loading
2 | * Description: basic API for dynamic module loading, used by
3 | * libexslt added in 2.6.17
4 | *
5 | * Copy: See Copyright for the status of this software.
6 | *
7 | * Author: Patrick Monnerat , DATASPHERE S.A.
8 |
9 | /if not defined(XML_MODULE_H__)
10 | /define XML_MODULE_H__
11 |
12 | /include "libxmlrpg/xmlversion"
13 |
14 | /if defined(LIBXML_MODULES_ENABLED)
15 |
16 | /include "libxmlrpg/xmlTypesC"
17 |
18 | * xmlModulePtr:
19 | *
20 | * A handle to a dynamically loaded module
21 |
22 | d xmlModulePtr s * based(######typedef######)
23 |
24 | * xmlModuleOption:
25 | *
26 | * enumeration of options that can be passed down to xmlModuleOpen()
27 |
28 | d xmlModuleOption...
29 | d s based(######typedef######)
30 | d like(xmlCenum)
31 | d XML_MODULE_LAZY... Lazy binding
32 | d c 1
33 | d XML_MODULE_LOCAL... Local binding
34 | d c 2
35 |
36 | d xmlModuleOpen pr extproc('xmlModuleOpen')
37 | d like(xmlModulePtr)
38 | d filename * value options(*string) const char *
39 | d options value like(xmlCint)
40 |
41 | d xmlModuleSymbol...
42 | d pr extproc('xmlModuleSymbol')
43 | d like(xmlCint)
44 | d module value like(xmlModulePtr)
45 | d name * value options(*string) const char *
46 | d result * void *(*)
47 |
48 | d xmlModuleClose pr extproc('xmlModuleClose')
49 | d like(xmlCint)
50 | d module value like(xmlModulePtr)
51 |
52 | d xmlModuleFree pr extproc('xmlModuleFree')
53 | d like(xmlCint)
54 | d module value like(xmlModulePtr)
55 |
56 | /endif LIBXML_MODULES_ENBLD
57 | /endif XML_MODULE_H__
58 |
--------------------------------------------------------------------------------
/upstream/python/tests/thread2.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | import string, sys, time
3 | try:
4 | from _thread import get_ident
5 | except:
6 | from thread import get_ident
7 | from threading import Thread, Lock
8 |
9 | import libxml2
10 |
11 | THREADS_COUNT = 15
12 |
13 | failed = 0
14 |
15 | class ErrorHandler:
16 |
17 | def __init__(self):
18 | self.errors = []
19 | self.lock = Lock()
20 |
21 | def handler(self,ctx,str):
22 | self.lock.acquire()
23 | self.errors.append(str)
24 | self.lock.release()
25 |
26 | def getLineNumbersDefault():
27 | old = libxml2.lineNumbersDefault(0)
28 | libxml2.lineNumbersDefault(old)
29 | return old
30 |
31 | def test(expectedLineNumbersDefault):
32 | time.sleep(1)
33 | global failed
34 | # check a per thread-global
35 | if expectedLineNumbersDefault != getLineNumbersDefault():
36 | failed = 1
37 | print("FAILED to obtain correct value for " \
38 | "lineNumbersDefault in thread %d" % get_ident())
39 | # check ther global error handler
40 | # (which is NOT per-thread in the python bindings)
41 | try:
42 | doc = libxml2.parseFile("bad.xml")
43 | except:
44 | pass
45 | else:
46 | assert "failed"
47 |
48 | # global error handler
49 | eh = ErrorHandler()
50 | libxml2.registerErrorHandler(eh.handler,"")
51 |
52 | # set on the main thread only
53 | libxml2.lineNumbersDefault(1)
54 | test(1)
55 | ec = len(eh.errors)
56 | if ec == 0:
57 | print("FAILED: should have obtained errors")
58 | sys.exit(1)
59 |
60 | ts = []
61 | for i in range(THREADS_COUNT):
62 | # expect 0 for lineNumbersDefault because
63 | # the new value has been set on the main thread only
64 | ts.append(Thread(target=test,args=(0,)))
65 | for t in ts:
66 | t.start()
67 | for t in ts:
68 | t.join()
69 |
70 | if len(eh.errors) != ec+THREADS_COUNT*ec:
71 | print("FAILED: did not obtain the correct number of errors")
72 | sys.exit(1)
73 |
74 | # set lineNumbersDefault for future new threads
75 | libxml2.thrDefLineNumbersDefaultValue(1)
76 | ts = []
77 | for i in range(THREADS_COUNT):
78 | # expect 1 for lineNumbersDefault
79 | ts.append(Thread(target=test,args=(1,)))
80 | for t in ts:
81 | t.start()
82 | for t in ts:
83 | t.join()
84 |
85 | if len(eh.errors) != ec+THREADS_COUNT*ec*2:
86 | print("FAILED: did not obtain the correct number of errors")
87 | sys.exit(1)
88 |
89 | if failed:
90 | print("FAILED")
91 | sys.exit(1)
92 |
93 | # Memory debug specific
94 | libxml2.cleanupParser()
95 | if libxml2.debugMemory(1) == 0:
96 | print("OK")
97 | else:
98 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
99 |
--------------------------------------------------------------------------------
/upstream/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Run this to generate all the initial makefiles, etc.
3 |
4 | THEDIR=`pwd`
5 | cd `dirname $0`
6 | srcdir=`pwd`
7 |
8 | DIE=0
9 |
10 | (autoconf --version) < /dev/null > /dev/null 2>&1 || {
11 | echo
12 | echo "You must have autoconf installed to compile libxml."
13 | echo "Download the appropriate package for your distribution,"
14 | echo "or see http://www.gnu.org/software/autoconf"
15 | DIE=1
16 | }
17 |
18 | (libtoolize --version) < /dev/null > /dev/null 2>&1 ||
19 | (glibtoolize --version) < /dev/null > /dev/null 2>&1 || {
20 | echo
21 | echo "You must have libtool installed to compile libxml."
22 | echo "Download the appropriate package for your distribution,"
23 | echo "or see http://www.gnu.org/software/libtool"
24 | DIE=1
25 | }
26 |
27 | (automake --version) < /dev/null > /dev/null 2>&1 || {
28 | echo
29 | DIE=1
30 | echo "You must have automake installed to compile libxml."
31 | echo "Download the appropriate package for your distribution,"
32 | echo "or see http://www.gnu.org/software/automake"
33 | }
34 |
35 | if test "$DIE" -eq 1; then
36 | exit 1
37 | fi
38 |
39 | test -f entities.c || {
40 | echo "You must run this script in the top-level libxml directory"
41 | exit 1
42 | }
43 |
44 | EXTRA_ARGS=
45 | if test "x$1" = "x--system"; then
46 | shift
47 | prefix=/usr
48 | libdir=$prefix/lib
49 | sysconfdir=/etc
50 | localstatedir=/var
51 | if [ -d /usr/lib64 ]; then
52 | libdir=$prefix/lib64
53 | fi
54 | EXTRA_ARGS="--prefix=$prefix --sysconfdir=$sysconfdir --localstatedir=$localstatedir --libdir=$libdir"
55 | echo "Running ./configure with $EXTRA_ARGS $@"
56 | else
57 | if test -z "$NOCONFIGURE" && test -z "$*"; then
58 | echo "I am going to run ./configure with no arguments - if you wish "
59 | echo "to pass any to it, please specify them on the $0 command line."
60 | fi
61 | fi
62 |
63 | if [ ! -d $srcdir/m4 ]; then
64 | mkdir $srcdir/m4
65 | fi
66 |
67 | # Replaced by autoreconf below
68 | autoreconf -if -Wall
69 |
70 | if ! grep -q pkg.m4 aclocal.m4; then
71 | cat <content of d""")
19 | input = libxml2.inputBuffer(f)
20 | reader = input.newTextReader("test_next")
21 | ret = reader.Read()
22 | if ret != 1:
23 | print("test_next: Error reading to first element")
24 | sys.exit(1)
25 | if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \
26 | reader.NodeType() != 1 or reader.HasAttributes() != 0:
27 | print("test_next: Error reading the first element")
28 | sys.exit(1)
29 | ret = reader.Read()
30 | if ret != 1:
31 | print("test_next: Error reading to second element")
32 | sys.exit(1)
33 | if reader.Name() != "b" or reader.IsEmptyElement() != 0 or \
34 | reader.NodeType() != 1 or reader.HasAttributes() != 0:
35 | print("test_next: Error reading the second element")
36 | sys.exit(1)
37 | ret = reader.Read()
38 | if ret != 1:
39 | print("test_next: Error reading to third element")
40 | sys.exit(1)
41 | if reader.Name() != "c" or reader.NodeType() != 1 or \
42 | reader.HasAttributes() != 0:
43 | print("test_next: Error reading the third element")
44 | sys.exit(1)
45 | ret = reader.Read()
46 | if ret != 1:
47 | print("test_next: Error reading to end of third element")
48 | sys.exit(1)
49 | if reader.Name() != "b" or reader.NodeType() != 15:
50 | print("test_next: Error reading to end of second element")
51 | sys.exit(1)
52 | ret = reader.Next()
53 | if ret != 1:
54 | print("test_next: Error moving to third element")
55 | sys.exit(1)
56 | if reader.Name() != "d" or reader.IsEmptyElement() != 0 or \
57 | reader.NodeType() != 1 or reader.HasAttributes() != 0:
58 | print("test_next: Error reading third element")
59 | sys.exit(1)
60 | ret = reader.Next()
61 | if ret != 1:
62 | print("test_next: Error reading to end of first element")
63 | sys.exit(1)
64 | if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \
65 | reader.NodeType() != 15 or reader.HasAttributes() != 0:
66 | print("test_next: Error reading the end of first element")
67 | sys.exit(1)
68 | ret = reader.Read()
69 | if ret != 0:
70 | print("test_next: Error reading to end of document")
71 | sys.exit(1)
72 |
73 | #
74 | # cleanup for memory allocation counting
75 | #
76 | del f
77 | del input
78 | del reader
79 |
80 | # Memory debug specific
81 | libxml2.cleanupParser()
82 | if libxml2.debugMemory(1) == 0:
83 | print("OK")
84 | else:
85 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
86 |
--------------------------------------------------------------------------------
/upstream/os400/iconv/README.iconv:
--------------------------------------------------------------------------------
1 | IBM OS/400 implements iconv in an odd way:
2 | - Type iconv_t is a structure: therefore objects of this type cannot be
3 | compared to (iconv_t) -1.
4 | - Supported character sets names are all of the form IBMCCSIDccsid..., where
5 | ccsid is a decimal 5-digit integer identifying an IBM coded character set.
6 | In addition, character set names have to be given in EBCDIC.
7 | Standard character set names like "UTF-8" are NOT recognized.
8 | - The prototype of iconv_open() does not declare parameters as const, although
9 | they are not altered.
10 |
11 | Since libiconv does not support EBCDIC, use of this package here as a
12 | replacement is not a solution.
13 |
14 | For these reasons, the code in this directory implements a wrapper to the
15 | OS/400 iconv implementation. The wrapper performs the following transformations:
16 | - Type iconv_t is an pointer. Although OS/400 pointers are odd, comparing
17 | with (iconv_t) -1 is OK.
18 | - All IANA character set names are recognized in a coding- and case-insensitive
19 | way, providing an equivalent CCSID exists. see
20 | http://www.iana.org/assignments/character-sets/character-sets.xhtml
21 | - All CCSIDs from the association file can be expressed as IBMCCSIDxxxxx where
22 | xxxxx is the 5 digit CCSID; no null terminator is required. Alternate codes
23 | are of the form ibm-xxx (null-terminated), where xxx is the integer CCSID with
24 | leading zeroes stripped.
25 | - If a IANA BIBenum is defined for a CCSID, the name iana-xxx can be used,
26 | where xxx is the integer MIBenum without leading zeroes.
27 | - In addition, some aliases are also taken from the association file. Examples
28 | are: ASCII, EBCDIC, UTF8.
29 | - Prototype of iconv_open() has const parameters.
30 | - Character code names can be given in any code.
31 |
32 | Character set names to CCSID conversion.
33 | - http://www.iana.org/assignments/character-sets/character-sets.xhtml provides
34 | all IANA registered character set names and aliases associated with a
35 | MIBenum, that is a unique character set identifier.
36 | - A hand-maintained file ccsid_mibenum.xml associates IBM CCSIDs to
37 | IANA MBenums.
38 | - An OS/400 C program (in subdirectory bldcsndfa) generates a deterministic
39 | finite automaton from the files mentioned above into a C file for all
40 | possible character set name and associating each of them with its
41 | corresponding CCSID. This program can only be run on OS/400 since it uses
42 | the native iconv support for EBCDIC.
43 | - Since these operations are tedious and the table generation needs bootstraping
44 | with libxml2, the generated automaton is stored within sources and need not
45 | be rebuilt at each compilation. However, source is provided here to allow
46 | new table generation with conversion tables that were not available at the
47 | time of original generation.
48 |
--------------------------------------------------------------------------------
/upstream/include/libxml/uri.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Summary: library of generic URI related routines
3 | * Description: library of generic URI related routines
4 | * Implements RFC 2396
5 | *
6 | * Copy: See Copyright for the status of this software.
7 | *
8 | * Author: Daniel Veillard
9 | */
10 |
11 | #ifndef __XML_URI_H__
12 | #define __XML_URI_H__
13 |
14 | #include
15 | #include
16 |
17 | #ifdef __cplusplus
18 | extern "C" {
19 | #endif
20 |
21 | /**
22 | * xmlURI:
23 | *
24 | * A parsed URI reference. This is a struct containing the various fields
25 | * as described in RFC 2396 but separated for further processing.
26 | *
27 | * Note: query is a deprecated field which is incorrectly unescaped.
28 | * query_raw takes precedence over query if the former is set.
29 | * See: http://mail.gnome.org/archives/xml/2007-April/thread.html#00127
30 | */
31 | typedef struct _xmlURI xmlURI;
32 | typedef xmlURI *xmlURIPtr;
33 | struct _xmlURI {
34 | char *scheme; /* the URI scheme */
35 | char *opaque; /* opaque part */
36 | char *authority; /* the authority part */
37 | char *server; /* the server part */
38 | char *user; /* the user part */
39 | int port; /* the port number */
40 | char *path; /* the path string */
41 | char *query; /* the query string (deprecated - use with caution) */
42 | char *fragment; /* the fragment identifier */
43 | int cleanup; /* parsing potentially unclean URI */
44 | char *query_raw; /* the query string (as it appears in the URI) */
45 | };
46 |
47 | /*
48 | * This function is in tree.h:
49 | * xmlChar * xmlNodeGetBase (xmlDocPtr doc,
50 | * xmlNodePtr cur);
51 | */
52 | XMLPUBFUN xmlURIPtr
53 | xmlCreateURI (void);
54 | XMLPUBFUN xmlChar *
55 | xmlBuildURI (const xmlChar *URI,
56 | const xmlChar *base);
57 | XMLPUBFUN xmlChar *
58 | xmlBuildRelativeURI (const xmlChar *URI,
59 | const xmlChar *base);
60 | XMLPUBFUN xmlURIPtr
61 | xmlParseURI (const char *str);
62 | XMLPUBFUN xmlURIPtr
63 | xmlParseURIRaw (const char *str,
64 | int raw);
65 | XMLPUBFUN int
66 | xmlParseURIReference (xmlURIPtr uri,
67 | const char *str);
68 | XMLPUBFUN xmlChar *
69 | xmlSaveUri (xmlURIPtr uri);
70 | XMLPUBFUN void
71 | xmlPrintURI (FILE *stream,
72 | xmlURIPtr uri);
73 | XMLPUBFUN xmlChar *
74 | xmlURIEscapeStr (const xmlChar *str,
75 | const xmlChar *list);
76 | XMLPUBFUN char *
77 | xmlURIUnescapeString (const char *str,
78 | int len,
79 | char *target);
80 | XMLPUBFUN int
81 | xmlNormalizeURIPath (char *path);
82 | XMLPUBFUN xmlChar *
83 | xmlURIEscape (const xmlChar *str);
84 | XMLPUBFUN void
85 | xmlFreeURI (xmlURIPtr uri);
86 | XMLPUBFUN xmlChar*
87 | xmlCanonicPath (const xmlChar *path);
88 | XMLPUBFUN xmlChar*
89 | xmlPathToURI (const xmlChar *path);
90 |
91 | #ifdef __cplusplus
92 | }
93 | #endif
94 | #endif /* __XML_URI_H__ */
95 |
--------------------------------------------------------------------------------
/upstream/include/libxml/pattern.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Summary: pattern expression handling
3 | * Description: allows to compile and test pattern expressions for nodes
4 | * either in a tree or based on a parser state.
5 | *
6 | * Copy: See Copyright for the status of this software.
7 | *
8 | * Author: Daniel Veillard
9 | */
10 |
11 | #ifndef __XML_PATTERN_H__
12 | #define __XML_PATTERN_H__
13 |
14 | #include
15 | #include
16 | #include
17 |
18 | #ifdef LIBXML_PATTERN_ENABLED
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | /**
25 | * xmlPattern:
26 | *
27 | * A compiled (XPath based) pattern to select nodes
28 | */
29 | typedef struct _xmlPattern xmlPattern;
30 | typedef xmlPattern *xmlPatternPtr;
31 |
32 | /**
33 | * xmlPatternFlags:
34 | *
35 | * This is the set of options affecting the behaviour of pattern
36 | * matching with this module
37 | *
38 | */
39 | typedef enum {
40 | XML_PATTERN_DEFAULT = 0, /* simple pattern match */
41 | XML_PATTERN_XPATH = 1<<0, /* standard XPath pattern */
42 | XML_PATTERN_XSSEL = 1<<1, /* XPath subset for schema selector */
43 | XML_PATTERN_XSFIELD = 1<<2 /* XPath subset for schema field */
44 | } xmlPatternFlags;
45 |
46 | XMLPUBFUN void
47 | xmlFreePattern (xmlPatternPtr comp);
48 |
49 | XMLPUBFUN void
50 | xmlFreePatternList (xmlPatternPtr comp);
51 |
52 | XMLPUBFUN xmlPatternPtr
53 | xmlPatterncompile (const xmlChar *pattern,
54 | xmlDict *dict,
55 | int flags,
56 | const xmlChar **namespaces);
57 | XMLPUBFUN int
58 | xmlPatternMatch (xmlPatternPtr comp,
59 | xmlNodePtr node);
60 |
61 | /* streaming interfaces */
62 | typedef struct _xmlStreamCtxt xmlStreamCtxt;
63 | typedef xmlStreamCtxt *xmlStreamCtxtPtr;
64 |
65 | XMLPUBFUN int
66 | xmlPatternStreamable (xmlPatternPtr comp);
67 | XMLPUBFUN int
68 | xmlPatternMaxDepth (xmlPatternPtr comp);
69 | XMLPUBFUN int
70 | xmlPatternMinDepth (xmlPatternPtr comp);
71 | XMLPUBFUN int
72 | xmlPatternFromRoot (xmlPatternPtr comp);
73 | XMLPUBFUN xmlStreamCtxtPtr
74 | xmlPatternGetStreamCtxt (xmlPatternPtr comp);
75 | XMLPUBFUN void
76 | xmlFreeStreamCtxt (xmlStreamCtxtPtr stream);
77 | XMLPUBFUN int
78 | xmlStreamPushNode (xmlStreamCtxtPtr stream,
79 | const xmlChar *name,
80 | const xmlChar *ns,
81 | int nodeType);
82 | XMLPUBFUN int
83 | xmlStreamPush (xmlStreamCtxtPtr stream,
84 | const xmlChar *name,
85 | const xmlChar *ns);
86 | XMLPUBFUN int
87 | xmlStreamPushAttr (xmlStreamCtxtPtr stream,
88 | const xmlChar *name,
89 | const xmlChar *ns);
90 | XMLPUBFUN int
91 | xmlStreamPop (xmlStreamCtxtPtr stream);
92 | XMLPUBFUN int
93 | xmlStreamWantsAnyNode (xmlStreamCtxtPtr stream);
94 | #ifdef __cplusplus
95 | }
96 | #endif
97 |
98 | #endif /* LIBXML_PATTERN_ENABLED */
99 |
100 | #endif /* __XML_PATTERN_H__ */
101 |
--------------------------------------------------------------------------------
/upstream/os400/libxmlrpg/threads.rpgle:
--------------------------------------------------------------------------------
1 | * Summary: interfaces for thread handling
2 | * Description: set of generic threading related routines
3 | * should work with pthreads, Windows native or TLS threads
4 | *
5 | * Copy: See Copyright for the status of this software.
6 | *
7 | * Author: Patrick Monnerat , DATASPHERE S.A.
8 |
9 | /if not defined(XML_THREADS_H__)
10 | /define XML_THREADS_H__
11 |
12 | /include "libxmlrpg/xmlversion"
13 | /include "libxmlrpg/xmlTypesC"
14 |
15 | * xmlMutex are a simple mutual exception locks.
16 |
17 | d xmlMutexPtr s * based(######typedef######)
18 |
19 | * xmlRMutex are reentrant mutual exception locks.
20 |
21 | d xmlRMutexPtr s * based(######typedef######)
22 |
23 | /include "libxmlrpg/globals"
24 |
25 | d xmlNewMutex pr extproc('xmlNewMutex')
26 | d like(xmlMutexPtr)
27 |
28 | d xmlMutexLock pr extproc('xmlMutexLock')
29 | d tok value like(xmlMutexPtr)
30 |
31 | d xmlMutexUnlock pr extproc('xmlMutexUnlock')
32 | d tok value like(xmlMutexPtr)
33 |
34 | d xmlFreeMutex pr extproc('xmlFreeMutex')
35 | d tok value like(xmlMutexPtr)
36 |
37 | d xmlNewRMutex pr extproc('xmlNewRMutex')
38 | d like(xmlRMutexPtr)
39 |
40 | d xmlRMutexLock pr extproc('xmlRMutexLock')
41 | d tok value like(xmlRMutexPtr)
42 |
43 | d xmlRMutexUnlock...
44 | d pr extproc('xmlRMutexUnlock')
45 | d tok value like(xmlRMutexPtr)
46 |
47 | d xmlFreeRMutex pr extproc('xmlFreeRMutex')
48 | d tok value like(xmlRMutexPtr)
49 |
50 | * Library wide APIs.
51 |
52 | d xmlInitThreads pr extproc('xmlInitThreads')
53 |
54 | d xmlLockLibrary pr extproc('xmlLockLibrary')
55 |
56 | d xmlUnlockLibrary...
57 | d pr extproc('xmlUnlockLibrary')
58 |
59 | d xmlGetThreadId pr extproc('xmlGetThreadId')
60 | d like(xmlCint)
61 |
62 | d xmlIsMainThread...
63 | d pr extproc('xmlIsMainThread')
64 | d like(xmlCint)
65 |
66 | d xmlCleanupThreads...
67 | d pr extproc('xmlCleanupThreads')
68 |
69 | d xmlGetGlobalState...
70 | d pr extproc('xmlGetGlobalState')
71 | d like(xmlGlobalStatePtr)
72 |
73 | /endif XML_THREADS_H__
74 |
--------------------------------------------------------------------------------
/upstream/os400/make.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # libxml2 compilation script for the OS/400.
4 | # This is a shell script since make is not a standard component of OS/400.
5 | #
6 | # See Copyright for the status of this software.
7 | #
8 | # Author: Patrick Monnerat , DATASPHERE S.A.
9 | #
10 |
11 | SCRIPTDIR=`dirname "${0}"`
12 | . "${SCRIPTDIR}/initscript.sh"
13 | cd "${TOPDIR}"
14 |
15 |
16 | # Create the OS/400 library if it does not exist.
17 |
18 | if action_needed "${LIBIFSNAME}"
19 | then CMD="CRTLIB LIB(${TARGETLIB})"
20 | CMD="${CMD} TEXT('libxml2: XML parser and toolkit API')"
21 | system "${CMD}"
22 | fi
23 |
24 |
25 | # Create the DOCS source file if it does not exist.
26 |
27 | if action_needed "${LIBIFSNAME}/DOCS.FILE"
28 | then CMD="CRTSRCPF FILE(${TARGETLIB}/DOCS) RCDLEN(112)"
29 | CMD="${CMD} CCSID(${TGTCCSID}) TEXT('Documentation texts')"
30 | system "${CMD}"
31 | fi
32 |
33 |
34 | # Copy some documentation files if needed.
35 |
36 | for TEXT in "${TOPDIR}/AUTHORS" "${TOPDIR}/ChangeLog" \
37 | "${TOPDIR}/Copyright" "${TOPDIR}/CONTRIBUTING" "${TOPDIR}/README" \
38 | "${TOPDIR}/MAINTAINERS" "${TOPDIR}/NEWS" "${TOPDIR}/TODO" \
39 | "${TOPDIR}/TODO_SCHEMAS" "${TOPDIR}/os400/README400"
40 | do if [ -f "${TEXT}" ]
41 | then MEMBER="`basename \"${TEXT}\" .OS400`"
42 | MEMBER="${LIBIFSNAME}/DOCS.FILE/`db2_name \"${MEMBER}\"`.MBR"
43 |
44 | if action_needed "${MEMBER}" "${TEXT}"
45 | then # Sources are in UTF-8.
46 | rm -f "${TOPDIR}/tmpfile"[12]
47 | CMD="CPY OBJ('${TEXT}') TOOBJ('${TOPDIR}/tmpfile1')"
48 | CMD="${CMD} FROMCCSID(1208) TOCCSID(${TGTCCSID})"
49 | CMD="${CMD} DTAFMT(*TEXT) REPLACE(*YES)"
50 | system "${CMD}"
51 | # Make sure all lines are < 100 characters.
52 | sed -e 's/.\{99\}/&\
53 | /g' -e 's/\n$//' "${TOPDIR}/tmpfile1" > "${TOPDIR}/tmpfile2"
54 | CMD="CPY OBJ('${TOPDIR}/tmpfile2') TOOBJ('${MEMBER}')"
55 | CMD="${CMD} TOCCSID(${TGTCCSID})"
56 | CMD="${CMD} DTAFMT(*TEXT) REPLACE(*YES)"
57 | system "${CMD}"
58 | fi
59 | fi
60 | done
61 |
62 |
63 | # Build files from template.
64 |
65 | configFile()
66 |
67 | {
68 | args=`set | sed -e '/^[A-Za-z_][A-Za-z0-9_]*=/!d' \
69 | -e 's/[\/\\\\&]/\\\\&/g' \
70 | -e "s/'/'\\\\\\''/g" \
71 | -e 's/^\([^=]*\)=\(.*\)$/-e '\''s\/@\1@\/\2\/g'\'/`
72 | eval sed ${args} < "${1}".in > "${1}"
73 | }
74 |
75 | configFile include/libxml/xmlversion.h
76 | configFile os400/os400config.h
77 | mv os400/os400config.h config.h
78 |
79 |
80 | # Build in each directory.
81 |
82 | for SUBDIR in include rpg src
83 | do "${SCRIPTDIR}/make-${SUBDIR}.sh"
84 | done
85 |
--------------------------------------------------------------------------------
/upstream/python/tests/walker.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | #
3 | # this tests the entities substitutions with the XmlTextReader interface
4 | #
5 | import sys
6 | import libxml2
7 |
8 | # Memory debug specific
9 | libxml2.debugMemory(1)
10 |
11 | result = ""
12 | def processNode(reader):
13 | global result
14 |
15 | result = result + "%d %d %s %d\n" % (reader.Depth(), reader.NodeType(),
16 | reader.Name(), reader.IsEmptyElement())
17 |
18 | #
19 | # Parse a document testing the readerForxxx API
20 | #
21 | docstr="""
22 |
23 | - 100
24 | """
25 | expect="""0 1 foo 0
26 | 1 14 #text 0
27 | 1 1 label 0
28 | 2 3 #text 0
29 | 1 15 label 0
30 | 1 14 #text 0
31 | 1 1 item 0
32 | 2 3 #text 0
33 | 1 15 item 0
34 | 1 14 #text 0
35 | 0 15 foo 0
36 | """
37 | result = ""
38 |
39 | doc = libxml2.parseDoc(docstr)
40 | reader = doc.readerWalker();
41 | ret = reader.Read()
42 | while ret == 1:
43 | processNode(reader)
44 | ret = reader.Read()
45 |
46 | if ret != 0:
47 | print("Error parsing the document test1")
48 | sys.exit(1)
49 |
50 | if result != expect:
51 | print("Unexpected result for test1")
52 | print(result)
53 | sys.exit(1)
54 |
55 | doc.freeDoc()
56 |
57 | #
58 | # Reuse the reader for another document testing the ReaderNewWalker API
59 | #
60 | docstr="""
61 |
62 | - 1000
63 | """
64 | expect="""0 1 foo 0
65 | 1 14 #text 0
66 | 1 1 label 0
67 | 2 3 #text 0
68 | 1 15 label 0
69 | 1 14 #text 0
70 | 1 1 item 0
71 | 2 3 #text 0
72 | 1 15 item 0
73 | 1 14 #text 0
74 | 0 15 foo 0
75 | """
76 | result = ""
77 |
78 | doc = libxml2.parseDoc(docstr)
79 | reader.NewWalker(doc)
80 |
81 | ret = reader.Read()
82 | while ret == 1:
83 | processNode(reader)
84 | ret = reader.Read()
85 |
86 | if ret != 0:
87 | print("Error parsing the document test2")
88 | sys.exit(1)
89 |
90 | if result != expect:
91 | print("Unexpected result for test2")
92 | print(result)
93 | sys.exit(1)
94 |
95 | doc.freeDoc()
96 |
97 | #
98 | # Reuse the reader for another document testing the ReaderNewxxx API
99 | #
100 | docstr="""
101 |
102 | - 1000
103 | """
104 | expect="""0 1 foo 0
105 | 1 14 #text 0
106 | 1 1 label 0
107 | 2 3 #text 0
108 | 1 15 label 0
109 | 1 14 #text 0
110 | 1 1 item 0
111 | 2 3 #text 0
112 | 1 15 item 0
113 | 1 14 #text 0
114 | 0 15 foo 0
115 | """
116 | result = ""
117 |
118 | reader.NewDoc(docstr, "test3", None, 0)
119 | ret = reader.Read()
120 | while ret == 1:
121 | processNode(reader)
122 | ret = reader.Read()
123 |
124 | if ret != 0:
125 | print("Error parsing the document test3")
126 | sys.exit(1)
127 |
128 | if result != expect:
129 | print("Unexpected result for test3")
130 | print(result)
131 | sys.exit(1)
132 |
133 | #
134 | # cleanup
135 | #
136 | del reader
137 |
138 | # Memory debug specific
139 | libxml2.cleanupParser()
140 | if libxml2.debugMemory(1) == 0:
141 | print("OK")
142 | else:
143 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
144 |
--------------------------------------------------------------------------------
/upstream/fuzz/xml.c:
--------------------------------------------------------------------------------
1 | /*
2 | * xml.c: a libFuzzer target to test several XML parser interfaces.
3 | *
4 | * See Copyright for the status of this software.
5 | */
6 |
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include "fuzz.h"
13 |
14 | int
15 | LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
16 | char ***argv ATTRIBUTE_UNUSED) {
17 | xmlFuzzMemSetup();
18 | xmlInitParser();
19 | #ifdef LIBXML_CATALOG_ENABLED
20 | xmlInitializeCatalog();
21 | #endif
22 | xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
23 | xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
24 |
25 | return 0;
26 | }
27 |
28 | int
29 | LLVMFuzzerTestOneInput(const char *data, size_t size) {
30 | static const size_t maxChunkSize = 128;
31 | xmlDocPtr doc;
32 | xmlParserCtxtPtr ctxt;
33 | xmlTextReaderPtr reader;
34 | xmlChar *out;
35 | const char *docBuffer, *docUrl;
36 | size_t maxAlloc, docSize, consumed, chunkSize;
37 | int opts, outSize;
38 |
39 | xmlFuzzDataInit(data, size);
40 | opts = (int) xmlFuzzReadInt(4);
41 | opts &= ~XML_PARSE_XINCLUDE & ~XML_PARSE_DTDVALID;
42 | maxAlloc = xmlFuzzReadInt(4) % (size + 1);
43 |
44 | xmlFuzzReadEntities();
45 | docBuffer = xmlFuzzMainEntity(&docSize);
46 | docUrl = xmlFuzzMainUrl();
47 | if (docBuffer == NULL)
48 | goto exit;
49 |
50 | /* Pull parser */
51 |
52 | xmlFuzzMemSetLimit(maxAlloc);
53 | doc = xmlReadMemory(docBuffer, docSize, docUrl, NULL, opts);
54 | /* Also test the serializer. */
55 | xmlDocDumpMemory(doc, &out, &outSize);
56 | xmlFree(out);
57 | xmlFreeDoc(doc);
58 |
59 | /* Push parser */
60 |
61 | xmlFuzzMemSetLimit(maxAlloc);
62 | ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, docUrl);
63 | if (ctxt == NULL)
64 | goto exit;
65 | xmlCtxtUseOptions(ctxt, opts);
66 |
67 | for (consumed = 0; consumed < docSize; consumed += chunkSize) {
68 | chunkSize = docSize - consumed;
69 | if (chunkSize > maxChunkSize)
70 | chunkSize = maxChunkSize;
71 | xmlParseChunk(ctxt, docBuffer + consumed, chunkSize, 0);
72 | }
73 |
74 | xmlParseChunk(ctxt, NULL, 0, 1);
75 | xmlFreeDoc(ctxt->myDoc);
76 | xmlFreeParserCtxt(ctxt);
77 |
78 | /* Reader */
79 |
80 | xmlFuzzMemSetLimit(maxAlloc);
81 | reader = xmlReaderForMemory(docBuffer, docSize, NULL, NULL, opts);
82 | if (reader == NULL)
83 | goto exit;
84 | while (xmlTextReaderRead(reader) == 1) {
85 | if (xmlTextReaderNodeType(reader) == XML_ELEMENT_NODE) {
86 | int i, n = xmlTextReaderAttributeCount(reader);
87 | for (i=0; i
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | """
31 | # Memory debug specific
32 | libxml2.debugMemory(1)
33 |
34 | #
35 | # Parse the Relax NG Schemas
36 | #
37 | rngp = libxml2.relaxNGNewMemParserCtxt(schema, len(schema))
38 | rngs = rngp.relaxNGParse()
39 | del rngp
40 |
41 | #
42 | # Parse and validate the correct document
43 | #
44 | docstr="""
45 |
46 | - 100
47 | """
48 |
49 | f = str_io(docstr)
50 | input = libxml2.inputBuffer(f)
51 | reader = input.newTextReader("correct")
52 | reader.RelaxNGSetSchema(rngs)
53 | ret = reader.Read()
54 | while ret == 1:
55 | ret = reader.Read()
56 |
57 | if ret != 0:
58 | print("Error parsing the document")
59 | sys.exit(1)
60 |
61 | if reader.IsValid() != 1:
62 | print("Document failed to validate")
63 | sys.exit(1)
64 |
65 | #
66 | # Parse and validate the incorrect document
67 | #
68 | docstr="""
69 |
70 | - 1000
71 | """
72 |
73 | err=""
74 | # RNG errors are not as good as before , TODO
75 | #expect="""RNG validity error: file error line 3 element text
76 | #Type byte doesn't allow value '1000'
77 | #RNG validity error: file error line 3 element text
78 | #Error validating datatype byte
79 | #RNG validity error: file error line 3 element text
80 | #Element item failed to validate content
81 | #"""
82 | expect="""Type byte doesn't allow value '1000'
83 | Error validating datatype byte
84 | Element item failed to validate content
85 | """
86 |
87 | def callback(ctx, str):
88 | global err
89 | err = err + "%s" % (str)
90 | libxml2.registerErrorHandler(callback, "")
91 |
92 | f = str_io(docstr)
93 | input = libxml2.inputBuffer(f)
94 | reader = input.newTextReader("error")
95 | reader.RelaxNGSetSchema(rngs)
96 | ret = reader.Read()
97 | while ret == 1:
98 | ret = reader.Read()
99 |
100 | if ret != 0:
101 | print("Error parsing the document")
102 | sys.exit(1)
103 |
104 | if reader.IsValid() != 0:
105 | print("Document failed to detect the validation error")
106 | sys.exit(1)
107 |
108 | if err != expect:
109 | print("Did not get the expected error message:")
110 | print(err)
111 | sys.exit(1)
112 |
113 | #
114 | # cleanup
115 | #
116 | del f
117 | del input
118 | del reader
119 | del rngs
120 | libxml2.relaxNGCleanupTypes()
121 |
122 | # Memory debug specific
123 | libxml2.cleanupParser()
124 | if libxml2.debugMemory(1) == 0:
125 | print("OK")
126 | else:
127 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
128 |
--------------------------------------------------------------------------------
/upstream/os400/make-rpg.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Installation of the ILE/RPG header files in the OS/400 library.
4 | #
5 | # See Copyright for the status of this software.
6 | #
7 | # Author: Patrick Monnerat , DATASPHERE S.A.
8 | #
9 |
10 | SCRIPTDIR=`dirname "${0}"`
11 | . "${SCRIPTDIR}/initscript.sh"
12 | cd "${TOPDIR}/os400/libxmlrpg"
13 |
14 |
15 | # Create the OS/400 source program file for the ILE/RPG header files.
16 |
17 | SRCPF="${LIBIFSNAME}/LIBXMLRPG.FILE"
18 |
19 | if action_needed "${SRCPF}"
20 | then CMD="CRTSRCPF FILE(${TARGETLIB}/LIBXMLRPG) RCDLEN(112)"
21 | CMD="${CMD} CCSID(${TGTCCSID}) TEXT('libxml2: ILE/RPG header files')"
22 | system "${CMD}"
23 | fi
24 |
25 |
26 | # Map file names to DB2 name syntax.
27 |
28 | for HFILE in *.rpgle *.rpgle.in
29 | do NAME="`basename \"${HFILE}\" .in`"
30 | VAR="`basename \"${NAME}\" .rpgle`"
31 | VAL="`db2_name \"${NAME}\" nomangle`"
32 |
33 | if [ "${VAR}" = 'xmlschemastypes' ]
34 | then VAL=SCHMTYPES
35 | fi
36 |
37 | eval "VAR_${VAR}=\"${VAL}\""
38 | echo "${VAR} s/${VAR}/${VAL}/g"
39 | done > tmpsubstfile1
40 |
41 | # Order substitution commands so that a prefix appears after all
42 | # file names beginning with the prefix.
43 |
44 | sort -r tmpsubstfile1 | sed 's/^[^ ]*[ ]*//' > tmpsubstfile2
45 |
46 |
47 | change_include()
48 |
49 | {
50 | sed -e '\#^....../include *"libxmlrpg/#{' \
51 | -e 's///' \
52 | -e 's/".*//' \
53 | -f tmpsubstfile2 \
54 | -e 's#.*# /include libxmlrpg,' \
55 | -e '}'
56 | }
57 |
58 |
59 | # Create the IFS directory for the ILE/RPG header files.
60 |
61 | RPGIFSDIR="${IFSDIR}/include/libxmlrpg"
62 |
63 | if action_needed "${RPGIFSDIR}"
64 | then mkdir -p "${RPGIFSDIR}"
65 | fi
66 |
67 | # Copy the header files to IFS ILE/RPG include directory.
68 | # Copy them with include path editing to the DB2 library.
69 |
70 | for HFILE in *.rpgle *.rpgle.in
71 | do IFSCMD="cat \"${HFILE}\""
72 | DB2CMD="change_include < \"${HFILE}\""
73 | IFSFILE="`basename \"${HFILE}\" .in`"
74 |
75 | case "${HFILE}" in
76 |
77 | *.in) IFSCMD="${IFSCMD} | versioned_copy"
78 | DB2CMD="${DB2CMD} | versioned_copy"
79 | ;;
80 | esac
81 |
82 | IFSDEST="${RPGIFSDIR}/${IFSFILE}"
83 |
84 | if action_needed "${IFSDEST}" "${HFILE}"
85 | then eval "${IFSCMD}" > "${IFSDEST}"
86 | fi
87 |
88 | eval DB2MBR="\"\${VAR_`basename \"${IFSDEST}\" .rpgle`}\""
89 | DB2DEST="${SRCPF}/${DB2MBR}.MBR"
90 |
91 | if action_needed "${DB2DEST}" "${HFILE}"
92 | then eval "${DB2CMD}" | change_include > tmphdrfile
93 |
94 | # Need to translate to target CCSID.
95 |
96 | CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DB2DEST}')"
97 | CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
98 | system "${CMD}"
99 | fi
100 | done
101 |
--------------------------------------------------------------------------------
/upstream/fuzz/valid.c:
--------------------------------------------------------------------------------
1 | /*
2 | * valid.c: a libFuzzer target to test DTD validation.
3 | *
4 | * See Copyright for the status of this software.
5 | */
6 |
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include "fuzz.h"
13 |
14 | int
15 | LLVMFuzzerInitialize(int *argc ATTRIBUTE_UNUSED,
16 | char ***argv ATTRIBUTE_UNUSED) {
17 | xmlFuzzMemSetup();
18 | xmlInitParser();
19 | #ifdef LIBXML_CATALOG_ENABLED
20 | xmlInitializeCatalog();
21 | #endif
22 | xmlSetGenericErrorFunc(NULL, xmlFuzzErrorFunc);
23 | xmlSetExternalEntityLoader(xmlFuzzEntityLoader);
24 |
25 | return 0;
26 | }
27 |
28 | int
29 | LLVMFuzzerTestOneInput(const char *data, size_t size) {
30 | static const size_t maxChunkSize = 128;
31 | xmlDocPtr doc;
32 | xmlParserCtxtPtr ctxt;
33 | xmlValidCtxtPtr vctxt;
34 | xmlTextReaderPtr reader;
35 | const char *docBuffer, *docUrl;
36 | size_t maxAlloc, docSize, consumed, chunkSize;
37 | int opts;
38 |
39 | xmlFuzzDataInit(data, size);
40 | opts = (int) xmlFuzzReadInt(4);
41 | opts &= ~XML_PARSE_XINCLUDE;
42 | opts |= XML_PARSE_DTDVALID;
43 | maxAlloc = xmlFuzzReadInt(4) % (size + 1);
44 |
45 | xmlFuzzReadEntities();
46 | docBuffer = xmlFuzzMainEntity(&docSize);
47 | docUrl = xmlFuzzMainUrl();
48 | if (docBuffer == NULL)
49 | goto exit;
50 |
51 | /* Pull parser */
52 |
53 | xmlFuzzMemSetLimit(maxAlloc);
54 | doc = xmlReadMemory(docBuffer, docSize, docUrl, NULL, opts);
55 | xmlFreeDoc(doc);
56 |
57 | /* Post validation */
58 |
59 | xmlFuzzMemSetLimit(maxAlloc);
60 | doc = xmlReadMemory(docBuffer, docSize, docUrl, NULL, opts & ~XML_PARSE_DTDVALID);
61 | vctxt = xmlNewValidCtxt();
62 | xmlValidateDocument(vctxt, doc);
63 | xmlFreeValidCtxt(vctxt);
64 | xmlFreeDoc(doc);
65 |
66 | /* Push parser */
67 |
68 | xmlFuzzMemSetLimit(maxAlloc);
69 | ctxt = xmlCreatePushParserCtxt(NULL, NULL, NULL, 0, docUrl);
70 | if (ctxt == NULL)
71 | goto exit;
72 | xmlCtxtUseOptions(ctxt, opts);
73 |
74 | for (consumed = 0; consumed < docSize; consumed += chunkSize) {
75 | chunkSize = docSize - consumed;
76 | if (chunkSize > maxChunkSize)
77 | chunkSize = maxChunkSize;
78 | xmlParseChunk(ctxt, docBuffer + consumed, chunkSize, 0);
79 | }
80 |
81 | xmlParseChunk(ctxt, NULL, 0, 1);
82 | xmlFreeDoc(ctxt->myDoc);
83 | xmlFreeParserCtxt(ctxt);
84 |
85 | /* Reader */
86 |
87 | xmlFuzzMemSetLimit(maxAlloc);
88 | reader = xmlReaderForMemory(docBuffer, docSize, NULL, NULL, opts);
89 | if (reader == NULL)
90 | goto exit;
91 | while (xmlTextReaderRead(reader) == 1) {
92 | if (xmlTextReaderNodeType(reader) == XML_ELEMENT_NODE) {
93 | int i, n = xmlTextReaderAttributeCount(reader);
94 | for (i=0; i