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