2000-04-05 18:38:42 +00:00
/*
* xmllint . c : a small tester program for XML input .
*
* See Copyright for the status of this software .
*
2001-06-24 12:13:24 +00:00
* daniel @ veillard . com
2000-04-05 18:38:42 +00:00
*/
2001-04-21 16:57:29 +00:00
# include "libxml.h"
2000-04-05 18:38:42 +00:00
# include <string.h>
# include <stdarg.h>
2003-01-05 22:37:17 +00:00
# include <assert.h>
2002-01-08 10:36:16 +00:00
# if defined (_WIN32) && !defined(__CYGWIN__)
2003-09-10 10:51:05 +00:00
# if defined (_MSC_VER) || defined(__BORLANDC__)
2001-04-16 17:46:18 +00:00
# include <winsock2.h>
# pragma comment(lib, "ws2_32.lib")
# define gettimeofday(p1,p2)
# endif /* _MSC_VER */
2003-08-28 12:32:04 +00:00
# endif /* _WIN32 */
2001-12-13 08:48:14 +00:00
# ifdef HAVE_SYS_TIME_H
2001-02-25 16:11:03 +00:00
# include <sys/time.h>
2001-12-13 08:48:14 +00:00
# endif
2001-12-18 07:09:59 +00:00
# ifdef HAVE_TIME_H
# include <time.h>
# endif
2001-02-25 16:11:03 +00:00
2003-08-14 01:23:25 +00:00
# ifdef __MINGW32__
# define _WINSOCKAPI_
# include <wsockcompat.h>
# include <winsock2.h>
# undef SOCKLEN_T
# define SOCKLEN_T unsigned int
# endif
2002-03-07 15:12:58 +00:00
# ifdef HAVE_SYS_TIMEB_H
# include <sys/timeb.h>
# endif
2000-04-05 18:38:42 +00:00
# ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
# endif
# 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>
# endif
2000-07-21 20:32:03 +00:00
# ifdef HAVE_SYS_MMAN_H
# include <sys/mman.h>
2000-08-12 21:12:04 +00:00
/* seems needed for Solaris */
# ifndef MAP_FAILED
# define MAP_FAILED ((void *) -1)
# endif
2000-07-21 20:32:03 +00:00
# endif
2000-04-05 18:38:42 +00:00
# ifdef HAVE_STDLIB_H
# include <stdlib.h>
# endif
# 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 19:56:55 +00:00
# include <libxml/xmlerror.h>
2000-11-06 16:43:11 +00:00
# ifdef LIBXML_XINCLUDE_ENABLED
# include <libxml/xinclude.h>
# endif
2001-05-22 15:08:55 +00:00
# ifdef LIBXML_CATALOG_ENABLED
# include <libxml/catalog.h>
# endif
2001-10-17 15:58:35 +00:00
# include <libxml/globals.h>
2003-01-03 16:19:51 +00:00
# include <libxml/xmlreader.h>
2003-02-05 13:19:53 +00:00
# ifdef LIBXML_SCHEMAS_ENABLED
# include <libxml/relaxng.h>
2003-05-12 15:25:56 +00:00
# include <libxml/xmlschemas.h>
2003-02-05 13:19:53 +00:00
# endif
2003-12-02 22:32:15 +00:00
# ifdef LIBXML_PATTERN_ENABLED
# include <libxml/pattern.h>
# endif
2004-08-22 13:11:39 +00:00
# ifdef LIBXML_C14N_ENABLED
# include <libxml/c14n.h>
# endif
2000-04-05 18:38:42 +00:00
2003-01-26 19:49:04 +00:00
# ifndef XML_XML_DEFAULT_CATALOG
# define XML_XML_DEFAULT_CATALOG "file: ///etc/xml/catalog"
# endif
2004-06-08 13:29:32 +00:00
typedef enum {
XMLLINT_RETURN_OK = 0 , /* No error */
XMLLINT_ERR_UNCLASS , /* Unclassified */
XMLLINT_ERR_DTD , /* Error in DTD */
XMLLINT_ERR_VALID , /* Validation error */
XMLLINT_ERR_RDFILE , /* CtxtReadFile error */
XMLLINT_ERR_SCHEMACOMP , /* Schema compilation */
XMLLINT_ERR_OUT , /* Error writing output */
XMLLINT_ERR_SCHEMAPAT , /* Error in schema pattern */
XMLLINT_ERR_RDREGIS , /* Error in Reader registration */
XMLLINT_ERR_MEM /* Out of memory error */
} xmllintReturnCode ;
2000-04-05 18:38:42 +00:00
# ifdef LIBXML_DEBUG_ENABLED
static int shell = 0 ;
static int debugent = 0 ;
# endif
2003-01-07 00:19:07 +00:00
static int debug = 0 ;
2004-05-03 22:54:49 +00:00
static int maxmem = 0 ;
2003-09-29 18:02:38 +00:00
# ifdef LIBXML_TREE_ENABLED
2000-04-05 18:38:42 +00:00
static int copy = 0 ;
2003-09-29 18:02:38 +00:00
# endif /* LIBXML_TREE_ENABLED */
2000-04-05 18:38:42 +00:00
static int recovery = 0 ;
static int noent = 0 ;
2003-09-29 13:20:24 +00:00
static int noblanks = 0 ;
2000-04-05 18:38:42 +00:00
static int noout = 0 ;
static int nowrap = 0 ;
2003-09-29 13:20:24 +00:00
# ifdef LIBXML_OUTPUT_ENABLED
static int format = 0 ;
static const char * output = NULL ;
static int compress = 0 ;
# endif /* LIBXML_OUTPUT_ENABLED */
2003-09-28 18:58:27 +00:00
# ifdef LIBXML_VALID_ENABLED
2000-04-05 18:38:42 +00:00
static int valid = 0 ;
static int postvalid = 0 ;
2000-10-11 15:57:05 +00:00
static char * dtdvalid = NULL ;
2003-08-18 16:39:51 +00:00
static char * dtdvalidfpi = NULL ;
2003-09-28 18:58:27 +00:00
# endif
2003-02-05 13:19:53 +00:00
# ifdef LIBXML_SCHEMAS_ENABLED
static char * relaxng = NULL ;
static xmlRelaxNGPtr relaxngschemas = NULL ;
2003-05-12 15:25:56 +00:00
static char * schema = NULL ;
static xmlSchemaPtr wxschemas = NULL ;
2003-02-05 13:19:53 +00:00
# endif
2000-04-05 18:38:42 +00:00
static int repeat = 0 ;
static int insert = 0 ;
2004-04-30 23:11:45 +00:00
# if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED)
2000-04-05 18:38:42 +00:00
static int html = 0 ;
2003-11-04 08:47:48 +00:00
static int xmlout = 0 ;
2003-09-28 18:58:27 +00:00
# endif
2000-04-05 18:38:42 +00:00
static int htmlout = 0 ;
2003-09-30 12:36:01 +00:00
# ifdef LIBXML_PUSH_ENABLED
2000-04-05 18:38:42 +00:00
static int push = 0 ;
2003-09-30 12:36:01 +00:00
# endif /* LIBXML_PUSH_ENABLED */
2000-07-21 20:32:03 +00:00
# ifdef HAVE_SYS_MMAN_H
static int memory = 0 ;
# endif
2000-04-12 13:27:38 +00:00
static int testIO = 0 ;
2000-06-28 23:40:59 +00:00
static char * encoding = NULL ;
2000-11-06 16:43:11 +00:00
# ifdef LIBXML_XINCLUDE_ENABLED
static int xinclude = 0 ;
# endif
2001-08-07 01:10:10 +00:00
static int dtdattrs = 0 ;
2001-06-20 13:55:33 +00:00
static int loaddtd = 0 ;
2004-06-08 13:29:32 +00:00
static xmllintReturnCode progresult = XMLLINT_RETURN_OK ;
2001-02-25 16:11:03 +00:00
static int timing = 0 ;
2001-04-11 07:50:02 +00:00
static int generate = 0 ;
2001-12-13 22:21:58 +00:00
static int dropdtd = 0 ;
2001-08-22 00:06:49 +00:00
# ifdef LIBXML_CATALOG_ENABLED
static int catalogs = 0 ;
static int nocatalogs = 0 ;
# endif
2004-08-14 22:37:54 +00:00
# ifdef LIBXML_C14N_ENABLED
static int canonical = 0 ;
# endif
2003-09-30 00:43:48 +00:00
# ifdef LIBXML_READER_ENABLED
2003-01-03 16:19:51 +00:00
static int stream = 0 ;
2003-11-03 12:31:38 +00:00
static int walker = 0 ;
2003-09-30 00:43:48 +00:00
# endif /* LIBXML_READER_ENABLED */
2003-01-05 22:37:17 +00:00
static int chkregister = 0 ;
2004-04-30 22:25:59 +00:00
static int nbregister = 0 ;
2003-09-30 00:43:48 +00:00
# ifdef LIBXML_SAX1_ENABLED
2003-09-10 10:51:05 +00:00
static int sax1 = 0 ;
2003-09-30 00:43:48 +00:00
# endif /* LIBXML_SAX1_ENABLED */
2003-12-02 22:32:15 +00:00
# ifdef LIBXML_PATTERN_ENABLED
static const char * pattern = NULL ;
static xmlPatternPtr patternc = NULL ;
# endif
2003-09-23 21:50:54 +00:00
static int options = 0 ;
2001-12-18 11:14:16 +00:00
2004-08-31 09:37:03 +00:00
/************************************************************************
* *
* Entity loading control and customization . *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# define MAX_PATHS 64
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 ) {
fprintf ( stderr , " MAX_PATHS reached: too many paths \n " ) ;
return ;
}
cur = path ;
while ( ( * cur = = ' ' ) | | ( * cur = = ' : ' ) )
cur + + ;
path = cur ;
while ( ( * cur ! = 0 ) & & ( * cur ! = ' ' ) & & ( * cur ! = ' : ' ) )
cur + + ;
if ( cur ! = path ) {
paths [ nbpaths ] = xmlStrndup ( path , cur - path ) ;
if ( paths [ nbpaths ] ! = NULL )
nbpaths + + ;
path = cur ;
}
}
}
xmlExternalEntityLoader defaultEntityLoader = NULL ;
static xmlParserInputPtr
xmllintExternalEntityLoader ( const char * URL , const char * ID ,
xmlParserCtxtPtr ctxt ) {
xmlParserInputPtr ret ;
warningSAXFunc warning = NULL ;
int i ;
const char * lastsegment = URL ;
const char * iter = URL ;
if ( nbpaths > 0 ) {
while ( * iter ! = 0 ) {
if ( * iter = = ' / ' )
lastsegment = iter + 1 ;
iter + + ;
}
}
if ( ( ctxt ! = NULL ) & & ( ctxt - > sax ! = NULL ) ) {
warning = ctxt - > sax - > warning ;
ctxt - > sax - > warning = NULL ;
}
if ( defaultEntityLoader ! = NULL ) {
ret = defaultEntityLoader ( URL , ID , ctxt ) ;
if ( ret ! = NULL ) {
if ( warning ! = NULL )
ctxt - > sax - > warning = warning ;
if ( load_trace ) {
fprintf \
( stderr ,
" Loaded URL= \" %s \" ID= \" %s \" \n " ,
URL ? URL : " (null) " ,
ID ? ID : " (null) " ) ;
}
return ( ret ) ;
}
}
for ( i = 0 ; i < nbpaths ; i + + ) {
xmlChar * newURL ;
newURL = xmlStrdup ( ( const xmlChar * ) paths [ i ] ) ;
newURL = xmlStrcat ( newURL , ( const xmlChar * ) " / " ) ;
newURL = xmlStrcat ( newURL , ( const xmlChar * ) lastsegment ) ;
if ( newURL ! = NULL ) {
ret = defaultEntityLoader ( ( const char * ) newURL , ID , ctxt ) ;
if ( ret ! = NULL ) {
if ( warning ! = NULL )
ctxt - > sax - > warning = warning ;
if ( load_trace ) {
fprintf \
( stderr ,
" Loaded URL= \" %s \" ID= \" %s \" \n " ,
newURL ,
ID ? ID : " (null) " ) ;
}
xmlFree ( newURL ) ;
return ( ret ) ;
}
xmlFree ( newURL ) ;
}
}
if ( warning ! = NULL ) {
ctxt - > sax - > warning = warning ;
if ( URL ! = NULL )
warning ( ctxt , " failed to load external entity \" %s \" \n " , URL ) ;
else if ( ID ! = NULL )
warning ( ctxt , " failed to load external entity \" %s \" \n " , ID ) ;
}
return ( NULL ) ;
}
2004-05-03 22:54:49 +00:00
/************************************************************************
* *
* Memory allocation consumption debugging *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2004-05-05 19:22:30 +00:00
static void
OOM ( void )
{
2004-05-03 22:54:49 +00:00
fprintf ( stderr , " Ran out of memory needs > %d bytes \n " , maxmem ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_MEM ;
2004-05-03 22:54:49 +00:00
}
2004-05-05 19:22:30 +00:00
static void
myFreeFunc ( void * mem )
{
2004-05-03 22:54:49 +00:00
xmlMemFree ( mem ) ;
}
2004-05-05 19:22:30 +00:00
static void *
myMallocFunc ( size_t size )
{
2004-05-03 22:54:49 +00:00
void * ret ;
ret = xmlMemMalloc ( size ) ;
if ( ret ! = NULL ) {
if ( xmlMemUsed ( ) > maxmem ) {
2004-05-05 19:22:30 +00:00
OOM ( ) ;
xmlMemFree ( ret ) ;
return ( NULL ) ;
}
2004-05-03 22:54:49 +00:00
}
2004-05-05 19:22:30 +00:00
return ( ret ) ;
2004-05-03 22:54:49 +00:00
}
2004-05-05 19:22:30 +00:00
static void *
myReallocFunc ( void * mem , size_t size )
{
2004-05-03 22:54:49 +00:00
void * ret ;
ret = xmlMemRealloc ( mem , size ) ;
if ( ret ! = NULL ) {
if ( xmlMemUsed ( ) > maxmem ) {
2004-05-05 19:22:30 +00:00
OOM ( ) ;
xmlMemFree ( ret ) ;
return ( NULL ) ;
}
2004-05-03 22:54:49 +00:00
}
2004-05-05 19:22:30 +00:00
return ( ret ) ;
2004-05-03 22:54:49 +00:00
}
2004-05-05 19:22:30 +00:00
static char *
myStrdupFunc ( const char * str )
{
2004-05-03 22:54:49 +00:00
char * ret ;
ret = xmlMemoryStrdup ( str ) ;
if ( ret ! = NULL ) {
if ( xmlMemUsed ( ) > maxmem ) {
2004-05-05 19:22:30 +00:00
OOM ( ) ;
xmlFree ( ret ) ;
return ( NULL ) ;
}
2004-05-03 22:54:49 +00:00
}
2004-05-05 19:22:30 +00:00
return ( ret ) ;
2004-05-03 22:54:49 +00:00
}
/************************************************************************
* *
* Internal timing routines to remove the necessity to have *
* unix - specific function calls . *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-12-18 07:09:59 +00:00
2002-03-07 11:21:00 +00:00
# ifndef HAVE_GETTIMEOFDAY
# ifdef HAVE_SYS_TIMEB_H
# ifdef HAVE_SYS_TIME_H
# ifdef HAVE_FTIME
2002-12-10 15:19:08 +00:00
static int
2002-03-07 11:21:00 +00: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 07:09:59 +00: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
*/
static void
2002-09-24 14:13:13 +00:00
endTimer ( const char * fmt , . . . )
2001-12-18 07:09:59 +00: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 ;
# ifndef HAVE_STDARG_H
# error "endTimer required stdarg functions"
# endif
2002-09-24 14:13:13 +00:00
va_start ( ap , fmt ) ;
vfprintf ( stderr , fmt , ap ) ;
2001-12-18 07:09:59 +00:00
va_end ( ap ) ;
fprintf ( stderr , " took %ld ms \n " , msec ) ;
}
# elif defined(HAVE_TIME_H)
/*
* 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 15:12:58 +00:00
# ifndef CLOCKS_PER_SEC
# define CLOCKS_PER_SEC 100
# endif
2001-12-18 07:09:59 +00:00
static clock_t begin , end ;
static void
startTimer ( void )
{
begin = clock ( ) ;
}
static void
endTimer ( const char * fmt , . . . )
{
long msec ;
va_list ap ;
end = clock ( ) ;
msec = ( ( end - begin ) * 1000 ) / CLOCKS_PER_SEC ;
# ifndef HAVE_STDARG_H
# error "endTimer required stdarg functions"
# endif
va_start ( ap , fmt ) ;
vfprintf ( stderr , fmt , ap ) ;
va_end ( ap ) ;
fprintf ( stderr , " took %ld ms \n " , msec ) ;
}
# else
/*
* We don ' t have a gettimeofday or time . h , so we just don ' t do timing
*/
static void
startTimer ( void )
{
/*
* Do nothing
*/
}
static void
endTimer ( char * format , . . . )
{
/*
* We cannot do anything because we don ' t have a timing function
*/
# ifdef HAVE_STDARG_H
va_start ( ap , format ) ;
vfprintf ( stderr , format , ap ) ;
va_end ( ap ) ;
fprintf ( stderr , " was not timed \n " , msec ) ;
# else
/* We don't have gettimeofday, time or stdarg.h, what crazy world is
* this ? !
*/
# endif
}
# endif
2000-04-05 18:38:42 +00:00
/************************************************************************
* *
* HTML ouput *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
char buffer [ 50000 ] ;
2001-03-24 17:00:36 +00:00
static void
2000-04-05 18:38:42 +00:00
xmlHTMLEncodeSend ( void ) {
char * result ;
result = ( char * ) xmlEncodeEntitiesReentrant ( NULL , BAD_CAST buffer ) ;
if ( result ) {
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext , " %s " , result ) ;
2000-04-05 18:38:42 +00:00
xmlFree ( result ) ;
}
buffer [ 0 ] = 0 ;
}
/**
* xmlHTMLPrintFileInfo :
* @ input : an xmlParserInputPtr input
*
* Displays the associated file and line informations for the current input
*/
2001-03-24 17:00:36 +00:00
static void
2000-04-05 18:38:42 +00:00
xmlHTMLPrintFileInfo ( xmlParserInputPtr input ) {
2002-06-14 17:07:10 +00:00
int len ;
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext , " <p> " ) ;
2002-06-14 17:07:10 +00:00
len = strlen ( buffer ) ;
2000-04-05 18:38:42 +00:00
if ( input ! = NULL ) {
if ( input - > filename ) {
2002-06-14 17:07:10 +00:00
snprintf ( & buffer [ len ] , sizeof ( buffer ) - len , " %s:%d: " , input - > filename ,
2000-04-05 18:38:42 +00:00
input - > line ) ;
} else {
2002-06-14 17:07:10 +00:00
snprintf ( & buffer [ len ] , sizeof ( buffer ) - len , " Entity: line %d: " , input - > line ) ;
2000-04-05 18:38:42 +00:00
}
}
xmlHTMLEncodeSend ( ) ;
}
/**
* xmlHTMLPrintFileContext :
* @ input : an xmlParserInputPtr input
*
* Displays current context within the input content for error tracking
*/
2001-03-24 17:00:36 +00:00
static void
2000-04-05 18:38:42 +00:00
xmlHTMLPrintFileContext ( xmlParserInputPtr input ) {
const xmlChar * cur , * base ;
2002-06-14 17:07:10 +00:00
int len ;
2000-04-05 18:38:42 +00:00
int n ;
if ( input = = NULL ) return ;
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext , " <pre> \n " ) ;
2000-04-05 18:38:42 +00:00
cur = input - > cur ;
base = input - > base ;
while ( ( cur > base ) & & ( ( * cur = = ' \n ' ) | | ( * cur = = ' \r ' ) ) ) {
cur - - ;
}
n = 0 ;
while ( ( n + + < 80 ) & & ( cur > base ) & & ( * cur ! = ' \n ' ) & & ( * cur ! = ' \r ' ) )
cur - - ;
if ( ( * cur = = ' \n ' ) | | ( * cur = = ' \r ' ) ) cur + + ;
base = cur ;
n = 0 ;
while ( ( * cur ! = 0 ) & & ( * cur ! = ' \n ' ) & & ( * cur ! = ' \r ' ) & & ( n < 79 ) ) {
2002-06-14 17:07:10 +00:00
len = strlen ( buffer ) ;
snprintf ( & buffer [ len ] , sizeof ( buffer ) - len , " %c " ,
( unsigned char ) * cur + + ) ;
2000-04-05 18:38:42 +00:00
n + + ;
}
2002-06-14 17:07:10 +00:00
len = strlen ( buffer ) ;
snprintf ( & buffer [ len ] , sizeof ( buffer ) - len , " \n " ) ;
2000-04-05 18:38:42 +00:00
cur = input - > cur ;
while ( ( * cur = = ' \n ' ) | | ( * cur = = ' \r ' ) )
cur - - ;
n = 0 ;
while ( ( cur ! = base ) & & ( n + + < 80 ) ) {
2002-06-14 17:07:10 +00:00
len = strlen ( buffer ) ;
snprintf ( & buffer [ len ] , sizeof ( buffer ) - len , " " ) ;
2000-04-05 18:38:42 +00:00
base + + ;
}
2002-06-14 17:07:10 +00:00
len = strlen ( buffer ) ;
snprintf ( & buffer [ len ] , sizeof ( buffer ) - len , " ^ \n " ) ;
2000-04-05 18:38:42 +00:00
xmlHTMLEncodeSend ( ) ;
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext , " </pre> " ) ;
2000-04-05 18:38:42 +00:00
}
/**
* xmlHTMLError :
* @ ctx : an XML parser context
* @ msg : the message to display / transmit
* @ . . . : extra parameters for the message display
*
* Display and format an error messages , gives file , line , position and
* extra parameters .
*/
2001-03-24 17:00:36 +00:00
static void
2000-04-05 18:38:42 +00:00
xmlHTMLError ( void * ctx , const char * msg , . . . )
{
xmlParserCtxtPtr ctxt = ( xmlParserCtxtPtr ) ctx ;
xmlParserInputPtr input ;
va_list args ;
2002-06-14 17:07:10 +00:00
int len ;
2000-04-05 18:38:42 +00:00
buffer [ 0 ] = 0 ;
input = ctxt - > input ;
if ( ( input ! = NULL ) & & ( input - > filename = = NULL ) & & ( ctxt - > inputNr > 1 ) ) {
input = ctxt - > inputTab [ ctxt - > inputNr - 2 ] ;
}
xmlHTMLPrintFileInfo ( input ) ;
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext , " <b>error</b>: " ) ;
2000-04-05 18:38:42 +00:00
va_start ( args , msg ) ;
2002-06-14 17:07:10 +00:00
len = strlen ( buffer ) ;
vsnprintf ( & buffer [ len ] , sizeof ( buffer ) - len , msg , args ) ;
2000-04-05 18:38:42 +00:00
va_end ( args ) ;
xmlHTMLEncodeSend ( ) ;
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext , " </p> \n " ) ;
2000-04-05 18:38:42 +00:00
xmlHTMLPrintFileContext ( input ) ;
xmlHTMLEncodeSend ( ) ;
}
/**
* xmlHTMLWarning :
* @ ctx : 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 .
*/
2001-03-24 17:00:36 +00:00
static void
2000-04-05 18:38:42 +00:00
xmlHTMLWarning ( void * ctx , const char * msg , . . . )
{
xmlParserCtxtPtr ctxt = ( xmlParserCtxtPtr ) ctx ;
xmlParserInputPtr input ;
va_list args ;
2002-06-14 17:07:10 +00:00
int len ;
2000-04-05 18:38:42 +00:00
buffer [ 0 ] = 0 ;
input = ctxt - > input ;
if ( ( input ! = NULL ) & & ( input - > filename = = NULL ) & & ( ctxt - > inputNr > 1 ) ) {
input = ctxt - > inputTab [ ctxt - > inputNr - 2 ] ;
}
xmlHTMLPrintFileInfo ( input ) ;
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext , " <b>warning</b>: " ) ;
2000-04-05 18:38:42 +00:00
va_start ( args , msg ) ;
2002-06-14 17:07:10 +00:00
len = strlen ( buffer ) ;
vsnprintf ( & buffer [ len ] , sizeof ( buffer ) - len , msg , args ) ;
2000-04-05 18:38:42 +00:00
va_end ( args ) ;
xmlHTMLEncodeSend ( ) ;
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext , " </p> \n " ) ;
2000-04-05 18:38:42 +00:00
xmlHTMLPrintFileContext ( input ) ;
xmlHTMLEncodeSend ( ) ;
}
/**
* xmlHTMLValidityError :
* @ ctx : an XML parser context
* @ msg : the message to display / transmit
* @ . . . : extra parameters for the message display
*
* Display and format an validity error messages , gives file ,
* line , position and extra parameters .
*/
2001-03-24 17:00:36 +00:00
static void
2000-04-05 18:38:42 +00:00
xmlHTMLValidityError ( void * ctx , const char * msg , . . . )
{
xmlParserCtxtPtr ctxt = ( xmlParserCtxtPtr ) ctx ;
xmlParserInputPtr input ;
va_list args ;
2002-06-14 17:07:10 +00:00
int len ;
2000-04-05 18:38:42 +00:00
buffer [ 0 ] = 0 ;
input = ctxt - > input ;
if ( ( input - > filename = = NULL ) & & ( ctxt - > inputNr > 1 ) )
input = ctxt - > inputTab [ ctxt - > inputNr - 2 ] ;
xmlHTMLPrintFileInfo ( input ) ;
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext , " <b>validity error</b>: " ) ;
2002-06-14 17:07:10 +00:00
len = strlen ( buffer ) ;
2000-04-05 18:38:42 +00:00
va_start ( args , msg ) ;
2002-06-14 17:07:10 +00:00
vsnprintf ( & buffer [ len ] , sizeof ( buffer ) - len , msg , args ) ;
2000-04-05 18:38:42 +00:00
va_end ( args ) ;
xmlHTMLEncodeSend ( ) ;
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext , " </p> \n " ) ;
2000-04-05 18:38:42 +00:00
xmlHTMLPrintFileContext ( input ) ;
xmlHTMLEncodeSend ( ) ;
}
/**
* xmlHTMLValidityWarning :
* @ ctx : an XML parser context
* @ msg : the message to display / transmit
* @ . . . : extra parameters for the message display
*
* Display and format a validity warning messages , gives file , line ,
* position and extra parameters .
*/
2001-03-24 17:00:36 +00:00
static void
2000-04-05 18:38:42 +00:00
xmlHTMLValidityWarning ( void * ctx , const char * msg , . . . )
{
xmlParserCtxtPtr ctxt = ( xmlParserCtxtPtr ) ctx ;
xmlParserInputPtr input ;
va_list args ;
2002-06-14 17:07:10 +00:00
int len ;
2000-04-05 18:38:42 +00:00
buffer [ 0 ] = 0 ;
input = ctxt - > input ;
if ( ( input - > filename = = NULL ) & & ( ctxt - > inputNr > 1 ) )
input = ctxt - > inputTab [ ctxt - > inputNr - 2 ] ;
xmlHTMLPrintFileInfo ( input ) ;
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext , " <b>validity warning</b>: " ) ;
2000-04-05 18:38:42 +00:00
va_start ( args , msg ) ;
2002-06-14 17:07:10 +00:00
len = strlen ( buffer ) ;
vsnprintf ( & buffer [ len ] , sizeof ( buffer ) - len , msg , args ) ;
2000-04-05 18:38:42 +00:00
va_end ( args ) ;
xmlHTMLEncodeSend ( ) ;
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext , " </p> \n " ) ;
2000-04-05 18:38:42 +00:00
xmlHTMLPrintFileContext ( input ) ;
xmlHTMLEncodeSend ( ) ;
}
/************************************************************************
* *
* Shell Interface *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-01-07 11:17:25 +00:00
# ifdef LIBXML_DEBUG_ENABLED
2004-11-09 16:17:02 +00:00
# ifdef LIBXML_XPATH_ENABLED
2000-04-05 18:38:42 +00:00
/**
* xmlShellReadline :
* @ prompt : the prompt value
*
* Read a string
*
* Returns a pointer to it or NULL on EOF the caller is expected to
* free the returned string .
*/
2001-03-24 17:00:36 +00:00
static char *
2000-04-05 18:38:42 +00: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-13 22:21:58 +00:00
char * ret ;
int len ;
2000-04-05 18:38:42 +00:00
if ( prompt ! = NULL )
fprintf ( stdout , " %s " , prompt ) ;
if ( ! fgets ( line_read , 500 , stdin ) )
return ( NULL ) ;
line_read [ 500 ] = 0 ;
2001-12-13 22:21:58 +00:00
len = strlen ( line_read ) ;
ret = ( char * ) malloc ( len + 1 ) ;
if ( ret ! = NULL ) {
memcpy ( ret , line_read , len + 1 ) ;
}
return ( ret ) ;
2000-04-05 18:38:42 +00:00
# endif
}
2004-11-09 16:17:02 +00:00
# endif /* LIBXML_XPATH_ENABLED */
2003-01-07 11:17:25 +00:00
# endif /* LIBXML_DEBUG_ENABLED */
2000-04-05 18:38:42 +00:00
2000-04-12 13:27:38 +00:00
/************************************************************************
* *
* I / O Interfaces *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-03-24 17:00:36 +00:00
static int myRead ( FILE * f , char * buf , int len ) {
return ( fread ( buf , 1 , len , f ) ) ;
2000-04-12 13:27:38 +00:00
}
2001-03-24 17:00:36 +00:00
static void myClose ( FILE * f ) {
2001-01-03 13:32:39 +00:00
if ( f ! = stdin ) {
2000-04-12 13:27:38 +00:00
fclose ( f ) ;
2001-01-03 13:32:39 +00:00
}
2000-04-12 13:27:38 +00:00
}
2003-09-30 00:43:48 +00:00
# ifdef LIBXML_READER_ENABLED
2000-04-05 18:38:42 +00:00
/************************************************************************
* *
2003-01-03 16:19:51 +00:00
* Stream Test processing *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void processNode ( xmlTextReaderPtr reader ) {
2003-10-20 17:07:41 +00:00
const xmlChar * name , * value ;
2003-01-04 16:35:29 +00:00
2003-10-20 17:07:41 +00:00
name = xmlTextReaderConstName ( reader ) ;
2003-01-04 16:35:29 +00:00
if ( name = = NULL )
2003-11-03 12:31:38 +00:00
name = BAD_CAST " -- " ;
2003-03-22 14:55:50 +00:00
2003-10-20 17:07:41 +00:00
value = xmlTextReaderConstValue ( reader ) ;
2003-01-04 16:35:29 +00:00
2003-03-22 14:55:50 +00:00
printf ( " %d %d %s %d %d " ,
2003-01-04 16:35:29 +00:00
xmlTextReaderDepth ( reader ) ,
xmlTextReaderNodeType ( reader ) ,
name ,
2003-03-22 14:55:50 +00:00
xmlTextReaderIsEmptyElement ( reader ) ,
xmlTextReaderHasValue ( reader ) ) ;
2003-01-04 16:35:29 +00:00
if ( value = = NULL )
printf ( " \n " ) ;
else {
printf ( " %s \n " , value ) ;
2003-01-03 16:19:51 +00:00
}
2003-12-02 22:32:15 +00:00
# ifdef LIBXML_PATTERN_ENABLED
if ( patternc ) {
if ( xmlPatternMatch ( patternc , xmlTextReaderCurrentNode ( reader ) ) = = 1 ) {
printf ( " Node matches pattern %s \n " , pattern ) ;
}
}
# endif
2003-01-03 16:19:51 +00:00
}
static void streamFile ( char * filename ) {
xmlTextReaderPtr reader ;
int ret ;
2003-09-17 19:36:25 +00:00
# ifdef HAVE_SYS_MMAN_H
int fd = - 1 ;
struct stat info ;
const char * base = NULL ;
xmlParserInputBufferPtr input = NULL ;
if ( memory ) {
if ( stat ( filename , & info ) < 0 )
return ;
if ( ( fd = open ( filename , O_RDONLY ) ) < 0 )
return ;
base = mmap ( NULL , info . st_size , PROT_READ , MAP_SHARED , fd , 0 ) ;
if ( base = = ( void * ) MAP_FAILED )
return ;
2003-11-03 12:31:38 +00:00
reader = xmlReaderForMemory ( base , info . st_size , filename ,
NULL , options ) ;
2003-09-17 19:36:25 +00:00
} else
# endif
2003-11-03 12:31:38 +00:00
reader = xmlReaderForFile ( filename , NULL , options ) ;
2003-01-03 16:19:51 +00:00
if ( reader ! = NULL ) {
2003-09-28 18:58:27 +00:00
# ifdef LIBXML_VALID_ENABLED
2003-01-03 16:19:51 +00:00
if ( valid )
xmlTextReaderSetParserProp ( reader , XML_PARSER_VALIDATE , 1 ) ;
2003-04-16 15:58:05 +00:00
else
2003-09-28 18:58:27 +00:00
# endif /* LIBXML_VALID_ENABLED */
2003-04-16 15:58:05 +00:00
xmlTextReaderSetParserProp ( reader , XML_PARSER_LOADDTD , 1 ) ;
2003-05-09 19:38:15 +00:00
# ifdef LIBXML_SCHEMAS_ENABLED
2003-04-16 15:58:05 +00:00
if ( relaxng ! = NULL ) {
2003-09-16 23:17:26 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2003-04-16 15:58:05 +00:00
startTimer ( ) ;
}
ret = xmlTextReaderRelaxNGValidate ( reader , relaxng ) ;
if ( ret < 0 ) {
xmlGenericError ( xmlGenericErrorContext ,
" Relax-NG schema %s failed to compile \n " , relaxng ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_SCHEMACOMP ;
2003-04-16 15:58:05 +00:00
relaxng = NULL ;
}
2003-09-16 23:17:26 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2003-04-16 15:58:05 +00:00
endTimer ( " Compiling the schemas " ) ;
}
}
2003-05-09 19:38:15 +00:00
# endif
2003-01-03 16:19:51 +00:00
/*
* Process all nodes in sequence
*/
2003-09-16 23:17:26 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2003-04-16 15:58:05 +00:00
startTimer ( ) ;
}
2003-01-03 16:19:51 +00:00
ret = xmlTextReaderRead ( reader ) ;
while ( ret = = 1 ) {
2003-12-02 22:32:15 +00:00
if ( ( debug )
# ifdef LIBXML_PATTERN_ENABLED
| | ( patternc )
# endif
)
2003-01-03 16:19:51 +00:00
processNode ( reader ) ;
ret = xmlTextReaderRead ( reader ) ;
}
2003-09-16 23:17:26 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2003-05-09 19:38:15 +00:00
# ifdef LIBXML_SCHEMAS_ENABLED
2004-02-25 11:52:31 +00:00
if ( relaxng ! = NULL )
2004-02-19 12:58:36 +00:00
endTimer ( " Parsing and validating " ) ;
else
2004-02-25 11:52:31 +00:00
# endif
2003-09-28 18:58:27 +00:00
# ifdef LIBXML_VALID_ENABLED
2003-05-09 19:38:15 +00:00
if ( valid )
2003-04-16 15:58:05 +00:00
endTimer ( " Parsing and validating " ) ;
else
2003-09-28 18:58:27 +00:00
# endif
2004-02-25 11:52:31 +00:00
endTimer ( " Parsing " ) ;
2003-04-16 15:58:05 +00:00
}
2003-01-03 16:19:51 +00:00
2003-09-28 18:58:27 +00:00
# ifdef LIBXML_VALID_ENABLED
2003-04-11 19:38:54 +00:00
if ( valid ) {
if ( xmlTextReaderIsValid ( reader ) ! = 1 ) {
xmlGenericError ( xmlGenericErrorContext ,
" Document %s does not validate \n " , filename ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_VALID ;
2003-04-11 19:38:54 +00:00
}
}
2003-09-28 18:58:27 +00:00
# endif /* LIBXML_VALID_ENABLED */
2003-05-09 19:38:15 +00:00
# ifdef LIBXML_SCHEMAS_ENABLED
2003-04-15 23:32:22 +00:00
if ( relaxng ! = NULL ) {
if ( xmlTextReaderIsValid ( reader ) ! = 1 ) {
2003-12-29 10:31:21 +00:00
fprintf ( stderr , " %s fails to validate \n " , filename ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_VALID ;
2003-04-15 23:32:22 +00:00
} else {
2003-12-29 10:31:21 +00:00
fprintf ( stderr , " %s validates \n " , filename ) ;
2003-04-15 23:32:22 +00:00
}
}
2003-05-09 19:38:15 +00:00
# endif
2003-01-03 16:19:51 +00:00
/*
* Done , cleanup and status
*/
xmlFreeTextReader ( reader ) ;
if ( ret ! = 0 ) {
2003-12-29 10:31:21 +00:00
fprintf ( stderr , " %s : failed to parse \n " , filename ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_UNCLASS ;
2003-01-03 16:19:51 +00:00
}
} else {
fprintf ( stderr , " Unable to open %s \n " , filename ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_UNCLASS ;
2003-01-03 16:19:51 +00:00
}
2003-09-17 19:36:25 +00:00
# ifdef HAVE_SYS_MMAN_H
if ( memory ) {
xmlFreeParserInputBuffer ( input ) ;
munmap ( ( char * ) base , info . st_size ) ;
close ( fd ) ;
}
# endif
2003-01-03 16:19:51 +00:00
}
2003-11-03 12:31:38 +00:00
static void walkDoc ( xmlDocPtr doc ) {
xmlTextReaderPtr reader ;
int ret ;
reader = xmlReaderWalker ( doc ) ;
if ( reader ! = NULL ) {
if ( ( timing ) & & ( ! repeat ) ) {
startTimer ( ) ;
}
ret = xmlTextReaderRead ( reader ) ;
while ( ret = = 1 ) {
2003-12-02 22:32:15 +00:00
if ( ( debug )
# ifdef LIBXML_PATTERN_ENABLED
| | ( patternc )
# endif
)
2003-11-03 12:31:38 +00:00
processNode ( reader ) ;
ret = xmlTextReaderRead ( reader ) ;
}
if ( ( timing ) & & ( ! repeat ) ) {
endTimer ( " walking through the doc " ) ;
}
xmlFreeTextReader ( reader ) ;
if ( ret ! = 0 ) {
2003-12-29 10:31:21 +00:00
fprintf ( stderr , " failed to walk through the doc \n " ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_UNCLASS ;
2003-11-03 12:31:38 +00:00
}
} else {
fprintf ( stderr , " Failed to crate a reader from the document \n " ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_UNCLASS ;
2003-11-03 12:31:38 +00:00
}
}
2003-09-30 00:43:48 +00:00
# endif /* LIBXML_READER_ENABLED */
2003-01-03 16:19:51 +00:00
/************************************************************************
* *
* Tree Test processing *
2000-04-05 18:38:42 +00:00
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-09-24 21:23:56 +00:00
static void parseAndPrintFile ( char * filename , xmlParserCtxtPtr rectxt ) {
2003-09-29 18:02:38 +00:00
xmlDocPtr doc = NULL ;
# ifdef LIBXML_TREE_ENABLED
xmlDocPtr tmp ;
# endif /* LIBXML_TREE_ENABLED */
2000-04-05 18:38:42 +00:00
2001-02-25 16:11:03 +00:00
if ( ( timing ) & & ( ! repeat ) )
2001-12-18 07:09:59 +00:00
startTimer ( ) ;
2001-02-25 16:11:03 +00:00
2003-09-29 18:02:38 +00:00
# ifdef LIBXML_TREE_ENABLED
2001-04-11 07:50:02 +00:00
if ( filename = = NULL ) {
if ( generate ) {
xmlNodePtr n ;
doc = xmlNewDoc ( BAD_CAST " 1.0 " ) ;
2004-10-26 21:53:55 +00:00
n = xmlNewDocNode ( doc , NULL , BAD_CAST " info " , NULL ) ;
2001-04-11 07:50:02 +00:00
xmlNodeSetContent ( n , BAD_CAST " abc " ) ;
xmlDocSetRootElement ( doc , n ) ;
}
}
2003-09-29 18:02:38 +00:00
# endif /* LIBXML_TREE_ENABLED */
2000-04-05 18:38:42 +00:00
# ifdef LIBXML_HTML_ENABLED
2003-09-30 12:36:01 +00:00
# ifdef LIBXML_PUSH_ENABLED
2003-07-31 14:47:38 +00:00
else if ( ( html ) & & ( push ) ) {
FILE * f ;
2004-06-27 02:07:51 +00:00
# if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
f = fopen ( filename , " rb " ) ;
# else
f = fopen ( filename , " r " ) ;
# endif
2003-07-31 14:47:38 +00:00
if ( f ! = NULL ) {
int res , size = 3 ;
char chars [ 4096 ] ;
htmlParserCtxtPtr ctxt ;
/* if (repeat) */
size = 4096 ;
res = fread ( chars , 1 , 4 , f ) ;
if ( res > 0 ) {
ctxt = htmlCreatePushParserCtxt ( NULL , NULL ,
2003-10-27 13:48:16 +00:00
chars , res , filename , XML_CHAR_ENCODING_NONE ) ;
2003-07-31 14:47:38 +00:00
while ( ( res = fread ( chars , 1 , size , f ) ) > 0 ) {
htmlParseChunk ( ctxt , chars , res , 0 ) ;
}
htmlParseChunk ( ctxt , chars , 0 , 1 ) ;
doc = ctxt - > myDoc ;
htmlFreeParserCtxt ( ctxt ) ;
}
fclose ( f ) ;
}
}
2003-09-30 12:36:01 +00:00
# endif /* LIBXML_PUSH_ENABLED */
2001-04-11 07:50:02 +00:00
else if ( html ) {
2003-09-26 12:47:50 +00:00
doc = htmlReadFile ( filename , NULL , options ) ;
2001-04-11 07:50:02 +00:00
}
2000-04-05 18:38:42 +00:00
# endif /* LIBXML_HTML_ENABLED */
2001-04-11 07:50:02 +00:00
else {
2003-09-30 12:36:01 +00:00
# ifdef LIBXML_PUSH_ENABLED
2000-04-05 18:38:42 +00:00
/*
* build an XML tree from a string ;
*/
if ( push ) {
FILE * f ;
2001-01-03 13:32:39 +00:00
/* '-' Usually means stdin -<sven@zen.org> */
if ( ( filename [ 0 ] = = ' - ' ) & & ( filename [ 1 ] = = 0 ) ) {
f = stdin ;
} else {
2004-06-27 02:07:51 +00:00
# if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
f = fopen ( filename , " rb " ) ;
# else
f = fopen ( filename , " r " ) ;
# endif
2001-01-03 13:32:39 +00:00
}
2000-04-05 18:38:42 +00:00
if ( f ! = NULL ) {
2000-08-29 18:29:38 +00:00
int ret ;
2003-04-21 21:36:41 +00:00
int res , size = 1024 ;
2000-04-05 18:38:42 +00:00
char chars [ 1024 ] ;
xmlParserCtxtPtr ctxt ;
2003-04-21 21:36:41 +00:00
/* if (repeat) size = 1024; */
2000-04-05 18:38:42 +00:00
res = fread ( chars , 1 , 4 , f ) ;
if ( res > 0 ) {
ctxt = xmlCreatePushParserCtxt ( NULL , NULL ,
chars , res , filename ) ;
2004-03-22 15:22:58 +00:00
xmlCtxtUseOptions ( ctxt , options ) ;
2000-04-05 18:38:42 +00:00
while ( ( res = fread ( chars , 1 , size , f ) ) > 0 ) {
xmlParseChunk ( ctxt , chars , res , 0 ) ;
}
xmlParseChunk ( ctxt , chars , 0 , 1 ) ;
doc = ctxt - > myDoc ;
2000-08-29 18:29:38 +00:00
ret = ctxt - > wellFormed ;
2000-04-05 18:38:42 +00:00
xmlFreeParserCtxt ( ctxt ) ;
2000-08-29 18:29:38 +00:00
if ( ! ret ) {
xmlFreeDoc ( doc ) ;
doc = NULL ;
}
2000-04-05 18:38:42 +00:00
}
}
2003-09-30 12:36:01 +00:00
} else
# endif /* LIBXML_PUSH_ENABLED */
if ( testIO ) {
2001-01-03 13:32:39 +00:00
if ( ( filename [ 0 ] = = ' - ' ) & & ( filename [ 1 ] = = 0 ) ) {
2003-09-25 21:05:58 +00:00
doc = xmlReadFd ( 0 , NULL , NULL , options ) ;
2001-01-03 13:32:39 +00:00
} else {
2003-09-23 21:50:54 +00:00
FILE * f ;
2000-04-12 13:27:38 +00:00
2004-06-27 02:07:51 +00:00
# if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
f = fopen ( filename , " rb " ) ;
# else
2003-09-23 21:50:54 +00:00
f = fopen ( filename , " r " ) ;
2004-06-27 02:07:51 +00:00
# endif
2003-09-24 21:23:56 +00:00
if ( f ! = NULL ) {
if ( rectxt = = NULL )
doc = xmlReadIO ( ( xmlInputReadCallback ) myRead ,
( xmlInputCloseCallback ) myClose , f ,
2003-09-25 21:05:58 +00:00
filename , NULL , options ) ;
2003-09-24 21:23:56 +00:00
else
doc = xmlCtxtReadIO ( rectxt ,
( xmlInputReadCallback ) myRead ,
( xmlInputCloseCallback ) myClose , f ,
2003-09-25 21:05:58 +00:00
filename , NULL , options ) ;
2003-09-24 21:23:56 +00:00
} else
2000-04-12 13:27:38 +00:00
doc = NULL ;
}
2000-04-05 18:38:42 +00:00
} else if ( htmlout ) {
xmlParserCtxtPtr ctxt ;
2000-08-04 18:23:10 +00:00
2003-09-24 21:23:56 +00:00
if ( rectxt = = NULL )
ctxt = xmlNewParserCtxt ( ) ;
else
ctxt = rectxt ;
2000-08-04 18:23:10 +00:00
if ( ctxt = = NULL ) {
2003-09-23 21:50:54 +00:00
doc = NULL ;
2000-08-04 18:23:10 +00:00
} else {
2003-09-23 21:50:54 +00:00
ctxt - > sax - > error = xmlHTMLError ;
ctxt - > sax - > warning = xmlHTMLWarning ;
ctxt - > vctxt . error = xmlHTMLValidityError ;
ctxt - > vctxt . warning = xmlHTMLValidityWarning ;
doc = xmlCtxtReadFile ( ctxt , filename , NULL , options ) ;
2003-09-24 21:23:56 +00:00
if ( rectxt = = NULL )
xmlFreeParserCtxt ( ctxt ) ;
2000-04-05 18:38:42 +00:00
}
2000-07-21 20:32:03 +00:00
# ifdef HAVE_SYS_MMAN_H
} else if ( memory ) {
int fd ;
struct stat info ;
const char * base ;
if ( stat ( filename , & info ) < 0 )
return ;
if ( ( fd = open ( filename , O_RDONLY ) ) < 0 )
return ;
base = mmap ( NULL , info . st_size , PROT_READ , MAP_SHARED , fd , 0 ) ;
2000-08-14 17:57:48 +00:00
if ( base = = ( void * ) MAP_FAILED )
2000-07-21 20:32:03 +00:00
return ;
2003-09-24 21:23:56 +00:00
if ( rectxt = = NULL )
2003-09-25 21:05:58 +00:00
doc = xmlReadMemory ( ( char * ) base , info . st_size ,
filename , NULL , options ) ;
2003-09-24 21:23:56 +00:00
else
2003-09-25 21:05:58 +00:00
doc = xmlCtxtReadMemory ( rectxt , ( char * ) base , info . st_size ,
filename , NULL , options ) ;
2003-09-24 21:23:56 +00:00
2000-07-21 20:32:03 +00:00
munmap ( ( char * ) base , info . st_size ) ;
# endif
2003-09-28 18:58:27 +00:00
# ifdef LIBXML_VALID_ENABLED
2002-12-20 00:16:24 +00:00
} else if ( valid ) {
2003-09-24 21:23:56 +00:00
xmlParserCtxtPtr ctxt = NULL ;
2002-12-20 00:16:24 +00:00
2003-09-24 21:23:56 +00:00
if ( rectxt = = NULL )
ctxt = xmlNewParserCtxt ( ) ;
else
ctxt = rectxt ;
2002-12-20 00:16:24 +00:00
if ( ctxt = = NULL ) {
2003-09-23 21:50:54 +00:00
doc = NULL ;
2002-12-20 00:16:24 +00:00
} else {
2003-09-23 21:50:54 +00:00
doc = xmlCtxtReadFile ( ctxt , filename , NULL , options ) ;
if ( ctxt - > valid = = 0 )
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_RDFILE ;
2003-09-24 21:23:56 +00:00
if ( rectxt = = NULL )
xmlFreeParserCtxt ( ctxt ) ;
2002-12-20 00:16:24 +00:00
}
2003-09-28 18:58:27 +00:00
# endif /* LIBXML_VALID_ENABLED */
2002-12-20 00:16:24 +00:00
} else {
2003-09-24 21:23:56 +00:00
if ( rectxt ! = NULL )
doc = xmlCtxtReadFile ( rectxt , filename , NULL , options ) ;
else
doc = xmlReadFile ( filename , NULL , options ) ;
2002-12-20 00:16:24 +00:00
}
2000-04-05 18:38:42 +00:00
}
2000-08-04 18:23:10 +00:00
/*
* If we don ' t have a document we might as well give up . Do we
* want an error message here ? < sven @ zen . org > */
2000-11-06 16:43:11 +00:00
if ( doc = = NULL ) {
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_UNCLASS ;
2000-08-04 18:23:10 +00:00
return ;
2000-11-06 16:43:11 +00:00
}
2001-02-25 16:11:03 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 07:09:59 +00:00
endTimer ( " Parsing " ) ;
2001-02-25 16:11:03 +00:00
}
2001-12-13 22:21:58 +00:00
/*
* Remove DOCTYPE nodes
*/
if ( dropdtd ) {
xmlDtdPtr dtd ;
dtd = xmlGetIntSubset ( doc ) ;
if ( dtd ! = NULL ) {
xmlUnlinkNode ( ( xmlNodePtr ) dtd ) ;
xmlFreeDtd ( dtd ) ;
}
}
2000-11-06 16:43:11 +00:00
# ifdef LIBXML_XINCLUDE_ENABLED
2001-02-25 16:11:03 +00:00
if ( xinclude ) {
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 07:09:59 +00:00
startTimer ( ) ;
2001-02-25 16:11:03 +00:00
}
2003-12-09 11:35:37 +00:00
xmlXIncludeProcessFlags ( doc , options ) ;
2001-02-25 16:11:03 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 07:09:59 +00:00
endTimer ( " Xinclude processing " ) ;
2001-02-25 16:11:03 +00:00
}
}
2000-11-06 16:43:11 +00:00
# endif
2000-08-04 18:23:10 +00:00
2000-04-05 18:38:42 +00:00
# ifdef LIBXML_DEBUG_ENABLED
2004-11-09 16:17:02 +00:00
# ifdef LIBXML_XPATH_ENABLED
2000-04-05 18:38:42 +00:00
/*
2001-12-31 16:16:02 +00:00
* shell interaction
2000-04-05 18:38:42 +00:00
*/
if ( shell )
xmlShell ( doc , filename , xmlShellReadline , stdout ) ;
# endif
2004-11-09 16:17:02 +00:00
# endif
2000-04-05 18:38:42 +00:00
2003-09-29 18:02:38 +00:00
# ifdef LIBXML_TREE_ENABLED
2000-04-05 18:38:42 +00:00
/*
* test intermediate copy if needed .
*/
if ( copy ) {
tmp = doc ;
2004-09-20 20:03:01 +00:00
if ( timing ) {
startTimer ( ) ;
}
2000-04-05 18:38:42 +00:00
doc = xmlCopyDoc ( doc , 1 ) ;
2004-09-20 20:03:01 +00:00
if ( timing ) {
endTimer ( " Copying " ) ;
}
if ( timing ) {
startTimer ( ) ;
}
2000-04-05 18:38:42 +00:00
xmlFreeDoc ( tmp ) ;
2004-09-20 20:03:01 +00:00
if ( timing ) {
endTimer ( " Freeing original " ) ;
}
2000-04-05 18:38:42 +00:00
}
2003-09-29 18:02:38 +00:00
# endif /* LIBXML_TREE_ENABLED */
2000-04-05 18:38:42 +00:00
2003-09-28 18:58:27 +00:00
# ifdef LIBXML_VALID_ENABLED
2000-04-05 18:38:42 +00:00
if ( ( insert ) & & ( ! html ) ) {
const xmlChar * list [ 256 ] ;
int nb , i ;
xmlNodePtr node ;
if ( doc - > children ! = NULL ) {
node = doc - > children ;
while ( ( node ! = NULL ) & & ( node - > last = = NULL ) ) node = node - > next ;
if ( node ! = NULL ) {
nb = xmlValidGetValidElements ( node - > last , NULL , list , 256 ) ;
if ( nb < 0 ) {
2003-12-29 10:31:21 +00:00
fprintf ( stderr , " could not get valid list of elements \n " ) ;
2000-04-05 18:38:42 +00:00
} else if ( nb = = 0 ) {
2003-12-29 10:31:21 +00:00
fprintf ( stderr , " No element can be inserted under root \n " ) ;
2000-04-05 18:38:42 +00:00
} else {
2003-12-29 10:31:21 +00:00
fprintf ( stderr , " %d element types can be inserted under root: \n " ,
2000-04-05 18:38:42 +00:00
nb ) ;
for ( i = 0 ; i < nb ; i + + ) {
2003-12-29 10:31:21 +00:00
fprintf ( stderr , " %s \n " , ( char * ) list [ i ] ) ;
2000-04-05 18:38:42 +00:00
}
}
}
}
2003-09-28 18:58:27 +00:00
} else
# endif /* LIBXML_VALID_ENABLED */
2003-11-03 12:31:38 +00:00
# ifdef LIBXML_READER_ENABLED
if ( walker ) {
walkDoc ( doc ) ;
}
# endif /* LIBXML_READER_ENABLED */
2003-09-29 13:20:24 +00:00
# ifdef LIBXML_OUTPUT_ENABLED
2003-09-28 18:58:27 +00:00
if ( noout = = 0 ) {
2003-12-10 10:17:51 +00:00
int ret ;
2000-04-05 18:38:42 +00:00
/*
* print it .
*/
# ifdef LIBXML_DEBUG_ENABLED
if ( ! debug ) {
# endif
2001-02-25 16:11:03 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 07:09:59 +00:00
startTimer ( ) ;
2001-02-25 16:11:03 +00:00
}
2004-04-30 23:11:45 +00:00
# ifdef LIBXML_HTML_ENABLED
2003-11-04 08:47:48 +00:00
if ( ( html ) & & ( ! xmlout ) ) {
if ( compress ) {
htmlSaveFile ( output ? output : " - " , doc ) ;
}
else if ( encoding ! = NULL ) {
if ( format ) {
htmlSaveFileFormat ( output ? output : " - " , doc , encoding , 1 ) ;
}
else {
htmlSaveFileFormat ( output ? output : " - " , doc , encoding , 0 ) ;
}
}
else if ( format ) {
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 13:29:32 +00:00
progresult = XMLLINT_ERR_OUT ;
2003-11-04 08:47:48 +00:00
if ( output ! = NULL )
fclose ( out ) ;
} else {
fprintf ( stderr , " failed to open %s \n " , output ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_OUT ;
2003-11-04 08:47:48 +00:00
}
}
if ( ( timing ) & & ( ! repeat ) ) {
endTimer ( " Saving " ) ;
}
} else
# endif
2004-08-14 22:37:54 +00:00
# ifdef LIBXML_C14N_ENABLED
if ( canonical ) {
xmlChar * result = NULL ;
int size ;
size = xmlC14NDocDumpMemory ( doc , NULL , 0 , NULL , 1 , & result ) ;
if ( size > = 0 ) {
write ( 1 , result , size ) ;
xmlFree ( result ) ;
} else {
fprintf ( stderr , " Failed to canonicalize \n " ) ;
progresult = XMLLINT_ERR_OUT ;
}
} else
# endif
2001-04-04 00:09:00 +00:00
# ifdef HAVE_SYS_MMAN_H
2000-12-27 10:46:47 +00:00
if ( memory ) {
xmlChar * result ;
int len ;
if ( encoding ! = NULL ) {
2001-11-08 17:32:47 +00:00
if ( format ) {
xmlDocDumpFormatMemoryEnc ( doc , & result , & len , encoding , 1 ) ;
} else {
xmlDocDumpMemoryEnc ( doc , & result , & len , encoding ) ;
}
2000-12-27 10:46:47 +00:00
} else {
2001-08-14 14:12:47 +00:00
if ( format )
xmlDocDumpFormatMemory ( doc , & result , & len , 1 ) ;
else
xmlDocDumpMemory ( doc , & result , & len ) ;
2000-12-27 10:46:47 +00:00
}
if ( result = = NULL ) {
fprintf ( stderr , " Failed to save \n " ) ;
2004-08-14 22:37:54 +00:00
progresult = XMLLINT_ERR_OUT ;
2000-12-27 10:46:47 +00:00
} else {
write ( 1 , result , len ) ;
xmlFree ( result ) ;
}
2001-04-04 00:09:00 +00:00
} else
# endif /* HAVE_SYS_MMAN_H */
2001-12-18 11:14:16 +00:00
if ( compress ) {
xmlSaveFile ( output ? output : " - " , doc ) ;
}
2001-11-08 17:32:47 +00:00
else if ( encoding ! = NULL ) {
if ( format ) {
2003-12-10 10:17:51 +00:00
ret = xmlSaveFormatFileEnc ( output ? output : " - " , doc ,
encoding , 1 ) ;
2001-12-18 11:14:16 +00:00
}
else {
2003-12-10 10:17:51 +00:00
ret = xmlSaveFileEnc ( output ? output : " - " , doc , encoding ) ;
}
if ( ret < 0 ) {
fprintf ( stderr , " failed save to %s \n " ,
output ? output : " - " ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_OUT ;
2001-12-18 11:14:16 +00:00
}
}
else if ( format ) {
2003-12-10 10:17:51 +00:00
ret = xmlSaveFormatFile ( output ? output : " - " , doc , 1 ) ;
if ( ret < 0 ) {
fprintf ( stderr , " failed save to %s \n " ,
output ? output : " - " ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_OUT ;
2003-12-10 10:17:51 +00:00
}
2001-12-18 11:14:16 +00:00
}
else {
FILE * out ;
if ( output = = NULL )
out = stdout ;
2001-11-08 17:32:47 +00:00
else {
2001-12-18 11:14:16 +00:00
out = fopen ( output , " wb " ) ;
2001-11-08 17:32:47 +00:00
}
2003-10-08 11:54:57 +00:00
if ( out ! = NULL ) {
2003-10-08 19:19:10 +00:00
if ( xmlDocDump ( out , doc ) < 0 )
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_OUT ;
2001-12-18 11:14:16 +00:00
2003-10-08 11:54:57 +00:00
if ( output ! = NULL )
fclose ( out ) ;
} else {
fprintf ( stderr , " failed to open %s \n " , output ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_OUT ;
2003-10-08 11:54:57 +00:00
}
2001-11-08 17:32:47 +00:00
}
2001-02-25 16:11:03 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 07:09:59 +00:00
endTimer ( " Saving " ) ;
2001-02-25 16:11:03 +00:00
}
2000-04-05 18:38:42 +00:00
# ifdef LIBXML_DEBUG_ENABLED
2000-12-27 10:46:47 +00:00
} else {
2001-12-18 11:14:16 +00:00
FILE * out ;
if ( output = = NULL )
out = stdout ;
else {
out = fopen ( output , " wb " ) ;
}
2003-10-08 11:54:57 +00:00
if ( out ! = NULL ) {
xmlDebugDumpDocument ( out , doc ) ;
2001-12-18 11:14:16 +00:00
2003-10-08 11:54:57 +00:00
if ( output ! = NULL )
fclose ( out ) ;
} else {
fprintf ( stderr , " failed to open %s \n " , output ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_OUT ;
2003-10-08 11:54:57 +00:00
}
2000-12-27 10:46:47 +00:00
}
2000-04-05 18:38:42 +00:00
# endif
}
2003-09-29 13:20:24 +00:00
# endif /* LIBXML_OUTPUT_ENABLED */
2000-04-05 18:38:42 +00:00
2003-09-28 18:58:27 +00:00
# ifdef LIBXML_VALID_ENABLED
2000-04-05 18:38:42 +00:00
/*
* A posteriori validation test
*/
2003-08-18 16:39:51 +00:00
if ( ( dtdvalid ! = NULL ) | | ( dtdvalidfpi ! = NULL ) ) {
2000-10-11 15:57:05 +00:00
xmlDtdPtr dtd ;
2001-02-25 16:11:03 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 07:09:59 +00:00
startTimer ( ) ;
2001-02-25 16:11:03 +00:00
}
2003-08-18 16:39:51 +00:00
if ( dtdvalid ! = NULL )
dtd = xmlParseDTD ( NULL , ( const xmlChar * ) dtdvalid ) ;
else
dtd = xmlParseDTD ( ( const xmlChar * ) dtdvalidfpi , NULL ) ;
2001-02-25 16:11:03 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 07:09:59 +00:00
endTimer ( " Parsing DTD " ) ;
2001-02-25 16:11:03 +00:00
}
2000-10-11 15:57:05 +00:00
if ( dtd = = NULL ) {
2003-08-18 16:39:51 +00:00
if ( dtdvalid ! = NULL )
xmlGenericError ( xmlGenericErrorContext ,
" Could not parse DTD %s \n " , dtdvalid ) ;
else
xmlGenericError ( xmlGenericErrorContext ,
" Could not parse DTD %s \n " , dtdvalidfpi ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_DTD ;
2000-10-11 15:57:05 +00:00
} else {
2003-06-09 09:10:36 +00:00
xmlValidCtxtPtr cvp ;
if ( ( cvp = xmlNewValidCtxt ( ) ) = = NULL ) {
xmlGenericError ( xmlGenericErrorContext ,
" Couldn't allocate validation context \n " ) ;
exit ( - 1 ) ;
}
cvp - > userData = ( void * ) stderr ;
cvp - > error = ( xmlValidityErrorFunc ) fprintf ;
cvp - > warning = ( xmlValidityWarningFunc ) fprintf ;
2001-02-25 16:11:03 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 07:09:59 +00:00
startTimer ( ) ;
2001-02-25 16:11:03 +00:00
}
2003-06-09 09:10:36 +00:00
if ( ! xmlValidateDtd ( cvp , doc , dtd ) ) {
2003-08-18 16:39:51 +00:00
if ( dtdvalid ! = NULL )
xmlGenericError ( xmlGenericErrorContext ,
" Document %s does not validate against %s \n " ,
filename , dtdvalid ) ;
else
xmlGenericError ( xmlGenericErrorContext ,
" Document %s does not validate against %s \n " ,
filename , dtdvalidfpi ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_VALID ;
2000-10-11 15:57:05 +00:00
}
2001-02-25 16:11:03 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 07:09:59 +00:00
endTimer ( " Validating against DTD " ) ;
2001-02-25 16:11:03 +00:00
}
2003-06-09 09:10:36 +00:00
xmlFreeValidCtxt ( cvp ) ;
2000-10-11 15:57:05 +00:00
xmlFreeDtd ( dtd ) ;
}
} else if ( postvalid ) {
2003-06-09 09:10:36 +00:00
xmlValidCtxtPtr cvp ;
if ( ( cvp = xmlNewValidCtxt ( ) ) = = NULL ) {
xmlGenericError ( xmlGenericErrorContext ,
" Couldn't allocate validation context \n " ) ;
exit ( - 1 ) ;
}
2001-02-25 16:11:03 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 07:09:59 +00:00
startTimer ( ) ;
2001-02-25 16:11:03 +00:00
}
2003-06-09 09:10:36 +00:00
cvp - > userData = ( void * ) stderr ;
cvp - > error = ( xmlValidityErrorFunc ) fprintf ;
cvp - > warning = ( xmlValidityWarningFunc ) fprintf ;
if ( ! xmlValidateDocument ( cvp , doc ) ) {
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext ,
" Document %s does not validate \n " , filename ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_VALID ;
2000-10-11 15:57:05 +00:00
}
2001-02-25 16:11:03 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 07:09:59 +00:00
endTimer ( " Validating " ) ;
2001-02-25 16:11:03 +00:00
}
2003-06-09 09:10:36 +00:00
xmlFreeValidCtxt ( cvp ) ;
2003-09-28 18:58:27 +00:00
}
# endif /* LIBXML_VALID_ENABLED */
2003-02-05 13:19:53 +00:00
# ifdef LIBXML_SCHEMAS_ENABLED
2003-09-28 18:58:27 +00:00
if ( relaxngschemas ! = NULL ) {
2003-02-05 13:19:53 +00:00
xmlRelaxNGValidCtxtPtr ctxt ;
int ret ;
2003-03-07 18:32:59 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
startTimer ( ) ;
}
2003-02-05 13:19:53 +00:00
ctxt = xmlRelaxNGNewValidCtxt ( relaxngschemas ) ;
xmlRelaxNGSetValidErrors ( ctxt ,
( xmlRelaxNGValidityErrorFunc ) fprintf ,
( xmlRelaxNGValidityWarningFunc ) fprintf ,
stderr ) ;
ret = xmlRelaxNGValidateDoc ( ctxt , doc ) ;
if ( ret = = 0 ) {
2003-12-29 10:31:21 +00:00
fprintf ( stderr , " %s validates \n " , filename ) ;
2003-02-05 13:19:53 +00:00
} else if ( ret > 0 ) {
2003-12-29 10:31:21 +00:00
fprintf ( stderr , " %s fails to validate \n " , filename ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_VALID ;
2003-02-05 13:19:53 +00:00
} else {
2003-12-29 10:31:21 +00:00
fprintf ( stderr , " %s validation generated an internal error \n " ,
2003-02-05 13:19:53 +00:00
filename ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_VALID ;
2003-02-05 13:19:53 +00:00
}
xmlRelaxNGFreeValidCtxt ( ctxt ) ;
2003-03-07 18:32:59 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
endTimer ( " Validating " ) ;
}
2003-05-12 15:25:56 +00:00
} else if ( wxschemas ! = NULL ) {
xmlSchemaValidCtxtPtr ctxt ;
int ret ;
if ( ( timing ) & & ( ! repeat ) ) {
startTimer ( ) ;
}
ctxt = xmlSchemaNewValidCtxt ( wxschemas ) ;
xmlSchemaSetValidErrors ( ctxt ,
( xmlSchemaValidityErrorFunc ) fprintf ,
( xmlSchemaValidityWarningFunc ) fprintf ,
stderr ) ;
ret = xmlSchemaValidateDoc ( ctxt , doc ) ;
if ( ret = = 0 ) {
2003-12-29 10:31:21 +00:00
fprintf ( stderr , " %s validates \n " , filename ) ;
2003-05-12 15:25:56 +00:00
} else if ( ret > 0 ) {
2003-12-29 10:31:21 +00:00
fprintf ( stderr , " %s fails to validate \n " , filename ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_VALID ;
2003-05-12 15:25:56 +00:00
} else {
2003-12-29 10:31:21 +00:00
fprintf ( stderr , " %s validation generated an internal error \n " ,
2003-05-12 15:25:56 +00:00
filename ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_VALID ;
2003-05-12 15:25:56 +00:00
}
xmlSchemaFreeValidCtxt ( ctxt ) ;
if ( ( timing ) & & ( ! repeat ) ) {
endTimer ( " Validating " ) ;
}
2000-04-05 18:38:42 +00:00
}
2003-09-28 18:58:27 +00:00
# endif
2000-04-05 18:38:42 +00:00
# ifdef LIBXML_DEBUG_ENABLED
if ( ( debugent ) & & ( ! html ) )
2000-08-26 21:40:43 +00:00
xmlDebugDumpEntities ( stderr , doc ) ;
2000-04-05 18:38:42 +00:00
# endif
/*
* free it .
*/
2001-02-25 16:11:03 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 07:09:59 +00:00
startTimer ( ) ;
2001-02-25 16:11:03 +00:00
}
2000-04-05 18:38:42 +00:00
xmlFreeDoc ( doc ) ;
2001-02-25 16:11:03 +00:00
if ( ( timing ) & & ( ! repeat ) ) {
2001-12-18 07:09:59 +00:00
endTimer ( " Freeing " ) ;
2001-02-25 16:11:03 +00:00
}
2000-04-05 18:38:42 +00:00
}
2001-06-20 13:55:33 +00:00
/************************************************************************
* *
* Usage and Main *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-09-17 23:04:40 +00:00
static void showVersion ( const char * name ) {
fprintf ( stderr , " %s: using libxml version %s \n " , name , xmlParserVersion ) ;
fprintf ( stderr , " compiled with: " ) ;
2003-09-28 18:58:27 +00:00
# ifdef LIBXML_VALID_ENABLED
fprintf ( stderr , " DTDValid " ) ;
# endif
2002-09-17 23:04:40 +00:00
# ifdef LIBXML_FTP_ENABLED
fprintf ( stderr , " FTP " ) ;
# endif
# ifdef LIBXML_HTTP_ENABLED
fprintf ( stderr , " HTTP " ) ;
# endif
# ifdef LIBXML_HTML_ENABLED
fprintf ( stderr , " HTML " ) ;
# endif
# ifdef LIBXML_C14N_ENABLED
fprintf ( stderr , " C14N " ) ;
# endif
# ifdef LIBXML_CATALOG_ENABLED
fprintf ( stderr , " Catalog " ) ;
# endif
# ifdef LIBXML_XPATH_ENABLED
fprintf ( stderr , " XPath " ) ;
# endif
# ifdef LIBXML_XPTR_ENABLED
fprintf ( stderr , " XPointer " ) ;
# endif
# ifdef LIBXML_XINCLUDE_ENABLED
fprintf ( stderr , " XInclude " ) ;
# endif
# ifdef LIBXML_ICONV_ENABLED
fprintf ( stderr , " Iconv " ) ;
# endif
# ifdef DEBUG_MEMORY_LOCATION
fprintf ( stderr , " MemDebug " ) ;
# endif
# ifdef LIBXML_UNICODE_ENABLED
fprintf ( stderr , " Unicode " ) ;
# endif
# ifdef LIBXML_REGEXP_ENABLED
fprintf ( stderr , " Regexps " ) ;
# endif
# ifdef LIBXML_AUTOMATA_ENABLED
fprintf ( stderr , " Automata " ) ;
# endif
# ifdef LIBXML_SCHEMAS_ENABLED
fprintf ( stderr , " Schemas " ) ;
2005-01-04 15:10:22 +00:00
# endif
# ifdef LIBXML_MODULES_ENABLED
fprintf ( stderr , " Modules " ) ;
2002-09-17 23:04:40 +00:00
# endif
fprintf ( stderr , " \n " ) ;
}
2001-06-20 13:55:33 +00:00
static void usage ( const char * name ) {
printf ( " Usage : %s [options] XMLfiles ... \n " , name ) ;
2003-09-29 13:20:24 +00:00
# ifdef LIBXML_OUTPUT_ENABLED
2001-06-20 13:55:33 +00:00
printf ( " \t Parse the XML files and output the result of the parsing \n " ) ;
2003-09-29 13:20:24 +00:00
# else
printf ( " \t Parse the XML files \n " ) ;
# endif /* LIBXML_OUTPUT_ENABLED */
2001-06-20 13:55:33 +00:00
printf ( " \t --version : display the version of the XML library used \n " ) ;
# ifdef LIBXML_DEBUG_ENABLED
printf ( " \t --debug : dump a debug tree of the in-memory document \n " ) ;
printf ( " \t --shell : run a navigating shell \n " ) ;
printf ( " \t --debugent : debug the entities defined in the document \n " ) ;
2003-01-07 00:19:07 +00:00
# else
2003-09-30 00:43:48 +00:00
# ifdef LIBXML_READER_ENABLED
2003-01-07 00:19:07 +00:00
printf ( " \t --debug : dump the nodes content when using --stream \n " ) ;
2003-09-30 00:43:48 +00:00
# endif /* LIBXML_READER_ENABLED */
2001-06-20 13:55:33 +00:00
# endif
2003-09-29 18:02:38 +00:00
# ifdef LIBXML_TREE_ENABLED
2001-06-20 13:55:33 +00:00
printf ( " \t --copy : used to test the internal copy implementation \n " ) ;
2003-09-29 18:02:38 +00:00
# endif /* LIBXML_TREE_ENABLED */
2001-06-20 13:55:33 +00:00
printf ( " \t --recover : output what was parsable on broken XML documents \n " ) ;
printf ( " \t --noent : substitute entity references by their value \n " ) ;
printf ( " \t --noout : don't output the result tree \n " ) ;
2004-08-31 09:37:03 +00:00
printf ( " \t --path 'paths': provide a set of paths for resources \n " ) ;
printf ( " \t --load-trace : print trace of all external entites loaded \n " ) ;
2003-05-13 22:14:13 +00:00
printf ( " \t --nonet : refuse to fetch DTDs or entities over network \n " ) ;
2001-06-20 13:55:33 +00:00
printf ( " \t --htmlout : output results as HTML \n " ) ;
2001-09-09 08:38:09 +00:00
printf ( " \t --nowrap : do not put HTML doc wrapper \n " ) ;
2003-09-28 18:58:27 +00:00
# ifdef LIBXML_VALID_ENABLED
2001-06-20 13:55:33 +00:00
printf ( " \t --valid : validate the document in addition to std well-formed check \n " ) ;
printf ( " \t --postvalid : do a posteriori validation, i.e after parsing \n " ) ;
printf ( " \t --dtdvalid URL : do a posteriori validation against a given DTD \n " ) ;
2003-08-18 16:39:51 +00:00
printf ( " \t --dtdvalidfpi FPI : same but name the DTD with a Public Identifier \n " ) ;
2003-09-28 18:58:27 +00:00
# endif /* LIBXML_VALID_ENABLED */
2001-06-20 13:55:33 +00:00
printf ( " \t --timing : print some timings \n " ) ;
2001-12-18 11:14:16 +00:00
printf ( " \t --output file or -o file: save to a given file \n " ) ;
2001-06-20 13:55:33 +00:00
printf ( " \t --repeat : repeat 100 times, for timing or profiling \n " ) ;
printf ( " \t --insert : ad-hoc test for valid insertions \n " ) ;
2003-09-29 13:20:24 +00:00
# ifdef LIBXML_OUTPUT_ENABLED
2001-12-18 11:14:16 +00:00
# ifdef HAVE_ZLIB_H
2001-06-20 13:55:33 +00:00
printf ( " \t --compress : turn on gzip compression of output \n " ) ;
2001-12-18 11:14:16 +00:00
# endif
2003-09-29 13:20:24 +00:00
# endif /* LIBXML_OUTPUT_ENABLED */
2001-06-20 13:55:33 +00:00
# ifdef LIBXML_HTML_ENABLED
printf ( " \t --html : use the HTML parser \n " ) ;
2003-11-04 08:47:48 +00:00
printf ( " \t --xmlout : force to use the XML serializer when using --html \n " ) ;
2001-06-20 13:55:33 +00:00
# endif
2003-09-30 12:36:01 +00:00
# ifdef LIBXML_PUSH_ENABLED
2001-06-20 13:55:33 +00:00
printf ( " \t --push : use the push mode of the parser \n " ) ;
2003-09-30 12:36:01 +00:00
# endif /* LIBXML_PUSH_ENABLED */
2001-06-20 13:55:33 +00:00
# ifdef HAVE_SYS_MMAN_H
printf ( " \t --memory : parse from memory \n " ) ;
# endif
2004-05-03 22:54:49 +00:00
printf ( " \t --maxmem nbbytes : limits memory allocation to nbbytes bytes \n " ) ;
2001-06-20 13:55:33 +00:00
printf ( " \t --nowarning : do not emit warnings from parser/validator \n " ) ;
printf ( " \t --noblanks : drop (ignorable?) blanks spaces \n " ) ;
2003-09-26 13:53:14 +00:00
printf ( " \t --nocdata : replace cdata section with text nodes \n " ) ;
2003-09-29 13:20:24 +00:00
# ifdef LIBXML_OUTPUT_ENABLED
2001-08-14 14:12:47 +00:00
printf ( " \t --format : reformat/reindent the input \n " ) ;
2001-06-20 13:55:33 +00:00
printf ( " \t --encode encoding : output in the given encoding \n " ) ;
2003-09-29 13:20:24 +00:00
printf ( " \t --dropdtd : remove the DOCTYPE of the input docs \n " ) ;
# endif /* LIBXML_OUTPUT_ENABLED */
2004-08-14 22:37:54 +00:00
printf ( " \t --c14n: save in W3C canonical format (with comments) \n " ) ;
# ifdef LIBXML_C14N_ENABLED
# endif /* LIBXML_C14N_ENABLED */
2003-09-29 13:20:24 +00:00
printf ( " \t --nsclean : remove redundant namespace declarations \n " ) ;
printf ( " \t --testIO : test user I/O support \n " ) ;
2001-06-20 13:55:33 +00:00
# ifdef LIBXML_CATALOG_ENABLED
2001-11-26 10:32:08 +00:00
printf ( " \t --catalogs : use SGML catalogs from $SGML_CATALOG_FILES \n " ) ;
printf ( " \t otherwise XML Catalogs starting from \n " ) ;
2003-12-02 22:32:15 +00:00
printf ( " \t %s are activated by default \n " , XML_XML_DEFAULT_CATALOG ) ;
2001-09-09 08:38:09 +00:00
printf ( " \t --nocatalogs: deactivate all catalogs \n " ) ;
2001-06-20 13:55:33 +00:00
# endif
printf ( " \t --auto : generate a small doc on the fly \n " ) ;
# ifdef LIBXML_XINCLUDE_ENABLED
printf ( " \t --xinclude : do XInclude processing \n " ) ;
2004-08-16 12:34:50 +00:00
printf ( " \t --noxincludenode : same but do not generate XInclude nodes \n " ) ;
2001-06-20 13:55:33 +00:00
# endif
2001-12-31 16:16:02 +00:00
printf ( " \t --loaddtd : fetch external DTD \n " ) ;
2001-08-07 01:10:10 +00:00
printf ( " \t --dtdattr : loaddtd + populate the tree with inherited attributes \n " ) ;
2003-09-30 00:43:48 +00:00
# ifdef LIBXML_READER_ENABLED
2003-01-03 16:19:51 +00:00
printf ( " \t --stream : use the streaming interface to process very large files \n " ) ;
2003-11-03 12:31:38 +00:00
printf ( " \t --walker : create a reader and walk though the resulting doc \n " ) ;
2003-09-30 00:43:48 +00:00
# endif /* LIBXML_READER_ENABLED */
2003-12-02 22:32:15 +00:00
# ifdef LIBXML_PATTERN_ENABLED
printf ( " \t --pattern pattern_value : test the pattern support \n " ) ;
# endif
2003-01-05 22:37:17 +00:00
printf ( " \t --chkregister : verify the node registration code \n " ) ;
2003-02-07 12:38:22 +00:00
# ifdef LIBXML_SCHEMAS_ENABLED
2003-02-05 13:19:53 +00:00
printf ( " \t --relaxng schema : do RelaxNG validation against the schema \n " ) ;
2003-05-12 15:25:56 +00:00
printf ( " \t --schema schema : do validation against the WXS schema \n " ) ;
2003-02-05 13:19:53 +00:00
# endif
2002-01-25 14:15:40 +00:00
printf ( " \n Libxml project home page: http://xmlsoft.org/ \n " ) ;
printf ( " To report bugs or get some help check: http://xmlsoft.org/bugs.html \n " ) ;
2001-06-20 13:55:33 +00:00
}
2003-01-05 22:37:17 +00:00
static void registerNode ( xmlNodePtr node )
{
node - > _private = malloc ( sizeof ( long ) ) ;
* ( long * ) node - > _private = ( long ) 0x81726354 ;
2004-04-30 22:25:59 +00:00
nbregister + + ;
2003-01-05 22:37:17 +00:00
}
static void deregisterNode ( xmlNodePtr node )
{
assert ( node - > _private ! = NULL ) ;
assert ( * ( long * ) node - > _private = = ( long ) 0x81726354 ) ;
free ( node - > _private ) ;
2004-04-30 22:25:59 +00:00
nbregister - - ;
2003-01-05 22:37:17 +00:00
}
2001-01-03 13:32:39 +00:00
int
main ( int argc , char * * argv ) {
2003-01-03 16:19:51 +00:00
int i , acount ;
2000-04-05 18:38:42 +00:00
int files = 0 ;
2002-01-09 11:51:37 +00:00
int version = 0 ;
2003-03-09 22:36:52 +00:00
const char * indent ;
2001-06-20 13:55:33 +00:00
if ( argc < = 1 ) {
usage ( argv [ 0 ] ) ;
return ( 1 ) ;
}
2000-06-28 23:40:59 +00:00
LIBXML_TEST_VERSION
2000-04-05 18:38:42 +00:00
for ( i = 1 ; i < argc ; i + + ) {
2001-06-20 13:55:33 +00:00
if ( ! strcmp ( argv [ i ] , " - " ) )
break ;
if ( argv [ i ] [ 0 ] ! = ' - ' )
continue ;
2000-04-05 18:38:42 +00:00
if ( ( ! strcmp ( argv [ i ] , " -debug " ) ) | | ( ! strcmp ( argv [ i ] , " --debug " ) ) )
debug + + ;
2003-01-07 11:17:25 +00:00
else
# ifdef LIBXML_DEBUG_ENABLED
if ( ( ! strcmp ( argv [ i ] , " -shell " ) ) | |
2000-04-05 18:38:42 +00:00
( ! strcmp ( argv [ i ] , " --shell " ) ) ) {
shell + + ;
noout = 1 ;
} else
# endif
2003-09-29 18:02:38 +00:00
# ifdef LIBXML_TREE_ENABLED
2000-04-05 18:38:42 +00:00
if ( ( ! strcmp ( argv [ i ] , " -copy " ) ) | | ( ! strcmp ( argv [ i ] , " --copy " ) ) )
copy + + ;
2003-09-29 18:02:38 +00:00
else
# endif /* LIBXML_TREE_ENABLED */
if ( ( ! strcmp ( argv [ i ] , " -recover " ) ) | |
2003-09-23 21:50:54 +00:00
( ! strcmp ( argv [ i ] , " --recover " ) ) ) {
2000-04-05 18:38:42 +00:00
recovery + + ;
2003-09-23 21:50:54 +00:00
options | = XML_PARSE_RECOVER ;
} else if ( ( ! strcmp ( argv [ i ] , " -noent " ) ) | |
( ! strcmp ( argv [ i ] , " --noent " ) ) ) {
2000-04-05 18:38:42 +00:00
noent + + ;
2003-09-23 21:50:54 +00:00
options | = XML_PARSE_NOENT ;
2003-09-26 13:53:14 +00: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-24 21:23:56 +00:00
} else if ( ( ! strcmp ( argv [ i ] , " -nodict " ) ) | |
( ! strcmp ( argv [ i ] , " --nodict " ) ) ) {
options | = XML_PARSE_NODICT ;
2003-09-23 21:50:54 +00:00
} else if ( ( ! strcmp ( argv [ i ] , " -version " ) ) | |
2002-01-09 11:51:37 +00:00
( ! strcmp ( argv [ i ] , " --version " ) ) ) {
2002-09-17 23:04:40 +00:00
showVersion ( argv [ 0 ] ) ;
2002-01-09 11:51:37 +00:00
version = 1 ;
} else if ( ( ! strcmp ( argv [ i ] , " -noout " ) ) | |
2000-04-05 18:38:42 +00:00
( ! strcmp ( argv [ i ] , " --noout " ) ) )
noout + + ;
2003-09-29 13:20:24 +00:00
# ifdef LIBXML_OUTPUT_ENABLED
2001-12-18 11:14:16 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -o " ) ) | |
( ! strcmp ( argv [ i ] , " -output " ) ) | |
( ! strcmp ( argv [ i ] , " --output " ) ) ) {
i + + ;
2002-04-09 09:55:20 +00:00
output = argv [ i ] ;
2001-12-18 11:14:16 +00:00
}
2003-09-29 13:20:24 +00:00
# endif /* LIBXML_OUTPUT_ENABLED */
2000-04-05 18:38:42 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -htmlout " ) ) | |
( ! strcmp ( argv [ i ] , " --htmlout " ) ) )
htmlout + + ;
2003-09-29 13:20:24 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -nowrap " ) ) | |
( ! strcmp ( argv [ i ] , " --nowrap " ) ) )
nowrap + + ;
2000-04-05 18:38:42 +00:00
# ifdef LIBXML_HTML_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -html " ) ) | |
( ! strcmp ( argv [ i ] , " --html " ) ) ) {
html + + ;
}
2003-11-04 08:47:48 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -xmlout " ) ) | |
( ! strcmp ( argv [ i ] , " --xmlout " ) ) ) {
xmlout + + ;
}
2000-04-05 18:38:42 +00:00
# endif /* LIBXML_HTML_ENABLED */
2001-06-20 13:55:33 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -loaddtd " ) ) | |
2003-09-23 21:50:54 +00:00
( ! strcmp ( argv [ i ] , " --loaddtd " ) ) ) {
2001-06-20 13:55:33 +00:00
loaddtd + + ;
2003-09-23 21:50:54 +00:00
options | = XML_PARSE_DTDLOAD ;
} else if ( ( ! strcmp ( argv [ i ] , " -dtdattr " ) ) | |
2001-08-07 01:10:10 +00:00
( ! strcmp ( argv [ i ] , " --dtdattr " ) ) ) {
loaddtd + + ;
dtdattrs + + ;
2003-09-23 21:50:54 +00:00
options | = XML_PARSE_DTDATTR ;
2003-09-28 18:58:27 +00:00
}
# ifdef LIBXML_VALID_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -valid " ) ) | |
2003-09-23 21:50:54 +00:00
( ! strcmp ( argv [ i ] , " --valid " ) ) ) {
2000-04-05 18:38:42 +00:00
valid + + ;
2003-09-23 21:50:54 +00:00
options | = XML_PARSE_DTDVALID ;
} else if ( ( ! strcmp ( argv [ i ] , " -postvalid " ) ) | |
2001-06-20 13:55:33 +00:00
( ! strcmp ( argv [ i ] , " --postvalid " ) ) ) {
2000-04-05 18:38:42 +00:00
postvalid + + ;
2001-06-20 13:55:33 +00:00
loaddtd + + ;
2003-12-09 13:54:39 +00:00
options | = XML_PARSE_DTDLOAD ;
2001-06-20 13:55:33 +00:00
} else if ( ( ! strcmp ( argv [ i ] , " -dtdvalid " ) ) | |
2000-10-11 15:57:05 +00:00
( ! strcmp ( argv [ i ] , " --dtdvalid " ) ) ) {
i + + ;
dtdvalid = argv [ i ] ;
2001-06-20 13:55:33 +00:00
loaddtd + + ;
2003-12-09 13:54:39 +00:00
options | = XML_PARSE_DTDLOAD ;
2003-08-18 16:39:51 +00:00
} else if ( ( ! strcmp ( argv [ i ] , " -dtdvalidfpi " ) ) | |
( ! strcmp ( argv [ i ] , " --dtdvalidfpi " ) ) ) {
i + + ;
dtdvalidfpi = argv [ i ] ;
loaddtd + + ;
2003-12-09 13:54:39 +00:00
options | = XML_PARSE_DTDLOAD ;
2000-10-11 15:57:05 +00:00
}
2003-09-28 18:58:27 +00:00
# endif /* LIBXML_VALID_ENABLED */
2001-12-13 22:21:58 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -dropdtd " ) ) | |
( ! strcmp ( argv [ i ] , " --dropdtd " ) ) )
dropdtd + + ;
2000-04-05 18:38:42 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -insert " ) ) | |
( ! strcmp ( argv [ i ] , " --insert " ) ) )
insert + + ;
2001-02-25 16:11:03 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -timing " ) ) | |
( ! strcmp ( argv [ i ] , " --timing " ) ) )
timing + + ;
2001-04-11 07:50:02 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -auto " ) ) | |
( ! strcmp ( argv [ i ] , " --auto " ) ) )
generate + + ;
2000-04-05 18:38:42 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -repeat " ) ) | |
2003-09-17 19:36:25 +00:00
( ! strcmp ( argv [ i ] , " --repeat " ) ) ) {
if ( repeat )
repeat * = 10 ;
else
repeat = 100 ;
2003-09-30 12:36:01 +00:00
}
# ifdef LIBXML_PUSH_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -push " ) ) | |
2000-04-05 18:38:42 +00:00
( ! strcmp ( argv [ i ] , " --push " ) ) )
push + + ;
2003-09-30 12:36:01 +00:00
# endif /* LIBXML_PUSH_ENABLED */
2000-07-21 20:32:03 +00:00
# ifdef HAVE_SYS_MMAN_H
else if ( ( ! strcmp ( argv [ i ] , " -memory " ) ) | |
( ! strcmp ( argv [ i ] , " --memory " ) ) )
memory + + ;
# endif
2000-04-12 13:27:38 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -testIO " ) ) | |
( ! strcmp ( argv [ i ] , " --testIO " ) ) )
testIO + + ;
2000-11-06 16:43:11 +00:00
# ifdef LIBXML_XINCLUDE_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -xinclude " ) ) | |
2003-09-23 21:50:54 +00:00
( ! strcmp ( argv [ i ] , " --xinclude " ) ) ) {
2000-11-06 16:43:11 +00:00
xinclude + + ;
2003-11-03 12:31:38 +00:00
options | = XML_PARSE_XINCLUDE ;
2003-09-23 21:50:54 +00:00
}
2004-08-16 12:34:50 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -noxincludenode " ) ) | |
( ! strcmp ( argv [ i ] , " --noxincludenode " ) ) ) {
xinclude + + ;
options | = XML_PARSE_XINCLUDE ;
options | = XML_PARSE_NOXINCNODE ;
}
2000-11-06 16:43:11 +00:00
# endif
2003-09-29 13:20:24 +00:00
# ifdef LIBXML_OUTPUT_ENABLED
2001-12-18 11:14:16 +00:00
# ifdef HAVE_ZLIB_H
2000-04-05 18:38:42 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -compress " ) ) | |
( ! strcmp ( argv [ i ] , " --compress " ) ) ) {
compress + + ;
xmlSetCompressMode ( 9 ) ;
}
2001-12-18 11:14:16 +00:00
# endif
2003-09-29 13:20:24 +00:00
# endif /* LIBXML_OUTPUT_ENABLED */
2000-04-05 18:38:42 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -nowarning " ) ) | |
( ! strcmp ( argv [ i ] , " --nowarning " ) ) ) {
xmlGetWarningsDefaultValue = 0 ;
2000-08-26 21:40:43 +00:00
xmlPedanticParserDefault ( 0 ) ;
2003-09-23 21:50:54 +00:00
options | = XML_PARSE_NOWARNING ;
2000-08-26 21:40:43 +00:00
}
else if ( ( ! strcmp ( argv [ i ] , " -pedantic " ) ) | |
( ! strcmp ( argv [ i ] , " --pedantic " ) ) ) {
xmlGetWarningsDefaultValue = 1 ;
xmlPedanticParserDefault ( 1 ) ;
2003-09-23 21:50:54 +00:00
options | = XML_PARSE_PEDANTIC ;
2000-04-05 18:38:42 +00:00
}
2000-09-22 16:07:02 +00:00
# ifdef LIBXML_DEBUG_ENABLED
2000-08-26 21:40:43 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -debugent " ) ) | |
( ! strcmp ( argv [ i ] , " --debugent " ) ) ) {
debugent + + ;
xmlParserDebugEntities = 1 ;
}
2001-05-22 15:08:55 +00:00
# endif
2004-08-14 22:37:54 +00: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 ;
}
# endif
2001-05-22 15:08:55 +00:00
# ifdef LIBXML_CATALOG_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -catalogs " ) ) | |
( ! strcmp ( argv [ i ] , " --catalogs " ) ) ) {
2001-08-22 00:06:49 +00:00
catalogs + + ;
} else if ( ( ! strcmp ( argv [ i ] , " -nocatalogs " ) ) | |
( ! strcmp ( argv [ i ] , " --nocatalogs " ) ) ) {
nocatalogs + + ;
2001-05-22 15:08:55 +00:00
}
2000-09-22 16:07:02 +00:00
# endif
2000-06-28 23:40:59 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -encode " ) ) | |
( ! strcmp ( argv [ i ] , " --encode " ) ) ) {
i + + ;
encoding = argv [ i ] ;
2000-08-26 21:40:43 +00:00
/*
* OK it ' s for testing purposes
*/
xmlAddEncodingAlias ( " UTF-8 " , " DVEnc " ) ;
2000-06-28 23:40:59 +00:00
}
2000-04-05 18:38:42 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -noblanks " ) ) | |
( ! strcmp ( argv [ i ] , " --noblanks " ) ) ) {
noblanks + + ;
xmlKeepBlanksDefault ( 0 ) ;
2001-08-14 14:12:47 +00:00
}
2004-05-03 22:54:49 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -maxmem " ) ) | |
( ! strcmp ( argv [ i ] , " --maxmem " ) ) ) {
i + + ;
if ( sscanf ( argv [ i ] , " %d " , & maxmem ) = = 1 ) {
xmlMemSetup ( myFreeFunc , myMallocFunc , myReallocFunc ,
myStrdupFunc ) ;
} else {
maxmem = 0 ;
}
}
2001-08-14 14:12:47 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -format " ) ) | |
( ! strcmp ( argv [ i ] , " --format " ) ) ) {
noblanks + + ;
2003-09-29 13:20:24 +00:00
# ifdef LIBXML_OUTPUT_ENABLED
2001-08-14 14:12:47 +00:00
format + + ;
2003-09-29 13:20:24 +00:00
# endif /* LIBXML_OUTPUT_ENABLED */
2001-08-14 14:12:47 +00:00
xmlKeepBlanksDefault ( 0 ) ;
2003-01-03 16:19:51 +00:00
}
2003-09-30 00:43:48 +00:00
# ifdef LIBXML_READER_ENABLED
2003-01-03 16:19:51 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -stream " ) ) | |
( ! strcmp ( argv [ i ] , " --stream " ) ) ) {
stream + + ;
2003-01-05 22:37:17 +00:00
}
2003-11-03 12:31:38 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -walker " ) ) | |
( ! strcmp ( argv [ i ] , " --walker " ) ) ) {
walker + + ;
noout + + ;
}
2003-09-30 00:43:48 +00:00
# endif /* LIBXML_READER_ENABLED */
# ifdef LIBXML_SAX1_ENABLED
2003-09-10 10:51:05 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -sax1 " ) ) | |
( ! strcmp ( argv [ i ] , " --sax1 " ) ) ) {
sax1 + + ;
}
2003-09-30 00:43:48 +00:00
# endif /* LIBXML_SAX1_ENABLED */
2003-01-05 22:37:17 +00:00
else if ( ( ! strcmp ( argv [ i ] , " -chkregister " ) ) | |
( ! strcmp ( argv [ i ] , " --chkregister " ) ) ) {
chkregister + + ;
2003-02-05 13:19:53 +00:00
# ifdef LIBXML_SCHEMAS_ENABLED
} else if ( ( ! strcmp ( argv [ i ] , " -relaxng " ) ) | |
( ! strcmp ( argv [ i ] , " --relaxng " ) ) ) {
i + + ;
relaxng = argv [ i ] ;
noent + + ;
2003-09-23 21:50:54 +00:00
options | = XML_PARSE_NOENT ;
2003-05-12 15:25:56 +00:00
} else if ( ( ! strcmp ( argv [ i ] , " -schema " ) ) | |
( ! strcmp ( argv [ i ] , " --schema " ) ) ) {
i + + ;
schema = argv [ i ] ;
noent + + ;
2003-02-05 13:19:53 +00:00
# endif
2003-05-13 22:14:13 +00:00
} else if ( ( ! strcmp ( argv [ i ] , " -nonet " ) ) | |
( ! strcmp ( argv [ i ] , " --nonet " ) ) ) {
2003-11-03 14:28:31 +00:00
options | = XML_PARSE_NONET ;
2004-08-31 09:37:03 +00: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 ] ) ;
2003-12-02 22:32:15 +00:00
# ifdef LIBXML_PATTERN_ENABLED
} else if ( ( ! strcmp ( argv [ i ] , " -pattern " ) ) | |
( ! strcmp ( argv [ i ] , " --pattern " ) ) ) {
i + + ;
pattern = argv [ i ] ;
# endif
2001-06-20 13:55:33 +00:00
} else {
fprintf ( stderr , " Unknown option %s \n " , argv [ i ] ) ;
usage ( argv [ 0 ] ) ;
return ( 1 ) ;
}
2000-04-05 18:38:42 +00:00
}
2001-08-22 00:06:49 +00:00
# ifdef LIBXML_CATALOG_ENABLED
if ( nocatalogs = = 0 ) {
if ( catalogs ) {
const char * catal ;
catal = getenv ( " SGML_CATALOG_FILES " ) ;
2001-08-25 13:33:14 +00:00
if ( catal ! = NULL ) {
xmlLoadCatalogs ( catal ) ;
} else {
fprintf ( stderr , " Variable $SGML_CATALOG_FILES not set \n " ) ;
}
2001-08-22 00:06:49 +00:00
}
}
# endif
2003-01-05 22:37:17 +00:00
2003-09-30 00:43:48 +00:00
# ifdef LIBXML_SAX1_ENABLED
2003-09-10 10:51:05 +00:00
if ( sax1 )
xmlSAXDefaultVersion ( 1 ) ;
else
xmlSAXDefaultVersion ( 2 ) ;
2003-09-30 00:43:48 +00:00
# endif /* LIBXML_SAX1_ENABLED */
2003-09-10 10:51:05 +00:00
2003-01-05 22:37:17 +00:00
if ( chkregister ) {
xmlRegisterNodeDefault ( registerNode ) ;
xmlDeregisterNodeDefault ( deregisterNode ) ;
}
2003-03-09 22:36:52 +00:00
indent = getenv ( " XMLLINT_INDENT " ) ;
if ( indent ! = NULL ) {
xmlTreeIndentString = indent ;
}
2003-01-05 22:37:17 +00:00
2004-08-31 09:37:03 +00:00
defaultEntityLoader = xmlGetExternalEntityLoader ( ) ;
xmlSetExternalEntityLoader ( xmllintExternalEntityLoader ) ;
2001-07-23 19:39:43 +00:00
xmlLineNumbersDefault ( 1 ) ;
2001-08-07 01:10:10 +00:00
if ( loaddtd ! = 0 )
xmlLoadExtDtdDefaultValue | = XML_DETECT_IDS ;
if ( dtdattrs )
xmlLoadExtDtdDefaultValue | = XML_COMPLETE_ATTRS ;
2000-04-05 18:38:42 +00:00
if ( noent ! = 0 ) xmlSubstituteEntitiesDefault ( 1 ) ;
2003-09-28 18:58:27 +00:00
# ifdef LIBXML_VALID_ENABLED
2000-04-05 18:38:42 +00:00
if ( valid ! = 0 ) xmlDoValidityCheckingDefaultValue = 1 ;
2003-09-28 18:58:27 +00:00
# endif /* LIBXML_VALID_ENABLED */
2000-04-05 18:38:42 +00:00
if ( ( htmlout ) & & ( ! nowrap ) ) {
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext ,
2000-04-05 18:38:42 +00:00
" <!DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.0 Transitional//EN \" \n " ) ;
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext ,
" \t \" http://www.w3.org/TR/REC-html40/loose.dtd \" > \n " ) ;
xmlGenericError ( xmlGenericErrorContext ,
2000-04-05 18:38:42 +00:00
" <html><head><title>%s output</title></head> \n " ,
argv [ 0 ] ) ;
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext ,
2000-04-05 18:38:42 +00:00
" <body bgcolor= \" #ffffff \" ><h1 align= \" center \" >%s output</h1> \n " ,
argv [ 0 ] ) ;
}
2003-02-05 13:19:53 +00:00
# ifdef LIBXML_SCHEMAS_ENABLED
2003-09-30 00:43:48 +00:00
if ( ( relaxng ! = NULL )
# ifdef LIBXML_READER_ENABLED
& & ( stream = = 0 )
# endif /* LIBXML_READER_ENABLED */
) {
2003-02-05 13:19:53 +00:00
xmlRelaxNGParserCtxtPtr ctxt ;
2003-04-16 15:58:05 +00:00
/* forces loading the DTDs */
xmlLoadExtDtdDefaultValue | = 1 ;
2003-09-23 21:50:54 +00:00
options | = XML_PARSE_DTDLOAD ;
2003-03-07 18:32:59 +00:00
if ( timing ) {
startTimer ( ) ;
}
2003-02-05 13:19:53 +00:00
ctxt = xmlRelaxNGNewParserCtxt ( relaxng ) ;
xmlRelaxNGSetParserErrors ( ctxt ,
( xmlRelaxNGValidityErrorFunc ) fprintf ,
( xmlRelaxNGValidityWarningFunc ) fprintf ,
stderr ) ;
relaxngschemas = xmlRelaxNGParse ( ctxt ) ;
2003-04-16 15:58:05 +00:00
if ( relaxngschemas = = NULL ) {
xmlGenericError ( xmlGenericErrorContext ,
" Relax-NG schema %s failed to compile \n " , relaxng ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_SCHEMACOMP ;
2003-04-16 15:58:05 +00:00
relaxng = NULL ;
}
2003-02-05 13:19:53 +00:00
xmlRelaxNGFreeParserCtxt ( ctxt ) ;
2003-03-07 18:32:59 +00:00
if ( timing ) {
endTimer ( " Compiling the schemas " ) ;
}
2004-03-25 09:35:49 +00:00
} else if ( ( schema ! = NULL )
# ifdef LIBXML_READER_ENABLED
& & ( stream = = 0 )
# endif
) {
2003-05-12 15:25:56 +00:00
xmlSchemaParserCtxtPtr ctxt ;
if ( timing ) {
startTimer ( ) ;
}
ctxt = xmlSchemaNewParserCtxt ( schema ) ;
xmlSchemaSetParserErrors ( ctxt ,
( xmlSchemaValidityErrorFunc ) fprintf ,
( xmlSchemaValidityWarningFunc ) fprintf ,
stderr ) ;
wxschemas = xmlSchemaParse ( ctxt ) ;
if ( wxschemas = = NULL ) {
xmlGenericError ( xmlGenericErrorContext ,
" WXS schema %s failed to compile \n " , schema ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_SCHEMACOMP ;
2003-05-12 15:25:56 +00:00
schema = NULL ;
}
xmlSchemaFreeParserCtxt ( ctxt ) ;
if ( timing ) {
endTimer ( " Compiling the schemas " ) ;
}
2003-02-05 13:19:53 +00:00
}
2003-12-02 22:32:15 +00:00
# endif /* LIBXML_SCHEMAS_ENABLED */
# ifdef LIBXML_PATTERN_ENABLED
if ( pattern ! = NULL ) {
2003-12-05 16:10:21 +00:00
patternc = xmlPatterncompile ( ( const xmlChar * ) pattern , NULL , 0 , NULL ) ;
2003-12-02 22:32:15 +00:00
if ( patternc = = NULL ) {
xmlGenericError ( xmlGenericErrorContext ,
" Pattern %s failed to compile \n " , pattern ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_SCHEMAPAT ;
2003-12-02 22:32:15 +00:00
pattern = NULL ;
}
}
# endif /* LIBXML_PATTERN_ENABLED */
2000-04-05 18:38:42 +00:00
for ( i = 1 ; i < argc ; i + + ) {
2000-06-28 23:40:59 +00:00
if ( ( ! strcmp ( argv [ i ] , " -encode " ) ) | |
( ! strcmp ( argv [ i ] , " --encode " ) ) ) {
i + + ;
continue ;
2001-12-18 11:14:16 +00:00
} else if ( ( ! strcmp ( argv [ i ] , " -o " ) ) | |
( ! strcmp ( argv [ i ] , " -output " ) ) | |
( ! strcmp ( argv [ i ] , " --output " ) ) ) {
i + + ;
continue ;
2000-06-28 23:40:59 +00:00
}
2003-09-28 18:58:27 +00:00
# ifdef LIBXML_VALID_ENABLED
2000-10-11 15:57:05 +00:00
if ( ( ! strcmp ( argv [ i ] , " -dtdvalid " ) ) | |
( ! strcmp ( argv [ i ] , " --dtdvalid " ) ) ) {
i + + ;
continue ;
2004-08-31 09:37:03 +00:00
}
if ( ( ! strcmp ( argv [ i ] , " -path " ) ) | |
( ! strcmp ( argv [ i ] , " --path " ) ) ) {
i + + ;
continue ;
2000-10-11 15:57:05 +00:00
}
2003-08-18 16:39:51 +00:00
if ( ( ! strcmp ( argv [ i ] , " -dtdvalidfpi " ) ) | |
( ! strcmp ( argv [ i ] , " --dtdvalidfpi " ) ) ) {
i + + ;
continue ;
}
2003-09-28 18:58:27 +00:00
# endif /* LIBXML_VALID_ENABLED */
2003-02-05 13:19:53 +00:00
if ( ( ! strcmp ( argv [ i ] , " -relaxng " ) ) | |
( ! strcmp ( argv [ i ] , " --relaxng " ) ) ) {
i + + ;
continue ;
}
2004-05-03 22:54:49 +00:00
if ( ( ! strcmp ( argv [ i ] , " -maxmem " ) ) | |
( ! strcmp ( argv [ i ] , " --maxmem " ) ) ) {
i + + ;
continue ;
}
2003-05-12 15:25:56 +00:00
if ( ( ! strcmp ( argv [ i ] , " -schema " ) ) | |
( ! strcmp ( argv [ i ] , " --schema " ) ) ) {
i + + ;
continue ;
}
2003-12-02 22:32:15 +00:00
# ifdef LIBXML_PATTERN_ENABLED
if ( ( ! strcmp ( argv [ i ] , " -pattern " ) ) | |
( ! strcmp ( argv [ i ] , " --pattern " ) ) ) {
i + + ;
continue ;
}
# endif
2001-02-25 16:11:03 +00:00
if ( ( timing ) & & ( repeat ) )
2001-12-18 07:09:59 +00:00
startTimer ( ) ;
2001-12-31 16:16:02 +00:00
/* Remember file names. "-" means stdin. <sven@zen.org> */
2001-01-03 13:32:39 +00:00
if ( ( argv [ i ] [ 0 ] ! = ' - ' ) | | ( strcmp ( argv [ i ] , " - " ) = = 0 ) ) {
2000-04-05 18:38:42 +00:00
if ( repeat ) {
2003-09-24 21:23:56 +00:00
xmlParserCtxtPtr ctxt = NULL ;
for ( acount = 0 ; acount < repeat ; acount + + ) {
2003-09-30 00:43:48 +00:00
# ifdef LIBXML_READER_ENABLED
2003-10-20 17:07:41 +00:00
if ( stream ! = 0 ) {
2003-01-03 16:19:51 +00:00
streamFile ( argv [ i ] ) ;
2003-10-20 17:07:41 +00:00
} else {
2003-09-30 00:43:48 +00:00
# endif /* LIBXML_READER_ENABLED */
2003-09-24 21:23:56 +00:00
if ( ctxt = = NULL )
ctxt = xmlNewParserCtxt ( ) ;
parseAndPrintFile ( argv [ i ] , ctxt ) ;
2003-09-30 00:43:48 +00:00
# ifdef LIBXML_READER_ENABLED
2003-09-24 21:23:56 +00:00
}
2003-09-30 00:43:48 +00:00
# endif /* LIBXML_READER_ENABLED */
2003-09-24 21:23:56 +00:00
}
if ( ctxt ! = NULL )
xmlFreeParserCtxt ( ctxt ) ;
2003-01-03 16:19:51 +00:00
} else {
2004-04-30 22:25:59 +00:00
nbregister = 0 ;
2003-09-30 00:43:48 +00:00
# ifdef LIBXML_READER_ENABLED
2003-01-03 16:19:51 +00:00
if ( stream ! = 0 )
streamFile ( argv [ i ] ) ;
else
2003-09-30 00:43:48 +00:00
# endif /* LIBXML_READER_ENABLED */
2003-09-24 21:23:56 +00:00
parseAndPrintFile ( argv [ i ] , NULL ) ;
2004-04-30 22:25:59 +00:00
if ( ( chkregister ) & & ( nbregister ! = 0 ) ) {
fprintf ( stderr , " Registration count off: %d \n " , nbregister ) ;
2004-06-08 13:29:32 +00:00
progresult = XMLLINT_ERR_RDREGIS ;
2004-04-30 22:25:59 +00:00
}
2003-01-03 16:19:51 +00:00
}
2000-04-05 18:38:42 +00:00
files + + ;
2001-12-04 13:14:44 +00:00
if ( ( timing ) & & ( repeat ) ) {
2003-09-17 19:36:25 +00:00
endTimer ( " %d iterations " , repeat ) ;
2001-12-04 13:14:44 +00:00
}
2001-02-25 16:11:03 +00:00
}
2000-04-05 18:38:42 +00:00
}
2001-04-11 07:50:02 +00:00
if ( generate )
2003-09-24 21:23:56 +00:00
parseAndPrintFile ( NULL , NULL ) ;
2000-04-05 18:38:42 +00:00
if ( ( htmlout ) & & ( ! nowrap ) ) {
2000-10-25 19:56:55 +00:00
xmlGenericError ( xmlGenericErrorContext , " </body></html> \n " ) ;
2000-04-05 18:38:42 +00:00
}
2002-01-09 11:51:37 +00:00
if ( ( files = = 0 ) & & ( ! generate ) & & ( version = = 0 ) ) {
2001-06-20 13:55:33 +00:00
usage ( argv [ 0 ] ) ;
2000-04-05 18:38:42 +00:00
}
2003-02-05 13:19:53 +00:00
# ifdef LIBXML_SCHEMAS_ENABLED
if ( relaxngschemas ! = NULL )
xmlRelaxNGFree ( relaxngschemas ) ;
2003-05-12 15:25:56 +00:00
if ( wxschemas ! = NULL )
xmlSchemaFree ( wxschemas ) ;
2003-02-05 13:19:53 +00:00
xmlRelaxNGCleanupTypes ( ) ;
2003-12-02 22:32:15 +00:00
# endif
# ifdef LIBXML_PATTERN_ENABLED
if ( patternc ! = NULL )
xmlFreePattern ( patternc ) ;
2003-02-05 13:19:53 +00:00
# endif
2000-04-05 18:38:42 +00:00
xmlCleanupParser ( ) ;
xmlMemoryDump ( ) ;
2001-02-23 18:44:52 +00:00
return ( progresult ) ;
2000-04-05 18:38:42 +00:00
}
2000-08-04 18:23:10 +00:00