# the original map image. In this case the lat and lon specify
# which portion it is.
#
-# Command : writehtml { filename = <filename>; };
+# Command : writehtml { filename = <filename>; class = <class>; };
# Example : writehtml { filename = "index.html"; };
# Description : Write the gathered information as HTML pages. Every server
# command will have their own HTML file. The filename is
# based on the hostname of the server. The index HTML file
# will include list of the servers. The generated HTML files
# are quite raw and are intended to be embedded into user's
-# own website.
+# own website. If <class> is defined the it is used as the
+# CSS class in the created HTML page.
#
# Command : cut { lat = <lat>; lon = <lon>; width = <width>;
# height = <height>; filename = <filename>; };
fp = fopen(filename, "r");
if (!fp) {
- fprintf(stderr, "fopen: %s\n", strerror(errno));
+ fprintf(stderr, "fopen: %s: %s\n", strerror(errno), filename);
return FALSE;
}
fp = fopen(filename, "w+");
if (!fp) {
- fprintf(stderr, "fopen: %s\n", strerror(errno));
+ fprintf(stderr, "fopen: %s: %s\n", strerror(errno), filename);
return FALSE;
}
static const SilcConfigTable silc_map_table_writehtml[] =
{
{ "filename", SILC_CONFIG_ARG_STR, silc_map_cmd_writehtml, NULL },
+ { "class", SILC_CONFIG_ARG_STRE, silc_map_cmd_writehtml, NULL },
};
static const SilcConfigTable silc_map_table_cut[] =
/* Will generate HTML pages */
map->writehtml.filename = filename;
+ map->writehtml.text = text; /* class */
map->writehtml.writehtml = TRUE;
- filename = NULL;
+ filename = text = NULL;
return retval;
}
-
if (!strcmp(name, "filename"))
filename = strdup((char *)val);
+ else if (!strcmp(name, "class"))
+ text = strdup((char *)val);
else
retval = SILC_CONFIG_ESILENT;
bool silc_map_writehtml_index(SilcMap map)
{
SilcMapConnection mapconn;
- char *hostname, *ip;
+ char *hostname, *ip, *class;
FILE *fp;
/* Open for writing */
}
/* Produce a simple HTML index file of all servers */
+ class = map->writehtml.text ? map->writehtml.text : "silcmap";
fprintf(fp, "<!-- Automatically generated by silcmap --!>\n");
fprintf(fp, "<br />\n");
- fprintf(fp, "<table cellspacing=\"2\" cellpadding=\"2\" border=\"1\">\n");
+ fprintf(fp, "<table cellspacing=\"0\" cellpadding=\"0\" "
+ "class=\"%s\" border=\"0\">\n", class);
fprintf(fp,
- "<tr>\n"
- "<td align=\"center\"><b>Hostname</b></td>\n"
- "<td align=\"center\"><b>IPv4 Address</b></td>\n"
- "<td align=\"center\"><b>Port</b></td>\n"
- "<td align=\"center\"><b>Country</b></td>\n"
- "<td align=\"center\"><b>Oper</b></td>\n"
- "</tr>\n");
+ "<tr class=\"%s\">\n"
+ "<td align=\"center\" class=\"%s\"><b>Hostname</b></td>\n"
+ "<td align=\"center\" class=\"%s\"><b>IPv4 Address</b></td>\n"
+ "<td align=\"center\" class=\"%s\"><b>Port</b></td>\n"
+ "<td align=\"center\" class=\"%s\"><b>Country</b></td>\n"
+ "<td align=\"center\" class=\"%s\"><b>Oper</b></td>\n"
+ "</tr>\n", class, class, class, class, class, class);
silc_dlist_start(map->conns);
while ((mapconn = silc_dlist_get(map->conns)) != SILC_LIST_END) {
ip = silc_dlist_get(mapconn->ips);
fprintf(fp,
- "<tr>\n"
- "<td align = \"center\"> <a href=\"%s_%d.html\">%s</a></td>\n"
- "<td align = \"center\"> %s</td>\n"
- "<td align = \"center\"> %d</td>\n"
- "<td align = \"center\"> %s</td>\n"
- "<td align = \"center\"> %s</td>\n"
- "</tr>\n", hostname, mapconn->port,
- hostname, ip, mapconn->port, mapconn->country, mapconn->admin);
+ "<tr class=\"%s\">\n"
+ "<td align = \"center\" class=\"%s\"> <a href=\"%s_%d.html\">%s</a></td>\n"
+ "<td align = \"center\" class=\"%s\"> %s</td>\n"
+ "<td align = \"center\" class=\"%s\"> %d</td>\n"
+ "<td align = \"center\" class=\"%s\"> %s</td>\n"
+ "<td align = \"center\" class=\"%s\"> %s</td>\n"
+ "</tr>\n", class, class, hostname, mapconn->port,
+ hostname, class, ip, class, mapconn->port, class,
+ mapconn->country, class, mapconn->admin);
}
fprintf(fp, "</table><br />\n");