Go to the documentation of this file.
66 static void rs_tube_catchup_write(
rs_job_t *job)
79 rs_trace(
"no output space available");
87 remain = job->write_len - len;
88 rs_trace(
"transmitted %d write bytes from tube, %d remain to be sent", len,
98 job->write_len = remain;
114 memcpy(stream->
next_out, job->scoop_next, this_len);
119 job->scoop_avail -= this_len;
120 job->scoop_next += this_len;
124 rs_trace(
"caught up on " FMT_SIZE
" copied bytes from scoop, " FMT_SIZE
125 " remain there, " FMT_LONG
" remain to be copied", this_len,
135 assert(job->write_len == 0);
139 if (job->scoop_avail && job->
copy_len) {
143 if (job->
copy_len && !job->scoop_avail) {
146 rs_trace(
"copied " FMT_SIZE
" bytes from input buffer, " FMT_LONG
147 " remain to be copied", this_copy, job->
copy_len);
157 if (job->write_len) {
158 rs_tube_catchup_write(job);
167 && !job->scoop_avail) {
169 (
"reached end of file while copying literal data through buffers");
181 int rs_tube_is_idle(
rs_job_t const *job)
183 return job->write_len == 0 && job->
copy_len == 0;
215 if (len >
sizeof(job->
write_buf) - job->write_len) {
216 rs_fatal(
"tube popped when trying to write " FMT_SIZE
" bytes!", len);
219 memcpy(job->
write_buf + job->write_len, buf, len);
220 job->write_len += len;
size_t avail_in
Number of bytes available at next_in.
int rs_buffers_copy(rs_buffers_t *stream, int max_len)
Copy up to max_len bytes from input of stream to its output.
@ RS_DONE
Completed successfully.
rs_byte_t write_buf[36]
If USED is >0, then buf contains that much write data to be sent out.
@ RS_INPUT_ENDED
Unexpected end of input file, perhaps due to a truncated file or dropped network connection.
rs_long_t copy_len
If copy_len is >0, then that much data should be copied through from the input.
int rs_tube_catchup(rs_job_t *job)
Put whatever will fit from the tube into the output of the stream.
static void rs_tube_catchup_copy(rs_job_t *job)
Catch up on an outstanding copy command.
int eof_in
True if there is no more data after this.
@ RS_BLOCKED
Blocked waiting for more data.
void rs_tube_write(rs_job_t *job, const void *buf, size_t len)
Push some data into the tube for storage.
char * next_out
Next output byte should be put there.
size_t avail_out
Remaining free space at next_out.
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.
static void rs_tube_copy_from_scoop(rs_job_t *job)
Execute a copy command, taking data from the scoop.
Description of input and output buffers.