aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/common
diff options
context:
space:
mode:
authordanglassey <danglassey>2002-09-26 13:02:15 +0000
committerdanglassey <danglassey>2002-09-26 13:02:15 +0000
commit08e1f7422791a20b5415aa62475c1d50cbf0dc74 (patch)
tree1b89bf2bb9d60aeabfdbf59cb562169dea758d57 /src/modules/common
parentb9c0a030bd400137de3b704a0634be3b9899f858 (diff)
downloadsword-sf-cvs-08e1f7422791a20b5415aa62475c1d50cbf0dc74.tar.gz
sync with crosswire 20020926-1300
Diffstat (limited to 'src/modules/common')
-rw-r--r--src/modules/common/rawverse.cpp2
-rw-r--r--src/modules/common/zstr.cpp10
-rw-r--r--src/modules/common/zverse.cpp57
3 files changed, 44 insertions, 25 deletions
diff --git a/src/modules/common/rawverse.cpp b/src/modules/common/rawverse.cpp
index f77fbe5..60b050b 100644
--- a/src/modules/common/rawverse.cpp
+++ b/src/modules/common/rawverse.cpp
@@ -199,7 +199,7 @@ void RawVerse::preptext(char *buf)
*/
void RawVerse::readtext(char testmt, long start, unsigned short size, char *buf) {
- memset(buf, 0, size+1);
+ memset(buf, 0, size);
if (!testmt)
testmt = ((idxfp[1]) ? 1:2);
if (size) {
diff --git a/src/modules/common/zstr.cpp b/src/modules/common/zstr.cpp
index cd1add5..972bc50 100644
--- a/src/modules/common/zstr.cpp
+++ b/src/modules/common/zstr.cpp
@@ -426,6 +426,9 @@ void zStr::getCompressedText(long block, long entry, char **buf) {
flushCache();
unsigned long len = size;
+
+ rawZFilter(*buf, len, 0); // 0 = decipher
+
compressor->zBuf(&len, *buf);
char * rawBuf = compressor->Buf(0, &len);
cacheBlock = new EntriesBlock(rawBuf, len);
@@ -610,6 +613,10 @@ void zStr::flushCache() {
compressor->Buf(rawBuf, &size);
compressor->zBuf(&size);
+ char *buf = new char [ size * 2 ];
+ memcpy(buf, compressor->zBuf(&size), size); // 1 = encipher
+ rawZFilter(buf, size, 1); // 1 = encipher
+
long zdxSize = lseek(zdxfd->getFd(), 0, SEEK_END);
long zdtSize = lseek(zdtfd->getFd(), 0, SEEK_END);
@@ -640,8 +647,7 @@ void zStr::flushCache() {
lseek(zdxfd->getFd(), cacheBlockIndex * ZDXENTRYSIZE, SEEK_SET);
lseek(zdtfd->getFd(), start, SEEK_SET);
- rawBuf = compressor->zBuf(&size);
- write(zdtfd->getFd(), rawBuf, size);
+ write(zdtfd->getFd(), buf, size);
// add a new line to make data file easier to read in an editor
write(zdtfd->getFd(), &nl, 2);
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;
}