/* +------------------------------------+
* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
* InspIRCd: (C) 2002-2007 InspIRCd Development Team
* See: http://www.inspircd.org/wiki/index.php/Credits
*
* This program is free but copyrighted software; see
* the file COPYING for details.
*
* ---------------------------------------------------
*/#ifndef INSPIRCD_CONFIGREADER#define INSPIRCD_CONFIGREADER/* handy defines *//** Determines if a channel op is exempt from given mode m,
* in config of server instance s.
*/#define CHANOPS_EXEMPT(s, m) (s->Config->ExemptChanOps[(unsigned char)m])#include<sstream>#include<string>#include<vector>#include<map>#include"inspircd.h"#include"globals.h"#include"modules.h"#include"socketengine.h"#include"socket.h"/* Required forward definitions */classServerConfig;classInspIRCd;classInspSocket;/** Types of data in the core config
*/enumConfigDataType{DT_NOTHING=0,/* No data */DT_INTEGER=1,/* Integer */DT_CHARPTR=2,/* Char pointer */DT_BOOLEAN=3,/* Boolean */DT_ALLOW_NEWLINE=128/* New line characters allowed */};/** Holds a config value, either string, integer or boolean.
* Callback functions receive one or more of these, either on
* their own as a reference, or in a reference to a deque of them.
* The callback function can then alter the values of the ValueItem
* classes to validate the settings.
*/classValueItem{/** Actual data */std::stringv;public:/** Initialize with an int */ValueItem(intvalue);/** Initialize with a bool */ValueItem(boolvalue);/** Initialize with a char pointer */ValueItem(char*value);/** Change value to a char pointer */voidSet(char*value);/** Change value to a const char pointer */voidSet(constchar*val);/** Change value to an int */voidSet(intvalue);/** Get value as an int */intGetInteger();/** Get value as a string */char*GetString();/** Get value as a bool */boolGetBool();};/** The base class of the container 'ValueContainer'
* used internally by the core to hold core values.
*/classValueContainerBase{public:/** Constructor */ValueContainerBase(){}/** Destructor */virtual~ValueContainerBase(){}};/** ValueContainer is used to contain pointers to different
* core values such as the server name, maximum number of
* clients etc.
* It is specialized to hold a data type, then pointed at
* a value in the ServerConfig class. When the value has been
* read and validated, the Set method is called to write the
* value safely in a type-safe manner.
*/template<typenameT>classValueContainer:publicValueContainerBase{/** Contained item */Tval;public:/** Initialize with nothing */ValueContainer(){val=NULL;}/** Initialize with a value of type T */ValueContainer(TVal){val=Val;}/** Change value to type T of size s */voidSet(Tnewval,size_ts){memcpy(val,newval,s);}};/** A specialization of ValueContainer to hold a pointer to a bool
*/typedefValueContainer<bool*>ValueContainerBool;/** A specialization of ValueContainer to hold a pointer to
* an unsigned int
*/typedefValueContainer<unsignedint*>ValueContainerUInt;/** A specialization of ValueContainer to hold a pointer to
* a char array.
*/typedefValueContainer<char*>ValueContainerChar;/** A specialization of ValueContainer to hold a pointer to
* an int
*/typedefValueContainer<int*>ValueContainerInt;/** A set of ValueItems used by multi-value validator functions
*/typedefstd::deque<ValueItem>ValueList;/** A callback for validating a single value
*/typedefbool(*Validator)(ServerConfig*conf,constchar*,constchar*,ValueItem&);/** A callback for validating multiple value entries
*/typedefbool(*MultiValidator)(ServerConfig*conf,constchar*,char**,ValueList&,int*);/** A callback indicating the end of a group of entries
*/typedefbool(*MultiNotify)(ServerConfig