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