43 char hexbuf[RS_MAX_STRONG_SUM_LENGTH * 2 + 2];
45 rs_trace(
"got block: weak=" FMT_WEAKSUM
", strong=%s", job->
weak_sig,
58 if ((result = rs_suck_n4(job, &l)) !=
RS_DONE) {
64 job->
statefn = rs_loadsig_s_strong;
71 rs_strong_sum_t *strongsum;
75 (
void **)&strongsum)) !=
RS_DONE)
77 job->
statefn = rs_loadsig_s_weak;
86 if ((result = rs_suck_n4(job, &l)) !=
RS_DONE)
88 if (l < 0 || l > RS_MAX_STRONG_SUM_LENGTH) {
89 rs_error(
"strong sum length %d is implausible", l);
92 rs_trace(
"got strong sum length %d", l);
93 job->sig_strong_len = l;
96 rs_signature_init(job->
signature, job->sig_magic, job->sig_block_len,
99 job->
statefn = rs_loadsig_s_weak;
108 if ((result = rs_suck_n4(job, &l)) !=
RS_DONE)
111 rs_error(
"block length of %d is bogus", l);
114 rs_trace(
"got block length %d", l);
115 job->sig_block_len = l;
116 job->
stats.block_len = l;
117 job->
statefn = rs_loadsig_s_stronglen;
126 if ((result = rs_suck_n4(job, &l)) !=
RS_DONE)
128 rs_trace(
"got signature magic %#x", l);
130 job->
statefn = rs_loadsig_s_blocklen;
138 job = rs_job_new(
"loadsig", rs_loadsig_s_magic);
Generic state-machine interface.
Public header for librsync.
rs_result
Return codes from nonblocking rsync operations.
@ RS_RUNNING
The job is still running, and not yet finished or blocked.
@ RS_DONE
Completed successfully.
@ RS_CORRUPT
Unbelievable value in stream.
@ RS_INPUT_ENDED
Unexpected end of input file, perhaps due to a truncated file or dropped network connection.
Network-byte-order output to the tube.
rs_job_t * rs_loadsig_begin(rs_signature_t **signature)
Read a signature from a file into an rs_signature structure in memory.
static rs_result rs_loadsig_add_sum(rs_job_t *job, rs_strong_sum_t *strong)
Add a just-read-in checksum pair to the signature block.
rs_result rs_scoop_read(rs_job_t *job, size_t len, void **ptr)
Read LEN bytes if possible, and remove them from the input scoop.
Manage librsync streams of IO.
The contents of this structure are private.
rs_weak_sum_t weak_sig
The weak signature digest used by readsums.c.
rs_result(* statefn)(rs_job_t *)
Callback for each processing step.
rs_long_t sig_fsize
The size of the signature file if available.
rs_signature_t * signature
Pointer to the signature that's being used by the operation.
rs_stats_t stats
Encoding statistics.
Signature of a whole file.
int strong_sum_len
The block strong sum length.
rs_long_t sig_blocks
Number of blocks described by the signature.
The rs_signature class implementation of a file signature.
#define rs_trace_enabled()
Call this before putting too much effort into generating trace messages.
Misc utility functions used by librsync.
#define rs_alloc_struct(type)
Allocate and zero-fill an instance of TYPE.