1 /**
2 * collectd - src/configfile.h
3 * Copyright (C) 2005 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 **/
23 #ifndef CONFIGFILE_H
24 #define CONFIGFILE_H
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 (char *type);
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 * `<Module $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 (char *type,
61 int (*callback) (char *, char *),
62 char **keys, int keys_num);
64 /*
65 * DESCRIPTION
66 * `cf_get_mode_option' returns options from the <Mode> section(s).
67 *
68 * PARAMETERS
69 * `key' Name of the option to query.
70 *
71 * RETURN VALUE
72 * The pointer returned is part of an internal structure and may not be
73 * changed. If the option is not found for whatever reason (wrong key, option
74 * not allowed for currently selected mode, ...) `NULL' is returned.
75 */
76 char *cf_get_mode_option (const char *key);
78 /*
79 * DESCRIPTION
80 * `cf_read' reads the config file `filename' and dispatches the read
81 * information to functions/variables. Most important: Is calls `plugin_load'
82 * to load specific plugins, depending on the current mode of operation.
83 *
84 * RETURN VALUE
85 * Returns zero upon success and non-zero otherwise. A error-message will have
86 * been printed in this case.
87 */
88 int cf_read (char *filename);
90 #endif /* defined(CONFIGFILE_H) */