mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Rename LARGE_INT to SUM_SIZE_INT, and simplify its handling.
This commit is contained in:
parent
b79e5bb0d3
commit
002def87d2
@ -1,3 +1,16 @@
|
|||||||
|
2005-06-25 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
|
* utils.c (with_thousand_seps_sum): Now defined only if
|
||||||
|
SUM_SIZE_INT is double.
|
||||||
|
|
||||||
|
* wget.h (SUM_SIZE_INT): Instead of bothering with long, long
|
||||||
|
long, __int64, and friends, simply either use wgint or double, end
|
||||||
|
of story. Since we know how to print either, we no longer need
|
||||||
|
LARGE_INT_FMT.
|
||||||
|
|
||||||
|
* sysdeps.h (LARGE_INT): Renamed to SUM_SIZE_INT to better reflect
|
||||||
|
its intent, and moved to wget.h.
|
||||||
|
|
||||||
2005-06-25 Hrvoje Niksic <hniksic@xemacs.org>
|
2005-06-25 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* Makefile.in: No need to clean .libs.
|
* Makefile.in: No need to clean .libs.
|
||||||
|
@ -50,7 +50,7 @@ so, delete this exception statement from your version. */
|
|||||||
#include "convert.h" /* for downloaded_file */
|
#include "convert.h" /* for downloaded_file */
|
||||||
#include "recur.h" /* for INFINITE_RECURSION */
|
#include "recur.h" /* for INFINITE_RECURSION */
|
||||||
|
|
||||||
extern LARGE_INT total_downloaded_bytes;
|
extern SUM_SIZE_INT total_downloaded_bytes;
|
||||||
|
|
||||||
/* File where the "ls -al" listing will be saved. */
|
/* File where the "ls -al" listing will be saved. */
|
||||||
#define LIST_FILENAME ".listing"
|
#define LIST_FILENAME ".listing"
|
||||||
|
@ -59,7 +59,7 @@ so, delete this exception statement from your version. */
|
|||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
|
|
||||||
extern char *version_string;
|
extern char *version_string;
|
||||||
extern LARGE_INT total_downloaded_bytes;
|
extern SUM_SIZE_INT total_downloaded_bytes;
|
||||||
|
|
||||||
extern FILE *output_stream;
|
extern FILE *output_stream;
|
||||||
extern bool output_stream_regular;
|
extern bool output_stream_regular;
|
||||||
|
12
src/init.c
12
src/init.c
@ -63,7 +63,7 @@ static bool enable_tilde_expansion;
|
|||||||
|
|
||||||
CMD_DECLARE (cmd_boolean);
|
CMD_DECLARE (cmd_boolean);
|
||||||
CMD_DECLARE (cmd_bytes);
|
CMD_DECLARE (cmd_bytes);
|
||||||
CMD_DECLARE (cmd_bytes_large);
|
CMD_DECLARE (cmd_bytes_sum);
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
CMD_DECLARE (cmd_cert_type);
|
CMD_DECLARE (cmd_cert_type);
|
||||||
#endif
|
#endif
|
||||||
@ -200,7 +200,7 @@ static struct {
|
|||||||
{ "proxypassword", &opt.proxy_passwd, cmd_string },
|
{ "proxypassword", &opt.proxy_passwd, cmd_string },
|
||||||
{ "proxyuser", &opt.proxy_user, cmd_string },
|
{ "proxyuser", &opt.proxy_user, cmd_string },
|
||||||
{ "quiet", &opt.quiet, cmd_boolean },
|
{ "quiet", &opt.quiet, cmd_boolean },
|
||||||
{ "quota", &opt.quota, cmd_bytes_large },
|
{ "quota", &opt.quota, cmd_bytes_sum },
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
{ "randomfile", &opt.random_file, cmd_file },
|
{ "randomfile", &opt.random_file, cmd_file },
|
||||||
#endif
|
#endif
|
||||||
@ -862,7 +862,7 @@ cmd_directory_vector (const char *com, const char *val, void *place)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Engine for cmd_bytes and cmd_bytes_large: converts a string such as
|
/* Engine for cmd_bytes and cmd_bytes_sum: converts a string such as
|
||||||
"100k" or "2.5G" to a floating point number. */
|
"100k" or "2.5G" to a floating point number. */
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -948,12 +948,12 @@ cmd_bytes (const char *com, const char *val, void *place)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Like cmd_bytes, but PLACE is interpreted as a pointer to
|
/* Like cmd_bytes, but PLACE is interpreted as a pointer to
|
||||||
LARGE_INT. It works by converting the string to double, therefore
|
SIZE_SUM. It works by converting the string to double, therefore
|
||||||
working with values up to 2^53-1 without loss of precision. This
|
working with values up to 2^53-1 without loss of precision. This
|
||||||
value (8192 TB) is large enough to serve for a while. */
|
value (8192 TB) is large enough to serve for a while. */
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cmd_bytes_large (const char *com, const char *val, void *place)
|
cmd_bytes_sum (const char *com, const char *val, void *place)
|
||||||
{
|
{
|
||||||
double byte_value;
|
double byte_value;
|
||||||
if (!parse_bytes_helper (val, &byte_value))
|
if (!parse_bytes_helper (val, &byte_value))
|
||||||
@ -962,7 +962,7 @@ cmd_bytes_large (const char *com, const char *val, void *place)
|
|||||||
exec_name, com, val);
|
exec_name, com, val);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*(LARGE_INT *)place = (LARGE_INT)byte_value;
|
*(SUM_SIZE_INT *) place = (SUM_SIZE_INT) byte_value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ so, delete this exception statement from your version. */
|
|||||||
|
|
||||||
struct options opt;
|
struct options opt;
|
||||||
|
|
||||||
extern LARGE_INT total_downloaded_bytes;
|
extern SUM_SIZE_INT total_downloaded_bytes;
|
||||||
extern char *version_string;
|
extern char *version_string;
|
||||||
|
|
||||||
extern struct cookie_jar *wget_cookie_jar;
|
extern struct cookie_jar *wget_cookie_jar;
|
||||||
@ -961,13 +961,14 @@ Can't timestamp and not clobber old files at the same time.\n"));
|
|||||||
{
|
{
|
||||||
logprintf (LOG_NOTQUIET,
|
logprintf (LOG_NOTQUIET,
|
||||||
_("\nFINISHED --%s--\nDownloaded: %s bytes in %d files\n"),
|
_("\nFINISHED --%s--\nDownloaded: %s bytes in %d files\n"),
|
||||||
time_str (NULL), with_thousand_seps_large (total_downloaded_bytes),
|
time_str (NULL),
|
||||||
|
with_thousand_seps_sum (total_downloaded_bytes),
|
||||||
opt.numurls);
|
opt.numurls);
|
||||||
/* Print quota warning, if exceeded. */
|
/* Print quota warning, if exceeded. */
|
||||||
if (opt.quota && total_downloaded_bytes > opt.quota)
|
if (opt.quota && total_downloaded_bytes > opt.quota)
|
||||||
logprintf (LOG_NOTQUIET,
|
logprintf (LOG_NOTQUIET,
|
||||||
_("Download quota (%s bytes) EXCEEDED!\n"),
|
_("Download quota (%s bytes) EXCEEDED!\n"),
|
||||||
with_thousand_seps_large (opt.quota));
|
with_thousand_seps_sum (opt.quota));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt.cookies_output)
|
if (opt.cookies_output)
|
||||||
|
@ -116,7 +116,7 @@ struct options
|
|||||||
|
|
||||||
wgint limit_rate; /* Limit the download rate to this
|
wgint limit_rate; /* Limit the download rate to this
|
||||||
many bps. */
|
many bps. */
|
||||||
LARGE_INT quota; /* Maximum file size to download and
|
SUM_SIZE_INT quota; /* Maximum file size to download and
|
||||||
store. */
|
store. */
|
||||||
|
|
||||||
int numurls; /* Number of successfully downloaded
|
int numurls; /* Number of successfully downloaded
|
||||||
|
@ -50,7 +50,7 @@ so, delete this exception statement from your version. */
|
|||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
|
|
||||||
extern char *version_string;
|
extern char *version_string;
|
||||||
extern LARGE_INT total_downloaded_bytes;
|
extern SUM_SIZE_INT total_downloaded_bytes;
|
||||||
|
|
||||||
extern struct hash_table *dl_url_file_map;
|
extern struct hash_table *dl_url_file_map;
|
||||||
extern struct hash_table *downloaded_html_set;
|
extern struct hash_table *downloaded_html_set;
|
||||||
|
@ -52,7 +52,7 @@ so, delete this exception statement from your version. */
|
|||||||
#include "ptimer.h"
|
#include "ptimer.h"
|
||||||
|
|
||||||
/* Total size of downloaded files. Used to enforce quota. */
|
/* Total size of downloaded files. Used to enforce quota. */
|
||||||
LARGE_INT total_downloaded_bytes;
|
SUM_SIZE_INT total_downloaded_bytes;
|
||||||
|
|
||||||
/* If non-NULL, the stream to which output should be written. This
|
/* If non-NULL, the stream to which output should be written. This
|
||||||
stream is initialized when `-O' is used. */
|
stream is initialized when `-O' is used. */
|
||||||
|
29
src/sysdep.h
29
src/sysdep.h
@ -96,35 +96,6 @@ typedef unsigned char _Bool;
|
|||||||
# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define a large integral type useful for storing large sizes that
|
|
||||||
exceed sizes of one download, such as when printing the sum of all
|
|
||||||
downloads. Note that this has nothing to do with large file
|
|
||||||
support, which determines the wgint type. This should be as large
|
|
||||||
as possible even on systems where when wgint is 32-bit; also,
|
|
||||||
unlike wgint, this can be a floating point type.
|
|
||||||
|
|
||||||
We use a 64-bit integral type where available, `double' otherwise.
|
|
||||||
It's hard to print LARGE_INT's portably, but fortunately it's
|
|
||||||
rarely needed. */
|
|
||||||
|
|
||||||
#if SIZEOF_LONG >= 8
|
|
||||||
/* Long is large enough: use it. */
|
|
||||||
typedef long LARGE_INT;
|
|
||||||
# define LARGE_INT_FMT "%ld"
|
|
||||||
#elif SIZEOF_LONG_LONG >= 8
|
|
||||||
/* Long long is large enough: use it. */
|
|
||||||
typedef long long LARGE_INT;
|
|
||||||
# define LARGE_INT_FMT "%lld"
|
|
||||||
#elif WINDOWS
|
|
||||||
/* Use __int64 under Windows. */
|
|
||||||
typedef __int64 LARGE_INT;
|
|
||||||
# define LARGE_INT_FMT "%I64"
|
|
||||||
#else
|
|
||||||
/* Large integer type unavailable; fake it with `double'. */
|
|
||||||
typedef double LARGE_INT;
|
|
||||||
# define LARGE_INT_FMT "%.0f"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* These are needed so we can #define struct_stat to struct _stati64
|
/* These are needed so we can #define struct_stat to struct _stati64
|
||||||
under Windows. */
|
under Windows. */
|
||||||
#ifndef struct_stat
|
#ifndef struct_stat
|
||||||
|
29
src/utils.c
29
src/utils.c
@ -1162,7 +1162,7 @@ free_keys_and_values (struct hash_table *ht)
|
|||||||
|
|
||||||
|
|
||||||
/* Add thousand separators to a number already in string form. Used
|
/* Add thousand separators to a number already in string form. Used
|
||||||
by with_thousand_seps and with_thousand_seps_large. */
|
by with_thousand_seps and with_thousand_seps_sum. */
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
add_thousand_seps (const char *repr)
|
add_thousand_seps (const char *repr)
|
||||||
@ -1213,30 +1213,19 @@ with_thousand_seps (wgint l)
|
|||||||
return add_thousand_seps (inbuf);
|
return add_thousand_seps (inbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write a string representation of LARGE_INT NUMBER into the provided
|
/* When SUM_SIZE_INT is wgint, with_thousand_seps_large is #defined to
|
||||||
buffer.
|
with_thousand_seps. The function below is used on non-LFS systems
|
||||||
|
where SUM_SIZE_INT typedeffed to double. */
|
||||||
It would be dangerous to use sprintf, because the code wouldn't
|
|
||||||
work on a machine with gcc-provided long long support, but without
|
|
||||||
libc support for "%lld". However, such old systems platforms
|
|
||||||
typically lack snprintf and will end up using our version, which
|
|
||||||
does support "%lld" whereever long longs are available. */
|
|
||||||
|
|
||||||
static void
|
|
||||||
large_int_to_string (char *buffer, int bufsize, LARGE_INT number)
|
|
||||||
{
|
|
||||||
snprintf (buffer, bufsize, LARGE_INT_FMT, number);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The same as with_thousand_seps, but works on LARGE_INT. */
|
|
||||||
|
|
||||||
|
#ifndef with_thousand_seps_sum
|
||||||
char *
|
char *
|
||||||
with_thousand_seps_large (LARGE_INT l)
|
with_thousand_seps_sum (SUM_SIZE_INT l)
|
||||||
{
|
{
|
||||||
char inbuf[48];
|
char inbuf[64];
|
||||||
large_int_to_string (inbuf, sizeof (inbuf), l);
|
snprintf (inbuf, sizeof (inbuf), "%.0f", l);
|
||||||
return add_thousand_seps (inbuf);
|
return add_thousand_seps (inbuf);
|
||||||
}
|
}
|
||||||
|
#endif /* not with_thousand_seps_sum */
|
||||||
|
|
||||||
/* N, a byte quantity, is converted to a human-readable abberviated
|
/* N, a byte quantity, is converted to a human-readable abberviated
|
||||||
form a la sizes printed by `ls -lh'. The result is written to a
|
form a la sizes printed by `ls -lh'. The result is written to a
|
||||||
|
@ -95,7 +95,9 @@ void string_set_free (struct hash_table *);
|
|||||||
void free_keys_and_values (struct hash_table *);
|
void free_keys_and_values (struct hash_table *);
|
||||||
|
|
||||||
char *with_thousand_seps (wgint);
|
char *with_thousand_seps (wgint);
|
||||||
char *with_thousand_seps_large (LARGE_INT);
|
#ifndef with_thousand_seps_sum
|
||||||
|
char *with_thousand_seps_sum (SUM_SIZE_INT);
|
||||||
|
#endif
|
||||||
char *human_readable (wgint);
|
char *human_readable (wgint);
|
||||||
int numdigit (wgint);
|
int numdigit (wgint);
|
||||||
char *number_to_string (char *, wgint);
|
char *number_to_string (char *, wgint);
|
||||||
|
19
src/wget.h
19
src/wget.h
@ -129,6 +129,25 @@ typedef off_t wgint;
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Now define a large integral type useful for storing sizes of *sums*
|
||||||
|
of downloads, such as the value of the --quota option. This should
|
||||||
|
be a type able to hold 2G+ values even on systems without large
|
||||||
|
file support. (It is useful to limit Wget's download quota to say
|
||||||
|
10G even if a single file cannot be that large.)
|
||||||
|
|
||||||
|
To make sure we get the largest size possible, we use `double' on
|
||||||
|
systems without a 64-bit integral type. (Since it is used in very
|
||||||
|
few places in Wget, this is acceptable.) */
|
||||||
|
|
||||||
|
#if SIZEOF_WGINT >= 8
|
||||||
|
/* just use wgint, which we already know how to print */
|
||||||
|
typedef wgint SUM_SIZE_INT;
|
||||||
|
# define with_thousand_seps_sum with_thousand_seps
|
||||||
|
#else
|
||||||
|
/* On systems without LFS, use double, which buys us integers up to 2^53. */
|
||||||
|
typedef double SUM_SIZE_INT;
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
/* Everything uses this, so include them here directly. */
|
/* Everything uses this, so include them here directly. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user