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