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