This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
deb-mbse/mbsetup/m_fgroup.c

905 lines
28 KiB
C
Raw Normal View History

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.
*
*****************************************************************************
2004-02-01 17:04:00 +00:00
* Copyright (C) 1997-2004
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
2003-08-15 20:05:34 +00:00
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
2001-08-17 05:46:24 +00:00
*****************************************************************************/
2002-06-30 12:48:44 +00:00
#include "../config.h"
2004-02-21 17:22:00 +00:00
#include "../lib/mbselib.h"
2001-08-17 05:46:24 +00:00
#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
*/
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
}
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);
2004-03-20 23:00:22 +00:00
disk_reset();
2001-08-17 05:46:24 +00:00
Syslog('+', "Updated \"fgroups.data\"");
2004-02-05 21:05:31 +00:00
if (!force)
working(6, 0, 0);
2001-08-17 05:46:24 +00:00
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);
2002-04-15 13:38:35 +00:00
fgroup.FileGate = TRUE;
fgroup.Secure = TRUE;
fgroup.VirScan = TRUE;
fgroup.Announce = TRUE;
fgroup.FileId = TRUE;
fgroup.DupCheck = TRUE;
fgroup.Replace = TRUE;
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);
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);
mbse_mvprintw( 4, 2, "10.1 EDIT FILE GROUP");
2001-08-17 05:46:24 +00:00
set_color(CYAN, BLACK);
mbse_mvprintw( 6, 2, "1. Name");
mbse_mvprintw( 7, 2, "2. Comment");
mbse_mvprintw( 8, 2, "3. Base path");
mbse_mvprintw( 9, 2, "4. Use Aka");
mbse_mvprintw(10, 2, "5. Uplink");
mbse_mvprintw(11, 2, "6. Areas");
mbse_mvprintw(12, 2, "7. Filegate");
mbse_mvprintw(13, 2, "8. Banner");
mbse_mvprintw(14, 2, "9. Convert");
mbse_mvprintw(15, 2, "10. BBS group");
mbse_mvprintw(16, 2, "11. New group");
mbse_mvprintw(17, 2, "12. Active");
mbse_mvprintw(18, 2, "13. Deleted");
mbse_mvprintw(19, 2, "14. Start at");
mbse_mvprintw(12,32, "15. Auto chng");
mbse_mvprintw(13,32, "16. User chng");
mbse_mvprintw(14,32, "17. Replace");
mbse_mvprintw(15,32, "18. Dupecheck");
mbse_mvprintw(16,32, "19. Secure");
mbse_mvprintw(17,32, "20. Touch");
mbse_mvprintw(18,32, "21. Virscan");
mbse_mvprintw(19,32, "22. Announce");
mbse_mvprintw(11,56, "23. Upd magic");
mbse_mvprintw(12,56, "24. File ID");
mbse_mvprintw(13,56, "25. Conv. all");
mbse_mvprintw(14,56, "26. Send orig");
mbse_mvprintw(15,56, "27. DL sec");
mbse_mvprintw(16,56, "28. UP sec");
mbse_mvprintw(17,56, "29. LT sec");
mbse_mvprintw(18,56, "30. Upl. area");
mbse_mvprintw(19,56, "31. 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;
char mfile[PATH_MAX], temp[13];
2001-08-17 05:46:24 +00:00
long offset;
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));
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);
2004-03-06 21:48:41 +00:00
show_bool(12,46, fgroup.AutoChange);
show_bool(13,46, fgroup.UserChange);
show_bool(14,46, fgroup.Replace);
show_bool(15,46, fgroup.DupCheck);
show_bool(16,46, fgroup.Secure);
show_bool(17,46, fgroup.Touch);
show_bool(18,46, fgroup.VirScan);
show_bool(19,46, fgroup.Announce);
show_bool(11,70, fgroup.UpdMagic);
show_bool(12,70, fgroup.FileId);
show_bool(13,70, fgroup.ConvertAll);
show_bool(14,70, fgroup.SendOrg);
show_int( 15,70, fgroup.DLSec.level);
show_int( 16,70, fgroup.UPSec.level);
show_int( 17,70, fgroup.LTSec.level);
show_int( 18,70, fgroup.Upload);
j = select_menu(31);
2001-08-17 05:46:24 +00:00
switch(j) {
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;
2004-02-05 21:05:31 +00:00
working(6, 0, 0);
2001-08-17 05:46:24 +00:00
}
}
IsDoing("Browsing Menu");
return 0;
case 1: if (CheckFgroup())
break;
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) {
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")
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;
2005-06-13 18:36:38 +00:00
case 6: E_STR( 11,16,12,fgroup.AreaFile, "The name of the ^Areas File^ from the uplink (case sensitive)")
2002-04-15 13:38:35 +00:00
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 (fgroup.Active && CheckFgroup())
2002-04-15 13:38:35 +00:00
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")
2004-03-06 21:48:41 +00:00
case 15:E_BOOL(12,46, fgroup.AutoChange, "^Automatic change areas^ when a new arealist is received")
case 16:tmp = edit_bool(13,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;
2004-03-06 21:48:41 +00:00
case 17:E_BOOL(14,46, fgroup.Replace, "Set ^Replace^ in new created tic areas")
case 18:E_BOOL(15,46, fgroup.DupCheck, "Set ^Dupe check^ in new created tic areas")
case 19:E_BOOL(16,46, fgroup.Secure, "Set ^Secure^ tic processing in new created tic areas")
case 20:E_BOOL(17,46, fgroup.Touch, "Set ^Touch filedate^ in new created tic areas")
case 21:E_BOOL(18,46, fgroup.VirScan, "Set ^Virus scanner^ in new created tic areas")
case 22:E_BOOL(19,46, fgroup.Announce, "Set ^Announce files^ in new created tic areas")
case 23:E_BOOL(11,70, fgroup.UpdMagic, "Set ^Update magic^ in new created tic areas")
case 24:E_BOOL(12,70, fgroup.FileId, "Set ^FILE_ID.DIZ extract^ in new created tic areas")
case 25:tmp = edit_bool(13,70, fgroup.ConvertAll, (char *)"Set ^Convert All^ setting in new created tic areas");
2002-05-10 14:23:24 +00:00
if (tmp && !fgroup.ConvertAll && (strlen(fgroup.Convert) == 0))
errmsg("No archiver configured to convert to, edit 9 first");
else
fgroup.ConvertAll = tmp;
break;
2004-03-06 21:48:41 +00:00
case 26:E_BOOL(14,70, fgroup.SendOrg, "Set ^Send original^ setting in new created tic areas")
case 27:E_SEC( 15,70, fgroup.DLSec, "10.1.27 FILE GROUP DOWNLOAD SECURITY", FgScreen)
case 28:E_SEC( 16,70, fgroup.UPSec, "10.1.28 FILE GROUP UPLOAD SECURITY", FgScreen)
case 29:E_SEC( 17,70, fgroup.LTSec, "10.1.29 FILE GROUP LIST SECURITY", FgScreen)
case 30:E_INT( 18,70, fgroup.Upload, "Set the default ^Upload area^ in new created file areas")
case 31:fgroup.LinkSec = edit_asec(fgroup.LinkSec, (char *)"10.1.31 DEFAULT NEW TIC AREAS SECURITY");
FgScreen();
break;
2001-08-17 05:46:24 +00:00
}
}
return 0;
}
void EditFGroup(void)
{
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;
}
o = 0;
if (! check_free())
return;
for (;;) {
2001-08-17 05:46:24 +00:00
clr_index();
set_color(WHITE, BLACK);
mbse_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';
mbse_mvprintw(y, x, temp);
y++;
}
}
fclose(fil);
}
2001-08-17 05:46:24 +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;
}
2001-08-17 05:46:24 +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);
} else {
errmsg("Cannot add group, change global setting in menu 1.11.5");
}
}
2001-08-17 05:46:24 +00:00
if (strncmp(pick, "N", 1) == 0)
if ((o + 20) < records)
o += 20;
2001-08-17 05:46:24 +00:00
if (strncmp(pick, "P", 1) == 0)
if ((o - 20) >= 0)
o -= 20;
2001-08-17 05:46:24 +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
}
}
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;
}
for (;;) {
clr_index();
set_color(WHITE, BLACK);
sprintf(temp, "%s. FILE GROUP SELECT", shdr);
mbse_mvprintw( 5, 4, temp);
2001-08-17 05:46:24 +00:00
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';
mbse_mvprintw(y, x, temp);
2001-08-17 05:46:24 +00:00
y++;
}
}
fclose(fil);
}
}
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)
{
2004-03-27 20:05:59 +00:00
char *temp, group[13];
FILE *ti, *wp, *ip, *no;
int refs, i, First = TRUE;;
2004-03-24 22:23:21 +00:00
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
if ((no = fopen(temp, "r")) == NULL) {
2002-04-15 13:38:35 +00:00
free(temp);
2004-03-24 22:23:21 +00:00
return page;
}
2001-08-17 05:46:24 +00:00
2004-03-24 22:23:21 +00:00
fread(&fgrouphdr, sizeof(fgrouphdr), 1, no);
fseek(no, 0, SEEK_SET);
fread(&fgrouphdr, fgrouphdr.hdrsize, 1, no);
ip = open_webdoc((char *)"filegroup.html", (char *)"File Groups", NULL);
fprintf(ip, "<A HREF=\"index.html\">Main</A>\n");
fprintf(ip, "<P>\n");
fprintf(ip, "<TABLE border='1' cellspacing='0' cellpadding='2'>\n");
fprintf(ip, "<TBODY>\n");
fprintf(ip, "<TR><TH align='left'>Group</TH><TH align='left'>Comment</TH><TH align='left'>Active</TH></TR>\n");
2004-03-24 22:23:21 +00:00
while ((fread(&fgroup, fgrouphdr.recsize, 1, no)) == 1) {
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
2004-03-24 22:23:21 +00:00
sprintf(temp, "filegroup_%s.html", fgroup.Name);
fprintf(ip, " <TR><TD><A HREF=\"%s\">%s</A></TD><TD>%s</TD><TD>%s</TD></TR>\n",
temp, fgroup.Name, fgroup.Comment, getboolean(fgroup.Active));
2004-03-24 22:23:21 +00:00
if ((wp = open_webdoc(temp, (char *)"File group", fgroup.Comment))) {
fprintf(wp, "<A HREF=\"index.html\">Main</A>&nbsp;<A HREF=\"filegroup.html\">Back</A>\n");
fprintf(wp, "<P>\n");
2004-03-28 19:36:30 +00:00
fprintf(wp, "<TABLE width='600' border='0' cellspacing='0' cellpadding='2'>\n");
fprintf(wp, "<COL width='30%%'><COL width='70%%'>\n");
2004-03-24 22:23:21 +00:00
fprintf(wp, "<TBODY>\n");
add_webtable(wp, (char *)"Group name", fgroup.Name);
add_webtable(wp, (char *)"Comment", fgroup.Comment);
add_webtable(wp, (char *)"Active", getboolean(fgroup.Active));
add_webtable(wp, (char *)"Use Aka", aka2str(fgroup.UseAka));
add_webtable(wp, (char *)"Uplink Aka", aka2str(fgroup.UpLink));
add_webtable(wp, (char *)"Areas file", fgroup.AreaFile);
sprintf(temp, "%ld", fgroup.StartArea);
add_webtable(wp, (char *)"Start autocreate BBS area", temp);
add_webtable(wp, (char *)"Banner file", fgroup.Banner);
add_webtable(wp, (char *)"Default archiver", fgroup.Convert);
add_webtable(wp, (char *)"Area file in Filegate format", getboolean(fgroup.FileGate));
add_webtable(wp, (char *)"Auto change areas", getboolean(fgroup.AutoChange));
add_webtable(wp, (char *)"User (downlink) change areas", getboolean(fgroup.UserChange));
add_webtable(wp, (char *)"Allow replace", getboolean(fgroup.Replace));
add_webtable(wp, (char *)"Dupe checking", getboolean(fgroup.DupCheck));
add_webtable(wp, (char *)"Secure processing", getboolean(fgroup.Secure));
add_webtable(wp, (char *)"Touch file dates", getboolean(fgroup.Touch));
add_webtable(wp, (char *)"Virus scan", getboolean(fgroup.VirScan));
add_webtable(wp, (char *)"Announce", getboolean(fgroup.Announce));
add_webtable(wp, (char *)"Allow update magics", getboolean(fgroup.UpdMagic));
add_webtable(wp, (char *)"Extract FILE_ID.DIZ", getboolean(fgroup.FileId));
add_webtable(wp, (char *)"Convert all archives", getboolean(fgroup.ConvertAll));
add_webtable(wp, (char *)"Send original file", getboolean(fgroup.SendOrg));
add_webtable(wp, (char *)"Base path for new areas", fgroup.BasePath);
web_secflags(wp, (char *)"Download security", fgroup.DLSec);
web_secflags(wp, (char *)"Upload security", fgroup.UPSec);
web_secflags(wp, (char *)"List security", fgroup.LTSec);
add_webtable(wp, (char *)"Default tic security", getflag(fgroup.LinkSec.flags, fgroup.LinkSec.notflags));
fprintf(wp, "<TR><TH align='left'>BBS (tic) file group</TH><TD><A HREF=\"filegroup_%s.html\">%s</A></TD></TH>\n",
fgroup.BbsGroup, fgroup.BbsGroup);
2004-03-28 19:36:30 +00:00
fprintf(wp, "<TR><TH align='left'>Newfiles announce group</TH><TD><A HREF=\"newgroup.html\">%s</A></TD></TH>\n",
fgroup.AnnGroup);
2004-03-24 22:23:21 +00:00
sprintf(temp, "%d", fgroup.Upload);
add_webtable(wp, (char *)"Upload area", temp);
add_webtable(wp, (char *)"Start date", ctime(&fgroup.StartDate));
add_webtable(wp, (char *)"Last active date", ctime(&fgroup.LastDate));
fprintf(wp, "</TBODY>\n");
fprintf(wp, "</TABLE>\n");
2004-03-27 20:05:59 +00:00
fprintf(wp, "<HR>\n");
fprintf(wp, "<H3>BBS File Areas Reference</H3>\n");
i = refs = 0;
sprintf(temp, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
if ((ti = fopen(temp, "r"))) {
fread(&areahdr, sizeof(areahdr), 1, ti);
while ((fread(&area, areahdr.recsize, 1, ti)) == 1) {
i++;
if (area.Available && (strcmp(fgroup.Name, area.BbsGroup) == 0)) {
if (refs == 0) {
fprintf(wp, "<TABLE width='600' border='0' cellspacing='0' cellpadding='2'>\n");
fprintf(wp, "<COL width='20%%'><COL width='80%%'>\n");
fprintf(wp, "<TBODY>\n");
}
2004-03-28 15:51:29 +00:00
fprintf(wp, "<TR><TD><A HREF=\"filearea_%d.html\">Area %d</A></TD><TD>%s</TD></TR>\n", i, i, area.Name);
2004-03-27 20:05:59 +00:00
refs++;
}
}
fclose(ti);
}
if (refs == 0)
fprintf(wp, "No BBS File Areas References\n");
else {
fprintf(wp, "</TBODY>\n");
fprintf(wp, "</TABLE>\n");
}
fprintf(wp, "<HR>\n");
fprintf(wp, "<H3>TIC Areas Reference</H3>\n");
refs = 0;
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
if ((ti = fopen(temp, "r"))) {
fread(&tichdr, sizeof(tichdr), 1, ti);
fseek(ti, 0, SEEK_SET);
fread(&tichdr, tichdr.hdrsize, 1, ti);
while ((fread(&tic, tichdr.recsize, 1, ti)) == 1) {
if (strcmp(fgroup.Name, tic.Group) == 0) {
if (refs == 0) {
fprintf(wp, "<TABLE width='600' border='0' cellspacing='0' cellpadding='2'>\n");
fprintf(wp, "<COL width='20%%'><COL width='80%%'>\n");
fprintf(wp, "<TBODY>\n");
}
2004-03-28 15:51:29 +00:00
fprintf(wp, "<TR><TD><A HREF=\"ticarea_%s.html\">%s</A></TD><TD>%s</TD></TR>\n",
tic.Name, tic.Name, tic.Comment);
2004-03-27 20:05:59 +00:00
refs++;
}
fseek(ti, tichdr.syssize, SEEK_CUR);
}
fclose(ti);
}
if (refs == 0)
fprintf(wp, "No TIC Areas References\n");
else {
fprintf(wp, "</TBODY>\n");
fprintf(wp, "</TABLE>\n");
}
fprintf(wp, "<HR>\n");
fprintf(wp, "<H3>Nodes Reference</H3>\n");
refs = 0;
sprintf(temp, "%s/etc/nodes.data", getenv("MBSE_ROOT"));
if ((ti = fopen(temp, "r"))) {
fread(&nodeshdr, sizeof(nodeshdr), 1, ti);
fseek(ti, 0, SEEK_SET);
fread(&nodeshdr, nodeshdr.hdrsize, 1, ti);
while ((fread(&nodes, nodeshdr.recsize, 1, ti)) == 1) {
for (i = 0; i < nodeshdr.filegrp / sizeof(group); i++) {
fread(&group, sizeof(group), 1, ti);
if (strcmp(group, fgroup.Name) == 0) {
if (refs == 0) {
fprintf(wp, "<TABLE width='600' border='0' cellspacing='0' cellpadding='2'>\n");
fprintf(wp, "<COL width='20%%'><COL width='80%%'>\n");
fprintf(wp, "<TBODY>\n");
}
2004-03-28 15:51:29 +00:00
fprintf(wp, "<TR><TD><A HREF=\"node_%d_%d_%d_%d_%s.html\">%s</A></TD><TD>%s</TD></TR>\n",
nodes.Aka[0].zone, nodes.Aka[0].net, nodes.Aka[0].node, nodes.Aka[0].point,
nodes.Aka[0].domain, aka2str(nodes.Aka[0]), nodes.Sysop);
2004-03-27 20:05:59 +00:00
refs++;
}
}
fseek(ti, nodeshdr.mailgrp, SEEK_CUR);
}
fclose(ti);
}
if (refs == 0)
fprintf(wp, "No Nodes References\n");
else {
fprintf(wp, "</TBODY>\n");
fprintf(wp, "</TABLE>\n");
}
2004-03-28 15:51:29 +00:00
fprintf(wp, "<HR>\n");
fprintf(wp, "<H3>Group Statistics</H3>\n");
add_statcnt(wp, (char *)"processed files", fgroup.Files);
add_statcnt(wp, (char *)"KBytes of files", fgroup.KBytes);
close_webdoc(wp);
2001-08-17 05:46:24 +00:00
}
2004-03-24 22:23:21 +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, " 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));
fprintf(fp, " Touch dates %s\n", getboolean(fgroup.Touch));
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));
fprintf(fp, " Def. tic sec. %s\n", getflag(fgroup.LinkSec.flags, fgroup.LinkSec.notflags));
fprintf(fp, " BBS group %s\n", fgroup.BbsGroup);
fprintf(fp, " Newfiles 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
fprintf(ip, "</TBODY>\n");
fprintf(ip, "</TABLE>\n");
2004-03-24 22:23:21 +00:00
close_webdoc(ip);
fclose(no);
free(temp);
return page;
2001-08-17 05:46:24 +00:00
}