Blame error.c

Packit 423ecb
/*
Packit 423ecb
 * error.c: module displaying/handling XML parser errors
Packit 423ecb
 *
Packit 423ecb
 * See Copyright for the status of this software.
Packit 423ecb
 *
Packit 423ecb
 * Daniel Veillard <daniel@veillard.com>
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
#define IN_LIBXML
Packit 423ecb
#include "libxml.h"
Packit 423ecb
Packit 423ecb
#include <string.h>
Packit 423ecb
#include <stdarg.h>
Packit 423ecb
#include <libxml/parser.h>
Packit 423ecb
#include <libxml/xmlerror.h>
Packit 423ecb
#include <libxml/xmlmemory.h>
Packit 423ecb
#include <libxml/globals.h>
Packit 423ecb
Packit 423ecb
void XMLCDECL xmlGenericErrorDefaultFunc	(void *ctx ATTRIBUTE_UNUSED,
Packit 423ecb
				 const char *msg,
Packit 423ecb
				 ...) LIBXML_ATTR_FORMAT(2,3);
Packit 423ecb
Packit 423ecb
#define XML_GET_VAR_STR(msg, str) {				\
Packit 423ecb
    int       size, prev_size = -1;				\
Packit 423ecb
    int       chars;						\
Packit 423ecb
    char      *larger;						\
Packit 423ecb
    va_list   ap;						\
Packit 423ecb
								\
Packit 423ecb
    str = (char *) xmlMalloc(150);				\
Packit 423ecb
    if (str != NULL) {						\
Packit 423ecb
								\
Packit 423ecb
    size = 150;							\
Packit 423ecb
								\
Packit 423ecb
    while (size < 64000) {					\
Packit 423ecb
	va_start(ap, msg);					\
Packit 423ecb
	chars = vsnprintf(str, size, msg, ap);			\
Packit 423ecb
	va_end(ap);						\
Packit 423ecb
	if ((chars > -1) && (chars < size)) {			\
Packit 423ecb
	    if (prev_size == chars) {				\
Packit 423ecb
		break;						\
Packit 423ecb
	    } else {						\
Packit 423ecb
		prev_size = chars;				\
Packit 423ecb
	    }							\
Packit 423ecb
	}							\
Packit 423ecb
	if (chars > -1)						\
Packit 423ecb
	    size += chars + 1;					\
Packit 423ecb
	else							\
Packit 423ecb
	    size += 100;					\
Packit 423ecb
	if ((larger = (char *) xmlRealloc(str, size)) == NULL) {\
Packit 423ecb
	    break;						\
Packit 423ecb
	}							\
Packit 423ecb
	str = larger;						\
Packit 423ecb
    }}								\
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/************************************************************************
Packit 423ecb
 *									*
Packit 423ecb
 *			Handling of out of context errors		*
Packit 423ecb
 *									*
Packit 423ecb
 ************************************************************************/
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlGenericErrorDefaultFunc:
Packit 423ecb
 * @ctx:  an error context
Packit 423ecb
 * @msg:  the message to display/transmit
Packit 423ecb
 * @...:  extra parameters for the message display
Packit 423ecb
 *
Packit 423ecb
 * Default handler for out of context error messages.
Packit 423ecb
 */
Packit 423ecb
void XMLCDECL
Packit 423ecb
xmlGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
Packit 423ecb
    va_list args;
Packit 423ecb
Packit 423ecb
    if (xmlGenericErrorContext == NULL)
Packit 423ecb
	xmlGenericErrorContext = (void *) stderr;
Packit 423ecb
Packit 423ecb
    va_start(args, msg);
Packit 423ecb
    vfprintf((FILE *)xmlGenericErrorContext, msg, args);
Packit 423ecb
    va_end(args);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * initGenericErrorDefaultFunc:
Packit 423ecb
 * @handler:  the handler
Packit 423ecb
 *
Packit 423ecb
 * Set or reset (if NULL) the default handler for generic errors
Packit 423ecb
 * to the builtin error function.
Packit 423ecb
 */
Packit 423ecb
void
Packit 423ecb
initGenericErrorDefaultFunc(xmlGenericErrorFunc * handler)
Packit 423ecb
{
Packit 423ecb
    if (handler == NULL)
Packit 423ecb
        xmlGenericError = xmlGenericErrorDefaultFunc;
Packit 423ecb
    else
Packit 423ecb
        xmlGenericError = (*handler);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlSetGenericErrorFunc:
Packit 423ecb
 * @ctx:  the new error handling context
Packit 423ecb
 * @handler:  the new handler function
Packit 423ecb
 *
Packit 423ecb
 * Function to reset the handler and the error context for out of
Packit 423ecb
 * context error messages.
Packit 423ecb
 * This simply means that @handler will be called for subsequent
Packit 423ecb
 * error messages while not parsing nor validating. And @ctx will
Packit 423ecb
 * be passed as first argument to @handler
Packit 423ecb
 * One can simply force messages to be emitted to another FILE * than
Packit 423ecb
 * stderr by setting @ctx to this file handle and @handler to NULL.
Packit 423ecb
 * For multi-threaded applications, this must be set separately for each thread.
Packit 423ecb
 */
Packit 423ecb
void
Packit 423ecb
xmlSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
Packit 423ecb
    xmlGenericErrorContext = ctx;
Packit 423ecb
    if (handler != NULL)
Packit 423ecb
	xmlGenericError = handler;
Packit 423ecb
    else
Packit 423ecb
	xmlGenericError = xmlGenericErrorDefaultFunc;
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlSetStructuredErrorFunc:
Packit 423ecb
 * @ctx:  the new error handling context
Packit 423ecb
 * @handler:  the new handler function
Packit 423ecb
 *
Packit 423ecb
 * Function to reset the handler and the error context for out of
Packit 423ecb
 * context structured error messages.
Packit 423ecb
 * This simply means that @handler will be called for subsequent
Packit 423ecb
 * error messages while not parsing nor validating. And @ctx will
Packit 423ecb
 * be passed as first argument to @handler
Packit 423ecb
 * For multi-threaded applications, this must be set separately for each thread.
Packit 423ecb
 */
Packit 423ecb
void
Packit 423ecb
xmlSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
Packit 423ecb
    xmlStructuredErrorContext = ctx;
Packit 423ecb
    xmlStructuredError = handler;
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/************************************************************************
Packit 423ecb
 *									*
Packit 423ecb
 *			Handling of parsing errors			*
Packit 423ecb
 *									*
Packit 423ecb
 ************************************************************************/
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlParserPrintFileInfo:
Packit 423ecb
 * @input:  an xmlParserInputPtr input
Packit 423ecb
 *
Packit 423ecb
 * Displays the associated file and line informations for the current input
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
void
Packit 423ecb
xmlParserPrintFileInfo(xmlParserInputPtr input) {
Packit 423ecb
    if (input != NULL) {
Packit 423ecb
	if (input->filename)
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		    "%s:%d: ", input->filename,
Packit 423ecb
		    input->line);
Packit 423ecb
	else
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext,
Packit 423ecb
		    "Entity: line %d: ", input->line);
Packit 423ecb
    }
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlParserPrintFileContext:
Packit 423ecb
 * @input:  an xmlParserInputPtr input
Packit 423ecb
 *
Packit 423ecb
 * Displays current context within the input content for error tracking
Packit 423ecb
 */
Packit 423ecb
Packit 423ecb
static void
Packit 423ecb
xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
Packit 423ecb
		xmlGenericErrorFunc channel, void *data ) {
Packit 423ecb
    const xmlChar *cur, *base;
Packit 423ecb
    unsigned int n, col;	/* GCC warns if signed, because compared with sizeof() */
Packit 423ecb
    xmlChar  content[81]; /* space for 80 chars + line terminator */
Packit 423ecb
    xmlChar *ctnt;
Packit 423ecb
Packit 423ecb
    if ((input == NULL) || (input->cur == NULL))
Packit 423ecb
        return;
Packit 423ecb
Packit 423ecb
    cur = input->cur;
Packit 423ecb
    base = input->base;
Packit 423ecb
    /* skip backwards over any end-of-lines */
Packit 423ecb
    while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) {
Packit 423ecb
	cur--;
Packit 423ecb
    }
Packit 423ecb
    n = 0;
Packit 423ecb
    /* search backwards for beginning-of-line (to max buff size) */
Packit 423ecb
    while ((n++ < (sizeof(content)-1)) && (cur > base) &&
Packit 423ecb
	   (*(cur) != '\n') && (*(cur) != '\r'))
Packit 423ecb
        cur--;
Packit 423ecb
    if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
Packit 423ecb
    /* calculate the error position in terms of the current position */
Packit 423ecb
    col = input->cur - cur;
Packit 423ecb
    /* search forward for end-of-line (to max buff size) */
Packit 423ecb
    n = 0;
Packit 423ecb
    ctnt = content;
Packit 423ecb
    /* copy selected text to our buffer */
Packit 423ecb
    while ((*cur != 0) && (*(cur) != '\n') &&
Packit 423ecb
	   (*(cur) != '\r') && (n < sizeof(content)-1)) {
Packit 423ecb
		*ctnt++ = *cur++;
Packit 423ecb
	n++;
Packit 423ecb
    }
Packit 423ecb
    *ctnt = 0;
Packit 423ecb
    /* print out the selected text */
Packit 423ecb
    channel(data ,"%s\n", content);
Packit 423ecb
    /* create blank line with problem pointer */
Packit 423ecb
    n = 0;
Packit 423ecb
    ctnt = content;
Packit 423ecb
    /* (leave buffer space for pointer + line terminator) */
Packit 423ecb
    while ((n
Packit 423ecb
	if (*(ctnt) != '\t')
Packit 423ecb
	    *(ctnt) = ' ';
Packit 423ecb
	ctnt++;
Packit 423ecb
    }
Packit 423ecb
    *ctnt++ = '^';
Packit 423ecb
    *ctnt = 0;
Packit 423ecb
    channel(data ,"%s\n", content);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlParserPrintFileContext:
Packit 423ecb
 * @input:  an xmlParserInputPtr input
Packit 423ecb
 *
Packit 423ecb
 * Displays current context within the input content for error tracking
Packit 423ecb
 */
Packit 423ecb
void
Packit 423ecb
xmlParserPrintFileContext(xmlParserInputPtr input) {
Packit 423ecb
   xmlParserPrintFileContextInternal(input, xmlGenericError,
Packit 423ecb
                                     xmlGenericErrorContext);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlReportError:
Packit 423ecb
 * @err: the error
Packit 423ecb
 * @ctx: the parser context or NULL
Packit 423ecb
 * @str: the formatted error message
Packit 423ecb
 *
Packit 423ecb
 * Report an erro with its context, replace the 4 old error/warning
Packit 423ecb
 * routines.
Packit 423ecb
 */
Packit 423ecb
static void
Packit 423ecb
xmlReportError(xmlErrorPtr err, xmlParserCtxtPtr ctxt, const char *str,
Packit 423ecb
               xmlGenericErrorFunc channel, void *data)
Packit 423ecb
{
Packit 423ecb
    char *file = NULL;
Packit 423ecb
    int line = 0;
Packit 423ecb
    int code = -1;
Packit 423ecb
    int domain;
Packit 423ecb
    const xmlChar *name = NULL;
Packit 423ecb
    xmlNodePtr node;
Packit 423ecb
    xmlErrorLevel level;
Packit 423ecb
    xmlParserInputPtr input = NULL;
Packit 423ecb
    xmlParserInputPtr cur = NULL;
Packit 423ecb
Packit 423ecb
    if (err == NULL)
Packit 423ecb
        return;
Packit 423ecb
Packit 423ecb
    if (channel == NULL) {
Packit 423ecb
	channel = xmlGenericError;
Packit 423ecb
	data = xmlGenericErrorContext;
Packit 423ecb
    }
Packit 423ecb
    file = err->file;
Packit 423ecb
    line = err->line;
Packit 423ecb
    code = err->code;
Packit 423ecb
    domain = err->domain;
Packit 423ecb
    level = err->level;
Packit 423ecb
    node = err->node;
Packit 423ecb
Packit 423ecb
    if (code == XML_ERR_OK)
Packit 423ecb
        return;
Packit 423ecb
Packit 423ecb
    if ((node != NULL) && (node->type == XML_ELEMENT_NODE))
Packit 423ecb
        name = node->name;
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * Maintain the compatibility with the legacy error handling
Packit 423ecb
     */
Packit 423ecb
    if (ctxt != NULL) {
Packit 423ecb
        input = ctxt->input;
Packit 423ecb
        if ((input != NULL) && (input->filename == NULL) &&
Packit 423ecb
            (ctxt->inputNr > 1)) {
Packit 423ecb
            cur = input;
Packit 423ecb
            input = ctxt->inputTab[ctxt->inputNr - 2];
Packit 423ecb
        }
Packit 423ecb
        if (input != NULL) {
Packit 423ecb
            if (input->filename)
Packit 423ecb
                channel(data, "%s:%d: ", input->filename, input->line);
Packit 423ecb
            else if ((line != 0) && (domain == XML_FROM_PARSER))
Packit 423ecb
                channel(data, "Entity: line %d: ", input->line);
Packit 423ecb
        }
Packit 423ecb
    } else {
Packit 423ecb
        if (file != NULL)
Packit 423ecb
            channel(data, "%s:%d: ", file, line);
Packit 423ecb
        else if ((line != 0) &&
Packit 423ecb
	         ((domain == XML_FROM_PARSER) || (domain == XML_FROM_SCHEMASV)||
Packit 423ecb
		  (domain == XML_FROM_SCHEMASP)||(domain == XML_FROM_DTD) ||
Packit 423ecb
		  (domain == XML_FROM_RELAXNGP)||(domain == XML_FROM_RELAXNGV)))
Packit 423ecb
            channel(data, "Entity: line %d: ", line);
Packit 423ecb
    }
Packit 423ecb
    if (name != NULL) {
Packit 423ecb
        channel(data, "element %s: ", name);
Packit 423ecb
    }
Packit 423ecb
    switch (domain) {
Packit 423ecb
        case XML_FROM_PARSER:
Packit 423ecb
            channel(data, "parser ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_NAMESPACE:
Packit 423ecb
            channel(data, "namespace ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_DTD:
Packit 423ecb
        case XML_FROM_VALID:
Packit 423ecb
            channel(data, "validity ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_HTML:
Packit 423ecb
            channel(data, "HTML parser ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_MEMORY:
Packit 423ecb
            channel(data, "memory ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_OUTPUT:
Packit 423ecb
            channel(data, "output ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_IO:
Packit 423ecb
            channel(data, "I/O ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_XINCLUDE:
Packit 423ecb
            channel(data, "XInclude ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_XPATH:
Packit 423ecb
            channel(data, "XPath ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_XPOINTER:
Packit 423ecb
            channel(data, "parser ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_REGEXP:
Packit 423ecb
            channel(data, "regexp ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_MODULE:
Packit 423ecb
            channel(data, "module ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_SCHEMASV:
Packit 423ecb
            channel(data, "Schemas validity ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_SCHEMASP:
Packit 423ecb
            channel(data, "Schemas parser ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_RELAXNGP:
Packit 423ecb
            channel(data, "Relax-NG parser ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_RELAXNGV:
Packit 423ecb
            channel(data, "Relax-NG validity ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_CATALOG:
Packit 423ecb
            channel(data, "Catalog ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_C14N:
Packit 423ecb
            channel(data, "C14N ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_XSLT:
Packit 423ecb
            channel(data, "XSLT ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_I18N:
Packit 423ecb
            channel(data, "encoding ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_SCHEMATRONV:
Packit 423ecb
            channel(data, "schematron ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_BUFFER:
Packit 423ecb
            channel(data, "internal buffer ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_FROM_URI:
Packit 423ecb
            channel(data, "URI ");
Packit 423ecb
            break;
Packit 423ecb
        default:
Packit 423ecb
            break;
Packit 423ecb
    }
Packit 423ecb
    switch (level) {
Packit 423ecb
        case XML_ERR_NONE:
Packit 423ecb
            channel(data, ": ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_ERR_WARNING:
Packit 423ecb
            channel(data, "warning : ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_ERR_ERROR:
Packit 423ecb
            channel(data, "error : ");
Packit 423ecb
            break;
Packit 423ecb
        case XML_ERR_FATAL:
Packit 423ecb
            channel(data, "error : ");
Packit 423ecb
            break;
Packit 423ecb
    }
Packit 423ecb
    if (str != NULL) {
Packit 423ecb
        int len;
Packit 423ecb
	len = xmlStrlen((const xmlChar *)str);
Packit 423ecb
	if ((len > 0) && (str[len - 1] != '\n'))
Packit 423ecb
	    channel(data, "%s\n", str);
Packit 423ecb
	else
Packit 423ecb
	    channel(data, "%s", str);
Packit 423ecb
    } else {
Packit 423ecb
        channel(data, "%s\n", "out of memory error");
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    if (ctxt != NULL) {
Packit 423ecb
        xmlParserPrintFileContextInternal(input, channel, data);
Packit 423ecb
        if (cur != NULL) {
Packit 423ecb
            if (cur->filename)
Packit 423ecb
                channel(data, "%s:%d: \n", cur->filename, cur->line);
Packit 423ecb
            else if ((line != 0) && (domain == XML_FROM_PARSER))
Packit 423ecb
                channel(data, "Entity: line %d: \n", cur->line);
Packit 423ecb
            xmlParserPrintFileContextInternal(cur, channel, data);
Packit 423ecb
        }
Packit 423ecb
    }
Packit 423ecb
    if ((domain == XML_FROM_XPATH) && (err->str1 != NULL) &&
Packit 423ecb
        (err->int1 < 100) &&
Packit 423ecb
	(err->int1 < xmlStrlen((const xmlChar *)err->str1))) {
Packit 423ecb
	xmlChar buf[150];
Packit 423ecb
	int i;
Packit 423ecb
Packit 423ecb
	channel(data, "%s\n", err->str1);
Packit 423ecb
	for (i=0;i < err->int1;i++)
Packit 423ecb
	     buf[i] = ' ';
Packit 423ecb
	buf[i++] = '^';
Packit 423ecb
	buf[i] = 0;
Packit 423ecb
	channel(data, "%s\n", buf);
Packit 423ecb
    }
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * __xmlRaiseError:
Packit 423ecb
 * @schannel: the structured callback channel
Packit 423ecb
 * @channel: the old callback channel
Packit 423ecb
 * @data: the callback data
Packit 423ecb
 * @ctx: the parser context or NULL
Packit 423ecb
 * @ctx: the parser context or NULL
Packit 423ecb
 * @domain: the domain for the error
Packit 423ecb
 * @code: the code for the error
Packit 423ecb
 * @level: the xmlErrorLevel for the error
Packit 423ecb
 * @file: the file source of the error (or NULL)
Packit 423ecb
 * @line: the line of the error or 0 if N/A
Packit 423ecb
 * @str1: extra string info
Packit 423ecb
 * @str2: extra string info
Packit 423ecb
 * @str3: extra string info
Packit 423ecb
 * @int1: extra int info
Packit 423ecb
 * @col: column number of the error or 0 if N/A
Packit 423ecb
 * @msg:  the message to display/transmit
Packit 423ecb
 * @...:  extra parameters for the message display
Packit 423ecb
 *
Packit 423ecb
 * Update the appropriate global or contextual error structure,
Packit 423ecb
 * then forward the error message down the parser or generic
Packit 423ecb
 * error callback handler
Packit 423ecb
 */
Packit 423ecb
void XMLCDECL
Packit 423ecb
__xmlRaiseError(xmlStructuredErrorFunc schannel,
Packit 423ecb
              xmlGenericErrorFunc channel, void *data, void *ctx,
Packit 423ecb
              void *nod, int domain, int code, xmlErrorLevel level,
Packit 423ecb
              const char *file, int line, const char *str1,
Packit 423ecb
              const char *str2, const char *str3, int int1, int col,
Packit 423ecb
	      const char *msg, ...)
Packit 423ecb
{
Packit 423ecb
    xmlParserCtxtPtr ctxt = NULL;
Packit 423ecb
    xmlNodePtr node = (xmlNodePtr) nod;
Packit 423ecb
    char *str = NULL;
Packit 423ecb
    xmlParserInputPtr input = NULL;
Packit 423ecb
    xmlErrorPtr to = &xmlLastError;
Packit 423ecb
    xmlNodePtr baseptr = NULL;
Packit 423ecb
Packit 423ecb
    if (code == XML_ERR_OK)
Packit 423ecb
        return;
Packit 423ecb
    if ((xmlGetWarningsDefaultValue == 0) && (level == XML_ERR_WARNING))
Packit 423ecb
        return;
Packit 423ecb
    if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) ||
Packit 423ecb
        (domain == XML_FROM_DTD) || (domain == XML_FROM_NAMESPACE) ||
Packit 423ecb
	(domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) {
Packit 423ecb
	ctxt = (xmlParserCtxtPtr) ctx;
Packit 423ecb
	if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
Packit 423ecb
	    (ctxt->sax->initialized == XML_SAX2_MAGIC) &&
Packit 423ecb
	    (ctxt->sax->serror != NULL)) {
Packit 423ecb
	    schannel = ctxt->sax->serror;
Packit 423ecb
	    data = ctxt->userData;
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
    /*
Packit 423ecb
     * Check if structured error handler set
Packit 423ecb
     */
Packit 423ecb
    if (schannel == NULL) {
Packit 423ecb
	schannel = xmlStructuredError;
Packit 423ecb
	/*
Packit 423ecb
	 * if user has defined handler, change data ptr to user's choice
Packit 423ecb
	 */
Packit 423ecb
	if (schannel != NULL)
Packit 423ecb
	    data = xmlStructuredErrorContext;
Packit 423ecb
    }
Packit 423ecb
    /*
Packit 423ecb
     * Formatting the message
Packit 423ecb
     */
Packit 423ecb
    if (msg == NULL) {
Packit 423ecb
        str = (char *) xmlStrdup(BAD_CAST "No error message provided");
Packit 423ecb
    } else {
Packit 423ecb
        XML_GET_VAR_STR(msg, str);
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * specific processing if a parser context is provided
Packit 423ecb
     */
Packit 423ecb
    if (ctxt != NULL) {
Packit 423ecb
        if (file == NULL) {
Packit 423ecb
            input = ctxt->input;
Packit 423ecb
            if ((input != NULL) && (input->filename == NULL) &&
Packit 423ecb
                (ctxt->inputNr > 1)) {
Packit 423ecb
                input = ctxt->inputTab[ctxt->inputNr - 2];
Packit 423ecb
            }
Packit 423ecb
            if (input != NULL) {
Packit 423ecb
                file = input->filename;
Packit 423ecb
                line = input->line;
Packit 423ecb
                col = input->col;
Packit 423ecb
            }
Packit 423ecb
        }
Packit 423ecb
        to = &ctxt->lastError;
Packit 423ecb
    } else if ((node != NULL) && (file == NULL)) {
Packit 423ecb
	int i;
Packit 423ecb
Packit 423ecb
	if ((node->doc != NULL) && (node->doc->URL != NULL)) {
Packit 423ecb
	    baseptr = node;
Packit 423ecb
/*	    file = (const char *) node->doc->URL; */
Packit 423ecb
	}
Packit 423ecb
	for (i = 0;
Packit 423ecb
	     ((i < 10) && (node != NULL) && (node->type != XML_ELEMENT_NODE));
Packit 423ecb
	     i++)
Packit 423ecb
	     node = node->parent;
Packit 423ecb
        if ((baseptr == NULL) && (node != NULL) &&
Packit 423ecb
	    (node->doc != NULL) && (node->doc->URL != NULL))
Packit 423ecb
	    baseptr = node;
Packit 423ecb
Packit 423ecb
	if ((node != NULL) && (node->type == XML_ELEMENT_NODE))
Packit 423ecb
	    line = node->line;
Packit 423ecb
	if ((line == 0) || (line == 65535))
Packit 423ecb
	    line = xmlGetLineNo(node);
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * Save the information about the error
Packit 423ecb
     */
Packit 423ecb
    xmlResetError(to);
Packit 423ecb
    to->domain = domain;
Packit 423ecb
    to->code = code;
Packit 423ecb
    to->message = str;
Packit 423ecb
    to->level = level;
Packit 423ecb
    if (file != NULL)
Packit 423ecb
        to->file = (char *) xmlStrdup((const xmlChar *) file);
Packit 423ecb
    else if (baseptr != NULL) {
Packit 423ecb
#ifdef LIBXML_XINCLUDE_ENABLED
Packit 423ecb
	/*
Packit 423ecb
	 * We check if the error is within an XInclude section and,
Packit 423ecb
	 * if so, attempt to print out the href of the XInclude instead
Packit 423ecb
	 * of the usual "base" (doc->URL) for the node (bug 152623).
Packit 423ecb
	 */
Packit 423ecb
        xmlNodePtr prev = baseptr;
Packit 423ecb
	int inclcount = 0;
Packit 423ecb
	while (prev != NULL) {
Packit 423ecb
	    if (prev->prev == NULL)
Packit 423ecb
	        prev = prev->parent;
Packit 423ecb
	    else {
Packit 423ecb
	        prev = prev->prev;
Packit 423ecb
		if (prev->type == XML_XINCLUDE_START) {
Packit 423ecb
		    if (--inclcount < 0)
Packit 423ecb
		        break;
Packit 423ecb
		} else if (prev->type == XML_XINCLUDE_END)
Packit 423ecb
		    inclcount++;
Packit 423ecb
	    }
Packit 423ecb
	}
Packit 423ecb
	if (prev != NULL) {
Packit 423ecb
	    if (prev->type == XML_XINCLUDE_START) {
Packit 423ecb
		prev->type = XML_ELEMENT_NODE;
Packit 423ecb
		to->file = (char *) xmlGetProp(prev, BAD_CAST "href");
Packit 423ecb
		prev->type = XML_XINCLUDE_START;
Packit 423ecb
	    } else {
Packit 423ecb
		to->file = (char *) xmlGetProp(prev, BAD_CAST "href");
Packit 423ecb
	    }
Packit 423ecb
	} else
Packit 423ecb
#endif
Packit 423ecb
	    to->file = (char *) xmlStrdup(baseptr->doc->URL);
Packit 423ecb
	if ((to->file == NULL) && (node != NULL) && (node->doc != NULL)) {
Packit 423ecb
	    to->file = (char *) xmlStrdup(node->doc->URL);
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
    to->line = line;
Packit 423ecb
    if (str1 != NULL)
Packit 423ecb
        to->str1 = (char *) xmlStrdup((const xmlChar *) str1);
Packit 423ecb
    if (str2 != NULL)
Packit 423ecb
        to->str2 = (char *) xmlStrdup((const xmlChar *) str2);
Packit 423ecb
    if (str3 != NULL)
Packit 423ecb
        to->str3 = (char *) xmlStrdup((const xmlChar *) str3);
Packit 423ecb
    to->int1 = int1;
Packit 423ecb
    to->int2 = col;
Packit 423ecb
    to->node = node;
Packit 423ecb
    to->ctxt = ctx;
Packit 423ecb
Packit 423ecb
    if (to != &xmlLastError)
Packit 423ecb
        xmlCopyError(to,&xmlLastError);
Packit 423ecb
Packit 423ecb
    if (schannel != NULL) {
Packit 423ecb
	schannel(data, to);
Packit 423ecb
	return;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    /*
Packit 423ecb
     * Find the callback channel if channel param is NULL
Packit 423ecb
     */
Packit 423ecb
    if ((ctxt != NULL) && (channel == NULL) &&
Packit 423ecb
        (xmlStructuredError == NULL) && (ctxt->sax != NULL)) {
Packit 423ecb
        if (level == XML_ERR_WARNING)
Packit 423ecb
	    channel = ctxt->sax->warning;
Packit 423ecb
        else
Packit 423ecb
	    channel = ctxt->sax->error;
Packit 423ecb
	data = ctxt->userData;
Packit 423ecb
    } else if (channel == NULL) {
Packit 423ecb
	channel = xmlGenericError;
Packit 423ecb
	if (ctxt != NULL) {
Packit 423ecb
	    data = ctxt;
Packit 423ecb
	} else {
Packit 423ecb
	    data = xmlGenericErrorContext;
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
    if (channel == NULL)
Packit 423ecb
        return;
Packit 423ecb
Packit 423ecb
    if ((channel == xmlParserError) ||
Packit 423ecb
        (channel == xmlParserWarning) ||
Packit 423ecb
	(channel == xmlParserValidityError) ||
Packit 423ecb
	(channel == xmlParserValidityWarning))
Packit 423ecb
	xmlReportError(to, ctxt, str, NULL, NULL);
Packit 423ecb
    else if ((channel == (xmlGenericErrorFunc) fprintf) ||
Packit 423ecb
             (channel == xmlGenericErrorDefaultFunc))
Packit 423ecb
	xmlReportError(to, ctxt, str, channel, data);
Packit 423ecb
    else
Packit 423ecb
	channel(data, "%s", str);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * __xmlSimpleError:
Packit 423ecb
 * @domain: where the error comes from
Packit 423ecb
 * @code: the error code
Packit 423ecb
 * @node: the context node
Packit 423ecb
 * @extra:  extra informations
Packit 423ecb
 *
Packit 423ecb
 * Handle an out of memory condition
Packit 423ecb
 */
Packit 423ecb
void
Packit 423ecb
__xmlSimpleError(int domain, int code, xmlNodePtr node,
Packit 423ecb
                 const char *msg, const char *extra)
Packit 423ecb
{
Packit 423ecb
Packit 423ecb
    if (code == XML_ERR_NO_MEMORY) {
Packit 423ecb
	if (extra)
Packit 423ecb
	    __xmlRaiseError(NULL, NULL, NULL, NULL, node, domain,
Packit 423ecb
			    XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra,
Packit 423ecb
			    NULL, NULL, 0, 0,
Packit 423ecb
			    "Memory allocation failed : %s\n", extra);
Packit 423ecb
	else
Packit 423ecb
	    __xmlRaiseError(NULL, NULL, NULL, NULL, node, domain,
Packit 423ecb
			    XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, NULL,
Packit 423ecb
			    NULL, NULL, 0, 0, "Memory allocation failed\n");
Packit 423ecb
    } else {
Packit 423ecb
	__xmlRaiseError(NULL, NULL, NULL, NULL, node, domain,
Packit 423ecb
			code, XML_ERR_ERROR, NULL, 0, extra,
Packit 423ecb
			NULL, NULL, 0, 0, msg, extra);
Packit 423ecb
    }
Packit 423ecb
}
Packit 423ecb
/**
Packit 423ecb
 * xmlParserError:
Packit 423ecb
 * @ctx:  an XML parser context
Packit 423ecb
 * @msg:  the message to display/transmit
Packit 423ecb
 * @...:  extra parameters for the message display
Packit 423ecb
 *
Packit 423ecb
 * Display and format an error messages, gives file, line, position and
Packit 423ecb
 * extra parameters.
Packit 423ecb
 */
Packit 423ecb
void XMLCDECL
Packit 423ecb
xmlParserError(void *ctx, const char *msg, ...)
Packit 423ecb
{
Packit 423ecb
    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Packit 423ecb
    xmlParserInputPtr input = NULL;
Packit 423ecb
    xmlParserInputPtr cur = NULL;
Packit 423ecb
    char * str;
Packit 423ecb
Packit 423ecb
    if (ctxt != NULL) {
Packit 423ecb
	input = ctxt->input;
Packit 423ecb
	if ((input != NULL) && (input->filename == NULL) &&
Packit 423ecb
	    (ctxt->inputNr > 1)) {
Packit 423ecb
	    cur = input;
Packit 423ecb
	    input = ctxt->inputTab[ctxt->inputNr - 2];
Packit 423ecb
	}
Packit 423ecb
	xmlParserPrintFileInfo(input);
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    xmlGenericError(xmlGenericErrorContext, "error: ");
Packit 423ecb
    XML_GET_VAR_STR(msg, str);
Packit 423ecb
    xmlGenericError(xmlGenericErrorContext, "%s", str);
Packit 423ecb
    if (str != NULL)
Packit 423ecb
	xmlFree(str);
Packit 423ecb
Packit 423ecb
    if (ctxt != NULL) {
Packit 423ecb
	xmlParserPrintFileContext(input);
Packit 423ecb
	if (cur != NULL) {
Packit 423ecb
	    xmlParserPrintFileInfo(cur);
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext, "\n");
Packit 423ecb
	    xmlParserPrintFileContext(cur);
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlParserWarning:
Packit 423ecb
 * @ctx:  an XML parser context
Packit 423ecb
 * @msg:  the message to display/transmit
Packit 423ecb
 * @...:  extra parameters for the message display
Packit 423ecb
 *
Packit 423ecb
 * Display and format a warning messages, gives file, line, position and
Packit 423ecb
 * extra parameters.
Packit 423ecb
 */
Packit 423ecb
void XMLCDECL
Packit 423ecb
xmlParserWarning(void *ctx, const char *msg, ...)
Packit 423ecb
{
Packit 423ecb
    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Packit 423ecb
    xmlParserInputPtr input = NULL;
Packit 423ecb
    xmlParserInputPtr cur = NULL;
Packit 423ecb
    char * str;
Packit 423ecb
Packit 423ecb
    if (ctxt != NULL) {
Packit 423ecb
	input = ctxt->input;
Packit 423ecb
	if ((input != NULL) && (input->filename == NULL) &&
Packit 423ecb
	    (ctxt->inputNr > 1)) {
Packit 423ecb
	    cur = input;
Packit 423ecb
	    input = ctxt->inputTab[ctxt->inputNr - 2];
Packit 423ecb
	}
Packit 423ecb
	xmlParserPrintFileInfo(input);
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    xmlGenericError(xmlGenericErrorContext, "warning: ");
Packit 423ecb
    XML_GET_VAR_STR(msg, str);
Packit 423ecb
    xmlGenericError(xmlGenericErrorContext, "%s", str);
Packit 423ecb
    if (str != NULL)
Packit 423ecb
	xmlFree(str);
Packit 423ecb
Packit 423ecb
    if (ctxt != NULL) {
Packit 423ecb
	xmlParserPrintFileContext(input);
Packit 423ecb
	if (cur != NULL) {
Packit 423ecb
	    xmlParserPrintFileInfo(cur);
Packit 423ecb
	    xmlGenericError(xmlGenericErrorContext, "\n");
Packit 423ecb
	    xmlParserPrintFileContext(cur);
Packit 423ecb
	}
Packit 423ecb
    }
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/************************************************************************
Packit 423ecb
 *									*
Packit 423ecb
 *			Handling of validation errors			*
Packit 423ecb
 *									*
Packit 423ecb
 ************************************************************************/
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlParserValidityError:
Packit 423ecb
 * @ctx:  an XML parser context
Packit 423ecb
 * @msg:  the message to display/transmit
Packit 423ecb
 * @...:  extra parameters for the message display
Packit 423ecb
 *
Packit 423ecb
 * Display and format an validity error messages, gives file,
Packit 423ecb
 * line, position and extra parameters.
Packit 423ecb
 */
Packit 423ecb
void XMLCDECL
Packit 423ecb
xmlParserValidityError(void *ctx, const char *msg, ...)
Packit 423ecb
{
Packit 423ecb
    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Packit 423ecb
    xmlParserInputPtr input = NULL;
Packit 423ecb
    char * str;
Packit 423ecb
    int len = xmlStrlen((const xmlChar *) msg);
Packit 423ecb
    static int had_info = 0;
Packit 423ecb
Packit 423ecb
    if ((len > 1) && (msg[len - 2] != ':')) {
Packit 423ecb
	if (ctxt != NULL) {
Packit 423ecb
	    input = ctxt->input;
Packit 423ecb
	    if ((input->filename == NULL) && (ctxt->inputNr > 1))
Packit 423ecb
		input = ctxt->inputTab[ctxt->inputNr - 2];
Packit 423ecb
Packit 423ecb
	    if (had_info == 0) {
Packit 423ecb
		xmlParserPrintFileInfo(input);
Packit 423ecb
	    }
Packit 423ecb
	}
Packit 423ecb
	xmlGenericError(xmlGenericErrorContext, "validity error: ");
Packit 423ecb
	had_info = 0;
Packit 423ecb
    } else {
Packit 423ecb
	had_info = 1;
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    XML_GET_VAR_STR(msg, str);
Packit 423ecb
    xmlGenericError(xmlGenericErrorContext, "%s", str);
Packit 423ecb
    if (str != NULL)
Packit 423ecb
	xmlFree(str);
Packit 423ecb
Packit 423ecb
    if ((ctxt != NULL) && (input != NULL)) {
Packit 423ecb
	xmlParserPrintFileContext(input);
Packit 423ecb
    }
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlParserValidityWarning:
Packit 423ecb
 * @ctx:  an XML parser context
Packit 423ecb
 * @msg:  the message to display/transmit
Packit 423ecb
 * @...:  extra parameters for the message display
Packit 423ecb
 *
Packit 423ecb
 * Display and format a validity warning messages, gives file, line,
Packit 423ecb
 * position and extra parameters.
Packit 423ecb
 */
Packit 423ecb
void XMLCDECL
Packit 423ecb
xmlParserValidityWarning(void *ctx, const char *msg, ...)
Packit 423ecb
{
Packit 423ecb
    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Packit 423ecb
    xmlParserInputPtr input = NULL;
Packit 423ecb
    char * str;
Packit 423ecb
    int len = xmlStrlen((const xmlChar *) msg);
Packit 423ecb
Packit 423ecb
    if ((ctxt != NULL) && (len != 0) && (msg[len - 1] != ':')) {
Packit 423ecb
	input = ctxt->input;
Packit 423ecb
	if ((input->filename == NULL) && (ctxt->inputNr > 1))
Packit 423ecb
	    input = ctxt->inputTab[ctxt->inputNr - 2];
Packit 423ecb
Packit 423ecb
	xmlParserPrintFileInfo(input);
Packit 423ecb
    }
Packit 423ecb
Packit 423ecb
    xmlGenericError(xmlGenericErrorContext, "validity warning: ");
Packit 423ecb
    XML_GET_VAR_STR(msg, str);
Packit 423ecb
    xmlGenericError(xmlGenericErrorContext, "%s", str);
Packit 423ecb
    if (str != NULL)
Packit 423ecb
	xmlFree(str);
Packit 423ecb
Packit 423ecb
    if (ctxt != NULL) {
Packit 423ecb
	xmlParserPrintFileContext(input);
Packit 423ecb
    }
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
Packit 423ecb
/************************************************************************
Packit 423ecb
 *									*
Packit 423ecb
 *			Extended Error Handling				*
Packit 423ecb
 *									*
Packit 423ecb
 ************************************************************************/
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlGetLastError:
Packit 423ecb
 *
Packit 423ecb
 * Get the last global error registered. This is per thread if compiled
Packit 423ecb
 * with thread support.
Packit 423ecb
 *
Packit 423ecb
 * Returns NULL if no error occurred or a pointer to the error
Packit 423ecb
 */
Packit 423ecb
xmlErrorPtr
Packit 423ecb
xmlGetLastError(void)
Packit 423ecb
{
Packit 423ecb
    if (xmlLastError.code == XML_ERR_OK)
Packit 423ecb
        return (NULL);
Packit 423ecb
    return (&xmlLastError);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlResetError:
Packit 423ecb
 * @err: pointer to the error.
Packit 423ecb
 *
Packit 423ecb
 * Cleanup the error.
Packit 423ecb
 */
Packit 423ecb
void
Packit 423ecb
xmlResetError(xmlErrorPtr err)
Packit 423ecb
{
Packit 423ecb
    if (err == NULL)
Packit 423ecb
        return;
Packit 423ecb
    if (err->code == XML_ERR_OK)
Packit 423ecb
        return;
Packit 423ecb
    if (err->message != NULL)
Packit 423ecb
        xmlFree(err->message);
Packit 423ecb
    if (err->file != NULL)
Packit 423ecb
        xmlFree(err->file);
Packit 423ecb
    if (err->str1 != NULL)
Packit 423ecb
        xmlFree(err->str1);
Packit 423ecb
    if (err->str2 != NULL)
Packit 423ecb
        xmlFree(err->str2);
Packit 423ecb
    if (err->str3 != NULL)
Packit 423ecb
        xmlFree(err->str3);
Packit 423ecb
    memset(err, 0, sizeof(xmlError));
Packit 423ecb
    err->code = XML_ERR_OK;
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlResetLastError:
Packit 423ecb
 *
Packit 423ecb
 * Cleanup the last global error registered. For parsing error
Packit 423ecb
 * this does not change the well-formedness result.
Packit 423ecb
 */
Packit 423ecb
void
Packit 423ecb
xmlResetLastError(void)
Packit 423ecb
{
Packit 423ecb
    if (xmlLastError.code == XML_ERR_OK)
Packit 423ecb
        return;
Packit 423ecb
    xmlResetError(&xmlLastError);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlCtxtGetLastError:
Packit 423ecb
 * @ctx:  an XML parser context
Packit 423ecb
 *
Packit 423ecb
 * Get the last parsing error registered.
Packit 423ecb
 *
Packit 423ecb
 * Returns NULL if no error occurred or a pointer to the error
Packit 423ecb
 */
Packit 423ecb
xmlErrorPtr
Packit 423ecb
xmlCtxtGetLastError(void *ctx)
Packit 423ecb
{
Packit 423ecb
    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Packit 423ecb
Packit 423ecb
    if (ctxt == NULL)
Packit 423ecb
        return (NULL);
Packit 423ecb
    if (ctxt->lastError.code == XML_ERR_OK)
Packit 423ecb
        return (NULL);
Packit 423ecb
    return (&ctxt->lastError);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlCtxtResetLastError:
Packit 423ecb
 * @ctx:  an XML parser context
Packit 423ecb
 *
Packit 423ecb
 * Cleanup the last global error registered. For parsing error
Packit 423ecb
 * this does not change the well-formedness result.
Packit 423ecb
 */
Packit 423ecb
void
Packit 423ecb
xmlCtxtResetLastError(void *ctx)
Packit 423ecb
{
Packit 423ecb
    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
Packit 423ecb
Packit 423ecb
    if (ctxt == NULL)
Packit 423ecb
        return;
Packit 423ecb
    ctxt->errNo = XML_ERR_OK;
Packit 423ecb
    if (ctxt->lastError.code == XML_ERR_OK)
Packit 423ecb
        return;
Packit 423ecb
    xmlResetError(&ctxt->lastError);
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
/**
Packit 423ecb
 * xmlCopyError:
Packit 423ecb
 * @from:  a source error
Packit 423ecb
 * @to:  a target error
Packit 423ecb
 *
Packit 423ecb
 * Save the original error to the new place.
Packit 423ecb
 *
Packit 423ecb
 * Returns 0 in case of success and -1 in case of error.
Packit 423ecb
 */
Packit 423ecb
int
Packit 423ecb
xmlCopyError(xmlErrorPtr from, xmlErrorPtr to) {
Packit 423ecb
    char *message, *file, *str1, *str2, *str3;
Packit 423ecb
Packit 423ecb
    if ((from == NULL) || (to == NULL))
Packit 423ecb
        return(-1);
Packit 423ecb
Packit 423ecb
    message = (char *) xmlStrdup((xmlChar *) from->message);
Packit 423ecb
    file = (char *) xmlStrdup ((xmlChar *) from->file);
Packit 423ecb
    str1 = (char *) xmlStrdup ((xmlChar *) from->str1);
Packit 423ecb
    str2 = (char *) xmlStrdup ((xmlChar *) from->str2);
Packit 423ecb
    str3 = (char *) xmlStrdup ((xmlChar *) from->str3);
Packit 423ecb
Packit 423ecb
    if (to->message != NULL)
Packit 423ecb
        xmlFree(to->message);
Packit 423ecb
    if (to->file != NULL)
Packit 423ecb
        xmlFree(to->file);
Packit 423ecb
    if (to->str1 != NULL)
Packit 423ecb
        xmlFree(to->str1);
Packit 423ecb
    if (to->str2 != NULL)
Packit 423ecb
        xmlFree(to->str2);
Packit 423ecb
    if (to->str3 != NULL)
Packit 423ecb
        xmlFree(to->str3);
Packit 423ecb
    to->domain = from->domain;
Packit 423ecb
    to->code = from->code;
Packit 423ecb
    to->level = from->level;
Packit 423ecb
    to->line = from->line;
Packit 423ecb
    to->node = from->node;
Packit 423ecb
    to->int1 = from->int1;
Packit 423ecb
    to->int2 = from->int2;
Packit 423ecb
    to->node = from->node;
Packit 423ecb
    to->ctxt = from->ctxt;
Packit 423ecb
    to->message = message;
Packit 423ecb
    to->file = file;
Packit 423ecb
    to->str1 = str1;
Packit 423ecb
    to->str2 = str2;
Packit 423ecb
    to->str3 = str3;
Packit 423ecb
Packit 423ecb
    return 0;
Packit 423ecb
}
Packit 423ecb
Packit 423ecb
#define bottom_error
Packit 423ecb
#include "elfgcchack.h"