From c6ffcc01aa82582b119de294ff40aac915c88e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Mon, 7 Jan 2013 21:29:45 +0200 Subject: Initial commit. Version 0.0.3. --- config.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 config.c (limited to 'config.c') diff --git a/config.c b/config.c new file mode 100755 index 0000000..01b2fea --- /dev/null +++ b/config.c @@ -0,0 +1,51 @@ +/* + * config.c: Global configuration + * + * See the README file for copyright information and how to reach the author. + * + */ + +#include "config.h" +#include + +/* Global instance */ +cHistorySetup HistorySetup; + +cHistorySetup::cHistorySetup() +{ + allow_delete = 1; + replay_history_size = 10; +} + +cString cHistorySetup::m_ProcessedArgs; + +bool cHistorySetup::ProcessArg(const char *Name, const char *Value) +{ + if (SetupParse(Name, Value)) { + m_ProcessedArgs = cString::sprintf("%s%s ", *m_ProcessedArgs ? *m_ProcessedArgs : " ", Name); + return true; + } + return false; +} + +bool cHistorySetup::ProcessArgs(int argc, char *argv[]) +{ + return true; +} + +bool cHistorySetup::SetupParse(const char *Name, const char *Value) +{ + const char *pt; + if (*m_ProcessedArgs && NULL != (pt = strstr(m_ProcessedArgs + 1, Name)) && + *(pt - 1) == ' ' && *(pt + strlen(Name)) == ' ') { + dsyslog("Skipping configuration entry %s=%s (overridden in command line)", Name, Value); + return true; + } + + if (!strcasecmp(Name, "ReplayHistorySize")) replay_history_size = atoi(Value); + else if (!strcasecmp(Name, "AllowDelete")) allow_delete = atoi(Value); + else + return false; + + return true; +} -- cgit v1.2.3