diff src/context.h @ 0:616666e2f34c

initial version
author carl
date Fri, 10 Mar 2006 10:30:08 -0800
parents
children 32b57406b656
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/context.h	Fri Mar 10 10:30:08 2006 -0800
@@ -0,0 +1,44 @@
+#ifndef context_include
+#define context_include
+
+#include "tokenizer.h"
+#include <map>
+
+
+typedef map<char *, char *, ltstr>		  string_map;
+
+struct CONFIG {
+	// the only mutable stuff once it has been loaded from the config file
+	int 		reference_count;	// protected by the global config_mutex
+	// all the rest is constant after loading from the config file
+	int 			generation;
+	time_t			load_time;
+	string_map		env_from;			// map senders to archive mailboxes
+	string_map		rcpt_to;			// map recipients to archive mailboxes
+
+	CONFIG();
+	~CONFIG();
+	void		add_from(char *from, char *target)		{env_from[from] = target;	 };
+	void		add_to(char *to, char *target)			{rcpt_to[to]	= target;	 };
+	char *		find_from(char *from)					{return find(from, env_from);};
+	char *		find_to(char *to)						{return find(to, env_to);	 };
+	char *		find(char *needle, &string_map haystack);
+	void		dump();
+};
+
+extern char *token_envfrom;
+extern char *token_lbrace;
+extern char *token_rbrace;
+extern char *token_rcptto;
+extern char *token_semi;
+
+extern string_set	all_strings;	// owns all the strings, only modified by the config loader thread
+
+void discard(string_set &s);
+char* register_string(string_set &s, char *name);
+char* register_string(char *name);
+CONFIG *parse_config(char *fn);
+bool  load_conf(CONFIG &dc, char *fn);
+void  token_init();
+
+#endif