GRASS GIS 7 Programmer's Manual
7.8.4(2020)-exported
|
Go to the documentation of this file.
63 #include <grass/config.h>
69 #include <grass/gis.h>
70 #include <grass/glocale.h>
80 G_fatal_error(_(
"GRASS needs to be compiled with ZSTD for ZSTD compression"));
83 return ZSTD_compressBound(src_sz);
91 int err, nbytes, buf_sz;
95 G_fatal_error(_(
"GRASS needs to be compiled with ZSTD for ZSTD compression"));
110 if (src_sz <= 0 || dst_sz <= 0) {
112 G_warning(_(
"Invalid source buffer size %d"), src_sz);
114 G_warning(_(
"Invalid destination buffer size %d"), dst_sz);
121 if (buf_sz > dst_sz) {
122 G_warning(
"G_zstd_compress(): programmer error, destination is too small");
123 if (
NULL == (buf = (
unsigned char *)
124 G_calloc(buf_sz,
sizeof(
unsigned char))))
131 err = ZSTD_compress((
char *)buf, buf_sz, (
char *)src, src_sz, 3);
133 if (
err <= 0 || ZSTD_isError(
err)) {
134 G_warning(_(
"ZSTD compression error %d: %s"),
135 err, ZSTD_getErrorName(
err));
169 G_fatal_error(_(
"GRASS needs to be compiled with ZSTD for ZSTD compression"));
184 if (src_sz <= 0 || dst_sz <= 0) {
186 G_warning(_(
"Invalid source buffer size %d"), src_sz);
188 G_warning(_(
"Invalid destination buffer size %d"), dst_sz);
193 err = ZSTD_decompress((
char *)
dst, dst_sz, (
char *)src, src_sz);
195 if (
err <= 0 || ZSTD_isError(
err)) {
196 G_warning(_(
"ZSTD compression error %d: %s"),
197 err, ZSTD_getErrorName(
err));
204 if (nbytes != dst_sz) {
206 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.