2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: string.c,v 1.6.2.1 2004/03/09 06:11:52 marka Exp $ */
24 #include <isc/string.h>
26 static char digits[] = "0123456789abcdefghijklmnoprstuvwxyz";
29 isc_string_touint64(char *source, char **end, int base) {
31 isc_uint64_t overflow;
36 if ((base < 0) || (base == 1) || (base > 36)) {
41 while (*s != 0 && isascii(*s&0xff) && isspace(*s&0xff))
43 if (*s == '+' /* || *s == '-' */)
46 if (*s == '0' && (*(s+1) == 'X' || *(s+1) == 'x')) {
62 while ((c = *s) != 0) {
65 if ((o = strchr(digits, c)) == NULL) {
70 if ((o - digits) >= base) {
81 if ((tmp + (o - digits)) < tmp) {
93 isc_string_separate(char **stringp, const char *delim) {
94 char *string = *stringp;
102 for (s = string; (sc = *s) != '\0'; s++)
103 for (d = delim; (dc = *d) != '\0'; d++)