/********************************************************************
               uustrip
 this program is designed to search a uuencoded file and remove the
 mail headers which (might) be found in it.  It outputs another file 
 with the same name as the first, with _s appended to it.
 
               rw salnick 1/3/92
*********************************************************************/
#include <stdio.h>
# define MAXLINE 255

main (argc,argv)

int argc;
char * argv[];

{
 char copyright[] = "Copyright RW Salnick, 1992";
 FILE *infile, *outfile; 
 char outfilename[255], line[MAXLINE];
 
 if (argc !=2)

   {
    printf ("Usage:\n");
    printf ("uustrip filename\n");
    printf ("   where filename is a uuencoded file to be decoded.\n");
    printf ("The output file produced will be 'filename_s'.\n");
    printf ("%s\n",copyright);
    exit(0);
   }
 
 infile = fopen(argv[1],"r");  
 if (infile > 0)
   {
    strcpy(outfilename,argv[1]);
    strcat(outfilename,"_s");  
    outfile = fopen(outfilename, "w");
    if (outfile > 0)
         {
          while (fgets(line,MAXLINE,infile) != NULL)
            {
               if (
                   (strncmp(line,"Message",7) ==0) |
                   (strncmp(line,"Date",4) ==0) |
                   (strncmp(line,"To:",3) ==0) |
                   (strncmp(line,"Subject",7) ==0) |
                   (strncmp(line,"From",4) ==0) |
                   (strncmp(line,"Received",8) ==0)|
                   (line[0]=='\n') |
                   (line[0]=='\t'))
                     {
                        printf("\033[32mStripped: \033[0m%s",line);
                     }
               else
                     {      
                       fprintf(outfile,"%s",line);
                     }  
            } /* end of read */

         fprintf(outfile,"\n");
         fclose(outfile);  
         }
    fclose (infile);
   }        
}
