annotate src/context.h @ 4:311e331f1bab

initial version
author carl
date Fri, 10 Mar 2006 11:52:38 -0800
parents 01268466f0dc
children 75e1a9bcbc2e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
616666e2f34c initial version
carl
parents:
diff changeset
1 #ifndef context_include
616666e2f34c initial version
carl
parents:
diff changeset
2 #define context_include
616666e2f34c initial version
carl
parents:
diff changeset
3
616666e2f34c initial version
carl
parents:
diff changeset
4 #include "tokenizer.h"
616666e2f34c initial version
carl
parents:
diff changeset
5 #include <map>
616666e2f34c initial version
carl
parents:
diff changeset
6
616666e2f34c initial version
carl
parents:
diff changeset
7
616666e2f34c initial version
carl
parents:
diff changeset
8 typedef map<char *, char *, ltstr> string_map;
616666e2f34c initial version
carl
parents:
diff changeset
9
616666e2f34c initial version
carl
parents:
diff changeset
10 struct CONFIG {
616666e2f34c initial version
carl
parents:
diff changeset
11 // the only mutable stuff once it has been loaded from the config file
616666e2f34c initial version
carl
parents:
diff changeset
12 int reference_count; // protected by the global config_mutex
616666e2f34c initial version
carl
parents:
diff changeset
13 // all the rest is constant after loading from the config file
616666e2f34c initial version
carl
parents:
diff changeset
14 int generation;
616666e2f34c initial version
carl
parents:
diff changeset
15 time_t load_time;
2
32b57406b656 initial version
carl
parents: 0
diff changeset
16 string_set config_files;
0
616666e2f34c initial version
carl
parents:
diff changeset
17 string_map env_from; // map senders to archive mailboxes
616666e2f34c initial version
carl
parents:
diff changeset
18 string_map rcpt_to; // map recipients to archive mailboxes
616666e2f34c initial version
carl
parents:
diff changeset
19
616666e2f34c initial version
carl
parents:
diff changeset
20 CONFIG();
616666e2f34c initial version
carl
parents:
diff changeset
21 ~CONFIG();
616666e2f34c initial version
carl
parents:
diff changeset
22 void add_from(char *from, char *target) {env_from[from] = target; };
616666e2f34c initial version
carl
parents:
diff changeset
23 void add_to(char *to, char *target) {rcpt_to[to] = target; };
616666e2f34c initial version
carl
parents:
diff changeset
24 char * find_from(char *from) {return find(from, env_from);};
3
01268466f0dc initial version
carl
parents: 2
diff changeset
25 char * find_to(char *to) {return find(to, rcpt_to); };
01268466f0dc initial version
carl
parents: 2
diff changeset
26 char * find(char *needle, string_map &haystack);
0
616666e2f34c initial version
carl
parents:
diff changeset
27 void dump();
616666e2f34c initial version
carl
parents:
diff changeset
28 };
616666e2f34c initial version
carl
parents:
diff changeset
29
616666e2f34c initial version
carl
parents:
diff changeset
30 extern char *token_envfrom;
3
01268466f0dc initial version
carl
parents: 2
diff changeset
31 extern char *token_include;
0
616666e2f34c initial version
carl
parents:
diff changeset
32 extern char *token_lbrace;
616666e2f34c initial version
carl
parents:
diff changeset
33 extern char *token_rbrace;
616666e2f34c initial version
carl
parents:
diff changeset
34 extern char *token_rcptto;
616666e2f34c initial version
carl
parents:
diff changeset
35 extern char *token_semi;
616666e2f34c initial version
carl
parents:
diff changeset
36
616666e2f34c initial version
carl
parents:
diff changeset
37 extern string_set all_strings; // owns all the strings, only modified by the config loader thread
616666e2f34c initial version
carl
parents:
diff changeset
38
616666e2f34c initial version
carl
parents:
diff changeset
39 void discard(string_set &s);
616666e2f34c initial version
carl
parents:
diff changeset
40 char* register_string(string_set &s, char *name);
616666e2f34c initial version
carl
parents:
diff changeset
41 char* register_string(char *name);
616666e2f34c initial version
carl
parents:
diff changeset
42 CONFIG *parse_config(char *fn);
616666e2f34c initial version
carl
parents:
diff changeset
43 bool load_conf(CONFIG &dc, char *fn);
616666e2f34c initial version
carl
parents:
diff changeset
44 void token_init();
616666e2f34c initial version
carl
parents:
diff changeset
45
616666e2f34c initial version
carl
parents:
diff changeset
46 #endif