changeset 142:0b9910c3ed30

Create configuration file path based on user's $HOME under UNIX-style systems.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 02 Nov 2010 21:50:49 +0200
parents cce05daf6f01
children 5babbff7ca26
files nnchat.c
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/nnchat.c	Tue Nov 02 21:48:54 2010 +0200
+++ b/nnchat.c	Tue Nov 02 21:50:49 2010 +0200
@@ -817,7 +817,21 @@
     {
     cfgitem_t *tmpcfg = NULL;
     FILE *cfgfile;
+    char *homeDir;
+
+#ifdef __WIN32
     
+#else
+    homeDir = getenv("HOME");
+#endif
+    
+    if (homeDir != NULL)
+        setConfigFile = th_strdup_printf("%s" SET_DIR_SEPARATOR "%s", homeDir, SET_CONFIG_FILE);
+    else
+        setConfigFile = th_strdup(SET_CONFIG_FILE);
+
+        THMSG(0, "Reading configuration from '%s'.\n", setConfigFile);
+
     th_cfg_add_comment(&tmpcfg, "General settings");
     th_cfg_add_string(&tmpcfg, "username", &optUserName, NULL);
     th_cfg_add_string(&tmpcfg, "password", &optPassword, NULL);