]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/configreader.h
787bcb243f3b65a3433b6ac851ed3be70a209a51
[user/henk/code/inspircd.git] / include / configreader.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef INSPIRCD_CONFIGREADER
15 #define INSPIRCD_CONFIGREADER
16
17 /* handy defines */
18
19 /** Determines if a channel op is exempt from given mode m,
20  * in config of server instance s.
21  */
22 #define CHANOPS_EXEMPT(s, m) (s->Config->ExemptChanOps[(unsigned char)m])
23
24 #include <sstream>
25 #include <string>
26 #include <vector>
27 #include <map>
28 #include "inspircd.h"
29 #include "modules.h"
30 #include "socketengine.h"
31 #include "socket.h"
32
33 /* Required forward definitions */
34 class ServerConfig;
35 class InspIRCd;
36 class BufferedSocket;
37
38 /** Types of data in the core config
39  */
40 enum ConfigDataType
41 {
42         DT_NOTHING       = 0,           /* No data */
43         DT_INTEGER       = 1,           /* Integer */
44         DT_CHARPTR       = 2,           /* Char pointer */
45         DT_BOOLEAN       = 3,           /* Boolean */
46         DT_HOSTNAME      = 4,           /* Hostname syntax */
47         DT_NOSPACES      = 5,           /* No spaces */
48         DT_IPADDRESS     = 6,           /* IP address (v4, v6) */
49         DT_CHANNEL       = 7,           /* Channel name */
50         DT_ALLOW_WILD    = 64,          /* Allow wildcards/CIDR in DT_IPADDRESS */
51         DT_ALLOW_NEWLINE = 128,         /* New line characters allowed in DT_CHARPTR */
52         DT_BOOTONLY      = 256          /* Can only be set on startup, not on rehash */
53 };
54
55 /** The maximum number of values in a core configuration tag. Can be increased if needed.
56  */
57 #define MAX_VALUES_PER_TAG 18
58
59 /** Holds a config value, either string, integer or boolean.
60  * Callback functions receive one or more of these, either on
61  * their own as a reference, or in a reference to a deque of them.
62  * The callback function can then alter the values of the ValueItem
63  * classes to validate the settings.
64  */
65 class ValueItem
66 {
67         /** Actual data */
68         std::string v;
69  public:
70         /** Initialize with an int */
71         ValueItem(int value);
72         /** Initialize with a bool */
73         ValueItem(bool value);
74         /** Initialize with a char pointer */
75         ValueItem(const char* value);
76         /** Change value to a char pointer */
77         void Set(const char* val);
78         /** Change value to an int */
79         void Set(int value);
80         /** Get value as an int */
81         int GetInteger();
82         /** Get value as a string */
83         char* GetString();
84         /** Get value as a bool */
85         bool GetBool();
86 };
87
88 /** The base class of the container 'ValueContainer'
89  * used internally by the core to hold core values.
90  */
91 class ValueContainerBase
92 {
93  public:
94         /** Constructor */
95         ValueContainerBase() { }
96         /** Destructor */
97         virtual ~ValueContainerBase() { }
98 };
99
100 /** ValueContainer is used to contain pointers to different
101  * core values such as the server name, maximum number of
102  * clients etc.
103  * It is specialized to hold a data type, then pointed at
104  * a value in the ServerConfig class. When the value has been
105  * read and validated, the Set method is called to write the
106  * value safely in a type-safe manner.
107  */
108 template<typename T> class ValueContainer : public ValueContainerBase
109 {
110         /** Contained item */
111         T val;
112  public:
113
114         /** Initialize with nothing */
115         ValueContainer()
116         {
117                 val = NULL;
118         }
119
120         /** Initialize with a value of type T */
121         ValueContainer(T Val)
122         {
123                 val = Val;
124         }
125
126         /** Change value to type T of size s */
127         void Set(T newval, size_t s)
128         {
129                 memcpy(val, newval, s);
130         }
131 };
132
133 /** A specialization of ValueContainer to hold a pointer to a bool
134  */
135 typedef ValueContainer<bool*> ValueContainerBool;
136
137 /** A specialization of ValueContainer to hold a pointer to
138  * an unsigned int
139  */
140 typedef ValueContainer<unsigned int*> ValueContainerUInt;
141
142 /** A specialization of ValueContainer to hold a pointer to
143  * a char array.
144  */
145 typedef ValueContainer<char*> ValueContainerChar;
146
147 /** A specialization of ValueContainer to hold a pointer to
148  * an int
149  */
150 typedef ValueContainer<int*> ValueContainerInt;
151
152 /** A specialization of ValueContainer to hold a pointer to
153  * a size_t.
154  */
155 typedef ValueContainer<size_t*> ValueContainerST;
156
157 /** A set of ValueItems used by multi-value validator functions
158  */
159 typedef std::deque<ValueItem> ValueList;
160
161 /** A callback for validating a single value
162  */
163 typedef bool (*Validator)(ServerConfig* conf, const char*, const char*, ValueItem&);
164 /** A callback for validating multiple value entries
165  */
166 typedef bool (*MultiValidator)(ServerConfig* conf, const char*, char**, ValueList&, int*);
167 /** A callback indicating the end of a group of entries
168  */
169 typedef bool (*MultiNotify)(ServerConfig* conf, const char*);
170
171 /** Holds a core configuration item and its callbacks
172  */
173 struct InitialConfig
174 {
175         /** Tag name */
176         const char* tag;
177         /** Value name */
178         const char* value;
179         /** Default, if not defined */
180         const char* default_value;
181         /** Value containers */
182         ValueContainerBase* val;
183         /** Data types */
184         int datatype;
185         /** Validation function */
186         Validator validation_function;
187 };
188
189 /** Represents a deprecated configuration tag.
190  */
191 struct Deprecated
192 {
193         /** Tag name
194          */
195         const char* tag;
196         /** Tag value
197          */
198         const char* value;
199         /** Reason for deprecation
200          */
201         const char* reason;
202 };
203
204 /** Holds a core configuration item and its callbacks
205  * where there may be more than one item
206  */
207 struct MultiConfig
208 {
209         /** Tag name */
210         const char*     tag;
211         /** One or more items within tag */
212         const char*     items[MAX_VALUES_PER_TAG];
213         /** One or more defaults for items within tags */
214         const char* items_default[MAX_VALUES_PER_TAG];
215         /** One or more data types */
216         int             datatype[MAX_VALUES_PER_TAG];
217         /** Initialization function */
218         MultiNotify     init_function;
219         /** Validation function */
220         MultiValidator  validation_function;
221         /** Completion function */
222         MultiNotify     finish_function;
223 };
224
225 /** A set of oper types
226  */
227 typedef std::map<irc::string,char*> opertype_t;
228
229 /** Holds an oper class.
230  */
231 struct operclass_data : public Extensible
232 {
233         /** Command list for the class
234          */
235         char *commandlist;
236
237         /** Channel mode list for the class
238          */
239         char *cmodelist;
240
241         /** User mode list for the class
242          */
243         char *umodelist;
244
245         /** Priviledges given by this class
246          */
247         char *privs;
248 };
249
250 /** A Set of oper classes
251  */
252 typedef std::map<irc::string, operclass_data> operclass_t;
253
254 /** Defines the server's length limits on various length-limited
255  * items such as topics, nicknames, channel names etc.
256  */
257 class ServerLimits : public Extensible
258 {
259  public:
260         /** Maximum nickname length */
261         size_t NickMax;
262         /** Maximum channel length */
263         size_t ChanMax;
264         /** Maximum number of modes per line */
265         size_t MaxModes;
266         /** Maximum length of ident, not including ~ etc */
267         size_t IdentMax;
268         /** Maximum length of a quit message */
269         size_t MaxQuit;
270         /** Maximum topic length */
271         size_t MaxTopic;
272         /** Maximum kick message length */
273         size_t MaxKick;
274         /** Maximum GECOS (real name) length */
275         size_t MaxGecos;
276         /** Maximum away message length */
277         size_t MaxAway;
278
279         /** Creating the class initialises it to the defaults
280          * as in 1.1's ./configure script. Reading other values
281          * from the config will change these values.
282          */
283         ServerLimits() : NickMax(31), ChanMax(64), MaxModes(20), IdentMax(12), MaxQuit(255), MaxTopic(307), MaxKick(255), MaxGecos(128), MaxAway(200)
284         {
285         }
286
287         /** Finalises the settings by adding one. This allows for them to be used as-is
288          * without a 'value+1' when using the std::string assignment methods etc.
289          */
290         void Finalise()
291         {
292                 NickMax++;
293                 ChanMax++;
294                 IdentMax++;
295                 MaxQuit++;
296                 MaxTopic++;
297                 MaxKick++;
298                 MaxGecos++;
299                 MaxAway++;
300         }
301 };
302
303 /** This class holds the bulk of the runtime configuration for the ircd.
304  * It allows for reading new config values, accessing configuration files,
305  * and storage of the configuration data needed to run the ircd, such as
306  * the servername, connect classes, /ADMIN data, MOTDs and filenames etc.
307  */
308 class CoreExport ServerConfig : public Extensible
309 {
310   private:
311         /** Creator/owner pointer
312          */
313         InspIRCd* ServerInstance;
314
315         /** This variable holds the names of all
316          * files included from the main one. This
317          * is used to make sure that no files are
318          * recursively included.
319          */
320         std::vector<std::string> include_stack;
321
322         /** This private method processes one line of
323          * configutation, appending errors to errorstream
324          * and setting error if an error has occured.
325          */
326         bool ParseLine(ConfigDataHash &target, const std::string &filename, std::string &line, long &linenumber, std::ostringstream &errorstream);
327
328         /** Check that there is only one of each configuration item
329          */
330         bool CheckOnce(const char* tag, ConfigDataHash &newconf);
331
332  public:
333         /** Process an include executable directive
334          */
335         bool DoPipe(ConfigDataHash &target, const std::string &file, std::ostringstream &errorstream);
336
337         /** Process an include file directive
338          */
339         bool DoInclude(ConfigDataHash &target, const std::string &file, std::ostringstream &errorstream);
340
341         /** User that is currently performing a rehash, needed because the
342          * rehash code is now threaded and needs to know who to give errors and feedback to.
343          */
344         std::string RehashUserUID;
345
346         /** Rehash parameter, as above
347          */
348         std::string RehashParameter;
349
350         /** Error stream, contains error output from any failed configuration parsing.
351          */
352         std::ostringstream* errstr;
353
354         /** Holds the new configuration when a rehash occurs so we dont overwrite the existing
355          * working config with a broken one without checking it first and swapping pointers.
356          */
357         ConfigDataHash newconfig;
358
359         /** Set of included files. Do we use this any more?
360          */
361         std::map<std::string, std::istream*> IncludedFiles;
362
363         /** Used to indicate who we announce invites to on a channel */
364         enum InviteAnnounceState { INVITE_ANNOUNCE_NONE, INVITE_ANNOUNCE_ALL, INVITE_ANNOUNCE_OPS, INVITE_ANNOUNCE_DYNAMIC };
365
366         /** Pointer to function that validates dns server addresses (can be changed depending on platform) */
367         Validator DNSServerValidator;
368
369         /** Returns the creator InspIRCd pointer
370          */
371         InspIRCd* GetInstance();
372
373         /** Not used any more as it is named, can probably be removed or renamed.
374          */
375         int DoDownloads();
376
377         /** This holds all the information in the config file,
378          * it's indexed by tag name to a vector of key/values.
379          */
380         ConfigDataHash config_data;
381
382         /** Length limits, see definition of ServerLimits class
383          */
384         ServerLimits Limits;
385
386         /** Clones CIDR range for ipv4 (0-32)
387          * Defaults to 32 (checks clones on all IPs seperately)
388          */
389         int c_ipv4_range;
390
391         /** Clones CIDR range for ipv6 (0-128)
392          * Defaults to 128 (checks on all IPs seperately)
393          */
394         int c_ipv6_range;
395
396         /** Max number of WhoWas entries per user.
397          */
398         int WhoWasGroupSize;
399
400         /** Max number of cumulative user-entries in WhoWas.
401          *  When max reached and added to, push out oldest entry FIFO style.
402          */
403         int WhoWasMaxGroups;
404
405         /** Max seconds a user is kept in WhoWas before being pruned.
406          */
407         int WhoWasMaxKeep;
408
409         /** Both for set(g|u)id.
410          */
411         char SetUser[MAXBUF];
412         char SetGroup[MAXBUF];
413
414         /** Holds the server name of the local server
415          * as defined by the administrator.
416          */
417         char ServerName[MAXBUF];
418
419         /** Notice to give to users when they are Xlined
420          */
421         char MoronBanner[MAXBUF];
422
423         /* Holds the network name the local server
424          * belongs to. This is an arbitary field defined
425          * by the administrator.
426          */
427         char Network[MAXBUF];
428
429         /** Holds the description of the local server
430          * as defined by the administrator.
431          */
432         char ServerDesc[MAXBUF];
433
434         /** Holds the admin's name, for output in
435          * the /ADMIN command.
436          */
437         char AdminName[MAXBUF];
438
439         /** Holds the email address of the admin,
440          * for output in the /ADMIN command.
441          */
442         char AdminEmail[MAXBUF];
443
444         /** Holds the admin's nickname, for output
445          * in the /ADMIN command
446          */
447         char AdminNick[MAXBUF];
448
449         /** The admin-configured /DIE password
450          */
451         char diepass[MAXBUF];
452
453         /** The admin-configured /RESTART password
454          */
455         char restartpass[MAXBUF];
456
457         /** The hash method for *BOTH* the die and restart passwords.
458          */
459         char powerhash[MAXBUF];
460
461         /** The pathname and filename of the message of the
462          * day file, as defined by the administrator.
463          */
464         char motd[MAXBUF];
465
466         /** The pathname and filename of the rules file,
467          * as defined by the administrator.
468          */
469         char rules[MAXBUF];
470
471         /** The quit prefix in use, or an empty string
472          */
473         char PrefixQuit[MAXBUF];
474
475         /** The quit suffix in use, or an empty string
476          */
477         char SuffixQuit[MAXBUF];
478
479         /** The fixed quit message in use, or an empty string
480          */
481         char FixedQuit[MAXBUF];
482
483         /** The part prefix in use, or an empty string
484          */
485         char PrefixPart[MAXBUF];
486
487         /** The part suffix in use, or an empty string
488          */
489         char SuffixPart[MAXBUF];
490
491         /** The fixed part message in use, or an empty string
492          */
493         char FixedPart[MAXBUF];
494
495         /** The last string found within a <die> tag, or
496          * an empty string.
497          */
498         char DieValue[MAXBUF];
499
500         /** The DNS server to use for DNS queries
501          */
502         char DNSServer[MAXBUF];
503
504         /** Pretend disabled commands don't exist.
505          */
506         bool DisabledDontExist;
507
508         /** This variable contains a space-seperated list
509          * of commands which are disabled by the
510          * administrator of the server for non-opers.
511          */
512         char DisabledCommands[MAXBUF];
513
514         /** This variable identifies which usermodes have been diabled.
515          */
516
517         char DisabledUModes[64];
518
519         /** This variable identifies which chanmodes have been disabled.
520          */
521         char DisabledCModes[64];
522
523         /** The full path to the modules directory.
524          * This is either set at compile time, or
525          * overridden in the configuration file via
526          * the <options> tag.
527          */
528         char ModPath[1024];
529
530         /** The full pathname to the executable, as
531          * given in argv[0] when the program starts.
532          */
533         char MyExecutable[1024];
534
535         /** The file handle of the logfile. If this
536          * value is NULL, the log file is not open,
537          * probably due to a permissions error on
538          * startup (this should not happen in normal
539          * operation!).
540          */
541         FILE *log_file;
542
543         /** If this value is true, the owner of the
544          * server specified -nofork on the command
545          * line, causing the daemon to stay in the
546          * foreground.
547          */
548         bool nofork;
549
550         /** If this value if true then all log
551          * messages will be output, regardless of
552          * the level given in the config file.
553          * This is set with the -debug commandline
554          * option.
555          */
556         bool forcedebug;
557
558         /** If this is true then log output will be
559          * written to the logfile. This is the default.
560          * If you put -nolog on the commandline then
561          * the logfile will not be written.
562          * This is meant to be used in conjunction with
563          * -debug for debugging without filling up the
564          * hard disk.
565          */
566         bool writelog;
567
568         /** If set to true, then all opers on this server are
569          * shown with a generic 'is an IRC operator' line rather
570          * than the oper type. Oper types are still used internally.
571          */
572         bool GenericOper;
573
574         /** If this value is true, banned users (+b, not extbans) will not be able to change nick
575          * if banned on any channel, nor to message them.
576          */
577         bool RestrictBannedUsers;
578
579         /** If this value is true, halfops have been
580          * enabled in the configuration file.
581          */
582         bool AllowHalfop;
583
584         /** If this is set to true, then mode lists (e.g
585          * MODE #chan b) are hidden from unprivileged
586          * users.
587          */
588         bool HideModeLists[256];
589
590         /** If this is set to true, then channel operators
591          * are exempt from this channel mode. Used for +Sc etc.
592          */
593         bool ExemptChanOps[256];
594
595         /** The number of seconds the DNS subsystem
596          * will wait before timing out any request.
597          */
598         int dns_timeout;
599
600         /** The size of the read() buffer in the user
601          * handling code, used to read data into a user's
602          * recvQ.
603          */
604         int NetBufferSize;
605
606         /** The value to be used for listen() backlogs
607          * as default.
608          */
609         int MaxConn;
610
611         /** The soft limit value assigned to the irc server.
612          * The IRC server will not allow more than this
613          * number of local users.
614          */
615         unsigned int SoftLimit;
616
617         /** Maximum number of targets for a multi target command
618          * such as PRIVMSG or KICK
619          */
620         unsigned int MaxTargets;
621
622         /** The maximum number of /WHO results allowed
623          * in any single /WHO command.
624          */
625         int MaxWhoResults;
626
627         /** True if the DEBUG loglevel is selected.
628          */
629         int debugging;
630
631         /** How many seconds to wait before exiting
632          * the program when /DIE is correctly issued.
633          */
634         int DieDelay;
635
636         /** True if we're going to hide netsplits as *.net *.split for non-opers
637          */
638         bool HideSplits;
639
640         /** True if we're going to hide ban reasons for non-opers (e.g. G-Lines,
641          * K-Lines, Z-Lines)
642          */
643         bool HideBans;
644
645         /** Announce invites to the channel with a server notice
646          */
647         InviteAnnounceState AnnounceInvites;
648
649         /** If this is enabled then operators will
650          * see invisible (+i) channels in /whois.
651          */
652         bool OperSpyWhois;
653
654         /** Set to a non-empty string to obfuscate the server name of users in WHOIS
655          */
656         char HideWhoisServer[MAXBUF];
657
658         /** Set to a non empty string to obfuscate nicknames prepended to a KILL.
659          */
660         char HideKillsServer[MAXBUF];
661
662         /** The MOTD file, cached in a file_cache type.
663          */
664         file_cache MOTD;
665
666         /** The RULES file, cached in a file_cache type.
667          */
668         file_cache RULES;
669
670         /** The full pathname and filename of the PID
671          * file as defined in the configuration.
672          */
673         char PID[1024];
674
675         /** The connect classes in use by the IRC server.
676          */
677         ClassVector Classes;
678
679         /** A list of the classes for listening ports
680          */
681         std::vector<ListenSocketBase *> ports;
682
683         /** The 005 tokens of this server (ISUPPORT)
684          * populated/repopulated upon loading or unloading
685          * modules.
686          */
687         std::string data005;
688
689         /** isupport strings
690          */
691         std::vector<std::string> isupport;
692
693         /** STATS characters in this list are available
694          * only to operators.
695          */
696         char UserStats[MAXBUF];
697
698         /** The path and filename of the ircd.log file
699          */
700         std::string logpath;
701
702         /** Default channel modes
703          */
704         char DefaultModes[MAXBUF];
705
706         /** Custom version string, which if defined can replace the system info in VERSION.
707          */
708         char CustomVersion[MAXBUF];
709
710         /** List of u-lined servers
711          */
712         std::map<irc::string, bool> ulines;
713
714         /** Max banlist sizes for channels (the std::string is a glob)
715          */
716         std::map<std::string, int> maxbans;
717
718         /** Directory where the inspircd binary resides
719          */
720         std::string MyDir;
721
722         /** If set to true, no user DNS lookups are to be performed
723          */
724         bool NoUserDns;
725
726         /** If set to true, provide syntax hints for unknown commands
727          */
728         bool SyntaxHints;
729
730         /** If set to true, users appear to quit then rejoin when their hosts change.
731          * This keeps clients synchronized properly.
732          */
733         bool CycleHosts;
734
735         /** If set to true, prefixed channel NOTICEs and PRIVMSGs will have the prefix
736          *  added to the outgoing text for undernet style msg prefixing.
737          */
738         bool UndernetMsgPrefix;
739
740         /** If set to true, the full nick!user@host will be shown in the TOPIC command
741          * for who set the topic last. If false, only the nick is shown.
742          */
743         bool FullHostInTopic;
744
745         /** All oper type definitions from the config file
746          */
747         opertype_t opertypes;
748
749         /** All oper class definitions from the config file
750          */
751         operclass_t operclass;
752
753         /** Saved argv from startup
754          */
755         char** argv;
756
757         /** Saved argc from startup
758          */
759         int argc;
760
761         /** Max channels per user
762          */
763         unsigned int MaxChans;
764
765         /** Oper max channels per user
766          */
767         unsigned int OperMaxChans;
768
769         /** TS6-like server ID.
770          * NOTE: 000...999 are usable for InspIRCd servers. This
771          * makes code simpler. 0AA, 1BB etc with letters are reserved
772          * for services use.
773          */
774         char sid[MAXBUF];
775
776         /** True if we have been told to run the testsuite from the commandline,
777          * rather than entering the mainloop.
778          */
779         bool TestSuite;
780
781         /** Construct a new ServerConfig
782          */
783         ServerConfig(InspIRCd* Instance);
784
785         /** Clears the include stack in preperation for a Read() call.
786          */
787         void ClearStack();
788
789         /** Get server ID as string with required leading zeroes
790          */
791         std::string GetSID();
792
793         /** Update the 005 vector
794          */
795         void Update005();
796
797         /** Send the 005 numerics (ISUPPORT) to a user
798          */
799         void Send005(User* user);
800
801         /** Read the entire configuration into memory
802          * and initialize this class. All other methods
803          * should be used only by the core.
804          */
805         void Read(bool bail, const std::string &useruid);
806
807         /** Read a file into a file_cache object
808          */
809         bool ReadFile(file_cache &F, const char* fname);
810
811         /* Returns true if the given string starts with a windows drive letter
812          */
813         bool StartsWithWindowsDriveLetter(const std::string &path);
814
815         /** Report a configuration error given in errormessage.
816          * @param bail If this is set to true, the error is sent to the console, and the program exits
817          * @param useruid If this is set to a non-empty value which is a valid UID, and bail is false,
818          * the errors are spooled to this user as SNOTICEs.
819          * If the parameter is not a valid UID, the messages are spooled to all opers.
820          */
821         void ReportConfigError(const std::string &errormessage, bool bail, const std::string &useruid);
822
823         /** Load 'filename' into 'target', with the new config parser everything is parsed into
824          * tag/key/value at load-time rather than at read-value time.
825          */
826         bool LoadConf(ConfigDataHash &target, FILE* &conf, const char* filename, std::ostringstream &errorstream);
827
828         /** Load 'filename' into 'target', with the new config parser everything is parsed into
829          * tag/key/value at load-time rather than at read-value time.
830          */
831         bool LoadConf(ConfigDataHash &target, FILE* &conf, const std::string &filename, std::ostringstream &errorstream);
832
833         /** Writes 'length' chars into 'result' as a string
834          */
835         bool ConfValue(ConfigDataHash &target, const char* tag, const char* var, int index, char* result, int length, bool allow_linefeeds = false);
836
837         /** Writes 'length' chars into 'result' as a string
838          */
839         bool ConfValue(ConfigDataHash &target, const char* tag, const char* var, const char* default_value, int index, char* result, int length, bool allow_linefeeds = false);
840
841         /** Writes 'length' chars into 'result' as a string
842          */
843         bool ConfValue(ConfigDataHash &target, const std::string &tag, const std::string &var, int index, std::string &result, bool allow_linefeeds = false);
844
845         /** Writes 'length' chars into 'result' as a string
846          */
847         bool ConfValue(ConfigDataHash &target, const std::string &tag, const std::string &var, const std::string &default_value, int index, std::string &result, bool allow_linefeeds = false);
848
849         /** Tries to convert the value to an integer and write it to 'result'
850          */
851         bool ConfValueInteger(ConfigDataHash &target, const char* tag, const char* var, int index, int &result);
852
853         /** Tries to convert the value to an integer and write it to 'result'
854          */
855         bool ConfValueInteger(ConfigDataHash &target, const char* tag, const char* var, const char* default_value, int index, int &result);
856
857         /** Tries to convert the value to an integer and write it to 'result'
858          */
859         bool ConfValueInteger(ConfigDataHash &target, const std::string &tag, const std::string &var, int index, int &result);
860
861         /** Tries to convert the value to an integer and write it to 'result'
862          */
863         bool ConfValueInteger(ConfigDataHash &target, const std::string &tag, const std::string &var, const std::string &default_value, int index, int &result);
864
865         /** Returns true if the value exists and has a true value, false otherwise
866          */
867         bool ConfValueBool(ConfigDataHash &target, const char* tag, const char* var, int index);
868
869         /** Returns true if the value exists and has a true value, false otherwise
870          */
871         bool ConfValueBool(ConfigDataHash &target, const char* tag, const char* var, const char* default_value, int index);
872
873         /** Returns true if the value exists and has a true value, false otherwise
874          */
875         bool ConfValueBool(ConfigDataHash &target, const std::string &tag, const std::string &var, int index);
876
877         /** Returns true if the value exists and has a true value, false otherwise
878          */
879         bool ConfValueBool(ConfigDataHash &target, const std::string &tag, const std::string &var, const std::string &default_value, int index);
880
881         /** Returns the number of occurences of tag in the config file
882          */
883         int ConfValueEnum(ConfigDataHash &target, const char* tag);
884         /** Returns the number of occurences of tag in the config file
885          */
886         int ConfValueEnum(ConfigDataHash &target, const std::string &tag);
887
888         /** Returns the numbers of vars inside the index'th 'tag in the config file
889          */
890         int ConfVarEnum(ConfigDataHash &target, const char* tag, int index);
891         /** Returns the numbers of vars inside the index'th 'tag in the config file
892          */
893         int ConfVarEnum(ConfigDataHash &target, const std::string &tag, int index);
894
895         /** Validates a hostname value, throwing ConfigException if it is not valid
896          */
897         void ValidateHostname(const char* p, const std::string &tag, const std::string &val);
898
899         /** Validates an IP address value, throwing ConfigException if it is not valid
900          */
901         void ValidateIP(const char* p, const std::string &tag, const std::string &val, bool wild);
902
903         /** Validates a value that should not contain spaces, throwing ConfigException of it is not valid
904          */
905         void ValidateNoSpaces(const char* p, const std::string &tag, const std::string &val);
906
907         /** Returns the fully qualified path to the inspircd directory
908          * @return The full program directory
909          */
910         std::string GetFullProgDir();
911
912         /** Returns true if a directory is valid (within the modules directory).
913          * @param dirandfile The directory and filename to check
914          * @return True if the directory is valid
915          */
916         static bool DirValid(const char* dirandfile);
917
918         /** Clean a filename, stripping the directories (and drives) from string.
919          * @param name Directory to tidy
920          * @return The cleaned filename
921          */
922         static char* CleanFilename(char* name);
923
924         /** Check if a file exists.
925          * @param file The full path to a file
926          * @return True if the file exists and is readable.
927          */
928         static bool FileExists(const char* file);
929
930         /** If this value is true, invites will bypass more than just +i
931          */
932         bool InvBypassModes;
933
934 };
935
936 /** Initialize the disabled commands list
937  */
938 CoreExport bool InitializeDisabledCommands(const char* data, InspIRCd* ServerInstance);
939
940 /** Initialize the oper types
941  */
942 bool InitTypes(ServerConfig* conf, const char* tag);
943
944 /** Initialize the oper classes
945  */
946 bool InitClasses(ServerConfig* conf, const char* tag);
947
948 /** Initialize an oper type
949  */
950 bool DoType(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types);
951
952 /** Initialize an oper class
953  */
954 bool DoClass(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types);
955
956 /** Finish initializing the oper types and classes
957  */
958 bool DoneClassesAndTypes(ServerConfig* conf, const char* tag);
959
960
961
962 /** Initialize x line
963  */
964 bool InitXLine(ServerConfig* conf, const char* tag);
965
966 /** Add a config-defined zline
967  */
968 bool DoZLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types);
969
970 /** Add a config-defined qline
971  */
972 bool DoQLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types);
973
974 /** Add a config-defined kline
975  */
976 bool DoKLine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types);
977
978 /** Add a config-defined eline
979  */
980 bool DoELine(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types);
981
982 #endif