From 58daf50667396477021e4a4f57d8241e44ff268c Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 30 Jan 2021 14:39:42 +0100 Subject: Fix homedir Bug --- src/xbot.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/xbot.c b/src/xbot.c index 2bc7def..1eb6065 100644 --- a/src/xbot.c +++ b/src/xbot.c @@ -10,7 +10,7 @@ #include -#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); } -- cgit v1.2.3-70-g09d2