X-Git-Url: http://git.asbjorn.biz/?p=debian%2Fdhcpd-pools.git;a=blobdiff_plain;f=src%2Foutput.c;fp=src%2Foutput.c;h=f2858c647156dc7908ca9e948619174c46b3725e;hp=613078d394862dd1ad6a58c63cf0c4d9966e8891;hb=849c8f5e73d671c7f9e3f74f0652a0876d7a2787;hpb=775157b1a5ae108e1828a6ada231fc4d4d56e01f diff --git a/src/output.c b/src/output.c index 613078d..f2858c6 100644 --- a/src/output.c +++ b/src/output.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "dhcpd-pools.h" @@ -39,8 +40,8 @@ int output_txt(void) if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); if (outfile == NULL) { - eprintf("output_txt: %s:", config.output_file); - exit(EXIT_FAILURE); + err(EXIT_FAILURE, "output_txt: %s", + config.output_file); } } else { outfile = stdout; @@ -172,12 +173,12 @@ int output_txt(void) if (outfile == stdout) { ret = fflush(stdout); if (ret) { - eprintf("output_txt: fflush:"); + warn("output_txt: fflush"); } } else { ret = fclose(outfile); if (ret) { - eprintf("output_txt: fclose:"); + warn("output_txt: fclose"); } } @@ -196,8 +197,8 @@ int output_xml(void) if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); if (outfile == NULL) { - eprintf("output_xml: %s:", config.output_file); - exit(EXIT_FAILURE); + err(EXIT_FAILURE, "output_xml: %s", + config.output_file); } } else { outfile = stdout; @@ -276,12 +277,12 @@ int output_xml(void) if (outfile == stdout) { ret = fflush(stdout); if (ret) { - eprintf("output_xml: fflush:"); + warn("output_xml: fflush"); } } else { ret = fclose(outfile); if (ret) { - eprintf("output_xml: fclose:"); + warn("output_xml: fclose"); } } @@ -425,8 +426,8 @@ int output_html(void) if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); if (outfile == NULL) { - eprintf("output_html: %s:", config.output_file); - exit(EXIT_FAILURE); + err(EXIT_FAILURE, "output_html: %s", + config.output_file); } } else { outfile = stdout; @@ -607,12 +608,12 @@ int output_html(void) if (outfile == stdout) { ret = fflush(stdout); if (ret) { - eprintf("output_html: fflush:"); + warn("output_html: fflush"); } } else { ret = fclose(outfile); if (ret) { - eprintf("output_html: fclose:"); + warn("output_html: fclose"); } } return 0; @@ -630,8 +631,8 @@ int output_csv(void) if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); if (outfile == NULL) { - eprintf("output_csv: %s:", config.output_file); - exit(EXIT_FAILURE); + err(EXIT_FAILURE, "output_csv: %s", + config.output_file); } } else { outfile = stdout; @@ -763,13 +764,13 @@ int output_csv(void) if (outfile == stdout) { ret = fflush(stdout); if (ret) { - eprintf("output_cvs: fflush:"); + warn("output_cvs: fflush"); } } else { ret = fclose(outfile); if (ret) { - eprintf("output_cvs: fclose:"); + warn("output_cvs: fclose"); } }