The function is no longer used via the curlx shortcut.
Remove the strtoofft.[ch] files.
Closes #16642
strequal.c \
strerror.c \
strparse.c \
- strtoofft.c \
system_win32.c \
telnet.c \
tftp.c \
strdup.h \
strerror.h \
strparse.h \
- strtoofft.h \
system_win32.h \
telnet.h \
tftp.h \
#include "vtls/vtls.h"
#include "transfer.h"
#include "multiif.h"
-#include "strtoofft.h"
+#include "strparse.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
k->httpcode);
}
else {
- if(curlx_strtoofft(header + strlen("Content-Length:"),
- NULL, 10, &ts->cl)) {
+ const char *p = header + strlen("Content-Length:");
+ if(Curl_str_numblanks(&p, &ts->cl)) {
failf(data, "Unsupported Content-Length value");
return CURLE_WEIRD_SERVER_REPLY;
}
#include "strcase.h"
/* "strcase.h" provides the strcasecompare protos */
-#include "strtoofft.h"
-/* "strtoofft.h" provides this function: curlx_strtoofft(), returns a
- curl_off_t number from a given string.
-*/
-
#include "nonblock.h"
/* "nonblock.h" provides curlx_nonblock() */
#include "version_win32.h"
/* "version_win32.h" provides curlx_verify_windows_version() */
+#include "strparse.h"
+/* The curlx_str_* parsing functions */
+
#endif /* HEADER_CURL_CURLX_H */
#include "urldata.h"
#include "fileinfo.h"
#include "llist.h"
-#include "strtoofft.h"
#include "ftp.h"
#include "ftplistparser.h"
#include "curl_fnmatch.h"
case PL_UNIX_SIZE_NUMBER:
parser->item_length++;
if(c == ' ') {
- char *p;
+ const char *p = mem + parser->item_offset;
curl_off_t fsize;
mem[parser->item_offset + parser->item_length - 1] = 0;
- if(!curlx_strtoofft(mem + parser->item_offset,
- &p, 10, &fsize)) {
- if(p[0] == '\0' && fsize != CURL_OFF_T_MAX &&
- fsize != CURL_OFF_T_MIN) {
+ if(!Curl_str_numblanks(&p, &fsize)) {
+ if(p[0] == '\0' && fsize != CURL_OFF_T_MAX) {
parser->file_data->info.flags |= CURLFINFOFLAG_KNOWN_SIZE;
parser->file_data->info.size = fsize;
}
finfo->size = 0;
}
else {
- char *endptr;
- if(curlx_strtoofft(mem +
- parser->item_offset,
- &endptr, 10, &finfo->size)) {
+ const char *p = mem + parser->item_offset;
+ if(Curl_str_numblanks(&p, &finfo->size)) {
parser->error = CURLE_FTP_BAD_FILE_LIST;
goto fail;
}
#include "headers.h"
#include "select.h"
#include "parsedate.h" /* for the week day and month names */
-#include "strtoofft.h"
#include "multiif.h"
#include "strcase.h"
#include "content_encoding.h"
HD_VAL(hd, hdlen, "Content-Length:") : NULL;
if(v) {
curl_off_t contentlength;
- CURLofft offt = curlx_strtoofft(v, NULL, 10, &contentlength);
+ int offt = Curl_str_numblanks(&v, &contentlength);
- if(offt == CURL_OFFT_OK) {
+ if(offt == STRE_OK) {
k->size = contentlength;
k->maxdownload = k->size;
}
- else if(offt == CURL_OFFT_FLOW) {
+ else if(offt == STRE_OVERFLOW) {
/* out of range */
if(data->set.max_filesize) {
failf(data, "Maximum file size exceeded");
return str_num_base(linep, nump, max, 8);
}
+/*
+ * Parse a positive number up to 63-bit number written in ASCII. Skip leading
+ * blanks. No support for prefixes.
+ */
+int Curl_str_numblanks(const char **str, curl_off_t *num)
+{
+ Curl_str_passblanks(str);
+ return Curl_str_number(str, num, CURL_OFF_T_MAX);
+}
+
/* CR or LF
return non-zero on error */
int Curl_str_newline(const char **linep)
/* Get an unsigned decimal number. Return non-zero on error */
int Curl_str_number(const char **linep, curl_off_t *nump, curl_off_t max);
+/* As above with CURL_OFF_T_MAX but also pass leading blanks */
+int Curl_str_numblanks(const char **str, curl_off_t *num);
+
/* Get an unsigned hexadecimal number. Return non-zero on error */
int Curl_str_hex(const char **linep, curl_off_t *nump, curl_off_t max);
+++ /dev/null
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- * SPDX-License-Identifier: curl
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-
-#include "strtoofft.h"
-#include "strparse.h"
-
-/*
- * Parse a positive number up to 63-bit number written in ASCII. Skip leading
- * blanks. No support for prefixes.
- */
-CURLofft curlx_strtoofft(const char *str, char **endp, int base,
- curl_off_t *num)
-{
- curl_off_t number;
- int rc;
- *num = 0; /* clear by default */
- DEBUGASSERT((base == 10) || (base == 16));
-
- Curl_str_passblanks(&str);
- rc = base == 10 ?
- Curl_str_number(&str, &number, CURL_OFF_T_MAX) :
- Curl_str_hex(&str, &number, CURL_OFF_T_MAX);
-
- if(endp)
- *endp = (char *)str;
- if(rc == STRE_OVERFLOW)
- /* overflow */
- return CURL_OFFT_FLOW;
- else if(rc)
- /* nothing parsed */
- return CURL_OFFT_INVAL;
-
- *num = number;
- return CURL_OFFT_OK;
-}
+++ /dev/null
-#ifndef HEADER_CURL_STRTOOFFT_H
-#define HEADER_CURL_STRTOOFFT_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- * SPDX-License-Identifier: curl
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-#include "strparse.h"
-
-typedef enum {
- CURL_OFFT_OK, /* parsed fine */
- CURL_OFFT_FLOW, /* over or underflow */
- CURL_OFFT_INVAL /* nothing was parsed */
-} CURLofft;
-
-CURLofft curlx_strtoofft(const char *str, char **endp, int base,
- curl_off_t *num);
-
-#endif /* HEADER_CURL_STRTOOFFT_H */
#include "inet_ntop.h"
#include "parsedate.h" /* for the week day and month names */
#include "sockaddr.h" /* required for Curl_sockaddr_storage */
-#include "strtoofft.h"
#include "strparse.h"
#include "multiif.h"
#include "select.h"
}
if(data->state.use_range) {
curl_off_t from, to;
- char *ptr;
- char *ptr2;
- CURLofft to_t;
- CURLofft from_t;
+ const char *p = data->state.range;
+ int from_t, to_t;
- from_t = curlx_strtoofft(data->state.range, &ptr, 10, &from);
- if(from_t == CURL_OFFT_FLOW) {
+ from_t = Curl_str_number(&p, &from, CURL_OFF_T_MAX);
+ if(from_t == STRE_OVERFLOW)
return CURLE_RANGE_ERROR;
- }
- while(*ptr && (ISBLANK(*ptr) || (*ptr == '-')))
- ptr++;
- to_t = curlx_strtoofft(ptr, &ptr2, 10, &to);
- if(to_t == CURL_OFFT_FLOW) {
+ Curl_str_passblanks(&p);
+ (void)Curl_str_single(&p, '-');
+
+ to_t = Curl_str_numblanks(&p, &to);
+ if(to_t == STRE_OVERFLOW)
return CURLE_RANGE_ERROR;
- }
- if((to_t == CURL_OFFT_INVAL) /* no "to" value given */
- || (to >= size)) {
+
+ if((to_t == STRE_NO_NUM) || (to >= size)) {
to = size - 1;
+ to_t = STRE_OK;
}
- if(from_t) {
+
+ if(from_t == STRE_NO_NUM) {
/* from is relative to end of file */
from = size - to;
to = size - 1;
+ from_t = STRE_OK;
}
if(from > size) {
failf(data, "Offset (%" FMT_OFF_T ") was beyond file size (%"
#include "inet_ntop.h"
#include "parsedate.h" /* for the week day and month names */
#include "sockaddr.h" /* required for Curl_sockaddr_storage */
-#include "strtoofft.h"
#include "multiif.h"
#include "select.h"
#include "warnless.h"
}
if(data->state.use_range) {
curl_off_t from, to;
- char *ptr;
- char *ptr2;
- CURLofft to_t;
- CURLofft from_t;
+ const char *p = data->state.range;
+ int to_t, from_t;
- from_t = curlx_strtoofft(data->state.range, &ptr, 10, &from);
- if(from_t == CURL_OFFT_FLOW)
+ from_t = Curl_str_number(&p, &from, CURL_OFF_T_MAX);
+ if(from_t == STRE_OVERFLOW)
return CURLE_RANGE_ERROR;
- while(*ptr && (ISBLANK(*ptr) || (*ptr == '-')))
- ptr++;
- to_t = curlx_strtoofft(ptr, &ptr2, 10, &to);
- if(to_t == CURL_OFFT_FLOW)
+ Curl_str_passblanks(&p);
+ (void)Curl_str_single(&p, '-');
+
+ to_t = Curl_str_numblanks(&p, &to);
+ if(to_t == STRE_OVERFLOW)
return CURLE_RANGE_ERROR;
- if((to_t == CURL_OFFT_INVAL) /* no "to" value given */
+ if((to_t == STRE_NO_NUM) /* no "to" value given */
|| (to >= size)) {
to = size - 1;
}
[.src]curl-tool_urlglob.o, [.src]curl-tool_util.o, -
[.src]curl-tool_vms.o, [.src]curl-tool_writeenv.o, -
[.src]curl-tool_writeout.o, [.src]curl-tool_xattr.o, -
- [.src]curl-strtoofft.o, [.src]curl-strdup.o, [.src]curl-strcase.o, -
[.src]curl-nonblock.o, gnv_packages_vms:curlmsg.obj,-
sys$input:/opt
gnv$libcurl/share
) else if "!var!" == "CURL_SRC_RC_FILES" (
for /f "delims=" %%r in ('dir /b ..\src\*.rc') do call :element %1 src "%%r" %3
) else if "!var!" == "CURL_SRC_X_C_FILES" (
- call :element %1 lib "strtoofft.c" %3
call :element %1 lib "strparse.c" %3
call :element %1 lib "strcase.c" %3
call :element %1 lib "timediff.c" %3
) else if "!var!" == "CURL_SRC_X_H_FILES" (
call :element %1 lib "config-win32.h" %3
call :element %1 lib "curl_setup.h" %3
- call :element %1 lib "strtoofft.h" %3
call :element %1 lib "strparse.h" %3
call :element %1 lib "strcase.h" %3
call :element %1 lib "timediff.h" %3
../lib/curl_multibyte.c \
../lib/dynbuf.c \
../lib/nonblock.c \
- ../lib/strtoofft.c \
../lib/strparse.c \
../lib/strcase.c \
../lib/timediff.c \
../lib/curl_setup.h \
../lib/dynbuf.h \
../lib/nonblock.h \
- ../lib/strtoofft.h \
../lib/strparse.h \
../lib/strcase.h \
../lib/timediff.h \
#endif
#include "terminal.h"
-#include "strtoofft.h"
+#include "curlx.h"
#include "memdebug.h" /* keep this as LAST include */
CURLX_SRCS = \
../../lib/mprintf.c \
../../lib/nonblock.c \
- ../../lib/strtoofft.c \
../../lib/strparse.c \
../../lib/strequal.c \
../../lib/warnless.c \
CURLX_HDRS = \
../../lib/curlx.h \
../../lib/nonblock.h \
- ../../lib/strtoofft.h \
../../lib/strcase.h \
../../lib/warnless.h \
../../lib/timediff.h \
CURL_FROM_LIBCURL=\
$(CURL_DIROBJ)\nonblock.obj \
- $(CURL_DIROBJ)\strtoofft.obj \
$(CURL_DIROBJ)\strparse.obj \
$(CURL_DIROBJ)\strcase.obj \
$(CURL_DIROBJ)\warnless.obj \
!ENDIF
$(CURL_DIROBJ)\nonblock.obj: ../lib/nonblock.c
$(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/nonblock.c
-$(CURL_DIROBJ)\strtoofft.obj: ../lib/strtoofft.c
- $(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/strtoofft.c
$(CURL_DIROBJ)\strparse.obj: ../lib/strparse.c
$(CURL_CC) $(CURL_CFLAGS) /Fo"$@" ../lib/strparse.c
$(CURL_DIROBJ)\strcase.obj: ../lib/strcase.c