aboutsummaryrefslogtreecommitdiffstats
path: root/mevent.c
diff options
context:
space:
mode:
authorEliteTK <tomasz.kramkowski@gmail.com>2014-05-05 14:26:29 +0100
committerEliteTK <tomasz.kramkowski@gmail.com>2014-05-05 14:26:29 +0100
commita530bad7a6ea2778129db0dc26c446d9f6df6ddd (patch)
tree8f2f751092046f44a7fbc8bd92f57b013e1483f5 /mevent.c
parenta98d134e89a42909721dcefd426118af38628048 (diff)
downloadc-stuff-a530bad7a6ea2778129db0dc26c446d9f6df6ddd.tar.gz
c-stuff-a530bad7a6ea2778129db0dc26c446d9f6df6ddd.tar.xz
c-stuff-a530bad7a6ea2778129db0dc26c446d9f6df6ddd.zip
More stuff.
Diffstat (limited to 'mevent.c')
-rw-r--r--mevent.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/mevent.c b/mevent.c
new file mode 100644
index 0000000..4fd176a
--- /dev/null
+++ b/mevent.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#define B2BP "%d%d%d%d%d%d%d%d"
+#define B2B(byte) \
+ (byte & 0x80 ? 1 : 0), \
+ (byte & 0x40 ? 1 : 0), \
+ (byte & 0x20 ? 1 : 0), \
+ (byte & 0x10 ? 1 : 0), \
+ (byte & 0x08 ? 1 : 0), \
+ (byte & 0x04 ? 1 : 0), \
+ (byte & 0x02 ? 1 : 0), \
+ (byte & 0x01 ? 1 : 0)
+
+int main(int argc, char **argv)
+{
+ signed char *c=malloc(3*sizeof(char)), i;
+ while(1){
+ for(i=0; i<3; i++)
+ c[i] = getchar();
+ printf("%2x %2x %2x ", (unsigned char)c[0], (unsigned char)c[1], (unsigned char)c[2]);
+ printf(": "B2BP B2BP B2BP" ", B2B(c[0]), B2B(c[1]), B2B(c[2]));
+ printf(": %d %d %d\n", (signed char)c[0], (signed char)c[1], (signed char)c[2]);
+ }
+ return 0;
+}