63 static 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",
93 if (len > job->scoop_avail)
94 len = job->scoop_avail;
98 memcpy(stream->
next_out, job->scoop_next, len);
101 job->scoop_avail -= len;
102 job->scoop_next += len;
105 rs_trace(
"copied " FMT_SIZE
" bytes from scoop, " FMT_SIZE
106 " left in scoop, " FMT_SIZE
" left to copy", len, job->scoop_avail,
131 rs_trace(
"copied " FMT_SIZE
" bytes from stream, " FMT_SIZE
132 "left in stream, " FMT_SIZE
" left to copy", len, stream->
avail_in,
142 assert(job->write_len == 0);
146 if (job->scoop_avail && job->
copy_len) {
150 if (job->
copy_len && !job->scoop_avail) {
161 if (job->write_len) {
162 rs_tube_catchup_write(job);
171 && !job->scoop_avail) {
172 rs_error(
"reached end of file while copying data");
184 int rs_tube_is_idle(
rs_job_t const *job)
186 return job->write_len == 0 && job->
copy_len == 0;
217 assert(len <=
sizeof(job->
write_buf) - job->write_len);
219 memcpy(job->
write_buf + job->write_len, buf, len);
220 job->write_len += len;
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.
Description of input and output buffers.
char * next_in
Next input byte.
size_t avail_in
Number of bytes available at next_in.
int eof_in
True if there is no more data after this.
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.
static void rs_tube_copy_from_stream(rs_job_t *job)
Execute a copy command, taking data from 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.
static void rs_tube_copy_from_scoop(rs_job_t *job)
Execute a copy command, taking data from the scoop.