2000-04-05 22:38:42 +04:00
/*
* xmllint . c : a small tester program for XML input .
*
* See Copyright for the status of this software .
*
2001-06-24 16:13:24 +04:00
* daniel @ veillard . com
2000-04-05 22:38:42 +04:00
*/
2001-04-21 20:57:29 +04:00
# include "libxml.h"
2000-04-05 22:38:42 +04:00
# include <string.h>
# include <stdarg.h>
2022-12-08 05:45:37 +03:00
# include <stdio.h>
2022-03-02 02:29:17 +03:00
# include <stdlib.h>
2003-01-06 01:37:17 +03:00
# include <assert.h>
2022-03-02 02:29:17 +03:00
# include <time.h>
2023-04-20 17:22:11 +03:00
# include <errno.h>
# include <limits.h>
2003-01-06 01:37:17 +03:00
2001-12-13 11:48:14 +03:00
# ifdef HAVE_SYS_TIME_H
2001-02-25 19:11:03 +03:00
# include <sys/time.h>
2001-12-13 11:48:14 +03:00
# endif
2002-03-07 18:12:58 +03:00
# ifdef HAVE_SYS_TIMEB_H
# include <sys/timeb.h>
# endif
2000-04-05 22:38:42 +04:00
# ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
# endif
# ifdef HAVE_FCNTL_H
# include <fcntl.h>
# endif
# ifdef HAVE_UNISTD_H
# include <unistd.h>
2022-11-22 17:37:49 +03:00
# elif defined (_WIN32)
# include <io.h>
2000-04-05 22:38:42 +04:00
# endif
2000-07-22 00:32:03 +04:00
# ifdef HAVE_SYS_MMAN_H
# include <sys/mman.h>
2000-08-13 01:12:04 +04:00
/* seems needed for Solaris */
# ifndef MAP_FAILED
# define MAP_FAILED ((void *) -1)
# endif
2000-07-22 00:32:03 +04:00
# endif
2000-04-05 22:38:42 +04:00
# ifdef HAVE_LIBREADLINE
# include <readline/readline.h>
# ifdef HAVE_LIBHISTORY
# include <readline/history.h>
# endif
# endif
# include <libxml/xmlmemory.h>
# include <libxml/parser.h>
# include <libxml/parserInternals.h>
# include <libxml/HTMLparser.h>
# include <libxml/HTMLtree.h>
# include <libxml/tree.h>
# include <libxml/xpath.h>
# include <libxml/debugXML.h>
2000-10-25 23:56:55 +04:00
# include <libxml/xmlerror.h>
2000-11-06 19:43:11 +03:00
# ifdef LIBXML_XINCLUDE_ENABLED
# include <libxml/xinclude.h>
# endif
2001-05-22 19:08:55 +04:00
# ifdef LIBXML_CATALOG_ENABLED
# include <libxml/catalog.h>
# endif
2003-01-03 19:19:51 +03:00
# include <libxml/xmlreader.h>
2005-07-24 18:27:16 +04:00
# ifdef LIBXML_SCHEMATRON_ENABLED
# include <libxml/schematron.h>
# endif
2003-02-05 16:19:53 +03:00
# ifdef LIBXML_SCHEMAS_ENABLED
# include <libxml/relaxng.h>
2003-05-12 19:25:56 +04:00
# include <libxml/xmlschemas.h>
2003-02-05 16:19:53 +03:00
# endif
2003-12-03 01:32:15 +03:00
# ifdef LIBXML_PATTERN_ENABLED
# include <libxml/pattern.h>
# endif
2004-08-22 17:11:39 +04:00
# ifdef LIBXML_C14N_ENABLED
# include <libxml/c14n.h>
# endif
2006-10-17 03:22:10 +04:00
# ifdef LIBXML_OUTPUT_ENABLED
# include <libxml/xmlsave.h>
# endif
2000-04-05 22:38:42 +04:00
2024-05-13 13:18:08 +03:00
# ifdef XMLLINT_FUZZ
# define ERR_STREAM stdout
# else
# define ERR_STREAM stderr
# endif
2024-05-06 01:33:19 +03:00
2003-01-26 22:49:04 +03:00
# ifndef XML_XML_DEFAULT_CATALOG
2022-03-30 01:32:35 +03:00
# define XML_XML_DEFAULT_CATALOG "file: //" SYSCONFDIR "/xml/catalog"
2003-01-26 22:49:04 +03:00
# endif
2023-12-21 01:53:19 +03:00
# ifndef STDIN_FILENO
# define STDIN_FILENO 0
# endif
2004-06-08 17:29:32 +04:00
typedef enum {
2024-02-12 18:45:16 +03:00
XMLLINT_RETURN_OK = 0 , /* No error */
XMLLINT_ERR_UNCLASS = 1 , /* Unclassified */
XMLLINT_ERR_DTD = 2 , /* Error in DTD */
XMLLINT_ERR_VALID = 3 , /* Validation error */
XMLLINT_ERR_RDFILE = 4 , /* CtxtReadFile error */
XMLLINT_ERR_SCHEMACOMP = 5 , /* Schema compilation */
XMLLINT_ERR_OUT = 6 , /* Error writing output */
XMLLINT_ERR_SCHEMAPAT = 7 , /* Error in schema pattern */
2024-04-28 18:33:19 +03:00
/*XMLLINT_ERR_RDREGIS = 8,*/
2024-02-12 18:45:16 +03:00
XMLLINT_ERR_MEM = 9 , /* Out of memory error */
XMLLINT_ERR_XPATH = 10 , /* XPath evaluation error */
XMLLINT_ERR_XPATH_EMPTY = 11 /* XPath result is empty */
2004-06-08 17:29:32 +04:00
} xmllintReturnCode ;
2024-05-07 17:53:43 +03:00
2000-04-05 22:38:42 +04:00
# ifdef LIBXML_DEBUG_ENABLED
static int shell = 0 ;
static int debugent = 0 ;
# endif
2003-01-07 03:19:07 +03:00
static int debug = 0 ;
2004-05-04 02:54:49 +04:00
static int maxmem = 0 ;
2000-04-05 22:38:42 +04:00
static int copy = 0 ;
static int noout = 0 ;
2022-08-24 16:51:28 +03:00
# ifdef LIBXML_OUTPUT_ENABLED
2003-09-29 17:20:24 +04:00
static const char * output = NULL ;
2024-05-07 17:53:43 +03:00
static int format = 0 ;
static const char * encoding = NULL ;
2003-09-29 17:20:24 +04:00
static int compress = 0 ;
# endif /* LIBXML_OUTPUT_ENABLED */
2003-09-28 22:58:27 +04:00
# ifdef LIBXML_VALID_ENABLED
2000-04-05 22:38:42 +04:00
static int postvalid = 0 ;
2024-05-05 16:20:15 +03:00
static const char * dtdvalid = NULL ;
static const char * dtdvalidfpi = NULL ;
2024-05-07 17:53:43 +03:00
static int insert = 0 ;
2003-09-28 22:58:27 +04:00
# endif
2003-02-05 16:19:53 +03:00
# ifdef LIBXML_SCHEMAS_ENABLED
2024-05-05 16:20:15 +03:00
static const char * relaxng = NULL ;
2003-02-05 16:19:53 +03:00
static xmlRelaxNGPtr relaxngschemas = NULL ;
2024-05-05 16:20:15 +03:00
static const char * schema = NULL ;
2003-05-12 19:25:56 +04:00
static xmlSchemaPtr wxschemas = NULL ;
2003-02-05 16:19:53 +03:00
# endif
2005-09-09 01:39:47 +04:00
# ifdef LIBXML_SCHEMATRON_ENABLED
2024-05-05 16:20:15 +03:00
static const char * schematron = NULL ;
2005-07-24 18:27:16 +04:00
static xmlSchematronPtr wxschematron = NULL ;
# endif
2000-04-05 22:38:42 +04:00
static int repeat = 0 ;
2024-05-07 17:53:43 +03:00
# if defined(LIBXML_HTML_ENABLED)
2000-04-05 22:38:42 +04:00
static int html = 0 ;
2003-11-04 11:47:48 +03:00
static int xmlout = 0 ;
2003-09-28 22:58:27 +04:00
# endif
2000-04-05 22:38:42 +04:00
static int htmlout = 0 ;
2003-09-30 16:36:01 +04:00
# ifdef LIBXML_PUSH_ENABLED
2000-04-05 22:38:42 +04:00
static int push = 0 ;
2012-10-25 11:37:50 +04:00
static int pushsize = 4096 ;
2003-09-30 16:36:01 +04:00
# endif /* LIBXML_PUSH_ENABLED */
Various "make distcheck" and portability fixups
Makefile.am:
* Don't use @VAR@, use $(VAR). Autoconf's AC_SUBST provides us the Make
variable, it allows overriding the value at the command line, and
(notably) it avoids a Make parse error in the libxml2_la_LDFLAGS
assignment when @MODULE_PLATFORM_LIBS@ is empty
* Changed how the THREADS_W32 mechanism switches the build between
testThreads.c and testThreadsWin32.c as appropriate; using AM_CONDITIONAL
allows this to work cleanly and plays well with dependencies
* testapi.c should be specified as BUILT_SOURCES
* Create symlinks to the test/ and result/ subdirs so that the runtests
target is usable in out-of-source-tree builds
* Don't do MAKEFLAGS+=--silent as this is not portable to non-GNU Makes
* Fixed incorrect find(1) syntax in the "cleanup" rule, and doing "rm -f"
instead of just "rm" is good form
* (DIST)CLEANFILES needed a bit more coverage to allow "make distcheck" to
pass
configure.in:
* Need AC_PROG_LN_S to create test/ and result/ symlinks in Makefile.am
* AC_LIBTOOL_WIN32_DLL and AM_PROG_LIBTOOL are obsolete; these have been
superceded by LT_INIT
* Don't rebuild docs by default, as this requires GNU Make (as
implemented)
* Check for uint32_t as some platforms don't provide it
* Check for some more functions, and undefine HAVE_MMAP if we don't also
HAVE_MUNMAP (one system I tested on actually needed this)
* Changed THREADS_W32 from a filename insert into an Automake conditional
* The "Copyright" file will not be in the current directory if builddir !=
srcdir
doc/Makefile.am:
* EXTRA_DIST cannot use wildcards when they refer to generated files; this
breaks dependencies. What I did was define EXTRA_DIST_wc, which uses GNU
Make $(wildcard) directives to build up a list of files, and EXTRA_DIST,
as a literal expansion of EXTRA_DIST_wc. I also added a new rule,
"check-extra-dist", to simplify checking that the two variables are
equivalent. (Note that this works only when builddir == srcdir)
(I can implement this differently if desired; this is just one way of
doing it)
* Don't define an "all" target; this steps on Automake's toes
* Fixed up the "libxml2-api.xml ..." rule by using $(wildcard) for
dependencies (as Make doesn't process the wildcards otherwise) and
qualifying appropriate files with $(srcdir)
(Note that $(srcdir) is not needed in the dependencies, thanks to VPATH,
which we can count on as this is GNU-Make-only code anyway)
doc/devhelp/Makefile.am:
* Qualified appropriate files with $(srcdir)
* Added an "uninstall-local" rule so that "make distcheck" passes
doc/examples/Makefile.am:
* Rather than use a wildcard that doesn't work, use a substitution that
most Make programs can handle
doc/examples/index.py:
* Do the same here
include/libxml/nanoftp.h:
* Some platforms (e.g. MSVC 6) already #define INVALID_SOCKET:
user@host:/cygdrive/c/Program Files/Microsoft Visual Studio/VC98/\
Include$ grep -R INVALID_SOCKET .
./WINSOCK.H:#define INVALID_SOCKET (SOCKET)(~0)
./WINSOCK2.H:#define INVALID_SOCKET (SOCKET)(~0)
include/libxml/xmlversion.h.in:
* Support ancient GCCs (I was actually able to build the library with 2.5
but for this bit)
python/Makefile.am:
* Expanded CLEANFILES to allow "make distcheck" to pass
python/tests/Makefile.am:
* Define CLEANFILES instead of a "clean" rule, and added tmp.xml to allow
"make distcheck" to pass
testRelax.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H (as some
systems have the header but not the function)
testSchemas.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H
testapi.c:
* Don't use putenv() if it's not available
threads.c:
* This fixes the following build error on Solaris 8:
libtool: compile: cc -DHAVE_CONFIG_H -I. -I./include -I./include \
-D_REENTRANT -D__EXTENSIONS__ -D_REENTRANT -Dsparc -Xa -mt -v \
-xarch=v9 -xcrossfile -xO5 -c threads.c -KPIC -DPIC -o threads.o
"threads.c", line 442: controlling expressions must have scalar type
"threads.c", line 512: controlling expressions must have scalar type
cc: acomp failed for threads.c
*** Error code 1
trio.c:
* Define isascii() if the system doesn't provide it
trio.h:
* The trio library's HAVE_CONFIG_H header is not the same as LibXML2's
HAVE_CONFIG_H header; this change is needed to avoid a double-inclusion
win32/configure.js:
* Added support for the LZMA compression option
win32/Makefile.{bcb,mingw,msvc}:
* Added appropriate bits to support WITH_LZMA=1
* Install the header files under $(INCPREFIX)\libxml2\libxml instead of
$(INCPREFIX)\libxml, to mirror the install location on Unix+Autotools
xml2-config.in:
* @MODULE_PLATFORM_LIBS@ (usually "-ldl") needs to be in there in order for
`xml2-config --libs` to provide a complete set of dependencies
xmllint.c:
* Use HAVE_MMAP instead of the less-explicit HAVE_SYS_MMAN_H
2012-08-06 07:32:54 +04:00
# ifdef HAVE_MMAP
2000-07-22 00:32:03 +04:00
static int memory = 0 ;
# endif
2000-04-12 17:27:38 +04:00
static int testIO = 0 ;
2000-11-06 19:43:11 +03:00
# ifdef LIBXML_XINCLUDE_ENABLED
static int xinclude = 0 ;
# endif
2004-06-08 17:29:32 +04:00
static xmllintReturnCode progresult = XMLLINT_RETURN_OK ;
2021-02-03 01:27:52 +03:00
static int quiet = 0 ;
2001-02-25 19:11:03 +03:00
static int timing = 0 ;
2001-04-11 11:50:02 +04:00
static int generate = 0 ;
2001-12-14 01:21:58 +03:00
static int dropdtd = 0 ;
2004-08-15 02:37:54 +04:00
# ifdef LIBXML_C14N_ENABLED
static int canonical = 0 ;
2009-07-09 12:26:22 +04:00
static int canonical_11 = 0 ;
2005-06-06 21:16:50 +04:00
static int exc_canonical = 0 ;
2004-08-15 02:37:54 +04:00
# endif
2003-09-30 04:43:48 +04:00
# ifdef LIBXML_READER_ENABLED
2003-11-03 15:31:38 +03:00
static int walker = 0 ;
2019-05-16 22:06:56 +03:00
# ifdef LIBXML_PATTERN_ENABLED
static const char * pattern = NULL ;
static xmlPatternPtr patternc = NULL ;
static xmlStreamCtxtPtr patstream = NULL ;
# endif
2003-09-30 04:43:48 +04:00
# endif /* LIBXML_READER_ENABLED */
2009-10-07 12:25:06 +04:00
# ifdef LIBXML_XPATH_ENABLED
static const char * xpathquery = NULL ;
# endif
2012-08-13 08:41:33 +04:00
static int options = XML_PARSE_COMPACT | XML_PARSE_BIG_LINES ;
2023-08-20 21:48:10 +03:00
static unsigned maxAmpl = 0 ;
2001-12-18 14:14:16 +03:00
2004-08-31 13:37:03 +04:00
/************************************************************************
* *
* Entity loading control and customization . *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# define MAX_PATHS 64
2007-04-17 16:33:19 +04:00
# ifdef _WIN32
# define PATH_SEPARATOR ';'
# else
# define PATH_SEPARATOR ':'
# endif
2004-08-31 13:37:03 +04:00
static xmlChar * paths [ MAX_PATHS + 1 ] ;
static int nbpaths = 0 ;
static int load_trace = 0 ;
static
void parsePath ( const xmlChar * path ) {
const xmlChar * cur ;
if ( path = = NULL )
return ;
while ( * path ! = 0 ) {
if ( nbpaths > = MAX_PATHS ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " MAX_PATHS reached: too many paths \n " ) ;
2004-08-31 13:37:03 +04:00
return ;
}
cur = path ;
2007-04-17 16:33:19 +04:00
while ( ( * cur = = ' ' ) | | ( * cur = = PATH_SEPARATOR ) )
2004-08-31 13:37:03 +04:00
cur + + ;
path = cur ;
2007-04-17 16:33:19 +04:00
while ( ( * cur ! = 0 ) & & ( * cur ! = ' ' ) & & ( * cur ! = PATH_SEPARATOR ) )
2004-08-31 13:37:03 +04:00
cur + + ;
if ( cur ! = path ) {
paths [ nbpaths ] = xmlStrndup ( path , cur - path ) ;
if ( paths [ nbpaths ] ! = NULL )
nbpaths + + ;
path = cur ;
}
}
}
2024-06-11 19:14:43 +03:00
static xmlResourceLoader defaultResourceLoader = NULL ;
2004-08-31 13:37:03 +04:00
2024-06-11 19:14:43 +03:00
static int
xmllintResourceLoader ( void * ctxt ATTRIBUTE_UNUSED , const char * URL ,
2024-06-11 20:10:41 +03:00
const char * ID , xmlResourceType type , int flags ,
2024-06-11 19:14:43 +03:00
xmlParserInputPtr * out ) {
int code ;
2004-08-31 13:37:03 +04:00
int i ;
const char * lastsegment = URL ;
const char * iter = URL ;
2008-01-11 09:53:15 +03:00
if ( ( nbpaths > 0 ) & & ( iter ! = NULL ) ) {
2004-08-31 13:37:03 +04:00
while ( * iter ! = 0 ) {
if ( * iter = = ' / ' )
lastsegment = iter + 1 ;
iter + + ;
}
}
2024-06-11 19:14:43 +03:00
if ( defaultResourceLoader ! = NULL )
code = defaultResourceLoader ( NULL , URL , ID , type , flags , out ) ;
else
code = xmlInputCreateUrl ( URL , flags , out ) ;
if ( code ! = XML_IO_ENOENT ) {
if ( ( load_trace ) & & ( code = = XML_ERR_OK ) ) {
fprintf ( ERR_STREAM , " Loaded URL= \" %s \" ID= \" %s \" \n " ,
URL , ID ? ID : " (null) " ) ;
}
return ( code ) ;
2004-08-31 13:37:03 +04:00
}
2024-06-11 19:14:43 +03:00
for ( i = 0 ; i < nbpaths ; i + + ) {
2004-08-31 13:37:03 +04:00
xmlChar * newURL ;
newURL = xmlStrdup ( ( const xmlChar * ) paths [ i ] ) ;
newURL = xmlStrcat ( newURL , ( const xmlChar * ) " / " ) ;
newURL = xmlStrcat ( newURL , ( const xmlChar * ) lastsegment ) ;
if ( newURL ! = NULL ) {
2024-06-11 19:14:43 +03:00
if ( defaultResourceLoader ! = NULL )
code = defaultResourceLoader ( NULL , ( const char * ) newURL , ID ,
type , flags , out ) ;
else
code = xmlInputCreateUrl ( ( const char * ) newURL , flags , out ) ;
if ( code ! = XML_IO_ENOENT ) {
if ( ( load_trace ) & & ( code = = XML_ERR_OK ) ) {
fprintf ( ERR_STREAM , " Loaded URL= \" %s \" ID= \" %s \" \n " ,
newURL , ID ? ID : " (null) " ) ;
}
xmlFree ( newURL ) ;
return ( code ) ;
}
2004-08-31 13:37:03 +04:00
xmlFree ( newURL ) ;
}
}
2024-06-11 19:14:43 +03:00
return ( XML_IO_ENOENT ) ;
2004-08-31 13:37:03 +04:00
}
2024-05-13 13:18:08 +03:00
2004-05-04 02:54:49 +04:00
/************************************************************************
2009-08-10 16:43:18 +04:00
* *
2004-05-04 02:54:49 +04:00
* Memory allocation consumption debugging *
2009-08-10 16:43:18 +04:00
* *
2004-05-04 02:54:49 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2004-05-05 23:22:30 +04:00
static void
OOM ( void )
{
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Ran out of memory needs > %d bytes \n " , maxmem ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_MEM ;
2004-05-04 02:54:49 +04:00
}
2004-05-05 23:22:30 +04:00
static void
myFreeFunc ( void * mem )
{
2004-05-04 02:54:49 +04:00
xmlMemFree ( mem ) ;
}
2004-05-05 23:22:30 +04:00
static void *
myMallocFunc ( size_t size )
{
2004-05-04 02:54:49 +04:00
void * ret ;
ret = xmlMemMalloc ( size ) ;
if ( ret ! = NULL ) {
if ( xmlMemUsed ( ) > maxmem ) {
2004-05-05 23:22:30 +04:00
OOM ( ) ;
xmlMemFree ( ret ) ;
return ( NULL ) ;
}
2004-05-04 02:54:49 +04:00
}
2004-05-05 23:22:30 +04:00
return ( ret ) ;
2004-05-04 02:54:49 +04:00
}
2004-05-05 23:22:30 +04:00
static void *
myReallocFunc ( void * mem , size_t size )
{
2023-03-14 15:02:36 +03:00
size_t oldsize = xmlMemSize ( mem ) ;
2004-05-04 02:54:49 +04:00
2023-03-14 15:02:36 +03:00
if ( xmlMemUsed ( ) + size - oldsize > ( size_t ) maxmem ) {
OOM ( ) ;
return ( NULL ) ;
2004-05-04 02:54:49 +04:00
}
2023-03-14 15:02:36 +03:00
return ( xmlMemRealloc ( mem , size ) ) ;
2004-05-04 02:54:49 +04:00
}
2004-05-05 23:22:30 +04:00
static char *
myStrdupFunc ( const char * str )
{
2004-05-04 02:54:49 +04:00
char * ret ;
ret = xmlMemoryStrdup ( str ) ;
if ( ret ! = NULL ) {
if ( xmlMemUsed ( ) > maxmem ) {
2004-05-05 23:22:30 +04:00
OOM ( ) ;
2024-05-13 13:18:08 +03:00
xmlMemFree ( ret ) ;
2004-05-05 23:22:30 +04:00
return ( NULL ) ;
}
2004-05-04 02:54:49 +04:00
}
2004-05-05 23:22:30 +04:00
return ( ret ) ;
2004-05-04 02:54:49 +04:00
}
/************************************************************************
2009-08-10 16:43:18 +04:00
* *
2004-05-04 02:54:49 +04:00
* Internal timing routines to remove the necessity to have *
* unix - specific function calls . *
2009-08-10 16:43:18 +04:00
* *
2004-05-04 02:54:49 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-12-18 10:09:59 +03:00
2009-08-10 16:43:18 +04:00
# ifndef HAVE_GETTIMEOFDAY
2002-03-07 14:21:00 +03:00
# ifdef HAVE_SYS_TIMEB_H
# ifdef HAVE_SYS_TIME_H
# ifdef HAVE_FTIME
2002-12-10 18:19:08 +03:00
static int
2002-03-07 14:21:00 +03:00
my_gettimeofday ( struct timeval * tvp , void * tzp )
{
struct timeb timebuffer ;
ftime ( & timebuffer ) ;
if ( tvp ) {
tvp - > tv_sec = timebuffer . time ;
tvp - > tv_usec = timebuffer . millitm * 1000L ;
}
return ( 0 ) ;
}
# define HAVE_GETTIMEOFDAY 1
# define gettimeofday my_gettimeofday
# endif /* HAVE_FTIME */
# endif /* HAVE_SYS_TIME_H */
# endif /* HAVE_SYS_TIMEB_H */
# endif /* !HAVE_GETTIMEOFDAY */
2001-12-18 10:09:59 +03:00
# if defined(HAVE_GETTIMEOFDAY)
static struct timeval begin , end ;
/*
* startTimer : call where you want to start timing
*/
static void
startTimer ( void )
{
gettimeofday ( & begin , NULL ) ;
}
/*
* endTimer : call where you want to stop timing and to print out a
* message about the timing performed ; format is a printf
* type argument
*/
2022-12-08 04:43:17 +03:00
static void LIBXML_ATTR_FORMAT ( 1 , 2 )
2002-09-24 18:13:13 +04:00
endTimer ( const char * fmt , . . . )
2001-12-18 10:09:59 +03:00
{
long msec ;
va_list ap ;
gettimeofday ( & end , NULL ) ;
msec = end . tv_sec - begin . tv_sec ;
msec * = 1000 ;
msec + = ( end . tv_usec - begin . tv_usec ) / 1000 ;
2002-09-24 18:13:13 +04:00
va_start ( ap , fmt ) ;
2024-05-06 01:33:19 +03:00
vfprintf ( ERR_STREAM , fmt , ap ) ;
2001-12-18 10:09:59 +03:00
va_end ( ap ) ;
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " took %ld ms \n " , msec ) ;
2001-12-18 10:09:59 +03:00
}
2022-03-02 02:29:17 +03:00
# else
2001-12-18 10:09:59 +03:00
/*
* No gettimeofday function , so we have to make do with calling clock .
* This is obviously less accurate , but there ' s little we can do about
* that .
*/
2002-03-07 18:12:58 +03:00
# ifndef CLOCKS_PER_SEC
# define CLOCKS_PER_SEC 100
# endif
2001-12-18 10:09:59 +03:00
static clock_t begin , end ;
static void
startTimer ( void )
{
begin = clock ( ) ;
}
2022-12-08 04:43:17 +03:00
static void LIBXML_ATTR_FORMAT ( 1 , 2 )
2001-12-18 10:09:59 +03:00
endTimer ( const char * fmt , . . . )
{
long msec ;
va_list ap ;
end = clock ( ) ;
msec = ( ( end - begin ) * 1000 ) / CLOCKS_PER_SEC ;
va_start ( ap , fmt ) ;
2024-05-06 01:33:19 +03:00
vfprintf ( ERR_STREAM , fmt , ap ) ;
2001-12-18 10:09:59 +03:00
va_end ( ap ) ;
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " took %ld ms \n " , msec ) ;
2001-12-18 10:09:59 +03:00
}
# endif
2000-04-05 22:38:42 +04:00
/************************************************************************
2009-08-10 16:43:18 +04:00
* *
2019-09-30 18:04:54 +03:00
* HTML output *
2009-08-10 16:43:18 +04:00
* *
2000-04-05 22:38:42 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-07-29 03:49:35 +04:00
static char buffer [ 50000 ] ;
2024-06-11 00:05:40 +03:00
static int htmlBufLen ;
2000-04-05 22:38:42 +04:00
2001-03-24 20:00:36 +03:00
static void
2000-04-05 22:38:42 +04:00
xmlHTMLEncodeSend ( void ) {
char * result ;
2020-08-07 22:54:27 +03:00
/*
* xmlEncodeEntitiesReentrant assumes valid UTF - 8 , but the buffer might
* end with a truncated UTF - 8 sequence . This is a hack to at least avoid
* an out - of - bounds read .
*/
memset ( & buffer [ sizeof ( buffer ) - 4 ] , 0 , 4 ) ;
2000-04-05 22:38:42 +04:00
result = ( char * ) xmlEncodeEntitiesReentrant ( NULL , BAD_CAST buffer ) ;
if ( result ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s " , result ) ;
2000-04-05 22:38:42 +04:00
xmlFree ( result ) ;
}
2024-06-11 00:05:40 +03:00
htmlBufLen = 0 ;
}
2000-04-05 22:38:42 +04:00
2001-03-24 20:00:36 +03:00
static void
2024-06-11 00:05:40 +03:00
xmlHTMLBufCat ( void * data ATTRIBUTE_UNUSED , const char * fmt , . . . ) {
va_list ap ;
int res ;
2002-06-14 21:07:10 +04:00
2024-06-11 00:05:40 +03:00
va_start ( ap , fmt ) ;
res = vsnprintf ( & buffer [ htmlBufLen ] , sizeof ( buffer ) - htmlBufLen , fmt , ap ) ;
va_end ( ap ) ;
if ( res > 0 ) {
if ( ( size_t ) res > sizeof ( buffer ) - htmlBufLen - 1 )
htmlBufLen = sizeof ( buffer ) - 1 ;
else
htmlBufLen + = res ;
2000-04-05 22:38:42 +04:00
}
}
2001-03-24 20:00:36 +03:00
static void
2024-06-11 00:05:40 +03:00
xmlHTMLPrintError ( void * ctx , const char * level , const char * msg , va_list ap ) {
xmlParserCtxtPtr ctxt = ( xmlParserCtxtPtr ) ctx ;
xmlParserInputPtr input ;
input = ctxt - > input ;
if ( ( input ! = NULL ) & & ( input - > filename = = NULL ) & & ( ctxt - > inputNr > 1 ) ) {
input = ctxt - > inputTab [ ctxt - > inputNr - 2 ] ;
2000-04-05 22:38:42 +04:00
}
2024-06-11 00:05:40 +03:00
xmlSetGenericErrorFunc ( NULL , xmlHTMLBufCat ) ;
fprintf ( ERR_STREAM , " <p> " ) ;
xmlParserPrintFileInfo ( input ) ;
xmlHTMLEncodeSend ( ) ;
fprintf ( ERR_STREAM , " <b>%s</b>: " , level ) ;
vsnprintf ( buffer , sizeof ( buffer ) , msg , ap ) ;
2000-04-05 22:38:42 +04:00
xmlHTMLEncodeSend ( ) ;
2024-06-11 00:05:40 +03:00
fprintf ( ERR_STREAM , " </p> \n " ) ;
if ( input ! = NULL ) {
fprintf ( ERR_STREAM , " <pre> \n " ) ;
xmlParserPrintFileContext ( input ) ;
xmlHTMLEncodeSend ( ) ;
fprintf ( ERR_STREAM , " </pre> " ) ;
}
xmlSetGenericErrorFunc ( NULL , NULL ) ;
2000-04-05 22:38:42 +04:00
}
/**
* xmlHTMLError :
* @ ctx : an XML parser context
* @ msg : the message to display / transmit
* @ . . . : extra parameters for the message display
2009-08-10 16:43:18 +04:00
*
2000-04-05 22:38:42 +04:00
* Display and format an error messages , gives file , line , position and
* extra parameters .
*/
2022-12-08 04:43:17 +03:00
static void LIBXML_ATTR_FORMAT ( 2 , 3 )
2000-04-05 22:38:42 +04:00
xmlHTMLError ( void * ctx , const char * msg , . . . )
{
va_list args ;
va_start ( args , msg ) ;
2024-06-11 00:05:40 +03:00
xmlHTMLPrintError ( ctx , " error " , msg , args ) ;
2000-04-05 22:38:42 +04:00
va_end ( args ) ;
}
/**
* xmlHTMLWarning :
* @ ctx : an XML parser context
* @ msg : the message to display / transmit
* @ . . . : extra parameters for the message display
2009-08-10 16:43:18 +04:00
*
2000-04-05 22:38:42 +04:00
* Display and format a warning messages , gives file , line , position and
* extra parameters .
*/
2022-12-08 04:43:17 +03:00
static void LIBXML_ATTR_FORMAT ( 2 , 3 )
2000-04-05 22:38:42 +04:00
xmlHTMLWarning ( void * ctx , const char * msg , . . . )
{
va_list args ;
va_start ( args , msg ) ;
2024-06-11 00:05:40 +03:00
xmlHTMLPrintError ( ctx , " warning " , msg , args ) ;
2000-04-05 22:38:42 +04:00
va_end ( args ) ;
}
/**
* xmlHTMLValidityError :
* @ ctx : an XML parser context
* @ msg : the message to display / transmit
* @ . . . : extra parameters for the message display
2009-08-10 16:43:18 +04:00
*
2000-04-05 22:38:42 +04:00
* Display and format an validity error messages , gives file ,
* line , position and extra parameters .
*/
2022-12-08 04:43:17 +03:00
static void LIBXML_ATTR_FORMAT ( 2 , 3 )
2000-04-05 22:38:42 +04:00
xmlHTMLValidityError ( void * ctx , const char * msg , . . . )
{
va_list args ;
va_start ( args , msg ) ;
2024-06-11 00:05:40 +03:00
xmlHTMLPrintError ( ctx , " validity error " , msg , args ) ;
2000-04-05 22:38:42 +04:00
va_end ( args ) ;
2005-03-16 15:57:31 +03:00
progresult = XMLLINT_ERR_VALID ;
2000-04-05 22:38:42 +04:00
}
/**
* xmlHTMLValidityWarning :
* @ ctx : an XML parser context
* @ msg : the message to display / transmit
* @ . . . : extra parameters for the message display
2009-08-10 16:43:18 +04:00
*
2000-04-05 22:38:42 +04:00
* Display and format a validity warning messages , gives file , line ,
* position and extra parameters .
*/
2022-12-08 04:43:17 +03:00
static void LIBXML_ATTR_FORMAT ( 2 , 3 )
2000-04-05 22:38:42 +04:00
xmlHTMLValidityWarning ( void * ctx , const char * msg , . . . )
{
va_list args ;
va_start ( args , msg ) ;
2024-06-11 00:05:40 +03:00
xmlHTMLPrintError ( ctx , " validity warning " , msg , args ) ;
2000-04-05 22:38:42 +04:00
va_end ( args ) ;
}
/************************************************************************
2009-08-10 16:43:18 +04:00
* *
* Shell Interface *
* *
2000-04-05 22:38:42 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-01-07 14:17:25 +03:00
# ifdef LIBXML_DEBUG_ENABLED
2004-11-09 19:17:02 +03:00
# ifdef LIBXML_XPATH_ENABLED
2000-04-05 22:38:42 +04:00
/**
* xmlShellReadline :
* @ prompt : the prompt value
*
* Read a string
2009-08-10 16:43:18 +04:00
*
2000-04-05 22:38:42 +04:00
* Returns a pointer to it or NULL on EOF the caller is expected to
* free the returned string .
*/
2001-03-24 20:00:36 +03:00
static char *
2000-04-05 22:38:42 +04:00
xmlShellReadline ( char * prompt ) {
# ifdef HAVE_LIBREADLINE
char * line_read ;
/* Get a line from the user. */
line_read = readline ( prompt ) ;
/* If the line has any text in it, save it on the history. */
if ( line_read & & * line_read )
add_history ( line_read ) ;
return ( line_read ) ;
# else
char line_read [ 501 ] ;
2001-12-14 01:21:58 +03:00
char * ret ;
int len ;
2000-04-05 22:38:42 +04:00
if ( prompt ! = NULL )
fprintf ( stdout , " %s " , prompt ) ;
2015-04-17 18:02:59 +03:00
fflush ( stdout ) ;
2000-04-05 22:38:42 +04:00
if ( ! fgets ( line_read , 500 , stdin ) )
return ( NULL ) ;
line_read [ 500 ] = 0 ;
2001-12-14 01:21:58 +03:00
len = strlen ( line_read ) ;
ret = ( char * ) malloc ( len + 1 ) ;
if ( ret ! = NULL ) {
memcpy ( ret , line_read , len + 1 ) ;
}
return ( ret ) ;
2000-04-05 22:38:42 +04:00
# endif
}
2004-11-09 19:17:02 +03:00
# endif /* LIBXML_XPATH_ENABLED */
2003-01-07 14:17:25 +03:00
# endif /* LIBXML_DEBUG_ENABLED */
2000-04-05 22:38:42 +04:00
2000-04-12 17:27:38 +04:00
/************************************************************************
2009-08-10 16:43:18 +04:00
* *
* I / O Interfaces *
* *
2000-04-12 17:27:38 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2017-11-09 19:47:47 +03:00
static int myRead ( void * f , char * buf , int len ) {
return ( fread ( buf , 1 , len , ( FILE * ) f ) ) ;
2000-04-12 17:27:38 +04:00
}
2017-11-09 19:47:47 +03:00
static int myClose ( void * context ) {
FILE * f = ( FILE * ) context ;
if ( f = = stdin )
return ( 0 ) ;
return ( fclose ( f ) ) ;
2000-04-12 17:27:38 +04:00
}
2005-07-08 21:27:33 +04:00
/************************************************************************
* *
2009-08-10 16:43:18 +04:00
* SAX based tests *
2005-07-08 21:27:33 +04:00
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* empty SAX block
*/
2005-07-29 03:49:35 +04:00
static xmlSAXHandler emptySAXHandlerStruct = {
2005-07-08 21:27:33 +04:00
NULL , /* internalSubset */
NULL , /* isStandalone */
NULL , /* hasInternalSubset */
NULL , /* hasExternalSubset */
NULL , /* resolveEntity */
NULL , /* getEntity */
NULL , /* entityDecl */
NULL , /* notationDecl */
NULL , /* attributeDecl */
NULL , /* elementDecl */
NULL , /* unparsedEntityDecl */
NULL , /* setDocumentLocator */
NULL , /* startDocument */
NULL , /* endDocument */
NULL , /* startElement */
NULL , /* endElement */
NULL , /* reference */
NULL , /* characters */
NULL , /* ignorableWhitespace */
NULL , /* processingInstruction */
NULL , /* comment */
NULL , /* xmlParserWarning */
NULL , /* xmlParserError */
NULL , /* xmlParserError */
NULL , /* getParameterEntity */
NULL , /* cdataBlock; */
NULL , /* externalSubset; */
2005-07-09 21:32:57 +04:00
XML_SAX2_MAGIC ,
2005-07-08 21:27:33 +04:00
NULL ,
NULL , /* startElementNs */
NULL , /* endElementNs */
NULL /* xmlStructuredErrorFunc */
} ;
2005-07-29 03:49:35 +04:00
static xmlSAXHandlerPtr emptySAXHandler = & emptySAXHandlerStruct ;
2005-07-08 21:27:33 +04:00
extern xmlSAXHandlerPtr debugSAXHandler ;
static int callbacks ;
/**
* isStandaloneDebug :
* @ ctxt : An XML parser context
*
* Is this document tagged standalone ?
*
* Returns 1 if true
*/
static int
isStandaloneDebug ( void * ctx ATTRIBUTE_UNUSED )
{
callbacks + + ;
if ( noout )
return ( 0 ) ;
fprintf ( stdout , " SAX.isStandalone() \n " ) ;
return ( 0 ) ;
}
/**
* hasInternalSubsetDebug :
* @ ctxt : An XML parser context
*
* Does this document has an internal subset
*
* Returns 1 if true
*/
static int
hasInternalSubsetDebug ( void * ctx ATTRIBUTE_UNUSED )
{
callbacks + + ;
if ( noout )
return ( 0 ) ;
fprintf ( stdout , " SAX.hasInternalSubset() \n " ) ;
return ( 0 ) ;
}
/**
* hasExternalSubsetDebug :
* @ ctxt : An XML parser context
*
* Does this document has an external subset
*
* Returns 1 if true
*/
static int
hasExternalSubsetDebug ( void * ctx ATTRIBUTE_UNUSED )
{
callbacks + + ;
if ( noout )
return ( 0 ) ;
fprintf ( stdout , " SAX.hasExternalSubset() \n " ) ;
return ( 0 ) ;
}
/**
* internalSubsetDebug :
* @ ctxt : An XML parser context
*
* Does this document has an internal subset
*/
static void
internalSubsetDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * name ,
const xmlChar * ExternalID , const xmlChar * SystemID )
{
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.internalSubset(%s, " , name ) ;
if ( ExternalID = = NULL )
fprintf ( stdout , " , " ) ;
else
fprintf ( stdout , " %s, " , ExternalID ) ;
if ( SystemID = = NULL )
fprintf ( stdout , " ) \n " ) ;
else
fprintf ( stdout , " %s) \n " , SystemID ) ;
}
/**
* externalSubsetDebug :
* @ ctxt : An XML parser context
*
* Does this document has an external subset
*/
static void
externalSubsetDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * name ,
const xmlChar * ExternalID , const xmlChar * SystemID )
{
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.externalSubset(%s, " , name ) ;
if ( ExternalID = = NULL )
fprintf ( stdout , " , " ) ;
else
fprintf ( stdout , " %s, " , ExternalID ) ;
if ( SystemID = = NULL )
fprintf ( stdout , " ) \n " ) ;
else
fprintf ( stdout , " %s) \n " , SystemID ) ;
}
/**
* resolveEntityDebug :
* @ ctxt : An XML parser context
* @ publicId : The public ID of the entity
* @ systemId : The system ID of the entity
*
* Special entity resolver , better left to the parser , it has
* more context than the application layer .
* The default behaviour is to NOT resolve the entities , in that case
* the ENTITY_REF nodes are built in the structure ( and the parameter
* values ) .
*
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour .
*/
static xmlParserInputPtr
resolveEntityDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * publicId , const xmlChar * systemId )
{
callbacks + + ;
if ( noout )
return ( NULL ) ;
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
2009-08-10 16:43:18 +04:00
2005-07-08 21:27:33 +04:00
fprintf ( stdout , " SAX.resolveEntity( " ) ;
if ( publicId ! = NULL )
fprintf ( stdout , " %s " , ( char * ) publicId ) ;
else
fprintf ( stdout , " " ) ;
if ( systemId ! = NULL )
fprintf ( stdout , " , %s) \n " , ( char * ) systemId ) ;
else
fprintf ( stdout , " , ) \n " ) ;
return ( NULL ) ;
}
/**
* getEntityDebug :
* @ ctxt : An XML parser context
* @ name : The entity name
*
* Get an entity by name
*
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour .
*/
static xmlEntityPtr
getEntityDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * name )
{
callbacks + + ;
if ( noout )
return ( NULL ) ;
fprintf ( stdout , " SAX.getEntity(%s) \n " , name ) ;
return ( NULL ) ;
}
/**
* getParameterEntityDebug :
* @ ctxt : An XML parser context
* @ name : The entity name
*
* Get a parameter entity by name
*
* Returns the xmlParserInputPtr
*/
static xmlEntityPtr
getParameterEntityDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * name )
{
callbacks + + ;
if ( noout )
return ( NULL ) ;
fprintf ( stdout , " SAX.getParameterEntity(%s) \n " , name ) ;
return ( NULL ) ;
}
/**
* entityDeclDebug :
* @ ctxt : An XML parser context
2009-08-10 16:43:18 +04:00
* @ name : the entity name
* @ type : the entity type
2005-07-08 21:27:33 +04:00
* @ publicId : The public ID of the entity
* @ systemId : The system ID of the entity
* @ content : the entity value ( without processing ) .
*
* An entity definition has been parsed
*/
static void
entityDeclDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * name , int type ,
const xmlChar * publicId , const xmlChar * systemId , xmlChar * content )
{
const xmlChar * nullstr = BAD_CAST " (null) " ;
/* not all libraries handle printing null pointers nicely */
if ( publicId = = NULL )
publicId = nullstr ;
if ( systemId = = NULL )
systemId = nullstr ;
if ( content = = NULL )
content = ( xmlChar * ) nullstr ;
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.entityDecl(%s, %d, %s, %s, %s) \n " ,
name , type , publicId , systemId , content ) ;
}
/**
* attributeDeclDebug :
* @ ctxt : An XML parser context
2009-08-10 16:43:18 +04:00
* @ name : the attribute name
* @ type : the attribute type
2005-07-08 21:27:33 +04:00
*
* An attribute definition has been parsed
*/
static void
attributeDeclDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * elem ,
const xmlChar * name , int type , int def ,
const xmlChar * defaultValue , xmlEnumerationPtr tree )
{
callbacks + + ;
if ( noout )
return ;
if ( defaultValue = = NULL )
fprintf ( stdout , " SAX.attributeDecl(%s, %s, %d, %d, NULL, ...) \n " ,
elem , name , type , def ) ;
else
fprintf ( stdout , " SAX.attributeDecl(%s, %s, %d, %d, %s, ...) \n " ,
elem , name , type , def , defaultValue ) ;
xmlFreeEnumeration ( tree ) ;
}
/**
* elementDeclDebug :
* @ ctxt : An XML parser context
2009-08-10 16:43:18 +04:00
* @ name : the element name
* @ type : the element type
2005-07-08 21:27:33 +04:00
* @ content : the element value ( without processing ) .
*
* An element definition has been parsed
*/
static void
elementDeclDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * name , int type ,
xmlElementContentPtr content ATTRIBUTE_UNUSED )
{
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.elementDecl(%s, %d, ...) \n " ,
name , type ) ;
}
/**
* notationDeclDebug :
* @ ctxt : An XML parser context
* @ name : The name of the notation
* @ publicId : The public ID of the entity
* @ systemId : The system ID of the entity
*
* What to do when a notation declaration has been parsed .
*/
static void
notationDeclDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * name ,
const xmlChar * publicId , const xmlChar * systemId )
{
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.notationDecl(%s, %s, %s) \n " ,
( char * ) name , ( char * ) publicId , ( char * ) systemId ) ;
}
/**
* unparsedEntityDeclDebug :
* @ ctxt : An XML parser context
* @ name : The name of the entity
* @ publicId : The public ID of the entity
* @ systemId : The system ID of the entity
* @ notationName : the name of the notation
*
* What to do when an unparsed entity declaration is parsed
*/
static void
unparsedEntityDeclDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * name ,
const xmlChar * publicId , const xmlChar * systemId ,
const xmlChar * notationName )
{
const xmlChar * nullstr = BAD_CAST " (null) " ;
if ( publicId = = NULL )
publicId = nullstr ;
if ( systemId = = NULL )
systemId = nullstr ;
if ( notationName = = NULL )
notationName = nullstr ;
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.unparsedEntityDecl(%s, %s, %s, %s) \n " ,
( char * ) name , ( char * ) publicId , ( char * ) systemId ,
( char * ) notationName ) ;
}
/**
* setDocumentLocatorDebug :
* @ ctxt : An XML parser context
* @ loc : A SAX Locator
*
* Receive the document locator at startup , actually xmlDefaultSAXLocator
* Everything is available on the context , so this is useless in our case .
*/
static void
setDocumentLocatorDebug ( void * ctx ATTRIBUTE_UNUSED , xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED )
{
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.setDocumentLocator() \n " ) ;
}
/**
* startDocumentDebug :
* @ ctxt : An XML parser context
*
* called when the document start being processed .
*/
static void
startDocumentDebug ( void * ctx ATTRIBUTE_UNUSED )
{
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.startDocument() \n " ) ;
}
/**
* endDocumentDebug :
* @ ctxt : An XML parser context
*
* called when the document end has been detected .
*/
static void
endDocumentDebug ( void * ctx ATTRIBUTE_UNUSED )
{
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.endDocument() \n " ) ;
}
/**
* startElementDebug :
* @ ctxt : An XML parser context
* @ name : The element name
*
* called when an opening tag has been processed .
*/
static void
startElementDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * name , const xmlChar * * atts )
{
int i ;
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.startElement(%s " , ( char * ) name ) ;
if ( atts ! = NULL ) {
for ( i = 0 ; ( atts [ i ] ! = NULL ) ; i + + ) {
fprintf ( stdout , " , %s=' " , atts [ i + + ] ) ;
if ( atts [ i ] ! = NULL )
fprintf ( stdout , " %s' " , atts [ i ] ) ;
}
}
fprintf ( stdout , " ) \n " ) ;
}
/**
* endElementDebug :
* @ ctxt : An XML parser context
* @ name : The element name
*
* called when the end of an element has been detected .
*/
static void
endElementDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * name )
{
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.endElement(%s) \n " , ( char * ) name ) ;
}
/**
* charactersDebug :
* @ ctxt : An XML parser context
* @ ch : a xmlChar string
* @ len : the number of xmlChar
*
* receiving some chars from the parser .
* Question : how much at a time ? ? ?
*/
static void
charactersDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * ch , int len )
{
char out [ 40 ] ;
int i ;
callbacks + + ;
if ( noout )
return ;
for ( i = 0 ; ( i < len ) & & ( i < 30 ) ; i + + )
2024-05-05 19:16:11 +03:00
out [ i ] = ( char ) ch [ i ] ;
2005-07-08 21:27:33 +04:00
out [ i ] = 0 ;
fprintf ( stdout , " SAX.characters(%s, %d) \n " , out , len ) ;
}
/**
* referenceDebug :
* @ ctxt : An XML parser context
* @ name : The entity name
*
2009-08-10 16:43:18 +04:00
* called when an entity reference is detected .
2005-07-08 21:27:33 +04:00
*/
static void
referenceDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * name )
{
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.reference(%s) \n " , name ) ;
}
/**
* ignorableWhitespaceDebug :
* @ ctxt : An XML parser context
* @ ch : a xmlChar string
* @ start : the first char in the string
* @ len : the number of xmlChar
*
* receiving some ignorable whitespaces from the parser .
* Question : how much at a time ? ? ?
*/
static void
ignorableWhitespaceDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * ch , int len )
{
char out [ 40 ] ;
int i ;
callbacks + + ;
if ( noout )
return ;
for ( i = 0 ; ( i < len ) & & ( i < 30 ) ; i + + )
out [ i ] = ch [ i ] ;
out [ i ] = 0 ;
fprintf ( stdout , " SAX.ignorableWhitespace(%s, %d) \n " , out , len ) ;
}
/**
* processingInstructionDebug :
* @ ctxt : An XML parser context
* @ target : the target name
* @ data : the PI data ' s
* @ len : the number of xmlChar
*
* A processing instruction has been parsed .
*/
static void
processingInstructionDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * target ,
const xmlChar * data )
{
callbacks + + ;
if ( noout )
return ;
if ( data ! = NULL )
fprintf ( stdout , " SAX.processingInstruction(%s, %s) \n " ,
( char * ) target , ( char * ) data ) ;
else
fprintf ( stdout , " SAX.processingInstruction(%s, NULL) \n " ,
( char * ) target ) ;
}
/**
* cdataBlockDebug :
* @ ctx : the user data ( XML parser context )
* @ value : The pcdata content
* @ len : the block length
*
* called when a pcdata block has been parsed
*/
static void
cdataBlockDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * value , int len )
{
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.pcdata(%.20s, %d) \n " ,
( char * ) value , len ) ;
}
/**
* commentDebug :
* @ ctxt : An XML parser context
* @ value : the comment content
*
* A comment has been parsed .
*/
static void
commentDebug ( void * ctx ATTRIBUTE_UNUSED , const xmlChar * value )
{
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.comment(%s) \n " , value ) ;
}
/**
* warningDebug :
* @ ctxt : An XML parser context
* @ msg : the message to display / transmit
* @ . . . : extra parameters for the message display
*
* Display and format a warning messages , gives file , line , position and
* extra parameters .
*/
2022-12-08 04:43:17 +03:00
static void LIBXML_ATTR_FORMAT ( 2 , 3 )
2005-07-08 21:27:33 +04:00
warningDebug ( void * ctx ATTRIBUTE_UNUSED , const char * msg , . . . )
{
va_list args ;
callbacks + + ;
if ( noout )
return ;
va_start ( args , msg ) ;
fprintf ( stdout , " SAX.warning: " ) ;
vfprintf ( stdout , msg , args ) ;
va_end ( args ) ;
}
/**
* errorDebug :
* @ ctxt : An XML parser context
* @ msg : the message to display / transmit
* @ . . . : extra parameters for the message display
*
* Display and format a error messages , gives file , line , position and
* extra parameters .
*/
2022-12-08 04:43:17 +03:00
static void LIBXML_ATTR_FORMAT ( 2 , 3 )
2005-07-08 21:27:33 +04:00
errorDebug ( void * ctx ATTRIBUTE_UNUSED , const char * msg , . . . )
{
va_list args ;
callbacks + + ;
if ( noout )
return ;
va_start ( args , msg ) ;
fprintf ( stdout , " SAX.error: " ) ;
vfprintf ( stdout , msg , args ) ;
va_end ( args ) ;
}
/**
* fatalErrorDebug :
* @ ctxt : An XML parser context
* @ msg : the message to display / transmit
* @ . . . : extra parameters for the message display
*
* Display and format a fatalError messages , gives file , line , position and
* extra parameters .
*/
2022-12-08 04:43:17 +03:00
static void LIBXML_ATTR_FORMAT ( 2 , 3 )
2005-07-08 21:27:33 +04:00
fatalErrorDebug ( void * ctx ATTRIBUTE_UNUSED , const char * msg , . . . )
{
va_list args ;
callbacks + + ;
if ( noout )
return ;
va_start ( args , msg ) ;
fprintf ( stdout , " SAX.fatalError: " ) ;
vfprintf ( stdout , msg , args ) ;
va_end ( args ) ;
}
2005-07-29 03:49:35 +04:00
static xmlSAXHandler debugSAXHandlerStruct = {
2005-07-08 21:27:33 +04:00
internalSubsetDebug ,
isStandaloneDebug ,
hasInternalSubsetDebug ,
hasExternalSubsetDebug ,
resolveEntityDebug ,
getEntityDebug ,
entityDeclDebug ,
notationDeclDebug ,
attributeDeclDebug ,
elementDeclDebug ,
unparsedEntityDeclDebug ,
setDocumentLocatorDebug ,
startDocumentDebug ,
endDocumentDebug ,
startElementDebug ,
endElementDebug ,
referenceDebug ,
charactersDebug ,
ignorableWhitespaceDebug ,
processingInstructionDebug ,
commentDebug ,
warningDebug ,
errorDebug ,
fatalErrorDebug ,
getParameterEntityDebug ,
cdataBlockDebug ,
externalSubsetDebug ,
1 ,
NULL ,
NULL ,
NULL ,
NULL
} ;
xmlSAXHandlerPtr debugSAXHandler = & debugSAXHandlerStruct ;
/*
* SAX2 specific callbacks
*/
/**
* startElementNsDebug :
* @ ctxt : An XML parser context
* @ name : The element name
*
* called when an opening tag has been processed .
*/
static void
startElementNsDebug ( void * ctx ATTRIBUTE_UNUSED ,
const xmlChar * localname ,
const xmlChar * prefix ,
const xmlChar * URI ,
int nb_namespaces ,
const xmlChar * * namespaces ,
int nb_attributes ,
int nb_defaulted ,
const xmlChar * * attributes )
{
int i ;
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.startElementNs(%s " , ( char * ) localname ) ;
if ( prefix = = NULL )
fprintf ( stdout , " , NULL " ) ;
else
fprintf ( stdout , " , %s " , ( char * ) prefix ) ;
if ( URI = = NULL )
fprintf ( stdout , " , NULL " ) ;
else
fprintf ( stdout , " , '%s' " , ( char * ) URI ) ;
fprintf ( stdout , " , %d " , nb_namespaces ) ;
2009-08-10 16:43:18 +04:00
2005-07-08 21:27:33 +04:00
if ( namespaces ! = NULL ) {
for ( i = 0 ; i < nb_namespaces * 2 ; i + + ) {
fprintf ( stdout , " , xmlns " ) ;
if ( namespaces [ i ] ! = NULL )
fprintf ( stdout , " :%s " , namespaces [ i ] ) ;
i + + ;
fprintf ( stdout , " ='%s' " , namespaces [ i ] ) ;
}
}
fprintf ( stdout , " , %d, %d " , nb_attributes , nb_defaulted ) ;
if ( attributes ! = NULL ) {
for ( i = 0 ; i < nb_attributes * 5 ; i + = 5 ) {
if ( attributes [ i + 1 ] ! = NULL )
fprintf ( stdout , " , %s:%s=' " , attributes [ i + 1 ] , attributes [ i ] ) ;
else
fprintf ( stdout , " , %s=' " , attributes [ i ] ) ;
fprintf ( stdout , " %.4s...', %d " , attributes [ i + 3 ] ,
( int ) ( attributes [ i + 4 ] - attributes [ i + 3 ] ) ) ;
}
}
fprintf ( stdout , " ) \n " ) ;
}
/**
* endElementDebug :
* @ ctxt : An XML parser context
* @ name : The element name
*
* called when the end of an element has been detected .
*/
static void
endElementNsDebug ( void * ctx ATTRIBUTE_UNUSED ,
const xmlChar * localname ,
const xmlChar * prefix ,
const xmlChar * URI )
{
callbacks + + ;
if ( noout )
return ;
fprintf ( stdout , " SAX.endElementNs(%s " , ( char * ) localname ) ;
if ( prefix = = NULL )
fprintf ( stdout , " , NULL " ) ;
else
fprintf ( stdout , " , %s " , ( char * ) prefix ) ;
if ( URI = = NULL )
fprintf ( stdout , " , NULL) \n " ) ;
else
fprintf ( stdout , " , '%s') \n " , ( char * ) URI ) ;
}
2005-07-29 03:49:35 +04:00
static xmlSAXHandler debugSAX2HandlerStruct = {
2005-07-08 21:27:33 +04:00
internalSubsetDebug ,
isStandaloneDebug ,
hasInternalSubsetDebug ,
hasExternalSubsetDebug ,
resolveEntityDebug ,
getEntityDebug ,
entityDeclDebug ,
notationDeclDebug ,
attributeDeclDebug ,
elementDeclDebug ,
unparsedEntityDeclDebug ,
setDocumentLocatorDebug ,
startDocumentDebug ,
endDocumentDebug ,
NULL ,
NULL ,
referenceDebug ,
charactersDebug ,
ignorableWhitespaceDebug ,
processingInstructionDebug ,
commentDebug ,
warningDebug ,
errorDebug ,
fatalErrorDebug ,
getParameterEntityDebug ,
cdataBlockDebug ,
externalSubsetDebug ,
XML_SAX2_MAGIC ,
NULL ,
startElementNsDebug ,
endElementNsDebug ,
NULL
} ;
2005-07-29 03:49:35 +04:00
static xmlSAXHandlerPtr debugSAX2Handler = & debugSAX2HandlerStruct ;
2005-07-08 21:27:33 +04:00
static void
testSAX ( const char * filename ) {
xmlSAXHandlerPtr handler ;
const char * user_data = " user_data " ; /* mostly for debugging */
callbacks = 0 ;
if ( noout ) {
handler = emptySAXHandler ;
2005-07-11 02:30:30 +04:00
# ifdef LIBXML_SAX1_ENABLED
2024-05-07 17:53:43 +03:00
} else if ( options & XML_PARSE_SAX1 ) {
2005-07-08 21:27:33 +04:00
handler = debugSAXHandler ;
2005-07-11 02:30:30 +04:00
# endif
2005-07-08 21:27:33 +04:00
} else {
handler = debugSAX2Handler ;
}
# ifdef LIBXML_SCHEMAS_ENABLED
if ( wxschemas ! = NULL ) {
int ret ;
xmlSchemaValidCtxtPtr vctxt ;
2022-08-24 05:21:58 +03:00
xmlParserInputBufferPtr buf ;
2023-12-21 01:53:19 +03:00
if ( strcmp ( filename , " - " ) = = 0 )
buf = xmlParserInputBufferCreateFd ( STDIN_FILENO ,
XML_CHAR_ENCODING_NONE ) ;
else
buf = xmlParserInputBufferCreateFilename ( filename ,
XML_CHAR_ENCODING_NONE ) ;
2022-08-24 05:21:58 +03:00
if ( buf = = NULL )
return ;
2005-07-08 21:27:33 +04:00
vctxt = xmlSchemaNewValidCtxt ( wxschemas ) ;
2022-02-01 17:56:21 +03:00
if ( vctxt = = NULL ) {
progresult = XMLLINT_ERR_MEM ;
xmlFreeParserInputBuffer ( buf ) ;
2022-08-24 05:21:58 +03:00
return ;
2022-02-01 17:56:21 +03:00
}
2012-08-14 07:01:07 +04:00
xmlSchemaValidateSetFilename ( vctxt , filename ) ;
2005-07-08 21:27:33 +04:00
2005-07-09 21:32:57 +04:00
ret = xmlSchemaValidateStream ( vctxt , buf , 0 , handler ,
( void * ) user_data ) ;
if ( repeat = = 0 ) {
if ( ret = = 0 ) {
2021-02-03 01:27:52 +03:00
if ( ! quiet ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s validates \n " , filename ) ;
2021-02-03 01:27:52 +03:00
}
2005-07-09 21:32:57 +04:00
} else if ( ret > 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s fails to validate \n " , filename ) ;
2005-07-09 21:32:57 +04:00
progresult = XMLLINT_ERR_VALID ;
} else {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s validation generated an internal error \n " ,
2005-07-09 21:32:57 +04:00
filename ) ;
progresult = XMLLINT_ERR_VALID ;
}
2005-07-08 21:27:33 +04:00
}
xmlSchemaFreeValidCtxt ( vctxt ) ;
} else
# endif
{
2022-08-24 05:21:58 +03:00
xmlParserCtxtPtr ctxt = NULL ;
2005-07-08 21:27:33 +04:00
/*
* Create the parser context amd hook the input
*/
2022-08-24 05:21:58 +03:00
ctxt = xmlNewSAXParserCtxt ( handler , ( void * ) user_data ) ;
2005-07-08 21:27:33 +04:00
if ( ctxt = = NULL ) {
2022-02-01 17:56:21 +03:00
progresult = XMLLINT_ERR_MEM ;
2022-08-24 05:21:58 +03:00
return ;
2005-07-08 21:27:33 +04:00
}
2024-06-11 19:14:43 +03:00
xmlCtxtSetResourceLoader ( ctxt , xmllintResourceLoader , NULL ) ;
2023-08-20 21:48:10 +03:00
if ( maxAmpl > 0 )
xmlCtxtSetMaxAmplification ( ctxt , maxAmpl ) ;
2023-12-21 01:53:19 +03:00
if ( strcmp ( filename , " - " ) = = 0 )
xmlCtxtReadFd ( ctxt , STDIN_FILENO , " - " , NULL , options ) ;
else
xmlCtxtReadFile ( ctxt , filename , NULL , options ) ;
2005-07-08 21:27:33 +04:00
if ( ctxt - > myDoc ! = NULL ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " SAX generated a doc ! \n " ) ;
2005-07-08 21:27:33 +04:00
xmlFreeDoc ( ctxt - > myDoc ) ;
ctxt - > myDoc = NULL ;
}
xmlFreeParserCtxt ( ctxt ) ;
}
}
2000-04-05 22:38:42 +04:00
/************************************************************************
2009-08-10 16:43:18 +04:00
* *
* Stream Test processing *
* *
2003-01-03 19:19:51 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-07-08 21:27:33 +04:00
# ifdef LIBXML_READER_ENABLED
2003-01-03 19:19:51 +03:00
static void processNode ( xmlTextReaderPtr reader ) {
2003-10-20 21:07:41 +04:00
const xmlChar * name , * value ;
2005-01-31 03:27:50 +03:00
int type , empty ;
2005-01-30 21:42:55 +03:00
type = xmlTextReaderNodeType ( reader ) ;
2005-01-31 03:27:50 +03:00
empty = xmlTextReaderIsEmptyElement ( reader ) ;
2005-01-30 21:42:55 +03:00
if ( debug ) {
name = xmlTextReaderConstName ( reader ) ;
if ( name = = NULL )
name = BAD_CAST " -- " ;
value = xmlTextReaderConstValue ( reader ) ;
2009-08-10 16:43:18 +04:00
printf ( " %d %d %s %d %d " ,
2005-01-30 21:42:55 +03:00
xmlTextReaderDepth ( reader ) ,
type ,
name ,
2005-01-31 03:27:50 +03:00
empty ,
2005-01-30 21:42:55 +03:00
xmlTextReaderHasValue ( reader ) ) ;
if ( value = = NULL )
printf ( " \n " ) ;
else {
printf ( " %s \n " , value ) ;
}
2003-01-03 19:19:51 +03:00
}
2003-12-03 01:32:15 +03:00
# ifdef LIBXML_PATTERN_ENABLED
if ( patternc ) {
2005-01-30 21:42:55 +03:00
xmlChar * path = NULL ;
int match = - 1 ;
2009-08-10 16:43:18 +04:00
2005-01-30 21:42:55 +03:00
if ( type = = XML_READER_TYPE_ELEMENT ) {
/* do the check only on element start */
match = xmlPatternMatch ( patternc , xmlTextReaderCurrentNode ( reader ) ) ;
if ( match ) {
path = xmlGetNodePath ( xmlTextReaderCurrentNode ( reader ) ) ;
printf ( " Node %s matches pattern %s \n " , path , pattern ) ;
}
}
if ( patstream ! = NULL ) {
int ret ;
if ( type = = XML_READER_TYPE_ELEMENT ) {
ret = xmlStreamPush ( patstream ,
xmlTextReaderConstLocalName ( reader ) ,
xmlTextReaderConstNamespaceUri ( reader ) ) ;
if ( ret < 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " xmlStreamPush() failure \n " ) ;
2005-01-30 21:42:55 +03:00
xmlFreeStreamCtxt ( patstream ) ;
patstream = NULL ;
} else if ( ret ! = match ) {
if ( path = = NULL ) {
path = xmlGetNodePath (
xmlTextReaderCurrentNode ( reader ) ) ;
}
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2005-01-30 21:42:55 +03:00
" xmlPatternMatch and xmlStreamPush disagree \n " ) ;
2009-08-10 16:43:18 +04:00
if ( path ! = NULL )
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " pattern %s node %s \n " ,
2009-08-10 16:43:18 +04:00
pattern , path ) ;
else
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " pattern %s node %s \n " ,
2009-08-10 16:43:18 +04:00
pattern , xmlTextReaderConstName ( reader ) ) ;
2005-01-30 21:42:55 +03:00
}
2009-08-10 16:43:18 +04:00
}
2005-01-31 03:27:50 +03:00
if ( ( type = = XML_READER_TYPE_END_ELEMENT ) | |
( ( type = = XML_READER_TYPE_ELEMENT ) & & ( empty ) ) ) {
2005-01-30 21:42:55 +03:00
ret = xmlStreamPop ( patstream ) ;
if ( ret < 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " xmlStreamPop() failure \n " ) ;
2005-01-30 21:42:55 +03:00
xmlFreeStreamCtxt ( patstream ) ;
patstream = NULL ;
}
}
2003-12-03 01:32:15 +03:00
}
2005-01-31 01:36:30 +03:00
if ( path ! = NULL )
xmlFree ( path ) ;
2003-12-03 01:32:15 +03:00
}
# endif
2003-01-03 19:19:51 +03:00
}
2024-05-05 16:20:15 +03:00
static void streamFile ( const char * filename ) {
2003-01-03 19:19:51 +03:00
xmlTextReaderPtr reader ;
int ret ;
Various "make distcheck" and portability fixups
Makefile.am:
* Don't use @VAR@, use $(VAR). Autoconf's AC_SUBST provides us the Make
variable, it allows overriding the value at the command line, and
(notably) it avoids a Make parse error in the libxml2_la_LDFLAGS
assignment when @MODULE_PLATFORM_LIBS@ is empty
* Changed how the THREADS_W32 mechanism switches the build between
testThreads.c and testThreadsWin32.c as appropriate; using AM_CONDITIONAL
allows this to work cleanly and plays well with dependencies
* testapi.c should be specified as BUILT_SOURCES
* Create symlinks to the test/ and result/ subdirs so that the runtests
target is usable in out-of-source-tree builds
* Don't do MAKEFLAGS+=--silent as this is not portable to non-GNU Makes
* Fixed incorrect find(1) syntax in the "cleanup" rule, and doing "rm -f"
instead of just "rm" is good form
* (DIST)CLEANFILES needed a bit more coverage to allow "make distcheck" to
pass
configure.in:
* Need AC_PROG_LN_S to create test/ and result/ symlinks in Makefile.am
* AC_LIBTOOL_WIN32_DLL and AM_PROG_LIBTOOL are obsolete; these have been
superceded by LT_INIT
* Don't rebuild docs by default, as this requires GNU Make (as
implemented)
* Check for uint32_t as some platforms don't provide it
* Check for some more functions, and undefine HAVE_MMAP if we don't also
HAVE_MUNMAP (one system I tested on actually needed this)
* Changed THREADS_W32 from a filename insert into an Automake conditional
* The "Copyright" file will not be in the current directory if builddir !=
srcdir
doc/Makefile.am:
* EXTRA_DIST cannot use wildcards when they refer to generated files; this
breaks dependencies. What I did was define EXTRA_DIST_wc, which uses GNU
Make $(wildcard) directives to build up a list of files, and EXTRA_DIST,
as a literal expansion of EXTRA_DIST_wc. I also added a new rule,
"check-extra-dist", to simplify checking that the two variables are
equivalent. (Note that this works only when builddir == srcdir)
(I can implement this differently if desired; this is just one way of
doing it)
* Don't define an "all" target; this steps on Automake's toes
* Fixed up the "libxml2-api.xml ..." rule by using $(wildcard) for
dependencies (as Make doesn't process the wildcards otherwise) and
qualifying appropriate files with $(srcdir)
(Note that $(srcdir) is not needed in the dependencies, thanks to VPATH,
which we can count on as this is GNU-Make-only code anyway)
doc/devhelp/Makefile.am:
* Qualified appropriate files with $(srcdir)
* Added an "uninstall-local" rule so that "make distcheck" passes
doc/examples/Makefile.am:
* Rather than use a wildcard that doesn't work, use a substitution that
most Make programs can handle
doc/examples/index.py:
* Do the same here
include/libxml/nanoftp.h:
* Some platforms (e.g. MSVC 6) already #define INVALID_SOCKET:
user@host:/cygdrive/c/Program Files/Microsoft Visual Studio/VC98/\
Include$ grep -R INVALID_SOCKET .
./WINSOCK.H:#define INVALID_SOCKET (SOCKET)(~0)
./WINSOCK2.H:#define INVALID_SOCKET (SOCKET)(~0)
include/libxml/xmlversion.h.in:
* Support ancient GCCs (I was actually able to build the library with 2.5
but for this bit)
python/Makefile.am:
* Expanded CLEANFILES to allow "make distcheck" to pass
python/tests/Makefile.am:
* Define CLEANFILES instead of a "clean" rule, and added tmp.xml to allow
"make distcheck" to pass
testRelax.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H (as some
systems have the header but not the function)
testSchemas.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H
testapi.c:
* Don't use putenv() if it's not available
threads.c:
* This fixes the following build error on Solaris 8:
libtool: compile: cc -DHAVE_CONFIG_H -I. -I./include -I./include \
-D_REENTRANT -D__EXTENSIONS__ -D_REENTRANT -Dsparc -Xa -mt -v \
-xarch=v9 -xcrossfile -xO5 -c threads.c -KPIC -DPIC -o threads.o
"threads.c", line 442: controlling expressions must have scalar type
"threads.c", line 512: controlling expressions must have scalar type
cc: acomp failed for threads.c
*** Error code 1
trio.c:
* Define isascii() if the system doesn't provide it
trio.h:
* The trio library's HAVE_CONFIG_H header is not the same as LibXML2's
HAVE_CONFIG_H header; this change is needed to avoid a double-inclusion
win32/configure.js:
* Added support for the LZMA compression option
win32/Makefile.{bcb,mingw,msvc}:
* Added appropriate bits to support WITH_LZMA=1
* Install the header files under $(INCPREFIX)\libxml2\libxml instead of
$(INCPREFIX)\libxml, to mirror the install location on Unix+Autotools
xml2-config.in:
* @MODULE_PLATFORM_LIBS@ (usually "-ldl") needs to be in there in order for
`xml2-config --libs` to provide a complete set of dependencies
xmllint.c:
* Use HAVE_MMAP instead of the less-explicit HAVE_SYS_MMAN_H
2012-08-06 07:32:54 +04:00
# ifdef HAVE_MMAP
2003-09-17 23:36:25 +04:00
int fd = - 1 ;
struct stat info ;
const char * base = NULL ;
if ( memory ) {
2009-08-10 16:43:18 +04:00
if ( stat ( filename , & info ) < 0 )
2003-09-17 23:36:25 +04:00
return ;
if ( ( fd = open ( filename , O_RDONLY ) ) < 0 )
return ;
base = mmap ( NULL , info . st_size , PROT_READ , MAP_SHARED , fd , 0 ) ;
2013-07-12 08:08:40 +04:00
if ( base = = ( void * ) MAP_FAILED ) {
close ( fd ) ;
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " mmap failure for file %s \n " , filename ) ;
2013-07-12 08:08:40 +04:00
progresult = XMLLINT_ERR_RDFILE ;
2003-09-17 23:36:25 +04:00
return ;
2013-07-12 08:08:40 +04:00
}
2003-09-17 23:36:25 +04:00
2003-11-03 15:31:38 +03:00
reader = xmlReaderForMemory ( base , info . st_size , filename ,
NULL , options ) ;
2003-09-17 23:36:25 +04:00
} else
# endif
2023-12-21 01:53:19 +03:00
if ( strcmp ( filename , " - " ) = = 0 )
reader = xmlReaderForFd ( STDIN_FILENO , " - " , NULL , options ) ;
else
2003-11-03 15:31:38 +03:00
reader = xmlReaderForFile ( filename , NULL , options ) ;
2005-01-30 21:42:55 +03:00
# ifdef LIBXML_PATTERN_ENABLED
if ( patternc ! = NULL ) {
patstream = xmlPatternGetStreamCtxt ( patternc ) ;
if ( patstream ! = NULL ) {
ret = xmlStreamPush ( patstream , NULL , NULL ) ;
if ( ret < 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " xmlStreamPush() failure \n " ) ;
2005-01-30 21:42:55 +03:00
xmlFreeStreamCtxt ( patstream ) ;
patstream = NULL ;
}
}
}
# endif
2003-11-03 15:31:38 +03:00
2003-01-03 19:19:51 +03:00
if ( reader ! = NULL ) {
2024-06-11 19:14:43 +03:00
xmlTextReaderSetResourceLoader ( reader , xmllintResourceLoader , NULL ) ;
2023-08-20 21:48:10 +03:00
if ( maxAmpl > 0 )
xmlTextReaderSetMaxAmplification ( reader , maxAmpl ) ;
2024-06-11 19:14:43 +03:00
2003-05-09 23:38:15 +04:00
# ifdef LIBXML_SCHEMAS_ENABLED
2003-04-16 19:58:05 +04:00
if ( relaxng ! = NULL ) {
2003-09-17 03:17:26 +04:00
if ( ( timing ) & & ( ! repeat ) ) {
2003-04-16 19:58:05 +04:00
startTimer ( ) ;
}
ret = xmlTextReaderRelaxNGValidate ( reader , relaxng ) ;
if ( ret < 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2003-04-16 19:58:05 +04:00
" Relax-NG schema %s failed to compile \n " , relaxng ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_SCHEMACOMP ;
2003-04-16 19:58:05 +04:00
relaxng = NULL ;
}
2003-09-17 03:17:26 +04:00
if ( ( timing ) & & ( ! repeat ) ) {
2003-04-16 19:58:05 +04:00
endTimer ( " Compiling the schemas " ) ;
}
}
2005-07-10 23:03:16 +04:00
if ( schema ! = NULL ) {
if ( ( timing ) & & ( ! repeat ) ) {
startTimer ( ) ;
}
ret = xmlTextReaderSchemaValidate ( reader , schema ) ;
if ( ret < 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2005-07-10 23:03:16 +04:00
" XSD schema %s failed to compile \n " , schema ) ;
progresult = XMLLINT_ERR_SCHEMACOMP ;
schema = NULL ;
}
if ( ( timing ) & & ( ! repeat ) ) {
endTimer ( " Compiling the schemas " ) ;
}
}
2003-05-09 23:38:15 +04:00
# endif
2003-01-03 19:19:51 +03:00
/*
* Process all nodes in sequence
*/
2003-09-17 03:17:26 +04:00
if ( ( timing ) & & ( ! repeat ) ) {
2003-04-16 19:58:05 +04:00
startTimer ( ) ;
}
2003-01-03 19:19:51 +03:00
ret = xmlTextReaderRead ( reader ) ;
while ( ret = = 1 ) {
2003-12-03 01:32:15 +03:00
if ( ( debug )
# ifdef LIBXML_PATTERN_ENABLED
| | ( patternc )
# endif
)
2003-01-03 19:19:51 +03:00
processNode ( reader ) ;
ret = xmlTextReaderRead ( reader ) ;
}
2003-09-17 03:17:26 +04:00
if ( ( timing ) & & ( ! repeat ) ) {
2003-05-09 23:38:15 +04:00
# ifdef LIBXML_SCHEMAS_ENABLED
2004-02-25 14:52:31 +03:00
if ( relaxng ! = NULL )
2004-02-19 15:58:36 +03:00
endTimer ( " Parsing and validating " ) ;
else
2004-02-25 14:52:31 +03:00
# endif
2003-09-28 22:58:27 +04:00
# ifdef LIBXML_VALID_ENABLED
2024-05-07 17:53:43 +03:00
if ( options & XML_PARSE_DTDVALID )
2003-04-16 19:58:05 +04:00
endTimer ( " Parsing and validating " ) ;
else
2003-09-28 22:58:27 +04:00
# endif
2004-02-25 14:52:31 +03:00
endTimer ( " Parsing " ) ;
2003-04-16 19:58:05 +04:00
}
2003-01-03 19:19:51 +03:00
2003-09-28 22:58:27 +04:00
# ifdef LIBXML_VALID_ENABLED
2024-05-07 17:53:43 +03:00
if ( options & XML_PARSE_DTDVALID ) {
2003-04-11 23:38:54 +04:00
if ( xmlTextReaderIsValid ( reader ) ! = 1 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2003-04-11 23:38:54 +04:00
" Document %s does not validate \n " , filename ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_VALID ;
2003-04-11 23:38:54 +04:00
}
}
2003-09-28 22:58:27 +04:00
# endif /* LIBXML_VALID_ENABLED */
2003-05-09 23:38:15 +04:00
# ifdef LIBXML_SCHEMAS_ENABLED
2005-07-10 23:03:16 +04:00
if ( ( relaxng ! = NULL ) | | ( schema ! = NULL ) ) {
2003-04-16 03:32:22 +04:00
if ( xmlTextReaderIsValid ( reader ) ! = 1 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s fails to validate \n " , filename ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_VALID ;
2003-04-16 03:32:22 +04:00
} else {
2021-02-03 01:27:52 +03:00
if ( ! quiet ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s validates \n " , filename ) ;
2021-02-03 01:27:52 +03:00
}
2003-04-16 03:32:22 +04:00
}
}
2003-05-09 23:38:15 +04:00
# endif
2003-01-03 19:19:51 +03:00
/*
* Done , cleanup and status
*/
xmlFreeTextReader ( reader ) ;
if ( ret ! = 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s : failed to parse \n " , filename ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_UNCLASS ;
2003-01-03 19:19:51 +03:00
}
} else {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Unable to open %s \n " , filename ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_UNCLASS ;
2003-01-03 19:19:51 +03:00
}
2005-01-30 21:42:55 +03:00
# ifdef LIBXML_PATTERN_ENABLED
if ( patstream ! = NULL ) {
xmlFreeStreamCtxt ( patstream ) ;
patstream = NULL ;
}
# endif
Various "make distcheck" and portability fixups
Makefile.am:
* Don't use @VAR@, use $(VAR). Autoconf's AC_SUBST provides us the Make
variable, it allows overriding the value at the command line, and
(notably) it avoids a Make parse error in the libxml2_la_LDFLAGS
assignment when @MODULE_PLATFORM_LIBS@ is empty
* Changed how the THREADS_W32 mechanism switches the build between
testThreads.c and testThreadsWin32.c as appropriate; using AM_CONDITIONAL
allows this to work cleanly and plays well with dependencies
* testapi.c should be specified as BUILT_SOURCES
* Create symlinks to the test/ and result/ subdirs so that the runtests
target is usable in out-of-source-tree builds
* Don't do MAKEFLAGS+=--silent as this is not portable to non-GNU Makes
* Fixed incorrect find(1) syntax in the "cleanup" rule, and doing "rm -f"
instead of just "rm" is good form
* (DIST)CLEANFILES needed a bit more coverage to allow "make distcheck" to
pass
configure.in:
* Need AC_PROG_LN_S to create test/ and result/ symlinks in Makefile.am
* AC_LIBTOOL_WIN32_DLL and AM_PROG_LIBTOOL are obsolete; these have been
superceded by LT_INIT
* Don't rebuild docs by default, as this requires GNU Make (as
implemented)
* Check for uint32_t as some platforms don't provide it
* Check for some more functions, and undefine HAVE_MMAP if we don't also
HAVE_MUNMAP (one system I tested on actually needed this)
* Changed THREADS_W32 from a filename insert into an Automake conditional
* The "Copyright" file will not be in the current directory if builddir !=
srcdir
doc/Makefile.am:
* EXTRA_DIST cannot use wildcards when they refer to generated files; this
breaks dependencies. What I did was define EXTRA_DIST_wc, which uses GNU
Make $(wildcard) directives to build up a list of files, and EXTRA_DIST,
as a literal expansion of EXTRA_DIST_wc. I also added a new rule,
"check-extra-dist", to simplify checking that the two variables are
equivalent. (Note that this works only when builddir == srcdir)
(I can implement this differently if desired; this is just one way of
doing it)
* Don't define an "all" target; this steps on Automake's toes
* Fixed up the "libxml2-api.xml ..." rule by using $(wildcard) for
dependencies (as Make doesn't process the wildcards otherwise) and
qualifying appropriate files with $(srcdir)
(Note that $(srcdir) is not needed in the dependencies, thanks to VPATH,
which we can count on as this is GNU-Make-only code anyway)
doc/devhelp/Makefile.am:
* Qualified appropriate files with $(srcdir)
* Added an "uninstall-local" rule so that "make distcheck" passes
doc/examples/Makefile.am:
* Rather than use a wildcard that doesn't work, use a substitution that
most Make programs can handle
doc/examples/index.py:
* Do the same here
include/libxml/nanoftp.h:
* Some platforms (e.g. MSVC 6) already #define INVALID_SOCKET:
user@host:/cygdrive/c/Program Files/Microsoft Visual Studio/VC98/\
Include$ grep -R INVALID_SOCKET .
./WINSOCK.H:#define INVALID_SOCKET (SOCKET)(~0)
./WINSOCK2.H:#define INVALID_SOCKET (SOCKET)(~0)
include/libxml/xmlversion.h.in:
* Support ancient GCCs (I was actually able to build the library with 2.5
but for this bit)
python/Makefile.am:
* Expanded CLEANFILES to allow "make distcheck" to pass
python/tests/Makefile.am:
* Define CLEANFILES instead of a "clean" rule, and added tmp.xml to allow
"make distcheck" to pass
testRelax.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H (as some
systems have the header but not the function)
testSchemas.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H
testapi.c:
* Don't use putenv() if it's not available
threads.c:
* This fixes the following build error on Solaris 8:
libtool: compile: cc -DHAVE_CONFIG_H -I. -I./include -I./include \
-D_REENTRANT -D__EXTENSIONS__ -D_REENTRANT -Dsparc -Xa -mt -v \
-xarch=v9 -xcrossfile -xO5 -c threads.c -KPIC -DPIC -o threads.o
"threads.c", line 442: controlling expressions must have scalar type
"threads.c", line 512: controlling expressions must have scalar type
cc: acomp failed for threads.c
*** Error code 1
trio.c:
* Define isascii() if the system doesn't provide it
trio.h:
* The trio library's HAVE_CONFIG_H header is not the same as LibXML2's
HAVE_CONFIG_H header; this change is needed to avoid a double-inclusion
win32/configure.js:
* Added support for the LZMA compression option
win32/Makefile.{bcb,mingw,msvc}:
* Added appropriate bits to support WITH_LZMA=1
* Install the header files under $(INCPREFIX)\libxml2\libxml instead of
$(INCPREFIX)\libxml, to mirror the install location on Unix+Autotools
xml2-config.in:
* @MODULE_PLATFORM_LIBS@ (usually "-ldl") needs to be in there in order for
`xml2-config --libs` to provide a complete set of dependencies
xmllint.c:
* Use HAVE_MMAP instead of the less-explicit HAVE_SYS_MMAN_H
2012-08-06 07:32:54 +04:00
# ifdef HAVE_MMAP
2003-09-17 23:36:25 +04:00
if ( memory ) {
munmap ( ( char * ) base , info . st_size ) ;
close ( fd ) ;
}
# endif
2003-01-03 19:19:51 +03:00
}
2003-11-03 15:31:38 +03:00
static void walkDoc ( xmlDocPtr doc ) {
xmlTextReaderPtr reader ;
int ret ;
2005-02-04 01:24:10 +03:00
# ifdef LIBXML_PATTERN_ENABLED
if ( pattern ! = NULL ) {
2024-05-06 03:34:01 +03:00
xmlNodePtr root ;
const xmlChar * namespaces [ 22 ] ;
int i ;
xmlNsPtr ns ;
root = xmlDocGetRootElement ( doc ) ;
if ( root = = NULL ) {
fprintf ( ERR_STREAM ,
" Document does not have a root element " ) ;
progresult = XMLLINT_ERR_UNCLASS ;
return ;
}
for ( ns = root - > nsDef , i = 0 ; ns ! = NULL & & i < 20 ; ns = ns - > next ) {
namespaces [ i + + ] = ns - > href ;
namespaces [ i + + ] = ns - > prefix ;
}
namespaces [ i + + ] = NULL ;
namespaces [ i ] = NULL ;
ret = xmlPatternCompileSafe ( ( const xmlChar * ) pattern , doc - > dict ,
0 , & namespaces [ 0 ] , & patternc ) ;
2005-02-04 01:24:10 +03:00
if ( patternc = = NULL ) {
2024-05-06 03:34:01 +03:00
if ( ret < 0 ) {
progresult = XMLLINT_ERR_MEM ;
} else {
fprintf ( ERR_STREAM ,
" Pattern %s failed to compile \n " , pattern ) ;
progresult = XMLLINT_ERR_SCHEMAPAT ;
2005-02-06 02:20:22 +03:00
}
2024-05-06 03:34:01 +03:00
goto error ;
2005-02-06 02:20:22 +03:00
}
2024-05-06 03:34:01 +03:00
patstream = xmlPatternGetStreamCtxt ( patternc ) ;
if ( patstream = = NULL ) {
progresult = XMLLINT_ERR_MEM ;
goto error ;
}
ret = xmlStreamPush ( patstream , NULL , NULL ) ;
if ( ret < 0 ) {
fprintf ( ERR_STREAM , " xmlStreamPush() failure \n " ) ;
progresult = XMLLINT_ERR_MEM ;
goto error ;
}
2005-02-06 02:20:22 +03:00
}
2005-02-04 01:24:10 +03:00
# endif /* LIBXML_PATTERN_ENABLED */
2003-11-03 15:31:38 +03:00
reader = xmlReaderWalker ( doc ) ;
if ( reader ! = NULL ) {
if ( ( timing ) & & ( ! repeat ) ) {
startTimer ( ) ;
}
ret = xmlTextReaderRead ( reader ) ;
while ( ret = = 1 ) {
2003-12-03 01:32:15 +03:00
if ( ( debug )
# ifdef LIBXML_PATTERN_ENABLED
| | ( patternc )
# endif
)
2003-11-03 15:31:38 +03:00
processNode ( reader ) ;
ret = xmlTextReaderRead ( reader ) ;
}
if ( ( timing ) & & ( ! repeat ) ) {
endTimer ( " walking through the doc " ) ;
}
xmlFreeTextReader ( reader ) ;
if ( ret ! = 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " failed to walk through the doc \n " ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_UNCLASS ;
2003-11-03 15:31:38 +03:00
}
} else {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Failed to crate a reader from the document \n " ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_UNCLASS ;
2003-11-03 15:31:38 +03:00
}
2024-05-06 03:34:01 +03:00
2005-02-06 02:20:22 +03:00
# ifdef LIBXML_PATTERN_ENABLED
2024-05-06 03:34:01 +03:00
error :
if ( patternc ! = NULL ) {
xmlFreePattern ( patternc ) ;
patternc = NULL ;
}
2005-02-06 02:20:22 +03:00
if ( patstream ! = NULL ) {
xmlFreeStreamCtxt ( patstream ) ;
patstream = NULL ;
}
# endif
2003-11-03 15:31:38 +03:00
}
2003-09-30 04:43:48 +04:00
# endif /* LIBXML_READER_ENABLED */
2003-01-03 19:19:51 +03:00
2009-10-07 12:25:06 +04:00
# ifdef LIBXML_XPATH_ENABLED
/************************************************************************
* *
* XPath Query *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void doXPathDump ( xmlXPathObjectPtr cur ) {
switch ( cur - > type ) {
case XPATH_NODESET : {
# ifdef LIBXML_OUTPUT_ENABLED
2018-09-23 02:09:56 +03:00
xmlOutputBufferPtr buf ;
2023-12-14 15:35:13 +03:00
xmlNodePtr node ;
int i ;
2009-10-07 12:25:06 +04:00
2012-03-27 10:41:37 +04:00
if ( ( cur - > nodesetval = = NULL ) | | ( cur - > nodesetval - > nodeNr < = 0 ) ) {
2024-02-12 18:45:16 +03:00
progresult = XMLLINT_ERR_XPATH_EMPTY ;
2022-10-19 03:47:30 +03:00
if ( ! quiet ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " XPath set is empty \n " ) ;
2022-10-19 03:47:30 +03:00
}
2009-10-07 12:25:06 +04:00
break ;
}
2018-09-23 02:09:56 +03:00
buf = xmlOutputBufferCreateFile ( stdout , NULL ) ;
if ( buf = = NULL ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Out of memory for XPath \n " ) ;
2009-10-07 12:25:06 +04:00
progresult = XMLLINT_ERR_MEM ;
return ;
}
for ( i = 0 ; i < cur - > nodesetval - > nodeNr ; i + + ) {
node = cur - > nodesetval - > nodeTab [ i ] ;
2019-03-12 16:45:04 +03:00
xmlNodeDumpOutput ( buf , NULL , node , 0 , 0 , NULL ) ;
2018-09-23 02:09:56 +03:00
xmlOutputBufferWrite ( buf , 1 , " \n " ) ;
2009-10-07 12:25:06 +04:00
}
2018-09-23 02:09:56 +03:00
xmlOutputBufferClose ( buf ) ;
2009-10-07 12:25:06 +04:00
# else
printf ( " xpath returned %d nodes \n " , cur - > nodesetval - > nodeNr ) ;
# endif
break ;
}
case XPATH_BOOLEAN :
2018-09-23 02:09:56 +03:00
if ( cur - > boolval ) printf ( " true \n " ) ;
else printf ( " false \n " ) ;
2009-10-07 12:25:06 +04:00
break ;
case XPATH_NUMBER :
switch ( xmlXPathIsInf ( cur - > floatval ) ) {
case 1 :
2018-09-23 02:09:56 +03:00
printf ( " Infinity \n " ) ;
2009-10-07 12:25:06 +04:00
break ;
case - 1 :
2018-09-23 02:09:56 +03:00
printf ( " -Infinity \n " ) ;
2009-10-07 12:25:06 +04:00
break ;
default :
if ( xmlXPathIsNaN ( cur - > floatval ) ) {
2018-09-23 02:09:56 +03:00
printf ( " NaN \n " ) ;
2009-10-07 12:25:06 +04:00
} else {
2018-09-23 02:09:56 +03:00
printf ( " %0g \n " , cur - > floatval ) ;
2009-10-07 12:25:06 +04:00
}
}
break ;
case XPATH_STRING :
2018-09-23 02:09:56 +03:00
printf ( " %s \n " , ( const char * ) cur - > stringval ) ;
2009-10-07 12:25:06 +04:00
break ;
case XPATH_UNDEFINED :
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " XPath Object is uninitialized \n " ) ;
2009-10-07 12:25:06 +04:00
progresult = XMLLINT_ERR_XPATH ;
break ;
default :
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " XPath object of unexpected type \n " ) ;
2009-10-07 12:25:06 +04:00
progresult = XMLLINT_ERR_XPATH ;
break ;
}
}
static void doXPathQuery ( xmlDocPtr doc , const char * query ) {
xmlXPathContextPtr ctxt ;
xmlXPathObjectPtr res ;
ctxt = xmlXPathNewContext ( doc ) ;
if ( ctxt = = NULL ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Out of memory for XPath \n " ) ;
2009-10-07 12:25:06 +04:00
progresult = XMLLINT_ERR_MEM ;
return ;
}
2012-05-25 12:44:20 +04:00
ctxt - > node = ( xmlNodePtr ) doc ;
2009-10-07 12:25:06 +04:00
res = xmlXPathEval ( BAD_CAST query , ctxt ) ;
xmlXPathFreeContext ( ctxt ) ;
if ( res = = NULL ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " XPath evaluation failure \n " ) ;
2009-10-07 12:25:06 +04:00
progresult = XMLLINT_ERR_XPATH ;
return ;
}
doXPathDump ( res ) ;
xmlXPathFreeObject ( res ) ;
}
# endif /* LIBXML_XPATH_ENABLED */
2003-01-03 19:19:51 +03:00
/************************************************************************
2009-08-10 16:43:18 +04:00
* *
* Tree Test processing *
* *
2000-04-05 22:38:42 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2024-05-07 16:23:03 +03:00
static xmlDocPtr
parseFile ( const char * filename , xmlParserCtxtPtr rectxt ) {
xmlParserCtxtPtr ctxt ;
2003-09-29 22:02:38 +04:00
xmlDocPtr doc = NULL ;
2000-04-05 22:38:42 +04:00
2024-05-07 16:23:03 +03:00
if ( ( generate ) & & ( filename = = NULL ) ) {
xmlNodePtr n ;
2009-08-10 16:43:18 +04:00
2024-05-07 16:23:03 +03:00
doc = xmlNewDoc ( BAD_CAST " 1.0 " ) ;
if ( doc = = NULL ) {
progresult = XMLLINT_ERR_MEM ;
return ( NULL ) ;
}
n = xmlNewDocNode ( doc , NULL , BAD_CAST " info " , NULL ) ;
if ( n = = NULL ) {
xmlFreeDoc ( doc ) ;
progresult = XMLLINT_ERR_MEM ;
return ( NULL ) ;
}
if ( xmlNodeSetContent ( n , BAD_CAST " abc " ) < 0 ) {
xmlFreeNode ( n ) ;
xmlFreeDoc ( doc ) ;
progresult = XMLLINT_ERR_MEM ;
return ( NULL ) ;
}
xmlDocSetRootElement ( doc , n ) ;
2001-02-25 19:11:03 +03:00
2024-05-07 16:23:03 +03:00
return ( doc ) ;
2001-04-11 11:50:02 +04:00
}
2024-05-07 16:23:03 +03:00
2000-04-05 22:38:42 +04:00
# ifdef LIBXML_HTML_ENABLED
2003-09-30 16:36:01 +04:00
# ifdef LIBXML_PUSH_ENABLED
2024-05-07 16:23:03 +03:00
if ( ( html ) & & ( push ) ) {
2003-07-31 18:47:38 +04:00
FILE * f ;
2023-08-29 22:16:34 +03:00
int res ;
char chars [ 4096 ] ;
2003-07-31 18:47:38 +04:00
2020-07-15 15:20:42 +03:00
if ( ( filename [ 0 ] = = ' - ' ) & & ( filename [ 1 ] = = 0 ) ) {
f = stdin ;
} else {
f = fopen ( filename , " rb " ) ;
2023-08-29 22:16:34 +03:00
if ( f = = NULL ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Can't open %s \n " , filename ) ;
2024-05-07 16:23:03 +03:00
progresult = XMLLINT_ERR_RDFILE ;
return ( NULL ) ;
2023-08-29 22:16:34 +03:00
}
2020-07-15 15:20:42 +03:00
}
2003-07-31 18:47:38 +04:00
2023-08-29 22:16:34 +03:00
res = fread ( chars , 1 , 4 , f ) ;
ctxt = htmlCreatePushParserCtxt ( NULL , NULL ,
chars , res , filename , XML_CHAR_ENCODING_NONE ) ;
if ( ctxt = = NULL ) {
progresult = XMLLINT_ERR_MEM ;
2022-02-01 17:56:21 +03:00
if ( f ! = stdin )
fclose ( f ) ;
2024-05-07 16:23:03 +03:00
return ( NULL ) ;
2003-07-31 18:47:38 +04:00
}
2023-08-29 22:16:34 +03:00
htmlCtxtUseOptions ( ctxt , options ) ;
while ( ( res = fread ( chars , 1 , pushsize , f ) ) > 0 ) {
htmlParseChunk ( ctxt , chars , res , 0 ) ;
}
htmlParseChunk ( ctxt , chars , 0 , 1 ) ;
doc = ctxt - > myDoc ;
htmlFreeParserCtxt ( ctxt ) ;
if ( f ! = stdin )
fclose ( f ) ;
2024-05-07 16:23:03 +03:00
return ( doc ) ;
2003-07-31 18:47:38 +04:00
}
2003-09-30 16:36:01 +04:00
# endif /* LIBXML_PUSH_ENABLED */
2024-05-07 16:23:03 +03:00
Various "make distcheck" and portability fixups
Makefile.am:
* Don't use @VAR@, use $(VAR). Autoconf's AC_SUBST provides us the Make
variable, it allows overriding the value at the command line, and
(notably) it avoids a Make parse error in the libxml2_la_LDFLAGS
assignment when @MODULE_PLATFORM_LIBS@ is empty
* Changed how the THREADS_W32 mechanism switches the build between
testThreads.c and testThreadsWin32.c as appropriate; using AM_CONDITIONAL
allows this to work cleanly and plays well with dependencies
* testapi.c should be specified as BUILT_SOURCES
* Create symlinks to the test/ and result/ subdirs so that the runtests
target is usable in out-of-source-tree builds
* Don't do MAKEFLAGS+=--silent as this is not portable to non-GNU Makes
* Fixed incorrect find(1) syntax in the "cleanup" rule, and doing "rm -f"
instead of just "rm" is good form
* (DIST)CLEANFILES needed a bit more coverage to allow "make distcheck" to
pass
configure.in:
* Need AC_PROG_LN_S to create test/ and result/ symlinks in Makefile.am
* AC_LIBTOOL_WIN32_DLL and AM_PROG_LIBTOOL are obsolete; these have been
superceded by LT_INIT
* Don't rebuild docs by default, as this requires GNU Make (as
implemented)
* Check for uint32_t as some platforms don't provide it
* Check for some more functions, and undefine HAVE_MMAP if we don't also
HAVE_MUNMAP (one system I tested on actually needed this)
* Changed THREADS_W32 from a filename insert into an Automake conditional
* The "Copyright" file will not be in the current directory if builddir !=
srcdir
doc/Makefile.am:
* EXTRA_DIST cannot use wildcards when they refer to generated files; this
breaks dependencies. What I did was define EXTRA_DIST_wc, which uses GNU
Make $(wildcard) directives to build up a list of files, and EXTRA_DIST,
as a literal expansion of EXTRA_DIST_wc. I also added a new rule,
"check-extra-dist", to simplify checking that the two variables are
equivalent. (Note that this works only when builddir == srcdir)
(I can implement this differently if desired; this is just one way of
doing it)
* Don't define an "all" target; this steps on Automake's toes
* Fixed up the "libxml2-api.xml ..." rule by using $(wildcard) for
dependencies (as Make doesn't process the wildcards otherwise) and
qualifying appropriate files with $(srcdir)
(Note that $(srcdir) is not needed in the dependencies, thanks to VPATH,
which we can count on as this is GNU-Make-only code anyway)
doc/devhelp/Makefile.am:
* Qualified appropriate files with $(srcdir)
* Added an "uninstall-local" rule so that "make distcheck" passes
doc/examples/Makefile.am:
* Rather than use a wildcard that doesn't work, use a substitution that
most Make programs can handle
doc/examples/index.py:
* Do the same here
include/libxml/nanoftp.h:
* Some platforms (e.g. MSVC 6) already #define INVALID_SOCKET:
user@host:/cygdrive/c/Program Files/Microsoft Visual Studio/VC98/\
Include$ grep -R INVALID_SOCKET .
./WINSOCK.H:#define INVALID_SOCKET (SOCKET)(~0)
./WINSOCK2.H:#define INVALID_SOCKET (SOCKET)(~0)
include/libxml/xmlversion.h.in:
* Support ancient GCCs (I was actually able to build the library with 2.5
but for this bit)
python/Makefile.am:
* Expanded CLEANFILES to allow "make distcheck" to pass
python/tests/Makefile.am:
* Define CLEANFILES instead of a "clean" rule, and added tmp.xml to allow
"make distcheck" to pass
testRelax.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H (as some
systems have the header but not the function)
testSchemas.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H
testapi.c:
* Don't use putenv() if it's not available
threads.c:
* This fixes the following build error on Solaris 8:
libtool: compile: cc -DHAVE_CONFIG_H -I. -I./include -I./include \
-D_REENTRANT -D__EXTENSIONS__ -D_REENTRANT -Dsparc -Xa -mt -v \
-xarch=v9 -xcrossfile -xO5 -c threads.c -KPIC -DPIC -o threads.o
"threads.c", line 442: controlling expressions must have scalar type
"threads.c", line 512: controlling expressions must have scalar type
cc: acomp failed for threads.c
*** Error code 1
trio.c:
* Define isascii() if the system doesn't provide it
trio.h:
* The trio library's HAVE_CONFIG_H header is not the same as LibXML2's
HAVE_CONFIG_H header; this change is needed to avoid a double-inclusion
win32/configure.js:
* Added support for the LZMA compression option
win32/Makefile.{bcb,mingw,msvc}:
* Added appropriate bits to support WITH_LZMA=1
* Install the header files under $(INCPREFIX)\libxml2\libxml instead of
$(INCPREFIX)\libxml, to mirror the install location on Unix+Autotools
xml2-config.in:
* @MODULE_PLATFORM_LIBS@ (usually "-ldl") needs to be in there in order for
`xml2-config --libs` to provide a complete set of dependencies
xmllint.c:
* Use HAVE_MMAP instead of the less-explicit HAVE_SYS_MMAN_H
2012-08-06 07:32:54 +04:00
# ifdef HAVE_MMAP
2024-05-07 16:23:03 +03:00
if ( ( html ) & & ( memory ) ) {
2006-10-14 02:33:03 +04:00
int fd ;
struct stat info ;
const char * base ;
2009-08-10 16:43:18 +04:00
if ( stat ( filename , & info ) < 0 )
2024-05-07 16:23:03 +03:00
return ( NULL ) ;
2006-10-14 02:33:03 +04:00
if ( ( fd = open ( filename , O_RDONLY ) ) < 0 )
2024-05-07 16:23:03 +03:00
return ( NULL ) ;
2006-10-14 02:33:03 +04:00
base = mmap ( NULL , info . st_size , PROT_READ , MAP_SHARED , fd , 0 ) ;
2013-07-12 08:08:40 +04:00
if ( base = = ( void * ) MAP_FAILED ) {
close ( fd ) ;
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " mmap failure for file %s \n " , filename ) ;
2013-07-12 08:08:40 +04:00
progresult = XMLLINT_ERR_RDFILE ;
2024-05-07 16:23:03 +03:00
return ( NULL ) ;
2013-07-12 08:08:40 +04:00
}
2006-10-14 02:33:03 +04:00
doc = htmlReadMemory ( ( char * ) base , info . st_size , filename ,
NULL , options ) ;
2009-08-10 16:43:18 +04:00
2006-10-14 02:33:03 +04:00
munmap ( ( char * ) base , info . st_size ) ;
close ( fd ) ;
2024-05-07 16:23:03 +03:00
return ( doc ) ;
2006-10-14 02:33:03 +04:00
}
# endif
2024-05-07 16:23:03 +03:00
if ( html ) {
2024-06-11 19:14:43 +03:00
ctxt = htmlNewParserCtxt ( ) ;
xmlCtxtSetResourceLoader ( ctxt , xmllintResourceLoader , NULL ) ;
2023-12-21 01:53:19 +03:00
if ( strcmp ( filename , " - " ) = = 0 )
2024-06-11 19:14:43 +03:00
doc = htmlCtxtReadFd ( ctxt , STDIN_FILENO , " - " , NULL , options ) ;
2023-12-21 01:53:19 +03:00
else
2024-06-11 19:14:43 +03:00
doc = htmlCtxtReadFile ( ctxt , filename , NULL , options ) ;
htmlFreeParserCtxt ( ctxt ) ;
2024-05-07 16:23:03 +03:00
return ( doc ) ;
2001-04-11 11:50:02 +04:00
}
2000-04-05 22:38:42 +04:00
# endif /* LIBXML_HTML_ENABLED */
2024-05-07 16:23:03 +03:00
2003-09-30 16:36:01 +04:00
# ifdef LIBXML_PUSH_ENABLED
2024-05-07 16:23:03 +03:00
if ( push ) {
FILE * f ;
int res ;
char chars [ 4096 ] ;
2023-08-29 22:16:34 +03:00
2024-05-07 16:23:03 +03:00
if ( ( filename [ 0 ] = = ' - ' ) & & ( filename [ 1 ] = = 0 ) ) {
f = stdin ;
} else {
f = fopen ( filename , " rb " ) ;
if ( f = = NULL ) {
fprintf ( ERR_STREAM , " Can't open %s \n " , filename ) ;
progresult = XMLLINT_ERR_RDFILE ;
return ( NULL ) ;
2023-08-29 22:16:34 +03:00
}
2024-05-07 16:23:03 +03:00
}
res = fread ( chars , 1 , 4 , f ) ;
ctxt = xmlCreatePushParserCtxt ( NULL , NULL ,
chars , res , filename ) ;
if ( ctxt = = NULL ) {
progresult = XMLLINT_ERR_MEM ;
2023-08-29 22:16:34 +03:00
if ( f ! = stdin )
fclose ( f ) ;
2024-05-07 16:23:03 +03:00
return ( NULL ) ;
}
2024-06-11 19:14:43 +03:00
xmlCtxtSetResourceLoader ( ctxt , xmllintResourceLoader , NULL ) ;
xmlCtxtUseOptions ( ctxt , options ) ;
2024-05-07 16:23:03 +03:00
if ( maxAmpl > 0 )
xmlCtxtSetMaxAmplification ( ctxt , maxAmpl ) ;
2003-09-24 01:50:54 +04:00
2024-05-07 16:23:03 +03:00
if ( htmlout ) {
2022-02-01 17:56:21 +03:00
ctxt - > sax - > error = xmlHTMLError ;
ctxt - > sax - > warning = xmlHTMLWarning ;
ctxt - > vctxt . error = xmlHTMLValidityError ;
ctxt - > vctxt . warning = xmlHTMLValidityWarning ;
2024-05-07 16:23:03 +03:00
}
2003-09-24 01:50:54 +04:00
2024-05-07 16:23:03 +03:00
while ( ( res = fread ( chars , 1 , pushsize , f ) ) > 0 ) {
xmlParseChunk ( ctxt , chars , res , 0 ) ;
}
xmlParseChunk ( ctxt , chars , 0 , 1 ) ;
2022-02-01 17:56:21 +03:00
2024-05-07 16:23:03 +03:00
doc = ctxt - > myDoc ;
if ( f ! = stdin )
fclose ( f ) ;
} else
# endif /* LIBXML_PUSH_ENABLED */
{
if ( rectxt = = NULL ) {
ctxt = xmlNewParserCtxt ( ) ;
if ( ctxt = = NULL ) {
progresult = XMLLINT_ERR_MEM ;
return ( NULL ) ;
}
} else {
ctxt = rectxt ;
}
2000-07-22 00:32:03 +04:00
2024-06-11 19:14:43 +03:00
xmlCtxtSetResourceLoader ( ctxt , xmllintResourceLoader , NULL ) ;
2024-05-07 16:23:03 +03:00
if ( maxAmpl > 0 )
xmlCtxtSetMaxAmplification ( ctxt , maxAmpl ) ;
2023-08-20 21:48:10 +03:00
2024-05-07 16:23:03 +03:00
if ( htmlout ) {
ctxt - > sax - > error = xmlHTMLError ;
ctxt - > sax - > warning = xmlHTMLWarning ;
ctxt - > vctxt . error = xmlHTMLValidityError ;
ctxt - > vctxt . warning = xmlHTMLValidityWarning ;
}
if ( testIO ) {
FILE * f ;
if ( ( filename [ 0 ] = = ' - ' ) & & ( filename [ 1 ] = = 0 ) ) {
f = stdin ;
2023-08-20 21:48:10 +03:00
} else {
2024-05-07 16:23:03 +03:00
f = fopen ( filename , " rb " ) ;
if ( f = = NULL ) {
fprintf ( ERR_STREAM , " Can't open %s \n " , filename ) ;
progresult = XMLLINT_ERR_RDFILE ;
goto error ;
}
2023-08-20 21:48:10 +03:00
}
2009-08-10 16:43:18 +04:00
2024-05-07 16:23:03 +03:00
doc = xmlCtxtReadIO ( ctxt , myRead , myClose , f , filename , NULL ,
options ) ;
# ifdef HAVE_MMAP
} else if ( memory ) {
int fd ;
struct stat info ;
const char * base ;
if ( stat ( filename , & info ) < 0 )
goto error ;
if ( ( fd = open ( filename , O_RDONLY ) ) < 0 )
goto error ;
base = mmap ( NULL , info . st_size , PROT_READ , MAP_SHARED , fd , 0 ) ;
if ( base = = ( void * ) MAP_FAILED ) {
close ( fd ) ;
fprintf ( ERR_STREAM , " mmap failure for file %s \n " , filename ) ;
progresult = XMLLINT_ERR_RDFILE ;
goto error ;
2022-02-01 17:56:21 +03:00
}
2003-09-24 01:50:54 +04:00
2024-05-07 16:23:03 +03:00
doc = xmlCtxtReadMemory ( ctxt , base , info . st_size , filename , NULL ,
options ) ;
2023-12-21 01:53:19 +03:00
2024-05-07 16:23:03 +03:00
munmap ( ( char * ) base , info . st_size ) ;
close ( fd ) ;
# endif
} else {
2023-12-21 01:53:19 +03:00
if ( strcmp ( filename , " - " ) = = 0 )
doc = xmlCtxtReadFd ( ctxt , STDIN_FILENO , " - " , NULL , options ) ;
else
doc = xmlCtxtReadFile ( ctxt , filename , NULL , options ) ;
2024-05-07 16:23:03 +03:00
}
}
2022-02-01 17:56:21 +03:00
2024-05-07 16:23:03 +03:00
if ( doc = = NULL ) {
if ( ctxt - > errNo = = XML_ERR_NO_MEMORY )
progresult = XMLLINT_ERR_MEM ;
else
progresult = XMLLINT_ERR_RDFILE ;
} else {
# ifdef LIBXML_VALID_ENABLED
2024-05-07 17:53:43 +03:00
if ( ( options & XML_PARSE_DTDVALID ) & & ( ctxt - > valid = = 0 ) )
2024-05-07 16:23:03 +03:00
progresult = XMLLINT_ERR_VALID ;
2003-09-28 22:58:27 +04:00
# endif /* LIBXML_VALID_ENABLED */
2024-05-07 16:23:03 +03:00
}
2023-08-20 21:48:10 +03:00
2024-05-07 16:23:03 +03:00
error :
if ( ctxt ! = rectxt )
xmlFreeParserCtxt ( ctxt ) ;
2023-12-21 01:53:19 +03:00
2024-05-07 16:23:03 +03:00
return ( doc ) ;
}
2023-12-21 01:53:19 +03:00
2024-05-07 16:23:03 +03:00
static void
parseAndPrintFile ( const char * filename , xmlParserCtxtPtr rectxt ) {
xmlDocPtr doc ;
2000-04-05 22:38:42 +04:00
2024-05-07 16:23:03 +03:00
if ( ( timing ) & & ( ! repeat ) )
startTimer ( ) ;
doc = parseFile ( filename , rectxt ) ;
2000-11-06 19:43:11 +03:00
if ( doc = = NULL ) {
2024-05-07 16:23:03 +03:00
if ( progresult = = XMLLINT_RETURN_OK )
progresult = XMLLINT_ERR_UNCLASS ;
2000-08-04 22:23:10 +04:00
return ;
2000-11-06 19:43:11 +03:00
}
2001-02-25 19:11:03 +03:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 10:09:59 +03:00
endTimer ( " Parsing " ) ;
2001-02-25 19:11:03 +03:00
}
2001-12-14 01:21:58 +03:00
if ( dropdtd ) {
xmlDtdPtr dtd ;
dtd = xmlGetIntSubset ( doc ) ;
if ( dtd ! = NULL ) {
xmlUnlinkNode ( ( xmlNodePtr ) dtd ) ;
2024-05-09 22:10:28 +03:00
doc - > intSubset = dtd ;
2001-12-14 01:21:58 +03:00
}
}
2000-11-06 19:43:11 +03:00
# ifdef LIBXML_XINCLUDE_ENABLED
2001-02-25 19:11:03 +03:00
if ( xinclude ) {
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 10:09:59 +03:00
startTimer ( ) ;
2001-02-25 19:11:03 +03:00
}
2005-02-11 13:58:55 +03:00
if ( xmlXIncludeProcessFlags ( doc , options ) < 0 )
progresult = XMLLINT_ERR_UNCLASS ;
2001-02-25 19:11:03 +03:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 10:09:59 +03:00
endTimer ( " Xinclude processing " ) ;
2001-02-25 19:11:03 +03:00
}
}
2000-11-06 19:43:11 +03:00
# endif
2000-08-04 22:23:10 +04:00
2009-10-07 12:25:06 +04:00
# ifdef LIBXML_XPATH_ENABLED
if ( xpathquery ! = NULL ) {
doXPathQuery ( doc , xpathquery ) ;
}
# endif
2000-04-05 22:38:42 +04:00
# ifdef LIBXML_DEBUG_ENABLED
2004-11-09 19:17:02 +03:00
# ifdef LIBXML_XPATH_ENABLED
2000-04-05 22:38:42 +04:00
/*
2001-12-31 19:16:02 +03:00
* shell interaction
2000-04-05 22:38:42 +04:00
*/
2006-10-20 16:55:34 +04:00
if ( shell ) {
xmlXPathOrderDocElems ( doc ) ;
2000-04-05 22:38:42 +04:00
xmlShell ( doc , filename , xmlShellReadline , stdout ) ;
2006-10-20 16:55:34 +04:00
}
2000-04-05 22:38:42 +04:00
# endif
2004-11-09 19:17:02 +03:00
# endif
2000-04-05 22:38:42 +04:00
/*
* test intermediate copy if needed .
*/
if ( copy ) {
2024-05-07 16:23:03 +03:00
xmlDocPtr tmp ;
2000-04-05 22:38:42 +04:00
tmp = doc ;
2004-09-21 00:03:01 +04:00
if ( timing ) {
startTimer ( ) ;
}
2000-04-05 22:38:42 +04:00
doc = xmlCopyDoc ( doc , 1 ) ;
2023-06-06 14:15:46 +03:00
if ( doc = = NULL ) {
progresult = XMLLINT_ERR_MEM ;
xmlFreeDoc ( tmp ) ;
return ;
}
2004-09-21 00:03:01 +04:00
if ( timing ) {
endTimer ( " Copying " ) ;
}
if ( timing ) {
startTimer ( ) ;
}
2000-04-05 22:38:42 +04:00
xmlFreeDoc ( tmp ) ;
2004-09-21 00:03:01 +04:00
if ( timing ) {
endTimer ( " Freeing original " ) ;
}
2000-04-05 22:38:42 +04:00
}
2003-09-28 22:58:27 +04:00
# ifdef LIBXML_VALID_ENABLED
2024-06-06 20:28:23 +03:00
if ( ( insert )
# ifdef LIBXML_HTML_ENABLED
& & ( ! html )
# endif
) {
2000-04-05 22:38:42 +04:00
const xmlChar * list [ 256 ] ;
int nb , i ;
xmlNodePtr node ;
if ( doc - > children ! = NULL ) {
node = doc - > children ;
2024-05-06 01:29:07 +03:00
while ( ( node ! = NULL ) & &
( ( node - > type ! = XML_ELEMENT_NODE ) | |
( node - > last = = NULL ) ) )
node = node - > next ;
2000-04-05 22:38:42 +04:00
if ( node ! = NULL ) {
nb = xmlValidGetValidElements ( node - > last , NULL , list , 256 ) ;
if ( nb < 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " could not get valid list of elements \n " ) ;
2000-04-05 22:38:42 +04:00
} else if ( nb = = 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " No element can be inserted under root \n " ) ;
2000-04-05 22:38:42 +04:00
} else {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %d element types can be inserted under root: \n " ,
2000-04-05 22:38:42 +04:00
nb ) ;
for ( i = 0 ; i < nb ; i + + ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s \n " , ( char * ) list [ i ] ) ;
2000-04-05 22:38:42 +04:00
}
}
}
2009-08-10 16:43:18 +04:00
}
2003-09-28 22:58:27 +04:00
} else
# endif /* LIBXML_VALID_ENABLED */
2003-11-03 15:31:38 +03:00
# ifdef LIBXML_READER_ENABLED
if ( walker ) {
walkDoc ( doc ) ;
}
# endif /* LIBXML_READER_ENABLED */
2003-09-29 17:20:24 +04:00
# ifdef LIBXML_OUTPUT_ENABLED
2003-09-28 22:58:27 +04:00
if ( noout = = 0 ) {
2024-04-28 18:54:36 +03:00
if ( compress )
xmlSetDocCompressMode ( doc , 9 ) ;
2000-04-05 22:38:42 +04:00
/*
* print it .
*/
# ifdef LIBXML_DEBUG_ENABLED
if ( ! debug ) {
# endif
2001-02-25 19:11:03 +03:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 10:09:59 +03:00
startTimer ( ) ;
2001-02-25 19:11:03 +03:00
}
2004-05-01 03:11:45 +04:00
# ifdef LIBXML_HTML_ENABLED
2003-11-04 11:47:48 +03:00
if ( ( html ) & & ( ! xmlout ) ) {
if ( compress ) {
htmlSaveFile ( output ? output : " - " , doc ) ;
}
else if ( encoding ! = NULL ) {
2010-11-01 16:27:11 +03:00
if ( format = = 1 ) {
2003-11-04 11:47:48 +03:00
htmlSaveFileFormat ( output ? output : " - " , doc , encoding , 1 ) ;
}
else {
htmlSaveFileFormat ( output ? output : " - " , doc , encoding , 0 ) ;
}
}
2010-11-01 16:27:11 +03:00
else if ( format = = 1 ) {
2003-11-04 11:47:48 +03:00
htmlSaveFileFormat ( output ? output : " - " , doc , NULL , 1 ) ;
}
else {
FILE * out ;
if ( output = = NULL )
out = stdout ;
else {
out = fopen ( output , " wb " ) ;
}
if ( out ! = NULL ) {
if ( htmlDocDump ( out , doc ) < 0 )
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_OUT ;
2003-11-04 11:47:48 +03:00
if ( output ! = NULL )
fclose ( out ) ;
} else {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " failed to open %s \n " , output ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_OUT ;
2003-11-04 11:47:48 +03:00
}
}
if ( ( timing ) & & ( ! repeat ) ) {
endTimer ( " Saving " ) ;
}
} else
# endif
2004-08-15 02:37:54 +04:00
# ifdef LIBXML_C14N_ENABLED
if ( canonical ) {
xmlChar * result = NULL ;
int size ;
2009-07-09 12:26:22 +04:00
size = xmlC14NDocDumpMemory ( doc , NULL , XML_C14N_1_0 , NULL , 1 , & result ) ;
if ( size > = 0 ) {
2011-05-09 13:14:59 +04:00
if ( write ( 1 , result , size ) = = - 1 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Can't write data \n " ) ;
2011-05-09 13:14:59 +04:00
}
2009-07-09 12:26:22 +04:00
xmlFree ( result ) ;
} else {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Failed to canonicalize \n " ) ;
2009-07-09 12:26:22 +04:00
progresult = XMLLINT_ERR_OUT ;
}
2014-06-09 18:10:15 +04:00
} else if ( canonical_11 ) {
2009-07-09 12:26:22 +04:00
xmlChar * result = NULL ;
int size ;
size = xmlC14NDocDumpMemory ( doc , NULL , XML_C14N_1_1 , NULL , 1 , & result ) ;
2004-08-15 02:37:54 +04:00
if ( size > = 0 ) {
2011-05-09 13:14:59 +04:00
if ( write ( 1 , result , size ) = = - 1 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Can't write data \n " ) ;
2011-05-09 13:14:59 +04:00
}
2004-08-15 02:37:54 +04:00
xmlFree ( result ) ;
} else {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Failed to canonicalize \n " ) ;
2004-08-15 02:37:54 +04:00
progresult = XMLLINT_ERR_OUT ;
}
} else
2005-06-06 21:16:50 +04:00
if ( exc_canonical ) {
xmlChar * result = NULL ;
int size ;
2009-07-09 12:26:22 +04:00
size = xmlC14NDocDumpMemory ( doc , NULL , XML_C14N_EXCLUSIVE_1_0 , NULL , 1 , & result ) ;
2005-06-06 21:16:50 +04:00
if ( size > = 0 ) {
2011-05-09 13:14:59 +04:00
if ( write ( 1 , result , size ) = = - 1 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Can't write data \n " ) ;
2011-05-09 13:14:59 +04:00
}
2005-06-06 21:16:50 +04:00
xmlFree ( result ) ;
} else {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Failed to canonicalize \n " ) ;
2005-06-06 21:16:50 +04:00
progresult = XMLLINT_ERR_OUT ;
}
} else
2004-08-15 02:37:54 +04:00
# endif
Various "make distcheck" and portability fixups
Makefile.am:
* Don't use @VAR@, use $(VAR). Autoconf's AC_SUBST provides us the Make
variable, it allows overriding the value at the command line, and
(notably) it avoids a Make parse error in the libxml2_la_LDFLAGS
assignment when @MODULE_PLATFORM_LIBS@ is empty
* Changed how the THREADS_W32 mechanism switches the build between
testThreads.c and testThreadsWin32.c as appropriate; using AM_CONDITIONAL
allows this to work cleanly and plays well with dependencies
* testapi.c should be specified as BUILT_SOURCES
* Create symlinks to the test/ and result/ subdirs so that the runtests
target is usable in out-of-source-tree builds
* Don't do MAKEFLAGS+=--silent as this is not portable to non-GNU Makes
* Fixed incorrect find(1) syntax in the "cleanup" rule, and doing "rm -f"
instead of just "rm" is good form
* (DIST)CLEANFILES needed a bit more coverage to allow "make distcheck" to
pass
configure.in:
* Need AC_PROG_LN_S to create test/ and result/ symlinks in Makefile.am
* AC_LIBTOOL_WIN32_DLL and AM_PROG_LIBTOOL are obsolete; these have been
superceded by LT_INIT
* Don't rebuild docs by default, as this requires GNU Make (as
implemented)
* Check for uint32_t as some platforms don't provide it
* Check for some more functions, and undefine HAVE_MMAP if we don't also
HAVE_MUNMAP (one system I tested on actually needed this)
* Changed THREADS_W32 from a filename insert into an Automake conditional
* The "Copyright" file will not be in the current directory if builddir !=
srcdir
doc/Makefile.am:
* EXTRA_DIST cannot use wildcards when they refer to generated files; this
breaks dependencies. What I did was define EXTRA_DIST_wc, which uses GNU
Make $(wildcard) directives to build up a list of files, and EXTRA_DIST,
as a literal expansion of EXTRA_DIST_wc. I also added a new rule,
"check-extra-dist", to simplify checking that the two variables are
equivalent. (Note that this works only when builddir == srcdir)
(I can implement this differently if desired; this is just one way of
doing it)
* Don't define an "all" target; this steps on Automake's toes
* Fixed up the "libxml2-api.xml ..." rule by using $(wildcard) for
dependencies (as Make doesn't process the wildcards otherwise) and
qualifying appropriate files with $(srcdir)
(Note that $(srcdir) is not needed in the dependencies, thanks to VPATH,
which we can count on as this is GNU-Make-only code anyway)
doc/devhelp/Makefile.am:
* Qualified appropriate files with $(srcdir)
* Added an "uninstall-local" rule so that "make distcheck" passes
doc/examples/Makefile.am:
* Rather than use a wildcard that doesn't work, use a substitution that
most Make programs can handle
doc/examples/index.py:
* Do the same here
include/libxml/nanoftp.h:
* Some platforms (e.g. MSVC 6) already #define INVALID_SOCKET:
user@host:/cygdrive/c/Program Files/Microsoft Visual Studio/VC98/\
Include$ grep -R INVALID_SOCKET .
./WINSOCK.H:#define INVALID_SOCKET (SOCKET)(~0)
./WINSOCK2.H:#define INVALID_SOCKET (SOCKET)(~0)
include/libxml/xmlversion.h.in:
* Support ancient GCCs (I was actually able to build the library with 2.5
but for this bit)
python/Makefile.am:
* Expanded CLEANFILES to allow "make distcheck" to pass
python/tests/Makefile.am:
* Define CLEANFILES instead of a "clean" rule, and added tmp.xml to allow
"make distcheck" to pass
testRelax.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H (as some
systems have the header but not the function)
testSchemas.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H
testapi.c:
* Don't use putenv() if it's not available
threads.c:
* This fixes the following build error on Solaris 8:
libtool: compile: cc -DHAVE_CONFIG_H -I. -I./include -I./include \
-D_REENTRANT -D__EXTENSIONS__ -D_REENTRANT -Dsparc -Xa -mt -v \
-xarch=v9 -xcrossfile -xO5 -c threads.c -KPIC -DPIC -o threads.o
"threads.c", line 442: controlling expressions must have scalar type
"threads.c", line 512: controlling expressions must have scalar type
cc: acomp failed for threads.c
*** Error code 1
trio.c:
* Define isascii() if the system doesn't provide it
trio.h:
* The trio library's HAVE_CONFIG_H header is not the same as LibXML2's
HAVE_CONFIG_H header; this change is needed to avoid a double-inclusion
win32/configure.js:
* Added support for the LZMA compression option
win32/Makefile.{bcb,mingw,msvc}:
* Added appropriate bits to support WITH_LZMA=1
* Install the header files under $(INCPREFIX)\libxml2\libxml instead of
$(INCPREFIX)\libxml, to mirror the install location on Unix+Autotools
xml2-config.in:
* @MODULE_PLATFORM_LIBS@ (usually "-ldl") needs to be in there in order for
`xml2-config --libs` to provide a complete set of dependencies
xmllint.c:
* Use HAVE_MMAP instead of the less-explicit HAVE_SYS_MMAN_H
2012-08-06 07:32:54 +04:00
# ifdef HAVE_MMAP
2000-12-27 13:46:47 +03:00
if ( memory ) {
xmlChar * result ;
int len ;
if ( encoding ! = NULL ) {
2010-11-01 16:27:11 +03:00
if ( format = = 1 ) {
2001-11-08 20:32:47 +03:00
xmlDocDumpFormatMemoryEnc ( doc , & result , & len , encoding , 1 ) ;
2009-08-10 16:43:18 +04:00
} else {
2001-11-08 20:32:47 +03:00
xmlDocDumpMemoryEnc ( doc , & result , & len , encoding ) ;
}
2000-12-27 13:46:47 +03:00
} else {
2010-11-01 16:27:11 +03:00
if ( format = = 1 )
2001-08-14 18:12:47 +04:00
xmlDocDumpFormatMemory ( doc , & result , & len , 1 ) ;
else
xmlDocDumpMemory ( doc , & result , & len ) ;
2000-12-27 13:46:47 +03:00
}
if ( result = = NULL ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Failed to save \n " ) ;
2004-08-15 02:37:54 +04:00
progresult = XMLLINT_ERR_OUT ;
2000-12-27 13:46:47 +03:00
} else {
2011-05-09 13:14:59 +04:00
if ( write ( 1 , result , len ) = = - 1 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Can't write data \n " ) ;
2011-05-09 13:14:59 +04:00
}
2000-12-27 13:46:47 +03:00
xmlFree ( result ) ;
}
2006-10-17 03:22:10 +04:00
2001-04-04 04:09:00 +04:00
} else
Various "make distcheck" and portability fixups
Makefile.am:
* Don't use @VAR@, use $(VAR). Autoconf's AC_SUBST provides us the Make
variable, it allows overriding the value at the command line, and
(notably) it avoids a Make parse error in the libxml2_la_LDFLAGS
assignment when @MODULE_PLATFORM_LIBS@ is empty
* Changed how the THREADS_W32 mechanism switches the build between
testThreads.c and testThreadsWin32.c as appropriate; using AM_CONDITIONAL
allows this to work cleanly and plays well with dependencies
* testapi.c should be specified as BUILT_SOURCES
* Create symlinks to the test/ and result/ subdirs so that the runtests
target is usable in out-of-source-tree builds
* Don't do MAKEFLAGS+=--silent as this is not portable to non-GNU Makes
* Fixed incorrect find(1) syntax in the "cleanup" rule, and doing "rm -f"
instead of just "rm" is good form
* (DIST)CLEANFILES needed a bit more coverage to allow "make distcheck" to
pass
configure.in:
* Need AC_PROG_LN_S to create test/ and result/ symlinks in Makefile.am
* AC_LIBTOOL_WIN32_DLL and AM_PROG_LIBTOOL are obsolete; these have been
superceded by LT_INIT
* Don't rebuild docs by default, as this requires GNU Make (as
implemented)
* Check for uint32_t as some platforms don't provide it
* Check for some more functions, and undefine HAVE_MMAP if we don't also
HAVE_MUNMAP (one system I tested on actually needed this)
* Changed THREADS_W32 from a filename insert into an Automake conditional
* The "Copyright" file will not be in the current directory if builddir !=
srcdir
doc/Makefile.am:
* EXTRA_DIST cannot use wildcards when they refer to generated files; this
breaks dependencies. What I did was define EXTRA_DIST_wc, which uses GNU
Make $(wildcard) directives to build up a list of files, and EXTRA_DIST,
as a literal expansion of EXTRA_DIST_wc. I also added a new rule,
"check-extra-dist", to simplify checking that the two variables are
equivalent. (Note that this works only when builddir == srcdir)
(I can implement this differently if desired; this is just one way of
doing it)
* Don't define an "all" target; this steps on Automake's toes
* Fixed up the "libxml2-api.xml ..." rule by using $(wildcard) for
dependencies (as Make doesn't process the wildcards otherwise) and
qualifying appropriate files with $(srcdir)
(Note that $(srcdir) is not needed in the dependencies, thanks to VPATH,
which we can count on as this is GNU-Make-only code anyway)
doc/devhelp/Makefile.am:
* Qualified appropriate files with $(srcdir)
* Added an "uninstall-local" rule so that "make distcheck" passes
doc/examples/Makefile.am:
* Rather than use a wildcard that doesn't work, use a substitution that
most Make programs can handle
doc/examples/index.py:
* Do the same here
include/libxml/nanoftp.h:
* Some platforms (e.g. MSVC 6) already #define INVALID_SOCKET:
user@host:/cygdrive/c/Program Files/Microsoft Visual Studio/VC98/\
Include$ grep -R INVALID_SOCKET .
./WINSOCK.H:#define INVALID_SOCKET (SOCKET)(~0)
./WINSOCK2.H:#define INVALID_SOCKET (SOCKET)(~0)
include/libxml/xmlversion.h.in:
* Support ancient GCCs (I was actually able to build the library with 2.5
but for this bit)
python/Makefile.am:
* Expanded CLEANFILES to allow "make distcheck" to pass
python/tests/Makefile.am:
* Define CLEANFILES instead of a "clean" rule, and added tmp.xml to allow
"make distcheck" to pass
testRelax.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H (as some
systems have the header but not the function)
testSchemas.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H
testapi.c:
* Don't use putenv() if it's not available
threads.c:
* This fixes the following build error on Solaris 8:
libtool: compile: cc -DHAVE_CONFIG_H -I. -I./include -I./include \
-D_REENTRANT -D__EXTENSIONS__ -D_REENTRANT -Dsparc -Xa -mt -v \
-xarch=v9 -xcrossfile -xO5 -c threads.c -KPIC -DPIC -o threads.o
"threads.c", line 442: controlling expressions must have scalar type
"threads.c", line 512: controlling expressions must have scalar type
cc: acomp failed for threads.c
*** Error code 1
trio.c:
* Define isascii() if the system doesn't provide it
trio.h:
* The trio library's HAVE_CONFIG_H header is not the same as LibXML2's
HAVE_CONFIG_H header; this change is needed to avoid a double-inclusion
win32/configure.js:
* Added support for the LZMA compression option
win32/Makefile.{bcb,mingw,msvc}:
* Added appropriate bits to support WITH_LZMA=1
* Install the header files under $(INCPREFIX)\libxml2\libxml instead of
$(INCPREFIX)\libxml, to mirror the install location on Unix+Autotools
xml2-config.in:
* @MODULE_PLATFORM_LIBS@ (usually "-ldl") needs to be in there in order for
`xml2-config --libs` to provide a complete set of dependencies
xmllint.c:
* Use HAVE_MMAP instead of the less-explicit HAVE_SYS_MMAN_H
2012-08-06 07:32:54 +04:00
# endif /* HAVE_MMAP */
2001-12-18 14:14:16 +03:00
if ( compress ) {
xmlSaveFile ( output ? output : " - " , doc ) ;
2006-10-17 03:22:10 +04:00
} else {
xmlSaveCtxtPtr ctxt ;
int saveOpts = 0 ;
2010-11-01 16:27:11 +03:00
if ( format = = 1 )
2006-10-17 03:22:10 +04:00
saveOpts | = XML_SAVE_FORMAT ;
2010-11-03 17:33:40 +03:00
else if ( format = = 2 )
saveOpts | = XML_SAVE_WSNONSIG ;
2010-03-10 17:02:49 +03:00
2024-06-06 20:28:23 +03:00
# if defined(LIBXML_HTML_ENABLED)
2009-08-23 17:31:18 +04:00
if ( xmlout )
saveOpts | = XML_SAVE_AS_XML ;
2010-03-10 17:02:49 +03:00
# endif
2006-10-17 03:22:10 +04:00
2001-12-18 14:14:16 +03:00
if ( output = = NULL )
2006-10-17 03:22:10 +04:00
ctxt = xmlSaveToFd ( 1 , encoding , saveOpts ) ;
else
ctxt = xmlSaveToFilename ( output , encoding , saveOpts ) ;
2001-12-18 14:14:16 +03:00
2006-10-17 03:22:10 +04:00
if ( ctxt ! = NULL ) {
if ( xmlSaveDoc ( ctxt , doc ) < 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " failed save to %s \n " ,
2006-10-17 03:22:10 +04:00
output ? output : " - " ) ;
progresult = XMLLINT_ERR_OUT ;
}
xmlSaveClose ( ctxt ) ;
2003-10-08 15:54:57 +04:00
} else {
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_OUT ;
2003-10-08 15:54:57 +04:00
}
2001-11-08 20:32:47 +03:00
}
2001-02-25 19:11:03 +03:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 10:09:59 +03:00
endTimer ( " Saving " ) ;
2001-02-25 19:11:03 +03:00
}
2000-04-05 22:38:42 +04:00
# ifdef LIBXML_DEBUG_ENABLED
2000-12-27 13:46:47 +03:00
} else {
2001-12-18 14:14:16 +03:00
FILE * out ;
if ( output = = NULL )
out = stdout ;
else {
out = fopen ( output , " wb " ) ;
}
2003-10-08 15:54:57 +04:00
if ( out ! = NULL ) {
xmlDebugDumpDocument ( out , doc ) ;
2001-12-18 14:14:16 +03:00
2003-10-08 15:54:57 +04:00
if ( output ! = NULL )
fclose ( out ) ;
} else {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " failed to open %s \n " , output ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_OUT ;
2003-10-08 15:54:57 +04:00
}
2000-12-27 13:46:47 +03:00
}
2000-04-05 22:38:42 +04:00
# endif
}
2003-09-29 17:20:24 +04:00
# endif /* LIBXML_OUTPUT_ENABLED */
2000-04-05 22:38:42 +04:00
2003-09-28 22:58:27 +04:00
# ifdef LIBXML_VALID_ENABLED
2000-04-05 22:38:42 +04:00
/*
* A posteriori validation test
*/
2003-08-18 20:39:51 +04:00
if ( ( dtdvalid ! = NULL ) | | ( dtdvalidfpi ! = NULL ) ) {
2000-10-11 19:57:05 +04:00
xmlDtdPtr dtd ;
2001-02-25 19:11:03 +03:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 10:09:59 +03:00
startTimer ( ) ;
2001-02-25 19:11:03 +03:00
}
2003-08-18 20:39:51 +04:00
if ( dtdvalid ! = NULL )
2009-08-10 16:43:18 +04:00
dtd = xmlParseDTD ( NULL , ( const xmlChar * ) dtdvalid ) ;
2003-08-18 20:39:51 +04:00
else
2009-08-10 16:43:18 +04:00
dtd = xmlParseDTD ( ( const xmlChar * ) dtdvalidfpi , NULL ) ;
2001-02-25 19:11:03 +03:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 10:09:59 +03:00
endTimer ( " Parsing DTD " ) ;
2001-02-25 19:11:03 +03:00
}
2000-10-11 19:57:05 +04:00
if ( dtd = = NULL ) {
2003-08-18 20:39:51 +04:00
if ( dtdvalid ! = NULL )
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2003-08-18 20:39:51 +04:00
" Could not parse DTD %s \n " , dtdvalid ) ;
else
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2003-08-18 20:39:51 +04:00
" Could not parse DTD %s \n " , dtdvalidfpi ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_DTD ;
2000-10-11 19:57:05 +04:00
} else {
2003-06-09 13:10:36 +04:00
xmlValidCtxtPtr cvp ;
if ( ( cvp = xmlNewValidCtxt ( ) ) = = NULL ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2003-06-09 13:10:36 +04:00
" Couldn't allocate validation context \n " ) ;
2022-02-01 17:56:21 +03:00
progresult = XMLLINT_ERR_MEM ;
xmlFreeDtd ( dtd ) ;
return ;
2003-06-09 13:10:36 +04:00
}
2001-02-25 19:11:03 +03:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 10:09:59 +03:00
startTimer ( ) ;
2001-02-25 19:11:03 +03:00
}
2003-06-09 13:10:36 +04:00
if ( ! xmlValidateDtd ( cvp , doc , dtd ) ) {
2003-08-18 20:39:51 +04:00
if ( dtdvalid ! = NULL )
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2003-08-18 20:39:51 +04:00
" Document %s does not validate against %s \n " ,
filename , dtdvalid ) ;
else
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2003-08-18 20:39:51 +04:00
" Document %s does not validate against %s \n " ,
filename , dtdvalidfpi ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_VALID ;
2000-10-11 19:57:05 +04:00
}
2001-02-25 19:11:03 +03:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 10:09:59 +03:00
endTimer ( " Validating against DTD " ) ;
2001-02-25 19:11:03 +03:00
}
2003-06-09 13:10:36 +04:00
xmlFreeValidCtxt ( cvp ) ;
2000-10-11 19:57:05 +04:00
xmlFreeDtd ( dtd ) ;
}
} else if ( postvalid ) {
2003-06-09 13:10:36 +04:00
xmlValidCtxtPtr cvp ;
if ( ( cvp = xmlNewValidCtxt ( ) ) = = NULL ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2003-06-09 13:10:36 +04:00
" Couldn't allocate validation context \n " ) ;
2022-02-01 17:56:21 +03:00
progresult = XMLLINT_ERR_MEM ;
xmlFreeDoc ( doc ) ;
return ;
2003-06-09 13:10:36 +04:00
}
2001-02-25 19:11:03 +03:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 10:09:59 +03:00
startTimer ( ) ;
2001-02-25 19:11:03 +03:00
}
2003-06-09 13:10:36 +04:00
if ( ! xmlValidateDocument ( cvp , doc ) ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2000-10-25 23:56:55 +04:00
" Document %s does not validate \n " , filename ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_VALID ;
2000-10-11 19:57:05 +04:00
}
2001-02-25 19:11:03 +03:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 10:09:59 +03:00
endTimer ( " Validating " ) ;
2001-02-25 19:11:03 +03:00
}
2003-06-09 13:10:36 +04:00
xmlFreeValidCtxt ( cvp ) ;
2003-09-28 22:58:27 +04:00
}
# endif /* LIBXML_VALID_ENABLED */
2005-07-24 18:27:16 +04:00
# ifdef LIBXML_SCHEMATRON_ENABLED
if ( wxschematron ! = NULL ) {
xmlSchematronValidCtxtPtr ctxt ;
int ret ;
2005-07-31 16:17:24 +04:00
int flag ;
2005-07-24 18:27:16 +04:00
if ( ( timing ) & & ( ! repeat ) ) {
startTimer ( ) ;
}
if ( debug )
flag = XML_SCHEMATRON_OUT_XML ;
2005-07-31 16:17:24 +04:00
else
flag = XML_SCHEMATRON_OUT_TEXT ;
if ( noout )
flag | = XML_SCHEMATRON_OUT_QUIET ;
2005-07-24 18:27:16 +04:00
ctxt = xmlSchematronNewValidCtxt ( wxschematron , flag ) ;
2022-02-01 17:56:21 +03:00
if ( ctxt = = NULL ) {
progresult = XMLLINT_ERR_MEM ;
xmlFreeDoc ( doc ) ;
return ;
}
2005-07-24 18:27:16 +04:00
ret = xmlSchematronValidateDoc ( ctxt , doc ) ;
if ( ret = = 0 ) {
2021-02-03 01:27:52 +03:00
if ( ! quiet ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s validates \n " , filename ) ;
2021-02-03 01:27:52 +03:00
}
2005-07-24 18:27:16 +04:00
} else if ( ret > 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s fails to validate \n " , filename ) ;
2005-07-24 18:27:16 +04:00
progresult = XMLLINT_ERR_VALID ;
} else {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s validation generated an internal error \n " ,
2005-07-24 18:27:16 +04:00
filename ) ;
progresult = XMLLINT_ERR_VALID ;
}
xmlSchematronFreeValidCtxt ( ctxt ) ;
if ( ( timing ) & & ( ! repeat ) ) {
endTimer ( " Validating " ) ;
}
}
# endif
2003-02-05 16:19:53 +03:00
# ifdef LIBXML_SCHEMAS_ENABLED
2003-09-28 22:58:27 +04:00
if ( relaxngschemas ! = NULL ) {
2003-02-05 16:19:53 +03:00
xmlRelaxNGValidCtxtPtr ctxt ;
int ret ;
2003-03-07 21:32:59 +03:00
if ( ( timing ) & & ( ! repeat ) ) {
startTimer ( ) ;
}
2003-02-05 16:19:53 +03:00
ctxt = xmlRelaxNGNewValidCtxt ( relaxngschemas ) ;
2022-02-01 17:56:21 +03:00
if ( ctxt = = NULL ) {
progresult = XMLLINT_ERR_MEM ;
xmlFreeDoc ( doc ) ;
return ;
}
2003-02-05 16:19:53 +03:00
ret = xmlRelaxNGValidateDoc ( ctxt , doc ) ;
if ( ret = = 0 ) {
2021-02-03 01:27:52 +03:00
if ( ! quiet ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s validates \n " , filename ) ;
2021-02-03 01:27:52 +03:00
}
2003-02-05 16:19:53 +03:00
} else if ( ret > 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s fails to validate \n " , filename ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_VALID ;
2003-02-05 16:19:53 +03:00
} else {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s validation generated an internal error \n " ,
2003-02-05 16:19:53 +03:00
filename ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_VALID ;
2003-02-05 16:19:53 +03:00
}
xmlRelaxNGFreeValidCtxt ( ctxt ) ;
2003-03-07 21:32:59 +03:00
if ( ( timing ) & & ( ! repeat ) ) {
endTimer ( " Validating " ) ;
}
2003-05-12 19:25:56 +04:00
} else if ( wxschemas ! = NULL ) {
xmlSchemaValidCtxtPtr ctxt ;
int ret ;
if ( ( timing ) & & ( ! repeat ) ) {
startTimer ( ) ;
}
ctxt = xmlSchemaNewValidCtxt ( wxschemas ) ;
2022-02-01 17:56:21 +03:00
if ( ctxt = = NULL ) {
progresult = XMLLINT_ERR_MEM ;
xmlFreeDoc ( doc ) ;
return ;
}
2003-05-12 19:25:56 +04:00
ret = xmlSchemaValidateDoc ( ctxt , doc ) ;
if ( ret = = 0 ) {
2021-02-03 01:27:52 +03:00
if ( ! quiet ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s validates \n " , filename ) ;
2021-02-03 01:27:52 +03:00
}
2003-05-12 19:25:56 +04:00
} else if ( ret > 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s fails to validate \n " , filename ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_VALID ;
2003-05-12 19:25:56 +04:00
} else {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s validation generated an internal error \n " ,
2003-05-12 19:25:56 +04:00
filename ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_VALID ;
2003-05-12 19:25:56 +04:00
}
xmlSchemaFreeValidCtxt ( ctxt ) ;
if ( ( timing ) & & ( ! repeat ) ) {
endTimer ( " Validating " ) ;
}
2000-04-05 22:38:42 +04:00
}
2003-09-28 22:58:27 +04:00
# endif
2000-04-05 22:38:42 +04:00
# ifdef LIBXML_DEBUG_ENABLED
2024-06-06 20:28:23 +03:00
if ( ( debugent )
# if defined(LIBXML_HTML_ENABLED)
& & ( ! html )
2008-11-06 16:47:39 +03:00
# endif
2024-06-06 20:28:23 +03:00
)
xmlDebugDumpEntities ( ERR_STREAM , doc ) ;
2000-04-05 22:38:42 +04:00
# endif
/*
* free it .
*/
2001-02-25 19:11:03 +03:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 10:09:59 +03:00
startTimer ( ) ;
2001-02-25 19:11:03 +03:00
}
2000-04-05 22:38:42 +04:00
xmlFreeDoc ( doc ) ;
2001-02-25 19:11:03 +03:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 10:09:59 +03:00
endTimer ( " Freeing " ) ;
2001-02-25 19:11:03 +03:00
}
2000-04-05 22:38:42 +04:00
}
2001-06-20 17:55:33 +04:00
/************************************************************************
2009-08-10 16:43:18 +04:00
* *
* Usage and Main *
* *
2001-06-20 17:55:33 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-09-18 03:04:40 +04:00
static void showVersion ( const char * name ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s: using libxml version %s \n " , name , xmlParserVersion ) ;
fprintf ( ERR_STREAM , " compiled with: " ) ;
if ( xmlHasFeature ( XML_WITH_THREAD ) ) fprintf ( ERR_STREAM , " Threads " ) ;
if ( xmlHasFeature ( XML_WITH_TREE ) ) fprintf ( ERR_STREAM , " Tree " ) ;
if ( xmlHasFeature ( XML_WITH_OUTPUT ) ) fprintf ( ERR_STREAM , " Output " ) ;
if ( xmlHasFeature ( XML_WITH_PUSH ) ) fprintf ( ERR_STREAM , " Push " ) ;
if ( xmlHasFeature ( XML_WITH_READER ) ) fprintf ( ERR_STREAM , " Reader " ) ;
if ( xmlHasFeature ( XML_WITH_PATTERN ) ) fprintf ( ERR_STREAM , " Patterns " ) ;
if ( xmlHasFeature ( XML_WITH_WRITER ) ) fprintf ( ERR_STREAM , " Writer " ) ;
if ( xmlHasFeature ( XML_WITH_SAX1 ) ) fprintf ( ERR_STREAM , " SAXv1 " ) ;
if ( xmlHasFeature ( XML_WITH_HTTP ) ) fprintf ( ERR_STREAM , " HTTP " ) ;
if ( xmlHasFeature ( XML_WITH_VALID ) ) fprintf ( ERR_STREAM , " DTDValid " ) ;
if ( xmlHasFeature ( XML_WITH_HTML ) ) fprintf ( ERR_STREAM , " HTML " ) ;
if ( xmlHasFeature ( XML_WITH_LEGACY ) ) fprintf ( ERR_STREAM , " Legacy " ) ;
if ( xmlHasFeature ( XML_WITH_C14N ) ) fprintf ( ERR_STREAM , " C14N " ) ;
if ( xmlHasFeature ( XML_WITH_CATALOG ) ) fprintf ( ERR_STREAM , " Catalog " ) ;
if ( xmlHasFeature ( XML_WITH_XPATH ) ) fprintf ( ERR_STREAM , " XPath " ) ;
if ( xmlHasFeature ( XML_WITH_XPTR ) ) fprintf ( ERR_STREAM , " XPointer " ) ;
if ( xmlHasFeature ( XML_WITH_XINCLUDE ) ) fprintf ( ERR_STREAM , " XInclude " ) ;
if ( xmlHasFeature ( XML_WITH_ICONV ) ) fprintf ( ERR_STREAM , " Iconv " ) ;
if ( xmlHasFeature ( XML_WITH_ICU ) ) fprintf ( ERR_STREAM , " ICU " ) ;
if ( xmlHasFeature ( XML_WITH_ISO8859X ) ) fprintf ( ERR_STREAM , " ISO8859X " ) ;
if ( xmlHasFeature ( XML_WITH_UNICODE ) ) fprintf ( ERR_STREAM , " Unicode " ) ;
if ( xmlHasFeature ( XML_WITH_REGEXP ) ) fprintf ( ERR_STREAM , " Regexps " ) ;
if ( xmlHasFeature ( XML_WITH_AUTOMATA ) ) fprintf ( ERR_STREAM , " Automata " ) ;
if ( xmlHasFeature ( XML_WITH_EXPR ) ) fprintf ( ERR_STREAM , " Expr " ) ;
if ( xmlHasFeature ( XML_WITH_SCHEMAS ) ) fprintf ( ERR_STREAM , " Schemas " ) ;
if ( xmlHasFeature ( XML_WITH_SCHEMATRON ) ) fprintf ( ERR_STREAM , " Schematron " ) ;
if ( xmlHasFeature ( XML_WITH_MODULES ) ) fprintf ( ERR_STREAM , " Modules " ) ;
if ( xmlHasFeature ( XML_WITH_DEBUG ) ) fprintf ( ERR_STREAM , " Debug " ) ;
if ( xmlHasFeature ( XML_WITH_ZLIB ) ) fprintf ( ERR_STREAM , " Zlib " ) ;
if ( xmlHasFeature ( XML_WITH_LZMA ) ) fprintf ( ERR_STREAM , " Lzma " ) ;
fprintf ( ERR_STREAM , " \n " ) ;
2002-09-18 03:04:40 +04:00
}
2017-06-20 17:19:33 +03:00
static void usage ( FILE * f , const char * name ) {
fprintf ( f , " Usage : %s [options] XMLfiles ... \n " , name ) ;
2003-09-29 17:20:24 +04:00
# ifdef LIBXML_OUTPUT_ENABLED
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t Parse the XML files and output the result of the parsing \n " ) ;
2003-09-29 17:20:24 +04:00
# else
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t Parse the XML files \n " ) ;
2003-09-29 17:20:24 +04:00
# endif /* LIBXML_OUTPUT_ENABLED */
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --version : display the version of the XML library used \n " ) ;
2001-06-20 17:55:33 +04:00
# ifdef LIBXML_DEBUG_ENABLED
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --debug : dump a debug tree of the in-memory document \n " ) ;
fprintf ( f , " \t --shell : run a navigating shell \n " ) ;
fprintf ( f , " \t --debugent : debug the entities defined in the document \n " ) ;
2003-01-07 03:19:07 +03:00
# else
2003-09-30 04:43:48 +04:00
# ifdef LIBXML_READER_ENABLED
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --debug : dump the nodes content when using --stream \n " ) ;
2003-09-30 04:43:48 +04:00
# endif /* LIBXML_READER_ENABLED */
2001-06-20 17:55:33 +04:00
# endif
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --copy : used to test the internal copy implementation \n " ) ;
fprintf ( f , " \t --recover : output what was parsable on broken XML documents \n " ) ;
fprintf ( f , " \t --huge : remove any internal arbitrary parser limits \n " ) ;
fprintf ( f , " \t --noent : substitute entity references by their value \n " ) ;
fprintf ( f , " \t --noenc : ignore any encoding specified inside the document \n " ) ;
fprintf ( f , " \t --noout : don't output the result tree \n " ) ;
fprintf ( f , " \t --path 'paths': provide a set of paths for resources \n " ) ;
fprintf ( f , " \t --load-trace : print trace of all external entities loaded \n " ) ;
fprintf ( f , " \t --nonet : refuse to fetch DTDs or entities over network \n " ) ;
fprintf ( f , " \t --nocompact : do not generate compact text nodes \n " ) ;
fprintf ( f , " \t --htmlout : output results as HTML \n " ) ;
fprintf ( f , " \t --nowrap : do not put HTML doc wrapper \n " ) ;
2003-09-28 22:58:27 +04:00
# ifdef LIBXML_VALID_ENABLED
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --valid : validate the document in addition to std well-formed check \n " ) ;
fprintf ( f , " \t --postvalid : do a posteriori validation, i.e after parsing \n " ) ;
fprintf ( f , " \t --dtdvalid URL : do a posteriori validation against a given DTD \n " ) ;
fprintf ( f , " \t --dtdvalidfpi FPI : same but name the DTD with a Public Identifier \n " ) ;
2024-05-07 17:53:43 +03:00
fprintf ( f , " \t --insert : ad-hoc test for valid insertions \n " ) ;
2003-09-28 22:58:27 +04:00
# endif /* LIBXML_VALID_ENABLED */
2021-02-03 01:27:52 +03:00
fprintf ( f , " \t --quiet : be quiet when succeeded \n " ) ;
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --timing : print some timings \n " ) ;
fprintf ( f , " \t --repeat : repeat 100 times, for timing or profiling \n " ) ;
2024-05-07 17:53:43 +03:00
fprintf ( f , " \t --dropdtd : remove the DOCTYPE of the input docs \n " ) ;
2001-06-20 17:55:33 +04:00
# ifdef LIBXML_HTML_ENABLED
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --html : use the HTML parser \n " ) ;
fprintf ( f , " \t --xmlout : force to use the XML serializer when using --html \n " ) ;
fprintf ( f , " \t --nodefdtd : do not default HTML doctype \n " ) ;
2001-06-20 17:55:33 +04:00
# endif
2003-09-30 16:36:01 +04:00
# ifdef LIBXML_PUSH_ENABLED
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --push : use the push mode of the parser \n " ) ;
fprintf ( f , " \t --pushsmall : use the push mode of the parser using tiny increments \n " ) ;
2003-09-30 16:36:01 +04:00
# endif /* LIBXML_PUSH_ENABLED */
Various "make distcheck" and portability fixups
Makefile.am:
* Don't use @VAR@, use $(VAR). Autoconf's AC_SUBST provides us the Make
variable, it allows overriding the value at the command line, and
(notably) it avoids a Make parse error in the libxml2_la_LDFLAGS
assignment when @MODULE_PLATFORM_LIBS@ is empty
* Changed how the THREADS_W32 mechanism switches the build between
testThreads.c and testThreadsWin32.c as appropriate; using AM_CONDITIONAL
allows this to work cleanly and plays well with dependencies
* testapi.c should be specified as BUILT_SOURCES
* Create symlinks to the test/ and result/ subdirs so that the runtests
target is usable in out-of-source-tree builds
* Don't do MAKEFLAGS+=--silent as this is not portable to non-GNU Makes
* Fixed incorrect find(1) syntax in the "cleanup" rule, and doing "rm -f"
instead of just "rm" is good form
* (DIST)CLEANFILES needed a bit more coverage to allow "make distcheck" to
pass
configure.in:
* Need AC_PROG_LN_S to create test/ and result/ symlinks in Makefile.am
* AC_LIBTOOL_WIN32_DLL and AM_PROG_LIBTOOL are obsolete; these have been
superceded by LT_INIT
* Don't rebuild docs by default, as this requires GNU Make (as
implemented)
* Check for uint32_t as some platforms don't provide it
* Check for some more functions, and undefine HAVE_MMAP if we don't also
HAVE_MUNMAP (one system I tested on actually needed this)
* Changed THREADS_W32 from a filename insert into an Automake conditional
* The "Copyright" file will not be in the current directory if builddir !=
srcdir
doc/Makefile.am:
* EXTRA_DIST cannot use wildcards when they refer to generated files; this
breaks dependencies. What I did was define EXTRA_DIST_wc, which uses GNU
Make $(wildcard) directives to build up a list of files, and EXTRA_DIST,
as a literal expansion of EXTRA_DIST_wc. I also added a new rule,
"check-extra-dist", to simplify checking that the two variables are
equivalent. (Note that this works only when builddir == srcdir)
(I can implement this differently if desired; this is just one way of
doing it)
* Don't define an "all" target; this steps on Automake's toes
* Fixed up the "libxml2-api.xml ..." rule by using $(wildcard) for
dependencies (as Make doesn't process the wildcards otherwise) and
qualifying appropriate files with $(srcdir)
(Note that $(srcdir) is not needed in the dependencies, thanks to VPATH,
which we can count on as this is GNU-Make-only code anyway)
doc/devhelp/Makefile.am:
* Qualified appropriate files with $(srcdir)
* Added an "uninstall-local" rule so that "make distcheck" passes
doc/examples/Makefile.am:
* Rather than use a wildcard that doesn't work, use a substitution that
most Make programs can handle
doc/examples/index.py:
* Do the same here
include/libxml/nanoftp.h:
* Some platforms (e.g. MSVC 6) already #define INVALID_SOCKET:
user@host:/cygdrive/c/Program Files/Microsoft Visual Studio/VC98/\
Include$ grep -R INVALID_SOCKET .
./WINSOCK.H:#define INVALID_SOCKET (SOCKET)(~0)
./WINSOCK2.H:#define INVALID_SOCKET (SOCKET)(~0)
include/libxml/xmlversion.h.in:
* Support ancient GCCs (I was actually able to build the library with 2.5
but for this bit)
python/Makefile.am:
* Expanded CLEANFILES to allow "make distcheck" to pass
python/tests/Makefile.am:
* Define CLEANFILES instead of a "clean" rule, and added tmp.xml to allow
"make distcheck" to pass
testRelax.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H (as some
systems have the header but not the function)
testSchemas.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H
testapi.c:
* Don't use putenv() if it's not available
threads.c:
* This fixes the following build error on Solaris 8:
libtool: compile: cc -DHAVE_CONFIG_H -I. -I./include -I./include \
-D_REENTRANT -D__EXTENSIONS__ -D_REENTRANT -Dsparc -Xa -mt -v \
-xarch=v9 -xcrossfile -xO5 -c threads.c -KPIC -DPIC -o threads.o
"threads.c", line 442: controlling expressions must have scalar type
"threads.c", line 512: controlling expressions must have scalar type
cc: acomp failed for threads.c
*** Error code 1
trio.c:
* Define isascii() if the system doesn't provide it
trio.h:
* The trio library's HAVE_CONFIG_H header is not the same as LibXML2's
HAVE_CONFIG_H header; this change is needed to avoid a double-inclusion
win32/configure.js:
* Added support for the LZMA compression option
win32/Makefile.{bcb,mingw,msvc}:
* Added appropriate bits to support WITH_LZMA=1
* Install the header files under $(INCPREFIX)\libxml2\libxml instead of
$(INCPREFIX)\libxml, to mirror the install location on Unix+Autotools
xml2-config.in:
* @MODULE_PLATFORM_LIBS@ (usually "-ldl") needs to be in there in order for
`xml2-config --libs` to provide a complete set of dependencies
xmllint.c:
* Use HAVE_MMAP instead of the less-explicit HAVE_SYS_MMAN_H
2012-08-06 07:32:54 +04:00
# ifdef HAVE_MMAP
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --memory : parse from memory \n " ) ;
2001-06-20 17:55:33 +04:00
# endif
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --maxmem nbbytes : limits memory allocation to nbbytes bytes \n " ) ;
fprintf ( f , " \t --nowarning : do not emit warnings from parser/validator \n " ) ;
fprintf ( f , " \t --noblanks : drop (ignorable?) blanks spaces \n " ) ;
fprintf ( f , " \t --nocdata : replace cdata section with text nodes \n " ) ;
2003-09-29 17:20:24 +04:00
# ifdef LIBXML_OUTPUT_ENABLED
2024-05-07 17:53:43 +03:00
fprintf ( f , " \t --output file or -o file: save to a given file \n " ) ;
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --format : reformat/reindent the output \n " ) ;
fprintf ( f , " \t --encode encoding : output in the given encoding \n " ) ;
fprintf ( f , " \t --pretty STYLE : pretty-print in a particular style \n " ) ;
fprintf ( f , " \t 0 Do not pretty print \n " ) ;
fprintf ( f , " \t 1 Format the XML content, as --format \n " ) ;
fprintf ( f , " \t 2 Add whitespace inside tags, preserving content \n " ) ;
2024-05-07 17:53:43 +03:00
# ifdef LIBXML_ZLIB_ENABLED
fprintf ( f , " \t --compress : turn on gzip compression of output \n " ) ;
# endif
2003-09-29 17:20:24 +04:00
# endif /* LIBXML_OUTPUT_ENABLED */
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --c14n : save in W3C canonical format v1.0 (with comments) \n " ) ;
fprintf ( f , " \t --c14n11 : save in W3C canonical format v1.1 (with comments) \n " ) ;
fprintf ( f , " \t --exc-c14n : save in W3C exclusive canonical format (with comments) \n " ) ;
2004-08-15 02:37:54 +04:00
# ifdef LIBXML_C14N_ENABLED
# endif /* LIBXML_C14N_ENABLED */
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --nsclean : remove redundant namespace declarations \n " ) ;
fprintf ( f , " \t --testIO : test user I/O support \n " ) ;
2001-06-20 17:55:33 +04:00
# ifdef LIBXML_CATALOG_ENABLED
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --catalogs : use SGML catalogs from $SGML_CATALOG_FILES \n " ) ;
fprintf ( f , " \t otherwise XML Catalogs starting from \n " ) ;
fprintf ( f , " \t %s are activated by default \n " , XML_XML_DEFAULT_CATALOG ) ;
fprintf ( f , " \t --nocatalogs: deactivate all catalogs \n " ) ;
2001-06-20 17:55:33 +04:00
# endif
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --auto : generate a small doc on the fly \n " ) ;
2001-06-20 17:55:33 +04:00
# ifdef LIBXML_XINCLUDE_ENABLED
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --xinclude : do XInclude processing \n " ) ;
fprintf ( f , " \t --noxincludenode : same but do not generate XInclude nodes \n " ) ;
fprintf ( f , " \t --nofixup-base-uris : do not fixup xml:base uris \n " ) ;
2001-06-20 17:55:33 +04:00
# endif
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --loaddtd : fetch external DTD \n " ) ;
fprintf ( f , " \t --dtdattr : loaddtd + populate the tree with inherited attributes \n " ) ;
2003-09-30 04:43:48 +04:00
# ifdef LIBXML_READER_ENABLED
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --stream : use the streaming interface to process very large files \n " ) ;
fprintf ( f , " \t --walker : create a reader and walk though the resulting doc \n " ) ;
2003-12-03 01:32:15 +03:00
# ifdef LIBXML_PATTERN_ENABLED
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --pattern pattern_value : test the pattern support \n " ) ;
2003-12-03 01:32:15 +03:00
# endif
2019-05-16 22:06:56 +03:00
# endif /* LIBXML_READER_ENABLED */
2003-02-07 15:38:22 +03:00
# ifdef LIBXML_SCHEMAS_ENABLED
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --relaxng schema : do RelaxNG validation against the schema \n " ) ;
fprintf ( f , " \t --schema schema : do validation against the WXS schema \n " ) ;
2003-02-05 16:19:53 +03:00
# endif
2005-07-31 01:09:12 +04:00
# ifdef LIBXML_SCHEMATRON_ENABLED
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --schematron schema : do validation against a schematron \n " ) ;
2005-07-31 01:09:12 +04:00
# endif
2005-07-09 21:32:57 +04:00
# ifdef LIBXML_SAX1_ENABLED
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --sax1: use the old SAX1 interfaces for processing \n " ) ;
2005-07-09 21:32:57 +04:00
# endif
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --sax: do not build a tree but work just at the SAX level \n " ) ;
fprintf ( f , " \t --oldxml10: use XML-1.0 parsing rules before the 5th edition \n " ) ;
2009-10-07 12:25:06 +04:00
# ifdef LIBXML_XPATH_ENABLED
2017-06-20 17:19:33 +03:00
fprintf ( f , " \t --xpath expr: evaluate the XPath expression, imply --noout \n " ) ;
2009-10-07 12:25:06 +04:00
# endif
2023-08-20 21:48:10 +03:00
fprintf ( f , " \t --max-ampl value: set maximum amplification factor \n " ) ;
2005-07-09 21:32:57 +04:00
2022-02-14 00:52:53 +03:00
fprintf ( f , " \n Libxml project home page: https://gitlab.gnome.org/GNOME/libxml2 \n " ) ;
2001-06-20 17:55:33 +04:00
}
2003-01-06 01:37:17 +03:00
2023-08-20 21:48:10 +03:00
static unsigned long
parseInteger ( const char * ctxt , const char * str ,
unsigned long min , unsigned long max ) {
char * strEnd ;
unsigned long val ;
errno = 0 ;
val = strtoul ( str , & strEnd , 10 ) ;
if ( errno = = EINVAL | | * strEnd ! = 0 ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s: invalid integer: %s \n " , ctxt , str ) ;
2023-08-20 21:48:10 +03:00
exit ( XMLLINT_ERR_UNCLASS ) ;
}
if ( errno ! = 0 | | val < min | | val > max ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " %s: integer out of range: %s \n " , ctxt , str ) ;
2023-08-20 21:48:10 +03:00
exit ( XMLLINT_ERR_UNCLASS ) ;
}
return ( val ) ;
}
2024-05-06 02:13:49 +03:00
static int
skipArgs ( const char * arg ) {
2024-05-07 17:53:43 +03:00
if ( ( ! strcmp ( arg , " -path " ) ) | |
( ! strcmp ( arg , " --path " ) ) | |
( ! strcmp ( arg , " -maxmem " ) ) | |
( ! strcmp ( arg , " --maxmem " ) ) | |
# ifdef LIBXML_OUTPUT_ENABLED
2024-05-06 02:13:49 +03:00
( ! strcmp ( arg , " -o " ) ) | |
( ! strcmp ( arg , " -output " ) ) | |
( ! strcmp ( arg , " --output " ) ) | |
2024-05-07 17:53:43 +03:00
( ! strcmp ( arg , " -encode " ) ) | |
( ! strcmp ( arg , " --encode " ) ) | |
( ! strcmp ( arg , " -pretty " ) ) | |
( ! strcmp ( arg , " --pretty " ) ) | |
# endif
2024-05-06 02:13:49 +03:00
# ifdef LIBXML_VALID_ENABLED
( ! strcmp ( arg , " -dtdvalid " ) ) | |
( ! strcmp ( arg , " --dtdvalid " ) ) | |
( ! strcmp ( arg , " -dtdvalidfpi " ) ) | |
( ! strcmp ( arg , " --dtdvalidfpi " ) ) | |
2024-05-07 17:53:43 +03:00
# endif
# ifdef LIBXML_SCHEMAS_ENABLED
2024-05-06 02:13:49 +03:00
( ! strcmp ( arg , " -relaxng " ) ) | |
( ! strcmp ( arg , " --relaxng " ) ) | |
( ! strcmp ( arg , " -schema " ) ) | |
( ! strcmp ( arg , " --schema " ) ) | |
2024-05-07 17:53:43 +03:00
# endif
# ifdef LIBXML_SCHEMATRON_ENABLED
2024-05-06 02:13:49 +03:00
( ! strcmp ( arg , " -schematron " ) ) | |
( ! strcmp ( arg , " --schematron " ) ) | |
2024-05-07 17:53:43 +03:00
# endif
2024-05-06 02:13:49 +03:00
# if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED)
( ! strcmp ( arg , " -pattern " ) ) | |
( ! strcmp ( arg , " --pattern " ) ) | |
# endif
# ifdef LIBXML_XPATH_ENABLED
( ! strcmp ( arg , " -xpath " ) ) | |
( ! strcmp ( arg , " --xpath " ) ) | |
# endif
( ! strcmp ( arg , " -max-ampl " ) ) | |
( ! strcmp ( arg , " --max-ampl " ) )
) {
return ( 1 ) ;
}
return ( 0 ) ;
}
2024-05-13 13:18:08 +03:00
static int
2024-06-11 19:14:43 +03:00
xmllintMain ( int argc , const char * * argv , xmlResourceLoader loader ) {
2003-01-03 19:19:51 +03:00
int i , acount ;
2000-04-05 22:38:42 +04:00
int files = 0 ;
2002-01-09 14:51:37 +03:00
int version = 0 ;
2024-05-07 17:53:43 +03:00
int nowrap = 0 ;
int sax = 0 ;
# ifdef LIBXML_READER_ENABLED
int stream = 0 ;
# endif
# ifdef LIBXML_CATALOG_ENABLED
int catalogs = 0 ;
int nocatalogs = 0 ;
# endif
2009-08-10 16:43:18 +04:00
2024-06-11 19:14:43 +03:00
defaultResourceLoader = loader ;
2024-05-13 13:18:08 +03:00
# ifdef XMLLINT_FUZZ
# ifdef LIBXML_DEBUG_ENABLED
shell = 0 ;
debugent = 0 ;
# endif
debug = 0 ;
maxmem = 0 ;
copy = 0 ;
noout = 0 ;
# ifdef LIBXML_OUTPUT_ENABLED
format = 0 ;
output = NULL ;
compress = 0 ;
# endif /* LIBXML_OUTPUT_ENABLED */
# ifdef LIBXML_VALID_ENABLED
postvalid = 0 ;
dtdvalid = NULL ;
dtdvalidfpi = NULL ;
insert = 0 ;
# endif
# ifdef LIBXML_SCHEMAS_ENABLED
relaxng = NULL ;
relaxngschemas = NULL ;
schema = NULL ;
wxschemas = NULL ;
# endif
# ifdef LIBXML_SCHEMATRON_ENABLED
schematron = NULL ;
wxschematron = NULL ;
# endif
repeat = 0 ;
# if defined(LIBXML_HTML_ENABLED)
html = 0 ;
xmlout = 0 ;
# endif
htmlout = 0 ;
# ifdef LIBXML_PUSH_ENABLED
push = 0 ;
pushsize = 4096 ;
# endif /* LIBXML_PUSH_ENABLED */
# ifdef HAVE_MMAP
memory = 0 ;
# endif
testIO = 0 ;
encoding = NULL ;
# ifdef LIBXML_XINCLUDE_ENABLED
xinclude = 0 ;
# endif
progresult = XMLLINT_RETURN_OK ;
quiet = 0 ;
timing = 0 ;
generate = 0 ;
dropdtd = 0 ;
# ifdef LIBXML_C14N_ENABLED
canonical = 0 ;
canonical_11 = 0 ;
exc_canonical = 0 ;
# endif
# ifdef LIBXML_READER_ENABLED
walker = 0 ;
# ifdef LIBXML_PATTERN_ENABLED
pattern = NULL ;
patternc = NULL ;
patstream = NULL ;
# endif
# endif /* LIBXML_READER_ENABLED */
# ifdef LIBXML_XPATH_ENABLED
xpathquery = NULL ;
# endif
options = XML_PARSE_COMPACT | XML_PARSE_BIG_LINES ;
maxAmpl = 0 ;
# endif /* XMLLINT_FUZZ */
2001-06-20 17:55:33 +04:00
if ( argc < = 1 ) {
2024-05-06 01:33:19 +03:00
usage ( ERR_STREAM , argv [ 0 ] ) ;
2022-01-31 16:45:09 +03:00
return ( XMLLINT_ERR_UNCLASS ) ;
2001-06-20 17:55:33 +04:00
}
2022-01-16 20:39:51 +03:00
/* xmlMemSetup must be called before initializing the parser. */
for ( i = 1 ; i < argc ; i + + ) {
if ( ( ! strcmp ( argv [ i ] , " -maxmem " ) ) | |
( ! strcmp ( argv [ i ] , " --maxmem " ) ) ) {
2023-04-20 17:22:11 +03:00
i + + ;
if ( i > = argc ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " maxmem: missing integer value \n " ) ;
2023-04-20 17:22:11 +03:00
return ( XMLLINT_ERR_UNCLASS ) ;
}
errno = 0 ;
2023-08-20 21:48:10 +03:00
maxmem = parseInteger ( " maxmem " , argv [ i ] , 0 , INT_MAX ) ;
2024-05-06 02:13:49 +03:00
} else if ( argv [ i ] [ 0 ] = = ' - ' ) {
i + = skipArgs ( argv [ i ] ) ;
}
2022-01-16 20:39:51 +03:00
}
2022-02-01 18:21:10 +03:00
if ( maxmem ! = 0 )
xmlMemSetup ( myFreeFunc , myMallocFunc , myReallocFunc , myStrdupFunc ) ;
2022-01-16 20:39:51 +03:00
2000-06-29 03:40:59 +04:00
LIBXML_TEST_VERSION
2022-01-16 20:39:51 +03:00
2000-04-05 22:38:42 +04:00
for ( i = 1 ; i < argc ; i + + ) {
2022-02-07 22:54:33 +03:00
if ( argv [ i ] [ 0 ] ! = ' - ' | | argv [ i ] [ 1 ] = = 0 )
2001-06-20 17:55:33 +04:00
continue ;
2022-02-04 16:13:59 +03:00
2000-04-05 22:38:42 +04:00
if ( ( ! strcmp ( argv [ i ] , " -debug " ) ) | | ( ! strcmp ( argv [ i ] , " --debug " ) ) )
debug + + ;
2003-01-07 14:17:25 +03:00
else
# ifdef LIBXML_DEBUG_ENABLED
if ( ( ! strcmp ( argv [ i ] , " -shell " ) ) | |
2000-04-05 22:38:42 +04:00
( ! strcmp ( argv [ i ] , " --shell " ) ) ) {
shell + + ;
noout = 1 ;
2009-08-10 16:43:18 +04:00
} else
2000-04-05 22:38:42 +04:00
# endif
if ( ( ! strcmp ( argv [ i ] , " -copy " ) ) | | ( ! strcmp ( argv [ i ] , " --copy " ) ) )
copy + + ;
2003-09-29 22:02:38 +04:00
else
if ( ( ! strcmp ( argv [ i ] , " -recover " ) ) | |
2003-09-24 01:50:54 +04:00
( ! strcmp ( argv [ i ] , " --recover " ) ) ) {
options | = XML_PARSE_RECOVER ;
2008-08-26 17:05:34 +04:00
} else if ( ( ! strcmp ( argv [ i ] , " -huge " ) ) | |
( ! strcmp ( argv [ i ] , " --huge " ) ) ) {
options | = XML_PARSE_HUGE ;
2003-09-24 01:50:54 +04:00
} else if ( ( ! strcmp ( argv [ i ] , " -noent " ) ) | |
( ! strcmp ( argv [ i ] , " --noent " ) ) ) {
2024-05-07 17:53:43 +03:00
options | = XML_PARSE_NOENT ;
2011-05-16 12:03:50 +04:00
} else if ( ( ! strcmp ( argv [ i ] , " -noenc " ) ) | |
( ! strcmp ( argv [ i ] , " --noenc " ) ) ) {
options | = XML_PARSE_IGNORE_ENC ;
2003-09-26 17:53:14 +04:00
} else if ( ( ! strcmp ( argv [ i ] , " -nsclean " ) ) | |
( ! strcmp ( argv [ i ] , " --nsclean " ) ) ) {
options | = XML_PARSE_NSCLEAN ;
} else if ( ( ! strcmp ( argv [ i ] , " -nocdata " ) ) | |
( ! strcmp ( argv [ i ] , " --nocdata " ) ) ) {
options | = XML_PARSE_NOCDATA ;
2003-09-25 01:23:56 +04:00
} else if ( ( ! strcmp ( argv [ i ] , " -nodict " ) ) | |
( ! strcmp ( argv [ i ] , " --nodict " ) ) ) {
options | = XML_PARSE_NODICT ;
2003-09-24 01:50:54 +04:00
} else if ( ( ! strcmp ( argv [ i ] , " -version " ) ) | |
2002-01-09 14:51:37 +03:00
( ! strcmp ( argv [ i ] , " --version " ) ) ) {
2002-09-18 03:04:40 +04:00
showVersion ( argv [ 0 ] ) ;
2002-01-09 14:51:37 +03:00
version = 1 ;
} else if ( ( ! strcmp ( argv [ i ] , " -noout " ) ) | |
2000-04-05 22:38:42 +04:00
( ! strcmp ( argv [ i ] , " --noout " ) ) )
noout + + ;
else if ( ( ! strcmp ( argv [ i ] , " -htmlout " ) ) | |
( ! strcmp ( argv [ i ] , " --htmlout " ) ) )
htmlout + + ;
2003-09-29 17:20:24 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -nowrap " ) ) | |
( ! strcmp ( argv [ i ] , " --nowrap " ) ) )
nowrap + + ;
2000-04-05 22:38:42 +04:00
# ifdef LIBXML_HTML_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -html " ) ) | |
( ! strcmp ( argv [ i ] , " --html " ) ) ) {
html + + ;
}
2003-11-04 11:47:48 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -xmlout " ) ) | |
( ! strcmp ( argv [ i ] , " --xmlout " ) ) ) {
xmlout + + ;
2010-07-26 16:02:42 +04:00
} else if ( ( ! strcmp ( argv [ i ] , " -nodefdtd " ) ) | |
( ! strcmp ( argv [ i ] , " --nodefdtd " ) ) ) {
options | = HTML_PARSE_NODEFDTD ;
2003-11-04 11:47:48 +03:00
}
2000-04-05 22:38:42 +04:00
# endif /* LIBXML_HTML_ENABLED */
2001-06-20 17:55:33 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -loaddtd " ) ) | |
2003-09-24 01:50:54 +04:00
( ! strcmp ( argv [ i ] , " --loaddtd " ) ) ) {
options | = XML_PARSE_DTDLOAD ;
} else if ( ( ! strcmp ( argv [ i ] , " -dtdattr " ) ) | |
2001-08-07 05:10:10 +04:00
( ! strcmp ( argv [ i ] , " --dtdattr " ) ) ) {
2003-09-24 01:50:54 +04:00
options | = XML_PARSE_DTDATTR ;
2003-09-28 22:58:27 +04:00
}
# ifdef LIBXML_VALID_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -valid " ) ) | |
2003-09-24 01:50:54 +04:00
( ! strcmp ( argv [ i ] , " --valid " ) ) ) {
options | = XML_PARSE_DTDVALID ;
} else if ( ( ! strcmp ( argv [ i ] , " -postvalid " ) ) | |
2001-06-20 17:55:33 +04:00
( ! strcmp ( argv [ i ] , " --postvalid " ) ) ) {
2000-04-05 22:38:42 +04:00
postvalid + + ;
2003-12-09 16:54:39 +03:00
options | = XML_PARSE_DTDLOAD ;
2001-06-20 17:55:33 +04:00
} else if ( ( ! strcmp ( argv [ i ] , " -dtdvalid " ) ) | |
2000-10-11 19:57:05 +04:00
( ! strcmp ( argv [ i ] , " --dtdvalid " ) ) ) {
i + + ;
dtdvalid = argv [ i ] ;
2003-12-09 16:54:39 +03:00
options | = XML_PARSE_DTDLOAD ;
2003-08-18 20:39:51 +04:00
} else if ( ( ! strcmp ( argv [ i ] , " -dtdvalidfpi " ) ) | |
( ! strcmp ( argv [ i ] , " --dtdvalidfpi " ) ) ) {
i + + ;
dtdvalidfpi = argv [ i ] ;
2003-12-09 16:54:39 +03:00
options | = XML_PARSE_DTDLOAD ;
2000-10-11 19:57:05 +04:00
}
2024-05-07 17:53:43 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -insert " ) ) | |
( ! strcmp ( argv [ i ] , " --insert " ) ) )
insert + + ;
2003-09-28 22:58:27 +04:00
# endif /* LIBXML_VALID_ENABLED */
2001-12-14 01:21:58 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -dropdtd " ) ) | |
( ! strcmp ( argv [ i ] , " --dropdtd " ) ) )
dropdtd + + ;
2021-02-03 01:27:52 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -quiet " ) ) | |
( ! strcmp ( argv [ i ] , " --quiet " ) ) )
quiet + + ;
2001-02-25 19:11:03 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -timing " ) ) | |
( ! strcmp ( argv [ i ] , " --timing " ) ) )
timing + + ;
2001-04-11 11:50:02 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -auto " ) ) | |
( ! strcmp ( argv [ i ] , " --auto " ) ) )
generate + + ;
2000-04-05 22:38:42 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -repeat " ) ) | |
2003-09-17 23:36:25 +04:00
( ! strcmp ( argv [ i ] , " --repeat " ) ) ) {
if ( repeat )
repeat * = 10 ;
else
repeat = 100 ;
2003-09-30 16:36:01 +04:00
}
# ifdef LIBXML_PUSH_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -push " ) ) | |
2000-04-05 22:38:42 +04:00
( ! strcmp ( argv [ i ] , " --push " ) ) )
push + + ;
2012-10-25 11:37:50 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -pushsmall " ) ) | |
( ! strcmp ( argv [ i ] , " --pushsmall " ) ) ) {
push + + ;
pushsize = 10 ;
}
2003-09-30 16:36:01 +04:00
# endif /* LIBXML_PUSH_ENABLED */
Various "make distcheck" and portability fixups
Makefile.am:
* Don't use @VAR@, use $(VAR). Autoconf's AC_SUBST provides us the Make
variable, it allows overriding the value at the command line, and
(notably) it avoids a Make parse error in the libxml2_la_LDFLAGS
assignment when @MODULE_PLATFORM_LIBS@ is empty
* Changed how the THREADS_W32 mechanism switches the build between
testThreads.c and testThreadsWin32.c as appropriate; using AM_CONDITIONAL
allows this to work cleanly and plays well with dependencies
* testapi.c should be specified as BUILT_SOURCES
* Create symlinks to the test/ and result/ subdirs so that the runtests
target is usable in out-of-source-tree builds
* Don't do MAKEFLAGS+=--silent as this is not portable to non-GNU Makes
* Fixed incorrect find(1) syntax in the "cleanup" rule, and doing "rm -f"
instead of just "rm" is good form
* (DIST)CLEANFILES needed a bit more coverage to allow "make distcheck" to
pass
configure.in:
* Need AC_PROG_LN_S to create test/ and result/ symlinks in Makefile.am
* AC_LIBTOOL_WIN32_DLL and AM_PROG_LIBTOOL are obsolete; these have been
superceded by LT_INIT
* Don't rebuild docs by default, as this requires GNU Make (as
implemented)
* Check for uint32_t as some platforms don't provide it
* Check for some more functions, and undefine HAVE_MMAP if we don't also
HAVE_MUNMAP (one system I tested on actually needed this)
* Changed THREADS_W32 from a filename insert into an Automake conditional
* The "Copyright" file will not be in the current directory if builddir !=
srcdir
doc/Makefile.am:
* EXTRA_DIST cannot use wildcards when they refer to generated files; this
breaks dependencies. What I did was define EXTRA_DIST_wc, which uses GNU
Make $(wildcard) directives to build up a list of files, and EXTRA_DIST,
as a literal expansion of EXTRA_DIST_wc. I also added a new rule,
"check-extra-dist", to simplify checking that the two variables are
equivalent. (Note that this works only when builddir == srcdir)
(I can implement this differently if desired; this is just one way of
doing it)
* Don't define an "all" target; this steps on Automake's toes
* Fixed up the "libxml2-api.xml ..." rule by using $(wildcard) for
dependencies (as Make doesn't process the wildcards otherwise) and
qualifying appropriate files with $(srcdir)
(Note that $(srcdir) is not needed in the dependencies, thanks to VPATH,
which we can count on as this is GNU-Make-only code anyway)
doc/devhelp/Makefile.am:
* Qualified appropriate files with $(srcdir)
* Added an "uninstall-local" rule so that "make distcheck" passes
doc/examples/Makefile.am:
* Rather than use a wildcard that doesn't work, use a substitution that
most Make programs can handle
doc/examples/index.py:
* Do the same here
include/libxml/nanoftp.h:
* Some platforms (e.g. MSVC 6) already #define INVALID_SOCKET:
user@host:/cygdrive/c/Program Files/Microsoft Visual Studio/VC98/\
Include$ grep -R INVALID_SOCKET .
./WINSOCK.H:#define INVALID_SOCKET (SOCKET)(~0)
./WINSOCK2.H:#define INVALID_SOCKET (SOCKET)(~0)
include/libxml/xmlversion.h.in:
* Support ancient GCCs (I was actually able to build the library with 2.5
but for this bit)
python/Makefile.am:
* Expanded CLEANFILES to allow "make distcheck" to pass
python/tests/Makefile.am:
* Define CLEANFILES instead of a "clean" rule, and added tmp.xml to allow
"make distcheck" to pass
testRelax.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H (as some
systems have the header but not the function)
testSchemas.c:
* Use HAVE_MMAP instead of the less explicit HAVE_SYS_MMAN_H
testapi.c:
* Don't use putenv() if it's not available
threads.c:
* This fixes the following build error on Solaris 8:
libtool: compile: cc -DHAVE_CONFIG_H -I. -I./include -I./include \
-D_REENTRANT -D__EXTENSIONS__ -D_REENTRANT -Dsparc -Xa -mt -v \
-xarch=v9 -xcrossfile -xO5 -c threads.c -KPIC -DPIC -o threads.o
"threads.c", line 442: controlling expressions must have scalar type
"threads.c", line 512: controlling expressions must have scalar type
cc: acomp failed for threads.c
*** Error code 1
trio.c:
* Define isascii() if the system doesn't provide it
trio.h:
* The trio library's HAVE_CONFIG_H header is not the same as LibXML2's
HAVE_CONFIG_H header; this change is needed to avoid a double-inclusion
win32/configure.js:
* Added support for the LZMA compression option
win32/Makefile.{bcb,mingw,msvc}:
* Added appropriate bits to support WITH_LZMA=1
* Install the header files under $(INCPREFIX)\libxml2\libxml instead of
$(INCPREFIX)\libxml, to mirror the install location on Unix+Autotools
xml2-config.in:
* @MODULE_PLATFORM_LIBS@ (usually "-ldl") needs to be in there in order for
`xml2-config --libs` to provide a complete set of dependencies
xmllint.c:
* Use HAVE_MMAP instead of the less-explicit HAVE_SYS_MMAN_H
2012-08-06 07:32:54 +04:00
# ifdef HAVE_MMAP
2000-07-22 00:32:03 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -memory " ) ) | |
( ! strcmp ( argv [ i ] , " --memory " ) ) )
memory + + ;
# endif
2000-04-12 17:27:38 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -testIO " ) ) | |
( ! strcmp ( argv [ i ] , " --testIO " ) ) )
testIO + + ;
2000-11-06 19:43:11 +03:00
# ifdef LIBXML_XINCLUDE_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -xinclude " ) ) | |
2003-09-24 01:50:54 +04:00
( ! strcmp ( argv [ i ] , " --xinclude " ) ) ) {
2000-11-06 19:43:11 +03:00
xinclude + + ;
2003-11-03 15:31:38 +03:00
options | = XML_PARSE_XINCLUDE ;
2003-09-24 01:50:54 +04:00
}
2004-08-16 16:34:50 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -noxincludenode " ) ) | |
( ! strcmp ( argv [ i ] , " --noxincludenode " ) ) ) {
xinclude + + ;
options | = XML_PARSE_XINCLUDE ;
options | = XML_PARSE_NOXINCNODE ;
}
2008-08-26 11:26:55 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -nofixup-base-uris " ) ) | |
( ! strcmp ( argv [ i ] , " --nofixup-base-uris " ) ) ) {
xinclude + + ;
options | = XML_PARSE_XINCLUDE ;
options | = XML_PARSE_NOBASEFIX ;
}
2000-11-06 19:43:11 +03:00
# endif
2000-04-05 22:38:42 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -nowarning " ) ) | |
( ! strcmp ( argv [ i ] , " --nowarning " ) ) ) {
2003-09-24 01:50:54 +04:00
options | = XML_PARSE_NOWARNING ;
2022-08-24 16:51:28 +03:00
options & = ~ XML_PARSE_PEDANTIC ;
2000-08-27 01:40:43 +04:00
}
else if ( ( ! strcmp ( argv [ i ] , " -pedantic " ) ) | |
( ! strcmp ( argv [ i ] , " --pedantic " ) ) ) {
2003-09-24 01:50:54 +04:00
options | = XML_PARSE_PEDANTIC ;
2024-05-08 04:04:15 +03:00
options & = ~ XML_PARSE_NOWARNING ;
2000-04-05 22:38:42 +04:00
}
2000-09-22 20:07:02 +04:00
# ifdef LIBXML_DEBUG_ENABLED
2000-08-27 01:40:43 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -debugent " ) ) | |
( ! strcmp ( argv [ i ] , " --debugent " ) ) ) {
debugent + + ;
2009-08-10 16:43:18 +04:00
}
2001-05-22 19:08:55 +04:00
# endif
2004-08-15 02:37:54 +04:00
# ifdef LIBXML_C14N_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -c14n " ) ) | |
( ! strcmp ( argv [ i ] , " --c14n " ) ) ) {
canonical + + ;
options | = XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD ;
2009-08-10 16:43:18 +04:00
}
2009-07-09 12:26:22 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -c14n11 " ) ) | |
( ! strcmp ( argv [ i ] , " --c14n11 " ) ) ) {
canonical_11 + + ;
options | = XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD ;
2009-08-10 16:43:18 +04:00
}
2005-06-06 21:16:50 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -exc-c14n " ) ) | |
( ! strcmp ( argv [ i ] , " --exc-c14n " ) ) ) {
exc_canonical + + ;
options | = XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_DTDLOAD ;
2009-08-10 16:43:18 +04:00
}
2004-08-15 02:37:54 +04:00
# endif
2001-05-22 19:08:55 +04:00
# ifdef LIBXML_CATALOG_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -catalogs " ) ) | |
( ! strcmp ( argv [ i ] , " --catalogs " ) ) ) {
2001-08-22 04:06:49 +04:00
catalogs + + ;
} else if ( ( ! strcmp ( argv [ i ] , " -nocatalogs " ) ) | |
( ! strcmp ( argv [ i ] , " --nocatalogs " ) ) ) {
nocatalogs + + ;
2009-08-10 16:43:18 +04:00
}
2000-09-22 20:07:02 +04:00
# endif
2000-04-05 22:38:42 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -noblanks " ) ) | |
( ! strcmp ( argv [ i ] , " --noblanks " ) ) ) {
2024-05-07 17:53:43 +03:00
options | = XML_PARSE_NOBLANKS ;
2001-08-14 18:12:47 +04:00
}
2004-05-04 02:54:49 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -maxmem " ) ) | |
( ! strcmp ( argv [ i ] , " --maxmem " ) ) ) {
i + + ;
}
2024-05-07 17:53:43 +03:00
# ifdef LIBXML_OUTPUT_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -o " ) ) | |
( ! strcmp ( argv [ i ] , " -output " ) ) | |
( ! strcmp ( argv [ i ] , " --output " ) ) ) {
i + + ;
output = argv [ i ] ;
}
2001-08-14 18:12:47 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -format " ) ) | |
( ! strcmp ( argv [ i ] , " --format " ) ) ) {
2022-08-24 16:51:28 +03:00
format = 1 ;
2024-05-07 17:53:43 +03:00
options | = XML_PARSE_NOBLANKS ;
2003-01-03 19:19:51 +03:00
}
2024-05-07 17:53:43 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -encode " ) ) | |
( ! strcmp ( argv [ i ] , " --encode " ) ) ) {
i + + ;
encoding = argv [ i ] ;
/*
* OK it ' s for testing purposes
*/
xmlAddEncodingAlias ( " UTF-8 " , " DVEnc " ) ;
}
2010-11-03 17:33:40 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -pretty " ) ) | |
( ! strcmp ( argv [ i ] , " --pretty " ) ) ) {
2022-08-24 16:51:28 +03:00
i + + ;
if ( argv [ i ] ! = NULL )
format = atoi ( argv [ i ] ) ;
2010-11-03 17:33:40 +03:00
}
2024-05-07 17:53:43 +03:00
# ifdef LIBXML_ZLIB_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -compress " ) ) | |
( ! strcmp ( argv [ i ] , " --compress " ) ) ) {
compress + + ;
}
# endif
# endif /* LIBXML_OUTPUT_ENABLED */
2003-09-30 04:43:48 +04:00
# ifdef LIBXML_READER_ENABLED
2003-01-03 19:19:51 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -stream " ) ) | |
( ! strcmp ( argv [ i ] , " --stream " ) ) ) {
stream + + ;
2003-01-06 01:37:17 +03:00
}
2003-11-03 15:31:38 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -walker " ) ) | |
( ! strcmp ( argv [ i ] , " --walker " ) ) ) {
walker + + ;
noout + + ;
2024-05-07 17:53:43 +03:00
}
2019-05-16 22:06:56 +03:00
# ifdef LIBXML_PATTERN_ENABLED
2024-05-07 17:53:43 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -pattern " ) ) | |
2019-05-16 22:06:56 +03:00
( ! strcmp ( argv [ i ] , " --pattern " ) ) ) {
i + + ;
pattern = argv [ i ] ;
2003-11-03 15:31:38 +03:00
}
2024-05-07 17:53:43 +03:00
# endif
2003-09-30 04:43:48 +04:00
# endif /* LIBXML_READER_ENABLED */
# ifdef LIBXML_SAX1_ENABLED
2003-09-10 14:51:05 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -sax1 " ) ) | |
( ! strcmp ( argv [ i ] , " --sax1 " ) ) ) {
2009-07-29 13:34:50 +04:00
options | = XML_PARSE_SAX1 ;
2003-09-10 14:51:05 +04:00
}
2003-09-30 04:43:48 +04:00
# endif /* LIBXML_SAX1_ENABLED */
2005-07-08 21:27:33 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -sax " ) ) | |
( ! strcmp ( argv [ i ] , " --sax " ) ) ) {
2009-07-29 13:34:50 +04:00
sax + + ;
2024-05-07 17:53:43 +03:00
}
2003-02-05 16:19:53 +03:00
# ifdef LIBXML_SCHEMAS_ENABLED
2024-05-07 17:53:43 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -relaxng " ) ) | |
2003-02-05 16:19:53 +03:00
( ! strcmp ( argv [ i ] , " --relaxng " ) ) ) {
i + + ;
relaxng = argv [ i ] ;
2024-05-07 17:53:43 +03:00
options | = XML_PARSE_NOENT ;
2003-05-12 19:25:56 +04:00
} else if ( ( ! strcmp ( argv [ i ] , " -schema " ) ) | |
( ! strcmp ( argv [ i ] , " --schema " ) ) ) {
i + + ;
schema = argv [ i ] ;
2024-05-07 17:53:43 +03:00
options | = XML_PARSE_NOENT ;
}
2005-07-24 18:27:16 +04:00
# endif
# ifdef LIBXML_SCHEMATRON_ENABLED
2024-05-07 17:53:43 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -schematron " ) ) | |
2005-07-24 18:27:16 +04:00
( ! strcmp ( argv [ i ] , " --schematron " ) ) ) {
i + + ;
schematron = argv [ i ] ;
2024-05-07 17:53:43 +03:00
options | = XML_PARSE_NOENT ;
}
2003-02-05 16:19:53 +03:00
# endif
2024-05-07 17:53:43 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -nonet " ) ) | |
2003-05-14 02:14:13 +04:00
( ! strcmp ( argv [ i ] , " --nonet " ) ) ) {
2003-11-03 17:28:31 +03:00
options | = XML_PARSE_NONET ;
2005-08-25 17:19:21 +04:00
} else if ( ( ! strcmp ( argv [ i ] , " -nocompact " ) ) | |
( ! strcmp ( argv [ i ] , " --nocompact " ) ) ) {
options & = ~ XML_PARSE_COMPACT ;
2004-08-31 13:37:03 +04:00
} else if ( ( ! strcmp ( argv [ i ] , " -load-trace " ) ) | |
( ! strcmp ( argv [ i ] , " --load-trace " ) ) ) {
load_trace + + ;
} else if ( ( ! strcmp ( argv [ i ] , " -path " ) ) | |
( ! strcmp ( argv [ i ] , " --path " ) ) ) {
i + + ;
parsePath ( BAD_CAST argv [ i ] ) ;
2024-05-07 17:53:43 +03:00
}
2009-10-07 12:25:06 +04:00
# ifdef LIBXML_XPATH_ENABLED
2024-05-07 17:53:43 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -xpath " ) ) | |
2009-10-07 12:25:06 +04:00
( ! strcmp ( argv [ i ] , " --xpath " ) ) ) {
i + + ;
noout + + ;
xpathquery = argv [ i ] ;
2024-05-07 17:53:43 +03:00
}
2003-12-03 01:32:15 +03:00
# endif
2024-05-07 17:53:43 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -oldxml10 " ) ) | |
2008-07-29 20:12:31 +04:00
( ! strcmp ( argv [ i ] , " --oldxml10 " ) ) ) {
options | = XML_PARSE_OLD10 ;
2023-08-20 21:48:10 +03:00
} else if ( ( ! strcmp ( argv [ i ] , " -max-ampl " ) ) | |
( ! strcmp ( argv [ i ] , " --max-ampl " ) ) ) {
i + + ;
if ( i > = argc ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " max-ampl: missing integer value \n " ) ;
2023-08-20 21:48:10 +03:00
return ( XMLLINT_ERR_UNCLASS ) ;
}
maxAmpl = parseInteger ( " max-ampl " , argv [ i ] , 1 , UINT_MAX ) ;
2001-06-20 17:55:33 +04:00
} else {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Unknown option %s \n " , argv [ i ] ) ;
usage ( ERR_STREAM , argv [ 0 ] ) ;
2022-01-31 16:45:09 +03:00
return ( XMLLINT_ERR_UNCLASS ) ;
2001-06-20 17:55:33 +04:00
}
2000-04-05 22:38:42 +04:00
}
2001-08-22 04:06:49 +04:00
# ifdef LIBXML_CATALOG_ENABLED
if ( nocatalogs = = 0 ) {
if ( catalogs ) {
const char * catal ;
catal = getenv ( " SGML_CATALOG_FILES " ) ;
2001-08-25 17:33:14 +04:00
if ( catal ! = NULL ) {
xmlLoadCatalogs ( catal ) ;
} else {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " Variable $SGML_CATALOG_FILES not set \n " ) ;
2001-08-25 17:33:14 +04:00
}
2001-08-22 04:06:49 +04:00
}
}
# endif
2003-01-06 01:37:17 +03:00
2023-09-20 18:54:48 +03:00
# ifdef LIBXML_OUTPUT_ENABLED
{
const char * indent = getenv ( " XMLLINT_INDENT " ) ;
if ( indent ! = NULL ) {
xmlTreeIndentString = indent ;
}
2003-03-10 01:36:52 +03:00
}
2023-09-20 18:54:48 +03:00
# endif
2003-01-06 01:37:17 +03:00
2000-04-05 22:38:42 +04:00
if ( ( htmlout ) & & ( ! nowrap ) ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2000-04-05 22:38:42 +04:00
" <!DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.0 Transitional//EN \" \n " ) ;
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2000-10-25 23:56:55 +04:00
" \t \" http://www.w3.org/TR/REC-html40/loose.dtd \" > \n " ) ;
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2000-04-05 22:38:42 +04:00
" <html><head><title>%s output</title></head> \n " ,
argv [ 0 ] ) ;
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2000-04-05 22:38:42 +04:00
" <body bgcolor= \" #ffffff \" ><h1 align= \" center \" >%s output</h1> \n " ,
argv [ 0 ] ) ;
}
2003-02-05 16:19:53 +03:00
2005-07-24 18:27:16 +04:00
# ifdef LIBXML_SCHEMATRON_ENABLED
if ( ( schematron ! = NULL ) & & ( sax = = 0 )
# ifdef LIBXML_READER_ENABLED
& & ( stream = = 0 )
# endif /* LIBXML_READER_ENABLED */
) {
xmlSchematronParserCtxtPtr ctxt ;
/* forces loading the DTDs */
options | = XML_PARSE_DTDLOAD ;
if ( timing ) {
startTimer ( ) ;
}
ctxt = xmlSchematronNewParserCtxt ( schematron ) ;
2022-02-01 17:56:21 +03:00
if ( ctxt = = NULL ) {
progresult = XMLLINT_ERR_MEM ;
goto error ;
}
2005-07-24 18:27:16 +04:00
wxschematron = xmlSchematronParse ( ctxt ) ;
if ( wxschematron = = NULL ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2005-07-24 18:27:16 +04:00
" Schematron schema %s failed to compile \n " , schematron ) ;
progresult = XMLLINT_ERR_SCHEMACOMP ;
schematron = NULL ;
}
xmlSchematronFreeParserCtxt ( ctxt ) ;
if ( timing ) {
endTimer ( " Compiling the schemas " ) ;
}
}
# endif
2003-02-05 16:19:53 +03:00
# ifdef LIBXML_SCHEMAS_ENABLED
2005-07-08 21:27:33 +04:00
if ( ( relaxng ! = NULL ) & & ( sax = = 0 )
2003-09-30 04:43:48 +04:00
# ifdef LIBXML_READER_ENABLED
& & ( stream = = 0 )
# endif /* LIBXML_READER_ENABLED */
) {
2003-02-05 16:19:53 +03:00
xmlRelaxNGParserCtxtPtr ctxt ;
2003-04-16 19:58:05 +04:00
/* forces loading the DTDs */
2003-09-24 01:50:54 +04:00
options | = XML_PARSE_DTDLOAD ;
2003-03-07 21:32:59 +03:00
if ( timing ) {
startTimer ( ) ;
}
2003-02-05 16:19:53 +03:00
ctxt = xmlRelaxNGNewParserCtxt ( relaxng ) ;
2022-02-01 17:56:21 +03:00
if ( ctxt = = NULL ) {
progresult = XMLLINT_ERR_MEM ;
goto error ;
}
2024-06-11 19:14:43 +03:00
xmlRelaxNGSetResourceLoader ( ctxt , xmllintResourceLoader , NULL ) ;
2003-02-05 16:19:53 +03:00
relaxngschemas = xmlRelaxNGParse ( ctxt ) ;
2003-04-16 19:58:05 +04:00
if ( relaxngschemas = = NULL ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2003-04-16 19:58:05 +04:00
" Relax-NG schema %s failed to compile \n " , relaxng ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_SCHEMACOMP ;
2003-04-16 19:58:05 +04:00
relaxng = NULL ;
}
2003-02-05 16:19:53 +03:00
xmlRelaxNGFreeParserCtxt ( ctxt ) ;
2003-03-07 21:32:59 +03:00
if ( timing ) {
endTimer ( " Compiling the schemas " ) ;
}
2004-03-25 12:35:49 +03:00
} else if ( ( schema ! = NULL )
# ifdef LIBXML_READER_ENABLED
2005-07-10 23:03:16 +04:00
& & ( stream = = 0 )
2004-03-25 12:35:49 +03:00
# endif
) {
2003-05-12 19:25:56 +04:00
xmlSchemaParserCtxtPtr ctxt ;
if ( timing ) {
startTimer ( ) ;
}
ctxt = xmlSchemaNewParserCtxt ( schema ) ;
2022-02-01 17:56:21 +03:00
if ( ctxt = = NULL ) {
progresult = XMLLINT_ERR_MEM ;
goto error ;
}
2024-06-11 19:14:43 +03:00
xmlSchemaSetResourceLoader ( ctxt , xmllintResourceLoader , NULL ) ;
2003-05-12 19:25:56 +04:00
wxschemas = xmlSchemaParse ( ctxt ) ;
if ( wxschemas = = NULL ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2003-05-12 19:25:56 +04:00
" WXS schema %s failed to compile \n " , schema ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_SCHEMACOMP ;
2003-05-12 19:25:56 +04:00
schema = NULL ;
}
xmlSchemaFreeParserCtxt ( ctxt ) ;
if ( timing ) {
endTimer ( " Compiling the schemas " ) ;
}
2003-02-05 16:19:53 +03:00
}
2003-12-03 01:32:15 +03:00
# endif /* LIBXML_SCHEMAS_ENABLED */
2019-05-16 22:06:56 +03:00
# if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED)
if ( ( pattern ! = NULL ) & & ( walker = = 0 ) ) {
2003-12-05 19:10:21 +03:00
patternc = xmlPatterncompile ( ( const xmlChar * ) pattern , NULL , 0 , NULL ) ;
2003-12-03 01:32:15 +03:00
if ( patternc = = NULL ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM ,
2003-12-03 01:32:15 +03:00
" Pattern %s failed to compile \n " , pattern ) ;
2004-06-08 17:29:32 +04:00
progresult = XMLLINT_ERR_SCHEMAPAT ;
2003-12-03 01:32:15 +03:00
pattern = NULL ;
}
}
2019-05-16 22:06:56 +03:00
# endif /* LIBXML_READER_ENABLED && LIBXML_PATTERN_ENABLED */
2000-04-05 22:38:42 +04:00
for ( i = 1 ; i < argc ; i + + ) {
2024-05-06 02:13:49 +03:00
if ( ( argv [ i ] [ 0 ] = = ' - ' ) & & ( strcmp ( argv [ i ] , " - " ) ! = 0 ) ) {
i + = skipArgs ( argv [ i ] ) ;
continue ;
2023-08-20 21:48:10 +03:00
}
2001-02-25 19:11:03 +03:00
if ( ( timing ) & & ( repeat ) )
2001-12-18 10:09:59 +03:00
startTimer ( ) ;
2024-05-06 02:13:49 +03:00
if ( repeat ) {
xmlParserCtxtPtr ctxt ;
2023-08-20 21:48:10 +03:00
2024-05-06 02:13:49 +03:00
ctxt = xmlNewParserCtxt ( ) ;
if ( ctxt = = NULL ) {
progresult = XMLLINT_ERR_MEM ;
goto error ;
}
2024-06-11 19:14:43 +03:00
xmlCtxtSetResourceLoader ( ctxt , xmllintResourceLoader , NULL ) ;
2024-05-06 02:13:49 +03:00
if ( maxAmpl > 0 )
xmlCtxtSetMaxAmplification ( ctxt , maxAmpl ) ;
2003-09-25 01:23:56 +04:00
2024-05-06 02:13:49 +03:00
for ( acount = 0 ; acount < repeat ; acount + + ) {
2003-09-30 04:43:48 +04:00
# ifdef LIBXML_READER_ENABLED
2024-05-06 02:13:49 +03:00
if ( stream ! = 0 ) {
streamFile ( argv [ i ] ) ;
} else {
2003-09-30 04:43:48 +04:00
# endif /* LIBXML_READER_ENABLED */
2024-05-06 02:13:49 +03:00
if ( sax ) {
testSAX ( argv [ i ] ) ;
} else {
parseAndPrintFile ( argv [ i ] , ctxt ) ;
}
2003-09-30 04:43:48 +04:00
# ifdef LIBXML_READER_ENABLED
2024-05-06 02:13:49 +03:00
}
2003-09-30 04:43:48 +04:00
# endif /* LIBXML_READER_ENABLED */
2024-05-06 02:13:49 +03:00
}
2023-08-20 21:48:10 +03:00
2024-05-06 02:13:49 +03:00
xmlFreeParserCtxt ( ctxt ) ;
} else {
2003-09-30 04:43:48 +04:00
# ifdef LIBXML_READER_ENABLED
2024-05-06 02:13:49 +03:00
if ( stream ! = 0 )
streamFile ( argv [ i ] ) ;
else
2003-09-30 04:43:48 +04:00
# endif /* LIBXML_READER_ENABLED */
2024-05-06 02:13:49 +03:00
if ( sax ) {
testSAX ( argv [ i ] ) ;
} else {
parseAndPrintFile ( argv [ i ] , NULL ) ;
}
}
files + + ;
if ( ( timing ) & & ( repeat ) ) {
endTimer ( " %d iterations " , repeat ) ;
}
2000-04-05 22:38:42 +04:00
}
2009-08-10 16:43:18 +04:00
if ( generate )
2003-09-25 01:23:56 +04:00
parseAndPrintFile ( NULL , NULL ) ;
2000-04-05 22:38:42 +04:00
if ( ( htmlout ) & & ( ! nowrap ) ) {
2024-05-06 01:33:19 +03:00
fprintf ( ERR_STREAM , " </body></html> \n " ) ;
2000-04-05 22:38:42 +04:00
}
2002-01-09 14:51:37 +03:00
if ( ( files = = 0 ) & & ( ! generate ) & & ( version = = 0 ) ) {
2024-05-06 01:33:19 +03:00
usage ( ERR_STREAM , argv [ 0 ] ) ;
2022-01-31 16:45:09 +03:00
progresult = XMLLINT_ERR_UNCLASS ;
2000-04-05 22:38:42 +04:00
}
2005-07-24 18:27:16 +04:00
# ifdef LIBXML_SCHEMATRON_ENABLED
if ( wxschematron ! = NULL )
xmlSchematronFree ( wxschematron ) ;
# endif
2003-02-05 16:19:53 +03:00
# ifdef LIBXML_SCHEMAS_ENABLED
if ( relaxngschemas ! = NULL )
xmlRelaxNGFree ( relaxngschemas ) ;
2003-05-12 19:25:56 +04:00
if ( wxschemas ! = NULL )
xmlSchemaFree ( wxschemas ) ;
2003-12-03 01:32:15 +03:00
# endif
2019-06-25 12:45:16 +03:00
# if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED)
2003-12-03 01:32:15 +03:00
if ( patternc ! = NULL )
xmlFreePattern ( patternc ) ;
2003-02-05 16:19:53 +03:00
# endif
2022-02-01 17:56:21 +03:00
2022-02-22 21:57:12 +03:00
/* Avoid unused label warning if features are disabled. */
goto error ;
2022-02-01 17:56:21 +03:00
error :
2000-04-05 22:38:42 +04:00
xmlCleanupParser ( ) ;
2001-02-23 21:44:52 +03:00
return ( progresult ) ;
2000-04-05 22:38:42 +04:00
}
2000-08-04 22:23:10 +04:00
2024-05-13 13:18:08 +03:00
# ifndef XMLLINT_FUZZ
int
main ( int argc , char * * argv ) {
2024-06-11 19:14:43 +03:00
return ( xmllintMain ( argc , ( const char * * ) argv , NULL ) ) ;
2024-05-13 13:18:08 +03:00
}
# endif