# HG changeset patch # User Matti Hamalainen # Date 1288727449 -7200 # Node ID 0b9910c3ed3038d325ac3a2b074050eeee48044e # Parent cce05daf6f01ada242c5f46c6eacfbd060a50616 Create configuration file path based on user's $HOME under UNIX-style systems. diff -r cce05daf6f01 -r 0b9910c3ed30 nnchat.c --- 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);