delta.h 903 Bytes
Newer Older
Nicolas Pitre's avatar
Nicolas Pitre committed
1 2 3 4
#ifndef DELTA_H
#define DELTA_H

/* handling of delta buffers */
5 6
extern void *diff_delta(void *from_buf, unsigned long from_size,
			void *to_buf, unsigned long to_size,
7
		        unsigned long *delta_size, unsigned long max_size);
8 9 10
extern void *patch_delta(void *src_buf, unsigned long src_size,
			 void *delta_buf, unsigned long delta_size,
			 unsigned long *dst_size);
Nicolas Pitre's avatar
Nicolas Pitre committed
11

12 13 14 15 16 17 18 19 20 21
/* 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.
 */
static inline unsigned long get_delta_hdr_size(const unsigned char **datap)
{
	const unsigned char *data = *datap;
Nicolas Pitre's avatar
Nicolas Pitre committed
22 23 24 25
	unsigned char cmd;
	unsigned long size = 0;
	int i = 0;
	do {
26 27 28
		cmd = *data++;
		size |= (cmd & ~0x80) << i;
		i += 7;
Nicolas Pitre's avatar
Nicolas Pitre committed
29
	} while (cmd & 0x80);
30 31 32 33
	*datap = data;
	return size;
}

Nicolas Pitre's avatar
Nicolas Pitre committed
34
#endif