/* * 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 #include #include "config.h" CONFIG cfg; /************************************************************************/ /* */ /* */ /************************************************************************/ void init_cfg(void) { char *cp; memset(&cfg, 0, sizeof(cfg)); if((cp = getenv("CHANGIWORKDIR")) != NULL) fine_dir(strcpy(cfg.workdir, cp), NULL); else fine_dir(getcwd(cfg.workdir, sizeof(cfg.workdir)), NULL); fine_dir(strcpy(cfg.logfile, "expire.log"), cfg.workdir); fine_dir(strcpy(cfg.configfile, "changi.cfg"), cfg.workdir); fine_dir(strcpy(cfg.pidfile, "expire.pid"), cfg.workdir); cfg.expiredays = 7; cfg.forgetdays = 7; } /************************************************************************/ /* */ /* */ /************************************************************************/ int validate_cfg(void) { int result = 1; char *cp; if(fine_dir(cfg.activefile, cfg.workdir) == NULL) fine_dir(strcpy(cfg.activefile, "active"), cfg.workdir); strcpy(cfg.newactfile, cfg.activefile); strcat(cfg.newactfile, ".new"); strcpy(cfg.oldactfile, cfg.activefile); strcat(cfg.oldactfile, ".old"); if(fine_dir(cfg.historyfile, cfg.workdir) == NULL) fine_dir(strcpy(cfg.historyfile, "history"), cfg.workdir); strcpy(cfg.newhistfile, cfg.historyfile); if((cp = strrchr(cfg.newhistfile, '\\')) == NULL) cp = cfg.newhistfile; else cp++; strcpy(cp, "newhist"); strcpy(cfg.oldhistfile, cfg.historyfile); if((cp = strrchr(cfg.oldhistfile, '\\')) == NULL) cp = cfg.oldhistfile; else cp++; strcpy(cp, "oldhist"); if(fine_dir(cfg.newsdir, cfg.workdir) == NULL) fine_dir(strcpy(cfg.newsdir, "news"), cfg.workdir); tzset(); time(&cfg.expiretime); cfg.forgettime = (cfg.expiretime += timezone); cfg.expiretime -= (time_t)cfg.expiredays * 60L * 60L * 24L; cfg.forgettime -= (time_t)cfg.forgetdays * 60L * 60L * 24L; /* TEST VALUES */ /* cfg.expiretime = 801827242; */ if(cfg.forgettime > cfg.expiretime) cfg.forgettime = cfg.expiretime; return(result); }