comparison src/context.h @ 0:616666e2f34c

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