[sword-svn] r2245 - in trunk: bindings/corba/java include src/mgr src/modules src/modules/comments src/modules/comments/rawcom src/modules/comments/rawcom4 src/modules/comments/zcom src/modules/texts src/modules/texts/rawtext src/modules/texts/rawtext4 src/modules/texts/ztext utilities

scribe at crosswire.org scribe at crosswire.org
Tue Feb 10 16:22:29 MST 2009


Author: scribe
Date: 2009-02-10 16:22:28 -0700 (Tue, 10 Feb 2009)
New Revision: 2245

Modified:
   trunk/bindings/corba/java/Makefile
   trunk/include/rawcom.h
   trunk/include/rawcom4.h
   trunk/include/rawtext.h
   trunk/include/rawtext4.h
   trunk/include/swcom.h
   trunk/include/swmodule.h
   trunk/include/swtext.h
   trunk/include/zcom.h
   trunk/include/ztext.h
   trunk/src/mgr/filemgr.cpp
   trunk/src/modules/comments/rawcom/rawcom.cpp
   trunk/src/modules/comments/rawcom4/rawcom4.cpp
   trunk/src/modules/comments/swcom.cpp
   trunk/src/modules/comments/zcom/zcom.cpp
   trunk/src/modules/swmodule.cpp
   trunk/src/modules/texts/rawtext/rawtext.cpp
   trunk/src/modules/texts/rawtext4/rawtext4.cpp
   trunk/src/modules/texts/swtext.cpp
   trunk/src/modules/texts/ztext/ztext.cpp
   trunk/utilities/imp2vs.cpp
   trunk/utilities/osis2mod.cpp
Log:
Added versification c-tor param to Bible drivers


Modified: trunk/bindings/corba/java/Makefile
===================================================================
--- trunk/bindings/corba/java/Makefile	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/bindings/corba/java/Makefile	2009-02-10 23:22:28 UTC (rev 2245)
@@ -1,8 +1,8 @@
 TOMCAT_HOME=/opt/tomcat
 #SERVLET_LIB=${TOMCAT_HOME}/common/lib/servlet-api.jar
 SERVLET_LIB=${TOMCAT_HOME}/lib/servlet-api.jar
-#instdir=/home/scribe/public_html/
-instdir=/home/scribe/src/swordweb/webapp
+instdir=/home/swordweb/livehtml/webapp
+#instdir=/home/scribe/src/swordweb/webapp
 all: src/org/crosswire/sword/orb/SWMgr.java classes/org/crosswire/sword/orb/SwordOrb.class
 
 src/org/crosswire/sword/orb/SWMgr.java: ../swordorb.idl

Modified: trunk/include/rawcom.h
===================================================================
--- trunk/include/rawcom.h	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/include/rawcom.h	2009-02-10 23:22:28 UTC (rev 2245)
@@ -36,9 +36,9 @@
 public:
     
 	RawCom(const char *ipath, const char *iname = 0, const char *idesc = 0,
-			SWDisplay * idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN,
+			SWDisplay *idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN,
 			SWTextDirection dir = DIRECTION_LTR, SWTextMarkup markup = FMT_UNKNOWN,
-			const char* ilang = 0);
+			const char *ilang = 0, const char *versification = "KJV");
 	virtual ~RawCom();
 
 	virtual SWBuf &getRawEntryBuf();

Modified: trunk/include/rawcom4.h
===================================================================
--- trunk/include/rawcom4.h	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/include/rawcom4.h	2009-02-10 23:22:28 UTC (rev 2245)
@@ -36,9 +36,9 @@
 public:
     
 	RawCom4(const char *ipath, const char *iname = 0, const char *idesc = 0,
-			SWDisplay * idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN,
+			SWDisplay *idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN,
 			SWTextDirection dir = DIRECTION_LTR, SWTextMarkup markup = FMT_UNKNOWN,
-			const char* ilang = 0);
+			const char *ilang = 0, const char *versification = "KJV");
 	virtual ~RawCom4();
 
 	virtual SWBuf &getRawEntryBuf();

Modified: trunk/include/rawtext.h
===================================================================
--- trunk/include/rawtext.h	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/include/rawtext.h	2009-02-10 23:22:28 UTC (rev 2245)
@@ -36,8 +36,7 @@
 
 public:
   
-	RawText(const char *ipath, const char *iname = 0, const char *idesc = 0, SWDisplay * idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN, SWTextDirection dir = DIRECTION_LTR, SWTextMarkup markup = FMT_UNKNOWN,
-	const char* ilang = 0);
+	RawText(const char *ipath, const char *iname = 0, const char *idesc = 0, SWDisplay * idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN, SWTextDirection dir = DIRECTION_LTR, SWTextMarkup markup = FMT_UNKNOWN, const char* ilang = 0, const char *versification = "KJV");
 	virtual ~RawText();
 	virtual SWBuf &getRawEntryBuf();
 	virtual void increment(int steps = 1);

Modified: trunk/include/rawtext4.h
===================================================================
--- trunk/include/rawtext4.h	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/include/rawtext4.h	2009-02-10 23:22:28 UTC (rev 2245)
@@ -37,8 +37,7 @@
 
 public:
   
-	RawText4(const char *ipath, const char *iname = 0, const char *idesc = 0, SWDisplay * idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN, SWTextDirection dir = DIRECTION_LTR, SWTextMarkup markup = FMT_UNKNOWN,
-	const char* ilang = 0);
+	RawText4(const char *ipath, const char *iname = 0, const char *idesc = 0, SWDisplay * idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN, SWTextDirection dir = DIRECTION_LTR, SWTextMarkup markup = FMT_UNKNOWN, const char* ilang = 0, const char *versification = "KJV");
 	virtual ~RawText4();
 	virtual SWBuf &getRawEntryBuf();
 	virtual void increment(int steps = 1);

Modified: trunk/include/swcom.h
===================================================================
--- trunk/include/swcom.h	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/include/swcom.h	2009-02-10 23:22:28 UTC (rev 2245)
@@ -37,6 +37,7 @@
 class SWDLLEXPORT SWCom : public SWModule {
 
 	mutable VerseKey *tmpVK;
+	char *versification;
 
 protected:
 	VerseKey &getVerseKey() const;
@@ -47,9 +48,10 @@
 	/** Initializes data for instance of SWCom
 	*/
 	SWCom(const char *imodname = 0, const char *imoddesc = 0,
-			SWDisplay * idisp = 0, SWTextEncoding enc = ENC_UNKNOWN,
+			SWDisplay *idisp = 0, SWTextEncoding enc = ENC_UNKNOWN,
 			SWTextDirection dir = DIRECTION_LTR,
-			SWTextMarkup mark = FMT_UNKNOWN, const char* ilang = 0);
+			SWTextMarkup mark = FMT_UNKNOWN, const char *ilang = 0,
+			const char *versification = "KJV");
 
 	virtual ~SWCom();
 	virtual SWKey *CreateKey();

Modified: trunk/include/swmodule.h
===================================================================
--- trunk/include/swmodule.h	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/include/swmodule.h	2009-02-10 23:22:28 UTC (rev 2245)
@@ -155,7 +155,7 @@
 	 * @param markup Source Markup of the module (e.g. OSIS)
 	 * @param modlang Language of the module (e.g. en)
 	 */
-	SWModule(const char *imodname = 0, const char *imoddesc = 0, SWDisplay * idisp = 0, char *imodtype = 0, SWTextEncoding encoding = ENC_UNKNOWN, SWTextDirection dir = DIRECTION_LTR, SWTextMarkup markup = FMT_UNKNOWN, const char* modlang = 0);
+	SWModule(const char *imodname = 0, const char *imoddesc = 0, SWDisplay * idisp = 0, const char *imodtype = 0, SWTextEncoding encoding = ENC_UNKNOWN, SWTextDirection dir = DIRECTION_LTR, SWTextMarkup markup = FMT_UNKNOWN, const char *modlang = 0);
 
 	/** SWModule d-tor
 	 */

Modified: trunk/include/swtext.h
===================================================================
--- trunk/include/swtext.h	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/include/swtext.h	2009-02-10 23:22:28 UTC (rev 2245)
@@ -37,6 +37,7 @@
 
 	// for conversion if we have been set with a different internal key type
 	mutable VerseKey *tmpVK;
+	char *versification;
 
 protected:
 	VerseKey &getVerseKey() const;
@@ -45,10 +46,11 @@
 	/** Initializes data for instance of SWText
 	*/
 	SWText(const char *imodname = 0, const char *imoddesc = 0,
-			SWDisplay * idisp = 0,
+			SWDisplay *idisp = 0,
 			SWTextEncoding encoding = ENC_UNKNOWN,
 			SWTextDirection dir = DIRECTION_LTR,
-			SWTextMarkup markup = FMT_UNKNOWN, const char* ilang = 0);
+			SWTextMarkup markup = FMT_UNKNOWN, const char *ilang = 0,
+			const char *versification = "KJV");
 
 	virtual ~SWText();
 	/** Create the correct key (VerseKey) for use with SWText

Modified: trunk/include/zcom.h
===================================================================
--- trunk/include/zcom.h	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/include/zcom.h	2009-02-10 23:22:28 UTC (rev 2245)
@@ -39,10 +39,11 @@
 public:
 
 	zCom(const char *ipath, const char *iname = 0, const char *idesc = 0,
-			int blockType = CHAPTERBLOCKS, SWCompress * icomp = 0,
-			SWDisplay * idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN,
+			int blockType = CHAPTERBLOCKS, SWCompress *icomp = 0,
+			SWDisplay *idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN,
 			SWTextDirection dir = DIRECTION_LTR,
-			SWTextMarkup markup = FMT_UNKNOWN, const char* ilang = 0);
+			SWTextMarkup markup = FMT_UNKNOWN, const char *ilang = 0,
+			const char *versification = "KJV");
 	virtual ~zCom();
 	virtual SWBuf &getRawEntryBuf();
 	virtual void increment(int steps = 1);

Modified: trunk/include/ztext.h
===================================================================
--- trunk/include/ztext.h	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/include/ztext.h	2009-02-10 23:22:28 UTC (rev 2245)
@@ -52,10 +52,11 @@
 public:
     
 	zText(const char *ipath, const char *iname = 0, const char *idesc = 0,
-			int blockType = CHAPTERBLOCKS, SWCompress * icomp = 0,
-			SWDisplay * idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN,
+			int blockType = CHAPTERBLOCKS, SWCompress *icomp = 0,
+			SWDisplay *idisp = 0, SWTextEncoding encoding = ENC_UNKNOWN,
 			SWTextDirection dir = DIRECTION_LTR,
-			SWTextMarkup markup = FMT_UNKNOWN, const char* ilang = 0);
+			SWTextMarkup markup = FMT_UNKNOWN, const char *ilang = 0,
+			const char *versification = "KJV");
 
 	virtual ~zText();
 	virtual SWBuf &getRawEntryBuf();

Modified: trunk/src/mgr/filemgr.cpp
===================================================================
--- trunk/src/mgr/filemgr.cpp	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/src/mgr/filemgr.cpp	2009-02-10 23:22:28 UTC (rev 2245)
@@ -481,7 +481,7 @@
 			line.append(chunk+start, size);
 		}
 	}
-	return ((len>0) || line.length());
+	return ((len > 0) || line.length());
 }
 
 

Modified: trunk/src/modules/comments/rawcom/rawcom.cpp
===================================================================
--- trunk/src/modules/comments/rawcom/rawcom.cpp	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/src/modules/comments/rawcom/rawcom.cpp	2009-02-10 23:22:28 UTC (rev 2245)
@@ -39,9 +39,9 @@
  *	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)
+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){
+            SWCom(iname, idesc, idisp, encoding, dir, markup, ilang, versification) {
 }
 
 

Modified: trunk/src/modules/comments/rawcom4/rawcom4.cpp
===================================================================
--- trunk/src/modules/comments/rawcom4/rawcom4.cpp	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/src/modules/comments/rawcom4/rawcom4.cpp	2009-02-10 23:22:28 UTC (rev 2245)
@@ -38,9 +38,9 @@
  *	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)
+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){
+            SWCom(iname, idesc, idisp, encoding, dir, markup, ilang, versification) {
 }
 
 

Modified: trunk/src/modules/comments/swcom.cpp
===================================================================
--- trunk/src/modules/comments/swcom.cpp	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/src/modules/comments/swcom.cpp	2009-02-10 23:22:28 UTC (rev 2245)
@@ -20,12 +20,15 @@
  */
 
 
+#include <utilstr.h>
 #include <swcom.h>
 #include <localemgr.h>
 #include <versekey.h>
 
+
 SWORD_NAMESPACE_START
 
+
 /******************************************************************************
  * SWCom Constructor - Initializes data for instance of SWCom
  *
@@ -34,10 +37,12 @@
  *	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): SWModule(imodname, imoddesc, idisp, (char *)"Commentaries", enc, dir, mark, ilang) {
+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 = CreateKey();
-	tmpVK = new VerseKey();
+	key = (VerseKey *)CreateKey();
+	tmpVK = (VerseKey *)CreateKey();
 }
 
 
@@ -47,12 +52,19 @@
 
 SWCom::~SWCom() {
 	delete tmpVK;
+	delete [] versification;
 }
 
 
-SWKey *SWCom::CreateKey() { return new VerseKey(); }
+SWKey *SWCom::CreateKey() {
+	VerseKey *vk = new VerseKey();
 
+	vk->setVersificationSystem(versification);
 
+	return vk;
+}
+
+
 long SWCom::Index() const {
 	VerseKey *key = 0;
 	SWTRY {
@@ -119,4 +131,5 @@
 	else	return *key;
 }
 
+
 SWORD_NAMESPACE_END

Modified: trunk/src/modules/comments/zcom/zcom.cpp
===================================================================
--- trunk/src/modules/comments/zcom/zcom.cpp	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/src/modules/comments/zcom/zcom.cpp	2009-02-10 23:22:28 UTC (rev 2245)
@@ -41,7 +41,7 @@
  *		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) : zVerse(ipath, -1, iblockType, icomp), SWCom(iname, idesc, idisp, enc, dir, mark, ilang)/*, SWCompress()*/
+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;

Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/src/modules/swmodule.cpp	2009-02-10 23:22:28 UTC (rev 2245)
@@ -76,7 +76,7 @@
  *	unicode  - if this module is unicode
  */
 
-SWModule::SWModule(const char *imodname, const char *imoddesc, SWDisplay *idisp, char *imodtype, SWTextEncoding encoding, SWTextDirection direction, SWTextMarkup markup, const char* imodlang) {
+SWModule::SWModule(const char *imodname, const char *imoddesc, SWDisplay *idisp, const char *imodtype, SWTextEncoding encoding, SWTextDirection direction, SWTextMarkup markup, const char *imodlang) {
 	key       = CreateKey();
 	entryBuf  = "";
 	config    = &ownConfig;

Modified: trunk/src/modules/texts/rawtext/rawtext.cpp
===================================================================
--- trunk/src/modules/texts/rawtext/rawtext.cpp	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/src/modules/texts/rawtext/rawtext.cpp	2009-02-10 23:22:28 UTC (rev 2245)
@@ -57,8 +57,8 @@
  *	idisp	 - Display object to use for displaying
  */
 
-RawText::RawText(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang)
-		: SWText(iname, idesc, idisp, enc, dir, mark, ilang),
+RawText::RawText(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, const char *versification)
+		: SWText(iname, idesc, idisp, enc, dir, mark, ilang, versification),
 		RawVerse(ipath) {
 }
 

Modified: trunk/src/modules/texts/rawtext4/rawtext4.cpp
===================================================================
--- trunk/src/modules/texts/rawtext4/rawtext4.cpp	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/src/modules/texts/rawtext4/rawtext4.cpp	2009-02-10 23:22:28 UTC (rev 2245)
@@ -57,8 +57,8 @@
  *	idisp	 - Display object to use for displaying
  */
 
-RawText4::RawText4(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang)
-		: SWText(iname, idesc, idisp, enc, dir, mark, ilang),
+RawText4::RawText4(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, const char *versification)
+		: SWText(iname, idesc, idisp, enc, dir, mark, ilang, versification),
 		RawVerse4(ipath) {
 }
 

Modified: trunk/src/modules/texts/swtext.cpp
===================================================================
--- trunk/src/modules/texts/swtext.cpp	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/src/modules/texts/swtext.cpp	2009-02-10 23:22:28 UTC (rev 2245)
@@ -18,6 +18,7 @@
  *
  */
 
+#include <utilstr.h>
 #include <swtext.h>
 #include <listkey.h>
 #include <localemgr.h>
@@ -33,10 +34,12 @@
  *	idisp	 - Display object to use for displaying
  */
 
-SWText::SWText(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang): SWModule(imodname, imoddesc, idisp, (char *)"Biblical Texts", enc, dir, mark, ilang) {
-	tmpVK = new VerseKey();
+SWText::SWText(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, const char *versification): SWModule(imodname, imoddesc, idisp, "Biblical Texts", enc, dir, mark, ilang) {
+	this->versification = 0;
+	stdstr(&(this->versification), versification);
 	delete key;
-	key = CreateKey();
+	key = (VerseKey *)CreateKey();
+	tmpVK = (VerseKey *)CreateKey();
 	skipConsecutiveLinks = false;
 }
 
@@ -47,6 +50,7 @@
 
 SWText::~SWText() {
 	delete tmpVK;
+	delete [] versification;
 }
 
 
@@ -57,12 +61,8 @@
 SWKey *SWText::CreateKey() {
 	VerseKey *vk = new VerseKey();
 
-// TODO: put this config check somewhere once
-//	SWBuf versif = getConfigEntry("Versification");
-//
-//	if (versif.length() > 0)
-//	vk->setVersificationSystem(versif);
-//
+	vk->setVersificationSystem(versification);
+
 	return vk;
 }
 

Modified: trunk/src/modules/texts/ztext/ztext.cpp
===================================================================
--- trunk/src/modules/texts/ztext/ztext.cpp	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/src/modules/texts/ztext/ztext.cpp	2009-02-10 23:22:28 UTC (rev 2245)
@@ -44,8 +44,8 @@
  *		idisp - Display object to use for displaying
  */
 
-zText::zText(const char *ipath, const char *iname, const char *idesc, int iblockType, SWCompress *icomp, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang)
-		: zVerse(ipath, FileMgr::RDWR, iblockType, icomp), SWText(iname, idesc, idisp, enc, dir, mark, ilang) {
+zText::zText(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, FileMgr::RDWR, iblockType, icomp), SWText(iname, idesc, idisp, enc, dir, mark, ilang, versification) {
 	blockType = iblockType;
 	lastWriteKey = 0;
 }

Modified: trunk/utilities/imp2vs.cpp
===================================================================
--- trunk/utilities/imp2vs.cpp	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/utilities/imp2vs.cpp	2009-02-10 23:22:28 UTC (rev 2245)
@@ -15,185 +15,179 @@
  *
  */
 
-#include <ctype.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string>
-#include <fstream>
 using namespace std;
 
 #include <iostream>
 #include <rawtext.h>
  #include <rawtext4.h>
 #include <versekey.h>
+#include <swbuf.h>
+#include <filemgr.h>
 
 
 #ifndef NO_SWORD_NAMESPACE
-using sword::RawText;
-using sword::RawText4;
-using sword::VerseKey;
-using sword::SWText;
-using sword::ListKey;
+using namespace sword;
 #endif
 
-int main(int argc, char **argv) {
-  
-  const string helptext ="imp2vs 1.0 Bible/Commentary module creation tool for the SWORD Project\n  usage:\n   %s <filename> [output dir] \n";
-  
-  string keybuffer = "";
-  string entbuffer = "";
-  string linebuffer = "";
-  string modname = "";
-  
-  if (argc > 2) {
-    modname = argv[2];
-  }
-  else if (argc > 1) {
-    modname = "./";
-  }
-  else {
-    fprintf(stderr, helptext.c_str(), argv[0]);
-    exit(-1);
-  }
-  int mode = 1;
-  if (argc > 3) {
-    switch (*argv[3]) {
-    case '4':
-      mode = 2;
-      break;
-    default:
-      mode = 1;
-    }
-  }
-  
+void writeEntry(const SWBuf &key, const SWBuf &entry, SWModule *module);
 
+void usage(const char *progName, const char *error = 0) {
+	if (error) fprintf(stderr, "\n%s: %s\n", progName, error);
+	fprintf(stderr, "%s (Revision $Rev: 2234 $) SWORD Bible/Commentary importer.\n", progName);
+	fprintf(stderr, "usage: %s <imp_file> [options]\n"
+		"\t -a augment module if exists (default is to create new)\n"
+		"\t -o <output_path> where to write data files.\n"
+		"\t -4 use 4 byte size entries (default is 2).\n"
+		, progName);
+	exit(-1);
+}
 
-  try {
-  
-  ifstream infile(argv[1]);
 
-  SWText* mod;
-  RawText * modRaw;
-  RawText4 * modRaw4;
-  
-  if (mode == 1) {
-          RawText::createModule(modname.c_str());
-          modRaw= new RawText(modname.c_str());
-          mod = modRaw;
-  } else {
-          RawText4::createModule(modname.c_str());
-          modRaw4= new RawText4(modname.c_str());
-          mod = modRaw4;
-  }
+int main(int argc, char **argv) {
 
-  VerseKey* vkey = new VerseKey;
-  vkey->Headings(1);
-  vkey->AutoNormalize(0);
-  vkey->Persist(1);
-  mod->setKey(*vkey);
-  char final; // 2 == pre-final line; 1 == final line; 0 == EOF
 
-  getline(infile,linebuffer);
-  final = (!infile.eof()) + 1;
+	// handle options
+	if (argc < 2) usage(*argv);
 
-  while (final) {
-    if (final == 1 || (linebuffer.size() > 3 && linebuffer.substr(0,3) == "$$$")) {
-      if (keybuffer.size() && entbuffer.size()) {
-	std::cout << "from file: " << keybuffer << std::endl;
-	*vkey = keybuffer.c_str();
-	if (!vkey->Chapter()) {
-	  // bad hack:  0:0 is Book intro; (chapter):0 is Chapter intro; 0:2 is Module intro; 0:1 is Testament intro
-	  int backstep = vkey->Verse();
-	  if (backstep) {
-		  vkey->Verse(1);
-		  vkey->Chapter(1);
-		  switch (backstep) {
-		  case 2:
-			  vkey->Book(1);
-			  vkey->Testament(0);
-		  case 1:
-			  vkey->Book(0);
-			  vkey->Chapter(0);
-		  }
-		  vkey->Verse(0);
-       }
+	const char *progName   = argv[0];
+	const char *inFileName = argv[1];
+	SWBuf outPath          = "./";
+	bool fourByteSize      = false;
+	bool append            = false;
 
-	  std::cout << "adding entry: " << *vkey << " length " << entbuffer.size() << "/" << (unsigned short)entbuffer.size() << std::endl;
-	  mod->setEntry(entbuffer.c_str(), entbuffer.size());
+	for (int i = 2; i < argc; i++) {
+		if (!strcmp(argv[i], "-a")) {
+			append = true;
+		}
+		else if (!strcmp(argv[i], "-o")) {
+			if (i+1 < argc) outPath = argv[++i];
+			else usage(progName, "-o requires <output_path>");
+		}
+		else usage(progName, (((SWBuf)"Unknown argument: ")+ argv[i]).c_str());
 	}
-	else {
-	  ListKey listkey = vkey->ParseVerseList(keybuffer.c_str(), "Gen1:1", true);
-	  int i;
-	  bool havefirst = false;
-	  VerseKey firstverse;
-	  firstverse.Headings(1);
-	  firstverse.AutoNormalize(0);
-	  for (i = 0; i < listkey.Count(); i++) {
-	    VerseKey *element = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(i));
-	    if (element) {
-	      *vkey = element->LowerBound();
-	      VerseKey finalkey = element->UpperBound();
-		  finalkey.Headings(1);
-		  finalkey.AutoNormalize(0);
-	      if (!havefirst) {
-		havefirst = true;
-		firstverse = *vkey;
+	// -----------------------------------------------------
 
-		std::cout << "adding entry: " << *vkey << " length " << entbuffer.size() << "/" << (unsigned short)entbuffer.size() << std::endl;
-		mod->setEntry(entbuffer.c_str(), entbuffer.size());
-		(*vkey)++;
-	      }
-	      while (! (finalkey < (*vkey))) {
-		std::cout << "linking entry: " << *vkey << " to " << firstverse << std::endl;
-		*mod << &firstverse;
-		(*vkey)++;
-	      }
-	    }
-	    else {
-	      if (havefirst) {
-		*vkey = (*listkey.GetElement(i));
-		std::cout << "linking entry: " << *vkey << " to " << firstverse << std::endl;
-		*mod << &firstverse;
-	      }
-	      else {
-		*vkey = (*listkey.GetElement(i));
-		havefirst = true;
-		firstverse = *vkey;
 
-		std::cout << "adding entry: " << *vkey << " length " << entbuffer.size() << "/" << (unsigned short)entbuffer.size() << std::endl;
-		mod->setEntry(entbuffer.c_str(), entbuffer.size());
-	      }
-	    }
-	  }
+	// setup module
+	if (!append) {
+		if (!fourByteSize)
+			RawText::createModule(outPath);
+		else	RawText4::createModule(outPath);
 	}
-      }
-      if (linebuffer.size() > 3)
-	      keybuffer = linebuffer.substr(3,linebuffer.size()) ;
-      entbuffer.resize(0);
-    }
-    else {
-      entbuffer.append(linebuffer);
-    }
-    final--;
-    if (final) {
-      getline(infile,linebuffer);
-      final = (!infile.eof()) + 1;
-    }
-  }
-  }
-  catch (const std::exception& e) {
-         std::cerr << "Exception: imp2vs failed: " << e.what() << std::endl;
-	 std::cerr << "Line: " << linebuffer.size() << " " << linebuffer << std::endl;
-	 std::cerr << "Key: "  << keybuffer.size() << " " << keybuffer << std::endl;
-	 std::cerr << "Ent: "  << entbuffer.size() << " " << entbuffer << std::endl;
-         return -2;
-  }
-  catch (...) {
-         std::cerr << "Exception: imp2vs failed" << std::endl;
-         return -3;
-  }
 
-  return 0;
+	SWModule *module = (!fourByteSize)
+			? (SWModule *)new RawText(outPath)
+			: (SWModule *)new RawText4(outPath);
+	// -----------------------------------------------------
+			
+
+	// setup module key to allow full range of possible values, and then some
+	VerseKey *vkey = (VerseKey *)module->CreateKey();
+	vkey->Headings(1);
+	vkey->AutoNormalize(0);
+	vkey->Persist(1);
+	module->setKey(*vkey);
+	// -----------------------------------------------------
+
+
+	// process input file
+	FileDesc *fd = FileMgr::getSystemFileMgr()->open(inFileName, FileMgr::RDONLY);
+
+	SWBuf lineBuffer;
+	SWBuf currentKey;
+	SWBuf currentEntry;
+
+	while (FileMgr::getLine(fd, lineBuffer)) {
+		if (lineBuffer.startsWith("$$$")) {
+			writeEntry(currentKey, currentEntry, module);
+			currentKey = lineBuffer;
+			currentKey << 3;
+			currentKey.trim();
+			currentEntry = "";
+		}
+		else {
+			currentEntry += lineBuffer;
+		}
+	}
+	writeEntry(currentKey, currentEntry, module);
+
+	return 0;
 }
+
+
+
+
+
+void writeEntry(const SWBuf &key, const SWBuf &entry, SWModule *module)
+{
+	if (key.size() && entry.size()) {
+		std::cout << "from file: " << key << std::endl;
+		VerseKey *vkey = (VerseKey *)module->getKey();
+		*vkey = key;
+		if (!vkey->Chapter()) {
+			// bad hack:  0:0 is Book intro; (chapter):0 is Chapter intro; 0:2 is Module intro; 0:1 is Testament intro
+			int backstep = vkey->Verse();
+			if (backstep) {
+				vkey->Verse(1);
+				vkey->Chapter(1);
+				switch (backstep) {
+				case 2:
+					vkey->Book(1);
+					vkey->Testament(0);
+				case 1:
+					vkey->Book(0);
+					vkey->Chapter(0);
+				}
+				vkey->Verse(0);
+			}
+
+			std::cout << "adding entry: " << *vkey << " length " << entry.size() << "/" << (unsigned short)entry.size() << std::endl;
+			module->setEntry(entry.c_str(), entry.size());
+		}
+		else {
+			ListKey listkey = vkey->ParseVerseList(key.c_str(), "Gen1:1", true);
+			int i;
+			bool havefirst = false;
+			VerseKey firstverse;
+			firstverse.Headings(1);
+			firstverse.AutoNormalize(0);
+			for (i = 0; i < listkey.Count(); i++) {
+				VerseKey *element = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(i));
+				if (element) {
+					*vkey = element->LowerBound();
+					VerseKey finalkey = element->UpperBound();
+					finalkey.Headings(1);
+					finalkey.AutoNormalize(0);
+					if (!havefirst) {
+						havefirst = true;
+						firstverse = *vkey;
+
+						std::cout << "adding entry: " << *vkey << " length " << entry.size() << "/" << (unsigned short)entry.size() << std::endl;
+						module->setEntry(entry.c_str(), entry.size());
+						(*vkey)++;
+					}
+					while (! (finalkey < (*vkey))) {
+						std::cout << "linking entry: " << *vkey << " to " << firstverse << std::endl;
+						*module << &firstverse;
+						(*vkey)++;
+					}
+				}
+				else {
+					if (havefirst) {
+						*vkey = (*listkey.GetElement(i));
+						std::cout << "linking entry: " << *vkey << " to " << firstverse << std::endl;
+						*module << &firstverse;
+					}
+					else {
+						*vkey = (*listkey.GetElement(i));
+						havefirst = true;
+						firstverse = *vkey;
+
+						std::cout << "adding entry: " << *vkey << " length " << entry.size() << "/" << (unsigned short)entry.size() << std::endl;
+						module->setEntry(entry.c_str(), entry.size());
+					}
+				}
+			}
+		}
+	}
+}

Modified: trunk/utilities/osis2mod.cpp
===================================================================
--- trunk/utilities/osis2mod.cpp	2009-02-10 00:12:46 UTC (rev 2244)
+++ trunk/utilities/osis2mod.cpp	2009-02-10 23:22:28 UTC (rev 2245)
@@ -20,7 +20,6 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <stdlib.h>
-#include <string>
 #include <stack>
 #include <vector>
 #include <iostream>
@@ -1215,7 +1214,7 @@
 	int append          = 0;
 	int compType        = 0;
 	int iType           = 4;
-	string cipherKey    = "";
+	SWBuf cipherKey     = "";
 
 	SWCompress *compressor = 0;
 
@@ -1299,7 +1298,7 @@
 
 	SWFilter *cipherFilter = 0;
 
-	if (!cipherKey.empty()) {
+	if (cipherKey.length()) {
 		fprintf(stderr, "Adding cipher filter with phrase: %s\n", cipherKey.c_str() );
 		cipherFilter = new CipherFilter(cipherKey.c_str());
 		module->AddRawFilter(cipherFilter);




More information about the sword-cvs mailing list