/* * This part was written by Harald Kipp * * Bug reports should be sent to * * harald@os2point.ping.de * harald@haport.sesam.com * Fido: 2:2448/434 * * This module contains routines to read the configuration file. * */ #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, "inews.log"), cfg.workdir); fine_dir(strcpy(cfg.configfile, "changi.cfg"), cfg.workdir); fine_dir(strcpy(cfg.pidfile, "inews.pid"), cfg.workdir); cfg.grade = 'd'; } /************************************************************************/ /* */ /* */ /************************************************************************/ int validate_cfg(void) { int result = 0; char *cp; /* * Get node and domain from environment */ if(!cfg.mydomain[0]) { if((cp = getenv("HOSTNAME")) != NULL) strcpy(cfg.mydomain, cp); } if(!cfg.mynode[0]) { if((cp = strchr(cfg.mydomain, '.')) != NULL) *cp = '\0'; strcpy(cfg.mynode, cfg.mydomain); if(cp) *cp = '.'; } /* * Get name of newsserver from environment */ if(!cfg.newsserver[0] && (cp = getenv("NNTPSERVER")) != NULL) { strncpy(cfg.newsserver, cp, sizeof(cfg.newsserver)); if((cp = strchr(cfg.newsserver, '.')) != NULL) *cp = '\0'; } if(!cfg.mynode[0]) lprintf("Missing my node name"); else if(!cfg.mydomain[0]) lprintf("Missing my domain name"); else if(!cfg.newsserver[0]) lprintf("Missing newsserver name"); else { if (!cfg.rnewscall[0]) strcpy(cfg.rnewscall, "rnews"); if(fine_dir(cfg.spooldir, cfg.workdir) == NULL) fine_dir(strcpy(cfg.spooldir, "spool"), cfg.workdir); result = 1; } return(result); }