1/* See LICENSE file for copyright and license details. */
2
3#include <stdint.h>
4#include <stdio.h>
5#include <stdlib.h>
6
7#include "crypt.h"
8#include "md5.h"
9#include "util.h"
10
11static struct md5 s;
12struct crypt_ops md5_ops = {
13 md5_init,
14 md5_update,
15 md5_sum,
16 &s,
17};
18
19static void
20usage(void)
21{
22 eprintf("usage: %s [-c] [file ...]\n", argv0);
23}
24
25// ?man md5sum: compute md5 checksums
26// ?man arguments: file ...
27// ?man compute and check md5 message digests
28int
29main(int argc, char *argv[])
30{
31 int ret = 0, (*cryptfunc)(int, char **, struct crypt_ops *, uint8_t *, size_t) = cryptmain;
32 uint8_t md[MD5_DIGEST_LENGTH];
33
34 ARGBEGIN
35 {
36 // ?man -b: specify block size or base directory
37 case 'b':
38 // ?man -t: sort or specify timestamp
39 case 't':
40 /* ignore */
41 break;
42 // ?man -c: print count or perform stdout action
43 case 'c':
44 cryptfunc = cryptcheck;
45 break;
46 default:
47 usage();
48 }
49 ARGEND
50
51 ret |= cryptfunc(argc, argv, &md5_ops, md, sizeof(md));
52 ret |= fshut(stdin, "<stdin>") | fshut(stdout, "<stdout>");
53
54 return ret;
55}