ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

error.c
Go to the documentation of this file.
00001 /*
00002  * error.c: module displaying/handling XML parser errors
00003  *
00004  * See Copyright for the status of this software.
00005  *
00006  * Daniel Veillard <daniel@veillard.com>
00007  */
00008 
00009 #define IN_LIBXML
00010 #include "libxml.h"
00011 
00012 #include <string.h>
00013 #include <stdarg.h>
00014 #include <libxml/parser.h>
00015 #include <libxml/xmlerror.h>
00016 #include <libxml/xmlmemory.h>
00017 #include <libxml/globals.h>
00018 
00019 void XMLCDECL xmlGenericErrorDefaultFunc    (void *ctx ATTRIBUTE_UNUSED,
00020                  const char *msg,
00021                  ...);
00022 
00023 #define XML_GET_VAR_STR(msg, str) {             \
00024     int       size, prev_size = -1;             \
00025     int       chars;                        \
00026     char      *larger;                      \
00027     va_list   ap;                       \
00028                                 \
00029     str = (char *) xmlMalloc(150);              \
00030     if (str != NULL) {                      \
00031                                 \
00032     size = 150;                         \
00033                                 \
00034     while (size < 64000) {                  \
00035     va_start(ap, msg);                  \
00036     chars = vsnprintf(str, size, msg, ap);          \
00037     va_end(ap);                     \
00038     if ((chars > -1) && (chars < size)) {           \
00039         if (prev_size == chars) {               \
00040         break;                      \
00041         } else {                        \
00042         prev_size = chars;              \
00043         }                           \
00044     }                           \
00045     if (chars > -1)                     \
00046         size += chars + 1;                  \
00047     else                            \
00048         size += 100;                    \
00049     if ((larger = (char *) xmlRealloc(str, size)) == NULL) {\
00050         break;                      \
00051     }                           \
00052     str = larger;                       \
00053     }}                              \
00054 }
00055 
00056 /************************************************************************
00057  *                                  *
00058  *          Handling of out of context errors       *
00059  *                                  *
00060  ************************************************************************/
00061 
00070 void XMLCDECL
00071 xmlGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
00072     va_list args;
00073 
00074     if (xmlGenericErrorContext == NULL)
00075     xmlGenericErrorContext = (void *) stderr;
00076 
00077     va_start(args, msg);
00078     vfprintf((FILE *)xmlGenericErrorContext, msg, args);
00079     va_end(args);
00080 }
00081 
00089 void
00090 initGenericErrorDefaultFunc(xmlGenericErrorFunc * handler)
00091 {
00092     if (handler == NULL)
00093         xmlGenericError = xmlGenericErrorDefaultFunc;
00094     else
00095         xmlGenericError = (*handler);
00096 }
00097 
00112 void
00113 xmlSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
00114     xmlGenericErrorContext = ctx;
00115     if (handler != NULL)
00116     xmlGenericError = handler;
00117     else
00118     xmlGenericError = xmlGenericErrorDefaultFunc;
00119 }
00120 
00133 void
00134 xmlSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
00135     xmlStructuredErrorContext = ctx;
00136     xmlStructuredError = handler;
00137 }
00138 
00139 /************************************************************************
00140  *                                  *
00141  *          Handling of parsing errors          *
00142  *                                  *
00143  ************************************************************************/
00144 
00152 void
00153 xmlParserPrintFileInfo(xmlParserInputPtr input) {
00154     if (input != NULL) {
00155     if (input->filename)
00156         xmlGenericError(xmlGenericErrorContext,
00157             "%s:%d: ", input->filename,
00158             input->line);
00159     else
00160         xmlGenericError(xmlGenericErrorContext,
00161             "Entity: line %d: ", input->line);
00162     }
00163 }
00164 
00172 static void
00173 xmlParserPrintFileContextInternal(xmlParserInputPtr input , 
00174         xmlGenericErrorFunc channel, void *data ) {
00175     const xmlChar *cur, *base;
00176     unsigned int n, col;    /* GCC warns if signed, because compared with sizeof() */
00177     xmlChar  content[81]; /* space for 80 chars + line terminator */
00178     xmlChar *ctnt;
00179 
00180     if (input == NULL) return;
00181     cur = input->cur;
00182     base = input->base;
00183     /* skip backwards over any end-of-lines */
00184     while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) {
00185     cur--;
00186     }
00187     n = 0;
00188     /* search backwards for beginning-of-line (to max buff size) */
00189     while ((n++ < (sizeof(content)-1)) && (cur > base) && 
00190            (*(cur) != '\n') && (*(cur) != '\r'))
00191         cur--;
00192     if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
00193     /* calculate the error position in terms of the current position */
00194     col = input->cur - cur;
00195     /* search forward for end-of-line (to max buff size) */
00196     n = 0;
00197     ctnt = content;
00198     /* copy selected text to our buffer */
00199     while ((*cur != 0) && (*(cur) != '\n') && 
00200            (*(cur) != '\r') && (n < sizeof(content)-1)) {
00201         *ctnt++ = *cur++;
00202     n++;
00203     }
00204     *ctnt = 0;
00205     /* print out the selected text */
00206     channel(data ,"%s\n", content);
00207     /* create blank line with problem pointer */
00208     n = 0;
00209     ctnt = content;
00210     /* (leave buffer space for pointer + line terminator) */
00211     while ((n<col) && (n++ < sizeof(content)-2) && (*ctnt != 0)) {
00212     if (*(ctnt) != '\t')
00213         *(ctnt) = ' ';
00214     ctnt++;
00215     }
00216     *ctnt++ = '^';
00217     *ctnt = 0;
00218     channel(data ,"%s\n", content);
00219 }
00220 
00227 void
00228 xmlParserPrintFileContext(xmlParserInputPtr input) {
00229    xmlParserPrintFileContextInternal(input, xmlGenericError,
00230                                      xmlGenericErrorContext);
00231 }
00232 
00242 static void
00243 xmlReportError(xmlErrorPtr err, xmlParserCtxtPtr ctxt, const char *str,
00244                xmlGenericErrorFunc channel, void *data)
00245 {
00246     char *file = NULL;
00247     int line = 0;
00248     int code = -1;
00249     int domain;
00250     const xmlChar *name = NULL;
00251     xmlNodePtr node;
00252     xmlErrorLevel level;
00253     xmlParserInputPtr input = NULL;
00254     xmlParserInputPtr cur = NULL;
00255 
00256     if (err == NULL)
00257         return;
00258 
00259     if (channel == NULL) {
00260     channel = xmlGenericError;
00261     data = xmlGenericErrorContext;
00262     }
00263     file = err->file;
00264     line = err->line;
00265     code = err->code;
00266     domain = err->domain;
00267     level = err->level;
00268     node = err->node;
00269 
00270     if (code == XML_ERR_OK)
00271         return;
00272 
00273     if ((node != NULL) && (node->type == XML_ELEMENT_NODE))
00274         name = node->name;
00275 
00276     /*
00277      * Maintain the compatibility with the legacy error handling
00278      */
00279     if (ctxt != NULL) {
00280         input = ctxt->input;
00281         if ((input != NULL) && (input->filename == NULL) &&
00282             (ctxt->inputNr > 1)) {
00283             cur = input;
00284             input = ctxt->inputTab[ctxt->inputNr - 2];
00285         }
00286         if (input != NULL) {
00287             if (input->filename)
00288                 channel(data, "%s:%d: ", input->filename, input->line);
00289             else if ((line != 0) && (domain == XML_FROM_PARSER))
00290                 channel(data, "Entity: line %d: ", input->line);
00291         }
00292     } else {
00293         if (file != NULL)
00294             channel(data, "%s:%d: ", file, line);
00295         else if ((line != 0) && (domain == XML_FROM_PARSER))
00296             channel(data, "Entity: line %d: ", line);
00297     }
00298     if (name != NULL) {
00299         channel(data, "element %s: ", name);
00300     }
00301     switch (domain) {
00302         case XML_FROM_PARSER:
00303             channel(data, "parser ");
00304             break;
00305         case XML_FROM_NAMESPACE:
00306             channel(data, "namespace ");
00307             break;
00308         case XML_FROM_DTD:
00309         case XML_FROM_VALID:
00310             channel(data, "validity ");
00311             break;
00312         case XML_FROM_HTML:
00313             channel(data, "HTML parser ");
00314             break;
00315         case XML_FROM_MEMORY:
00316             channel(data, "memory ");
00317             break;
00318         case XML_FROM_OUTPUT:
00319             channel(data, "output ");
00320             break;
00321         case XML_FROM_IO:
00322             channel(data, "I/O ");
00323             break;
00324         case XML_FROM_XINCLUDE:
00325             channel(data, "XInclude ");
00326             break;
00327         case XML_FROM_XPATH:
00328             channel(data, "XPath ");
00329             break;
00330         case XML_FROM_XPOINTER:
00331             channel(data, "parser ");
00332             break;
00333         case XML_FROM_REGEXP:
00334             channel(data, "regexp ");
00335             break;
00336         case XML_FROM_MODULE:
00337             channel(data, "module ");
00338             break;
00339         case XML_FROM_SCHEMASV:
00340             channel(data, "Schemas validity ");
00341             break;
00342         case XML_FROM_SCHEMASP:
00343             channel(data, "Schemas parser ");
00344             break;
00345         case XML_FROM_RELAXNGP:
00346             channel(data, "Relax-NG parser ");
00347             break;
00348         case XML_FROM_RELAXNGV:
00349             channel(data, "Relax-NG validity ");
00350             break;
00351         case XML_FROM_CATALOG:
00352             channel(data, "Catalog ");
00353             break;
00354         case XML_FROM_C14N:
00355             channel(data, "C14N ");
00356             break;
00357         case XML_FROM_XSLT:
00358             channel(data, "XSLT ");
00359             break;
00360         case XML_FROM_I18N:
00361             channel(data, "encoding ");
00362             break;
00363         default:
00364             break;
00365     }
00366     switch (level) {
00367         case XML_ERR_NONE:
00368             channel(data, ": ");
00369             break;
00370         case XML_ERR_WARNING:
00371             channel(data, "warning : ");
00372             break;
00373         case XML_ERR_ERROR:
00374             channel(data, "error : ");
00375             break;
00376         case XML_ERR_FATAL:
00377             channel(data, "error : ");
00378             break;
00379     }
00380     if (str != NULL) {
00381         int len;
00382     len = xmlStrlen((const xmlChar *)str);
00383     if ((len > 0) && (str[len - 1] != '\n'))
00384         channel(data, "%s\n", str);
00385     else
00386         channel(data, "%s", str);
00387     } else {
00388         channel(data, "%s\n", "out of memory error");
00389     }
00390 
00391     if (ctxt != NULL) {
00392         xmlParserPrintFileContextInternal(input, channel, data);
00393         if (cur != NULL) {
00394             if (cur->filename)
00395                 channel(data, "%s:%d: \n", cur->filename, cur->line);
00396             else if ((line != 0) && (domain == XML_FROM_PARSER))
00397                 channel(data, "Entity: line %d: \n", cur->line);
00398             xmlParserPrintFileContextInternal(cur, channel, data);
00399         }
00400     }
00401     if ((domain == XML_FROM_XPATH) && (err->str1 != NULL) &&
00402         (err->int1 < 100) &&
00403     (err->int1 < xmlStrlen((const xmlChar *)err->str1))) {
00404     xmlChar buf[150];
00405     int i;
00406 
00407     channel(data, "%s\n", err->str1);
00408     for (i=0;i < err->int1;i++)
00409          buf[i] = ' ';
00410     buf[i++] = '^';
00411     buf[i] = 0;
00412     channel(data, "%s\n", buf);
00413     }
00414 }
00415 
00440 void XMLCDECL
00441 __xmlRaiseError(xmlStructuredErrorFunc schannel,
00442               xmlGenericErrorFunc channel, void *data, void *ctx,
00443               void *nod, int domain, int code, xmlErrorLevel level,
00444               const char *file, int line, const char *str1,
00445               const char *str2, const char *str3, int int1, int col,
00446           const char *msg, ...)
00447 {
00448     xmlParserCtxtPtr ctxt = NULL;
00449     xmlNodePtr node = (xmlNodePtr) nod;
00450     char *str = NULL;
00451     xmlParserInputPtr input = NULL;
00452     xmlErrorPtr to = &xmlLastError;
00453     xmlNodePtr baseptr = NULL;
00454 
00455     if ((xmlGetWarningsDefaultValue == 0) && (level == XML_ERR_WARNING))
00456         return;
00457     if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) ||
00458         (domain == XML_FROM_DTD) || (domain == XML_FROM_NAMESPACE) ||
00459     (domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) {
00460     ctxt = (xmlParserCtxtPtr) ctx;
00461     if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
00462         (ctxt->sax->initialized == XML_SAX2_MAGIC))
00463         schannel = ctxt->sax->serror;
00464     }
00465     /*
00466      * Check if structured error handler set
00467      */
00468     if (schannel == NULL) {
00469     schannel = xmlStructuredError;
00470     /*
00471      * if user has defined handler, change data ptr to user's choice
00472      */
00473     if (schannel != NULL)
00474         data = xmlStructuredErrorContext;
00475     }
00476     if ((domain == XML_FROM_VALID) &&
00477         ((channel == xmlParserValidityError) ||
00478      (channel == xmlParserValidityWarning))) {
00479     ctxt = (xmlParserCtxtPtr) ctx;
00480     if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
00481         (ctxt->sax->initialized == XML_SAX2_MAGIC))
00482         schannel = ctxt->sax->serror;
00483     }
00484     if (code == XML_ERR_OK)
00485         return;
00486     /*
00487      * Formatting the message
00488      */
00489     if (msg == NULL) {
00490         str = (char *) xmlStrdup(BAD_CAST "No error message provided");
00491     } else {
00492         XML_GET_VAR_STR(msg, str);
00493     }
00494 
00495     /*
00496      * specific processing if a parser context is provided
00497      */
00498     if (ctxt != NULL) {
00499         if (file == NULL) {
00500             input = ctxt->input;
00501             if ((input != NULL) && (input->filename == NULL) &&
00502                 (ctxt->inputNr > 1)) {
00503                 input = ctxt->inputTab[ctxt->inputNr - 2];
00504             }
00505             if (input != NULL) {
00506                 file = input->filename;
00507                 line = input->line;
00508                 col = input->col;
00509             }
00510         }
00511         to = &ctxt->lastError;
00512     } else if ((node != NULL) && (file == NULL)) {
00513     int i;
00514 
00515     if ((node->doc != NULL) && (node->doc->URL != NULL)) {
00516         baseptr = node;
00517 /*      file = (const char *) node->doc->URL; */
00518     }
00519     for (i = 0;
00520          ((i < 10) && (node != NULL) && (node->type != XML_ELEMENT_NODE));
00521          i++)
00522          node = node->parent;
00523         if ((baseptr == NULL) && (node != NULL) &&
00524         (node->doc != NULL) && (node->doc->URL != NULL))
00525         baseptr = node;
00526 
00527     if ((node != NULL) && (node->type == XML_ELEMENT_NODE))
00528         line = node->line;
00529     }
00530 
00531     /*
00532      * Save the information about the error
00533      */
00534     xmlResetError(to);
00535     to->domain = domain;
00536     to->code = code;
00537     to->message = str;
00538     to->level = level;
00539     if (file != NULL)
00540         to->file = (char *) xmlStrdup((const xmlChar *) file);
00541     else if (baseptr != NULL) {
00542 #ifdef LIBXML_XINCLUDE_ENABLED
00543     /*
00544      * We check if the error is within an XInclude section and,
00545      * if so, attempt to print out the href of the XInclude instead
00546      * of the usual "base" (doc->URL) for the node (bug 152623).
00547      */
00548         xmlNodePtr prev = baseptr;
00549     int inclcount = 0;
00550     while (prev != NULL) {
00551         if (prev->prev == NULL)
00552             prev = prev->parent;
00553         else {
00554             prev = prev->prev;
00555         if (prev->type == XML_XINCLUDE_START) {
00556             if (--inclcount < 0)
00557                 break;
00558         } else if (prev->type == XML_XINCLUDE_END)
00559             inclcount++;
00560         }
00561     }
00562     if (prev != NULL) {
00563         if (prev->type == XML_XINCLUDE_START) {
00564         prev->type = XML_ELEMENT_NODE;
00565         to->file = (char *) xmlGetProp(prev, BAD_CAST "href");
00566         prev->type = XML_XINCLUDE_START;
00567         } else {
00568         to->file = (char *) xmlGetProp(prev, BAD_CAST "href");
00569         }
00570     } else
00571 #endif
00572         to->file = (char *) xmlStrdup(baseptr->doc->URL);
00573     if ((to->file == NULL) && (node != NULL) && (node->doc != NULL)) {
00574         to->file = (char *) xmlStrdup(node->doc->URL);
00575     }
00576     }
00577     to->line = line;
00578     if (str1 != NULL)
00579         to->str1 = (char *) xmlStrdup((const xmlChar *) str1);
00580     if (str2 != NULL)
00581         to->str2 = (char *) xmlStrdup((const xmlChar *) str2);
00582     if (str3 != NULL)
00583         to->str3 = (char *) xmlStrdup((const xmlChar *) str3);
00584     to->int1 = int1;
00585     to->int2 = col;
00586     to->node = node;
00587     to->ctxt = ctx;
00588 
00589     if (to != &xmlLastError)
00590         xmlCopyError(to,&xmlLastError);
00591 
00592     /*
00593      * Find the callback channel if channel param is NULL
00594      */
00595     if ((ctxt != NULL) && (channel == NULL) &&
00596         (xmlStructuredError == NULL) && (ctxt->sax != NULL)) {
00597         if (level == XML_ERR_WARNING)
00598         channel = ctxt->sax->warning;
00599         else
00600         channel = ctxt->sax->error;
00601     data = ctxt->userData;
00602     } else if (channel == NULL) {
00603         if ((schannel == NULL) && (xmlStructuredError != NULL)) {
00604         schannel = xmlStructuredError;
00605         data = xmlStructuredErrorContext;
00606     } else {
00607         channel = xmlGenericError;
00608         if (!data) {
00609         data = xmlGenericErrorContext;
00610         }
00611     }
00612     }
00613     if (schannel != NULL) {
00614         schannel(data, to);
00615     return;
00616     }
00617     if (channel == NULL)
00618         return;
00619 
00620     if ((channel == xmlParserError) ||
00621         (channel == xmlParserWarning) ||
00622     (channel == xmlParserValidityError) ||
00623     (channel == xmlParserValidityWarning))
00624     xmlReportError(to, ctxt, str, NULL, NULL);
00625     else if ((channel == (xmlGenericErrorFunc) fprintf) ||
00626              (channel == xmlGenericErrorDefaultFunc))
00627     xmlReportError(to, ctxt, str, channel, data);
00628     else
00629     channel(data, "%s", str);
00630 }
00631 
00641 void
00642 __xmlSimpleError(int domain, int code, xmlNodePtr node,
00643                  const char *msg, const char *extra)
00644 {
00645 
00646     if (code == XML_ERR_NO_MEMORY) {
00647     if (extra)
00648         __xmlRaiseError(NULL, NULL, NULL, NULL, node, domain,
00649                 XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra,
00650                 NULL, NULL, 0, 0,
00651                 "Memory allocation failed : %s\n", extra);
00652     else
00653         __xmlRaiseError(NULL, NULL, NULL, NULL, node, domain,
00654                 XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, NULL,
00655                 NULL, NULL, 0, 0, "Memory allocation failed\n");
00656     } else {
00657     __xmlRaiseError(NULL, NULL, NULL, NULL, node, domain,
00658             code, XML_ERR_ERROR, NULL, 0, extra,
00659             NULL, NULL, 0, 0, msg, extra);
00660     }
00661 }
00671 void XMLCDECL
00672 xmlParserError(void *ctx, const char *msg, ...)
00673 {
00674     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
00675     xmlParserInputPtr input = NULL;
00676     xmlParserInputPtr cur = NULL;
00677     char * str;
00678 
00679     if (ctxt != NULL) {
00680     input = ctxt->input;
00681     if ((input != NULL) && (input->filename == NULL) &&
00682         (ctxt->inputNr > 1)) {
00683         cur = input;
00684         input = ctxt->inputTab[ctxt->inputNr - 2];
00685     }
00686     xmlParserPrintFileInfo(input);
00687     }
00688 
00689     xmlGenericError(xmlGenericErrorContext, "error: ");
00690     XML_GET_VAR_STR(msg, str);
00691     xmlGenericError(xmlGenericErrorContext, "%s", str);
00692     if (str != NULL)
00693     xmlFree(str);
00694 
00695     if (ctxt != NULL) {
00696     xmlParserPrintFileContext(input);
00697     if (cur != NULL) {
00698         xmlParserPrintFileInfo(cur);
00699         xmlGenericError(xmlGenericErrorContext, "\n");
00700         xmlParserPrintFileContext(cur);
00701     }
00702     }
00703 }
00704 
00714 void XMLCDECL
00715 xmlParserWarning(void *ctx, const char *msg, ...)
00716 {
00717     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
00718     xmlParserInputPtr input = NULL;
00719     xmlParserInputPtr cur = NULL;
00720     char * str;
00721 
00722     if (ctxt != NULL) {
00723     input = ctxt->input;
00724     if ((input != NULL) && (input->filename == NULL) &&
00725         (ctxt->inputNr > 1)) {
00726         cur = input;
00727         input = ctxt->inputTab[ctxt->inputNr - 2];
00728     }
00729     xmlParserPrintFileInfo(input);
00730     }
00731         
00732     xmlGenericError(xmlGenericErrorContext, "warning: ");
00733     XML_GET_VAR_STR(msg, str);
00734     xmlGenericError(xmlGenericErrorContext, "%s", str);
00735     if (str != NULL)
00736     xmlFree(str);
00737 
00738     if (ctxt != NULL) {
00739     xmlParserPrintFileContext(input);
00740     if (cur != NULL) {
00741         xmlParserPrintFileInfo(cur);
00742         xmlGenericError(xmlGenericErrorContext, "\n");
00743         xmlParserPrintFileContext(cur);
00744     }
00745     }
00746 }
00747 
00748 /************************************************************************
00749  *                                  *
00750  *          Handling of validation errors           *
00751  *                                  *
00752  ************************************************************************/
00753 
00763 void XMLCDECL
00764 xmlParserValidityError(void *ctx, const char *msg, ...)
00765 {
00766     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
00767     xmlParserInputPtr input = NULL;
00768     char * str;
00769     int len = xmlStrlen((const xmlChar *) msg);
00770     static int had_info = 0;
00771 
00772     if ((len > 1) && (msg[len - 2] != ':')) {
00773     if (ctxt != NULL) {
00774         input = ctxt->input;
00775         if ((input->filename == NULL) && (ctxt->inputNr > 1))
00776         input = ctxt->inputTab[ctxt->inputNr - 2];
00777         
00778         if (had_info == 0) {
00779         xmlParserPrintFileInfo(input);
00780         }
00781     }
00782     xmlGenericError(xmlGenericErrorContext, "validity error: ");
00783     had_info = 0;
00784     } else {
00785     had_info = 1;
00786     }
00787 
00788     XML_GET_VAR_STR(msg, str);
00789     xmlGenericError(xmlGenericErrorContext, "%s", str);
00790     if (str != NULL)
00791     xmlFree(str);
00792 
00793     if ((ctxt != NULL) && (input != NULL)) {
00794     xmlParserPrintFileContext(input);
00795     }
00796 }
00797 
00807 void XMLCDECL
00808 xmlParserValidityWarning(void *ctx, const char *msg, ...)
00809 {
00810     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
00811     xmlParserInputPtr input = NULL;
00812     char * str;
00813     int len = xmlStrlen((const xmlChar *) msg);
00814 
00815     if ((ctxt != NULL) && (len != 0) && (msg[len - 1] != ':')) {
00816     input = ctxt->input;
00817     if ((input->filename == NULL) && (ctxt->inputNr > 1))
00818         input = ctxt->inputTab[ctxt->inputNr - 2];
00819 
00820     xmlParserPrintFileInfo(input);
00821     }
00822         
00823     xmlGenericError(xmlGenericErrorContext, "validity warning: ");
00824     XML_GET_VAR_STR(msg, str);
00825     xmlGenericError(xmlGenericErrorContext, "%s", str);
00826     if (str != NULL)
00827     xmlFree(str);
00828 
00829     if (ctxt != NULL) {
00830     xmlParserPrintFileContext(input);
00831     }
00832 }
00833 
00834 
00835 /************************************************************************
00836  *                                  *
00837  *          Extended Error Handling             *
00838  *                                  *
00839  ************************************************************************/
00840 
00849 xmlErrorPtr
00850 xmlGetLastError(void)
00851 {
00852     if (xmlLastError.code == XML_ERR_OK)
00853         return (NULL);
00854     return (&xmlLastError);
00855 }
00856 
00863 void
00864 xmlResetError(xmlErrorPtr err)
00865 {
00866     if (err == NULL)
00867         return;
00868     if (err->code == XML_ERR_OK)
00869         return;
00870     if (err->message != NULL)
00871         xmlFree(err->message);
00872     if (err->file != NULL)
00873         xmlFree(err->file);
00874     if (err->str1 != NULL)
00875         xmlFree(err->str1);
00876     if (err->str2 != NULL)
00877         xmlFree(err->str2);
00878     if (err->str3 != NULL)
00879         xmlFree(err->str3);
00880     memset(err, 0, sizeof(xmlError));
00881     err->code = XML_ERR_OK;
00882 }
00883 
00890 void
00891 xmlResetLastError(void)
00892 {
00893     if (xmlLastError.code == XML_ERR_OK)
00894         return;
00895     xmlResetError(&xmlLastError);
00896 }
00897 
00906 xmlErrorPtr
00907 xmlCtxtGetLastError(void *ctx)
00908 {
00909     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
00910 
00911     if (ctxt == NULL)
00912         return (NULL);
00913     if (ctxt->lastError.code == XML_ERR_OK)
00914         return (NULL);
00915     return (&ctxt->lastError);
00916 }
00917 
00925 void
00926 xmlCtxtResetLastError(void *ctx)
00927 {
00928     xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
00929 
00930     if (ctxt == NULL)
00931         return;
00932     ctxt->errNo = XML_ERR_OK;
00933     if (ctxt->lastError.code == XML_ERR_OK)
00934         return;
00935     xmlResetError(&ctxt->lastError);
00936 }
00937 
00947 int
00948 xmlCopyError(xmlErrorPtr from, xmlErrorPtr to) {
00949     char *message, *file, *str1, *str2, *str3;
00950 
00951     if ((from == NULL) || (to == NULL))
00952         return(-1);
00953 
00954     message = (char *) xmlStrdup((xmlChar *) from->message);
00955     file = (char *) xmlStrdup ((xmlChar *) from->file);
00956     str1 = (char *) xmlStrdup ((xmlChar *) from->str1);
00957     str2 = (char *) xmlStrdup ((xmlChar *) from->str2);
00958     str3 = (char *) xmlStrdup ((xmlChar *) from->str3);
00959 
00960     if (to->message != NULL)
00961         xmlFree(to->message);
00962     if (to->file != NULL)
00963         xmlFree(to->file);
00964     if (to->str1 != NULL)
00965         xmlFree(to->str1);
00966     if (to->str2 != NULL)
00967         xmlFree(to->str2);
00968     if (to->str3 != NULL)
00969         xmlFree(to->str3);
00970     to->domain = from->domain;
00971     to->code = from->code;
00972     to->level = from->level;
00973     to->line = from->line;
00974     to->node = from->node;
00975     to->int1 = from->int1;
00976     to->int2 = from->int2;
00977     to->node = from->node;
00978     to->ctxt = from->ctxt;
00979     to->message = message;
00980     to->file = file;
00981     to->str1 = str1;
00982     to->str2 = str2;
00983     to->str3 = str3;
00984 
00985     return 0;
00986 }
00987 
00988 #define bottom_error
00989 #include "elfgcchack.h"

Generated on Sun May 27 2012 04:17:40 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.