mirror of
https://github.com/anope/anope.git
synced 2026-06-30 18:46:38 +02:00
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
This commit is contained in:
@@ -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" }
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+32
-9
@@ -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) {
|
||||
|
||||
+8
-12
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user