comparison nnchat.c @ 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
comparison
equal deleted inserted replaced
141:cce05daf6f01 142:0b9910c3ed30
815 815
816 /* Read config */ 816 /* Read config */
817 { 817 {
818 cfgitem_t *tmpcfg = NULL; 818 cfgitem_t *tmpcfg = NULL;
819 FILE *cfgfile; 819 FILE *cfgfile;
820 820 char *homeDir;
821
822 #ifdef __WIN32
823
824 #else
825 homeDir = getenv("HOME");
826 #endif
827
828 if (homeDir != NULL)
829 setConfigFile = th_strdup_printf("%s" SET_DIR_SEPARATOR "%s", homeDir, SET_CONFIG_FILE);
830 else
831 setConfigFile = th_strdup(SET_CONFIG_FILE);
832
833 THMSG(0, "Reading configuration from '%s'.\n", setConfigFile);
834
821 th_cfg_add_comment(&tmpcfg, "General settings"); 835 th_cfg_add_comment(&tmpcfg, "General settings");
822 th_cfg_add_string(&tmpcfg, "username", &optUserName, NULL); 836 th_cfg_add_string(&tmpcfg, "username", &optUserName, NULL);
823 th_cfg_add_string(&tmpcfg, "password", &optPassword, NULL); 837 th_cfg_add_string(&tmpcfg, "password", &optPassword, NULL);
824 th_cfg_add_hexvalue(&tmpcfg, "color", &optUserColor, optUserColor); 838 th_cfg_add_hexvalue(&tmpcfg, "color", &optUserColor, optUserColor);
825 th_cfg_add_section(&cfg, "general", tmpcfg); 839 th_cfg_add_section(&cfg, "general", tmpcfg);