diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.c | 41 | ||||
| -rw-r--r-- | src/misc.c | 20 |
2 files changed, 40 insertions, 21 deletions
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; |
