Annotation of src/usr.bin/file2c/file2c.c, Revision 1.3
1.3 ! deraadt 1: /* $OpenBSD: file2c.c,v 1.2 2001/07/12 05:17:03 deraadt Exp $ */
1.1 downsj 2: /*
3: * ----------------------------------------------------------------------------
4: * "THE BEER-WARE LICENSE" (Revision 42):
5: * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
6: * can do whatever you want with this stuff. If we meet some day, and you think
7: * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
8: * ----------------------------------------------------------------------------
9: *
10: * $FreeBSD: file2c.c,v 1.1 1995/01/29 00:49:57 phk Exp $
11: *
12: */
13:
14: #include <stdio.h>
15:
16: int
1.3 ! deraadt 17: main(int argc, char *argv[])
1.1 downsj 18: {
1.3 ! deraadt 19: int i, j, k;
1.1 downsj 20:
1.3 ! deraadt 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:
! 35: printf("%d", i);
! 36:
! 37: if (i > 99)
! 38: j += 3;
! 39: else if (i > 9)
! 40: j += 2;
! 41: else
! 42: j++;
1.1 downsj 43: }
1.3 ! deraadt 44: putchar('\n');
! 45: if (argc > 2)
! 46: printf("%s\n", argv[2]);
! 47: return 0;
1.1 downsj 48: }