summaryrefslogtreecommitdiff
path: root/src/modules/comments
diff options
context:
space:
mode:
authorDimitri John Ledkov <xnox@ubuntu.com>2014-05-11 22:09:52 +0100
committerDimitri John Ledkov <xnox@ubuntu.com>2014-05-11 22:09:52 +0100
commit3525014850e3800ac7b28fd34e7f7af427f1c620 (patch)
tree3d1b8a17b86cfa9af178ceb818a4dc9daf52a46b /src/modules/comments
sword (1.7.2+dfsg-2) unstable; urgency=medium
* Correct shared library symlink. (Closes: #747420) # imported from the archive
Diffstat (limited to 'src/modules/comments')
-rw-r--r--src/modules/comments/Makefile5
-rw-r--r--src/modules/comments/Makefile.am9
-rw-r--r--src/modules/comments/hrefcom/Makefile5
-rw-r--r--src/modules/comments/hrefcom/Makefile.am2
-rw-r--r--src/modules/comments/hrefcom/hrefcom.cpp95
-rw-r--r--src/modules/comments/rawcom/Makefile5
-rw-r--r--src/modules/comments/rawcom/Makefile.am2
-rw-r--r--src/modules/comments/rawcom/rawcom.cpp184
-rw-r--r--src/modules/comments/rawcom4/Makefile5
-rw-r--r--src/modules/comments/rawcom4/Makefile.am2
-rw-r--r--src/modules/comments/rawcom4/rawcom4.cpp179
-rw-r--r--src/modules/comments/rawfiles/Makefile5
-rw-r--r--src/modules/comments/rawfiles/Makefile.am2
-rw-r--r--src/modules/comments/rawfiles/rawfiles.cpp232
-rw-r--r--src/modules/comments/swcom.cpp123
-rw-r--r--src/modules/comments/zcom/Makefile5
-rw-r--r--src/modules/comments/zcom/Makefile.am2
-rw-r--r--src/modules/comments/zcom/zcom.cpp220
18 files changed, 1082 insertions, 0 deletions
diff --git a/src/modules/comments/Makefile b/src/modules/comments/Makefile
new file mode 100644
index 0000000..1a2d00d
--- /dev/null
+++ b/src/modules/comments/Makefile
@@ -0,0 +1,5 @@
+
+root := ../../..
+
+all:
+ make -C ${root}
diff --git a/src/modules/comments/Makefile.am b/src/modules/comments/Makefile.am
new file mode 100644
index 0000000..7139cf8
--- /dev/null
+++ b/src/modules/comments/Makefile.am
@@ -0,0 +1,9 @@
+commentsdir = $(top_srcdir)/src/modules/comments
+
+libsword_la_SOURCES += $(commentsdir)/swcom.cpp
+
+include ../src/modules/comments/rawcom/Makefile.am
+include ../src/modules/comments/rawcom4/Makefile.am
+include ../src/modules/comments/rawfiles/Makefile.am
+include ../src/modules/comments/zcom/Makefile.am
+include ../src/modules/comments/hrefcom/Makefile.am
diff --git a/src/modules/comments/hrefcom/Makefile b/src/modules/comments/hrefcom/Makefile
new file mode 100644
index 0000000..35d6648
--- /dev/null
+++ b/src/modules/comments/hrefcom/Makefile
@@ -0,0 +1,5 @@
+
+root := ../../../..
+
+all:
+ make -C ${root}
diff --git a/src/modules/comments/hrefcom/Makefile.am b/src/modules/comments/hrefcom/Makefile.am
new file mode 100644
index 0000000..dba4294
--- /dev/null
+++ b/src/modules/comments/hrefcom/Makefile.am
@@ -0,0 +1,2 @@
+hrefcomdir = $(top_srcdir)/src/modules/comments/hrefcom
+libsword_la_SOURCES += $(hrefcomdir)/hrefcom.cpp
diff --git a/src/modules/comments/hrefcom/hrefcom.cpp b/src/modules/comments/hrefcom/hrefcom.cpp
new file mode 100644
index 0000000..3716dbf
--- /dev/null
+++ b/src/modules/comments/hrefcom/hrefcom.cpp
@@ -0,0 +1,95 @@
+/******************************************************************************
+ *
+ * hrefcom.cpp - code for class 'HREFCom'- a module that produces HTML
+ * HREFs pointing to actual text desired. Uses standard
+ * files: ot and nt using indexs ??.bks ??.cps ??.vss
+ *
+ * $Id: hrefcom.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+
+#include <ctype.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+#include <utilstr.h>
+#include <rawverse.h>
+#include <hrefcom.h>
+#include <swbuf.h>
+#include <versekey.h>
+
+SWORD_NAMESPACE_START
+
+ /******************************************************************************
+ * HREFCom Constructor - Initializes data for instance of HREFCom
+ *
+ * ENT: iname - Internal name for module
+ * iprefix - string to prepend to each HREF (e.g. "file://mods/com/jfb/")
+ * idesc - Name to display to user for module
+ * idisp - Display object to use for displaying
+ */
+
+HREFCom::HREFCom(const char *ipath, const char *iprefix, const char *iname, const char *idesc, SWDisplay *idisp) : RawVerse(ipath), SWCom(iname, idesc, idisp)
+{
+ prefix = 0;
+ stdstr(&prefix, iprefix);
+}
+
+
+/******************************************************************************
+ * HREFCom Destructor - Cleans up instance of HREFCom
+ */
+
+HREFCom::~HREFCom()
+{
+ if (prefix)
+ delete [] prefix;
+}
+
+
+/******************************************************************************
+ * HREFCom::operator char * - Returns the correct verse when char * cast
+ * is requested
+ *
+ * RET: string buffer with verse
+ */
+
+SWBuf &HREFCom::getRawEntryBuf() const {
+ long start;
+ unsigned short size;
+ VerseKey *key = 0;
+
+ key = &getVerseKey();
+
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
+ entrySize = size; // support getEntrySize call
+
+ SWBuf tmpbuf;
+
+ readText(key->getTestament(), start, size, tmpbuf);
+ entryBuf = prefix;
+ entryBuf += tmpbuf.c_str();
+ prepText(entryBuf);
+
+ if (key != this->key)
+ delete key;
+
+ return entryBuf;
+}
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/comments/rawcom/Makefile b/src/modules/comments/rawcom/Makefile
new file mode 100644
index 0000000..35d6648
--- /dev/null
+++ b/src/modules/comments/rawcom/Makefile
@@ -0,0 +1,5 @@
+
+root := ../../../..
+
+all:
+ make -C ${root}
diff --git a/src/modules/comments/rawcom/Makefile.am b/src/modules/comments/rawcom/Makefile.am
new file mode 100644
index 0000000..116d706
--- /dev/null
+++ b/src/modules/comments/rawcom/Makefile.am
@@ -0,0 +1,2 @@
+rawcomdir = $(top_srcdir)/src/modules/comments/rawcom
+libsword_la_SOURCES += $(rawcomdir)/rawcom.cpp
diff --git a/src/modules/comments/rawcom/rawcom.cpp b/src/modules/comments/rawcom/rawcom.cpp
new file mode 100644
index 0000000..5189cdc
--- /dev/null
+++ b/src/modules/comments/rawcom/rawcom.cpp
@@ -0,0 +1,184 @@
+/******************************************************************************
+ *
+ * rawcom.cpp - code for class 'RawCom'- a module that reads raw
+ * commentary files:
+ * ot and nt using indexs ??.bks ??.cps ??.vss
+ *
+ * $Id: rawcom.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+
+#include <ctype.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+#include <filemgr.h>
+#include <rawverse.h>
+#include <rawcom.h>
+#include <versekey.h>
+
+SWORD_NAMESPACE_START
+
+ /******************************************************************************
+ * RawCom Constructor - Initializes data for instance of RawCom
+ *
+ * ENT: iname - Internal name for module
+ * idesc - Name to display to user for module
+ * idisp - Display object to use for displaying
+ */
+
+RawCom::RawCom(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding encoding, SWTextDirection dir, SWTextMarkup markup, const char *ilang, const char *versification)
+ : RawVerse(ipath),
+ SWCom(iname, idesc, idisp, encoding, dir, markup, ilang, versification) {
+}
+
+
+/******************************************************************************
+ * RawCom Destructor - Cleans up instance of RawCom
+ */
+
+RawCom::~RawCom()
+{
+}
+
+
+bool RawCom::isWritable() const {
+ return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
+}
+/******************************************************************************
+ * RawCom::getRawEntry() - Returns the correct verse when char * cast
+ * is requested
+ *
+ * RET: string buffer with verse
+ */
+
+SWBuf &RawCom::getRawEntryBuf() const {
+ long start = 0;
+ unsigned short size = 0;
+ VerseKey *key = &getVerseKey();
+
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
+ entrySize = size; // support getEntrySize call
+
+ entryBuf = "";
+ readText(key->getTestament(), start, size, entryBuf);
+
+ rawFilter(entryBuf, 0); // hack, decipher
+ rawFilter(entryBuf, key);
+
+// if (!isUnicode())
+ prepText(entryBuf);
+
+ return entryBuf;
+}
+
+
+/******************************************************************************
+ * RawCom::increment - Increments module key a number of entries
+ *
+ * ENT: steps - Number of entries to jump forward
+ *
+ * RET: *this
+ */
+
+void RawCom::increment(int steps) {
+ long start;
+ unsigned short size;
+ VerseKey *tmpkey = &getVerseKey();
+
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size);
+
+ SWKey lastgood = *tmpkey;
+ while (steps) {
+ long laststart = start;
+ unsigned short lastsize = size;
+ SWKey lasttry = *tmpkey;
+ (steps > 0) ? ++(*key) : --(*key);
+ tmpkey = &getVerseKey();
+
+ if ((error = key->popError())) {
+ *key = lastgood;
+ break;
+ }
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size);
+ if (
+ (((laststart != start) || (lastsize != size)) // we're a different entry
+// && (start > 0)
+ && (size)) // and we actually have a size
+ ||(!skipConsecutiveLinks)) { // or we don't want to skip consecutive links
+ steps += (steps < 0) ? 1 : -1;
+ lastgood = *tmpkey;
+ }
+ }
+ error = (error) ? KEYERR_OUTOFBOUNDS : 0;
+}
+
+
+void RawCom::setEntry(const char *inbuf, long len) {
+ VerseKey *key = &getVerseKey();
+ doSetText(key->getTestament(), key->getTestamentIndex(), inbuf, len);
+}
+
+
+void RawCom::linkEntry(const SWKey *inkey) {
+ VerseKey *destkey = &getVerseKey();
+ const VerseKey *srckey = &getVerseKey(inkey);
+
+ doLinkEntry(destkey->getTestament(), destkey->getTestamentIndex(), srckey->getTestamentIndex());
+
+ if (inkey != srckey) // free our key if we created a VerseKey
+ delete srckey;
+}
+
+
+/******************************************************************************
+ * RawCom::deleteEntry - deletes this entry
+ *
+ * RET: *this
+ */
+
+void RawCom::deleteEntry() {
+
+ VerseKey *key = &getVerseKey();
+ doSetText(key->getTestament(), key->getTestamentIndex(), "");
+}
+
+bool RawCom::isLinked(const SWKey *k1, const SWKey *k2) const {
+ long start1, start2;
+ unsigned short size1, size2;
+ VerseKey *vk1 = &getVerseKey(k1);
+ VerseKey *vk2 = &getVerseKey(k2);
+ if (vk1->getTestament() != vk2->getTestament()) return false;
+
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2);
+ if (!size1 || !size2) return false;
+ return start1 == start2;
+}
+
+bool RawCom::hasEntry(const SWKey *k) const {
+ long start;
+ unsigned short size;
+ VerseKey *vk = &getVerseKey(k);
+
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size);
+ return size;
+}
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/comments/rawcom4/Makefile b/src/modules/comments/rawcom4/Makefile
new file mode 100644
index 0000000..a08e07e
--- /dev/null
+++ b/src/modules/comments/rawcom4/Makefile
@@ -0,0 +1,5 @@
+
+root := ../../../..
+
+all:
+ make -C ${root}
diff --git a/src/modules/comments/rawcom4/Makefile.am b/src/modules/comments/rawcom4/Makefile.am
new file mode 100644
index 0000000..346dbc5
--- /dev/null
+++ b/src/modules/comments/rawcom4/Makefile.am
@@ -0,0 +1,2 @@
+rawcom4dir = $(top_srcdir)/src/modules/comments/rawcom4
+libsword_la_SOURCES += $(rawcom4dir)/rawcom4.cpp
diff --git a/src/modules/comments/rawcom4/rawcom4.cpp b/src/modules/comments/rawcom4/rawcom4.cpp
new file mode 100644
index 0000000..7cfc603
--- /dev/null
+++ b/src/modules/comments/rawcom4/rawcom4.cpp
@@ -0,0 +1,179 @@
+/******************************************************************************
+ *
+ * rawcom4.cpp - code for class 'RawCom4'- a module that reads raw
+ * commentary files:
+ * ot and nt using indexs ??.bks ??.cps ??.vss
+ *
+ * $Id: rawcom4.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2007-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+#include <filemgr.h>
+#include <rawverse4.h>
+#include <rawcom4.h>
+#include <versekey.h>
+
+SWORD_NAMESPACE_START
+
+ /******************************************************************************
+ * RawCom4 Constructor - Initializes data for instance of RawCom4
+ *
+ * ENT: iname - Internal name for module
+ * idesc - Name to display to user for module
+ * idisp - Display object to use for displaying
+ */
+
+RawCom4::RawCom4(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding encoding, SWTextDirection dir, SWTextMarkup markup, const char *ilang, const char *versification)
+ : RawVerse4(ipath),
+ SWCom(iname, idesc, idisp, encoding, dir, markup, ilang, versification) {
+}
+
+
+/******************************************************************************
+ * RawCom4 Destructor - Cleans up instance of RawCom4
+ */
+
+RawCom4::~RawCom4()
+{
+}
+
+
+bool RawCom4::isWritable() const {
+ return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
+}
+/******************************************************************************
+ * RawCom4::getRawEntry() - Returns the correct verse when char * cast
+ * is requested
+ *
+ * RET: string buffer with verse
+ */
+
+SWBuf &RawCom4::getRawEntryBuf() const {
+ long start = 0;
+ unsigned long size = 0;
+ VerseKey *key = &getVerseKey();
+
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
+ entrySize = size; // support getEntrySize call
+
+ entryBuf = "";
+ readText(key->getTestament(), start, size, entryBuf);
+
+ rawFilter(entryBuf, 0); // hack, decipher
+ rawFilter(entryBuf, key);
+
+// if (!isUnicode())
+ prepText(entryBuf);
+
+ return entryBuf;
+}
+
+
+/******************************************************************************
+ * RawCom4::increment - Increments module key a number of entries
+ *
+ * ENT: steps - Number of entries to jump forward
+ *
+ * RET: *this
+ */
+
+void RawCom4::increment(int steps) {
+ long start;
+ unsigned long size;
+ VerseKey *tmpkey = &getVerseKey();
+
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size);
+
+ SWKey lastgood = *tmpkey;
+ while (steps) {
+ long laststart = start;
+ unsigned long lastsize = size;
+ SWKey lasttry = *tmpkey;
+ (steps > 0) ? ++(*key) : --(*key);
+ tmpkey = &getVerseKey();
+
+ if ((error = key->popError())) {
+ *key = lastgood;
+ break;
+ }
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size);
+ if (
+ (((laststart != start) || (lastsize != size)) // we're a different entry
+// && (start > 0)
+ && (size)) // and we actually have a size
+ ||(!skipConsecutiveLinks)) { // or we don't want to skip consecutive links
+ steps += (steps < 0) ? 1 : -1;
+ lastgood = *tmpkey;
+ }
+ }
+ error = (error) ? KEYERR_OUTOFBOUNDS : 0;
+}
+
+
+void RawCom4::setEntry(const char *inbuf, long len) {
+ VerseKey *key = &getVerseKey();
+ doSetText(key->getTestament(), key->getTestamentIndex(), inbuf, len);
+}
+
+
+void RawCom4::linkEntry(const SWKey *inkey) {
+ VerseKey *destkey = &getVerseKey();
+ const VerseKey *srckey = &getVerseKey(inkey);
+ doLinkEntry(destkey->getTestament(), destkey->getTestamentIndex(), srckey->getTestamentIndex());
+}
+
+
+/******************************************************************************
+ * RawCom4::deleteEntry - deletes this entry
+ *
+ * RET: *this
+ */
+
+void RawCom4::deleteEntry() {
+
+ VerseKey *key = &getVerseKey();
+ doSetText(key->getTestament(), key->getTestamentIndex(), "");
+}
+
+bool RawCom4::isLinked(const SWKey *k1, const SWKey *k2) const {
+ long start1, start2;
+ unsigned long size1, size2;
+ VerseKey *vk1 = &getVerseKey(k1);
+ VerseKey *vk2 = &getVerseKey(k2);
+ if (vk1->getTestament() != vk2->getTestament()) return false;
+
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2);
+ if (!size1 || !size2) return false;
+ return start1 == start2;
+}
+
+bool RawCom4::hasEntry(const SWKey *k) const {
+ long start;
+ unsigned long size;
+ VerseKey *vk = &getVerseKey(k);
+
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size);
+ return size;
+}
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/comments/rawfiles/Makefile b/src/modules/comments/rawfiles/Makefile
new file mode 100644
index 0000000..35d6648
--- /dev/null
+++ b/src/modules/comments/rawfiles/Makefile
@@ -0,0 +1,5 @@
+
+root := ../../../..
+
+all:
+ make -C ${root}
diff --git a/src/modules/comments/rawfiles/Makefile.am b/src/modules/comments/rawfiles/Makefile.am
new file mode 100644
index 0000000..a9b7dbe
--- /dev/null
+++ b/src/modules/comments/rawfiles/Makefile.am
@@ -0,0 +1,2 @@
+rawfilesdir = $(top_srcdir)/src/modules/comments/rawfiles
+libsword_la_SOURCES += $(rawfilesdir)/rawfiles.cpp
diff --git a/src/modules/comments/rawfiles/rawfiles.cpp b/src/modules/comments/rawfiles/rawfiles.cpp
new file mode 100644
index 0000000..7c2d524
--- /dev/null
+++ b/src/modules/comments/rawfiles/rawfiles.cpp
@@ -0,0 +1,232 @@
+/******************************************************************************
+ *
+ * rawfiles.cpp - code for class 'RawFiles'- a module that produces HTML
+ * HREFs pointing to actual text desired. Uses standard
+ * files: ot and nt using indexs ??.bks ??.cps ??.vss
+ *
+ * $Id: rawfiles.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+#include <rawverse.h>
+#include <rawfiles.h>
+#include <filemgr.h>
+#include <versekey.h>
+#include <sysdata.h>
+
+SWORD_NAMESPACE_START
+
+ /******************************************************************************
+ * RawFiles Constructor - Initializes data for instance of RawFiles
+ *
+ * ENT: iname - Internal name for module
+ * idesc - Name to display to user for module
+ * idisp - Display object to use for displaying
+ */
+
+RawFiles::RawFiles(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang) : RawVerse(ipath, FileMgr::RDWR), SWCom(iname, idesc, idisp, enc, dir, mark, ilang)
+{
+}
+
+
+/******************************************************************************
+ * RawFiles Destructor - Cleans up instance of RawFiles
+ */
+
+RawFiles::~RawFiles()
+{
+}
+
+
+/** Is the module writable? :)
+* @return yes or no
+*/
+bool RawFiles::isWritable() const {
+ return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
+}
+
+
+/******************************************************************************
+ * RawFiles::getRawEntry - Retrieve the unprocessed entry contents at
+ * the current key position of this module
+ *
+ * RET: entry contents
+ */
+
+SWBuf &RawFiles::getRawEntryBuf() const {
+ FileDesc *datafile;
+ long start = 0;
+ unsigned short size = 0;
+ VerseKey *key = &getVerseKey();
+
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
+
+ entryBuf = "";
+ if (size) {
+ SWBuf tmpbuf = path;
+ tmpbuf += '/';
+ readText(key->getTestament(), start, size, entryBuf);
+ tmpbuf += entryBuf;
+ entryBuf = "";
+ datafile = FileMgr::getSystemFileMgr()->open(tmpbuf.c_str(), FileMgr::RDONLY);
+ if (datafile->getFd() > 0) {
+ size = datafile->seek(0, SEEK_END);
+ char *tmpBuf = new char [ size + 1 ];
+ memset(tmpBuf, 0, size + 1);
+ datafile->seek(0, SEEK_SET);
+ datafile->read(tmpBuf, size);
+ entryBuf = tmpBuf;
+ delete [] tmpBuf;
+// preptext(entrybuf);
+ }
+ FileMgr::getSystemFileMgr()->close(datafile);
+ }
+ return entryBuf;
+}
+
+
+/******************************************************************************
+ * RawFiles::setEntry(char *)- Update the module's current key entry with
+ * provided text
+ */
+
+void RawFiles::setEntry(const char *inbuf, long len) {
+ FileDesc *datafile;
+ long start;
+ unsigned short size;
+ VerseKey *key = &getVerseKey();
+
+ len = (len<0)?strlen(inbuf):len;
+
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
+
+ if (size) {
+ SWBuf tmpbuf;
+ entryBuf = path;
+ entryBuf += '/';
+ readText(key->getTestament(), start, size, tmpbuf);
+ entryBuf += tmpbuf;
+ }
+ else {
+ SWBuf tmpbuf;
+ entryBuf = path;
+ entryBuf += '/';
+ tmpbuf = getNextFilename();
+ doSetText(key->getTestament(), key->getTestamentIndex(), tmpbuf);
+ entryBuf += tmpbuf;
+ }
+ datafile = FileMgr::getSystemFileMgr()->open(entryBuf, FileMgr::CREAT|FileMgr::WRONLY|FileMgr::TRUNC);
+ if (datafile->getFd() > 0) {
+ datafile->write(inbuf, len);
+ }
+ FileMgr::getSystemFileMgr()->close(datafile);
+}
+
+
+/******************************************************************************
+ * RawFiles::linkEntry(SWKey *)- Link the modules current key entry with
+ * another module entry
+ *
+ * RET: *this
+ */
+
+void RawFiles::linkEntry(const SWKey *inkey) {
+
+ long start;
+ unsigned short size;
+ const VerseKey *key = &getVerseKey();
+
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
+
+ if (size) {
+ SWBuf tmpbuf;
+ readText(key->getTestament(), start, size + 2, tmpbuf);
+
+ key = &getVerseKey(inkey);
+ doSetText(key->getTestament(), key->getTestamentIndex(), tmpbuf.c_str());
+ }
+}
+
+
+/******************************************************************************
+ * RawFiles::deleteEntry - deletes this entry
+ *
+ * RET: *this
+ */
+
+void RawFiles::deleteEntry() {
+ VerseKey *key = &getVerseKey();
+ doSetText(key->getTestament(), key->getTestamentIndex(), "");
+}
+
+
+/******************************************************************************
+ * RawFiles::getNextfilename - generates a valid filename in which to store
+ * an entry
+ *
+ * RET: filename
+ */
+
+const char *RawFiles::getNextFilename() {
+ static SWBuf incfile;
+ __u32 number = 0;
+ FileDesc *datafile;
+
+ incfile.setFormatted("%s/incfile", path);
+ datafile = FileMgr::getSystemFileMgr()->open(incfile, FileMgr::RDONLY);
+ if (datafile->getFd() != -1) {
+ if (datafile->read(&number, 4) != 4) number = 0;
+ number = swordtoarch32(number);
+ }
+ number++;
+ FileMgr::getSystemFileMgr()->close(datafile);
+
+ datafile = FileMgr::getSystemFileMgr()->open(incfile, FileMgr::CREAT|FileMgr::WRONLY|FileMgr::TRUNC);
+ incfile.setFormatted("%.7d", number-1);
+
+ number = archtosword32(number);
+ datafile->write(&number, 4);
+
+ FileMgr::getSystemFileMgr()->close(datafile);
+ return incfile;
+}
+
+
+char RawFiles::createModule(const char *path) {
+ char *incfile = new char [ strlen (path) + 16 ];
+
+ __u32 zero = 0;
+ zero = archtosword32(zero);
+
+ FileDesc *datafile;
+
+ sprintf(incfile, "%s/incfile", path);
+ datafile = FileMgr::getSystemFileMgr()->open(incfile, FileMgr::CREAT|FileMgr::WRONLY|FileMgr::TRUNC);
+ delete [] incfile;
+ datafile->write(&zero, 4);
+ FileMgr::getSystemFileMgr()->close(datafile);
+
+ return RawVerse::createModule (path);
+}
+
+
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/comments/swcom.cpp b/src/modules/comments/swcom.cpp
new file mode 100644
index 0000000..52bd61b
--- /dev/null
+++ b/src/modules/comments/swcom.cpp
@@ -0,0 +1,123 @@
+/******************************************************************************
+ *
+ * swcom.cpp - code for base class 'SWCom'- The basis for all commentary
+ * modules
+ *
+ * $Id: swcom.cpp 2893 2013-07-16 03:07:02Z scribe $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+
+#include <utilstr.h>
+#include <swcom.h>
+#include <localemgr.h>
+#include <versekey.h>
+
+
+SWORD_NAMESPACE_START
+
+
+/******************************************************************************
+ * SWCom Constructor - Initializes data for instance of SWCom
+ *
+ * ENT: imodname - Internal name for module
+ * imoddesc - Name to display to user for module
+ * idisp - Display object to use for displaying
+ */
+
+SWCom::SWCom(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char *ilang, const char *versification): SWModule(imodname, imoddesc, idisp, "Commentaries", enc, dir, mark, ilang) {
+ this->versification = 0;
+ stdstr(&(this->versification), versification);
+ delete key;
+ key = (VerseKey *)createKey();
+ tmpVK1 = (VerseKey *)createKey();
+ tmpVK2 = (VerseKey *)createKey();
+ tmpSecond = false;
+}
+
+
+/******************************************************************************
+ * SWCom Destructor - Cleans up instance of SWCom
+ */
+
+SWCom::~SWCom() {
+ delete tmpVK1;
+ delete tmpVK2;
+ delete [] versification;
+}
+
+
+SWKey *SWCom::createKey() const {
+ VerseKey *vk = new VerseKey();
+
+ vk->setVersificationSystem(versification);
+
+ return vk;
+}
+
+
+long SWCom::getIndex() const {
+ VerseKey *key = &getVerseKey();
+ entryIndex = key->getIndex();
+ return entryIndex;
+}
+
+void SWCom::setIndex(long iindex) {
+ VerseKey *key = &getVerseKey();
+ key->setTestament(1);
+ key->setIndex(iindex);
+
+ if (key != this->key) {
+ this->key->copyFrom(*key);
+ }
+}
+
+
+VerseKey &SWCom::getVerseKey(const SWKey *keyToConvert) const {
+ const SWKey *thisKey = keyToConvert ? keyToConvert : this->key;
+
+ VerseKey *key = 0;
+ // see if we have a VerseKey * or decendant
+ SWTRY {
+ key = SWDYNAMIC_CAST(VerseKey, thisKey);
+ }
+ SWCATCH ( ... ) { }
+ if (!key) {
+ ListKey *lkTest = 0;
+ SWTRY {
+ lkTest = SWDYNAMIC_CAST(ListKey, thisKey);
+ }
+ SWCATCH ( ... ) { }
+ if (lkTest) {
+ SWTRY {
+ key = SWDYNAMIC_CAST(VerseKey, lkTest->getElement());
+ }
+ SWCATCH ( ... ) { }
+ }
+ }
+ if (!key) {
+ VerseKey *retKey = (tmpSecond) ? tmpVK1 : tmpVK2;
+ tmpSecond = !tmpSecond;
+ retKey->setLocale(LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName());
+ (*retKey) = *(thisKey);
+ return (*retKey);
+ }
+ else return *key;
+}
+
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/comments/zcom/Makefile b/src/modules/comments/zcom/Makefile
new file mode 100644
index 0000000..35d6648
--- /dev/null
+++ b/src/modules/comments/zcom/Makefile
@@ -0,0 +1,5 @@
+
+root := ../../../..
+
+all:
+ make -C ${root}
diff --git a/src/modules/comments/zcom/Makefile.am b/src/modules/comments/zcom/Makefile.am
new file mode 100644
index 0000000..f22700c
--- /dev/null
+++ b/src/modules/comments/zcom/Makefile.am
@@ -0,0 +1,2 @@
+zcomdir = $(top_srcdir)/src/modules/comments/zcom
+libsword_la_SOURCES += $(zcomdir)/zcom.cpp
diff --git a/src/modules/comments/zcom/zcom.cpp b/src/modules/comments/zcom/zcom.cpp
new file mode 100644
index 0000000..65c4ca8
--- /dev/null
+++ b/src/modules/comments/zcom/zcom.cpp
@@ -0,0 +1,220 @@
+/******************************************************************************
+ *
+ * zcom.cpp - code for class 'zCom'- a module that reads raw commentary
+ * files
+ *
+ * $Id: zcom.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+#include <swbuf.h>
+#include <zverse.h>
+#include <versekey.h>
+#include <zcom.h>
+#include <filemgr.h>
+
+SWORD_NAMESPACE_START
+
+/******************************************************************************
+ * zCom Constructor - Initializes data for instance of zCom
+ *
+ * ENT: ipath - path to data files
+ * iname - Internal name for module
+ * idesc - Name to display to user for module
+ * iblockType - verse, chapter, book, etc. of index chunks
+ * icomp - Compressor object
+ * idisp - Display object to use for displaying
+ */
+
+zCom::zCom(const char *ipath, const char *iname, const char *idesc, int iblockType, SWCompress *icomp, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char *ilang, const char *versification) : zVerse(ipath, -1, iblockType, icomp), SWCom(iname, idesc, idisp, enc, dir, mark, ilang, versification)/*, SWCompress()*/
+{
+ blockType = iblockType;
+ lastWriteKey = 0;
+}
+
+/******************************************************************************
+ * zCom Destructor - Cleans up instance of zCom
+ */
+
+zCom::~zCom() {
+ flushCache();
+
+ if (lastWriteKey)
+ delete lastWriteKey;
+}
+
+
+bool zCom::isWritable() const {
+ return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
+}
+
+
+/******************************************************************************
+ * zCom::getRawEntry - Returns the correct verse when char * cast
+ * is requested
+ *
+ * RET: string buffer with verse
+ */
+SWBuf &zCom::getRawEntryBuf() const {
+ long start = 0;
+ unsigned short size = 0;
+ unsigned long buffnum;
+ VerseKey *key = &getVerseKey();
+
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size, &buffnum);
+ entrySize = size; // support getEntrySize call
+
+ entryBuf = "";
+ zReadText(key->getTestament(), start, size, buffnum, entryBuf);
+
+ rawFilter(entryBuf, key);
+
+// if (!isUnicode())
+ prepText(entryBuf);
+
+ return entryBuf;
+}
+
+
+bool zCom::sameBlock(VerseKey *k1, VerseKey *k2) {
+ if (k1->getTestament() != k2->getTestament())
+ return false;
+
+ switch (blockType) {
+ case VERSEBLOCKS:
+ if (k1->getVerse() != k2->getVerse())
+ return false;
+ case CHAPTERBLOCKS:
+ if (k1->getChapter() != k2->getChapter())
+ return false;
+ case BOOKBLOCKS:
+ if (k1->getBook() != k2->getBook())
+ return false;
+ }
+ return true;
+}
+
+void zCom::setEntry(const char *inbuf, long len) {
+ VerseKey *key = &getVerseKey();
+
+ // see if we've jumped across blocks since last write
+ if (lastWriteKey) {
+ if (!sameBlock(lastWriteKey, key)) {
+ flushCache();
+ }
+ delete lastWriteKey;
+ }
+
+ doSetText(key->getTestament(), key->getTestamentIndex(), inbuf, len);
+
+ lastWriteKey = (VerseKey *)key->clone(); // must delete
+}
+
+
+void zCom::linkEntry(const SWKey *inkey) {
+ VerseKey *destkey = &getVerseKey();
+ const VerseKey *srckey = &getVerseKey(inkey);
+
+ doLinkEntry(destkey->getTestament(), destkey->getTestamentIndex(), srckey->getTestamentIndex());
+
+ if (inkey != srckey) // free our key if we created a VerseKey
+ delete srckey;
+}
+
+/******************************************************************************
+ * zCom::deleteEntry - deletes this entry
+ *
+ * RET: *this
+ */
+
+void zCom::deleteEntry() {
+
+ VerseKey *key = &getVerseKey();
+ doSetText(key->getTestament(), key->getTestamentIndex(), "");
+}
+
+
+/******************************************************************************
+ * zCom::increment - Increments module key a number of entries
+ *
+ * ENT: increment - Number of entries to jump forward
+ *
+ * RET: *this
+ */
+
+void zCom::increment(int steps) {
+ long start;
+ unsigned short size;
+ unsigned long buffnum;
+ VerseKey *tmpkey = &getVerseKey();
+
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size, &buffnum);
+
+ SWKey lastgood = *tmpkey;
+ while (steps) {
+ long laststart = start;
+ unsigned short lastsize = size;
+ SWKey lasttry = *tmpkey;
+ (steps > 0) ? ++(*key) : --(*key);
+ tmpkey = &getVerseKey();
+
+ if ((error = key->popError())) {
+ *key = lastgood;
+ break;
+ }
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size, &buffnum);
+ if (
+ (((laststart != start) || (lastsize != size)) // we're a different entry
+// && (start > 0)
+ && (size)) // and we actually have a size
+ ||(!skipConsecutiveLinks)) { // or we don't want to skip consecutive links
+ steps += (steps < 0) ? 1 : -1;
+ lastgood = *tmpkey;
+ }
+ }
+ error = (error) ? KEYERR_OUTOFBOUNDS : 0;
+}
+
+bool zCom::isLinked(const SWKey *k1, const SWKey *k2) const {
+ long start1, start2;
+ unsigned short size1, size2;
+ unsigned long buffnum1, buffnum2;
+ VerseKey *vk1 = &getVerseKey(k1);
+ VerseKey *vk2 = &getVerseKey(k2);
+ if (vk1->getTestament() != vk2->getTestament()) return false;
+
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1, &buffnum1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2, &buffnum2);
+ return start1 == start2 && buffnum1 == buffnum2;
+}
+
+bool zCom::hasEntry(const SWKey *k) const {
+ long start;
+ unsigned short size;
+ unsigned long buffnum;
+ VerseKey *vk = &getVerseKey(k);
+
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size, &buffnum);
+ return size;
+}
+
+SWORD_NAMESPACE_END