Import of bind-9.3.2-P1
[dragonfly.git] / contrib / bind-9.3 / lib / dns / dst_result.c
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and 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.1.4.1 2004/12/09 04:07:17 marka 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         "openssl 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         "UNUSED6",                              /*  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 };
54
55 #define DST_RESULT_RESULTSET                    2
56
57 static isc_once_t               once = ISC_ONCE_INIT;
58
59 static void
60 initialize_action(void) {
61         isc_result_t result;
62
63         result = isc_result_register(ISC_RESULTCLASS_DST, DST_R_NRESULTS,
64                                      text, dst_msgcat, DST_RESULT_RESULTSET);
65         if (result != ISC_R_SUCCESS)
66                 UNEXPECTED_ERROR(__FILE__, __LINE__,
67                                  "isc_result_register() failed: %u", result);
68 }
69
70 static void
71 initialize(void) {
72         dst_lib_initmsgcat();
73         RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
74 }
75
76 const char *
77 dst_result_totext(isc_result_t result) {
78         initialize();
79
80         return (isc_result_totext(result));
81 }
82
83 void
84 dst_result_register(void) {
85         initialize();
86 }