bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-inetutils] ftp 1.5 open - arguments too long?


From: Barry deFreese
Subject: Re: [bug-inetutils] ftp 1.5 open - arguments too long?
Date: Mon, 26 Mar 2007 21:38:12 -0400
User-agent: Thunderbird 1.5.0.10 (Windows/20070221)

Alfred M. Szmidt wrote:
   ftp> open

   gets the error:
   sorry, arguments too long

   Too long?  Too short I could understand :).

That bug is qute strange I should add! and on a first glance I don't
get it.

   However, I suggest an enhancement: have open without an argument re-open
   the previous host, if there is one.  E.g.,

   ftp ftp.gnu.org
   ... connects ...
   ftp> close
   221 Goodbye.
   ftp> open
   ... connects again to ftp.gnu.org ...

A very good idea and I think I will implement it, the `other' (*BSD)
ftp does not do this.  But I'm not sure if we want to be compatible
here or not.  Right now the way `open' should work (if we ignore the
above bug) is that if you type it without any arguments, you get a
interactive prompt like this (_!_ being where the cursor is):

ftp> open
(to) _!_

Hey folks,

Here is a preliminary patch for the arguments too long issue. I think I still have a memory problem somewhere and I'm not sure if it is the cleanest, so any input is greatly appreciate.

I'm also just about done with argp'ifying ftp but someone yelled at me to get this done first. ;-)

Thanks,

Barry deFreese (aka bddebian)


diff -urN inetutils-20070322/ftp/cmds.c 
ftp_readline/inetutils-20070322/ftp/cmds.c
--- inetutils-20070322/ftp/cmds.c       2007-03-21 21:44:58.000000000 -0400
+++ ftp_readline/inetutils-20070322/ftp/cmds.c  2007-03-26 17:46:59.000000000 
-0400
@@ -69,6 +69,10 @@
    system headers on some platforms. */
 #include <glob.h>
 
+#if HAVE_READLINE_READLINE_H
+# include <readline/readline.h>
+#endif
+
 #include "ftp_var.h"
 
 /* Returns true if STR is entirely lower case.  */
@@ -136,20 +140,42 @@
      char ***pargv;
      char *prompt;
 {
-  int len = strlen (line), ret;
+  int ret, len;
+
+#if HAVE_LIBREADLINE
+  char *l;
+
+  l = readline (prompt);
+  if (!l)
+    quit(0, 0);
+
+  line = strcat (line, " ");
+  line = strcat (line, l);
+
+  if (l)
+    free (l);
+
+  if (line && *line)
+    add_history (line);
+
+  len = strlen (line);
+#else
+  len = strlen (line);
 
   if (len >= sizeof (line) - 3)
     {
       printf ("sorry, arguments too long\n");
       intr ();
     }
-  printf ("(%s) ", prompt);
+  printf ("%s", prompt);
   line[len++] = ' ';
   if (fgets (&line[len], sizeof (line) - len, stdin) == NULL)
     intr ();
   len += strlen (&line[len]);
   if (len > 0 && line[len - 1] == '\n')
     line[len - 1] = '\0';
+#endif
+
   makeargv ();
   ret = margc > *pargc;
   *pargc = margc;
@@ -176,7 +202,7 @@
       return;
     }
   if (argc < 2)
-    another (&argc, &argv, "to");
+    another (&argc, &argv, "(to) ");
   if (argc < 2 || argc > 3)
     {
       printf ("usage: %s host-name [port]\n", argv[0]);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]