aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/lukemftp/src/main.c
diff options
context:
space:
mode:
authorMike Heffner <mikeh@FreeBSD.org>2005-02-20 17:33:34 +0000
committerMike Heffner <mikeh@FreeBSD.org>2005-02-20 17:33:34 +0000
commit90580277219d71354d55ed572fca05ccbec50a31 (patch)
treeb3e525aeb6db7ad0b9e566173c63af30b14693ce /contrib/lukemftp/src/main.c
parent7e475d60f53f104292ac3b1c0015eeb52678c424 (diff)
downloadsrc-90580277219d71354d55ed572fca05ccbec50a31.tar.gz
src-90580277219d71354d55ed572fca05ccbec50a31.zip
Import the latest CVS version of lukemftp.
Short list of changes: * SIGINT termination from auto-fetch. * Less trusting of remote filenames during auto mgets. * Improved RFC2616 compliancy. * Fix globs when using ftp reget (from mat@). * Limit send buffer size.
Notes
Notes: svn path=/vendor/lukemftp/dist/; revision=142129
Diffstat (limited to 'contrib/lukemftp/src/main.c')
-rw-r--r--contrib/lukemftp/src/main.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/contrib/lukemftp/src/main.c b/contrib/lukemftp/src/main.c
index be2940a1d0bb..ffed2571b1a4 100644
--- a/contrib/lukemftp/src/main.c
+++ b/contrib/lukemftp/src/main.c
@@ -1,7 +1,7 @@
-/* $NetBSD: main.c,v 1.86 2003/08/07 11:13:56 agc Exp $ */
+/* $NetBSD: main.c,v 1.90 2004/07/21 00:09:14 lukem Exp $ */
/*-
- * Copyright (c) 1996-2002 The NetBSD Foundation, Inc.
+ * Copyright (c) 1996-2004 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -104,7 +104,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 1989, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
#else
-__RCSID("$NetBSD: main.c,v 1.86 2003/08/07 11:13:56 agc Exp $");
+__RCSID("$NetBSD: main.c,v 1.90 2004/07/21 00:09:14 lukem Exp $");
#endif
#endif /* not lint */
@@ -119,6 +119,7 @@ __RCSID("$NetBSD: main.c,v 1.86 2003/08/07 11:13:56 agc Exp $");
#include <netdb.h>
#include <paths.h>
#include <pwd.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -147,6 +148,8 @@ main(int argc, char *argv[])
setlocale(LC_ALL, "");
setprogname(argv[0]);
+ sigint_raised = 0;
+
ftpport = "ftp";
httpport = "http";
gateport = NULL;
@@ -214,9 +217,14 @@ main(int argc, char *argv[])
(void)close(s);
/* sanity check returned buffer sizes */
if (rcvbuf_size <= 0)
- rcvbuf_size = 8192;
+ rcvbuf_size = 8 * 1024;
if (sndbuf_size <= 0)
- sndbuf_size = 8192;
+ sndbuf_size = 8 * 1024;
+
+ if (sndbuf_size > 8 * 1024 * 1024)
+ sndbuf_size = 8 * 1024 * 1024;
+ if (rcvbuf_size > 8 * 1024 * 1024)
+ rcvbuf_size = 8 * 1024 * 1024;
marg_sl = xsl_init();
if ((tmpdir = getenv("TMPDIR")) == NULL)
@@ -501,17 +509,22 @@ main(int argc, char *argv[])
if (argc > 0) {
if (isupload) {
rval = auto_put(argc, argv, upload_path);
+ sigint_or_rval_exit:
+ if (sigint_raised) {
+ (void)xsignal(SIGINT, SIG_DFL);
+ raise(SIGINT);
+ }
exit(rval);
} else if (strchr(argv[0], ':') != NULL
&& ! isipv6addr(argv[0])) {
rval = auto_fetch(argc, argv);
if (rval >= 0) /* -1 == connected and cd-ed */
- exit(rval);
+ goto sigint_or_rval_exit;
} else {
char *xargv[4], *user, *host;
- if (sigsetjmp(toplevel, 1))
- exit(0);
+ if ((rval = sigsetjmp(toplevel, 1)))
+ goto sigint_or_rval_exit;
(void)xsignal(SIGINT, intr);
(void)xsignal(SIGPIPE, lostpeer);
user = NULL;
@@ -1024,8 +1037,8 @@ usage(void)
const char *progname = getprogname();
(void)fprintf(stderr,
-"usage: %s [-46AadefginpRtvV] [-N netrc] [-o outfile] [-P port] [-r retry]\n"
-" [-T dir,max[,inc][[user@]host [port]]] [host:path[/]]\n"
+"usage: %s [-46AadefginpRtvV] [-N netrc] [-o outfile] [-P port] [-q quittime]\n"
+" [-r retry] [-T dir,max[,inc][[user@]host [port]]] [host:path[/]]\n"
" [file:///file] [ftp://[user[:pass]@]host[:port]/path[/]]\n"
" [http://[user[:pass]@]host[:port]/path] [...]\n"
" %s -u URL file [...]\n", progname, progname);