]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/configreader.cpp
Whoops, make /stats s work
[user/henk/code/inspircd.git] / src / configreader.cpp
index 293cf996400a4a215ea2447394cf170748f735bb..b8719fcd85b1e149ff6ade231a3f66d1ec57c396 100644 (file)
@@ -28,7 +28,7 @@ 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;
        CycleHosts = writelog = AllowHalfop = true;
@@ -518,7 +518,7 @@ void ServerConfig::Read(bool bail, userrec* user)
        std::ostringstream errstr;      /* String stream containing the error output */
 
        /* These tags MUST occur and must ONLY occur once in the config file */
-       static char* Once[] = { "server", "admin", "files", "power", "options", "pid", NULL };
+       static char* Once[] = { "server", "admin", "files", "power", "options", NULL };
 
        /* These tags can occur ONCE or not at all */
        static InitialConfig Values[] = {
@@ -533,7 +533,7 @@ void ServerConfig::Read(bool bail, userrec* user)
                {"files",               "motd",                         &this->motd,                    DT_CHARPTR, ValidateMotd},
                {"files",               "rules",                        &this->rules,                   DT_CHARPTR, ValidateRules},
                {"power",               "diepass",                      &this->diepass,                 DT_CHARPTR, NoValidation},      
-               {"power",               "pauseval",                     &this->DieDelay,                DT_INTEGER, NoValidation},
+               {"power",               "pause",                        &this->DieDelay,                DT_INTEGER, NoValidation},
                {"power",               "restartpass",                  &this->restartpass,             DT_CHARPTR, NoValidation},
                {"options",             "prefixquit",                   &this->PrefixQuit,              DT_CHARPTR, NoValidation},
                {"die",                 "value",                        &this->DieValue,                DT_CHARPTR, NoValidation},
@@ -545,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},
@@ -771,7 +771,8 @@ void ServerConfig::Read(bool bail, userrec* user)
         */
        if (!bail)
        {
-               ServerInstance->stats->BoundPortCount = ServerInstance->BindPorts(false);
+               int found_ports;
+               ServerInstance->stats->BoundPortCount = ServerInstance->BindPorts(false, found_ports);
 
                if (!removed_modules.empty())
                        for (std::vector<std::string>::iterator removing = removed_modules.begin(); removing != removed_modules.end(); removing++)
@@ -904,6 +905,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;
                        }
@@ -1068,7 +1071,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 == '"')
@@ -1266,23 +1272,32 @@ bool ServerConfig::ReadFile(file_cache &F, const char* fname)
        char linebuf[MAXBUF];
 
        F.clear();
-       file =  fopen(fname,"r");
+       
+       if (*fname != '/')
+       {
+               std::string::size_type pos;
+               std::string confpath = CONFIG_FILE;
+               if((pos = confpath.find("/inspircd.conf")) != std::string::npos)
+               {
+                       /* Leaves us with just the path */
+                       std::string newfile = confpath.substr(0, pos) + std::string("/") + fname;
+                       file =  fopen(newfile.c_str(), "r");
+                       
+               }
+       }
+       else
+               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 : " ");
                        }
                }