47 pf->buf = rs_alloc(buf_len,
"file buffer");
48 pf->buf_len = buf_len;
56 rs_bzero(fb,
sizeof *fb);
71 assert(buf->
next_in >= fb->buf);
76 }
else if (buf->
avail_in > fb->buf_len / 2) {
81 rs_trace(
"moving buffer " FMT_SIZE
" bytes to reuse " FMT_SIZE
" bytes",
88 if ((buf->
eof_in = feof(f))) {
89 rs_trace(
"seen end of file on input");
92 rs_error(
"error filling buf from file: %s", strerror(errno));
118 size_t present = buf->
next_out - fb->buf;
120 size_t result = fwrite(fb->buf, 1, present, f);
121 if (present != result) {
122 rs_error(
"error draining buf to file: %s", strerror(errno));
Buffers that map between stdio file streams and librsync streams.
Generic state-machine interface.
Public header for librsync.
rs_result
Return codes from nonblocking rsync operations.
@ RS_DONE
Completed successfully.
@ RS_IO_ERROR
Error in file or network 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.
rs_stats_t stats
Encoding statistics.
rs_long_t out_bytes
Total bytes written to output.
rs_long_t in_bytes
Total bytes read from input.
Misc utility functions used by librsync.
#define rs_alloc_struct(type)
Allocate and zero-fill an instance of TYPE.