51 job->
stats.start = time(NULL);
53 rs_trace(
"start %s job", job_name);
63 rs_bzero(job,
sizeof *job);
73 assert(rs_tube_is_idle(job) || result !=
RS_DONE);
76 job->
stats.end = time(NULL);
80 rs_trace(
"%s job complete", job->
job_name);
88 size_t orig_in, orig_out;
95 result = rs_job_work(job, buffers);
98 && orig_in && orig_out) {
99 rs_error(
"internal error: job made no progress " "[orig_in="
100 FMT_SIZE
", orig_out=" FMT_SIZE
", final_in=" FMT_SIZE
101 ", final_out=" FMT_SIZE
"]", orig_in, orig_out,
115 job->stream = buffers;
130 return rs_job_complete(job, result);
144 rs_bzero(buf,
sizeof *buf);
147 if (!buf->
eof_in && in_cb) {
148 iores = in_cb(job, buf, in_opaque);
158 iores = (out_cb) (job, buf, out_opaque);
Generic state-machine interface.
#define RS_JOB_TAG
Magic job tag number for checking jobs have been initialized.
#define rs_job_check(job)
Assert that a job is valid.
Public header for librsync.
LIBRSYNC_EXPORT rs_result rs_job_free(rs_job_t *)
Deallocate job state.
LIBRSYNC_EXPORT void rs_free_sumset(rs_signature_t *)
Deep deallocation of checksums.
LIBRSYNC_EXPORT char const * rs_strerror(rs_result r)
Return an English description of a rs_result value.
rs_result
Return codes from nonblocking rsync operations.
@ RS_RUNNING
The job is still running, and not yet finished or blocked.
@ RS_DONE
Completed successfully.
@ RS_INTERNAL_ERROR
Probably a library bug.
@ RS_BLOCKED
Blocked waiting for more data.
LIBRSYNC_EXPORT rs_result rs_job_drive(rs_job_t *job, rs_buffers_t *buf, rs_driven_cb in_cb, void *in_opaque, rs_driven_cb out_cb, void *out_opaque)
Actively process a job, by making callbacks to fill and empty the buffers until the job is done.
LIBRSYNC_EXPORT const rs_stats_t * rs_job_statistics(rs_job_t *job)
Return a pointer to the statistics in a job.
rs_result rs_driven_cb(rs_job_t *job, rs_buffers_t *buf, void *opaque)
Type of application-supplied function for rs_job_drive().
LIBRSYNC_EXPORT rs_result rs_job_iter(rs_job_t *job, rs_buffers_t *buffers)
Run a rs_job state machine until it blocks (RS_BLOCKED), returns an error, or completes (RS_DONE).
Manage librsync streams of IO.
rs_result rs_tube_catchup(rs_job_t *job)
Put whatever will fit from the tube into the output of the stream.
Description of input and output buffers.
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.
The contents of this structure are private.
const char * job_name
Human-readable job operation name.
rs_byte_t * scoop_buf
Buffer of data in the scoop.
int job_owns_sig
Flag indicating signature should be destroyed with the job.
rs_result(* statefn)(rs_job_t *)
Callback for each processing step.
rs_result final_result
Final result of processing job.
rs_signature_t * signature
Pointer to the signature that's being used by the operation.
rs_stats_t stats
Encoding statistics.
Performance statistics from a librsync encoding or decoding operation.
char const * op
Human-readable name of current operation.
Misc utility functions used by librsync.
#define rs_alloc_struct(type)
Allocate and zero-fill an instance of TYPE.