-
Notifications
You must be signed in to change notification settings - Fork 0
/
rabin.h
37 lines (30 loc) · 817 Bytes
/
rabin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef _RABIN_H
#define _RABIN_H
#include <stdint.h>
#define POLYNOMIAL 0x3DA3358B4DC173LL
#define POLYNOMIAL_DEGREE 53
#define WINSIZE 64
#define AVERAGE_BITS 20
#define MINSIZE (4*1024)
#define MAXSIZE (48*1024)
struct rabin_t {
uint8_t window[WINSIZE];
unsigned int wpos;
unsigned int count;
unsigned int pos;
unsigned int start;
uint64_t digest;
};
struct chunk_t {
unsigned int start;
unsigned int length;
uint64_t cut_fingerprint;
};
extern struct chunk_t last_chunk;
struct rabin_t *rabin_init(void);
void rabin_reset(struct rabin_t *h);
void rabin_slide(struct rabin_t *h, uint8_t b);
void rabin_append(struct rabin_t *h, uint8_t b);
int rabin_next_chunk(struct rabin_t *h, uint8_t *buf, unsigned int len);
struct chunk_t *rabin_finalize(struct rabin_t *h);
#endif