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 ...............: FileMgr
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
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.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "../lib/libs.h"
|
|
|
|
#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/dbtic.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"
|
2002-04-18 19:39:23 +00:00
|
|
|
#include "createf.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "filemgr.h"
|
|
|
|
|
2002-03-29 22:58:53 +00:00
|
|
|
#define LIST_LIST 0
|
|
|
|
#define LIST_NOTIFY 1
|
|
|
|
#define LIST_QUERY 2
|
|
|
|
#define LIST_UNLINK 3
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* External declarations
|
|
|
|
*/
|
|
|
|
extern int do_quiet;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Global variables
|
|
|
|
*/
|
|
|
|
extern int net_bad; /* Bad netmails (tracking errors */
|
|
|
|
|
|
|
|
int filemgr = 0; /* Nr of FileMgr messages */
|
2002-03-02 15:42:08 +00:00
|
|
|
int f_help = FALSE; /* Send FileMgr help */
|
|
|
|
int f_list = FALSE; /* Send FileMgr list */
|
|
|
|
int f_query = FALSE; /* Send FileMgr query */
|
|
|
|
int f_stat = FALSE; /* Send FileMgr status */
|
|
|
|
int f_unlnk = FALSE; /* Send FileMgr unlink */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-25 19:53:11 +00:00
|
|
|
void F_Help(faddr *, char *);
|
|
|
|
void F_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-02-11 21:49:10 +00:00
|
|
|
|
|
|
|
Syslog('+', "FileMgr: Help");
|
2002-03-29 22:58:53 +00:00
|
|
|
subject=calloc(255,sizeof(char));
|
|
|
|
sprintf(subject,"FileMgr help");
|
|
|
|
GetRpSubject("filemgr.help",subject);
|
|
|
|
|
|
|
|
if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", subject, replyid)) != NULL) {
|
2002-04-10 20:29:57 +00:00
|
|
|
if ((fi = OpenMacro("filemgr.help", nodes.Language, FALSE)) != NULL ){
|
2002-03-31 15:04:34 +00:00
|
|
|
MacroVars("sAYP", "ssss", nodes.Sysop, (char *)"Filemgr", ascfnode(bestaka_s(t), 0xf), nodes.Fpasswd );
|
|
|
|
MacroRead(fi, fp);
|
|
|
|
MacroClear();
|
|
|
|
fclose(fi);
|
2002-03-29 22:58:53 +00:00
|
|
|
}
|
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
|
|
|
free(subject);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-25 19:53:11 +00:00
|
|
|
void F_Query(faddr *, char *);
|
|
|
|
void F_Query(faddr *t, char *replyid)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2002-03-31 20:07:04 +00:00
|
|
|
F_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 F_List(faddr *t, char *replyid, int Notify)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2002-03-31 20:07:04 +00:00
|
|
|
FILE *qp, *gp, *fp, *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[4];
|
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;
|
|
|
|
|
|
|
|
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-31 20:07:04 +00:00
|
|
|
|
|
|
|
switch (Notify) {
|
|
|
|
case LIST_NOTIFY: Syslog('+', "FileMgr: Notify to %s", ascfnode(t, 0xff));
|
|
|
|
sprintf(subject,"FileMgr Notify");
|
|
|
|
GetRpSubject("filemgr.notify.list",subject);
|
2002-04-10 20:29:57 +00:00
|
|
|
fi=OpenMacro("filemgr.notify.list", nodes.Language, FALSE);
|
2002-03-31 20:07:04 +00:00
|
|
|
break;
|
|
|
|
case LIST_LIST: Syslog('+', "FileMgr: List");
|
|
|
|
sprintf(subject,"FileMgr list");
|
|
|
|
GetRpSubject("filemgr.list",subject);
|
2002-04-10 20:29:57 +00:00
|
|
|
fi=OpenMacro("filemgr.list", nodes.Language, FALSE);
|
2002-03-31 20:07:04 +00:00
|
|
|
break;
|
|
|
|
case LIST_QUERY: Syslog('+', "FileMgr: Query");
|
|
|
|
sprintf(subject,"FileMgr Query");
|
|
|
|
GetRpSubject("filemgr.query",subject);
|
2002-04-10 20:29:57 +00:00
|
|
|
fi=OpenMacro("filemgr.query", nodes.Language, FALSE);
|
2002-03-31 20:07:04 +00:00
|
|
|
break;
|
|
|
|
default: Syslog('+', "FileMgr: Unlinked");
|
|
|
|
sprintf(subject,"FileMgr: Unlinked areas");
|
|
|
|
GetRpSubject("filemgr.unlink",subject);
|
2002-04-10 20:29:57 +00:00
|
|
|
fi=OpenMacro("filemgr.unlink", nodes.Language, FALSE);
|
2002-03-31 20:07:04 +00:00
|
|
|
break;
|
2002-03-29 22:58:53 +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
|
|
|
}
|
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 *)"Filemgr", 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-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
|
|
|
WriteFileGroups(qp, f);
|
2002-03-31 20:07:04 +00:00
|
|
|
|
|
|
|
MacroRead(fi, qp);
|
|
|
|
fgetpos(fi,&fileptr);
|
2002-03-02 15:42:08 +00:00
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2002-02-11 21:49:10 +00:00
|
|
|
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
|
2002-03-02 15:42:08 +00:00
|
|
|
if ((fp = 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 15:42:08 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
fread(&tichdr, sizeof(tichdr), 1, fp);
|
|
|
|
Cons = tichdr.syssize / sizeof(System);
|
2002-03-02 15:42:08 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
|
2002-03-02 15:42:08 +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 15:42:08 +00:00
|
|
|
fclose(fp);
|
2002-03-31 20:07:04 +00:00
|
|
|
fclose(fi);
|
2002-03-02 15:42:08 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
|
2002-03-02 15:42:08 +00:00
|
|
|
free(temp);
|
2002-02-11 21:49:10 +00:00
|
|
|
|
|
|
|
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) {
|
2002-06-17 20:36:06 +00:00
|
|
|
Temp = fido2faddr(fgroup.UseAka);
|
|
|
|
g = bestaka_s(Temp);
|
2002-02-11 21:49:10 +00:00
|
|
|
if ((!strcmp(fgroup.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",fgroup.Name, fgroup.Comment, aka2str(fgroup.UseAka) );
|
|
|
|
fsetpos(fi,&fileptr);
|
|
|
|
MacroRead(fi, qp);
|
|
|
|
fgetpos(fi,&fileptr1);
|
2002-02-11 21:49:10 +00:00
|
|
|
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';
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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';
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
}
|
2002-03-29 22:58:53 +00:00
|
|
|
if ( (Notify == LIST_LIST)
|
|
|
|
|| (Notify == LIST_NOTIFY)
|
|
|
|
|| ((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("XDEsrp", "sssddd",
|
2002-03-29 22:58:53 +00:00
|
|
|
Stat, tic.Name, tic.Comment,
|
|
|
|
(Stat[0] == 'S'),
|
|
|
|
(Stat[1] == 'R'),
|
|
|
|
(Stat[2] == 'P')
|
|
|
|
);
|
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(fp, tichdr.syssize, SEEK_CUR);
|
|
|
|
}
|
2002-03-31 20:07:04 +00:00
|
|
|
MacroVars("ZA", "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 *)"Filemgr", subject, replyid);
|
|
|
|
msgptr = ftell(qp);
|
2002-03-02 23:07:30 +00:00
|
|
|
}
|
2002-03-31 20:07:04 +00:00
|
|
|
MacroRead(fi, qp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-06-17 20:36:06 +00:00
|
|
|
tidy_faddr(Temp);
|
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(fp);
|
|
|
|
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 F_Status(faddr *, char *);
|
|
|
|
void F_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;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-29 22:58:53 +00:00
|
|
|
subject = calloc(255, sizeof(char));
|
|
|
|
sprintf(subject,"FileMgr Status");
|
2002-02-11 21:49:10 +00:00
|
|
|
Syslog('+', "FileMgr: Status");
|
|
|
|
if (Miy == 0)
|
|
|
|
i = 11;
|
|
|
|
else
|
|
|
|
i = Miy - 1;
|
2002-04-03 20:29:12 +00:00
|
|
|
MacroVars("ABCDEfGIJabcdefghijkls", "ddddddddddddddddddddds",
|
2002-03-29 22:58:53 +00:00
|
|
|
nodes.Message,
|
|
|
|
nodes.Tic,
|
|
|
|
nodes.AdvTic,
|
|
|
|
nodes.Notify,
|
|
|
|
nodes.Billing,
|
|
|
|
nodes.BillDirect,
|
|
|
|
nodes.Debet,
|
|
|
|
nodes.Credit,
|
|
|
|
nodes.WarnLevel,
|
|
|
|
nodes.FilesSent.lweek,
|
|
|
|
nodes.FilesSent.month[i],
|
|
|
|
nodes.FilesSent.total,
|
|
|
|
nodes.F_KbSent.lweek,
|
|
|
|
nodes.F_KbSent.month[i],
|
|
|
|
nodes.F_KbSent.total,
|
|
|
|
nodes.FilesRcvd.lweek,
|
|
|
|
nodes.FilesRcvd.month[i],
|
|
|
|
nodes.FilesRcvd.total,
|
|
|
|
nodes.F_KbRcvd.lweek,
|
|
|
|
nodes.F_KbRcvd.month[i],
|
|
|
|
nodes.F_KbRcvd.total,
|
|
|
|
nodes.Sysop
|
|
|
|
);
|
|
|
|
GetRpSubject("filemgr.status",subject);
|
|
|
|
|
2002-04-10 20:29:57 +00:00
|
|
|
if ((fi = OpenMacro("filemgr.status", nodes.Language, FALSE)) == NULL ) {
|
2002-03-31 20:07:04 +00:00
|
|
|
free(subject);
|
|
|
|
MacroClear();
|
|
|
|
return;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
|
2002-03-31 20:07:04 +00:00
|
|
|
if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", subject, replyid)) != NULL) {
|
|
|
|
MacroRead(fi, fp);
|
|
|
|
MacroClear();
|
|
|
|
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 F_Unlinked(faddr *, char *);
|
|
|
|
void F_Unlinked(faddr *t, char *replyid)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2002-03-31 20:07:04 +00:00
|
|
|
F_List(t, replyid, LIST_UNLINK);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void F_Disconnect(faddr *, char *, FILE *);
|
|
|
|
void F_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('+', "FileMgr: %s", Area);
|
|
|
|
ShiftBuf(Area, 1);
|
2002-03-02 15:42:08 +00:00
|
|
|
for (i = 0; i < strlen(Area); i++)
|
|
|
|
Area[i] = toupper(Area[i]);
|
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (!SearchTic(Area)) {
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, "Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_DISC_NOTFOUND",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.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", tic.Name, fgroup.Name);
|
|
|
|
|
|
|
|
First = TRUE;
|
|
|
|
while ((Group = GetNodeFileGrp(First)) != NULL) {
|
|
|
|
First = FALSE;
|
|
|
|
if (strcmp(Group, fgroup.Name) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (Group == NULL) {
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, "Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_DISC_NOTGROUP",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.responses",tmp);
|
2002-03-02 13:27:44 +00:00
|
|
|
Syslog('+', " Group %s not available for %s", fgroup.Name, ascfnode(t, 0x1f));
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
b = bestaka_s(t);
|
2002-06-17 20:36:06 +00:00
|
|
|
Temp = fido2faddr(tic.Aka);
|
|
|
|
i = metric(b, Temp);
|
|
|
|
tidy_faddr(Temp);
|
2002-02-11 21:49:10 +00:00
|
|
|
Syslog('m', "Aka match level is %d", i);
|
|
|
|
|
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, "Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_DISC_BADADD",Area,ascfnode(t, 0x1f),"","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.responses",tmp);
|
2002-03-02 13:27:44 +00:00
|
|
|
Syslog('+', " %s may not disconnect from group %s", ascfnode(t, 0x1f), fgroup.Name);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&Sys, 0, sizeof(Sys));
|
|
|
|
memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr));
|
|
|
|
Sys.sendto = FALSE;
|
|
|
|
Sys.receivefrom = FALSE;
|
|
|
|
|
|
|
|
if (!TicSystemConnected(Sys)) {
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_DISC_NC",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.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;
|
|
|
|
}
|
|
|
|
|
2002-03-12 19:41:41 +00:00
|
|
|
if (TicSystemConnect(&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
|
|
|
|
*/
|
|
|
|
f_list = TRUE;
|
|
|
|
Syslog('+', "Disconnected file area %s", Area);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","OK_DISC",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.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,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_DISC_NOTAVAIL",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.responses",tmp);
|
2002-02-11 21:49:10 +00:00
|
|
|
Syslog('+', "Didn't disconnect %s from mandatory file area %s", ascfnode(t, 0x1f), Area);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-31 20:07:04 +00:00
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
void F_Connect(faddr *, char *, FILE *);
|
|
|
|
void F_Connect(faddr *t, char *Area, FILE *tmp)
|
|
|
|
{
|
2002-02-11 21:49:10 +00:00
|
|
|
int i, First;
|
2002-04-18 19:39:23 +00:00
|
|
|
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-04-18 19:39:23 +00:00
|
|
|
FILE *gp;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
Syslog('+', "FileMgr: %s", Area);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (Area[0] == '+')
|
|
|
|
ShiftBuf(Area, 1);
|
2002-03-02 15:42:08 +00:00
|
|
|
for (i = 0; i < strlen(Area); i++)
|
|
|
|
Area[i] = toupper(Area[i]);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (!SearchTic(Area)) {
|
2002-04-18 19:39:23 +00:00
|
|
|
/*
|
|
|
|
* Close noderecord, atocreate will destroy it.
|
|
|
|
*/
|
|
|
|
UpdateNode();
|
|
|
|
|
|
|
|
Syslog('f', " Area not found, trying to create");
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
|
|
|
|
if ((gp = fopen(temp, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
free(temp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
|
|
|
|
fseek(gp, fgrouphdr.hdrsize, SEEK_SET);
|
|
|
|
|
|
|
|
while ((fread(&fgroup, fgrouphdr.recsize, 1, gp)) == 1) {
|
|
|
|
if ((fgroup.UseAka.zone == t->zone) && (fgroup.UseAka.net == t->net) && fgroup.UpLink.zone &&
|
|
|
|
strlen(fgroup.AreaFile) && fgroup.Active && fgroup.UserChange) {
|
2002-05-12 17:59:55 +00:00
|
|
|
if (CheckTicGroup(Area, fgroup.UpLink.zone, t) == 0) {
|
2002-04-18 19:39:23 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_CONN_FORWARD",Area,aka2str(fgroup.UpLink),"","","");
|
|
|
|
MsgResult("filemgr.responses",tmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(gp);
|
|
|
|
free(temp);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restore noderecord and try to load area again
|
|
|
|
*/
|
|
|
|
SearchNodeFaddr(t);
|
|
|
|
if (!SearchTic(Area)) {
|
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, "Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_CONN_NOTFOUND",Area,"","","","");
|
|
|
|
MsgResult("filemgr.responses",tmp);
|
|
|
|
Syslog('+', "Area %s not found", Area);
|
|
|
|
MacroClear();
|
|
|
|
return;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, "Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_CONN_NOTGROUP",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.responses",tmp);
|
2002-03-02 13:27:44 +00:00
|
|
|
Syslog('+', " Group %s not available for %s", fgroup.Name, ascfnode(t, 0x1f));
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
b = bestaka_s(t);
|
2002-06-17 20:36:06 +00:00
|
|
|
Temp = fido2faddr(tic.Aka);
|
|
|
|
i = metric(b, Temp);
|
|
|
|
tidy_faddr(Temp);
|
2002-02-11 21:49:10 +00:00
|
|
|
Syslog('m', "Aka match level is %d", i);
|
|
|
|
|
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,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_CONN_BADADD",Area,ascfnode(t, 0x1f),"","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.responses",tmp);
|
2002-03-02 13:27:44 +00:00
|
|
|
Syslog('+', " Node %s may not connect to group %s", ascfnode(t, 0x1f), fgroup.Name);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&Sys, 0, sizeof(Sys));
|
|
|
|
memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr));
|
|
|
|
Sys.sendto = TRUE;
|
|
|
|
|
|
|
|
if (TicSystemConnected(Sys)) {
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_CONN_ALREADY",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TicSystemConnect(&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
|
|
|
|
*/
|
|
|
|
f_list = TRUE;
|
|
|
|
Syslog('+', "Connected to file area %s", Area);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","OK_CONN",Area,aka2str(tic.Aka),"","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.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,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","ERR_CONN_NOTAVAIL",Area,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.responses",tmp);
|
2002-02-11 21:49:10 +00:00
|
|
|
WriteError("Can't connect node %s to file area %s", ascfnode(t, 0x1f), Area);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void F_All(faddr *, int, FILE *, char *);
|
|
|
|
void F_All(faddr *t, int Connect, FILE *tmp, char *Grp)
|
|
|
|
{
|
2002-02-11 21:49:10 +00:00
|
|
|
FILE *fp, *gp;
|
2002-03-02 15:42:08 +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('+', "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);
|
2002-03-02 15:42:08 +00:00
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2002-02-11 21:49:10 +00:00
|
|
|
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
|
2002-03-02 15:42:08 +00:00
|
|
|
if ((fp = fopen(temp, "r+")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
free(temp);
|
|
|
|
return;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
fread(&tichdr, sizeof(tichdr), 1, fp);
|
|
|
|
Cons = tichdr.syssize / sizeof(Sys);
|
2002-03-02 15:42:08 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
|
2002-03-02 15:42:08 +00:00
|
|
|
if ((gp = fopen(temp, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
free(temp);
|
|
|
|
fclose(fp);
|
|
|
|
return;
|
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
|
2002-03-02 15:42:08 +00:00
|
|
|
free(temp);
|
2002-02-11 21:49:10 +00:00
|
|
|
|
|
|
|
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(fp, tichdr.hdrsize, SEEK_SET);
|
|
|
|
while (fread(&tic, tichdr.recsize, 1, fp) == 1) {
|
|
|
|
|
2002-06-17 20:36:06 +00:00
|
|
|
Temp = fido2faddr(tic.Aka);
|
2002-03-02 19:50:13 +00:00
|
|
|
if ((!strcmp(Group, tic.Group)) && tic.Active && strlen(tic.Name) &&
|
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, fp);
|
2002-06-17 20:36:06 +00:00
|
|
|
tidy_faddr(Temp);
|
|
|
|
Temp = fido2faddr(Sys.aka);
|
|
|
|
if (metric(Temp, t) == METRIC_EQUAL)
|
2002-03-02 13:27:44 +00:00
|
|
|
Link = TRUE;
|
2002-02-11 21:49:10 +00:00
|
|
|
}
|
|
|
|
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);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","OK_CONN",tic.Name,aka2str(tic.Aka),"","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.responses",tmp);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
f_list = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
fseek(fp, Pos, SEEK_SET);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < Cons; i++) {
|
|
|
|
fread(&Sys, sizeof(Sys), 1, fp);
|
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
|
|
|
memset(&Sys, 0, sizeof(Sys));
|
|
|
|
fseek(fp, - sizeof(Sys), SEEK_CUR);
|
|
|
|
fwrite(&Sys, sizeof(Sys), 1, fp);
|
|
|
|
Syslog('+', "FileMgr: Disconnected %s", tic.Name);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","OK_DISC",tic.Name,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.responses",tmp);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2002-02-11 21:49:10 +00:00
|
|
|
f_list = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-02-11 21:49:10 +00:00
|
|
|
} else
|
|
|
|
fseek(fp, tichdr.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(fp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void F_Group(faddr *, char *, int, FILE *);
|
|
|
|
void F_Group(faddr *t, char *Area, int Connect, FILE *tmp)
|
|
|
|
{
|
2002-03-02 15:42:08 +00:00
|
|
|
int i;
|
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
ShiftBuf(Area, 2);
|
|
|
|
CleanBuf(Area);
|
2002-03-02 15:42:08 +00:00
|
|
|
for (i = 0; i < strlen(Area); i++)
|
|
|
|
Area[i] = toupper(Area[i]);
|
2002-02-11 21:49:10 +00:00
|
|
|
F_All(t, Connect, tmp, Area);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void F_Pause(faddr *, int, FILE *);
|
|
|
|
void F_Pause(faddr *t, int Pause, FILE *tmp)
|
|
|
|
{
|
2002-03-02 15:42:08 +00:00
|
|
|
FILE *fp;
|
2002-06-17 20:36:06 +00:00
|
|
|
faddr *f, *Temp;
|
2002-03-02 15:42:08 +00:00
|
|
|
int i, Cons;
|
|
|
|
sysconnect Sys;
|
|
|
|
char *temp;
|
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (Pause)
|
|
|
|
Syslog('+', "FileMgr: Pause");
|
|
|
|
else
|
|
|
|
Syslog('+', "FileMgr: Resume");
|
2002-03-02 15:42:08 +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/tic.data", getenv("MBSE_ROOT"));
|
|
|
|
if ((fp = fopen(temp, "r+")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
free(temp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fread(&tichdr, sizeof(tichdr), 1, fp);
|
|
|
|
Cons = tichdr.syssize / sizeof(Sys);
|
|
|
|
|
|
|
|
while (fread(&tic, tichdr.recsize, 1, fp) == 1) {
|
|
|
|
if (tic.Active) {
|
|
|
|
for (i = 0; i < Cons; i++) {
|
|
|
|
fread(&Sys, sizeof(Sys), 1, fp);
|
2002-06-17 20:36:06 +00:00
|
|
|
Temp = fido2faddr(Sys.aka);
|
|
|
|
if ((metric(Temp, t) == METRIC_EQUAL) && (!Sys.cutoff)) {
|
2002-03-02 15:42:08 +00:00
|
|
|
Sys.pause = Pause;
|
|
|
|
fseek(fp, - sizeof(Sys), SEEK_CUR);
|
|
|
|
fwrite(&Sys, sizeof(Sys), 1, fp);
|
2002-03-29 22:58:53 +00:00
|
|
|
Syslog('+', "FileMgr: %s area %s", Pause?"Pause":"Resume", tic.Name);
|
2002-03-31 20:07:04 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"FileMgr");
|
2002-03-31 21:33:16 +00:00
|
|
|
MacroVars("RABCDE", "ssdsss","OK_PAUSE",tic.Name,Pause,"","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.responses",tmp);
|
2002-03-02 15:42:08 +00:00
|
|
|
f_list = TRUE;
|
|
|
|
}
|
2002-06-17 20:36:06 +00:00
|
|
|
tidy_faddr(Temp);
|
2002-03-02 15:42:08 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fseek(fp, tichdr.syssize, SEEK_CUR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void F_Message(faddr *t, char *Buf, FILE *tmp)
|
|
|
|
{
|
2002-02-11 21:49:10 +00:00
|
|
|
ShiftBuf(Buf, 8);
|
|
|
|
CleanBuf(Buf);
|
|
|
|
|
|
|
|
if (!strncasecmp(Buf, "on", 2))
|
|
|
|
nodes.Message = TRUE;
|
|
|
|
else if (!strncasecmp(Buf, "off", 3))
|
|
|
|
nodes.Message = FALSE;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
UpdateNode();
|
2002-02-14 21:24:27 +00:00
|
|
|
SearchNodeFaddr(t);
|
2002-03-31 20:07:04 +00:00
|
|
|
Syslog('+', "FileMgr: Message %s", nodes.Message?"Yes":"No");
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "sdssss","OK_MESSAGE",nodes.Message,"","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.responses",tmp);
|
2002-03-29 22:58:53 +00:00
|
|
|
MacroClear();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void F_Tick(faddr *t, char *Buf, FILE *tmp)
|
|
|
|
{
|
2002-02-11 21:49:10 +00:00
|
|
|
ShiftBuf(Buf, 5);
|
|
|
|
CleanBuf(Buf);
|
2002-02-14 21:24:27 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
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();
|
2002-02-14 21:24:27 +00:00
|
|
|
SearchNodeFaddr(t);
|
2002-03-31 20:07:04 +00:00
|
|
|
Syslog('+', "FileMgr: Tick %s, Advanced %s", nodes.Tic?"Yes":"No", nodes.AdvTic?"Yes":"No");
|
2002-02-11 21:49:10 +00:00
|
|
|
if (nodes.Tic)
|
2002-03-29 22:58:53 +00:00
|
|
|
if (nodes.AdvTic){
|
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "sddsss","OK_TIC_ADV",nodes.Tic,nodes.AdvTic,"","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.responses",tmp);
|
2002-03-29 22:58:53 +00:00
|
|
|
}else{
|
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "sddsss","OK_TIC_NORM",nodes.Tic,nodes.AdvTic,"","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.responses",tmp);
|
2002-03-29 22:58:53 +00:00
|
|
|
}else{
|
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "sddsss","OK_TIC_OFF",nodes.Tic,nodes.AdvTic,"","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.responses",tmp);
|
2002-03-29 22:58:53 +00:00
|
|
|
}
|
|
|
|
MacroClear();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
2002-03-31 20:07:04 +00:00
|
|
|
|
|
|
|
|
2001-08-25 19:53:11 +00:00
|
|
|
int FileMgr(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;
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
2002-02-14 21:24:27 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
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 refresh the nodes record.
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2002-02-14 21:24:27 +00:00
|
|
|
SearchNodeFaddr(f);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
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)) {
|
|
|
|
|
|
|
|
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);
|
2002-03-29 22:58:53 +00:00
|
|
|
else if (!strncasecmp(Buf, "%passive", 8))
|
|
|
|
F_Pause(f, TRUE, tmp);
|
2002-02-11 21:49:10 +00:00
|
|
|
else if (!strncasecmp(Buf, "%resume", 7))
|
|
|
|
F_Pause(f, FALSE, tmp);
|
2002-03-29 22:58:53 +00:00
|
|
|
else if (!strncasecmp(Buf, "%active", 7))
|
|
|
|
F_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, 1);
|
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, 1);
|
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, 1);
|
2002-02-11 21:49:10 +00:00
|
|
|
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_Disconnect(f, Buf, tmp);
|
|
|
|
else
|
|
|
|
F_Connect(f, Buf, tmp);
|
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
|
|
|
if (ftell(tmp)) {
|
2002-03-29 22:58:53 +00:00
|
|
|
subject=calloc(256,sizeof(char));
|
|
|
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
|
|
|
MacroVars("RABCDE", "ssssss","","","","","","");
|
|
|
|
sprintf(subject,"Your FileMgr request");
|
|
|
|
GetRpSubject("filemgr.responses",subject);
|
|
|
|
if ((np = SendMgrMail(f, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", subject, replyid)) != NULL) {
|
|
|
|
MacroVars("RABCDE", "ssssss","WELLCOME","","","","","");
|
2002-03-31 20:07:04 +00:00
|
|
|
MsgResult("filemgr.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);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
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);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
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("filemgr.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 (f_stat)
|
|
|
|
F_Status(f, replyid);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (f_query)
|
|
|
|
F_Query(f, replyid);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (f_list)
|
|
|
|
F_List(f, replyid, FALSE);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (f_unlnk)
|
|
|
|
F_Unlinked(f, replyid);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-11 21:49:10 +00:00
|
|
|
if (f_help)
|
|
|
|
F_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
|
|
|
}
|
|
|
|
|