Set up pre- and post-command hooks.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 5 Nov 2004 01:23:34 +0000 (01:23 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 5 Nov 2004 01:23:34 +0000 (01:23 +0000)
io.c
sst.c
sst.h

diff --git a/io.c b/io.c
index 572d3957926de3302a03ad4ef78707cf5c2e9f93..a5ac6d9e30411105399ca04869758b15ffcee87a 100644 (file)
--- a/io.c
+++ b/io.c
@@ -98,7 +98,7 @@ void pause(int i) {
 
        }
        if (curses) {
-               waddch('\n');
+           waddch(stdscr, '\n');
                waddstr(stdscr, prompt);
                wgetnstr(stdscr, buf, sizeof(buf));
                wclear(stdscr);
@@ -189,8 +189,7 @@ void prouts(char *fmt, ...) {
        }
 }
 
-void getline(char *line, int max)
-{
+void getline(char *line, int max) {
     if (curses) {
        wgetnstr(stdscr, line, max);
        wrefresh(stdscr);
@@ -199,3 +198,6 @@ void getline(char *line, int max)
         line[strlen(line)-1] = '\0';
     }
 }
+
+void commandhook(char *cmd, int before) {
+}
diff --git a/sst.c b/sst.c
index 77fbeb826ba2b4f273df612835c408f13be1827b..ee80b3fc878ba45048deeea559f9aae42f81b366 100644 (file)
--- a/sst.c
+++ b/sst.c
@@ -190,6 +190,7 @@ static void makemoves(void) {
                        }\r
                        else prout("UNRECOGNIZED COMMAND.");\r
                }\r
+               commandhook(commands[i], TRUE);\r
                switch (i) { /* command switch */\r
                        case 0:                 // srscan\r
                                srscan(1);\r
@@ -314,6 +315,7 @@ static void makemoves(void) {
                                helpme();       // get help\r
                                break;\r
                }\r
+               commandhook(commands[i], FALSE);\r
                for (;;) {\r
                        if (alldone) break;             // Game has ended\r
 #ifdef DEBUG\r
diff --git a/sst.h b/sst.h
index b0da117e2b880915c6927346f49cacf9e606ded0..375e7aaddcfc0d07407d91d80e5486f9bce18397 100644 (file)
--- a/sst.h
+++ b/sst.h
@@ -426,3 +426,4 @@ void clearscreen(void);
 void iostart(int);\r
 void ioend(void);\r
 void getline(char *, int);\r
+void commandhook(char *, int);\r