From: Pekka Riikonen Date: Thu, 14 Aug 2003 19:11:44 +0000 (+0000) Subject: Added CSS class support to "writehtml" command. X-Git-Tag: silc.trunk.merged.silc.1.0.branch.2~12 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=c608e6c1f696ecb50bf375efc97e755a7f0c15c7 Added CSS class support to "writehtml" command. --- diff --git a/apps/silcmap/silcmap.c b/apps/silcmap/silcmap.c index 6e0a16d0..b3506e3d 100644 --- a/apps/silcmap/silcmap.c +++ b/apps/silcmap/silcmap.c @@ -129,6 +129,7 @@ void silc_map_free(SilcMap map) silc_free(map->writemap.filename); silc_free(map->writehtml.filename); + silc_free(map->writehtml.text); silc_free(map->writemaphtml.filename); silc_free(map->writemaphtml.text); silc_free(map->cut.filename); diff --git a/apps/silcmap/silcmap.conf b/apps/silcmap/silcmap.conf index c8a85ab3..9c878b7f 100644 --- a/apps/silcmap/silcmap.conf +++ b/apps/silcmap/silcmap.conf @@ -27,14 +27,15 @@ # the original map image. In this case the lat and lon specify # which portion it is. # -# Command : writehtml { filename = ; }; +# Command : writehtml { filename = ; 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 is defined the it is used as the +# CSS class in the created HTML page. # # Command : cut { lat = ; lon = ; width = ; # height = ; filename = ; }; diff --git a/apps/silcmap/silcmap_bitmap.c b/apps/silcmap/silcmap_bitmap.c index ea4c92c7..dd1c7a6a 100644 --- a/apps/silcmap/silcmap_bitmap.c +++ b/apps/silcmap/silcmap_bitmap.c @@ -38,7 +38,7 @@ bool silc_map_load_ppm(SilcMap map, const char *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; } @@ -78,7 +78,7 @@ bool silc_map_write_ppm(SilcMap map, const char *filename) fp = fopen(filename, "w+"); if (!fp) { - fprintf(stderr, "fopen: %s\n", strerror(errno)); + fprintf(stderr, "fopen: %s: %s\n", strerror(errno), filename); return FALSE; } diff --git a/apps/silcmap/silcmap_command.c b/apps/silcmap/silcmap_command.c index 9cb8f7b7..39242bae 100644 --- a/apps/silcmap/silcmap_command.c +++ b/apps/silcmap/silcmap_command.c @@ -55,6 +55,7 @@ static const SilcConfigTable silc_map_table_writemaphtml[] = 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[] = @@ -466,14 +467,16 @@ SILC_CONFIG_CALLBACK(silc_map_cmd_writehtml) /* 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; diff --git a/apps/silcmap/silcmap_html.c b/apps/silcmap/silcmap_html.c index a8a8183a..7f8f64e4 100644 --- a/apps/silcmap/silcmap_html.c +++ b/apps/silcmap/silcmap_html.c @@ -294,7 +294,7 @@ bool silc_map_writehtml(SilcMap map, SilcMapConnection mapconn) bool silc_map_writehtml_index(SilcMap map) { SilcMapConnection mapconn; - char *hostname, *ip; + char *hostname, *ip, *class; FILE *fp; /* Open for writing */ @@ -305,18 +305,20 @@ bool silc_map_writehtml_index(SilcMap map) } /* Produce a simple HTML index file of all servers */ + class = map->writehtml.text ? map->writehtml.text : "silcmap"; fprintf(fp, "\n"); fprintf(fp, "
\n"); - fprintf(fp, "\n"); + fprintf(fp, "
\n", class); fprintf(fp, - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n"); + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", class, class, class, class, class, class); silc_dlist_start(map->conns); while ((mapconn = silc_dlist_get(map->conns)) != SILC_LIST_END) { @@ -327,14 +329,15 @@ bool silc_map_writehtml_index(SilcMap map) ip = silc_dlist_get(mapconn->ips); fprintf(fp, - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", hostname, mapconn->port, - hostname, ip, mapconn->port, mapconn->country, mapconn->admin); + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", class, class, hostname, mapconn->port, + hostname, class, ip, class, mapconn->port, class, + mapconn->country, class, mapconn->admin); } fprintf(fp, "
HostnameIPv4 AddressPortCountryOper
HostnameIPv4 AddressPortCountryOper
 %s %s %d %s %s
 %s %s %d %s %s

\n");