MIDAS
Loading...
Searching...
No Matches
crc32c_sum.cxx File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "crc32c.h"
Include dependency graph for crc32c_sum.cxx:

Go to the source code of this file.

Macros

#define SIZE   (262144*3)
 
#define CHUNK   SIZE
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

◆ CHUNK

#define CHUNK   SIZE

Definition at line 11 of file crc32c_sum.cxx.

◆ SIZE

#define SIZE   (262144*3)

Definition at line 10 of file crc32c_sum.cxx.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 13 of file crc32c_sum.cxx.

14{
15 char *buf;
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}
uint32_t crc32c(uint32_t crc, const void *buf, size_t len)
Definition crc32c.cxx:391
uint32_t crc32c_sw(uint32_t crci, const void *buf, size_t len)
Definition crc32c.cxx:99
#define CHUNK
#define SIZE
DWORD n[4]
Definition mana.cxx:247
#define read(n, a, f)
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Here is the call graph for this function: