summaryrefslogtreecommitdiffstats
path: root/src/modules/UserBackendMysql
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-08-06 21:28:41 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-08-06 21:28:41 +0200
commit0d1a7cb65b7b0f5ecc8e3cd6fbabdebab7f47f7f (patch)
treebd12565104b27cb6f28b8c0b2544dd65baf94b5b /src/modules/UserBackendMysql
parentf7d433e6e8559b4584263cae025d3addd1342df4 (diff)
downloadmad-0d1a7cb65b7b0f5ecc8e3cd6fbabdebab7f47f7f.tar
mad-0d1a7cb65b7b0f5ecc8e3cd6fbabdebab7f47f7f.zip
Revised server config format
Diffstat (limited to 'src/modules/UserBackendMysql')
-rw-r--r--src/modules/UserBackendMysql/UserBackendMysql.cpp188
1 files changed, 95 insertions, 93 deletions
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.cpp b/src/modules/UserBackendMysql/UserBackendMysql.cpp
index ebf86d5..3ef44d1 100644
--- a/src/modules/UserBackendMysql/UserBackendMysql.cpp
+++ b/src/modules/UserBackendMysql/UserBackendMysql.cpp
@@ -36,111 +36,113 @@ namespace UserBackendMysql {
const std::string UserBackendMysql::name("UserBackendMysql");
-bool UserBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) {
- if(handled)
+bool UserBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/) {
+ if(!entry[0].getKey().matches("UserManager"))
return false;
- if(entry[0].getKey().matches("UserBackendMysql")) {
- if(entry[1].getKey().matches("Host")) {
- if(entry[2].empty())
- host = entry[1][0];
+ if(entry[1].empty())
+ return true;
+
+ if(!entry[1].getKey().matches("Mysql"))
+ return false;
+
+ if(entry[2].getKey().matches("Host")) {
+ if(entry[3].empty())
+ host = entry[2][0];
+ }
+ else if(entry[2].getKey().matches("Username")) {
+ if(entry[3].empty())
+ username = entry[2][0];
+ }
+ else if(entry[2].getKey().matches("Password")) {
+ if(entry[3].empty())
+ passwd = entry[2][0];
+ }
+ else if(entry[2].getKey().matches("Database")) {
+ if(entry[3].empty())
+ db = entry[2][0];
+ }
+ else if(entry[2].getKey().matches("Port")) {
+ if(entry[3].empty()) {
+ char *endptr;
+ long val;
+
+ val = strtol(entry[2][0].c_str(), &endptr, 10);
+
+ if(endptr != 0 || val < 0 || val > 65535)
+ application->log(Core::LoggerBase::WARNING, "UserBackendMysql: Invalid port");
+ else
+ port = val;
}
- else if(entry[1].getKey().matches("Username")) {
- if(entry[2].empty())
- username = entry[1][0];
+ }
+ else if(entry[2].getKey().matches("UnixSocket")) {
+ if(entry[3].empty())
+ unixSocket = entry[2][0];
+ }
+ else if(entry[2].getKey().matches("Queries")) {
+ if(entry[3].getKey().matches("ListUsers")) {
+ if(entry[4].empty())
+ queryListUsers = entry[3][0];
}
- else if(entry[1].getKey().matches("Password")) {
- if(entry[2].empty())
- passwd = entry[1][0];
+ else if(entry[3].getKey().matches("ListGroups")) {
+ if(entry[4].empty())
+ queryListGroups = entry[3][0];
}
- else if(entry[1].getKey().matches("Database")) {
- if(entry[2].empty())
- db = entry[1][0];
+ else if(entry[3].getKey().matches("ListUserGroups")) {
+ if(entry[4].empty())
+ queryListUserGroups = entry[3][0];
}
- else if(entry[1].getKey().matches("Port")) {
- if(entry[2].empty()) {
- char *endptr;
- long val;
-
- val = strtol(entry[1][0].c_str(), &endptr, 10);
-
- if(endptr != 0 || val < 0 || val > 65535)
- application->log(Core::LoggerBase::WARNING, "UserBackendMysql: Invalid port");
- else
- port = val;
- }
+ else if(entry[3].getKey().matches("ListGroupUsers")) {
+ if(entry[4].empty())
+ queryListGroupUsers = entry[3][0];
}
- else if(entry[1].getKey().matches("UnixSocket")) {
- if(entry[2].empty())
- unixSocket = entry[1][0];
+ else if(entry[3].getKey().matches("UserById")) {
+ if(entry[4].empty())
+ queryUserById = entry[3][0];
}
- else if(entry[1].getKey().matches("Queries")) {
- if(entry[2].getKey().matches("ListUsers")) {
- if(entry[3].empty())
- queryListUsers = entry[2][0];
- }
- else if(entry[2].getKey().matches("ListGroups")) {
- if(entry[3].empty())
- queryListGroups = entry[2][0];
- }
- else if(entry[2].getKey().matches("ListUserGroups")) {
- if(entry[3].empty())
- queryListUserGroups = entry[2][0];
- }
- else if(entry[2].getKey().matches("ListGroupUsers")) {
- if(entry[3].empty())
- queryListGroupUsers = entry[2][0];
- }
- else if(entry[2].getKey().matches("UserById")) {
- if(entry[3].empty())
- queryUserById = entry[2][0];
- }
- else if(entry[2].getKey().matches("UserByName")) {
- if(entry[3].empty())
- queryUserByName = entry[2][0];
- }
- else if(entry[2].getKey().matches("GroupById")) {
- if(entry[3].empty())
- queryGroupById = entry[2][0];
- }
- else if(entry[2].getKey().matches("GroupByName")) {
- if(entry[3].empty())
- queryGroupByName = entry[2][0];
- }
- else if(entry[2].getKey().matches("UserGroupTable")) {
- if(entry[3].empty())
- queryUserGroupTable = entry[2][0];
- }
- else if(entry[2].getKey().matches("AddUser")) {
- if(entry[3].empty())
- queryAddUser = entry[2][0];
- }
- else if(entry[2].getKey().matches("UpdateUser")) {
- if(entry[3].empty())
- queryUpdateUser = entry[2][0];
- }
- else if(entry[2].getKey().matches("DeleteUser")) {
- if(entry[3].empty())
- queryDeleteUser = entry[2][0];
- }
- else if(entry[2].getKey().matches("AddUserToGroup")) {
- if(entry[3].empty())
- queryAddUserToGroup = entry[2][0];
- }
- else if(entry[2].getKey().matches("DeleteUserFromGroup")) {
- if(entry[3].empty())
- queryDeleteUserFromGroup = entry[2][0];
- }
- else if(!entry[2].empty())
- return false;
+ else if(entry[3].getKey().matches("UserByName")) {
+ if(entry[4].empty())
+ queryUserByName = entry[3][0];
+ }
+ else if(entry[3].getKey().matches("GroupById")) {
+ if(entry[4].empty())
+ queryGroupById = entry[3][0];
}
- else if(!entry[1].empty())
+ else if(entry[3].getKey().matches("GroupByName")) {
+ if(entry[4].empty())
+ queryGroupByName = entry[3][0];
+ }
+ else if(entry[3].getKey().matches("UserGroupTable")) {
+ if(entry[4].empty())
+ queryUserGroupTable = entry[3][0];
+ }
+ else if(entry[3].getKey().matches("AddUser")) {
+ if(entry[4].empty())
+ queryAddUser = entry[3][0];
+ }
+ else if(entry[3].getKey().matches("UpdateUser")) {
+ if(entry[4].empty())
+ queryUpdateUser = entry[3][0];
+ }
+ else if(entry[3].getKey().matches("DeleteUser")) {
+ if(entry[4].empty())
+ queryDeleteUser = entry[3][0];
+ }
+ else if(entry[3].getKey().matches("AddUserToGroup")) {
+ if(entry[4].empty())
+ queryAddUserToGroup = entry[3][0];
+ }
+ else if(entry[3].getKey().matches("DeleteUserFromGroup")) {
+ if(entry[4].empty())
+ queryDeleteUserFromGroup = entry[3][0];
+ }
+ else if(!entry[3].empty())
return false;
-
- return true;
}
+ else if(!entry[2].empty())
+ return false;
- return false;
+ return true;
}
void UserBackendMysql::configFinished() {