annotate src/syslogconfig.h @ 1:551433a01cab

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