"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/lib/isc/pk11_result.c" (7 Sep 2020, 2315 Bytes) of package /linux/misc/dns/bind9/9.11.23/bind-9.11.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "pk11_result.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 #include <config.h>
   13 #include <stddef.h>
   14 
   15 #include <isc/once.h>
   16 #include <isc/msgcat.h>
   17 #include <isc/util.h>
   18 
   19 #include <pk11/result.h>
   20 
   21 LIBISC_EXTERNAL_DATA isc_msgcat_t *     pk11_msgcat = NULL;
   22 
   23 static isc_once_t       msgcat_once = ISC_ONCE_INIT;
   24 
   25 static const char *text[PK11_R_NRESULTS] = {
   26     "PKCS#11 initialization failed",        /*%< 0 */
   27     "no PKCS#11 provider",              /*%< 1 */
   28     "PKCS#11 provider has no random service",   /*%< 2 */
   29     "PKCS#11 provider has no digest service",   /*%< 3 */
   30     "PKCS#11 provider has no AES service",      /*%< 4 */
   31 };
   32 
   33 static const char *ids[PK11_R_NRESULTS] = {
   34     "PK11_R_INITFAILED",
   35     "PK11_R_NOPROVIDER",
   36     "PK11_R_NORANDOMSERVICE",
   37     "PK11_R_NODIGESTSERVICE",
   38     "PK11_R_NOAESSERVICE",
   39 };
   40 
   41 #define PK11_RESULT_RESULTSET           2
   42 
   43 static isc_once_t       once = ISC_ONCE_INIT;
   44 
   45 static void
   46 open_msgcat(void) {
   47     isc_msgcat_open("libpk11.cat", &pk11_msgcat);
   48 }
   49 
   50 void
   51 pk11_initmsgcat(void) {
   52 
   53     /*
   54      * Initialize the PKCS#11 support's message catalog,
   55      * pk11_msgcat, if it has not already been initialized.
   56      */
   57 
   58     RUNTIME_CHECK(isc_once_do(&msgcat_once, open_msgcat) == ISC_R_SUCCESS);
   59 }
   60 
   61 static void
   62 initialize_action(void) {
   63     isc_result_t result;
   64 
   65     result = isc_result_register(ISC_RESULTCLASS_PK11, PK11_R_NRESULTS,
   66                      text, pk11_msgcat, PK11_RESULT_RESULTSET);
   67     if (result != ISC_R_SUCCESS)
   68         UNEXPECTED_ERROR(__FILE__, __LINE__,
   69                  "isc_result_register() failed: %u", result);
   70 
   71     result = isc_result_registerids(ISC_RESULTCLASS_PK11, PK11_R_NRESULTS,
   72                     ids, pk11_msgcat,
   73                     PK11_RESULT_RESULTSET);
   74     if (result != ISC_R_SUCCESS)
   75         UNEXPECTED_ERROR(__FILE__, __LINE__,
   76                  "isc_result_registerids() failed: %u", result);
   77 }
   78 
   79 static void
   80 initialize(void) {
   81     pk11_initmsgcat();
   82     RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
   83 }
   84 
   85 const char *
   86 pk11_result_totext(isc_result_t result) {
   87     initialize();
   88 
   89     return (isc_result_totext(result));
   90 }
   91 
   92 void
   93 pk11_result_register(void) {
   94     initialize();
   95 }