blob: b8ba945a0f12f62ab54ca6c33a22d16019eb47b4 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001#ifndef PATCH_H
2#define PATCH_H
3
4// Image patch chunk types
5#define CHUNK_NORMAL 0
6#define CHUNK_GZIP 1 // version 1 only
7#define CHUNK_DEFLATE 2 // version 2 only
8#define CHUNK_RAW 3 // version 2 only
9
10// The gzip header size is actually variable, but we currently don't
11// support gzipped data with any of the optional fields, so for now it
12// will always be ten bytes. See RFC 1952 for the definition of the
13// gzip format.
14#define GZIP_HEADER_LEN 10
15
16// The gzip footer size really is fixed.
17#define GZIP_FOOTER_LEN 8
18
19int lzma_decompress(unsigned char *data_in, unsigned char *cpage_out,
20 ssize_t srclen, ssize_t dstlen);
21
22int ApplyBSDiffPatch(const unsigned char *old_data, ssize_t old_size,
23 unsigned char *patch, ssize_t patch_size, ssize_t patch_offset,
24 unsigned char **new_data, ssize_t *new_size);
25
26int ApplyImagePatch(unsigned char *old_data, ssize_t old_size,
27 unsigned char *patch, ssize_t patch_size,
28 unsigned char **new_data, ssize_t *new_size,
29 int seg_num);
30
31int ApplyOverridePatch(const unsigned char* old_data, ssize_t old_size,
32 unsigned char* patch, ssize_t patch_size, ssize_t patch_offset,
33 unsigned char** new_data, ssize_t* new_size);
34
35unsigned char *lzma_decode(const char *file_name, size_t *out_sz);
36int lzma_encode(const char *in, ssize_t in_len, char *out_file);
37
38#endif /*PATCH_H*/