Merge branch 'collectd-4.5'
[collectd.git] / src / filter_chain.h
1 /**
2  * collectd - src/filter_chain.h
3  * Copyright (C) 2008  Florian octo Forster
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; only version 2 of the License is applicable.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
17  *
18  * Authors:
19  *   Florian octo Forster <octo at verplant.org>
20  **/
21
22 #ifndef FILTER_CHAIN_H
23 #define FILTER_CHAIN_H 1
24
25 #include "collectd.h"
26 #include "plugin.h"
27
28 #define FC_MATCH_NO_MATCH  0
29 #define FC_MATCH_MATCHES   1
30
31 #define FC_TARGET_CONTINUE 0
32 #define FC_TARGET_STOP     1
33 #define FC_TARGET_RETURN   2
34
35 /*
36  * Match functions
37  */
38 struct match_proc_s
39 {
40   int (*create) (const oconfig_item_t *ci, void **user_data);
41   int (*destroy) (void **user_data);
42   int (*match) (const data_set_t *ds, const value_list_t *vl,
43       notification_meta_t **meta, void **user_data);
44 };
45 typedef struct match_proc_s match_proc_t;
46
47 int fc_register_match (const char *name, match_proc_t proc);
48
49 /*
50  * Target functions
51  */
52 struct target_proc_s
53 {
54   int (*create) (const oconfig_item_t *ci, void **user_data);
55   int (*destroy) (void **user_data);
56   int (*invoke) (const data_set_t *ds, value_list_t *vl,
57       notification_meta_t **meta, void **user_data);
58 };
59 typedef struct target_proc_s target_proc_t;
60
61 int fc_register_target (const char *name, target_proc_t proc);
62
63 /*
64  * TODO: Chain management
65  */
66 #if 0
67 int fc_chain_add (const char *chain_name,
68     const char *target_name, int target_argc, char **target_argv);
69 int fc_chain_delete (const char *chain_name);
70 #endif
71
72 /*
73  * TODO: Rule management
74  */
75 #if 0
76 int fc_rule_add (const char *chain_name, int position,
77     int match_num, const char **match_name, int *match_argc, char ***match_argv,
78     const char *target_name, int target_argc, char **target_argv);
79 int fc_rule_delete (const char *chain_name, int position);
80 #endif
81
82 /*
83  * Processing function
84  */
85 int fc_process (const data_set_t *ds, value_list_t *vl);
86
87 /* 
88  * Shortcut for global configuration
89  */
90 int fc_configure (const oconfig_item_t *ci);
91
92 #endif /* FILTER_CHAIN_H */
93 /* vim: set sw=2 sts=2 et : */