Add some basic readline support.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1071 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1996-11-24 08:37:21 +00:00
parent b25480e04b
commit 6ec154ff86

View File

@@ -188,6 +188,28 @@ tail(filename)
}
*/
#ifndef HAVE_READLINE
static char *
readline(char *prompt)
{
char buf[BUFSIZ];
printf ("%s", prompt);
fflush (stdout);
if(fgets(buf, sizeof(buf), stdin) == NULL)
return NULL;
if (buf[strlen(buf) - 1] == '\n')
buf[strlen(buf) - 1] = '\0';
return strdup(buf);
}
static void
add_history(char *p)
{
}
#endif
/*
* Command parser.
*/
@@ -201,11 +223,19 @@ cmdscanner(int top)
putchar('\n');
for (;;) {
if (fromatty) {
printf("ftp> ");
fflush(stdout);
}
char *p;
p = readline("ftp> ");
if(p == NULL)
quit(0, 0);
strncpy(line, p, sizeof(line));
line[sizeof(line) - 1] = 0;
add_history(p);
free(p);
} else{
if (fgets(line, sizeof line, stdin) == NULL)
quit(0, 0);
}
/* XXX will break on long lines */
l = strlen(line);
if (l == 0)
break;