src/common.c: move read_file_contents() from thermal plugin
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
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;
+}
+
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 */
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];