X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=networking%2Fwget.c;h=41b4e30af69952e86681b60d8506e7e30f96b0ec;hb=85dd4b3b272793502b513d0d54b546c741ad1a5d;hp=61945b7d1ec641af658a3805da416c3757bbd52c;hpb=8071c021311afb592bb6710b841350018ba97b9d;p=oweals%2Fbusybox.git diff --git a/networking/wget.c b/networking/wget.c index 61945b7d1..41b4e30af 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -56,12 +56,12 @@ static void parse_url(char *url, struct host_info *h); static FILE *open_socket(char *host, int port); static char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc); static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf); -static void progressmeter(int flag); /* Globals (can be accessed from signal handlers */ static off_t filesize = 0; /* content-length of the file */ static int chunked = 0; /* chunked transfer encoding */ -#ifdef BB_FEATURE_WGET_STATUSBAR +#ifdef CONFIG_FEATURE_WGET_STATUSBAR +static void progressmeter(int flag); static char *curfile; /* Name of current file being transferred. */ static struct timeval start; /* Time a transfer started. */ static volatile unsigned long statbytes = 0; /* Number of bytes transferred so far. */ @@ -126,7 +126,7 @@ static char *safe_fgets(char *s, int size, FILE *stream) error_msg_and_die(s); } -#ifdef BB_FEATURE_WGET_AUTHENTICATION +#ifdef CONFIG_FEATURE_WGET_AUTHENTICATION /* * Base64-encode character string * oops... isn't something similar in uuencode.c? @@ -195,7 +195,7 @@ int wget_main(int argc, char **argv) ++do_continue; break; case 'P': - dir_prefix = optarg; + dir_prefix = optarg; break; case 'q': quiet_flag = TRUE; @@ -245,18 +245,20 @@ int wget_main(int argc, char **argv) /* Guess an output filename */ if (!fname_out) { fname_out = -#ifdef BB_FEATURE_WGET_STATUSBAR +#ifdef CONFIG_FEATURE_WGET_STATUSBAR curfile = #endif get_last_path_component(target.path); if (fname_out==NULL || strlen(fname_out)<1) { fname_out = -#ifdef BB_FEATURE_WGET_STATUSBAR +#ifdef CONFIG_FEATURE_WGET_STATUSBAR curfile = #endif "index.html"; } -#ifdef BB_FEATURE_WGET_STATUSBAR + if (dir_prefix != NULL) + fname_out = concat_path_file(dir_prefix, fname_out); +#ifdef CONFIG_FEATURE_WGET_STATUSBAR } else { curfile = get_last_path_component(fname_out); #endif @@ -272,7 +274,6 @@ int wget_main(int argc, char **argv) output = stdout; quiet_flag = TRUE; } else { - fname_out = concat_path_file(dir_prefix, fname_out); output = xfopen(fname_out, (do_continue ? "a" : "w")); } @@ -315,7 +316,7 @@ int wget_main(int argc, char **argv) fprintf(sfp, "Host: %s\r\nUser-Agent: Wget\r\n", target.host); -#ifdef BB_FEATURE_WGET_AUTHENTICATION +#ifdef CONFIG_FEATURE_WGET_AUTHENTICATION if (target.user) { fprintf(sfp, "Authorization: Basic %s\r\n", base64enc(target.user, buf, sizeof(buf))); @@ -474,14 +475,14 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) fgets(buf, sizeof(buf), dfp); filesize = strtol(buf, (char **) NULL, 16); } -#ifdef BB_FEATURE_WGET_STATUSBAR +#ifdef CONFIG_FEATURE_WGET_STATUSBAR if (quiet_flag==FALSE) progressmeter(-1); #endif do { while ((filesize > 0 || !got_clen) && (n = safe_fread(buf, 1, chunked ? (filesize > sizeof(buf) ? sizeof(buf) : filesize) : sizeof(buf), dfp)) > 0) { safe_fwrite(buf, 1, n, output); -#ifdef BB_FEATURE_WGET_STATUSBAR +#ifdef CONFIG_FEATURE_WGET_STATUSBAR statbytes+=n; #endif if (got_clen) @@ -498,7 +499,7 @@ read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) if (n == 0 && ferror(dfp)) perror_msg_and_die("network read error"); } while (chunked); -#ifdef BB_FEATURE_WGET_STATUSBAR +#ifdef CONFIG_FEATURE_WGET_STATUSBAR if (quiet_flag==FALSE) progressmeter(1); #endif @@ -644,7 +645,7 @@ static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf) return atoi(buf); } -#ifdef BB_FEATURE_WGET_STATUSBAR +#ifdef CONFIG_FEATURE_WGET_STATUSBAR /* Stuff below is from BSD rcp util.c, as added to openshh. * Original copyright notice is retained at the end of this file. * @@ -781,7 +782,7 @@ progressmeter(int flag) } #endif -/* Original copyright notice which applies to the BB_FEATURE_WGET_STATUSBAR stuff, +/* Original copyright notice which applies to the CONFIG_FEATURE_WGET_STATUSBAR stuff, * much of which was blatently stolen from openssh. */ /*- @@ -816,7 +817,7 @@ progressmeter(int flag) * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: wget.c,v 1.42 2001/06/21 19:45:06 andersen Exp $ + * $Id: wget.c,v 1.46 2001/10/24 04:59:56 andersen Exp $ */