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 * ----------------------------------------------------------------------------
9 * $FreeBSD: src/usr.bin/file2c/file2c.c,v 1.11 2007/10/30 17:49:00 ru Exp $
10 * $DragonFly: src/usr.bin/file2c/file2c.c,v 1.4 2008/04/05 09:12:45 swildner Exp $
23 fprintf(stderr, "usage: %s [-sx] [-n count] [prefix [suffix]]\n",
29 main(int argc, char *argv[])
31 int c, count, linepos, maxcount, pretty, radix;
36 while ((c = getopt(argc, argv, "n:sx")) != -1) {
38 case 'n': /* Max. number of bytes per line. */
39 maxcount = strtol(optarg, NULL, 10);
41 case 's': /* Be more style(9) compliant. */
44 case 'x': /* Print hexadecimal numbers. */
56 printf("%s\n", argv[0]);
58 while((c = getchar()) != EOF) {
63 if ((maxcount == 0 && linepos > 70) ||
64 (maxcount > 0 && count >= maxcount)) {
79 linepos += printf("%d", c);
82 linepos += printf("0x%02x", c);
91 printf("%s\n", argv[1]);