52 job->sig_strong_len, 0)) !=
RS_DONE)
54 rs_squirt_n4(job, sig->
magic);
57 rs_trace(
"sent header (magic %#x, block len = %d, strong sum len = %d)",
70 rs_weak_sum_t weak_sum;
71 rs_strong_sum_t strong_sum;
75 rs_squirt_n4(job, weak_sum);
78 char strong_sum_hex[RS_MAX_STRONG_SUM_LENGTH * 2 + 1];
80 rs_trace(
"sent block: weak=" FMT_WEAKSUM
", strong=%s", weak_sum,
102 }
else if (result !=
RS_DONE) {
103 rs_trace(
"generate stopped: %s",
rs_strerror(result));
106 rs_trace(
"got " FMT_SIZE
" byte block", len);
107 return rs_sig_do_block(job, block, len);
118 job->sig_magic = sig_magic;
119 job->sig_block_len = (int)block_len;
120 job->sig_strong_len = (int)strong_len;
Generic state-machine interface.
Public header for librsync.
LIBRSYNC_EXPORT char const * rs_strerror(rs_result r)
Return an English description of a rs_result value.
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_INPUT_ENDED
Unexpected end of input file, perhaps due to a truncated file or dropped network connection.
rs_magic_number
A uint32 magic number, emitted in bigendian/network order at the start of librsync files.
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_sig_begin(size_t block_len, size_t strong_len, rs_magic_number sig_magic)
Start generating a signature.
static rs_result rs_sig_s_generate(rs_job_t *)
State of reading a block and trying to generate its sum.
static rs_result rs_sig_s_header(rs_job_t *)
State of trying to send the signature header.
Network-byte-order output to the tube.
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.
rs_result rs_scoop_read_rest(rs_job_t *job, size_t *len, void **ptr)
Read whatever data remains in the input stream.
Manage librsync streams of IO.
void rs_tube_write(rs_job_t *job, void const *buf, size_t len)
Push some data into the tube for storage.
The contents of this structure are private.
int job_owns_sig
Flag indicating signature should be destroyed with the job.
rs_result(* statefn)(rs_job_t *)
Callback for each processing step.
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 magic
The signature magic value.
int block_len
The block length.
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.
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.
#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.