no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | addons:wmlpatch [2010/03/01 23:02] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== WML Patch ====== | ||
+ | |||
+ | ^ Author | [[Jemimah.Ruhala@pmsionline.com|Jemimah Ruhala]] | | ||
+ | ^ Compatibility | Xymon 4.2 | | ||
+ | ^ Requirements | Gnu Patch, GCC | | ||
+ | ^ Download | {{addons: | ||
+ | ^ Last Update | 2007-12-07 | | ||
+ | |||
+ | |||
+ | ===== Description ===== | ||
+ | |||
+ | This is a patch to wmlgen.c to create simplified html output suitable for smartphones such as Blackberry instead of WML, which is too basic to be useful on these phones. | ||
+ | |||
+ | |||
+ | ===== Installation ===== | ||
+ | |||
+ | Copy wmlgen.patch into the hobbit-4.2.0/ | ||
+ | |||
+ | < | ||
+ | patch -p1 < wmlgen.patch | ||
+ | </ | ||
+ | |||
+ | Recompile Xymon. | ||
+ | |||
+ | Reinstall, or just copy the new **// | ||
+ | |||
+ | Enable wml in the hobbitserver.cfg file | ||
+ | |||
+ | Update bb-hosts with WML:test1, test2,etc to include all the tests you want to see on your phone. | ||
+ | |||
+ | Create a directory called gif under your wml output directory, and copy the gif files from the main www/gifs directory to wml/ | ||
+ | |||
+ | If everything worked, you should see html files appear in your wml directory. | ||
+ | |||
+ | ===== Source ===== | ||
+ | |||
+ | ==== wmlgen.patch ==== | ||
+ | |||
+ | <hidden onHidden=" | ||
+ | <code diff> | ||
+ | *** 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: | ||
+ | ! case COL_RED: | ||
+ | ! case COL_YELLOW: return " | ||
+ | ! case COL_PURPLE: return " | ||
+ | ! case COL_CLEAR: | ||
+ | ! case COL_BLUE: | ||
+ | } | ||
+ | | ||
+ | return ""; | ||
+ | --- 59,70 ---- | ||
+ | static char *wml_colorname(int color) | ||
+ | { | ||
+ | switch (color) { | ||
+ | ! case COL_GREEN: | ||
+ | ! case COL_RED: | ||
+ | ! case COL_YELLOW: return "< | ||
+ | ! case COL_PURPLE: return "< | ||
+ | ! case COL_CLEAR: | ||
+ | ! case COL_BLUE: | ||
+ | } | ||
+ | | ||
+ | return ""; | ||
+ | *************** | ||
+ | *** 72,84 **** | ||
+ | | ||
+ | static void wml_header(FILE *output, char *cardid, int idpart) | ||
+ | { | ||
+ | ! fprintf(output, | ||
+ | ! fprintf(output, | ||
+ | ! fprintf(output, | ||
+ | ! fprintf(output, | ||
+ | ! fprintf(output, | ||
+ | ! fprintf(output, | ||
+ | ! fprintf(output, | ||
+ | } | ||
+ | | ||
+ | | ||
+ | --- 72,78 ---- | ||
+ | | ||
+ | static void wml_header(FILE *output, char *cardid, int idpart) | ||
+ | { | ||
+ | ! fprintf(output, | ||
+ | } | ||
+ | | ||
+ | | ||
+ | *************** | ||
+ | *** 95,101 **** | ||
+ | sprintf(hobbitdreq, | ||
+ | hobbitdresult = sendmessage(hobbitdreq, | ||
+ | if ((hobbitdresult != BB_OK) || (logbuf == NULL) || (strlen(logbuf) == 0)) { | ||
+ | ! errprintf(" | ||
+ | return; | ||
+ | } | ||
+ | | ||
+ | --- 89,95 ---- | ||
+ | sprintf(hobbitdreq, | ||
+ | hobbitdresult = sendmessage(hobbitdreq, | ||
+ | if ((hobbitdresult != BB_OK) || (logbuf == NULL) || (strlen(logbuf) == 0)) { | ||
+ | ! // | ||
+ | return; | ||
+ | } | ||
+ | | ||
+ | *************** | ||
+ | *** 111,117 **** | ||
+ | | ||
+ | nextline = msg; | ||
+ | | ||
+ | ! sprintf(fn, | ||
+ | fd = fopen(fn, " | ||
+ | if (fd == NULL) { | ||
+ | errprintf(" | ||
+ | --- 105,111 ---- | ||
+ | | ||
+ | nextline = msg; | ||
+ | | ||
+ | ! sprintf(fn, | ||
+ | fd = fopen(fn, " | ||
+ | if (fd == NULL) { | ||
+ | errprintf(" | ||
+ | *************** | ||
+ | *** 120,130 **** | ||
+ | | ||
+ | wml_header(fd, | ||
+ | fprintf(fd, | ||
+ | ! fprintf(fd, | ||
+ | ! fprintf(fd, | ||
+ | ! fprintf(fd, | ||
+ | fprintf(fd, | ||
+ | | ||
+ | /* | ||
+ | * 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, | ||
+ | fprintf(fd, | ||
+ | ! fprintf(fd, | ||
+ | ! fprintf(fd, | ||
+ | ! fprintf(fd, | ||
+ | ! fprintf(fd, | ||
+ | ! fprintf(fd, | ||
+ | ! fprintf(fd, | ||
+ | ! fprintf(fd, | ||
+ | fprintf(fd, | ||
+ | | ||
+ | + fprintf(fd,"< | ||
+ | + fprintf(fd,"< | ||
+ | + | ||
+ | + | ||
+ | /* | ||
+ | * 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, "& | ||
+ | ! strcpy(outp, | ||
+ | ! outp += 10; p += 4; | ||
+ | } | ||
+ | else if (strncmp(p, "& | ||
+ | ! strcpy(outp, | ||
+ | ! outp += 12; p += 6; | ||
+ | } | ||
+ | else if (strncmp(p, "& | ||
+ | ! strcpy(outp, | ||
+ | ! outp += 13; p += 7; | ||
+ | } | ||
+ | else if (strncmp(p, "& | ||
+ | ! strcpy(outp, | ||
+ | ! outp += 13; p += 7; | ||
+ | } | ||
+ | else if (strncmp(p, "& | ||
+ | ! strcpy(outp, | ||
+ | ! outp += 12; p += 6; | ||
+ | } | ||
+ | else if (strncmp(p, "& | ||
+ | ! strcpy(outp, | ||
+ | ! 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, "& | ||
+ | ! strcpy(outp, | ||
+ | ! outp += 23; p += 4; | ||
+ | } | ||
+ | else if (strncmp(p, "& | ||
+ | ! strcpy(outp, | ||
+ | ! outp += 25; p += 6; | ||
+ | } | ||
+ | else if (strncmp(p, "& | ||
+ | ! strcpy(outp, | ||
+ | ! outp += 26; p += 7; | ||
+ | } | ||
+ | else if (strncmp(p, "& | ||
+ | ! strcpy(outp, | ||
+ | ! outp += 26; p += 7; | ||
+ | } | ||
+ | else if (strncmp(p, "& | ||
+ | ! strcpy(outp, | ||
+ | ! outp += 25; p += 6; | ||
+ | } | ||
+ | else if (strncmp(p, "& | ||
+ | ! strcpy(outp, | ||
+ | ! outp += 24; p += 5; | ||
+ | } | ||
+ | + | ||
+ | + else if (strncmp(p, " | ||
+ | + | ||
+ | + outp += 18; p += 3; | ||
+ | + } | ||
+ | + else if (strncmp(p, " | ||
+ | + | ||
+ | + outp += 21; p += 6; | ||
+ | + } | ||
+ | + else if (strncmp(p, " | ||
+ | + | ||
+ | + outp += 21; p += 6; | ||
+ | + } | ||
+ | + else if (strncmp(p, " | ||
+ | + | ||
+ | + outp += 19; p += 4; | ||
+ | + } | ||
+ | + else if (strncmp(p, " | ||
+ | + | ||
+ | + outp += 21; p += 6; | ||
+ | + } | ||
+ | else if (*p == '&' | ||
+ | strcpy(outp, | ||
+ | outp += 5; p++; | ||
+ | *************** | ||
+ | *** 233,239 **** | ||
+ | *outp = ' | ||
+ | if (strlen(lineout)) fprintf(fd, " | ||
+ | } | ||
+ | ! fprintf(fd, | ||
+ | | ||
+ | fclose(fd); | ||
+ | if (logbuf) xfree(logbuf); | ||
+ | --- 257,263 ---- | ||
+ | *outp = ' | ||
+ | if (strlen(lineout)) fprintf(fd, " | ||
+ | } | ||
+ | ! fprintf(fd, | ||
+ | | ||
+ | fclose(fd); | ||
+ | if (logbuf) xfree(logbuf); | ||
+ | *************** | ||
+ | *** 285,310 **** | ||
+ | for (h = hostlistBegin(); | ||
+ | h-> | ||
+ | for (t = h-> | ||
+ | - if (t-> | ||
+ | generate_wml_statuscard(h-> | ||
+ | h-> | ||
+ | - } | ||
+ | - else { | ||
+ | - /* Clear the onwap flag - makes testing later a bit simpler */ | ||
+ | - t-> | ||
+ | - } | ||
+ | | ||
+ | if (t-> | ||
+ | } | ||
+ | | ||
+ | /* Update the bb2wapcolor */ | ||
+ | ! if ( (h-> | ||
+ | ! if (h-> | ||
+ | ! } | ||
+ | } | ||
+ | | ||
+ | /* Start the BB2 WML card */ | ||
+ | ! sprintf(bb2fn, | ||
+ | bb2fd = fopen(bb2fn, | ||
+ | if (bb2fd == NULL) { | ||
+ | errprintf(" | ||
+ | --- 309,327 ---- | ||
+ | for (h = hostlistBegin(); | ||
+ | h-> | ||
+ | for (t = h-> | ||
+ | generate_wml_statuscard(h-> | ||
+ | h-> | ||
+ | | ||
+ | if (t-> | ||
+ | + if(h-> | ||
+ | } | ||
+ | | ||
+ | /* Update the bb2wapcolor */ | ||
+ | ! if (h-> | ||
+ | } | ||
+ | | ||
+ | /* Start the BB2 WML card */ | ||
+ | ! sprintf(bb2fn, | ||
+ | bb2fd = fopen(bb2fn, | ||
+ | if (bb2fd == NULL) { | ||
+ | errprintf(" | ||
+ | *************** | ||
+ | *** 314,327 **** | ||
+ | /* Standard BB2 wap header */ | ||
+ | wml_header(bb2fd, | ||
+ | fprintf(bb2fd, | ||
+ | ! fprintf(bb2fd, | ||
+ | ! fprintf(bb2fd, | ||
+ | ! fprintf(bb2fd, | ||
+ | | ||
+ | - /* All green ? Just say so */ | ||
+ | - if (bb2wapcolor == COL_GREEN) { | ||
+ | - fprintf(bb2fd, | ||
+ | - } | ||
+ | | ||
+ | /* Now loop through the hostlist again, and generate the bb2wap links and host pages */ | ||
+ | for (h = hostlistBegin(); | ||
+ | --- 331,338 ---- | ||
+ | /* Standard BB2 wap header */ | ||
+ | wml_header(bb2fd, | ||
+ | fprintf(bb2fd, | ||
+ | ! fprintf(bb2fd, | ||
+ | | ||
+ | | ||
+ | /* Now loop through the hostlist again, and generate the bb2wap links and host pages */ | ||
+ | for (h = hostlistBegin(); | ||
+ | *************** | ||
+ | *** 328,334 **** | ||
+ | if (h-> | ||
+ | | ||
+ | /* Create the host WAP card, with links to individual test results */ | ||
+ | ! sprintf(hostfn, | ||
+ | hostfd = fopen(hostfn, | ||
+ | if (hostfd == NULL) { | ||
+ | errprintf(" | ||
+ | --- 339,345 ---- | ||
+ | if (h-> | ||
+ | | ||
+ | /* Create the host WAP card, with links to individual test results */ | ||
+ | ! sprintf(hostfn, | ||
+ | hostfd = fopen(hostfn, | ||
+ | if (hostfd == NULL) { | ||
+ | errprintf(" | ||
+ | *************** | ||
+ | *** 337,408 **** | ||
+ | | ||
+ | wml_header(hostfd, | ||
+ | fprintf(hostfd, | ||
+ | - fprintf(hostfd, | ||
+ | fprintf(hostfd, | ||
+ | fprintf(hostfd, | ||
+ | fprintf(hostfd, | ||
+ | | ||
+ | for (t = h-> | ||
+ | if (t-> | ||
+ | ! fprintf(hostfd, | ||
+ | t-> | ||
+ | wml_colorname(t-> | ||
+ | ! (t-> | ||
+ | ! h-> | ||
+ | t-> | ||
+ | } | ||
+ | } | ||
+ | ! fprintf(hostfd, | ||
+ | fclose(hostfd); | ||
+ | | ||
+ | /* Create the link from the bb2 wap card to the host card */ | ||
+ | ! fprintf(bb2fd, | ||
+ | h-> | ||
+ | ! h-> | ||
+ | | ||
+ | - /* | ||
+ | - * Gross hack. Some WAP phones cannot handle large cards. | ||
+ | - * So if the card grows larger than WMLMAXCHARS, | ||
+ | - * 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, | ||
+ | - | ||
+ | - bb2part++; | ||
+ | - | ||
+ | - fprintf(bb2fd, | ||
+ | - fprintf(bb2fd, | ||
+ | - fclose(bb2fd); | ||
+ | - | ||
+ | - /* Start a new BB2 WML card */ | ||
+ | - sprintf(bb2fn, | ||
+ | - bb2fd = fopen(bb2fn, | ||
+ | - if (bb2fd == NULL) { | ||
+ | - errprintf(" | ||
+ | - return; | ||
+ | - } | ||
+ | - wml_header(bb2fd, | ||
+ | - fprintf(bb2fd, | ||
+ | - fprintf(bb2fd, | ||
+ | - fprintf(bb2fd, | ||
+ | - fprintf(bb2fd, | ||
+ | - fprintf(bb2fd, | ||
+ | - } | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | ! fprintf(bb2fd, | ||
+ | fclose(bb2fd); | ||
+ | | ||
+ | if (chdir(wmldir) == 0) { | ||
+ | /* Rename the top-level file into place now */ | ||
+ | ! rename(" | ||
+ | | ||
+ | /* Make sure there is the index.wml file pointing to bb2.wml */ | ||
+ | ! symlink(" | ||
+ | } | ||
+ | | ||
+ | return; | ||
+ | --- 348,391 ---- | ||
+ | | ||
+ | wml_header(hostfd, | ||
+ | fprintf(hostfd, | ||
+ | fprintf(hostfd, | ||
+ | + fprintf(hostfd, | ||
+ | fprintf(hostfd, | ||
+ | fprintf(hostfd, | ||
+ | | ||
+ | + fprintf(hostfd,"< | ||
+ | + fprintf(hostfd,"< | ||
+ | + | ||
+ | for (t = h-> | ||
+ | if (t-> | ||
+ | ! fprintf(hostfd, | ||
+ | ! h-> | ||
+ | t-> | ||
+ | wml_colorname(t-> | ||
+ | ! (t-> | ||
+ | t-> | ||
+ | } | ||
+ | } | ||
+ | ! fprintf(hostfd, | ||
+ | fclose(hostfd); | ||
+ | | ||
+ | /* Create the link from the bb2 wap card to the host card */ | ||
+ | ! fprintf(bb2fd, | ||
+ | h-> | ||
+ | ! h-> | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | ! fprintf(bb2fd, | ||
+ | fclose(bb2fd); | ||
+ | | ||
+ | if (chdir(wmldir) == 0) { | ||
+ | /* Rename the top-level file into place now */ | ||
+ | ! rename(" | ||
+ | | ||
+ | /* Make sure there is the index.wml file pointing to bb2.wml */ | ||
+ | ! symlink(" | ||
+ | } | ||
+ | | ||
+ | return; | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Known Bugs and Issues ===== | ||
+ | |||
+ | ===== To Do ===== | ||
+ | |||
+ | ===== Credits ===== | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | * **2007-12-07** | ||
+ | * Initial release | ||