*** mddriver.c Wed Aug 9 10:37:27 1995 --- mddriver-btron.c Sun May 9 11:49:09 2004 *************** *** 21,27 **** #endif #include ! #include #include #include "global.h" #if MD == 2 --- 21,27 ---- #endif #include ! // #include #include #include "global.h" #if MD == 2 *************** *** 34,49 **** #include "md5.h" #endif /* Length of test block, number of test blocks. */ ! #define TEST_BLOCK_LEN 1000 ! #define TEST_BLOCK_COUNT 1000 static void MDString PROTO_LIST ((char *)); static void MDTimeTrial PROTO_LIST ((void)); static void MDTestSuite PROTO_LIST ((void)); static void MDFile PROTO_LIST ((char *)); ! static void MDFilter PROTO_LIST ((void)); static void MDPrint PROTO_LIST ((unsigned char [16])); #if MD == 2 --- 34,56 ---- #include "md5.h" #endif + /* quick hack for BTRON(Cho-Kanji/Personal-Media) by SASANO Takayoshi. + */ + #include + #include + #include + #include + /* Length of test block, number of test blocks. */ ! #define TEST_BLOCK_LEN 100000 // 1000 ! #define TEST_BLOCK_COUNT 10000 // 1000 static void MDString PROTO_LIST ((char *)); static void MDTimeTrial PROTO_LIST ((void)); static void MDTestSuite PROTO_LIST ((void)); static void MDFile PROTO_LIST ((char *)); ! // static void MDFilter PROTO_LIST ((void)); static void MDPrint PROTO_LIST ((unsigned char [16])); #if MD == 2 *************** *** 74,98 **** filename - digests file (none) - digests standard input */ ! int main (argc, argv) ! int argc; ! char *argv[]; { int i; if (argc > 1) for (i = 1; i < argc; i++) ! if (argv[i][0] == '-' && argv[i][1] == 's') ! MDString (argv[i] + 2); ! else if (strcmp (argv[i], "-t") == 0) MDTimeTrial (); ! else if (strcmp (argv[i], "-x") == 0) MDTestSuite (); else MDFile (argv[i]); else ! MDFilter (); return (0); } --- 81,107 ---- filename - digests file (none) - digests standard input */ ! WERR main (argc, argv) ! W argc; ! TC *argv[]; { int i; + TC timetrial_option[] = {TK_MINS, TK_t, TK_NULL}; + TC testsuite_option[] = {TK_MINS, TK_x, TK_NULL}; if (argc > 1) for (i = 1; i < argc; i++) ! if (argv[i][0] == TK_MINS && argv[i][1] == TK_s) ! printf ("unsupported option (-s)\n"); // MDString (argv[i] + 2); ! else if (tc_strcmp (argv[i], timetrial_option) == 0) MDTimeTrial (); ! else if (tc_strcmp (argv[i], testsuite_option) == 0) MDTestSuite (); else MDFile (argv[i]); else ! printf ("unsupported option (standard input)\n"); //MDFilter (); return (0); } *************** *** 121,127 **** static void MDTimeTrial () { MD5_CTX context; ! time_t endTime, startTime; unsigned char block[TEST_BLOCK_LEN], digest[16]; unsigned int i; --- 130,136 ---- static void MDTimeTrial () { MD5_CTX context; ! STIME endTime, startTime; unsigned char block[TEST_BLOCK_LEN], digest[16]; unsigned int i; *************** *** 135,141 **** block[i] = (unsigned char)(i & 0xff); /* Start timer */ ! time (&startTime); /* Digest blocks */ MDInit (&context); --- 144,150 ---- block[i] = (unsigned char)(i & 0xff); /* Start timer */ ! get_tim (&startTime, NULL); /* Digest blocks */ MDInit (&context); *************** *** 144,150 **** MDFinal (digest, &context); /* Stop timer */ ! time (&endTime); printf (" done\n"); printf ("Digest = "); --- 153,159 ---- MDFinal (digest, &context); /* Stop timer */ ! get_tim (&endTime, NULL); printf (" done\n"); printf ("Digest = "); *************** *** 176,205 **** /* Digests a file and prints the result. */ static void MDFile (filename) ! char *filename; { ! FILE *file; MD5_CTX context; ! int len; unsigned char buffer[1024], digest[16]; ! if ((file = fopen (filename, "rb")) == NULL) ! printf ("%s can't be opened\n", filename); else { MDInit (&context); ! while (len = fread (buffer, 1, 1024, file)) MDUpdate (&context, buffer, len); MDFinal (digest, &context); ! fclose (file); ! printf ("MD%d (%s) = ", MD, filename); MDPrint (digest); printf ("\n"); } } ! /* Digests the standard input and prints the result. */ static void MDFilter () --- 185,219 ---- /* Digests a file and prints the result. */ static void MDFile (filename) ! TC *filename; { ! LINK link; MD5_CTX context; ! W len, fd, pos; unsigned char buffer[1024], digest[16]; ! if (get_lnk (filename, &link, F_NORM) < ER_OK ! || (fd = opn_fil (&link, F_READ, NULL)) < ER_OK) ! printf ("%S can't be opened\n", filename); else { MDInit (&context); ! for (pos = 0; ; pos += 1024) { ! if (rea_rec (fd, pos, buffer, 1024, &len, NULL) < ER_OK) break; ! if (len > sizeof(buffer)) len = 1024; MDUpdate (&context, buffer, len); + if (len < 1024) break; + } MDFinal (digest, &context); ! cls_fil (fd); ! printf ("MD%d (%S) = ", MD, filename); MDPrint (digest); printf ("\n"); } } ! #if 0 /* Digests the standard input and prints the result. */ static void MDFilter () *************** *** 216,222 **** MDPrint (digest); printf ("\n"); } ! /* Prints a message digest in hexadecimal. */ static void MDPrint (digest) --- 230,236 ---- MDPrint (digest); printf ("\n"); } ! #endif /* Prints a message digest in hexadecimal. */ static void MDPrint (digest)