105 static inline void rs_getinput(
rs_job_t *job);
133 && ((job->scoop_pos + block_len) < job->scoop_avail)) {
141 weaksum_rotate(&job->
weak_sum, job->scoop_next[job->scoop_pos],
142 job->scoop_next[job->scoop_pos + block_len]);
149 if (job->stream->
eof_in) {
150 job->
statefn = rs_delta_s_flush;
172 while ((result ==
RS_DONE) && (job->scoop_pos < job->scoop_avail)) {
180 weaksum_rollout(&job->
weak_sum, job->scoop_next[job->scoop_pos]);
181 rs_trace(
"block reduced to " FMT_SIZE
"",
203 static inline void rs_getinput(
rs_job_t *job)
208 if (job->scoop_avail < len) {
228 if (weaksum_count(&job->
weak_sum) == 0) {
230 *match_len = job->scoop_avail - job->scoop_pos;
231 if (*match_len > block_len) {
232 *match_len = block_len;
235 weaksum_update(&job->
weak_sum, job->scoop_next + job->scoop_pos,
237 rs_trace(
"calculate weak sum from scratch length " FMT_SIZE
"",
241 *match_len = weaksum_count(&job->
weak_sum);
245 job->scoop_next + job->scoop_pos, *match_len);
246 return *match_pos != -1;
257 if (job->basis_len && (job->
basis_pos + job->basis_len) == match_pos) {
258 job->basis_len += match_len;
264 job->basis_len = match_len;
267 job->scoop_pos += match_len;
283 const size_t max_miss = 32768;
287 if (job->basis_len || (job->scoop_pos >= max_miss)) {
291 job->scoop_pos += miss_len;
299 if (job->basis_len) {
300 rs_trace(
"matched " FMT_LONG
" bytes at " FMT_LONG
"!", job->basis_len,
306 }
else if (job->scoop_pos) {
307 rs_trace(
"got " FMT_SIZE
" bytes of literal data", job->scoop_pos);
328 job->scoop_avail -= job->scoop_pos;
329 job->scoop_next += job->scoop_pos;
362 rs_trace(
"emit slack delta for " FMT_SIZE
" available bytes", avail);
366 }
else if (rs_job_input_is_ending(job)) {
380 rs_trace(
"no signature provided for delta, using slack deltas");
392 if (sig && sig->
count > 0) {
393 rs_signature_check(sig);
397 weaksum_init(&job->
weak_sum, rs_signature_weaksum_kind(sig));
static int rs_findmatch(rs_job_t *job, rs_long_t *match_pos, size_t *match_len)
find a match at scoop_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,...
void rs_emit_end_cmd(rs_job_t *job)
Write an END command.
void rs_emit_literal_cmd(rs_job_t *job, int len)
Write a LITERAL command.
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_delta_header(rs_job_t *job)
Write the magic for the start of a delta.
How to emit commands to the client.
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.
size_t rs_scoop_total_avail(rs_job_t *job)
Return the total number of bytes available including the scoop and input buffer.
void rs_scoop_input(rs_job_t *job, size_t len)
Try to accept a from the input buffer to get LEN bytes in the scoop.
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.
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.
Description of input and output buffers.
size_t avail_in
Number of bytes available at next_in.
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_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.