/* 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 */
+ * Only available with POSIX_TYPES, GNU C, or WIN32 */
/* #define MSGHANDLER */
/* enable status highlighting via STATUS_HILITE directives in run-time
static void putmesg(const char *);
static char *You_buf(int);
-#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
+#if defined(MSGHANDLER)
static void execplinehandler(const char *);
#endif
#ifdef USER_SOUNDS
putmesg(line);
-#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
+#if defined(MSGHANDLER)
execplinehandler(line);
#endif
pbuf[BUFSZ - 1] = '\0'; /* terminate strncpy or truncate vsprintf */
}
raw_print(line);
-#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
+#if defined(MSGHANDLER)
execplinehandler(line);
#endif
}
RESTORE_WARNING_FORMAT_NONLITERAL
-#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
+#if defined(MSGHANDLER)
static boolean use_pline_handler = TRUE;
static void
return;
}
+#if defined(POSIX_TYPES) || defined(__GNUC__)
f = fork();
if (f == 0) { /* child */
args[0] = env;
use_pline_handler = FALSE;
pline("%s", "Fork to message handler failed.");
}
+#elif defined(WIN32)
+ {
+ intptr_t ret;
+ args[0] = env;
+ args[1] = line;
+ args[2] = NULL;
+ ret = _spawnv(_P_NOWAIT, env, args);
+ }
+#else
+#error MSGHANDLER is not implemented on this sysytem.
+#endif
}
-#endif /* MSGHANDLER && (POSIX_TYPES || __GNUC__) */
+#endif /* MSGHANDLER */
/*
* varargs handling for files.c