summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-08-11 13:43:03 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-08-11 13:43:03 +0200
commitad4fa274907bbc78ebabb015b4351d5f9226f081 (patch)
tree3eb033a3d6bedb50459ea0181e5180e1531d00e8 /lib
parent3fcf4400a7b051bdbe9fc175b88336519099ff22 (diff)
parent3a0f44a7839d475c58720c4091d5e008215cd166 (diff)
downloadbarebox-ad4fa274907bbc78ebabb015b4351d5f9226f081.tar.gz
barebox-ad4fa274907bbc78ebabb015b4351d5f9226f081.tar.xz
Merge branch 'for-next/misc'
Diffstat (limited to 'lib')
-rw-r--r--lib/logo/Kconfig1
-rw-r--r--lib/uncompress.c40
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;
+}