77 for (newsize = 64; newsize < len; newsize <<= 1) ;
78 newbuf = rs_alloc(newsize,
"scoop buffer");
84 rs_trace(
"resized scoop buffer to " FMT_SIZE
" bytes from " FMT_SIZE
"",
89 rs_trace(
"moving scoop " FMT_SIZE
" bytes to reuse " FMT_SIZE
" bytes",
103 rs_trace(
"accepted " FMT_SIZE
" bytes from input to scoop", tocopy);
126 rs_trace(
"advance over " FMT_SIZE
" bytes from scoop", len);
127 assert(len <= job->scoop_avail);
131 rs_trace(
"advance over " FMT_SIZE
" bytes from input buffer", len);
132 assert(len <= stream->avail_in);
156 rs_trace(
"got " FMT_SIZE
" bytes direct from input", len);
160 rs_trace(
"scoop has less than " FMT_SIZE
" bytes, scooping from "
161 FMT_SIZE
" input bytes", len, stream->
avail_in);
166 rs_trace(
"scoop has at least " FMT_SIZE
" bytes, this is enough",
170 }
else if (stream->
eof_in) {
172 rs_trace(
"reached end of input stream");
176 rs_trace(
"blocked with insufficient input data");
214 *len = rs_scoop_avail(job);
217 else if (job->stream->
eof_in)
Generic state-machine interface.
#define rs_job_check(job)
Assert that a job is valid.
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.
rs_result rs_scoop_readahead(rs_job_t *job, size_t len, void **ptr)
Read from scoop without advancing.
static 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.
rs_result rs_scoop_read(rs_job_t *job, size_t len, void **ptr)
Read LEN bytes if possible, and remove them from the input scoop.
void rs_scoop_advance(rs_job_t *job, size_t len)
Advance the input cursor forward len bytes.
rs_result rs_scoop_read_rest(rs_job_t *job, size_t *len, void **ptr)
Read whatever data remains in the input stream.
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.
The contents of this structure are private.
rs_byte_t * scoop_buf
Buffer of data in the scoop.
size_t scoop_alloc
The buffer allocation size.
rs_byte_t * scoop_next
The next data pointer.
size_t scoop_avail
The amount of data available.
Misc utility functions used by librsync.