10SN/A/* $NetBSD$ */ 211238Sjuh 30SN/A/* 40SN/A * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") 50SN/A * Copyright (C) 1999-2001 Internet Software Consortium. 60SN/A * 72362SN/A * Permission to use, copy, modify, and/or distribute this software for any 80SN/A * purpose with or without fee is hereby granted, provided that the above 92362SN/A * copyright notice and this permission notice appear in all copies. 100SN/A * 110SN/A * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 120SN/A * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 130SN/A * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 140SN/A * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 150SN/A * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 160SN/A * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 170SN/A * PERFORMANCE OF THIS SOFTWARE. 180SN/A */ 190SN/A 200SN/A/* Id: lib.c,v 1.14 2007/06/19 23:47:17 tbox Exp */ 212362SN/A 222362SN/A/*! \file */ 232362SN/A 240SN/A#include <config.h> 250SN/A 260SN/A#include <stdio.h> 270SN/A#include <stdlib.h> 280SN/A 290SN/A#include <isc/once.h> 300SN/A#include <isc/msgs.h> 310SN/A#include <isc/lib.h> 320SN/A 330SN/A/*** 340SN/A *** Globals 350SN/A ***/ 360SN/A 370SN/ALIBISC_EXTERNAL_DATA isc_msgcat_t * isc_msgcat = NULL; 380SN/A 390SN/A 400SN/A/*** 410SN/A *** Private 420SN/A ***/ 430SN/A 440SN/Astatic isc_once_t msgcat_once = ISC_ONCE_INIT; 450SN/A 460SN/A 470SN/A/*** 480SN/A *** Functions 490SN/A ***/ 500SN/A 510SN/Astatic void 520SN/Aopen_msgcat(void) { 530SN/A isc_msgcat_open("libisc.cat", &isc_msgcat); 540SN/A} 550SN/A 560SN/Avoid 570SN/Aisc_lib_initmsgcat(void) { 580SN/A isc_result_t result; 590SN/A 600SN/A /*! 610SN/A * Initialize the ISC library's message catalog, isc_msgcat, if it 620SN/A * has not already been initialized. 630SN/A */ 640SN/A 650SN/A result = isc_once_do(&msgcat_once, open_msgcat); 660SN/A if (result != ISC_R_SUCCESS) { 670SN/A /* 680SN/A * Normally we'd use RUNTIME_CHECK() or FATAL_ERROR(), but 690SN/A * we can't do that here, since they might call us! 700SN/A * (Note that the catalog might be open anyway, so we might 710SN/A * as well try to provide an internationalized message.) 720SN/A */ 730SN/A fprintf(stderr, "%s:%d: %s: isc_once_do() %s.\n", 740SN/A __FILE__, __LINE__, 750SN/A isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, 760SN/A ISC_MSG_FATALERROR, "fatal error"), 770SN/A isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, 780SN/A ISC_MSG_FAILED, "failed")); 790SN/A abort(); 800SN/A } 810SN/A} 820SN/A