13
|
1 /*
|
|
2
|
|
3 Copyright (c) 2007 Carl Byington - 510 Software Group, released under
|
|
4 the GPL version 3 or any later version at your choice available at
|
|
5 http://www.gnu.org/licenses/gpl-3.0.txt
|
|
6
|
|
7 */
|
0
|
8 #ifndef context_include
|
|
9 #define context_include
|
|
10
|
|
11 #include "tokenizer.h"
|
|
12 #include <map>
|
|
13
|
|
14
|
|
15 typedef map<char *, char *, ltstr> string_map;
|
|
16
|
|
17 struct CONFIG {
|
|
18 // the only mutable stuff once it has been loaded from the config file
|
|
19 int reference_count; // protected by the global config_mutex
|
|
20 // all the rest is constant after loading from the config file
|
|
21 int generation;
|
|
22 time_t load_time;
|
2
|
23 string_set config_files;
|
0
|
24 string_map env_from; // map senders to archive mailboxes
|
|
25 string_map rcpt_to; // map recipients to archive mailboxes
|
13
|
26 string_set rcpt_remove; // remove these recipients
|
0
|
27
|
|
28 CONFIG();
|
|
29 ~CONFIG();
|
13
|
30 void add_from(char *from, char *target) {env_from[from] = target; };
|
|
31 void add_to(char *to, char *target) {rcpt_to[to] = target; };
|
|
32 void add_remove(char *to) {rcpt_remove.insert(to); };
|
|
33 char * find_from(char *from) {return find(from, env_from); };
|
|
34 char * find_to(char *to) {return find(to, rcpt_to); };
|
|
35 bool find_remove(char *to) {return find(to, rcpt_remove); };
|
|
36 bool find(char *needle, string_set &haystack);
|
3
|
37 char * find(char *needle, string_map &haystack);
|
0
|
38 void dump();
|
|
39 };
|
|
40
|
|
41 extern char *token_envfrom;
|
3
|
42 extern char *token_include;
|
0
|
43 extern char *token_lbrace;
|
|
44 extern char *token_rbrace;
|
|
45 extern char *token_rcptto;
|
13
|
46 extern char *token_remove;
|
0
|
47 extern char *token_semi;
|
|
48
|
|
49 extern string_set all_strings; // owns all the strings, only modified by the config loader thread
|
|
50
|
|
51 void discard(string_set &s);
|
|
52 char* register_string(string_set &s, char *name);
|
|
53 char* register_string(char *name);
|
13
|
54 void clear_strings();
|
0
|
55 CONFIG *parse_config(char *fn);
|
|
56 bool load_conf(CONFIG &dc, char *fn);
|
|
57 void token_init();
|
|
58
|
|
59 #endif
|