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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user