librsync  2.0.2
librsync.h
Go to the documentation of this file.
1 /*= -*- c-basic-offset: 4; indent-tabs-mode: nil; -*-
2  *
3  * librsync -- library for network deltas
4  *
5  * Copyright 2000, 2001, 2014, 2015 by Martin Pool <mbp@sourcefrog.net>
6  * Copyright (C) 2003 by Donovan Baarda <abo@minkirri.apana.org.au>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22 
23  /*=
24  | You should never wear your best
25  | trousers when you go out to fight for
26  | freedom and liberty.
27  | -- Henrik Ibsen
28  */
29 
30 /** \file librsync.h Public header for librsync. */
31 
32 #ifndef _RSYNC_H
33 # define _RSYNC_H
34 
35 # include <sys/types.h>
36 # include <stdio.h>
37 # include <stdint.h>
38 # include <time.h>
39 
40 # ifdef __cplusplus
41 extern "C" {
42 # endif
43 
44 /** Library version string.
45  *
46  * \sa \ref versioning */
47 extern char const rs_librsync_version[];
48 
49 /** Summary of the licence for librsync. */
50 extern char const rs_licence_string[];
51 
52 typedef uint8_t rs_byte_t;
53 typedef intmax_t rs_long_t;
54 
55  /*=
56  | "The IETF already has more than enough
57  | RFCs that codify the obvious, make
58  | stupidity illegal, support truth,
59  | justice, and the IETF way, and generally
60  | demonstrate the author is a brilliant and
61  | valuable Contributor to The Standards
62  | Process."
63  | -- Vernon Schryver
64  */
65 
66 /** A uint32 magic number, emitted in bigendian/network order at the start of
67  * librsync files. */
68 typedef enum {
69  /** A delta file.
70  *
71  * At present, there's only one delta format.
72  *
73  * The four-byte literal \c "rs\x026". */
74  RS_DELTA_MAGIC = 0x72730236,
75 
76  /** A signature file with MD4 signatures.
77  *
78  * Backward compatible with librsync < 1.0, but strongly deprecated because
79  * it creates a security vulnerability on files containing partly untrusted
80  * data. See <https://github.com/librsync/librsync/issues/5>.
81  *
82  * The four-byte literal \c "rs\x016".
83  *
84  * \sa rs_sig_begin() */
85  RS_MD4_SIG_MAGIC = 0x72730136,
86 
87  /** A signature file using the BLAKE2 hash. Supported from librsync 1.0.
88  *
89  * The four-byte literal \c "rs\x017".
90  *
91  * \sa rs_sig_begin() */
92  RS_BLAKE2_SIG_MAGIC = 0x72730137
94 
95 /** Log severity levels.
96  *
97  * These are the same as syslog, at least in glibc.
98  *
99  * \sa rs_trace_set_level() \sa \ref api_trace */
100 typedef enum {
101  RS_LOG_EMERG = 0, /**< System is unusable */
102  RS_LOG_ALERT = 1, /**< Action must be taken immediately */
103  RS_LOG_CRIT = 2, /**< Critical conditions */
104  RS_LOG_ERR = 3, /**< Error conditions */
105  RS_LOG_WARNING = 4, /**< Warning conditions */
106  RS_LOG_NOTICE = 5, /**< Normal but significant condition */
107  RS_LOG_INFO = 6, /**< Informational */
108  RS_LOG_DEBUG = 7 /**< Debug-level messages */
109 } rs_loglevel;
110 
111 /** \typedef rs_trace_fn_t Callback to write out log messages.
112  *
113  * \param level a syslog level.
114  *
115  * \param msg message to be logged.
116  *
117  * \sa \ref api_trace */
118 typedef void rs_trace_fn_t(rs_loglevel level, char const *msg);
119 
120 /** Set the least important message severity that will be output.
121  *
122  * \sa \ref api_trace */
123 void rs_trace_set_level(rs_loglevel level);
124 
125 /** Set trace callback.
126  *
127  * \sa \ref api_trace */
128 void rs_trace_to(rs_trace_fn_t *);
129 
130 /** Default trace callback that writes to stderr.
131  *
132  * Implements ::rs_trace_fn_t, and may be passed to rs_trace_to().
133  *
134  * \sa \ref api_trace */
135 void rs_trace_stderr(rs_loglevel level, char const *msg);
136 
137 /** Check whether the library was compiled with debugging trace.
138  *
139  * \returns True if the library contains trace code; otherwise false.
140  *
141  * If this returns false, then trying to turn trace on will achieve nothing.
142  *
143  * \sa \ref api_trace */
144 int rs_supports_trace(void);
145 
146 /** Convert \p from_len bytes at \p from_buf into a hex representation in \p
147  * to_buf, which must be twice as long plus one byte for the null terminator. */
148 void rs_hexify(char *to_buf, void const *from_buf, int from_len);
149 
150 /** Decode a base64 buffer in place.
151  *
152  * \returns The number of binary bytes. */
153 size_t rs_unbase64(char *s);
154 
155 /** Encode a buffer as base64. */
156 void rs_base64(unsigned char const *buf, int n, char *out);
157 
158 /** \enum rs_result Return codes from nonblocking rsync operations.
159  *
160  * \sa rs_strerror() \sa api_callbacks */
161 typedef enum rs_result {
162  RS_DONE = 0, /**< Completed successfully. */
163  RS_BLOCKED = 1, /**< Blocked waiting for more data. */
164  RS_RUNNING = 2, /**< The job is still running, and not yet
165  * finished or blocked. (This value should
166  * never be seen by the application.) */
167  RS_TEST_SKIPPED = 77, /**< Test neither passed or failed. */
168  RS_IO_ERROR = 100, /**< Error in file or network IO. */
169  RS_SYNTAX_ERROR = 101, /**< Command line syntax error. */
170  RS_MEM_ERROR = 102, /**< Out of memory. */
171  RS_INPUT_ENDED = 103, /**< Unexpected end of input file, perhaps due
172  * to a truncated file or dropped network
173  * connection. */
174  RS_BAD_MAGIC = 104, /**< Bad magic number at start of stream.
175  * Probably not a librsync file, or possibly
176  * the wrong kind of file or from an
177  * incompatible library version. */
178  RS_UNIMPLEMENTED = 105, /**< Author is lazy. */
179  RS_CORRUPT = 106, /**< Unbelievable value in stream. */
180  RS_INTERNAL_ERROR = 107, /**< Probably a library bug. */
181  RS_PARAM_ERROR = 108 /**< Bad value passed in to library, probably
182  * an application bug. */
183 } rs_result;
184 
185 /** Return an English description of a ::rs_result value. */
186 char const *rs_strerror(rs_result r);
187 
188 /** Performance statistics from a librsync encoding or decoding operation.
189  *
190  * \sa api_stats \sa rs_format_stats() \sa rs_log_stats() */
191 typedef struct rs_stats {
192  char const *op; /**< Human-readable name of current operation.
193  * For example, "delta". */
194  int lit_cmds; /**< Number of literal commands. */
195  rs_long_t lit_bytes; /**< Number of literal bytes. */
196  rs_long_t lit_cmdbytes; /**< Number of bytes used in literal command
197  * headers. */
198 
199  rs_long_t copy_cmds, copy_bytes, copy_cmdbytes;
200  rs_long_t sig_cmds, sig_bytes;
201  int false_matches;
202 
203  rs_long_t sig_blocks; /**< Number of blocks described by the
204  * signature. */
205 
206  size_t block_len;
207 
208  rs_long_t in_bytes; /**< Total bytes read from input. */
209  rs_long_t out_bytes; /**< Total bytes written to output. */
210 
211  time_t start, end;
212 } rs_stats_t;
213 
214 /** \typedef struct rs_mdfour rs_mdfour_t
215  *
216  * \brief MD4 message-digest accumulator.
217  *
218  * \sa rs_mdfour(), rs_mdfour_begin(), rs_mdfour_update(), rs_mdfour_result() */
219 typedef struct rs_mdfour rs_mdfour_t;
220 
221 extern const int RS_MD4_SUM_LENGTH, RS_BLAKE2_SUM_LENGTH;
222 
223 # define RS_MAX_STRONG_SUM_LENGTH 32
224 
225 typedef uint32_t rs_weak_sum_t;
226 typedef unsigned char rs_strong_sum_t[RS_MAX_STRONG_SUM_LENGTH];
227 
228 void rs_mdfour(unsigned char *out, void const *in, size_t);
229 void rs_mdfour_begin( /* @out@ */ rs_mdfour_t *md);
230 
231 /** Feed some data into the MD4 accumulator.
232  *
233  * \param md MD4 accumulator.
234  *
235  * \param in_void Data to add.
236  *
237  * \param n Number of bytes fed in. */
238 void rs_mdfour_update(rs_mdfour_t *md, void const *in_void, size_t n);
239 void rs_mdfour_result(rs_mdfour_t *md, unsigned char *out);
240 
241 /** Return a human-readable representation of statistics.
242  *
243  * The string is truncated if it does not fit. 100 characters should be
244  * sufficient space.
245  *
246  * \param stats Statistics from an encoding or decoding operation.
247  *
248  * \param buf Buffer to receive result.
249  *
250  * \param size Size of buffer.
251  *
252  * \return \p buf.
253  *
254  * \sa \ref api_stats */
255 char *rs_format_stats(rs_stats_t const *stats, char *buf, size_t size);
256 
257 /** Write statistics into the current log as text.
258  *
259  * \sa \ref api_stats \sa \ref api_trace */
260 int rs_log_stats(rs_stats_t const *stats);
261 
262 /** \typedef rs_signature_t */
263 typedef struct rs_signature rs_signature_t;
264 
265 /** Deep deallocation of checksums. */
267 
268 /** Dump signatures to the log. */
269 void rs_sumset_dump(rs_signature_t const *);
270 
271 /** Description of input and output buffers.
272  *
273  * On each call to ::rs_job_iter(), the caller can make available
274  *
275  * - #avail_in bytes of input data at #next_in
276  *
277  * - #avail_out bytes of output space at #next_out
278  *
279  * - or some of both
280  *
281  * Buffers must be allocated and passed in by the caller.
282  *
283  * On input, the buffers structure must contain the address and length of the
284  * input and output buffers. The library updates these values to indicate the
285  * amount of \b remaining buffer. So, on return, #avail_out is not the amount
286  * of output data produced, but rather the amount of output buffer space still
287  * available.
288  *
289  * This means that the values on return are consistent with the values on
290  * entry, and suitable to be passed in on a second call, but they don't
291  * directly tell you how much output data was produced.
292  *
293  * Note also that if *#avail_in is nonzero on return, then not all of the input
294  * data has been consumed. The caller should either provide more output buffer
295  * space and call ::rs_job_iter() again passing the same #next_in and
296  * #avail_in, or put the remaining input data into some persistent buffer and
297  * call rs_job_iter() with it again when there is more output space.
298  *
299  * \sa rs_job_iter() */
300 struct rs_buffers_s {
301  /** Next input byte.
302  *
303  * References a pointer which on entry should point to the start of the
304  * data to be encoded. Updated to point to the byte after the last one
305  * consumed. */
306  char *next_in;
307 
308  /** Number of bytes available at next_in.
309  *
310  * References the length of available input. Updated to be the number of
311  * unused data bytes, which will be zero if all the input was consumed. May
312  * be zero if there is no new input, but the caller just wants to drain
313  * output. */
314  size_t avail_in;
315 
316  /** True if there is no more data after this. */
317  int eof_in;
318 
319  /** Next output byte should be put there.
320  *
321  * References a pointer which on entry points to the start of the output
322  * buffer. Updated to point to the byte after the last one filled. */
323  char *next_out;
324 
325  /** Remaining free space at next_out.
326  *
327  * References the size of available output buffer. Updated to the size of
328  * unused output buffer. */
329  size_t avail_out;
330 };
331 
332 /** \sa ::rs_buffers_s */
333 typedef struct rs_buffers_s rs_buffers_t;
334 
335 /** Default block length, if not determined by any other factors. */
336 # define RS_DEFAULT_BLOCK_LEN 2048
337 
338 /** Job of work to be done.
339  *
340  * Created by functions such as rs_sig_begin(), and then iterated over by
341  * rs_job_iter().
342  *
343  * The contents are opaque to the application, and instances are always
344  * allocated by the library.
345  *
346  * \sa \ref api_streaming \sa rs_job */
347 typedef struct rs_job rs_job_t;
348 
349 /** Run a ::rs_job state machine until it blocks (::RS_BLOCKED), returns an
350  * error, or completes (::RS_DONE).
351  *
352  * \param job Description of job state.
353  *
354  * \param buffers Pointer to structure describing input and output buffers.
355  *
356  * \return The ::rs_result that caused iteration to stop.
357  *
358  * \c buffers->eof_in should be true if there is no more data after what's in
359  * the input buffer. The final block checksum will run across whatever's in
360  * there, without trying to accumulate anything else.
361  *
362  * \sa \ref api_streaming */
364 
365 /** Type of application-supplied function for rs_job_drive().
366  *
367  * \sa \ref api_pull */
369  void *opaque);
370 
371 /** Actively process a job, by making callbacks to fill and empty the buffers
372  * until the job is done. */
374  void *in_opaque, rs_driven_cb out_cb, void *out_opaque);
375 
376 /** Return a pointer to the statistics in a job. */
378 
379 /** Deallocate job state. */
381 
382 /** Start generating a signature.
383  *
384  * \return A new rs_job_t into which the old file data can be passed.
385  *
386  * \param sig_magic Indicates the version of signature file format to generate.
387  * See ::rs_magic_number.
388  *
389  * \param new_block_len Size of checksum blocks. Larger values make the
390  * signature shorter, and the delta longer.
391  *
392  * \param strong_sum_len If non-zero, truncate the strong signatures to this
393  * many bytes, to make the signature shorter. It's recommended you leave this
394  * at zero to get the full strength.
395  *
396  * \sa rs_sig_file() */
397 rs_job_t *rs_sig_begin(size_t new_block_len, size_t strong_sum_len,
398  rs_magic_number sig_magic);
399 
400 /** Prepare to compute a streaming delta.
401  *
402  * \todo Add a version of this that takes a ::rs_magic_number controlling the
403  * delta format. */
405 
406 /** Read a signature from a file into an ::rs_signature structure in memory.
407  *
408  * Once there, it can be used to generate a delta to a newer version of the
409  * file.
410  *
411  * \note After loading the signatures, you must call \ref rs_build_hash_table()
412  * before you can use them. */
414 
415 /** Call this after loading a signature to index it.
416  *
417  * Use rs_free_sumset() to release it after use. */
419 
420 /** Callback used to retrieve parts of the basis file.
421  *
422  * \param pos Position where copying should begin.
423  *
424  * \param len On input, the amount of data that should be retrieved. Updated to
425  * show how much is actually available, but should not be greater than the
426  * input value.
427  *
428  * \param buf On input, a buffer of at least \p *len bytes. May be updated to
429  * point to a buffer allocated by the callback if it prefers. */
430 typedef rs_result rs_copy_cb(void *opaque, rs_long_t pos, size_t *len,
431  void **buf);
432 
433 /** Apply a \a delta to a \a basis file to recreate the \a new file.
434  *
435  * This gives you back a ::rs_job_t object, which can be cranked by calling
436  * rs_job_iter() and updating the stream pointers. When finished, call
437  * rs_job_free() to dispose of it.
438  *
439  * \param copy_cb Callback used to retrieve content from the basis file.
440  *
441  * \param copy_arg Opaque environment pointer passed through to the callback.
442  *
443  * \todo As output is produced, accumulate the MD4 checksum of the output. Then
444  * if we find a CHECKSUM command we can check it's contents against the output.
445  *
446  * \todo Implement COPY commands.
447  *
448  * \sa rs_patch_file() \sa \ref api_streaming */
449 rs_job_t *rs_patch_begin(rs_copy_cb * copy_cb, void *copy_arg);
450 
451 # ifndef RSYNC_NO_STDIO_INTERFACE
452 # include <stdio.h>
453 
454 /** Buffer sizes for file IO.
455  *
456  * The default 0 means use the recommended buffer size for the operation being
457  * performed, any other value will override the recommended sizes. You probably
458  * only need to change these in testing. */
459 extern int rs_inbuflen, rs_outbuflen;
460 
461 /** Generate the signature of a basis file, and write it out to another.
462  *
463  * \param old_file Stdio readable file whose signature will be generated.
464  *
465  * \param sig_file Writable stdio file to which the signature will be written./
466  *
467  * \param block_len block size for signature generation, in bytes
468  *
469  * \param strong_len truncated length of strong checksums, in bytes
470  *
471  * \param sig_magic A signature magic number indicating what format to use.
472  *
473  * \param stats Optional pointer to receive statistics.
474  *
475  * \sa \ref api_whole */
476 rs_result rs_sig_file(FILE *old_file, FILE *sig_file, size_t block_len,
477  size_t strong_len, rs_magic_number sig_magic,
478  rs_stats_t *stats);
479 
480 /** Load signatures from a signature file into memory.
481  *
482  * \param sig_file Readable stdio file from which the signature will be read.
483  *
484  * \param sumset on return points to the newly allocated structure.
485  *
486  * \param stats Optional pointer to receive statistics.
487  *
488  * \sa \ref api_whole */
489 rs_result rs_loadsig_file(FILE *sig_file, rs_signature_t **sumset,
490  rs_stats_t *stats);
491 
492 /** ::rs_copy_cb that reads from a stdio file. */
493 rs_result rs_file_copy_cb(void *arg, rs_long_t pos, size_t *len, void **buf);
494 
495 /** Generate a delta between a signature and a new file into a delta file.
496  *
497  * \sa \ref api_whole */
498 rs_result rs_delta_file(rs_signature_t *, FILE *new_file, FILE *delta_file,
499  rs_stats_t *);
500 
501 /** Apply a patch, relative to a basis, into a new file.
502  *
503  * \sa \ref api_whole */
504 rs_result rs_patch_file(FILE *basis_file, FILE *delta_file, FILE *new_file,
505  rs_stats_t *);
506 # endif /* !RSYNC_NO_STDIO_INTERFACE */
507 
508 # ifdef __cplusplus
509 } /* extern "C" */
510 # endif
511 
512 #endif /* !_RSYNC_H */
rs_base64
void rs_base64(unsigned char const *buf, int n, char *out)
Encode a buffer as base64.
Definition: base64.c:65
RS_PARAM_ERROR
@ RS_PARAM_ERROR
Bad value passed in to library, probably an application bug.
Definition: librsync.h:181
rs_stats::op
const char * op
Human-readable name of current operation.
Definition: librsync.h:192
rs_format_stats
char * rs_format_stats(rs_stats_t const *stats, char *buf, size_t size)
Return a human-readable representation of statistics.
Definition: stats.c:49
RS_MEM_ERROR
@ RS_MEM_ERROR
Out of memory.
Definition: librsync.h:170
rs_buffers_s::avail_in
size_t avail_in
Number of bytes available at next_in.
Definition: librsync.h:314
rs_librsync_version
const char rs_librsync_version[]
Library version string.
Definition: version.c:24
RS_LOG_ALERT
@ RS_LOG_ALERT
Action must be taken immediately.
Definition: librsync.h:102
rs_result
rs_result
Definition: librsync.h:161
rs_build_hash_table
rs_result rs_build_hash_table(rs_signature_t *sums)
Call this after loading a signature to index it.
Definition: sumset.c:221
RS_LOG_ERR
@ RS_LOG_ERR
Error conditions.
Definition: librsync.h:104
rs_sig_begin
rs_job_t * rs_sig_begin(size_t new_block_len, size_t strong_sum_len, rs_magic_number sig_magic)
Start generating a signature.
Definition: mksum.c:117
rs_job_statistics
const rs_stats_t * rs_job_statistics(rs_job_t *job)
Return a pointer to the statistics in a job.
Definition: job.c:145
rs_file_copy_cb
rs_result rs_file_copy_cb(void *arg, rs_long_t pos, size_t *len, void **buf)
rs_copy_cb that reads from a stdio file.
Definition: fileutil.c:137
RS_DONE
@ RS_DONE
Completed successfully.
Definition: librsync.h:162
rs_stats::sig_blocks
rs_long_t sig_blocks
Number of blocks described by the signature.
Definition: librsync.h:203
RS_INTERNAL_ERROR
@ RS_INTERNAL_ERROR
Probably a library bug.
Definition: librsync.h:180
rs_hexify
void rs_hexify(char *to_buf, void const *from_buf, int from_len)
Convert from_len bytes at from_buf into a hex representation in to_buf, which must be twice as long p...
Definition: hex.c:32
rs_stats::in_bytes
rs_long_t in_bytes
Total bytes read from input.
Definition: librsync.h:208
rs_job_drive
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.
Definition: job.c:155
rs_job_iter
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).
Definition: job.c:96
rs_job
Definition: job.h:26
rs_strerror
const char * rs_strerror(rs_result r)
Return an English description of a rs_result value.
Definition: msg.c:49
RS_RUNNING
@ RS_RUNNING
The job is still running, and not yet finished or blocked.
Definition: librsync.h:164
RS_LOG_CRIT
@ RS_LOG_CRIT
Critical conditions.
Definition: librsync.h:103
RS_INPUT_ENDED
@ RS_INPUT_ENDED
Unexpected end of input file, perhaps due to a truncated file or dropped network connection.
Definition: librsync.h:171
rs_buffers_s::next_in
char * next_in
Next input byte.
Definition: librsync.h:306
RS_LOG_WARNING
@ RS_LOG_WARNING
Warning conditions.
Definition: librsync.h:105
RS_LOG_EMERG
@ RS_LOG_EMERG
System is unusable.
Definition: librsync.h:101
rs_trace_set_level
void rs_trace_set_level(rs_loglevel level)
Set the least important message severity that will be output.
Definition: trace.c:84
rs_stats::out_bytes
rs_long_t out_bytes
Total bytes written to output.
Definition: librsync.h:209
RS_DELTA_MAGIC
@ RS_DELTA_MAGIC
A delta file.
Definition: librsync.h:74
rs_driven_cb
rs_result rs_driven_cb(rs_job_t *job, rs_buffers_t *buf, void *opaque)
Type of application-supplied function for rs_job_drive().
Definition: librsync.h:368
RS_UNIMPLEMENTED
@ RS_UNIMPLEMENTED
Author is lazy.
Definition: librsync.h:178
rs_inbuflen
int rs_inbuflen
Buffer sizes for file IO.
Definition: whole.c:52
RS_LOG_DEBUG
@ RS_LOG_DEBUG
Debug-level messages.
Definition: librsync.h:108
rs_loadsig_begin
rs_job_t * rs_loadsig_begin(rs_signature_t **)
Read a signature from a file into an rs_signature structure in memory.
Definition: readsums.c:140
rs_stats::lit_cmds
int lit_cmds
Number of literal commands.
Definition: librsync.h:194
rs_job::stats
rs_stats_t stats
Encoding statistics.
Definition: job.h:72
rs_log_stats
int rs_log_stats(rs_stats_t const *stats)
Write statistics into the current log as text.
Definition: stats.c:40
RS_LOG_INFO
@ RS_LOG_INFO
Informational.
Definition: librsync.h:107
rs_stats::lit_bytes
rs_long_t lit_bytes
Number of literal bytes.
Definition: librsync.h:195
rs_loglevel
rs_loglevel
Log severity levels.
Definition: librsync.h:100
rs_stats_t
struct rs_stats rs_stats_t
Performance statistics from a librsync encoding or decoding operation.
RS_CORRUPT
@ RS_CORRUPT
Unbelievable value in stream.
Definition: librsync.h:179
rs_patch_begin
rs_job_t * rs_patch_begin(rs_copy_cb *copy_cb, void *copy_arg)
Apply a delta to a basis file to recreate the new file.
Definition: patch.c:256
rs_trace_stderr
void rs_trace_stderr(rs_loglevel level, char const *msg)
Default trace callback that writes to stderr.
rs_job_free
rs_result rs_job_free(rs_job_t *)
Deallocate job state.
Definition: job.c:69
rs_delta_begin
rs_job_t * rs_delta_begin(rs_signature_t *)
Prepare to compute a streaming delta.
Definition: delta.c:404
rs_buffers_s::eof_in
int eof_in
True if there is no more data after this.
Definition: librsync.h:317
RS_BLOCKED
@ RS_BLOCKED
Blocked waiting for more data.
Definition: librsync.h:163
RS_TEST_SKIPPED
@ RS_TEST_SKIPPED
Test neither passed or failed.
Definition: librsync.h:167
rs_sig_file
rs_result rs_sig_file(FILE *old_file, FILE *sig_file, size_t block_len, size_t strong_len, rs_magic_number sig_magic, rs_stats_t *stats)
Generate the signature of a basis file, and write it out to another.
Definition: whole.c:93
rs_signature
Signature of a whole file.
Definition: sumset.h:37
RS_MD4_SIG_MAGIC
@ RS_MD4_SIG_MAGIC
A signature file with MD4 signatures.
Definition: librsync.h:85
rs_mdfour_update
void rs_mdfour_update(rs_mdfour_t *md, void const *in_void, size_t n)
Feed some data into the MD4 accumulator.
Definition: mdfour.c:292
rs_trace_to
void rs_trace_to(rs_trace_fn_t *)
Set trace callback.
Definition: trace.c:79
RS_IO_ERROR
@ RS_IO_ERROR
Error in file or network IO.
Definition: librsync.h:168
rs_licence_string
const char rs_licence_string[]
Summary of the licence for librsync.
rs_delta_file
rs_result rs_delta_file(rs_signature_t *, FILE *new_file, FILE *delta_file, rs_stats_t *)
Generate a delta between a signature and a new file into a delta file.
Definition: whole.c:129
rs_mdfour_t
struct rs_mdfour rs_mdfour_t
MD4 message-digest accumulator.
Definition: librsync.h:219
rs_buffers_s::next_out
char * next_out
Next output byte should be put there.
Definition: librsync.h:323
rs_buffers_s::avail_out
size_t avail_out
Remaining free space at next_out.
Definition: librsync.h:329
RS_LOG_NOTICE
@ RS_LOG_NOTICE
Normal but significant condition.
Definition: librsync.h:106
rs_patch_file
rs_result rs_patch_file(FILE *basis_file, FILE *delta_file, FILE *new_file, rs_stats_t *)
Apply a patch, relative to a basis, into a new file.
Definition: whole.c:145
rs_copy_cb
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:430
rs_supports_trace
int rs_supports_trace(void)
Check whether the library was compiled with debugging trace.
Definition: trace.c:171
RS_BLAKE2_SIG_MAGIC
@ RS_BLAKE2_SIG_MAGIC
A signature file using the BLAKE2 hash.
Definition: librsync.h:92
rs_free_sumset
void rs_free_sumset(rs_signature_t *)
Deep deallocation of checksums.
Definition: sumset.c:241
rs_stats
Performance statistics from a librsync encoding or decoding operation.
Definition: librsync.h:191
RS_BAD_MAGIC
@ RS_BAD_MAGIC
Bad magic number at start of stream.
Definition: librsync.h:174
rs_magic_number
rs_magic_number
A uint32 magic number, emitted in bigendian/network order at the start of librsync files.
Definition: librsync.h:68
rs_loadsig_file
rs_result rs_loadsig_file(FILE *sig_file, rs_signature_t **sumset, rs_stats_t *stats)
Load signatures from a signature file into memory.
Definition: whole.c:111
rs_job::copy_cb
rs_copy_cb * copy_cb
Callback used to copy data from the basis into the output.
Definition: job.h:95
rs_stats::lit_cmdbytes
rs_long_t lit_cmdbytes
Number of bytes used in literal command headers.
Definition: librsync.h:196
RS_SYNTAX_ERROR
@ RS_SYNTAX_ERROR
Command line syntax error.
Definition: librsync.h:169
rs_sumset_dump
void rs_sumset_dump(rs_signature_t const *)
Dump signatures to the log.
Definition: sumset.c:247
rs_buffers_s
Description of input and output buffers.
Definition: librsync.h:300
rs_unbase64
size_t rs_unbase64(char *s)
Decode a base64 buffer in place.
Definition: base64.c:33