]> git.decadent.org.uk Git - dak.git/blob - tools/dsync-0.0/libdsync/rsync-algo.h
Cope with empty queue
[dak.git] / tools / dsync-0.0 / libdsync / rsync-algo.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description                                                          /*{{{*/
3 // $Id: rsync-algo.h,v 1.3 1999/12/26 06:59:01 jgg Exp $
4 /* ######################################################################
5    
6    RSync Algorithrim
7    
8    The RSync algorithim is attributed to Andrew Tridgell and is a means
9    for matching blocks between two streams.  The algorithrim implemented 
10    here differs slightly in its structure and is carefully optimized to be 
11    able to operate on very large files effectively.
12
13    We rely on the RSync rolling weak checksum routine and the MD4 strong 
14    checksum routine. This implementation requires a uniform block size 
15    for each run.
16    
17    ##################################################################### */
18                                                                         /*}}}*/
19 #ifndef DSYNC_RSYNC_ALGO_H
20 #define DSYNC_RSYNC_ALGO_H
21
22 #ifdef __GNUG__
23 #pragma interface "dsync/rsync-algo.h"
24 #endif 
25
26 #include <dsync/fileutl.h>
27 #include <dsync/filelist.h>
28 #include <dsync/bitmap.h>
29
30 #include <inttypes.h>
31
32 class RSyncMatch
33 {
34    uint32_t **Indexes;
35    uint32_t **IndexesEnd;
36    uint32_t **Hashes[257];
37    BitmapVector Fast;
38    dsFList::RSyncChecksum const &Ck;
39
40    static int Sort(const void *L,const void *R);
41    
42    protected:
43    
44    virtual bool Hit(unsigned long Block,off_t SrcOff,
45                     const unsigned char *Data) {return true;};
46    
47    public:
48
49    bool Scan(FileFd &Fd);
50       
51    RSyncMatch(dsFList::RSyncChecksum const &Ck);
52    virtual ~RSyncMatch();
53 };
54
55 bool GenerateRSync(FileFd &Fd,dsFList::RSyncChecksum &Ck,
56                    unsigned char MD5[16],
57                    unsigned long BlockSize = 8*1024);
58
59 #endif