[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23096 - Extractor/src/main
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23096 - Extractor/src/main |
Date: |
Sat, 4 Aug 2012 20:48:26 +0200 |
Author: grothoff
Date: 2012-08-04 20:48:26 +0200 (Sat, 04 Aug 2012)
New Revision: 23096
Modified:
Extractor/src/main/TODO
Extractor/src/main/extractor_datasource.c
Log:
adding missing #ifdefs for libz, starting with bz2 code
Modified: Extractor/src/main/TODO
===================================================================
--- Extractor/src/main/TODO 2012-08-04 18:39:59 UTC (rev 23095)
+++ Extractor/src/main/TODO 2012-08-04 18:48:26 UTC (rev 23096)
@@ -1,5 +1,4 @@
* bz2 decompression (not implemented)
-* extract-from-gz-file test fails!
* extract-from-bz2-file test fails!
* MAX_META_DATA buffer of 32 MB is a bit big as a non-growing default size;
Modified: Extractor/src/main/extractor_datasource.c
===================================================================
--- Extractor/src/main/extractor_datasource.c 2012-08-04 18:39:59 UTC (rev
23095)
+++ Extractor/src/main/extractor_datasource.c 2012-08-04 18:48:26 UTC (rev
23096)
@@ -447,6 +447,7 @@
}
+#if HAVE_ZLIB
/**
* Reset gz-compressed data stream to the beginning.
*
@@ -483,8 +484,10 @@
cfs->fpos = 0;
return 1;
}
+#endif
+#if HAVE_LIBBZ2
/**
* Reset bz2-compressed data stream to the beginning.
*
@@ -494,10 +497,16 @@
static int
cfs_reset_stream_bz2 (struct CompressedFileSource *cfs)
{
- /* not implemented */
- LOG ("bz2 decompression not implemented\n");
- return -1;
+ BZ2_bzDecompressEnd (&cfs->bstrm);
+ if (BZ_OK !=
+ BZ2_bzDecompressInit (&cfs->bstrm, 0, 0))
+ {
+ LOG ("Failed to reinitialize BZ2 decompressor\n");
+ return -1;
+ }
+ return 1;
}
+#endif
/**
@@ -514,10 +523,14 @@
{
switch (cfs->compression_type)
{
+#if HAVE_ZLIB
case COMP_TYPE_ZLIB:
return cfs_reset_stream_zlib (cfs);
+#endif
+#if HAVE_LIBBZ2
case COMP_TYPE_BZ2:
return cfs_reset_stream_bz2 (cfs);
+#endif
default:
LOG ("invalid compression type selected\n");
return -1;
@@ -525,6 +538,7 @@
}
+#if HAVE_ZLIB
/**
* Initializes gz-decompression object. Might report metadata about
* compresse stream, if available. Resets the stream to the beginning.
@@ -628,8 +642,10 @@
cfs->gzip_header_length = gzip_header_length;
return cfs_reset_stream_zlib (cfs);
}
+#endif
+#if HAVE_LIBBZ2
/**
* Initializes bz2-decompression object. Might report metadata about
* compresse stream, if available. Resets the stream to the beginning.
@@ -643,9 +659,12 @@
cfs_init_decompressor_bz2 (struct CompressedFileSource *cfs,
EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
{
- LOG ("bz2 decompression not implemented\n");
- return -1;
+ if (BZ_OK !=
+ BZ2_bzDecompressInit (&cfs->bstrm, 0, 0))
+ return -1;
+ return 1;
}
+#endif
/**
@@ -663,10 +682,14 @@
{
switch (cfs->compression_type)
{
+#if HAVE_ZLIB
case COMP_TYPE_ZLIB:
return cfs_init_decompressor_zlib (cfs, proc, proc_cls);
+#endif
+#if HAVE_LIBBZ2
case COMP_TYPE_BZ2:
return cfs_init_decompressor_bz2 (cfs, proc, proc_cls);
+#endif
default:
LOG ("invalid compression type selected\n");
return -1;
@@ -674,6 +697,7 @@
}
+#if HAVE_ZLIB
/**
* Deinitializes gz-decompression object.
*
@@ -686,8 +710,10 @@
inflateEnd (&cfs->strm);
return 1;
}
+#endif
+#if HAVE_LIBBZ2
/**
* Deinitializes bz2-decompression object.
*
@@ -697,9 +723,10 @@
static int
cfs_deinit_decompressor_bz2 (struct CompressedFileSource *cfs)
{
- LOG ("bz2 decompression not implemented\n");
- return -1;
+ BZ2_bzDecompressEnd (&cfs->bstrm);
+ return 1;
}
+#endif
/**
@@ -713,10 +740,14 @@
{
switch (cfs->compression_type)
{
+#if HAVE_ZLIB
case COMP_TYPE_ZLIB:
return cfs_deinit_decompressor_zlib (cfs);
+#endif
+#if HAVE_LIBBZ2
case COMP_TYPE_BZ2:
return cfs_deinit_decompressor_bz2 (cfs);
+#endif
default:
LOG ("invalid compression type selected\n");
return -1;
@@ -775,6 +806,7 @@
}
+#if HAVE_ZLIB
/**
* Fills 'data' with new uncompressed data. Does the actual
* decompression. Will set uncompressed_size on the end of compressed
@@ -854,8 +886,10 @@
cfs->uncompressed_size = cfs->fpos;
return rc;
}
+#endif
+#if HAVE_LIBBZ2
/**
* Fills 'data' with new uncompressed data. Does the actual
* decompression. Will set uncompressed_size on the end of compressed
@@ -874,6 +908,7 @@
LOG ("bz2 decompression not implemented\n");
return -1;
}
+#endif
/**
@@ -893,10 +928,14 @@
{
switch (cfs->compression_type)
{
+#if HAVE_ZLIB
case COMP_TYPE_ZLIB:
return cfs_read_zlib (cfs, data, size);
+#endif
+#if HAVE_LIBBZ2
case COMP_TYPE_BZ2:
return cfs_read_bz2 (cfs, data, size);
+#endif
default:
LOG ("invalid compression type selected\n");
return -1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23096 - Extractor/src/main,
gnunet <=