#include #include #include #include #include #include #include #define ARRAY_SIZE(foo) (sizeof(foo)/sizeof(foo[0])) char codes[] = {39,38,44,43,49,48,84,83,119,118,154,148,184,178,214,208,209,203,204,198,199,163,164,128,129,93,99,63,69,33}; void usage(){ printf("Usage: lolcat [-h horizontal_speed] [-v vertical_speed] [--] [FILES...]\n"); exit(1); } int main(int argc, char **argv){ int c, cc=-1, i, l=0; double freq_h = 0.23, freq_v = 0.1; for(i=1;i 0){ if(c == '\n'){ l++; i = 0; }else if(isprint(c)){ int ncc = (int)((i++)*freq_h + l*freq_v); if(ncc != cc) printf("\033[38;5;%hhum", codes[(cc = ncc) % ARRAY_SIZE(codes)]); } printf("%lc", c); } if(c != WEOF){ fprintf(stderr, "Error reading input file \"%s\": %s (%d)\n", *filename, strerror(errno), errno); return 2; } fclose(f); } }