On Fri, Jun 24, 2011 at 12:04:40PM +0200, Michal Novotny wrote:
This commit introduces names definition for the DNS hosts file using
the following syntax:
<dns>
<host ip="192.168.1.1">
<name>alias1</name>
<name>alias2</name>
</host>
</dns>
Some of the improvements and fixes were done by Laine Stump so
I'm putting him into the SOB clause again ;-)
Signed-off-by: Michal Novotny <minovotn(a)redhat.com>
Signed-off-by: Laine Stump <lstump(a)redhat.com>
[...]
+ cur = node->children;
+ while (cur != NULL) {
+ if (cur->type == XML_ELEMENT_NODE &&
+ xmlStrEqual(cur->name, BAD_CAST "hostname")) {
+ if (cur->children != NULL) {
+ if (VIR_REALLOC_N(def->hosts[def->nhosts].names,
def->hosts[def->nhosts].nnames + 1) < 0) {
+ virReportOOMError();
+ goto error;
+ }
+
+
def->hosts[def->nhosts].names[def->hosts[def->nhosts].nnames] = strdup((char
*)cur->children->content);
+ def->hosts[def->nhosts].nnames++;
+ }
+ }
+
+ cur = cur->next;
+ }
I would suggest to clean this up, as a separate patch to use a
XPath nodeset query for hostname, and then use xmlNodeGetContent()
to get the content string instead of trying to poke at
cur->children->content (which may broke in some weird cases)
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/