error.c revision 38ae7e4efe803ea78b6499cd05a394db32623e41
/*
* error.c: module displaying/handling XML parser errors
*
* See Copyright for the status of this software.
*
* Daniel Veillard <daniel@veillard.com>
*/
#define IN_LIBXML
#include "libxml.h"
#include <string.h>
#include <stdarg.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlmemory.h>
const char *msg,
...);
int chars; \
char *larger; \
\
\
size = 150; \
\
while (1) { \
break; \
} else { \
} \
} \
if (chars > -1) \
else \
size += 100; \
break; \
} \
}} \
}
/************************************************************************
* *
* Handling of out of context errors *
* *
************************************************************************/
/**
* xmlGenericErrorDefaultFunc:
* @ctx: an error context
* @...: extra parameters for the message display
*
* Default handler for out of context error messages.
*/
void XMLCDECL
if (xmlGenericErrorContext == NULL)
xmlGenericErrorContext = (void *) stderr;
}
/**
* initGenericErrorDefaultFunc:
* @handler: the handler
*
* Set or reset (if NULL) the default handler for generic errors
* to the builtin error function.
*/
void
{
else
xmlGenericError = (*handler);
}
/**
* xmlSetGenericErrorFunc:
* @ctx: the new error handling context
* @handler: the new handler function
*
* Function to reset the handler and the error context for out of
* context error messages.
* This simply means that @handler will be called for subsequent
* error messages while not parsing nor validating. And @ctx will
* be passed as first argument to @handler
* One can simply force messages to be emitted to another FILE * than
* stderr by setting @ctx to this file handle and @handler to NULL.
* For multi-threaded applications, this must be set separately for each thread.
*/
void
else
}
/**
* xmlSetStructuredErrorFunc:
* @ctx: the new error handling context
* @handler: the new handler function
*
* Function to reset the handler and the error context for out of
* context structured error messages.
* This simply means that @handler will be called for subsequent
* error messages while not parsing nor validating. And @ctx will
* be passed as first argument to @handler
* For multi-threaded applications, this must be set separately for each thread.
*/
void
}
/************************************************************************
* *
* Handling of parsing errors *
* *
************************************************************************/
/**
* xmlParserPrintFileInfo:
* @input: an xmlParserInputPtr input
*
* Displays the associated file and line informations for the current input
*/
void
else
}
}
/**
* xmlParserPrintFileContext:
* @input: an xmlParserInputPtr input
*
* Displays current context within the input content for error tracking
*/
static void
unsigned int n, col; /* GCC warns if signed, because compared with sizeof() */
/* skip backwards over any end-of-lines */
cur--;
}
n = 0;
/* search backwards for beginning-of-line (to max buff size) */
cur--;
/* calculate the error position in terms of the current position */
/* search forward for end-of-line (to max buff size) */
n = 0;
/* copy selected text to our buffer */
n++;
}
*ctnt = 0;
/* print out the selected text */
/* create blank line with problem pointer */
n = 0;
/* (leave buffer space for pointer + line terminator) */
if (*(ctnt) != '\t')
*(ctnt) = ' ';
ctnt++;
}
*ctnt++ = '^';
*ctnt = 0;
}
/**
* xmlParserPrintFileContext:
* @input: an xmlParserInputPtr input
*
* Displays current context within the input content for error tracking
*/
void
}
/**
* xmlReportError:
* @err: the error
* @ctx: the parser context or NULL
* @str: the formatted error message
*
* routines.
*/
static void
{
int line = 0;
int code = -1;
int domain;
return;
}
if (code == XML_ERR_OK)
return;
/*
* Maintain the compatibility with the legacy error handling
*/
}
}
} else {
}
}
switch (domain) {
case XML_FROM_PARSER:
break;
case XML_FROM_NAMESPACE:
break;
case XML_FROM_DTD:
case XML_FROM_VALID:
break;
case XML_FROM_HTML:
break;
case XML_FROM_MEMORY:
break;
case XML_FROM_OUTPUT:
break;
case XML_FROM_IO:
break;
case XML_FROM_XINCLUDE:
break;
case XML_FROM_XPATH:
break;
case XML_FROM_XPOINTER:
break;
case XML_FROM_REGEXP:
break;
case XML_FROM_MODULE:
break;
case XML_FROM_SCHEMASV:
break;
case XML_FROM_SCHEMASP:
break;
case XML_FROM_RELAXNGP:
break;
case XML_FROM_RELAXNGV:
break;
case XML_FROM_CATALOG:
break;
case XML_FROM_C14N:
break;
case XML_FROM_XSLT:
break;
case XML_FROM_I18N:
break;
default:
break;
}
switch (level) {
case XML_ERR_NONE:
break;
case XML_ERR_WARNING:
break;
case XML_ERR_ERROR:
break;
case XML_ERR_FATAL:
break;
}
int len;
else
} else {
}
}
}
int i;
buf[i] = ' ';
buf[i++] = '^';
buf[i] = 0;
}
}
/**
* __xmlRaiseError:
* @schannel: the structured callback channel
* @channel: the old callback channel
* @data: the callback data
* @ctx: the parser context or NULL
* @ctx: the parser context or NULL
* @domain: the domain for the error
* @code: the code for the error
* @level: the xmlErrorLevel for the error
* @file: the file source of the error (or NULL)
* @line: the line of the error or 0 if N/A
* @str1: extra string info
* @str2: extra string info
* @str3: extra string info
* @int1: extra int info
* @col: column number of the error or 0 if N/A
* @...: extra parameters for the message display
*
* Update the appropriate global or contextual error structure,
* then forward the error message down the parser or generic
* error callback handler
*/
void XMLCDECL
const char *msg, ...)
{
return;
}
/*
* Check if structured error handler set
*/
/*
* if user has defined handler, change data ptr to user's choice
*/
}
if ((domain == XML_FROM_VALID) &&
((channel == xmlParserValidityError) ||
(channel == xmlParserValidityWarning))) {
}
if (code == XML_ERR_OK)
return;
/*
* Formatting the message
*/
} else {
}
/*
* specific processing if a parser context is provided
*/
}
}
}
int i;
/* file = (const char *) node->doc->URL; */
}
for (i = 0;
i++)
}
/*
* Save the information about the error
*/
#ifdef LIBXML_XINCLUDE_ENABLED
/*
* We check if the error is within an XInclude section and,
* if so, attempt to print out the href of the XInclude instead
* of the usual "base" (doc->URL) for the node (bug 152623).
*/
int inclcount = 0;
else {
if (--inclcount < 0)
break;
inclcount++;
}
}
} else {
}
} else
#endif
}
}
if (to != &xmlLastError)
/*
* Find the callback channel if channel param is NULL
*/
if (level == XML_ERR_WARNING)
else
if (xmlStructuredError != NULL)
else
if (!data) {
}
}
return;
}
return;
if ((channel == xmlParserError) ||
(channel == xmlParserWarning) ||
(channel == xmlParserValidityError) ||
else
}
/**
* __xmlSimpleError:
* @domain: where the error comes from
* @code: the error code
* @node: the context node
* @extra: extra informations
*
* Handle an out of memory condition
*/
void
{
if (code == XML_ERR_NO_MEMORY) {
if (extra)
"Memory allocation failed : %s\n", extra);
else
} else {
}
}
/**
* xmlParserError:
* @ctx: an XML parser context
* @...: extra parameters for the message display
*
* Display and format an error messages, gives file, line, position and
* extra parameters.
*/
void XMLCDECL
{
char * str;
}
}
}
}
}
/**
* xmlParserWarning:
* @ctx: an XML parser context
* @...: extra parameters for the message display
*
* Display and format a warning messages, gives file, line, position and
* extra parameters.
*/
void XMLCDECL
{
char * str;
}
}
}
}
}
/************************************************************************
* *
* Handling of validation errors *
* *
************************************************************************/
/**
* xmlParserValidityError:
* @ctx: an XML parser context
* @...: extra parameters for the message display
*
* Display and format an validity error messages, gives file,
* line, position and extra parameters.
*/
void XMLCDECL
{
char * str;
static int had_info = 0;
if (had_info == 0) {
}
}
had_info = 0;
} else {
had_info = 1;
}
}
}
/**
* xmlParserValidityWarning:
* @ctx: an XML parser context
* @...: extra parameters for the message display
*
* Display and format a validity warning messages, gives file, line,
* position and extra parameters.
*/
void XMLCDECL
{
char * str;
}
}
}
/************************************************************************
* *
* Extended Error Handling *
* *
************************************************************************/
/**
* xmlGetLastError:
*
* Get the last global error registered. This is per thread if compiled
* with thread support.
*
* Returns NULL if no error occured or a pointer to the error
*/
xmlGetLastError(void)
{
return (NULL);
return (&xmlLastError);
}
/**
* xmlResetError:
* @err: pointer to the error.
*
* Cleanup the error.
*/
void
{
return;
return;
}
/**
* xmlResetLastError:
*
* Cleanup the last global error registered. For parsing error
* this does not change the well-formedness result.
*/
void
xmlResetLastError(void)
{
return;
}
/**
* xmlCtxtGetLastError:
* @ctx: an XML parser context
*
* Get the last parsing error registered.
*
* Returns NULL if no error occured or a pointer to the error
*/
xmlCtxtGetLastError(void *ctx)
{
return (NULL);
return (NULL);
}
/**
* xmlCtxtResetLastError:
* @ctx: an XML parser context
*
* Cleanup the last global error registered. For parsing error
* this does not change the well-formedness result.
*/
void
xmlCtxtResetLastError(void *ctx)
{
return;
return;
}
/**
* xmlCopyError:
* @from: a source error
* @to: a target error
*
* Save the original error to the new place.
*
* Returns 0 in case of success and -1 in case of error.
*/
int
return(-1);
return 0;
}
#define bottom_error
#include "elfgcchack.h"