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