diff options
author | xengineering <mail2xengineering@protonmail.com> | 2021-01-30 14:39:42 +0100 |
---|---|---|
committer | xengineering <mail2xengineering@protonmail.com> | 2021-01-30 14:39:42 +0100 |
commit | 58daf50667396477021e4a4f57d8241e44ff268c (patch) | |
tree | a85db34353a8c4e0f8289f50322eed38c0eae377 | |
parent | b1918078d913193544e0fdc933457d2a71836447 (diff) | |
download | xbot-58daf50667396477021e4a4f57d8241e44ff268c.tar xbot-58daf50667396477021e4a4f57d8241e44ff268c.tar.zst xbot-58daf50667396477021e4a4f57d8241e44ff268c.zip |
Fix homedir Bug
-rw-r--r-- | src/xbot.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -10,7 +10,7 @@ #include <strophe.h> -#define DEFAULT_PROFILE_PATH "~/.config/xbot/profile.ini" +#define DEFAULT_PROFILE_PATH_APPENDIX "/.config/xbot/profile.ini" struct xmpp_job_t @@ -84,8 +84,10 @@ void parse_cli_args(int argc, char **argv, struct xmpp_job_t *job, char **cfg_pa } if(*cfg_path == NULL) { - *cfg_path = malloc((strlen(DEFAULT_PROFILE_PATH) + 1)*sizeof(char)); - strcpy(*cfg_path, DEFAULT_PROFILE_PATH); + char *homedir = getenv("HOME"); + *cfg_path = malloc((strlen(homedir) + strlen(DEFAULT_PROFILE_PATH_APPENDIX) + 1)*sizeof(char)); + strcpy(*cfg_path, homedir); + strcat(*cfg_path, DEFAULT_PROFILE_PATH_APPENDIX); } printf("message = '%s'\ntarget_jid = '%s'\nprofile_path = '%s'\n", job->message, job->recipient_jid, *cfg_path); } |