]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/configreader.h
All the limits were one less than specified in the config, so now we postincrement...
[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                 MaxModes++;
257                 IdentMax++;
258                 MaxQuit++;
259                 MaxTopic++;
260                 MaxKick++;
261                 MaxGecos++;
262                 MaxAway++;
263         }
264 };
265
266 /** This class holds the bulk of the runtime configuration for the ircd.
267  * It allows for reading new config values, accessing configuration files,
268  * and storage of the configuration data needed to run the ircd, such as
269  * the servername, connect classes, /ADMIN data, MOTDs and filenames etc.
270  */
271 class CoreExport ServerConfig : public Extensible
272 {
273   private:
274         /** Creator/owner pointer
275          */
276         InspIRCd* ServerInstance;
277
278         /** This variable holds the names of all
279          * files included from the main one. This
280          * is used to make sure that no files are
281          * recursively included.
282          */
283         std::vector<std::string> include_stack;
284
285         /** This private method processes one line of
286          * configutation, appending errors to errorstream
287          * and setting error if an error has occured.
288          */
289         bool ParseLine(ConfigDataHash &target, std::string &line, long &linenumber, std::ostringstream &errorstream);
290
291         /** Check that there is only one of each configuration item
292          */
293         bool CheckOnce(const char* tag, ConfigDataHash &newconf);
294
295  public:
296
297         /** Process an include executable directive
298          */
299         bool DoPipe(ConfigDataHash &target, const std::string &file, std::ostringstream &errorstream);
300
301         /** Process an include file directive
302          */
303         bool DoInclude(ConfigDataHash &target, const std::string &file, std::ostringstream &errorstream);
304
305         User* RehashUser;
306
307         std::string RehashParameter;
308
309         std::ostringstream errstr;
310
311         ConfigDataHash newconfig;
312
313         std::map<std::string, std::istream*> IncludedFiles;
314
315         /** Used to indicate who we announce invites to on a channel */
316         enum InviteAnnounceState { INVITE_ANNOUNCE_NONE, INVITE_ANNOUNCE_ALL, INVITE_ANNOUNCE_OPS, INVITE_ANNOUNCE_DYNAMIC };
317
318         /** Pointer to function that validates dns server addresses (can be changed depending on platform) */
319         Validator DNSServerValidator;
320
321         InspIRCd* GetInstance();
322
323         int DoDownloads();
324           
325         /** This holds all the information in the config file,
326          * it's indexed by tag name to a vector of key/values.
327          */
328         ConfigDataHash config_data;
329
330         ServerLimits Limits;
331
332         /** Max number of WhoWas entries per user.
333          */
334         int WhoWasGroupSize;
335
336         /** Max number of cumulative user-entries in WhoWas.
337          *  When max reached and added to, push out oldest entry FIFO style.
338          */
339         int WhoWasMaxGroups;
340
341         /** Max seconds a user is kept in WhoWas before being pruned.
342          */
343         int WhoWasMaxKeep;
344
345         /** Holds the server name of the local server
346          * as defined by the administrator.
347          */
348         char ServerName[MAXBUF];
349
350         /** Notice to give to users when they are Xlined
351          */
352         char MoronBanner[MAXBUF];
353         
354         /* Holds the network name the local server
355          * belongs to. This is an arbitary field defined
356          * by the administrator.
357          */
358         char Network[MAXBUF];
359
360         /** Holds the description of the local server
361          * as defined by the administrator.
362          */
363         char ServerDesc[MAXBUF];
364
365         /** Holds the admin's name, for output in
366          * the /ADMIN command.
367          */
368         char AdminName[MAXBUF];
369
370         /** Holds the email address of the admin,
371          * for output in the /ADMIN command.
372          */
373         char AdminEmail[MAXBUF];
374
375         /** Holds the admin's nickname, for output
376          * in the /ADMIN command
377          */
378         char AdminNick[MAXBUF];
379
380         /** The admin-configured /DIE password
381          */
382         char diepass[MAXBUF];
383
384         /** The admin-configured /RESTART password
385          */
386         char restartpass[MAXBUF];
387
388         /** The hash method for *BOTH* the die and restart passwords.
389          */
390         char powerhash[MAXBUF];
391
392         /** The pathname and filename of the message of the
393          * day file, as defined by the administrator.
394          */
395         char motd[MAXBUF];
396
397         /** The pathname and filename of the rules file,
398          * as defined by the administrator.
399          */
400         char rules[MAXBUF];
401
402         /** The quit prefix in use, or an empty string
403          */
404         char PrefixQuit[MAXBUF];
405
406         /** The quit suffix in use, or an empty string
407          */
408         char SuffixQuit[MAXBUF];
409
410         /** The fixed quit message in use, or an empty string
411          */
412         char FixedQuit[MAXBUF];
413
414         /** The part prefix in use, or an empty string
415          */
416         char PrefixPart[MAXBUF];
417
418         /** The part suffix in use, or an empty string
419          */
420         char SuffixPart[MAXBUF];
421
422         /** The fixed part message in use, or an empty string
423          */
424         char FixedPart[MAXBUF];
425
426         /** The last string found within a <die> tag, or
427          * an empty string.
428          */
429         char DieValue[MAXBUF];
430
431         /** The DNS server to use for DNS queries
432          */
433         char DNSServer[MAXBUF];
434
435         /** This variable contains a space-seperated list
436          * of commands which are disabled by the
437          * administrator of the server for non-opers.
438          */
439         char DisabledCommands[MAXBUF];
440
441         /** The full path to the modules directory.
442          * This is either set at compile time, or
443          * overridden in the configuration file via
444          * the <options> tag.
445          */
446         char ModPath[1024];
447
448         /** The full pathname to the executable, as
449          * given in argv[0] when the program starts.
450          */
451         char MyExecutable[1024];
452
453         /** The file handle of the logfile. If this
454          * value is NULL, the log file is not open,
455          * probably due to a permissions error on
456          * startup (this should not happen in normal
457          * operation!).
458          */
459         FILE *log_file;
460
461         /** If this value is true, the owner of the
462          * server specified -nofork on the command
463          * line, causing the daemon to stay in the
464          * foreground.
465          */
466         bool nofork;
467         
468         /** If this value if true then all log
469          * messages will be output, regardless of
470          * the level given in the config file.
471          * This is set with the -debug commandline
472          * option.
473          */
474         bool forcedebug;
475         
476         /** If this is true then log output will be
477          * written to the logfile. This is the default.
478          * If you put -nolog on the commandline then
479          * the logfile will not be written.
480          * This is meant to be used in conjunction with
481          * -debug for debugging without filling up the
482          * hard disk.
483          */
484         bool writelog;
485
486         /** If this value is true, halfops have been
487          * enabled in the configuration file.
488          */
489         bool AllowHalfop;
490
491         /** If this is set to true, then mode lists (e.g
492          * MODE #chan b) are hidden from unprivileged
493          * users.
494          */
495         bool HideModeLists[256];
496
497         /** If this is set to true, then channel operators
498          * are exempt from this channel mode. Used for +Sc etc.
499          */
500         bool ExemptChanOps[256];
501
502         /** The number of seconds the DNS subsystem
503          * will wait before timing out any request.
504          */
505         int dns_timeout;
506
507         /** The size of the read() buffer in the user
508          * handling code, used to read data into a user's
509          * recvQ.
510          */
511         int NetBufferSize;
512
513         /** The value to be used for listen() backlogs
514          * as default.
515          */
516         int MaxConn;
517
518         /** The soft limit value assigned to the irc server.
519          * The IRC server will not allow more than this
520          * number of local users.
521          */
522         unsigned int SoftLimit;
523
524         /** Maximum number of targets for a multi target command
525          * such as PRIVMSG or KICK
526          */
527         unsigned int MaxTargets;
528
529         /** The maximum number of /WHO results allowed
530          * in any single /WHO command.
531          */
532         int MaxWhoResults;
533
534         /** True if the DEBUG loglevel is selected.
535          */
536         int debugging;
537
538         /** How many seconds to wait before exiting
539          * the program when /DIE is correctly issued.
540          */
541         int DieDelay;
542
543         /** True if we're going to hide netsplits as *.net *.split for non-opers
544          */
545         bool HideSplits;
546
547         /** True if we're going to hide ban reasons for non-opers (e.g. G-Lines,
548          * K-Lines, Z-Lines)
549          */
550         bool HideBans;
551
552         /** Announce invites to the channel with a server notice
553          */
554         InviteAnnounceState AnnounceInvites;
555
556         /** If this is enabled then operators will
557          * see invisible (+i) channels in /whois.
558          */
559         bool OperSpyWhois;
560
561         /** Set to a non-empty string to obfuscate the server name of users in WHOIS
562          */
563         char HideWhoisServer[MAXBUF];
564
565         /** Set to a non empty string to obfuscate nicknames prepended to a KILL.
566          */
567         char HideKillsServer[MAXBUF];
568
569         /** The MOTD file, cached in a file_cache type.
570          */
571         file_cache MOTD;
572
573         /** The RULES file, cached in a file_cache type.
574          */
575         file_cache RULES;
576
577         /** The full pathname and filename of the PID
578          * file as defined in the configuration.
579          */
580         char PID[1024];
581
582         /** The connect classes in use by the IRC server.
583          */
584         ClassVector Classes;
585
586         /** A list of the classes for listening client ports
587          */
588         std::vector<ListenSocket*> ports;
589
590         /** socket objects that are attached to by modules
591          */
592         std::map<BufferedSocket*, Module*> SocketIOHookModule;
593
594         /** The 005 tokens of this server (ISUPPORT)
595          * populated/repopulated upon loading or unloading
596          * modules.
597          */
598         std::string data005;
599
600         /** isupport strings
601          */
602         std::vector<std::string> isupport;
603
604         /** STATS characters in this list are available
605          * only to operators.
606          */
607         char UserStats[MAXBUF];
608         
609         /** The path and filename of the ircd.log file
610          */
611         std::string logpath;
612
613         /** Default channel modes
614          */
615         char DefaultModes[MAXBUF];
616
617         /** Custom version string, which if defined can replace the system info in VERSION.
618          */
619         char CustomVersion[MAXBUF];
620
621         /** List of u-lined servers
622          */
623         std::map<irc::string, bool> ulines;
624
625         /** Max banlist sizes for channels (the std::string is a glob)
626          */
627         std::map<std::string, int> maxbans;
628
629         /** Directory where the inspircd binary resides
630          */
631         std::string MyDir;
632
633         /** If set to true, no user DNS lookups are to be performed
634          */
635         bool NoUserDns;
636
637         /** If set to true, provide syntax hints for unknown commands
638          */
639         bool SyntaxHints;
640
641         /** If set to true, users appear to quit then rejoin when their hosts change.
642          * This keeps clients synchronized properly.
643          */
644         bool CycleHosts;
645
646         /** If set to true, prefixed channel NOTICEs and PRIVMSGs will have the prefix
647          *  added to the outgoing text for undernet style msg prefixing.
648          */
649         bool UndernetMsgPrefix;
650
651         /** If set to true, the full nick!user@host will be shown in the TOPIC command
652          * for who set the topic last. If false, only the nick is shown.
653          */
654         bool FullHostInTopic;
655
656         /** All oper type definitions from the config file
657          */
658         opertype_t opertypes;
659
660         /** All oper class definitions from the config file
661          */
662         operclass_t operclass;
663
664         /** Saved argv from startup
665          */
666         char** argv;
667
668         /** Saved argc from startup
669          */
670         int argc;
671
672         /** Max channels per user
673          */
674         unsigned int MaxChans;
675
676         /** Oper max channels per user
677          */
678         unsigned int OperMaxChans;
679
680         /** TS6-like server ID.
681          * NOTE: 000...999 are usable for InspIRCd servers. This
682          * makes code simpler. 0AA, 1BB etc with letters are reserved
683          * for services use.
684          */
685         char sid[MAXBUF];
686
687         /** True if we have been told to run the testsuite from the commandline,
688          * rather than entering the mainloop.
689          */
690         bool TestSuite;
691
692         /** Construct a new ServerConfig
693          */
694         ServerConfig(InspIRCd* Instance);
695
696         /** Clears the include stack in preperation for a Read() call.
697          */
698         void ClearStack();
699
700         /** Get server ID as string with required leading zeroes
701          */
702         std::string GetSID();
703
704         /** Update the 005 vector
705          */
706         void Update005();
707
708         /** Send the 005 numerics (ISUPPORT) to a user
709          */
710         void Send005(User* user);
711
712         /** Read the entire configuration into memory
713          * and initialize this class. All other methods
714          * should be used only by the core.
715          */
716         void Read(bool bail, User* user);
717
718         /** Read a file into a file_cache object
719          */
720         bool ReadFile(file_cache &F, const char* fname);
721
722         /* Returns true if the given string starts with a windows drive letter
723          */
724         bool StartsWithWindowsDriveLetter(const std::string &path);
725
726         /** Report a configuration error given in errormessage.
727          * @param bail If this is set to true, the error is sent to the console, and the program exits
728          * @param user If this is set to a non-null value, and bail is false, the errors are spooled to
729          * this user as SNOTICEs.
730          * If the parameter is NULL, the messages are spooled to all opers.
731          */
732         void ReportConfigError(const std::string &errormessage, bool bail, User* user);
733
734         /** Load 'filename' into 'target', with the new config parser everything is parsed into
735          * tag/key/value at load-time rather than at read-value time.
736          */
737         bool LoadConf(ConfigDataHash &target, FILE* &conf, const char* filename, std::ostringstream &errorstream);
738
739         /** Load 'filename' into 'target', with the new config parser everything is parsed into
740          * tag/key/value at load-time rather than at read-value time.
741          */
742         bool LoadConf(ConfigDataHash &target, FILE* &conf, const std::string &filename, std::ostringstream &errorstream);
743         
744         /* Both these return true if the value existed or false otherwise */
745         
746         /** Writes 'length' chars into 'result' as a string
747          */
748         bool ConfValue(ConfigDataHash &target, const char* tag, const char* var, int index, char* result, int length, bool allow_linefeeds = false);
749         /** Writes 'length' chars into 'result' as a string
750          */
751         bool ConfValue(ConfigDataHash &target, const char* tag, const char* var, const char* default_value, int index, char* result, int length, bool allow_linefeeds = false);
752
753         /** Writes 'length' chars into 'result' as a string
754          */
755         bool ConfValue(ConfigDataHash &target, const std::string &tag, const std::string &var, int index, std::string &result, bool allow_linefeeds = false);
756         /** Writes 'length' chars into 'result' as a string
757          */
758         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);
759         
760         /** Tries to convert the value to an integer and write it to 'result'
761          */
762         bool ConfValueInteger(ConfigDataHash &target, const char* tag, const char* var, int index, int &result);
763         /** Tries to convert the value to an integer and write it to 'result'
764          */
765         bool ConfValueInteger(ConfigDataHash &target, const char* tag, const char* var, const char* default_value, int index, int &result);
766         /** Tries to convert the value to an integer and write it to 'result'
767          */
768         bool ConfValueInteger(ConfigDataHash &target, const std::string &tag, const std::string &var, int index, int &result);
769         /** Tries to convert the value to an integer and write it to 'result'
770          */
771         bool ConfValueInteger(ConfigDataHash &target, const std::string &tag, const std::string &var, const std::string &default_value, int index, int &result);
772         
773         /** Returns true if the value exists and has a true value, false otherwise
774          */
775         bool ConfValueBool(ConfigDataHash &target, const char* tag, const char* var, int index);
776         /** Returns true if the value exists and has a true value, false otherwise
777          */
778         bool ConfValueBool(ConfigDataHash &target, const char* tag, const char* var, const char* default_value, int index);
779         /** Returns true if the value exists and has a true value, false otherwise
780          */
781         bool ConfValueBool(ConfigDataHash &target, const std::string &tag, const std::string &var, int index);
782         /** Returns true if the value exists and has a true value, false otherwise
783          */
784         bool ConfValueBool(ConfigDataHash &target, const std::string &tag, const std::string &var, const std::string &default_value, int index);
785         
786         /** Returns the number of occurences of tag in the config file
787          */
788         int ConfValueEnum(ConfigDataHash &target, const char* tag);
789         /** Returns the number of occurences of tag in the config file
790          */
791         int ConfValueEnum(ConfigDataHash &target, const std::string &tag);
792         
793         /** Returns the numbers of vars inside the index'th 'tag in the config file
794          */
795         int ConfVarEnum(ConfigDataHash &target, const char* tag, int index);
796         /** Returns the numbers of vars inside the index'th 'tag in the config file
797          */
798         int ConfVarEnum(ConfigDataHash &target, const std::string &tag, int index);
799
800         void ValidateHostname(const char* p, const std::string &tag, const std::string &val);
801
802         void ValidateIP(const char* p, const std::string &tag, const std::string &val, bool wild);
803
804         void ValidateNoSpaces(const char* p, const std::string &tag, const std::string &val);
805
806         /** Get a pointer to the module which has hooked the given BufferedSocket class.
807          * @parameter port Port number
808          * @return Returns a pointer to the hooking module, or NULL
809          */
810         Module* GetIOHook(BufferedSocket* is);
811
812         /** Hook a module to an BufferedSocket class, so that it can receive notifications
813          * of low-level socket activity.
814          * @param iomod The module to hook to the socket
815          * @param is The BufferedSocket to attach to
816          * @return True if the hook was successful.
817          */
818         bool AddIOHook(Module* iomod, BufferedSocket* is);
819
820         /** Delete a module hook from an BufferedSocket.
821          * @param is The BufferedSocket to detatch from.
822          * @return True if the unhook was successful
823          */
824         bool DelIOHook(BufferedSocket* is);
825
826         /** Returns the fully qualified path to the inspircd directory
827          * @return The full program directory
828          */
829         std::string GetFullProgDir();
830
831         /** Returns true if a directory is valid (within the modules directory).
832          * @param dirandfile The directory and filename to check
833          * @return True if the directory is valid
834          */
835         static bool DirValid(const char* dirandfile);
836
837         /** Clean a filename, stripping the directories (and drives) from string.
838          * @param name Directory to tidy
839          * @return The cleaned filename
840          */
841         static char* CleanFilename(char* name);
842
843         /** Check if a file exists.
844          * @param file The full path to a file
845          * @return True if the file exists and is readable.
846          */
847         static bool FileExists(const char* file);
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