mirror of
https://github.com/anope/anope.git
synced 2026-07-09 01:43:12 +02:00
Removed DT_CHARPTR from the config reader, its unneeded
This commit is contained in:
+1
-47
@@ -33,7 +33,6 @@ enum ConfigDataType
|
||||
DT_INTEGER, // Integer
|
||||
DT_UINTEGER, // Unsigned Integer
|
||||
DT_LUINTEGER, // Long Unsigned Integer
|
||||
DT_CHARPTR, // Char pointer
|
||||
DT_STRING, // Anope::string
|
||||
DT_BOOLEAN, // Boolean
|
||||
DT_HOSTNAME, // Hostname syntax
|
||||
@@ -42,7 +41,7 @@ enum ConfigDataType
|
||||
DT_TIME, // Time value
|
||||
DT_NORELOAD = 32, // Item can't be reloaded after startup
|
||||
DT_ALLOW_WILD = 64, // Allow wildcards/CIDR in DT_IPADDRESS
|
||||
DT_ALLOW_NEWLINE = 128 // New line characters allowed in DT_CHARPTR
|
||||
DT_ALLOW_NEWLINE = 128 // New line characters allowed in DT_STRING
|
||||
};
|
||||
|
||||
/** Holds a config value, either string, integer or boolean.
|
||||
@@ -61,12 +60,6 @@ class CoreExport ValueItem
|
||||
ValueItem(int);
|
||||
/** Initialize with a bool */
|
||||
ValueItem(bool);
|
||||
/** Initialize with a char pointer */
|
||||
ValueItem(const char *);
|
||||
/** Initialize with an std::string */
|
||||
ValueItem(const std::string &);
|
||||
/** Initialize with a ci::string */
|
||||
ValueItem(const ci::string &);
|
||||
/** Initialize with an Anope::string */
|
||||
ValueItem(const Anope::string &);
|
||||
/** Initialize with a long */
|
||||
@@ -137,40 +130,6 @@ template<typename T> class ValueContainer : public ValueContainerBase
|
||||
}
|
||||
};
|
||||
|
||||
/** This a specific version of ValueContainer to handle character arrays specially
|
||||
*/
|
||||
template<> class ValueContainer<char **> : public ValueContainerBase
|
||||
{
|
||||
private:
|
||||
/** Contained item */
|
||||
char **val;
|
||||
public:
|
||||
/** Initialize with nothing */
|
||||
ValueContainer() : ValueContainerBase(), val(NULL) { }
|
||||
/** Initialize with a value of type T */
|
||||
ValueContainer(char **Val) : ValueContainerBase(), val(Val) { }
|
||||
/** Initialize with a copy */
|
||||
ValueContainer(const ValueContainer &Val) : ValueContainerBase(), val(Val.val) { }
|
||||
ValueContainer &operator=(const ValueContainer &Val)
|
||||
{
|
||||
val = Val.val;
|
||||
return *this;
|
||||
}
|
||||
/** Change value to type T of size s */
|
||||
void Set(const char *newval, size_t s)
|
||||
{
|
||||
if (*val)
|
||||
delete [] *val;
|
||||
if (!*newval)
|
||||
{
|
||||
*val = NULL;
|
||||
return;
|
||||
}
|
||||
*val = new char[s];
|
||||
memcpy(*val, newval, s);
|
||||
}
|
||||
};
|
||||
|
||||
/** This a specific version of ValueContainer to handle Anope::string specially
|
||||
*/
|
||||
template<> class ValueContainer<Anope::string *> : public ValueContainerBase
|
||||
@@ -217,11 +176,6 @@ typedef ValueContainer<unsigned *> ValueContainerUInt;
|
||||
*/
|
||||
typedef ValueContainer<long unsigned *> ValueContainerLUInt;
|
||||
|
||||
/** A specialization of ValueContainer to hold a pointer to
|
||||
* a char array.
|
||||
*/
|
||||
typedef ValueContainer<char **> ValueContainerChar;
|
||||
|
||||
/** A specialization of ValueContainer to hold a pointer to
|
||||
* an int
|
||||
*/
|
||||
|
||||
@@ -88,13 +88,6 @@ class CommandOSConfig : public Command
|
||||
vcs->Set(vi.GetValue());
|
||||
break;
|
||||
}
|
||||
case DT_CHARPTR:
|
||||
{
|
||||
ValueContainerChar *vcc = debug_cast<ValueContainerChar *>(v->val);
|
||||
// Make sure we also copy the null terminator
|
||||
vcc->Set(vi.GetString(), strlen(vi.GetString()) + 1);
|
||||
break;
|
||||
}
|
||||
case DT_STRING:
|
||||
{
|
||||
ValueContainerString *vcs = debug_cast<ValueContainerString *>(v->val);
|
||||
|
||||
+6
-32
@@ -969,10 +969,6 @@ ConfigItems::ConfigItems(ServerConfig *conf)
|
||||
* unsigned blarg;
|
||||
* {"tag", "value", "0", new ValueContainerUInt(&conf->blarg), DT_UINTEGER, <validation>},
|
||||
*
|
||||
* If you want to create a directive using a character pointer without additional validation (see below for hostnames, fields with no spaces, and IP addresses):
|
||||
* char *blarg;
|
||||
* {"tag", "value", "", new ValueContainerChar(&conf->blarg), DT_CHARPTR, <validation>},
|
||||
*
|
||||
* If you want to create a directive using a string:
|
||||
* Anope::string blarg;
|
||||
* {"tag", "value", "", new ValueContainerString(&conf->blarg), DT_STRING, <validation>},
|
||||
@@ -1000,7 +996,7 @@ ConfigItems::ConfigItems(ServerConfig *conf)
|
||||
* For the second-to-last argument, you can or (|) in the following values:
|
||||
* DT_NORELOAD - The variable can't be changed on a reload of the configuration
|
||||
* DT_ALLOW_WILD - Allows wildcards/CIDR in DT_IPADDRESS
|
||||
* DT_ALLOW_NEWLINE - Allows new line characters in DT_CHARPTR, DT_STRING, and DT_CISTRING
|
||||
* DT_ALLOW_NEWLINE - Allows new line characters in DT_STRING
|
||||
*
|
||||
* We may need to add some other validation functions to handle certain things, we can handle that later.
|
||||
* Any questions about these, w00t, feel free to ask. */
|
||||
@@ -1103,7 +1099,7 @@ ConfigItems::ConfigItems(ServerConfig *conf)
|
||||
{"chanserv", "opersonly", "no", new ValueContainerBool(&conf->CSOpersOnly), DT_BOOLEAN, ValidateChanServ},
|
||||
{"memoserv", "nick", "", new ValueContainerString(&conf->s_MemoServ), DT_STRING | DT_NORELOAD, NoValidation},
|
||||
{"memoserv", "description", "Memo Service", new ValueContainerString(&conf->desc_MemoServ), DT_STRING | DT_NORELOAD, ValidateMemoServ},
|
||||
{"memoserv", "modules", "", new ValueContainerString(&Config->MemoCoreModules), DT_STRING, NoValidation},
|
||||
{"memoserv", "modules", "", new ValueContainerString(&conf->MemoCoreModules), DT_STRING, NoValidation},
|
||||
{"memoserv", "maxmemos", "0", new ValueContainerUInt(&conf->MSMaxMemos), DT_UINTEGER, NoValidation},
|
||||
{"memoserv", "senddelay", "0", new ValueContainerTime(&conf->MSSendDelay), DT_TIME, NoValidation},
|
||||
{"memoserv", "notifyall", "no", new ValueContainerBool(&conf->MSNotifyAll), DT_BOOLEAN, NoValidation},
|
||||
@@ -1163,7 +1159,7 @@ ConfigItems::ConfigItems(ServerConfig *conf)
|
||||
{"include",
|
||||
{"type", "name", ""},
|
||||
{"", "", ""},
|
||||
{DT_CHARPTR, DT_CHARPTR},
|
||||
{DT_STRING, DT_STRING},
|
||||
InitInclude, DoInclude, DoneInclude},
|
||||
{"uplink",
|
||||
{"host", "ipv6", "port", "password", ""},
|
||||
@@ -1173,7 +1169,7 @@ ConfigItems::ConfigItems(ServerConfig *conf)
|
||||
{"module",
|
||||
{"name", ""},
|
||||
{"", ""},
|
||||
{DT_CHARPTR},
|
||||
{DT_STRING},
|
||||
InitModules, DoModule, DoneModules},
|
||||
{"log",
|
||||
{"target", "source", "logage", "inhabitlogchannel", "admin", "override", "commands", "servers", "channels", "users", "other", "rawio", "debug", ""},
|
||||
@@ -1183,12 +1179,12 @@ ConfigItems::ConfigItems(ServerConfig *conf)
|
||||
{"opertype",
|
||||
{"name", "inherits", "commands", "privs", ""},
|
||||
{"", "", "", "", ""},
|
||||
{DT_CHARPTR, DT_CHARPTR, DT_CHARPTR, DT_CHARPTR},
|
||||
{DT_STRING, DT_STRING, DT_STRING, DT_STRING},
|
||||
InitOperTypes, DoOperType, DoneOperTypes},
|
||||
{"oper",
|
||||
{"name", "type", "password", "certfp", ""},
|
||||
{"", "", "", "", ""},
|
||||
{DT_CHARPTR, DT_CHARPTR, DT_CHARPTR, DT_CHARPTR},
|
||||
{DT_STRING, DT_STRING, DT_STRING, DT_STRING},
|
||||
InitOpers, DoOper, DoneOpers},
|
||||
{"",
|
||||
{""},
|
||||
@@ -1275,15 +1271,6 @@ void ServerConfig::Read()
|
||||
ValidateIP(vl[vl.size() - 1].GetValue(), configitems.MultiValues[Index].tag, configitems.MultiValues[Index].items[valuenum], allow_wild);
|
||||
break;
|
||||
}
|
||||
case DT_CHARPTR:
|
||||
{
|
||||
Anope::string item;
|
||||
if (ConfValue(hash, configitems.MultiValues[Index].tag, configitems.MultiValues[Index].items[valuenum], configitems.MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines))
|
||||
vl.push_back(ValueItem(item.c_str()));
|
||||
else
|
||||
vl.push_back(ValueItem(""));
|
||||
break;
|
||||
}
|
||||
case DT_STRING:
|
||||
{
|
||||
Anope::string item;
|
||||
@@ -1372,13 +1359,6 @@ void ServerConfig::Read()
|
||||
vcs->Set(vi.GetValue());
|
||||
break;
|
||||
}
|
||||
case DT_CHARPTR:
|
||||
{
|
||||
ValueContainerChar *vcc = debug_cast<ValueContainerChar *>(configitems.Values[Index].val);
|
||||
// Make sure we also copy the null terminator
|
||||
vcc->Set(vi.GetString(), strlen(vi.GetString()) + 1);
|
||||
break;
|
||||
}
|
||||
case DT_STRING:
|
||||
{
|
||||
ValueContainerString *vcs = debug_cast<ValueContainerString *>(configitems.Values[Index].val);
|
||||
@@ -1775,12 +1755,6 @@ ValueItem::ValueItem(bool value) : v("")
|
||||
v = n.str();
|
||||
}
|
||||
|
||||
ValueItem::ValueItem(const char *value) : v(value) { }
|
||||
|
||||
ValueItem::ValueItem(const std::string &value) : v(value) { }
|
||||
|
||||
ValueItem::ValueItem(const ci::string &value) : v(value) { }
|
||||
|
||||
ValueItem::ValueItem(const Anope::string &value) : v(value) { }
|
||||
|
||||
void ValueItem::Set(const char *value)
|
||||
|
||||
Reference in New Issue
Block a user