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:
Markus Armbruster 2015-12-06 08:40:14 +01:00
parent f83e61cdd2
commit 60fee0e6ae
3 changed files with 20 additions and 28 deletions

View file

@ -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);
}
}