*** wmlgen.c Tue Dec 18 10:53:15 2007 --- wmlgen.c.htmlversion Tue Dec 18 10:53:07 2007 *************** *** 59,70 **** static char *wml_colorname(int color) { switch (color) { ! case COL_GREEN: return "GR"; break; ! case COL_RED: return "RE"; break; ! case COL_YELLOW: return "YE"; break; ! case COL_PURPLE: return "PU"; break; ! case COL_CLEAR: return "CL"; break; ! case COL_BLUE: return "BL"; break; } return ""; --- 59,70 ---- static char *wml_colorname(int color) { switch (color) { ! case COL_GREEN: return ""; break; ! case COL_RED: return ""; break; ! case COL_YELLOW: return ""; break; ! case COL_PURPLE: return ""; break; ! case COL_CLEAR: return ""; break; ! case COL_BLUE: return ""; break; } return ""; *************** *** 72,84 **** static void wml_header(FILE *output, char *cardid, int idpart) { ! fprintf(output, "\n"); ! fprintf(output, "\n"); ! fprintf(output, "\n"); ! fprintf(output, "\n"); ! fprintf(output, "\n"); ! fprintf(output, "\n"); ! fprintf(output, "\n", cardid, idpart); } --- 72,78 ---- static void wml_header(FILE *output, char *cardid, int idpart) { ! fprintf(output, " \n"); } *************** *** 95,101 **** sprintf(hobbitdreq, "hobbitdlog %s.%s", host->hostname, entry->column->name); hobbitdresult = sendmessage(hobbitdreq, NULL, NULL, &logbuf, 1, BBTALK_TIMEOUT); if ((hobbitdresult != BB_OK) || (logbuf == NULL) || (strlen(logbuf) == 0)) { ! errprintf("WML: Status not available\n"); return; } --- 89,95 ---- sprintf(hobbitdreq, "hobbitdlog %s.%s", host->hostname, entry->column->name); hobbitdresult = sendmessage(hobbitdreq, NULL, NULL, &logbuf, 1, BBTALK_TIMEOUT); if ((hobbitdresult != BB_OK) || (logbuf == NULL) || (strlen(logbuf) == 0)) { ! //errprintf("WML: Status not available\n"); return; } *************** *** 111,117 **** nextline = msg; ! sprintf(fn, "%s/%s.%s.wml", wmldir, host->hostname, entry->column->name); fd = fopen(fn, "w"); if (fd == NULL) { errprintf("Cannot create file %s\n", fn); --- 105,111 ---- nextline = msg; ! sprintf(fn, "%s/%s.%s.html", wmldir, host->hostname, entry->column->name); fd = fopen(fn, "w"); if (fd == NULL) { errprintf("Cannot create file %s\n", fn); *************** *** 120,130 **** wml_header(fd, "name", 1); fprintf(fd, "

\n"); ! fprintf(fd, "Host
\n", host->hostname); ! fprintf(fd, "%s

\n", timestamp); ! fprintf(fd, "

\n"); fprintf(fd, "%s.%s

\n", host->hostname, entry->column->name); /* * We need to parse the logfile a bit to get a decent WML * card that contains the logfile. bbd does this for --- 114,132 ---- wml_header(fd, "name", 1); fprintf(fd, "

\n"); ! fprintf(fd, "%s\n", timestamp); ! fprintf(fd, "
Host
\n", host->hostname); ! fprintf(fd, "Hourly Graph
\n", host->hostname,entry->column->name); ! fprintf(fd, "Daily Graph
\n", host->hostname,entry->column->name); ! fprintf(fd, "Weekly Graph
\n", host->hostname,entry->column->name); ! fprintf(fd, "Monthly Graph
\n", host->hostname,entry->column->name); ! fprintf(fd, "

\n"); fprintf(fd, "%s.%s

\n", host->hostname, entry->column->name); + fprintf(fd,"

"); + fprintf(fd,"


", entry->column->name,host->hostname ); + + /* * We need to parse the logfile a bit to get a decent WML * card that contains the logfile. bbd does this for *************** *** 184,217 **** p = endtag+1; } } else if (*p == '>') { strcpy(outp, ">"); outp += 4; p++; } else if (strncmp(p, "&red", 4) == 0) { ! strcpy(outp, "red"); ! outp += 10; p += 4; } else if (strncmp(p, "&green", 6) == 0) { ! strcpy(outp, "green"); ! outp += 12; p += 6; } else if (strncmp(p, "&purple", 7) == 0) { ! strcpy(outp, "purple"); ! outp += 13; p += 7; } else if (strncmp(p, "&yellow", 7) == 0) { ! strcpy(outp, "yellow"); ! outp += 13; p += 7; } else if (strncmp(p, "&clear", 6) == 0) { ! strcpy(outp, "clear"); ! outp += 12; p += 6; } else if (strncmp(p, "&blue", 5) == 0) { ! strcpy(outp, "blue"); ! outp += 11; p += 5; } else if (*p == '&') { strcpy(outp, "&"); outp += 5; p++; --- 186,241 ---- p = endtag+1; } } + else if (*p == '>') { strcpy(outp, ">"); outp += 4; p++; } else if (strncmp(p, "&red", 4) == 0) { ! strcpy(outp, ""); ! outp += 23; p += 4; } else if (strncmp(p, "&green", 6) == 0) { ! strcpy(outp, ""); ! outp += 25; p += 6; } else if (strncmp(p, "&purple", 7) == 0) { ! strcpy(outp, ""); ! outp += 26; p += 7; } else if (strncmp(p, "&yellow", 7) == 0) { ! strcpy(outp, ""); ! outp += 26; p += 7; } else if (strncmp(p, "&clear", 6) == 0) { ! strcpy(outp, ""); ! outp += 25; p += 6; } else if (strncmp(p, "&blue", 5) == 0) { ! strcpy(outp, ""); ! outp += 24; p += 5; } + + else if (strncmp(p, "red", 3) == 0) { + strcpy(outp, ""); + outp += 18; p += 3; + } + else if (strncmp(p, "yellow", 6) == 0) { + strcpy(outp, ""); + outp += 21; p += 6; + } + else if (strncmp(p, "purple", 6) == 0) { + strcpy(outp, ""); + outp += 21; p += 6; + } + else if (strncmp(p, "blue", 4) == 0) { + strcpy(outp, ""); + outp += 19; p += 4; + } + else if (strncmp(p, "green", 6) == 0) { + strcpy(outp, ""); + outp += 21; p += 6; + } else if (*p == '&') { strcpy(outp, "&"); outp += 5; p++; *************** *** 233,239 **** *outp = '\0'; if (strlen(lineout)) fprintf(fd, "%s\n
\n", lineout); } ! fprintf(fd, "

\n"); fclose(fd); if (logbuf) xfree(logbuf); --- 257,263 ---- *outp = '\0'; if (strlen(lineout)) fprintf(fd, "%s\n
\n", lineout); } ! fprintf(fd, "

\n"); fclose(fd); if (logbuf) xfree(logbuf); *************** *** 285,310 **** for (h = hostlistBegin(); (h); h = hostlistNext()) { h->hostentry->wapcolor = COL_GREEN; for (t = h->hostentry->entries; (t); t = t->next) { - if (t->onwap && ((t->color == COL_RED) || (t->color == COL_YELLOW))) { generate_wml_statuscard(h->hostentry, t); h->hostentry->anywaps = 1; - } - else { - /* Clear the onwap flag - makes testing later a bit simpler */ - t->onwap = 0; - } if (t->onwap && (t->color > h->hostentry->wapcolor)) h->hostentry->wapcolor = t->color; } /* Update the bb2wapcolor */ ! if ( (h->hostentry->wapcolor == COL_RED) || (h->hostentry->wapcolor == COL_YELLOW) ) { ! if (h->hostentry->wapcolor > bb2wapcolor) bb2wapcolor = h->hostentry->wapcolor; ! } } /* Start the BB2 WML card */ ! sprintf(bb2fn, "%s/bb2.wml.tmp", wmldir); bb2fd = fopen(bb2fn, "w"); if (bb2fd == NULL) { errprintf("Cannot open BB2 WML file %s\n", bb2fn); --- 309,327 ---- for (h = hostlistBegin(); (h); h = hostlistNext()) { h->hostentry->wapcolor = COL_GREEN; for (t = h->hostentry->entries; (t); t = t->next) { generate_wml_statuscard(h->hostentry, t); h->hostentry->anywaps = 1; if (t->onwap && (t->color > h->hostentry->wapcolor)) h->hostentry->wapcolor = t->color; + if(h->hostentry->wapcolor == COL_CLEAR) h->hostentry->wapcolor = COL_GREEN ; } /* Update the bb2wapcolor */ ! if (h->hostentry->wapcolor > bb2wapcolor) bb2wapcolor = h->hostentry->wapcolor; } /* Start the BB2 WML card */ ! sprintf(bb2fn, "%s/bb2.html.tmp", wmldir); bb2fd = fopen(bb2fn, "w"); if (bb2fd == NULL) { errprintf("Cannot open BB2 WML file %s\n", bb2fn); *************** *** 314,327 **** /* Standard BB2 wap header */ wml_header(bb2fd, "card", bb2part); fprintf(bb2fd, "

\n"); ! fprintf(bb2fd, "%s

\n", timestamp); ! fprintf(bb2fd, "

\n"); ! fprintf(bb2fd, "Summary Status
%s

\n", colorname(bb2wapcolor)); - /* All green ? Just say so */ - if (bb2wapcolor == COL_GREEN) { - fprintf(bb2fd, "All is OK
\n"); - } /* Now loop through the hostlist again, and generate the bb2wap links and host pages */ for (h = hostlistBegin(); (h); h = hostlistNext()) { --- 331,338 ---- /* Standard BB2 wap header */ wml_header(bb2fd, "card", bb2part); fprintf(bb2fd, "

\n"); ! fprintf(bb2fd, "Summary Status
%s

" , colorname(bb2wapcolor), colorname(bb2wapcolor)); /* Now loop through the hostlist again, and generate the bb2wap links and host pages */ for (h = hostlistBegin(); (h); h = hostlistNext()) { *************** *** 328,334 **** if (h->hostentry->anywaps) { /* Create the host WAP card, with links to individual test results */ ! sprintf(hostfn, "%s/%s.wml", wmldir, h->hostentry->hostname); hostfd = fopen(hostfn, "w"); if (hostfd == NULL) { errprintf("Cannot create file %s\n", hostfn); --- 339,345 ---- if (h->hostentry->anywaps) { /* Create the host WAP card, with links to individual test results */ ! sprintf(hostfn, "%s/%s.html", wmldir, h->hostentry->hostname); hostfd = fopen(hostfn, "w"); if (hostfd == NULL) { errprintf("Cannot create file %s\n", hostfn); *************** *** 337,408 **** wml_header(hostfd, "name", 1); fprintf(hostfd, "

\n"); - fprintf(hostfd, "Overall
\n"); fprintf(hostfd, "%s

\n", timestamp); fprintf(hostfd, "

\n"); fprintf(hostfd, "%s

\n", h->hostentry->hostname); for (t = h->hostentry->entries; (t); t = t->next) { if (t->onwap) { ! fprintf(hostfd, "%s%s %s
\n", t->column->name, wml_colorname(t->color), ! (t->acked ? "x" : ""), ! h->hostentry->hostname, t->column->name, t->column->name); } } ! fprintf(hostfd, "\n

\n"); fclose(hostfd); /* Create the link from the bb2 wap card to the host card */ ! fprintf(bb2fd, "%s %s
\n", h->hostentry->hostname, wml_colorname(h->hostentry->wapcolor), ! h->hostentry->hostname, h->hostentry->hostname); - /* - * Gross hack. Some WAP phones cannot handle large cards. - * So if the card grows larger than WMLMAXCHARS, split it into - * multiple files and link from one file to the next. - */ - if (ftello(bb2fd) >= wmlmaxchars) { - char oldbb2fn[PATH_MAX]; - - /* WML link is from the bb2fn except leading wmldir+'/' */ - strcpy(oldbb2fn, bb2fn+strlen(wmldir)+1); - - bb2part++; - - fprintf(bb2fd, "
Next\n", bb2part); - fprintf(bb2fd, "

\n"); - fclose(bb2fd); - - /* Start a new BB2 WML card */ - sprintf(bb2fn, "%s/bb2-%d.wml", wmldir, bb2part); - bb2fd = fopen(bb2fn, "w"); - if (bb2fd == NULL) { - errprintf("Cannot open BB2 WML file %s\n", bb2fn); - return; - } - wml_header(bb2fd, "card", bb2part); - fprintf(bb2fd, "

\n"); - fprintf(bb2fd, "Previous
\n", oldbb2fn); - fprintf(bb2fd, "%s

\n", timestamp); - fprintf(bb2fd, "

\n"); - fprintf(bb2fd, "Summary Status
%s

\n", colorname(bb2wapcolor)); - } } } ! fprintf(bb2fd, "

\n"); fclose(bb2fd); if (chdir(wmldir) == 0) { /* Rename the top-level file into place now */ ! rename("bb2.wml.tmp", "bb2.wml"); /* Make sure there is the index.wml file pointing to bb2.wml */ ! symlink("bb2.wml", "index.wml"); } return; --- 348,391 ---- wml_header(hostfd, "name", 1); fprintf(hostfd, "

\n"); fprintf(hostfd, "%s

\n", timestamp); + fprintf(hostfd, " Overall
\n"); fprintf(hostfd, "

\n"); fprintf(hostfd, "%s

\n", h->hostentry->hostname); + fprintf(hostfd,"

"); + fprintf(hostfd,"


", h->hostentry->hostname ); + for (t = h->hostentry->entries; (t); t = t->next) { if (t->onwap) { ! fprintf(hostfd, "%s%s %s
\n", ! h->hostentry->hostname, t->column->name, wml_colorname(t->color), ! (t->acked ? "" : ""), t->column->name); } } ! fprintf(hostfd, "\n

\n"); fclose(hostfd); /* Create the link from the bb2 wap card to the host card */ ! fprintf(bb2fd, "%s %s
\n", h->hostentry->hostname, wml_colorname(h->hostentry->wapcolor), ! h->hostentry->hostname); } } ! fprintf(bb2fd, "

\n"); fclose(bb2fd); if (chdir(wmldir) == 0) { /* Rename the top-level file into place now */ ! rename("bb2.html.tmp", "bb2.html"); /* Make sure there is the index.wml file pointing to bb2.wml */ ! symlink("bb2.html", "index.html"); } return;