[sword-svn] r425 - in trunk/misc: . olb

chrislit at crosswire.org chrislit at crosswire.org
Sat Jun 22 02:21:20 MST 2013


Author: chrislit
Date: 2013-06-22 02:21:20 -0700 (Sat, 22 Jun 2013)
New Revision: 425

Added:
   trunk/misc/olb/
   trunk/misc/olb/Convert.bpr
   trunk/misc/olb/Convert.cpp
   trunk/misc/olb/Doinit.c
   trunk/misc/olb/Getstrng.c
   trunk/misc/olb/Getvrsn.c
   trunk/misc/olb/Mainfrm.cpp
   trunk/misc/olb/Mainfrm.dfm
   trunk/misc/olb/Mainfrm.h
   trunk/misc/olb/Online.c
   trunk/misc/olb/addstrongs.cpp
   trunk/misc/olb/dumpav.cpp
   trunk/misc/olb/olb.bpg
   trunk/misc/olb/olb2sword.bpr
   trunk/misc/olb/olb2sword.cpp
   trunk/misc/olb/online.ide
   trunk/misc/olb/online.prj
   trunk/misc/olb/prn2sword.bpr
   trunk/misc/olb/prn2sword.cpp
   trunk/misc/olb/prn2swordfrm.cpp
   trunk/misc/olb/prn2swordfrm.dfm
   trunk/misc/olb/prn2swordfrm.h
Log:
moved this ancient, unmaintained, and unneeded converter from the sword SVN root

Added: trunk/misc/olb/Convert.bpr
===================================================================
--- trunk/misc/olb/Convert.bpr	                        (rev 0)
+++ trunk/misc/olb/Convert.bpr	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,116 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<!-- C++Builder XML Project -->
+<PROJECT>
+  <MACROS>
+    <VERSION value="BCB.05.03"/>
+    <PROJECT value="Convert.exe"/>
+    <OBJFILES value="Convert.obj Mainfrm.obj all.obj ..\src\keys\versekey.obj 
+      ..\src\keys\strkey.obj ..\src\keys\swkey.obj ..\src\keys\listkey.obj 
+      ..\src\utilfuns\utilstr.obj"/>
+    <RESFILES value="Convert.res"/>
+    <IDLFILES value=""/>
+    <DEFFILE value=""/>
+    <RESDEPEN value="$(RESFILES) Mainfrm.dfm"/>
+    <LIBFILES value=""/>
+    <LIBRARIES value=""/>
+    <SPARELIBS value="vcl50.lib"/>
+    <PACKAGES value="vclx50.bpi vcl50.bpi vcldb50.bpi vclbde50.bpi vcldbx50.bpi bcbsmp50.bpi 
+      dclocx50.bpi qrpt50.bpi teeui50.bpi vclsmp50.bpi teedb50.bpi tee50.bpi 
+      ibsmp50.bpi nmfast50.bpi inetdb50.bpi inet50.bpi"/>
+    <PATHCPP value=".;..\src\keys;..\src\utilfuns"/>
+    <PATHPAS value=".;"/>
+    <PATHRC value=".;"/>
+    <PATHASM value=".;"/>
+    <DEBUGLIBPATH value="$(BCB)\lib\debug"/>
+    <RELEASELIBPATH value="$(BCB)\lib\release"/>
+    <LINKER value="ilink32"/>
+    <USERDEFINES value=""/>
+    <SYSDEFINES value="NO_STRICT;_RTLDLL;_VIS_NOLIB;USEPACKAGES"/>
+    <MAINSOURCE value="Convert.cpp"/>
+    <INCLUDEPATH value="..\src\utilfuns;..\src\keys;$(BCB)\include;$(BCB)\include\vcl;..\include"/>
+    <LIBPATH value="..\src\utilfuns;..\src\keys;$(BCB)\lib\obj;$(BCB)\lib"/>
+    <WARNINGS value="-w-par -w-8027 -w-8026"/>
+    <WARNOPTSTR value=""/>
+  </MACROS>
+  <OPTIONS>
+    <IDLCFLAGS value="-I..\src\utilfuns -I..\src\keys -I$(BCB)\include -I$(BCB)\include\vcl 
+      -I..\include -src_suffix cpp -boa"/>
+    <CFLAG1 value="-Od -H=c:\PROGRA~1\BORLAND\CBUILD~1\lib\vcl50.csm -Hc -Vx -Ve -Tkh30000 
+      -X- -r- -a1 -b- -k -y -v -vi- -c -tW -tWM"/>
+    <PFLAGS value="-$YD -$W -$O- -v -M -JPHNE"/>
+    <RFLAGS value=""/>
+    <AFLAGS value="/mx /w2 /zd"/>
+    <LFLAGS value="-D&quot;&quot; -aa -Tpe -x -Gn -v"/>
+  </OPTIONS>
+  <LINKER>
+    <ALLOBJ value="c0w32.obj $(PACKAGES) Memmgr.Lib sysinit.obj $(OBJFILES)"/>
+    <ALLRES value="$(RESFILES)"/>
+    <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib"/>
+  </LINKER>
+  <IDEOPTIONS>
+[Version Info]
+IncludeVerInfo=0
+AutoIncBuild=0
+MajorVer=1
+MinorVer=0
+Release=0
+Build=0
+Debug=0
+PreRelease=0
+Special=0
+Private=0
+DLL=0
+Locale=1033
+CodePage=1252
+
+[Version Info Keys]
+CompanyName=
+FileDescription=
+FileVersion=1.0.0.0
+InternalName=
+LegalCopyright=
+LegalTrademarks=
+OriginalFilename=
+ProductName=
+ProductVersion=1.0.0.0
+Comments=
+
+[HistoryLists\hlIncludePath]
+Count=2
+Item0=..\src\utilfuns;..\src\keys;$(BCB)\include;$(BCB)\include\vcl;../include
+Item1=$(BCB)\include;$(BCB)\include\vcl;../include
+
+[HistoryLists\hlLibraryPath]
+Count=2
+Item0=..\src\utilfuns;..\src\keys;$(BCB)\lib\obj;$(BCB)\lib
+Item1=$(BCB)\lib\obj;$(BCB)\lib
+
+[HistoryLists\hlDebugSourcePath]
+Count=1
+Item0=$(BCB)\source\vcl
+
+[HistoryLists\hlConditionals]
+Count=1
+Item0=_RTLDLL;USEPACKAGES
+
+[Debugging]
+DebugSourceDirs=$(BCB)\source\vcl
+
+[Parameters]
+RunParams=
+HostApplication=
+RemoteHost=
+RemotePath=
+RemoteDebug=0
+
+[Compiler]
+ShowInfoMsgs=0
+LinkDebugVcl=0
+LinkCGLIB=0
+
+[Language]
+ActiveLang=
+ProjectLang=
+RootDir=
+  </IDEOPTIONS>
+</PROJECT>
\ No newline at end of file

Added: trunk/misc/olb/Convert.cpp
===================================================================
--- trunk/misc/olb/Convert.cpp	                        (rev 0)
+++ trunk/misc/olb/Convert.cpp	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2009 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 <vcl.h>
+#pragma hdrstop
+USERES("Convert.res");
+USEFORM("Mainfrm.cpp", Form1);
+USEUNIT("all.c");
+USEUNIT("..\src\keys\versekey.cpp");
+USEUNIT("..\src\keys\strkey.cpp");
+USEUNIT("..\src\keys\swkey.cpp");
+USEUNIT("..\src\keys\listkey.cpp");
+USEUNIT("..\src\utilfuns\utilstr.cpp");
+//---------------------------------------------------------------------------
+WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
+{
+	try
+	{
+		Application->Initialize();
+		Application->CreateForm(__classid(TForm1), &Form1);
+		Application->Run();
+	}
+	catch (Exception &exception)
+	{
+		Application->ShowException(&exception);
+	}
+	return 0;
+}
+//---------------------------------------------------------------------------

Added: trunk/misc/olb/Doinit.c
===================================================================
--- trunk/misc/olb/Doinit.c	                        (rev 0)
+++ trunk/misc/olb/Doinit.c	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2009 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 <online.dcl>
+struct zonline online;
+struct zversion version;
+struct zref ref;
+struct zstdindex stdindex;
+struct ztrace trace;
+/*
+  Initialises the System
+
+  Inputs:
+      pointer to path for files
+         e.g. c:\bible\scholar
+*/
+void DOINIT(CHAR *olbpath)
+{
+ static CHAR *titles[10] =
+    {"\\id.dat",      "\\text.dat", "\\textndx.dat", "\\tokens.dat",
+     "\\version.dat", "\\xref.dat", "\\xrefndx.dat", "\\xrefndxs.dat",
+     "\\cxref\\cxref.dat", "\\cxref\\cxrefndx.dat"};
+
+ CHAR  path[64];
+ static long int zero ={0};
+
+ struct
+    {
+     CHAR key;
+     CHAR size[2];
+     INT indexsize;
+     int token_blksize;
+    } record;
+
+ int   i;
+ int   j;
+
+ /*
+   Open Files
+ */
+
+ trace.level = -1;
+ X("Doinit");
+ for (i = 0; i < 8; i++)
+    {
+     STRCPY(path, olbpath, 64, "Doinit-1");
+     STRCAT(path, titles[i], 64,"Doinit-2");
+     call OPEN(i, path);
+     online.lrecl[i] = 0;
+    }
+
+ /*
+   Initialise Version Structure
+ */
+ call READ(fp_version, sizeof(version), &version.version_id);
+ call CLOSE(fp_version);
+ call DUMPLINE("VERSION.DAT", 16, &version.version_id);
+                 /* convert PLI strings to C-Weed format */
+/*
+ for (i = 0; i < 128; i++)
+    call PLITOC(&(version.hot_words[i][0]), 9);
+*/
+ for (i = 0; i < 66; i++)
+    call PLITOC(&(version.books[i][0]), 15);
+
+ /*
+   setup access to TEXT.DAT file
+ */
+ call DREAD(fp_textndx, 3, &record.key, zero);
+ call DUMPLINE("TEXTNDX.DAT", 3, &record.key);
+
+ online.textndxsz = record.size[0];
+ if (record.key == 0) then
+    online.lrecl[fp_textndx] = 3;
+ else
+    online.lrecl[fp_textndx] = record.size[0];
+
+ /*
+   setup access to XREF.DAT file
+ */
+ call DREAD(fp_xrefndx, 7, &record.key, zero);
+ call DUMPLINE("XREFNDX.DAT", 7, &record.key);
+ online.lrecl[fp_xrefndx] = record.size[0] + record.size[1];
+ online.xrefndxsz[0] = record.size[0];
+ online.xrefndxsz[1] = record.size[1];
+ if (record.key == 2) then
+    {
+     online.indexsize = record.indexsize;
+     online.tokenblksize = record.token_blksize * 2;
+     online.tokenarea = &online.tokenwork[0];
+    }
+ else
+     online.tokenblksize = 0;
+ /*
+   setup access to XREFNDXS.DAT file
+ */
+ call DREAD(fp_xrefndxs, 3, &record.key, zero);
+ call DUMPLINE("XREFNDXS.DAT", 3, &record.key);
+ if (record.key == 0) then
+    online.lrecl[fp_xrefndxs] = 3;
+ else
+    online.lrecl[fp_xrefndxs] = record.size[0];
+
+ online.version_mark = 3;
+ /*
+   Setup Version ID for multiple versions
+ */
+ call VERINIT();
+
+ /*
+   Setup Cross Reference Files
+ */
+ for (i = 8; i < 10; i++)
+    {
+     STRCPY(path, olbpath, 64, "Doinit-3");
+     j = strlen(path);
+     while(path[j] != '\\')
+        j--;
+     path[j] = 0;
+     STRCAT(path, titles[i], 64, "Doinit-4");
+     call OPEN(i, path);
+     online.lrecl[i] = 0;
+    }
+ /*
+   setup access to CXREF.DAT file
+ */
+ call DREAD(fp_cxrefndx, 3, &record.key, zero);
+ call DUMPLINE("CXREFNDX.DAT", 3, &record.key);
+ if (record.key == 0) then
+    online.lrecl[fp_cxrefndx] = 3;
+ else
+    online.lrecl[fp_cxrefndx] = record.size[0];
+ trace.traceflag = 1;
+ Y();
+}

Added: trunk/misc/olb/Getstrng.c
===================================================================
--- trunk/misc/olb/Getstrng.c	                        (rev 0)
+++ trunk/misc/olb/Getstrng.c	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2009 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 <online.dcl>
+
+void GETSTRNG(strongs_no, verse_list, otflg)
+
+                           /* get verses for a given strongs no */
+
+int strongs_no;            /* strongs number to fetch verse list for */
+INT verse_list[MAX_LIST];  /* resultant verse list */
+CHAR otflg;                /* Old Testament Number flag */
+{
+ extern struct zversion version;
+ int entry_size;
+ long int seek_posn;
+
+ X("Getstrng");
+ if (strongs_no > 8849 || strongs_no < 0) then
+    ERROR("Getstrng - Invalid Strong's Number");
+
+ entry_size = READNDX(strongs_no, fp_xrefndxs, &seek_posn);
+ call LISTLOAD(fp_xref, entry_size, verse_list, seek_posn);
+ if (otflg == 0) then
+    call LISTRANG(verse_list, version.nt_ver, version.total_ver);
+ else
+    call LISTRANG(verse_list, 1, version.nt_ver - 1);
+ Y();
+}

Added: trunk/misc/olb/Getvrsn.c
===================================================================
--- trunk/misc/olb/Getvrsn.c	                        (rev 0)
+++ trunk/misc/olb/Getvrsn.c	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2009 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 <online.dcl>
+
+/*
+  Get version id for display
+
+  If triple verse A_B_C then
+
+  Inputs:
+      1 - returns "A"
+      2 - returns "B"
+      3 - returns "A_B"
+      4 - returns "C"
+      5 - returns "A_C"
+      6 - returns "B_C"
+      7 - returns "A_B_C"
+*/
+
+CHAR *GETVRSN(int version)
+{
+ extern struct zonline online;
+ static CHAR versionid[16];
+
+ X("Getvrsn");
+ if (version < 1 || version > 7) then
+    call ERROR("Version Id Invalid");
+ versionid[0] = 0;
+ if (version & 1) then
+    {
+     strcat(versionid, "_");
+     STRCAT(versionid, &online.versions[0][0], 16, "Getrsn-1");
+    }
+ if (version & 2) then
+    {
+     if (online.versions[1][0] != 0) then
+        {
+         strcat(versionid, "_");
+         STRCAT(versionid, &online.versions[1][0], 16, "Getrsn-2");
+        }
+    }
+ if (version & 4) then
+    {
+     if (online.versions[2][0] != 0) then
+        {
+         strcat(versionid, "_");
+         STRCAT(versionid, &online.versions[2][0], 16, "Getrsn-3");
+        }
+    }
+ Y();
+ return(&versionid[1]);
+}

Added: trunk/misc/olb/Mainfrm.cpp
===================================================================
--- trunk/misc/olb/Mainfrm.cpp	                        (rev 0)
+++ trunk/misc/olb/Mainfrm.cpp	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,327 @@
+/*
+ * Copyright 2009 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 <vcl.h>
+#pragma hdrstop
+
+#include "Mainfrm.h"
+//---------------------------------------------------------------------------
+#pragma package(smart_init)
+#pragma resource "*.dfm"
+
+
+ extern "C" {
+#include "online.h"
+}
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#ifndef __GNUC__
+#include <io.h>
+#include <sys/stat.h>
+#else
+#include <unistd.h>
+#endif
+
+#include <fcntl.h>
+#include <versekey.h>
+
+
+
+
+
+TForm1 *Form1;
+//---------------------------------------------------------------------------
+__fastcall TForm1::TForm1(TComponent* Owner)
+	: TForm(Owner)
+{
+	
+}
+//---------------------------------------------------------------------------
+
+int TForm1::ProcessOLB(char *filepath)
+{
+	long pos, offset;
+	int num1, num2, rangemax, curbook = 0, curchap = 0, curverse = 0;
+	char buf[127];
+	short size, tmp;
+	extern struct zonline online;
+
+//	checkparams(argc, argv);
+	startflag = 0;
+
+	inckey = key1 = key2 = key3 = "Genesis 1:1";
+	olbvnum = 0;
+
+	openfiles();
+
+	num1    = key1.Chapter();
+	num2    = key1.Verse();
+
+	DOINIT(filepath);   /* initialize OLB system */
+
+	while(!findbreak(fp, &offset, &num1, &num2, &rangemax, &size)) {
+		if (!startflag) {
+			startflag = 1;
+		}
+		else {
+			if (num2 < key2.Verse()) {            // new chapter
+				if (num1 <= key2.Chapter()) { // new book
+					key2.Verse(1);
+					key2.Chapter(1);
+					key2.Book(key2.Book()+1);
+				}
+				printf("Found Chapter Break: %d ('%s')\n", num1, (const char *)key2);
+				chapoffset = offset;
+				chapsize = size;
+//				continue;
+			}
+		}
+		key2.Verse(1);
+		key2.Chapter(num1);
+		key2.Verse(num2);
+
+		key3 = key2;
+//		key3 += (rangemax - key3.Verse());
+
+		writeidx(key1, key2, key3, offset, size);
+	}
+	close(vfp);
+	close(cfp);
+	close(bfp);
+	close(fp);
+	DOEND();		// close OLB system
+}
+
+
+/**************************************************************************
+ * ENT:	key1	- current location of index
+ * 	key2	- minimum keyval for which this offset is valid
+ * 	key3	- maximum keyval for which this offset is valid
+ */
+
+void TForm1::writeidx(VerseKey &key1, VerseKey &key2, VerseKey &key3, long offset, short size)
+{
+	long pos;
+	short tmp;
+
+		if (key1.Verse() == 1) {	// new chapter
+			if (key1.Chapter() == 1) {	// new book
+				pos = lseek(cfp, 0, SEEK_CUR);
+				write(bfp, &pos, 4);
+				pos = lseek(vfp, 0, SEEK_CUR); /* Book intro (cps) */
+				write(cfp, &pos, 4);
+				write(vfp, &chapoffset, 4);  /* Book intro (vss)  set to same as chap for now(it should be chap 1 which usually contains the book into anyway)*/
+				write(vfp, &chapsize, 2);
+			}
+			pos = lseek(vfp, 0, SEEK_CUR);
+			write(cfp, &pos, 4);
+			write(vfp, &chapoffset, 4);  /* Chapter intro */
+			write(vfp, &chapsize, 2);
+		}
+		if (key1 >= key2) {
+			write(vfp, &offset, 4);
+			write(vfp, &size, 2);
+		}
+		else	{
+			pos = 0;
+			tmp = 0;
+			write(vfp, &pos, 4);
+			write(vfp, &tmp, 2);
+		}
+		key1++;
+}
+
+
+
+char TForm1::findbreak(int fp, long *offset, int *num1, int *num2, int *rangemax, short *size)
+{
+	char buf[7];
+	char buf2[20];
+	char ch;
+	char loop;
+	long offset2;
+	int ch2, vs2, rm2;
+	bool flag;
+	long chapstart = 0; 
+	short versedata[MAX_VERSE];
+	char data[MAX_DATA];
+
+
+	if (++olbvnum <= 31102) {
+
+		if (olbvnum == 23146) {	// "Matthew 1:1"	
+			close(vfp);
+			close(cfp);
+			close(bfp);
+			close(fp);
+			key1 = key2 = key3 = inckey = "Matthew 1:1";
+			openfiles();
+			startflag = 0;
+		}
+
+
+		*offset = lseek(fp, 0, SEEK_CUR);
+
+		if ((olbvnum!=1) && (olbvnum != 23146))
+			inckey++;
+			
+		*num1 = inckey.Chapter();
+		*num2 = inckey.Verse();
+	
+	// output verse from olb
+//		printf("%s\n", (const char *)inckey);
+		GETEXT(olbvnum, versedata, 1, 1, 1, 1);
+		BLDVERSE(versedata, data);
+		charsetconvert(data);
+		write(fp, data, strlen(data));
+
+		*size = lseek(fp, 0, SEEK_CUR) - *offset;
+		write(fp, "\n", 1);
+		return 0;
+	}
+	return 1;
+}
+
+void TForm1::charsetconvert(char *data)
+{
+	for (;*data; data++) {
+//		printf("%c %d", *data, *data);
+		switch((unsigned char)*data) {
+		case 129: *data = 252; break;
+		case 130: *data = 233; break;
+		case 131: *data = 226; break;
+		case 133: *data = 224; break;
+		case 135: *data = 231; break;
+		case 136: *data = 234; break;
+		case 137: *data = 235; break;
+		case 138: *data = 232; break;
+		case 139: *data = 239; break;
+		case 140: *data = 238; break;
+		case 144: *data = 201; break;
+		case 147: *data = 244; break;
+		case 150: *data = 251; break;
+		case 151: *data = 249; break;
+		case 160: *data = 225; break;
+		case 161: *data = 237; break;
+		case 162: *data = 243; break;
+		case 163: *data = 250; break;
+		case 164: *data = 241; break;
+		case 168: *data = 191; break;
+		case 173: *data = 161; break;
+		default:
+			if ((unsigned char)*data > 126)
+				fprintf(stderr, "Suspicious character: %c (%d); %s\n", *data, (unsigned char )*data, (const char *)inckey);
+			break;
+		}
+	}
+}
+
+
+void TForm1::openfiles()
+{
+	char buf[255];
+	char fname[5];
+	long pos;
+	short size;
+	
+	testmnt = key1.Testament();
+
+	strcpy(fname, (testmnt==2) ? "nt" : "ot");
+	unlink(fname);
+	if ((fp = open(fname, O_CREAT|O_RDWR|O_BINARY, S_IREAD|S_IWRITE)) == -1) {
+		sprintf(buf, "Couldn't open file: %s\n", fname);
+		MessageBox(this->Handle, buf, "openfiles()", MB_OK);
+		exit(1);
+	}
+
+	sprintf(buf, "%s.vss", fname);
+	unlink(buf);
+	if ((vfp = open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE)) == -1) {
+		fprintf(stderr, "Couldn't open file: %s\n", buf);
+		exit(1);
+	}
+
+	sprintf(buf, "%s.cps", fname);
+	unlink(buf);
+	if ((cfp = open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE)) == -1) {
+		fprintf(stderr, "Couldn't open file: %s\n", buf);
+		exit(1);
+	}
+
+	sprintf(buf, "%s.bks", fname);
+	unlink(buf);
+	if ((bfp = open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE)) == -1) {
+		fprintf(stderr, "Couldn't open file: %s\n", buf);
+		exit(1);
+	}
+
+	pos  = 0;
+	write(bfp, &pos, 4);  /* Book    offset for testament intros */
+	pos = 4;
+	write(cfp, &pos, 4);  /* Chapter offset for testament intro */
+
+
+/*	Right now just zero out intros until parsing correctly */
+	pos = 0;
+	size = 0;
+	write(vfp, &pos, 4);  /* Module intro */
+	write(vfp, &size, 2);
+	write(vfp, &pos, 4);  /* Testament intro */
+	write(vfp, &size, 2);
+
+}
+
+
+void TForm1::checkparams(int argc, char **argv)
+{
+	if (argc < 2) {
+		fprintf(stderr, "usage: %s <path to OLB module directory (e.g. \"G:\\BIBLE\\AV\")>\n", argv[0]);
+		exit(1);
+	}
+}
+void __fastcall TForm1::FSButtonClick(TObject *Sender)
+{
+	FSDialog->FileName = "Text.dat";
+	char *fname;
+
+	if (FSDialog->Execute()) {
+		fname = new char [ strlen(FSDialog->FileName.c_str()) + 1 ];
+		strcpy(fname, FSDialog->FileName.c_str());
+		for (int i = strlen(fname) - 1; i; i--) {
+			if ((fname[i] != '\\') && (fname[i] != '/'))
+				fname[i] = 0;
+			else break;
+		}
+		FilePathEdit->Text = fname;
+		delete [] fname;
+		try {
+			RichEdit1->Lines->LoadFromFile(FilePathEdit->Text + "Copyrite.dat");
+		}
+		catch (...) {}
+	}
+}
+//---------------------------------------------------------------------------
+void __fastcall TForm1::Button1Click(TObject *Sender)
+{
+	ProcessOLB(FilePathEdit->Text.c_str());	
+}
+//---------------------------------------------------------------------------

Added: trunk/misc/olb/Mainfrm.dfm
===================================================================
(Binary files differ)


Property changes on: trunk/misc/olb/Mainfrm.dfm
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/misc/olb/Mainfrm.h
===================================================================
--- trunk/misc/olb/Mainfrm.h	                        (rev 0)
+++ trunk/misc/olb/Mainfrm.h	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2009 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.
+ *
+ */
+
+//---------------------------------------------------------------------------
+#ifndef MainfrmH
+#define MainfrmH
+//---------------------------------------------------------------------------
+#include <Classes.hpp>
+#include <Controls.hpp>
+#include <StdCtrls.hpp>
+#include <Forms.hpp>
+#include <Dialogs.hpp>
+#include <versekey.h>
+#include <ComCtrls.hpp>
+#include <ExtCtrls.hpp>
+//---------------------------------------------------------------------------
+class TForm1 : public TForm
+{
+__published:	// IDE-managed Components
+	TOpenDialog *FSDialog;
+	TPanel *Panel1;
+	TPanel *Panel2;
+	TButton *Button1;
+	TLabel *Label1;
+	TEdit *FilePathEdit;
+	TButton *FSButton;
+	TRichEdit *RichEdit1;
+	void __fastcall FSButtonClick(TObject *Sender);
+	void __fastcall Button1Click(TObject *Sender);
+private:	// User declarations
+
+void writeidx(VerseKey &key1, VerseKey &key2, VerseKey &key3, long offset, short size);
+char findbreak(int fp, long *offset, int *num1, int *num2, int *rangemax, short *size);
+void openfiles();
+void checkparams(int argc, char **argv);
+void charsetconvert(char *data);
+int ProcessOLB(char *filepath);
+
+
+VerseKey key1, key2, key3;
+int fp, vfp, cfp, bfp;
+long chapoffset;
+short chapsize;
+char testmnt;
+char startflag;
+VerseKey inckey;
+int olbvnum;
+
+public:		// User declarations
+	__fastcall TForm1(TComponent* Owner);
+};
+//---------------------------------------------------------------------------
+extern PACKAGE TForm1 *Form1;
+//---------------------------------------------------------------------------
+#endif

Added: trunk/misc/olb/Online.c
===================================================================
--- trunk/misc/olb/Online.c	                        (rev 0)
+++ trunk/misc/olb/Online.c	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2009 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 "online.dcl"
+
+/*
+   Online Bible Database Access Routines
+*/
+
+INT versedata[MAX_VERSE];
+INT verse_list[MAX_LIST];
+CHAR data[MAX_DATA];
+
+void main(argc, argv)
+int  argc;
+CHAR *argv[];
+{
+ CHAR found, passage[64], *p;
+ int i, j;
+ INT word;
+short verse_list[MAX_LIST];
+ extern struct zonline online;
+
+ if (argc > 1)
+    call DOINIT(argv[1]);   /* initialise system */
+ else
+    call DOINIT("g:\\bible\\av");   /* initialise system */
+
+					   /* get text for Ge 1:1 & Rev 22:21 */
+
+ for (i = 1; i < 8; i++)
+    puts(GETVRSN(i));
+
+ verse_list[0] = 10;
+ for (i=1; i <= 8; i++)
+    verse_list[i] = i;
+ verse_list[9] = 31101;
+ verse_list[10] = 31102;
+ for (i = 1; i <= 10; i++)
+    puts(VRSTOREF(verse_list[i], 0));
+ call DUMPVRS(verse_list, versedata, data);
+
+ word = MAPWORD("Aaron", &found);   /* map a word into an absolute number */
+ call PUTLIST("Aaron=", word);
+ if (found == 0) then
+    puts("*Not Found");
+ else
+    puts("*Found");
+ call GETWORD(word, verse_list);    /* get list of verses for a word */
+ call DUMPVRS(verse_list, versedata, (CHAR *) data);
+
+ /* first word in index */
+ word = MAPWORD("a", &found);   /* map a word into an absolute number */
+ call PUTLIST("a=", word);
+ if (found == 0) then
+    puts("*Not Found");
+ else
+    puts("*Found");
+ call GETWORD(word, verse_list);    /* get list of verses for a word */
+ call DUMPVRS(verse_list, versedata, (CHAR *) data);
+ call GETSTRNG(1, verse_list, 0);   /* get list of verses for Strong's */
+ call DUMPVRS(verse_list, versedata, (CHAR *) data);
+
+ /* last word in index */
+ word = MAPWORD("Zuzims", &found);   /* map a word into an absolute number */
+ call PUTLIST("Zuzims=", word);
+ if (found == 0) then
+    puts("*Not Found");
+ else
+    puts("*Found");
+
+ call GETWORD(word, verse_list);    /* get list of verses for a word */
+ call DUMPVRS(verse_list, versedata, (CHAR *) data);
+
+ printf("\nCross References for Ge 1:1\n");
+ call GETCXREF(1, verse_list);      /* get cross-references for a verse */
+ verse_list[1] = verse_list[66];
+ verse_list[2] = verse_list[67];
+ call DUMPVRS(verse_list, versedata, (CHAR *) data);
+
+ for (i = 1; i <= 31102; i++)   /* verify conversion routines work */
+    {
+	if ((i % 1000) == 0) then
+        puts(DECIMAL(i));
+	p = VRSTOREF(i, 0);
+	if (*p < '9' && *(p+1) == ' ') then
+	   {                      /* fix book names like 1 Timothy -> 1Timothy */
+         *(p+1) = *p;
+	    *p = ' ';
+	   }
+	j = REFTOVRS(p);
+     if (j != i) then
+        {
+	    printf("i=%d, j=%d, ref=%s\n", i, j, p);
+	    call ERROR("VRSTOREF - Error");
+        }
+    }
+
+ DOEND();
+}

Added: trunk/misc/olb/addstrongs.cpp
===================================================================
--- trunk/misc/olb/addstrongs.cpp	                        (rev 0)
+++ trunk/misc/olb/addstrongs.cpp	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2009 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 "online.dcl"
+#include <stdlib.h>
+#include <fcntl.h>
+#include <io.h>
+
+/*
+   Online Bible Database Access Routines
+*/
+
+INT versedata[MAX_VERSE];
+CHAR data[MAX_DATA];
+
+void main(argc, argv)
+int  argc;
+CHAR *argv[];
+{
+	int fd;
+ CHAR found, passage[64], *p;
+ int i, j;
+ INT word;
+short verse_list[MAX_LIST];
+ extern struct zonline online;
+
+ if (argc > 1)
+    call DOINIT(argv[1]);   /* initialise system */
+ else
+    call DOINIT("g:\\bible\\av");   /* initialise system */
+	fd = open("../modules/texts/rawtext/kjv/ot", O_RDONLY, S_IREAD|S_IWRITE);
+
+					   /* get text for Ge 1:1 & Rev 22:21 */
+
+ for (i = 1; i < 8; i++)
+    puts(GETVRSN(i));
+
+ verse_list[0] = 10;
+ for (i=1; i <= 8; i++)
+    verse_list[i] = i;
+ verse_list[9] = 31101;
+ verse_list[10] = 31102;
+ for (i = 1; i <= 10; i++)
+    puts(VRSTOREF(verse_list[i], 0));
+ call DUMPVRS(verse_list, versedata, data);
+
+ word = MAPWORD("Aaron", &found);   /* map a word into an absolute number */
+ call PUTLIST("Aaron=", word);
+ if (found == 0) then
+    puts("*Not Found");
+ else
+    puts("*Found");
+ call GETWORD(word, verse_list);    /* get list of verses for a word */
+ call DUMPVRS(verse_list, versedata, (CHAR *) data);
+
+ /* first word in index */
+ word = MAPWORD("a", &found);   /* map a word into an absolute number */
+ call PUTLIST("a=", word);
+ if (found == 0) then
+    puts("*Not Found");
+ else
+    puts("*Found");
+ call GETWORD(word, verse_list);    /* get list of verses for a word */
+ call DUMPVRS(verse_list, versedata, (CHAR *) data);
+ call GETSTRNG(1, verse_list, 0);   /* get list of verses for Strong's */
+ call DUMPVRS(verse_list, versedata, (CHAR *) data);
+
+ /* last word in index */
+ word = MAPWORD("Zuzims", &found);   /* map a word into an absolute number */
+ call PUTLIST("Zuzims=", word);
+ if (found == 0) then
+    puts("*Not Found");
+ else
+    puts("*Found");
+
+ call GETWORD(word, verse_list);    /* get list of verses for a word */
+ call DUMPVRS(verse_list, versedata, (CHAR *) data);
+
+ printf("\nCross References for Ge 1:1\n");
+ call GETCXREF(1, verse_list);      /* get cross-references for a verse */
+ verse_list[1] = verse_list[66];
+ verse_list[2] = verse_list[67];
+ call DUMPVRS(verse_list, versedata, (CHAR *) data);
+
+ for (i = 1; i <= 31102; i++)   /* verify conversion routines work */
+    {
+	if ((i % 1000) == 0) then
+        puts(DECIMAL(i));
+	p = VRSTOREF(i, 0);
+	if (*p < '9' && *(p+1) == ' ') then
+	   {                      /* fix book names like 1 Timothy -> 1Timothy */
+         *(p+1) = *p;
+	    *p = ' ';
+	   }
+	j = REFTOVRS(p);
+     if (j != i) then
+        {
+	    printf("i=%d, j=%d, ref=%s\n", i, j, p);
+	    call ERROR("VRSTOREF - Error");
+        }
+    }
+
+ DOEND();
+}

Added: trunk/misc/olb/dumpav.cpp
===================================================================
--- trunk/misc/olb/dumpav.cpp	                        (rev 0)
+++ trunk/misc/olb/dumpav.cpp	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2009 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.
+ *
+ */
+
+extern "C" {
+#include "online.dcl"
+}
+
+void main(int argc, char **argv)
+{
+	CHAR found, passage[64], *p;
+	int i, j;
+	INT word;
+	short verse_list[MAX_LIST];
+	short versedata[MAX_VERSE];
+	char data[MAX_DATA];
+	extern struct zonline online;
+	int versenum = 0;
+
+	
+	if (argc > 1)
+		call DOINIT(argv[1]);   /* initialise system */
+	else	call DOINIT("g:\\bible\\av");   /* initialise system */
+
+	for (versenum = 23146; versenum <= 23147 /*31102*/; versenum++) {
+		call GETEXT(versenum, versedata, 1, 1, 1, 1);
+		call BLDVERSE(versedata, data);
+		printf("%s\n", VRSTOREF(versenum, 1));
+//		printf("%s\n", data);
+	}
+
+	DOEND();
+}

Added: trunk/misc/olb/olb.bpg
===================================================================
--- trunk/misc/olb/olb.bpg	                        (rev 0)
+++ trunk/misc/olb/olb.bpg	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,26 @@
+#------------------------------------------------------------------------------
+VERSION = BWS.01
+#------------------------------------------------------------------------------
+!ifndef ROOT
+ROOT = $(MAKEDIR)\..
+!endif
+#------------------------------------------------------------------------------
+MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
+DCC = $(ROOT)\bin\dcc32.exe $**
+BRCC = $(ROOT)\bin\brcc32.exe $**
+#------------------------------------------------------------------------------
+PROJECTS = Convert.exe olb2sword.exe prn2sword.exe
+#------------------------------------------------------------------------------
+default: $(PROJECTS)
+#------------------------------------------------------------------------------
+
+Convert.exe: Convert.bpr
+  $(MAKE)
+
+olb2sword.exe: olb2sword.bpr
+  $(MAKE)
+
+prn2sword.exe: prn2sword.bpr
+  $(MAKE)
+
+

Added: trunk/misc/olb/olb2sword.bpr
===================================================================
--- trunk/misc/olb/olb2sword.bpr	                        (rev 0)
+++ trunk/misc/olb/olb2sword.bpr	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,112 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<!-- C++Builder XML Project -->
+<PROJECT>
+  <MACROS>
+    <VERSION value="BCB.05.03"/>
+    <PROJECT value="olb2sword.exe"/>
+    <OBJFILES value="olb2sword.obj ..\src\keys\listkey.obj ..\src\keys\strkey.obj 
+      ..\src\keys\swkey.obj ..\src\keys\versekey.obj ..\src\utilfuns\utilstr.obj 
+      all.obj"/>
+    <RESFILES value=""/>
+    <IDLFILES value=""/>
+    <DEFFILE value=""/>
+    <RESDEPEN value="$(RESFILES)"/>
+    <LIBFILES value=""/>
+    <LIBRARIES value=""/>
+    <SPARELIBS value=""/>
+    <PACKAGES value="vcl50.bpi vclx50.bpi bcbsmp50.bpi dss50.bpi qrpt50.bpi teeui50.bpi 
+      teedb50.bpi tee50.bpi vcldb50.bpi vclbde50.bpi vcldbx50.bpi ibsmp50.bpi 
+      vclmid50.bpi nmfast50.bpi inetdb50.bpi inet50.bpi dclocx50.bpi DCLUSR50.bpi"/>
+    <PATHCPP value=".;..\src\keys;..\src\utilfuns"/>
+    <PATHPAS value=".;"/>
+    <PATHRC value=".;"/>
+    <PATHASM value=".;"/>
+    <DEBUGLIBPATH value="$(BCB)\lib\debug"/>
+    <RELEASELIBPATH value="$(BCB)\lib\release"/>
+    <LINKER value="ilink32"/>
+    <USERDEFINES value=""/>
+    <SYSDEFINES value="_NO_VCL;_VIS_NOLIB"/>
+    <MAINSOURCE value="olb2sword.cpp"/>
+    <INCLUDEPATH value="..\src\utilfuns;..\src\keys;$(BCB)\include;..\include"/>
+    <LIBPATH value="..\src\utilfuns;..\src\keys;$(BCB)\lib"/>
+    <WARNINGS value=""/>
+    <WARNOPTSTR value=""/>
+  </MACROS>
+  <OPTIONS>
+    <IDLCFLAGS value="-I..\src\utilfuns -I..\src\keys -I$(BCB)\include -I..\include -src_suffix 
+      cpp -boa"/>
+    <CFLAG1 value="-Od -Tkh30000 -X- -r- -a1 -b -k -y -v -vi- -c -tWM -tWC"/>
+    <PFLAGS value="-$YD -$W -$O- -v -JPHN -M"/>
+    <RFLAGS value=""/>
+    <AFLAGS value="/mx /w2 /zd"/>
+    <LFLAGS value="-D&quot;&quot; -ap -Tpe -x -Gn -v"/>
+  </OPTIONS>
+  <LINKER>
+    <ALLOBJ value="c0x32.obj $(OBJFILES)"/>
+    <ALLRES value="$(RESFILES)"/>
+    <ALLLIB value="$(LIBFILES)  import32.lib cw32mt.lib"/>
+  </LINKER>
+  <IDEOPTIONS>
+[Version Info]
+IncludeVerInfo=0
+AutoIncBuild=0
+MajorVer=1
+MinorVer=0
+Release=0
+Build=0
+Debug=0
+PreRelease=0
+Special=0
+Private=0
+DLL=0
+Locale=1033
+CodePage=1252
+
+[Version Info Keys]
+CompanyName=
+FileDescription=Executable (Console)
+FileVersion=1.0.0.0
+InternalName=
+LegalCopyright=
+LegalTrademarks=
+OriginalFilename=
+ProductName=
+ProductVersion=1.0.0.0
+Comments=
+
+[HistoryLists\hlIncludePath]
+Count=2
+Item0=..\src\utilfuns;..\src\keys;$(BCB)\include;..\include
+Item1=$(BCB)\include;../include
+
+[HistoryLists\hlLibraryPath]
+Count=2
+Item0=..\src\utilfuns;..\src\keys;$(BCB)\lib
+Item1=$(BCB)\lib
+
+[HistoryLists\hlRunParameters]
+Count=2
+Item0=c:\bible\weyItem1=c:\bible\wey[Debugging]
+Item1=
+
+[Debugging]
+DebugSourceDirs=
+
+[Parameters]
+RunParams=c:\bible\weyHostApplication=
+HostApplication=
+RemoteHost=
+RemotePath=
+RemoteDebug=0
+
+[Compiler]
+ShowInfoMsgs=0
+LinkDebugVcl=1
+LinkCGLIB=0
+
+[Language]
+ActiveLang=
+ProjectLang=
+RootDir=
+  </IDEOPTIONS>
+</PROJECT>
\ No newline at end of file

Added: trunk/misc/olb/olb2sword.cpp
===================================================================
--- trunk/misc/olb/olb2sword.cpp	                        (rev 0)
+++ trunk/misc/olb/olb2sword.cpp	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,312 @@
+/*
+ * Copyright 2009 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.
+ *
+ */
+
+
+#pragma hdrstop
+#include <condefs.h>
+
+
+//---------------------------------------------------------------------------
+#pragma argsused
+/*****************************************************************************
+ *
+ */
+
+ extern "C" {
+#include "online.h"
+}
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#ifndef __GNUC__
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+#include <fcntl.h>
+#include <versekey.h>
+
+
+USEUNIT("..\src\keys\listkey.cpp");
+USEUNIT("..\src\keys\strkey.cpp");
+USEUNIT("..\src\keys\swkey.cpp");
+USEUNIT("..\src\keys\versekey.cpp");
+USEUNIT("..\src\utilfuns\utilstr.cpp");
+USEUNIT("all.c");
+//---------------------------------------------------------------------------
+void writeidx(VerseKey &key1, VerseKey &key2, VerseKey &key3, long offset, short size);
+char findbreak(int fp, long *offset, int *num1, int *num2, int *rangemax, short *size);
+void openfiles();
+void checkparams(int argc, char **argv);
+void charsetconvert(char *data);
+
+
+VerseKey key1, key2, key3;
+int fp, vfp, cfp, bfp;
+long chapoffset;
+short chapsize;
+char testmnt;
+char startflag = 0;
+VerseKey inckey;
+
+
+main(int argc, char **argv)
+{
+	long pos, offset;
+	int num1, num2, rangemax, curbook = 0, curchap = 0, curverse = 0;
+	char buf[127];
+	short size, tmp;
+	extern struct zonline online;
+
+	checkparams(argc, argv);
+
+	inckey = key1 = key2 = key3 = "Genesis 1:1";
+
+	openfiles();
+
+	num1    = key1.Chapter();
+	num2    = key1.Verse();
+
+	DOINIT(argv[1]);   /* initialize OLB system */
+
+	while(!findbreak(fp, &offset, &num1, &num2, &rangemax, &size)) {
+		if (!startflag) {
+			startflag = 1;
+		}
+		else {
+			if (num2 < key2.Verse()) {            // new chapter
+				if (num1 <= key2.Chapter()) { // new book
+					key2.Verse(1);
+					key2.Chapter(1);
+					key2.Book(key2.Book()+1);
+				}
+				printf("Found Chapter Break: %d ('%s')\n", num1, (const char *)key2);
+				chapoffset = offset;
+				chapsize = size;
+//				continue;
+			}
+		}
+		key2.Verse(1);
+		key2.Chapter(num1);
+		key2.Verse(num2);
+
+		key3 = key2;
+//		key3 += (rangemax - key3.Verse());
+
+		writeidx(key1, key2, key3, offset, size);
+	}
+	close(vfp);
+	close(cfp);
+	close(bfp);
+	close(fp);
+	DOEND();		// close OLB system
+}
+
+
+/**************************************************************************
+ * ENT:	key1	- current location of index
+ * 	key2	- minimum keyval for which this offset is valid
+ * 	key3	- maximum keyval for which this offset is valid
+ */
+
+void writeidx(VerseKey &key1, VerseKey &key2, VerseKey &key3, long offset, short size)
+{
+	long pos;
+	short tmp;
+
+		if (key1.Verse() == 1) {	// new chapter
+			if (key1.Chapter() == 1) {	// new book
+				pos = lseek(cfp, 0, SEEK_CUR);
+				write(bfp, &pos, 4);
+				pos = lseek(vfp, 0, SEEK_CUR); /* Book intro (cps) */
+				write(cfp, &pos, 4);
+				write(vfp, &chapoffset, 4);  /* Book intro (vss)  set to same as chap for now(it should be chap 1 which usually contains the book into anyway)*/
+				write(vfp, &chapsize, 2);
+			}
+			pos = lseek(vfp, 0, SEEK_CUR);
+			write(cfp, &pos, 4);
+			write(vfp, &chapoffset, 4);  /* Chapter intro */
+			write(vfp, &chapsize, 2);
+		}
+		if (key1 >= key2) {
+			write(vfp, &offset, 4);
+			write(vfp, &size, 2);
+		}
+		else	{
+			pos = 0;
+			tmp = 0;
+			write(vfp, &pos, 4);
+			write(vfp, &tmp, 2);
+		}
+		key1++;
+}
+
+
+
+char findbreak(int fp, long *offset, int *num1, int *num2, int *rangemax, short *size)
+{
+	char buf[7];
+	char buf2[20];
+	char ch;
+	char loop;
+	long offset2;
+	int ch2, vs2, rm2;
+	bool flag;
+	long chapstart = 0; 
+	static int olbvnum = 0;
+	short versedata[MAX_VERSE];
+	char data[MAX_DATA];
+	int len;
+
+
+	if (++olbvnum <= 31102) {
+
+		if (olbvnum == 23146) {	// "Matthew 1:1"	
+			close(vfp);
+			close(cfp);
+			close(bfp);
+			close(fp);
+			key1 = key2 = key3 = inckey = "Matthew 1:1";
+			openfiles();
+			startflag = 0;
+		}
+
+
+		*offset = lseek(fp, 0, SEEK_CUR);
+
+		if ((olbvnum!=1) && (olbvnum != 23146))
+			inckey++;
+			
+		*num1 = inckey.Chapter();
+		*num2 = inckey.Verse();
+	
+	// output verse from olb
+//		printf("%s\n", (const char *)inckey);
+		GETEXT(olbvnum, versedata, 1, 1, 1, 1);
+		BLDVERSE(versedata, data);
+		charsetconvert(data);
+		len = strlen(data);
+		if (len)
+			write(fp, data, strlen(data));
+
+		*size = lseek(fp, 0, SEEK_CUR) - *offset;
+		write(fp, "\n", 1);
+		return 0;
+	}
+	return 1;
+}
+
+void charsetconvert(char *data)
+{
+	for (;*data; data++) {
+//		printf("%c %d", *data, *data);
+		switch((unsigned char)*data) {
+		case 129: *data = 252; break;
+		case 130: *data = 233; break;
+		case 131: *data = 226; break;
+		case 133: *data = 224; break;
+		case 135: *data = 231; break;
+		case 136: *data = 234; break;
+		case 137: *data = 235; break;
+		case 138: *data = 232; break;
+		case 139: *data = 239; break;
+		case 140: *data = 238; break;
+		case 144: *data = 201; break;
+		case 147: *data = 244; break;
+		case 150: *data = 251; break;
+		case 151: *data = 249; break;
+		case 160: *data = 225; break;
+		case 161: *data = 237; break;
+		case 162: *data = 243; break;
+		case 163: *data = 250; break;
+		case 164: *data = 241; break;
+		case 168: *data = 191; break;
+		case 173: *data = 161; break;
+		default:
+			if ((unsigned char)*data > 126)
+				fprintf(stderr, "Suspicious character: %c (%d); %s\n", *data, (unsigned char )*data, (const char *)inckey);
+			break;
+		}
+	}
+}
+
+
+void openfiles()
+{
+	char buf[255];
+	char fname[5];
+	long pos;
+	short size;
+	
+	testmnt = key1.Testament();
+
+	strcpy(fname, (testmnt==2) ? "nt" : "ot");
+	unlink(fname);
+	if ((fp = open(fname, O_CREAT|O_RDWR|O_BINARY, S_IREAD|S_IWRITE)) == -1) {
+		fprintf(stderr, "Couldn't open file: %s\n", fname);
+		exit(1);
+	}
+
+	sprintf(buf, "%s.vss", fname);
+	unlink(buf);
+	if ((vfp = open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE)) == -1) {
+		fprintf(stderr, "Couldn't open file: %s\n", buf);
+		exit(1);
+	}
+
+	sprintf(buf, "%s.cps", fname);
+	unlink(buf);
+	if ((cfp = open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE)) == -1) {
+		fprintf(stderr, "Couldn't open file: %s\n", buf);
+		exit(1);
+	}
+
+	sprintf(buf, "%s.bks", fname);
+	unlink(buf);
+	if ((bfp = open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE)) == -1) {
+		fprintf(stderr, "Couldn't open file: %s\n", buf);
+		exit(1);
+	}
+
+	pos  = 0;
+	write(bfp, &pos, 4);  /* Book    offset for testament intros */
+	pos = 4;
+	write(cfp, &pos, 4);  /* Chapter offset for testament intro */
+
+
+/*	Right now just zero out intros until parsing correctly */
+	pos = 0;
+	size = 0;
+	write(vfp, &pos, 4);  /* Module intro */
+	write(vfp, &size, 2);
+	write(vfp, &pos, 4);  /* Testament intro */
+	write(vfp, &size, 2);
+
+}
+
+
+void checkparams(int argc, char **argv)
+{
+	if (argc < 2) {
+		fprintf(stderr, "usage: %s <path to OLB module directory (e.g. \"G:\\BIBLE\\AV\")>\n", argv[0]);
+		exit(1);
+	}
+} 

Added: trunk/misc/olb/online.ide
===================================================================
(Binary files differ)


Property changes on: trunk/misc/olb/online.ide
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/misc/olb/online.prj
===================================================================
--- trunk/misc/olb/online.prj	                        (rev 0)
+++ trunk/misc/olb/online.prj	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1 @@
+Turbo C Project File 
\ No newline at end of file

Added: trunk/misc/olb/prn2sword.bpr
===================================================================
--- trunk/misc/olb/prn2sword.bpr	                        (rev 0)
+++ trunk/misc/olb/prn2sword.bpr	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,123 @@
+<?xml version='1.0' encoding='utf-8' ?>
+<!-- C++Builder XML Project -->
+<PROJECT>
+  <MACROS>
+    <VERSION value="BCB.05.03"/>
+    <PROJECT value="prn2sword.exe"/>
+    <OBJFILES value="prn2sword.obj prn2swordfrm.obj ..\src\keys\versekey.obj 
+      ..\src\keys\strkey.obj ..\src\keys\swkey.obj ..\src\keys\listkey.obj 
+      ..\src\utilfuns\utilstr.obj ..\src\mgr\localemgr.obj 
+      ..\src\mgr\swlocale.obj ..\src\mgr\swconfig.obj ..\src\mgr\swmgr.obj 
+      ..\src\mgr\filemgr.obj ..\src\utilfuns\roman.obj"/>
+    <RESFILES value="prn2sword.res"/>
+    <IDLFILES value=""/>
+    <IDLGENFILES value=""/>
+    <DEFFILE value=""/>
+    <RESDEPEN value="$(RESFILES) prn2swordfrm.dfm"/>
+    <LIBFILES value=""/>
+    <LIBRARIES value="vcl50.lib"/>
+    <SPARELIBS value="vcl50.lib"/>
+    <PACKAGES value="vcl50.bpi vclx50.bpi vcljpg50.bpi vclmid50.bpi vcldb50.bpi vclbde50.bpi 
+      bcbsmp50.bpi vcldbx50.bpi qrpt50.bpi teeui50.bpi teedb50.bpi tee50.bpi 
+      dss50.bpi ibsmp50.bpi nmfast50.bpi inetdb50.bpi inet50.bpi dclocx50.bpi 
+      DCLUSR50.bpi"/>
+    <PATHCPP value=".;..\src\keys;..\src\utilfuns;..\src\mgr"/>
+    <PATHPAS value=".;"/>
+    <PATHRC value=".;"/>
+    <PATHASM value=".;"/>
+    <DEBUGLIBPATH value="$(BCB)\lib\debug"/>
+    <RELEASELIBPATH value="$(BCB)\lib\release"/>
+    <LINKER value="ilink32"/>
+    <USERDEFINES value=""/>
+    <SYSDEFINES value="NO_STRICT;_VIS_NOLIB"/>
+    <MAINSOURCE value="prn2sword.cpp"/>
+    <INCLUDEPATH value="..\src\mgr;..\src\utilfuns;..\src\keys;$(BCB)\include;$(BCB)\include\vcl;..\include"/>
+    <LIBPATH value="..\src\mgr;..\src\utilfuns;..\src\keys;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib"/>
+    <WARNINGS value="-w-par -w-8027 -w-8026"/>
+    <WARNOPTSTR value=""/>
+  </MACROS>
+  <OPTIONS>
+    <IDLCFLAGS value="-I..\src\mgr -I..\src\utilfuns -I..\src\keys -I$(BCB)\include 
+      -I$(BCB)\include\vcl -I..\include -src_suffix cpp -boa"/>
+    <CFLAG1 value="-O2 -H=c:\PROGRA~1\BORLAND\CBUILD~1\lib\vcl50.csm -Hc -Vx -Ve -X- -a8 -b- 
+      -k- -vi -c -tW -tWM"/>
+    <PFLAGS value="-$Y- -$L- -$D- -v -JPHNE -M"/>
+    <RFLAGS value=""/>
+    <AFLAGS value="/mx /w2 /zn"/>
+    <LFLAGS value="-D&quot;&quot; -aa -Tpe -x -Gn"/>
+  </OPTIONS>
+  <LINKER>
+    <ALLOBJ value="c0w32.obj sysinit.obj $(OBJFILES)"/>
+    <ALLRES value="$(RESFILES)"/>
+    <ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib"/>
+  </LINKER>
+  <IDEOPTIONS>
+[Version Info]
+IncludeVerInfo=0
+AutoIncBuild=0
+MajorVer=1
+MinorVer=0
+Release=0
+Build=0
+Debug=0
+PreRelease=0
+Special=0
+Private=0
+DLL=0
+Locale=1033
+CodePage=1252
+
+[Version Info Keys]
+CompanyName=
+FileDescription=
+FileVersion=1.0.0.0
+InternalName=
+LegalCopyright=
+LegalTrademarks=
+OriginalFilename=
+ProductName=
+ProductVersion=1.0.0.0
+Comments=
+
+[HistoryLists\hlIncludePath]
+Count=3
+Item0=..\src\mgr;..\src\utilfuns;..\src\keys;$(BCB)\include;$(BCB)\include\vcl;..\include
+Item1=..\src\utilfuns;..\src\keys;$(BCB)\include;$(BCB)\include\vcl;..\include
+Item2=$(BCB)\include;$(BCB)\include\vcl;../include
+
+[HistoryLists\hlLibraryPath]
+Count=3
+Item0=..\src\mgr;..\src\utilfuns;..\src\keys;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib
+Item1=..\src\utilfuns;..\src\keys;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib
+Item2=$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib
+
+[HistoryLists\hlDebugSourcePath]
+Count=1
+Item0=$(BCB)\source\vcl
+
+[Debugging]
+DebugSourceDirs=$(BCB)\source\vcl
+
+[Parameters]
+RunParams=
+HostApplication=
+RemoteHost=
+RemotePath=
+RemoteDebug=0
+
+[Compiler]
+ShowInfoMsgs=0
+LinkDebugVcl=0
+LinkCGLIB=0
+
+[CORBA]
+AddServerUnit=1
+AddClientUnit=1
+PrecompiledHeaders=1
+
+[Language]
+ActiveLang=
+ProjectLang=
+RootDir=
+  </IDEOPTIONS>
+</PROJECT>
\ No newline at end of file

Added: trunk/misc/olb/prn2sword.cpp
===================================================================
--- trunk/misc/olb/prn2sword.cpp	                        (rev 0)
+++ trunk/misc/olb/prn2sword.cpp	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2009 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 <vcl.h>
+#pragma hdrstop
+USERES("prn2sword.res");
+USEFORM("prn2swordfrm.cpp", Form2);
+USEUNIT("..\src\keys\versekey.cpp");
+USEUNIT("..\src\keys\strkey.cpp");
+USEUNIT("..\src\keys\swkey.cpp");
+USEUNIT("..\src\keys\listkey.cpp");
+USEUNIT("..\src\utilfuns\utilstr.cpp");
+USEUNIT("..\src\mgr\localemgr.cpp");
+USEUNIT("..\src\mgr\swlocale.cpp");
+USEUNIT("..\src\mgr\swconfig.cpp");
+USEUNIT("..\src\mgr\swmgr.cpp");
+USEUNIT("..\src\mgr\filemgr.cpp");
+USEUNIT("..\src\utilfuns\roman.c");
+//---------------------------------------------------------------------------
+WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
+{
+	try
+	{
+		Application->Initialize();
+		Application->CreateForm(__classid(TForm2), &Form2);
+                 Application->Run();
+	}
+	catch (Exception &exception)
+	{
+		Application->ShowException(&exception);
+	}
+	return 0;
+}
+//---------------------------------------------------------------------------

Added: trunk/misc/olb/prn2swordfrm.cpp
===================================================================
--- trunk/misc/olb/prn2swordfrm.cpp	                        (rev 0)
+++ trunk/misc/olb/prn2swordfrm.cpp	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,501 @@
+/*
+ * Copyright 2009 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 <vcl.h>
+#pragma hdrstop
+
+#include "prn2swordfrm.h"
+#include <stdio.h>
+#include <fcntl.h>
+#include <versekey.h>
+#include <io.h>
+#include <sys/stat.h>
+
+//---------------------------------------------------------------------------
+#pragma package(smart_init)
+#pragma resource "*.dfm"
+TForm2 *Form2;
+const MAXVLEN = 8192;
+//---------------------------------------------------------------------------
+__fastcall TForm2::TForm2(TComponent* Owner)
+	: TForm(Owner)
+{
+}
+//---------------------------------------------------------------------------
+void __fastcall TForm2::FSButtonClick(TObject *Sender)
+{
+	FSDialog->FileName = "*.rtf";
+	char *fname;
+
+	if (FSDialog->Execute()) {
+		FilePathEdit->Text = FSDialog->FileName;
+	}
+}
+//---------------------------------------------------------------------------
+
+
+void TForm2::ProcessFile(char *fileName)
+{
+	unsigned long pos = 0L;
+	unsigned short size = 0, tmp;
+	int verseNum, curbook = 0, curchap = 0, curverse = 0, curTestament = 1;
+	char buf[127];
+	VerseKey mykey;
+	char verseBuf[MAXVLEN];
+	bool fail = false;
+	char end = 0;
+	
+
+	if ((fp = open(fileName, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE)) == -1) {
+		sprintf(buf, "Couldn't open file: %s\n", fileName);
+		MessageBox(this->Handle, buf, "ProcessFile", MB_OK);
+		return;
+	}
+
+	openFiles("ot");
+	
+	mykey = "Genesis 1:1";
+	
+	getVerse(fp, &verseNum, verseBuf, 1);
+	do {
+		end = getVerse(fp, &verseNum, verseBuf, mykey.Testament());
+		if (mykey.Verse() == 1) {  		/* if we're at a new chapter */
+			if (mykey.Chapter() == 1) {	/* if we're at a new book */
+				if (mykey.Testament() != curTestament) { // we've made it to new testament
+					curTestament = mykey.Testament();
+					close(vfp);	// verse
+					close(cfp);	// chapter
+					close(bfp);	// book
+					close(dfp);	// data
+					openFiles("nt");
+				}
+				Memo1->Text = "";
+				pos = lseek(cfp, 0, SEEK_CUR);
+				write(bfp, &pos, 4);
+				pos = lseek(vfp, 0, SEEK_CUR); /* Book intro (cps) */
+				write(cfp, &pos, 4);
+				pos  = 0L;
+				tmp = 0;
+				write(vfp, &pos, 4);  /* Book intro (vss) */
+				write(vfp, &tmp, 2);
+				curbook++;
+				curchap = 0;
+			}
+			pos = lseek(vfp, 0, SEEK_CUR);
+			write(cfp, &pos, 4);
+			curverse = 1;
+			pos  = 0L;
+			tmp = 0;
+			write(vfp, &pos, 4);  /* Chapter intro */
+			write(vfp, &tmp, 2);
+			curchap++;
+		}
+		else curverse++;
+	
+		if (mykey.Chapter() != curchap) {
+			sprintf(buf, "Error: Found chaptures out of sequence");
+			Memo1->Lines->Append(buf);
+			fail = true;
+			break;
+		}
+		if ((mykey.Verse() != curverse) || (curverse != verseNum)) {
+			Memo1->Lines->Append("Error: Found verses out of sequence");
+			sprintf(buf, "Expected %d (%s), but got %d\n\n", curverse, (const char *)mykey, verseNum);
+			Memo1->Lines->Append(buf);
+			Memo1->Lines->Append("   Currently SWORD only supports KJV verse numbering and book ordering.");
+			Memo1->Lines->Append("   Try combining extra verses with the last valid verse just before, including it in footnote markers <RF><Rf>(eg. <RF>(24) verse text. (25) verse text<Rf>)");
+			Memo1->Lines->Append("   This way, even though they will display in SWORD along with the previous verse, all data will be displayed.");
+			Memo1->Lines->Append("   Where verses are missing, add a blank entry.");
+			Memo1->Lines->Append("   Then try rerunning");
+			fail = true;
+			break;
+		}
+		
+		pos = lseek(dfp, 0, SEEK_CUR);
+		write(vfp, &pos, 4);
+		size = strlen(verseBuf);
+		write(vfp, &size, 2);
+		sprintf(buf, "%2d:%3d:%3d (%s) found at offset: %7ld; size: %d", curbook, mykey.Chapter(), mykey.Verse(), (const char *)mykey, pos, size);
+		Memo1->Lines->Append(buf);
+		if ((size < 0) || (size > 1000)) {
+			Memo1->Lines->Append("WARNING: Strange Size.");
+		}
+		write(dfp, verseBuf, size);
+		mykey++;
+	} while (!end);
+
+	close(vfp);	// verse
+	close(cfp);	// chapter
+	close(bfp);	// book
+	close(dfp);	// data
+	close(fp);	// source
+	if (!fail)
+		Memo1->Lines->Append("SUCCESS!!!!!!!");
+}
+
+
+char TForm2::getVerse(int fp, int *verseNum, char *verseBuf, char testament)
+{
+	char buf[21];
+	char retVal = 0;
+	*verseNum=-1;
+	char *finalBuf = verseBuf;
+	int paridx;
+	const char *parchar = "\\par";
+
+	memset(buf, 0, 21);
+
+	while (1) {
+
+		if (!memcmp(buf, "\\f1 \\b0 \\fs22  \\f", 17)) {
+                        if (isdigit(buf[18])) {
+                                lseek(fp, -1, SEEK_CUR);
+                                break;
+                        }
+                        else if (isdigit(buf[17])) {
+	        		lseek(fp, -2, SEEK_CUR);
+        			break;
+                        }
+		}
+		if (!memcmp(buf, "\\f1 \\b0 \\fs22 ", 14)) {
+			lseek(fp, -7, SEEK_CUR);
+			break;
+		}
+		if (!memcmp(buf, "\\li0\\fi0 \\par \\u", 16)) {
+			lseek(fp, -4, SEEK_CUR);
+                        while(read(fp, buf, 1) == 1) {
+				if (*buf == 10)
+					break;
+			}
+			memset(buf, 0, 21);
+		}
+		memmove(buf, &buf[1], 20);
+		if (*buf) {
+			*verseBuf++ = *buf;
+			if (*verseNum == -1) {
+				if (isdigit(*buf)) {
+					sscanf(buf, "%d", verseNum);
+				}
+			}
+		}
+		if (read(fp, &buf[20], 1) != 1) {
+			retVal = 1;
+			for (int i = 1; i < 12; i++)
+				*verseBuf++ = buf[i];
+			break;
+		}
+	}
+	*--verseBuf = 0;
+	paridx = 3;
+	// trim trailing junk
+	do {
+		verseBuf--;
+		if (paridx > -1) {
+			if (*verseBuf == parchar[paridx]) {
+				*verseBuf = 0;
+				paridx--;
+				continue;
+			}
+			if (paridx < 3) {
+				for (;paridx < 4;paridx++)
+					*verseBuf++ = parchar[paridx];
+				break;
+			}
+		}
+		if ((*verseBuf != ' ') && (*verseBuf != 10) && (*verseBuf != 13) && (*verseBuf != '\\'))
+			break;
+		*verseBuf = 0;
+	} while (verseBuf > finalBuf);
+	*++verseBuf = 0;
+	
+	// check for Paragraph marker on next verse
+	for (int i = 7; i < 48; i++) {
+		if (buf[i] == '¶') {
+			*verseBuf++ = '<';
+			*verseBuf++ = 'C';
+			*verseBuf++ = 'M';
+			*verseBuf++ = '>';
+			*verseBuf++ = 0;
+			break;
+		}
+	}
+
+	filterVerse(finalBuf, (testament == 2)?'G':'H');
+	
+	return retVal;
+}
+
+
+
+
+
+
+
+// lang	- 'G' | 'H'
+void TForm2::filterVerse(char *text, char lang)
+{
+	char *to, *from, token[MAXVLEN], tokpos = 0;
+	bool intoken = false;
+	bool intoken2 = false;
+	bool deref = false;
+	bool lastspace = false;
+	int len;
+	int maxlen = MAXVLEN - 1;
+	
+
+	len = strlen(text) + 1;						// shift string to right of buffer
+	if (len < maxlen) {
+		memmove(&text[maxlen - len], text, len);
+		from = &text[maxlen - len];
+	}
+	else	from = text;							// -------------------------------
+
+	while (*from) {
+		if ((*from != ' ') && (!isdigit(*from)) && (*from != 10) && (*from !=13))
+			break;
+		from++;
+	}
+	
+	for (to = text; *from; from++) {
+		if ((*from == '\\') && (!deref)) {
+			deref = true;
+			continue;
+		}
+		if (*from == '<') {
+			if (!isdigit(from[1])) {	// Not a strongs number
+				if ((from[1] != 'C') || (from[2] != 'M') || (from[3] != '>')) {
+					*to++ = '<';
+					*to++ = 'F';
+					*to++ = 'O';
+					*to++ = '>';
+					continue;
+				}
+			}
+		}
+		if (*from == '>') {
+			if (!isdigit(from[-1])) {	// Not a strongs number
+				if ((from[-2] != 'C') || (from[-1] != 'M') || (from[-3] != '<')) {
+					*to++ = '<';
+					*to++ = 'F';
+					*to++ = 'o';
+					*to++ = '>';
+					continue;
+				}
+			}
+		}
+		if (deref) {
+			deref = false;
+			if (*from == '{') {
+				*to++ = '<';
+				*to++ = 'R';
+				*to++ = 'F';
+				*to++ = '>';
+				continue;
+			}
+			
+			if (*from == '}') {
+				*to++ = '<';
+				*to++ = 'R';
+				*to++ = 'f';
+				*to++ = '>';
+                                if (from[1] == '\\' && from[2] == 'i' && from[3] == '0') {
+                                        from += 3;
+					if (from[1] == ' ') {
+						if (lastspace)
+							from++;
+					}
+                                }
+				continue;
+			}
+			if (*from == 'i') {
+				if (from[1] == '1') {
+                                        if (from[2] == ' ' && from[3] == '\\' && from[4] == '{') {
+                                                from++;
+						if (lastspace)
+							from++;
+        					continue;
+                                        }
+					*to++ = '<';
+					*to++ = 'F';
+					*to++ = 'I';
+					*to++ = '>';
+					from++;
+					if (from[1] == ' ') {
+						if (lastspace)
+							from++;
+					}
+					continue;
+				}
+				if (from[1] == '0') {
+					*to++ = '<';
+					*to++ = 'F';
+					*to++ = 'i';
+					*to++ = '>';
+					from++;
+					if (from[1] == ' ') {
+						if (lastspace)
+							from++;
+					}
+					if ((from[1] == ' ') && (from[2] == ' ')){	// dorky, but OLB places 2 spaces after italics off
+						from++;
+					}
+					continue;
+				}
+			}
+                        if (*from == 'f' && from[1] == 's') {
+                                from++;
+                                while (isdigit(from[1])) {
+                                        from++;
+                                }
+				if (from[1] == ' ') {
+                                        if (lastspace)
+        					from++;
+				}
+                                continue;
+                        }
+			*to++ = '\\';
+			*to++ = *from;
+			lastspace = (*from == ' ');
+			continue;
+		}
+			
+		if (*from == '<') {
+			if (isdigit(from[1])) {
+				intoken = true;
+				tokpos = 0;
+				memset(token, 0, 20);
+				continue;
+			}
+		}
+		if (*from == '(') {
+			if (isdigit(from[1])) {
+				intoken2 = true;
+				tokpos = 0;
+				memset(token, 0, 20);
+				continue;
+			}
+		}
+		if ((*from == '>') && (intoken)) {
+			intoken = false;
+			if (*(to - 1) == ' ')
+				to--;
+			*to++ = '<';
+			*to++ = 'W';
+			*to++ = lang;
+			for (int i = 0; i < strlen(token); i++)
+				*to++ = token[i];
+			*to++ = '>';
+			continue;
+		}
+		if ((*from == ')') && (intoken2)) {
+			intoken2 = false;
+			if (*(to - 1) == ' ')
+				to--;
+			*to++ = '<';
+			*to++ = 'W';
+			*to++ = 'T';
+			*to++ = lang;
+			for (int i = 0; i < strlen(token); i++)
+				*to++ = token[i];
+			*to++ = '>';
+			continue;
+		}
+		
+		if ((*from == 13) || (*from == 10)) {
+			continue;
+		}
+
+		if (*from == '¶') {
+                        if (from[1] == ' ') {
+                                from++;
+                        }
+			continue;
+		}
+
+		if (intoken || intoken2)
+			token[tokpos++] = *from;
+		else
+                	*to++ = *from;
+		lastspace = (*from == ' ');
+	}
+	*to-- = 0;
+	*++to = '\n';
+	*++to = 0;
+}
+
+
+void TForm2::openFiles(char *fileName)
+{
+	char buf[128];
+	long pos;
+	short size;
+
+	unlink(fileName);
+	if ((dfp = open(fileName, O_CREAT|O_WRONLY, S_IREAD|S_IWRITE)) == -1) {
+		sprintf(buf, "Couldn't open file: %s\n", fileName);
+		MessageBox(this->Handle, buf, "ProcessFile", MB_OK);
+		return;
+	}
+
+	sprintf(buf, "%s.vss", fileName);
+	unlink(buf);
+	if ((vfp = open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE)) == -1) {
+		sprintf(buf, "Couldn't open file: %s\n", buf);
+		MessageBox(this->Handle, buf, "ProcessFile", MB_OK);
+		return;
+	}
+
+	sprintf(buf, "%s.cps", fileName);
+	unlink(buf);
+	if ((cfp = open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE)) == -1) {
+		sprintf(buf, "Couldn't open file: %s\n", buf);
+		MessageBox(this->Handle, buf, "ProcessFile", MB_OK);
+		return;
+	}
+
+	sprintf(buf, "%s.bks", fileName);
+	unlink(buf);
+	if ((bfp = open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE)) == -1) {
+		sprintf(buf, "Couldn't open file: %s\n", buf);
+		MessageBox(this->Handle, buf, "ProcessFile", MB_OK);
+		return;
+	}
+	pos  = 0;
+	write(bfp, &pos, 4);  /* Book    offset for testament intros */
+	pos = 4;
+	write(cfp, &pos, 4);  /* Chapter offset for testament intro */
+
+
+/*	Right now just zero out intros until parsing correctly */
+	pos = 0;
+	size = 0;
+	write(vfp, &pos, 4);  /* Module intro */
+	write(vfp, &size, 2);
+	write(vfp, &pos, 4);  /* Testament intro */
+	write(vfp, &size, 2);
+
+
+}
+
+void __fastcall TForm2::Button1Click(TObject *Sender)
+{
+	ProcessFile(FilePathEdit->Text.c_str());	
+}
+//---------------------------------------------------------------------------
+
+

Added: trunk/misc/olb/prn2swordfrm.dfm
===================================================================
(Binary files differ)


Property changes on: trunk/misc/olb/prn2swordfrm.dfm
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/misc/olb/prn2swordfrm.h
===================================================================
--- trunk/misc/olb/prn2swordfrm.h	                        (rev 0)
+++ trunk/misc/olb/prn2swordfrm.h	2013-06-22 09:21:20 UTC (rev 425)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2009 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.
+ *
+ */
+
+//---------------------------------------------------------------------------
+#ifndef prn2swordfrmH
+#define prn2swordfrmH
+//---------------------------------------------------------------------------
+#include <Classes.hpp>
+#include <Controls.hpp>
+#include <StdCtrls.hpp>
+#include <Forms.hpp>
+#include <Dialogs.hpp>
+#include <ExtCtrls.hpp>
+//---------------------------------------------------------------------------
+class TForm2 : public TForm
+{
+__published:	// IDE-managed Components
+	TPanel *Panel1;
+	TLabel *Label1;
+	TEdit *FilePathEdit;
+	TButton *FSButton;
+	TPanel *Panel2;
+	TButton *Button1;
+	TMemo *Memo1;
+	TOpenDialog *FSDialog;
+	void __fastcall FSButtonClick(TObject *Sender);
+	void __fastcall Button1Click(TObject *Sender);
+private:	// User declarations
+	int fp, vfp, cfp, bfp, dfp;
+	void openFiles(char *fileName);
+	void filterVerse(char *finalBuf, char lang);
+public:		// User declarations
+	__fastcall TForm2(TComponent* Owner);
+	void ProcessFile(char *fileName);
+	char getVerse(int fp, int *verseNum, char *verseBuf, char testament);
+};
+//---------------------------------------------------------------------------
+extern PACKAGE TForm2 *Form2;
+//---------------------------------------------------------------------------
+#endif




More information about the sword-cvs mailing list