summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/ftp/ftp.17
-rw-r--r--usr.bin/ftp/ftp.c16
-rw-r--r--usr.bin/ftp/ftp_var.h3
-rw-r--r--usr.bin/ftp/main.c38
4 files changed, 46 insertions, 18 deletions
diff --git a/usr.bin/ftp/ftp.1 b/usr.bin/ftp/ftp.1
index 84d16d699b5..b1e149e1a8d 100644
--- a/usr.bin/ftp/ftp.1
+++ b/usr.bin/ftp/ftp.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ftp.1,v 1.3 1996/09/13 03:21:18 deraadt Exp $
+.\" $OpenBSD: ftp.1,v 1.4 1996/10/31 14:36:55 mickey Exp $
.\" $NetBSD: ftp.1,v 1.11 1995/09/08 01:06:24 tls Exp $
.\"
.\" Copyright (c) 1985, 1989, 1990, 1993
@@ -50,6 +50,7 @@ file transfer program
.Op Fl i
.Op Fl n
.Op Fl g
+.Op Fl r Ar seconds
.Op Ar host
.Nm ftp
.Ar http://host/path/file.html
@@ -101,6 +102,10 @@ multiple file transfers.
Enables debugging.
.It Fl g
Disables file name globbing.
+.It Fl r Ar number
+Retry to connect if failed, pausing for
+.Ar number
+of seconds.
.El
.Pp
The client host with which
diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c
index 26218c7f90e..cd142947dd6 100644
--- a/usr.bin/ftp/ftp.c
+++ b/usr.bin/ftp/ftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftp.c,v 1.5 1996/08/02 05:56:23 deraadt Exp $ */
+/* $OpenBSD: ftp.c,v 1.6 1996/10/31 14:36:56 mickey Exp $ */
/* $NetBSD: ftp.c,v 1.13 1995/09/16 22:32:59 pk Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
#else
-static char rcsid[] = "$OpenBSD: ftp.c,v 1.5 1996/08/02 05:56:23 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ftp.c,v 1.6 1996/10/31 14:36:56 mickey Exp $";
#endif
#endif /* not lint */
@@ -372,8 +372,11 @@ getreply(expecteof)
code = 421;
return (4);
}
- if (c != '\r' && (verbose > 0 ||
- (verbose > -1 && n == '5' && dig > 4))) {
+ if (n == 0)
+ n = c;
+ if (c != '\r' && (n < '5' || !retry_connect) &&
+ (verbose > 0 ||
+ (verbose > -1 && n == '5' && dig > 4))) {
if (proxflag &&
(dig == 1 || dig == 5 && verbose == 0))
printf("%s:",hostname);
@@ -398,12 +401,11 @@ getreply(expecteof)
code = 0;
continuation++;
}
- if (n == 0)
- n = c;
if (cp < &reply_string[sizeof(reply_string) - 1])
*cp++ = c;
}
- if (verbose > 0 || verbose > -1 && n == '5') {
+ if ((verbose > 0 || (verbose > -1 && n == '5')) &&
+ (n < '5' || !retry_connect)) {
(void) putchar(c);
(void) fflush (stdout);
}
diff --git a/usr.bin/ftp/ftp_var.h b/usr.bin/ftp/ftp_var.h
index c840bf705f2..d58f30e77af 100644
--- a/usr.bin/ftp/ftp_var.h
+++ b/usr.bin/ftp/ftp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftp_var.h,v 1.3 1996/06/26 05:33:37 deraadt Exp $ */
+/* $OpenBSD: ftp_var.h,v 1.4 1996/10/31 14:36:56 mickey Exp $ */
/* $NetBSD: ftp_var.h,v 1.7 1995/09/15 00:32:35 pk Exp $ */
/*
@@ -87,6 +87,7 @@ int mode; /* file transfer mode */
char bytename[32]; /* local byte size in ascii */
int bytesize; /* local byte size in binary */
int anonftp; /* force an anonftp login */
+int retry_connect; /* retry connect if failed */
char *hostname; /* name of host connected to */
int unix_server; /* server is unix, can use binary for ascii */
diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c
index df9eb3c5732..a8c618ef680 100644
--- a/usr.bin/ftp/main.c
+++ b/usr.bin/ftp/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.6 1996/09/03 18:00:06 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.7 1996/10/31 14:36:57 mickey Exp $ */
/*
* Copyright (c) 1985, 1989, 1993, 1994
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.6 1996/09/03 18:00:06 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.7 1996/10/31 14:36:57 mickey Exp $";
#endif
#endif /* not lint */
@@ -87,7 +87,7 @@ main(argc, argv)
interactive = 1;
autologin = 1;
- while ((ch = getopt(argc, argv, "p:dgintv")) != EOF) {
+ while ((ch = getopt(argc, argv, "p:r:dgintv")) != EOF) {
switch (ch) {
case 'd':
options |= SO_DEBUG;
@@ -110,6 +110,18 @@ main(argc, argv)
force_port = atoi(optarg);
break;
+ case 'r':
+ if (isdigit(*optarg))
+ retry_connect = atoi(optarg);
+ else {
+ extern char *__progname;
+ (void)fprintf(stderr,
+ "%s: -r requires numeric argument\n",
+ __progname);
+ exit(1);
+ }
+ break;
+
case 't':
trace++;
break;
@@ -119,8 +131,8 @@ main(argc, argv)
break;
default:
- (void)fprintf(stderr,
- "usage: ftp [-dgintv] [host [port]]\n");
+ (void)fprintf(stderr, "usage: "
+ "ftp [-dgintv] [-r<seconds>] [host [port]]\n");
exit(1);
}
}
@@ -191,14 +203,13 @@ main(argc, argv)
}
xargv[1] = host;
- xargv[2] = NULL;
xargc = 2;
if (force_port) {
- xargv[2] = portstr;
+ xargv[xargc++] = portstr;
snprintf(portstr, sizeof portstr, "%d",
force_port);
- xargc++;
}
+ xargv[xargc] = NULL;
setpeer(xargc, xargv);
if (!connected) {
printf("failed to connect to %s\n", host);
@@ -247,7 +258,16 @@ bail:
xargv[2] = argv[1];
xargv[3] = argv[2];
xargv[4] = NULL;
- setpeer(argc+1, xargv);
+ do {
+ setpeer(argc+1, xargv);
+ if (!retry_connect)
+ break;
+ if (!connected) {
+ macnum = 0;
+ printf("Retrying...\n");
+ sleep(retry_connect);
+ }
+ } while (!connected);
}
top = setjmp(toplevel) == 0;
if (top) {