Mercurial > sm-archive
annotate src/context.h @ 27:9298f8b00db2 stable-1-0-10
patches from Takao Abe add switches for config and pid files
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 24 May 2018 10:35:45 -0700 |
parents | b24369330483 |
children |
rev | line source |
---|---|
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 | |
19
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
11 typedef map<const char *, const char *, ltstr> string_map; |
0 | 12 |
13 struct CONFIG { | |
19
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
14 // the only mutable stuff once it has been loaded from the config file |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
15 int reference_count; // protected by the global config_mutex |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
16 // all the rest is constant after loading from the config file |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
17 int generation; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
18 time_t load_time; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
19 string_set config_files; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
20 string_map env_from; // map senders to archive mailboxes |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
21 string_map rcpt_to; // map recipients to archive mailboxes |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
22 string_set rcpt_remove; // remove these recipients |
0 | 23 |
19
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
24 CONFIG(); |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
25 ~CONFIG(); |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
26 void add_from(const char *from, const char *target) {env_from[from] = target; }; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
27 void add_to(const char *to, const char *target) {rcpt_to[to] = target; }; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
28 void add_remove(const char *to) {rcpt_remove.insert(to); }; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
29 const char *find_from(const char *from) {return find(from, env_from); }; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
30 const char *find_to(const char *to) {return find(to, rcpt_to); }; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
31 bool find_remove(const char *to) {return find(to, rcpt_remove); }; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
32 bool find(const char *needle, string_set &haystack); |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
33 const char *find(const char *needle, string_map &haystack); |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
34 void dump(); |
0 | 35 }; |
36 | |
19
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
37 extern const char *token_envfrom; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
38 extern const char *token_include; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
39 extern const char *token_lbrace; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
40 extern const char *token_rbrace; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
41 extern const char *token_rcptto; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
42 extern const char *token_remove; |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
43 extern const char *token_semi; |
0 | 44 |
19
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
45 extern string_set all_strings; // owns all the strings, only modified by the config loader thread |
0 | 46 |
47 void discard(string_set &s); | |
19
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
48 const char* register_string(string_set &s, const char *name); |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
49 const char* register_string(const char *name); |
13 | 50 void clear_strings(); |
19
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
51 CONFIG *parse_config(const char *fn); |
b24369330483
Fedora 9 compile and const correctness.
Carl Byington <carl@five-ten-sg.com>
parents:
13
diff
changeset
|
52 bool load_conf(CONFIG &dc, const char *fn); |
0 | 53 void token_init(); |
54 | |
55 #endif |