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

📄 runtest.c

📁 xml开源解析代码.版本为libxml2-2.6.29,可支持GB3212.网络消息发送XML时很有用.
💻 C
📖 第 1 页 / 共 5 页
字号:
unparsedEntityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name,		   const xmlChar *publicId, const xmlChar *systemId,		   const xmlChar *notationName){const xmlChar *nullstr = BAD_CAST "(null)";    if (publicId == NULL)        publicId = nullstr;    if (systemId == NULL)        systemId = nullstr;    if (notationName == NULL)        notationName = nullstr;    callbacks++;    if (quiet)	return;    fprintf(SAXdebug, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",            (char *) name, (char *) publicId, (char *) systemId,	    (char *) notationName);}/** * setDocumentLocatorDebug: * @ctxt:  An XML parser context * @loc: A SAX Locator * * Receive the document locator at startup, actually xmlDefaultSAXLocator * Everything is available on the context, so this is useless in our case. */static voidsetDocumentLocatorDebug(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED){    callbacks++;    if (quiet)	return;    fprintf(SAXdebug, "SAX.setDocumentLocator()\n");}/** * startDocumentDebug: * @ctxt:  An XML parser context * * called when the document start being processed. */static voidstartDocumentDebug(void *ctx ATTRIBUTE_UNUSED){    callbacks++;    if (quiet)	return;    fprintf(SAXdebug, "SAX.startDocument()\n");}/** * endDocumentDebug: * @ctxt:  An XML parser context * * called when the document end has been detected. */static voidendDocumentDebug(void *ctx ATTRIBUTE_UNUSED){    callbacks++;    if (quiet)	return;    fprintf(SAXdebug, "SAX.endDocument()\n");}/** * startElementDebug: * @ctxt:  An XML parser context * @name:  The element name * * called when an opening tag has been processed. */static voidstartElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts){    int i;    callbacks++;    if (quiet)	return;    fprintf(SAXdebug, "SAX.startElement(%s", (char *) name);    if (atts != NULL) {        for (i = 0;(atts[i] != NULL);i++) {	    fprintf(SAXdebug, ", %s='", atts[i++]);	    if (atts[i] != NULL)	        fprintf(SAXdebug, "%s'", atts[i]);	}    }    fprintf(SAXdebug, ")\n");}/** * endElementDebug: * @ctxt:  An XML parser context * @name:  The element name * * called when the end of an element has been detected. */static voidendElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name){    callbacks++;    if (quiet)	return;    fprintf(SAXdebug, "SAX.endElement(%s)\n", (char *) name);}/** * charactersDebug: * @ctxt:  An XML parser context * @ch:  a xmlChar string * @len: the number of xmlChar * * receiving some chars from the parser. * Question: how much at a time ??? */static voidcharactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len){    char output[40];    int i;    callbacks++;    if (quiet)	return;    for (i = 0;(i<len) && (i < 30);i++)	output[i] = ch[i];    output[i] = 0;    fprintf(SAXdebug, "SAX.characters(%s, %d)\n", output, len);}/** * referenceDebug: * @ctxt:  An XML parser context * @name:  The entity name * * called when an entity reference is detected.  */static voidreferenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name){    callbacks++;    if (quiet)	return;    fprintf(SAXdebug, "SAX.reference(%s)\n", name);}/** * ignorableWhitespaceDebug: * @ctxt:  An XML parser context * @ch:  a xmlChar string * @start: the first char in the string * @len: the number of xmlChar * * receiving some ignorable whitespaces from the parser. * Question: how much at a time ??? */static voidignorableWhitespaceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len){    char output[40];    int i;    callbacks++;    if (quiet)	return;    for (i = 0;(i<len) && (i < 30);i++)	output[i] = ch[i];    output[i] = 0;    fprintf(SAXdebug, "SAX.ignorableWhitespace(%s, %d)\n", output, len);}/** * processingInstructionDebug: * @ctxt:  An XML parser context * @target:  the target name * @data: the PI data's * @len: the number of xmlChar * * A processing instruction has been parsed. */static voidprocessingInstructionDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *target,                      const xmlChar *data){    callbacks++;    if (quiet)	return;    if (data != NULL)	fprintf(SAXdebug, "SAX.processingInstruction(%s, %s)\n",		(char *) target, (char *) data);    else	fprintf(SAXdebug, "SAX.processingInstruction(%s, NULL)\n",		(char *) target);}/** * cdataBlockDebug: * @ctx: the user data (XML parser context) * @value:  The pcdata content * @len:  the block length * * called when a pcdata block has been parsed */static voidcdataBlockDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value, int len){    callbacks++;    if (quiet)	return;    fprintf(SAXdebug, "SAX.pcdata(%.20s, %d)\n",	    (char *) value, len);}/** * commentDebug: * @ctxt:  An XML parser context * @value:  the comment content * * A comment has been parsed. */static voidcommentDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value){    callbacks++;    if (quiet)	return;    fprintf(SAXdebug, "SAX.comment(%s)\n", value);}/** * warningDebug: * @ctxt:  An XML parser context * @msg:  the message to display/transmit * @...:  extra parameters for the message display * * Display and format a warning messages, gives file, line, position and * extra parameters. */static void XMLCDECLwarningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...){    va_list args;    callbacks++;    if (quiet)	return;    va_start(args, msg);    fprintf(SAXdebug, "SAX.warning: ");    vfprintf(SAXdebug, msg, args);    va_end(args);}/** * errorDebug: * @ctxt:  An XML parser context * @msg:  the message to display/transmit * @...:  extra parameters for the message display * * Display and format a error messages, gives file, line, position and * extra parameters. */static void XMLCDECLerrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...){    va_list args;    callbacks++;    if (quiet)	return;    va_start(args, msg);    fprintf(SAXdebug, "SAX.error: ");    vfprintf(SAXdebug, msg, args);    va_end(args);}/** * fatalErrorDebug: * @ctxt:  An XML parser context * @msg:  the message to display/transmit * @...:  extra parameters for the message display * * Display and format a fatalError messages, gives file, line, position and * extra parameters. */static void XMLCDECLfatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...){    va_list args;    callbacks++;    if (quiet)	return;    va_start(args, msg);    fprintf(SAXdebug, "SAX.fatalError: ");    vfprintf(SAXdebug, msg, args);    va_end(args);}static xmlSAXHandler debugSAXHandlerStruct = {    internalSubsetDebug,    isStandaloneDebug,    hasInternalSubsetDebug,    hasExternalSubsetDebug,    resolveEntityDebug,    getEntityDebug,    entityDeclDebug,    notationDeclDebug,    attributeDeclDebug,    elementDeclDebug,    unparsedEntityDeclDebug,    setDocumentLocatorDebug,    startDocumentDebug,    endDocumentDebug,    startElementDebug,    endElementDebug,    referenceDebug,    charactersDebug,    ignorableWhitespaceDebug,    processingInstructionDebug,    commentDebug,    warningDebug,    errorDebug,    fatalErrorDebug,    getParameterEntityDebug,    cdataBlockDebug,    externalSubsetDebug,    1,    NULL,    NULL,    NULL,    NULL};static xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct;/* * SAX2 specific callbacks *//** * startElementNsDebug: * @ctxt:  An XML parser context * @name:  The element name * * called when an opening tag has been processed. */static voidstartElementNsDebug(void *ctx ATTRIBUTE_UNUSED,                    const xmlChar *localname,                    const xmlChar *prefix,                    const xmlChar *URI,		    int nb_namespaces,		    const xmlChar **namespaces,		    int nb_attributes,		    int nb_defaulted,		    const xmlChar **attributes){    int i;    callbacks++;    if (quiet)	return;    fprintf(SAXdebug, "SAX.startElementNs(%s", (char *) localname);    if (prefix == NULL)	fprintf(SAXdebug, ", NULL");    else	fprintf(SAXdebug, ", %s", (char *) prefix);    if (URI == NULL)	fprintf(SAXdebug, ", NULL");    else	fprintf(SAXdebug, ", '%s'", (char *) URI);    fprintf(SAXdebug, ", %d", nb_namespaces);        if (namespaces != NULL) {        for (i = 0;i < nb_namespaces * 2;i++) {	    fprintf(SAXdebug, ", xmlns");	    if (namespaces[i] != NULL)	        fprintf(SAXdebug, ":%s", namespaces[i]);	    i++;	    fprintf(SAXdebug, "='%s'", namespaces[i]);	}    }    fprintf(SAXdebug, ", %d, %d", nb_attributes, nb_defaulted);    if (attributes != NULL) {        for (i = 0;i < nb_attributes * 5;i += 5) {	    if (attributes[i + 1] != NULL)		fprintf(SAXdebug, ", %s:%s='", attributes[i + 1], attributes[i]);	    else		fprintf(SAXdebug, ", %s='", attributes[i]);	    fprintf(SAXdebug, "%.4s...', %d", attributes[i + 3],		    (int)(attributes[i + 4] - attributes[i + 3]));	}    }    fprintf(SAXdebug, ")\n");}/** * endElementDebug: * @ctxt:  An XML parser context * @name:  The element name * * called when the end of an element has been detected. */static voidendElementNsDebug(void *ctx ATTRIBUTE_UNUSED,                  const xmlChar *localname,                  const xmlChar *prefix,                  const xmlChar *URI){    callbacks++;    if (quiet)	return;    fprintf(SAXdebug, "SAX.endElementNs(%s", (char *) localname);    if (prefix == NULL)	fprintf(SAXdebug, ", NULL");    else	fprintf(SAXdebug, ", %s", (char *) prefix);    if (URI == NULL)	fprintf(SAXdebug, ", NULL)\n");    else	fprintf(SAXdebug, ", '%s')\n", (char *) URI);}static xmlSAXHandler debugSAX2HandlerStruct = {    internalSubsetDebug,    isStandaloneDebug,    hasInternalSubsetDebug,    hasExternalSubsetDebug,    resolveEntityDebug,    getEntityDebug,    entityDeclDebug,    notationDeclDebug,    attributeDeclDebug,    elementDeclDebug,    unparsedEntityDeclDebug,    setDocumentLocatorDebug,    startDocumentDebug,    endDocumentDebug,    NULL,    NULL,    referenceDebug,    charactersDebug,    ignorableWhitespaceDebug,    processingInstructionDebug,    commentDebug,    warningDebug,    errorDebug,    fatalErrorDebug,    getParameterEntityDebug,    cdataBlockDebug,    externalSubsetDebug,    XML_SAX2_MAGIC,    NULL,    startElementNsDebug,    endElementNsDebug,    NULL};static xmlSAXHandlerPtr debugSAX2Handler = &debugSAX2HandlerStruct;#ifdef LIBXML_HTML_ENABLED/** * htmlstartElementDebug: * @ctxt:  An XML parser context * @name:  The element name * * called when an opening tag has been processed. */static voidhtmlstartElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts){    int i;    fprintf(SAXdebug, "SAX.startElement(%s", (char *) name);    if (atts != NULL) {        for (i = 0;(atts[i] != NULL);i++) {	    fprintf(SAXdebug, ", %s", atts[i++]);	    if (atts[i] != NULL) {		unsigned char output[40];		const unsigned char *att = atts[i];		int outlen, attlen;	        fprintf(SAXdebug, "='");		while ((attlen = strlen((char*)att)) > 0) {		    outlen = sizeof output - 1;		    htmlEncodeEntities(output, &outlen, att, &attlen, '\'');		    output[outlen] = 0;		    fprintf(SAXdebug, "%s", (char *) output);		    att += attlen;		}		fprintf(SAXdebug, "'");	    }	}    }    fprintf(SAXdebug, ")\n");}/** * htmlcharactersDebug: * @ctxt:  An XML parser context * @ch:  a xmlChar string * @len: the number of xmlChar * * receiving some chars from the parser. * Question: how much at a time ??? */static voidhtmlcharactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len){    unsigned char output[40];    int inlen = len, outlen = 30;    htmlEncodeEntities(output, &outlen, ch, &inlen, 0);    output[outlen] = 0;    fprintf(SAXdebug, "SAX.characters(%s, %d)\n", output, len);}/** * htmlcdataDebug: * @ctxt:  An XML parser context * @ch:  a xmlChar string * @len: the number of xmlChar * * receiving some cdata chars from the parser. * Question: how much at a time ??? */

⌨️ 快捷键说明

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