view src/context.h @ 15:72a94c46c2be stable-1-5

fix bash header
author carl
date Sat, 25 Aug 2007 11:37:34 -0700
parents 75e1a9bcbc2e
children b24369330483
line wrap: on
line source

/*

Copyright (c) 2007 Carl Byington - 510 Software Group, released under
the GPL version 3 or any later version at your choice available at
http://www.gnu.org/licenses/gpl-3.0.txt

*/
#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_set		config_files;
	string_map		env_from;			// map senders to archive mailboxes
	string_map		rcpt_to;			// map recipients to archive mailboxes
	string_set		rcpt_remove;		// remove these recipients

	CONFIG();
	~CONFIG();
	void		add_from(char *from, char *target)		{env_from[from] = target;	   };
	void		add_to(char *to, char *target)			{rcpt_to[to]	= target;	   };
	void		add_remove(char *to)					{rcpt_remove.insert(to);	   };
	char *		find_from(char *from)					{return find(from, env_from);  };
	char *		find_to(char *to)						{return find(to, rcpt_to);	   };
	bool		find_remove(char *to)					{return find(to, rcpt_remove); };
	bool		find(char *needle, string_set &haystack);
	char *		find(char *needle, string_map &haystack);
	void		dump();
};

extern char *token_envfrom;
extern char *token_include;
extern char *token_lbrace;
extern char *token_rbrace;
extern char *token_rcptto;
extern char *token_remove;
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);
void  clear_strings();
CONFIG *parse_config(char *fn);
bool  load_conf(CONFIG &dc, char *fn);
void  token_init();

#endif