From 0884954c842e88835396b6952d5f324247e6280c Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Sat, 2 Aug 2014 13:04:29 -0400 Subject: [PATCH] fix data file init bug --- src/toxic.c | 5 +++++ src/windows.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/toxic.c b/src/toxic.c index 9fb98fe..930d5ac 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -501,6 +501,7 @@ static void set_default_opts(void) arg_opts.use_ipv4 = 0; arg_opts.ignore_data_file = 0; arg_opts.default_locale = 0; + arg_opts.use_custom_data = 0; } static void parse_args(int argc, char *argv[]) @@ -523,6 +524,7 @@ static void parse_args(int argc, char *argv[]) while ((opt = getopt_long(argc, argv, opts_str, long_opts, &indexptr)) != -1) { switch (opt) { case 'f': + arg_opts.use_custom_data = 1; DATA_FILE = strdup(optarg); BLOCK_FILE = malloc(strlen(optarg) + strlen("-blocklist") + 1); @@ -565,6 +567,9 @@ static void parse_args(int argc, char *argv[]) #define BLOCKNAME "data-blocklist" static int init_data_files(void) { + if (arg_opts.use_custom_data) + return 0; + char *user_config_dir = get_user_config_dir(); int config_err = create_user_config_dir(user_config_dir); diff --git a/src/windows.h b/src/windows.h index 529487b..f1438ad 100644 --- a/src/windows.h +++ b/src/windows.h @@ -75,6 +75,7 @@ struct arg_opts { int ignore_data_file; int use_ipv4; int default_locale; + int use_custom_data; char config_path[MAX_STR_SIZE]; char nodes_path[MAX_STR_SIZE]; };