]>
Commit | Line | Data |
---|---|---|
d1af002d NP |
1 | #ifndef DELTA_H |
2 | #define DELTA_H | |
3 | ||
4 | /* handling of delta buffers */ | |
a310d434 NP |
5 | extern void *diff_delta(void *from_buf, unsigned long from_size, |
6 | void *to_buf, unsigned long to_size, | |
75c42d8c | 7 | unsigned long *delta_size, unsigned long max_size); |
a310d434 NP |
8 | extern void *patch_delta(void *src_buf, unsigned long src_size, |
9 | void *delta_buf, unsigned long delta_size, | |
10 | unsigned long *dst_size); | |
d1af002d | 11 | |
dcde55bc NP |
12 | /* the smallest possible delta size is 4 bytes */ |
13 | #define DELTA_SIZE_MIN 4 | |
14 | ||
15 | /* | |
16 | * This must be called twice on the delta data buffer, first to get the | |
17 | * expected reference buffer size, and again to get the result buffer size. | |
18 | */ | |
8960844a NP |
19 | static inline unsigned long get_delta_hdr_size(const unsigned char **datap, |
20 | const unsigned char *top) | |
dcde55bc NP |
21 | { |
22 | const unsigned char *data = *datap; | |
39556fbd NP |
23 | unsigned char cmd; |
24 | unsigned long size = 0; | |
25 | int i = 0; | |
26 | do { | |
dcde55bc NP |
27 | cmd = *data++; |
28 | size |= (cmd & ~0x80) << i; | |
29 | i += 7; | |
8960844a | 30 | } while (cmd & 0x80 && data < top); |
dcde55bc NP |
31 | *datap = data; |
32 | return size; | |
33 | } | |
34 | ||
d1af002d | 35 | #endif |