[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] Re: your mail

From: Gunnar Farneback
Subject: Re: [gnugo-devel] Re: your mail
Date: Tue, 09 Oct 2001 21:06:08 +0200
User-agent: EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/20.7 (sparc-sun-solaris2.7) (with unibyte mode)

Dan wrote:
> Here's an implementation of this. I don't think it's ugly or
> impractical. In fact, this seems to be the simplest way.

I don't agree. I've tested it now and I find it mostly useless. This
really is a problem that is better solved on the controller side of
the gtp connection.

> The objection that can be raised to this patch is that we
> don't really want this in gtp.c.

Correct, we really don't want this in gtp.c. If you absolutely want
this functionality, the modifications to gtp.c and gtp.h must be
limited to what's in the appended patch. This is completely untested
and also requires a minor modification of play_gtp.c before it can


Index: interface/gtp.c
RCS file: /cvsroot/gnugo/gnugo/interface/gtp.c,v
retrieving revision 1.5
diff -u -r1.5 gtp.c
--- interface/gtp.c     2001/09/06 21:39:52     1.5
+++ interface/gtp.c     2001/10/09 19:03:00
@@ -60,7 +60,8 @@
 /* Read filehandle gtp_input linewise and interpret as GTP commands. */
-gtp_main_loop(struct gtp_command commands[], FILE *gtp_input)
+gtp_main_loop(struct gtp_command commands[], FILE *gtp_input,
+             gtp_hook_ptr pre_command_hook, gtp_hook_ptr post_command_hook)
   char line[GTP_BUFSIZE];
   char command[GTP_BUFSIZE];
@@ -97,7 +98,11 @@
     for (i = 0; commands[i].name != NULL; i++) {
       if (strcmp(command, commands[i].name) == 0) {
+       if (pre_command_hook != NULL)
+         (*pre_command_hook)(command);
        status = (*commands[i].function)(p, id);
+       if (post_command_hook != NULL)
+         (*post_command_hook)(command);
Index: interface/gtp.h
RCS file: /cvsroot/gnugo/gnugo/interface/gtp.h,v
retrieving revision 1.5
diff -u -r1.5 gtp.h
--- interface/gtp.h     2001/09/06 21:39:52     1.5
+++ interface/gtp.h     2001/10/09 19:03:00
@@ -54,6 +54,10 @@
 /* Function pointer for callback functions. */
 typedef int (*gtp_fn_ptr)(char *s, int id);
+/* Function pointer for hook functions. */
+typedef int (*gtp_hook_ptr)(char *s);
 /* Elements in the array of commands required by gtp_main_loop. */
 struct gtp_command {
   const char *name;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]