Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

rsync.h

Go to the documentation of this file.
00001 /*=                    -*- c-basic-offset: 4; indent-tabs-mode: nil; -*-
00002  *
00003  * librsync -- library for network deltas
00004  * $Id: rsync.h,v 1.1.1.1 2002/01/25 22:15:09 kergoth Exp $
00005  * 
00006  * Copyright (C) 2000, 2001 by Martin Pool <mbp@samba.org>
00007  * 
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License as published by
00010  * the Free Software Foundation; either version 2.1 of the License, or
00011  * (at your option) any later version.
00012  * 
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU Lesser General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU Lesser General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021  */
00022 
00023                               /*
00024                                | You should never wear your best
00025                                | trousers when you go out to fight for
00026                                | freedom and liberty.
00027                                |        -- Henrik Ibsen
00028                                */
00029 
00030 
00042 #include <sys/types.h>
00043 
00044 extern char const rs_librsync_version[];
00045 extern char const rs_licence_string[];
00046 
00047 
00055 #if SIZEOF_LONG_LONG
00056 typedef signed long long    rs_long_t;
00057 #else
00058 typedef long rs_long_t;
00059 #endif
00060 
00061 
00069 typedef enum {
00070     RS_LOG_EMERG         = 0,   
00071     RS_LOG_ALERT         = 1,   
00072     RS_LOG_CRIT          = 2,   
00073     RS_LOG_ERR           = 3,   
00074     RS_LOG_WARNING       = 4,   
00075     RS_LOG_NOTICE        = 5,   
00076     RS_LOG_INFO          = 6,   
00077     RS_LOG_DEBUG         = 7    
00078 } rs_loglevel;
00079 
00080 
00081 
00088 typedef void    rs_trace_fn_t(int level, char const *msg);
00089 
00090 void            rs_trace_set_level(rs_loglevel level);
00091 
00093 void            rs_trace_to(rs_trace_fn_t *);
00094 
00097 void            rs_trace_stderr(int level, char const *msg);
00098 
00101 int             rs_supports_trace(void);
00102 
00103 
00104 
00110 void     rs_hexify(char *to_buf, void const *from_buf, int from_len);
00111 
00116 size_t rs_unbase64(char *s);
00117 
00118 
00122 void rs_base64(unsigned char const *buf, int n, char *out);
00123 
00124 
00128 typedef enum {
00129     RS_DONE =           0,      
00130     RS_BLOCKED =        1,      
00131     RS_RUNNING  =       2,      
00135     RS_TEST_SKIPPED =   77,     
00137     RS_IO_ERROR =       100,    
00138     RS_SYNTAX_ERROR =   101,    
00139     RS_MEM_ERROR =      102,    
00140     RS_INPUT_ENDED =    103,    
00142     RS_BAD_MAGIC =      104,    
00147     RS_UNIMPLEMENTED =  105,    
00148     RS_CORRUPT =        106,    
00149     RS_INTERNAL_ERROR = 107,    
00150     RS_PARAM_ERROR =    108     
00152 } rs_result;
00153 
00154 
00155 
00159 char const *rs_strerror(rs_result r);
00160 
00161 
00168 typedef struct rs_stats {
00169     char const     *op;     
00171     int             lit_cmds;   
00172     rs_long_t       lit_bytes;  
00173     rs_long_t       lit_cmdbytes; 
00176     rs_long_t       copy_cmds, copy_bytes, copy_cmdbytes;
00177     rs_long_t       sig_cmds, sig_bytes;
00178     int             false_matches;
00179 
00180     rs_long_t       sig_blocks; 
00183     size_t          block_len;
00184 
00185     rs_long_t       in_bytes;   
00186     rs_long_t       out_bytes;  
00187 } rs_stats_t;
00188 
00189 
00197 typedef struct rs_mdfour {
00198     int                 A, B, C, D;
00199     int                 totalN;
00200     int                 tail_len;
00201     unsigned char       tail[64];
00202 } rs_mdfour_t;
00203 
00204 #define RS_MD4_LENGTH 16
00205 
00206 typedef unsigned int rs_weak_sum_t;
00207 typedef unsigned char rs_strong_sum_t[RS_MD4_LENGTH];
00208 
00209 void            rs_mdfour(unsigned char *out, void const *in, size_t); 
00210 void            rs_mdfour_begin(/* @out@ */ rs_mdfour_t * md);
00211 void            rs_mdfour_update(rs_mdfour_t * md, void const *,
00212                                  size_t n);
00213 void rs_mdfour_result(rs_mdfour_t * md, unsigned char *out);
00214 
00215 char *rs_format_stats(rs_stats_t const *, char *, size_t);
00216 
00217 int rs_log_stats(rs_stats_t const *stats);
00218 
00219 
00220 typedef struct rs_signature rs_signature_t;
00221 
00222 void rs_free_sumset(rs_signature_t *);
00223 void rs_sumset_dump(rs_signature_t const *);
00224 
00225 
00273 struct rs_buffers_s {
00274     char *next_in;              
00275     size_t avail_in;            
00276     int eof_in;                 
00279     char *next_out;             
00280     size_t avail_out;           
00281 };
00282 
00290 typedef struct rs_buffers_s rs_buffers_t;
00291 
00294 #define RS_DEFAULT_STRONG_LEN 8
00295 
00297 #define RS_DEFAULT_BLOCK_LEN 2048
00298 
00299 
00306 typedef struct rs_job rs_job_t;
00307 
00312 typedef enum rs_work_options {
00313     RS_END = 0x01               
00315 } rs_work_options;
00316 
00317 
00318 rs_result       rs_job_iter(rs_job_t *, rs_buffers_t *);
00319 
00320 typedef rs_result rs_driven_cb(rs_job_t *job, rs_buffers_t *buf,
00321                                void *opaque);
00322 
00323 rs_result rs_job_drive(rs_job_t *job, rs_buffers_t *buf,
00324                        rs_driven_cb in_cb, void *in_opaque,
00325                        rs_driven_cb out_cb, void *out_opaque);
00326 
00327 rs_result       rs_job_free(rs_job_t *);
00328 
00329 int             rs_accum_value(rs_job_t *, char *sum, size_t sum_len);
00330 
00331 rs_job_t *rs_sig_begin(size_t new_block_len, size_t strong_sum_len);
00332 
00333 rs_job_t *rs_delta_begin(rs_signature_t *);
00334 
00335 rs_job_t *rs_loadsig_begin(rs_signature_t **);
00336 
00349 typedef rs_result rs_copy_cb(void *opaque, off_t pos,
00350                              size_t *len, void **buf);
00351 
00352 
00353 
00354 rs_job_t *rs_patch_begin(rs_copy_cb *, void *copy_arg);
00355 
00356 
00357 rs_result rs_build_hash_table(rs_signature_t* sums);
00358 
00359 
00360 
00361 #ifndef RSYNC_NO_STDIO_INTERFACE
00362 
00367 extern int rs_inbuflen, rs_outbuflen;
00368 
00369 
00376 void rs_mdfour_file(FILE *in_file, char *result);
00377 
00378 rs_result rs_sig_file(FILE *old_file, FILE *sig_file,
00379                       size_t block_len, size_t strong_len, rs_stats_t *); 
00380 
00381 rs_result rs_loadsig_file(FILE *, rs_signature_t **, rs_stats_t *);
00382 
00383 rs_result rs_file_copy_cb(void *arg, off_t pos, size_t *len, void **buf);
00384 
00385 rs_result rs_delta_file(rs_signature_t *, FILE *new_file, FILE *delta_file, rs_stats_t *);
00386 
00387 rs_result rs_patch_file(FILE *basis_file, FILE *delta_file, FILE *new_file, rs_stats_t *);
00388 #endif

Generated on Sat Nov 5 16:18:35 2005 for OPIE by  doxygen 1.4.2