diff options
-rw-r--r-- | ui-tree.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/ui-tree.c b/ui-tree.c index a37a4e5..c6159ec 100644 --- a/ui-tree.c +++ b/ui-tree.c | |||
@@ -37,21 +37,26 @@ static void print_text_buffer(char *buf, unsigned long size) | |||
37 | html("</code></pre></td></tr></table>\n"); | 37 | html("</code></pre></td></tr></table>\n"); |
38 | } | 38 | } |
39 | 39 | ||
40 | #define ROWLEN 32 | ||
41 | |||
40 | static void print_binary_buffer(char *buf, unsigned long size) | 42 | static void print_binary_buffer(char *buf, unsigned long size) |
41 | { | 43 | { |
42 | unsigned long ofs, idx; | 44 | unsigned long ofs, idx; |
45 | static char ascii[ROWLEN + 1]; | ||
43 | 46 | ||
44 | html("<table summary='blob content' class='bin-blob'>\n"); | 47 | html("<table summary='blob content' class='bin-blob'>\n"); |
45 | html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>"); | 48 | html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>"); |
46 | for (ofs = 0; ofs < size; ofs += 32, buf += 32) { | 49 | for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) { |
47 | htmlf("<tr><td class='right'>%04x</td><td class='hex'>", ofs); | 50 | htmlf("<tr><td class='right'>%04x</td><td class='hex'>", ofs); |
48 | for (idx = 0; idx < 32 && ofs + idx < size; idx++) | 51 | for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) |
49 | htmlf("%*s%02x", | 52 | htmlf("%*s%02x", |
50 | idx == 16 ? 4 : 1, "", | 53 | idx == 16 ? 4 : 1, "", |
51 | buf[idx] & 0xff); | 54 | buf[idx] & 0xff); |
52 | html(" </td><td class='hex'>"); | 55 | html(" </td><td class='hex'>"); |
53 | for (idx = 0; idx < 32 && ofs + idx < size; idx++) | 56 | for (idx = 0; idx < ROWLEN && ofs + idx < size; idx++) |
54 | htmlf("%c", isgraph(buf[idx]) ? buf[idx] : '.'); | 57 | ascii[idx] = isgraph(buf[idx]) ? buf[idx] : '.'; |
58 | ascii[idx] = '\0'; | ||
59 | html_txt(ascii); | ||
55 | html("</td></tr>\n"); | 60 | html("</td></tr>\n"); |
56 | } | 61 | } |
57 | html("</table>\n"); | 62 | html("</table>\n"); |