From 60326e7a3dd289d05db087e7ab4830d53314f76d Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Wed, 10 Aug 2005 18:57:22 +0000 Subject: [PATCH] Recreate golded.inc and msg.txt when message areas are auto created --- ChangeLog | 2 + TODO | 3 - mbfido/Makefile | 2 +- mbfido/createm.c | 177 ++++++++++++++++++++++++++++++++++++++++++++++- mbfido/createm.h | 8 ++- mbfido/mbfido.c | 1 - mbfido/mbfido.h | 4 +- 7 files changed, 186 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8208e560..0f612a86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,8 @@ v0.71.3 13-Jun-2005 mbfido: Fixed commandline parser for mail recipients. Added subject line clean in several places. + When message areas are autocreated, golded.inc and msg.txt are + recreated for the external editors. mbsetup: Added setup switches per node to disable PLZ or GZ and BZ2 diff --git a/TODO b/TODO index 147b4517..dadf55d9 100644 --- a/TODO +++ b/TODO @@ -98,9 +98,6 @@ mbfido: N: Add statistic mail messages. Via AMC?? - N: With auto created areas golded.inc is not adjusted to the new - setup. - N: After readalias we need to free the alias list when mbfido ends. N: Reimplement characterset conversion again on the gateway. diff --git a/mbfido/Makefile b/mbfido/Makefile index 20b94c4e..66af9d49 100644 --- a/mbfido/Makefile +++ b/mbfido/Makefile @@ -138,7 +138,7 @@ addpkt.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h addpkt.h bwrite.o: ../config.h ../lib/mbselib.h bwrite.h forward.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h ../lib/diesel.h tic.h sendmail.h rollover.h mgrutil.h forward.h lhash.o: ../config.h ../lib/mbselib.h lhash.h -mbfido.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/nodelist.h ../lib/mbsedb.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 msg.h +mbfido.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/nodelist.h ../lib/mbsedb.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 msg.h createm.h mkftnhdr.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h atoul.h hash.h msgflags.h aliasdb.h mkftnhdr.h ping.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/msg.h ../lib/msgtext.h ../lib/mbsedb.h sendmail.h postnetmail.h ping.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 rollover.h postnetmail.h postecho.h msgflags.h rfc2ftn.h diff --git a/mbfido/createm.c b/mbfido/createm.c index de4c9677..8221d7a4 100644 --- a/mbfido/createm.c +++ b/mbfido/createm.c @@ -4,7 +4,7 @@ * Purpose ...............: Create Message Area * ***************************************************************************** - * Copyright (C) 1997-2004 + * Copyright (C) 1997-2005 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -39,6 +39,8 @@ #define MCHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" +extern int areas_changed; + int create_msgarea(char *marea, faddr *p_from) { @@ -285,6 +287,7 @@ int CheckEchoGroup(char *Area, int SendUplink, faddr *f) else Mgrlog("Auto created echo %s, group %s, area %ld, for node %s", msgs.Tag, msgs.Group, offset, ascfnode(f , 0x1f)); + areas_changed = TRUE; return 0; } /* if (strcmp(tag, Area) == 0) */ } /* if (strlen(buf) && isalnum(buf[0])) */ @@ -298,3 +301,175 @@ int CheckEchoGroup(char *Area, int SendUplink, faddr *f) } + +void msged_areas(FILE *fp) +{ + char *temp, *aka; + FILE *no; + int i = 0; + + temp = calloc(PATH_MAX, sizeof(char)); + sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + if ((no = fopen(temp, "r")) == NULL) { + free(temp); + return; + } + + fread(&msgshdr, sizeof(msgshdr), 1, no); + fseek(no, 0, SEEK_SET); + fread(&msgshdr, msgshdr.hdrsize, 1, no); + + while (fread(&msgs, msgshdr.recsize, 1, no) == 1) { + + i++; + if (msgs.Active) { + + fprintf(fp, "Jam "); + + switch (msgs.Type) { + case LOCALMAIL: fprintf(fp, "l"); break; + case NETMAIL: fprintf(fp, "mp"); break; + case ECHOMAIL: fprintf(fp, "e"); break; + case NEWS: fprintf(fp, "e"); break; + } + + if (((msgs.Type == NEWS) || (msgs.Type == ECHOMAIL)) && strlen(msgs.Tag) && strlen(msgs.Newsgroup)) { + fprintf(fp, "u"); + } + fprintf(fp, "8"); + fprintf(fp, " \"%s\" %s", msgs.Name, msgs.Base); + if (msgs.Type == ECHOMAIL) + fprintf(fp, " %s", msgs.Tag); + if (msgs.Type != LOCALMAIL) { + aka = xstrcpy(strtok(aka2str(msgs.Aka), "@")); + fprintf(fp, " %s", aka); + free(aka); + } + fprintf(fp, "\n"); + } + fseek(no, msgshdr.syssize, SEEK_CUR); + } + + fclose(no); + free(temp); +} + + + +void gold_areas(FILE *fp) +{ + char *temp, *aka; + FILE *no; + int i = 0; + + temp = calloc(PATH_MAX, sizeof(char)); + sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + if ((no = fopen(temp, "r")) == NULL) { + free(temp); + return; + } + + fread(&msgshdr, sizeof(msgshdr), 1, no); + fseek(no, 0, SEEK_SET); + fread(&msgshdr, msgshdr.hdrsize, 1, no); + + fprintf(fp, "; Message Areas\n;\n"); + fprintf(fp, "AREASCAN *\n"); + fprintf(fp, "AREATYPEORDER Net Email Echo News Local\n"); + + while (fread(&msgs, msgshdr.recsize, 1, no) == 1) { + + i++; + if (msgs.Active) { + fprintf(fp, "AREADEF "); + if (strlen(msgs.Tag)) + fprintf(fp, "%s", msgs.Tag); + else + fprintf(fp, "AREA%d", i); + fprintf(fp, " \"%s\" ", msgs.Name); + switch (msgs.Type) { + case LOCALMAIL : fprintf(fp, "0 Local"); break; + case NETMAIL : fprintf(fp, "N Net"); break; + case ECHOMAIL : fprintf(fp, "C Echo"); break; + case NEWS : fprintf(fp, "I News"); break; + } + aka = xstrcpy(strtok(aka2str(msgs.Aka), "@")); + fprintf(fp, " JAM %s %s ", msgs.Base, aka); + free(aka); + if (msgs.Type == NETMAIL) + fprintf(fp, "(Loc Pvt)"); + else + fprintf(fp, "(Loc)"); + + fprintf(fp, " \"%s\"\n", msgs.Origin); + } + fseek(no, msgshdr.syssize, SEEK_CUR); + } + + fclose(no); + free(temp); + fprintf(fp, "\n"); +} + + + +void gold_akamatch(FILE *fp) +{ + char temp[PATH_MAX]; + FILE *fido; + faddr *want, *ta; + int i; + + sprintf(temp, "%s/etc/fidonet.data", getenv("MBSE_ROOT")); + if ((fido = fopen(temp, "r")) == NULL) + return; + + fprintf(fp, "; AKA Matching\n;\n"); + want = (faddr *)malloc(sizeof(faddr)); + + fread(&fidonethdr, sizeof(fidonethdr), 1, fido); + while ((fread(&fidonet, fidonethdr.recsize, 1, fido)) == 1) { + + if (fidonet.available) { + for (i = 0; i < 6; i++) { + if (fidonet.zone[i]) { + want->zone = fidonet.zone[0]; + want->net = 0; + want->node = 0; + want->point = 0; + want->name = NULL; + want->domain = NULL; + ta = bestaka_s(want); + fprintf(fp, "AKAMATCH %d:* %s\n", fidonet.zone[i], ascfnode(ta, 0xf)); + tidy_faddr(ta); + } + } + } + } + + free(want); + fprintf(fp, ";\n"); + fprintf(fp, "AKAMATCHNET YES\n"); + fprintf(fp, "AKAMATCHECHO YES\n"); + fprintf(fp, "AKAMATCHLOCAL NO\n\n"); + + fprintf(fp, "; NODELISTS\n;\n"); + fprintf(fp, "NODEPATH %s/\n", CFG.nodelists); + fseek(fido, fidonethdr.hdrsize, SEEK_SET); + while ((fread(&fidonet, fidonethdr.recsize, 1, fido)) == 1) { + if (fidonet.available) { + fprintf(fp, "NODELIST %s.*\n", fidonet.nodelist); + for (i = 0; i < 6; i++) + if (strlen(fidonet.seclist[i].nodelist) || fidonet.seclist[i].zone) + fprintf(fp, "NODELIST %s.*\n", fidonet.seclist[i].nodelist); + } + } + // fprintf(fp, "USERLIST golded.lst\n"); + fprintf(fp, "LOOKUPNET YES\n"); + fprintf(fp, "LOOKUPECHO NO\n"); + fprintf(fp, "LOOKUPLOCAL NO\n\n"); + fclose(fido); +} + + + diff --git a/mbfido/createm.h b/mbfido/createm.h index 92db357d..03c9ec29 100644 --- a/mbfido/createm.h +++ b/mbfido/createm.h @@ -4,9 +4,11 @@ #define _CREATEM_H -int create_msgarea(char *, faddr *); -int CheckEchoGroup(char *, int, faddr *); - +int create_msgarea(char *, faddr *); +int CheckEchoGroup(char *, int, faddr *); +void msged_areas(FILE *); +void gold_areas(FILE *); +void gold_akamatch(FILE *); #endif diff --git a/mbfido/mbfido.c b/mbfido/mbfido.c index 76ca022b..aac53a40 100644 --- a/mbfido/mbfido.c +++ b/mbfido/mbfido.c @@ -708,7 +708,6 @@ int TossMail(void) int files = 0, files_ok = 0, rc = 0, maxrc = 0; fd_list *fdl = NULL; - areas_changed = TRUE; if (do_unprot) inbound = xstrcpy(CFG.inbound); else diff --git a/mbfido/mbfido.h b/mbfido/mbfido.h index 67facb0f..38823e20 100644 --- a/mbfido/mbfido.h +++ b/mbfido/mbfido.h @@ -1,8 +1,8 @@ -/* mbfido.h */ - #ifndef _MBFIDO_H #define _MBFIDO_H +/* $Id$ */ + void Help(void); void ProgName(void); void die(int);