/* ************************************************************************
* File: wld2html.c *
* Usage: Convert a DikuMUD .wld file into a series of .html files *
* *
* This program is in the public domain. *
* Written (QUICKLY AND DIRTILY) by Jeremy Elson (jelson@circlemud.org) *
* Based on the Circle 3.0 syntax checker program (scheck.c) *
************************************************************************ */
#define log(msg) fprintf(stderr, "%s\n", msg)
#include "conf.h"
#include "sysdep.h"
#define MEM_USE 10000
char buf[MEM_USE];
int get_line(FILE * fl, char *buf);
void skip_spaces(char **string);
void parse_webster_html(char *arg);
int main(int argc, char **argv)
{
int pid = 0;
if (argc != 3) {
return 0; /* no word/pid given */
}
pid = atoi(argv[2]);
snprintf(buf, sizeof(buf),
"lynx -accept_all_cookies -source http://www.thefreedictionary.com/%s"
" >webster.html", argv[1]);
system(buf);
parse_webster_html(argv[1]);
if (pid)
kill(pid, SIGUSR2);
return (0);
}
void parse_webster_html(char *arg) {
FILE *infile, *outfile;
char scanbuf[MEM_USE], outline[MEM_USE], *p, *q;
outfile = fopen("websterinfo", "w");
if (!outfile)
exit(1);
infile = fopen("webster.html", "r");
if (!infile) {
fprintf(outfile, "A bug has occured in webster. (no webster.html) Please notify Welcor.");
fclose(outfile);
return;
}
// unlink("webster.html"); /* We can still read */
for ( ; get_line(infile, buf)!=0; ) {
if (strncmp(buf, "", 37) != 0)
continue; // read until we hit the line with results in it.
p = buf+37;
if (strncmp(p, "
", 4) == 0)
{
fprintf(outfile, "That word could not be found.\n");
goto end;
}
else if (strncmp(p, "