📄 relaxng.c.svn-base
字号:
* Handle a redefinition of attribute error */static voidxmlRngPErrMemory(xmlRelaxNGParserCtxtPtr ctxt, const char *extra){ xmlStructuredErrorFunc schannel = NULL; xmlGenericErrorFunc channel = NULL; void *data = NULL; if (ctxt != NULL) { channel = ctxt->error; data = ctxt->userData; ctxt->nbErrors++; schannel = ctxt->serror; } if (extra) __xmlRaiseError(schannel, channel, data, NULL, NULL, XML_FROM_RELAXNGP, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra, NULL, NULL, 0, 0, "Memory allocation failed : %s\n", extra); else __xmlRaiseError(schannel, channel, data, NULL, NULL, XML_FROM_RELAXNGP, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "Memory allocation failed\n");}/** * xmlRngVErrMemory: * @ctxt: a Relax-NG validation context * @extra: extra informations * * Handle a redefinition of attribute error */static voidxmlRngVErrMemory(xmlRelaxNGValidCtxtPtr ctxt, const char *extra){ xmlStructuredErrorFunc schannel = NULL; xmlGenericErrorFunc channel = NULL; void *data = NULL; if (ctxt != NULL) { channel = ctxt->error; data = ctxt->userData; ctxt->nbErrors++; schannel = ctxt->serror; } if (extra) __xmlRaiseError(schannel, channel, data, NULL, NULL, XML_FROM_RELAXNGV, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra, NULL, NULL, 0, 0, "Memory allocation failed : %s\n", extra); else __xmlRaiseError(schannel, channel, data, NULL, NULL, XML_FROM_RELAXNGV, XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "Memory allocation failed\n");}/** * xmlRngPErr: * @ctxt: a Relax-NG parser context * @node: the node raising the error * @error: the error code * @msg: message * @str1: extra info * @str2: extra info * * Handle a Relax NG Parsing error */static voidxmlRngPErr(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar * str1, const xmlChar * str2){ xmlStructuredErrorFunc schannel = NULL; xmlGenericErrorFunc channel = NULL; void *data = NULL; if (ctxt != NULL) { channel = ctxt->error; data = ctxt->userData; ctxt->nbErrors++; schannel = ctxt->serror; } __xmlRaiseError(schannel, channel, data, NULL, node, XML_FROM_RELAXNGP, error, XML_ERR_ERROR, NULL, 0, (const char *) str1, (const char *) str2, NULL, 0, 0, msg, str1, str2);}/** * xmlRngVErr: * @ctxt: a Relax-NG validation context * @node: the node raising the error * @error: the error code * @msg: message * @str1: extra info * @str2: extra info * * Handle a Relax NG Validation error */static voidxmlRngVErr(xmlRelaxNGValidCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar * str1, const xmlChar * str2){ xmlStructuredErrorFunc schannel = NULL; xmlGenericErrorFunc channel = NULL; void *data = NULL; if (ctxt != NULL) { channel = ctxt->error; data = ctxt->userData; ctxt->nbErrors++; schannel = ctxt->serror; } __xmlRaiseError(schannel, channel, data, NULL, node, XML_FROM_RELAXNGV, error, XML_ERR_ERROR, NULL, 0, (const char *) str1, (const char *) str2, NULL, 0, 0, msg, str1, str2);}/************************************************************************ * * * Preliminary type checking interfaces * * * ************************************************************************//** * xmlRelaxNGTypeHave: * @data: data needed for the library * @type: the type name * @value: the value to check * * Function provided by a type library to check if a type is exported * * Returns 1 if yes, 0 if no and -1 in case of error. */typedef int (*xmlRelaxNGTypeHave) (void *data, const xmlChar * type);/** * xmlRelaxNGTypeCheck: * @data: data needed for the library * @type: the type name * @value: the value to check * @result: place to store the result if needed * * Function provided by a type library to check if a value match a type * * Returns 1 if yes, 0 if no and -1 in case of error. */typedef int (*xmlRelaxNGTypeCheck) (void *data, const xmlChar * type, const xmlChar * value, void **result, xmlNodePtr node);/** * xmlRelaxNGFacetCheck: * @data: data needed for the library * @type: the type name * @facet: the facet name * @val: the facet value * @strval: the string value * @value: the value to check * * Function provided by a type library to check a value facet * * Returns 1 if yes, 0 if no and -1 in case of error. */typedef int (*xmlRelaxNGFacetCheck) (void *data, const xmlChar * type, const xmlChar * facet, const xmlChar * val, const xmlChar * strval, void *value);/** * xmlRelaxNGTypeFree: * @data: data needed for the library * @result: the value to free * * Function provided by a type library to free a returned result */typedef void (*xmlRelaxNGTypeFree) (void *data, void *result);/** * xmlRelaxNGTypeCompare: * @data: data needed for the library * @type: the type name * @value1: the first value * @value2: the second value * * Function provided by a type library to compare two values accordingly * to a type. * * Returns 1 if yes, 0 if no and -1 in case of error. */typedef int (*xmlRelaxNGTypeCompare) (void *data, const xmlChar * type, const xmlChar * value1, xmlNodePtr ctxt1, void *comp1, const xmlChar * value2, xmlNodePtr ctxt2);typedef struct _xmlRelaxNGTypeLibrary xmlRelaxNGTypeLibrary;typedef xmlRelaxNGTypeLibrary *xmlRelaxNGTypeLibraryPtr;struct _xmlRelaxNGTypeLibrary { const xmlChar *namespace; /* the datatypeLibrary value */ void *data; /* data needed for the library */ xmlRelaxNGTypeHave have; /* the export function */ xmlRelaxNGTypeCheck check; /* the checking function */ xmlRelaxNGTypeCompare comp; /* the compare function */ xmlRelaxNGFacetCheck facet; /* the facet check function */ xmlRelaxNGTypeFree freef; /* the freeing function */};/************************************************************************ * * * Allocation functions * * * ************************************************************************/static void xmlRelaxNGFreeGrammar(xmlRelaxNGGrammarPtr grammar);static void xmlRelaxNGFreeDefine(xmlRelaxNGDefinePtr define);static void xmlRelaxNGNormExtSpace(xmlChar * value);static void xmlRelaxNGFreeInnerSchema(xmlRelaxNGPtr schema);static int xmlRelaxNGEqualValidState(xmlRelaxNGValidCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlRelaxNGValidStatePtr state1, xmlRelaxNGValidStatePtr state2);static void xmlRelaxNGFreeValidState(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGValidStatePtr state);/** * xmlRelaxNGFreeDocument: * @docu: a document structure * * Deallocate a RelaxNG document structure. */static voidxmlRelaxNGFreeDocument(xmlRelaxNGDocumentPtr docu){ if (docu == NULL) return; if (docu->href != NULL) xmlFree(docu->href); if (docu->doc != NULL) xmlFreeDoc(docu->doc); if (docu->schema != NULL) xmlRelaxNGFreeInnerSchema(docu->schema); xmlFree(docu);}/** * xmlRelaxNGFreeDocumentList: * @docu: a list of document structure * * Deallocate a RelaxNG document structures. */static voidxmlRelaxNGFreeDocumentList(xmlRelaxNGDocumentPtr docu){ xmlRelaxNGDocumentPtr next; while (docu != NULL) { next = docu->next; xmlRelaxNGFreeDocument(docu); docu = next; }}/** * xmlRelaxNGFreeInclude: * @incl: a include structure * * Deallocate a RelaxNG include structure. */static voidxmlRelaxNGFreeInclude(xmlRelaxNGIncludePtr incl){ if (incl == NULL) return; if (incl->href != NULL) xmlFree(incl->href); if (incl->doc != NULL) xmlFreeDoc(incl->doc); if (incl->schema != NULL) xmlRelaxNGFree(incl->schema); xmlFree(incl);}/** * xmlRelaxNGFreeIncludeList: * @incl: a include structure list * * Deallocate a RelaxNG include structure. */static voidxmlRelaxNGFreeIncludeList(xmlRelaxNGIncludePtr incl){ xmlRelaxNGIncludePtr next; while (incl != NULL) { next = incl->next; xmlRelaxNGFreeInclude(incl); incl = next; }}/** * xmlRelaxNGNewRelaxNG: * @ctxt: a Relax-NG validation context (optional) * * Allocate a new RelaxNG structure. * * Returns the newly allocated structure or NULL in case or error */static xmlRelaxNGPtrxmlRelaxNGNewRelaxNG(xmlRelaxNGParserCtxtPtr ctxt){ xmlRelaxNGPtr ret; ret = (xmlRelaxNGPtr) xmlMalloc(sizeof(xmlRelaxNG)); if (ret == NULL) { xmlRngPErrMemory(ctxt, NULL); return (NULL); } memset(ret, 0, sizeof(xmlRelaxNG)); return (ret);}/** * xmlRelaxNGFreeInnerSchema: * @schema: a schema structure * * Deallocate a RelaxNG schema structure. */static voidxmlRelaxNGFreeInnerSchema(xmlRelaxNGPtr schema){ if (schema == NULL) return; if (schema->doc != NULL) xmlFreeDoc(schema->doc); if (schema->defTab != NULL) { int i; for (i = 0; i < schema->defNr; i++) xmlRelaxNGFreeDefine(schema->defTab[i]); xmlFree(schema->defTab); } xmlFree(schema);}/** * xmlRelaxNGFree: * @schema: a schema structure * * Deallocate a RelaxNG structure. */voidxmlRelaxNGFree(xmlRelaxNGPtr schema){ if (schema == NULL) return; if (schema->topgrammar != NULL) xmlRelaxNGFreeGrammar(schema->topgrammar); if (schema->doc != NULL) xmlFreeDoc(schema->doc); if (schema->documents != NULL) xmlRelaxNGFreeDocumentList(schema->documents); if (schema->includes != NULL) xmlRelaxNGFreeIncludeList(schema->includes); if (schema->defTab != NULL) { int i; for (i = 0; i < schema->defNr; i++) xmlRelaxNGFreeDefine(schema->defTab[i]); xmlFree(schema->defTab); } xmlFree(schema);}/** * xmlRelaxNGNewGrammar: * @ctxt: a Relax-NG validation context (optional) * * Allocate a new RelaxNG grammar. * * Returns the newly allocated structure or NULL in case or error */static xmlRelaxNGGrammarPtrxmlRelaxNGNewGrammar(xmlRelaxNGParserCtxtPtr ctxt){ xmlRelaxNGGrammarPtr ret; ret = (xmlRelaxNGGrammarPtr) xmlMalloc(sizeof(xmlRelaxNGGrammar)); if (ret == NULL) { xmlRngPErrMemory(ctxt, NULL); return (NULL); } memset(ret, 0, sizeof(xmlRelaxNGGrammar)); return (ret);}/** * xmlRelaxNGFreeGrammar: * @grammar: a grammar structure * * Deallocate a RelaxNG grammar structure. */static voidxmlRelaxNGFreeGrammar(xmlRelaxNGGrammarPtr grammar){ if (grammar == NULL) return; if (grammar->children != NULL) { xmlRelaxNGFreeGrammar(grammar->children); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -