X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fconfigreader.cpp;h=905eb786af84b0646b6ae4eca423e172cb903935;hb=bbeb5ea38686dfeb9537860770bbdb3bd2f9cd3f;hp=8951ec0eede43f6344cf2b65ee1292a21395d9d8;hpb=b36ce84c7da93f680fc397bcb4c877abe063eaaa;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/configreader.cpp b/src/configreader.cpp index 8951ec0ee..905eb786a 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -23,7 +23,6 @@ #include "inspircd.h" -#include #include "xline.h" #include "listmode.h" #include "exitcodes.h" @@ -368,10 +367,15 @@ void ServerConfig::Fill() else { if (ServerName != ConfValue("server")->getString("name")) - throw CoreException("You must restart to change the server name or SID"); + throw CoreException("You must restart to change the server name"); + std::string nsid = ConfValue("server")->getString("id"); if (!nsid.empty() && nsid != sid) - throw CoreException("You must restart to change the server name or SID"); + throw CoreException("You must restart to change the server id"); + + if (Limits.MaxLine != static_cast(ConfValue("limits")->getInt("maxline", 512))) + throw CoreException("You must restart to change the maximum line length"); + } diepass = ConfValue("power")->getString("diepass"); restartpass = ConfValue("power")->getString("restartpass"); @@ -424,6 +428,7 @@ void ServerConfig::Fill() Limits.MaxKick = ConfValue("limits")->getInt("maxkick", 255); Limits.MaxGecos = ConfValue("limits")->getInt("maxgecos", 128); Limits.MaxAway = ConfValue("limits")->getInt("maxaway", 200); + Limits.MaxLine = ConfValue("limits")->getInt("maxline", 512); InvBypassModes = options->getBool("invitebypassmodes", true); NoSnoticeStack = options->getBool("nosnoticestack", false); @@ -768,14 +773,31 @@ bool ServerConfig::FileExists(const char* file) if ((sb.st_mode & S_IFDIR) > 0) return false; - FILE *input = fopen(file, "r"); - if (input == NULL) - return false; - else + return !access(file, F_OK); +} + +std::string ServerConfig::Escape(const std::string& str, bool xml) +{ + std::string escaped; + for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) { - fclose(input); - return true; + switch (*it) + { + case '"': + escaped += xml ? """ : "\""; + break; + case '&': + escaped += xml ? "&" : "&"; + break; + case '\\': + escaped += xml ? "\\" : "\\\\"; + break; + default: + escaped += *it; + break; + } } + return escaped; } const char* ServerConfig::CleanFilename(const char* name) @@ -785,11 +807,6 @@ const char* ServerConfig::CleanFilename(const char* name) return (p != name ? ++p : p); } -const std::string& ServerConfig::GetSID() -{ - return sid; -} - void ConfigReaderThread::Run() { Config->Read();