SILC Map distribution added.
[silc.git] / apps / silcmap / silcmap_html.c
index bc350c6b86e50b59523d1a2e40961c436911e606..cb3c475cbc875b38219d285202ba84f471212799 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2003 Pekka Riikonen
+  Copyright (C) 2003 - 2004 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -46,7 +46,7 @@ bool silc_map_writehtml(SilcMap map, SilcMapConnection mapconn)
 
   /* Write the HTML page */
 
-  fprintf(fp, "<!-- Automatically generated by silcmap --!>\n");
+  fprintf(fp, "<!-- Automatically generated by silcmap -->\n");
   fprintf(fp, "<br /><hr ><br />\n");
 
   /* General stuff */
@@ -153,7 +153,8 @@ bool silc_map_writehtml(SilcMap map, SilcMapConnection mapconn)
 
     fprintf(fp, "<br /><tt><small>\n");
     begin = 0;
-    while (silc_gets(line, sizeof(line) - 1, pdd, pk_len + 1, &begin) != EOF)
+    while ((begin = silc_gets(line, sizeof(line) - 1, pdd, pk_len + 1, 
+                             begin)) != EOF)
       fprintf(fp, "%s<br />\n", line);
     fprintf(fp, "</small></tt><br />\n");
 
@@ -215,67 +216,67 @@ bool silc_map_writehtml(SilcMap map, SilcMapConnection mapconn)
     if (mapconn->clients) {
       fprintf(fp, "<tr><td>&nbsp;&nbsp;");
       fprintf(fp, "Local clients</td><td>&nbsp;:</td><td>&nbsp;%ld</td></tr>\n",
-             mapconn->data.clients);
+             (unsigned long)mapconn->data.clients);
     }
     if (mapconn->channels) {
       fprintf(fp, "<tr><td>&nbsp;&nbsp;");
       fprintf(fp, "Local channels</td><td>&nbsp;:</td><td>&nbsp;%ld</td></tr>\n",
-             mapconn->data.channels);
+             (unsigned long)mapconn->data.channels);
     }
     if (mapconn->server_ops) {
       fprintf(fp, "<tr><td>&nbsp;&nbsp;");
       fprintf(fp, "Local server operators</td><td>&nbsp;:</td><td>&nbsp;%ld</td></tr>\n",
-             mapconn->data.server_ops);
+             (unsigned long)mapconn->data.server_ops);
     }
     if (mapconn->router_ops) {
       fprintf(fp, "<tr><td>&nbsp;&nbsp;");
       fprintf(fp, "Local router operators</td><td>&nbsp;:</td><td>&nbsp;%ld</td></tr>\n",
-             mapconn->data.router_ops);
+             (unsigned long)mapconn->data.router_ops);
     }
     if (mapconn->cell_clients) {
       fprintf(fp, "<tr><td>&nbsp;&nbsp;");
       fprintf(fp, "Cell clients</td><td>&nbsp;:</td><td>&nbsp;%ld</td></tr>\n",
-             mapconn->data.cell_clients);
+             (unsigned long)mapconn->data.cell_clients);
     }
     if (mapconn->cell_channels) {
       fprintf(fp, "<tr><td>&nbsp;&nbsp;");
       fprintf(fp, "Cell channels</td><td>&nbsp;:</td><td>&nbsp;%ld</td></tr>\n",
-             mapconn->data.cell_channels);
+             (unsigned long)mapconn->data.cell_channels);
     }
     if (mapconn->cell_servers) {
       fprintf(fp, "<tr><td>&nbsp;&nbsp;");
       fprintf(fp, "Cell servers</td><td>&nbsp;:</td><td>&nbsp;%ld</td></tr>\n",
-             mapconn->data.cell_servers);
+             (unsigned long)mapconn->data.cell_servers);
     }
     if (mapconn->all_clients) {
       fprintf(fp, "<tr><td>&nbsp;&nbsp;");
       fprintf(fp, "All SILC clients</td><td>&nbsp;:</td><td>&nbsp;%ld</td></tr>\n",
-             mapconn->data.all_clients);
+             (unsigned long)mapconn->data.all_clients);
     }
     if (mapconn->all_channels) {
       fprintf(fp, "<tr><td>&nbsp;&nbsp;");
       fprintf(fp, "All SILC channels</td><td>&nbsp;:</td><td>&nbsp;%ld</td></tr>\n",
-             mapconn->data.all_channels);
+             (unsigned long)mapconn->data.all_channels);
     }
     if (mapconn->all_servers) {
       fprintf(fp, "<tr><td>&nbsp;&nbsp;");
       fprintf(fp, "All SILC servers</td><td>&nbsp;:</td><td>&nbsp;%ld</td></tr>\n",
-             mapconn->data.all_servers);
+             (unsigned long)mapconn->data.all_servers);
     }
     if (mapconn->all_routers) {
       fprintf(fp, "<tr><td>&nbsp;&nbsp;");
       fprintf(fp, "All SILC routers</td><td>&nbsp;:</td><td>&nbsp;%ld</td></tr>\n",
-             mapconn->data.all_routers);
+             (unsigned long)mapconn->data.all_routers);
     }
     if (mapconn->all_server_ops) {
       fprintf(fp, "<tr><td>&nbsp;&nbsp;");
       fprintf(fp, "All SILC server operators</td><td>&nbsp;:</td><td>&nbsp;%ld</td></tr>\n",
-             mapconn->data.all_server_ops);
+             (unsigned long)mapconn->data.all_server_ops);
     }
     if (mapconn->all_router_ops) {
       fprintf(fp, "<tr><td>&nbsp;&nbsp;");
       fprintf(fp, "All SILC router operators</td><td>&nbsp;:</td><td>&nbsp;%ld</td></tr>\n",
-             mapconn->data.all_router_ops);
+             (unsigned long)mapconn->data.all_router_ops);
     }
     fprintf(fp, "</table>\n");
   }
@@ -287,8 +288,8 @@ bool silc_map_writehtml(SilcMap map, SilcMapConnection mapconn)
 
     fprintf(fp, "<br /><tt><small>\n");
     begin = 0;
-    while (silc_gets(line, sizeof(line) - 1, mapconn->data.motd,
-                    strlen(mapconn->data.motd), &begin) != EOF)
+    while ((begin = silc_gets(line, sizeof(line) - 1, mapconn->data.motd,
+                             strlen(mapconn->data.motd), begin)) != EOF)
       fprintf(fp, "%s<br />\n", line);
     fprintf(fp, "</small></tt>\n");
   }
@@ -317,7 +318,7 @@ 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, "<!-- Automatically generated by silcmap -->\n");
   fprintf(fp, "<br />\n");
   fprintf(fp, "<table cellspacing=\"0\" cellpadding=\"0\" "
          "class=\"%s\" border=\"0\">\n", class);
@@ -373,6 +374,10 @@ bool silc_map_writemaphtml(SilcMap map)
 
   for (i = 0; i < map->writemaphtml_count; i++) {
     c = &map->writemaphtml[i];
+    if (c->alon && c->alat) {
+      c->x = silc_map_lon2x(map, c->alon);
+      c->y = silc_map_lat2y(map, c->alat);
+    }
 
     /* Open for writing */
     fp = fopen(c->filename, "w+");
@@ -388,7 +393,7 @@ bool silc_map_writemaphtml(SilcMap map)
 
     memset(url, 0, sizeof(url));
 
-    fprintf(fp, "<!-- Automatically generated by silcmap --!>\n");
+    fprintf(fp, "<!-- Automatically generated by silcmap -->\n");
     fprintf(fp, "<img src=\"%s\" usemap=\"#map\" class=\"silcmap\">\n",
            c->text);
     fprintf(fp, "<map name=\"map\">\n");
@@ -408,6 +413,11 @@ bool silc_map_writemaphtml(SilcMap map)
       /* Print the positions of various items on the map into the map file */
       silc_dlist_start(mapconn->commands);
       while ((cmd = silc_dlist_get(mapconn->commands)) != SILC_LIST_END) {
+       if (cmd->alon && cmd->alat) {
+         cmd->x = silc_map_lon2x(map, cmd->alon);
+         cmd->y = silc_map_lat2y(map, cmd->alat);
+       }
+
        if (cmd->draw_text) {
          w = strlen(cmd->text) * 5;
          h = map->font.height - 2;
@@ -516,7 +526,7 @@ bool silc_map_writerelhtml(SilcMap map)
   /* Produce the reliability graph as HTML file. */
   class = map->writerel.text ? map->writerel.text : "silcmap";
 
-  fprintf(fp, "<!-- Automatically generated by silcmap --!>\n");
+  fprintf(fp, "<!-- Automatically generated by silcmap -->\n");
   fprintf(fp, "<br />\n");
   fprintf(fp, "<table cellspacing=\"0\" cellpadding=\"0\" "
          "class=\"%s\" border=\"0\">\n", class);
@@ -546,7 +556,7 @@ bool silc_map_writerelhtml(SilcMap map)
 
     /* Count the reliability */
     if (try)
-      rel = ((double)success / (double)try) * (double)190.0;
+      rel = ((double)success / (double)try) * (double)160.0;
 
     fprintf(fp, "<tr>\n");
     if (mapconn->html_url)
@@ -556,14 +566,14 @@ bool silc_map_writerelhtml(SilcMap map)
       fprintf(fp,
              "<td align = \"center\" class=\"%s\">&nbsp;<a href=\"%s_%d.html\">%s</a></td>\n", class, hostname, mapconn->port, hostname);
     fprintf(fp,
-           "<td class=\"%s\" width=\"190\">"
-           "<table style=\"border: solid 1px black; width: 190px;\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"%s\"><tr>"
+           "<td class=\"%s\" width=\"160\">"
+           "<table style=\"border: solid 1px black; width: 160px;\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"%s\"><tr>"
            "<td style=\"width: %fpx; height: 10px;\" bgcolor=\"gray\"></td>"
            "<td style=\"width: %fpx; height: 10px;\" bgcolor=\"white\"></td>"
            "</tr></table></td>\n"
            "<td class=\"%s\">%.2f%% - score: %d</td>\n"
            "</tr>\n",
-           class, class, rel, 190 - rel, class,
+           class, class, rel, 160 - rel, class,
            ((double)success / (double)try) * (double)100.0, success);
   }