Added a bit of iconv code to rfc2ftn

This commit is contained in:
Michiel Broek 2007-02-18 20:22:43 +00:00
parent 230bbd87c3
commit b19fb0af99
2 changed files with 31 additions and 0 deletions

View File

@ -97,6 +97,10 @@
#endif #endif
#include <locale.h> #include <locale.h>
#include <langinfo.h> #include <langinfo.h>
#ifdef HAVE_ICONV_H
#include <iconv.h>
#endif
/* used to use #elif, but native braindead hpux 9.00 c compiler didn't /* used to use #elif, but native braindead hpux 9.00 c compiler didn't
* * understand it */ * * understand it */

View File

@ -78,6 +78,10 @@ extern int most_debug;
* Internal functions * Internal functions
*/ */
int needputrfc(rfcmsg *, int); 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)); charset_set_in_out(charset,getrfcchrs(msgs.Charset));
#endif #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 { do {
Syslog('m', "rfc2ftn: split loop, splitpart = %d", splitpart); Syslog('m', "rfc2ftn: split loop, splitpart = %d", splitpart);
@ -751,6 +768,16 @@ int rfc2ftn(FILE *fp, faddr *recipient)
Syslog('m', "rfc2ftn: out of splitloop"); 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); free(temp);
if (charset) if (charset)
free(charset); free(charset);