summaryrefslogtreecommitdiff
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.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/modules/common/zverse.cpp b/src/modules/common/zverse.cpp
index fa76467..c280d98 100644
--- a/src/modules/common/zverse.cpp
+++ b/src/modules/common/zverse.cpp
@@ -1,11 +1,13 @@
/******************************************************************************
- * zverse.h - code for class 'zVerse'- a module that reads raw text
+ *
+ * zverse.cpp - code for class 'zVerse'- a module that reads raw text
* files: ot and nt using indexs ??.bks ??.cps ??.vss
* and provides lookup and parsing functions based on
* class VerseKey for compressed modules
*
+ * $Id: zverse.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -155,7 +157,7 @@ void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *s
// set size to
// set
*start = *size = *buffnum = 0;
- //printf ("Finding offset %ld\n", idxoff);
+ //fprintf(stderr, "Finding offset %ld\n", idxoff);
idxoff *= 10;
if (!testmt) {
testmt = ((idxfp[0]) ? 1:2);
@@ -168,7 +170,7 @@ void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *s
long newOffset = compfp[testmt-1]->seek(idxoff, SEEK_SET);
if (newOffset == idxoff) {
if (compfp[testmt-1]->read(&ulBuffNum, 4) != 4) {
- printf ("Error reading ulBuffNum\n");
+ fprintf(stderr, "Error reading ulBuffNum\n");
return;
}
}
@@ -176,12 +178,12 @@ void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *s
if (compfp[testmt-1]->read(&ulVerseStart, 4) < 2)
{
- printf ("Error reading ulVerseStart\n");
+ fprintf(stderr, "Error reading ulVerseStart\n");
return;
}
if (compfp[testmt-1]->read(&usVerseSize, 2) < 2)
{
- printf ("Error reading usVerseSize\n");
+ fprintf(stderr, "Error reading usVerseSize\n");
return;
}
@@ -202,7 +204,7 @@ void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *s
*
*/
-void zVerse::zReadText(char testmt, long start, unsigned short size, unsigned long ulBuffNum, SWBuf &inBuf) {
+void zVerse::zReadText(char testmt, long start, unsigned short size, unsigned long ulBuffNum, SWBuf &inBuf) const {
__u32 ulCompOffset = 0; // compressed buffer start
__u32 ulCompSize = 0; // buffer size compressed
__u32 ulUnCompSize = 0; // buffer size uncompressed
@@ -217,26 +219,26 @@ void zVerse::zReadText(char testmt, long start, unsigned short size, unsigned lo
if (size &&
!(((long) ulBuffNum == cacheBufIdx) && (testmt == cacheTestament) && (cacheBuf))) {
- //printf ("Got buffer number{%ld} versestart{%ld} versesize{%d}\n", ulBuffNum, ulVerseStart, usVerseSize);
+ //fprintf(stderr, "Got buffer number{%ld} versestart{%ld} versesize{%d}\n", ulBuffNum, ulVerseStart, usVerseSize);
if (idxfp[testmt-1]->seek(ulBuffNum*12, SEEK_SET)!=(long) ulBuffNum*12)
{
- printf ("Error seeking compressed file index\n");
+ fprintf(stderr, "Error seeking compressed file index\n");
return;
}
if (idxfp[testmt-1]->read(&ulCompOffset, 4)<4)
{
- printf ("Error reading ulCompOffset\n");
+ fprintf(stderr, "Error reading ulCompOffset\n");
return;
}
if (idxfp[testmt-1]->read(&ulCompSize, 4)<4)
{
- printf ("Error reading ulCompSize\n");
+ fprintf(stderr, "Error reading ulCompSize\n");
return;
}
if (idxfp[testmt-1]->read(&ulUnCompSize, 4)<4)
{
- printf ("Error reading ulUnCompSize\n");
+ fprintf(stderr, "Error reading ulUnCompSize\n");
return;
}
@@ -246,14 +248,14 @@ void zVerse::zReadText(char testmt, long start, unsigned short size, unsigned lo
if (textfp[testmt-1]->seek(ulCompOffset, SEEK_SET)!=(long)ulCompOffset)
{
- printf ("Error: could not seek to right place in compressed text\n");
+ fprintf(stderr, "Error: could not seek to right place in compressed text\n");
return;
}
SWBuf pcCompText;
pcCompText.setSize(ulCompSize+5);
if (textfp[testmt-1]->read(pcCompText.getRawData(), ulCompSize)<(long)ulCompSize) {
- printf ("Error reading compressed text\n");
+ fprintf(stderr, "Error reading compressed text\n");
return;
}
pcCompText.setSize(ulCompSize);
@@ -335,7 +337,7 @@ void zVerse::doSetText(char testmt, long idxoff, const char *buf, long len) {
}
-void zVerse::flushCache() {
+void zVerse::flushCache() const {
if (dirtyCache) {
__u32 idxoff;
__u32 start, outstart;
@@ -469,15 +471,15 @@ char zVerse::createModule(const char *ipath, int blockBound, const char *v11n)
VerseKey vk;
vk.setVersificationSystem(v11n);
- vk.Headings(1);
+ vk.setIntros(true);
__s32 offset = 0;
__s16 size = 0;
offset = archtosword32(offset);
size = archtosword16(size);
- for (vk = TOP; !vk.Error(); vk++) {
- if (vk.Testament() < 2) {
+ for (vk = TOP; !vk.popError(); vk++) {
+ if (vk.getTestament() < 2) {
fd->write(&offset, 4); //compBufIdxOffset
fd->write(&offset, 4);
fd->write(&size, 2);