0.17.31
by John Arbash Meinel
Bring in the 'rabin' experiment. |
1 |
/*
|
2 |
* delta.h: headers for delta functionality
|
|
3 |
*
|
|
4 |
* Adapted from GIT for Bazaar by
|
|
5 |
* John Arbash Meinel <john@arbash-meinel.com> (C) 2009
|
|
6 |
*
|
|
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.
|
|
10 |
*/
|
|
0.23.5
by John Arbash Meinel
Minor changes to get diff-delta.c and patch-delta.c to compile. |
11 |
#ifndef DELTA_H
|
12 |
#define DELTA_H
|
|
13 |
||
14 |
/* opaque object for delta index */
|
|
15 |
struct delta_index; |
|
16 |
||
0.23.42
by John Arbash Meinel
Change the code around again. |
17 |
struct source_info { |
0.23.57
by John Arbash Meinel
Change the formatting, replace \t with spaces to be consistent with bzr coding. |
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 |
|
21 |
aggregate source */
|
|
0.23.42
by John Arbash Meinel
Change the code around again. |
22 |
};
|
23 |
||
0.23.5
by John Arbash Meinel
Minor changes to get diff-delta.c and patch-delta.c to compile. |
24 |
/*
|
25 |
* create_delta_index: compute index data from given buffer
|
|
26 |
*
|
|
27 |
* This returns a pointer to a struct delta_index that should be passed to
|
|
28 |
* subsequent create_delta() calls, or to free_delta_index(). A NULL pointer
|
|
29 |
* is returned on failure. The given buffer must not be freed nor altered
|
|
30 |
* before free_delta_index() is called. The returned pointer must be freed
|
|
31 |
* using free_delta_index().
|
|
32 |
*/
|
|
33 |
extern struct delta_index * |
|
0.23.43
by John Arbash Meinel
Change the internals to allow delta indexes to be expanded with new source data. |
34 |
create_delta_index(const struct source_info *src, |
3735.33.12
by John Arbash Meinel
Now we are able to weave 'add_source' into the existing index. |
35 |
struct delta_index *old); |
0.23.5
by John Arbash Meinel
Minor changes to get diff-delta.c and patch-delta.c to compile. |
36 |
|
0.23.45
by John Arbash Meinel
Add a function that updates the index for delta bytes. |
37 |
|
38 |
/*
|
|
39 |
* create_delta_index_from_delta: compute index data from given buffer
|
|
40 |
*
|
|
41 |
* This returns a pointer to a struct delta_index that should be passed to
|
|
42 |
* subsequent create_delta() calls, or to free_delta_index(). A NULL pointer
|
|
43 |
* is returned on failure.
|
|
44 |
* The bytes must be in the form of a delta structure, as generated by
|
|
45 |
* create_delta(). The generated index will only index the insert bytes, and
|
|
46 |
* not any of the control structures.
|
|
47 |
*/
|
|
48 |
extern struct delta_index * |
|
49 |
create_delta_index_from_delta(const struct source_info *delta, |
|
3735.33.4
by John Arbash Meinel
The new layout is working. |
50 |
struct delta_index *old); |
0.23.5
by John Arbash Meinel
Minor changes to get diff-delta.c and patch-delta.c to compile. |
51 |
/*
|
52 |
* free_delta_index: free the index created by create_delta_index()
|
|
53 |
*
|
|
54 |
* Given pointer must be what create_delta_index() returned, or NULL.
|
|
55 |
*/
|
|
56 |
extern void free_delta_index(struct delta_index *index); |
|
57 |
||
58 |
/*
|
|
59 |
* sizeof_delta_index: returns memory usage of delta index
|
|
60 |
*
|
|
61 |
* Given pointer must be what create_delta_index() returned, or NULL.
|
|
62 |
*/
|
|
63 |
extern unsigned long sizeof_delta_index(struct delta_index *index); |
|
64 |
||
65 |
/*
|
|
66 |
* create_delta: create a delta from given index for the given buffer
|
|
67 |
*
|
|
68 |
* This function may be called multiple times with different buffers using
|
|
69 |
* the same delta_index pointer. If max_delta_size is non-zero and the
|
|
70 |
* resulting delta is to be larger than max_delta_size then NULL is returned.
|
|
71 |
* On success, a non-NULL pointer to the buffer with the delta data is
|
|
72 |
* returned and *delta_size is updated with its size. The returned buffer
|
|
73 |
* must be freed by the caller.
|
|
74 |
*/
|
|
75 |
extern void * |
|
0.23.44
by John Arbash Meinel
Remove the multi-index handling now that we have index combining instead. |
76 |
create_delta(const struct delta_index *index, |
0.23.57
by John Arbash Meinel
Change the formatting, replace \t with spaces to be consistent with bzr coding. |
77 |
const void *buf, unsigned long bufsize, |
78 |
unsigned long *delta_size, unsigned long max_delta_size); |
|
0.23.5
by John Arbash Meinel
Minor changes to get diff-delta.c and patch-delta.c to compile. |
79 |
|
3735.38.1
by John Arbash Meinel
Change the delta byte stream to remove the 'source length' entry. |
80 |
/* the smallest possible delta size is 3 bytes
|
81 |
* Target size, Copy command, Copy length
|
|
82 |
*/
|
|
83 |
#define DELTA_SIZE_MIN 3
|
|
0.23.5
by John Arbash Meinel
Minor changes to get diff-delta.c and patch-delta.c to compile. |
84 |
|
85 |
/*
|
|
86 |
* This must be called twice on the delta data buffer, first to get the
|
|
87 |
* expected source buffer size, and again to get the target buffer size.
|
|
88 |
*/
|
|
3735.36.7
by John Arbash Meinel
Get rid of inline and const, to reduce warnings and errors. |
89 |
static unsigned long |
90 |
get_delta_hdr_size(unsigned char **datap, const unsigned char *top) |
|
0.23.5
by John Arbash Meinel
Minor changes to get diff-delta.c and patch-delta.c to compile. |
91 |
{
|
3735.36.7
by John Arbash Meinel
Get rid of inline and const, to reduce warnings and errors. |
92 |
unsigned char *data = *datap; |
0.23.57
by John Arbash Meinel
Change the formatting, replace \t with spaces to be consistent with bzr coding. |
93 |
unsigned char cmd; |
94 |
unsigned long size = 0; |
|
95 |
int i = 0; |
|
96 |
do { |
|
97 |
cmd = *data++; |
|
98 |
size |= (cmd & ~0x80) << i; |
|
99 |
i += 7; |
|
100 |
} while (cmd & 0x80 && data < top); |
|
101 |
*datap = data; |
|
102 |
return size; |
|
0.23.5
by John Arbash Meinel
Minor changes to get diff-delta.c and patch-delta.c to compile. |
103 |
}
|
104 |
||
105 |
#endif
|