-u, --usage Display a terse usage message.\n\
\n\
-a, --algorithm=ALG Use the message digest algorithm ALG.\n\
+-E, --encoding=ENC Represent hashes using encoding ENC.\n\
\n\
-f, --files Read a list of file names from standard input.\n\
-0, --null File names are null terminated, not plain text.\n\
-b, --binary When reading files, treat them as binary.\n\
-v, --verbose Be verbose when checking digests.\n\
\n\
-For a list of supported message digest algorithms, type `$ --list'.\n\
+For a list of hashing algorithms and encodings, type `$ --list'.\n\
");
if (gch)
fprintf(fp, "The default message digest algorithm is %s.\n", gch->name);
break;
case 'l': {
unsigned j;
+ printf("Algorithms: ");
for (j = 0; ghashtab[j]; j++) {
- if (j)
- fputc(' ', stdout);
+ if (j) fputc(' ', stdout);
printf("%s", ghashtab[j]->name);
}
fputc('\n', stdout);
+ printf("Encodings: ");
+ for (j = 0; enctab[j].name; j++) {
+ if (j) fputc(' ', stdout);
+ printf("%s", enctab[j].name);
+ }
+ fputc('\n', stdout);
exit(0);
} break;
case 'E':
/* --- Generate output --- */
- if (!(f & f_check)) {
- if (f & f_oddhash) printf("#hash %s\n", gch->name);
- if (f & f_oddenc) printf("#encoding %s\n", e->name);
- if (f & f_escape) fputs("#escape\n", stdout);
- }
-
- if (argc) {
+ if (!argc)
+ rc = hashsum(0, f, gch, e);
+ else {
int i;
int rrc;
+
rc = 0;
+ if (!(f & f_check)) {
+ if (f & f_oddhash) printf("#hash %s\n", gch->name);
+ if (f & f_oddenc) printf("#encoding %s\n", e->name);
+ if (f & f_escape) fputs("#escape\n", stdout);
+ }
for (i = 0; i < argc; i++) {
if ((rrc = hashsum(argv[i], f, gch, e)) != 0)
rc = rrc;
}
- } else
- rc = hashsum(0, f, gch, e);
+ }
return (rc);
}