ACMD(ispell) conversion

From: Akuma/Chris Baggett/DOOMer (doomer@BAYOU.COM)
Date: 11/18/97

ok, i looked at Erwin's ispell.txt on his LETTERS site.
and as a start, i decided that i would circle-fy it.
after i figured out what certain variables were meant to do,
i proceeded.
and here it is.
the only thing you need to add (aside from the bottom half of this email)
if you want to use this ACMD() is :
1) ACMD(do_ispell);  in the ACMD() list in interpreter.c
2) put "ispell" in the command_interpreter array as a new command is done
3) void ispell_init(void);    (put this line at the top of comm.c)
4) in comm.c's game_loop() right before the while (!circle_shutdown)
   put this      ispell_init();
after that,  change your Makefile (i use the makefile auto-dependencies thing
so it helps me out a lot to just be able to type make depend)
put ispell.o in the OBJFILES, and basically add the new file to the
Makefile listing
and don't forget  ispell.c (right below)
ok, here it is.
the syntax for it is basically
ispell <word> (which checks to see if it is spelled correctly and gives
ispell +<word> (which adds it to your personal dictionary defined at the
top of ispell.c)
this should work, i worked out all the bugs and no problems now.
works fine.
thanks go out to Erwin S. Andreasen for the help he gave, and the original
i'm not responsible for any damage done to anything on your system.
this is mailer code that works! :-P
here it is (ispell.c)  WARNING: this only works on UNIX systems (i think)
/* Interface to iSpell
 * Copyright (c) 1997 Erwin S. Andreasen <>
#include "conf.h"
#include "sysdep.h"
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "db.h"
#include <sys/wait.h>
#define Stringify(x) Str(x)
#define Str(x) #x
#define ISPELL_DICTIONARY "etc/mud.dictionary"
static FILE *ispell_out;
static ispell_pid=-1;
static int to[2], from[2];
#define ISPELL_BUF_SIZE 1024
void ispell_init(void)
{        char ignore_buf[1024];
#if 0
        if (IS_SET(sysdata.options, OPT_NO_ISPELL))
       {        ispell_pid=-1;
        pipe(to);     pipe(from);
        ispell_pid = fork();
        if (ispell_pid < 0)
                log("ispell_init: fork: %s", strerror(errno));
        else if (ispell_pid == 0) /* child */
        {       int i;
       dup2 (to[0], 0); /* this is where we read commands from - make it
stdin */
                close (to[0]);
                close (to[1]);
                dup2 (from[1], 1); /* this is where we write stuff to */
                close (from[0]);
                close (from[1]);
             /* Close all the other files */
                for (i = 2; i < 255; i++)
                        close (i);
             execlp ("ispell", "ispell", "-a", "-p" ISPELL_DICTIONARY,
(char *)NULL);
        else /* ok !*/
        {       close (to[0]);
                close (from[1]);
                ispell_out = fdopen (to[1], "w");
                setbuf (ispell_out, NULL);
                #if !defined( sun ) /* that ispell on sun gives no (c) msg */
                    read (from[0], ignore_buf, 1024);
void ispell_done(void)
{      if (ispell_pid != -1)
        {       fprintf (ispell_out, "#\n");
                fclose (ispell_out);  close (from[0]);
                waitpid(ispell_pid, NULL, 0);
                ispell_pid = -1;

char* get_ispell_line (char *word)
{      static char buf[ISPELL_BUF_SIZE];
        char buf2[MSL*3];
        int len;
        if (ispell_pid == -1)     return NULL;
        if (word)
        {       fprintf (ispell_out, "^%s\n", word);
                fflush (ispell_out);
        len = read (from[0], buf2, ISPELL_BUF_SIZE);
        buf2[len] = '\0';
        /* Read up to max 1024 characters here */
        if (sscanf (buf2, "%" Stringify(ISPELL_BUF_SIZE) "[^\n]\n\n", buf)
!= 1)
                return NULL;
        return buf;
{      char *pc;
     if (ispell_pid <= 0)
        {       send_to_char ("ispell is not running.\r\n",ch);
        if (!argument[0] || strchr (argument, ' '))
        {       send_to_char ("Invalid input.\r\n",ch);
        if (argument[0] == '+')
        {    for (pc = argument+1;*pc; pc++)
                        if (!isalpha(*pc))
                        {       send_to_charf (ch, "'%c' is not a
letter.\r\n", *pc);
                fprintf (ispell_out, "*%s\n", argument+1);
                fflush (ispell_out);
                return; /* we assume everything is OK.. better be so! */
        pc = get_ispell_line(argument);
        if (!pc)
        {       send_to_char ("ispell: failed.\r\n",ch);
        switch (pc[0])
        {       case '*':    case '+': /* root */      case '-': /*
compound */
                        send_to_char ("Correct.\r\n",ch);
                case '&': /* miss */
         send_to_charf(ch, "Not found. Possible words: %s\r\n", strchr(pc,
               case '?': /* guess */
            send_to_charf(ch, "Not found. Possible words: %s\r\n",
strchr(pc, ':')+1);
                case '#': /* none */
                   send_to_char ("Unable to find anything that
                        send_to_charf (ch, "Weird output from ispell:
%s\r\n", pc);

Akuma the Raging Coder

  | "The poets talk about love, but what I talk about is DOOM, |
  |      because in the end, DOOM is all that counts." -       |
  |   Alex Machine/George Stark/Stephen King, The Dark Half    |
  |        "Nothing is IMPOSSIBLE, Just IMPROBABLE"            |
  |   "Easier Said Than Done, But Better Done Than Said..."    |

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/08/00 PST