mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Use long long in place of long in conv.c to allow show size of files bigger
than 2GiB in the download dialog. Also let regetting big files. Previously the Content-Length variable in http.c was int, what is not enough. Now it is long long.
This commit is contained in:
parent
9574b38abe
commit
f60d85c4c1
@ -1848,10 +1848,10 @@ again:
|
|||||||
d = parse_header(conn->cached->head, "Content-Length", NULL);
|
d = parse_header(conn->cached->head, "Content-Length", NULL);
|
||||||
if (d) {
|
if (d) {
|
||||||
unsigned char *ep;
|
unsigned char *ep;
|
||||||
int l;
|
long long l;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
l = strtol(d, (char **) &ep, 10);
|
l = strtoll(d, (char **) &ep, 10);
|
||||||
|
|
||||||
if (!errno && !*ep && l >= 0) {
|
if (!errno && !*ep && l >= 0) {
|
||||||
if (!http->close || POST_HTTP_1_0(version))
|
if (!http->close || POST_HTTP_1_0(version))
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
* if it had to be truncated. A negative value signs an error. */
|
* if it had to be truncated. A negative value signs an error. */
|
||||||
NONSTATIC_INLINE int
|
NONSTATIC_INLINE int
|
||||||
elinks_ulongcat(unsigned char *s, unsigned int *slen,
|
elinks_ulongcat(unsigned char *s, unsigned int *slen,
|
||||||
unsigned long number, unsigned int width,
|
unsigned long long number, unsigned int width,
|
||||||
unsigned char fillchar, unsigned int base,
|
unsigned char fillchar, unsigned int base,
|
||||||
unsigned int upper)
|
unsigned int upper)
|
||||||
{
|
{
|
||||||
@ -62,7 +62,7 @@ elinks_ulongcat(unsigned char *s, unsigned int *slen,
|
|||||||
unsigned int start = slen ? *slen : 0;
|
unsigned int start = slen ? *slen : 0;
|
||||||
unsigned int nlen = 1; /* '0' is one char, we can't have less. */
|
unsigned int nlen = 1; /* '0' is one char, we can't have less. */
|
||||||
unsigned int pos = start; /* starting position of the number */
|
unsigned int pos = start; /* starting position of the number */
|
||||||
unsigned long q = number;
|
unsigned long long q = number;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (width < 1 || !s || base < 2 || base > 16) return -1;
|
if (width < 1 || !s || base < 2 || base > 16) return -1;
|
||||||
@ -110,7 +110,7 @@ elinks_ulongcat(unsigned char *s, unsigned int *slen,
|
|||||||
/** Similar to elinks_ulongcat() but for @c long number. */
|
/** Similar to elinks_ulongcat() but for @c long number. */
|
||||||
NONSTATIC_INLINE int
|
NONSTATIC_INLINE int
|
||||||
elinks_longcat(unsigned char *s, unsigned int *slen,
|
elinks_longcat(unsigned char *s, unsigned int *slen,
|
||||||
long number, unsigned int width,
|
long long number, unsigned int width,
|
||||||
unsigned char fillchar, unsigned int base,
|
unsigned char fillchar, unsigned int base,
|
||||||
unsigned int upper)
|
unsigned int upper)
|
||||||
{
|
{
|
||||||
@ -129,9 +129,9 @@ elinks_longcat(unsigned char *s, unsigned int *slen,
|
|||||||
|
|
||||||
/** @relates string */
|
/** @relates string */
|
||||||
struct string *
|
struct string *
|
||||||
add_long_to_string(struct string *string, long number)
|
add_long_to_string(struct string *string, long long number)
|
||||||
{
|
{
|
||||||
unsigned char buffer[32];
|
unsigned char buffer[64];
|
||||||
int length = 0;
|
int length = 0;
|
||||||
int width;
|
int width;
|
||||||
|
|
||||||
@ -146,10 +146,10 @@ add_long_to_string(struct string *string, long number)
|
|||||||
|
|
||||||
/** @relates string */
|
/** @relates string */
|
||||||
struct string *
|
struct string *
|
||||||
add_knum_to_string(struct string *string, long num)
|
add_knum_to_string(struct string *string, long long num)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
unsigned char t[32];
|
unsigned char t[64];
|
||||||
int tlen = 0;
|
int tlen = 0;
|
||||||
|
|
||||||
if (num && (num / (1024 * 1024)) * (1024 * 1024) == num) {
|
if (num && (num / (1024 * 1024)) * (1024 * 1024) == num) {
|
||||||
@ -173,7 +173,7 @@ add_knum_to_string(struct string *string, long num)
|
|||||||
|
|
||||||
/** @relates string */
|
/** @relates string */
|
||||||
struct string *
|
struct string *
|
||||||
add_xnum_to_string(struct string *string, off_t xnum)
|
add_xnum_to_string(struct string *string, long long xnum)
|
||||||
{
|
{
|
||||||
unsigned char suff[3] = "\0i";
|
unsigned char suff[3] = "\0i";
|
||||||
off_t d = -1;
|
off_t d = -1;
|
||||||
@ -191,7 +191,6 @@ add_xnum_to_string(struct string *string, off_t xnum)
|
|||||||
xnum /= 1024;
|
xnum /= 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(xnum == (long) xnum);
|
|
||||||
add_long_to_string(string, xnum);
|
add_long_to_string(string, xnum);
|
||||||
|
|
||||||
if (xnum < 10 && d != -1) {
|
if (xnum < 10 && d != -1) {
|
||||||
@ -291,7 +290,7 @@ add_html_to_string(struct string *string, const unsigned char *src, int len)
|
|||||||
int rollback_length = string->length;
|
int rollback_length = string->length;
|
||||||
|
|
||||||
if (!add_bytes_to_string(string, "&#", 2)
|
if (!add_bytes_to_string(string, "&#", 2)
|
||||||
|| !add_long_to_string(string, (long) *src)
|
|| !add_long_to_string(string, (long long)*src)
|
||||||
|| !add_char_to_string(string, ';')) {
|
|| !add_char_to_string(string, ';')) {
|
||||||
string->length = rollback_length;
|
string->length = rollback_length;
|
||||||
string->source[rollback_length] = '\0';
|
string->source[rollback_length] = '\0';
|
||||||
|
@ -44,9 +44,9 @@ unhx(register unsigned char a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* These use granular allocation stuff. */
|
/* These use granular allocation stuff. */
|
||||||
struct string *add_long_to_string(struct string *string, long number);
|
struct string *add_long_to_string(struct string *string, long long number);
|
||||||
struct string *add_knum_to_string(struct string *string, long number);
|
struct string *add_knum_to_string(struct string *string, long long number);
|
||||||
struct string *add_xnum_to_string(struct string *string, off_t number);
|
struct string *add_xnum_to_string(struct string *string, long long number);
|
||||||
struct string *add_duration_to_string(struct string *string, long seconds);
|
struct string *add_duration_to_string(struct string *string, long seconds);
|
||||||
struct string *add_timeval_to_string(struct string *string, timeval_T *timeval);
|
struct string *add_timeval_to_string(struct string *string, timeval_T *timeval);
|
||||||
|
|
||||||
@ -118,11 +118,11 @@ struct string *add_shell_safe_to_string(struct string *string, unsigned char *cm
|
|||||||
|
|
||||||
/* These are fast functions to convert integers to string, or to hexadecimal string. */
|
/* These are fast functions to convert integers to string, or to hexadecimal string. */
|
||||||
|
|
||||||
int elinks_ulongcat(unsigned char *s, unsigned int *slen, unsigned long number,
|
int elinks_ulongcat(unsigned char *s, unsigned int *slen, unsigned long long number,
|
||||||
unsigned int width, unsigned char fillchar, unsigned int base,
|
unsigned int width, unsigned char fillchar, unsigned int base,
|
||||||
unsigned int upper);
|
unsigned int upper);
|
||||||
|
|
||||||
int elinks_longcat(unsigned char *s, unsigned int *slen, long number,
|
int elinks_longcat(unsigned char *s, unsigned int *slen, long long number,
|
||||||
unsigned int width, unsigned char fillchar, unsigned int base,
|
unsigned int width, unsigned char fillchar, unsigned int base,
|
||||||
unsigned int upper);
|
unsigned int upper);
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ int elinks_longcat(unsigned char *s, unsigned int *slen, long number,
|
|||||||
#define ulongcat(s, slen, number, width, fillchar) \
|
#define ulongcat(s, slen, number, width, fillchar) \
|
||||||
elinks_ulongcat((unsigned char *) (s), \
|
elinks_ulongcat((unsigned char *) (s), \
|
||||||
(unsigned int *) (slen), \
|
(unsigned int *) (slen), \
|
||||||
(unsigned long) (number), \
|
(unsigned long long) (number), \
|
||||||
(unsigned int) (width), \
|
(unsigned int) (width), \
|
||||||
(unsigned char) (fillchar), \
|
(unsigned char) (fillchar), \
|
||||||
(unsigned int) 10, \
|
(unsigned int) 10, \
|
||||||
@ -141,7 +141,7 @@ int elinks_longcat(unsigned char *s, unsigned int *slen, long number,
|
|||||||
#define longcat(s, slen, number, width, fillchar) \
|
#define longcat(s, slen, number, width, fillchar) \
|
||||||
elinks_longcat((unsigned char *) (s), \
|
elinks_longcat((unsigned char *) (s), \
|
||||||
(unsigned int *) (slen), \
|
(unsigned int *) (slen), \
|
||||||
(long) (number), \
|
(long long) (number), \
|
||||||
(unsigned int) (width), \
|
(unsigned int) (width), \
|
||||||
(unsigned char) (fillchar), \
|
(unsigned char) (fillchar), \
|
||||||
(unsigned int) 10, \
|
(unsigned int) 10, \
|
||||||
@ -151,7 +151,7 @@ int elinks_longcat(unsigned char *s, unsigned int *slen, long number,
|
|||||||
#define ulonghexcat(s, slen, number, width, fillchar, upper) \
|
#define ulonghexcat(s, slen, number, width, fillchar, upper) \
|
||||||
elinks_ulongcat((unsigned char *) (s), \
|
elinks_ulongcat((unsigned char *) (s), \
|
||||||
(unsigned int *) (slen), \
|
(unsigned int *) (slen), \
|
||||||
(unsigned long) (number), \
|
(unsigned long long) (number), \
|
||||||
(unsigned int) (width), \
|
(unsigned int) (width), \
|
||||||
(unsigned char) (fillchar), \
|
(unsigned char) (fillchar), \
|
||||||
(unsigned int) 16, \
|
(unsigned int) 16, \
|
||||||
|
Loading…
Reference in New Issue
Block a user