summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <mail2xengineering@protonmail.com>2021-01-30 14:39:42 +0100
committerxengineering <mail2xengineering@protonmail.com>2021-01-30 14:39:42 +0100
commit58daf50667396477021e4a4f57d8241e44ff268c (patch)
treea85db34353a8c4e0f8289f50322eed38c0eae377
parentb1918078d913193544e0fdc933457d2a71836447 (diff)
downloadxbot-58daf50667396477021e4a4f57d8241e44ff268c.tar
xbot-58daf50667396477021e4a4f57d8241e44ff268c.tar.zst
xbot-58daf50667396477021e4a4f57d8241e44ff268c.zip
Fix homedir Bug
-rw-r--r--src/xbot.c8
1 files 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 <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);
}