0a0305eda5488c54303d811a66e543527cf638e0
[collectd.git] / src / utils_fbhash.h
1 /**
2  * collectd - src/utils_fbhash.h
3  * Copyright (C) 2009  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; only version 2 of the License is applicable.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
17  *
18  * Authors:
19  *   Florian octo Forster <octo at verplant.org>
20  **/
21
22 #ifndef UTILS_FBHASH_H
23 #define UTILS_FBHASH_H 1
24
25 /*
26  * File-backed hash
27  *
28  * This module reads a file of the form
29  *   key: value
30  * into a hash, which can then be queried. The file is given to `fbh_create',
31  * the hash is queried using `fbh_get'. If the file is changed during runtime,
32  * it will automatically be re-read.
33  */
34
35 struct fbhash_s;
36 typedef struct fbhash_s fbhash_t;
37
38 fbhash_t *fbh_create (const char *file);
39 void fbh_destroy (fbhash_t *h);
40
41 /* Returns the value as a newly allocated `char *'. It's the caller's
42  * responsibility to free this memory. */
43 char *fbh_get (fbhash_t *h, const char *key);
44
45 #endif /* UTILS_FBHASH_H */
46
47 /* vim: set sw=2 sts=2 et fdm=marker : */