mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -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
|
||||
|
||||
EXTRA_DIST = getdate.y Makefile.b32 Makefile.b32.resp Makefile.m32 \
|
||||
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 \
|
||||
ca-bundle.crt README.encoding README.memoryleak README.ares \
|
||||
makefile.dj config.dj libcurl.framework.make libcurl.plist \
|
||||
libcurl.rc config-amigaos.h amigaos.c amigaos.h makefile.amiga \
|
||||
config-netware.h Makefile.netware nwlib.c libcurl.imp
|
||||
EXTRA_DIST = getdate.y Makefile.b32 Makefile.b32.resp Makefile.m32 \
|
||||
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 \
|
||||
ca-bundle.crt README.encoding README.memoryleak README.ares README.curlx \
|
||||
makefile.dj config.dj libcurl.framework.make libcurl.plist libcurl.rc \
|
||||
config-amigaos.h amigaos.c amigaos.h makefile.amiga config-netware.h \
|
||||
Makefile.netware nwlib.c libcurl.imp
|
||||
|
||||
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) {
|
||||
/* get the size from the ascii string: */
|
||||
*size = strtoofft(buf+4, NULL, 0);
|
||||
*size = curlx_strtoofft(buf+4, NULL, 0);
|
||||
}
|
||||
else
|
||||
return CURLE_FTP_COULDNT_GET_SIZE;
|
||||
@ -1849,10 +1849,10 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
||||
char *ptr;
|
||||
char *ptr2;
|
||||
|
||||
from=strtoofft(conn->range, &ptr, 0);
|
||||
from=curlx_strtoofft(conn->range, &ptr, 0);
|
||||
while(ptr && *ptr && (isspace((int)*ptr) || (*ptr=='-')))
|
||||
ptr++;
|
||||
to=strtoofft(ptr, &ptr2, 0);
|
||||
to=curlx_strtoofft(ptr, &ptr2, 0);
|
||||
if(ptr == ptr2) {
|
||||
/* we didn't get any digit */
|
||||
to=-1;
|
||||
@ -2071,7 +2071,7 @@ CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
||||
/* only if we have nothing but digits: */
|
||||
if(bytes++) {
|
||||
/* 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 HAVE_STRTOLL
|
||||
#define strtoofft strtoll
|
||||
#define curlx_strtoofft strtoll
|
||||
#else /* HAVE_STRTOLL */
|
||||
|
||||
/* For MSVC7 we can use _strtoi64() which seems to be a strtoll() clone */
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
#define strtoofft _strtoi64
|
||||
#define curlx_strtoofft _strtoi64
|
||||
#else /* MSVC7 or later */
|
||||
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
|
||||
#endif /* MSVC7 or later */
|
||||
|
||||
#endif /* HAVE_STRTOLL */
|
||||
#else /* SIZEOF_CURL_OFF_T > 4 */
|
||||
/* simply use strtol() to get 32bit numbers */
|
||||
#define strtoofft strtol
|
||||
#define curlx_strtoofft strtol
|
||||
#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. */
|
||||
if ((k->httpcode != 416) &&
|
||||
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 >
|
||||
data->set.max_filesize) {
|
||||
failf(data, "Maximum file size exceeded");
|
||||
@ -784,7 +784,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
/* stupid colon skip */
|
||||
ptr++;
|
||||
|
||||
k->offset = strtoofft(ptr, NULL, 10);
|
||||
k->offset = curlx_strtoofft(ptr, NULL, 10);
|
||||
|
||||
if (conn->resume_from == k->offset)
|
||||
/* we asked for a resume and we got it */
|
||||
|
@ -1035,7 +1035,7 @@ static int str2offset(curl_off_t *val, char *str)
|
||||
#endif
|
||||
|
||||
/* 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)
|
||||
return 1;
|
||||
@ -1319,7 +1319,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
||||
{
|
||||
/* We support G, M, K too */
|
||||
char *unit;
|
||||
curl_off_t value = strtoofft(nextarg, &unit, 0);
|
||||
curl_off_t value = curlx_strtoofft(nextarg, &unit, 0);
|
||||
switch(nextarg[strlen(nextarg)-1]) {
|
||||
case 'G':
|
||||
case 'g':
|
||||
|
Loading…
Reference in New Issue
Block a user