Add a default configuration file name to
Subsystems (2)
PATCH 1/6 Add a default configuration file name to
Let libsensors know the default path to its configuration file. That way, applications no longer have to care.
--- Makefile | 4 ++-- lib/init.c | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-)
lib/init.c +20 -4
@@ -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 ;
Makefile +2 -2
@@ -144,9 +144,9 @@ ALL_CFLAGS += $(CFLAGS) PROGCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS) PROGCFLAGS := $(ALL_CFLAGS) -ARCPPFLAGS := $(ALL_CPPFLAGS) +ARCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS) ARCFLAGS := $(ALL_CFLAGS) -LIBCPPFLAGS := $(ALL_CPPFLAGS) +LIBCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS) LIBCFLAGS := -fpic -D_REENTRANT $(ALL_CFLAGS) .PHONY: all user clean install user_install uninstall user_uninstall
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors