From 80598eb9c1cf339151a66e3bdf1b7756efdde1a2 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 27 Dec 2011 14:11:18 -0500 Subject: [PATCH] zlib is now mandatory. --- citadel/configure.ac | 31 +++++++++++++++++-------------- citadel/database.c | 33 ++++----------------------------- webcit/configure.ac | 30 +++++++++++++++++------------- webcit/webcit.h | 2 -- 4 files changed, 38 insertions(+), 58 deletions(-) diff --git a/citadel/configure.ac b/citadel/configure.ac index 4e0982cbe..8401e58b0 100644 --- a/citadel/configure.ac +++ b/citadel/configure.ac @@ -171,20 +171,23 @@ AC_SUBST(LOCALEDIR) dnl Checks for the zlib compression library. -if test "x$with_zlib" != xno ; then - AC_CHECK_HEADERS(zlib.h, - [AC_CHECK_LIB(z, zlibVersion, - [ok_zlib=yes],, - )]) -fi - -if test "x$ok_zlib" = xyes ; then - LDFLAGS="-lz $LDFLAGS" - AC_DEFINE(HAVE_ZLIB, [], [define this if you have zlib compression available]) -fi - - - +saved_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $SERVER_LIBS" +AC_CHECK_HEADER(zlib.h, + [AC_CHECK_LIB(z, zlibVersion, + [ + LIBS="-lz $LIBS $SERVER_LIBS" + ], + [ + AC_MSG_ERROR(zlib was not found or is not usable. Please install zlib.) + ] + , + )], + [ + AC_MSG_ERROR(zlib.h was not found or is not usable. Please install zlib.) + ] +) +CFLAGS="$saved_CFLAGS" dnl Here is the check for a libc integrated iconv AC_ARG_ENABLE(iconv, diff --git a/citadel/database.c b/citadel/database.c index 141e74bf7..4eb34cdd7 100644 --- a/citadel/database.c +++ b/citadel/database.c @@ -1,22 +1,16 @@ /* * This is a data store backend for the Citadel server which uses Berkeley DB. * - * Copyright (c) 1987-2011 by the citadel.org team + * Copyright (c) 1987-2012 by the citadel.org team * * This program is open source software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. + * modify it under the terms of the GNU General Public License version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * */ /***************************************************************************** @@ -43,6 +37,7 @@ #include #include #include +#include #ifdef HAVE_DB_H #include @@ -76,10 +71,6 @@ static DB *dbp[MAXCDB]; /* One DB handle for each Citadel database */ static DB_ENV *dbenv; /* The DB environment (global) */ -#ifdef HAVE_ZLIB -#include -#endif - /* Verbose logging callback */ void cdb_verbose_log(const DB_ENV *dbenv, const char *msg) @@ -283,9 +274,7 @@ void open_databases(void) CitControl.MMdbversion = current_dbversion; put_control(); -#ifdef HAVE_ZLIB syslog(LOG_INFO, "Linked zlib: %s\n", zlibVersion()); -#endif /* * Silently try to create the database subdirectory. If it's @@ -473,7 +462,7 @@ void close_databases(void) /* - * Compression functions only used if we have zlib + * Decompress a database item if it was compressed on disk */ void cdb_decompress_if_necessary(struct cdbdata *cdb) { @@ -485,7 +474,6 @@ void cdb_decompress_if_necessary(struct cdbdata *cdb) (memcmp(cdb->ptr, &magic, sizeof(magic)))) return; -#ifdef HAVE_ZLIB /* At this point we know we're looking at a compressed item. */ struct CtdlCompressHeader zheader; @@ -518,11 +506,6 @@ void cdb_decompress_if_necessary(struct cdbdata *cdb) free(cdb->ptr); cdb->len = (size_t) destLen; cdb->ptr = uncompressed_data; -#else /* HAVE_ZLIB */ - syslog(LOG_EMERG, "Database contains compressed data, but this citserver was built without compression support."); - syslog(LOG_EMERG, "Please see http://www.citadel.org/doku.php/faq:installation:zlib for more information."); - exit(CTDLEXIT_DB); -#endif /* HAVE_ZLIB */ } @@ -538,13 +521,11 @@ int cdb_store(int cdb, const void *ckey, int ckeylen, void *cdata, int cdatalen) DB_TXN *tid; int ret = 0; -#ifdef HAVE_ZLIB struct CtdlCompressHeader zheader; char *compressed_data = NULL; int compressing = 0; size_t buffer_len = 0; uLongf destLen = 0; -#endif memset(&dkey, 0, sizeof(DBT)); memset(&ddata, 0, sizeof(DBT)); @@ -553,7 +534,6 @@ int cdb_store(int cdb, const void *ckey, int ckeylen, void *cdata, int cdatalen) ddata.size = cdatalen; ddata.data = cdata; -#ifdef HAVE_ZLIB /* Only compress Visit records. Everything else is uncompressed. */ if (cdb == CDB_VISIT) { compressing = 1; @@ -574,7 +554,6 @@ int cdb_store(int cdb, const void *ckey, int ckeylen, void *cdata, int cdatalen) ddata.size = (size_t) (sizeof(struct CtdlCompressHeader) + zheader.compressed_len); ddata.data = compressed_data; } -#endif if (TSD->tid != NULL) { ret = dbp[cdb]->put(dbp[cdb], /* db */ @@ -586,10 +565,8 @@ int cdb_store(int cdb, const void *ckey, int ckeylen, void *cdata, int cdatalen) syslog(LOG_EMERG, "cdb_store(%d): %s", cdb, db_strerror(ret)); abort(); } -#ifdef HAVE_ZLIB if (compressing) free(compressed_data); -#endif return ret; } else { @@ -612,11 +589,9 @@ int cdb_store(int cdb, const void *ckey, int ckeylen, void *cdata, int cdatalen) } } else { txcommit(tid); -#ifdef HAVE_ZLIB if (compressing) { free(compressed_data); } -#endif return ret; } } diff --git a/webcit/configure.ac b/webcit/configure.ac index 6819bb28a..ba0d46d31 100644 --- a/webcit/configure.ac +++ b/webcit/configure.ac @@ -140,18 +140,23 @@ AC_CHECK_HEADER(CUnit/CUnit.h, [AC_DEFINE(ENABLE_TESTS, [], [whether we should c AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h iconv.h xlocale.h) dnl Checks for the zlib compression library. -if test "x$with_zlib" != xno ; then - AC_CHECK_HEADERS(zlib.h, - [AC_CHECK_LIB(z, zlibVersion, - [ok_zlib=yes],, - )]) -fi - -if test "x$ok_zlib" = xyes ; then -dnl libcitadel will bring libz, so we don't need it here. LDFLAGS="-lz $LDFLAGS" - AC_DEFINE(HAVE_ZLIB, [], [define this if you have zlib compression available]) -fi - +saved_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $SERVER_LIBS" +AC_CHECK_HEADER(zlib.h, + [AC_CHECK_LIB(z, zlibVersion, + [ + LIBS="-lz $LIBS $SERVER_LIBS" + ], + [ + AC_MSG_ERROR(zlib was not found or is not usable. Please install zlib.) + ] + , + )], + [ + AC_MSG_ERROR(zlib.h was not found or is not usable. Please install zlib.) + ] +) +CFLAGS="$saved_CFLAGS" dnl Here is the check for a libc integrated iconv AC_ARG_ENABLE(iconv, @@ -547,5 +552,4 @@ fi echo ------------------------------------------------------------------------ echo 'Character set conversion support:' $ok_iconv echo 'National language support: ' $ok_nls -echo 'Compression support: ' $ok_zlib echo diff --git a/webcit/webcit.h b/webcit/webcit.h index de01cf42b..c46e8b4b5 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -76,9 +76,7 @@ #define DBG_QR(x) if(DO_DBG_QR) _DBG_QR(x) #define DBG_QR2(x) if(DO_DBG_QR) _DBG_QR2(x) -#ifdef HAVE_ZLIB_H #include -#endif #include -- 2.30.2