aboutsummaryrefslogtreecommitdiffstats
path: root/src/cnki_zlib.c
diff options
context:
space:
mode:
authoryzrh <yzrh@noema.org>2020-12-30 03:09:00 +0000
committeryzrh <yzrh@noema.org>2020-12-30 03:09:00 +0000
commit98691d4203f4e578b84b2014db0fbe0c1209cc48 (patch)
treec528e3ea964111b934ae5e61e847831d62944f41 /src/cnki_zlib.c
parent8d6fbb43c9bc840d4217bf4f0b49b1213f1601a1 (diff)
downloadmelon-98691d4203f4e578b84b2014db0fbe0c1209cc48.tar.gz
melon-98691d4203f4e578b84b2014db0fbe0c1209cc48.tar.zst
Add HN text extraction.
Diffstat (limited to 'src/cnki_zlib.c')
-rw-r--r--src/cnki_zlib.c20
1 files changed, 19 insertions, 1 deletions
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 <zlib.h>
+#include <stdint.h>
+#include <string.h>
+
+#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;
+}