2005-05-20 20:59:17 +00:00
|
|
|
#ifndef DELTA_H
|
|
|
|
#define DELTA_H
|
|
|
|
|
|
|
|
/* handling of delta buffers */
|
2005-05-19 14:27:14 +00:00
|
|
|
extern void *diff_delta(void *from_buf, unsigned long from_size,
|
|
|
|
void *to_buf, unsigned long to_size,
|
2005-06-26 02:30:20 +00:00
|
|
|
unsigned long *delta_size, unsigned long max_size);
|
2005-05-19 14:27:14 +00:00
|
|
|
extern void *patch_delta(void *src_buf, unsigned long src_size,
|
|
|
|
void *delta_buf, unsigned long delta_size,
|
|
|
|
unsigned long *dst_size);
|
2005-05-20 20:59:17 +00:00
|
|
|
|
2005-06-29 06:49:56 +00:00
|
|
|
/* the smallest possible delta size is 4 bytes */
|
|
|
|
#define DELTA_SIZE_MIN 4
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This must be called twice on the delta data buffer, first to get the
|
|
|
|
* expected reference buffer size, and again to get the result buffer size.
|
|
|
|
*/
|
2006-04-07 19:26:10 +00:00
|
|
|
static inline unsigned long get_delta_hdr_size(const unsigned char **datap,
|
|
|
|
const unsigned char *top)
|
2005-06-29 06:49:56 +00:00
|
|
|
{
|
|
|
|
const unsigned char *data = *datap;
|
2006-02-10 18:42:05 +00:00
|
|
|
unsigned char cmd;
|
|
|
|
unsigned long size = 0;
|
|
|
|
int i = 0;
|
|
|
|
do {
|
2005-06-29 06:49:56 +00:00
|
|
|
cmd = *data++;
|
|
|
|
size |= (cmd & ~0x80) << i;
|
|
|
|
i += 7;
|
2006-04-07 19:26:10 +00:00
|
|
|
} while (cmd & 0x80 && data < top);
|
2005-06-29 06:49:56 +00:00
|
|
|
*datap = data;
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2005-05-20 20:59:17 +00:00
|
|
|
#endif
|