Merge from vendor branch OPENSSH:
[dragonfly.git] / contrib / bind-9.3 / lib / isc / include / isc / parseint.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 2001, 2002  Internet Software Consortium.
4  *
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.
8  *
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.
16  */
17
18 /* $Id: parseint.h,v 1.2.202.4 2004/03/08 09:04:52 marka Exp $ */
19
20 #ifndef ISC_PARSEINT_H
21 #define ISC_PARSEINT_H 1
22
23 #include <isc/lang.h>
24 #include <isc/types.h>
25
26 /*
27  * Parse integers, in a saner way than atoi() or strtoul() do.
28  */
29
30 /***
31  ***    Functions
32  ***/
33
34 ISC_LANG_BEGINDECLS
35
36 isc_result_t
37 isc_parse_uint32(isc_uint32_t *uip, const char *string, int base);
38
39 isc_result_t
40 isc_parse_uint16(isc_uint16_t *uip, const char *string, int base);
41
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'.  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.
50  *
51  * Requires:
52  *      'string' points to a null-terminated string
53  *      0 <= 'base' <= 36
54  *
55  * Returns:
56  *      ISC_R_SUCCESS
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.
59  */
60
61 ISC_LANG_ENDDECLS
62
63 #endif /* ISC_PARSEINT_H */