-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcli.c
40 lines (29 loc) · 735 Bytes
/
cli.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* This file is part of quickxorhash and distributed under the terms of the
* MIT license. See COPYING.
*/
#include <config.h>
#include <stdio.h>
#include "quickxorhash.h"
int
main(int argc, char **argv) {
FILE * fp;
struct qxhash *q;
uint8_t buf[ 4096 ];
size_t len;
if (argc != 2) {
fprintf(stderr, "Usage: quickxorhash <filename>\n");
return 1;
}
fp = fopen(argv[ 1 ], "rb");
if (!fp) {
fprintf(stderr, "Failed to open %s\n", argv[ 1 ]);
return 1;
}
q = qxh_new();
while ((len = fread(buf, 1, 4096, fp)) > 0) {
qxh_update(q, buf, len);
}
printf("%s\n", qxh_finalize(q));
qxh_free(q);
return 0;
}