annotate src/context.h @ 23:37793d4c90a0

changes for rhel7 systemd and /var/run on tmpfs
author Carl Byington <carl@five-ten-sg.com>
date Mon, 06 Feb 2017 10:45:07 -0800
parents b24369330483
children
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
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
616666e2f34c initial version
carl
parents:
diff changeset
12
616666e2f34c initial version
carl
parents:
diff changeset
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
616666e2f34c initial version
carl
parents:
diff changeset
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
616666e2f34c initial version
carl
parents:
diff changeset
35 };
616666e2f34c initial version
carl
parents:
diff changeset
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
616666e2f34c initial version
carl
parents:
diff changeset
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
616666e2f34c initial version
carl
parents:
diff changeset
46
616666e2f34c initial version
carl
parents:
diff changeset
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
75e1a9bcbc2e gpl3, add removal option for original recipients
carl
parents: 3
diff changeset
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
616666e2f34c initial version
carl
parents:
diff changeset
53 void token_init();
616666e2f34c initial version
carl
parents:
diff changeset
54
616666e2f34c initial version
carl
parents:
diff changeset
55 #endif