Diff between 90cb7c5884b147288220314d8fdd276f7d068ac4 and bcb96cdde52b66eaca3ca976cd354466fa35033d

Changed Files

File Additions Deletions Status
emulator/main.c +11 -7 modified

Full Patch

diff --git a/emulator/main.c b/emulator/main.c
index a11fdd8..f185a97 100644
--- a/emulator/main.c
+++ b/emulator/main.c
@@ -55,9 +55,9 @@ static void usage(void)
 }
 
 static const struct option main_options[] = {
-	{ "local",   no_argument, NULL, 'l' },
-	{ "version", no_argument, NULL, 'v' },
-	{ "help",    no_argument, NULL, 'h' },
+	{ "local",   optional_argument,	NULL, 'l' },
+	{ "version", no_argument,	NULL, 'v' },
+	{ "help",    no_argument,	NULL, 'h' },
 	{ }
 };
 
@@ -69,22 +69,26 @@ int main(int argc, char *argv[])
 	struct server *server3;
 	struct server *server4;
 	struct server *server5;
-	bool enable_vhci = false;
+	int vhci_count = 0;
 	enum vhci_type vhci_type = VHCI_TYPE_BREDRLE;
 	sigset_t mask;
+	int i;
 
 	mainloop_init();
 
 	for (;;) {
 		int opt;
 
-		opt = getopt_long(argc, argv, "lLBvh", main_options, NULL);
+		opt = getopt_long(argc, argv, "l::LBvh", main_options, NULL);
 		if (opt < 0)
 			break;
 
 		switch (opt) {
 		case 'l':
-			enable_vhci = true;
+			if (optarg)
+				vhci_count = atoi(optarg);
+			else
+				vhci_count = 1;
 			break;
 		case 'L':
 			vhci_type = VHCI_TYPE_LE;
@@ -111,7 +115,7 @@ int main(int argc, char *argv[])
 
 	printf("Bluetooth emulator ver %s\n", VERSION);
 
-	if (enable_vhci) {
+	for (i = 0; i < vhci_count; i++) {
 		vhci = vhci_open(vhci_type);
 		if (!vhci)
 			fprintf(stderr, "Failed to open Virtual HCI device\n");