103#define MAX_MISS_LEN (MAX_DELTA_CMD - 3)
134 if ((result = rs_getinput(job, block_len)) !=
RS_DONE)
153 if (job->stream->
eof_in) {
154 job->
statefn = rs_delta_s_flush;
176 if ((result = rs_getinput(job, block_len)) !=
RS_DONE)
188 rs_trace(
"block reduced to " FMT_SIZE
"",
214 job->
scan_len = rs_scoop_avail(job);
235 if (weaksum_count(&job->
weak_sum) == 0) {
238 if (*match_len > block_len) {
239 *match_len = block_len;
244 rs_trace(
"calculate weak sum from scratch length " FMT_SIZE
"",
248 *match_len = weaksum_count(&job->
weak_sum);
253 return *match_pos != -1;
264 if (job->basis_len && (job->
basis_pos + job->basis_len) == match_pos) {
265 job->basis_len += match_len;
271 job->basis_len = match_len;
305 if (job->basis_len) {
306 rs_trace(
"matched " FMT_LONG
" bytes at " FMT_LONG
"!", job->basis_len,
313 rs_trace(
"got " FMT_SIZE
" bytes of literal data", job->
scan_pos);
357 assert(job->write_len > 0);
369 size_t avail = rs_scoop_avail(job);
372 rs_trace(
"emit slack delta for " FMT_SIZE
" available bytes", avail);
390 rs_trace(
"no signature provided for delta, using slack deltas");
402 if (sig && sig->
count > 0) {
Abstract wrappers around different weaksum and strongsum implementations.
static int rs_findmatch(rs_job_t *job, rs_long_t *match_pos, size_t *match_len)
find a match at scan_pos, returning the match_pos and match_len.
static rs_result rs_processmiss(rs_job_t *job)
Process miss data in the scoop.
static rs_result rs_processmatch(rs_job_t *job)
Process matching data in the scoop.
rs_job_t * rs_delta_begin(rs_signature_t *sig)
Prepare to compute a streaming delta.
static rs_result rs_delta_s_scan(rs_job_t *job)
Get a block of data if possible, and see if it matches.
static rs_result rs_delta_s_slack(rs_job_t *job)
State function that does a slack delta containing only literal data to recreate the input.
static rs_result rs_appendmiss(rs_job_t *job, size_t miss_len)
Append a miss of length miss_len to the delta, extending a previous miss if possible,...
static rs_result rs_appendflush(rs_job_t *job)
Flush any accumulating hit or miss, appending it to the delta.
static rs_result rs_delta_s_header(rs_job_t *job)
State function for writing out the header of the encoding job.
static rs_result rs_appendmatch(rs_job_t *job, rs_long_t match_pos, size_t match_len)
Append a match at match_pos of length match_len to the delta, extending a previous match if possible,...
#define MAX_MISS_LEN
Max length of a miss is 64K including 3 command bytes.
encoding output routines.
void rs_emit_delta_header(rs_job_t *)
Write the magic for the start of a delta.
void rs_emit_copy_cmd(rs_job_t *job, rs_long_t where, rs_long_t len)
Write a COPY command for given offset and length.
void rs_emit_end_cmd(rs_job_t *)
Write an END command.
void rs_emit_literal_cmd(rs_job_t *, int len)
Write a LITERAL command.
Generic state-machine interface.
#define rs_job_check(job)
Assert that a job is valid.
#define MAX_DELTA_CMD
Max length of a singled delta command is including command bytes.
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_BLOCKED
Blocked waiting for more data.
rs_result rs_scoop_readahead(rs_job_t *job, size_t len, void **ptr)
Read from scoop without advancing.
void rs_scoop_advance(rs_job_t *job, size_t len)
Advance the input cursor forward len bytes.
Manage librsync streams of IO.
rs_result rs_tube_catchup(rs_job_t *job)
Put whatever will fit from the tube into the output of the stream.
static bool rs_scoop_eof(rs_job_t *job)
Test if the scoop has reached eof.
void rs_tube_copy(rs_job_t *job, size_t len)
Queue up a request to copy through len bytes from the input to the output of the stream.
int eof_in
True if there is no more data after this.
The contents of this structure are private.
rs_long_t basis_pos
Copy from the basis position.
rs_byte_t * scan_buf
The delta scan buffer, where scan_buf[scan_pos..scan_len] is the data yet to be scanned.
size_t copy_len
If copy_len is >0, then that much data should be copied through from the input.
size_t scan_pos
The delta scan position.
size_t scan_len
The delta scan buffer length.
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.
weaksum_t weak_sum
The rollsum weak signature accumulator used by delta.c.
Signature of a whole file.
int count
Total number of blocks.
hashtable_t * hashtable
The hashtable for finding matches.
int block_len
The block length.
The rs_signature class implementation of a file signature.
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.
static weaksum_kind_t rs_signature_weaksum_kind(rs_signature_t const *sig)
Get the weaksum kind for a signature.
#define rs_signature_check(sig)
Assert that a signature is valid.