rsync-algo.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. RSync Algorithrim
  6. The RSync algorithim is attributed to Andrew Tridgell and is a means
  7. for matching blocks between two streams. The algorithrim implemented
  8. here differs slightly in its structure and is carefully optimized to be
  9. able to operate on very large files effectively.
  10. We rely on the RSync rolling weak checksum routine and the MD4 strong
  11. checksum routine. This implementation requires a uniform block size
  12. for each run.
  13. ##################################################################### */
  14. /*}}}*/
  15. #ifndef DSYNC_RSYNC_ALGO_H
  16. #define DSYNC_RSYNC_ALGO_H
  17. #ifdef __GNUG__
  18. #pragma interface "dsync/rsync-algo.h"
  19. #endif
  20. #include <dsync/fileutl.h>
  21. #include <dsync/filelist.h>
  22. #include <dsync/bitmap.h>
  23. #include <inttypes.h>
  24. class RSyncMatch
  25. {
  26. uint32_t **Indexes;
  27. uint32_t **IndexesEnd;
  28. uint32_t **Hashes[257];
  29. BitmapVector Fast;
  30. dsFList::RSyncChecksum const &Ck;
  31. static int Sort(const void *L,const void *R);
  32. protected:
  33. virtual bool Hit(unsigned long Block,off_t SrcOff,
  34. const unsigned char *Data) {return true;};
  35. public:
  36. bool Scan(FileFd &Fd);
  37. RSyncMatch(dsFList::RSyncChecksum const &Ck);
  38. virtual ~RSyncMatch();
  39. };
  40. bool GenerateRSync(FileFd &Fd,dsFList::RSyncChecksum &Ck,
  41. unsigned char MD5[16],
  42. unsigned long BlockSize = 8*1024);
  43. #endif