xref: /freebsd/usr.bin/file2c/file2c.c (revision 05c7a37afb48ddd5ee1bd921a5d46fe59cc70b15)
1 /*
2  * ----------------------------------------------------------------------------
3  * "THE BEER-WARE LICENSE" (Revision 42):
4  * <phk@login.dknet.dk> 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  * ----------------------------------------------------------------------------
8  *
9  * $Id$
10  *
11  */
12 
13 #include <stdio.h>
14 
15 int
16 main(int argc, char **argv)
17 {
18     int i,j,k;
19     char s[10];
20 
21     if (argc > 1)
22         printf("%s\n",argv[1]);
23     k = 0;
24     j = 0;
25     while((i = getchar()) != EOF) {
26 	if(k++) {
27 	    putchar(',');
28 	    j++;
29 	}
30 	if (j > 70) {
31 	    putchar('\n');
32 	    j = 0;
33 	}
34 	printf("%d",i);
35 	if (i > 99)
36 	    j += 3;
37 	else if (i > 9)
38 	    j += 2;
39 	else
40 	    j++;
41     }
42     putchar('\n');
43     if (argc > 2)
44         printf("%s\n",argv[2]);
45     return 0;
46 }
47