X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/9b499e95373954240eaff3b43fcfc703035c9dc6..3648ab3a2474ba318291dc9184cd68fa7b120591:/rsync.c diff --git a/rsync.c b/rsync.c index 6d1ee8f9..48b2520f 100644 --- a/rsync.c +++ b/rsync.c @@ -21,6 +21,14 @@ process */ #include "rsync.h" +#if defined HAVE_ICONV_OPEN && 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,35 @@ extern int keep_dirlinks; extern int make_backups; extern struct stats stats; +#if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H +iconv_t ic_chck = (iconv_t)-1; + +static const 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 + const char *def = nl_langinfo(CODESET); + if (strcmp(def, "646") == 0) /* Solaris brain-damage */ + return "ASCII"; + return def; +#else + return ""; /* Works with (at the very least) gnu iconv... */ +#endif +} + +void setup_iconv() +{ + const 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