Added CSS class support to "writehtml" command.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 14 Aug 2003 19:11:44 +0000 (19:11 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 14 Aug 2003 19:11:44 +0000 (19:11 +0000)
apps/silcmap/silcmap.c
apps/silcmap/silcmap.conf
apps/silcmap/silcmap_bitmap.c
apps/silcmap/silcmap_command.c
apps/silcmap/silcmap_html.c

index 6e0a16d0cb28fef8136ea7d8e9f0d18e92e00c97..b3506e3d87996aa9b2d19b22c11350adb3d16f85 100644 (file)
@@ -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);
index c8a85ab376465881a1907fd7043abcf0f40af05d..9c878b7f116bef6b8b07472e401627378c5d192a 100644 (file)
 #               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>; };
index ea4c92c7a839c8e6690bdd5d3d2413c80dc4bdaf..dd1c7a6a0e641d03ad1919eac5d11a2fefe0d6dd 100644 (file)
@@ -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;
   }
 
index 9cb8f7b793965786228aa55761b70323ed4da3e7..39242bae6b2d2514988b8493e213e7d35a9b8ad9 100644 (file)
@@ -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;
 
index a8a8183af1f4e9991903f215791a1cd477142a24..7f8f64e42fd5db8073f70d62ed20e119a282a82f 100644 (file)
@@ -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, "<!-- 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) {
@@ -327,14 +329,15 @@ bool silc_map_writehtml_index(SilcMap map)
     ip = silc_dlist_get(mapconn->ips);
 
     fprintf(fp,
-           "<tr>\n"
-           "<td align = \"center\">&nbsp;<a href=\"%s_%d.html\">%s</a></td>\n"
-           "<td align = \"center\">&nbsp;%s</td>\n"
-           "<td align = \"center\">&nbsp;%d</td>\n"
-           "<td align = \"center\">&nbsp;%s</td>\n"
-           "<td align = \"center\">&nbsp;%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\">&nbsp;<a href=\"%s_%d.html\">%s</a></td>\n"
+           "<td align = \"center\" class=\"%s\">&nbsp;%s</td>\n"
+           "<td align = \"center\" class=\"%s\">&nbsp;%d</td>\n"
+           "<td align = \"center\" class=\"%s\">&nbsp;%s</td>\n"
+           "<td align = \"center\" class=\"%s\">&nbsp;%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");