mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 05:57:52 +00:00
Replace isc_string_touint64 with strtoull (C99)
This commit is contained in:
parent
fd9c3ad389
commit
20d145efef
@ -52,7 +52,7 @@ fromtext_any_tsig(ARGS_FROMTEXT) {
|
||||
*/
|
||||
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
|
||||
ISC_FALSE));
|
||||
sigtime = isc_string_touint64(DNS_AS_STR(token), &e, 10);
|
||||
sigtime = strtoull(DNS_AS_STR(token), &e, 10);
|
||||
if (*e != 0)
|
||||
RETTOK(DNS_R_SYNTAX);
|
||||
if ((sigtime >> 48) != 0)
|
||||
|
@ -32,21 +32,6 @@
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_uint64_t
|
||||
isc_string_touint64(char *source, char **endp, int base);
|
||||
/*%<
|
||||
* Convert the string pointed to by 'source' to isc_uint64_t.
|
||||
*
|
||||
* On successful conversion 'endp' points to the first character
|
||||
* after conversion is complete.
|
||||
*
|
||||
* 'base': 0 or 2..36
|
||||
*
|
||||
* If base is 0 the base is computed from the string type.
|
||||
*
|
||||
* On error 'endp' points to 'source'.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_string_copy(char *target, size_t size, const char *source);
|
||||
/*
|
||||
@ -114,23 +99,6 @@ isc_string_append(char *target, size_t size, const char *source);
|
||||
* is too small.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_string_append_truncate(char *target, size_t size, const char *source);
|
||||
/*
|
||||
* Append the string pointed to by 'source' to 'target' which is a
|
||||
* pointer to a NUL terminated string of at least 'size' bytes.
|
||||
*
|
||||
* Requires:
|
||||
* 'target' is a pointer to a NUL terminated char[] of at
|
||||
* least 'size' bytes.
|
||||
* 'size' an integer > 0.
|
||||
* 'source' == NULL or points to a NUL terminated string.
|
||||
*
|
||||
* Ensures:
|
||||
* 'target' will be a NUL terminated string of no more
|
||||
* than 'size' bytes (including NUL).
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_string_printf(char *target, size_t size, const char *format, ...)
|
||||
ISC_FORMAT_PRINTF(3, 4);
|
||||
|
@ -1280,8 +1280,7 @@ remove_old_tsversions(isc_logfile_t *file, int versions) {
|
||||
dir.entry.name[bnamelen] == '.')
|
||||
{
|
||||
char *ename = &dir.entry.name[bnamelen + 1];
|
||||
version = isc_string_touint64(ename,
|
||||
&digit_end, 10);
|
||||
version = strtoull(ename, &digit_end, 10);
|
||||
if (*digit_end == '\0') {
|
||||
int i = 0;
|
||||
while (i < versions &&
|
||||
@ -1316,7 +1315,7 @@ remove_old_tsversions(isc_logfile_t *file, int versions) {
|
||||
dir.entry.name[bnamelen] == '.')
|
||||
{
|
||||
char *ename = &dir.entry.name[bnamelen + 1];
|
||||
version = isc_string_touint64(ename, &digit_end, 10);
|
||||
version = strtoull(ename, &digit_end, 10);
|
||||
/*
|
||||
* Remove any backup files that exceed versions.
|
||||
*/
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/string.h>
|
||||
#include <isc/net.h>
|
||||
#include <isc/netscope.h>
|
||||
@ -47,7 +49,7 @@ isc_netscope_pton(int af, char *scopename, void *addr, isc_uint32_t *zoneid) {
|
||||
zone = (isc_uint32_t)ifid;
|
||||
else {
|
||||
#endif
|
||||
llz = isc_string_touint64(scopename, &ep, 10);
|
||||
llz = strtoull(scopename, &ep, 10);
|
||||
if (ep == scopename)
|
||||
return (ISC_R_FAILURE);
|
||||
|
||||
|
@ -50,72 +50,6 @@
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
static const char digits[] = "0123456789abcdefghijklmnoprstuvwxyz";
|
||||
|
||||
isc_uint64_t
|
||||
isc_string_touint64(char *source, char **end, int base) {
|
||||
isc_uint64_t tmp;
|
||||
isc_uint64_t overflow;
|
||||
char *s = source;
|
||||
const char *o;
|
||||
char c;
|
||||
|
||||
if ((base < 0) || (base == 1) || (base > 36)) {
|
||||
*end = source;
|
||||
return (0);
|
||||
}
|
||||
|
||||
while (*s != 0 && isascii(*s&0xff) && isspace(*s&0xff))
|
||||
s++;
|
||||
if (*s == '+' /* || *s == '-' */)
|
||||
s++;
|
||||
if (base == 0) {
|
||||
if (*s == '0' && (*(s+1) == 'X' || *(s+1) == 'x')) {
|
||||
s += 2;
|
||||
base = 16;
|
||||
} else if (*s == '0')
|
||||
base = 8;
|
||||
else
|
||||
base = 10;
|
||||
}
|
||||
if (*s == 0) {
|
||||
*end = source;
|
||||
return (0);
|
||||
}
|
||||
overflow = ~0;
|
||||
overflow /= base;
|
||||
tmp = 0;
|
||||
|
||||
while ((c = *s) != 0) {
|
||||
c = tolower(c&0xff);
|
||||
/* end ? */
|
||||
if ((o = strchr(digits, c)) == NULL) {
|
||||
*end = s;
|
||||
return (tmp);
|
||||
}
|
||||
/* end ? */
|
||||
if ((o - digits) >= base) {
|
||||
*end = s;
|
||||
return (tmp);
|
||||
}
|
||||
/* overflow ? */
|
||||
if (tmp > overflow) {
|
||||
*end = source;
|
||||
return (0);
|
||||
}
|
||||
tmp *= base;
|
||||
/* overflow ? */
|
||||
if ((tmp + (o - digits)) < tmp) {
|
||||
*end = source;
|
||||
return (0);
|
||||
}
|
||||
tmp += o - digits;
|
||||
s++;
|
||||
}
|
||||
*end = s;
|
||||
return (tmp);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_string_copy(char *target, size_t size, const char *source) {
|
||||
REQUIRE(size > 0U);
|
||||
@ -154,16 +88,6 @@ isc_string_append(char *target, size_t size, const char *source) {
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
void
|
||||
isc_string_append_truncate(char *target, size_t size, const char *source) {
|
||||
REQUIRE(size > 0U);
|
||||
REQUIRE(strlen(target) < size);
|
||||
|
||||
strlcat(target, source, size);
|
||||
|
||||
ENSURE(strlen(target) < size);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_string_printf(char *target, size_t size, const char *format, ...) {
|
||||
va_list args;
|
||||
|
@ -20,6 +20,18 @@
|
||||
|
||||
#define ISC_PLATFORM_USETHREADS 1
|
||||
|
||||
/*
|
||||
* Some compatibility cludges
|
||||
*/
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#ifndef strtoull
|
||||
#define strtoull _strtoui64
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/***
|
||||
*** Network.
|
||||
***/
|
||||
|
@ -646,7 +646,6 @@ isc_stdio_tell
|
||||
isc_stdio_write
|
||||
isc_stdtime_get
|
||||
isc_string_append
|
||||
isc_string_append_truncate
|
||||
isc_string_copy
|
||||
isc_string_copy_truncate
|
||||
isc_string_printf
|
||||
@ -656,7 +655,6 @@ isc_string_separate
|
||||
isc_string_strcasestr
|
||||
isc_string_strlcat
|
||||
isc_string_strlcpy
|
||||
isc_string_touint64
|
||||
isc_symtab_count
|
||||
isc_symtab_create
|
||||
isc_symtab_define
|
||||
|
@ -2552,7 +2552,7 @@ parse_unitstring(char *str, isc_resourcevalue_t *valuep) {
|
||||
isc_uint64_t value;
|
||||
isc_uint64_t unit;
|
||||
|
||||
value = isc_string_touint64(str, &endp, 10);
|
||||
value = strtoull(str, &endp, 10);
|
||||
if (*endp == 0) {
|
||||
*valuep = value;
|
||||
return (ISC_R_SUCCESS);
|
||||
@ -2628,7 +2628,7 @@ parse_sizeval_percent(cfg_parser_t *pctx, const cfg_type_t *type,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
percent = isc_string_touint64(TOKEN_STRING(pctx), &endp, 10);
|
||||
percent = strtoull(TOKEN_STRING(pctx), &endp, 10);
|
||||
|
||||
if (*endp == '%' && *(endp+1) == 0) {
|
||||
CHECK(cfg_create_obj(pctx, &cfg_type_percentage, &obj));
|
||||
|
@ -752,7 +752,7 @@ cfg_parse_percentage(cfg_parser_t *pctx, const cfg_type_t *type,
|
||||
return (ISC_R_UNEXPECTEDTOKEN);
|
||||
}
|
||||
|
||||
percent = isc_string_touint64(TOKEN_STRING(pctx), &endp, 10);
|
||||
percent = strtoull(TOKEN_STRING(pctx), &endp, 10);
|
||||
if (*endp != '%' || *(endp+1) != 0) {
|
||||
cfg_parser_error(pctx, CFG_LOG_NEAR,
|
||||
"expected percentage");
|
||||
|
Loading…
x
Reference in New Issue
Block a user