*/
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)
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);
/*
* 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);
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 &&
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.
*/
#include <config.h>
+#include <stdlib.h>
+
#include <isc/string.h>
#include <isc/net.h>
#include <isc/netscope.h>
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);
#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);
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;
#define ISC_PLATFORM_USETHREADS 1
+/*
+ * Some compatibility cludges
+ */
+
+#if defined(_WIN32) || defined(_WIN64)
+
+#ifndef strtoull
+#define strtoull _strtoui64
+#endif
+
+#endif
+
/***
*** Network.
***/
isc_stdio_write
isc_stdtime_get
isc_string_append
-isc_string_append_truncate
isc_string_copy
isc_string_copy_truncate
isc_string_printf
isc_string_strcasestr
isc_string_strlcat
isc_string_strlcpy
-isc_string_touint64
isc_symtab_count
isc_symtab_create
isc_symtab_define
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);
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));
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");