summaryrefslogtreecommitdiff
path: root/src/configreader.cpp
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2013-06-05 17:52:39 -0700
committerAttila Molnar <attilamolnar@hush.com>2013-06-05 17:52:39 -0700
commitf00ac52c5d593fcb761fc316b2582bb06158035c (patch)
treebec88a8a69c4a912606636c9df6283c154962fef /src/configreader.cpp
parentd9d99cd02dadf34bfcc220734ba0c422f0acb3e6 (diff)
parent5d0b2b7cfccf057e7abab94c41065f94420899cd (diff)
Merge pull request #544 from SaberUK/master+kill-maxbuf
Purge MAXBUF in favour of a configuration option.
Diffstat (limited to 'src/configreader.cpp')
-rw-r--r--src/configreader.cpp39
1 files changed, 31 insertions, 8 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp
index a8c0abe89..905eb786a 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -367,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<size_t>(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");
@@ -423,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);
@@ -767,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 ? "&quot;" : "\"";
+ break;
+ case '&':
+ escaped += xml ? "&amp;" : "&";
+ break;
+ case '\\':
+ escaped += xml ? "\\" : "\\\\";
+ break;
+ default:
+ escaped += *it;
+ break;
+ }
}
+ return escaped;
}
const char* ServerConfig::CleanFilename(const char* name)