|
0
|
1 |
#ifndef VMAILMGR__CONFIG_RC__H__
|
|
|
2 |
#define VMAILMGR__CONFIG_RC__H__
|
|
|
3 |
|
|
|
4 |
#ifndef GLOBAL_CONFIG_DIR
|
|
|
5 |
#define GLOBAL_CONFIG_DIR "/etc/vmailmgr"
|
|
|
6 |
#endif
|
|
|
7 |
|
|
|
8 |
#ifndef LOCAL_CONFIG_DIR
|
|
|
9 |
#define LOCAL_CONFIG_DIR ".vmailmgr"
|
|
|
10 |
#endif
|
|
|
11 |
|
|
|
12 |
#include "mystring/mystring.h"
|
|
|
13 |
#include "misc/strlist.h"
|
|
|
14 |
|
|
|
15 |
template<class T>
|
|
|
16 |
struct config_cache
|
|
|
17 |
{
|
|
|
18 |
T* value;
|
|
|
19 |
config_cache() : value(0) { }
|
|
|
20 |
~config_cache() { delete value; }
|
|
|
21 |
};
|
|
|
22 |
|
|
|
23 |
class configuration
|
|
|
24 |
{
|
|
|
25 |
public:
|
|
|
26 |
configuration();
|
|
|
27 |
configuration(const configuration* prev, const mystring& dir);
|
|
|
28 |
~configuration();
|
|
|
29 |
|
|
|
30 |
configuration const * parent;
|
|
|
31 |
|
|
|
32 |
const mystring directory;
|
|
|
33 |
|
|
|
34 |
%%LIST%%
|
|
|
35 |
|
|
|
36 |
private:
|
|
|
37 |
mystring read_str(const mystring& name, const mystring& def,
|
|
|
38 |
config_cache<mystring>&) const;
|
|
|
39 |
mystring read_dir(const mystring& name, const mystring& def,
|
|
|
40 |
config_cache<mystring>&) const;
|
|
|
41 |
unsigned read_uns(const mystring& name, unsigned def,
|
|
|
42 |
config_cache<unsigned>&) const;
|
|
|
43 |
strlist read_list(const mystring& name, const strlist& def,
|
|
|
44 |
config_cache<strlist>&) const;
|
|
|
45 |
};
|
|
|
46 |
|
|
|
47 |
extern const configuration* config;
|
|
|
48 |
|
|
|
49 |
#endif
|