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 * $FreeBSD: src/usr.bin/file2c/file2c.c,v 1.5 1999/08/28 01:01:10 peter Exp $ 10 * $DragonFly: src/usr.bin/file2c/file2c.c,v 1.2 2003/06/17 04:29:26 dillon Exp $ 11 * 12 */ 13 14 #include <stdio.h> 15 16 int 17 main(int argc, char **argv) 18 { 19 int i,j,k; 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