1 /*
2 * Copyright (C) 2004, 2005, 2007, 2008, 2012, 2013 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2001 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
18 /*%
19 * Principal Author: Brian Wellington
20 * $Id: dst_result.c,v 1.7 2008/04/01 23:47:10 tbox Exp $
21 */
22
23 #include <config.h>
24
25 #include <isc/once.h>
26 #include <isc/util.h>
27
28 #include <dst/result.h>
29 #include <dst/lib.h>
30
31 static const char *text[DST_R_NRESULTS] = {
32 "algorithm is unsupported", /*%< 0 */
33 "crypto failure", /*%< 1 */
34 "built with no crypto support", /*%< 2 */
35 "illegal operation for a null key", /*%< 3 */
36 "public key is invalid", /*%< 4 */
37 "private key is invalid", /*%< 5 */
38 "external key", /*%< 6 */
39 "error occurred writing key to disk", /*%< 7 */
40 "invalid algorithm specific parameter", /*%< 8 */
41 "UNUSED9", /*%< 9 */
42 "UNUSED10", /*%< 10 */
43 "sign failure", /*%< 11 */
44 "UNUSED12", /*%< 12 */
45 "UNUSED13", /*%< 13 */
46 "verify failure", /*%< 14 */
47 "not a public key", /*%< 15 */
48 "not a private key", /*%< 16 */
49 "not a key that can compute a secret", /*%< 17 */
50 "failure computing a shared secret", /*%< 18 */
51 "no randomness available", /*%< 19 */
52 "bad key type", /*%< 20 */
53 "no engine" /*%< 21 */
54 };
55
56 #define DST_RESULT_RESULTSET 2
57
58 static isc_once_t once = ISC_ONCE_INIT;
59
60 static void
initialize_action(void)61 initialize_action(void) {
62 isc_result_t result;
63
64 result = isc_result_register(ISC_RESULTCLASS_DST, DST_R_NRESULTS,
65 text, dst_msgcat, DST_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 dst_lib_initmsgcat();
74 RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
75 }
76
77 const char *
dst_result_totext(isc_result_t result)78 dst_result_totext(isc_result_t result) {
79 initialize();
80
81 return (isc_result_totext(result));
82 }
83
84 void
dst_result_register(void)85 dst_result_register(void) {
86 initialize();
87 }
88
89 /*! \file */
90