Removed charset translation code

This commit is contained in:
Michiel Broek
2003-01-30 21:23:57 +00:00
parent 8c5034f00f
commit d95fc43626
21 changed files with 719 additions and 3941 deletions

View File

@@ -242,8 +242,8 @@ int CheckEchoGroup(char *Area, int SendUplink, faddr *f)
msgs.NetReply = mgroup.NetReply;
msgs.Active = TRUE;
msgs.Quotes = mgroup.Quotes;
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.Rfccode = 0; // CHRS_DEFAULT_RFC;
msgs.Ftncode = 0; // CHRS_DEFAULT_FTN;
msgs.MaxArticles = CFG.maxarticles;
tag = tl(tag);
for (i = 0; i < strlen(tag); i++)

View File

@@ -308,20 +308,18 @@ void Send(int newsmode, char *outstr)
int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int flags, FILE *pkt)
{
int rrq, result = 1, modtype = 0;
int incode = CHRS_NOTSET, outcode = CHRS_NOTSET;
int waskludge = FALSE, badkludge, pgpsigned = FALSE;
int waskludge = FALSE, badkludge;
int bNeedToGetAddressFromMsgid = (int)NULL;
int newsmode = 0, lines, pass, count, first;
char *newsgroup = NULL, *distribution = NULL, *moderator = NULL;
char *temp, *p, *q, *r, *l, *b;
char *To = NULL, buf[4096], *charset, c;
char *To = NULL, buf[4096], c;
time_t now;
rfcmsg *kmsg = NULL, **tmsg, *qmsg, *msg = NULL;
off_t endmsg_off, tear_off, orig_off, via_off;
faddr *o, *bestaka, *ta, *tfaddr;
FILE *fp;
fa_list *rlist, *tfa, *ftnpath = NULL;
int dirtyoutcode = CHRS_NOTSET;
struct utsname utsbuf;
char MailFrom[128], MailTo[128];
@@ -416,9 +414,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
if (waskludge && (isspace(buf[0])))
fputs("\n",fp); /* first body line is not RFC hdr */
waskludge=0;
if (!strncmp(buf,PGP_SIGNED_BEGIN, strlen(PGP_SIGNED_BEGIN)))
pgpsigned = TRUE;
else if ((!strncmp(buf,"---",3)) && ((buf[3] == '\r') || (buf[3] == ' ') || (buf[3] == '\n'))) {
if ((!strncmp(buf,"---",3)) && (buf[3] != '-')) {
tear_off=ftell(fp);
if ((hdr((char *)"Tearline",kmsg) == NULL)) {
*tmsg=(rfcmsg *)malloc(sizeof(rfcmsg));
@@ -523,46 +519,46 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
bestaka = bestaka_s(f);
rewind(fp);
p = hdr((char *)"CHRS", kmsg);
if (p == NULL)
p = hdr((char *)"CHARSET", kmsg);
if (p == NULL)
p = hdr((char *)"CODEPAGE", kmsg);
if (p)
outcode = readchrs(p);
else {
p=hdr((char *)"Content-Type",msg);
if (p == NULL)
p=hdr((char *)"RFC-Content-Type",kmsg);
if (p == NULL)
p=hdr((char *)"Content-Type",kmsg);
if (p)
outcode=readcharset(p);
else {
q = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka);
if ((hdr((char *)"Message-ID",msg)) || (hdr((char *)"RFC-Message-ID",kmsg)) ||
(hdr((char *)"Message-ID",kmsg)) || (hdr((char *)"RFCID",kmsg)) ||
(hdr((char *)"ORIGID",kmsg)) || ((hdr((char *)"MSGID",kmsg)) && (!chkftnmsgid(q))))
outcode = defaultrfcchar;
else
outcode = defaultftnchar;
if (q)
free(q);
q = NULL;
}
}
// p = hdr((char *)"CHRS", kmsg);
// if (p == NULL)
// p = hdr((char *)"CHARSET", kmsg);
// if (p == NULL)
// p = hdr((char *)"CODEPAGE", kmsg);
// if (p)
// outcode = readchrs(p);
// else {
// p=hdr((char *)"Content-Type",msg);
// if (p == NULL)
// p=hdr((char *)"RFC-Content-Type",kmsg);
// if (p == NULL)
// p=hdr((char *)"Content-Type",kmsg);
// if (p)
// outcode=readcharset(p);
// else {
// q = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka);
// if ((hdr((char *)"Message-ID",msg)) || (hdr((char *)"RFC-Message-ID",kmsg)) ||
// (hdr((char *)"Message-ID",kmsg)) || (hdr((char *)"RFCID",kmsg)) ||
// (hdr((char *)"ORIGID",kmsg)) || ((hdr((char *)"MSGID",kmsg)) && (!chkftnmsgid(q))))
// outcode = defaultrfcchar;
// else
// outcode = defaultftnchar;
// if (q)
// free(q);
// q = NULL;
// }
// }
/*
* A hack for TerMail
*/
p = hdr((char *)"PID", kmsg);
if ((p) && (!strncmp(p, "TerMail", 7)) && (outcode == defaultrfcchar))
outcode = defaultftnchar;
// p = hdr((char *)"PID", kmsg);
// if ((p) && (!strncmp(p, "TerMail", 7)) && (outcode == defaultrfcchar))
// outcode = defaultftnchar;
if (dirtyoutcode != CHRS_NOTSET)
outcode = dirtyoutcode;
if (pgpsigned)
incode = outcode;
// if (dirtyoutcode != CHRS_NOTSET)
// outcode = dirtyoutcode;
// if (pgpsigned)
// incode = outcode;
if (kmsg && !strcmp(kmsg->key,"AREA")) {
/*
@@ -585,20 +581,20 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
newsmode = FALSE;
Syslog('m', "Got %s message", newsmode?"echo":"netmail");
if ((outcode == CHRS_NOTSET) && (hdr((char *)"MSGID", kmsg))) {
p = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka);
if ((hdr((char *)"Message-ID",msg)) || (hdr((char *)"RFC-Message-ID",kmsg)) ||
(hdr((char *)"Message-ID",kmsg)) || (hdr((char *)"RFCID",kmsg)) ||
(hdr((char *)"ORIGID",kmsg)) || ((hdr((char *)"MSGID",kmsg)) && (!chkftnmsgid(p))))
outcode = defaultrfcchar;
else
outcode = defaultftnchar;
free(p);
}
if (pgpsigned)
incode = outcode;
else if (incode == CHRS_NOTSET)
incode = getincode(outcode);
// if ((outcode == CHRS_NOTSET) && (hdr((char *)"MSGID", kmsg))) {
// p = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka);
// if ((hdr((char *)"Message-ID",msg)) || (hdr((char *)"RFC-Message-ID",kmsg)) ||
// (hdr((char *)"Message-ID",kmsg)) || (hdr((char *)"RFCID",kmsg)) ||
// (hdr((char *)"ORIGID",kmsg)) || ((hdr((char *)"MSGID",kmsg)) && (!chkftnmsgid(p))))
// outcode = defaultrfcchar;
// else
// outcode = defaultftnchar;
// free(p);
// }
// if (pgpsigned)
// incode = outcode;
// else if (incode == CHRS_NOTSET)
// incode = getincode(outcode);
/*
@@ -857,7 +853,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
if (p == NULL)
p=hdr((char *)"To",msg);
if ((p) && (strcasecmp(p,"All\n"))) {
sprintf(temp,"X-Comment-To:%s",hdrconv(p,outcode,incode));
sprintf(temp,"X-Comment-To:%s", p);
Send(newsmode, temp);
} else {
if (p == NULL)
@@ -867,10 +863,10 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
if (p == NULL)
p=hdr((char *)"RFC-To",kmsg);
if ((p) && (strcasecmp(p,"All\n"))) {
sprintf(temp,"X-Comment-To: %s",hdrconv(p,outcode,incode));
sprintf(temp,"X-Comment-To: %s", p);
Send(newsmode, temp);
} else if ((t) && (t->name) && (strcasecmp(t->name,"All"))) {
sprintf(temp,"X-Comment-To: %s\n",hdrconv(t->name,outcode,incode));
sprintf(temp,"X-Comment-To: %s\n", t->name);
Send(newsmode, temp);
} else {
sprintf(temp,"X-Comment-To: All\n");
@@ -991,22 +987,22 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
}
if ((p = hdr((char *)"From",msg))) {
sprintf(temp, "From:%s", hdrconv(p,outcode,incode));
sprintf(temp, "From:%s", p);
Send(newsmode, temp);
} else if ((p = hdr((char *)"RFC-From",kmsg))) {
Syslog('m', "b");
sprintf(temp, "From: %s", hdrconv(p,outcode,incode));
sprintf(temp, "From: %s", p);
Send(newsmode, temp);
} else if ((p = hdr((char *)"From\n",kmsg))) {
Syslog('m', "c");
sprintf(temp, "From: %s", hdrconv(p,outcode,incode));
sprintf(temp, "From: %s", p);
Send(newsmode, temp);
} else if ((p = hdr((char *)"X-PcBoard-FROM",msg))) {
if (f->name) {
while (isspace(*p))
p++;
p[strlen(p)-1] = '\0';
sprintf(temp,"From: %s <%s>\n", hdrconv(f->name,outcode,incode), p);
sprintf(temp,"From: %s <%s>\n", f->name, p);
} else {
sprintf(temp,"From:%s\n", p);
}
@@ -1035,12 +1031,12 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
*r--='\0';
}
Syslog('m', "d");
sprintf(temp,"From: \"%s\" <%s>\n",hdrconv(l,outcode,incode),p);
sprintf(temp,"From: \"%s\" <%s>\n", l, p);
Send(newsmode, temp);
free(q);
} else if (f->name) {
Syslog('m', "e");
sprintf(temp,"From: \"%s\" <%s>\n",hdrconv(f->name,outcode,incode),p);
sprintf(temp,"From: \"%s\" <%s>\n", f->name, p);
Send(newsmode, temp);
} else {
Syslog('m', "f");
@@ -1051,9 +1047,9 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
}
if (p)
sprintf(temp,"X-FTN-Sender: %s\n",hdrconv(ascinode(f,0xff),outcode,incode));
sprintf(temp,"X-FTN-Sender: %s\n", ascinode(f,0xff));
else
sprintf(temp,"From: %s\n",hdrconv(ascinode(f,0xff),outcode,incode));
sprintf(temp,"From: %s\n", ascinode(f,0xff));
Send(newsmode, temp);
if ((p=hdr((char *)"Reply-To",msg))) {
@@ -1117,15 +1113,15 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
}
if ((p = hdr((char *)"Subject",msg)))
sprintf(temp, "Subject:%s", hdrconv(p,outcode,incode));
sprintf(temp, "Subject:%s", p);
else if ((p = hdr((char *)"RFC-Subject",kmsg)))
sprintf(temp, "Subject: %s", hdrconv(p,outcode,incode));
sprintf(temp, "Subject: %s", p);
else if ((p = hdr((char *)"Subject",kmsg)))
sprintf(temp, "Subject: %s", hdrconv(p,outcode,incode));
sprintf(temp, "Subject: %s", p);
else if ((p = hdr((char *)"X-PcBoard-SUBJECT",msg)))
sprintf(temp, "Subject:%s", hdrconv(p,outcode,incode));
sprintf(temp, "Subject:%s", p);
else if (subj && (strspn(subj," \t\n\r") != strlen(subj)))
sprintf(temp, "Subject: %s\n", hdrconv(subj,outcode,incode));
sprintf(temp, "Subject: %s\n", subj);
else
sprintf(temp, "Subject: <none>\n");
Send(newsmode, temp);
@@ -1200,25 +1196,25 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
}
if ((p=hdr((char *)"Organization",msg))) {
sprintf(temp,"Organization:%s",hdrconv(p,outcode,incode));
sprintf(temp,"Organization:%s",p);
Send(newsmode, temp);
} else if ((p=hdr((char *)"Organisation",msg))) {
sprintf(temp,"Organization:%s",hdrconv(p,outcode,incode));
sprintf(temp,"Organization:%s",p);
Send(newsmode, temp);
} else if ((p=hdr((char *)"RFC-Organization",kmsg))) {
sprintf(temp,"Organization: %s",hdrconv(p,outcode,incode));
sprintf(temp,"Organization: %s",p);
Send(newsmode, temp);
} else if ((p=hdr((char *)"RFC-Organisation",kmsg))) {
sprintf(temp,"Organization: %s",hdrconv(p,outcode,incode));
sprintf(temp,"Organization: %s",p);
Send(newsmode, temp);
} else if ((p=hdr((char *)"Organization",kmsg))) {
sprintf(temp,"Organization: %s",hdrconv(p,outcode,incode));
sprintf(temp,"Organization: %s",p);
Send(newsmode, temp);
} else if ((p=hdr((char *)"Organisation",kmsg))) {
sprintf(temp,"Organization: %s",hdrconv(p,outcode,incode));
sprintf(temp,"Organization: %s",p);
Send(newsmode, temp);
} else if (origline) {
sprintf(temp,"Organization: %s\n",hdrconv(origline,outcode,incode));
sprintf(temp,"Organization: %s\n",origline);
Send(newsmode, temp);
}
@@ -1256,13 +1252,13 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
}
}
sprintf(temp, "X-FTN-CHRS: %s\n", getchrs(incode));
Send(newsmode, temp);
if (incode != outcode) {
sprintf(temp, "X-FTN-ORIGCHRS: %s\n", getchrs(outcode));
Send(newsmode, temp);
}
charset = getcharset(incode);
// sprintf(temp, "X-FTN-CHRS: %s\n", getchrs(incode));
// Send(newsmode, temp);
// if (incode != outcode) {
// sprintf(temp, "X-FTN-ORIGCHRS: %s\n", getchrs(outcode));
// Send(newsmode, temp);
// }
// charset = getcharset(incode);
if ((p=hdr((char *)"Mime-Version",msg))) {
sprintf(temp,(char *)"Mime-Version:%s",p);
@@ -1273,9 +1269,9 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
} else if ((p=hdr((char *)"Mime-Version",kmsg))) {
sprintf(temp,(char *)"Mime-Version: %s",p);
Send(newsmode, temp);
} else if ((charset) && (incode != CHRS_NOTSET)) {
sprintf(temp,"Mime-Version: 1.0\n");
Send(newsmode, temp);
// } else if ((charset) && (incode != CHRS_NOTSET)) {
// sprintf(temp,"Mime-Version: 1.0\n");
// Send(newsmode, temp);
}
if ((p=hdr((char *)"Content-Type",msg))) {
@@ -1287,12 +1283,12 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
} else if ((p=hdr((char *)"Content-Type",kmsg))) {
sprintf(temp,"Content-Type: %s",p);
Send(newsmode, temp);
} else if ((charset) && (incode != CHRS_NOTSET)) {
if ((p=hdr((char *)"FSCHTML",kmsg)) || (p=hdr((char *)"HTML",kmsg)))
sprintf(temp,"Content-Type: text/html; charset=%s\n",charset);
else
sprintf(temp,"Content-Type: text/plain; charset=%s\n",charset);
Send(newsmode, temp);
// } else if ((charset) && (incode != CHRS_NOTSET)) {
// if ((p=hdr((char *)"FSCHTML",kmsg)) || (p=hdr((char *)"HTML",kmsg)))
// sprintf(temp,"Content-Type: text/html; charset=%s\n",charset);
// else
// sprintf(temp,"Content-Type: text/plain; charset=%s\n",charset);
// Send(newsmode, temp);
}
if ((p=hdr((char *)"Content-Length",msg))) {
@@ -1313,16 +1309,16 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
sprintf(temp,"Content-Transfer-Encoding: %s",p);
else if ((p=hdr((char *)"Content-Transfer-Encoding",kmsg)))
sprintf(temp,"Content-Transfer-Encoding: %s",p);
else if ((charset) && (incode == CHRS_ISO_8859_1_QP))
sprintf(temp,"Content-Transfer-Encoding: quoted-printable\n");
else if ((charset) && (incode != CHRS_NOTSET)) {
if ((incode == CHRS_ASCII || incode == CHRS_UTF_7))
sprintf(temp,"Content-Transfer-Encoding: 7bit\n");
else if (strncasecmp(charset,"iso-2022-",9) == 0)
sprintf(temp,"Content-Transfer-Encoding: 7bit\n");
else
sprintf(temp,"Content-Transfer-Encoding: 8bit\n"); /* all others are 8 bit */
}
// else if ((charset) && (incode == CHRS_ISO_8859_1_QP))
// sprintf(temp,"Content-Transfer-Encoding: quoted-printable\n");
// else if ((charset) && (incode != CHRS_NOTSET)) {
// if ((incode == CHRS_ASCII || incode == CHRS_UTF_7))
// sprintf(temp,"Content-Transfer-Encoding: 7bit\n");
// else if (strncasecmp(charset,"iso-2022-",9) == 0)
// sprintf(temp,"Content-Transfer-Encoding: 7bit\n");
// else
// sprintf(temp,"Content-Transfer-Encoding: 8bit\n"); /* all others are 8 bit */
// }
if (temp[0])
Send(newsmode, temp);
@@ -1388,7 +1384,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
strcasecmp(qmsg->key,"Distribution") &&
strcasecmp(qmsg->key,"Approved") &&
strcasecmp(qmsg->key,"Message-ID")) {
sprintf(temp,"%s:%s",qmsg->key,hdrconv(qmsg->val,outcode,incode));
sprintf(temp,"%s:%s",qmsg->key,qmsg->val);
Send(newsmode, temp);
}
}
@@ -1468,16 +1464,16 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
strcasecmp(qmsg->key,"RFC-Approved") &&
strcasecmp(qmsg->key,"RFC-Message-ID")) {
if (!strncmp(qmsg->key,"RFC-",4)) {
sprintf(temp,"%s: %s",qmsg->key+4,hdrconv(qmsg->val,outcode,incode));
sprintf(temp,"%s: %s",qmsg->key+4,qmsg->val);
Send(newsmode, temp);
} else if ((!strncasecmp(qmsg->key,"X-",2)) || (!strncasecmp(qmsg->key,"NNTP-",5))) {
sprintf(temp,"%s: %s",qmsg->key,hdrconv(qmsg->val,outcode,incode));
sprintf(temp,"%s: %s",qmsg->key,qmsg->val);
Send(newsmode, temp);
} else if ((!strncasecmp(qmsg->key,"ZC-",3))) {
sprintf(temp,"X-%s: %s",qmsg->key,qmsg->val);
Send(newsmode, temp);
} else if ((!strcasecmp(qmsg->key,"Origin")) || (!strcasecmp(qmsg->key,"MOOD"))) {
sprintf(temp,"X-FTN-%s: %s",qmsg->key,hdrconv(qmsg->val,outcode,incode));
sprintf(temp,"X-FTN-%s: %s",qmsg->key,qmsg->val);
Send(newsmode, temp);
} else {
sprintf(temp,"X-FTN-%s: %s",qmsg->key,qmsg->val);
@@ -1560,7 +1556,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
if ((p=hdr((char *)"X-Body-Start",msg))) {
lines++;
q = xstrcpy(strkconv(p, outcode, incode));
q = xstrcpy(p);
Send(newsmode, q);
free(q);
}
@@ -1578,7 +1574,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
case ' ': b=p-1; break;
case '\n': b=NULL; count=0; lines++; break;
}
if ((count++ > BOUNDARY) && (!pgpsigned)) {
if ((count++ > BOUNDARY) /* && (!pgpsigned) */ ) {
if (b) {
// *b++='\r';
// *b = '\n';
@@ -1592,7 +1588,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
}
}
if (strncmp(buf, ".\r\n", 3))
q = xstrcpy(strkconv(buf, outcode, incode));
q = xstrcpy(buf);
else
q = xstrcpy((char *)" .\n");
Send(newsmode, q);

View File

@@ -678,8 +678,8 @@ int Areas(void)
msgs.Type = ECHOMAIL;
msgs.MsgKinds = PUBLIC;
msgs.UsrDelete = TRUE;
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.Rfccode = 0; // CHRS_DEFAULT_RFC;
msgs.Ftncode = 0; // CHRS_DEFAULT_FTN;
msgs.MaxArticles = CFG.maxarticles;
strcpy(msgs.Origin, CFG.origin);
}

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
int ftnmsgid(char *,char **,unsigned long *,char *);
ftnmsg *mkftnhdr(rfcmsg *, int, int, int, faddr *);
ftnmsg *mkftnhdr(rfcmsg *, int, faddr *);
#endif

View File

@@ -94,7 +94,7 @@ void Msg_Pid(void)
temp = calloc(81, sizeof(char));
sprintf(temp, "\001PID: MBSE-FIDO %s", VERSION);
MsgText_Add2(temp);
sprintf(temp, "\001CHRS: %s", getchrs(msgs.Ftncode));
// sprintf(temp, "\001CHRS: %s", getchrs(msgs.Ftncode));
tt = time(NULL);
sprintf(temp, "\001TZUTC: %s", gmtoffset(tt));
MsgText_Add2(temp);

View File

@@ -196,8 +196,8 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor)
Msg.ReplyCRC = 0xffffffff;
sprintf(temp, "\001PID: MBSE-FIDO %s", VERSION);
MsgText_Add2(temp);
sprintf(temp, "\001CHRS: %s", getchrs(msgs.Ftncode));
MsgText_Add2(temp);
// sprintf(temp, "\001CHRS: %s", getchrs(msgs.Ftncode));
// MsgText_Add2(temp);
sprintf(temp, "\001TZUTC: %s", gmtoffset(tt));
MsgText_Add2(temp);

View File

@@ -68,7 +68,6 @@ static int removesupersedes;
static int removeapproved;
static int removereplyto;
static int removereturnto;
static int dirtyoutcode = CHRS_NOTSET;
@@ -135,15 +134,15 @@ int kludgewrite(char *s, FILE *fp)
int rfc2ftn(FILE *fp, faddr *recipient)
{
char sbe[16], *p, *q, *temp, *origin, newsubj[4 * (MAXSUBJ+1)], *oldsubj, *acup_a = NULL;
int i, rc, incode, outcode, pgpsigned, newsmode, seenlen, oldnet;
int i, rc, newsmode, seenlen, oldnet;
rfcmsg *msg = NULL, *tmsg, *tmp;
ftnmsg *fmsg = NULL;
FILE *ofp;
fa_list *sbl = NULL, *ptl = NULL, *tmpl;
faddr *ta, *fta;
unsigned long svmsgid, svreply, acup_n = 0;
int sot_kludge = FALSE, eot_kludge = FALSE, qp_or_base64 = FALSE, tinyorigin = FALSE;
int needsplit, hdrsize, datasize, splitpart, forbidsplit, rfcheaders, html_message = FALSE;
int sot_kludge = FALSE, eot_kludge = FALSE, tinyorigin = FALSE;
int needsplit, hdrsize, datasize, splitpart, forbidsplit, rfcheaders;
time_t Now;
temp = calloc(4097, sizeof(char));
@@ -158,8 +157,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
// Syslog('m', "========== RFC end");
// rewind(fp);
msg = parsrfc(fp);
incode = outcode = CHRS_NOTSET;
pgpsigned = FALSE;
newsmode = hdr((char *)"Newsgroups", msg) ?TRUE:FALSE;
Syslog('m', "RFC message is %s", newsmode ? "news article":"e-mail message");
@@ -169,30 +166,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
else
email_in++;
p = hdr((char *)"Content-Type",msg);
if (p)
incode = readcharset(p);
if (incode == CHRS_NOTSET) {
p = hdr((char *)"X-FTN-CHRS",msg);
if (p == NULL)
p = hdr((char *)"X-FTN-CHARSET", msg);
if (p == NULL)
p = hdr((char *)"X-FTN-CODEPAGE", msg);
if (p)
incode = readchrs(p);
}
if ((p = hdr((char *)"Content-Type",msg)) && ((strcasestr(p,(char *)"multipart/signed")) ||
(strcasestr(p,(char *)"application/pgp")))) {
pgpsigned = TRUE;
outcode = incode;
} else if ((p = hdr((char *)"X-FTN-ORIGCHRS", msg)))
outcode = readchrs(p);
else if (dirtyoutcode != CHRS_NOTSET)
outcode = dirtyoutcode;
else
outcode = getoutcode(incode);
if (!CFG.allowcontrol) {
if (hdr((char *)"Control",msg)) {
Syslog('+', "Control message skipped");
@@ -201,7 +174,7 @@ int rfc2ftn(FILE *fp, faddr *recipient)
}
}
if ((fmsg = mkftnhdr(msg, incode, outcode, newsmode, recipient)) == NULL) {
if ((fmsg = mkftnhdr(msg, newsmode, recipient)) == NULL) {
WriteError("Unable to create FTN headers from RFC ones, aborting");
tidyrfc(msg);
return 1;
@@ -229,20 +202,7 @@ int rfc2ftn(FILE *fp, faddr *recipient)
}
}
if (incode == CHRS_NOTSET && newsmode)
incode = msgs.Rfccode;
if (outcode == CHRS_NOTSET) {
if (newsmode)
outcode = msgs.Ftncode;
else
outcode = CHRS_DEFAULT_FTN;
}
if ((incode == CHRS_NOTSET) && (hdr((char *)"Message-ID",msg))) {
if (chkftnmsgid(hdr((char *)"Message-ID",msg)))
incode = CHRS_DEFAULT_FTN;
else
incode = CHRS_DEFAULT_RFC;
}
chkftnmsgid(hdr((char *)"Message-ID",msg)); // ??
removemime = FALSE;
removemsgid = FALSE;
removeref = FALSE;
@@ -252,10 +212,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
removereplyto = TRUE;
removereturnto = TRUE;
ftnorigin = fmsg->ftnorigin;
if ((hdr((char *)"X-PGP-Signed",msg)))
pgpsigned = TRUE;
if (pgpsigned)
Syslog('m', "pgpsigned = %s", pgpsigned ? "True":"False");
q = hdr((char *)"Content-Transfer-Encoding",msg);
if (q)
@@ -268,38 +224,14 @@ int rfc2ftn(FILE *fp, faddr *recipient)
p++;
/*
* turn the quoted-printable decode mode on; remember FTN is virtually 8-bit clean
* Check for mime to remove.
*/
if ((strncasecmp(p, "text/plain", 10) == 0) && (strncasecmp(q, "quoted-printable", 16) == 0))
qp_or_base64 = 1;
/*
* turn the base64 decode mode on
*/
else if ((strncasecmp(p, "text/plain", 10) == 0) && (strncasecmp(q, "base64", 6) == 0))
qp_or_base64 = 2;
/*
* text/html support from FSC-HTML 001 proposal of Odinn Sorensen (2:236/77)
*/
if (strncasecmp(p, "text/html", 9) == 0)
html_message = TRUE;
for (tmp = msg; tmp; tmp = tmp->next)
if (((strcasecmp(tmp->key,"X-FTN-KLUDGE") == 0) && (strcasecmp(tmp->val,"FSCHTML") == 0)) ||
(strcasecmp(tmp->key,"X-FTN-HTML") == 0))
html_message = FALSE;
if ((readcharset(p) != CHRS_NOTSET ) && ((q == NULL) || (strncasecmp(q,"7bit",4) == 0) ||
((!pgpsigned) && (qp_or_base64==1)) || ((!pgpsigned) && (qp_or_base64==2)) || (strncasecmp(q,"8bit",4) == 0)))
if ((strncasecmp(p, "text/plain", 10) == 0) && ((q == NULL) ||
(strncasecmp(q,"7bit",4) == 0) || (strncasecmp(q,"8bit",4) == 0)))
removemime=1; /* no need in MIME headers */
/*
* some old MUA puts "text" instead of "text/plain; charset=..."
*/
else if ((strcasecmp(p,"text\n") == 0))
removemime = TRUE;
}
if (removemime || qp_or_base64 || html_message)
Syslog('m', "removemime=%s, qp_or_base64 = %d, html_message=%s", removemime ? "True":"False", qp_or_base64,
html_message ? "True":"False");
if (removemime)
Syslog('m', "removemime=%s", removemime ? "True":"False");
if ((p = hdr((char *)"Message-ID",msg))) {
if (!removemsgid)
@@ -412,7 +344,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
} else {
strncpy(newsubj,fmsg->subj,MAXSUBJ);
}
strcpy(newsubj, hdrnconv(newsubj, incode, outcode, MAXSUBJ));
newsubj[MAXSUBJ]='\0';
if (splitpart) {
@@ -500,14 +431,14 @@ int rfc2ftn(FILE *fp, faddr *recipient)
}
}
if (getchrs(outcode) != NULL) {
hdrsize += 8 + strlen(getchrs(outcode));
fprintf(ofp, "\001CHRS: %s\n", getchrs(outcode));
if (html_message) {
hdrsize += 9;
fprintf(ofp, "\1HTML: 5\n");
}
}
// if (getchrs(outcode) != NULL) {
// hdrsize += 8 + strlen(getchrs(outcode));
// fprintf(ofp, "\001CHRS: %s\n", getchrs(outcode));
// if (html_message) {
// hdrsize += 9;
// fprintf(ofp, "\1HTML: 5\n");
// }
// }
if (CFG.allowcontrol && (!hdr((char *)"X-FTN-ACUPDATE",msg)) && (p=hdr((char *)"Control",msg))) {
if (strstr(p,"cancel")) {
@@ -593,6 +524,7 @@ int rfc2ftn(FILE *fp, faddr *recipient)
kludgewrite(tmp->val,ofp);
}
/*
* Add the Received: header from this system to the mesage.
*/
@@ -611,7 +543,8 @@ int rfc2ftn(FILE *fp, faddr *recipient)
hdrsize += strlen(tmp->key)+strlen(tmp->val);
fprintf(ofp,"\1RFC-%s:",tmp->key);
}
kludgewrite(hdrconv(tmp->val, incode, outcode),ofp);
// kludgewrite(hdrconv(tmp->val, incode, outcode),ofp);
kludgewrite(tmp->val, ofp);
}
}
@@ -626,7 +559,8 @@ int rfc2ftn(FILE *fp, faddr *recipient)
hdrsize += strlen(tmp->key)+strlen(tmp->val);
fprintf(ofp,"%s:",tmp->key);
}
charwrite(hdrconv(tmp->val, incode, outcode),ofp);
charwrite(tmp->val, ofp);
// charwrite(hdrconv(tmp->val, incode, outcode),ofp);
}
}
@@ -634,8 +568,8 @@ int rfc2ftn(FILE *fp, faddr *recipient)
charwrite((char *)"\n",ofp);
if ((hdr((char *)"X-FTN-SOT",msg)) || (sot_kludge))
fprintf(ofp,"\1SOT:\n");
if ((splitpart == 0) && (hdr((char *)"X-PGP-Signed",msg)))
fprintf(ofp,PGP_SIGNED_BEGIN"\n");
// if ((splitpart == 0) && (hdr((char *)"X-PGP-Signed",msg)))
// fprintf(ofp,PGP_SIGNED_BEGIN"\n");
}
if (replyaddr) {
replyaddr = NULL;
@@ -646,47 +580,57 @@ int rfc2ftn(FILE *fp, faddr *recipient)
needsplit = FALSE;
} else if ((p=hdr((char *)"X-Body-Start",msg))) {
datasize += strlen(p);
if (qp_or_base64==1)
charwrite(strkconv(qp_decode(p), incode, outcode), ofp);
else if (qp_or_base64==2)
charwrite(strkconv(b64_decode(p), incode, outcode), ofp);
else
charwrite(strkconv(p, incode, outcode), ofp);
charwrite(p, ofp);
// if (qp_or_base64==1)
// charwrite(strkconv(qp_decode(p), incode, outcode), ofp);
// else if (qp_or_base64==2)
// charwrite(strkconv(b64_decode(p), incode, outcode), ofp);
// else
// charwrite(strkconv(p, incode, outcode), ofp);
}
//Syslog('-', "14");
while (!(needsplit=(!forbidsplit) && (((splitpart && (datasize > (CFG.new_split * 1024))) ||
(!splitpart && ((datasize+hdrsize) > (CFG.new_split * 1024)))))) && (bgets(temp,4096-1,fp))) {
// Striplf(temp);
Syslog('-', "%d", strlen(temp));
// if (*(temp + strlen(temp)) != '\0') {
Syslog('-', "%d", (*(temp + strlen(temp))));
// }
Syslog('-', "14a \"%s\"", temp);
datasize += strlen(temp);
if (qp_or_base64==1)
charwrite(strkconv(qp_decode(temp), incode, outcode), ofp);
else if (qp_or_base64==2)
charwrite(strkconv(b64_decode(temp), incode, outcode), ofp);
else
charwrite(strkconv(temp, incode, outcode), ofp);
charwrite(temp, ofp);
// if (qp_or_base64==1)
// charwrite(strkconv(qp_decode(temp), incode, outcode), ofp);
// else if (qp_or_base64==2)
// charwrite(strkconv(b64_decode(temp), incode, outcode), ofp);
// else
// charwrite(strkconv(temp, incode, outcode), ofp);
}
//Syslog('-', "15");
if (needsplit) {
fprintf(ofp,"\n * Message split, to be continued *\n");
splitpart++;
} else if ((p=hdr((char *)"X-PGP-Signed",msg))) {
fprintf(ofp,PGP_SIG_BEGIN"\n");
if ((q=hdr((char *)"X-PGP-Version",msg))) {
fprintf(ofp,"Version:");
charwrite(q,ofp);
}
if ((q=hdr((char *)"X-PGP-Charset",msg))) {
fprintf(ofp,"Charset:");
charwrite(q,ofp);
}
if ((q=hdr((char *)"X-PGP-Comment",msg))) {
fprintf(ofp,"Comment:");
charwrite(q,ofp);
}
fprintf(ofp,"\n");
p=xstrcpy(p);
q=strtok(p," \t\n");
fprintf(ofp,"%s\n",q);
while ((q=(strtok(NULL," \t\n"))))
fprintf(ofp,"%s\n",q);
fprintf(ofp,PGP_SIG_END"\n");
// } else if ((p=hdr((char *)"X-PGP-Signed",msg))) {
// fprintf(ofp,PGP_SIG_BEGIN"\n");
// if ((q=hdr((char *)"X-PGP-Version",msg))) {
// fprintf(ofp,"Version:");
// charwrite(q,ofp);
// }
// if ((q=hdr((char *)"X-PGP-Charset",msg))) {
// fprintf(ofp,"Charset:");
// charwrite(q,ofp);
// }
// if ((q=hdr((char *)"X-PGP-Comment",msg))) {
// fprintf(ofp,"Comment:");
// charwrite(q,ofp);
// }
// fprintf(ofp,"\n");
// p=xstrcpy(p);
// q=strtok(p," \t\n");
// fprintf(ofp,"%s\n",q);
// while ((q=(strtok(NULL," \t\n"))))
// fprintf(ofp,"%s\n",q);
// fprintf(ofp,PGP_SIG_END"\n");
}
if ((p=hdr((char *)"X-FTN-EOT",msg)) || (eot_kludge))
fprintf(ofp,"\1EOT:\n");
@@ -704,11 +648,11 @@ int rfc2ftn(FILE *fp, faddr *recipient)
if (*(q=p+strlen(p)-1) == '\n')
*q='\0';
origin = xstrcpy((char *)" * Origin: ");
origin = xstrcat(origin, hdrconv(p, incode, outcode));
origin = xstrcat(origin, p);
} else {
origin = xstrcpy((char *)" * Origin: ");
if (fmsg->origin)
origin = xstrcat(origin, hdrconv(fmsg->origin, incode, outcode));
origin = xstrcat(origin, fmsg->origin);
else
origin = xstrcat(origin, CFG.origin);
origin = xstrcat(origin, (char *)" (");