From 2b0e9c3f5f0eb631619bc111764146553bcdf303 Mon Sep 17 00:00:00 2001 From: "Robin Burchell w00t@inspircd.org" Date: Mon, 13 Oct 2008 12:32:37 +0000 Subject: [PATCH] Merge commit 'cbx/anopeng-config' into anopeng-config git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1429 5417fbe8-f217-4b02-8779-1006273d7864 --- configure | 194 ---------------------------- configure.in | 2 - data/example.conf | 3 - data/example_new.conf | 176 ++++++++++++++++++++++++++ include/extern.h | 38 +++--- include/hashcomp.h | 82 ++++++++++++ include/services.h | 3 +- include/sysconf.h.in | 6 - include/sysconf.h.win32 | 2 - makefile.inc.win32 | 1 - src/Makefile | 32 ++--- src/compat.c | 24 ---- src/config.c | 257 ++++++++++++++++---------------------- src/datafiles.c | 34 +---- src/hashcomp.cpp | 56 +++++++++ src/protocol/bahamut.c | 1 - src/protocol/charybdis.c | 1 - src/protocol/inspircd11.c | 1 - src/protocol/ratbox.c | 1 - src/protocol/unreal32.c | 1 - 20 files changed, 458 insertions(+), 457 deletions(-) create mode 100644 include/hashcomp.h create mode 100644 src/hashcomp.cpp diff --git a/configure b/configure index d9e420987..5090a5a78 100755 --- a/configure +++ b/configure @@ -6955,200 +6955,6 @@ fi done -for ac_func in strdup -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then - eval "$as_ac_var=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval echo '${'$as_ac_var'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - cat >>confdefs.h <<\_ACEOF -#define HAVE_STRDUP 1 -_ACEOF - -fi -done - - -for ac_func in strspn -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then - eval "$as_ac_var=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval echo '${'$as_ac_var'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - cat >>confdefs.h <<\_ACEOF -#define HAVE_STRSPN 1 -_ACEOF - -fi -done - - for ac_func in gettimeofday do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` diff --git a/configure.in b/configure.in index 7e91eaed8..4a880af7d 100644 --- a/configure.in +++ b/configure.in @@ -234,8 +234,6 @@ AC_CHECK_HEADER(execinfo.h,AC_DEFINE(HAVE_BACKTRACE,1,"")) AC_CHECK_FUNCS(stricmp,AC_DEFINE(HAVE_STRICMP,1)) AC_CHECK_FUNCS(strcasecmp,AC_DEFINE(HAVE_STRCASECMP,1)) -AC_CHECK_FUNCS(strdup,AC_DEFINE(HAVE_STRDUP,1)) -AC_CHECK_FUNCS(strspn,AC_DEFINE(HAVE_STRSPN,1)) AC_CHECK_FUNCS(gettimeofday,AC_DEFINE(HAVE_GETTIMEOFDAY,1)) AC_CHECK_FUNCS(setgrent,AC_DEFINE(HAVE_SETGRENT,1)) AC_CHECK_FUNCS(umask,AC_DEFINE(HAVE_UMASK,1)) diff --git a/data/example.conf b/data/example.conf index 2c494fa4a..b6cd27bb9 100644 --- a/data/example.conf +++ b/data/example.conf @@ -1274,9 +1274,6 @@ WallDrop # with a large exception list, can degrade services' performance. # See the source and comments in sessions.c and the online help for more # information about session limiting. -# -# NOTE: This option is not available when STREAMLINED is defined in -# the Makefile. LimitSessions diff --git a/data/example_new.conf b/data/example_new.conf index 333b651b7..bca494c00 100644 --- a/data/example_new.conf +++ b/data/example_new.conf @@ -123,6 +123,7 @@ uplink * [REQUIRED] NickServ Config * * This section is used to set up the Nickname Registration Service pseudo-client. + * Unless specified otherwise, all directives are required. */ nickserv { @@ -130,9 +131,184 @@ nickserv * The nickname of the NickServ client. */ nick = "NickServ" + /* * The description of the NickServ client, which will be used as the GECOS (real * name) of the client. */ description = "Nickname Registration Service" + + /* + * The filename of the NickServ database. The path is relative to the services + * executable. If not given, defaults to "nick.db". + */ + database = "nick.db" + + /* + * The filename of the NickServ Pre-Nick database. The path is relative to the + * services executable. This directive is only required if the e-mail registration + * option is enabled. + */ + #prenickdatabase = "prenick.db" + + /* + * Force users to give an e-mail address when they register a nick. This directive + * is recommended to be enabled, and required if the e-mail registration option is + * enabled. + */ + forceemail = yes + + /* + * Require an e-mail to be sent to the user before they can register their nick. + */ + #emailregistration = yes + + /* + * The default options for newly registered nicks. Note that changing these options + * will have no effect on nicks which are already registered. The list must be separated + * by spaces + * + * The options are: + * - kill: Kill nick if not identified within 60 seconds + * - killquick: Kill nick if not identified within 20 seconds, this one overrides the above + * option and the above must be specified with this one + * - secure: Enable nickname security, requiring the nick's password before any operations + * can be done on it + * - private: Hide the nick from NickServ's LIST command + * - hideemail: Hide's the nick's e-mail address from NickServ's INFO command + * - hideusermask: Hide's the nick's last or current user@host from NickServ's INFO command + * - hidequit: Hide's the nick's last quit message + * - memosignon: Notify user if they have a new memo when they sign into the nick + * - memoreceive: Notify user if they have a new memo as soon as it's received + * - autoop: User will be automatically opped in channels they enter and have access to + * - msg: Services messages will be sent as PRIVMSGs instead of NOTICEs, requires UsePrivmsg + * to be enabled as well + * + * This directive is optional, if left blank, the options will default to secure, memosignon, and + * memoreceive. If you really want no defaults, use "none" by itself as the option. + */ + defaults="secure private hideemail hideusermask memosignon memoreceive autoop" + + /* + * Default language that non- and newly-registered nicks will receive messages in. The number + * here is the same as the number in NickServ's SET LANGUAGE help. + */ + defaultlanguage = 1 + + /* + * The minimum length of time between consecutive uses of NickServ's REGISTER command. This + * directive is optional, but recommended. If not set, this restriction will be disabled. + */ + regdelay = 30s + + /* + * The minimum length of time between consecutive uses of NickServ's RESEND command. This + * directive is optional, but recommended. If not set, this restriction will be disabled. + */ + resenddelay = 90s + + /* + * The length of time before a nick registration expires. This directive is optional, but + * recommended. If not set, the default is 21 days. + */ + expire = 21d + + /* + * The length of time a user gets to enter the confirmation code which has been e-mailed + * to them before the nick will be released for general use again. This directive is + * only required if the e-mail registration option is enabled. + */ + #preregexpire = 1d + + /* + * The maximum number of nicks allowed in a group. This directve is optional, but + * recommended. If not set or set to 0, no limits will be applied. + */ + maxaliases = 16 + + /* + * The maximum number of entries allowed on a nickname's access list. + */ + accessmax = 32 + + /* + * The username (and possibly hostname) used for the fake user created when NickServ collides + * a user. Should be in the user@host format. If the host is not given, the one from ServicesUser + * is used. + */ + enforceruser = "enforcer@localhost.net" + #enforceruser = "enforcer" + + /* + * The delay before a NickServ-collided nick is released. + */ + releasetimeout = 1m + + /* + * Allow the use of the IMMED option in the NickServ SET KILL command. This directive is optional. + */ + #allowkillimmed = yes + + /* + * If set, the NickServ GROUP command won't allow any group change. This is recommended for + * better performance and to protect against nick stealing, however users will have less + * flexibility. This directive is optional. + */ + #nogroupchange = yes + + /* + * Limits the use of the NickServ LIST command to IRC operators. This directive is optional. + */ + #listopersonly = yes + + /* + * The maximum number of nicks to be returned for a NickServ LIST command. + */ + listmax = 50 + + /* + * When a user's nick is forcibly changed to enforce a "nick kill", their new nick will start + * with this value. The rest will be made up of 6 or 7 digits. + */ + guestnickprefix = "Guest" + + /* + * Prevents the use of the DROP, FORBID, GETPASS, and SET PASSWORD commands by Services Admins + * on other Services Admins or the Services Root(s). This directive is optional, but + * recommended. + */ + secureadmins = yes + + /* + * If set, any user wanting to use the privileges of Services Root, Services Admin, or Services + * Operator must have been logged as an IRC Operator with the /oper command. This directive is + * optional, but recommended. + */ + strictprivileges = yes + + /* + * If set, Services will set the channel modes a user has access to upon identifying, assuming + * they are not already set. This directive is optional. + */ + #modeonid = yes + + /* + * If set, Services will only allow Services Root(s) to use the NickServ GETPASS command on + * a nick. This directive is optional. + */ + restrictgetpass = yes + + /* + * If set, Services will track your last nick identified when issuing nick changes. This + * directive is optional. + */ + #nicktracking = yes + + /* + * If set, Services will add the usermask of registering users to the access list of their + * newly created account. If not set, users will always have to identify to NickServ before + * being recognized, unless they manually add an address to the access list of their account. + * This directive is optional. + */ + addaccessonreg = yes } diff --git a/include/extern.h b/include/extern.h index 7135f7229..44f489fdd 100644 --- a/include/extern.h +++ b/include/extern.h @@ -217,12 +217,6 @@ E char *get_mlock_modes(ChannelInfo * ci, int complete); E int stricmp(const char *s1, const char *s2); E int strnicmp(const char *s1, const char *s2, size_t len); #endif -#if !HAVE_STRDUP -E char *strdup(const char *s); -#endif -#if !HAVE_STRSPN -E size_t strspn(const char *s, const char *accept); -#endif #ifdef _WIN32 char *sockstrerror(int error); #endif @@ -324,28 +318,28 @@ E int DontQuoteAddresses; E int NSDefFlags; E int NSDefLanguage; -E int NSRegDelay; -E int NSResendDelay; -E int NSExpire; -E int NSRExpire; -E int NSForceEmail; +E time_t NSRegDelay; +E time_t NSResendDelay; +E time_t NSExpire; +E time_t NSRExpire; +E bool NSForceEmail; E int NSMaxAliases; E int NSAccessMax; E char *NSEnforcerUser; E char *NSEnforcerHost; -E int NSReleaseTimeout; -E int NSAllowKillImmed; -E int NSNoGroupChange; -E int NSListOpersOnly; +E time_t NSReleaseTimeout; +E bool NSAllowKillImmed; +E bool NSNoGroupChange; +E bool NSListOpersOnly; E int NSListMax; E char *NSGuestNickPrefix; -E int NSSecureAdmins; -E int NSStrictPrivileges; -E int NSEmailReg; -E int NSModeOnID; -E int NSRestrictGetPass; -E int NSNickTracking; -E int NSAddAccessOnReg; +E bool NSSecureAdmins; +E bool NSStrictPrivileges; +E bool NSEmailReg; +E bool NSModeOnID; +E bool NSRestrictGetPass; +E bool NSNickTracking; +E bool NSAddAccessOnReg; E int CSDefFlags; E int CSMaxReg; diff --git a/include/hashcomp.h b/include/hashcomp.h new file mode 100644 index 000000000..8d0b09ec2 --- /dev/null +++ b/include/hashcomp.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2002-2008 InspIRCd Development Team + * Copyright (C) 2008 Anope Team + * + * Please read COPYING and README for further details. + * + * These classes have been copied from InspIRCd and modified + * for use in Anope. + * + * $Id$ + * + */ + +#ifndef _HASHCOMP_H_ +#define _HASHCOMP_H_ + +#include + +/** sepstream allows for splitting token seperated lists. + * Each successive call to sepstream::GetToken() returns + * the next token, until none remain, at which point the method returns + * an empty string. + */ +class sepstream +{ + private: + /** Original string. + */ + std::string tokens; + /** Last position of a seperator token + */ + std::string::iterator last_starting_position; + /** Current string position + */ + std::string::iterator n; + /** Seperator value + */ + char sep; + public: + /** Create a sepstream and fill it with the provided data + */ + sepstream(const std::string &source, char seperator); + virtual ~sepstream() { } + + /** Fetch the next token from the stream + * @param token The next token from the stream is placed here + * @return True if tokens still remain, false if there are none left + */ + virtual bool GetToken(std::string &token); + + /** Fetch the entire remaining stream, without tokenizing + * @return The remaining part of the stream + */ + virtual const std::string GetRemaining(); + + /** Returns true if the end of the stream has been reached + * @return True if the end of the stream has been reached, otherwise false + */ + virtual bool StreamEnd(); +}; + +/** A derived form of sepstream, which seperates on commas + */ +class commasepstream : public sepstream +{ + public: + /** Initialize with comma seperator + */ + commasepstream(const std::string &source) : sepstream(source, ',') { } +}; + +/** A derived form of sepstream, which seperates on spaces + */ +class spacesepstream : public sepstream +{ + public: + /** Initialize with space seperator + */ + spacesepstream(const std::string &source) : sepstream(source, ' ') { } +}; + +#endif diff --git a/include/services.h b/include/services.h index aafbb3ddc..c8d9af8ac 100644 --- a/include/services.h +++ b/include/services.h @@ -266,7 +266,6 @@ struct ircdvars_ { const char *operservmode; /* Mode used by OperServ */ const char *botservmode; /* Mode used by BotServ */ const char *helpservmode; /* Mode used by HelpServ */ - const char *devnullmode; /* Mode used by Dev/Null */ const char *globalmode; /* Mode used by Global */ const char *botserv_bot_mode; /* Mode used by BotServ Bots */ int max_symbols; /* Chan Max Symbols */ @@ -409,7 +408,7 @@ typedef struct { /* Flags: */ #define PARAM_OPTIONAL 0x01 -#define PARAM_FULLONLY 0x02 /* Directive only allowed if !STREAMLINED */ +/*#define PARAM_FULLONLY 0x02 unused */ #define PARAM_RELOAD 0x04 /* Directive is reloadable */ /*************************************************************************/ diff --git a/include/sysconf.h.in b/include/sysconf.h.in index f4b3f99e7..8c0f63f56 100644 --- a/include/sysconf.h.in +++ b/include/sysconf.h.in @@ -42,9 +42,6 @@ /* Define to 1 if you have the `strcasecmp' function. */ #undef HAVE_STRCASECMP -/* Define to 1 if you have the `strdup' function. */ -#undef HAVE_STRDUP - /* Define to 1 if you have the `stricmp' function. */ #undef HAVE_STRICMP @@ -60,9 +57,6 @@ /* Define to 1 if you have the `strlcpy' function. */ #undef HAVE_STRLCPY -/* Define to 1 if you have the `strspn' function. */ -#undef HAVE_STRSPN - /* "" */ #undef HAVE_SYS_SELECT_H diff --git a/include/sysconf.h.win32 b/include/sysconf.h.win32 index fb6d5a6e9..5b33a3608 100644 --- a/include/sysconf.h.win32 +++ b/include/sysconf.h.win32 @@ -18,8 +18,6 @@ typedef unsigned __int8 u_int8_t; #define HAVE_STRICMP 1 #define HAVE_STRCASECMP 0 -#define HAVE_STRDUP 1 -#define HAVE_STRSPN 1 #define HAVE_STRSIGNAL 0 #define HAVE_GETTIMEOFDAY 0 #define HAVE_SETGRENT 0 diff --git a/makefile.inc.win32 b/makefile.inc.win32 index 62448d015..aa81608ac 100644 --- a/makefile.inc.win32 +++ b/makefile.inc.win32 @@ -87,7 +87,6 @@ BASE_CFLAGS=/D USE_ENCRYPTION /D ENCRYPT_MD5 $(BASE_CFLAGS) # Compilation options: # -DCLEAN_COMPILE Attempt to compile without any warnings (note that # this may reduce performance) -# -DSTREAMLINED Leave out "fancy" options to enhance performance CDEFS = 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("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(value) == "prenickdatabase") { + if (!*data.GetString()) throw ConfigException(static_cast("The value for <") + tag + ":" + value + "> cannot be empty when e-mail registrations are enabled!"); + } + else if (static_cast(value) == "preregexpire") { + if (!data.GetInteger()) throw ConfigException(static_cast("The value for <") + tag + ":" + value + "> must be non-zero when e-mail registration are enabled!"); + } + else { + if (!data.GetBool()) throw ConfigException(static_cast("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("The value for 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 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 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 + * + * 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 */