Added mbfido areas command, bulk create msg areas works

This commit is contained in:
Michiel Broek 2002-04-27 21:06:51 +00:00
parent 376e2b2b5c
commit d7ddc264bc
13 changed files with 273 additions and 21 deletions

View File

@ -4729,6 +4729,10 @@ v0.33.20 10-Feb-2002
Areamgr uplink requests the sender name is now set to the
sysop's name, so he/she will get to read the responses.
mbmsg:
When creating non-existend message bases, the path is created
first if it doesn't exist.
mbfile:
The mbfile index command now creates the html pages using the
macro templates html.main and html.areas. The files.css file

View File

@ -217,7 +217,7 @@ void Cookie(void)
srand(getpid());
firstrandom = FALSE;
}
recno = 1+(int) (1.0 * records * rand() / (RAND_MAX + 1.0));
recno = (1+(int) (1.0 * records * rand() / (RAND_MAX + 1.0))) - 1;
if (fseek(olf, olhdr.hdrsize + (recno * olhdr.recsize), SEEK_SET) == 0) {
if (fread(&ol, olhdr.recsize, 1, olf) == 1) {

View File

@ -139,7 +139,7 @@ backalias.o: ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ../l
flock.o: ../lib/libs.h ../lib/clcomm.h flock.h
hatch.o: ../lib/libs.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: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbdiff.h
mgrutil.o: ../lib/libs.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 mgrutil.h
mgrutil.o: ../lib/libs.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: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/dbftn.h ../lib/clcomm.h ../lib/dbnode.h pack.h
ptic.o: ../lib/libs.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
sendmail.o: ../lib/libs.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
@ -148,7 +148,7 @@ addpkt.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/
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 ../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
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 mgrutil.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
ping.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/dbtic.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/dbftn.h sendmail.h postnetmail.h ping.h
rfc2ftn.o: ../lib/libs.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 rfc2ftn.h
@ -203,6 +203,6 @@ mbftoberep.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../
mbfmove.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbfmove.h
mbfdel.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbfmove.h
bounce.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/dbtic.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/dbftn.h sendmail.h postnetmail.h ping.h
createm.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h mgrutil.h createm.h
createm.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h mgrutil.h createm.h
createf.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h mgrutil.h createf.h
# End of generated dependencies

View File

@ -64,7 +64,7 @@ int Add_BBS()
* Create filedatabase record.
*/
memset(&frec, 0, sizeof(frec));
strcpy(temp1, TIC.NewName);
sprintf(temp1, "%s", TIC.NewName);
name_mangle(temp1);
strcpy(frec.Name, temp1);
strcpy(frec.LName, TIC.NewName);

View File

@ -349,7 +349,10 @@ int CheckTicGroup(char *Area, int SendUplink, faddr *f)
fclose(ap);
free(buf);
free(temp);
Syslog('+', "Auto created TIC area %s, group %s, bbs area %ld, for node %s",
if (f == NULL)
Syslog('+', "Auto created TIC area %s, group %s, bbs area %ld", tic.Name, tic.Group, AreaNr);
else
Syslog('+', "Auto created TIC area %s, group %s, bbs area %ld, for node %s",
tic.Name, tic.Group, AreaNr, ascfnode(f, 0x1f));
return 0;

View File

@ -34,6 +34,7 @@
#include "../lib/records.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "../lib/msg.h"
#include "mgrutil.h"
#include "createm.h"
@ -215,6 +216,9 @@ int CheckEchoGroup(char *Area, int SendUplink, faddr *f)
tag[i] = '/';
sprintf(msgs.Base, "%s/%s", mgroup.BasePath, tag);
fwrite(&msgs, sizeof(msgs), 1, mp);
mkdirs(msgs.Base, 0770);
if (Msg_Open(msgs.Base))
Msg_Close();
memset(&System, 0, sizeof(System));
System.aka = mgroup.UpLink;
@ -228,8 +232,11 @@ int CheckEchoGroup(char *Area, int SendUplink, faddr *f)
fclose(ap);
free(buf);
free(temp);
Syslog('+', "Auto created echo %s, group %s, area %ld, for node %s",
msgs.Tag, msgs.Group, offset, ascfnode(f , 0x1f));
if (f == NULL)
Syslog('+', "Auto created echo %s, group %s, area %ld", msgs.Tag, msgs.Group, offset);
else
Syslog('+', "Auto created echo %s, group %s, area %ld, for node %s",
msgs.Tag, msgs.Group, offset, ascfnode(f , 0x1f));
return 0;
} /* if (strcmp(tag, Area) == 0) */
} /* if (strlen(buf) && isalnum(buf[0])) */

View File

@ -60,6 +60,7 @@
#include "makestat.h"
#include "newspost.h"
#include "rnews.h"
#include "mgrutil.h"
#include "backalias.h"
#include "rfc2ftn.h"
@ -67,6 +68,7 @@
#define UNPACK_FACTOR 300
int do_areas = FALSE; /* Process area taglists */
int do_toss = FALSE; /* Toss flag */
int do_scan = FALSE; /* Scan flag */
int do_tic = FALSE; /* Process .tic files */
@ -116,6 +118,7 @@ void Help(void)
colour(9, 0);
printf(" Commands are:\n\n");
colour(3, 0);
printf(" a areas Process Areas taglists\n");
printf(" m mail <recipient> ... MTA Mail mode\n");
printf(" ne news Scan for new news\n");
printf(" no notify <nodes> Send notify messages\n");
@ -351,6 +354,8 @@ int main(int argc, char **argv)
}
if (strncmp(tl(argv[i]), "r", 1) == 0)
do_roll = TRUE;
else if (strncmp(tl(argv[i]), "a", 1) == 0)
do_areas = TRUE;
else if (strncmp(tl(argv[i]), "s", 1) == 0)
do_scan = TRUE;
else if (strncmp(tl(argv[i]), "ta", 2) == 0)
@ -529,6 +534,8 @@ int main(int argc, char **argv)
MakeStat();
if (do_uucp)
NewsUUCP();
if (do_areas)
Areas();
die(0);
return 0;
}

View File

@ -292,6 +292,7 @@ void DoMsgBase()
fflush(stdout);
}
are_tot++;
mkdirs(msgs.Base, 0770);
if (do_kill)
KillArea(msgs.Base, msgs.Name, msgs.DaysOld, msgs.MaxMsgs);
if (do_pack || msg_del)
@ -321,6 +322,7 @@ void DoMsgBase()
fflush(stdout);
}
are_tot++;
mkdirs(msgs.Base, 0770);
processed = FALSE;
if (do_kill)
KillArea(msgs.Base, msgs.Name, msgs.DaysOld, msgs.MaxMsgs);

View File

@ -39,12 +39,20 @@
#include "sendmail.h"
#include "rollover.h"
#include "addpkt.h"
#include "pack.h"
#include "createm.h"
#include "createf.h"
#include "mgrutil.h"
extern int net_out;
void tidy_arealist(AreaList **);
void fill_arealist(AreaList **, char *, int);
void MacroRead(FILE *fi, FILE *fp)
{
char *line, *temp;
@ -457,3 +465,196 @@ int MsgResult(const char * report, FILE *fo)
void tidy_arealist(AreaList **fdp)
{
AreaList *tmp, *old;
for (tmp = *fdp; tmp; tmp = old) {
old = tmp->next;
free(tmp);
}
*fdp = NULL;
}
void fill_arealist(AreaList **fdp, char *tag, int DoDelete)
{
AreaList **tmp;
for (tmp = fdp; *tmp; tmp = &((*tmp)->next));
*tmp = (AreaList *)malloc(sizeof(AreaList));
(*tmp)->next = NULL;
strcpy((*tmp)->Name, tag);
(*tmp)->IsPresent = FALSE;
(*tmp)->DoDelete = DoDelete;
}
int Areas(void)
{
FILE *gp, *ap, *fp;
char *temp, *buf, *tag;
AreaList *alist = NULL, *tmp;
int i, Found;
sysconnect System;
Syslog('+', "Process areas taglists");
temp = calloc(PATH_MAX, sizeof(char));
buf = calloc(4097, sizeof(char));
sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT"));
if ((gp = fopen(temp, "r")) == NULL) {
WriteError("Can't open %s", temp);
} else {
fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp);
fseek(gp, mgrouphdr.hdrsize, SEEK_SET);
while ((fread(&mgroup, mgrouphdr.recsize, 1, gp)) == 1) {
if (mgroup.Active && mgroup.AutoChange && strlen(mgroup.AreaFile)) {
Syslog('+', "Checking mail group %s, file %s", mgroup.Name, mgroup.AreaFile);
sprintf(temp, "%s/%s", CFG.alists_path, mgroup.AreaFile);
if ((ap = fopen(temp, "r")) == NULL) {
WriteError("Can't open %s", temp);
} else {
while (fgets(buf, 4096, ap)) {
if (strlen(buf) && isalnum(buf[0])) {
tag = strtok(buf, "\t \r\n\0");
fill_arealist(&alist, tag, FALSE);
}
}
fclose(ap);
/*
* Mark areas already present in the taglist.
*/
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r")) == NULL) {
WriteError("Can't open %s", temp);
tidy_arealist(&alist);
free(buf);
free(temp);
return FALSE;
}
fread(&msgshdr, sizeof(msgshdr), 1, fp);
for (tmp = alist; tmp; tmp = tmp->next) {
fseek(fp, msgshdr.hdrsize, SEEK_SET);
while (fread(&msgs, msgshdr.recsize, 1, fp) == 1) {
if (msgs.Active && !strcmp(msgs.Group, mgroup.Name) && !strcmp(msgs.Tag, tmp->Name))
tmp->IsPresent = TRUE;
fseek(fp, msgshdr.syssize, SEEK_CUR);
}
}
/*
* Add areas to AreaList not in the taglist, they must be deleted.
*/
fseek(fp, msgshdr.hdrsize, SEEK_SET);
while (fread(&msgs, msgshdr.recsize, 1, fp) == 1) {
if (msgs.Active && !strcmp(msgs.Group, mgroup.Name)) {
Found = FALSE;
for (tmp = alist; tmp; tmp = tmp->next) {
if (!strcmp(msgs.Tag, tmp->Name))
Found = TRUE;
}
if (!Found)
fill_arealist(&alist, msgs.Tag, TRUE);
}
fseek(fp, msgshdr.syssize, SEEK_CUR);
}
fclose(fp);
/*
* Debug logging
*/
// Syslog('m', "Area tag Oke Del");
// for (tmp = alist; tmp; tmp = tmp->next) {
// Syslog('m', "%-20s %s %s", tmp->Name, tmp->IsPresent?"Yes":"No ", tmp->DoDelete?"Yes":"No ");
// }
/*
* Make modification, first add missing areas
*/
for (tmp = alist; tmp; tmp = tmp->next) {
if (!tmp->IsPresent && !tmp->DoDelete)
CheckEchoGroup(tmp->Name, TRUE, NULL);
}
/*
* Now remove deleted areas
*/
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r+")) == NULL) {
WriteError("Can't open %s for r/w");
} else {
fread(&msgshdr, sizeof(msgshdr), 1, fp);
for (tmp = alist; tmp; tmp = tmp->next) {
if (!tmp->IsPresent && tmp->DoDelete) {
fseek(fp, msgshdr.hdrsize, SEEK_SET);
Syslog('m', "Delete %s", tmp->Name);
while (fread(&msgs, msgshdr.recsize, 1, fp) == 1) {
if (msgs.Active && !strcmp(msgs.Group, mgroup.Name) && !strcmp(msgs.Tag, tmp->Name)) {
fseek(fp, - msgshdr.recsize, SEEK_CUR);
Syslog('+', "Removing message area %d, %s",
((ftell(fp) - msgshdr.hdrsize) / (msgshdr.recsize + msgshdr.syssize)) + 1, msgs.Tag);
memset(&msgs, 0, sizeof(msgs));
msgs.DaysOld = CFG.defdays;
msgs.MaxMsgs = CFG.defmsgs;
msgs.Type = ECHOMAIL;
msgs.MsgKinds = PUBLIC;
msgs.UsrDelete = TRUE;
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.MaxArticles = CFG.maxarticles;
strcpy(msgs.Origin, CFG.origin);
memset(&System, 0, sizeof(System));
fwrite(&msgs, msgshdr.recsize, 1, fp);
for (i = 0; i < (msgshdr.syssize / sizeof(sysconnect)); i++)
fwrite(&System, sizeof(system), 1, fp);
break;
} else {
fseek(fp, msgshdr.syssize, SEEK_CUR);
}
}
}
}
}
tidy_arealist(&alist);
}
}
}
fclose(gp);
}
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
if ((gp = fopen(temp, "r")) == NULL) {
WriteError("Can't open %s", temp);
} else {
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
fseek(gp, fgrouphdr.hdrsize, SEEK_SET);
while ((fread(&fgroup, fgrouphdr.recsize, 1, gp)) == 1) {
if (fgroup.Active && fgroup.AutoChange && strlen(fgroup.AreaFile)) {
Syslog('+', "Checking tic group %s, file %s", fgroup.Name, fgroup.AreaFile);
Syslog('f', "Area tag Oke Del");
for (tmp = alist; tmp; tmp = tmp->next) {
Syslog('f', "%-20s %s %s", tmp->Name, tmp->IsPresent?"Yes":"No ", tmp->DoDelete?"Yes":"No ");
}
tidy_arealist(&alist);
}
}
fclose(gp);
}
free(buf);
free(temp);
packmail();
return TRUE;
}

View File

@ -4,6 +4,17 @@
#define _MGRUTIL_H
/*
* Linked list for atea areas create
*/
typedef struct _AreaList {
struct _AreaList *next;
char Name[51];
int IsPresent;
int DoDelete;
} AreaList;
void MacroRead(FILE *, FILE *);
int MsgResult(const char *, FILE * );
void GetRpSubject(const char *, char*);
@ -15,6 +26,8 @@ void ShiftBuf(char *, int);
void MgrPasswd(faddr *, char *, FILE *, int, int);
void MgrNotify(faddr *, char *, FILE *, int);
int UplinkRequest(faddr *, int, char *);
int Areas(void);
#endif

View File

@ -205,7 +205,7 @@ int LoadTic(char *inb, char *tfn)
Temp[255] = '\0';
}
// Syslog('f', "TIC: %s", Temp);
Syslog('f', "TIC: %s", Temp);
if (strncasecmp(Temp, "hatch", 5) == 0) {
TIC.TicIn.Hatch = TRUE;
@ -264,12 +264,11 @@ int LoadTic(char *inb, char *tfn)
TIC.Aka.net = atoi(strtok(NULL, "/"));
TIC.Aka.node = atoi(strtok(NULL, "\0"));
for (i = 0; i < 40; i++)
if ((CFG.akavalid[i]) &&
(CFG.aka[i].zone == TIC.Aka.zone) &&
(CFG.aka[i].net == TIC.Aka.net) &&
(CFG.aka[i].node == TIC.Aka.node) &&
(!CFG.aka[i].point))
if ((CFG.akavalid[i]) && (CFG.aka[i].zone == TIC.Aka.zone) && (CFG.aka[i].net == TIC.Aka.net) &&
(CFG.aka[i].node == TIC.Aka.node) && (!CFG.aka[i].point)) {
TIC.TicIn.PathError = TRUE;
Syslog('+', "Aka %d: %s in path", i + 1, aka2str(CFG.aka[i]));
}
} else if (strncasecmp(Temp, "seenby ", 7) == 0) {
fill_list(&sbl, Temp+7, NULL);

View File

@ -224,6 +224,8 @@ int AppendFGroup(void)
fgroup.VirScan = TRUE;
fgroup.Announce = TRUE;
fgroup.FileId = TRUE;
fgroup.DupCheck = TRUE;
fgroup.Replace = TRUE;
fwrite(&fgroup, sizeof(fgroup), 1, fil);
fclose(fil);
FGrpUpdated = 1;
@ -307,9 +309,9 @@ void FgScreen(void)
int EditFGrpRec(int Area)
{
FILE *fil;
char mfile[PATH_MAX];
char mfile[PATH_MAX], temp[13];
long offset;
int j, tmp;
int i, j, tmp;
unsigned long crc, crc1;
clr_index();
@ -399,7 +401,21 @@ int EditFGrpRec(int Area)
case 1: if (CheckFgroup())
break;
E_UPS( 6,16,12,fgroup.Name, "The ^name^ of this file group")
strcpy(fgroup.Name, edit_ups(6,16,12, fgroup.Name, (char *)"The ^name^ of this file group"));
if (strlen(mgroup.BasePath) == 0) {
memset(&temp, 0, sizeof(temp));
strcpy(temp, fgroup.Name);
for (i = 0; i < strlen(temp); i++) {
if (temp[i] == '.')
temp[i] = '/';
if (isupper(temp[i]))
temp[i] = tolower(temp[i]);
}
sprintf(fgroup.BasePath, "%s/%s", CFG.ftp_base, temp);
}
if (strlen(fgroup.BbsGroup) == 0)
strcpy(fgroup.BbsGroup, fgroup.Name);
break;
case 2: E_STR( 7,16,55,fgroup.Comment, "The ^description^ of this file group")
case 3: E_PTH( 8,16,64,fgroup.BasePath, "The ^base path^ for new created file areas")
case 4: tmp = PickAka((char *)"10.1.4", TRUE);

View File

@ -451,9 +451,9 @@ int EditConnections(FILE *fil)
if (System.aka.zone) {
set_color(CYAN,BLACK);
sprintf(temp, "%3d. %s %d:%d/%d.%d@%s", o+i, status,
System.aka.zone, System.aka.net, System.aka.node,
System.aka.point, System.aka.domain);
sprintf(temp, "%3d. %s %s", o+i, status, aka2str(System.aka));
// System.aka.zone, System.aka.net, System.aka.node,
// System.aka.point, System.aka.domain);
} else {
set_color(LIGHTBLUE, BLACK);
sprintf(temp, "%3d.", o+i);
@ -1290,7 +1290,7 @@ void EditMsgarea(void)
fread(&msgs, msgshdr.recsize, 1, fil);
if (msgs.Active) {
set_color(CYAN, BLACK);
sprintf(temp, "%3d. %-8s %-25s %-40s", o + i, getmsgtype(msgs.Type), msgs.Tag, msgs.Name);
sprintf(temp, "%3d. %-8s %-23s %-40s", o + i, getmsgtype(msgs.Type), msgs.Tag, msgs.Name);
} else {
set_color(LIGHTBLUE, BLACK);
sprintf(temp, "%3d.", o+i);