mirror of
https://github.com/moparisthebest/curl
synced 2024-11-17 15:05:02 -05:00
renamed the strtoofft() macro to curlx_strtoofft() to adjust to the curlx_*
concept, and added lib/README.curlx to explain details about it
This commit is contained in:
parent
f052cbee19
commit
cf1f46e1ca
@ -22,13 +22,13 @@
|
|||||||
###########################################################################
|
###########################################################################
|
||||||
AUTOMAKE_OPTIONS = foreign nostdinc
|
AUTOMAKE_OPTIONS = foreign nostdinc
|
||||||
|
|
||||||
EXTRA_DIST = getdate.y Makefile.b32 Makefile.b32.resp Makefile.m32 \
|
EXTRA_DIST = getdate.y Makefile.b32 Makefile.b32.resp Makefile.m32 \
|
||||||
Makefile.vc6 Makefile.riscos libcurl.def curllib.dsp curllib.dsw \
|
Makefile.vc6 Makefile.riscos libcurl.def curllib.dsp curllib.dsw \
|
||||||
config-vms.h config-win32.h config-riscos.h config-mac.h config.h.in \
|
config-vms.h config-win32.h config-riscos.h config-mac.h config.h.in \
|
||||||
ca-bundle.crt README.encoding README.memoryleak README.ares \
|
ca-bundle.crt README.encoding README.memoryleak README.ares README.curlx \
|
||||||
makefile.dj config.dj libcurl.framework.make libcurl.plist \
|
makefile.dj config.dj libcurl.framework.make libcurl.plist libcurl.rc \
|
||||||
libcurl.rc config-amigaos.h amigaos.c amigaos.h makefile.amiga \
|
config-amigaos.h amigaos.c amigaos.h makefile.amiga config-netware.h \
|
||||||
config-netware.h Makefile.netware nwlib.c libcurl.imp
|
Makefile.netware nwlib.c libcurl.imp
|
||||||
|
|
||||||
lib_LTLIBRARIES = libcurl.la
|
lib_LTLIBRARIES = libcurl.la
|
||||||
|
|
||||||
|
43
lib/README.curlx
Normal file
43
lib/README.curlx
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
$Id$
|
||||||
|
_ _ ____ _
|
||||||
|
___| | | | _ \| |
|
||||||
|
/ __| | | | |_) | |
|
||||||
|
| (__| |_| | _ <| |___
|
||||||
|
\___|\___/|_| \_\_____|
|
||||||
|
|
||||||
|
Source Code Functions Apps Might Use
|
||||||
|
====================================
|
||||||
|
|
||||||
|
The libcurl source code offers a few functions by source only. They are not
|
||||||
|
part of the official libcurl API, but the source files might be useful for
|
||||||
|
others so apps can optionally compile/build with these sources to gain
|
||||||
|
additional functions.
|
||||||
|
|
||||||
|
|
||||||
|
strtoofft.[ch]
|
||||||
|
==============
|
||||||
|
|
||||||
|
curlx_strtoofft()
|
||||||
|
|
||||||
|
A macro that converts a string containing a number to a curl_off_t number.
|
||||||
|
This might use the curlx_strtoll() function which is provided as source
|
||||||
|
code in strtoofft.c. Note that the function is only provided if no
|
||||||
|
strtoll() (or equivalent) function exist on your platform. If curl_off_t
|
||||||
|
is only a 32 bit number on your platform, this macro uses strtol().
|
||||||
|
|
||||||
|
timeval.[ch]
|
||||||
|
============
|
||||||
|
|
||||||
|
Provides a 'struct timeval' for platforms that don't have one already, and
|
||||||
|
includes the proper include files for those that have one. Using this will
|
||||||
|
make the output require the 'winmm' lib on Windows (unless WITHOUT_MM_LIB
|
||||||
|
is defined at compile-time).
|
||||||
|
|
||||||
|
curlx_tvnow()
|
||||||
|
|
||||||
|
returns a struct timeval for the current time.
|
||||||
|
|
||||||
|
curlx_tvdiff()
|
||||||
|
|
||||||
|
returns the difference between two timeval structs, in number of
|
||||||
|
milliseconds.
|
@ -961,7 +961,7 @@ CURLcode ftp_getsize(struct connectdata *conn, char *file,
|
|||||||
|
|
||||||
if(ftpcode == 213) {
|
if(ftpcode == 213) {
|
||||||
/* get the size from the ascii string: */
|
/* get the size from the ascii string: */
|
||||||
*size = strtoofft(buf+4, NULL, 0);
|
*size = curlx_strtoofft(buf+4, NULL, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return CURLE_FTP_COULDNT_GET_SIZE;
|
return CURLE_FTP_COULDNT_GET_SIZE;
|
||||||
@ -1849,10 +1849,10 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
|||||||
char *ptr;
|
char *ptr;
|
||||||
char *ptr2;
|
char *ptr2;
|
||||||
|
|
||||||
from=strtoofft(conn->range, &ptr, 0);
|
from=curlx_strtoofft(conn->range, &ptr, 0);
|
||||||
while(ptr && *ptr && (isspace((int)*ptr) || (*ptr=='-')))
|
while(ptr && *ptr && (isspace((int)*ptr) || (*ptr=='-')))
|
||||||
ptr++;
|
ptr++;
|
||||||
to=strtoofft(ptr, &ptr2, 0);
|
to=curlx_strtoofft(ptr, &ptr2, 0);
|
||||||
if(ptr == ptr2) {
|
if(ptr == ptr2) {
|
||||||
/* we didn't get any digit */
|
/* we didn't get any digit */
|
||||||
to=-1;
|
to=-1;
|
||||||
@ -2071,7 +2071,7 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
|||||||
/* only if we have nothing but digits: */
|
/* only if we have nothing but digits: */
|
||||||
if(bytes++) {
|
if(bytes++) {
|
||||||
/* get the number! */
|
/* get the number! */
|
||||||
size = strtoofft(bytes, NULL, 0);
|
size = curlx_strtoofft(bytes, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,22 +40,22 @@
|
|||||||
*/
|
*/
|
||||||
#if SIZEOF_CURL_OFF_T > 4
|
#if SIZEOF_CURL_OFF_T > 4
|
||||||
#if HAVE_STRTOLL
|
#if HAVE_STRTOLL
|
||||||
#define strtoofft strtoll
|
#define curlx_strtoofft strtoll
|
||||||
#else /* HAVE_STRTOLL */
|
#else /* HAVE_STRTOLL */
|
||||||
|
|
||||||
/* For MSVC7 we can use _strtoi64() which seems to be a strtoll() clone */
|
/* For MSVC7 we can use _strtoi64() which seems to be a strtoll() clone */
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
#if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||||
#define strtoofft _strtoi64
|
#define curlx_strtoofft _strtoi64
|
||||||
#else /* MSVC7 or later */
|
#else /* MSVC7 or later */
|
||||||
curl_off_t curlx_strtoll(const char *nptr, char **endptr, int base);
|
curl_off_t curlx_strtoll(const char *nptr, char **endptr, int base);
|
||||||
#define strtoofft curlx_strtoll
|
#define curlx_strtoofft curlx_strtoll
|
||||||
#define NEED_CURL_STRTOLL
|
#define NEED_CURL_STRTOLL
|
||||||
#endif /* MSVC7 or later */
|
#endif /* MSVC7 or later */
|
||||||
|
|
||||||
#endif /* HAVE_STRTOLL */
|
#endif /* HAVE_STRTOLL */
|
||||||
#else /* SIZEOF_CURL_OFF_T > 4 */
|
#else /* SIZEOF_CURL_OFF_T > 4 */
|
||||||
/* simply use strtol() to get 32bit numbers */
|
/* simply use strtol() to get 32bit numbers */
|
||||||
#define strtoofft strtol
|
#define curlx_strtoofft strtol
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -651,7 +651,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
info about the true size of the document we didn't get now. */
|
info about the true size of the document we didn't get now. */
|
||||||
if ((k->httpcode != 416) &&
|
if ((k->httpcode != 416) &&
|
||||||
checkprefix("Content-Length:", k->p)) {
|
checkprefix("Content-Length:", k->p)) {
|
||||||
contentlength = strtoofft(k->p+15, NULL, 10);
|
contentlength = curlx_strtoofft(k->p+15, NULL, 10);
|
||||||
if (data->set.max_filesize && contentlength >
|
if (data->set.max_filesize && contentlength >
|
||||||
data->set.max_filesize) {
|
data->set.max_filesize) {
|
||||||
failf(data, "Maximum file size exceeded");
|
failf(data, "Maximum file size exceeded");
|
||||||
@ -784,7 +784,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
/* stupid colon skip */
|
/* stupid colon skip */
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
k->offset = strtoofft(ptr, NULL, 10);
|
k->offset = curlx_strtoofft(ptr, NULL, 10);
|
||||||
|
|
||||||
if (conn->resume_from == k->offset)
|
if (conn->resume_from == k->offset)
|
||||||
/* we asked for a resume and we got it */
|
/* we asked for a resume and we got it */
|
||||||
|
@ -1035,7 +1035,7 @@ static int str2offset(curl_off_t *val, char *str)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* this is a duplicate of the function that is also used in libcurl */
|
/* this is a duplicate of the function that is also used in libcurl */
|
||||||
*val = strtoofft(str, NULL, 0);
|
*val = curlx_strtoofft(str, NULL, 0);
|
||||||
|
|
||||||
if ((*val == LLONG_MAX || *val == LLONG_MIN) && errno == ERANGE)
|
if ((*val == LLONG_MAX || *val == LLONG_MIN) && errno == ERANGE)
|
||||||
return 1;
|
return 1;
|
||||||
@ -1319,7 +1319,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
{
|
{
|
||||||
/* We support G, M, K too */
|
/* We support G, M, K too */
|
||||||
char *unit;
|
char *unit;
|
||||||
curl_off_t value = strtoofft(nextarg, &unit, 0);
|
curl_off_t value = curlx_strtoofft(nextarg, &unit, 0);
|
||||||
switch(nextarg[strlen(nextarg)-1]) {
|
switch(nextarg[strlen(nextarg)-1]) {
|
||||||
case 'G':
|
case 'G':
|
||||||
case 'g':
|
case 'g':
|
||||||
|
Loading…
Reference in New Issue
Block a user