=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ftp/fetch.c,v retrieving revision 1.77 retrieving revision 1.78 diff -u -r1.77 -r1.78 --- src/usr.bin/ftp/fetch.c 2008/06/15 04:43:20 1.77 +++ src/usr.bin/ftp/fetch.c 2008/06/25 21:15:19 1.78 @@ -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 @@ #ifndef SMALL #include #include -#else +#else /* !SMALL */ #define SSL void -#endif +#endif /* !SMALL */ #include "ftp_var.h" @@ -92,7 +92,7 @@ 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 @@ 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 @@ } 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 @@ warnx("can't append to stdout"); goto cleanup_url_get; } -#endif +#endif /* !SMALL */ if (EMPTYSTRING(savefile)) { if (isftpurl) @@ -206,7 +206,7 @@ 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 @@ 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 @@ } restart_point = st.st_size; } -#endif +#endif /* !SMALL */ /* Trap signals */ oldintr = NULL; @@ -369,9 +369,9 @@ 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 @@ } 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 @@ #ifndef SMALL if (proxyenv && sslhost) proxy_connect(s, sslhost); -#endif +#endif /* !SMALL */ break; } freeaddrinfo(res0); @@ -465,9 +465,9 @@ } 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 @@ */ #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 @@ 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 @@ 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 @@ #ifndef SMALL free(buf); -#endif +#endif /* !SMALL */ buf = NULL; if (fin != NULL && fflush(fin) == EOF) { @@ -586,7 +586,7 @@ #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 @@ 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 @@ #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 @@ 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 @@ 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 @@ SSL_shutdown(ssl); SSL_free(ssl); } -#endif +#endif /* !SMALL */ if (fin != NULL) fclose(fin); else if (s != -1) @@ -855,7 +855,7 @@ #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 @@ 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 @@ if (resume) reget(xargc, xargv); else -#endif +#endif /* !SMALL */ get(xargc, xargv); } @@ -1148,7 +1156,7 @@ 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 @@ #ifndef SMALL else if (ssl != NULL) return SSL_readline(ssl, lenp); -#endif +#endif /* !SMALL */ else return NULL; } @@ -1185,7 +1193,7 @@ else ret = nr; } -#endif +#endif /* !SMALL */ else ret = 0; return (ret); @@ -1204,7 +1212,7 @@ #ifndef SMALL else if (ssl != NULL) ret = SSL_vprintf((SSL*)ssl, fmt, ap); -#endif +#endif /* !SMALL */ else ret = NULL; @@ -1283,4 +1291,4 @@ free(connstr); return(200); } -#endif +#endif /* !SMALL */