The xml output is dirty and marked as FIXME
authorSami Kerola <kerolasa@iki.fi>
Sat, 22 Jan 2011 12:06:04 +0000 (13:06 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sat, 22 Jan 2011 12:06:04 +0000 (13:06 +0100)
The xml output does not use output file as all other outputs, it
has sections here and there while everything is supposed to be in
output.c, and finally the unnecessary field analysis loop made
program about 20% slower when xml was not asked.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>

src/dhcpd-pools.c
src/getdata.c

index 78a6ce0..e3467cb 100644 (file)
@@ -246,6 +246,7 @@ int main(int argc, char **argv)
                     shared_net_names + strlen(shared_net_names) + 1,
                     shared_networks);
 
+       /* FIXME: move to output.c and use FILE *outfile */
        if ((config.output_format[0] == 'x')
            || (config.output_format[0] == 'X')) {
                printf("<dhcpstatus>\n");
@@ -271,6 +272,7 @@ int main(int argc, char **argv)
        if (errno == 25)
                errno = 0;
 
+       /* FIXME: move to output.c and use FILE *outfile */
        if ((config.output_format[0] == 'x')
            || (config.output_format[0] == 'X')) {
                printf("</dhcpstatus>\n");
index 2fc1f5f..430468c 100644 (file)
@@ -134,16 +134,16 @@ int parse_leases(void)
                        num_backups++;
                }
 
-               if ((sw_active_lease == 1)
+               /* FIXME: move to output.c and use FILE *outfile */
+               if ((config.output_format[0] == 'X')
+                   && (sw_active_lease == 1)
                    && (strstr(line, "hardware ethernet"))) {
                        nth_field(3, macstring, line);
                        macstring[strlen(macstring) - 1] = '\0';
 
-                       if (config.output_format[0] == 'X') {
-                               printf
-                                   ("<active_lease>\n\t<ip>%s</ip>\n\t<macaddress>%s</macaddress>\n</active_lease>\n",
-                                    ipstring, macstring);
-                       };
+                        printf
+                           ("<active_lease>\n\t<ip>%s</ip>\n\t<macaddress>%s</macaddress>\n</active_lease>\n",
+                            ipstring, macstring);
                }
 
                if ((leasesmallocsize < num_leases) ||