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