20
20
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21
21
* KIND, either express or implied.
23
* $Id: strtoofft.h,v 1.16 2007-11-06 16:20:54 giva Exp $
23
* $Id: strtoofft.h,v 1.22 2008-08-21 06:58:13 yangtse Exp $
24
24
***************************************************************************/
27
* CAUTION: this header is designed to work when included by the app-side
28
* as well as the library. Do not mix with library internals!
33
#include <curl/curl.h> /* for the curl_off_t type */
35
/* Determine what type of file offset conversion handling we wish to use. For
36
* systems with a 32-bit curl_off_t type, we should use strtol. For systems
37
* with a 64-bit curl_off_t type, we should use strtoll if it exists, and if
38
* not, should try to emulate its functionality. At any rate, we define
39
* 'strtoofft' such that it can be used to work with curl_off_t's regardless.
41
#if (SIZEOF_CURL_OFF_T > 4) && (SIZEOF_LONG < 8)
43
#define curlx_strtoofft strtoll
44
#else /* HAVE_STRTOLL */
46
/* For MSVC7 we can use _strtoi64() which seems to be a strtoll() clone */
47
#if defined(_MSC_VER) && (_MSC_VER >= 1300)
48
_CRTIMP __int64 __cdecl _strtoi64(const char *, char **, int); /* in <crt/stdlib.h> */
49
#define curlx_strtoofft _strtoi64
50
#else /* MSVC7 or later */
51
curl_off_t curlx_strtoll(const char *nptr, char **endptr, int base);
52
#define curlx_strtoofft curlx_strtoll
53
#define NEED_CURL_STRTOLL
54
#endif /* MSVC7 or later */
56
#endif /* HAVE_STRTOLL */
57
#else /* (SIZEOF_CURL_OFF_T > 4) && (SIZEOF_LONG < 8) */
58
/* simply use strtol() to get numbers, either 32 or 64 bit */
59
#define curlx_strtoofft strtol
62
#if defined(_MSC_VER) || defined(__WATCOMC__)
63
#define CURL_LLONG_MIN 0x8000000000000000i64
64
#define CURL_LLONG_MAX 0x7FFFFFFFFFFFFFFFi64
65
#elif defined(HAVE_LL)
66
#define CURL_LLONG_MIN 0x8000000000000000LL
67
#define CURL_LLONG_MAX 0x7FFFFFFFFFFFFFFFLL
29
* Determine which string to integral data type conversion function we use
30
* to implement string conversion to our curl_off_t integral data type.
32
* Notice that curl_off_t might be 64 or 32 bit wide, and that it might use
33
* an undelying data type which might be 'long', 'int64_t', 'long long' or
34
* '__int64' and more remotely other data types.
36
* On systems where the size of curl_off_t is greater than the size of 'long'
37
* the conversion funtion to use is strtoll() if it is available, otherwise,
38
* we emulate its functionality with our own clone.
40
* On systems where the size of curl_off_t is smaller or equal than the size
41
* of 'long' the conversion funtion to use is strtol().
44
#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
46
# define curlx_strtoofft strtoll
48
# if defined(_MSC_VER) && (_MSC_VER >= 1300) && (_INTEGRAL_MAX_BITS >= 64)
49
_CRTIMP __int64 __cdecl _strtoi64(const char *, char **, int);
50
# define curlx_strtoofft _strtoi64
52
curl_off_t curlx_strtoll(const char *nptr, char **endptr, int base);
53
# define curlx_strtoofft curlx_strtoll
54
# define NEED_CURL_STRTOLL 1
69
#define CURL_LLONG_MIN 0x8000000000000000L
70
#define CURL_LLONG_MAX 0x7FFFFFFFFFFFFFFFL
58
# define curlx_strtoofft strtol
61
#define CURL_LLONG_MAX CURL_OFF_T_C(0x7FFFFFFFFFFFFFFF)
62
#define CURL_LLONG_MIN (-CURL_LLONG_MAX - CURL_OFF_T_C(1))