From 39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91 Mon Sep 17 00:00:00 2001 From: pohly Date: Thu, 05 May 2005 14:39:33 +0000 Subject: new opie-reader sources with support for ArriereGo, Reb input and flite output plugins --- (limited to 'noncore/apps/opie-reader/decompress.cpp') diff --git a/noncore/apps/opie-reader/decompress.cpp b/noncore/apps/opie-reader/decompress.cpp new file mode 100644 index 0000000..9bfec49 --- a/dev/null +++ b/noncore/apps/opie-reader/decompress.cpp @@ -0,0 +1,95 @@ +#include +#include "decompress.h" +#include +#include + +size_t UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) +{ + z_stream zstream; + memset(&zstream,sizeof(zstream),0); + zstream.next_in = compressedbuffer; + zstream.next_out = tgtbuffer; + zstream.avail_out = bsize; + zstream.avail_in = reclen; + + int keylen = 0; + + zstream.zalloc = Z_NULL; + zstream.zfree = Z_NULL; + zstream.opaque = Z_NULL; + + // printf("Initialising\n"); + + inflateInit(&zstream); + int err = 0; + do { + if ( zstream.avail_in == 0 && 0 < keylen ) { + zstream.next_in = compressedbuffer + keylen; + zstream.avail_in = reclen - keylen; + keylen = 0; + } + zstream.next_out = tgtbuffer; + zstream.avail_out = bsize; + + err = inflate( &zstream, Z_SYNC_FLUSH ); + + // //qDebug("err:%d - %u", err, zstream.avail_in); + + } while ( err == Z_OK ); + + inflateEnd(&zstream); + return zstream.total_out; +} + +#if defined(__STATIC) && defined(USENEF) +#include "Model.h" +size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t) +{ + if (strcmp(_s, "PluckerDecompress3") == 0) + { + return PluckerDecompress3; + } + if (strcmp(_s, "PluckerDecompress4") == 0) + { + return PluckerDecompress4; + } + if (strcmp(_s, "RebDecompress") == 0) + { + return RebDecompress; + } + return NULL; +} +#else + +#include "qfileinfo.h" + +#include + +size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t) +{ +#ifdef USEQPE +#ifdef OPIE + QString codecpath(getenv("OPIEDIR")); +#else + QString codecpath(getenv("QTDIR")); +#endif + codecpath += "/plugins/reader/support/libpluckerdecompress.so"; +#else + QString codecpath(getenv("READERDIR")); + codecpath += "/support/libpluckerdecompress.so"; +#endif + qDebug("Codec:%s", (const char*)codecpath); + if (QFile::exists(codecpath)) + { + qDebug("Codec:%s", (const char*)codecpath); + void* handle = dlopen(codecpath, RTLD_LAZY); + if (handle == 0) + { + qDebug("Can't find codec:%s", dlerror()); + return NULL; + } + return (size_t (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s); + } + return NULL; +} +#endif -- cgit v0.9.0.2