From fd6a8e93920553e2e6655b0f396be61a6e6b832c Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Tue, 12 Mar 2013 18:21:21 +0100 Subject: Add support for mandatory tags in included config files If the mandatory tag is not found in the included config, the rehash is aborted. This is especially useful for remote includes, as it allows users to have a dummy tag at the end of the included config to indicate that the config has been wholly read. This method does not depend on exit codes so even situations where wget returns an empty or a wrong page that we would otherwise accept can be detected and an error can be generated before we assume that the contents have disappeared (and unload all modules, if the included file is supposed to contain module tags, for example). Usage: - if the included config doesn't contain a tag then the rehash is aborted Fixes #30 reported by @Justasic --- include/configparser.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/configparser.h') diff --git a/include/configparser.h b/include/configparser.h index f44b7c8a5..999d79e24 100644 --- a/include/configparser.h +++ b/include/configparser.h @@ -51,8 +51,8 @@ struct ParseStack vars["quot"] = "\""; vars["newline"] = vars["nl"] = "\n"; } - bool ParseFile(const std::string& name, int flags); - bool ParseExec(const std::string& name, int flags); + bool ParseFile(const std::string& name, int flags, const std::string& mandatory_tag = ""); + bool ParseExec(const std::string& name, int flags, const std::string& mandatory_tag = ""); void DoInclude(ConfigTag* includeTag, int flags); void DoReadFile(const std::string& key, const std::string& file, int flags, bool exec); }; -- cgit v1.2.3