2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2001-11-14 21:37:58 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Setup FGroups.
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
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.
|
|
|
|
*
|
|
|
|
* MB 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 MB 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 "screen.h"
|
|
|
|
#include "mutil.h"
|
|
|
|
#include "ledit.h"
|
|
|
|
#include "stlist.h"
|
|
|
|
#include "m_global.h"
|
|
|
|
#include "m_node.h"
|
2002-04-15 13:38:35 +00:00
|
|
|
#include "m_archive.h"
|
|
|
|
#include "m_ngroup.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "m_ticarea.h"
|
|
|
|
#include "m_fgroup.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int FGrpUpdated = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Count nr of fgroup records in the database.
|
|
|
|
* Creates the database if it doesn't exist.
|
|
|
|
*/
|
|
|
|
int CountFGroup(void)
|
|
|
|
{
|
|
|
|
FILE *fil;
|
2001-10-19 14:25:14 +00:00
|
|
|
char ffile[PATH_MAX];
|
2001-08-17 05:46:24 +00:00
|
|
|
int count;
|
|
|
|
|
|
|
|
sprintf(ffile, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
|
|
|
|
if ((fil = fopen(ffile, "r")) == NULL) {
|
|
|
|
if ((fil = fopen(ffile, "a+")) != NULL) {
|
2001-10-19 14:25:14 +00:00
|
|
|
Syslog('+', "Created new %s", ffile);
|
2001-08-17 05:46:24 +00:00
|
|
|
fgrouphdr.hdrsize = sizeof(fgrouphdr);
|
|
|
|
fgrouphdr.recsize = sizeof(fgroup);
|
|
|
|
fwrite(&fgrouphdr, sizeof(fgrouphdr), 1, fil);
|
|
|
|
fclose(fil);
|
2001-11-14 21:37:58 +00:00
|
|
|
chmod(ffile, 0640);
|
2001-08-17 05:46:24 +00:00
|
|
|
return 0;
|
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fread(&fgrouphdr, sizeof(fgrouphdr), 1, fil);
|
|
|
|
fseek(fil, 0, SEEK_SET);
|
|
|
|
fread(&fgrouphdr, fgrouphdr.hdrsize, 1, fil);
|
|
|
|
fseek(fil, 0, SEEK_END);
|
|
|
|
count = (ftell(fil) - fgrouphdr.hdrsize) / fgrouphdr.recsize;
|
|
|
|
fclose(fil);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open database for editing. The datafile is copied, if the format
|
|
|
|
* is changed it will be converted on the fly. All editing must be
|
|
|
|
* done on the copied file.
|
|
|
|
*/
|
2001-10-19 14:25:14 +00:00
|
|
|
int OpenFGroup(void);
|
2001-08-17 05:46:24 +00:00
|
|
|
int OpenFGroup(void)
|
|
|
|
{
|
|
|
|
FILE *fin, *fout;
|
2002-02-10 20:57:58 +00:00
|
|
|
char fnin[PATH_MAX], fnout[PATH_MAX], temp[13];
|
2001-08-17 05:46:24 +00:00
|
|
|
long oldsize;
|
|
|
|
|
|
|
|
sprintf(fnin, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
|
|
|
|
sprintf(fnout, "%s/etc/fgroups.temp", getenv("MBSE_ROOT"));
|
|
|
|
if ((fin = fopen(fnin, "r")) != NULL) {
|
|
|
|
if ((fout = fopen(fnout, "w")) != NULL) {
|
|
|
|
FGrpUpdated = 0;
|
|
|
|
fread(&fgrouphdr, sizeof(fgrouphdr), 1, fin);
|
|
|
|
fseek(fin, 0, SEEK_SET);
|
|
|
|
fread(&fgrouphdr, fgrouphdr.hdrsize, 1, fin);
|
|
|
|
if (fgrouphdr.hdrsize != sizeof(fgrouphdr)) {
|
|
|
|
fgrouphdr.hdrsize = sizeof(fgrouphdr);
|
|
|
|
fgrouphdr.lastupd = time(NULL);
|
|
|
|
FGrpUpdated = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-02-10 17:02:45 +00:00
|
|
|
* In case we are automatic upgrading the data format
|
2001-08-17 05:46:24 +00:00
|
|
|
* we save the old format. If it is changed, the
|
|
|
|
* database must always be updated.
|
|
|
|
*/
|
|
|
|
oldsize = fgrouphdr.recsize;
|
2001-10-19 14:25:14 +00:00
|
|
|
if (oldsize != sizeof(fgroup))
|
2001-08-17 05:46:24 +00:00
|
|
|
FGrpUpdated = 1;
|
|
|
|
fgrouphdr.hdrsize = sizeof(fgrouphdr);
|
|
|
|
fgrouphdr.recsize = sizeof(fgroup);
|
|
|
|
fwrite(&fgrouphdr, sizeof(fgrouphdr), 1, fout);
|
|
|
|
|
2001-10-19 14:25:14 +00:00
|
|
|
if (FGrpUpdated)
|
|
|
|
Syslog('+', "Updated %s, format changed", fnin);
|
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
/*
|
|
|
|
* The datarecord is filled with zero's before each
|
|
|
|
* read, so if the format changed, the new fields
|
|
|
|
* will be empty.
|
|
|
|
*/
|
|
|
|
memset(&fgroup, 0, sizeof(fgroup));
|
|
|
|
while (fread(&fgroup, oldsize, 1, fin) == 1) {
|
2002-02-10 17:02:45 +00:00
|
|
|
/*
|
|
|
|
* Now set defaults
|
|
|
|
*/
|
2002-09-29 20:08:32 +00:00
|
|
|
if (FGrpUpdated && !strlen(fgroup.BasePath)) {
|
2002-02-10 17:02:45 +00:00
|
|
|
fgroup.DupCheck = TRUE;
|
|
|
|
fgroup.Secure = TRUE;
|
|
|
|
fgroup.VirScan = TRUE;
|
|
|
|
fgroup.Announce = TRUE;
|
|
|
|
fgroup.UpdMagic = TRUE;
|
|
|
|
fgroup.FileId = TRUE;
|
2002-02-10 20:57:58 +00:00
|
|
|
memset(&temp, 0, sizeof(temp));
|
|
|
|
strcpy(temp, fgroup.Name);
|
|
|
|
sprintf(fgroup.BasePath, "%s/ftp/pub/%s", getenv("MBSE_ROOT"), tl(temp));
|
2002-02-10 17:02:45 +00:00
|
|
|
}
|
2002-09-29 20:08:32 +00:00
|
|
|
if (FGrpUpdated && !fgroup.LinkSec.level) {
|
|
|
|
fgroup.LinkSec.level = 1;
|
|
|
|
fgroup.LinkSec.flags = 1;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
fwrite(&fgroup, sizeof(fgroup), 1, fout);
|
|
|
|
memset(&fgroup, 0, sizeof(fgroup));
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fin);
|
|
|
|
fclose(fout);
|
|
|
|
return 0;
|
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-10-19 14:25:14 +00:00
|
|
|
void CloseFGroup(int);
|
|
|
|
void CloseFGroup(int force)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2001-10-19 14:25:14 +00:00
|
|
|
char fin[PATH_MAX], fout[PATH_MAX];
|
2001-08-17 05:46:24 +00:00
|
|
|
FILE *fi, *fo;
|
|
|
|
st_list *fgr = NULL, *tmp;
|
|
|
|
|
|
|
|
sprintf(fin, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
|
|
|
|
sprintf(fout,"%s/etc/fgroups.temp", getenv("MBSE_ROOT"));
|
|
|
|
|
|
|
|
if (FGrpUpdated == 1) {
|
2001-10-19 14:25:14 +00:00
|
|
|
if (force || (yes_no((char *)"Database is changed, save changes") == 1)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
working(1, 0, 0);
|
|
|
|
fi = fopen(fout, "r");
|
|
|
|
fo = fopen(fin, "w");
|
|
|
|
fread(&fgrouphdr, fgrouphdr.hdrsize, 1, fi);
|
|
|
|
fwrite(&fgrouphdr, fgrouphdr.hdrsize, 1, fo);
|
|
|
|
|
|
|
|
while (fread(&fgroup, fgrouphdr.recsize, 1, fi) == 1)
|
|
|
|
if (!fgroup.Deleted)
|
|
|
|
fill_stlist(&fgr, fgroup.Name, ftell(fi) - fgrouphdr.recsize);
|
|
|
|
sort_stlist(&fgr);
|
|
|
|
|
|
|
|
for (tmp = fgr; tmp; tmp = tmp->next) {
|
|
|
|
fseek(fi, tmp->pos, SEEK_SET);
|
|
|
|
fread(&fgroup, fgrouphdr.recsize, 1, fi);
|
|
|
|
fwrite(&fgroup, fgrouphdr.recsize, 1, fo);
|
|
|
|
}
|
|
|
|
|
|
|
|
tidy_stlist(&fgr);
|
|
|
|
fclose(fi);
|
|
|
|
fclose(fo);
|
|
|
|
unlink(fout);
|
2001-11-14 21:37:58 +00:00
|
|
|
chmod(fin, 0640);
|
2001-08-17 05:46:24 +00:00
|
|
|
Syslog('+', "Updated \"fgroups.data\"");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2002-01-25 20:21:50 +00:00
|
|
|
chmod(fin, 0640);
|
2001-08-17 05:46:24 +00:00
|
|
|
working(1, 0, 0);
|
|
|
|
unlink(fout);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int AppendFGroup(void)
|
|
|
|
{
|
|
|
|
FILE *fil;
|
2001-10-19 14:25:14 +00:00
|
|
|
char ffile[PATH_MAX];
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
sprintf(ffile, "%s/etc/fgroups.temp", getenv("MBSE_ROOT"));
|
|
|
|
if ((fil = fopen(ffile, "a")) != NULL) {
|
|
|
|
memset(&fgroup, 0, sizeof(fgroup));
|
2001-12-23 16:44:18 +00:00
|
|
|
fgroup.StartDate = time(NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
fgroup.DivideCost = TRUE;
|
2002-04-15 13:38:35 +00:00
|
|
|
fgroup.FileGate = TRUE;
|
|
|
|
fgroup.Secure = TRUE;
|
|
|
|
fgroup.VirScan = TRUE;
|
|
|
|
fgroup.Announce = TRUE;
|
|
|
|
fgroup.FileId = TRUE;
|
2002-04-27 21:06:51 +00:00
|
|
|
fgroup.DupCheck = TRUE;
|
|
|
|
fgroup.Replace = TRUE;
|
2002-09-29 20:08:32 +00:00
|
|
|
fgroup.LinkSec.level = 1;
|
|
|
|
fgroup.LinkSec.flags = 1;
|
2001-08-17 05:46:24 +00:00
|
|
|
fwrite(&fgroup, sizeof(fgroup), 1, fil);
|
|
|
|
fclose(fil);
|
|
|
|
FGrpUpdated = 1;
|
|
|
|
return 0;
|
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if field can be edited without screwing up the database
|
|
|
|
*/
|
|
|
|
int CheckFgroup(void);
|
|
|
|
int CheckFgroup(void)
|
|
|
|
{
|
|
|
|
int ncnt, tcnt;
|
|
|
|
|
|
|
|
working(1, 0, 0);
|
|
|
|
ncnt = GroupInNode(fgroup.Name, FALSE);
|
|
|
|
tcnt = GroupInTic(fgroup.Name);
|
|
|
|
working(0, 0, 0);
|
|
|
|
if (ncnt || tcnt) {
|
|
|
|
errmsg((char *)"Error, %d node(s) and/or %d tic area(s) connected", ncnt, tcnt);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FgScreen(void)
|
|
|
|
{
|
|
|
|
clr_index();
|
|
|
|
set_color(WHITE, BLACK);
|
2002-04-15 13:38:35 +00:00
|
|
|
mvprintw( 4, 2, "10.1 EDIT FILE GROUP");
|
2001-08-17 05:46:24 +00:00
|
|
|
set_color(CYAN, BLACK);
|
2002-04-15 13:38:35 +00:00
|
|
|
mvprintw( 6, 2, "1. Name");
|
|
|
|
mvprintw( 7, 2, "2. Comment");
|
|
|
|
mvprintw( 8, 2, "3. Base path");
|
|
|
|
mvprintw( 9, 2, "4. Use Aka");
|
|
|
|
mvprintw(10, 2, "5. Uplink");
|
|
|
|
mvprintw(11, 2, "6. Areas");
|
|
|
|
mvprintw(12, 2, "7. Filegate");
|
|
|
|
mvprintw(13, 2, "8. Banner");
|
|
|
|
mvprintw(14, 2, "9. Convert");
|
|
|
|
mvprintw(15, 2, "10. BBS group");
|
|
|
|
mvprintw(16, 2, "11. New group");
|
|
|
|
mvprintw(17, 2, "12. Active");
|
|
|
|
mvprintw(18, 2, "13. Deleted");
|
|
|
|
mvprintw(19, 2, "14. Start at");
|
|
|
|
|
|
|
|
mvprintw(11,32, "15. Unit Cost");
|
|
|
|
mvprintw(12,32, "16. Unit Size");
|
|
|
|
mvprintw(13,32, "17. Add Prom.");
|
|
|
|
mvprintw(14,32, "18. Divide");
|
|
|
|
mvprintw(15,32, "19. Auto chng");
|
|
|
|
mvprintw(16,32, "20. User chng");
|
|
|
|
mvprintw(17,32, "21. Replace");
|
|
|
|
mvprintw(18,32, "22. Dupecheck");
|
|
|
|
mvprintw(19,32, "23. Secure");
|
|
|
|
|
2002-05-29 19:53:42 +00:00
|
|
|
mvprintw( 9,56, "24. Touch");
|
2002-04-15 13:38:35 +00:00
|
|
|
mvprintw(10,56, "25. Virscan");
|
|
|
|
mvprintw(11,56, "26. Announce");
|
|
|
|
mvprintw(12,56, "27. Upd magic");
|
|
|
|
mvprintw(13,56, "28. File ID");
|
|
|
|
mvprintw(14,56, "29. Conv. all");
|
|
|
|
mvprintw(15,56, "30. Send orig");
|
|
|
|
mvprintw(16,56, "31. DL sec");
|
|
|
|
mvprintw(17,56, "32. UP sec");
|
|
|
|
mvprintw(18,56, "33. LT sec");
|
|
|
|
mvprintw(19,56, "34. Upl. area");
|
2002-09-29 20:08:32 +00:00
|
|
|
mvprintw(20,56, "35. Link sec");
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Edit one record, return -1 if there are errors, 0 if ok.
|
|
|
|
*/
|
|
|
|
int EditFGrpRec(int Area)
|
|
|
|
{
|
|
|
|
FILE *fil;
|
2002-04-27 21:06:51 +00:00
|
|
|
char mfile[PATH_MAX], temp[13];
|
2001-08-17 05:46:24 +00:00
|
|
|
long offset;
|
2002-04-27 21:06:51 +00:00
|
|
|
int i, j, tmp;
|
2001-08-17 05:46:24 +00:00
|
|
|
unsigned long crc, crc1;
|
|
|
|
|
|
|
|
clr_index();
|
|
|
|
working(1, 0, 0);
|
|
|
|
IsDoing("Edit FileGroup");
|
|
|
|
|
|
|
|
sprintf(mfile, "%s/etc/fgroups.temp", getenv("MBSE_ROOT"));
|
|
|
|
if ((fil = fopen(mfile, "r")) == NULL) {
|
|
|
|
working(2, 0, 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
offset = sizeof(fgrouphdr) + ((Area -1) * sizeof(fgroup));
|
|
|
|
if (fseek(fil, offset, 0) != 0) {
|
|
|
|
working(2, 0, 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fread(&fgroup, sizeof(fgroup), 1, fil);
|
|
|
|
fclose(fil);
|
|
|
|
crc = 0xffffffff;
|
|
|
|
crc = upd_crc32((char *)&fgroup, crc, sizeof(fgroup));
|
|
|
|
working(0, 0, 0);
|
|
|
|
FgScreen();
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
set_color(WHITE, BLACK);
|
2002-04-15 13:38:35 +00:00
|
|
|
show_str( 6,16,12, fgroup.Name);
|
|
|
|
show_str( 7,16,55, fgroup.Comment);
|
|
|
|
show_str( 8,16,64, fgroup.BasePath);
|
|
|
|
show_aka( 9,16, fgroup.UseAka);
|
|
|
|
show_aka( 10,16, fgroup.UpLink);
|
|
|
|
show_str( 11,16,12, fgroup.AreaFile);
|
|
|
|
show_bool(12,16, fgroup.FileGate);
|
|
|
|
show_str( 13,16,14, fgroup.Banner);
|
|
|
|
show_str( 14,16,5, fgroup.Convert);
|
|
|
|
show_str( 15,16,12, fgroup.BbsGroup);
|
|
|
|
show_str( 16,16,12, fgroup.AnnGroup);
|
|
|
|
show_bool(17,16, fgroup.Active);
|
|
|
|
show_bool(18,16, fgroup.Deleted);
|
|
|
|
show_int( 19,16, fgroup.StartArea);
|
|
|
|
|
|
|
|
show_int( 11,46, fgroup.UnitCost);
|
|
|
|
show_int( 12,46, fgroup.UnitSize);
|
|
|
|
show_int( 13,46, fgroup.AddProm);
|
|
|
|
show_bool(14,46, fgroup.DivideCost);
|
|
|
|
show_bool(15,46, fgroup.AutoChange);
|
|
|
|
show_bool(16,46, fgroup.UserChange);
|
|
|
|
show_bool(17,46, fgroup.Replace);
|
|
|
|
show_bool(18,46, fgroup.DupCheck);
|
|
|
|
show_bool(19,46, fgroup.Secure);
|
|
|
|
|
2002-05-29 19:53:42 +00:00
|
|
|
show_bool( 9,70, fgroup.Touch);
|
2002-04-15 13:38:35 +00:00
|
|
|
show_bool(10,70, fgroup.VirScan);
|
|
|
|
show_bool(11,70, fgroup.Announce);
|
|
|
|
show_bool(12,70, fgroup.UpdMagic);
|
|
|
|
show_bool(13,70, fgroup.FileId);
|
|
|
|
show_bool(14,70, fgroup.ConvertAll);
|
|
|
|
show_bool(15,70, fgroup.SendOrg);
|
|
|
|
show_int( 16,70, fgroup.DLSec.level);
|
|
|
|
show_int( 17,70, fgroup.UPSec.level);
|
|
|
|
show_int( 18,70, fgroup.LTSec.level);
|
|
|
|
show_int( 19,70, fgroup.Upload);
|
|
|
|
|
2002-09-29 20:08:32 +00:00
|
|
|
j = select_menu(35);
|
2001-08-17 05:46:24 +00:00
|
|
|
switch(j) {
|
2002-05-23 17:56:37 +00:00
|
|
|
case 0: if (!fgroup.StartArea && strlen(fgroup.AreaFile)) {
|
|
|
|
errmsg("Areas file defined but no BBS start area");
|
|
|
|
break;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
crc1 = 0xffffffff;
|
|
|
|
crc1 = upd_crc32((char *)&fgroup, crc1, sizeof(fgroup));
|
|
|
|
if (crc != crc1) {
|
|
|
|
if (yes_no((char *)"Record is changed, save") == 1) {
|
|
|
|
working(1, 0, 0);
|
|
|
|
if ((fil = fopen(mfile, "r+")) == NULL) {
|
|
|
|
working(2, 0, 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
fseek(fil, offset, 0);
|
|
|
|
fwrite(&fgroup, sizeof(fgroup), 1, fil);
|
|
|
|
fclose(fil);
|
|
|
|
FGrpUpdated = 1;
|
|
|
|
working(1, 0, 0);
|
|
|
|
working(0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IsDoing("Browsing Menu");
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case 1: if (CheckFgroup())
|
|
|
|
break;
|
2002-04-27 21:06:51 +00:00
|
|
|
strcpy(fgroup.Name, edit_ups(6,16,12, fgroup.Name, (char *)"The ^name^ of this file group"));
|
2002-05-10 14:18:29 +00:00
|
|
|
if (strlen(fgroup.BasePath) == 0) {
|
2002-04-27 21:06:51 +00:00
|
|
|
memset(&temp, 0, sizeof(temp));
|
|
|
|
strcpy(temp, fgroup.Name);
|
|
|
|
for (i = 0; i < strlen(temp); i++) {
|
|
|
|
if (temp[i] == '.')
|
|
|
|
temp[i] = '/';
|
|
|
|
if (isupper(temp[i]))
|
|
|
|
temp[i] = tolower(temp[i]);
|
|
|
|
}
|
|
|
|
sprintf(fgroup.BasePath, "%s/%s", CFG.ftp_base, temp);
|
|
|
|
}
|
|
|
|
if (strlen(fgroup.BbsGroup) == 0)
|
|
|
|
strcpy(fgroup.BbsGroup, fgroup.Name);
|
|
|
|
break;
|
2002-04-15 13:38:35 +00:00
|
|
|
case 2: E_STR( 7,16,55,fgroup.Comment, "The ^description^ of this file group")
|
2002-06-24 20:34:07 +00:00
|
|
|
case 3: E_PTH( 8,16,64,fgroup.BasePath, "The ^base path^ for new created file areas", 0775)
|
2001-08-17 05:46:24 +00:00
|
|
|
case 4: tmp = PickAka((char *)"10.1.4", TRUE);
|
|
|
|
if (tmp != -1)
|
|
|
|
fgroup.UseAka = CFG.aka[tmp];
|
|
|
|
FgScreen();
|
|
|
|
break;
|
|
|
|
case 5: fgroup.UpLink = PullUplink((char *)"10.1.5");
|
|
|
|
FgScreen();
|
|
|
|
break;
|
2002-04-15 13:38:35 +00:00
|
|
|
case 6: E_STR( 11,16,12,fgroup.AreaFile, "The name of the ^Areas File^ from the uplink")
|
|
|
|
case 7: E_BOOL(12,16, fgroup.FileGate, "Is the areas file in ^filegate.zxx^ format")
|
|
|
|
case 8: E_STR( 13,16,14,fgroup.Banner, "The ^banner^ to add to the archives")
|
|
|
|
case 9: strcpy(fgroup.Convert, PickArchive((char *)"10.1.9"));
|
|
|
|
FgScreen();
|
|
|
|
break;
|
2002-04-15 14:23:42 +00:00
|
|
|
case 10:strncpy(fgroup.BbsGroup, PickFGroup((char *)"8.4.17"), 12);
|
2002-04-15 13:38:35 +00:00
|
|
|
FgScreen();
|
|
|
|
break;
|
2002-04-15 14:23:42 +00:00
|
|
|
case 11:strncpy(fgroup.AnnGroup, PickNGroup((char *)"8.4.18"), 12);
|
2002-04-15 13:38:35 +00:00
|
|
|
FgScreen();
|
|
|
|
break;
|
|
|
|
case 12:if (CheckFgroup())
|
|
|
|
break;
|
|
|
|
E_BOOL(17,16, fgroup.Active, "Is this file group ^active^")
|
|
|
|
case 13:if (CheckFgroup())
|
2001-08-17 05:46:24 +00:00
|
|
|
break;
|
2002-04-15 13:38:35 +00:00
|
|
|
E_BOOL(18,16, fgroup.Deleted, "Is this file group ^Deleted^")
|
|
|
|
case 14:E_INT( 19,16, fgroup.StartArea, "The ^start area^ to create new BBS areas")
|
|
|
|
|
|
|
|
case 15:E_INT( 11,46, fgroup.UnitCost, "The ^cost per size unit^ files received in this tic group")
|
|
|
|
case 16:E_INT( 12,46, fgroup.UnitSize, "The ^unit size^ in KBytes, 0 means cost per file in this tic group")
|
|
|
|
case 17:E_INT( 13,46, fgroup.AddProm, "The ^Promillage^ to add or substract of the filecost")
|
|
|
|
case 18:E_BOOL(14,46, fgroup.DivideCost, "^Divide^ the cost over all downlinks or charge each link full cost")
|
|
|
|
case 19:E_BOOL(15,46, fgroup.AutoChange, "^Automatic change areas^ when a new arealist is received")
|
2002-05-12 17:59:55 +00:00
|
|
|
case 20:tmp = edit_bool(16,46, fgroup.UserChange, (char *)"Create new areas when ^users^ request new tic areas");
|
|
|
|
if (tmp && !fgroup.UpLink.zone)
|
|
|
|
errmsg("It looks like you are at the toplevel, no Uplink defined");
|
|
|
|
else
|
|
|
|
fgroup.UserChange = tmp;
|
|
|
|
break;
|
2002-04-15 13:38:35 +00:00
|
|
|
case 21:E_BOOL(17,46, fgroup.Replace, "Set ^Replace^ in new created tic areas")
|
|
|
|
case 22:E_BOOL(18,46, fgroup.DupCheck, "Set ^Dupe check^ in new created tic areas")
|
|
|
|
case 23:E_BOOL(19,46, fgroup.Secure, "Set ^Secure^ tic processing in new created tic areas")
|
|
|
|
|
2002-05-29 19:53:42 +00:00
|
|
|
case 24:E_BOOL( 9,70, fgroup.Touch, "Set ^Touch filedate^ in new created tic areas")
|
2002-04-15 13:38:35 +00:00
|
|
|
case 25:E_BOOL(10,70, fgroup.VirScan, "Set ^Virus scanner^ in new created tic areas")
|
|
|
|
case 26:E_BOOL(11,70, fgroup.Announce, "Set ^Announce files^ in new created tic areas")
|
|
|
|
case 27:E_BOOL(12,70, fgroup.UpdMagic, "Set ^Update magic^ in new created tic areas")
|
|
|
|
case 28:E_BOOL(13,70, fgroup.FileId, "Set ^FILE_ID.DIZ extract^ in new created tic areas")
|
2002-05-10 14:23:24 +00:00
|
|
|
case 29:tmp = edit_bool(14,70, fgroup.ConvertAll, (char *)"Set ^Convert All^ setting in new created tic areas");
|
|
|
|
if (tmp && !fgroup.ConvertAll && (strlen(fgroup.Convert) == 0))
|
|
|
|
errmsg("No archiver configured to convert to, edit 9 first");
|
|
|
|
else
|
|
|
|
fgroup.ConvertAll = tmp;
|
|
|
|
break;
|
2002-04-15 13:38:35 +00:00
|
|
|
case 30:E_BOOL(15,70, fgroup.SendOrg, "Set ^Send original^ setting in new created tic areas")
|
|
|
|
case 31:E_SEC( 16,70, fgroup.DLSec, "10.1.31 FILE GROUP DOWNLOAD SECURITY", FgScreen)
|
|
|
|
case 32:E_SEC( 17,70, fgroup.UPSec, "10.1.32 FILE GROUP UPLOAD SECURITY", FgScreen)
|
|
|
|
case 33:E_SEC( 18,70, fgroup.LTSec, "10.1.33 FILE GROUP LIST SECURITY", FgScreen)
|
|
|
|
case 34:E_INT( 19,70, fgroup.Upload, "Set the default ^Upload area^ in new created file areas")
|
2002-09-29 20:08:32 +00:00
|
|
|
case 35:fgroup.LinkSec = edit_asec(fgroup.LinkSec, (char *)"10.1.35 DEFAULT NEW TIC AREAS SECURITY");
|
|
|
|
FgScreen();
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void EditFGroup(void)
|
|
|
|
{
|
2003-01-31 21:49:29 +00:00
|
|
|
int records, i, o, x, y;
|
|
|
|
char pick[12], temp[PATH_MAX];
|
|
|
|
FILE *fil;
|
|
|
|
long offset;
|
|
|
|
|
|
|
|
clr_index();
|
|
|
|
working(1, 0, 0);
|
|
|
|
IsDoing("Browsing Menu");
|
|
|
|
if (config_read() == -1) {
|
|
|
|
working(2, 0, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
records = CountFGroup();
|
|
|
|
if (records == -1) {
|
|
|
|
working(2, 0, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OpenFGroup() == -1) {
|
|
|
|
working(2, 0, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
working(0, 0, 0);
|
|
|
|
o = 0;
|
|
|
|
if (! check_free())
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (;;) {
|
2001-08-17 05:46:24 +00:00
|
|
|
clr_index();
|
2003-01-31 21:49:29 +00:00
|
|
|
set_color(WHITE, BLACK);
|
|
|
|
mvprintw( 5, 4, "10.1 FILE GROUPS SETUP");
|
|
|
|
set_color(CYAN, BLACK);
|
|
|
|
if (records != 0) {
|
|
|
|
sprintf(temp, "%s/etc/fgroups.temp", getenv("MBSE_ROOT"));
|
|
|
|
working(1, 0, 0);
|
|
|
|
if ((fil = fopen(temp, "r")) != NULL) {
|
|
|
|
fread(&fgrouphdr, sizeof(fgrouphdr), 1, fil);
|
|
|
|
x = 2;
|
|
|
|
y = 7;
|
|
|
|
set_color(CYAN, BLACK);
|
|
|
|
for (i = 1; i <= 20; i++) {
|
|
|
|
if (i == 11 ) {
|
|
|
|
x = 42;
|
|
|
|
y = 7;
|
|
|
|
}
|
|
|
|
if ((o + i) <= records) {
|
|
|
|
offset = sizeof(fgrouphdr) + (((o + i) - 1) * fgrouphdr.recsize);
|
|
|
|
fseek(fil, offset, 0);
|
|
|
|
fread(&fgroup, fgrouphdr.recsize, 1, fil);
|
|
|
|
if (fgroup.Active)
|
|
|
|
set_color(CYAN, BLACK);
|
|
|
|
else
|
|
|
|
set_color(LIGHTBLUE, BLACK);
|
|
|
|
sprintf(temp, "%3d. %-12s %-18s", o + i, fgroup.Name, fgroup.Comment);
|
|
|
|
temp[38] = '\0';
|
|
|
|
mvprintw(y, x, temp);
|
|
|
|
y++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fil);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
working(0, 0, 0);
|
2003-01-31 21:49:29 +00:00
|
|
|
strcpy(pick, select_record(records, 20));
|
|
|
|
|
|
|
|
if (strncmp(pick, "-", 1) == 0) {
|
|
|
|
CloseFGroup(FALSE);
|
|
|
|
open_bbs();
|
2002-05-04 19:45:19 +00:00
|
|
|
return;
|
2003-01-31 21:49:29 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-01-31 21:49:29 +00:00
|
|
|
if (strncmp(pick, "A", 1) == 0) {
|
|
|
|
if (records < CFG.tic_groups) {
|
|
|
|
working(1, 0, 0);
|
|
|
|
if (AppendFGroup() == 0) {
|
|
|
|
records++;
|
|
|
|
working(1, 0, 0);
|
|
|
|
} else
|
|
|
|
working(2, 0, 0);
|
2001-08-17 05:46:24 +00:00
|
|
|
working(0, 0, 0);
|
2003-01-31 21:49:29 +00:00
|
|
|
} else {
|
2003-02-02 21:26:46 +00:00
|
|
|
errmsg("Cannot add group, change global setting in menu 1.11.5");
|
2003-01-31 21:49:29 +00:00
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-01-31 21:49:29 +00:00
|
|
|
if (strncmp(pick, "N", 1) == 0)
|
|
|
|
if ((o + 20) < records)
|
|
|
|
o += 20;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-01-31 21:49:29 +00:00
|
|
|
if (strncmp(pick, "P", 1) == 0)
|
|
|
|
if ((o - 20) >= 0)
|
|
|
|
o -= 20;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-01-31 21:49:29 +00:00
|
|
|
if ((atoi(pick) >= 1) && (atoi(pick) <= records)) {
|
|
|
|
EditFGrpRec(atoi(pick));
|
|
|
|
o = ((atoi(pick) - 1) / 20) * 20;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-01-31 21:49:29 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-10-19 14:25:14 +00:00
|
|
|
void InitFGroup(void)
|
|
|
|
{
|
|
|
|
CountFGroup();
|
|
|
|
OpenFGroup();
|
|
|
|
CloseFGroup(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
char *PickFGroup(char *shdr)
|
|
|
|
{
|
|
|
|
static char FGrp[21] = "";
|
|
|
|
int records, i, o = 0, x, y;
|
|
|
|
char pick[12];
|
|
|
|
FILE *fil;
|
2001-10-19 14:25:14 +00:00
|
|
|
char temp[PATH_MAX];
|
2001-08-17 05:46:24 +00:00
|
|
|
long offset;
|
|
|
|
|
|
|
|
|
|
|
|
clr_index();
|
|
|
|
working(1, 0, 0);
|
|
|
|
if (config_read() == -1) {
|
|
|
|
working(2, 0, 0);
|
|
|
|
return FGrp;
|
|
|
|
}
|
|
|
|
|
|
|
|
records = CountFGroup();
|
|
|
|
if (records == -1) {
|
|
|
|
working(2, 0, 0);
|
|
|
|
return FGrp;
|
|
|
|
}
|
|
|
|
|
|
|
|
working(0, 0, 0);
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
clr_index();
|
|
|
|
set_color(WHITE, BLACK);
|
|
|
|
sprintf(temp, "%s. FILE GROUP SELECT", shdr);
|
|
|
|
mvprintw( 5, 4, temp);
|
|
|
|
set_color(CYAN, BLACK);
|
|
|
|
if (records != 0) {
|
|
|
|
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
|
|
|
|
working(1, 0, 0);
|
|
|
|
if ((fil = fopen(temp, "r")) != NULL) {
|
|
|
|
fread(&fgrouphdr, sizeof(fgrouphdr), 1, fil);
|
|
|
|
x = 2;
|
|
|
|
y = 7;
|
|
|
|
set_color(CYAN, BLACK);
|
|
|
|
for (i = 1; i <= 20; i++) {
|
|
|
|
if (i == 11) {
|
|
|
|
x = 42;
|
|
|
|
y = 7;
|
|
|
|
}
|
|
|
|
if ((o + i) <= records) {
|
|
|
|
offset = sizeof(fgrouphdr) + (((o + i) - 1) * fgrouphdr.recsize);
|
|
|
|
fseek(fil, offset, 0);
|
|
|
|
fread(&fgroup, fgrouphdr.recsize, 1, fil);
|
|
|
|
if (fgroup.Active)
|
|
|
|
set_color(CYAN, BLACK);
|
|
|
|
else
|
|
|
|
set_color(LIGHTBLUE, BLACK);
|
|
|
|
sprintf(temp, "%3d. %-12s %-18s", o + i, fgroup.Name, fgroup.Comment);
|
|
|
|
temp[38] = '\0';
|
|
|
|
mvprintw(y, x, temp);
|
|
|
|
y++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fil);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
working(0, 0, 0);
|
|
|
|
strcpy(pick, select_pick(records, 20));
|
|
|
|
|
|
|
|
if (strncmp(pick, "-", 1) == 0) {
|
|
|
|
return FGrp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strncmp(pick, "N", 1) == 0)
|
|
|
|
if ((o + 20) < records)
|
|
|
|
o = o + 20;
|
|
|
|
|
|
|
|
if (strncmp(pick, "P", 1) == 0)
|
|
|
|
if ((o - 20) >= 0)
|
|
|
|
o = o - 20;
|
|
|
|
|
|
|
|
if ((atoi(pick) >= 1) && (atoi(pick) <= records)) {
|
|
|
|
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
|
|
|
|
fil = fopen(temp, "r");
|
|
|
|
offset = fgrouphdr.hdrsize + ((atoi(pick) - 1) * fgrouphdr.recsize);
|
|
|
|
fseek(fil, offset, 0);
|
|
|
|
fread(&fgroup, fgrouphdr.recsize, 1, fil);
|
|
|
|
fclose(fil);
|
|
|
|
strcpy(FGrp, fgroup.Name);
|
|
|
|
return (FGrp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int tic_group_doc(FILE *fp, FILE *toc, int page)
|
|
|
|
{
|
2002-04-15 13:38:35 +00:00
|
|
|
char *temp;
|
2001-08-17 05:46:24 +00:00
|
|
|
FILE *no;
|
2002-04-15 13:38:35 +00:00
|
|
|
int First = TRUE;;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-04-15 13:38:35 +00:00
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2001-08-17 05:46:24 +00:00
|
|
|
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
|
2002-04-15 13:38:35 +00:00
|
|
|
if ((no = fopen(temp, "r")) == NULL) {
|
|
|
|
free(temp);
|
|
|
|
return page;
|
|
|
|
}
|
|
|
|
free(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
fread(&fgrouphdr, sizeof(fgrouphdr), 1, no);
|
|
|
|
fseek(no, 0, SEEK_SET);
|
|
|
|
fread(&fgrouphdr, fgrouphdr.hdrsize, 1, no);
|
|
|
|
|
|
|
|
while ((fread(&fgroup, fgrouphdr.recsize, 1, no)) == 1) {
|
2002-04-15 13:38:35 +00:00
|
|
|
if (First) {
|
|
|
|
addtoc(fp, toc, 10, 1, page, (char *)"File processing groups");
|
|
|
|
First = FALSE;
|
|
|
|
fprintf(fp, "\n");
|
|
|
|
} else {
|
|
|
|
page = newpage(fp, page);
|
|
|
|
fprintf(fp, "\n\n");
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
2002-04-15 13:38:35 +00:00
|
|
|
fprintf(fp, " Group name %s\n", fgroup.Name);
|
|
|
|
fprintf(fp, " Comment %s\n", fgroup.Comment);
|
|
|
|
fprintf(fp, " Active %s\n", getboolean(fgroup.Active));
|
|
|
|
fprintf(fp, " Use Aka %s\n", aka2str(fgroup.UseAka));
|
|
|
|
fprintf(fp, " Uplink %s\n", aka2str(fgroup.UpLink));
|
|
|
|
fprintf(fp, " Areas file %s\n", fgroup.AreaFile);
|
|
|
|
fprintf(fp, " Divice cost %s\n", getboolean(fgroup.DivideCost));
|
|
|
|
fprintf(fp, " Unit cost %ld\n", fgroup.UnitCost);
|
|
|
|
fprintf(fp, " Unit size %ld\n", fgroup.UnitSize);
|
|
|
|
fprintf(fp, " Add promille %ld\n", fgroup.AddProm);
|
|
|
|
fprintf(fp, " Start area %ld\n", fgroup.StartArea);
|
|
|
|
fprintf(fp, " Banner file %s\n", fgroup.Banner);
|
|
|
|
fprintf(fp, " Def. archiver %s\n", fgroup.Convert);
|
|
|
|
fprintf(fp, " Filegate fmt %s\n", getboolean(fgroup.FileGate));
|
|
|
|
fprintf(fp, " Auto change %s\n", getboolean(fgroup.AutoChange));
|
|
|
|
fprintf(fp, " User change %s\n", getboolean(fgroup.UserChange));
|
|
|
|
fprintf(fp, " Allow replace %s\n", getboolean(fgroup.Replace));
|
|
|
|
fprintf(fp, " Dupe checking %s\n", getboolean(fgroup.DupCheck));
|
|
|
|
fprintf(fp, " Secure %s\n", getboolean(fgroup.Secure));
|
2002-05-29 19:53:42 +00:00
|
|
|
fprintf(fp, " Touch dates %s\n", getboolean(fgroup.Touch));
|
2002-04-15 13:38:35 +00:00
|
|
|
fprintf(fp, " Virus scan %s\n", getboolean(fgroup.VirScan));
|
|
|
|
fprintf(fp, " Announce %s\n", getboolean(fgroup.Announce));
|
|
|
|
fprintf(fp, " Update magics %s\n", getboolean(fgroup.UpdMagic));
|
|
|
|
fprintf(fp, " FILE_ID.DIZ %s\n", getboolean(fgroup.FileId));
|
|
|
|
fprintf(fp, " Convert all %s\n", getboolean(fgroup.ConvertAll));
|
|
|
|
fprintf(fp, " Send original %s\n", getboolean(fgroup.SendOrg));
|
|
|
|
fprintf(fp, " Base path %s\n", fgroup.BasePath);
|
|
|
|
fprintf(fp, " Download sec. %s\n", get_secstr(fgroup.DLSec));
|
|
|
|
fprintf(fp, " Upload sec. %s\n", get_secstr(fgroup.UPSec));
|
|
|
|
fprintf(fp, " List security %s\n", get_secstr(fgroup.LTSec));
|
2002-09-29 20:08:32 +00:00
|
|
|
fprintf(fp, " Def. tic sec. %s\n", getflag(fgroup.LinkSec.flags, fgroup.LinkSec.notflags));
|
2002-04-15 13:38:35 +00:00
|
|
|
fprintf(fp, " BBS group %s\n", fgroup.BbsGroup);
|
|
|
|
fprintf(fp, " Announce group %s\n", fgroup.AnnGroup);
|
|
|
|
fprintf(fp, " Upload area %d\n", fgroup.Upload);
|
|
|
|
fprintf(fp, " Start date %s", ctime(&fgroup.StartDate));
|
|
|
|
fprintf(fp, " Last date %s\n", ctime(&fgroup.LastDate));
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fclose(no);
|
|
|
|
return page;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|