⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlparservalidityerror_chdl.c

📁 图片显示,电脑光于望技术湖连望键往,网络
💻 C
字号:
#include <libxml/xmlerror.h>
#include <ch.h>

#define XML_GET_VAR_STR_VA(msg, str, ap_c) {                    \
    int       size;                                             \
    int       chars;                                            \
    char      *larger;                                          \
                                                                \
    str = (char *) xmlMalloc(150);                              \
    if (str != NULL) {                                          \
      size = 150;                                               \
      while (1) {                                               \
        chars = vsnprintf(str, size, msg, ap_c);                \
        if ((chars > -1) && (chars < size))                     \
            break;                                              \
        if (chars > -1)                                         \
            size += chars + 1;                                  \
        else                                                    \
            size += 100;                                        \
        if ((larger = (char *) xmlRealloc(str, size)) == NULL) {\
            break;                                              \
        }                                                       \
        str = larger;                                           \
      }                                                         \
    }                                                           \
}

/************************************************************************
 *                                                                      *
 *                      Handling of validation errors                   *
 *                                                                      *
 ************************************************************************/

/**
 * xmlParserValidityVError:
 * @ctx:  an XML parser context
 * @msg:  the message to display/transmit
 * @...:  extra parameters for the message display
 *
 * Display and format an validity error messages, gives file,
 * line, position and extra parameters.
 */
void
xmlParserValidityVError(void *ctx, const char *msg, va_list ap_c)
{
    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
    xmlParserInputPtr input = NULL;
    char * str;
    int len = xmlStrlen((const xmlChar *) msg);
    static int had_info = 0;

    if ((len > 1) && (msg[len - 2] != ':')) {
        if (ctxt != NULL) {
            input = ctxt->input;
            if ((input->filename == NULL) && (ctxt->inputNr > 1))
                input = ctxt->inputTab[ctxt->inputNr - 2];

            if (had_info == 0) {
                xmlParserPrintFileInfo(input);
            }
        }
        xmlGenericError(xmlGenericErrorContext, "validity error: ");
        had_info = 0;
    } else {
        had_info = 1;
    }

    XML_GET_VAR_STR_VA(msg, str, ap_c);
    xmlGenericError(xmlGenericErrorContext, "%s", str);
    if (str != NULL)
        xmlFree(str);

    if ((ctxt != NULL) && (input != NULL)) {
        xmlParserPrintFileContext(input);
    }
}

EXPORTCH void xmlParserValidityError_chdl(void *varg) {
    ChInterp_t interp;
    va_list ap;
    void *ctx;
    char *msg;
    va_list ap_ch, ap_c;
    void *memhandle;

    Ch_VaStart(interp, ap, varg);
    ctx = Ch_VaArg(interp, ap, void *);
    msg = Ch_VaArg(interp, ap, char *);
    ap_ch = Ch_VaArg(interp, ap, va_list);
    ap_c = Ch_VaVarArgsCreate(interp, ap_ch, &memhandle);
    xmlParserValidityVError(ctx, msg, ap_c);
    Ch_VaVarArgsDelete(interp, memhandle);
    Ch_VaEnd(interp, ap);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -