1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

use curl_off_t instead of off_t!

This commit is contained in:
Daniel Stenberg 2004-01-22 12:45:50 +00:00
parent 6cd0a90b52
commit b791e158f0
13 changed files with 67 additions and 81 deletions

View File

@ -69,7 +69,7 @@
#define SELECT_TYPE_ARG1 int #define SELECT_TYPE_ARG1 int
#define SELECT_TYPE_ARG234 (fd_set *) #define SELECT_TYPE_ARG234 (fd_set *)
#define SELECT_TYPE_ARG5 (struct timeval *) #define SELECT_TYPE_ARG5 (struct timeval *)
#define SIZEOF_OFF_T 4 #define SIZEOF_CURL_OFF_T 4
#define STDC_HEADERS 1 #define STDC_HEADERS 1
#define TIME_WITH_SYS_TIME 1 #define TIME_WITH_SYS_TIME 1

View File

@ -92,7 +92,7 @@ CURLcode Curl_dict(struct connectdata *conn)
int sockfd = conn->sock[FIRSTSOCKET]; int sockfd = conn->sock[FIRSTSOCKET];
char *path = conn->path; char *path = conn->path;
off_t *bytecount = &conn->bytecount; curl_off_t *bytecount = &conn->bytecount;
if(conn->bits.user_passwd) { if(conn->bits.user_passwd) {
/* AUTH is missing */ /* AUTH is missing */

View File

@ -211,7 +211,7 @@ CURLcode curl_easy_setopt(CURL *curl, CURLoption tag, ...)
func_T param_func = (func_T)0; func_T param_func = (func_T)0;
long param_long = 0; long param_long = 0;
void *param_obj = NULL; void *param_obj = NULL;
off_t param_offset = 0; curl_off_t param_offset = 0;
struct SessionHandle *data = curl; struct SessionHandle *data = curl;
CURLcode ret=CURLE_FAILED_INIT; CURLcode ret=CURLE_FAILED_INIT;
@ -239,8 +239,8 @@ CURLcode curl_easy_setopt(CURL *curl, CURLoption tag, ...)
param_func = va_arg(arg, func_T ); param_func = va_arg(arg, func_T );
ret = Curl_setopt(data, tag, param_func); ret = Curl_setopt(data, tag, param_func);
} else { } else {
/* This is an off_t type */ /* This is a curl_off_t type */
param_offset = va_arg(arg, off_t); param_offset = va_arg(arg, curl_off_t);
ret = Curl_setopt(data, tag, param_offset); ret = Curl_setopt(data, tag, param_offset);
} }

View File

@ -163,12 +163,12 @@ CURLcode Curl_file(struct connectdata *conn)
*/ */
CURLcode res = CURLE_OK; CURLcode res = CURLE_OK;
struct stat statbuf; struct stat statbuf;
off_t expected_size=0; curl_off_t expected_size=0;
bool fstated=FALSE; bool fstated=FALSE;
ssize_t nread; ssize_t nread;
struct SessionHandle *data = conn->data; struct SessionHandle *data = conn->data;
char *buf = data->state.buffer; char *buf = data->state.buffer;
off_t bytecount = 0; curl_off_t bytecount = 0;
struct timeval start = Curl_tvnow(); struct timeval start = Curl_tvnow();
struct timeval now = start; struct timeval now = start;
int fd; int fd;

View File

@ -921,7 +921,7 @@ static CURLcode ftp_transfertype(struct connectdata *conn,
static static
CURLcode ftp_getsize(struct connectdata *conn, char *file, CURLcode ftp_getsize(struct connectdata *conn, char *file,
off_t *size) curl_off_t *size)
{ {
struct SessionHandle *data = conn->data; struct SessionHandle *data = conn->data;
int ftpcode; int ftpcode;
@ -1660,7 +1660,7 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
/* the ftp struct is already inited in Curl_ftp_connect() */ /* the ftp struct is already inited in Curl_ftp_connect() */
struct FTP *ftp = conn->proto.ftp; struct FTP *ftp = conn->proto.ftp;
off_t *bytecountp = ftp->bytecountp; curl_off_t *bytecountp = ftp->bytecountp;
if(data->set.upload) { if(data->set.upload) {
@ -1692,7 +1692,7 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
if(conn->resume_from < 0 ) { if(conn->resume_from < 0 ) {
/* we could've got a specified offset from the command line, /* we could've got a specified offset from the command line,
but now we know we didn't */ but now we know we didn't */
off_t gottensize; curl_off_t gottensize;
if(CURLE_OK != ftp_getsize(conn, ftp->file, &gottensize)) { if(CURLE_OK != ftp_getsize(conn, ftp->file, &gottensize)) {
failf(data, "Couldn't get remote file size"); failf(data, "Couldn't get remote file size");
@ -1703,7 +1703,7 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
if(conn->resume_from) { if(conn->resume_from) {
/* do we still game? */ /* do we still game? */
off_t passed=0; curl_off_t passed=0;
/* enable append instead */ /* enable append instead */
data->set.ftp_append = 1; data->set.ftp_append = 1;
@ -1711,8 +1711,8 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
input. If we knew it was a proper file we could've just input. If we knew it was a proper file we could've just
fseek()ed but we only have a stream here */ fseek()ed but we only have a stream here */
do { do {
off_t readthisamountnow = (conn->resume_from - passed); curl_off_t readthisamountnow = (conn->resume_from - passed);
off_t actuallyread; curl_off_t actuallyread;
if(readthisamountnow > BUFSIZE) if(readthisamountnow > BUFSIZE)
readthisamountnow = BUFSIZE; readthisamountnow = BUFSIZE;
@ -1802,11 +1802,11 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
else if(!data->set.no_body) { else if(!data->set.no_body) {
/* Retrieve file or directory */ /* Retrieve file or directory */
bool dirlist=FALSE; bool dirlist=FALSE;
off_t downloadsize=-1; curl_off_t downloadsize=-1;
if(conn->bits.use_range && conn->range) { if(conn->bits.use_range && conn->range) {
off_t from, to; curl_off_t from, to;
off_t totalsize=-1; curl_off_t totalsize=-1;
char *ptr; char *ptr;
char *ptr2; char *ptr2;
@ -1863,7 +1863,7 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
(data->set.ftp_list_only?"NLST":"LIST")); (data->set.ftp_list_only?"NLST":"LIST"));
} }
else { else {
off_t foundsize; curl_off_t foundsize;
/* Set type to binary (unless specified ASCII) */ /* Set type to binary (unless specified ASCII) */
result = ftp_transfertype(conn, data->set.ftp_ascii); result = ftp_transfertype(conn, data->set.ftp_ascii);
@ -1986,7 +1986,7 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
E: E:
125 Data connection already open; Transfer starting. */ 125 Data connection already open; Transfer starting. */
off_t size=-1; /* default unknown size */ curl_off_t size=-1; /* default unknown size */
/* /*
@ -2170,7 +2170,7 @@ CURLcode ftp_perform(struct connectdata *conn,
/* The SIZE command is _not_ RFC 959 specified, and therefor many servers /* The SIZE command is _not_ RFC 959 specified, and therefor many servers
may not support it! It is however the only way we have to get a file's may not support it! It is however the only way we have to get a file's
size! */ size! */
off_t filesize; curl_off_t filesize;
ssize_t nread; ssize_t nread;
int ftpcode; int ftpcode;

View File

@ -1245,14 +1245,14 @@ CURLcode Curl_http(struct connectdata *conn)
if(conn->resume_from) { if(conn->resume_from) {
/* do we still game? */ /* do we still game? */
off_t passed=0; curl_off_t passed=0;
/* Now, let's read off the proper amount of bytes from the /* Now, let's read off the proper amount of bytes from the
input. If we knew it was a proper file we could've just input. If we knew it was a proper file we could've just
fseek()ed but we only have a stream here */ fseek()ed but we only have a stream here */
do { do {
off_t readthisamountnow = (conn->resume_from - passed); curl_off_t readthisamountnow = (conn->resume_from - passed);
off_t actuallyread; curl_off_t actuallyread;
if(readthisamountnow > BUFSIZE) if(readthisamountnow > BUFSIZE)
readthisamountnow = BUFSIZE; readthisamountnow = BUFSIZE;
@ -1299,7 +1299,8 @@ CURLcode Curl_http(struct connectdata *conn)
if(conn->resume_from) { if(conn->resume_from) {
/* This is because "resume" was selected */ /* This is because "resume" was selected */
off_t total_expected_size= conn->resume_from + data->set.infilesize; curl_off_t total_expected_size=
conn->resume_from + data->set.infilesize;
conn->allocptr.rangeline = conn->allocptr.rangeline =
aprintf("Content-Range: bytes %s%Od/%Od\r\n", aprintf("Content-Range: bytes %s%Od/%Od\r\n",
conn->range, total_expected_size-1, conn->range, total_expected_size-1,

View File

@ -38,6 +38,8 @@
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include <curl/curl.h> /* for the curl_off_t type */
#ifndef SIZEOF_LONG_DOUBLE #ifndef SIZEOF_LONG_DOUBLE
#define SIZEOF_LONG_DOUBLE 0 #define SIZEOF_LONG_DOUBLE 0
#endif #endif
@ -377,9 +379,10 @@ static int dprintf_Pass1(char *format, va_stack_t *vto, char **endpos, va_list a
flags |= FLAGS_LONG; flags |= FLAGS_LONG;
break; break;
case 'O': case 'O':
if (sizeof(off_t) > sizeof(unsigned long int)) { if (sizeof(curl_off_t) > sizeof(unsigned long int)) {
flags |= FLAGS_LONGLONG; flags |= FLAGS_LONGLONG;
} else if (sizeof(off_t) > sizeof(unsigned int)) { }
else if (sizeof(curl_off_t) > sizeof(unsigned int)) {
flags |= FLAGS_LONG; flags |= FLAGS_LONG;
} }
break; break;

View File

@ -244,21 +244,4 @@ typedef struct hostent Curl_addrinfo;
typedef struct in_addr Curl_ipconnect; typedef struct in_addr Curl_ipconnect;
#endif #endif
#if 0
#if (SIZEOF_OFF_T > 4)
/* off_t is bigger than 4 bytes, and that makes it our prefered variable
type for filesizes */
typedef off_t filesize_t;
#else
#ifdef HAVE_LONGLONG
/* we have long long, use this for filesizes internally */
typedef long long filesize_t;
#else
/* small off_t and no long long, no support for large files :-( */
typedef long filesize_t;
#endif /* didn't have long long */
#endif /* sizeof wasn't bigger than 4 */
#endif /* 0 */
#endif /* __CONFIG_H */ #endif /* __CONFIG_H */

View File

@ -27,14 +27,13 @@
#include "setup.h" #include "setup.h"
#include <stddef.h> #include <stddef.h>
/* Determine what type of file offset conversion handling we wish /* Determine what type of file offset conversion handling we wish to use. For
* to use. For systems with a 32-bit off_t type, we should use * systems with a 32-bit curl_off_t type, we should use strtol. For systems
* strtol. For systems with a 64-bit off_t type, we should use * with a 64-bit curl_off_t type, we should use strtoll if it exists, and if
* strtoll if it exists, and if not, should try to emulate its * not, should try to emulate its functionality. At any rate, we define
* functionality. At any rate, we define 'strtoofft' such that it * 'strtoofft' such that it can be used to work with curl_off_t's regardless.
* can be used to work with off_t's regardless.
*/ */
#if SIZEOF_OFF_T > 4 #if SIZEOF_CURL_OFF_T > 4
#if HAVE_STRTOLL #if HAVE_STRTOLL
#define strtoofft strtoll #define strtoofft strtoll
#else #else

View File

@ -1955,14 +1955,14 @@ CURLcode Curl_perform(struct SessionHandle *data)
CURLcode CURLcode
Curl_Transfer(struct connectdata *c_conn, /* connection data */ Curl_Transfer(struct connectdata *c_conn, /* connection data */
int sockindex, /* socket index to read from or -1 */ int sockindex, /* socket index to read from or -1 */
off_t size, /* -1 if unknown at this point */ curl_off_t size, /* -1 if unknown at this point */
bool getheader, /* TRUE if header parsing is wanted */ bool getheader, /* TRUE if header parsing is wanted */
off_t *bytecountp, /* return number of bytes read or NULL */ curl_off_t *bytecountp, /* return number of bytes read or NULL */
int writesockindex, /* socket index to write to, it may very int writesockindex, /* socket index to write to, it may very
well be the same we read from. -1 well be the same we read from. -1
disables */ disables */
off_t *writebytecountp /* return number of bytes written or curl_off_t *writecountp /* return number of bytes written or
NULL */ NULL */
) )
{ {
@ -1978,7 +1978,7 @@ Curl_Transfer(struct connectdata *c_conn, /* connection data */
conn->bits.getheader = getheader; conn->bits.getheader = getheader;
conn->bytecountp = bytecountp; conn->bytecountp = bytecountp;
conn->writesockfd = writesockindex==-1?-1:conn->sock[writesockindex]; conn->writesockfd = writesockindex==-1?-1:conn->sock[writesockindex];
conn->writebytecountp = writebytecountp; conn->writebytecountp = writecountp;
return CURLE_OK; return CURLE_OK;

View File

@ -38,11 +38,11 @@ CURLcode Curl_readwrite_init(struct connectdata *conn);
CURLcode CURLcode
Curl_Transfer (struct connectdata *data, Curl_Transfer (struct connectdata *data,
int sockfd, /* socket to read from or -1 */ int sockfd, /* socket to read from or -1 */
off_t size, /* -1 if unknown at this point */ curl_off_t size, /* -1 if unknown at this point */
bool getheader, /* TRUE if header parsing is wanted */ bool getheader, /* TRUE if header parsing is wanted */
off_t *bytecountp, /* return number of bytes read */ curl_off_t *bytecountp, /* return number of bytes read */
int writesockfd, /* socket to write to, it may very well be int writesockfd, /* socket to write to, it may very well be
the same we read from. -1 disables */ the same we read from. -1 disables */
off_t *writebytecountp /* return number of bytes written */ curl_off_t *writecountp /* return number of bytes written */
); );
#endif #endif

View File

@ -716,7 +716,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
* If known, this should inform curl about the file size of the * If known, this should inform curl about the file size of the
* to-be-uploaded file. * to-be-uploaded file.
*/ */
data->set.infilesize = va_arg(param, off_t); data->set.infilesize = va_arg(param, curl_off_t);
break; break;
case CURLOPT_LOW_SPEED_LIMIT: case CURLOPT_LOW_SPEED_LIMIT:
/* /*
@ -966,7 +966,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
/* /*
* Resume transfer at the give file position * Resume transfer at the give file position
*/ */
data->set.set_resume_from = va_arg(param, off_t); data->set.set_resume_from = va_arg(param, curl_off_t);
break; break;
case CURLOPT_DEBUGFUNCTION: case CURLOPT_DEBUGFUNCTION:
/* /*
@ -1279,7 +1279,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
/* /*
* Set the maximum size of a file to download. * Set the maximum size of a file to download.
*/ */
data->set.max_filesize = va_arg(param, off_t); data->set.max_filesize = va_arg(param, curl_off_t);
break; break;
default: default:

View File

@ -77,16 +77,16 @@
#include "timeval.h" #include "timeval.h"
#ifdef HAVE_ZLIB_H
#include <zlib.h> /* for content-encoding */
#endif
#include <curl/curl.h> #include <curl/curl.h>
#include "http_chunks.h" /* for the structs and enum stuff */ #include "http_chunks.h" /* for the structs and enum stuff */
#include "hostip.h" #include "hostip.h"
#include "hash.h" #include "hash.h"
#ifdef HAVE_ZLIB_H
#include <zlib.h> /* for content-encoding */
#endif
#ifdef HAVE_GSSAPI #ifdef HAVE_GSSAPI
#ifdef HAVE_GSSMIT #ifdef HAVE_GSSMIT
#include <gssapi/gssapi.h> #include <gssapi/gssapi.h>
@ -211,8 +211,8 @@ struct HTTP {
const char *p_pragma; /* Pragma: string */ const char *p_pragma; /* Pragma: string */
const char *p_accept; /* Accept: string */ const char *p_accept; /* Accept: string */
off_t readbytecount; curl_off_t readbytecount;
off_t writebytecount; curl_off_t writebytecount;
/* For FORM posting */ /* For FORM posting */
struct Form form; struct Form form;
@ -240,7 +240,7 @@ struct HTTP {
* FTP unique setup * FTP unique setup
***************************************************************************/ ***************************************************************************/
struct FTP { struct FTP {
off_t *bytecountp; curl_off_t *bytecountp;
char *user; /* user name string */ char *user; /* user name string */
char *passwd; /* password string */ char *passwd; /* password string */
char *urlpath; /* the originally given path part of the URL */ char *urlpath; /* the originally given path part of the URL */
@ -250,7 +250,7 @@ struct FTP {
char *entrypath; /* the PWD reply when we logged on */ char *entrypath; /* the PWD reply when we logged on */
char *cache; /* data cache between getresponse()-calls */ char *cache; /* data cache between getresponse()-calls */
off_t cache_size; /* size of cache in bytes */ curl_off_t cache_size; /* size of cache in bytes */
bool dont_check; /* Set to TRUE to prevent the final (post-transfer) bool dont_check; /* Set to TRUE to prevent the final (post-transfer)
file size and 226/250 status check. It should still file size and 226/250 status check. It should still
read the line, just ignore the result. */ read the line, just ignore the result. */
@ -305,7 +305,7 @@ struct ConnectBits {
*/ */
struct Curl_transfer_keeper { struct Curl_transfer_keeper {
off_t bytecount; /* total number of bytes read */ curl_off_t bytecount; /* total number of bytes read */
int writebytecount; /* number of bytes written */ int writebytecount; /* number of bytes written */
struct timeval start; /* transfer started at this time */ struct timeval start; /* transfer started at this time */
struct timeval now; /* current time */ struct timeval now; /* current time */
@ -326,7 +326,7 @@ struct Curl_transfer_keeper {
char *end_ptr; /* within buf */ char *end_ptr; /* within buf */
char *p; /* within headerbuff */ char *p; /* within headerbuff */
bool content_range; /* set TRUE if Content-Range: was found */ bool content_range; /* set TRUE if Content-Range: was found */
off_t offset; /* possible resume offset read from the curl_off_t offset; /* possible resume offset read from the
Content-Range: header */ Content-Range: header */
int httpcode; /* error code from the 'HTTP/1.? XXX' line */ int httpcode; /* error code from the 'HTTP/1.? XXX' line */
int httpversion; /* the HTTP version*10 */ int httpversion; /* the HTTP version*10 */
@ -428,12 +428,12 @@ struct connectdata {
unsigned short remote_port; /* what remote port to connect to, unsigned short remote_port; /* what remote port to connect to,
not the proxy port! */ not the proxy port! */
char *ppath; char *ppath;
off_t bytecount; curl_off_t bytecount;
long headerbytecount; /* only count received headers */ long headerbytecount; /* only count received headers */
char *range; /* range, if used. See README for detailed specification on char *range; /* range, if used. See README for detailed specification on
this syntax. */ this syntax. */
off_t resume_from; /* continue [ftp] transfer from here */ curl_off_t resume_from; /* continue [ftp] transfer from here */
char *proxyhost; /* name of the http proxy host */ char *proxyhost; /* name of the http proxy host */
@ -447,7 +447,7 @@ struct connectdata {
struct timeval created; /* creation time */ struct timeval created; /* creation time */
int sock[2]; /* two sockets, the second is used for the data transfer int sock[2]; /* two sockets, the second is used for the data transfer
when doing FTP */ when doing FTP */
off_t maxdownload; /* in bytes, the maximum amount of data to fetch, 0 curl_off_t maxdownload; /* in bytes, the maximum amount of data to fetch, 0
means unlimited */ means unlimited */
struct ssl_connect_data ssl[2]; /* this is for ssl-stuff */ struct ssl_connect_data ssl[2]; /* this is for ssl-stuff */
@ -484,14 +484,14 @@ struct connectdata {
/**** curl_get() phase fields */ /**** curl_get() phase fields */
/* READ stuff */ /* READ stuff */
int sockfd; /* socket to read from or -1 */ int sockfd; /* socket to read from or -1 */
off_t size; /* -1 if unknown at this point */ curl_off_t size; /* -1 if unknown at this point */
off_t *bytecountp; /* return number of bytes read or NULL */ curl_off_t *bytecountp; /* return number of bytes read or NULL */
/* WRITE stuff */ /* WRITE stuff */
int writesockfd; /* socket to write to, it may very int writesockfd; /* socket to write to, it may very
well be the same we read from. -1 disables */ well be the same we read from. -1 disables */
off_t *writebytecountp; /* return number of bytes written or NULL */ curl_off_t *writebytecountp; /* return number of bytes written or NULL */
/** Dynamicly allocated strings, may need to be freed before this **/ /** Dynamicly allocated strings, may need to be freed before this **/
/** struct is killed. **/ /** struct is killed. **/
@ -785,10 +785,10 @@ struct UserDefined {
long timeout; /* in seconds, 0 means no timeout */ long timeout; /* in seconds, 0 means no timeout */
long connecttimeout; /* in seconds, 0 means no timeout */ long connecttimeout; /* in seconds, 0 means no timeout */
long ftp_response_timeout; /* in seconds, 0 means no timeout */ long ftp_response_timeout; /* in seconds, 0 means no timeout */
off_t infilesize; /* size of file to upload, -1 means unknown */ curl_off_t infilesize; /* size of file to upload, -1 means unknown */
long low_speed_limit; /* bytes/second */ long low_speed_limit; /* bytes/second */
long low_speed_time; /* number of seconds */ long low_speed_time; /* number of seconds */
off_t set_resume_from; /* continue [ftp] transfer from here */ curl_off_t set_resume_from; /* continue [ftp] transfer from here */
char *cookie; /* HTTP cookie string to send */ char *cookie; /* HTTP cookie string to send */
struct curl_slist *headers; /* linked list of extra headers */ struct curl_slist *headers; /* linked list of extra headers */
struct curl_httppost *httppost; /* linked list of POST data */ struct curl_httppost *httppost; /* linked list of POST data */
@ -830,7 +830,7 @@ struct UserDefined {
int ip_version; int ip_version;
off_t max_filesize; /* Maximum file size to download */ curl_off_t max_filesize; /* Maximum file size to download */
/* Here follows boolean settings that define how to behave during /* Here follows boolean settings that define how to behave during
this session. They are STATIC, set by libcurl users or at least initially this session. They are STATIC, set by libcurl users or at least initially