summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2012-04-05 15:18:03 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2012-04-05 15:18:03 +0200
commit7efb8c8ef10c1d0b9479c24a6a5b4e96fc0e6286 (patch)
tree0b707ca7c07780eb20f4ad5028936fc371f99b8e /apt-pkg/contrib
parentbacc49dfe278f16859b43d159e7042e9fc22d603 (diff)
detect zlib correctly. We still don't allow to build without it to remain
compatible with users accessing it directly, but this prepares for a drop of this strict requirement in the future
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/fileutl.cc32
1 files changed, 13 insertions, 19 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 1808489d7..691657cb4 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -44,14 +44,8 @@
#include <set>
#include <algorithm>
-// FIXME: Compressor Fds have some speed disadvantages and are a bit buggy currently,
-// so while the current implementation satisfies the testcases it is not a real option
-// to disable it for now
-#define APT_USE_ZLIB 1
-#if APT_USE_ZLIB
-#include <zlib.h>
-#else
-#pragma message "Usage of zlib is DISABLED!"
+#ifdef HAVE_ZLIB
+ #include <zlib.h>
#endif
#ifdef WORDS_BIGENDIAN
@@ -65,7 +59,7 @@ using namespace std;
class FileFdPrivate {
public:
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
gzFile gz;
#else
void* gz;
@@ -1016,7 +1010,7 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
d->compressor = compressor;
if (compressor.Name == "." || compressor.Binary.empty() == true)
return true;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
else if (compressor.Name == "gzip")
{
if ((Mode & ReadWrite) == ReadWrite)
@@ -1137,7 +1131,7 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
*((char *)To) = '\0';
do
{
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d->gz != NULL)
Res = gzread(d->gz,To,Size);
else
@@ -1149,7 +1143,7 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
if (errno == EINTR)
continue;
Flags |= Fail;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d->gz != NULL)
{
int err;
@@ -1190,7 +1184,7 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
char* FileFd::ReadLine(char *To, unsigned long long const Size)
{
*To = '\0';
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d->gz != NULL)
return gzgets(d->gz, To, Size);
#endif
@@ -1221,7 +1215,7 @@ bool FileFd::Write(const void *From,unsigned long long Size)
errno = 0;
do
{
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d->gz != NULL)
Res = gzwrite(d->gz,From,Size);
else
@@ -1289,7 +1283,7 @@ bool FileFd::Seek(unsigned long long To)
return true;
}
int res;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d->gz)
res = gzseek(d->gz,To,SEEK_SET);
else
@@ -1325,7 +1319,7 @@ bool FileFd::Skip(unsigned long long Over)
}
int res;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d->gz != NULL)
res = gzseek(d->gz,Over,SEEK_CUR);
else
@@ -1373,7 +1367,7 @@ unsigned long long FileFd::Tell()
return d->seekpos;
off_t Res;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d->gz != NULL)
Res = gztell(d->gz);
else
@@ -1427,7 +1421,7 @@ unsigned long long FileFd::Size()
size = Tell();
Seek(oldSeek);
}
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
// only check gzsize if we are actually a gzip file, just checking for
// "gz" is not sufficient as uncompressed files could be opened with
// gzopen in "direct" mode as well
@@ -1500,7 +1494,7 @@ bool FileFd::Close()
bool Res = true;
if ((Flags & AutoClose) == AutoClose)
{
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d != NULL && d->gz != NULL) {
int const e = gzclose(d->gz);
// gzdclose() on empty files always fails with "buffer error" here, ignore that