2 #include <crcsync/crcsync.h>
7 void validate(struct crc_context
*crcctx
)
9 char *getpos
= "XXXXXX0123XXXXXXXXXX456789ABXCDEFZZX"; // same data but starting with two mismatch characters
10 ssize_t remaining
= strlen(getpos
);
12 while (remaining
!= 0)
14 size_t ndigested
= crc_read_block(crcctx
, &rd_block_rslt
, getpos
, (remaining
> 3) ? 3: remaining
);
15 printf("read block rslt: %ld, ndigested: %zd\n", rd_block_rslt
, ndigested
);
17 remaining
-= ndigested
;
19 rd_block_rslt
= crc_read_flush(crcctx
);
20 printf("flush rslt: %ld\n", rd_block_rslt
);
21 crc_reset_running_crcs(crcctx
);
24 int main(int argc
, char *argv
[])
26 char *tstdata
= "0123456789ABCDEFZ";
28 uint64_t hashes
[nblocks
];
29 size_t datalen
= strlen(tstdata
);
30 size_t block_size
= datalen
/nblocks
;
31 crc_of_blocks(tstdata
, datalen
, block_size
, 64, true, hashes
); // set-up hashes
34 size_t tail_size
= block_size
+ datalen
%nblocks
;
35 printf("block_size: %zd, tail_size: %zd, nblocks: %zd\n", block_size
, tail_size
, nblocks
);
36 struct crc_context
*crcctx
= crc_context_new(block_size
, 64, hashes
, nblocks
, tail_size
);
37 printf("context initialized\n");
42 crc_context_free(crcctx
);