From 83524f36ad6cda88d937d1d8648a93b9de51680f Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Wed, 15 Nov 2000 22:56:35 +0000 Subject: [PATCH] add `-l' for no line-editing git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9183 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftp/main.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/appl/ftp/ftp/main.c b/appl/ftp/ftp/main.c index b423f461a..8d4aeb730 100644 --- a/appl/ftp/ftp/main.c +++ b/appl/ftp/ftp/main.c @@ -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)