summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/hs_request.c34
-rw-r--r--src/modules/ns_maxemail.c17
-rw-r--r--src/modules/ns_noop_convert.c22
-rw-r--r--src/modules/os_ignore_db.c61
-rw-r--r--src/modules/os_info.c25
5 files changed, 56 insertions, 103 deletions
diff --git a/src/modules/hs_request.c b/src/modules/hs_request.c
index e9ad605a8..5eb7cc7f3 100644
--- a/src/modules/hs_request.c
+++ b/src/modules/hs_request.c
@@ -110,7 +110,7 @@ class HSRequest : public Module
c = createCommand("list", hs_do_list_out, is_services_oper, -1, -1, -1, -1, -1);
this->AddCommand(HOSTSERV, c, MOD_HEAD);
- c = createCommand("drop", ns_do_drop, NULL, -1, -1, -1, -1, -1);
+ c = createCommand("drop", ns_do_drop, NULL, -1, -1, -1, -1, -1);
this->AddCommand(NICKSERV, c, MOD_HEAD);
hook = createEventHook(EVENT_DB_SAVING, hsreqevt_db_saving);
@@ -945,29 +945,15 @@ int hsreqevt_db_backup(int argc, char **argv)
void my_load_config(void)
{
- int i;
- char *tmp = NULL;
-
- Directive confvalues[][1] = {
- {{"HSRequestMemoUser",
- {{PARAM_SET, PARAM_RELOAD, &HSRequestMemoUser}}}},
- {{"HSRequestMemoOper",
- {{PARAM_SET, PARAM_RELOAD, &HSRequestMemoOper}}}},
- {{"HSRequestMemoSetters",
- {{PARAM_SET, PARAM_RELOAD, &HSRequestMemoSetters}}}},
- {{"HSRequestDBName", {{PARAM_STRING, PARAM_RELOAD, &tmp}}}}
- };
-
- for (i = 0; i < 4; i++)
- moduleGetConfigDirective(confvalues[i]);
-
- if (tmp) {
- if (HSRequestDBName)
- free(HSRequestDBName);
- HSRequestDBName = sstrdup(tmp);
- } else {
- HSRequestDBName = sstrdup(HSREQ_DEFAULT_DBNAME);
- }
+ ConfigReader config;
+ HSRequestMemoUser = config.ReadFlag("hs_request", "memouser", "no", 0);
+ HSRequestMemoOper = config.ReadFlag("hs_request", "memooper", "no", 0);
+ HSRequestMemoSetters = config.ReadFlag("hs_request", "memosetters", "no", 0);
+ std::string tmp = config.ReadValue("hs_request", "database", HSREQ_DEFAULT_DBNAME, 0);
+
+ if (HSRequestDBName)
+ free(HSRequestDBName);
+ HSRequestDBName = sstrdup(tmp.c_str());
if (debug)
alog("debug: [hs_request] Set config vars: MemoUser=%d MemoOper=%d MemoSetters=%d DBName='%s'", HSRequestMemoUser, HSRequestMemoOper, HSRequestMemoSetters, HSRequestDBName);
diff --git a/src/modules/ns_maxemail.c b/src/modules/ns_maxemail.c
index b2f82eb41..29773dfe5 100644
--- a/src/modules/ns_maxemail.c
+++ b/src/modules/ns_maxemail.c
@@ -1,12 +1,12 @@
/* ns_maxemail.c - Limit the amount of times an email address
* can be used for a NickServ account.
- *
+ *
* (C) 2003-2008 Anope Team
* Contact us at info@anope.org
- *
+ *
* Included in the Anope module pack since Anope 1.7.9
* Anope Coder: GeniusDex <geniusdex@anope.org>
- *
+ *
* Please read COPYING and README for further details.
*
* Send any bug reports to the Anope Coder, as he will be able
@@ -168,10 +168,10 @@ int my_ns_set(User * u)
cur_buffer = moduleGetLastBuffer();
set = myStrGetToken(cur_buffer, ' ', 0);
-
+
if (!set)
return MOD_CONT;
-
+
if (stricmp(set, "email") != 0) {
free(set);
return MOD_CONT;
@@ -198,11 +198,8 @@ int my_event_reload(int argc, char **argv)
void my_load_config(void)
{
- Directive confvalues[] = {
- {"NSEmailMax", {{PARAM_INT, PARAM_RELOAD, &NSEmailMax}}}
- };
-
- moduleGetConfigDirective(confvalues);
+ ConfigReader config;
+ NSEmailMax = config.ReadInteger("ns_maxemail", "maxemails", "0", 0, false);
if (debug)
alog("debug: [ns_maxemail] NSEmailMax set to %d", NSEmailMax);
diff --git a/src/modules/ns_noop_convert.c b/src/modules/ns_noop_convert.c
index 6a2a29b09..bc9a59d02 100644
--- a/src/modules/ns_noop_convert.c
+++ b/src/modules/ns_noop_convert.c
@@ -88,7 +88,7 @@ class NSNOOPConvert : public Module
/*************************************************************************/
-/**
+/**
* Load data from the db file, and populate the autoop setting
* @return 0 for success
**/
@@ -126,31 +126,21 @@ int mLoadData(void)
/*************************************************************************/
-/**
+/**
* Load the configuration directives from Services configuration file.
* @return 0 for success
**/
int mLoadConfig(int argc, char **argv)
{
- char *tmp = NULL;
-
- Directive d[] = {
- {"NSAutoOPDBName", {{PARAM_STRING, PARAM_RELOAD, &tmp}}},
- };
-
- moduleGetConfigDirective(d);
+ ConfigReader config;
+ std::string tmp = config.ReadValue("ns_noop_convert", "database", DEFAULT_DB_NAME, 0);
if (NSAutoOPDBName)
free(NSAutoOPDBName);
- if (tmp) {
- NSAutoOPDBName = tmp;
- } else {
- NSAutoOPDBName = sstrdup(DEFAULT_DB_NAME);
- alog("ns_noop: NSAutoOPDBName is not defined in Services configuration file, using default %s", NSAutoOPDBName);
- }
+ NSAutoOPDBName = sstrdup(tmp.c_str());
- if (!NSAutoOPDBName) {
+ if (tmp.empty()) {
alog("ns_noop: FATAL: Can't read required configuration directives!");
return MOD_STOP;
} else {
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)
diff --git a/src/modules/os_info.c b/src/modules/os_info.c
index 4adc4e0a2..731573f37 100644
--- a/src/modules/os_info.c
+++ b/src/modules/os_info.c
@@ -323,7 +323,7 @@ class OSInfo : public Module
~OSInfo()
{
char *av[1];
-
+
for (int i = 0; i < 1024; i++)
{
/* Remove the nick Cores */
@@ -336,7 +336,7 @@ class OSInfo : public Module
nc->Shrink("os_modinfo");
}
}
- }
+ }
av[0] = sstrdup(EVENT_START);
mSaveData(1, av);
free(av[0]);
@@ -401,7 +401,7 @@ int myAddNickInfo(User * u)
free(c);
na->nc->Shrink("os_info");
}
-
+
moduleNoticeLang(s_NickServ, u, OINFO_DEL_SUCCESS, nick);
/* NickCore not found! */
} else {
@@ -666,7 +666,7 @@ int mSaveData(int argc, char **argv)
/* If we have any info on this channel */
char *c;
if (ci->GetExt("os_info", c))
- {
+ {
fprintf(out, "C %s %s\n", ci->name, c);
}
}
@@ -698,24 +698,13 @@ int mBackupData(int argc, char **argv)
**/
int mLoadConfig(void)
{
- char *tmp = NULL;
-
- Directive directivas[] = {
- {"OSInfoDBName", {{PARAM_STRING, PARAM_RELOAD, &tmp}}},
- };
-
- Directive *d = &directivas[0];
- moduleGetConfigDirective(d);
+ ConfigReader config;
+ std::string tmp = config.ReadValue("os_info", "database", DEFAULT_DB_NAME, 0);
if (OSInfoDBName)
free(OSInfoDBName);
- if (tmp) {
- OSInfoDBName = tmp;
- } else {
- OSInfoDBName = sstrdup(DEFAULT_DB_NAME);
- alog("os_info: OSInfoDBName is not defined in Services configuration file, using default %s", OSInfoDBName);
- }
+ OSInfoDBName = sstrdup(tmp.c_str());
alog("os_info: Directive OSInfoDBName loaded (%s)...", OSInfoDBName);