]> git.pond.sub.org Git - empserver/blobdiff - src/client/servcmd.c
Update copyright notice
[empserver] / src / client / servcmd.c
index 3aab4318bcba0d7782fa11ddaf304ac09d87922c..12017a19ee6e85fed8aa3a92e7e4b71c86af76e5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  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
@@ -30,7 +30,7 @@
  *     Dave Pare, 1989
  *     Steve McClure, 1998
  *     Ron Koenderink, 2005
- *     Markus Armbruster, 2005-2015
+ *     Markus Armbruster, 2005-2017
  */
 
 #include <config.h>
@@ -54,12 +54,11 @@ static FILE *redir_fp;
 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;
@@ -81,6 +80,7 @@ servercmd(int code, char *arg, int len)
                (void)fclose(redir_fp);
            redir_fp = NULL;
        }
+       outch('\n');
        prompt(code, the_prompt, teles);
        executing = 0;
        break;
@@ -90,15 +90,9 @@ servercmd(int code, char *arg, int len)
        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)
@@ -113,6 +107,7 @@ servercmd(int code, char *arg, int len)
        if (arg[0] != '\n') {
            snprintf(teles, sizeof(teles), "(%.*s) ", len - 1, arg);
            if (!redir_fp) {
+               outch('\n');
                putchar('\07');
                prompt(code, the_prompt, teles);
            }
@@ -129,20 +124,8 @@ servercmd(int code, char *arg, int len)
        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 *