blob: 075456b28ca23296487e6d504863468703f3a62f (
plain) (
tree)
|
|
/*
* Copyright (c) 2020-2022, yzrh <yzrh@noema.org>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <string.h>
#include "zlib.h"
int
cnki_zlib(char **dst, int *dst_size,
const char * restrict src, int src_size)
{
uint8_t padding = 0;
int32_t size;
if (strncmp(src + 8, "COMPRESSTEXT", 12) == 0)
padding = 8;
memcpy(&size, src + 12 + padding, 4);
*dst_size = size;
if (strinflate(dst, size, src + 16 + padding, src_size - 16 - padding) != 0)
return 1;
return 0;
}
|