From ceccbacc34d71a5d90986b2318e634daaad0f296 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sat, 4 Feb 2006 22:03:33 +0000 Subject: [PATCH] The new function setup_iconv() initializes the ic_chck var. --- rsync.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/rsync.c b/rsync.c index 6d1ee8f9..b9db23b6 100644 --- a/rsync.c +++ b/rsync.c @@ -21,6 +21,14 @@ process */ #include "rsync.h" +#if defined HAVE_ICONV && defined HAVE_ICONV_H +#include +#endif +#if defined HAVE_LIBCHARSET_H && defined HAVE_LOCALE_CHARSET +#include +#elif defined HAVE_LANGINFO_H && defined HAVE_NL_LANGINFO +#include +#endif extern int verbose; extern int dry_run; @@ -42,6 +50,32 @@ extern int keep_dirlinks; extern int make_backups; extern struct stats stats; +#ifdef HAVE_ICONV +iconv_t ic_chck = (iconv_t)-1; + +static char *default_charset(void) +{ +#if defined HAVE_LIBCHARSET_H && defined HAVE_LOCALE_CHARSET + return locale_charset(); +#elif defined HAVE_LANGINFO_H && defined HAVE_NL_LANGINFO + return nl_langinfo(CODESET); +#else + return ""; /* Works with (at the very least) gnu iconv... */ +#endif +} + +void setup_iconv() +{ + char *defset = default_charset(); + + if (!am_server + && (ic_chck = iconv_open(defset, defset)) == (iconv_t)-1) { + rprintf(FERROR, "iconv_open(\"%s\", \"%s\") failed\n", + defset, defset); + exit_cleanup(RERR_UNSUPPORTED); + } +} +#endif /* free a sums struct -- 2.34.1