The xml output is dirty and marked as FIXME
[debian/dhcpd-pools.git] / src / dhcpd-pools.c
index a27724d..e3467cb 100644 (file)
@@ -36,6 +36,7 @@ extern char *malloc();
 #include <strings.h>
 #endif
 #include <getopt.h>
+#include <errno.h>
 
 #include "dhcpd-pools.h"
 #include "defaults.h"
@@ -139,7 +140,7 @@ int main(int argc, char **argv)
                        /* Output sorting option */
                        if (optarg != NULL) {
                                sorts = strlen(optarg);
-                               if (sorts > 5) {
+                               if (5 < sorts) {
                                        eprintf
                                            ("main: only 5 first sort orders will be used");
                                        strncpy(config.sort, optarg,
@@ -245,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");
@@ -262,7 +264,15 @@ int main(int argc, char **argv)
        }
        free(tmp_ranges);
        output_analysis();
+       /* After fopen in ouput ioctl does like /dev/null which
+        * cause ENOTTY, and clean_up will see that without this
+        * reset. At least linux does this, and possibly some
+        * other systems. There's a report from FreeBSD 8.0 which
+        * matches quite well with the symptom. */
+       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");