summaryrefslogtreecommitdiff
path: root/other/burneye/src/stub/utils/hdump.c
blob: 7d057f164f2e58eff15ab7a289a0430be8864cd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45













#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>


int
main (int argc, char *argv[])
{
	unsigned char	i;
	unsigned int	dp = 0;	/* data pointer */


	while (read (0, &i, 1) > 0) {
		if (dp % 16 == 0)
			printf ("\"");

		printf ("\\x%02x", i);

		dp += 1;
		if (dp % 16 == 0)
			printf ("\"\n");
	}

	if (dp % 16 != 0)
		printf ("\";\n");
	else
		printf ("\"\";\n");

	exit (EXIT_SUCCESS);
}