put msgcat init in lib.c
This commit is contained in:
@@ -33,15 +33,15 @@ CWARNINGS =
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Alphabetically
|
||||
OBJS = callbacks.o compress.o db.o dbiterator.o dbtable.o \
|
||||
master.o message.o name.o rbt.o rbtdb.o rbtdb64.o \
|
||||
OBJS = callbacks.o compress.o db.o dbiterator.o dbtable.o dispatch.o \
|
||||
lib.o master.o message.o name.o rbt.o rbtdb.o rbtdb64.o \
|
||||
rdata.o rdatalist.o rdataset.o rdatasetiter.o rdataslab.o \
|
||||
result.o version.o masterdump.o time.o ttl.o dispatch.o
|
||||
resolver.o result.o version.o masterdump.o time.o ttl.o
|
||||
|
||||
OSRC = callbacks.c compress.c db.c dbiterator.c dbtable.c \
|
||||
master.c name.c rbt.c rbtdb.c rbtdb64.c \
|
||||
OSRC = callbacks.c compress.c db.c dbiterator.c dbtable.c dispatch.c \
|
||||
lib.c master.c name.c rbt.c rbtdb.c rbtdb64.c \
|
||||
rdata.c rdatalist.c rdataset.c rdatasetiter.c rdataslab.c \
|
||||
result.c version.c masterdump.c time.c ttl.c dispatch.c
|
||||
resolver.c result.c version.c masterdump.c time.c ttl.c
|
||||
|
||||
SUBDIRS = include
|
||||
TARGETS = include/dns/enumtype.h include/dns/enumclass.h \
|
||||
|
||||
@@ -20,7 +20,7 @@ top_srcdir = @top_srcdir@
|
||||
@BIND9_VERSION@
|
||||
|
||||
HEADERS = callbacks.h cert.h compress.h db.h dbiterator.h dbtable.h \
|
||||
events.h dispatch.h events.h fixedname.h master.h \
|
||||
events.h dispatch.h events.h fixedname.h lib.h master.h \
|
||||
masterdump.h message.h name.h rbt.h rcode.h rdata.h \
|
||||
rdataclass.h rdatalist.h rdataset.h rdatasetiter.h \
|
||||
rdataslab.h rdatatype.h result.h secalg.h tcpmsg.h time.h \
|
||||
|
||||
37
lib/dns/include/dns/lib.h
Normal file
37
lib/dns/include/dns/lib.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 1999 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef DNS_LIB_H
|
||||
#define DNS_LIB_H 1
|
||||
|
||||
#include <isc/types.h>
|
||||
#include <isc/lang.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
extern isc_msgcat_t *dns_msgcat;
|
||||
|
||||
void
|
||||
dns_lib_initmsgcat(void);
|
||||
/*
|
||||
* Initialize the DNS library's message catalog, dns_msgcat, if it
|
||||
* has not already been initialized.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* DNS_LIB_H */
|
||||
60
lib/dns/lib.c
Normal file
60
lib/dns/lib.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 1999 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <isc/once.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/msgcat.h>
|
||||
|
||||
#include <dns/lib.h>
|
||||
|
||||
/***
|
||||
*** Globals
|
||||
***/
|
||||
|
||||
isc_msgcat_t * dns_msgcat = NULL;
|
||||
|
||||
|
||||
/***
|
||||
*** Private
|
||||
***/
|
||||
|
||||
static isc_once_t msgcat_once = ISC_ONCE_INIT;
|
||||
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
static void
|
||||
open_msgcat(void) {
|
||||
isc_msgcat_open("libdns.cat", &dns_msgcat);
|
||||
}
|
||||
|
||||
void
|
||||
dns_lib_initmsgcat(void) {
|
||||
|
||||
/*
|
||||
* Initialize the DNS library's message catalog, dns_msgcat, if it
|
||||
* has not already been initialized.
|
||||
*/
|
||||
|
||||
RUNTIME_CHECK(isc_once_do(&msgcat_once, open_msgcat) == ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -22,7 +22,9 @@
|
||||
#include <isc/resultclass.h>
|
||||
#include <isc/once.h>
|
||||
#include <isc/error.h>
|
||||
|
||||
#include <dns/result.h>
|
||||
#include <dns/lib.h>
|
||||
|
||||
static char *text[DNS_R_NRESULTS] = {
|
||||
"success", /* 0 */
|
||||
@@ -80,13 +82,11 @@ static char *text[DNS_R_NRESULTS] = {
|
||||
#define DNS_RESULT_RESULTSET 2
|
||||
|
||||
static isc_once_t once = ISC_ONCE_INIT;
|
||||
static isc_msgcat_t * dns_msgcat = NULL;
|
||||
|
||||
static void
|
||||
initialize_action(void) {
|
||||
isc_result_t result;
|
||||
|
||||
isc_msgcat_open("libdns.cat", &dns_msgcat);
|
||||
result = isc_result_register(ISC_RESULTCLASS_DNS, DNS_R_NRESULTS,
|
||||
text, dns_msgcat, DNS_RESULT_RESULTSET);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
@@ -96,6 +96,7 @@ initialize_action(void) {
|
||||
|
||||
static void
|
||||
initialize(void) {
|
||||
dns_lib_initmsgcat();
|
||||
RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ CDEFINES =
|
||||
CWARNINGS =
|
||||
|
||||
OBJS = @ISC_EXTRA_OBJS@ \
|
||||
assertions.o base64.o buffer.o error.o heap.o lex.o mem.o \
|
||||
result.o rwlock.o symtab.o str.o event.o task.o timer.o \
|
||||
assertions.o base64.o buffer.o error.o heap.o lex.o lib.o \
|
||||
mem.o result.o rwlock.o symtab.o str.o event.o task.o timer.o \
|
||||
version.o \
|
||||
unix/app.o unix/time.o unix/stdtime.o unix/socket.o \
|
||||
unix/interfaceiter.o nls/msgcat.o pthreads/condition.o
|
||||
|
||||
@@ -23,7 +23,7 @@ top_srcdir = @top_srcdir@
|
||||
# Note: inet.h has been intentionally left off the HEADERS list.
|
||||
#
|
||||
HEADERS = assertions.h base64.h boolean.h buffer.h error.h event.h \
|
||||
eventclass.h heap.h int.h interfaceiter.h lang.h lex.h \
|
||||
eventclass.h heap.h int.h interfaceiter.h lang.h lex.h lib.h \
|
||||
list.h mem.h msgcat.h rbtgen.h region.h result.h \
|
||||
resultclass.h rwlock.h socket.h str.h symtab.h task.h \
|
||||
timer.h types.h
|
||||
|
||||
37
lib/isc/include/isc/lib.h
Normal file
37
lib/isc/include/isc/lib.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 1999 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef ISC_LIB_H
|
||||
#define ISC_LIB_H 1
|
||||
|
||||
#include <isc/types.h>
|
||||
#include <isc/lang.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
extern isc_msgcat_t *isc_msgcat;
|
||||
|
||||
void
|
||||
isc_lib_initmsgcat(void);
|
||||
/*
|
||||
* Initialize the ISC library's message catalog, isc_msgcat, if it
|
||||
* has not already been initialized.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_LIB_H */
|
||||
71
lib/isc/lib.c
Normal file
71
lib/isc/lib.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 1999 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <isc/once.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/msgcat.h>
|
||||
#include <isc/lib.h>
|
||||
|
||||
/***
|
||||
*** Globals
|
||||
***/
|
||||
|
||||
isc_msgcat_t * isc_msgcat = NULL;
|
||||
|
||||
|
||||
/***
|
||||
*** Private
|
||||
***/
|
||||
|
||||
static isc_once_t msgcat_once = ISC_ONCE_INIT;
|
||||
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
static void
|
||||
open_msgcat(void) {
|
||||
isc_msgcat_open("libisc.cat", &isc_msgcat);
|
||||
}
|
||||
|
||||
void
|
||||
isc_lib_initmsgcat(void) {
|
||||
isc_result_t result;
|
||||
|
||||
/*
|
||||
* Initialize the ISC library's message catalog, isc_msgcat, if it
|
||||
* has not already been initialized.
|
||||
*/
|
||||
|
||||
result = isc_once_do(&msgcat_once, open_msgcat);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
/*
|
||||
* Normally we'd use RUNTIME_CHECK() or FATAL_ERROR(), but
|
||||
* we can't do that here, since they might call us!
|
||||
*/
|
||||
fprintf(stderr, "%s:%d: fatal error: isc_once_do() failed.\n",
|
||||
__FILE__, __LINE__);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/once.h>
|
||||
#include <isc/msgcat.h>
|
||||
#include <isc/lib.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
@@ -81,7 +82,6 @@ static char *text[ISC_R_NRESULTS] = {
|
||||
#define ISC_RESULT_UNAVAILABLESET 3
|
||||
|
||||
static isc_once_t once = ISC_ONCE_INIT;
|
||||
static isc_msgcat_t * isc_msgcat = NULL;
|
||||
static ISC_LIST(resulttable) tables;
|
||||
static isc_mutex_t lock;
|
||||
|
||||
@@ -125,7 +125,6 @@ initialize_action(void) {
|
||||
RUNTIME_CHECK(isc_mutex_init(&lock) == ISC_R_SUCCESS);
|
||||
ISC_LIST_INIT(tables);
|
||||
|
||||
isc_msgcat_open("libisc.cat", &isc_msgcat);
|
||||
result = register_table(ISC_RESULTCLASS_ISC, ISC_R_NRESULTS, text,
|
||||
isc_msgcat, ISC_RESULT_RESULTSET);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
@@ -135,6 +134,7 @@ initialize_action(void) {
|
||||
|
||||
static void
|
||||
initialize(void) {
|
||||
isc_lib_initmsgcat();
|
||||
RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user