From: Michał Mirosław Date: Sat, 21 Jun 2008 20:21:07 +0000 (+0200) Subject: src/common.c: Move read_file_contents() to here. X-Git-Tag: collectd-4.5.0~108 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=cd98358e0b15d5a987c120299d39ba72d68d3de7;p=collectd.git src/common.c: Move read_file_contents() to here. src/common.c: move read_file_contents() from thermal plugin Signed-off-by: Michał Mirosław Signed-off-by: Florian Forster --- diff --git a/src/common.c b/src/common.c index 39436178..bdab108c 100644 --- a/src/common.c +++ b/src/common.c @@ -893,4 +893,18 @@ int walk_directory (const char *dir, dirwalk_callback_f callback) return ok ? 0 : -1; } +int read_file_contents (const char *filename, char *buf, int bufsize) +{ + FILE *fh; + int n; + + if ((fh = fopen (filename, "r")) == NULL) + return -1; + + n = fread(buf, 1, bufsize, fh); + fclose(fh); + + return n; +} + diff --git a/src/common.h b/src/common.h index ca34e781..a5e2167b 100644 --- a/src/common.h +++ b/src/common.h @@ -203,5 +203,6 @@ int notification_init (notification_t *n, int severity, const char *message, typedef int (*dirwalk_callback_f)(const char *filename); int walk_directory (const char *dir, dirwalk_callback_f callback); +int read_file_contents (const char *filename, char *buf, int bufsize); #endif /* COMMON_H */ diff --git a/src/thermal.c b/src/thermal.c index 29ea05f5..93781328 100644 --- a/src/thermal.c +++ b/src/thermal.c @@ -61,20 +61,6 @@ static void thermal_submit (const char *plugin_instance, enum dev_type dt, plugin_dispatch_values (&vl); } -static int read_file_contents (const char *filename, char *buf, int bufsize) -{ - FILE *fh; - int n; - - if ((fh = fopen (filename, "r")) == NULL) - return -1; - - n = fread(buf, 1, bufsize, fh); - fclose(fh); - - return n; -} - static int thermal_sysfs_device_read (const char *name) { char filename[256];