home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / UTILITY / SWC.ZIP / SWC.C
Text File  |  1994-01-16  |  1KB  |  56 lines

  1. Diamond #196 @3950
  2. Sat Jan 15 21:15:33 1994
  3. 0R: net33: @3113 (via @1021) [23:03 01/16/94]
  4. 0R: net34: @1021 (via @1040) [20:21 01/16/94]
  5. 0R: net33: @1040 (via @2050) [12:14 01/16/94]
  6. 0R: net34: @2050 [10:25 01/16/94]
  7. 0R: net34: @2050 (via @1040) [02:47 01/16/94]
  8. 0R: net33: @1040 (via @1021) [03:08 01/16/94]
  9. 0R: net34: @1021 (via @3950) [23:39 01/15/94]
  10. 0R: net34: @3950 [21:47 01/15/94]
  11. RE: ASCII strip program
  12. BY: Nirvana #1 @6655
  13.  
  14. /*
  15.  *   SWC.C
  16.  *   This program will strip WWIV color codes (heart codes) from a file.
  17.  *
  18.  *   Source code written by Diamond #1 @3956
  19.  *   Please give credit where credit is due.
  20.  */
  21.  
  22. #include <stdio.h>
  23. #include <fcntl.h>
  24. #include <share.h>
  25. #include <sys\stat.h>
  26.  
  27. void main(int argc,char **argv)
  28. {
  29.   int input,output,i;
  30.   unsigned char ch;
  31.  
  32.   if(argc<2) {
  33.     printf("Must specify filename.\n");
  34.     exit(1);
  35.   }
  36.  
  37.   input=open(argv[1],O_RDONLY|O_BINARY);
  38.   if(input==NULL) {
  39.     printf("Bad filename \"%s\"",argv[1]);
  40.     exit(1);
  41.   }
  42.   output=open("TEMP.XXX",O_CREAT|O_TRUNC|O_RDWR|O_CREAT,S_IREAD|S_IWRITE);
  43.  
  44.   i=_read(input,&ch,1);
  45.   while(i>0) {
  46.     if(ch!=3)
  47.       _write(output,&ch,1);
  48.     else
  49.       _read(input,&ch,1);
  50.     i=_read(input,&ch,1);
  51.   }
  52.   close(input);
  53.   close(output);
  54.   unlink(argv[1]);
  55.   rename("TEMP.XXX",argv[1]);
  56. }