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
This commit is contained in:
Jean Delvare committed 2007-10-25 09:48:18 +00:00
1 parent f7bc498fd0
commit fb920578a9
4 files changed
+34 -7

No files matched your search

+1
View File
@@ -2,6 +2,7 @@ lm-sensors CHANGES file
-----------------------
SVN HEAD
libsensors: Add a default configuration file
sensord: Reload config on SIGHUP rather than automatically
sensors: Fix file handle leak on library initialization error
Handle the case where voltage measurements aren't available
+2 -2
View File
@@ -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
+20 -4
View File
@@ -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;
+11 -1
View File
@@ -24,7 +24,7 @@
.\"
.\" References consulted:
.\" libsensors source code
.TH libsensors 3 "June 2007" "lm-sensors 3" "Linux Programmer's Manual"
.TH libsensors 3 "October 2007" "lm-sensors 3" "Linux Programmer's Manual"
.SH NAME
libsensors \- publicly accessible functions provided by the sensors library
.SH SYNOPSIS
@@ -57,6 +57,9 @@ value unequal to zero, you are in trouble; you can not assume anything will
be initialized properly. If you want to reload the configuration file, call
sensors_cleanup() below before calling sensors_init() again.
If FILE is NULL, the default configuration file is used (see the FILES
section below). Most applications will want to do that.
.B void sensors_cleanup(void);
.br
Clean-up function: You can't access anything after this, until the next sensors_init() call!
@@ -168,6 +171,13 @@ data structures.
.br
A string representing the version of libsensors.
.SH FILES
.I /etc/sensors.conf
.RS
The system-wide
.BR libsensors (3)
configuration file.
.SH SEE ALSO
sensors.conf(5)