/* * 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 #include #include #include #include #include "config.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, "chanx.log"), cfg.workdir); fine_dir(strcpy(cfg.configfile, "changi.cfg"), cfg.workdir); fine_dir(strcpy(cfg.pidfile, "chanx.pid"), cfg.workdir); fine_dir(strcpy(cfg.newsgroups, "newsgroups"), cfg.workdir); fine_dir(strcpy(cfg.newnwsgrps, "newsgroups.new"), cfg.workdir); fine_dir(strcpy(cfg.oldnwsgrps, "newsgroups.old"), cfg.workdir); strcpy(cfg.remoteport, "nntp"); } /************************************************************************/ /* */ /* */ /************************************************************************/ int validate_cfg(void) { int result = 1; if(fine_dir(cfg.spooldir, cfg.workdir) == NULL) fine_dir(strcpy(cfg.spooldir, "spool"), cfg.workdir); if(fine_dir(cfg.historyfile, cfg.workdir) == NULL) fine_dir(strcpy(cfg.historyfile, "history"), cfg.workdir); if(fine_dir(cfg.rnewscall, NULL) == NULL) strcpy(cfg.rnewscall, "rnews"); return(result); }