1: #include <stdio.h>
2:
3: unsigned count = 1000;
4: int fnumber;
5: char fname[100];
6: char *ifil;
7: char *ofil;
8: FILE *is;
9: FILE *os;
10:
11: main(argc, argv)
12: char *argv[];
13: {
14: register i, c, f;
15: int iflg = 0;
16:
17: for(i=1; i<argc; i++)
18: if(argv[i][0] == '-')
19: switch(argv[i][1]) {
20:
21: case '\0':
22: iflg = 1;
23: continue;
24:
25: case '0':
26: case '1':
27: case '2':
28: case '3':
29: case '4':
30: case '5':
31: case '6':
32: case '7':
33: case '8':
34: case '9':
35: count = atoi(argv[i]+1);
36: continue;
37: }
38: else
39: if(iflg)
40: ofil = argv[i];
41: else {
42: ifil = argv[i];
43: iflg = 2;
44: }
45: if(iflg != 2)
46: is = stdin;
47: else
48: if((is=fopen(ifil,"r")) == NULL) {
49: perror(ifil);
50: exit(1);
51: }
52: if(ofil == 0)
53: ofil = "x";
54:
55: loop:
56: f = 1;
57: for(i=0; i<count; i++)
58: do {
59: c = getc(is);
60: if(c == EOF) {
61: if(f == 0)
62: fclose(os);
63: exit(0);
64: }
65: if(f) {
66: for(f=0; ofil[f]; f++)
67: fname[f] = ofil[f];
68: fname[f++] = fnumber/26 + 'a';
69: fname[f++] = fnumber%26 + 'a';
70: fname[f] = '\0';
71: if (fnumber++ >= 26 * 26) {
72: fprintf(stderr, "Too many files\n");
73: exit(1);
74: }
75: if((os=fopen(fname,"w")) == NULL) {
76: perror ("write");
77: exit(1);
78: }
79: f = 0;
80: }
81: if ((putc(c, os) == EOF) && ferror(os)) {
82: perror("write");
83: exit(1);
84: }
85: } while(c != '\n');
86: fclose(os);
87: goto loop;
88: }
Defined functions
main
defined in line
11;
never used
Defined variables
count
defined in line
3; used 2 times
fname
defined in line
5; used 5 times
ifil
defined in line
6; used 3 times
ofil
defined in line
7; used 5 times