annotate src/context.h @ 13:75e1a9bcbc2e

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