00001 /* 00002 * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") 00003 * Copyright (C) 2001, 2002 Internet Software Consortium. 00004 * 00005 * Permission to use, copy, modify, and/or distribute this software for any 00006 * purpose with or without fee is hereby granted, provided that the above 00007 * copyright notice and this permission notice appear in all copies. 00008 * 00009 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 00010 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 00011 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 00012 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 00013 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 00014 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00015 * PERFORMANCE OF THIS SOFTWARE. 00016 */ 00017 00018 /* $Id: parseint.h,v 1.9 2007/06/19 23:47:18 tbox Exp $ */ 00019 00020 #ifndef ISC_PARSEINT_H 00021 #define ISC_PARSEINT_H 1 00022 00023 #include <isc/lang.h> 00024 #include <isc/types.h> 00025 00026 /*! \file isc/parseint.h 00027 * \brief Parse integers, in a saner way than atoi() or strtoul() do. 00028 */ 00029 00030 /*** 00031 *** Functions 00032 ***/ 00033 00034 ISC_LANG_BEGINDECLS 00035 00036 isc_result_t 00037 isc_parse_uint32(isc_uint32_t *uip, const char *string, int base); 00038 00039 isc_result_t 00040 isc_parse_uint16(isc_uint16_t *uip, const char *string, int base); 00041 00042 isc_result_t 00043 isc_parse_uint8(isc_uint8_t *uip, const char *string, int base); 00044 /*%< 00045 * Parse the null-terminated string 'string' containing a base 'base' 00046 * integer, storing the result in '*uip'. 00047 * The base is interpreted 00048 * as in strtoul(). Unlike strtoul(), leading whitespace, minus or 00049 * plus signs are not accepted, and all errors (including overflow) 00050 * are reported uniformly through the return value. 00051 * 00052 * Requires: 00053 *\li 'string' points to a null-terminated string 00054 *\li 0 <= 'base' <= 36 00055 * 00056 * Returns: 00057 *\li #ISC_R_SUCCESS 00058 *\li #ISC_R_BADNUMBER The string is not numeric (in the given base) 00059 *\li #ISC_R_RANGE The number is not representable as the requested type. 00060 */ 00061 00062 ISC_LANG_ENDDECLS 00063 00064 #endif /* ISC_PARSEINT_H */