Allow multiple -D/-L/-d/-S flags, only allow one -k flag.

Multiple instances of a single flag from -D/-L/-d/-S should behave like
a single instance of that flag; -D plus -L, for example, is not
supported, but -D plus another -D should be.  -k, however, takes an
argument, and we only support one.

Change-Id: I8baced346fbffd75f8d768497213f67bb9a0555f
Reviewed-on: https://code.wireshark.org/review/7723
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2015-03-17 13:11:12 -07:00
parent 6637f4d144
commit 7a14f89f12
1 changed files with 25 additions and 12 deletions

View File

@ -4646,28 +4646,41 @@ DIAG_ON(cast-qual)
break;
/*** all non capture option specific ***/
case 'D': /* Print a list of capture devices and exit */
list_interfaces = TRUE;
run_once_args++;
if (!list_interfaces) {
list_interfaces = TRUE;
run_once_args++;
}
break;
case 'L': /* Print list of link-layer types and exit */
list_link_layer_types = TRUE;
run_once_args++;
if (!list_link_layer_types) {
list_link_layer_types = TRUE;
run_once_args++;
}
break;
#ifdef HAVE_BPF_IMAGE
case 'd': /* Print BPF code for capture filter and exit */
print_bpf_code = TRUE;
run_once_args++;
if (!print_bpf_code) {
print_bpf_code = TRUE;
run_once_args++;
}
break;
#endif
case 'S': /* Print interface statistics once a second */
print_statistics = TRUE;
run_once_args++;
if (!print_statistics) {
print_statistics = TRUE;
run_once_args++;
}
break;
case 'k': /* Set wireless channel */
set_chan = TRUE;
set_chan_arg = optarg;
run_once_args++;
break;
if (!set_chan) {
set_chan = TRUE;
set_chan_arg = optarg;
run_once_args++;
} else {
cmdarg_err("Only one -k flag may be specified");
arg_error = TRUE;
}
break;
case 'M': /* For -D, -L, and -S, print machine-readable output */
machine_readable = TRUE;
break;