diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/logo/Kconfig | 1 | ||||
-rw-r--r-- | lib/uncompress.c | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/lib/logo/Kconfig b/lib/logo/Kconfig index de3494eccf..7e5a6fcb63 100644 --- a/lib/logo/Kconfig +++ b/lib/logo/Kconfig @@ -2,6 +2,7 @@ menuconfig BAREBOX_LOGO bool "include barebox logos in build" + depends on IMAGE_RENDERER help Say yes here to build the barebox logos. This adds ImageMagick's convert tool to the build dependencies. The logo can be found under diff --git a/lib/uncompress.c b/lib/uncompress.c index 5c0d1e9f4d..0608e9f9d3 100644 --- a/lib/uncompress.c +++ b/lib/uncompress.c @@ -172,3 +172,43 @@ int uncompress_fd_to_buf(int infd, void *output, return uncompress(NULL, 0, fill_fd, NULL, output, NULL, error_fn); } + +int uncompress_buf_to_fd(const void *input, size_t input_len, + int outfd, void(*error_fn)(char *x)) +{ + uncompress_outfd = outfd; + + return uncompress((void *)input, input_len, NULL, flush_fd, + NULL, NULL, error_fn); +} + +ssize_t uncompress_buf_to_buf(const void *input, size_t input_len, + void **buf, void(*error_fn)(char *x)) +{ + char *dstpath; + size_t size; + int outfd, ret; + + dstpath = make_temp("data-uncompressed"); + if (!dstpath) + return -ENOMEM; + + outfd = open(dstpath, O_CREAT | O_WRONLY); + if (outfd < 0) { + ret = -ENODEV; + goto free_temp; + } + + ret = uncompress_buf_to_fd(input, input_len, outfd, uncompress_err_stdout); + if (ret) + goto close_outfd; + + *buf = read_file(dstpath, &size); +close_outfd: + close(outfd); + unlink(dstpath); +free_temp: + free(dstpath); + + return ret ?: size; +} |