38# include "librsync_export.h"
49typedef uint8_t rs_byte_t;
50typedef intmax_t rs_long_t;
166LIBRSYNC_EXPORT
void rs_hexify(
char *to_buf,
void const *from_buf,
175LIBRSYNC_EXPORT
void rs_base64(
unsigned char const *buf,
int n,
char *out);
218 rs_long_t copy_cmds, copy_bytes, copy_cmdbytes;
219 rs_long_t sig_cmds, sig_bytes;
238LIBRSYNC_EXPORT
extern const int RS_MD4_SUM_LENGTH, RS_BLAKE2_SUM_LENGTH;
240# define RS_MAX_STRONG_SUM_LENGTH 32
242typedef uint32_t rs_weak_sum_t;
243typedef unsigned char rs_strong_sum_t[RS_MAX_STRONG_SUM_LENGTH];
245LIBRSYNC_EXPORT
void rs_mdfour(
unsigned char *out,
void const *in,
size_t);
246LIBRSYNC_EXPORT
void rs_mdfour_begin(
rs_mdfour_t *md);
257LIBRSYNC_EXPORT
void rs_mdfour_result(
rs_mdfour_t *md,
unsigned char *out);
367# define RS_DEFAULT_BLOCK_LEN 2048
373# define RS_DEFAULT_MIN_STRONG_LEN 12
446 size_t *block_len,
size_t *strong_len);
523# ifndef RSYNC_NO_STDIO_INTERFACE
536LIBRSYNC_EXPORT FILE *
rs_file_open(
char const *filename,
char const *mode,
564LIBRSYNC_EXPORT
extern int rs_inbuflen, rs_outbuflen;
589 size_t block_len,
size_t strong_len,
LIBRSYNC_EXPORT void rs_trace_to(rs_trace_fn_t *)
Set trace callback.
LIBRSYNC_EXPORT 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.
LIBRSYNC_EXPORT rs_result rs_build_hash_table(rs_signature_t *sums)
Call this after loading a signature to index it.
LIBRSYNC_EXPORT void rs_base64(unsigned char const *buf, int n, char *out)
Encode a buffer as base64.
LIBRSYNC_EXPORT rs_job_t * rs_sig_begin(size_t block_len, size_t strong_len, rs_magic_number sig_magic)
Start generating a signature.
LIBRSYNC_EXPORT int rs_file_close(FILE *file)
Close a file with special handling for stdin or stdout.
LIBRSYNC_EXPORT rs_result rs_job_free(rs_job_t *)
Deallocate job state.
LIBRSYNC_EXPORT 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.
LIBRSYNC_EXPORT FILE * rs_file_open(char const *filename, char const *mode, int force)
Open a file with special handling for stdin or stdout.
LIBRSYNC_EXPORT void rs_signature_log_stats(rs_signature_t const *sig)
Log the rs_signature_delta match stats.
LIBRSYNC_EXPORT rs_result rs_sig_args(rs_long_t old_fsize, rs_magic_number *magic, size_t *block_len, size_t *strong_len)
Get or check signature arguments for a given file size.
LIBRSYNC_EXPORT size_t rs_unbase64(char *s)
Decode a base64 buffer in place.
LIBRSYNC_EXPORT int rs_supports_trace(void)
Check whether the library was compiled with debugging trace.
LIBRSYNC_EXPORT void rs_mdfour_update(rs_mdfour_t *md, void const *in_void, size_t n)
Feed some data into the MD4 accumulator.
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.
LIBRSYNC_EXPORT rs_long_t rs_file_size(FILE *file)
Get the size of a file.
struct rs_stats rs_stats_t
Performance statistics from a librsync encoding or decoding operation.
LIBRSYNC_EXPORT rs_job_t * rs_loadsig_begin(rs_signature_t **)
Read a signature from a file into an rs_signature structure in memory.
LIBRSYNC_EXPORT void rs_trace_stderr(rs_loglevel level, char const *msg)
Default trace callback that writes to stderr.
LIBRSYNC_EXPORT 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.
LIBRSYNC_EXPORT rs_result rs_loadsig_file(FILE *sig_file, rs_signature_t **sumset, rs_stats_t *stats)
Load signatures from a signature file into memory.
LIBRSYNC_EXPORT rs_job_t * rs_delta_begin(rs_signature_t *)
Prepare to compute a streaming delta.
void rs_trace_fn_t(rs_loglevel level, char const *msg)
Callback to write out log messages.
LIBRSYNC_EXPORT 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.
rs_result
Return codes from nonblocking rsync operations.
@ RS_TEST_SKIPPED
Test neither passed or failed.
@ RS_MEM_ERROR
Out of memory.
@ RS_RUNNING
The job is still running, and not yet finished or blocked.
@ RS_UNIMPLEMENTED
Author is lazy.
@ RS_DONE
Completed successfully.
@ RS_PARAM_ERROR
Bad value passed in to library, probably an application bug.
@ RS_CORRUPT
Unbelievable value in stream.
@ RS_INPUT_ENDED
Unexpected end of input file, perhaps due to a truncated file or dropped network connection.
@ RS_SYNTAX_ERROR
Command line syntax error.
@ RS_BAD_MAGIC
Bad magic number at start of stream.
@ RS_INTERNAL_ERROR
Probably a library bug.
@ RS_BLOCKED
Blocked waiting for more data.
@ RS_IO_ERROR
Error in file or network IO.
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.
rs_loglevel
Log severity levels.
@ RS_LOG_EMERG
System is unusable.
@ RS_LOG_DEBUG
Debug-level messages.
@ RS_LOG_ERR
Error conditions.
@ RS_LOG_NOTICE
Normal but significant condition.
@ RS_LOG_WARNING
Warning conditions.
@ RS_LOG_ALERT
Action must be taken immediately.
@ RS_LOG_CRIT
Critical conditions.
@ RS_LOG_INFO
Informational.
rs_magic_number
A uint32 magic number, emitted in bigendian/network order at the start of librsync files.
@ RS_BLAKE2_SIG_MAGIC
A signature file using the BLAKE2 hash.
@ RS_MD4_SIG_MAGIC
A signature file with MD4 signatures.
@ RS_DELTA_MAGIC
A delta file.
@ RS_RK_BLAKE2_SIG_MAGIC
A signature file with RabinKarp rollsum and BLAKE2 hash.
@ RS_RK_MD4_SIG_MAGIC
A signature file with RabinKarp rollsum and MD4 hash.
LIBRSYNC_EXPORT 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.
LIBRSYNC_EXPORT void rs_sumset_dump(rs_signature_t const *)
Dump signatures to the log.
LIBRSYNC_EXPORT int rs_log_stats(rs_stats_t const *stats)
Write statistics into the current log as text.
LIBRSYNC_EXPORT int rs_inbuflen
Buffer sizes for file IO.
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 void rs_trace_set_level(rs_loglevel level)
Set the least important message severity that will be output.
LIBRSYNC_EXPORT char const rs_librsync_version[]
Library version string.
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).
LIBRSYNC_EXPORT char * rs_format_stats(rs_stats_t const *stats, char *buf, size_t size)
Return a human-readable representation of statistics.
LIBRSYNC_EXPORT 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...
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.
Description of input and output buffers.
char * next_in
Next input byte.
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.
char * next_out
Next output byte should be put there.
The contents of this structure are private.
rs_copy_cb * copy_cb
Callback used to copy data from the basis into the output.
rs_stats_t stats
Encoding statistics.
The rs_mdfour state type.
Signature of a whole file.
Performance statistics from a librsync encoding or decoding operation.
int lit_cmds
Number of literal commands.
rs_long_t lit_cmdbytes
Number of bytes used in literal command headers.
char const * op
Human-readable name of current operation.
rs_long_t sig_blocks
Number of blocks described by the signature.
rs_long_t out_bytes
Total bytes written to output.
rs_long_t lit_bytes
Number of literal bytes.
rs_long_t in_bytes
Total bytes read from input.