Updates for POST command

This commit is contained in:
Michiel Broek 2004-05-11 12:25:34 +00:00
parent eb08dc97f7
commit 76d22550a1
13 changed files with 49 additions and 1457 deletions

View File

@ -4,14 +4,11 @@
include ../Makefile.global
SRCS = mbnntp.c openport.c ttyio.c auth.c commands.c rfc2ftn.c \
hash.c lhash.c msgflags.c postecho.c addpkt.c qualify.c \
storeecho.c rollover.c mkftnhdr.c atoul.c
hash.c lhash.c msgflags.c mkftnhdr.c atoul.c
HDRS = mbnntp.h openport.h ttyio.h auth.h commands.h rfc2ftn.h \
hash.h lhash.h msgflags.h postecho.h addpkt.h qualify.h \
storeecho.h rollover.h mkftnhdr.h atoul.h
hash.h lhash.h msgflags.h mkftnhdr.h atoul.h
OBJS = mbnntp.o openport.o ttyio.o auth.o commands.o rfc2ftn.o \
hash.o lhash.o msgflags.o postecho.o addpkt.o qualify.o \
storeecho.o rollover.o mkftnhdr.o atoul.o
hash.o lhash.o msgflags.o mkftnhdr.o atoul.o
LIBS += ../lib/libmbse.a ../lib/libmsgbase.a ../lib/libdbase.a
OTHER = Makefile
@ -65,16 +62,11 @@ mbnntp.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h ../lib/msg
openport.o: ../config.h ../lib/mbselib.h ttyio.h openport.h
ttyio.o: ../config.h ../lib/mbselib.h ttyio.h
auth.o: ../config.h ../lib/mbselib.h ../lib/users.h mbnntp.h auth.h
commands.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/msg.h ../lib/msgtext.h ttyio.h mbnntp.h rfc2ftn.h commands.h
rfc2ftn.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbinet.h ../lib/mbsedb.h ../lib/msg.h ../lib/msgtext.h mkftnhdr.h hash.h postecho.h msgflags.h rfc2ftn.h
commands.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/msg.h ../lib/msgtext.h ../lib/mbsedb.h ttyio.h mbnntp.h rfc2ftn.h commands.h
rfc2ftn.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbinet.h ../lib/mbsedb.h ../lib/msg.h ../lib/msgtext.h mkftnhdr.h hash.h msgflags.h rfc2ftn.h
hash.o: ../config.h ../lib/mbselib.h hash.h lhash.h
lhash.o: ../config.h ../lib/mbselib.h lhash.h
msgflags.o: ../config.h ../lib/mbselib.h msgflags.h
postecho.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/msg.h ../lib/msgtext.h ../lib/mbsedb.h postecho.h storeecho.h addpkt.h rollover.h qualify.h
addpkt.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h addpkt.h
qualify.o: ../config.h ../lib/mbselib.h qualify.h
storeecho.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/msg.h ../lib/msgtext.h ../lib/mbsedb.h rollover.h storeecho.h
rollover.o: ../config.h ../lib/mbselib.h rollover.h
mkftnhdr.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h atoul.h hash.h msgflags.h mkftnhdr.h
atoul.o: ../config.h ../lib/mbselib.h atoul.h
# End of generated dependencies

View File

@ -1,296 +0,0 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: Add mail to .pkt
*
*****************************************************************************
* Copyright (C) 1997-2004
*
* 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, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*****************************************************************************/
#include "../config.h"
#include "../lib/mbselib.h"
#include "../lib/users.h"
#include "../lib/mbsedb.h"
#include "addpkt.h"
static char *months[]={(char *)"Jan",(char *)"Feb",(char *)"Mar",
(char *)"Apr",(char *)"May",(char *)"Jun",
(char *)"Jul",(char *)"Aug",(char *)"Sep",
(char *)"Oct",(char *)"Nov",(char *)"Dec"};
/*
* Prepare ARCmail, this is actually just a rename of the temporary
* .pkt file on the queue to a permanent .pkt name that will later
* be added to the real ARCmail bundle.
*/
int PrepARC(char *, fidoaddr);
int PrepARC(char *Queue, fidoaddr Dest)
{
char *pktfile;
FILE *fp;
Syslog('p', "Prepare ARCmail for %s", aka2str(Dest));
if (!SearchNode(Dest)) {
WriteError("Downlink %s not found", aka2str(Dest));
return FALSE;
}
pktfile = calloc(PATH_MAX, sizeof(char));
sprintf(pktfile, "%s/%d.%d.%d.%d/%08lx.pkt", CFG.out_queue, Dest.zone, Dest.net, Dest.node, Dest.point, sequencer());
Syslog('p', "Rename .pkt to %s", pktfile);
if (rename(Queue, pktfile)) {
WriteError("$Can't rename %s to %s", Queue, pktfile);
free(pktfile);
return FALSE;
}
/*
* Add zero word to end of .pkt file
*/
if ((fp = fopen(pktfile, "a+")) == NULL) {
WriteError("$Can't open %s", pktfile);
free(pktfile);
return FALSE;
}
putc('\0', fp);
putc('\0', fp);
fsync(fileno(fp));
fclose(fp);
free(pktfile);
return TRUE;
}
FILE *CreatePkt(char *, fidoaddr, fidoaddr, char *);
FILE *CreatePkt(char *Queue, fidoaddr Orig, fidoaddr Dest, char *Extension)
{
static FILE *qp;
unsigned char buffer[0x3a];
time_t Now;
int i;
struct tm *Tm;
char str[81];
if ((qp = fopen(Queue, "a")) == NULL) {
WriteError("$Can't create Queue %s", Queue);
return NULL;
}
/*
* Write .PKT header, see FSC-0039 rev. 4
*/
memset(&buffer, 0, sizeof(buffer));
Now = time(NULL);
Tm = localtime(&Now);
if (Tm->tm_sec > 59)
Tm->tm_sec = 59;
buffer[0x00] = (Orig.node & 0x00ff);
buffer[0x01] = (Orig.node & 0xff00) >> 8;
buffer[0x02] = (Dest.node & 0x00ff);
buffer[0x03] = (Dest.node & 0xff00) >> 8;
buffer[0x04] = ((Tm->tm_year + 1900) & 0x00ff);
buffer[0x05] = ((Tm->tm_year + 1900) & 0xff00) >> 8;
buffer[0x06] = Tm->tm_mon;
buffer[0x08] = Tm->tm_mday;
buffer[0x0a] = Tm->tm_hour;
buffer[0x0c] = Tm->tm_min;
buffer[0x0e] = Tm->tm_sec;
buffer[0x12] = 2;
buffer[0x14] = (Orig.net & 0x00ff);
buffer[0x15] = (Orig.net & 0xff00) >> 8;
buffer[0x16] = (Dest.net & 0x00ff);
buffer[0x17] = (Dest.net & 0xff00) >> 8;
buffer[0x18] = (PRODCODE & 0x00ff);
buffer[0x19] = (VERSION_MAJOR & 0x00ff);
memset(&str, 0, 8); /* Packet password */
if (SearchNode(Dest)) {
if (strlen(nodes.Epasswd)) {
sprintf(str, "%s", nodes.Epasswd);
}
}
for (i = 0; i < 8; i++)
buffer[0x1a + i] = toupper(str[i]); /* FSC-0039 only talks about A-Z, 0-9, so force uppercase */
buffer[0x22] = (Orig.zone & 0x00ff);
buffer[0x23] = (Orig.zone & 0xff00) >> 8;
buffer[0x24] = (Dest.zone & 0x00ff);
buffer[0x25] = (Dest.zone & 0xff00) >> 8;
buffer[0x29] = 1;
buffer[0x2a] = (PRODCODE & 0xff00) >> 8;
buffer[0x2b] = (VERSION_MINOR & 0x00ff);
buffer[0x2c] = 1;
buffer[0x2e] = buffer[0x22];
buffer[0x2f] = buffer[0x23];
buffer[0x30] = buffer[0x24];
buffer[0x31] = buffer[0x25];
buffer[0x32] = (Orig.point & 0x00ff);
buffer[0x33] = (Orig.point & 0xff00) >> 8;
buffer[0x34] = (Dest.point & 0x00ff);
buffer[0x35] = (Dest.point & 0xff00) >> 8;
buffer[0x36] = 'm';
buffer[0x37] = 'b';
buffer[0x38] = 's';
buffer[0x39] = 'e';
fwrite(buffer, 1, 0x3a, qp);
fsync(fileno(qp));
return qp;
}
/*
* Open a .pkt file on the queue, create a fresh one if needed.
* If CFG.maxpktsize is set then it will add the .pkt to the
* ARCmail archive when possible.
*/
FILE *OpenPkt(fidoaddr Orig, fidoaddr Dest, char *Extension)
{
char *Queue;
static FILE *qp;
Queue = calloc(PATH_MAX, sizeof(char));
sprintf(Queue, "%s/%d.%d.%d.%d/mailpkt.%s", CFG.out_queue, Dest.zone, Dest.net, Dest.node, Dest.point, Extension);
mkdirs(Queue, 0750);
if (file_exist(Queue, R_OK))
qp = CreatePkt(Queue, Orig, Dest, Extension);
else {
if ((qp = fopen(Queue, "a")) == NULL) {
WriteError("$Can't reopen Queue %s", Queue);
free(Queue);
return NULL;
}
if (CFG.maxpktsize && (ftell(qp) >= (CFG.maxpktsize * 1024)) && (strcmp(Extension, "qqq") == 0)) {
/*
* It's a pkt that's meant to be send archived and it's
* bigger then maxpktsize. Try to add this pkt to the
* outbound archive for this node.
*/
fsync(fileno(qp));
fclose(qp);
if (PrepARC(Queue, Dest) == TRUE) {
/*
* If the pack succeeded create a fresh packet.
*/
qp = CreatePkt(Queue, Orig, Dest, Extension);
} else {
/*
* If the pack failed the existing queue is
* reopened and we continue adding to that
* existing packet.
*/
Syslog('s', "PrepARC failed");
qp = fopen(Queue, "a");
}
/*
* Go back to the original inbound directory.
*/
chdir(CFG.inbound);
}
}
free(Queue);
return qp;
}
int AddMsgHdr(FILE *fp, faddr *f, faddr *t, int flags, int cost, time_t date, char *tname, char *fname, char *subj)
{
unsigned char buffer[0x0e];
struct tm *Tm;
if ((tname == NULL) || (strlen(tname) > 36) ||
(fname == NULL) || (strlen(fname) > 36) ||
(subj == NULL) || (strlen(subj) > 72)) {
if (tname == NULL)
WriteError("AddMsgHdr() error, To name is NULL");
else if (strlen(tname) > 36)
WriteError("AddMsgHdr() error, To name length %d", strlen(tname));
if (fname == NULL)
WriteError("AddMsgHdr() error, From name is NULL");
else if (strlen(fname) > 36)
WriteError("AddMsgHdr() error, From name length %d", strlen(fname));
if (subj == NULL)
WriteError("AddMsgHdr() error, Subject is NULL");
else if (strlen(subj) > 72)
WriteError("AddMsgHdr() error, Subject length %d", strlen(subj));
return 1;
}
buffer[0x00] = 2;
buffer[0x01] = 0;
buffer[0x02] = (f->node & 0x00ff);
buffer[0x03] = (f->node & 0xff00) >> 8;
buffer[0x04] = (t->node & 0x00ff);
buffer[0x05] = (t->node & 0xff00) >> 8;
buffer[0x06] = (f->net & 0x00ff);
buffer[0x07] = (f->net & 0xff00) >> 8;
buffer[0x08] = (t->net & 0x00ff);
buffer[0x09] = (t->net & 0xff00) >> 8;
buffer[0x0a] = (flags & 0x00ff);
buffer[0x0b] = (flags & 0xff00) >> 8;
buffer[0x0c] = (cost & 0x00ff);
buffer[0x0d] = (cost & 0xff00) >> 8;
fwrite(buffer, 1, sizeof(buffer), fp);
if (date == (time_t)0) {
date = time(NULL);
Tm = localtime(&date);
} else
Tm = gmtime(&date);
/*
* According to the manpage the tm_sec value is in the range 0..61
* to allow leap seconds. FTN networks don't allow this, so if this
* happens we reset the leap seconds.
*/
if (Tm->tm_sec > 59)
Tm->tm_sec = 59;
fprintf(fp, "%02d %-3.3s %02d %02d:%02d:%02d%c",
Tm->tm_mday % 100, months[Tm->tm_mon], Tm->tm_year % 100,
Tm->tm_hour % 100, Tm->tm_min % 100, Tm->tm_sec % 100, '\0');
fprintf(fp, "%s%c", tname, '\0');
fprintf(fp, "%s%c", fname, '\0');
fprintf(fp, "%s%c", subj, '\0');
fsync(fileno(fp));
return 0;
}

View File

@ -1,9 +0,0 @@
#ifndef _ADDPKT_H
#define _ADDPKT_H
/* $Id$ */
FILE *OpenPkt(fidoaddr, fidoaddr, char *);
int AddMsgHdr(FILE *, faddr *, faddr *, int, int, time_t, char *, char *, char *);
#endif

View File

@ -46,6 +46,7 @@ struct sockaddr_in peeraddr;
pid_t mypid;
unsigned long rcvdbytes = 0L;
unsigned long sentbytes = 0L;
int do_mailout = FALSE;
extern char *ttystat[];
extern int authorized;
@ -64,6 +65,9 @@ void die(int onsig)
WriteError("Terminated with error %d", onsig);
}
if (do_mailout)
CreateSema((char *)"mailout");
t_end = time(NULL);
Syslog('+', "Send [%6lu] Received [%6lu]", sentbytes, rcvdbytes);
Syslog(' ', "MBNNTP finished in %s", t_elapsed(t_start, t_end));

View File

@ -1,480 +0,0 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: Post echomail message.
*
*****************************************************************************
* Copyright (C) 1997-2004
*
* 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, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*****************************************************************************/
#include "../config.h"
#include "../lib/mbselib.h"
#include "../lib/users.h"
#include "../lib/msg.h"
#include "../lib/msgtext.h"
#include "../lib/mbsedb.h"
#include "postecho.h"
#include "storeecho.h"
#include "addpkt.h"
#include "rollover.h"
#include "qualify.h"
#define MAXPATH 73
#define MAXSEEN 70
int EchoOut(fidoaddr, char *, char *, char *, FILE *, int, int, time_t);
/*
* Add echomail mesage to the queue.
*/
int EchoOut(fidoaddr aka, char *toname, char *fromname, char *subj, FILE *fp, int flags, int cost, time_t date)
{
char *buf, ext[4];
FILE *qp;
faddr *From, *To;
int rc;
/*
* Pack flavor for echomail packets.
*/
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(msgs.Aka, aka, (char *)ext)) == NULL) {
WriteError("EchoOut(): OpenPkt failed");
return 1;
}
From = fido2faddr(msgs.Aka);
To = fido2faddr(aka);
rc = AddMsgHdr(qp, From, To, flags, cost, date, toname, fromname, subj);
tidy_faddr(To);
tidy_faddr(From);
if (rc) {
WriteError("EchoOut(): AddMsgHdr failed");
return 1;
}
rewind(fp);
buf = calloc(MAX_LINE_LENGTH +1, sizeof(char));
while ((fgets(buf, MAX_LINE_LENGTH, fp)) != NULL) {
Striplf(buf);
fprintf(qp, "%s\r", buf);
}
free(buf);
putc(0, qp);
fsync(fileno(qp));
fclose(qp);
return 0;
}
/*
* Post echomail message, forward if needed.
* pkt_from, from, to, subj, orig, mdate, flags, cost, file
* The msgs record must be in memory.
*
* 1 - Cannot open message base.
* 4 - Rejected echomail message.
*
* For echomail, the crc32 is calculated over the ^AREA kludge, subject,
* message date, origin line, message id.
*/
int postecho(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj, time_t mdate, int flags, int cost, FILE *fp, int tonews)
{
char *buf, *msgid = NULL, *reply = NULL, *p, sbe[16];
int First = TRUE, rc = 0, i, dupe = FALSE, bad = TRUE, seenlen, oldnet;
faddr *Faddr;
unsigned long crc;
sysconnect Link;
fa_list *sbl = NULL, *ptl = NULL, *tmpl;
qualify *qal = NULL, *tmpq;
FILE *nfp;
time_t ddate;
memset(&Link, 0, sizeof(Link));
crc = 0xffffffff;
/*
* p_from is set for tossed echomail, it is NULL for local posted echomail and gated news.
*/
if (p_from) {
while (GetMsgSystem(&Link, First)) {
First = FALSE;
if ((p_from->zone == Link.aka.zone) && (p_from->net == Link.aka.net) && (p_from->node == Link.aka.node)) {
bad = FALSE;
break;
}
}
if (bad && msgs.UnSecure) {
bad = FALSE;
memset(&Link, 0, sizeof(Link));
Syslog('!', "Warning, unsecure echomail from %s accepted in area %s", ascfnode(p_from, 0x1f), msgs.Tag);
}
if (bad) {
Syslog('+', "Node %s not connected to area %s", ascfnode(p_from, 0x1f), msgs.Tag);
return 4;
}
if (Link.cutoff && !bad) {
Syslog('+', "Echomail from %s in %s refused, cutoff", ascfnode(p_from, 0x1f), msgs.Tag);
bad = TRUE;
return 4;
}
if (!Link.receivefrom && !bad) {
Syslog('+', "Echomail from %s in %s refused, read only", ascfnode(p_from, 0x1f), msgs.Tag);
bad = TRUE;
return 4;
}
} else {
/*
* Fake the zone entry to be our own zone, this prevents
* zonegate behaviour. It's also not a bad message yet.
*/
Link.aka.zone = msgs.Aka.zone;
bad = FALSE;
}
/*
* Read the message for kludges we need.
*/
buf = calloc(MAX_LINE_LENGTH +1, sizeof(char));
First = TRUE;
rewind(fp);
while ((fgets(buf, MAX_LINE_LENGTH, fp)) != NULL) {
Striplf(buf);
if (First && (!strncmp(buf, "AREA:", 5))) {
crc = upd_crc32(buf, crc, strlen(buf));
First = FALSE;
}
if (!strncmp(buf, "\001MSGID: ", 8)) {
msgid = xstrcpy(buf + 8);
}
if (!strncmp(buf, "\001REPLY: ", 8))
reply = xstrcpy(buf + 8);
if (!strncmp(buf, "SEEN-BY:", 8)) {
p = xstrcpy(buf + 9);
fill_list(&sbl, p, NULL);
free(p);
}
if (!strncmp(buf, "\001PATH:", 6)) {
p = xstrcpy(buf + 7);
fill_path(&ptl, p);
free(p);
}
} /* end of checking kludges */
/*
* Further dupe checking.
*/
crc = upd_crc32(subj, crc, strlen(subj));
if (orig == NULL)
Syslog('!', "No origin line found");
else
crc = upd_crc32(orig, crc, strlen(orig));
/*
* Some tossers don't bother the seconds in the message, also some
* rescanning software changes the seconds of a message. Do the
* timestamp check without the seconds.
*/
ddate = mdate - (mdate % 60);
crc = upd_crc32((char *)&ddate, crc, sizeof(ddate));
if (msgid != NULL) {
crc = upd_crc32(msgid, crc, strlen(msgid));
} else {
/*
* If a MSGID is missing it is possible that dupes from some offline
* readers slip through because these readers use the same date for
* each message. In this case the message text is included in the
* dupecheck. Redy Rodriguez.
*/
rewind(fp);
while ((fgets(buf, MAX_LINE_LENGTH, fp)) != NULL) {
Striplf(buf);
if (strncmp(buf, "---", 3) == 0)
break;
if ((strncmp(buf, "\001", 1) != 0 ) && (strncmp(buf,"AREA:",5) != 0 ))
crc = upd_crc32(buf, crc , strlen(buf));
}
}
dupe = CheckDupe(crc, D_ECHOMAIL, CFG.toss_dupes);
if (!dupe && !msgs.UnSecure) {
/*
* Check if the message is for us. Don't check point address,
* echomail messages don't have point destination set.
*/
if ((msgs.Aka.zone != t->zone) || (msgs.Aka.net != t->net) || (msgs.Aka.node != t->node)) {
bad = TRUE;
/*
* If we are a hub or host and have all our echomail
* connected to the hub/host aka, echomail from points
* under a nodenumber aka isn't accepted. The match
* must be further tested.
*/
if ((msgs.Aka.zone == t->zone) && (msgs.Aka.net == t->net)) {
for (i = 0; i < 40; i++) {
if ((CFG.akavalid[i]) && (CFG.aka[i].zone == t->zone) &&
(CFG.aka[i].net == t->net) && (CFG.aka[i].node == t->node))
bad = FALSE; /* Undo the result */
}
}
}
if (bad) {
WriteError("Msg in %s not for us (%s) but for %s", msgs.Tag, aka2str(msgs.Aka), ascfnode(t,0x1f));
free(buf);
if (msgid)
free(msgid);
if (reply)
free(reply);
return 4;
}
}
/*
* The echomail message is accepted for post/forward/gate
*/
if (!dupe) {
if (msgs.Aka.zone != Link.aka.zone) {
/*
* If it is a zonegated echomailmessage the SEEN-BY lines
* are stripped off including that of the other zone's
* gate. Add the gate's aka to the SEEN-BY
*/
Syslog('m', "Gated echomail, clean SB");
tidy_falist(&sbl);
sprintf(sbe, "%u/%u", Link.aka.net, Link.aka.node);
Syslog('m', "Add gate SB %s", sbe);
fill_list(&sbl, sbe, NULL);
}
/*
* Add more aka's to SEENBY if in the same zone as our system.
* When ready filter dupe's, there is at least one.
*/
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))) {
sprintf(sbe, "%u/%u", CFG.aka[i].net, CFG.aka[i].node);
fill_list(&sbl, sbe, NULL);
}
}
uniq_list(&sbl);
}
/*
* Add our system to the path for later export.
*/
sprintf(sbe, "%u/%u", msgs.Aka.net, msgs.Aka.node);
fill_path(&ptl, sbe);
uniq_list(&ptl); /* remove possible duplicate own aka */
/*
* Build a list of qualified systems to receive this message.
* Complete the SEEN-BY lines.
*/
First = TRUE;
while (GetMsgSystem(&Link, First)) {
First = FALSE;
if ((Link.aka.zone) && (Link.sendto) && (!Link.pause) && (!Link.cutoff)) {
Faddr = fido2faddr(Link.aka);
if (p_from == NULL) {
fill_qualify(&qal, Link.aka, FALSE, in_list(Faddr, &sbl, FALSE));
} else {
fill_qualify(&qal, Link.aka, ((p_from->zone == Link.aka.zone) &&
(p_from->net == Link.aka.net) && (p_from->node == Link.aka.node) &&
(p_from->point == Link.aka.point)), in_list(Faddr, &sbl, FALSE));
}
tidy_faddr(Faddr);
}
}
/*
* Add SEEN-BY for nodes qualified to receive this message.
* When ready, filter the dupes and sort the SEEN-BY entries.
*/
for (tmpq = qal; tmpq; tmpq = tmpq->next) {
if (tmpq->send) {
sprintf(sbe, "%u/%u", tmpq->aka.net, tmpq->aka.node);
fill_list(&sbl, sbe, NULL);
}
}
uniq_list(&sbl);
sort_list(&sbl);
/*
* Create a new tmpfile with a copy of the message
* without original PATH and SEENBY lines, add the
* new PATH and SEENBY lines.
*/
rewind(fp);
if ((nfp = tmpfile()) == NULL)
WriteError("$Unable to open tmpfile");
while ((fgets(buf, MAX_LINE_LENGTH, fp)) != NULL) {
Striplf(buf);
fprintf(nfp, "%s", buf);
/*
* Don't write SEEN-BY and PATH lines
*/
if (strncmp(buf, " * Origin:", 10) == 0)
break;
fprintf(nfp, "\n");
}
/*
* Now add new SEEN-BY and PATH lines
*/
seenlen = MAXSEEN + 1;
/*
* Ensure that it will not match for the first entry.
*/
oldnet = sbl->addr->net - 1;
for (tmpl = sbl; tmpl; tmpl = tmpl->next) {
if (tmpl->addr->net == oldnet)
sprintf(sbe, " %u", tmpl->addr->node);
else
sprintf(sbe, " %u/%u", tmpl->addr->net, tmpl->addr->node);
oldnet = tmpl->addr->net;
seenlen += strlen(sbe);
if (seenlen > MAXSEEN) {
seenlen = 0;
fprintf(nfp, "\nSEEN-BY:");
sprintf(sbe, " %u/%u", tmpl->addr->net, tmpl->addr->node);
seenlen = strlen(sbe);
}
fprintf(nfp, "%s", sbe);
}
seenlen = MAXPATH + 1;
/*
* Ensure it will not match for the first entry
*/
oldnet = ptl->addr->net - 1;
for (tmpl = ptl; tmpl; tmpl = tmpl->next) {
if (tmpl->addr->net == oldnet)
sprintf(sbe, " %u", tmpl->addr->node);
else
sprintf(sbe, " %u/%u", tmpl->addr->net, tmpl->addr->node);
oldnet = tmpl->addr->net;
seenlen += strlen(sbe);
if (seenlen > MAXPATH) {
seenlen = 0;
fprintf(nfp, "\n\001PATH:");
sprintf(sbe, " %u/%u", tmpl->addr->net, tmpl->addr->node);
seenlen = strlen(sbe);
}
fprintf(nfp, "%s", sbe);
}
fprintf(nfp, "\n");
fflush(nfp);
rewind(nfp);
/*
* Import this echomail, even if it's bad or a dupe.
*/
if ((rc = storeecho(f, t, mdate, flags, subj, msgid, reply, nfp)) || bad || dupe) {
/*
* Store failed or it was bad or a dupe. Only log failed store.
*/
if (rc)
WriteError("Store echomail in JAM base failed");
tidy_falist(&sbl);
tidy_falist(&ptl);
tidy_qualify(&qal);
free(buf);
if (msgid)
free(msgid);
if (reply)
free(reply);
fclose(nfp);
return rc;
}
/*
* Forward to other links
*/
for (tmpq = qal; tmpq; tmpq = tmpq->next) {
if (tmpq->send) {
if (SearchNode(tmpq->aka)) {
StatAdd(&nodes.MailSent, 1L);
UpdateNode();
SearchNode(tmpq->aka);
if (EchoOut(tmpq->aka, t->name, f->name, subj, nfp, flags, cost, mdate))
WriteError("Forward echomail to %s failed", aka2str(tmpq->aka));
} else {
WriteError("Forward echomail to %s failed, noderecord not found", aka2str(tmpq->aka));
}
}
}
fclose(nfp);
/*
* Free memory used by SEEN-BY, ^APATH and Qualified lines.
*/
tidy_falist(&sbl);
tidy_falist(&ptl);
tidy_qualify(&qal);
if (rc < 0)
rc =-rc;
free(buf);
if (msgid)
free(msgid);
if (reply)
free(reply);
return rc;
}

View File

@ -1,8 +0,0 @@
#ifndef _POSTECHO_H
#define _POSTECHO_H
/* $Id$ */
int postecho(faddr *, faddr *, faddr *, char *, char *, time_t, int, int, FILE *, int);
#endif

View File

@ -1,63 +0,0 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: List of qualified systems
*
*****************************************************************************
* Copyright (C) 1997-2004
*
* 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, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*****************************************************************************/
#include "../config.h"
#include "../lib/mbselib.h"
#include "qualify.h"
void tidy_qualify(qualify **qal)
{
qualify *tmp, *old;
for (tmp = *qal; tmp; tmp = old) {
old = tmp->next;
free(tmp);
}
*qal = NULL;
}
void fill_qualify(qualify **qal, fidoaddr aka, int orig, int insb)
{
qualify *tmp;
tmp = (qualify *)malloc(sizeof(qualify));
tmp->next = *qal;
tmp->aka = aka;
tmp->inseenby = insb;
tmp->send = ((!insb) && (!orig));
tmp->orig = orig;
*qal = tmp;
}

View File

@ -1,23 +0,0 @@
#ifndef _QUALIFY_H
#define _QUALIFY_H
/* $Id$ */
/*
* Structure for qualified systems to receive a echomail message/tic file
*/
typedef struct _qualify {
struct _qualify *next; /* Linked list */
fidoaddr aka; /* AKA of the linked system */
unsigned inseenby : 1; /* System is in SEEN-BY */
unsigned send : 1; /* Send message to link */
unsigned orig : 1; /* Is originator of message */
} qualify;
void tidy_qualify(qualify **);
void fill_qualify(qualify **, fidoaddr, int, int);
#endif

View File

@ -37,7 +37,6 @@
#include "../lib/msgtext.h"
#include "mkftnhdr.h"
#include "hash.h"
#include "postecho.h"
#include "msgflags.h"
#include "rfc2ftn.h"
@ -64,6 +63,8 @@ static int removereturnto;
* External variables
*/
extern char *replyaddr;
extern int do_mailout;
/*
@ -121,7 +122,7 @@ int rfc2ftn(FILE *fp)
int i, rc, newsmode, seenlen, oldnet;
rfcmsg *msg = NULL, *tmsg, *tmp;
ftnmsg *fmsg = NULL;
FILE *ofp;
FILE *ofp, *qfp;
fa_list *sbl = NULL, *ptl = NULL, *tmpl;
faddr *ta, *fta;
unsigned long svmsgid, svreply;
@ -645,8 +646,44 @@ int rfc2ftn(FILE *fp)
}
Syslog('m', "========== Fido end");
rc = postecho(NULL, fmsg->from, fmsg->to, origin, fmsg->subj, fmsg->date, fmsg->flags, 0, ofp, FALSE);
if (!Msg_Open(msgs.Base)) {
WriteError("Failed to open msgbase \"%s\"", msgs.Base);
} else {
if (!Msg_Lock(30L)) {
WriteError("Can't lock %s", msgs.Base);
} else {
Msg_New();
strcpy(Msg.From, fmsg->from->name);
strcpy(Msg.To, fmsg->to->name);
strcpy(Msg.FromAddress, ascfnode(fmsg->from,0x1f));
strcpy(Msg.Subject, fmsg->subj);
Msg.Written = Msg.Arrived = time(NULL) - (gmt_offset((time_t)0) * 60);
Msg.Local = TRUE;
rewind(ofp);
while (fgets(temp, 4096, ofp) != NULL) {
Striplf(temp);
MsgText_Add2(temp);
}
Msg_AddMsg();
Msg_UnLock();
Syslog('+', "Msg (%ld) to \"%s\", \"%s\"", Msg.Id, Msg.To, Msg.Subject);
do_mailout = TRUE;
sprintf(temp, "%s/tmp/echomail.jam", getenv("MBSE_ROOT"));
if ((qfp = fopen(temp, "a")) != NULL) {
fprintf(qfp, "%s %lu\n", msgs.Base, Msg.Id);
fclose(qfp);
}
rc = Msg_Link(msgs.Base, TRUE, CFG.slow_util);
if (rc != -1)
Syslog('+', "Linked %d message%s", rc, (rc != 1) ? "s":"");
else
Syslog('+', "Could not link messages");
}
Msg_Close();
}
free(origin);
fclose(ofp);
} while (needsplit);

View File

@ -1,421 +0,0 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: Statistic rollover util.
*
*****************************************************************************
* Copyright (C) 1997-2004
*
* 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, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*****************************************************************************/
#include "../config.h"
#include "../lib/mbselib.h"
#include "rollover.h"
extern int do_quiet;
void StatAdd(statcnt *S, unsigned long V)
{
S->total += V;
S->tweek += V;
S->tdow[Diw] += V;
S->month[Miy] += V;
}
void RollWeek(statcnt *);
void RollWeek(statcnt *S)
{
int i;
for (i = 0; i < 7; i++) {
S->ldow[i] = S->tdow[i];
S->tdow[i] = 0L;
}
S->lweek = S->tweek;
S->tweek = 0L;
if (CFG.slow_util && do_quiet)
msleep(1);
}
FILE *OpenData(char *);
FILE *OpenData(char *Name)
{
char *temp;
FILE *fp;
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/%s", getenv("MBSE_ROOT"), Name);
if ((fp = fopen(temp, "r+")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
return NULL;
}
free(temp);
return fp;
}
/*
* Test all files with statistic counters if a new week has started
* or a new month has started. All the record counters will be
* updated if one of these is the case.
*/
void Rollover()
{
time_t Now, Temp;
struct tm *t;
FILE *fp, *ft;
int do_week, do_month, Day, i;
char *temp, *temp1;
struct _history history;
Now = time(NULL);
t = localtime(&Now);
Diw = t->tm_wday;
Miy = t->tm_mon;
Day = t->tm_yday;
if ((fp = OpenData((char *)"nodes.data")) != NULL) {
fread(&nodeshdr, sizeof(nodeshdr), 1, fp);
Temp = nodeshdr.lastupd;
t = localtime(&Temp);
/*
* Test if it's sunday, and the last update wasn't today.
* If it's not sunday, and the last update was more then
* 7 days ago, we maybe missed last sunday and the update
* is still done.
*/
if (((Diw == 0) && (Day != t->tm_yday)) || ((Day - t->tm_yday) > 7))
do_week = TRUE;
else
do_week = FALSE;
/*
* If the month is different then the last update, we must
* be in a new month.
*/
if (Miy != t->tm_mon)
do_month = TRUE;
else
do_month = FALSE;
if (do_week || do_month) {
IsDoing("Date rollover");
Syslog('+', "Rollover nodes.data");
while (fread(&nodes, nodeshdr.recsize, 1, fp) == 1) {
if (do_week) {
RollWeek(&nodes.FilesSent);
RollWeek(&nodes.FilesRcvd);
RollWeek(&nodes.F_KbSent);
RollWeek(&nodes.F_KbRcvd);
RollWeek(&nodes.MailSent);
RollWeek(&nodes.MailRcvd);
}
if (do_month) {
nodes.FilesSent.month[Miy] = 0;
nodes.FilesRcvd.month[Miy] = 0;
nodes.F_KbSent.month[Miy] = 0;
nodes.F_KbRcvd.month[Miy] = 0;
nodes.MailSent.month[Miy] = 0;
nodes.MailRcvd.month[Miy] = 0;
if (CFG.slow_util && do_quiet)
msleep(1);
}
fseek(fp, - nodeshdr.recsize, SEEK_CUR);
fwrite(&nodes, nodeshdr.recsize, 1, fp);
fseek(fp, nodeshdr.filegrp + nodeshdr.mailgrp, SEEK_CUR);
}
fseek(fp, 0, SEEK_SET);
nodeshdr.lastupd = time(NULL);
fwrite(&nodeshdr, nodeshdr.hdrsize, 1, fp);
}
fclose(fp);
}
if ((fp = OpenData((char *)"mareas.data")) != NULL) {
fread(&msgshdr, sizeof(msgshdr), 1, fp);
Temp = msgshdr.lastupd;
t = localtime(&Temp);
if (((Diw == 0) && (Day != t->tm_yday)) || ((Day - t->tm_yday) > 7))
do_week = TRUE;
else
do_week = FALSE;
if (Miy != t->tm_mon)
do_month = TRUE;
else
do_month = FALSE;
if (do_week || do_month) {
Syslog('+', "Rollover mareas.data");
while (fread(&msgs, msgshdr.recsize, 1, fp) == 1) {
if (do_week) {
RollWeek(&msgs.Received);
RollWeek(&msgs.Posted);
}
if (do_month) {
msgs.Received.month[Miy] = 0;
msgs.Posted.month[Miy] = 0;
if (CFG.slow_util && do_quiet)
msleep(1);
}
fseek(fp, - msgshdr.recsize, SEEK_CUR);
fwrite(&msgs, msgshdr.recsize, 1, fp);
fseek(fp, msgshdr.syssize, SEEK_CUR);
}
msgshdr.lastupd = time(NULL);
fseek(fp, 0, SEEK_SET);
fwrite(&msgshdr, msgshdr.hdrsize, 1, fp);
}
fclose(fp);
}
if ((fp = OpenData((char *)"mgroups.data")) != NULL) {
fread(&mgrouphdr, sizeof(mgrouphdr), 1, fp);
Temp = mgrouphdr.lastupd;
t = localtime(&Temp);
if (((Diw == 0) && (Day != t->tm_yday)) || ((Day - t->tm_yday) > 7))
do_week = TRUE;
else
do_week = FALSE;
if (Miy != t->tm_mon)
do_month = TRUE;
else
do_month = FALSE;
if (do_week || do_month) {
Syslog('+', "Rollover mgroups.data");
while (fread(&mgroup, mgrouphdr.recsize, 1, fp) == 1) {
if (do_week) {
RollWeek(&mgroup.MsgsRcvd);
RollWeek(&mgroup.MsgsSent);
}
if (do_month) {
mgroup.MsgsRcvd.month[Miy] = 0;
mgroup.MsgsSent.month[Miy] = 0;
if (CFG.slow_util && do_quiet)
msleep(1);
}
fseek(fp, - mgrouphdr.recsize, SEEK_CUR);
fwrite(&mgroup, mgrouphdr.recsize, 1, fp);
}
mgrouphdr.lastupd = time(NULL);
fseek(fp, 0, SEEK_SET);
fwrite(&mgrouphdr, mgrouphdr.hdrsize, 1, fp);
}
fclose(fp);
}
if ((fp = OpenData((char *)"tic.data")) != NULL) {
fread(&tichdr, sizeof(tichdr), 1, fp);
Temp = tichdr.lastupd;
t = localtime(&Temp);
if (((Diw == 0) && (Day != t->tm_yday)) || ((Day - t->tm_yday) > 7))
do_week = TRUE;
else
do_week = FALSE;
if (Miy != t->tm_mon)
do_month = TRUE;
else
do_month = FALSE;
if (do_week || do_month) {
Syslog('+', "Rollover tic.data");
while (fread(&tic, tichdr.recsize, 1, fp) == 1) {
if (do_week) {
RollWeek(&tic.Files);
RollWeek(&tic.KBytes);
}
if (do_month) {
tic.Files.month[Miy] = 0;
tic.KBytes.month[Miy] = 0;
if (CFG.slow_util && do_quiet)
msleep(1);
}
fseek(fp, - tichdr.recsize, SEEK_CUR);
fwrite(&tic, tichdr.recsize, 1, fp);
fseek(fp, tichdr.syssize, SEEK_CUR);
}
tichdr.lastupd = time(NULL);
fseek(fp, 0, SEEK_SET);
fwrite(&tichdr, tichdr.hdrsize, 1, fp);
}
fclose(fp);
}
if ((fp = OpenData((char *)"fgroups.data")) != NULL) {
fread(&fgrouphdr, sizeof(fgrouphdr), 1, fp);
Temp = fgrouphdr.lastupd;
t = localtime(&Temp);
if (((Diw == 0) && (Day != t->tm_yday)) || ((Day - t->tm_yday) > 7))
do_week = TRUE;
else
do_week = FALSE;
if (Miy != t->tm_mon)
do_month = TRUE;
else
do_month = FALSE;
if (do_week || do_month) {
Syslog('+', "Rollover fgroups.data");
while (fread(&fgroup, fgrouphdr.recsize, 1, fp) == 1) {
if (do_week) {
RollWeek(&fgroup.Files);
RollWeek(&fgroup.KBytes);
}
if (do_month) {
fgroup.Files.month[Miy] = 0;
fgroup.KBytes.month[Miy] = 0;
if (CFG.slow_util && do_quiet)
msleep(1);
}
fseek(fp, - fgrouphdr.recsize, SEEK_CUR);
fwrite(&fgroup, fgrouphdr.recsize, 1, fp);
}
fgrouphdr.lastupd = time(NULL);
fseek(fp, 0, SEEK_SET);
fwrite(&fgrouphdr, fgrouphdr.hdrsize, 1, fp);
}
fclose(fp);
}
if ((fp = OpenData((char *)"hatch.data")) != NULL) {
fread(&hatchhdr, sizeof(hatchhdr), 1, fp);
Temp = hatchhdr.lastupd;
t = localtime(&Temp);
if (((Diw == 0) && (Day != t->tm_yday)) || ((Day - t->tm_yday) > 7))
do_week = TRUE;
else
do_week = FALSE;
if (Miy != t->tm_mon)
do_month = TRUE;
else
do_month = FALSE;
if (do_week || do_month) {
Syslog('+', "Rollover hatch.data");
while (fread(&hatch, hatchhdr.recsize, 1, fp) == 1) {
if (do_week)
RollWeek(&hatch.Hatched);
if (do_month) {
hatch.Hatched.month[Miy] = 0;
if (CFG.slow_util && do_quiet)
msleep(1);
}
fseek(fp, - hatchhdr.recsize, SEEK_CUR);
fwrite(&hatch, hatchhdr.recsize, 1, fp);
}
hatchhdr.lastupd = time(NULL);
fseek(fp, 0, SEEK_SET);
fwrite(&hatchhdr, hatchhdr.hdrsize, 1, fp);
}
fclose(fp);
}
temp = calloc(PATH_MAX, sizeof(char));
temp1 = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/var/mailer.hist", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r"))) {
fread(&history, sizeof(history), 1, fp);
Temp = history.online;
t = localtime(&Temp);
if (t->tm_mon != Miy) {
/*
* Calculate date/time for records to delete
*/
t = localtime(&Now);
if (t->tm_mon == 0) {
t->tm_mon = 11;
t->tm_year--;
} else {
t->tm_mon--;
}
t->tm_mday = 1;
t->tm_hour = 0;
t->tm_min = 0;
t->tm_sec = 0;
Now = mktime(t);
Syslog('+', "Packing mailer history since %s", rfcdate(Now));
sprintf(temp1, "%s/var/mailer.temp", getenv("MBSE_ROOT"));
if ((ft = fopen(temp1, "a")) == NULL) {
WriteError("$Can't create %s", temp1);
fclose(fp);
} else {
memset(&history, 0, sizeof(history));
history.online = time(NULL);
history.offline = time(NULL);
fwrite(&history, sizeof(history), 1, ft);
i = 0;
while (fread(&history, sizeof(history), 1, fp)) {
if (history.online >= Now) {
fwrite(&history, sizeof(history), 1, ft);
i++;
}
}
fclose(ft);
fclose(fp);
unlink(temp);
rename(temp1, temp);
Syslog('+', "Written %d records", i);
}
} else {
fclose(fp);
}
}
free(temp);
free(temp1);
}

View File

@ -1,8 +0,0 @@
#ifndef _ROLLOVER_H
#define _ROLLOVER_H
/* $Id$ */
void StatAdd(statcnt *, unsigned long);
#endif

View File

@ -1,124 +0,0 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: Import a echomail message
*
*****************************************************************************
* Copyright (C) 1997-2004
*
* 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, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*****************************************************************************/
#include "../config.h"
#include "../lib/mbselib.h"
#include "../lib/users.h"
#include "../lib/msg.h"
#include "../lib/msgtext.h"
#include "../lib/mbsedb.h"
#include "rollover.h"
#include "storeecho.h"
/*
* Store echomail into the JAM base.
*
* 0 - All seems well.
* 1 - Can't access messagebase.
*
*/
int storeecho(faddr *f, faddr *t, time_t mdate, int flags, char *subj, char *msgid, char *reply, FILE *fp)
{
int result;
unsigned long crc2;
char *buf;
/*
* Update import counters
*/
StatAdd(&msgs.Received, 1L);
msgs.LastRcvd = time(NULL);
StatAdd(&mgroup.MsgsRcvd, 1L);
mgroup.LastDate = time(NULL);
UpdateMsgs();
result = Msg_Open(msgs.Base);
if (!result) {
WriteError("Can't open JAMmb %s", msgs.Base);
return 1;
}
if (Msg_Lock(30L)) {
Msg_New();
/*
* Fill subfields
*/
strcpy(Msg.From, f->name);
strcpy(Msg.To, t->name);
strcpy(Msg.FromAddress, ascfnode(f,0x1f));
strcpy(Msg.Subject, subj);
Msg.Written = mdate;
Msg.Arrived = time(NULL) - (gmt_offset((time_t)0) * 60);
Msg.Echomail = TRUE;
/*
* These are the only usefull flags in echomail
*/
if ((flags & M_PVT) && ((msgs.MsgKinds == BOTH) || (msgs.MsgKinds == PRIVATE)))
Msg.Private = TRUE;
/*
* Set MSGID and REPLY crc.
*/
if (msgid != NULL) {
crc2 = -1;
Msg.MsgIdCRC = upd_crc32(msgid, crc2, strlen(msgid));
}
if (reply != NULL) {
crc2 = -1;
Msg.ReplyCRC = upd_crc32(reply, crc2, strlen(reply));
}
/*
* Start write the message
* Eat the first line (AREA:tag).
*/
buf = calloc(MAX_LINE_LENGTH +1, sizeof(char));
rewind(fp);
fgets(buf , MAX_LINE_LENGTH, fp);
Msg_Write(fp);
Msg_AddMsg();
Msg_UnLock();
Msg_Close();
free(buf);
return 0;
} else {
Syslog('+', "Can't lock msgbase %s", msgs.Base);
Msg_UnLock();
Msg_Close();
return 1;
}
}

View File

@ -1,9 +0,0 @@
#ifndef _STOREECHO_H
#define _STOREECHO_H
/* $Id$ */
int storeecho(faddr *, faddr *, time_t, int, char *, char *, char *, FILE *);
#endif