diff options
author | stig <stig@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-11-05 15:40:44 +0000 |
---|---|---|
committer | stig <stig@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-11-05 15:40:44 +0000 |
commit | c233d411d67c3d2cb881c0a62dd4d58248d36289 (patch) | |
tree | 6b3d75ebd5a5a9da30074805ce5f1db9010ecb33 /gtk/main_proto_draw.c | |
parent | 363f3c901f88be84fd001d4d506acdbf283b8c18 (diff) |
Simplified printing of bits in packet bytes view.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@30835 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'gtk/main_proto_draw.c')
-rw-r--r-- | gtk/main_proto_draw.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/gtk/main_proto_draw.c b/gtk/main_proto_draw.c index 853ffa6458..1667829d7e 100644 --- a/gtk/main_proto_draw.c +++ b/gtk/main_proto_draw.c @@ -1117,11 +1117,13 @@ static void packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart, int bend, int astart, int aend, int encoding) { - int i = 0, j, k = 0, cur; + int i = 0, j, k = 0, b, cur; guchar line[MAX_LINES_LEN + 1]; static guchar hexchars[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + static const guint8 bitmask[8] = { + 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; guchar c = '\0'; unsigned int use_digits; gboolean reverse, newreverse; @@ -1267,24 +1269,25 @@ packet_hex_print_common(GtkWidget *bv, const guint8 *pd, int len, int bstart, line[cur++] = hexchars[pd[i] & 0x0f]; break; case BYTES_BITS: - line[cur++] = (pd[i] & 0x80) ? '1' : '0'; - line[cur++] = (pd[i] & 0x40) ? '1' : '0'; - line[cur++] = (pd[i] & 0x20) ? '1' : '0'; - line[cur++] = (pd[i] & 0x10) ? '1' : '0'; - line[cur++] = (pd[i] & 0x08) ? '1' : '0'; - line[cur++] = (pd[i] & 0x04) ? '1' : '0'; - line[cur++] = (pd[i] & 0x02) ? '1' : '0'; - line[cur++] = (pd[i] & 0x01) ? '1' : '0'; + for (b = 0; b < 8; b++) { + line[cur++] = (pd[i] & bitmask[b]) ? '1' : '0'; + } break; default: g_assert_not_reached(); } } else { - line[cur++] = ' '; line[cur++] = ' '; - if (recent.gui_bytes_view == BYTES_BITS) { - line[cur++] = ' '; line[cur++] = ' '; - line[cur++] = ' '; line[cur++] = ' '; + switch (recent.gui_bytes_view) { + case BYTES_HEX: line[cur++] = ' '; line[cur++] = ' '; + break; + case BYTES_BITS: + for (b = 0; b < 8; b++) { + line[cur++] = ' '; + } + break; + default: + g_assert_not_reached(); } } i++; |