From 381c9c8870fad4c544f29deec22ba4be3549a731 Mon Sep 17 00:00:00 2001 From: Naram Qashat Date: Sun, 20 Jun 2010 18:42:58 -0400 Subject: The first of a few "CBX OCDing over code style" commits, focusing on include/* and src/* but not src/core/* or src/modules/*. --- include/account.h | 44 +- include/bots.h | 24 +- include/channels.h | 28 +- include/commands.h | 18 +- include/config.h | 1465 +++++++++++++++++++++++++----------------------- include/extensible.h | 27 +- include/extern.h | 137 ++--- include/hashcomp.h | 86 +-- include/mail.h | 6 +- include/modes.h | 123 ++-- include/module.h | 3 +- include/modules.h | 120 ++-- include/operserv.h | 19 +- include/opertype.h | 60 +- include/regchannel.h | 37 +- include/servers.h | 18 +- include/services.h | 570 +++++++++---------- include/sockets.h | 19 +- include/threadengine.h | 12 +- include/timers.h | 168 +++--- include/users.h | 38 +- include/version.sh.c | 70 ++- 22 files changed, 1595 insertions(+), 1497 deletions(-) (limited to 'include') diff --git a/include/account.h b/include/account.h index e44880c29..0b7c95b44 100644 --- a/include/account.h +++ b/include/account.h @@ -1,3 +1,6 @@ +#ifndef ACCOUNT_H +#define ACCOUNT_H + class NickAlias; class NickCore; class NickRequest; @@ -92,7 +95,7 @@ class CoreExport NickRequest : public Extensible std::string password; char *email; time_t requested; - time_t lastmail; /* Unsaved */ + time_t lastmail; /* Unsaved */ }; class NickCore; @@ -111,12 +114,12 @@ class CoreExport NickAlias : public Extensible, public Flags ~NickAlias(); char *nick; /* Nickname */ - char *last_quit; /* Last quit message */ - char *last_realname; /* Last realname */ - char *last_usermask; /* Last usermask */ - time_t time_registered; /* When the nick was registered */ - time_t last_seen; /* When it was seen online for the last time */ - NickCore *nc; /* I'm an alias of this */ + char *last_quit; /* Last quit message */ + char *last_realname; /* Last realname */ + char *last_usermask; /* Last usermask */ + time_t time_registered; /* When the nick was registered */ + time_t last_seen; /* When it was seen online for the last time */ + NickCore *nc; /* I'm an alias of this */ HostInfo hostinfo; /** Release a nick @@ -146,28 +149,28 @@ class CoreExport NickCore : public Extensible, public Flags std::list Users; - char *display; /* How the nick is displayed */ - std::string pass; /* Password of the nicks */ - char *email; /* E-mail associated to the nick */ - char *greet; /* Greet associated to the nick */ - uint32 icq; /* ICQ # associated to the nick */ - char *url; /* URL associated to the nick */ - uint16 language; /* Language selected by nickname owner (LANG_*) */ - std::vector access; /* Access list, vector of strings */ + char *display; /* How the nick is displayed */ + std::string pass; /* Password of the nicks */ + char *email; /* E-mail associated to the nick */ + char *greet; /* Greet associated to the nick */ + uint32 icq; /* ICQ # associated to the nick */ + char *url; /* URL associated to the nick */ + uint16 language; /* Language selected by nickname owner (LANG_*) */ + std::vector access; /* Access list, vector of strings */ MemoInfo memos; - uint16 channelcount; /* Number of channels currently registered */ + uint16 channelcount; /* Number of channels currently registered */ OperType *ot; /* Unsaved data */ - time_t lastmail; /* Last time this nick record got a mail */ - std::list aliases; /* List of aliases */ + time_t lastmail; /* Last time this nick record got a mail */ + std::list aliases; /* List of aliases */ /** Check whether this opertype has access to run the given command string. * @param cmdstr The string to check, e.g. botserv/set/private. * @return True if this opertype may run the specified command, false otherwise. */ - virtual bool HasCommand(const std::string &cmdstr) const; + virtual bool HasCommand(const ci::string &cmdstr) const; /** Checks whether this account is a services oper or not. * @return True if this account is a services oper, false otherwise. @@ -178,7 +181,7 @@ class CoreExport NickCore : public Extensible, public Flags * @param privstr The priv to check for, e.g. users/auspex. * @return True if this opertype has the specified priv, false otherwise. */ - virtual bool HasPriv(const std::string &privstr) const; + virtual bool HasPriv(const ci::string &privstr) const; /** Add an entry to the nick's access list * @@ -221,3 +224,4 @@ class CoreExport NickCore : public Extensible, public Flags void ClearAccess(); }; +#endif // ACCOUNT_H diff --git a/include/bots.h b/include/bots.h index 8952005e7..9227f5c68 100644 --- a/include/bots.h +++ b/include/bots.h @@ -3,11 +3,11 @@ * Copyright (C) 2008-2010 Anope Team * * Please read COPYING and README for further details. - * - * - * */ +#ifndef BOTS_H +#define BOTS_H + #include "commands.h" class BotInfo; @@ -32,15 +32,15 @@ enum BotFlag class CoreExport BotInfo : public Extensible, public Flags { public: - std::string uid; /* required for UID supporting servers, as opposed to the shitty struct Uid. */ - std::string nick; /* Nickname of the bot */ - std::string user; /* Its user name */ - std::string host; /* Its hostname */ - std::string real; /* Its real name */ - time_t created; /* Birth date ;) */ - int16 chancount; /* Number of channels that use the bot. */ + std::string uid; /* required for UID supporting servers, as opposed to the shitty struct Uid. */ + std::string nick; /* Nickname of the bot */ + std::string user; /* Its user name */ + std::string host; /* Its hostname */ + std::string real; /* Its real name */ + time_t created; /* Birth date ;) */ + int16 chancount; /* Number of channels that use the bot. */ /* Dynamic data */ - time_t lastmsg; /* Last time we said something */ + time_t lastmsg; /* Last time we said something */ CommandMap Commands; /** Create a new bot. @@ -77,3 +77,5 @@ class CoreExport BotInfo : public Extensible, public Flags */ void UnAssign(User *u, ChannelInfo *ci); }; + +#endif // BOTS_H diff --git a/include/channels.h b/include/channels.h index 7814a377a..75f5dad3d 100644 --- a/include/channels.h +++ b/include/channels.h @@ -4,10 +4,11 @@ * Contact us at team@anope.org * * Please read COPYING and README for further details. - * - * */ +#ifndef CHANNELS_H +#define CHANNELS_H + typedef unordered_map_namespace::unordered_map channel_map; extern CoreExport channel_map ChannelList; @@ -75,12 +76,12 @@ class CoreExport Channel : public Extensible, public Flags */ ~Channel(); - std::string name; /* Channel name */ - ChannelInfo *ci; /* Corresponding ChannelInfo */ - time_t creation_time; /* When channel was created */ + std::string name; /* Channel name */ + ChannelInfo *ci; /* Corresponding ChannelInfo */ + time_t creation_time; /* When channel was created */ char *topic; std::string topic_setter; - time_t topic_time; /* When topic was set */ + time_t topic_time; /* When topic was set */ EList *bans; EList *excepts; @@ -90,13 +91,13 @@ class CoreExport Channel : public Extensible, public Flags CUserList users; BanData *bd; - - time_t server_modetime; /* Time of last server MODE */ - time_t chanserv_modetime; /* Time of last check_modes() */ - int16 server_modecount; /* Number of server MODEs this second */ - int16 chanserv_modecount; /* Number of check_mode()'s this sec */ - int16 bouncy_modes; /* Did we fail to set modes here? */ - int16 topic_sync; /* Is the topic in sync? */ + + time_t server_modetime; /* Time of last server MODE */ + time_t chanserv_modetime; /* Time of last check_modes() */ + int16 server_modecount; /* Number of server MODEs this second */ + int16 chanserv_modecount; /* Number of check_mode()'s this sec */ + int16 bouncy_modes; /* Did we fail to set modes here? */ + int16 topic_sync; /* Is the topic in sync? */ /** Restore the channel topic, set mlock (key), set stickied bans, etc */ @@ -263,3 +264,4 @@ class CoreExport Channel : public Extensible, public Flags bool Kick(BotInfo *bi, User *u, const char *reason = NULL, ...); }; +#endif // CHANNELS_H diff --git a/include/commands.h b/include/commands.h index 327d65736..cfe2eddab 100644 --- a/include/commands.h +++ b/include/commands.h @@ -7,12 +7,10 @@ * * Based on the original code of Epona by Lara. * Based on the original code of Services by Andy Church. - * - * */ -#ifndef COMMAND_H_ -#define COMMAND_H_ +#ifndef COMMAND_H +#define COMMAND_H #include "services.h" @@ -57,7 +55,7 @@ class CoreExport Command : public Flags /* Command name */ ci::string name; /* Permission needed to use this comand */ - std::string permission; + ci::string permission; /* Module which owns us */ Module *module; @@ -70,7 +68,7 @@ class CoreExport Command : public Flags * @param max_params The maximum number of parameters the parser will create, after max_params, all will be combined into the last argument. * NOTE: If max_params is not set (default), there is no limit to the max number of params. */ - Command(const ci::string &sname, size_t min_params, size_t max_params = 0, const std::string &spermission = ""); + Command(const ci::string &sname, size_t min_params, size_t max_params = 0, const ci::string &spermission = ""); virtual ~Command(); @@ -86,8 +84,7 @@ class CoreExport Command : public Flags /** Requested when the user is requesting help on this command. Help on this command should be sent to the user. * @param u The user requesting help - * @param subcommand The subcommand the user is requesting help on, or an empty string. (e.g. /ns help set foo bar lol gives a subcommand of -"FOO BAR LOL") + * @param subcommand The subcommand the user is requesting help on, or an empty string. (e.g. /ns help set foo bar lol gives a subcommand of "FOO BAR LOL") * @return true if help was provided to the user, false otherwise. */ virtual bool OnHelp(User *u, const ci::string &subcommand); @@ -101,7 +98,7 @@ class CoreExport Command : public Flags /** Set which command permission (e.g. chanserv/forbid) is required for this command. * @param reststr The permission required to successfully execute this command */ - void SetPermission(const std::string &reststr); + void SetPermission(const ci::string &reststr); /** Add a subcommand to this command * @param c The command @@ -114,5 +111,4 @@ class CoreExport Command : public Flags virtual bool DelSubcommand(const ci::string &cname); }; -#endif - +#endif // COMMANDS_H diff --git a/include/config.h b/include/config.h index dacf3db06..dc1dde3f8 100644 --- a/include/config.h +++ b/include/config.h @@ -1,5 +1,5 @@ -#ifndef _CONFIGREADER_H_ -#define _CONFIGREADER_H_ +#ifndef CONFIG_H +#define CONFIG_H #include #include @@ -10,7 +10,7 @@ /** A configuration key and value pair */ -typedef std::pair KeyVal; +typedef std::pair KeyVal; /** A list of related configuration keys and values */ @@ -18,20 +18,22 @@ typedef std::vector KeyValList; /** An entire config file, built up of KeyValLists */ -typedef std::multimap ConfigDataHash; +typedef std::multimap ConfigDataHash; // Required forward definitions class ServerConfig; /** Types of data in the core config */ -enum ConfigDataType { +enum ConfigDataType +{ DT_NOTHING, // No data DT_INTEGER, // Integer DT_UINTEGER, // Unsigned Integer DT_LUINTEGER, // Long Unsigned Integer DT_CHARPTR, // Char pointer DT_STRING, // std::string + DT_CISTRING, // ci::string DT_BOOLEAN, // Boolean DT_HOSTNAME, // Hostname syntax DT_NOSPACES, // No spaces @@ -50,35 +52,42 @@ enum ConfigDataType { */ class ValueItem { - /** Actual data */ - std::string v; - public: - /** Initialize with an int */ - ValueItem(int); - /** Initialize with a bool */ - ValueItem(bool); - /** Initialize with a char pointer */ - ValueItem(const char *); - /** Initialize with an std::string */ - ValueItem(const std::string &); - /** Initialize with a long */ - ValueItem(long); - /** Change value to a char pointer */ - //void Set(char *); - /** Change value to a const char pointer */ - void Set(const char *); - /** Change value to an std::string */ - void Set(const std::string &); - /** Change value to an int */ - void Set(int); - /** Get value as an int */ - int GetInteger(); - /** Get value as a string */ - const char *GetString() const; - /** Get value as a string */ - inline const std::string &GetValue() const { return v; } - /** Get value as a bool */ - bool GetBool(); + private: + /** Actual data */ + std::string v; + public: + /** Initialize with an int */ + ValueItem(int); + /** Initialize with a bool */ + ValueItem(bool); + /** Initialize with a char pointer */ + ValueItem(const char *); + /** Initialize with an std::string */ + ValueItem(const std::string &); + /** Initialize with an std::string */ + ValueItem(const ci::string &); + /** Initialize with a long */ + ValueItem(long); + /** Change value to a char pointer */ + //void Set(char *); + /** Change value to a const char pointer */ + void Set(const char *); + /** Change value to an std::string */ + void Set(const std::string &); + /** Change value to a ci::string */ + void Set(const ci::string &); + /** Change value to an int */ + void Set(int); + /** Get value as an int */ + int GetInteger(); + /** Get value as a string */ + const char *GetString() const; + /** Get value as a string */ + inline const std::string &GetValue() const { return v; } + /** Get value as a ci::string */ + inline const ci::string GetCIValue() const { return v.c_str(); } + /** Get value as a bool */ + bool GetBool(); }; /** The base class of the container 'ValueContainer' @@ -86,11 +95,11 @@ class ValueItem */ class ValueContainerBase { - public: - /** Constructor */ - ValueContainerBase() { } - /** Destructor */ - virtual ~ValueContainerBase() { } + public: + /** Constructor */ + ValueContainerBase() { } + /** Destructor */ + virtual ~ValueContainerBase() { } }; /** ValueContainer is used to contain pointers to different @@ -103,86 +112,132 @@ class ValueContainerBase */ template class ValueContainer : public ValueContainerBase { - /** Contained item */ - T val; - public: - /** Initialize with nothing */ - ValueContainer() : ValueContainerBase(), val(NULL) { } - /** Initialize with a value of type T */ - ValueContainer(T Val) : ValueContainerBase(), val(Val) { } - /** Initialize with a copy */ - ValueContainer(const ValueContainer &Val) : ValueContainerBase(), val(Val.val) { } - ValueContainer &operator=(const ValueContainer &Val) - { - val = Val.val; - return *this; - } - /** Change value to type T of size s */ - void Set(const T newval, size_t s) - { - memcpy(val, newval, s); - } + private: + /** Contained item */ + T val; + public: + /** Initialize with nothing */ + ValueContainer() : ValueContainerBase(), val(NULL) { } + /** Initialize with a value of type T */ + ValueContainer(T Val) : ValueContainerBase(), val(Val) { } + /** Initialize with a copy */ + ValueContainer(const ValueContainer &Val) : ValueContainerBase(), val(Val.val) { } + ValueContainer &operator=(const ValueContainer &Val) + { + val = Val.val; + return *this; + } + /** Change value to type T of size s */ + void Set(const T newval, size_t s) + { + memcpy(val, newval, s); + } }; /** This a specific version of ValueContainer to handle character arrays specially */ template<> class ValueContainer : public ValueContainerBase { - /** Contained item */ - char **val; - public: - /** Initialize with nothing */ - ValueContainer() : ValueContainerBase(), val(NULL) { } - /** Initialize with a value of type T */ - ValueContainer(char **Val) : ValueContainerBase(), val(Val) { } - /** Initialize with a copy */ - ValueContainer(const ValueContainer &Val) : ValueContainerBase(), val(Val.val) { } - ValueContainer &operator=(const ValueContainer &Val) + private: + /** Contained item */ + char **val; + public: + /** Initialize with nothing */ + ValueContainer() : ValueContainerBase(), val(NULL) { } + /** Initialize with a value of type T */ + ValueContainer(char **Val) : ValueContainerBase(), val(Val) { } + /** Initialize with a copy */ + ValueContainer(const ValueContainer &Val) : ValueContainerBase(), val(Val.val) { } + ValueContainer &operator=(const ValueContainer &Val) + { + val = Val.val; + return *this; + } + /** Change value to type T of size s */ + void Set(const char *newval, size_t s) + { + if (*val) + delete [] *val; + if (!*newval) { - val = Val.val; - return *this; - } - /** Change value to type T of size s */ - void Set(const char *newval, size_t s) - { - if (*val) delete [] *val; - if (!*newval) { - *val = NULL; - return; - } - *val = new char[s]; - strlcpy(*val, newval, s); + *val = NULL; + return; } + *val = new char[s]; + strlcpy(*val, newval, s); + } }; /** This a specific version of ValueContainer to handle std::string specially */ template<> class ValueContainer : public ValueContainerBase { - /** Contained item */ - std::string *val; - public: - /** Initialize with nothing */ - ValueContainer() : ValueContainerBase(), val(NULL) { } - /** Initialize with an std::string */ - ValueContainer(std::string *Val) : ValueContainerBase(), val(Val) { } - /** Initialize with a copy */ - ValueContainer(const ValueContainer &Val) : ValueContainerBase(), val(Val.val) { } - ValueContainer &operator=(const ValueContainer &Val) - { - val = Val.val; - return *this; - } - /** Change value to given std::string */ - void Set(const std::string &newval) - { - *val = newval; - } - /** Change value to given char pointer */ - void Set(const char *newval) - { - *val = newval; - } + private: + /** Contained item */ + std::string *val; + public: + /** Initialize with nothing */ + ValueContainer() : ValueContainerBase(), val(NULL) { } + /** Initialize with an std::string */ + ValueContainer(std::string *Val) : ValueContainerBase(), val(Val) { } + /** Initialize with a copy */ + ValueContainer(const ValueContainer &Val) : ValueContainerBase(), val(Val.val) { } + ValueContainer &operator=(const ValueContainer &Val) + { + val = Val.val; + return *this; + } + /** Change value to given std::string */ + void Set(const std::string &newval) + { + *val = newval; + } + /** Change value to given ci::string */ + void Set(const ci::string &newval) + { + *val = newval.c_str(); + } + /** Change value to given char pointer */ + void Set(const char *newval) + { + *val = newval; + } +}; + +/** This a specific version of ValueContainer to handle ci::string specially + */ +template<> class ValueContainer : public ValueContainerBase +{ + private: + /** Contained item */ + ci::string *val; + public: + /** Initialize with nothing */ + ValueContainer() : ValueContainerBase(), val(NULL) { } + /** Initialize with an std::string */ + ValueContainer(ci::string *Val) : ValueContainerBase(), val(Val) { } + /** Initialize with a copy */ + ValueContainer(const ValueContainer &Val) : ValueContainerBase(), val(Val.val) { } + ValueContainer &operator=(const ValueContainer &Val) + { + val = Val.val; + return *this; + } + /** Change value to given std::string */ + void Set(const std::string &newval) + { + *val = newval.c_str(); + } + /** Change value to given ci::string */ + void Set(const ci::string &newval) + { + *val = newval; + } + /** Change value to given char pointer */ + void Set(const char *newval) + { + *val = newval; + } }; /** A specialization of ValueContainer to hold a pointer to a bool @@ -219,6 +274,11 @@ typedef ValueContainer ValueContainerTime; */ typedef ValueContainer ValueContainerString; +/** A specialization of ValueContainer to hold a pointer to + * an ci::string + */ +typedef ValueContainer ValueContainerCIString; + /** A set of ValueItems used by multi-value validator functions */ typedef std::deque ValueList; @@ -279,482 +339,487 @@ struct MultiConfig */ class ServerConfig { - private: - /** This variable holds the names of all - * files included from the main one. This - * is used to make sure that no files are - * recursively included. - */ - std::vector include_stack; - /** Check that there is only one of each configuration item - */ - bool CheckOnce(const char *); - public: - std::ostringstream errstr; - ConfigDataHash newconfig; - /** This holds all the information in the config file, - * it's indexed by tag name to a vector of key/values. - */ - ConfigDataHash config_data; - /** Construct a new ServerConfig - */ - ServerConfig(); - /** Clears the include stack in preperation for a Read() call. - */ - void ClearStack(); - /** Read the entire configuration into memory - * and initialize this class. All other methods - * should be used only by the core. - */ - int Read(bool); - /** Report a configuration error given in errormessage. - * @param bail If this is set to true, the error is sent to the console, and the program exits - * @param connection If this is set to a non-null value, and bail is false, the errors are spooled to - * this connection as SNOTICEs. - * If the parameter is NULL, the messages are spooled to all connections via WriteOpers as SNOTICEs. - */ - void ReportConfigError(const std::string &, bool); - /** Load 'filename' into 'target', with the new config parser everything is parsed into - * tag/key/value at load-time rather than at read-value time. - */ - bool LoadConf(ConfigDataHash &, const char *, std::ostringstream &); - /** Load 'filename' into 'target', with the new config parser everything is parsed into - * tag/key/value at load-time rather than at read-value time. - */ - bool LoadConf(ConfigDataHash &, const std::string &, std::ostringstream &); - // Both these return true if the value existed or false otherwise - /** Writes 'length' chars into 'result' as a string - */ - bool ConfValue(ConfigDataHash &, const char *, const char *, int, char *, int, bool = false); - /** Writes 'length' chars into 'result' as a string - */ - bool ConfValue(ConfigDataHash &, const char *, const char *, const char *, int, char *, int, bool = false); - /** Writes 'length' chars into 'result' as a string - */ - bool ConfValue(ConfigDataHash &, const std::string &, const std::string &, int, std::string &, bool = false); - /** Writes 'length' chars into 'result' as a string - */ - bool ConfValue(ConfigDataHash &, const std::string &, const std::string &, const std::string &, int, std::string &, bool = false); - /** Tries to convert the value to an integer and write it to 'result' - */ - bool ConfValueInteger(ConfigDataHash &, const char *, const char *, int, int &); - /** Tries to convert the value to an integer and write it to 'result' - */ - bool ConfValueInteger(ConfigDataHash &, const char *, const char *, const char *, int, int &); - /** Tries to convert the value to an integer and write it to 'result' - */ - bool ConfValueInteger(ConfigDataHash &, const std::string &, const std::string &, int, int &); - /** Tries to convert the value to an integer and write it to 'result' - */ - bool ConfValueInteger(ConfigDataHash &, const std::string &, const std::string &, const std::string &, int, int &); - /** Returns true if the value exists and has a true value, false otherwise - */ - bool ConfValueBool(ConfigDataHash &, const char *, const char *, int); - /** Returns true if the value exists and has a true value, false otherwise - */ - bool ConfValueBool(ConfigDataHash &, const char *, const char *, const char *, int); - /** Returns true if the value exists and has a true value, false otherwise - */ - bool ConfValueBool(ConfigDataHash &, const std::string &, const std::string &, int); - /** Returns true if the value exists and has a true value, false otherwise - */ - bool ConfValueBool(ConfigDataHash &, const std::string &, const std::string &, const std::string &, int); - /** Returns the number of occurences of tag in the config file - */ - int ConfValueEnum(ConfigDataHash &, const char *); - /** Returns the number of occurences of tag in the config file - */ - int ConfValueEnum(ConfigDataHash &, const std::string &); - /** Returns the numbers of vars inside the index'th 'tag in the config file - */ - int ConfVarEnum(ConfigDataHash &, const char *, int); - /** Returns the numbers of vars inside the index'th 'tag in the config file - */ - int ConfVarEnum(ConfigDataHash &, const std::string &, int); - void ValidateHostname(const char *, const std::string &, const std::string &); - void ValidateIP(const char *p, const std::string &, const std::string &, bool); - void ValidateNoSpaces(const char *, const std::string &, const std::string &); - - - - /** Below here is a list of variables which contain the config files values - */ - /* IRCd module in use */ - char *IRCDModule; - - /* Host to connect to **/ - char *LocalHost; - /* List of uplink servers to try and connect to */ - std::list Uplinks; - - /* Our server name */ - char *ServerName; - /* Our servers description */ - char *ServerDesc; - /* The username/ident of services clients */ - char *ServiceUser; - /* The hostname if services clients */ - char *ServiceHost; - - /* Help channel, ops here get usermode +h **/ - char *HelpChannel; - /* Log channel */ - char *LogChannel; - /* Name of the network were on */ - char *NetworkName; - /* The max legnth of nicks */ - unsigned NickLen; - /* Max length of idents */ - unsigned UserLen; - /* Max lenght of hostnames */ - unsigned HostLen; - - /* Max length of passwords */ - unsigned PassLen; - - /* NickServ Name */ - char *s_NickServ; - /* ChanServ Name */ - char *s_ChanServ; - /* MemoServ Name */ - char *s_MemoServ; - /* BotServ Name */ - char *s_BotServ; - /* OperServ name */ - char *s_OperServ; - /* Global name */ - char *s_GlobalNoticer; - /* NickServs realname */ - char *desc_NickServ; - /* ChanServ realname */ - char *desc_ChanServ; - /* MemoServ relname */ - char *desc_MemoServ; - /* BotServ realname */ - char *desc_BotServ; - /* OperServ realname */ - char *desc_OperServ; - /* Global realname */ - char *desc_GlobalNoticer; - - /* HostServ Name */ - char *s_HostServ; - /* HostServ realname */ - char *desc_HostServ; - - /* Filename for the PID file */ - char *PIDFilename; - /* MOTD filename */ - char *MOTDFilename; - - /* True if its ok to not be able to save backs */ - bool NoBackupOkay; - /* Do password checking when new people register */ - bool StrictPasswords; - /* How many times you're allowed to give a bad password before being killed */ - unsigned BadPassLimit; - /* How long before bad passwords are forgotten */ - time_t BadPassTimeout; - /* Delay between automatic database updates */ - time_t UpdateTimeout; - /* Delay between checks for expired nicks and channels */ - time_t ExpireTimeout; - /* How long to wait for something from the uplink, this is passed to select() */ - time_t ReadTimeout; - /* How often to send program errors */ - time_t WarningTimeout; - /* How long to process things such as timers to see if there is anything to calll */ - time_t TimeoutCheck; - /* Num of days logfiles are kept */ - int KeepLogs; - /* Number of days backups are kept */ - int KeepBackups; - /* Forbidding requires a reason */ - bool ForceForbidReason; - /* Services should use privmsgs instead of notices */ - bool UsePrivmsg; - /* Services only respond to full PRIVMSG client@services.server.name messages */ - bool UseStrictPrivMsg; - /* Dump a core file if we crash */ - bool DumpCore; - /* Log users connecting/existing/changing nicks */ - bool LogUsers; - /* Number of seconds between consecutive uses of the REGISTER command - * Not to be confused with NSRegDelay */ - unsigned NickRegDelay; - /* Max number if news items allowed in the list */ - unsigned NewsCount; - /* Default mlock modes */ - std::string MLock; - /* Default botmodes on channels, defaults to ao */ - std::string BotModes; - /* How many times to try and reconnect to the uplink before giving up */ - unsigned MaxRetries; - /* How long to wait between connection attempts */ - int RetryWait; - - /* Services can use email */ - bool UseMail; - /* Path to the sendmail executable */ - char *SendMailPath; - /* Address to send from */ - char *SendFrom; - /* Only opers can have services send mail */ - bool RestrictMail; - /* Delay between sending mail */ - time_t MailDelay; - /* Don't quote the To: address */ - bool DontQuoteAddresses; - - /* Prefix of guest nicks when a user gets forced off of a nick */ - char *NSGuestNickPrefix; - /* Allow users to set kill immed on */ - bool NSAllowKillImmed; - /* Don't allow nicks to use /ns group to regroup nicks */ - bool NSNoGroupChange; - /* Default flags for newly registered nicks */ - Flags NSDefFlags; - /* Default language used by services */ - unsigned NSDefLanguage; - /* Users must be connected this long before they can register - * Not to be confused with NickRegDelay */ - time_t NSRegDelay; - /* Time before the registering mail will be resent */ - time_t NSResendDelay; - /* How long before nicks expir */ - time_t NSExpire; - /* Time before NickRequests expire */ - time_t NSRExpire; - /* Force email when registering */ - bool NSForceEmail; - /* Max number of nicks in a group */ - int NSMaxAliases; - /* Max number of allowed strings on the access list */ - unsigned NSAccessMax; - /* Enforcer client user name */ - char *NSEnforcerUser; - /* Enforcer client hostname */ - char *NSEnforcerHost; - /* How long before recovered nicks are released */ - time_t NSReleaseTimeout; - /* /nickserv list is oper only */ - bool NSListOpersOnly; - /* Max number of entries that can be returned from the list command */ - unsigned NSListMax; - /* Only allow usermode +a etc on real services admins */ - bool NSSecureAdmins; - /* Services opers must be /operd on the ircd aswell */ - bool NSStrictPrivileges; - /* Use email to verify new users registering */ - bool NSEmailReg; - /* Set the proper channel modes on users when they identify */ - bool NSModeOnID; - /* Add the users hostnask their access list when they register */ - bool NSAddAccessOnReg; - - /* Default flags for newly registered channels */ - Flags CSDefFlags; - /* Max number of channels a user can own */ - unsigned CSMaxReg; - /* Time before a channel expires */ - time_t CSExpire; - /* Default ban type to use for channels */ - int CSDefBantype; - /* Max number of entries allowed on channel access lists */ - unsigned CSAccessMax; - /* Max number of entries allowed on autokick lists */ - unsigned CSAutokickMax; - /* Default autokick reason */ - char *CSAutokickReason; - /* Time ChanServ should stay in the channel to hold it to keep users from getting in */ - time_t CSInhabit; - /* ChanServ's LIST command is oper only */ - bool CSListOpersOnly; - /* Max number of entries allowed to be returned from the LIST command */ - unsigned CSListMax; - /* true to make ChanServ oper only */ - bool CSOpersOnly; - - /* Max number of memos allowed */ - unsigned MSMaxMemos; - /* Time you must wait between sending memos */ - time_t MSSendDelay; - /* Notify all of the aliases of the core the memo was sent to */ - bool MSNotifyAll; - /* Who can use memos reciepts */ - unsigned MSMemoReceipt; - - /* Defai;t BotServ flags */ - Flags BSDefFlags; - /* How long before botserv forgets a user. This is used for flood kickers etc */ - time_t BSKeepData; - /* Min number of users to have in the channel before the service bot joins */ - unsigned BSMinUsers; - /* Max number of words allowed on the badwordslist */ - unsigned BSBadWordsMax; - /* BotServ bot only joins if it would normally allowed to, abides by bans etc */ - bool BSSmartJoin; - /* Dont tell users what badword they used */ - bool BSGentleBWReason; - /* Case sensitive badwords matching */ - bool BSCaseSensitive; - /* Char to use for the fantasy char, eg ! */ - char *BSFantasyCharacter; - - /* Only show /stats o to opers */ - bool HideStatsO; - /* Send out a global when services shut down or restart */ - bool GlobalOnCycle; - /* Don't include the opers name in globals */ - bool AnonymousGlobal; - /* Dont allow users to register nicks with oper names in them */ - bool RestrictOperNicks; - /* Message to send when shutting down */ - char *GlobalOnCycleMessage; - /* Message to send when starting up */ - char *GlobalOnCycleUP; - /* Super admin is allowed */ - bool SuperAdmin; - /* Log things said through ACT/SAY */ - bool LogBot; - /* Log when new user max is reached */ - bool LogMaxUsers; - /* Default expiry time for akills */ - time_t AutokillExpiry; - /* Default expiry time for chan kills */ - time_t ChankillExpiry; - /* Default expiry time for SNLine Expire */ - time_t SNLineExpiry; - /* Default expiry time for SQLines */ - time_t SQLineExpiry; - /* Default expiry time for SZLine */ - time_t SZLineExpiry; - /* Actually akill the user when the akill is added */ - bool AkillOnAdd; - /* Kill users on SNLine */ - bool KillonSNline; - /* Kill users on SQline */ - bool KillonSQline; - /* Send a WALLOPS/GLOBOPS when a user opers */ - bool WallOper; - /* Send a WALLOPS/GLOBOPS when a nonoper tries to use OperServ */ - bool WallBadOS; - /* Send a WALLOPS/GLOBOPS when someone uses the GLOBAL command */ - bool WallOSGlobal; - /* Send a WALLOPS/GLOBOPS when someone uses the MODE command */ - bool WallOSMode; - /* Send a WALLOPS/GLOBOPS when someone uses the CLEARMODES command */ - bool WallOSClearmodes; - /* Send a WALLOPS/GLOBOPS when someone uses the KICK command */ - bool WallOSKick; - /* Send a WALLOPS/GLOBOPS when someone uses the AKILL command */ - bool WallOSAkill; - /* Send a WALLOPS/GLOBOPS when someone uses the SNLINE command */ - bool WallOSSNLine; - /* Send a WALLOPS/GLOBOPS when someone uses the SQLINE command */ - bool WallOSSQLine; - /* Send a WALLOPS/GLOBOPS when someone uses the SZLINE command */ - bool WallOSSZLine; - /* Send a WALLOPS/GLOBOPS when someone uses the NOOP command */ - bool WallOSNoOp; - /* Send a WALLOPS/GLOBOPS when when someone uses the JUPE command */ - bool WallOSJupe; - /* Send a WALLOPS/GLOBOPS when an akill expires */ - bool WallAkillExpire; - /* Send a WALLOPS/GLOBOPS when SNLines expire */ - bool WallSNLineExpire; - /* Send a WALLOPS/GLOBOPS when SQLines expire */ - bool WallSQLineExpire; - /* Send a WALLOPS/GLOBOPS when SZLines expire */ - bool WallSZLineExpire; - /* Send a WALLOPS/GLOBOPS when exceptions expire */ - bool WallExceptionExpire; - /* Send a WALLOPS/GLOBOPS when DROP is used */ - bool WallDrop; - /* Send a WALLOPS/GLOBOPS when FORBID is used */ - bool WallForbid; - /* Send a WALLOPS/GLOBOPS when GETPASS is used */ - bool WallGetpass; - /* Send a WALLOPS/GLOBOPS when SETPASS is used */ - bool WallSetpass; - /* Add the akillers nick to the akill reason */ - bool AddAkiller; - - /* Limit sessions */ - bool LimitSessions; - /* The default session limit */ - unsigned DefSessionLimit; - /* How long before exceptions expire */ - time_t ExceptionExpiry; - /* How many times to kill before adding an KILL */ - int MaxSessionKill; - /* Max limit that can be used for exceptions */ - unsigned MaxSessionLimit; - /* How long session akills should last */ - time_t SessionAutoKillExpiry; - /* Reason to use for session kills */ - char *SessionLimitExceeded; - /* Optional second reason */ - char *SessionLimitDetailsLoc; - /* OperServ requires you to be an operator */ - bool OSOpersOnly; - - /* List of modules to autoload */ - std::list ModulesAutoLoad; - /* Encryption modules */ - std::list EncModuleList; - /* Database modules */ - std::list DBModuleList; - /* HostServ Core Modules */ - std::list HostServCoreModules; - /* MemoServ Core Modules */ - std::list MemoServCoreModules; - /* BotServ Core Modules */ - std::list BotServCoreModules; - /* OperServ Core Modules */ - std::list OperServCoreModules; - /* NickServ Core Modules */ - std::list NickServCoreModules; - /* ChanServ Core Modules */ - std::list ChanServCoreModules; - - /* Default defcon level */ - int DefConLevel; - /* Timeout before defcon is reset */ - time_t DefConTimeOut; - /* Session limiit to use when using defcon */ - int DefConSessionLimit; - /* How long to add akills for defcon */ - time_t DefConAKILL; - /* Chan modes for defcon */ - char *DefConChanModes; - /* Should we global on defcon */ - bool GlobalOnDefcon; - /* Should we send DefconMessage aswell? */ - bool GlobalOnDefconMore; - /* Message to send when defcon is off */ - char *DefConOffMessage; - /* Message to send when defcon is on*/ - char *DefconMessage; - /* Reason to akill clients for defcon */ - char *DefConAkillReason; - - /* User keys to use for generating random hashes for pass codes etc */ - long unsigned int UserKey1; - long unsigned int UserKey2; - long unsigned int UserKey3; - - /* Numeric */ - char *Numeric; - /* Array of ulined servers */ - char **Ulines; - /* Number of ulines */ - int NumUlines; - - /* List of available opertypes */ - std::list MyOperTypes; - /* List of pairs of opers and their opertype from the config */ - std::list > Opers; + private: + /** This variable holds the names of all + * files included from the main one. This + * is used to make sure that no files are + * recursively included. + */ + std::vector include_stack; + /** Check that there is only one of each configuration item + */ + bool CheckOnce(const char *); + public: + std::ostringstream errstr; + ConfigDataHash newconfig; + /** This holds all the information in the config file, + * it's indexed by tag name to a vector of key/values. + */ + ConfigDataHash config_data; + /** Construct a new ServerConfig + */ + ServerConfig(); + /** Clears the include stack in preperation for a Read() call. + */ + void ClearStack(); + /** Read the entire configuration into memory + * and initialize this class. All other methods + * should be used only by the core. + */ + int Read(bool); + /** Report a configuration error given in errormessage. + * @param bail If this is set to true, the error is sent to the console, and the program exits + * @param connection If this is set to a non-null value, and bail is false, the errors are spooled to + * this connection as SNOTICEs. + * If the parameter is NULL, the messages are spooled to all connections via WriteOpers as SNOTICEs. + */ + void ReportConfigError(const std::string &, bool); + /** Load 'filename' into 'target', with the new config parser everything is parsed into + * tag/key/value at load-time rather than at read-value time. + */ + bool LoadConf(ConfigDataHash &, const char *, std::ostringstream &); + /** Load 'filename' into 'target', with the new config parser everything is parsed into + * tag/key/value at load-time rather than at read-value time. + */ + bool LoadConf(ConfigDataHash &, const std::string &, std::ostringstream &); + /** Load 'filename' into 'target', with the new config parser everything is parsed into + * tag/key/value at load-time rather than at read-value time. + */ + bool LoadConf(ConfigDataHash &, const ci::string &, std::ostringstream &); + // Both these return true if the value existed or false otherwise + /** Writes 'length' chars into 'result' as a string + */ + bool ConfValue(ConfigDataHash &, const char *, const char *, int, char *, int, bool = false); + /** Writes 'length' chars into 'result' as a string + */ + bool ConfValue(ConfigDataHash &, const char *, const char *, const char *, int, char *, int, bool = false); + /** Writes 'length' chars into 'result' as a string + */ + bool ConfValue(ConfigDataHash &, const ci::string &, const ci::string &, int, ci::string &, bool = false); + /** Writes 'length' chars into 'result' as a string + */ + bool ConfValue(ConfigDataHash &, const ci::string &, const ci::string &, const ci::string &, int, ci::string &, bool = false); + /** Tries to convert the value to an integer and write it to 'result' + */ + bool ConfValueInteger(ConfigDataHash &, const char *, const char *, int, int &); + /** Tries to convert the value to an integer and write it to 'result' + */ + bool ConfValueInteger(ConfigDataHash &, const char *, const char *, const char *, int, int &); + /** Tries to convert the value to an integer and write it to 'result' + */ + bool ConfValueInteger(ConfigDataHash &, const ci::string &, const ci::string &, int, int &); + /** Tries to convert the value to an integer and write it to 'result' + */ + bool ConfValueInteger(ConfigDataHash &, const ci::string &, const ci::string &, const ci::string &, int, int &); + /** Returns true if the value exists and has a true value, false otherwise + */ + bool ConfValueBool(ConfigDataHash &, const char *, const char *, int); + /** Returns true if the value exists and has a true value, false otherwise + */ + bool ConfValueBool(ConfigDataHash &, const char *, const char *, const char *, int); + /** Returns true if the value exists and has a true value, false otherwise + */ + bool ConfValueBool(ConfigDataHash &, const ci::string &, const ci::string &, int); + /** Returns true if the value exists and has a true value, false otherwise + */ + bool ConfValueBool(ConfigDataHash &, const ci::string &, const ci::string &, const ci::string &, int); + /** Returns the number of occurences of tag in the config file + */ + int ConfValueEnum(ConfigDataHash &, const char *); + /** Returns the number of occurences of tag in the config file + */ + int ConfValueEnum(ConfigDataHash &, const std::string &); + /** Returns the number of occurences of tag in the config file + */ + int ConfValueEnum(ConfigDataHash &, const ci::string &); + /** Returns the numbers of vars inside the index'th 'tag in the config file + */ + int ConfVarEnum(ConfigDataHash &, const char *, int); + /** Returns the numbers of vars inside the index'th 'tag in the config file + */ + int ConfVarEnum(ConfigDataHash &, const ci::string &, int); + void ValidateHostname(const char *, const ci::string &, const ci::string &); + void ValidateIP(const char *p, const ci::string &, const ci::string &, bool); + void ValidateNoSpaces(const char *, const ci::string &, const ci::string &); + + /** Below here is a list of variables which contain the config files values + */ + /* IRCd module in use */ + char *IRCDModule; + + /* Host to connect to **/ + char *LocalHost; + /* List of uplink servers to try and connect to */ + std::list Uplinks; + + /* Our server name */ + char *ServerName; + /* Our servers description */ + char *ServerDesc; + /* The username/ident of services clients */ + char *ServiceUser; + /* The hostname if services clients */ + char *ServiceHost; + + /* Help channel, ops here get usermode +h **/ + char *HelpChannel; + /* Log channel */ + char *LogChannel; + /* Name of the network were on */ + char *NetworkName; + /* The max legnth of nicks */ + unsigned NickLen; + /* Max length of idents */ + unsigned UserLen; + /* Max lenght of hostnames */ + unsigned HostLen; + + /* Max length of passwords */ + unsigned PassLen; + + /* NickServ Name */ + char *s_NickServ; + /* ChanServ Name */ + char *s_ChanServ; + /* MemoServ Name */ + char *s_MemoServ; + /* BotServ Name */ + char *s_BotServ; + /* OperServ name */ + char *s_OperServ; + /* Global name */ + char *s_GlobalNoticer; + /* NickServs realname */ + char *desc_NickServ; + /* ChanServ realname */ + char *desc_ChanServ; + /* MemoServ relname */ + char *desc_MemoServ; + /* BotServ realname */ + char *desc_BotServ; + /* OperServ realname */ + char *desc_OperServ; + /* Global realname */ + char *desc_GlobalNoticer; + + /* HostServ Name */ + char *s_HostServ; + /* HostServ realname */ + char *desc_HostServ; + + /* Filename for the PID file */ + char *PIDFilename; + /* MOTD filename */ + char *MOTDFilename; + + /* True if its ok to not be able to save backs */ + bool NoBackupOkay; + /* Do password checking when new people register */ + bool StrictPasswords; + /* How many times you're allowed to give a bad password before being killed */ + unsigned BadPassLimit; + /* How long before bad passwords are forgotten */ + time_t BadPassTimeout; + /* Delay between automatic database updates */ + time_t UpdateTimeout; + /* Delay between checks for expired nicks and channels */ + time_t ExpireTimeout; + /* How long to wait for something from the uplink, this is passed to select() */ + time_t ReadTimeout; + /* How often to send program errors */ + time_t WarningTimeout; + /* How long to process things such as timers to see if there is anything to calll */ + time_t TimeoutCheck; + /* Num of days logfiles are kept */ + int KeepLogs; + /* Number of days backups are kept */ + int KeepBackups; + /* Forbidding requires a reason */ + bool ForceForbidReason; + /* Services should use privmsgs instead of notices */ + bool UsePrivmsg; + /* Services only respond to full PRIVMSG client@services.server.name messages */ + bool UseStrictPrivMsg; + /* Dump a core file if we crash */ + bool DumpCore; + /* Log users connecting/existing/changing nicks */ + bool LogUsers; + /* Number of seconds between consecutive uses of the REGISTER command + * Not to be confused with NSRegDelay */ + unsigned NickRegDelay; + /* Max number if news items allowed in the list */ + unsigned NewsCount; + /* Default mlock modes */ + ci::string MLock; + /* Default botmodes on channels, defaults to ao */ + ci::string BotModes; + /* How many times to try and reconnect to the uplink before giving up */ + unsigned MaxRetries; + /* How long to wait between connection attempts */ + int RetryWait; + + /* Services can use email */ + bool UseMail; + /* Path to the sendmail executable */ + char *SendMailPath; + /* Address to send from */ + char *SendFrom; + /* Only opers can have services send mail */ + bool RestrictMail; + /* Delay between sending mail */ + time_t MailDelay; + /* Don't quote the To: address */ + bool DontQuoteAddresses; + + /* Prefix of guest nicks when a user gets forced off of a nick */ + char *NSGuestNickPrefix; + /* Allow users to set kill immed on */ + bool NSAllowKillImmed; + /* Don't allow nicks to use /ns group to regroup nicks */ + bool NSNoGroupChange; + /* Default flags for newly registered nicks */ + Flags NSDefFlags; + /* Default language used by services */ + unsigned NSDefLanguage; + /* Users must be connected this long before they can register + * Not to be confused with NickRegDelay */ + time_t NSRegDelay; + /* Time before the registering mail will be resent */ + time_t NSResendDelay; + /* How long before nicks expir */ + time_t NSExpire; + /* Time before NickRequests expire */ + time_t NSRExpire; + /* Force email when registering */ + bool NSForceEmail; + /* Max number of nicks in a group */ + int NSMaxAliases; + /* Max number of allowed strings on the access list */ + unsigned NSAccessMax; + /* Enforcer client user name */ + char *NSEnforcerUser; + /* Enforcer client hostname */ + char *NSEnforcerHost; + /* How long before recovered nicks are released */ + time_t NSReleaseTimeout; + /* /nickserv list is oper only */ + bool NSListOpersOnly; + /* Max number of entries that can be returned from the list command */ + unsigned NSListMax; + /* Only allow usermode +a etc on real services admins */ + bool NSSecureAdmins; + /* Services opers must be /operd on the ircd aswell */ + bool NSStrictPrivileges; + /* Use email to verify new users registering */ + bool NSEmailReg; + /* Set the proper channel modes on users when they identify */ + bool NSModeOnID; + /* Add the users hostnask their access list when they register */ + bool NSAddAccessOnReg; + + /* Default flags for newly registered channels */ + Flags CSDefFlags; + /* Max number of channels a user can own */ + unsigned CSMaxReg; + /* Time before a channel expires */ + time_t CSExpire; + /* Default ban type to use for channels */ + int CSDefBantype; + /* Max number of entries allowed on channel access lists */ + unsigned CSAccessMax; + /* Max number of entries allowed on autokick lists */ + unsigned CSAutokickMax; + /* Default autokick reason */ + char *CSAutokickReason; + /* Time ChanServ should stay in the channel to hold it to keep users from getting in */ + time_t CSInhabit; + /* ChanServ's LIST command is oper only */ + bool CSListOpersOnly; + /* Max number of entries allowed to be returned from the LIST command */ + unsigned CSListMax; + /* true to make ChanServ oper only */ + bool CSOpersOnly; + + /* Max number of memos allowed */ + unsigned MSMaxMemos; + /* Time you must wait between sending memos */ + time_t MSSendDelay; + /* Notify all of the aliases of the core the memo was sent to */ + bool MSNotifyAll; + /* Who can use memos reciepts */ + unsigned MSMemoReceipt; + + /* Defai;t BotServ flags */ + Flags BSDefFlags; + /* How long before botserv forgets a user. This is used for flood kickers etc */ + time_t BSKeepData; + /* Min number of users to have in the channel before the service bot joins */ + unsigned BSMinUsers; + /* Max number of words allowed on the badwordslist */ + unsigned BSBadWordsMax; + /* BotServ bot only joins if it would normally allowed to, abides by bans etc */ + bool BSSmartJoin; + /* Dont tell users what badword they used */ + bool BSGentleBWReason; + /* Case sensitive badwords matching */ + bool BSCaseSensitive; + /* Char to use for the fantasy char, eg ! */ + char *BSFantasyCharacter; + + /* Only show /stats o to opers */ + bool HideStatsO; + /* Send out a global when services shut down or restart */ + bool GlobalOnCycle; + /* Don't include the opers name in globals */ + bool AnonymousGlobal; + /* Dont allow users to register nicks with oper names in them */ + bool RestrictOperNicks; + /* Message to send when shutting down */ + char *GlobalOnCycleMessage; + /* Message to send when starting up */ + char *GlobalOnCycleUP; + /* Super admin is allowed */ + bool SuperAdmin; + /* Log things said through ACT/SAY */ + bool LogBot; + /* Log when new user max is reached */ + bool LogMaxUsers; + /* Default expiry time for akills */ + time_t AutokillExpiry; + /* Default expiry time for chan kills */ + time_t ChankillExpiry; + /* Default expiry time for SNLine Expire */ + time_t SNLineExpiry; + /* Default expiry time for SQLines */ + time_t SQLineExpiry; + /* Default expiry time for SZLine */ + time_t SZLineExpiry; + /* Actually akill the user when the akill is added */ + bool AkillOnAdd; + /* Kill users on SNLine */ + bool KillonSNline; + /* Kill users on SQline */ + bool KillonSQline; + /* Send a WALLOPS/GLOBOPS when a user opers */ + bool WallOper; + /* Send a WALLOPS/GLOBOPS when a nonoper tries to use OperServ */ + bool WallBadOS; + /* Send a WALLOPS/GLOBOPS when someone uses the GLOBAL command */ + bool WallOSGlobal; + /* Send a WALLOPS/GLOBOPS when someone uses the MODE command */ + bool WallOSMode; + /* Send a WALLOPS/GLOBOPS when someone uses the CLEARMODES command */ + bool WallOSClearmodes; + /* Send a WALLOPS/GLOBOPS when someone uses the KICK command */ + bool WallOSKick; + /* Send a WALLOPS/GLOBOPS when someone uses the AKILL command */ + bool WallOSAkill; + /* Send a WALLOPS/GLOBOPS when someone uses the SNLINE command */ + bool WallOSSNLine; + /* Send a WALLOPS/GLOBOPS when someone uses the SQLINE command */ + bool WallOSSQLine; + /* Send a WALLOPS/GLOBOPS when someone uses the SZLINE command */ + bool WallOSSZLine; + /* Send a WALLOPS/GLOBOPS when someone uses the NOOP command */ + bool WallOSNoOp; + /* Send a WALLOPS/GLOBOPS when when someone uses the JUPE command */ + bool WallOSJupe; + /* Send a WALLOPS/GLOBOPS when an akill expires */ + bool WallAkillExpire; + /* Send a WALLOPS/GLOBOPS when SNLines expire */ + bool WallSNLineExpire; + /* Send a WALLOPS/GLOBOPS when SQLines expire */ + bool WallSQLineExpire; + /* Send a WALLOPS/GLOBOPS when SZLines expire */ + bool WallSZLineExpire; + /* Send a WALLOPS/GLOBOPS when exceptions expire */ + bool WallExceptionExpire; + /* Send a WALLOPS/GLOBOPS when DROP is used */ + bool WallDrop; + /* Send a WALLOPS/GLOBOPS when FORBID is used */ + bool WallForbid; + /* Send a WALLOPS/GLOBOPS when GETPASS is used */ + bool WallGetpass; + /* Send a WALLOPS/GLOBOPS when SETPASS is used */ + bool WallSetpass; + /* Add the akillers nick to the akill reason */ + bool AddAkiller; + + /* Limit sessions */ + bool LimitSessions; + /* The default session limit */ + unsigned DefSessionLimit; + /* How long before exceptions expire */ + time_t ExceptionExpiry; + /* How many times to kill before adding an KILL */ + int MaxSessionKill; + /* Max limit that can be used for exceptions */ + unsigned MaxSessionLimit; + /* How long session akills should last */ + time_t SessionAutoKillExpiry; + /* Reason to use for session kills */ + char *SessionLimitExceeded; + /* Optional second reason */ + char *SessionLimitDetailsLoc; + /* OperServ requires you to be an operator */ + bool OSOpersOnly; + + /* List of modules to autoload */ + std::list ModulesAutoLoad; + /* Encryption modules */ + std::list EncModuleList; + /* Database modules */ + std::list DBModuleList; + /* HostServ Core Modules */ + std::list HostServCoreModules; + /* MemoServ Core Modules */ + std::list MemoServCoreModules; + /* BotServ Core Modules */ + std::list BotServCoreModules; + /* OperServ Core Modules */ + std::list OperServCoreModules; + /* NickServ Core Modules */ + std::list NickServCoreModules; + /* ChanServ Core Modules */ + std::list ChanServCoreModules; + + /* Default defcon level */ + int DefConLevel; + /* Timeout before defcon is reset */ + time_t DefConTimeOut; + /* Session limiit to use when using defcon */ + int DefConSessionLimit; + /* How long to add akills for defcon */ + time_t DefConAKILL; + /* Chan modes for defcon */ + char *DefConChanModes; + /* Should we global on defcon */ + bool GlobalOnDefcon; + /* Should we send DefconMessage aswell? */ + bool GlobalOnDefconMore; + /* Message to send when defcon is off */ + char *DefConOffMessage; + /* Message to send when defcon is on*/ + char *DefconMessage; + /* Reason to akill clients for defcon */ + char *DefConAkillReason; + + /* User keys to use for generating random hashes for pass codes etc */ + long unsigned int UserKey1; + long unsigned int UserKey2; + long unsigned int UserKey3; + + /* Numeric */ + char *Numeric; + /* Array of ulined servers */ + char **Ulines; + /* Number of ulines */ + int NumUlines; + + /* List of available opertypes */ + std::list MyOperTypes; + /* List of pairs of opers and their opertype from the config */ + std::list > Opers; }; /** This class can be used on its own to represent an exception, or derived to represent a module-specific exception. @@ -765,18 +830,20 @@ class ServerConfig */ class ConfigException : public CoreException { - public: - /** Default constructor, just uses the error mesage 'Config threw an exception'. - */ - ConfigException() : CoreException("Config threw an exception", "Config Parser") {} - /** This constructor can be used to specify an error message before throwing. - */ - ConfigException(const std::string &message) : CoreException(message, "Config Parser") {} - /** This destructor solves world hunger, cancels the world debt, and causes the world to end. - * Actually no, it does nothing. Never mind. - * @throws Nothing! - */ - virtual ~ConfigException() throw() { }; + public: + /** Default constructor, just uses the error mesage 'Config threw an exception'. + */ + ConfigException() : CoreException("Config threw an exception", "Config Parser") {} + /** This constructor can be used to specify an error message before throwing. + */ + ConfigException(const char *message) : CoreException(message, "Config Parser") {} + ConfigException(const std::string &message) : CoreException(message, "Config Parser") {} + ConfigException(const ci::string &message) : CoreException(message, "Config Parser") {} + /** This destructor solves world hunger, cancels the world debt, and causes the world to end. + * Actually no, it does nothing. Never mind. + * @throws Nothing! + */ + virtual ~ConfigException() throw() { } }; #define CONF_NO_ERROR 0x000000 @@ -793,111 +860,111 @@ class ConfigException : public CoreException */ class CoreExport ConfigReader { - protected: - /** The contents of the configuration file - * This protected member should never be accessed by a module (and cannot be accessed unless the - * core is changed). It will contain a pointer to the configuration file data with unneeded data - * (such as comments) stripped from it. - */ - ConfigDataHash *data; - /** Used to store errors - */ - std::ostringstream *errorlog; - /** If we're using our own config data hash or not - */ - bool privatehash; - /** True if an error occured reading the config file - */ - bool readerror; - /** Error code - */ - long error; - public: - /** Default constructor. - * This constructor initialises the ConfigReader class to read services.conf. - */ - ConfigReader(); - /** Overloaded constructor. - * This constructor initialises the ConfigReader class to read a user-specified config file - */ - ConfigReader(const std::string &); - /** Default destructor. - * This method destroys the ConfigReader class. - */ - ~ConfigReader(); - /** Retrieves a value from the config file. - * This method retrieves a value from the config file. Where multiple copies of the tag - * exist in the config file, index indicates which of the values to retrieve. - */ - std::string ReadValue(const std::string &, const std::string &, int, bool = false); - /** Retrieves a value from the config file. - * This method retrieves a value from the config file. Where multiple copies of the tag - * exist in the config file, index indicates which of the values to retrieve. If the - * tag is not found the default value is returned instead. - */ - std::string ReadValue(const std::string &, const std::string &, const std::string &, int, bool = false); - /** Retrieves a boolean value from the config file. - * This method retrieves a boolean value from the config file. Where multiple copies of the tag - * exist in the config file, index indicates which of the values to retrieve. The values "1", "yes" - * and "true" in the config file count as true to ReadFlag, and any other value counts as false. - */ - bool ReadFlag(const std::string &, const std::string &, int); - /** Retrieves a boolean value from the config file. - * This method retrieves a boolean value from the config file. Where multiple copies of the tag - * exist in the config file, index indicates which of the values to retrieve. The values "1", "yes" - * and "true" in the config file count as true to ReadFlag, and any other value counts as false. - * If the tag is not found, the default value is used instead. - */ - bool ReadFlag(const std::string &, const std::string &, const std::string &, int); - /** Retrieves an integer value from the config file. - * This method retrieves an integer value from the config file. Where multiple copies of the tag - * exist in the config file, index indicates which of the values to retrieve. Any invalid integer - * values in the tag will cause the objects error value to be set, and any call to GetError() will - * return CONF_INVALID_NUMBER to be returned. need_positive is set if the number must be non-negative. - * If a negative number is placed into a tag which is specified positive, 0 will be returned and GetError() - * will return CONF_INT_NEGATIVE. Note that need_positive is not suitable to get an unsigned int - you - * should cast the result to achieve that effect. - */ - int ReadInteger(const std::string &, const std::string &, int, bool); - /** Retrieves an integer value from the config file. - * This method retrieves an integer value from the config file. Where multiple copies of the tag - * exist in the config file, index indicates which of the values to retrieve. Any invalid integer - * values in the tag will cause the objects error value to be set, and any call to GetError() will - * return CONF_INVALID_NUMBER to be returned. needs_unsigned is set if the number must be unsigned. - * If a signed number is placed into a tag which is specified unsigned, 0 will be returned and GetError() - * will return CONF_NOT_UNSIGNED. If the tag is not found, the default value is used instead. - */ - int ReadInteger(const std::string &, const std::string &, const std::string &, int, bool); - /** Returns the last error to occur. - * Valid errors can be found by looking in modules.h. Any nonzero value indicates an error condition. - * A call to GetError() resets the error flag back to 0. - */ - long GetError(); - /** Counts the number of times a given tag appears in the config file. - * This method counts the number of times a tag appears in a config file, for use where - * there are several tags of the same kind, e.g. with opers and connect types. It can be - * used with the index value of ConfigReader::ReadValue to loop through all copies of a - * multiple instance tag. - */ - int Enumerate(const std::string &); - /** Returns true if a config file is valid. - * This method is partially implemented and will only return false if the config - * file does not exist or could not be opened. - */ - bool Verify(); - /** Dumps the list of errors in a config file to an output location. If bail is true, - * then the program will abort. If bail is false and user points to a valid user - * record, the error report will be spooled to the given user by means of NOTICE. - * if bool is false AND user is false, the error report will be spooled to all opers - * by means of a NOTICE to all opers. - */ - void DumpErrors(bool); - /** Returns the number of items within a tag. - * For example if the tag was <test tag="blah" data="foo"> then this - * function would return 2. Spaces and newlines both qualify as valid seperators - * between values. - */ - int EnumerateValues(const std::string &, int); + protected: + /** The contents of the configuration file + * This protected member should never be accessed by a module (and cannot be accessed unless the + * core is changed). It will contain a pointer to the configuration file data with unneeded data + * (such as comments) stripped from it. + */ + ConfigDataHash *data; + /** Used to store errors + */ + std::ostringstream *errorlog; + /** If we're using our own config data hash or not + */ + bool privatehash; + /** True if an error occured reading the config file + */ + bool readerror; + /** Error code + */ + long error; + public: + /** Default constructor. + * This constructor initialises the ConfigReader class to read services.conf. + */ + ConfigReader(); + /** Overloaded constructor. + * This constructor initialises the ConfigReader class to read a user-specified config file + */ + ConfigReader(const std::string &); + /** Default destructor. + * This method destroys the ConfigReader class. + */ + ~ConfigReader(); + /** Retrieves a value from the config file. + * This method retrieves a value from the config file. Where multiple copies of the tag + * exist in the config file, index indicates which of the values to retrieve. + */ + std::string ReadValue(const std::string &, const std::string &, int, bool = false); + /** Retrieves a value from the config file. + * This method retrieves a value from the config file. Where multiple copies of the tag + * exist in the config file, index indicates which of the values to retrieve. If the + * tag is not found the default value is retu