mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2025-04-21 12:27:27 +03:00
tools/: added option -d driver[:arg] to all tools
- atrf-id/atrf-id.c (main), atrf-reset/atrf-reset.c (main), atrf-trim/atrf-trim.c (main): changed command-line parsing to use "getopt" - atrf-id/atrf-id.c (usage, main), atrf-reset/atrf-reset.c (usage, main), atrf-rssi/atrf-rssi.c (usage, main), atrf-trim/atrf-trim.c (usage, main), atrf-txrx/atrf-txrx.c (init_txrx, usage, main), atrf-xtal/atrf-xtal.c (usage, main): added option -d to select a driver
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_USB
|
||||
#include <usb.h>
|
||||
@@ -157,18 +158,29 @@ static void show_info(struct atrf_dsc *dsc)
|
||||
|
||||
static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr, "usage: %s\n", name);
|
||||
fprintf(stderr, "usage: [-d driver[:arg]] %s\n", name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
int main(int argc, char *const *argv)
|
||||
{
|
||||
const char *driver = NULL;
|
||||
struct atrf_dsc *dsc;
|
||||
int c;
|
||||
|
||||
if (argc != 1)
|
||||
while ((c = getopt(argc, argv, "d:")) != EOF)
|
||||
switch (c) {
|
||||
case 'd':
|
||||
driver = optarg;
|
||||
break;
|
||||
default:
|
||||
usage(*argv);
|
||||
}
|
||||
if (argc != optind)
|
||||
usage(*argv);
|
||||
dsc = atrf_open(NULL);
|
||||
|
||||
dsc = atrf_open(driver);
|
||||
if (!dsc)
|
||||
return 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user