librsync  2.3.2
job.h
1/*= -*- c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 *
3 * librsync -- the library for network deltas
4 *
5 * Copyright (C) 2000, 2001, 2014 by Martin Pool <mbp@sourcefrog.net>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include "mdfour.h"
23#include "checksum.h"
24
25/** The contents of this structure are private. */
26struct rs_job {
27 int dogtag;
28
29 /** Human-readable job operation name. */
30 const char *job_name;
31
32 rs_buffers_t *stream;
33
34 /** Callback for each processing step. */
36
37 /** Final result of processing job. Used by rs_job_s_failed(). */
39
40 /* Arguments for initializing the signature used by mksum.c and readsums.c.
41 */
42 int sig_magic;
43 int sig_block_len;
44 int sig_strong_len;
45
46 /** The size of the signature file if available. Used by loadsums.c when
47 * initializing the signature to preallocate memory. */
48 rs_long_t sig_fsize;
49
50 /** Pointer to the signature that's being used by the operation. */
52
53 /** Flag indicating signature should be destroyed with the job. */
55
56 /** Command byte currently being processed, if any. */
57 unsigned char op;
58
59 /** The weak signature digest used by readsums.c */
60 rs_weak_sum_t weak_sig;
61
62 /** The rollsum weak signature accumulator used by delta.c */
64
65 /** Lengths of expected parameters. */
66 rs_long_t param1, param2;
67
68 struct rs_prototab_ent const *cmd;
69 rs_mdfour_t output_md4;
70
71 /** Encoding statistics. */
73
74 /** Buffer of data in the scoop. Allocation is scoop_buf[0..scoop_alloc],
75 * and scoop_next[0..scoop_avail] contains data yet to be processed.
76 * scoop_next[scoop_pos..scoop_avail] is the data yet to be scanned. */
77 rs_byte_t *scoop_buf; /* the allocation pointer */
78 rs_byte_t *scoop_next; /* the data pointer */
79 size_t scoop_alloc; /* the allocation size */
80 size_t scoop_avail; /* the data size */
81 size_t scoop_pos; /* the scan position */
82
83 /** If USED is >0, then buf contains that much write data to be sent out. */
84 rs_byte_t write_buf[36];
85 size_t write_len;
86
87 /** If \p copy_len is >0, then that much data should be copied through
88 * from the input. */
89 size_t copy_len;
90
91 /** Copy from the basis position. */
92 rs_long_t basis_pos, basis_len;
93
94 /** Callback used to copy data from the basis into the output. */
96 void *copy_arg;
97};
98
99rs_job_t *rs_job_new(const char *, rs_result (*statefn)(rs_job_t *));
100
101int rs_job_input_is_ending(rs_job_t *job);
102
103/** Magic job tag number for checking jobs have been initialized. */
104#define RS_JOB_TAG 20010225
105
106/** Assert that a job is valid.
107 *
108 * We don't use a static inline function here so that assert failure output
109 * points at where rs_job_check() was called from. */
110#define rs_job_check(job) do {\
111 assert(job->dogtag == RS_JOB_TAG);\
112} while (0)
rs_result
Return codes from nonblocking rsync operations.
Definition: librsync.h:180
struct rs_mdfour rs_mdfour_t
MD4 message-digest accumulator.
Definition: librsync.h:236
rs_result rs_copy_cb(void *opaque, rs_long_t pos, size_t *len, void **buf)
Callback used to retrieve parts of the basis file.
Definition: librsync.h:493
Description of input and output buffers.
Definition: librsync.h:322
The contents of this structure are private.
Definition: job.h:26
const char * job_name
Human-readable job operation name.
Definition: job.h:30
rs_long_t basis_pos
Copy from the basis position.
Definition: job.h:92
rs_byte_t * scoop_buf
Buffer of data in the scoop.
Definition: job.h:77
unsigned char op
Command byte currently being processed, if any.
Definition: job.h:57
rs_copy_cb * copy_cb
Callback used to copy data from the basis into the output.
Definition: job.h:95
size_t copy_len
If copy_len is >0, then that much data should be copied through from the input.
Definition: job.h:89
rs_weak_sum_t weak_sig
The weak signature digest used by readsums.c.
Definition: job.h:60
int job_owns_sig
Flag indicating signature should be destroyed with the job.
Definition: job.h:54
rs_result(* statefn)(rs_job_t *)
Callback for each processing step.
Definition: job.h:35
rs_long_t sig_fsize
The size of the signature file if available.
Definition: job.h:48
rs_result final_result
Final result of processing job.
Definition: job.h:38
rs_signature_t * signature
Pointer to the signature that's being used by the operation.
Definition: job.h:51
rs_byte_t write_buf[36]
If USED is >0, then buf contains that much write data to be sent out.
Definition: job.h:84
rs_stats_t stats
Encoding statistics.
Definition: job.h:72
weaksum_t weak_sum
The rollsum weak signature accumulator used by delta.c.
Definition: job.h:63
rs_long_t param1
Lengths of expected parameters.
Definition: job.h:66
Signature of a whole file.
Definition: sumset.h:37
Performance statistics from a librsync encoding or decoding operation.
Definition: librsync.h:210
Abstract wrapper around weaksum implementations.
Definition: checksum.h:51