diff --git a/acconfig.h b/acconfig.h index 83e749fdb5..794fa5fffb 100644 --- a/acconfig.h +++ b/acconfig.h @@ -44,3 +44,6 @@ /* define if LinuxThreads is in use */ #undef HAVE_LINUXTHREADS + +/* define if catgets() is available */ +#undef HAVE_CATGETS diff --git a/config.h.in b/config.h.in index dc890fc9c5..561670777a 100644 --- a/config.h.in +++ b/config.h.in @@ -30,9 +30,6 @@ /* define if your struct sockaddr has a sa_len member */ #undef HAVE_SA_LEN -/* define on DEC OSF to enable 4.4BSD style sa_len support */ -#undef _SOCKADDR_LEN - /* define if your system needs pthread_init() before using pthreads */ #undef NEED_PTHREAD_INIT @@ -45,6 +42,9 @@ /* define if LinuxThreads is in use */ #undef HAVE_LINUXTHREADS +/* define if catgets() is available */ +#undef HAVE_CATGETS + /* Define if you have the header file. */ #undef HAVE_FCNTL_H diff --git a/configure b/configure index e2167a78ff..058ea8c32d 100755 --- a/configure +++ b/configure @@ -1,11 +1,11 @@ #! /bin/sh -# From configure.in Revision: 1.27 +# From configure.in Revision: 1.29 # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13 +# Generated automatically using autoconf version 2.12 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -57,7 +57,6 @@ mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 @@ -341,7 +340,7 @@ EOF verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.13" + echo "configure generated by autoconf version 2.12" exit 0 ;; -with-* | --with-*) @@ -511,11 +510,9 @@ ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross -ac_exeext= -ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then @@ -552,26 +549,26 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # Make sure we can run config.sub. -if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : +if $ac_config_sub sun4 >/dev/null 2>&1; then : else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:561: checking host system type" >&5 +echo "configure:558: checking host system type" >&5 host_alias=$host case "$host_alias" in NONE) case $nonopt in NONE) - if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : + if host_alias=`$ac_config_guess`; then : else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } fi ;; *) host_alias=$nonopt ;; esac ;; esac -host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` +host=`$ac_config_sub $host_alias` host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` @@ -579,7 +576,7 @@ echo "$ac_t""$host" 1>&6 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:583: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:580: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -608,16 +605,15 @@ fi # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:612: checking for $ac_word" >&5 +echo "configure:609: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_RANLIB="ranlib" @@ -642,30 +638,28 @@ fi # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:651: checking for a BSD compatible install" >&5 +echo "configure:646: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do + for ac_prog in ginstall installbsd scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. + # OSF/1 installbsd also uses dspmsg, but is usable. : else ac_cv_path_install="$ac_dir/$ac_prog -c" @@ -695,8 +689,6 @@ echo "$ac_t""$INSTALL" 1>&6 # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' - test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' @@ -729,7 +721,7 @@ case "$host" in *-netbsd*) CC="gcc" echo $ac_n "checking which thread library to use""... $ac_c" 1>&6 -echo "configure:733: checking which thread library to use" >&5 +echo "configure:725: checking which thread library to use" >&5 # Check whether --with-mit-pthreads or --without-mit-pthreads was given. if test "${with_mit_pthreads+set}" = set; then @@ -792,16 +784,15 @@ esac # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:796: checking for $ac_word" >&5 +echo "configure:788: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" @@ -822,17 +813,16 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:826: checking for $ac_word" >&5 +echo "configure:817: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" ac_prog_rejected=no - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do + for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then @@ -867,61 +857,25 @@ else echo "$ac_t""no" 1>&6 fi - if test -z "$CC"; then - case "`uname -s`" in - *win32* | *WIN32*) - # Extract the first word of "cl", so it can be a program name with args. -set dummy cl; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:877: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="cl" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - ;; - esac - fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:909: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:865: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross -cat > conftest.$ac_ext << EOF - -#line 920 "configure" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:879: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -935,24 +889,18 @@ else ac_cv_prog_cc_works=no fi rm -fr conftest* -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:951: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:899: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:956: checking whether we are using GNU C" >&5 +echo "configure:904: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -961,7 +909,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:965: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:913: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -972,15 +920,11 @@ echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes -else - GCC= -fi - -ac_test_CFLAGS="${CFLAGS+set}" -ac_save_CFLAGS="$CFLAGS" -CFLAGS= -echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:984: checking whether ${CC-cc} accepts -g" >&5 + ac_test_CFLAGS="${CFLAGS+set}" + ac_save_CFLAGS="$CFLAGS" + CFLAGS= + echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:928: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -995,20 +939,16 @@ rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 -if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then + if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" + elif test $ac_cv_prog_cc_g = yes; then CFLAGS="-g -O2" else - CFLAGS="-g" + CFLAGS="-O2" fi else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi + GCC= + test "${CFLAGS+set}" = set || CFLAGS="-g" fi for ac_prog in 'bison -y' byacc @@ -1016,16 +956,15 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1020: checking for $ac_word" >&5 +echo "configure:960: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$YACC"; then ac_cv_prog_YACC="$YACC" # Let the user override the test. else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_YACC="$ac_prog" @@ -1048,7 +987,7 @@ test -n "$YACC" || YACC="yacc" echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1052: checking how to run the C preprocessor" >&5 +echo "configure:991: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1063,14 +1002,14 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1073: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +{ (eval echo configure:1012: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then : else @@ -1080,31 +1019,14 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1090: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -nologo -E" - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1107: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +{ (eval echo configure:1029: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then : else @@ -1116,8 +1038,6 @@ else fi rm -f conftest* fi -rm -f conftest* -fi rm -f conftest* ac_cv_prog_CPP="$CPP" fi @@ -1128,12 +1048,12 @@ fi echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1132: checking for ANSI C header files" >&5 +echo "configure:1052: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1141,8 +1061,8 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1145: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +{ (eval echo configure:1065: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* ac_cv_header_stdc=yes @@ -1158,7 +1078,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1176,7 +1096,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1197,7 +1117,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1208,7 +1128,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:1212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1132: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then : else @@ -1235,18 +1155,18 @@ for ac_hdr in fcntl.h sys/time.h unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1239: checking for $ac_hdr" >&5 +echo "configure:1159: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1249: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +{ (eval echo configure:1169: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" @@ -1273,12 +1193,12 @@ done echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1277: checking for working const" >&5 +echo "configure:1197: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1251: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -1348,21 +1268,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:1352: checking for inline" >&5 +echo "configure:1272: checking for inline" >&5 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1286: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -1388,12 +1308,12 @@ EOF esac echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:1392: checking for size_t" >&5 +echo "configure:1312: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -1402,7 +1322,7 @@ else #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + egrep "size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then rm -rf conftest* ac_cv_type_size_t=yes else @@ -1421,12 +1341,12 @@ EOF fi echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:1425: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:1345: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1435,7 +1355,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:1439: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1359: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -1457,7 +1377,7 @@ fi echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:1461: checking for pthread_create in -lpthread" >&5 +echo "configure:1381: checking for pthread_create in -lpthread" >&5 ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1465,7 +1385,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1400: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1502,7 +1422,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for __pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:1506: checking for __pthread_create in -lpthread" >&5 +echo "configure:1426: checking for __pthread_create in -lpthread" >&5 ac_lib_var=`echo pthread'_'__pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1510,7 +1430,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1445: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1549,7 +1469,7 @@ else fi echo $ac_n "checking for __pthread_create_system in -lpthread""... $ac_c" 1>&6 -echo "configure:1553: checking for __pthread_create_system in -lpthread" >&5 +echo "configure:1473: checking for __pthread_create_system in -lpthread" >&5 ac_lib_var=`echo pthread'_'__pthread_create_system | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1557,7 +1477,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1492: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1602,7 +1522,7 @@ fi if test "$ac_cv_lib_pthread" != "yes"; then echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6 -echo "configure:1606: checking for pthread_create in -lc_r" >&5 +echo "configure:1526: checking for pthread_create in -lc_r" >&5 ac_lib_var=`echo c_r'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1610,7 +1530,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lc_r $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1652,7 +1572,7 @@ fi echo $ac_n "checking for sigwait in -lpthread""... $ac_c" 1>&6 -echo "configure:1656: checking for sigwait in -lpthread" >&5 +echo "configure:1576: checking for sigwait in -lpthread" >&5 ac_lib_var=`echo pthread'_'sigwait | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1660,7 +1580,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1693,7 +1613,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for _Psigwait in -lpthread""... $ac_c" 1>&6 -echo "configure:1697: checking for _Psigwait in -lpthread" >&5 +echo "configure:1617: checking for _Psigwait in -lpthread" >&5 ac_lib_var=`echo pthread'_'_Psigwait | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1701,7 +1621,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1748,6 +1668,58 @@ EOF ;; esac +echo $ac_n "checking for catgets""... $ac_c" 1>&6 +echo "configure:1673: checking for catgets" >&5 +if eval "test \"`echo '$''{'ac_cv_func_catgets'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char catgets(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_catgets) || defined (__stub___catgets) +choke me +#else +catgets(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1701: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_func_catgets=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_catgets=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'catgets`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_CATGETS 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi + + case "$host" in *-bsdi3.1*) cat >> confdefs.h <<\EOF @@ -1769,7 +1741,7 @@ case "$host" in ;; *) echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 -echo "configure:1773: checking for socket in -lsocket" >&5 +echo "configure:1745: checking for socket in -lsocket" >&5 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1777,7 +1749,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1816,7 +1788,7 @@ else fi echo $ac_n "checking for inet_ntoa in -lnsl""... $ac_c" 1>&6 -echo "configure:1820: checking for inet_ntoa in -lnsl" >&5 +echo "configure:1792: checking for inet_ntoa in -lnsl" >&5 ac_lib_var=`echo nsl'_'inet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1824,7 +1796,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1811: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1866,12 +1838,12 @@ fi esac echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6 -echo "configure:1870: checking for inet_ntop" >&5 +echo "configure:1842: checking for inet_ntop" >&5 if eval "test \"`echo '$''{'ac_cv_func_inet_ntop'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1870: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_inet_ntop=yes" else @@ -1921,12 +1893,12 @@ EOF fi echo $ac_n "checking for inet_pton""... $ac_c" 1>&6 -echo "configure:1925: checking for inet_pton" >&5 +echo "configure:1897: checking for inet_pton" >&5 if eval "test \"`echo '$''{'ac_cv_func_inet_pton'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_inet_pton=yes" else @@ -1976,12 +1948,12 @@ EOF fi echo $ac_n "checking for inet_aton""... $ac_c" 1>&6 -echo "configure:1980: checking for inet_aton" >&5 +echo "configure:1952: checking for inet_aton" >&5 if eval "test \"`echo '$''{'ac_cv_func_inet_aton'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1980: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_inet_aton=yes" else @@ -2071,9 +2043,9 @@ esac echo $ac_n "checking for sa_len in struct sockaddr""... $ac_c" 1>&6 -echo "configure:2075: checking for sa_len in struct sockaddr" >&5 +echo "configure:2047: checking for sa_len in struct sockaddr" >&5 cat > conftest.$ac_ext < EOF @@ -2124,7 +2096,7 @@ EOF # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in + case `(ac_space=' '; set) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). @@ -2191,7 +2163,7 @@ do echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.13" + echo "$CONFIG_STATUS generated by autoconf version 2.12" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -2212,6 +2184,7 @@ trap 'rm -fr `echo "make/rules lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile + lib/isc/nls/Makefile lib/isc/pthreads/Makefile lib/isc/pthreads/include/Makefile lib/isc/pthreads/include/isc/Makefile @@ -2236,11 +2209,9 @@ sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF $ac_vpsub $extrasub -s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g -s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g @@ -2267,7 +2238,6 @@ s%@host_os@%$host_os%g s%@SET_MAKE@%$SET_MAKE%g s%@RANLIB@%$RANLIB%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@STD_CINCLUDES@%$STD_CINCLUDES%g s%@STD_CDEFINES@%$STD_CDEFINES%g @@ -2332,6 +2302,7 @@ CONFIG_FILES=\${CONFIG_FILES-"make/rules lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile + lib/isc/nls/Makefile lib/isc/pthreads/Makefile lib/isc/pthreads/include/Makefile lib/isc/pthreads/include/isc/Makefile diff --git a/configure.in b/configure.in index cb78901ec7..320b93d054 100644 --- a/configure.in +++ b/configure.in @@ -13,7 +13,7 @@ dnl PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS dnl ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS dnl SOFTWARE. -AC_REVISION($Revision: 1.28 $) +AC_REVISION($Revision: 1.29 $) AC_PREREQ(2.12) @@ -142,7 +142,7 @@ AC_CHECK_LIB(pthread, pthread_create,, dnl For FreeBSD which has no libpthread but instead libc_r if test "$ac_cv_lib_pthread" != "yes"; then - AC_CHECK_LIB(c_r,pthread_create) + AC_CHECK_LIB(c_r, pthread_create) fi @@ -164,6 +164,11 @@ case "$host" in ;; esac +dnl +dnl NLS +dnl +AC_CHECK_FUNC(catgets, AC_DEFINE(HAVE_CATGETS),) + dnl dnl BSDI 3.1 needs pthread_init() to be called before certain pthreads dnl calls. LinuxThreads requires some changes to the way we deal with @@ -282,6 +287,7 @@ AC_OUTPUT( lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile + lib/isc/nls/Makefile lib/isc/pthreads/Makefile lib/isc/pthreads/include/Makefile lib/isc/pthreads/include/isc/Makefile diff --git a/lib/dns/result.c b/lib/dns/result.c index 29b76ef1bc..6a1f6de739 100644 --- a/lib/dns/result.c +++ b/lib/dns/result.c @@ -77,14 +77,16 @@ static char *text[DNS_R_NRESULTS] = { "unexpected error", /* 49 */ }; -static isc_once_t once = ISC_ONCE_INIT; +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); + text, dns_msgcat, 2); if (result != ISC_R_SUCCESS) UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_result_register() failed: %u", result); diff --git a/lib/isc/Makefile.in b/lib/isc/Makefile.in index d2d5ea5fd6..3ea72ec9ce 100644 --- a/lib/isc/Makefile.in +++ b/lib/isc/Makefile.in @@ -30,9 +30,9 @@ OBJS = @ISC_EXTRA_OBJS@ \ 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 \ - pthreads/condition.o unix/interfaceiter.o + unix/interfaceiter.o nls/msgcat.o pthreads/condition.o -SUBDIRS = include unix pthreads +SUBDIRS = include unix nls pthreads TARGETS = timestamp @BIND9_MAKE_RULES@ diff --git a/lib/isc/include/isc/Makefile.in b/lib/isc/include/isc/Makefile.in index 2a629f7a45..da8266df67 100644 --- a/lib/isc/include/isc/Makefile.in +++ b/lib/isc/include/isc/Makefile.in @@ -24,8 +24,9 @@ top_srcdir = @top_srcdir@ # 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 \ - list.h mem.h rbtgen.h region.h result.h resultclass.h \ - rwlock.h socket.h str.h symtab.h task.h timer.h types.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 SUBDIRS = TARGETS = diff --git a/lib/isc/include/isc/msgcat.h b/lib/isc/include/isc/msgcat.h new file mode 100644 index 0000000000..2400540f84 --- /dev/null +++ b/lib/isc/include/isc/msgcat.h @@ -0,0 +1,130 @@ +/* + * 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_MSGCAT_H +#define ISC_MSGCAT_H 1 + +/***** + ***** Module Info + *****/ + +/* + * ISC Message Catalog + * + * Message catalogs aid internationalization of applications by allowing + * messages to be retrieved from locale-specific files instead of + * hardwiring them into the application. This allows translations of + * messages appropriate to the locale to be supplied without recompiling + * the application. + * + * Notes: + * It's very important that message catalogs work, even if only the + * default_text can be used. + * + * MP: + * The caller must ensure appropriate synchronization of + * isc_msgcat_open() and isc_msgcat_close(). isc_msgcat_get() + * ensures appropriate synchronization. + * + * Reliability: + * No anticipated impact. + * + * Resources: + * + * + * Security: + * No anticipated impact. + * + * Standards: + * None. + */ + +/***** + ***** Imports + *****/ + +#include +#include +#include + +ISC_LANG_BEGINDECLS + +/***** + ***** Methods + *****/ + +void +isc_msgcat_open(char *name, isc_msgcat_t **msgcatp); +/* + * Open a message catalog. + * + * Notes: + * + * If memory cannot be allocated or other failures occur, *msgcatp + * will be set to NULL. If a NULL msgcat is given to isc_msgcat_get(), + * the default_text will be returned, ensuring that some message text + * will be available, no matter what's going wrong. + * + * Requires: + * + * 'name' is a valid string. + * + * msgcatp != NULL && *msgcatp == NULL + */ + +void +isc_msgcat_close(isc_msgcat_t **msgcatp); +/* + * Close a message catalog. + * + * Notes: + * + * Any string pointers returned by prior calls to isc_msgcat_get() are + * invalid after isc_msgcat_close() has been called and must not be + * used. + * + * Requires: + * + * *msgcatp is a valid message catalog or is NULL. + * + * Ensures: + * + * All resources associated with the message catalog are released. + * + * *msgcatp == NULL + */ + +char * +isc_msgcat_get(isc_msgcat_t *msgcat, int set, int message, char *default_text); +/* + * Get message 'message' from message set 'set' in 'msgcat'. If it + * is not available, use 'default_text'. + * + * Requires: + * + * 'msgcat' is a valid message catalog or is NULL. + * + * set > 0 + * + * message > 0 + * + * 'default_text' is a valid string. + */ + +ISC_LANG_ENDDECLS + +#endif /* ISC_MSGCAT_H */ diff --git a/lib/isc/include/isc/result.h b/lib/isc/include/isc/result.h index b32ad45686..b3c2c6109f 100644 --- a/lib/isc/include/isc/result.h +++ b/lib/isc/include/isc/result.h @@ -21,11 +21,10 @@ #include #include #include +#include ISC_LANG_BEGINDECLS -typedef unsigned int isc_result_t; - #define ISC_R_SUCCESS 0 #define ISC_R_NOMEMORY 1 #define ISC_R_TIMEDOUT 2 @@ -67,7 +66,9 @@ typedef unsigned int isc_result_t; char * isc_result_totext(isc_result_t); isc_result_t isc_result_register(unsigned int base, unsigned int nresults, - char **text); + char **text, + isc_msgcat_t *msgcat, + int set); ISC_LANG_ENDDECLS diff --git a/lib/isc/nls/.cvsignore b/lib/isc/nls/.cvsignore new file mode 100644 index 0000000000..f3c7a7c5da --- /dev/null +++ b/lib/isc/nls/.cvsignore @@ -0,0 +1 @@ +Makefile diff --git a/lib/isc/nls/Makefile.in b/lib/isc/nls/Makefile.in new file mode 100644 index 0000000000..8b8fa0642c --- /dev/null +++ b/lib/isc/nls/Makefile.in @@ -0,0 +1,30 @@ +# 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. + +srcdir = @srcdir@ +VPATH = @srcdir@ +top_srcdir = @top_srcdir@ + +CINCLUDES = -I${srcdir}/include \ + -I${srcdir}/../include +CDEFINES = +CWARNINGS = + +OBJS = msgcat.o + +SUBDIRS = +TARGETS = ${OBJS} + +@BIND9_MAKE_RULES@ diff --git a/lib/isc/nls/msgcat.c b/lib/isc/nls/msgcat.c new file mode 100644 index 0000000000..492be2ca92 --- /dev/null +++ b/lib/isc/nls/msgcat.c @@ -0,0 +1,128 @@ +/* + * 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. + */ + +/* + * Principal Author: Bob Halley + */ + +#include + +#include +#include + +#include +#include + +#ifdef HAVE_CATGETS +#include +#endif + +/* + * Implementation Notes: + * + * We use malloc() and free() instead of isc_mem_get() and isc_mem_put() + * because we don't want to require a memory context to be specified + * in order to use a message catalog. + */ + +struct isc_msgcat { + unsigned int magic; +#ifdef HAVE_CATGETS + nl_catd catalog; +#endif +}; + +#define MSGCAT_MAGIC 0x4D436174 /* MCat */ +#define VALID_MSGCAT(m) ((m) != NULL && \ + (m)->magic == MSGCAT_MAGIC) + +void +isc_msgcat_open(char *name, isc_msgcat_t **msgcatp) { + isc_msgcat_t *msgcat; + + /* + * Open a message catalog. + */ + + REQUIRE(name != NULL); + REQUIRE(msgcatp != NULL && *msgcatp == NULL); + + msgcat = malloc(sizeof *msgcat); + if (msgcat == NULL) { + *msgcatp = NULL; + return; + } + +#ifdef HAVE_CATGETS + /* + * We don't check if catopen() fails because we don't care. + * If it does fail, then when we call catgets(), it will use + * the default string. + */ + msgcat->catalog = catopen(name, 0); +#endif + msgcat->magic = MSGCAT_MAGIC; + + *msgcatp = msgcat; +} + +void +isc_msgcat_close(isc_msgcat_t **msgcatp) { + isc_msgcat_t *msgcat; + + /* + * Close a message catalog. + */ + + REQUIRE(msgcatp != NULL); + msgcat = *msgcatp; + REQUIRE(VALID_MSGCAT(msgcat) || msgcat == NULL); + + if (msgcat != NULL) { +#ifdef HAVE_CATGETS + if (msgcat->catalog != (nl_catd)(-1)) + catclose(msgcat->catalog); +#endif + msgcat->magic = 0; + free(msgcat); + } + + *msgcatp = NULL; +} + +char * +isc_msgcat_get(isc_msgcat_t *msgcat, int set, int message, + char *default_text) +{ + /* + * Get message 'message' from message set 'set' in 'msgcat'. If it + * is not available, use 'default'. + */ + + REQUIRE(VALID_MSGCAT(msgcat) || msgcat == NULL); + REQUIRE(set > 0); + REQUIRE(message > 0); + REQUIRE(default_text != NULL); + +#ifdef HAVE_CATGETS + if (msgcat == NULL) + return (default_text); + return (catgets(msgcat->catalog, set, message, default_text)); +#else + return (default_text); +#endif +} diff --git a/lib/isc/result.c b/lib/isc/result.c index 3ec532086f..3e0a0b98fc 100644 --- a/lib/isc/result.c +++ b/lib/isc/result.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "util.h" @@ -33,6 +34,8 @@ typedef struct resulttable { unsigned int base; unsigned int last; char ** text; + isc_msgcat_t * msgcat; + int set; ISC_LINK(struct resulttable) link; } resulttable; @@ -75,11 +78,14 @@ static char *text[ISC_R_NRESULTS] = { }; 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; static isc_result_t -register_table(unsigned int base, unsigned int nresults, char **text) { +register_table(unsigned int base, unsigned int nresults, char **text, + isc_msgcat_t *msgcat, int set) +{ resulttable *table; REQUIRE(base % ISC_RESULTCLASS_SIZE == 0); @@ -96,6 +102,8 @@ register_table(unsigned int base, unsigned int nresults, char **text) { table->base = base; table->last = base + nresults; table->text = text; + table->msgcat = msgcat; + table->set = set; ISC_LINK_INIT(table, link); LOCK(&lock); @@ -114,7 +122,9 @@ initialize_action(void) { RUNTIME_CHECK(isc_mutex_init(&lock) == ISC_R_SUCCESS); ISC_LIST_INIT(tables); - result = register_table(ISC_RESULTCLASS_ISC, ISC_R_NRESULTS, text); + isc_msgcat_open("libisc.cat", &isc_msgcat); + result = register_table(ISC_RESULTCLASS_ISC, ISC_R_NRESULTS, text, + isc_msgcat, 2); if (result != ISC_R_SUCCESS) UNEXPECTED_ERROR(__FILE__, __LINE__, "register_table() failed: %u", result); @@ -128,7 +138,8 @@ initialize(void) { char * isc_result_totext(isc_result_t result) { resulttable *table; - char *text; + char *text, *default_text; + int index; initialize(); @@ -139,7 +150,15 @@ isc_result_totext(isc_result_t result) { table != NULL; table = ISC_LIST_NEXT(table, link)) { if (result >= table->base && result <= table->last) { - text = table->text[result - table->base]; + index = (int)(result - table->base); + default_text = table->text[index]; + /* + * Note: we use 'index + 1' as the message number + * instead of index because isc_msgcat_get() requires + * the message number to be > 0. + */ + text = isc_msgcat_get(table->msgcat, table->set, + index + 1, default_text); break; } } @@ -150,8 +169,10 @@ isc_result_totext(isc_result_t result) { } isc_result_t -isc_result_register(unsigned int base, unsigned int nresults, char **text) { +isc_result_register(unsigned int base, unsigned int nresults, char **text, + isc_msgcat_t *msgcat, int set) +{ initialize(); - return (register_table(base, nresults, text)); + return (register_table(base, nresults, text, msgcat, set)); }