\doxysubsection{librsync.\+h}
\label{librsync_8h_source}\index{librsync.h@{librsync.h}}
\mbox{\hyperlink{librsync_8h}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001 \textcolor{comment}{/*= -\/*-\/ c-\/basic-\/offset: 4; indent-\/tabs-\/mode: nil; -\/*-\/}}
\DoxyCodeLine{00002 \textcolor{comment}{ *}}
\DoxyCodeLine{00003 \textcolor{comment}{ * librsync -\/-\/ library for network deltas}}
\DoxyCodeLine{00004 \textcolor{comment}{ *}}
\DoxyCodeLine{00005 \textcolor{comment}{ * Copyright 2000, 2001, 2014, 2015 by Martin Pool <mbp@sourcefrog.net>}}
\DoxyCodeLine{00006 \textcolor{comment}{ * Copyright (C) 2003 by Donovan Baarda <abo@minkirri.apana.org.au>}}
\DoxyCodeLine{00007 \textcolor{comment}{ *}}
\DoxyCodeLine{00008 \textcolor{comment}{ * This program is free software; you can redistribute it and/or modify}}
\DoxyCodeLine{00009 \textcolor{comment}{ * it under the terms of the GNU Lesser General Public License as published by}}
\DoxyCodeLine{00010 \textcolor{comment}{ * the Free Software Foundation; either version 2.1 of the License, or}}
\DoxyCodeLine{00011 \textcolor{comment}{ * (at your option) any later version.}}
\DoxyCodeLine{00012 \textcolor{comment}{ *}}
\DoxyCodeLine{00013 \textcolor{comment}{ * This program is distributed in the hope that it will be useful,}}
\DoxyCodeLine{00014 \textcolor{comment}{ * but WITHOUT ANY WARRANTY; without even the implied warranty of}}
\DoxyCodeLine{00015 \textcolor{comment}{ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the}}
\DoxyCodeLine{00016 \textcolor{comment}{ * GNU Lesser General Public License for more details.}}
\DoxyCodeLine{00017 \textcolor{comment}{ *}}
\DoxyCodeLine{00018 \textcolor{comment}{ * You should have received a copy of the GNU Lesser General Public License}}
\DoxyCodeLine{00019 \textcolor{comment}{ * along with this program; if not, write to the Free Software}}
\DoxyCodeLine{00020 \textcolor{comment}{ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.}}
\DoxyCodeLine{00021 \textcolor{comment}{ */}}
\DoxyCodeLine{00022 }
\DoxyCodeLine{00023                               \textcolor{comment}{/*=}}
\DoxyCodeLine{00024 \textcolor{comment}{                               | You should never wear your best}}
\DoxyCodeLine{00025 \textcolor{comment}{                               | trousers when you go out to fight for}}
\DoxyCodeLine{00026 \textcolor{comment}{                               | freedom and liberty.}}
\DoxyCodeLine{00027 \textcolor{comment}{                               |        -\/-\/ Henrik Ibsen}}
\DoxyCodeLine{00028 \textcolor{comment}{                               */}}
\DoxyCodeLine{00029 \textcolor{comment}{}}
\DoxyCodeLine{00030 \textcolor{comment}{/** \(\backslash\)file librsync.h}}
\DoxyCodeLine{00031 \textcolor{comment}{ * Public header for librsync. */}}
\DoxyCodeLine{00032 \textcolor{preprocessor}{\#ifndef LIBRSYNC\_H}}
\DoxyCodeLine{00033 \textcolor{preprocessor}{\#  define LIBRSYNC\_H}}
\DoxyCodeLine{00034 }
\DoxyCodeLine{00035 \textcolor{preprocessor}{\#  include <stdio.h>}}
\DoxyCodeLine{00036 \textcolor{preprocessor}{\#  include <stdint.h>}}
\DoxyCodeLine{00037 \textcolor{preprocessor}{\#  include <time.h>}}
\DoxyCodeLine{00038 \textcolor{preprocessor}{\#  include "{}librsync\_export.h"{}}}
\DoxyCodeLine{00039 }
\DoxyCodeLine{00040 \textcolor{preprocessor}{\#  ifdef \_\_cplusplus}}
\DoxyCodeLine{00041 \textcolor{keyword}{extern} \textcolor{stringliteral}{"{}C"{}} \{}
\DoxyCodeLine{00042 \textcolor{preprocessor}{\#  endif}}
\DoxyCodeLine{00043 \textcolor{comment}{}}
\DoxyCodeLine{00044 \textcolor{comment}{/** Library version string.}}
\DoxyCodeLine{00045 \textcolor{comment}{ *}}
\DoxyCodeLine{00046 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref page\_versioning */}}
\DoxyCodeLine{00047 LIBRSYNC\_EXPORT \textcolor{keyword}{extern} \textcolor{keywordtype}{char} \textcolor{keyword}{const} rs\_librsync\_version[];}
\DoxyCodeLine{00048 }
\DoxyCodeLine{00049 \textcolor{keyword}{typedef} uint8\_t rs\_byte\_t;}
\DoxyCodeLine{00050 \textcolor{keyword}{typedef} intmax\_t rs\_long\_t;}
\DoxyCodeLine{00051 }
\DoxyCodeLine{00052                           \textcolor{comment}{/*=}}
\DoxyCodeLine{00053 \textcolor{comment}{                           | "{}The IETF already has more than enough}}
\DoxyCodeLine{00054 \textcolor{comment}{                           | RFCs that codify the obvious, make}}
\DoxyCodeLine{00055 \textcolor{comment}{                           | stupidity illegal, support truth,}}
\DoxyCodeLine{00056 \textcolor{comment}{                           | justice, and the IETF way, and generally}}
\DoxyCodeLine{00057 \textcolor{comment}{                           | demonstrate the author is a brilliant and}}
\DoxyCodeLine{00058 \textcolor{comment}{                           | valuable Contributor to The Standards}}
\DoxyCodeLine{00059 \textcolor{comment}{                           | Process."{}}}
\DoxyCodeLine{00060 \textcolor{comment}{                           |     -\/-\/ Vernon Schryver}}
\DoxyCodeLine{00061 \textcolor{comment}{                           */}}
\DoxyCodeLine{00062 \textcolor{comment}{}}
\DoxyCodeLine{00063 \textcolor{comment}{/** A uint32 magic number, emitted in bigendian/network order at the start of}}
\DoxyCodeLine{00064 \textcolor{comment}{ * librsync files. */}}
\DoxyCodeLine{00065 \textcolor{keyword}{typedef} \textcolor{keyword}{enum} \{\textcolor{comment}{}}
\DoxyCodeLine{00066 \textcolor{comment}{    /** A delta file.}}
\DoxyCodeLine{00067 \textcolor{comment}{     *}}
\DoxyCodeLine{00068 \textcolor{comment}{     * At present, there's only one delta format.}}
\DoxyCodeLine{00069 \textcolor{comment}{     *}}
\DoxyCodeLine{00070 \textcolor{comment}{     * The four-\/byte literal \(\backslash\)c "{}rs\(\backslash\)x026"{}. */}}
\DoxyCodeLine{00071     RS\_DELTA\_MAGIC = 0x72730236,}
\DoxyCodeLine{00072 \textcolor{comment}{}}
\DoxyCodeLine{00073 \textcolor{comment}{    /** A signature file with MD4 signatures.}}
\DoxyCodeLine{00074 \textcolor{comment}{     *}}
\DoxyCodeLine{00075 \textcolor{comment}{     * Backward compatible with librsync < 1.0, but strongly deprecated because}}
\DoxyCodeLine{00076 \textcolor{comment}{     * it creates a security vulnerability on files containing partly untrusted}}
\DoxyCodeLine{00077 \textcolor{comment}{     * data. See <https://github.com/librsync/librsync/issues/5>.}}
\DoxyCodeLine{00078 \textcolor{comment}{     *}}
\DoxyCodeLine{00079 \textcolor{comment}{     * The four-\/byte literal \(\backslash\)c "{}rs\(\backslash\)x016"{}.}}
\DoxyCodeLine{00080 \textcolor{comment}{     *}}
\DoxyCodeLine{00081 \textcolor{comment}{     * \(\backslash\)sa rs\_sig\_begin() */}}
\DoxyCodeLine{00082     RS\_MD4\_SIG\_MAGIC = 0x72730136,}
\DoxyCodeLine{00083 \textcolor{comment}{}}
\DoxyCodeLine{00084 \textcolor{comment}{    /** A signature file using the BLAKE2 hash. Supported from librsync 1.0.}}
\DoxyCodeLine{00085 \textcolor{comment}{     *}}
\DoxyCodeLine{00086 \textcolor{comment}{     * The four-\/byte literal \(\backslash\)c "{}rs\(\backslash\)x017"{}.}}
\DoxyCodeLine{00087 \textcolor{comment}{     *}}
\DoxyCodeLine{00088 \textcolor{comment}{     * \(\backslash\)sa rs\_sig\_begin() */}}
\DoxyCodeLine{00089     RS\_BLAKE2\_SIG\_MAGIC = 0x72730137,}
\DoxyCodeLine{00090 \textcolor{comment}{}}
\DoxyCodeLine{00091 \textcolor{comment}{    /** A signature file with RabinKarp rollsum and MD4 hash.}}
\DoxyCodeLine{00092 \textcolor{comment}{     *}}
\DoxyCodeLine{00093 \textcolor{comment}{     * Uses a faster/safer rollsum, but still strongly discouraged because of}}
\DoxyCodeLine{00094 \textcolor{comment}{     * MD4's security vulnerability. Supported since librsync 2.2.0.}}
\DoxyCodeLine{00095 \textcolor{comment}{     *}}
\DoxyCodeLine{00096 \textcolor{comment}{     * The four-\/byte literal \(\backslash\)c "{}rs\(\backslash\)x01F"{}.}}
\DoxyCodeLine{00097 \textcolor{comment}{     *}}
\DoxyCodeLine{00098 \textcolor{comment}{     * \(\backslash\)sa rs\_sig\_begin() */}}
\DoxyCodeLine{00099     RS\_RK\_MD4\_SIG\_MAGIC = 0x72730146,}
\DoxyCodeLine{00100 \textcolor{comment}{}}
\DoxyCodeLine{00101 \textcolor{comment}{    /** A signature file with RabinKarp rollsum and BLAKE2 hash.}}
\DoxyCodeLine{00102 \textcolor{comment}{     *}}
\DoxyCodeLine{00103 \textcolor{comment}{     * Uses a faster/safer rollsum together with the safer BLAKE2 hash. This is}}
\DoxyCodeLine{00104 \textcolor{comment}{     * the recommended default supported since librsync 2.2.0.}}
\DoxyCodeLine{00105 \textcolor{comment}{     *}}
\DoxyCodeLine{00106 \textcolor{comment}{     * The four-\/byte literal \(\backslash\)c "{}rs\(\backslash\)x01G"{}.}}
\DoxyCodeLine{00107 \textcolor{comment}{     *}}
\DoxyCodeLine{00108 \textcolor{comment}{     * \(\backslash\)sa rs\_sig\_begin() */}}
\DoxyCodeLine{00109     RS\_RK\_BLAKE2\_SIG\_MAGIC = 0x72730147,}
\DoxyCodeLine{00110 }
\DoxyCodeLine{00111 \} rs\_magic\_number;}
\DoxyCodeLine{00112 \textcolor{comment}{}}
\DoxyCodeLine{00113 \textcolor{comment}{/** Log severity levels.}}
\DoxyCodeLine{00114 \textcolor{comment}{ *}}
\DoxyCodeLine{00115 \textcolor{comment}{ * These are the same as syslog, at least in glibc.}}
\DoxyCodeLine{00116 \textcolor{comment}{ *}}
\DoxyCodeLine{00117 \textcolor{comment}{ * \(\backslash\)sa rs\_trace\_set\_level() \(\backslash\)sa \(\backslash\)ref api\_trace */}}
\DoxyCodeLine{00118 \textcolor{keyword}{typedef} \textcolor{keyword}{enum} \{}
\DoxyCodeLine{00119     RS\_LOG\_EMERG = 0,           \textcolor{comment}{/**< System is unusable */}}
\DoxyCodeLine{00120     RS\_LOG\_ALERT = 1,           \textcolor{comment}{/**< Action must be taken immediately */}}
\DoxyCodeLine{00121     RS\_LOG\_CRIT = 2,            \textcolor{comment}{/**< Critical conditions */}}
\DoxyCodeLine{00122     RS\_LOG\_ERR = 3,             \textcolor{comment}{/**< Error conditions */}}
\DoxyCodeLine{00123     RS\_LOG\_WARNING = 4,         \textcolor{comment}{/**< Warning conditions */}}
\DoxyCodeLine{00124     RS\_LOG\_NOTICE = 5,          \textcolor{comment}{/**< Normal but significant condition */}}
\DoxyCodeLine{00125     RS\_LOG\_INFO = 6,            \textcolor{comment}{/**< Informational */}}
\DoxyCodeLine{00126     RS\_LOG\_DEBUG = 7            \textcolor{comment}{/**< Debug-\/level messages */}}
\DoxyCodeLine{00127 \} rs\_loglevel;}
\DoxyCodeLine{00128 \textcolor{comment}{}}
\DoxyCodeLine{00129 \textcolor{comment}{/** Callback to write out log messages.}}
\DoxyCodeLine{00130 \textcolor{comment}{ *}}
\DoxyCodeLine{00131 \textcolor{comment}{ * \(\backslash\)param level a syslog level.}}
\DoxyCodeLine{00132 \textcolor{comment}{ *}}
\DoxyCodeLine{00133 \textcolor{comment}{ * \(\backslash\)param msg message to be logged.}}
\DoxyCodeLine{00134 \textcolor{comment}{ *}}
\DoxyCodeLine{00135 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_trace */}}
\DoxyCodeLine{00136 \textcolor{keyword}{typedef} \textcolor{keywordtype}{void} rs\_trace\_fn\_t(rs\_loglevel level, \textcolor{keywordtype}{char} \textcolor{keyword}{const} *msg);}
\DoxyCodeLine{00137 \textcolor{comment}{}}
\DoxyCodeLine{00138 \textcolor{comment}{/** Set the least important message severity that will be output.}}
\DoxyCodeLine{00139 \textcolor{comment}{ *}}
\DoxyCodeLine{00140 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_trace */}}
\DoxyCodeLine{00141 LIBRSYNC\_EXPORT \textcolor{keywordtype}{void} rs\_trace\_set\_level(rs\_loglevel level);}
\DoxyCodeLine{00142 \textcolor{comment}{}}
\DoxyCodeLine{00143 \textcolor{comment}{/** Set trace callback.}}
\DoxyCodeLine{00144 \textcolor{comment}{ *}}
\DoxyCodeLine{00145 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_trace */}}
\DoxyCodeLine{00146 LIBRSYNC\_EXPORT \textcolor{keywordtype}{void} rs\_trace\_to(rs\_trace\_fn\_t *);}
\DoxyCodeLine{00147 \textcolor{comment}{}}
\DoxyCodeLine{00148 \textcolor{comment}{/** Default trace callback that writes to stderr.}}
\DoxyCodeLine{00149 \textcolor{comment}{ *}}
\DoxyCodeLine{00150 \textcolor{comment}{ * Implements ::rs\_trace\_fn\_t, and may be passed to rs\_trace\_to().}}
\DoxyCodeLine{00151 \textcolor{comment}{ *}}
\DoxyCodeLine{00152 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_trace */}}
\DoxyCodeLine{00153 LIBRSYNC\_EXPORT \textcolor{keywordtype}{void} rs\_trace\_stderr(rs\_loglevel level, \textcolor{keywordtype}{char} \textcolor{keyword}{const} *msg);}
\DoxyCodeLine{00154 \textcolor{comment}{}}
\DoxyCodeLine{00155 \textcolor{comment}{/** Check whether the library was compiled with debugging trace.}}
\DoxyCodeLine{00156 \textcolor{comment}{ *}}
\DoxyCodeLine{00157 \textcolor{comment}{ * \(\backslash\)returns True if the library contains trace code; otherwise false.}}
\DoxyCodeLine{00158 \textcolor{comment}{ *}}
\DoxyCodeLine{00159 \textcolor{comment}{ * If this returns false, then trying to turn trace on will achieve nothing.}}
\DoxyCodeLine{00160 \textcolor{comment}{ *}}
\DoxyCodeLine{00161 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_trace */}}
\DoxyCodeLine{00162 LIBRSYNC\_EXPORT \textcolor{keywordtype}{int} rs\_supports\_trace(\textcolor{keywordtype}{void});}
\DoxyCodeLine{00163 \textcolor{comment}{}}
\DoxyCodeLine{00164 \textcolor{comment}{/** Convert \(\backslash\)p from\_len bytes at \(\backslash\)p from\_buf into a hex representation in \(\backslash\)p}}
\DoxyCodeLine{00165 \textcolor{comment}{ * to\_buf, which must be twice as long plus one byte for the null terminator. */}}
\DoxyCodeLine{00166 LIBRSYNC\_EXPORT \textcolor{keywordtype}{void} rs\_hexify(\textcolor{keywordtype}{char} *to\_buf, \textcolor{keywordtype}{void} \textcolor{keyword}{const} *from\_buf,}
\DoxyCodeLine{00167                                \textcolor{keywordtype}{int} from\_len);}
\DoxyCodeLine{00168 \textcolor{comment}{}}
\DoxyCodeLine{00169 \textcolor{comment}{/** Decode a base64 buffer in place.}}
\DoxyCodeLine{00170 \textcolor{comment}{ *}}
\DoxyCodeLine{00171 \textcolor{comment}{ * \(\backslash\)returns The number of binary bytes. */}}
\DoxyCodeLine{00172 LIBRSYNC\_EXPORT \textcolor{keywordtype}{size\_t} rs\_unbase64(\textcolor{keywordtype}{char} *s);}
\DoxyCodeLine{00173 \textcolor{comment}{}}
\DoxyCodeLine{00174 \textcolor{comment}{/** Encode a buffer as base64. */}}
\DoxyCodeLine{00175 LIBRSYNC\_EXPORT \textcolor{keywordtype}{void} rs\_base64(\textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{char} \textcolor{keyword}{const} *buf, \textcolor{keywordtype}{int} n, \textcolor{keywordtype}{char} *out);}
\DoxyCodeLine{00176 \textcolor{comment}{}}
\DoxyCodeLine{00177 \textcolor{comment}{/** Return codes from nonblocking rsync operations.}}
\DoxyCodeLine{00178 \textcolor{comment}{ *}}
\DoxyCodeLine{00179 \textcolor{comment}{ * \(\backslash\)sa rs\_strerror() \(\backslash\)sa api\_callbacks */}}
\DoxyCodeLine{00180 \textcolor{keyword}{typedef} \textcolor{keyword}{enum} rs\_result \{}
\DoxyCodeLine{00181     RS\_DONE = 0,                \textcolor{comment}{/**< Completed successfully. */}}
\DoxyCodeLine{00182     RS\_BLOCKED = 1,             \textcolor{comment}{/**< Blocked waiting for more data. */}}
\DoxyCodeLine{00183     RS\_RUNNING = 2,             \textcolor{comment}{/**< The job is still running, and not yet}}
\DoxyCodeLine{00184 \textcolor{comment}{                                 * finished or blocked. (This value should}}
\DoxyCodeLine{00185 \textcolor{comment}{                                 * never be seen by the application.) */}}
\DoxyCodeLine{00186     RS\_TEST\_SKIPPED = 77,       \textcolor{comment}{/**< Test neither passed or failed. */}}
\DoxyCodeLine{00187     RS\_IO\_ERROR = 100,          \textcolor{comment}{/**< Error in file or network IO. */}}
\DoxyCodeLine{00188     RS\_SYNTAX\_ERROR = 101,      \textcolor{comment}{/**< Command line syntax error. */}}
\DoxyCodeLine{00189     RS\_MEM\_ERROR = 102,         \textcolor{comment}{/**< Out of memory. */}}
\DoxyCodeLine{00190     RS\_INPUT\_ENDED = 103,       \textcolor{comment}{/**< Unexpected end of input file, perhaps due}}
\DoxyCodeLine{00191 \textcolor{comment}{                                 * to a truncated file or dropped network}}
\DoxyCodeLine{00192 \textcolor{comment}{                                 * connection. */}}
\DoxyCodeLine{00193     RS\_BAD\_MAGIC = 104,         \textcolor{comment}{/**< Bad magic number at start of stream.}}
\DoxyCodeLine{00194 \textcolor{comment}{                                 * Probably not a librsync file, or possibly}}
\DoxyCodeLine{00195 \textcolor{comment}{                                 * the wrong kind of file or from an}}
\DoxyCodeLine{00196 \textcolor{comment}{                                 * incompatible library version. */}}
\DoxyCodeLine{00197     RS\_UNIMPLEMENTED = 105,     \textcolor{comment}{/**< Author is lazy. */}}
\DoxyCodeLine{00198     RS\_CORRUPT = 106,           \textcolor{comment}{/**< Unbelievable value in stream. */}}
\DoxyCodeLine{00199     RS\_INTERNAL\_ERROR = 107,    \textcolor{comment}{/**< Probably a library bug. */}}
\DoxyCodeLine{00200     RS\_PARAM\_ERROR = 108        \textcolor{comment}{/**< Bad value passed in to library, probably}}
\DoxyCodeLine{00201 \textcolor{comment}{                                 * an application bug. */}}
\DoxyCodeLine{00202 \} rs\_result;}
\DoxyCodeLine{00203 \textcolor{comment}{}}
\DoxyCodeLine{00204 \textcolor{comment}{/** Return an English description of a ::rs\_result value. */}}
\DoxyCodeLine{00205 LIBRSYNC\_EXPORT \textcolor{keywordtype}{char} \textcolor{keyword}{const} *rs\_strerror(rs\_result r);}
\DoxyCodeLine{00206 \textcolor{comment}{}}
\DoxyCodeLine{00207 \textcolor{comment}{/** Performance statistics from a librsync encoding or decoding operation.}}
\DoxyCodeLine{00208 \textcolor{comment}{ *}}
\DoxyCodeLine{00209 \textcolor{comment}{ * \(\backslash\)sa api\_stats \(\backslash\)sa rs\_format\_stats() \(\backslash\)sa rs\_log\_stats() */}}
\DoxyCodeLine{00210 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }rs\_stats \{}
\DoxyCodeLine{00211     \textcolor{keywordtype}{char} \textcolor{keyword}{const} *op;             \textcolor{comment}{/**< Human-\/readable name of current operation.}}
\DoxyCodeLine{00212 \textcolor{comment}{                                 * For example, "{}delta"{}. */}}
\DoxyCodeLine{00213     \textcolor{keywordtype}{int} lit\_cmds;               \textcolor{comment}{/**< Number of literal commands. */}}
\DoxyCodeLine{00214     rs\_long\_t lit\_bytes;        \textcolor{comment}{/**< Number of literal bytes. */}}
\DoxyCodeLine{00215     rs\_long\_t lit\_cmdbytes;     \textcolor{comment}{/**< Number of bytes used in literal command}}
\DoxyCodeLine{00216 \textcolor{comment}{                                 * headers. */}}
\DoxyCodeLine{00217 }
\DoxyCodeLine{00218     rs\_long\_t copy\_cmds, copy\_bytes, copy\_cmdbytes;}
\DoxyCodeLine{00219     rs\_long\_t sig\_cmds, sig\_bytes;}
\DoxyCodeLine{00220     \textcolor{keywordtype}{int} false\_matches;}
\DoxyCodeLine{00221 }
\DoxyCodeLine{00222     rs\_long\_t sig\_blocks;       \textcolor{comment}{/**< Number of blocks described by the}}
\DoxyCodeLine{00223 \textcolor{comment}{                                 * signature. */}}
\DoxyCodeLine{00224 }
\DoxyCodeLine{00225     \textcolor{keywordtype}{size\_t} block\_len;}
\DoxyCodeLine{00226 }
\DoxyCodeLine{00227     rs\_long\_t in\_bytes;         \textcolor{comment}{/**< Total bytes read from input. */}}
\DoxyCodeLine{00228     rs\_long\_t out\_bytes;        \textcolor{comment}{/**< Total bytes written to output. */}}
\DoxyCodeLine{00229 }
\DoxyCodeLine{00230     time\_t start, end;}
\DoxyCodeLine{00231 \} rs\_stats\_t;}
\DoxyCodeLine{00232 \textcolor{comment}{}}
\DoxyCodeLine{00233 \textcolor{comment}{/** MD4 message-\/digest accumulator.}}
\DoxyCodeLine{00234 \textcolor{comment}{ *}}
\DoxyCodeLine{00235 \textcolor{comment}{ * \(\backslash\)sa rs\_mdfour(), rs\_mdfour\_begin(), rs\_mdfour\_update(), rs\_mdfour\_result() */}}
\DoxyCodeLine{00236 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }rs\_mdfour rs\_mdfour\_t;}
\DoxyCodeLine{00237 }
\DoxyCodeLine{00238 LIBRSYNC\_EXPORT \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keywordtype}{int} RS\_MD4\_SUM\_LENGTH, RS\_BLAKE2\_SUM\_LENGTH;}
\DoxyCodeLine{00239 }
\DoxyCodeLine{00240 \textcolor{preprocessor}{\#  define RS\_MAX\_STRONG\_SUM\_LENGTH 32}}
\DoxyCodeLine{00241 }
\DoxyCodeLine{00242 \textcolor{keyword}{typedef} uint32\_t rs\_weak\_sum\_t;}
\DoxyCodeLine{00243 \textcolor{keyword}{typedef} \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{char} rs\_strong\_sum\_t[RS\_MAX\_STRONG\_SUM\_LENGTH];}
\DoxyCodeLine{00244 }
\DoxyCodeLine{00245 LIBRSYNC\_EXPORT \textcolor{keywordtype}{void} rs\_mdfour(\textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{char} *out, \textcolor{keywordtype}{void} \textcolor{keyword}{const} *in, \textcolor{keywordtype}{size\_t});}
\DoxyCodeLine{00246 LIBRSYNC\_EXPORT \textcolor{keywordtype}{void} rs\_mdfour\_begin( \textcolor{comment}{/* @out@ */} rs\_mdfour\_t *md);}
\DoxyCodeLine{00247 \textcolor{comment}{}}
\DoxyCodeLine{00248 \textcolor{comment}{/** Feed some data into the MD4 accumulator.}}
\DoxyCodeLine{00249 \textcolor{comment}{ *}}
\DoxyCodeLine{00250 \textcolor{comment}{ * \(\backslash\)param md MD4 accumulator.}}
\DoxyCodeLine{00251 \textcolor{comment}{ *}}
\DoxyCodeLine{00252 \textcolor{comment}{ * \(\backslash\)param in\_void Data to add.}}
\DoxyCodeLine{00253 \textcolor{comment}{ *}}
\DoxyCodeLine{00254 \textcolor{comment}{ * \(\backslash\)param n Number of bytes fed in. */}}
\DoxyCodeLine{00255 LIBRSYNC\_EXPORT \textcolor{keywordtype}{void} rs\_mdfour\_update(rs\_mdfour\_t *md, \textcolor{keywordtype}{void} \textcolor{keyword}{const} *in\_void,}
\DoxyCodeLine{00256                                       \textcolor{keywordtype}{size\_t} n);}
\DoxyCodeLine{00257 LIBRSYNC\_EXPORT \textcolor{keywordtype}{void} rs\_mdfour\_result(rs\_mdfour\_t *md, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{char} *out);}
\DoxyCodeLine{00258 \textcolor{comment}{}}
\DoxyCodeLine{00259 \textcolor{comment}{/** Return a human-\/readable representation of statistics.}}
\DoxyCodeLine{00260 \textcolor{comment}{ *}}
\DoxyCodeLine{00261 \textcolor{comment}{ * The string is truncated if it does not fit. 100 characters should be}}
\DoxyCodeLine{00262 \textcolor{comment}{ * sufficient space.}}
\DoxyCodeLine{00263 \textcolor{comment}{ *}}
\DoxyCodeLine{00264 \textcolor{comment}{ * \(\backslash\)param stats Statistics from an encoding or decoding operation.}}
\DoxyCodeLine{00265 \textcolor{comment}{ *}}
\DoxyCodeLine{00266 \textcolor{comment}{ * \(\backslash\)param buf Buffer to receive result.}}
\DoxyCodeLine{00267 \textcolor{comment}{ *}}
\DoxyCodeLine{00268 \textcolor{comment}{ * \(\backslash\)param size Size of buffer.}}
\DoxyCodeLine{00269 \textcolor{comment}{ *}}
\DoxyCodeLine{00270 \textcolor{comment}{ * \(\backslash\)return \(\backslash\)p buf.}}
\DoxyCodeLine{00271 \textcolor{comment}{ *}}
\DoxyCodeLine{00272 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_stats */}}
\DoxyCodeLine{00273 LIBRSYNC\_EXPORT \textcolor{keywordtype}{char} *rs\_format\_stats(rs\_stats\_t \textcolor{keyword}{const} *stats, \textcolor{keywordtype}{char} *buf,}
\DoxyCodeLine{00274                                       \textcolor{keywordtype}{size\_t} size);}
\DoxyCodeLine{00275 \textcolor{comment}{}}
\DoxyCodeLine{00276 \textcolor{comment}{/** Write statistics into the current log as text.}}
\DoxyCodeLine{00277 \textcolor{comment}{ *}}
\DoxyCodeLine{00278 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_stats \(\backslash\)sa \(\backslash\)ref api\_trace */}}
\DoxyCodeLine{00279 LIBRSYNC\_EXPORT \textcolor{keywordtype}{int} rs\_log\_stats(rs\_stats\_t \textcolor{keyword}{const} *stats);}
\DoxyCodeLine{00280 \textcolor{comment}{}}
\DoxyCodeLine{00281 \textcolor{comment}{/** The signature datastructure type. */}}
\DoxyCodeLine{00282 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }rs\_signature rs\_signature\_t;}
\DoxyCodeLine{00283 \textcolor{comment}{}}
\DoxyCodeLine{00284 \textcolor{comment}{/** Log the rs\_signature\_delta match stats. */}}
\DoxyCodeLine{00285 LIBRSYNC\_EXPORT \textcolor{keywordtype}{void} rs\_signature\_log\_stats(rs\_signature\_t \textcolor{keyword}{const} *sig);}
\DoxyCodeLine{00286 \textcolor{comment}{}}
\DoxyCodeLine{00287 \textcolor{comment}{/** Deep deallocation of checksums. */}}
\DoxyCodeLine{00288 LIBRSYNC\_EXPORT \textcolor{keywordtype}{void} rs\_free\_sumset(rs\_signature\_t *);}
\DoxyCodeLine{00289 \textcolor{comment}{}}
\DoxyCodeLine{00290 \textcolor{comment}{/** Dump signatures to the log. */}}
\DoxyCodeLine{00291 LIBRSYNC\_EXPORT \textcolor{keywordtype}{void} rs\_sumset\_dump(rs\_signature\_t \textcolor{keyword}{const} *);}
\DoxyCodeLine{00292 \textcolor{comment}{}}
\DoxyCodeLine{00293 \textcolor{comment}{/** Description of input and output buffers.}}
\DoxyCodeLine{00294 \textcolor{comment}{ *}}
\DoxyCodeLine{00295 \textcolor{comment}{ * On each call to ::rs\_job\_iter(), the caller can make available}}
\DoxyCodeLine{00296 \textcolor{comment}{ *}}
\DoxyCodeLine{00297 \textcolor{comment}{ * -\/ \#avail\_in bytes of input data at \#next\_in}}
\DoxyCodeLine{00298 \textcolor{comment}{ *}}
\DoxyCodeLine{00299 \textcolor{comment}{ * -\/ \#avail\_out bytes of output space at \#next\_out}}
\DoxyCodeLine{00300 \textcolor{comment}{ *}}
\DoxyCodeLine{00301 \textcolor{comment}{ * -\/ or some of both}}
\DoxyCodeLine{00302 \textcolor{comment}{ *}}
\DoxyCodeLine{00303 \textcolor{comment}{ * Buffers must be allocated and passed in by the caller.}}
\DoxyCodeLine{00304 \textcolor{comment}{ *}}
\DoxyCodeLine{00305 \textcolor{comment}{ * On input, the buffers structure must contain the address and length of the}}
\DoxyCodeLine{00306 \textcolor{comment}{ * input and output buffers. The library updates these values to indicate the}}
\DoxyCodeLine{00307 \textcolor{comment}{ * amount of \(\backslash\)b remaining buffer. So, on return, \#avail\_out is not the amount}}
\DoxyCodeLine{00308 \textcolor{comment}{ * of output data produced, but rather the amount of output buffer space still}}
\DoxyCodeLine{00309 \textcolor{comment}{ * available.}}
\DoxyCodeLine{00310 \textcolor{comment}{ *}}
\DoxyCodeLine{00311 \textcolor{comment}{ * This means that the values on return are consistent with the values on}}
\DoxyCodeLine{00312 \textcolor{comment}{ * entry, and suitable to be passed in on a second call, but they don't}}
\DoxyCodeLine{00313 \textcolor{comment}{ * directly tell you how much output data was produced.}}
\DoxyCodeLine{00314 \textcolor{comment}{ *}}
\DoxyCodeLine{00315 \textcolor{comment}{ * If the input buffer was large enough, it will be processed directly,}}
\DoxyCodeLine{00316 \textcolor{comment}{ * otherwise the data can be copied and accumulated into an internal buffer for}}
\DoxyCodeLine{00317 \textcolor{comment}{ * processing. This means using larger buffers can be much more efficient.}}
\DoxyCodeLine{00318 \textcolor{comment}{ *}}
\DoxyCodeLine{00319 \textcolor{comment}{ * Note also that if \#avail\_in is nonzero on return, then not all of the input}}
\DoxyCodeLine{00320 \textcolor{comment}{ * data has been consumed. This can happen either because it ran out of output}}
\DoxyCodeLine{00321 \textcolor{comment}{ * buffer space, or because it processed as much data as possible directly from}}
\DoxyCodeLine{00322 \textcolor{comment}{ * the input buffer and needs more input to proceed without copying into}}
\DoxyCodeLine{00323 \textcolor{comment}{ * internal buffers. The caller should provide more output buffer space and/or}}
\DoxyCodeLine{00324 \textcolor{comment}{ * pack the remaining input data into another buffer with more input before}}
\DoxyCodeLine{00325 \textcolor{comment}{ * calling rs\_job\_iter() again.}}
\DoxyCodeLine{00326 \textcolor{comment}{ *}}
\DoxyCodeLine{00327 \textcolor{comment}{ * \(\backslash\)sa rs\_job\_iter() */}}
\DoxyCodeLine{00328 \textcolor{keyword}{struct }rs\_buffers\_s \{\textcolor{comment}{}}
\DoxyCodeLine{00329 \textcolor{comment}{    /** Next input byte.}}
\DoxyCodeLine{00330 \textcolor{comment}{     *}}
\DoxyCodeLine{00331 \textcolor{comment}{     * References a pointer which on entry should point to the start of the}}
\DoxyCodeLine{00332 \textcolor{comment}{     * data to be encoded. Updated to point to the byte after the last one}}
\DoxyCodeLine{00333 \textcolor{comment}{     * consumed. */}}
\DoxyCodeLine{00334     \textcolor{keywordtype}{char} *next\_in;}
\DoxyCodeLine{00335 \textcolor{comment}{}}
\DoxyCodeLine{00336 \textcolor{comment}{    /** Number of bytes available at next\_in.}}
\DoxyCodeLine{00337 \textcolor{comment}{     *}}
\DoxyCodeLine{00338 \textcolor{comment}{     * References the length of available input. Updated to be the number of}}
\DoxyCodeLine{00339 \textcolor{comment}{     * unused data bytes, which will be zero if all the input was consumed. May}}
\DoxyCodeLine{00340 \textcolor{comment}{     * be zero if there is no new input, but the caller just wants to drain}}
\DoxyCodeLine{00341 \textcolor{comment}{     * output. */}}
\DoxyCodeLine{00342     \textcolor{keywordtype}{size\_t} avail\_in;}
\DoxyCodeLine{00343 \textcolor{comment}{}}
\DoxyCodeLine{00344 \textcolor{comment}{    /** True if there is no more data after this. */}}
\DoxyCodeLine{00345     \textcolor{keywordtype}{int} eof\_in;}
\DoxyCodeLine{00346 \textcolor{comment}{}}
\DoxyCodeLine{00347 \textcolor{comment}{    /** Next output byte should be put there.}}
\DoxyCodeLine{00348 \textcolor{comment}{     *}}
\DoxyCodeLine{00349 \textcolor{comment}{     * References a pointer which on entry points to the start of the output}}
\DoxyCodeLine{00350 \textcolor{comment}{     * buffer. Updated to point to the byte after the last one filled. */}}
\DoxyCodeLine{00351     \textcolor{keywordtype}{char} *next\_out;}
\DoxyCodeLine{00352 \textcolor{comment}{}}
\DoxyCodeLine{00353 \textcolor{comment}{    /** Remaining free space at next\_out.}}
\DoxyCodeLine{00354 \textcolor{comment}{     *}}
\DoxyCodeLine{00355 \textcolor{comment}{     * References the size of available output buffer. Updated to the size of}}
\DoxyCodeLine{00356 \textcolor{comment}{     * unused output buffer. */}}
\DoxyCodeLine{00357     \textcolor{keywordtype}{size\_t} avail\_out;}
\DoxyCodeLine{00358 \};}
\DoxyCodeLine{00359 \textcolor{comment}{}}
\DoxyCodeLine{00360 \textcolor{comment}{/** \(\backslash\)sa ::rs\_buffers\_s */}}
\DoxyCodeLine{00361 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }rs\_buffers\_s rs\_buffers\_t;}
\DoxyCodeLine{00362 \textcolor{comment}{}}
\DoxyCodeLine{00363 \textcolor{comment}{/** Default block length, if not determined by any other factors.}}
\DoxyCodeLine{00364 \textcolor{comment}{ *}}
\DoxyCodeLine{00365 \textcolor{comment}{ * The 2K default assumes a typical file is about 4MB and should be OK for}}
\DoxyCodeLine{00366 \textcolor{comment}{ * files up to 32G with more than 1GB ram. */}}
\DoxyCodeLine{00367 \textcolor{preprocessor}{\#  define RS\_DEFAULT\_BLOCK\_LEN 2048}}
\DoxyCodeLine{00368 \textcolor{comment}{}}
\DoxyCodeLine{00369 \textcolor{comment}{/** Default minimum strong sum length, if the filesize is unknown.}}
\DoxyCodeLine{00370 \textcolor{comment}{ *}}
\DoxyCodeLine{00371 \textcolor{comment}{ * This is conservative, and should be safe for files less than 45TB with a 2KB}}
\DoxyCodeLine{00372 \textcolor{comment}{ * block\_len, assuming no collision attack with crafted data. */}}
\DoxyCodeLine{00373 \textcolor{preprocessor}{\#  define RS\_DEFAULT\_MIN\_STRONG\_LEN 12}}
\DoxyCodeLine{00374 \textcolor{comment}{}}
\DoxyCodeLine{00375 \textcolor{comment}{/** Job of work to be done.}}
\DoxyCodeLine{00376 \textcolor{comment}{ *}}
\DoxyCodeLine{00377 \textcolor{comment}{ * Created by functions such as rs\_sig\_begin(), and then iterated over by}}
\DoxyCodeLine{00378 \textcolor{comment}{ * rs\_job\_iter().}}
\DoxyCodeLine{00379 \textcolor{comment}{ *}}
\DoxyCodeLine{00380 \textcolor{comment}{ * The contents are opaque to the application, and instances are always}}
\DoxyCodeLine{00381 \textcolor{comment}{ * allocated by the library.}}
\DoxyCodeLine{00382 \textcolor{comment}{ *}}
\DoxyCodeLine{00383 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_streaming \(\backslash\)sa rs\_job */}}
\DoxyCodeLine{00384 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }rs\_job rs\_job\_t;}
\DoxyCodeLine{00385 \textcolor{comment}{}}
\DoxyCodeLine{00386 \textcolor{comment}{/** Run a ::rs\_job state machine until it blocks (::RS\_BLOCKED), returns an}}
\DoxyCodeLine{00387 \textcolor{comment}{ * error, or completes (::RS\_DONE).}}
\DoxyCodeLine{00388 \textcolor{comment}{ *}}
\DoxyCodeLine{00389 \textcolor{comment}{ * \(\backslash\)param job Description of job state.}}
\DoxyCodeLine{00390 \textcolor{comment}{ *}}
\DoxyCodeLine{00391 \textcolor{comment}{ * \(\backslash\)param buffers Pointer to structure describing input and output buffers.}}
\DoxyCodeLine{00392 \textcolor{comment}{ *}}
\DoxyCodeLine{00393 \textcolor{comment}{ * \(\backslash\)return The ::rs\_result that caused iteration to stop.}}
\DoxyCodeLine{00394 \textcolor{comment}{ *}}
\DoxyCodeLine{00395 \textcolor{comment}{ * \(\backslash\)c buffers-\/>eof\_in should be true if there is no more data after what's in}}
\DoxyCodeLine{00396 \textcolor{comment}{ * the input buffer. The final block checksum will run across whatever's in}}
\DoxyCodeLine{00397 \textcolor{comment}{ * there, without trying to accumulate anything else.}}
\DoxyCodeLine{00398 \textcolor{comment}{ *}}
\DoxyCodeLine{00399 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_streaming */}}
\DoxyCodeLine{00400 LIBRSYNC\_EXPORT rs\_result rs\_job\_iter(rs\_job\_t *job, rs\_buffers\_t *buffers);}
\DoxyCodeLine{00401 \textcolor{comment}{}}
\DoxyCodeLine{00402 \textcolor{comment}{/** Type of application-\/supplied function for rs\_job\_drive().}}
\DoxyCodeLine{00403 \textcolor{comment}{ *}}
\DoxyCodeLine{00404 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_pull */}}
\DoxyCodeLine{00405 \textcolor{keyword}{typedef} rs\_result rs\_driven\_cb(rs\_job\_t *job, rs\_buffers\_t *buf,}
\DoxyCodeLine{00406                                \textcolor{keywordtype}{void} *opaque);}
\DoxyCodeLine{00407 \textcolor{comment}{}}
\DoxyCodeLine{00408 \textcolor{comment}{/** Actively process a job, by making callbacks to fill and empty the buffers}}
\DoxyCodeLine{00409 \textcolor{comment}{ * until the job is done. */}}
\DoxyCodeLine{00410 LIBRSYNC\_EXPORT rs\_result rs\_job\_drive(rs\_job\_t *job, rs\_buffers\_t *buf,}
\DoxyCodeLine{00411                                        rs\_driven\_cb in\_cb, \textcolor{keywordtype}{void} *in\_opaque,}
\DoxyCodeLine{00412                                        rs\_driven\_cb out\_cb, \textcolor{keywordtype}{void} *out\_opaque);}
\DoxyCodeLine{00413 \textcolor{comment}{}}
\DoxyCodeLine{00414 \textcolor{comment}{/** Return a pointer to the statistics in a job. */}}
\DoxyCodeLine{00415 LIBRSYNC\_EXPORT \textcolor{keyword}{const} rs\_stats\_t *rs\_job\_statistics(rs\_job\_t *job);}
\DoxyCodeLine{00416 \textcolor{comment}{}}
\DoxyCodeLine{00417 \textcolor{comment}{/** Deallocate job state. */}}
\DoxyCodeLine{00418 LIBRSYNC\_EXPORT rs\_result rs\_job\_free(rs\_job\_t *);}
\DoxyCodeLine{00419 \textcolor{comment}{}}
\DoxyCodeLine{00420 \textcolor{comment}{/** Get or check signature arguments for a given file size.}}
\DoxyCodeLine{00421 \textcolor{comment}{ *}}
\DoxyCodeLine{00422 \textcolor{comment}{ * This can be used to get the recommended arguments for generating a}}
\DoxyCodeLine{00423 \textcolor{comment}{ * signature. On calling, old\_fsize should be set to the old file size or -\/1}}
\DoxyCodeLine{00424 \textcolor{comment}{ * for "{}unknown"{}. The magic and block\_len arguments should be set to a valid}}
\DoxyCodeLine{00425 \textcolor{comment}{ * value or 0 for "{}recommended"{}. The strong\_len input should be set to a valid}}
\DoxyCodeLine{00426 \textcolor{comment}{ * value, 0 for "{}maximum"{}, or -\/1 for "{}miniumum"{}. Use strong\_len=0 for the best}}
\DoxyCodeLine{00427 \textcolor{comment}{ * protection against active hash collision attacks for the given magic type.}}
\DoxyCodeLine{00428 \textcolor{comment}{ * Use strong\_len=-\/1 for the smallest signature size that is safe against}}
\DoxyCodeLine{00429 \textcolor{comment}{ * random hash collisions for the block\_len and old\_fsize. Use strong\_len=20}}
\DoxyCodeLine{00430 \textcolor{comment}{ * for something probably good enough against attacks with smaller signatures.}}
\DoxyCodeLine{00431 \textcolor{comment}{ * On return the 0 or -\/1 input args will be set to recommended values and the}}
\DoxyCodeLine{00432 \textcolor{comment}{ * returned result will indicate if any inputs were invalid.}}
\DoxyCodeLine{00433 \textcolor{comment}{ *}}
\DoxyCodeLine{00434 \textcolor{comment}{ * \(\backslash\)param old\_fsize -\/ the original file size (-\/1 for "{}unknown"{}).}}
\DoxyCodeLine{00435 \textcolor{comment}{ *}}
\DoxyCodeLine{00436 \textcolor{comment}{ * \(\backslash\)param *magic -\/ the magic type to use (0 for "{}recommended"{}).}}
\DoxyCodeLine{00437 \textcolor{comment}{ *}}
\DoxyCodeLine{00438 \textcolor{comment}{ * \(\backslash\)param *block\_len -\/ the block length to use (0 for "{}recommended"{}).}}
\DoxyCodeLine{00439 \textcolor{comment}{ *}}
\DoxyCodeLine{00440 \textcolor{comment}{ * \(\backslash\)param *strong\_len -\/ the strongsum length to use (0 for "{}maximum"{}, -\/1 for}}
\DoxyCodeLine{00441 \textcolor{comment}{ * "{}minimum"{}).}}
\DoxyCodeLine{00442 \textcolor{comment}{ *}}
\DoxyCodeLine{00443 \textcolor{comment}{ * \(\backslash\)return RS\_DONE if all arguments are valid, otherwise an error code. */}}
\DoxyCodeLine{00444 LIBRSYNC\_EXPORT rs\_result rs\_sig\_args(rs\_long\_t old\_fsize,}
\DoxyCodeLine{00445                                       rs\_magic\_number * magic,}
\DoxyCodeLine{00446                                       \textcolor{keywordtype}{size\_t} *block\_len, \textcolor{keywordtype}{size\_t} *strong\_len);}
\DoxyCodeLine{00447 \textcolor{comment}{}}
\DoxyCodeLine{00448 \textcolor{comment}{/** Start generating a signature.}}
\DoxyCodeLine{00449 \textcolor{comment}{ *}}
\DoxyCodeLine{00450 \textcolor{comment}{ * It's recommended you use rs\_sig\_args() to get the recommended arguments for}}
\DoxyCodeLine{00451 \textcolor{comment}{ * this based on the original file size.}}
\DoxyCodeLine{00452 \textcolor{comment}{ *}}
\DoxyCodeLine{00453 \textcolor{comment}{ * \(\backslash\)return A new rs\_job\_t into which the old file data can be passed.}}
\DoxyCodeLine{00454 \textcolor{comment}{ *}}
\DoxyCodeLine{00455 \textcolor{comment}{ * \(\backslash\)param sig\_magic Signature file format to generate (0 for "{}recommended"{}).}}
\DoxyCodeLine{00456 \textcolor{comment}{ * See ::rs\_magic\_number.}}
\DoxyCodeLine{00457 \textcolor{comment}{ *}}
\DoxyCodeLine{00458 \textcolor{comment}{ * \(\backslash\)param block\_len Checksum block size to use (0 for "{}recommended"{}). Larger}}
\DoxyCodeLine{00459 \textcolor{comment}{ * values make the signature shorter, and the delta longer.}}
\DoxyCodeLine{00460 \textcolor{comment}{ *}}
\DoxyCodeLine{00461 \textcolor{comment}{ * \(\backslash\)param strong\_len Strongsum length in bytes to use (0 for "{}maximum"{}, -\/1 for}}
\DoxyCodeLine{00462 \textcolor{comment}{ * "{}minimum"{}). Smaller values make the signature shorter but increase the risk}}
\DoxyCodeLine{00463 \textcolor{comment}{ * of corruption from hash collisions.}}
\DoxyCodeLine{00464 \textcolor{comment}{ *}}
\DoxyCodeLine{00465 \textcolor{comment}{ * \(\backslash\)sa rs\_sig\_file() */}}
\DoxyCodeLine{00466 LIBRSYNC\_EXPORT rs\_job\_t *rs\_sig\_begin(\textcolor{keywordtype}{size\_t} block\_len, \textcolor{keywordtype}{size\_t} strong\_len,}
\DoxyCodeLine{00467                                        rs\_magic\_number sig\_magic);}
\DoxyCodeLine{00468 \textcolor{comment}{}}
\DoxyCodeLine{00469 \textcolor{comment}{/** Prepare to compute a streaming delta.}}
\DoxyCodeLine{00470 \textcolor{comment}{ *}}
\DoxyCodeLine{00471 \textcolor{comment}{ * \(\backslash\)todo Add a version of this that takes a ::rs\_magic\_number controlling the}}
\DoxyCodeLine{00472 \textcolor{comment}{ * delta format. */}}
\DoxyCodeLine{00473 LIBRSYNC\_EXPORT rs\_job\_t *rs\_delta\_begin(rs\_signature\_t *);}
\DoxyCodeLine{00474 \textcolor{comment}{}}
\DoxyCodeLine{00475 \textcolor{comment}{/** Read a signature from a file into an ::rs\_signature structure in memory.}}
\DoxyCodeLine{00476 \textcolor{comment}{ *}}
\DoxyCodeLine{00477 \textcolor{comment}{ * Once there, it can be used to generate a delta to a newer version of the}}
\DoxyCodeLine{00478 \textcolor{comment}{ * file.}}
\DoxyCodeLine{00479 \textcolor{comment}{ *}}
\DoxyCodeLine{00480 \textcolor{comment}{ * \(\backslash\)note After loading the signatures, you must call \(\backslash\)ref rs\_build\_hash\_table()}}
\DoxyCodeLine{00481 \textcolor{comment}{ * before you can use them. */}}
\DoxyCodeLine{00482 LIBRSYNC\_EXPORT rs\_job\_t *rs\_loadsig\_begin(rs\_signature\_t **);}
\DoxyCodeLine{00483 \textcolor{comment}{}}
\DoxyCodeLine{00484 \textcolor{comment}{/** Call this after loading a signature to index it.}}
\DoxyCodeLine{00485 \textcolor{comment}{ *}}
\DoxyCodeLine{00486 \textcolor{comment}{ * Use rs\_free\_sumset() to release it after use. */}}
\DoxyCodeLine{00487 LIBRSYNC\_EXPORT rs\_result rs\_build\_hash\_table(rs\_signature\_t *sums);}
\DoxyCodeLine{00488 \textcolor{comment}{}}
\DoxyCodeLine{00489 \textcolor{comment}{/** Callback used to retrieve parts of the basis file.}}
\DoxyCodeLine{00490 \textcolor{comment}{ *}}
\DoxyCodeLine{00491 \textcolor{comment}{ * \(\backslash\)param opaque The opaque object to execute the callback with. Often the file}}
\DoxyCodeLine{00492 \textcolor{comment}{ * to read from.}}
\DoxyCodeLine{00493 \textcolor{comment}{ *}}
\DoxyCodeLine{00494 \textcolor{comment}{ * \(\backslash\)param pos Position where copying should begin.}}
\DoxyCodeLine{00495 \textcolor{comment}{ *}}
\DoxyCodeLine{00496 \textcolor{comment}{ * \(\backslash\)param len On input, the amount of data that should be retrieved. Updated to}}
\DoxyCodeLine{00497 \textcolor{comment}{ * show how much is actually available, but should not be greater than the}}
\DoxyCodeLine{00498 \textcolor{comment}{ * input value.}}
\DoxyCodeLine{00499 \textcolor{comment}{ *}}
\DoxyCodeLine{00500 \textcolor{comment}{ * \(\backslash\)param buf On input, a buffer of at least \(\backslash\)p *len bytes. May be updated to}}
\DoxyCodeLine{00501 \textcolor{comment}{ * point to a buffer allocated by the callback if it prefers. */}}
\DoxyCodeLine{00502 \textcolor{keyword}{typedef} rs\_result rs\_copy\_cb(\textcolor{keywordtype}{void} *opaque, rs\_long\_t pos, \textcolor{keywordtype}{size\_t} *len,}
\DoxyCodeLine{00503                              \textcolor{keywordtype}{void} **buf);}
\DoxyCodeLine{00504 \textcolor{comment}{}}
\DoxyCodeLine{00505 \textcolor{comment}{/** Apply a \(\backslash\)a delta to a \(\backslash\)a basis file to recreate the \(\backslash\)a new file.}}
\DoxyCodeLine{00506 \textcolor{comment}{ *}}
\DoxyCodeLine{00507 \textcolor{comment}{ * This gives you back a ::rs\_job\_t object, which can be cranked by calling}}
\DoxyCodeLine{00508 \textcolor{comment}{ * rs\_job\_iter() and updating the stream pointers. When finished, call}}
\DoxyCodeLine{00509 \textcolor{comment}{ * rs\_job\_free() to dispose of it.}}
\DoxyCodeLine{00510 \textcolor{comment}{ *}}
\DoxyCodeLine{00511 \textcolor{comment}{ * \(\backslash\)param copy\_cb Callback used to retrieve content from the basis file.}}
\DoxyCodeLine{00512 \textcolor{comment}{ *}}
\DoxyCodeLine{00513 \textcolor{comment}{ * \(\backslash\)param copy\_arg Opaque environment pointer passed through to the callback.}}
\DoxyCodeLine{00514 \textcolor{comment}{ *}}
\DoxyCodeLine{00515 \textcolor{comment}{ * \(\backslash\)todo As output is produced, accumulate the MD4 checksum of the output. Then}}
\DoxyCodeLine{00516 \textcolor{comment}{ * if we find a CHECKSUM command we can check it's contents against the output.}}
\DoxyCodeLine{00517 \textcolor{comment}{ *}}
\DoxyCodeLine{00518 \textcolor{comment}{ * \(\backslash\)todo Implement COPY commands.}}
\DoxyCodeLine{00519 \textcolor{comment}{ *}}
\DoxyCodeLine{00520 \textcolor{comment}{ * \(\backslash\)sa rs\_patch\_file() \(\backslash\)sa \(\backslash\)ref api\_streaming */}}
\DoxyCodeLine{00521 LIBRSYNC\_EXPORT rs\_job\_t *rs\_patch\_begin(rs\_copy\_cb * copy\_cb, \textcolor{keywordtype}{void} *copy\_arg);}
\DoxyCodeLine{00522 }
\DoxyCodeLine{00523 \textcolor{preprocessor}{\#  ifndef RSYNC\_NO\_STDIO\_INTERFACE}}
\DoxyCodeLine{00524 \textcolor{preprocessor}{\#    include <stdio.h>}}
\DoxyCodeLine{00525 \textcolor{comment}{}}
\DoxyCodeLine{00526 \textcolor{comment}{/** Open a file with special handling for stdin or stdout.}}
\DoxyCodeLine{00527 \textcolor{comment}{ *}}
\DoxyCodeLine{00528 \textcolor{comment}{ * This provides a platform independent way to open large binary files. A}}
\DoxyCodeLine{00529 \textcolor{comment}{ * filename "{}"{} or "{}-\/"{} means use stdin for reading, or stdout for writing.}}
\DoxyCodeLine{00530 \textcolor{comment}{ *}}
\DoxyCodeLine{00531 \textcolor{comment}{ * \(\backslash\)param filename -\/ The filename to open.}}
\DoxyCodeLine{00532 \textcolor{comment}{ *}}
\DoxyCodeLine{00533 \textcolor{comment}{ * \(\backslash\)param mode -\/ fopen style mode string.}}
\DoxyCodeLine{00534 \textcolor{comment}{ *}}
\DoxyCodeLine{00535 \textcolor{comment}{ * \(\backslash\)param force -\/ bool to force overwriting of existing files. */}}
\DoxyCodeLine{00536 LIBRSYNC\_EXPORT FILE *rs\_file\_open(\textcolor{keywordtype}{char} \textcolor{keyword}{const} *filename, \textcolor{keywordtype}{char} \textcolor{keyword}{const} *mode,}
\DoxyCodeLine{00537                                    \textcolor{keywordtype}{int} force);}
\DoxyCodeLine{00538 \textcolor{comment}{}}
\DoxyCodeLine{00539 \textcolor{comment}{/** Close a file with special handling for stdin or stdout.}}
\DoxyCodeLine{00540 \textcolor{comment}{ *}}
\DoxyCodeLine{00541 \textcolor{comment}{ * This will not actually close the file if it is stdin or stdout.}}
\DoxyCodeLine{00542 \textcolor{comment}{ *}}
\DoxyCodeLine{00543 \textcolor{comment}{ * \(\backslash\)param file -\/ the stdio file to close. */}}
\DoxyCodeLine{00544 LIBRSYNC\_EXPORT \textcolor{keywordtype}{int} rs\_file\_close(FILE *file);}
\DoxyCodeLine{00545 \textcolor{comment}{}}
\DoxyCodeLine{00546 \textcolor{comment}{/** Get the size of a file.}}
\DoxyCodeLine{00547 \textcolor{comment}{ *}}
\DoxyCodeLine{00548 \textcolor{comment}{ * This provides a platform independent way to get the size of large files. It}}
\DoxyCodeLine{00549 \textcolor{comment}{ * will return -\/1 if the size cannot be determined because it is not a regular}}
\DoxyCodeLine{00550 \textcolor{comment}{ * file.}}
\DoxyCodeLine{00551 \textcolor{comment}{ *}}
\DoxyCodeLine{00552 \textcolor{comment}{ * \(\backslash\)param file -\/ the stdio file to get the size of. */}}
\DoxyCodeLine{00553 LIBRSYNC\_EXPORT rs\_long\_t rs\_file\_size(FILE *file);}
\DoxyCodeLine{00554 \textcolor{comment}{}}
\DoxyCodeLine{00555 \textcolor{comment}{/** ::rs\_copy\_cb that reads from a stdio file. */}}
\DoxyCodeLine{00556 LIBRSYNC\_EXPORT rs\_result rs\_file\_copy\_cb(\textcolor{keywordtype}{void} *arg, rs\_long\_t pos, \textcolor{keywordtype}{size\_t} *len,}
\DoxyCodeLine{00557                                           \textcolor{keywordtype}{void} **buf);}
\DoxyCodeLine{00558 \textcolor{comment}{}}
\DoxyCodeLine{00559 \textcolor{comment}{/** Buffer sizes for file IO.}}
\DoxyCodeLine{00560 \textcolor{comment}{ *}}
\DoxyCodeLine{00561 \textcolor{comment}{ * The default 0 means use the recommended buffer size for the operation being}}
\DoxyCodeLine{00562 \textcolor{comment}{ * performed, any other value will override the recommended sizes. You probably}}
\DoxyCodeLine{00563 \textcolor{comment}{ * only need to change these in testing. */}}
\DoxyCodeLine{00564 LIBRSYNC\_EXPORT \textcolor{keyword}{extern} \textcolor{keywordtype}{int} rs\_inbuflen, rs\_outbuflen;}
\DoxyCodeLine{00565 \textcolor{comment}{}}
\DoxyCodeLine{00566 \textcolor{comment}{/** Generate the signature of a basis file, and write it out to another.}}
\DoxyCodeLine{00567 \textcolor{comment}{ *}}
\DoxyCodeLine{00568 \textcolor{comment}{ * It's recommended you use rs\_sig\_args() to get the recommended arguments for}}
\DoxyCodeLine{00569 \textcolor{comment}{ * this based on the original file size.}}
\DoxyCodeLine{00570 \textcolor{comment}{ *}}
\DoxyCodeLine{00571 \textcolor{comment}{ * \(\backslash\)param old\_file Stdio readable file whose signature will be generated.}}
\DoxyCodeLine{00572 \textcolor{comment}{ *}}
\DoxyCodeLine{00573 \textcolor{comment}{ * \(\backslash\)param sig\_file Writable stdio file to which the signature will be written./}}
\DoxyCodeLine{00574 \textcolor{comment}{ *}}
\DoxyCodeLine{00575 \textcolor{comment}{ * \(\backslash\)param block\_len Checksum block size to use (0 for "{}recommended"{}). Larger}}
\DoxyCodeLine{00576 \textcolor{comment}{ * values make the signature shorter, and the delta longer.}}
\DoxyCodeLine{00577 \textcolor{comment}{ *}}
\DoxyCodeLine{00578 \textcolor{comment}{ * \(\backslash\)param strong\_len Strongsum length in bytes to use (0 for "{}maximum"{}, -\/1 for}}
\DoxyCodeLine{00579 \textcolor{comment}{ * "{}minimum"{}). Smaller values make the signature shorter but increase the risk}}
\DoxyCodeLine{00580 \textcolor{comment}{ * of corruption from hash collisions.}}
\DoxyCodeLine{00581 \textcolor{comment}{ *}}
\DoxyCodeLine{00582 \textcolor{comment}{ * \(\backslash\)param sig\_magic Signature file format to generate (0 for "{}recommended"{}).}}
\DoxyCodeLine{00583 \textcolor{comment}{ * See ::rs\_magic\_number.}}
\DoxyCodeLine{00584 \textcolor{comment}{ *}}
\DoxyCodeLine{00585 \textcolor{comment}{ * \(\backslash\)param stats Optional pointer to receive statistics.}}
\DoxyCodeLine{00586 \textcolor{comment}{ *}}
\DoxyCodeLine{00587 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_whole */}}
\DoxyCodeLine{00588 LIBRSYNC\_EXPORT rs\_result rs\_sig\_file(FILE *old\_file, FILE *sig\_file,}
\DoxyCodeLine{00589                                       \textcolor{keywordtype}{size\_t} block\_len, \textcolor{keywordtype}{size\_t} strong\_len,}
\DoxyCodeLine{00590                                       rs\_magic\_number sig\_magic,}
\DoxyCodeLine{00591                                       rs\_stats\_t *stats);}
\DoxyCodeLine{00592 \textcolor{comment}{}}
\DoxyCodeLine{00593 \textcolor{comment}{/** Load signatures from a signature file into memory.}}
\DoxyCodeLine{00594 \textcolor{comment}{ *}}
\DoxyCodeLine{00595 \textcolor{comment}{ * \(\backslash\)param sig\_file Readable stdio file from which the signature will be read.}}
\DoxyCodeLine{00596 \textcolor{comment}{ *}}
\DoxyCodeLine{00597 \textcolor{comment}{ * \(\backslash\)param sumset on return points to the newly allocated structure.}}
\DoxyCodeLine{00598 \textcolor{comment}{ *}}
\DoxyCodeLine{00599 \textcolor{comment}{ * \(\backslash\)param stats Optional pointer to receive statistics.}}
\DoxyCodeLine{00600 \textcolor{comment}{ *}}
\DoxyCodeLine{00601 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_whole */}}
\DoxyCodeLine{00602 LIBRSYNC\_EXPORT rs\_result rs\_loadsig\_file(FILE *sig\_file,}
\DoxyCodeLine{00603                                           rs\_signature\_t **sumset,}
\DoxyCodeLine{00604                                           rs\_stats\_t *stats);}
\DoxyCodeLine{00605 \textcolor{comment}{}}
\DoxyCodeLine{00606 \textcolor{comment}{/** Generate a delta between a signature and a new file into a delta file.}}
\DoxyCodeLine{00607 \textcolor{comment}{ *}}
\DoxyCodeLine{00608 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_whole */}}
\DoxyCodeLine{00609 LIBRSYNC\_EXPORT rs\_result rs\_delta\_file(rs\_signature\_t *, FILE *new\_file,}
\DoxyCodeLine{00610                                         FILE *delta\_file, rs\_stats\_t *);}
\DoxyCodeLine{00611 \textcolor{comment}{}}
\DoxyCodeLine{00612 \textcolor{comment}{/** Apply a patch, relative to a basis, into a new file.}}
\DoxyCodeLine{00613 \textcolor{comment}{ *}}
\DoxyCodeLine{00614 \textcolor{comment}{ * \(\backslash\)sa \(\backslash\)ref api\_whole */}}
\DoxyCodeLine{00615 LIBRSYNC\_EXPORT rs\_result rs\_patch\_file(FILE *basis\_file, FILE *delta\_file,}
\DoxyCodeLine{00616                                         FILE *new\_file, rs\_stats\_t *);}
\DoxyCodeLine{00617 \textcolor{preprocessor}{\#  endif                        }\textcolor{comment}{/* !RSYNC\_NO\_STDIO\_INTERFACE */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00618 }
\DoxyCodeLine{00619 \textcolor{preprocessor}{\#  ifdef \_\_cplusplus}}
\DoxyCodeLine{00620 \}                               \textcolor{comment}{/* extern "{}C"{} */}}
\DoxyCodeLine{00621 \textcolor{preprocessor}{\#  endif}}
\DoxyCodeLine{00622 }
\DoxyCodeLine{00623 \textcolor{preprocessor}{\#endif                          }\textcolor{comment}{/* !LIBRSYNC\_H */}\textcolor{preprocessor}{}}

\end{DoxyCode}
