1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-22 20:23:01 +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 (setlocale(LC_ALL, "") == NULL) if (!arg_opts.default_locale) {
exit_toxic_err("Could not set your locale, please check your locale settings or" if (setlocale(LC_ALL, "") == NULL)
"disable wide char support", FATALERR_LOCALE_SET); exit_toxic_err("Could not set your locale, please check your locale settings or "
"disable unicode support with the -D flag.", FATALERR_LOCALE_SET);
}
#endif #endif
initscr(); initscr();
@ -492,18 +496,20 @@ void *thread_filesenders(void *data)
static void print_usage(void) static void print_usage(void)
{ {
fprintf(stderr, "usage: toxic [OPTION] [FILE ...]\n"); fprintf(stderr, "usage: toxic [OPTION] [FILE ...]\n");
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, " -c, --config Use specified config file\n"); fprintf(stderr, " -d, --default_locale Use default locale\n");
fprintf(stderr, " -n, --nodes Use specified DHTnodes file\n"); fprintf(stderr, " -c, --config Use specified config file\n");
fprintf(stderr, " -h, --help Show this message and exit\n"); fprintf(stderr, " -n, --nodes Use specified DHTnodes file\n");
fprintf(stderr, " -h, --help Show this message and exit\n");
} }
static void set_default_opts(void) 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();