thermferm/rdconfig.c

changeset 55
11d7cc3bdf31
parent 54
c06190a58f22
child 56
f7711c6ac93c
--- a/thermferm/rdconfig.c	Mon May 26 23:25:48 2014 +0200
+++ b/thermferm/rdconfig.c	Tue May 27 22:24:39 2014 +0200
@@ -120,7 +120,11 @@
     w1_therm    *tmp1;
     rc_switch   *tmp2;
 
-    mypath = xstrcpy(getenv((char *)"HOME"));
+    if (getenv((char *)"HOME") == NULL) {
+	mypath = xstrcpy((char *)"/root");
+    } else {
+    	mypath = xstrcpy(getenv((char *)"HOME"));
+    }
     mypath = xstrcat(mypath, (char *)"/mbsepi-apps/");
     mypath = xstrcat(mypath, config);
 
@@ -202,7 +206,11 @@
     /*
      * Search config file
      */
-    mypath = xstrcpy(getenv((char *)"HOME"));
+    if (getenv((char *)"HOME") == NULL) {
+	mypath = xstrcpy((char *)"/root");
+    } else {
+    	mypath = xstrcpy(getenv((char *)"HOME"));
+    }
     mypath = xstrcat(mypath, (char *)"/mbsepi-apps/");
     mypath = xstrcat(mypath, config);
     if ((fp = fopen(mypath, "r")) == NULL) {
@@ -220,11 +228,12 @@
 	    mypath = xstrcpy((char *)"/usr/local/etc/mbsepi-apps/");
 	    mypath = xstrcat(mypath, config);
 	    if ((fp = fopen(mypath, "r")) == NULL) {
-		syslog(LOG_NOTICE, "rdconfig: could not open %s", mypath);
+		syslog(LOG_NOTICE, "rdconfig: could find %s", config);
 		return 1;
 	    }
 	}
     }
+    syslog(LOG_NOTICE, "rdconfig: using %s", mypath);
 
     linecnt = 0;
     while (fgets(buf, sizeof(buf) -1, fp)) {

mercurial