2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
10 #include <sys/cdefs.h>
11 __FBSDID("$FreeBSD$");
22 fprintf(stderr, "usage: %s [-sx] [-n count] [prefix [suffix]]\n",
28 main(int argc, char *argv[])
30 int c, count, linepos, maxcount, pretty, radix;
35 while ((c = getopt(argc, argv, "n:sx")) != -1) {
37 case 'n': /* Max. number of bytes per line. */
38 maxcount = strtol(optarg, NULL, 10);
40 case 's': /* Be more style(9) comliant. */
43 case 'x': /* Print hexadecimal numbers. */
55 printf("%s\n", argv[0]);
57 while((c = getchar()) != EOF) {
62 if ((maxcount == 0 && linepos > 70) ||
63 (maxcount > 0 && count >= maxcount)) {
78 linepos += printf("%d", c);
81 linepos += printf("0x%02x", c);
90 printf("%s\n", argv[1]);