view src/syslogconfig.h @ 1:551433a01cab

initial coding
author carl
date Wed, 23 Nov 2005 19:29:14 -0800
parents
children 6e88da080f08
line wrap: on
line source

/***************************************************************************
 *	 Copyright (C) 2005 by 510 Software Group							   *
 *																		   *
 *																		   *
 *	 This program is free software; you can redistribute it and/or modify  *
 *	 it under the terms of the GNU General Public License as published by  *
 *	 the Free Software Foundation; either version 2 of the License, or	   *
 *	 (at your option) any later version.								   *
 *																		   *
 *	 This program is distributed in the hope that it will be useful,	   *
 *	 but WITHOUT ANY WARRANTY; without even the implied warranty of 	   *
 *	 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the		   *
 *	 GNU General Public License for more details.						   *
 *																		   *
 *	 You should have received a copy of the GNU General Public License	   *
 *	 along with this program; if not, write to the						   *
 *	 Free Software Foundation, Inc.,									   *
 *	 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.			   *
 ***************************************************************************/

#ifndef syslogconfig_include
#define syslogconfig_include

#include "tokenizer.h"
#include <map>


class SYSLOGCONFIG;

typedef SYSLOGCONFIG *			SYSLOGCONFIGP;
typedef list<SYSLOGCONFIGP> 	syslogconfig_list;
enum parser_style {cisco, ssh};

class SYSLOGCONFIG {
	char *			file_name;	// name of the syslog file
	parser_style	parser;
public:
	SYSLOGCONFIG(char *file_name_, parser_style parser_);
	~SYSLOGCONFIG();
	void	dump(int level);
};

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;
	syslogconfig_list	syslogconfigs;		 // owns all the syslogconfigs, not just top level syslogconfigs

	CONFIG();
	~CONFIG();
	void		add_syslogconfig(SYSLOGCONFIGP con);
	void		dump();
};

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();

extern char *token_cisco;
extern char *token_file;
extern char *token_include;
extern char *token_lbrace;
extern char *token_parser;
extern char *token_rbrace;
extern char *token_semi;
extern char *token_ssh;

#endif