Skip to contentSkip to conversation

rfcomm 'anycommand' bug

PATCH Filippo Giunchedi 2 participants 2 messages Jun 3, 2006 – Jun 4, 2006 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hi Marcel,
attached there is a new patch (using tabs, "set noet" for the vim lovers) for rfcomm, agreed it could be better. I hope it is clear enough.

thanks,
filippo
--
Filippo Giunchedi - http://esaurito.net
PGP key: 0x6B79D401
random quote follows:

The only way to get rid of a temptation is to yield to it. -- Oscar Wilde

main.c +12 -1
diff -u -r1.16 main.c
@@ -621,8 +621,19 @@
 	argv += optind;
 	optind = 0;
 
-	if (argc < 2)
+	if (argc == 0) {
 		show_all = 1;
+	} else if (argc == 1) {
+		for(i = 0; command[i].cmd; i++) {
+			if ((strncmp(command[i].cmd, argv[0], 4) == 0) && (strncmp(command[i].alt, argv[0], 4) == 0) )
+				break;
+			if (command[i+1].cmd == NULL) {
+				usage();
+				exit(0);
+			}
+		}
+		show_all = 1;
+	}
 
 	if ((ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_RFCOMM)) < 0 ) {
 		perror("Can't open RFCOMM control socket");

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#1 lore raw

Hi Filippo,

Quoted 2 lines

attached there is a new patch (using tabs, "set noet" for the vim lovers) for rfcomm, agreed it could be better. I hope it is clear enough.

now the patch is readable, but it is still worse. However it helped me to understand what you tried to achieve. I fixed it with the attached patch.

Regards

Marcel

? .deps
? .libs
? Makefile
? Makefile.in
? lexer.c
? parser.c
? parser.h
? rfcomm
Index: main.c
===================================================================
RCS file: /cvsroot/bluez/utils/rfcomm/main.c,v
retrieving revision 1.16

main.c +7 -2
diff -u -r1.16 main.c
@@ -621,8 +621,13 @@
 	argv += optind;
 	optind = 0;
 
-	if (argc < 2)
-		show_all = 1;
+	if (argc < 2) {
+		if (argc != 0) {
+			usage();
+			exit(1);
+		} else
+			show_all = 1;
+	}
 
 	if ((ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_RFCOMM)) < 0 ) {
 		perror("Can't open RFCOMM control socket");

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel