summaryrefslogtreecommitdiff
path: root/config.c
blob: 01b2fea02bd522d5faa202050f69816442dc46e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * config.c: Global configuration
 *
 * See the README file for copyright information and how to reach the author.
 *
 */

#include "config.h"
#include <string.h>

/* 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;
}