diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-03-25 02:52:43 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-03-25 02:52:43 +0000 |
commit | 0340f1a432d684347d8dbc3aa85c8436c56d4039 (patch) | |
tree | 0da4a282f28b42d5447ff2ee6f645c7936cf4383 /src/inspircd.cpp | |
parent | 0825e274f6e047c3e948334b8fdbc0189dba3e32 (diff) |
Added a lot of config error checking
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@898 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r-- | src/inspircd.cpp | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 92808bd0b..634e5ac3f 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -302,13 +302,45 @@ void readfile(file_cache &F, const char* fname) log(DEBUG,"readfile: loaded %s, %d lines",fname,F.size()); } -void ReadConfig(void) +void ReadConfig(bool bail, userrec* user) { char dbg[MAXBUF],pauseval[MAXBUF],Value[MAXBUF],timeout[MAXBUF],NB[MAXBUF],flood[MAXBUF],MW[MAXBUF]; char AH[MAXBUF],AP[MAXBUF],AF[MAXBUF]; ConnectClass c; + std::stringstream errstr; - LoadConf(CONFIG_FILE,&config_f); + if (!LoadConf(CONFIG_FILE,&config_f,&errstr)) + { + errstr.seekg(0); + if (bail) + { + printf("There were errors in your configuration:\n%s",errstr.str().c_str()); + exit(0); + } + else + { + char dataline[1024]; + if (user) + { + WriteServ(user->fd,"NOTICE %s :There were errors in the configuration file:",user->nick); + while (!errstr.eof()) + { + errstr.getline(dataline,1024); + WriteServ(user->fd,"NOTICE %s :%s",user->nick,dataline); + } + } + else + { + WriteOpers("There were errors in the configuration file:",user->nick); + while (!errstr.eof()) + { + errstr.getline(dataline,1024); + WriteOpers(dataline); + } + } + return; + } + } ConfValue("server","name",0,ServerName,&config_f); ConfValue("server","description",0,ServerDesc,&config_f); @@ -3172,7 +3204,7 @@ int InspIRCd(void) SetupCommandTable(); log(DEBUG,"InspIRCd: startup: default command table set up"); - ReadConfig(); + ReadConfig(true,NULL); if (strcmp(DieValue,"")) { printf("WARNING: %s\n\n",DieValue); |