summaryrefslogtreecommitdiff
path: root/testSAX.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2001-03-24 17:00:36 +0000
committerDaniel Veillard <veillard@src.gnome.org>2001-03-24 17:00:36 +0000
commit56a4cb8c4d3eab4ab3295a61c87e8e92483922c6 (patch)
tree24cdc196bdb98eb6980c2d27e405fc7e1f1d7bdf /testSAX.c
parentc7ad7ce598261a447cfceb7837219fcd93151336 (diff)
downloadlibxml2-56a4cb8c4d3eab4ab3295a61c87e8e92483922c6.tar.gz
Huge cleanup, I switched to compile with
-Wall -g -O -ansi -pedantic -W -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline - HTMLparser.[ch] HTMLtree.c SAX.c debugXML.c encoding.[ch] encoding.h entities.c error.c list.[ch] nanoftp.c nanohttp.c parser.[ch] parserInternals.[ch] testHTML.c testSAX.c testURI.c testXPath.c tree.[ch] uri.c valid.[ch] xinclude.c xmlIO.[ch] xmllint.c xmlmemory.c xpath.c xpathInternals.h xpointer.[ch] example/gjobread.c: Cleanup, staticfied a number of non-exported functions, detected and cleaned up a dozen of problem found this way, avoided a lot of public function name/typedef/system names clashes - doc/xml.html: updated - configure.in: switched private flags to the really pedantic ones. Daniel
Diffstat (limited to 'testSAX.c')
-rw-r--r--testSAX.c178
1 files changed, 107 insertions, 71 deletions
diff --git a/testSAX.c b/testSAX.c
index ff96e4bd..51def378 100644
--- a/testSAX.c
+++ b/testSAX.c
@@ -44,6 +44,18 @@
#include <libxml/debugXML.h>
#include <libxml/xmlmemory.h>
+/************************************************************************
+ * *
+ * When running GCC in vaacum cleaner mode *
+ * *
+ ************************************************************************/
+
+#ifdef __GNUC__
+#define UNUSED __attribute__((__unused__))
+#else
+#define UNUSED
+#endif
+
static int debug = 0;
static int copy = 0;
static int recovery = 0;
@@ -77,6 +89,7 @@ xmlSAXHandler emptySAXHandlerStruct = {
NULL, /* xmlParserError */
NULL, /* getParameterEntity */
NULL, /* cdataBlock; */
+ NULL /* externalSubset; */
};
xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct;
@@ -96,8 +109,8 @@ extern xmlSAXHandlerPtr debugSAXHandler;
*
* Returns 1 if true
*/
-int
-isStandaloneDebug(void *ctx)
+static int
+isStandaloneDebug(void *ctx UNUSED)
{
fprintf(stdout, "SAX.isStandalone()\n");
return(0);
@@ -111,8 +124,8 @@ isStandaloneDebug(void *ctx)
*
* Returns 1 if true
*/
-int
-hasInternalSubsetDebug(void *ctx)
+static int
+hasInternalSubsetDebug(void *ctx UNUSED)
{
fprintf(stdout, "SAX.hasInternalSubset()\n");
return(0);
@@ -126,8 +139,8 @@ hasInternalSubsetDebug(void *ctx)
*
* Returns 1 if true
*/
-int
-hasExternalSubsetDebug(void *ctx)
+static int
+hasExternalSubsetDebug(void *ctx UNUSED)
{
fprintf(stdout, "SAX.hasExternalSubset()\n");
return(0);
@@ -139,8 +152,8 @@ hasExternalSubsetDebug(void *ctx)
*
* Does this document has an internal subset
*/
-void
-internalSubsetDebug(void *ctx, const xmlChar *name,
+static void
+internalSubsetDebug(void *ctx UNUSED, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *SystemID)
{
fprintf(stdout, "SAX.internalSubset(%s,", name);
@@ -155,6 +168,27 @@ internalSubsetDebug(void *ctx, const xmlChar *name,
}
/**
+ * externalSubsetDebug:
+ * @ctxt: An XML parser context
+ *
+ * Does this document has an external subset
+ */
+static void
+externalSubsetDebug(void *ctx UNUSED, const xmlChar *name,
+ const xmlChar *ExternalID, const xmlChar *SystemID)
+{
+ fprintf(stdout, "SAX.externalSubset(%s,", name);
+ if (ExternalID == NULL)
+ fprintf(stdout, " ,");
+ else
+ fprintf(stdout, " %s,", ExternalID);
+ if (SystemID == NULL)
+ fprintf(stdout, " )\n");
+ else
+ fprintf(stdout, " %s)\n", SystemID);
+}
+
+/**
* resolveEntityDebug:
* @ctxt: An XML parser context
* @publicId: The public ID of the entity
@@ -168,8 +202,8 @@ internalSubsetDebug(void *ctx, const xmlChar *name,
*
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
*/
-xmlParserInputPtr
-resolveEntityDebug(void *ctx, const xmlChar *publicId, const xmlChar *systemId)
+static xmlParserInputPtr
+resolveEntityDebug(void *ctx UNUSED, const xmlChar *publicId, const xmlChar *systemId)
{
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
@@ -200,8 +234,8 @@ resolveEntityDebug(void *ctx, const xmlChar *publicId, const xmlChar *systemId)
*
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
*/
-xmlEntityPtr
-getEntityDebug(void *ctx, const xmlChar *name)
+static xmlEntityPtr
+getEntityDebug(void *ctx UNUSED, const xmlChar *name)
{
fprintf(stdout, "SAX.getEntity(%s)\n", name);
return(NULL);
@@ -216,8 +250,8 @@ getEntityDebug(void *ctx, const xmlChar *name)
*
* Returns the xmlParserInputPtr
*/
-xmlEntityPtr
-getParameterEntityDebug(void *ctx, const xmlChar *name)
+static xmlEntityPtr
+getParameterEntityDebug(void *ctx UNUSED, const xmlChar *name)
{
fprintf(stdout, "SAX.getParameterEntity(%s)\n", name);
return(NULL);
@@ -235,8 +269,8 @@ getParameterEntityDebug(void *ctx, const xmlChar *name)
*
* An entity definition has been parsed
*/
-void
-entityDeclDebug(void *ctx, const xmlChar *name, int type,
+static void
+entityDeclDebug(void *ctx UNUSED, const xmlChar *name, int type,
const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
{
fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
@@ -251,10 +285,10 @@ entityDeclDebug(void *ctx, const xmlChar *name, int type,
*
* An attribute definition has been parsed
*/
-void
-attributeDeclDebug(void *ctx, const xmlChar *elem, const xmlChar *name,
+static void
+attributeDeclDebug(void *ctx UNUSED, const xmlChar *elem, const xmlChar *name,
int type, int def, const xmlChar *defaultValue,
- xmlEnumerationPtr tree)
+ xmlEnumerationPtr tree UNUSED)
{
if (defaultValue == NULL)
fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n",
@@ -273,9 +307,9 @@ attributeDeclDebug(void *ctx, const xmlChar *elem, const xmlChar *name,
*
* An element definition has been parsed
*/
-void
-elementDeclDebug(void *ctx, const xmlChar *name, int type,
- xmlElementContentPtr content)
+static void
+elementDeclDebug(void *ctx UNUSED, const xmlChar *name, int type,
+ xmlElementContentPtr content UNUSED)
{
fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n",
name, type);
@@ -290,8 +324,8 @@ elementDeclDebug(void *ctx, const xmlChar *name, int type,
*
* What to do when a notation declaration has been parsed.
*/
-void
-notationDeclDebug(void *ctx, const xmlChar *name,
+static void
+notationDeclDebug(void *ctx UNUSED, const xmlChar *name,
const xmlChar *publicId, const xmlChar *systemId)
{
fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n",
@@ -308,8 +342,8 @@ notationDeclDebug(void *ctx, const xmlChar *name,
*
* What to do when an unparsed entity declaration is parsed
*/
-void
-unparsedEntityDeclDebug(void *ctx, const xmlChar *name,
+static void
+unparsedEntityDeclDebug(void *ctx UNUSED, const xmlChar *name,
const xmlChar *publicId, const xmlChar *systemId,
const xmlChar *notationName)
{
@@ -326,8 +360,8 @@ unparsedEntityDeclDebug(void *ctx, const xmlChar *name,
* Receive the document locator at startup, actually xmlDefaultSAXLocator
* Everything is available on the context, so this is useless in our case.
*/
-void
-setDocumentLocatorDebug(void *ctx, xmlSAXLocatorPtr loc)
+static void
+setDocumentLocatorDebug(void *ctx UNUSED, xmlSAXLocatorPtr loc UNUSED)
{
fprintf(stdout, "SAX.setDocumentLocator()\n");
}
@@ -338,8 +372,8 @@ setDocumentLocatorDebug(void *ctx, xmlSAXLocatorPtr loc)
*
* called when the document start being processed.
*/
-void
-startDocumentDebug(void *ctx)
+static void
+startDocumentDebug(void *ctx UNUSED)
{
fprintf(stdout, "SAX.startDocument()\n");
}
@@ -350,8 +384,8 @@ startDocumentDebug(void *ctx)
*
* called when the document end has been detected.
*/
-void
-endDocumentDebug(void *ctx)
+static void
+endDocumentDebug(void *ctx UNUSED)
{
fprintf(stdout, "SAX.endDocument()\n");
}
@@ -363,8 +397,8 @@ endDocumentDebug(void *ctx)
*
* called when an opening tag has been processed.
*/
-void
-startElementDebug(void *ctx, const xmlChar *name, const xmlChar **atts)
+static void
+startElementDebug(void *ctx UNUSED, const xmlChar *name, const xmlChar **atts)
{
int i;
@@ -386,8 +420,8 @@ startElementDebug(void *ctx, const xmlChar *name, const xmlChar **atts)
*
* called when the end of an element has been detected.
*/
-void
-endElementDebug(void *ctx, const xmlChar *name)
+static void
+endElementDebug(void *ctx UNUSED, const xmlChar *name)
{
fprintf(stdout, "SAX.endElement(%s)\n", (char *) name);
}
@@ -401,8 +435,8 @@ endElementDebug(void *ctx, const xmlChar *name)
* receiving some chars from the parser.
* Question: how much at a time ???
*/
-void
-charactersDebug(void *ctx, const xmlChar *ch, int len)
+static void
+charactersDebug(void *ctx UNUSED, const xmlChar *ch, int len)
{
char output[40];
int i;
@@ -421,8 +455,8 @@ charactersDebug(void *ctx, const xmlChar *ch, int len)
*
* called when an entity reference is detected.
*/
-void
-referenceDebug(void *ctx, const xmlChar *name)
+static void
+referenceDebug(void *ctx UNUSED, const xmlChar *name)
{
fprintf(stdout, "SAX.reference(%s)\n", name);
}
@@ -437,8 +471,8 @@ referenceDebug(void *ctx, const xmlChar *name)
* receiving some ignorable whitespaces from the parser.
* Question: how much at a time ???
*/
-void
-ignorableWhitespaceDebug(void *ctx, const xmlChar *ch, int len)
+static void
+ignorableWhitespaceDebug(void *ctx UNUSED, const xmlChar *ch, int len)
{
char output[40];
int i;
@@ -458,8 +492,8 @@ ignorableWhitespaceDebug(void *ctx, const xmlChar *ch, int len)
*
* A processing instruction has been parsed.
*/
-void
-processingInstructionDebug(void *ctx, const xmlChar *target,
+static void
+processingInstructionDebug(void *ctx UNUSED, const xmlChar *target,
const xmlChar *data)
{
fprintf(stdout, "SAX.processingInstruction(%s, %s)\n",
@@ -474,8 +508,8 @@ processingInstructionDebug(void *ctx, const xmlChar *target,
*
* called when a pcdata block has been parsed
*/
-void
-cdataBlockDebug(void *ctx, const xmlChar *value, int len)
+static void
+cdataBlockDebug(void *ctx UNUSED, const xmlChar *value, int len)
{
fprintf(stdout, "SAX.pcdata(%.20s, %d)\n",
(char *) value, len);
@@ -488,8 +522,8 @@ cdataBlockDebug(void *ctx, const xmlChar *value, int len)
*
* A comment has been parsed.
*/
-void
-commentDebug(void *ctx, const xmlChar *value)
+static void
+commentDebug(void *ctx UNUSED, const xmlChar *value)
{
fprintf(stdout, "SAX.comment(%s)\n", value);
}
@@ -503,8 +537,8 @@ commentDebug(void *ctx, const xmlChar *value)
* Display and format a warning messages, gives file, line, position and
* extra parameters.
*/
-void
-warningDebug(void *ctx, const char *msg, ...)
+static void
+warningDebug(void *ctx UNUSED, const char *msg, ...)
{
va_list args;
@@ -523,8 +557,8 @@ warningDebug(void *ctx, const char *msg, ...)
* Display and format a error messages, gives file, line, position and
* extra parameters.
*/
-void
-errorDebug(void *ctx, const char *msg, ...)
+static void
+errorDebug(void *ctx UNUSED, const char *msg, ...)
{
va_list args;
@@ -543,8 +577,8 @@ errorDebug(void *ctx, const char *msg, ...)
* Display and format a fatalError messages, gives file, line, position and
* extra parameters.
*/
-void
-fatalErrorDebug(void *ctx, const char *msg, ...)
+static void
+fatalErrorDebug(void *ctx UNUSED, const char *msg, ...)
{
va_list args;
@@ -580,7 +614,8 @@ xmlSAXHandler debugSAXHandlerStruct = {
errorDebug,
fatalErrorDebug,
getParameterEntityDebug,
- cdataBlockDebug
+ cdataBlockDebug,
+ externalSubsetDebug
};
xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct;
@@ -591,7 +626,8 @@ xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct;
* *
************************************************************************/
-void parseAndPrintFile(char *filename) {
+static void
+parseAndPrintFile(char *filename) {
int res;
if (push) {
@@ -602,16 +638,16 @@ void parseAndPrintFile(char *filename) {
*/
f = fopen(filename, "r");
if (f != NULL) {
- int res;
+ int ret;
char chars[10];
xmlParserCtxtPtr ctxt;
- res = fread(chars, 1, 4, f);
- if (res > 0) {
+ ret = fread(chars, 1, 4, f);
+ if (ret > 0) {
ctxt = xmlCreatePushParserCtxt(emptySAXHandler, NULL,
- chars, res, filename);
- while ((res = fread(chars, 1, 3, f)) > 0) {
- xmlParseChunk(ctxt, chars, res, 0);
+ chars, ret, filename);
+ while ((ret = fread(chars, 1, 3, f)) > 0) {
+ xmlParseChunk(ctxt, chars, ret, 0);
}
xmlParseChunk(ctxt, chars, 0, 1);
xmlFreeParserCtxt(ctxt);
@@ -626,22 +662,22 @@ void parseAndPrintFile(char *filename) {
*/
f = fopen(filename, "r");
if (f != NULL) {
- int res;
+ int ret;
char chars[10];
xmlParserCtxtPtr ctxt;
- res = fread(chars, 1, 4, f);
- if (res > 0) {
+ ret = fread(chars, 1, 4, f);
+ if (ret > 0) {
ctxt = xmlCreatePushParserCtxt(debugSAXHandler, NULL,
- chars, res, filename);
- while ((res = fread(chars, 1, 3, f)) > 0) {
- xmlParseChunk(ctxt, chars, res, 0);
+ chars, ret, filename);
+ while ((ret = fread(chars, 1, 3, f)) > 0) {
+ xmlParseChunk(ctxt, chars, ret, 0);
}
- res = xmlParseChunk(ctxt, chars, 0, 1);
+ ret = xmlParseChunk(ctxt, chars, 0, 1);
xmlFreeParserCtxt(ctxt);
- if (res != 0) {
+ if (ret != 0) {
fprintf(stdout,
- "xmlSAXUserParseFile returned error %d\n", res);
+ "xmlSAXUserParseFile returned error %d\n", ret);
}
}
fclose(f);