From 5fa2fe46f25c793765e5cc107f1d48a51086fcab Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Fri, 25 Sep 2009 13:36:33 +0200 Subject: Added eurephiaXML_IsResultMsg() to check if an XML doc is a ResultMsg document --- common/eurephia_xml.c | 16 ++++++++++++++++ common/eurephia_xml.h | 1 + 2 files changed, 17 insertions(+) (limited to 'common') diff --git a/common/eurephia_xml.c b/common/eurephia_xml.c index 91eacf4..0dc42ae 100644 --- a/common/eurephia_xml.c +++ b/common/eurephia_xml.c @@ -235,6 +235,22 @@ xmlNode *eurephiaXML_getRoot(eurephiaCTX *ctx, xmlDoc *doc, const char *nodeset, } +/** + * Checks if the given XML document is an eurephia ResultMsg XML document + * + * @param ctx eurephiaCTX + * @param resxml XML document to validate + * + * @return Returns 1 if the input XML document is a ResultMsg document. Otherwise 0 + */ +unsigned int eurephiaXML_IsResultMsg(eurephiaCTX *ctx, xmlDoc *resxml) { + xmlNode *node = NULL; + + assert( (ctx != NULL) && (resxml != NULL) ); + node = eurephiaXML_getRoot(ctx, resxml, "Result", 1); + return (node != NULL ? 1 : 0); +} + /** * Parses an eurephia Result XML document * diff --git a/common/eurephia_xml.h b/common/eurephia_xml.h index 614394a..2ee1175 100644 --- a/common/eurephia_xml.h +++ b/common/eurephia_xml.h @@ -69,6 +69,7 @@ int eurephiaXML_CreateDoc(eurephiaCTX *ctx, int format, const char *rootname, xm xmlNode *eurephiaXML_getRoot(eurephiaCTX *ctx, xmlDoc *doc, const char *nodeset, int min_format); xmlDoc *eurephiaXML_ResultMsg(eurephiaCTX *ctx, exmlResultType type, xmlNode *info_n, const char *fmt, ... ); +unsigned int eurephiaXML_IsResultMsg(eurephiaCTX *ctx, xmlDoc *resxml); eurephiaRESULT *eurephiaXML_ParseResultMsg(eurephiaCTX *ctx, xmlDoc *resxml); inline char *xmlExtractContent(xmlNode *n); -- cgit