diff options
author | Martynas Venckus <martynas@cvs.openbsd.org> | 2008-06-25 21:15:20 +0000 |
---|---|---|
committer | Martynas Venckus <martynas@cvs.openbsd.org> | 2008-06-25 21:15:20 +0000 |
commit | a85feb9cc10f0895358f0a480a20d3283a3ef3f2 (patch) | |
tree | 39af1f7c2f124ca6e163371f62f58c79ae59fd95 /usr.bin | |
parent | c2d7eefaed6e79700d108fc23ad79d240836de16 (diff) |
in resume mode, pass -c to mget when {dir,file}hasglob, so that i'm
able to continue multiple transfers with -C; ok millert@
while here fix some comments (!SMALL vs. SMALL stuff), and add
missing
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ftp/cmdtab.c | 8 | ||||
-rw-r--r-- | usr.bin/ftp/cookie.c | 4 | ||||
-rw-r--r-- | usr.bin/ftp/extern.h | 4 | ||||
-rw-r--r-- | usr.bin/ftp/fetch.c | 78 | ||||
-rw-r--r-- | usr.bin/ftp/ftp.c | 6 | ||||
-rw-r--r-- | usr.bin/ftp/ftp_var.h | 4 | ||||
-rw-r--r-- | usr.bin/ftp/main.c | 32 | ||||
-rw-r--r-- | usr.bin/ftp/ruserpass.c | 6 | ||||
-rw-r--r-- | usr.bin/ftp/util.c | 6 |
9 files changed, 78 insertions, 70 deletions
diff --git a/usr.bin/ftp/cmdtab.c b/usr.bin/ftp/cmdtab.c index eef9f473ba8..07744ae4818 100644 --- a/usr.bin/ftp/cmdtab.c +++ b/usr.bin/ftp/cmdtab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmdtab.c,v 1.21 2008/06/25 18:07:00 martynas Exp $ */ +/* $OpenBSD: cmdtab.c,v 1.22 2008/06/25 21:15:19 martynas Exp $ */ /* $NetBSD: cmdtab.c,v 1.17 1997/08/18 10:20:17 lukem Exp $ */ /* @@ -31,7 +31,7 @@ */ #if !defined(lint) && !defined(SMALL) -static const char rcsid[] = "$OpenBSD: cmdtab.c,v 1.21 2008/06/25 18:07:00 martynas Exp $"; +static const char rcsid[] = "$OpenBSD: cmdtab.c,v 1.22 2008/06/25 21:15:19 martynas Exp $"; #endif /* not lint and not SMALL */ #include <stdio.h> @@ -127,11 +127,11 @@ char empty[] = ""; #define CMPL(x) #define CMPL0 #define H(x) empty -#else /* !SMALL */ +#else /* SMALL */ #define CMPL(x) __STRING(x), #define CMPL0 "", #define H(x) x -#endif /* !SMALL */ +#endif /* SMALL */ struct cmd cmdtab[] = { { "!", H(shellhelp), 0, 0, 0, CMPL0 shell }, diff --git a/usr.bin/ftp/cookie.c b/usr.bin/ftp/cookie.c index 1feb920c03e..18fbb711b3d 100644 --- a/usr.bin/ftp/cookie.c +++ b/usr.bin/ftp/cookie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cookie.c,v 1.2 2007/10/08 18:39:37 pyr Exp $ */ +/* $OpenBSD: cookie.c,v 1.3 2008/06/25 21:15:19 martynas Exp $ */ /* * Copyright (c) 2007 Pierre-Yves Ritschard <pyr@openbsd.org> * @@ -225,4 +225,4 @@ cookie_get(const char *domain, const char *path, int secure, char **pstr) *pstr = str; } -#endif /* ! SMALL */ +#endif /* !SMALL */ diff --git a/usr.bin/ftp/extern.h b/usr.bin/ftp/extern.h index d26150b805b..7d3c32368e9 100644 --- a/usr.bin/ftp/extern.h +++ b/usr.bin/ftp/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.33 2008/06/25 18:07:00 martynas Exp $ */ +/* $OpenBSD: extern.h,v 1.34 2008/06/25 21:15:19 martynas Exp $ */ /* $NetBSD: extern.h,v 1.17 1997/08/18 10:20:19 lukem Exp $ */ /* @@ -195,7 +195,7 @@ void user(int, char **); int ruserpass(const char *, char **, char **, char **); void cookie_load(void); void cookie_get(const char *, const char *, int, char **); -#endif +#endif /* !SMALL */ extern jmp_buf abortprox; diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index 0c6cdf795d4..6a4592575a5 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fetch.c,v 1.77 2008/06/15 04:43:20 martynas Exp $ */ +/* $OpenBSD: fetch.c,v 1.78 2008/06/25 21:15:19 martynas Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- @@ -38,7 +38,7 @@ */ #if !defined(lint) && !defined(SMALL) -static const char rcsid[] = "$OpenBSD: fetch.c,v 1.77 2008/06/15 04:43:20 martynas Exp $"; +static const char rcsid[] = "$OpenBSD: fetch.c,v 1.78 2008/06/25 21:15:19 martynas Exp $"; #endif /* not lint and not SMALL */ /* @@ -74,9 +74,9 @@ static const char rcsid[] = "$OpenBSD: fetch.c,v 1.77 2008/06/15 04:43:20 martyn #ifndef SMALL #include <openssl/ssl.h> #include <openssl/err.h> -#else +#else /* !SMALL */ #define SSL void -#endif +#endif /* !SMALL */ #include "ftp_var.h" @@ -92,7 +92,7 @@ size_t ftp_read(FILE *, SSL *, char *, size_t); int proxy_connect(int, char *); int SSL_vprintf(SSL *, const char *, va_list); char *SSL_readline(SSL *, size_t *); -#endif +#endif /* !SMALL */ #define FTP_URL "ftp://" /* ftp URL prefix */ #define HTTP_URL "http://" /* http URL prefix */ @@ -137,7 +137,7 @@ url_get(const char *origline, const char *proxyenv, const char *outfile) char *sslpath = NULL, *sslhost = NULL; int ishttpsurl = 0; SSL_CTX *ssl_ctx = NULL; -#endif +#endif /* !SMALL */ SSL *ssl = NULL; int status; @@ -156,7 +156,7 @@ url_get(const char *origline, const char *proxyenv, const char *outfile) } else if (strncasecmp(newline, HTTPS_URL, sizeof(HTTPS_URL) - 1) == 0) { host = newline + sizeof(HTTPS_URL) - 1; ishttpsurl = 1; -#endif +#endif /* !SMALL */ } else errx(1, "url_get: Invalid URL '%s'", newline); @@ -189,7 +189,7 @@ url_get(const char *origline, const char *proxyenv, const char *outfile) warnx("can't append to stdout"); goto cleanup_url_get; } -#endif +#endif /* !SMALL */ if (EMPTYSTRING(savefile)) { if (isftpurl) @@ -206,7 +206,7 @@ url_get(const char *origline, const char *proxyenv, const char *outfile) if (! sslpath || ! sslhost) errx(1, "Can't allocate memory for https path/host."); } -#endif +#endif /* !SMALL */ proxyurl = strdup(proxyenv); if (proxyurl == NULL) errx(1, "Can't allocate memory for proxy URL."); @@ -270,7 +270,7 @@ url_get(const char *origline, const char *proxyenv, const char *outfile) if (resume) out = open(savefile, O_APPEND | O_WRONLY); else -#endif +#endif /* !SMALL */ out = open(savefile, O_CREAT | O_WRONLY | O_TRUNC, 0666); if (out < 0) { @@ -292,7 +292,7 @@ url_get(const char *origline, const char *proxyenv, const char *outfile) } restart_point = st.st_size; } -#endif +#endif /* !SMALL */ /* Trap signals */ oldintr = NULL; @@ -369,9 +369,9 @@ url_get(const char *origline, const char *proxyenv, const char *outfile) hints.ai_socktype = SOCK_STREAM; #ifndef SMALL port = portnum ? portnum : (ishttpsurl ? httpsport : httpport); -#else +#else /* !SMALL */ port = portnum ? portnum : httpport; -#endif +#endif /* !SMALL */ error = getaddrinfo(host, port, &hints, &res0); /* * If the services file is corrupt/missing, fall back @@ -384,7 +384,7 @@ url_get(const char *origline, const char *proxyenv, const char *outfile) } else if (error == EAI_SERVICE && port == httpsport) { snprintf(pbuf, sizeof(pbuf), "%d", HTTPS_PORT); error = getaddrinfo(host, pbuf, &hints, &res0); -#endif +#endif /* !SMALL */ } if (error) { warnx("%s: %s", gai_strerror(error), host); @@ -429,7 +429,7 @@ again: #ifndef SMALL if (proxyenv && sslhost) proxy_connect(s, sslhost); -#endif +#endif /* !SMALL */ break; } freeaddrinfo(res0); @@ -465,9 +465,9 @@ again: } else { fin = fdopen(s, "r+"); } -#else +#else /* !SMALL */ fin = fdopen(s, "r+"); -#endif +#endif /* !SMALL */ if (verbose) fprintf(ttyout, "Requesting %s", origline); @@ -476,7 +476,7 @@ again: */ #ifndef SMALL cookie_get(host, path, ishttpsurl, &buf); -#endif +#endif /* !SMALL */ if (proxyurl) { if (verbose) fprintf(ttyout, " (via %s)\n", proxyenv); @@ -496,7 +496,7 @@ again: ftp_printf(fin, ssl, "GET /%s %s\r\nHost: ", path, #ifndef SMALL resume ? "HTTP/1.1" : -#endif +#endif /* !SMALL */ "HTTP/1.0"); if (strchr(host, ':')) { char *h, *p; @@ -538,10 +538,10 @@ again: ftp_printf(fin, ssl, "\r\nRange: bytes=%lld-", (long long)restart_point); } -#else +#else /* !SMALL */ if (port && strcmp(port, "80") != 0) ftp_printf(fin, ssl, ":%s", port); -#endif +#endif /* !SMALL */ ftp_printf(fin, ssl, "\r\n%s%s\r\n\r\n", buf ? buf : "", HTTP_USER_AGENT); if (verbose) @@ -551,7 +551,7 @@ again: #ifndef SMALL free(buf); -#endif +#endif /* !SMALL */ buf = NULL; if (fin != NULL && fflush(fin) == EOF) { @@ -586,7 +586,7 @@ again: #ifndef SMALL case 206: /* Partial Content */ break; -#endif +#endif /* !SMALL */ case 301: /* Moved Permanently */ case 302: /* Found */ case 303: /* See Other */ @@ -601,7 +601,7 @@ again: case 416: /* Requested Range Not Satisfiable */ warnx("File is already fully retrieved."); goto cleanup_url_get; -#endif +#endif /* !SMALL */ default: warnx("Error retrieving file: %s", cp); goto cleanup_url_get; @@ -637,7 +637,7 @@ again: #ifndef SMALL if (resume) filesize += restart_point; -#endif +#endif /* !SMALL */ #define LOCATION "Location: " } else if (isredirect && strncasecmp(cp, LOCATION, sizeof(LOCATION) - 1) == 0) { @@ -662,7 +662,7 @@ again: if (resume) out = open(savefile, O_APPEND | O_WRONLY); else -#endif +#endif /* !SMALL */ out = open(savefile, O_CREAT | O_WRONLY | O_TRUNC, 0666); if (out < 0) { @@ -725,7 +725,7 @@ again: if ( #ifndef SMALL !resume && -#endif +#endif /* !SMALL */ filesize != -1 && len == 0 && bytes != filesize) { if (verbose) fputs("Read short file.\n", ttyout); @@ -753,7 +753,7 @@ cleanup_url_get: SSL_shutdown(ssl); SSL_free(ssl); } -#endif +#endif /* !SMALL */ if (fin != NULL) fclose(fin); else if (s != -1) @@ -855,7 +855,7 @@ auto_fetch(int argc, char *argv[], char *outfile) #ifndef SMALL /* even if we compiled without SSL, url_get will check */ strncasecmp(url, HTTPS_URL, sizeof(HTTPS_URL) -1) == 0 || -#endif +#endif /* !SMALL */ strncasecmp(url, FILE_URL, sizeof(FILE_URL) - 1) == 0) { redirect_loop = 0; if (url_get(url, httpproxy, outfile) == -1) @@ -1062,6 +1062,14 @@ bad_ftp_url: ointeractive = interactive; interactive = 0; xargv[0] = "mget"; +#ifndef SMALL + if (resume) { + xargc = 3; + xargv[1] = "-c"; + xargv[2] = file; + xargv[3] = NULL; + } +#endif /* !SMALL */ mget(xargc, xargv); interactive = ointeractive; } else { @@ -1074,7 +1082,7 @@ bad_ftp_url: if (resume) reget(xargc, xargv); else -#endif +#endif /* !SMALL */ get(xargc, xargv); } @@ -1148,7 +1156,7 @@ isurl(const char *p) strncasecmp(p, HTTP_URL, sizeof(HTTP_URL) - 1) == 0 || #ifndef SMALL strncasecmp(p, HTTPS_URL, sizeof(HTTPS_URL) - 1) == 0 || -#endif +#endif /* !SMALL */ strncasecmp(p, FILE_URL, sizeof(FILE_URL) - 1) == 0 || strstr(p, ":/")) return (1); @@ -1163,7 +1171,7 @@ ftp_readline(FILE *fp, SSL *ssl, size_t *lenp) #ifndef SMALL else if (ssl != NULL) return SSL_readline(ssl, lenp); -#endif +#endif /* !SMALL */ else return NULL; } @@ -1185,7 +1193,7 @@ ftp_read(FILE *fp, SSL *ssl, char *buf, size_t len) else ret = nr; } -#endif +#endif /* !SMALL */ else ret = 0; return (ret); @@ -1204,7 +1212,7 @@ ftp_printf(FILE *fp, SSL *ssl, const char *fmt, ...) #ifndef SMALL else if (ssl != NULL) ret = SSL_vprintf((SSL*)ssl, fmt, ap); -#endif +#endif /* !SMALL */ else ret = NULL; @@ -1283,4 +1291,4 @@ proxy_connect(int socket, char *host) free(connstr); return(200); } -#endif +#endif /* !SMALL */ diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c index 298f00a1f6c..4055b6a7946 100644 --- a/usr.bin/ftp/ftp.c +++ b/usr.bin/ftp/ftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftp.c,v 1.71 2008/06/25 18:07:00 martynas Exp $ */ +/* $OpenBSD: ftp.c,v 1.72 2008/06/25 21:15:19 martynas Exp $ */ /* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */ /* @@ -60,7 +60,7 @@ */ #if !defined(lint) && !defined(SMALL) -static const char rcsid[] = "$OpenBSD: ftp.c,v 1.71 2008/06/25 18:07:00 martynas Exp $"; +static const char rcsid[] = "$OpenBSD: ftp.c,v 1.72 2008/06/25 21:15:19 martynas Exp $"; #endif /* not lint and not SMALL */ #include <sys/types.h> @@ -149,7 +149,7 @@ hookup(char *host, char *port) #ifndef SMALL else if (strcmp(port, "https") == 0) snprintf(pbuf, sizeof(pbuf), "%d", HTTPS_PORT); -#endif +#endif /* !SMALL */ if (pbuf[0]) error = getaddrinfo(host, pbuf, &hints, &res0); } diff --git a/usr.bin/ftp/ftp_var.h b/usr.bin/ftp/ftp_var.h index 9d00b32022c..8a2e9763145 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.25 2007/11/26 12:39:00 martynas Exp $ */ +/* $OpenBSD: ftp_var.h,v 1.26 2008/06/25 21:15:19 martynas Exp $ */ /* $NetBSD: ftp_var.h,v 1.18 1997/08/18 10:20:25 lukem Exp $ */ /* @@ -176,7 +176,7 @@ char *ftpport; /* port number to use for ftp connections */ char *httpport; /* port number to use for http connections */ #ifndef SMALL char *httpsport; /* port number to use for https connections */ -#endif +#endif /* !SMALL */ char *gateport; /* port number to use for gateftp connections */ jmp_buf toplevel; /* non-local goto stuff for cmd scanner */ diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c index b684bec185d..02b96f151fe 100644 --- a/usr.bin/ftp/main.c +++ b/usr.bin/ftp/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.68 2007/11/28 16:21:25 jmc Exp $ */ +/* $OpenBSD: main.c,v 1.69 2008/06/25 21:15:19 martynas Exp $ */ /* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */ /* @@ -66,7 +66,7 @@ static const char copyright[] = #endif /* not lint */ #if !defined(lint) && !defined(SMALL) -static const char rcsid[] = "$OpenBSD: main.c,v 1.68 2007/11/28 16:21:25 jmc Exp $"; +static const char rcsid[] = "$OpenBSD: main.c,v 1.69 2008/06/25 21:15:19 martynas Exp $"; #endif /* not lint and not SMALL */ /* @@ -103,7 +103,7 @@ main(volatile int argc, char *argv[]) httpport = "http"; #ifndef SMALL httpsport = "https"; -#endif +#endif /* !SMALL */ gateport = getenv("FTPSERVERPORT"); if (gateport == NULL || *gateport == '\0') gateport = "ftpgate"; @@ -122,7 +122,7 @@ main(volatile int argc, char *argv[]) hist = NULL; cookiefile = NULL; resume = 0; -#endif +#endif /* !SMALL */ mark = HASHBYTES; marg_sl = sl_init(); #ifdef INET6 @@ -171,7 +171,7 @@ main(volatile int argc, char *argv[]) #ifndef SMALL if (!dumb_terminal) editing = 1; /* editing mode on if tty is usable */ -#endif +#endif /* !SMALL */ } ttyout = stdout; @@ -180,7 +180,7 @@ main(volatile int argc, char *argv[]) #ifndef SMALL cookiefile = getenv("http_cookies"); -#endif +#endif /* !SMALL */ while ((ch = getopt(argc, argv, "46AaCc:dEegik:mno:pP:r:tvV")) != -1) { switch (ch) { @@ -202,13 +202,13 @@ main(volatile int argc, char *argv[]) case 'C': #ifndef SMALL resume = 1; -#endif +#endif /* !SMALL */ break; case 'c': #ifndef SMALL cookiefile = optarg; -#endif +#endif /* !SMALL */ break; case 'd': @@ -223,7 +223,7 @@ main(volatile int argc, char *argv[]) case 'e': #ifndef SMALL editing = 0; -#endif +#endif /* !SMALL */ break; case 'g': @@ -296,7 +296,7 @@ main(volatile int argc, char *argv[]) #ifndef SMALL cookie_load(); -#endif +#endif /* !SMALL */ cpend = 0; /* no pending replies */ proxy = 0; /* proxy not active */ @@ -424,7 +424,7 @@ cmdscanner(int top) int num; #ifndef SMALL HistEvent hev; -#endif +#endif /* !SMALL */ if (!top #ifndef SMALL @@ -577,7 +577,7 @@ makeargv(void) #ifdef SMALL #define INC_CHKCURSOR(x) (x)++ -#else /* !SMALL */ +#else /* SMALL */ #define INC_CHKCURSOR(x) { (x)++ ; \ if (x == cursor_pos) { \ cursor_argc = margc; \ @@ -585,7 +585,7 @@ makeargv(void) cursor_pos = NULL; \ } } -#endif /* !SMALL */ +#endif /* SMALL */ /* * Parse string into argbuf; @@ -773,12 +773,12 @@ usage(void) #ifndef SMALL " %s [-C] [-c cookie] [-o output] " "https://host[:port]/file\n" -#endif +#endif /* !SMALL */ " %s [-C] [-o output] host:[/path/]file[/]\n", #ifndef SMALL __progname, __progname, __progname, __progname, __progname); -#else +#else /* !SMALL */ __progname, __progname, __progname, __progname); -#endif +#endif /* !SMALL */ exit(1); } diff --git a/usr.bin/ftp/ruserpass.c b/usr.bin/ftp/ruserpass.c index 12828793441..20a3a4d8f8d 100644 --- a/usr.bin/ftp/ruserpass.c +++ b/usr.bin/ftp/ruserpass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ruserpass.c,v 1.25 2007/06/20 17:56:37 moritz Exp $ */ +/* $OpenBSD: ruserpass.c,v 1.26 2008/06/25 21:15:19 martynas Exp $ */ /* $NetBSD: ruserpass.c,v 1.14 1997/07/20 09:46:01 lukem Exp $ */ /* @@ -35,7 +35,7 @@ #if 0 static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95"; #else -static const char rcsid[] = "$OpenBSD: ruserpass.c,v 1.25 2007/06/20 17:56:37 moritz Exp $"; +static const char rcsid[] = "$OpenBSD: ruserpass.c,v 1.26 2008/06/25 21:15:19 martynas Exp $"; #endif #endif /* not lint */ @@ -319,4 +319,4 @@ token(void) return (t->tval); return (ID); } -#endif +#endif /* !SMALL */ diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c index e7cf9b6a40d..666504a638b 100644 --- a/usr.bin/ftp/util.c +++ b/usr.bin/ftp/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.51 2008/06/16 19:56:04 martynas Exp $ */ +/* $OpenBSD: util.c,v 1.52 2008/06/25 21:15:19 martynas Exp $ */ /* $NetBSD: util.c,v 1.12 1997/08/18 10:20:27 lukem Exp $ */ /*- @@ -71,7 +71,7 @@ */ #if !defined(lint) && !defined(SMALL) -static const char rcsid[] = "$OpenBSD: util.c,v 1.51 2008/06/16 19:56:04 martynas Exp $"; +static const char rcsid[] = "$OpenBSD: util.c,v 1.52 2008/06/25 21:15:19 martynas Exp $"; #endif /* not lint and not SMALL */ /* @@ -242,7 +242,7 @@ ftp_login(const char *host, char *user, char *pass) return (0); } } -#endif +#endif /* !SMALL */ /* * Set up arguments for an anonymous FTP session, if necessary. |