From 9d1241c00644e4ff52aad4b2d5ff9fbdef24b33e Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 2 May 2015 19:40:06 +0100 Subject: [PATCH] improve html output Remove unnecessary html indentation, so that there is less page content to transfer. Right align the network names, and IP's so that they are easier to read. And ensure quoting is done correctly. Signed-off-by: Sami Kerola --- src/output.c | 136 +++++++++++++++++++++++++-------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/output.c b/src/output.c index 156be3d..28d6775 100644 --- a/src/output.c +++ b/src/output.c @@ -475,59 +475,59 @@ static void html_header(FILE *restrict f) errx(EXIT_FAILURE, "html_header: strftime returned 0"); } - fprintf(f, "\n"); + fprintf(f, "\n"); fprintf(f, "\n"); fprintf(f, "\n"); fprintf(f, "\n"); - fprintf(f, " ISC dhcpd stats\n"); - fprintf(f, " \n"); + fprintf(f, "ISC dhcpd stats\n"); + fprintf(f, "\n"); fprintf(f, "\n"); fprintf(f, "\n"); fprintf(f, "The lease file mtime: %s", outstr); @@ -541,12 +541,12 @@ static void html_footer(FILE *restrict f) { fprintf(f, "


\n"); fprintf(f, "
\n"); - fprintf(f, "

\nData generated by "); + fprintf(f, "

\nData generated by "); fprintf(f, "", PACKAGE_URL); fprintf(f, "%s.\n

\n", PACKAGE_STRING); - fprintf(f, "

\n"); + fprintf(f, "

\n"); fprintf(f, "\n
\n

\n"); fprintf(f, "\n"); @@ -568,7 +568,7 @@ static void newrow(FILE *restrict f) */ static void endrow(FILE *restrict f) { - fprintf(f, "\n\n"); + fprintf(f, "\n"); } /*! \brief Line with text in html output format. @@ -581,7 +581,7 @@ static void endrow(FILE *restrict f) static void output_line(FILE *restrict f, char const *restrict type, char const *restrict class, char const *restrict text) { - fprintf(f, " <%s class=%s>%s\n", type, class, text, type); + fprintf(f, "<%s class=\"%s\">%s\n", type, class, text, type); } /*! \brief Line with digit in html output format. @@ -592,7 +592,7 @@ static void output_line(FILE *restrict f, char const *restrict type, */ static void output_double(FILE *restrict f, char const *restrict type, double d) { - fprintf(f, " <%s class=ralign>%g\n", type, d, type); + fprintf(f, "<%s class=\"ralign\">%g\n", type, d, type); } /*! \brief Line with float in html output format. @@ -603,7 +603,7 @@ static void output_double(FILE *restrict f, char const *restrict type, double d) */ static void output_float(FILE *f, char const *restrict type, float fl) { - fprintf(f, " <%s class=ralign>%.3f\n", type, fl, type); + fprintf(f, "<%s class=\"ralign\">%.3f\n", type, fl, type); } /*! \brief Begin table in html output format. @@ -634,7 +634,7 @@ static void table_end(FILE *restrict f) static void newsection(FILE *restrict f, char const *restrict title) { newrow(f); - output_line(f, "td", "calign", " "); + output_line(f, "td", "lalign", " "); endrow(f); newrow(f); output_line(f, "th", "section", title); @@ -671,9 +671,9 @@ int output_html(void) if (config.output_limit[0] & BIT1) { newsection(outfile, "Ranges:"); newrow(outfile); - output_line(outfile, "th", "calign", "shared net name"); - output_line(outfile, "th", "calign", "first ip"); - output_line(outfile, "th", "calign", "last ip"); + output_line(outfile, "th", "lalign", "shared net name"); + output_line(outfile, "th", "lalign", "first ip"); + output_line(outfile, "th", "lalign", "last ip"); output_line(outfile, "th", "ralign", "max"); output_line(outfile, "th", "ralign", "cur"); output_line(outfile, "th", "ralign", "percent"); @@ -690,12 +690,12 @@ int output_html(void) for (i = 0; i < num_ranges; i++) { newrow(outfile); if (range_p->shared_net) { - output_line(outfile, "td", "calign", range_p->shared_net->name); + output_line(outfile, "td", "lalign", range_p->shared_net->name); } else { - output_line(outfile, "td", "calign", "not_defined"); + output_line(outfile, "td", "lalign", "not_defined"); } - output_line(outfile, "td", "calign", ntop_ipaddr(&range_p->first_ip)); - output_line(outfile, "td", "calign", ntop_ipaddr(&range_p->last_ip)); + output_line(outfile, "td", "lalign", ntop_ipaddr(&range_p->first_ip)); + output_line(outfile, "td", "lalign", ntop_ipaddr(&range_p->last_ip)); output_double(outfile, "td", range_size); output_double(outfile, "td", range_p->count); output_float(outfile, "td", (float)(100 * range_p->count) / range_size); @@ -719,7 +719,7 @@ int output_html(void) if (config.output_limit[0] & BIT2) { newsection(outfile, "Shared networks:"); newrow(outfile); - output_line(outfile, "th", "calign", "name"); + output_line(outfile, "th", "lalign", "name"); output_line(outfile, "th", "ralign", "max"); output_line(outfile, "th", "ralign", "cur"); output_line(outfile, "th", "ralign", "percent"); @@ -736,7 +736,7 @@ int output_html(void) for (i = 0; i < num_shared_networks; i++) { shared_p++; newrow(outfile); - output_line(outfile, "td", "calign", shared_p->name); + output_line(outfile, "td", "lalign", shared_p->name); output_double(outfile, "td", shared_p->available); output_double(outfile, "td", shared_p->used); output_float(outfile, "td", @@ -765,7 +765,7 @@ int output_html(void) if (config.output_limit[0] & BIT3) { newsection(outfile, "Sum of all ranges:"); newrow(outfile); - output_line(outfile, "th", "calign", "name"); + output_line(outfile, "th", "lalign", "name"); output_line(outfile, "th", "ralign", "max"); output_line(outfile, "th", "ralign", "cur"); output_line(outfile, "th", "ralign", "percent"); @@ -781,7 +781,7 @@ int output_html(void) } if (config.output_limit[1] & BIT3) { newrow(outfile); - output_line(outfile, "td", "calign", shared_networks->name); + output_line(outfile, "td", "lalign", shared_networks->name); output_double(outfile, "td", shared_networks->available); output_double(outfile, "td", shared_networks->used); output_float(outfile, "td",