summaryrefslogtreecommitdiff
path: root/src/modules/os_ignore_db.c
diff options
context:
space:
mode:
authorcyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2008-11-19 00:48:29 +0000
committercyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2008-11-19 00:48:29 +0000
commit0f069f0e8becfd1770a6ce396ead7aa67e3bde06 (patch)
treeede474534d89b32bcdcc24d58e5cca6c427d6176 /src/modules/os_ignore_db.c
parent1a2fdff0c653562ebde967850875e5445bc0c5ae (diff)
Converted modules to use ConfigReader to access new config parser.
Added all module directives to new config. Removed references to old config parser (not sure if I got them all, though). git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1756 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/modules/os_ignore_db.c')
-rw-r--r--src/modules/os_ignore_db.c61
1 files changed, 26 insertions, 35 deletions
diff --git a/src/modules/os_ignore_db.c b/src/modules/os_ignore_db.c
index 064dfa380..2984b3b20 100644
--- a/src/modules/os_ignore_db.c
+++ b/src/modules/os_ignore_db.c
@@ -76,11 +76,11 @@ int reload_config(int argc, char **argv);
/* ------------------------------------------------------------------------------- */
-class OSIgnoreDB : public Module
-{
- public:
- OSIgnoreDB(const std::string &modname, const std::string &creator) : Module(modname, creator)
- {
+class OSIgnoreDB : public Module
+{
+ public:
+ OSIgnoreDB(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ {
EvtHook *hook;
IgnoreDB = NULL;
@@ -89,53 +89,44 @@ class OSIgnoreDB : public Module
this->SetType(SUPPORTED);
hook = createEventHook(EVENT_RELOAD, reload_config);
- if (this->AddEventHook(hook) != MOD_ERR_OK)
+ if (this->AddEventHook(hook) != MOD_ERR_OK)
throw ModuleException("os_ignore_db: Can't hook to EVENT_RELOAD event");
-
+
hook = createEventHook(EVENT_DB_SAVING, save_ignoredb);
- if (this->AddEventHook(hook) != MOD_ERR_OK)
+ if (this->AddEventHook(hook) != MOD_ERR_OK)
throw ModuleException("os_ignore_db: Can't hook to EVENT_DB_SAVING event");
hook = createEventHook(EVENT_DB_BACKUP, backup_ignoredb);
- if (this->AddEventHook(hook) != MOD_ERR_OK)
+ if (this->AddEventHook(hook) != MOD_ERR_OK)
throw ModuleException("os_ignore_db: Can't hook to EVENT_DB_BACKUP event");
load_config();
/* Load the ignore database and re-add them to anopes ignorelist. */
load_ignore_db();
- }
-
- ~OSIgnoreDB()
- {
+ }
+
+ ~OSIgnoreDB()
+ {
/* Save the ignore database before bailing out.. */
save_ignore_db();
if (IgnoreDB)
- free(IgnoreDB);
- }
+ free(IgnoreDB);
+ }
};
-
-
+
+
/* ------------------------------------------------------------------------------- */
void load_config(void) {
- int i;
-
- Directive confvalues[][1] = {
- {{"OSIgnoreDBName", {{PARAM_STRING, PARAM_RELOAD, &IgnoreDB}}}},
- };
+ ConfigReader config;
+ std::string tmp = config.ReadValue("os_ignore", "database", DefIgnoreDB, 0);
if (IgnoreDB)
free(IgnoreDB);
- IgnoreDB = NULL;
-
- for (i = 0; i < 1; i++)
- moduleGetConfigDirective(confvalues[i]);
-
- if (!IgnoreDB)
- IgnoreDB = sstrdup(DefIgnoreDB);
+ IgnoreDB = sstrdup(tmp.c_str());
if (debug)
alog("[os_ignore_db] debug: Set config vars: OSIgnoreDBName='%s'", IgnoreDB);
@@ -215,14 +206,14 @@ void load_ignore_db(void) {
free(dbptr);
return;
} else if (retval == DB_READ_BLOCKEND) { /* DB_READ_BLOCKEND */
- /* Check if we have everything to add the ignore..
+ /* Check if we have everything to add the ignore..
* We shouldn't bother with already expired ignores either.. */
if (mask && (expiry_time > time(NULL) || expiry_time == 0)) {
/* We should check for double entries.. */
for (ign = ignore; ign; ign = ign->next)
if (!stricmp(ign->mask, mask))
break;
-
+
if (!ign) {
/* Create a fresh entry.. */
ign = (IgnoreData *)scalloc(sizeof(*ign), 1);
@@ -236,7 +227,7 @@ void load_ignore_db(void) {
if (debug)
alog("[os_ignore_db] debug: Added new ignore entry for %s", mask);
} else {
- /* Update time on existing entry.
+ /* Update time on existing entry.
* The longest expiry time survives.. */
if (expiry_time == 0 || ign->time == 0)
ign->time = 0;
@@ -244,7 +235,7 @@ void load_ignore_db(void) {
ign->time = expiry_time;
}
}
-
+
if (mask) free(mask);
mask = NULL;
expiry_time = time(NULL);
@@ -532,6 +523,6 @@ void fill_db_ptr(DBFile *dbptr, int version, int core_version,
strcpy(dbptr->filename, filename);
snprintf(dbptr->temp_name, 261, "%s.temp", filename);
return;
-}
+}
-MODULE_INIT("os_ignore_db", OSIgnoreDB)
+MODULE_INIT("os_ignore_db", OSIgnoreDB)