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
{
24 struct got_delta_table
{
25 struct got_delta_block
*blocks
;
30 * Index for blocks. offs[n] is zero when the slot is free,
31 * otherwise it points to blocks[offs[n] - 1].
38 struct got_delta_instruction
{
45 GOT_DELTIFY_MINCHUNK
= 32,
46 GOT_DELTIFY_MAXCHUNK
= 8192,
47 GOT_DELTIFY_SPLITMASK
= (1 << 8) - 1,
50 const struct got_error
*got_deltify_init(struct got_delta_table
**dt
, FILE *f
,
51 off_t fileoffset
, off_t filesize
, uint32_t seed
);
52 const struct got_error
*got_deltify_init_mem(struct got_delta_table
**dt
,
53 uint8_t *data
, off_t fileoffset
, off_t filesize
, uint32_t seed
);
54 const struct got_error
*got_deltify(struct got_delta_instruction
**deltas
,
55 int *ndeltas
, FILE *f
, off_t fileoffset
, off_t filesize
, uint32_t seed
,
56 struct got_delta_table
*dt
, FILE *basefile
, off_t basefile_offset0
,
58 const struct got_error
*got_deltify_file_mem(
59 struct got_delta_instruction
**deltas
, int *ndeltas
,
60 FILE *f
, off_t fileoffset
, off_t filesize
, uint32_t seed
,
61 struct got_delta_table
*dt
, uint8_t *basedata
, off_t basefile_offset0
,
63 const struct got_error
*got_deltify_mem_file(
64 struct got_delta_instruction
**deltas
, int *ndeltas
,
65 uint8_t *data
, off_t fileoffset
, off_t filesize
, uint32_t seed
,
66 struct got_delta_table
*dt
, FILE *basefile
, off_t basefile_offset0
,
68 const struct got_error
*got_deltify_mem_mem(
69 struct got_delta_instruction
**deltas
, int *ndeltas
,
70 uint8_t *data
, off_t fileoffset
, off_t filesize
, uint32_t seed
,
71 struct got_delta_table
*dt
, uint8_t *basedata
, off_t basefile_offset0
,
73 void got_deltify_free(struct got_delta_table
*dt
);