diff --git a/usr.bin/ftp/cmds.c b/usr.bin/ftp/cmds.c index e49498d2b22f..7031163a0aa7 100644 --- a/usr.bin/ftp/cmds.c +++ b/usr.bin/ftp/cmds.c @@ -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 @@ restart(int argc, char *argv[]) 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 @@ restart(int argc, char *argv[]) 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 @@ sizecmd(int argc, char *argv[]) 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 --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index cc49e670a309..0dee2fd2e1cd 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -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 #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 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) 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 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) 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 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) 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 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) 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 --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c index e5cc2887d614..595e254a20e1 100644 --- a/usr.bin/ftp/ftp.c +++ b/usr.bin/ftp/ftp.c @@ -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 @@ sendrequest(const char *cmd, const char *local, const char *remote, 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 @@ recvrequest(const char *cmd, const char *local, const char *remote, 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 @@ proxtrans(const char *cmd, const char *local, const char *remote) 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 @@ proxtrans(const char *cmd, const char *local, const char *remote) 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 --git a/usr.bin/ftp/ftp_var.h b/usr.bin/ftp/ftp_var.h index 8c900c87e36c..24e7c51e5fa7 100644 --- a/usr.bin/ftp/ftp_var.h +++ b/usr.bin/ftp/ftp_var.h @@ -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 @@ extern char *__progname; /* from crt0.o */ #define EMPTYSTRING(x) ((x) == NULL || (*(x) == '\0')) #define FREEPTR(x) if ((x) != NULL) { free(x); (x) = NULL; } + + +#ifdef NO_QUAD +# define QUADF "%ld" +# define QUADFP(x) "%" x "ld" +# define QUADT long +# define STRTOLL(x,y,z) strtol(x,y,z) +#else +# define QUADF "%lld" +# define QUADFP(x) "%" x "lld" +# define QUADT long long +# define STRTOLL(x,y,z) strtoll(x,y,z) +#endif diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c index 3ca7bd52333c..110b5d4f4d5c 100644 --- a/usr.bin/ftp/util.c +++ b/usr.bin/ftp/util.c @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.97 2000/07/18 07:16:56 lukem Exp $ */ +/* $NetBSD: util.c,v 1.98 2000/07/30 04:42:38 lukem Exp $ */ /*- * Copyright (c) 1997-2000 The NetBSD Foundation, Inc. @@ -75,7 +75,7 @@ #include #ifndef lint -__RCSID("$NetBSD: util.c,v 1.97 2000/07/18 07:16:56 lukem Exp $"); +__RCSID("$NetBSD: util.c,v 1.98 2000/07/30 04:42:38 lukem Exp $"); #endif /* not lint */ /* @@ -655,11 +655,7 @@ remotesize(const char *file, int noisy) cp = strchr(reply_string, ' '); if (cp != NULL) { cp++; -#ifndef NO_QUAD - size = strtoll(cp, &ep, 10); -#else - size = strtol(cp, &ep, 10); -#endif + size = STRTOLL(cp, &ep, 10); if (*ep != '\0' && !isspace((unsigned char)*ep)) size = -1; } @@ -938,12 +934,8 @@ progressmeter(int flag) abbrevsize = cursize; for (i = 0; abbrevsize >= 100000 && i < sizeof(prefixes); i++) abbrevsize >>= 10; - len += snprintf(buf + len, BUFLEFT, -#ifndef NO_QUAD - " %5lld %c%c ", (long long)abbrevsize, -#else - " %5ld %c%c ", (long)abbrevsize, -#endif + len += snprintf(buf + len, BUFLEFT, " " QUADFP("5") " %c%c ", + (QUADT)abbrevsize, prefixes[i], i == 0 ? ' ' : 'B'); @@ -959,11 +951,8 @@ progressmeter(int flag) for (i = 1; bytespersec >= 1024000 && i < sizeof(prefixes); i++) bytespersec >>= 10; len += snprintf(buf + len, BUFLEFT, -#ifndef NO_QUAD - " %3lld.%02d %cB/s ", (long long)bytespersec / 1024, -#else - " %3ld.%02d %cB/s ", (long)bytespersec / 1024, -#endif + " " QUADFP("3") ".%02d %cB/s ", + (QUADT)(bytespersec / 1024), (int)((bytespersec % 1024) * 100 / 1024), prefixes[i]); @@ -1032,13 +1021,8 @@ ptransfer(int siginfo) bytespersec /= elapsed; } len = 0; - len += snprintf(buf + len, BUFLEFT, -#ifndef NO_QUAD - "%lld byte%s %s in ", (long long)bytes, -#else - "%ld byte%s %s in ", (long)bytes, -#endif - bytes == 1 ? "" : "s", direction); + len += snprintf(buf + len, BUFLEFT, QUADF " byte%s %s in ", + (QUADT)bytes, bytes == 1 ? "" : "s", direction); remaining = (int)elapsed; if (remaining > SECSPERDAY) { int days; @@ -1057,12 +1041,8 @@ ptransfer(int siginfo) for (i = 1; bytespersec >= 1024000 && i < sizeof(prefixes); i++) bytespersec >>= 10; - len += snprintf(buf + len, BUFLEFT, -#ifndef NO_QUAD - "(%lld.%02d %cB/s)", (long long)bytespersec / 1024, -#else - "(%ld.%02d %cB/s)", (long)bytespersec / 1024, -#endif + len += snprintf(buf + len, BUFLEFT, "(" QUADF ".%02d %cB/s)", + (QUADT)(bytespersec / 1024), (int)((bytespersec % 1024) * 100 / 1024), prefixes[i]); diff --git a/usr.bin/ftp/version.h b/usr.bin/ftp/version.h index ffe52f0d80e4..66a4aa40f6ed 100644 --- a/usr.bin/ftp/version.h +++ b/usr.bin/ftp/version.h @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.16 2000/07/28 12:01:40 lukem Exp $ */ +/* $NetBSD: version.h,v 1.17 2000/07/30 04:42:38 lukem Exp $ */ /*- * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. * All rights reserved. @@ -40,5 +40,5 @@ #endif #ifndef FTP_VERSION -#define FTP_VERSION "20000728" +#define FTP_VERSION "20000730" #endif