[xml] xml error functionality

Date view Thread view Subject view Author view

From: Todd Babinski (todd.babinski@dynetics.com)
Date: Wed Feb 21 2001 - 15:44:23 EST


I have been working with the library on WinNT for a couple of weeks now,
seeing if it will fit the needs for a project that I am on. I've
noticed a problem with how the errors are handled. The programmer is
allowed to set the context and function used to handle the errors using
the xmlSetGenericErrorFunc, and then that is supposed to be used in
error handling from there on out. The problem I've encountered is how
the context (xmlGenericErrorContext) gets used in the functions
xmlParserWarning, xmlParserValidityError, and xmlParserValidityWarning.
The context is treaded as a FILE* in these functions with the following
code snippet (similar in all the functions):

        va_start(args,msg);
        vfprintf(xmlGenericErrorContext,msg, args);
        va_end(args);

This works for contexts such as stderr, but in my case, the context will
be a pointer to a GUI interpreter, and the above code causes the program
to hang. I've changed the above code on my machine to the following to
allow more flexibility in reporting of parser warnings and errors:

        char buf[8192] = {'\0'};
        ...
        va_start(args,msg);
        vsprintf(buf, msg, args);
        va_end(args);
            xmlGenericError(xmlGenericErrorContext, buf);

I choose 8192 as the string length because it worked in my code, though
I know that it could have a potential overrun for long errors. It
shouldn't be that hard to cobble together a function that would
dynamically allocate a long enough char* to fit the entire message
without overruns.

Anyways, this is just a suggestion to bring back into the code base
since I did not find a more elegant way to do it in the existing code
base, and this seems to fit the intent of the generic error handler
better.

Todd B.

----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Feb 21 2001 - 16:43:50 EST