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 [-n count] [-x] [prefix [suffix]]\n",
28 main(int argc, char *argv[])
30 int c, count, linepos, maxcount, radix;
34 while ((c = getopt(argc, argv, "n:x")) != -1) {
36 case 'n': /* Max. number of bytes per line. */
37 maxcount = strtol(optarg, NULL, 10);
39 case 'x': /* Print hexadecimal numbers. */
51 printf("%s\n", argv[0]);
53 while((c = getchar()) != EOF) {
58 if ((maxcount == 0 && linepos > 70) ||
59 (maxcount > 0 && count >= maxcount)) {
65 linepos += printf("%d", c);
68 linepos += printf("0x%02x", c);
77 printf("%s\n", argv[1]);