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

add option to use the default locale

This commit is contained in:
Jfreegman 2014-06-29 18:14:28 -04:00
parent 61d3f7e63e
commit a194f7ad87
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
2 changed files with 23 additions and 10 deletions

View File

@ -23,6 +23,8 @@ instead of
Ignore data file Ignore data file
.IP "\-4, \-\-ipv4" .IP "\-4, \-\-ipv4"
Force IPv4 connection Force IPv4 connection
.IP "\-d, \-\-default_locale
Use default locale
.IP "\-c, \-\-config config\-file" .IP "\-c, \-\-config config\-file"
Use specified Use specified
.I config\-file .I config\-file

View File

@ -78,6 +78,7 @@ ToxWindow *prompt = NULL;
struct arg_opts { struct arg_opts {
int ignore_data_file; int ignore_data_file;
int use_ipv4; int use_ipv4;
int default_locale;
char config_path[MAX_STR_SIZE]; char config_path[MAX_STR_SIZE];
char nodes_path[MAX_STR_SIZE]; char nodes_path[MAX_STR_SIZE];
} arg_opts; } arg_opts;
@ -130,9 +131,12 @@ static void init_term(void)
#if HAVE_WIDECHAR #if HAVE_WIDECHAR
if (!arg_opts.default_locale) {
if (setlocale(LC_ALL, "") == NULL) if (setlocale(LC_ALL, "") == NULL)
exit_toxic_err("Could not set your locale, please check your locale settings or" exit_toxic_err("Could not set your locale, please check your locale settings or "
"disable wide char support", FATALERR_LOCALE_SET); "disable unicode support with the -D flag.", FATALERR_LOCALE_SET);
}
#endif #endif
initscr(); initscr();
@ -495,6 +499,7 @@ static void print_usage(void)
fprintf(stderr, " -f, --file Use specified data file\n"); fprintf(stderr, " -f, --file Use specified data file\n");
fprintf(stderr, " -x, --nodata Ignore data file\n"); fprintf(stderr, " -x, --nodata Ignore data file\n");
fprintf(stderr, " -4, --ipv4 Force IPv4 connection\n"); fprintf(stderr, " -4, --ipv4 Force IPv4 connection\n");
fprintf(stderr, " -d, --default_locale Use default locale\n");
fprintf(stderr, " -c, --config Use specified config file\n"); fprintf(stderr, " -c, --config Use specified config file\n");
fprintf(stderr, " -n, --nodes Use specified DHTnodes file\n"); fprintf(stderr, " -n, --nodes Use specified DHTnodes file\n");
fprintf(stderr, " -h, --help Show this message and exit\n"); fprintf(stderr, " -h, --help Show this message and exit\n");
@ -504,6 +509,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;
} }
static void parse_args(int argc, char *argv[]) static void parse_args(int argc, char *argv[])
@ -514,12 +520,13 @@ static void parse_args(int argc, char *argv[])
{"file", required_argument, 0, 'f'}, {"file", required_argument, 0, 'f'},
{"nodata", no_argument, 0, 'x'}, {"nodata", no_argument, 0, 'x'},
{"ipv4", no_argument, 0, '4'}, {"ipv4", no_argument, 0, '4'},
{"default_locale", no_argument, 0, 'd'},
{"config", required_argument, 0, 'c'}, {"config", required_argument, 0, 'c'},
{"nodes", required_argument, 0, 'n'}, {"nodes", required_argument, 0, 'n'},
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
}; };
const char *opts_str = "4xf:c:n:h"; const char *opts_str = "4xdf:c:n:h";
int opt, indexptr; int opt, indexptr;
while ((opt = getopt_long(argc, argv, opts_str, long_opts, &indexptr)) != -1) { while ((opt = getopt_long(argc, argv, opts_str, long_opts, &indexptr)) != -1) {
@ -544,6 +551,10 @@ static void parse_args(int argc, char *argv[])
snprintf(arg_opts.nodes_path, sizeof(arg_opts.nodes_path), "%s", optarg); snprintf(arg_opts.nodes_path, sizeof(arg_opts.nodes_path), "%s", optarg);
break; break;
case 'd':
arg_opts.default_locale = 1;
break;
case 'h': case 'h':
default: default:
print_usage(); print_usage();