/* -*-c-*-
*
- * $Id: hashsum.c,v 1.8 2001/04/19 18:26:33 mdw Exp $
+ * $Id: hashsum.c,v 1.9 2004/04/04 19:42:59 mdw Exp $
*
* Hash files using some secure hash function
*
/*----- Revision history --------------------------------------------------*
*
* $Log: hashsum.c,v $
+ * Revision 1.9 2004/04/04 19:42:59 mdw
+ * Add set -e.
+ *
* Revision 1.8 2001/04/19 18:26:33 mdw
* Add CRC as another hash function.
*
#include "ghash.h"
-#include "crc32.h"
-#include "md2.h"
-#include "md4.h"
-#include "md5.h"
-#include "rmd128.h"
-#include "rmd160.h"
-#include "rmd256.h"
-#include "rmd320.h"
-#include "sha.h"
-#include "sha256.h"
-#include "sha384.h"
-#include "sha512.h"
-#include "tiger.h"
-
/*----- Static variables --------------------------------------------------*/
-static const gchash *hashtab[] = {
- &md5, &md4, &md2,
- &sha, &sha256, &sha384, &sha512,
- &rmd128, &rmd160, &rmd256, &rmd320,
- &tiger, &gcrc32,
- 0
-};
-
#define f_binary 1u
#define f_bogus 2u
#define f_verbose 4u
static const gchash *gethash(const char *name)
{
- const gchash **g, *gg = 0;
+ const gchash *const *g, *gg = 0;
size_t sz = strlen(name);
- for (g = hashtab; *g; g++) {
+ for (g = ghashtab; *g; g++) {
if (strncmp(name, (*g)->name, sz) == 0) {
if ((*g)->name[sz] == 0) {
gg = *g;
gch = gethash(q);
}
if (!gch)
- gch = hashtab[0];
+ gch = gethash("md5");
xfree(q);
}
break;
case 'l': {
unsigned j;
- for (j = 0; hashtab[j]; j++) {
+ for (j = 0; ghashtab[j]; j++) {
if (j)
fputc(' ', stdout);
- printf("%s", hashtab[j]->name);
+ printf("%s", ghashtab[j]->name);
}
fputc('\n', stdout);
exit(0);