comparison src/context.h @ 19:b24369330483 stable-1-0-7

Fedora 9 compile and const correctness.
author Carl Byington <carl@five-ten-sg.com>
date Thu, 12 Jun 2008 18:17:33 -0700
parents 75e1a9bcbc2e
children
comparison
equal deleted inserted replaced
18:e1a028daceb9 19:b24369330483
6 6
7 */ 7 */
8 #ifndef context_include 8 #ifndef context_include
9 #define context_include 9 #define context_include
10 10
11 #include "tokenizer.h" 11 typedef map<const char *, const char *, ltstr> string_map;
12 #include <map>
13
14
15 typedef map<char *, char *, ltstr> string_map;
16 12
17 struct CONFIG { 13 struct CONFIG {
18 // the only mutable stuff once it has been loaded from the config file 14 // the only mutable stuff once it has been loaded from the config file
19 int reference_count; // protected by the global config_mutex 15 int reference_count; // protected by the global config_mutex
20 // all the rest is constant after loading from the config file 16 // all the rest is constant after loading from the config file
21 int generation; 17 int generation;
22 time_t load_time; 18 time_t load_time;
23 string_set config_files; 19 string_set config_files;
24 string_map env_from; // map senders to archive mailboxes 20 string_map env_from; // map senders to archive mailboxes
25 string_map rcpt_to; // map recipients to archive mailboxes 21 string_map rcpt_to; // map recipients to archive mailboxes
26 string_set rcpt_remove; // remove these recipients 22 string_set rcpt_remove; // remove these recipients
27 23
28 CONFIG(); 24 CONFIG();
29 ~CONFIG(); 25 ~CONFIG();
30 void add_from(char *from, char *target) {env_from[from] = target; }; 26 void add_from(const char *from, const char *target) {env_from[from] = target; };
31 void add_to(char *to, char *target) {rcpt_to[to] = target; }; 27 void add_to(const char *to, const char *target) {rcpt_to[to] = target; };
32 void add_remove(char *to) {rcpt_remove.insert(to); }; 28 void add_remove(const char *to) {rcpt_remove.insert(to); };
33 char * find_from(char *from) {return find(from, env_from); }; 29 const char *find_from(const char *from) {return find(from, env_from); };
34 char * find_to(char *to) {return find(to, rcpt_to); }; 30 const char *find_to(const char *to) {return find(to, rcpt_to); };
35 bool find_remove(char *to) {return find(to, rcpt_remove); }; 31 bool find_remove(const char *to) {return find(to, rcpt_remove); };
36 bool find(char *needle, string_set &haystack); 32 bool find(const char *needle, string_set &haystack);
37 char * find(char *needle, string_map &haystack); 33 const char *find(const char *needle, string_map &haystack);
38 void dump(); 34 void dump();
39 }; 35 };
40 36
41 extern char *token_envfrom; 37 extern const char *token_envfrom;
42 extern char *token_include; 38 extern const char *token_include;
43 extern char *token_lbrace; 39 extern const char *token_lbrace;
44 extern char *token_rbrace; 40 extern const char *token_rbrace;
45 extern char *token_rcptto; 41 extern const char *token_rcptto;
46 extern char *token_remove; 42 extern const char *token_remove;
47 extern char *token_semi; 43 extern const char *token_semi;
48 44
49 extern string_set all_strings; // owns all the strings, only modified by the config loader thread 45 extern string_set all_strings; // owns all the strings, only modified by the config loader thread
50 46
51 void discard(string_set &s); 47 void discard(string_set &s);
52 char* register_string(string_set &s, char *name); 48 const char* register_string(string_set &s, const char *name);
53 char* register_string(char *name); 49 const char* register_string(const char *name);
54 void clear_strings(); 50 void clear_strings();
55 CONFIG *parse_config(char *fn); 51 CONFIG *parse_config(const char *fn);
56 bool load_conf(CONFIG &dc, char *fn); 52 bool load_conf(CONFIG &dc, const char *fn);
57 void token_init(); 53 void token_init();
58 54
59 #endif 55 #endif