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 <armbru@pond.sub.org>
This commit is contained in:
parent
f83e61cdd2
commit
60fee0e6ae
3 changed files with 20 additions and 28 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,14 +46,6 @@
|
|||
#include "proto.h"
|
||||
#include "secure.h"
|
||||
|
||||
#ifdef HAVE_LIBREADLINE
|
||||
# if defined(HAVE_READLINE_READLINE_H)
|
||||
# include <readline/readline.h>
|
||||
# elif defined(HAVE_READLINE_H)
|
||||
# include <readline.h>
|
||||
# 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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue