1
|
1 /***************************************************************************
|
|
2 * Copyright (C) 2005 by 510 Software Group *
|
|
3 * *
|
|
4 * *
|
|
5 * This program is free software; you can redistribute it and/or modify *
|
|
6 * it under the terms of the GNU General Public License as published by *
|
|
7 * the Free Software Foundation; either version 2 of the License, or *
|
|
8 * (at your option) any later version. *
|
|
9 * *
|
|
10 * This program is distributed in the hope that it will be useful, *
|
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
13 * GNU General Public License for more details. *
|
|
14 * *
|
|
15 * You should have received a copy of the GNU General Public License *
|
|
16 * along with this program; if not, write to the *
|
|
17 * Free Software Foundation, Inc., *
|
|
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
19 ***************************************************************************/
|
|
20
|
|
21 #ifndef syslogconfig_include
|
|
22 #define syslogconfig_include
|
|
23
|
|
24 #include "tokenizer.h"
|
|
25 #include <map>
|
|
26
|
|
27
|
|
28 class SYSLOGCONFIG;
|
|
29
|
|
30 typedef SYSLOGCONFIG * SYSLOGCONFIGP;
|
|
31 typedef list<SYSLOGCONFIGP> syslogconfig_list;
|
|
32 enum parser_style {cisco, ssh};
|
2
|
33 const int buflen = 1024;
|
1
|
34
|
|
35 class SYSLOGCONFIG {
|
|
36 char * file_name; // name of the syslog file
|
|
37 parser_style parser;
|
2
|
38 int fd;
|
|
39 int len; // bytes in the buffer
|
|
40 char buf[buflen];
|
1
|
41 public:
|
2
|
42 SYSLOGCONFIG(TOKEN &tok, char *file_name_, parser_style parser_);
|
1
|
43 ~SYSLOGCONFIG();
|
|
44 void dump(int level);
|
2
|
45 bool failed() { return (fd == -1); };
|
|
46 void read();
|
|
47 void process();
|
1
|
48 };
|
|
49
|
|
50 struct CONFIG {
|
|
51 // the only mutable stuff once it has been loaded from the config file
|
|
52 int reference_count; // protected by the global config_mutex
|
|
53 // all the rest is constant after loading from the config file
|
|
54 int generation;
|
|
55 time_t load_time;
|
|
56 string_set config_files;
|
|
57 syslogconfig_list syslogconfigs; // owns all the syslogconfigs, not just top level syslogconfigs
|
|
58
|
|
59 CONFIG();
|
|
60 ~CONFIG();
|
2
|
61 void add_syslogconfig(SYSLOGCONFIGP con);
|
|
62 void dump();
|
|
63 void read();
|
1
|
64 };
|
|
65
|
|
66 void discard(string_set &s);
|
|
67 char* register_string(string_set &s, char *name);
|
|
68 char* register_string(char *name);
|
|
69 CONFIG *parse_config(char *fn);
|
|
70 bool load_conf(CONFIG &dc, char *fn);
|
|
71 void token_init();
|
|
72
|
|
73 extern char *token_cisco;
|
|
74 extern char *token_file;
|
|
75 extern char *token_include;
|
|
76 extern char *token_lbrace;
|
|
77 extern char *token_parser;
|
|
78 extern char *token_rbrace;
|
|
79 extern char *token_semi;
|
|
80 extern char *token_ssh;
|
|
81
|
|
82 #endif
|