| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: fetch.c,v 1.228 2017/02/15 11:52:11 nonaka Exp $ */ | | 1 | /* $NetBSD: fetch.c,v 1.229 2017/11/25 15:39:17 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Luke Mewburn. | | 8 | * by Luke Mewburn. |
9 | * | | 9 | * |
10 | * This code is derived from software contributed to The NetBSD Foundation | | 10 | * This code is derived from software contributed to The NetBSD Foundation |
11 | * by Scott Aaron Bamford. | | 11 | * by Scott Aaron Bamford. |
12 | * | | 12 | * |
13 | * This code is derived from software contributed to The NetBSD Foundation | | 13 | * This code is derived from software contributed to The NetBSD Foundation |
14 | * by Thomas Klausner. | | 14 | * by Thomas Klausner. |
| @@ -27,27 +27,27 @@ | | | @@ -27,27 +27,27 @@ |
27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
35 | * POSSIBILITY OF SUCH DAMAGE. | | 35 | * POSSIBILITY OF SUCH DAMAGE. |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | #ifndef lint | | 39 | #ifndef lint |
40 | __RCSID("$NetBSD: fetch.c,v 1.228 2017/02/15 11:52:11 nonaka Exp $"); | | 40 | __RCSID("$NetBSD: fetch.c,v 1.229 2017/11/25 15:39:17 christos Exp $"); |
41 | #endif /* not lint */ | | 41 | #endif /* not lint */ |
42 | | | 42 | |
43 | /* | | 43 | /* |
44 | * FTP User Program -- Command line file retrieval | | 44 | * FTP User Program -- Command line file retrieval |
45 | */ | | 45 | */ |
46 | | | 46 | |
47 | #include <sys/types.h> | | 47 | #include <sys/types.h> |
48 | #include <sys/param.h> | | 48 | #include <sys/param.h> |
49 | #include <sys/socket.h> | | 49 | #include <sys/socket.h> |
50 | #include <sys/stat.h> | | 50 | #include <sys/stat.h> |
51 | #include <sys/time.h> | | 51 | #include <sys/time.h> |
52 | | | 52 | |
53 | #include <netinet/in.h> | | 53 | #include <netinet/in.h> |
| @@ -2087,34 +2087,35 @@ fetch_ftp(const char *url) | | | @@ -2087,34 +2087,35 @@ fetch_ftp(const char *url) |
2087 | if (dirhasglob || filehasglob) { | | 2087 | if (dirhasglob || filehasglob) { |
2088 | int ointeractive; | | 2088 | int ointeractive; |
2089 | | | 2089 | |
2090 | ointeractive = interactive; | | 2090 | ointeractive = interactive; |
2091 | interactive = 0; | | 2091 | interactive = 0; |
2092 | if (restartautofetch) | | 2092 | if (restartautofetch) |
2093 | (void)strlcpy(cmdbuf, "mreget", sizeof(cmdbuf)); | | 2093 | (void)strlcpy(cmdbuf, "mreget", sizeof(cmdbuf)); |
2094 | else | | 2094 | else |
2095 | (void)strlcpy(cmdbuf, "mget", sizeof(cmdbuf)); | | 2095 | (void)strlcpy(cmdbuf, "mget", sizeof(cmdbuf)); |
2096 | xargv[0] = cmdbuf; | | 2096 | xargv[0] = cmdbuf; |
2097 | mget(xargc, xargv); | | 2097 | mget(xargc, xargv); |
2098 | interactive = ointeractive; | | 2098 | interactive = ointeractive; |
2099 | } else { | | 2099 | } else { |
2100 | if (outfile == NULL) { | | 2100 | char *destfile = outfile; |
| | | 2101 | if (destfile == NULL) { |
2101 | cp = strrchr(file, '/'); /* find savefile */ | | 2102 | cp = strrchr(file, '/'); /* find savefile */ |
2102 | if (cp != NULL) | | 2103 | if (cp != NULL) |
2103 | outfile = cp + 1; | | 2104 | destfile = cp + 1; |
2104 | else | | 2105 | else |
2105 | outfile = file; | | 2106 | destfile = file; |
2106 | } | | 2107 | } |
2107 | xargv[2] = (char *)outfile; | | 2108 | xargv[2] = (char *)destfile; |
2108 | xargv[3] = NULL; | | 2109 | xargv[3] = NULL; |
2109 | xargc++; | | 2110 | xargc++; |
2110 | if (restartautofetch) | | 2111 | if (restartautofetch) |
2111 | reget(xargc, xargv); | | 2112 | reget(xargc, xargv); |
2112 | else | | 2113 | else |
2113 | get(xargc, xargv); | | 2114 | get(xargc, xargv); |
2114 | } | | 2115 | } |
2115 | | | 2116 | |
2116 | if ((code / 100) == COMPLETE) | | 2117 | if ((code / 100) == COMPLETE) |
2117 | rval = 0; | | 2118 | rval = 0; |
2118 | | | 2119 | |
2119 | cleanup_fetch_ftp: | | 2120 | cleanup_fetch_ftp: |
2120 | freeurlinfo(&ui); | | 2121 | freeurlinfo(&ui); |
| @@ -2240,28 +2241,29 @@ auto_fetch(int argc, char *argv[]) | | | @@ -2240,28 +2241,29 @@ auto_fetch(int argc, char *argv[]) |
2240 | (void)xsignal(SIGPIPE, lostpeer); | | 2241 | (void)xsignal(SIGPIPE, lostpeer); |
2241 | | | 2242 | |
2242 | /* | | 2243 | /* |
2243 | * Loop through as long as there's files to fetch. | | 2244 | * Loop through as long as there's files to fetch. |
2244 | */ | | 2245 | */ |
2245 | for (; (rval == 0) && (argpos < argc); argpos++) { | | 2246 | for (; (rval == 0) && (argpos < argc); argpos++) { |
2246 | if (strchr(argv[argpos], ':') == NULL) | | 2247 | if (strchr(argv[argpos], ':') == NULL) |
2247 | break; | | 2248 | break; |
2248 | redirect_loop = 0; | | 2249 | redirect_loop = 0; |
2249 | if (!anonftp) | | 2250 | if (!anonftp) |
2250 | anonftp = 2; /* Handle "automatic" transfers. */ | | 2251 | anonftp = 2; /* Handle "automatic" transfers. */ |
2251 | rval = go_fetch(argv[argpos]); | | 2252 | rval = go_fetch(argv[argpos]); |
2252 | if (outfile != NULL && strcmp(outfile, "-") != 0 | | 2253 | if (outfile != NULL && strcmp(outfile, "-") != 0 |
2253 | && outfile[0] != '|') | | 2254 | && outfile[0] != '|') { |
2254 | outfile = NULL; | | 2255 | FREEPTR(outfile); |
| | | 2256 | } |
2255 | if (rval > 0) | | 2257 | if (rval > 0) |
2256 | rval = argpos + 1; | | 2258 | rval = argpos + 1; |
2257 | } | | 2259 | } |
2258 | | | 2260 | |
2259 | if (connected && rval != -1) | | 2261 | if (connected && rval != -1) |
2260 | disconnect(0, NULL); | | 2262 | disconnect(0, NULL); |
2261 | return (rval); | | 2263 | return (rval); |
2262 | } | | 2264 | } |
2263 | | | 2265 | |
2264 | | | 2266 | |
2265 | /* | | 2267 | /* |
2266 | * Upload multiple files from the command line. | | 2268 | * Upload multiple files from the command line. |
2267 | * | | 2269 | * |