mirror of
https://github.com/tbamud/tbamud.git
synced 2025-09-21 21:40:49 +02:00
Remove webster lookup since it no longer works (#99)
* removed useless util/webster.c and fixed a couple of potential buffer overruns in the util functions * removed stray utf-8 error chars. I guess someone has used an editor with fancy 's * removed last webster integrations
This commit is contained in:
parent
9a0a096f85
commit
89eb009c4f
8 changed files with 55 additions and 348 deletions
|
@ -865,7 +865,7 @@ AUTOQUESTS QUESTS QUESTMASTERS QUEST-MOBS QUESTMOBS
|
|||
|
||||
An autoquest is a quest that can be automatically started and completed
|
||||
without the intervention of an immortal. Simply visit a questmaster and join
|
||||
an available quest, and get rewarded on it’s completion. Keep an eye out for
|
||||
an available quest, and get rewarded on it's completion. Keep an eye out for
|
||||
autoquests scattered throughout the World.
|
||||
|
||||
See Also: QUEST-FLAG, QUESTPOINTS
|
||||
|
@ -1584,7 +1584,6 @@ qedit (quest editor)
|
|||
questpoints
|
||||
buildwalk
|
||||
dig
|
||||
tell m-w (an in game dictionary lookup)
|
||||
gemote
|
||||
history
|
||||
file
|
||||
|
@ -2444,25 +2443,6 @@ Example:
|
|||
> diagnose doctor
|
||||
|
||||
See also: CONSIDER, HIT, KILL
|
||||
#0
|
||||
DICTIONARY DICTIONARIES THESAURUS M-W.COM DEFINITION MERRIAM-WEBSTER M-W-DEFINITION WEBSTER MW TELL-M-W BREATHER SPELLING WORDS
|
||||
|
||||
Usage: tell m-w <word>
|
||||
|
||||
We have a direct link to Merriam Webster. To use the dictionary just
|
||||
tell m-w <word>
|
||||
|
||||
>tell m-w breather
|
||||
You get this feedback from Merriam-Webster:
|
||||
That means:
|
||||
1 : one that breathes
|
||||
2 : a break in activity for rest or relief
|
||||
3 : a small vent in an otherwise airtight enclosure
|
||||
|
||||
A few obscure definitions are not available through m-w since they are in the
|
||||
unabridged version that requires membership. They also offer a thesaurus at:
|
||||
@Chttp://m-w.com/@n
|
||||
|
||||
#31
|
||||
DIG UNDIG RDIG RELINK RLINKS
|
||||
|
||||
|
@ -3173,7 +3153,7 @@ game.
|
|||
Invest in a thesaurus. Makes a world of difference, and if that doesn't
|
||||
help, just make up your own words for things you create (just be sure to
|
||||
describe them very well. Use @Chttp://m-w.com/@n for an online thesaurus
|
||||
and dictionary. You can @Rtell m-w <word>@n to lookup a definition.
|
||||
and dictionary.
|
||||
|
||||
4. Where can I learn Trigedit?
|
||||
Here! Welcor is now the developer of trigedit. We have extensive help files,
|
||||
|
@ -3564,8 +3544,8 @@ GRAMMAR GRAMMER TIPS
|
|||
words can be particularly tricky and elude electronic spell checkers. A good
|
||||
dictionary, however, will help you spell archaic words. Whenever I am building
|
||||
I use our Merriam Webster dictionary link on TBA to check any tough words for
|
||||
proper spelling. Test it out @RTELL M-W DEFINITION@n. We hope to add a thesaurus
|
||||
soon! Goto @Chttp://m-w.com/@n until then.
|
||||
proper spelling. We hope to add a thesaurus soon! Goto @Chttp://m-w.com/@n
|
||||
until then.
|
||||
I have found that a good principle to make is to avoid the use of all
|
||||
contractions. For example, if you mean to say "it is", do not use "it's", spell
|
||||
it out. This will help differentiate between "its" (which means 'belonging to
|
||||
|
@ -7192,7 +7172,7 @@ prefer to add the quest in the zone where quest completion takes place.
|
|||
Quests use vnums in exactly the same way as mobiles, object and rooms. Each
|
||||
zone will normally have 100 vnums available (#00 to #99, where # is the zone
|
||||
number). Usually, when creating the first quest in a zone, #00 is used,
|
||||
then #01, etc…
|
||||
then #01, etc.
|
||||
|
||||
When you qedit <vnum> to create a new quest (or edit an existing one), you will
|
||||
see the menu in @RHELP QEDIT-MENU@n
|
||||
|
@ -7203,12 +7183,12 @@ QEDIT-ACCEPT
|
|||
|
||||
This is the text that is sent to the player when they start the quest. It
|
||||
should describe in detail exactly what is required to complete the quest. The
|
||||
text is simply output on the player’s screen, so be creative here. An example
|
||||
text is simply output on the player's screen, so be creative here. An example
|
||||
of an accept message text could be something like:
|
||||
|
||||
The questmaster rummages in a large pile of papers.
|
||||
The questmaster says ‘Ah, here it is’
|
||||
The questmaster says ‘Bob, the local butcher has offered this quest’
|
||||
The questmaster says "Ah, here it is"
|
||||
The questmaster says "Bob, the local butcher has offered this quest"
|
||||
The questmaster shows you a hastily scrawled note, that reads:
|
||||
|
||||
I am willing to offer any plucky adventurer 10 quest points if they bring me a
|
||||
|
@ -7218,7 +7198,7 @@ order to fill. I need these within 24 hours
|
|||
|
||||
Thanks, Bob the Butcher, Midgaard
|
||||
The questmaster sighs.
|
||||
The questmaster says ‘A tricky quest, but it’ll cost you 5qp to back out now’
|
||||
The questmaster says "A tricky quest, but it'll cost you 5qp to back out now"
|
||||
#31
|
||||
QEDIT-COMPLETED QEDIT-ABANDONED
|
||||
|
||||
|
@ -7232,7 +7212,7 @@ all timed quests.
|
|||
QEDIT-COMPLETION
|
||||
|
||||
Just like the accept message, this is simply text that is output on the
|
||||
player’s screen when they successfully complete the quest. Prizes (quest
|
||||
player's screen when they successfully complete the quest. Prizes (quest
|
||||
points, gold coins, experience points or an object) are automatically
|
||||
announced after this text is shown, so this text does not need to have that
|
||||
information in it.
|
||||
|
@ -7258,7 +7238,7 @@ Quest flags: @cNOBITS@n
|
|||
Enter quest flags, 0 to quit :
|
||||
|
||||
Currently, only one flag is available, the REPEATABLE flag. When you have
|
||||
finished turning this on or off, select ‘0’ (zero) to return to the main menu.
|
||||
finished turning this on or off, select "0" (zero) to return to the main menu.
|
||||
#31
|
||||
QEDIT-LEVELS
|
||||
|
||||
|
@ -7312,12 +7292,12 @@ QEDIT-NEXT
|
|||
|
||||
This is the quest vnum of next quest in a chain. When a player completes
|
||||
the current quest, the next quest will automatically be joined. This allows
|
||||
for long quests with a number of ‘steps’.
|
||||
for long quests with a number of "steps".
|
||||
#31
|
||||
QEDIT-PREREQUISITE
|
||||
|
||||
This is the object vnum for a prerequisite object. The prerequisite object
|
||||
should be in the player’s inventory in order for them to be able to join the
|
||||
should be in the player's inventory in order for them to be able to join the
|
||||
quest. It is not taken from the player when the quest starts.
|
||||
#31
|
||||
QEDIT-PREVIOUS
|
||||
|
@ -7328,15 +7308,15 @@ completed by the player in order to join this quest.
|
|||
QEDIT-QUANTITY
|
||||
|
||||
This is the number of times the player needs to repeat the quest. For
|
||||
example, it could be the number of items the player needs to find in a ‘object’
|
||||
quest of the number of mobs the player should kill in a ‘kill mob’ quest. This
|
||||
should be used with caution, however. In an object quest ‘picking up’ the same
|
||||
example, it could be the number of items the player needs to find in a "object"
|
||||
quest of the number of mobs the player should kill in a "kill mob" quest. This
|
||||
should be used with caution, however. In an object quest picking up the same
|
||||
object 20 times will also complete the quest.
|
||||
#31
|
||||
QEDIT-QUIT QEDIT-MESSAGE
|
||||
|
||||
The quit message is sent to the player when they type quest leave. Players
|
||||
can lose quest points for abandoning a quest (see “Abandoned” on the next
|
||||
can lose quest points for abandoning a quest (see "Abandoned" on the next
|
||||
page), so if they lose quest points, this text really should inform them of
|
||||
that.
|
||||
#31
|
||||
|
@ -7365,14 +7345,14 @@ Room, Clear Room - Room VNUM
|
|||
#31
|
||||
QEDIT-TIME
|
||||
|
||||
This is the number of ‘ticks’ or game hours that the player has to complete
|
||||
This is the number of 'ticks' or game hours that the player has to complete
|
||||
the quest. If this is set, then the builder should really try to do the quest
|
||||
themselves, and time how long it takes (typing ‘time’ before and after the
|
||||
attempt), and then giving at least one extra ‘tick’ for players to complete it.
|
||||
themselves, and time how long it takes (typing 'time' before and after the
|
||||
attempt), and then giving at least one extra 'tick' for players to complete it.
|
||||
#31
|
||||
QEDIT-TYPE
|
||||
|
||||
There are a few different quest types. When you select option ‘7’ from the
|
||||
There are a few different quest types. When you select option '7' from the
|
||||
main menu, you will be shown a list to choose from:
|
||||
|
||||
0) Object - Player needs to find a particular object.
|
||||
|
@ -7447,7 +7427,7 @@ Usage: quest [list | join <#> | progress | leave | history]
|
|||
|
||||
quest - Show usage information for the quest command.
|
||||
quest list - Used at the questmaster to see which quests are available.
|
||||
quest join # - Used to the questmaster to join the quest listed as number ‘nn’ on quest list.
|
||||
quest join # - Used to the questmaster to join the quest listed as number 'nn' on quest list.
|
||||
quest progress - Shows the player which quest they are doing, and their quest progress.
|
||||
quest leave - Allows the player to abandon the current quest, taking the quest point penalty.
|
||||
quest history - Shows all previously completed non-repeatable quests.
|
||||
|
@ -9352,7 +9332,7 @@ and simply bearing artistic merit. Second, by ensuring that they are absolutely
|
|||
necessary to achieve the goals of the game! If your game is made for experience
|
||||
and equipment gathering, and failure to read descriptions directly impedes this
|
||||
goal, then players will learn to read everything. If your game is made for
|
||||
exploring or role-play, most of your players probably already read them Â-
|
||||
exploring or role-play, most of your players probably already read them -
|
||||
because knowing their environment is a basic requirement of play. In any case,
|
||||
builders exist to ensure that the goals of play are supported by game
|
||||
descriptions.
|
||||
|
@ -9364,7 +9344,7 @@ meaning behind descriptions, areas to find, special items, unique nooks and
|
|||
crannies to spend time socializing, and hints that point to these things
|
||||
elsewhere outside of your own zone is an excellent idea. In fact, if you
|
||||
don't wish to be building descriptions no one will read, you should employ
|
||||
special secrets Â- most especially on games where knowing one's environment
|
||||
special secrets - most especially on games where knowing one's environment
|
||||
does deeply affect a character's development. No matter what kind of zone you
|
||||
are building, keep it interesting throughout!
|
||||
|
||||
|
@ -9387,7 +9367,7 @@ road.
|
|||
shouldn't be the sole builder of your zone. Instead, seek the assistance of
|
||||
someone who adds creative merit to your descriptions. You can do practically
|
||||
everything from plot to secrets to minutiae, even write the zone in full and
|
||||
just ask someone you know who writes well to Â'say it better' and rewrite
|
||||
just ask someone you know who writes well to 'say it better' and rewrite
|
||||
what you intended to have there all along. Novels have editors, and so
|
||||
should any zone.
|
||||
|
||||
|
@ -9659,19 +9639,19 @@ have a point and here it is: *drum roll please*
|
|||
Building is hard work! It is a form of expression and creativity. What kind
|
||||
of areas you build generally reflects on what kind of person you are. You
|
||||
do not have to be a good speller but you do need a good dictionary/thesaurus.
|
||||
@RHELP M-W@n. Sometimes building can seem like a thankless job and sometimes
|
||||
building can be a reward in itself. Building a few areas, even a few good
|
||||
ones, does not make you an Immortal or an Imp. It takes more than building to
|
||||
be one of those and it entails even more work. Respect others and they will
|
||||
respect you. The more detailed an area the better it is. Always choose Quality
|
||||
over Quantity. Put some pride in your areas, develop a style of your own. Try
|
||||
new things keep it interesting, if you become bored with building an area take
|
||||
a break and play a mortal or do something else, don't take advantage of builder
|
||||
privileges. Treat others as you wish to be treated. One more warning I would
|
||||
give to builders before they take things personally or get insulted. Everyone
|
||||
has their own ideas on how to run a MUD, what it comes down to is whoever owns
|
||||
the MUD makes the final decision, so it does not matter how good you think your
|
||||
idea is, it may never be used if the owner does not like it. Plain and simple.
|
||||
Sometimes building can seem like a thankless job and sometimes building can be
|
||||
a reward in itself. Building a few areas, even a few good ones, does not make
|
||||
you an Immortal or an Imp. It takes more than building to be one of those and
|
||||
it entails even more work. Respect others and they will respect you. The more
|
||||
detailed an area the better it is. Always choose Quality over Quantity. Put
|
||||
some pride in your areas, develop a style of your own. Try new things keep it
|
||||
interesting, if you become bored with building an area take a break and play a
|
||||
mortal or do something else, don't take advantage of builder privileges.
|
||||
Treat others as you wish to be treated. One more warning I would give to
|
||||
builders before they take things personally or get insulted. Everyone has their
|
||||
own ideas on how to run a MUD, what it comes down to is whoever owns the MUD
|
||||
makes the final decision, so it does not matter how good you think your idea
|
||||
is, it may never be used if the owner does not like it. Plain and simple.
|
||||
You see this on every MUD. So please keep the ideas coming, but do not try to
|
||||
force them onto anyone. Be constructive, not critical about peoples ideas.
|
||||
Everyone is allowed their opinions.
|
||||
|
|
|
@ -150,39 +150,7 @@ ACMD(do_tell)
|
|||
|
||||
if (!*buf || !*buf2)
|
||||
send_to_char(ch, "Who do you wish to tell what??\r\n");
|
||||
else if (!strcmp(buf, "m-w")) {
|
||||
#ifdef CIRCLE_WINDOWS
|
||||
/* getpid() is not portable */
|
||||
send_to_char(ch, "Sorry, that is not available in the windows port.\r\n");
|
||||
#else /* all other configurations */
|
||||
char word[MAX_INPUT_LENGTH], *p, *q;
|
||||
|
||||
if (last_webster_teller != -1L) {
|
||||
if (GET_IDNUM(ch) == last_webster_teller) {
|
||||
send_to_char(ch, "You are still waiting for a response.\r\n");
|
||||
return;
|
||||
} else {
|
||||
send_to_char(ch, "Hold on, m-w is busy. Try again in a couple of seconds.\r\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Only a-z and +/- allowed. */
|
||||
for (p = buf2, q = word; *p ; p++)
|
||||
if ((LOWER(*p) <= 'z' && LOWER(*p) >= 'a') || (*p == '+') || (*p == '-'))
|
||||
*q++ = *p;
|
||||
|
||||
*q = '\0';
|
||||
|
||||
if (!*word) {
|
||||
send_to_char(ch, "Sorry, only letters and +/- are allowed characters.\r\n");
|
||||
return;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "../bin/webster %s %d &", word, (int) getpid());
|
||||
last_webster_teller = GET_IDNUM(ch);
|
||||
send_to_char(ch, "You look up '%s' in Merriam-Webster.\r\n", word);
|
||||
#endif /* platform specific part */
|
||||
} else if (GET_LEVEL(ch) < LVL_IMMORT && !(vict = get_player_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
|
||||
else if (GET_LEVEL(ch) < LVL_IMMORT && !(vict = get_player_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
|
||||
send_to_char(ch, "%s", CONFIG_NOPERSON);
|
||||
else if (GET_LEVEL(ch) >= LVL_IMMORT && !(vict = get_char_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
|
||||
send_to_char(ch, "%s", CONFIG_NOPERSON);
|
||||
|
|
70
src/comm.c
70
src/comm.c
|
@ -104,8 +104,7 @@ unsigned long pulse = 0; /* number of pulses since game start */
|
|||
ush_int port;
|
||||
socket_t mother_desc;
|
||||
int next_tick = SECS_PER_MUD_HOUR; /* Tick countdown */
|
||||
/* used with do_tell and handle_webster_file utility */
|
||||
long last_webster_teller = -1L;
|
||||
|
||||
|
||||
/* static local global variable declarations (current file scope only) */
|
||||
static struct txt_block *bufpool = 0; /* pool of large output buffers */
|
||||
|
@ -113,14 +112,11 @@ static int max_players = 0; /* max descriptors available */
|
|||
static int tics_passed = 0; /* for extern checkpointing */
|
||||
static struct timeval null_time; /* zero-valued time structure */
|
||||
static byte reread_wizlist; /* signal: SIGUSR1 */
|
||||
/* normally signal SIGUSR2, currently orphaned in favor of Webster dictionary
|
||||
* lookup
|
||||
static byte emergency_unban;
|
||||
*/
|
||||
static byte emergency_unban; /* signal: SIGUSR2 */
|
||||
|
||||
static int dg_act_check; /* toggle for act_trigger */
|
||||
static bool fCopyOver; /* Are we booting in copyover mode? */
|
||||
static char *last_act_message = NULL;
|
||||
static byte webster_file_ready = FALSE;/* signal: SIGUSR2 */
|
||||
|
||||
/* static local function prototypes (current file scope only) */
|
||||
static RETSIGTYPE reread_wizlists(int sig);
|
||||
|
@ -160,9 +156,6 @@ static int open_logfile(const char *filename, FILE *stderr_fp);
|
|||
#if defined(POSIX)
|
||||
static sigfunc *my_signal(int signo, sigfunc *func);
|
||||
#endif
|
||||
/* Webster Dictionary Lookup functions */
|
||||
static RETSIGTYPE websterlink(int sig);
|
||||
static void handle_webster_file(void);
|
||||
|
||||
static void msdp_update(void); /* KaVir plugin*/
|
||||
|
||||
|
@ -958,7 +951,7 @@ void game_loop(socket_t local_mother_desc)
|
|||
mudlog(CMP, LVL_IMMORT, TRUE, "Signal received - rereading wizlists.");
|
||||
reboot_wizlists();
|
||||
}
|
||||
/* Orphaned right now as signal trapping is used for Webster lookup
|
||||
|
||||
if (emergency_unban) {
|
||||
emergency_unban = FALSE;
|
||||
mudlog(BRF, LVL_IMMORT, TRUE, "Received SIGUSR2 - completely unrestricting game (emergent)");
|
||||
|
@ -966,11 +959,7 @@ void game_loop(socket_t local_mother_desc)
|
|||
circle_restrict = 0;
|
||||
num_invalid = 0;
|
||||
}
|
||||
*/
|
||||
if (webster_file_ready) {
|
||||
webster_file_ready = FALSE;
|
||||
handle_webster_file();
|
||||
}
|
||||
|
||||
|
||||
#ifdef CIRCLE_UNIX
|
||||
/* Update tics_passed for deadlock protection (UNIX only) */
|
||||
|
@ -2232,18 +2221,10 @@ static RETSIGTYPE reread_wizlists(int sig)
|
|||
reread_wizlist = TRUE;
|
||||
}
|
||||
|
||||
/* Orphaned right now in place of Webster ...
|
||||
static RETSIGTYPE unrestrict_game(int sig)
|
||||
{
|
||||
emergency_unban = TRUE;
|
||||
}
|
||||
*/
|
||||
|
||||
static RETSIGTYPE websterlink(int sig)
|
||||
{
|
||||
webster_file_ready = TRUE;
|
||||
}
|
||||
|
||||
|
||||
#ifdef CIRCLE_UNIX
|
||||
|
||||
|
@ -2318,7 +2299,7 @@ static void signal_setup(void)
|
|||
|
||||
/* user signal 2: unrestrict game. Used for emergencies if you lock
|
||||
* yourself out of the MUD somehow. */
|
||||
my_signal(SIGUSR2, websterlink);
|
||||
my_signal(SIGUSR2, unrestrict_game);
|
||||
|
||||
/* set up the deadlock-protection so that the MUD aborts itself if it gets
|
||||
* caught in an infinite loop for more than 3 minutes. */
|
||||
|
@ -2780,45 +2761,6 @@ static void circle_sleep(struct timeval *timeout)
|
|||
|
||||
#endif /* CIRCLE_WINDOWS */
|
||||
|
||||
static void handle_webster_file(void) {
|
||||
FILE *fl;
|
||||
struct char_data *ch = find_char(last_webster_teller);
|
||||
char retval[MAX_STRING_LENGTH], line[READ_SIZE];
|
||||
size_t len = 0, nlen = 0;
|
||||
|
||||
last_webster_teller = -1L;
|
||||
|
||||
if (!ch) /* they quit ? */
|
||||
return;
|
||||
|
||||
fl = fopen("websterinfo", "r");
|
||||
if (!fl) {
|
||||
send_to_char(ch, "It seems the dictionary is offline..\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
unlink("websterinfo");
|
||||
|
||||
get_line(fl, line);
|
||||
while (!feof(fl)) {
|
||||
nlen = snprintf(retval + len, sizeof(retval) - len, "%s\r\n", line);
|
||||
if (len + nlen >= sizeof(retval))
|
||||
break;
|
||||
len += nlen;
|
||||
get_line(fl, line);
|
||||
}
|
||||
|
||||
if (len >= sizeof(retval)) {
|
||||
const char *overflow = "\r\n**OVERFLOW**\r\n";
|
||||
strcpy(retval + sizeof(retval) - strlen(overflow) - 1, overflow); /* strcpy: OK */
|
||||
}
|
||||
fclose(fl);
|
||||
|
||||
send_to_char(ch, "You get this feedback from Merriam-Webster:\r\n");
|
||||
page_string(ch->desc, retval, 1);
|
||||
}
|
||||
|
||||
|
||||
/* KaVir's plugin*/
|
||||
static void msdp_update( void )
|
||||
{
|
||||
|
|
|
@ -60,9 +60,6 @@ void game_loop(socket_t mother_desc);
|
|||
void heartbeat(int heart_pulse);
|
||||
void copyover_recover(void);
|
||||
|
||||
/** webster dictionary lookup */
|
||||
extern long last_webster_teller;
|
||||
|
||||
extern struct descriptor_data *descriptor_list;
|
||||
extern int buf_largecount;
|
||||
extern int buf_overflows;
|
||||
|
|
|
@ -23,7 +23,7 @@ CFLAGS = @CFLAGS@ $(MYFLAGS) $(PROFILE) -I$(INCDIR)
|
|||
|
||||
default: all
|
||||
|
||||
all: $(BINDIR)/asciipasswd $(BINDIR)/autowiz $(BINDIR)/plrtoascii $(BINDIR)/rebuildIndex $(BINDIR)/rebuildMailIndex $(BINDIR)/shopconv $(BINDIR)/sign $(BINDIR)/split $(BINDIR)/wld2html $(BINDIR)/webster
|
||||
all: $(BINDIR)/asciipasswd $(BINDIR)/autowiz $(BINDIR)/plrtoascii $(BINDIR)/rebuildIndex $(BINDIR)/rebuildMailIndex $(BINDIR)/shopconv $(BINDIR)/sign $(BINDIR)/split $(BINDIR)/wld2html
|
||||
|
||||
asciipasswd: $(BINDIR)/asciipasswd
|
||||
|
||||
|
@ -43,8 +43,6 @@ split: $(BINDIR)/split
|
|||
|
||||
wld2html: $(BINDIR)/wld2html
|
||||
|
||||
webster: $(BINDIR)/webster
|
||||
|
||||
$(BINDIR)/asciipasswd: asciipasswd.c
|
||||
$(CC) $(CFLAGS) -o $(BINDIR)/asciipasswd asciipasswd.c @CRYPTLIB@
|
||||
|
||||
|
@ -72,9 +70,6 @@ $(BINDIR)/split: split.c
|
|||
$(BINDIR)/wld2html: wld2html.c
|
||||
$(CC) $(CFLAGS) -o $(BINDIR)/wld2html wld2html.c
|
||||
|
||||
$(BINDIR)/webster: webster.c
|
||||
$(CC) $(CFLAGS) -o $(BINDIR)/webster webster.c
|
||||
|
||||
# Dependencies for the object files (automagically generated with
|
||||
# gcc -MM)
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ void read_file(void)
|
|||
while (get_line(fl, line))
|
||||
if (*line != '~')
|
||||
recs++;
|
||||
rewind(fl);
|
||||
rewind(fl);
|
||||
|
||||
for (i = 0; i < recs; i++) {
|
||||
get_line(fl, line);
|
||||
|
|
|
@ -155,7 +155,7 @@ static int boot_the_shops_conv(FILE * shop_f, FILE * newshop_f, char *filename)
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *sfp, *nsfp;
|
||||
char fn[256], part[256];
|
||||
char fn[120], part[256];
|
||||
int result, index, i;
|
||||
|
||||
if (argc < 2) {
|
||||
|
@ -173,20 +173,20 @@ int main(int argc, char *argv[])
|
|||
perror(fn);
|
||||
} else {
|
||||
if ((nsfp = fopen(fn, "w")) == NULL) {
|
||||
printf("Error writing to %s.\n", fn);
|
||||
continue;
|
||||
printf("Error writing to %s.\n", fn);
|
||||
continue;
|
||||
}
|
||||
printf("%s:\n", fn);
|
||||
result = boot_the_shops_conv(sfp, nsfp, fn);
|
||||
fclose(nsfp);
|
||||
fclose(sfp);
|
||||
if (result) {
|
||||
sprintf(part, "mv %s.tmp %s", fn, fn);
|
||||
i = system(part);
|
||||
sprintf(part, "mv %s.tmp %s", fn, fn);
|
||||
i = system(part);
|
||||
} else {
|
||||
sprintf(part, "mv %s.tmp %s.bak", fn, fn);
|
||||
i = system(part);
|
||||
printf("Done!\n");
|
||||
sprintf(part, "mv %s.tmp %s.bak", fn, fn);
|
||||
i = system(part);
|
||||
printf("Done!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,175 +0,0 @@
|
|||
/* ************************************************************************
|
||||
* File: webster.c Part of tbaMUD *
|
||||
* Usage: Use an online dictionary via tell m-w <word>. *
|
||||
* *
|
||||
* Based on the Circle 3.0 syntax checker and wld2html programs. *
|
||||
************************************************************************ */
|
||||
|
||||
#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, "<script>write_ads(AdsNum, 0, 1)</script>", 40) != 0)
|
||||
continue; // read until we hit the line with results in it.
|
||||
|
||||
p = buf+40;
|
||||
|
||||
if (strncmp(p, "<br>", 4) == 0)
|
||||
{
|
||||
fprintf(outfile, "That word could not be found.\n");
|
||||
goto end;
|
||||
}
|
||||
else if (strncmp(p, "<div ", 5) == 0) // definition is here, all in one line.
|
||||
{
|
||||
while (strncmp(p, "ds-list", 7)) //seek to the definition
|
||||
p++;
|
||||
|
||||
strncpy(scanbuf, p, sizeof(scanbuf)); // strtok on a copy.
|
||||
|
||||
p = strtok(scanbuf, ">"); // chop the line at the end of tags: <br><b>word</b> becomes "<br" "<b" "word</b"
|
||||
p = strtok(NULL, ">"); // skip the rest of this tag.
|
||||
|
||||
fprintf(outfile, "Info on: %s\n\n", arg);
|
||||
|
||||
while (1)
|
||||
{
|
||||
q = outline;
|
||||
|
||||
while (*p != '<')
|
||||
{
|
||||
assert(p < scanbuf+sizeof(scanbuf));
|
||||
*q++ = *p++;
|
||||
}
|
||||
if (!strncmp(p, "<br", 3) || !strncmp(p, "<p", 2) || !strncmp(p, "<div class=\"ds-list\"", 23) || !strncmp(p, "<div class=\"sds-list\"", 24))
|
||||
*q++ = '\n';
|
||||
// if it's not a <br> tag or a <div class="sds-list"> or <div class="ds-list"> tag, ignore it.
|
||||
|
||||
*q++='\0';
|
||||
fprintf(outfile, "%s", outline);
|
||||
|
||||
if (!strncmp(p, "</table", 7))
|
||||
goto end;
|
||||
|
||||
p = strtok(NULL, ">");
|
||||
}
|
||||
}
|
||||
else if (strncmp(p, "<div>", 5) == 0) // not found, but suggestions are ample:
|
||||
{
|
||||
strncpy(scanbuf, p, sizeof(scanbuf)); // strtok on a copy.
|
||||
|
||||
p = strtok(scanbuf, ">"); // chop the line at the end of tags: <br><b>word</b> becomes "<br>" "<b>" "word</b>"
|
||||
p = strtok(NULL, ">"); // skip the rest of this tag.
|
||||
|
||||
while (1)
|
||||
{
|
||||
q = outline;
|
||||
|
||||
while (*p != '<')
|
||||
*q++ = *p++;
|
||||
|
||||
if (!strncmp(p, "<td ", 4))
|
||||
*q++ = '\n';
|
||||
// if it's not a <td> tag, ignore it.
|
||||
|
||||
*q++='\0';
|
||||
fprintf(outfile, "%s", outline);
|
||||
|
||||
if (!strncmp(p, "</table", 7))
|
||||
goto end;
|
||||
|
||||
p = strtok(NULL, ">");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// weird.. one of the above should be correct.
|
||||
fprintf(outfile, "It would appear that the free online dictionary has changed their format.\n"
|
||||
"Sorry, but you might need a webrowser instead.\n\n"
|
||||
"See http://www.thefreedictionary.com/%s", arg);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
fclose(infile);
|
||||
|
||||
fprintf(outfile, "~");
|
||||
fclose(outfile);
|
||||
}
|
||||
|
||||
/* get_line reads the next non-blank line off of the input stream.
|
||||
* The newline character is removed from the input.
|
||||
*/
|
||||
int get_line(FILE * fl, char *buf)
|
||||
{
|
||||
char temp[MEM_USE];
|
||||
|
||||
do {
|
||||
fgets(temp, MEM_USE, fl);
|
||||
if (*temp)
|
||||
temp[strlen(temp) - 1] = '\0';
|
||||
} while (!feof(fl) && !*temp);
|
||||
|
||||
if (feof(fl))
|
||||
return (0);
|
||||
else {
|
||||
strcpy(buf, temp);
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function to skip over the leading spaces of a string.
|
||||
*/
|
||||
void skip_spaces(char **string)
|
||||
{
|
||||
for (; **string && isspace(**string); (*string)++);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue