diff options
| author | David Sommerseth <davids@redhat.com> | 2009-10-12 15:54:04 +0200 |
|---|---|---|
| committer | David Sommerseth <davids@redhat.com> | 2009-10-12 15:54:04 +0200 |
| commit | f6f73968ce3a2ae624a5a1d820da579eebe6d365 (patch) | |
| tree | 1d813d7a3e66e809dfd4951bf10ebec11877dc9f /server/parser/xmlparser.c | |
| parent | 25d8bb2e5baeb4a14a2f0435e9229ce043a5528a (diff) | |
Added sqldataGetHostInfo()
This function parses the input report XML through the xmlparser.xsl XSLT
template. It returns hostname and IP address via the function arguments and
an sqldata XML document as the return value. On errors, NULL is returned.
Diffstat (limited to 'server/parser/xmlparser.c')
| -rw-r--r-- | server/parser/xmlparser.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/server/parser/xmlparser.c b/server/parser/xmlparser.c index 8977e99..3ab99bb 100644 --- a/server/parser/xmlparser.c +++ b/server/parser/xmlparser.c @@ -258,3 +258,43 @@ char *sqldataGetValue(xmlDoc *sqld, const char *fname, int recid ) { } return NULL; } + + +xmlDoc *sqldataGetHostInfo(xsltStylesheet *xslt, xmlDoc *summaryxml, + int syskey, char **hostname, char **ipaddr) +{ + xmlDoc *hostinfo_d = NULL; + parseParams prms; + + memset(&prms, 0, sizeof(parseParams)); + prms.table = "systems_hostname"; + prms.syskey = syskey; + + hostinfo_d = parseToSQLdata(xslt, summaryxml, &prms); + if( !hostinfo_d ) { + fprintf(stderr, "** ERROR ** Could not parse input XML data (hostinfo)\n"); + xmlFreeDoc(hostinfo_d); + goto exit; + } + + // Grab hostname from input XML + *hostname = sqldataGetValue(hostinfo_d, "hostname", 0); + if( !hostname ) { + fprintf(stderr, + "** ERROR ** Could not retrieve the hostname field from the input XML\n"); + xmlFreeDoc(hostinfo_d); + goto exit; + } + + // Grab ipaddr from input XML + *ipaddr = sqldataGetValue(hostinfo_d, "ipaddr", 0); + if( !ipaddr ) { + fprintf(stderr, + "** ERROR ** Could not retrieve the IP address field from the input XML\n"); + free_nullsafe(hostname); + xmlFreeDoc(hostinfo_d); + goto exit; + } + exit: + return hostinfo_d; +} |
