Nicolas Pitre | d1af002 | 2005-05-20 16:59:17 -0400 | [diff] [blame] | 1 | #ifndef DELTA_H |
| 2 | #define DELTA_H |
| 3 | |
| 4 | /* handling of delta buffers */ |
Nicolas Pitre | a310d43 | 2005-05-19 10:27:14 -0400 | [diff] [blame] | 5 | extern void *diff_delta(void *from_buf, unsigned long from_size, |
| 6 | void *to_buf, unsigned long to_size, |
Linus Torvalds | 75c42d8 | 2005-06-25 19:30:20 -0700 | [diff] [blame] | 7 | unsigned long *delta_size, unsigned long max_size); |
Nicolas Pitre | a310d43 | 2005-05-19 10:27:14 -0400 | [diff] [blame] | 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); |
Nicolas Pitre | d1af002 | 2005-05-20 16:59:17 -0400 | [diff] [blame] | 11 | |
Nicolas Pitre | dcde55b | 2005-06-29 02:49:56 -0400 | [diff] [blame] | 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 | */ |
| 19 | static inline unsigned long get_delta_hdr_size(const unsigned char **datap) |
| 20 | { |
| 21 | const unsigned char *data = *datap; |
| 22 | unsigned char cmd = *data++; |
| 23 | unsigned long size = cmd & ~0x80; |
| 24 | int i = 7; |
| 25 | while (cmd & 0x80) { |
| 26 | cmd = *data++; |
| 27 | size |= (cmd & ~0x80) << i; |
| 28 | i += 7; |
| 29 | } |
| 30 | *datap = data; |
| 31 | return size; |
| 32 | } |
| 33 | |
Nicolas Pitre | d1af002 | 2005-05-20 16:59:17 -0400 | [diff] [blame] | 34 | #endif |