53# ifndef HASHTABLE_NSTATS
73 size_t block_len,
size_t strong_len,
81 rs_weak_sum_t weak_sum,
82 rs_strong_sum_t *strong_sum);
86 void const *buf,
size_t len);
92# define rs_sig_args_check(magic, block_len, strong_len) do {\
93 assert(((magic) & ~0xff) == (RS_MD4_SIG_MAGIC & ~0xff));\
94 assert(((magic) & 0xf0) == 0x30 || ((magic) & 0xf0) == 0x40);\
95 assert((((magic) & 0x0f) == 0x06 &&\
96 (int)(strong_len) <= RS_MD4_SUM_LENGTH) ||\
97 (((magic) & 0x0f) == 0x07 &&\
98 (int)(strong_len) <= RS_BLAKE2_SUM_LENGTH));\
99 assert(0 < (block_len));\
100 assert(0 < (strong_len) && (strong_len) <= RS_MAX_STRONG_SUM_LENGTH);\
107# define rs_signature_check(sig) do {\
108 rs_sig_args_check((sig)->magic, (sig)->block_len, (sig)->strong_sum_len);\
109 assert(0 <= (sig)->count && (sig)->count <= (sig)->size);\
110 assert(!(sig)->hashtable || (sig)->hashtable->count <= (sig)->count);\
117 return (sig->
magic & 0xf0) == 0x30 ? RS_ROLLSUM : RS_RABINKARP;
124 return (sig->
magic & 0x0f) == 0x06 ? RS_MD4 : RS_BLAKE2;
129 *sig,
void const *buf,
137 void const *buf,
size_t len,
138 rs_strong_sum_t *sum)
Abstract wrappers around different weaksum and strongsum implementations.
rs_weak_sum_t rs_calc_weak_sum(weaksum_kind_t kind, void const *buf, size_t len)
Calculate a weaksum.
strongsum_kind_t
Strongsum implementations.
weaksum_kind_t
Weaksum implementations.
void rs_calc_strong_sum(strongsum_kind_t kind, void const *buf, size_t len, rs_strong_sum_t *sum)
Calculate a strongsum.
A generic open addressing hashtable.
Public header for librsync.
rs_result
Return codes from nonblocking rsync operations.
rs_magic_number
A uint32 magic number, emitted in bigendian/network order at the start of librsync files.
Signature of a single block.
rs_strong_sum_t strong_sum
Block's strong checksum.
rs_weak_sum_t weak_sum
Block's weak checksum.
Signature of a whole file.
int count
Total number of blocks.
int size
Total number of blocks allocated.
int magic
The signature magic value.
hashtable_t * hashtable
The hashtable for finding matches.
int block_len
The block length.
void * block_sigs
The packed block_sigs for all blocks.
long calc_strong_count
The count of strongsum calcs done.
int strong_sum_len
The block strong sum length.
static rs_weak_sum_t rs_signature_calc_weak_sum(rs_signature_t const *sig, void const *buf, size_t len)
Calculate the weak sum of a buffer.
static void rs_signature_calc_strong_sum(rs_signature_t const *sig, void const *buf, size_t len, rs_strong_sum_t *sum)
Calculate the strong sum of a buffer.
rs_result rs_signature_init(rs_signature_t *sig, rs_magic_number magic, size_t block_len, size_t strong_len, rs_long_t sig_fsize)
Initialize an rs_signature instance.
rs_long_t rs_signature_find_match(rs_signature_t *sig, rs_weak_sum_t weak_sum, void const *buf, size_t len)
Find a matching block offset in a signature.
rs_block_sig_t * rs_signature_add_block(rs_signature_t *sig, rs_weak_sum_t weak_sum, rs_strong_sum_t *strong_sum)
Add a block to an rs_signature instance.
static strongsum_kind_t rs_signature_strongsum_kind(rs_signature_t const *sig)
Get the strongsum kind for a signature.
void rs_signature_done(rs_signature_t *sig)
Destroy an rs_signature instance.
static weaksum_kind_t rs_signature_weaksum_kind(rs_signature_t const *sig)
Get the weaksum kind for a signature.
struct rs_block_sig rs_block_sig_t
Signature of a single block.