aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/common/zverse.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/common/zverse.cpp')
-rw-r--r--src/modules/common/zverse.cpp57
1 files changed, 35 insertions, 22 deletions
diff --git a/src/modules/common/zverse.cpp b/src/modules/common/zverse.cpp
index 600a317..e4c04cf 100644
--- a/src/modules/common/zverse.cpp
+++ b/src/modules/common/zverse.cpp
@@ -228,6 +228,9 @@ void zVerse::findoffset(char testmt, long idxoff, long *start, unsigned short *s
printf ("Error reading compressed text\n");
return;
}
+
+ rawZFilter(pcCompText, ulCompSize, 0); // 0 = decipher
+
compressor->zBuf(&ulCompSize, pcCompText);
if (cacheBuf) {
@@ -326,28 +329,38 @@ void zVerse::flushCache() {
unsigned long zsize, outzsize;
idxoff = cacheBufIdx * 12;
- size = outsize = zsize = outzsize = strlen(cacheBuf);
- if (size) {
-// if (compressor) {
-// delete compressor;
-// compressor = new LZSSCompress();
-// }
- compressor->Buf(cacheBuf);
- compressor->zBuf(&zsize);
- outzsize = zsize;
-
- start = outstart = lseek(textfp[cacheTestament-1]->getFd(), 0, SEEK_END);
-
- outstart = archtosword32(start);
- outsize = archtosword32(size);
- outzsize = archtosword32(zsize);
-
- write(textfp[cacheTestament-1]->getFd(), compressor->zBuf(&zsize), zsize);
-
- lseek(idxfp[cacheTestament-1]->getFd(), idxoff, SEEK_SET);
- write(idxfp[cacheTestament-1]->getFd(), &outstart, 4);
- write(idxfp[cacheTestament-1]->getFd(), &outzsize, 4);
- write(idxfp[cacheTestament-1]->getFd(), &outsize, 4);
+ if (cacheBuf) {
+ size = outsize = zsize = outzsize = strlen(cacheBuf);
+ if (size) {
+ // if (compressor) {
+ // delete compressor;
+ // compressor = new LZSSCompress();
+ // }
+ compressor->Buf(cacheBuf);
+ compressor->zBuf(&zsize);
+ outzsize = zsize;
+
+ char *buf = new char [ zsize * 2 ];
+ memcpy(buf, compressor->zBuf(&zsize), zsize);
+ rawZFilter(buf, zsize, 1); // 1 = encipher
+
+ start = outstart = lseek(textfp[cacheTestament-1]->getFd(), 0, SEEK_END);
+
+ outstart = archtosword32(start);
+ outsize = archtosword32(size);
+ outzsize = archtosword32(zsize);
+
+ write(textfp[cacheTestament-1]->getFd(), buf, zsize);
+
+ delete [] buf;
+
+ lseek(idxfp[cacheTestament-1]->getFd(), idxoff, SEEK_SET);
+ write(idxfp[cacheTestament-1]->getFd(), &outstart, 4);
+ write(idxfp[cacheTestament-1]->getFd(), &outzsize, 4);
+ write(idxfp[cacheTestament-1]->getFd(), &outsize, 4);
+ }
+ free(cacheBuf);
+ cacheBuf = 0;
}
dirtyCache = false;
}