summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-08 17:54:47 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-08 17:54:47 +0000
commit7039a66b58706457c7423de60556e04545432943 (patch)
treea512daebc3674c819766664c8ea17d41ef7fef02 /networking
parent1385899416a4396385ad421ae1f532be7103738a (diff)
downloadbusybox-w32-7039a66b58706457c7423de60556e04545432943.tar.gz
busybox-w32-7039a66b58706457c7423de60556e04545432943.tar.bz2
busybox-w32-7039a66b58706457c7423de60556e04545432943.zip
correct largefile support, add comments about it.
Diffstat (limited to 'networking')
-rw-r--r--networking/ftpgetput.c20
-rw-r--r--networking/httpd.c4
-rw-r--r--networking/wget.c24
3 files changed, 25 insertions, 23 deletions
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index 902528f93..5d13e289b 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -104,9 +104,11 @@ static FILE *ftp_login(ftp_host_info_t *server)
104} 104}
105 105
106#if !ENABLE_FTPGET 106#if !ENABLE_FTPGET
107#define ftp_receive 0 107int ftp_receive(ftp_host_info_t *server, FILE *control_stream,
108 const char *local_path, char *server_path);
108#else 109#else
109static int ftp_receive(ftp_host_info_t *server, FILE *control_stream, 110static
111int ftp_receive(ftp_host_info_t *server, FILE *control_stream,
110 const char *local_path, char *server_path) 112 const char *local_path, char *server_path)
111{ 113{
112 char buf[512]; 114 char buf[512];
@@ -122,10 +124,8 @@ static int ftp_receive(ftp_host_info_t *server, FILE *control_stream,
122 fd_data = xconnect_ftpdata(server, buf); 124 fd_data = xconnect_ftpdata(server, buf);
123 125
124 if (ftpcmd("SIZE ", server_path, control_stream, buf) == 213) { 126 if (ftpcmd("SIZE ", server_path, control_stream, buf) == 213) {
125 unsigned long value=filesize; 127 if (SAFE_STRTOOFF(buf + 4, &filesize))
126 if (safe_strtoul(buf + 4, &value))
127 bb_error_msg_and_die("SIZE error: %s", buf + 4); 128 bb_error_msg_and_die("SIZE error: %s", buf + 4);
128 filesize = value;
129 } else { 129 } else {
130 filesize = -1; 130 filesize = -1;
131 do_continue = 0; 131 do_continue = 0;
@@ -139,7 +139,7 @@ static int ftp_receive(ftp_host_info_t *server, FILE *control_stream,
139 if (do_continue) { 139 if (do_continue) {
140 struct stat sbuf; 140 struct stat sbuf;
141 if (lstat(local_path, &sbuf) < 0) { 141 if (lstat(local_path, &sbuf) < 0) {
142 bb_perror_msg_and_die("fstat()"); 142 bb_perror_msg_and_die("lstat");
143 } 143 }
144 if (sbuf.st_size > 0) { 144 if (sbuf.st_size > 0) {
145 beg_range = sbuf.st_size; 145 beg_range = sbuf.st_size;
@@ -149,7 +149,7 @@ static int ftp_receive(ftp_host_info_t *server, FILE *control_stream,
149 } 149 }
150 150
151 if (do_continue) { 151 if (do_continue) {
152 sprintf(buf, "REST %ld", (long)beg_range); 152 sprintf(buf, "REST "OFF_FMT, beg_range);
153 if (ftpcmd(buf, NULL, control_stream, buf) != 350) { 153 if (ftpcmd(buf, NULL, control_stream, buf) != 350) {
154 do_continue = 0; 154 do_continue = 0;
155 } else { 155 } else {
@@ -191,9 +191,11 @@ static int ftp_receive(ftp_host_info_t *server, FILE *control_stream,
191#endif 191#endif
192 192
193#if !ENABLE_FTPPUT 193#if !ENABLE_FTPPUT
194#define ftp_send 0 194int ftp_send(ftp_host_info_t *server, FILE *control_stream,
195 const char *server_path, char *local_path);
195#else 196#else
196static int ftp_send(ftp_host_info_t *server, FILE *control_stream, 197static
198int ftp_send(ftp_host_info_t *server, FILE *control_stream,
197 const char *server_path, char *local_path) 199 const char *server_path, char *local_path)
198{ 200{
199 struct stat sbuf; 201 struct stat sbuf;
diff --git a/networking/httpd.c b/networking/httpd.c
index f3fe49cae..bbb2dfe7f 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -919,8 +919,8 @@ static int sendHeaders(HttpResponseNum responseNum)
919 919
920 if (config->ContentLength != -1) { /* file */ 920 if (config->ContentLength != -1) { /* file */
921 strftime(timeStr, sizeof(timeStr), RFC1123FMT, gmtime(&config->last_mod)); 921 strftime(timeStr, sizeof(timeStr), RFC1123FMT, gmtime(&config->last_mod));
922 len += sprintf(buf+len, "Last-Modified: %s\r\n%s "FILEOFF_FMT"\r\n", 922 len += sprintf(buf+len, "Last-Modified: %s\r\n%s "OFF_FMT"\r\n",
923 timeStr, Content_length, (FILEOFF_TYPE) config->ContentLength); 923 timeStr, Content_length, (off_t) config->ContentLength);
924 } 924 }
925 strcat(buf, "\r\n"); 925 strcat(buf, "\r\n");
926 len += 2; 926 len += 2;
diff --git a/networking/wget.c b/networking/wget.c
index e7b19f2ef..74feccc36 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -29,9 +29,9 @@ static char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc);
29static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf); 29static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf);
30 30
31/* Globals (can be accessed from signal handlers */ 31/* Globals (can be accessed from signal handlers */
32static FILEOFF_TYPE content_len; /* Content-length of the file */ 32static off_t content_len; /* Content-length of the file */
33static FILEOFF_TYPE beg_range; /* Range at which continue begins */ 33static off_t beg_range; /* Range at which continue begins */
34static FILEOFF_TYPE transferred; /* Number of bytes transferred so far */ 34static off_t transferred; /* Number of bytes transferred so far */
35static int chunked; /* chunked transfer encoding */ 35static int chunked; /* chunked transfer encoding */
36#ifdef CONFIG_FEATURE_WGET_STATUSBAR 36#ifdef CONFIG_FEATURE_WGET_STATUSBAR
37static void progressmeter(int flag); 37static void progressmeter(int flag);
@@ -215,10 +215,10 @@ int wget_main(int argc, char **argv)
215 opt |= WGET_OPT_QUIET; 215 opt |= WGET_OPT_QUIET;
216 opt &= ~WGET_OPT_CONTINUE; 216 opt &= ~WGET_OPT_CONTINUE;
217 } else if (opt & WGET_OPT_CONTINUE) { 217 } else if (opt & WGET_OPT_CONTINUE) {
218 output_fd = open(fname_out, O_WRONLY|O_LARGEFILE); 218 output_fd = open(fname_out, O_WRONLY);
219 if (output_fd >= 0) { 219 if (output_fd >= 0) {
220 beg_range = LSEEK(output_fd, 0, SEEK_END); 220 beg_range = lseek(output_fd, 0, SEEK_END);
221 if (beg_range == (FILEOFF_TYPE)-1) 221 if (beg_range == (off_t)-1)
222 bb_perror_msg_and_die("lseek"); 222 bb_perror_msg_and_die("lseek");
223 } 223 }
224 /* File doesn't exist. We do not create file here yet. 224 /* File doesn't exist. We do not create file here yet.
@@ -282,7 +282,7 @@ int wget_main(int argc, char **argv)
282#endif 282#endif
283 283
284 if (beg_range) 284 if (beg_range)
285 fprintf(sfp, "Range: bytes="FILEOFF_FMT"-\r\n", beg_range); 285 fprintf(sfp, "Range: bytes="OFF_FMT"-\r\n", beg_range);
286 if(extra_headers_left < sizeof(extra_headers)) 286 if(extra_headers_left < sizeof(extra_headers))
287 fputs(extra_headers,sfp); 287 fputs(extra_headers,sfp);
288 fprintf(sfp,"Connection: close\r\n\r\n"); 288 fprintf(sfp,"Connection: close\r\n\r\n");
@@ -413,7 +413,7 @@ read_response:
413 dfp = open_socket(&s_in); 413 dfp = open_socket(&s_in);
414 414
415 if (beg_range) { 415 if (beg_range) {
416 sprintf(buf, "REST "FILEOFF_FMT, beg_range); 416 sprintf(buf, "REST "OFF_FMT, beg_range);
417 if (ftpcmd(buf, NULL, sfp, buf) == 350) 417 if (ftpcmd(buf, NULL, sfp, buf) == 350)
418 content_len -= beg_range; 418 content_len -= beg_range;
419 } 419 }
@@ -435,7 +435,7 @@ read_response:
435 /* Do it before progressmeter (want to have nice error message) */ 435 /* Do it before progressmeter (want to have nice error message) */
436 if (output_fd < 0) 436 if (output_fd < 0)
437 output_fd = xopen3(fname_out, 437 output_fd = xopen3(fname_out,
438 O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_LARGEFILE, 0666); 438 O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666);
439 439
440 if (!(opt & WGET_OPT_QUIET)) 440 if (!(opt & WGET_OPT_QUIET))
441 progressmeter(-1); 441 progressmeter(-1);
@@ -685,10 +685,10 @@ static void
685progressmeter(int flag) 685progressmeter(int flag)
686{ 686{
687 static struct timeval lastupdate; 687 static struct timeval lastupdate;
688 static FILEOFF_TYPE lastsize, totalsize; 688 static off_t lastsize, totalsize;
689 689
690 struct timeval now, td, tvwait; 690 struct timeval now, td, tvwait;
691 FILEOFF_TYPE abbrevsize; 691 off_t abbrevsize;
692 int elapsed, ratio, barlength, i; 692 int elapsed, ratio, barlength, i;
693 char buf[256]; 693 char buf[256];
694 694
@@ -739,7 +739,7 @@ progressmeter(int flag)
739 if (tvwait.tv_sec >= STALLTIME) { 739 if (tvwait.tv_sec >= STALLTIME) {
740 fprintf(stderr, " - stalled -"); 740 fprintf(stderr, " - stalled -");
741 } else { 741 } else {
742 FILEOFF_TYPE to_download = totalsize - beg_range; 742 off_t to_download = totalsize - beg_range;
743 if (transferred <= 0 || elapsed <= 0 || transferred > to_download || chunked) { 743 if (transferred <= 0 || elapsed <= 0 || transferred > to_download || chunked) {
744 fprintf(stderr, "--:--:-- ETA"); 744 fprintf(stderr, "--:--:-- ETA");
745 } else { 745 } else {