[collectd] [PATCH 3/4] move read_file_contents() to src/common.c
Michał Mirosław
mirq-linux at rere.qmqm.pl
Sat Jun 21 22:21:07 CEST 2008
src/common.c: move read_file_contents() from thermal plugin
Signed-off-by: Michał Mirosław <mirq-linux at rere.qmqm.pl>
diff --git a/src/common.c b/src/common.c
--- 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 ca34e78..a5e2167 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 29ea05f..9378132 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];
More information about the collectd
mailing list