106 int rs_roll_paranoia = 0;
111 static inline void rs_getinput(
rs_job_t *job);
140 && ((job->scoop_pos + block_len) < job->scoop_avail)) {
148 RollsumRotate(&job->
weak_sum, job->scoop_next[job->scoop_pos],
149 job->scoop_next[job->scoop_pos + block_len]);
151 if (rs_roll_paranoia) {
153 RollsumUpdate(&test, job->scoop_next + job->scoop_pos,
155 if (RollsumDigest(&test) != RollsumDigest(&job->
weak_sum)) {
156 rs_fatal(
"mismatch between rolled sum " FMT_WEAKSUM
157 " and check " FMT_WEAKSUM
"",
159 RollsumDigest(&test));
168 if (job->stream->
eof_in) {
169 job->
statefn = rs_delta_s_flush;
191 while ((result ==
RS_DONE) && (job->scoop_pos < job->scoop_avail)) {
199 RollsumRollout(&job->
weak_sum, job->scoop_next[job->scoop_pos]);
200 rs_trace(
"block reduced to " FMT_SIZE
"", job->
weak_sum.count);
221 static inline void rs_getinput(
rs_job_t *job)
226 if (job->scoop_avail < len) {
248 *match_len = job->scoop_avail - job->scoop_pos;
249 if (*match_len > block_len) {
250 *match_len = block_len;
253 RollsumUpdate(&job->
weak_sum, job->scoop_next + job->scoop_pos,
255 rs_trace(
"calculate weak sum from scratch length " FMT_SIZE
"",
263 job->scoop_next + job->scoop_pos, *match_len);
264 return *match_pos != -1;
275 if (job->basis_len && (job->
basis_pos + job->basis_len) == match_pos) {
276 job->basis_len += match_len;
282 job->basis_len = match_len;
285 job->scoop_pos += match_len;
301 const size_t max_miss = 32768;
305 if (job->basis_len || (job->scoop_pos >= max_miss)) {
309 job->scoop_pos += miss_len;
317 if (job->basis_len) {
318 rs_trace(
"matched " FMT_LONG
" bytes at " FMT_LONG
"!", job->basis_len,
324 }
else if (job->scoop_pos) {
325 rs_trace(
"got " FMT_SIZE
" bytes of literal data", job->scoop_pos);
346 job->scoop_avail -= job->scoop_pos;
347 job->scoop_next += job->scoop_pos;
380 rs_trace(
"emit slack delta for " FMT_SIZE
" available bytes", avail);
384 }
else if (rs_job_input_is_ending(job)) {
398 rs_trace(
"no signature provided for delta, using slack deltas");
410 if (sig && sig->
count > 0) {
411 rs_signature_check(sig);
hashtable_t * hashtable
The hashtable for finding matches.
Description of input and output buffers.
int count
Total number of blocks.
int block_len
The block length.
void rs_emit_delta_header(rs_job_t *job)
Write the magic for the start of a delta.
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.
size_t rs_scoop_total_avail(rs_job_t *job)
Return the total number of bytes available including the scoop and input buffer.
rs_signature_t * signature
Pointer to the signature that's being used by the operation.
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.
static rs_result rs_delta_s_header(rs_job_t *job)
State function for writing out the header of the encoding job.
size_t avail_in
Number of bytes available at next_in.
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, or flushing any previous match.
void rs_emit_end_cmd(rs_job_t *job)
Write an END command.
rs_long_t basis_pos
Copy from the basis position.
Public header for librsync.
static rs_result rs_delta_s_scan(rs_job_t *job)
Get a block of data if possible, and see if it matches.
Signature of a whole file.
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_processmiss(rs_job_t *job)
Process miss data in the scoop.
rs_job_t * rs_delta_begin(rs_signature_t *sig)
Prepare to compute a streaming delta.
Rollsum weak_sum
The rollsum weak signature accumulator used by delta.c.
void rs_tube_copy(rs_job_t *job, int len)
Queue up a request to copy through len bytes from the input to the output of the stream.
rs_result
Return codes from nonblocking rsync operations.
How to emit commands to the client.
int rs_tube_catchup(rs_job_t *job)
Put whatever will fit from the tube into the output of the stream.
static rs_result rs_appendflush(rs_job_t *job)
Flush any accumulating hit or miss, appending it to the delta.
Blocked waiting for more data.
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.
The job is still running, and not yet finished or blocked.
rs_result(* statefn)(rs_job_t *)
Callback for each processing step.
int eof_in
True if there is no more data after this.
void rs_emit_literal_cmd(rs_job_t *job, int len)
Write a LITERAL command.
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...
static rs_result rs_processmatch(rs_job_t *job)
Process matching data in the scoop.
of this structure are private.