46 char hexbuf[RS_MAX_STRONG_SUM_LENGTH * 2 + 2];
48 rs_trace(
"got block: weak=" FMT_WEAKSUM
", strong=%s", job->
weak_sig,
61 if ((result = rs_suck_n4(job, &l)) !=
RS_DONE) {
67 job->
statefn = rs_loadsig_s_strong;
74 rs_strong_sum_t *strongsum;
78 (
void **)&strongsum)) !=
RS_DONE)
80 job->
statefn = rs_loadsig_s_weak;
89 if ((result = rs_suck_n4(job, &l)) !=
RS_DONE)
91 if (l < 0 || l > RS_MAX_STRONG_SUM_LENGTH) {
92 rs_error(
"strong sum length %d is implausible", l);
95 rs_trace(
"got strong sum length %d", l);
96 job->sig_strong_len = l;
99 rs_signature_init(job->
signature, job->sig_magic, job->sig_block_len,
102 job->
statefn = rs_loadsig_s_weak;
111 if ((result = rs_suck_n4(job, &l)) !=
RS_DONE)
114 rs_error(
"block length of %d is bogus", l);
117 rs_trace(
"got block length %d", l);
118 job->sig_block_len = l;
119 job->
stats.block_len = l;
120 job->
statefn = rs_loadsig_s_stronglen;
129 if ((result = rs_suck_n4(job, &l)) !=
RS_DONE)
131 rs_trace(
"got signature magic %#x", l);
133 job->
statefn = rs_loadsig_s_blocklen;
141 job = rs_job_new(
"loadsig", rs_loadsig_s_magic);
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.
LIBRSYNC_EXPORT void rs_hexify(char *to_buf, void const *from_buf, int from_len)
Convert from_len bytes at from_buf into a hex representation in to_buf, which must be twice as long p...
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.
#define rs_trace_enabled()
Call this before putting too much effort into generating trace messages.