Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(797)

Unified Diff: md5/md5cmp.c

Issue 1934113002: Update libjpeg_turbo to 1.4.90 from https://github.com/libjpeg-turbo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: md5/md5cmp.c
diff --git a/tjutil.c b/md5/md5cmp.c
similarity index 68%
copy from tjutil.c
copy to md5/md5cmp.c
index 6618d158cf72965886fca304b337a068aa339e83..dfd60bd396d3a7cd1170ae5330949c082afa2adf 100644
--- a/tjutil.c
+++ b/md5/md5cmp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2011 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2013, 2016 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -26,41 +26,35 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef _WIN32
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include "./md5.h"
+#include "../tjutil.h"
-#include <windows.h>
-
-static double getfreq(void)
+int main(int argc, char *argv[])
{
- LARGE_INTEGER freq;
- if(!QueryPerformanceFrequency(&freq)) return 0.0;
- return (double)freq.QuadPart;
-}
-
-static double f=-1.0;
+ char *md5sum = NULL, buf[65];
-double gettime(void)
-{
- LARGE_INTEGER t;
- if(f<0.0) f=getfreq();
- if(f==0.0) return (double)GetTickCount()/1000.;
- else
- {
- QueryPerformanceCounter(&t);
- return (double)t.QuadPart/f;
+ if (argc < 3) {
+ fprintf(stderr, "USAGE: %s <correct MD5 sum> <file>\n", argv[0]);
+ return -1;
}
-}
-#else
+ if (strlen(argv[1]) != 32)
+ fprintf(stderr, "WARNING: MD5 hash size is wrong.\n");
-#include <stdlib.h>
-#include <sys/time.h>
+ md5sum = MD5File(argv[2], buf);
+ if (!md5sum) {
+ perror("Could not obtain MD5 sum");
+ return -1;
+ }
-double gettime(void)
-{
- struct timeval tv;
- if(gettimeofday(&tv, NULL)<0) return 0.0;
- else return (double)tv.tv_sec+((double)tv.tv_usec/1000000.);
+ if (!strcasecmp(md5sum, argv[1])) {
+ fprintf(stderr, "%s: OK\n", argv[2]);
+ return 0;
+ } else {
+ fprintf(stderr, "%s: FAILED. Checksum is %s\n", argv[2], md5sum);
+ return -1;
+ }
}
-
-#endif

Powered by Google App Engine
This is Rietveld 408576698