Create a new configuration file if it doesn't exist.

Wed, 19 Aug 2015 22:09:17 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 19 Aug 2015 22:09:17 +0200
changeset 388
05a55609cd9a
parent 387
03635517595c
child 389
584d40bb4b09

Create a new configuration file if it doesn't exist.

thermferm/rdconfig.c file | annotate | diff | comparison | revisions
--- a/thermferm/rdconfig.c	Sat Aug 15 11:27:54 2015 +0200
+++ b/thermferm/rdconfig.c	Wed Aug 19 22:09:17 2015 +0200
@@ -1933,20 +1933,15 @@
     mypath = xstrcat(mypath, (char *)"thermferm.xml");
     if ((doc = xmlParseFile(mypath)) == NULL) {
 	/*
-	 * Not in the users home directory
+	 * No config file, create a fresh one
 	 */
-	free(mypath);
-	mypath = xstrcpy((char *)"/etc/mbsepi-apps/thermferm.xml");
+	syslog(LOG_NOTICE, "rdconfig: %s not found, creating", mypath);
+	wrconfig();
+
 	if ((doc = xmlParseFile(mypath)) == NULL) {
-	    /*
-	     * Try /usr/local/etc
-	     */
+	    syslog(LOG_NOTICE, "rdconfig: could not create %s", mypath);
 	    free(mypath);
-	    mypath = xstrcpy((char *)"/usr/local/etc/mbsepi-apps/thermferm.xml");
-	    if ((doc = xmlParseFile(mypath)) == NULL) {
-		syslog(LOG_NOTICE, "rdconfig: could not find thermferm.xml");
-		return 1;
-	    }
+	    return 1;
 	}
     }
     syslog(LOG_NOTICE, "rdconfig: using %s", mypath);

mercurial