summaryrefslogtreecommitdiff
path: root/lib/init.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-10-25 09:48:18 +0000
committerJean Delvare <khali@linux-fr.org>2007-10-25 09:48:18 +0000
commitfb920578a941024530e0b0f393c884c9092e8fa3 (patch)
tree73a4f88dfc67c36311a9534023ff4a3b157e3487 /lib/init.c
parentf7bc498fd00298c397549db39d23232e4a59b6ef (diff)
downloadlm-sensors-git-fb920578a941024530e0b0f393c884c9092e8fa3.tar.gz
Let libsensors know the default path to its configuration file.
That way, applications no longer have to care. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4985 7894878c-1315-0410-8ee3-d5d059ff63e0
Diffstat (limited to 'lib/init.c')
-rw-r--r--lib/init.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/init.c b/lib/init.c
index 5f80a274..15ad3a5a 100644
--- a/lib/init.c
+++ b/lib/init.c
@@ -29,6 +29,8 @@
#include "scanner.h"
#include "init.h"
+#define DEFAULT_CONFIG_FILE ETCDIR "/sensors.conf"
+
int sensors_init(FILE *input)
{
int res;
@@ -38,10 +40,24 @@ int sensors_init(FILE *input)
if ((res = sensors_read_sysfs_bus()) ||
(res = sensors_read_sysfs_chips()))
return res;
- if ((res = sensors_scanner_init(input)))
- return -SENSORS_ERR_PARSE;
- if ((res = sensors_yyparse()))
- return -SENSORS_ERR_PARSE;
+
+ if (input) {
+ if (sensors_scanner_init(input) ||
+ sensors_yyparse())
+ return -SENSORS_ERR_PARSE;
+ } else {
+ /* No configuration provided, use default */
+ input = fopen(DEFAULT_CONFIG_FILE, "r");
+ if (!input)
+ return -SENSORS_ERR_PARSE;
+ if (sensors_scanner_init(input) ||
+ sensors_yyparse()) {
+ fclose(input);
+ return -SENSORS_ERR_PARSE;
+ }
+ fclose(input);
+ }
+
if ((res = sensors_substitute_busses()))
return res;
return 0;