44 char hexbuf[RS_MAX_STRONG_SUM_LENGTH * 2 + 2];
46 rs_trace(
"got block: weak=" FMT_WEAKSUM
", strong=%s", job->
weak_sig,
59 if ((result = rs_suck_n4(job, &l)) !=
RS_DONE) {
65 job->
statefn = rs_loadsig_s_strong;
72 rs_strong_sum_t *strongsum;
76 (
void **)&strongsum)) !=
RS_DONE)
78 job->
statefn = rs_loadsig_s_weak;
87 if ((result = rs_suck_n4(job, &l)) !=
RS_DONE)
89 if (l < 0 || l > RS_MAX_STRONG_SUM_LENGTH) {
90 rs_error(
"strong sum length %d is implausible", l);
93 rs_trace(
"got strong sum length %d", l);
94 job->sig_strong_len = l;
100 job->
statefn = rs_loadsig_s_weak;
109 if ((result = rs_suck_n4(job, &l)) !=
RS_DONE)
112 rs_error(
"block length of %d is bogus", l);
115 rs_trace(
"got block length %d", l);
116 job->sig_block_len = l;
117 job->
stats.block_len = l;
118 job->
statefn = rs_loadsig_s_stronglen;
127 if ((result = rs_suck_n4(job, &l)) !=
RS_DONE)
129 rs_trace(
"got signature magic %#x", l);
131 job->
statefn = rs_loadsig_s_blocklen;
139 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.
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...
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.
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_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.
#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.