annotate src/syslogconfig.h @ 2:6e88da080f08

initial coding
author carl
date Thu, 24 Nov 2005 10:31:09 -0800
parents 551433a01cab
children 8fe310e5cd44
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};
2
6e88da080f08 initial coding
carl
parents: 1
diff changeset
33 const int buflen = 1024;
1
551433a01cab initial coding
carl
parents:
diff changeset
34
551433a01cab initial coding
carl
parents:
diff changeset
35 class SYSLOGCONFIG {
551433a01cab initial coding
carl
parents:
diff changeset
36 char * file_name; // name of the syslog file
551433a01cab initial coding
carl
parents:
diff changeset
37 parser_style parser;
2
6e88da080f08 initial coding
carl
parents: 1
diff changeset
38 int fd;
6e88da080f08 initial coding
carl
parents: 1
diff changeset
39 int len; // bytes in the buffer
6e88da080f08 initial coding
carl
parents: 1
diff changeset
40 char buf[buflen];
1
551433a01cab initial coding
carl
parents:
diff changeset
41 public:
2
6e88da080f08 initial coding
carl
parents: 1
diff changeset
42 SYSLOGCONFIG(TOKEN &tok, char *file_name_, parser_style parser_);
1
551433a01cab initial coding
carl
parents:
diff changeset
43 ~SYSLOGCONFIG();
551433a01cab initial coding
carl
parents:
diff changeset
44 void dump(int level);
2
6e88da080f08 initial coding
carl
parents: 1
diff changeset
45 bool failed() { return (fd == -1); };
6e88da080f08 initial coding
carl
parents: 1
diff changeset
46 void read();
6e88da080f08 initial coding
carl
parents: 1
diff changeset
47 void process();
1
551433a01cab initial coding
carl
parents:
diff changeset
48 };
551433a01cab initial coding
carl
parents:
diff changeset
49
551433a01cab initial coding
carl
parents:
diff changeset
50 struct CONFIG {
551433a01cab initial coding
carl
parents:
diff changeset
51 // the only mutable stuff once it has been loaded from the config file
551433a01cab initial coding
carl
parents:
diff changeset
52 int reference_count; // protected by the global config_mutex
551433a01cab initial coding
carl
parents:
diff changeset
53 // all the rest is constant after loading from the config file
551433a01cab initial coding
carl
parents:
diff changeset
54 int generation;
551433a01cab initial coding
carl
parents:
diff changeset
55 time_t load_time;
551433a01cab initial coding
carl
parents:
diff changeset
56 string_set config_files;
551433a01cab initial coding
carl
parents:
diff changeset
57 syslogconfig_list syslogconfigs; // owns all the syslogconfigs, not just top level syslogconfigs
551433a01cab initial coding
carl
parents:
diff changeset
58
551433a01cab initial coding
carl
parents:
diff changeset
59 CONFIG();
551433a01cab initial coding
carl
parents:
diff changeset
60 ~CONFIG();
2
6e88da080f08 initial coding
carl
parents: 1
diff changeset
61 void add_syslogconfig(SYSLOGCONFIGP con);
6e88da080f08 initial coding
carl
parents: 1
diff changeset
62 void dump();
6e88da080f08 initial coding
carl
parents: 1
diff changeset
63 void read();
1
551433a01cab initial coding
carl
parents:
diff changeset
64 };
551433a01cab initial coding
carl
parents:
diff changeset
65
551433a01cab initial coding
carl
parents:
diff changeset
66 void discard(string_set &s);
551433a01cab initial coding
carl
parents:
diff changeset
67 char* register_string(string_set &s, char *name);
551433a01cab initial coding
carl
parents:
diff changeset
68 char* register_string(char *name);
551433a01cab initial coding
carl
parents:
diff changeset
69 CONFIG *parse_config(char *fn);
551433a01cab initial coding
carl
parents:
diff changeset
70 bool load_conf(CONFIG &dc, char *fn);
551433a01cab initial coding
carl
parents:
diff changeset
71 void token_init();
551433a01cab initial coding
carl
parents:
diff changeset
72
551433a01cab initial coding
carl
parents:
diff changeset
73 extern char *token_cisco;
551433a01cab initial coding
carl
parents:
diff changeset
74 extern char *token_file;
551433a01cab initial coding
carl
parents:
diff changeset
75 extern char *token_include;
551433a01cab initial coding
carl
parents:
diff changeset
76 extern char *token_lbrace;
551433a01cab initial coding
carl
parents:
diff changeset
77 extern char *token_parser;
551433a01cab initial coding
carl
parents:
diff changeset
78 extern char *token_rbrace;
551433a01cab initial coding
carl
parents:
diff changeset
79 extern char *token_semi;
551433a01cab initial coding
carl
parents:
diff changeset
80 extern char *token_ssh;
551433a01cab initial coding
carl
parents:
diff changeset
81
551433a01cab initial coding
carl
parents:
diff changeset
82 #endif