Eric Biggers bf50c64e86 scripts: rename tools/ directory to scripts/
"scripts" is a more descriptive name than "tools", which sounds too
similar to "programs".
2020-10-18 15:14:15 -07:00

29 lines
570 B
C

#include <assert.h>
#include <libdeflate.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
int main(int argc, char **argv)
{
struct libdeflate_decompressor *d;
int ret;
int fd = open(argv[1], O_RDONLY);
struct stat stbuf;
assert(fd >= 0);
ret = fstat(fd, &stbuf);
assert(!ret);
char in[stbuf.st_size];
ret = read(fd, in, sizeof in);
assert(ret == sizeof in);
char out[sizeof(in) * 3];
d = libdeflate_alloc_decompressor();
libdeflate_zlib_decompress(d, in, sizeof in, out, sizeof out, NULL);
libdeflate_free_decompressor(d);
return 0;
}