{
FILE *fp;
char *hostname;
- char filename[256];
+ char filename[256], line[128];
+ int begin;
/* Generate data filename. First configure hostname is the filename */
silc_dlist_start(mapconn->hostnames);
fprintf(fp, "Country</td><td> :</td><td> %s</td></tr>\n", ident->country);
}
fprintf(fp, "<tr><td> ");
- fprintf(fp, "Fingerprint (SHA1)</td><td> :</td><td> %s</td></tr>\n", fingerprint);
+ fprintf(fp, "Fingerprint (SHA1)</td><td> :</td><td> <tt>%s</tt></td></tr>\n", fingerprint);
fprintf(fp, "<tr><td> ");
- fprintf(fp, "Babbleprint (SHA1)</td><td> :</td><td> %s</td></tr>\n", babbleprint);
+ fprintf(fp, "Babbleprint (SHA1)</td><td> :</td><td> <tt>%s</tt></td></tr>\n", babbleprint);
fprintf(fp, "</table>\n");
pd = fopen(mapconn->public_key, "r");
return FALSE;
pk_len = silc_file_size(mapconn->public_key);
- pdd = silc_calloc(pk_len + 1, sizeof(*pdd));
+ pdd = silc_calloc(pk_len + 2, sizeof(*pdd));
if (!pdd)
return FALSE;
fread(pdd, pk_len, 1, pd);
+ pdd[pk_len] = EOF;
- fprintf(fp, "<pre><tt>\n");
- fprintf(fp, "%s", pdd);
- fprintf(fp, "</tt></pre>\n");
+ fprintf(fp, "<br /><tt><small>\n");
+ begin = 0;
+ while (silc_gets(line, sizeof(line) - 1, pdd, pk_len + 1, &begin) != EOF)
+ fprintf(fp, "%s<br />\n", line);
+ fprintf(fp, "</small></tt><br />\n");
fclose(pd);
silc_free(pdd);
if (mapconn->motd) {
fprintf(fp, " <br /><hr ><br />\n");
fprintf(fp, "<b>Message of the Day:</b> <br />\n");
- fprintf(fp, "<pre><tt>%s</tt><pre>\n", mapconn->data.motd);
+
+ fprintf(fp, "<br /><tt><small>\n");
+ begin = 0;
+ while (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");
}
fprintf(fp, "<br />\n");
fprintf(fp, "<table cellspacing=\"0\" cellpadding=\"0\" "
"class=\"%s\" border=\"0\">\n", class);
fprintf(fp,
- "<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);
+ "<tr>\n"
+ "<td align=\"center\" class=\"%s_header\"><b>Hostname</b></td>\n"
+ "<td align=\"center\" class=\"%s_header\"><b>IPv4 Address</b></td>\n"
+ "<td align=\"center\" class=\"%s_header\"><b>Port</b></td>\n"
+ "<td align=\"center\" class=\"%s_header\"><b>Country</b></td>\n"
+ "<td align=\"center\" class=\"%s_header\"><b>Oper</b></td>\n"
+ "</tr>\n", class, class, class, class, class);
silc_dlist_start(map->conns);
while ((mapconn = silc_dlist_get(map->conns)) != SILC_LIST_END) {
silc_dlist_start(mapconn->ips);
ip = silc_dlist_get(mapconn->ips);
+ fprintf(fp, "<tr>\n");
+ if (mapconn->html_url)
+ fprintf(fp,
+ "<td align = \"center\" class=\"%s\"> <a href=\"%s\">%s</a></td>\n", class, mapconn->html_url, hostname);
+ else
+ fprintf(fp,
+ "<td align = \"center\" class=\"%s\"> <a href=\"%s_%d.html\">%s</a></td>\n", class, hostname, mapconn->port, hostname);
fprintf(fp,
- "<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,
+ "</tr>\n",
+ class, ip, class, mapconn->port, class,
mapconn->country, class, mapconn->admin);
}
bool silc_map_writemaphtml(SilcMap map)
{
SilcMapConnection mapconn;
- SilcMapCommand cmd;
+ SilcMapCommand cmd, c;
char *hostname, url[256];
FILE *fp;
- int xx , yy, w, h;
-
- /* Open for writing */
- fp = fopen(map->writemaphtml.filename, "w+");
- if (!fp) {
- fprintf(stderr, "Could not open file '%s'\n", map->writemaphtml.filename);
- return FALSE;
- }
-
- /* The target may be portion of the original map, so we must make the
- new coordinates relative to the new map. */
- xx = map->writemaphtml.x;
- yy = map->writemaphtml.y;
-
- memset(url, 0, sizeof(url));
-
- fprintf(fp, "<!-- Automatically generated by silcmap --!>\n");
- fprintf(fp, "<br />\n");
- fprintf(fp, "<img src=\"%s\" usemap=\"#map\" border=\"0\">\n",
- map->writemaphtml.text);
- fprintf(fp, "<map name=\"map\">\n");
+ int i, xx , yy, w, h;
- memset(url, 0, sizeof(url));
+ for (i = 0; i < map->writemaphtml_count; i++) {
+ c = &map->writemaphtml[i];
- silc_dlist_start(map->conns);
- while ((mapconn = silc_dlist_get(map->conns)) != SILC_LIST_END) {
- if (mapconn->writemaphtml_url && mapconn->writemaphtml_url[0]) {
- silc_strncat(url, sizeof(url), mapconn->writemaphtml_url,
- strlen(mapconn->writemaphtml_url));
- } else {
- silc_dlist_start(mapconn->hostnames);
- hostname = silc_dlist_get(mapconn->hostnames);
- snprintf(url, sizeof(url) - 1, "%s_%d.html", hostname, mapconn->port);
+ /* Open for writing */
+ fp = fopen(c->filename, "w+");
+ if (!fp) {
+ fprintf(stderr, "Could not open file '%s'\n", c->filename);
+ return FALSE;
}
- /* 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->draw_text) {
- w = strlen(cmd->text) * 5;
- h = map->font.height - 2;
- fprintf(fp,
- "<area shape=\"rect\" coords=\"%d,%d,%d,%d\" href=\"%s\">\n",
- (int)(cmd->x - xx), (int)(cmd->y - yy), w, h, url);
+ /* The target may be portion of the original map, so we must make the
+ new coordinates relative to the new map. */
+ xx = c->x;
+ yy = c->y;
+
+ memset(url, 0, sizeof(url));
+
+ 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");
+
+ silc_dlist_start(map->conns);
+ while ((mapconn = silc_dlist_get(map->conns)) != SILC_LIST_END) {
+ memset(url, 0, sizeof(url));
+ if (mapconn->html_url && mapconn->html_url[0]) {
+ silc_strncat(url, sizeof(url), mapconn->html_url,
+ strlen(mapconn->html_url));
+ } else {
+ silc_dlist_start(mapconn->hostnames);
+ hostname = silc_dlist_get(mapconn->hostnames);
+ snprintf(url, sizeof(url) - 1, "%s_%d.html", hostname, mapconn->port);
}
- if (cmd->draw_circle) {
- w = 4;
- fprintf(fp,
- "<area shape=\"circle\" coords=\"%d,%d,%d\" href=\"%s\">\n",
- (int)(cmd->x - xx), (int)(cmd->y - yy), w, url);
- if (cmd->text) {
+ /* 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->draw_text) {
w = strlen(cmd->text) * 5;
h = map->font.height - 2;
fprintf(fp,
"<area shape=\"rect\" coords=\"%d,%d,%d,%d\" href=\"%s\">\n",
- (int)(cmd->x - xx + cmd->lposx),
- (int)(cmd->y - yy - cmd->lposy),
- (int)(cmd->x - xx + cmd->lposx + w),
- (int)(cmd->y - yy - cmd->lposy + h), url);
+ (int)(cmd->x - xx), (int)(cmd->y - yy), w, h, url);
}
- }
- if (cmd->draw_rectangle) {
- w = 7;
- h = 6;
- fprintf(fp,
- "<area shape=\"rect\" coords=\"%d,%d,%d,%d\" href=\"%s\">\n",
- (int)(cmd->x - xx), (int)(cmd->y - yy),
- (int)(cmd->x - xx + w), (int)(cmd->y - yy + h), url);
- if (cmd->text) {
- w = strlen(cmd->text) * 5;
- h = map->font.height - 2;
+ if (cmd->draw_circle) {
+ w = 4;
+ fprintf(fp,
+ "<area shape=\"circle\" coords=\"%d,%d,%d\" href=\"%s\">\n",
+ (int)(cmd->x - xx), (int)(cmd->y - yy), w, url);
+ if (cmd->text) {
+ w = strlen(cmd->text) * 5;
+ h = map->font.height - 2;
+ fprintf(fp,
+ "<area shape=\"rect\" coords=\"%d,%d,%d,%d\" href=\"%s\">\n",
+ (int)(cmd->x - xx + cmd->lposx),
+ (int)(cmd->y - yy - cmd->lposy),
+ (int)(cmd->x - xx + cmd->lposx + w),
+ (int)(cmd->y - yy - cmd->lposy + h), url);
+ }
+ }
+
+ if (cmd->draw_rectangle) {
+ w = 7;
+ h = 6;
fprintf(fp,
"<area shape=\"rect\" coords=\"%d,%d,%d,%d\" href=\"%s\">\n",
- (int)(cmd->x - xx + cmd->lposx),
- (int)(cmd->y - yy - cmd->lposy),
- (int)(cmd->x - xx + cmd->lposx + w),
- (int)(cmd->y - yy - cmd->lposy + h), url);
+ (int)(cmd->x - xx), (int)(cmd->y - yy),
+ (int)(cmd->x - xx + w), (int)(cmd->y - yy + h), url);
+ if (cmd->text) {
+ w = strlen(cmd->text) * 5;
+ h = map->font.height - 2;
+ fprintf(fp,
+ "<area shape=\"rect\" coords=\"%d,%d,%d,%d\" href=\"%s\">\n",
+ (int)(cmd->x - xx + cmd->lposx),
+ (int)(cmd->y - yy - cmd->lposy),
+ (int)(cmd->x - xx + cmd->lposx + w),
+ (int)(cmd->y - yy - cmd->lposy + h), url);
+ }
}
}
}
- }
- fprintf(fp, "</map><br />\n");
- fclose(fp);
+ fprintf(fp, "</map>\n");
+ fclose(fp);
+ }
return TRUE;
}