Blob


1 /*
2 * Copyright (c) 2020 Ori Bernstein
3 * Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
18 struct got_delta_block {
19 off_t len;
20 off_t offset;
21 uint64_t hash;
22 };
24 struct got_delta_table {
25 struct got_delta_block *blocks;
26 int nblocks;
27 int nalloc;
28 };
30 struct got_delta_instruction {
31 int copy;
32 off_t offset;
33 off_t len;
34 };
36 enum {
37 GOT_DELTIFY_MINCHUNK = 128,
38 GOT_DELTIFY_MAXCHUNK = 8192,
39 GOT_DELTIFY_SPLITMASK = (1 << 8) - 1,
41 };
43 const struct got_error *got_deltify_init(struct got_delta_table **dt, FILE *f,
44 off_t fileoffset, off_t filesize);
45 const struct got_error *got_deltify(struct got_delta_instruction **deltas,
46 int *ndeltas, FILE *f, off_t fileoffset, off_t filesize,
47 struct got_delta_table *dt, FILE *basefile, off_t basefile_size);
48 void got_deltify_free(struct got_delta_table *dt);