summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile32
-rw-r--r--src/compat.c24
-rw-r--r--src/config.c257
-rw-r--r--src/datafiles.c34
-rw-r--r--src/hashcomp.cpp56
-rw-r--r--src/protocol/bahamut.c1
-rw-r--r--src/protocol/charybdis.c1
-rw-r--r--src/protocol/inspircd11.c1
-rw-r--r--src/protocol/ratbox.c1
-rw-r--r--src/protocol/unreal32.c1
10 files changed, 183 insertions, 225 deletions
diff --git a/src/Makefile b/src/Makefile
index ea4b572c2..3d7122c5f 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,21 +1,21 @@
MYSQL_OBJ = $(MYSQL:.c=.o)
RDB_OBJ = $(RDB:.c=.o)
OBJS = actions.o base64.o bots.o botserv.o channels.o chanserv.o commands.o compat.o \
- config.o datafiles.o encrypt.o events.o helpserv.o hostserv.o init.o ircd.o language.o log.o mail.o main.o \
+ config.o datafiles.o encrypt.o events.o hashcomp.o helpserv.o hostserv.o init.o ircd.o language.o log.o mail.o main.o \
memory.o memoserv.o messages.o misc.o modules.o news.o nickserv.o operserv.o \
process.o send.o servers.o sessions.o slist.o sockutil.o timeout.o users.o \
- $(RDB_OBJ) $(MYSQL_OBJ)
+ $(RDB_OBJ) $(MYSQL_OBJ)
SRCS = actions.c base64.c bots.cpp botserv.c channels.c chanserv.c commands.c compat.c \
- config.c datafiles.c encrypt.c events.c helpserv.c hostserv.c init.c ircd.c language.c log.c mail.c main.c \
+ config.c datafiles.c encrypt.c events.c hashcomp.c helpserv.c hostserv.c init.c ircd.c language.c log.c mail.c main.c \
memory.c memoserv.c messages.c misc.c modules.c news.c nickserv.c operserv.c \
process.c send.c servers.c sessions.c s sockutil.c timeout.c users.c \
- $(RDB) $(MYSQL)
+ $(RDB) $(MYSQL)
INCLUDES = ../include/commands.h ../include/defs.h ../include/language.h \
../include/pseudo.h ../include/sysconf.h ../include/config.h \
../include/encrypt.h ../include/messages.h ../include/services.h \
../include/timeout.h ../include/datafiles.h ../include/extern.h \
- ../include/modules.h ../include/slist.h
+ ../include/modules.h ../include/slist.h ../include/hashcomp.h
MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \
'LDFLAGS=${LDFLAGS}' 'BINDEST=${BINDEST}' 'INSTALL=${INSTALL}' \
@@ -36,26 +36,26 @@ distclean: spotless
distclean_modules: clean_modules spotless
services: $(OBJS) mod_version
- @../run-cc.pl $(CC) $(CFLAGS) $(OBJS) $(ANOPELIBS) $(MLIBS) -o $@ $(LDFLAGS)
+ @../run-cc.pl $(CC) $(CFLAGS) $(OBJS) $(ANOPELIBS) $(MLIBS) -o $@ $(LDFLAGS)
$(OBJS): Makefile
actions.o: actions.c $(INCLUDES)
-base64.o: base64.c $(INCLUDES)
+base64.o: base64.c $(INCLUDES)
bots.o: bots.cpp $(INCLUDES)
-botserv.o: botserv.c $(INCLUDES)
-channels.o: channels.c $(INCLUDES)
-chanserv.o: chanserv.c $(INCLUDES)
-commands.o: commands.c $(INCLUDES)
+botserv.o: botserv.c $(INCLUDES)
+channels.o: channels.c $(INCLUDES)
+chanserv.o: chanserv.c $(INCLUDES)
+commands.o: commands.c $(INCLUDES)
compat.o: compat.c $(INCLUDES)
-config.o: config.c $(INCLUDES)
+config.o: config.c $(INCLUDES)
datafiles.o: datafiles.c $(INCLUDES)
-encrypt.o: encrypt.c $(INCLUDES)
+encrypt.o: encrypt.c $(INCLUDES)
events.o: events.c $(INCLUDES)
init.o: init.c $(INCLUDES)
ircd.o: ircd.c $(INCLUDES)
-helpserv.o: helpserv.c $(INCLUDES)
-hostserv.o: hostserv.c $(INCLUDES)
-language.o: language.c $(INCLUDES)
+helpserv.o: helpserv.c $(INCLUDES)
+hostserv.o: hostserv.c $(INCLUDES)
+language.o: language.c $(INCLUDES)
log.o: log.c $(INCLUDES)
mail.o: mail.c $(INCLUDES)
main.o: main.c $(INCLUDES)
diff --git a/src/compat.c b/src/compat.c
index 7b7947c1c..0279efec8 100644
--- a/src/compat.c
+++ b/src/compat.c
@@ -57,27 +57,3 @@ int strnicmp(const char *s1, const char *s2, size_t len)
/*************************************************************************/
-#if !HAVE_STRDUP
-char *strdup(const char *s)
-{
- char *new = calloc(strlen(s) + 1, 1);
- if (new)
- strcpy(new, s);
- return new;
-}
-#endif
-
-/*************************************************************************/
-
-#if !HAVE_STRSPN
-size_t strspn(const char *s, const char *accept)
-{
- size_t i = 0;
-
- while (*s && strchr(accept, *s))
- ++i, ++s;
- return i;
-}
-#endif
-
-/*************************************************************************/
diff --git a/src/config.c b/src/config.c
index 639cfae12..41f5cedd7 100644
--- a/src/config.c
+++ b/src/config.c
@@ -14,6 +14,7 @@
#include "services.h"
#include "configreader.h"
+#include "hashcomp.h" // If this gets added to services.h or someplace else later, remove it from here -- CyberBotX
/*************************************************************************/
@@ -114,43 +115,32 @@ int RestrictMail;
int MailDelay;
int DontQuoteAddresses;
-static int NSDefNone;
+static std::string NSDefaults;
char *NSGuestNickPrefix;
-int NSAllowKillImmed;
-int NSNoGroupChange;
-int NSDefKill;
-int NSDefKillQuick;
-int NSDefSecure;
-int NSDefPrivate;
-int NSDefMsg;
-int NSDefHideEmail;
-int NSDefHideUsermask;
-int NSDefHideQuit;
-int NSDefMemoSignon;
-int NSDefMemoReceive;
+bool NSAllowKillImmed;
+bool NSNoGroupChange;
int NSDefFlags;
int NSDefLanguage;
-int NSDefAutoop;
-int NSRegDelay;
-int NSResendDelay;
-int NSExpire;
-int NSRExpire;
-int NSForceEmail;
+time_t NSRegDelay;
+time_t NSResendDelay;
+time_t NSExpire;
+time_t NSRExpire;
+bool NSForceEmail;
int NSMaxAliases;
int NSAccessMax;
char *NSEnforcerUser;
char *NSEnforcerHost;
static char *temp_nsuserhost;
-int NSReleaseTimeout;
-int NSListOpersOnly;
+time_t NSReleaseTimeout;
+bool NSListOpersOnly;
int NSListMax;
-int NSSecureAdmins;
-int NSStrictPrivileges;
-int NSEmailReg;
-int NSModeOnID;
-int NSRestrictGetPass;
-int NSNickTracking;
-int NSAddAccessOnReg;
+bool NSSecureAdmins;
+bool NSStrictPrivileges;
+bool NSEmailReg;
+bool NSModeOnID;
+bool NSRestrictGetPass;
+bool NSNickTracking;
+bool NSAddAccessOnReg;
int CSDefNone;
int CSDefKeepTopic;
@@ -452,6 +442,26 @@ bool ValidateNotEmpty(ServerConfig *, const char *tag, const char *value, ValueI
return true;
}
+bool ValidateNotZero(ServerConfig *, const char *tag, const char *value, ValueItem &data)
+{
+ if (!data.GetInteger()) throw ConfigException(static_cast<std::string>("The value for <") + tag + ":" + value + "> must be non-zero!");
+ return true;
+}
+
+bool ValidateEmailReg(ServerConfig *, const char *tag, const char *value, ValueItem &data)
+{
+ if (static_cast<std::string>(value) == "prenickdatabase") {
+ if (!*data.GetString()) throw ConfigException(static_cast<std::string>("The value for <") + tag + ":" + value + "> cannot be empty when e-mail registrations are enabled!");
+ }
+ else if (static_cast<std::string>(value) == "preregexpire") {
+ if (!data.GetInteger()) throw ConfigException(static_cast<std::string>("The value for <") + tag + ":" + value + "> must be non-zero when e-mail registration are enabled!");
+ }
+ else {
+ if (!data.GetBool()) throw ConfigException(static_cast<std::string>("The value for <") + tag + ":" + value + "> must be set to yes when e-mail registrations are enabled!");
+ }
+ return true;
+}
+
bool ValidatePort(ServerConfig *, const char *tag, const char *value, ValueItem &data)
{
int port = data.GetInteger();
@@ -461,6 +471,23 @@ bool ValidatePort(ServerConfig *, const char *tag, const char *value, ValueItem
return true;
}
+bool ValidateLanguage(ServerConfig *, const char *, const char *, ValueItem &data)
+{
+ int language = data.GetInteger();
+ char maxlang[3];
+ snprintf(maxlang, 3, "%d", USED_LANGS);
+ if (language < 1 || language > USED_LANGS) throw ConfigException(static_cast<std::string>("The value for <nickserv:defaultlanguage> must be between 1 and ") + maxlang + "!");
+ data.Set(--language);
+ return true;
+}
+
+bool ValidateGuestPrefix(ServerConfig *conf, const char *tag, const char *value, ValueItem &data)
+{
+ ValidateNotEmpty(conf, tag, value, data);
+ if (strlen(data.GetString()) > 21) throw ConfigException("The value for <nickserv:guestnickprefix> cannot exceed 21 characters in length!");
+ return true;
+}
+
void ServerConfig::ReportConfigError(const std::string &errormessage, bool bail)
{
alog("There were errors in your configuration file: %s", errormessage.c_str());
@@ -532,6 +559,31 @@ int ServerConfig::Read(bool bail)
{"uplink", "password", "", new ValueContainerChar(&RemotePassword), DT_NOSPACES | DT_NORELOAD, ValidateNotEmpty},
{"nickserv", "nick", "NickServ", new ValueContainerChar(&s_NickServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty},
{"nickserv", "descrption", "Nickname Registration Service", new ValueContainerChar(&desc_NickServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty},
+ {"nickserv", "database", "nick.db", new ValueContainerChar(&NickDBName), DT_CHARPTR, ValidateNotEmpty},
+ {"nickserv", "emailregistration", "no", new ValueContainerBool(&NSEmailReg), DT_BOOLEAN, NoValidation},
+ {"nickserv", "prenickdatabase", "", new ValueContainerChar(&PreNickDBName), DT_CHARPTR, ValidateEmailReg},
+ {"nickserv", "forceemail", "no", new ValueContainerBool(&NSForceEmail), DT_BOOLEAN, ValidateEmailReg},
+ {"nickserv", "defaults", "secure memosignon memoreceive", new ValueContainerString(&NSDefaults), DT_BOOLEAN, NoValidation},
+ {"nickserv", "defaultlanguage", "0", new ValueContainerInt(&NSDefLanguage), DT_INTEGER, ValidateLanguage},
+ {"nickserv", "regdelay", "0", new ValueContainerTime(&NSRegDelay), DT_TIME, NoValidation},
+ {"nickserv", "resenddelay", "0", new ValueContainerTime(&NSResendDelay), DT_TIME, NoValidation},
+ {"nickserv", "expire", "21d", new ValueContainerTime(&NSExpire), DT_TIME, ValidateNotZero},
+ {"nickserv", "preregexpire", "0", new ValueContainerTime(&NSRExpire), DT_TIME, ValidateEmailReg},
+ {"nickserv", "maxaliases", "0", new ValueContainerInt(&NSMaxAliases), DT_INTEGER, NoValidation},
+ {"nickserv", "accessmax", "0", new ValueContainerInt(&NSAccessMax), DT_INTEGER, ValidateNotZero},
+ {"nickserv", "enforceruser", "", new ValueContainerChar(&temp_nsuserhost), DT_CHARPTR, ValidateNotEmpty},
+ {"nickserv", "releasetimeout", "0", new ValueContainerTime(&NSReleaseTimeout), DT_TIME, ValidateNotZero},
+ {"nickserv", "allowkillimmed", "no", new ValueContainerBool(&NSAllowKillImmed), DT_BOOLEAN | DT_NORELOAD, NoValidation},
+ {"nickserv", "nogroupchange", "no", new ValueContainerBool(&NSNoGroupChange), DT_BOOLEAN, NoValidation},
+ {"nickserv", "listopersonly", "no", new ValueContainerBool(&NSListOpersOnly), DT_BOOLEAN, NoValidation},
+ {"nickserv", "listmax", "0", new ValueContainerInt(&NSListMax), DT_INTEGER, ValidateNotZero},
+ {"nickserv", "guestnickprefix", "", new ValueContainerChar(&NSGuestNickPrefix), DT_CHARPTR, ValidateGuestPrefix},
+ {"nickserv", "secureadmins", "no", new ValueContainerBool(&NSSecureAdmins), DT_BOOLEAN, NoValidation},
+ {"nickserv", "strictprivileges", "no", new ValueContainerBool(&NSStrictPrivileges), DT_BOOLEAN, NoValidation},
+ {"nickserv", "modeonid", "no", new ValueContainerBool(&NSModeOnID), DT_BOOLEAN, NoValidation},
+ {"nickserv", "restrictgetpass", "no", new ValueContainerBool(&NSRestrictGetPass), DT_BOOLEAN, NoValidation},
+ {"nickserv", "nicktracking", "no", new ValueContainerBool(&NSNickTracking), DT_BOOLEAN, NoValidation},
+ {"nickserv", "addaccessonreg", "no", new ValueContainerBool(&NSAddAccessOnReg), DT_BOOLEAN, NoValidation},
{NULL, NULL, NULL, NULL, DT_NOTHING, NoValidation}
};
/* These tags can occur multiple times, and therefore they have special code to read them
@@ -1202,7 +1254,7 @@ Directive directives[] = {
{"KillonSGline", {{PARAM_SET, PARAM_RELOAD, &KillonSGline}}},
{"KillonSQline", {{PARAM_SET, PARAM_RELOAD, &KillonSQline}}},
{"AddAkiller", {{PARAM_SET, PARAM_RELOAD, &AddAkiller}}},
- {"LimitSessions", {{PARAM_SET, PARAM_FULLONLY, &LimitSessions}}},
+ {"LimitSessions", {{PARAM_SET, 0, &LimitSessions}}},
{"LocalAddress", {{PARAM_STRING, 0, &LocalHost},
{PARAM_PORT, PARAM_OPTIONAL, &LocalPort}}},
{"LogUsers", {{PARAM_SET, PARAM_RELOAD, &LogUsers}}},
@@ -1236,48 +1288,10 @@ Directive directives[] = {
{"NewsCount", {{PARAM_POSINT, PARAM_RELOAD, &NewsCount}}},
{"NewsDB", {{PARAM_STRING, PARAM_RELOAD, &NewsDBName}}},
{"NickLen", {{PARAM_POSINT, 0, &NickLen}}},
- {"NickservDB", {{PARAM_STRING, PARAM_RELOAD, &NickDBName}}},
{"Numeric", {{PARAM_STRING, PARAM_RELOAD, &Numeric}}},
- {"PreNickServDB", {{PARAM_STRING, PARAM_RELOAD, &PreNickDBName}}},
- {"NSEmailReg", {{PARAM_SET, PARAM_RELOAD, &NSEmailReg}}},
{"NickCoreModules", {{PARAM_STRING, PARAM_RELOAD, &NickCoreModules}}},
{"NickRegDelay", {{PARAM_POSINT, PARAM_RELOAD, &NickRegDelay}}},
{"NoBackupOkay", {{PARAM_SET, PARAM_RELOAD, &NoBackupOkay}}},
- {"NSAccessMax", {{PARAM_POSINT, PARAM_RELOAD, &NSAccessMax}}},
- {"NSAllowKillImmed", {{PARAM_SET, 0, &NSAllowKillImmed}}},
- {"NSDefHideEmail", {{PARAM_SET, PARAM_RELOAD, &NSDefHideEmail}}},
- {"NSDefHideQuit", {{PARAM_SET, PARAM_RELOAD, &NSDefHideQuit}}},
- {"NSDefHideUsermask", {{PARAM_SET, PARAM_RELOAD, &NSDefHideUsermask}}},
- {"NSDefKill", {{PARAM_SET, PARAM_RELOAD, &NSDefKill}}},
- {"NSDefKillQuick", {{PARAM_SET, PARAM_RELOAD, &NSDefKillQuick}}},
- {"NSDefLanguage", {{PARAM_POSINT, PARAM_RELOAD, &NSDefLanguage}}},
- {"NSDefMemoReceive", {{PARAM_SET, PARAM_RELOAD, &NSDefMemoReceive}}},
- {"NSDefMemoSignon", {{PARAM_SET, PARAM_RELOAD, &NSDefMemoSignon}}},
- {"NSDefMsg", {{PARAM_SET, PARAM_RELOAD, &NSDefMsg}}},
- {"NSDefNone", {{PARAM_SET, PARAM_RELOAD, &NSDefNone}}},
- {"NSDefPrivate", {{PARAM_SET, PARAM_RELOAD, &NSDefPrivate}}},
- {"NSDefSecure", {{PARAM_SET, PARAM_RELOAD, &NSDefSecure}}},
- {"NSDefAutoop", {{PARAM_SET, PARAM_RELOAD, &NSDefAutoop}}},
- {"NSEnforcerUser", {{PARAM_STRING, PARAM_RELOAD, &temp_nsuserhost}}},
- {"NSExpire", {{PARAM_TIME, PARAM_RELOAD, &NSExpire}}},
- {"NSRExpire", {{PARAM_TIME, PARAM_RELOAD, &NSRExpire}}},
- {"NSModeOnID", {{PARAM_SET, PARAM_RELOAD, &NSModeOnID}}},
- {"NSForceEmail", {{PARAM_SET, PARAM_RELOAD, &NSForceEmail}}},
- {"NSGuestNickPrefix",
- {{PARAM_STRING, PARAM_RELOAD, &NSGuestNickPrefix}}},
- {"NSListMax", {{PARAM_POSINT, PARAM_RELOAD, &NSListMax}}},
- {"NSListOpersOnly", {{PARAM_SET, PARAM_RELOAD, &NSListOpersOnly}}},
- {"NSMaxAliases", {{PARAM_INT, PARAM_RELOAD, &NSMaxAliases}}},
- {"NSNoGroupChange", {{PARAM_SET, PARAM_RELOAD, &NSNoGroupChange}}},
- {"NSRegDelay", {{PARAM_TIME, PARAM_RELOAD, &NSRegDelay}}},
- {"NSResendDelay", {{PARAM_TIME, PARAM_RELOAD, &NSResendDelay}}},
- {"NSReleaseTimeout", {{PARAM_TIME, PARAM_RELOAD, &NSReleaseTimeout}}},
- {"NSSecureAdmins", {{PARAM_SET, PARAM_RELOAD, &NSSecureAdmins}}},
- {"NSStrictPrivileges",
- {{PARAM_SET, PARAM_RELOAD, &NSStrictPrivileges}}},
- {"NSRestrictGetPass", {{PARAM_SET, PARAM_RELOAD, &NSRestrictGetPass}}},
- {"NSNickTracking", {{PARAM_SET, PARAM_RELOAD, &NSNickTracking}}},
- {"NSAddAccessOnReg", {{PARAM_SET, PARAM_RELOAD, &NSAddAccessOnReg}}},
{"OperCoreModules", {{PARAM_STRING, PARAM_RELOAD, &OperCoreModules}}},
{"OperServDB", {{PARAM_STRING, PARAM_RELOAD, &OperDBName}}},
{"OperServName", {{PARAM_STRING, 0, &s_OperServ},
@@ -1372,20 +1386,17 @@ void error(int linenum, const char *message, ...)
vsnprintf(buf, sizeof(buf), message, args);
va_end(args);
-#ifndef NOT_MAIN
if (linenum)
alog("%s:%d: %s", SERVICES_CONF, linenum, buf);
else
alog("%s: %s", SERVICES_CONF, buf);
- if (!nofork && isatty(2)) {
-#endif
+
+ if (!nofork && isatty(2)) {
if (linenum)
fprintf(stderr, "%s:%d: %s\n", SERVICES_CONF, linenum, buf);
else
fprintf(stderr, "%s: %s\n", SERVICES_CONF, buf);
-#ifndef NOT_MAIN
}
-#endif
}
/*************************************************************************/
@@ -1414,14 +1425,6 @@ int parse_directive(Directive * d, char *dir, int ac, char *av[MAXPARAMS],
*(int *) d->params[i].ptr = 1;
continue;
}
-#ifdef STREAMLINED
- if (d->params[i].flags & PARAM_FULLONLY) {
- error(linenum,
- "Directive `%s' not available in STREAMLINED mode",
- d->name);
- break;
- }
-#endif
/* Should we remove PARAM_DEPRECATED because it's
* useless right now? -GD */
@@ -1638,10 +1641,8 @@ int read_config(int reload)
if (!retval) return 0; // Temporary until most of the below is modified to use the new parser -- CyberBotX
config = fopen(SERVICES_CONF, "r");
if (!config) {
-#ifndef NOT_MAIN
log_perror("Can't open " SERVICES_CONF);
if (!nofork && isatty(2)) {
-#endif
if (!reload)
perror("Can't open " SERVICES_CONF);
else
@@ -1703,7 +1704,6 @@ int read_config(int reload)
CHEK2(MOTDFilename, MOTDFile);
if (!reload) {
- CHEK2(NickDBName, NickServDB);
CHEK2(ChanDBName, ChanServDB);
CHEK2(OperDBName, OperServDB);
CHEK2(NewsDBName, NewsDB);
@@ -1714,10 +1714,6 @@ int read_config(int reload)
CHECK(ReadTimeout);
CHECK(WarningTimeout);
CHECK(TimeoutCheck);
- CHECK(NSAccessMax);
- CHEK2(temp_nsuserhost, NSEnforcerUser);
- CHECK(NSReleaseTimeout);
- CHECK(NSListMax);
CHECK(CSAccessMax);
CHECK(CSAutokickMax);
CHECK(CSAutokickReason);
@@ -1755,48 +1751,30 @@ int read_config(int reload)
}
}
- if (!NSDefNone &&
- !NSDefKill &&
- !NSDefKillQuick &&
- !NSDefSecure &&
- !NSDefPrivate &&
- !NSDefHideEmail &&
- !NSDefHideUsermask &&
- !NSDefHideQuit && !NSDefMemoSignon && !NSDefMemoReceive) {
- NSDefSecure = 1;
- NSDefMemoSignon = 1;
- NSDefMemoReceive = 1;
- }
-
- NSDefFlags = 0;
- if (!NSDefNone) {
- if (NSDefKill)
- NSDefFlags |= NI_KILLPROTECT;
- if (NSDefKillQuick)
- NSDefFlags |= NI_KILL_QUICK;
- if (NSDefSecure)
- NSDefFlags |= NI_SECURE;
- if (NSDefPrivate)
- NSDefFlags |= NI_PRIVATE;
- if (NSDefMsg) {
- if (!UsePrivmsg)
- alog("NSDefMsg can only be used when UsePrivmsg is set - unsetting NSDefMsg");
- else
- NSDefFlags |= NI_MSG;
- }
- if (NSDefHideEmail)
- NSDefFlags |= NI_HIDE_EMAIL;
- if (NSDefHideUsermask)
- NSDefFlags |= NI_HIDE_MASK;
- if (NSDefHideQuit)
- NSDefFlags |= NI_HIDE_QUIT;
- if (NSDefMemoSignon)
- NSDefFlags |= NI_MEMO_SIGNON;
- if (NSDefMemoReceive)
- NSDefFlags |= NI_MEMO_RECEIVE;
- if (!NSDefAutoop)
- NSDefFlags |= NI_AUTOOP;
- }
+ NSDefFlags = 0;
+ if (NSDefaults.empty()) NSDefFlags = NI_SECURE | NI_MEMO_SIGNON | NI_MEMO_RECEIVE;
+ else if (NSDefaults != "none") {
+ bool hadAutoop = false;
+ spacesepstream options(NSDefaults);
+ std::string option;
+ while (options.GetToken(option)) {
+ if (option == "kill") NSDefFlags |= NI_KILLPROTECT;
+ else if (option == "killquick") NSDefFlags |= NI_KILL_QUICK;
+ else if (option == "secure") NSDefFlags |= NI_SECURE;
+ else if (option == "private") NSDefFlags |= NI_PRIVATE;
+ else if (option == "msg") {
+ if (!UsePrivmsg) alog("msg in <nickserv:defaults> can only be used when UsePrivmsg is set");
+ else NSDefFlags |= NI_MSG;
+ }
+ else if (option == "hideemail") NSDefFlags |= NI_HIDE_EMAIL;
+ else if (option == "hideusermask") NSDefFlags |= NI_HIDE_MASK;
+ else if (option == "hidequit") NSDefFlags |= NI_HIDE_QUIT;
+ else if (option == "memosignon") NSDefFlags |= NI_MEMO_SIGNON;
+ else if (option == "memoreceive") NSDefFlags |= NI_MEMO_RECEIVE;
+ else if (option == "autoop") hadAutoop = true;
+ }
+ if (!hadAutoop) NSDefFlags |= NI_AUTOOP;
+ }
if (!ServicesRoot) {
error(0,
@@ -1808,22 +1786,6 @@ int read_config(int reload)
retval = 0;
}
- CHECK(NSGuestNickPrefix); /* Add safety check */
- if (NSGuestNickPrefix && (strlen(NSGuestNickPrefix) > 21)) {
- error(0, "Value of NSGuestNickPrefix must be between 1 and 21");
- retval = 0;
- }
-
- CHECK(NSDefLanguage);
- if (NSDefLanguage) {
- NSDefLanguage--;
- if (NSDefLanguage < 0 || NSDefLanguage >= NUM_LANGS) {
- error(0, "Value of NSDefLanguage must be between 1 and %d",
- USED_LANGS);
- retval = 0;
- }
- }
-
if (!NewsCount) {
NewsCount = 3;
}
@@ -2052,12 +2014,9 @@ int read_config(int reload)
* rob
**/
if (NSEmailReg) {
- CHEK2(PreNickDBName, PreNickServDB);
- CHECK(NSEmailReg);
- CHECK(NSRExpire);
CHECK(UseMail);
- CHECK(NSForceEmail);
} else {
+ delete [] PreNickDBName;
PreNickDBName = NULL;
NSRExpire = 0;
}
diff --git a/src/datafiles.c b/src/datafiles.c
index 10008952e..4316da7b4 100644
--- a/src/datafiles.c
+++ b/src/datafiles.c
@@ -34,20 +34,14 @@ int get_file_version(dbFILE * f)
int version =
fgetc(fp) << 24 | fgetc(fp) << 16 | fgetc(fp) << 8 | fgetc(fp);
if (ferror(fp)) {
-#ifndef NOT_MAIN
log_perror("Error reading version number on %s", f->filename);
-#endif
return 0;
} else if (feof(fp)) {
-#ifndef NOT_MAIN
alog("Error reading version number on %s: End of file detected",
f->filename);
-#endif
return 0;
} else if (version < 1) {
-#ifndef NOT_MAIN
alog("Invalid version number (%d) on %s", version, f->filename);
-#endif
return 0;
}
return version;
@@ -67,9 +61,7 @@ int write_file_version(dbFILE * f, uint32 version)
fputc(version >> 16 & 0xFF, fp) < 0 ||
fputc(version >> 8 & 0xFF, fp) < 0 ||
fputc(version & 0xFF, fp) < 0) {
-#ifndef NOT_MAIN
log_perror("Error writing version number on %s", f->filename);
-#endif
return 0;
}
return 1;
@@ -90,7 +82,6 @@ static dbFILE *open_db_read(const char *service, const char *filename)
f = (dbFILE *)scalloc(sizeof(*f), 1);
if (!f) {
-#ifndef NOT_MAIN
log_perror("Can't read %s database %s", service, filename);
if (time(NULL) - lastwarn > WarningTimeout) {
ircdproto->SendGlobops(NULL,
@@ -98,7 +89,6 @@ static dbFILE *open_db_read(const char *service, const char *filename)
filename);
lastwarn = time(NULL);
}
-#endif
return NULL;
}
strscpy(f->filename, filename, sizeof(f->filename));
@@ -106,7 +96,6 @@ static dbFILE *open_db_read(const char *service, const char *filename)
fp = fopen(f->filename, "rb");
if (!fp) {
int errno_save = errno;
-#ifndef NOT_MAIN
if (errno != ENOENT)
log_perror("Can not read %s database %s", service,
f->filename);
@@ -115,7 +104,6 @@ static dbFILE *open_db_read(const char *service, const char *filename)
strerror(errno));
lastwarn = time(NULL);
}
-#endif
free(f);
errno = errno_save;
return NULL;
@@ -151,11 +139,7 @@ static dbFILE *open_db_write(const char *service, const char *filename,
f = (dbFILE *)scalloc(sizeof(*f), 1);
if (!f) {
-#ifndef NOT_MAIN
log_perror("Can not read %s database %s", service, filename);
-#else
- alog("Can not read %s database %s", service, filename);
-#endif
return NULL;
}
strscpy(f->filename, filename, sizeof(f->filename));
@@ -172,10 +156,8 @@ static dbFILE *open_db_write(const char *service, const char *filename,
snprintf(f->backupname, sizeof(f->backupname), "%s.save", filename);
if (!*f->backupname || strcmp(f->backupname, filename) == 0) {
int errno_save = errno;
-#ifndef NOT_MAIN
alog("Opening %s database %s for write: Filename too long",
service, filename);
-#endif
free(f);
errno = errno_save;
return NULL;
@@ -194,7 +176,7 @@ static dbFILE *open_db_write(const char *service, const char *filename,
if (rename(filename, f->backupname) < 0 && errno != ENOENT) {
int errno_save = errno;
#endif
-#ifndef NOT_MAIN
+
static int walloped = 0;
if (!walloped) {
walloped++;
@@ -219,15 +201,12 @@ static dbFILE *open_db_write(const char *service, const char *filename,
errno = errno_save;
log_perror("Can not back up %s database %s", service, filename);
if (!NoBackupOkay) {
-#endif
if (f->backupfp)
fclose(f->backupfp);
free(f);
errno = errno_save;
return NULL;
-#ifndef NOT_MAIN
}
-#endif
*f->backupname = 0;
}
#ifndef _WIN32
@@ -244,7 +223,6 @@ static dbFILE *open_db_write(const char *service, const char *filename,
f->fp = fdopen(fd, "wb"); /* will fail and return NULL if fd < 0 */
if (!f->fp || !write_file_version(f, version)) {
int errno_save = errno;
-#ifndef NOT_MAIN
static int walloped = 0;
if (!walloped) {
walloped++;
@@ -253,7 +231,6 @@ static dbFILE *open_db_write(const char *service, const char *filename,
}
errno = errno_save;
log_perror("Can't write to %s database %s", service, filename);
-#endif
if (f->fp) {
fclose(f->fp);
#ifndef _WIN32
@@ -263,12 +240,9 @@ static dbFILE *open_db_write(const char *service, const char *filename,
#endif
}
if (*f->backupname && rename(f->backupname, filename) < 0)
-#ifndef NOT_MAIN
log_perror("Cannot restore backup copy of %s", filename);
-#else
- ;
-#endif
- /* Then the Lord said unto Moses, thou shalt free what thou hast malloced
+
+ /* Then the Lord said unto Moses, thou shalt free what thou hast malloced
* -- codemastr */
free(f);
errno = errno_save;
@@ -342,10 +316,8 @@ void restore_db(dbFILE * f)
ftruncate(fileno(f->fp), ftell(f->fp));
}
}
-#ifndef NOT_MAIN
if (!ok && errno > 0)
log_perror("Unable to restore backup of %s", f->filename);
-#endif
errno_save = errno;
if (f->backupfp)
fclose(f->backupfp);
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
new file mode 100644
index 000000000..0c6d7718c
--- /dev/null
+++ b/src/hashcomp.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2002-2008 InspIRCd Development Team
+ * Copyright (C) 2008 Anope Team <info@anope.org>
+ *
+ * Please read COPYING and README for further details.
+ *
+ * These classes have been copied from InspIRCd and modified
+ * for use in Anope.
+ *
+ * $Id$
+ *
+ */
+
+#include "hashcomp.h"
+
+sepstream::sepstream(const std::string &source, char seperator) : tokens(source), sep(seperator)
+{
+ last_starting_position = n = tokens.begin();
+}
+
+bool sepstream::GetToken(std::string &token)
+{
+ std::string::iterator lsp = last_starting_position;
+
+ while (n != tokens.end())
+ {
+ if (*n == sep || n + 1 == tokens.end())
+ {
+ last_starting_position = n + 1;
+ token = std::string(lsp, n + 1 == tokens.end() ? n + 1 : ++n);
+
+ while (token.length() && token.find_last_of(sep) == token.length() - 1)
+ token.erase(token.end() - 1);
+
+ if (token.empty())
+ ++n;
+
+ return n == tokens.end() ? false : true;
+ }
+
+ ++n;
+ }
+
+ token = "";
+ return false;
+}
+
+const std::string sepstream::GetRemaining()
+{
+ return std::string(n, tokens.end());
+}
+
+bool sepstream::StreamEnd()
+{
+ return n + 1 == tokens.end();
+}
diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c
index ad489f101..a2e6ec763 100644
--- a/src/protocol/bahamut.c
+++ b/src/protocol/bahamut.c
@@ -71,7 +71,6 @@ IRCDVar myIrcd[] = {
"+io", /* operserv mode */
"+o", /* botserv mode */
"+h", /* helpserv mode */
- "+i", /* Dev/Null mode */
"+io", /* Global mode */
"+", /* Used by BotServ Bots */
2, /* Chan Max Symbols */
diff --git a/src/protocol/charybdis.c b/src/protocol/charybdis.c
index 2d1d8fb2f..ba6f5f1eb 100644
--- a/src/protocol/charybdis.c
+++ b/src/protocol/charybdis.c
@@ -57,7 +57,6 @@ IRCDVar myIrcd[] = {
"+oaiS", /* operserv mode */
"+oiS", /* botserv mode */
"+oiS", /* helpserv mode */
- "+oiS", /* Dev/Null mode */
"+oiS", /* Global mode */
"+oiS", /* Used by BotServ Bots */
2, /* Chan Max Symbols */
diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c
index d085df49e..0d4a671d8 100644
--- a/src/protocol/inspircd11.c
+++ b/src/protocol/inspircd11.c
@@ -79,7 +79,6 @@ IRCDVar myIrcd[] = {
"+ioI", /* operserv mode */
"+oI", /* botserv mode */
"+oI", /* helpserv mode */
- "+iI", /* Dev/Null mode */
"+ioI", /* Global mode */
"+sI", /* Used by BotServ Bots */
5, /* Chan Max Symbols */
diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c
index 859324490..f423a849a 100644
--- a/src/protocol/ratbox.c
+++ b/src/protocol/ratbox.c
@@ -56,7 +56,6 @@ IRCDVar myIrcd[] = {
"+oai", /* operserv mode */
"+oi", /* botserv mode */
"+oi", /* helpserv mode */
- "+oi", /* Dev/Null mode */
"+oi", /* Global mode */
"+oi", /* Used by BotServ Bots */
2, /* Chan Max Symbols */
diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c
index c51da8a0b..7ade811c8 100644
--- a/src/protocol/unreal32.c
+++ b/src/protocol/unreal32.c
@@ -93,7 +93,6 @@ IRCDVar myIrcd[] = {
"+ioS", /* operserv mode */
"+oS", /* botserv mode */
"+oS", /* helpserv mode */
- "+iS", /* Dev/Null mode */
"+ioS", /* Global mode */
"+qS", /* Used by BotServ Bots */
5, /* Chan Max Symbols */