/contrib/bind9/lib/isc/include/isc/parseint.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 64 lines · 13 code · 11 blank · 40 comment · 0 complexity · 308ea08947ef42bf04cb382966e1f951 MD5 · raw file

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