testHTML.c revision 38ae7e4efe803ea78b6499cd05a394db32623e41
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/*
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * testHTML.c : a small tester program for HTML input.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * See Copyright for the status of this software.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * daniel@veillard.com
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include "libxml.h"
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef LIBXML_HTML_ENABLED
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <string.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <stdarg.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef HAVE_SYS_TYPES_H
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <sys/types.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef HAVE_SYS_STAT_H
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <sys/stat.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef HAVE_FCNTL_H
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <fcntl.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef HAVE_UNISTD_H
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <unistd.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef HAVE_STDLIB_H
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <stdlib.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <libxml/xmlmemory.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <libxml/HTMLparser.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <libxml/HTMLtree.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <libxml/debugXML.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <libxml/xmlerror.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <libxml/globals.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef LIBXML_DEBUG_ENABLED
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic int debug = 0;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic int copy = 0;
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic int sax = 0;
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic int repeat = 0;
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic int noout = 0;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef LIBXML_PUSH_ENABLED
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic int push = 0;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif /* LIBXML_PUSH_ENABLED */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic char *encoding = NULL;
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic int options = 0;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic xmlSAXHandler emptySAXHandlerStruct = {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* internalSubset */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* isStandalone */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* hasInternalSubset */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* hasExternalSubset */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* resolveEntity */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* getEntity */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* entityDecl */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* notationDecl */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* attributeDecl */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* elementDecl */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* unparsedEntityDecl */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* setDocumentLocator */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* startDocument */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* endDocument */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* startElement */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* endElement */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* reference */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* characters */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* ignorableWhitespace */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* processingInstruction */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* comment */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* xmlParserWarning */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* xmlParserError */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* xmlParserError */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* getParameterEntity */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* cdataBlock */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* externalSubset */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow 1, /* initialized */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL, /* private */
91d632c867159b669d90fc7e172295433d0519efgwr NULL, /* startElementNsSAX2Func */
91d632c867159b669d90fc7e172295433d0519efgwr NULL, /* endElementNsSAX2Func */
91d632c867159b669d90fc7e172295433d0519efgwr NULL /* xmlStructuredErrorFunc */
91d632c867159b669d90fc7e172295433d0519efgwr};
91d632c867159b669d90fc7e172295433d0519efgwr
91d632c867159b669d90fc7e172295433d0519efgwrstatic xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct;
91d632c867159b669d90fc7e172295433d0519efgwrextern xmlSAXHandlerPtr debugSAXHandler;
91d632c867159b669d90fc7e172295433d0519efgwr
91d632c867159b669d90fc7e172295433d0519efgwr/************************************************************************
91d632c867159b669d90fc7e172295433d0519efgwr * *
91d632c867159b669d90fc7e172295433d0519efgwr * Debug Handlers *
91d632c867159b669d90fc7e172295433d0519efgwr * *
91d632c867159b669d90fc7e172295433d0519efgwr ************************************************************************/
91d632c867159b669d90fc7e172295433d0519efgwr
91d632c867159b669d90fc7e172295433d0519efgwr/**
91d632c867159b669d90fc7e172295433d0519efgwr * isStandaloneDebug:
91d632c867159b669d90fc7e172295433d0519efgwr * @ctxt: An XML parser context
91d632c867159b669d90fc7e172295433d0519efgwr *
91d632c867159b669d90fc7e172295433d0519efgwr * Is this document tagged standalone ?
91d632c867159b669d90fc7e172295433d0519efgwr *
91d632c867159b669d90fc7e172295433d0519efgwr * Returns 1 if true
91d632c867159b669d90fc7e172295433d0519efgwr */
91d632c867159b669d90fc7e172295433d0519efgwrstatic int
91d632c867159b669d90fc7e172295433d0519efgwrisStandaloneDebug(void *ctx ATTRIBUTE_UNUSED)
91d632c867159b669d90fc7e172295433d0519efgwr{
91d632c867159b669d90fc7e172295433d0519efgwr fprintf(stdout, "SAX.isStandalone()\n");
91d632c867159b669d90fc7e172295433d0519efgwr return(0);
91d632c867159b669d90fc7e172295433d0519efgwr}
91d632c867159b669d90fc7e172295433d0519efgwr
91d632c867159b669d90fc7e172295433d0519efgwr/**
91d632c867159b669d90fc7e172295433d0519efgwr * hasInternalSubsetDebug:
91d632c867159b669d90fc7e172295433d0519efgwr * @ctxt: An XML parser context
91d632c867159b669d90fc7e172295433d0519efgwr *
91d632c867159b669d90fc7e172295433d0519efgwr * Does this document has an internal subset
91d632c867159b669d90fc7e172295433d0519efgwr *
91d632c867159b669d90fc7e172295433d0519efgwr * Returns 1 if true
91d632c867159b669d90fc7e172295433d0519efgwr */
91d632c867159b669d90fc7e172295433d0519efgwrstatic int
91d632c867159b669d90fc7e172295433d0519efgwrhasInternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.hasInternalSubset()\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow return(0);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
91d632c867159b669d90fc7e172295433d0519efgwr
91d632c867159b669d90fc7e172295433d0519efgwr/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * hasExternalSubsetDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Does this document has an external subset
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Returns 1 if true
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic int
4bff34e37def8a90f9194d81bc345c52ba20086athurlowhasExternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.hasExternalSubset()\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow return(0);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * hasInternalSubsetDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Does this document has an internal subset
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowinternalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow const xmlChar *ExternalID, const xmlChar *SystemID)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.internalSubset(%s,", name);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (ExternalID == NULL)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, " ,");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, " %s,", ExternalID);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (SystemID == NULL)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, " )\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, " %s)\n", SystemID);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * resolveEntityDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @publicId: The public ID of the entity
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @systemId: The system ID of the entity
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Special entity resolver, better left to the parser, it has
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * more context than the application layer.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * The default behaviour is to NOT resolve the entities, in that case
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * the ENTITY_REF nodes are built in the structure (and the parameter
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * values).
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic xmlParserInputPtr
4bff34e37def8a90f9194d81bc345c52ba20086athurlowresolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xmlChar *systemId)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.resolveEntity(");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (publicId != NULL)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "%s", (char *)publicId);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, " ");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (systemId != NULL)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, ", %s)\n", (char *)systemId);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, ", )\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/*********
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (systemId != NULL) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow return(xmlNewInputFromFile(ctxt, (char *) systemId));
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *********/
4bff34e37def8a90f9194d81bc345c52ba20086athurlow return(NULL);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * getEntityDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @name: The entity name
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Get an entity by name
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic xmlEntityPtr
4bff34e37def8a90f9194d81bc345c52ba20086athurlowgetEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.getEntity(%s)\n", name);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow return(NULL);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * getParameterEntityDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @name: The entity name
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Get a parameter entity by name
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Returns the xmlParserInputPtr
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic xmlEntityPtr
4bff34e37def8a90f9194d81bc345c52ba20086athurlowgetParameterEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.getParameterEntity(%s)\n", name);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow return(NULL);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * entityDeclDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @name: the entity name
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @type: the entity type
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @publicId: The public ID of the entity
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @systemId: The system ID of the entity
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @content: the entity value (without processing).
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * An entity definition has been parsed
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowentityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
4bff34e37def8a90f9194d81bc345c52ba20086athurlow name, type, publicId, systemId, content);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * attributeDeclDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @name: the attribute name
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @type: the attribute type
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * An attribute definition has been parsed
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowattributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *elem, const xmlChar *name,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int type, int def, const xmlChar *defaultValue,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow xmlEnumerationPtr tree ATTRIBUTE_UNUSED)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
4bff34e37def8a90f9194d81bc345c52ba20086athurlow elem, name, type, def, defaultValue);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * elementDeclDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @name: the element name
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @type: the element type
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @content: the element value (without processing).
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * An element definition has been parsed
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowelementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow xmlElementContentPtr content ATTRIBUTE_UNUSED)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n",
4bff34e37def8a90f9194d81bc345c52ba20086athurlow name, type);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * notationDeclDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @name: The name of the notation
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @publicId: The public ID of the entity
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @systemId: The system ID of the entity
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * What to do when a notation declaration has been parsed.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlownotationDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow const xmlChar *publicId, const xmlChar *systemId)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n",
4bff34e37def8a90f9194d81bc345c52ba20086athurlow (char *) name, (char *) publicId, (char *) systemId);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * unparsedEntityDeclDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @name: The name of the entity
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @publicId: The public ID of the entity
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @systemId: The system ID of the entity
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @notationName: the name of the notation
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * What to do when an unparsed entity declaration is parsed
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowunparsedEntityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow const xmlChar *publicId, const xmlChar *systemId,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow const xmlChar *notationName)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
4bff34e37def8a90f9194d81bc345c52ba20086athurlow (char *) name, (char *) publicId, (char *) systemId,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow (char *) notationName);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * setDocumentLocatorDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @loc: A SAX Locator
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Receive the document locator at startup, actually xmlDefaultSAXLocator
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Everything is available on the context, so this is useless in our case.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowsetDocumentLocatorDebug(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.setDocumentLocator()\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * startDocumentDebug:
91d632c867159b669d90fc7e172295433d0519efgwr * @ctxt: An XML parser context
91d632c867159b669d90fc7e172295433d0519efgwr *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * called when the document start being processed.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstartDocumentDebug(void *ctx ATTRIBUTE_UNUSED)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.startDocument()\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * endDocumentDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * called when the document end has been detected.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowendDocumentDebug(void *ctx ATTRIBUTE_UNUSED)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.endDocument()\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * startElementDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @name: The element name
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * called when an opening tag has been processed.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstartElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int i;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.startElement(%s", (char *) name);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (atts != NULL) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow for (i = 0;(atts[i] != NULL);i++) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, ", %s", atts[i++]);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (atts[i] != NULL) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow unsigned char output[40];
4bff34e37def8a90f9194d81bc345c52ba20086athurlow const unsigned char *att = atts[i];
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int outlen, attlen;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "='");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow while ((attlen = strlen((char*)att)) > 0) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow outlen = sizeof output - 1;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlEncodeEntities(output, &outlen, att, &attlen, '\'');
4bff34e37def8a90f9194d81bc345c52ba20086athurlow output[outlen] = 0;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "%s", (char *) output);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow att += attlen;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "'");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, ")\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * endElementDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @name: The element name
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * called when the end of an element has been detected.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowendElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.endElement(%s)\n", (char *) name);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * charactersDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ch: a xmlChar string
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @len: the number of xmlChar
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * receiving some chars from the parser.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Question: how much at a time ???
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowcharactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow unsigned char output[40];
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int inlen = len, outlen = 30;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlEncodeEntities(output, &outlen, ch, &inlen, 0);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow output[outlen] = 0;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.characters(%s, %d)\n", output, len);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * cdataDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ch: a xmlChar string
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @len: the number of xmlChar
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * receiving some cdata chars from the parser.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Question: how much at a time ???
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowcdataDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow unsigned char output[40];
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int inlen = len, outlen = 30;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlEncodeEntities(output, &outlen, ch, &inlen, 0);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow output[outlen] = 0;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.cdata(%s, %d)\n", output, len);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * referenceDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @name: The entity name
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * called when an entity reference is detected.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowreferenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.reference(%s)\n", name);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
91d632c867159b669d90fc7e172295433d0519efgwr
91d632c867159b669d90fc7e172295433d0519efgwr/**
91d632c867159b669d90fc7e172295433d0519efgwr * ignorableWhitespaceDebug:
91d632c867159b669d90fc7e172295433d0519efgwr * @ctxt: An XML parser context
91d632c867159b669d90fc7e172295433d0519efgwr * @ch: a xmlChar string
91d632c867159b669d90fc7e172295433d0519efgwr * @start: the first char in the string
91d632c867159b669d90fc7e172295433d0519efgwr * @len: the number of xmlChar
91d632c867159b669d90fc7e172295433d0519efgwr *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * receiving some ignorable whitespaces from the parser.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Question: how much at a time ???
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowignorableWhitespaceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow char output[40];
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int i;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
91d632c867159b669d90fc7e172295433d0519efgwr for (i = 0;(i<len) && (i < 30);i++)
91d632c867159b669d90fc7e172295433d0519efgwr output[i] = ch[i];
91d632c867159b669d90fc7e172295433d0519efgwr output[i] = 0;
91d632c867159b669d90fc7e172295433d0519efgwr
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.ignorableWhitespace(%s, %d)\n", output, len);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * processingInstructionDebug:
91d632c867159b669d90fc7e172295433d0519efgwr * @ctxt: An XML parser context
91d632c867159b669d90fc7e172295433d0519efgwr * @target: the target name
91d632c867159b669d90fc7e172295433d0519efgwr * @data: the PI data's
91d632c867159b669d90fc7e172295433d0519efgwr * @len: the number of xmlChar
91d632c867159b669d90fc7e172295433d0519efgwr *
91d632c867159b669d90fc7e172295433d0519efgwr * A processing instruction has been parsed.
91d632c867159b669d90fc7e172295433d0519efgwr */
91d632c867159b669d90fc7e172295433d0519efgwrstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowprocessingInstructionDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *target,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow const xmlChar *data)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.processingInstruction(%s, %s)\n",
4bff34e37def8a90f9194d81bc345c52ba20086athurlow (char *) target, (char *) data);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * commentDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @value: the comment content
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * A comment has been parsed.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowcommentDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.comment(%s)\n", value);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * warningDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @msg: the message to display/transmit
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @...: extra parameters for the message display
91d632c867159b669d90fc7e172295433d0519efgwr *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Display and format a warning messages, gives file, line, position and
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * extra parameters.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void XMLCDECL
4bff34e37def8a90f9194d81bc345c52ba20086athurlowwarningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow va_list args;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow va_start(args, msg);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.warning: ");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow vfprintf(stdout, msg, args);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow va_end(args);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * errorDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @msg: the message to display/transmit
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @...: extra parameters for the message display
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Display and format a error messages, gives file, line, position and
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * extra parameters.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void XMLCDECL
4bff34e37def8a90f9194d81bc345c52ba20086athurlowerrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow va_list args;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow va_start(args, msg);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.error: ");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow vfprintf(stdout, msg, args);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow va_end(args);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/**
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * fatalErrorDebug:
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @ctxt: An XML parser context
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @msg: the message to display/transmit
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * @...: extra parameters for the message display
4bff34e37def8a90f9194d81bc345c52ba20086athurlow *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Display and format a fatalError messages, gives file, line, position and
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * extra parameters.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void XMLCDECL
4bff34e37def8a90f9194d81bc345c52ba20086athurlowfatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow{
4bff34e37def8a90f9194d81bc345c52ba20086athurlow va_list args;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow va_start(args, msg);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "SAX.fatalError: ");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow vfprintf(stdout, msg, args);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow va_end(args);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic xmlSAXHandler debugSAXHandlerStruct = {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow internalSubsetDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow isStandaloneDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow hasInternalSubsetDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow hasExternalSubsetDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow resolveEntityDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow getEntityDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow entityDeclDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow notationDeclDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow attributeDeclDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow elementDeclDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow unparsedEntityDeclDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow setDocumentLocatorDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow startDocumentDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow endDocumentDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow startElementDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow endElementDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow referenceDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow charactersDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow ignorableWhitespaceDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow processingInstructionDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow commentDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow warningDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow errorDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fatalErrorDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow getParameterEntityDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow cdataDebug,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow 1,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow NULL
4bff34e37def8a90f9194d81bc345c52ba20086athurlow};
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlowxmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow/************************************************************************
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Debug *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * *
4bff34e37def8a90f9194d81bc345c52ba20086athurlow ************************************************************************/
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowparseSAXFile(char *filename) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlDocPtr doc = NULL;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /*
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Empty callbacks for checking
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef LIBXML_PUSH_ENABLED
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (push) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow FILE *f;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow f = fopen(filename, "rb");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow f = fopen(filename, "r");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (f != NULL) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int res, size = 3;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow char chars[4096];
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlParserCtxtPtr ctxt;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /* if (repeat) */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow size = 4096;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow res = fread(chars, 1, 4, f);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (res > 0) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow ctxt = htmlCreatePushParserCtxt(emptySAXHandler, NULL,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow chars, res, filename, XML_CHAR_ENCODING_NONE);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow while ((res = fread(chars, 1, size, f)) > 0) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlParseChunk(ctxt, chars, res, 0);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlParseChunk(ctxt, chars, 0, 1);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow doc = ctxt->myDoc;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlFreeParserCtxt(ctxt);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (doc != NULL) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "htmlSAXParseFile returned non-NULL\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow xmlFreeDoc(doc);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fclose(f);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (!noout) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow f = fopen(filename, "rb");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow f = fopen(filename, "r");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (f != NULL) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int res, size = 3;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow char chars[4096];
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlParserCtxtPtr ctxt;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /* if (repeat) */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow size = 4096;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow res = fread(chars, 1, 4, f);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (res > 0) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow ctxt = htmlCreatePushParserCtxt(debugSAXHandler, NULL,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow chars, res, filename, XML_CHAR_ENCODING_NONE);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow while ((res = fread(chars, 1, size, f)) > 0) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlParseChunk(ctxt, chars, res, 0);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlParseChunk(ctxt, chars, 0, 1);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow doc = ctxt->myDoc;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlFreeParserCtxt(ctxt);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (doc != NULL) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "htmlSAXParseFile returned non-NULL\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow xmlFreeDoc(doc);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fclose(f);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow } else {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif /* LIBXML_PUSH_ENABLED */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow doc = htmlSAXParseFile(filename, NULL, emptySAXHandler, NULL);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (doc != NULL) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "htmlSAXParseFile returned non-NULL\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow xmlFreeDoc(doc);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (!noout) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /*
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * Debug callback
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow doc = htmlSAXParseFile(filename, NULL, debugSAXHandler, NULL);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (doc != NULL) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fprintf(stdout, "htmlSAXParseFile returned non-NULL\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow xmlFreeDoc(doc);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef LIBXML_PUSH_ENABLED
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif /* LIBXML_PUSH_ENABLED */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlowstatic void
4bff34e37def8a90f9194d81bc345c52ba20086athurlowparseAndPrintFile(char *filename) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlDocPtr doc = NULL;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /*
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * build an HTML tree from a string;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef LIBXML_PUSH_ENABLED
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (push) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow FILE *f;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow f = fopen(filename, "rb");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow f = fopen(filename, "r");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (f != NULL) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int res, size = 3;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow char chars[4096];
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlParserCtxtPtr ctxt;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /* if (repeat) */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow size = 4096;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow res = fread(chars, 1, 4, f);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (res > 0) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow ctxt = htmlCreatePushParserCtxt(NULL, NULL,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow chars, res, filename, XML_CHAR_ENCODING_NONE);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow while ((res = fread(chars, 1, size, f)) > 0) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlParseChunk(ctxt, chars, res, 0);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlParseChunk(ctxt, chars, 0, 1);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow doc = ctxt->myDoc;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlFreeParserCtxt(ctxt);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow fclose(f);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow } else {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow doc = htmlReadFile(filename, NULL, options);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow doc = htmlReadFile(filename,NULL,options);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (doc == NULL) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow xmlGenericError(xmlGenericErrorContext,
4bff34e37def8a90f9194d81bc345c52ba20086athurlow "Could not parse %s\n", filename);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef LIBXML_TREE_ENABLED
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /*
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * test intermediate copy if needed.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (copy) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlDocPtr tmp;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow tmp = doc;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow doc = xmlCopyDoc(doc, 1);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow xmlFreeDoc(tmp);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef LIBXML_OUTPUT_ENABLED
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /*
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * print it.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (!noout) {
91d632c867159b669d90fc7e172295433d0519efgwr#ifdef LIBXML_DEBUG_ENABLED
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (!debug) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (encoding)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlSaveFileEnc("-", doc, encoding);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlDocDump(stdout, doc);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow } else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow xmlDebugDumpDocument(stdout, doc);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (encoding)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlSaveFileEnc("-", doc, encoding);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow htmlDocDump(stdout, doc);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif /* LIBXML_OUTPUT_ENABLED */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow /*
4bff34e37def8a90f9194d81bc345c52ba20086athurlow * free it.
4bff34e37def8a90f9194d81bc345c52ba20086athurlow */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow xmlFreeDoc(doc);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint main(int argc, char **argv) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int i, count;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow int files = 0;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow for (i = 1; i < argc ; i++) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef LIBXML_DEBUG_ENABLED
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
4bff34e37def8a90f9194d81bc345c52ba20086athurlow debug++;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy")))
4bff34e37def8a90f9194d81bc345c52ba20086athurlow copy++;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef LIBXML_PUSH_ENABLED
4bff34e37def8a90f9194d81bc345c52ba20086athurlow else if ((!strcmp(argv[i], "-push")) || (!strcmp(argv[i], "--push")))
4bff34e37def8a90f9194d81bc345c52ba20086athurlow push++;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif /* LIBXML_PUSH_ENABLED */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow else if ((!strcmp(argv[i], "-sax")) || (!strcmp(argv[i], "--sax")))
4bff34e37def8a90f9194d81bc345c52ba20086athurlow sax++;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow else if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout")))
4bff34e37def8a90f9194d81bc345c52ba20086athurlow noout++;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow else if ((!strcmp(argv[i], "-repeat")) ||
4bff34e37def8a90f9194d81bc345c52ba20086athurlow (!strcmp(argv[i], "--repeat")))
4bff34e37def8a90f9194d81bc345c52ba20086athurlow repeat++;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow else if ((!strcmp(argv[i], "-encode")) ||
4bff34e37def8a90f9194d81bc345c52ba20086athurlow (!strcmp(argv[i], "--encode"))) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow i++;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow encoding = argv[i];
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow for (i = 1; i < argc ; i++) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if ((!strcmp(argv[i], "-encode")) ||
4bff34e37def8a90f9194d81bc345c52ba20086athurlow (!strcmp(argv[i], "--encode"))) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow i++;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow continue;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (argv[i][0] != '-') {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (repeat) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow for (count = 0;count < 100 * repeat;count++) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (sax)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow parseSAXFile(argv[i]);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow parseAndPrintFile(argv[i]);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow } else {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (sax)
4bff34e37def8a90f9194d81bc345c52ba20086athurlow parseSAXFile(argv[i]);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow else
4bff34e37def8a90f9194d81bc345c52ba20086athurlow parseAndPrintFile(argv[i]);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow files ++;
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow if (files == 0) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow printf("Usage : %s [--debug] [--copy] [--copy] HTMLfiles ...\n",
4bff34e37def8a90f9194d81bc345c52ba20086athurlow argv[0]);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow printf("\tParse the HTML files and output the result of the parsing\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef LIBXML_DEBUG_ENABLED
4bff34e37def8a90f9194d81bc345c52ba20086athurlow printf("\t--debug : dump a debug tree of the in-memory document\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlow printf("\t--copy : used to test the internal copy implementation\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow printf("\t--sax : debug the sequence of SAX callbacks\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow printf("\t--repeat : parse the file 100 times, for timing\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow printf("\t--noout : do not print the result\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#ifdef LIBXML_PUSH_ENABLED
4bff34e37def8a90f9194d81bc345c52ba20086athurlow printf("\t--push : use the push mode parser\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif /* LIBXML_PUSH_ENABLED */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow printf("\t--encode encoding : output in the given encoding\n");
4bff34e37def8a90f9194d81bc345c52ba20086athurlow }
4bff34e37def8a90f9194d81bc345c52ba20086athurlow xmlCleanupParser();
4bff34e37def8a90f9194d81bc345c52ba20086athurlow xmlMemoryDump();
4bff34e37def8a90f9194d81bc345c52ba20086athurlow
4bff34e37def8a90f9194d81bc345c52ba20086athurlow return(0);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#else /* !LIBXML_HTML_ENABLED */
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#include <stdio.h>
4bff34e37def8a90f9194d81bc345c52ba20086athurlowint main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
4bff34e37def8a90f9194d81bc345c52ba20086athurlow printf("%s : HTML support not compiled in\n", argv[0]);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow return(0);
4bff34e37def8a90f9194d81bc345c52ba20086athurlow}
4bff34e37def8a90f9194d81bc345c52ba20086athurlow#endif
4bff34e37def8a90f9194d81bc345c52ba20086athurlow