Changed AreaMgr and FileMgr code

This commit is contained in:
Michiel Broek 2002-02-11 21:49:10 +00:00
parent 11d712c572
commit 465b620050
3 changed files with 1456 additions and 1479 deletions

View File

@ -4585,7 +4585,8 @@ v0.33.19 26-Oct-2001
v0.33.20 10-Feb-2002
upgrade:
Compile sources and install binaries. Restart the BBS.
Enter mbsetup, this will upgrade the databases.
general:
Added structures for area maintenance with area lists.
@ -4595,3 +4596,11 @@ v0.33.20 10-Feb-2002
Added 2 functions to return the OS name and CPU family.
Added a function to return the right tearline.
mbsetup:
In message groups added default settings for auto area
creation.
mbfido:
In AreaMgr and FileMgr changed aka matching for area
connections. Code cleanups.

View File

@ -140,7 +140,7 @@ void A_Query(faddr *t, char *replyid)
char *temp, *Group;
int i, First = TRUE, SubTot, Total = 0, Cons;
char Stat[5];
faddr *f;
faddr *f, *g;
sysconnect System;
Syslog('+', "AreaMgr: Query");
@ -148,7 +148,7 @@ void A_Query(faddr *t, char *replyid)
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"Your query request", replyid)) != NULL) {
temp = calloc(128, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
mp = fopen(temp, "r");
@ -168,13 +168,12 @@ void A_Query(faddr *t, char *replyid)
fseek(gp, mgrouphdr.hdrsize, SEEK_SET);
while (fread(&mgroup, mgrouphdr.recsize, 1, gp) == 1) {
g = bestaka_s(fido2faddr(mgroup.UseAka));
if ((!strcmp(mgroup.Name, Group)) &&
(mgroup.UseAka.zone == f->zone) &&
(mgroup.UseAka.net == f->net) &&
(mgroup.UseAka.node == f->node) &&
(mgroup.UseAka.point == f->point)) {
(g->zone == f->zone) && (g->net == f->net) &&
(g->node == f->node) && (g->point == f->point)) {
SubTot = 0;
fprintf(qp, "Group %s - %s\r\r", mgroup.Name, mgroup.Comment);
fprintf(qp, "Group %s - %s (%s)\r\r", mgroup.Name, mgroup.Comment, aka2str(mgroup.UseAka));
fprintf(qp, "Con Message area Description\r");
fprintf(qp, "----------------------------------------------------------------------------\r");
fseek(mp, msgshdr.hdrsize, SEEK_SET);
@ -185,15 +184,12 @@ void A_Query(faddr *t, char *replyid)
Stat[sizeof(Stat)-1] = '\0';
/*
* Now check if this node is connected,
* if so, set the Stat bits
* Now check if this node is connected, if so, set the Stat bits
*/
for (i = 0; i < Cons; i++) {
fread(&System, sizeof(System), 1, mp);
if ((t->zone == System.aka.zone) &&
(t->net == System.aka.net) &&
(t->node == System.aka.node) &&
(t->point == System.aka.point)) {
if ((t->zone == System.aka.zone) && (t->net == System.aka.net) &&
(t->node == System.aka.node) && (t->point == System.aka.point)) {
if (System.receivefrom)
Stat[0] = 'S';
if (System.sendto)
@ -246,7 +242,7 @@ void A_List(faddr *t, char *replyid, int Notify)
char *temp, *Group;
int i, First = TRUE, SubTot, Total = 0, Cons;
char Stat[5];
faddr *f;
faddr *f, *g;
sysconnect System;
if (Notify)
@ -258,7 +254,7 @@ void A_List(faddr *t, char *replyid, int Notify)
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"AreaMgr List", replyid)) != NULL) {
WriteMailGroups(qp, f);
temp = calloc(128, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
mp = fopen(temp, "r");
@ -278,13 +274,12 @@ void A_List(faddr *t, char *replyid, int Notify)
fseek(gp, mgrouphdr.hdrsize, SEEK_SET);
while (fread(&mgroup, mgrouphdr.recsize, 1, gp) == 1) {
g = bestaka_s(fido2faddr(mgroup.UseAka));
if ((!strcmp(mgroup.Name, Group)) &&
(mgroup.UseAka.zone == f->zone) &&
(mgroup.UseAka.net == f->net) &&
(mgroup.UseAka.node == f->node) &&
(mgroup.UseAka.point == f->point)) {
(g->zone == f->zone) && (g->net == f->net) &&
(g->node == f->node) && (g->point == f->point)) {
SubTot = 0;
fprintf(qp, "Group %s - %s\r\r", mgroup.Name, mgroup.Comment);
fprintf(qp, "Group %s - %s (%s)\r\r", mgroup.Name, mgroup.Comment, aka2str(mgroup.UseAka));
fprintf(qp, "Con Message area Description\r");
fprintf(qp, "----------------------------------------------------------------------------\r");
fseek(mp, msgshdr.hdrsize, SEEK_SET);
@ -295,15 +290,12 @@ void A_List(faddr *t, char *replyid, int Notify)
Stat[sizeof(Stat)-1] = '\0';
/*
* Now check if this node is connected,
* if so, set the Stat bits
* Now check if this node is connected, if so, set the Stat bits
*/
for (i = 0; i < Cons; i++) {
fread(&System, sizeof(System), 1, mp);
if ((t->zone == System.aka.zone) &&
(t->net == System.aka.net) &&
(t->node == System.aka.node) &&
(t->point == System.aka.point)) {
if ((t->zone == System.aka.zone) && (t->net == System.aka.net) &&
(t->node == System.aka.node) && (t->point == System.aka.point)) {
if (System.receivefrom)
Stat[0] = 'S';
if (System.sendto)
@ -353,7 +345,7 @@ void A_Flow(faddr *t, char *replyid, int Notify)
char *temp, *Group;
int i, First = TRUE, Cons;
char Stat[2];
faddr *f;
faddr *f, *g;
sysconnect System;
time_t Now;
struct tm *tt;
@ -376,7 +368,7 @@ void A_Flow(faddr *t, char *replyid, int Notify)
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"AreaMgr Flow report", replyid)) != NULL) {
temp = calloc(128, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
mp = fopen(temp, "r");
@ -397,11 +389,10 @@ void A_Flow(faddr *t, char *replyid, int Notify)
lm = lw = 0;
fseek(gp, mgrouphdr.hdrsize, SEEK_SET);
while (fread(&mgroup, mgrouphdr.recsize, 1, gp) == 1) {
g = bestaka_s(fido2faddr(mgroup.UseAka));
if ((!strcmp(mgroup.Name, Group)) &&
(mgroup.UseAka.zone == f->zone) &&
(mgroup.UseAka.net == f->net) &&
(mgroup.UseAka.node == f->node) &&
(mgroup.UseAka.point == f->point)) {
(g->zone == f->zone) && (g->net == f->net) &&
(g->node == f->node) && (g->point == f->point)) {
fprintf(qp, "Group %s - %s\r\r", mgroup.Name, mgroup.Comment);
// 1 2 3 4 5 6 7
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890
@ -415,24 +406,18 @@ void A_Flow(faddr *t, char *replyid, int Notify)
Stat[sizeof(Stat)-1] = '\0';
/*
* Now check if this node is connected,
* if so, set the Stat bits
* Now check if this node is connected, if so, set the Stat bits
*/
for (i = 0; i < Cons; i++) {
fread(&System, sizeof(System), 1, mp);
if ((t->zone == System.aka.zone) &&
(t->net == System.aka.net) &&
(t->node == System.aka.node) &&
(t->point == System.aka.point)) {
if ((System.receivefrom || System.sendto) &&
(!System.pause) && (!System.cutoff))
if ((t->zone == System.aka.zone) && (t->net == System.aka.net) &&
(t->node == System.aka.node) && (t->point == System.aka.point)) {
if ((System.receivefrom || System.sendto) && (!System.pause) && (!System.cutoff))
Stat[0] = 'C';
}
}
fprintf(qp, "%s %s %9lu %10lu\r",
Stat, padleft(msgs.Tag, 50, ' '),
msgs.Received.lweek,
msgs.Received.month[lmonth]);
fprintf(qp, "%s %s %9lu %10lu\r", Stat, padleft(msgs.Tag, 50, ' '),
msgs.Received.lweek, msgs.Received.month[lmonth]);
lm += msgs.Received.month[lmonth];
lw += msgs.Received.lweek;
} else
@ -508,7 +493,7 @@ void A_Unlinked(faddr *t, char *replyid)
char *temp, *Group;
int i, First = TRUE, SubTot, Total = 0, Cons;
char Stat[5];
faddr *f;
faddr *f, *g;
sysconnect System;
Syslog('+', "AreaMgr: Unlinked");
@ -537,11 +522,12 @@ void A_Unlinked(faddr *t, char *replyid)
fseek(gp, mgrouphdr.hdrsize, SEEK_SET);
while (fread(&mgroup, mgrouphdr.recsize, 1, gp) == 1) {
g = bestaka_s(fido2faddr(mgroup.UseAka));
if ((!strcmp(mgroup.Name, Group)) &&
(mgroup.UseAka.zone == f->zone) &&
(mgroup.UseAka.net == f->net) &&
(mgroup.UseAka.node == f->node) &&
(mgroup.UseAka.point == f->point)) {
(g->zone == f->zone) &&
(g->net == f->net) &&
(g->node == f->node) &&
(g->point == f->point)) {
SubTot = 0;
fprintf(qp, "Group %s - %s\r\r", mgroup.Name, mgroup.Comment);
fprintf(qp, "Con Message area Description\r");
@ -554,15 +540,12 @@ void A_Unlinked(faddr *t, char *replyid)
Stat[sizeof(Stat)-1] = '\0';
/*
* Now check if this node is connected,
* if so, set the Stat bits
* Now check if this node is connected, if so, set the Stat bits
*/
for (i = 0; i < Cons; i++) {
fread(&System, sizeof(System), 1, mp);
if ((t->zone == System.aka.zone) &&
(t->net == System.aka.net) &&
(t->node == System.aka.node) &&
(t->point == System.aka.point)) {
if ((t->zone == System.aka.zone) && (t->net == System.aka.net) &&
(t->node == System.aka.node) && (t->point == System.aka.point)) {
if (System.receivefrom)
Stat[0] = 'S';
if (System.sendto)
@ -809,14 +792,12 @@ void A_All(faddr *t, int Connect, FILE *tmp, char *Grp)
fseek(gp, mgrouphdr.hdrsize, SEEK_SET);
while (fread(&mgroup, mgrouphdr.recsize, 1, gp) == 1) {
if ((!strcmp(mgroup.Name, Group)) &&
((Grp == NULL) || (!strcmp(Group, Grp)))) {
if ((!strcmp(mgroup.Name, Group)) && ((Grp == NULL) || (!strcmp(Group, Grp)))) {
fseek(mp, msgshdr.hdrsize, SEEK_SET);
while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) {
if ((!strcmp(Group, msgs.Group)) &&
(msgs.Active) && (!msgs.Mandatory) &&
if ((!strcmp(Group, msgs.Group)) && (msgs.Active) && (!msgs.Mandatory) &&
(metric(fido2faddr(mgroup.UseAka), f) == METRIC_EQUAL)) {
if (Connect) {
@ -849,8 +830,7 @@ void A_All(faddr *t, int Connect, FILE *tmp, char *Grp)
} else {
for (i = 0; i < Cons; i++) {
fread(&Sys, sizeof(Sys), 1, mp);
if ((metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL) &&
(!Sys.cutoff)) {
if ((metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL) && (!Sys.cutoff)) {
memset(&Sys, 0, sizeof(Sys));
fseek(mp, - sizeof(Sys), SEEK_CUR);
fwrite(&Sys, sizeof(Sys), 1, mp);
@ -908,18 +888,18 @@ void A_Rescan(faddr *t, char *Area, FILE *tmp)
*/
ShiftBuf(Area, 7);
CleanBuf(Area);
for (i=0; i < strlen(Area); i++ )
Area[i]=toupper(Area[i]);
for (i = 0; i < strlen(Area); i++ )
Area[i] = toupper(Area[i]);
Syslog('+', "AreaMgr: Rescan %s, MSGS=%lu", Area, a_msgs);
result=RescanOne(t, Area, a_msgs);
if (result==0){
if (a_msgs>0)
result = RescanOne(t, Area, a_msgs);
if (result == 0){
if (a_msgs > 0)
fprintf(tmp, "Rescan area %s, %lu last msgs.\n", Area, a_msgs);
else
fprintf(tmp, "Rescan area %s \n", Area);
} else if (result==1)
} else if (result == 1)
fprintf(tmp, "Can't rescan unknown area %s\n", Area);
else if (result==2)
else if (result == 2)
fprintf(tmp, "%s can't rescan area %s\n", ascfnode(t, 0x1f), Area);
else
fprintf(tmp, "Fatal Error Rescanning area %s\n", Area);

View File

@ -139,15 +139,16 @@ void F_Query(faddr *t, char *replyid)
char *temp, *Group;
int i, First = TRUE, SubTot, Total = 0, Cons;
char Stat[4];
faddr *f;
faddr *f, *g;
sysconnect System;
Syslog('+', "FileMgr: Query");
f = bestaka_s(t);
Syslog('f', "Bestaka for %s is %s", ascfnode(t, 0x0f), ascfnode(f, 0x0f));
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"Your query request", replyid)) != NULL) {
temp = calloc(128, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
fp = fopen(temp, "r");
@ -167,13 +168,13 @@ void F_Query(faddr *t, char *replyid)
fseek(gp, fgrouphdr.hdrsize, SEEK_SET);
while (fread(&fgroup, fgrouphdr.recsize, 1, gp) == 1) {
g = bestaka_s(fido2faddr(fgroup.UseAka));
if ((!strcmp(fgroup.Name, Group)) &&
(fgroup.UseAka.zone == f->zone) &&
(fgroup.UseAka.net == f->net) &&
(fgroup.UseAka.node == f->node) &&
(fgroup.UseAka.point == f->point)) {
(g->zone == f->zone) && (g->net == f->net) &&
(g->node == f->node) && (g->point == f->point)) {
Syslog('f', "Group %s, aka %s", fgroup.Name, aka2str(fgroup.UseAka));
SubTot = 0;
fprintf(qp, "Group %s - %s\r\r", fgroup.Name, fgroup.Comment);
fprintf(qp, "Group %s - %s (%s)\r\r", fgroup.Name, fgroup.Comment, aka2str(fgroup.UseAka));
fprintf(qp, "Con File tic Description\r");
fprintf(qp, "------------------------------------------------------------------------\r");
fseek(fp, tichdr.hdrsize, SEEK_SET);
@ -189,10 +190,8 @@ void F_Query(faddr *t, char *replyid)
*/
for (i = 0; i < Cons; i++) {
fread(&System, sizeof(System), 1, fp);
if ((t->zone == System.aka.zone) &&
(t->net == System.aka.net) &&
(t->node == System.aka.node) &&
(t->point == System.aka.point)) {
if ((t->zone == System.aka.zone) && (t->net == System.aka.net) &&
(t->node == System.aka.node) && (t->point == System.aka.point)) {
if (System.receivefrom)
Stat[0] = 'S';
if (System.sendto)
@ -241,7 +240,7 @@ void F_List(faddr *t, char *replyid, int Notify)
char *temp, *Group;
int i, First = TRUE, SubTot, Total = 0, Cons;
char Stat[4];
faddr *f;
faddr *f, *g;
sysconnect System;
if (Notify)
@ -253,7 +252,7 @@ void F_List(faddr *t, char *replyid, int Notify)
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"FileMgr List", replyid)) != NULL) {
WriteFileGroups(qp, f);
temp = calloc(128, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
fp = fopen(temp, "r");
@ -273,13 +272,12 @@ void F_List(faddr *t, char *replyid, int Notify)
fseek(gp, fgrouphdr.hdrsize, SEEK_SET);
while (fread(&fgroup, fgrouphdr.recsize, 1, gp) == 1) {
g = bestaka_s(fido2faddr(fgroup.UseAka));
if ((!strcmp(fgroup.Name, Group)) &&
(fgroup.UseAka.zone == f->zone) &&
(fgroup.UseAka.net == f->net) &&
(fgroup.UseAka.node == f->node) &&
(fgroup.UseAka.point == f->point)) {
(g->zone == f->zone) && (g->net == f->net) &&
(g->node == f->node) && (g->point == f->point)) {
SubTot = 0;
fprintf(qp, "Group %s - %s\r\r", fgroup.Name, fgroup.Comment);
fprintf(qp, "Group %s - %s (%s)\r\r", fgroup.Name, fgroup.Comment, aka2str(fgroup.UseAka));
fprintf(qp, "Con File tic Description\r");
fprintf(qp, "------------------------------------------------------------------------\r");
fseek(fp, tichdr.hdrsize, SEEK_SET);
@ -290,15 +288,12 @@ void F_List(faddr *t, char *replyid, int Notify)
Stat[sizeof(Stat)-1] = '\0';
/*
* Now check if this node is connected,
* if so, set the Stat bits.
* Now check if this node is connected, if so, set the Stat bits.
*/
for (i = 0; i < Cons; i++) {
fread(&System, sizeof(System), 1, fp);
if ((t->zone == System.aka.zone) &&
(t->net == System.aka.net) &&
(t->node == System.aka.node) &&
(t->point == System.aka.point)) {
if ((t->zone == System.aka.zone) && (t->net == System.aka.net) &&
(t->node == System.aka.node) && (t->point == System.aka.point)) {
if (System.receivefrom)
Stat[0] = 'S';
if (System.sendto)
@ -394,7 +389,7 @@ void F_Unlinked(faddr *t, char *replyid)
char *temp, *Group;
int i, First = TRUE, SubTot, Total = 0, Cons;
char Stat[4];
faddr *f;
faddr *f, *g;
sysconnect System;
Syslog('+', "FileMgr: Unlinked");
@ -402,7 +397,7 @@ void F_Unlinked(faddr *t, char *replyid)
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"Your unlinked request", replyid)) != NULL) {
temp = calloc(128, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
fp = fopen(temp, "r");
@ -422,13 +417,12 @@ void F_Unlinked(faddr *t, char *replyid)
fseek(gp, fgrouphdr.hdrsize, SEEK_SET);
while (fread(&fgroup, fgrouphdr.recsize, 1, gp) == 1) {
g = bestaka_s(fido2faddr(fgroup.UseAka));
if ((!strcmp(fgroup.Name, Group)) &&
(fgroup.UseAka.zone == f->zone) &&
(fgroup.UseAka.net == f->net) &&
(fgroup.UseAka.node == f->node) &&
(fgroup.UseAka.point == f->point)) {
(g->zone == f->zone) && (g->net == f->net) &&
(g->node == f->node) && (g->point == f->point)) {
SubTot = 0;
fprintf(qp, "Group %s - %s\r\r", fgroup.Name, fgroup.Comment);
fprintf(qp, "Group %s - %s (%s)\r\r", fgroup.Name, fgroup.Comment, aka2str(fgroup.UseAka));
fprintf(qp, "Con File tic Description\r");
fprintf(qp, "------------------------------------------------------------------------\r");
fseek(fp, tichdr.hdrsize, SEEK_SET);
@ -439,15 +433,12 @@ void F_Unlinked(faddr *t, char *replyid)
Stat[sizeof(Stat)-1] = '\0';
/*
* Now check if this node is connected,
* if so, set the Stat bits.
* Now check if this node is connected, if so, set the Stat bits.
*/
for (i = 0; i < Cons; i++) {
fread(&System, sizeof(System), 1, fp);
if ((t->zone == System.aka.zone) &&
(t->net == System.aka.net) &&
(t->node == System.aka.node) &&
(t->point == System.aka.point)) {
if ((t->zone == System.aka.zone) && (t->net == System.aka.net) &&
(t->node == System.aka.node) && (t->point == System.aka.point)) {
if (System.receivefrom)
Stat[0] = 'S';
if (System.sendto)
@ -649,7 +640,7 @@ void F_All(faddr *, int, FILE *, char *);
void F_All(faddr *t, int Connect, FILE *tmp, char *Grp)
{
FILE *fp, *gp;
char *Group, temp[81];
char *Group, temp[PATH_MAX];
faddr *f;
int i, Link, First = TRUE, Cons;
sysconnect Sys;
@ -684,15 +675,12 @@ void F_All(faddr *t, int Connect, FILE *tmp, char *Grp)
fseek(gp, fgrouphdr.hdrsize, SEEK_SET);
while (fread(&fgroup, fgrouphdr.recsize, 1, gp) == 1) {
if ((!strcmp(fgroup.Name, Group)) &&
((Grp == NULL) || (!strcmp(Group, Grp)))) {
if ((!strcmp(fgroup.Name, Group)) && ((Grp == NULL) || (!strcmp(Group, Grp)))) {
fseek(fp, tichdr.hdrsize, SEEK_SET);
while (fread(&tic, tichdr.recsize, 1, fp) == 1) {
if ((!strcmp(Group, tic.Group)) && tic.Active &&
(metric(fido2faddr(fgroup.UseAka), f) == METRIC_EQUAL)) {
if ((!strcmp(Group, tic.Group)) && tic.Active && (metric(fido2faddr(fgroup.UseAka), f) == METRIC_EQUAL)) {
if (Connect) {
Link = FALSE;