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 if(iflg)
  39:             ofil = argv[i];
  40:         else {
  41:             ifil = argv[i];
  42:             iflg = 2;
  43:         }
  44:     if(iflg != 2)
  45:         is = stdin;
  46:     else
  47:         if((is=fopen(ifil,"r")) == NULL) {
  48:             fprintf(stderr,"cannot open input\n");
  49:             exit(1);
  50:         }
  51:     if(ofil == 0)
  52:         ofil = "x";
  53: 
  54: loop:
  55:     f = 1;
  56:     for(i=0; i<count; i++)
  57:     do {
  58:         c = getc(is);
  59:         if(c == EOF) {
  60:             if(f == 0)
  61:                 fclose(os);
  62:             exit(0);
  63:         }
  64:         if(f) {
  65:             for(f=0; ofil[f]; f++)
  66:                 fname[f] = ofil[f];
  67:             fname[f++] = fnumber/26 + 'a';
  68:             fname[f++] = fnumber%26 + 'a';
  69:             fname[f] = '\0';
  70:             fnumber++;
  71:             if((os=fopen(fname,"w")) == NULL) {
  72:                 fprintf(stderr,"Cannot create output\n");
  73:                 exit(1);
  74:             }
  75:             f = 0;
  76:         }
  77:         putc(c, os);
  78:     } while(c != '\n');
  79:     fclose(os);
  80:     goto loop;
  81: }

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
fnumber defined in line 4; used 3 times
ifil defined in line 6; used 2 times
ofil defined in line 7; used 5 times
Last modified: 1979-01-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 631
Valid CSS Valid XHTML 1.0 Strict