annotate src/context.h @ 0:616666e2f34c

initial version
author carl
date Fri, 10 Mar 2006 10:30:08 -0800
parents
children 32b57406b656
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;
616666e2f34c initial version
carl
parents:
diff changeset
16 string_map env_from; // map senders to archive mailboxes
616666e2f34c initial version
carl
parents:
diff changeset
17 string_map rcpt_to; // map recipients to archive mailboxes
616666e2f34c initial version
carl
parents:
diff changeset
18
616666e2f34c initial version
carl
parents:
diff changeset
19 CONFIG();
616666e2f34c initial version
carl
parents:
diff changeset
20 ~CONFIG();
616666e2f34c initial version
carl
parents:
diff changeset
21 void add_from(char *from, char *target) {env_from[from] = target; };
616666e2f34c initial version
carl
parents:
diff changeset
22 void add_to(char *to, char *target) {rcpt_to[to] = target; };
616666e2f34c initial version
carl
parents:
diff changeset
23 char * find_from(char *from) {return find(from, env_from);};
616666e2f34c initial version
carl
parents:
diff changeset
24 char * find_to(char *to) {return find(to, env_to); };
616666e2f34c initial version
carl
parents:
diff changeset
25 char * find(char *needle, &string_map haystack);
616666e2f34c initial version
carl
parents:
diff changeset
26 void dump();
616666e2f34c initial version
carl
parents:
diff changeset
27 };
616666e2f34c initial version
carl
parents:
diff changeset
28
616666e2f34c initial version
carl
parents:
diff changeset
29 extern char *token_envfrom;
616666e2f34c initial version
carl
parents:
diff changeset
30 extern char *token_lbrace;
616666e2f34c initial version
carl
parents:
diff changeset
31 extern char *token_rbrace;
616666e2f34c initial version
carl
parents:
diff changeset
32 extern char *token_rcptto;
616666e2f34c initial version
carl
parents:
diff changeset
33 extern char *token_semi;
616666e2f34c initial version
carl
parents:
diff changeset
34
616666e2f34c initial version
carl
parents:
diff changeset
35 extern string_set all_strings; // owns all the strings, only modified by the config loader thread
616666e2f34c initial version
carl
parents:
diff changeset
36
616666e2f34c initial version
carl
parents:
diff changeset
37 void discard(string_set &s);
616666e2f34c initial version
carl
parents:
diff changeset
38 char* register_string(string_set &s, char *name);
616666e2f34c initial version
carl
parents:
diff changeset
39 char* register_string(char *name);
616666e2f34c initial version
carl
parents:
diff changeset
40 CONFIG *parse_config(char *fn);
616666e2f34c initial version
carl
parents:
diff changeset
41 bool load_conf(CONFIG &dc, char *fn);
616666e2f34c initial version
carl
parents:
diff changeset
42 void token_init();
616666e2f34c initial version
carl
parents:
diff changeset
43
616666e2f34c initial version
carl
parents:
diff changeset
44 #endif