/* For progressmeter() -- number of seconds before xfer considered "stalled" */
static const int STALLTIME = 5;
#endif
-
+
static void close_and_delete_outfile(FILE* output, char *fname_out, int do_continue)
{
if (output != stdout && do_continue==0) {
use_proxy = 0;
}
}
-
+
/* Guess an output filename */
if (!fname_out) {
- fname_out =
+ fname_out =
#ifdef CONFIG_FEATURE_WGET_STATUSBAR
- curfile =
+ curfile =
#endif
bb_get_last_path_component(target.path);
if (fname_out==NULL || strlen(fname_out)<1) {
- fname_out =
+ fname_out =
#ifdef CONFIG_FEATURE_WGET_STATUSBAR
- curfile =
+ curfile =
#endif
"index.html";
}
*/
if (sfp) fclose(sfp);
sfp = open_socket(&s_in);
-
+
/*
* Send HTTP request.
*/
read_response:
if (fgets(buf, sizeof(buf), sfp) == NULL)
close_delete_and_die("no response from server");
-
+
for (s = buf ; *s != '\0' && !isspace(*s) ; ++s)
;
for ( ; isspace(*s) ; ++s)
chomp(buf);
close_delete_and_die("server returned error %d: %s", atoi(s), buf);
}
-
+
/*
* Retrieve HTTP headers.
*/
}
}
} while(status >= 300);
-
+
dfp = sfp;
}
else
if (ftpcmd(NULL, NULL, sfp, buf) != 220)
close_delete_and_die("%s", buf+4);
- /*
+ /*
* Splitting username:password pair,
* trying to log in
*/
default:
close_delete_and_die("ftp login: %s", buf+4);
}
-
+
ftpcmd("CDUP", NULL, sfp, buf);
ftpcmd("TYPE I", NULL, sfp, buf);
-
+
/*
* Querying file size
*/
filesize = value;
got_clen = 1;
}
-
+
/*
* Entering passive mode
*/
} else
filesize -= beg_range;
}
-
+
if (ftpcmd("RETR /", target.path, sfp, buf) > 150)
close_delete_and_die("RETR: %s", buf+4);
static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf)
{
- char *p;
-
if (s1) {
if (!s2) s2="";
fprintf(fp, "%s%s\r\n", s1, s2);
fflush(fp);
}
-
+
do {
- p = fgets(buf, 510, fp);
- if (!p)
+ char *buf_ptr;
+
+ if (fgets(buf, 510, fp) == NULL) {
bb_perror_msg_and_die("fgets()");
+ }
+ buf_ptr = strstr(buf, "\r\n");
+ if (buf_ptr) {
+ *buf_ptr = '\0';
+ }
} while (! isdigit(buf[0]) || buf[3] != ' ');
-
+
return atoi(buf);
}
#ifdef CONFIG_FEATURE_WGET_STATUSBAR
-/* Stuff below is from BSD rcp util.c, as added to openshh.
+/* Stuff below is from BSD rcp util.c, as added to openshh.
* Original copyright notice is retained at the end of this file.
- *
- */
+ *
+ */
static int
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"%02d:%02d ETA", i / 60, i % 60);
}
- write(fileno(stderr), buf, strlen(buf));
+ write(STDERR_FILENO, buf, strlen(buf));
if (flag == -1) {
struct sigaction sa;
#endif
/* Original copyright notice which applies to the CONFIG_FEATURE_WGET_STATUSBAR stuff,
- * much of which was blatently stolen from openssh. */
-
+ * much of which was blatantly stolen from openssh. */
+
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
- * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
+ * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
+ * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
*
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: wget.c,v 1.70 2004/03/06 22:11:44 andersen Exp $
+ * $Id: wget.c,v 1.74 2004/04/14 17:51:24 andersen Exp $
*/