diff options
author | Guillaume Friloux <guillaume.friloux@gmail.com> | 2013-12-19 10:45:57 +0100 |
---|---|---|
committer | Guillaume Friloux <guillaume.friloux@gmail.com> | 2013-12-19 10:45:57 +0100 |
commit | d380b49deef43c71de1c4353d4ab2c4c808da559 (patch) | |
tree | f2746bc4b9b2a86d77419e6270a32f8cd63b136e | |
parent | dbb099df5455a2932b9ed3b12258cff8faca513b (diff) |
Smman can now load its conf file and fake loading of rules.
Next step is to compile regexes and find log files to watch.
-rw-r--r-- | src/bin/Makefile.mk | 4 | ||||
-rw-r--r-- | src/bin/filter.c | 10 | ||||
-rw-r--r-- | src/bin/smman.h | 6 | ||||
-rw-r--r-- | src/include/Rules.h | 30 | ||||
-rw-r--r-- | src/lib/rules/rules_main.c | 1 | ||||
-rw-r--r-- | src/lib/rules/rules_private.h | 26 |
6 files changed, 49 insertions, 28 deletions
diff --git a/src/bin/Makefile.mk b/src/bin/Makefile.mk index 169a3ff..6ab1a81 100644 --- a/src/bin/Makefile.mk +++ b/src/bin/Makefile.mk | |||
@@ -7,8 +7,10 @@ src/bin/smman | |||
7 | src_bin_smman_SOURCES = \ | 7 | src_bin_smman_SOURCES = \ |
8 | src/bin/main.c \ | 8 | src/bin/main.c \ |
9 | src/bin/config.c \ | 9 | src/bin/config.c \ |
10 | src/bin/filter.c \ | ||
10 | src/bin/smman.h | 11 | src/bin/smman.h |
11 | src_bin_smman_CPPFLAGS = @BIN_CFLAGS@ $(EXTRA_CPPFLAGS) | 12 | src_bin_smman_CPPFLAGS = @BIN_CFLAGS@ $(EXTRA_CPPFLAGS) |
12 | src_bin_smman_LDFLAGS = @BIN_LIBS@ | 13 | src_bin_smman_LDFLAGS = @BIN_LIBS@ |
13 | src_bin_smman_LDADD = \ | 14 | src_bin_smman_LDADD = \ |
14 | src/lib/libconf.la | 15 | src/lib/libconf.la \ |
16 | src/lib/librules.la | ||
diff --git a/src/bin/filter.c b/src/bin/filter.c index f5095ed..83d51ac 100644 --- a/src/bin/filter.c +++ b/src/bin/filter.c | |||
@@ -5,16 +5,26 @@ filter_load(void *data, | |||
5 | Rules *rules, | 5 | Rules *rules, |
6 | Rule *rule) | 6 | Rule *rule) |
7 | { | 7 | { |
8 | Smman *smman; | ||
8 | 9 | ||
10 | smman = data; | ||
11 | if (smman->rules != rules) | ||
12 | return; | ||
9 | 13 | ||
14 | DBG("smman[%p] rules[%p] rule[%p][%s]", smman, rules, rule, rule->name); | ||
10 | } | 15 | } |
11 | 16 | ||
12 | void | 17 | void |
13 | filter_load_done(void *data, | 18 | filter_load_done(void *data, |
14 | Rules *rules) | 19 | Rules *rules) |
15 | { | 20 | { |
21 | Smman *smman; | ||
16 | 22 | ||
23 | smman = data; | ||
24 | if (smman->rules != rules) | ||
25 | return; | ||
17 | 26 | ||
27 | DBG("smman[%p] rules[%p]", smman, rules); | ||
18 | } | 28 | } |
19 | 29 | ||
20 | 30 | ||
diff --git a/src/bin/smman.h b/src/bin/smman.h index 62a273d..a532b86 100644 --- a/src/bin/smman.h +++ b/src/bin/smman.h | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <Ecore_Getopt.h> | 7 | #include <Ecore_Getopt.h> |
8 | #include <Eio.h> | 8 | #include <Eio.h> |
9 | #include <Conf.h> | 9 | #include <Conf.h> |
10 | #include <Rules.h> | ||
10 | 11 | ||
11 | int smman_log_dom_global; | 12 | int smman_log_dom_global; |
12 | 13 | ||
@@ -27,6 +28,9 @@ typedef struct _Smman | |||
27 | #define WRN(...) EINA_LOG_DOM_WARN(smman_log_dom_global, __VA_ARGS__) | 28 | #define WRN(...) EINA_LOG_DOM_WARN(smman_log_dom_global, __VA_ARGS__) |
28 | #define CRI(...) EINA_LOG_DOM_CRIT(smman_log_dom_global, __VA_ARGS__) | 29 | #define CRI(...) EINA_LOG_DOM_CRIT(smman_log_dom_global, __VA_ARGS__) |
29 | 30 | ||
30 | |||
31 | void config_done(void *data, Conf *conf); | 31 | void config_done(void *data, Conf *conf); |
32 | void config_error(void *data, Conf *conf, const char *errstr); | 32 | void config_error(void *data, Conf *conf, const char *errstr); |
33 | |||
34 | void filter_load(void *data, Rules *rules, Rule *rule); | ||
35 | void filter_load_done(void *data, Rules *rules); | ||
36 | void filter_load_error(void *data, Rules *rules, const char *errstr); | ||
diff --git a/src/include/Rules.h b/src/include/Rules.h index 6bd964d..0c6fad9 100644 --- a/src/include/Rules.h +++ b/src/include/Rules.h | |||
@@ -5,9 +5,38 @@ | |||
5 | #include <Eio.h> | 5 | #include <Eio.h> |
6 | #include <Conf.h> | 6 | #include <Conf.h> |
7 | 7 | ||
8 | #include <sys/types.h> | ||
9 | #include <regex.h> | ||
10 | |||
8 | typedef struct _Rules Rules; | 11 | typedef struct _Rules Rules; |
9 | typedef struct _Rule Rule; | 12 | typedef struct _Rule Rule; |
10 | 13 | ||
14 | struct _Rule | ||
15 | { | ||
16 | EINA_INLIST; | ||
17 | const char *name; | ||
18 | |||
19 | struct | ||
20 | { | ||
21 | const char *filename, | ||
22 | *type, | ||
23 | *source_host, | ||
24 | *source_path, | ||
25 | *tags; | ||
26 | Eina_Bool todel; | ||
27 | Eina_Inlist *regex; | ||
28 | } spec; | ||
29 | }; | ||
30 | |||
31 | typedef struct _Rule_Regex | ||
32 | { | ||
33 | EINA_INLIST; | ||
34 | const char *regex; | ||
35 | Eina_Bool must_match; | ||
36 | regex_t preg; | ||
37 | } Rule_Regex; | ||
38 | |||
39 | |||
11 | typedef void (*Rules_Progress_Cb)(void *data, Rules *rules, Rule *rule); | 40 | typedef void (*Rules_Progress_Cb)(void *data, Rules *rules, Rule *rule); |
12 | typedef void (*Rules_Done_Cb)(void *data, Rules *rules); | 41 | typedef void (*Rules_Done_Cb)(void *data, Rules *rules); |
13 | typedef void (*Rules_Error_Cb)(void *data, Rules *rules, const char *errstr); | 42 | typedef void (*Rules_Error_Cb)(void *data, Rules *rules, const char *errstr); |
@@ -16,5 +45,6 @@ int rules_init(void); | |||
16 | int rules_shutdown(void); | 45 | int rules_shutdown(void); |
17 | 46 | ||
18 | Rules * rules_new(const char *directory); | 47 | Rules * rules_new(const char *directory); |
48 | Eina_Bool rules_load(Rules *rules, Rules_Progress_Cb progress_cb, Rules_Done_Cb done_cb, Rules_Error_Cb error_cb, void *data); | ||
19 | 49 | ||
20 | #endif | 50 | #endif |
diff --git a/src/lib/rules/rules_main.c b/src/lib/rules/rules_main.c index eb19723..3ea4746 100644 --- a/src/lib/rules/rules_main.c +++ b/src/lib/rules/rules_main.c | |||
@@ -10,6 +10,7 @@ rules_new(const char *directory) | |||
10 | 10 | ||
11 | rules = calloc(1, sizeof(Rules)); | 11 | rules = calloc(1, sizeof(Rules)); |
12 | rules->directory = strdup(directory); | 12 | rules->directory = strdup(directory); |
13 | return rules; | ||
13 | } | 14 | } |
14 | 15 | ||
15 | Eina_Bool | 16 | Eina_Bool |
diff --git a/src/lib/rules/rules_private.h b/src/lib/rules/rules_private.h index c4a370f..1d74d95 100644 --- a/src/lib/rules/rules_private.h +++ b/src/lib/rules/rules_private.h | |||
@@ -1,6 +1,4 @@ | |||
1 | #include <Rules.h> | 1 | #include <Rules.h> |
2 | #include <sys/types.h> | ||
3 | #include <regex.h> | ||
4 | 2 | ||
5 | extern int _rules_log_dom_global; | 3 | extern int _rules_log_dom_global; |
6 | 4 | ||
@@ -16,30 +14,6 @@ struct _Rules | |||
16 | Eina_Inlist *rules; | 14 | Eina_Inlist *rules; |
17 | }; | 15 | }; |
18 | 16 | ||
19 | struct _Rule | ||
20 | { | ||
21 | EINA_INLIST; | ||
22 | const char *name; | ||
23 | |||
24 | struct | ||
25 | { | ||
26 | const char *filename, | ||
27 | *type, | ||
28 | *source_host, | ||
29 | *source_path, | ||
30 | *tags; | ||
31 | Eina_Bool todel; | ||
32 | Eina_Inlist *regex; | ||
33 | } spec; | ||
34 | }; | ||
35 | |||
36 | typedef struct _Rule_Regex | ||
37 | { | ||
38 | const char *regex; | ||
39 | Eina_Bool must_match; | ||
40 | regex_t preg; | ||
41 | } Rule_Regex; | ||
42 | |||
43 | typedef struct _Rules_Load | 17 | typedef struct _Rules_Load |
44 | { | 18 | { |
45 | Rules *rules; | 19 | Rules *rules; |