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/cnki_zlib.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/cnki_zlib.c') diff --git a/src/cnki_zlib.c b/src/cnki_zlib.c index 4355433..fd4cedf 100644 --- a/src/cnki_zlib.c +++ b/src/cnki_zlib.c @@ -4,4 +4,22 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include +#include + +#include "zlib.h" + +int +cnki_zlib(char **dst, int *dst_size, + const char * restrict src, int src_size) +{ + int32_t size; + memcpy(&size, src + 20, 4); + + *dst_size = size; + + if (strinflate(dst, size, src + 24, size - 24) != 0) + return 1; + + return 0; +} -- cgit v1.2.3