63 static void rs_tube_catchup_write(
rs_job_t *job)
66 int len = job->write_len;
72 rs_trace(
"no output space available");
78 job->write_len -= len;
79 if (job->write_len > 0) {
83 rs_trace(
"wrote %d bytes from tube, %d remaining", len, job->write_len);
95 if (len > job->scoop_avail)
96 len = job->scoop_avail;
99 memcpy(stream->
next_out, job->scoop_next, len);
102 job->scoop_avail -= len;
103 job->scoop_next += len;
105 rs_trace(
"caught up on " FMT_SIZE
" copied bytes from scoop, " FMT_SIZE
106 " remain there, " FMT_LONG
" remain to be copied", len,
116 assert(job->write_len == 0);
120 if (job->scoop_avail && job->
copy_len) {
124 if (job->
copy_len && !job->scoop_avail) {
127 rs_trace(
"copied " FMT_SIZE
" bytes from input buffer, " FMT_LONG
128 " remain to be copied", this_copy, job->
copy_len);
138 if (job->write_len) {
139 rs_tube_catchup_write(job);
148 && !job->scoop_avail) {
150 (
"reached end of file while copying literal data through buffers");
162 int rs_tube_is_idle(
rs_job_t const *job)
164 return job->write_len == 0 && job->
copy_len == 0;
195 assert(len <=
sizeof(job->
write_buf) - job->write_len);
197 memcpy(job->
write_buf + job->write_len, buf, len);
198 job->write_len += len;
Description of input and output buffers.
rs_long_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.
size_t avail_out
Remaining free space at next_out.
static void rs_tube_catchup_copy(rs_job_t *job)
Catch up on an outstanding copy command.
char * next_out
Next output byte should be put there.
size_t avail_in
Number of bytes available at next_in.
Public header for librsync.
static void rs_tube_copy_from_scoop(rs_job_t *job)
Execute a copy command, taking data from the scoop.
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.
int rs_tube_catchup(rs_job_t *job)
Put whatever will fit from the tube into the output of the stream.
Unexpected end of input file, perhaps due to a truncated file or dropped network connection.
Blocked waiting for more data.
int rs_buffers_copy(rs_buffers_t *stream, int max_len)
Copy up to max_len bytes from input of stream to its output.
int eof_in
True if there is no more data after this.
void rs_tube_write(rs_job_t *job, const void *buf, size_t len)
Push some data into the tube for storage.
The contents of this structure are private.