diff options
author | Quentin Hibon <qh.public@yahoo.com> | 2018-05-27 10:05:56 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2018-05-28 06:29:09 +0200 |
commit | 407d5abd231eeedb9bfdc5e81b9ef7030bb05325 (patch) | |
tree | b13ebe41e321fa23e231d9057407b6b30a89671b /src/io.c | |
parent | 574156be7c0feae9c66909b2f83a46c6906fdf50 (diff) | |
download | calcurse-407d5abd231eeedb9bfdc5e81b9ef7030bb05325.tar.gz calcurse-407d5abd231eeedb9bfdc5e81b9ef7030bb05325.zip |
Add option to specify the configuration file used
The configuration file (~/.calcurse/conf by default) can now be
specified with -C or --conf.
Workaround for GitHub issue #86.
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/io.c')
-rw-r--r-- | src/io.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -226,16 +226,20 @@ unsigned io_fprintln(const char *fname, const char *fmt, ...) * one (~/.calcurse/apts) is taken. If the one given does not exist, it * is created. * The datadir argument can be use to specify an alternative data root dir. + * The conffile argument can be use to specify an alternative configuration file. */ -void io_init(const char *cfile, const char *datadir) +void io_init(const char *cfile, const char *datadir, const char *conffile) { const char *home; if (datadir != NULL) { home = datadir; snprintf(path_dir, BUFSIZ, "%s", home); + if (conffile) + snprintf(path_conf, BUFSIZ, "%s", conffile); + else + snprintf(path_conf, BUFSIZ, "%s/" CONF_PATH_NAME, home); snprintf(path_todo, BUFSIZ, "%s/" TODO_PATH_NAME, home); - snprintf(path_conf, BUFSIZ, "%s/" CONF_PATH_NAME, home); snprintf(path_notes, BUFSIZ, "%s/" NOTES_DIR_NAME, home); snprintf(path_keys, BUFSIZ, "%s/" KEYS_PATH_NAME, home); snprintf(path_cpid, BUFSIZ, "%s/" CPID_PATH_NAME, home); @@ -248,9 +252,12 @@ void io_init(const char *cfile, const char *datadir) if (home == NULL) { home = "."; } + if (conffile) + snprintf(path_conf, BUFSIZ, "%s", conffile); + else + snprintf(path_conf, BUFSIZ, "%s/" CONF_PATH, home); snprintf(path_dir, BUFSIZ, "%s/" DIR_NAME, home); snprintf(path_todo, BUFSIZ, "%s/" TODO_PATH, home); - snprintf(path_conf, BUFSIZ, "%s/" CONF_PATH, home); snprintf(path_keys, BUFSIZ, "%s/" KEYS_PATH, home); snprintf(path_cpid, BUFSIZ, "%s/" CPID_PATH, home); snprintf(path_dpid, BUFSIZ, "%s/" DPID_PATH, home); |