Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/ftp clean up NO_QUAD support: create helper #defines...



details:   https://anonhg.NetBSD.org/src/rev/4a6ed52f8fee
branches:  trunk
changeset: 495505:4a6ed52f8fee
user:      lukem <lukem%NetBSD.org@localhost>
date:      Sun Jul 30 04:42:37 2000 +0000

description:
clean up NO_QUAD support: create helper #defines and use as appropriate:
        #define         NOQUAD          ! NOQUAD
        -------         ------          - ------
        QUADF           "%ld"           "%lld"
        QUADFP(x)       "%" x "ld"      "%" x "lld"
        QUADT           long            long long
        STRTOL(x,y,z)   strtol(x,y,z)   strtoll(x,y,z)

diffstat:

 usr.bin/ftp/cmds.c    |  25 +++----------
 usr.bin/ftp/fetch.c   |  91 ++++++++++++--------------------------------------
 usr.bin/ftp/ftp.c     |  33 ++++--------------
 usr.bin/ftp/ftp_var.h |  15 +++++++-
 usr.bin/ftp/util.c    |  42 ++++++-----------------
 usr.bin/ftp/version.h |   4 +-
 6 files changed, 63 insertions(+), 147 deletions(-)

diffs (truncated from 421 to 300 lines):

diff -r c708669769af -r 4a6ed52f8fee usr.bin/ftp/cmds.c
--- a/usr.bin/ftp/cmds.c        Sun Jul 30 04:41:15 2000 +0000
+++ b/usr.bin/ftp/cmds.c        Sun Jul 30 04:42:37 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmds.c,v 1.88 2000/07/18 07:16:52 lukem Exp $  */
+/*     $NetBSD: cmds.c,v 1.89 2000/07/30 04:42:37 lukem Exp $  */
 
 /*-
  * Copyright (c) 1996-2000 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.88 2000/07/18 07:16:52 lukem Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.89 2000/07/30 04:42:37 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -2302,11 +2302,7 @@
                off_t rp;
                char *ep;
 
-#ifndef NO_QUAD
-               rp = strtoll(argv[1], &ep, 10);
-#else
-               rp = strtol(argv[1], &ep, 10);
-#endif
+               rp = STRTOLL(argv[1], &ep, 10);
                if (rp < 0 || *ep != '\0')
                        fprintf(ttyout, "restart: Invalid offset `%s'\n",
                            argv[1]);
@@ -2317,13 +2313,8 @@
                fputs("No restart point defined.\n", ttyout);
        else
                fprintf(ttyout,
-#ifndef NO_QUAD
-                   "Restarting at %lld for next get, put or append\n",
-                   (long long)restart_point);
-#else
-                   "Restarting at %ld for next get, put or append\n",
-                   (long)restart_point);
-#endif
+                   "Restarting at " QUADF " for next get, put or append\n",
+                   (QUADT)restart_point);
 }
 
 /*
@@ -2425,11 +2416,7 @@
        size = remotesize(argv[1], 1);
        if (size != -1)
                fprintf(ttyout,
-#ifndef NO_QUAD
-                   "%s\t%lld\n", argv[1], (long long)size);
-#else
-                   "%s\t%ld\n", argv[1], (long)size);
-#endif
+                   "%s\t" QUADF "\n", argv[1], (QUADT)size);
        code = (size > 0);
 }
 
diff -r c708669769af -r 4a6ed52f8fee usr.bin/ftp/fetch.c
--- a/usr.bin/ftp/fetch.c       Sun Jul 30 04:41:15 2000 +0000
+++ b/usr.bin/ftp/fetch.c       Sun Jul 30 04:42:37 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fetch.c,v 1.118 2000/07/18 06:49:21 lukem Exp $        */
+/*     $NetBSD: fetch.c,v 1.119 2000/07/30 04:42:37 lukem Exp $        */
 
 /*-
  * Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: fetch.c,v 1.118 2000/07/18 06:49:21 lukem Exp $");
+__RCSID("$NetBSD: fetch.c,v 1.119 2000/07/30 04:42:37 lukem Exp $");
 #endif /* not lint */
 
 /*
@@ -562,13 +562,8 @@
                if (verbose) {
                        fprintf(ttyout, "Copying %s", decodedpath);
                        if (restart_point)
-#ifndef NO_QUAD
-                               fprintf(ttyout, " (restarting at %lld)",
-                                   (long long)restart_point);
-#else
-                               fprintf(ttyout, " (restarting at %ld)",
-                                   (long)restart_point);
-#endif
+                               fprintf(ttyout, " (restarting at " QUADF ")",
+                                   (QUADT)restart_point);
                        fputs("\n", ttyout);
                }
        } else {                                /* ftp:// or http:// URLs */
@@ -813,17 +808,10 @@
                        fprintf(fin, "Connection: close\r\n");
                        if (restart_point) {
                                fputs(leading, ttyout);
-#ifndef NO_QUAD
-                               fprintf(fin, "Range: bytes=%lld-\r\n",
-                                   (long long)restart_point);
-                               fprintf(ttyout, "restarting at %lld",
-                                   (long long)restart_point);
-#else
-                               fprintf(fin, "Range: bytes=%ld-\r\n",
-                                   (long)restart_point);
-                               fprintf(ttyout, "restarting at %ld",
-                                   (long)restart_point);
-#endif
+                               fprintf(fin, "Range: bytes=" QUADF "-\r\n",
+                                   (QUADT)restart_point);
+                               fprintf(ttyout, "restarting at " QUADF,
+                                   (QUADT)restart_point);
                                leading = ", ";
                                hasleading++;
                        }
@@ -901,67 +889,38 @@
                        if (strncasecmp(cp, CONTENTLEN,
                                        sizeof(CONTENTLEN) - 1) == 0) {
                                cp += sizeof(CONTENTLEN) - 1;
-#ifndef NO_QUAD
-                               filesize = strtoll(cp, &ep, 10);
-#else
-                               filesize = strtol(cp, &ep, 10);
-#endif
+                               filesize = STRTOLL(cp, &ep, 10);
                                if (filesize < 0 || *ep != '\0')
                                        goto improper;
                                if (debug)
-#ifndef NO_QUAD
-                                       fprintf(ttyout, "parsed len as: %lld\n",
-                                           (long long)filesize);
-#else
-                                       fprintf(ttyout, "parsed len as: %ld\n",
-                                           (long)filesize);
-#endif
+                                       fprintf(ttyout,
+                                           "parsed len as: " QUADF "\n",
+                                           (QUADT)filesize);
 
 #define CONTENTRANGE "Content-Range: bytes "
                        } else if (strncasecmp(cp, CONTENTRANGE,
                                        sizeof(CONTENTRANGE) - 1) == 0) {
                                cp += sizeof(CONTENTRANGE) - 1;
-#ifndef NO_QUAD
-                               rangestart = strtoll(cp, &ep, 10);
-#else
-                               rangestart = strtol(cp, &ep, 10);
-#endif
+                               rangestart = STRTOLL(cp, &ep, 10);
                                if (rangestart < 0 || *ep != '-')
                                        goto improper;
                                cp = ep + 1;
-
-#ifndef NO_QUAD
-                               rangeend = strtoll(cp, &ep, 10);
-#else
-                               rangeend = strtol(cp, &ep, 10);
-#endif
+                               rangeend = STRTOLL(cp, &ep, 10);
                                if (rangeend < 0 || *ep != '/' ||
                                    rangeend < rangestart)
                                        goto improper;
                                cp = ep + 1;
-
-#ifndef NO_QUAD
-                               entitylen = strtoll(cp, &ep, 10);
-#else
-                               entitylen = strtol(cp, &ep, 10);
-#endif
+                               entitylen = STRTOLL(cp, &ep, 10);
                                if (entitylen < 0 || *ep != '\0')
                                        goto improper;
 
                                if (debug)
-#ifndef NO_QUAD
                                        fprintf(ttyout,
-                                           "parsed range as: %lld-%lld/%lld\n",
-                                           (long long)rangestart,
-                                           (long long)rangeend,
-                                           (long long)entitylen);
-#else
-                                       fprintf(ttyout,
-                                           "parsed range as: %ld-%ld/%ld\n",
-                                           (long)rangestart,
-                                           (long)rangeend,
-                                           (long)entitylen);
-#endif
+                                           "parsed range as: "
+                                           QUADF "-" QUADF "/" QUADF "\n",
+                                           (QUADT)rangestart,
+                                           (QUADT)rangeend,
+                                           (QUADT)entitylen);
                                if (! restart_point) {
                                        warnx(
                                    "Received unexpected Content-Range header");
@@ -1217,14 +1176,8 @@
                                goto cleanup_fetch_url;
                        }
                        if (debug)
-                               fprintf(ttyout,
-#ifndef NO_QUAD
-                                   "got chunksize of %lld\n",
-                                   (long long)chunksize);
-#else
-                                   "got chunksize of %ld\n",
-                                   (long)chunksize);
-#endif
+                               fprintf(ttyout, "got chunksize of " QUADF "\n",
+                                   (QUADT)chunksize);
                        if (chunksize == 0)
                                break;
                }
diff -r c708669769af -r 4a6ed52f8fee usr.bin/ftp/ftp.c
--- a/usr.bin/ftp/ftp.c Sun Jul 30 04:41:15 2000 +0000
+++ b/usr.bin/ftp/ftp.c Sun Jul 30 04:42:37 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftp.c,v 1.102 2000/07/18 07:16:54 lukem Exp $  */
+/*     $NetBSD: ftp.c,v 1.103 2000/07/30 04:42:37 lukem Exp $  */
 
 /*-
  * Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
@@ -103,7 +103,7 @@
 #if 0
 static char sccsid[] = "@(#)ftp.c      8.6 (Berkeley) 10/27/94";
 #else
-__RCSID("$NetBSD: ftp.c,v 1.102 2000/07/18 07:16:54 lukem Exp $");
+__RCSID("$NetBSD: ftp.c,v 1.103 2000/07/30 04:42:37 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -819,12 +819,7 @@
                        warn("local: %s", local);
                        goto cleanupsend;
                }
-#ifndef NO_QUAD
-               if (command("REST %lld", (long long) restart_point) !=
-#else
-               if (command("REST %ld", (long) restart_point) !=
-#endif
-                   CONTINUE)
+               if (command("REST " QUADF, (QUADT)restart_point) != CONTINUE)
                        goto cleanupsend;
                lmode = "r+w";
        }
@@ -1128,11 +1123,7 @@
        if (sigsetjmp(xferabort, 1))
                goto abort;
        if (is_retr && restart_point &&
-#ifndef NO_QUAD
-           command("REST %lld", (long long) restart_point) != CONTINUE)
-#else
-           command("REST %ld", (long) restart_point) != CONTINUE)
-#endif
+           command("REST " QUADF, (QUADT) restart_point) != CONTINUE)
                goto cleanuprecv;
        if (! EMPTYSTRING(remote)) {
                if (command("%s %s", cmd, remote) != PRELIM)
@@ -1981,12 +1972,8 @@
                goto abort;
        oldintr = xsignal(SIGINT, abortpt);
        if ((restart_point &&
-#ifndef NO_QUAD
-           (command("REST %lld", (long long) restart_point) != CONTINUE)
-#else
-           (command("REST %ld", (long) restart_point) != CONTINUE)
-#endif
-           ) || (command("%s %s", cmd, remote) != PRELIM)) {
+           (command("REST " QUADF, (QUADT) restart_point) != CONTINUE))
+           || (command("%s %s", cmd, remote) != PRELIM)) {
                (void)xsignal(SIGINT, oldintr);
                pswitch(1);
                return;
@@ -1995,12 +1982,8 @@
        pswitch(1);
        secndflag++;
        if ((restart_point &&
-#ifndef NO_QUAD
-           (command("REST %lld", (long long) restart_point) != CONTINUE)
-#else
-           (command("REST %ld", (long) restart_point) != CONTINUE)
-#endif
-           ) || (command("%s %s", cmd2, local) != PRELIM))
+           (command("REST " QUADF, (QUADT) restart_point) != CONTINUE))
+           || (command("%s %s", cmd2, local) != PRELIM))
                goto abort;
        ptflag++;
        (void)getreply(0);
diff -r c708669769af -r 4a6ed52f8fee usr.bin/ftp/ftp_var.h
--- a/usr.bin/ftp/ftp_var.h     Sun Jul 30 04:41:15 2000 +0000
+++ b/usr.bin/ftp/ftp_var.h     Sun Jul 30 04:42:37 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftp_var.h,v 1.56 2000/07/28 11:03:13 lukem Exp $       */
+/*     $NetBSD: ftp_var.h,v 1.57 2000/07/30 04:42:38 lukem Exp $       */
 
 /*-
  * Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
@@ -337,3 +337,16 @@
 
 #define        EMPTYSTRING(x)  ((x) == NULL || (*(x) == '\0'))



Home | Main Index | Thread Index | Old Index