summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/configparser.h2
-rw-r--r--include/configreader.h8
-rw-r--r--include/typedefs.h6
-rw-r--r--src/configparser.cpp19
-rw-r--r--src/configreader.cpp6
-rw-r--r--src/modules/m_httpd_config.cpp4
6 files changed, 22 insertions, 23 deletions
diff --git a/include/configparser.h b/include/configparser.h
index 02619e759..c9790c59f 100644
--- a/include/configparser.h
+++ b/include/configparser.h
@@ -41,7 +41,7 @@ enum ParseFlags
struct ParseStack
{
std::vector<std::string> reading;
- insp::flat_map<std::string, std::string> vars;
+ insp::flat_map<std::string, std::string, irc::insensitive_swo> vars;
ConfigDataHash& output;
ConfigFileCache& FilesOutput;
std::stringstream& errstr;
diff --git a/include/configreader.h b/include/configreader.h
index 005d4a37d..4d70d8510 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -35,7 +35,7 @@
/** Structure representing a single \<tag> in config */
class CoreExport ConfigTag : public refcountbase
{
- std::vector<KeyVal> items;
+ ConfigItems items;
public:
const std::string tag;
const std::string src_name;
@@ -80,10 +80,10 @@ class CoreExport ConfigTag : public refcountbase
std::string getTagLocation();
- inline const std::vector<KeyVal>& getItems() const { return items; }
+ inline const ConfigItems& getItems() const { return items; }
- /** Create a new ConfigTag, giving access to the private KeyVal item list */
- static ConfigTag* create(const std::string& Tag, const std::string& file, int line, std::vector<KeyVal>*& Items);
+ /** Create a new ConfigTag, giving access to the private ConfigItems item list */
+ static ConfigTag* create(const std::string& Tag, const std::string& file, int line, ConfigItems*& Items);
private:
ConfigTag(const std::string& Tag, const std::string& file, int line);
};
diff --git a/include/typedefs.h b/include/typedefs.h
index 879ef0627..873382999 100644
--- a/include/typedefs.h
+++ b/include/typedefs.h
@@ -66,13 +66,13 @@ typedef std::vector<Membership*> IncludeChanList;
*/
typedef std::vector<std::string> file_cache;
-/** A configuration key and value pair
+/** A mapping of configuration keys to their assigned values.
*/
-typedef std::pair<std::string, std::string> KeyVal;
+typedef insp::flat_map<std::string, std::string, irc::insensitive_swo> ConfigItems;
/** The entire configuration
*/
-typedef std::multimap<std::string, reference<ConfigTag> > ConfigDataHash;
+typedef std::multimap<std::string, reference<ConfigTag>, irc::insensitive_swo> ConfigDataHash;
/** Iterator of ConfigDataHash */
typedef ConfigDataHash::const_iterator ConfigIter;
diff --git a/src/configparser.cpp b/src/configparser.cpp
index 8bf9aaec2..7c03fe58a 100644
--- a/src/configparser.cpp
+++ b/src/configparser.cpp
@@ -91,7 +91,7 @@ struct Parser
unget(ch);
}
- bool kv(std::vector<KeyVal>* items, std::set<std::string>& seen)
+ bool kv(ConfigItems* items)
{
std::string key;
nextword(key);
@@ -177,10 +177,10 @@ struct Parser
value.push_back(ch);
}
- if (!seen.insert(key).second)
+ if (items->find(key) != items->end())
throw CoreException("Duplicate key '" + key + "' found");
- items->push_back(KeyVal(key, value));
+ (*items)[key] = value;
return true;
}
@@ -199,11 +199,10 @@ struct Parser
if (name.empty())
throw CoreException("Empty tag name");
- std::vector<KeyVal>* items;
- std::set<std::string> seen;
+ ConfigItems* items;
tag = ConfigTag::create(name, current.filename, current.line, items);
- while (kv(items, seen))
+ while (kv(items))
{
// Do nothing here (silences a GCC warning).
}
@@ -220,14 +219,14 @@ struct Parser
}
else if (name == "files")
{
- for(std::vector<KeyVal>::iterator i = items->begin(); i != items->end(); i++)
+ for(ConfigItems::iterator i = items->begin(); i != items->end(); i++)
{
stack.DoReadFile(i->first, i->second, flags, false);
}
}
else if (name == "execfiles")
{
- for(std::vector<KeyVal>::iterator i = items->begin(); i != items->end(); i++)
+ for(ConfigItems::iterator i = items->begin(); i != items->end(); i++)
{
stack.DoReadFile(i->first, i->second, flags, true);
}
@@ -385,7 +384,7 @@ bool ParseStack::ParseFile(const std::string& path, int flags, const std::string
bool ConfigTag::readString(const std::string& key, std::string& value, bool allow_lf)
{
- for(std::vector<KeyVal>::iterator j = items.begin(); j != items.end(); ++j)
+ for(ConfigItems::iterator j = items.begin(); j != items.end(); ++j)
{
if(j->first != key)
continue;
@@ -488,7 +487,7 @@ std::string ConfigTag::getTagLocation()
return src_name + ":" + ConvToStr(src_line);
}
-ConfigTag* ConfigTag::create(const std::string& Tag, const std::string& file, int line, std::vector<KeyVal>*& Items)
+ConfigTag* ConfigTag::create(const std::string& Tag, const std::string& file, int line, ConfigItems*& Items)
{
ConfigTag* rv = new ConfigTag(Tag, file, line);
Items = &rv->items;
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 9d327532b..8263b8737 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -46,7 +46,7 @@ ServerLimits::ServerLimits(ConfigTag* tag)
static ConfigTag* CreateEmptyTag()
{
- std::vector<KeyVal>* items;
+ ConfigItems* items;
return ConfigTag::create("empty", "<auto>", 0, items);
}
@@ -220,9 +220,9 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
if (blk_count == 0)
{
// No connect blocks found; make a trivial default block
- std::vector<KeyVal>* items;
+ ConfigItems* items;
ConfigTag* tag = ConfigTag::create("connect", "<auto>", 0, items);
- items->push_back(std::make_pair("allow", "*"));
+ (*items)["allow"] = "*";
config_data.insert(std::make_pair("connect", tag));
blk_count = 1;
}
diff --git a/src/modules/m_httpd_config.cpp b/src/modules/m_httpd_config.cpp
index 6fd7f4050..11c82c031 100644
--- a/src/modules/m_httpd_config.cpp
+++ b/src/modules/m_httpd_config.cpp
@@ -81,8 +81,8 @@ class ModuleHttpConfig : public Module, public HTTPRequestEventListener
for (ConfigDataHash::iterator x = ServerInstance->Config->config_data.begin(); x != ServerInstance->Config->config_data.end(); ++x)
{
data << "&lt;" << x->first << " ";
- ConfigTag* tag = x->second;
- for (std::vector<KeyVal>::const_iterator j = tag->getItems().begin(); j != tag->getItems().end(); j++)
+ const ConfigItems& items = x->second->getItems();
+ for (ConfigItems::const_iterator j = items.begin(); j != items.end(); j++)
{
data << Sanitize(j->first) << "=&quot;" << Sanitize(j->second) << "&quot; ";
}