21
21
aggregate source */
25
/* result type for functions that have multiple failure modes */
27
DELTA_OK, /* Success */
28
DELTA_OUT_OF_MEMORY, /* Could not allocate required memory */
29
DELTA_INDEX_NEEDED, /* A delta_index must be passed */
30
DELTA_SOURCE_EMPTY, /* A source_info had no content */
31
DELTA_SOURCE_BAD, /* A source_info had invalid or corrupt content */
32
DELTA_BUFFER_EMPTY, /* A buffer pointer and size */
33
DELTA_SIZE_TOO_BIG, /* Delta data is larger than the max requested */
38
25
* create_delta_index: compute index data from given buffer
40
* Returns a delta_result status, when DELTA_OK then *fresh is set to a struct
41
* delta_index that should be passed to subsequent create_delta() calls, or to
42
* free_delta_index(). Other values are a failure, and *fresh is unset.
43
* The given buffer must not be freed nor altered before free_delta_index() is
44
* called. The resultant struct must be freed using free_delta_index().
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().
33
extern struct delta_index *
47
34
create_delta_index(const struct source_info *src,
48
struct delta_index *old,
49
struct delta_index **fresh);
35
struct delta_index *old);
53
39
* create_delta_index_from_delta: compute index data from given buffer
55
* Returns a delta_result status, when DELTA_OK then *fresh is set to a struct
56
* delta_index that should be passed to subsequent create_delta() calls, or to
57
* free_delta_index(). Other values are a failure, and *fresh is unset.
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.
58
44
* The bytes must be in the form of a delta structure, as generated by
59
45
* create_delta(). The generated index will only index the insert bytes, and
60
46
* not any of the control structures.
48
extern struct delta_index *
63
49
create_delta_index_from_delta(const struct source_info *delta,
64
struct delta_index *old,
65
struct delta_index **fresh);
50
struct delta_index *old);
67
52
* free_delta_index: free the index created by create_delta_index()
83
68
* This function may be called multiple times with different buffers using
84
69
* the same delta_index pointer. If max_delta_size is non-zero and the
85
* resulting delta is to be larger than max_delta_size then DELTA_SIZE_TOO_BIG
86
* is returned. Otherwise on success, DELTA_OK is returned and *delta_data is
87
* set to a new buffer with the delta data and *delta_size is updated with its
88
* size. That buffer must be freed by the caller.
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.
91
76
create_delta(const struct delta_index *index,
92
const void *buf, unsigned long bufsize,
93
unsigned long *delta_size, unsigned long max_delta_size,
77
const void *buf, unsigned long bufsize,
78
unsigned long *delta_size, unsigned long max_delta_size);
96
80
/* the smallest possible delta size is 3 bytes
97
81
* Target size, Copy command, Copy length