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/lib/dbcfg.c

97 lines
2.4 KiB
C
Raw Normal View History

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 ...............: Config Database.
*
*****************************************************************************
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 "libs.h"
#include "mbse.h"
#include "structs.h"
2002-01-07 19:16:03 +00:00
#include "users.h"
2001-08-17 05:46:24 +00:00
#include "records.h"
#include "dbcfg.h"
void InitConfig(void)
{
if ((getenv("MBSE_ROOT")) == NULL) {
printf("Could not get MBSE_ROOT environment variable\n");
printf("Please set the environment variable ie:\n");
printf("\"MBSE_ROOT=/opt/mbse;export MBSE_ROOT\"\n\n");
exit(1);
}
LoadConfig();
}
void LoadConfig(void)
{
FILE *pDataFile;
char *FileName;
FileName = calloc(PATH_MAX, sizeof(char));
sprintf(FileName, "%s/etc/config.data", getenv("MBSE_ROOT"));
if ((pDataFile = fopen(FileName, "r")) == NULL) {
perror("\n\nFATAL ERROR:");
printf(" Can't open %s\n", FileName);
printf("Please run mbsetup to create configuration file.\n");
printf("Or check that your MBSE_ROOT variable is set to the BBS path!\n\n");
free(FileName);
#ifdef MEMWATCH
mwTerm();
#endif
exit(1);
}
free(FileName);
fread(&CFG, sizeof(CFG), 1, pDataFile);
fclose(pDataFile);
}
int IsOurAka(fidoaddr taka)
{
int i;
for (i = 0; i < 40; i++) {
if ((taka.zone == CFG.aka[i].zone) &&
(taka.net == CFG.aka[i].net) &&
(taka.node == CFG.aka[i].node) &&
(taka.point == CFG.aka[i].point) &&
(CFG.akavalid[i]))
return TRUE;
}
return FALSE;
}