]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/md5.c
Fix reporting jobs from state file + misc
[bacula/bacula] / bacula / src / lib / md5.c
index 9ea7671f8ce91603e3691968048e3fe60407bd4d..f5a68abc1c781ec57004e5ba055f4c3aaa553ac5 100644 (file)
@@ -13,6 +13,8 @@
  * MD5Context structure, pass it to MD5Init, call MD5Update as
  * needed on buffers full of bytes, and then call MD5Final, which
  * will fill a supplied 16-byte array with the digest.
+ *
+ *   Version $Id$
  */
 
 /* Brutally hacked by John Walker back from ANSI C to K&R (no
 
 #include "bacula.h"
 
-#ifdef sgi
-#define HIGHFIRST
-#endif
-
-#ifdef sun
-#define HIGHFIRST
-#endif
-
-#ifndef HIGHFIRST
+#ifndef HAVE_BIGENDIAN
 #define byteReverse(buf, len)  /* Nothing */
 #else
 /*
@@ -255,3 +249,36 @@ void MD5Transform(uint32_t buf[4], uint32_t in[16])
     buf[2] += c;
     buf[3] += d;
 }
+
+#ifdef MD5_SUM
+/*
+ * Reads a single ASCII file and prints the HEX md5 sum.
+ */
+#include <stdio.h>
+int main(int argc, char *argv[]) 
+{
+   FILE *fd;
+   MD5Context ctx;
+   char buf[5000];
+   char signature[20];
+
+   if (argc < 1) {
+      printf("Must have filename\n");
+      exit(1);
+   }
+   fd = fopen(argv[1], "r");
+   if (!fd) {
+      printf("Could not open %s: ERR=%s\n", argv[1], strerror(errno));
+      exit(1);
+   }
+   MD5Init(&ctx);
+   while (fgets(buf, sizeof(buf), fd)) {
+      MD5Update(&ctx, (unsigned char *)buf, strlen(buf));
+   }
+   MD5Final((unsigned char *)signature, &ctx);
+   for (int i=0; i < 16; i++) {
+      printf("%02x", signature[i]& 0xFF);
+   }
+   printf("  %s\n", argv[1]);
+}
+#endif