MIDAS
Loading...
Searching...
No Matches
crc32c_sum.cxx
Go to the documentation of this file.
1
//
2
// compute CRC32C checksum
3
//
4
5
#include <stdio.h>
6
#include <stdlib.h>
7
#include <unistd.h>
8
#include "
crc32c.h
"
9
10
#define SIZE (262144*3)
11
#define CHUNK SIZE
12
13
int
main
(
int
argc
,
char
**
argv
)
14
{
15
char
*buf;
16
ssize_t
got
;
17
size_t
off
,
n
;
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
;
31
if
(
n
>
CHUNK
)
32
n
=
CHUNK
;
33
crc =
argc
> 1 ?
crc32c_sw
(crc, buf +
off
,
n
) :
34
crc32c
(crc, buf +
off
,
n
);
35
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
}
46
47
/* emacs
48
* Local Variables:
49
* tab-width: 8
50
* c-basic-offset: 3
51
* indent-tabs-mode: nil
52
* End:
53
*/
crc32c
uint32_t crc32c(uint32_t crc, const void *buf, size_t len)
Definition
crc32c.cxx:391
crc32c_sw
uint32_t crc32c_sw(uint32_t crci, const void *buf, size_t len)
Definition
crc32c.cxx:99
crc32c.h
CHUNK
#define CHUNK
Definition
crc32c_sum.cxx:11
SIZE
#define SIZE
Definition
crc32c_sum.cxx:10
main
int main()
Definition
hwtest.cxx:23
n
DWORD n[4]
Definition
mana.cxx:247
read
#define read(n, a, f)
Definition
midas_macro.h:242
h1_book
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition
rmidas.h:24
progs
crc32c_sum.cxx
Generated on Sat May 3 2025 05:01:05 for MIDAS by
1.9.8