Merge branch 'collectd-5.5' into collectd-5.6
[collectd.git] / src / daemon / filter_chain.h
1 /**
2  * collectd - src/filter_chain.h
3  * Copyright (C) 2008,2009  Florian octo Forster
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  * Authors:
24  *   Florian octo Forster <octo at collectd.org>
25  **/
26
27 #ifndef FILTER_CHAIN_H
28 #define FILTER_CHAIN_H 1
29
30 #include "collectd.h"
31
32 #include "plugin.h"
33
34 #define FC_MATCH_NO_MATCH  0
35 #define FC_MATCH_MATCHES   1
36
37 #define FC_TARGET_CONTINUE 0
38 #define FC_TARGET_STOP     1
39 #define FC_TARGET_RETURN   2
40
41 /*
42  * Match functions
43  */
44 struct match_proc_s
45 {
46   int (*create) (const oconfig_item_t *ci, void **user_data);
47   int (*destroy) (void **user_data);
48   int (*match) (const data_set_t *ds, const value_list_t *vl,
49       notification_meta_t **meta, void **user_data);
50 };
51 typedef struct match_proc_s match_proc_t;
52
53 int fc_register_match (const char *name, match_proc_t proc);
54
55 /*
56  * Target functions
57  */
58 struct target_proc_s
59 {
60   int (*create) (const oconfig_item_t *ci, void **user_data);
61   int (*destroy) (void **user_data);
62   int (*invoke) (const data_set_t *ds, value_list_t *vl,
63       notification_meta_t **meta, void **user_data);
64 };
65 typedef struct target_proc_s target_proc_t;
66
67 struct fc_chain_s;
68 typedef struct fc_chain_s fc_chain_t;
69
70 int fc_register_target (const char *name, target_proc_t proc);
71
72 /*
73  * TODO: Chain management
74  */
75 #if 0
76 int fc_chain_add (const char *chain_name,
77     const char *target_name, int target_argc, char **target_argv);
78 int fc_chain_delete (const char *chain_name);
79 #endif
80
81 /*
82  * TODO: Rule management
83  */
84 #if 0
85 int fc_rule_add (const char *chain_name, int position,
86     int match_num, const char **match_name, int *match_argc, char ***match_argv,
87     const char *target_name, int target_argc, char **target_argv);
88 int fc_rule_delete (const char *chain_name, int position);
89 #endif
90
91 /*
92  * Processing function
93  */
94 fc_chain_t *fc_chain_get_by_name (const char *chain_name);
95
96 int fc_process_chain (const data_set_t *ds, value_list_t *vl,
97     fc_chain_t *chain);
98
99 int fc_default_action (const data_set_t *ds, value_list_t *vl);
100
101 /*
102  * Shortcut for global configuration
103  */
104 int fc_configure (const oconfig_item_t *ci);
105
106 #endif /* FILTER_CHAIN_H */
107 /* vim: set sw=2 sts=2 et : */