This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
deb-mbse/mbfido/scan.c

1200 lines
31 KiB
C
Raw Normal View History

2001-08-17 05:46:24 +00:00
/*****************************************************************************
*
2002-01-07 19:16:03 +00:00
* $Id$
2001-08-17 05:46:24 +00:00
* Purpose ...............: Scan for outgoing mail.
*
*****************************************************************************
* Copyright (C) 1997-2005
2001-08-17 05:46:24 +00:00
*
* 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
2003-08-15 20:05:34 +00:00
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
2001-08-17 05:46:24 +00:00
*****************************************************************************/
2002-06-30 12:48:44 +00:00
#include "../config.h"
2004-02-21 17:22:00 +00:00
#include "../lib/mbselib.h"
2002-01-07 19:16:03 +00:00
#include "../lib/users.h"
2001-08-17 05:46:24 +00:00
#include "../lib/msg.h"
#include "../lib/msgtext.h"
2004-02-21 17:22:00 +00:00
#include "../lib/mbsedb.h"
2001-08-17 05:46:24 +00:00
#include "addpkt.h"
#include "tracker.h"
2001-08-25 19:53:11 +00:00
#include "ftn2rfc.h"
2001-09-17 21:44:23 +00:00
#include "rfc2ftn.h"
#include "rollover.h"
2001-08-17 05:46:24 +00:00
#include "postemail.h"
#include "scan.h"
extern int do_quiet;
extern int net_out;
extern int net_bad;
extern int echo_in;
extern int email_out;
extern int echo_out;
extern int most_debug;
2002-08-05 13:30:44 +00:00
extern int do_flush;
2001-08-17 05:46:24 +00:00
int scanned;
#define MAXSEEN 70
/*
* Internal prototypes
*/
void ScanFull(void);
void ScanOne(char *, unsigned long);
void ExportEcho(sysconnect, unsigned long, fa_list **);
void ExportNews( unsigned long, fa_list **);
void ExportNet(unsigned long, int);
void ExportEmail(unsigned long);
/*
* Scan for outgoing mail. If using the files $MBSE_ROOT/tmp/echomail.jam
* or netmail.jam not all mail is scanned a full mailscan will be
* performed.
*/
void ScanMail(int DoAll)
{
int DoFull = FALSE, i = 0;
unsigned long msg;
2005-08-12 15:11:14 +00:00
char *Fname = NULL, *temp, *msgstr, *path;
FILE *fp;
2001-08-17 05:46:24 +00:00
if (DoAll) {
DoFull = TRUE;
} else {
scanned = 0;
Fname = calloc(PATH_MAX, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
2005-08-28 12:12:24 +00:00
snprintf(Fname, PATH_MAX -1, "%s/tmp/echomail.jam", getenv("MBSE_ROOT"));
if ((fp = fopen(Fname, "r")) != NULL) {
while ((fgets(temp, PATH_MAX - 1, fp)) != NULL) {
2005-08-12 15:11:14 +00:00
path = strtok(temp, " \n\0");
msgstr = strtok(NULL, "\n\0");
if (path && msgstr) {
msg = atol(msgstr);
Syslog('+', "Export message %lu from %s", msg, path);
ScanOne(path, msg);
i++;
} else {
Syslog('!', "Ignored garbage line in %s", Fname);
}
Nopper();
}
fclose(fp);
unlink(Fname);
}
2001-08-17 05:46:24 +00:00
2005-08-28 12:12:24 +00:00
snprintf(Fname, PATH_MAX -1, "%s/tmp/netmail.jam", getenv("MBSE_ROOT"));
if ((fp = fopen(Fname, "r")) != NULL) {
while ((fgets(temp, PATH_MAX - 1, fp)) != NULL) {
2005-08-12 15:11:14 +00:00
path = strtok(temp, " \n\0");
msgstr = strtok(NULL, "\n\0");
if (path && msgstr) {
msg = atol(msgstr);
Syslog('+', "Export message %lu from %s", msg, path);
ScanOne(path, msg);
i++;
} else {
Syslog('!', "Ignored garbage line in %s", Fname);
}
Nopper();
}
fclose(fp);
unlink(Fname);
}
2001-08-17 05:46:24 +00:00
if ((i != scanned) || (i == 0)) {
Syslog('+', "Not all messages exported, forcing full mail scan to fix this");
DoFull = TRUE;
2001-08-17 05:46:24 +00:00
}
free(Fname);
free(temp);
}
2001-08-17 05:46:24 +00:00
if (DoFull)
ScanFull();
2001-08-17 05:46:24 +00:00
if (echo_out || net_out)
do_flush = TRUE;
RemoveSema((char *)"mailout");
2001-08-17 05:46:24 +00:00
}
void ScanFull()
{
2003-09-14 12:24:18 +00:00
char *sAreas, sbe[128];
FILE *pAreas;
long arearec = 0, sysstart, nextstart;
unsigned long Total, Number;
int i;
sysconnect Link;
fa_list *sbl = NULL;
2001-08-17 05:46:24 +00:00
2003-09-14 12:24:18 +00:00
Syslog('+', "Full mailscan");
IsDoing("Scanning mail");
2001-08-17 05:46:24 +00:00
2003-09-14 12:24:18 +00:00
if (!do_quiet) {
2005-08-19 20:48:54 +00:00
mbse_colour(LIGHTBLUE, BLACK);
2003-09-14 12:24:18 +00:00
printf("Scanning mail\n");
2005-08-19 20:48:54 +00:00
mbse_colour(CYAN, BLACK);
2003-09-14 12:24:18 +00:00
fflush(stdout);
}
2001-08-17 05:46:24 +00:00
2003-09-14 12:24:18 +00:00
sAreas = calloc(PATH_MAX, sizeof(char));
2005-08-28 12:12:24 +00:00
snprintf(sAreas, PATH_MAX -1, "%s/etc/users.data", getenv("MBSE_ROOT"));
2003-09-14 12:24:18 +00:00
if ((pAreas = fopen(sAreas, "r")) != NULL) {
fread(&usrconfighdr, sizeof(usrconfighdr), 1, pAreas);
2002-03-15 19:15:31 +00:00
2003-09-14 12:24:18 +00:00
while (fread(&usrconfig, usrconfighdr.recsize, 1, pAreas) == 1) {
if (usrconfig.Email && strlen(usrconfig.Name)) {
2001-08-17 05:46:24 +00:00
2003-09-14 12:24:18 +00:00
Nopper();
if (!do_quiet) {
2005-08-19 20:48:54 +00:00
mbse_colour(CYAN, BLACK);
2003-09-14 12:24:18 +00:00
printf("\r%8s %-40s", usrconfig.Name, usrconfig.sUserName);
2005-08-19 20:48:54 +00:00
mbse_colour(LIGHTMAGENTA, BLACK);
2003-09-14 12:24:18 +00:00
fflush(stdout);
}
2001-08-17 05:46:24 +00:00
2005-08-28 12:12:24 +00:00
snprintf(sAreas, PATH_MAX -1, "%s/%s/mailbox", CFG.bbs_usersdir, usrconfig.Name);
2003-09-14 12:24:18 +00:00
if (Msg_Open(sAreas)) {
if ((Total = Msg_Number()) != 0L) {
Number = Msg_Lowest();
2001-08-17 05:46:24 +00:00
2003-09-14 12:24:18 +00:00
do {
if (CFG.slow_util && do_quiet)
2004-01-25 10:57:35 +00:00
msleep(1);
2001-08-17 05:46:24 +00:00
2003-09-14 12:24:18 +00:00
if (((Number % 10) == 0) && (!do_quiet)) {
printf("%6lu\b\b\b\b\b\b", Number);
fflush(stdout);
}
2001-08-17 05:46:24 +00:00
2003-09-14 12:24:18 +00:00
Msg_ReadHeader(Number);
if (Msg.Local) {
if (Msg_Lock(15L)) {
Syslog('m', "Export %lu email from %s", Number, usrconfig.Name);
ExportEmail(Number);
Msg.Local = FALSE;
Msg.Arrived = time(NULL);
Msg_WriteHeader(Number);
Msg_UnLock();
2001-08-17 05:46:24 +00:00
}
2003-09-14 12:24:18 +00:00
}
} while (Msg_Next(&Number) == TRUE);
}
Msg_Close();
if (!do_quiet) {
printf(" \b\b\b\b\b\b");
fflush(stdout);
}
2001-08-17 05:46:24 +00:00
}
2003-09-14 12:24:18 +00:00
}
2001-08-17 05:46:24 +00:00
}
2003-09-14 12:24:18 +00:00
fclose(pAreas);
}
2001-08-17 05:46:24 +00:00
2005-08-28 12:12:24 +00:00
snprintf(sAreas, PATH_MAX -1, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
2003-09-14 12:24:18 +00:00
if ((pAreas = fopen(sAreas, "r")) == NULL) {
WriteError("Can't open %s", sAreas);
2002-05-20 12:07:10 +00:00
free(sAreas);
2003-09-14 12:24:18 +00:00
return;
}
free(sAreas);
fread(&msgshdr, sizeof(msgshdr), 1, pAreas);
2002-03-15 19:15:31 +00:00
2003-09-14 12:24:18 +00:00
while (fread(&msgs, msgshdr.recsize, 1, pAreas) == 1) {
sysstart = ftell(pAreas);
fseek(pAreas, msgshdr.syssize, SEEK_CUR);
nextstart = ftell(pAreas);
arearec++;
2001-08-17 05:46:24 +00:00
2003-09-14 12:24:18 +00:00
if ((msgs.Active) && (msgs.Type == ECHOMAIL || msgs.Type == NETMAIL || msgs.Type == NEWS)) {
2001-08-17 05:46:24 +00:00
2003-09-14 12:24:18 +00:00
Nopper();
if (!do_quiet) {
2005-08-19 20:48:54 +00:00
mbse_colour(CYAN, BLACK);
2003-09-14 12:24:18 +00:00
printf("\r%5ld .. %-40s", arearec, msgs.Name);
2005-08-19 20:48:54 +00:00
mbse_colour(LIGHTMAGENTA, BLACK);
2003-09-14 12:24:18 +00:00
fflush(stdout);
}
2001-08-17 05:46:24 +00:00
2003-09-14 12:24:18 +00:00
if (Msg_Open(msgs.Base)) {
if ((Total = Msg_Number()) != 0L) {
Number = Msg_Lowest();
2001-08-17 05:46:24 +00:00
2003-09-14 12:24:18 +00:00
do {
if (CFG.slow_util && do_quiet)
2004-01-25 10:57:35 +00:00
msleep(1);
2001-08-17 05:46:24 +00:00
2003-09-14 12:24:18 +00:00
if (((Number % 10) == 0) && (!do_quiet)) {
printf("%6lu\b\b\b\b\b\b", Number);
fflush(stdout);
}
2001-08-17 05:46:24 +00:00
2003-09-14 12:24:18 +00:00
Msg_ReadHeader(Number);
if (Msg.Local) {
if (Msg_Lock(15L)) {
Syslog('m', "Export %lu from area %ld", Number, arearec);
/*
* Setup SEEN-BY lines
*/
if ((msgs.Type == ECHOMAIL) || (msgs.Type == NEWS)) {
echo_in++;
fill_list(&sbl, aka2str(msgs.Aka), NULL);
for (i = 0; i < 40; i++) {
if (CFG.akavalid[i] && (msgs.Aka.zone == CFG.aka[i].zone) &&
(CFG.aka[i].point == 0) && !((msgs.Aka.net == CFG.aka[i].net) &&
(msgs.Aka.node == CFG.aka[i].node))) {
2005-08-28 12:12:24 +00:00
snprintf(sbe, 127, "%u/%u", CFG.aka[i].net, CFG.aka[i].node);
2003-09-14 12:24:18 +00:00
fill_list(&sbl, sbe, NULL);
}
}
fseek(pAreas, sysstart, SEEK_SET);
for (i = 0; i < (msgshdr.syssize / sizeof(sysconnect)); i++) {
fread(&Link, sizeof(sysconnect), 1, pAreas);
if ((Link.aka.zone) && (Link.sendto) && (!Link.pause)) {
fill_list(&sbl, aka2str(Link.aka), NULL);
}
}
uniq_list(&sbl);
sort_list(&sbl);
fseek(pAreas, sysstart, SEEK_SET);
for (i = 0; i < (msgshdr.syssize / sizeof(sysconnect)); i++) {
fread(&Link, sizeof(sysconnect), 1, pAreas);
if (Link.aka.zone)
ExportEcho(Link, Number, &sbl);
}
2004-06-20 14:38:11 +00:00
#ifdef USE_NEWSGATE
if (strlen(msgs.Newsgroup))
#else
2004-04-13 19:09:17 +00:00
if (strlen(msgs.Newsgroup) && (msgs.Type == NEWS))
2004-06-20 14:38:11 +00:00
#endif
ExportNews(Number, &sbl);
2003-09-14 12:24:18 +00:00
tidy_falist(&sbl);
2001-08-17 05:46:24 +00:00
}
2003-09-14 12:24:18 +00:00
if (msgs.Type == NETMAIL) {
ExportNet(Number, FALSE);
most_debug = FALSE;
2001-08-17 05:46:24 +00:00
}
2003-09-14 12:24:18 +00:00
Msg.Local = FALSE;
Msg.Arrived = time(NULL);
Msg_WriteHeader(Number);
Msg_UnLock();
}
2001-08-17 05:46:24 +00:00
}
2003-09-14 12:24:18 +00:00
} while (Msg_Next(&Number) == TRUE);
2001-08-17 05:46:24 +00:00
}
2003-09-14 12:24:18 +00:00
Msg_Close();
2001-08-17 05:46:24 +00:00
2003-09-14 12:24:18 +00:00
if (!do_quiet) {
printf(" \b\b\b\b\b\b");
fflush(stdout);
}
}
/*
* Make sure to start at the next area.
*/
fseek(pAreas, nextstart, SEEK_SET);
2001-08-17 05:46:24 +00:00
}
2003-09-14 12:24:18 +00:00
}
fclose(pAreas);
if (!do_quiet) {
printf("\r \r");
fflush(stdout);
}
2001-08-17 05:46:24 +00:00
}
void ScanOne(char *path, unsigned long MsgNum)
{
char *sAreas, sbe[128];
FILE *pAreas;
long sysstart;
unsigned long Total, Area = 0;
int i;
sysconnect Link;
fa_list *sbl = NULL;
2001-08-17 05:46:24 +00:00
IsDoing("Scanning mail");
2001-08-17 05:46:24 +00:00
if (!do_quiet) {
2005-08-19 20:48:54 +00:00
mbse_colour(LIGHTBLUE, BLACK);
printf("Scanning mail\n");
2005-08-19 20:48:54 +00:00
mbse_colour(CYAN, BLACK);
fflush(stdout);
}
2001-08-17 05:46:24 +00:00
if (strncmp(CFG.bbs_usersdir, path, strlen(CFG.bbs_usersdir)) == 0) {
if (Msg_Open(path)) {
if (((Total = Msg_Number()) != 0L) && (Msg_ReadHeader(MsgNum)) && Msg.Local) {
if (Msg_Lock(15L)) {
scanned++;
ExportEmail(MsgNum);
Msg.Local = FALSE;
Msg.Arrived = time(NULL);
Msg_WriteHeader(MsgNum);
Msg_UnLock();
2001-08-17 05:46:24 +00:00
}
}
Msg_Close();
} else {
WriteError("Can't open %s", path);
2001-08-17 05:46:24 +00:00
}
return;
}
2001-08-17 05:46:24 +00:00
sAreas = calloc(PATH_MAX, sizeof(char));
2005-08-28 12:12:24 +00:00
snprintf(sAreas, PATH_MAX -1, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((pAreas = fopen(sAreas, "r")) == NULL) {
WriteError("Can't open %s", sAreas);
2002-05-20 12:07:10 +00:00
free(sAreas);
return;
}
free(sAreas);
fread(&msgshdr, sizeof(msgshdr), 1, pAreas);
2001-08-17 05:46:24 +00:00
/*
* Seek the path we want
*/
while (TRUE) {
if (fread(&msgs, msgshdr.recsize, 1, pAreas) != 1) {
fclose(pAreas);
Syslog('m', "ScanOne() reached end of areas");
return;
2001-08-17 05:46:24 +00:00
}
Area++;
sysstart = ftell(pAreas);
fseek(pAreas, msgshdr.syssize, SEEK_CUR);
if (strcmp(msgs.Base, path) == 0)
break;
}
2001-08-17 05:46:24 +00:00
if ((msgs.Active) && (msgs.Type == ECHOMAIL || msgs.Type == NETMAIL || msgs.Type == NEWS)) {
if (!do_quiet) {
2005-08-19 20:48:54 +00:00
mbse_colour(CYAN, BLACK);
printf("\r%5ld .. %-40s", Area, msgs.Name);
2005-08-19 20:48:54 +00:00
mbse_colour(LIGHTMAGENTA, BLACK);
fflush(stdout);
}
2001-08-17 05:46:24 +00:00
if (Msg_Open(msgs.Base)) {
if ((Total = Msg_Number()) != 0L) {
if (Msg_ReadHeader(MsgNum)) {
if (Msg.Local) {
if (Msg_Lock(15L)) {
scanned++;
/*
* Setup SEEN-BY lines
*/
if (msgs.Type == ECHOMAIL || msgs.Type == NEWS) {
echo_in++;
fill_list(&sbl, aka2str(msgs.Aka), NULL);
for (i = 0; i < 40; i++) {
if (CFG.akavalid[i] && (msgs.Aka.zone == CFG.aka[i].zone) && (CFG.aka[i].point == 0) &&
!((msgs.Aka.net == CFG.aka[i].net) && (msgs.Aka.node == CFG.aka[i].node))) {
2005-08-28 12:12:24 +00:00
snprintf(sbe, 127, "%u/%u", CFG.aka[i].net, CFG.aka[i].node);
fill_list(&sbl, sbe, NULL);
}
}
fseek(pAreas, sysstart, SEEK_SET);
for (i = 0; i < (msgshdr.syssize / sizeof(sysconnect)); i++) {
fread(&Link, sizeof(sysconnect), 1, pAreas);
if ((Link.aka.zone) && (Link.sendto) && (!Link.pause)) {
fill_list(&sbl, aka2str(Link.aka), NULL);
}
}
uniq_list(&sbl);
sort_list(&sbl);
fseek(pAreas, sysstart, SEEK_SET);
for (i = 0; i < (msgshdr.syssize / sizeof(sysconnect)); i++) {
fread(&Link, sizeof(sysconnect), 1, pAreas);
if (Link.aka.zone) {
ExportEcho(Link, MsgNum, &sbl);
}
}
2004-06-20 14:38:11 +00:00
#ifdef USE_NEWSGATE
if (strlen(msgs.Newsgroup))
2004-06-20 14:38:11 +00:00
#else
if (strlen(msgs.Newsgroup) && (msgs.Type == NEWS))
2004-06-20 14:38:11 +00:00
#endif
ExportNews(MsgNum, &sbl);
2001-08-17 05:46:24 +00:00
tidy_falist(&sbl);
}
if (msgs.Type == NETMAIL) {
ExportNet(MsgNum, FALSE);
most_debug = FALSE;
}
2001-08-17 05:46:24 +00:00
Msg.Local = FALSE;
Msg.Arrived = time(NULL);
Msg_WriteHeader(MsgNum);
Msg_UnLock();
}
}
2001-08-17 05:46:24 +00:00
}
}
Msg_Close();
2001-08-17 05:46:24 +00:00
}
} else {
WriteError("Config error: area %d not active or not Echo/Netmail area", Area);
}
2001-08-17 05:46:24 +00:00
fclose(pAreas);
2001-08-17 05:46:24 +00:00
if (!do_quiet) {
printf("\r \r");
fflush(stdout);
}
2001-08-17 05:46:24 +00:00
}
int RescanOne(faddr *L, char *marea, unsigned long Num)
// Return: 0 -> Ok
// 1 -> Unknown area
// 2 -> Node cant rescan this area
{
unsigned long Total, MsgNum, Area = 0;
fa_list *sbl = NULL;
fidoaddr *l;
int First, Found;
unsigned long rescanned;
sysconnect Link;
IsDoing("ReScan mail");
if (!do_quiet) {
2005-08-19 20:48:54 +00:00
mbse_colour(LIGHTBLUE, BLACK);
printf("ReScan mail\n");
2005-08-19 20:48:54 +00:00
mbse_colour(CYAN, BLACK);
fflush(stdout);
}
l = faddr2fido( L );
rescanned = 0L;
if (!SearchMsgs(marea)) {
Mgrlog("ReScan of unknown echo area %s", marea);
return 1;
}
First = TRUE;
Found = FALSE;
while (GetMsgSystem(&Link, First)) {
First = FALSE;
if ((l->zone == Link.aka.zone) && (l->net == Link.aka.net) && (l->node == Link.aka.node) && (l->point == Link.aka.point)) {
Found = TRUE;
break;
2001-08-17 05:46:24 +00:00
}
}
if (!Found) {
Mgrlog("Node %s can't Rescan area %s", L, marea);
return 2;
}
2001-08-17 05:46:24 +00:00
if ((msgs.Active) && ((msgs.Type == ECHOMAIL) || (msgs.Type == NEWS) || (msgs.Type == LIST))) {
if (!do_quiet) {
2005-08-19 20:48:54 +00:00
mbse_colour(CYAN, BLACK);
printf("\r%5ld .. %-40s", Area, msgs.Name);
2005-08-19 20:48:54 +00:00
mbse_colour(LIGHTMAGENTA, BLACK);
fflush(stdout);
}
2001-08-17 05:46:24 +00:00
if (Msg_Open(msgs.Base)) {
Total = Msg_Number();
MsgNum = 1;
if (Num!=0 && Num<Total)
MsgNum = (Total + 1 - Num);
while (MsgNum<=Total){
if (Msg_ReadHeader(MsgNum)) {
if (Msg_Lock(15L)) {
fill_list(&sbl, aka2str(msgs.Aka), NULL);
fill_list(&sbl, aka2str(Link.aka), NULL);
sort_list(&sbl);
ExportEcho(Link, MsgNum, &sbl);
tidy_falist(&sbl);
Msg_UnLock();
rescanned++;
}
2001-08-17 05:46:24 +00:00
}
MsgNum++;
}
Msg_Close();
2001-08-17 05:46:24 +00:00
}
}
2001-08-17 05:46:24 +00:00
if (!do_quiet) {
printf("\r \r");
fflush(stdout);
}
2001-08-17 05:46:24 +00:00
Mgrlog("Rescan OK. %ul messages rescanned", rescanned);
return 0;
2001-08-17 05:46:24 +00:00
}
/*
* Export message to downlink. The messagebase is locked.
*/
void ExportEcho(sysconnect L, unsigned long MsgNum, fa_list **sbl)
{
2003-09-14 12:24:18 +00:00
int rc, seenlen, oldnet, flags = 0, kludges = TRUE;
2005-08-28 12:12:24 +00:00
char *p, sbe[128], ext[4];
fa_list *tmpl;
FILE *qp;
faddr *from, *dest;
2001-08-17 05:46:24 +00:00
if ((!L.sendto) || L.pause || L.cutoff)
return;
2001-08-17 05:46:24 +00:00
Syslog('M', "Export to %s", aka2str(L.aka));
2001-08-17 05:46:24 +00:00
if (!SearchNode(L.aka)) {
WriteError("Can't send to %s, noderecord not found", aka2str(L.aka));
return;
}
2001-08-17 05:46:24 +00:00
/*
* Add statistics count
*/
StatAdd(&nodes.MailSent, 1L);
UpdateNode();
SearchNode(L.aka);
memset(&ext, 0, sizeof(ext));
if (nodes.PackNetmail)
2005-08-28 12:12:24 +00:00
snprintf(ext, 3, (char *)"qqq");
else if (nodes.Crash)
2005-08-28 12:12:24 +00:00
snprintf(ext, 3, (char *)"ccc");
else if (nodes.Hold)
2005-08-28 12:12:24 +00:00
snprintf(ext, 3, (char *)"hhh");
else
2005-08-28 12:12:24 +00:00
snprintf(ext, 3, (char *)"nnn");
if ((qp = OpenPkt(msgs.Aka, L.aka, (char *)ext)) == NULL)
return;
flags |= (Msg.Private) ? M_PVT : 0;
from = fido2faddr(msgs.Aka);
dest = fido2faddr(L.aka);
2003-09-14 12:24:18 +00:00
rc = AddMsgHdr(qp, from, dest, flags, 0, Msg.Written, Msg.To, Msg.From, Msg.Subject);
tidy_faddr(from);
tidy_faddr(dest);
2003-09-14 12:24:18 +00:00
if (rc) {
Syslog('+', "Cannot export message");
fclose(qp);
return;
}
fprintf(qp, "AREA:%s\r", msgs.Tag);
if (Msg_Read(MsgNum, 79)) {
if ((p = (char *)MsgText_First()) != NULL) {
do {
2002-11-12 20:29:47 +00:00
if (kludges && (p[0] != '\001')) {
/*
2002-11-12 20:29:47 +00:00
* At the end of the kludges, add the TID kludge.
*/
2002-11-12 20:29:47 +00:00
kludges = FALSE;
fprintf(qp, "\001TID: MBSE-FIDO %s (%s-%s)\r", VERSION, OsName(), OsCPU());
}
fprintf(qp, "%s", p);
if (strncmp(p, " * Origin:", 10) == 0)
break;
/*
* Only append CR if not the last line
*/
fprintf(qp, "\r");
} while ((p = (char *)MsgText_Next()) != NULL);
2001-08-17 05:46:24 +00:00
}
}
2001-08-17 05:46:24 +00:00
seenlen = MAXSEEN + 1;
/*
* Ensure that it will not match the first entry.
*/
oldnet = (*sbl)->addr->net - 1;
for (tmpl = *sbl; tmpl; tmpl = tmpl->next) {
if (tmpl->addr->net == oldnet)
2005-08-28 12:12:24 +00:00
snprintf(sbe, 127, " %u", tmpl->addr->node);
else
2005-08-28 12:12:24 +00:00
snprintf(sbe, 127, " %u/%u", tmpl->addr->net, tmpl->addr->node);
oldnet = tmpl->addr->net;
seenlen += strlen(sbe);
if (seenlen > MAXSEEN) {
seenlen = 0;
fprintf(qp, "\rSEEN-BY:");
2005-08-28 12:12:24 +00:00
snprintf(sbe, 127, " %u/%u", tmpl->addr->net, tmpl->addr->node);
seenlen = strlen(sbe);
2001-08-17 05:46:24 +00:00
}
fprintf(qp, "%s", sbe);
}
fprintf(qp, "\r\001PATH: %u/%u\r", msgs.Aka.net, msgs.Aka.node);
putc(0, qp);
fclose(qp);
2001-08-17 05:46:24 +00:00
echo_out++;
2001-08-17 05:46:24 +00:00
}
/*
* Export message to the newsserver. The messagebase is locked.
*/
void ExportNews(unsigned long MsgNum, fa_list **sbl)
{
char *p;
int i, seenlen, oldnet, flags = 0;
2005-08-28 12:12:24 +00:00
char sbe[128];
fa_list *tmpl;
FILE *qp;
faddr *from, *dest;
int kludges = TRUE;
2001-08-17 05:46:24 +00:00
qp = tmpfile();
2001-08-17 05:46:24 +00:00
Syslog('m', "Msg.From %s", Msg.From);
Syslog('m', "Msg.FromAddress %s", Msg.FromAddress);
Syslog('m', "Msg.To %s", Msg.To);
Syslog('m', "Msg.ToAddress %s", Msg.ToAddress);
2001-08-17 05:46:24 +00:00
flags |= (Msg.Private) ? M_PVT : 0;
from = fido2faddr(msgs.Aka);
/*
* Add name with echo to news gate.
*/
p = calloc(256, sizeof(char));
strcpy(p, Msg.From);
for (i = 0; i < strlen(p); i++) {
if (p[i] == '@') {
p[i] = '\0';
break;
}
}
from->name = xstrcpy(p);
free(p);
Syslog('m', "from %s", ascinode(from, 0xff));
dest = NULL;
fprintf(qp, "AREA:%s\n", msgs.Tag);
if (Msg_Read(MsgNum, 79)) {
if ((p = (char *)MsgText_First()) != NULL) {
do {
if (kludges) {
if (p[0] != '\001') {
/*
* After the first kludges, send RFC headers
*/
kludges = FALSE;
fprintf(qp, "\001TID: MBSE-FIDO %s (%s-%s)\n", VERSION, OsName(), OsCPU());
fprintf(qp, "Subject: %s\n", Msg.Subject);
fprintf(qp, "\n");
fprintf(qp, "%s\n", p);
} else {
fprintf(qp, "%s\n", p+1);
}
} else {
fprintf(qp, "%s", p);
if (strncmp(p, " * Origin:", 10) == 0)
break;
/*
* Only append NL if not the last line
*/
fprintf(qp, "\n");
2001-08-17 05:46:24 +00:00
}
} while ((p = (char *)MsgText_Next()) != NULL);
2001-08-17 05:46:24 +00:00
}
}
2001-08-17 05:46:24 +00:00
seenlen = MAXSEEN + 1;
/*
* Ensure that it will not match the first entry.
*/
oldnet = (*sbl)->addr->net - 1;
for (tmpl = *sbl; tmpl; tmpl = tmpl->next) {
if (tmpl->addr->net == oldnet)
2005-08-28 12:12:24 +00:00
snprintf(sbe, 127, " %u", tmpl->addr->node);
else
2005-08-28 12:12:24 +00:00
snprintf(sbe, 127, " %u/%u", tmpl->addr->net, tmpl->addr->node);
oldnet = tmpl->addr->net;
seenlen += strlen(sbe);
if (seenlen > MAXSEEN) {
seenlen = 0;
fprintf(qp, "\nSEEN-BY:");
2005-08-28 12:12:24 +00:00
snprintf(sbe, 127, " %u/%u", tmpl->addr->net, tmpl->addr->node);
seenlen = strlen(sbe);
2001-08-17 05:46:24 +00:00
}
fprintf(qp, "%s", sbe);
}
fprintf(qp, "\n\001PATH: %u/%u\n", msgs.Aka.net, msgs.Aka.node);
2001-08-17 05:46:24 +00:00
rewind(qp);
most_debug = TRUE;
ftn2rfc(from, dest, NULL, NULL, Msg.Written + (gmt_offset((time_t)0) * 60), flags, qp);
most_debug = FALSE;
tidy_faddr(from);
fclose(qp);
2001-08-17 05:46:24 +00:00
}
/*
* Export Netmail message, the messagebase is locked.
*/
void ExportNet(unsigned long MsgNum, int UUCPgate)
{
2002-07-14 16:20:28 +00:00
char *p, *q, ext[4], fromname[37], flavor, MailFrom[128], MailTo[128];
int i, rc, flags = 0, first, is_fmpt = FALSE, is_topt = FALSE, is_intl = FALSE, mypoint = FALSE, empty = TRUE;
2002-08-05 20:43:29 +00:00
FILE *qp, *fp, *fl;
2002-07-14 16:20:28 +00:00
fidoaddr Dest, Route, *dest;
time_t now;
struct tm *tm;
faddr *from, *too, *ta;
unsigned short point;
Syslog('m', "Export netmail to %s of %s (%s) %s mode", Msg.To, Msg.ToAddress,
2001-08-17 05:46:24 +00:00
(Msg.Crash || Msg.Direct || Msg.FileAttach) ? "Direct" : "Routed", UUCPgate ? "UUCP" : "Netmail");
2002-07-14 16:20:28 +00:00
/*
* Analyze this message if it contains INTL, FMPT and TOPT kludges
* and check if we need them. If they are missing they are inserted.
* GoldED doesn't insert them but MBSE does.
*/
if (Msg_Read(MsgNum, 79)) {
2002-07-14 16:20:28 +00:00
if ((p = (char *)MsgText_First()) != NULL) {
do {
if (strncmp(p, "\001FMPT", 5) == 0)
is_fmpt = TRUE;
if (strncmp(p, "\001TOPT", 5) == 0)
is_topt = TRUE;
if (strncmp(p, "\001INTL", 5) == 0)
is_intl = TRUE;
if (strncmp(p, "--- ", 4) == 0)
break;
if ((p[0] != '\001') && (p[0] != '\0')) {
empty = FALSE;
}
2002-07-14 16:20:28 +00:00
} while ((p = (char *)MsgText_Next()) != NULL);
2001-08-25 19:53:11 +00:00
}
2002-07-14 16:20:28 +00:00
}
Syslog('m', " netmail is %sempt", empty ? "":"not ");
2002-07-14 16:20:28 +00:00
/*
* Check if this a netmail to our own local UUCP gate.
*/
ta = parsefnode(Msg.ToAddress);
if ((!strcmp(Msg.To, "UUCP")) && (is_local(ta))) {
tidy_faddr(ta);
most_debug = TRUE;
if ((fp = tmpfile()) == NULL) {
WriteError("$Can't open tempfile");
return;
}
from = fido2faddr(msgs.Aka);
strncpy(fromname, Msg.From, 36);
for (i = 0; i < strlen(fromname); i++)
if (fromname[i] == ' ')
fromname[i] = '_';
2005-08-28 12:12:24 +00:00
snprintf(MailFrom, 127, "%s@%s", fromname, ascinode(from, 0x2f));
2002-07-14 16:20:28 +00:00
if (Msg_Read(MsgNum, 79)) {
2002-07-14 16:20:28 +00:00
if ((p = (char *)MsgText_First()) != NULL) {
do {
if (strncmp(p, "To: ", 4) == 0) {
Syslog('m', "%s", MBSE_SS(p));
if ((strchr(p, '<') != NULL) && (strchr(p, '>') != NULL)) {
q = strtok(p, "<");
q = strtok(NULL, ">");
} else {
q = strtok(p, " ");
q = strtok(NULL, " \n\r\t");
}
2005-08-28 12:12:24 +00:00
snprintf(MailTo, 127, "%s", q);
2002-07-14 16:20:28 +00:00
Syslog('m', "Final MailTo \"%s\"", MailTo);
break;
}
} while ((p = (char *)MsgText_Next()) != NULL);
}
}
Syslog('+', "UUCP gate From: %s at %s To: %s", Msg.From, Msg.FromAddress, MailTo);
2001-08-17 05:46:24 +00:00
/*
2002-07-14 16:20:28 +00:00
* First send all headers
2001-08-17 05:46:24 +00:00
*/
2002-07-14 16:20:28 +00:00
fprintf(fp, "Date: %s\n", rfcdate(Msg.Written));
fprintf(fp, "From: %s@%s\n", fromname, ascinode(from, 0x2f));
tidy_faddr(from);
fprintf(fp, "Subject: %s\n", Msg.Subject);
fprintf(fp, "MIME-Version: 1.0\n");
fprintf(fp, "Content-Type: text/plain\n");
fprintf(fp, "Content-Transfer-Encoding: 8bit\n");
fprintf(fp, "X-Mailreader: MBSE BBS %s\r\n", VERSION);
2001-08-17 05:46:24 +00:00
2002-07-14 16:20:28 +00:00
if (msgs.Aka.point && !is_fmpt)
fprintf(fp, "X-FTN-FMPT: %d\n", msgs.Aka.point);
2001-08-25 19:53:11 +00:00
if (Msg_Read(MsgNum, 79)) {
2002-07-14 16:20:28 +00:00
if ((p = (char *)MsgText_First()) != NULL) {
do {
if (p[0] == '\001') {
if (strncmp(p, "\001INTL", 5) == 0)
fprintf(fp, "X-FTN-INTL: %s\n", p+6);
else
fprintf(fp, "X-FTN-%s\n", p+1);
}
} while ((p = (char *)MsgText_Next()) != NULL);
}
}
2001-08-17 05:46:24 +00:00
if (Msg_Read(MsgNum, 79)) {
2002-07-14 16:20:28 +00:00
if ((p = (char *)MsgText_First()) != NULL) {
do {
if (p[0] != '\001') {
fprintf(fp, "%s\n", p);
}
} while ((p = (char *)MsgText_Next()) != NULL);
}
2001-08-17 05:46:24 +00:00
}
2002-07-14 16:20:28 +00:00
postemail(fp, MailFrom, MailTo);
fclose(fp);
return;
}
tidy_faddr(ta);
if (UUCPgate) {
memcpy(&Dest, &CFG.UUCPgate, sizeof(fidoaddr));
memset(&msgs, 0, sizeof(msgs));
memcpy(&msgs.Aka, &CFG.EmailFidoAka, sizeof(fidoaddr));
} else {
ta = parsefnode(Msg.ToAddress);
dest = faddr2fido(ta);
tidy_faddr(ta);
memcpy(&Dest, dest, sizeof(fidoaddr));
}
Dest.domain[0] = '\0';
if (!(Msg.Crash || Msg.Immediate || Msg.Direct || Msg.FileAttach)) {
if (!TrackMail(Dest, &Route)) {
Syslog('!', "No route to %s, message orphaned", Msg.ToAddress);
Msg.Orphan = TRUE;
net_bad++;
return;
2001-08-17 05:46:24 +00:00
}
2002-07-14 16:20:28 +00:00
}
Msg.Sent = TRUE;
if (Msg.KillSent)
Msg.Deleted = TRUE;
if (Msg.Crash || Msg.Direct || Msg.FileAttach || Msg.Immediate) {
memset(&ext, 0, sizeof(ext));
if (Msg.Immediate)
2005-08-28 12:12:24 +00:00
snprintf(ext, 3, (char *)"ddd");
2002-07-14 16:20:28 +00:00
else if (Msg.Crash)
2005-08-28 12:12:24 +00:00
snprintf(ext, 3, (char *)"ccc");
2002-07-14 16:20:28 +00:00
else
2005-08-28 12:12:24 +00:00
snprintf(ext, 3, (char *)"nnn");
2002-09-30 18:49:21 +00:00
/*
* If the destination is a point, check if it is our point
*/
for (i = 0; i < 40; i++) {
if (CFG.akavalid[i] &&
(CFG.aka[i].zone == Dest.zone) && (CFG.aka[i].net == Dest.net) && (CFG.aka[i].node == Dest.node)) {
if (Dest.point && !CFG.aka[i].point) {
mypoint = TRUE;
}
}
}
if (mypoint) {
if ((qp = OpenPkt(msgs.Aka, Dest, (char *)ext)) == NULL) {
net_bad++;
return;
}
} else {
point = Dest.point;
Dest.point = 0;
if (point)
Syslog('+', "Routing via Boss %s", aka2str(Dest));
if ((qp = OpenPkt(msgs.Aka, Dest, (char *)ext)) == NULL) {
net_bad++;
return;
}
Dest.point = point;
2001-08-17 05:46:24 +00:00
}
2002-07-14 16:20:28 +00:00
} else {
Syslog('m', "Route via %s", aka2str(Route));
if (!SearchNode(Route)) {
WriteError("Routing node %s not in setup, aborting", aka2str(Route));
return;
2001-08-17 05:46:24 +00:00
}
2002-07-14 16:20:28 +00:00
/*
* Note that even if the exported netmail is not crash, that if
* the routing node has crash status, this netmail will be send
* crash.
*/
memset(&ext, 0, sizeof(ext));
if (nodes.PackNetmail)
2005-08-28 12:12:24 +00:00
snprintf(ext, 3, (char *)"qqq");
2002-07-14 16:20:28 +00:00
else if (nodes.Crash)
2005-08-28 12:12:24 +00:00
snprintf(ext, 3, (char *)"ccc");
2002-07-14 16:20:28 +00:00
else if (nodes.Hold)
2005-08-28 12:12:24 +00:00
snprintf(ext, 3, (char *)"hhh");
2002-07-14 16:20:28 +00:00
else
2005-08-28 12:12:24 +00:00
snprintf(ext, 3, (char *)"nnn");
2002-07-14 16:20:28 +00:00
if ((qp = OpenPkt(msgs.Aka, Route, (char *)ext)) == NULL) {
net_bad++;
return;
2001-08-17 05:46:24 +00:00
}
2002-07-14 16:20:28 +00:00
}
flags |= (Msg.Private) ? M_PVT : 0;
flags |= (Msg.Crash) ? M_CRASH : 0;
flags |= (Msg.Hold) ? M_HOLD : 0;
flags |= (Msg.Immediate) ? M_CRASH : 0;
flags |= (Msg.FileRequest) ? M_REQ : 0;
flags |= (Msg.FileAttach) ? M_FILE : 0;
flags |= (Msg.ReceiptRequest) ? M_RRQ : 0;
flags |= (Msg.ConfirmRequest) ? M_AUDIT : 0;
too = fido2faddr(Dest);
from = fido2faddr(msgs.Aka);
if (UUCPgate) {
Syslog('m', "AddMsgHdr(%s, %s, %s)", (char *)"UUCP", Msg.From, Msg.Subject);
rc = AddMsgHdr(qp, from, too, flags, 0, Msg.Written, (char *)"UUCP", Msg.From, Msg.Subject);
} else {
rc = AddMsgHdr(qp, from, too, flags, 0, Msg.Written, Msg.To, Msg.From, Msg.Subject);
}
tidy_faddr(from);
tidy_faddr(too);
if (rc) {
WriteError("Create message failed");
return;
}
if (msgs.Aka.point && !is_fmpt)
fprintf(qp, "\001FMPT %d\r", msgs.Aka.point);
if (Dest.point && !is_topt)
fprintf(qp, "\001TOPT %d\r", Dest.point);
if (!is_intl)
fprintf(qp, "\001INTL %d:%d/%d %d:%d/%d\r", Dest.zone, Dest.net, Dest.node,
msgs.Aka.zone, msgs.Aka.net, msgs.Aka.node);
if (Msg_Read(MsgNum, 79)) {
2002-07-14 16:20:28 +00:00
first = TRUE;
if ((p = (char *)MsgText_First()) != NULL) {
do {
if (UUCPgate && first && (p[0] != '\001')) {
/*
* Past the kludges at the message start.
* Add the To: name@dom.com and a blank line.
*/
fprintf(qp, "To: %s\r", Msg.To);
fprintf(qp, "\r");
first = FALSE;
2001-08-17 05:46:24 +00:00
}
2002-07-14 16:20:28 +00:00
fprintf(qp, "%s\r", p);
if (strncmp(p, "--- ", 4) == 0)
break;
} while ((p = (char *)MsgText_Next()) != NULL);
2001-08-17 05:46:24 +00:00
}
2002-07-14 16:20:28 +00:00
}
2001-08-17 05:46:24 +00:00
2002-07-14 16:20:28 +00:00
now = time(NULL);
tm = gmtime(&now);
fprintf(qp, "\001Via %s @%d%02d%02d.%02d%02d%02d.01.UTC MBSE BBS %s\r",
2001-08-17 05:46:24 +00:00
aka2str(msgs.Aka), tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec, VERSION);
2002-07-14 16:20:28 +00:00
putc(0, qp);
fclose(qp);
2001-08-17 05:46:24 +00:00
2002-07-14 16:20:28 +00:00
if (Msg.FileAttach) {
if (Msg.Crash)
flavor = 'c';
else
flavor = 'f';
2001-08-17 05:46:24 +00:00
2002-07-14 16:20:28 +00:00
ta = parsefnode(Msg.ToAddress);
2002-08-05 20:43:29 +00:00
p = calloc(PATH_MAX, sizeof(char));
2005-08-28 12:12:24 +00:00
snprintf(p, PATH_MAX -1, "%s/%d.%d.%d.%d/.filelist", CFG.out_queue, ta->zone, ta->net, ta->node, ta->point);
2002-08-05 20:43:29 +00:00
mkdirs(p, 0750);
if ((fl = fopen(p, "a+")) == NULL) {
WriteError("$Can't open %s", p);
2002-07-14 16:20:28 +00:00
} else {
2002-08-05 20:43:29 +00:00
if (strlen(CFG.dospath)) {
2004-07-16 11:09:04 +00:00
fprintf(fl, "%c LEAVE NOR %s\n", flavor, Dos2Unix(Msg.Subject));
2002-08-05 20:43:29 +00:00
Syslog('+', "FileAttach %s", Dos2Unix(Msg.Subject));
} else {
2004-07-16 11:09:04 +00:00
fprintf(fl, "%c LEAVE NOR %s\n", flavor, Msg.Subject);
2002-08-05 20:43:29 +00:00
Syslog('+', "FileAttach %s", Msg.Subject);
}
fsync(fileno(fl));
fclose(fl);
2001-08-17 05:46:24 +00:00
}
2002-07-14 16:20:28 +00:00
tidy_faddr(ta);
}
2001-08-17 05:46:24 +00:00
2002-07-14 16:20:28 +00:00
net_out++;
2001-08-17 05:46:24 +00:00
}
/*
* Export Email message, the messagebase is locked.
*/
void ExportEmail(unsigned long MsgNum)
{
2004-08-18 19:46:30 +00:00
char *p, *q, MailFrom[128], MailTo[128];
FILE *qp;
int retval, flags = 0, kludges = TRUE;
faddr *from, *too;
2001-08-17 05:46:24 +00:00
Syslog('m', "Export email to %s", Msg.To);
Syslog('m', " from %s", Msg.From);
Msg.Sent = TRUE;
if (Msg.KillSent)
Msg.Deleted = TRUE;
2001-08-17 05:46:24 +00:00
/*
* For local scanned messages both addresses are the same.
*/
from = fido2faddr(CFG.EmailFidoAka);
too = fido2faddr(CFG.EmailFidoAka);
qp = tmpfile();
flags |= (Msg.Private) ? M_PVT : 0;
flags |= (Msg.Crash) ? M_CRASH : 0;
flags |= (Msg.Hold) ? M_HOLD : 0;
flags |= (Msg.Immediate) ? M_CRASH : 0;
flags |= (Msg.FileRequest) ? M_REQ : 0;
flags |= (Msg.FileAttach) ? M_FILE : 0;
flags |= (Msg.ReceiptRequest) ? M_RRQ : 0;
flags |= (Msg.ConfirmRequest) ? M_AUDIT : 0;
2001-08-17 05:46:24 +00:00
Syslog('m', "------------ Scanned message start");
if (Msg_Read(MsgNum, 79)) {
if ((p = (char *)MsgText_First()) != NULL) {
do {
Syslog('m', "%s", printable(p, 0));
/*
* GoldED places ^A characters in front of the RFC headers,
* so does mbsebbs as well.
*/
if (p[0] == '\001') {
fprintf(qp, "%s\n", p+1);
if (!strncmp(p, "\001PID:", 5)) {
fprintf(qp, "TID: MBSE-FIDO %s (%s-%s)\n", VERSION, OsName(), OsCPU());
}
} else {
if (kludges) {
kludges = FALSE;
fprintf(qp, "\n");
}
fprintf(qp, "%s\n", p);
2001-08-17 05:46:24 +00:00
}
} while ((p = (char *)MsgText_Next()) != NULL);
2001-08-17 05:46:24 +00:00
}
}
Syslog('m', "------------ Scanned message end");
rewind(qp);
most_debug = TRUE;
2001-09-17 21:44:23 +00:00
/*
* At this point the message is RFC formatted.
*/
if (CFG.EmailMode != E_NOISP) {
2001-09-17 21:44:23 +00:00
/*
* Dialup or direct internet connection, send message via MTA.
2004-08-18 19:46:30 +00:00
* Reformat the addresses for SMTP.
2001-09-17 21:44:23 +00:00
*/
p = Msg.From;
2004-08-18 19:46:30 +00:00
if ((strchr(p, '<') != NULL) && (strchr(p, '>') != NULL)) {
q = strtok(p, "<");
q = strtok(NULL, ">");
2005-08-28 12:12:24 +00:00
snprintf(MailFrom, 127, "%s", q);
2004-08-18 19:46:30 +00:00
} else if (Msg.From[0] == ' ') {
q = strtok(p, " ");
q = strtok(NULL, " \n\r\t");
2005-08-28 12:12:24 +00:00
snprintf(MailFrom, 127, "%s", q);
2004-08-18 19:46:30 +00:00
} else {
2005-08-28 12:12:24 +00:00
snprintf(MailFrom, 127, "%s", Msg.From);
}
2004-08-18 19:46:30 +00:00
p = Msg.To;
if ((strchr(p, '<') != NULL) && (strchr(p, '>') != NULL)) {
q = strtok(p, "<");
q = strtok(NULL, ">");
2005-08-28 12:12:24 +00:00
snprintf(MailTo, 127, "%s", q);
2004-08-18 19:46:30 +00:00
} else if (Msg.To[0] == ' ') {
q = strtok(p, " ");
q = strtok(NULL, " \n\r\t");
2005-08-28 12:12:24 +00:00
snprintf(MailTo, 127, "%s", q);
2004-08-18 19:46:30 +00:00
} else {
2005-08-28 12:12:24 +00:00
snprintf(MailTo, 127, "%s", Msg.To);
2001-09-17 21:44:23 +00:00
}
2004-08-18 19:46:30 +00:00
retval = postemail(qp, MailFrom, MailTo);
} else {
/*
* Message goes to UUCP gateway.
*/
retval = rfc2ftn(qp, too);
}
2001-09-17 21:44:23 +00:00
most_debug = FALSE;
tidy_faddr(from);
tidy_faddr(too);
Syslog('m', "posted email rc=%d", retval);
email_out++;
2001-08-17 05:46:24 +00:00
}