deleted 4 obsolete files
This commit is contained in:
parent
4010192976
commit
0ede531286
@ -2,7 +2,7 @@
|
||||
*
|
||||
* File ..................: mbfido/ftn2rfc.c
|
||||
* Purpose ...............: Gate netmail->email or echomail->news
|
||||
* Last modification date : 17-Sep-2001
|
||||
* Last modification date : 27-Oct-2001
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2001
|
||||
@ -343,19 +343,19 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
|
||||
return 4;
|
||||
}
|
||||
|
||||
Syslog('m', "Message input start =============");
|
||||
Syslog('M', "Message input start =============");
|
||||
rewind(pkt);
|
||||
while ((fgets(buf, sizeof(buf)-2, pkt)) != NULL) {
|
||||
/*
|
||||
* Simple test to see how large the buffer must be. 2048 bytes has been seen.
|
||||
*/
|
||||
if (strlen(buf) > (sizeof(buf) /2))
|
||||
Syslog('+', "Possible bufferoverflow: line read %d bytes", strlen(buf));
|
||||
Syslog('+', "FTN: Possible bufferoverflow: line read %d bytes", strlen(buf));
|
||||
if (strlen(buf) > 200) {
|
||||
Syslog('m', "Next line should be %d characters", strlen(buf));
|
||||
Syslog('m', "FTN: Next line should be %d characters", strlen(buf));
|
||||
Syslogp('m', printable(buf, 200));
|
||||
} else {
|
||||
Syslogp('m', printable(buf, 0));
|
||||
Syslogp('M', printable(buf, 0));
|
||||
}
|
||||
if ((buf[0] == '\1') || !strncmp(buf,"AREA:",5) || !strncmp(buf,"SEEN-BY",7)) { /* This is a kluge line */
|
||||
waskludge = TRUE;
|
||||
@ -488,7 +488,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
|
||||
}
|
||||
|
||||
}
|
||||
Syslog('m', "Message input end ===============");
|
||||
Syslog('M', "Message input end ===============");
|
||||
|
||||
if (bNeedToGetAddressFromMsgid && (p = hdr((char *)"MSGID", kmsg))) {
|
||||
Syslog('m', "Need To Get Address From Msgid start...");
|
||||
@ -547,7 +547,6 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
|
||||
outcode=readcharset(p);
|
||||
else {
|
||||
q = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka);
|
||||
Syslog('m', "start headers checking 1j");
|
||||
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))))
|
||||
@ -707,10 +706,9 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
|
||||
substitute(buf);
|
||||
Syslog('+', "mail from %s to %s",ascfnode(f,0x7f),buf);
|
||||
To = xstrcpy(buf);
|
||||
|
||||
Syslog('m', "Preparing email");
|
||||
// if (p)
|
||||
// free(p);
|
||||
|
||||
p = NULL;
|
||||
p = hdr((char *)"Return-Path",msg);
|
||||
if (p == NULL)
|
||||
|
418
mbfido/mbmail.c
418
mbfido/mbmail.c
@ -1,418 +0,0 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File ..................: mbmail/mbmail.c
|
||||
* Purpose ...............: MBSE BBS Mail Gate
|
||||
* Last modification date : 28-May-2001
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2001
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
* 1971 BV IJmuiden
|
||||
* the Netherlands
|
||||
*
|
||||
* This file is part of MBSE BBS.
|
||||
*
|
||||
* This BBS is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* MBSE BBS is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../lib/libs.h"
|
||||
#include "../lib/structs.h"
|
||||
#include "../lib/records.h"
|
||||
#include "../lib/common.h"
|
||||
#include "../lib/clcomm.h"
|
||||
#include "../lib/dbftn.h"
|
||||
#include "../lib/dbcfg.h"
|
||||
#include "../lib/dbnode.h"
|
||||
#include "../lib/dbmsgs.h"
|
||||
#include "../lib/dbuser.h"
|
||||
#include "hash.h"
|
||||
#include "mkftnhdr.h"
|
||||
#include "message.h"
|
||||
|
||||
|
||||
/* ### Modified by P.Saratxaga on 9 Aug 1995 ###
|
||||
* - added a line so if fmsg->to->name is greater than MAXNAME (35),
|
||||
* and "@" or "%" or "!" is in it; then UUCP is used instead. So we can
|
||||
* send messages to old style fido->email gates (that is, using another
|
||||
* soft than mbmail ;-) ) with long adresses.
|
||||
*/
|
||||
|
||||
extern int most_debug;
|
||||
extern int addrerror;
|
||||
extern int defaultrfcchar;
|
||||
extern int defaultftnchar;
|
||||
extern int do_quiet; /* Quiet flag */
|
||||
extern int e_pid; /* Pid of child process */
|
||||
extern int show_log; /* Show logging on screen */
|
||||
time_t t_start; /* Start time */
|
||||
time_t t_end; /* End time */
|
||||
extern int usetmp;
|
||||
int pgpsigned;
|
||||
extern char *configname;
|
||||
extern char passwd[];
|
||||
int net_in = 0, net_imp = 0, net_out = 0, net_bad = 0;
|
||||
int dirtyoutcode = CHRS_NOTSET;
|
||||
|
||||
|
||||
void ProgName(void)
|
||||
{
|
||||
if (do_quiet)
|
||||
return;
|
||||
|
||||
colour(15, 0);
|
||||
printf("\nMBMAIL: MBSE BBS %s - Internet Fidonet mail gate\n", VERSION);
|
||||
colour(14, 0);
|
||||
printf(" %s\n", Copyright);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Help(void)
|
||||
{
|
||||
do_quiet = FALSE;
|
||||
ProgName();
|
||||
|
||||
colour(11, 0);
|
||||
printf("\nUsage: mbmail -r<addr> -g<grade> <recip> ...\n\n");
|
||||
colour(9, 0);
|
||||
printf(" Commands are:\n\n");
|
||||
colour(3, 0);
|
||||
printf(" -r<addr> address to route packet\n");
|
||||
printf(" -g<grade> [ n | c | h ] \"flavor\" of packet\n");
|
||||
printf(" -c<charset> force the given charset\n");
|
||||
printf(" <recip> list of receipient addresses\n");
|
||||
colour(7, 0);
|
||||
ExitClient(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void die(int onsig)
|
||||
{
|
||||
/*
|
||||
* First check if there is a child running, if so, kill it.
|
||||
*/
|
||||
if (e_pid) {
|
||||
if ((kill(e_pid, SIGTERM)) == 0)
|
||||
Syslog('+', "SIGTERM to pid %d succeeded", e_pid);
|
||||
else {
|
||||
if ((kill(e_pid, SIGKILL)) == 0)
|
||||
Syslog('+', "SIGKILL to pid %d succeeded", e_pid);
|
||||
else
|
||||
WriteError("Failed to kill pid %d", e_pid);
|
||||
}
|
||||
|
||||
/*
|
||||
* In case the child had the tty in raw mode, reset the tty.
|
||||
*/
|
||||
system("stty sane");
|
||||
}
|
||||
|
||||
signal(onsig, SIG_IGN);
|
||||
|
||||
if (!do_quiet) {
|
||||
show_log = TRUE;
|
||||
colour(3, 0);
|
||||
}
|
||||
|
||||
if (onsig) {
|
||||
if (onsig <= NSIG)
|
||||
WriteError("$Terminated on signal %d (%s)", onsig, SigName[onsig]);
|
||||
else
|
||||
WriteError("Terminated with error %d", onsig);
|
||||
}
|
||||
|
||||
Syslog('+', "Msgs in [%4d] imp [%4d] out [%4d] bad [%4d]", net_in, net_imp, net_out, net_bad);
|
||||
|
||||
if (net_out)
|
||||
CreateSema((char *)"scanout");
|
||||
|
||||
|
||||
time(&t_end);
|
||||
Syslog(' ', "MBMAIL finished in %s", t_elapsed(t_start, t_end));
|
||||
|
||||
if (!do_quiet)
|
||||
colour(7, 0);
|
||||
ExitClient(onsig);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *cmd, *envptr;
|
||||
struct passwd *pw;
|
||||
int i, c, rc;
|
||||
char *routec = NULL;
|
||||
faddr *route = NULL;
|
||||
char *p;
|
||||
char buf[BUFSIZ];
|
||||
FILE *fp;
|
||||
fa_list **envrecip, *envrecip_start = NULL;
|
||||
int envrecip_count = 0;
|
||||
rfcmsg *msg=NULL;
|
||||
ftnmsg *fmsg=NULL;
|
||||
faddr *taddr;
|
||||
char cflavor = '\0', flavor;
|
||||
fa_list *sbl = NULL;
|
||||
int incode, outcode;
|
||||
|
||||
#ifdef MEMWATCH
|
||||
mwInit();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The next trick is to supply a fake environment variable
|
||||
* MBSE_ROOT in case we are started from the MTA.
|
||||
* Some MTA's can't change uid to mbse, so if that's the
|
||||
* case we will try it ourself.
|
||||
* This will setup the variable so InitConfig() will work.
|
||||
* The /etc/passwd must point to the correct homedirectory.
|
||||
*/
|
||||
pw = getpwuid(getuid());
|
||||
if (getenv("MBSE_ROOT") == NULL) {
|
||||
pw = getpwuid(getuid());
|
||||
if (strcmp(pw->pw_name, "mbse")) {
|
||||
/*
|
||||
* We are not running as user mbse.
|
||||
*/
|
||||
pw = getpwnam("mbse");
|
||||
if (setuid(pw->pw_uid)) {
|
||||
printf("Fatal error: can't set uid to user mbse\n");
|
||||
}
|
||||
}
|
||||
envptr = xstrcpy((char *)"MBSE_ROOT=");
|
||||
envptr = xstrcat(envptr, pw->pw_dir);
|
||||
putenv(envptr);
|
||||
}
|
||||
|
||||
do_quiet = TRUE;
|
||||
InitConfig();
|
||||
InitFidonet();
|
||||
InitNode();
|
||||
InitMsgs();
|
||||
InitUser();
|
||||
TermInit(1);
|
||||
time(&t_start);
|
||||
umask(002);
|
||||
|
||||
/*
|
||||
* Catch all the signals we can, and ignore the rest.
|
||||
*/
|
||||
for(i = 0; i < NSIG; i++) {
|
||||
|
||||
if ((i == SIGINT) || (i == SIGBUS) || (i == SIGILL) ||
|
||||
(i == SIGSEGV) || (i == SIGTERM) || (i == SIGKILL))
|
||||
signal(i, (void (*))die);
|
||||
else
|
||||
signal(i, SIG_IGN);
|
||||
}
|
||||
|
||||
if (argc < 2)
|
||||
Help();
|
||||
|
||||
cmd = xstrcpy((char *)"Cmd line: mbmail");
|
||||
|
||||
while ((c = getopt(argc, argv, "g:r:c:h")) != -1) {
|
||||
cmd = xstrcat(cmd, (char *)" - ");
|
||||
cmd[strlen(cmd) -1] = c;
|
||||
switch (c) {
|
||||
case 'h': Help();
|
||||
case 'g': if (optarg && ((*optarg == 'n') || (*optarg == 'c') || (*optarg == 'h'))) {
|
||||
cflavor = *optarg;
|
||||
cmd = xstrcat(cmd, optarg);
|
||||
} else {
|
||||
Help();
|
||||
}
|
||||
break;
|
||||
case 'r': routec = optarg; cmd = xstrcat(cmd, optarg); break;
|
||||
case 'c': dirtyoutcode = readchrs(optarg);
|
||||
cmd = xstrcat(cmd, optarg);
|
||||
if (dirtyoutcode == CHRS_NOTSET)
|
||||
dirtyoutcode = getcode(optarg);
|
||||
break;
|
||||
default: Help();
|
||||
}
|
||||
}
|
||||
|
||||
ProgName();
|
||||
InitClient(pw->pw_name, (char *)"mbmail", CFG.location, CFG.logfile, CFG.util_loglevel, CFG.error_log);
|
||||
|
||||
Syslog(' ', " ");
|
||||
Syslog(' ', "MBMAIL v%s", VERSION);
|
||||
most_debug = TRUE;
|
||||
|
||||
if (!diskfree(CFG.freespace))
|
||||
die(101);
|
||||
|
||||
|
||||
if (cflavor == 'n')
|
||||
cflavor='o';
|
||||
|
||||
if ((routec) && ((route=parsefaddr(routec)) == NULL))
|
||||
WriteError("unparsable route address \"%s\" (%s)", MBSE_SS(routec),addrerrstr(addrerror));
|
||||
|
||||
if ((p=strrchr(argv[0],'/')))
|
||||
p++;
|
||||
else
|
||||
p=argv[0];
|
||||
|
||||
envrecip = &envrecip_start;
|
||||
while (argv[optind]) {
|
||||
cmd = xstrcat(cmd, (char *)" ");
|
||||
cmd = xstrcat(cmd, argv[optind]);
|
||||
if ((taddr = parsefaddr(argv[optind++]))) {
|
||||
(*envrecip)=(fa_list*)malloc(sizeof(fa_list));
|
||||
(*envrecip)->next=NULL;
|
||||
(*envrecip)->addr=taddr;
|
||||
envrecip=&((*envrecip)->next);
|
||||
envrecip_count++;
|
||||
} else
|
||||
WriteError("unparsable recipient \"%s\" (%s), ignored", argv[optind-1], addrerrstr(addrerror));
|
||||
}
|
||||
Syslog(' ', cmd);
|
||||
free(cmd);
|
||||
|
||||
if (!envrecip_count) {
|
||||
WriteError("No valid receipients specified, aborting");
|
||||
die(105);
|
||||
}
|
||||
|
||||
for (envrecip = &envrecip_start; *envrecip; envrecip = &((*envrecip)->next))
|
||||
Syslog('+', "envrecip: %s",ascfnode((*envrecip)->addr,0x7f));
|
||||
Syslog('+', "route: %s",ascfnode(route,0x1f));
|
||||
|
||||
umask(066); /* packets may contain confidential information */
|
||||
|
||||
while (!feof(stdin)) {
|
||||
usetmp = 0;
|
||||
tidyrfc(msg);
|
||||
msg = parsrfc(stdin);
|
||||
|
||||
incode = outcode = CHRS_NOTSET;
|
||||
pgpsigned = 0;
|
||||
|
||||
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 *)"Message-ID",msg)) && (chkftnmsgid(p)))
|
||||
incode = defaultftnchar;
|
||||
else
|
||||
incode = defaultrfcchar;
|
||||
}
|
||||
if ((p = hdr((char *)"Content-Type",msg)) && ((strcasestr(p, (char *)"multipart/signed")) ||
|
||||
(strcasestr(p,(char *)"application/pgp")))) {
|
||||
pgpsigned = 1;
|
||||
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);
|
||||
|
||||
flavor = cflavor;
|
||||
|
||||
if ((p = hdr((char *)"X-FTN-FLAGS",msg))) {
|
||||
if (!flavor) {
|
||||
if (flag_on((char *)"CRS",p))
|
||||
flavor = 'c';
|
||||
else if (flag_on((char *)"HLD",p))
|
||||
flavor = 'h';
|
||||
else
|
||||
flavor = 'o';
|
||||
}
|
||||
if (flag_on((char *)"ATT",p))
|
||||
attach(*route, hdr((char *)"Subject",msg), 0, flavor);
|
||||
if (flag_on((char *)"TFS",p))
|
||||
attach(*route, hdr((char *)"Subject",msg), 1, flavor);
|
||||
if (flag_on((char *)"KFS",p))
|
||||
attach(*route, hdr((char *)"Subject",msg), 2, flavor);
|
||||
}
|
||||
if ((!flavor) && ((p = hdr((char *)"Priority",msg)) ||
|
||||
(p = hdr((char *)"Precedence",msg)) || (p = hdr((char *)"X-Class",msg)))) {
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
if ((strncasecmp(p,"fast",4) == 0) || (strncasecmp(p,"high",4) == 0) ||
|
||||
(strncasecmp(p,"crash",5) == 0) || (strncasecmp(p,"airmail",5) == 0) ||
|
||||
(strncasecmp(p,"special-delivery",5) == 0) || (strncasecmp(p,"first-class",5) == 0))
|
||||
flavor='c';
|
||||
else if ((strncasecmp(p,"slow",4) == 0) || (strncasecmp(p,"low",3) == 0) ||
|
||||
(strncasecmp(p,"hold",4) == 0) || (strncasecmp(p,"news",4) == 0) ||
|
||||
(strncasecmp(p,"bulk",4) == 0) || (strncasecmp(p,"junk",4) == 0))
|
||||
flavor='h';
|
||||
}
|
||||
if (!flavor)
|
||||
flavor='o';
|
||||
|
||||
if (envrecip_count > 1) {
|
||||
if ((fp = tmpfile()) == NULL) {
|
||||
WriteError("$Cannot open temporary file");
|
||||
die(102);
|
||||
}
|
||||
while (bgets(buf, sizeof(buf)-1, stdin))
|
||||
fputs(buf, fp);
|
||||
rewind(fp);
|
||||
usetmp = 1;
|
||||
} else {
|
||||
fp = stdin;
|
||||
usetmp = 0;
|
||||
}
|
||||
|
||||
tidy_ftnmsg(fmsg);
|
||||
if ((fmsg = mkftnhdr(msg, incode, outcode, FALSE)) == NULL) {
|
||||
WriteError("Unable to create FTN headers from RFC ones, aborting");
|
||||
die(103);
|
||||
}
|
||||
|
||||
for (envrecip = &envrecip_start; *envrecip; envrecip = &((*envrecip)->next)) {
|
||||
fmsg->to = (*envrecip)->addr;
|
||||
if ((!fmsg->to->name) || ((strlen(fmsg->to->name) > MAXNAME)
|
||||
&& ((strstr(fmsg->to->name,"@")) || (strstr(fmsg->to->name,"%"))
|
||||
|| (strstr(fmsg->to->name,"!")))))
|
||||
fmsg->to->name = (char *)"UUCP";
|
||||
rc = putmessage(msg, fmsg, fp, route, flavor, &sbl, incode, outcode);
|
||||
if (rc == 1) {
|
||||
WriteError("Unable to put netmail message into the packet, aborting");
|
||||
die(104);
|
||||
}
|
||||
if (rc == 2) {
|
||||
WriteError("Unable to import netmail messages into the messabe base");
|
||||
die(105);
|
||||
}
|
||||
if (usetmp)
|
||||
rewind(fp);
|
||||
fmsg->to = NULL;
|
||||
}
|
||||
net_in++;
|
||||
if (usetmp)
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
closepkt();
|
||||
die(0);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,6 +0,0 @@
|
||||
#ifndef _MBMAIL_H
|
||||
#define _MBMAIL_H
|
||||
|
||||
|
||||
#endif
|
||||
|
882
mbfido/message.c
882
mbfido/message.c
@ -1,882 +0,0 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File ..................: mbmail/message.c
|
||||
* Purpose ...............: MBSE BBS Mail Gate
|
||||
* Last modification date : 27-Jul-2001
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2001
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
* 1971 BV IJmuiden
|
||||
* the Netherlands
|
||||
*
|
||||
* This file is part of MBSE BBS.
|
||||
*
|
||||
* This BBS is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* MBSE BBS is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../lib/libs.h"
|
||||
#include "../lib/structs.h"
|
||||
#include "../lib/records.h"
|
||||
#include "../lib/common.h"
|
||||
#include "../lib/clcomm.h"
|
||||
#include "../lib/dbcfg.h"
|
||||
#include "../lib/dbuser.h"
|
||||
|
||||
|
||||
/* ### Modified by P.Saratxaga on 7 Aug 1995 ###
|
||||
* - Newsgroups: line is now gated if there is more than one newsgroup
|
||||
* - Added support for X-FTN-To and X-FTN-From generated by other gates
|
||||
* - modified removemime to kludgerise lines if charset != us-ascii
|
||||
* - creation of ^aACUPDATE kludges from Supersedes: and cancel's
|
||||
* - added charset support (see Changelog for details)
|
||||
* - added recognition of X-Fsc-
|
||||
* - added support to dequote MIME quoted printable messages. Code by T.Tanaka
|
||||
* - added removemsgid and removeinreply
|
||||
*/
|
||||
#include "bread.h"
|
||||
#include "bwrite.h"
|
||||
#include "hash.h"
|
||||
#include "mkftnhdr.h"
|
||||
#include "tracker.h"
|
||||
#include "viadate.h"
|
||||
#include "storenet.h"
|
||||
|
||||
|
||||
#define MAXHDRSIZE 2048
|
||||
#define MAXSEEN 70
|
||||
#define MAXPATH 73
|
||||
|
||||
|
||||
extern time_t now;
|
||||
extern char *replyaddr;
|
||||
extern faddr *bestaka;
|
||||
extern int pgpsigned;
|
||||
extern int net_bad;
|
||||
extern int net_out;
|
||||
extern char *ftnmsgidstyle;
|
||||
|
||||
|
||||
char *subj;
|
||||
char *localdomain=NULL;
|
||||
static int removemime;
|
||||
static int removeorg;
|
||||
static int removemsgid;
|
||||
static int removeref;
|
||||
static int removeinreply;
|
||||
static int removesupersedes;
|
||||
static int removeapproved;
|
||||
static int removefrom;
|
||||
static int removereplyto;
|
||||
static int removereturnto;
|
||||
static int ftnorigin;
|
||||
|
||||
|
||||
void StatAdd(statcnt *S, unsigned long V)
|
||||
{
|
||||
S->total += V;
|
||||
S->tweek += V;
|
||||
S->tdow[Diw] += V;
|
||||
S->month[Miy] += V;
|
||||
}
|
||||
|
||||
|
||||
int needputrfc(rfcmsg *msg)
|
||||
{
|
||||
faddr *ta;
|
||||
|
||||
/* 0-junk, 1-kludge, 2-pass */
|
||||
|
||||
if (!strcasecmp(msg->key,"X-UUCP-From"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"X-Body-Start"))
|
||||
return 0;
|
||||
if (!strncasecmp(msg->key,".",1))
|
||||
return 0;
|
||||
if (!strncasecmp(msg->key,"X-FTN-",6))
|
||||
return 0;
|
||||
if (!strncasecmp(msg->key,"X-Fsc-",6))
|
||||
return 0;
|
||||
if (!strncasecmp(msg->key,"X-ZC-",5))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"X-Gateway"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"Path"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"Newsgroups")) {
|
||||
if ((hdr((char *)"X-Origin-Newsgroups",msg)))
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
if (!strcasecmp(msg->key,"X-Origin-Newsgroups")) {
|
||||
return 1;
|
||||
}
|
||||
if (!strcasecmp(msg->key,"Control")) {
|
||||
if (CFG.allowcontrol) {
|
||||
if (strstr(msg->val,"cancel"))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
if (!strcasecmp(msg->key,"Return-Path"))
|
||||
return 1;
|
||||
if (!strcasecmp(msg->key,"Xref"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"Approved"))
|
||||
return removeapproved ?0:2;
|
||||
if (!strcasecmp(msg->key,"X-URL"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"Return-Receipt-To"))
|
||||
return removereturnto ?0:1;
|
||||
if (!strcasecmp(msg->key,"Notice-Requested-Upon-Delivery-To"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"Received")) {
|
||||
return ftnorigin ?0:1;
|
||||
}
|
||||
if (!strcasecmp(msg->key,"From")) {
|
||||
if ((ta=parsefaddr(msg->val))) {
|
||||
tidy_faddr(ta);
|
||||
return 0;
|
||||
} else
|
||||
return removefrom ?0:2;
|
||||
}
|
||||
if (!strcasecmp(msg->key,"To")) {
|
||||
if ((ta=parsefaddr(msg->val))) {
|
||||
tidy_faddr(ta);
|
||||
return 0;
|
||||
} else
|
||||
return 2;
|
||||
}
|
||||
if (!strcasecmp(msg->key,"Cc"))
|
||||
return 2;
|
||||
if (!strcasecmp(msg->key,"Bcc"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"Reply-To")) {
|
||||
if ((ta=parsefaddr(msg->val))) {
|
||||
tidy_faddr(ta);
|
||||
return 0;
|
||||
} else
|
||||
return removereplyto ?0:2;
|
||||
}
|
||||
if (!strcasecmp(msg->key,"Lines"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"Date"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"Subject")) {
|
||||
if ((msg->val) && (strlen(msg->val) > MAXSUBJ))
|
||||
return 2;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
if (!strcasecmp(msg->key,"Organization"))
|
||||
return removeorg ?0:1;
|
||||
if (!strcasecmp(msg->key,"Comment-To"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"X-Comment-To"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"X-Apparently-To"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"Apparently-To"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"X-Fidonet-Comment-To"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"Keywords"))
|
||||
return 2;
|
||||
if (!strcasecmp(msg->key,"Summary"))
|
||||
return 2;
|
||||
if (!strcasecmp(msg->key,"MIME-Version"))
|
||||
return removemime ?0:1;
|
||||
if (!strcasecmp(msg->key,"Content-Type"))
|
||||
return removemime ?0:1;
|
||||
if (!strcasecmp(msg->key,"Content-Length"))
|
||||
return removemime ?0:1;
|
||||
if (!strcasecmp(msg->key,"Content-Transfer-Encoding"))
|
||||
return removemime ?0:1;
|
||||
if (!strcasecmp(msg->key,"Content-Name"))
|
||||
return 2;
|
||||
if (!strcasecmp(msg->key,"Content-Description"))
|
||||
return 2;
|
||||
if (!strcasecmp(msg->key,"Message-ID"))
|
||||
return removemsgid ?0:1;
|
||||
if (!strcasecmp(msg->key,"References"))
|
||||
return removeref ?0:1;
|
||||
if (!strcasecmp(msg->key,"In-Reply-To"))
|
||||
return removeinreply ?0:1;
|
||||
if (!strcasecmp(msg->key,"Supersedes"))
|
||||
return removesupersedes ?0:1;
|
||||
if (!strcasecmp(msg->key,"Distribution"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"X-Newsreader"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"X-Mailer"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"User-Agent"))
|
||||
return 0;
|
||||
if (!strncasecmp(msg->key,"NNTP-",5))
|
||||
return 0;
|
||||
if (!strncasecmp(msg->key,"X-Trace",7))
|
||||
return 0;
|
||||
if (!strncasecmp(msg->key,"X-Complaints",12))
|
||||
return 0;
|
||||
if (!strncasecmp(msg->key,"X-MSMail",9))
|
||||
return 0;
|
||||
if (!strncasecmp(msg->key,"X-MimeOLE",9))
|
||||
return 0;
|
||||
if (!strncasecmp(msg->key,"X-MIME-Autoconverted",20))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"X-Origin-Date"))
|
||||
return 0;
|
||||
if (!strncasecmp(msg->key,"X-PGP-",6))
|
||||
return 0;
|
||||
if (!strncasecmp(msg->key,"Resent-",7))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"X-Mailing-List"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"X-Loop"))
|
||||
return 0;
|
||||
if (!strcasecmp(msg->key,"Precedence"))
|
||||
return 0;
|
||||
/*if (!strcasecmp(msg->key,"")) return ;*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int putmessage(rfcmsg *msg, ftnmsg *fmsg, FILE *fp, faddr *route, char flavor,fa_list **sbl, int incode, int outcode)
|
||||
{
|
||||
char buf[BUFSIZ],*p,*q,newsubj[4 * (MAXSUBJ+1)],*oldsubj;
|
||||
rfcmsg *tmp;
|
||||
int rfcheaders, postlocal;
|
||||
int needsplit,hdrsize,datasize,splitpart,forbidsplit;
|
||||
int sot_kludge, eot_kludge;
|
||||
int qp_or_base64; /* 0=plain text, 1=quoted-printable, 2=base64 */
|
||||
int html_message;
|
||||
int tinyorigin=0;
|
||||
fa_list *ptl=NULL;
|
||||
faddr *ta;
|
||||
int i;
|
||||
FILE *pkt;
|
||||
fidoaddr Dest, Route, *dest;
|
||||
time_t Now;
|
||||
|
||||
Syslog('m', "putmessage from %s",ascfnode(fmsg->from,0x7f));
|
||||
Syslog('m', "putmessage to %s",ascfnode(fmsg->to,0x7f));
|
||||
Syslog('m', "putmessage subj %s",MBSE_SS(fmsg->subj));
|
||||
Syslog('m', "putmessage flags %04x",fmsg->flags);
|
||||
Syslog('m', "putmessage msgid %s %lx",MBSE_SS(fmsg->msgid_a),fmsg->msgid_n);
|
||||
Syslog('m', "putmessage reply %s %lx",MBSE_SS(fmsg->reply_a),fmsg->reply_n);
|
||||
Syslog('m', "putmessage date %s",ftndate(fmsg->date));
|
||||
|
||||
removemime = FALSE;
|
||||
removeorg = FALSE;
|
||||
removemsgid = FALSE;
|
||||
removeref = FALSE;
|
||||
removeinreply = FALSE;
|
||||
removesupersedes = FALSE;
|
||||
removeapproved = FALSE;
|
||||
removefrom = TRUE;
|
||||
removereplyto = TRUE;
|
||||
removereturnto = TRUE;
|
||||
ftnorigin=fmsg->ftnorigin;
|
||||
sot_kludge = 0;
|
||||
eot_kludge = 0;
|
||||
qp_or_base64 = 0;
|
||||
html_message = 0;
|
||||
|
||||
if ((hdr((char *)"X-PGP-Signed",msg)))
|
||||
pgpsigned = TRUE;
|
||||
Syslog('m', "pgpsigned = %s", pgpsigned ? "True":"False");
|
||||
|
||||
q = hdr((char *)"Content-Transfer-Encoding",msg);
|
||||
if (q)
|
||||
while (*q && isspace(*q))
|
||||
q++;
|
||||
if (!(q))
|
||||
q = (char *)"8bit";
|
||||
if ((p = hdr((char *)"Content-Type",msg))) {
|
||||
while (*p && isspace(*p))
|
||||
p++;
|
||||
|
||||
/*
|
||||
* turn the quoted-printable decode mode on; remember FTN is virtually 8-bit clean
|
||||
*/
|
||||
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)))
|
||||
removemime = TRUE; /* no need in MIME headers */
|
||||
|
||||
/*
|
||||
* some old MUA puts "text" instead of "text/plain; charset=..."
|
||||
*/
|
||||
else if ((strcasecmp(p,"text\n") == 0))
|
||||
removemime = TRUE;
|
||||
|
||||
}
|
||||
Syslog('m', "removemime=%s, qp_or_base64 = %d, html_message=%s", removemime ? "True":"False", qp_or_base64,
|
||||
html_message ? "True":"False");
|
||||
|
||||
if ((p = hdr((char *)"Message-ID",msg))) {
|
||||
if (!removemsgid)
|
||||
removemsgid = chkftnmsgid(p);
|
||||
}
|
||||
Syslog('m', "removemsgid = %s", removemsgid ? "True":"False");
|
||||
|
||||
if ((p = hdr((char *)"In-Reply-To",msg))) {
|
||||
p = xstrcpy(p);
|
||||
q = strtok(p," \t\n");
|
||||
if ((q) && (strtok(NULL," \t\n") == NULL))
|
||||
removeinreply = chkftnmsgid(q);
|
||||
free(p);
|
||||
}
|
||||
Syslog('m', "removeinreply = %s", removeinreply ? "True":"False");
|
||||
|
||||
if ((p = hdr((char *)"Reply-To",msg))) {
|
||||
removereplyto = FALSE;
|
||||
if ((!removereplyto) && (q = hdr((char *)"From",msg))) {
|
||||
char *r;
|
||||
r = xstrcpy(p);
|
||||
p = r;
|
||||
while(*p && isspace(*p))
|
||||
p++;
|
||||
if (p[strlen(p)-1] == '\n')
|
||||
p[strlen(p)-1]='\0';
|
||||
if (strcasestr(q,p))
|
||||
removereplyto = TRUE;
|
||||
free(r);
|
||||
}
|
||||
}
|
||||
Syslog('m', "removereplyto = %s", removereplyto ? "True":"False");
|
||||
|
||||
if ((p = hdr((char *)"Return-Receipt-To",msg))) {
|
||||
removereturnto = FALSE;
|
||||
if ((!removereturnto) && (q=hdr((char *)"From",msg))) {
|
||||
char *r;
|
||||
r = xstrcpy(p); p = r;
|
||||
while(*p && isspace(*p))
|
||||
p++;
|
||||
if (p[strlen(p)-1] == '\n')
|
||||
p[strlen(p)-1]='\0';
|
||||
if (strcasestr(q,p))
|
||||
removereturnto = TRUE;
|
||||
// free(r);
|
||||
}
|
||||
}
|
||||
Syslog('m', "removereturnto = %s", removereturnto ? "True":"False");
|
||||
|
||||
p = ascfnode(fmsg->from,0x1f);
|
||||
i = 79-11-3-strlen(p);
|
||||
if (ftnorigin && fmsg->origin && (strlen(fmsg->origin) > i)) {
|
||||
/* This is a kludge... I don't like it too much. But well,
|
||||
if this is a message of FTN origin, the original origin (:)
|
||||
line MUST have been short enough to fit in 79 chars...
|
||||
So we give it a try. Probably it would be better to keep
|
||||
the information about the address format from the origin
|
||||
line in a special X-FTN-... header, but this seems even
|
||||
less elegant. Any _good_ ideas, anyone? */
|
||||
|
||||
/* OK, I am keeping this, though if should never be used
|
||||
al long as X-FTN-Origin is used now */
|
||||
|
||||
p = ascfnode(fmsg->from,0x0f);
|
||||
i = 79-11-3-strlen(p);
|
||||
tinyorigin = TRUE;
|
||||
}
|
||||
Syslog('m', "tinyorigin = %s", tinyorigin ? "True":"False");
|
||||
|
||||
if ((fmsg->origin) && (strlen(fmsg->origin) > i))
|
||||
fmsg->origin[i]='\0';
|
||||
forbidsplit=(ftnorigin || (hdr((char *)"X-FTN-Split",msg)));
|
||||
needsplit = 0;
|
||||
splitpart = 0;
|
||||
hdrsize = 20;
|
||||
hdrsize += (fmsg->subj)?strlen(fmsg->subj):0;
|
||||
if (fmsg->from)
|
||||
hdrsize += (fmsg->from->name)?strlen(fmsg->from->name):0;
|
||||
if (fmsg->to)
|
||||
hdrsize += (fmsg->to->name)?strlen(fmsg->to->name):0;
|
||||
do {
|
||||
Syslog('m', "split loop, splitpart = %d", splitpart);
|
||||
datasize=0;
|
||||
|
||||
if (splitpart) {
|
||||
sprintf(newsubj,"[part %d] ",splitpart+1);
|
||||
strncat(newsubj,fmsg->subj,MAXSUBJ-strlen(newsubj));
|
||||
} else {
|
||||
strncpy(newsubj,fmsg->subj,MAXSUBJ);
|
||||
}
|
||||
strcpy(newsubj, hdrnconv(newsubj, incode, outcode, MAXSUBJ));
|
||||
newsubj[MAXSUBJ]='\0';
|
||||
|
||||
if (splitpart) {
|
||||
hash_update_n(&fmsg->msgid_n,splitpart);
|
||||
}
|
||||
|
||||
oldsubj=fmsg->subj;
|
||||
fmsg->subj=newsubj;
|
||||
|
||||
/*
|
||||
* We got the routing address from the mailer which was given by our Host's sendmail.
|
||||
* This is probably our address so we need to get the address for the next hop.
|
||||
*/
|
||||
dest = faddr2fido(fmsg->to);
|
||||
memcpy(&Dest, dest, sizeof(fidoaddr));
|
||||
free(dest);
|
||||
if (TrackMail(Dest, &Route) == R_LOCAL) {
|
||||
/*
|
||||
* Mail for our local system. Instead of adding the message to a .pkt create
|
||||
* a temporary file which later will be send via the storenet function.
|
||||
*/
|
||||
postlocal = TRUE;
|
||||
pkt = tmpfile();
|
||||
} else {
|
||||
/*
|
||||
* New outbound route.
|
||||
*/
|
||||
route = fido2faddr(Route);
|
||||
postlocal = FALSE;
|
||||
if ((pkt = ftnmsghdr(fmsg, NULL, route, flavor, (char *)"MBSE-FIDO")) == NULL) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
fmsg->subj=oldsubj;
|
||||
|
||||
Syslog('m', "replyaddr=%s removereplyto=%s removefrom=%s",
|
||||
printable(replyaddr, 0), removereplyto?"True":"False", removefrom?"True":"False");
|
||||
|
||||
/*
|
||||
* Add FTN MSGID: and REPLY: if needed.
|
||||
*/
|
||||
Now = time(NULL) - (gmt_offset((time_t)0) * 60);
|
||||
if (postlocal) {
|
||||
fprintf(pkt, "\001MSGID: %s %08lx\n", MBSE_SS(fmsg->msgid_a),fmsg->msgid_n);
|
||||
if (fmsg->reply_s)
|
||||
fprintf(pkt, "\1REPLY: %s\n", fmsg->reply_s);
|
||||
else if (fmsg->reply_a)
|
||||
fprintf(pkt, "\1REPLY: %s %08lx\n", fmsg->reply_a, fmsg->reply_n);
|
||||
fprintf(pkt, "\001TZUTC: %s\n", gmtoffset(Now));
|
||||
} else {
|
||||
fprintf(pkt, "\001MSGID: %s %08lx\r", MBSE_SS(fmsg->msgid_a),fmsg->msgid_n);
|
||||
if (fmsg->reply_s)
|
||||
fprintf(pkt, "\1REPLY: %s\r", fmsg->reply_s);
|
||||
else if (fmsg->reply_a)
|
||||
fprintf(pkt, "\1REPLY: %s %08lx\r", fmsg->reply_a, fmsg->reply_n);
|
||||
fprintf(pkt, "\001TZUTC: %s\r", gmtoffset(Now));
|
||||
}
|
||||
|
||||
if ((p=hdr((char *)"X-FTN-REPLYADDR",msg))) {
|
||||
hdrsize += 10+strlen(p);
|
||||
fprintf(pkt,"\1REPLYADDR:");
|
||||
kwrite(p,pkt,postlocal);
|
||||
} else if ((replyaddr) && ((!removereplyto) || (!removefrom))) {
|
||||
hdrsize += 10+strlen(replyaddr);
|
||||
fprintf(pkt,"\1REPLYADDR: ");
|
||||
kwrite(replyaddr,pkt,postlocal);
|
||||
}
|
||||
|
||||
if ((p=hdr((char *)"X-FTN-REPLYTO",msg))) {
|
||||
hdrsize += 8+strlen(p);
|
||||
fprintf(pkt,"\1REPLYTO:");
|
||||
kwrite(p,pkt,postlocal);
|
||||
} else if ((replyaddr) && ((!removereplyto) || (!removefrom))) {
|
||||
hdrsize += 15;
|
||||
if (postlocal)
|
||||
fprintf(pkt,"\1REPLYTO: %s UUCP\n", ascfnode(bestaka,0x1f));
|
||||
else
|
||||
fprintf(pkt,"\1REPLYTO: %s UUCP\r", ascfnode(bestaka,0x1f));
|
||||
} else if ((p=hdr((char *)"Reply-To",msg))) {
|
||||
if ((ta=parsefaddr(p))) {
|
||||
if ((q=hdr((char *)"From",msg))) {
|
||||
if (!strcasestr(q,p)) {
|
||||
if (postlocal)
|
||||
fprintf(pkt,"\1REPLYTO: %s %s\n", ascfnode(ta,0x1f), ta->name);
|
||||
else
|
||||
fprintf(pkt,"\1REPLYTO: %s %s\r", ascfnode(ta,0x1f), ta->name);
|
||||
}
|
||||
tidy_faddr(ta);
|
||||
}
|
||||
}
|
||||
/* Added 15-Apr-2001 MB. Add UUCP reply info if there is nothing. */
|
||||
} else if ((p=hdr((char *)"X-UUCP-From",msg)) && (q=hdr((char *)"From",msg))) {
|
||||
hdrsize += 15;
|
||||
Striplf(q);
|
||||
if (postlocal) {
|
||||
fprintf(pkt,"\1REPLYADDR: %s\n", q);
|
||||
fprintf(pkt,"\1REPLYTO: %s UUCP\n", ascfnode(bestaka,0x1f));
|
||||
} else {
|
||||
fprintf(pkt,"\1REPLYADDR: %s\r", q);
|
||||
fprintf(pkt,"\1REPLYTO: %s UUCP\r", ascfnode(bestaka,0x1f));
|
||||
}
|
||||
}
|
||||
|
||||
if ((p=strip_flags(hdr((char *)"X-FTN-FLAGS",msg)))) {
|
||||
hdrsize += 15;
|
||||
if (postlocal)
|
||||
fprintf(pkt,"\1FLAGS:%s\n",p);
|
||||
else
|
||||
fprintf(pkt,"\1FLAGS:%s\r",p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
if (!hdr((char *)"X-FTN-PID", msg)) {
|
||||
p = hdr((char *)"User-Agent", msg);
|
||||
if (p == NULL)
|
||||
p = hdr((char *)"X-Newsreader", msg);
|
||||
if (p == NULL)
|
||||
p = hdr((char *)"X-Mailer", msg);
|
||||
if (p) {
|
||||
hdrsize += 4 + strlen(p);
|
||||
fprintf(pkt, "\1PID:");
|
||||
kwrite(p, pkt, postlocal);
|
||||
} else {
|
||||
if (postlocal)
|
||||
fprintf(pkt, "\001PID: MBSE-MAIL %s\n", VERSION);
|
||||
else
|
||||
fprintf(pkt, "\001PID: MBSE-MAIL %s\r", VERSION);
|
||||
}
|
||||
}
|
||||
|
||||
hdrsize += 15;
|
||||
if (postlocal)
|
||||
writechrs(outcode,pkt,3);
|
||||
else
|
||||
writechrs(outcode,pkt,1);
|
||||
|
||||
if (html_message) {
|
||||
hdrsize += 9;
|
||||
if (postlocal)
|
||||
fprintf(pkt, "\1HTML: 5\n");
|
||||
else
|
||||
fprintf(pkt, "\1HTML: 5\r");
|
||||
}
|
||||
|
||||
#ifdef FSC_0070
|
||||
/* FSC-0070 */
|
||||
if ((p = hdr((char *)"Message-ID", msg)) && !(hdr((char *)"X-FTN-RFCID", msg))) {
|
||||
q = strdup(p);
|
||||
fprintf(pkt,"\1RFCID:");
|
||||
if ((l = strrchr(q, '<')) && (r = strchr(q, '>')) && (l < r)) {
|
||||
*l++ = ' ';
|
||||
while(*l && isspace(*l))
|
||||
l++;
|
||||
l--; /* leading ' ' */
|
||||
*r-- = '\0';
|
||||
while(*r && isspace(*r))
|
||||
*r-- = '\0';
|
||||
} else
|
||||
l = q;
|
||||
kwrite(l, pkt, postlocal);
|
||||
hdrsize += 6 + strlen(l);
|
||||
free(q);
|
||||
}
|
||||
#endif /* FSC_0070 */
|
||||
|
||||
if (!(hdr((char *)"X-FTN-Tearline", msg)) && !(hdr((char *)"X-FTN-TID", msg))) {
|
||||
sprintf(buf, " mbmail %s", VERSION);
|
||||
hdrsize += 4 + strlen(buf);
|
||||
fprintf(pkt, "\1TID:");
|
||||
kwrite(buf, pkt, postlocal);
|
||||
}
|
||||
|
||||
if ((splitpart == 0) || (hdrsize < MAXHDRSIZE)) {
|
||||
for (tmp=msg;tmp;tmp=tmp->next)
|
||||
if ((!strncmp(tmp->key,"X-Fsc-",6)) ||
|
||||
(!strncmp(tmp->key,"X-FTN-",6) &&
|
||||
strcasecmp(tmp->key,"X-FTN-Tearline") &&
|
||||
strcasecmp(tmp->key,"X-FTN-Origin") &&
|
||||
strcasecmp(tmp->key,"X-FTN-Sender") &&
|
||||
strcasecmp(tmp->key,"X-FTN-Split") &&
|
||||
strcasecmp(tmp->key,"X-FTN-FLAGS") &&
|
||||
strcasecmp(tmp->key,"X-FTN-AREA") &&
|
||||
strcasecmp(tmp->key,"X-FTN-MSGID") &&
|
||||
strcasecmp(tmp->key,"X-FTN-REPLY") &&
|
||||
strcasecmp(tmp->key,"X-FTN-SEEN-BY") &&
|
||||
strcasecmp(tmp->key,"X-FTN-PATH") &&
|
||||
strcasecmp(tmp->key,"X-FTN-REPLYADDR") &&
|
||||
strcasecmp(tmp->key,"X-FTN-REPLYTO") &&
|
||||
strcasecmp(tmp->key,"X-FTN-To") &&
|
||||
strcasecmp(tmp->key,"X-FTN-From") &&
|
||||
strcasecmp(tmp->key,"X-FTN-CHARSET") &&
|
||||
strcasecmp(tmp->key,"X-FTN-CHRS") &&
|
||||
strcasecmp(tmp->key,"X-FTN-CODEPAGE") &&
|
||||
strcasecmp(tmp->key,"X-FTN-ORIGCHRS") &&
|
||||
strcasecmp(tmp->key,"X-FTN-SOT") &&
|
||||
strcasecmp(tmp->key,"X-FTN-EOT") &&
|
||||
strcasecmp(tmp->key,"X-FTN-Via"))) {
|
||||
if (strcasecmp(tmp->key,"X-FTN-KLUDGE") == 0) {
|
||||
if (!strcasecmp(tmp->val," SOT:\n"))
|
||||
sot_kludge = 1;
|
||||
else if (!strcasecmp(tmp->val," EOT:\n"))
|
||||
eot_kludge = 1;
|
||||
else {
|
||||
hdrsize += strlen(tmp->val);
|
||||
fprintf(pkt,"\1");
|
||||
/* we should have restored the original string here... */
|
||||
kwrite((tmp->val)+1, pkt, postlocal);
|
||||
}
|
||||
} else {
|
||||
hdrsize += strlen(tmp->key)+strlen(tmp->val);
|
||||
fprintf(pkt,"\1%s:",tmp->key+6);
|
||||
kwrite(tmp->val, pkt, postlocal);
|
||||
}
|
||||
}
|
||||
/* ZConnect are X-ZC-*: in usenet, \1ZC-*: in FTN */
|
||||
for (tmp=msg;tmp;tmp=tmp->next)
|
||||
if ((!strncmp(tmp->key,"X-ZC-",5))) {
|
||||
hdrsize += strlen(tmp->key)+strlen(tmp->val);
|
||||
fprintf(pkt, "\1%s:", tmp->key+2);
|
||||
kwrite(tmp->val, pkt, postlocal);
|
||||
}
|
||||
/* mondo.org gateway uses ".MSGID: ..." in usenet */
|
||||
for (tmp=msg;tmp;tmp=tmp->next)
|
||||
if ((!strncmp(tmp->key,".",1)) && (strcasecmp(tmp->key,".MSGID"))) {
|
||||
hdrsize += strlen(tmp->key)+strlen(tmp->val);
|
||||
fprintf(pkt,"\1%s:",tmp->key+1);
|
||||
kwrite(tmp->val, pkt, postlocal);
|
||||
}
|
||||
|
||||
rfcheaders = 0;
|
||||
for (tmp=msg;tmp;tmp=tmp->next)
|
||||
if ((needputrfc(tmp) == 1)) {
|
||||
if (strcasestr((char *)"X-Origin-Newsgroups",tmp->key)) {
|
||||
hdrsize += 10+strlen(tmp->val);
|
||||
fprintf(pkt,"\1RFC-Newsgroups:");
|
||||
} else {
|
||||
hdrsize += strlen(tmp->key)+strlen(tmp->val);
|
||||
fprintf(pkt,"\1RFC-%s:",tmp->key);
|
||||
}
|
||||
kwrite(hdrconv(tmp->val, incode, outcode),pkt, postlocal);
|
||||
}
|
||||
for (tmp=msg;tmp;tmp=tmp->next)
|
||||
if ((needputrfc(tmp) > 1)) {
|
||||
rfcheaders++;
|
||||
if (strcasestr((char *)"X-Origin-Newsgroups",tmp->key)) {
|
||||
hdrsize += 10+strlen(tmp->val);
|
||||
fprintf(pkt,"Newsgroups:");
|
||||
} else {
|
||||
hdrsize += strlen(tmp->key)+strlen(tmp->val);
|
||||
fprintf(pkt,"%s:",tmp->key);
|
||||
}
|
||||
cwrite(hdrconv(tmp->val, incode, outcode),pkt,postlocal);
|
||||
}
|
||||
if (rfcheaders)
|
||||
cwrite((char *)"\n",pkt, postlocal);
|
||||
if ((hdr((char *)"X-FTN-SOT",msg)) || (sot_kludge)) {
|
||||
if (postlocal)
|
||||
fprintf(pkt,"\1SOT:\n");
|
||||
else
|
||||
fprintf(pkt,"\1SOT:\r");
|
||||
}
|
||||
if ((splitpart == 0) && (hdr((char *)"X-PGP-Signed",msg))) {
|
||||
if (postlocal)
|
||||
fprintf(pkt,PGP_SIGNED_BEGIN"\n");
|
||||
else
|
||||
fprintf(pkt,PGP_SIGNED_BEGIN"\r");
|
||||
}
|
||||
}
|
||||
|
||||
if (replyaddr) {
|
||||
// free(replyaddr); /* Gives SIGSEGV */
|
||||
replyaddr=NULL;
|
||||
}
|
||||
if (needsplit) {
|
||||
if (postlocal)
|
||||
fprintf(pkt," * Continuation %d of a split message *\n\n", splitpart);
|
||||
else
|
||||
fprintf(pkt," * Continuation %d of a split message *\r\r", splitpart);
|
||||
needsplit=0;
|
||||
} else if ((p=hdr((char *)"X-Body-Start",msg))) {
|
||||
datasize += strlen(p);
|
||||
if (qp_or_base64==1)
|
||||
cwrite(strkconv(qp_decode(p), incode, outcode), pkt, postlocal);
|
||||
else if (qp_or_base64==2)
|
||||
cwrite(strkconv(b64_decode(p), incode, outcode), pkt, postlocal);
|
||||
else
|
||||
cwrite(strkconv(p, incode, outcode), pkt, postlocal);
|
||||
}
|
||||
while (!(needsplit=(!forbidsplit) && (((splitpart && (datasize > (CFG.new_split * 1024))) ||
|
||||
(!splitpart && ((datasize+hdrsize) > (CFG.new_split * 1024)))))) && (bgets(buf,sizeof(buf)-1,fp))) {
|
||||
// Syslog('m', "putmessage body %s",buf);
|
||||
datasize += strlen(buf);
|
||||
if (qp_or_base64==1)
|
||||
cwrite(strkconv(qp_decode(buf), incode, outcode), pkt, postlocal);
|
||||
else if (qp_or_base64==2)
|
||||
cwrite(strkconv(b64_decode(buf), incode, outcode), pkt, postlocal);
|
||||
else
|
||||
cwrite(strkconv(buf, incode, outcode), pkt, postlocal);
|
||||
}
|
||||
if (needsplit) {
|
||||
if (postlocal)
|
||||
fprintf(pkt,"\n * Message split, to be continued *\n");
|
||||
else
|
||||
fprintf(pkt,"\r * Message split, to be continued *\r");
|
||||
splitpart++;
|
||||
} else if ((p=hdr((char *)"X-PGP-Signed",msg))) {
|
||||
if (postlocal)
|
||||
fprintf(pkt,PGP_SIG_BEGIN"\n");
|
||||
else
|
||||
fprintf(pkt,PGP_SIG_BEGIN"\r");
|
||||
if ((q=hdr((char *)"X-PGP-Version",msg))) {
|
||||
fprintf(pkt,"Version:");
|
||||
cwrite(q,pkt, postlocal);
|
||||
}
|
||||
if ((q=hdr((char *)"X-PGP-Charset",msg))) {
|
||||
fprintf(pkt,"Charset:");
|
||||
cwrite(q,pkt, postlocal);
|
||||
}
|
||||
if ((q=hdr((char *)"X-PGP-Comment",msg))) {
|
||||
fprintf(pkt,"Comment:");
|
||||
cwrite(q,pkt, postlocal);
|
||||
}
|
||||
if (postlocal)
|
||||
fprintf(pkt,"\n");
|
||||
else
|
||||
fprintf(pkt,"\r");
|
||||
p=xstrcpy(p);
|
||||
q=strtok(p," \t\n");
|
||||
if (postlocal)
|
||||
fprintf(pkt,"%s\n",q);
|
||||
else
|
||||
fprintf(pkt,"%s\r",q);
|
||||
while ((q=(strtok(NULL," \t\n")))) {
|
||||
if (postlocal)
|
||||
fprintf(pkt,"%s\n",q);
|
||||
else
|
||||
fprintf(pkt,"%s\r",q);
|
||||
}
|
||||
if (postlocal)
|
||||
fprintf(pkt,PGP_SIG_END"\n");
|
||||
else
|
||||
fprintf(pkt,PGP_SIG_END"\r");
|
||||
}
|
||||
|
||||
if ((p=hdr((char *)"X-FTN-EOT",msg)) || (eot_kludge)) {
|
||||
if (postlocal)
|
||||
fprintf(pkt,"\1EOT:\n");
|
||||
else
|
||||
fprintf(pkt,"\1EOT:\r");
|
||||
}
|
||||
|
||||
if ((p=hdr((char *)"X-FTN-Tearline",msg))) {
|
||||
fprintf(pkt,"---");
|
||||
if (strcasecmp(p," (none)\n") == 0)
|
||||
cwrite((char *)"\n",pkt,postlocal);
|
||||
else
|
||||
cwrite(p,pkt,postlocal);
|
||||
} else {
|
||||
if (postlocal)
|
||||
fprintf(pkt,"--- MBSE BBSv.%s\n",VERSION);
|
||||
else
|
||||
fprintf(pkt,"--- MBSE BBSv.%s\r",VERSION);
|
||||
}
|
||||
|
||||
if ((p=hdr((char *)"X-FTN-Origin",msg))) {
|
||||
if (*(q=p+strlen(p)-1) == '\n')
|
||||
*q='\0';
|
||||
fprintf(pkt," * Origin:");
|
||||
cwrite(hdrconv(p, incode, outcode),pkt, postlocal);
|
||||
if (postlocal)
|
||||
fprintf(pkt, "\n");
|
||||
else
|
||||
fprintf(pkt,"\r");
|
||||
} else {
|
||||
fprintf(pkt," * Origin: ");
|
||||
if (fmsg->origin)
|
||||
cwrite(hdrconv(fmsg->origin, incode, outcode), pkt, postlocal);
|
||||
else
|
||||
fprintf(pkt, "%s", CFG.origin);
|
||||
if (postlocal)
|
||||
fprintf(pkt, " (%s)\n", ascfnode(fmsg->from,tinyorigin?0x0f:0x1f));
|
||||
else
|
||||
fprintf(pkt, " (%s)\r", ascfnode(fmsg->from,tinyorigin?0x0f:0x1f));
|
||||
}
|
||||
|
||||
for (tmp = msg; tmp; tmp = tmp->next)
|
||||
if (!strcasecmp(tmp->key,"X-FTN-Via")) {
|
||||
datasize += strlen(tmp->key)+strlen(tmp->val);
|
||||
fprintf(pkt,"\1Via");
|
||||
kwrite(tmp->val,pkt, postlocal);
|
||||
}
|
||||
|
||||
/*
|
||||
* @Via mbmail 2:293/2219@fidonet, Wed Jan 3 1996 at 07:49 (2.8c)
|
||||
*/
|
||||
if (postlocal)
|
||||
fprintf(pkt,"\1Via mbmail %s, %s (%s)\n", ascfnode(bestaka,0x1f), viadate(),VERSION);
|
||||
else
|
||||
fprintf(pkt,"\1Via mbmail %s, %s (%s)\r", ascfnode(bestaka,0x1f), viadate(),VERSION);
|
||||
|
||||
if (postlocal) {
|
||||
subj = xstrcpy(fmsg->subj);
|
||||
|
||||
/*
|
||||
* Check userlist real names, handles, unix names.
|
||||
* Import if one fits.
|
||||
*/
|
||||
if (!SearchUser(fmsg->to->name)) {
|
||||
Syslog('+', " \"%s\" is not a known BBS user", fmsg->to->name);
|
||||
/*
|
||||
* Unknown, readdress it to the sysop.
|
||||
*/
|
||||
net_bad++;
|
||||
Syslog('+', " Readdress from %s to %s", fmsg->to->name, CFG.sysop_name);
|
||||
fmsg->to->name = xstrcpy(CFG.sysop_name);
|
||||
}
|
||||
if (SearchUser(fmsg->to->name)) {
|
||||
Syslog('m', "storenet(%s, %s, %s, %04x)", ascfnode(fmsg->from,0x7f),
|
||||
ascfnode(fmsg->to,0x7f), ftndate(fmsg->date), fmsg->flags);
|
||||
if (storenet(fmsg->from, fmsg->to, fmsg->date, fmsg->flags, fmsg->subj, fmsg->msgid_a, fmsg->reply_a, pkt))
|
||||
return 2;
|
||||
} else {
|
||||
WriteError("Unknown bbs user");
|
||||
return 2;
|
||||
}
|
||||
} else {
|
||||
awrite((char *)"",pkt); /* trailing zero byte */
|
||||
if (ferror(pkt)) {
|
||||
WriteError("$error writing to ftn packet");
|
||||
return 1;
|
||||
}
|
||||
net_out++;
|
||||
}
|
||||
tidy_falist(&ptl);
|
||||
}
|
||||
while (needsplit);
|
||||
|
||||
Syslog('m', "putmessage exiting...");
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
#ifndef _MESSAGE_H
|
||||
#define _MESSAGE_H
|
||||
|
||||
|
||||
void StatAdd(statcnt *, unsigned long);
|
||||
int needputrfc(rfcmsg*);
|
||||
char *viadate(void);
|
||||
int putmessage(rfcmsg *, ftnmsg *, FILE *, faddr *, char,fa_list **, int, int);
|
||||
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user