X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fconfigparser.cpp;h=056ed54a4b3e5fb019d88122f1359c4fee06e448;hb=5245a9d7c49b2b397f38b915382adae3483b6e17;hp=558c49117dd69ff6343015205c354c8a27e04af2;hpb=f2256deeefe9a9f57f6f6b902604c01138ad16cc;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/configparser.cpp b/src/configparser.cpp index 558c49117..056ed54a4 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -1,16 +1,22 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2009-2010 Daniel De Graaf * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #include "inspircd.h" #include #include "configparser.h" @@ -76,7 +82,7 @@ struct Parser int ch = next(); while (isspace(ch)) ch = next(); - while (isalnum(ch) || ch == '_') + while (isalnum(ch) || ch == '_'|| ch == '-') { rv.push_back(ch); ch = next(); @@ -84,7 +90,7 @@ struct Parser unget(ch); } - bool kv(std::vector* items) + bool kv(std::vector* items, std::set& seen) { std::string key; nextword(key); @@ -149,6 +155,10 @@ struct Parser else value.push_back(ch); } + + if (!seen.insert(key).second) + throw CoreException("Duplicate key '" + key + "' found"); + items->push_back(KeyVal(key, value)); return true; } @@ -169,9 +179,10 @@ struct Parser throw CoreException("Empty tag name"); std::vector* items; + std::set seen; tag = ConfigTag::create(name, current.filename, current.line, items); - while (kv(items)); + while (kv(items, seen)); if (name == "include") { @@ -429,7 +440,14 @@ bool ConfigTag::getBool(const std::string &key, bool def) if(!readString(key, result)) return def; - return (result == "yes" || result == "true" || result == "1" || result == "on"); + if (result == "yes" || result == "true" || result == "1" || result == "on") + return true; + if (result == "no" || result == "false" || result == "0" || result == "off") + return false; + + ServerInstance->Logs->Log("CONFIG",DEFAULT, "Value of <" + tag + ":" + key + "> at " + getTagLocation() + + " is not valid, ignoring"); + return def; } std::string ConfigTag::getTagLocation()