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>
2001-07-14 20:44:32 +04:00
2003-01-06 01:37:17 +03:00
# include <assert.h>
2002-01-08 13:36:16 +03:00
# if defined (_WIN32) && !defined(__CYGWIN__)
2001-04-16 21:46:18 +04:00
# ifdef _MSC_VER
# include <winsock2.h>
# pragma comment(lib, "ws2_32.lib")
# define gettimeofday(p1,p2)
2002-02-08 16:44:24 +03:00
# include <time.h>
2001-07-14 20:44:32 +04:00
# else /* _MSC_VER */
# include <sys/time.h>
2001-04-16 21:46:18 +04:00
# endif /* _MSC_VER */
# else /* _WIN32 */
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
2001-12-18 10:09:59 +03:00
# ifdef HAVE_TIME_H
# include <time.h>
# endif
2001-04-16 21:46:18 +04:00
# endif /* _WIN32 */
2001-02-25 19:11:03 +03:00
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_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-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_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 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
2001-10-22 13:46:13 +04:00
# ifdef LIBXML_DOCB_ENABLED
# include <libxml/DOCBparser.h>
# endif
2001-10-17 19:58:35 +04:00
# include <libxml/globals.h>
2003-01-03 19:19:51 +03:00
# include <libxml/xmlreader.h>
2003-02-05 16:19:53 +03:00
# ifdef LIBXML_SCHEMAS_ENABLED
# include <libxml/relaxng.h>
# endif
2000-04-05 22:38:42 +04:00
2003-01-26 22:49:04 +03:00
# ifndef XML_XML_DEFAULT_CATALOG
# define XML_XML_DEFAULT_CATALOG "file: ///etc/xml/catalog"
# endif
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 ;
2000-04-05 22:38:42 +04:00
static int copy = 0 ;
static int recovery = 0 ;
static int noent = 0 ;
static int noout = 0 ;
static int nowrap = 0 ;
static int valid = 0 ;
static int postvalid = 0 ;
2000-10-11 19:57:05 +04:00
static char * dtdvalid = NULL ;
2003-02-05 16:19:53 +03:00
# ifdef LIBXML_SCHEMAS_ENABLED
static char * relaxng = NULL ;
static xmlRelaxNGPtr relaxngschemas = NULL ;
# endif
2000-04-05 22:38:42 +04:00
static int repeat = 0 ;
static int insert = 0 ;
static int compress = 0 ;
2001-10-22 13:46:13 +04:00
# ifdef LIBXML_DOCB_ENABLED
static int sgml = 0 ;
# endif
2000-04-05 22:38:42 +04:00
static int html = 0 ;
static int htmlout = 0 ;
static int push = 0 ;
2000-07-22 00:32:03 +04:00
# ifdef HAVE_SYS_MMAN_H
static int memory = 0 ;
# endif
2000-04-05 22:38:42 +04:00
static int noblanks = 0 ;
2001-08-14 18:12:47 +04:00
static int format = 0 ;
2000-04-12 17:27:38 +04:00
static int testIO = 0 ;
2000-06-29 03:40:59 +04:00
static char * encoding = NULL ;
2000-11-06 19:43:11 +03:00
# ifdef LIBXML_XINCLUDE_ENABLED
static int xinclude = 0 ;
# endif
2001-08-07 05:10:10 +04:00
static int dtdattrs = 0 ;
2001-06-20 17:55:33 +04:00
static int loaddtd = 0 ;
2001-02-23 21:44:52 +03:00
static int progresult = 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 ;
2001-08-22 04:06:49 +04:00
# ifdef LIBXML_CATALOG_ENABLED
static int catalogs = 0 ;
static int nocatalogs = 0 ;
# endif
2003-01-03 19:19:51 +03:00
static int stream = 0 ;
2003-01-06 01:37:17 +03:00
static int chkregister = 0 ;
2001-12-18 14:14:16 +03:00
static const char * output = NULL ;
2000-04-05 22:38:42 +04:00
2001-12-18 10:09:59 +03:00
/*
* Internal timing routines to remove the necessity to have unix - specific
* function calls
*/
2002-03-07 14:21:00 +03:00
# ifndef HAVE_GETTIMEOFDAY
# 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
*/
static void
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 ;
# ifndef HAVE_STDARG_H
# error "endTimer required stdarg functions"
# endif
2002-09-24 18:13:13 +04:00
va_start ( ap , fmt ) ;
vfprintf ( stderr , fmt , ap ) ;
2001-12-18 10:09:59 +03: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 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 ( ) ;
}
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 22:38:42 +04:00
/************************************************************************
* *
* HTML ouput *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
char buffer [ 50000 ] ;
2001-03-24 20:00:36 +03:00
static void
2000-04-05 22:38:42 +04:00
xmlHTMLEncodeSend ( void ) {
char * result ;
result = ( char * ) xmlEncodeEntitiesReentrant ( NULL , BAD_CAST buffer ) ;
if ( result ) {
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext , " %s " , result ) ;
2000-04-05 22:38:42 +04: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 20:00:36 +03:00
static void
2000-04-05 22:38:42 +04:00
xmlHTMLPrintFileInfo ( xmlParserInputPtr input ) {
2002-06-14 21:07:10 +04:00
int len ;
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext , " <p> " ) ;
2002-06-14 21:07:10 +04:00
len = strlen ( buffer ) ;
2000-04-05 22:38:42 +04:00
if ( input ! = NULL ) {
if ( input - > filename ) {
2002-06-14 21:07:10 +04:00
snprintf ( & buffer [ len ] , sizeof ( buffer ) - len , " %s:%d: " , input - > filename ,
2000-04-05 22:38:42 +04:00
input - > line ) ;
} else {
2002-06-14 21:07:10 +04:00
snprintf ( & buffer [ len ] , sizeof ( buffer ) - len , " Entity: line %d: " , input - > line ) ;
2000-04-05 22:38:42 +04:00
}
}
xmlHTMLEncodeSend ( ) ;
}
/**
* xmlHTMLPrintFileContext :
* @ input : an xmlParserInputPtr input
*
* Displays current context within the input content for error tracking
*/
2001-03-24 20:00:36 +03:00
static void
2000-04-05 22:38:42 +04:00
xmlHTMLPrintFileContext ( xmlParserInputPtr input ) {
const xmlChar * cur , * base ;
2002-06-14 21:07:10 +04:00
int len ;
2000-04-05 22:38:42 +04:00
int n ;
if ( input = = NULL ) return ;
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext , " <pre> \n " ) ;
2000-04-05 22:38:42 +04: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 21:07:10 +04:00
len = strlen ( buffer ) ;
snprintf ( & buffer [ len ] , sizeof ( buffer ) - len , " %c " ,
( unsigned char ) * cur + + ) ;
2000-04-05 22:38:42 +04:00
n + + ;
}
2002-06-14 21:07:10 +04:00
len = strlen ( buffer ) ;
snprintf ( & buffer [ len ] , sizeof ( buffer ) - len , " \n " ) ;
2000-04-05 22:38:42 +04:00
cur = input - > cur ;
while ( ( * cur = = ' \n ' ) | | ( * cur = = ' \r ' ) )
cur - - ;
n = 0 ;
while ( ( cur ! = base ) & & ( n + + < 80 ) ) {
2002-06-14 21:07:10 +04:00
len = strlen ( buffer ) ;
snprintf ( & buffer [ len ] , sizeof ( buffer ) - len , " " ) ;
2000-04-05 22:38:42 +04:00
base + + ;
}
2002-06-14 21:07:10 +04:00
len = strlen ( buffer ) ;
snprintf ( & buffer [ len ] , sizeof ( buffer ) - len , " ^ \n " ) ;
2000-04-05 22:38:42 +04:00
xmlHTMLEncodeSend ( ) ;
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext , " </pre> " ) ;
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
*
* Display and format an error messages , gives file , line , position and
* extra parameters .
*/
2001-03-24 20:00:36 +03:00
static void
2000-04-05 22:38:42 +04:00
xmlHTMLError ( void * ctx , const char * msg , . . . )
{
xmlParserCtxtPtr ctxt = ( xmlParserCtxtPtr ) ctx ;
xmlParserInputPtr input ;
xmlParserInputPtr cur = NULL ;
va_list args ;
2002-06-14 21:07:10 +04:00
int len ;
2000-04-05 22:38:42 +04:00
buffer [ 0 ] = 0 ;
input = ctxt - > input ;
if ( ( input ! = NULL ) & & ( input - > filename = = NULL ) & & ( ctxt - > inputNr > 1 ) ) {
cur = input ;
input = ctxt - > inputTab [ ctxt - > inputNr - 2 ] ;
}
xmlHTMLPrintFileInfo ( input ) ;
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext , " <b>error</b>: " ) ;
2000-04-05 22:38:42 +04:00
va_start ( args , msg ) ;
2002-06-14 21:07:10 +04:00
len = strlen ( buffer ) ;
vsnprintf ( & buffer [ len ] , sizeof ( buffer ) - len , msg , args ) ;
2000-04-05 22:38:42 +04:00
va_end ( args ) ;
xmlHTMLEncodeSend ( ) ;
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext , " </p> \n " ) ;
2000-04-05 22:38:42 +04: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 20:00:36 +03:00
static void
2000-04-05 22:38:42 +04:00
xmlHTMLWarning ( void * ctx , const char * msg , . . . )
{
xmlParserCtxtPtr ctxt = ( xmlParserCtxtPtr ) ctx ;
xmlParserInputPtr input ;
xmlParserInputPtr cur = NULL ;
va_list args ;
2002-06-14 21:07:10 +04:00
int len ;
2000-04-05 22:38:42 +04:00
buffer [ 0 ] = 0 ;
input = ctxt - > input ;
if ( ( input ! = NULL ) & & ( input - > filename = = NULL ) & & ( ctxt - > inputNr > 1 ) ) {
cur = input ;
input = ctxt - > inputTab [ ctxt - > inputNr - 2 ] ;
}
xmlHTMLPrintFileInfo ( input ) ;
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext , " <b>warning</b>: " ) ;
2000-04-05 22:38:42 +04:00
va_start ( args , msg ) ;
2002-06-14 21:07:10 +04:00
len = strlen ( buffer ) ;
vsnprintf ( & buffer [ len ] , sizeof ( buffer ) - len , msg , args ) ;
2000-04-05 22:38:42 +04:00
va_end ( args ) ;
xmlHTMLEncodeSend ( ) ;
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext , " </p> \n " ) ;
2000-04-05 22:38:42 +04: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 20:00:36 +03:00
static void
2000-04-05 22:38:42 +04:00
xmlHTMLValidityError ( void * ctx , const char * msg , . . . )
{
xmlParserCtxtPtr ctxt = ( xmlParserCtxtPtr ) ctx ;
xmlParserInputPtr input ;
va_list args ;
2002-06-14 21:07:10 +04:00
int len ;
2000-04-05 22:38:42 +04: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 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext , " <b>validity error</b>: " ) ;
2002-06-14 21:07:10 +04:00
len = strlen ( buffer ) ;
2000-04-05 22:38:42 +04:00
va_start ( args , msg ) ;
2002-06-14 21:07:10 +04:00
vsnprintf ( & buffer [ len ] , sizeof ( buffer ) - len , msg , args ) ;
2000-04-05 22:38:42 +04:00
va_end ( args ) ;
xmlHTMLEncodeSend ( ) ;
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext , " </p> \n " ) ;
2000-04-05 22:38:42 +04: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 20:00:36 +03:00
static void
2000-04-05 22:38:42 +04:00
xmlHTMLValidityWarning ( void * ctx , const char * msg , . . . )
{
xmlParserCtxtPtr ctxt = ( xmlParserCtxtPtr ) ctx ;
xmlParserInputPtr input ;
va_list args ;
2002-06-14 21:07:10 +04:00
int len ;
2000-04-05 22:38:42 +04: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 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext , " <b>validity warning</b>: " ) ;
2000-04-05 22:38:42 +04:00
va_start ( args , msg ) ;
2002-06-14 21:07:10 +04:00
len = strlen ( buffer ) ;
vsnprintf ( & buffer [ len ] , sizeof ( buffer ) - len , msg , args ) ;
2000-04-05 22:38:42 +04:00
va_end ( args ) ;
xmlHTMLEncodeSend ( ) ;
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext , " </p> \n " ) ;
2000-04-05 22:38:42 +04:00
xmlHTMLPrintFileContext ( input ) ;
xmlHTMLEncodeSend ( ) ;
}
/************************************************************************
* *
* Shell Interface *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-01-07 14:17:25 +03:00
# ifdef LIBXML_DEBUG_ENABLED
2000-04-05 22:38:42 +04: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 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 ) ;
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
}
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
/************************************************************************
* *
* I / O Interfaces *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-03-24 20:00:36 +03:00
static int myRead ( FILE * f , char * buf , int len ) {
return ( fread ( buf , 1 , len , f ) ) ;
2000-04-12 17:27:38 +04:00
}
2001-03-24 20:00:36 +03:00
static void myClose ( FILE * f ) {
2001-01-03 16:32:39 +03:00
if ( f ! = stdin ) {
2000-04-12 17:27:38 +04:00
fclose ( f ) ;
2001-01-03 16:32:39 +03:00
}
2000-04-12 17:27:38 +04:00
}
2000-04-05 22:38:42 +04:00
/************************************************************************
* *
2003-01-03 19:19:51 +03:00
* Stream Test processing *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static int count = 0 ;
static int elem , attrs ;
static void processNode ( xmlTextReaderPtr reader ) {
2003-01-04 19:35:29 +03:00
xmlChar * name , * value ;
name = xmlTextReaderName ( reader ) ;
if ( name = = NULL )
name = xmlStrdup ( BAD_CAST " -- " ) ;
value = xmlTextReaderValue ( reader ) ;
printf ( " %d %d %s %d " ,
xmlTextReaderDepth ( reader ) ,
xmlTextReaderNodeType ( reader ) ,
name ,
xmlTextReaderIsEmptyElement ( reader ) ) ;
xmlFree ( name ) ;
if ( value = = NULL )
printf ( " \n " ) ;
else {
printf ( " %s \n " , value ) ;
xmlFree ( value ) ;
2003-01-03 19:19:51 +03:00
}
}
static void streamFile ( char * filename ) {
xmlTextReaderPtr reader ;
int ret ;
if ( count ) {
elem = 0 ;
attrs = 0 ;
}
reader = xmlNewTextReaderFilename ( filename ) ;
if ( reader ! = NULL ) {
if ( valid )
xmlTextReaderSetParserProp ( reader , XML_PARSER_VALIDATE , 1 ) ;
/*
* Process all nodes in sequence
*/
ret = xmlTextReaderRead ( reader ) ;
while ( ret = = 1 ) {
if ( debug )
processNode ( reader ) ;
ret = xmlTextReaderRead ( reader ) ;
}
/*
* Done , cleanup and status
*/
xmlFreeTextReader ( reader ) ;
if ( ret ! = 0 ) {
printf ( " %s : failed to parse \n " , filename ) ;
}
} else {
fprintf ( stderr , " Unable to open %s \n " , filename ) ;
}
}
/************************************************************************
* *
* Tree Test processing *
2000-04-05 22:38:42 +04:00
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-03-24 20:00:36 +03:00
static void parseAndPrintFile ( char * filename ) {
2000-04-05 22:38:42 +04:00
xmlDocPtr doc = NULL , tmp ;
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
2001-04-11 11:50:02 +04:00
if ( filename = = NULL ) {
if ( generate ) {
xmlNodePtr n ;
doc = xmlNewDoc ( BAD_CAST " 1.0 " ) ;
n = xmlNewNode ( NULL , BAD_CAST " info " ) ;
xmlNodeSetContent ( n , BAD_CAST " abc " ) ;
xmlDocSetRootElement ( doc , n ) ;
}
}
2001-10-22 13:46:13 +04:00
# ifdef LIBXML_DOCB_ENABLED
/*
* build an SGML tree from a string ;
*/
else if ( ( sgml ) & & ( push ) ) {
FILE * f ;
f = fopen ( filename , " r " ) ;
if ( f ! = NULL ) {
int res , size = 3 ;
char chars [ 4096 ] ;
docbParserCtxtPtr ctxt ;
/* if (repeat) */
size = 4096 ;
res = fread ( chars , 1 , 4 , f ) ;
if ( res > 0 ) {
ctxt = docbCreatePushParserCtxt ( NULL , NULL ,
chars , res , filename , 0 ) ;
while ( ( res = fread ( chars , 1 , size , f ) ) > 0 ) {
docbParseChunk ( ctxt , chars , res , 0 ) ;
}
docbParseChunk ( ctxt , chars , 0 , 1 ) ;
doc = ctxt - > myDoc ;
docbFreeParserCtxt ( ctxt ) ;
}
fclose ( f ) ;
}
} else if ( sgml ) {
doc = docbParseFile ( filename , NULL ) ;
}
# endif
2000-04-05 22:38:42 +04:00
# ifdef LIBXML_HTML_ENABLED
2001-04-11 11:50:02 +04:00
else if ( html ) {
2000-04-05 22:38:42 +04:00
doc = htmlParseFile ( filename , NULL ) ;
2001-04-11 11:50:02 +04:00
}
2000-04-05 22:38:42 +04:00
# endif /* LIBXML_HTML_ENABLED */
2001-04-11 11:50:02 +04:00
else {
2000-04-05 22:38:42 +04:00
/*
* build an XML tree from a string ;
*/
if ( push ) {
FILE * f ;
2001-01-03 16:32:39 +03:00
/* '-' Usually means stdin -<sven@zen.org> */
if ( ( filename [ 0 ] = = ' - ' ) & & ( filename [ 1 ] = = 0 ) ) {
f = stdin ;
} else {
f = fopen ( filename , " r " ) ;
}
2000-04-05 22:38:42 +04:00
if ( f ! = NULL ) {
2000-08-29 22:29:38 +04:00
int ret ;
2000-04-05 22:38:42 +04:00
int res , size = 3 ;
char chars [ 1024 ] ;
xmlParserCtxtPtr ctxt ;
if ( repeat )
size = 1024 ;
res = fread ( chars , 1 , 4 , f ) ;
if ( res > 0 ) {
ctxt = xmlCreatePushParserCtxt ( NULL , NULL ,
chars , res , filename ) ;
while ( ( res = fread ( chars , 1 , size , f ) ) > 0 ) {
xmlParseChunk ( ctxt , chars , res , 0 ) ;
}
xmlParseChunk ( ctxt , chars , 0 , 1 ) ;
doc = ctxt - > myDoc ;
2000-08-29 22:29:38 +04:00
ret = ctxt - > wellFormed ;
2000-04-05 22:38:42 +04:00
xmlFreeParserCtxt ( ctxt ) ;
2000-08-29 22:29:38 +04:00
if ( ! ret ) {
xmlFreeDoc ( doc ) ;
doc = NULL ;
}
2000-04-05 22:38:42 +04:00
}
}
2000-04-12 17:27:38 +04:00
} else if ( testIO ) {
int ret ;
FILE * f ;
2001-01-03 16:32:39 +03:00
/* '-' Usually means stdin -<sven@zen.org> */
if ( ( filename [ 0 ] = = ' - ' ) & & ( filename [ 1 ] = = 0 ) ) {
f = stdin ;
} else {
f = fopen ( filename , " r " ) ;
}
2000-04-12 17:27:38 +04:00
if ( f ! = NULL ) {
xmlParserCtxtPtr ctxt ;
ctxt = xmlCreateIOParserCtxt ( NULL , NULL ,
( xmlInputReadCallback ) myRead ,
( xmlInputCloseCallback ) myClose ,
f , XML_CHAR_ENCODING_NONE ) ;
xmlParseDocument ( ctxt ) ;
ret = ctxt - > wellFormed ;
doc = ctxt - > myDoc ;
xmlFreeParserCtxt ( ctxt ) ;
if ( ! ret ) {
xmlFreeDoc ( doc ) ;
doc = NULL ;
}
}
2000-04-05 22:38:42 +04:00
} else if ( recovery ) {
doc = xmlRecoverFile ( filename ) ;
} else if ( htmlout ) {
int ret ;
xmlParserCtxtPtr ctxt ;
xmlSAXHandler silent , * old ;
ctxt = xmlCreateFileParserCtxt ( filename ) ;
2000-08-04 22:23:10 +04:00
if ( ctxt = = NULL ) {
2001-12-31 19:16:02 +03:00
/* If xmlCreateFileParserCtxt() return NULL something
2000-08-04 22:23:10 +04:00
strange happened so we don ' t want to do anything . Do
we want to print an error message here ?
< sven @ zen . org > */
2000-08-04 22:24:45 +04:00
doc = NULL ;
2000-08-04 22:23:10 +04:00
} else {
memcpy ( & silent , ctxt - > sax , sizeof ( silent ) ) ;
old = ctxt - > sax ;
silent . error = xmlHTMLError ;
if ( xmlGetWarningsDefaultValue )
2000-04-05 22:38:42 +04:00
silent . warning = xmlHTMLWarning ;
2000-08-04 22:23:10 +04:00
else
2000-04-05 22:38:42 +04:00
silent . warning = NULL ;
2000-08-04 22:23:10 +04:00
silent . fatalError = xmlHTMLError ;
ctxt - > sax = & silent ;
ctxt - > vctxt . error = xmlHTMLValidityError ;
if ( xmlGetWarningsDefaultValue )
2000-04-05 22:38:42 +04:00
ctxt - > vctxt . warning = xmlHTMLValidityWarning ;
2000-08-04 22:23:10 +04:00
else
2000-04-05 22:38:42 +04:00
ctxt - > vctxt . warning = NULL ;
2000-08-04 22:23:10 +04:00
xmlParseDocument ( ctxt ) ;
2000-04-05 22:38:42 +04:00
2000-08-04 22:23:10 +04:00
ret = ctxt - > wellFormed ;
doc = ctxt - > myDoc ;
ctxt - > sax = old ;
xmlFreeParserCtxt ( ctxt ) ;
if ( ! ret ) {
2000-04-05 22:38:42 +04:00
xmlFreeDoc ( doc ) ;
doc = NULL ;
2000-08-04 22:23:10 +04:00
}
2000-04-05 22:38:42 +04:00
}
2000-07-22 00:32:03 +04: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 21:57:48 +04:00
if ( base = = ( void * ) MAP_FAILED )
2000-07-22 00:32:03 +04:00
return ;
doc = xmlParseMemory ( ( char * ) base , info . st_size ) ;
munmap ( ( char * ) base , info . st_size ) ;
# endif
2002-12-20 03:16:24 +03:00
} else if ( valid ) {
int ret ;
xmlParserCtxtPtr ctxt ;
ctxt = xmlCreateFileParserCtxt ( filename ) ;
if ( ctxt = = NULL ) {
doc = NULL ;
} else {
xmlParseDocument ( ctxt ) ;
if ( ctxt - > valid = = 0 )
progresult = 4 ;
ret = ctxt - > wellFormed ;
doc = ctxt - > myDoc ;
xmlFreeParserCtxt ( ctxt ) ;
if ( ! ret ) {
xmlFreeDoc ( doc ) ;
doc = NULL ;
}
}
} else {
2000-04-05 22:38:42 +04:00
doc = xmlParseFile ( filename ) ;
2002-12-20 03:16:24 +03:00
}
2000-04-05 22:38:42 +04:00
}
2000-08-04 22:23:10 +04: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 19:43:11 +03:00
if ( doc = = NULL ) {
2001-02-23 21:44:52 +03:00
progresult = 1 ;
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
/*
* Remove DOCTYPE nodes
*/
if ( dropdtd ) {
xmlDtdPtr dtd ;
dtd = xmlGetIntSubset ( doc ) ;
if ( dtd ! = NULL ) {
xmlUnlinkNode ( ( xmlNodePtr ) dtd ) ;
xmlFreeDtd ( dtd ) ;
}
}
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
}
2000-11-06 19:43:11 +03:00
xmlXIncludeProcess ( doc ) ;
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
2000-04-05 22:38:42 +04:00
# ifdef LIBXML_DEBUG_ENABLED
/*
2001-12-31 19:16:02 +03:00
* shell interaction
2000-04-05 22:38:42 +04:00
*/
if ( shell )
xmlShell ( doc , filename , xmlShellReadline , stdout ) ;
# endif
/*
* test intermediate copy if needed .
*/
if ( copy ) {
tmp = doc ;
doc = xmlCopyDoc ( doc , 1 ) ;
xmlFreeDoc ( tmp ) ;
}
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 ) {
printf ( " could not get valid list of elements \n " ) ;
} else if ( nb = = 0 ) {
2001-09-24 07:08:43 +04:00
printf ( " No element can be inserted under root \n " ) ;
2000-04-05 22:38:42 +04:00
} else {
2001-09-24 07:08:43 +04:00
printf ( " %d element types can be inserted under root: \n " ,
2000-04-05 22:38:42 +04:00
nb ) ;
for ( i = 0 ; i < nb ; i + + ) {
2003-01-06 01:37:17 +03:00
printf ( " %s \n " , ( char * ) list [ i ] ) ;
2000-04-05 22:38:42 +04:00
}
}
}
}
} else if ( noout = = 0 ) {
/*
* 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
}
2001-04-04 04:09:00 +04:00
# ifdef HAVE_SYS_MMAN_H
2000-12-27 13:46:47 +03:00
if ( memory ) {
xmlChar * result ;
int len ;
if ( encoding ! = NULL ) {
2001-11-08 20:32:47 +03:00
if ( format ) {
xmlDocDumpFormatMemoryEnc ( doc , & result , & len , encoding , 1 ) ;
} else {
xmlDocDumpMemoryEnc ( doc , & result , & len , encoding ) ;
}
2000-12-27 13:46:47 +03:00
} else {
2001-08-14 18:12:47 +04:00
if ( format )
xmlDocDumpFormatMemory ( doc , & result , & len , 1 ) ;
else
xmlDocDumpMemory ( doc , & result , & len ) ;
2000-12-27 13:46:47 +03:00
}
if ( result = = NULL ) {
fprintf ( stderr , " Failed to save \n " ) ;
} else {
write ( 1 , result , len ) ;
xmlFree ( result ) ;
}
2001-04-04 04:09:00 +04:00
} else
# endif /* HAVE_SYS_MMAN_H */
2001-12-18 14:14:16 +03:00
if ( compress ) {
xmlSaveFile ( output ? output : " - " , doc ) ;
}
2001-11-08 20:32:47 +03:00
else if ( encoding ! = NULL ) {
if ( format ) {
2001-12-18 14:14:16 +03:00
xmlSaveFormatFileEnc ( output ? output : " - " , doc , encoding , 1 ) ;
}
else {
xmlSaveFileEnc ( output ? output : " - " , doc , encoding ) ;
}
}
else if ( format ) {
xmlSaveFormatFile ( output ? output : " - " , doc , 1 ) ;
}
else {
FILE * out ;
if ( output = = NULL )
out = stdout ;
2001-11-08 20:32:47 +03:00
else {
2001-12-18 14:14:16 +03:00
out = fopen ( output , " wb " ) ;
2001-11-08 20:32:47 +03:00
}
2001-12-18 14:14:16 +03:00
xmlDocDump ( out , doc ) ;
if ( output )
fclose ( out ) ;
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 " ) ;
}
xmlDebugDumpDocument ( out , doc ) ;
if ( output )
fclose ( out ) ;
2000-12-27 13:46:47 +03:00
}
2000-04-05 22:38:42 +04:00
# endif
}
/*
* A posteriori validation test
*/
2000-10-11 19:57:05 +04:00
if ( dtdvalid ! = NULL ) {
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
}
2000-10-11 19:57:05 +04:00
dtd = xmlParseDTD ( NULL , ( const xmlChar * ) dtdvalid ) ;
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 ) {
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext ,
" Could not parse DTD %s \n " , dtdvalid ) ;
2001-02-23 21:44:52 +03:00
progresult = 2 ;
2000-10-11 19:57:05 +04:00
} else {
xmlValidCtxt cvp ;
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
}
2001-12-18 10:09:59 +03:00
cvp . userData = ( void * ) stderr ;
cvp . error = ( xmlValidityErrorFunc ) fprintf ;
cvp . warning = ( xmlValidityWarningFunc ) fprintf ;
2000-10-11 19:57:05 +04:00
if ( ! xmlValidateDtd ( & cvp , doc , dtd ) ) {
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext ,
" Document %s does not validate against %s \n " ,
2000-10-11 19:57:05 +04:00
filename , dtdvalid ) ;
2001-02-23 21:44:52 +03:00
progresult = 3 ;
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
}
2000-10-11 19:57:05 +04:00
xmlFreeDtd ( dtd ) ;
}
} else if ( postvalid ) {
2000-04-05 22:38:42 +04:00
xmlValidCtxt cvp ;
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
}
2001-08-19 17:00:43 +04:00
cvp . userData = ( void * ) stderr ;
cvp . error = ( xmlValidityErrorFunc ) fprintf ;
cvp . warning = ( xmlValidityWarningFunc ) fprintf ;
2000-10-11 19:57:05 +04:00
if ( ! xmlValidateDocument ( & cvp , doc ) ) {
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext ,
" Document %s does not validate \n " , filename ) ;
2001-02-23 21:44:52 +03:00
progresult = 3 ;
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-02-05 16:19:53 +03:00
# ifdef LIBXML_SCHEMAS_ENABLED
} else if ( relaxngschemas ! = NULL ) {
xmlRelaxNGValidCtxtPtr ctxt ;
int ret ;
ctxt = xmlRelaxNGNewValidCtxt ( relaxngschemas ) ;
xmlRelaxNGSetValidErrors ( ctxt ,
( xmlRelaxNGValidityErrorFunc ) fprintf ,
( xmlRelaxNGValidityWarningFunc ) fprintf ,
stderr ) ;
ret = xmlRelaxNGValidateDoc ( ctxt , doc ) ;
if ( ret = = 0 ) {
printf ( " %s validates \n " , filename ) ;
} else if ( ret > 0 ) {
printf ( " %s fails to validate \n " , filename ) ;
} else {
printf ( " %s validation generated an internal error \n " ,
filename ) ;
}
xmlRelaxNGFreeValidCtxt ( ctxt ) ;
# endif
2000-04-05 22:38:42 +04:00
}
# ifdef LIBXML_DEBUG_ENABLED
if ( ( debugent ) & & ( ! html ) )
2000-08-27 01:40:43 +04:00
xmlDebugDumpEntities ( stderr , 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
/************************************************************************
* *
* Usage and Main *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-09-18 03:04:40 +04:00
static void showVersion ( const char * name ) {
fprintf ( stderr , " %s: using libxml version %s \n " , name , xmlParserVersion ) ;
fprintf ( stderr , " compiled with: " ) ;
# 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_DOCB_ENABLED
fprintf ( stderr , " DocBook " ) ;
# 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 " ) ;
# endif
fprintf ( stderr , " \n " ) ;
}
2001-06-20 17:55:33 +04:00
static void usage ( const char * name ) {
printf ( " Usage : %s [options] XMLfiles ... \n " , name ) ;
printf ( " \t Parse the XML files and output the result of the parsing \n " ) ;
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 03:19:07 +03:00
# else
printf ( " \t --debug : dump the nodes content when using --stream \n " ) ;
2001-06-20 17:55:33 +04:00
# endif
printf ( " \t --copy : used to test the internal copy implementation \n " ) ;
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 " ) ;
printf ( " \t --htmlout : output results as HTML \n " ) ;
2001-09-09 12:38:09 +04:00
printf ( " \t --nowrap : do not put HTML doc wrapper \n " ) ;
2001-06-20 17:55:33 +04: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 " ) ;
printf ( " \t --timing : print some timings \n " ) ;
2001-12-18 14:14:16 +03:00
printf ( " \t --output file or -o file: save to a given file \n " ) ;
2001-06-20 17:55:33 +04:00
printf ( " \t --repeat : repeat 100 times, for timing or profiling \n " ) ;
printf ( " \t --insert : ad-hoc test for valid insertions \n " ) ;
2001-12-18 14:14:16 +03:00
# ifdef HAVE_ZLIB_H
2001-06-20 17:55:33 +04:00
printf ( " \t --compress : turn on gzip compression of output \n " ) ;
2001-12-18 14:14:16 +03:00
# endif
2001-10-22 13:46:13 +04:00
# ifdef LIBXML_DOCB_ENABLED
printf ( " \t --sgml : use the DocBook SGML parser \n " ) ;
# endif
2001-06-20 17:55:33 +04:00
# ifdef LIBXML_HTML_ENABLED
printf ( " \t --html : use the HTML parser \n " ) ;
# endif
printf ( " \t --push : use the push mode of the parser \n " ) ;
# ifdef HAVE_SYS_MMAN_H
printf ( " \t --memory : parse from memory \n " ) ;
# endif
printf ( " \t --nowarning : do not emit warnings from parser/validator \n " ) ;
printf ( " \t --noblanks : drop (ignorable?) blanks spaces \n " ) ;
2001-08-14 18:12:47 +04:00
printf ( " \t --format : reformat/reindent the input \n " ) ;
2001-06-20 17:55:33 +04:00
printf ( " \t --testIO : test user I/O support \n " ) ;
printf ( " \t --encode encoding : output in the given encoding \n " ) ;
# ifdef LIBXML_CATALOG_ENABLED
2001-11-26 13:32:08 +03:00
printf ( " \t --catalogs : use SGML catalogs from $SGML_CATALOG_FILES \n " ) ;
printf ( " \t otherwise XML Catalogs starting from \n " ) ;
2003-01-26 22:49:04 +03:00
printf ( " \t " XML_XML_DEFAULT_CATALOG " are activated by default \n " ) ;
2001-09-09 12:38:09 +04:00
printf ( " \t --nocatalogs: deactivate all catalogs \n " ) ;
2001-06-20 17:55:33 +04:00
# endif
printf ( " \t --auto : generate a small doc on the fly \n " ) ;
# ifdef LIBXML_XINCLUDE_ENABLED
printf ( " \t --xinclude : do XInclude processing \n " ) ;
# endif
2001-12-31 19:16:02 +03:00
printf ( " \t --loaddtd : fetch external DTD \n " ) ;
2001-08-07 05:10:10 +04:00
printf ( " \t --dtdattr : loaddtd + populate the tree with inherited attributes \n " ) ;
2001-12-14 01:21:58 +03:00
printf ( " \t --dropdtd : remove the DOCTYPE of the input docs \n " ) ;
2003-01-03 19:19:51 +03:00
printf ( " \t --stream : use the streaming interface to process very large files \n " ) ;
2003-01-06 01:37:17 +03:00
printf ( " \t --chkregister : verify the node registration code \n " ) ;
2003-02-07 15:38:22 +03:00
# ifdef LIBXML_SCHEMAS_ENABLED
2003-02-05 16:19:53 +03:00
printf ( " \t --relaxng schema : do RelaxNG validation against the schema \n " ) ;
# endif
2002-01-25 17:15:40 +03: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 17:55:33 +04:00
}
2003-01-06 01:37:17 +03:00
static void registerNode ( xmlNodePtr node )
{
node - > _private = malloc ( sizeof ( long ) ) ;
* ( long * ) node - > _private = ( long ) 0x81726354 ;
}
static void deregisterNode ( xmlNodePtr node )
{
assert ( node - > _private ! = NULL ) ;
assert ( * ( long * ) node - > _private = = ( long ) 0x81726354 ) ;
free ( node - > _private ) ;
}
2001-01-03 16:32:39 +03:00
int
main ( int argc , char * * argv ) {
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 ;
2000-04-05 22:38:42 +04:00
2001-06-20 17:55:33 +04:00
if ( argc < = 1 ) {
usage ( argv [ 0 ] ) ;
return ( 1 ) ;
}
2000-06-29 03:40:59 +04:00
LIBXML_TEST_VERSION
2000-04-05 22:38:42 +04:00
for ( i = 1 ; i < argc ; i + + ) {
2001-06-20 17:55:33 +04:00
if ( ! strcmp ( argv [ i ] , " - " ) )
break ;
if ( argv [ i ] [ 0 ] ! = ' - ' )
continue ;
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 ;
} else
# endif
if ( ( ! strcmp ( argv [ i ] , " -copy " ) ) | | ( ! strcmp ( argv [ i ] , " --copy " ) ) )
copy + + ;
else if ( ( ! strcmp ( argv [ i ] , " -recover " ) ) | |
( ! strcmp ( argv [ i ] , " --recover " ) ) )
recovery + + ;
else if ( ( ! strcmp ( argv [ i ] , " -noent " ) ) | |
( ! strcmp ( argv [ i ] , " --noent " ) ) )
noent + + ;
2001-06-17 14:31:07 +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 + + ;
2001-12-18 14:14:16 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -o " ) ) | |
( ! strcmp ( argv [ i ] , " -output " ) ) | |
( ! strcmp ( argv [ i ] , " --output " ) ) ) {
i + + ;
2002-04-09 13:55:20 +04:00
output = argv [ i ] ;
2001-12-18 14:14:16 +03:00
}
2000-04-05 22:38:42 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -htmlout " ) ) | |
( ! strcmp ( argv [ i ] , " --htmlout " ) ) )
htmlout + + ;
2001-10-22 13:46:13 +04:00
# ifdef LIBXML_DOCB_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -sgml " ) ) | |
( ! strcmp ( argv [ i ] , " --sgml " ) ) ) {
sgml + + ;
}
# endif
2000-04-05 22:38:42 +04:00
# ifdef LIBXML_HTML_ENABLED
else if ( ( ! strcmp ( argv [ i ] , " -html " ) ) | |
( ! strcmp ( argv [ i ] , " --html " ) ) ) {
html + + ;
}
# endif /* LIBXML_HTML_ENABLED */
else if ( ( ! strcmp ( argv [ i ] , " -nowrap " ) ) | |
( ! strcmp ( argv [ i ] , " --nowrap " ) ) )
nowrap + + ;
2001-06-20 17:55:33 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -loaddtd " ) ) | |
( ! strcmp ( argv [ i ] , " --loaddtd " ) ) )
loaddtd + + ;
2001-08-07 05:10:10 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -dtdattr " ) ) | |
( ! strcmp ( argv [ i ] , " --dtdattr " ) ) ) {
loaddtd + + ;
dtdattrs + + ;
} else if ( ( ! strcmp ( argv [ i ] , " -valid " ) ) | |
2000-04-05 22:38:42 +04:00
( ! strcmp ( argv [ i ] , " --valid " ) ) )
valid + + ;
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 + + ;
2001-06-20 17:55:33 +04:00
loaddtd + + ;
} else if ( ( ! strcmp ( argv [ i ] , " -dtdvalid " ) ) | |
2000-10-11 19:57:05 +04:00
( ! strcmp ( argv [ i ] , " --dtdvalid " ) ) ) {
i + + ;
dtdvalid = argv [ i ] ;
2001-06-20 17:55:33 +04:00
loaddtd + + ;
2000-10-11 19:57:05 +04:00
}
2001-12-14 01:21:58 +03:00
else if ( ( ! strcmp ( argv [ i ] , " -dropdtd " ) ) | |
( ! strcmp ( argv [ i ] , " --dropdtd " ) ) )
dropdtd + + ;
2000-04-05 22:38:42 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -insert " ) ) | |
( ! strcmp ( argv [ i ] , " --insert " ) ) )
insert + + ;
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 " ) ) | |
( ! strcmp ( argv [ i ] , " --repeat " ) ) )
repeat + + ;
else if ( ( ! strcmp ( argv [ i ] , " -push " ) ) | |
( ! strcmp ( argv [ i ] , " --push " ) ) )
push + + ;
2000-07-22 00:32:03 +04:00
# ifdef HAVE_SYS_MMAN_H
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 " ) ) | |
( ! strcmp ( argv [ i ] , " --xinclude " ) ) )
xinclude + + ;
# endif
2001-12-18 14:14:16 +03:00
# ifdef HAVE_ZLIB_H
2000-04-05 22:38:42 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -compress " ) ) | |
( ! strcmp ( argv [ i ] , " --compress " ) ) ) {
compress + + ;
xmlSetCompressMode ( 9 ) ;
}
2001-12-18 14:14:16 +03:00
# endif
2000-04-05 22:38:42 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -nowarning " ) ) | |
( ! strcmp ( argv [ i ] , " --nowarning " ) ) ) {
xmlGetWarningsDefaultValue = 0 ;
2000-08-27 01:40:43 +04:00
xmlPedanticParserDefault ( 0 ) ;
}
else if ( ( ! strcmp ( argv [ i ] , " -pedantic " ) ) | |
( ! strcmp ( argv [ i ] , " --pedantic " ) ) ) {
xmlGetWarningsDefaultValue = 1 ;
xmlPedanticParserDefault ( 1 ) ;
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 + + ;
xmlParserDebugEntities = 1 ;
}
2001-05-22 19:08:55 +04:00
# endif
# 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 + + ;
2001-05-22 19:08:55 +04:00
}
2000-09-22 20:07:02 +04:00
# endif
2000-06-29 03:40:59 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -encode " ) ) | |
( ! strcmp ( argv [ i ] , " --encode " ) ) ) {
i + + ;
encoding = argv [ i ] ;
2000-08-27 01:40:43 +04:00
/*
* OK it ' s for testing purposes
*/
xmlAddEncodingAlias ( " UTF-8 " , " DVEnc " ) ;
2000-06-29 03:40:59 +04:00
}
2000-04-05 22:38:42 +04:00
else if ( ( ! strcmp ( argv [ i ] , " -noblanks " ) ) | |
( ! strcmp ( argv [ i ] , " --noblanks " ) ) ) {
noblanks + + ;
xmlKeepBlanksDefault ( 0 ) ;
2001-08-14 18:12:47 +04:00
}
else if ( ( ! strcmp ( argv [ i ] , " -format " ) ) | |
( ! strcmp ( argv [ i ] , " --format " ) ) ) {
noblanks + + ;
format + + ;
xmlKeepBlanksDefault ( 0 ) ;
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
}
else if ( ( ! strcmp ( argv [ i ] , " -chkregister " ) ) | |
( ! strcmp ( argv [ i ] , " --chkregister " ) ) ) {
chkregister + + ;
2003-02-05 16:19:53 +03:00
# ifdef LIBXML_SCHEMAS_ENABLED
} else if ( ( ! strcmp ( argv [ i ] , " -relaxng " ) ) | |
( ! strcmp ( argv [ i ] , " --relaxng " ) ) ) {
i + + ;
relaxng = argv [ i ] ;
noent + + ;
# endif
2001-06-20 17:55:33 +04:00
} else {
fprintf ( stderr , " Unknown option %s \n " , argv [ i ] ) ;
usage ( argv [ 0 ] ) ;
return ( 1 ) ;
}
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 {
fprintf ( stderr , " Variable $SGML_CATALOG_FILES not set \n " ) ;
}
2001-08-22 04:06:49 +04:00
}
}
# endif
2003-01-06 01:37:17 +03:00
if ( chkregister ) {
xmlRegisterNodeDefault ( registerNode ) ;
xmlDeregisterNodeDefault ( deregisterNode ) ;
}
2001-07-23 23:39:43 +04:00
xmlLineNumbersDefault ( 1 ) ;
2001-08-07 05:10:10 +04:00
if ( loaddtd ! = 0 )
xmlLoadExtDtdDefaultValue | = XML_DETECT_IDS ;
if ( dtdattrs )
xmlLoadExtDtdDefaultValue | = XML_COMPLETE_ATTRS ;
2000-04-05 22:38:42 +04:00
if ( noent ! = 0 ) xmlSubstituteEntitiesDefault ( 1 ) ;
if ( valid ! = 0 ) xmlDoValidityCheckingDefaultValue = 1 ;
if ( ( htmlout ) & & ( ! nowrap ) ) {
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext ,
2000-04-05 22:38:42 +04:00
" <!DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.0 Transitional//EN \" \n " ) ;
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext ,
" \t \" http://www.w3.org/TR/REC-html40/loose.dtd \" > \n " ) ;
xmlGenericError ( xmlGenericErrorContext ,
2000-04-05 22:38:42 +04:00
" <html><head><title>%s output</title></head> \n " ,
argv [ 0 ] ) ;
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext ,
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
# ifdef LIBXML_SCHEMAS_ENABLED
if ( relaxng ! = NULL ) {
xmlRelaxNGParserCtxtPtr ctxt ;
ctxt = xmlRelaxNGNewParserCtxt ( relaxng ) ;
xmlRelaxNGSetParserErrors ( ctxt ,
( xmlRelaxNGValidityErrorFunc ) fprintf ,
( xmlRelaxNGValidityWarningFunc ) fprintf ,
stderr ) ;
relaxngschemas = xmlRelaxNGParse ( ctxt ) ;
xmlRelaxNGFreeParserCtxt ( ctxt ) ;
}
# endif
2000-04-05 22:38:42 +04:00
for ( i = 1 ; i < argc ; i + + ) {
2000-06-29 03:40:59 +04:00
if ( ( ! strcmp ( argv [ i ] , " -encode " ) ) | |
( ! strcmp ( argv [ i ] , " --encode " ) ) ) {
i + + ;
continue ;
2001-12-18 14:14:16 +03:00
} else if ( ( ! strcmp ( argv [ i ] , " -o " ) ) | |
( ! strcmp ( argv [ i ] , " -output " ) ) | |
( ! strcmp ( argv [ i ] , " --output " ) ) ) {
i + + ;
continue ;
2000-06-29 03:40:59 +04:00
}
2000-10-11 19:57:05 +04:00
if ( ( ! strcmp ( argv [ i ] , " -dtdvalid " ) ) | |
( ! strcmp ( argv [ i ] , " --dtdvalid " ) ) ) {
i + + ;
continue ;
}
2003-02-05 16:19:53 +03:00
if ( ( ! strcmp ( argv [ i ] , " -relaxng " ) ) | |
( ! strcmp ( argv [ i ] , " --relaxng " ) ) ) {
i + + ;
continue ;
}
2001-02-25 19:11:03 +03:00
if ( ( timing ) & & ( repeat ) )
2001-12-18 10:09:59 +03:00
startTimer ( ) ;
2001-12-31 19:16:02 +03:00
/* Remember file names. "-" means stdin. <sven@zen.org> */
2001-01-03 16:32:39 +03:00
if ( ( argv [ i ] [ 0 ] ! = ' - ' ) | | ( strcmp ( argv [ i ] , " - " ) = = 0 ) ) {
2000-04-05 22:38:42 +04:00
if ( repeat ) {
2003-01-03 19:19:51 +03:00
for ( acount = 0 ; acount < 100 * repeat ; acount + + )
if ( stream ! = 0 )
streamFile ( argv [ i ] ) ;
else
parseAndPrintFile ( argv [ i ] ) ;
} else {
if ( stream ! = 0 )
streamFile ( argv [ i ] ) ;
else
2000-04-05 22:38:42 +04:00
parseAndPrintFile ( argv [ i ] ) ;
2003-01-03 19:19:51 +03:00
}
2000-04-05 22:38:42 +04:00
files + + ;
2001-12-04 16:14:44 +03:00
if ( ( timing ) & & ( repeat ) ) {
2001-12-18 10:09:59 +03:00
endTimer ( " 100 iterations " ) ;
2001-12-04 16:14:44 +03:00
}
2001-02-25 19:11:03 +03:00
}
2000-04-05 22:38:42 +04:00
}
2001-04-11 11:50:02 +04:00
if ( generate )
parseAndPrintFile ( NULL ) ;
2000-04-05 22:38:42 +04:00
if ( ( htmlout ) & & ( ! nowrap ) ) {
2000-10-25 23:56:55 +04:00
xmlGenericError ( xmlGenericErrorContext , " </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 ) ) {
2001-06-20 17:55:33 +04:00
usage ( argv [ 0 ] ) ;
2000-04-05 22:38:42 +04:00
}
2003-02-05 16:19:53 +03:00
# ifdef LIBXML_SCHEMAS_ENABLED
if ( relaxngschemas ! = NULL )
xmlRelaxNGFree ( relaxngschemas ) ;
xmlRelaxNGCleanupTypes ( ) ;
# endif
2000-04-05 22:38:42 +04:00
xmlCleanupParser ( ) ;
xmlMemoryDump ( ) ;
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