1 #include <assert.h>
2 #include <libdeflate.h>
3 #include <fcntl.h>
4 #include <unistd.h>
5 #include <sys/stat.h>
6
main(int argc,char ** argv)7 int main(int argc, char **argv)
8 {
9 struct libdeflate_decompressor *d;
10 int ret;
11 int fd = open(argv[1], O_RDONLY);
12 struct stat stbuf;
13 assert(fd >= 0);
14 ret = fstat(fd, &stbuf);
15 assert(!ret);
16
17 char in[stbuf.st_size];
18 ret = read(fd, in, sizeof in);
19 assert(ret == sizeof in);
20
21 char out[sizeof(in) * 3];
22
23 d = libdeflate_alloc_decompressor();
24
25 libdeflate_zlib_decompress(d, in, sizeof in, out, sizeof out, NULL);
26 libdeflate_free_decompressor(d);
27 return 0;
28 }
29