2 * collectd - src/configfile.h
3 * Copyright (C) 2005,2006 Florian octo Forster
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.
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.
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
20 * Florian octo Forster <octo at verplant.org>
28 * Remove a registered plugin from the internal data structures.
31 * `type' Name of the plugin (must be the same as passed to
34 void cf_unregister (char *type);
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.
43 * `type' Name of the plugin (must be the same as passed to
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
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-
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.
60 void cf_register (char *type,
61 int (*callback) (char *, char *),
62 char **keys, int keys_num);
66 * `cf_get_option' returns various general options.
69 * `key' Name of the option to query.
70 * `def' Pointer to return as default value.
73 * The pointer returned is part of an internal structure and may not be
74 * changed. If the option is not found for whatever reason (wrong key, option
75 * not allowed for currently selected mode, ...) `NULL' is returned.
77 char *cf_get_option (const char *key, char *def);
81 * `cf_read' reads the config file `filename' and dispatches the read
82 * information to functions/variables. Most important: Is calls `plugin_load'
83 * to load specific plugins, depending on the current mode of operation.
86 * `filename' An additional filename to look for. This function calls
87 * `lc_process' which already searches many standard locations..
88 * If set to NULL will use the `CONFIGFILE' define.
91 * Returns zero upon success and non-zero otherwise. A error-message will have
92 * been printed in this case.
94 int cf_read (char *filename);
96 #endif /* defined(CONFIGFILE_H) */