From ecb963680530131a0d08b37b439ce6b24ba7d995 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 13 Oct 2021 15:46:31 +0200 Subject: Make zlib dependency optional --- libcrystfel/src/image-cbf.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'libcrystfel/src') diff --git a/libcrystfel/src/image-cbf.c b/libcrystfel/src/image-cbf.c index de9fc75a..51003934 100644 --- a/libcrystfel/src/image-cbf.c +++ b/libcrystfel/src/image-cbf.c @@ -32,9 +32,12 @@ #include #include #include -#include #include +#ifdef HAVE_ZLIB +#include +#endif + #include "image.h" #include "utils.h" #include "detgeom.h" @@ -284,6 +287,7 @@ static float *read_cbf_data(const char *filename, int gz, int *w, int *h) } else { + #ifdef HAVE_ZLIB gzFile gzfh; int len_read; size_t len; @@ -293,8 +297,10 @@ static float *read_cbf_data(const char *filename, int gz, int *w, int *h) gzfh = gzopen(filename, "rb"); if ( gzfh == NULL ) return NULL; + #ifdef HAVE_GZBUFFER /* Set larger buffer size for hopefully faster uncompression */ gzbuffer(gzfh, 128*1024); + #endif buf = malloc(bufsz); if ( buf == NULL ) return NULL; @@ -322,6 +328,10 @@ static float *read_cbf_data(const char *filename, int gz, int *w, int *h) gzclose(gzfh); + #else + return NULL; + #endif + } /* This is really horrible, but there are at least three different types @@ -528,6 +538,7 @@ signed int is_cbf_file(const char *filename) signed int is_cbfgz_file(const char *filename) { + #ifdef HAVE_ZLIB gzFile gzfh; char line[1024]; @@ -541,6 +552,10 @@ signed int is_cbfgz_file(const char *filename) } return 1; + + #else /* No zlib */ + return 0; + #endif } -- cgit v1.2.3