public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] [PATCH] bluez-libs patch to include bachk() function
@ 2007-06-21 18:10 Tadas Dailyda
  0 siblings, 0 replies; only message in thread
From: Tadas Dailyda @ 2007-06-21 18:10 UTC (permalink / raw)
  To: bluez-devel

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: bachk.patch --]
[-- Type: text/x-patch, Size: 1704 bytes --]

Index: include/bluetooth.h
===================================================================
RCS file: /cvsroot/bluez/libs/include/bluetooth.h,v
retrieving revision 1.27
diff -u -r1.27 bluetooth.h
--- include/bluetooth.h	13 Jan 2007 17:50:06 -0000	1.27
+++ include/bluetooth.h	21 Jun 2007 17:45:10 -0000
@@ -125,6 +125,7 @@
 int ba2str(const bdaddr_t *ba, char *str);
 int str2ba(const char *str, bdaddr_t *ba);
 int ba2oui(const bdaddr_t *ba, char *oui);
+int bachk(const char *str);
 
 int baprintf(const char *format, ...);
 int bafprintf(FILE *stream, const char *format, ...);
Index: src/bluetooth.c
===================================================================
RCS file: /cvsroot/bluez/libs/src/bluetooth.c,v
retrieving revision 1.41
diff -u -r1.41 bluetooth.c
--- src/bluetooth.c	20 Jun 2007 15:34:46 -0000	1.41
+++ src/bluetooth.c	21 Jun 2007 17:45:11 -0000
@@ -33,6 +33,7 @@
 #include <stdlib.h>
 #include <malloc.h>
 #include <string.h>
+#include <ctype.h>
 #include <sys/socket.h>
 
 #include <bluetooth/bluetooth.h>
@@ -110,6 +111,38 @@
 	return sprintf(str, "%2.2X-%2.2X-%2.2X", b[0], b[1], b[2]);
 }
 
+int bachk(const char *str)
+{
+	char tmp[18];
+	char *ptr = tmp;
+
+	if (!str)
+		return -1;
+	if (strlen(str) != 17)
+		return -1;
+
+	memcpy(tmp, str, 18);
+
+	while (*ptr) {
+		*ptr = toupper(*ptr);
+		if (*ptr < '0'|| (*ptr > '9' && *ptr < 'A') || *ptr > 'F')
+			return -1;
+		ptr++;
+		*ptr = toupper(*ptr);
+		if (*ptr < '0'|| (*ptr > '9' && *ptr < 'A') || *ptr > 'F')
+			return -1;
+		ptr++;
+		*ptr = toupper(*ptr);
+		if (*ptr == 0)
+			break;
+		if (*ptr != ':')
+			return -1;
+		ptr++;
+	}
+
+	return 0;
+}
+
 int baprintf(const char *format, ...)
 {
 	va_list ap;

[-- Attachment #3: Type: text/plain, Size: 286 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-06-21 18:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-21 18:10 [Bluez-devel] [PATCH] bluez-libs patch to include bachk() function Tadas Dailyda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox