mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-16 15:57:00 +00:00
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:
parent
c4e5ef6198
commit
9d1241c006
1 changed files with 68 additions and 68 deletions
136
src/output.c
136
src/output.c
|
|
@ -475,59 +475,59 @@ static void html_header(FILE *restrict f)
|
||||||
errx(EXIT_FAILURE, "html_header: strftime returned 0");
|
errx(EXIT_FAILURE, "html_header: strftime returned 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \n");
|
fprintf(f, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n");
|
||||||
fprintf(f, " \"http://www.w3.org/TR/html4/strict.dtd\">\n");
|
fprintf(f, "\"http://www.w3.org/TR/html4/loose.dtd\">\n");
|
||||||
fprintf(f, "<html>\n");
|
fprintf(f, "<html>\n");
|
||||||
fprintf(f, "<head>\n");
|
fprintf(f, "<head>\n");
|
||||||
fprintf(f, "<meta http-equiv=\"Content-Type\" ");
|
fprintf(f, "<meta http-equiv=\"Content-Type\" ");
|
||||||
fprintf(f, "content=\"text/html; charset=iso-8859-1\">\n");
|
fprintf(f, "content=\"text/html; charset=iso-8859-1\">\n");
|
||||||
fprintf(f, " <title>ISC dhcpd stats</title>\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, "<!--\n");
|
||||||
fprintf(f, " table.dhcpd-pools {\n");
|
fprintf(f, "table.dhcpd-pools {\n");
|
||||||
fprintf(f, " color: black;\n");
|
fprintf(f, "color: black;\n");
|
||||||
fprintf(f, " vertical-align: middle;\n");
|
fprintf(f, "vertical-align: middle;\n");
|
||||||
fprintf(f, " text-align: center;\n");
|
fprintf(f, "text-align: center;\n");
|
||||||
fprintf(f, " }\n");
|
fprintf(f, "}\n");
|
||||||
fprintf(f, " table.dhcpd-pools th.section {\n");
|
fprintf(f, "table.dhcpd-pools th.section {\n");
|
||||||
fprintf(f, " color: black;\n");
|
fprintf(f, "color: black;\n");
|
||||||
fprintf(f, " font-size: large;\n");
|
fprintf(f, "font-size: large;\n");
|
||||||
fprintf(f, " vertical-align: middle;\n");
|
fprintf(f, "vertical-align: middle;\n");
|
||||||
fprintf(f, " text-align: left;\n");
|
fprintf(f, "text-align: left;\n");
|
||||||
fprintf(f, " }\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, "color: black;\n");
|
||||||
fprintf(f, " vertical-align: middle;\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, "text-decoration: underline;\n");
|
||||||
fprintf(f, " }\n");
|
fprintf(f, "}\n");
|
||||||
fprintf(f, " table.dhcpd-pools th.ralign {\n");
|
fprintf(f, "table.dhcpd-pools th.ralign {\n");
|
||||||
fprintf(f, " color: black;\n");
|
fprintf(f, "color: black;\n");
|
||||||
fprintf(f, " vertical-align: middle;\n");
|
fprintf(f, "vertical-align: middle;\n");
|
||||||
fprintf(f, " text-align: right;\n");
|
fprintf(f, "text-align: right;\n");
|
||||||
fprintf(f, " text-decoration: underline;\n");
|
fprintf(f, "text-decoration: underline;\n");
|
||||||
fprintf(f, " }\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, "color: black;\n");
|
||||||
fprintf(f, " vertical-align: middle;\n");
|
fprintf(f, "vertical-align: middle;\n");
|
||||||
fprintf(f, " text-align: center;\n");
|
fprintf(f, "text-align: left;\n");
|
||||||
fprintf(f, " }\n");
|
fprintf(f, "}\n");
|
||||||
fprintf(f, " table.dhcpd-pools td.ralign {\n");
|
fprintf(f, "table.dhcpd-pools td.ralign {\n");
|
||||||
fprintf(f, " color: black;\n");
|
fprintf(f, "color: black;\n");
|
||||||
fprintf(f, " vertical-align: middle;\n");
|
fprintf(f, "vertical-align: middle;\n");
|
||||||
fprintf(f, " text-align: right;\n");
|
fprintf(f, "text-align: right;\n");
|
||||||
fprintf(f, " }\n");
|
fprintf(f, "}\n");
|
||||||
fprintf(f, " p.created {\n");
|
fprintf(f, "p.created {\n");
|
||||||
fprintf(f, " font-size: small;\n");
|
fprintf(f, "font-size: small;\n");
|
||||||
fprintf(f, " color: grey;\n");
|
fprintf(f, "color: grey;\n");
|
||||||
fprintf(f, " }\n");
|
fprintf(f, "}\n");
|
||||||
fprintf(f, " p.updated {\n");
|
fprintf(f, "p.updated {\n");
|
||||||
fprintf(f, " font-size: small;\n");
|
fprintf(f, "font-size: small;\n");
|
||||||
fprintf(f, " color: grey;\n");
|
fprintf(f, "color: grey;\n");
|
||||||
fprintf(f, " font-style: italic;\n");
|
fprintf(f, "font-style: italic;\n");
|
||||||
fprintf(f, " }\n");
|
fprintf(f, "}\n");
|
||||||
fprintf(f, " -->\n");
|
fprintf(f, "-->\n");
|
||||||
fprintf(f, " </style>\n");
|
fprintf(f, "</style>\n");
|
||||||
fprintf(f, "</head>\n");
|
fprintf(f, "</head>\n");
|
||||||
fprintf(f, "<body>\n");
|
fprintf(f, "<body>\n");
|
||||||
fprintf(f, "<a name=\"ranges\">The lease file mtime: %s</a>", outstr);
|
fprintf(f, "<a name=\"ranges\">The lease file mtime: %s</a>", outstr);
|
||||||
|
|
@ -541,12 +541,12 @@ static void html_footer(FILE *restrict f)
|
||||||
{
|
{
|
||||||
fprintf(f, "<p><br></p>\n");
|
fprintf(f, "<p><br></p>\n");
|
||||||
fprintf(f, "<hr>\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, "<a href=\"%s\">", PACKAGE_URL);
|
||||||
fprintf(f, "%s</a>.\n</p>\n", PACKAGE_STRING);
|
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, "<script type=\"text/javascript\">\n");
|
||||||
fprintf(f, " document.write(\"Last Updated On \" + ");
|
fprintf(f, "document.write(\"Last Updated On \" + ");
|
||||||
fprintf(f, "document.lastModified + \".\")\n");
|
fprintf(f, "document.lastModified + \".\")\n");
|
||||||
fprintf(f, "</script>\n<br>\n</p>\n");
|
fprintf(f, "</script>\n<br>\n</p>\n");
|
||||||
fprintf(f, "</body>\n");
|
fprintf(f, "</body>\n");
|
||||||
|
|
@ -568,7 +568,7 @@ static void newrow(FILE *restrict f)
|
||||||
*/
|
*/
|
||||||
static void endrow(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.
|
/*! \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,
|
static void output_line(FILE *restrict f, char const *restrict type,
|
||||||
char const *restrict class, char const *restrict text)
|
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.
|
/*! \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)
|
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.
|
/*! \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)
|
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.
|
/*! \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)
|
static void newsection(FILE *restrict f, char const *restrict title)
|
||||||
{
|
{
|
||||||
newrow(f);
|
newrow(f);
|
||||||
output_line(f, "td", "calign", " ");
|
output_line(f, "td", "lalign", " ");
|
||||||
endrow(f);
|
endrow(f);
|
||||||
newrow(f);
|
newrow(f);
|
||||||
output_line(f, "th", "section", title);
|
output_line(f, "th", "section", title);
|
||||||
|
|
@ -671,9 +671,9 @@ int output_html(void)
|
||||||
if (config.output_limit[0] & BIT1) {
|
if (config.output_limit[0] & BIT1) {
|
||||||
newsection(outfile, "Ranges:");
|
newsection(outfile, "Ranges:");
|
||||||
newrow(outfile);
|
newrow(outfile);
|
||||||
output_line(outfile, "th", "calign", "shared net name");
|
output_line(outfile, "th", "lalign", "shared net name");
|
||||||
output_line(outfile, "th", "calign", "first ip");
|
output_line(outfile, "th", "lalign", "first ip");
|
||||||
output_line(outfile, "th", "calign", "last ip");
|
output_line(outfile, "th", "lalign", "last ip");
|
||||||
output_line(outfile, "th", "ralign", "max");
|
output_line(outfile, "th", "ralign", "max");
|
||||||
output_line(outfile, "th", "ralign", "cur");
|
output_line(outfile, "th", "ralign", "cur");
|
||||||
output_line(outfile, "th", "ralign", "percent");
|
output_line(outfile, "th", "ralign", "percent");
|
||||||
|
|
@ -690,12 +690,12 @@ int output_html(void)
|
||||||
for (i = 0; i < num_ranges; i++) {
|
for (i = 0; i < num_ranges; i++) {
|
||||||
newrow(outfile);
|
newrow(outfile);
|
||||||
if (range_p->shared_net) {
|
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 {
|
} 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", "lalign", 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->last_ip));
|
||||||
output_double(outfile, "td", range_size);
|
output_double(outfile, "td", range_size);
|
||||||
output_double(outfile, "td", range_p->count);
|
output_double(outfile, "td", range_p->count);
|
||||||
output_float(outfile, "td", (float)(100 * range_p->count) / range_size);
|
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) {
|
if (config.output_limit[0] & BIT2) {
|
||||||
newsection(outfile, "Shared networks:");
|
newsection(outfile, "Shared networks:");
|
||||||
newrow(outfile);
|
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", "max");
|
||||||
output_line(outfile, "th", "ralign", "cur");
|
output_line(outfile, "th", "ralign", "cur");
|
||||||
output_line(outfile, "th", "ralign", "percent");
|
output_line(outfile, "th", "ralign", "percent");
|
||||||
|
|
@ -736,7 +736,7 @@ int output_html(void)
|
||||||
for (i = 0; i < num_shared_networks; i++) {
|
for (i = 0; i < num_shared_networks; i++) {
|
||||||
shared_p++;
|
shared_p++;
|
||||||
newrow(outfile);
|
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->available);
|
||||||
output_double(outfile, "td", shared_p->used);
|
output_double(outfile, "td", shared_p->used);
|
||||||
output_float(outfile, "td",
|
output_float(outfile, "td",
|
||||||
|
|
@ -765,7 +765,7 @@ int output_html(void)
|
||||||
if (config.output_limit[0] & BIT3) {
|
if (config.output_limit[0] & BIT3) {
|
||||||
newsection(outfile, "Sum of all ranges:");
|
newsection(outfile, "Sum of all ranges:");
|
||||||
newrow(outfile);
|
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", "max");
|
||||||
output_line(outfile, "th", "ralign", "cur");
|
output_line(outfile, "th", "ralign", "cur");
|
||||||
output_line(outfile, "th", "ralign", "percent");
|
output_line(outfile, "th", "ralign", "percent");
|
||||||
|
|
@ -781,7 +781,7 @@ int output_html(void)
|
||||||
}
|
}
|
||||||
if (config.output_limit[1] & BIT3) {
|
if (config.output_limit[1] & BIT3) {
|
||||||
newrow(outfile);
|
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->available);
|
||||||
output_double(outfile, "td", shared_networks->used);
|
output_double(outfile, "td", shared_networks->used);
|
||||||
output_float(outfile, "td",
|
output_float(outfile, "td",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue