portable: configure: use config.h
[got-portable.git] / lib / got_lib_deltify.h
blob23d51d665edd5927c4b9ca18e2ebebf3473b1795
1 /*
2 * Copyright (c) 2020 Ori Bernstein
3 * Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
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.
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.
18 struct got_delta_block {
19 off_t len;
20 off_t offset;
21 uint32_t hash;
24 struct got_delta_table {
25 struct got_delta_block *blocks;
26 int nblocks;
27 int nalloc;
30 struct got_delta_instruction {
31 int copy;
32 off_t offset;
33 off_t len;
36 enum {
37 GOT_DELTIFY_MINCHUNK = 32,
38 GOT_DELTIFY_MAXCHUNK = 8192,
39 GOT_DELTIFY_SPLITMASK = (1 << 8) - 1,
42 const struct got_error *got_deltify_init(struct got_delta_table **dt, FILE *f,
43 off_t fileoffset, off_t filesize, uint32_t seed);
44 const struct got_error *got_deltify_init_mem(struct got_delta_table **dt,
45 uint8_t *data, off_t fileoffset, off_t filesize, uint32_t seed);
46 const struct got_error *got_deltify(struct got_delta_instruction **deltas,
47 int *ndeltas, FILE *f, off_t fileoffset, off_t filesize, uint32_t seed,
48 struct got_delta_table *dt, FILE *basefile, off_t basefile_offset0,
49 off_t basefile_size);
50 const struct got_error *got_deltify_file_mem(
51 struct got_delta_instruction **deltas, int *ndeltas,
52 FILE *f, off_t fileoffset, off_t filesize, uint32_t seed,
53 struct got_delta_table *dt, uint8_t *basedata, off_t basefile_offset0,
54 off_t basefile_size);
55 const struct got_error *got_deltify_mem_file(
56 struct got_delta_instruction **deltas, int *ndeltas,
57 uint8_t *data, off_t fileoffset, off_t filesize, uint32_t seed,
58 struct got_delta_table *dt, FILE *basefile, off_t basefile_offset0,
59 off_t basefile_size);
60 const struct got_error *got_deltify_mem_mem(
61 struct got_delta_instruction **deltas, int *ndeltas,
62 uint8_t *data, off_t fileoffset, off_t filesize, uint32_t seed,
63 struct got_delta_table *dt, uint8_t *basedata, off_t basefile_offset0,
64 off_t basefile_size);
65 void got_deltify_free(struct got_delta_table *dt);