From 98691d4203f4e578b84b2014db0fbe0c1209cc48 Mon Sep 17 00:00:00 2001 From: yzrh Date: Wed, 30 Dec 2020 03:09:00 +0000 Subject: Add HN text extraction. --- src/zlib.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/zlib.c (limited to 'src/zlib.c') diff --git a/src/zlib.c b/src/zlib.c new file mode 100644 index 0000000..49004b7 --- /dev/null +++ b/src/zlib.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020, yzrh + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +#include + +int +strinflate(char **dst, int dst_size, + const char * restrict src, int src_size) +{ + *dst = malloc(dst_size); + + if (*dst == NULL) + return 1; + + unsigned long size = dst_size; + + uncompress((Bytef *) *dst, &size, (const Bytef *) src, src_size); + + if (size != dst_size) { + free(*dst); + return 1; + } + + return 0; +} -- cgit v1.2.3