63static void rs_tube_catchup_write(
rs_job_t *job)
66 size_t len = job->write_len;
75 job->write_len -= len;
76 if (job->write_len > 0)
80 rs_trace(
"wrote " FMT_SIZE
" bytes from tube, " FMT_SIZE
" left to write",
90 assert(job->write_len == 0);
94 size_t avail_in = rs_scoop_avail(job);
99 if (copy_len > avail_in)
101 if (copy_len > avail_out)
102 copy_len = avail_out;
106 memcpy(stream->
next_out, next, ilen);
111 rs_trace(
"copied " FMT_SIZE
" bytes from scoop, " FMT_SIZE
112 " left in scoop, " FMT_SIZE
" left to copy", copy_len,
113 rs_scoop_avail(job), job->
copy_len);
122 if (job->write_len) {
123 rs_tube_catchup_write(job);
132 rs_error(
"reached end of file while copying data");
144int rs_tube_is_idle(
rs_job_t const *job)
146 return job->write_len == 0 && job->
copy_len == 0;
177 assert(len <=
sizeof(job->
write_buf) - job->write_len);
179 memcpy(job->
write_buf + job->write_len, buf, len);
180 job->write_len += len;
Generic state-machine interface.
Public header for librsync.
rs_result
Return codes from nonblocking rsync operations.
@ RS_DONE
Completed successfully.
@ RS_INPUT_ENDED
Unexpected end of input file, perhaps due to a truncated file or dropped network connection.
@ RS_BLOCKED
Blocked waiting for more data.
Manage librsync streams of IO.
static bool rs_scoop_eof(rs_job_t *job)
Test if the scoop has reached eof.
static void * rs_scoop_iterbuf(rs_job_t *job, size_t *len, size_t *ilen)
Iterate through and consume contiguous data buffers in the scoop.
static void * rs_scoop_nextbuf(rs_job_t *job, size_t *len, size_t *ilen)
Get the next iteration of contiguous data buffers from the scoop.
Description of input and output buffers.
size_t avail_out
Remaining free space at next_out.
char * next_out
Next output byte should be put there.
The contents of this structure are private.
size_t copy_len
If copy_len is >0, then that much data should be copied through from the input.
rs_byte_t write_buf[36]
If USED is >0, then buf contains that much write data to be sent out.
void rs_tube_write(rs_job_t *job, const void *buf, size_t len)
Push some data into the tube for storage.
static void rs_tube_catchup_copy(rs_job_t *job)
Catch up on an outstanding copy command.
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.