From cd98358e0b15d5a987c120299d39ba72d68d3de7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Miros=C5=82aw?= Date: Sat, 21 Jun 2008 22:21:07 +0200 Subject: [PATCH] src/common.c: Move read_file_contents() to here. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit src/common.c: move read_file_contents() from thermal plugin Signed-off-by: Michał Mirosław Signed-off-by: Florian Forster --- src/common.c | 14 ++++++++++++++ src/common.h | 1 + src/thermal.c | 14 -------------- 3 files changed, 15 insertions(+), 14 deletions(-) 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]; -- 2.11.0