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