diff src/syslogconfig.h @ 4:2737ab01659a

initial coding
author carl
date Thu, 01 Dec 2005 17:17:37 -0800
parents 8fe310e5cd44
children d76f9ff42487
line wrap: on
line diff
--- a/src/syslogconfig.h	Sun Nov 27 21:12:01 2005 -0800
+++ b/src/syslogconfig.h	Thu Dec 01 17:17:37 2005 -0800
@@ -24,6 +24,8 @@
 #include "tokenizer.h"
 #include <map>
 #include <regex.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 
 
 class SYSLOGCONFIG;
@@ -39,10 +41,10 @@
 	char *			pattern;	// owned by the string table
 	regex_t 		re;
 	int 			index;		// zero based substring of the regex match that contains the ip address or hostname
-	int 			bucket; 	// count to add to the ip address leaky bucket
+	int 			amount; 	// count to add to the ip address leaky bucket
 public:
 	~PATTERN();
-	PATTERN(TOKEN &tok, char *pattern_, int index_, int bucket_);
+	PATTERN(TOKEN &tok, char *pattern_, int index_, int amount_);
 	bool	process(char *buf, CONFIG &con);
 	void	dump(int level);
 };
@@ -55,17 +57,21 @@
 const int buflen = 1024;
 
 class SYSLOGCONFIG {
+	TOKEN * 		tokp;
 	char *			file_name;	// name of the syslog file
 	pattern_list	patterns;	// owns the patterns
 	int 			fd;
+	struct stat 	openfdstat;
 	int 			len;		// bytes in the buffer
 	char			buf[buflen];
 public:
 	SYSLOGCONFIG(TOKEN &tok, char *file_name_);
 	~SYSLOGCONFIG();
+	bool	failed()	{ return (fd == -1); };
+	void	open(bool msg);
+	bool	read(CONFIG &con);
+	void	close();
 	void	add_pattern(PATTERNP pat);
-	bool	failed()	{ return (fd == -1); };
-	bool	read(CONFIG &con);
 	void	process(CONFIG &con);
 	void	dump(int level);
 };
@@ -90,7 +96,7 @@
 	void	add_pair(IPPAIR pair);
 	void	dump();
 	void	read();
-	void	sleep(int duration);
+	void	sleep(int duration, time_t &previous);
 	bool	looking(int ip);
 };