|
GRASS GIS 8 Programmer's Manual
8.2.1(2023)-exported
|
Go to the documentation of this file.
62 #include <grass/config.h>
68 #include <grass/gis.h>
69 #include <grass/glocale.h>
79 G_fatal_error(_(
"GRASS needs to be compiled with ZSTD for ZSTD compression"));
82 return ZSTD_compressBound(src_sz);
90 int err, nbytes, buf_sz;
94 G_fatal_error(_(
"GRASS needs to be compiled with ZSTD for ZSTD compression"));
109 if (src_sz <= 0 || dst_sz <= 0) {
111 G_warning(_(
"Invalid source buffer size %d"), src_sz);
113 G_warning(_(
"Invalid destination buffer size %d"), dst_sz);
120 if (buf_sz > dst_sz) {
121 G_warning(
"G_zstd_compress(): programmer error, destination is too small");
122 if (
NULL == (buf = (
unsigned char *)
123 G_calloc(buf_sz,
sizeof(
unsigned char))))
130 err = ZSTD_compress((
char *)buf, buf_sz, (
char *)src, src_sz, 3);
132 if (
err <= 0 || ZSTD_isError(
err)) {
133 G_warning(_(
"ZSTD compression error %d: %s"),
134 err, ZSTD_getErrorName(
err));
168 G_fatal_error(_(
"GRASS needs to be compiled with ZSTD for ZSTD compression"));
183 if (src_sz <= 0 || dst_sz <= 0) {
185 G_warning(_(
"Invalid source buffer size %d"), src_sz);
187 G_warning(_(
"Invalid destination buffer size %d"), dst_sz);
192 err = ZSTD_decompress((
char *)
dst, dst_sz, (
char *)src, src_sz);
194 if (
err <= 0 || ZSTD_isError(
err)) {
195 G_warning(_(
"ZSTD compression error %d: %s"),
196 err, ZSTD_getErrorName(
err));
203 if (nbytes != dst_sz) {
205 G_warning(_(
"Got uncompressed size %d, expected %d"), (
int)nbytes, dst_sz);
int G_zstd_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
int G_zstd_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
void G_free(void *buf)
Free allocated memory.
int G_zstd_compress_bound(int src_sz)
void G_warning(const char *msg,...)
Print a warning message to stderr.