3952c180d9949f08bc42a94899d23a9c19a5db70
[collectd.git] / src / configfile.h
1 #ifndef CONFIGFILE_H
2 #define CONFIGFILE_H
3 /**
4  * collectd - src/configfile.h
5  * Copyright (C) 2005,2006  Florian octo Forster
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation; either version 2 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
20  *
21  * Authors:
22  *   Florian octo Forster <octo at verplant.org>
23  **/
24
25 #include "collectd.h"
26 #include "liboconfig/oconfig.h"
27
28 /*
29  * DESCRIPTION
30  *  Remove a registered plugin from the internal data structures.
31  * 
32  * PARAMETERS
33  *  `type'      Name of the plugin (must be the same as passed to
34  *              `plugin_register'
35  */
36 void cf_unregister (const char *type);
37 void cf_unregister_complex (const char *type);
38
39 /*
40  * DESCRIPTION
41  *  `cf_register' is called by plugins that wish to receive config keys. The
42  *  plugin will then receive all keys it registered for if they're found in a
43  *  `<Plugin $type>' section.
44  *
45  * PARAMETERS
46  *  `type'      Name of the plugin (must be the same as passed to
47  *              `plugin_register'
48  *  `callback'  Pointer to the callback function. The callback must return zero
49  *              upon success, a value smaller than zero if it doesn't know how
50  *              to handle the `key' passed to it (the first argument) or a
51  *              value greater than zero if it knows how to handle the key but
52  *              failed.
53  *  `keys'      Array of key values this plugin wished to receive. The last
54  *              element must be a NULL-pointer.
55  *  `keys_num'  Number of elements in the array (not counting the last NULL-
56  *              pointer.
57  *
58  * NOTES
59  *  `cf_unregister' will be called for `type' to make sure only one record
60  *  exists for each `type' at any time. This means that `cf_register' may be
61  *  called multiple times, but only the last call will have an effect.
62  */
63 void cf_register (const char *type,
64                 int (*callback) (const char *, const char *),
65                 const char **keys, int keys_num);
66
67 int cf_register_complex (const char *type, int (*callback) (oconfig_item_t *));
68
69 /*
70  * DESCRIPTION
71  *  `cf_read' reads the config file `filename' and dispatches the read
72  *  information to functions/variables. Most important: Is calls `plugin_load'
73  *  to load specific plugins, depending on the current mode of operation.
74  *
75  * PARAMETERS
76  *  `filename'  An additional filename to look for. This function calls
77  *              `lc_process' which already searches many standard locations..
78  *              If set to NULL will use the `CONFIGFILE' define.
79  *
80  * RETURN VALUE
81  *  Returns zero upon success and non-zero otherwise. A error-message will have
82  *  been printed in this case.
83  */
84 int cf_read (char *filename);
85
86 int global_option_set (const char *option, const char *value);
87 const char *global_option_get (const char *option);
88
89 #endif /* defined(CONFIGFILE_H) */