2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2001, 2002 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: parseint.h,v 1.2.202.4 2004/03/08 09:04:52 marka Exp $ */
20 #ifndef ISC_PARSEINT_H
21 #define ISC_PARSEINT_H 1
24 #include <isc/types.h>
27 * Parse integers, in a saner way than atoi() or strtoul() do.
37 isc_parse_uint32(isc_uint32_t *uip, const char *string, int base);
40 isc_parse_uint16(isc_uint16_t *uip, const char *string, int base);
43 isc_parse_uint8(isc_uint8_t *uip, const char *string, int base);
45 * Parse the null-terminated string 'string' containing a base 'base'
46 * integer, storing the result in '*uip'. The base is interpreted
47 * as in strtoul(). Unlike strtoul(), leading whitespace, minus or
48 * plus signs are not accepted, and all errors (including overflow)
49 * are reported uniformly through the return value.
52 * 'string' points to a null-terminated string
57 * ISC_R_BADNUMBER The string is not numeric (in the given base)
58 * ISC_R_RANGE The number is not representable as the requested type.
63 #endif /* ISC_PARSEINT_H */