]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/configreader.cpp
Whoops, forgot to init a var
[user/henk/code/inspircd.git] / src / configreader.cpp
index e983bbc9029f2ef8af6e32b1fad74585d2e1704e..1059770b456aa6bc7410e49a22126c4abfd273d2 100644 (file)
  * ---------------------------------------------------
  */
 
-#include "inspircd_config.h"
 #include "configreader.h"
-#include <string>
 #include <sstream>
-#include <iostream>
 #include <fstream>
 #include "inspircd.h"
-#include "inspstring.h"
-#include "helperfuncs.h"
-#include "userprocess.h"
 #include "xline.h"
 
 std::vector<std::string> old_module_names, new_module_names, added_modules, removed_modules;
@@ -34,10 +28,10 @@ ServerConfig::ServerConfig(InspIRCd* Instance) : ServerInstance(Instance)
        *TempDir = *ServerName = *Network = *ServerDesc = *AdminName = '\0';
        *HideWhoisServer = *AdminEmail = *AdminNick = *diepass = *restartpass = '\0';
        *CustomVersion = *motd = *rules = *PrefixQuit = *DieValue = *DNSServer = '\0';
-       *OperOnlyStats = *ModPath = *MyExecutable = *DisabledCommands = *PID = '\0';
+       *UserStats = *ModPath = *MyExecutable = *DisabledCommands = *PID = '\0';
        log_file = NULL;
        NoUserDns = forcedebug = OperSpyWhois = nofork = HideBans = HideSplits = false;
-       writelog = AllowHalfop = true;
+       CycleHosts = writelog = AllowHalfop = true;
        dns_timeout = DieDelay = 5;
        MaxTargets = 20;
        NetBufferSize = 10240;
@@ -551,7 +545,7 @@ void ServerConfig::Read(bool bail, userrec* user)
                {"dns",                 "timeout",                      &this->dns_timeout,             DT_INTEGER, ValidateDnsTimeout},
                {"options",             "moduledir",                    &this->ModPath,                 DT_CHARPTR, ValidateModPath},
                {"disabled",            "commands",                     &this->DisabledCommands,        DT_CHARPTR, NoValidation},
-               {"options",             "operonlystats",                &this->OperOnlyStats,           DT_CHARPTR, NoValidation},
+               {"options",             "userstats",            &this->UserStats,               DT_CHARPTR, NoValidation},
                {"options",             "customversion",                &this->CustomVersion,           DT_CHARPTR, NoValidation},
                {"options",             "hidesplits",                   &this->HideSplits,              DT_BOOLEAN, NoValidation},
                {"options",             "hidebans",                     &this->HideBans,                DT_BOOLEAN, NoValidation},
@@ -560,6 +554,7 @@ void ServerConfig::Read(bool bail, userrec* user)
                {"options",             "tempdir",                      &this->TempDir,                 DT_CHARPTR, ValidateTempDir},
                {"options",             "nouserdns",                    &this->NoUserDns,               DT_BOOLEAN, NoValidation},
                {"options",             "syntaxhints",                  &this->SyntaxHints,             DT_BOOLEAN, NoValidation},
+               {"options",             "cyclehosts",                   &this->CycleHosts,              DT_BOOLEAN, NoValidation},
                {"pid",                 "file",                         &this->PID,                     DT_CHARPTR, NoValidation},
                {NULL}
        };
@@ -634,24 +629,8 @@ void ServerConfig::Read(bool bail, userrec* user)
        if (this->LoadConf(newconfig, CONFIG_FILE, errstr))
        {
                /* If we succeeded, set the ircd config to the new one */
-               this->config_data = newconfig;
-               
-/*             int c = 1;
-               std::string last;
-               
-               for(ConfigDataHash::const_iterator i = this->config_data.begin(); i != this->config_data.end(); i++)
-               {
-                       c = (i->first != last) ? 1 : c+1;
-                       last = i->first;
-                       
-                       std::cout << "[" << i->first << " " << c << "/" << this->config_data.count(i->first) << "]" << std::endl;
-                       
-                       for(KeyValList::const_iterator j = i->second.begin(); j != i->second.end(); j++)
-                               std::cout << "\t" << j->first << " = " << j->second << std::endl;
-                       
-                       std::cout << "[/" << i->first << " " << c << "/" << this->config_data.count(i->first) << "]" << std::endl;
-               }
- */    }
+               this->config_data = newconfig;  
+       }
        else
        {
                ServerInstance->Log(DEFAULT, "There were errors in your configuration:\n%s", errstr.str().c_str());
@@ -925,6 +904,8 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
                        if (conf.get(real_character))
                        {
                                ServerInstance->Log(DEBUG,"Escaping %c", real_character);
+                               if (real_character == 'n')
+                                       real_character = '\n';
                                line += real_character;
                                continue;
                        }
@@ -1089,7 +1070,10 @@ bool ServerConfig::ParseLine(ConfigDataHash &target, std::string &line, long lin
                                if ((*c == '\\') && (in_quote))
                                {
                                        c++;
-                                       current_value += *c;
+                                       if (*c == 'n')
+                                               current_value += '\n';
+                                       else
+                                               current_value += *c;
                                        continue;
                                }
                                if (*c == '"')
@@ -1287,23 +1271,18 @@ bool ServerConfig::ReadFile(file_cache &F, const char* fname)
        char linebuf[MAXBUF];
 
        F.clear();
-       file =  fopen(fname,"r");
+       file =  fopen(fname, "r");
 
        if (file)
        {
                while (!feof(file))
                {
-                       fgets(linebuf,sizeof(linebuf),file);
-                       linebuf[strlen(linebuf)-1]='\0';
-
-                       if (!*linebuf)
-                       {
-                               strcpy(linebuf," ");
-                       }
+                       fgets(linebuf, sizeof(linebuf), file);
+                       linebuf[strlen(linebuf)-1] = 0;
 
                        if (!feof(file))
                        {
-                               F.push_back(linebuf);
+                               F.push_back(*linebuf ? linebuf : " ");
                        }
                }