add `-l' for no line-editing

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9183 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
2000-11-15 22:56:35 +00:00
parent d070c0181a
commit 83524f36ad

View File

@@ -54,10 +54,11 @@ main(int argc, char **argv)
doglob = 1;
interactive = 1;
autologin = 1;
lineedit = 1;
passivemode = 0; /* passive mode not active */
use_kerberos = 1;
while ((ch = getopt(argc, argv, "dginptvK")) != -1) {
while ((ch = getopt(argc, argv, "dgilnptvK")) != -1) {
switch (ch) {
case 'd':
options |= SO_DEBUG;
@@ -72,6 +73,9 @@ main(int argc, char **argv)
interactive = 0;
break;
case 'l':
lineedit = 0;
break;
case 'n':
autologin = 0;
break;
@@ -94,7 +98,7 @@ main(int argc, char **argv)
default:
fprintf(stderr,
"usage: ftp [-dginptvK] [host [port]]\n");
"usage: ftp [-dgilnptvK] [host [port]]\n");
exit(1);
}
}
@@ -206,10 +210,8 @@ tail(filename)
}
*/
#ifndef HAVE_READLINE
static char *
readline(char *prompt)
simple_readline(char *prompt)
{
char buf[BUFSIZ];
printf ("%s", prompt);
@@ -221,6 +223,14 @@ readline(char *prompt)
return strdup(buf);
}
#ifndef HAVE_READLINE
static char *
readline(char *prompt)
{
return simple_readline (prompt);
}
static void
add_history(char *p)
{
@@ -249,13 +259,17 @@ cmdscanner(int top)
for (;;) {
if (fromatty) {
char *p;
p = readline("ftp> ");
if (lineedit)
p = readline("ftp> ");
else
p = simple_readline("ftp> ");
if(p == NULL) {
printf("\n");
quit(0, 0);
}
strlcpy(line, p, sizeof(line));
add_history(p);
if (lineedit)
add_history(p);
free(p);
} else{
if (fgets(line, sizeof line, stdin) == NULL)