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 <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2015-05-02 19:40:06 +01:00
parent c4e5ef6198
commit 9d1241c006

View file

@ -475,14 +475,14 @@ static void html_header(FILE *restrict f)
errx(EXIT_FAILURE, "html_header: strftime returned 0");
}
fprintf(f, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \n");
fprintf(f, " \"http://www.w3.org/TR/html4/strict.dtd\">\n");
fprintf(f, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n");
fprintf(f, "\"http://www.w3.org/TR/html4/loose.dtd\">\n");
fprintf(f, "<html>\n");
fprintf(f, "<head>\n");
fprintf(f, "<meta http-equiv=\"Content-Type\" ");
fprintf(f, "content=\"text/html; charset=iso-8859-1\">\n");
fprintf(f, "<title>ISC dhcpd stats</title>\n");
fprintf(f, " <style TYPE=\"text/css\">\n");
fprintf(f, "<style type=\"text/css\">\n");
fprintf(f, "<!--\n");
fprintf(f, "table.dhcpd-pools {\n");
fprintf(f, "color: black;\n");
@ -495,10 +495,10 @@ static void html_header(FILE *restrict f)
fprintf(f, "vertical-align: middle;\n");
fprintf(f, "text-align: left;\n");
fprintf(f, "}\n");
fprintf(f, " table.dhcpd-pools th.calign {\n");
fprintf(f, "table.dhcpd-pools th.lalign {\n");
fprintf(f, "color: black;\n");
fprintf(f, "vertical-align: middle;\n");
fprintf(f, " text-align: center;\n");
fprintf(f, "text-align: left;\n");
fprintf(f, "text-decoration: underline;\n");
fprintf(f, "}\n");
fprintf(f, "table.dhcpd-pools th.ralign {\n");
@ -507,10 +507,10 @@ static void html_header(FILE *restrict f)
fprintf(f, "text-align: right;\n");
fprintf(f, "text-decoration: underline;\n");
fprintf(f, "}\n");
fprintf(f, " table.dhcpd-pools td.calign {\n");
fprintf(f, "table.dhcpd-pools td.lalign {\n");
fprintf(f, "color: black;\n");
fprintf(f, "vertical-align: middle;\n");
fprintf(f, " text-align: center;\n");
fprintf(f, "text-align: left;\n");
fprintf(f, "}\n");
fprintf(f, "table.dhcpd-pools td.ralign {\n");
fprintf(f, "color: black;\n");
@ -541,10 +541,10 @@ static void html_footer(FILE *restrict f)
{
fprintf(f, "<p><br></p>\n");
fprintf(f, "<hr>\n");
fprintf(f, "<p class=created>\nData generated by ");
fprintf(f, "<p class=\"created\">\nData generated by ");
fprintf(f, "<a href=\"%s\">", PACKAGE_URL);
fprintf(f, "%s</a>.\n</p>\n", PACKAGE_STRING);
fprintf(f, "<p class=updated>\n");
fprintf(f, "<p class=\"updated\">\n");
fprintf(f, "<script type=\"text/javascript\">\n");
fprintf(f, "document.write(\"Last Updated On \" + ");
fprintf(f, "document.lastModified + \".\")\n");
@ -568,7 +568,7 @@ static void newrow(FILE *restrict f)
*/
static void endrow(FILE *restrict f)
{
fprintf(f, "</tr>\n\n");
fprintf(f, "</tr>\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</%s>\n", type, class, text, type);
fprintf(f, "<%s class=\"%s\">%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</%s>\n", type, d, type);
fprintf(f, "<%s class=\"ralign\">%g</%s>\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</%s>\n", type, fl, type);
fprintf(f, "<%s class=\"ralign\">%.3f</%s>\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", "&nbsp;");
output_line(f, "td", "lalign", "&nbsp;");
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",