Home | History | Annotate | Line # | Download | only in isc
lib.c revision 1.2.2.3
      1 /*	$NetBSD: lib.c,v 1.2.2.3 2019/01/18 08:49:57 pgoyette Exp $	*/
      2 
      3 /*
      4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
      5  *
      6  * This Source Code Form is subject to the terms of the Mozilla Public
      7  * License, v. 2.0. If a copy of the MPL was not distributed with this
      8  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
      9  *
     10  * See the COPYRIGHT file distributed with this work for additional
     11  * information regarding copyright ownership.
     12  */
     13 
     14 
     15 /*! \file */
     16 
     17 #include <config.h>
     18 
     19 #include <stdio.h>
     20 #include <stdlib.h>
     21 
     22 #include <openssl/evp.h>
     23 
     24 #include <isc/app.h>
     25 #include <isc/lib.h>
     26 #include <isc/mem.h>
     27 #include <isc/msgs.h>
     28 #include <isc/once.h>
     29 #include <isc/print.h>
     30 #include <isc/socket.h>
     31 #include <isc/task.h>
     32 #include <isc/timer.h>
     33 #include <isc/util.h>
     34 
     35 /***
     36  *** Globals
     37  ***/
     38 
     39 LIBISC_EXTERNAL_DATA isc_msgcat_t *		isc_msgcat = NULL;
     40 
     41 
     42 /***
     43  *** Private
     44  ***/
     45 
     46 static isc_once_t		msgcat_once = ISC_ONCE_INIT;
     47 
     48 /***
     49  *** Functions
     50  ***/
     51 
     52 static void
     53 open_msgcat(void) {
     54 	isc_msgcat_open("libisc.cat", &isc_msgcat);
     55 }
     56 
     57 void
     58 isc_lib_initmsgcat(void) {
     59 	isc_result_t result;
     60 
     61 	/*!
     62 	 * Initialize the ISC library's message catalog, isc_msgcat, if it
     63 	 * has not already been initialized.
     64 	 */
     65 
     66 	result = isc_once_do(&msgcat_once, open_msgcat);
     67 	if (result != ISC_R_SUCCESS) {
     68 		/*
     69 		 * Normally we'd use RUNTIME_CHECK() or FATAL_ERROR(), but
     70 		 * we can't do that here, since they might call us!
     71 		 * (Note that the catalog might be open anyway, so we might
     72 		 * as well try to  provide an internationalized message.)
     73 		 */
     74 		fprintf(stderr, "%s:%d: %s: isc_once_do() %s.\n",
     75 			__FILE__, __LINE__,
     76 			isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
     77 				       ISC_MSG_FATALERROR, "fatal error"),
     78 			isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
     79 				       ISC_MSG_FAILED, "failed"));
     80 		abort();
     81 	}
     82 }
     83 
     84 void
     85 isc_lib_register(void) {
     86 	isc_bind9 = false;
     87 }
     88