Import bind 9.5.2 vendor sources.
[dragonfly.git] / contrib / bind-9.5.2 / lib / isc / include / isc / parseint.h
blob5047676852bf32f40fd34834ecfb4b44d619c59d
1 /*
2 * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2001, 2002 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or 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.9 2007/06/19 23:47:18 tbox Exp $ */
20 #ifndef ISC_PARSEINT_H
21 #define ISC_PARSEINT_H 1
23 #include <isc/lang.h>
24 #include <isc/types.h>
26 /*! \file isc/parseint.h
27 * \brief Parse integers, in a saner way than atoi() or strtoul() do.
30 /***
31 *** Functions
32 ***/
34 ISC_LANG_BEGINDECLS
36 isc_result_t
37 isc_parse_uint32(isc_uint32_t *uip, const char *string, int base);
39 isc_result_t
40 isc_parse_uint16(isc_uint16_t *uip, const char *string, int base);
42 isc_result_t
43 isc_parse_uint8(isc_uint8_t *uip, const char *string, int base);
44 /*%<
45 * Parse the null-terminated string 'string' containing a base 'base'
46 * integer, storing the result in '*uip'.
47 * The base is interpreted
48 * as in strtoul(). Unlike strtoul(), leading whitespace, minus or
49 * plus signs are not accepted, and all errors (including overflow)
50 * are reported uniformly through the return value.
52 * Requires:
53 *\li 'string' points to a null-terminated string
54 *\li 0 <= 'base' <= 36
56 * Returns:
57 *\li #ISC_R_SUCCESS
58 *\li #ISC_R_BADNUMBER The string is not numeric (in the given base)
59 *\li #ISC_R_RANGE The number is not representable as the requested type.
62 ISC_LANG_ENDDECLS
64 #endif /* ISC_PARSEINT_H */