1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-26 21:23:27 +01:00

fix data file init bug

This commit is contained in:
Jfreegman 2014-08-02 13:04:29 -04:00
parent 43727c6730
commit 0884954c84
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
2 changed files with 6 additions and 0 deletions

View File

@ -501,6 +501,7 @@ static void set_default_opts(void)
arg_opts.use_ipv4 = 0; arg_opts.use_ipv4 = 0;
arg_opts.ignore_data_file = 0; arg_opts.ignore_data_file = 0;
arg_opts.default_locale = 0; arg_opts.default_locale = 0;
arg_opts.use_custom_data = 0;
} }
static void parse_args(int argc, char *argv[]) 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) { while ((opt = getopt_long(argc, argv, opts_str, long_opts, &indexptr)) != -1) {
switch (opt) { switch (opt) {
case 'f': case 'f':
arg_opts.use_custom_data = 1;
DATA_FILE = strdup(optarg); DATA_FILE = strdup(optarg);
BLOCK_FILE = malloc(strlen(optarg) + strlen("-blocklist") + 1); BLOCK_FILE = malloc(strlen(optarg) + strlen("-blocklist") + 1);
@ -565,6 +567,9 @@ static void parse_args(int argc, char *argv[])
#define BLOCKNAME "data-blocklist" #define BLOCKNAME "data-blocklist"
static int init_data_files(void) static int init_data_files(void)
{ {
if (arg_opts.use_custom_data)
return 0;
char *user_config_dir = get_user_config_dir(); char *user_config_dir = get_user_config_dir();
int config_err = create_user_config_dir(user_config_dir); int config_err = create_user_config_dir(user_config_dir);

View File

@ -75,6 +75,7 @@ struct arg_opts {
int ignore_data_file; int ignore_data_file;
int use_ipv4; int use_ipv4;
int default_locale; int default_locale;
int use_custom_data;
char config_path[MAX_STR_SIZE]; char config_path[MAX_STR_SIZE];
char nodes_path[MAX_STR_SIZE]; char nodes_path[MAX_STR_SIZE];
}; };