------------------------------------------------
tty: menu_overlay -option to clear screen and align menus to left
tty: compile-time option to output escape codes for tile data hints
+unix: compile-time option MSGHANDLER to pass messages to external program
NetHack Community Patches (or Variation) Included
* Note that gnome-terminal at least doesn't work with this. */
/* #define TTY_TILES_ESCCODES */
+/* NetHack will execute an external program whenever a new message-window
+ * message is shown. The program to execute is given in environment variable
+ * NETHACK_MSGHANDLER. It will get the message as the only parameter.
+ * Only available with POSIX_TYPES or GNU C */
+/* #define MSGHANDLER */
+
/* #define STATUS_VIA_WINDOWPORT */ /* re-work of the status line
updating process */
/* #define STATUS_HILITES */ /* support hilites of status fields */
static char prevmsg[BUFSZ];
static char *FDECL(You_buf, (int));
+#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
+static void FDECL(execplinehandler, (const char *));
+#endif
/*VARARGS1*/
/* Note that these declarations rely on knowledge of the internals
flush_screen(1); /* %% */
putstr(WIN_MESSAGE, 0, line);
+
+#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
+ execplinehandler(line);
+#endif
+
/* this gets cleared after every pline message */
iflags.last_msg = PLNMSG_UNKNOWN;
strncpy(prevmsg, line, BUFSZ), prevmsg[BUFSZ - 1] = '\0';
}
}
+#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
+static boolean use_pline_handler = TRUE;
+static void
+execplinehandler(line)
+const char *line;
+{
+ int f;
+ const char *args[3];
+ char *env;
+
+ if (!use_pline_handler)
+ return;
+
+ if (!(env = nh_getenv("NETHACK_MSGHANDLER"))) {
+ use_pline_handler = FALSE;
+ return;
+ }
+
+ f = fork();
+ if (f == 0) { /* child */
+ args[0] = env;
+ args[1] = line;
+ args[2] = NULL;
+ (void) setgid(getgid());
+ (void) setuid(getuid());
+ (void) execv(args[0], (char *const *) args);
+ perror((char *) 0);
+ (void) fprintf(stderr, "Exec to message handler %s failed.\n",
+ env);
+ terminate(EXIT_FAILURE);
+ } else if (f == -1) {
+ perror((char *) 0);
+ use_pline_handler = FALSE;
+ pline("Fork to message handler failed.");
+ }
+}
+#endif /* defined(POSIX_TYPES) || defined(__GNUC__) */
+
/*pline.c*/