/*
* This part was written by Harald Kipp
*
* Bug reports should be sent to
*
* harald@os2point.ping.de
* harald@sesam.com
* Fido: 2:2448/434
*
* This module contains routines to read the configuration file.
*
*/
#include <os2.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <direct.h>
#include <lprintf.h>
#include <chanlib.h>
#include "config.h"
#include "globals.h"
#include "nntp.h"
#include "changi.h"
CONFIG cfg;
/************************************************************************/
/* */
/* */
/************************************************************************/
void init_cfg(void)
{
char *cp;
memset(&cfg, 0, sizeof(cfg));
if((cp = getenv("CHANGIWORKDIR")) != NULL)
strcpy(cfg.workdir, cp);
else
fine_dir(getcwd(cfg.workdir, sizeof(cfg.workdir)), NULL);
fine_dir(strcpy(cfg.logfile, "changi.log"), cfg.workdir);
fine_dir(strcpy(cfg.configfile, "changi.cfg"), cfg.workdir);
fine_dir(strcpy(cfg.pidfile, "changi.pid"), cfg.workdir);
}
/************************************************************************/
/* */
/* */
/************************************************************************/
int validate_cfg(void)
{
int result = 1;
fine_dir(cfg.accessfile, cfg.workdir);
if (fine_dir(cfg.activefile, cfg.workdir) == NULL)
fine_dir(strcpy(cfg.activefile, "active"), cfg.workdir);
if (fine_dir(cfg.active_times, cfg.workdir) == NULL)
fine_dir(strcpy(cfg.active_times, "active.times"), cfg.workdir);
if (fine_dir(cfg.historyfile, cfg.workdir) == NULL)
fine_dir(strcpy(cfg.historyfile, "history"), cfg.workdir);
if (fine_dir(cfg.newsdir, cfg.workdir) == NULL)
fine_dir(strcpy(cfg.newsdir, "news"), cfg.workdir);
if (fine_dir(cfg.inewscall, NULL) == NULL)
strcpy(cfg.inewscall, "inews");
if (fine_dir(cfg.rnewscall, NULL) == NULL)
strcpy(cfg.rnewscall, "rnews");
return(result);
}