]> git.ipfire.org Git - thirdparty/git.git/blame - t/helper/test-hexdump.c
Merge branch 'ob/t9001-indent-fix'
[thirdparty/git.git] / t / helper / test-hexdump.c
CommitLineData
9915e08f
JH
1#include "test-tool.h"
2#include "git-compat-util.h"
3
4/*
5 * Read stdin and print a hexdump to stdout.
6 */
126e3b3d 7int cmd__hexdump(int argc UNUSED, const char **argv UNUSED)
9915e08f
JH
8{
9 char buf[1024];
10 ssize_t i, len;
11 int have_data = 0;
12
13 for (;;) {
14 len = xread(0, buf, sizeof(buf));
15 if (len < 0)
16 die_errno("failure reading stdin");
17 if (!len)
18 break;
19
20 have_data = 1;
21
22 for (i = 0; i < len; i++)
23 printf("%02x ", (unsigned char)buf[i]);
24 }
25
26 if (have_data)
27 putchar('\n');
28
29 return 0;
30}