xref: /minix/external/bsd/bind/dist/lib/dns/dst_result.c (revision 00b67f09)
1 /*	$NetBSD: dst_result.c,v 1.8 2014/12/10 04:37:58 christos Exp $	*/
2 
3 /*
4  * Copyright (C) 2004, 2005, 2007, 2008, 2012-2014  Internet Systems Consortium, Inc. ("ISC")
5  * Copyright (C) 1999-2001  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 DISCLAIMS ALL WARRANTIES WITH
12  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /*%
21  * Principal Author: Brian Wellington
22  * Id: dst_result.c,v 1.7 2008/04/01 23:47:10 tbox Exp
23  */
24 
25 #include <config.h>
26 
27 #include <isc/once.h>
28 #include <isc/util.h>
29 
30 #include <dst/result.h>
31 #include <dst/lib.h>
32 
33 static const char *text[DST_R_NRESULTS] = {
34 	"algorithm is unsupported",		/*%< 0 */
35 	"crypto failure",			/*%< 1 */
36 	"built with no crypto support",		/*%< 2 */
37 	"illegal operation for a null key",	/*%< 3 */
38 	"public key is invalid",		/*%< 4 */
39 	"private key is invalid",		/*%< 5 */
40 	"external key",				/*%< 6 */
41 	"error occurred writing key to disk",	/*%< 7 */
42 	"invalid algorithm specific parameter",	/*%< 8 */
43 	"UNUSED9",				/*%< 9 */
44 	"UNUSED10",				/*%< 10 */
45 	"sign failure",				/*%< 11 */
46 	"UNUSED12",				/*%< 12 */
47 	"UNUSED13",				/*%< 13 */
48 	"verify failure",			/*%< 14 */
49 	"not a public key",			/*%< 15 */
50 	"not a private key",			/*%< 16 */
51 	"not a key that can compute a secret",	/*%< 17 */
52 	"failure computing a shared secret",	/*%< 18 */
53 	"no randomness available",		/*%< 19 */
54 	"bad key type",				/*%< 20 */
55 	"no engine",				/*%< 21 */
56 	"illegal operation for an external key",/*%< 22 */
57 };
58 
59 #define DST_RESULT_RESULTSET			2
60 
61 static isc_once_t		once = ISC_ONCE_INIT;
62 
63 static void
initialize_action(void)64 initialize_action(void) {
65 	isc_result_t result;
66 
67 	result = isc_result_register(ISC_RESULTCLASS_DST, DST_R_NRESULTS,
68 				     text, dst_msgcat, DST_RESULT_RESULTSET);
69 	if (result != ISC_R_SUCCESS)
70 		UNEXPECTED_ERROR(__FILE__, __LINE__,
71 				 "isc_result_register() failed: %u", result);
72 }
73 
74 static void
initialize(void)75 initialize(void) {
76 	dst_lib_initmsgcat();
77 	RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
78 }
79 
80 const char *
dst_result_totext(isc_result_t result)81 dst_result_totext(isc_result_t result) {
82 	initialize();
83 
84 	return (isc_result_totext(result));
85 }
86 
87 void
dst_result_register(void)88 dst_result_register(void) {
89 	initialize();
90 }
91 
92 /*! \file */
93