/contrib/bind9/lib/isccc/result.c

https://bitbucket.org/freebsd/freebsd-head/ · C · 85 lines · 39 code · 14 blank · 32 comment · 3 complexity · 19d07aa8bc72caa6236865a7ffb68366 MD5 · raw file

  1. /*
  2. * Portions Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
  3. * Portions Copyright (C) 2001, 2003 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 AND NOMINUM DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
  11. * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY
  12. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. *
  17. * Portions Copyright (C) 2001 Nominum, Inc.
  18. *
  19. * Permission to use, copy, modify, and/or distribute this software for any
  20. * purpose with or without fee is hereby granted, provided that the above
  21. * copyright notice and this permission notice appear in all copies.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL
  24. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
  25. * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY
  26. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  27. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  28. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  29. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  30. */
  31. /* $Id: result.c,v 1.10 2007/08/28 07:20:43 tbox Exp $ */
  32. /*! \file */
  33. #include <config.h>
  34. #include <isc/once.h>
  35. #include <isc/util.h>
  36. #include <isccc/result.h>
  37. #include <isccc/lib.h>
  38. static const char *text[ISCCC_R_NRESULTS] = {
  39. "unknown version", /* 1 */
  40. "syntax error", /* 2 */
  41. "bad auth", /* 3 */
  42. "expired", /* 4 */
  43. "clock skew", /* 5 */
  44. "duplicate" /* 6 */
  45. };
  46. #define ISCCC_RESULT_RESULTSET 2
  47. static isc_once_t once = ISC_ONCE_INIT;
  48. static void
  49. initialize_action(void) {
  50. isc_result_t result;
  51. result = isc_result_register(ISC_RESULTCLASS_ISCCC, ISCCC_R_NRESULTS,
  52. text, isccc_msgcat,
  53. ISCCC_RESULT_RESULTSET);
  54. if (result != ISC_R_SUCCESS)
  55. UNEXPECTED_ERROR(__FILE__, __LINE__,
  56. "isc_result_register() failed: %u", result);
  57. }
  58. static void
  59. initialize(void) {
  60. isccc_lib_initmsgcat();
  61. RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
  62. }
  63. const char *
  64. isccc_result_totext(isc_result_t result) {
  65. initialize();
  66. return (isc_result_totext(result));
  67. }
  68. void
  69. isccc_result_register(void) {
  70. initialize();
  71. }