Lines 45-50
__FBSDID("$FreeBSD$");
Link Here
|
45 |
#define TEST_BLOCK_COUNT 100000 |
45 |
#define TEST_BLOCK_COUNT 100000 |
46 |
#define MDTESTCOUNT 8 |
46 |
#define MDTESTCOUNT 8 |
47 |
|
47 |
|
|
|
48 |
static int pflag; |
48 |
static int qflag; |
49 |
static int qflag; |
49 |
static int rflag; |
50 |
static int rflag; |
50 |
static int sflag; |
51 |
static int sflag; |
Lines 176-188
main(int argc, char *argv[])
Link Here
|
176 |
failed = 0; |
177 |
failed = 0; |
177 |
checkAgainst = NULL; |
178 |
checkAgainst = NULL; |
178 |
checksFailed = 0; |
179 |
checksFailed = 0; |
179 |
while ((ch = getopt(argc, argv, "c:pqrs:tx")) != -1) |
180 |
pflag = 0; |
|
|
181 |
while ((ch = getopt(argc, argv, "c:Ppqrs:tx")) != -1) |
180 |
switch (ch) { |
182 |
switch (ch) { |
181 |
case 'c': |
183 |
case 'c': |
182 |
checkAgainst = optarg; |
184 |
checkAgainst = optarg; |
183 |
break; |
185 |
break; |
|
|
186 |
case 'P': |
187 |
pflag = STDERR_FILENO; |
188 |
break; |
184 |
case 'p': |
189 |
case 'p': |
185 |
MDFilter(&Algorithm[digest], 1); |
190 |
pflag = STDOUT_FILENO; |
186 |
break; |
191 |
break; |
187 |
case 'q': |
192 |
case 'q': |
188 |
qflag = 1; |
193 |
qflag = 1; |
Lines 229-236
main(int argc, char *argv[])
Link Here
|
229 |
printf("\n"); |
234 |
printf("\n"); |
230 |
} |
235 |
} |
231 |
} while (*++argv); |
236 |
} while (*++argv); |
232 |
} else if (!sflag && (optind == 1 || qflag || rflag)) |
237 |
} else if (!sflag && (optind == 1 || qflag || rflag || pflag || checkAgainst)) |
233 |
MDFilter(&Algorithm[digest], 0); |
238 |
MDFilter(&Algorithm[digest], pflag); |
234 |
|
239 |
|
235 |
if (failed != 0) |
240 |
if (failed != 0) |
236 |
return (1); |
241 |
return (1); |
Lines 449-455
MDTestSuite(const Algorithm_t *alg)
Link Here
|
449 |
} |
454 |
} |
450 |
|
455 |
|
451 |
/* |
456 |
/* |
452 |
* Digests the standard input and prints the result. |
457 |
* Digests the standard input and prints the result to stdoud or stderr. In |
|
|
458 |
* any case digested input is either passed to stdout (tee > 0), or not passed |
459 |
* at all (tee == 0) |
453 |
*/ |
460 |
*/ |
454 |
static void |
461 |
static void |
455 |
MDFilter(const Algorithm_t *alg, int tee) |
462 |
MDFilter(const Algorithm_t *alg, int tee) |
Lines 458-463
MDFilter(const Algorithm_t *alg, int tee)
Link Here
|
458 |
unsigned int len; |
465 |
unsigned int len; |
459 |
unsigned char buffer[BUFSIZ]; |
466 |
unsigned char buffer[BUFSIZ]; |
460 |
char buf[HEX_DIGEST_LENGTH]; |
467 |
char buf[HEX_DIGEST_LENGTH]; |
|
|
468 |
char *p; |
461 |
|
469 |
|
462 |
alg->Init(&context); |
470 |
alg->Init(&context); |
463 |
while ((len = fread(buffer, 1, BUFSIZ, stdin))) { |
471 |
while ((len = fread(buffer, 1, BUFSIZ, stdin))) { |
Lines 465-471
MDFilter(const Algorithm_t *alg, int tee)
Link Here
|
465 |
err(1, "stdout"); |
473 |
err(1, "stdout"); |
466 |
alg->Update(&context, buffer, len); |
474 |
alg->Update(&context, buffer, len); |
467 |
} |
475 |
} |
468 |
printf("%s\n", alg->End(&context, buf)); |
476 |
p = alg->End(&context, buf); |
|
|
477 |
if (checkAgainst && strcmp(checkAgainst,p)) |
478 |
{ |
479 |
checksFailed++; |
480 |
if (!qflag) |
481 |
printf(" [ Failed ]"); |
482 |
} |
483 |
fprintf(tee == STDERR_FILENO ? stderr : stdout, "%s\n", p); |
469 |
} |
484 |
} |
470 |
|
485 |
|
471 |
static void |
486 |
static void |