New mail queue system

This commit is contained in:
Michiel Broek 2002-08-05 13:30:44 +00:00
parent e94171cc94
commit 79327388e9
22 changed files with 1437 additions and 1341 deletions

View File

@ -4,9 +4,9 @@
include ../Makefile.global
SRCS = addbbs.c backalias.c flock.c hatch.c mbdiff.c mgrutil.c pack.c \
SRCS = addbbs.c backalias.c flock.c hatch.c mbdiff.c mgrutil.c \
ptic.c sendmail.c tracker.c addpkt.c bwrite.c forward.c lhash.c \
mbfido.c mkftnhdr.c ping.c rfc2ftn.c storeecho.c ulock.c aliasdb.c \
mbfido.c mkftnhdr.c ping.c rfc2ftn.c storeecho.c unpack.c aliasdb.c \
fsort.c magic.c mbfile.c mover.c post.c rnews.c storenet.c \
utic.c announce.c fflist.c ftn2rfc.c makestat.c mbindex.c msgutil.c \
postecho.c rollover.c tic.c areamgr.c filefind.c grlist.c maketags.c \
@ -14,25 +14,26 @@ SRCS = addbbs.c backalias.c flock.c hatch.c mbdiff.c mgrutil.c pack.c \
hash.c mbaff.c mbseq.c notify.c postnetmail.c scannews.c tosspkt.c \
mbfkill.c mbfutil.c mbfindex.c mbfcheck.c mbfpack.c mbflist.c mbfadopt.c \
mbfimport.c virscan.c mbftoberep.c mbfmove.c mbfdel.c bounce.c \
createm.c createf.c msgflags.c dirsession.c queue.c
HDRS = addbbs.h backalias.h flock.h hatch.h mbdiff.h mgrutil.h pack.h \
createm.c createf.c msgflags.c dirsession.c queue.c dirlock.c
HDRS = addbbs.h backalias.h flock.h hatch.h mbdiff.h mgrutil.h \
postnetmail.h scannews.h tosspkt.h addpkt.h bwrite.h forward.h \
lhash.h mbfido.h mkftnhdr.h ptic.h sendmail.h tracker.h \
aliasdb.h fsort.h magic.h mbfile.h mover.h ping.h rfc2ftn.h \
storeecho.h ulock.h announce.h fflist.h ftn2rfc.h makestat.h mbindex.h \
storeecho.h unpack.h announce.h fflist.h ftn2rfc.h makestat.h mbindex.h \
msgutil.h post.h rnews.h storenet.h utic.h areamgr.h filefind.h \
grlist.h maketags.h mbmsg.h newspost.h postecho.h rollover.h tic.h \
atoul.h filemgr.h hash.h mbaff.h mbseq.h notify.h postemail.h scan.h toberep.h \
mbfkill.h mbfutil.h mbfindex.h mbfcheck.h mbfpack.h mbflist.h mbfadopt.h \
mbfimport.h virscan.h mbftoberep.h mbfmove.h mbfdel.h bounce.h \
createm.h createf.h msgflags.h dirsession.h queue.h
createm.h createf.h msgflags.h dirsession.h queue.h dirlock.h
MBFIDO_OBJS = flock.o tosspkt.o mbfido.o hatch.o maketags.o virscan.o tracker.o \
makestat.o scannews.o lhash.o bounce.o pack.o ulock.o tic.o ptic.o \
makestat.o scannews.o lhash.o bounce.o unpack.o tic.o ptic.o \
utic.o mover.o hash.o mkftnhdr.o addbbs.o magic.o fsort.o toberep.o \
ftn2rfc.o atoul.o ping.o forward.o sendmail.o scan.o addpkt.o \
storenet.o storeecho.o areamgr.o filemgr.o notify.o mgrutil.o rollover.o \
bwrite.o rfc2ftn.o rnews.o newspost.o aliasdb.o postemail.o postnetmail.o \
postecho.o backalias.o createm.o createf.o msgflags.o dirsession.o queue.o
postecho.o backalias.o createm.o createf.o msgflags.o dirsession.o \
queue.o dirlock.o
MBSEQ_OBJS = mbseq.o
MBAFF_OBJS = announce.o fflist.o filefind.o grlist.o mbaff.o msgutil.o
MBINDEX_OBJS = mbindex.o
@ -139,28 +140,27 @@ backalias.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib
flock.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/clcomm.h flock.h
hatch.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbtic.h utic.h rollover.h hatch.h
mbdiff.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbdiff.h
mgrutil.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h ../lib/diesel.h sendmail.h rollover.h addpkt.h pack.h createm.h createf.h mgrutil.h
pack.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/dbftn.h ../lib/clcomm.h ../lib/dbnode.h dirsession.h pack.h
ptic.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/dbtic.h ../lib/clcomm.h ../lib/dbnode.h ../lib/dbdupe.h ulock.h mover.h toberep.h tic.h utic.h addbbs.h magic.h forward.h rollover.h ptic.h magic.h createf.h virscan.h
mgrutil.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h ../lib/diesel.h sendmail.h rollover.h addpkt.h createm.h createf.h mgrutil.h
ptic.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/dbtic.h ../lib/clcomm.h ../lib/dbnode.h ../lib/dbdupe.h unpack.h mover.h toberep.h tic.h utic.h addbbs.h magic.h forward.h rollover.h ptic.h magic.h createf.h virscan.h
sendmail.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/dbnode.h ../lib/clcomm.h ../lib/dbmsgs.h addpkt.h rollover.h sendmail.h
tracker.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h ../lib/dbftn.h tracker.h
addpkt.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/dbnode.h ../lib/dbmsgs.h pack.h addpkt.h
addpkt.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/dbnode.h ../lib/dbmsgs.h addpkt.h
bwrite.o: ../config.h ../lib/libs.h ../lib/memwatch.h bwrite.h
forward.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h ../lib/dbtic.h ../lib/diesel.h tic.h sendmail.h rollover.h mgrutil.h forward.h dirsession.h
lhash.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/clcomm.h lhash.h
mbfido.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbdupe.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/dbuser.h ../lib/dbftn.h ../lib/dbtic.h ../lib/msg.h flock.h tosspkt.h pack.h ulock.h tic.h fsort.h scan.h mbfido.h tracker.h notify.h rollover.h hatch.h scannews.h maketags.h makestat.h newspost.h rnews.h mgrutil.h backalias.h rfc2ftn.h dirsession.h
mbfido.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbdupe.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/dbuser.h ../lib/dbftn.h ../lib/dbtic.h ../lib/msg.h flock.h tosspkt.h unpack.h tic.h fsort.h scan.h mbfido.h tracker.h notify.h rollover.h hatch.h scannews.h maketags.h makestat.h newspost.h rnews.h mgrutil.h backalias.h rfc2ftn.h dirsession.h dirlock.h queue.h
mkftnhdr.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h atoul.h hash.h msgflags.h aliasdb.h mkftnhdr.h
ping.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbtic.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/dbftn.h sendmail.h postnetmail.h ping.h
rfc2ftn.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/dbdupe.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/msg.h ../lib/msgtext.h mkftnhdr.h hash.h rollover.h pack.h postnetmail.h postecho.h msgflags.h rfc2ftn.h
rfc2ftn.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/dbdupe.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/msg.h ../lib/msgtext.h mkftnhdr.h hash.h rollover.h postnetmail.h postecho.h msgflags.h rfc2ftn.h
storeecho.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbmsgs.h ../lib/dbuser.h rollover.h storeecho.h
ulock.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h flock.h ulock.h
unpack.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h flock.h unpack.h
aliasdb.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h aliasdb.h
fsort.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/clcomm.h fsort.h
magic.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbtic.h tic.h utic.h magic.h
mbfile.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfkill.h mbfadopt.h mbfindex.h mbfcheck.h mbfpack.h mbflist.h mbfimport.h mbftoberep.h mbfmove.h mbfdel.h mbfutil.h mbfile.h
mover.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h tic.h mover.h
post.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/msg.h ../lib/msgtext.h post.h
rnews.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/dbdupe.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/msg.h ../lib/msgtext.h pack.h rfc2ftn.h mbfido.h ../paths.h rnews.h
rnews.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/dbdupe.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/msg.h ../lib/msgtext.h rfc2ftn.h mbfido.h ../paths.h rnews.h
storenet.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbmsgs.h ../lib/dbuser.h msgflags.h rollover.h storenet.h
utic.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h tic.h mover.h tic.h utic.h
announce.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/msg.h ../lib/msgtext.h ../lib/diesel.h grlist.h msgutil.h announce.h
@ -171,7 +171,7 @@ mbindex.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/u
msgutil.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/msg.h ../lib/msgtext.h ../lib/diesel.h msgutil.h
postecho.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/dbftn.h ftn2rfc.h postecho.h storeecho.h addpkt.h rollover.h
rollover.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h rollover.h
tic.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/dbftn.h ../lib/clcomm.h ulock.h ptic.h fsort.h pack.h tic.h
tic.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/dbftn.h ../lib/clcomm.h unpack.h ptic.h fsort.h tic.h
areamgr.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/dbftn.h ../lib/diesel.h sendmail.h mgrutil.h scan.h createm.h areamgr.h
filefind.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/msg.h ../lib/msgtext.h ../lib/diesel.h fflist.h filefind.h msgutil.h
grlist.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/clcomm.h grlist.h
@ -179,7 +179,7 @@ maketags.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/
mbmsg.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/dbcfg.h post.h mbmsg.h
newspost.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h newspost.h
postemail.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/dbuser.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h postemail.h
scan.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/msg.h ../lib/clcomm.h ../lib/msgtext.h ../lib/dbnode.h ../lib/dbmsgs.h addpkt.h pack.h tracker.h ftn2rfc.h rfc2ftn.h postemail.h scan.h
scan.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/msg.h ../lib/clcomm.h ../lib/msgtext.h ../lib/dbnode.h ../lib/dbmsgs.h addpkt.h tracker.h ftn2rfc.h rfc2ftn.h postemail.h scan.h
toberep.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h tic.h toberep.h
atoul.o: ../config.h ../lib/libs.h ../lib/memwatch.h atoul.h
filemgr.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbtic.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/dbftn.h ../lib/diesel.h sendmail.h mgrutil.h createf.h filemgr.h
@ -188,7 +188,7 @@ mbaff.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/use
mbseq.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbseq.h
notify.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbnode.h filemgr.h areamgr.h sendmail.h notify.h
postnetmail.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/common.h ../lib/records.h ../lib/dbcfg.h ../lib/dbuser.h ../lib/dbnode.h ../lib/dbftn.h ../lib/clcomm.h tracker.h addpkt.h storenet.h ftn2rfc.h areamgr.h filemgr.h ping.h bounce.h postemail.h
scannews.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/dbdupe.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/msg.h ../lib/msgtext.h mkftnhdr.h hash.h rollover.h pack.h storeecho.h rfc2ftn.h scannews.h
scannews.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/dbdupe.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/msg.h ../lib/msgtext.h mkftnhdr.h hash.h rollover.h storeecho.h rfc2ftn.h scannews.h
tosspkt.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/dbftn.h tosspkt.h postnetmail.h postecho.h rollover.h createm.h
mbfkill.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfkill.h mbfutil.h
mbfutil.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbfile.h
@ -207,4 +207,6 @@ createm.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/u
createf.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h mgrutil.h createf.h
msgflags.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/clcomm.h msgflags.h
dirsession.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h dirsession.h
queue.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h ../lib/dbftn.h fsort.h dirsession.h queue.h
dirlock.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h flock.h dirlock.h
# End of generated dependencies

View File

@ -38,10 +38,11 @@
#include "../lib/common.h"
#include "../lib/dbnode.h"
#include "../lib/dbmsgs.h"
#include "pack.h"
#include "addpkt.h"
extern int do_flush;
static char *months[]={(char *)"Jan",(char *)"Feb",(char *)"Mar",
(char *)"Apr",(char *)"May",(char *)"Jun",
@ -51,80 +52,128 @@ static char *months[]={(char *)"Jan",(char *)"Feb",(char *)"Mar",
extern int do_unprot;
/*
* 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)
{
FILE *qp;
unsigned char buffer[0x3a];
time_t Now;
int i;
struct tm *Tm;
char str[81];
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;
if ((qp = fopen(Queue, "a")) == NULL) {
WriteError("$Can't create Queue %s", Queue);
return NULL;
}
Syslog('p', "CreatePkt(%s, %s, %s)", Queue, aka2str(Dest), Extension);
/*
* 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] = 0xfe;
memset(&str, 0, 8); /* Packet password */
if (SearchNode(Dest)) {
if (strlen(nodes.Epasswd)) {
sprintf(str, "%s", nodes.Epasswd);
}
}
/*
* 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;
for (i = 0; i < 8; i++)
buffer[0x1a + i] = str[i];
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] = 0xfe;
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[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);
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] = str[i];
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[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;
fsync(fileno(qp));
return qp;
}
@ -136,59 +185,59 @@ FILE *CreatePkt(char *Queue, fidoaddr Orig, fidoaddr Dest, char *Extension)
*/
FILE *OpenPkt(fidoaddr Orig, fidoaddr Dest, char *Extension)
{
char Queue[128], qname[128];
FILE *qp;
char *Queue;
static FILE *qp;
sprintf(Queue, "%s/tmp/%d.%d.%d.%d.%s", getenv("MBSE_ROOT"),
Dest.zone, Dest.net, Dest.node, Dest.point, Extension);
Queue = calloc(PATH_MAX, sizeof(char));
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);
return NULL;
}
if (CFG.maxpktsize && (ftell(qp) >= (CFG.maxpktsize * 1024)) &&
(strncmp(Extension, "qqq", 3) == 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.
*/
sprintf(qname, "%s/tmp", getenv("MBSE_ROOT"));
chdir(qname);
sprintf(qname, "%d.%d.%d.%d.qqq", Dest.zone, Dest.net, Dest.node, Dest.point);
fsync(fileno(qp));
fclose(qp);
if (pack_queue(qname) == 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. This is the case when the
* node is locked.
*/
Syslog('s', "pack_queue failed");
qp = fopen(Queue, "a");
}
/*
* Go back to the original inbound directory.
*/
if (do_unprot)
chdir(CFG.inbound);
else
chdir(CFG.pinbound);
}
sprintf(Queue, "%s/%d.%d.%d.%d/mailpkt.%s", CFG.out_queue, Dest.zone, Dest.net, Dest.node, Dest.point, Extension);
mkdirs(Queue, 0750);
Syslog('p', "OpenPkt(%s, %s)", aka2str(Dest), Extension);
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;
}
return qp;
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.
*/
if (do_unprot)
chdir(CFG.inbound);
else
chdir(CFG.pinbound);
}
}
do_flush = TRUE;
return qp;
}

129
mbfido/dirlock.c Normal file
View File

@ -0,0 +1,129 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: Lock mbfido processing.
*
*****************************************************************************
* Copyright (C) 1997-2002
*
* 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 "../config.h"
#include "../lib/libs.h"
#include "../lib/memwatch.h"
#include "../lib/structs.h"
#include "../lib/users.h"
#include "../lib/records.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "flock.h"
#include "dirlock.h"
#define TMPNAME "TMP."
#define LCKNAME "LOCKFILE"
/*
* Put a lock on this program.
*/
int lockdir(char *directory)
{
char *Tmpfile, *lockfile;
FILE *fp;
pid_t oldpid;
Tmpfile = calloc(PATH_MAX, sizeof(char));
lockfile = calloc(PATH_MAX, sizeof(char));
sprintf(Tmpfile, "%s/", directory);
strcpy(lockfile, Tmpfile);
sprintf(Tmpfile + strlen(Tmpfile), "%s%u", TMPNAME, getpid());
sprintf(lockfile + strlen(lockfile), "%s", LCKNAME);
if ((fp = fopen(Tmpfile, "w")) == NULL) {
WriteError("$Can't create lockfile \"%s\"", Tmpfile);
free(Tmpfile);
free(lockfile);
return FALSE;
}
fprintf(fp, "%10u\n", getpid());
fclose(fp);
while (TRUE) {
if (link(Tmpfile, lockfile) == 0) {
unlink(Tmpfile);
free(Tmpfile);
free(lockfile);
return TRUE;
}
if ((fp = fopen(lockfile, "r")) == NULL) {
WriteError("$Can't open lockfile \"%s\"", Tmpfile);
unlink(Tmpfile);
free(Tmpfile);
free(lockfile);
return FALSE;
}
if (fscanf(fp, "%u", &oldpid) != 1) {
WriteError("$Can't read old pid from \"%s\"", Tmpfile);
fclose(fp);
unlink(Tmpfile);
free(Tmpfile);
free(lockfile);
return FALSE;
}
fclose(fp);
if (kill(oldpid,0) == -1) {
if (errno == ESRCH) {
Syslog('+', "Stale lock found for pid %u", oldpid);
unlink(lockfile);
/* no return, try lock again */
} else {
WriteError("$Kill for %u failed",oldpid);
unlink(Tmpfile);
free(Tmpfile);
free(lockfile);
return FALSE;
}
} else {
Syslog('+', "mbfido already running, pid=%u", oldpid);
unlink(Tmpfile);
free(Tmpfile);
free(lockfile);
return FALSE;
}
}
}
void ulockdir(char *directory)
{
char *lockfile;
lockfile = calloc(PATH_MAX, sizeof(char));
sprintf(lockfile, "%s/", directory);
sprintf(lockfile + strlen(lockfile), "%s", LCKNAME);
(void)unlink(lockfile);
free(lockfile);
}

7
mbfido/dirlock.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef _DIRLOCK_H
#define _DIRLOCK_H
int lockdir(char *);
void ulockdir(char *);
#endif

View File

@ -45,13 +45,13 @@ extern int do_unprot;
/*
* Check for lock, return TRUE if node is locked.
*/
int islocked(char *lockfile, int chklck, int waitclr)
int islocked(char *lockfile, int chklck, int waitclr, int loglvl)
{
int i;
time_t now, ftime;
if (chklck && strlen(lockfile)) {
Syslog('m', "Checking lockfile %s", lockfile);
Syslog(loglvl, "Checking lockfile %s", lockfile);
/*
* First check for stale lockfile.
@ -103,13 +103,13 @@ int islocked(char *lockfile, int chklck, int waitclr)
* Create a 1 byte lockfile if create is TRUE.
* Returns FALSE if failed.
*/
int setlock(char *lockfile, int create)
int setlock(char *lockfile, int create, int loglvl)
{
FILE *fp;
char temp[1];
if (create && strlen(lockfile)) {
Syslog('m', "create lockfile %s", lockfile);
Syslog(loglvl, "create lockfile %s", lockfile);
if ((fp = fopen(lockfile, "w")) == NULL) {
WriteError("$Can't create lock %s", lockfile);
return FALSE;
@ -128,13 +128,13 @@ int setlock(char *lockfile, int create)
/*
* Removing lockfile
*/
void remlock(char *lockfile, int create)
void remlock(char *lockfile, int create, int loglvl)
{
if (create) {
if (file_rm(lockfile))
WriteError("$Can't remove lock %s", lockfile);
else
Syslog('m', "Removed lock %s", lockfile);
Syslog(loglvl, "Removed lock %s", lockfile);
}
}
@ -159,9 +159,9 @@ void dirinbound(void)
if (nodes.Session_in == S_DIR && strlen(nodes.Dir_in_path)) {
fileptr = ftell(fp) - nodeshdr.recsize;
Syslog('+', "Directory inbound session for node %s", aka2str(nodes.Aka[0]));
if (! islocked(nodes.Dir_in_clock, nodes.Dir_in_chklck, nodes.Dir_in_waitclr)) {
if (! islocked(nodes.Dir_in_clock, nodes.Dir_in_chklck, nodes.Dir_in_waitclr, 'm')) {
Syslog('m', "Node is free, start processing");
setlock(nodes.Dir_in_mlock, nodes.Dir_in_mklck);
setlock(nodes.Dir_in_mlock, nodes.Dir_in_mklck, 'm');
if ((dp = opendir(nodes.Dir_in_path)) == NULL) {
WriteError("$Can't open directory %s", nodes.Dir_in_path);
@ -197,7 +197,7 @@ void dirinbound(void)
free(from);
}
remlock(nodes.Dir_in_mlock, nodes.Dir_in_mklck);
remlock(nodes.Dir_in_mlock, nodes.Dir_in_mklck, 'm');
}
/*

View File

@ -4,9 +4,9 @@
/* $Id$ */
int islocked(char *, int, int); /* Is directory locked */
int setlock(char *, int); /* Lock directory */
void remlock(char *, int); /* Unlock directory */
int islocked(char *, int, int, int); /* Is directory locked */
int setlock(char *, int, int); /* Lock directory */
void remlock(char *, int, int); /* Unlock directory */
void dirinbound(void); /* Process nodes */
#endif

View File

@ -115,13 +115,13 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
routeto = fido2faddr(Node);
dest = fido2faddr(Node);
if (nodes.Session_out == S_DIR) {
if (islocked(nodes.Dir_out_clock, nodes.Dir_out_chklck, nodes.Dir_out_waitclr)) {
if (islocked(nodes.Dir_out_clock, nodes.Dir_out_chklck, nodes.Dir_out_waitclr, 'p')) {
/*
* Not good, should go to a queue
*/
attach(*routeto, fwdfile, LEAVE, flavor);
} else {
if (! setlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck)) {
if (! setlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck, 'p')) {
/*
* Not good again
*/
@ -348,7 +348,7 @@ void ForwardFile(fidoaddr Node, fa_list *sbl)
}
if (nodes.Session_out == S_DIR)
remlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck);
remlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck, 'p');
/*
* Update the nodes statistic counters

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,6 @@
#include "sendmail.h"
#include "rollover.h"
#include "addpkt.h"
#include "pack.h"
#include "createm.h"
#include "createf.h"
#include "mgrutil.h"
@ -49,6 +48,7 @@
extern int net_out;
extern int do_quiet;
extern int do_flush;
void tidy_arealist(AreaList **);
@ -981,7 +981,7 @@ int Areas(void)
free(buf);
free(temp);
if (net_out)
packmail();
do_flush = TRUE;
return TRUE;
}

View File

@ -1,539 +0,0 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: Pack mail
*
*****************************************************************************
* Copyright (C) 1997-2002
*
* 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 "../config.h"
#include "../lib/libs.h"
#include "../lib/memwatch.h"
#include "../lib/structs.h"
#include "../lib/users.h"
#include "../lib/records.h"
#include "../lib/common.h"
#include "../lib/dbftn.h"
#include "../lib/clcomm.h"
#include "../lib/dbnode.h"
#include "dirsession.h"
#include "pack.h"
extern int do_quiet; /* Quiet flag */
static char *dow[] = {(char *)"su", (char *)"mo", (char *)"tu", (char *)"we",
(char *)"th", (char *)"fr", (char *)"sa"};
/*
* Pack queued arcmail mail for a node. If the node is locked, the mail won't
* be packed, and the queue stays as it is. The mail will then be packed
* on a next run.
*/
int pack_queue(char *name)
{
FILE *fp;
faddr noden, *bestaka;
fidoaddr nodenr;
char flavor, nr, oldnr, maxnr, *ext, srcfile[128], *arcfile, *pktfile;
int Attach, fage;
long fsize;
time_t Now;
struct tm *ptm;
sprintf(srcfile, "%s", name);
/*
* Get the nodenumber from the filename
*/
noden.domain = NULL;
noden.name = NULL;
noden.zone = atoi(strtok(name, "."));
noden.net = atoi(strtok(NULL, "."));
noden.node = atoi(strtok(NULL, "."));
noden.point = atoi(strtok(NULL, "."));
if (SearchFidonet(noden.zone))
noden.domain = xstrcpy(fidonet.domain);
memset(&nodenr, 0, sizeof(nodenr));
nodenr.zone = noden.zone;
nodenr.net = noden.net;
nodenr.node = noden.node;
nodenr.point = noden.point;
sprintf(nodenr.domain, "%s", noden.domain);
if (!SearchNode(nodenr)) {
WriteError("Downlink %s not found", aka2str(nodenr));
if (noden.domain)
free(noden.domain);
return FALSE;
}
/*
* If we route via another aka, change everything.
*/
if (nodes.RouteVia.zone) {
Syslog('p', "Route Via %s", aka2str(nodes.RouteVia));
noden.zone = nodes.RouteVia.zone;
noden.net = nodes.RouteVia.net;
noden.node = nodes.RouteVia.node;
noden.point = nodes.RouteVia.point;
if (noden.domain)
free(noden.domain);
noden.domain = xstrcpy(nodes.RouteVia.domain);
/*
* Load routevia noderecord to get the correct flavor.
* If there is no noderecord, reload the old one.
*/
if (!SearchNode(nodes.RouteVia))
SearchNode(nodenr);
}
Syslog('+', "Pack ARCmail for %s, via %s", aka2str(nodenr), ascfnode(&noden, 0x1f));
if (!do_quiet) {
printf("\rAdding ARCmail for %s ", ascfnode(&noden, 0x1f));
fflush(stdout);
}
if (getarchiver((char *)"ZIP")) {
flavor = 'f';
if (nodes.Crash)
flavor = 'c';
if (nodes.Hold)
flavor = 'h';
} else {
WriteError("Archiver ZIP not found");
if (noden.domain)
free(noden.domain);
return FALSE;
}
/*
* Generate ARCmail filename and .PKT filename,
*/
arcfile = calloc(PATH_MAX, sizeof(char));
if (nodes.Session_out == S_DIR) {
Now = time(NULL);
ptm = localtime(&Now);
ext = dow[ptm->tm_wday];
if (!nodes.ARCmailCompat && (nodes.Aka[0].zone != noden.zone)) {
/*
* Generate ARCfile name from the CRC of the ASCII string
* of the node address.
*/
sprintf(arcfile, "%s/%08lx.%s0", nodes.Dir_out_path, StringCRC32(ascfnode(&noden, 0x1f)), ext);
} else {
bestaka = bestaka_s(&noden);
if (noden.point) {
sprintf(arcfile, "%s/%04x%04x.%s0", nodes.Dir_out_path, ((bestaka->net) - (noden.net)) & 0xffff,
((bestaka->node) - (noden.node) + (noden.point)) & 0xffff, ext);
} else if (bestaka->point) {
/*
* Inserted the next code for if we are a point,
* I hope this is ARCmail 0.60 compliant. 21-May-1999
*/
sprintf(arcfile, "%s/%04x%04x.%s0", nodes.Dir_out_path, ((bestaka->net) - (noden.net)) & 0xffff,
((bestaka->node) - (noden.node) - (bestaka->point)) & 0xffff, ext);
} else {
sprintf(arcfile, "%s/%04x%04x.%s0", nodes.Dir_out_path, ((bestaka->net) - (noden.net)) & 0xffff,
((bestaka->node) - (noden.node)) &0xffff, ext);
}
}
Syslog('m', "Arcmail file %s", arcfile);
} else {
sprintf(arcfile, "%s", arcname(&noden, nodes.Aka[0].zone, nodes.ARCmailCompat));
}
pktfile = calloc(40, sizeof(char));
sprintf(pktfile, "%08lx.pkt", sequencer());
if (nodes.Session_out == S_DIR) {
if (islocked(nodes.Dir_out_clock, nodes.Dir_out_chklck, nodes.Dir_out_waitclr)) {
Syslog('+', "Mail stays in queue, will be added later");
if (noden.domain)
free(noden.domain);
free(arcfile);
free(pktfile);
return FALSE;
} else {
if (! setlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck)) {
Syslog('+', "Mail stays in queue, will be added later");
if (noden.domain)
free(noden.domain);
free(arcfile);
free(pktfile);
return FALSE;
}
}
} else {
if (nodelock(&noden)) {
Syslog('+', "Mail stays in queue, will be added later");
if (noden.domain)
free(noden.domain);
free(arcfile);
free(pktfile);
return FALSE;
}
}
if (rename(srcfile, pktfile)) {
WriteError("$Can't rename %s to %s", srcfile, pktfile);
if (nodes.Session_out == S_DIR)
remlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck);
else
nodeulock(&noden);
if (noden.domain)
free(noden.domain);
free(arcfile);
free(pktfile);
return FALSE;
}
/*
* Add zero word at the end of the .pkt file
*/
if ((fp = fopen(pktfile, "a+")) == NULL) {
WriteError("$Can't open %s", pktfile);
if (nodes.Session_out == S_DIR)
remlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck);
else
nodeulock(&noden);
if (noden.domain)
free(noden.domain);
free(arcfile);
free(pktfile);
return FALSE;
}
putc('\0', fp);
putc('\0', fp);
fsync(fileno(fp));
fclose(fp);
/*
* Check the size of the existing archive if there is a size limit.
* Change to new archive names if the existing is too large.
* If the archive size is zero, it's an already sent archive, the
* number will be bumped also.
* If the archive is older then 6 days, the name is also bumped.
* Do this until we find a new name or if the last digit is a '9' or 'z'.
* Purge archives older then toss_days.
*/
nr = oldnr = '0';
Now = time(NULL);
if (nodes.ARCmailAlpha)
maxnr = 'z';
else
maxnr = '9';
Attach = FALSE;
for (;;) {
fsize = file_size(arcfile);
fage = (int)((Now - file_time(arcfile)) / 86400);
if (fsize == -1L) {
Attach = TRUE;
break;
}
if (fsize == 0L) {
if ((fage > 6) && (nr < maxnr)) {
/*
* Remove truncated ARCmail files older then 6 days.
*/
unlink(arcfile);
fsize = -1L;
Attach = TRUE;
break;
}
/*
* Increase filename extension if there is a truncated file of today.
*/
nr++;
if (nr == ('9' +1))
nr = 'a';
arcfile[strlen(arcfile) -1] = nr;
} else if (CFG.maxarcsize && (fsize > (CFG.maxarcsize * 1024)) && (nr < maxnr)) {
/*
* Use a new ARCmail file if the last one is too big.
*/
nr++;
if (nr == ('9' +1))
nr = 'a';
arcfile[strlen(arcfile) -1] = nr;
}
fsize = file_size(arcfile);
fage = (int)((Now - file_time(arcfile)) / 86400);
if ((fsize > 0L) && (fage > 6) && (nr < maxnr)) {
/*
* If there is ARCmail of a week old or older, add mail
* to a new ARCmail bundle.
*/
nr++;
if (nr == ('9' +1))
nr = 'a';
arcfile[strlen(arcfile) -1] = nr;
}
if (oldnr == nr)
break;
else
oldnr = nr;
}
fsize = file_size(arcfile);
if (execute(archiver.marc, arcfile, pktfile, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
unlink(pktfile);
} else {
sync();
sleep(1);
Syslog('+', "Create ARCmail failed, trying again after sync()");
if (execute(archiver.marc, arcfile, pktfile, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
unlink(pktfile);
} else {
WriteError("Can't add %s to ARCmail archive", pktfile);
}
}
if (nodes.Session_out == S_DIR) {
/*
* Change filemode so downlink has rights to the file.
*/
chmod(arcfile, 0660);
}
/*
* Attach file to .flo, not for FTP or Directory sessions.
*/
if (Attach && nodes.Session_out == S_DIRECT)
attach(noden, arcfile, TFS, flavor);
if (nodes.Session_out == S_DIR)
remlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck);
else
nodeulock(&noden);
if (noden.domain)
free(noden.domain);
free(arcfile);
free(pktfile);
return TRUE;
}
/*
* Add queued unpacked mail for a node. If the node is locked, the mail
* stays in the queue.
*/
int add_queue(char *name)
{
faddr noden;
char flavor, srcfile[128], *outfile, *buf;
FILE *inf, *ouf;
int bread;
sprintf(srcfile, "%s", name);
/*
* Get the nodenumber from the filename
*/
noden.domain = NULL;
noden.name = NULL;
noden.zone = atoi(strtok(name, "."));
noden.net = atoi(strtok(NULL, "."));
noden.node = atoi(strtok(NULL, "."));
noden.point = atoi(strtok(NULL, "."));
if (SearchFidonet(noden.zone))
noden.domain = xstrcpy(fidonet.domain);
Syslog('+', "Add Netmail for %s", ascfnode(&noden, 0x1f));
if (!do_quiet) {
printf("\rAdding Netmail for %s ", ascfnode(&noden, 0x1f));
fflush(stdout);
}
outfile = calloc(PATH_MAX, sizeof(char));
if (strstr(srcfile, ".iii"))
flavor = 'i';
else if (strstr(srcfile, ".ccc"))
flavor = 'c';
else if (strstr(srcfile, ".hhh"))
flavor = 'h';
else
flavor = 'f';
if (nodes.Session_out == S_DIR) {
if (flavor == 'f')
flavor = 'o';
if (noden.point)
sprintf(outfile, "%s/%08x.%cut", nodes.Dir_out_path, noden.point, flavor);
else
sprintf(outfile, "%s/%04x%04x.%cut", nodes.Dir_out_path, noden.net, noden.node, flavor);
} else {
sprintf(outfile, "%s", pktname(&noden, flavor));
}
Syslog('p', "Outfile: %s", outfile);
if (nodes.Session_out == S_DIR) {
if (islocked(nodes.Dir_out_clock, nodes.Dir_out_chklck, nodes.Dir_out_waitclr)) {
Syslog('+', "Mail stays in queue, will be added later");
if (noden.domain)
free(noden.domain);
return FALSE;
} else {
if (! setlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck)) {
Syslog('+', "Mail stays in queue, will be added later");
if (noden.domain)
free(noden.domain);
return FALSE;
}
}
} else {
if (nodelock(&noden)) {
Syslog('+', "Mail stays in queue, will be added later");
free(outfile);
if (noden.domain)
free(noden.domain);
return FALSE;
}
}
/*
* Now we must see if there is already mail in the outbound.
* If that's the case, we must skip the .pkt header from the queue
* because there is already a .pkt header also, append to the
* outbound 2 bytes before the end of file, this is the zero word.
*/
if ((inf = fopen(srcfile, "r")) != NULL) {
if (access(outfile, R_OK) == -1) {
ouf = fopen(outfile, "w"); /* create new */
Syslog('p', "Create new %s", outfile);
} else {
ouf = fopen(outfile, "r+"); /* open R/W */
fseek(ouf, -2, SEEK_END); /* b4 0 word */
fseek(inf, 58, SEEK_SET); /* skip header */
Syslog('p', "Append to %s", outfile);
}
if (ouf != NULL) {
buf = malloc(16384);
do {
bread = fread(buf, 1, 16384, inf);
fwrite(buf, 1, bread, ouf);
} while (bread);
free(buf);
putc('\0', ouf);
putc('\0', ouf);
fsync(fileno(ouf));
fclose(ouf);
fclose(inf);
unlink(srcfile);
} else {
WriteError("$Can't open %s", outfile);
fclose(inf);
}
}
if (nodes.Session_out == S_DIR) {
/*
* Change filemode so downlink has rights to the file.
*/
chmod(outfile, 0660);
}
if (nodes.Session_out == S_DIR)
remlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck);
else
nodeulock(&noden);
if (noden.domain)
free(noden.domain);
free(outfile);
return TRUE;
}
/*
* Pack mailqueue file(s) in the $MBSE_ROOT/tmp directory.
*/
void packmail()
{
char *temp;
struct dirent *de;
DIR *dp;
if (!diskfree(CFG.freespace))
return;
IsDoing("Packing mail");
if (!do_quiet) {
colour(9, 0);
printf("Packing mail\n");
colour(3, 0);
}
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/tmp", getenv("MBSE_ROOT"));
if (chdir(temp) == -1) {
WriteError("$Error chdir to %s", temp);
free(temp);
return;
}
if ((dp = opendir(temp)) == NULL) {
WriteError("$Error opendir %s", temp);
free(temp);
return;
}
/*
* Scan the $MBSE_ROOT/tmp directory for .qqq or .nnn files
*/
while ((de = readdir(dp))) {
if (strstr(de->d_name, ".qqq"))
pack_queue(de->d_name);
if (strstr(de->d_name, ".nnn") || strstr(de->d_name, ".iii") || strstr(de->d_name, ".ccc") || strstr(de->d_name, ".hhh"))
add_queue(de->d_name);
}
closedir(dp);
free(temp);
if (!do_quiet) {
printf("\r \r");
fflush(stdout);
}
}

View File

@ -1,11 +0,0 @@
#ifndef _PACK_H
#define _PACK_H
int pack_queue(char *);
int add_queue(char *);
void packmail(void);
#endif

View File

@ -39,7 +39,7 @@
#include "../lib/clcomm.h"
#include "../lib/dbnode.h"
#include "../lib/dbdupe.h"
#include "ulock.h"
#include "unpack.h"
#include "mover.h"
#include "toberep.h"
#include "tic.h"

View File

@ -36,7 +36,530 @@
#include "../lib/records.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "../lib/dbnode.h"
#include "../lib/dbftn.h"
#include "fsort.h"
#include "dirsession.h"
#include "queue.h"
static char *dow[] = {(char *)"su", (char *)"mo", (char *)"tu", (char *)"we",
(char *)"th", (char *)"fr", (char *)"sa"};
extern int do_quiet;
void flush_dir(char *);
void flush_dir(char *ndir)
{
struct dirent *de;
DIR *dp;
FILE *fp, *inf, *ouf;
faddr noden, *bestaka;
fidoaddr nodenr;
int flavor, Attach, fage, first, bread;
long fsize;
char *temp, *fname, *arcfile, *pktfile, *ext, maxnr, nr, oldnr, *buf;
time_t Now;
struct tm *ptm;
struct stat sbuf;
fd_list *fdl = NULL;
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/%s", CFG.out_queue, ndir);
if (chdir(temp) == -1) {
WriteError("$Error chdir to %s", temp);
free(temp);
return;
}
Syslog('p', "Processing outbound queue %s", temp);
/*
* Get the nodenumber from the filename
*/
noden.domain = NULL;
noden.name = NULL;
noden.zone = atoi(strtok(ndir, "."));
noden.net = atoi(strtok(NULL, "."));
noden.node = atoi(strtok(NULL, "."));
noden.point = atoi(strtok(NULL, "\0"));
if (SearchFidonet(noden.zone))
noden.domain = xstrcpy(fidonet.domain);
memset(&nodenr, 0, sizeof(nodenr));
nodenr.zone = noden.zone;
nodenr.net = noden.net;
nodenr.node = noden.node;
nodenr.point = noden.point;
sprintf(nodenr.domain, "%s", noden.domain);
if (!SearchNode(nodenr)) {
WriteError("Downlink %s not found", aka2str(nodenr));
if (noden.domain)
free(noden.domain);
free(temp);
return;
}
/*
* If we route via another aka, change everything.
*/
if (nodes.RouteVia.zone) {
Syslog('p', "Route Via %s", aka2str(nodes.RouteVia));
noden.zone = nodes.RouteVia.zone;
noden.net = nodes.RouteVia.net;
noden.node = nodes.RouteVia.node;
noden.point = nodes.RouteVia.point;
if (noden.domain)
free(noden.domain);
noden.domain = xstrcpy(nodes.RouteVia.domain);
/*
* Load routevia noderecord to get the correct flavor.
* If there is no noderecord, reload the old one.
*/
if (!SearchNode(nodes.RouteVia))
SearchNode(nodenr);
}
/*
* At this point we are ready to add everything to the real outbound.
* Lock the node, if this fails because the node is busy we abort
* and try to add at a later time.
*/
if (nodes.Session_out == S_DIR) {
if (islocked(nodes.Dir_out_clock, nodes.Dir_out_chklck, nodes.Dir_out_waitclr, 'p')) {
Syslog('+', "Mail and files stay in queue, will be added later");
if (noden.domain)
free(noden.domain);
free(temp);
return;
} else {
if (! setlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck, 'p')) {
Syslog('+', "Mail and files stay in queue, will be added later");
if (noden.domain)
free(noden.domain);
free(temp);
return;
}
}
} else {
if (nodelock(&noden)) {
Syslog('+', "Mail and files stay in queue, will be added later");
if (noden.domain)
free(noden.domain);
free(temp);
return;
}
}
/*
* Create arcmail filename for this node.
*/
Now = time(NULL);
arcfile = calloc(PATH_MAX, sizeof(char));
if (nodes.Session_out == S_DIR) {
ptm = localtime(&Now);
ext = dow[ptm->tm_wday];
if (!nodes.ARCmailCompat && (nodes.Aka[0].zone != noden.zone)) {
/*
* Generate ARCfile name from the CRC of the ASCII string of the node address.
*/
sprintf(arcfile, "%s/%08lx.%s0", nodes.Dir_out_path, StringCRC32(ascfnode(&noden, 0x1f)), ext);
} else {
bestaka = bestaka_s(&noden);
if (noden.point) {
sprintf(arcfile, "%s/%04x%04x.%s0", nodes.Dir_out_path, ((bestaka->net) - (noden.net)) & 0xffff,
((bestaka->node) - (noden.node) + (noden.point)) & 0xffff, ext);
} else if (bestaka->point) {
/*
* Inserted the next code for if we are a point,
* I hope this is ARCmail 0.60 compliant. 21-May-1999
*/
sprintf(arcfile, "%s/%04x%04x.%s0", nodes.Dir_out_path, ((bestaka->net) - (noden.net)) & 0xffff,
((bestaka->node) - (noden.node) - (bestaka->point)) & 0xffff, ext);
} else {
sprintf(arcfile, "%s/%04x%04x.%s0", nodes.Dir_out_path, ((bestaka->net) - (noden.net)) & 0xffff,
((bestaka->node) - (noden.node)) &0xffff, ext);
}
}
} else {
sprintf(arcfile, "%s", arcname(&noden, nodes.Aka[0].zone, nodes.ARCmailCompat));
}
Syslog('p', "Arcmail file %s", arcfile);
/*
* If a not finished .pkt file exist, close it first and rename it.
*/
pktfile = calloc(PATH_MAX, sizeof(char));
fname = calloc(PATH_MAX, sizeof(char));
sprintf(fname, "%s/mailpkt.qqq", temp);
if (access(fname, W_OK) == 0) {
sprintf(pktfile, "%s/%08lx.pkt", temp, sequencer());
if (rename(fname, pktfile)) {
WriteError("$Can't rename %s to %s", fname, pktfile);
} else {
/*
* Add zero word to end of .pkt file
*/
if ((fp = fopen(pktfile, "a+")) == NULL) {
WriteError("$Can't open %s", pktfile);
}
putc('\0', fp);
putc('\0', fp);
fsync(fileno(fp));
fclose(fp);
Syslog('p', "Renamed %s to %s", fname, pktfile);
}
}
free(fname);
/*
* Now all mail pkts are ready to archive
*/
if ((dp = opendir(temp)) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
free(arcfile);
if (nodes.Session_out == S_DIR)
remlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck, 'p');
else
nodeulock(&noden);
if (noden.domain)
free(noden.domain);
return;
}
/*
* Read all .pkt filenames, get the timestamp and add them
* to the memory array for later sort on filedate.
*/
while ((de = readdir(dp)))
if ((strlen(de->d_name) == 12) && (strncasecmp(de->d_name+8,".pkt",4) == 0)) {
stat(de->d_name, &sbuf);
Syslog('p', "Adding %s to filelist", de->d_name);
fill_fdlist(&fdl, de->d_name, sbuf.st_mtime);
}
closedir(dp);
sort_fdlist(&fdl);
if (getarchiver((char *)"ZIP")) {
flavor = 'f';
if (nodes.Crash)
flavor = 'c';
if (nodes.Hold)
flavor = 'h';
} else {
WriteError("Archiver ZIP not found");
if (noden.domain)
free(noden.domain);
free(temp);
free(arcfile);
return;
}
first = TRUE;
while ((fname = pull_fdlist(&fdl)) != NULL) {
/*
* Check the size of the existing archive if there is a size limit.
* Change to new archive names if the existing is too large.
* If the archive size is zero, it's an already sent archive, the
* number will be bumped also.
* If the archive is older then 6 days, the name is also bumped.
* Do this until we find a new name or if the last digit is a '9' or 'z'.
* Purge archives older then toss_days.
*/
Syslog('p', "Pulled %s", fname);
nr = oldnr = '0';
if (nodes.ARCmailAlpha)
maxnr = 'z';
else
maxnr = '9';
Attach = FALSE;
for (;;) {
fsize = file_size(arcfile);
fage = (int)((Now - file_time(arcfile)) / 86400);
if (fsize == -1L) {
Attach = TRUE;
break;
}
if (fsize == 0L) {
if ((fage > 6) && (nr < maxnr)) {
/*
* Remove truncated ARCmail files older then 6 days.
*/
unlink(arcfile);
fsize = -1L;
Attach = TRUE;
break;
}
/*
* Increase filename extension if there is a truncated file of today.
*/
nr++;
if (nr == ('9' +1))
nr = 'a';
arcfile[strlen(arcfile) -1] = nr;
} else if (CFG.maxarcsize && (fsize > (CFG.maxarcsize * 1024)) && (nr < maxnr)) {
/*
* Use a new ARCmail file if the last one is too big.
*/
nr++;
if (nr == ('9' +1))
nr = 'a';
arcfile[strlen(arcfile) -1] = nr;
}
fsize = file_size(arcfile);
fage = (int)((Now - file_time(arcfile)) / 86400);
if ((fsize > 0L) && (fage > 6) && (nr < maxnr)) {
/*
* If there is ARCmail of a week old or older, add mail
* to a new ARCmail bundle.
*/
nr++;
if (nr == ('9' +1))
nr = 'a';
arcfile[strlen(arcfile) -1] = nr;
}
if (oldnr == nr)
break;
else
oldnr = nr;
}
fsize = file_size(arcfile);
if (first) {
Syslog('+', "Pack ARCmail for %s, via %s", aka2str(nodenr), ascfnode(&noden, 0x1f));
if (!do_quiet) {
printf("\rAdding ARCmail for %s ", ascfnode(&noden, 0x1f));
fflush(stdout);
}
first = FALSE;
}
if (execute(archiver.marc, arcfile, fname, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
unlink(fname);
} else {
Syslog('+', "Create ARCmail failed, trying again after sync()");
sync();
sleep(1);
if (execute(archiver.marc, arcfile, fname, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null") == 0) {
unlink(fname);
} else {
WriteError("Can't add %s to ARCmail archive", fname);
Attach = FALSE;
}
}
/*
* Change filemode so downlink has rights to the file.
*/
if (nodes.Session_out == S_DIR)
chmod(arcfile, 0660);
/*
* Attach file to .flo, not for FTP or Directory sessions.
*/
if (Attach && nodes.Session_out == S_DIRECT)
attach(noden, arcfile, TFS, flavor);
}
Syslog('p', "Done with ARCmail");
/*
* Open directory again.
*/
if ((dp = opendir(temp)) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
free(arcfile);
if (nodes.Session_out == S_DIR)
remlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck, 'p');
else
nodeulock(&noden);
if (noden.domain)
free(noden.domain);
return;
}
/*
* Read all other mail filenames, get the timestamp and add them
* to the memory array for later sort on filedate.
*/
while ((de = readdir(dp)))
if ((strlen(de->d_name) == 11) && (strncasecmp(de->d_name,"mailpkt.",8) == 0)) {
stat(de->d_name, &sbuf);
Syslog('p', "Adding %s to filelist", de->d_name);
fill_fdlist(&fdl, de->d_name, sbuf.st_mtime);
}
closedir(dp);
sort_fdlist(&fdl);
first = TRUE;
while ((fname = pull_fdlist(&fdl)) != NULL) {
if (first) {
Syslog('+', "Pack unpacked mail for %s, via %s", aka2str(nodenr), ascfnode(&noden, 0x1f));
if (!do_quiet) {
printf("\rAdding netmail for %s ", ascfnode(&noden, 0x1f));
fflush(stdout);
}
first = FALSE;
}
sprintf(pktfile, "%s/%s", temp, fname);
if (strstr(fname, ".iii"))
flavor = 'i';
else if (strstr(fname, ".ccc"))
flavor = 'c';
else if (strstr(fname, ".hhh"))
flavor = 'h';
else
flavor = 'o';
if (nodes.Session_out == S_DIR) {
if (noden.point)
sprintf(arcfile, "%s/%08x.%cut", nodes.Dir_out_path, noden.point, flavor);
else
sprintf(arcfile, "%s/%04x%04x.%cut", nodes.Dir_out_path, noden.net, noden.node, flavor);
} else {
sprintf(arcfile, "%s", pktname(&noden, flavor));
}
Syslog('p', "Outfile: %s", arcfile);
Syslog('p', "Pktfile: %s", pktfile);
/*
* Now we must see if there is already mail in the outbound.
* If that's the case, we must skip the .pkt header from the queue
* because there is already a .pkt header also, append to the
* outbound 2 bytes before the end of file, this is the zero word.
*/
if ((inf = fopen(pktfile, "r")) != NULL) {
if (access(arcfile, R_OK) == -1) {
ouf = fopen(arcfile, "w"); /* create new */
Syslog('p', "Create new %s", arcfile);
} else {
ouf = fopen(arcfile, "r+"); /* open R/W */
fseek(ouf, -2, SEEK_END); /* b4 0 word */
fseek(inf, 58, SEEK_SET); /* skip header */
Syslog('p', "Append to %s", arcfile);
}
if (ouf != NULL) {
buf = malloc(16384);
do {
bread = fread(buf, 1, 16384, inf);
fwrite(buf, 1, bread, ouf);
} while (bread);
free(buf);
putc('\0', ouf);
putc('\0', ouf);
fsync(fileno(ouf));
fclose(ouf);
fclose(inf);
unlink(pktfile);
} else {
WriteError("$Can't open %s", arcfile);
fclose(inf);
}
}
/*
* Change filemode so downlink has rights to the file.
*/
if (nodes.Session_out == S_DIR)
chmod(arcfile, 0660);
}
Syslog('p', "Done with netmail");
// Add files
/*
* We are done, the queue is flushed, unlock the node.
*/
if (nodes.Session_out == S_DIR)
remlock(nodes.Dir_out_mlock, nodes.Dir_out_mklck, 'p');
else
nodeulock(&noden);
if (noden.domain)
free(noden.domain);
free(temp);
free(arcfile);
free(pktfile);
return;
}
/*
* Flush outbound queue to real outbound.
*/
void flush_queue(void)
{
char *temp;
struct dirent *de;
DIR *dp;
Syslog('+', "Flushing outbound queue");
if (!diskfree(CFG.freespace))
return;
IsDoing("Flush queue");
if (!do_quiet) {
colour(LIGHTBLUE, BLACK);
printf("Flushing outbound queue\n");
colour(CYAN, BLACK);
}
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/foobar", CFG.out_queue);
mkdirs(temp, 0750);
if ((dp = opendir(CFG.out_queue)) == 0) {
WriteError("$Can't open %s", CFG.out_queue);
free(temp);
return;
}
/*
* The outbound queue contains subdirectories which actuallly hold the
* queue outbound files. Process each found subdirectory.
*/
while ((de = readdir(dp))) {
if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) {
sprintf(temp, "%s/%s", CFG.out_queue, de->d_name);
Syslog('p', "Queue directory %s", temp);
flush_dir(de->d_name);
if (chdir(CFG.out_queue))
WriteError("$Can't chdir to %s", CFG.out_queue);
if (rmdir(temp))
WriteError("$Can't rmdir %s", temp);
}
}
closedir(dp);
free(temp);
if (!do_quiet) {
printf("\r \r");
fflush(stdout);
}
}

View File

@ -3,4 +3,8 @@
/* $Id$ */
void flush_queue(void);
#endif

View File

@ -45,7 +45,6 @@
#include "mkftnhdr.h"
#include "hash.h"
#include "rollover.h"
#include "pack.h"
#include "postnetmail.h"
#include "postecho.h"
#include "msgflags.h"

View File

@ -43,7 +43,6 @@
#include "../lib/dbmsgs.h"
#include "../lib/msg.h"
#include "../lib/msgtext.h"
#include "pack.h"
#include "rfc2ftn.h"
#include "mbfido.h"
#include "../paths.h"
@ -100,6 +99,7 @@ extern int most_debug;
extern int news_in;
extern int news_dupe;
extern int check_dupe;
extern int do_flush;
void ProcessOne(FILE *);
@ -561,7 +561,7 @@ void NewsUUCP(void)
most_debug = FALSE;
WaitForChildren(i);
Syslog('+', "End of UUCP batch, rc=%d", rc);
packmail();
do_flush = TRUE;
if (!do_quiet)
printf("\r \r");

View File

@ -41,7 +41,6 @@
#include "../lib/dbnode.h"
#include "../lib/dbmsgs.h"
#include "addpkt.h"
#include "pack.h"
#include "tracker.h"
#include "ftn2rfc.h"
#include "rfc2ftn.h"
@ -56,6 +55,7 @@ extern int echo_in;
extern int email_out;
extern int echo_out;
extern int most_debug;
extern int do_flush;
int scanned;
#define MAXSEEN 70
@ -133,7 +133,7 @@ void ScanMail(int DoAll)
ScanFull();
if (echo_out || net_out)
packmail();
do_flush = TRUE;
RemoveSema((char *)"mailout");
}

View File

@ -45,7 +45,6 @@
#include "mkftnhdr.h"
#include "hash.h"
#include "rollover.h"
#include "pack.h"
#include "storeecho.h"
#include "rfc2ftn.h"
#include "scannews.h"
@ -75,6 +74,7 @@ extern int news_imp;
extern int news_dupe;
extern int echo_out;
extern int echo_in;
extern int do_flush;
extern char *replyaddr;
@ -243,7 +243,7 @@ void ScanNews(void)
free(tmp->field);
free(tmp);
}
packmail();
do_flush = TRUE;
if (!do_quiet)
printf("\r \r");

View File

@ -37,10 +37,9 @@
#include "../lib/common.h"
#include "../lib/dbftn.h"
#include "../lib/clcomm.h"
#include "ulock.h"
#include "unpack.h"
#include "ptic.h"
#include "fsort.h"
#include "pack.h"
#include "tic.h"
#define UNPACK_FACTOR 300
@ -55,6 +54,7 @@ int tic_dup = 0; /* dupe .tic files */
extern int do_unprot;
extern int do_quiet;
extern int tic_in;
extern int do_flush;
/*
@ -149,7 +149,7 @@ int Tic()
}
if (rc)
packmail();
do_flush = TRUE;
if (CompileNL)
CreateSema((char *)"mbindex");

View File

@ -1,11 +0,0 @@
#ifndef _ULOCK_H
#define _ULOCK_H
int checkspace(char *, char *, int);
int lockunpack(void);
void ulockunpack(void);
int unpack(char *);
#endif

View File

@ -1,7 +1,7 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: Lock mbfido processing.
* Purpose ...............: Unpacker
*
*****************************************************************************
* Copyright (C) 1997-2002
@ -37,85 +37,13 @@
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "flock.h"
#include "ulock.h"
#include "unpack.h"
#define UNPACK_FACTOR 300
#define TOSS_FACTOR 120
#define TMPNAME "TMP."
#define LCKNAME "LOCKFILE"
static char lockfile[81];
extern int do_quiet;
static int is_locked = FALSE;
/*
* Put a lock on this program.
*/
int lockunpack(void)
{
char Tmpfile[81];
FILE *fp;
pid_t oldpid;
sprintf(Tmpfile, "%s/", CFG.inbound);
strcpy(lockfile, Tmpfile);
sprintf(Tmpfile + strlen(Tmpfile), "%s%u", TMPNAME, getpid());
sprintf(lockfile + strlen(lockfile), "%s", LCKNAME);
if ((fp = fopen(Tmpfile, "w")) == NULL) {
WriteError("$Can't create lockfile \"%s\"", Tmpfile);
return 1;
}
fprintf(fp, "%10u\n", getpid());
fclose(fp);
while (1) {
if (link(Tmpfile, lockfile) == 0) {
unlink(Tmpfile);
is_locked = TRUE;
return 0;
}
if ((fp = fopen(lockfile, "r")) == NULL) {
WriteError("$Can't open lockfile \"%s\"", Tmpfile);
unlink(Tmpfile);
return 1;
}
if (fscanf(fp, "%u", &oldpid) != 1) {
WriteError("$Can't read old pid from \"%s\"", Tmpfile);
fclose(fp);
unlink(Tmpfile);
return 1;
}
fclose(fp);
if (kill(oldpid,0) == -1) {
if (errno == ESRCH) {
Syslog('+', "Stale lock found for pid %u", oldpid);
unlink(lockfile);
/* no return, try lock again */
} else {
WriteError("$Kill for %u failed",oldpid);
unlink(Tmpfile);
return 1;
}
} else {
Syslog('+', "mbfido already running, pid=%u", oldpid);
unlink(Tmpfile);
return 1;
}
}
}
void ulockunpack(void)
{
if (is_locked && lockfile)
(void)unlink(lockfile);
}
extern int do_quiet;
int checkspace(char *dir, char *fn, int factor)

9
mbfido/unpack.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef _UNPACK_H
#define _UNPACK_H
/* $Id$ */
int checkspace(char *, char *, int);
int unpack(char *);
#endif