output: change to full html behaviour

The full html will now print the mtime of dhcpd.leases file in
header. Additionally at the footer of the page the dhcpd-pools
will have package name and version number.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2011-07-08 22:33:13 +02:00
parent 76915512b2
commit cef03de0a9

View file

@ -37,9 +37,12 @@
#include <arpa/inet.h>
#include <err.h>
#include <langinfo.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <time.h>
#define _FILE_OFFSET_BITS 64
#include <inttypes.h>
@ -312,6 +315,20 @@ int output_xml(void)
void html_header(FILE * f)
{
char outstr[200];
struct tm *tmp;
struct stat statbuf;
stat(config.dhcpdlease_file, &statbuf);
tmp = localtime(&statbuf.st_mtime);
if (tmp == NULL) {
err(EXIT_FAILURE, "html_header: localtime");
}
if (strftime(outstr, sizeof(outstr), nl_langinfo(D_T_FMT), tmp) == 0) {
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, "<html>\n");
@ -367,6 +384,7 @@ void html_header(FILE * f)
fprintf(f, " </style>\n");
fprintf(f, "</head>\n");
fprintf(f, "<body>\n");
fprintf(f, "<a name=\"ranges\">The lease file mtime: %s</a>", outstr);
}
void html_footer(FILE * f)
@ -375,7 +393,7 @@ void html_footer(FILE * f)
fprintf(f, "<hr>\n");
fprintf(f, "<p class=created>\nData generated by ");
fprintf(f, "<a href=\"%s\">", PACKAGE_URL);
fprintf(f, "%s</a>.\n</p>\n", PACKAGE_NAME);
fprintf(f, "%s</a>.\n</p>\n", PACKAGE_STRING);
fprintf(f, "<p class=updated>\n");
fprintf(f, "<script type=\"text/javascript\">\n");
fprintf(f, " document.write(\"Last Updated On \" + ");