mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 04:20:20 +00:00
port/posix-h4: allow multi stage argv parsing
This commit is contained in:
parent
e2475b4c6e
commit
1ab12960cb
@ -287,7 +287,7 @@ static void local_version_information_handler(uint8_t * packet){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char short_options[] = "hu:l:rb:";
|
static char short_options[] = "+hu:l:rb:";
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
@ -329,7 +329,8 @@ int main(int argc, const char * argv[]){
|
|||||||
|
|
||||||
// set default device path
|
// set default device path
|
||||||
config.device_name = "/dev/tty.usbmodemEF437DF524C51";
|
config.device_name = "/dev/tty.usbmodemEF437DF524C51";
|
||||||
|
int oldopterr = opterr;
|
||||||
|
opterr = 0;
|
||||||
// parse command line parameters
|
// parse command line parameters
|
||||||
while(true){
|
while(true){
|
||||||
int c = getopt_long( argc, (char* const *)argv, short_options, long_options, NULL );
|
int c = getopt_long( argc, (char* const *)argv, short_options, long_options, NULL );
|
||||||
@ -337,7 +338,7 @@ int main(int argc, const char * argv[]){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (c == '?'){
|
if (c == '?'){
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'u':
|
case 'u':
|
||||||
@ -355,9 +356,13 @@ int main(int argc, const char * argv[]){
|
|||||||
case 'h':
|
case 'h':
|
||||||
default:
|
default:
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
return EXIT_FAILURE;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// reset getopt parsing, so it works as intended from btstack_main
|
||||||
|
optind = 1;
|
||||||
|
opterr = oldopterr;
|
||||||
|
|
||||||
/// GET STARTED with BTstack ///
|
/// GET STARTED with BTstack ///
|
||||||
btstack_memory_init();
|
btstack_memory_init();
|
||||||
btstack_run_loop_init(btstack_run_loop_posix_get_instance());
|
btstack_run_loop_init(btstack_run_loop_posix_get_instance());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user