/* http://www.mrwadlo.com */ #include #include void showpercent(int percent); void createfilename(); int symbolcheck( char sym ); int repcheck( char sym, char p1, char p2, char p3 ); void setdefault(); int mark; char inputfile[15]; char outputfile[15]; char settings[19]; int main() { long i; long filesize; char sym, p1, p2, p3; int percent; int selected = 0; int len; long counter = 0; FILE *fpREAD; FILE *fpWRITE; clrscr(); do { printf("\n Enter First Filename Using 8.3 limit: "); scanf("%12s", &inputfile); if ( fopen(inputfile,"rb") ) break; else printf(" %s <-- No Such File, Try Again!", inputfile); } while ( 1 ); sym = 0; setdefault(); do { clrscr(); switch ( sym ) { case 72: if ( selected > 0 ) { selected--; } break; case 80: if ( selected < 20 ) { selected++; } break; case 13: if ( ( selected != 19 ) && ( selected != 20 ) ) { settings[selected] = ( settings[selected] + 1 ) % 2; } break; } printf("\n Lowercase : : "); if (settings[0] == 1) { printf("YES"); } else { printf("NO"); } printf("\n Uppercase : : "); if (settings[1] == 1) { printf("YES"); } else { printf("NO"); } printf("\n Numerical : : "); if (settings[2] == 1) { printf("YES"); } else { printf("NO"); } printf("\n Spaces : : "); if (settings[3] == 1) { printf("YES"); } else { printf("NO"); } printf("\n Tabs : : "); if (settings[4] == 1) { printf("YES"); } else { printf("NO"); } printf("\n Linefeeds : : "); if (settings[5] == 1) { printf("YES"); } else { printf("NO"); } printf("\n Chars : .,?!@_ : "); if (settings[6] == 1) { printf("YES"); } else { printf("NO"); } printf("\n Chars : '\":; : "); if (settings[7] == 1) { printf("YES"); } else { printf("NO"); } printf("\n Chars : @#$%%^&* : "); if (settings[8] == 1) { printf("YES"); } else { printf("NO"); } printf("\n Chars : ()[]{}<> : "); if (settings[9] == 1) { printf("YES"); } else { printf("NO"); } printf("\n Math : +-*/=^%%$ : "); if (settings[10] == 1) { printf("YES"); } else { printf("NO"); } printf("\n Special : ~`_|\\ : "); if (settings[11] == 1) { printf("YES"); } else { printf("NO"); } printf("\n Null char : %c : ",237); if (settings[12] == 1) { printf("YES"); } else { printf("NO"); } printf("\n ASCII : 1-127 : "); if (settings[13] == 1) { printf("YES"); } else { printf("NO"); } printf("\n ASCII ext : 128-175 : "); if (settings[14] == 1) { printf("YES"); } else { printf("NO"); } printf("\n ASCII ext : 176-223 : "); if (settings[15] == 1) { printf("YES"); } else { printf("NO"); } printf("\n ASCII ext : 224-255 : "); if (settings[16] == 1) { printf("YES"); } else { printf("NO"); } printf("\n 4+ Repeat : Any Char : "); if (settings[17] == 1) { printf("YES"); } else { printf("NO"); } printf("\n Long Word : Len > 30 : "); if (settings[18] == 1) { printf("YES"); } else { printf("NO"); } printf("\n Done and Go!"); printf("\n Exit"); gotoxy(29,selected+2); printf("%c",17); if ( selected == 0 ) { printf(" (a-z.)"); } if ( selected == 1 ) { printf(" (A-Z.)"); } if ( selected == 2 ) { printf(" (0-9.)"); } if ( selected == 3 ) { printf(" (ASCII 32.)"); } if ( selected == 4 ) { printf(" (ASCII 9.)"); } if ( selected == 5 ) { printf(" (ASCII 10 and 13.)"); } if ( selected == 12 ) { printf(" (ASCII character 0, often displays as a space.)"); } if ( selected == 13 ) { printf(" (Includes all english keyboard characters.)"); } if ( selected == 14 ) { printf(" (Extended ASCII characters; many non-english.)"); } if ( selected == 15 ) { printf(" (Extended ASCII characters; display symbols.)"); } if ( selected == 16 ) { printf(" (Extended ASCII characters; Greek and math.)"); } if ( selected == 17 ) { printf(" (Limit repeating character to 3x.)"); } if ( selected == 18 ) { printf(" (Chop English words of lenth greater than 30.)"); } if ( selected == 19 ) { printf(" (Run with current settings.)"); } if ( selected == 20 ) { printf(" (Do not run.)"); } sym = getch(); } while ( sym != 13 || ( selected != 19 && selected != 20 ) ); if ( selected == 20 ) return 0; printf("%c",13); for ( i=0 ; i<38 ; i++ ) printf("- "); createfilename(); printf("\n Outputting to: %s", outputfile); fpREAD = fopen(inputfile,"rb"); fpWRITE = fopen(outputfile,"wb"); fseek(fpREAD, 0, SEEK_END); filesize = ftell(fpREAD); rewind(fpREAD); printf("\n %12s ", inputfile); percent = 0; len = 0; for ( i=0 ; i < filesize ; i++ ) { fread(&sym, 1, 1, fpREAD); if ( ( ( sym >= 'a' && sym <= 'z' ) || ( sym >= 'A' && sym <= 'Z' ) ) ) { if ( len <=30 ) { len++; } } else { len = 0; } if ( symbolcheck(sym) && repcheck( sym, p1, p2, p3 ) && ( len <= 30 || settings[18] == 0 ) ) { fwrite(&sym, 1, 1, fpWRITE); counter++; p3 = p2; p2 = p1; p1 = sym; } if ( 100*i/filesize > percent ) { percent++; showpercent(percent); } } while (percent < 100 ) showpercent(++percent); fclose(fpREAD); fclose(fpWRITE); printf("\n Done. Nearly %ld%% of file cleared. Press Any Key To Exit...", 100L - (100*counter/(filesize)) ); getch(); return 0; } void showpercent(int percent) { if( percent % 2 == 0) { mark++; if ( mark % 2 == 0) { printf("%c",223); } else { printf("%c",220); } printf(" %3d%%", percent); printf("\b\b\b\b\b"); } } void createfilename() { int i; for ( i=0 ; i<13 ; i++ ) { if ( inputfile[i] == '.' ) break; else outputfile[i] = 'O'; } while ( i<13 && inputfile[i] != '\n') { outputfile[i] = inputfile[i]; i++; } } int symbolcheck( char sym ) { if ( settings[0] == 1 && sym >= 'a' && sym <= 'z' ) return 1; else if ( settings[1] == 1 && sym >= 'A' && sym <= 'Z' ) return 1; else if ( settings[2] == 1 && sym >= '0' && sym <= '9' ) return 1; else if ( settings[3] == 1 && sym == ' ' ) return 1; else if ( settings[4] == 1 && sym == 9 ) /* tab */ return 1; else if ( settings[5] == 1 && ( sym == 10 || sym == 13 ) ) return 1; else if ( settings[6] == 1 && ( sym == '.' || sym == ',' || sym == '?' || sym == '!' || sym == '@' || sym == '_' ) ) return 1; else if ( settings[7] == 1 && ( sym == 39 || sym == '"' || sym == ':' || sym == ';' ) ) return 1; else if ( settings[8] == 1 && ( sym == '@' || sym == '#' || sym == '%' || sym == '^' || sym == '&' || sym == '*' ) ) return 1; else if ( settings[9] == 1 && ( sym == '(' || sym == ')' || sym == '[' || sym == ']' || sym == '{' || sym == '}' || sym == '<' || sym == '>' ) ) return 1; else if ( settings[10] == 1 && ( sym == '+' || sym == '-' || sym == '*' || sym == '/' || sym == '=' || sym == '^' || sym == '%' || sym == '$' ) ) return 1; else if ( settings[11] == 1 && ( sym == '~' || sym == '`' || sym == '_' || sym == '|' || sym == '\\' ) ) return 1; else if ( settings[12] == 1 && ( sym == 0 ) ) return 1; else if ( settings[13] == 1 && sym >= 1 && sym <= 127 ) return 1; else if ( settings[14] == 1 && sym >= -128 && sym <= -81 ) return 1; else if ( settings[15] == 1 && sym >= -80 && sym <= -33 ) return 1; else if ( settings[16] == 1 && sym >= -32 && sym <= -1 ) return 1; else { return 0; } } int repcheck( char sym, char p1, char p2, char p3 ) { if ( settings[17] == 0 ) return 1; else if ( sym == p1 && p1 == p2 && p2 == p3 ) { return 0; } else return 1; } void setdefault() { settings[0] = 0; settings[1] = 0; settings[2] = 0; settings[3] = 0; settings[4] = 0; settings[5] = 0; settings[6] = 0; settings[7] = 0; settings[8] = 0; settings[9] = 0; settings[10] = 0; settings[11] = 0; settings[12] = 0; settings[13] = 0; settings[14] = 0; settings[15] = 0; settings[16] = 0; settings[17] = 0; settings[18] = 0; settings[19] = 0; }