bluez-libs patch to include bachk() function
PATCH 1/1 bluez-libs patch to include bachk() function
Index: include/bluetooth.h
===================================================================
RCS file: /cvsroot/bluez/libs/include/bluetooth.h,v retrieving revision 1.27
bluetooth.h +1 -0
@@ -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
bluetooth.c +33 -0
@@ -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;
-------------------------------------------------------------------------
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/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel