diff options
| author | Adam <Adam@anope.org> | 2010-06-19 11:54:08 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2010-06-19 11:54:08 -0400 |
| commit | 52058fe87b4b0475b1775198c725af14e540d355 (patch) | |
| tree | c3597d6411a006ffbb670d2ce761101b9640e9b6 /include | |
| parent | 43e951aed54f838ba55a4c1552214773aee2fb2f (diff) | |
| parent | df9d291bcba9788e51d11424ebaf6f05c26cc80f (diff) | |
Merge remote branch 'origin/1.9.3' into 1.9
Diffstat (limited to 'include')
| -rw-r--r-- | include/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | include/Makefile | 10 | ||||
| -rw-r--r-- | include/account.h | 21 | ||||
| -rw-r--r-- | include/bots.h | 27 | ||||
| -rw-r--r-- | include/channels.h | 8 | ||||
| -rw-r--r-- | include/commands.h | 109 | ||||
| -rw-r--r-- | include/config.h | 920 | ||||
| -rw-r--r-- | include/configreader.h | 903 | ||||
| -rw-r--r-- | include/defs.h | 39 | ||||
| -rw-r--r-- | include/extern.h | 191 | ||||
| -rw-r--r-- | include/hashcomp.h | 59 | ||||
| -rw-r--r-- | include/mail.h | 24 | ||||
| -rw-r--r-- | include/messages.h | 22 | ||||
| -rw-r--r-- | include/modes.h | 87 | ||||
| -rw-r--r-- | include/modules.h | 422 | ||||
| -rw-r--r-- | include/operserv.h | 231 | ||||
| -rw-r--r-- | include/opertype.h | 9 | ||||
| -rw-r--r-- | include/pseudo.h | 17 | ||||
| -rw-r--r-- | include/regchannel.h | 33 | ||||
| -rw-r--r-- | include/servers.h | 179 | ||||
| -rw-r--r-- | include/services.h | 264 | ||||
| -rw-r--r-- | include/slist.h | 49 | ||||
| -rw-r--r-- | include/sockets.h | 2 | ||||
| -rw-r--r-- | include/threadengine.h | 117 | ||||
| -rw-r--r-- | include/users.h | 25 | ||||
| -rw-r--r-- | include/version.sh | 10 | ||||
| -rw-r--r-- | include/version.sh.c | 2 |
27 files changed, 2005 insertions, 1779 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 19bbcfc6c..de44e4f28 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -8,7 +8,7 @@ if(MSVC OR NOT SH) # Generate version.h from the above executable and the version.log file from the main source directory, with dependencies to the given headers and all source files in the main Anope build add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.h COMMAND version_sh ${Anope_SOURCE_DIR}/version.log ${CMAKE_CURRENT_SOURCE_DIR}/version.sh ${CMAKE_CURRENT_BINARY_DIR}/version.h - MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/version.sh DEPENDS version_sh ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.h ${CMAKE_CURRENT_SOURCE_DIR}/messages.h ${SRC_SRCS} + MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/version.sh DEPENDS version_sh ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${SRC_SRCS} ) # Add version_sh to list of files for CPack to ignore get_target_property(version_sh_BINARY version_sh LOCATION) @@ -19,7 +19,7 @@ else(MSVC OR NOT SH) # Generate version.h from version.sh and the version.log file from the main source directory, with dependencies to the given headers and all source files in the main Anope build add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.h COMMAND ${SH} ${CMAKE_CURRENT_SOURCE_DIR}/version.sh ${Anope_SOURCE_DIR}/version.log ${CMAKE_CURRENT_BINARY_DIR}/version.h - MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/version.sh DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.h ${CMAKE_CURRENT_SOURCE_DIR}/messages.h ${SRC_SRCS} + MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/version.sh DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${SRC_SRCS} ) endif(MSVC OR NOT SH) diff --git a/include/Makefile b/include/Makefile index 3d8067aa6..de32199d3 100644 --- a/include/Makefile +++ b/include/Makefile @@ -1,18 +1,12 @@ -all: services.h extern.h pseudo.h version.h +all: services.h extern.h version.h -version.h: Makefile version.sh services.h pseudo.h messages.h $(SRCS) +version.h: Makefile version.sh services.h $(SRCS) sh version.sh ../version.log $@ services.h: sysconf.h config.h extern.h touch $@ -extern.h: slist.h - touch $@ - -pseudo.h: commands.h timers.h slist.h - touch $@ - clean: (rm -f language.h) diff --git a/include/account.h b/include/account.h index 004760699..e44880c29 100644 --- a/include/account.h +++ b/include/account.h @@ -1,3 +1,14 @@ +class NickAlias; +class NickCore; +class NickRequest; + +typedef unordered_map_namespace::unordered_map<ci::string, NickAlias *, hash_compare_ci_string> nickalias_map; +typedef unordered_map_namespace::unordered_map<ci::string, NickCore *, hash_compare_ci_string> nickcore_map; +typedef unordered_map_namespace::unordered_map<ci::string, NickRequest *, hash_compare_ci_string> nickrequest_map; + +extern CoreExport nickalias_map NickAliasList; +extern CoreExport nickcore_map NickCoreList; +extern CoreExport nickrequest_map NickRequestList; /* NickServ nickname structures. */ @@ -69,16 +80,13 @@ enum NickCoreFlag NI_END }; -/** XXX: this really needs to die with fire and be merged with metadata into NickCore or something. - */ -class CoreExport NickRequest +class CoreExport NickRequest : public Extensible { public: NickRequest(const std::string &nickname); ~NickRequest(); - NickRequest *next, *prev; char *nick; std::string passcode; std::string password; @@ -102,7 +110,6 @@ class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag> */ ~NickAlias(); - NickAlias *next, *prev; char *nick; /* Nickname */ char *last_quit; /* Last quit message */ char *last_realname; /* Last realname */ @@ -137,8 +144,6 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag> */ ~NickCore(); - NickCore *next, *prev; - std::list<User *> Users; char *display; /* How the nick is displayed */ @@ -156,7 +161,7 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag> /* Unsaved data */ time_t lastmail; /* Last time this nick record got a mail */ - SList aliases; /* List of aliases */ + std::list<NickAlias *> 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. diff --git a/include/bots.h b/include/bots.h index 3b4987bb7..8952005e7 100644 --- a/include/bots.h +++ b/include/bots.h @@ -8,6 +8,15 @@ * */ +#include "commands.h" + +class BotInfo; + +typedef unordered_map_namespace::unordered_map<ci::string, BotInfo *, hash_compare_ci_string> botinfo_map; +typedef unordered_map_namespace::unordered_map<std::string, BotInfo *, hash_compare_std_string> botinfo_uid_map; +extern CoreExport botinfo_map BotListByNick; +extern CoreExport botinfo_uid_map BotListByUID; + /** Flags settable on a bot */ enum BotFlag @@ -16,29 +25,13 @@ enum BotFlag /* This bot can only be assigned by IRCops */ BI_PRIVATE, - /* The following flags are used to determin what bot really is what. - * Since you *could* have ChanServ really named BotServ or something stupid, - * this keeps track of them and allows them to be renamed in the config - * at any time, even if they already exist in the database - */ - BI_CHANSERV, - BI_BOTSERV, - BI_HOSTSERV, - BI_OPERSERV, - BI_MEMOSERV, - BI_NICKSERV, - BI_GLOBAL, BI_END }; -struct CommandHash; - class CoreExport BotInfo : public Extensible, public Flags<BotFlag> { public: - BotInfo *next, *prev; - 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 */ @@ -48,7 +41,7 @@ class CoreExport BotInfo : public Extensible, public Flags<BotFlag> int16 chancount; /* Number of channels that use the bot. */ /* Dynamic data */ time_t lastmsg; /* Last time we said something */ - CommandHash **cmdTable; + CommandMap Commands; /** Create a new bot. * @param nick The nickname to assign to the bot. diff --git a/include/channels.h b/include/channels.h index 51b830c03..7814a377a 100644 --- a/include/channels.h +++ b/include/channels.h @@ -8,6 +8,9 @@ * */ +typedef unordered_map_namespace::unordered_map<ci::string, Channel *, hash_compare_ci_string> channel_map; +extern CoreExport channel_map ChannelList; + struct UserData { UserData() @@ -59,7 +62,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags> std::map<ChannelModeName, std::string> Params; /* Modes set on the channel */ - std::bitset<128> modes; + Flags<ChannelModeName> modes; public: /** Default constructor @@ -72,7 +75,6 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags> */ ~Channel(); - Channel *next, *prev; std::string name; /* Channel name */ ChannelInfo *ci; /* Corresponding ChannelInfo */ time_t creation_time; /* When channel was created */ @@ -134,7 +136,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags> /** See if the channel has any modes at all * @return true or false */ - inline const bool HasModes() const { return modes.count(); } + inline const bool HasModes() const { return modes.FlagCount(); } /** See if a channel has a mode * @param Name The mode name diff --git a/include/commands.h b/include/commands.h index d139fa01a..327d65736 100644 --- a/include/commands.h +++ b/include/commands.h @@ -11,17 +11,108 @@ * */ - #include "modules.h" +#ifndef COMMAND_H_ +#define COMMAND_H_ -/*************************************************************************/ +#include "services.h" -/* Routines for looking up commands. Command lists are arrays that must be - * terminated with a NULL name. +class Module; +class BotInfo; +class Command; + +typedef std::map<ci::string, Command *> CommandMap; + +/** The return value from commands. + */ +enum CommandReturn +{ + MOD_CONT, + MOD_STOP +}; + +extern CoreExport Command *FindCommand(BotInfo *bi, const ci::string &cmd); +extern CoreExport void mod_help_cmd(BotInfo *bi, User *u, const ci::string &cmd); +extern CoreExport void mod_run_cmd(BotInfo *bi, User *u, const std::string &message); +extern CoreExport void mod_run_cmd(BotInfo *bi, User *u, Command *c, const ci::string &command, const ci::string &message); + +enum CommandFlag +{ + CFLAG_ALLOW_UNREGISTERED, + CFLAG_ALLOW_FORBIDDEN, + CFLAG_ALLOW_SUSPENDED, + CFLAG_ALLOW_UNREGISTEREDCHANNEL, + CFLAG_STRIP_CHANNEL, + CFLAG_DISABLE_FANTASY +}; + +/** Every services command is a class, inheriting from Command. */ +class CoreExport Command : public Flags<CommandFlag> +{ + public: + /* Maximum paramaters accepted by this command */ + size_t MaxParams; + /* Minimum parameters required to use this command */ + size_t MinParams; + /* Command name */ + ci::string name; + /* Permission needed to use this comand */ + std::string permission; + + /* Module which owns us */ + Module *module; + /* Service this command is on */ + BotInfo *service; + + /** Create a new command. + * @param sname The command name + * @param min_params The minimum number of parameters the parser will require to execute this command + * @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 = ""); + + virtual ~Command(); + + /** Execute this command. + * @param u The user executing the command. + */ + virtual CommandReturn Execute(User *u, const std::vector<ci::string> &); + + /** Called when HELP is requsted for the client this command is on. + * @param u The user requesting help + */ + virtual void OnServHelp(User *u); + + /** 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") + * @return true if help was provided to the user, false otherwise. + */ + virtual bool OnHelp(User *u, const ci::string &subcommand); + + /** Requested when the user provides bad syntax to this command (not enough params, etc). + * @param u The user executing the command. + * @param subcommand The subcommand the user tried to use + */ + virtual void OnSyntaxError(User *u, const ci::string &subcommand); + + /** 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); + + /** Add a subcommand to this command + * @param c The command + */ + virtual bool AddSubcommand(Command *c); + + /** Delete a subcommand from this command + * @param cname The subcommand name + */ + virtual bool DelSubcommand(const ci::string &cname); +}; -extern MDE Command *lookup_cmd(Command *list, char *name); -extern MDE void mod_help_cmd(char *service, User *u, CommandHash *cmdTable[], const char *cmd); -extern MDE void mod_run_cmd(const std::string &service, User *u, CommandHash *cmdTable[], const char *cmd); -//extern MDE void do_help_limited(char *service, User * u, Command * c); +#endif -/*************************************************************************/ diff --git a/include/config.h b/include/config.h index 825cc9af4..dacf3db06 100644 --- a/include/config.h +++ b/include/config.h @@ -1,39 +1,903 @@ -/* Services configuration. - * - * (C) 2003-2010 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for furhter details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * - * +#ifndef _CONFIGREADER_H_ +#define _CONFIGREADER_H_ + +#include <string> +#include <fstream> +#include <sstream> +#include <vector> +#include <map> +#include <deque> + +/** A configuration key and value pair + */ +typedef std::pair<std::string, std::string> KeyVal; + +/** A list of related configuration keys and values + */ +typedef std::vector<KeyVal> KeyValList; + +/** An entire config file, built up of KeyValLists + */ +typedef std::multimap<std::string, KeyValList> ConfigDataHash; + +// Required forward definitions +class ServerConfig; + +/** Types of data in the core config + */ +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_BOOLEAN, // Boolean + DT_HOSTNAME, // Hostname syntax + DT_NOSPACES, // No spaces + DT_IPADDRESS, // IP address (v4, v6) + DT_TIME, // Time value + DT_NORELOAD = 32, // Item can't be reloaded after startup + DT_ALLOW_WILD = 64, // Allow wildcards/CIDR in DT_IPADDRESS + DT_ALLOW_NEWLINE = 128 // New line characters allowed in DT_CHARPTR +}; + +/** Holds a config value, either string, integer or boolean. + * Callback functions receive one or more of these, either on + * their own as a reference, or in a reference to a deque of them. + * The callback function can then alter the values of the ValueItem + * classes to validate the settings. + */ +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(); +}; + +/** The base class of the container 'ValueContainer' + * used internally by the core to hold core values. + */ +class ValueContainerBase +{ + public: + /** Constructor */ + ValueContainerBase() { } + /** Destructor */ + virtual ~ValueContainerBase() { } +}; + +/** ValueContainer is used to contain pointers to different + * core values such as the server name, maximum number of + * clients etc. + * It is specialized to hold a data type, then pointed at + * a value in the ServerConfig class. When the value has been + * read and validated, the Set method is called to write the + * value safely in a type-safe manner. + */ +template<typename T> 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); + } +}; + +/** This a specific version of ValueContainer to handle character arrays specially + */ +template<> class ValueContainer<char **> : 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) + { + 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); + } +}; + +/** This a specific version of ValueContainer to handle std::string specially + */ +template<> class ValueContainer<std::string *> : 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; + } +}; + +/** A specialization of ValueContainer to hold a pointer to a bool + */ +typedef ValueContainer<bool *> ValueContainerBool; + +/** A specialization of ValueContainer to hold a pointer to + * an unsigned int + */ +typedef ValueContainer<unsigned *> ValueContainerUInt; + +/** A specialization of ValueContainer to hold a pointer to + * a long unsigned int + */ +typedef ValueContainer<long unsigned *> ValueContainerLUInt; + +/** A specialization of ValueContainer to hold a pointer to + * a char array. + */ +typedef ValueContainer<char **> ValueContainerChar; + +/** A specialization of ValueContainer to hold a pointer to + * an int + */ +typedef ValueContainer<int *> ValueContainerInt; + +/** A specialization of ValueContainer to hold a pointer to + * a time_t + */ +typedef ValueContainer<time_t *> ValueContainerTime; + +/** A specialization of ValueContainer to hold a pointer to + * an std::string + */ +typedef ValueContainer<std::string *> ValueContainerString; + +/** A set of ValueItems used by multi-value validator functions + */ +typedef std::deque<ValueItem> ValueList; + +/** A callback for validating a single value + */ +typedef bool (*Validator)(ServerConfig *, const char *, const char *, ValueItem &); +/** A callback for validating multiple value entries + */ +typedef bool (*MultiValidator)(ServerConfig *, const char *, const char **, ValueList &, int *, bool); +/** A callback indicating the end of a group of entries + */ +typedef bool (*MultiNotify)(ServerConfig *, const char *, bool); + +/** Holds a core configuration item and its callbacks + */ +struct InitialConfig +{ + /** Tag name */ + const char *tag; + /** Value name */ + const char *value; + /** Default, if not defined */ + const char *default_value; + /** Value containers */ + ValueContainerBase *val; + /** Data types */ + int datatype; + /** Validation function */ + Validator validation_function; +}; + +/** Holds a core configuration item and its callbacks + * where there may be more than one item + */ +struct MultiConfig +{ + /** Tag name */ + const char *tag; + /** One or more items within tag */ + const char *items[17]; + /** One or more defaults for items within tags */ + const char *items_default[17]; + /** One or more data types */ + int datatype[17]; + /** Initialization function */ + MultiNotify init_function; + /** Validation function */ + MultiValidator validation_function; + /** Completion function */ + MultiNotify finish_function; +}; + +/** This class holds the bulk of the runtime configuration for the ircd. + * It allows for reading new config values, accessing configuration files, + * and storage of the configuration data needed to run the ircd, such as + * the servername, connect classes, /ADMIN data, MOTDs and filenames etc. */ +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<std::string> 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; -#ifndef CONFIG_H -#define CONFIG_H + /* Host to connect to **/ + char *LocalHost; + /* List of uplink servers to try and connect to */ + std::list<Uplink *> Uplinks; -/* Note that most of the options which used to be here have been moved to - * services.conf. */ + /* 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; -/******* General configuration *******/ + /* Max length of passwords */ + unsigned PassLen; -/* Name of log file (in Services directory) */ -#define LOG_FILENAME "services.log" + /* 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; -/******************* END OF USER-CONFIGURABLE SECTION ********************/ + /* HostServ Name */ + char *s_HostServ; + /* HostServ realname */ + char *desc_HostServ; -/* Size of input buffer (note: this is different from BUFSIZ) - * This must be big enough to hold at least one full IRC message, or messy - * things will happen. */ -#define BUFSIZE 1024 + /* Filename for the PID file */ + char *PIDFilename; + /* MOTD filename */ + char *MOTDFilename; -/* Maximum amount of data from/to the network to buffer (bytes). */ -#define NET_BUFSIZE 65536 + /* 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 a |
