[gnome-bluetooth] Add major class output to test-class



commit 41c164796de5dcbf9265a915a3ca2d5d47a0f5a7
Author: Bastien Nocera <hadess hadess net>
Date:   Sun May 2 18:44:06 2010 +0100

    Add major class output to test-class

 lib/test-class.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/lib/test-class.c b/lib/test-class.c
index b62307e..06eea06 100644
--- a/lib/test-class.c
+++ b/lib/test-class.c
@@ -25,11 +25,25 @@
 #include <config.h>
 #endif
 
+#include <string.h>
 #include <gtk/gtk.h>
 
 #include "bluetooth-client.h"
 #include "bluetooth-client-private.h"
 
+static const char *
+byte_to_binary (int x)
+{
+	static char b[9] = {0};
+
+	int z;
+	for (z = 256; z > 0; z >>= 1) {
+		strcat(b, ((x & z) == z) ? "1" : "0");
+	}
+
+	return b;
+}
+
 int main(int argc, char *argv[])
 {
 	GLogLevelFlags fatal_mask;
@@ -43,6 +57,8 @@ int main(int argc, char *argv[])
 
 	class = g_ascii_strtoull (argv[1], NULL, 0);
 
+	g_message ("major class: 0x%X %s", (class & 0x1f00) >> 8, byte_to_binary ((class & 0x1f00) >> 8));
+
 	g_message ("%d %s", bluetooth_class_to_type (class), bluetooth_type_to_string (bluetooth_class_to_type (class)));
 
 	return 0;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]