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