summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2008-11-16 17:44:35 +0000
committercyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2008-11-16 17:44:35 +0000
commit72a4c7e6c7a4187bfee58bdbf3c235f2b0ae44c7 (patch)
tree16401c11ca7f35fd2a54517e5820500077864d67
parent0db67c7938e8f7c30ffc227d756bb5d51a53d861 (diff)
Added module blocks for autoloading non-core modules.
Modified buildStringList to take an std::string and use spacesepstream instead of strtok. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1745 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r--data/example_new.conf16
-rw-r--r--include/extern.h2
-rw-r--r--src/config.c41
-rw-r--r--src/misc.c20
4 files changed, 57 insertions, 22 deletions
diff --git a/data/example_new.conf b/data/example_new.conf
index 64273839c..ccac60782 100644
--- a/data/example_new.conf
+++ b/data/example_new.conf
@@ -1421,3 +1421,19 @@ defcon
*/
#akillreason = "This network is currently not accepting connections, please try again later"
}
+
+/*
+ * [OPTIONAL] Non-Core Modules
+ *
+ * The following single-line blocks are used to load all non-core modules, including 3rd-party modules.
+ * Modules can be prevented from loading by commenting out the line, other modules can be added by
+ * adding a module block. These modules will be loaded prior to Services connecting to your network.
+ */
+module { name = "hs_moo" }
+module { name = "ircd_defizzer" }
+module { name = "os_ignore" }
+module { name = "cs_appendtopic" }
+module { name = "cs_enforce" }
+module { name = "ns_maxemail" }
+module { name = "os_info" }
+module { name = "hs_request" }
diff --git a/include/extern.h b/include/extern.h
index 325625916..b1706b622 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -696,7 +696,7 @@ E char *str_signed(unsigned char *str);
E void ntoa(struct in_addr addr, char *ipaddr, int len);
-E char **buildStringList(char *src, int *number);
+E char **buildStringList(const std::string &src, int *number);
E void binary_to_hex(unsigned char *bin, char *hex, int length);
E uint32 cidr_to_netmask(uint16 cidr);
diff --git a/src/config.c b/src/config.c
index 6fcea128a..8a8473764 100644
--- a/src/config.c
+++ b/src/config.c
@@ -225,7 +225,7 @@ char *SessionLimitDetailsLoc;
bool OSOpersOnly;
-char *Modules;
+static std::string Modules;
char **ModulesAutoload;
int ModulesNumber;
@@ -566,6 +566,24 @@ void ServerConfig::ReportConfigError(const std::string &errormessage, bool bail)
}
}
+bool InitModules(ServerConfig *, const char *)
+{
+ Modules.clear();
+ return true;
+}
+
+bool DoModule(ServerConfig *, const char *, const char **, ValueList &values, int *)
+{
+ if (!Modules.empty()) Modules += " ";
+ Modules += values[0].GetString();
+ return true;
+}
+
+bool DoneModules(ServerConfig *, const char *)
+{
+ return true;
+}
+
int ServerConfig::Read(bool bail)
{
errstr.clear();
@@ -795,6 +813,11 @@ int ServerConfig::Read(bool bail)
/* These tags can occur multiple times, and therefore they have special code to read them
* which is different to the code for reading the singular tags listed above. */
MultiConfig MultiValues[] = {
+ {"module",
+ {"name", NULL},
+ {"", NULL},
+ {DT_CHARPTR},
+ InitModules, DoModule, DoneModules},
{NULL,
{NULL},
{NULL},
@@ -1852,28 +1875,28 @@ int read_config(int reload)
}
/* Host Setters building... :P */
- HostSetters = buildStringList(HostSetter, &HostNumber);
+ HostSetters = buildStringList(HostSetter ? HostSetter : "", &HostNumber);
/* Modules Autoload building... :P */
ModulesAutoload = buildStringList(Modules, &ModulesNumber);
HostServCoreModules =
- buildStringList(HostCoreModules, &HostServCoreNumber);
+ buildStringList(HostCoreModules ? HostCoreModules : "", &HostServCoreNumber);
MemoServCoreModules =
- buildStringList(MemoCoreModules, &MemoServCoreNumber);
+ buildStringList(MemoCoreModules ? MemoCoreModules : "", &MemoServCoreNumber);
HelpServCoreModules =
- buildStringList(HelpCoreModules, &HelpServCoreNumber);
+ buildStringList(HelpCoreModules ? HelpCoreModules : "", &HelpServCoreNumber);
BotServCoreModules =
- buildStringList(BotCoreModules, &BotServCoreNumber);
+ buildStringList(BotCoreModules ? BotCoreModules : "", &BotServCoreNumber);
OperServCoreModules =
- buildStringList(OperCoreModules, &OperServCoreNumber);
+ buildStringList(OperCoreModules ? OperCoreModules : "", &OperServCoreNumber);
ChanServCoreModules =
- buildStringList(ChanCoreModules, &ChanServCoreNumber);
+ buildStringList(ChanCoreModules ? ChanCoreModules : "", &ChanServCoreNumber);
NickServCoreModules =
- buildStringList(NickCoreModules, &NickServCoreNumber);
+ buildStringList(NickCoreModules ? NickCoreModules : "", &NickServCoreNumber);
if (LimitSessions) {
diff --git a/src/misc.c b/src/misc.c
index df0b628f6..77eee30cc 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -15,6 +15,7 @@
#include "services.h"
#include "language.h"
+#include "hashcomp.h" // If this gets added to services.h or someplace else later, remove it from here -- CyberBotX
/* Cheaper than isspace() or isblank() */
#define issp(c) ((c) == 32)
@@ -1165,23 +1166,18 @@ void ntoa(struct in_addr addr, char *ipaddr, int len)
* Build a string list from a given source string.
* This is usually used for parsing out values from the config file, but could
* be used for other things.
- * NOTE: this function uses strtok(), be aware it will break any buffer you think you have in there ;)
**/
-char **buildStringList(char *src, int *number)
+char **buildStringList(const std::string &src, int *number)
{
- char *s;
int i = 0;
char **list = NULL;
+ spacesepstream tokens(src);
+ std::string token;
- if (src) {
- s = strtok(src, " ");
- do {
- if (s) {
- i++;
- list = (char **)realloc(list, sizeof(char *) * i);
- list[i - 1] = sstrdup(s);
- }
- } while ((s = strtok(NULL, " ")));
+ while (tokens.GetToken(token)) {
+ i++;
+ list = (char **)realloc(list, sizeof(char *) * i);
+ list[i - 1] = sstrdup(token.c_str());
}
*number = i; /* always zero it, even if we have no setters */
return list;