/* * freq_analysis.c * (c)Steve Parker, 31st Oct 2003 * GPL v2 for now. * http://www.gnu.org/copyleft/gpl.html * * See also crypto.c * This is just a quick utility to generate a structure definition from a given piece of text. */ #include #define MAXCRYPTO 999999 // Longest string to be translated struct freq { int f; char c; char t; }; void bubblesort(struct freq a[], int n) { int i,j; struct freq tmp; for (j=0; j0) { while (f[i].c<0) f[i].c+=255; if (((int)f[i].c < 127) && ((int)f[i].c!=10)) { // don't bother with 8-bit ASCII for now //printf("%4d : %c (%03d)\n", f[i].f, f[i].c, f[i].c); printf("'%c', ", f[i].c); } } j++; } printf(" };\n"); } int main(int argc, char *argv[]) { char *p; char *s; FILE *in; p=(char*)malloc(MAXCRYPTO); s=(char*)malloc(255); in=fopen(argv[1], "rb"); while (fgets(s, 255, in)) { strcat(p, s); } fclose(in); freq_analysis(p); free(p); return 0; }