373 if (getenv((char *)"USER") == NULL) { |
373 if (getenv((char *)"USER") == NULL) { |
374 mypath = xstrcpy((char *)"/root"); |
374 mypath = xstrcpy((char *)"/root"); |
375 } else { |
375 } else { |
376 mypath = xstrcpy(getenv((char *)"HOME")); |
376 mypath = xstrcpy(getenv((char *)"HOME")); |
377 } |
377 } |
378 mypath = xstrcat(mypath, (char *)"/mbsepi-apps/"); |
378 mypath = xstrcat(mypath, (char *)"/.thermferm/etc/"); |
379 mypath = xstrcat(mypath, confxml); |
379 mkdirs(mypath, 0755); |
|
380 mypath = xstrcat(mypath, (char *)"thermferm.xml"); |
380 |
381 |
381 if (debug) |
382 if (debug) |
382 fprintf(stdout, "Writing %s\n", mypath); |
383 fprintf(stdout, "Writing %s\n", mypath); |
383 |
384 |
384 if ((fp = fopen(mypath, "w")) == NULL) { |
385 if ((fp = fopen(mypath, "w")) == NULL) { |
695 if (getenv((char *)"USER") == NULL) { |
696 if (getenv((char *)"USER") == NULL) { |
696 mypath = xstrcpy((char *)"/root"); |
697 mypath = xstrcpy((char *)"/root"); |
697 } else { |
698 } else { |
698 mypath = xstrcpy(getenv((char *)"HOME")); |
699 mypath = xstrcpy(getenv((char *)"HOME")); |
699 } |
700 } |
700 mypath = xstrcat(mypath, (char *)"/mbsepi-apps/"); |
701 mypath = xstrcat(mypath, (char *)"/.thermferm/etc/"); |
701 mypath = xstrcat(mypath, config); |
702 mkdirs(mypath, 0755); |
|
703 mypath = xstrcat(mypath, (char *)"thermferm.xml"); |
702 if ((doc = xmlParseFile(mypath)) == NULL) { |
704 if ((doc = xmlParseFile(mypath)) == NULL) { |
703 /* |
705 /* |
704 * Not in the users home directory |
706 * Not in the users home directory |
705 */ |
707 */ |
706 free(mypath); |
708 free(mypath); |
707 mypath = xstrcpy((char *)"/etc/mbsepi-apps/"); |
709 mypath = xstrcpy((char *)"/etc/mbsepi-apps/thermferm.xml"); |
708 mypath = xstrcat(mypath, config); |
|
709 if ((doc = xmlParseFile(mypath)) == NULL) { |
710 if ((doc = xmlParseFile(mypath)) == NULL) { |
710 /* |
711 /* |
711 * Try /usr/local/etc |
712 * Try /usr/local/etc |
712 */ |
713 */ |
713 free(mypath); |
714 free(mypath); |
714 mypath = xstrcpy((char *)"/usr/local/etc/mbsepi-apps/"); |
715 mypath = xstrcpy((char *)"/usr/local/etc/mbsepi-apps/thermferm.xml"); |
715 mypath = xstrcat(mypath, config); |
|
716 if ((doc = xmlParseFile(mypath)) == NULL) { |
716 if ((doc = xmlParseFile(mypath)) == NULL) { |
717 syslog(LOG_NOTICE, "rdconfig: could not parse %s", config); |
717 syslog(LOG_NOTICE, "rdconfig: could not find thermferm.xml"); |
718 return 1; |
718 return 1; |
719 } |
719 } |
720 } |
720 } |
721 } |
721 } |
722 syslog(LOG_NOTICE, "rdconfig: using %s", mypath); |
722 syslog(LOG_NOTICE, "rdconfig: using %s", mypath); |