1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

xmllint: Move shell to xmllint

Move source code for xmllint shell to shell.c and move it from the
libxml2 library to the xmllint executable.

Also allow shell to run without XPath and debug modules.

Add stubs for old shell API functions in legacy build mode.
This commit is contained in:
Nick Wellnhofer 2024-06-16 17:57:12 +02:00
parent c9b065914f
commit 1341deac13
12 changed files with 1813 additions and 2888 deletions

View File

@ -468,13 +468,14 @@ if(MSVC AND BUILD_SHARED_LIBS)
endif()
if(LIBXML2_WITH_PROGRAMS)
add_executable(xmllint xmllint.c shell.c)
add_executable(xmlcatalog xmlcatalog.c)
set(
PROGRAMS
xmlcatalog
xmllint
)
foreach(PROGRAM ${PROGRAMS})
add_executable(${PROGRAM} ${PROGRAM}.c)
add_executable(LibXml2::${PROGRAM} ALIAS ${PROGRAM})
target_compile_definitions(${PROGRAM} PRIVATE SYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
target_link_libraries(${PROGRAM} LibXml2)

View File

@ -137,7 +137,7 @@ runsuite_SOURCES=runsuite.c
runsuite_DEPENDENCIES = $(DEPS)
runsuite_LDADD= $(LDADDS)
xmllint_SOURCES=xmllint.c
xmllint_SOURCES = xmllint.c shell.c
xmllint_CFLAGS = $(AM_CFLAGS) $(RDL_CFLAGS) $(ICONV_CFLAGS)
xmllint_DEPENDENCIES = $(DEPS)
xmllint_LDADD= $(RDL_LIBS) $(LDADDS)

1762
debugXML.c

File diff suppressed because it is too large Load Diff

View File

@ -311,10 +311,6 @@
<summary>Tree debugging APIs</summary>
<description>Interfaces to a set of routines used for debugging the tree produced by the XML parser. </description>
<author>Daniel Veillard </author>
<exports symbol='xmlShellCtxt' type='typedef'/>
<exports symbol='xmlShellCtxtPtr' type='typedef'/>
<exports symbol='_xmlShellCtxt' type='struct'/>
<exports symbol='xmlBoolToText' type='function'/>
<exports symbol='xmlDebugCheckDocument' type='function'/>
<exports symbol='xmlDebugDumpAttr' type='function'/>
<exports symbol='xmlDebugDumpAttrList' type='function'/>
@ -326,24 +322,6 @@
<exports symbol='xmlDebugDumpNodeList' type='function'/>
<exports symbol='xmlDebugDumpOneNode' type='function'/>
<exports symbol='xmlDebugDumpString' type='function'/>
<exports symbol='xmlLsCountNode' type='function'/>
<exports symbol='xmlLsOneNode' type='function'/>
<exports symbol='xmlShell' type='function'/>
<exports symbol='xmlShellBase' type='function'/>
<exports symbol='xmlShellCat' type='function'/>
<exports symbol='xmlShellCmd' type='function'/>
<exports symbol='xmlShellDir' type='function'/>
<exports symbol='xmlShellDu' type='function'/>
<exports symbol='xmlShellList' type='function'/>
<exports symbol='xmlShellLoad' type='function'/>
<exports symbol='xmlShellPrintNode' type='function'/>
<exports symbol='xmlShellPrintXPathError' type='function'/>
<exports symbol='xmlShellPrintXPathResult' type='function'/>
<exports symbol='xmlShellPwd' type='function'/>
<exports symbol='xmlShellReadlineFunc' type='function'/>
<exports symbol='xmlShellSave' type='function'/>
<exports symbol='xmlShellValidate' type='function'/>
<exports symbol='xmlShellWrite' type='function'/>
</file>
<file name='dict'>
<summary>string dictionary</summary>
@ -6656,16 +6634,6 @@ Could we use @subtypes for this?'/>
<struct name='xmlSchematronValidCtxt' file='schematron' type='struct _xmlSchematronValidCtxt'/>
<typedef name='xmlSchematronValidCtxtPtr' file='schematron' type='xmlSchematronValidCtxt *'/>
<typedef name='xmlSchematronValidOptions' file='schematron' type='enum'/>
<struct name='xmlShellCtxt' file='debugXML' type='struct _xmlShellCtxt'>
<field name='filename' type='char *' info=''/>
<field name='doc' type='xmlDocPtr' info=''/>
<field name='node' type='xmlNodePtr' info=''/>
<field name='pctxt' type='xmlXPathContextPtr' info=''/>
<field name='loaded' type='int' info=''/>
<field name='output' type='FILE *' info=''/>
<field name='input' type='xmlShellReadlineFunc' info=''/>
</struct>
<typedef name='xmlShellCtxtPtr' file='debugXML' type='xmlShellCtxt *'/>
<struct name='xmlStartTag' file='parser' type='struct _xmlStartTag'/>
<struct name='xmlStreamCtxt' file='pattern' type='struct _xmlStreamCtxt'/>
<typedef name='xmlStreamCtxtPtr' file='pattern' type='xmlStreamCtxt *'/>
@ -8313,12 +8281,6 @@ Could we use @subtypes for this?'/>
<arg name='am' type='xmlAutomataPtr' info='an automata'/>
<arg name='state' type='xmlAutomataStatePtr' info='a state in this automata'/>
</function>
<function name='xmlBoolToText' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED)</cond>
<info>Convenient way to turn bool into text</info>
<return type='const char *' info='a pointer to either &quot;True&quot; or &quot;False&quot;'/>
<arg name='boolval' type='int' info='a bool to turn into text'/>
</function>
<function name='xmlBufContent' file='tree' module='buf'>
<info>Function to extract the content of a buffer</info>
<return type='xmlChar *' info='the internal content'/>
@ -10689,19 +10651,6 @@ Could we use @subtypes for this?'/>
<arg name='enc' type='xmlCharEncoding' info='an xmlCharEncoding value.'/>
<arg name='out' type='xmlCharEncodingHandler **' info='pointer to result'/>
</function>
<function name='xmlLsCountNode' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED)</cond>
<info>Count the children of @node.</info>
<return type='int' info='the number of children of @node.'/>
<arg name='node' type='xmlNodePtr' info='the node to count'/>
</function>
<function name='xmlLsOneNode' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED)</cond>
<info>Dump to @output the type and name of @node.</info>
<return type='void'/>
<arg name='output' type='FILE *' info='the FILE * for the output'/>
<arg name='node' type='xmlNodePtr' info='the node to dump'/>
</function>
<function name='xmlMallocAtomicLoc' file='xmlmemory' module='xmlmemory'>
<info>DEPRECATED: don&apos;t use</info>
<return type='void *' info='a pointer to the allocated area or NULL in case of lack of memory.'/>
@ -13932,139 +13881,6 @@ Could we use @subtypes for this?'/>
<arg name='buffer' type='const xmlChar *' info='a xmlChar * buffer'/>
<arg name='filename' type='const char *' info='a file name'/>
</function>
<function name='xmlShell' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED)</cond>
<info>Implements the XML shell This allow to load, validate, view, modify and save a document using a environment similar to a UNIX commandline.</info>
<return type='void'/>
<arg name='doc' type='xmlDocPtr' info='the initial document'/>
<arg name='filename' type='const char *' info='the output buffer'/>
<arg name='input' type='xmlShellReadlineFunc' info='the line reading function'/>
<arg name='output' type='FILE *' info='the output FILE*, defaults to stdout if NULL'/>
</function>
<function name='xmlShellBase' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED)</cond>
<info>Implements the XML shell function &quot;base&quot; dumps the current XML base of the node</info>
<return type='int' info='0'/>
<arg name='ctxt' type='xmlShellCtxtPtr' info='the shell context'/>
<arg name='arg' type='char *' info='unused'/>
<arg name='node' type='xmlNodePtr' info='a node'/>
<arg name='node2' type='xmlNodePtr' info='unused'/>
</function>
<function name='xmlShellCat' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED) &amp;&amp; defined(LIBXML_OUTPUT_ENABLED)</cond>
<info>Implements the XML shell function &quot;cat&quot; dumps the serialization node content (XML or HTML).</info>
<return type='int' info='0'/>
<arg name='ctxt' type='xmlShellCtxtPtr' info='the shell context'/>
<arg name='arg' type='char *' info='unused'/>
<arg name='node' type='xmlNodePtr' info='a node'/>
<arg name='node2' type='xmlNodePtr' info='unused'/>
</function>
<functype name='xmlShellCmd' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED)</cond>
<info>This is a generic signature for the XML shell functions.</info>
<return type='int' info='an int, negative returns indicating errors.'/>
<arg name='ctxt' type='xmlShellCtxtPtr' info='a shell context'/>
<arg name='arg' type='char *' info='a string argument'/>
<arg name='node' type='xmlNodePtr' info='a first node'/>
<arg name='node2' type='xmlNodePtr' info='a second node'/>
</functype>
<function name='xmlShellDir' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED)</cond>
<info>Implements the XML shell function &quot;dir&quot; dumps information about the node (namespace, attributes, content).</info>
<return type='int' info='0'/>
<arg name='ctxt' type='xmlShellCtxtPtr' info='the shell context'/>
<arg name='arg' type='char *' info='unused'/>
<arg name='node' type='xmlNodePtr' info='a node'/>
<arg name='node2' type='xmlNodePtr' info='unused'/>
</function>
<function name='xmlShellDu' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED)</cond>
<info>Implements the XML shell function &quot;du&quot; show the structure of the subtree under node @tree If @tree is null, the command works on the current node.</info>
<return type='int' info='0 or -1 in case of error'/>
<arg name='ctxt' type='xmlShellCtxtPtr' info='the shell context'/>
<arg name='arg' type='char *' info='unused'/>
<arg name='tree' type='xmlNodePtr' info='a node defining a subtree'/>
<arg name='node2' type='xmlNodePtr' info='unused'/>
</function>
<function name='xmlShellList' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED)</cond>
<info>Implements the XML shell function &quot;ls&quot; Does an Unix like listing of the given node (like a directory)</info>
<return type='int' info='0'/>
<arg name='ctxt' type='xmlShellCtxtPtr' info='the shell context'/>
<arg name='arg' type='char *' info='unused'/>
<arg name='node' type='xmlNodePtr' info='a node'/>
<arg name='node2' type='xmlNodePtr' info='unused'/>
</function>
<function name='xmlShellLoad' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED)</cond>
<info>Implements the XML shell function &quot;load&quot; loads a new document specified by the filename</info>
<return type='int' info='0 or -1 if loading failed'/>
<arg name='ctxt' type='xmlShellCtxtPtr' info='the shell context'/>
<arg name='filename' type='char *' info='the file name'/>
<arg name='node' type='xmlNodePtr' info='unused'/>
<arg name='node2' type='xmlNodePtr' info='unused'/>
</function>
<function name='xmlShellPrintNode' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED) &amp;&amp; defined(LIBXML_OUTPUT_ENABLED)</cond>
<info>Print node to the output FILE</info>
<return type='void'/>
<arg name='node' type='xmlNodePtr' info='a non-null node to print to the output FILE'/>
</function>
<function name='xmlShellPrintXPathError' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED)</cond>
<info>Print the xpath error to libxml default error channel</info>
<return type='void'/>
<arg name='errorType' type='int' info='valid xpath error id'/>
<arg name='arg' type='const char *' info='the argument that cause xpath to fail'/>
</function>
<function name='xmlShellPrintXPathResult' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED)</cond>
<info>Prints result to the output FILE</info>
<return type='void'/>
<arg name='list' type='xmlXPathObjectPtr' info='a valid result generated by an xpath evaluation'/>
</function>
<function name='xmlShellPwd' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED)</cond>
<info>Implements the XML shell function &quot;pwd&quot; Show the full path from the root to the node, if needed building thumblers when similar elements exists at a given ancestor level. The output is compatible with XPath commands.</info>
<return type='int' info='0 or -1 in case of error'/>
<arg name='ctxt' type='xmlShellCtxtPtr' info='the shell context'/>
<arg name='buffer' type='char *' info='the output buffer'/>
<arg name='node' type='xmlNodePtr' info='a node'/>
<arg name='node2' type='xmlNodePtr' info='unused'/>
</function>
<functype name='xmlShellReadlineFunc' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED)</cond>
<info>This is a generic signature for the XML shell input function.</info>
<return type='char *' info='a string which will be freed by the Shell.'/>
<arg name='prompt' type='char *' info='a string prompt'/>
</functype>
<function name='xmlShellSave' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED) &amp;&amp; defined(LIBXML_OUTPUT_ENABLED)</cond>
<info>Implements the XML shell function &quot;save&quot; Write the current document to the filename, or it&apos;s original name</info>
<return type='int' info='0 or -1 in case of error'/>
<arg name='ctxt' type='xmlShellCtxtPtr' info='the shell context'/>
<arg name='filename' type='char *' info='the file name (optional)'/>
<arg name='node' type='xmlNodePtr' info='unused'/>
<arg name='node2' type='xmlNodePtr' info='unused'/>
</function>
<function name='xmlShellValidate' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED) &amp;&amp; defined(LIBXML_VALID_ENABLED)</cond>
<info>Implements the XML shell function &quot;validate&quot; Validate the document, if a DTD path is provided, then the validation is done against the given DTD.</info>
<return type='int' info='0 or -1 in case of error'/>
<arg name='ctxt' type='xmlShellCtxtPtr' info='the shell context'/>
<arg name='dtd' type='char *' info='the DTD URI (optional)'/>
<arg name='node' type='xmlNodePtr' info='unused'/>
<arg name='node2' type='xmlNodePtr' info='unused'/>
</function>
<function name='xmlShellWrite' file='debugXML' module='debugXML'>
<cond>defined(LIBXML_DEBUG_ENABLED) &amp;&amp; defined(LIBXML_XPATH_ENABLED) &amp;&amp; defined(LIBXML_OUTPUT_ENABLED)</cond>
<info>Implements the XML shell function &quot;write&quot; Write the current node to the filename, it saves the serialization of the subtree under the @node specified</info>
<return type='int' info='0 or -1 in case of error'/>
<arg name='ctxt' type='xmlShellCtxtPtr' info='the shell context'/>
<arg name='filename' type='char *' info='the file name'/>
<arg name='node' type='xmlNodePtr' info='a node in the tree'/>
<arg name='node2' type='xmlNodePtr' info='unused'/>
</function>
<function name='xmlSkipBlankChars' file='parserInternals' module='parser'>
<info>DEPRECATED: Internal function, do not use. Skip whitespace in the input stream.</info>
<return type='int' info='the number of space chars skipped'/>

View File

@ -71,144 +71,6 @@ XMLPUBFUN int
xmlDebugCheckDocument (FILE * output,
xmlDocPtr doc);
/****************************************************************
* *
* XML shell helpers *
* *
****************************************************************/
XMLPUBFUN void
xmlLsOneNode (FILE *output, xmlNodePtr node);
XMLPUBFUN int
xmlLsCountNode (xmlNodePtr node);
XMLPUBFUN const char *
xmlBoolToText (int boolval);
/****************************************************************
* *
* The XML shell related structures and functions *
* *
****************************************************************/
#ifdef LIBXML_XPATH_ENABLED
/**
* xmlShellReadlineFunc:
* @prompt: a string prompt
*
* This is a generic signature for the XML shell input function.
*
* Returns a string which will be freed by the Shell.
*/
typedef char * (* xmlShellReadlineFunc)(char *prompt);
/**
* xmlShellCtxt:
*
* A debugging shell context.
* TODO: add the defined function tables.
*/
typedef struct _xmlShellCtxt xmlShellCtxt;
typedef xmlShellCtxt *xmlShellCtxtPtr;
struct _xmlShellCtxt {
char *filename;
xmlDocPtr doc;
xmlNodePtr node;
xmlXPathContextPtr pctxt;
int loaded;
FILE *output;
xmlShellReadlineFunc input;
};
/**
* xmlShellCmd:
* @ctxt: a shell context
* @arg: a string argument
* @node: a first node
* @node2: a second node
*
* This is a generic signature for the XML shell functions.
*
* Returns an int, negative returns indicating errors.
*/
typedef int (* xmlShellCmd) (xmlShellCtxtPtr ctxt,
char *arg,
xmlNodePtr node,
xmlNodePtr node2);
XMLPUBFUN void
xmlShellPrintXPathError (int errorType,
const char *arg);
XMLPUBFUN void
xmlShellPrintXPathResult(xmlXPathObjectPtr list);
XMLPUBFUN int
xmlShellList (xmlShellCtxtPtr ctxt,
char *arg,
xmlNodePtr node,
xmlNodePtr node2);
XMLPUBFUN int
xmlShellBase (xmlShellCtxtPtr ctxt,
char *arg,
xmlNodePtr node,
xmlNodePtr node2);
XMLPUBFUN int
xmlShellDir (xmlShellCtxtPtr ctxt,
char *arg,
xmlNodePtr node,
xmlNodePtr node2);
XMLPUBFUN int
xmlShellLoad (xmlShellCtxtPtr ctxt,
char *filename,
xmlNodePtr node,
xmlNodePtr node2);
#ifdef LIBXML_OUTPUT_ENABLED
XMLPUBFUN void
xmlShellPrintNode (xmlNodePtr node);
XMLPUBFUN int
xmlShellCat (xmlShellCtxtPtr ctxt,
char *arg,
xmlNodePtr node,
xmlNodePtr node2);
XMLPUBFUN int
xmlShellWrite (xmlShellCtxtPtr ctxt,
char *filename,
xmlNodePtr node,
xmlNodePtr node2);
XMLPUBFUN int
xmlShellSave (xmlShellCtxtPtr ctxt,
char *filename,
xmlNodePtr node,
xmlNodePtr node2);
#endif /* LIBXML_OUTPUT_ENABLED */
#ifdef LIBXML_VALID_ENABLED
XMLPUBFUN int
xmlShellValidate (xmlShellCtxtPtr ctxt,
char *dtd,
xmlNodePtr node,
xmlNodePtr node2);
#endif /* LIBXML_VALID_ENABLED */
XMLPUBFUN int
xmlShellDu (xmlShellCtxtPtr ctxt,
char *arg,
xmlNodePtr tree,
xmlNodePtr node2);
XMLPUBFUN int
xmlShellPwd (xmlShellCtxtPtr ctxt,
char *buffer,
xmlNodePtr node,
xmlNodePtr node2);
/*
* The Shell interface.
*/
XMLPUBFUN void
xmlShell (xmlDocPtr doc,
const char *filename,
xmlShellReadlineFunc input,
FILE *output);
#endif /* LIBXML_XPATH_ENABLED */
#ifdef __cplusplus
}
#endif

View File

@ -12,6 +12,7 @@ EXTRA_DIST = \
parser.h \
regexp.h \
save.h \
shell.h \
string.h \
threads.h \
tree.h \

7
include/private/shell.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef XML_SHELL_H_PRIVATE__
#define XML_SHELL_H_PRIVATE__
void
xmllintShell(xmlDocPtr doc, const char *filename, FILE *output);
#endif /* XML_SHELL_H_PRIVATE__ */

165
legacy.c
View File

@ -1354,8 +1354,6 @@ cdataBlock(void *ctx, const xmlChar * value, int len)
* nanoftp.h
*/
/** DOC_DISABLE */
#ifdef _WIN32
#include <winsock2.h>
#else
@ -1591,14 +1589,10 @@ xmlIOFTPClose(void *context ATTRIBUTE_UNUSED) {
return(-1);
}
/** DOC_ENABLE */
/*
* xpointer.h
*/
/** DOC_DISABLE */
XMLPUBFUN void *
xmlXPtrNewRange(void *start, int startindex,
void *end, int endindex);
@ -1753,7 +1747,164 @@ xmlXPtrRangeToFunction(void *ctxt ATTRIBUTE_UNUSED,
int nargs ATTRIBUTE_UNUSED) {
}
/** DOC_ENABLE */
/*
* xmllint shell functions formerly in debugXML.h
*/
XMLPUBFUN void
xmlLsOneNode(FILE *output, xmlNodePtr node);
void
xmlLsOneNode(FILE *output ATTRIBUTE_UNUSED, xmlNodePtr node ATTRIBUTE_UNUSED) {
}
XMLPUBFUN int
xmlLsCountNode(xmlNodePtr node);
int
xmlLsCountNode(xmlNodePtr node ATTRIBUTE_UNUSED) {
return(0);
}
XMLPUBFUN const char *
xmlBoolToText(int boolval);
const char *
xmlBoolToText(int boolval) {
if (boolval)
return("True");
else
return("False");
}
#ifdef LIBXML_XPATH_ENABLED
XMLPUBFUN void
xmlShellPrintXPathError(int errorType, const char *arg);
void
xmlShellPrintXPathError(int errorType ATTRIBUTE_UNUSED,
const char *arg ATTRIBUTE_UNUSED) {
}
XMLPUBFUN void
xmlShellPrintXPathResult(void *list);
void
xmlShellPrintXPathResult(void *list ATTRIBUTE_UNUSED) {
}
XMLPUBFUN int
xmlShellList(void *ctxt, char *arg, void *node, void *node2);
int
xmlShellList(void *ctxt ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED,
void *node ATTRIBUTE_UNUSED, void *node2 ATTRIBUTE_UNUSED) {
return(0);
}
XMLPUBFUN int
xmlShellBase(void *ctxt, char *arg, void *node, void *node2);
int
xmlShellBase(void *ctxt ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED,
void *node ATTRIBUTE_UNUSED, void *node2 ATTRIBUTE_UNUSED) {
return(0);
}
XMLPUBFUN int
xmlShellDir(void *ctxt, char *arg, void *node, void *node2);
int
xmlShellDir(void *ctxt ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED,
void *node ATTRIBUTE_UNUSED, void *node2 ATTRIBUTE_UNUSED) {
return(0);
}
XMLPUBFUN int
xmlShellLoad(void *ctxt, char *arg, void *node, void *node2);
int
xmlShellLoad(void *ctxt ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED,
void *node ATTRIBUTE_UNUSED, void *node2 ATTRIBUTE_UNUSED) {
return(0);
}
#ifdef LIBXML_OUTPUT_ENABLED
XMLPUBFUN void
xmlShellPrintNode(void *node);
void
xmlShellPrintNode(void *ctxt ATTRIBUTE_UNUSED) {
}
XMLPUBFUN int
xmlShellCat(void *ctxt, char *arg, void *node, void *node2);
int
xmlShellCat(void *ctxt ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED,
void *node ATTRIBUTE_UNUSED, void *node2 ATTRIBUTE_UNUSED) {
return(0);
}
XMLPUBFUN int
xmlShellWrite(void *ctxt, char *arg, void *node, void *node2);
int
xmlShellWrite(void *ctxt ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED,
void *node ATTRIBUTE_UNUSED, void *node2 ATTRIBUTE_UNUSED) {
return(0);
}
XMLPUBFUN int
xmlShellSave(void *ctxt, char *arg, void *node, void *node2);
int
xmlShellSave(void *ctxt ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED,
void *node ATTRIBUTE_UNUSED, void *node2 ATTRIBUTE_UNUSED) {
return(0);
}
#endif /* LIBXML_OUTPUT_ENABLED */
#ifdef LIBXML_VALID_ENABLED
XMLPUBFUN int
xmlShellValidate(void *ctxt, char *arg, void *node, void *node2);
int
xmlShellValidate(void *ctxt ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED,
void *node ATTRIBUTE_UNUSED, void *node2 ATTRIBUTE_UNUSED) {
return(0);
}
#endif /* LIBXML_VALID_ENABLED */
XMLPUBFUN int
xmlShellDu(void *ctxt, char *arg, void *node, void *node2);
int
xmlShellDu(void *ctxt ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED,
void *node ATTRIBUTE_UNUSED, void *node2 ATTRIBUTE_UNUSED) {
return(0);
}
XMLPUBFUN int
xmlShellPwd(void *ctxt, char *arg, void *node, void *node2);
int
xmlShellPwd(void *ctxt ATTRIBUTE_UNUSED, char *arg ATTRIBUTE_UNUSED,
void *node ATTRIBUTE_UNUSED, void *node2 ATTRIBUTE_UNUSED) {
return(0);
}
typedef char * (*xmlShellReadlineFunc)(char *prompt);
XMLPUBFUN void
xmlShell(void *doc, char *filename, xmlShellReadlineFunc input, void *output);
void
xmlShell(void *doc ATTRIBUTE_UNUSED, char *filename ATTRIBUTE_UNUSED,
xmlShellReadlineFunc input ATTRIBUTE_UNUSED,
void *output ATTRIBUTE_UNUSED) {
}
#endif /* LIBXML_XPATH_ENABLED */
#endif /* LIBXML_LEGACY_ENABLED */

View File

@ -665,7 +665,7 @@ meson.override_dependency('libxml-2.0', xml_dep)
executable(
'xmllint',
files('xmllint.c'),
files('xmllint.c', 'shell.c'),
dependencies: [xml_dep, xmllint_deps],
include_directories: config_dir,
install: true,

1629
shell.c Normal file

File diff suppressed because it is too large Load Diff

735
testapi.c
View File

@ -929,17 +929,6 @@ static void des_xmlNodeSetPtr(int no ATTRIBUTE_UNUSED, xmlNodeSetPtr val ATTRIBU
}
#endif
#ifdef LIBXML_DEBUG_ENABLED
#ifdef LIBXML_XPATH_ENABLED
#define gen_nb_xmlShellCtxtPtr 1
static xmlShellCtxtPtr gen_xmlShellCtxtPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
return(NULL);
}
static void des_xmlShellCtxtPtr(int no ATTRIBUTE_UNUSED, xmlShellCtxtPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
}
#endif
#endif
#ifdef LIBXML_PATTERN_ENABLED
#define gen_nb_xmlPatternPtr 1
static xmlPatternPtr gen_xmlPatternPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
@ -7004,40 +6993,6 @@ test_chvalid(void) {
return(test_ret);
}
static int
test_xmlBoolToText(void) {
int test_ret = 0;
#if defined(LIBXML_DEBUG_ENABLED)
int mem_base;
const char * ret_val;
int boolval; /* a bool to turn into text */
int n_boolval;
for (n_boolval = 0;n_boolval < gen_nb_int;n_boolval++) {
mem_base = xmlMemBlocks();
boolval = gen_int(n_boolval, 0);
ret_val = xmlBoolToText(boolval);
desret_const_char_ptr(ret_val);
call_tests++;
des_int(n_boolval, boolval, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlBoolToText",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_boolval);
printf("\n");
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlDebugCheckDocument(void) {
int test_ret = 0;
@ -7503,681 +7458,11 @@ test_xmlDebugDumpString(void) {
return(test_ret);
}
static int
test_xmlLsCountNode(void) {
int test_ret = 0;
#if defined(LIBXML_DEBUG_ENABLED)
int mem_base;
int ret_val;
xmlNodePtr node; /* the node to count */
int n_node;
for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) {
mem_base = xmlMemBlocks();
node = gen_xmlNodePtr(n_node, 0);
ret_val = xmlLsCountNode(node);
desret_int(ret_val);
call_tests++;
des_xmlNodePtr(n_node, node, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlLsCountNode",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_node);
printf("\n");
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlLsOneNode(void) {
int test_ret = 0;
#if defined(LIBXML_DEBUG_ENABLED)
int mem_base;
FILE * output; /* the FILE * for the output */
int n_output;
xmlNodePtr node; /* the node to dump */
int n_node;
for (n_output = 0;n_output < gen_nb_debug_FILE_ptr;n_output++) {
for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) {
mem_base = xmlMemBlocks();
output = gen_debug_FILE_ptr(n_output, 0);
node = gen_xmlNodePtr(n_node, 1);
xmlLsOneNode(output, node);
call_tests++;
des_debug_FILE_ptr(n_output, output, 0);
des_xmlNodePtr(n_node, node, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlLsOneNode",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_output);
printf(" %d", n_node);
printf("\n");
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlShell(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
#define gen_nb_char_ptr 1
#define gen_char_ptr(no, nr) NULL
#define des_char_ptr(no, val, nr)
static int
test_xmlShellBase(void) {
int test_ret = 0;
#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
int mem_base;
int ret_val;
xmlShellCtxtPtr ctxt; /* the shell context */
int n_ctxt;
char * arg; /* unused */
int n_arg;
xmlNodePtr node; /* a node */
int n_node;
xmlNodePtr node2; /* unused */
int n_node2;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) {
for (n_arg = 0;n_arg < gen_nb_char_ptr;n_arg++) {
for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) {
for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0);
arg = gen_char_ptr(n_arg, 1);
node = gen_xmlNodePtr(n_node, 2);
node2 = gen_xmlNodePtr(n_node2, 3);
ret_val = xmlShellBase(ctxt, arg, node, node2);
desret_int(ret_val);
call_tests++;
des_xmlShellCtxtPtr(n_ctxt, ctxt, 0);
des_char_ptr(n_arg, arg, 1);
des_xmlNodePtr(n_node, node, 2);
des_xmlNodePtr(n_node2, node2, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlShellBase",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_arg);
printf(" %d", n_node);
printf(" %d", n_node2);
printf("\n");
}
}
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlShellCat(void) {
int test_ret = 0;
#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
int mem_base;
int ret_val;
xmlShellCtxtPtr ctxt; /* the shell context */
int n_ctxt;
char * arg; /* unused */
int n_arg;
xmlNodePtr node; /* a node */
int n_node;
xmlNodePtr node2; /* unused */
int n_node2;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) {
for (n_arg = 0;n_arg < gen_nb_char_ptr;n_arg++) {
for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) {
for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0);
arg = gen_char_ptr(n_arg, 1);
node = gen_xmlNodePtr(n_node, 2);
node2 = gen_xmlNodePtr(n_node2, 3);
ret_val = xmlShellCat(ctxt, arg, node, node2);
desret_int(ret_val);
call_tests++;
des_xmlShellCtxtPtr(n_ctxt, ctxt, 0);
des_char_ptr(n_arg, arg, 1);
des_xmlNodePtr(n_node, node, 2);
des_xmlNodePtr(n_node2, node2, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlShellCat",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_arg);
printf(" %d", n_node);
printf(" %d", n_node2);
printf("\n");
}
}
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlShellDir(void) {
int test_ret = 0;
#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
int mem_base;
int ret_val;
xmlShellCtxtPtr ctxt; /* the shell context */
int n_ctxt;
char * arg; /* unused */
int n_arg;
xmlNodePtr node; /* a node */
int n_node;
xmlNodePtr node2; /* unused */
int n_node2;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) {
for (n_arg = 0;n_arg < gen_nb_char_ptr;n_arg++) {
for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) {
for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0);
arg = gen_char_ptr(n_arg, 1);
node = gen_xmlNodePtr(n_node, 2);
node2 = gen_xmlNodePtr(n_node2, 3);
ret_val = xmlShellDir(ctxt, arg, node, node2);
desret_int(ret_val);
call_tests++;
des_xmlShellCtxtPtr(n_ctxt, ctxt, 0);
des_char_ptr(n_arg, arg, 1);
des_xmlNodePtr(n_node, node, 2);
des_xmlNodePtr(n_node2, node2, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlShellDir",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_arg);
printf(" %d", n_node);
printf(" %d", n_node2);
printf("\n");
}
}
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlShellDu(void) {
int test_ret = 0;
#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
int mem_base;
int ret_val;
xmlShellCtxtPtr ctxt; /* the shell context */
int n_ctxt;
char * arg; /* unused */
int n_arg;
xmlNodePtr tree; /* a node defining a subtree */
int n_tree;
xmlNodePtr node2; /* unused */
int n_node2;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) {
for (n_arg = 0;n_arg < gen_nb_char_ptr;n_arg++) {
for (n_tree = 0;n_tree < gen_nb_xmlNodePtr;n_tree++) {
for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0);
arg = gen_char_ptr(n_arg, 1);
tree = gen_xmlNodePtr(n_tree, 2);
node2 = gen_xmlNodePtr(n_node2, 3);
ret_val = xmlShellDu(ctxt, arg, tree, node2);
desret_int(ret_val);
call_tests++;
des_xmlShellCtxtPtr(n_ctxt, ctxt, 0);
des_char_ptr(n_arg, arg, 1);
des_xmlNodePtr(n_tree, tree, 2);
des_xmlNodePtr(n_node2, node2, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlShellDu",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_arg);
printf(" %d", n_tree);
printf(" %d", n_node2);
printf("\n");
}
}
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlShellList(void) {
int test_ret = 0;
#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
int mem_base;
int ret_val;
xmlShellCtxtPtr ctxt; /* the shell context */
int n_ctxt;
char * arg; /* unused */
int n_arg;
xmlNodePtr node; /* a node */
int n_node;
xmlNodePtr node2; /* unused */
int n_node2;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) {
for (n_arg = 0;n_arg < gen_nb_char_ptr;n_arg++) {
for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) {
for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0);
arg = gen_char_ptr(n_arg, 1);
node = gen_xmlNodePtr(n_node, 2);
node2 = gen_xmlNodePtr(n_node2, 3);
ret_val = xmlShellList(ctxt, arg, node, node2);
desret_int(ret_val);
call_tests++;
des_xmlShellCtxtPtr(n_ctxt, ctxt, 0);
des_char_ptr(n_arg, arg, 1);
des_xmlNodePtr(n_node, node, 2);
des_xmlNodePtr(n_node2, node2, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlShellList",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_arg);
printf(" %d", n_node);
printf(" %d", n_node2);
printf("\n");
}
}
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlShellLoad(void) {
int test_ret = 0;
#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
int mem_base;
int ret_val;
xmlShellCtxtPtr ctxt; /* the shell context */
int n_ctxt;
char * filename; /* the file name */
int n_filename;
xmlNodePtr node; /* unused */
int n_node;
xmlNodePtr node2; /* unused */
int n_node2;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) {
for (n_filename = 0;n_filename < gen_nb_char_ptr;n_filename++) {
for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) {
for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0);
filename = gen_char_ptr(n_filename, 1);
node = gen_xmlNodePtr(n_node, 2);
node2 = gen_xmlNodePtr(n_node2, 3);
ret_val = xmlShellLoad(ctxt, filename, node, node2);
desret_int(ret_val);
call_tests++;
des_xmlShellCtxtPtr(n_ctxt, ctxt, 0);
des_char_ptr(n_filename, filename, 1);
des_xmlNodePtr(n_node, node, 2);
des_xmlNodePtr(n_node2, node2, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlShellLoad",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_filename);
printf(" %d", n_node);
printf(" %d", n_node2);
printf("\n");
}
}
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlShellPrintXPathResult(void) {
int test_ret = 0;
#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
int mem_base;
xmlXPathObjectPtr list; /* a valid result generated by an xpath evaluation */
int n_list;
for (n_list = 0;n_list < gen_nb_xmlXPathObjectPtr;n_list++) {
mem_base = xmlMemBlocks();
list = gen_xmlXPathObjectPtr(n_list, 0);
xmlShellPrintXPathResult(list);
call_tests++;
des_xmlXPathObjectPtr(n_list, list, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlShellPrintXPathResult",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_list);
printf("\n");
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlShellPwd(void) {
int test_ret = 0;
#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
int mem_base;
int ret_val;
xmlShellCtxtPtr ctxt; /* the shell context */
int n_ctxt;
char * buffer; /* the output buffer */
int n_buffer;
xmlNodePtr node; /* a node */
int n_node;
xmlNodePtr node2; /* unused */
int n_node2;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) {
for (n_buffer = 0;n_buffer < gen_nb_char_ptr;n_buffer++) {
for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) {
for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0);
buffer = gen_char_ptr(n_buffer, 1);
node = gen_xmlNodePtr(n_node, 2);
node2 = gen_xmlNodePtr(n_node2, 3);
ret_val = xmlShellPwd(ctxt, buffer, node, node2);
desret_int(ret_val);
call_tests++;
des_xmlShellCtxtPtr(n_ctxt, ctxt, 0);
des_char_ptr(n_buffer, buffer, 1);
des_xmlNodePtr(n_node, node, 2);
des_xmlNodePtr(n_node2, node2, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlShellPwd",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_buffer);
printf(" %d", n_node);
printf(" %d", n_node2);
printf("\n");
}
}
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlShellSave(void) {
int test_ret = 0;
#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
int mem_base;
int ret_val;
xmlShellCtxtPtr ctxt; /* the shell context */
int n_ctxt;
char * filename; /* the file name (optional) */
int n_filename;
xmlNodePtr node; /* unused */
int n_node;
xmlNodePtr node2; /* unused */
int n_node2;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) {
for (n_filename = 0;n_filename < gen_nb_char_ptr;n_filename++) {
for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) {
for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0);
filename = gen_char_ptr(n_filename, 1);
node = gen_xmlNodePtr(n_node, 2);
node2 = gen_xmlNodePtr(n_node2, 3);
ret_val = xmlShellSave(ctxt, filename, node, node2);
desret_int(ret_val);
call_tests++;
des_xmlShellCtxtPtr(n_ctxt, ctxt, 0);
des_char_ptr(n_filename, filename, 1);
des_xmlNodePtr(n_node, node, 2);
des_xmlNodePtr(n_node2, node2, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlShellSave",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_filename);
printf(" %d", n_node);
printf(" %d", n_node2);
printf("\n");
}
}
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlShellValidate(void) {
int test_ret = 0;
#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_VALID_ENABLED)
int mem_base;
int ret_val;
xmlShellCtxtPtr ctxt; /* the shell context */
int n_ctxt;
char * dtd; /* the DTD URI (optional) */
int n_dtd;
xmlNodePtr node; /* unused */
int n_node;
xmlNodePtr node2; /* unused */
int n_node2;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) {
for (n_dtd = 0;n_dtd < gen_nb_char_ptr;n_dtd++) {
for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) {
for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0);
dtd = gen_char_ptr(n_dtd, 1);
node = gen_xmlNodePtr(n_node, 2);
node2 = gen_xmlNodePtr(n_node2, 3);
ret_val = xmlShellValidate(ctxt, dtd, node, node2);
desret_int(ret_val);
call_tests++;
des_xmlShellCtxtPtr(n_ctxt, ctxt, 0);
des_char_ptr(n_dtd, dtd, 1);
des_xmlNodePtr(n_node, node, 2);
des_xmlNodePtr(n_node2, node2, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlShellValidate",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_dtd);
printf(" %d", n_node);
printf(" %d", n_node2);
printf("\n");
}
}
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlShellWrite(void) {
int test_ret = 0;
#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
int mem_base;
int ret_val;
xmlShellCtxtPtr ctxt; /* the shell context */
int n_ctxt;
char * filename; /* the file name */
int n_filename;
xmlNodePtr node; /* a node in the tree */
int n_node;
xmlNodePtr node2; /* unused */
int n_node2;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlShellCtxtPtr;n_ctxt++) {
for (n_filename = 0;n_filename < gen_nb_char_ptr;n_filename++) {
for (n_node = 0;n_node < gen_nb_xmlNodePtr;n_node++) {
for (n_node2 = 0;n_node2 < gen_nb_xmlNodePtr;n_node2++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlShellCtxtPtr(n_ctxt, 0);
filename = gen_char_ptr(n_filename, 1);
node = gen_xmlNodePtr(n_node, 2);
node2 = gen_xmlNodePtr(n_node2, 3);
ret_val = xmlShellWrite(ctxt, filename, node, node2);
desret_int(ret_val);
call_tests++;
des_xmlShellCtxtPtr(n_ctxt, ctxt, 0);
des_char_ptr(n_filename, filename, 1);
des_xmlNodePtr(n_node, node, 2);
des_xmlNodePtr(n_node2, node2, 3);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlShellWrite",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_filename);
printf(" %d", n_node);
printf(" %d", n_node2);
printf("\n");
}
}
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_debugXML(void) {
int test_ret = 0;
if (quiet == 0) printf("Testing debugXML : 25 of 28 functions ...\n");
test_ret += test_xmlBoolToText();
if (quiet == 0) printf("Testing debugXML : 11 of 11 functions ...\n");
test_ret += test_xmlDebugCheckDocument();
test_ret += test_xmlDebugDumpAttr();
test_ret += test_xmlDebugDumpAttrList();
@ -8189,20 +7474,6 @@ test_debugXML(void) {
test_ret += test_xmlDebugDumpNodeList();
test_ret += test_xmlDebugDumpOneNode();
test_ret += test_xmlDebugDumpString();
test_ret += test_xmlLsCountNode();
test_ret += test_xmlLsOneNode();
test_ret += test_xmlShell();
test_ret += test_xmlShellBase();
test_ret += test_xmlShellCat();
test_ret += test_xmlShellDir();
test_ret += test_xmlShellDu();
test_ret += test_xmlShellList();
test_ret += test_xmlShellLoad();
test_ret += test_xmlShellPrintXPathResult();
test_ret += test_xmlShellPwd();
test_ret += test_xmlShellSave();
test_ret += test_xmlShellValidate();
test_ret += test_xmlShellWrite();
if (test_ret != 0)
printf("Module debugXML: %d errors\n", test_ret);
@ -25035,6 +24306,10 @@ test_xmlCreateURI(void) {
}
#define gen_nb_char_ptr 1
#define gen_char_ptr(no, nr) NULL
#define des_char_ptr(no, val, nr)
static int
test_xmlNormalizeURIPath(void) {
int test_ret = 0;

View File

@ -41,12 +41,6 @@
#define MAP_FAILED ((void *) -1)
#endif
#endif
#ifdef HAVE_LIBREADLINE
#include <readline/readline.h>
#ifdef HAVE_LIBHISTORY
#include <readline/history.h>
#endif
#endif
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
@ -81,6 +75,8 @@
#include <libxml/xmlsave.h>
#endif
#include "private/shell.h"
#ifdef XMLLINT_FUZZ
#define ERR_STREAM stdout
#else
@ -110,8 +106,8 @@ typedef enum {
XMLLINT_ERR_XPATH_EMPTY = 11 /* XPath result is empty */
} xmllintReturnCode;
#ifdef LIBXML_DEBUG_ENABLED
static int shell = 0;
#ifdef LIBXML_DEBUG_ENABLED
static int debugent = 0;
#endif
static int debug = 0;
@ -599,57 +595,6 @@ xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
va_end(args);
}
/************************************************************************
* *
* Shell Interface *
* *
************************************************************************/
#ifdef LIBXML_DEBUG_ENABLED
#ifdef LIBXML_XPATH_ENABLED
/**
* xmlShellReadline:
* @prompt: the prompt value
*
* Read a string
*
* Returns a pointer to it or NULL on EOF the caller is expected to
* free the returned string.
*/
static char *
xmlShellReadline(char *prompt) {
#ifdef HAVE_LIBREADLINE
char *line_read;
/* Get a line from the user. */
line_read = readline (prompt);
/* If the line has any text in it, save it on the history. */
if (line_read && *line_read)
add_history (line_read);
return (line_read);
#else
char line_read[501];
char *ret;
int len;
if (prompt != NULL)
fprintf(stdout, "%s", prompt);
fflush(stdout);
if (!fgets(line_read, 500, stdin))
return(NULL);
line_read[500] = 0;
len = strlen(line_read);
ret = (char *) malloc(len + 1);
if (ret != NULL) {
memcpy (ret, line_read, len + 1);
}
return(ret);
#endif
}
#endif /* LIBXML_XPATH_ENABLED */
#endif /* LIBXML_DEBUG_ENABLED */
/************************************************************************
* *
* I/O Interfaces *
@ -2292,16 +2237,16 @@ parseAndPrintFile(const char *filename, xmlParserCtxtPtr rectxt) {
}
#endif
#ifdef LIBXML_DEBUG_ENABLED
#ifdef LIBXML_XPATH_ENABLED
#ifndef XMLLINT_FUZZ
/*
* shell interaction
*/
if (shell) {
#ifdef LIBXML_XPATH_ENABLED
xmlXPathOrderDocElems(doc);
xmlShell(doc, filename, xmlShellReadline, stdout);
}
#endif
xmllintShell(doc, filename, stdout);
}
#endif
/*
@ -2814,9 +2759,9 @@ static void usage(FILE *f, const char *name) {
fprintf(f, "\tParse the XML files\n");
#endif /* LIBXML_OUTPUT_ENABLED */
fprintf(f, "\t--version : display the version of the XML library used\n");
fprintf(f, "\t--shell : run a navigating shell\n");
#ifdef LIBXML_DEBUG_ENABLED
fprintf(f, "\t--debug : dump a debug tree of the in-memory document\n");
fprintf(f, "\t--shell : run a navigating shell\n");
fprintf(f, "\t--debugent : debug the entities defined in the document\n");
#else
#ifdef LIBXML_READER_ENABLED
@ -3112,13 +3057,11 @@ xmllintMain(int argc, const char **argv, xmlResourceLoader loader) {
if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
debug++;
else
#ifdef LIBXML_DEBUG_ENABLED
if ((!strcmp(argv[i], "-shell")) ||
(!strcmp(argv[i], "--shell"))) {
shell++;
noout = 1;
} else
#endif
if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy")))
copy++;
else