From 60fee0e6aef5bfc14151194ce9ec94326387af17 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 6 Dec 2015 08:40:14 +0100 Subject: [PATCH] client: Collect readline-related code in play.c Move prompt() from servcmd.c to play.c and give it external linkage. Signed-off-by: Markus Armbruster --- src/client/misc.h | 1 + src/client/play.c | 19 +++++++++++++++++++ src/client/servcmd.c | 28 ---------------------------- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/src/client/misc.h b/src/client/misc.h index ffdc2dfa5..dacaf12b4 100644 --- a/src/client/misc.h +++ b/src/client/misc.h @@ -61,6 +61,7 @@ int expect(int s, int match, char *buf); int tcp_connect(char *, char *); int login(int s, char *uname, char *cname, char *cpass, int kill_proc, int); int play(int, char *); +void prompt(int, char *, char *); void sendcmd(int s, char *cmd, char *arg); int servercmd(int, char *, int); void outch(char); diff --git a/src/client/play.c b/src/client/play.c index 2684a2b9f..9979ad697 100644 --- a/src/client/play.c +++ b/src/client/play.c @@ -699,3 +699,22 @@ play(int sock, char *history_file) #endif return ret; } + +void +prompt(int code, char *prompt, char *teles) +{ + char pr[1024]; + + snprintf(pr, sizeof(pr), "%s%s", teles, prompt); +#ifdef HAVE_LIBREADLINE + rl_set_prompt(pr); + rl_forced_update_display(); +#else /* !HAVE_LIBREADLINE */ + printf("%s", pr); + fflush(stdout); +#endif /* !HAVE_LIBREADLINE */ + if (auxfp) { + fprintf(auxfp, "%s%s", teles, prompt); + fflush(auxfp); + } +} diff --git a/src/client/servcmd.c b/src/client/servcmd.c index 75ec60b38..ba6d974e6 100644 --- a/src/client/servcmd.c +++ b/src/client/servcmd.c @@ -46,14 +46,6 @@ #include "proto.h" #include "secure.h" -#ifdef HAVE_LIBREADLINE -# if defined(HAVE_READLINE_READLINE_H) -# include -# elif defined(HAVE_READLINE_H) -# include -# endif /* defined(HAVE_READLINE_H) */ -#endif /* HAVE_LIBREADLINE */ - int eight_bit_clean; FILE *auxfp; int restricted; @@ -62,7 +54,6 @@ 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); @@ -137,25 +128,6 @@ servercmd(int code, char *arg, int len) return 0; } -static void -prompt(int code, char *prompt, char *teles) -{ - char pr[1024]; - - snprintf(pr, sizeof(pr), "%s%s", teles, prompt); -#ifdef HAVE_LIBREADLINE - rl_set_prompt(pr); - rl_forced_update_display(); -#else /* !HAVE_LIBREADLINE */ - printf("%s", pr); - fflush(stdout); -#endif /* !HAVE_LIBREADLINE */ - if (auxfp) { - fprintf(auxfp, "%s%s", teles, prompt); - fflush(auxfp); - } -} - static char * fname(char *s) { -- 2.43.0