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.
|
* Command parser.
|
||||||
*/
|
*/
|
||||||
@@ -201,11 +223,19 @@ cmdscanner(int top)
|
|||||||
putchar('\n');
|
putchar('\n');
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (fromatty) {
|
if (fromatty) {
|
||||||
printf("ftp> ");
|
char *p;
|
||||||
fflush(stdout);
|
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)
|
if (fgets(line, sizeof line, stdin) == NULL)
|
||||||
quit(0, 0);
|
quit(0, 0);
|
||||||
|
}
|
||||||
|
/* XXX will break on long lines */
|
||||||
l = strlen(line);
|
l = strlen(line);
|
||||||
if (l == 0)
|
if (l == 0)
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user