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