63 #include <grass/config.h> 69 #include <grass/gis.h> 70 #include <grass/glocale.h> 78 unsigned int i, nbytes, buf_sz;
82 G_fatal_error(_(
"GRASS needs to be compiled with BZIP2 for BZIP2 compression"));
95 buf_sz = (
unsigned int)((
double)dst_sz * 1.01 + (double)600);
97 if (
NULL == (buf = (
unsigned char *)
98 G_calloc(buf_sz,
sizeof(
unsigned char))))
103 err = BZ2_bzBuffToBuffCompress((
char *)buf, &nbytes,
114 if (nbytes >= (
unsigned int)src_sz) {
121 if ((
unsigned int)dst_sz < nbytes)
125 for (i = 0; i < nbytes; i++)
142 G_fatal_error(_(
"GRASS needs to be compiled with BZIP2 for BZIP2 compression"));
151 if (src_sz <= 0 || dst_sz <= 0)
157 err = BZ2_bzBuffToBuffDecompress((
char *)dst, &nbytes,
166 if (!(err == BZ_OK)) {
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
int G_bz2_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
void G_free(void *buf)
Free allocated memory.
int G_bz2_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)