2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2002-01-07 19:16:03 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: AreaMgr
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2002-01-07 19:16:03 +00:00
|
|
|
* Copyright (C) 1997-2002
|
2001-08-17 05:46:24 +00:00
|
|
|
*
|
|
|
|
* Michiel Broek FIDO: 2:280/2802
|
|
|
|
* Beekmansbos 10
|
|
|
|
* 1971 BV IJmuiden
|
|
|
|
* the Netherlands
|
|
|
|
*
|
|
|
|
* This file is part of MBSE BBS.
|
|
|
|
*
|
|
|
|
* This BBS is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* MBSE BBS is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
|
|
|
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../config.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/libs.h"
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../lib/memwatch.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/structs.h"
|
2002-01-07 19:16:03 +00:00
|
|
|
#include "../lib/users.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/records.h"
|
|
|
|
#include "../lib/common.h"
|
|
|
|
#include "../lib/clcomm.h"
|
|
|
|
#include "../lib/msg.h"
|
|
|
|
#include "../lib/msgtext.h"
|
|
|
|
#include "../lib/dbcfg.h"
|
|
|
|
#include "../lib/dbnode.h"
|
|
|
|
#include "../lib/dbmsgs.h"
|
|
|
|
#include "../lib/dbdupe.h"
|
|
|
|
#include "../lib/dbuser.h"
|
|
|
|
#include "../lib/dbftn.h"
|
2002-03-29 22:58:53 +00:00
|
|
|
#include "../lib/diesel.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "sendmail.h"
|
|
|
|
#include "mgrutil.h"
|
|
|
|
#include "scan.h"
|
2002-03-03 16:28:10 +00:00
|
|
|
#include "createm.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "areamgr.h"
|
|
|
|
|
2002-03-29 22:58:53 +00:00
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* External declarations
|
|
|
|
*/
|
|
|
|
extern int do_quiet;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Global variables
|
|
|
|
*/
|
|
|
|
extern int net_bad; /* Bad netmails (tracking errors */
|
|
|
|
|
2002-03-02 13:27:44 +00:00
|
|
|
int areamgr = 0; /* Nr of AreaMgr messages */
|
|
|
|
int a_help = FALSE; /* Send AreaMgr help */
|
|
|
|
int a_list = FALSE; /* Send AreaMgr list */
|
|
|
|
int a_query = FALSE; /* Send AreaMgr query */
|
|
|
|
int a_stat = FALSE; /* Send AreaMgr status */
|
|
|
|
int a_unlnk = FALSE; /* Send AreaMgr unlinked */
|
|
|
|
int a_flow = FALSE; /* Send AreaMgr flow */
|
|
|
|
unsigned long a_msgs = 0; /* Messages to rescan */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-25 19:53:11 +00:00
|
|
|
void A_Help(faddr *, char *);
|
|
|
|
void A_Help(faddr *t, char *replyid)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2002-03-29 22:58:53 +00:00
|
|
|
FILE *fp, *fi;
|
2002-03-31 13:09:23 +00:00
|
|
|
char *subject;
|
2002-06-19 21:23:56 +00:00
|
|
|
faddr *ta;
|
2002-02-11 21:49:10 +00:00
|
|
|
|
|
|
|
Syslog('+', "AreaMgr: Help");
|
2002-03-29 22:58:53 +00:00
|
|
|
|
|
|
|
subject = calloc(255, sizeof(char));
|
|
|
|
sprintf(subject,"AreaMgr Help");
|
|
|
|
GetRpSubject("areamgr.help",subject);
|
|
|
|
|
|
|
|
if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", subject , replyid)) != NULL) {
|
2002-06-19 21:23:56 +00:00
|
|
|
if ((fi = OpenMacro("areamgr.help", nodes.Language, FALSE)) != NULL ) {
|
|
|
|
ta = bestaka_s(t);
|
2002-08-16 20:50:28 +00:00
|
|
|
MacroVars("s", "s", nodes.Sysop);
|
|
|
|
MacroVars("A", "s", (char *)"Areamgr");
|
|
|
|
MacroVars("Y", "s", ascfnode(ta, 0xff));
|
|
|
|
MacroVars("P", "s", nodes.Apasswd);
|
2002-06-19 21:23:56 +00:00
|
|
|
tidy_faddr(ta);
|
2002-03-31 20:07:04 +00:00
|
|
|
MacroRead(fi, fp);
|
|
|
|
fclose(fi);
|
2002-03-29 22:58:53 +00:00
|
|
|
}
|
2002-03-31 20:07:04 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
fprintf(fp, "%s\r", TearLine());
|
|
|
|
CloseMail(fp, t);
|
2002-03-31 20:07:04 +00:00
|
|
|
} else {
|
2002-02-11 21:49:10 +00:00
|
|
|
WriteError("Can't create netmail");
|
2002-03-31 20:07:04 +00:00
|
|
|
}
|
|
|
|
|
2002-03-29 22:58:53 +00:00
|
|
|
free(subject);
|
|
|
|
MacroClear();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-25 19:53:11 +00:00
|
|
|
void A_Query(faddr *, char *);
|
|
|
|
void A_Query(faddr *t, char *replyid)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2002-03-31 20:07:04 +00:00
|
|
|
A_List(t, replyid, LIST_QUERY);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
2002-03-31 20:07:04 +00:00
|
|
|
|
|
|
|
|
2001-08-25 19:53:11 +00:00
|
|
|
void A_List(faddr *t, char *replyid, int Notify)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2002-03-31 15:04:34 +00:00
|
|
|
FILE *qp, *gp, *mp, *fi = NULL;
|
2002-03-31 13:09:23 +00:00
|
|
|
char *temp, *Group, *subject;
|
|
|
|
int i, First = TRUE, SubTot, Total = 0, Cons;
|
2002-02-11 21:49:10 +00:00
|
|
|
char Stat[5];
|
2002-06-17 20:36:06 +00:00
|
|
|
faddr *f, *g, *Temp;
|
2002-02-11 21:49:10 +00:00
|
|
|
sysconnect System;
|
2002-03-02 23:07:30 +00:00
|
|
|
long msgptr;
|
2002-03-29 22:58:53 +00:00
|
|
|
fpos_t fileptr,fileptr1,fileptr2;
|
2002-02-11 21:49:10 +00:00
|
|
|
|
2002-03-29 22:58:53 +00:00
|
|
|
subject = calloc(255, sizeof(char));
|
2002-03-31 15:04:34 +00:00
|
|
|
f = bestaka_s(t);
|
2002-08-16 20:50:28 +00:00
|
|
|
MacroVars("s", "s", nodes.Sysop);
|
|
|
|
MacroVars("K", "d", Notify);
|
|
|
|
MacroVars("y", "s", ascfnode(t, 0xff));
|
|
|
|
MacroVars("Y", "s", ascfnode(f, 0xff));
|
2002-03-29 22:58:53 +00:00
|
|
|
|
2002-03-31 20:07:04 +00:00
|
|
|
switch (Notify) {
|
|
|
|
case LIST_NOTIFY: Syslog('+', "AreaMgr: Notify to %s", ascfnode(t, 0xff));
|
|
|
|
sprintf(subject,"AreaMgr Notify");
|
|
|
|
GetRpSubject("areamgr.notify.list",subject);
|
2002-04-10 20:29:57 +00:00
|
|
|
fi = OpenMacro("areamgr.notify.list", nodes.Language, FALSE);
|
2002-03-31 20:07:04 +00:00
|
|
|
break;
|
|
|
|
case LIST_LIST: Syslog('+', "AreaMgr: List");
|
|
|
|
sprintf(subject,"AreaMgr list");
|
|
|
|
GetRpSubject("areamgr.list",subject);
|
2002-04-10 20:29:57 +00:00
|
|
|
fi = OpenMacro("areamgr.list", nodes.Language, FALSE);
|
2002-03-31 20:07:04 +00:00
|
|
|
break;
|
|
|
|
case LIST_QUERY: Syslog('+', "AreaMgr: Query");
|
|
|
|
sprintf(subject,"AreaMgr Query");
|
|
|
|
GetRpSubject("areamgr.query",subject);
|
2002-04-10 20:29:57 +00:00
|
|
|
fi = OpenMacro("areamgr.query", nodes.Language, FALSE);
|
2002-03-31 20:07:04 +00:00
|
|
|
break;
|
|
|
|
case LIST_UNLINK: Syslog('+', "AreaMgr: Unlinked");
|
|
|
|
sprintf(subject,"AreaMgr: Unlinked areas");
|
|
|
|
GetRpSubject("areamgr.unlink",subject);
|
2002-04-10 20:29:57 +00:00
|
|
|
fi = OpenMacro("areamgr.unlink", nodes.Language, FALSE);
|
2002-03-31 20:07:04 +00:00
|
|
|
break;
|
2002-03-29 22:58:53 +00:00
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
|
2002-03-31 20:07:04 +00:00
|
|
|
if (fi == NULL) {
|
|
|
|
MacroClear();
|
|
|
|
free(subject);
|
|
|
|
return;
|
|
|
|
}
|
2002-03-29 22:58:53 +00:00
|
|
|
|
|
|
|
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", subject, replyid)) != NULL) {
|
2002-02-11 21:49:10 +00:00
|
|
|
|
2002-03-02 23:07:30 +00:00
|
|
|
/*
|
|
|
|
* Mark begin of message in .pkt
|
|
|
|
*/
|
|
|
|
msgptr = ftell(qp);
|
|
|
|
|
2002-03-31 20:07:04 +00:00
|
|
|
if ((Notify == LIST_LIST) || (Notify == LIST_NOTIFY))
|
|
|
|
WriteMailGroups(qp, f);
|
|
|
|
|
|
|
|
MacroRead(fi, qp);
|
|
|
|
fgetpos(fi,&fileptr);
|
|
|
|
|
2002-03-02 13:27:44 +00:00
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2002-02-11 21:49:10 +00:00
|
|
|
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
|
2002-03-02 13:27:44 +00:00
|
|
|
if ((mp = fopen(temp, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
free(temp);
|
2002-03-29 22:58:53 +00:00
|
|
|
free(subject);
|
|
|
|
MacroClear();
|
2002-03-31 20:07:04 +00:00
|
|
|
fclose(fi);
|
2002-03-02 13:27:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
fread(&msgshdr, sizeof(msgshdr), 1, mp);
|
|
|
|
Cons = msgshdr.syssize / sizeof(System);
|
2002-03-02 13:27:44 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT"));
|
2002-03-02 13:27:44 +00:00
|
|
|
if ((gp = fopen(temp, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
free(temp);
|
2002-03-29 22:58:53 +00:00
|
|
|
free(subject);
|
|
|
|
MacroClear();
|
2002-03-02 13:27:44 +00:00
|
|
|
fclose(mp);
|
2002-03-31 20:07:04 +00:00
|
|
|
fclose(fi);
|
2002-03-02 13:27:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp);
|
2002-03-02 13:27:44 +00:00
|
|
|
free(temp);
|
2002-03-29 22:58:53 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
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) {
|
2002-06-17 20:36:06 +00:00
|
|
|
Temp = fido2faddr(mgroup.UseAka);
|
|
|
|
g = bestaka_s(Temp);
|
|
|
|
tidy_faddr(Temp);
|
2002-02-11 21:49:10 +00:00
|
|
|
if ((!strcmp(mgroup.Name, Group)) &&
|
2002-03-31 20:07:04 +00:00
|
|
|
(g->zone == f->zone) && (g->net == f->net) && (g->node == f->node) && (g->point == f->point)) {
|
2002-02-11 21:49:10 +00:00
|
|
|
SubTot = 0;
|
2002-03-31 20:07:04 +00:00
|
|
|
MacroVars("GJI", "sss",mgroup.Name, mgroup.Comment, aka2str(mgroup.UseAka) );
|
|
|
|
fsetpos(fi,&fileptr);
|
|
|
|
MacroRead(fi, qp);
|
|
|
|
fgetpos(fi,&fileptr1);
|
2002-02-11 21:49:10 +00:00
|
|
|
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';
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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';
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
}
|
2002-03-31 20:07:04 +00:00
|
|
|
if ( (Notify == LIST_LIST) || (Notify == LIST_NOTIFY)
|
2002-03-29 22:58:53 +00:00
|
|
|
|| ((Notify == LIST_QUERY) && ((Stat[0]=='S') || (Stat[1]=='R')))
|
|
|
|
|| ((Notify >= LIST_UNLINK) && ((Stat[0]!='S') && (Stat[1]!='R')))){
|
2002-03-31 20:07:04 +00:00
|
|
|
MacroVars("XDEsrpc", "sssdddd",
|
2002-03-29 22:58:53 +00:00
|
|
|
Stat, msgs.Tag, msgs.Name,
|
|
|
|
(Stat[0] == 'S'),
|
|
|
|
(Stat[1] == 'R'),
|
|
|
|
(Stat[2] == 'P'),
|
|
|
|
(Stat[3] == 'C')
|
|
|
|
);
|
2002-03-31 20:07:04 +00:00
|
|
|
fsetpos(fi,&fileptr1);
|
|
|
|
MacroRead(fi, qp);
|
|
|
|
fgetpos(fi,&fileptr2);
|
2002-03-29 22:58:53 +00:00
|
|
|
SubTot++;
|
|
|
|
Total++;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
} else
|
|
|
|
fseek(mp, msgshdr.syssize, SEEK_CUR);
|
|
|
|
}
|
2002-03-31 20:07:04 +00:00
|
|
|
MacroVars("ZC", "dd", (int) 0 , SubTot );
|
|
|
|
fsetpos(fi,&fileptr2);
|
|
|
|
if (((ftell(qp) - msgptr) / 1024) >= CFG.new_split) {
|
|
|
|
MacroVars("Z","d",1);
|
|
|
|
Syslog('-', " Splitting message at %ld bytes", ftell(qp) - msgptr);
|
|
|
|
CloseMail(qp, t);
|
|
|
|
qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", subject, replyid);
|
|
|
|
msgptr = ftell(qp);
|
|
|
|
}
|
|
|
|
MacroRead(fi, qp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
}
|
|
|
|
}
|
2002-03-31 20:07:04 +00:00
|
|
|
|
|
|
|
MacroVars("B", "d", Total );
|
|
|
|
MacroRead(fi, qp);
|
|
|
|
MacroClear();
|
|
|
|
fclose(fi);
|
2002-02-11 21:49:10 +00:00
|
|
|
fclose(mp);
|
|
|
|
fclose(gp);
|
|
|
|
fprintf(qp, "%s\r", TearLine());
|
|
|
|
CloseMail(qp, t);
|
|
|
|
} else
|
|
|
|
WriteError("Can't create netmail");
|
2002-03-29 22:58:53 +00:00
|
|
|
free(subject);
|
|
|
|
MacroClear();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-25 19:53:11 +00:00
|
|
|
void A_Flow(faddr *t, char *replyid, int Notify)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2002-03-31 15:04:34 +00:00
|
|
|
FILE *qp, *gp, *mp, *fi = NULL;
|
2002-03-31 13:09:23 +00:00
|
|
|
char *temp, *Group, *subject;
|
|
|
|
int i, First = TRUE, Cons;
|
2002-02-11 21:49:10 +00:00
|
|
|
char Stat[2];
|
2002-06-17 20:36:06 +00:00
|
|
|
faddr *f, *g, *Temp;
|
2002-02-11 21:49:10 +00:00
|
|
|
sysconnect System;
|
|
|
|
time_t Now;
|
|
|
|
struct tm *tt;
|
|
|
|
int lmonth;
|
2002-03-29 22:58:53 +00:00
|
|
|
long rlw, rlm, rlt, plw, plm, plt;
|
2002-03-02 23:07:30 +00:00
|
|
|
long msgptr;
|
2002-03-29 22:58:53 +00:00
|
|
|
fpos_t fileptr, fileptr1, fileptr2;
|
2002-02-11 21:49:10 +00:00
|
|
|
|
|
|
|
Now = time(NULL);
|
|
|
|
tt = localtime(&Now);
|
|
|
|
lmonth = tt->tm_mon;
|
|
|
|
if (lmonth)
|
|
|
|
lmonth--;
|
|
|
|
else
|
|
|
|
lmonth = 11;
|
|
|
|
|
2002-03-29 22:58:53 +00:00
|
|
|
subject = calloc(255, sizeof(char));
|
2002-03-31 15:04:34 +00:00
|
|
|
f = bestaka_s(t);
|
|
|
|
MacroVars("sKyY", "sdss", nodes.Sysop, Notify, ascfnode(t, 0xff), ascfnode(f, 0xf));
|
2002-03-29 22:58:53 +00:00
|
|
|
|
|
|
|
if (Notify){
|
2002-02-11 21:49:10 +00:00
|
|
|
Syslog('+', "AreaMgr: Flow report to %s", ascfnode(t, 0xff));
|
2002-03-29 22:58:53 +00:00
|
|
|
sprintf(subject,"AreaMgr Notify Flow Report");
|
|
|
|
GetRpSubject("areamgr.notify.flow",subject);
|
2002-04-10 20:29:57 +00:00
|
|
|
fi = OpenMacro("areamgr.notify.flow", nodes.Language, FALSE);
|
2002-03-29 22:58:53 +00:00
|
|
|
}else{
|
2002-02-11 21:49:10 +00:00
|
|
|
Syslog('+', "AreaMgr: Flow report");
|
2002-03-29 22:58:53 +00:00
|
|
|
sprintf(subject,"AreaMgr Flow Report");
|
|
|
|
GetRpSubject("areamgr.flow",subject);
|
2002-04-10 20:29:57 +00:00
|
|
|
fi = OpenMacro("areamgr.flow", nodes.Language, FALSE);
|
2002-03-31 20:07:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fi == 0) {
|
|
|
|
free(subject);
|
|
|
|
MacroClear();
|
|
|
|
return;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
|
2002-03-29 22:58:53 +00:00
|
|
|
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", subject, replyid)) != NULL) {
|
2002-03-02 23:07:30 +00:00
|
|
|
/*
|
|
|
|
* Mark begin of message in .pkt
|
|
|
|
*/
|
|
|
|
msgptr = ftell(qp);
|
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
|
2002-03-02 13:27:44 +00:00
|
|
|
if ((mp = fopen(temp, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
free(temp);
|
2002-03-29 22:58:53 +00:00
|
|
|
free(subject);
|
2002-03-31 20:07:04 +00:00
|
|
|
fclose(fi);
|
|
|
|
MacroClear();
|
2002-03-02 13:27:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
fread(&msgshdr, sizeof(msgshdr), 1, mp);
|
|
|
|
Cons = msgshdr.syssize / sizeof(System);
|
2002-03-02 13:27:44 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT"));
|
2002-03-02 13:27:44 +00:00
|
|
|
if ((gp = fopen(temp, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
free(temp);
|
2002-03-29 22:58:53 +00:00
|
|
|
free(subject);
|
2002-03-02 13:27:44 +00:00
|
|
|
fclose(mp);
|
2002-03-31 20:07:04 +00:00
|
|
|
fclose(fi);
|
|
|
|
MacroClear();
|
2002-03-02 13:27:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp);
|
2002-03-02 13:27:44 +00:00
|
|
|
free(temp);
|
2002-03-31 20:07:04 +00:00
|
|
|
|
|
|
|
MacroRead(fi, qp);
|
|
|
|
fgetpos(fi,&fileptr);
|
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
while (TRUE) {
|
|
|
|
Group = GetNodeMailGrp(First);
|
|
|
|
if (Group == NULL)
|
|
|
|
break;
|
|
|
|
First = FALSE;
|
|
|
|
|
2002-03-29 22:58:53 +00:00
|
|
|
plm = plw = plt = rlm = rlw = rlt = 0;
|
2002-02-11 21:49:10 +00:00
|
|
|
fseek(gp, mgrouphdr.hdrsize, SEEK_SET);
|
|
|
|
while (fread(&mgroup, mgrouphdr.recsize, 1, gp) == 1) {
|
2002-06-17 20:36:06 +00:00
|
|
|
Temp = fido2faddr(mgroup.UseAka);
|
|
|
|
g = bestaka_s(Temp);
|
|
|
|
tidy_faddr(Temp);
|
2002-02-11 21:49:10 +00:00
|
|
|
if ((!strcmp(mgroup.Name, Group)) &&
|
2002-03-31 20:07:04 +00:00
|
|
|
(g->zone == f->zone) && (g->net == f->net) && (g->node == f->node) && (g->point == f->point)) {
|
|
|
|
|
|
|
|
MacroVars("GJI", "sss",mgroup.Name, mgroup.Comment, aka2str(mgroup.UseAka) );
|
|
|
|
fsetpos(fi,&fileptr);
|
|
|
|
MacroRead(fi, qp);
|
|
|
|
fgetpos(fi,&fileptr1);
|
2002-02-11 21:49:10 +00:00
|
|
|
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';
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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';
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
}
|
2002-03-31 20:07:04 +00:00
|
|
|
MacroVars("XAPQRpqrx", "csddddddd",
|
2002-03-29 22:58:53 +00:00
|
|
|
Stat[0],
|
|
|
|
msgs.Tag,
|
|
|
|
msgs.Received.lweek,
|
|
|
|
msgs.Received.month[lmonth],
|
|
|
|
msgs.Received.total,
|
|
|
|
msgs.Posted.lweek,
|
|
|
|
msgs.Posted.month[lmonth],
|
|
|
|
msgs.Posted.total,
|
|
|
|
(Stat[0] == 'C')
|
|
|
|
);
|
2002-03-31 20:07:04 +00:00
|
|
|
fsetpos(fi,&fileptr1);
|
|
|
|
MacroRead(fi, qp);
|
|
|
|
fgetpos(fi,&fileptr2);
|
2002-03-29 22:58:53 +00:00
|
|
|
rlm += msgs.Received.month[lmonth];
|
|
|
|
rlw += msgs.Received.lweek;
|
|
|
|
rlt += msgs.Received.total;
|
|
|
|
plm += msgs.Posted.month[lmonth];
|
|
|
|
plw += msgs.Posted.lweek;
|
|
|
|
plt += msgs.Posted.total;
|
2002-02-11 21:49:10 +00:00
|
|
|
} else
|
|
|
|
fseek(mp, msgshdr.syssize, SEEK_CUR);
|
|
|
|
}
|
2002-03-31 20:07:04 +00:00
|
|
|
MacroVars("ZBCDbcd", "ddddddd", (int) 0 , rlw, rlm, rlt, plw, plm, plt);
|
|
|
|
fsetpos(fi,&fileptr2);
|
|
|
|
if (((ftell(qp) - msgptr) / 1024) >= CFG.new_split) {
|
|
|
|
MacroVars("Z","d",1);
|
|
|
|
Syslog('-', " Splitting message at %ld bytes", ftell(qp) - msgptr);
|
|
|
|
CloseMail(qp, t);
|
|
|
|
qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", subject, replyid);
|
|
|
|
msgptr = ftell(qp);
|
|
|
|
}
|
|
|
|
MacroRead(fi, qp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 20:07:04 +00:00
|
|
|
MacroRead(fi, qp);
|
|
|
|
MacroClear();
|
|
|
|
fclose(fi);
|
|
|
|
CloseMail(qp, t);
|
2002-02-11 21:49:10 +00:00
|
|
|
fclose(mp);
|
|
|
|
fclose(gp);
|
|
|
|
} else
|
|
|
|
WriteError("Can't create netmail");
|
2002-03-29 22:58:53 +00:00
|
|
|
free(subject);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-25 19:53:11 +00:00
|
|
|
void A_Status(faddr *, char *);
|
|
|
|
void A_Status(faddr *t, char *replyid)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2002-03-29 22:58:53 +00:00
|
|
|
FILE *fp, *fi;
|
2002-03-31 13:09:23 +00:00
|
|
|
int i;
|
|
|
|
char *subject;
|
2002-06-19 21:23:56 +00:00
|
|
|
faddr *ta;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-29 22:58:53 +00:00
|
|
|
subject = calloc(255, sizeof(char));
|
|
|
|
sprintf(subject,"AreaMgr Status");
|
2002-04-03 20:29:12 +00:00
|
|
|
Syslog('+', "AreaMgr: Status");
|
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (Miy == 0)
|
|
|
|
i = 11;
|
|
|
|
else
|
|
|
|
i = Miy - 1;
|
2002-06-19 21:23:56 +00:00
|
|
|
MacroVars("D", "d", nodes.Direct);
|
|
|
|
MacroVars("C", "d", nodes.Crash);
|
|
|
|
MacroVars("E", "d", nodes.Hold);
|
|
|
|
MacroVars("f", "d", nodes.Notify);
|
|
|
|
MacroVars("G", "c", nodes.Language);
|
|
|
|
MacroVars("v", "s", aka2str(nodes.RouteVia));
|
|
|
|
MacroVars("P", "d", nodes.MailSent.lweek);
|
|
|
|
MacroVars("Q", "d", nodes.MailSent.month[i]);
|
|
|
|
MacroVars("R", "d", nodes.MailSent.total);
|
|
|
|
MacroVars("p", "d", nodes.MailRcvd.lweek);
|
|
|
|
MacroVars("q", "d", nodes.MailRcvd.month[i]);
|
|
|
|
MacroVars("r", "d", nodes.MailRcvd.total);
|
|
|
|
MacroVars("s", "s", nodes.Sysop);
|
|
|
|
MacroVars("Y", "s", ascfnode(t, 0xff));
|
|
|
|
ta = bestaka_s(t);
|
|
|
|
MacroVars("y", "s", ascfnode(ta, 0xf));
|
|
|
|
tidy_faddr(ta);
|
|
|
|
|
2002-03-29 22:58:53 +00:00
|
|
|
GetRpSubject("areamgr.status",subject);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-04-10 20:29:57 +00:00
|
|
|
if ((fi = OpenMacro("areamgr.status", nodes.Language, FALSE)) == NULL ){
|
2002-03-31 20:07:04 +00:00
|
|
|
MacroClear();
|
|
|
|
free(subject);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-03-29 22:58:53 +00:00
|
|
|
if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", subject, replyid)) != NULL) {
|
2002-03-31 20:07:04 +00:00
|
|
|
MacroRead(fi, fp);
|
|
|
|
fclose(fi);
|
2002-02-11 21:49:10 +00:00
|
|
|
fprintf(fp, "%s\r", TearLine());
|
|
|
|
CloseMail(fp, t);
|
|
|
|
} else
|
|
|
|
WriteError("Can't create netmail");
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
|
|
|
free(subject);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-25 19:53:11 +00:00
|
|
|
void A_Unlinked(faddr *, char *);
|
|
|
|
void A_Unlinked(faddr *t, char *replyid)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2002-03-31 20:07:04 +00:00
|
|
|
A_List(t, replyid, LIST_UNLINK);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void A_Disconnect(faddr *, char *, FILE *);
|
|
|
|
void A_Disconnect(faddr *t, char *Area, FILE *tmp)
|
|
|
|
{
|
2002-02-11 21:49:10 +00:00
|
|
|
int i, First;
|
|
|
|
char *Group;
|
2002-06-17 20:36:06 +00:00
|
|
|
faddr *b, *Temp;
|
2002-02-11 21:49:10 +00:00
|
|
|
sysconnect Sys;
|
|
|
|
|
|
|
|
Syslog('+', "AreaMgr: \"%s\"", Area);
|
|
|
|
ShiftBuf(Area, 1);
|
|
|
|
for (i=0; i < strlen(Area); i++ )
|
|
|
|
Area[i]=toupper(Area[i]);
|
|
|
|
|
|
|
|
if (!SearchMsgs(Area)) {
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, "Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_DISC_NOTFOUND",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-03-02 13:27:44 +00:00
|
|
|
Syslog('+', " Area not found");
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, "Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_DISC_NOTGROUP",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-03-02 13:27:44 +00:00
|
|
|
Syslog('+', " Group %s not available for %s", mgroup.Name, ascfnode(t, 0x1f));
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
b = bestaka_s(t);
|
2002-06-17 20:36:06 +00:00
|
|
|
Temp = fido2faddr(msgs.Aka);
|
|
|
|
i = metric(b, Temp);
|
|
|
|
tidy_faddr(Temp);
|
2002-02-11 21:49:10 +00:00
|
|
|
Syslog('m', "Aka match level is %d", i);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-02 16:10:54 +00:00
|
|
|
if (i >= METRIC_NET) {
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, "Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_DISC_BADADD",Area,ascfnode(t, 0x1f),"","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-03-02 13:27:44 +00:00
|
|
|
Syslog('+', " %s may not disconnect from group %s", ascfnode(t, 0x1f), mgroup.Name);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
memset(&Sys, 0, sizeof(Sys));
|
|
|
|
memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr));
|
|
|
|
Sys.sendto = FALSE;
|
|
|
|
Sys.receivefrom = FALSE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (!MsgSystemConnected(Sys)) {
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_DISC_NC",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-03-02 13:27:44 +00:00
|
|
|
Syslog('+', " %s is not connected to %s", ascfnode(t, 0x1f), Area);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (MsgSystemConnect(&Sys, FALSE)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
/*
|
|
|
|
* Make sure to write an overview afterwards.
|
|
|
|
*/
|
|
|
|
a_list = TRUE;
|
|
|
|
Syslog('+', "Disconnected echo area %s", Area);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","OK_DISC",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_DISC_NOTAVAIL",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-02-11 21:49:10 +00:00
|
|
|
Syslog('+', "Didn't disconnect %s from mandatory or cutoff echo area %s", ascfnode(t, 0x1f), Area);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void A_Connect(faddr *, char *, FILE *);
|
|
|
|
void A_Connect(faddr *t, char *Area, FILE *tmp)
|
|
|
|
{
|
2002-03-03 16:28:10 +00:00
|
|
|
int i, First;
|
|
|
|
char *Group, *temp;
|
2002-06-17 20:36:06 +00:00
|
|
|
faddr *b, *Temp;
|
2002-02-11 21:49:10 +00:00
|
|
|
sysconnect Sys;
|
2002-03-03 16:28:10 +00:00
|
|
|
FILE *gp;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
Syslog('+', "AreaMgr: \"%s\"", printable(Area, 0));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (Area[0] == '+')
|
|
|
|
ShiftBuf(Area, 1);
|
|
|
|
for (i=0; i < strlen(Area); i++ )
|
|
|
|
Area[i]=toupper(Area[i]);
|
|
|
|
|
|
|
|
if (!SearchMsgs(Area)) {
|
2002-03-15 21:16:16 +00:00
|
|
|
/*
|
|
|
|
* Close noderecord, autocreate will destroy it.
|
|
|
|
*/
|
|
|
|
UpdateNode();
|
|
|
|
|
2002-03-03 15:09:59 +00:00
|
|
|
Syslog('m', " Area not found, trying to create");
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT"));
|
|
|
|
if ((gp = fopen(temp, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
free(temp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp);
|
|
|
|
fseek(gp, mgrouphdr.hdrsize, SEEK_SET);
|
|
|
|
|
|
|
|
while ((fread(&mgroup, mgrouphdr.recsize, 1, gp)) == 1) {
|
|
|
|
if ((mgroup.UseAka.zone == t->zone) && (mgroup.UseAka.net == t->net) && mgroup.UpLink.zone &&
|
|
|
|
strlen(mgroup.AreaFile) && mgroup.Active && mgroup.UserChange) {
|
2002-05-12 17:59:55 +00:00
|
|
|
if (CheckEchoGroup(Area, mgroup.UpLink.zone, t) == 0) {
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_CONN_FORWARD",Area,aka2str(mgroup.UpLink),"","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-03-03 15:09:59 +00:00
|
|
|
break;
|
2002-03-03 16:28:10 +00:00
|
|
|
}
|
|
|
|
}
|
2002-03-03 15:09:59 +00:00
|
|
|
}
|
|
|
|
fclose(gp);
|
|
|
|
free(temp);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restore noderecord and try to load the area again
|
|
|
|
*/
|
|
|
|
SearchNodeFaddr(t);
|
|
|
|
if (!SearchMsgs(Area)) {
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, "Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_CONN_NOTFOUND",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-03-03 15:09:59 +00:00
|
|
|
Syslog('+', "Area %s not found", Area);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-03-03 15:09:59 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, "Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_CONN_NOTGROUP",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-03-02 13:27:44 +00:00
|
|
|
Syslog('+', " Group %s not available for node %s", mgroup.Name, ascfnode(t, 0x1f));
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
b = bestaka_s(t);
|
2002-06-17 20:36:06 +00:00
|
|
|
Temp = fido2faddr(msgs.Aka);
|
|
|
|
i = metric(b, Temp);
|
|
|
|
tidy_faddr(Temp);
|
2002-02-11 21:49:10 +00:00
|
|
|
Syslog('m', "Aka match level is %d", i);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-02 16:10:54 +00:00
|
|
|
if (i >= METRIC_NET) {
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_CONN_BADADD",Area,ascfnode(t, 0x1f),"","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-03-02 13:27:44 +00:00
|
|
|
Syslog('+', " %s may not connect to group %s", ascfnode(t, 0x1f), mgroup.Name);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
memset(&Sys, 0, sizeof(Sys));
|
|
|
|
memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr));
|
|
|
|
Sys.sendto = TRUE;
|
|
|
|
Sys.receivefrom = TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (MsgSystemConnected(Sys)) {
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_CONN_ALREADY",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-03-02 13:27:44 +00:00
|
|
|
Syslog('+', " %s is already connected to %s", ascfnode(t, 0x1f), Area);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (MsgSystemConnect(&Sys, TRUE)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
/*
|
|
|
|
* Make sure to write an overview afterwards.
|
|
|
|
*/
|
|
|
|
a_list = TRUE;
|
|
|
|
Syslog('+', "Connected echo area %s", Area);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","OK_CONN",Area,aka2str(msgs.Aka),"","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_CONN_NOTAVAIL",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-02-11 21:49:10 +00:00
|
|
|
WriteError("Can't connect node %s to echo area %s", ascfnode(t, 0x1f), Area);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void A_All(faddr *, int, FILE *, char *);
|
|
|
|
void A_All(faddr *t, int Connect, FILE *tmp, char *Grp)
|
|
|
|
{
|
2002-02-11 21:49:10 +00:00
|
|
|
FILE *mp, *gp;
|
2002-03-02 13:27:44 +00:00
|
|
|
char *Group, *temp;
|
2002-06-17 20:36:06 +00:00
|
|
|
faddr *f, *Temp;
|
2002-02-11 21:49:10 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
f = bestaka_s(t);
|
2002-03-02 19:50:13 +00:00
|
|
|
temp = xstrcpy(ascfnode(t, 0x1f));
|
|
|
|
Syslog('m', "Bestaka for %s is %s", temp, ascfnode(f, 0x1f));
|
|
|
|
free(temp);
|
2002-02-11 21:49:10 +00:00
|
|
|
|
2002-03-02 13:27:44 +00:00
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2002-02-11 21:49:10 +00:00
|
|
|
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
|
2002-03-02 13:27:44 +00:00
|
|
|
if ((mp = fopen(temp, "r+")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
free(temp);
|
|
|
|
return;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
fread(&msgshdr, sizeof(msgshdr), 1, mp);
|
|
|
|
Cons = msgshdr.syssize / sizeof(Sys);
|
2002-03-02 13:27:44 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT"));
|
2002-03-02 13:27:44 +00:00
|
|
|
if ((gp = fopen(temp, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
free(temp);
|
|
|
|
fclose(mp);
|
|
|
|
return;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp);
|
2002-03-02 13:27:44 +00:00
|
|
|
free(temp);
|
2002-02-11 21:49:10 +00:00
|
|
|
|
|
|
|
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(mp, msgshdr.hdrsize, SEEK_SET);
|
|
|
|
|
|
|
|
while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) {
|
2002-06-17 20:36:06 +00:00
|
|
|
Temp = fido2faddr(msgs.Aka);
|
2002-03-02 19:50:13 +00:00
|
|
|
if ((!strcmp(Group, msgs.Group)) && (msgs.Active) && (!msgs.Mandatory) && strlen(msgs.Tag) &&
|
|
|
|
((msgs.Type == ECHOMAIL) || (msgs.Type == NEWS) || (msgs.Type == LIST)) &&
|
2002-06-17 20:36:06 +00:00
|
|
|
(metric(Temp, f) < METRIC_NET)) {
|
2002-02-11 21:49:10 +00:00
|
|
|
|
|
|
|
if (Connect) {
|
|
|
|
Link = FALSE;
|
|
|
|
for (i = 0; i < Cons; i++) {
|
|
|
|
fread(&Sys, sizeof(Sys), 1, mp);
|
2002-06-17 20:36:06 +00:00
|
|
|
tidy_faddr(Temp);
|
|
|
|
Temp = fido2faddr(Sys.aka);
|
|
|
|
if (metric(Temp, t) == METRIC_EQUAL)
|
2002-02-11 21:49:10 +00:00
|
|
|
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);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","OK_CONN",msgs.Tag,aka2str(msgs.Aka),"","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
a_list = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fseek(mp, Pos, SEEK_SET);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < Cons; i++) {
|
|
|
|
fread(&Sys, sizeof(Sys), 1, mp);
|
2002-06-17 20:36:06 +00:00
|
|
|
tidy_faddr(Temp);
|
|
|
|
Temp = fido2faddr(Sys.aka);
|
|
|
|
if ((metric(Temp, t) == METRIC_EQUAL) && (!Sys.cutoff)) {
|
2002-02-11 21:49:10 +00:00
|
|
|
memset(&Sys, 0, sizeof(Sys));
|
|
|
|
fseek(mp, - sizeof(Sys), SEEK_CUR);
|
|
|
|
fwrite(&Sys, sizeof(Sys), 1, mp);
|
|
|
|
Syslog('+', "AreaMgr: Disconnected %s", msgs.Tag);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","OK_DISC",msgs.Tag,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
a_list = TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
} else
|
|
|
|
fseek(mp, msgshdr.syssize, SEEK_CUR);
|
2002-06-17 20:36:06 +00:00
|
|
|
tidy_faddr(Temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
}
|
|
|
|
fclose(gp);
|
|
|
|
fclose(mp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void A_Group(faddr *, char *, int, FILE *);
|
|
|
|
void A_Group(faddr *t, char *Area, int Connect, FILE *tmp)
|
|
|
|
{
|
2002-02-11 21:49:10 +00:00
|
|
|
int i;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
ShiftBuf(Area, 2);
|
|
|
|
CleanBuf(Area);
|
2002-03-02 13:27:44 +00:00
|
|
|
for (i = 0; i < strlen(Area); i++ )
|
|
|
|
Area[i] = toupper(Area[i]);
|
2002-02-11 21:49:10 +00:00
|
|
|
A_All(t, Connect, tmp, Area);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void A_Pause(faddr *, int, FILE *);
|
|
|
|
void A_Pause(faddr *t, int Pause, FILE *tmp)
|
|
|
|
{
|
2002-03-02 13:27:44 +00:00
|
|
|
FILE *mp;
|
2002-06-17 20:36:06 +00:00
|
|
|
faddr *f, *Temp;
|
2002-03-02 13:27:44 +00:00
|
|
|
int i, Cons;
|
|
|
|
sysconnect Sys;
|
|
|
|
char *temp;
|
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (Pause)
|
|
|
|
Syslog('+', "AreaMgr: Pause");
|
|
|
|
else
|
|
|
|
Syslog('+', "AreaMgr: Resume");
|
2002-03-02 13:27:44 +00:00
|
|
|
|
|
|
|
f = bestaka_s(t);
|
|
|
|
Syslog('m', "Bestaka for %s is %s", ascfnode(t, 0x1f), ascfnode(f, 0x1f));
|
|
|
|
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
|
|
|
|
if ((mp = fopen(temp, "r+")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
free(temp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
free(temp);
|
|
|
|
fread(&msgshdr, sizeof(msgshdr), 1, mp);
|
|
|
|
Cons = msgshdr.syssize / sizeof(Sys);
|
|
|
|
|
|
|
|
while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) {
|
|
|
|
if (msgs.Active) {
|
|
|
|
for (i = 0; i < Cons; i++) {
|
|
|
|
fread(&Sys, sizeof(Sys), 1, mp);
|
2002-06-17 20:36:06 +00:00
|
|
|
Temp = fido2faddr(Sys.aka);
|
|
|
|
if ((metric(Temp, t) == METRIC_EQUAL) && (!Sys.cutoff)) {
|
2002-03-02 13:27:44 +00:00
|
|
|
Sys.pause = Pause;
|
|
|
|
fseek(mp, - sizeof(Sys), SEEK_CUR);
|
|
|
|
fwrite(&Sys, sizeof(Sys), 1, mp);
|
|
|
|
Syslog('+', "AreaMgr: %s area %s", Pause?"Pause":"Resume", msgs.Tag);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Areamgr");
|
2002-03-31 21:33:16 +00:00
|
|
|
MacroVars("RABCDE", "ssdsss","OK_PAUSE",msgs.Tag,Pause,"","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",tmp);
|
2002-03-02 13:27:44 +00:00
|
|
|
a_list = TRUE;
|
|
|
|
}
|
2002-06-17 20:36:06 +00:00
|
|
|
tidy_faddr(Temp);
|
2002-03-02 13:27:44 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fseek(mp, msgshdr.syssize, SEEK_CUR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(mp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void A_Rescan(faddr *, char *, FILE *);
|
|
|
|
void A_Rescan(faddr *t, char *Area, FILE *tmp)
|
|
|
|
{
|
2002-02-11 21:49:10 +00:00
|
|
|
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);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Areamgr");
|
2002-02-11 21:49:10 +00:00
|
|
|
if (result == 0){
|
2002-03-31 20:07:04 +00:00
|
|
|
MacroVars("RABCDE", "ssdsss","OK_RESCAN",Area,a_msgs,"","","");
|
|
|
|
MsgResult("areamgr.responses",tmp);
|
|
|
|
} else if (result == 1) {
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_RESCAN_UNK",Area,"","","","");
|
|
|
|
MsgResult("areamgr.responses",tmp);
|
|
|
|
} else if (result == 2) {
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_RESCAN_NOTAVAIL",Area,ascfnode(t, 0x1f),"","","");
|
|
|
|
MsgResult("areamgr.responses",tmp);
|
|
|
|
} else {
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_RESCAN_FATAL",Area,ascfnode(t, 0x1f),"","","");
|
|
|
|
MsgResult("areamgr.responses",tmp);
|
|
|
|
}
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void A_Msgs(char *, int);
|
|
|
|
void A_Msgs(char *Buf, int skip)
|
|
|
|
{
|
2002-02-11 21:49:10 +00:00
|
|
|
/*
|
|
|
|
* First strip leading garbage
|
|
|
|
*/
|
|
|
|
ShiftBuf(Buf, skip);
|
|
|
|
CleanBuf(Buf);
|
|
|
|
a_msgs = strtoul( Buf, (char **)NULL, 10 );
|
|
|
|
Syslog('+', "AreaMgr: msgs %s ", Buf );
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-25 19:53:11 +00:00
|
|
|
int AreaMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int flags, FILE *fp)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2002-02-11 21:49:10 +00:00
|
|
|
int i, rc = 0, spaces;
|
2002-03-29 22:58:53 +00:00
|
|
|
char *Buf, *subject;
|
2002-02-11 21:49:10 +00:00
|
|
|
FILE *tmp, *np;
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
/*
|
2002-02-11 21:49:10 +00:00
|
|
|
* Make sure we have the nodes record loaded
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2002-03-02 15:42:08 +00:00
|
|
|
SearchNodeFaddr(f);
|
2002-02-11 21:49:10 +00:00
|
|
|
|
|
|
|
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';
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (!strncmp(Buf, "---", 3))
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (strlen(Buf) && (*(Buf) != '\001') && (spaces <= 1)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
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);
|
2002-03-29 22:58:53 +00:00
|
|
|
else if (!strncasecmp(Buf, "%passive", 8))
|
|
|
|
A_Pause(f, TRUE, tmp);
|
|
|
|
else if (!strncasecmp(Buf, "%active", 7))
|
|
|
|
A_Pause(f, FALSE, tmp);
|
2002-02-11 21:49:10 +00:00
|
|
|
else if (!strncasecmp(Buf, "%password", 9))
|
2002-03-29 22:58:53 +00:00
|
|
|
MgrPasswd(f, Buf, tmp, 9, 0);
|
2002-02-11 21:49:10 +00:00
|
|
|
else if (!strncasecmp(Buf, "%pwd", 4))
|
2002-03-29 22:58:53 +00:00
|
|
|
MgrPasswd(f, Buf, tmp, 4, 0);
|
2002-02-11 21:49:10 +00:00
|
|
|
else if (!strncasecmp(Buf, "%notify", 7))
|
2002-03-29 22:58:53 +00:00
|
|
|
MgrNotify(f, Buf, tmp, 0);
|
2002-02-11 21:49:10 +00:00
|
|
|
else if (*(Buf) == '-')
|
|
|
|
A_Disconnect(f, Buf, tmp);
|
|
|
|
else
|
|
|
|
A_Connect(f, Buf, tmp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the temporary response file isn't empty,
|
|
|
|
* create a response netmail about what we did.
|
|
|
|
*/
|
|
|
|
if (ftell(tmp)) {
|
2002-03-29 22:58:53 +00:00
|
|
|
subject=calloc(256,sizeof(char));
|
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Areamgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","","","","","","");
|
|
|
|
sprintf(subject,"Your AreaMgr request");
|
|
|
|
GetRpSubject("areamgr.responses",subject);
|
|
|
|
if ((np = SendMgrMail(f, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", subject, replyid)) != NULL) {
|
|
|
|
MacroVars("RABCDE", "ssssss","WELLCOME","","","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",np);
|
2002-03-31 21:33:16 +00:00
|
|
|
fprintf(np, "\r");
|
2002-02-11 21:49:10 +00:00
|
|
|
fseek(tmp, 0, SEEK_SET);
|
|
|
|
|
|
|
|
while ((fgets(Buf, 2048, tmp)) != NULL) {
|
2002-03-29 22:58:53 +00:00
|
|
|
while ((Buf[strlen(Buf) - 1]=='\n') || (Buf[strlen(Buf) - 1]=='\r')) {
|
|
|
|
Buf[strlen(Buf) - 1] = '\0';
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
fprintf(np, "%s\r", Buf);
|
|
|
|
}
|
2002-03-31 21:33:16 +00:00
|
|
|
fprintf(np, "\r");
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("RABCDE", "ssssss","GOODBYE","","","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("areamgr.responses",np);
|
2002-03-31 21:33:16 +00:00
|
|
|
fprintf(np, "\r%s\r", TearLine());
|
2002-02-11 21:49:10 +00:00
|
|
|
CloseMail(np, t);
|
|
|
|
} else
|
|
|
|
WriteError("Can't create netmail");
|
2002-03-29 22:58:53 +00:00
|
|
|
free(subject);
|
2002-02-11 21:49:10 +00:00
|
|
|
}
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
free(Buf);
|
|
|
|
fclose(tmp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (a_stat)
|
|
|
|
A_Status(f, replyid);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (a_query)
|
|
|
|
A_Query(f, replyid);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (a_list)
|
2002-08-16 20:50:28 +00:00
|
|
|
A_List(f, replyid, LIST_LIST);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (a_flow)
|
|
|
|
A_Flow(f, replyid, FALSE);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (a_unlnk)
|
|
|
|
A_Unlinked(f, replyid);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (a_help)
|
|
|
|
A_Help(f, replyid);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
return rc;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-03-31 20:07:04 +00:00
|
|
|
|