Merged changes on `common.[ch]' from quota-branch to trunk
[collectd.git] / src / common.h
1 /**
2  * collectd - src/common.h
3  * Copyright (C) 2005  Florian octo Forster
4  *
5  * This program is free software; you can redistribute it and/
6  * or modify it under the terms of the GNU General Public Li-
7  * cence as published by the Free Software Foundation; either
8  * version 2 of the Licence, or any later version.
9  *
10  * This program is distributed in the hope that it will be use-
11  * ful, but WITHOUT ANY WARRANTY; without even the implied war-
12  * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public Licence for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * Licence along with this program; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
18  * USA.
19  *
20  * Authors:
21  *   Florian octo Forster <octo at verplant.org>
22  *   Niki W. Waibel <niki.waibel@gmx.net>
23 **/
24
25 #ifndef COMMON_H
26 #define COMMON_H
27
28 #include "collectd.h"
29
30 #define sfree(ptr) \
31         if((ptr) != NULL) { \
32                 free(ptr); \
33         } \
34         (ptr) = NULL
35
36 void sstrncpy(char *d, const char *s, int len);
37 char *sstrdup(const char *s);
38 void *smalloc(size_t size);
39
40 int strsplit (char *string, char **fields, size_t size);
41
42 int rrd_update_file (char *host, char *file, char *values, char **ds_def,
43                 int ds_num);
44
45 #ifdef HAVE_LIBKSTAT
46 int get_kstat (kstat_t **ksp_ptr, char *module, int instance, char *name);
47 long long get_kstat_value (kstat_t *ksp, char *name);
48 #endif
49
50 #endif /* COMMON_H */