Merge pull request #1308 from mfournier/openldap-persistent-connection
[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 #include "plugin.h"
32
33 #define FC_MATCH_NO_MATCH  0
34 #define FC_MATCH_MATCHES   1
35
36 #define FC_TARGET_CONTINUE 0
37 #define FC_TARGET_STOP     1
38 #define FC_TARGET_RETURN   2
39
40 /*
41  * Match functions
42  */
43 struct match_proc_s
44 {
45   int (*create) (const oconfig_item_t *ci, void **user_data);
46   int (*destroy) (void **user_data);
47   int (*match) (const data_set_t *ds, const value_list_t *vl,
48       notification_meta_t **meta, void **user_data);
49 };
50 typedef struct match_proc_s match_proc_t;
51
52 int fc_register_match (const char *name, match_proc_t proc);
53
54 /*
55  * Target functions
56  */
57 struct target_proc_s
58 {
59   int (*create) (const oconfig_item_t *ci, void **user_data);
60   int (*destroy) (void **user_data);
61   int (*invoke) (const data_set_t *ds, value_list_t *vl,
62       notification_meta_t **meta, void **user_data);
63 };
64 typedef struct target_proc_s target_proc_t;
65
66 struct fc_chain_s;
67 typedef struct fc_chain_s fc_chain_t;
68
69 int fc_register_target (const char *name, target_proc_t proc);
70
71 /*
72  * TODO: Chain management
73  */
74 #if 0
75 int fc_chain_add (const char *chain_name,
76     const char *target_name, int target_argc, char **target_argv);
77 int fc_chain_delete (const char *chain_name);
78 #endif
79
80 /*
81  * TODO: Rule management
82  */
83 #if 0
84 int fc_rule_add (const char *chain_name, int position,
85     int match_num, const char **match_name, int *match_argc, char ***match_argv,
86     const char *target_name, int target_argc, char **target_argv);
87 int fc_rule_delete (const char *chain_name, int position);
88 #endif
89
90 /*
91  * Processing function
92  */
93 fc_chain_t *fc_chain_get_by_name (const char *chain_name);
94
95 int fc_process_chain (const data_set_t *ds, value_list_t *vl,
96     fc_chain_t *chain);
97
98 int fc_default_action (const data_set_t *ds, value_list_t *vl);
99
100 /*
101  * Shortcut for global configuration
102  */
103 int fc_configure (const oconfig_item_t *ci);
104
105 #endif /* FILTER_CHAIN_H */
106 /* vim: set sw=2 sts=2 et : */