2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2001-11-16 20:07:42 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Output a netmail to one of our links.
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2002-01-07 19:16:03 +00:00
|
|
|
* Copyright (C) 1997-2002
|
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"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/libs.h"
|
|
|
|
#include "../lib/structs.h"
|
2002-01-07 19:16:03 +00:00
|
|
|
#include "../lib/users.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/records.h"
|
|
|
|
#include "../lib/common.h"
|
|
|
|
#include "../lib/dbnode.h"
|
|
|
|
#include "../lib/clcomm.h"
|
|
|
|
#include "../lib/dbmsgs.h"
|
|
|
|
#include "addpkt.h"
|
|
|
|
#include "rollover.h"
|
|
|
|
#include "sendmail.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-03-03 17:05:05 +00:00
|
|
|
extern int net_out;
|
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
/*
|
|
|
|
* Start a netmail to one of our nodes in the setup.
|
|
|
|
* Return a file descriptor if success else NULL.
|
|
|
|
* Later the pack routine will add these mails to the outbound.
|
|
|
|
*/
|
|
|
|
FILE *SendMgrMail(faddr *t, int Keep, int FileAttach, char *bymgr, char *subj, char *reply)
|
|
|
|
{
|
|
|
|
FILE *qp;
|
|
|
|
time_t Now;
|
|
|
|
fidoaddr Orig, Dest;
|
|
|
|
faddr From;
|
|
|
|
unsigned flags = M_PVT;
|
|
|
|
char ext[4];
|
|
|
|
|
|
|
|
From = *bestaka_s(t);
|
|
|
|
memset(&Orig, 0, sizeof(Orig));
|
|
|
|
Orig.zone = From.zone;
|
|
|
|
Orig.net = From.net;
|
|
|
|
Orig.node = From.node;
|
|
|
|
Orig.point = From.point;
|
|
|
|
sprintf(Orig.domain, "%s", From.domain);
|
|
|
|
|
|
|
|
memset(&Dest, 0, sizeof(Dest));
|
|
|
|
Dest.zone = t->zone;
|
|
|
|
Dest.net = t->net;
|
|
|
|
Dest.node = t->node;
|
|
|
|
Dest.point = t->point;
|
|
|
|
sprintf(Dest.domain, "%s", t->domain);
|
|
|
|
|
|
|
|
if (!SearchNode(Dest)) {
|
2002-04-13 13:46:39 +00:00
|
|
|
Syslog('!', "SendMgrMail(): Can't find node %s", aka2str(Dest));
|
2001-08-17 05:46:24 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-04-13 13:46:39 +00:00
|
|
|
Syslog('m', " Netmail from %s to %s", aka2str(Orig), ascfnode(t, 0x1f));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
Now = time(NULL) - (gmt_offset((time_t)0) * 60);
|
|
|
|
flags |= (nodes.Crash) ? M_CRASH : 0;
|
|
|
|
flags |= (FileAttach) ? M_FILE : 0;
|
|
|
|
flags |= (nodes.Hold) ? M_HOLD : 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Increase counters, update record and reload.
|
|
|
|
*/
|
|
|
|
StatAdd(&nodes.MailSent, 1L);
|
|
|
|
UpdateNode();
|
|
|
|
SearchNode(Dest);
|
|
|
|
|
|
|
|
memset(&ext, 0, sizeof(ext));
|
|
|
|
if (nodes.PackNetmail)
|
|
|
|
sprintf(ext, (char *)"qqq");
|
|
|
|
else if (nodes.Crash)
|
|
|
|
sprintf(ext, (char *)"ccc");
|
|
|
|
else if (nodes.Hold)
|
|
|
|
sprintf(ext, (char *)"hhh");
|
|
|
|
else
|
|
|
|
sprintf(ext, (char *)"nnn");
|
|
|
|
|
|
|
|
if ((qp = OpenPkt(Orig, Dest, (char *)ext)) == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (AddMsgHdr(qp, &From, t, flags, 0, Now, nodes.Sysop, tlcap(bymgr), subj)) {
|
|
|
|
fclose(qp);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Dest.point)
|
|
|
|
fprintf(qp, "\001TOPT %d\r", Dest.point);
|
|
|
|
if (Orig.point)
|
|
|
|
fprintf(qp, "\001FMPT %d\r", Orig.point);
|
|
|
|
|
|
|
|
fprintf(qp, "\001INTL %d:%d/%d %d:%d/%d\r", Dest.zone, Dest.net, Dest.node, Orig.zone, Orig.net, Orig.node);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add MSGID, REPLY and PID
|
|
|
|
*/
|
|
|
|
fprintf(qp, "\001MSGID: %s %08lx\r", aka2str(Orig), sequencer());
|
|
|
|
if (reply != NULL)
|
|
|
|
fprintf(qp, "\001REPLY: %s\r", reply);
|
|
|
|
fprintf(qp, "\001PID: MBSE-FIDO %s\r", VERSION);
|
|
|
|
fprintf(qp, "\001TZUTC: %s\r", gmtoffset(Now));
|
|
|
|
return qp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CloseMail(FILE *qp, faddr *t)
|
|
|
|
{
|
2002-06-18 18:52:48 +00:00
|
|
|
time_t Now;
|
|
|
|
struct tm *tm;
|
|
|
|
faddr *ta;
|
|
|
|
|
|
|
|
putc('\r', qp);
|
|
|
|
Now = time(NULL);
|
|
|
|
tm = gmtime(&Now);
|
|
|
|
ta = bestaka_s(t);
|
|
|
|
fprintf(qp, "\001Via %s @%d%02d%02d.%02d%02d%02d.02.UTC %s\r",
|
|
|
|
ascfnode(ta, 0x1f), tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
|
2001-08-17 05:46:24 +00:00
|
|
|
tm->tm_hour, tm->tm_min, tm->tm_sec, VERSION);
|
2002-06-18 18:52:48 +00:00
|
|
|
tidy_faddr(ta);
|
|
|
|
putc(0, qp);
|
|
|
|
fclose(qp);
|
|
|
|
net_out++;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|