🌐 AI搜索 & 代理 主页
blob: a15350dabcd497d4cb21261721706eca072de034 [file] [log] [blame]
Nicolas Pitred1af0022005-05-20 20:59:171#ifndef DELTA_H
2#define DELTA_H
3
4/* handling of delta buffers */
Nicolas Pitrea310d432005-05-19 14:27:145extern void *diff_delta(void *from_buf, unsigned long from_size,
6 void *to_buf, unsigned long to_size,
Linus Torvalds75c42d82005-06-26 02:30:207 unsigned long *delta_size, unsigned long max_size);
Nicolas Pitrea310d432005-05-19 14:27:148extern void *patch_delta(void *src_buf, unsigned long src_size,
9 void *delta_buf, unsigned long delta_size,
10 unsigned long *dst_size);
Nicolas Pitred1af0022005-05-20 20:59:1711
Nicolas Pitredcde55b2005-06-29 06:49:5612/* 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 */
19static inline unsigned long get_delta_hdr_size(const unsigned char **datap)
20{
21 const unsigned char *data = *datap;
Nicolas Pitre39556fb2006-02-10 18:42:0522 unsigned char cmd;
23 unsigned long size = 0;
24 int i = 0;
25 do {
Nicolas Pitredcde55b2005-06-29 06:49:5626 cmd = *data++;
27 size |= (cmd & ~0x80) << i;
28 i += 7;
Nicolas Pitre39556fb2006-02-10 18:42:0529 } while (cmd & 0x80);
Nicolas Pitredcde55b2005-06-29 06:49:5630 *datap = data;
31 return size;
32}
33
Nicolas Pitred1af0022005-05-20 20:59:1734#endif