#endif
])
+OPENAFS_TEST_PACKAGE(libintl,[#include <libintl.h>],[-lintl],,,INTL)
+
dnl Don't build PAM on IRIX; the interface doesn't work for us.
if test "$ac_cv_header_security_pam_modules_h" = yes -a "$enable_pam" = yes; then
case $AFS_SYSNAME in
SHLIB_SUFFIX="so"
CCOBJ="$CC"
MT_CC="$CC"
-XLIBS="${LIB_AFSDB} ${XBSA_XLIBS}"
+XLIBS="${LIB_AFSDB} ${XBSA_XLIBS} ${LIB_libintl}"
dnl debugging and optimization flag defaults
dnl Note, these are all the defaults for if debug/optimize turned on, and
EXTRA_VLIBOBJS="fstab.o"
SHLIB_LINKER="${MT_CC} -dynamiclib"
SHLIB_SUFFIX="dylib"
+ XLIBS="${LIB_AFSDB} ${XBSA_XLIBS} -framework CoreFoundation"
;;
*_darwin_80)
SHLIB_LINKER="${MT_CC} -dynamiclib"
SHLIB_SUFFIX="dylib"
RANLIB="ranlib -c"
+ XLIBS="${LIB_AFSDB} ${XBSA_XLIBS} -framework CoreFoundation"
;;
*_darwin_90)
SHLIB_LINKER="${MT_CC} -dynamiclib"
SHLIB_SUFFIX="dylib"
RANLIB="ranlib -c"
+ XLIBS="${LIB_AFSDB} ${XBSA_XLIBS} -framework CoreFoundation"
;;
*_darwin_100)
AFSD_LDFLAGS="-F/System/Library/PrivateFrameworks -framework DiskArbitration -framework SystemConfiguration -framework IOKit -framework CoreFoundation"
LEX="lex -l"
MT_CFLAGS='-DAFS_PTHREAD_ENV -D_REENTRANT ${XCFLAGS} ${ARCHFLAGS}'
- MT_LIBS="-lresolv"
+ MT_LIBS="${LIB_AFSDB} -framework CoreFoundation"
KROOT=
KINCLUDES='-I$(KROOT)/System/Library/Frameworks/Kernel.framework/Headers'
LD="cc"
SHLIB_LINKER="${MT_CC} -dynamiclib"
SHLIB_SUFFIX="dylib"
RANLIB="ranlib"
+ XLIBS="${LIB_AFSDB} ${XBSA_XLIBS} -framework CoreFoundation"
;;
ppc_linux*)
SHLIB_SUFFIX="o"
TXLIBS="-lcurses"
XCFLAGS="-K -D_NONSTD_TYPES -D_MBI=void"
- XLIBS="${LIB_AFSDB} -ldl"
+ XLIBS="${LIB_AFSDB} ${LIB_libintl} -ldl"
SHLIB_LINKER="${MT_CC} -bM:SRE -berok"
AIX32=""
AIX64="#"
SHLIB_SUFFIX="o"
TXLIBS="-lcurses"
XCFLAGS="-K -D_NONSTD_TYPES -D_MBI=void"
- XLIBS="${LIB_AFSDB} -ldl"
+ XLIBS="${LIB_AFSDB} ${LIB_libintl} -ldl"
SHLIB_LINKER="${MT_CC} -bM:SRE -berok"
AIX32=""
AIX64=""
SHLIB_SUFFIX="o"
TXLIBS="-lcurses"
XCFLAGS="-K -D_NONSTD_TYPES -D_MBI=void"
- XLIBS="${LIB_AFSDB} -ldl"
+ XLIBS="${LIB_AFSDB} ${LIB_libintl} -ldl"
SHLIB_LINKER="${MT_CC} -bM:SRE -berok"
AIX32=""
AIX64=""
SHLIB_SUFFIX="o"
TXLIBS="-lcurses"
XCFLAGS="-K -D_NONSTD_TYPES -D_MBI=void"
- XLIBS="${LIB_AFSDB} -ldl"
+ XLIBS="${LIB_AFSDB} ${LIB_libintl} -ldl"
SHLIB_LINKER="${MT_CC} -bM:SRE -berok"
AIX32=""
AIX64=""
SHLIB_SUFFIX="o"
TXLIBS="-lcurses"
XCFLAGS="-K -D_NONSTD_TYPES -D_MBI=void"
- XLIBS="${LIB_AFSDB} -ldl"
+ XLIBS="${LIB_AFSDB} ${LIB_libintl} -ldl"
SHLIB_LINKER="${MT_CC} -bM:SRE -berok"
AIX32="#"
AIX64=""
--- /dev/null
+AC_DEFUN([OPENAFS_TEST_PACKAGE],[
+AC_ARG_WITH($1,
+[ --with-$1=dir use $1 in dir])
+AC_ARG_WITH($1-lib,
+[ --with-$1-lib=dir use $1 libraries in dir],
+[if test "$withval" = "yes" -o "$withval" = "no"; then
+ AC_MSG_ERROR([No argument for --with-$1-lib])
+elif test "X$with_$1" = "X"; then
+ with_$1=yes
+fi])
+AC_ARG_WITH($1-include,
+[ --with-$1-include=dir use $1 headers in dir],
+[if test "$withval" = "yes" -o "$withval" = "no"; then
+ AC_MSG_ERROR([No argument for --with-$1-include])
+elif test "X$with_$1" = "X"; then
+ with_$1=yes
+fi])
+
+AC_MSG_CHECKING(for $1)
+
+case "$with_$1" in
+yes) ;;
+no) ;;
+"") ;;
+*) if test "$with_$1_include" = ""; then
+ with_$1_include="$with_$1/include"
+ fi
+ if test "$with_$1_lib" = ""; then
+ with_$1_lib="$with_$1/lib$abilibdirext"
+ fi
+ ;;
+esac
+header_dirs=
+lib_dirs=
+d='$5'
+for i in $d; do
+ header_dirs="$header_dirs $i/include"
+ lib_dirs="$lib_dirs $i/lib$abilibdirext"
+done
+
+case "$with_$1_include" in
+yes) ;;
+no) ;;
+*) header_dirs="$with_$1_include $header_dirs";;
+esac
+case "$with_$1_lib" in
+yes) ;;
+no) ;;
+*) lib_dirs="$with_$1_lib $lib_dirs";;
+esac
+
+save_CFLAGS="$CFLAGS"
+save_LIBS="$LIBS"
+ires= lres=
+for i in $header_dirs; do
+ CFLAGS="-I$i $save_CFLAGS"
+ AC_TRY_COMPILE([$2],,ires=$i;break)
+done
+for i in $lib_dirs; do
+ LIBS="-L$i $3 $4 $save_LIBS"
+ AC_TRY_LINK([$2],,lres=$i;break)
+done
+CFLAGS="$save_CFLAGS"
+LIBS="$save_LIBS"
+
+if test "$ires" -a "$lres" -a "$with_$1" != "no"; then
+ $1_includedir="$ires"
+ $1_libdir="$lres"
+ INCLUDE_$1="-I$$1_includedir"
+ LIB_$1="-L$$1_libdir $3"
+ AC_DEFINE_UNQUOTED(m4_toupper($1),1,[Define if you have the $1 package.])
+ AC_DEFINE_UNQUOTED(m4_toupper(HAVE_$1),1,[Define if you have the $1 package.])
+ with_$1=yes
+ AC_MSG_RESULT([headers $ires, libraries $lres])
+else
+ INCLUDE_$1=
+ LIB_$1=
+ with_$1=no
+ AC_MSG_RESULT($with_$1)
+fi
+AC_SUBST(INCLUDE_$1)
+AC_SUBST(LIB_$1)
+])
extern const char *afs_error_table_name(afs_int32);
extern const char *afs_error_message(afs_int32);
+extern const char *afs_error_message_localize(afs_int32 code, char *str, size_t len);
extern
void (*afs_set_com_err_hook
(void (*)(const char *, afs_int32, const char *, va_list)))
#include <stdio.h>
#include "error_table.h"
#include "mit-sipb-cr.h"
+#ifdef HAVE_LIBINTL
+#include <libintl.h>
+#endif
+#ifdef AFS_DARWIN70_ENV
+#include <CoreFoundation/CoreFoundation.h>
+#endif
#include <afs/errors.h>
#include <afs/afsutil.h>
#include <string.h>
return "unknown volume error";
}
-const char *
-afs_error_message(afs_int32 code)
+#ifdef AFS_DARWIN70_ENV
+static_inline const char *
+_intlize(const char *msg, int base, char *str, size_t len)
+{
+ char domain[12 +20];
+ CFStringRef cfstring = CFStringCreateWithCString(kCFAllocatorSystemDefault,
+ msg,
+ kCFStringEncodingUTF8);
+ CFStringRef cfdomain;
+ CFBundleRef OpenAFSBundle = CFBundleGetBundleWithIdentifier(CFSTR("org.openafs.filesystems.afs"));
+
+ if (!str)
+ return msg;
+ snprintf(domain, sizeof(domain), "heim_com_err%d", base);
+ cfdomain = CFStringCreateWithCString(kCFAllocatorSystemDefault, domain,
+ kCFStringEncodingUTF8);
+ if (OpenAFSBundle != NULL)
+ cfstring = CFBundleCopyLocalizedString(OpenAFSBundle, cfstring,
+ cfstring, cfdomain);
+ CFStringGetCString(cfstring, str, len, kCFStringEncodingUTF8);
+ CFRelease(cfstring);
+ CFRelease(cfdomain);
+ return str;
+}
+#else
+static_inline const char *
+_intlize(const char *msg, int base, char *str, size_t len)
+{
+ char domain[12 +20];
+ if (!str)
+ return msg;
+ snprintf(domain, sizeof(domain), "heim_com_err%d", base);
+#if defined(HAVE_LIBINTL)
+ strlcpy(str, dgettext(domain, msg), len);
+#endif
+ return str;
+}
+#endif
+
+static const char *
+afs_error_message_int(struct et_list *list, afs_int32 code, char *str, size_t len)
{
int offset;
struct et_list *et;
- int table_num;
+ int table_num, unlock = 0;
int started = 0;
char *cp;
- char *err_msg;
+ const char *err_msg;
/* check for rpc errors first */
if (code < 0)
- return negative_message(code);
+ return _intlize(negative_message(code), -1, str, len);
offset = code & ((1 << ERRCODE_RANGE) - 1);
table_num = code - offset;
if (!table_num) {
if ((err_msg = strerror(offset)) != NULL)
- return (err_msg);
+ return _intlize(err_msg, 0, str, len);
else if (offset < 140)
- return volume_message(code);
+ return _intlize(volume_message(code), 0, str, len);
else
goto oops;
}
- LOCK_ET_LIST;
- for (et = _et_list; et; et = et->next) {
+ if (list) {
+ et = list;
+ } else {
+ LOCK_ET_LIST;
+ unlock = 1;
+ et = _et_list;
+ }
+ for (; et; et = et->next) {
if (et->table->base == table_num) {
/* This is the right table */
if (et->table->n_msgs <= offset)
goto oops;
- UNLOCK_ET_LIST;
- return (et->table->msgs[offset]);
+ err_msg = _intlize(et->table->msgs[offset], et->table->base,
+ str, len);
+ if (unlock)
+ UNLOCK_ET_LIST;
+ return err_msg;
}
}
oops:
- UNLOCK_ET_LIST;
- strlcpy(buffer, "Unknown code ", sizeof buffer);
+ if (unlock)
+ UNLOCK_ET_LIST;
+ /* Unknown code can be included in the negative errors catalog */
+ _intlize("Unknown code ", -1, buffer, sizeof buffer);
if (table_num) {
strlcat(buffer, afs_error_table_name(table_num), sizeof buffer);
strlcat(buffer, " ", sizeof buffer);
return (buffer);
}
+const char *
+afs_error_message_localize(afs_int32 code, char *str, size_t len)
+{
+ return afs_error_message_int((struct et_list *)0, code, str, len);
+}
+
+const char *
+afs_com_right_r(struct et_list *list, long code, char *str, size_t len)
+{
+ return afs_error_message_int(list, (afs_int32)code, str, len);
+}
+
+const char *
+afs_com_right(struct et_list *list, long code)
+{
+ return afs_error_message_int(list, (afs_int32)code, (char *)0, 0);
+}
+
+const char *
+afs_error_message(afs_int32 code)
+{
+ return afs_error_message_int((struct et_list *)0, code, (char *)0, 0);
+}
+
void
afs_add_to_error_table(struct et_list *new_table)
{
extern char const *afs_error_table_name(afs_int32 num);
extern void afs_add_to_error_table(struct et_list *new_table);
+extern const char *afs_com_right(struct et_list *list, long code);
+extern const char *afs_com_right_r(struct et_list *list, long code, char *str, size_t len);
+
#ifdef AFS_OLD_COM_ERR
#define error_table_name afs_error_table_name
#define add_to_error_table(X) afs_add_to_error_table(X)
DBG = @DBG@
DEST = @DEST@
FSINCLUDES = @FSINCLUDES@
+INCLUDE_LIBINTL = @INCLUDE_libintl@
KERN_DBG = @KERN_DBG@
KERN_OPTMZ = @KERN_OPTMZ@
LD = @LD@
LEX = @LEX@
LIB_AFSDB = @LIB_AFSDB@
LIBS = @LIBS@
+LIB_LIBINTL = @LIB_libintl@
LINUX_KERNEL_PATH = @LINUX_KERNEL_PATH@
LINUX_KERNEL_BUILD = @LINUX_KERNEL_BUILD@
LINUX_LIBAFS_NAME = @LINUX_LIBAFS_NAME@
# conditionalise them on that.
COMMON_INCL=-I${TOP_OBJDIR}/src/config -I${TOP_INCDIR} -I${srcdir} -I.
-COMMON_CFLAGS=${DBG} ${OPTMZ} ${COMMON_INCL}
+COMMON_CFLAGS=${DBG} ${OPTMZ} ${COMMON_INCL} ${INCLUDE_LIBINTL}
CFLAGS=${COMMON_CFLAGS} ${XCFLAGS} ${ARCHFLAGS} $(CFLAGS_NOERROR)
LDFLAGS=${XLDFLAGS} ${ARCHFLAGS}
int i;
afs_int32 code;
afs_int32 offset;
+ char msgbuf[BUFSIZ];
#ifdef AFS_AIX32_ENV
/*
offset = code & ((1 << ERRCODE_RANGE) - 1);
printf("%d (%s).%d = %s\n", (int)code, afs_error_table_name(code),
- (int)offset, afs_error_message(code));
+ (int)offset, afs_error_message_localize(code, msgbuf, BUFSIZ));
}
return 0;
}
rebuild.o: rebuild.c $(INCLS) AFS_component_version_number.o
rebuild: rebuild.o kautils.o $(LIBS)
- ${CC} ${LDFLAGS} -o rebuild rebuild.o kautils.o $(LIBS)
+ ${CC} ${LDFLAGS} -o rebuild rebuild.o kautils.o $(LIBS) ${XLIBS}
#
# Install targets
-I${TOP_OBJDIR}/src/vlserver \
-I${TOP_OBJDIR}/src/libuafs \
-I${TOP_INCDIR} \
- -I${TOP_INCDIR}/afs
+ -I${TOP_INCDIR}/afs @INCLUDE_libintl@
# Build rules - CC and CFLAGS are defined in system specific MakefileProtos.