summaryrefslogtreecommitdiffstats
path: root/server/parser/xmlparser.c
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2009-12-08 14:36:02 +0100
committerDavid Sommerseth <davids@redhat.com>2009-12-08 14:36:02 +0100
commitf3069aacf0c0e3682e4842033481abdf83fed6ce (patch)
tree95ace1f91f011a89ef525d9cbb280a87f73d7282 /server/parser/xmlparser.c
parent605fb465994df62ddd57faab1412d32a47edc386 (diff)
downloadrteval-f3069aacf0c0e3682e4842033481abdf83fed6ce.tar.gz
rteval-f3069aacf0c0e3682e4842033481abdf83fed6ce.tar.xz
rteval-f3069aacf0c0e3682e4842033481abdf83fed6ce.zip
Added function to extract and parse the new //sqldata/@schemaver attribute
This attribute defines which version of the SQL database schema which is needed for the SQL data found in the <sqldata/> document. This is to avoid SQL failures when inserting data which the database is not prepared for.
Diffstat (limited to 'server/parser/xmlparser.c')
-rw-r--r--server/parser/xmlparser.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/server/parser/xmlparser.c b/server/parser/xmlparser.c
index 8cf13a8..e7e31b1 100644
--- a/server/parser/xmlparser.c
+++ b/server/parser/xmlparser.c
@@ -412,3 +412,34 @@ xmlDoc *sqldataGetHostInfo(LogContext *log, xsltStylesheet *xslt, xmlDoc *summar
exit:
return hostinfo_d;
}
+
+int sqldataGetRequiredSchemaVer(LogContext *log, xmlNode *sqldata_root)
+{
+ char *schver = NULL, *cp = NULL, *ptr = NULL;
+ int majv = 0, minv = 0;
+
+ if( !sqldata_root || (xmlStrcmp(sqldata_root->name, (xmlChar *) "sqldata") != 0) ) {
+ writelog(log, LOG_ERR, "sqldataGetRequiredSchemaVer: Invalid document node");
+ return -1;
+ }
+
+ schver = xmlGetAttrValue(sqldata_root->properties, "schemaver");
+ if( schver == NULL ) {
+ return 100; // If not defined, presume lowest available version.
+ }
+ cp = strdup(schver);
+ assert( cp != NULL );
+
+ if( (ptr = strpbrk(cp, ".")) != NULL ) {
+ *ptr = 0;
+ ptr++;
+ majv = atoi_nullsafe(cp);
+ minv = atoi_nullsafe(ptr);
+ } else {
+ majv = atoi_nullsafe(cp);
+ minv = 0;
+ }
+ free_nullsafe(cp);
+
+ return (majv * 100) + minv;
+}