summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Friloux <guillaume.friloux@gmail.com>2013-12-19 10:45:57 +0100
committerGuillaume Friloux <guillaume.friloux@gmail.com>2013-12-19 10:45:57 +0100
commitd380b49deef43c71de1c4353d4ab2c4c808da559 (patch)
treef2746bc4b9b2a86d77419e6270a32f8cd63b136e /src
parentdbb099df5455a2932b9ed3b12258cff8faca513b (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.
Diffstat (limited to 'src')
-rw-r--r--src/bin/Makefile.mk4
-rw-r--r--src/bin/filter.c10
-rw-r--r--src/bin/smman.h6
-rw-r--r--src/include/Rules.h30
-rw-r--r--src/lib/rules/rules_main.c1
-rw-r--r--src/lib/rules/rules_private.h26
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
7src_bin_smman_SOURCES = \ 7src_bin_smman_SOURCES = \
8src/bin/main.c \ 8src/bin/main.c \
9src/bin/config.c \ 9src/bin/config.c \
10src/bin/filter.c \
10src/bin/smman.h 11src/bin/smman.h
11src_bin_smman_CPPFLAGS = @BIN_CFLAGS@ $(EXTRA_CPPFLAGS) 12src_bin_smman_CPPFLAGS = @BIN_CFLAGS@ $(EXTRA_CPPFLAGS)
12src_bin_smman_LDFLAGS = @BIN_LIBS@ 13src_bin_smman_LDFLAGS = @BIN_LIBS@
13src_bin_smman_LDADD = \ 14src_bin_smman_LDADD = \
14src/lib/libconf.la 15src/lib/libconf.la \
16src/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
12void 17void
13filter_load_done(void *data, 18filter_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
11int smman_log_dom_global; 12int 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
31void config_done(void *data, Conf *conf); 31void config_done(void *data, Conf *conf);
32void config_error(void *data, Conf *conf, const char *errstr); 32void config_error(void *data, Conf *conf, const char *errstr);
33
34void filter_load(void *data, Rules *rules, Rule *rule);
35void filter_load_done(void *data, Rules *rules);
36void 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
8typedef struct _Rules Rules; 11typedef struct _Rules Rules;
9typedef struct _Rule Rule; 12typedef struct _Rule Rule;
10 13
14struct _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
31typedef 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
11typedef void (*Rules_Progress_Cb)(void *data, Rules *rules, Rule *rule); 40typedef void (*Rules_Progress_Cb)(void *data, Rules *rules, Rule *rule);
12typedef void (*Rules_Done_Cb)(void *data, Rules *rules); 41typedef void (*Rules_Done_Cb)(void *data, Rules *rules);
13typedef void (*Rules_Error_Cb)(void *data, Rules *rules, const char *errstr); 42typedef void (*Rules_Error_Cb)(void *data, Rules *rules, const char *errstr);
@@ -16,5 +45,6 @@ int rules_init(void);
16int rules_shutdown(void); 45int rules_shutdown(void);
17 46
18Rules * rules_new(const char *directory); 47Rules * rules_new(const char *directory);
48Eina_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
15Eina_Bool 16Eina_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
5extern int _rules_log_dom_global; 3extern 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
19struct _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
36typedef struct _Rule_Regex
37{
38 const char *regex;
39 Eina_Bool must_match;
40 regex_t preg;
41} Rule_Regex;
42
43typedef struct _Rules_Load 17typedef struct _Rules_Load
44{ 18{
45 Rules *rules; 19 Rules *rules;