libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

commit 397a6fec015c2d611ca0ad1732c579ea7be0d39e
parent 07aa6e57127306886d97c592d7d1f8b8ea9c77d1
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat,  4 Aug 2012 18:39:59 +0000

-fixing gzip

Diffstat:
Msrc/main/extractor.c | 15---------------
Msrc/main/extractor_datasource.c | 29++++++++++++++++-------------
Msrc/main/extractor_ipc.c | 3---
Msrc/main/test_extractor.c | 3---
4 files changed, 16 insertions(+), 34 deletions(-)

diff --git a/src/main/extractor.c b/src/main/extractor.c @@ -478,8 +478,6 @@ do_extract (struct EXTRACTOR_PluginList *plugins, if ( (-1 == min_seek) || (min_seek > pos->seek_request) ) { - LOG ("Updating min seek to %llu\n", - (unsigned long long) pos->seek_request); min_seek = pos->seek_request; } } @@ -499,10 +497,6 @@ do_extract (struct EXTRACTOR_PluginList *plugins, abort_all_channels (plugins); break; } - LOG ("Seeking to %lld, got %d bytes ready there\n", - (long long) min_seek, - (int) data_available); - } /* if 'prp.file_finished', send 'abort' to plugins; if not, send 'seek' notification to plugins in range */ @@ -522,21 +516,12 @@ do_extract (struct EXTRACTOR_PluginList *plugins, ( (min_seek + data_available > pos->seek_request) || (min_seek == EXTRACTOR_datasource_get_size_ (ds, 0))) ) { - LOG ("Notifying plugin about seek\n"); send_update_message (pos, min_seek, data_available, ds); pos->seek_request = -1; } - else - { - if (-1 != pos->seek_request) - LOG ("Skipping plugin, seek %lld not in range %llu-%llu\n", - (long long) pos->seek_request, - min_seek, - min_seek + data_available); - } if (0 == pos->round_finished) done = 0; /* can't be done, plugin still active */ } diff --git a/src/main/extractor_datasource.c b/src/main/extractor_datasource.c @@ -798,7 +798,7 @@ cfs_read_zlib (struct CompressedFileSource *cfs, if (cfs->fpos == cfs->uncompressed_size) { - LOG ("fpos at EOF, returning 0 from cfs_read_zlib\n"); + /* end of file */ return 0; } rc = 0; @@ -852,8 +852,6 @@ cfs_read_zlib (struct CompressedFileSource *cfs, } if (Z_STREAM_END == ret) cfs->uncompressed_size = cfs->fpos; - LOG ("returning %d from cfs_read_zlib\n", - (int) rc); return rc; } @@ -941,12 +939,7 @@ cfs_seek (struct CompressedFileSource *cfs, nposition = cfs->fpos + position; break; case SEEK_END: - if (-1 == cfs->uncompressed_size) - { - /* yuck, need to first find end of file! */ - LOG ("Seeking from end-of-file in compressed files not implemented\n"); - return -1; // FIXME: not implemented - } + ASSERT (-1 != cfs->uncompressed_size); if (position > 0) { LOG ("Invalid seek operation\n"); @@ -983,6 +976,7 @@ cfs_seek (struct CompressedFileSource *cfs, if (cfs->result_pos >= - delta) { cfs->result_pos += delta; + cfs->fpos += delta; delta = 0; } else @@ -1257,7 +1251,17 @@ EXTRACTOR_datasource_seek_ (void *cls, struct EXTRACTOR_Datasource *ds = cls; if (NULL != ds->cfs) - return cfs_seek (ds->cfs, pos, whence); + { + if ( (SEEK_END == whence) && + (-1 == ds->cfs->uncompressed_size) ) + { + /* need to obtain uncompressed size */ + (void) EXTRACTOR_datasource_get_size_ (ds, 1); + if (-1 == ds->cfs->uncompressed_size) + return -1; + } + return cfs_seek (ds->cfs, pos, whence); + } return bfds_seek (ds->bfds, pos, whence); } @@ -1283,7 +1287,6 @@ EXTRACTOR_datasource_get_size_ (void *cls, (-1 == ds->cfs->uncompressed_size) ) { pos = ds->cfs->fpos; - LOG ("seeking to end\n"); while ( (-1 == ds->cfs->uncompressed_size) && (-1 != cfs_read (ds->cfs, buf, sizeof (buf))) ) ; if (-1 == cfs_seek (ds->cfs, pos, SEEK_SET)) @@ -1291,8 +1294,8 @@ EXTRACTOR_datasource_get_size_ (void *cls, LOG ("Serious problem, I moved the buffer to determine the file size but could not restore it...\n"); return -1; } - LOG ("File size is %llu bytes decompressed\n", - (unsigned long long) ds->cfs->uncompressed_size); + if (-1 == ds->cfs->uncompressed_size) + return -1; } return ds->cfs->uncompressed_size; } diff --git a/src/main/extractor_ipc.c b/src/main/extractor_ipc.c @@ -70,9 +70,6 @@ EXTRACTOR_IPC_process_reply_ (struct EXTRACTOR_PluginList *plugin, memcpy (&seek, cdata, sizeof (seek)); plugin->seek_request = (int64_t) seek.file_offset; plugin->seek_whence = seek.whence; - LOG ("Received %d-seek request to %llu\n", - (int) seek.whence, - (unsigned long long) seek.file_offset); return sizeof (struct SeekRequestMessage); case MESSAGE_META: /* Meta */ if (size < sizeof (struct MetaMessage)) diff --git a/src/main/test_extractor.c b/src/main/test_extractor.c @@ -98,7 +98,6 @@ EXTRACTOR_test_extract_method (struct EXTRACTOR_ExtractContext *ec) fprintf (stderr, "Unexpected data at offset 100k - 3\n"); abort (); } - fprintf (stderr, "Seeking to 150k\n"); if (1024 * 150 != ec->seek (ec->cls, 0, SEEK_END)) { fprintf (stderr, "Failure to seek (SEEK_END)\n"); @@ -114,7 +113,6 @@ EXTRACTOR_test_extract_method (struct EXTRACTOR_ExtractContext *ec) fprintf (stderr, "Failure to seek (SEEK_END - 2)\n"); abort (); } - fprintf (stderr, "Reading at 150k - 2\n"); if (1 != ec->read (ec->cls, &dp, 1)) { fprintf (stderr, "Failure to read at 150k - 3\n"); @@ -125,7 +123,6 @@ EXTRACTOR_test_extract_method (struct EXTRACTOR_ExtractContext *ec) fprintf (stderr, "Unexpected data at offset 150k - 3\n"); abort (); } - fprintf (stderr, "Good at 150k\n"); if (0 != ec->proc (ec->cls, "test", EXTRACTOR_METATYPE_COMMENT, EXTRACTOR_METAFORMAT_UTF8, "<no mime>", "Hello world!", strlen ("Hello world!") + 1))