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);};
|
|
25 char * find_to(char *to) {return find(to, env_to); };
|
|
26 char * find(char *needle, &string_map haystack);
|
|
27 void dump();
|
|
28 };
|
|
29
|
|
30 extern char *token_envfrom;
|
|
31 extern char *token_lbrace;
|
|
32 extern char *token_rbrace;
|
|
33 extern char *token_rcptto;
|
|
34 extern char *token_semi;
|
|
35
|
|
36 extern string_set all_strings; // owns all the strings, only modified by the config loader thread
|
|
37
|
|
38 void discard(string_set &s);
|
|
39 char* register_string(string_set &s, char *name);
|
|
40 char* register_string(char *name);
|
|
41 CONFIG *parse_config(char *fn);
|
|
42 bool load_conf(CONFIG &dc, char *fn);
|
|
43 void token_init();
|
|
44
|
|
45 #endif
|