Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/ftp * fix up confirm() (broke `a' and `p' in last co...



details:   https://anonhg.NetBSD.org/src/rev/4bb084673893
branches:  trunk
changeset: 477154:4bb084673893
user:      lukem <lukem%NetBSD.org@localhost>
date:      Wed Oct 13 02:47:54 1999 +0000

description:
* fix up confirm() (broke `a' and `p' in last commit)
* simplify main loop (don't need `top' variable any more)
* use a struct sockaddr_in6.sin6_addr for the result from inet_pton(),
  rather than u_char buf[16]
* add a few more comments

diffstat:

 usr.bin/ftp/cmds.c   |  14 ++++++--------
 usr.bin/ftp/extern.h |   4 ++--
 usr.bin/ftp/main.c   |  32 +++++++++++---------------------
 usr.bin/ftp/util.c   |  31 ++++++++++++++++++++++++++-----
 4 files changed, 45 insertions(+), 36 deletions(-)

diffs (256 lines):

diff -r 3e90c8ded3b2 -r 4bb084673893 usr.bin/ftp/cmds.c
--- a/usr.bin/ftp/cmds.c        Wed Oct 13 02:25:26 1999 +0000
+++ b/usr.bin/ftp/cmds.c        Wed Oct 13 02:47:54 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmds.c,v 1.74 1999/10/12 06:04:59 lukem Exp $  */
+/*     $NetBSD: cmds.c,v 1.75 1999/10/13 02:47:54 lukem Exp $  */
 
 /*-
  * Copyright (c) 1996-1999 The NetBSD Foundation, Inc.
@@ -107,7 +107,7 @@
 #if 0
 static char sccsid[] = "@(#)cmds.c     8.6 (Berkeley) 10/9/94";
 #else
-__RCSID("$NetBSD: cmds.c,v 1.74 1999/10/12 06:04:59 lukem Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.75 1999/10/13 02:47:54 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -176,8 +176,6 @@
                                fprintf(ttyout,
                                    "Prompting off for duration of %s.\n", cmd);
                                break;
-                       case 'n':
-                               return (0);
                        case 'p':
                                interactive = 0;
                                fputs("Interactive mode: off.\n", ttyout);
@@ -185,10 +183,9 @@
                        case 'q':
                                mflag = 0;
                                fprintf(ttyout, "%s aborted\n", mname);
+                               /* FALLTHROUGH */
+                       case 'n':
                                return (0);
-                       case 'y':
-                       default:
-                               return (1);
                        case '?':
                                fprintf(ttyout,
                                    " confirmation options:\n"
@@ -199,8 +196,9 @@
                                    "\ty  answer `yes' for this file\n"
                                    "\t?  this help list\n",
                                    cmd, cmd);
-                               break;
+                               continue;       /* back to while(1) */
                }
+               return (1);
        }
        /* NOTREACHED */
 }
diff -r 3e90c8ded3b2 -r 4bb084673893 usr.bin/ftp/extern.h
--- a/usr.bin/ftp/extern.h      Wed Oct 13 02:25:26 1999 +0000
+++ b/usr.bin/ftp/extern.h      Wed Oct 13 02:47:54 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.46 1999/10/12 06:04:59 lukem Exp $        */
+/*     $NetBSD: extern.h,v 1.47 1999/10/13 02:47:54 lukem Exp $        */
 
 /*-
  * Copyright (c) 1996-1999 The NetBSD Foundation, Inc.
@@ -117,7 +117,7 @@
 void   changetype __P((int, int));
 void   cmdabort __P((int));
 void   cmdtimeout __P((int));
-void   cmdscanner __P((int));
+void   cmdscanner __P((void));
 void   crankrate __P((int));
 int    command __P((const char *, ...));
 #ifndef NO_EDITCOMPLETE
diff -r 3e90c8ded3b2 -r 4bb084673893 usr.bin/ftp/main.c
--- a/usr.bin/ftp/main.c        Wed Oct 13 02:25:26 1999 +0000
+++ b/usr.bin/ftp/main.c        Wed Oct 13 02:47:54 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.63 1999/10/12 06:05:01 lukem Exp $  */
+/*     $NetBSD: main.c,v 1.64 1999/10/13 02:47:54 lukem Exp $  */
 
 /*-
  * Copyright (c) 1996-1999 The NetBSD Foundation, Inc.
@@ -108,7 +108,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.6 (Berkeley) 10/9/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.63 1999/10/12 06:05:01 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.64 1999/10/13 02:47:54 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -143,7 +143,7 @@
        int argc;
        char *argv[];
 {
-       int ch, top, rval;
+       int ch, rval;
        struct passwd *pw = NULL;
        char *cp, *ep;
        int dumbterm, s, len;
@@ -449,15 +449,12 @@
 #ifndef NO_EDITCOMPLETE
        controlediting();
 #endif /* !NO_EDITCOMPLETE */
-       top = sigsetjmp(toplevel, 1) == 0;
-       if (top) {
-               (void)xsignal(SIGINT, intr);
-               (void)xsignal(SIGPIPE, (sig_t)lostpeer);
-       }
-       for (;;) {
-               cmdscanner(top);
-               top = 1;
-       }
+
+       (void)sigsetjmp(toplevel, 1);
+       (void)xsignal(SIGINT, intr);
+       (void)xsignal(SIGPIPE, (sig_t)lostpeer);
+       for (;;)
+               cmdscanner();
 }
 
 void
@@ -466,7 +463,7 @@
 {
 
        alarmtimer(0);
-       if (editing)            /* ugly hack to cleanup after editline */
+       if (fromatty)
                write(fileno(ttyout), "\n", 1);
        siglongjmp(toplevel, 1);
 }
@@ -517,18 +514,11 @@
  * Command parser.
  */
 void
-cmdscanner(top)
-       int top;
+cmdscanner()
 {
        struct cmd *c;
        int num;
 
-       if (!top
-#ifndef NO_EDITCOMPLETE
-           && !editing
-#endif /* !NO_EDITCOMPLETE */
-           )
-               (void)putc('\n', ttyout);
        for (;;) {
 #ifndef NO_EDITCOMPLETE
                if (!editing) {
diff -r 3e90c8ded3b2 -r 4bb084673893 usr.bin/ftp/util.c
--- a/usr.bin/ftp/util.c        Wed Oct 13 02:25:26 1999 +0000
+++ b/usr.bin/ftp/util.c        Wed Oct 13 02:47:54 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.77 1999/10/12 06:05:01 lukem Exp $  */
+/*     $NetBSD: util.c,v 1.78 1999/10/13 02:47:54 lukem Exp $  */
 
 /*-
  * Copyright (c) 1997-1999 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: util.c,v 1.77 1999/10/12 06:05:01 lukem Exp $");
+__RCSID("$NetBSD: util.c,v 1.78 1999/10/13 02:47:54 lukem Exp $");
 #endif /* not lint */
 
 /*
@@ -85,6 +85,7 @@
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
+#include <netinet/in.h>
 #include <arpa/ftp.h>
 
 #include <ctype.h>
@@ -618,6 +619,9 @@
 
 static void updateprogressmeter __P((int));
 
+/*
+ * SIGALRM handler to update the progress meter
+ */
 static void
 updateprogressmeter(dummy)
        int dummy;
@@ -876,7 +880,7 @@
 }
 
 /*
- * Print transfer stats if a transfer is in progress
+ * SIG{INFO,QUIT} handler to print transfer stats if a transfer is in progress
  */
 void
 psummary(notused)
@@ -1098,6 +1102,9 @@
                warn("unable to set rcvbuf size %d", rcvbuf_size);
 }
 
+/*
+ * Copy characters from src into dst, \ quoting characters that require it
+ */
 void
 ftpvis(dst, dstlen, src, srclen)
        char            *dst;
@@ -1138,9 +1145,9 @@
 {
        int rv = 0;
 #ifdef INET6
-       u_char buf[16];         /* XXX: sizeof(struct in_addr6) */
+       struct sockaddr_in6 su_sin6;
 
-       rv = inet_pton(AF_INET6, addr, &buf);
+       rv = inet_pton(AF_INET6, addr, &su_sin6.sin6_addr);
        if (debug)
                fprintf(ttyout, "isipv6addr: got %d for %s\n", rv, addr);
 #endif
@@ -1174,6 +1181,9 @@
        return (listen(sock, backlog));
 }
 
+/*
+ * malloc() with inbuilt error checking
+ */
 void *
 xmalloc(size)
        size_t size;
@@ -1186,6 +1196,9 @@
        return (p);
 }
 
+/*
+ * strdup() with inbuilt error checking
+ */
 char *
 xstrdup(str)
        const char *str;
@@ -1200,6 +1213,10 @@
        return (s);
 }
 
+/*
+ * Install a POSIX signal handler, allowing the invoker to set whether
+ * the signal should be restartable or not
+ */
 sig_t
 xsignal_restart(sig, func, restartable)
        int sig;
@@ -1222,6 +1239,10 @@
        return (oact.sa_handler);
 }
 
+/*
+ * Install a signal handler with the `restartable' flag set dependent upon
+ * which signal is being set. (This is a wrapper to xsignal_restart())
+ */
 sig_t
 xsignal(sig, func)
        int sig;



Home | Main Index | Thread Index | Old Index