# HG changeset patch # User Michiel Broek # Date 1440014957 -7200 # Node ID 05a55609cd9a7aed585dea5c310d88a0d302e057 # Parent 03635517595c94883c797736f55cd48e583718ff Create a new configuration file if it doesn't exist. diff -r 03635517595c -r 05a55609cd9a thermferm/rdconfig.c --- 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);