0
|
1 #ifndef context_include
|
|
2 #define context_include
|
|
3
|
|
4 #include "tokenizer.h"
|
|
5 #include <map>
|
|
6
|
|
7
|
|
8 typedef map<char *, char *, ltstr> string_map;
|
|
9
|
|
10 struct CONFIG {
|
|
11 // the only mutable stuff once it has been loaded from the config file
|
|
12 int reference_count; // protected by the global config_mutex
|
|
13 // all the rest is constant after loading from the config file
|
|
14 int generation;
|
|
15 time_t load_time;
|
2
|
16 string_set config_files;
|
0
|
17 string_map env_from; // map senders to archive mailboxes
|
|
18 string_map rcpt_to; // map recipients to archive mailboxes
|
|
19
|
|
20 CONFIG();
|
|
21 ~CONFIG();
|
|
22 void add_from(char *from, char *target) {env_from[from] = target; };
|
|
23 void add_to(char *to, char *target) {rcpt_to[to] = target; };
|
|
24 char * find_from(char *from) {return find(from, env_from);};
|
3
|
25 char * find_to(char *to) {return find(to, rcpt_to); };
|
|
26 char * find(char *needle, string_map &haystack);
|
0
|
27 void dump();
|
|
28 };
|
|
29
|
|
30 extern char *token_envfrom;
|
3
|
31 extern char *token_include;
|
0
|
32 extern char *token_lbrace;
|
|
33 extern char *token_rbrace;
|
|
34 extern char *token_rcptto;
|
|
35 extern char *token_semi;
|
|
36
|
|
37 extern string_set all_strings; // owns all the strings, only modified by the config loader thread
|
|
38
|
|
39 void discard(string_set &s);
|
|
40 char* register_string(string_set &s, char *name);
|
|
41 char* register_string(char *name);
|
|
42 CONFIG *parse_config(char *fn);
|
|
43 bool load_conf(CONFIG &dc, char *fn);
|
|
44 void token_init();
|
|
45
|
|
46 #endif
|