All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali@linux-fr.org>
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] [PATCH 1/6] Add a default configuration file name to
Date: Wed, 24 Oct 2007 15:08:15 +0000	[thread overview]
Message-ID: <20071024170815.76deb8ec@hyperion.delvare> (raw)

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(-)

--- lm-sensors-3.orig/lib/init.c	2007-10-20 16:02:44.000000000 +0200
+++ lm-sensors-3/lib/init.c	2007-10-20 16:08:42.000000000 +0200
@@ -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;
--- lm-sensors-3.orig/Makefile	2007-10-20 16:02:44.000000000 +0200
+++ lm-sensors-3/Makefile	2007-10-20 16:06:18.000000000 +0200
@@ -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


-- 
Jean Delvare

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

                 reply	other threads:[~2007-10-24 15:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071024170815.76deb8ec@hyperion.delvare \
    --to=khali@linux-fr.org \
    --cc=lm-sensors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.