All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tadas Dailyda <tadas@dailyda.com>
To: bluez-devel@lists.sourceforge.net
Subject: [Bluez-devel] [PATCH] bluez-libs patch to include bachk() function
Date: Thu, 21 Jun 2007 21:10:21 +0300	[thread overview]
Message-ID: <1182449421.10358.3.camel@VAIO> (raw)

[-- 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

                 reply	other threads:[~2007-06-21 18:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1182449421.10358.3.camel@VAIO \
    --to=tadas@dailyda.com \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.