#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "crc32c.h"
Go to the source code of this file.
|
| int | main (int argc, char **argv) |
| |
◆ CHUNK
◆ SIZE
◆ main()
| int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 13 of file crc32c_sum.cxx.
14{
15 char *buf;
16 ssize_t got;
18 uint32_t crc;
19
20 (void)argv;
21 crc = 0;
22 buf = (
char*)malloc(
SIZE);
23 if (buf == NULL) {
24 fputs("out of memory", stderr);
25 return 1;
26 }
27 while ((got =
read(0, buf,
SIZE)) > 0) {
28 off = 0;
29 do {
30 n = (size_t)got - off;
33 crc = argc > 1 ?
crc32c_sw(crc, buf + off,
n) :
36 } while (off < (size_t)got);
37 }
38 free(buf);
39 if (got == -1) {
40 fputs("read error\n", stderr);
41 return 1;
42 }
43 printf("%08x\n", crc);
44 return 0;
45}
uint32_t crc32c(uint32_t crc, const void *buf, size_t len)
uint32_t crc32c_sw(uint32_t crci, const void *buf, size_t len)