2005-10-08 Simon Josefsson <jas@extundo.com>
[pspp] / lib / gc-gnulib.c
index 99d6dc2bce4ba7dd677fdb56a12f7617f89134f3..abb1bb466a3914567d8ba676ceea8a2142ae39e2 100644 (file)
 # include <config.h>
 #endif
 
-#include <stdlib.h>
-
 /* Get prototype. */
 #include <gc.h>
 
+#include <stdlib.h>
+#include <string.h>
+
 /* For randomize. */
 #include <unistd.h>
 #include <sys/types.h>
@@ -36,7 +37,8 @@
 #include <fcntl.h>
 #include <errno.h>
 
-#include <string.h>
+#include "md5.h"
+#include "hmac.h"
 
 int
 gc_init (void)
@@ -133,7 +135,23 @@ gc_set_allocators (gc_malloc_t func_malloc,
   return;
 }
 
-#include "md5.h"
+/* Hashes. */
+
+int
+gc_hash_buffer (int hash, const void *in, size_t inlen, char *resbuf)
+{
+  switch (hash)
+    {
+    case GC_MD5:
+      md5_buffer (in, inlen, resbuf);
+      break;
+
+    default:
+      return GC_INVALID_HASH;
+    }
+
+  return GC_OK;
+}
 
 int
 gc_md5 (const void *in, size_t inlen, void *resbuf)
@@ -142,8 +160,6 @@ gc_md5 (const void *in, size_t inlen, void *resbuf)
   return 0;
 }
 
-#include "hmac.h"
-
 int
 gc_hmac_md5 (const void *key, size_t keylen,
             const void *in, size_t inlen, char *resbuf)