/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2018, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire is free software: you can redistribute it and/or modify
* Dave Pare, 1989
* Steve McClure, 1998
* Ron Koenderink, 2005
- * Markus Armbruster, 2005-2015
+ * Markus Armbruster, 2005-2017
*/
#include <config.h>
static int redir_is_pipe;
static int executing;
-static void prompt(int, char *, char *);
static void doredir(char *p);
static void dopipe(char *p);
static int doexecute(char *p);
-void
+int
servercmd(int code, char *arg, int len)
{
static int nmin, nbtu, fd;
(void)fclose(redir_fp);
redir_fp = NULL;
}
+ outch('\n');
prompt(code, the_prompt, teles);
executing = 0;
break;
break;
case C_EXECUTE:
fd = doexecute(arg);
- if (fd < 0) {
- if (input_fd)
- close(input_fd);
- } else {
- assert(!input_fd);
+ if (fd >= 0)
executing = 1;
- }
- input_fd = fd;
- break;
+ return fd;
case C_EXIT:
printf("Exit: %s", arg);
if (auxfp)
if (arg[0] != '\n') {
snprintf(teles, sizeof(teles), "(%.*s) ", len - 1, arg);
if (!redir_fp) {
+ outch('\n');
putchar('\07');
prompt(code, the_prompt, teles);
}
assert(0);
break;
}
-}
-static void
-prompt(int code, char *prompt, char *teles)
-{
- char *nl;
-
- nl = code == C_PROMPT || code == C_INFORM ? "\n" : "";
- printf("%s%s%s", nl, teles, prompt);
- fflush(stdout);
- if (auxfp) {
- fprintf(auxfp, "%s%s%s", nl, teles, prompt);
- fflush(auxfp);
- }
+ return 0;
}
static char *