Added charset detecting

This commit is contained in:
Michiel Broek 2005-08-13 14:40:46 +00:00
parent 98d22d5544
commit cc60870d48

View File

@ -124,7 +124,7 @@ int kludgewrite(char *s, FILE *fp)
*/ */
int rfc2ftn(FILE *fp, faddr *recipient) int rfc2ftn(FILE *fp, faddr *recipient)
{ {
char sbe[16], *p, *q, *temp, *origin, newsubj[4 * (MAXSUBJ+1)], *oldsubj, *acup_a = NULL; char sbe[16], *p, *q, *temp, *origin, newsubj[4 * (MAXSUBJ+1)], *oldsubj, *acup_a = NULL, *charset = NULL;
int i, rc, newsmode, seenlen, oldnet; int i, rc, newsmode, seenlen, oldnet;
rfcmsg *msg = NULL, *tmsg, *tmp; rfcmsg *msg = NULL, *tmsg, *tmp;
ftnmsg *fmsg = NULL; ftnmsg *fmsg = NULL;
@ -216,8 +216,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
while (*p && isspace(*p)) while (*p && isspace(*p))
p++; p++;
Syslog('m', "Content-Type: %s", printable(p, 0));
/* /*
* Check for mime to remove. * Check for mime to remove.
*/ */
@ -229,6 +227,15 @@ int rfc2ftn(FILE *fp, faddr *recipient)
q = strtok(p, " \n\0"); q = strtok(p, " \n\0");
q = strtok(NULL, " \n\0"); q = strtok(NULL, " \n\0");
Syslog('m', "charset part: %s", printable(q, 0)); Syslog('m', "charset part: %s", printable(q, 0));
if (q && (strcasecmp(q, "charset=") == 0)) {
charset = xstrcpy(q + 8);
Syslog('m', "Charset \"%s\"", printable(charset, 0));
}
}
if (charset == NULL) {
charset = xstrcpy((char *)"iso-8859-1");
Syslog('m', "No charset, setting default to iso-8859-1");
} }
if ((p = hdr((char *)"Message-ID",msg))) { if ((p = hdr((char *)"Message-ID",msg))) {
@ -704,7 +711,10 @@ int rfc2ftn(FILE *fp, faddr *recipient)
free(origin); free(origin);
fclose(ofp); fclose(ofp);
} while (needsplit); } while (needsplit);
free(temp); free(temp);
if (charset)
free(charset);
tidyrfc(msg); tidyrfc(msg);
tidy_ftnmsg(fmsg); tidy_ftnmsg(fmsg);
UpdateMsgs(); UpdateMsgs();