/* STRIP -- If any character has the hi order bit on, turn it off. 
   Mark Lerner, CUCCA User Services, August 1983
   Usage: STRIP <input filename> <output filename>
*/

#include <stdio.h>
#define MAXBUFF 1024

main(argc,argv)
  int argc;
  char **argv;
  { char line[MAXBUFF];
    int  j;
    int incnt  = 0;
    int outcnt = 0;
    char *infile, *outfile;
    int   infr,    outfr, inlen, eof;
    infile  = *++argv;
    outfile = *++argv; 
    fprintf(stderr,"Copy from %s to %s.\n",infile,outfile);
    if((infr=open(infile, BREAD))==0)
      {fprintf(stderr,"Can't open file %s.\n",infile);
       exit(1);
      }
    if((outfr=creat(outfile, BWRITE))==0)
      {fprintf(stderr,"Can't open file %s.\n",outfile);
       exit(1);
      }

    for(eof=0;eof==0;)
    { inlen=read(infr,line,MAXBUFF);
      if (inlen<=0) 
        eof=1; 
      else 
        { incnt=incnt+inlen;
          for(j=0;j<=inlen;j++)line[j]=line[j] & 0177;
          inlen=write(outfr,line,inlen);
	  outcnt=outcnt+inlen;
        }
    }
    if(incnt==outcnt) 
      printf("Copied %d characters.\n",incnt);
    else
      printf("ERROR: Read %d characters and wrote %d characters!\n",
	      incnt,outcnt);
    close(infr);
    close(outfr);
 }
