]>
Commit | Line | Data |
---|---|---|
a9ef2fa2 ER |
1 | --- wget-1.9.1/configure.in.lfs 2004-09-29 17:54:08.505860800 +0200 |
2 | +++ wget-1.9.1/configure.in 2004-09-29 17:54:08.554853352 +0200 | |
3 | @@ -106,6 +106,16 @@ | |
4 | AC_PROG_CC | |
5 | ||
6 | dnl | |
7 | +dnl Define Large File support | |
8 | +dnl | |
9 | + | |
10 | +AC_ARG_ENABLE(LFS, [ --disable-LFS disable Large File Support], | |
11 | +ENABLE_LFS=$enableval, ENABLE_LFS=yes) | |
12 | +test x"${ENABLE_LFS}" = xyes && AC_DEFINE([ENABLE_LFS], 1, | |
13 | + [Define if you want the Large File Support compiled in.]) | |
14 | + | |
15 | + | |
16 | +dnl | |
17 | dnl if the user hasn't specified CFLAGS, then | |
18 | dnl if compiler is gcc, then use -O2 and some warning flags | |
19 | dnl else use os-specific flags or -O | |
20 | @@ -123,6 +133,14 @@ | |
21 | fi | |
22 | ||
23 | dnl | |
24 | +dnl if we're compiling with largefile support, append appropriate | |
25 | +dnl parameters to CFLAGS, don't care if they are already in CFLAGS | |
26 | +dnl | |
27 | +if test x"$ENABLE_LFS" = xyes; then | |
28 | + CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DLFS" | |
29 | +fi | |
30 | + | |
31 | +dnl | |
32 | dnl Handle AIX | |
33 | dnl | |
34 | AC_AIX | |
35 | @@ -195,7 +213,7 @@ | |
36 | AC_CHECK_FUNCS(strdup strstr strcasecmp strncasecmp strpbrk memmove) | |
37 | AC_CHECK_FUNCS(gettimeofday mktime strptime strerror snprintf vsnprintf) | |
38 | AC_CHECK_FUNCS(select sigblock sigsetjmp signal symlink access isatty) | |
39 | -AC_CHECK_FUNCS(uname gethostname usleep) | |
40 | +AC_CHECK_FUNCS(uname gethostname usleep strtol strtoll) | |
41 | ||
42 | dnl | |
43 | dnl Check if we need to compile in getopt.c. | |
44 | --- wget-1.9.1/src/utils.h.lfs 2003-10-11 15:57:11.000000000 +0200 | |
45 | +++ wget-1.9.1/src/utils.h 2004-09-29 17:54:08.555853200 +0200 | |
46 | @@ -45,7 +45,7 @@ | |
47 | ||
48 | struct file_memory { | |
49 | char *content; | |
50 | - long length; | |
51 | + off_t length; | |
52 | int mmap_p; | |
53 | }; | |
54 | ||
55 | @@ -71,7 +71,7 @@ | |
56 | int remove_link PARAMS ((const char *)); | |
57 | int file_exists_p PARAMS ((const char *)); | |
58 | int file_non_directory_p PARAMS ((const char *)); | |
59 | -long file_size PARAMS ((const char *)); | |
60 | +off_t file_size PARAMS ((const char *)); | |
61 | int make_directory PARAMS ((const char *)); | |
62 | char *unique_name PARAMS ((const char *, int)); | |
63 | char *file_merge PARAMS ((const char *, const char *)); | |
64 | @@ -101,10 +101,21 @@ | |
65 | void string_set_free PARAMS ((struct hash_table *)); | |
66 | void free_keys_and_values PARAMS ((struct hash_table *)); | |
67 | ||
68 | -char *legible PARAMS ((long)); | |
69 | +char *legible PARAMS ((unsigned long int)); | |
70 | char *legible_large_int PARAMS ((LARGE_INT)); | |
71 | -int numdigit PARAMS ((long)); | |
72 | -char *number_to_string PARAMS ((char *, long)); | |
73 | +int numdigit PARAMS ((unsigned long int)); | |
74 | +char *number_to_string PARAMS ((char *, unsigned long int)); | |
75 | + | |
76 | +#ifdef LFS | |
77 | +char *legible_off_t PARAMS ((off_t)); | |
78 | +char *number_to_string_off_t PARAMS ((char *, off_t )); | |
79 | +char *number_to_string_64 PARAMS ((char *, unsigned long long int)); | |
80 | +int numdigit_64 PARAMS ((unsigned long long int)); | |
81 | +unsigned long long int wget_strtoull ( const char *ptr, char **endptr, int base ); | |
82 | +#else | |
83 | +#define number_to_string_off_t number_to_string | |
84 | +#define legible_off_t legible | |
85 | +#endif | |
86 | ||
87 | struct wget_timer *wtimer_allocate PARAMS ((void)); | |
88 | struct wget_timer *wtimer_new PARAMS ((void)); | |
89 | --- wget-1.9.1/src/utils.c.lfs 2003-10-23 14:16:21.000000000 +0200 | |
90 | +++ wget-1.9.1/src/utils.c 2004-09-29 17:54:08.559852592 +0200 | |
91 | @@ -569,10 +569,10 @@ | |
92 | ||
93 | /* Return the size of file named by FILENAME, or -1 if it cannot be | |
94 | opened or seeked into. */ | |
95 | -long | |
96 | +off_t | |
97 | file_size (const char *filename) | |
98 | { | |
99 | - long size; | |
100 | + off_t size; | |
101 | /* We use fseek rather than stat to determine the file size because | |
102 | that way we can also verify whether the file is readable. | |
103 | Inspired by the POST patch by Arnaud Wylie. */ | |
104 | @@ -985,7 +985,7 @@ | |
105 | { | |
106 | int fd; | |
107 | struct file_memory *fm; | |
108 | - long size; | |
109 | + off_t size; | |
110 | int inhibit_close = 0; | |
111 | ||
112 | /* Some magic in the finest tradition of Perl and its kin: if FILE | |
113 | @@ -1037,7 +1037,7 @@ | |
114 | fm->content = xmalloc (size); | |
115 | while (1) | |
116 | { | |
117 | - long nread; | |
118 | + off_t nread; | |
119 | if (fm->length > size / 2) | |
120 | { | |
121 | /* #### I'm not sure whether the whole exponential-growth | |
122 | @@ -1337,7 +1337,7 @@ | |
123 | /* Legible -- return a static pointer to the legibly printed long. */ | |
124 | ||
125 | char * | |
126 | -legible (long l) | |
127 | +legible (unsigned long int l) | |
128 | { | |
129 | char inbuf[24]; | |
130 | /* Print the number into the buffer. */ | |
131 | @@ -1373,7 +1373,7 @@ | |
132 | ||
133 | /* Count the digits in a (long) integer. */ | |
134 | int | |
135 | -numdigit (long number) | |
136 | +numdigit (unsigned long int number) | |
137 | { | |
138 | int cnt = 1; | |
139 | if (number < 0) | |
140 | @@ -1386,6 +1386,25 @@ | |
141 | return cnt; | |
142 | } | |
143 | ||
144 | +#ifdef LFS | |
145 | +int | |
146 | +numdigit_64 (unsigned long long int number) | |
147 | +{ | |
148 | + int cnt = 1; | |
149 | + if (number < 0) | |
150 | + { | |
151 | + number = -number; | |
152 | + ++cnt; | |
153 | + } | |
154 | + while ((number /= 10ULL) > 0) | |
155 | + ++cnt; | |
156 | + return cnt; | |
157 | +} | |
158 | + | |
159 | +#endif | |
160 | + | |
161 | + | |
162 | + | |
163 | /* A half-assed implementation of INT_MAX on machines that don't | |
164 | bother to define one. */ | |
165 | #ifndef INT_MAX | |
166 | @@ -1437,10 +1456,10 @@ | |
167 | terminating '\0'. */ | |
168 | ||
169 | char * | |
170 | -number_to_string (char *buffer, long number) | |
171 | +number_to_string (char *buffer, unsigned long int number) | |
172 | { | |
173 | char *p = buffer; | |
174 | - long n = number; | |
175 | + unsigned long int n = number; | |
176 | ||
177 | #if (SIZEOF_LONG != 4) && (SIZEOF_LONG != 8) | |
178 | /* We are running in a strange or misconfigured environment. Let | |
179 | @@ -2084,4 +2103,91 @@ | |
180 | return 0; | |
181 | } | |
182 | #endif /* not WINDOWS */ | |
183 | + | |
184 | #endif /* not USE_SIGNAL_TIMEOUT */ | |
185 | + | |
186 | +#ifdef LFS | |
187 | +char * | |
188 | +number_to_string_off_t (char *buffer, off_t number) | |
189 | +{ | |
190 | + if ( sizeof(number) == 8 ) | |
191 | + return number_to_string_64 (buffer, number); | |
192 | + else | |
193 | + return number_to_string (buffer, number); | |
194 | + return number_to_string (buffer, number); | |
195 | +} | |
196 | + | |
197 | + | |
198 | +/* Legible_off_t -- return a static pointer to the legibly printed long. */ | |
199 | +/* the same as legible, but it interprete the argument */ | |
200 | +/* either as 32-bits unsigned long or as 64-bits unsigned */ | |
201 | +/* long according to the size of off_t */ | |
202 | + | |
203 | +char * | |
204 | +legible_off_t ( off_t l) | |
205 | +{ | |
206 | + char inbuf[28]; | |
207 | + /* Print the number into the buffer. */ | |
208 | + | |
209 | + number_to_string_off_t (inbuf, l); | |
210 | + return legible_1 (inbuf); | |
211 | +} | |
212 | + | |
213 | +/* number_to_string_64 -- is the same as number_to_string, but it it */ | |
214 | +/* assumes that its argukent is a 64-bits unsigned */ | |
215 | +/* long */ | |
216 | + | |
217 | +char * | |
218 | +number_to_string_64 (char *buffer, unsigned long long int number) | |
219 | +{ | |
220 | + char *p = buffer; | |
221 | + unsigned long long int n = number; | |
222 | + | |
223 | +#define ONE_DIGIT(figure) *p++ = n / (figure) + '0' | |
224 | +#define ONE_DIGIT_ADVANCE(figure) (ONE_DIGIT (figure), n %= (figure)) | |
225 | + | |
226 | +#define DIGITS_1(figure) ONE_DIGIT (figure) | |
227 | +#define DIGITS_2(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_1 ((figure) / 10) | |
228 | +#define DIGITS_3(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_2 ((figure) / 10) | |
229 | +#define DIGITS_4(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_3 ((figure) / 10) | |
230 | +#define DIGITS_5(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_4 ((figure) / 10) | |
231 | +#define DIGITS_6(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_5 ((figure) / 10) | |
232 | +#define DIGITS_7(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_6 ((figure) / 10) | |
233 | +#define DIGITS_8(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_7 ((figure) / 10) | |
234 | +#define DIGITS_9(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_8 ((figure) / 10) | |
235 | +#define DIGITS_10(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_9 ((figure) / 10) | |
236 | +#define DIGITS_11(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_10 ((figure) / 10) | |
237 | +#define DIGITS_12(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_11 ((figure) / 10) | |
238 | +#define DIGITS_13(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_12 ((figure) / 10) | |
239 | +#define DIGITS_14(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_13 ((figure) / 10) | |
240 | +#define DIGITS_15(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_14 ((figure) / 10) | |
241 | +#define DIGITS_16(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_15 ((figure) / 10) | |
242 | +#define DIGITS_17(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_16 ((figure) / 10) | |
243 | +#define DIGITS_18(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_17 ((figure) / 10) | |
244 | +#define DIGITS_19(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_18 ((figure) / 10) | |
245 | + | |
246 | + if (n < 10ULL) { DIGITS_1 (1ULL); } | |
247 | + else if (n < 100ULL) { DIGITS_2 (10ULL); } | |
248 | + else if (n < 1000ULL) { DIGITS_3 (100ULL); } | |
249 | + else if (n < 10000ULL) { DIGITS_4 (1000ULL); } | |
250 | + else if (n < 100000ULL) { DIGITS_5 (10000ULL); } | |
251 | + else if (n < 1000000ULL) { DIGITS_6 (100000ULL); } | |
252 | + else if (n < 10000000ULL) { DIGITS_7 (1000000ULL); } | |
253 | + else if (n < 100000000ULL) { DIGITS_8 (10000000ULL); } | |
254 | + else if (n < 1000000000ULL) { DIGITS_9 (100000000ULL); } | |
255 | + else if (n < 10000000000ULL) { DIGITS_10 (1000000000ULL); } | |
256 | + else if (n < 100000000000ULL) { DIGITS_11 (10000000000ULL); } | |
257 | + else if (n < 1000000000000ULL) { DIGITS_12 (100000000000ULL); } | |
258 | + else if (n < 10000000000000ULL) { DIGITS_13 (1000000000000ULL); } | |
259 | + else if (n < 100000000000000ULL) { DIGITS_14 (10000000000000ULL); } | |
260 | + else if (n < 1000000000000000ULL) { DIGITS_15 (100000000000000ULL); } | |
261 | + else if (n < 10000000000000000ULL) { DIGITS_16 (1000000000000000ULL); } | |
262 | + else if (n < 100000000000000000ULL) { DIGITS_17 (10000000000000000ULL); } | |
263 | + else if (n < 1000000000000000000ULL) { DIGITS_18 (100000000000000000ULL); } | |
264 | + else { DIGITS_19 (1000000000000000000ULL); } | |
265 | + | |
266 | + *p = '\0'; | |
267 | + return p; | |
268 | +} | |
269 | +#endif | |
270 | + | |
271 | --- wget-1.9.1/src/ftp.h.lfs 2003-09-18 15:46:17.000000000 +0200 | |
272 | +++ wget-1.9.1/src/ftp.h 2004-09-29 17:54:08.560852440 +0200 | |
273 | @@ -57,11 +57,11 @@ | |
274 | uerr_t ftp_type PARAMS ((struct rbuf *, int)); | |
275 | uerr_t ftp_cwd PARAMS ((struct rbuf *, const char *)); | |
276 | uerr_t ftp_retr PARAMS ((struct rbuf *, const char *)); | |
277 | -uerr_t ftp_rest PARAMS ((struct rbuf *, long)); | |
278 | +uerr_t ftp_rest PARAMS ((struct rbuf *, off_t)); | |
279 | uerr_t ftp_list PARAMS ((struct rbuf *, const char *)); | |
280 | uerr_t ftp_syst PARAMS ((struct rbuf *, enum stype *)); | |
281 | uerr_t ftp_pwd PARAMS ((struct rbuf *, char **)); | |
282 | -uerr_t ftp_size PARAMS ((struct rbuf *, const char *, long int *)); | |
283 | +uerr_t ftp_size PARAMS ((struct rbuf *, const char *, off_t *)); | |
284 | ||
285 | struct url; | |
286 | ||
287 | @@ -86,7 +86,7 @@ | |
288 | { | |
289 | enum ftype type; /* file type */ | |
290 | char *name; /* file name */ | |
291 | - long size; /* file size */ | |
292 | + off_t size; /* file size */ | |
293 | long tstamp; /* time-stamp */ | |
294 | int perms; /* file permissions */ | |
295 | char *linkto; /* link to which file points */ | |
296 | --- wget-1.9.1/src/html-url.c.lfs 2003-10-13 16:32:25.000000000 +0200 | |
297 | +++ wget-1.9.1/src/html-url.c 2004-09-29 17:54:08.561852288 +0200 | |
298 | @@ -598,7 +598,7 @@ | |
299 | logprintf (LOG_NOTQUIET, "%s: %s\n", file, strerror (errno)); | |
300 | return NULL; | |
301 | } | |
302 | - DEBUGP (("Loaded %s (size %ld).\n", file, fm->length)); | |
303 | + DEBUGP (("Loaded %s (size %s).\n", file, legible_off_t(fm->length))); | |
304 | ||
305 | ctx.text = fm->content; | |
306 | ctx.head = ctx.tail = NULL; | |
307 | @@ -647,7 +647,7 @@ | |
308 | logprintf (LOG_NOTQUIET, "%s: %s\n", file, strerror (errno)); | |
309 | return NULL; | |
310 | } | |
311 | - DEBUGP (("Loaded %s (size %ld).\n", file, fm->length)); | |
312 | + DEBUGP (("Loaded %s (size %s).\n", file, legible_off_t(fm->length))); | |
313 | ||
314 | head = tail = NULL; | |
315 | text = fm->content; | |
316 | --- wget-1.9.1/src/connect.h.lfs 2003-09-21 01:12:18.000000000 +0200 | |
317 | +++ wget-1.9.1/src/connect.h 2004-09-29 17:54:08.562852136 +0200 | |
318 | @@ -45,7 +45,7 @@ | |
319 | void closeport PARAMS ((int)); | |
320 | int conaddr PARAMS ((int, ip_address *)); | |
321 | ||
322 | -int iread PARAMS ((int, char *, int)); | |
323 | -int iwrite PARAMS ((int, char *, int)); | |
324 | +int iread PARAMS ((int, char *, off_t)); | |
325 | +int iwrite PARAMS ((int, char *, off_t)); | |
326 | ||
327 | #endif /* CONNECT_H */ | |
328 | --- wget-1.9.1/src/http.c.lfs 2004-09-29 17:54:08.481864448 +0200 | |
329 | +++ wget-1.9.1/src/http.c 2004-09-29 18:03:55.983550616 +0200 | |
330 | @@ -194,10 +194,10 @@ | |
331 | longer, read only that much; if the file is shorter, report an error. */ | |
332 | ||
333 | static int | |
334 | -post_file (int sock, void *ssl, const char *file_name, long promised_size) | |
335 | +post_file (int sock, void *ssl, const char *file_name, off_t promised_size) | |
336 | { | |
337 | static char chunk[8192]; | |
338 | - long written = 0; | |
339 | + off_t written = 0; | |
340 | int write_error; | |
341 | FILE *fp; | |
342 | ||
343 | @@ -248,9 +248,9 @@ | |
344 | /* Functions to be used as arguments to header_process(): */ | |
345 | ||
346 | struct http_process_range_closure { | |
347 | - long first_byte_pos; | |
348 | - long last_byte_pos; | |
349 | - long entity_length; | |
350 | + off_t first_byte_pos; | |
351 | + off_t last_byte_pos; | |
352 | + off_t entity_length; | |
353 | }; | |
354 | ||
355 | /* Parse the `Content-Range' header and extract the information it | |
356 | @@ -260,7 +260,7 @@ | |
357 | { | |
358 | struct http_process_range_closure *closure | |
359 | = (struct http_process_range_closure *)arg; | |
360 | - long num; | |
361 | + off_t num; | |
362 | ||
363 | /* Certain versions of Nutscape proxy server send out | |
364 | `Content-Length' without "bytes" specifier, which is a breach of | |
365 | @@ -566,9 +566,9 @@ | |
366 | \f | |
367 | struct http_stat | |
368 | { | |
369 | - long len; /* received length */ | |
370 | - long contlen; /* expected length */ | |
371 | - long restval; /* the restart value */ | |
372 | + off_t len; /* received length */ | |
373 | + off_t contlen; /* expected length */ | |
374 | + off_t restval; /* the restart value */ | |
375 | int res; /* the result of last read */ | |
376 | char *newloc; /* new location (redirection) */ | |
377 | char *remote_time; /* remote time-stamp string */ | |
378 | @@ -633,7 +633,7 @@ | |
379 | char *request_keep_alive; | |
380 | int sock, hcount, all_length, statcode; | |
381 | int write_error; | |
382 | - long contlen, contrange; | |
383 | + off_t contlen, contrange; | |
384 | struct url *conn; | |
385 | FILE *fp; | |
386 | int auth_tried_already; | |
387 | @@ -662,7 +662,7 @@ | |
388 | ||
389 | /* Headers sent when using POST. */ | |
390 | char *post_content_type, *post_content_length; | |
391 | - long post_data_size = 0; | |
392 | + off_t post_data_size = 0; | |
393 | ||
394 | #ifdef HAVE_SSL | |
395 | /* initialize ssl_ctx on first run */ | |
396 | @@ -811,7 +811,11 @@ | |
397 | HTTP/1.1 specifies a multipart/byte-ranges MIME type, but | |
398 | only if multiple non-overlapping ranges are requested -- | |
399 | which Wget never does. */ | |
400 | +#ifdef LFS | |
401 | + sprintf (range, "Range: bytes=%llu-\r\n", hs->restval); | |
402 | +#else | |
403 | sprintf (range, "Range: bytes=%ld-\r\n", hs->restval); | |
404 | +#endif | |
405 | } | |
406 | else | |
407 | range = NULL; | |
408 | @@ -933,8 +937,13 @@ | |
409 | } | |
410 | } | |
411 | post_content_length = xmalloc (16 + numdigit (post_data_size) + 2 + 1); | |
412 | +#ifdef LFS | |
413 | + sprintf (post_content_length, | |
414 | + "Content-Length: %llu\r\n", post_data_size); | |
415 | +#else | |
416 | sprintf (post_content_length, | |
417 | "Content-Length: %ld\r\n", post_data_size); | |
418 | +#endif | |
419 | } | |
420 | ||
421 | if (proxy) | |
422 | @@ -1168,7 +1177,7 @@ | |
423 | ||
424 | /* Try getting content-length. */ | |
425 | if (contlen == -1 && !opt.ignore_length) | |
426 | - if (header_process (hdr, "Content-Length", header_extract_number, | |
427 | + if (header_process (hdr, "Content-Length", header_extract_number_off_t, | |
428 | &contlen)) | |
429 | goto done_header; | |
430 | /* Try getting content-type. */ | |
431 | @@ -1448,10 +1457,10 @@ | |
432 | logputs (LOG_VERBOSE, _("Length: ")); | |
433 | if (contlen != -1) | |
434 | { | |
435 | - logputs (LOG_VERBOSE, legible (contlen)); | |
436 | + logputs (LOG_VERBOSE, legible_off_t (contlen)); | |
437 | if (contrange != -1) | |
438 | logprintf (LOG_VERBOSE, _(" (%s to go)"), | |
439 | - legible (contlen - contrange)); | |
440 | + legible_off_t (contlen - contrange)); | |
441 | } | |
442 | else | |
443 | logputs (LOG_VERBOSE, | |
444 | @@ -1573,7 +1582,7 @@ | |
445 | char *tms, *locf, *tmrate; | |
446 | uerr_t err; | |
447 | time_t tml = -1, tmr = -1; /* local and remote time-stamps */ | |
448 | - long local_size = 0; /* the size of the local file */ | |
449 | + off_t local_size = 0; /* the size of the local file */ | |
450 | size_t filename_len; | |
451 | struct http_stat hstat; /* HTTP status */ | |
452 | struct stat st; | |
453 | @@ -1905,7 +1914,7 @@ | |
454 | } | |
455 | else if (tml >= tmr) | |
456 | logprintf (LOG_VERBOSE, _("\ | |
457 | -The sizes do not match (local %ld) -- retrieving.\n"), local_size); | |
458 | +The sizes do not match (local %s) -- retrieving.\n"), legible_off_t(local_size)); | |
459 | else | |
460 | logputs (LOG_VERBOSE, | |
461 | _("Remote file is newer, retrieving.\n")); | |
462 | @@ -1949,11 +1958,11 @@ | |
463 | if (*dt & RETROKF) | |
464 | { | |
465 | logprintf (LOG_VERBOSE, | |
466 | - _("%s (%s) - `%s' saved [%ld/%ld]\n\n"), | |
467 | - tms, tmrate, locf, hstat.len, hstat.contlen); | |
468 | + _("%s (%s) - `%s' saved [%s/%s]\n\n"), | |
469 | + tms, tmrate, locf, legible_off_t(hstat.len), legible_off_t(hstat.contlen)); | |
470 | logprintf (LOG_NONVERBOSE, | |
471 | - "%s URL:%s [%ld/%ld] -> \"%s\" [%d]\n", | |
472 | - tms, u->url, hstat.len, hstat.contlen, locf, count); | |
473 | + "%s URL:%s [%s/%s] -> \"%s\" [%d]\n", | |
474 | + tms, u->url, legible_off_t(hstat.len), legible_off_t(hstat.contlen), locf, count); | |
475 | } | |
476 | ++opt.numurls; | |
477 | total_downloaded_bytes += hstat.len; | |
478 | @@ -1976,11 +1985,11 @@ | |
479 | if (*dt & RETROKF) | |
480 | { | |
481 | logprintf (LOG_VERBOSE, | |
482 | - _("%s (%s) - `%s' saved [%ld]\n\n"), | |
483 | - tms, tmrate, locf, hstat.len); | |
484 | + _("%s (%s) - `%s' saved [%s]\n\n"), | |
485 | + tms, tmrate, locf, legible_off_t(hstat.len)); | |
486 | logprintf (LOG_NONVERBOSE, | |
487 | - "%s URL:%s [%ld] -> \"%s\" [%d]\n", | |
488 | - tms, u->url, hstat.len, locf, count); | |
489 | + "%s URL:%s [%s] -> \"%s\" [%d]\n", | |
490 | + tms, u->url, legible_off_t(hstat.len), locf, count); | |
491 | } | |
492 | ++opt.numurls; | |
493 | total_downloaded_bytes += hstat.len; | |
494 | @@ -1999,8 +2008,8 @@ | |
495 | connection too soon */ | |
496 | { | |
497 | logprintf (LOG_VERBOSE, | |
498 | - _("%s (%s) - Connection closed at byte %ld. "), | |
499 | - tms, tmrate, hstat.len); | |
500 | + _("%s (%s) - Connection closed at byte %s. "), | |
501 | + tms, tmrate, legible_off_t(hstat.len)); | |
502 | printwhat (count, opt.ntry); | |
503 | free_hstat (&hstat); | |
504 | continue; | |
505 | @@ -2008,11 +2017,11 @@ | |
506 | else if (!opt.kill_longer) /* meaning we got more than expected */ | |
507 | { | |
508 | logprintf (LOG_VERBOSE, | |
509 | - _("%s (%s) - `%s' saved [%ld/%ld])\n\n"), | |
510 | - tms, tmrate, locf, hstat.len, hstat.contlen); | |
511 | + _("%s (%s) - `%s' saved [%s/%s])\n\n"), | |
512 | + tms, tmrate, locf, legible_off_t(hstat.len), legible_off_t(hstat.contlen)); | |
513 | logprintf (LOG_NONVERBOSE, | |
514 | - "%s URL:%s [%ld/%ld] -> \"%s\" [%d]\n", | |
515 | - tms, u->url, hstat.len, hstat.contlen, locf, count); | |
516 | + "%s URL:%s [%s/%s] -> \"%s\" [%d]\n", | |
517 | + tms, u->url, legible_off_t(hstat.len), legible_off_t(hstat.contlen), locf, count); | |
518 | ++opt.numurls; | |
519 | total_downloaded_bytes += hstat.len; | |
520 | ||
521 | @@ -2029,8 +2038,8 @@ | |
522 | else /* the same, but not accepted */ | |
523 | { | |
524 | logprintf (LOG_VERBOSE, | |
525 | - _("%s (%s) - Connection closed at byte %ld/%ld. "), | |
526 | - tms, tmrate, hstat.len, hstat.contlen); | |
527 | + _("%s (%s) - Connection closed at byte %s/%s. "), | |
528 | + tms, tmrate, legible_off_t(hstat.len), legible_off_t(hstat.contlen)); | |
529 | printwhat (count, opt.ntry); | |
530 | free_hstat (&hstat); | |
531 | continue; | |
532 | @@ -2041,8 +2050,8 @@ | |
533 | if (hstat.contlen == -1) | |
534 | { | |
535 | logprintf (LOG_VERBOSE, | |
536 | - _("%s (%s) - Read error at byte %ld (%s)."), | |
537 | - tms, tmrate, hstat.len, strerror (errno)); | |
538 | + _("%s (%s) - Read error at byte %s (%s)."), | |
539 | + tms, tmrate, legible_off_t(hstat.len), strerror (errno)); | |
540 | printwhat (count, opt.ntry); | |
541 | free_hstat (&hstat); | |
542 | continue; | |
543 | @@ -2050,8 +2059,8 @@ | |
544 | else /* hstat.res == -1 and contlen is given */ | |
545 | { | |
546 | logprintf (LOG_VERBOSE, | |
547 | - _("%s (%s) - Read error at byte %ld/%ld (%s). "), | |
548 | - tms, tmrate, hstat.len, hstat.contlen, | |
549 | + _("%s (%s) - Read error at byte %s/%s (%s). "), | |
550 | + tms, tmrate, legible_off_t(hstat.len), legible_off_t(hstat.contlen), | |
551 | strerror (errno)); | |
552 | printwhat (count, opt.ntry); | |
553 | free_hstat (&hstat); | |
554 | --- wget-1.9.1/src/gen_sslfunc.h.lfs 2002-05-18 04:16:22.000000000 +0200 | |
555 | +++ wget-1.9.1/src/gen_sslfunc.h 2004-09-29 17:54:08.565851680 +0200 | |
556 | @@ -42,8 +42,8 @@ | |
557 | void shutdown_ssl PARAMS ((SSL*)); | |
558 | void free_ssl_ctx PARAMS ((SSL_CTX *)); | |
559 | int verify_callback PARAMS ((int, X509_STORE_CTX *)); | |
560 | -int ssl_iread PARAMS ((SSL *, char *, int)); | |
561 | -int ssl_iwrite PARAMS ((SSL *, char *, int)); | |
562 | +int ssl_iread PARAMS ((SSL *, char *, off_t)); | |
563 | +int ssl_iwrite PARAMS ((SSL *, char *, off_t)); | |
564 | int ssl_printerrors PARAMS ((void)); | |
565 | ||
566 | #endif /* GEN_SSLFUNC_H */ | |
567 | --- wget-1.9.1/src/gen_sslfunc.c.lfs 2003-09-21 06:41:55.000000000 +0200 | |
568 | +++ wget-1.9.1/src/gen_sslfunc.c 2004-09-29 17:54:08.566851528 +0200 | |
569 | @@ -312,7 +312,7 @@ | |
570 | most LEN bytes from FD, storing them to BUF. */ | |
571 | ||
572 | int | |
573 | -ssl_iread (SSL *con, char *buf, int len) | |
574 | +ssl_iread (SSL *con, char *buf, off_t len) | |
575 | { | |
576 | int res, fd; | |
577 | BIO_get_fd (con->rbio, &fd); | |
578 | @@ -332,7 +332,7 @@ | |
579 | LEN bytes from BUF to FD. */ | |
580 | ||
581 | int | |
582 | -ssl_iwrite (SSL *con, char *buf, int len) | |
583 | +ssl_iwrite (SSL *con, char *buf, off_t len) | |
584 | { | |
585 | int res = 0, fd; | |
586 | BIO_get_fd (con->rbio, &fd); | |
587 | --- wget-1.9.1/src/headers.c.lfs 2004-09-29 17:59:26.421530272 +0200 | |
588 | +++ wget-1.9.1/src/headers.c 2004-09-29 18:00:53.141346856 +0200 | |
589 | @@ -179,6 +179,33 @@ | |
590 | return 1; | |
591 | } | |
592 | ||
593 | +/* Extract a long integer from HEADER and store it to CLOSURE. If an | |
594 | + error is encountered, return 0, else 1. */ | |
595 | +int | |
596 | +header_extract_number_off_t (const char *header, void *closure) | |
597 | +{ | |
598 | + const char *p = header; | |
599 | + off_t result; | |
600 | + | |
601 | + for (result = 0; ISDIGIT (*p); p++) | |
602 | + result = 10 * result + (*p - '0'); | |
603 | + | |
604 | + /* Failure if no number present. */ | |
605 | + if (p == header) | |
606 | + return 0; | |
607 | + | |
608 | + /* Skip trailing whitespace. */ | |
609 | + p += skip_lws (p); | |
610 | + | |
611 | + /* Indicate failure if trailing garbage is present. */ | |
612 | + if (*p) | |
613 | + return 0; | |
614 | + | |
615 | + *(off_t *)closure = result; | |
616 | + return 1; | |
617 | +} | |
618 | + | |
619 | + | |
620 | /* Strdup HEADER, and place the pointer to CLOSURE. */ | |
621 | int | |
622 | header_strdup (const char *header, void *closure) | |
623 | --- wget-1.9.1/src/ftp-basic.c.lfs 2004-09-29 17:54:08.534856392 +0200 | |
624 | +++ wget-1.9.1/src/ftp-basic.c 2004-09-29 17:54:08.567851376 +0200 | |
625 | @@ -614,14 +614,14 @@ | |
626 | ||
627 | /* Sends REST command to the FTP server. */ | |
628 | uerr_t | |
629 | -ftp_rest (struct rbuf *rbuf, long offset) | |
630 | +ftp_rest (struct rbuf *rbuf, off_t offset) | |
631 | { | |
632 | char *request, *respline; | |
633 | int nwritten; | |
634 | uerr_t err; | |
635 | static char numbuf[24]; /* Buffer for the number */ | |
636 | ||
637 | - number_to_string (numbuf, offset); | |
638 | + number_to_string_off_t (numbuf, offset); | |
639 | request = ftp_request ("REST", numbuf); | |
640 | nwritten = iwrite (RBUF_FD (rbuf), request, strlen (request)); | |
641 | if (nwritten < 0) | |
642 | @@ -828,10 +828,140 @@ | |
643 | return FTPOK; | |
644 | } | |
645 | ||
646 | + | |
647 | +#ifdef LFS | |
648 | +unsigned long long int wget_strtoull ( const char * str, | |
649 | + char ** endptr, | |
650 | + int base ) | |
651 | +/* *********************************************************************** */ | |
652 | +/* */ | |
653 | +/* These functions shall convert the initial portion of the string */ | |
654 | +/* pointed to by nptr to double, float, and long double representation, */ | |
655 | +/* respectively. First, they decompose the input string into three parts: */ | |
656 | +/* */ | |
657 | +/* An initial, possibly empty, sequence of white-space characters */ | |
658 | +/* (as specified by isspace()) */ | |
659 | +/* A subject sequence interpreted as a floating-point constant or */ | |
660 | +/* representing infinity or NaN */ | |
661 | +/* A final string of one or more unrecognized characters, including the */ | |
662 | +/* terminating null byte of the input string */ | |
663 | +/* */ | |
664 | +/* Then they shall attempt to convert the subject sequence */ | |
665 | +/* to a floating-point number, and return the result. */ | |
666 | +/* */ | |
667 | +/* The expected form of the subject sequence is an optional plus or */ | |
668 | +/* minus sign, then one of the following: */ | |
669 | +/* */ | |
670 | +/* A non-empty sequence of decimal digits optionally containing */ | |
671 | +/* a radix character, then an optional exponent part */ | |
672 | +/* */ | |
673 | +/* A 0x or 0X, then a non-empty sequence of hexadecimal digits optionally */ | |
674 | +/* containing a radix character, then an optional binary exponent part */ | |
675 | +/* */ | |
676 | +/* One of INF or INFINITY, ignoring case */ | |
677 | +/* */ | |
678 | +/* One of NAN or NAN(n-char-sequenceopt), ignoring case */ | |
679 | +/* in the NAN part, where: */ | |
680 | +/* n-char-sequence: -- digit -- nondigit -- n-char-sequence digit */ | |
681 | +/* -- n-char-sequence nondigit */ | |
682 | +/* */ | |
683 | +/* Borrowed from http://www.greatsnakes.com/Sepal/d8/d4/strtoull_8c.html */ | |
684 | +/* on 2004.09.09 */ | |
685 | +/* */ | |
686 | +/* 2003, greatsnakes.com. "Verbatim copying and distribution of this */ | |
687 | +/* entire article is permitted in any medium, provided this notice */ | |
688 | +/* is preserved." -- unless otherwise specified. */ | |
689 | +/* */ | |
690 | +/* *********************************************************************** */ | |
691 | +#define WGET__ULLONG_MAX ( 18446744073709551615ULL ) | |
692 | + | |
693 | +{ | |
694 | + unsigned long long result; | |
695 | + unsigned long long stop; | |
696 | + | |
697 | + const char *cursor = str; | |
698 | + int i_char, sign = 0, track, threshold; | |
699 | + | |
700 | + do | |
701 | + { | |
702 | + i_char = *cursor++; | |
703 | + } while ( isspace( i_char & 0xff ) ); | |
704 | + | |
705 | + if ( i_char == '-' ) | |
706 | + { | |
707 | + sign = 1; | |
708 | + i_char = *cursor++; | |
709 | + } else if ( i_char == '+' ) | |
710 | + { | |
711 | + i_char = *cursor++; | |
712 | + }/* end of if else */ | |
713 | + | |
714 | + if (( base == 0 || base == 16 ) && | |
715 | + ( i_char == '0' ) && ( ( ( *cursor == 'x' ) || ( *cursor == 'X' )))) | |
716 | + { | |
717 | + i_char = cursor[1]; | |
718 | + cursor += 2; | |
719 | + base = 16; | |
720 | + }/* end of if base */ | |
721 | + | |
722 | + if ( base == 0 ) | |
723 | + base = ( ( i_char == '0' ) ? 8 : 10 ); | |
724 | + | |
725 | + stop = ((( unsigned long long ) WGET__ULLONG_MAX) / base); | |
726 | + threshold = ((( unsigned long long ) WGET__ULLONG_MAX) % base); | |
727 | + result = 0; track = 0; | |
728 | + | |
729 | + for ( ;; ( i_char = *cursor++ ), ( i_char &= 0xff ) ) | |
730 | + { | |
731 | + if ( isdigit(i_char) ) | |
732 | + { | |
733 | + i_char -= '0'; | |
734 | + } else if (isalpha(i_char)) | |
735 | + { | |
736 | + i_char -= ( isupper(i_char) ? ('A' - 10) : ('a' - 10) ); | |
737 | + } else | |
738 | + { | |
739 | + break; | |
740 | + }/* if elseif else */ | |
741 | + | |
742 | + if ( i_char >= base ) | |
743 | + break; | |
744 | + if ( ( track < 0 ) || ( result > stop ) || | |
745 | + ( result == stop && ( i_char > threshold ) ) ) | |
746 | + { | |
747 | + track = -1; | |
748 | + } else | |
749 | + { | |
750 | + track = 1; | |
751 | + result *= base; | |
752 | + result += i_char; | |
753 | + }/* end if else */ | |
754 | + }/* for ( ;; ( i_char = *cursor++ ), ( i_char &= 0xff ) ) */ | |
755 | + | |
756 | + if ( track < 0 ) | |
757 | + { | |
758 | + result = (( unsigned long long ) WGET__ULLONG_MAX); | |
759 | + errno = ERANGE; | |
760 | + } else if ( sign ) | |
761 | + { | |
762 | + result = -result; | |
763 | + }/* end of if else */ | |
764 | + | |
765 | + if ( endptr != 0 ) | |
766 | + { | |
767 | + // *endptr = ( track ? ( fixit( str, char * ) - 1 ) | |
768 | + // : fixit( str, char * ) ); | |
769 | + } | |
770 | + | |
771 | + return result; | |
772 | +}/* unsigned long long int wget_strtoull ( const char *str, char **endptr, int base ) */ | |
773 | + | |
774 | +#endif /* ifdef LFS */ | |
775 | + | |
776 | /* Sends the SIZE command to the server, and returns the value in 'size'. | |
777 | * If an error occurs, size is set to zero. */ | |
778 | uerr_t | |
779 | -ftp_size (struct rbuf *rbuf, const char *file, long int *size) | |
780 | +ftp_size (struct rbuf *rbuf, const char *file, off_t *size) | |
781 | { | |
782 | char *request, *respline; | |
783 | int nwritten; | |
784 | @@ -867,7 +997,11 @@ | |
785 | } | |
786 | ||
787 | errno = 0; | |
788 | - *size = strtol (respline + 4, NULL, 0); | |
789 | +#ifdef LFS | |
790 | + *size = wget_strtoull (respline + 4, NULL, 10); | |
791 | +#else | |
792 | + *size = strtol (respline + 4, NULL, 10); | |
793 | +#endif | |
794 | if (errno) | |
795 | { | |
796 | /* | |
797 | --- wget-1.9.1/src/progress.h.lfs 2003-09-15 23:14:15.000000000 +0200 | |
798 | +++ wget-1.9.1/src/progress.h 2004-09-29 17:54:08.568851224 +0200 | |
799 | @@ -34,8 +34,8 @@ | |
800 | void set_progress_implementation PARAMS ((const char *)); | |
801 | void progress_schedule_redirect PARAMS ((void)); | |
802 | ||
803 | -void *progress_create PARAMS ((long, long)); | |
804 | -void progress_update PARAMS ((void *, long, double)); | |
805 | +void *progress_create PARAMS ((off_t, off_t)); | |
806 | +void progress_update PARAMS ((void *, off_t, double)); | |
807 | void progress_finish PARAMS ((void *, double)); | |
808 | ||
809 | RETSIGTYPE progress_handle_sigwinch PARAMS ((int)); | |
810 | --- wget-1.9.1/src/connect.c.lfs 2004-09-29 17:54:08.533856544 +0200 | |
811 | +++ wget-1.9.1/src/connect.c 2004-09-29 17:54:08.569851072 +0200 | |
812 | @@ -448,7 +448,7 @@ | |
813 | read()). */ | |
814 | ||
815 | int | |
816 | -iread (int fd, char *buf, int len) | |
817 | +iread (int fd, char *buf, off_t len) | |
818 | { | |
819 | int res; | |
820 | ||
821 | @@ -470,7 +470,7 @@ | |
822 | value equals to LEN. Instead, you should simply check for -1. */ | |
823 | ||
824 | int | |
825 | -iwrite (int fd, char *buf, int len) | |
826 | +iwrite (int fd, char *buf, off_t len) | |
827 | { | |
828 | int res = 0; | |
829 | ||
830 | --- wget-1.9.1/src/ftp-ls.c.lfs 2004-09-29 17:54:08.478864904 +0200 | |
831 | +++ wget-1.9.1/src/ftp-ls.c 2004-09-29 17:54:08.570850920 +0200 | |
832 | @@ -213,7 +213,7 @@ | |
833 | if (i != 12) | |
834 | { | |
835 | char *t = tok - 2; | |
836 | - long mul = 1; | |
837 | + off_t mul = 1; | |
838 | ||
839 | for (cur.size = 0; t > line && ISDIGIT (*t); mul *= 10, t--) | |
840 | cur.size += mul * (*t - '0'); | |
841 | @@ -512,7 +512,7 @@ | |
842 | cur.type = FT_PLAINFILE; | |
843 | cur.size = atoi(tok); | |
844 | cur.perms = 0644; | |
845 | - DEBUGP(("File, size %ld bytes\n", cur.size)); | |
846 | + DEBUGP(("File, size %s bytes\n", legible_off_t(cur.size))); | |
847 | } | |
848 | ||
849 | cur.linkto = NULL; | |
850 | @@ -912,7 +912,7 @@ | |
851 | putc ('/', fp); | |
852 | fprintf (fp, "</a> "); | |
853 | if (f->type == FT_PLAINFILE) | |
854 | - fprintf (fp, _(" (%s bytes)"), legible (f->size)); | |
855 | + fprintf (fp, _(" (%s bytes)"), legible_off_t (f->size)); | |
856 | else if (f->type == FT_SYMLINK) | |
857 | fprintf (fp, "-> %s", f->linkto ? f->linkto : "(nil)"); | |
858 | putc ('\n', fp); | |
859 | --- wget-1.9.1/src/progress.c.lfs 2004-09-29 17:54:08.485863840 +0200 | |
860 | +++ wget-1.9.1/src/progress.c 2004-09-29 17:54:08.571850768 +0200 | |
861 | @@ -53,21 +53,21 @@ | |
862 | ||
863 | struct progress_implementation { | |
864 | char *name; | |
865 | - void *(*create) PARAMS ((long, long)); | |
866 | - void (*update) PARAMS ((void *, long, double)); | |
867 | + void *(*create) PARAMS ((off_t, off_t)); | |
868 | + void (*update) PARAMS ((void *, off_t, double)); | |
869 | void (*finish) PARAMS ((void *, double)); | |
870 | void (*set_params) PARAMS ((const char *)); | |
871 | }; | |
872 | ||
873 | /* Necessary forward declarations. */ | |
874 | ||
875 | -static void *dot_create PARAMS ((long, long)); | |
876 | -static void dot_update PARAMS ((void *, long, double)); | |
877 | +static void *dot_create PARAMS ((off_t, off_t)); | |
878 | +static void dot_update PARAMS ((void *, off_t, double)); | |
879 | static void dot_finish PARAMS ((void *, double)); | |
880 | static void dot_set_params PARAMS ((const char *)); | |
881 | ||
882 | -static void *bar_create PARAMS ((long, long)); | |
883 | -static void bar_update PARAMS ((void *, long, double)); | |
884 | +static void *bar_create PARAMS ((off_t, off_t)); | |
885 | +static void bar_update PARAMS ((void *, off_t, double)); | |
886 | static void bar_finish PARAMS ((void *, double)); | |
887 | static void bar_set_params PARAMS ((const char *)); | |
888 | ||
889 | @@ -157,7 +157,7 @@ | |
890 | advance. */ | |
891 | ||
892 | void * | |
893 | -progress_create (long initial, long total) | |
894 | +progress_create (off_t initial, off_t total) | |
895 | { | |
896 | /* Check if the log status has changed under our feet. */ | |
897 | if (output_redirected) | |
898 | @@ -174,7 +174,7 @@ | |
899 | time in milliseconds since the beginning of the download. */ | |
900 | ||
901 | void | |
902 | -progress_update (void *progress, long howmuch, double dltime) | |
903 | +progress_update (void *progress, off_t howmuch, double dltime) | |
904 | { | |
905 | current_impl->update (progress, howmuch, dltime); | |
906 | } | |
907 | @@ -191,12 +191,12 @@ | |
908 | /* Dot-printing. */ | |
909 | ||
910 | struct dot_progress { | |
911 | - long initial_length; /* how many bytes have been downloaded | |
912 | + off_t initial_length; /* how many bytes have been downloaded | |
913 | previously. */ | |
914 | - long total_length; /* expected total byte count when the | |
915 | + off_t total_length; /* expected total byte count when the | |
916 | download finishes */ | |
917 | ||
918 | - int accumulated; | |
919 | + off_t accumulated; | |
920 | ||
921 | int rows; /* number of rows printed so far */ | |
922 | int dots; /* number of dots printed in this row */ | |
923 | @@ -206,7 +206,7 @@ | |
924 | /* Dot-progress backend for progress_create. */ | |
925 | ||
926 | static void * | |
927 | -dot_create (long initial, long total) | |
928 | +dot_create (off_t initial, off_t total) | |
929 | { | |
930 | struct dot_progress *dp = xmalloc (sizeof (struct dot_progress)); | |
931 | ||
932 | @@ -217,11 +217,35 @@ | |
933 | ||
934 | if (dp->initial_length) | |
935 | { | |
936 | +#ifdef LFS /* 64-bit off_t */ | |
937 | + long long int dot_bytes = opt.dot_bytes; | |
938 | + long row_bytes = opt.dot_bytes * opt.dots_in_line; | |
939 | + | |
940 | + long long int remainder = (long long int) (dp->initial_length % row_bytes); | |
941 | + off_t skipped = dp->initial_length - remainder; | |
942 | + | |
943 | + if (skipped) | |
944 | + { | |
945 | + long long int skipped_k = (skipped / 1024ULL); /* skipped amount in K */ | |
946 | + int skipped_k_len = numdigit_64 (skipped_k); | |
947 | + if (skipped_k_len < 5) | |
948 | + skipped_k_len = 5; | |
949 | + | |
950 | + /* Align the [ skipping ... ] line with the dots. To do | |
951 | + that, insert the number of spaces equal to the number of | |
952 | + digits in the skipped amount in K. */ | |
953 | + DEBUGP ( ("Skipped bytes: %llu", skipped )); | |
954 | + logprintf (LOG_VERBOSE, _("\n%*s[ skipping %lluK ]"), | |
955 | + 2 + skipped_k_len, "", skipped_k); | |
956 | + } | |
957 | + | |
958 | + logprintf (LOG_VERBOSE, "\n%5lluK", (skipped / 1024ULL) ); | |
959 | +#else | |
960 | int dot_bytes = opt.dot_bytes; | |
961 | long row_bytes = opt.dot_bytes * opt.dots_in_line; | |
962 | ||
963 | int remainder = (int) (dp->initial_length % row_bytes); | |
964 | - long skipped = dp->initial_length - remainder; | |
965 | + off_t skipped = dp->initial_length - remainder; | |
966 | ||
967 | if (skipped) | |
968 | { | |
969 | @@ -233,11 +257,13 @@ | |
970 | /* Align the [ skipping ... ] line with the dots. To do | |
971 | that, insert the number of spaces equal to the number of | |
972 | digits in the skipped amount in K. */ | |
973 | + DEBUGP ( ("Skipped bytes: %ld", skipped )); | |
974 | logprintf (LOG_VERBOSE, _("\n%*s[ skipping %dK ]"), | |
975 | 2 + skipped_k_len, "", skipped_k); | |
976 | } | |
977 | ||
978 | - logprintf (LOG_VERBOSE, "\n%5ldK", skipped / 1024); | |
979 | + logprintf (LOG_VERBOSE, "\n%5luK", skipped / 1024); | |
980 | +#endif | |
981 | for (; remainder >= dot_bytes; remainder -= dot_bytes) | |
982 | { | |
983 | if (dp->dots % opt.dot_spacing == 0) | |
984 | @@ -255,14 +281,14 @@ | |
985 | } | |
986 | ||
987 | static void | |
988 | -print_percentage (long bytes, long expected) | |
989 | +print_percentage (off_t bytes, off_t expected) | |
990 | { | |
991 | int percentage = (int)(100.0 * bytes / expected); | |
992 | logprintf (LOG_VERBOSE, "%3d%%", percentage); | |
993 | } | |
994 | ||
995 | static void | |
996 | -print_download_speed (struct dot_progress *dp, long bytes, double dltime) | |
997 | +print_download_speed (struct dot_progress *dp, off_t bytes, double dltime) | |
998 | { | |
999 | logprintf (LOG_VERBOSE, " %s", | |
1000 | retr_rate (bytes, dltime - dp->last_timer_value, 1)); | |
1001 | @@ -272,7 +298,7 @@ | |
1002 | /* Dot-progress backend for progress_update. */ | |
1003 | ||
1004 | static void | |
1005 | -dot_update (void *progress, long howmuch, double dltime) | |
1006 | +dot_update (void *progress, off_t howmuch, double dltime) | |
1007 | { | |
1008 | struct dot_progress *dp = progress; | |
1009 | int dot_bytes = opt.dot_bytes; | |
1010 | @@ -284,7 +310,12 @@ | |
1011 | for (; dp->accumulated >= dot_bytes; dp->accumulated -= dot_bytes) | |
1012 | { | |
1013 | if (dp->dots == 0) | |
1014 | +#ifdef LFS | |
1015 | + logprintf (LOG_VERBOSE, "\n%5lluK", | |
1016 | + (long long)dp->rows * (long long)row_bytes / 1024ULL ); | |
1017 | +#else | |
1018 | logprintf (LOG_VERBOSE, "\n%5ldK", dp->rows * row_bytes / 1024); | |
1019 | +#endif | |
1020 | ||
1021 | if (dp->dots % opt.dot_spacing == 0) | |
1022 | logputs (LOG_VERBOSE, " "); | |
1023 | @@ -301,7 +332,12 @@ | |
1024 | dp->dots = 0; | |
1025 | ||
1026 | if (dp->total_length) | |
1027 | +#ifdef LFS | |
1028 | + print_percentage ( (long long)dp->rows * (long long)row_bytes, | |
1029 | + dp->total_length); | |
1030 | +#else | |
1031 | print_percentage (dp->rows * row_bytes, dp->total_length); | |
1032 | +#endif | |
1033 | print_download_speed (dp, row_qty, dltime); | |
1034 | } | |
1035 | } | |
1036 | @@ -322,7 +358,12 @@ | |
1037 | log_set_flush (0); | |
1038 | ||
1039 | if (dp->dots == 0) | |
1040 | +#ifdef LFS | |
1041 | + logprintf (LOG_VERBOSE, "\n%5lluK", | |
1042 | + (long long)dp->rows * (long long)(row_bytes) / 1024ULL ); | |
1043 | +#else | |
1044 | logprintf (LOG_VERBOSE, "\n%5ldK", dp->rows * row_bytes / 1024); | |
1045 | +#endif | |
1046 | for (i = dp->dots; i < opt.dots_in_line; i++) | |
1047 | { | |
1048 | if (i % opt.dot_spacing == 0) | |
1049 | @@ -331,14 +372,26 @@ | |
1050 | } | |
1051 | if (dp->total_length) | |
1052 | { | |
1053 | +#ifdef LFS | |
1054 | + print_percentage ( (long long)dp->rows * (long long)row_bytes | |
1055 | + + (long long)dp->dots * (long long)dot_bytes | |
1056 | + + dp->accumulated, | |
1057 | + dp->total_length); | |
1058 | +#else | |
1059 | print_percentage (dp->rows * row_bytes | |
1060 | + dp->dots * dot_bytes | |
1061 | + dp->accumulated, | |
1062 | dp->total_length); | |
1063 | +#endif | |
1064 | } | |
1065 | ||
1066 | { | |
1067 | +#ifdef LFS | |
1068 | + long long row_qty = (long long)dp->dots * (long long)dot_bytes | |
1069 | + + dp->accumulated; | |
1070 | +#else | |
1071 | long row_qty = dp->dots * dot_bytes + dp->accumulated; | |
1072 | +#endif | |
1073 | if (dp->rows == dp->initial_length / row_bytes) | |
1074 | row_qty -= dp->initial_length % row_bytes; | |
1075 | print_download_speed (dp, row_qty, dltime); | |
1076 | @@ -425,11 +478,11 @@ | |
1077 | #define DLSPEED_SAMPLE_MIN 150 | |
1078 | ||
1079 | struct bar_progress { | |
1080 | - long initial_length; /* how many bytes have been downloaded | |
1081 | + off_t initial_length; /* how many bytes have been downloaded | |
1082 | previously. */ | |
1083 | - long total_length; /* expected total byte count when the | |
1084 | + off_t total_length; /* expected total byte count when the | |
1085 | download finishes */ | |
1086 | - long count; /* bytes downloaded so far */ | |
1087 | + off_t count; /* bytes downloaded so far */ | |
1088 | ||
1089 | double last_screen_update; /* time of the last screen update, | |
1090 | measured since the beginning of | |
1091 | @@ -452,18 +505,18 @@ | |
1092 | details. */ | |
1093 | struct bar_progress_hist { | |
1094 | int pos; | |
1095 | - long times[DLSPEED_HISTORY_SIZE]; | |
1096 | - long bytes[DLSPEED_HISTORY_SIZE]; | |
1097 | + off_t times[DLSPEED_HISTORY_SIZE]; | |
1098 | + off_t bytes[DLSPEED_HISTORY_SIZE]; | |
1099 | ||
1100 | /* The sum of times and bytes respectively, maintained for | |
1101 | efficiency. */ | |
1102 | - long total_time; | |
1103 | - long total_bytes; | |
1104 | + off_t total_time; | |
1105 | + off_t total_bytes; | |
1106 | } hist; | |
1107 | ||
1108 | double recent_start; /* timestamp of beginning of current | |
1109 | position. */ | |
1110 | - long recent_bytes; /* bytes downloaded so far. */ | |
1111 | + off_t recent_bytes; /* bytes downloaded so far. */ | |
1112 | ||
1113 | /* create_image() uses these to make sure that ETA information | |
1114 | doesn't flash. */ | |
1115 | @@ -477,7 +530,7 @@ | |
1116 | static void display_image PARAMS ((char *)); | |
1117 | ||
1118 | static void * | |
1119 | -bar_create (long initial, long total) | |
1120 | +bar_create (off_t initial, off_t total) | |
1121 | { | |
1122 | struct bar_progress *bp = xmalloc (sizeof (struct bar_progress)); | |
1123 | ||
1124 | @@ -504,10 +557,10 @@ | |
1125 | return bp; | |
1126 | } | |
1127 | ||
1128 | -static void update_speed_ring PARAMS ((struct bar_progress *, long, double)); | |
1129 | +static void update_speed_ring PARAMS ((struct bar_progress *, off_t, double)); | |
1130 | ||
1131 | static void | |
1132 | -bar_update (void *progress, long howmuch, double dltime) | |
1133 | +bar_update (void *progress, off_t howmuch, double dltime) | |
1134 | { | |
1135 | struct bar_progress *bp = progress; | |
1136 | int force_screen_update = 0; | |
1137 | @@ -578,7 +631,7 @@ | |
1138 | 3-second average would be too erratic. */ | |
1139 | ||
1140 | static void | |
1141 | -update_speed_ring (struct bar_progress *bp, long howmuch, double dltime) | |
1142 | +update_speed_ring (struct bar_progress *bp, off_t howmuch, double dltime) | |
1143 | { | |
1144 | struct bar_progress_hist *hist = &bp->hist; | |
1145 | double recent_age = dltime - bp->recent_start; | |
1146 | @@ -643,9 +696,9 @@ | |
1147 | create_image (struct bar_progress *bp, double dl_total_time) | |
1148 | { | |
1149 | char *p = bp->buffer; | |
1150 | - long size = bp->initial_length + bp->count; | |
1151 | + off_t size = bp->initial_length + bp->count; | |
1152 | ||
1153 | - char *size_legible = legible (size); | |
1154 | + char *size_legible = legible_off_t (size); | |
1155 | int size_legible_len = strlen (size_legible); | |
1156 | ||
1157 | struct bar_progress_hist *hist = &bp->hist; | |
1158 | @@ -752,7 +805,7 @@ | |
1159 | } | |
1160 | ||
1161 | /* " 234,567,890" */ | |
1162 | - sprintf (p, " %-11s", legible (size)); | |
1163 | + sprintf (p, " %-11s", legible_off_t (size)); | |
1164 | p += strlen (p); | |
1165 | ||
1166 | /* " 1012.45K/s" */ | |
1167 | @@ -762,7 +815,7 @@ | |
1168 | int units = 0; | |
1169 | /* Calculate the download speed using the history ring and | |
1170 | recent data that hasn't made it to the ring yet. */ | |
1171 | - long dlquant = hist->total_bytes + bp->recent_bytes; | |
1172 | + off_t dlquant = hist->total_bytes + bp->recent_bytes; | |
1173 | double dltime = hist->total_time + (dl_total_time - bp->recent_start); | |
1174 | double dlspeed = calc_rate (dlquant, dltime, &units); | |
1175 | sprintf (p, " %7.2f%s", dlspeed, short_units[units]); | |
1176 | @@ -795,7 +848,7 @@ | |
1177 | I found that doing that results in a very jerky and | |
1178 | ultimately unreliable ETA. */ | |
1179 | double time_sofar = (double)dl_total_time / 1000; | |
1180 | - long bytes_remaining = bp->total_length - size; | |
1181 | + off_t bytes_remaining = bp->total_length - size; | |
1182 | eta = (long) (time_sofar * bytes_remaining / bp->count); | |
1183 | bp->last_eta_value = eta; | |
1184 | bp->last_eta_time = dl_total_time; | |
1185 | --- wget-1.9.1/src/ftp.c.lfs 2004-09-29 17:54:08.476865208 +0200 | |
1186 | +++ wget-1.9.1/src/ftp.c 2004-09-29 17:54:08.574850312 +0200 | |
1187 | @@ -84,10 +84,10 @@ | |
1188 | /* Look for regexp "( *[0-9]+ *byte" (literal parenthesis) anywhere in | |
1189 | the string S, and return the number converted to long, if found, 0 | |
1190 | otherwise. */ | |
1191 | -static long | |
1192 | +static off_t | |
1193 | ftp_expected_bytes (const char *s) | |
1194 | { | |
1195 | - long res; | |
1196 | + off_t res; | |
1197 | ||
1198 | while (1) | |
1199 | { | |
1200 | @@ -127,16 +127,16 @@ | |
1201 | connection to the server. It always closes the data connection, | |
1202 | and closes the control connection in case of error. */ | |
1203 | static uerr_t | |
1204 | -getftp (struct url *u, long *len, long restval, ccon *con) | |
1205 | +getftp (struct url *u, off_t *len, off_t restval, ccon *con) | |
1206 | { | |
1207 | int csock, dtsock, res; | |
1208 | - uerr_t err; | |
1209 | + uerr_t err = 0; | |
1210 | FILE *fp; | |
1211 | char *user, *passwd, *respline; | |
1212 | char *tms, *tmrate; | |
1213 | int cmd = con->cmd; | |
1214 | int pasv_mode_open = 0; | |
1215 | - long expected_bytes = 0L; | |
1216 | + off_t expected_bytes = 0; | |
1217 | ||
1218 | assert (con != NULL); | |
1219 | assert (con->target != NULL); | |
1220 | @@ -666,7 +666,7 @@ | |
1221 | if (restval && (cmd & DO_RETR)) | |
1222 | { | |
1223 | if (!opt.server_response) | |
1224 | - logprintf (LOG_VERBOSE, "==> REST %ld ... ", restval); | |
1225 | + logprintf (LOG_VERBOSE, "==> REST %s ... ", legible_off_t(restval)); | |
1226 | err = ftp_rest (&con->rbuf, restval); | |
1227 | ||
1228 | /* FTPRERR, WRITEFAILED, FTPRESTFAIL */ | |
1229 | @@ -897,21 +897,33 @@ | |
1230 | ||
1231 | if (*len) | |
1232 | { | |
1233 | - logprintf (LOG_VERBOSE, _("Length: %s"), legible (*len)); | |
1234 | + logprintf (LOG_VERBOSE, _("Length: %s"), legible_off_t (*len)); | |
1235 | if (restval) | |
1236 | - logprintf (LOG_VERBOSE, _(" [%s to go]"), legible (*len - restval)); | |
1237 | + logprintf (LOG_VERBOSE, _(" [%s to go]"), legible_off_t (*len - restval)); | |
1238 | logputs (LOG_VERBOSE, "\n"); | |
1239 | expected_bytes = *len; /* for get_contents/show_progress */ | |
1240 | } | |
1241 | else if (expected_bytes) | |
1242 | { | |
1243 | - logprintf (LOG_VERBOSE, _("Length: %s"), legible (expected_bytes)); | |
1244 | + logprintf (LOG_VERBOSE, _("Length: %s"), legible_off_t (expected_bytes)); | |
1245 | if (restval) | |
1246 | logprintf (LOG_VERBOSE, _(" [%s to go]"), | |
1247 | - legible (expected_bytes - restval)); | |
1248 | + legible_off_t (expected_bytes - restval)); | |
1249 | logputs (LOG_VERBOSE, _(" (unauthoritative)\n")); | |
1250 | } | |
1251 | - | |
1252 | + if (*len > 2147483647 && (*len - restval) <= 0 ) | |
1253 | + { | |
1254 | + logputs (LOG_VERBOSE, _("File has already been downloaded. Nothing to do.\n")); | |
1255 | + /* Close data connection socket. */ | |
1256 | + closeport (dtsock); | |
1257 | + /* Close the local file. */ | |
1258 | + int flush_res; | |
1259 | + if (con->cmd & DO_LIST) | |
1260 | + flush_res = fclose (fp); | |
1261 | + else | |
1262 | + flush_res = fflush (fp); | |
1263 | + return RETRFINISHED; | |
1264 | + } | |
1265 | /* Get the contents of the document. */ | |
1266 | res = get_contents (dtsock, fp, len, restval, expected_bytes, &con->rbuf, | |
1267 | 0, &con->dltime); | |
1268 | @@ -1031,7 +1043,7 @@ | |
1269 | ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con) | |
1270 | { | |
1271 | int count, orig_lp; | |
1272 | - long restval, len; | |
1273 | + off_t restval, len; | |
1274 | char *tms, *locf; | |
1275 | char *tmrate = NULL; | |
1276 | uerr_t err; | |
1277 | @@ -1179,16 +1191,16 @@ | |
1278 | rbuf_uninitialize (&con->rbuf); | |
1279 | } | |
1280 | if (!opt.spider) | |
1281 | - logprintf (LOG_VERBOSE, _("%s (%s) - `%s' saved [%ld]\n\n"), | |
1282 | - tms, tmrate, locf, len); | |
1283 | + logprintf (LOG_VERBOSE, _("%s (%s) - `%s' saved [%s]\n\n"), | |
1284 | + tms, tmrate, locf, legible_off_t(len)); | |
1285 | if (!opt.verbose && !opt.quiet) | |
1286 | { | |
1287 | /* Need to hide the password from the URL. The `if' is here | |
1288 | so that we don't do the needless allocation every | |
1289 | time. */ | |
1290 | char *hurl = url_string (u, 1); | |
1291 | - logprintf (LOG_NONVERBOSE, "%s URL: %s [%ld] -> \"%s\" [%d]\n", | |
1292 | - tms, hurl, len, locf, count); | |
1293 | + logprintf (LOG_NONVERBOSE, "%s URL: %s [%s] -> \"%s\" [%d]\n", | |
1294 | + tms, hurl, legible_off_t(len), locf, count); | |
1295 | xfree (hurl); | |
1296 | } | |
1297 | ||
1298 | @@ -1305,7 +1317,7 @@ | |
1299 | static int depth = 0; | |
1300 | uerr_t err; | |
1301 | struct fileinfo *orig; | |
1302 | - long local_size; | |
1303 | + off_t local_size; | |
1304 | time_t tml; | |
1305 | int dlthis; | |
1306 | ||
1307 | @@ -1398,7 +1410,7 @@ | |
1308 | { | |
1309 | /* Sizes do not match */ | |
1310 | logprintf (LOG_VERBOSE, _("\ | |
1311 | -The sizes do not match (local %ld) -- retrieving.\n\n"), local_size); | |
1312 | +The sizes do not match (local %s) -- retrieving.\n\n"), legible_off_t(local_size)); | |
1313 | } | |
1314 | } | |
1315 | } /* opt.timestamping && f->type == FT_PLAINFILE */ | |
1316 | @@ -1762,8 +1774,8 @@ | |
1317 | else | |
1318 | sz = -1; | |
1319 | logprintf (LOG_NOTQUIET, | |
1320 | - _("Wrote HTML-ized index to `%s' [%ld].\n"), | |
1321 | - filename, sz); | |
1322 | + _("Wrote HTML-ized index to `%s' [%s].\n"), | |
1323 | + filename, legible_off_t(sz)); | |
1324 | } | |
1325 | else | |
1326 | logprintf (LOG_NOTQUIET, | |
1327 | --- wget-1.9.1/src/headers.h.lfs 2004-09-29 18:01:40.465152544 +0200 | |
1328 | +++ wget-1.9.1/src/headers.h 2004-09-29 18:01:27.312152104 +0200 | |
1329 | @@ -43,6 +43,7 @@ | |
1330 | void *)); | |
1331 | ||
1332 | int header_extract_number PARAMS ((const char *, void *)); | |
1333 | +int header_extract_number_off_t PARAMS ((const char *, void *)); | |
1334 | int header_strdup PARAMS ((const char *, void *)); | |
1335 | int header_exists PARAMS ((const char *, void *)); | |
1336 | ||
1337 | --- wget-1.9.1/src/retr.h.lfs 2003-10-11 15:57:11.000000000 +0200 | |
1338 | +++ wget-1.9.1/src/retr.h 2004-09-29 17:54:08.576850008 +0200 | |
1339 | @@ -32,15 +32,15 @@ | |
1340 | ||
1341 | #include "rbuf.h" | |
1342 | ||
1343 | -int get_contents PARAMS ((int, FILE *, long *, long, long, struct rbuf *, | |
1344 | +int get_contents PARAMS ((int, FILE *, off_t *, off_t, off_t, struct rbuf *, | |
1345 | int, double *)); | |
1346 | ||
1347 | uerr_t retrieve_url PARAMS ((const char *, char **, char **, | |
1348 | const char *, int *)); | |
1349 | uerr_t retrieve_from_file PARAMS ((const char *, int, int *)); | |
1350 | ||
1351 | -char *retr_rate PARAMS ((long, double, int)); | |
1352 | -double calc_rate PARAMS ((long, double, int *)); | |
1353 | +char *retr_rate PARAMS ((off_t, double, int)); | |
1354 | +double calc_rate PARAMS ((off_t, double, int *)); | |
1355 | void printwhat PARAMS ((int, int)); | |
1356 | ||
1357 | void sleep_between_retrievals PARAMS ((int)); | |
1358 | --- wget-1.9.1/src/retr.c.lfs 2004-09-29 17:54:08.482864296 +0200 | |
1359 | +++ wget-1.9.1/src/retr.c 2004-09-29 17:54:08.577849856 +0200 | |
1360 | @@ -73,7 +73,7 @@ | |
1361 | ||
1362 | \f | |
1363 | static struct { | |
1364 | - long chunk_bytes; | |
1365 | + off_t chunk_bytes; | |
1366 | double chunk_start; | |
1367 | double sleep_adjust; | |
1368 | } limit_data; | |
1369 | @@ -90,7 +90,7 @@ | |
1370 | is the number of milliseconds it took to receive them. */ | |
1371 | ||
1372 | static void | |
1373 | -limit_bandwidth (long bytes, double *dltime, struct wget_timer *timer) | |
1374 | +limit_bandwidth (off_t bytes, double *dltime, struct wget_timer *timer) | |
1375 | { | |
1376 | double delta_t = *dltime - limit_data.chunk_start; | |
1377 | double expected; | |
1378 | @@ -108,12 +108,12 @@ | |
1379 | double t0, t1; | |
1380 | if (slp < 200) | |
1381 | { | |
1382 | - DEBUGP (("deferring a %.2f ms sleep (%ld/%.2f).\n", | |
1383 | - slp, limit_data.chunk_bytes, delta_t)); | |
1384 | + DEBUGP (("deferring a %.2f ms sleep (%s/%.2f).\n", | |
1385 | + slp, legible_off_t(limit_data.chunk_bytes), delta_t)); | |
1386 | return; | |
1387 | } | |
1388 | - DEBUGP (("\nsleeping %.2f ms for %ld bytes, adjust %.2f ms\n", | |
1389 | - slp, limit_data.chunk_bytes, limit_data.sleep_adjust)); | |
1390 | + DEBUGP (("\nsleeping %.2f ms for %s bytes, adjust %.2f ms\n", | |
1391 | + slp, legible_off_t(limit_data.chunk_bytes), limit_data.sleep_adjust)); | |
1392 | ||
1393 | t0 = *dltime; | |
1394 | usleep ((unsigned long) (1000 * slp)); | |
1395 | @@ -158,7 +158,7 @@ | |
1396 | rbuf_flush() before actually reading from fd. If you wish to read | |
1397 | from fd immediately, flush or discard the buffer. */ | |
1398 | int | |
1399 | -get_contents (int fd, FILE *fp, long *len, long restval, long expected, | |
1400 | +get_contents (int fd, FILE *fp, off_t *len, off_t restval, off_t expected, | |
1401 | struct rbuf *rbuf, int use_expected, double *elapsed) | |
1402 | { | |
1403 | int res = 0; | |
1404 | @@ -213,7 +213,7 @@ | |
1405 | then expected being zero means exactly that. */ | |
1406 | while (!use_expected || (*len < expected)) | |
1407 | { | |
1408 | - int amount_to_read = (use_expected | |
1409 | + off_t amount_to_read = (use_expected | |
1410 | ? MIN (expected - *len, dlbufsize) : dlbufsize); | |
1411 | #ifdef HAVE_SSL | |
1412 | if (rbuf->ssl!=NULL) | |
1413 | @@ -266,7 +266,7 @@ | |
1414 | appropriate for the speed. If PAD is non-zero, strings will be | |
1415 | padded to the width of 7 characters (xxxx.xx). */ | |
1416 | char * | |
1417 | -retr_rate (long bytes, double msecs, int pad) | |
1418 | +retr_rate (off_t bytes, double msecs, int pad) | |
1419 | { | |
1420 | static char res[20]; | |
1421 | static char *rate_names[] = {"B/s", "KB/s", "MB/s", "GB/s" }; | |
1422 | @@ -286,7 +286,7 @@ | |
1423 | UNITS is zero for B/s, one for KB/s, two for MB/s, and three for | |
1424 | GB/s. */ | |
1425 | double | |
1426 | -calc_rate (long bytes, double msecs, int *units) | |
1427 | +calc_rate (off_t bytes, double msecs, int *units) | |
1428 | { | |
1429 | double dlrate; | |
1430 |