summaryrefslogtreecommitdiff
path: root/src/configreader.cpp
diff options
context:
space:
mode:
authoraquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-23 20:43:35 +0000
committeraquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-23 20:43:35 +0000
commit743c10e4ca5acd45e670b335a07b5bf3ab754ab6 (patch)
treeb71daa8b64cbbcdaba191afd9709dd896be12a6b /src/configreader.cpp
parent68730d4c9701b34c962302e6410908865fb2ba28 (diff)
Add ability to control what opertypes can set what operonly user/chan modes. This works the same way as commands, in that modes allowed by classes are added together, and * allows all.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9176 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/configreader.cpp')
-rw-r--r--src/configreader.cpp37
1 files changed, 30 insertions, 7 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 2093c82c8..83b7e14d9 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -925,9 +925,9 @@ void ServerConfig::Read(bool bail, User* user)
InitTypes, DoType, DoneClassesAndTypes},
{"class",
- {"name", "commands", NULL},
- {"", "", NULL},
- {DT_NOSPACES, DT_CHARPTR},
+ {"name", "commands", "usermodes", "chanmodes", NULL},
+ {"", "", "", "", NULL},
+ {DT_NOSPACES, DT_CHARPTR, DT_CHARPTR, DT_CHARPTR},
InitClasses, DoClass, DoneClassesAndTypes},
{NULL,
@@ -2105,8 +2105,12 @@ bool InitClasses(ServerConfig* conf, const char*)
{
for (operclass_t::iterator n = conf->operclass.begin(); n != conf->operclass.end(); n++)
{
- if (n->second)
- delete[] n->second;
+ if (n->second.commandlist)
+ delete[] n->second.commandlist;
+ if (n->second.cmodelist)
+ delete[] n->second.cmodelist;
+ if (n->second.umodelist)
+ delete[] n->second.umodelist;
}
}
@@ -2129,12 +2133,31 @@ bool DoType(ServerConfig* conf, const char*, char**, ValueList &values, int*)
/*
* XXX should this be in a class? -- w00t
*/
-bool DoClass(ServerConfig* conf, const char*, char**, ValueList &values, int*)
+bool DoClass(ServerConfig* conf, const char* tag, char**, ValueList &values, int*)
{
const char* ClassName = values[0].GetString();
const char* CommandList = values[1].GetString();
+ const char* UModeList = values[2].GetString();
+ const char* CModeList = values[3].GetString();
+
+ for (const char* c = UModeList; *c; ++c)
+ {
+ if ((*c < 'A' || *c > 'z') && *c != '*')
+ {
+ throw CoreException("Character " + std::string(1, *c) + " is not a valid mode in <class:usermodes>");
+ }
+ }
+ for (const char* c = CModeList; *c; ++c)
+ {
+ if ((*c < 'A' || *c > 'z') && *c != '*')
+ {
+ throw CoreException("Character " + std::string(1, *c) + " is not a valid mode in <class:chanmodes>");
+ }
+ }
- conf->operclass[ClassName] = strnewdup(CommandList);
+ conf->operclass[ClassName].commandlist = strnewdup(CommandList);
+ conf->operclass[ClassName].umodelist = strnewdup(UModeList);
+ conf->operclass[ClassName].cmodelist = strnewdup(CModeList);
return true;
}