From f5e883cc6f65594639f98fd7c283b0742db40b2f Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Wed, 3 Apr 2002 20:29:12 +0000 Subject: [PATCH] TIC netmail forward now uses a template --- ChangeLog | 1 + examples/templates.tar | Bin 51200 -> 51200 bytes lib/mbdiesel.c | 50 ++++++++++++++++++++++++++++++++ mbfido/Makefile | 11 ++++--- mbfido/areamgr.c | 6 ++-- mbfido/filemgr.c | 2 +- mbfido/forward.c | 64 +++++++++++++++++++++++------------------ 7 files changed, 96 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 074f14bc..31d9fab0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4696,6 +4696,7 @@ v0.33.20 10-Feb-2002 the diesel macro language. The tic file forward function now uses only filenames in the subject of the netmail messages without the path. + The tic file forward netmails now uses template forward.tic mball: Will not crash anymore when it needs more then 10 minutes to diff --git a/examples/templates.tar b/examples/templates.tar index 3e2a2ed981ee8b842835b2ec1eaafc47ffa65a24..20ee29467a2c7cf9577db639f3e2839d979694b6 100644 GIT binary patch delta 2186 zcma)7&u`pB6wV}&6f01u60t!Q42nn_DMbFgqDv(w*$pYBO|xmKKoynOJG*h$Ye%-5 z5Ku^I6Cs3>1{)+e6e0CMPpHM0NF2g}1IKdU#@~R%l>_2EuXpYAV3Azree?Xyd*AzJ z_SXKut^I-hor0qF@kLn?RfQK7p^p~?RTcXv9}1)%5i-(0Hc!ves&3bvHf=brf752v zaGaLOq8A1Zh6bmnr>Qm{&U|?oYUD~Vyi<^r9wpELrN~QikMh~SNG|0PiQatvhk;;Z zdrTBlCW+_c;v}KRG`gJ6q?72;i-&_pEBrB_I|UW0N}87VVy9`f$NTEf1GyF6CefLR z;Mh^#YQXOumxZDLdJ2kMH&!kMEQt835pbW#6dPI_p`iWv@5|tDAL^CA3v`~Al0rS7;_-12+8>eg0 zFAE3#q!DeLAMPLGdc(gOTuj@S6;L7RbMX!t6NOA2N<2qiF7_H)`YpeX3W>NY*Pd|N zL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$o`g~kx+5j7aAl@2Gtcd_X*o=QyT4m3s-aD^6c=BLRx&U4T%P=wZ?wA#} z>%9%=)zq~I=QKSH{{70Rm9fY*E$UbD?DuPRh#nH6(T<(zig>9pXlrNXo< zIIi8;1m!{zl!Co(>*8V_io9z#9bH|jK~<}}oh$a1-ByX6tcG8CaX`cWDrL9<_(ms* m+~ydezw-4k#e!RDQlcpW{*eBgfd0FxM_-LT-a7%0{kebrc^JO{ diff --git a/lib/mbdiesel.c b/lib/mbdiesel.c index 4ac97ac4..8a6f9ed2 100644 --- a/lib/mbdiesel.c +++ b/lib/mbdiesel.c @@ -36,6 +36,8 @@ #include "clcomm.h" #include "diesel.h" +static int firstrandom = TRUE; + void MacroVars( const char *codes, const char *fmt, ...) { @@ -187,6 +189,53 @@ char *ParseMacro( const char *line, int *dieselrc) +/* + * Add random fortune cookie to the macrovars + */ +void Cookie(void); +void Cookie(void) +{ + FILE *olf; + char *fname; + long recno, records; + + fname = calloc(PATH_MAX, sizeof(char)); + sprintf(fname, "%s/etc/oneline.data", getenv("MBSE_ROOT")); + + if ((olf = fopen(fname, "r")) == NULL) { + WriteError("$Can't open %s", fname); + free(fname); + return; + } + + fread(&olhdr, sizeof(olhdr), 1, olf); + fseek(olf, 0, SEEK_END); + records = (ftell(olf) - olhdr.hdrsize) / olhdr.recsize; + + if (firstrandom) { + srand(getpid()); + firstrandom = FALSE; + } + recno = 1+(int) (1.0 * records * rand() / (RAND_MAX + 1.0)); + Syslog('f', "Selected quote %d out of %d records", recno, records); + + if (fseek(olf, olhdr.hdrsize + (recno * olhdr.recsize), SEEK_SET) == 0) { + if (fread(&ol, olhdr.recsize, 1, olf) == 1) { + MacroVars("F", "s", ol.Oneline); + } else { + WriteError("Can't read %s", fname); + } + } else { + WriteError("$Can't seek record %d in %s", recno, fname); + } + fclose(olf); + free(fname); + + return; +} + + + FILE *OpenMacro(const char *filename, int Language) { FILE *pLang, *fi = NULL; @@ -236,6 +285,7 @@ FILE *OpenMacro(const char *filename, int Language) sprintf(temp, "%s-%s", OsName(), OsCPU()); MacroVars("HLMNOSTUVYZ", "ssssssssssd", CFG.www_url, CFG.location, CFG.sysdomain, CFG.bbs_name, temp, CFG.sysop_name, CFG.comment, CFG.sysop, VERSION, aka2str(CFG.aka[0]), 0); + Cookie(); } free(temp); diff --git a/mbfido/Makefile b/mbfido/Makefile index 9833bf42..19de8c74 100644 --- a/mbfido/Makefile +++ b/mbfido/Makefile @@ -7,7 +7,7 @@ include ../Makefile.global SRCS = addbbs.c backalias.c flock.c hatch.c mbdiff.c mgrutil.c pack.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 \ - cookie.c fsort.c magic.c mbfile.c mover.c post.c rnews.c storenet.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 \ mbmsg.c newspost.c postemail.c scan.c toberep.c atoul.c filemgr.c \ @@ -18,7 +18,7 @@ SRCS = addbbs.c backalias.c flock.c hatch.c mbdiff.c mgrutil.c pack.c \ HDRS = addbbs.h backalias.h flock.h hatch.h mbdiff.h mgrutil.h pack.h \ postnetmail.h scannews.h tosspkt.h addpkt.h bwrite.h forward.h \ lhash.h mbfido.h mkftnhdr.h paths.h ptic.h sendmail.h tracker.h \ - aliasdb.h cookie.h fsort.h magic.h mbfile.h mover.h ping.h rfc2ftn.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 \ 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 \ @@ -29,7 +29,7 @@ HDRS = addbbs.h backalias.h flock.h hatch.h mbdiff.h mgrutil.h pack.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 \ utic.o mover.o hash.o mkftnhdr.o addbbs.o magic.o fsort.o toberep.o \ - ftn2rfc.o atoul.o ping.o cookie.o forward.o sendmail.o scan.o addpkt.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 @@ -146,7 +146,7 @@ sendmail.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../li tracker.o: ../lib/libs.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: ../lib/libs.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 bwrite.o: ../lib/libs.h bwrite.h -forward.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h ../lib/dbtic.h tic.h cookie.h sendmail.h rollover.h forward.h +forward.o: ../lib/libs.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 lhash.o: ../lib/libs.h ../lib/clcomm.h lhash.h mbfido.o: ../lib/libs.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 backalias.h rfc2ftn.h mkftnhdr.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h atoul.h hash.h aliasdb.h mkftnhdr.h @@ -155,7 +155,6 @@ rfc2ftn.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib storeecho.o: ../lib/libs.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: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h flock.h ulock.h aliasdb.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h aliasdb.h -cookie.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h cookie.h fsort.o: ../lib/libs.h ../lib/clcomm.h fsort.h magic.o: ../lib/libs.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: ../lib/libs.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 @@ -174,7 +173,7 @@ postecho.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../li rollover.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h rollover.h tic.o: ../lib/libs.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 areamgr.o: ../lib/libs.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: ../lib/libs.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 fflist.h filefind.h msgutil.h +filefind.o: ../lib/libs.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: ../lib/libs.h ../lib/clcomm.h grlist.h maketags.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h maketags.h mbmsg.o: ../lib/libs.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 diff --git a/mbfido/areamgr.c b/mbfido/areamgr.c index 8c7baefb..8ac87db6 100644 --- a/mbfido/areamgr.c +++ b/mbfido/areamgr.c @@ -464,12 +464,13 @@ void A_Status(faddr *t, char *replyid) subject = calloc(255, sizeof(char)); sprintf(subject,"AreaMgr Status"); - + Syslog('+', "AreaMgr: Status"); + if (Miy == 0) i = 11; else i = Miy - 1; - MacroVars("DCEFGRPQRpqrsYy","ddddcsddddddsss", + MacroVars("DCEfGvPQRpqrsYy","ddddcsddddddsss", nodes.Direct, nodes.Crash, nodes.Hold, @@ -487,7 +488,6 @@ void A_Status(faddr *t, char *replyid) ascfnode(bestaka_s(t), 0xf) ); GetRpSubject("areamgr.status",subject); - Syslog('+', "AreaMgr: Status"); if ((fi = OpenMacro("areamgr.status", nodes.Language)) == NULL ){ MacroClear(); diff --git a/mbfido/filemgr.c b/mbfido/filemgr.c index d4204f6a..2a57cb6e 100644 --- a/mbfido/filemgr.c +++ b/mbfido/filemgr.c @@ -292,7 +292,7 @@ void F_Status(faddr *t, char *replyid) i = 11; else i = Miy - 1; - MacroVars("ABCDEFGIJabcdefghijkls", "ddddddddddddddddddddds", + MacroVars("ABCDEfGIJabcdefghijkls", "ddddddddddddddddddddds", nodes.Message, nodes.Tic, nodes.AdvTic, diff --git a/mbfido/forward.c b/mbfido/forward.c index c2fedc2f..89ea6d27 100644 --- a/mbfido/forward.c +++ b/mbfido/forward.c @@ -36,10 +36,11 @@ #include "../lib/clcomm.h" #include "../lib/dbnode.h" #include "../lib/dbtic.h" +#include "../lib/diesel.h" #include "tic.h" -#include "cookie.h" #include "sendmail.h" #include "rollover.h" +#include "mgrutil.h" #include "forward.h" @@ -47,13 +48,14 @@ void ForwardFile(fidoaddr Node, fa_list *sbl) { - char *subject = NULL, *temp, *fwdfile = NULL, *ticfile = NULL, fname[PATH_MAX], *ticname; - FILE *fp, *net; + char *subject = NULL, *temp, *line, *fwdfile = NULL, *ticfile = NULL, fname[PATH_MAX], *ticname; + FILE *fp, *fi, *net; char flavor; faddr *dest, *route, *Fa; int i, z, n; time_t now; fa_list *tmp; + long filepos; Syslog('+', "Forward file to %s", aka2str(Node)); @@ -133,32 +135,38 @@ void ForwardFile(fidoaddr Node, fa_list *sbl) * Send netmail message if the node has it turned on. */ if (nodes.Message) { - if ((net = SendMgrMail(fido2faddr(Node), CFG.ct_KeepMgr, TRUE, (char *)"Filemgr", subject, NULL)) != NULL) { - fprintf(net, " Dear %s\r", nodes.Sysop); - fprintf(net, "\r"); - fprintf(net, "I sent the following file to your system:\r"); - fprintf(net, "\r"); - if (TIC.SendOrg) - fprintf(net, "File : %s\r", TIC.RealName); - else - fprintf(net, "File : %s\r", TIC.NewName); - fprintf(net, "Description : %s\r", TIC.TicIn.Desc); - fprintf(net, "Area : %s %s\r", TIC.TicIn.Area, TIC.TicIn.AreaDesc); - fprintf(net, "Size : %ld\r", (long)(TIC.FileSize)); - fprintf(net, "CRC : %s\r", TIC.TicIn.Crc); - fprintf(net, "Origin : %s\r", TIC.TicIn.Origin); - if (strlen(TIC.TicIn.Magic)) - fprintf(net, "Magic : %s\r", TIC.TicIn.Magic); - if (strlen(TIC.TicIn.Replace)) - fprintf(net, "Replaces : %s\r", TIC.TicIn.Replace); - fprintf(net, "\r\r"); - fprintf(net, "With regards, %s\r\r", CFG.sysop_name); - fprintf(net, "... %s\r\r", Cookie()); - fprintf(net, "%s\r", TearLine()); - CloseMail(net, fido2faddr(Node)); - } else { - WriteError("$Can't create netmail"); + if ((net = SendMgrMail(fido2faddr(Node), CFG.ct_KeepMgr, TRUE, (char *)"Filemgr", subject, NULL)) != NULL) { + if ((fi = OpenMacro("forward.tic", nodes.Language)) != NULL) { + MacroVars("abcfghijmns", "ssdsddsssss", TIC.TicIn.Area, TIC.TicIn.AreaDesc, TIC.FileCost, + TIC.TicIn.FullName, TIC.FileSize, TIC.FileSize / 1024, + TIC.TicIn.Crc, TIC.TicIn.Origin, " ", TIC.TicIn.LDesc[0], nodes.Sysop); + if (TIC.SendOrg) + MacroVars("e", "s", TIC.RealName); + else + MacroVars("e", "s", TIC.NewName); + if (strlen(TIC.TicIn.Magic)) + MacroVars("k", "s", TIC.TicIn.Magic); + if (strlen(TIC.TicIn.Replace)) + MacroVars("l", "s", TIC.TicIn.Replace); + MacroRead(fi, net); + filepos = ftell(fi); + for (i = 1; i < 25; i++) { + fseek(fi, filepos, SEEK_SET); + if (strlen(TIC.TicIn.LDesc[i])) { + MacroRead(fi, net); + } else { + line = calloc(255, sizeof(char)); + while ((fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) {} + free(line); + } + } + MacroRead(fi, net); + fprintf(net, "%s\r", TearLine()); + CloseMail(net, fido2faddr(Node)); } + } else { + WriteError("$Can't create netmail"); + } } free(subject);