00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <config.h>
00018 #include <stddef.h>
00019
00020 #include <isc/once.h>
00021 #include <isc/msgcat.h>
00022 #include <isc/util.h>
00023
00024 #include <pk11/result.h>
00025
00026 LIBISC_EXTERNAL_DATA isc_msgcat_t * pk11_msgcat = NULL;
00027
00028 static isc_once_t msgcat_once = ISC_ONCE_INIT;
00029
00030 static const char *text[PK11_R_NRESULTS] = {
00031 "PKCS#11 initialization failed",
00032 "no PKCS#11 provider",
00033 "PKCS#11 provider has no random service",
00034 "PKCS#11 provider has no digest service",
00035 "PKCS#11 provider has no AES service",
00036 };
00037
00038 #define PK11_RESULT_RESULTSET 2
00039
00040 static isc_once_t once = ISC_ONCE_INIT;
00041
00042 static void
00043 open_msgcat(void) {
00044 isc_msgcat_open("libpk11.cat", &pk11_msgcat);
00045 }
00046
00047 void
00048 pk11_initmsgcat(void) {
00049
00050
00051
00052
00053
00054
00055 RUNTIME_CHECK(isc_once_do(&msgcat_once, open_msgcat) == ISC_R_SUCCESS);
00056 }
00057
00058 static void
00059 initialize_action(void) {
00060 isc_result_t result;
00061
00062 result = isc_result_register(ISC_RESULTCLASS_PK11, PK11_R_NRESULTS,
00063 text, pk11_msgcat, PK11_RESULT_RESULTSET);
00064 if (result != ISC_R_SUCCESS)
00065 UNEXPECTED_ERROR(__FILE__, __LINE__,
00066 "isc_result_register() failed: %u", result);
00067 }
00068
00069 static void
00070 initialize(void) {
00071 pk11_initmsgcat();
00072 RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
00073 }
00074
00075 const char *
00076 pk11_result_totext(isc_result_t result) {
00077 initialize();
00078
00079 return (isc_result_totext(result));
00080 }
00081
00082 void
00083 pk11_result_register(void) {
00084 initialize();
00085 }