Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / ntp / dist / lib / isc / lib.c
blob77c382743b654ce9e34e5ff0a9a34ddbdb98e28d
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1999-2001 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: lib.c,v 1.14 2007/06/19 23:47:17 tbox Exp */
22 /*! \file */
24 #include <config.h>
26 #include <stdio.h>
27 #include <stdlib.h>
29 #include <isc/once.h>
30 #include <isc/msgs.h>
31 #include <isc/lib.h>
33 /***
34 *** Globals
35 ***/
37 LIBISC_EXTERNAL_DATA isc_msgcat_t * isc_msgcat = NULL;
40 /***
41 *** Private
42 ***/
44 static isc_once_t msgcat_once = ISC_ONCE_INIT;
47 /***
48 *** Functions
49 ***/
51 static void
52 open_msgcat(void) {
53 isc_msgcat_open("libisc.cat", &isc_msgcat);
56 void
57 isc_lib_initmsgcat(void) {
58 isc_result_t result;
60 /*!
61 * Initialize the ISC library's message catalog, isc_msgcat, if it
62 * has not already been initialized.
65 result = isc_once_do(&msgcat_once, open_msgcat);
66 if (result != ISC_R_SUCCESS) {
68 * Normally we'd use RUNTIME_CHECK() or FATAL_ERROR(), but
69 * we can't do that here, since they might call us!
70 * (Note that the catalog might be open anyway, so we might
71 * as well try to provide an internationalized message.)
73 fprintf(stderr, "%s:%d: %s: isc_once_do() %s.\n",
74 __FILE__, __LINE__,
75 isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
76 ISC_MSG_FATALERROR, "fatal error"),
77 isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
78 ISC_MSG_FAILED, "failed"));
79 abort();