From 75b61c0a4f415fdb6518b9cf99f9b5d4b8072c5f Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Mon, 8 Sep 2008 16:56:51 -0300 Subject: Add -i option to avinfo. --- tools/avinfo.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'tools') diff --git a/tools/avinfo.c b/tools/avinfo.c index 76d29c0c..dccf4e7d 100644 --- a/tools/avinfo.c +++ b/tools/avinfo.c @@ -607,11 +607,15 @@ static void usage() { printf("avinfo - Audio/Video Info Tool ver %s\n", VERSION); printf("Usage:\n" - "\tavinfo \n"); + "\tavinfo [options] \n"); + printf("Options:\n" + "\t-h\t\tDisplay help\n" + "\t-i\t\tSpecify source interface\n"); } static struct option main_options[] = { { "help", 0, 0, 'h' }, + { "device", 1, 0, 'i' }, { 0, 0, 0, 0 } }; @@ -625,8 +629,22 @@ int main(int argc, char *argv[]) exit(0); } - while ((opt = getopt_long(argc, argv, "h", main_options, NULL)) != -1) { + bacpy(&src, BDADDR_ANY); + dev_id = hci_get_route(&src); + if ((dev_id < 0) || (hci_devba(dev_id, &src) < 0)) { + printf("Cannot find any local adapter\n"); + exit(-1); + } + + while ((opt = getopt_long(argc, argv, "+i:h", main_options, NULL)) != -1) { switch (opt) { + case 'i': + if (!strncmp(optarg, "hci", 3)) + hci_devba(atoi(optarg + 3), &src); + else + str2ba(optarg, &src); + break; + case 'h': default: usage(); @@ -634,21 +652,14 @@ int main(int argc, char *argv[]) } } - bacpy(&src, BDADDR_ANY); - dev_id = hci_get_route(&src); - if ((dev_id < 0) || (hci_devba(dev_id, &src) < 0)) { - printf("Cannot find any local adapter\n"); - exit(-1); - } - printf("Connecting ... \n"); - if (bachk(argv[1]) < 0) { + if (bachk(argv[optind]) < 0) { printf("Invalid argument\n"); exit(1); } - str2ba(argv[1], &dst); + str2ba(argv[optind], &dst); sk = l2cap_connect(&src, &dst); if (sk < 0) exit(1); -- cgit