From 8fe7f3a09bb2d963ff6b805a835a4f18da5a96d9 Mon Sep 17 00:00:00 2001 From: Sebastian Hack Date: Mon, 4 Oct 2004 12:05:23 +0000 Subject: [PATCH] Implemented get_tarval_bitpattern() [r4027] --- ir/tv/tv.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ir/tv/tv.c b/ir/tv/tv.c index 80af06155..d348ce226 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -1479,7 +1479,22 @@ int tarval_printf(tarval *tv) { char *get_tarval_bitpattern(tarval *tv) { - return NULL; + int i, j, pos = 0; + int n = get_mode_size_bits(tv->mode); + int bytes = n / 8 + ((n & 7) != 0); + char *res = malloc((n + 1) * sizeof(char)); + unsigned char byte; + + for(i = 0; i < bytes; i++) { + byte = get_tarval_sub_bits(tv, i); + for(j = 1; j < 256; j <<= 1) + if(pos < n) + res[pos++] = j & byte ? '1' : '0'; + } + + res[n] = '\0'; + + return res; } /* -- 2.20.1