ReactOS 0.4.15-dev-8138-g1e75ea8
xmllint.c File Reference
#include "libxml.h"
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#include <sys/timeb.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#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>
#include <libxml/xmlerror.h>
#include <libxml/globals.h>
#include <libxml/xmlreader.h>
Include dependency graph for xmllint.c:

Go to the source code of this file.

Macros

#define XML_XML_DEFAULT_CATALOG   "file://" SYSCONFDIR "/xml/catalog"
 
#define MAX_PATHS   64
 
#define PATH_SEPARATOR   ':'
 
#define CLOCKS_PER_SEC   100
 

Enumerations

enum  xmllintReturnCode {
  XMLLINT_RETURN_OK = 0 , XMLLINT_ERR_UNCLASS = 1 , XMLLINT_ERR_DTD = 2 , XMLLINT_ERR_VALID = 3 ,
  XMLLINT_ERR_RDFILE = 4 , XMLLINT_ERR_SCHEMACOMP = 5 , XMLLINT_ERR_OUT = 6 , XMLLINT_ERR_SCHEMAPAT = 7 ,
  XMLLINT_ERR_RDREGIS = 8 , XMLLINT_ERR_MEM = 9 , XMLLINT_ERR_XPATH = 10
}
 

Functions

static void parsePath (const xmlChar *path)
 
static xmlParserInputPtr xmllintExternalEntityLoader (const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
 
static void OOM (void)
 
static void myFreeFunc (void *mem)
 
static voidmyMallocFunc (size_t size)
 
static voidmyReallocFunc (void *mem, size_t size)
 
static charmyStrdupFunc (const char *str)
 
static void startTimer (void)
 
static void XMLCDECL LIBXML_ATTR_FORMAT (1, 2)
 
static void xmlHTMLEncodeSend (void)
 
static void xmlHTMLPrintFileInfo (xmlParserInputPtr input)
 
static void xmlHTMLPrintFileContext (xmlParserInputPtr input)
 
static int myRead (void *f, char *buf, int len)
 
static int myClose (void *context)
 
static int isStandaloneDebug (void *ctx ATTRIBUTE_UNUSED)
 
static int hasInternalSubsetDebug (void *ctx ATTRIBUTE_UNUSED)
 
static int hasExternalSubsetDebug (void *ctx ATTRIBUTE_UNUSED)
 
static void internalSubsetDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
 
static void externalSubsetDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
 
static xmlParserInputPtr resolveEntityDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xmlChar *systemId)
 
: The entity name

getParameterEntityDebug: @ctxt: An XML parser context

Get a parameter entity by name

Returns the xmlParserInputPtr

static xmlEntityPtr getEntityDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
 
static xmlEntityPtr getParameterEntityDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
 
: the attribute name

attributeDeclDebug: @ctxt: An XML parser context

@type: the attribute type

An attribute definition has been parsed

static void attributeDeclDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *elem, const xmlChar *name, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree)
 
: The name of the notation

notationDeclDebug: @ctxt: An XML parser context

@publicId: The public ID of the entity @systemId: The system ID of the entity

What to do when a notation declaration has been parsed.

static void notationDeclDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
 
: The name of the entity

unparsedEntityDeclDebug: @ctxt: An XML parser context

@publicId: The public ID of the entity @systemId: The system ID of the entity @notationName: the name of the notation

What to do when an unparsed entity declaration is parsed

static void unparsedEntityDeclDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)
 
static void setDocumentLocatorDebug (void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED)
 
static void startDocumentDebug (void *ctx ATTRIBUTE_UNUSED)
 
static void endDocumentDebug (void *ctx ATTRIBUTE_UNUSED)
 

Variables

static int debug = 0
 
static int maxmem = 0
 
static int recovery = 0
 
static int noent = 0
 
static int noenc = 0
 
static int noblanks = 0
 
static int noout = 0
 
static int nowrap = 0
 
static int repeat = 0
 
static int insert = 0
 
static int htmlout = 0
 
static int testIO = 0
 
static charencoding = NULL
 
static int dtdattrs = 0
 
static int loaddtd = 0
 
static xmllintReturnCode progresult = XMLLINT_RETURN_OK
 
static int quiet = 0
 
static int timing = 0
 
static int generate = 0
 
static int dropdtd = 0
 
static int chkregister = 0
 
static int nbregister = 0
 
static int options = XML_PARSE_COMPACT | XML_PARSE_BIG_LINES
 
static int sax = 0
 
static int oldxml10 = 0
 
static xmlCharpaths [MAX_PATHS+1]
 
static int nbpaths = 0
 
static int load_trace = 0
 
static xmlExternalEntityLoader defaultEntityLoader = NULL
 
static clock_t begin
 
static clock_t end
 
static char buffer [50000]
 
static xmlSAXHandler emptySAXHandlerStruct
 
static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct
 
static int callbacks
 

: the entity name

referenceDebug: @ctxt: An XML parser context

called when an entity reference is detected.

xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct
 
static xmlSAXHandler debugSAXHandlerStruct
 
static void XMLCDECL LIBXML_ATTR_FORMAT (2, 3)
 
static void entityDeclDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
 
static void referenceDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
 
static void ignorableWhitespaceDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
 
static void processingInstructionDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *target, const xmlChar *data)
 
static void cdataBlockDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *value, int len)
 
static void commentDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *value)
 

: the element name

endElementDebug: @ctxt: An XML parser context

called when the end of an element has been detected.

static xmlSAXHandler debugSAX2HandlerStruct
 
static xmlSAXHandlerPtr debugSAX2Handler = &debugSAX2HandlerStruct
 
static void elementDeclDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, xmlElementContentPtr content ATTRIBUTE_UNUSED)
 
static void startElementDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts)
 
static void endElementDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
 
static void charactersDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len)
 
static void startElementNsDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes)
 
static void endElementNsDebug (void *ctx ATTRIBUTE_UNUSED, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI)
 
static void testSAX (const char *filename)
 
static void parseAndPrintFile (char *filename, xmlParserCtxtPtr rectxt)
 
static void showVersion (const char *name)
 
static void usage (FILE *f, const char *name)
 
static void registerNode (xmlNodePtr node)
 
static void deregisterNode (xmlNodePtr node)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

◆ CLOCKS_PER_SEC

#define CLOCKS_PER_SEC   100

Definition at line 455 of file xmllint.c.

◆ MAX_PATHS

#define MAX_PATHS   64

Definition at line 201 of file xmllint.c.

◆ PATH_SEPARATOR

#define PATH_SEPARATOR   ':'

Definition at line 205 of file xmllint.c.

◆ XML_XML_DEFAULT_CATALOG

#define XML_XML_DEFAULT_CATALOG   "file://" SYSCONFDIR "/xml/catalog"

Definition at line 84 of file xmllint.c.

Enumeration Type Documentation

◆ xmllintReturnCode

Enumerator
XMLLINT_RETURN_OK 
XMLLINT_ERR_UNCLASS 
XMLLINT_ERR_DTD 
XMLLINT_ERR_VALID 
XMLLINT_ERR_RDFILE 
XMLLINT_ERR_SCHEMACOMP 
XMLLINT_ERR_OUT 
XMLLINT_ERR_SCHEMAPAT 
XMLLINT_ERR_RDREGIS 
XMLLINT_ERR_MEM 
XMLLINT_ERR_XPATH 

Definition at line 87 of file xmllint.c.

87 {
88 XMLLINT_RETURN_OK = 0, /* No error */
89 XMLLINT_ERR_UNCLASS = 1, /* Unclassified */
90 XMLLINT_ERR_DTD = 2, /* Error in DTD */
91 XMLLINT_ERR_VALID = 3, /* Validation error */
92 XMLLINT_ERR_RDFILE = 4, /* CtxtReadFile error */
93 XMLLINT_ERR_SCHEMACOMP = 5, /* Schema compilation */
94 XMLLINT_ERR_OUT = 6, /* Error writing output */
95 XMLLINT_ERR_SCHEMAPAT = 7, /* Error in schema pattern */
96 XMLLINT_ERR_RDREGIS = 8, /* Error in Reader registration */
97 XMLLINT_ERR_MEM = 9, /* Out of memory error */
98 XMLLINT_ERR_XPATH = 10 /* XPath evaluation error */
xmllintReturnCode
Definition: xmllint.c:87
@ XMLLINT_ERR_DTD
Definition: xmllint.c:90
@ XMLLINT_ERR_RDFILE
Definition: xmllint.c:92
@ XMLLINT_ERR_MEM
Definition: xmllint.c:97
@ XMLLINT_ERR_VALID
Definition: xmllint.c:91
@ XMLLINT_RETURN_OK
Definition: xmllint.c:88
@ XMLLINT_ERR_XPATH
Definition: xmllint.c:98
@ XMLLINT_ERR_RDREGIS
Definition: xmllint.c:96
@ XMLLINT_ERR_OUT
Definition: xmllint.c:94
@ XMLLINT_ERR_SCHEMACOMP
Definition: xmllint.c:93
@ XMLLINT_ERR_UNCLASS
Definition: xmllint.c:89
@ XMLLINT_ERR_SCHEMAPAT
Definition: xmllint.c:95

Function Documentation

◆ attributeDeclDebug()

static void attributeDeclDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar elem,
const xmlChar name,
int  type,
int  def,
const xmlChar defaultValue,
xmlEnumerationPtr  tree 
)
static

Definition at line 1055 of file xmllint.c.

1058{
1059 callbacks++;
1060 if (noout)
1061 return;
1062 if (defaultValue == NULL)
1063 fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n",
1064 elem, name, type, def);
1065 else
1066 fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
1067 elem, name, type, def, defaultValue);
1069}
#define NULL
Definition: types.h:112
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define stdout
Definition: stdio.h:99
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static size_t elem
Definition: string.c:68
Definition: name.c:39
XMLPUBFUN void XMLCALL xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1817
static int noout
Definition: xmllint.c:113
static int callbacks
Definition: xmllint.c:838

◆ cdataBlockDebug()

static void cdataBlockDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar value,
int  len 
)
static

cdataBlockDebug: @ctx: the user data (XML parser context) @value: The pcdata content @len: the block length

called when a pcdata block has been parsed

Definition at line 1330 of file xmllint.c.

1331{
1332 callbacks++;
1333 if (noout)
1334 return;
1335 fprintf(stdout, "SAX.pcdata(%.20s, %d)\n",
1336 (char *) value, len);
1337}
GLenum GLsizei len
Definition: glext.h:6722
Definition: pdh_main.c:94

◆ charactersDebug()

static void charactersDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar ch,
int  len 
)
static

charactersDebug: @ctxt: An XML parser context @ch: a xmlChar string @len: the number of xmlChar

receiving some chars from the parser. Question: how much at a time ???

Definition at line 1241 of file xmllint.c.

1242{
1243 char out[40];
1244 int i;
1245
1246 callbacks++;
1247 if (noout)
1248 return;
1249 for (i = 0;(i<len) && (i < 30);i++)
1250 out[i] = ch[i];
1251 out[i] = 0;
1252
1253 fprintf(stdout, "SAX.characters(%s, %d)\n", out, len);
1254}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static FILE * out
Definition: regtests2xml.c:44

◆ commentDebug()

static void commentDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar value 
)
static

commentDebug: @ctxt: An XML parser context @value: the comment content

A comment has been parsed.

Definition at line 1347 of file xmllint.c.

1348{
1349 callbacks++;
1350 if (noout)
1351 return;
1352 fprintf(stdout, "SAX.comment(%s)\n", value);
1353}

◆ deregisterNode()

static void deregisterNode ( xmlNodePtr  node)
static

Definition at line 3101 of file xmllint.c.

3102{
3103 assert(node->_private != NULL);
3104 assert(*(long*)node->_private == (long) 0x81726354);
3105 free(node->_private);
3106 nbregister--;
3107}
#define free
Definition: debug_ros.c:5
#define assert(x)
Definition: debug.h:53
Definition: dlist.c:348
static int nbregister
Definition: xmllint.c:185

Referenced by main().

◆ elementDeclDebug()

static void elementDeclDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar name,
int  type,
xmlElementContentPtr content  ATTRIBUTE_UNUSED 
)
static

Definition at line 1081 of file xmllint.c.

1083{
1084 callbacks++;
1085 if (noout)
1086 return;
1087 fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n",
1088 name, type);
1089}

◆ endDocumentDebug()

static void endDocumentDebug ( void *ctx  ATTRIBUTE_UNUSED)
static

endDocumentDebug: @ctxt: An XML parser context

called when the document end has been detected.

Definition at line 1181 of file xmllint.c.

1182{
1183 callbacks++;
1184 if (noout)
1185 return;
1186 fprintf(stdout, "SAX.endDocument()\n");
1187}

◆ endElementDebug()

static void endElementDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar name 
)
static

Definition at line 1223 of file xmllint.c.

1224{
1225 callbacks++;
1226 if (noout)
1227 return;
1228 fprintf(stdout, "SAX.endElement(%s)\n", (char *) name);
1229}

◆ endElementNsDebug()

static void endElementNsDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar localname,
const xmlChar prefix,
const xmlChar URI 
)
static

Definition at line 1529 of file xmllint.c.

1533{
1534 callbacks++;
1535 if (noout)
1536 return;
1537 fprintf(stdout, "SAX.endElementNs(%s", (char *) localname);
1538 if (prefix == NULL)
1539 fprintf(stdout, ", NULL");
1540 else
1541 fprintf(stdout, ", %s", (char *) prefix);
1542 if (URI == NULL)
1543 fprintf(stdout, ", NULL)\n");
1544 else
1545 fprintf(stdout, ", '%s')\n", (char *) URI);
1546}

◆ entityDeclDebug()

static void entityDeclDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar name,
int  type,
const xmlChar publicId,
const xmlChar systemId,
xmlChar content 
)
static

Definition at line 1028 of file xmllint.c.

1030{
1031const xmlChar *nullstr = BAD_CAST "(null)";
1032 /* not all libraries handle printing null pointers nicely */
1033 if (publicId == NULL)
1034 publicId = nullstr;
1035 if (systemId == NULL)
1036 systemId = nullstr;
1037 if (content == NULL)
1038 content = (xmlChar *)nullstr;
1039 callbacks++;
1040 if (noout)
1041 return;
1042 fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
1043 name, type, publicId, systemId, content);
1044}
content
Definition: atl_ax.c:994
#define BAD_CAST
Definition: xmlstring.h:35
unsigned char xmlChar
Definition: xmlstring.h:28

◆ externalSubsetDebug()

static void externalSubsetDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar name,
const xmlChar ExternalID,
const xmlChar SystemID 
)
static

externalSubsetDebug: @ctxt: An XML parser context

Does this document has an external subset

Definition at line 925 of file xmllint.c.

927{
928 callbacks++;
929 if (noout)
930 return;
931 fprintf(stdout, "SAX.externalSubset(%s,", name);
932 if (ExternalID == NULL)
933 fprintf(stdout, " ,");
934 else
935 fprintf(stdout, " %s,", ExternalID);
936 if (SystemID == NULL)
937 fprintf(stdout, " )\n");
938 else
939 fprintf(stdout, " %s)\n", SystemID);
940}

◆ getEntityDebug()

static xmlEntityPtr getEntityDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar name 
)
static

Definition at line 987 of file xmllint.c.

988{
989 callbacks++;
990 if (noout)
991 return(NULL);
992 fprintf(stdout, "SAX.getEntity(%s)\n", name);
993 return(NULL);
994}

◆ getParameterEntityDebug()

static xmlEntityPtr getParameterEntityDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar name 
)
static

Definition at line 1006 of file xmllint.c.

1007{
1008 callbacks++;
1009 if (noout)
1010 return(NULL);
1011 fprintf(stdout, "SAX.getParameterEntity(%s)\n", name);
1012 return(NULL);
1013}

◆ hasExternalSubsetDebug()

static int hasExternalSubsetDebug ( void *ctx  ATTRIBUTE_UNUSED)
static

hasExternalSubsetDebug: @ctxt: An XML parser context

Does this document has an external subset

Returns 1 if true

Definition at line 885 of file xmllint.c.

886{
887 callbacks++;
888 if (noout)
889 return(0);
890 fprintf(stdout, "SAX.hasExternalSubset()\n");
891 return(0);
892}

◆ hasInternalSubsetDebug()

static int hasInternalSubsetDebug ( void *ctx  ATTRIBUTE_UNUSED)
static

hasInternalSubsetDebug: @ctxt: An XML parser context

Does this document has an internal subset

Returns 1 if true

Definition at line 867 of file xmllint.c.

868{
869 callbacks++;
870 if (noout)
871 return(0);
872 fprintf(stdout, "SAX.hasInternalSubset()\n");
873 return(0);
874}

◆ ignorableWhitespaceDebug()

static void ignorableWhitespaceDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar ch,
int  len 
)
static

ignorableWhitespaceDebug: @ctxt: An XML parser context @ch: a xmlChar string @start: the first char in the string @len: the number of xmlChar

receiving some ignorable whitespaces from the parser. Question: how much at a time ???

Definition at line 1283 of file xmllint.c.

1284{
1285 char out[40];
1286 int i;
1287
1288 callbacks++;
1289 if (noout)
1290 return;
1291 for (i = 0;(i<len) && (i < 30);i++)
1292 out[i] = ch[i];
1293 out[i] = 0;
1294 fprintf(stdout, "SAX.ignorableWhitespace(%s, %d)\n", out, len);
1295}

◆ internalSubsetDebug()

static void internalSubsetDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar name,
const xmlChar ExternalID,
const xmlChar SystemID 
)
static

internalSubsetDebug: @ctxt: An XML parser context

Does this document has an internal subset

Definition at line 901 of file xmllint.c.

903{
904 callbacks++;
905 if (noout)
906 return;
907 fprintf(stdout, "SAX.internalSubset(%s,", name);
908 if (ExternalID == NULL)
909 fprintf(stdout, " ,");
910 else
911 fprintf(stdout, " %s,", ExternalID);
912 if (SystemID == NULL)
913 fprintf(stdout, " )\n");
914 else
915 fprintf(stdout, " %s)\n", SystemID);
916}

◆ isStandaloneDebug()

static int isStandaloneDebug ( void *ctx  ATTRIBUTE_UNUSED)
static

isStandaloneDebug: @ctxt: An XML parser context

Is this document tagged standalone ?

Returns 1 if true

Definition at line 849 of file xmllint.c.

850{
851 callbacks++;
852 if (noout)
853 return(0);
854 fprintf(stdout, "SAX.isStandalone()\n");
855 return(0);
856}

◆ LIBXML_ATTR_FORMAT() [1/2]

static void XMLCDECL LIBXML_ATTR_FORMAT ( ,
 
)
static

Definition at line 464 of file xmllint.c.

466{
467 long msec;
468 va_list ap;
469
470 end = clock();
471 msec = ((end - begin) * 1000) / CLOCKS_PER_SEC;
472
473 va_start(ap, fmt);
475 va_end(ap);
476 fprintf(stderr, " took %ld ms\n", msec);
477}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
GLuint GLuint end
Definition: gl.h:1545
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
_Check_return_ _CRTIMP clock_t __cdecl clock(void)
Definition: clock.c:23
Definition: dsound.c:943
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36
#define CLOCKS_PER_SEC
Definition: xmllint.c:455
static clock_t begin
Definition: xmllint.c:458

◆ LIBXML_ATTR_FORMAT() [2/2]

static void XMLCDECL LIBXML_ATTR_FORMAT ( ,
 
)
static

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.

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.

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.

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.

warningDebug: @ctxt: An XML parser context @msg: the message to display/transmit ...: extra parameters for the message display

Display and format a warning messages, gives file, line, position and extra parameters.

errorDebug: @ctxt: An XML parser context @msg: the message to display/transmit ...: extra parameters for the message display

Display and format a error messages, gives file, line, position and extra parameters.

fatalErrorDebug: @ctxt: An XML parser context @msg: the message to display/transmit ...: extra parameters for the message display

Display and format a fatalError messages, gives file, line, position and extra parameters.

Definition at line 586 of file xmllint.c.

588{
592 int len;
593
594 buffer[0] = 0;
595 input = ctxt->input;
596 if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) {
597 input = ctxt->inputTab[ctxt->inputNr - 2];
598 }
599
601
602 xmlGenericError(xmlGenericErrorContext, "<b>error</b>: ");
603 va_start(args, msg);
604 len = strlen(buffer);
605 vsnprintf(&buffer[len], sizeof(buffer) - len, msg, args);
606 va_end(args);
609
612}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define msg(x)
Definition: auth_time.c:54
GLuint buffer
Definition: glext.h:5915
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:353
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:337
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39
#define args
Definition: format.c:66
xmlParserInputPtr * inputTab
Definition: parser.h:202
xmlParserInputPtr input
Definition: parser.h:199
Definition: match.c:390
#define vsnprintf
Definition: tif_win32.c:406
static void xmlHTMLPrintFileContext(xmlParserInputPtr input)
Definition: xmllint.c:536
static void xmlHTMLPrintFileInfo(xmlParserInputPtr input)
Definition: xmllint.c:512
static void xmlHTMLEncodeSend(void)
Definition: xmllint.c:487

◆ main()

int main ( int argc  ,
char **  argv 
)

Definition at line 3110 of file xmllint.c.

3110 {
3111 int i, acount;
3112 int files = 0;
3113 int version = 0;
3114 const char* indent;
3115
3116 if (argc <= 1) {
3117 usage(stderr, argv[0]);
3118 return(XMLLINT_ERR_UNCLASS);
3119 }
3120
3121 /* xmlMemSetup must be called before initializing the parser. */
3122 for (i = 1; i < argc ; i++) {
3123 if (argv[i][0] != '-')
3124 continue;
3125
3126 if ((!strcmp(argv[i], "-maxmem")) ||
3127 (!strcmp(argv[i], "--maxmem"))) {
3128 i++;
3129 if ((i >= argc) || (sscanf(argv[i], "%d", &maxmem) != 1)) {
3130 maxmem = 0;
3131 }
3132 }
3133 }
3134 if (maxmem != 0)
3136
3138
3139 for (i = 1; i < argc ; i++) {
3140 if (argv[i][0] != '-' || argv[i][1] == 0)
3141 continue;
3142
3143 if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
3144 debug++;
3145 else
3146#ifdef LIBXML_DEBUG_ENABLED
3147 if ((!strcmp(argv[i], "-shell")) ||
3148 (!strcmp(argv[i], "--shell"))) {
3149 shell++;
3150 noout = 1;
3151 } else
3152#endif
3153#ifdef LIBXML_TREE_ENABLED
3154 if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy")))
3155 copy++;
3156 else
3157#endif /* LIBXML_TREE_ENABLED */
3158 if ((!strcmp(argv[i], "-recover")) ||
3159 (!strcmp(argv[i], "--recover"))) {
3160 recovery++;
3162 } else if ((!strcmp(argv[i], "-huge")) ||
3163 (!strcmp(argv[i], "--huge"))) {
3165 } else if ((!strcmp(argv[i], "-noent")) ||
3166 (!strcmp(argv[i], "--noent"))) {
3167 noent++;
3169 } else if ((!strcmp(argv[i], "-noenc")) ||
3170 (!strcmp(argv[i], "--noenc"))) {
3171 noenc++;
3173 } else if ((!strcmp(argv[i], "-nsclean")) ||
3174 (!strcmp(argv[i], "--nsclean"))) {
3176 } else if ((!strcmp(argv[i], "-nocdata")) ||
3177 (!strcmp(argv[i], "--nocdata"))) {
3179 } else if ((!strcmp(argv[i], "-nodict")) ||
3180 (!strcmp(argv[i], "--nodict"))) {
3182 } else if ((!strcmp(argv[i], "-version")) ||
3183 (!strcmp(argv[i], "--version"))) {
3184 showVersion(argv[0]);
3185 version = 1;
3186 } else if ((!strcmp(argv[i], "-noout")) ||
3187 (!strcmp(argv[i], "--noout")))
3188 noout++;
3189#ifdef LIBXML_OUTPUT_ENABLED
3190 else if ((!strcmp(argv[i], "-o")) ||
3191 (!strcmp(argv[i], "-output")) ||
3192 (!strcmp(argv[i], "--output"))) {
3193 i++;
3194 output = argv[i];
3195 }
3196#endif /* LIBXML_OUTPUT_ENABLED */
3197 else if ((!strcmp(argv[i], "-htmlout")) ||
3198 (!strcmp(argv[i], "--htmlout")))
3199 htmlout++;
3200 else if ((!strcmp(argv[i], "-nowrap")) ||
3201 (!strcmp(argv[i], "--nowrap")))
3202 nowrap++;
3203#ifdef LIBXML_HTML_ENABLED
3204 else if ((!strcmp(argv[i], "-html")) ||
3205 (!strcmp(argv[i], "--html"))) {
3206 html++;
3207 }
3208 else if ((!strcmp(argv[i], "-xmlout")) ||
3209 (!strcmp(argv[i], "--xmlout"))) {
3210 xmlout++;
3211 } else if ((!strcmp(argv[i], "-nodefdtd")) ||
3212 (!strcmp(argv[i], "--nodefdtd"))) {
3213 nodefdtd++;
3214 options |= HTML_PARSE_NODEFDTD;
3215 }
3216#endif /* LIBXML_HTML_ENABLED */
3217 else if ((!strcmp(argv[i], "-loaddtd")) ||
3218 (!strcmp(argv[i], "--loaddtd"))) {
3219 loaddtd++;
3221 } else if ((!strcmp(argv[i], "-dtdattr")) ||
3222 (!strcmp(argv[i], "--dtdattr"))) {
3223 loaddtd++;
3224 dtdattrs++;
3226 }
3227#ifdef LIBXML_VALID_ENABLED
3228 else if ((!strcmp(argv[i], "-valid")) ||
3229 (!strcmp(argv[i], "--valid"))) {
3230 valid++;
3232 } else if ((!strcmp(argv[i], "-postvalid")) ||
3233 (!strcmp(argv[i], "--postvalid"))) {
3234 postvalid++;
3235 loaddtd++;
3237 } else if ((!strcmp(argv[i], "-dtdvalid")) ||
3238 (!strcmp(argv[i], "--dtdvalid"))) {
3239 i++;
3240 dtdvalid = argv[i];
3241 loaddtd++;
3243 } else if ((!strcmp(argv[i], "-dtdvalidfpi")) ||
3244 (!strcmp(argv[i], "--dtdvalidfpi"))) {
3245 i++;
3246 dtdvalidfpi = argv[i];
3247 loaddtd++;
3249 }
3250#endif /* LIBXML_VALID_ENABLED */
3251 else if ((!strcmp(argv[i], "-dropdtd")) ||
3252 (!strcmp(argv[i], "--dropdtd")))
3253 dropdtd++;
3254 else if ((!strcmp(argv[i], "-insert")) ||
3255 (!strcmp(argv[i], "--insert")))
3256 insert++;
3257 else if ((!strcmp(argv[i], "-quiet")) ||
3258 (!strcmp(argv[i], "--quiet")))
3259 quiet++;
3260 else if ((!strcmp(argv[i], "-timing")) ||
3261 (!strcmp(argv[i], "--timing")))
3262 timing++;
3263 else if ((!strcmp(argv[i], "-auto")) ||
3264 (!strcmp(argv[i], "--auto")))
3265 generate++;
3266 else if ((!strcmp(argv[i], "-repeat")) ||
3267 (!strcmp(argv[i], "--repeat"))) {
3268 if (repeat)
3269 repeat *= 10;
3270 else
3271 repeat = 100;
3272 }
3273#ifdef LIBXML_PUSH_ENABLED
3274 else if ((!strcmp(argv[i], "-push")) ||
3275 (!strcmp(argv[i], "--push")))
3276 push++;
3277 else if ((!strcmp(argv[i], "-pushsmall")) ||
3278 (!strcmp(argv[i], "--pushsmall"))) {
3279 push++;
3280 pushsize = 10;
3281 }
3282#endif /* LIBXML_PUSH_ENABLED */
3283#ifdef HAVE_MMAP
3284 else if ((!strcmp(argv[i], "-memory")) ||
3285 (!strcmp(argv[i], "--memory")))
3286 memory++;
3287#endif
3288 else if ((!strcmp(argv[i], "-testIO")) ||
3289 (!strcmp(argv[i], "--testIO")))
3290 testIO++;
3291#ifdef LIBXML_XINCLUDE_ENABLED
3292 else if ((!strcmp(argv[i], "-xinclude")) ||
3293 (!strcmp(argv[i], "--xinclude"))) {
3294 xinclude++;
3296 }
3297 else if ((!strcmp(argv[i], "-noxincludenode")) ||
3298 (!strcmp(argv[i], "--noxincludenode"))) {
3299 xinclude++;
3302 }
3303 else if ((!strcmp(argv[i], "-nofixup-base-uris")) ||
3304 (!strcmp(argv[i], "--nofixup-base-uris"))) {
3305 xinclude++;
3308 }
3309#endif
3310#ifdef LIBXML_OUTPUT_ENABLED
3311#ifdef LIBXML_ZLIB_ENABLED
3312 else if ((!strcmp(argv[i], "-compress")) ||
3313 (!strcmp(argv[i], "--compress"))) {
3314 compress++;
3316 }
3317#endif
3318#endif /* LIBXML_OUTPUT_ENABLED */
3319 else if ((!strcmp(argv[i], "-nowarning")) ||
3320 (!strcmp(argv[i], "--nowarning"))) {
3324 }
3325 else if ((!strcmp(argv[i], "-pedantic")) ||
3326 (!strcmp(argv[i], "--pedantic"))) {
3330 }
3331#ifdef LIBXML_DEBUG_ENABLED
3332 else if ((!strcmp(argv[i], "-debugent")) ||
3333 (!strcmp(argv[i], "--debugent"))) {
3334 debugent++;
3336 }
3337#endif
3338#ifdef LIBXML_C14N_ENABLED
3339 else if ((!strcmp(argv[i], "-c14n")) ||
3340 (!strcmp(argv[i], "--c14n"))) {
3341 canonical++;
3343 }
3344 else if ((!strcmp(argv[i], "-c14n11")) ||
3345 (!strcmp(argv[i], "--c14n11"))) {
3346 canonical_11++;
3348 }
3349 else if ((!strcmp(argv[i], "-exc-c14n")) ||
3350 (!strcmp(argv[i], "--exc-c14n"))) {
3351 exc_canonical++;
3353 }
3354#endif
3355#ifdef LIBXML_CATALOG_ENABLED
3356 else if ((!strcmp(argv[i], "-catalogs")) ||
3357 (!strcmp(argv[i], "--catalogs"))) {
3358 catalogs++;
3359 } else if ((!strcmp(argv[i], "-nocatalogs")) ||
3360 (!strcmp(argv[i], "--nocatalogs"))) {
3361 nocatalogs++;
3362 }
3363#endif
3364 else if ((!strcmp(argv[i], "-encode")) ||
3365 (!strcmp(argv[i], "--encode"))) {
3366 i++;
3367 encoding = argv[i];
3368 /*
3369 * OK it's for testing purposes
3370 */
3371 xmlAddEncodingAlias("UTF-8", "DVEnc");
3372 }
3373 else if ((!strcmp(argv[i], "-noblanks")) ||
3374 (!strcmp(argv[i], "--noblanks"))) {
3375 noblanks++;
3378 }
3379 else if ((!strcmp(argv[i], "-maxmem")) ||
3380 (!strcmp(argv[i], "--maxmem"))) {
3381 i++;
3382 }
3383 else if ((!strcmp(argv[i], "-format")) ||
3384 (!strcmp(argv[i], "--format"))) {
3385 noblanks++;
3386#ifdef LIBXML_OUTPUT_ENABLED
3387 format = 1;
3388#endif /* LIBXML_OUTPUT_ENABLED */
3390 }
3391 else if ((!strcmp(argv[i], "-pretty")) ||
3392 (!strcmp(argv[i], "--pretty"))) {
3393 i++;
3394#ifdef LIBXML_OUTPUT_ENABLED
3395 if (argv[i] != NULL) {
3396 format = atoi(argv[i]);
3397 if (format == 1) {
3398 noblanks++;
3400 }
3401 }
3402#endif /* LIBXML_OUTPUT_ENABLED */
3403 }
3404#ifdef LIBXML_READER_ENABLED
3405 else if ((!strcmp(argv[i], "-stream")) ||
3406 (!strcmp(argv[i], "--stream"))) {
3407 stream++;
3408 }
3409 else if ((!strcmp(argv[i], "-walker")) ||
3410 (!strcmp(argv[i], "--walker"))) {
3411 walker++;
3412 noout++;
3413#ifdef LIBXML_PATTERN_ENABLED
3414 } else if ((!strcmp(argv[i], "-pattern")) ||
3415 (!strcmp(argv[i], "--pattern"))) {
3416 i++;
3417 pattern = argv[i];
3418#endif
3419 }
3420#endif /* LIBXML_READER_ENABLED */
3421#ifdef LIBXML_SAX1_ENABLED
3422 else if ((!strcmp(argv[i], "-sax1")) ||
3423 (!strcmp(argv[i], "--sax1"))) {
3424 sax1++;
3426 }
3427#endif /* LIBXML_SAX1_ENABLED */
3428 else if ((!strcmp(argv[i], "-sax")) ||
3429 (!strcmp(argv[i], "--sax"))) {
3430 sax++;
3431 }
3432 else if ((!strcmp(argv[i], "-chkregister")) ||
3433 (!strcmp(argv[i], "--chkregister"))) {
3434 chkregister++;
3435#ifdef LIBXML_SCHEMAS_ENABLED
3436 } else if ((!strcmp(argv[i], "-relaxng")) ||
3437 (!strcmp(argv[i], "--relaxng"))) {
3438 i++;
3439 relaxng = argv[i];
3440 noent++;
3442 } else if ((!strcmp(argv[i], "-schema")) ||
3443 (!strcmp(argv[i], "--schema"))) {
3444 i++;
3445 schema = argv[i];
3446 noent++;
3447#endif
3448#ifdef LIBXML_SCHEMATRON_ENABLED
3449 } else if ((!strcmp(argv[i], "-schematron")) ||
3450 (!strcmp(argv[i], "--schematron"))) {
3451 i++;
3452 schematron = argv[i];
3453 noent++;
3454#endif
3455 } else if ((!strcmp(argv[i], "-nonet")) ||
3456 (!strcmp(argv[i], "--nonet"))) {
3459 } else if ((!strcmp(argv[i], "-nocompact")) ||
3460 (!strcmp(argv[i], "--nocompact"))) {
3461 options &= ~XML_PARSE_COMPACT;
3462 } else if ((!strcmp(argv[i], "-load-trace")) ||
3463 (!strcmp(argv[i], "--load-trace"))) {
3464 load_trace++;
3465 } else if ((!strcmp(argv[i], "-path")) ||
3466 (!strcmp(argv[i], "--path"))) {
3467 i++;
3469#ifdef LIBXML_XPATH_ENABLED
3470 } else if ((!strcmp(argv[i], "-xpath")) ||
3471 (!strcmp(argv[i], "--xpath"))) {
3472 i++;
3473 noout++;
3474 xpathquery = argv[i];
3475#endif
3476 } else if ((!strcmp(argv[i], "-oldxml10")) ||
3477 (!strcmp(argv[i], "--oldxml10"))) {
3478 oldxml10++;
3480 } else {
3481 fprintf(stderr, "Unknown option %s\n", argv[i]);
3482 usage(stderr, argv[0]);
3483 return(XMLLINT_ERR_UNCLASS);
3484 }
3485 }
3486
3487#ifdef LIBXML_CATALOG_ENABLED
3488 if (nocatalogs == 0) {
3489 if (catalogs) {
3490 const char *catal;
3491
3492 catal = getenv("SGML_CATALOG_FILES");
3493 if (catal != NULL) {
3494 xmlLoadCatalogs(catal);
3495 } else {
3496 fprintf(stderr, "Variable $SGML_CATALOG_FILES not set\n");
3497 }
3498 }
3499 }
3500#endif
3501
3502#ifdef LIBXML_SAX1_ENABLED
3503 if (sax1)
3504 xmlSAXDefaultVersion(1);
3505 else
3506 xmlSAXDefaultVersion(2);
3507#endif /* LIBXML_SAX1_ENABLED */
3508
3509 if (chkregister) {
3512 }
3513
3514 indent = getenv("XMLLINT_INDENT");
3515 if(indent != NULL) {
3517 }
3518
3519
3522
3524 if (loaddtd != 0)
3526 if (dtdattrs)
3529#ifdef LIBXML_VALID_ENABLED
3531#endif /* LIBXML_VALID_ENABLED */
3532 if ((htmlout) && (!nowrap)) {
3534 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n");
3536 "\t\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n");
3538 "<html><head><title>%s output</title></head>\n",
3539 argv[0]);
3541 "<body bgcolor=\"#ffffff\"><h1 align=\"center\">%s output</h1>\n",
3542 argv[0]);
3543 }
3544
3545#ifdef LIBXML_SCHEMATRON_ENABLED
3546 if ((schematron != NULL) && (sax == 0)
3548 && (stream == 0)
3549#endif /* LIBXML_READER_ENABLED */
3550 ) {
3551 xmlSchematronParserCtxtPtr ctxt;
3552
3553 /* forces loading the DTDs */
3556 if (timing) {
3557 startTimer();
3558 }
3559 ctxt = xmlSchematronNewParserCtxt(schematron);
3560 if (ctxt == NULL) {
3562 goto error;
3563 }
3564#if 0
3565 xmlSchematronSetParserErrors(ctxt, xmlGenericError, xmlGenericError,
3566 NULL);
3567#endif
3568 wxschematron = xmlSchematronParse(ctxt);
3569 if (wxschematron == NULL) {
3571 "Schematron schema %s failed to compile\n", schematron);
3573 schematron = NULL;
3574 }
3575 xmlSchematronFreeParserCtxt(ctxt);
3576 if (timing) {
3577 endTimer("Compiling the schemas");
3578 }
3579 }
3580#endif
3581#ifdef LIBXML_SCHEMAS_ENABLED
3582 if ((relaxng != NULL) && (sax == 0)
3584 && (stream == 0)
3585#endif /* LIBXML_READER_ENABLED */
3586 ) {
3587 xmlRelaxNGParserCtxtPtr ctxt;
3588
3589 /* forces loading the DTDs */
3592 if (timing) {
3593 startTimer();
3594 }
3595 ctxt = xmlRelaxNGNewParserCtxt(relaxng);
3596 if (ctxt == NULL) {
3598 goto error;
3599 }
3600 xmlRelaxNGSetParserErrors(ctxt, xmlGenericError, xmlGenericError,
3601 NULL);
3602 relaxngschemas = xmlRelaxNGParse(ctxt);
3603 if (relaxngschemas == NULL) {
3605 "Relax-NG schema %s failed to compile\n", relaxng);
3607 relaxng = NULL;
3608 }
3609 xmlRelaxNGFreeParserCtxt(ctxt);
3610 if (timing) {
3611 endTimer("Compiling the schemas");
3612 }
3613 } else if ((schema != NULL)
3615 && (stream == 0)
3616#endif
3617 ) {
3618 xmlSchemaParserCtxtPtr ctxt;
3619
3620 if (timing) {
3621 startTimer();
3622 }
3623 ctxt = xmlSchemaNewParserCtxt(schema);
3624 if (ctxt == NULL) {
3626 goto error;
3627 }
3628 xmlSchemaSetParserErrors(ctxt, xmlGenericError, xmlGenericError, NULL);
3629 wxschemas = xmlSchemaParse(ctxt);
3630 if (wxschemas == NULL) {
3632 "WXS schema %s failed to compile\n", schema);
3634 schema = NULL;
3635 }
3636 xmlSchemaFreeParserCtxt(ctxt);
3637 if (timing) {
3638 endTimer("Compiling the schemas");
3639 }
3640 }
3641#endif /* LIBXML_SCHEMAS_ENABLED */
3642#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED)
3643 if ((pattern != NULL) && (walker == 0)) {
3644 patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0, NULL);
3645 if (patternc == NULL) {
3647 "Pattern %s failed to compile\n", pattern);
3649 pattern = NULL;
3650 }
3651 }
3652#endif /* LIBXML_READER_ENABLED && LIBXML_PATTERN_ENABLED */
3653 for (i = 1; i < argc ; i++) {
3654 if ((!strcmp(argv[i], "-encode")) ||
3655 (!strcmp(argv[i], "--encode"))) {
3656 i++;
3657 continue;
3658 } else if ((!strcmp(argv[i], "-o")) ||
3659 (!strcmp(argv[i], "-output")) ||
3660 (!strcmp(argv[i], "--output"))) {
3661 i++;
3662 continue;
3663 }
3664#ifdef LIBXML_VALID_ENABLED
3665 if ((!strcmp(argv[i], "-dtdvalid")) ||
3666 (!strcmp(argv[i], "--dtdvalid"))) {
3667 i++;
3668 continue;
3669 }
3670 if ((!strcmp(argv[i], "-path")) ||
3671 (!strcmp(argv[i], "--path"))) {
3672 i++;
3673 continue;
3674 }
3675 if ((!strcmp(argv[i], "-dtdvalidfpi")) ||
3676 (!strcmp(argv[i], "--dtdvalidfpi"))) {
3677 i++;
3678 continue;
3679 }
3680#endif /* LIBXML_VALID_ENABLED */
3681 if ((!strcmp(argv[i], "-relaxng")) ||
3682 (!strcmp(argv[i], "--relaxng"))) {
3683 i++;
3684 continue;
3685 }
3686 if ((!strcmp(argv[i], "-maxmem")) ||
3687 (!strcmp(argv[i], "--maxmem"))) {
3688 i++;
3689 continue;
3690 }
3691 if ((!strcmp(argv[i], "-pretty")) ||
3692 (!strcmp(argv[i], "--pretty"))) {
3693 i++;
3694 continue;
3695 }
3696 if ((!strcmp(argv[i], "-schema")) ||
3697 (!strcmp(argv[i], "--schema"))) {
3698 i++;
3699 continue;
3700 }
3701 if ((!strcmp(argv[i], "-schematron")) ||
3702 (!strcmp(argv[i], "--schematron"))) {
3703 i++;
3704 continue;
3705 }
3706#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED)
3707 if ((!strcmp(argv[i], "-pattern")) ||
3708 (!strcmp(argv[i], "--pattern"))) {
3709 i++;
3710 continue;
3711 }
3712#endif
3713#ifdef LIBXML_XPATH_ENABLED
3714 if ((!strcmp(argv[i], "-xpath")) ||
3715 (!strcmp(argv[i], "--xpath"))) {
3716 i++;
3717 continue;
3718 }
3719#endif
3720 if ((timing) && (repeat))
3721 startTimer();
3722 /* Remember file names. "-" means stdin. <sven@zen.org> */
3723 if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) {
3724 if (repeat) {
3725 xmlParserCtxtPtr ctxt = NULL;
3726
3727 for (acount = 0;acount < repeat;acount++) {
3728#ifdef LIBXML_READER_ENABLED
3729 if (stream != 0) {
3730 streamFile(argv[i]);
3731 } else {
3732#endif /* LIBXML_READER_ENABLED */
3733 if (sax) {
3734 testSAX(argv[i]);
3735 } else {
3736 if (ctxt == NULL)
3737 ctxt = xmlNewParserCtxt();
3738 parseAndPrintFile(argv[i], ctxt);
3739 }
3740#ifdef LIBXML_READER_ENABLED
3741 }
3742#endif /* LIBXML_READER_ENABLED */
3743 }
3744 if (ctxt != NULL)
3745 xmlFreeParserCtxt(ctxt);
3746 } else {
3747 nbregister = 0;
3748
3749#ifdef LIBXML_READER_ENABLED
3750 if (stream != 0)
3751 streamFile(argv[i]);
3752 else
3753#endif /* LIBXML_READER_ENABLED */
3754 if (sax) {
3755 testSAX(argv[i]);
3756 } else {
3758 }
3759
3760 if ((chkregister) && (nbregister != 0)) {
3761 fprintf(stderr, "Registration count off: %d\n", nbregister);
3763 }
3764 }
3765 files ++;
3766 if ((timing) && (repeat)) {
3767 endTimer("%d iterations", repeat);
3768 }
3769 }
3770 }
3771 if (generate)
3773 if ((htmlout) && (!nowrap)) {
3774 xmlGenericError(xmlGenericErrorContext, "</body></html>\n");
3775 }
3776 if ((files == 0) && (!generate) && (version == 0)) {
3777 usage(stderr, argv[0]);
3779 }
3780#ifdef LIBXML_SCHEMATRON_ENABLED
3781 if (wxschematron != NULL)
3782 xmlSchematronFree(wxschematron);
3783#endif
3784#ifdef LIBXML_SCHEMAS_ENABLED
3785 if (relaxngschemas != NULL)
3786 xmlRelaxNGFree(relaxngschemas);
3787 if (wxschemas != NULL)
3788 xmlSchemaFree(wxschemas);
3789#endif
3790#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED)
3791 if (patternc != NULL)
3792 xmlFreePattern(patternc);
3793#endif
3794
3795 /* Avoid unused label warning if features are disabled. */
3796 goto error;
3797
3798error:
3800 xmlMemoryDump();
3801
3802 return(progresult);
3803}
static int argc
Definition: ServiceArgs.c:12
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
static const WCHAR indent[]
Definition: object.c:1156
static const WCHAR version[]
Definition: asmname.c:66
XMLPUBFUN int XMLCALL xmlAddEncodingAlias(const char *name, const char *alias)
Definition: encoding.c:1077
BOOLEAN valid
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLubyte * pattern
Definition: glext.h:7787
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
const WCHAR * schema
#define error(str)
Definition: mkdosfs.c:1605
static char memory[1024 *256]
Definition: process.c:116
#define argv
Definition: mplay32.c:18
static void push(calc_node_t *op)
Definition: rpn_ieee.c:113
XMLPUBVAR int xmlParserDebugEntities
Definition: globals.h:423
XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
Definition: globals.c:578
XMLPUBVAR int xmlGetWarningsDefaultValue
Definition: globals.h:369
XMLPUBVAR int xmlLoadExtDtdDefaultValue
Definition: globals.h:414
XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
Definition: globals.c:611
XMLPUBVAR int xmlDoValidityCheckingDefaultValue
Definition: globals.h:328
XMLPUBVAR const char * xmlTreeIndentString
Definition: globals.h:387
XMLPUBFUN int XMLCALL xmlKeepBlanksDefault(int val)
XMLPUBFUN void XMLCALL xmlCleanupParser(void)
Definition: parser.c:14739
#define XML_DETECT_IDS
Definition: parser.h:137
#define XML_COMPLETE_ATTRS
Definition: parser.h:146
@ XML_PARSE_SAX1
Definition: parser.h:1102
@ XML_PARSE_DTDVALID
Definition: parser.h:1097
@ XML_PARSE_NOWARNING
Definition: parser.h:1099
@ XML_PARSE_NOCDATA
Definition: parser.h:1107
@ XML_PARSE_NONET
Definition: parser.h:1104
@ XML_PARSE_NOBLANKS
Definition: parser.h:1101
@ XML_PARSE_IGNORE_ENC
Definition: parser.h:1116
@ XML_PARSE_NOBASEFIX
Definition: parser.h:1113
@ XML_PARSE_DTDLOAD
Definition: parser.h:1095
@ XML_PARSE_XINCLUDE
Definition: parser.h:1103
@ XML_PARSE_RECOVER
Definition: parser.h:1093
@ XML_PARSE_HUGE
Definition: parser.h:1114
@ XML_PARSE_NODICT
Definition: parser.h:1105
@ XML_PARSE_DTDATTR
Definition: parser.h:1096
@ XML_PARSE_OLD10
Definition: parser.h:1112
@ XML_PARSE_NOXINCNODE
Definition: parser.h:1108
@ XML_PARSE_NOENT
Definition: parser.h:1094
@ XML_PARSE_PEDANTIC
Definition: parser.h:1100
@ XML_PARSE_NSCLEAN
Definition: parser.h:1106
XMLPUBFUN xmlExternalEntityLoader XMLCALL xmlGetExternalEntityLoader(void)
XMLPUBFUN int XMLCALL xmlPedanticParserDefault(int val)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
XMLPUBFUN int XMLCALL xmlLineNumbersDefault(int val)
XMLPUBFUN void XMLCALL xmlSetExternalEntityLoader(xmlExternalEntityLoader f)
XMLPUBFUN int XMLCALL xmlSubstituteEntitiesDefault(int val)
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)
XMLPUBFUN void XMLCALL xmlSetCompressMode(int mode)
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
Definition: compress.c:68
Definition: parse.h:23
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNoNetExternalEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
static char * myStrdupFunc(const char *str)
Definition: xmllint.c:368
static int noenc
Definition: xmllint.c:111
static void startTimer(void)
Definition: xmllint.c:460
static int noent
Definition: xmllint.c:110
static void deregisterNode(xmlNodePtr node)
Definition: xmllint.c:3101
static void registerNode(xmlNodePtr node)
Definition: xmllint.c:3090
static int load_trace
Definition: xmllint.c:209
static int loaddtd
Definition: xmllint.c:160
static int timing
Definition: xmllint.c:163
static xmlParserInputPtr xmllintExternalEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
Definition: xmllint.c:240
static void parsePath(const xmlChar *path)
Definition: xmllint.c:212
static int generate
Definition: xmllint.c:164
static int nowrap
Definition: xmllint.c:114
static xmlExternalEntityLoader defaultEntityLoader
Definition: xmllint.c:237
static xmllintReturnCode progresult
Definition: xmllint.c:161
static int dtdattrs
Definition: xmllint.c:159
static int quiet
Definition: xmllint.c:162
static int maxmem
Definition: xmllint.c:105
static int noblanks
Definition: xmllint.c:112
static int recovery
Definition: xmllint.c:109
static int sax
Definition: xmllint.c:193
static int htmlout
Definition: xmllint.c:143
static void testSAX(const char *filename)
Definition: xmllint.c:1586
static void * myReallocFunc(void *mem, size_t size)
Definition: xmllint.c:353
static int chkregister
Definition: xmllint.c:184
static int dropdtd
Definition: xmllint.c:165
static int repeat
Definition: xmllint.c:137
static void * myMallocFunc(size_t size)
Definition: xmllint.c:338
static int oldxml10
Definition: xmllint.c:194
static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt)
Definition: xmllint.c:2133
static char * encoding
Definition: xmllint.c:155
static int debug
Definition: xmllint.c:104
static int insert
Definition: xmllint.c:138
static void myFreeFunc(void *mem)
Definition: xmllint.c:333
static void showVersion(const char *name)
Definition: xmllint.c:2931
static int testIO
Definition: xmllint.c:154
XMLPUBFUN void XMLCALL xmlMemoryDump(void)
Definition: xmlmemory.c:910
XMLPUBFUN int XMLCALL xmlMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc, xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc)
Definition: xmlmemory.c:1022
#define LIBXML_TEST_VERSION
Definition: xmlversion.h:61
#define LIBXML_READER_ENABLED
Definition: xmlversion.h:139

◆ myClose()

static int myClose ( void context)
static

Definition at line 785 of file xmllint.c.

785 {
786 FILE *f = (FILE *) context;
787 if (f == stdin)
788 return(0);
789 return(fclose(f));
790}
GLfloat f
Definition: glext.h:7540
#define stdin
Definition: stdio.h:98
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
Definition: http.c:7252

Referenced by parseAndPrintFile().

◆ myFreeFunc()

static void myFreeFunc ( void mem)
static

Definition at line 333 of file xmllint.c.

334{
336}
Definition: mem.c:156
XMLPUBFUN void XMLCALL xmlMemFree(void *ptr)
Definition: xmlmemory.c:414

Referenced by main().

◆ myMallocFunc()

static void * myMallocFunc ( size_t  size)
static

Definition at line 338 of file xmllint.c.

339{
340 void *ret;
341
343 if (ret != NULL) {
344 if (xmlMemUsed() > maxmem) {
345 OOM();
347 return (NULL);
348 }
349 }
350 return (ret);
351}
GLsizeiptr size
Definition: glext.h:5919
int ret
static void OOM(void)
Definition: xmllint.c:326
XMLPUBFUN int XMLCALL xmlMemUsed(void)
Definition: xmlmemory.c:568
XMLPUBFUN void *XMLCALL xmlMemMalloc(size_t size) LIBXML_ATTR_ALLOC_SIZE(1)
Definition: xmlmemory.c:294

Referenced by main().

◆ myRead()

static int myRead ( void f,
char buf,
int  len 
)
static

Definition at line 782 of file xmllint.c.

782 {
783 return(fread(buf, 1, len, (FILE *) f));
784}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)

Referenced by parseAndPrintFile().

◆ myReallocFunc()

static void * myReallocFunc ( void mem,
size_t  size 
)
static

Definition at line 353 of file xmllint.c.

354{
355 void *ret;
356
358 if (ret != NULL) {
359 if (xmlMemUsed() > maxmem) {
360 OOM();
362 return (NULL);
363 }
364 }
365 return (ret);
366}
XMLPUBFUN void *XMLCALL xmlMemRealloc(void *ptr, size_t size)
Definition: xmlmemory.c:403

Referenced by main().

◆ myStrdupFunc()

static char * myStrdupFunc ( const char str)
static

Definition at line 368 of file xmllint.c.

369{
370 char *ret;
371
373 if (ret != NULL) {
374 if (xmlMemUsed() > maxmem) {
375 OOM();
376 xmlFree(ret);
377 return (NULL);
378 }
379 }
380 return (ret);
381}
const WCHAR * str
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
XMLPUBFUN char *XMLCALL xmlMemoryStrdup(const char *str)
Definition: xmlmemory.c:555

Referenced by main().

◆ notationDeclDebug()

static void notationDeclDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar name,
const xmlChar publicId,
const xmlChar systemId 
)
static

Definition at line 1101 of file xmllint.c.

1103{
1104 callbacks++;
1105 if (noout)
1106 return;
1107 fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n",
1108 (char *) name, (char *) publicId, (char *) systemId);
1109}

◆ OOM()

static void OOM ( void  )
static

Definition at line 326 of file xmllint.c.

327{
328 fprintf(stderr, "Ran out of memory needs > %d bytes\n", maxmem);
330}

Referenced by myMallocFunc(), myReallocFunc(), and myStrdupFunc().

◆ parseAndPrintFile()

static void parseAndPrintFile ( char filename,
xmlParserCtxtPtr  rectxt 
)
static

Definition at line 2133 of file xmllint.c.

2133 {
2134 xmlDocPtr doc = NULL;
2135#ifdef LIBXML_TREE_ENABLED
2136 xmlDocPtr tmp;
2137#endif /* LIBXML_TREE_ENABLED */
2138
2139 if ((timing) && (!repeat))
2140 startTimer();
2141
2142
2143#ifdef LIBXML_TREE_ENABLED
2144 if (filename == NULL) {
2145 if (generate) {
2146 xmlNodePtr n;
2147
2148 doc = xmlNewDoc(BAD_CAST "1.0");
2149 n = xmlNewDocNode(doc, NULL, BAD_CAST "info", NULL);
2151 xmlDocSetRootElement(doc, n);
2152 }
2153 }
2154#endif /* LIBXML_TREE_ENABLED */
2155#ifdef LIBXML_HTML_ENABLED
2156#ifdef LIBXML_PUSH_ENABLED
2157 else if ((html) && (push)) {
2158 FILE *f;
2159
2160 if ((filename[0] == '-') && (filename[1] == 0)) {
2161 f = stdin;
2162 } else {
2163 f = fopen(filename, "rb");
2164 }
2165 if (f != NULL) {
2166 int res;
2167 char chars[4096];
2168 htmlParserCtxtPtr ctxt;
2169
2170 res = fread(chars, 1, 4, f);
2171 if (res > 0) {
2172 ctxt = htmlCreatePushParserCtxt(NULL, NULL,
2174 if (ctxt == NULL) {
2176 if (f != stdin)
2177 fclose(f);
2178 return;
2179 }
2180 htmlCtxtUseOptions(ctxt, options);
2181 while ((res = fread(chars, 1, pushsize, f)) > 0) {
2182 htmlParseChunk(ctxt, chars, res, 0);
2183 }
2184 htmlParseChunk(ctxt, chars, 0, 1);
2185 doc = ctxt->myDoc;
2186 htmlFreeParserCtxt(ctxt);
2187 }
2188 if (f != stdin)
2189 fclose(f);
2190 }
2191 }
2192#endif /* LIBXML_PUSH_ENABLED */
2193#ifdef HAVE_MMAP
2194 else if ((html) && (memory)) {
2195 int fd;
2196 struct stat info;
2197 const char *base;
2198 if (stat(filename, &info) < 0)
2199 return;
2200 if ((fd = open(filename, O_RDONLY)) < 0)
2201 return;
2202 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ;
2203 if (base == (void *) MAP_FAILED) {
2204 close(fd);
2205 fprintf(stderr, "mmap failure for file %s\n", filename);
2207 return;
2208 }
2209
2210 doc = htmlReadMemory((char *) base, info.st_size, filename,
2211 NULL, options);
2212
2213 munmap((char *) base, info.st_size);
2214 close(fd);
2215 }
2216#endif
2217 else if (html) {
2218 doc = htmlReadFile(filename, NULL, options);
2219 }
2220#endif /* LIBXML_HTML_ENABLED */
2221 else {
2222#ifdef LIBXML_PUSH_ENABLED
2223 /*
2224 * build an XML tree from a string;
2225 */
2226 if (push) {
2227 FILE *f;
2228
2229 /* '-' Usually means stdin -<sven@zen.org> */
2230 if ((filename[0] == '-') && (filename[1] == 0)) {
2231 f = stdin;
2232 } else {
2233 f = fopen(filename, "rb");
2234 }
2235 if (f != NULL) {
2236 int ret;
2237 int res, size = 1024;
2238 char chars[1024];
2239 xmlParserCtxtPtr ctxt;
2240
2241 /* if (repeat) size = 1024; */
2242 res = fread(chars, 1, 4, f);
2243 if (res > 0) {
2244 ctxt = xmlCreatePushParserCtxt(NULL, NULL,
2245 chars, res, filename);
2246 if (ctxt == NULL) {
2248 if (f != stdin)
2249 fclose(f);
2250 return;
2251 }
2253 while ((res = fread(chars, 1, size, f)) > 0) {
2254 xmlParseChunk(ctxt, chars, res, 0);
2255 }
2256 xmlParseChunk(ctxt, chars, 0, 1);
2257 doc = ctxt->myDoc;
2258 ret = ctxt->wellFormed;
2259 xmlFreeParserCtxt(ctxt);
2260 if ((!ret) && (!recovery)) {
2261 xmlFreeDoc(doc);
2262 doc = NULL;
2263 }
2264 }
2265 if (f != stdin)
2266 fclose(f);
2267 }
2268 } else
2269#endif /* LIBXML_PUSH_ENABLED */
2270 if (testIO) {
2271 if ((filename[0] == '-') && (filename[1] == 0)) {
2272 doc = xmlReadFd(0, NULL, NULL, options);
2273 } else {
2274 FILE *f;
2275
2276 f = fopen(filename, "rb");
2277 if (f != NULL) {
2278 if (rectxt == NULL)
2280 options);
2281 else
2282 doc = xmlCtxtReadIO(rectxt, myRead, myClose, f,
2284 } else
2285 doc = NULL;
2286 }
2287 } else if (htmlout) {
2288 xmlParserCtxtPtr ctxt;
2289
2290 if (rectxt == NULL) {
2291 ctxt = xmlNewParserCtxt();
2292 if (ctxt == NULL) {
2294 return;
2295 }
2296 } else {
2297 ctxt = rectxt;
2298 }
2299
2300 ctxt->sax->error = xmlHTMLError;
2301 ctxt->sax->warning = xmlHTMLWarning;
2302 ctxt->vctxt.error = xmlHTMLValidityError;
2303 ctxt->vctxt.warning = xmlHTMLValidityWarning;
2304
2305 doc = xmlCtxtReadFile(ctxt, filename, NULL, options);
2306
2307 if (rectxt == NULL)
2308 xmlFreeParserCtxt(ctxt);
2309#ifdef HAVE_MMAP
2310 } else if (memory) {
2311 int fd;
2312 struct stat info;
2313 const char *base;
2314 if (stat(filename, &info) < 0)
2315 return;
2316 if ((fd = open(filename, O_RDONLY)) < 0)
2317 return;
2318 base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ;
2319 if (base == (void *) MAP_FAILED) {
2320 close(fd);
2321 fprintf(stderr, "mmap failure for file %s\n", filename);
2323 return;
2324 }
2325
2326 if (rectxt == NULL)
2327 doc = xmlReadMemory((char *) base, info.st_size,
2329 else
2330 doc = xmlCtxtReadMemory(rectxt, (char *) base, info.st_size,
2332
2333 munmap((char *) base, info.st_size);
2334 close(fd);
2335#endif
2336#ifdef LIBXML_VALID_ENABLED
2337 } else if (valid) {
2338 xmlParserCtxtPtr ctxt = NULL;
2339
2340 if (rectxt == NULL) {
2341 ctxt = xmlNewParserCtxt();
2342 if (ctxt == NULL) {
2344 return;
2345 }
2346 } else {
2347 ctxt = rectxt;
2348 }
2349
2350 doc = xmlCtxtReadFile(ctxt, filename, NULL, options);
2351
2352 if (ctxt->valid == 0)
2354 if (rectxt == NULL)
2355 xmlFreeParserCtxt(ctxt);
2356#endif /* LIBXML_VALID_ENABLED */
2357 } else {
2358 if (rectxt != NULL)
2359 doc = xmlCtxtReadFile(rectxt, filename, NULL, options);
2360 else {
2361#ifdef LIBXML_SAX1_ENABLED
2362 if (sax1)
2363 doc = xmlParseFile(filename);
2364 else
2365#endif /* LIBXML_SAX1_ENABLED */
2367 }
2368 }
2369 }
2370
2371 /*
2372 * If we don't have a document we might as well give up. Do we
2373 * want an error message here? <sven@zen.org> */
2374 if (doc == NULL) {
2376 return;
2377 }
2378
2379 if ((timing) && (!repeat)) {
2380 endTimer("Parsing");
2381 }
2382
2383 /*
2384 * Remove DOCTYPE nodes
2385 */
2386 if (dropdtd) {
2387 xmlDtdPtr dtd;
2388
2389 dtd = xmlGetIntSubset(doc);
2390 if (dtd != NULL) {
2392 doc->intSubset = NULL;
2393 xmlFreeDtd(dtd);
2394 }
2395 }
2396
2397#ifdef LIBXML_XINCLUDE_ENABLED
2398 if (xinclude) {
2399 if ((timing) && (!repeat)) {
2400 startTimer();
2401 }
2402 if (xmlXIncludeProcessFlags(doc, options) < 0)
2404 if ((timing) && (!repeat)) {
2405 endTimer("Xinclude processing");
2406 }
2407 }
2408#endif
2409
2410#ifdef LIBXML_XPATH_ENABLED
2411 if (xpathquery != NULL) {
2412 doXPathQuery(doc, xpathquery);
2413 }
2414#endif
2415
2416#ifdef LIBXML_DEBUG_ENABLED
2417#ifdef LIBXML_XPATH_ENABLED
2418 /*
2419 * shell interaction
2420 */
2421 if (shell) {
2422 xmlXPathOrderDocElems(doc);
2423 xmlShell(doc, filename, xmlShellReadline, stdout);
2424 }
2425#endif
2426#endif
2427
2428#ifdef LIBXML_TREE_ENABLED
2429 /*
2430 * test intermediate copy if needed.
2431 */
2432 if (copy) {
2433 tmp = doc;
2434 if (timing) {
2435 startTimer();
2436 }
2437 doc = xmlCopyDoc(doc, 1);
2438 if (timing) {
2439 endTimer("Copying");
2440 }
2441 if (timing) {
2442 startTimer();
2443 }
2444 xmlFreeDoc(tmp);
2445 if (timing) {
2446 endTimer("Freeing original");
2447 }
2448 }
2449#endif /* LIBXML_TREE_ENABLED */
2450
2451#ifdef LIBXML_VALID_ENABLED
2452 if ((insert) && (!html)) {
2453 const xmlChar* list[256];
2454 int nb, i;
2456
2457 if (doc->children != NULL) {
2458 node = doc->children;
2459 while ((node != NULL) && (node->last == NULL)) node = node->next;
2460 if (node != NULL) {
2461 nb = xmlValidGetValidElements(node->last, NULL, list, 256);
2462 if (nb < 0) {
2463 fprintf(stderr, "could not get valid list of elements\n");
2464 } else if (nb == 0) {
2465 fprintf(stderr, "No element can be inserted under root\n");
2466 } else {
2467 fprintf(stderr, "%d element types can be inserted under root:\n",
2468 nb);
2469 for (i = 0;i < nb;i++) {
2470 fprintf(stderr, "%s\n", (char *) list[i]);
2471 }
2472 }
2473 }
2474 }
2475 }else
2476#endif /* LIBXML_VALID_ENABLED */
2477#ifdef LIBXML_READER_ENABLED
2478 if (walker) {
2479 walkDoc(doc);
2480 }
2481#endif /* LIBXML_READER_ENABLED */
2482#ifdef LIBXML_OUTPUT_ENABLED
2483 if (noout == 0) {
2484 int ret;
2485
2486 /*
2487 * print it.
2488 */
2489#ifdef LIBXML_DEBUG_ENABLED
2490 if (!debug) {
2491#endif
2492 if ((timing) && (!repeat)) {
2493 startTimer();
2494 }
2495#ifdef LIBXML_HTML_ENABLED
2496 if ((html) && (!xmlout)) {
2497 if (compress) {
2498 htmlSaveFile(output ? output : "-", doc);
2499 }
2500 else if (encoding != NULL) {
2501 if (format == 1) {
2502 htmlSaveFileFormat(output ? output : "-", doc, encoding, 1);
2503 }
2504 else {
2505 htmlSaveFileFormat(output ? output : "-", doc, encoding, 0);
2506 }
2507 }
2508 else if (format == 1) {
2509 htmlSaveFileFormat(output ? output : "-", doc, NULL, 1);
2510 }
2511 else {
2512 FILE *out;
2513 if (output == NULL)
2514 out = stdout;
2515 else {
2516 out = fopen(output,"wb");
2517 }
2518 if (out != NULL) {
2519 if (htmlDocDump(out, doc) < 0)
2521
2522 if (output != NULL)
2523 fclose(out);
2524 } else {
2525 fprintf(stderr, "failed to open %s\n", output);
2527 }
2528 }
2529 if ((timing) && (!repeat)) {
2530 endTimer("Saving");
2531 }
2532 } else
2533#endif
2534#ifdef LIBXML_C14N_ENABLED
2535 if (canonical) {
2536 xmlChar *result = NULL;
2537 int size;
2538
2539 size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_0, NULL, 1, &result);
2540 if (size >= 0) {
2541 if (write(1, result, size) == -1) {
2542 fprintf(stderr, "Can't write data\n");
2543 }
2544 xmlFree(result);
2545 } else {
2546 fprintf(stderr, "Failed to canonicalize\n");
2548 }
2549 } else if (canonical_11) {
2550 xmlChar *result = NULL;
2551 int size;
2552
2553 size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_1, NULL, 1, &result);
2554 if (size >= 0) {
2555 if (write(1, result, size) == -1) {
2556 fprintf(stderr, "Can't write data\n");
2557 }
2558 xmlFree(result);
2559 } else {
2560 fprintf(stderr, "Failed to canonicalize\n");
2562 }
2563 } else
2564 if (exc_canonical) {
2565 xmlChar *result = NULL;
2566 int size;
2567
2568 size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_EXCLUSIVE_1_0, NULL, 1, &result);
2569 if (size >= 0) {
2570 if (write(1, result, size) == -1) {
2571 fprintf(stderr, "Can't write data\n");
2572 }
2573 xmlFree(result);
2574 } else {
2575 fprintf(stderr, "Failed to canonicalize\n");
2577 }
2578 } else
2579#endif
2580#ifdef HAVE_MMAP
2581 if (memory) {
2582 xmlChar *result;
2583 int len;
2584
2585 if (encoding != NULL) {
2586 if (format == 1) {
2587 xmlDocDumpFormatMemoryEnc(doc, &result, &len, encoding, 1);
2588 } else {
2589 xmlDocDumpMemoryEnc(doc, &result, &len, encoding);
2590 }
2591 } else {
2592 if (format == 1)
2593 xmlDocDumpFormatMemory(doc, &result, &len, 1);
2594 else
2595 xmlDocDumpMemory(doc, &result, &len);
2596 }
2597 if (result == NULL) {
2598 fprintf(stderr, "Failed to save\n");
2600 } else {
2601 if (write(1, result, len) == -1) {
2602 fprintf(stderr, "Can't write data\n");
2603 }
2604 xmlFree(result);
2605 }
2606
2607 } else
2608#endif /* HAVE_MMAP */
2609 if (compress) {
2610 xmlSaveFile(output ? output : "-", doc);
2611 } else if (oldout) {
2612 if (encoding != NULL) {
2613 if (format == 1) {
2614 ret = xmlSaveFormatFileEnc(output ? output : "-", doc,
2615 encoding, 1);
2616 }
2617 else {
2618 ret = xmlSaveFileEnc(output ? output : "-", doc,
2619 encoding);
2620 }
2621 if (ret < 0) {
2622 fprintf(stderr, "failed save to %s\n",
2623 output ? output : "-");
2625 }
2626 } else if (format == 1) {
2627 ret = xmlSaveFormatFile(output ? output : "-", doc, 1);
2628 if (ret < 0) {
2629 fprintf(stderr, "failed save to %s\n",
2630 output ? output : "-");
2632 }
2633 } else {
2634 FILE *out;
2635 if (output == NULL)
2636 out = stdout;
2637 else {
2638 out = fopen(output,"wb");
2639 }
2640 if (out != NULL) {
2641 if (xmlDocDump(out, doc) < 0)
2643
2644 if (output != NULL)
2645 fclose(out);
2646 } else {
2647 fprintf(stderr, "failed to open %s\n", output);
2649 }
2650 }
2651 } else {
2652 xmlSaveCtxtPtr ctxt;
2653 int saveOpts = 0;
2654
2655 if (format == 1)
2656 saveOpts |= XML_SAVE_FORMAT;
2657 else if (format == 2)
2658 saveOpts |= XML_SAVE_WSNONSIG;
2659
2660#if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED)
2661 if (xmlout)
2662 saveOpts |= XML_SAVE_AS_XML;
2663#endif
2664
2665 if (output == NULL)
2666 ctxt = xmlSaveToFd(1, encoding, saveOpts);
2667 else
2668 ctxt = xmlSaveToFilename(output, encoding, saveOpts);
2669
2670 if (ctxt != NULL) {
2671 if (xmlSaveDoc(ctxt, doc) < 0) {
2672 fprintf(stderr, "failed save to %s\n",
2673 output ? output : "-");
2675 }
2676 xmlSaveClose(ctxt);
2677 } else {
2679 }
2680 }
2681 if ((timing) && (!repeat)) {
2682 endTimer("Saving");
2683 }
2684#ifdef LIBXML_DEBUG_ENABLED
2685 } else {
2686 FILE *out;
2687 if (output == NULL)
2688 out = stdout;
2689 else {
2690 out = fopen(output,"wb");
2691 }
2692 if (out != NULL) {
2693 xmlDebugDumpDocument(out, doc);
2694
2695 if (output != NULL)
2696 fclose(out);
2697 } else {
2698 fprintf(stderr, "failed to open %s\n", output);
2700 }
2701 }
2702#endif
2703 }
2704#endif /* LIBXML_OUTPUT_ENABLED */
2705
2706#ifdef LIBXML_VALID_ENABLED
2707 /*
2708 * A posteriori validation test
2709 */
2710 if ((dtdvalid != NULL) || (dtdvalidfpi != NULL)) {
2711 xmlDtdPtr dtd;
2712
2713 if ((timing) && (!repeat)) {
2714 startTimer();
2715 }
2716 if (dtdvalid != NULL)
2717 dtd = xmlParseDTD(NULL, (const xmlChar *)dtdvalid);
2718 else
2719 dtd = xmlParseDTD((const xmlChar *)dtdvalidfpi, NULL);
2720 if ((timing) && (!repeat)) {
2721 endTimer("Parsing DTD");
2722 }
2723 if (dtd == NULL) {
2724 if (dtdvalid != NULL)
2726 "Could not parse DTD %s\n", dtdvalid);
2727 else
2729 "Could not parse DTD %s\n", dtdvalidfpi);
2731 } else {
2732 xmlValidCtxtPtr cvp;
2733
2734 if ((cvp = xmlNewValidCtxt()) == NULL) {
2736 "Couldn't allocate validation context\n");
2738 xmlFreeDtd(dtd);
2739 return;
2740 }
2741 cvp->userData = NULL;
2742 cvp->error = xmlGenericError;
2743 cvp->warning = xmlGenericError;
2744
2745 if ((timing) && (!repeat)) {
2746 startTimer();
2747 }
2748 if (!xmlValidateDtd(cvp, doc, dtd)) {
2749 if (dtdvalid != NULL)
2751 "Document %s does not validate against %s\n",
2752 filename, dtdvalid);
2753 else
2755 "Document %s does not validate against %s\n",
2756 filename, dtdvalidfpi);
2758 }
2759 if ((timing) && (!repeat)) {
2760 endTimer("Validating against DTD");
2761 }
2762 xmlFreeValidCtxt(cvp);
2763 xmlFreeDtd(dtd);
2764 }
2765 } else if (postvalid) {
2766 xmlValidCtxtPtr cvp;
2767
2768 if ((cvp = xmlNewValidCtxt()) == NULL) {
2770 "Couldn't allocate validation context\n");
2772 xmlFreeDoc(doc);
2773 return;
2774 }
2775
2776 if ((timing) && (!repeat)) {
2777 startTimer();
2778 }
2779 cvp->userData = NULL;
2780 cvp->error = xmlGenericError;
2781 cvp->warning = xmlGenericError;
2782 if (!xmlValidateDocument(cvp, doc)) {
2784 "Document %s does not validate\n", filename);
2786 }
2787 if ((timing) && (!repeat)) {
2788 endTimer("Validating");
2789 }
2790 xmlFreeValidCtxt(cvp);
2791 }
2792#endif /* LIBXML_VALID_ENABLED */
2793#ifdef LIBXML_SCHEMATRON_ENABLED
2794 if (wxschematron != NULL) {
2795 xmlSchematronValidCtxtPtr ctxt;
2796 int ret;
2797 int flag;
2798
2799 if ((timing) && (!repeat)) {
2800 startTimer();
2801 }
2802
2803 if (debug)
2804 flag = XML_SCHEMATRON_OUT_XML;
2805 else
2806 flag = XML_SCHEMATRON_OUT_TEXT;
2807 if (noout)
2808 flag |= XML_SCHEMATRON_OUT_QUIET;
2809 ctxt = xmlSchematronNewValidCtxt(wxschematron, flag);
2810 if (ctxt == NULL) {
2812 xmlFreeDoc(doc);
2813 return;
2814 }
2815#if 0
2816 xmlSchematronSetValidErrors(ctxt, xmlGenericError, xmlGenericError,
2817 NULL);
2818#endif
2819 ret = xmlSchematronValidateDoc(ctxt, doc);
2820 if (ret == 0) {
2821 if (!quiet) {
2822 fprintf(stderr, "%s validates\n", filename);
2823 }
2824 } else if (ret > 0) {
2825 fprintf(stderr, "%s fails to validate\n", filename);
2827 } else {
2828 fprintf(stderr, "%s validation generated an internal error\n",
2829 filename);
2831 }
2832 xmlSchematronFreeValidCtxt(ctxt);
2833 if ((timing) && (!repeat)) {
2834 endTimer("Validating");
2835 }
2836 }
2837#endif
2838#ifdef LIBXML_SCHEMAS_ENABLED
2839 if (relaxngschemas != NULL) {
2840 xmlRelaxNGValidCtxtPtr ctxt;
2841 int ret;
2842
2843 if ((timing) && (!repeat)) {
2844 startTimer();
2845 }
2846
2847 ctxt = xmlRelaxNGNewValidCtxt(relaxngschemas);
2848 if (ctxt == NULL) {
2850 xmlFreeDoc(doc);
2851 return;
2852 }
2853 xmlRelaxNGSetValidErrors(ctxt, xmlGenericError, xmlGenericError, NULL);
2854 ret = xmlRelaxNGValidateDoc(ctxt, doc);
2855 if (ret == 0) {
2856 if (!quiet) {
2857 fprintf(stderr, "%s validates\n", filename);
2858 }
2859 } else if (ret > 0) {
2860 fprintf(stderr, "%s fails to validate\n", filename);
2862 } else {
2863 fprintf(stderr, "%s validation generated an internal error\n",
2864 filename);
2866 }
2867 xmlRelaxNGFreeValidCtxt(ctxt);
2868 if ((timing) && (!repeat)) {
2869 endTimer("Validating");
2870 }
2871 } else if (wxschemas != NULL) {
2872 xmlSchemaValidCtxtPtr ctxt;
2873 int ret;
2874
2875 if ((timing) && (!repeat)) {
2876 startTimer();
2877 }
2878
2879 ctxt = xmlSchemaNewValidCtxt(wxschemas);
2880 if (ctxt == NULL) {
2882 xmlFreeDoc(doc);
2883 return;
2884 }
2885 xmlSchemaSetValidErrors(ctxt, xmlGenericError, xmlGenericError, NULL);
2886 ret = xmlSchemaValidateDoc(ctxt, doc);
2887 if (ret == 0) {
2888 if (!quiet) {
2889 fprintf(stderr, "%s validates\n", filename);
2890 }
2891 } else if (ret > 0) {
2892 fprintf(stderr, "%s fails to validate\n", filename);
2894 } else {
2895 fprintf(stderr, "%s validation generated an internal error\n",
2896 filename);
2898 }
2899 xmlSchemaFreeValidCtxt(ctxt);
2900 if ((timing) && (!repeat)) {
2901 endTimer("Validating");
2902 }
2903 }
2904#endif
2905
2906#ifdef LIBXML_DEBUG_ENABLED
2907#if defined(LIBXML_HTML_ENABLED) || defined(LIBXML_VALID_ENABLED)
2908 if ((debugent) && (!html))
2909 xmlDebugDumpEntities(stderr, doc);
2910#endif
2911#endif
2912
2913 /*
2914 * free it.
2915 */
2916 if ((timing) && (!repeat)) {
2917 startTimer();
2918 }
2919 xmlFreeDoc(doc);
2920 if ((timing) && (!repeat)) {
2921 endTimer("Freeing");
2922 }
2923}
#define stat
Definition: acwin.h:99
#define O_RDONLY
Definition: acwin.h:108
#define open
Definition: acwin.h:95
#define close
Definition: acwin.h:98
#define write
Definition: acwin.h:97
Definition: list.h:37
@ XML_CHAR_ENCODING_NONE
Definition: encoding.h:58
#define MAP_FAILED
GLdouble n
Definition: glext.h:7729
GLuint res
Definition: glext.h:9613
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
Definition: glfuncs.h:52
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
const char * filename
Definition: ioapi.h:137
#define f
Definition: ke_i.h:83
XMLPUBFUN xmlDocPtr XMLCALL xmlReadMemory(const char *buffer, int size, const char *URL, const char *encoding, int options)
Definition: parser.c:15253
XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options)
Definition: parser.c:15515
XMLPUBFUN xmlDocPtr XMLCALL xmlReadFile(const char *URL, const char *encoding, int options)
Definition: parser.c:15229
XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size, const char *URL, const char *encoding, int options)
Definition: parser.c:15426
XMLPUBFUN xmlDocPtr XMLCALL xmlReadFd(int fd, const char *URL, const char *encoding, int options)
Definition: parser.c:15278
XMLPUBFUN int XMLCALL xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
Definition: parser.c:15141
XMLPUBFUN xmlDocPtr XMLCALL xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options)
Definition: parser.c:15321
XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadFile(xmlParserCtxtPtr ctxt, const char *filename, const char *encoding, int options)
Definition: parser.c:15390
XMLPUBFUN void XMLCALL xmlFreeDtd(xmlDtdPtr cur)
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content)
XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc(const xmlChar *version)
XMLPUBFUN xmlDtdPtr XMLCALL xmlGetIntSubset(const xmlDoc *doc)
XMLPUBFUN void XMLCALL xmlUnlinkNode(xmlNodePtr cur)
XMLPUBFUN void XMLCALL xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content)
static int fd
Definition: io.c:51
Definition: tree.h:551
struct _xmlDtd * intSubset
Definition: tree.h:570
struct _xmlNode * children
Definition: tree.h:555
Definition: tree.h:406
Definition: tree.h:489
xmlValidCtxt vctxt
Definition: parser.h:221
int wellFormed
Definition: parser.h:188
struct _xmlSAXHandler * sax
Definition: parser.h:185
xmlDocPtr myDoc
Definition: parser.h:187
Definition: stat.h:55
void * next
Definition: dlist.c:360
xmlValidCtxt * xmlValidCtxtPtr
Definition: valid.h:81
static int myClose(void *context)
Definition: xmllint.c:785
static int myRead(void *f, char *buf, int len)
Definition: xmllint.c:782

Referenced by main().

◆ parsePath()

static void parsePath ( const xmlChar path)
static

Definition at line 212 of file xmllint.c.

212 {
213 const xmlChar *cur;
214
215 if (path == NULL)
216 return;
217 while (*path != 0) {
218 if (nbpaths >= MAX_PATHS) {
219 fprintf(stderr, "MAX_PATHS reached: too many paths\n");
220 return;
221 }
222 cur = path;
223 while ((*cur == ' ') || (*cur == PATH_SEPARATOR))
224 cur++;
225 path = cur;
226 while ((*cur != 0) && (*cur != ' ') && (*cur != PATH_SEPARATOR))
227 cur++;
228 if (cur != path) {
230 if (paths[nbpaths] != NULL)
231 nbpaths++;
232 path = cur;
233 }
234 }
235}
FxCollectionEntry * cur
GLsizei const GLuint * paths
Definition: glext.h:11717
#define PATH_SEPARATOR
Definition: xmllint.c:205
#define MAX_PATHS
Definition: xmllint.c:201
static int nbpaths
Definition: xmllint.c:208
XMLPUBFUN xmlChar *XMLCALL xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:42

Referenced by main().

◆ processingInstructionDebug()

static void processingInstructionDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar target,
const xmlChar data 
)
static

processingInstructionDebug: @ctxt: An XML parser context @target: the target name @data: the PI data's @len: the number of xmlChar

A processing instruction has been parsed.

Definition at line 1307 of file xmllint.c.

1309{
1310 callbacks++;
1311 if (noout)
1312 return;
1313 if (data != NULL)
1314 fprintf(stdout, "SAX.processingInstruction(%s, %s)\n",
1315 (char *) target, (char *) data);
1316 else
1317 fprintf(stdout, "SAX.processingInstruction(%s, NULL)\n",
1318 (char *) target);
1319}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum target
Definition: glext.h:7315

◆ referenceDebug()

static void referenceDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar name 
)
static

Definition at line 1264 of file xmllint.c.

1265{
1266 callbacks++;
1267 if (noout)
1268 return;
1269 fprintf(stdout, "SAX.reference(%s)\n", name);
1270}

◆ registerNode()

static void registerNode ( xmlNodePtr  node)
static

Definition at line 3090 of file xmllint.c.

3091{
3092 node->_private = malloc(sizeof(long));
3093 if (node->_private == NULL) {
3094 fprintf(stderr, "Out of memory in xmllint:registerNode()\n");
3096 }
3097 *(long*)node->_private = (long) 0x81726354;
3098 nbregister++;
3099}
#define malloc
Definition: debug_ros.c:4
#define exit(n)
Definition: config.h:202

Referenced by main().

◆ resolveEntityDebug()

static xmlParserInputPtr resolveEntityDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar publicId,
const xmlChar systemId 
)
static

resolveEntityDebug: @ctxt: An XML parser context @publicId: The public ID of the entity @systemId: The system ID of the entity

Special entity resolver, better left to the parser, it has more context than the application layer. The default behaviour is to NOT resolve the entities, in that case the ENTITY_REF nodes are built in the structure (and the parameter values).

Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.

Definition at line 957 of file xmllint.c.

958{
959 callbacks++;
960 if (noout)
961 return(NULL);
962 /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
963
964
965 fprintf(stdout, "SAX.resolveEntity(");
966 if (publicId != NULL)
967 fprintf(stdout, "%s", (char *)publicId);
968 else
969 fprintf(stdout, " ");
970 if (systemId != NULL)
971 fprintf(stdout, ", %s)\n", (char *)systemId);
972 else
973 fprintf(stdout, ", )\n");
974 return(NULL);
975}

◆ setDocumentLocatorDebug()

static void setDocumentLocatorDebug ( void *ctx  ATTRIBUTE_UNUSED,
xmlSAXLocatorPtr loc  ATTRIBUTE_UNUSED 
)
static

setDocumentLocatorDebug: @ctxt: An XML parser context @loc: A SAX Locator

Receive the document locator at startup, actually xmlDefaultSAXLocator Everything is available on the context, so this is useless in our case.

Definition at line 1151 of file xmllint.c.

1152{
1153 callbacks++;
1154 if (noout)
1155 return;
1156 fprintf(stdout, "SAX.setDocumentLocator()\n");
1157}

◆ showVersion()

static void showVersion ( const char name)
static

Definition at line 2931 of file xmllint.c.

2931 {
2932 fprintf(stderr, "%s: using libxml version %s\n", name, xmlParserVersion);
2933 fprintf(stderr, " compiled with: ");
2934 if (xmlHasFeature(XML_WITH_THREAD)) fprintf(stderr, "Threads ");
2935 if (xmlHasFeature(XML_WITH_TREE)) fprintf(stderr, "Tree ");
2936 if (xmlHasFeature(XML_WITH_OUTPUT)) fprintf(stderr, "Output ");
2937 if (xmlHasFeature(XML_WITH_PUSH)) fprintf(stderr, "Push ");
2938 if (xmlHasFeature(XML_WITH_READER)) fprintf(stderr, "Reader ");
2939 if (xmlHasFeature(XML_WITH_PATTERN)) fprintf(stderr, "Patterns ");
2940 if (xmlHasFeature(XML_WITH_WRITER)) fprintf(stderr, "Writer ");
2941 if (xmlHasFeature(XML_WITH_SAX1)) fprintf(stderr, "SAXv1 ");
2943 if (xmlHasFeature(XML_WITH_HTTP)) fprintf(stderr, "HTTP ");
2944 if (xmlHasFeature(XML_WITH_VALID)) fprintf(stderr, "DTDValid ");
2945 if (xmlHasFeature(XML_WITH_HTML)) fprintf(stderr, "HTML ");
2946 if (xmlHasFeature(XML_WITH_LEGACY)) fprintf(stderr, "Legacy ");
2947 if (xmlHasFeature(XML_WITH_C14N)) fprintf(stderr, "C14N ");
2948 if (xmlHasFeature(XML_WITH_CATALOG)) fprintf(stderr, "Catalog ");
2949 if (xmlHasFeature(XML_WITH_XPATH)) fprintf(stderr, "XPath ");
2950 if (xmlHasFeature(XML_WITH_XPTR)) fprintf(stderr, "XPointer ");
2951 if (xmlHasFeature(XML_WITH_XINCLUDE)) fprintf(stderr, "XInclude ");
2952 if (xmlHasFeature(XML_WITH_ICONV)) fprintf(stderr, "Iconv ");
2954 if (xmlHasFeature(XML_WITH_ISO8859X)) fprintf(stderr, "ISO8859X ");
2955 if (xmlHasFeature(XML_WITH_UNICODE)) fprintf(stderr, "Unicode ");
2956 if (xmlHasFeature(XML_WITH_REGEXP)) fprintf(stderr, "Regexps ");
2957 if (xmlHasFeature(XML_WITH_AUTOMATA)) fprintf(stderr, "Automata ");
2958 if (xmlHasFeature(XML_WITH_EXPR)) fprintf(stderr, "Expr ");
2959 if (xmlHasFeature(XML_WITH_SCHEMAS)) fprintf(stderr, "Schemas ");
2960 if (xmlHasFeature(XML_WITH_SCHEMATRON)) fprintf(stderr, "Schematron ");
2961 if (xmlHasFeature(XML_WITH_MODULES)) fprintf(stderr, "Modules ");
2962 if (xmlHasFeature(XML_WITH_DEBUG)) fprintf(stderr, "Debug ");
2963 if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug ");
2964 if (xmlHasFeature(XML_WITH_DEBUG_RUN)) fprintf(stderr, "RunDebug ");
2965 if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib ");
2966 if (xmlHasFeature(XML_WITH_LZMA)) fprintf(stderr, "Lzma ");
2967 fprintf(stderr, "\n");
2968}
XMLPUBVAR const char * xmlParserVersion
Definition: globals.h:432
XMLPUBFUN int XMLCALL xmlHasFeature(xmlFeature feature)
Definition: parser.c:874
@ XML_WITH_DEBUG
Definition: parser.h:1229
@ XML_WITH_LEGACY
Definition: parser.h:1214
@ XML_WITH_CATALOG
Definition: parser.h:1216
@ XML_WITH_XPATH
Definition: parser.h:1217
@ XML_WITH_TREE
Definition: parser.h:1203
@ XML_WITH_DEBUG_MEM
Definition: parser.h:1230
@ XML_WITH_DEBUG_RUN
Definition: parser.h:1231
@ XML_WITH_XPTR
Definition: parser.h:1218
@ XML_WITH_OUTPUT
Definition: parser.h:1204
@ XML_WITH_EXPR
Definition: parser.h:1225
@ XML_WITH_VALID
Definition: parser.h:1212
@ XML_WITH_THREAD
Definition: parser.h:1202
@ XML_WITH_SCHEMAS
Definition: parser.h:1226
@ XML_WITH_C14N
Definition: parser.h:1215
@ XML_WITH_MODULES
Definition: parser.h:1228
@ XML_WITH_UNICODE
Definition: parser.h:1222
@ XML_WITH_REGEXP
Definition: parser.h:1223
@ XML_WITH_HTML
Definition: parser.h:1213
@ XML_WITH_LZMA
Definition: parser.h:1234
@ XML_WITH_AUTOMATA
Definition: parser.h:1224
@ XML_WITH_ISO8859X
Definition: parser.h:1221
@ XML_WITH_PUSH
Definition: parser.h:1205
@ XML_WITH_ICONV
Definition: parser.h:1220
@ XML_WITH_ZLIB
Definition: parser.h:1232
@ XML_WITH_SAX1
Definition: parser.h:1209
@ XML_WITH_PATTERN
Definition: parser.h:1207
@ XML_WITH_WRITER
Definition: parser.h:1208
@ XML_WITH_FTP
Definition: parser.h:1210
@ XML_WITH_HTTP
Definition: parser.h:1211
@ XML_WITH_READER
Definition: parser.h:1206
@ XML_WITH_XINCLUDE
Definition: parser.h:1219
@ XML_WITH_SCHEMATRON
Definition: parser.h:1227
@ XML_WITH_ICU
Definition: parser.h:1233

Referenced by main().

◆ startDocumentDebug()

static void startDocumentDebug ( void *ctx  ATTRIBUTE_UNUSED)
static

startDocumentDebug: @ctxt: An XML parser context

called when the document start being processed.

Definition at line 1166 of file xmllint.c.

1167{
1168 callbacks++;
1169 if (noout)
1170 return;
1171 fprintf(stdout, "SAX.startDocument()\n");
1172}

◆ startElementDebug()

static void startElementDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar name,
const xmlChar **  atts 
)
static

Definition at line 1197 of file xmllint.c.

1198{
1199 int i;
1200
1201 callbacks++;
1202 if (noout)
1203 return;
1204 fprintf(stdout, "SAX.startElement(%s", (char *) name);
1205 if (atts != NULL) {
1206 for (i = 0;(atts[i] != NULL);i++) {
1207 fprintf(stdout, ", %s='", atts[i++]);
1208 if (atts[i] != NULL)
1209 fprintf(stdout, "%s'", atts[i]);
1210 }
1211 }
1212 fprintf(stdout, ")\n");
1213}
_In_ uint16_t _Out_ ULONG * atts
Definition: btrfs_drv.h:1107

◆ startElementNsDebug()

static void startElementNsDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar localname,
const xmlChar prefix,
const xmlChar URI,
int  nb_namespaces,
const xmlChar **  namespaces,
int  nb_attributes,
int  nb_defaulted,
const xmlChar **  attributes 
)
static

Definition at line 1472 of file xmllint.c.

1481{
1482 int i;
1483
1484 callbacks++;
1485 if (noout)
1486 return;
1487 fprintf(stdout, "SAX.startElementNs(%s", (char *) localname);
1488 if (prefix == NULL)
1489 fprintf(stdout, ", NULL");
1490 else
1491 fprintf(stdout, ", %s", (char *) prefix);
1492 if (URI == NULL)
1493 fprintf(stdout, ", NULL");
1494 else
1495 fprintf(stdout, ", '%s'", (char *) URI);
1496 fprintf(stdout, ", %d", nb_namespaces);
1497
1498 if (namespaces != NULL) {
1499 for (i = 0;i < nb_namespaces * 2;i++) {
1500 fprintf(stdout, ", xmlns");
1501 if (namespaces[i] != NULL)
1502 fprintf(stdout, ":%s", namespaces[i]);
1503 i++;
1504 fprintf(stdout, "='%s'", namespaces[i]);
1505 }
1506 }
1507 fprintf(stdout, ", %d, %d", nb_attributes, nb_defaulted);
1508 if (attributes != NULL) {
1509 for (i = 0;i < nb_attributes * 5;i += 5) {
1510 if (attributes[i + 1] != NULL)
1511 fprintf(stdout, ", %s:%s='", attributes[i + 1], attributes[i]);
1512 else
1513 fprintf(stdout, ", %s='", attributes[i]);
1514 fprintf(stdout, "%.4s...', %d", attributes[i + 3],
1515 (int)(attributes[i + 4] - attributes[i + 3]));
1516 }
1517 }
1518 fprintf(stdout, ")\n");
1519}

◆ startTimer()

static void startTimer ( void  )
static

◆ testSAX()

static void testSAX ( const char filename)
static

Definition at line 1586 of file xmllint.c.

1586 {
1588 const char *user_data = "user_data"; /* mostly for debugging */
1590 xmlParserInputPtr inputStream;
1591 xmlParserCtxtPtr ctxt = NULL;
1592 xmlSAXHandlerPtr old_sax = NULL;
1593
1594 callbacks = 0;
1595
1596 if (noout) {
1598#ifdef LIBXML_SAX1_ENABLED
1599 } else if (sax1) {
1601#endif
1602 } else {
1604 }
1605
1606 /*
1607 * it's not the simplest code but the most generic in term of I/O
1608 */
1610 if (buf == NULL) {
1611 goto error;
1612 }
1613
1614#ifdef LIBXML_SCHEMAS_ENABLED
1615 if (wxschemas != NULL) {
1616 int ret;
1617 xmlSchemaValidCtxtPtr vctxt;
1618
1619 vctxt = xmlSchemaNewValidCtxt(wxschemas);
1620 if (vctxt == NULL) {
1623 goto error;
1624 }
1625 xmlSchemaSetValidErrors(vctxt, xmlGenericError, xmlGenericError, NULL);
1626 xmlSchemaValidateSetFilename(vctxt, filename);
1627
1628 ret = xmlSchemaValidateStream(vctxt, buf, 0, handler,
1629 (void *)user_data);
1630 if (repeat == 0) {
1631 if (ret == 0) {
1632 if (!quiet) {
1633 fprintf(stderr, "%s validates\n", filename);
1634 }
1635 } else if (ret > 0) {
1636 fprintf(stderr, "%s fails to validate\n", filename);
1638 } else {
1639 fprintf(stderr, "%s validation generated an internal error\n",
1640 filename);
1642 }
1643 }
1644 xmlSchemaFreeValidCtxt(vctxt);
1645 } else
1646#endif
1647 {
1648 /*
1649 * Create the parser context amd hook the input
1650 */
1651 ctxt = xmlNewParserCtxt();
1652 if (ctxt == NULL) {
1655 goto error;
1656 }
1657 old_sax = ctxt->sax;
1658 ctxt->sax = handler;
1659 ctxt->userData = (void *) user_data;
1660 inputStream = xmlNewIOInputStream(ctxt, buf, XML_CHAR_ENCODING_NONE);
1661 if (inputStream == NULL) {
1663 goto error;
1664 }
1665 inputPush(ctxt, inputStream);
1666
1667 /* do the parsing */
1668 xmlParseDocument(ctxt);
1669
1670 if (ctxt->myDoc != NULL) {
1671 fprintf(stderr, "SAX generated a doc !\n");
1672 xmlFreeDoc(ctxt->myDoc);
1673 ctxt->myDoc = NULL;
1674 }
1675 }
1676
1677error:
1678 if (ctxt != NULL) {
1679 ctxt->sax = old_sax;
1680 xmlFreeParserCtxt(ctxt);
1681 }
1682}
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7482
XMLPUBFUN int XMLCALL inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1745
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
XMLPUBFUN int XMLCALL xmlParseDocument(xmlParserCtxtPtr ctxt)
Definition: parser.c:10697
void * userData
Definition: parser.h:186
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc)
xmlSAXHandlerPtr debugSAXHandler
Definition: xmllint.c:1459
static xmlSAXHandlerPtr emptySAXHandler
Definition: xmllint.c:836
static xmlSAXHandlerPtr debugSAX2Handler
Definition: xmllint.c:1583

Referenced by main().

◆ unparsedEntityDeclDebug()

static void unparsedEntityDeclDebug ( void *ctx  ATTRIBUTE_UNUSED,
const xmlChar name,
const xmlChar publicId,
const xmlChar systemId,
const xmlChar notationName 
)
static

Definition at line 1122 of file xmllint.c.

1125{
1126const xmlChar *nullstr = BAD_CAST "(null)";
1127
1128 if (publicId == NULL)
1129 publicId = nullstr;
1130 if (systemId == NULL)
1131 systemId = nullstr;
1132 if (notationName == NULL)
1133 notationName = nullstr;
1134 callbacks++;
1135 if (noout)
1136 return;
1137 fprintf(stdout, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
1138 (char *) name, (char *) publicId, (char *) systemId,
1139 (char *) notationName);
1140}

◆ usage()

static void usage ( FILE f,
const char name 
)
static

Definition at line 2970 of file xmllint.c.

2970 {
2971 fprintf(f, "Usage : %s [options] XMLfiles ...\n", name);
2972#ifdef LIBXML_OUTPUT_ENABLED
2973 fprintf(f, "\tParse the XML files and output the result of the parsing\n");
2974#else
2975 fprintf(f, "\tParse the XML files\n");
2976#endif /* LIBXML_OUTPUT_ENABLED */
2977 fprintf(f, "\t--version : display the version of the XML library used\n");
2978#ifdef LIBXML_DEBUG_ENABLED
2979 fprintf(f, "\t--debug : dump a debug tree of the in-memory document\n");
2980 fprintf(f, "\t--shell : run a navigating shell\n");
2981 fprintf(f, "\t--debugent : debug the entities defined in the document\n");
2982#else
2983#ifdef LIBXML_READER_ENABLED
2984 fprintf(f, "\t--debug : dump the nodes content when using --stream\n");
2985#endif /* LIBXML_READER_ENABLED */
2986#endif
2987#ifdef LIBXML_TREE_ENABLED
2988 fprintf(f, "\t--copy : used to test the internal copy implementation\n");
2989#endif /* LIBXML_TREE_ENABLED */
2990 fprintf(f, "\t--recover : output what was parsable on broken XML documents\n");
2991 fprintf(f, "\t--huge : remove any internal arbitrary parser limits\n");
2992 fprintf(f, "\t--noent : substitute entity references by their value\n");
2993 fprintf(f, "\t--noenc : ignore any encoding specified inside the document\n");
2994 fprintf(f, "\t--noout : don't output the result tree\n");
2995 fprintf(f, "\t--path 'paths': provide a set of paths for resources\n");
2996 fprintf(f, "\t--load-trace : print trace of all external entities loaded\n");
2997 fprintf(f, "\t--nonet : refuse to fetch DTDs or entities over network\n");
2998 fprintf(f, "\t--nocompact : do not generate compact text nodes\n");
2999 fprintf(f, "\t--htmlout : output results as HTML\n");
3000 fprintf(f, "\t--nowrap : do not put HTML doc wrapper\n");
3001#ifdef LIBXML_VALID_ENABLED
3002 fprintf(f, "\t--valid : validate the document in addition to std well-formed check\n");
3003 fprintf(f, "\t--postvalid : do a posteriori validation, i.e after parsing\n");
3004 fprintf(f, "\t--dtdvalid URL : do a posteriori validation against a given DTD\n");
3005 fprintf(f, "\t--dtdvalidfpi FPI : same but name the DTD with a Public Identifier\n");
3006#endif /* LIBXML_VALID_ENABLED */
3007 fprintf(f, "\t--quiet : be quiet when succeeded\n");
3008 fprintf(f, "\t--timing : print some timings\n");
3009 fprintf(f, "\t--output file or -o file: save to a given file\n");
3010 fprintf(f, "\t--repeat : repeat 100 times, for timing or profiling\n");
3011 fprintf(f, "\t--insert : ad-hoc test for valid insertions\n");
3012#ifdef LIBXML_OUTPUT_ENABLED
3013#ifdef LIBXML_ZLIB_ENABLED
3014 fprintf(f, "\t--compress : turn on gzip compression of output\n");
3015#endif
3016#endif /* LIBXML_OUTPUT_ENABLED */
3017#ifdef LIBXML_HTML_ENABLED
3018 fprintf(f, "\t--html : use the HTML parser\n");
3019 fprintf(f, "\t--xmlout : force to use the XML serializer when using --html\n");
3020 fprintf(f, "\t--nodefdtd : do not default HTML doctype\n");
3021#endif
3022#ifdef LIBXML_PUSH_ENABLED
3023 fprintf(f, "\t--push : use the push mode of the parser\n");
3024 fprintf(f, "\t--pushsmall : use the push mode of the parser using tiny increments\n");
3025#endif /* LIBXML_PUSH_ENABLED */
3026#ifdef HAVE_MMAP
3027 fprintf(f, "\t--memory : parse from memory\n");
3028#endif
3029 fprintf(f, "\t--maxmem nbbytes : limits memory allocation to nbbytes bytes\n");
3030 fprintf(f, "\t--nowarning : do not emit warnings from parser/validator\n");
3031 fprintf(f, "\t--noblanks : drop (ignorable?) blanks spaces\n");
3032 fprintf(f, "\t--nocdata : replace cdata section with text nodes\n");
3033#ifdef LIBXML_OUTPUT_ENABLED
3034 fprintf(f, "\t--format : reformat/reindent the output\n");
3035 fprintf(f, "\t--encode encoding : output in the given encoding\n");
3036 fprintf(f, "\t--dropdtd : remove the DOCTYPE of the input docs\n");
3037 fprintf(f, "\t--pretty STYLE : pretty-print in a particular style\n");
3038 fprintf(f, "\t 0 Do not pretty print\n");
3039 fprintf(f, "\t 1 Format the XML content, as --format\n");
3040 fprintf(f, "\t 2 Add whitespace inside tags, preserving content\n");
3041#endif /* LIBXML_OUTPUT_ENABLED */
3042 fprintf(f, "\t--c14n : save in W3C canonical format v1.0 (with comments)\n");
3043 fprintf(f, "\t--c14n11 : save in W3C canonical format v1.1 (with comments)\n");
3044 fprintf(f, "\t--exc-c14n : save in W3C exclusive canonical format (with comments)\n");
3045#ifdef LIBXML_C14N_ENABLED
3046#endif /* LIBXML_C14N_ENABLED */
3047 fprintf(f, "\t--nsclean : remove redundant namespace declarations\n");
3048 fprintf(f, "\t--testIO : test user I/O support\n");
3049#ifdef LIBXML_CATALOG_ENABLED
3050 fprintf(f, "\t--catalogs : use SGML catalogs from $SGML_CATALOG_FILES\n");
3051 fprintf(f, "\t otherwise XML Catalogs starting from \n");
3052 fprintf(f, "\t %s are activated by default\n", XML_XML_DEFAULT_CATALOG);
3053 fprintf(f, "\t--nocatalogs: deactivate all catalogs\n");
3054#endif
3055 fprintf(f, "\t--auto : generate a small doc on the fly\n");
3056#ifdef LIBXML_XINCLUDE_ENABLED
3057 fprintf(f, "\t--xinclude : do XInclude processing\n");
3058 fprintf(f, "\t--noxincludenode : same but do not generate XInclude nodes\n");
3059 fprintf(f, "\t--nofixup-base-uris : do not fixup xml:base uris\n");
3060#endif
3061 fprintf(f, "\t--loaddtd : fetch external DTD\n");
3062 fprintf(f, "\t--dtdattr : loaddtd + populate the tree with inherited attributes \n");
3063#ifdef LIBXML_READER_ENABLED
3064 fprintf(f, "\t--stream : use the streaming interface to process very large files\n");
3065 fprintf(f, "\t--walker : create a reader and walk though the resulting doc\n");
3066#ifdef LIBXML_PATTERN_ENABLED
3067 fprintf(f, "\t--pattern pattern_value : test the pattern support\n");
3068#endif
3069#endif /* LIBXML_READER_ENABLED */
3070 fprintf(f, "\t--chkregister : verify the node registration code\n");
3071#ifdef LIBXML_SCHEMAS_ENABLED
3072 fprintf(f, "\t--relaxng schema : do RelaxNG validation against the schema\n");
3073 fprintf(f, "\t--schema schema : do validation against the WXS schema\n");
3074#endif
3075#ifdef LIBXML_SCHEMATRON_ENABLED
3076 fprintf(f, "\t--schematron schema : do validation against a schematron\n");
3077#endif
3078#ifdef LIBXML_SAX1_ENABLED
3079 fprintf(f, "\t--sax1: use the old SAX1 interfaces for processing\n");
3080#endif
3081 fprintf(f, "\t--sax: do not build a tree but work just at the SAX level\n");
3082 fprintf(f, "\t--oldxml10: use XML-1.0 parsing rules before the 5th edition\n");
3083#ifdef LIBXML_XPATH_ENABLED
3084 fprintf(f, "\t--xpath expr: evaluate the XPath expression, imply --noout\n");
3085#endif
3086
3087 fprintf(f, "\nLibxml project home page: https://gitlab.gnome.org/GNOME/libxml2\n");
3088}
#define XML_XML_DEFAULT_CATALOG
Definition: xmllint.c:84

◆ xmlHTMLEncodeSend()

static void xmlHTMLEncodeSend ( void  )
static

Definition at line 487 of file xmllint.c.

487 {
488 char *result;
489
490 /*
491 * xmlEncodeEntitiesReentrant assumes valid UTF-8, but the buffer might
492 * end with a truncated UTF-8 sequence. This is a hack to at least avoid
493 * an out-of-bounds read.
494 */
495 memset(&buffer[sizeof(buffer)-4], 0, 4);
497 if (result) {
500 }
501 buffer[0] = 0;
502}
XMLPUBFUN xmlChar *XMLCALL xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input)
#define memset(x, y, z)
Definition: compat.h:39

Referenced by LIBXML_ATTR_FORMAT(), xmlHTMLPrintFileContext(), and xmlHTMLPrintFileInfo().

◆ xmlHTMLPrintFileContext()

static void xmlHTMLPrintFileContext ( xmlParserInputPtr  input)
static

xmlHTMLPrintFileContext: @input: an xmlParserInputPtr input

Displays current context within the input content for error tracking

Definition at line 536 of file xmllint.c.

536 {
537 const xmlChar *cur, *base;
538 int len;
539 int n;
540
541 if (input == NULL) return;
543 cur = input->cur;
544 base = input->base;
545 while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
546 cur--;
547 }
548 n = 0;
549 while ((n++ < 80) && (cur > base) && (*cur != '\n') && (*cur != '\r'))
550 cur--;
551 if ((*cur == '\n') || (*cur == '\r')) cur++;
552 base = cur;
553 n = 0;
554 while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
555 len = strlen(buffer);
556 snprintf(&buffer[len], sizeof(buffer) - len, "%c",
557 (unsigned char) *cur++);
558 n++;
559 }
560 len = strlen(buffer);
561 snprintf(&buffer[len], sizeof(buffer) - len, "\n");
562 cur = input->cur;
563 while ((*cur == '\n') || (*cur == '\r'))
564 cur--;
565 n = 0;
566 while ((cur != base) && (n++ < 80)) {
567 len = strlen(buffer);
568 snprintf(&buffer[len], sizeof(buffer) - len, " ");
569 base++;
570 }
571 len = strlen(buffer);
572 snprintf(&buffer[len], sizeof(buffer) - len, "^\n");
575}
#define snprintf
Definition: wintirpc.h:48

Referenced by LIBXML_ATTR_FORMAT().

◆ xmlHTMLPrintFileInfo()

static void xmlHTMLPrintFileInfo ( xmlParserInputPtr  input)
static

xmlHTMLPrintFileInfo: @input: an xmlParserInputPtr input

Displays the associated file and line information for the current input

Definition at line 512 of file xmllint.c.

512 {
513 int len;
515
516 len = strlen(buffer);
517 if (input != NULL) {
518 if (input->filename) {
519 snprintf(&buffer[len], sizeof(buffer) - len, "%s:%d: ", input->filename,
520 input->line);
521 } else {
522 snprintf(&buffer[len], sizeof(buffer) - len, "Entity: line %d: ", input->line);
523 }
524 }
526}

Referenced by LIBXML_ATTR_FORMAT().

◆ xmllintExternalEntityLoader()

static xmlParserInputPtr xmllintExternalEntityLoader ( const char URL,
const char ID,
xmlParserCtxtPtr  ctxt 
)
static

Definition at line 240 of file xmllint.c.

241 {
245
246 int i;
247 const char *lastsegment = URL;
248 const char *iter = URL;
249
250 if ((nbpaths > 0) && (iter != NULL)) {
251 while (*iter != 0) {
252 if (*iter == '/')
253 lastsegment = iter + 1;
254 iter++;
255 }
256 }
257
258 if ((ctxt != NULL) && (ctxt->sax != NULL)) {
259 warning = ctxt->sax->warning;
260 err = ctxt->sax->error;
261 ctxt->sax->warning = NULL;
262 ctxt->sax->error = NULL;
263 }
264
265 if (defaultEntityLoader != NULL) {
266 ret = defaultEntityLoader(URL, ID, ctxt);
267 if (ret != NULL) {
268 if (warning != NULL)
269 ctxt->sax->warning = warning;
270 if (err != NULL)
271 ctxt->sax->error = err;
272 if (load_trace) {
273 fprintf \
274 (stderr,
275 "Loaded URL=\"%s\" ID=\"%s\"\n",
276 URL ? URL : "(null)",
277 ID ? ID : "(null)");
278 }
279 return(ret);
280 }
281 }
282 for (i = 0;i < nbpaths;i++) {
283 xmlChar *newURL;
284
285 newURL = xmlStrdup((const xmlChar *) paths[i]);
286 newURL = xmlStrcat(newURL, (const xmlChar *) "/");
287 newURL = xmlStrcat(newURL, (const xmlChar *) lastsegment);
288 if (newURL != NULL) {
289 ret = defaultEntityLoader((const char *)newURL, ID, ctxt);
290 if (ret != NULL) {
291 if (warning != NULL)
292 ctxt->sax->warning = warning;
293 if (err != NULL)
294 ctxt->sax->error = err;
295 if (load_trace) {
296 fprintf \
297 (stderr,
298 "Loaded URL=\"%s\" ID=\"%s\"\n",
299 newURL,
300 ID ? ID : "(null)");
301 }
302 xmlFree(newURL);
303 return(ret);
304 }
305 xmlFree(newURL);
306 }
307 }
308 if (err != NULL)
309 ctxt->sax->error = err;
310 if (warning != NULL) {
311 ctxt->sax->warning = warning;
312 if (URL != NULL)
313 warning(ctxt, "failed to load external entity \"%s\"\n", URL);
314 else if (ID != NULL)
315 warning(ctxt, "failed to load external entity \"%s\"\n", ID);
316 }
317 return(NULL);
318}
#define err(...)
#define ID
Definition: ruserpass.c:36
#define warning(s)
Definition: debug.h:83
void(XMLCDECL * warningSAXFunc)(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
Definition: parser.h:608
void(XMLCDECL *) typedef void(XMLCDECL * errorSAXFunc)(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
Definition: parser.h:618
XMLPUBFUN xmlChar *XMLCALL xmlStrcat(xmlChar *cur, const xmlChar *add)
Definition: xmlstring.c:524
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:67

Referenced by main().

Variable Documentation

◆ begin

clock_t begin
static

Definition at line 458 of file xmllint.c.

Referenced by basic_string< _CharT, _Traits, _Alloc >::_M_assign(), __BVECTOR_QUALIFIED::_M_fill_assign(), vector< _Tp, >::_M_fill_assign(), list< _Tp, >::_M_fill_assign(), __BVECTOR_QUALIFIED::_M_fill_insert(), __BVECTOR_QUALIFIED::_M_insert_aux(), adns__findtype(), list< _Tp, >::assign(), basic_string< _CharT, _Traits, _Alloc >::assign(), __BVECTOR_QUALIFIED::capacity(), checkMiddle(), __BVECTOR_QUALIFIED::clear(), list< _Tp, >::clear(), _Rb_tree< _Key, _Compare, _Value, _KeyOfValue, _Traits, >::clear(), copy_char_to_wchar_sz(), DBG_cutIntersectionPoly(), DBG_edgeIntersectChainD(), DecompressBitmap(), directedLine::deleteChain(), Window::dispatch_dialog_msg(), __BVECTOR_QUALIFIED::empty(), list< _Tp, >::erase(), _Rb_tree< _Key, _Compare, _Value, _KeyOfValue, _Traits, >::erase(), basic_string< _CharT, _Traits, _Alloc >::find_first_of(), basic_string< _CharT, _Traits, _Alloc >::find_last_not_of(), basic_string< _CharT, _Traits, _Alloc >::find_last_of(), vertexArray::findDecreaseChainFromEnd(), findIncreaseChainFromBegin(), __BVECTOR_QUALIFIED::front(), list< _Tp, >::front(), slist< _Tp, >::front(), ResizeManager::HandleSize(), anonymous_namespace{mstscax.cpp}::init(), ATL::CComEnumImpl< Base, piid, T, Copy >::Init(), vector< _Tp, >::insert(), __BVECTOR_QUALIFIED::insert(), LIBXML_ATTR_FORMAT(), list< _Tp, >::list(), list< _Tp, >::merge(), msi_dialog_edit_control(), msi_dialog_vcl_add_columns(), __BVECTOR_QUALIFIED::operator=(), list< _Tp, >::operator=(), _Rb_tree< key_type, key_compare, value_type, _STLP_SELECT1ST(value_type, int), _MapTraits, _Alloc >::operator=(), _Rb_tree< _Key, _Compare, _Value, _KeyOfValue, _Traits, >::operator=(), __BVECTOR_QUALIFIED::operator[](), parse_hex_literal(), list< _Tp, >::pop_front(), Window::pretranslate_msg(), print_tokens(), list< _Tp, >::push_front(), list< _Tp, >::remove(), XMLStorage::XMLNode::Children::remove(), __BVECTOR_QUALIFIED::rend(), list< _Tp, >::rend(), _Rb_tree< _Key, _Compare, _Value, _KeyOfValue, _Traits, >::rend(), deque< _Tp, >::rend(), vector< _Tp, >::rend(), __BVECTOR_QUALIFIED::reserve(), __BVECTOR_QUALIFIED::resize(), list< _Tp, >::resize(), basic_string< _CharT, _Traits, _Alloc >::rfind(), ShowDiff(), __BVECTOR_QUALIFIED::size(), list< _Tp, >::size(), startTimer(), XMLStorage::XMLErrorList::str(), String_trim(), Desktops::SwitchToDesktop(), and Desktops::~Desktops().

◆ buffer

char buffer[50000]
static

Definition at line 484 of file xmllint.c.

◆ callbacks

◆ chkregister

int chkregister = 0
static

Definition at line 184 of file xmllint.c.

Referenced by main().

◆ debug

int debug = 0
static

Definition at line 104 of file xmllint.c.

Referenced by main(), and parseAndPrintFile().

◆ debugSAX2Handler

xmlSAXHandlerPtr debugSAX2Handler = &debugSAX2HandlerStruct
static

Definition at line 1583 of file xmllint.c.

Referenced by testSAX().

◆ debugSAX2HandlerStruct

xmlSAXHandler debugSAX2HandlerStruct
static

Definition at line 1548 of file xmllint.c.

◆ debugSAXHandler

Definition at line 1459 of file xmllint.c.

Referenced by testSAX().

◆ debugSAXHandlerStruct

xmlSAXHandler debugSAXHandlerStruct
static

Definition at line 1424 of file xmllint.c.

◆ defaultEntityLoader

xmlExternalEntityLoader defaultEntityLoader = NULL
static

Definition at line 237 of file xmllint.c.

Referenced by main(), and xmllintExternalEntityLoader().

◆ dropdtd

int dropdtd = 0
static

Definition at line 165 of file xmllint.c.

Referenced by main(), and parseAndPrintFile().

◆ dtdattrs

int dtdattrs = 0
static

Definition at line 159 of file xmllint.c.

Referenced by main().

◆ emptySAXHandler

xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct
static

Definition at line 836 of file xmllint.c.

Referenced by testSAX().

◆ emptySAXHandlerStruct

xmlSAXHandler emptySAXHandlerStruct
static

Definition at line 801 of file xmllint.c.

◆ encoding

char* encoding = NULL
static

Definition at line 155 of file xmllint.c.

Referenced by _test_current_encoding(), _test_form_encoding(), _test_form_put_encoding(), BDF_Face_Init(), blob_to_str(), cff_cmap_encoding_init(), cff_encoding_done(), cff_encoding_load(), cff_face_init(), create_writer_output(), CreateFontPackage(), CreateXmlReaderInputWithEncodingName(), CreateXmlWriterOutputWithEncodingName(), decode_inner_content(), dwarf2_parse_augmentation_ptr(), dwarf2_parse_base_type(), enc2num(), find_unicode_charmap(), fnIMultiLanguage_ConvertStringFromUnicode(), FT_DEFINE_SERVICE_PSFONTNAMEREC(), FT_Get_BDF_Charset_ID(), FT_Select_Charmap(), get_code_page(), get_encoding_name(), get_url_encoding(), id3_to_utf8(), init_content_encoding(), init_output_buffer(), main(), mpg123_encsize(), mpg123_fmt_support(), mpg123_format_support(), mpg123_getformat(), mpg123_getformat2(), mpg123_open_fixed(), mxwriter_get_encoding(), mxwriter_put_encoding(), next_text(), open_fixed_post(), open_fixed_pre(), XMLStorage::XMLReaderBase::parse(), parse_cie_details(), parse_encoding_name(), parseAndPrintFile(), pcf_get_encodings(), process_comment(), process_extra(), process_picture(), PROFILE_Save(), PROFILE_WriteLine(), PROFILE_WriteMarker(), SearchFile(), set_content_length(), sfnt_find_encoding(), store_id3_text(), t1_cmap_custom_init(), test_mxwriter_default_properties(), test_sip(), test_UrlMkGetSessionOption(), UrlMkGetSessionOption(), WINTRUST_GetTimeFromCounterSigner(), WINTRUST_GetTimeFromSigner(), xmlCtxtReadDoc(), xmlCtxtReadFd(), xmlCtxtReadFile(), xmlCtxtReadIO(), xmlCtxtReadMemory(), xmlCtxtResetPush(), xmlCtxtUseOptionsInternal(), XMLStorage::XMLReaderBase::XmlDeclHandler(), xmlDoRead(), xmlParseEncodingDecl(), xmlParseTextDecl(), xmlReadDoc(), xmlReadFd(), xmlReadFile(), xmlReadIO(), xmlReadMemory(), xsltApplyStylesheetInternal(), xsltDocumentElem(), xsltSaveResultTo(), xsltSaveResultToFd(), xsltSaveResultToFile(), xsltSaveResultToFilename(), and xsltSaveResultToString().

◆ end

clock_t end
static

Definition at line 458 of file xmllint.c.

◆ generate

int generate = 0
static

Definition at line 164 of file xmllint.c.

Referenced by GeneratorTest::gener1(), GeneratorTest::gener2(), main(), and parseAndPrintFile().

◆ htmlout

int htmlout = 0
static

Definition at line 143 of file xmllint.c.

Referenced by main(), and parseAndPrintFile().

◆ insert

int insert = 0
static

Definition at line 138 of file xmllint.c.

Referenced by __BVECTOR_QUALIFIED::_M_fill_assign(), deque< _Tp, >::_M_fill_assign(), list< _Tp, >::_M_fill_assign(), list< _Tp, >::_M_fill_insert(), list< _Tp, >::_M_insert(), basic_string< _CharT, _Traits, _Alloc >::_M_insert_dispatch(), basic_string< _CharT, _Traits, _Alloc >::_M_insertT(), _STLP_STATIC_ASSERT(), add_entry(), add_reglocator_entry(), AddToInputListView(), deque< _Tp, >::assign(), list< _Tp, >::assign(), format_insert(), _Locale_impl::insert(), list< _Tp, >::insert(), vector< _Tp, >::insert(), deque< _Tp, >::insert(), slist< _Tp, >::insert(), reflexChain::insert(), rope< _CharT, _Alloc >::insert(), basic_string< _CharT, _Traits, _Alloc >::insert(), _Locale_impl::insert_collate_facets(), _Locale_impl::insert_ctype_facets(), _Locale_impl::insert_messages_facets(), _Locale_impl::insert_monetary_facets(), _Locale_impl::insert_numeric_facets(), _Locale_impl::insert_time_facets(), list< _Tp, >::list(), LoadSystemIni(), main(), ME_InsertString(), deque< _Tp, >::operator=(), list< _Tp, >::operator=(), map< _Key, _Tp,, >::operator[](), parseAndPrintFile(), reflexChain::processNewVertex(), PropertyStore_LookupValue(), psh_glyph_interpolate_normal_points(), vector< _Tp, >::push_back(), list< _Tp, >::push_back(), list< _Tp, >::push_front(), basic_string< _CharT, _Traits, _Alloc >::replace(), __BVECTOR_QUALIFIED::resize(), vector< _Tp, >::resize(), deque< _Tp, >::resize(), list< _Tp, >::splice(), slist< _Tp, >::splice(), Knotspec::transform(), primStream::triangle(), xmlDictExists(), xmlDictLookup(), xmlDictQLookup(), xmlHashAddEntry3(), xmlHashUpdateEntry3(), xsltApplySequenceConstructor(), xsltCopyTree(), xsltCopyTreeList(), xsltEvalTemplateString(), xsltShallowCopyElem(), and xsltShallowCopyNsNode().

◆ load_trace

int load_trace = 0
static

Definition at line 209 of file xmllint.c.

Referenced by main(), and xmllintExternalEntityLoader().

◆ loaddtd

int loaddtd = 0
static

Definition at line 160 of file xmllint.c.

Referenced by main().

◆ maxmem

int maxmem = 0
static

Definition at line 105 of file xmllint.c.

Referenced by main(), myMallocFunc(), myReallocFunc(), myStrdupFunc(), and OOM().

◆ nbpaths

int nbpaths = 0
static

Definition at line 208 of file xmllint.c.

Referenced by parsePath(), and xmllintExternalEntityLoader().

◆ nbregister

int nbregister = 0
static

Definition at line 185 of file xmllint.c.

Referenced by deregisterNode(), main(), and registerNode().

◆ noblanks

int noblanks = 0
static

Definition at line 112 of file xmllint.c.

Referenced by main().

◆ noenc

int noenc = 0
static

Definition at line 111 of file xmllint.c.

Referenced by main(), and xsltCopyTree().

◆ noent

int noent = 0
static

Definition at line 110 of file xmllint.c.

Referenced by main().

◆ noout

◆ nowrap

int nowrap = 0
static

Definition at line 114 of file xmllint.c.

Referenced by main().

◆ oldxml10

int oldxml10 = 0
static

Definition at line 194 of file xmllint.c.

Referenced by main().

◆ options

Definition at line 192 of file xmllint.c.

◆ paths

xmlChar* paths[MAX_PATHS+1]
static

Definition at line 207 of file xmllint.c.

◆ progresult

xmllintReturnCode progresult = XMLLINT_RETURN_OK
static

Definition at line 161 of file xmllint.c.

Referenced by main(), OOM(), parseAndPrintFile(), and testSAX().

◆ quiet

◆ recovery

int recovery = 0
static

Definition at line 109 of file xmllint.c.

Referenced by main(), and parseAndPrintFile().

◆ repeat

◆ sax

int sax = 0
static

◆ testIO

int testIO = 0
static

Definition at line 154 of file xmllint.c.

Referenced by main(), and parseAndPrintFile().

◆ timing

int timing = 0
static

Definition at line 163 of file xmllint.c.

Referenced by AtapiDmaInit(), hpt_timing(), main(), parseAndPrintFile(), and promise_timing().