From b19fb0af990c46525290aed52618d6fa829799a2 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Sun, 18 Feb 2007 20:22:43 +0000 Subject: [PATCH] Added a bit of iconv code to rfc2ftn --- lib/mbselib.h | 4 ++++ mbfido/rfc2ftn.c | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/lib/mbselib.h b/lib/mbselib.h index aa72d612..3ddffd5d 100644 --- a/lib/mbselib.h +++ b/lib/mbselib.h @@ -97,6 +97,10 @@ #endif #include #include +#ifdef HAVE_ICONV_H +#include +#endif + /* used to use #elif, but native braindead hpux 9.00 c compiler didn't * * understand it */ diff --git a/mbfido/rfc2ftn.c b/mbfido/rfc2ftn.c index 709aec4b..32ce6d46 100644 --- a/mbfido/rfc2ftn.c +++ b/mbfido/rfc2ftn.c @@ -78,6 +78,10 @@ extern int most_debug; * Internal functions */ int needputrfc(rfcmsg *, int); +#ifdef USE_EXPERIMENT +int use_iconv = FALSE; +iconv_t iconv_s; +#endif @@ -350,6 +354,19 @@ int rfc2ftn(FILE *fp, faddr *recipient) */ charset_set_in_out(charset,getrfcchrs(msgs.Charset)); #endif +#ifdef USE_EXPERIMENT + if (strcmp(charset,getrfcchrs(msgs.Charset)) == 0) { + Syslog('m', "rfc2ftn: no need for iconv"); + } else { + iconv_s = iconv_open(getrfcchrs(msgs.Charset), charset); + if (iconv_s != (iconv_t)-1) { + Syslog('m', "rfc2ftn: activated iconv"); + use_iconv = TRUE; + } else { + Syslog('+', "rfc2ftn: iconv_open(%s, %s) failed", getrfcchrs(msgs.Charset), charset); + } + } +#endif do { Syslog('m', "rfc2ftn: split loop, splitpart = %d", splitpart); @@ -751,6 +768,16 @@ int rfc2ftn(FILE *fp, faddr *recipient) Syslog('m', "rfc2ftn: out of splitloop"); +#ifdef USE_EXPERIMENT + if (use_iconv) { + if (iconv_close(iconv_s)) + WriteError("$rfc2ftn: iconv_close()"); + else + Syslog('m', "rfc2ftn: inconv_close() success"); + use_iconv = FALSE; + } +#endif + free(temp); if (charset) free(charset);