47 lines
872 B
C
47 lines
872 B
C
//
|
|
// Created by haraldwolff on 08.08.22.
|
|
//
|
|
|
|
#include <blksync.h>
|
|
#include <hash.h>
|
|
|
|
|
|
int bs_test(bsync_engine_t *engine){
|
|
if (!(engine->blocksize))
|
|
engine->blocksize = defaultBlocksize;
|
|
|
|
char *block = malloc(engine->blocksize);
|
|
if (!block)
|
|
{
|
|
fprintf(stderr, "no memory available for block");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
long p = 0;
|
|
long r = engine->filesize;
|
|
|
|
if (engine->ds_flags & DS_VERBOSE){
|
|
fprintf( stderr, "about to start...\n");
|
|
dump_engine(engine);
|
|
}
|
|
|
|
while (r > 0){
|
|
int32_t size = r > engine->blocksize ? engine->blocksize : r;
|
|
uint64_t blockhash;
|
|
|
|
if (read_block(engine, p, block, size) != size)
|
|
exit(EXIT_FAILURE);
|
|
|
|
blockhash = dhash( block, size);
|
|
|
|
int percent = 100 * p / engine->filesize;
|
|
|
|
fprintf(stdout, "offset: 0x%lx (%d%%) [0x%lx]\n", p, percent, blockhash);
|
|
fflush(stdout);
|
|
|
|
p += size;
|
|
r -= size;
|
|
}
|
|
|
|
return 0;
|
|
} |