/* mol text, (c)JTHZ april'96
   TC3 compilation, feb97 */

#include <dir.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>


void main(int argc,char*argv[]){
    FILE *f1,*f2;
    int c;
    char buf[13];
    char buf2[5];

    randomize();
    if(argc!=2){
        printf("#2 file\n");
        exit(0);
    }
    if(access(argv[1],0)){
        printf("Can't find %s!\n",argv[1]);
        exit(0);
    }
    fnsplit(argv[1],NULL,NULL,buf,buf2);
    if(strcmpi(".bak",buf2))
        strcat(buf,".bak");
    else
        strcat(buf,".kut");

    unlink(buf);
    rename(argv[1],buf);

    f1=fopen(buf,"r");
    f2=fopen(argv[1],"w");

    for(;;){
        c=fgetc(f1);
        if(feof(f1))
            break;
        switch(c){
        case 'a':
            fputc('',f2); 
            break;
        case 'c':
            if(random(2))
                fputc('',f2);
            else
                fputc('c',f2);
            break;
        case 'd':
            fputc('',f2); 
            break;
        case 'e':
            if(random(2))
                fputc('',f2);
            else
                fputc('e',f2);
            break;
        case 'f':
            fputc('',f2); 
            break;
        case 'i':
            if(random(2))
                fputc('',f2);
            else
                fputc('|',f2);
            break;
        case 'l':
            if(random(2))
                fputc('',f2);
            else
                fputc('l',f2);
            break;
        case 'n':
            fputc('',f2); 
            break;
        case 'o':
            fputc('',f2); 
            break;
        case 'r':
            c=random(4);
            if(c>=2)
                fputc('',f2);
            else if(c==1)
                fputc('',f2);
            else
                fputc('',f2);
            break;
        case 'u':
            if(random(2))
                fputc('',f2);
            else
                fputc('u',f2);
            break;
        case 'y':
            if(random(3))
                fputc('y',f2);
            else
                fputc('',f2);
            break;
        case 'A':
            if(random(2))
                fputc('',f2);
            else
                fputc('A',f2);
            break;
        case 'B':
            if(random(2))
                fputc('',f2);
            else
                fputc('B',f2);
            break;
        case 'C':
            c=random(3);
            if(c==2)
                fputc('C',f2);
            else if(c==1)
                fputc('(',f2);
            else
                fputc('<',f2);
            break;
        case 'E':
            c=random(3);
            if(c==2)
                fputc('',f2);
            else if(c==1)
                fputc('E',f2);
            else
                fputc('',f2);
            break;
        case 'F':
            if(random(2))
                fputc('',f2);
            else
                fputc('',f2);
            break;
        case 'H':
            if(random(2))
                fprintf(f2,"ô");
            else
                fputc('H',f2);
            break;
        case 'J':
            fputc('',f2); 
            break;
        case 'M':
            if(random(2))
                fprintf(f2,"¿");
            else
                fputc('M',f2);
            break;
        case 'N':
            if(random(2))
                fputc('',f2);
            else
                fprintf(f2,"¿");
            break;
        case 'O':
            fputc('',f2); 
            break;
        case 'R':
            if(random(2))
                fputc('',f2);
            else
                fputc('R',f2);
            break;
        case 'S':
            fputc('$',f2); 
            break;
        case 'T':
            c=random(3);
            if(c==2)
                fputc('',f2);
            else if(c==1)
                fputc('',f2);
            else
                fputc('',f2);
            break;
        case 'V':
            if(random(2))
                fputc('',f2);
            else
                fputc('V',f2);
            break;
        case 'Y':
            if(random(3))
                fputc('',f2);
            else
                fputc('Y',f2);
            break;
        default:
            fputc(c,f2);
        }
    }
    fcloseall();
}
