From 465b6200508b94569c60ce841ae73e37561397f5 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Mon, 11 Feb 2002 21:49:10 +0000 Subject: [PATCH] Changed AreaMgr and FileMgr code --- ChangeLog | 11 +- mbfido/areamgr.c | 1568 +++++++++++++++++++++++----------------------- mbfido/filemgr.c | 1356 ++++++++++++++++++++------------------- 3 files changed, 1456 insertions(+), 1479 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea21a95d..3ba2a519 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. + diff --git a/mbfido/areamgr.c b/mbfido/areamgr.c index b26e7c93..be0d0308 100644 --- a/mbfido/areamgr.c +++ b/mbfido/areamgr.c @@ -82,53 +82,53 @@ unsigned long a_msgs = 0; void A_Help(faddr *, char *); void A_Help(faddr *t, char *replyid) { - FILE *fp; + FILE *fp; - Syslog('+', "AreaMgr: Help"); + Syslog('+', "AreaMgr: Help"); - if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"AreaMgr help", replyid)) != NULL) { - fprintf(fp, "Address all requests to '%s' (without quotes)\r", (char *)"Areamgr"); - fprintf(fp, "Youre AreaMgr password goes on the subject line.\r\r"); + if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"AreaMgr help", replyid)) != NULL) { + fprintf(fp, "Address all requests to '%s' (without quotes)\r", (char *)"Areamgr"); + fprintf(fp, "Youre AreaMgr password goes on the subject line.\r\r"); - fprintf(fp, "In the body of the message to AreaMgr:\r\r"); + fprintf(fp, "In the body of the message to AreaMgr:\r\r"); - fprintf(fp, "+ To connect to an echomail area\r"); - fprintf(fp, "- To disconnect from an echomail area\r"); - fprintf(fp, "%%+ALL To connect to all echomail areas\r"); - fprintf(fp, "%%-ALL To disconnect from all echomail areas\r"); - fprintf(fp, "%%+ To connect all echomail areas of a group\r"); - fprintf(fp, "%%- To disconnect from all echomail areas of a group\r"); - fprintf(fp, "%%HELP To request this help message\r"); - fprintf(fp, "%%LIST To request a list of echomail areas available to you\r"); - fprintf(fp, "%%QUERY To request a list of echomail areas for which you are active\r"); - fprintf(fp, "%%UNLINKED To request a list of echomail areas available to you\r"); - fprintf(fp, " to which you are not already connected\r"); - fprintf(fp, "%%FLOW To request a flow report of available areas\r"); - fprintf(fp, "%%STATUS To request a status report for your system\r"); -// fprintf(fp, "%%PAUSE To temporary disconnect from the connected echomail areas\r"); -// fprintf(fp, "%%RESUME To reconnect the temporary disconnected echomail areas\r"); - fprintf(fp, "%%PWD=newpwd To set a new AreaMgr and FileMgr password\r"); - fprintf(fp, "%%MSGS To set max. number of messages to be rescanned\r"); - fprintf(fp, "%%RESCAN To request messages from 'area' again\r"); - fprintf(fp, "%%NOTIFY=On/Off To switch the notify function on or off\r"); - fprintf(fp, "[---] Everything below the tearline is ignored\r\r"); + fprintf(fp, "+ To connect to an echomail area\r"); + fprintf(fp, "- To disconnect from an echomail area\r"); + fprintf(fp, "%%+ALL To connect to all echomail areas\r"); + fprintf(fp, "%%-ALL To disconnect from all echomail areas\r"); + fprintf(fp, "%%+ To connect all echomail areas of a group\r"); + fprintf(fp, "%%- To disconnect from all echomail areas of a group\r"); + fprintf(fp, "%%HELP To request this help message\r"); + fprintf(fp, "%%LIST To request a list of echomail areas available to you\r"); + fprintf(fp, "%%QUERY To request a list of echomail areas for which you are active\r"); + fprintf(fp, "%%UNLINKED To request a list of echomail areas available to you\r"); + fprintf(fp, " to which you are not already connected\r"); + fprintf(fp, "%%FLOW To request a flow report of available areas\r"); + fprintf(fp, "%%STATUS To request a status report for your system\r"); +// fprintf(fp, "%%PAUSE To temporary disconnect from the connected echomail areas\r"); +// fprintf(fp, "%%RESUME To reconnect the temporary disconnected echomail areas\r"); + fprintf(fp, "%%PWD=newpwd To set a new AreaMgr and FileMgr password\r"); + fprintf(fp, "%%MSGS To set max. number of messages to be rescanned\r"); + fprintf(fp, "%%RESCAN To request messages from 'area' again\r"); + fprintf(fp, "%%NOTIFY=On/Off To switch the notify function on or off\r"); + fprintf(fp, "[---] Everything below the tearline is ignored\r\r"); - fprintf(fp, "Example:\r\r"); + fprintf(fp, "Example:\r\r"); - fprintf(fp, " By: %s\r", nodes.Sysop); - fprintf(fp, " To: %s, %s\r", (char *)"Areamgr", ascfnode(bestaka_s(t), 0xf)); - fprintf(fp, " Re: %s\r", nodes.Apasswd); - fprintf(fp, " St: Pvt Local Kill\r"); - fprintf(fp, " ----------------------------------------------------------\r"); - fprintf(fp, " +SYSOPS\r"); - fprintf(fp, " -GENERAL\r"); - fprintf(fp, " %%QUERY\r"); - fprintf(fp, " %%LIST\r\r"); - fprintf(fp, "%s\r", TearLine()); - CloseMail(fp, t); - net_out++; - } else - WriteError("Can't create netmail"); + fprintf(fp, " By: %s\r", nodes.Sysop); + fprintf(fp, " To: %s, %s\r", (char *)"Areamgr", ascfnode(bestaka_s(t), 0xf)); + fprintf(fp, " Re: %s\r", nodes.Apasswd); + fprintf(fp, " St: Pvt Local Kill\r"); + fprintf(fp, " ----------------------------------------------------------\r"); + fprintf(fp, " +SYSOPS\r"); + fprintf(fp, " -GENERAL\r"); + fprintf(fp, " %%QUERY\r"); + fprintf(fp, " %%LIST\r\r"); + fprintf(fp, "%s\r", TearLine()); + CloseMail(fp, t); + net_out++; + } else + WriteError("Can't create netmail"); } @@ -136,327 +136,312 @@ void A_Help(faddr *t, char *replyid) void A_Query(faddr *, char *); void A_Query(faddr *t, char *replyid) { - FILE *qp, *gp, *mp; - char *temp, *Group; - int i, First = TRUE, SubTot, Total = 0, Cons; - char Stat[5]; - faddr *f; - sysconnect System; + FILE *qp, *gp, *mp; + char *temp, *Group; + int i, First = TRUE, SubTot, Total = 0, Cons; + char Stat[5]; + faddr *f, *g; + sysconnect System; - Syslog('+', "AreaMgr: Query"); - f = bestaka_s(t); + Syslog('+', "AreaMgr: Query"); + f = bestaka_s(t); - if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"Your query request", replyid)) != NULL) { + 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"); - fread(&msgshdr, sizeof(msgshdr), 1, mp); - Cons = msgshdr.syssize / sizeof(System); - sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); - gp = fopen(temp, "r"); - fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp); + sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + mp = fopen(temp, "r"); + fread(&msgshdr, sizeof(msgshdr), 1, mp); + Cons = msgshdr.syssize / sizeof(System); + sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); + gp = fopen(temp, "r"); + fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp); - fprintf(qp, "The following is a list of all connected message areas\r\r"); + fprintf(qp, "The following is a list of all connected message areas\r\r"); - while (TRUE) { - Group = GetNodeMailGrp(First); - if (Group == NULL) - break; - First = FALSE; + while (TRUE) { + Group = GetNodeMailGrp(First); + if (Group == NULL) + break; + First = FALSE; - fseek(gp, mgrouphdr.hdrsize, SEEK_SET); - while (fread(&mgroup, mgrouphdr.recsize, 1, gp) == 1) { - 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)) { - SubTot = 0; - fprintf(qp, "Group %s - %s\r\r", mgroup.Name, mgroup.Comment); - fprintf(qp, "Con Message area Description\r"); - fprintf(qp, "----------------------------------------------------------------------------\r"); - fseek(mp, msgshdr.hdrsize, SEEK_SET); + 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)) && + (g->zone == f->zone) && (g->net == f->net) && + (g->node == f->node) && (g->point == f->point)) { + SubTot = 0; + 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); - while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) { - if (!strcmp(Group, msgs.Group) && msgs.Active) { - memset(&Stat, ' ', sizeof(Stat)); - Stat[sizeof(Stat)-1] = '\0'; + while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) { + if (!strcmp(Group, msgs.Group) && msgs.Active) { + memset(&Stat, ' ', sizeof(Stat)); + Stat[sizeof(Stat)-1] = '\0'; - /* - * 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) - Stat[0] = 'S'; - if (System.sendto) - Stat[1] = 'R'; - if (System.pause) - Stat[2] = 'P'; - if (System.cutoff) - Stat[3] = 'C'; - } - } - - if (Stat[0] == 'S' || Stat[1] == 'R') { - fprintf(qp, "%s %-25s %s\r", Stat, msgs.Tag, msgs.Name); - SubTot++; - Total++; - } - } else - fseek(mp, msgshdr.syssize, SEEK_CUR); - } - - fprintf(qp, "----------------------------------------------------------------------------\r"); - fprintf(qp, "%d connected area(s)\r\r\r", SubTot); + /* + * 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) + Stat[0] = 'S'; + if (System.sendto) + Stat[1] = 'R'; + if (System.pause) + Stat[2] = 'P'; + if (System.cutoff) + Stat[3] = 'C'; } - } + } + + if (Stat[0] == 'S' || Stat[1] == 'R') { + fprintf(qp, "%s %-25s %s\r", Stat, msgs.Tag, msgs.Name); + SubTot++; + Total++; + } + } else + fseek(mp, msgshdr.syssize, SEEK_CUR); + } + + fprintf(qp, "----------------------------------------------------------------------------\r"); + fprintf(qp, "%d connected area(s)\r\r\r", SubTot); } - fprintf(qp, "Total: %d connected area(s)\r\r\r", Total); + } + } + fprintf(qp, "Total: %d connected area(s)\r\r\r", Total); - fclose(mp); - fclose(gp); + fclose(mp); + fclose(gp); - fprintf(qp, "Con means:\r"); - fprintf(qp, " R - You receive mail from my system\r"); - fprintf(qp, " S - You may send mail to my system\r"); - fprintf(qp, " P - The message area is temporary paused\r"); - fprintf(qp, " C - You are cutoff from this area\r\r"); - fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "%s\r", TearLine()); - CloseMail(qp, t); - net_out++; - free(temp); - } else - WriteError("Can't create netmail"); + fprintf(qp, "Con means:\r"); + fprintf(qp, " R - You receive mail from my system\r"); + fprintf(qp, " S - You may send mail to my system\r"); + fprintf(qp, " P - The message area is temporary paused\r"); + fprintf(qp, " C - You are cutoff from this area\r\r"); + fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); + fprintf(qp, "%s\r", TearLine()); + CloseMail(qp, t); + net_out++; + free(temp); + } else + WriteError("Can't create netmail"); } void A_List(faddr *t, char *replyid, int Notify) { - FILE *qp, *gp, *mp; - char *temp, *Group; - int i, First = TRUE, SubTot, Total = 0, Cons; - char Stat[5]; - faddr *f; - sysconnect System; + FILE *qp, *gp, *mp; + char *temp, *Group; + int i, First = TRUE, SubTot, Total = 0, Cons; + char Stat[5]; + faddr *f, *g; + sysconnect System; - if (Notify) - Syslog('+', "AreaMgr: Notify to %s", ascfnode(t, 0xff)); - else - Syslog('+', "AreaMgr: List"); - f = bestaka_s(t); + if (Notify) + Syslog('+', "AreaMgr: Notify to %s", ascfnode(t, 0xff)); + else + Syslog('+', "AreaMgr: List"); + f = bestaka_s(t); - if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"AreaMgr List", replyid)) != NULL) { + if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"AreaMgr List", replyid)) != NULL) { - WriteMailGroups(qp, f); - temp = calloc(128, sizeof(char)); + WriteMailGroups(qp, f); + temp = calloc(PATH_MAX, sizeof(char)); - sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); - mp = fopen(temp, "r"); - fread(&msgshdr, sizeof(msgshdr), 1, mp); - Cons = msgshdr.syssize / sizeof(System); - sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); - gp = fopen(temp, "r"); - fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp); + sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + mp = fopen(temp, "r"); + fread(&msgshdr, sizeof(msgshdr), 1, mp); + Cons = msgshdr.syssize / sizeof(System); + sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); + gp = fopen(temp, "r"); + fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp); - fprintf(qp, "The following is a list of all message areas\r\r"); + fprintf(qp, "The following is a list of all message areas\r\r"); - while (TRUE) { - Group = GetNodeMailGrp(First); - if (Group == NULL) - break; - First = FALSE; + while (TRUE) { + Group = GetNodeMailGrp(First); + if (Group == NULL) + break; + First = FALSE; - fseek(gp, mgrouphdr.hdrsize, SEEK_SET); - while (fread(&mgroup, mgrouphdr.recsize, 1, gp) == 1) { - 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)) { - SubTot = 0; - fprintf(qp, "Group %s - %s\r\r", mgroup.Name, mgroup.Comment); - fprintf(qp, "Con Message area Description\r"); - fprintf(qp, "----------------------------------------------------------------------------\r"); - fseek(mp, msgshdr.hdrsize, SEEK_SET); + 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)) && + (g->zone == f->zone) && (g->net == f->net) && + (g->node == f->node) && (g->point == f->point)) { + SubTot = 0; + 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); - while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) { - if (!strcmp(Group, msgs.Group) && msgs.Active) { - memset(&Stat, ' ', sizeof(Stat)); - Stat[sizeof(Stat)-1] = '\0'; + while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) { + if (!strcmp(Group, msgs.Group) && msgs.Active) { + memset(&Stat, ' ', sizeof(Stat)); + Stat[sizeof(Stat)-1] = '\0'; - /* - * 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) - Stat[0] = 'S'; - if (System.sendto) - Stat[1] = 'R'; - if (System.pause) - Stat[2] = 'P'; - if (System.cutoff) - Stat[3] = 'C'; - } - } - fprintf(qp, "%s %-25s %s\r", Stat, msgs.Tag, msgs.Name); - SubTot++; - Total++; - } else - fseek(mp, msgshdr.syssize, SEEK_CUR); - } - - fprintf(qp, "----------------------------------------------------------------------------\r"); - fprintf(qp, "%d available area(s)\r\r\r", SubTot); + /* + * 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) + Stat[0] = 'S'; + if (System.sendto) + Stat[1] = 'R'; + if (System.pause) + Stat[2] = 'P'; + if (System.cutoff) + Stat[3] = 'C'; } - } + } + fprintf(qp, "%s %-25s %s\r", Stat, msgs.Tag, msgs.Name); + SubTot++; + Total++; + } else + fseek(mp, msgshdr.syssize, SEEK_CUR); + } + + fprintf(qp, "----------------------------------------------------------------------------\r"); + fprintf(qp, "%d available area(s)\r\r\r", SubTot); } - fprintf(qp, "Total: %d available area(s)\r\r\r", Total); + } + } + fprintf(qp, "Total: %d available area(s)\r\r\r", Total); - fclose(mp); - fclose(gp); + fclose(mp); + fclose(gp); - fprintf(qp, "Con means:\r"); - fprintf(qp, " R - You receive mail from my system\r"); - fprintf(qp, " S - You may send mail to my system\r"); - fprintf(qp, " P - The message area is temporary paused\r"); - fprintf(qp, " C - You are cutoff from this area\r\r"); - fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "%s\r", TearLine()); - CloseMail(qp, t); - net_out++; - free(temp); - } else - WriteError("Can't create netmail"); + fprintf(qp, "Con means:\r"); + fprintf(qp, " R - You receive mail from my system\r"); + fprintf(qp, " S - You may send mail to my system\r"); + fprintf(qp, " P - The message area is temporary paused\r"); + fprintf(qp, " C - You are cutoff from this area\r\r"); + fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); + fprintf(qp, "%s\r", TearLine()); + CloseMail(qp, t); + net_out++; + free(temp); + } else + WriteError("Can't create netmail"); } void A_Flow(faddr *t, char *replyid, int Notify) { - FILE *qp, *gp, *mp; - char *temp, *Group; - int i, First = TRUE, Cons; - char Stat[2]; - faddr *f; - sysconnect System; - time_t Now; - struct tm *tt; - int lmonth; - long lw, lm; + FILE *qp, *gp, *mp; + char *temp, *Group; + int i, First = TRUE, Cons; + char Stat[2]; + faddr *f, *g; + sysconnect System; + time_t Now; + struct tm *tt; + int lmonth; + long lw, lm; - Now = time(NULL); - tt = localtime(&Now); - lmonth = tt->tm_mon; - if (lmonth) - lmonth--; - else - lmonth = 11; + Now = time(NULL); + tt = localtime(&Now); + lmonth = tt->tm_mon; + if (lmonth) + lmonth--; + else + lmonth = 11; - if (Notify) - Syslog('+', "AreaMgr: Flow report to %s", ascfnode(t, 0xff)); - else - Syslog('+', "AreaMgr: Flow report"); - f = bestaka_s(t); + if (Notify) + Syslog('+', "AreaMgr: Flow report to %s", ascfnode(t, 0xff)); + else + Syslog('+', "AreaMgr: Flow report"); + f = bestaka_s(t); - if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"AreaMgr Flow report", replyid)) != NULL) { + 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"); - fread(&msgshdr, sizeof(msgshdr), 1, mp); - Cons = msgshdr.syssize / sizeof(System); - sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); - gp = fopen(temp, "r"); - fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp); + sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + mp = fopen(temp, "r"); + fread(&msgshdr, sizeof(msgshdr), 1, mp); + Cons = msgshdr.syssize / sizeof(System); + sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); + gp = fopen(temp, "r"); + fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp); - fprintf(qp, "The following is a flow report of all message areas\r\r"); + fprintf(qp, "The following is a flow report of all message areas\r\r"); - while (TRUE) { - Group = GetNodeMailGrp(First); - if (Group == NULL) - break; - First = FALSE; + while (TRUE) { + Group = GetNodeMailGrp(First); + if (Group == NULL) + break; + First = FALSE; - lm = lw = 0; - fseek(gp, mgrouphdr.hdrsize, SEEK_SET); - while (fread(&mgroup, mgrouphdr.recsize, 1, gp) == 1) { - 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)) { - fprintf(qp, "Group %s - %s\r\r", mgroup.Name, mgroup.Comment); -// 1 2 3 4 5 6 7 -// 12345678901234567890123456789012345678901234567890123456789012345678901234567890 - fprintf(qp, "Con Message area Last week Last Month\r"); - fprintf(qp, "---------------------------------------------------------------------------\r"); - fseek(mp, msgshdr.hdrsize, SEEK_SET); + 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)) && + (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 + fprintf(qp, "Con Message area Last week Last Month\r"); + fprintf(qp, "---------------------------------------------------------------------------\r"); + fseek(mp, msgshdr.hdrsize, SEEK_SET); - while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) { - if (!strcmp(Group, msgs.Group) && msgs.Active) { - memset(&Stat, ' ', sizeof(Stat)); - Stat[sizeof(Stat)-1] = '\0'; + while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) { + if (!strcmp(Group, msgs.Group) && msgs.Active) { + memset(&Stat, ' ', sizeof(Stat)); + Stat[sizeof(Stat)-1] = '\0'; - /* - * 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)) - Stat[0] = 'C'; - } - } - 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 - fseek(mp, msgshdr.syssize, SEEK_CUR); - } - - fprintf(qp, "---------------------------------------------------------------------------\r"); - fprintf(qp, "Total %58lu %10lu\r\r\r", lw, lm); + /* + * 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)) + Stat[0] = 'C'; } - } + } + 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 + fseek(mp, msgshdr.syssize, SEEK_CUR); + } + + fprintf(qp, "---------------------------------------------------------------------------\r"); + fprintf(qp, "Total %58lu %10lu\r\r\r", lw, lm); } + } + } - fclose(mp); - fclose(gp); + fclose(mp); + fclose(gp); - fprintf(qp, "Con means:\r"); - fprintf(qp, " C - You connected to this area\r"); - fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "%s\r", TearLine()); - CloseMail(qp, t); - net_out++; - free(temp); - } else - WriteError("Can't create netmail"); + fprintf(qp, "Con means:\r"); + fprintf(qp, " C - You connected to this area\r"); + fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); + fprintf(qp, "%s\r", TearLine()); + CloseMail(qp, t); + net_out++; + free(temp); + } else + WriteError("Can't create netmail"); } @@ -464,39 +449,39 @@ void A_Flow(faddr *t, char *replyid, int Notify) void A_Status(faddr *, char *); void A_Status(faddr *t, char *replyid) { - FILE *fp; - int i; + FILE *fp; + int i; - Syslog('+', "AreaMgr: Status"); - if (Miy == 0) - i = 11; - else - i = Miy - 1; + Syslog('+', "AreaMgr: Status"); + if (Miy == 0) + i = 11; + else + i = Miy - 1; - if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"AreaMgr status", replyid)) != NULL) { + if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"AreaMgr status", replyid)) != NULL) { - fprintf(fp, "Here is your (echo)mail status:\r\r"); + fprintf(fp, "Here is your (echo)mail status:\r\r"); - fprintf(fp, "Netmail direct %s\r", GetBool(nodes.Direct)); - fprintf(fp, "Netmail crash %s\r", GetBool(nodes.Crash)); - fprintf(fp, "Netmail hold %s\r", GetBool(nodes.Hold)); - if (nodes.RouteVia.zone) - fprintf(fp, "Route via %s\r", aka2str(nodes.RouteVia)); + fprintf(fp, "Netmail direct %s\r", GetBool(nodes.Direct)); + fprintf(fp, "Netmail crash %s\r", GetBool(nodes.Crash)); + fprintf(fp, "Netmail hold %s\r", GetBool(nodes.Hold)); + if (nodes.RouteVia.zone) + fprintf(fp, "Route via %s\r", aka2str(nodes.RouteVia)); - fprintf(fp, "\r\rMailflow:\r\r"); + fprintf(fp, "\r\rMailflow:\r\r"); - fprintf(fp, " Last week Last month Total ever\r"); - fprintf(fp, " ---------- ---------- ----------\r"); - fprintf(fp, "Messages to you %-10ld %-10ld %-10ld\r", nodes.MailSent.lweek, nodes.MailSent.month[i], nodes.MailSent.total); - fprintf(fp, "Messages from you %-10ld %-10ld %-10ld\r", nodes.MailRcvd.lweek, nodes.MailRcvd.month[i], nodes.MailRcvd.total); + fprintf(fp, " Last week Last month Total ever\r"); + fprintf(fp, " ---------- ---------- ----------\r"); + fprintf(fp, "Messages to you %-10ld %-10ld %-10ld\r", nodes.MailSent.lweek, nodes.MailSent.month[i], nodes.MailSent.total); + fprintf(fp, "Messages from you %-10ld %-10ld %-10ld\r", nodes.MailRcvd.lweek, nodes.MailRcvd.month[i], nodes.MailRcvd.total); - fprintf(fp, "\rWith regards, %s\r\r", CFG.sysop_name); + fprintf(fp, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(fp, "%s\r", TearLine()); - CloseMail(fp, t); - net_out++; - } else - WriteError("Can't create netmail"); + fprintf(fp, "%s\r", TearLine()); + CloseMail(fp, t); + net_out++; + } else + WriteError("Can't create netmail"); } @@ -504,106 +489,104 @@ void A_Status(faddr *t, char *replyid) void A_Unlinked(faddr *, char *); void A_Unlinked(faddr *t, char *replyid) { - FILE *qp, *gp, *mp; - char *temp, *Group; - int i, First = TRUE, SubTot, Total = 0, Cons; - char Stat[5]; - faddr *f; - sysconnect System; + FILE *qp, *gp, *mp; + char *temp, *Group; + int i, First = TRUE, SubTot, Total = 0, Cons; + char Stat[5]; + faddr *f, *g; + sysconnect System; - Syslog('+', "AreaMgr: Unlinked"); - f = bestaka_s(t); + Syslog('+', "AreaMgr: Unlinked"); + f = bestaka_s(t); - if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"Your unlinked request", replyid)) != NULL) { + if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"Your unlinked request", replyid)) != NULL) { - WriteMailGroups(qp, f); - temp = calloc(128, sizeof(char)); + WriteMailGroups(qp, f); + temp = calloc(128, sizeof(char)); - sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); - mp = fopen(temp, "r"); - fread(&msgshdr, sizeof(msgshdr), 1, mp); - Cons = msgshdr.syssize / sizeof(System); - sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); - gp = fopen(temp, "r"); - fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp); + sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + mp = fopen(temp, "r"); + fread(&msgshdr, sizeof(msgshdr), 1, mp); + Cons = msgshdr.syssize / sizeof(System); + sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); + gp = fopen(temp, "r"); + fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp); - fprintf(qp, "The following is a list of all available message areas\r\r"); + fprintf(qp, "The following is a list of all available message areas\r\r"); - while (TRUE) { - Group = GetNodeMailGrp(First); - if (Group == NULL) - break; - First = FALSE; + while (TRUE) { + Group = GetNodeMailGrp(First); + if (Group == NULL) + break; + First = FALSE; - fseek(gp, mgrouphdr.hdrsize, SEEK_SET); - while (fread(&mgroup, mgrouphdr.recsize, 1, gp) == 1) { - 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)) { - SubTot = 0; - fprintf(qp, "Group %s - %s\r\r", mgroup.Name, mgroup.Comment); - fprintf(qp, "Con Message area Description\r"); - fprintf(qp, "----------------------------------------------------------------------------\r"); - fseek(mp, msgshdr.hdrsize, SEEK_SET); + 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)) && + (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"); + fprintf(qp, "----------------------------------------------------------------------------\r"); + fseek(mp, msgshdr.hdrsize, SEEK_SET); - while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) { - if (!strcmp(Group, msgs.Group) && msgs.Active) { - memset(&Stat, ' ', sizeof(Stat)); - Stat[sizeof(Stat)-1] = '\0'; + while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) { + if (!strcmp(Group, msgs.Group) && msgs.Active) { + memset(&Stat, ' ', sizeof(Stat)); + Stat[sizeof(Stat)-1] = '\0'; - /* - * 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) - Stat[0] = 'S'; - if (System.sendto) - Stat[1] = 'R'; - if (System.pause) - Stat[2] = 'P'; - if (System.cutoff) - Stat[3] = 'C'; - } - } - - if ((!System.sendto) && (!System.receivefrom)) { - fprintf(qp, "%s %-25s %s\r", Stat, msgs.Tag, msgs.Name); - SubTot++; - Total++; - } - } else - fseek(mp, msgshdr.syssize, SEEK_CUR); - } - - fprintf(qp, "----------------------------------------------------------------------------\r"); - fprintf(qp, "%d available area(s)\r\r\r", SubTot); + /* + * 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) + Stat[0] = 'S'; + if (System.sendto) + Stat[1] = 'R'; + if (System.pause) + Stat[2] = 'P'; + if (System.cutoff) + Stat[3] = 'C'; } - } + } + + if ((!System.sendto) && (!System.receivefrom)) { + fprintf(qp, "%s %-25s %s\r", Stat, msgs.Tag, msgs.Name); + SubTot++; + Total++; + } + } else + fseek(mp, msgshdr.syssize, SEEK_CUR); + } + + fprintf(qp, "----------------------------------------------------------------------------\r"); + fprintf(qp, "%d available area(s)\r\r\r", SubTot); } + } + } - fclose(mp); - fclose(gp); + fclose(mp); + fclose(gp); - fprintf(qp, "Con means:\r"); - fprintf(qp, " R - You receive mail from my system\r"); - fprintf(qp, " S - You may send mail to my system\r"); - fprintf(qp, " P - The message area is temporary paused\r"); - fprintf(qp, " C - You are cutoff from this area\r\r"); - fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "%s\r", TearLine()); - CloseMail(qp, t); - net_out++; - free(temp); - } else - WriteError("Can't create netmail"); + fprintf(qp, "Con means:\r"); + fprintf(qp, " R - You receive mail from my system\r"); + fprintf(qp, " S - You may send mail to my system\r"); + fprintf(qp, " P - The message area is temporary paused\r"); + fprintf(qp, " C - You are cutoff from this area\r\r"); + fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); + fprintf(qp, "%s\r", TearLine()); + CloseMail(qp, t); + net_out++; + free(temp); + } else + WriteError("Can't create netmail"); } @@ -611,8 +594,8 @@ void A_Unlinked(faddr *t, char *replyid) void A_Global(faddr *, char *, FILE *); void A_Global(faddr *t, char *Cmd, FILE *tmp) { - ShiftBuf(Cmd, 1); - Syslog('m', " AreaMgr node %s global %s", ascfnode(t, 0x1f), Cmd); + ShiftBuf(Cmd, 1); + Syslog('m', " AreaMgr node %s global %s", ascfnode(t, 0x1f), Cmd); } @@ -620,70 +603,70 @@ void A_Global(faddr *t, char *Cmd, FILE *tmp) void A_Disconnect(faddr *, char *, FILE *); void A_Disconnect(faddr *t, char *Area, FILE *tmp) { - int i, First; - char *Group; - faddr *b; - sysconnect Sys; + int i, First; + char *Group; + faddr *b; + sysconnect Sys; - Syslog('+', "AreaMgr: \"%s\"", Area); - ShiftBuf(Area, 1); - for (i=0; i < strlen(Area); i++ ) - Area[i]=toupper(Area[i]); + Syslog('+', "AreaMgr: \"%s\"", Area); + ShiftBuf(Area, 1); + for (i=0; i < strlen(Area); i++ ) + Area[i]=toupper(Area[i]); - if (!SearchMsgs(Area)) { - fprintf(tmp, "Area %s not found\n", Area); - Syslog('m', " Area not found"); - return; - } + if (!SearchMsgs(Area)) { + fprintf(tmp, "Area %s not found\n", Area); + Syslog('m', " Area not found"); + return; + } - Syslog('m', " Found %s group %s", msgs.Tag, mgroup.Name); + Syslog('m', " Found %s group %s", msgs.Tag, mgroup.Name); - First = TRUE; - while ((Group = GetNodeMailGrp(First)) != NULL) { - First = FALSE; - if (strcmp(Group, mgroup.Name) == 0) - break; - } - if (Group == NULL) { - fprintf(tmp, "You may not disconnect from area %s\n", Area); - Syslog('m', " Group %s not available for node", mgroup.Name); - return; - } + First = TRUE; + while ((Group = GetNodeMailGrp(First)) != NULL) { + First = FALSE; + if (strcmp(Group, mgroup.Name) == 0) + break; + } + if (Group == NULL) { + fprintf(tmp, "You may not disconnect from area %s\n", Area); + Syslog('m', " Group %s not available for node", mgroup.Name); + return; + } - b = bestaka_s(t); - i = metric(b, fido2faddr(mgroup.UseAka)); - Syslog('m', "Aka match level is %d", i); + b = bestaka_s(t); + i = metric(b, fido2faddr(mgroup.UseAka)); + Syslog('m', "Aka match level is %d", i); - if (i > METRIC_POINT) { - fprintf(tmp, "You may not disconnect area %s with nodenumber %s\n", Area, ascfnode(t, 0x1f)); - Syslog('m', " Node may not disconnect from group %s", mgroup.Name); - return; - } + if (i > METRIC_POINT) { + fprintf(tmp, "You may not disconnect area %s with nodenumber %s\n", Area, ascfnode(t, 0x1f)); + Syslog('m', " Node may not disconnect from group %s", mgroup.Name); + return; + } - memset(&Sys, 0, sizeof(Sys)); - memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr)); - Sys.sendto = FALSE; - Sys.receivefrom = FALSE; + memset(&Sys, 0, sizeof(Sys)); + memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr)); + Sys.sendto = FALSE; + Sys.receivefrom = FALSE; - if (!MsgSystemConnected(Sys)) { - fprintf(tmp, "You are not connected to %s\n", Area); - Syslog('m', " Node is not connected to %s", Area); - return; - } + if (!MsgSystemConnected(Sys)) { + fprintf(tmp, "You are not connected to %s\n", Area); + Syslog('m', " Node is not connected to %s", Area); + return; + } - if (MsgSystemConnect(&Sys, FALSE)) { + if (MsgSystemConnect(&Sys, FALSE)) { - /* - * Make sure to write an overview afterwards. - */ - a_list = TRUE; - Syslog('+', "Disconnected echo area %s", Area); - fprintf(tmp, "Disconnected from area %s\n", Area); - return; - } + /* + * Make sure to write an overview afterwards. + */ + a_list = TRUE; + Syslog('+', "Disconnected echo area %s", Area); + fprintf(tmp, "Disconnected from area %s\n", Area); + return; + } - fprintf(tmp, "You may not disconnect area %s\n", Area); - Syslog('+', "Didn't disconnect %s from mandatory or cutoff echo area %s", ascfnode(t, 0x1f), Area); + fprintf(tmp, "You may not disconnect area %s\n", Area); + Syslog('+', "Didn't disconnect %s from mandatory or cutoff echo area %s", ascfnode(t, 0x1f), Area); } @@ -691,79 +674,79 @@ void A_Disconnect(faddr *t, char *Area, FILE *tmp) void A_Connect(faddr *, char *, FILE *); void A_Connect(faddr *t, char *Area, FILE *tmp) { - int i, First; - char *Group; - faddr *b; - sysconnect Sys; + int i, First; + char *Group; + faddr *b; + sysconnect Sys; - Syslog('+', "AreaMgr: \"%s\"", printable(Area, 0)); + Syslog('+', "AreaMgr: \"%s\"", printable(Area, 0)); - if (Area[0] == '+') - ShiftBuf(Area, 1); - for (i=0; i < strlen(Area); i++ ) - Area[i]=toupper(Area[i]); + if (Area[0] == '+') + ShiftBuf(Area, 1); + for (i=0; i < strlen(Area); i++ ) + Area[i]=toupper(Area[i]); - if (!SearchMsgs(Area)) { - fprintf(tmp, "Area %s not found\n", Area); - Syslog('m', " Area not found"); - /* SHOULD CHECK FOR AREAS FILE AND ASK UPLINK - CHECK ALL GROUPRECORDS FOR AKA MATCH - IF MATCH CHECK FOR UPLINK AND AREAS FILE - IF FOUND, CREATE MSG AREA, CONNECT UPLINK - RESTORE NODERECORD (IS GONE!) - FALLTHRU TO CONNECT DOWNLINK - */ - return; - } + if (!SearchMsgs(Area)) { + fprintf(tmp, "Area %s not found\n", Area); + Syslog('m', " Area not found"); + /* SHOULD CHECK FOR AREAS FILE AND ASK UPLINK + CHECK ALL GROUPRECORDS FOR AKA MATCH + IF MATCH CHECK FOR UPLINK AND AREAS FILE + IF FOUND, CREATE MSG AREA, CONNECT UPLINK + RESTORE NODERECORD (IS GONE!) + FALLTHRU TO CONNECT DOWNLINK + */ + return; + } - Syslog('m', " Found %s group %s", msgs.Tag, mgroup.Name); + Syslog('m', " Found %s group %s", msgs.Tag, mgroup.Name); - First = TRUE; - while ((Group = GetNodeMailGrp(First)) != NULL) { - First = FALSE; - if (strcmp(Group, mgroup.Name) == 0) - break; - } - if (Group == NULL) { - fprintf(tmp, "You may not connect to area %s\n", Area); - Syslog('m', " Group %s not available for node %s", mgroup.Name); - return; - } + First = TRUE; + while ((Group = GetNodeMailGrp(First)) != NULL) { + First = FALSE; + if (strcmp(Group, mgroup.Name) == 0) + break; + } + if (Group == NULL) { + fprintf(tmp, "You may not connect to area %s\n", Area); + Syslog('m', " Group %s not available for node %s", mgroup.Name); + return; + } - b = bestaka_s(t); - i = metric(b, fido2faddr(mgroup.UseAka)); - Syslog('m', "Aka match level is %d", i); + b = bestaka_s(t); + i = metric(b, fido2faddr(mgroup.UseAka)); + Syslog('m', "Aka match level is %d", i); - if (i > METRIC_POINT) { - fprintf(tmp, "You may not connect area %s with nodenumber %s\n", Area, ascfnode(t, 0x1f)); - Syslog('m', " Node may not connect to group %s", mgroup.Name); - return; - } + if (i > METRIC_POINT) { + fprintf(tmp, "You may not connect area %s with nodenumber %s\n", Area, ascfnode(t, 0x1f)); + Syslog('m', " Node may not connect to group %s", mgroup.Name); + return; + } - memset(&Sys, 0, sizeof(Sys)); - memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr)); - Sys.sendto = TRUE; - Sys.receivefrom = TRUE; + memset(&Sys, 0, sizeof(Sys)); + memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr)); + Sys.sendto = TRUE; + Sys.receivefrom = TRUE; - if (MsgSystemConnected(Sys)) { - fprintf(tmp, "You are already connected to %s\n", Area); - Syslog('m', " Node is already connected to %s", Area); - return; - } + if (MsgSystemConnected(Sys)) { + fprintf(tmp, "You are already connected to %s\n", Area); + Syslog('m', " Node is already connected to %s", Area); + return; + } - if (MsgSystemConnect(&Sys, TRUE)) { + if (MsgSystemConnect(&Sys, TRUE)) { - /* - * Make sure to write an overview afterwards. - */ - a_list = TRUE; - Syslog('+', "Connected echo area %s", Area); - fprintf(tmp, "Connected to area %s\n", Area); - return; - } + /* + * Make sure to write an overview afterwards. + */ + a_list = TRUE; + Syslog('+', "Connected echo area %s", Area); + fprintf(tmp, "Connected to area %s\n", Area); + return; + } - fprintf(tmp, "Not connected to %s, this is not allowed\n", Area); - WriteError("Can't connect node %s to echo area %s", ascfnode(t, 0x1f), Area); + fprintf(tmp, "Not connected to %s, this is not allowed\n", Area); + WriteError("Can't connect node %s to echo area %s", ascfnode(t, 0x1f), Area); } @@ -771,103 +754,100 @@ void A_Connect(faddr *t, char *Area, FILE *tmp) void A_All(faddr *, int, FILE *, char *); void A_All(faddr *t, int Connect, FILE *tmp, char *Grp) { - FILE *mp, *gp; - char *Group, temp[81]; - faddr *f; - int i, Link, First = TRUE, Cons; - sysconnect Sys; - long Pos; + FILE *mp, *gp; + char *Group, temp[81]; + faddr *f; + int i, Link, First = TRUE, Cons; + sysconnect Sys; + long Pos; - if (Grp == NULL) { - if (Connect) - Syslog('+', "AreaMgr: Connect All"); - else - Syslog('+', "AreaMgr: Disconnect All"); - } else { - if (Connect) - Syslog('+', "AreaMgr: Connect group %s", Grp); - else - Syslog('+', "AreaMgr: Disconnect group %s", Grp); - } + if (Grp == NULL) { + if (Connect) + Syslog('+', "AreaMgr: Connect All"); + else + Syslog('+', "AreaMgr: Disconnect All"); + } else { + if (Connect) + Syslog('+', "AreaMgr: Connect group %s", Grp); + else + Syslog('+', "AreaMgr: Disconnect group %s", Grp); + } - f = bestaka_s(t); - Syslog('m', "Bestaka for %s is %s", ascfnode(t, 0x1f), ascfnode(f, 0x1f)); + f = bestaka_s(t); + Syslog('m', "Bestaka for %s is %s", ascfnode(t, 0x1f), ascfnode(f, 0x1f)); - sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); - mp = fopen(temp, "r+"); - fread(&msgshdr, sizeof(msgshdr), 1, mp); - Cons = msgshdr.syssize / sizeof(Sys); - sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); - gp = fopen(temp, "r"); - fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp); + sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT")); + mp = fopen(temp, "r+"); + fread(&msgshdr, sizeof(msgshdr), 1, mp); + Cons = msgshdr.syssize / sizeof(Sys); + sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); + gp = fopen(temp, "r"); + fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp); - while (TRUE) { - Group = GetNodeMailGrp(First); - if (Group == NULL) - break; - First = FALSE; + while (TRUE) { + Group = GetNodeMailGrp(First); + if (Group == NULL) + break; + First = FALSE; - fseek(gp, mgrouphdr.hdrsize, SEEK_SET); - while (fread(&mgroup, mgrouphdr.recsize, 1, gp) == 1) { - if ((!strcmp(mgroup.Name, Group)) && - ((Grp == NULL) || (!strcmp(Group, 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)))) { - fseek(mp, msgshdr.hdrsize, SEEK_SET); + fseek(mp, msgshdr.hdrsize, SEEK_SET); - while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) { - if ((!strcmp(Group, msgs.Group)) && - (msgs.Active) && (!msgs.Mandatory) && - (metric(fido2faddr(mgroup.UseAka), f) == METRIC_EQUAL)) { + while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) { + if ((!strcmp(Group, msgs.Group)) && (msgs.Active) && (!msgs.Mandatory) && + (metric(fido2faddr(mgroup.UseAka), f) == METRIC_EQUAL)) { - if (Connect) { - Link = FALSE; - for (i = 0; i < Cons; i++) { - fread(&Sys, sizeof(Sys), 1, mp); - if (metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL) - Link = TRUE; - } - if (!Link) { - Pos = ftell(mp); - fseek(mp, - msgshdr.syssize, SEEK_CUR); - for (i = 0; i < Cons; i++) { - fread(&Sys, sizeof(Sys), 1, mp); - if (!Sys.aka.zone) { - memset(&Sys, 0, sizeof(Sys)); - memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr)); - Sys.sendto = TRUE; - Sys.receivefrom = TRUE; - fseek(mp, - sizeof(Sys), SEEK_CUR); - fwrite(&Sys, sizeof(Sys), 1, mp); - Syslog('+', "AreaMgr: Connected %s", msgs.Tag); - fprintf(tmp, "Connected area %s\n", msgs.Tag); - a_list = TRUE; - break; - } - } - fseek(mp, Pos, SEEK_SET); - } - } else { - for (i = 0; i < Cons; i++) { - fread(&Sys, sizeof(Sys), 1, mp); - 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); - Syslog('+', "AreaMgr: Disconnected %s", msgs.Tag); - fprintf(tmp, "Disconnected area %s\n", msgs.Tag); - a_list = TRUE; - } - } - } - } else - fseek(mp, msgshdr.syssize, SEEK_CUR); + if (Connect) { + Link = FALSE; + for (i = 0; i < Cons; i++) { + fread(&Sys, sizeof(Sys), 1, mp); + if (metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL) + Link = TRUE; + } + if (!Link) { + Pos = ftell(mp); + fseek(mp, - msgshdr.syssize, SEEK_CUR); + for (i = 0; i < Cons; i++) { + fread(&Sys, sizeof(Sys), 1, mp); + if (!Sys.aka.zone) { + memset(&Sys, 0, sizeof(Sys)); + memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr)); + Sys.sendto = TRUE; + Sys.receivefrom = TRUE; + fseek(mp, - sizeof(Sys), SEEK_CUR); + fwrite(&Sys, sizeof(Sys), 1, mp); + Syslog('+', "AreaMgr: Connected %s", msgs.Tag); + fprintf(tmp, "Connected area %s\n", msgs.Tag); + a_list = TRUE; + break; + } } + fseek(mp, Pos, SEEK_SET); + } + } else { + for (i = 0; i < Cons; i++) { + fread(&Sys, sizeof(Sys), 1, mp); + 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); + Syslog('+', "AreaMgr: Disconnected %s", msgs.Tag); + fprintf(tmp, "Disconnected area %s\n", msgs.Tag); + a_list = TRUE; + } + } } + } else + fseek(mp, msgshdr.syssize, SEEK_CUR); } + } } - fclose(gp); - fclose(mp); + } + fclose(gp); + fclose(mp); } @@ -875,13 +855,13 @@ void A_All(faddr *t, int Connect, FILE *tmp, char *Grp) void A_Group(faddr *, char *, int, FILE *); void A_Group(faddr *t, char *Area, int Connect, FILE *tmp) { - int i; + int i; - ShiftBuf(Area, 2); - CleanBuf(Area); - for (i=0; i < strlen(Area); i++ ) - Area[i]=toupper(Area[i]); - A_All(t, Connect, tmp, Area); + ShiftBuf(Area, 2); + CleanBuf(Area); + for (i=0; i < strlen(Area); i++ ) + Area[i]=toupper(Area[i]); + A_All(t, Connect, tmp, Area); } @@ -889,11 +869,11 @@ void A_Group(faddr *t, char *Area, int Connect, FILE *tmp) void A_Pause(faddr *, int, FILE *); void A_Pause(faddr *t, int Pause, FILE *tmp) { - return; - if (Pause) - Syslog('+', "AreaMgr: Pause"); - else - Syslog('+', "AreaMgr: Resume"); + return; + if (Pause) + Syslog('+', "AreaMgr: Pause"); + else + Syslog('+', "AreaMgr: Resume"); } @@ -901,28 +881,28 @@ void A_Pause(faddr *t, int Pause, FILE *tmp) void A_Rescan(faddr *, char *, FILE *); void A_Rescan(faddr *t, char *Area, FILE *tmp) { - int i,result; + int i,result; - /* - * First strip leading garbage - */ - ShiftBuf(Area, 7); - CleanBuf(Area); - 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) - fprintf(tmp, "Rescan area %s, %lu last msgs.\n", Area, a_msgs); - else - fprintf(tmp, "Rescan area %s \n", Area); - } else if (result==1) - fprintf(tmp, "Can't rescan unknown area %s\n", Area); - else if (result==2) - fprintf(tmp, "%s can't rescan area %s\n", ascfnode(t, 0x1f), Area); + /* + * First strip leading garbage + */ + ShiftBuf(Area, 7); + CleanBuf(Area); + 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) + fprintf(tmp, "Rescan area %s, %lu last msgs.\n", Area, a_msgs); else - fprintf(tmp, "Fatal Error Rescanning area %s\n", Area); + fprintf(tmp, "Rescan area %s \n", Area); + } else if (result == 1) + fprintf(tmp, "Can't rescan unknown area %s\n", Area); + 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); } @@ -930,172 +910,172 @@ void A_Rescan(faddr *t, char *Area, FILE *tmp) void A_Msgs(char *, int); void A_Msgs(char *Buf, int skip) { - /* - * First strip leading garbage - */ - ShiftBuf(Buf, skip); - CleanBuf(Buf); - a_msgs = strtoul( Buf, (char **)NULL, 10 ); - Syslog('+', "AreaMgr: msgs %s ", Buf ); + /* + * First strip leading garbage + */ + ShiftBuf(Buf, skip); + CleanBuf(Buf); + a_msgs = strtoul( Buf, (char **)NULL, 10 ); + Syslog('+', "AreaMgr: msgs %s ", Buf ); } int AreaMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int flags, FILE *fp) { - int i, rc = 0, spaces; - char *Buf; - FILE *tmp, *np; - fidoaddr Node; + int i, rc = 0, spaces; + char *Buf; + FILE *tmp, *np; + fidoaddr Node; - a_help = a_stat = a_unlnk = a_list = a_query = FALSE; - areamgr++; - if (SearchFidonet(f->zone)) - f->domain = xstrcpy(fidonet.domain); + a_help = a_stat = a_unlnk = a_list = a_query = FALSE; + areamgr++; + if (SearchFidonet(f->zone)) + f->domain = xstrcpy(fidonet.domain); - Syslog('+', "AreaMgr msg from %s", ascfnode(f, 0xff)); + Syslog('+', "AreaMgr msg from %s", ascfnode(f, 0xff)); + + /* + * If the password failed, we return silently and don't respond. + */ + if ((!strlen(subj)) || (strcasecmp(subj, nodes.Apasswd))) { + WriteError("AreaMgr: password expected \"%s\", got \"%s\"", nodes.Apasswd, subj); + net_bad++; + return FALSE; + } + + if ((tmp = tmpfile()) == NULL) { + WriteError("$AreaMgr: Can't open tmpfile()"); + net_bad++; + return FALSE; + } + + Buf = calloc(2049, sizeof(char)); + rewind(fp); + + while ((fgets(Buf, 2048, fp)) != NULL) { /* - * If the password failed, we return silently and don't respond. + * Make sure we have the nodes record loaded */ - if ((!strlen(subj)) || (strcasecmp(subj, nodes.Apasswd))) { - WriteError("AreaMgr: password expected \"%s\", got \"%s\"", nodes.Apasswd, subj); - net_bad++; - return FALSE; + memcpy(&Node, faddr2fido(f), sizeof(fidoaddr)); + SearchNode(Node); + + spaces = 0; + for (i = 0; i < strlen(Buf); i++) { + if (*(Buf + i) == ' ') + spaces++; + if (*(Buf + i) == '\t') + spaces++; + if (*(Buf + i) == '\0') + break; + if (*(Buf + i) == '\n') + *(Buf + i) = '\0'; + if (*(Buf + i) == '\r') + *(Buf + i) = '\0'; } - if ((tmp = tmpfile()) == NULL) { - WriteError("$AreaMgr: Can't open tmpfile()"); - net_bad++; - return FALSE; + if (!strncmp(Buf, "---", 3)) + break; + + if (strlen(Buf) && (*(Buf) != '\001') && (spaces <= 1)) { + + if (!strncasecmp(Buf, "%help", 5)) + a_help = TRUE; + else if (!strncasecmp(Buf, "%query", 6)) + a_query = TRUE; + else if (!strncasecmp(Buf, "%linked", 7)) + a_query = TRUE; + else if (!strncasecmp(Buf, "%list", 5)) + a_list = TRUE; + else if (!strncasecmp(Buf, "%status", 7)) + a_stat = TRUE; + else if (!strncasecmp(Buf, "%unlinked", 9)) + a_unlnk = TRUE; + else if (!strncasecmp(Buf, "%flow", 5)) + a_flow = TRUE; + else if (!strncasecmp(Buf, "%msgs", 5)) + A_Msgs(Buf, 5); + else if (!strncasecmp(Buf, "%rescan", 7)) + A_Rescan(f, Buf, tmp); + else if (!strncasecmp(Buf, "%+all", 5)) + A_All(f, TRUE, tmp, NULL); + else if (!strncasecmp(Buf, "%-all", 5)) + A_All(f, FALSE, tmp, NULL); + else if (!strncasecmp(Buf, "%+*", 3)) + A_All(f, TRUE, tmp, NULL); + else if (!strncasecmp(Buf, "%-*", 3)) + A_All(f, FALSE, tmp, NULL); + else if (!strncasecmp(Buf, "%+", 2)) + A_Group(f, Buf, TRUE, tmp); + else if (!strncasecmp(Buf, "%-", 2)) + A_Group(f, Buf, FALSE, tmp); + else if (!strncasecmp(Buf, "%pause", 6)) + A_Pause(f, TRUE, tmp); + else if (!strncasecmp(Buf, "%resume", 7)) + A_Pause(f, FALSE, tmp); + else if (!strncasecmp(Buf, "%password", 9)) + MgrPasswd(f, Buf, tmp, 9); + else if (!strncasecmp(Buf, "%pwd", 4)) + MgrPasswd(f, Buf, tmp, 4); + else if (!strncasecmp(Buf, "%notify", 7)) + MgrNotify(f, Buf, tmp); + else if (*(Buf) == '%') + A_Global(f, Buf, tmp); + else if (*(Buf) == '-') + A_Disconnect(f, Buf, tmp); + else + A_Connect(f, Buf, tmp); } + } - Buf = calloc(2049, sizeof(char)); - rewind(fp); + /* + * If the temporary response file isn't empty, + * create a response netmail about what we did. + */ + if (ftell(tmp)) { + if ((np = SendMgrMail(f, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"Your AreaMgr request", replyid)) != NULL) { - while ((fgets(Buf, 2048, fp)) != NULL) { + fprintf(np, " Dear %s\r\r", nodes.Sysop); + fprintf(np, "Here is the result of your AreaMgr request:\r\r"); + fseek(tmp, 0, SEEK_SET); - /* - * Make sure we have the nodes record loaded - */ - memcpy(&Node, faddr2fido(f), sizeof(fidoaddr)); - SearchNode(Node); + while ((fgets(Buf, 2048, tmp)) != NULL) { + Buf[strlen(Buf)-1] = '\0'; + fprintf(np, "%s\r", Buf); + Syslog('m', "Rep: %s", Buf); + } - spaces = 0; - for (i = 0; i < strlen(Buf); i++) { - if (*(Buf + i) == ' ') - spaces++; - if (*(Buf + i) == '\t') - spaces++; - if (*(Buf + i) == '\0') - break; - if (*(Buf + i) == '\n') - *(Buf + i) = '\0'; - if (*(Buf + i) == '\r') - *(Buf + i) = '\0'; - } + fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name); + fprintf(np, "%s\r", TearLine()); + CloseMail(np, t); + net_out++; + } else + WriteError("Can't create netmail"); + } - if (!strncmp(Buf, "---", 3)) - break; + free(Buf); + fclose(tmp); - if (strlen(Buf) && (*(Buf) != '\001') && (spaces <= 1)) { + if (a_stat) + A_Status(f, replyid); - if (!strncasecmp(Buf, "%help", 5)) - a_help = TRUE; - else if (!strncasecmp(Buf, "%query", 6)) - a_query = TRUE; - else if (!strncasecmp(Buf, "%linked", 7)) - a_query = TRUE; - else if (!strncasecmp(Buf, "%list", 5)) - a_list = TRUE; - else if (!strncasecmp(Buf, "%status", 7)) - a_stat = TRUE; - else if (!strncasecmp(Buf, "%unlinked", 9)) - a_unlnk = TRUE; - else if (!strncasecmp(Buf, "%flow", 5)) - a_flow = TRUE; - else if (!strncasecmp(Buf, "%msgs", 5)) - A_Msgs(Buf, 5); - else if (!strncasecmp(Buf, "%rescan", 7)) - A_Rescan(f, Buf, tmp); - else if (!strncasecmp(Buf, "%+all", 5)) - A_All(f, TRUE, tmp, NULL); - else if (!strncasecmp(Buf, "%-all", 5)) - A_All(f, FALSE, tmp, NULL); - else if (!strncasecmp(Buf, "%+*", 3)) - A_All(f, TRUE, tmp, NULL); - else if (!strncasecmp(Buf, "%-*", 3)) - A_All(f, FALSE, tmp, NULL); - else if (!strncasecmp(Buf, "%+", 2)) - A_Group(f, Buf, TRUE, tmp); - else if (!strncasecmp(Buf, "%-", 2)) - A_Group(f, Buf, FALSE, tmp); - else if (!strncasecmp(Buf, "%pause", 6)) - A_Pause(f, TRUE, tmp); - else if (!strncasecmp(Buf, "%resume", 7)) - A_Pause(f, FALSE, tmp); - else if (!strncasecmp(Buf, "%password", 9)) - MgrPasswd(f, Buf, tmp, 9); - else if (!strncasecmp(Buf, "%pwd", 4)) - MgrPasswd(f, Buf, tmp, 4); - else if (!strncasecmp(Buf, "%notify", 7)) - MgrNotify(f, Buf, tmp); - else if (*(Buf) == '%') - A_Global(f, Buf, tmp); - else if (*(Buf) == '-') - A_Disconnect(f, Buf, tmp); - else - A_Connect(f, Buf, tmp); - } - } + if (a_query) + A_Query(f, replyid); - /* - * If the temporary response file isn't empty, - * create a response netmail about what we did. - */ - if (ftell(tmp)) { - if ((np = SendMgrMail(f, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", (char *)"Your AreaMgr request", replyid)) != NULL) { + if (a_list) + A_List(f, replyid, FALSE); - fprintf(np, " Dear %s\r\r", nodes.Sysop); - fprintf(np, "Here is the result of your AreaMgr request:\r\r"); - fseek(tmp, 0, SEEK_SET); + if (a_flow) + A_Flow(f, replyid, FALSE); - while ((fgets(Buf, 2048, tmp)) != NULL) { - Buf[strlen(Buf)-1] = '\0'; - fprintf(np, "%s\r", Buf); - Syslog('m', "Rep: %s", Buf); - } + if (a_unlnk) + A_Unlinked(f, replyid); - fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(np, "%s\r", TearLine()); - CloseMail(np, t); - net_out++; - } else - WriteError("Can't create netmail"); - } + if (a_help) + A_Help(f, replyid); - free(Buf); - fclose(tmp); - - if (a_stat) - A_Status(f, replyid); - - if (a_query) - A_Query(f, replyid); - - if (a_list) - A_List(f, replyid, FALSE); - - if (a_flow) - A_Flow(f, replyid, FALSE); - - if (a_unlnk) - A_Unlinked(f, replyid); - - if (a_help) - A_Help(f, replyid); - - return rc; + return rc; } diff --git a/mbfido/filemgr.c b/mbfido/filemgr.c index 039cc287..5bb7dcb2 100644 --- a/mbfido/filemgr.c +++ b/mbfido/filemgr.c @@ -79,55 +79,55 @@ int f_unlnk = FALSE; void F_Help(faddr *, char *); void F_Help(faddr *t, char *replyid) { - FILE *fp; + FILE *fp; - Syslog('+', "FileMgr: Help"); + Syslog('+', "FileMgr: Help"); - if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"FileMgr help", replyid)) != NULL) { - fprintf(fp, "Address all requests to '%s' (without quotes)\r", (char *)"Filemgr"); - fprintf(fp, "Youre FileMgr password goes on the subject line.\r\r"); + if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"FileMgr help", replyid)) != NULL) { + fprintf(fp, "Address all requests to '%s' (without quotes)\r", (char *)"Filemgr"); + fprintf(fp, "Youre FileMgr password goes on the subject line.\r\r"); - fprintf(fp, "In the body of the message to FileMgr:\r\r"); + fprintf(fp, "In the body of the message to FileMgr:\r\r"); - fprintf(fp, "+ To connect to an fileecho area\r"); - fprintf(fp, "- To disconnect from an fileecho area\r"); - fprintf(fp, "%%+ALL To connect to all fileecho areas\r"); - fprintf(fp, "%%-ALL To disconnect from all fileecho areas\r"); - fprintf(fp, "%%+ To connect all fileecho areas of a group\r"); - fprintf(fp, "%%- To disconnect from all fileecho areas of a group\r"); - fprintf(fp, "%%HELP To request this help message\r"); - fprintf(fp, "%%LIST To request a list of available fileecho areas\r"); - fprintf(fp, "%%QUERY To request a list of active fileecho areas\r"); - fprintf(fp, "%%UNLINKED To request a list of available fileecho areas\r"); - fprintf(fp, " to which you are not already connected\r"); - fprintf(fp, "%%STATUS To request a status report for your system\r"); -// fprintf(fp, "%%PAUSE To temporary disconnect from the connected areas\r"); -// fprintf(fp, "%%RESUME To reconnect the temporary disconnected areas\r); - fprintf(fp, "%%PWD=newpwd To set a new AreaMgr and FileMgr password\r"); -// fprintf(fp, "%%RESCAN To request all files from 'area' again\r"); - fprintf(fp, "%%MESSGAE=On/Off To switch the message function on or off\r"); - fprintf(fp, "%%TICK=On/Off/Advanced To set the tic file mode off, normal or advanced\r"); - fprintf(fp, "%%NOTIFY=On/Off To switch the notify function on or off\r"); -// fprintf(fp, "%%RESEND To resend file 'name' with tic file\r"); - fprintf(fp, "[---] Everything below the tearline is ignored\r\r"); + fprintf(fp, "+ To connect to an fileecho area\r"); + fprintf(fp, "- To disconnect from an fileecho area\r"); + fprintf(fp, "%%+ALL To connect to all fileecho areas\r"); + fprintf(fp, "%%-ALL To disconnect from all fileecho areas\r"); + fprintf(fp, "%%+ To connect all fileecho areas of a group\r"); + fprintf(fp, "%%- To disconnect from all fileecho areas of a group\r"); + fprintf(fp, "%%HELP To request this help message\r"); + fprintf(fp, "%%LIST To request a list of available fileecho areas\r"); + fprintf(fp, "%%QUERY To request a list of active fileecho areas\r"); + fprintf(fp, "%%UNLINKED To request a list of available fileecho areas\r"); + fprintf(fp, " to which you are not already connected\r"); + fprintf(fp, "%%STATUS To request a status report for your system\r"); +// fprintf(fp, "%%PAUSE To temporary disconnect from the connected areas\r"); +// fprintf(fp, "%%RESUME To reconnect the temporary disconnected areas\r); + fprintf(fp, "%%PWD=newpwd To set a new AreaMgr and FileMgr password\r"); +// fprintf(fp, "%%RESCAN To request all files from 'area' again\r"); + fprintf(fp, "%%MESSGAE=On/Off To switch the message function on or off\r"); + fprintf(fp, "%%TICK=On/Off/Advanced To set the tic file mode off, normal or advanced\r"); + fprintf(fp, "%%NOTIFY=On/Off To switch the notify function on or off\r"); +// fprintf(fp, "%%RESEND To resend file 'name' with tic file\r"); + fprintf(fp, "[---] Everything below the tearline is ignored\r\r"); - fprintf(fp, "Example:\r\r"); + fprintf(fp, "Example:\r\r"); - fprintf(fp, " By: %s\r", nodes.Sysop); - fprintf(fp, " To: %s, %s\r", (char *)"Filemgr", ascfnode(bestaka_s(t), 0xf)); - fprintf(fp, " Re: %s\r", nodes.Fpasswd); - fprintf(fp, " St: Pvt Local Kill\r"); - fprintf(fp, " ----------------------------------------------------------\r"); - fprintf(fp, " +MBSE_BBS\r"); - fprintf(fp, " -NODELIST\r"); - fprintf(fp, " %%QUERY\r"); - fprintf(fp, " %%LIST\r\r"); + fprintf(fp, " By: %s\r", nodes.Sysop); + fprintf(fp, " To: %s, %s\r", (char *)"Filemgr", ascfnode(bestaka_s(t), 0xf)); + fprintf(fp, " Re: %s\r", nodes.Fpasswd); + fprintf(fp, " St: Pvt Local Kill\r"); + fprintf(fp, " ----------------------------------------------------------\r"); + fprintf(fp, " +MBSE_BBS\r"); + fprintf(fp, " -NODELIST\r"); + fprintf(fp, " %%QUERY\r"); + fprintf(fp, " %%LIST\r\r"); - fprintf(fp, "%s\r", TearLine()); - CloseMail(fp, t); - net_out++; - } else - WriteError("Can't create netmail"); + fprintf(fp, "%s\r", TearLine()); + CloseMail(fp, t); + net_out++; + } else + WriteError("Can't create netmail"); } @@ -135,205 +135,200 @@ void F_Help(faddr *t, char *replyid) void F_Query(faddr *, char *); void F_Query(faddr *t, char *replyid) { - FILE *qp, *gp, *fp; - char *temp, *Group; - int i, First = TRUE, SubTot, Total = 0, Cons; - char Stat[4]; - faddr *f; - sysconnect System; + FILE *qp, *gp, *fp; + char *temp, *Group; + int i, First = TRUE, SubTot, Total = 0, Cons; + char Stat[4]; + faddr *f, *g; + sysconnect System; - Syslog('+', "FileMgr: Query"); - f = bestaka_s(t); + 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) { + 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"); - fread(&tichdr, sizeof(tichdr), 1, fp); - Cons = tichdr.syssize / sizeof(System); - sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT")); - gp = fopen(temp, "r"); - fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp); + sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT")); + fp = fopen(temp, "r"); + fread(&tichdr, sizeof(tichdr), 1, fp); + Cons = tichdr.syssize / sizeof(System); + sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT")); + gp = fopen(temp, "r"); + fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp); - fprintf(qp, "The following is a list of all connected file areas\r\r"); + fprintf(qp, "The following is a list of all connected file areas\r\r"); - while (TRUE) { - Group = GetNodeFileGrp(First); - if (Group == NULL) - break; - First = FALSE; + while (TRUE) { + Group = GetNodeFileGrp(First); + if (Group == NULL) + break; + First = FALSE; - fseek(gp, fgrouphdr.hdrsize, SEEK_SET); - while (fread(&fgroup, fgrouphdr.recsize, 1, gp) == 1) { - 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)) { - SubTot = 0; - fprintf(qp, "Group %s - %s\r\r", fgroup.Name, fgroup.Comment); - fprintf(qp, "Con File tic Description\r"); - fprintf(qp, "------------------------------------------------------------------------\r"); - fseek(fp, tichdr.hdrsize, SEEK_SET); + 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)) && + (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 (%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); - while (fread(&tic, tichdr.recsize, 1, fp) == 1) { - if (!strcmp(Group, tic.Group) && tic.Active) { - memset(&Stat, ' ', sizeof(Stat)); - Stat[sizeof(Stat)-1] = '\0'; + while (fread(&tic, tichdr.recsize, 1, fp) == 1) { + if (!strcmp(Group, tic.Group) && tic.Active) { + memset(&Stat, ' ', sizeof(Stat)); + Stat[sizeof(Stat)-1] = '\0'; - /* - * 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 (System.receivefrom) - Stat[0] = 'S'; - if (System.sendto) - Stat[1] = 'R'; - if (System.pause) - Stat[2] = 'P'; + /* + * 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 (System.receivefrom) + Stat[0] = 'S'; + if (System.sendto) + Stat[1] = 'R'; + if (System.pause) + Stat[2] = 'P'; - if (System.sendto || System.receivefrom) { - fprintf(qp, "%s %-20s %s\r", Stat, tic.Name, tic.Comment); - SubTot++; - Total++; - } - } - } - } else - fseek(fp, tichdr.syssize, SEEK_CUR); - } - - fprintf(qp, "------------------------------------------------------------------------\r"); - fprintf(qp, "%d available area(s)\r\r\r", SubTot); + if (System.sendto || System.receivefrom) { + fprintf(qp, "%s %-20s %s\r", Stat, tic.Name, tic.Comment); + SubTot++; + Total++; + } } - } + } + } else + fseek(fp, tichdr.syssize, SEEK_CUR); + } + + fprintf(qp, "------------------------------------------------------------------------\r"); + fprintf(qp, "%d available area(s)\r\r\r", SubTot); } + } + } - fclose(fp); - fclose(gp); + fclose(fp); + fclose(gp); - fprintf(qp, "Con means:\r"); - fprintf(qp, " R - You receive files from my system\r"); - fprintf(qp, " S - You may send files in this area\r"); - fprintf(qp, " P - The file area is temporary paused\r\r"); - fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "%s\r", TearLine()); - CloseMail(qp, t); - net_out++; - free(temp); - } else - WriteError("Can't create netmail"); + fprintf(qp, "Con means:\r"); + fprintf(qp, " R - You receive files from my system\r"); + fprintf(qp, " S - You may send files in this area\r"); + fprintf(qp, " P - The file area is temporary paused\r\r"); + fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); + fprintf(qp, "%s\r", TearLine()); + CloseMail(qp, t); + net_out++; + free(temp); + } else + WriteError("Can't create netmail"); } void F_List(faddr *t, char *replyid, int Notify) { - FILE *qp, *gp, *fp; - char *temp, *Group; - int i, First = TRUE, SubTot, Total = 0, Cons; - char Stat[4]; - faddr *f; - sysconnect System; + FILE *qp, *gp, *fp; + char *temp, *Group; + int i, First = TRUE, SubTot, Total = 0, Cons; + char Stat[4]; + faddr *f, *g; + sysconnect System; - if (Notify) - Syslog('+', "FileMgr: Notify to %s", ascfnode(t, 0xff)); - else - Syslog('+', "FileMgr: List"); - f = bestaka_s(t); + if (Notify) + Syslog('+', "FileMgr: Notify to %s", ascfnode(t, 0xff)); + else + Syslog('+', "FileMgr: List"); + f = bestaka_s(t); - if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"FileMgr List", replyid)) != NULL) { + if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"FileMgr List", replyid)) != NULL) { - WriteFileGroups(qp, f); - temp = calloc(128, sizeof(char)); + WriteFileGroups(qp, f); + temp = calloc(PATH_MAX, sizeof(char)); - sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT")); - fp = fopen(temp, "r"); - fread(&tichdr, sizeof(tichdr), 1, fp); - Cons = tichdr.syssize / sizeof(System); - sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT")); - gp = fopen(temp, "r"); - fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp); + sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT")); + fp = fopen(temp, "r"); + fread(&tichdr, sizeof(tichdr), 1, fp); + Cons = tichdr.syssize / sizeof(System); + sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT")); + gp = fopen(temp, "r"); + fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp); - fprintf(qp, "The following is a list of all file areas\r\r"); + fprintf(qp, "The following is a list of all file areas\r\r"); - while (TRUE) { - Group = GetNodeFileGrp(First); - if (Group == NULL) - break; - First = FALSE; + while (TRUE) { + Group = GetNodeFileGrp(First); + if (Group == NULL) + break; + First = FALSE; - fseek(gp, fgrouphdr.hdrsize, SEEK_SET); - while (fread(&fgroup, fgrouphdr.recsize, 1, gp) == 1) { - 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)) { - SubTot = 0; - fprintf(qp, "Group %s - %s\r\r", fgroup.Name, fgroup.Comment); - fprintf(qp, "Con File tic Description\r"); - fprintf(qp, "------------------------------------------------------------------------\r"); - fseek(fp, tichdr.hdrsize, SEEK_SET); + 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)) && + (g->zone == f->zone) && (g->net == f->net) && + (g->node == f->node) && (g->point == f->point)) { + SubTot = 0; + 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); - while (fread(&tic, tichdr.recsize, 1, fp) == 1) { - if (!strcmp(Group, tic.Group) && tic.Active) { - memset(&Stat, ' ', sizeof(Stat)); - Stat[sizeof(Stat)-1] = '\0'; + while (fread(&tic, tichdr.recsize, 1, fp) == 1) { + if (!strcmp(Group, tic.Group) && tic.Active) { + memset(&Stat, ' ', sizeof(Stat)); + Stat[sizeof(Stat)-1] = '\0'; - /* - * 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 (System.receivefrom) - Stat[0] = 'S'; - if (System.sendto) - Stat[1] = 'R'; - if (System.pause) - Stat[2] = 'P'; - } - } - fprintf(qp, "%s %-20s %s\r", Stat, tic.Name, tic.Comment); - SubTot++; - Total++; - } else - fseek(fp, tichdr.syssize, SEEK_CUR); - } - - fprintf(qp, "------------------------------------------------------------------------\r"); - fprintf(qp, "%d available area(s)\r\r\r", SubTot); + /* + * 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 (System.receivefrom) + Stat[0] = 'S'; + if (System.sendto) + Stat[1] = 'R'; + if (System.pause) + Stat[2] = 'P'; } - } + } + fprintf(qp, "%s %-20s %s\r", Stat, tic.Name, tic.Comment); + SubTot++; + Total++; + } else + fseek(fp, tichdr.syssize, SEEK_CUR); + } + + fprintf(qp, "------------------------------------------------------------------------\r"); + fprintf(qp, "%d available area(s)\r\r\r", SubTot); } + } + } - fclose(fp); - fclose(gp); + fclose(fp); + fclose(gp); - fprintf(qp, "Con means:\r"); - fprintf(qp, " R - You receive files from my system\r"); - fprintf(qp, " S - You may send files in this area\r"); - fprintf(qp, " P - The file area is temporary paused\r\r"); - fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "%s\r", TearLine()); - CloseMail(qp, t); - net_out++; - free(temp); - } else - WriteError("Can't create netmail"); + fprintf(qp, "Con means:\r"); + fprintf(qp, " R - You receive files from my system\r"); + fprintf(qp, " S - You may send files in this area\r"); + fprintf(qp, " P - The file area is temporary paused\r\r"); + fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); + fprintf(qp, "%s\r", TearLine()); + CloseMail(qp, t); + net_out++; + free(temp); + } else + WriteError("Can't create netmail"); } @@ -341,48 +336,48 @@ void F_List(faddr *t, char *replyid, int Notify) void F_Status(faddr *, char *); void F_Status(faddr *t, char *replyid) { - FILE *fp; - int i; + FILE *fp; + int i; - Syslog('+', "FileMgr: Status"); - if (Miy == 0) - i = 11; - else - i = Miy - 1; + Syslog('+', "FileMgr: Status"); + if (Miy == 0) + i = 11; + else + i = Miy - 1; - if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"FileMgr Status", replyid)) != NULL) { + if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"FileMgr Status", replyid)) != NULL) { - fprintf(fp, "Here is your fileecho status:\r\r"); + fprintf(fp, "Here is your fileecho status:\r\r"); - fprintf(fp, "Netmail message %s\r", GetBool(nodes.Message)); - fprintf(fp, "TIC files %s\r", GetBool(nodes.Tic)); - if (nodes.Tic) - fprintf(fp, "Andvanced TIC files %s\r", GetBool(nodes.AdvTic)); - fprintf(fp, "Notify messages %s\r", GetBool(nodes.Notify)); - fprintf(fp, "Cost sharing %s\r", GetBool(nodes.Billing)); - if (nodes.Billing) { - fprintf(fp, "Send bill direct %s\r", GetBool(nodes.BillDirect)); - fprintf(fp, "Units debet %ld\r", nodes.Debet); - fprintf(fp, "Units credit %ld\r", nodes.Credit); - fprintf(fp, "Warning level %ld\r", nodes.WarnLevel); - } + fprintf(fp, "Netmail message %s\r", GetBool(nodes.Message)); + fprintf(fp, "TIC files %s\r", GetBool(nodes.Tic)); + if (nodes.Tic) + fprintf(fp, "Andvanced TIC files %s\r", GetBool(nodes.AdvTic)); + fprintf(fp, "Notify messages %s\r", GetBool(nodes.Notify)); + fprintf(fp, "Cost sharing %s\r", GetBool(nodes.Billing)); + if (nodes.Billing) { + fprintf(fp, "Send bill direct %s\r", GetBool(nodes.BillDirect)); + fprintf(fp, "Units debet %ld\r", nodes.Debet); + fprintf(fp, "Units credit %ld\r", nodes.Credit); + fprintf(fp, "Warning level %ld\r", nodes.WarnLevel); + } - fprintf(fp, "\r\rRecent flow:\r\r"); + fprintf(fp, "\r\rRecent flow:\r\r"); - fprintf(fp, " Last week Last month Total ever\r"); - fprintf(fp, " ---------- ---------- ----------\r"); - fprintf(fp, "Files sent %-10ld %-10ld %-10ld\r", nodes.FilesSent.lweek, nodes.FilesSent.month[i], nodes.FilesSent.total); - fprintf(fp, "KBytes sent %-10ld %-10ld %-10ld\r", nodes.F_KbSent.lweek, nodes.F_KbSent.month[i], nodes.F_KbSent.total); - fprintf(fp, "Files received %-10ld %-10ld %-10ld\r", nodes.FilesRcvd.lweek, nodes.FilesRcvd.month[i], nodes.FilesRcvd.total); - fprintf(fp, "KBytes received %-10ld %-10ld %-10ld\r", nodes.F_KbRcvd.lweek, nodes.F_KbRcvd.month[i], nodes.F_KbRcvd.total); + fprintf(fp, " Last week Last month Total ever\r"); + fprintf(fp, " ---------- ---------- ----------\r"); + fprintf(fp, "Files sent %-10ld %-10ld %-10ld\r", nodes.FilesSent.lweek, nodes.FilesSent.month[i], nodes.FilesSent.total); + fprintf(fp, "KBytes sent %-10ld %-10ld %-10ld\r", nodes.F_KbSent.lweek, nodes.F_KbSent.month[i], nodes.F_KbSent.total); + fprintf(fp, "Files received %-10ld %-10ld %-10ld\r", nodes.FilesRcvd.lweek, nodes.FilesRcvd.month[i], nodes.FilesRcvd.total); + fprintf(fp, "KBytes received %-10ld %-10ld %-10ld\r", nodes.F_KbRcvd.lweek, nodes.F_KbRcvd.month[i], nodes.F_KbRcvd.total); - fprintf(fp, "\rWith regards, %s\r\r", CFG.sysop_name); + fprintf(fp, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(fp, "%s\r", TearLine()); - CloseMail(fp, t); - net_out++; - } else - WriteError("Can't create netmail"); + fprintf(fp, "%s\r", TearLine()); + CloseMail(fp, t); + net_out++; + } else + WriteError("Can't create netmail"); } @@ -390,102 +385,98 @@ void F_Status(faddr *t, char *replyid) void F_Unlinked(faddr *, char *); void F_Unlinked(faddr *t, char *replyid) { - FILE *qp, *gp, *fp; - char *temp, *Group; - int i, First = TRUE, SubTot, Total = 0, Cons; - char Stat[4]; - faddr *f; - sysconnect System; + FILE *qp, *gp, *fp; + char *temp, *Group; + int i, First = TRUE, SubTot, Total = 0, Cons; + char Stat[4]; + faddr *f, *g; + sysconnect System; - Syslog('+', "FileMgr: Unlinked"); - f = bestaka_s(t); + Syslog('+', "FileMgr: Unlinked"); + f = bestaka_s(t); - if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"Your unlinked request", replyid)) != NULL) { + 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"); - fread(&tichdr, sizeof(tichdr), 1, fp); - Cons = tichdr.syssize / sizeof(System); - sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT")); - gp = fopen(temp, "r"); - fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp); + sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT")); + fp = fopen(temp, "r"); + fread(&tichdr, sizeof(tichdr), 1, fp); + Cons = tichdr.syssize / sizeof(System); + sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT")); + gp = fopen(temp, "r"); + fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp); - fprintf(qp, "The following is a list of all available file areas\r\r"); + fprintf(qp, "The following is a list of all available file areas\r\r"); - while (TRUE) { - Group = GetNodeFileGrp(First); - if (Group == NULL) - break; - First = FALSE; + while (TRUE) { + Group = GetNodeFileGrp(First); + if (Group == NULL) + break; + First = FALSE; - fseek(gp, fgrouphdr.hdrsize, SEEK_SET); - while (fread(&fgroup, fgrouphdr.recsize, 1, gp) == 1) { - 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)) { - SubTot = 0; - fprintf(qp, "Group %s - %s\r\r", fgroup.Name, fgroup.Comment); - fprintf(qp, "Con File tic Description\r"); - fprintf(qp, "------------------------------------------------------------------------\r"); - fseek(fp, tichdr.hdrsize, SEEK_SET); + 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)) && + (g->zone == f->zone) && (g->net == f->net) && + (g->node == f->node) && (g->point == f->point)) { + SubTot = 0; + 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); - while (fread(&tic, tichdr.recsize, 1, fp) == 1) { - if (!strcmp(Group, tic.Group) && tic.Active) { - memset(&Stat, ' ', sizeof(Stat)); - Stat[sizeof(Stat)-1] = '\0'; + while (fread(&tic, tichdr.recsize, 1, fp) == 1) { + if (!strcmp(Group, tic.Group) && tic.Active) { + memset(&Stat, ' ', sizeof(Stat)); + Stat[sizeof(Stat)-1] = '\0'; - /* - * 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 (System.receivefrom) - Stat[0] = 'S'; - if (System.sendto) - Stat[1] = 'R'; - if (System.pause) - Stat[2] = 'P'; - } - } - - if ((!System.sendto) && (!System.receivefrom)) { - fprintf(qp, "%s %-20s %s\r", Stat, tic.Name, tic.Comment); - SubTot++; - Total++; - } - } else - fseek(fp, tichdr.syssize, SEEK_CUR); - } - - fprintf(qp, "------------------------------------------------------------------------\r"); - fprintf(qp, "%d available area(s)\r\r\r", SubTot); + /* + * 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 (System.receivefrom) + Stat[0] = 'S'; + if (System.sendto) + Stat[1] = 'R'; + if (System.pause) + Stat[2] = 'P'; } - } + } + + if ((!System.sendto) && (!System.receivefrom)) { + fprintf(qp, "%s %-20s %s\r", Stat, tic.Name, tic.Comment); + SubTot++; + Total++; + } + } else + fseek(fp, tichdr.syssize, SEEK_CUR); + } + + fprintf(qp, "------------------------------------------------------------------------\r"); + fprintf(qp, "%d available area(s)\r\r\r", SubTot); } + } + } - fclose(fp); - fclose(gp); + fclose(fp); + fclose(gp); - fprintf(qp, "Con means:\r"); - fprintf(qp, " R - You receive files from my system\r"); - fprintf(qp, " S - You may send files in this area\r"); - fprintf(qp, " P - The file area is temporary paused\r\r"); - fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); - fprintf(qp, "%s\r", TearLine()); - CloseMail(qp, t); - net_out++; - free(temp); - } else - WriteError("Can't create netmail"); + fprintf(qp, "Con means:\r"); + fprintf(qp, " R - You receive files from my system\r"); + fprintf(qp, " S - You may send files in this area\r"); + fprintf(qp, " P - The file area is temporary paused\r\r"); + fprintf(qp, "With regards, %s\r\r", CFG.sysop_name); + fprintf(qp, "%s\r", TearLine()); + CloseMail(qp, t); + net_out++; + free(temp); + } else + WriteError("Can't create netmail"); } @@ -502,68 +493,68 @@ void F_Global(faddr *t, char *Cmd, FILE *tmp) void F_Disconnect(faddr *, char *, FILE *); void F_Disconnect(faddr *t, char *Area, FILE *tmp) { - int i, First; - char *Group; - faddr *b; - sysconnect Sys; + int i, First; + char *Group; + faddr *b; + sysconnect Sys; - Syslog('+', "FileMgr: %s", Area); - ShiftBuf(Area, 1); + Syslog('+', "FileMgr: %s", Area); + ShiftBuf(Area, 1); - if (!SearchTic(Area)) { - fprintf(tmp, "Area %s not found\n", Area); - Syslog('m', " Area not found"); - return; - } + if (!SearchTic(Area)) { + fprintf(tmp, "Area %s not found\n", Area); + Syslog('m', " Area not found"); + return; + } - Syslog('m', " Found %s group %s", tic.Name, fgroup.Name); + Syslog('m', " Found %s group %s", tic.Name, fgroup.Name); - First = TRUE; - while ((Group = GetNodeFileGrp(First)) != NULL) { - First = FALSE; - if (strcmp(Group, fgroup.Name) == 0) - break; - } - if (Group == NULL) { - fprintf(tmp, "You may not disconnect from area %s\n", Area); - Syslog('m', " Group %s not available for node", fgroup.Name); - return; - } + First = TRUE; + while ((Group = GetNodeFileGrp(First)) != NULL) { + First = FALSE; + if (strcmp(Group, fgroup.Name) == 0) + break; + } + if (Group == NULL) { + fprintf(tmp, "You may not disconnect from area %s\n", Area); + Syslog('m', " Group %s not available for node", fgroup.Name); + return; + } - b = bestaka_s(t); - i = metric(b, fido2faddr(fgroup.UseAka)); - Syslog('m', "Aka match level is %d", i); + b = bestaka_s(t); + i = metric(b, fido2faddr(fgroup.UseAka)); + Syslog('m', "Aka match level is %d", i); - if (i > METRIC_POINT) { - fprintf(tmp, "You may not disconnect area %s with nodenumber %s\n", Area, ascfnode(t, 0x1f)); - Syslog('m', " Node may not disconnect from group %s", fgroup.Name); - return; - } + if (i > METRIC_POINT) { + fprintf(tmp, "You may not disconnect area %s with nodenumber %s\n", Area, ascfnode(t, 0x1f)); + Syslog('m', " Node may not disconnect from group %s", fgroup.Name); + return; + } - memset(&Sys, 0, sizeof(Sys)); - memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr)); - Sys.sendto = FALSE; - Sys.receivefrom = FALSE; + memset(&Sys, 0, sizeof(Sys)); + memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr)); + Sys.sendto = FALSE; + Sys.receivefrom = FALSE; - if (!TicSystemConnected(Sys)) { - fprintf(tmp, "You are not connected to %s\n", Area); - Syslog('m', " Node is not connected to %s", Area); - return; - } + if (!TicSystemConnected(Sys)) { + fprintf(tmp, "You are not connected to %s\n", Area); + Syslog('m', " Node is not connected to %s", Area); + return; + } - if (!TicSystemConnect(&Sys, FALSE)) { + if (!TicSystemConnect(&Sys, FALSE)) { - /* - * Make sure to write an overview afterwards - */ - f_list = TRUE; - Syslog('+', "Disconnected file area %s", Area); - fprintf(tmp, "Disconnected from area %s\n", Area); - return; - } + /* + * Make sure to write an overview afterwards + */ + f_list = TRUE; + Syslog('+', "Disconnected file area %s", Area); + fprintf(tmp, "Disconnected from area %s\n", Area); + return; + } - fprintf(tmp, "You may not disconnect area %s, area is mandatory\n", Area); - Syslog('+', "Didn't disconnect %s from mandatory file area %s", ascfnode(t, 0x1f), Area); + fprintf(tmp, "You may not disconnect area %s, area is mandatory\n", Area); + Syslog('+', "Didn't disconnect %s from mandatory file area %s", ascfnode(t, 0x1f), Area); } @@ -571,76 +562,76 @@ void F_Disconnect(faddr *t, char *Area, FILE *tmp) void F_Connect(faddr *, char *, FILE *); void F_Connect(faddr *t, char *Area, FILE *tmp) { - int i, First; - char *Group; - faddr *b; - sysconnect Sys; + int i, First; + char *Group; + faddr *b; + sysconnect Sys; - Syslog('+', "FileMgr: %s", Area); + Syslog('+', "FileMgr: %s", Area); - if (Area[0] == '+') - ShiftBuf(Area, 1); + if (Area[0] == '+') + ShiftBuf(Area, 1); - if (!SearchTic(Area)) { - fprintf(tmp, "Area %s not found\n", Area); - Syslog('m', " Area not found"); - /* SHOULD CHECK FOR AREAS FILE AND ASK UPLINK - CHECK ALL GROUPRECORDS FOR AKA MATCH - IF MATCH CHECK FOR UPLINK AND AREAS FILE - IF FOUND, CREATE TIC AREA, CONNECT UPLINK - RESTORE NODERECORD (IS GONE!) - FALLTHRU TO CONNECT DOWNLINK - */ - return; - } + if (!SearchTic(Area)) { + fprintf(tmp, "Area %s not found\n", Area); + Syslog('m', " Area not found"); + /* SHOULD CHECK FOR AREAS FILE AND ASK UPLINK + CHECK ALL GROUPRECORDS FOR AKA MATCH + IF MATCH CHECK FOR UPLINK AND AREAS FILE + IF FOUND, CREATE TIC AREA, CONNECT UPLINK + RESTORE NODERECORD (IS GONE!) + FALLTHRU TO CONNECT DOWNLINK + */ + return; + } - Syslog('m', " Found %s group %s", tic.Name, fgroup.Name); + Syslog('m', " Found %s group %s", tic.Name, fgroup.Name); - First = TRUE; - while ((Group = GetNodeFileGrp(First)) != NULL) { - First = FALSE; - if (strcmp(Group, fgroup.Name) == 0) - break; - } - if (Group == NULL) { - fprintf(tmp, "You may not connect to area %s\n", Area); - Syslog('m', " Group %s not available for node %s", fgroup.Name); - return; - } + First = TRUE; + while ((Group = GetNodeFileGrp(First)) != NULL) { + First = FALSE; + if (strcmp(Group, fgroup.Name) == 0) + break; + } + if (Group == NULL) { + fprintf(tmp, "You may not connect to area %s\n", Area); + Syslog('m', " Group %s not available for node %s", fgroup.Name); + return; + } - b = bestaka_s(t); - i = metric(b, fido2faddr(fgroup.UseAka)); - Syslog('m', "Aka match level is %d", i); + b = bestaka_s(t); + i = metric(b, fido2faddr(fgroup.UseAka)); + Syslog('m', "Aka match level is %d", i); - if (i > METRIC_POINT) { - fprintf(tmp, "You may not connect area %s with nodenumber %s\n", Area, ascfnode(t, 0x1f)); - Syslog('m', " Node may not connect to group %s", fgroup.Name); - return; - } + if (i > METRIC_POINT) { + fprintf(tmp, "You may not connect area %s with nodenumber %s\n", Area, ascfnode(t, 0x1f)); + Syslog('m', " Node may not connect to group %s", fgroup.Name); + return; + } - memset(&Sys, 0, sizeof(Sys)); - memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr)); - Sys.sendto = TRUE; + memset(&Sys, 0, sizeof(Sys)); + memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr)); + Sys.sendto = TRUE; - if (TicSystemConnected(Sys)) { - fprintf(tmp, "You are already connected to %s\n", Area); - Syslog('m', " Node is already connected to %s", Area); - return; - } + if (TicSystemConnected(Sys)) { + fprintf(tmp, "You are already connected to %s\n", Area); + Syslog('m', " Node is already connected to %s", Area); + return; + } - if (TicSystemConnect(&Sys, TRUE)) { + if (TicSystemConnect(&Sys, TRUE)) { - /* - * Make sure to write an overview afterwards - */ - f_list = TRUE; - Syslog('+', "Connected to file area %s", Area); - fprintf(tmp, "Connected to area %s\n", Area); - return; - } + /* + * Make sure to write an overview afterwards + */ + f_list = TRUE; + Syslog('+', "Connected to file area %s", Area); + fprintf(tmp, "Connected to area %s\n", Area); + return; + } - fprintf(tmp, "Not connected to %s, internal error, sysop is notified\n", Area); - WriteError("Can't connect node %s to file area %s", ascfnode(t, 0x1f), Area); + fprintf(tmp, "Not connected to %s, internal error, sysop is notified\n", Area); + WriteError("Can't connect node %s to file area %s", ascfnode(t, 0x1f), Area); } @@ -648,99 +639,96 @@ void F_Connect(faddr *t, char *Area, FILE *tmp) 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]; - faddr *f; - int i, Link, First = TRUE, Cons; - sysconnect Sys; - long Pos; + FILE *fp, *gp; + char *Group, temp[PATH_MAX]; + faddr *f; + int i, Link, First = TRUE, Cons; + sysconnect Sys; + long Pos; - if (Grp == NULL) { - if (Connect) - Syslog('+', "FileMgr: Connect All"); - else - Syslog('+', "FileMgr: Disconnect All"); - } else { - if (Connect) - Syslog('+', "FileMgr: Connect group %s", Grp); - else - Syslog('+', "FileMgr: Disconnect group %s", Grp); - } + if (Grp == NULL) { + if (Connect) + Syslog('+', "FileMgr: Connect All"); + else + Syslog('+', "FileMgr: Disconnect All"); + } else { + if (Connect) + Syslog('+', "FileMgr: Connect group %s", Grp); + else + Syslog('+', "FileMgr: Disconnect group %s", Grp); + } - f = bestaka_s(t); - sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT")); - fp = fopen(temp, "r+"); - fread(&tichdr, sizeof(tichdr), 1, fp); - Cons = tichdr.syssize / sizeof(Sys); - sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT")); - gp = fopen(temp, "r"); - fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp); + f = bestaka_s(t); + sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT")); + fp = fopen(temp, "r+"); + fread(&tichdr, sizeof(tichdr), 1, fp); + Cons = tichdr.syssize / sizeof(Sys); + sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT")); + gp = fopen(temp, "r"); + fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp); - while (TRUE) { - Group = GetNodeFileGrp(First); - if (Group == NULL) - break; - First = FALSE; + while (TRUE) { + Group = GetNodeFileGrp(First); + if (Group == NULL) + break; + First = FALSE; - fseek(gp, fgrouphdr.hdrsize, SEEK_SET); - while (fread(&fgroup, fgrouphdr.recsize, 1, gp) == 1) { - if ((!strcmp(fgroup.Name, Group)) && - ((Grp == NULL) || (!strcmp(Group, 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)))) { - fseek(fp, tichdr.hdrsize, SEEK_SET); + fseek(fp, tichdr.hdrsize, SEEK_SET); + while (fread(&tic, tichdr.recsize, 1, fp) == 1) { - 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; - for (i = 0; i < Cons; i++) { - fread(&Sys, sizeof(Sys), 1, fp); - if (metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL) - Link = TRUE; - } - if (!Link) { - Pos = ftell(fp); - fseek(fp, - tichdr.syssize, SEEK_CUR); - for (i = 0; i < Cons; i++) { - fread(&Sys, sizeof(Sys), 1, fp); - if (!Sys.aka.zone) { - memset(&Sys, 0, sizeof(Sys)); - memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr)); - Sys.sendto = TRUE; - fseek(fp, - sizeof(Sys), SEEK_CUR); - fwrite(&Sys, sizeof(Sys), 1, fp); - Syslog('+', "FileMgr: Connected %s", tic.Name); - fprintf(tmp, "Connected area %s\n", tic.Name); - f_list = TRUE; - break; - } - } - fseek(fp, Pos, SEEK_SET); - } - } else { - for (i = 0; i < Cons; i++) { - fread(&Sys, sizeof(Sys), 1, fp); - if (metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL) { - memset(&Sys, 0, sizeof(Sys)); - fseek(fp, - sizeof(Sys), SEEK_CUR); - fwrite(&Sys, sizeof(Sys), 1, fp); - Syslog('+', "FileMgr: Disconnected %s", tic.Name); - fprintf(tmp, "Disconnected area %s\n", tic.Name); - f_list = TRUE; - } - } - } - } else - fseek(fp, tichdr.syssize, SEEK_CUR); + if (Connect) { + Link = FALSE; + for (i = 0; i < Cons; i++) { + fread(&Sys, sizeof(Sys), 1, fp); + if (metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL) + Link = TRUE; + } + if (!Link) { + Pos = ftell(fp); + fseek(fp, - tichdr.syssize, SEEK_CUR); + for (i = 0; i < Cons; i++) { + fread(&Sys, sizeof(Sys), 1, fp); + if (!Sys.aka.zone) { + memset(&Sys, 0, sizeof(Sys)); + memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr)); + Sys.sendto = TRUE; + fseek(fp, - sizeof(Sys), SEEK_CUR); + fwrite(&Sys, sizeof(Sys), 1, fp); + Syslog('+', "FileMgr: Connected %s", tic.Name); + fprintf(tmp, "Connected area %s\n", tic.Name); + f_list = TRUE; + break; + } } + fseek(fp, Pos, SEEK_SET); + } + } else { + for (i = 0; i < Cons; i++) { + fread(&Sys, sizeof(Sys), 1, fp); + if (metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL) { + memset(&Sys, 0, sizeof(Sys)); + fseek(fp, - sizeof(Sys), SEEK_CUR); + fwrite(&Sys, sizeof(Sys), 1, fp); + Syslog('+', "FileMgr: Disconnected %s", tic.Name); + fprintf(tmp, "Disconnected area %s\n", tic.Name); + f_list = TRUE; + } + } } + } else + fseek(fp, tichdr.syssize, SEEK_CUR); } + } } - fclose(gp); - fclose(fp); + } + fclose(gp); + fclose(fp); } @@ -748,9 +736,9 @@ void F_All(faddr *t, int Connect, FILE *tmp, char *Grp) void F_Group(faddr *, char *, int, FILE *); void F_Group(faddr *t, char *Area, int Connect, FILE *tmp) { - ShiftBuf(Area, 2); - CleanBuf(Area); - F_All(t, Connect, tmp, Area); + ShiftBuf(Area, 2); + CleanBuf(Area); + F_All(t, Connect, tmp, Area); } @@ -758,215 +746,215 @@ void F_Group(faddr *t, char *Area, int Connect, FILE *tmp) void F_Pause(faddr *, int, FILE *); void F_Pause(faddr *t, int Pause, FILE *tmp) { - if (Pause) - Syslog('+', "FileMgr: Pause"); - else - Syslog('+', "FileMgr: Resume"); + if (Pause) + Syslog('+', "FileMgr: Pause"); + else + Syslog('+', "FileMgr: Resume"); } void F_Message(faddr *t, char *Buf, FILE *tmp) { - fidoaddr Node; + fidoaddr Node; - ShiftBuf(Buf, 8); - CleanBuf(Buf); + ShiftBuf(Buf, 8); + CleanBuf(Buf); - if (!strncasecmp(Buf, "on", 2)) - nodes.Message = TRUE; - else if (!strncasecmp(Buf, "off", 3)) - nodes.Message = FALSE; - else - return; + if (!strncasecmp(Buf, "on", 2)) + nodes.Message = TRUE; + else if (!strncasecmp(Buf, "off", 3)) + nodes.Message = FALSE; + else + return; - UpdateNode(); - memcpy(&Node, faddr2fido(t), sizeof(fidoaddr)); - SearchNode(Node); - Syslog('+', "FileMgr: Message %s", GetBool(nodes.Message)); - fprintf(tmp, "FileMgr Message file is %s\n", GetBool(nodes.Message)); + UpdateNode(); + memcpy(&Node, faddr2fido(t), sizeof(fidoaddr)); + SearchNode(Node); + Syslog('+', "FileMgr: Message %s", GetBool(nodes.Message)); + fprintf(tmp, "FileMgr Message file is %s\n", GetBool(nodes.Message)); } void F_Tick(faddr *t, char *Buf, FILE *tmp) { - fidoaddr Node; + fidoaddr Node; - ShiftBuf(Buf, 5); - CleanBuf(Buf); + ShiftBuf(Buf, 5); + CleanBuf(Buf); - if (!strncasecmp(Buf, "on", 2)) { - nodes.Tic = TRUE; - nodes.AdvTic = FALSE; - } else if (!strncasecmp(Buf, "off", 3)) { - nodes.Tic = nodes.AdvTic = FALSE; - } else if (!strncasecmp(Buf, "advanced", 8)) { - nodes.Tic = nodes.AdvTic = TRUE; - } else - return; + if (!strncasecmp(Buf, "on", 2)) { + nodes.Tic = TRUE; + nodes.AdvTic = FALSE; + } else if (!strncasecmp(Buf, "off", 3)) { + nodes.Tic = nodes.AdvTic = FALSE; + } else if (!strncasecmp(Buf, "advanced", 8)) { + nodes.Tic = nodes.AdvTic = TRUE; + } else + return; - UpdateNode(); - memcpy(&Node, faddr2fido(t), sizeof(fidoaddr)); - SearchNode(Node); - Syslog('+', "FileMgr: Tick %s, Advanced %s", nodes.Tic, nodes.AdvTic); - if (nodes.Tic) - if (nodes.AdvTic) - fprintf(tmp, "Tick mode is advanced"); - else - fprintf(tmp, "Tick mode is normal"); + UpdateNode(); + memcpy(&Node, faddr2fido(t), sizeof(fidoaddr)); + SearchNode(Node); + Syslog('+', "FileMgr: Tick %s, Advanced %s", nodes.Tic, nodes.AdvTic); + if (nodes.Tic) + if (nodes.AdvTic) + fprintf(tmp, "Tick mode is advanced"); else - fprintf(tmp, "Tick mode is off"); + fprintf(tmp, "Tick mode is normal"); + else + fprintf(tmp, "Tick mode is off"); } int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int flags, FILE *fp) { - int i, rc = 0, spaces; - char *Buf; - FILE *tmp, *np; - fidoaddr Node; + int i, rc = 0, spaces; + char *Buf; + FILE *tmp, *np; + fidoaddr Node; - f_help = f_stat = f_unlnk = f_list = f_query = FALSE; - filemgr++; - if (SearchFidonet(f->zone)) - f->domain = xstrcpy(fidonet.domain); + f_help = f_stat = f_unlnk = f_list = f_query = FALSE; + filemgr++; + if (SearchFidonet(f->zone)) + f->domain = xstrcpy(fidonet.domain); - Syslog('+', "FileMgr msg from %s", ascfnode(f, 0xff)); + Syslog('+', "FileMgr msg from %s", ascfnode(f, 0xff)); + + /* + * If the password failed, we return silently and don't respond. + */ + if ((!strlen(subj)) || (strcasecmp(subj, nodes.Fpasswd))) { + WriteError("FileMgr: password expected \"%s\", got \"%s\"", nodes.Fpasswd, subj); + net_bad++; + return FALSE; + } + + if ((tmp = tmpfile()) == NULL) { + WriteError("$FileMsr: Can't open tmpfile()"); + net_bad++; + return FALSE; + } + + Buf = calloc(2049, sizeof(char)); + rewind(fp); + + while ((fgets(Buf, 2048, fp)) != NULL) { /* - * If the password failed, we return silently and don't respond. + * Make sure we refresh the nodes record. */ - if ((!strlen(subj)) || (strcasecmp(subj, nodes.Fpasswd))) { - WriteError("FileMgr: password expected \"%s\", got \"%s\"", nodes.Fpasswd, subj); - net_bad++; - return FALSE; + memcpy(&Node, faddr2fido(f), sizeof(fidoaddr)); + SearchNode(Node); + + spaces = 0; + for (i = 0; i < strlen(Buf); i++) { + if (*(Buf + i) == ' ') + spaces++; + if (*(Buf + i) == '\t') + spaces++; + if (*(Buf + i) == '\0') + break; + if (*(Buf + i) == '\n') + *(Buf + i) = '\0'; + if (*(Buf + i) == '\r') + *(Buf + i) = '\0'; } - if ((tmp = tmpfile()) == NULL) { - WriteError("$FileMsr: Can't open tmpfile()"); - net_bad++; - return FALSE; + if (!strncmp(Buf, "---", 3)) + break; + + if (strlen(Buf) && (*(Buf) != '\001') && (spaces <= 1)) { + + if (!strncasecmp(Buf, "%help", 5)) + f_help = TRUE; + else if (!strncasecmp(Buf, "%query", 6)) + f_query = TRUE; + else if (!strncasecmp(Buf, "%linked", 7)) + f_query = TRUE; + else if (!strncasecmp(Buf, "%list", 5)) + f_list = TRUE; + else if (!strncasecmp(Buf, "%status", 7)) + f_stat = TRUE; + else if (!strncasecmp(Buf, "%unlinked", 9)) + f_unlnk = TRUE; + else if (!strncasecmp(Buf, "%+all", 5)) + F_All(f, TRUE, tmp, NULL); + else if (!strncasecmp(Buf, "%-all", 5)) + F_All(f, FALSE, tmp, NULL); + else if (!strncasecmp(Buf, "%+*", 3)) + F_All(f, TRUE, tmp, NULL); + else if (!strncasecmp(Buf, "%-*", 3)) + F_All(f, FALSE, tmp, NULL); + else if (!strncasecmp(Buf, "%+", 2)) + F_Group(f, Buf, TRUE, tmp); + else if (!strncasecmp(Buf, "%-", 2)) + F_Group(f, Buf, FALSE, tmp); + else if (!strncasecmp(Buf, "%pause", 6)) + F_Pause(f, TRUE, tmp); + else if (!strncasecmp(Buf, "%resume", 7)) + F_Pause(f, FALSE, tmp); + else if (!strncasecmp(Buf, "%password", 9)) + MgrPasswd(f, Buf, tmp, 9); + else if (!strncasecmp(Buf, "%pwd", 4)) + MgrPasswd(f, Buf, tmp, 4); + else if (!strncasecmp(Buf, "%notify", 7)) + MgrNotify(f, Buf, tmp); + else if (!strncasecmp(Buf, "%message", 8)) + F_Message(f, Buf, tmp); + else if (!strncasecmp(Buf, "%tick", 5)) + F_Tick(f, Buf, tmp); + else if (*(Buf) == '%') + F_Global(f, Buf, tmp); + else if (*(Buf) == '-') + F_Disconnect(f, Buf, tmp); + else + F_Connect(f, Buf, tmp); } + } - Buf = calloc(2049, sizeof(char)); - rewind(fp); + if (ftell(tmp)) { + if ((np = SendMgrMail(f, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"Your FileMgr request", replyid)) != NULL) { - while ((fgets(Buf, 2048, fp)) != NULL) { + fprintf(np, " Dear %s\r\r", nodes.Sysop); + fprintf(np, "Here is the result of your FileMgr request:\r\r"); + fseek(tmp, 0, SEEK_SET); - /* - * Make sure we refresh the nodes record. - */ - memcpy(&Node, faddr2fido(f), sizeof(fidoaddr)); - SearchNode(Node); + while ((fgets(Buf, 2048, tmp)) != NULL) { + Buf[strlen(Buf)-1] = '\0'; + fprintf(np, "%s\r", Buf); + Syslog('m', "Rep: %s", Buf); + } - spaces = 0; - for (i = 0; i < strlen(Buf); i++) { - if (*(Buf + i) == ' ') - spaces++; - if (*(Buf + i) == '\t') - spaces++; - if (*(Buf + i) == '\0') - break; - if (*(Buf + i) == '\n') - *(Buf + i) = '\0'; - if (*(Buf + i) == '\r') - *(Buf + i) = '\0'; - } + fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name); + fprintf(np, "%s\r", TearLine()); + CloseMail(np, t); + net_out++; + } else + WriteError("Can't create netmail"); + } - if (!strncmp(Buf, "---", 3)) - break; + free(Buf); + fclose(tmp); - if (strlen(Buf) && (*(Buf) != '\001') && (spaces <= 1)) { + if (f_stat) + F_Status(f, replyid); - if (!strncasecmp(Buf, "%help", 5)) - f_help = TRUE; - else if (!strncasecmp(Buf, "%query", 6)) - f_query = TRUE; - else if (!strncasecmp(Buf, "%linked", 7)) - f_query = TRUE; - else if (!strncasecmp(Buf, "%list", 5)) - f_list = TRUE; - else if (!strncasecmp(Buf, "%status", 7)) - f_stat = TRUE; - else if (!strncasecmp(Buf, "%unlinked", 9)) - f_unlnk = TRUE; - else if (!strncasecmp(Buf, "%+all", 5)) - F_All(f, TRUE, tmp, NULL); - else if (!strncasecmp(Buf, "%-all", 5)) - F_All(f, FALSE, tmp, NULL); - else if (!strncasecmp(Buf, "%+*", 3)) - F_All(f, TRUE, tmp, NULL); - else if (!strncasecmp(Buf, "%-*", 3)) - F_All(f, FALSE, tmp, NULL); - else if (!strncasecmp(Buf, "%+", 2)) - F_Group(f, Buf, TRUE, tmp); - else if (!strncasecmp(Buf, "%-", 2)) - F_Group(f, Buf, FALSE, tmp); - else if (!strncasecmp(Buf, "%pause", 6)) - F_Pause(f, TRUE, tmp); - else if (!strncasecmp(Buf, "%resume", 7)) - F_Pause(f, FALSE, tmp); - else if (!strncasecmp(Buf, "%password", 9)) - MgrPasswd(f, Buf, tmp, 9); - else if (!strncasecmp(Buf, "%pwd", 4)) - MgrPasswd(f, Buf, tmp, 4); - else if (!strncasecmp(Buf, "%notify", 7)) - MgrNotify(f, Buf, tmp); - else if (!strncasecmp(Buf, "%message", 8)) - F_Message(f, Buf, tmp); - else if (!strncasecmp(Buf, "%tick", 5)) - F_Tick(f, Buf, tmp); - else if (*(Buf) == '%') - F_Global(f, Buf, tmp); - else if (*(Buf) == '-') - F_Disconnect(f, Buf, tmp); - else - F_Connect(f, Buf, tmp); - } - } + if (f_query) + F_Query(f, replyid); - if (ftell(tmp)) { - if ((np = SendMgrMail(f, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"Your FileMgr request", replyid)) != NULL) { + if (f_list) + F_List(f, replyid, FALSE); - fprintf(np, " Dear %s\r\r", nodes.Sysop); - fprintf(np, "Here is the result of your FileMgr request:\r\r"); - fseek(tmp, 0, SEEK_SET); + if (f_unlnk) + F_Unlinked(f, replyid); - while ((fgets(Buf, 2048, tmp)) != NULL) { - Buf[strlen(Buf)-1] = '\0'; - fprintf(np, "%s\r", Buf); - Syslog('m', "Rep: %s", Buf); - } + if (f_help) + F_Help(f, replyid); - fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name); - fprintf(np, "%s\r", TearLine()); - CloseMail(np, t); - net_out++; - } else - WriteError("Can't create netmail"); - } - - free(Buf); - fclose(tmp); - - if (f_stat) - F_Status(f, replyid); - - if (f_query) - F_Query(f, replyid); - - if (f_list) - F_List(f, replyid, FALSE); - - if (f_unlnk) - F_Unlinked(f, replyid); - - if (f_help) - F_Help(f, replyid); - - return rc; + return rc; }