2
* delta.h: headers for delta functionality
4
* Adapted from GIT for Bazaar by
5
* John Arbash Meinel <john@arbash-meinel.com> (C) 2009
7
* This code is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License version 2 as
9
* published by the Free Software Foundation.
14
6
/* opaque object for delta index */
17
9
struct source_info {
18
const void *buf; /* Pointer to the beginning of source data */
19
unsigned long size; /* Total length of source data */
20
unsigned long agg_offset; /* Start of source data as part of the
10
const void *buf; /* Pointer to the beginning of source data */
11
unsigned long size; /* Total length of source data */
12
unsigned long agg_offset; /* Start of source data as part of the
33
25
extern struct delta_index *
34
26
create_delta_index(const struct source_info *src,
35
struct delta_index *old);
27
const struct delta_index *old);
48
40
extern struct delta_index *
49
41
create_delta_index_from_delta(const struct source_info *delta,
50
struct delta_index *old);
42
const struct delta_index *old);
52
44
* free_delta_index: free the index created by create_delta_index()
76
68
create_delta(const struct delta_index *index,
77
const void *buf, unsigned long bufsize,
78
unsigned long *delta_size, unsigned long max_delta_size);
69
const void *buf, unsigned long bufsize,
70
unsigned long *delta_size, unsigned long max_delta_size);
80
/* the smallest possible delta size is 3 bytes
81
* Target size, Copy command, Copy length
83
#define DELTA_SIZE_MIN 3
72
/* the smallest possible delta size is 4 bytes */
73
#define DELTA_SIZE_MIN 4
86
76
* This must be called twice on the delta data buffer, first to get the
87
77
* expected source buffer size, and again to get the target buffer size.
90
get_delta_hdr_size(unsigned char **datap, const unsigned char *top)
79
static inline unsigned long get_delta_hdr_size(const unsigned char **datap,
80
const unsigned char *top)
92
unsigned char *data = *datap;
94
unsigned long size = 0;
98
size |= (cmd & ~0x80) << i;
100
} while (cmd & 0x80 && data < top);
82
const unsigned char *data = *datap;
84
unsigned long size = 0;
88
size |= (cmd & ~0x80) << i;
90
} while (cmd & 0x80 && data < top);