#include #include #include #include #include #include #include #define NEVER 1 #define MAYBE 2 #define ALWAYS 3 #define COMPAT 4 static int print_names = MAYBE; static int size = -1; extern const char *__progname; static const char *algname(int size) { switch (size) { case 0: return("SHA"); break; case 1: return("SHA1"); break; case 224: return("SHA224"); break; case 256: return("SHA256"); break; case 384: return("SHA384"); break; case 512: return("SHA512"); break; } abort(); } static void process_file( int fd, int pnames, const char *fn_out, const char *fn_err) { void *h; int n; int l; static char buf[65536]; h = shaX_init(size); while (1) { n = read(fd,&buf[0],sizeof(buf)); if (n < 0) { fprintf(stderr,"%s: read error on %s: %s\n",__progname,fn_err,strerror(errno)); n = 0; } if (n == 0) { l = shaX_hashsize(h); shaX_result(h,&buf[0]); if (pnames == COMPAT) printf("%s (%s) = ",algname(size),fn_out); for (n=0;n