Fixed large files on 32 bit systems; fixed warnings
This commit is contained in:
parent
d1dbaeb55b
commit
e5d57be8ad
14
src/main.c
14
src/main.c
|
@ -124,7 +124,7 @@ int parse_range(const char *range, off_t total_len, struct RequestRange *result)
|
|||
char *numstr;
|
||||
char *dashptr;
|
||||
int dashpos;
|
||||
off_t num;
|
||||
long long num;
|
||||
|
||||
LOG(LVL_DEBUG, "Requested Range is %s", range);
|
||||
|
||||
|
@ -155,7 +155,7 @@ int parse_range(const char *range, off_t total_len, struct RequestRange *result)
|
|||
if(dashpos == 0) {
|
||||
// example: bytes=-500
|
||||
// -> letzte 500 bytes ausgeben
|
||||
if(sscanf(dashptr+1, "%li", &num) != 1) {
|
||||
if(sscanf(dashptr+1, "%lli", &num) != 1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ int parse_range(const char *range, off_t total_len, struct RequestRange *result)
|
|||
// examples: bytes=100-200; bytes=300-
|
||||
|
||||
// parse the first number
|
||||
if(sscanf(numstr, "%li", &num) != 1) {
|
||||
if(sscanf(numstr, "%lli", &num) != 1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ int parse_range(const char *range, off_t total_len, struct RequestRange *result)
|
|||
}
|
||||
|
||||
// a complete range was given -> parse the second number
|
||||
if(sscanf(numstr+dashpos+1, "%li", &num) != 1) {
|
||||
if(sscanf(numstr+dashpos+1, "%lli", &num) != 1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,11 @@ int serv_regular_file(struct MHD_Connection *connection, struct ConnectionState
|
|||
range.start);
|
||||
|
||||
// build content range header
|
||||
sprintf(buf, "bytes %li-%li/%li", range.start, range.start+range.length-1, connstate->targetStat.st_size);
|
||||
sprintf(buf, "bytes %lli-%lli/%lli",
|
||||
(long long)range.start,
|
||||
(long long)range.start+range.length-1,
|
||||
(long long)connstate->targetStat.st_size);
|
||||
|
||||
MHD_add_response_header(response, MHD_HTTP_HEADER_CONTENT_RANGE, buf);
|
||||
|
||||
LOG(LVL_DUMP, "Content-Range: %s", buf);
|
||||
|
|
Loading…
Reference in a new issue