]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/md5.c
Use the command line utility dropdb instead of the psql command
[bacula/bacula] / bacula / src / lib / md5.c
index 9b4b7b805a8ca05f4f56d6a42da9d350ee07b48b..f5a68abc1c781ec57004e5ba055f4c3aaa553ac5 100644 (file)
 
 #include "bacula.h"
 
-#ifdef sgi
-#define HIGHFIRST
-#endif
-
-#ifdef sun
-#define HIGHFIRST
-#endif
-
-#ifndef HIGHFIRST
+#ifndef HAVE_BIGENDIAN
 #define byteReverse(buf, len)  /* Nothing */
 #else
 /*
@@ -257,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