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