summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-03-29 10:53:52 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-03-29 10:53:52 -0400
commit148bd343f3e7e32d141f66b5b5c9b98b2975b0b3 (patch)
tree31078963b85110d57310759016e60e8d26ccb1e6 /src
parent8c8aa6b07e595cfac56838b5964ab3e96051f1b2 (diff)
Imported Upstream version 1.5.8
Diffstat (limited to 'src')
-rw-r--r--src/Makefile5
-rw-r--r--src/frontend/Makefile5
-rw-r--r--src/frontend/Makefile.am6
-rw-r--r--src/frontend/X11/Makefile5
-rw-r--r--src/frontend/framework/Makefile4
-rw-r--r--src/frontend/framework/femain.cpp12
-rw-r--r--src/frontend/im/Makefile5
-rw-r--r--src/frontend/im/hebrewmcim.cpp653
-rw-r--r--src/frontend/im/nullim.cpp11
-rw-r--r--src/frontend/im/swinputmeth.cpp26
-rw-r--r--src/frontend/swdisp.cpp31
-rw-r--r--src/frontend/swlog.cpp133
-rw-r--r--src/frontend/windoze/Makefile5
-rw-r--r--src/keys/Makefile4
-rw-r--r--src/keys/Makefile.am9
-rw-r--r--src/keys/genarray.c33
-rw-r--r--src/keys/listkey.cpp313
-rw-r--r--src/keys/nt.bksbin112 -> 0 bytes
-rw-r--r--src/keys/nt.cpsbin1152 -> 0 bytes
-rw-r--r--src/keys/ot.bksbin160 -> 0 bytes
-rw-r--r--src/keys/ot.cpsbin3876 -> 0 bytes
-rw-r--r--src/keys/strkey.cpp43
-rw-r--r--src/keys/swkey.cpp215
-rw-r--r--src/keys/treekey.cpp34
-rw-r--r--src/keys/treekeyidx.cpp600
-rw-r--r--src/keys/versekey.cpp1523
-rw-r--r--src/mgr/Makefile4
-rw-r--r--src/mgr/Makefile.am22
-rw-r--r--src/mgr/encfiltmgr.cpp152
-rw-r--r--src/mgr/filemgr.cpp357
-rw-r--r--src/mgr/installmgr.cpp629
-rw-r--r--src/mgr/localemgr.cpp190
-rw-r--r--src/mgr/markupfiltmgr.cpp250
-rw-r--r--src/mgr/swcacher.cpp47
-rw-r--r--src/mgr/swconfig.cpp170
-rw-r--r--src/mgr/swfiltermgr.cpp93
-rw-r--r--src/mgr/swlocale.cpp143
-rw-r--r--src/mgr/swmgr.cpp1181
-rw-r--r--src/mgr/swsearchable.cpp42
-rw-r--r--src/mgr/swsourcemgr.cpp91
-rw-r--r--src/modules/Makefile5
-rw-r--r--src/modules/Makefile.am10
-rw-r--r--src/modules/comments/Makefile5
-rw-r--r--src/modules/comments/Makefile.am8
-rw-r--r--src/modules/comments/hrefcom/Makefile5
-rw-r--r--src/modules/comments/hrefcom/Makefile.am4
-rw-r--r--src/modules/comments/hrefcom/hrefcom.cpp90
-rw-r--r--src/modules/comments/hrefcom/jfbgen.cpp242
-rw-r--r--src/modules/comments/rawcom/Makefile5
-rw-r--r--src/modules/comments/rawcom/Makefile.am4
-rw-r--r--src/modules/comments/rawcom/mhcidx.cpp292
-rw-r--r--src/modules/comments/rawcom/rawcom.cpp184
-rw-r--r--src/modules/comments/rawcom/rtfidx.cpp292
-rw-r--r--src/modules/comments/rawcom/rwpidx.cpp266
-rw-r--r--src/modules/comments/rawfiles/Makefile5
-rw-r--r--src/modules/comments/rawfiles/Makefile.am3
-rw-r--r--src/modules/comments/rawfiles/rawfiles.cpp269
-rw-r--r--src/modules/comments/rawfiles/rawfilesgen.cpp236
-rw-r--r--src/modules/comments/swcom.cpp71
-rw-r--r--src/modules/comments/zcom/Makefile5
-rw-r--r--src/modules/comments/zcom/Makefile.am4
-rw-r--r--src/modules/comments/zcom/makeidx.c146
-rw-r--r--src/modules/comments/zcom/rawtxt2z.cpp83
-rw-r--r--src/modules/comments/zcom/zcom.cpp216
-rw-r--r--src/modules/common/Makefile4
-rw-r--r--src/modules/common/Makefile.am21
-rw-r--r--src/modules/common/compress.cpp767
-rw-r--r--src/modules/common/entriesblk.cpp169
-rw-r--r--src/modules/common/lzsscomprs.cpp668
-rw-r--r--src/modules/common/rawstr.cpp555
-rw-r--r--src/modules/common/rawstr4.cpp561
-rw-r--r--src/modules/common/rawverse.cpp353
-rw-r--r--src/modules/common/sapphire.cpp231
-rw-r--r--src/modules/common/swcipher.cpp128
-rw-r--r--src/modules/common/swcomprs.cpp193
-rw-r--r--src/modules/common/swcomprs.doc802
-rw-r--r--src/modules/common/zipcomprs.cpp161
-rw-r--r--src/modules/common/zstr.cpp718
-rw-r--r--src/modules/common/zverse.cpp538
-rw-r--r--src/modules/filters/Makefile5
-rw-r--r--src/modules/filters/Makefile.am92
-rw-r--r--src/modules/filters/cipherfil.cpp44
-rw-r--r--src/modules/filters/gbffootnotes.cpp197
-rw-r--r--src/modules/filters/gbfheadings.cpp92
-rw-r--r--src/modules/filters/gbfhtml.cpp168
-rw-r--r--src/modules/filters/gbfhtmlhref.cpp229
-rw-r--r--src/modules/filters/gbfmorph.cpp82
-rw-r--r--src/modules/filters/gbfosis.cpp439
-rw-r--r--src/modules/filters/gbfplain.cpp95
-rw-r--r--src/modules/filters/gbfredletterwords.cpp98
-rw-r--r--src/modules/filters/gbfrtf.cpp289
-rw-r--r--src/modules/filters/gbfstrongs.cpp116
-rw-r--r--src/modules/filters/gbfthml.cpp216
-rw-r--r--src/modules/filters/gbfwebif.cpp161
-rw-r--r--src/modules/filters/greeklexattribs.cpp100
-rw-r--r--src/modules/filters/latin1utf16.cpp119
-rw-r--r--src/modules/filters/latin1utf8.cpp173
-rw-r--r--src/modules/filters/osisfootnotes.cpp138
-rw-r--r--src/modules/filters/osisheadings.cpp118
-rw-r--r--src/modules/filters/osishtmlhref.cpp339
-rw-r--r--src/modules/filters/osislemma.cpp78
-rw-r--r--src/modules/filters/osismorph.cpp75
-rw-r--r--src/modules/filters/osisplain.cpp151
-rw-r--r--src/modules/filters/osisredletterwords.cpp77
-rw-r--r--src/modules/filters/osisrtf.cpp333
-rw-r--r--src/modules/filters/osisscripref.cpp104
-rw-r--r--src/modules/filters/osisstrongs.cpp128
-rw-r--r--src/modules/filters/osiswebif.cpp212
-rw-r--r--src/modules/filters/plainfootnotes.cpp83
-rw-r--r--src/modules/filters/plainhtml.cpp70
-rw-r--r--src/modules/filters/rtfhtml.cpp80
-rw-r--r--src/modules/filters/scsuutf8.cpp226
-rw-r--r--src/modules/filters/swbasicfilter.cpp321
-rw-r--r--src/modules/filters/swoptfilter.cpp38
-rw-r--r--src/modules/filters/thmlfootnotes.cpp127
-rw-r--r--src/modules/filters/thmlgbf.cpp283
-rw-r--r--src/modules/filters/thmlheadings.cpp96
-rw-r--r--src/modules/filters/thmlhtml.cpp226
-rw-r--r--src/modules/filters/thmlhtmlhref.cpp209
-rw-r--r--src/modules/filters/thmllemma.cpp69
-rw-r--r--src/modules/filters/thmlmorph.cpp69
-rw-r--r--src/modules/filters/thmlosis.cpp385
-rw-r--r--src/modules/filters/thmlplain.cpp210
-rw-r--r--src/modules/filters/thmlrtf.cpp314
-rw-r--r--src/modules/filters/thmlscripref.cpp126
-rw-r--r--src/modules/filters/thmlstrongs.cpp139
-rw-r--r--src/modules/filters/thmlvariants.cpp112
-rw-r--r--src/modules/filters/thmlwebif.cpp104
-rw-r--r--src/modules/filters/unicodertf.cpp86
-rw-r--r--src/modules/filters/utf16utf8.cpp92
-rw-r--r--src/modules/filters/utf8arshaping.cpp52
-rw-r--r--src/modules/filters/utf8bidireorder.cpp61
-rw-r--r--src/modules/filters/utf8cantillation.cpp55
-rw-r--r--src/modules/filters/utf8greekaccents.cpp249
-rw-r--r--src/modules/filters/utf8hebrewpoints.cpp44
-rw-r--r--src/modules/filters/utf8html.cpp69
-rw-r--r--src/modules/filters/utf8latin1.cpp74
-rw-r--r--src/modules/filters/utf8nfc.cpp53
-rw-r--r--src/modules/filters/utf8nfkd.cpp53
-rw-r--r--src/modules/filters/utf8transliterator.cpp889
-rw-r--r--src/modules/filters/utf8utf16.cpp78
-rw-r--r--src/modules/genbook/Makefile5
-rw-r--r--src/modules/genbook/Makefile.am5
-rw-r--r--src/modules/genbook/rawgenbook/Makefile4
-rw-r--r--src/modules/genbook/rawgenbook/Makefile.am4
-rw-r--r--src/modules/genbook/rawgenbook/rawgenbook.cpp209
-rw-r--r--src/modules/genbook/swgenbook.cpp29
-rw-r--r--src/modules/lexdict/Makefile5
-rw-r--r--src/modules/lexdict/Makefile.am7
-rw-r--r--src/modules/lexdict/rawld/Makefile5
-rw-r--r--src/modules/lexdict/rawld/Makefile.am4
-rw-r--r--src/modules/lexdict/rawld/no13.c34
-rw-r--r--src/modules/lexdict/rawld/rawld.cpp174
-rw-r--r--src/modules/lexdict/rawld/rawldidx.c96
-rw-r--r--src/modules/lexdict/rawld/strongsidx.c90
-rw-r--r--src/modules/lexdict/rawld4/Makefile5
-rw-r--r--src/modules/lexdict/rawld4/Makefile.am4
-rw-r--r--src/modules/lexdict/rawld4/rawld4.cpp172
-rw-r--r--src/modules/lexdict/swld.cpp78
-rw-r--r--src/modules/lexdict/zld/Makefile5
-rw-r--r--src/modules/lexdict/zld/Makefile.am4
-rw-r--r--src/modules/lexdict/zld/zld.cpp170
-rw-r--r--src/modules/readme9
-rw-r--r--src/modules/swmodule.cpp741
-rw-r--r--src/modules/tests/Makefile4
-rw-r--r--src/modules/tests/echomod.cpp21
-rw-r--r--src/modules/texts/Makefile5
-rw-r--r--src/modules/texts/Makefile.am6
-rw-r--r--src/modules/texts/rawgbf/Gbf.c485
-rw-r--r--src/modules/texts/rawgbf/Gbf.pas735
-rw-r--r--src/modules/texts/rawgbf/Gbfmain.pas1267
-rw-r--r--src/modules/texts/rawgbf/Makefile5
-rw-r--r--src/modules/texts/rawgbf/Makefile.am4
-rw-r--r--src/modules/texts/rawgbf/gbf.cpp735
-rw-r--r--src/modules/texts/rawgbf/gbf.h67
-rw-r--r--src/modules/texts/rawgbf/gbfidx.cpp294
-rw-r--r--src/modules/texts/rawgbf/rawgbf.cpp87
-rw-r--r--src/modules/texts/rawtext/Makefile5
-rw-r--r--src/modules/texts/rawtext/Makefile.am4
-rw-r--r--src/modules/texts/rawtext/kjvidx.cpp169
-rw-r--r--src/modules/texts/rawtext/makebnds.c86
-rw-r--r--src/modules/texts/rawtext/nuidx.cpp238
-rw-r--r--src/modules/texts/rawtext/ojbtxidx.c166
-rw-r--r--src/modules/texts/rawtext/rawtext.cpp736
-rw-r--r--src/modules/texts/rawtext/rawtxidx.c146
-rw-r--r--src/modules/texts/rawtext/rtfidx.cpp164
-rw-r--r--src/modules/texts/rawtext/svetxidx.c153
-rw-r--r--src/modules/texts/rawtext/vntidx.cpp185
-rw-r--r--src/modules/texts/swtext.cpp81
-rw-r--r--src/modules/texts/ztext/Makefile5
-rw-r--r--src/modules/texts/ztext/Makefile.am4
-rw-r--r--src/modules/texts/ztext/gbfidx.cpp661
-rw-r--r--src/modules/texts/ztext/makeidx.c146
-rw-r--r--src/modules/texts/ztext/nasb.cpp107
-rw-r--r--src/modules/texts/ztext/rawtxt2z.cpp457
-rw-r--r--src/modules/texts/ztext/ztext.cpp440
-rw-r--r--src/utilfuns/Greek2Greek.cpp905
-rw-r--r--src/utilfuns/Makefile4
-rw-r--r--src/utilfuns/Makefile.am31
-rw-r--r--src/utilfuns/ftpparse.c446
-rw-r--r--src/utilfuns/greekpatch19
-rw-r--r--src/utilfuns/regex.c5725
-rw-r--r--src/utilfuns/roman.cpp87
-rw-r--r--src/utilfuns/sub.c36
-rw-r--r--src/utilfuns/swbuf.cpp163
-rw-r--r--src/utilfuns/swunicod.cpp138
-rw-r--r--src/utilfuns/swversion.cpp81
-rw-r--r--src/utilfuns/unixstr.cpp10
-rw-r--r--src/utilfuns/utilconf.cpp22
-rw-r--r--src/utilfuns/utilstr.cpp204
-rw-r--r--src/utilfuns/utilweb.cpp35
-rw-r--r--src/utilfuns/utilxml.cpp202
-rw-r--r--src/utilfuns/win32/dirent.cpp131
-rw-r--r--src/utilfuns/win32/dirent.h32
-rw-r--r--src/utilfuns/zlib/adler32.c48
-rw-r--r--src/utilfuns/zlib/compress.c68
-rw-r--r--src/utilfuns/zlib/crc32.c162
-rw-r--r--src/utilfuns/zlib/deflate.c1350
-rw-r--r--src/utilfuns/zlib/deflate.h318
-rw-r--r--src/utilfuns/zlib/gzio.c875
-rw-r--r--src/utilfuns/zlib/infblock.c403
-rw-r--r--src/utilfuns/zlib/infblock.h39
-rw-r--r--src/utilfuns/zlib/infcodes.c251
-rw-r--r--src/utilfuns/zlib/infcodes.h27
-rw-r--r--src/utilfuns/zlib/inffast.c183
-rw-r--r--src/utilfuns/zlib/inffast.h17
-rw-r--r--src/utilfuns/zlib/inffixed.h151
-rw-r--r--src/utilfuns/zlib/inflate.c366
-rw-r--r--src/utilfuns/zlib/inftrees.c454
-rw-r--r--src/utilfuns/zlib/inftrees.h58
-rw-r--r--src/utilfuns/zlib/infutil.c87
-rw-r--r--src/utilfuns/zlib/infutil.h98
-rw-r--r--src/utilfuns/zlib/maketree.c85
-rw-r--r--src/utilfuns/zlib/trees.c1214
-rw-r--r--src/utilfuns/zlib/trees.h128
-rw-r--r--src/utilfuns/zlib/uncompr.c58
-rw-r--r--src/utilfuns/zlib/untgz.c436
-rw-r--r--src/utilfuns/zlib/zutil.c225
-rw-r--r--src/utilfuns/zlib/zutil.h220
239 files changed, 0 insertions, 50094 deletions
diff --git a/src/Makefile b/src/Makefile
deleted file mode 100644
index fc04b62..0000000
--- a/src/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-root := ..
-
-all:
- make -C ${root}
diff --git a/src/frontend/Makefile b/src/frontend/Makefile
deleted file mode 100644
index ef8eccd..0000000
--- a/src/frontend/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-root := ../..
-
-all:
- make -C ${root}
diff --git a/src/frontend/Makefile.am b/src/frontend/Makefile.am
deleted file mode 100644
index df82518..0000000
--- a/src/frontend/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-frontenddir = $(top_srcdir)/src/frontend
-
-libsword_la_SOURCES += $(frontenddir)/swdisp.cpp
-libsword_la_SOURCES += $(frontenddir)/swlog.cpp
-
-
diff --git a/src/frontend/X11/Makefile b/src/frontend/X11/Makefile
deleted file mode 100644
index 1a2d00d..0000000
--- a/src/frontend/X11/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-root := ../../..
-
-all:
- make -C ${root}
diff --git a/src/frontend/framework/Makefile b/src/frontend/framework/Makefile
deleted file mode 100644
index 81f7721..0000000
--- a/src/frontend/framework/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-root := ../../..
-
-all:
- make -C ${root}
diff --git a/src/frontend/framework/femain.cpp b/src/frontend/framework/femain.cpp
deleted file mode 100644
index 415ab6f..0000000
--- a/src/frontend/framework/femain.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <femain.h>
-
-FEMain::FEMain() {
-}
-
-FEMain::~FEMain() {
- list <SWDisplay *>::iterator it;
-
- for (it = displays.begin(); it != displays.end(); it++)
- delete *it;
-
-}
diff --git a/src/frontend/im/Makefile b/src/frontend/im/Makefile
deleted file mode 100644
index 1a2d00d..0000000
--- a/src/frontend/im/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-root := ../../..
-
-all:
- make -C ${root}
diff --git a/src/frontend/im/hebrewmcim.cpp b/src/frontend/im/hebrewmcim.cpp
deleted file mode 100644
index 9ec55a9..0000000
--- a/src/frontend/im/hebrewmcim.cpp
+++ /dev/null
@@ -1,653 +0,0 @@
-
-/**
- * Title: Keyboard mapping for Michigan-Claremont Hebrew input
- * Description:
- * Copyright: Copyright (c) 2001 CrossWire Bible Society under the terms of the GNU GPL
- * Company:
- * @author Troy A. Griffitts
- * @version 1.0
- */
-
-#include <hebrewmcim.h>
-
-HebrewMCIM::HebrewMCIM()
- :SWInputMethod() {
-
- init();
-}
-
-
-int *HebrewMCIM::translate(char in) {
- int retVal = 0;
- static int retString[5];
- int retStringIndex = 0;
-
- memset(retString, 0, 5);
-
- if (getState() > 1) {
- if (getState() >= 12) { // serious issue with internal structure
- setState(0);
- retString[retStringIndex++] = in;
- return retString;
- }
- map<int, int>::iterator find = subst2[getState()].find(in);
- if (find != subst2[getState()].end())
- retVal = find->second;
- else retVal = in;
-
- setState(0);
- retString[retStringIndex++] = retVal;
- return retString;
- }
- else {
- retVal = subst[in];
-
- if (retVal == 0) {
- setState(0);
- retString[retStringIndex++] = in;
- return retString;
- }
- if (retVal > 100) {
- setState(1);
- retString[retStringIndex++] = retVal;
- return retString;
- }
- if (retVal == 50) { // multiChar
- setState(1);
- int *chars = multiChars[in];
- if (chars != 0) {
- retString[retStringIndex++] = chars[0];
- retString[retStringIndex++] = chars[1];
- return retString;
- }
- }
- }
- setState(retVal);
- return 0;
-}
-
-
-void HebrewMCIM::init() {
- memset(subst, 0, 255);
-
- subst[')'] = 1488;
- subst['B'] = 1489;
- subst['G'] = 1490;
- subst['D'] = 1491;
- subst['H'] = 1492;
- subst['W'] = 1493;
- subst['Z'] = 1494;
- subst['X'] = 1495;
- subst['+'] = 1496;
- subst['Y'] = 1497;
-
- subst['k'] = 1498; // finals
- subst['m'] = 1501;
- subst['n'] = 1503;
- subst['c'] = 1509;
-
- subst['P'] = 1508;
- subst['K'] = 1499;
- subst['L'] = 1500;
- subst['M'] = 1502;
- subst['N'] = 1504;
- subst['S'] = 1505;
- subst['('] = 1506;
- subst['p'] = 1507;
- subst['C'] = 1510;
- subst['Q'] = 1511;
- subst['R'] = 1512;
- subst['#'] = 1513;
-
- // special multiChars
- subst['&'] = 50;
- subst['$'] = 50;
-
- static int x[] = {1513, 1474};
- multiChars['&'] = x;
- static int y[] = {1513, 1473};
- multiChars['$'] = y;
-
- subst['T'] = 1514;
-
- // VOWELS
- subst['A'] = 1463;
- subst['F'] = 1464;
- subst['E'] = 1462;
- subst['"'] = 1461;
- subst['I'] = 1460;
- subst['O'] = 1465;
- subst['U'] = 1467;
-
-
-
- // OTHER DIACRITICS
- subst['.'] = 1468;
- subst['-'] = 1470;
- subst[','] = 1471;
-
- // Compound input
-
- // CANTILLATION
-
- subst[':'] = 2;
- subst2[2]['A'] = 1458;
- subst2[2]['E'] = 1457;
- subst2[2]['F'] = 1459;
-
-
- /* Telisha qetana is postpositive as in '04' above. However, Michigan
-# code '24' is for a medial telisha. Graphically, there is no
-# difference.
- */
- subst['2'] = 5;
- subst2[5]['4'] = 1449;
-
-
- /* Note Michigan encoding distinguishes between medial metheg '35' (occuring
-# on the left of the vowel), and the ordinary meteg '95' (occuring on the
-# right of the vowel). It is also used for silluq.
- */
- subst['3'] = 6;
- subst2[6]['3'] = 1433;
- subst2[6]['5'] = 1469;
-
-
- /* The Michigan code of telisha gedola in medial position. Graphically,
-# there is no difference.
- */
- subst['4'] = 7;
- subst2[7]['4'] = 1440;
-
- subst['6'] = 8;
- subst2[8]['0'] = 1451;
- subst2[8]['1'] = 1436;
-
- subst['1'] = 4;
- subst2[4]['0'] = 1434;
-
- /* In the poetic books, prepositive dehi occurs; it's unclear whether
-# tipeha also occurs in the poetic books. Otherwise, we could simply
-# check for what book in the Tanach we are in. Michigan uses the same
-# code for each.
- */
-
- subst2[4]['3'] = 1430;
-
- /* This is the poetic accent mugrash, which also includes rebia, but is
-# encoded separately as '81' in the Michigan text.
- */
- subst2[4]['1'] = 1437;
- subst2[4]['4'] = 1440;
-
-
- subst['0'] = 3;
- subst2[3]['0'] = 1475;
- subst2[3]['1'] = 1426;
-
- /* According to BHS, zarqa and sinnor are both postpositive. However,
-# the Michigan encoding uses one code for both. The Unicode zarqa
-# (0x0598) is definitely NOT postpositive. And further, the shape of
-# the symbol is different in BHS and Uniocde. This needs further
-# research to determine what's going on here. For now, we follow BHS
-# and use the postpositive Unicode zinor or both accents.
- */
-
- subst2[3]['2'] = 1454;
-
- /* Pashta is postpositive, and the Unicode equivalent reflects
-# this. However, there is a poetic equivalent -- azla legarmeh --
-# which is not postpositive, but no equivalent code point exists in
-# Unicode. The Michigan encoding does not distinguish between the two,
-# although it could be algorithmically determined.
- */
-
- subst2[3]['3'] = 1433;
- subst2[3]['4'] = 1449;
- subst2[3]['5'] = 1472;
-
-
- /* This is the Unicode Hebrew *accent*; there is also another Hebrew
-# *punctuation* called GERSHAYIM 0x05F4. I'm using the more
-# traditional rounded marks, rather than the alternate straight
-# marks.
- */
-
- subst2[8]['2'] = 1438;
-
- // Also known as azla
- subst2[8]['3'] = 1448;
- subst2[8]['4'] = 1452;
- subst2[8]['5'] = 1427;
-
-
- subst['8'] = 9;
- subst2[9]['0'] = 1428;
- subst2[9]['1'] = 1431;
-
- /* Note, this accent is actually sinnorit, but it does not exist as a
-# separate glyph in the Unicode standard. The 'ZINOR' Unicode accent
-# is postpositive, while sinnorit is not. ZARQA is as close as I can
-# get to this.
- */
- subst2[9]['2'] = 1432;
-
- /* The Unicode form does not match the form used by BHS, but the names
-# are the same.
- */
- subst2[9]['3'] = 1441;
- subst2[9]['4'] = 1439;
- subst2[9]['5'] = 1429;
-
- subst['7'] = 10;
- subst2[10]['0'] = 1444;
- subst2[10]['1'] = 1445;
- subst2[10]['2'] = 1446;
- subst2[10]['3'] = 1430; // also '13', '73' also is used for majela
- subst2[10]['4'] = 1443;
- subst2[10]['5'] = 1469; // this is silluq; should appear to the left of the vowel
-
- subst['9'] = 11;
- subst2[11]['1'] = 1435;
- subst2[11]['2'] = 1425;
- subst2[11]['3'] = 1450;
- subst2[11]['4'] = 1447;
- subst2[11]['5'] = 1469; // should appear to the right of the vowel
-
-}
-
- /*
-
-
-# CANTILLION MARKS
-
- my $ETNAHTA = '&#1425;';
-# officially the Unicode name for this symbol was "SEGOL." However, that is
-# not a unique name, conflicting with the vowel of the same name. Further,
-# the position of the symbol is different. I have changed the name of the
-# accent to "SEGOLTA," the traditional name for this accent.
- my $SEGOLTA = '&#1426;';
- my $SHALSHELET = '&#1427;';
- my $ZAQEF_QATAN = '&#1428;';
- my $ZAQEF_GADOL = '&#1429;';
- my $TIPEHA = '&#1430;';
- my $REVIA = '&#1431;';
- my $ZARQA = '&#1432;';
- my $PASHTA = '&#1433;';
- my $YETIV = '&#1434;';
- my $TEVIR = '&#1435;';
- my $GERESH = '&#1436;';
- my $GERESH_MUQDAM = '&#1437;';
- my $GERSHAYIM = '&#1438;';
- my $QARNEY_PARA = '&#1439;';
- my $TELISHA_GEDOLA = '&#1440;';
- my $PAZER = '&#1441;';
- my $MUNAH = '&#1443;';
- my $MAHAPAKH = '&#1444;';
- my $MERKHA = '&#1445;';
- my $MERKHA_KEFULA = '&#1446;';
- my $DARGA = '&#1447;';
- my $QADMA = '&#1448;';
- my $TELISHA_QETANA = '&#1449;';
- my $YERAH_BEN_YOMO = '&#1450;';
- my $OLE = '&#1451;';
- my $ILUY = '&#1452;';
- my $DEHI = '&#1453;';
- my $ZINOR = '&#1454;';
-# HEBREW MARK
- my $MASORA_CIRCLE = '&#1455;';
-# HEBREW EXTENDED-A points and punctuation
- my $SHEVA = '&#1456;';
- my $HATAF_SEGOL = '&#1457;';
- my $HATAF_PATAH = '&#1458;';
- my $HATAF_QAMATS = '&#1459;';
- my $HIRIQ = '&#1460;';
- my $TSERE = '&#1461;';
- my $SEGOL = '&#1462;';
-# furtive Patah is not a distinct character
- my $PATAH = '&#1463;';
- my $QAMATS = '&#1464;';
- my $HOLAM = '&#1465;';
- my $QUBUTS = '&#1467;';
-# also used as shuruq
-# falls within the base letter
- my $DAGESH_OR_MAPIQ = '&#1468;';
-# also used as siluq
- my $METAG = '&#1469;';
- my $MAQAF = '&#1470;';
- my $RAFE = '&#1471;';
-# Also used for legarmeh
-# may be treated as spacing punctuation, not as a point
- my $PASEQ = '&#1472;';
- my $SHIN_DOT = '&#1473;';
- my $SIN_DOT = '&#1474;';
- my $SOF_PASUQ = '&#1475;';
-# HEBREW MARK
- my $UPPER_DOT = '&#1476;';
-# HEBREW LETTERS based on ISO 8859-8
-# aleph
-# x (alef symbol - 2135)
- my $ALEF = '&#1488;';
-# x (bet symbol - 2136)
- my $BET = '&#1489;';
-# x (gimel symbol - 2137)
- my $GIMEL = '&#1490;';
-# x (dalet symbol - 2138)
- my $DALET = '&#1491;';
- my $HE = '&#1492;';
- my $VAV = '&#1493;';
- my $ZAYIN = '&#1494;';
- my $HET = '&#1495;';
- my $TET = '&#1496;';
- my $YOD = '&#1497;';
- my $FINAL_KAF = '&#1498;';
- my $KAF = '&#1499;';
- my $LAMED = '&#1500;';
- my $FINAL_MEM = '&#1501;';
- my $MEM = '&#1502;';
- my $FINAL_NUN = '&#1503;';
- my $NUN = '&#1504;';
- my $SAMEKH = '&#1505;';
- my $AYIN = '&#1506;';
- my $FINAL_PE = '&#1507;';
- my $PE = '&#1508;';
- my $FINAL_TSADI = '&#1509;';
-# also known as zade
- my $TSADI = '&#1510;';
- my $QOF = '&#1511;';
- my $RESH = '&#1512;';
- my $SHIN = '&#1513;';
- my $TAV = '&#1514;';
-# Yiddish digraphs
-# Hebrew Ligature
-# tsvey vovn
- my $DOUBLE_VAV = '&#1520;';
- my $VAV_YOD = '&#1521;';
-# tsvey yudn
- my $DOUBLE_YOD = '&#1522;';
-
-# Additional punctuation
- my $PUNCT_GERESH = '&#1523;';
- my $PUNCT_GERSHAYIM = '&#1524;';
-# Reserved: 0x05F5"
-# x (hebrew point judeo-spanish varika - FB1E)
-#my $JUDEO_SPANISH_VARIKA = pack("U",0xFB1E); # UTF-8 OxFB1E
-
-#############################
-# End of Unicode 2.0 Hebrew #
-#############################
-
-# A hash whose key is a Michagan code, and whose value is a Unicode
-# equvalent
-
- char subst[] = new char [255];
- subst[')'] = 1488;
- 'B' => $BET,
- 'G' => $GIMEL,
- 'D' => $DALET,
- 'H' => $HE,
- 'W' => $VAV,
- 'Z' => $ZAYIN,
- 'X' => $HET,
- '+' => $TET,
- 'Y' => $YOD,
- 'K' => $KAF,
- 'L' => $LAMED,
- 'M' => $MEM,
- 'N' => $NUN,
- 'S' => $SAMEKH,
- '(' => $AYIN,
- 'P' => $PE,
- 'C' => $TSADI,
- 'Q' => $QOF,
- 'R' => $RESH,
- '#' => $SHIN, # the letter shin without a point
- '&' => ($SHIN . $SIN_DOT),
- '$' => ($SHIN . $SHIN_DOT), # '
- 'T' => $TAV,
-# VOWELS
- 'A' => $PATAH,
- 'F' => $QAMATS,
- 'E' => $SEGOL,
- '"' => $TSERE,
- 'I' => $HIRIQ,
- 'O' => $HOLAM,
- 'U' => $QUBUTS,
- ':' => $SHEVA,
- ':A' => $HATAF_PATAH,
- ':E' => $HATAF_SEGOL,
- ':F' => $HATAF_QAMATS,
-# OTHER DIACRITICS
- '.' => $DAGESH_OR_MAPIQ,
- '-' => $MAQAF,
- ',' => $RAFE,
-# CANTILLATION
- '00' => $SOF_PASUQ,
- '01' => $SEGOLTA,
-# According to BHS, zarqa and sinnor are both postpositive. However,
-# the Michigan encoding uses one code for both. The Unicode zarqa
-# (0x0598) is definitely NOT postpositive. And further, the shape of
-# the symbol is different in BHS and Uniocde. This needs further
-# research to determine what's going on here. For now, we follow BHS
-# and use the postpositive Unicode zinor or both accents.
- '02' => $ZINOR,
-# Pashta is postpositive, and the Unicode equivalent reflects
-# this. However, there is a poetic equivalent -- azla legarmeh --
-# which is not postpositive, but no equivalent code point exists in
-# Unicode. The Michigan encoding does not distinguish between the two,
-# although it could be algorithmically determined.
- '03' => $PASHTA,
- '04' => $TELISHA_QETANA,
- '05' => $PASEQ,
- '10' => $YETIV,
-# In the poetic books, prepositive dehi occurs; it's unclear whether
-# tipeha also occurs in the poetic books. Otherwise, we could simply
-# check for what book in the Tanach we are in. Michigan uses the same
-# code for each.
- '13' => $TIPEHA, # also $DEHI
-# This is the poetic accent mugrash, which also includes rebia, but is
-# encoded separately as '81' in the Michigan text.
- '11' => $GERESH_MUQDAM,
- '14' => $TELISHA_GEDOLA,
-# Telisha qetana is postpositive as in '04' above. However, Michigan
-# code '24' is for a medial telisha. Graphically, there is no
-# difference.
- '24' => $TELISHA_QETANA,
- '33' => $PASHTA,
-# The Michigan code of telisha gedola in medial position. Graphically,
-# there is no difference.
- '44' => $TELISHA_GEDOLA,
- '60' => $OLE,
- '61' => $GERESH,
-# This is the Unicode Hebrew *accent*; there is also another Hebrew
-# *punctuation* called GERSHAYIM 0x05F4. I'm using the more
-# traditional rounded marks, rather than the alternate straight
-# marks.
- '62' => $GERSHAYIM,
-# Also known as azla
- '63' => $QADMA,
- '64' => $ILUY,
- '65' => $SHALSHELET,
- '80' => $ZAQEF_QATAN,
- '81' => $REVIA,
-# Note, this accent is actually sinnorit, but it does not exist as a
-# separate glyph in the Unicode standard. The 'ZINOR' Unicode accent
-# is postpositive, while sinnorit is not. ZARQA is as close as I can
-# get to this.
- '82' => $ZARQA,
-# The Unicode form does not match the form used by BHS, but the names
-# are the same.
- '83' => $PAZER,
- '84' => $QARNEY_PARA,
- '85' => $ZAQEF_GADOL,
-# Note Michigan encoding distinguishes between medial metheg '35' (occuring
-# on the left of the vowel), and the ordinary meteg '95' (occuring on the
-# right of the vowel). It is also used for silluq.
- '35' => $METAG,
- '70' => $MAHAPAKH,
- '71' => $MERKHA,
- '72' => $MERKHA_KEFULA,
- '73' => $TIPEHA, # also '13', '73' also is used for majela
- '74' => $MUNAH,
- '75' => $METAG, # this is silluq; should appear to the left of the vowel
- '91' => $TEVIR,
- '92' => $ETNAHTA,
- '93' => $YERAH_BEN_YOMO,
- '94' => $DARGA,
- '95' => $METAG, # should appear to the right of the vowel
-
-# Not used by the Michigan Encoding
-# $UPPER_DOT = '05C4';
- );
-
-# declare other variables
- my (@bhsLines,
- @bhsVerse,
- @entity_line) = ();
-
- my ($i,
- $verse,
- $word,
- $character) = 0;
-
- my ($element,
- $saveGuttural) = "";
-
-# read in a line
- while (<>) {
-# Process one verse
-# iterate over every character and change to XML decimal entity
- CHAR: for ( $i = 0; ($i < scalar(@bhsVerse)); $i++) {
- # find and convert final kaf, mem, nun, pe, tsade
- ( # if final form
- $bhsVerse[$i] =~ /[KMNPC]/
- )
- &&
- (
- ( # whitespace or
- $bhsVerse[$i+1] =~ /[ \-?]/
- )
- ||
- ( # EOL or
- $i == ( scalar(@bhsVerse) - 1 )
- )
- ||
- ( # sof pasuq or
- ( $bhsVerse[$i+1] =~ /0/ ) &&
- ( $bhsVerse[$i+2] =~ /0/ )
- )
- ||
- ( # one accent followed by white, eol or
- (
- ( $bhsVerse[$i+1] =~ /\d/ ) &&
- ( $bhsVerse[$i+2] =~ /\d/ )
- ) &&
- (
- ( $bhsVerse[$i+3] =~ /[ \-?]/ ) ||
- ( $i == ( scalar(@bhsVerse) - 1 ) )
- )
- )
- ||
- ( # two accents followed by white, eol
- (
- ( $bhsVerse[$i+1] =~ /\d/ ) &&
- ( $bhsVerse[$i+2] =~ /\d/ ) &&
- ( $bhsVerse[$i+3] =~ /\d/ ) &&
- ( $bhsVerse[$i+4] =~ /\d/ )
- ) &&
- (
- ( $bhsVerse[$i+5] =~ /[ \-?]/ ) ||
- ( $i == ( scalar(@bhsVerse) - 1 ) )
- )
- )
- ||
- ( # followed by a vowel and white, eol, sof pasuq
- ( $bhsVerse[$i+1] =~ /[:F]/ ) &&
- ( # followed by
- ( $bhsVerse[$i+2] =~ /[ \-?]/ ) || # whitespace or
- ( $i == ( scalar(@bhsVerse) - 1 ) ) || # eol or
- ( # sof pasuq
- ( $bhsVerse[$i+2] =~ /0/ ) &&
- ( $bhsVerse[$i+3] =~ /0/ )
- )
- )
- )
- ) # end of what follows after final letter
- &&
- do {
- $bhsVerse[$i] =~ /K/ && eval { push @entity_line,$FINAL_KAF; }
- && next CHAR;
- $bhsVerse[$i] =~ /M/ && eval { push @entity_line,$FINAL_MEM; }
- && next CHAR;
- $bhsVerse[$i] =~ /N/ && eval { push @entity_line,$FINAL_NUN; }
- && next CHAR;
- $bhsVerse[$i] =~ /P/ && eval { push @entity_line,$FINAL_PE; }
- && next CHAR;
- $bhsVerse[$i] =~ /C/ && eval { push @entity_line,$FINAL_TSADI; }
- && next CHAR;
- };
- # find and convert "furtive patach"
- ( $bhsVerse[$i] =~ /A/ ) && # If the letter is a patach
- ( $bhsVerse[$i-1] =~ /[)HX(]/ ) && # and is preceeded by a guttural
- ( ( $bhsVerse[$i-2] =~ /[AEFOU]/ ) || # and is preceeded by a vowel
- ( ( $bhsVerse[$i-2] =~ /\./ ) && # or by suruq
- ( $bhsVerse[$i-3] =~ /W/ ) ) || #
- ( ( $bhsVerse[$i-2] =~ /W/ ) && # or by holem (written plene)
- ( $bhsVerse[$i-3] =~ /O/ ) ) || #
- ( ( $bhsVerse[$i-2] =~ /Y/ ) && # or by hiriq-yod
- ( $bhsVerse[$i-3] =~ /I/ ) ) ) &&
- do {
- $saveGuttural = pop @entity_line; # snip off the gutteral
- push @entity_line,$PATAH; # push on the patach
- push @entity_line,$saveGuttural; # push back on the gutteral
- next CHAR;
- };
- # convert cantillation
- # since we have previously dealt with all other cases of
- # numbers, two digit patterns are all we have to search for
- $bhsVerse[$i] =~ /\d/ && $bhsVerse[$i+1] =~ /\d/ && do {
- push @entity_line,$Michigan2XMLentity{"$bhsVerse[$i]$bhsVerse[$i+1]"};
- $i++; # accents are two digits long, so advance past the 2nd digit
- next CHAR;
- };
- # convert katef vowels, which are two characters long
- $bhsVerse[$i] =~ /:/ && $bhsVerse[$i+1] =~ /[AEF]/ && do {
- push @entity_line,$Michigan2XMLentity{"$bhsVerse[$i]$bhsVerse[$i+1]"};
- $i++;
- next CHAR;
- };
- # convert everything else
- push @entity_line,$Michigan2XMLentity{"$bhsVerse[$i]"};
- } # end CHAR
-# print the line to standard output with XML character-level encoding
-# each character has the following format:
-# <c id="1kg1.verse#.word#.character#">&#1234;</c>
-
-# set up the verse element
- $word = 1;
- $character = 1;
- print "<verse>\n<word>\n";
-# print each character element
-# if there is a space, then close the word entity, open a new word
-# entity, increment the word number, reset the character number to
-# zero.
- foreach $element (@entity_line) {
- if ( $element =~ " " ) {
- $word++;
- $character = 1;
- print "</word>\n<word>\n";
- next;
- }
- print "<c id=\"1kg1.$verse.$word.$character\">$element</c>\n";
- $character++;
- }
-# close the verse element
- print "</word></verse>\n";
-# reinitialize variables
- @bhsVerse = ();
- @entity_line = ();
- @bhsLines = ();
- } # end while
-# close the XML document
- print "</body>\n";
- */
diff --git a/src/frontend/im/nullim.cpp b/src/frontend/im/nullim.cpp
deleted file mode 100644
index a4f4aad..0000000
--- a/src/frontend/im/nullim.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <nullim.h>
-
-
-NullIM::NullIM() {
-}
-
-int *NullIM::translate(char ch) {
- static int retVal[1];
- *retVal = ch;
- return retVal;
-}
diff --git a/src/frontend/im/swinputmeth.cpp b/src/frontend/im/swinputmeth.cpp
deleted file mode 100644
index 7f64865..0000000
--- a/src/frontend/im/swinputmeth.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Title:
- * Description:
- * Copyright: Copyright (c) 2001 CrossWire Bible Society under the terms of the GNU GPL
- * Company:
- * @author Troy A. Griffitts
- * @version 1.0
- */
-
-#include <swinputmeth.h>
-
-SWInputMethod::SWInputMethod() {
- state = 0;
-}
-
-void SWInputMethod::setState(int state) {
- this->state = state;
-}
-
-int SWInputMethod::getState() {
- return state;
-}
-
-void SWInputMethod::clearState() {
- state = 0;
-}
diff --git a/src/frontend/swdisp.cpp b/src/frontend/swdisp.cpp
deleted file mode 100644
index bdb0a74..0000000
--- a/src/frontend/swdisp.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/******************************************************************************
- * swdisp.cpp - code for base class 'swdisp'. swdisp is the basis for all
- * types of displays (e.g. raw textout, curses, xwindow, etc.)
- */
-
-#include <iostream>
-#include <swmodule.h>
-#include <swdisp.h>
-
-SWORD_NAMESPACE_START
-
-static const char *classes[] = {"SWDisplay", "SWObject", 0};
-SWClass SWDisplay::classdef(classes);
-
-/******************************************************************************
- * SWDisplay::Display - casts a module to a character pointer and displays it to
- * raw output (overriden for different display types and
- * module types if necessary)
- *
- * ENT: imodule - module to display
- *
- * RET: error status
- */
-
-char SWDisplay::Display(SWModule &imodule)
-{
- std::cout << (const char *)imodule;
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/frontend/swlog.cpp b/src/frontend/swlog.cpp
deleted file mode 100644
index 03cfc23..0000000
--- a/src/frontend/swlog.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-//---------------------------------------------------------------------------
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <iostream>
-#if defined(_ICU_) && !defined(_ICUSWORD_)
-#define _USTDIO_
-#include <unicode/ustdio.h>
-#include <unicode/ustream.h>
-#endif
-#include "swlog.h"
-//---------------------------------------------------------------------------
-
-SWORD_NAMESPACE_START
-
-SWLog *SWLog::systemlog = 0;
-
-
-class __staticsystemlog {
-public:
- __staticsystemlog() {
- SWLog::systemlog = new SWLog();
- }
- ~__staticsystemlog() {
- delete SWLog::systemlog;
- }
-} _staticsystemlog;
-
-
-void SWLog::LogWarning(char *fmt, ...)
-{
- //#ifdef _USTDIO_
- //UChar msg[2048];
- //#else
- char msg[2048];
- //#endif
- va_list argptr;
-
- if (logLevel >= 2) {
- va_start(argptr, fmt);
- //#ifdef _USTDIO_
- //u_vsprintf(msg, NULL, fmt, argptr);
- //#else
- vsprintf(msg, fmt, argptr);
- //#endif
- va_end(argptr);
-
-#ifndef _WIN32_WCE
- std::cerr << msg;
- std::cerr << std::endl;
-#endif
- }
-}
-
-
-void SWLog::LogError(char *fmt, ...)
-{
- //#ifdef _USTDIO_
- //UChar msg[2048];
- //#else
- char msg[2048];
- //#endif
- va_list argptr;
-
- if (logLevel) {
- va_start(argptr, fmt);
- //#ifdef _USTDIO_
- //u_vsprintf(msg, NULL, fmt, argptr);
- //#else
- vsprintf(msg, fmt, argptr);
- //#endif
- va_end(argptr);
-
-#ifndef _WIN32_WCE
- std::cerr << msg;
- std::cerr << std::endl;
-#endif
- }
-}
-
-
-void SWLog::LogTimedInformation(char *fmt, ...)
-{
- //#ifdef _USTDIO_
- //UChar msg[2048];
- //#else
- char msg[2048];
- //#endif
- va_list argptr;
-
- if (logLevel >= 4) {
- va_start(argptr, fmt);
- //#ifdef _USTDIO_
- //u_vsprintf(msg, NULL, fmt, argptr);
- //#else
- vsprintf(msg, fmt, argptr);
- //#endif
- va_end(argptr);
-
-#ifndef _WIN32_WCE
- std::cout << msg;
- std::cout << std::endl;
-#endif
- }
-}
-
-
-void SWLog::LogInformation(char *fmt, ...)
-{
- //#ifdef _USTDIO_
- //UChar msg[2048];
- //#else
- char msg[2048];
- //#endif
- va_list argptr;
-
- if (logLevel >= 3) {
- va_start(argptr, fmt);
- //#ifdef _USTDIO_
- //u_vsprintf(msg, NULL, fmt, argptr);
- //#else
- vsprintf(msg, fmt, argptr);
- //#endif
- va_end(argptr);
-
-#ifndef _WIN32_WCE
- std::cout << msg;
- std::cout << std::endl;
-#endif
- }
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/frontend/windoze/Makefile b/src/frontend/windoze/Makefile
deleted file mode 100644
index 1a2d00d..0000000
--- a/src/frontend/windoze/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-root := ../../..
-
-all:
- make -C ${root}
diff --git a/src/keys/Makefile b/src/keys/Makefile
deleted file mode 100644
index 339f87a..0000000
--- a/src/keys/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-root := ../..
-
-all:
- make -C ${root}
diff --git a/src/keys/Makefile.am b/src/keys/Makefile.am
deleted file mode 100644
index ddeab6a..0000000
--- a/src/keys/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-keysdir = $(top_srcdir)/src/keys
-
-libsword_la_SOURCES += $(keysdir)/swkey.cpp
-libsword_la_SOURCES += $(keysdir)/listkey.cpp
-libsword_la_SOURCES += $(keysdir)/versekey.cpp
-libsword_la_SOURCES += $(keysdir)/strkey.cpp
-libsword_la_SOURCES += $(keysdir)/treekey.cpp
-libsword_la_SOURCES += $(keysdir)/treekeyidx.cpp
-
diff --git a/src/keys/genarray.c b/src/keys/genarray.c
deleted file mode 100644
index f519950..0000000
--- a/src/keys/genarray.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <stdio.h>
-#include <fcntl.h>
-#include <stdlib.h>
-
-main()
-{
- int fd, l1, l2, l3;
- char *fnames[] = {"ot.bks", "ot.cps", "nt.bks", "nt.cps"};
- long val;
- char buf[64];
-
-#ifndef O_BINARY // O_BINARY is needed in Borland C++ 4.53
-#define O_BINARY 0 // If it hasn't been defined than we probably
-#endif // don't need it.
-
-
- for (l1 = 0; l1 < 2; l1++) {
- for (l2 = 0; l2 < 2; l2++) {
- l3 = 1;
- sprintf(buf, "%s", fnames[(l1*2)+l2]);
- printf(" // %s\n", fnames[(l1*2)+l2]);
- fd = open(buf, O_RDONLY|O_BINARY);
- while (read(fd, &val, 4) == 4) {
- l3++;
- printf("%ld, ", val/(4 + (l2*2)));
- if (!(l3%7))
- printf("\n");
- }
- close(fd);
- printf("}, \n");
- }
- }
-}
diff --git a/src/keys/listkey.cpp b/src/keys/listkey.cpp
deleted file mode 100644
index 1dec72b..0000000
--- a/src/keys/listkey.cpp
+++ /dev/null
@@ -1,313 +0,0 @@
-/******************************************************************************
- * listkey.cpp - code for base class 'ListKey'. ListKey is the basis for all
- * types of keys that have lists of specified indexes
- * (e.g. a list of verses, place, etc.)
- */
-
-#include <utilfuns.h>
-#include <stdlib.h>
-#include <swkey.h>
-#include <listkey.h>
-
-SWORD_NAMESPACE_START
-
-static const char *classes[] = {"ListKey", "SWKey", "SWObject", 0};
-SWClass ListKey::classdef(classes);
-
-/******************************************************************************
- * ListKey Constructor - initializes instance of ListKey
- *
- * ENT: ikey - text key
- */
-
-ListKey::ListKey(const char *ikey): SWKey(ikey) {
- arraymax = 0;
- ClearList();
- init();
-}
-
-
-ListKey::ListKey(ListKey const &k) : SWKey(k.keytext) {
- arraymax = k.arraymax;
- arraypos = k.arraypos;
- arraycnt = k.arraycnt;
- array = (arraymax)?(SWKey **)malloc(k.arraymax * sizeof(SWKey *)):0;
- for (int i = 0; i < arraycnt; i++)
- array[i] = k.array[i]->clone();
- init();
-}
-
-
-void ListKey::init() {
- myclass = &classdef;
-}
-
-
-SWKey *ListKey::clone() const
-{
- return new ListKey(*this);
-}
-
-/******************************************************************************
- * ListKey Destructor - cleans up instance of ListKey
- */
-
-ListKey::~ListKey()
-{
- ClearList();
-}
-
-
-/******************************************************************************
- * ListKey::ClearList - Clears out elements of list
- */
-
-void ListKey::ClearList()
-{
- int loop;
-
- if (arraymax) {
- for (loop = 0; loop < arraycnt; loop++)
- delete array[loop];
-
- free(array);
- arraymax = 0;
- }
- arraycnt = 0;
- arraypos = 0;
- array = 0;
-}
-
-
-/******************************************************************************
- * ListKey::copyFrom Equates this ListKey to another ListKey object
- *
- * ENT: ikey - other ListKey object
- */
-
-void ListKey::copyFrom(const ListKey &ikey) {
- ClearList();
-
- arraymax = ikey.arraymax;
- arraypos = ikey.arraypos;
- arraycnt = ikey.arraycnt;
- array = (arraymax)?(SWKey **)malloc(ikey.arraymax * sizeof(SWKey *)):0;
- for (int i = 0; i < arraycnt; i++)
- array[i] = ikey.array[i]->clone();
-
- SetToElement(0);
-}
-
-
-/******************************************************************************
- * ListKey::add - Adds an element to the list
- */
-
-void ListKey::add(const SWKey &ikey) {
- if (++arraycnt > arraymax) {
- array = (SWKey **) ((array) ? realloc(array, (arraycnt + 32) * sizeof(SWKey *)) : calloc(arraycnt + 32, sizeof(SWKey *)));
- arraymax = arraycnt + 32;
- }
- array[arraycnt-1] = ikey.clone();
- SetToElement(arraycnt-1);
-}
-
-
-
-/******************************************************************************
- * ListKey::setPosition(SW_POSITION) - Positions this key
- *
- * ENT: p - position
- *
- * RET: *this
- */
-
-void ListKey::setPosition(SW_POSITION p) {
- switch (p) {
- case 1: // GCC won't compile P_TOP
- SetToElement(0, p);
- break;
- case 2: // GCC won't compile P_BOTTOM
- SetToElement(arraycnt-1, p);
- break;
- }
-}
-
-
-/******************************************************************************
- * ListKey::increment - Increments a number of elements
- */
-
-void ListKey::increment(int step) {
- if (step < 0) {
- decrement(step*-1);
- return;
- }
- Error(); // clear error
- for(; step && !Error(); step--) {
- if (arraypos < arraycnt) {
- if (array[arraypos]->isBoundSet())
- (*(array[arraypos]))++;
- if ((array[arraypos]->Error()) || (!array[arraypos]->isBoundSet())) {
- SetToElement(arraypos+1);
- }
- else SWKey::setText((const char *)(*array[arraypos]));
- }
- else error = KEYERR_OUTOFBOUNDS;
- }
-}
-
-
-/******************************************************************************
- * ListKey::decrement - Decrements a number of elements
- */
-
-void ListKey::decrement(int step) {
- if (step < 0) {
- increment(step*-1);
- return;
- }
- Error(); // clear error
- for(; step && !Error(); step--) {
- if (arraypos > -1) {
- if (array[arraypos]->isBoundSet())
- (*(array[arraypos]))--;
- if ((array[arraypos]->Error()) || (!array[arraypos]->isBoundSet())) {
- SetToElement(arraypos-1, BOTTOM);
- }
- else SWKey::setText((const char *)(*array[arraypos]));
- }
- else error = KEYERR_OUTOFBOUNDS;
- }
-}
-
-
-/******************************************************************************
- * ListKey::Count - Returns number of elements in list
- */
-
-int ListKey::Count() {
- return arraycnt;
-}
-
-
-/******************************************************************************
- * ListKey::SetToElement - Sets key to element number
- *
- * ENT: ielement - element number to set to
- *
- * RET: error status
- */
-
-char ListKey::SetToElement(int ielement, SW_POSITION pos) {
- arraypos = ielement;
- if (arraypos >= arraycnt) {
- arraypos = (arraycnt>0)?arraycnt - 1:0;
- error = KEYERR_OUTOFBOUNDS;
- }
- else {
- if (arraypos < 0) {
- arraypos = 0;
- error = KEYERR_OUTOFBOUNDS;
- }
- else {
- error = 0;
- }
- }
-
- if (arraycnt) {
- if (array[arraypos]->isBoundSet())
- (*array[arraypos]) = pos;
- SWKey::setText((const char *)(*array[arraypos]));
- }
- else SWKey::setText("");
-
- return error;
-}
-
-
-/******************************************************************************
- * ListKey::GetElement - Gets a key element number
- *
- * ENT: pos - element number to get (or default current)
- *
- * RET: Key or null on error
- */
-
-SWKey *ListKey::getElement(int pos) {
- if (pos < 0)
- pos = arraypos;
-
- if (pos >=arraycnt)
- error = KEYERR_OUTOFBOUNDS;
-
- return (error) ? 0:array[pos];
-}
-
-
-/******************************************************************************
- * ListKey::Remove - Removes current element from list
- */
-
-void ListKey::Remove() {
- if ((arraypos > -1) && (arraypos < arraycnt)) {
- delete array[arraypos];
- if (arraypos < arraycnt - 1)
- memmove(&array[arraypos], &array[arraypos+1], (arraycnt - arraypos - 1) * sizeof(SWKey *));
- arraycnt--;
-
- SetToElement((arraypos)?arraypos-1:0);
- }
-}
-
-
-/******************************************************************************
- * ListKey::getRangeText - returns parsable range text for this key
- */
-
-const char *ListKey::getRangeText() const {
- char *buf = new char[(arraycnt + 1) * 255];
- buf[0] = 0;
- for (int i = 0; i < arraycnt; i++) {
- strcat(buf, array[i]->getRangeText());
- if (i < arraycnt-1)
- strcat(buf, "; ");
- }
- stdstr(&rangeText, buf);
- delete [] buf;
- return rangeText;
-}
-
-
-/******************************************************************************
- * ListKey::getText - returns text key if (const char *) cast is requested
- */
-
-const char *ListKey::getText() const {
- int pos = arraypos;
- SWKey *key = (pos >= arraycnt) ? 0:array[pos];
- return (key) ? key->getText() : keytext;
-}
-
-
-void ListKey::setText(const char *ikey) {
- // at least try to set the current element to this text
- int pos = arraypos;
- for (arraypos = 0; arraypos < arraycnt; arraypos++) {
- SWKey *key = array[arraypos];
- if (key) {
- key->setText(ikey);
- if (!key->Error())
- break;
- }
- }
- if (arraypos >= arraycnt) {
- error = 1;
- arraypos = arraycnt-1;
- }
-
- SWKey::setText(ikey);
-}
-
-SWORD_NAMESPACE_END
-
diff --git a/src/keys/nt.bks b/src/keys/nt.bks
deleted file mode 100644
index 6a3cf92..0000000
--- a/src/keys/nt.bks
+++ /dev/null
Binary files differ
diff --git a/src/keys/nt.cps b/src/keys/nt.cps
deleted file mode 100644
index fdaa6f4..0000000
--- a/src/keys/nt.cps
+++ /dev/null
Binary files differ
diff --git a/src/keys/ot.bks b/src/keys/ot.bks
deleted file mode 100644
index 512f064..0000000
--- a/src/keys/ot.bks
+++ /dev/null
Binary files differ
diff --git a/src/keys/ot.cps b/src/keys/ot.cps
deleted file mode 100644
index f4bf66b..0000000
--- a/src/keys/ot.cps
+++ /dev/null
Binary files differ
diff --git a/src/keys/strkey.cpp b/src/keys/strkey.cpp
deleted file mode 100644
index 587f185..0000000
--- a/src/keys/strkey.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/******************************************************************************
- * StrKey.cpp - code for class 'StrKey'- a standard string key class (used
- * for modules that index on single strings (eg. cities,
- * names, words, etc.)
- */
-
-#include <swmacs.h>
-#include <utilfuns.h>
-#include <strkey.h>
-#include <stdio.h>
-
-SWORD_NAMESPACE_START
-
-static const char *classes[] = {"StrKey", "SWKey", "SWObject", 0};
-SWClass StrKey::classdef(classes);
-
-/******************************************************************************
- * StrKey Constructor - initializes instance of StrKey
- *
- * ENT: ikey - text key (word, city, name, etc.)
- */
-
-StrKey::StrKey(const char *ikey) : SWKey(ikey)
-{
- init();
-}
-
-
-void StrKey::init() {
- myclass = &classdef;
-}
-
-
-/******************************************************************************
- * StrKey Destructor - cleans up instance of StrKey
- *
- * ENT: ikey - text key
- */
-
-StrKey::~StrKey() {
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/keys/swkey.cpp b/src/keys/swkey.cpp
deleted file mode 100644
index 994402f..0000000
--- a/src/keys/swkey.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/******************************************************************************
- * swkey.cpp - code for base class 'SWKey'. SWKey is the basis for all
- * types of keys for indexing into modules (e.g. verse, word,
- * place, etc.)
- */
-
-#include <swkey.h>
-#include <utilfuns.h>
-
-SWORD_NAMESPACE_START
-
-static const char *classes[] = {"SWKey", "SWObject", 0};
-SWClass SWKey::classdef(classes);
-
-/******************************************************************************
- * SWKey Constructor - initializes instance of SWKey
- *
- * ENT: ikey - text key
- */
-
-SWKey::SWKey(const char *ikey)
-{
- index = 0;
- persist = 0;
- keytext = 0;
- rangeText = 0;
- error = 0;
- userData = 0;
- stdstr(&keytext, ikey);
- init();
-}
-
-SWKey::SWKey(SWKey const &k)
-{
- index = k.index;
- persist = k.persist;
- userData = k.userData;
- keytext = 0;
- rangeText = 0;
- error = k.error;
- setText(k.getText());
- init();
-}
-
-void SWKey::init() {
- myclass = &classdef;
- boundSet = false;
-}
-
-SWKey *SWKey::clone() const
-{
- return new SWKey(*this);
-}
-
-/******************************************************************************
- * SWKey Destructor - cleans up instance of SWKey
- */
-
-SWKey::~SWKey() {
- if (keytext)
- delete [] keytext;
- if (rangeText)
- delete [] rangeText;
-}
-
-
-/******************************************************************************
- * SWKey::Persist - Gets whether this object itself persists within a
- * module that it was used to setKey or just a copy.
- * (1 - persists in module; 0 - a copy is attempted
- *
- * RET: value of persist
- */
-
-char SWKey::Persist() const
-{
- return persist;
-}
-
-
-/******************************************************************************
- * SWKey::Persist - Set/gets whether this object itself persists within a
- * module that it was used to setKey or just a copy.
- * (1 - persists in module; 0 - a copy is attempted
- *
- * ENT: ipersist - value which to set persist
- * [-1] - only get
- *
- * RET: value of persist
- */
-
-char SWKey::Persist(signed char ipersist)
-{
- if (ipersist != -1)
- persist = ipersist;
-
- return persist;
-}
-
-
-/******************************************************************************
- * SWKey::Error - Gets and clears error status
- *
- * RET: error status
- */
-
-char SWKey::Error()
-{
- char retval = error;
-
- error = 0;
- return retval;
-}
-
-
-/******************************************************************************
- * SWKey::setText Equates this SWKey to a character string
- *
- * ENT: ikey - other swkey object
- */
-
-void SWKey::setText(const char *ikey) {
- stdstr(&keytext, ikey);
-}
-
-
-/******************************************************************************
- * SWKey::copyFrom Equates this SWKey to another SWKey object
- *
- * ENT: ikey - other swkey object
- */
-
-void SWKey::copyFrom(const SWKey &ikey) {
-// not desirable Persist(ikey.Persist());
- setText((const char *)ikey);
-}
-
-
-/******************************************************************************
- * SWKey::getText - returns text key if (const char *) cast is requested
- */
-
-const char *SWKey::getText() const {
- return keytext;
-}
-
-
-/******************************************************************************
- * SWKey::getRangeText - returns parsable range text for this key
- */
-
-const char *SWKey::getRangeText() const {
- stdstr(&rangeText, keytext);
- return rangeText;
-}
-
-
-/******************************************************************************
- * SWKey::compare - Compares another VerseKey object
- *
- * ENT: ikey - key to compare with this one
- *
- * RET: > 0 if this key is greater than compare key
- * < 0
- * 0
- */
-
-int SWKey::compare(const SWKey &ikey)
-{
- return strcmp((const char *)*this, (const char *)ikey);
-}
-
-
-/******************************************************************************
- * SWKey::setPosition(SW_POSITION) - Positions this key if applicable
- */
-
-void SWKey::setPosition(SW_POSITION p) {
- switch (p) {
- case POS_TOP:
-// *this = "";
- break;
- case POS_BOTTOM:
-// *this = "zzzzzzzzz";
- break;
- }
-}
-
-
-/******************************************************************************
- * SWKey::increment - Increments key a number of entries
- *
- * ENT: increment - Number of entries to jump forward
- *
- * RET: *this
- */
-
-void SWKey::increment(int) {
- error = KEYERR_OUTOFBOUNDS;
-}
-
-
-/******************************************************************************
- * SWKey::decrement - Decrements key a number of entries
- *
- * ENT: decrement - Number of entries to jump backward
- *
- * RET: *this
- */
-
-void SWKey::decrement(int) {
- error = KEYERR_OUTOFBOUNDS;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/keys/treekey.cpp b/src/keys/treekey.cpp
deleted file mode 100644
index ce94775..0000000
--- a/src/keys/treekey.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/******************************************************************************
- * versekey.h - code for class 'versekey'- a standard Biblical verse key
- *
- * $Id: treekey.cpp,v 1.3 2002/10/01 19:52:40 dglassey Exp $
- *
- * Copyright 1998 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 <treekey.h>
-
-SWORD_NAMESPACE_START
-
-static const char *classes[] = {"TreeKey", "SWKey", "SWObject", 0};
-SWClass TreeKey::classdef(classes);
-
-void TreeKey::init() {
- myclass = &classdef;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/keys/treekeyidx.cpp b/src/keys/treekeyidx.cpp
deleted file mode 100644
index e8fb3f8..0000000
--- a/src/keys/treekeyidx.cpp
+++ /dev/null
@@ -1,600 +0,0 @@
-/******************************************************************************
- * versekey.h - code for class 'versekey'- a standard Biblical verse key
- *
- * $Id: treekeyidx.cpp,v 1.14 2003/06/27 01:41:07 scribe Exp $
- *
- * Copyright 1998 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 <treekeyidx.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <errno.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-SWORD_NAMESPACE_START
-
-static const char nl = '\n';
-static const char *classes[] = {"TreeKeyIdx", "TreeKey", "SWKey", "SWObject", 0};
-SWClass TreeKeyIdx::classdef(classes);
-
-
-TreeKeyIdx::TreeKeyIdx(const TreeKeyIdx &ikey) : currentNode() {
- init();
- path = 0;
- idxfd = 0;
- datfd = 0;
- copyFrom(ikey);
-}
-
-TreeKeyIdx::TreeKeyIdx(const char *idxPath, int fileMode) : currentNode() {
- char buf[127];
-
- init();
- path = 0;
- stdstr(&path, idxPath);
-
-#ifndef O_BINARY // O_BINARY is needed in Borland C++ 4.53
-#define O_BINARY 0 // If it hasn't been defined than we probably
-#endif // don't need it.
-
- if (fileMode == -1) { // try read/write if possible
- fileMode = O_RDWR;
- }
-
- sprintf(buf, "%s.idx", path);
- idxfd = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
- sprintf(buf, "%s.dat", path);
- datfd = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- if (datfd <= 0) {
- sprintf(buf, "Error: %d", errno);
- perror(buf);
- error = errno;
- }
- else {
- root();
- }
-}
-
-
-void TreeKeyIdx::init() {
- myclass = &classdef;
-}
-
-
-TreeKeyIdx::~TreeKeyIdx () {
- if (path)
- delete [] path;
-
- FileMgr::systemFileMgr.close(idxfd);
- FileMgr::systemFileMgr.close(datfd);
-}
-
-
-const char *TreeKeyIdx::getLocalName() {
- return currentNode.name;
-}
-
-
-const char *TreeKeyIdx::getUserData(int *size) {
- if (size)
- *size = (int)currentNode.dsize;
- return currentNode.userData;
-}
-
-
-void TreeKeyIdx::setUserData(const char *userData, int size) {
- if (currentNode.userData)
- delete currentNode.userData;
-
- if (!size)
- size = strlen(userData) + 1;
-
- currentNode.userData = new char [ size ];
- memcpy(currentNode.userData, userData, size);
- currentNode.dsize = size;
-}
-
-const char *TreeKeyIdx::setLocalName(const char *newName) {
- stdstr(&(currentNode.name), newName);
- return currentNode.name;
-}
-
-
-void TreeKeyIdx::save() {
- saveTreeNode(&currentNode);
-}
-
-
-const char *TreeKeyIdx::getFullName() const {
- TreeNode parent;
- static SWBuf fullPath;
- fullPath = currentNode.name;
- parent.parent = currentNode.parent;
- while (parent.parent > -1) {
- getTreeNodeFromIdxOffset(parent.parent, &parent);
- fullPath = ((SWBuf)parent.name) + (SWBuf) "/" + fullPath;
- }
- return fullPath.c_str();
-}
-
-
-void TreeKeyIdx::root() {
- error = getTreeNodeFromIdxOffset(0, &currentNode);
-}
-
-
-bool TreeKeyIdx::parent() {
- if (currentNode.parent > -1) {
- error = getTreeNodeFromIdxOffset(currentNode.parent, &currentNode);
- return true;
- }
- return false;
-}
-
-
-bool TreeKeyIdx::firstChild() {
- if (currentNode.firstChild > -1) {
- error = getTreeNodeFromIdxOffset(currentNode.firstChild, &currentNode);
- return true;
- }
- return false;
-}
-
-
-bool TreeKeyIdx::nextSibling() {
- if (currentNode.next > -1) {
- error = getTreeNodeFromIdxOffset(currentNode.next, &currentNode);
- return true;
- }
- return false;
-}
-
-
-bool TreeKeyIdx::previousSibling() {
- TreeNode iterator;
- __u32 target = currentNode.offset;
- if (currentNode.parent > -1) {
- getTreeNodeFromIdxOffset(currentNode.parent, &iterator);
- getTreeNodeFromIdxOffset(iterator.firstChild, &iterator);
- if (iterator.offset != target) {
- while ((iterator.next != target) && (iterator.next > -1))
- getTreeNodeFromIdxOffset(iterator.next, &iterator);
- if (iterator.next > -1) {
- error = getTreeNodeFromIdxOffset(iterator.offset, &currentNode);
- return true;
- }
- }
- }
- return false;
-}
-
-
-bool TreeKeyIdx::hasChildren() {
- return (currentNode.firstChild > -1);
-}
-
-
-void TreeKeyIdx::append() {
- TreeNode lastSib;
- if (currentNode.offset) {
- getTreeNodeFromIdxOffset(currentNode.offset, &lastSib);
- while (lastSib.next > -1) {
- getTreeNodeFromIdxOffset(lastSib.next, &lastSib);
- }
- __u32 idxOffset = lseek(idxfd->getFd(), 0, SEEK_END);
- lastSib.next = idxOffset;
- saveTreeNodeOffsets(&lastSib);
- __u32 parent = currentNode.parent;
- currentNode.clear();
- currentNode.offset = idxOffset;
- currentNode.parent = parent;
- }
-}
-
-
-void TreeKeyIdx::appendChild() {
- if (firstChild()) {
- append();
- }
- else {
- __u32 idxOffset = lseek(idxfd->getFd(), 0, SEEK_END);
- currentNode.firstChild = idxOffset;
- saveTreeNodeOffsets(&currentNode);
- __u32 parent = currentNode.offset;
- currentNode.clear();
- currentNode.offset = idxOffset;
- currentNode.parent = parent;
- }
-}
-
-
-void TreeKeyIdx::insertBefore() {
-}
-
-
-void TreeKeyIdx::remove() {
-}
-
-
-/******************************************************************************
- * TreeKeyIdx::Create - Creates new key idx/dat files
- *
- * ENT: path - directory to store module files
- * RET: error status
- */
-
-signed char TreeKeyIdx::create(const char *ipath) {
- char *path = 0;
- char *buf = new char [ strlen (ipath) + 20 ];
- FileDesc *fd, *fd2;
-
- stdstr(&path, ipath);
-
- if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\'))
- path[strlen(path)-1] = 0;
-
- sprintf(buf, "%s.dat", path);
- unlink(buf);
- fd = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd->getFd();
- FileMgr::systemFileMgr.close(fd);
-
- sprintf(buf, "%s.idx", path);
- unlink(buf);
- fd2 = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd2->getFd();
- FileMgr::systemFileMgr.close(fd2);
-
- TreeKeyIdx newTree(path);
- TreeKeyIdx::TreeNode root;
- stdstr(&(root.name), "");
- newTree.saveTreeNode(&root);
-
- delete [] path;
-
- return 0;
-}
-
-
-/******************************************************************************
- * zStr::getidxbufdat - Gets the index string at the given dat offset
- * NOTE: buf is calloc'd, or if not null, realloc'd and must
- * be free'd by calling function
- *
- * ENT: ioffset - offset in dat file to lookup
- * node - address of pointer to allocate for storage of string
- */
-
-void TreeKeyIdx::getTreeNodeFromDatOffset(long ioffset, TreeNode *node) const {
- char ch;
- __s32 tmp;
- __u16 tmp2;
-
- if (datfd > 0) {
-
- lseek(datfd->getFd(), ioffset, SEEK_SET);
-
- read(datfd->getFd(), &tmp, 4);
- node->parent = swordtoarch32(tmp);
-
- read(datfd->getFd(), &tmp, 4);
- node->next = swordtoarch32(tmp);
-
- read(datfd->getFd(), &tmp, 4);
- node->firstChild = swordtoarch32(tmp);
-
- SWBuf name;
- do {
- read(datfd->getFd(), &ch, 1);
- name += ch;
- } while (ch);
-
- stdstr(&(node->name), name.c_str());
-
- read(datfd->getFd(), &tmp2, 2);
- node->dsize = swordtoarch16(tmp2);
-
- if (node->dsize) {
- if (node->userData)
- delete [] node->userData;
- node->userData = new char [node->dsize];
- read(datfd->getFd(), node->userData, node->dsize);
- }
- }
-}
-
-
-/******************************************************************************
- * zStr::getidxbuf - Gets the index string at the given idx offset
- * NOTE: buf is calloc'd, or if not null, realloc'd
- * and must be freed by calling function
- *
- * ENT: ioffset - offset in idx file to lookup
- * buf - address of pointer to allocate for storage of string
- */
-
-char TreeKeyIdx::getTreeNodeFromIdxOffset(long ioffset, TreeNode *node) const {
- __u32 offset;
- char error = KEYERR_OUTOFBOUNDS;
-
- if (ioffset < 0) {
- ioffset = 0;
- error = 77; // out of bounds but still position to 0;
- }
-
- node->offset = ioffset;
- if (idxfd > 0) {
- if (idxfd->getFd() > 0) {
- lseek(idxfd->getFd(), ioffset, SEEK_SET);
- if (read(idxfd->getFd(), &offset, 4) == 4) {
- offset = swordtoarch32(offset);
- error = (error == 77) ? KEYERR_OUTOFBOUNDS : 0;
- getTreeNodeFromDatOffset(offset, node);
- }
- else {
- lseek(idxfd->getFd(), -4, SEEK_END);
- if (read(idxfd->getFd(), &offset, 4) == 4) {
- offset = swordtoarch32(offset);
- getTreeNodeFromDatOffset(offset, node);
- }
- }
- }
- }
- return error;
-}
-
-
-unsigned long TreeKeyIdx::getOffset() const {
- return currentNode.offset;
-}
-
-void TreeKeyIdx::setOffset(unsigned long offset) {
- error = getTreeNodeFromIdxOffset(offset, &currentNode);
-}
-
-
-void TreeKeyIdx::saveTreeNodeOffsets(TreeNode *node) {
- long datOffset = 0;
- __s32 tmp;
-
- if (idxfd > 0) {
- lseek(idxfd->getFd(), node->offset, SEEK_SET);
- if (read(idxfd->getFd(), &tmp, 4) != 4) {
- datOffset = lseek(datfd->getFd(), 0, SEEK_END);
- tmp = archtosword32(datOffset);
- write(idxfd->getFd(), &tmp, 4);
- }
- else {
- datOffset = swordtoarch32(tmp);
- lseek(datfd->getFd(), datOffset, SEEK_SET);
- }
-
- tmp = archtosword32(node->parent);
- write(datfd->getFd(), &tmp, 4);
-
- tmp = archtosword32(node->next);
- write(datfd->getFd(), &tmp, 4);
-
- tmp = archtosword32(node->firstChild);
- write(datfd->getFd(), &tmp, 4);
- }
-}
-
-
-void TreeKeyIdx::copyFrom(const TreeKeyIdx &ikey) {
-
- SWKey::copyFrom(ikey);
-
- currentNode.offset = ikey.currentNode.offset;
- currentNode.parent = ikey.currentNode.parent;
- currentNode.next = ikey.currentNode.next;
- currentNode.firstChild = ikey.currentNode.firstChild;
- stdstr(&(currentNode.name), ikey.currentNode.name);
- currentNode.dsize = ikey.currentNode.dsize;
-
- if (currentNode.userData)
- delete [] currentNode.userData;
- if (currentNode.dsize) {
- currentNode.userData = new char [ currentNode.dsize ];
- memcpy(currentNode.userData, ikey.currentNode.userData, currentNode.dsize);
- }
- else currentNode.userData = 0;
-
- bool newFiles = true;
-
- if (path && ikey.path)
- newFiles = strcmp(path, ikey.path);
-
- if (newFiles) {
- stdstr(&path, ikey.path);
-
- if (idxfd) {
- FileMgr::systemFileMgr.close(idxfd);
- FileMgr::systemFileMgr.close(datfd);
- }
- idxfd = FileMgr::systemFileMgr.open(ikey.idxfd->path, ikey.idxfd->mode, ikey.idxfd->perms);
- datfd = FileMgr::systemFileMgr.open(ikey.datfd->path, ikey.datfd->mode, ikey.datfd->perms);
- }
-}
-
-
-void TreeKeyIdx::saveTreeNode(TreeNode *node) {
- long datOffset = 0;
- __s32 tmp;
- if (idxfd > 0) {
-
- lseek(idxfd->getFd(), node->offset, SEEK_SET);
- datOffset = lseek(datfd->getFd(), 0, SEEK_END);
- tmp = archtosword32(datOffset);
- write(idxfd->getFd(), &tmp, 4);
-
- saveTreeNodeOffsets(node);
-
- write(datfd->getFd(), node->name, strlen(node->name));
- char null = 0;
- write(datfd->getFd(), &null, 1);
-
- __u16 tmp2 = archtosword16(node->dsize);
- write(datfd->getFd(), &tmp2, 2);
-
- if (node->dsize) {
- write(datfd->getFd(), node->userData, node->dsize);
- }
- }
-}
-
-
-void TreeKeyIdx::setText(const char *ikey) {
- char *buf = 0;
- stdstr(&buf, ikey);
- char *leaf = strtok(buf, "/");
- root();
- while ((leaf) && (!Error())) {
- bool ok, inChild = false;
- for (ok = firstChild(); ok; ok = nextSibling()) {
- inChild = true;
- if (!stricmp(leaf, getLocalName()))
- break;
- }
- leaf = strtok(0, "/");
- if (!ok) {
- if (inChild) { // if we didn't find a matching child node, default to first child
- parent();
- firstChild();
- }
- if (leaf)
- error = KEYERR_OUTOFBOUNDS;
- break;
- }
- }
- delete [] buf;
-}
-
-
-
-void TreeKeyIdx::copyFrom(const SWKey &ikey) {
- SWKey::copyFrom(ikey);
-}
-
-void TreeKeyIdx::setPosition(SW_POSITION p) {
- switch (p) {
- case POS_TOP:
- root();
- break;
- case POS_BOTTOM:
- error = getTreeNodeFromIdxOffset(lseek(idxfd->getFd(), -4, SEEK_END), &currentNode);
- break;
- }
- Error(); // clear error from normalize
-}
-
-const char *TreeKeyIdx::getText() const {
- return getFullName();
-}
-
-
-int TreeKeyIdx::_compare (const TreeKeyIdx & ikey) {
- return (getOffset() - ikey.getOffset());
-}
-
-
-int TreeKeyIdx::compare(const SWKey &ikey) {
- TreeKeyIdx *treeKey = SWDYNAMIC_CAST(TreeKeyIdx, (&ikey));
- if (treeKey)
- return _compare(*treeKey);
- return SWKey::compare(ikey);
-}
-
-
-void TreeKeyIdx::decrement(int steps) {
- error = getTreeNodeFromIdxOffset(currentNode.offset - (4*steps), &currentNode);
-}
-
-void TreeKeyIdx::increment(int steps) {
- error = getTreeNodeFromIdxOffset(currentNode.offset + (4*steps), &currentNode);
-
-/*
- // assert positive
- if (steps < 0) {
- decrement(steps * -1);
- return;
- }
-
- while (steps > 0) {
- if (!firstChild()) {
- if (!nextSibbling() {
- error = KEYERR_OUTOFBOUNDS;
- return;
- }
- }
- steps--;
- }
-*/
-}
-
-
-
-TreeKeyIdx::TreeNode::TreeNode() {
-
- name = 0;
- stdstr(&name, "");
- userData = 0;
-
- clear();
-}
-
-
-void TreeKeyIdx::TreeNode::clear() {
- offset = 0;
- parent = -1;
- next = -1;
- firstChild = -1;
- dsize = 0;
-
- if (name)
- delete [] name;
- name = 0;
- stdstr(&name, "");
-
- if (userData)
- delete [] userData;
- userData = 0;
-}
-
-
-TreeKeyIdx::TreeNode::~TreeNode() {
- if (name)
- delete [] name;
-
- if (userData)
- delete [] userData;
-}
-
-
-SWKey *TreeKeyIdx::clone() const
-{
- return new TreeKeyIdx(*this);
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/keys/versekey.cpp b/src/keys/versekey.cpp
deleted file mode 100644
index b2f78e3..0000000
--- a/src/keys/versekey.cpp
+++ /dev/null
@@ -1,1523 +0,0 @@
-/******************************************************************************
- * VerseKey.cpp - code for class 'VerseKey'- a standard Biblical verse key
- */
-
-#include <swmacs.h>
-#include <utilfuns.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <stdlib.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#include <utilstr.h>
-#include <swkey.h>
-#include <swlog.h>
-#include <versekey.h>
-#include <localemgr.h>
-#include <roman.h>
-
-SWORD_NAMESPACE_START
-
-static const char *classes[] = {"VerseKey", "SWKey", "SWObject", 0};
-SWClass VerseKey::classdef(classes);
-
-/******************************************************************************
- * Initialize static members of VerseKey
- */
-
-#include <canon.h> // Initialize static members of canonical books structure
-
-struct sbook *VerseKey::builtin_books[2] = {0,0};
-const char VerseKey::builtin_BMAX[2] = {39, 27};
-long *VerseKey::offsets[2][2] = {{VerseKey::otbks, VerseKey::otcps}, {VerseKey::ntbks, VerseKey::ntcps}};
-int VerseKey::instance = 0;
-VerseKey::LocaleCache VerseKey::localeCache;
-
-
-/******************************************************************************
- * VerseKey::init - initializes instance of VerseKey
- */
-
-void VerseKey::init() {
- myclass = &classdef;
- if (!instance)
- initstatics();
-
- instance++;
- autonorm = 1; // default auto normalization to true
- headings = 0; // default display headings option is false
- upperBound = 0;
- lowerBound = 0;
- boundSet = false;
- testament = 0;
- book = 0;
- chapter = 0;
- verse = 0;
- locale = 0;
-
- setLocale(LocaleMgr::systemLocaleMgr.getDefaultLocaleName());
-}
-
-/******************************************************************************
- * VerseKey Constructor - initializes instance of VerseKey
- *
- * ENT: ikey - base key (will take various forms of 'BOOK CH:VS'. See
- * VerseKey::parse for more detailed information)
- */
-
-VerseKey::VerseKey(const SWKey *ikey) : SWKey(*ikey)
-{
- init();
- if (ikey)
- parse();
-}
-
-
-/******************************************************************************
- * VerseKey Constructor - initializes instance of VerseKey
- *
- * ENT: ikey - text key (will take various forms of 'BOOK CH:VS'. See
- * VerseKey::parse for more detailed information)
- */
-
-VerseKey::VerseKey(const char *ikey) : SWKey(ikey)
-{
- init();
- if (ikey)
- parse();
-}
-
-
-VerseKey::VerseKey(VerseKey const &k) : SWKey(k)
-{
- init();
- autonorm = k.autonorm;
- headings = k.headings;
- testament = k.Testament();
- book = k.Book();
- chapter = k.Chapter();
- verse = k.Verse();
- if (k.isBoundSet()) {
- LowerBound(k.LowerBound());
- UpperBound(k.UpperBound());
- }
-}
-
-
-VerseKey::VerseKey(const char *min, const char *max) : SWKey()
-{
- init();
- LowerBound(min);
- UpperBound(max);
- setPosition(TOP);
-}
-
-
-SWKey *VerseKey::clone() const
-{
- return new VerseKey(*this);
-}
-
-
-/******************************************************************************
- * VerseKey Destructor - cleans up instance of VerseKey
- *
- * ENT: ikey - text key
- */
-
-VerseKey::~VerseKey() {
- if (upperBound)
- delete upperBound;
- if (lowerBound)
- delete lowerBound;
- if (locale)
- delete [] locale;
-
- --instance;
-}
-
-
-void VerseKey::setLocale(const char *name) {
- char *BMAX;
- struct sbook **books;
- bool useCache = false;
-
- if (localeCache.name)
- useCache = (!strcmp(localeCache.name, name));
-
- if (!useCache) { // if we're setting params for a new locale
- stdstr(&(localeCache.name), name);
- localeCache.abbrevsCnt = 0;
- }
-
- SWLocale *locale = (useCache) ? localeCache.locale : LocaleMgr::systemLocaleMgr.getLocale(name);
- localeCache.locale = locale;
-
- if (locale) {
- locale->getBooks(&BMAX, &books);
- setBooks(BMAX, books);
- setBookAbbrevs(locale->getBookAbbrevs(), localeCache.abbrevsCnt);
- localeCache.abbrevsCnt = abbrevsCnt;
- }
- else {
- setBooks(builtin_BMAX, builtin_books);
- setBookAbbrevs(builtin_abbrevs, localeCache.abbrevsCnt);
- localeCache.abbrevsCnt = abbrevsCnt;
- }
- stdstr(&(this->locale), localeCache.name);
-
- if (lowerBound)
- LowerBound().setLocale(name);
- if (upperBound)
- UpperBound().setLocale(name);
-}
-
-void VerseKey::setBooks(const char *iBMAX, struct sbook **ibooks) {
- BMAX = iBMAX;
- books = ibooks;
-}
-
-
-void VerseKey::setBookAbbrevs(const struct abbrev *bookAbbrevs, unsigned int size) {
- abbrevs = bookAbbrevs;
- if (!size) {
- for (abbrevsCnt = 0; *abbrevs[abbrevsCnt].ab; abbrevsCnt++) {
- /*
- if (strcmp(abbrevs[abbrevsCnt-1].ab, abbrevs[abbrevsCnt].ab) > 0) {
- fprintf(stderr, "ERROR: book abbreviation (canon.h or locale) misordered at entry: %s\n", abbrevs[abbrevsCnt].ab);
- exit(-1);
- }
- */
- }
- for (int t = 0; t < 2; t++) {
- for (int i = 0; i < BMAX[t]; i++) {
- int bn = getBookAbbrev(books[t][i].name);
- if ((bn-1)%39 != i) {
- SWLog::systemlog->LogError("Book: %s does not have a matching toupper abbrevs entry! book number returned was: %d", books[t][i].name, bn);
- }
- }
- }
- }
- else abbrevsCnt = size;
-}
-
-
-/******************************************************************************
- * VerseKey::initstatics - initializes statics. Performed only when first
- * instance on VerseKey (or descendent) is created.
- */
-
-void VerseKey::initstatics() {
- int l1, l2, chaptmp = 0;
-
- builtin_books[0] = otbooks;
- builtin_books[1] = ntbooks;
-
- for (l1 = 0; l1 < 2; l1++) {
- for (l2 = 0; l2 < builtin_BMAX[l1]; l2++) {
- builtin_books[l1][l2].versemax = &vm[chaptmp];
- chaptmp += builtin_books[l1][l2].chapmax;
- }
- }
-}
-
-
-/******************************************************************************
- * VerseKey::parse - parses keytext into testament|book|chapter|verse
- *
- * RET: error status
- */
-
-char VerseKey::parse()
-{
-
-
- testament = 2;
- book = BMAX[1];
- chapter = 1;
- verse = 1;
- int booklen = 0;
-
- int error = 0;
-
- if (keytext) {
- ListKey tmpListKey = VerseKey::ParseVerseList(keytext);
- if (tmpListKey.Count()) {
- SWKey::setText((const char *)tmpListKey);
- for (int i = 1; i < 3; i++) {
- for (int j = 1; j <= BMAX[i-1]; j++) {
- int matchlen = strlen(books[i-1][j-1].name);
- if (!strncmp(keytext, books[i-1][j-1].name, matchlen)) {
- if (matchlen > booklen) {
- booklen = matchlen;
- testament = i;
- book = j;
- }
- }
- }
- }
-
- if (booklen) {
- sscanf(&keytext[booklen], "%d:%d", &chapter, &verse);
- }
- else error = 1;
- } else error = 1;
- }
- Normalize(1);
- freshtext();
-
- return (this->error) ? this->error : (this->error = error);
-}
-
-
-/******************************************************************************
- * VerseKey::freshtext - refreshes keytext based on
- * testament|book|chapter|verse
- */
-
-void VerseKey::freshtext() const
-{
- char buf[2024];
- int realtest = testament;
- int realbook = book;
-
- if (book < 1) {
- if (testament < 1)
- sprintf(buf, "[ Module Heading ]");
- else sprintf(buf, "[ Testament %d Heading ]", (int)testament);
- }
- else {
- if (realbook > BMAX[realtest-1]) {
- realbook -= BMAX[realtest-1];
- if (realtest < 2)
- realtest++;
- if (realbook > BMAX[realtest-1])
- realbook = BMAX[realtest-1];
- }
- sprintf(buf, "%s %d:%d", books[realtest-1][realbook-1].name, chapter, verse);
- }
-
- stdstr((char **)&keytext, buf);
-}
-
-
-
-/******************************************************************************
- * VerseKey::getBookAbbrev - Attempts to find a book abbreviation for a buffer
- *
- * ENT: abbr - key for which to search;
- * RET: book number or < 0 = not valid
- */
-
-int VerseKey::getBookAbbrev(const char *iabbr)
-{
- int loop, diff, abLen, min, max, target, retVal = -1;
-
- char *abbr = 0;
-
- for (int i = 0; i < 2; i++) {
- stdstr(&abbr, iabbr);
- strstrip(abbr);
- if (!i)
- toupperstr(abbr);
- abLen = strlen(abbr);
-
- if (abLen) {
- min = 0;
-// max = abbrevsCnt - 1;
- max = abbrevsCnt;
- while(1) {
- target = min + ((max - min) / 2);
- diff = strncmp(abbr, abbrevs[target].ab, abLen);
- if ((!diff)||(target >= max)||(target <= min))
- break;
- if (diff > 0)
- min = target;
- else max = target;
- }
- for (; target > 0; target--) {
- if (strncmp(abbr, abbrevs[target-1].ab, abLen))
- break;
- }
-
- retVal = (!diff) ? abbrevs[target].book : -1;
- }
- if (retVal > 0)
- break;
- }
- delete [] abbr;
- return retVal;
-}
-
-/******************************************************************************
- * VerseKey::ParseVerseList - Attempts to parse a buffer into separate
- * verse entries returned in a ListKey
- *
- * ENT: buf - buffer to parse;
- * defaultKey - if verse, chap, book, or testament is left off,
- * pull info from this key (ie. Gen 2:3; 4:5;
- * Gen would be used when parsing the 4:5 section)
- * expandRange - whether or not to expand eg. John 1:10-12 or just
- * save John 1:10
- *
- * RET: ListKey reference filled with verse entries contained in buf
- *
- * COMMENT: This code works but wreaks. Rewrite to make more maintainable.
- */
-
-ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool expandRange) {
- SWKey textkey;
-
- char book[2048];
- char number[2048];
- int tobook = 0;
- int tonumber = 0;
- int chap = -1, verse = -1;
- int bookno = 0;
- VerseKey curkey, lBound;
- curkey.setLocale(getLocale());
- lBound.setLocale(getLocale());
- int loop;
- char comma = 0;
- char dash = 0;
- const char *orig = buf;
- int q;
- ListKey tmpListKey;
- ListKey internalListKey;
- SWKey tmpDefaultKey = defaultKey;
- char lastPartial = 0;
- bool inTerm = true;
- int notAllDigits;
-
- curkey.AutoNormalize(0);
- tmpListKey << tmpDefaultKey;
- tmpListKey.GetElement()->userData = (void *)buf;
-
- while (*buf) {
- switch (*buf) {
- case ':':
- number[tonumber] = 0;
- tonumber = 0;
- if (*number)
- chap = atoi(number);
- *number = 0;
- break;
-
- case ' ':
- inTerm = true;
- while (true) {
- if ((!*number) || (chap < 0))
- break;
- for (q = 1; ((buf[q]) && (buf[q] != ' ')); q++);
- if (buf[q] == ':')
- break;
- inTerm = false;
- break;
- }
- if (inTerm) {
- book[tobook++] = ' ';
- break;
- }
- case '-':
- case ',': // on number new verse
- case ';': // on number new chapter
- number[tonumber] = 0;
- tonumber = 0;
- if (*number) {
- if (chap >= 0)
- verse = atoi(number);
- else chap = atoi(number);
- }
- *number = 0;
- book[tobook] = 0;
- tobook = 0;
- bookno = -1;
- if (*book) {
- for (loop = strlen(book) - 1; loop+1; loop--) {
- if ((isdigit(book[loop])) || (book[loop] == ' ')) {
- book[loop] = 0;
- continue;
- }
- else {
- if ((SW_toupper(book[loop])=='F')&&(loop)) {
- if ((isdigit(book[loop-1])) || (book[loop-1] == ' ') || (SW_toupper(book[loop-1]) == 'F')) {
- book[loop] = 0;
- continue;
- }
- }
- }
- break;
- }
-
- for (loop = strlen(book) - 1; loop+1; loop--) {
- if (book[loop] == ' ') {
- if (isroman(&book[loop+1])) {
- if (verse == -1) {
- verse = chap;
- chap = from_rom(&book[loop+1]);
- book[loop] = 0;
- }
- }
- break;
- }
- }
-
- if ((!stricmp(book, "V")) || (!stricmp(book, "VER"))) { // Verse abbrev
- if (verse == -1) {
- verse = chap;
- chap = VerseKey(tmpListKey).Chapter();
- *book = 0;
- }
- }
- if ((!stricmp(book, "ch")) || (!stricmp(book, "chap"))) { // Verse abbrev
- strcpy(book, VerseKey(tmpListKey).getBookName());
- }
- bookno = getBookAbbrev(book);
- }
- if (((bookno > -1) || (!*book)) && ((*book) || (chap >= 0) || (verse >= 0))) {
- char partial = 0;
- curkey.Verse(1);
- curkey.Chapter(1);
- curkey.Book(1);
-
- if (bookno < 0) {
- curkey.Testament(VerseKey(tmpListKey).Testament());
- curkey.Book(VerseKey(tmpListKey).Book());
- }
- else {
- curkey.Testament(1);
- curkey.Book(bookno);
- }
-
- if (((comma)||((verse < 0)&&(bookno < 0)))&&(!lastPartial)) {
-// if (comma) {
- curkey.Chapter(VerseKey(tmpListKey).Chapter());
- curkey.Verse(chap); // chap because this is the first number captured
- }
- else {
- if (chap >= 0) {
- curkey.Chapter(chap);
- }
- else {
- partial++;
- curkey.Chapter(1);
- }
- if (verse >= 0) {
- curkey.Verse(verse);
- }
- else {
- partial++;
- curkey.Verse(1);
- }
- }
-
- if ((*buf == '-') && (expandRange)) { // if this is a dash save lowerBound and wait for upper
- VerseKey newElement;
- newElement.LowerBound(curkey);
- newElement.setPosition(TOP);
- tmpListKey << newElement;
- tmpListKey.GetElement()->userData = (void *)buf;
- }
- else {
- if (!dash) { // if last separator was not a dash just add
- if (expandRange && partial) {
- VerseKey newElement;
- newElement.LowerBound(curkey);
- if (partial > 1)
- curkey.setPosition(MAXCHAPTER);
- if (partial > 0)
- curkey = MAXVERSE;
- newElement.UpperBound(curkey);
- newElement = TOP;
- tmpListKey << newElement;
- tmpListKey.GetElement()->userData = (void *)buf;
- }
- else {
- tmpListKey << (const SWKey &)(const SWKey)(const char *)curkey;
- tmpListKey.GetElement()->userData = (void *)buf;
- }
- }
- else if (expandRange) {
- VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.GetElement());
- if (newElement) {
- if (partial > 1)
- curkey = MAXCHAPTER;
- if (partial > 0)
- curkey = MAXVERSE;
- newElement->UpperBound(curkey);
- *newElement = TOP;
- tmpListKey.GetElement()->userData = (void *)buf;
- }
- }
- }
- lastPartial = partial;
- }
- *book = 0;
- chap = -1;
- verse = -1;
- if (*buf == ',')
- comma = 1;
- else comma = 0;
- if (*buf == '-')
- dash = 1;
- else dash = 0;
- break;
- case 10: // ignore these
- case 13:
- case '[':
- case ']':
- case '(':
- case ')':
- break;
- case '.':
- if (buf > orig) // ignore (break) if preceeding char is not a digit
- for (notAllDigits = tobook; notAllDigits; notAllDigits--) {
- if ((!isdigit(book[notAllDigits-1])) && (!strchr(" .", book[notAllDigits-1])))
- break;
- }
- if (!notAllDigits)
- break;
-
- number[tonumber] = 0;
- tonumber = 0;
- if (*number)
- chap = atoi(number);
- *number = 0;
- break;
-
- default:
- if (isdigit(*buf)) {
- number[tonumber++] = *buf;
- }
- else {
- switch (*buf) {
- case ' ': // ignore these and don't reset number
- case 'f':
- case 'F':
- break;
- default:
- number[tonumber] = 0;
- tonumber = 0;
- break;
- }
- }
- if (chap == -1)
- book[tobook++] = *buf;
- }
- buf++;
- }
- number[tonumber] = 0;
- tonumber = 0;
- if (*number) {
- if (chap >= 0)
- verse = atoi(number);
- else chap = atoi(number);
- }
- *number = 0;
- book[tobook] = 0;
- tobook = 0;
- if (*book) {
- for (loop = strlen(book) - 1; loop+1; loop--) {
- if ((isdigit(book[loop])) || (book[loop] == ' ')) {
- book[loop] = 0;
- continue;
- }
- else {
- if ((SW_toupper(book[loop])=='F')&&(loop)) {
- if ((isdigit(book[loop-1])) || (book[loop-1] == ' ') || (SW_toupper(book[loop-1]) == 'F')) {
- book[loop] = 0;
- continue;
- }
- }
- }
- break;
- }
-
- for (loop = strlen(book) - 1; loop+1; loop--) {
- if (book[loop] == ' ') {
- if (isroman(&book[loop+1])) {
- if (verse == -1) {
- verse = chap;
- chap = from_rom(&book[loop+1]);
- book[loop] = 0;
- }
- }
- break;
- }
- }
-
- if ((!stricmp(book, "V")) || (!stricmp(book, "VER"))) { // Verse abbrev.
- if (verse == -1) {
- verse = chap;
- chap = VerseKey(tmpListKey).Chapter();
- *book = 0;
- }
- }
-
- if ((!stricmp(book, "ch")) || (!stricmp(book, "chap"))) { // Verse abbrev
- strcpy(book, VerseKey(tmpListKey).getBookName());
- }
- bookno = getBookAbbrev(book);
- }
- if (((bookno > -1) || (!*book)) && ((*book) || (chap >= 0) || (verse >= 0))) {
- char partial = 0;
- curkey.Verse(1);
- curkey.Chapter(1);
- curkey.Book(1);
-
- if (bookno < 0) {
- curkey.Testament(VerseKey(tmpListKey).Testament());
- curkey.Book(VerseKey(tmpListKey).Book());
- }
- else {
- curkey.Testament(1);
- curkey.Book(bookno);
- }
-
- if (((comma)||((verse < 0)&&(bookno < 0)))&&(!lastPartial)) {
-// if (comma) {
- curkey.Chapter(VerseKey(tmpListKey).Chapter());
- curkey.Verse(chap); // chap because this is the first number captured
- }
- else {
- if (chap >= 0) {
- curkey.Chapter(chap);
- }
- else {
- partial++;
- curkey.Chapter(1);
- }
- if (verse >= 0) {
- curkey.Verse(verse);
- }
- else {
- partial++;
- curkey.Verse(1);
- }
- }
-
- if ((*buf == '-') && (expandRange)) { // if this is a dash save lowerBound and wait for upper
- VerseKey newElement;
- newElement.LowerBound(curkey);
- newElement = TOP;
- tmpListKey << newElement;
- tmpListKey.GetElement()->userData = (void *)buf;
- }
- else {
- if (!dash) { // if last separator was not a dash just add
- if (expandRange && partial) {
- VerseKey newElement;
- newElement.LowerBound(curkey);
- if (partial > 1)
- curkey = MAXCHAPTER;
- if (partial > 0)
- curkey = MAXVERSE;
- newElement.UpperBound(curkey);
- newElement = TOP;
- tmpListKey << newElement;
- tmpListKey.GetElement()->userData = (void *)buf;
- }
- else {
- tmpListKey << (const SWKey &)(const SWKey)(const char *)curkey;
- tmpListKey.GetElement()->userData = (void *)buf;
- }
- }
- else if (expandRange) {
- VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.GetElement());
- if (newElement) {
- if (partial > 1)
- curkey = MAXCHAPTER;
- if (partial > 0)
- curkey = MAXVERSE;
- newElement->UpperBound(curkey);
- *newElement = TOP;
- tmpListKey.GetElement()->userData = (void *)buf;
- }
- }
- }
- }
- *book = 0;
- tmpListKey = TOP;
- tmpListKey.Remove(); // remove defaultKey
- internalListKey = tmpListKey;
- internalListKey = TOP; // Align internalListKey to first element before passing back;
-
- return internalListKey;
-}
-
-
-/******************************************************************************
- * VerseKey::LowerBound - sets / gets the lower boundary for this key
- */
-
-VerseKey &VerseKey::LowerBound(const char *lb)
-{
- if (!lowerBound)
- initBounds();
-
- (*lowerBound) = lb;
- lowerBound->Normalize();
- lowerBound->setLocale( this->getLocale() );
- boundSet = true;
- return (*lowerBound);
-}
-
-
-/******************************************************************************
- * VerseKey::UpperBound - sets / gets the upper boundary for this key
- */
-
-VerseKey &VerseKey::UpperBound(const char *ub)
-{
- if (!upperBound)
- initBounds();
-
-// need to set upperbound parsing to resolve to max verse/chap if not specified
- (*upperBound) = ub;
- if (*upperBound < *lowerBound)
- *upperBound = *lowerBound;
- upperBound->Normalize();
- upperBound->setLocale( this->getLocale() );
-
-// until we have a proper method to resolve max verse/chap use this kludge
- int len = strlen(ub);
- bool alpha = false;
- bool versespec = false;
- bool chapspec = false;
- for (int i = 0; i < len; i++) {
- if (isalpha(ub[i]))
- alpha = true;
- if (ub[i] == ':') // if we have a : we assume verse spec
- versespec = true;
- if ((isdigit(ub[i])) && (alpha)) // if digit after alpha assume chap spec
- chapspec = true;
- }
- if (!chapspec)
- *upperBound = MAXCHAPTER;
- if (!versespec)
- *upperBound = MAXVERSE;
-
-
-// -- end kludge
- boundSet = true;
- return (*upperBound);
-}
-
-
-/******************************************************************************
- * VerseKey::LowerBound - sets / gets the lower boundary for this key
- */
-
-VerseKey &VerseKey::LowerBound() const
-{
- if (!lowerBound)
- initBounds();
-
- return (*lowerBound);
-}
-
-
-/******************************************************************************
- * VerseKey::UpperBound - sets / gets the upper boundary for this key
- */
-
-VerseKey &VerseKey::UpperBound() const
-{
- if (!upperBound)
- initBounds();
-
- return (*upperBound);
-}
-
-
-/******************************************************************************
- * VerseKey::ClearBounds - clears bounds for this VerseKey
- */
-
-void VerseKey::ClearBounds()
-{
- initBounds();
-}
-
-
-void VerseKey::initBounds() const
-{
- if (!upperBound) {
- upperBound = new VerseKey();
- upperBound->AutoNormalize(0);
- upperBound->Headings(1);
- }
- if (!lowerBound) {
- lowerBound = new VerseKey();
- lowerBound->AutoNormalize(0);
- lowerBound->Headings(1);
- }
-
- lowerBound->Testament(0);
- lowerBound->Book(0);
- lowerBound->Chapter(0);
- lowerBound->Verse(0);
-
- upperBound->Testament(2);
- upperBound->Book(BMAX[1]);
- upperBound->Chapter(books[1][BMAX[1]-1].chapmax);
- upperBound->Verse(books[1][BMAX[1]-1].versemax[upperBound->Chapter()-1]);
- boundSet = false;
-}
-
-
-/******************************************************************************
- * VerseKey::copyFrom - Equates this VerseKey to another VerseKey
- */
-
-void VerseKey::copyFrom(const VerseKey &ikey) {
- SWKey::copyFrom(ikey);
-
- parse();
-}
-
-
-/******************************************************************************
- * VerseKey::copyFrom - Equates this VerseKey to another SWKey
- */
-
-void VerseKey::copyFrom(const SWKey &ikey) {
- SWKey::copyFrom(ikey);
-
- parse();
-}
-
-
-/******************************************************************************
- * VerseKey::getText - refreshes keytext before returning if cast to
- * a (char *) is requested
- */
-
-const char *VerseKey::getText() const {
- freshtext();
- return keytext;
-}
-
-
-const char *VerseKey::getShortText() const {
- static char *stext = 0;
- char buf[2047];
- freshtext();
- if (book < 1) {
- if (testament < 1)
- sprintf(buf, "[ Module Heading ]");
- else sprintf(buf, "[ Testament %d Heading ]", (int)testament);
- }
- else {
- sprintf(buf, "%s %d:%d", books[testament-1][book-1].prefAbbrev, chapter, verse);
- }
- stdstr(&stext, buf);
- return stext;
-}
-
-
-const char *VerseKey::getBookName() const {
- return books[testament-1][book-1].name;
-}
-
-
-const char *VerseKey::getBookAbbrev() const {
- return books[testament-1][book-1].prefAbbrev;
-}
-/******************************************************************************
- * VerseKey::setPosition(SW_POSITION) - Positions this key
- *
- * ENT: p - position
- *
- * RET: *this
- */
-
-void VerseKey::setPosition(SW_POSITION p) {
- switch (p) {
- case POS_TOP:
- testament = LowerBound().Testament();
- book = LowerBound().Book();
- chapter = LowerBound().Chapter();
- verse = LowerBound().Verse();
- break;
- case POS_BOTTOM:
- testament = UpperBound().Testament();
- book = UpperBound().Book();
- chapter = UpperBound().Chapter();
- verse = UpperBound().Verse();
- break;
- case POS_MAXVERSE:
- Normalize();
- verse = books[testament-1][book-1].versemax[chapter-1];
- break;
- case POS_MAXCHAPTER:
- verse = 1;
- Normalize();
- chapter = books[testament-1][book-1].chapmax;
- break;
- }
- Normalize(1);
- Error(); // clear error from normalize
-}
-
-
-/******************************************************************************
- * VerseKey::increment - Increments key a number of verses
- *
- * ENT: step - Number of verses to jump forward
- *
- * RET: *this
- */
-
-void VerseKey::increment(int step) {
- char ierror = 0;
- Index(Index() + step);
- while ((!verse) && (!headings) && (!ierror)) {
- Index(Index() + 1);
- ierror = Error();
- }
-
- error = (ierror) ? ierror : error;
-}
-
-
-/******************************************************************************
- * VerseKey::decrement - Decrements key a number of verses
- *
- * ENT: step - Number of verses to jump backward
- *
- * RET: *this
- */
-
-void VerseKey::decrement(int step) {
- char ierror = 0;
-
- Index(Index() - step);
- while ((!verse) && (!headings) && (!ierror)) {
- Index(Index() - 1);
- ierror = Error();
- }
- if ((ierror) && (!headings))
- (*this)++;
-
- error = (ierror) ? ierror : error;
-}
-
-
-/******************************************************************************
- * VerseKey::Normalize - checks limits and normalizes if necessary (e.g.
- * Matthew 29:47 = Mark 2:2). If last verse is
- * exceeded, key is set to last Book CH:VS
- * RET: *this
- */
-
-void VerseKey::Normalize(char autocheck)
-{
- error = 0;
-
- if ((autocheck) && (!autonorm)) // only normalize if we were explicitely called or if autonorm is turned on
- return;
-
- if ((headings) && (!verse)) // this is cheeze and temporary until deciding what actions should be taken.
- return; // so headings should only be turned on when positioning with Index() or incrementors
-
- while ((testament < 3) && (testament > 0)) {
-
- if (book > BMAX[testament-1]) {
- book -= BMAX[testament-1];
- testament++;
- continue;
- }
-
- if (book < 1) {
- if (--testament > 0) {
- book += BMAX[testament-1];
- }
- continue;
- }
-
- if (chapter > books[testament-1][book-1].chapmax) {
- chapter -= books[testament-1][book-1].chapmax;
- book++;
- continue;
- }
-
- if (chapter < 1) {
- if (--book > 0) {
- chapter += books[testament-1][book-1].chapmax;
- }
- else {
- if (testament > 1) {
- chapter += books[0][BMAX[0]-1].chapmax;
- }
- }
- continue;
- }
-
- if (verse > books[testament-1][book-1].versemax[chapter-1]) { // -1 because e.g chapter 1 of Matthew is books[1][0].versemax[0]
- verse -= books[testament-1][book-1].versemax[chapter++ - 1];
- continue;
- }
-
- if (verse < 1) {
- if (--chapter > 0) {
- verse += books[testament-1][book-1].versemax[chapter-1];
- }
- else {
- if (book > 1) {
- verse += books[testament-1][book-2].versemax[books[testament-1][book-2].chapmax-1];
- }
- else {
- if (testament > 1) {
- verse += books[0][BMAX[0]-1].versemax[books[0][BMAX[0]-1].chapmax-1];
- }
- }
- }
- continue;
- }
-
- break; // If we've made it this far (all failure checks continue) we're ok
- }
-
- if (testament > 2) {
- testament = 2;
- book = BMAX[testament-1];
- chapter = books[testament-1][book-1].chapmax;
- verse = books[testament-1][book-1].versemax[chapter-1];
- error = KEYERR_OUTOFBOUNDS;
- }
-
- if (testament < 1) {
- error = ((!headings) || (testament < 0) || (book < 0)) ? KEYERR_OUTOFBOUNDS : 0;
- testament = ((headings) ? 0 : 1);
- book = ((headings) ? 0 : 1);
- chapter = ((headings) ? 0 : 1);
- verse = ((headings) ? 0 : 1);
- }
- if (_compare(UpperBound()) > 0) {
- *this = UpperBound();
- error = KEYERR_OUTOFBOUNDS;
- }
- if (_compare(LowerBound()) < 0) {
- *this = LowerBound();
- error = KEYERR_OUTOFBOUNDS;
- }
-}
-
-
-/******************************************************************************
- * VerseKey::Testament - Gets testament
- *
- * RET: value of testament
- */
-
-char VerseKey::Testament() const
-{
- return testament;
-}
-
-
-/******************************************************************************
- * VerseKey::Book - Gets book
- *
- * RET: value of book
- */
-
-char VerseKey::Book() const
-{
- return book;
-}
-
-
-/******************************************************************************
- * VerseKey::Chapter - Gets chapter
- *
- * RET: value of chapter
- */
-
-int VerseKey::Chapter() const
-{
- return chapter;
-}
-
-
-/******************************************************************************
- * VerseKey::Verse - Gets verse
- *
- * RET: value of verse
- */
-
-int VerseKey::Verse() const
-{
- return verse;
-}
-
-
-/******************************************************************************
- * VerseKey::Testament - Sets/gets testament
- *
- * ENT: itestament - value which to set testament
- * [MAXPOS(char)] - only get
- *
- * RET: if unchanged -> value of testament
- * if changed -> previous value of testament
- */
-
-char VerseKey::Testament(char itestament)
-{
- char retval = testament;
-
- if (itestament != MAXPOS(char)) {
- testament = itestament;
- Normalize(1);
- }
- return retval;
-}
-
-
-/******************************************************************************
- * VerseKey::Book - Sets/gets book
- *
- * ENT: ibook - value which to set book
- * [MAXPOS(char)] - only get
- *
- * RET: if unchanged -> value of book
- * if changed -> previous value of book
- */
-
-char VerseKey::Book(char ibook)
-{
- char retval = book;
-
- Chapter(1);
- book = ibook;
- Normalize(1);
-
- return retval;
-}
-
-
-/******************************************************************************
- * VerseKey::Chapter - Sets/gets chapter
- *
- * ENT: ichapter - value which to set chapter
- * [MAXPOS(int)] - only get
- *
- * RET: if unchanged -> value of chapter
- * if changed -> previous value of chapter
- */
-
-int VerseKey::Chapter(int ichapter)
-{
- int retval = chapter;
-
- Verse(1);
- chapter = ichapter;
- Normalize(1);
-
- return retval;
-}
-
-
-/******************************************************************************
- * VerseKey::Verse - Sets/gets verse
- *
- * ENT: iverse - value which to set verse
- * [MAXPOS(int)] - only get
- *
- * RET: if unchanged -> value of verse
- * if changed -> previous value of verse
- */
-
-int VerseKey::Verse(int iverse)
-{
- int retval = verse;
-
- verse = iverse;
- Normalize(1);
-
- return retval;
-}
-
-
-/******************************************************************************
- * VerseKey::AutoNormalize - Sets/gets flag that tells VerseKey to auto-
- * matically normalize itself when modified
- *
- * ENT: iautonorm - value which to set autonorm
- * [MAXPOS(char)] - only get
- *
- * RET: if unchanged -> value of autonorm
- * if changed -> previous value of autonorm
- */
-
-char VerseKey::AutoNormalize(char iautonorm)
-{
- char retval = autonorm;
-
- if (iautonorm != MAXPOS(char)) {
- autonorm = iautonorm;
- Normalize(1);
- }
- return retval;
-}
-
-
-/******************************************************************************
- * VerseKey::Headings - Sets/gets flag that tells VerseKey to include
- * chap/book/testmnt/module headings
- *
- * ENT: iheadings - value which to set headings
- * [MAXPOS(char)] - only get
- *
- * RET: if unchanged -> value of headings
- * if changed -> previous value of headings
- */
-
-char VerseKey::Headings(char iheadings)
-{
- char retval = headings;
-
- if (iheadings != MAXPOS(char)) {
- headings = iheadings;
- Normalize(1);
- }
- return retval;
-}
-
-
-/******************************************************************************
- * VerseKey::findindex - binary search to find the index closest, but less
- * than the given value.
- *
- * ENT: array - long * to array to search
- * size - number of elements in the array
- * value - value to find
- *
- * RET: the index into the array that is less than but closest to value
- */
-
-int VerseKey::findindex(long *array, int size, long value)
-{
- int lbound, ubound, tval;
-
- lbound = 0;
- ubound = size - 1;
- while ((ubound - lbound) > 1) {
- tval = lbound + (ubound-lbound)/2;
- if (array[tval] <= value)
- lbound = tval;
- else ubound = tval;
- }
- return (array[ubound] <= value) ? ubound : lbound;
-}
-
-
-/******************************************************************************
- * VerseKey::Index - Gets index based upon current verse
- *
- * RET: offset
- */
-
-long VerseKey::Index() const
-{
- long offset;
-
- if (!testament) { // if we want module heading
- offset = 0;
- verse = 0;
- }
- else {
- if (!book)
- chapter = 0;
- if (!chapter)
- verse = 0;
-
- offset = offsets[testament-1][0][book];
- offset = offsets[testament-1][1][(int)offset + chapter];
- if (!(offset|verse)) // if we have a testament but nothing else.
- offset = 1;
- }
- return (offset + verse);
-}
-
-
-/******************************************************************************
- * VerseKey::Index - Gets index based upon current verse
- *
- * RET: offset
- */
-
-long VerseKey::NewIndex() const
-{
- static long otMaxIndex = 32300 - 8245; // total positions - new testament positions
-// static long otMaxIndex = offsets[0][1][(int)offsets[0][0][BMAX[0]] + books[0][BMAX[0]].chapmax];
- return ((testament-1) * otMaxIndex) + Index();
-}
-
-
-/******************************************************************************
- * VerseKey::Index - Sets index based upon current verse
- *
- * ENT: iindex - value to set index to
- *
- * RET: offset
- */
-
-long VerseKey::Index(long iindex)
-{
- long offset;
-
-// This is the dirty stuff --------------------------------------------
-
- if (!testament)
- testament = 1;
-
- if (iindex < 1) { // if (-) or module heading
- if (testament < 2) {
- if (iindex < 0) {
- testament = 0; // previously we changed 0 -> 1
- error = KEYERR_OUTOFBOUNDS;
- }
- else testament = 0; // we want module heading
- }
- else {
- testament--;
- iindex = (offsets[testament-1][1][offsize[testament-1][1]-1] + books[testament-1][BMAX[testament-1]-1].versemax[books[testament-1][BMAX[testament-1]-1].chapmax-1]) + iindex; // What a doozy! ((offset of last chapter + number of verses in the last chapter) + iindex)
- }
- }
-
-// --------------------------------------------------------------------
-
-
- if (testament) {
- if ((!error) && (iindex)) {
- offset = findindex(offsets[testament-1][1], offsize[testament-1][1], iindex);
- verse = iindex - offsets[testament-1][1][offset];
- book = findindex(offsets[testament-1][0], offsize[testament-1][0], offset);
- chapter = offset - offsets[testament-1][0][VerseKey::book];
- verse = (chapter) ? verse : 0; // funny check. if we are index=1 (testmt header) all gets set to 0 exept verse. Don't know why. Fix if you figure out. Think its in the offsets table.
- if (verse) { // only check if -1 won't give negative
- if (verse > books[testament-1][book-1].versemax[chapter-1]) {
- if (testament > 1) {
- verse = books[testament-1][book-1].versemax[chapter-1];
- error = KEYERR_OUTOFBOUNDS;
- }
- else {
- testament++;
- Index(verse - books[testament-2][book-1].versemax[chapter-1]);
- }
- }
- }
- }
- }
- if (_compare(UpperBound()) > 0) {
- *this = UpperBound();
- error = KEYERR_OUTOFBOUNDS;
- }
- if (_compare(LowerBound()) < 0) {
- *this = LowerBound();
- error = KEYERR_OUTOFBOUNDS;
- }
- return Index();
-}
-
-
-/******************************************************************************
- * VerseKey::compare - Compares another SWKey object
- *
- * ENT: ikey - key to compare with this one
- *
- * RET: >0 if this versekey is greater than compare versekey
- * <0 <
- * 0 =
- */
-
-int VerseKey::compare(const SWKey &ikey)
-{
- VerseKey ivkey = (const char *)ikey;
- return _compare(ivkey);
-}
-
-
-/******************************************************************************
- * VerseKey::_compare - Compares another VerseKey object
- *
- * ENT: ikey - key to compare with this one
- *
- * RET: >0 if this versekey is greater than compare versekey
- * <0 <
- * 0 =
- */
-
-int VerseKey::_compare(const VerseKey &ivkey)
-{
- long keyval1 = 0;
- long keyval2 = 0;
-
- keyval1 += Testament() * 1000000000;
- keyval2 += ivkey.Testament() * 1000000000;
- keyval1 += Book() * 1000000;
- keyval2 += ivkey.Book() * 1000000;
- keyval1 += Chapter() * 1000;
- keyval2 += ivkey.Chapter() * 1000;
- keyval1 += Verse();
- keyval2 += ivkey.Verse();
- keyval1 -= keyval2;
- keyval1 = (keyval1) ? ((keyval1 > 0) ? 1 : -1) /*keyval1/labs(keyval1)*/:0; // -1 | 0 | 1
- return keyval1;
-}
-
-
-const char *VerseKey::getOSISRef() const {
- static char buf[5][254];
- static char loop = 0;
-
- if (loop > 4)
- loop = 0;
-
- static char *osisotbooks[] = {
- "Gen","Exod","Lev","Num","Deut","Josh","Judg","Ruth","1Sam","2Sam",
- "1Kgs","2Kgs","1Chr","2Chr","Ezra","Neh","Esth","Job","Ps",
- "Prov", // added this. Was not in OSIS spec
- "Eccl",
- "Song","Isa","Jer","Lam","Ezek","Dan","Hos","Joel","Amos","Obad",
- "Jonah","Mic","Nah","Hab","Zeph","Hag","Zech","Mal","Bar","PrAzar",
- "Bel","Sus","1Esd","2Esd","AddEsth","EpJer","Jdt","1Macc","2Macc","3Macc",
- "4Macc","PrMan","Ps151","Sir","Tob","Wis"};
- static char *osisntbooks[] = {
- "Matt","Mark","Luke","John","Acts","Rom","1Cor","2Cor","Gal","Eph",
- "Phil","Col","1Thess","2Thess","1Tim","2Tim","Titus","Phlm","Heb","Jas",
- "1Pet","2Pet","1John","2John","3John","Jude","Rev"};
- static char **osisbooks[] = { osisotbooks, osisntbooks };
- if (Verse())
- sprintf(buf[loop], "%s.%d.%d", osisbooks[Testament()-1][Book()-1], (int)Chapter(), (int)Verse());
- else if (Chapter())
- sprintf(buf[loop], "%s.%d", osisbooks[Testament()-1][Book()-1], (int)Chapter());
- else if (Book())
- sprintf(buf[loop], "%s", osisbooks[Testament()-1][Book()-1]);
- else sprintf(buf[loop], "");
- return buf[loop++];
-}
-
-
-/******************************************************************************
- * VerseKey::getRangeText - returns parsable range text for this key
- */
-
-const char *VerseKey::getRangeText() const {
- if (isBoundSet()) {
- char buf[1023];
- sprintf(buf, "%s-%s", (const char *)LowerBound(), (const char *)UpperBound());
- stdstr(&rangeText, buf);
- }
- else stdstr(&rangeText, getText());
- return rangeText;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/mgr/Makefile b/src/mgr/Makefile
deleted file mode 100644
index 339f87a..0000000
--- a/src/mgr/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-root := ../..
-
-all:
- make -C ${root}
diff --git a/src/mgr/Makefile.am b/src/mgr/Makefile.am
deleted file mode 100644
index 15883b5..0000000
--- a/src/mgr/Makefile.am
+++ /dev/null
@@ -1,22 +0,0 @@
-mgrdir = $(top_srcdir)/src/mgr
-
-if CONFDEF
-globdef = -DGLOBCONFPATH=\"${globalconfdir}/sword.conf\"
-else
-globdef =
-endif
-
-INCLUDES += $(globdef)
-
-libsword_la_SOURCES += $(mgrdir)/swconfig.cpp
-libsword_la_SOURCES += $(mgrdir)/swmgr.cpp
-libsword_la_SOURCES += $(mgrdir)/swfiltermgr.cpp
-libsword_la_SOURCES += $(mgrdir)/encfiltmgr.cpp
-libsword_la_SOURCES += $(mgrdir)/markupfiltmgr.cpp
-libsword_la_SOURCES += $(mgrdir)/filemgr.cpp
-libsword_la_SOURCES += $(mgrdir)/swlocale.cpp
-libsword_la_SOURCES += $(mgrdir)/localemgr.cpp
-libsword_la_SOURCES += $(mgrdir)/swcacher.cpp
-libsword_la_SOURCES += $(mgrdir)/swsearchable.cpp
-libsword_la_SOURCES += $(mgrdir)/installmgr.cpp
-
diff --git a/src/mgr/encfiltmgr.cpp b/src/mgr/encfiltmgr.cpp
deleted file mode 100644
index 35be96a..0000000
--- a/src/mgr/encfiltmgr.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/******************************************************************************
- * swencodingmgr.cpp - implementaion of class EncodingFilterMgr, subclass of
- * used to transcode all module text to a requested
- * encoding.
- *
- * Copyright 1998 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 <encfiltmgr.h>
-
-#include <scsuutf8.h>
-#include <latin1utf8.h>
-
-#include <unicodertf.h>
-#include <utf8latin1.h>
-#include <utf8utf16.h>
-#include <utf8html.h>
-
-#include <swmgr.h>
-
-SWORD_NAMESPACE_START
-
-/******************************************************************************
- * EncodingFilterMgr Constructor - initializes instance of EncodingFilterMgr
- *
- * ENT:
- * enc - Encoding format to emit
- */
-
-EncodingFilterMgr::EncodingFilterMgr (char enc)
- : SWFilterMgr() {
-
- scsuutf8 = new SCSUUTF8();
- latin1utf8 = new Latin1UTF8();
-
- encoding = enc;
-
- switch (encoding) {
- case ENC_LATIN1:
- targetenc = new UTF8Latin1();
- break;
- case ENC_UTF16:
- targetenc = new UTF8UTF16();
- break;
- case ENC_RTF:
- targetenc = new UnicodeRTF();
- break;
- case ENC_HTML:
- targetenc = new UTF8HTML();
- break;
- default: // i.e. case ENC_UTF8
- targetenc = NULL;
- }
-}
-
-/******************************************************************************
- * EncodingFilterMgr Destructor - Cleans up instance of EncodingFilterMgr
- */
-EncodingFilterMgr::~EncodingFilterMgr() {
- if (scsuutf8)
- delete scsuutf8;
- if (latin1utf8)
- delete latin1utf8;
- if (targetenc)
- delete targetenc;
-}
-
-void EncodingFilterMgr::AddRawFilters(SWModule *module, ConfigEntMap &section) {
-
- ConfigEntMap::iterator entry;
-
- SWBuf encoding = ((entry = section.find("Encoding")) != section.end()) ? (*entry).second : (SWBuf)"";
- if (!encoding.length() || !stricmp(encoding.c_str(), "Latin-1")) {
- module->AddRawFilter(latin1utf8);
- }
- else if (!stricmp(encoding.c_str(), "SCSU")) {
- module->AddRawFilter(scsuutf8);
- }
-}
-
-void EncodingFilterMgr::AddEncodingFilters(SWModule *module, ConfigEntMap &section) {
- if (targetenc)
- module->AddEncodingFilter(targetenc);
-}
-
-/******************************************************************************
- * EncodingFilterMgr::Encoding - sets/gets encoding
- *
- * ENT: enc - new encoding or 0 to simply get the current encoding
- *
- * RET: encoding
- */
-char EncodingFilterMgr::Encoding(char enc) {
- if (enc && enc != encoding) {
- encoding = enc;
- SWFilter * oldfilter = targetenc;
-
- switch (encoding) {
- case ENC_LATIN1:
- targetenc = new UTF8Latin1();
- break;
- case ENC_UTF16:
- targetenc = new UTF8UTF16();
- break;
- case ENC_RTF:
- targetenc = new UnicodeRTF();
- break;
- case ENC_HTML:
- targetenc = new UTF8HTML();
- break;
- default: // i.e. case ENC_UTF8
- targetenc = NULL;
- }
-
- ModMap::const_iterator module;
-
- if (oldfilter != targetenc) {
- if (oldfilter) {
- if (!targetenc) {
- for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
- module->second->RemoveRenderFilter(oldfilter);
- }
- else {
- for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
- module->second->ReplaceRenderFilter(oldfilter, targetenc);
- }
- delete oldfilter;
- }
- else if (targetenc) {
- for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
- module->second->AddRenderFilter(targetenc);
- }
- }
-
- }
- return encoding;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/mgr/filemgr.cpp b/src/mgr/filemgr.cpp
deleted file mode 100644
index 44bc768..0000000
--- a/src/mgr/filemgr.cpp
+++ /dev/null
@@ -1,357 +0,0 @@
-/******************************************************************************
- * filemgr.cpp - implementation of class FileMgr used for pooling file
- * handles
- *
- * $Id: filemgr.cpp,v 1.33 2003/12/23 01:36:12 chrislit Exp $
- *
- * Copyright 1998 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 <filemgr.h>
-#include <utilstr.h>
-
-#include <dirent.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#if !defined(__GNUC__) && !defined(_WIN32_WCE)
-#include <io.h>
-#include <direct.h>
-#else
-#include <unistd.h>
-#endif
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-#ifndef S_IRGRP
-#define S_IRGRP 0
-#endif
-
-#ifndef S_IROTH
-#define S_IROTH 0
-#endif
-
-SWORD_NAMESPACE_START
-
-// ---------------- statics -----------------
-FileMgr FileMgr::systemFileMgr;
-
-// --------------- end statics --------------
-
-
-FileDesc::FileDesc(FileMgr *parent, const char *path, int mode, int perms, bool tryDowngrade) {
- this->parent = parent;
- this->path = 0;
- stdstr(&this->path, path);
- this->mode = mode;
- this->perms = perms;
- this->tryDowngrade = tryDowngrade;
- offset = 0;
- fd = -77;
-}
-
-
-FileDesc::~FileDesc() {
- if (fd > 0)
- close(fd);
-
- if (path)
- delete [] path;
-}
-
-
-int FileDesc::getFd() {
- if (fd == -77)
- fd = parent->sysOpen(this);
- return fd;
-}
-
-
-FileMgr::FileMgr(int maxFiles) {
- this->maxFiles = maxFiles; // must be at least 2
- files = 0;
-}
-
-
-FileMgr::~FileMgr() {
- FileDesc *tmp;
-
- while(files) {
- tmp = files->next;
- delete files;
- files = tmp;
- }
-}
-
-
-FileDesc *FileMgr::open(const char *path, int mode, bool tryDowngrade) {
- return open(path, mode, S_IREAD | S_IWRITE|S_IRGRP|S_IROTH, tryDowngrade);
-}
-
-FileDesc *FileMgr::open(const char *path, int mode, int perms, bool tryDowngrade) {
- FileDesc **tmp, *tmp2;
-
- for (tmp = &files; *tmp; tmp = &((*tmp)->next)) {
- if ((*tmp)->fd < 0) // insert as first non-system_open file
- break;
- }
-
- tmp2 = new FileDesc(this, path, mode, perms, tryDowngrade);
- tmp2->next = *tmp;
- *tmp = tmp2;
-
- return tmp2;
-}
-
-
-void FileMgr::close(FileDesc *file) {
- FileDesc **loop;
-
- for (loop = &files; *loop; loop = &((*loop)->next)) {
- if (*loop == file) {
- *loop = (*loop)->next;
- delete file;
- break;
- }
- }
-}
-
-
-// to truncate a file at its current position
-// leaving byte at current possition intact
-// deleting everything afterward.
-signed char FileMgr::trunc(FileDesc *file) {
-
- static const char *writeTest = "x";
- long size = lseek(file->getFd(), 1, SEEK_CUR);
- if (size == 1) // was empty
- size = 0;
- char nibble [ 32767 ];
- bool writable = write(file->getFd(), writeTest, 1);
- int bytes = 0;
-
- if (writable) {
- // get tmpfilename
- char *buf = new char [ strlen(file->path) + 10 ];
- int i;
- for (i = 0; i < 9999; i++) {
- sprintf(buf, "%stmp%.4d", file->path, i);
- if (!existsFile(buf))
- break;
- }
- if (i == 9999)
- return -2;
-
- int fd = ::open(buf, O_CREAT|O_RDWR, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
- if (fd < 0)
- return -3;
-
- lseek(file->getFd(), 0, SEEK_SET);
- while (size > 0) {
- bytes = read(file->getFd(), nibble, 32767);
- write(fd, nibble, (bytes < size)?bytes:size);
- size -= bytes;
- }
- // zero out the file
- ::close(file->fd);
- file->fd = ::open(file->path, O_TRUNC, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
- ::close(file->fd);
- file->fd = -77; // force file open by filemgr
- // copy tmp file back (dumb, but must preserve file permissions)
- lseek(fd, 0, SEEK_SET);
- do {
- bytes = read(fd, nibble, 32767);
- write(file->getFd(), nibble, bytes);
- } while (bytes == 32767);
-
- ::close(fd);
- ::close(file->fd);
- removeFile(buf); // remove our tmp file
- file->fd = -77; // causes file to be swapped out forcing open on next call to getFd()
- }
- else { // put offset back and return failure
- lseek(file->getFd(), -1, SEEK_CUR);
- return -1;
- }
- return 0;
-}
-
-
-int FileMgr::sysOpen(FileDesc *file) {
- FileDesc **loop;
- int openCount = 1; // because we are presently opening 1 file, and we need to be sure to close files to accomodate, if necessary
-
- for (loop = &files; *loop; loop = &((*loop)->next)) {
-
- if ((*loop)->fd > 0) {
- if (++openCount > maxFiles) {
- (*loop)->offset = lseek((*loop)->fd, 0, SEEK_CUR);
- ::close((*loop)->fd);
- (*loop)->fd = -77;
- }
- }
-
- if (*loop == file) {
- if (*loop != files) {
- *loop = (*loop)->next;
- file->next = files;
- files = file;
- }
- if ((!access(file->path, 04)) || ((file->mode & O_CREAT) == O_CREAT)) { // check for at least file exists / read access before we try to open
- char tries = (((file->mode & O_RDWR) == O_RDWR) && (file->tryDowngrade)) ? 2 : 1; // try read/write if possible
- for (int i = 0; i < tries; i++) {
- if (i > 0) {
- file->mode = (file->mode & ~O_RDWR); // remove write access
- file->mode = (file->mode | O_RDONLY);// add read access
- }
- file->fd = ::open(file->path, file->mode, file->perms);
-
- if (file->fd >= 0)
- break;
- }
-
- if (file->fd >= 0)
- lseek(file->fd, file->offset, SEEK_SET);
- }
- else file->fd = -1;
- if (!*loop)
- break;
- }
- }
- return file->fd;
-}
-
-
-signed char FileMgr::existsFile(const char *ipath, const char *ifileName)
-{
- int len = strlen(ipath) + ((ifileName)?strlen(ifileName):0) + 3;
- char *ch;
- char *path = new char [ len ];
- strcpy(path, ipath);
-
- if ((path[strlen(path)-1] == '\\') || (path[strlen(path)-1] == '/'))
- path[strlen(path)-1] = 0;
-
- if (ifileName) {
- ch = path + strlen(path);
- sprintf(ch, "/%s", ifileName);
- }
- signed char retVal = !access(path, 04);
- delete [] path;
- return retVal;
-}
-
-
-signed char FileMgr::existsDir(const char *ipath, const char *idirName)
-{
- char *ch;
- int len = strlen(ipath) + ((idirName)?strlen(idirName):0) + 1;
- if (idirName)
- len += strlen(idirName);
- char *path = new char [ len ];
- strcpy(path, ipath);
-
- if ((path[strlen(path)-1] == '\\') || (path[strlen(path)-1] == '/'))
- path[strlen(path)-1] = 0;
-
- if (idirName) {
- ch = path + strlen(path);
- sprintf(ch, "/%s", idirName);
- }
- signed char retVal = !access(path, 04);
- delete [] path;
- return retVal;
-}
-
-
-int FileMgr::createParent(const char *pName) {
- char *buf = new char [ strlen(pName) + 1 ];
- int retCode = 0;
-
- strcpy(buf, pName);
- int end = strlen(buf) - 1;
- while (end) {
- if ((buf[end] == '/') || (buf[end] == '\\'))
- break;
- end--;
- }
- buf[end] = 0;
- if (strlen(buf)>0) {
- if (access(buf, 02)) { // not exists with write access?
- if ((retCode = mkdir(buf
-#ifndef WIN32
- , 0755
-#endif
- ))) {
- createParent(buf);
- retCode = mkdir(buf
-#ifndef WIN32
- , 0755
-#endif
- );
- }
- }
- }
- else retCode = -1;
- delete [] buf;
- return retCode;
-}
-
-
-int FileMgr::createPathAndFile(const char *fName) {
- int fd;
-
- fd = ::open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
- if (fd < 1) {
- createParent(fName);
- fd = ::open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
- }
- return fd;
-}
-
-
-int FileMgr::copyFile(const char *sourceFile, const char *targetFile) {
- int sfd, dfd, len;
- char buf[4096];
-
- if ((sfd = ::open(sourceFile, O_RDONLY|O_BINARY)) < 1)
- return -1;
- if ((dfd = createPathAndFile(targetFile)) < 1)
- return -1;
-
- do {
- len = read(sfd, buf, 4096);
- write(dfd, buf, len);
- }
- while(len == 4096);
- ::close(dfd);
- ::close(sfd);
-
- return 0;
-}
-
-
-int FileMgr::removeFile(const char *fName) {
- return ::remove(fName);
-}
-
-
-
-SWORD_NAMESPACE_END
diff --git a/src/mgr/installmgr.cpp b/src/mgr/installmgr.cpp
deleted file mode 100644
index 5fbfb05..0000000
--- a/src/mgr/installmgr.cpp
+++ /dev/null
@@ -1,629 +0,0 @@
-/*****************************************************************************
- * InstallMgr functions to be made into something usefully exposed by
- * master Glassey
- *
- */
-
-
-#ifndef EXCLUDEZLIB
-extern "C" {
-#include <untgz.h>
-}
-#endif
-
-
-#include <installmgr.h>
-#include <filemgr.h>
-
-#include <fcntl.h>
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-#ifdef CURLAVAILABLE
-#include <curl/curl.h>
-#include <curl/types.h>
-#include <curl/easy.h>
-#endif
-
-#include <defs.h>
-#include <vector>
-#include <swmgr.h>
-#include <dirent.h>
-
-using namespace std;
-
-SWORD_NAMESPACE_START
-
-int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream);
-int my_fprogress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
-
-static InstallMgr_init _InstallMgr_init;
-
-InstallMgr_init::InstallMgr_init() {
-#ifdef CURLAVAILABLE
- curl_global_init(CURL_GLOBAL_DEFAULT);
-#else
-// fprintf(stderr, "libCURL is needed for remote installation functions\n");
-#endif
-}
-
-InstallMgr_init::~InstallMgr_init() {
-#ifdef CURLAVAILABLE
- curl_global_cleanup();
-#else
-// fprintf(stderr, "libCURL is needed for remote installation functions\n");
-#endif
-}
-
-
-int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) {
- struct FtpFile *out=(struct FtpFile *)stream;
- if (out && !out->stream) {
- /* open file for writing */
- out->stream=fopen(out->filename, "wb");
- if (!out->stream)
- return -1; /* failure, can't open file to write */
- }
- return fwrite(buffer, size, nmemb, out->stream);
-}
-
-
-int my_fprogress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) {
- if (clientp) {
- ((InstallMgr *)clientp)->statusUpdate(dltotal, dlnow);
- }
- return 0;
-}
-
-
-InstallMgr::InstallMgr(const char *privatePath) {
- this->privatePath = 0;
- stdstr(&(this->privatePath), privatePath);
- SWBuf confPath = (SWBuf)privatePath + "/InstallMgr.conf";
- FileMgr::createParent(confPath.c_str());
-
- installConf = new SWConfig(confPath.c_str());
-
- SectionMap::iterator sourcesSection;
- ConfigEntMap::iterator sourceBegin;
- ConfigEntMap::iterator sourceEnd;
-
- sources.clear();
-
- sourcesSection = installConf->Sections.find("Sources");
- passive = (!stricmp((*installConf)["General"]["PassiveFTP"].c_str(), "true"));
-
- if (sourcesSection != installConf->Sections.end()) {
- sourceBegin = sourcesSection->second.lower_bound("FTPSource");
- sourceEnd = sourcesSection->second.upper_bound("FTPSource");
-
- while (sourceBegin != sourceEnd) {
- InstallSource *is = new InstallSource("FTP", sourceBegin->second.c_str());
- sources[is->caption] = is;
- SWBuf parent = (SWBuf)privatePath + "/" + is->source + "/file";
- FileMgr::createParent(parent.c_str());
- is->localShadow = (SWBuf)privatePath + "/" + is->source;
- sourceBegin++;
- }
- }
-}
-
-
-InstallMgr::~InstallMgr() {
- delete [] privatePath;
- delete installConf;
-}
-
-
-void InstallMgr::statusUpdate(double dltotal, double dlnow) {
-}
-
-void InstallMgr::preDownloadStatus(long totalBytes, long completedBytes, const char *message) {
-}
-
-char InstallMgr::FTPURLGetFile(void *session, const char *dest, const char *sourceurl) {
- char retVal = 0;
-#ifdef CURLAVAILABLE
- struct FtpFile ftpfile = {dest, NULL};
-
- CURL *curl = (CURL *)session;
- CURLcode res;
-
- if (curl) {
- curl_easy_setopt(curl, CURLOPT_URL, sourceurl);
-
- curl_easy_setopt(curl, CURLOPT_USERPWD, "ftp:installmgr@user.com");
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
- if (!passive)
- curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
- curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
- curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, this);
- curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_fprogress);
- /* Set a pointer to our struct to pass to the callback */
- curl_easy_setopt(curl, CURLOPT_FILE, &ftpfile);
-
- /* Switch on full protocol/debug output */
- curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE);
-
- res = curl_easy_perform(curl);
-
- if(CURLE_OK != res) {
- retVal = -1;
- }
- }
-
- if (ftpfile.stream)
- fclose(ftpfile.stream); /* close the local file */
-#else
- fprintf(stderr, "libCURL is needed for remote installation functions\n");
-#endif
- return retVal;
-}
-
-
-
-vector<struct ftpparse> InstallMgr::FTPURLGetDir(void *session, const char *dirurl) {
-
- vector<struct ftpparse> dirList;
-
- if (!FTPURLGetFile(session, "dirlist", dirurl)) {
- int fd = open("dirlist", O_RDONLY|O_BINARY);
- long size = lseek(fd, 0, SEEK_END);
- lseek(fd, 0, SEEK_SET);
- char *buf = new char [ size + 1 ];
- read(fd, buf, size);
- close(fd);
- char *start = buf;
- char *end = start;
- while (start < (buf+size)) {
- struct ftpparse item;
- bool looking = true;
- for (end = start; *end; end++) {
- if (looking) {
- if ((*end == 10) || (*end == 13)) {
- *end = 0;
- looking = false;
- }
- }
- else if ((*end != 10) && (*end != 13))
- break;
- }
- int status = ftpparse(&item, start, end - start);
- if (status)
- dirList.push_back(item);
- start = end;
- }
- }
- return dirList;
-}
-
-
-void *InstallMgr::FTPOpenSession() {
- void *retVal = 0;
-#ifdef CURLAVAILABLE
- CURL *curl;
-
- retVal = curl_easy_init();
-#else
- fprintf(stderr, "libCURL is needed for remote installation functions\n");
-#endif
- return retVal;
-}
-
-
-void InstallMgr::FTPCloseSession(void *session) {
-#ifdef CURLAVAILABLE
- CURL *curl = (CURL *)session;
- curl_easy_cleanup(curl);
-#else
- fprintf(stderr, "libCURL is needed for remote installation functions\n");
-#endif
-}
-
-
-int InstallMgr::removeModule(SWMgr *manager, const char *modName) {
- SectionMap::iterator module;
- ConfigEntMap::iterator fileBegin;
- ConfigEntMap::iterator fileEnd, entry;
-
- module = manager->config->Sections.find(modName);
-
- if (module != manager->config->Sections.end()) {
-
- fileBegin = module->second.lower_bound("File");
- fileEnd = module->second.upper_bound("File");
-
- SWBuf modFile;
- SWBuf modDir;
- entry = module->second.find("AbsoluteDataPath");
- modDir = entry->second.c_str();
- if (fileBegin != fileEnd) { // remove each file
- while (fileBegin != fileEnd) {
- modFile = modDir;
- modFile += "/";
- modFile += fileBegin->second.c_str();
- //remove file
- remove(modFile.c_str());
- fileBegin++;
- }
- }
- else { //remove all files in DataPath directory
-
- DIR *dir;
- struct dirent *ent;
- ConfigEntMap::iterator entry;
-
-
- if (dir = opendir(modDir.c_str())) {
- rewinddir(dir);
- while ((ent = readdir(dir))) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- modFile = modDir;
- modFile += "/";
- modFile += ent->d_name;
- remove(modFile.c_str());
- }
- }
- closedir(dir);
- }
- if (dir = opendir(manager->configPath)) { // find and remove .conf file
- rewinddir(dir);
- while ((ent = readdir(dir))) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- modFile = manager->configPath;
- modFile += "/";
- modFile += ent->d_name;
- SWConfig *config = new SWConfig(modFile.c_str());
- if (config->Sections.find(modName) != config->Sections.end()) {
- delete config;
- remove(modFile.c_str());
- }
- else delete config;
- }
- }
- closedir(dir);
- }
- }
- return 0;
- }
- return 1;
-}
-
-
-
-InstallSource::InstallSource(const char *type, const char *confEnt) {
- this->type = type;
- mgr = 0;
- userData = 0;
- if (confEnt) {
- char *buf = 0;
- stdstr(&buf, confEnt);
-
- caption = strtok(buf, "|");
- source = strtok(0, "|");
- directory = strtok(0, "|");
- delete [] buf;
- }
-}
-
-
-InstallSource::~InstallSource() {
- if (mgr)
- delete mgr;
-}
-
-
-void InstallSource::flush() {
- if (mgr) {
- delete mgr;
- mgr = 0;
- }
-}
-
-
-SWMgr *InstallSource::getMgr() {
- if (!mgr)
- mgr = new SWMgr(localShadow.c_str());
- return mgr;
-}
-
-
-int InstallMgr::FTPCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer, const char *suffix) {
- terminate = false;
- long i;
- void *session = FTPOpenSession();
- SWBuf url = (SWBuf)"ftp://" + is->source + is->directory.c_str() + "/"; //dont forget the final slash
- if (FTPURLGetFile(session, "dirlist", url.c_str())) {
- return -1;
- }
- if (dirTransfer) {
- SWBuf url = (SWBuf)"ftp://" + is->source + is->directory.c_str() + "/" + src + "/"; //dont forget the final slash
- vector<struct ftpparse> dirList = FTPURLGetDir(session, url.c_str());
-
- if (!dirList.size()) {
- return -1;
- }
-
- long totalBytes = 0;
- for (i = 0; i < dirList.size(); i++)
- totalBytes += dirList[i].size;
- long completedBytes = 0;
- for (i = 0; i < dirList.size(); i++) {
- if (dirList[i].flagtrycwd != 1) {
- SWBuf buffer = (SWBuf)dest + "/" + (dirList[i].name);
- if (!strcmp(&buffer.c_str()[buffer.length()-strlen(suffix)], suffix)) {
- SWBuf buffer2 = "Downloading (";
- buffer2.appendFormatted("%d", i+1);
- buffer2 += " of ";
- buffer2.appendFormatted("%d", dirList.size());
- buffer2 += "): ";
- buffer2 += (dirList[i].name);
- preDownloadStatus(totalBytes, completedBytes, buffer2.c_str());
- FileMgr::createParent(buffer.c_str()); // make sure parent directory exists
- try {
- SWBuf url = (SWBuf)"ftp://" + is->source + is->directory.c_str() + "/" + src + "/" + dirList[i].name; //dont forget the final slash
- if (FTPURLGetFile(session, buffer.c_str(), url.c_str())) {
- return -2;
- }
- completedBytes += dirList[i].size;
- }
- catch (...) {}
- if (terminate)
- break;
- }
- }
- }
- }
- else {
-// Synchronize((TThreadMethod)&PreDownload2);
- try {
- SWBuf url = (SWBuf)"ftp://" + is->source + is->directory.c_str() + "/" + src; //dont forget the final slash
- if (FTPURLGetFile(session, dest, url.c_str())) {
- return -1;
- }
- }
- catch(...) {
- terminate = true;
- }
- }
- try {
- FTPCloseSession(session);
- }
- catch(...){}
- return 0;
-}
-
-
-int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const char *modName, InstallSource *is) {
- SectionMap::iterator module, section;
- ConfigEntMap::iterator fileBegin;
- ConfigEntMap::iterator fileEnd;
- ConfigEntMap::iterator entry;
- SWBuf sourceDir;
- SWBuf buffer;
- bool aborted = false;
- bool cipher = false;
- DIR *dir;
- struct dirent *ent;
- SWBuf modFile;
-
-
- if (is)
- sourceDir = (SWBuf)privatePath + "/" + is->source;
- else sourceDir = fromLocation;
-
- if (sourceDir[sourceDir.length()-1] != '/')
- sourceDir += '/';
-
- SWMgr mgr(sourceDir.c_str());
-
- module = mgr.config->Sections.find(modName);
-
- if (module != mgr.config->Sections.end()) {
-
- entry = module->second.find("CipherKey");
- if (entry != module->second.end())
- cipher = true;
-
- fileEnd = module->second.upper_bound("File");
- fileBegin = module->second.lower_bound("File");
-
- if (fileBegin != fileEnd) { // copy each file
- if (is) {
- while (fileBegin != fileEnd) { // ftp each file first
- buffer = sourceDir + "/" + fileBegin->second.c_str();
- if (FTPCopy(is, fileBegin->second.c_str(), buffer.c_str())) {
- aborted = true;
- break; // user aborted
- }
- fileBegin++;
- }
- fileBegin = module->second.lower_bound("File");
- }
-
- if (!aborted) {
- // DO THE INSTALL
- while (fileBegin != fileEnd) {
- copyFileToSWORDInstall(destMgr, sourceDir.c_str(), fileBegin->second.c_str());
- fileBegin++;
- }
- }
- //---------------
-
- if (is) {
- fileBegin = module->second.lower_bound("File");
- while (fileBegin != fileEnd) { // delete each tmp ftp file
- buffer = sourceDir + "/" + fileBegin->second.c_str();
- remove(buffer.c_str());
- fileBegin++;
- }
- }
- }
- else { //copy all files in DataPath directory
- ConfigEntMap::iterator entry;
- SWBuf sourceOrig = sourceDir;
-
- entry = module->second.find("DataPath");
- if (entry != module->second.end()) {
- SWBuf modDir = entry->second.c_str();
- entry = module->second.find("ModDrv");
- if (entry != module->second.end()) {
- if (!strcmp(entry->second.c_str(), "RawLD") || !strcmp(entry->second.c_str(), "RawLD4") || !strcmp(entry->second.c_str(), "zLD") || !strcmp(entry->second.c_str(), "RawGenBook") || !strcmp(entry->second.c_str(), "zGenBook")) {
- int end = modDir.length() - 1;
- while (end >= 0) { //while(end) wouldn't work for length() == 0
- if (modDir[end] == '/')
- break;
-
- modDir--; //remove last char
- end--;
- }
- }
-
- //make sure there's no trailing slash in modDir, required for Bibles and Commentaries
- if ( modDir.length() && (modDir[modDir.length()-1] == '/')) //last char is a slash
- modDir--; //remove the slash
- }
-
- if (is) {
- buffer = sourceDir + "/" + modDir;
- if (FTPCopy(is, modDir.c_str(), buffer.c_str(), true)) {
- aborted = true; // user aborted
- }
- }
- sourceDir += "/";
- sourceDir += modDir;
- if (!aborted) {
- if (dir = opendir(sourceDir.c_str())) {
- rewinddir(dir);
- while ((ent = readdir(dir))) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- modFile = modDir;
- modFile += "/";
- modFile += ent->d_name;
- copyFileToSWORDInstall(destMgr, sourceOrig.c_str(), modFile.c_str());
- }
- }
- closedir(dir);
- }
- }
- if (is) { // delete tmp ftp files
- if (dir = opendir(sourceDir.c_str())) {
- rewinddir(dir);
- while ((ent = readdir(dir))) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- modFile = sourceOrig + "/" + modDir;
- modFile += "/";
- modFile += ent->d_name;
- remove(modFile.c_str());
- }
- }
- closedir(dir);
- }
- }
- sourceDir = sourceOrig;
- sourceDir += "/mods.d/";
- }
- }
- if (!aborted) {
- if (dir = opendir(sourceDir.c_str())) { // find and copy .conf file
- rewinddir(dir);
- while ((ent = readdir(dir))) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- modFile = sourceDir;
- modFile += ent->d_name;
- SWConfig *config = new SWConfig(modFile.c_str());
- if (config->Sections.find(modName) != config->Sections.end()) {
- SWBuf targetFile = destMgr->configPath; //"./mods.d/";
- targetFile += "/";
- targetFile += ent->d_name;
- FileMgr::copyFile(modFile.c_str(), targetFile.c_str());
- if (cipher) {
- if (getCipherCode(modName, config)) {
- SWMgr newDest(destMgr->prefixPath);
- removeModule(&newDest, modName);
- aborted = true;
- }
- else {
- config->Save();
- FileMgr::copyFile(modFile.c_str(), targetFile.c_str());
- }
- }
- }
- delete config;
- }
- }
- closedir(dir);
- }
- }
- return (aborted) ? -1 : 0;
- }
- return 1;
-}
-
-
-// return aborted
-bool InstallMgr::getCipherCode(const char *modName, SWConfig *config) {
- return false;
-}
-
-int InstallMgr::copyFileToSWORDInstall(SWMgr *manager, const char *sourceDir, const char *fName) {
- SWBuf sourcePath = sourceDir;
- sourcePath += fName;
-
- SWBuf dest;
- dest = manager->prefixPath;
- if ((manager->prefixPath[strlen(manager->prefixPath)-1] != '\\') && ( manager->prefixPath[strlen(manager->prefixPath)-1] != '/'))
- dest += "/";
- dest += fName;
-
- return FileMgr::copyFile(sourcePath.c_str(), dest.c_str());
-}
-
-
-void InstallMgr::refreshRemoteSource(InstallSource *is) {
- DIR *dir;
- struct dirent *ent;
- ConfigEntMap::iterator entry;
- SWBuf modDir;
- SWBuf modFile;
- SWBuf root = privatePath;
- root += (SWBuf)"/" + is->source.c_str();
- SWBuf target = root + "/mods.d";
-
- if (dir = opendir(target.c_str())) {
- rewinddir(dir);
- while ((ent = readdir(dir))) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- modFile = target;
- modFile += "/";
- modFile += ent->d_name;
- remove(modFile.c_str());
- }
- }
- closedir(dir);
- }
-
-
-
-#ifndef EXCLUDEZLIB
- SWBuf archive = root + "/mods.d.tar.gz";
- if (!FTPCopy(is, "mods.d.tar.gz", archive.c_str(), false)) {
- int fd = open(archive.c_str(), O_RDONLY|O_BINARY);
- untargz(fd, root.c_str());
- close(fd);
- }
- else
-#endif
- FTPCopy(is, "mods.d", target.c_str(), true, ".conf");
- is->flush();
-}
-
-SWORD_NAMESPACE_END
-
diff --git a/src/mgr/localemgr.cpp b/src/mgr/localemgr.cpp
deleted file mode 100644
index 6c3da4a..0000000
--- a/src/mgr/localemgr.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/******************************************************************************
- * localemgr.cpp - implementation of class LocaleMgr used to interact with
- * registered locales for a sword installation
- *
- * $Id: localemgr.cpp,v 1.16 2003/07/05 04:58:42 scribe Exp $
- *
- * Copyright 1998 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 <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#include <unixstr.h>
-#endif
-#include <sys/stat.h>
-#include <dirent.h>
-
-#include <swmgr.h>
-#include <utilfuns.h>
-
-#include <localemgr.h>
-#include <filemgr.h>
-
-SWORD_NAMESPACE_START
-
-
-LocaleMgr LocaleMgr::systemLocaleMgr;
-
-
-LocaleMgr::LocaleMgr(const char *iConfigPath) {
- locales = new LocaleMap();
- char *prefixPath = 0;
- char *configPath = 0;
- char configType = 0;
- SWBuf path;
-
- defaultLocaleName = 0;
-
- char *lang = getenv ("LANG");
- if (lang) {
- if (strlen(lang) > 0)
- setDefaultLocaleName(lang);
- else setDefaultLocaleName("en_us");
- }
- else setDefaultLocaleName("en_us");
-
- if (!iConfigPath)
- SWMgr::findConfig(&configType, &prefixPath, &configPath);
- else configPath = (char *)iConfigPath;
-
- if (prefixPath) {
- switch (configType) {
- case 2:
- int i;
- for (i = strlen(configPath)-1; ((i) && (configPath[i] != '/') && (configPath[i] != '\\')); i--);
- configPath[i] = 0;
- path = configPath;
- path += "/";
- break;
- default:
- path = prefixPath;
- if ((prefixPath[strlen(prefixPath)-1] != '\\') && (prefixPath[strlen(prefixPath)-1] != '/'))
- path += "/";
-
- break;
- }
- if (FileMgr::existsDir(path.c_str(), "locales.d")) {
- path += "locales.d";
- loadConfigDir(path.c_str());
- }
- }
-
- if (prefixPath)
- delete [] prefixPath;
-
- if (configPath)
- delete [] configPath;
-}
-
-
-LocaleMgr::~LocaleMgr() {
- if (defaultLocaleName)
- delete [] defaultLocaleName;
- deleteLocales();
- delete locales;
-}
-
-
-void LocaleMgr::loadConfigDir(const char *ipath) {
- DIR *dir;
- struct dirent *ent;
- SWBuf newmodfile;
- LocaleMap::iterator it;
-
- if ((dir = opendir(ipath))) {
- rewinddir(dir);
- while ((ent = readdir(dir))) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- newmodfile = ipath;
- if ((ipath[strlen(ipath)-1] != '\\') && (ipath[strlen(ipath)-1] != '/'))
- newmodfile += "/";
- newmodfile += ent->d_name;
- SWLocale *locale = new SWLocale(newmodfile.c_str());
- if (locale->getName()) {
- it = locales->find(locale->getName());
- if (it != locales->end()) {
- *((*it).second) += *locale;
- delete locale;
- }
- else locales->insert(LocaleMap::value_type(locale->getName(), locale));
- }
- else delete locale;
- }
- }
- closedir(dir);
- }
-}
-
-
-void LocaleMgr::deleteLocales() {
-
- LocaleMap::iterator it;
-
- for (it = locales->begin(); it != locales->end(); it++)
- delete (*it).second;
-
- locales->erase(locales->begin(), locales->end());
-}
-
-
-SWLocale *LocaleMgr::getLocale(const char *name) {
- LocaleMap::iterator it;
-
- it = locales->find(name);
- if (it != locales->end())
- return (*it).second;
-
- return 0;
-}
-
-
-std::list <SWBuf> LocaleMgr::getAvailableLocales() {
- std::list <SWBuf> retVal;
- for (LocaleMap::iterator it = locales->begin(); it != locales->end(); it++)
- retVal.push_back((*it).second->getName());
-
- return retVal;
-}
-
-
-const char *LocaleMgr::translate(const char *text, const char *localeName) {
- SWLocale *target;
- if (!localeName) {
- localeName = getDefaultLocaleName();
- }
- target = getLocale(localeName);
- if (target)
- return target->translate(text);
- return text;
-}
-
-
-const char *LocaleMgr::getDefaultLocaleName() {
- return defaultLocaleName;
-}
-
-
-void LocaleMgr::setDefaultLocaleName(const char *name) {
- stdstr(&defaultLocaleName, name);
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/mgr/markupfiltmgr.cpp b/src/mgr/markupfiltmgr.cpp
deleted file mode 100644
index 07a9fb0..0000000
--- a/src/mgr/markupfiltmgr.cpp
+++ /dev/null
@@ -1,250 +0,0 @@
-/******************************************************************************
- * swmarkupmgr.cpp - implementaion of class MarkupFilterMgr, subclass of
- * used to transcode all module text to a requested
- * markup.
- *
- * Copyright 1998 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 <thmlplain.h>
-#include <gbfplain.h>
-#include <thmlgbf.h>
-#include <gbfthml.h>
-#include <thmlhtml.h>
-#include <gbfhtml.h>
-#include <plainhtml.h>
-#include <thmlhtmlhref.h>
-#include <gbfhtmlhref.h>
-#include <thmlrtf.h>
-#include <gbfrtf.h>
-#include <gbfosis.h>
-#include <thmlosis.h>
-#include <osisrtf.h>
-#include <osishtmlhref.h>
-#include <gbfwebif.h>
-#include <thmlwebif.h>
-#include <osiswebif.h>
-
-#include <markupfiltmgr.h>
-
-#include <swmgr.h>
-
-SWORD_NAMESPACE_START
-
-/******************************************************************************
- * MarkupFilterMgr Constructor - initializes instance of MarkupFilterMgr
- *
- * ENT:
- * enc - Encoding format to emit
- * mark - Markup format to emit
- */
-
-MarkupFilterMgr::MarkupFilterMgr (char mark, char enc)
- : EncodingFilterMgr(enc) {
-
- markup = mark;
-
- CreateFilters(markup);
-}
-
-
-/******************************************************************************
- * MarkupFilterMgr Destructor - Cleans up instance of MarkupFilterMgr
- */
-
-MarkupFilterMgr::~MarkupFilterMgr() {
- if (fromthml)
- delete (fromthml);
- if (fromgbf)
- delete (fromgbf);
- if (fromplain)
- delete (fromplain);
- if (fromosis)
- delete (fromosis);
-}
-
-/******************************************************************************
- * MarkupFilterMgr::Markup - sets/gets markup
- *
- * ENT: mark - new encoding or 0 to simply get the current markup
- *
- * RET: markup
- */
-char MarkupFilterMgr::Markup(char mark) {
- if (mark && mark != markup) {
- markup = mark;
- ModMap::const_iterator module;
-
- SWFilter * oldplain = fromplain;
- SWFilter * oldthml = fromthml;
- SWFilter * oldgbf = fromgbf;
- SWFilter * oldosis = fromosis;
-
- CreateFilters(markup);
-
- for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
- switch (module->second->Markup()) {
- case FMT_THML:
- if (oldthml != fromthml) {
- if (oldthml) {
- if (!fromthml) {
- module->second->RemoveRenderFilter(oldthml);
- }
- else {
- module->second->ReplaceRenderFilter(oldthml, fromthml);
- }
- }
- else if (fromthml) {
- module->second->AddRenderFilter(fromthml);
- }
- }
- break;
- case FMT_GBF:
- if (oldgbf != fromgbf) {
- if (oldgbf) {
- if (!fromgbf) {
- module->second->RemoveRenderFilter(oldgbf);
- }
- else {
- module->second->ReplaceRenderFilter(oldgbf, fromgbf);
- }
- }
- else if (fromgbf) {
- module->second->AddRenderFilter(fromgbf);
- }
- break;
- }
- case FMT_PLAIN:
- if (oldplain != fromplain) {
- if (oldplain) {
- if (!fromplain) {
- module->second->RemoveRenderFilter(oldplain);
- }
- else {
- module->second->ReplaceRenderFilter(oldplain, fromplain);
- }
- }
- else if (fromplain) {
- module->second->AddRenderFilter(fromplain);
- }
- break;
- }
- case FMT_OSIS:
- if (oldosis != fromosis) {
- if (oldosis) {
- if (!fromosis) {
- module->second->RemoveRenderFilter(oldosis);
- }
- else {
- module->second->ReplaceRenderFilter(oldosis, fromosis);
- }
- }
- else if (fromosis) {
- module->second->AddRenderFilter(fromosis);
- }
- break;
- }
- }
-
- if (oldthml)
- delete oldthml;
- if (oldgbf)
- delete oldgbf;
- if (oldplain)
- delete oldplain;
- if (oldosis)
- delete oldosis;
- }
- return markup;
-}
-
-void MarkupFilterMgr::AddRenderFilters(SWModule *module, ConfigEntMap &section) {
- switch (module->Markup()) {
- case FMT_THML:
- if (fromthml)
- module->AddRenderFilter(fromthml);
- break;
- case FMT_GBF:
- if (fromgbf)
- module->AddRenderFilter(fromgbf);
- break;
- case FMT_PLAIN:
- if (fromplain)
- module->AddRenderFilter(fromplain);
- break;
- case FMT_OSIS:
- if (fromosis)
- module->AddRenderFilter(fromosis);
- break;
- }
-}
-
-void MarkupFilterMgr::CreateFilters(char markup) {
-
- switch (markup) {
- case FMT_PLAIN:
- fromplain = NULL;
- fromthml = new ThMLPlain();
- fromgbf = new GBFPlain();
- fromosis = NULL;
- break;
- case FMT_THML:
- fromplain = NULL;
- fromthml = NULL;
- fromgbf = new GBFThML();
- fromosis = NULL;
- break;
- case FMT_GBF:
- fromplain = NULL;
- fromthml = new ThMLGBF();
- fromgbf = NULL;
- fromosis = NULL;
- break;
- case FMT_HTML:
- fromplain = new PLAINHTML();
- fromthml = new ThMLHTML();
- fromgbf = new GBFHTML();
- fromosis = NULL;
- break;
- case FMT_HTMLHREF:
- fromplain = new PLAINHTML();
- fromthml = new ThMLHTMLHREF();
- fromgbf = new GBFHTMLHREF();
- fromosis = new OSISHTMLHREF();
- break;
- case FMT_RTF:
- fromplain = NULL;
- fromthml = new ThMLRTF();
- fromgbf = new GBFRTF();
- fromosis = new OSISRTF();
- break;
- case FMT_OSIS:
- fromplain = NULL;
- fromthml = new ThMLOSIS();
- fromgbf = new GBFOSIS();
- fromosis = NULL;
- break;
- case FMT_WEBIF:
- fromplain = NULL;
- fromthml = new ThMLWEBIF();
- fromgbf = new GBFWEBIF();
- fromosis = new OSISWEBIF();
- break;
- }
-
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/mgr/swcacher.cpp b/src/mgr/swcacher.cpp
deleted file mode 100644
index ef04d98..0000000
--- a/src/mgr/swcacher.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/******************************************************************************
- * swcacher.h - definition of class SWCacher used to provide an interface for
- * objects that cache and want a standard interface for cleaning up.
- *
- * $Id: swcacher.cpp,v 1.2 2002/10/01 19:52:40 dglassey Exp $
- *
- * Copyright 1998 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 <swcacher.h>
-
-SWORD_NAMESPACE_START
-
-
-SWCacher::SWCacher() {
-}
-
-
-SWCacher::~SWCacher() {
-}
-
-
-void SWCacher::flush() {
-}
-
-long SWCacher::resourceConsumption() {
- return 0;
-}
-
-long SWCacher::lastAccess() {
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/mgr/swconfig.cpp b/src/mgr/swconfig.cpp
deleted file mode 100644
index d9eccc6..0000000
--- a/src/mgr/swconfig.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/******************************************************************************
- * swconfig.cpp - implementation of Class SWConfig used for saving and
- * retrieval of configuration information
- *
- * $Id: swconfig.cpp,v 1.13 2003/06/27 01:41:07 scribe Exp $
- *
- * Copyright 1998 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 <swconfig.h>
-#include <utilfuns.h>
-
-SWORD_NAMESPACE_START
-
-SWConfig::SWConfig(const char * ifilename) {
- filename = ifilename;
- Load();
-}
-
-
-SWConfig::~SWConfig() {
-}
-
-
-char SWConfig::getline(FILE *fp, SWBuf &line)
-{
- char retval = 0;
- char buf[255];
- int len;
-
- line = "";
-
- while (fgets(buf, 254, fp)) {
- while (buf[strlen(buf)-1] == '\n' || buf[strlen(buf)-1] == '\r')
- buf[strlen(buf)-1] = 0;
- len = strlen(buf);
- while (len>0 && buf[len-1] == '\n' || buf[len-1] == '\r')
- buf[(len--)-1] = 0;
-
- if (len>0 && buf[len-1] == '\\') {
- buf[(len--)-1] = 0;
- line += buf;
- continue;
- }
- line += buf;
-
- if (len < 253) {
- retval = 1;
- break;
- }
- }
- return retval;
-}
-
-
-void SWConfig::Load() {
- FILE *cfile;
- char *buf, *data;
- SWBuf line;
- ConfigEntMap cursect;
- SWBuf sectname;
- bool first = true;
-
- Sections.erase(Sections.begin(), Sections.end());
-
- if ((cfile = fopen(filename.c_str(), "r"))) {
- while (getline(cfile, line)) {
- buf = new char [ line.length() + 1 ];
- strcpy(buf, line.c_str());
- if (*strstrip(buf) == '[') {
- if (!first)
- Sections.insert(SectionMap::value_type(sectname, cursect));
- else first = false;
-
- cursect.erase(cursect.begin(), cursect.end());
-
- strtok(buf, "]");
- sectname = buf+1;
- }
- else {
- strtok(buf, "=");
- if ((*buf) && (*buf != '=')) {
- if ((data = strtok(NULL, "")))
- cursect.insert(ConfigEntMap::value_type(buf, strstrip(data)));
- else cursect.insert(ConfigEntMap::value_type(buf, ""));
- }
- }
- delete [] buf;
- }
- if (!first)
- Sections.insert(SectionMap::value_type(sectname, cursect));
-
- fclose(cfile);
- }
-}
-
-
-void SWConfig::Save() {
- FILE *cfile;
- SWBuf buf;
- SectionMap::iterator sit;
- ConfigEntMap::iterator entry;
- SWBuf sectname;
-
- if ((cfile = fopen(filename.c_str(), "w"))) {
-
- for (sit = Sections.begin(); sit != Sections.end(); sit++) {
- buf = "\n[";
- buf += (*sit).first.c_str();
- buf += "]\n";
- fputs(buf.c_str(), cfile);
- for (entry = (*sit).second.begin(); entry != (*sit).second.end(); entry++) {
- buf = (*entry).first.c_str();
- buf += "=";
- buf += (*entry).second.c_str();
- buf += "\n";
- fputs(buf.c_str(), cfile);
- }
- }
- fputs("\n", cfile); // so getline will find last line
- fclose(cfile);
- }
-}
-
-
-void SWConfig::augment(SWConfig &addFrom) {
-
- SectionMap::iterator section;
- ConfigEntMap::iterator entry, start, end;
-
- for (section = addFrom.Sections.begin(); section != addFrom.Sections.end(); section++) {
- for (entry = (*section).second.begin(); entry != (*section).second.end(); entry++) {
- start = Sections[section->first].lower_bound(entry->first);
- end = Sections[section->first].upper_bound(entry->first);
- if (start != end) {
- if (((++start) != end)
- || ((++(addFrom.Sections[section->first].lower_bound(entry->first))) != addFrom.Sections[section->first].upper_bound(entry->first))) {
- for (--start; start != end; start++) {
- if (!strcmp(start->second.c_str(), entry->second.c_str()))
- break;
- }
- if (start == end)
- Sections[(*section).first].insert(ConfigEntMap::value_type((*entry).first, (*entry).second));
- }
- else Sections[section->first][entry->first.c_str()] = entry->second.c_str();
- }
- else Sections[section->first][entry->first.c_str()] = entry->second.c_str();
- }
- }
-}
-
-
-ConfigEntMap & SWConfig::operator [] (const char *section) {
- return Sections[section];
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/mgr/swfiltermgr.cpp b/src/mgr/swfiltermgr.cpp
deleted file mode 100644
index 26ba98a..0000000
--- a/src/mgr/swfiltermgr.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/******************************************************************************
- * swfiltermgr.cpp - definition of class SWFilterMgr used as an interface to
- * manage filters on a module
- *
- * $Id: swfiltermgr.cpp,v 1.3 2002/10/01 19:52:40 dglassey Exp $
- *
- * Copyright 1998 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 <swfiltermgr.h>
-
-SWORD_NAMESPACE_START
-
-
-SWFilterMgr::SWFilterMgr() {
-}
-
-
-SWFilterMgr::~SWFilterMgr() {
-}
-
-
-void SWFilterMgr::setParentMgr(SWMgr *parentMgr) {
- this->parentMgr = parentMgr;
-}
-
-
-SWMgr *SWFilterMgr::getParentMgr() {
- return parentMgr;
-}
-
-
-void SWFilterMgr::AddGlobalOptions(SWModule * module, ConfigEntMap & section, ConfigEntMap::iterator start, ConfigEntMap::iterator end) {
-}
-
-
-void SWFilterMgr::AddLocalOptions(SWModule * module, ConfigEntMap & section, ConfigEntMap::iterator start, ConfigEntMap::iterator end) {
-}
-
-
-/**
-* Adds the encoding filters which are defined in "section" to the SWModule object "module".
-* @param module To this module the encoding filter(s) are added
-* @param section We use this section to get a list of filters we should apply to the module
-*/
-
-void SWFilterMgr::AddEncodingFilters(SWModule * module, ConfigEntMap & section) {
-}
-
-
-/**
-* Adds the render filters which are defined in "section" to the SWModule object "module".
-* @param module To this module the render filter(s) are added
-* @param section We use this section to get a list of filters we should apply to the module
-*/
-
-void SWFilterMgr::AddRenderFilters(SWModule * module, ConfigEntMap & section) {
-}
-
-
-/**
-* Adds the strip filters which are defined in "section" to the SWModule object "module".
-* @param module To this module the strip filter(s) are added
-* @param section We use this section to get a list of filters we should apply to the module
-*/
-
-void SWFilterMgr::AddStripFilters(SWModule * module, ConfigEntMap & section) {
-}
-
-
-/**
-* Adds the raw filters which are defined in "section" to the SWModule object "module".
-* @param module To this module the raw filter(s) are added
-* @param section We use this section to get a list of filters we should apply to the module
-*/
-
-void SWFilterMgr::AddRawFilters(SWModule * module, ConfigEntMap & section) {
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/mgr/swlocale.cpp b/src/mgr/swlocale.cpp
deleted file mode 100644
index 8cf1e96..0000000
--- a/src/mgr/swlocale.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/******************************************************************************
- * swlocale.cpp - implementation of Class SWLocale used for retrieval
- * of locale lookups
- *
- * $Id: swlocale.cpp,v 1.5 2002/10/01 19:52:40 dglassey Exp $
- *
- * Copyright 2000 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 <swlocale.h>
-#include <utilfuns.h>
-
-SWORD_NAMESPACE_START
-
-SWLocale::SWLocale(const char * ifilename) {
- ConfigEntMap::iterator confEntry;
-
- name = 0;
- description = 0;
- bookAbbrevs = 0;
- BMAX = 0;
- books = 0;
- localeSource = new SWConfig(ifilename);
-
- confEntry = localeSource->Sections["Meta"].find("Name");
- if (confEntry != localeSource->Sections["Meta"].end())
- stdstr(&name, (*confEntry).second.c_str());
-
- confEntry = localeSource->Sections["Meta"].find("Description");
- if (confEntry != localeSource->Sections["Meta"].end())
- stdstr(&description, (*confEntry).second.c_str());
-}
-
-
-SWLocale::~SWLocale() {
-
- delete localeSource;
-
- if (description)
- delete [] description;
-
- if (name)
- delete [] name;
-
- if (bookAbbrevs)
- delete [] bookAbbrevs;
-
- if (BMAX) {
- for (int i = 0; i < 2; i++)
- delete [] books[i];
- delete [] BMAX;
- delete [] books;
- }
-}
-
-
-const char *SWLocale::translate(const char *text) {
- LookupMap::iterator entry;
-
- entry = lookupTable.find(text);
-
- if (entry == lookupTable.end()) {
- ConfigEntMap::iterator confEntry;
- confEntry = localeSource->Sections["Text"].find(text);
- if (confEntry == localeSource->Sections["Text"].end())
- lookupTable.insert(LookupMap::value_type(text, text));
- else lookupTable.insert(LookupMap::value_type(text, (*confEntry).second.c_str()));
- entry = lookupTable.find(text);
- }
- return (*entry).second.c_str();
-}
-
-
-const char *SWLocale::getName() {
- return name;
-}
-
-
-const char *SWLocale::getDescription() {
- return description;
-}
-
-
-void SWLocale::augment(SWLocale &addFrom) {
- *localeSource += *addFrom.localeSource;
-}
-
-
-const struct abbrev *SWLocale::getBookAbbrevs() {
- static const char *nullstr = "";
- if (!bookAbbrevs) {
- ConfigEntMap::iterator it;
- int i;
- int size = localeSource->Sections["Book Abbrevs"].size();
- bookAbbrevs = new struct abbrev[size + 1];
- for (i = 0, it = localeSource->Sections["Book Abbrevs"].begin(); it != localeSource->Sections["Book Abbrevs"].end(); it++, i++) {
- bookAbbrevs[i].ab = (*it).first.c_str();
- bookAbbrevs[i].book = atoi((*it).second.c_str());
- }
- bookAbbrevs[i].ab = nullstr;
- bookAbbrevs[i].book = -1;
- }
-
- return bookAbbrevs;
-}
-
-
-void SWLocale::getBooks(char **iBMAX, struct sbook ***ibooks) {
- if (!BMAX) {
- BMAX = new char [2];
- BMAX[0] = VerseKey::builtin_BMAX[0];
- BMAX[1] = VerseKey::builtin_BMAX[1];
-
- books = new struct sbook *[2];
- books[0] = new struct sbook[BMAX[0]];
- books[1] = new struct sbook[BMAX[1]];
-
- for (int i = 0; i < 2; i++) {
- for (int j = 0; j < BMAX[i]; j++) {
- books[i][j] = VerseKey::builtin_books[i][j];
- books[i][j].name = translate(VerseKey::builtin_books[i][j].name);
- }
- }
- }
-
- *iBMAX = BMAX;
- *ibooks = books;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/mgr/swmgr.cpp b/src/mgr/swmgr.cpp
deleted file mode 100644
index 6207b60..0000000
--- a/src/mgr/swmgr.cpp
+++ /dev/null
@@ -1,1181 +0,0 @@
-/******************************************************************************
- * swmgr.cpp - implementaion of class SWMgr used to interact with an install
- * base of sword modules.
- *
- * $Id: swmgr.cpp,v 1.96 2003/12/05 21:44:33 scribe Exp $
- *
- * Copyright 1998 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 <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#include <unixstr.h>
-#endif
-#include <sys/stat.h>
-#ifndef _MSC_VER
-#include <iostream>
-#endif
-#include <dirent.h>
-
-#include <swmgr.h>
-#include <rawtext.h>
-#include <rawgenbook.h>
-#include <rawcom.h>
-#include <hrefcom.h>
-#include <rawld.h>
-#include <rawld4.h>
-#include <utilfuns.h>
-#include <gbfplain.h>
-#include <thmlplain.h>
-#include <osisplain.h>
-#include <gbfstrongs.h>
-#include <gbffootnotes.h>
-#include <gbfheadings.h>
-#include <gbfredletterwords.h>
-#include <gbfmorph.h>
-#include <osisheadings.h>
-#include <osisfootnotes.h>
-#include <osisstrongs.h>
-#include <osismorph.h>
-#include <osislemma.h>
-#include <osisredletterwords.h>
-#include <osisscripref.h>
-#include <thmlstrongs.h>
-#include <thmlfootnotes.h>
-#include <thmlheadings.h>
-#include <thmlmorph.h>
-#include <thmlvariants.h>
-#include <thmllemma.h>
-#include <thmlscripref.h>
-#include <cipherfil.h>
-#include <rawfiles.h>
-#include <ztext.h>
-#include <zld.h>
-#include <zcom.h>
-#include <lzsscomprs.h>
-#include <utf8greekaccents.h>
-#include <utf8cantillation.h>
-#include <utf8hebrewpoints.h>
-#include <greeklexattribs.h>
-#include <swfiltermgr.h>
-#ifndef EXCLUDEZLIB
-#include "zipcomprs.h"
-#endif
-
-
-#ifdef _ICU_
-#include <utf8transliterator.h>
-#endif
-
-SWORD_NAMESPACE_START
-
-#ifdef _ICU_
-bool SWMgr::isICU = true;
-#else
-bool SWMgr::isICU = false;
-#endif
-
-
-bool SWMgr::debug = false;
-
-#ifdef GLOBCONFPATH
-const char *SWMgr::globalConfPath = GLOBCONFPATH;
-#else
-const char *SWMgr::globalConfPath = "/etc/sword.conf:/usr/local/etc/sword.conf";
-#endif
-
-void SWMgr::init() {
- SWFilter *tmpFilter = 0;
- configPath = 0;
- prefixPath = 0;
- configType = 0;
- myconfig = 0;
- mysysconfig = 0;
- homeConfig = 0;
-
-
- cipherFilters.clear();
- optionFilters.clear();
- cleanupFilters.clear();
-
- tmpFilter = new ThMLVariants();
- optionFilters.insert(FilterMap::value_type("ThMLVariants", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new GBFStrongs();
- optionFilters.insert(FilterMap::value_type("GBFStrongs", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new GBFFootnotes();
- optionFilters.insert(FilterMap::value_type("GBFFootnotes", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new GBFRedLetterWords();
- optionFilters.insert(FilterMap::value_type("GBFRedLetterWords", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new GBFMorph();
- optionFilters.insert(FilterMap::value_type("GBFMorph", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new GBFHeadings();
- optionFilters.insert(FilterMap::value_type("GBFHeadings", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new OSISHeadings();
- optionFilters.insert(FilterMap::value_type("OSISHeadings", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new OSISStrongs();
- optionFilters.insert(FilterMap::value_type("OSISStrongs", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new OSISMorph();
- optionFilters.insert(FilterMap::value_type("OSISMorph", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new OSISLemma();
- optionFilters.insert(FilterMap::value_type("OSISLemma", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new OSISFootnotes();
- optionFilters.insert(FilterMap::value_type("OSISFootnotes", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new OSISScripref();
- optionFilters.insert(FilterMap::value_type("OSISScripref", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new OSISRedLetterWords();
- optionFilters.insert(FilterMap::value_type("OSISRedLetterWords", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new ThMLStrongs();
- optionFilters.insert(FilterMap::value_type("ThMLStrongs", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new ThMLFootnotes();
- optionFilters.insert(FilterMap::value_type("ThMLFootnotes", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new ThMLMorph();
- optionFilters.insert(FilterMap::value_type("ThMLMorph", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new ThMLHeadings();
- optionFilters.insert(FilterMap::value_type("ThMLHeadings", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new ThMLLemma();
- optionFilters.insert(FilterMap::value_type("ThMLLemma", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new ThMLScripref();
- optionFilters.insert(FilterMap::value_type("ThMLScripref", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new UTF8GreekAccents();
- optionFilters.insert(FilterMap::value_type("UTF8GreekAccents", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new UTF8HebrewPoints();
- optionFilters.insert(FilterMap::value_type("UTF8HebrewPoints", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new UTF8Cantillation();
- optionFilters.insert(FilterMap::value_type("UTF8Cantillation", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- tmpFilter = new GreekLexAttribs();
- optionFilters.insert(FilterMap::value_type("GreekLexAttribs", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
-// UTF8Transliterator needs to be handled differently because it should always available as an option, for all modules
-#ifdef _ICU_
- transliterator = new UTF8Transliterator();
- optionFilters.insert(FilterMap::value_type("UTF8Transliterator", transliterator));
- options.push_back(transliterator->getOptionName());
- cleanupFilters.push_back(transliterator);
-#endif
-
- gbfplain = new GBFPlain();
- cleanupFilters.push_back(gbfplain);
-
- thmlplain = new ThMLPlain();
- cleanupFilters.push_back(thmlplain);
-
- osisplain = new OSISPlain();
- cleanupFilters.push_back(osisplain);
-}
-
-
-SWMgr::SWMgr(SWFilterMgr *filterMgr) {
- commonInit(0, 0, true, filterMgr);
-}
-
-
-SWMgr::SWMgr(SWConfig *iconfig, SWConfig *isysconfig, bool autoload, SWFilterMgr *filterMgr) {
- commonInit(iconfig, isysconfig, autoload, filterMgr);
-}
-
-
-void SWMgr::commonInit(SWConfig * iconfig, SWConfig * isysconfig, bool autoload, SWFilterMgr *filterMgr) {
- this->filterMgr = filterMgr;
- if (filterMgr)
- filterMgr->setParentMgr(this);
-
- init();
-
- if (iconfig) {
- config = iconfig;
- myconfig = 0;
- }
- else config = 0;
- if (isysconfig) {
- sysconfig = isysconfig;
- mysysconfig = 0;
- }
- else sysconfig = 0;
-
- if (autoload)
- Load();
-}
-
-
-SWMgr::SWMgr(const char *iConfigPath, bool autoload, SWFilterMgr *filterMgr) {
-
- SWBuf path;
-
- this->filterMgr = filterMgr;
- if (filterMgr)
- filterMgr->setParentMgr(this);
-
- init();
-
- path = iConfigPath;
- int len = path.length();
- if ((len < 1) || (iConfigPath[len-1] != '\\') && (iConfigPath[len-1] != '/'))
- path += "/";
- if (FileMgr::existsFile(path.c_str(), "mods.conf")) {
- stdstr(&prefixPath, path.c_str());
- path += "mods.conf";
- stdstr(&configPath, path.c_str());
- }
- else {
- if (FileMgr::existsDir(path.c_str(), "mods.d")) {
- stdstr(&prefixPath, path.c_str());
- path += "mods.d";
- stdstr(&configPath, path.c_str());
- configType = 1;
- }
- }
-
- config = 0;
- sysconfig = 0;
-
- if (autoload && configPath)
- Load();
-}
-
-
-SWMgr::~SWMgr() {
-
- DeleteMods();
-
- for (FilterList::iterator it = cleanupFilters.begin(); it != cleanupFilters.end(); it++)
- delete (*it);
-
- if (homeConfig)
- delete homeConfig;
-
- if (myconfig)
- delete myconfig;
-
- if (prefixPath)
- delete [] prefixPath;
-
- if (configPath)
- delete [] configPath;
-
- if (filterMgr)
- delete filterMgr;
-}
-
-
-void SWMgr::findConfig(char *configType, char **prefixPath, char **configPath, std::list<SWBuf> *augPaths) {
- SWBuf path;
- ConfigEntMap::iterator entry;
- ConfigEntMap::iterator lastEntry;
-
- char *envsworddir = getenv ("SWORD_PATH");
- char *envhomedir = getenv ("HOME");
-
- *configType = 0;
-
-#ifndef _MSC_VER
- // check working directory
-if (debug)
- std::cerr << "Checking working directory for mods.conf...";
-#endif
-
- if (FileMgr::existsFile(".", "mods.conf")) {
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "found\n";
-#endif
-
- stdstr(prefixPath, "./");
- stdstr(configPath, "./mods.conf");
- return;
- }
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "\nChecking working directory for mods.d...";
-#endif
-
- if (FileMgr::existsDir(".", "mods.d")) {
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "found\n";
-#endif
-
- stdstr(prefixPath, "./");
- stdstr(configPath, "./mods.d");
- *configType = 1;
- return;
- }
-
-
- // check environment variable SWORD_PATH
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "\nChecking SWORD_PATH...";
-#endif
-
- if (envsworddir != NULL) {
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "found (" << envsworddir << ")\n";
-#endif
-
- path = envsworddir;
- if ((envsworddir[strlen(envsworddir)-1] != '\\') && (envsworddir[strlen(envsworddir)-1] != '/'))
- path += "/";
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "\nChecking $SWORD_PATH for mods.conf...";
-#endif
-
- if (FileMgr::existsFile(path.c_str(), "mods.conf")) {
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "found\n";
-#endif
-
- stdstr(prefixPath, path.c_str());
- path += "mods.conf";
- stdstr(configPath, path.c_str());
- return;
- }
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "\nChecking $SWORD_PATH for mods.d...";
-#endif
-
- if (FileMgr::existsDir(path.c_str(), "mods.d")) {
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "found\n";
-#endif
-
- stdstr(prefixPath, path.c_str());
- path += "mods.d";
- stdstr(configPath, path.c_str());
- *configType = 1;
- return;
- }
- }
-
-
- // check for systemwide globalConfPath
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "\nParsing " << globalConfPath << "...";
-#endif
-
- char *globPaths = 0;
- char *gfp;
- stdstr(&globPaths, globalConfPath);
- for (gfp = strtok(globPaths, ":"); gfp; gfp = strtok(0, ":")) {
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "\nChecking for " << gfp << "...";
-#endif
-
- if (FileMgr::existsFile(gfp))
- break;
- }
- SWBuf sysConfPath;
- if (gfp)
- sysConfPath = gfp;
-
- SWBuf homeDir = getenv ("HOME");
- if (homeDir.size() > 0) {
- if ((homeDir[homeDir.size()-1] != '\\') && (homeDir[homeDir.size()-1] != '/'))
- homeDir += "/";
- homeDir += ".sword/sword.conf";
- if (FileMgr::existsFile(homeDir)) {
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "\nOverriding any systemwide sword.conf with one found in users home directory." << gfp << "...";
-#endif
- sysConfPath = homeDir;
- }
- }
-
-
- if (sysConfPath.size()) {
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "found\n";
-#endif
-
- SWConfig etcconf(sysConfPath);
- if ((entry = etcconf.Sections["Install"].find("DataPath")) != etcconf.Sections["Install"].end()) {
- path = (*entry).second;
- if (((*entry).second.c_str()[strlen((*entry).second.c_str())-1] != '\\') && ((*entry).second.c_str()[strlen((*entry).second.c_str())-1] != '/'))
- path += "/";
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "DataPath in " << sysConfPath << " is set to: " << path;
-#endif
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "\nChecking for mods.conf in DataPath ";
-#endif
- if (FileMgr::existsFile(path.c_str(), "mods.conf")) {
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "found\n";
-#endif
-
- stdstr(prefixPath, path.c_str());
- path += "mods.conf";
- stdstr(configPath, path.c_str());
- *configType = 1;
- }
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "\nChecking for mods.d in DataPath ";
-#endif
-
- if (FileMgr::existsDir(path.c_str(), "mods.d")) {
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "found\n";
-#endif
-
- stdstr(prefixPath, path.c_str());
- path += "mods.d";
- stdstr(configPath, path.c_str());
- *configType = 1;
- }
- }
- if (augPaths) {
- augPaths->clear();
- entry = etcconf.Sections["Install"].lower_bound("AugmentPath");
- lastEntry = etcconf.Sections["Install"].upper_bound("AugmentPath");
- for (;entry != lastEntry; entry++) {
- path = entry->second;
- if ((entry->second.c_str()[strlen(entry->second.c_str())-1] != '\\') && (entry->second.c_str()[strlen(entry->second.c_str())-1] != '/'))
- path += "/";
- augPaths->push_back(path);
- }
- }
- }
-
- delete [] globPaths;
- if (*configType)
- return;
-
- // check ~/.sword/
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "\nChecking home directory for ~/.sword/mods.conf" << path;
-#endif
-
- if (envhomedir != NULL) {
- path = envhomedir;
- if ((envhomedir[strlen(envhomedir)-1] != '\\') && (envhomedir[strlen(envhomedir)-1] != '/'))
- path += "/";
- path += ".sword/";
- if (FileMgr::existsFile(path.c_str(), "mods.conf")) {
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << " found\n";
-#endif
-
- stdstr(prefixPath, path.c_str());
- path += "mods.conf";
- stdstr(configPath, path.c_str());
- return;
- }
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "\nChecking home directory for ~/.sword/mods.d" << path;
-#endif
-
- if (FileMgr::existsDir(path.c_str(), "mods.d")) {
-
-#ifndef _MSC_VER
-if (debug)
- std::cerr << "found\n";
-#endif
-
- stdstr(prefixPath, path.c_str());
- path += "mods.d";
- stdstr(configPath, path.c_str());
- *configType = 2;
- return;
- }
- }
-}
-
-
-void SWMgr::loadConfigDir(const char *ipath)
-{
- DIR *dir;
- struct dirent *ent;
- SWBuf newmodfile;
-
- if ((dir = opendir(ipath))) {
- rewinddir(dir);
- while ((ent = readdir(dir))) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- newmodfile = ipath;
- if ((ipath[strlen(ipath)-1] != '\\') && (ipath[strlen(ipath)-1] != '/'))
- newmodfile += "/";
- newmodfile += ent->d_name;
- if (config) {
- SWConfig tmpConfig(newmodfile.c_str());
- *config += tmpConfig;
- }
- else config = myconfig = new SWConfig(newmodfile.c_str());
- }
- }
- closedir(dir);
- if (!config) { // if no .conf file exist yet, create a default
- newmodfile = ipath;
- if ((ipath[strlen(ipath)-1] != '\\') && (ipath[strlen(ipath)-1] != '/'))
- newmodfile += "/";
- newmodfile += "globals.conf";
- config = myconfig = new SWConfig(newmodfile.c_str());
- }
- }
-}
-
-
-void SWMgr::augmentModules(const char *ipath) {
- SWBuf path = ipath;
- if ((ipath[strlen(ipath)-1] != '\\') && (ipath[strlen(ipath)-1] != '/'))
- path += "/";
- if (FileMgr::existsDir(path.c_str(), "mods.d")) {
- char *savePrefixPath = 0;
- char *saveConfigPath = 0;
- SWConfig *saveConfig = 0;
- stdstr(&savePrefixPath, prefixPath);
- stdstr(&prefixPath, path.c_str());
- path += "mods.d";
- stdstr(&saveConfigPath, configPath);
- stdstr(&configPath, path.c_str());
- saveConfig = config;
- config = myconfig = 0;
- loadConfigDir(configPath);
-
- CreateMods();
-
- stdstr(&prefixPath, savePrefixPath);
- delete []savePrefixPath;
- stdstr(&configPath, saveConfigPath);
- delete []saveConfigPath;
- (*saveConfig) += *config;
- homeConfig = myconfig;
- config = myconfig = saveConfig;
- }
-}
-
-
-/***********************************************************************
- * SWMgr::Load - loads actual modules
- *
- * RET: status - 0 = ok; -1 no config found; 1 = no modules installed
- *
- */
-
-signed char SWMgr::Load() {
- signed char ret = 0;
-
- if (!config) { // If we weren't passed a config object at construction, find a config file
- if (!configPath) // If we weren't passed a config path at construction...
- findConfig(&configType, &prefixPath, &configPath, &augPaths);
- if (configPath) {
- if (configType)
- loadConfigDir(configPath);
- else config = myconfig = new SWConfig(configPath);
- }
- }
-
- if (config) {
- SectionMap::iterator Sectloop, Sectend;
- ConfigEntMap::iterator Entryloop, Entryend;
-
- DeleteMods();
-
- for (Sectloop = config->Sections.lower_bound("Globals"), Sectend = config->Sections.upper_bound("Globals"); Sectloop != Sectend; Sectloop++) { // scan thru all 'Globals' sections
- for (Entryloop = (*Sectloop).second.lower_bound("AutoInstall"), Entryend = (*Sectloop).second.upper_bound("AutoInstall"); Entryloop != Entryend; Entryloop++) // scan thru all AutoInstall entries
- InstallScan((*Entryloop).second.c_str()); // Scan AutoInstall entry directory for new modules and install
- }
- if (configType) { // force reload on config object because we may have installed new modules
- delete myconfig;
- config = myconfig = 0;
- loadConfigDir(configPath);
- }
- else config->Load();
-
- CreateMods();
-
- for (std::list<SWBuf>::iterator pathIt = augPaths.begin(); pathIt != augPaths.end(); pathIt++) {
- augmentModules(pathIt->c_str());
- }
-// augment config with ~/.sword/mods.d if it exists ---------------------
- char *envhomedir = getenv ("HOME");
- if (envhomedir != NULL && configType != 2) { // 2 = user only
- SWBuf path = envhomedir;
- if ((envhomedir[strlen(envhomedir)-1] != '\\') && (envhomedir[strlen(envhomedir)-1] != '/'))
- path += "/";
- path += ".sword/";
- augmentModules(path.c_str());
- }
-// -------------------------------------------------------------------------
- if ( !Modules.size() ) // config exists, but no modules
- ret = 1;
-
- }
- else {
- SWLog::systemlog->LogError("SWMgr: Can't find 'mods.conf' or 'mods.d'. Try setting:\n\tSWORD_PATH=<directory containing mods.conf>\n\tOr see the README file for a full description of setup options (%s)", (configPath) ? configPath : "<configPath is null>");
- ret = -1;
- }
-
- return ret;
-}
-
-SWModule *SWMgr::CreateMod(const char *name, const char *driver, ConfigEntMap &section)
-{
- SWBuf description, datapath, misc1;
- ConfigEntMap::iterator entry;
- SWModule *newmod = 0;
- SWBuf lang, sourceformat, encoding;
- signed char direction, enc, markup;
-
- description = ((entry = section.find("Description")) != section.end()) ? (*entry).second : (SWBuf)"";
- lang = ((entry = section.find("Lang")) != section.end()) ? (*entry).second : (SWBuf)"en";
- sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (SWBuf)"";
- encoding = ((entry = section.find("Encoding")) != section.end()) ? (*entry).second : (SWBuf)"";
- datapath = prefixPath;
- if ((prefixPath[strlen(prefixPath)-1] != '\\') && (prefixPath[strlen(prefixPath)-1] != '/'))
- datapath += "/";
- misc1 += ((entry = section.find("DataPath")) != section.end()) ? (*entry).second : (SWBuf)"";
- char *buf = new char [ strlen(misc1.c_str()) + 1 ];
- char *buf2 = buf;
- strcpy(buf, misc1.c_str());
-// for (; ((*buf2) && ((*buf2 == '.') || (*buf2 == '/') || (*buf2 == '\\'))); buf2++);
- for (; ((*buf2) && ((*buf2 == '/') || (*buf2 == '\\'))); buf2++);
- if (!strncmp(buf2, "./", 2)) { //remove the leading ./ in the module data path to make it look better
- buf2 += 2;
- }
- if (*buf2)
- datapath += buf2;
- delete [] buf;
-
- section["AbsoluteDataPath"] = datapath;
-
- if (!stricmp(sourceformat.c_str(), "GBF"))
- markup = FMT_GBF;
- else if (!stricmp(sourceformat.c_str(), "ThML"))
- markup = FMT_THML;
- else if (!stricmp(sourceformat.c_str(), "OSIS"))
- markup = FMT_OSIS;
- else
- markup = FMT_GBF;
-
- if (!stricmp(encoding.c_str(), "SCSU"))
- enc = ENC_SCSU;
- else if (!stricmp(encoding.c_str(), "UTF-8")) {
- enc = ENC_UTF8;
- }
- else enc = ENC_LATIN1;
-
- if ((entry = section.find("Direction")) == section.end()) {
- direction = DIRECTION_LTR;
- }
- else if (!stricmp((*entry).second.c_str(), "rtol")) {
- direction = DIRECTION_RTL;
- }
- else if (!stricmp((*entry).second.c_str(), "bidi")) {
- direction = DIRECTION_BIDI;
- }
- else {
- direction = DIRECTION_LTR;
- }
-
- if ((!stricmp(driver, "zText")) || (!stricmp(driver, "zCom"))) {
- SWCompress *compress = 0;
- int blockType = CHAPTERBLOCKS;
- misc1 = ((entry = section.find("BlockType")) != section.end()) ? (*entry).second : (SWBuf)"CHAPTER";
- if (!stricmp(misc1.c_str(), "VERSE"))
- blockType = VERSEBLOCKS;
- else if (!stricmp(misc1.c_str(), "CHAPTER"))
- blockType = CHAPTERBLOCKS;
- else if (!stricmp(misc1.c_str(), "BOOK"))
- blockType = BOOKBLOCKS;
-
- misc1 = ((entry = section.find("CompressType")) != section.end()) ? (*entry).second : (SWBuf)"LZSS";
-#ifndef EXCLUDEZLIB
- if (!stricmp(misc1.c_str(), "ZIP"))
- compress = new ZipCompress();
- else
-#endif
- if (!stricmp(misc1.c_str(), "LZSS"))
- compress = new LZSSCompress();
-
- if (compress) {
- if (!stricmp(driver, "zText"))
- newmod = new zText(datapath.c_str(), name, description.c_str(), blockType, compress, 0, enc, direction, markup, lang.c_str());
- else newmod = new zCom(datapath.c_str(), name, description.c_str(), blockType, compress, 0, enc, direction, markup, lang.c_str());
- }
- }
-
- if (!stricmp(driver, "RawText")) {
- newmod = new RawText(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
- }
-
- // backward support old drivers
- if (!stricmp(driver, "RawGBF")) {
- newmod = new RawText(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
- }
-
- if (!stricmp(driver, "RawCom")) {
- newmod = new RawCom(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
- }
-
- if (!stricmp(driver, "RawFiles")) {
- newmod = new RawFiles(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
- }
-
- if (!stricmp(driver, "HREFCom")) {
- misc1 = ((entry = section.find("Prefix")) != section.end()) ? (*entry).second : (SWBuf)"";
- newmod = new HREFCom(datapath.c_str(), misc1.c_str(), name, description.c_str());
- }
-
- int pos; //used for position of final / in AbsoluteDataPath, but also set to 1 for modules types that need to strip module name
- if (!stricmp(driver, "RawLD")) {
- newmod = new RawLD(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
- pos = 1;
- }
-
- if (!stricmp(driver, "RawLD4")) {
- newmod = new RawLD4(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
- pos = 1;
- }
-
- if (!stricmp(driver, "zLD")) {
- SWCompress *compress = 0;
- int blockCount;
- misc1 = ((entry = section.find("BlockCount")) != section.end()) ? (*entry).second : (SWBuf)"200";
- blockCount = atoi(misc1.c_str());
- blockCount = (blockCount) ? blockCount : 200;
-
- misc1 = ((entry = section.find("CompressType")) != section.end()) ? (*entry).second : (SWBuf)"LZSS";
-#ifndef EXCLUDEZLIB
- if (!stricmp(misc1.c_str(), "ZIP"))
- compress = new ZipCompress();
- else
-#endif
- if (!stricmp(misc1.c_str(), "LZSS"))
- compress = new LZSSCompress();
-
- if (compress) {
- newmod = new zLD(datapath.c_str(), name, description.c_str(), blockCount, compress, 0, enc, direction, markup, lang.c_str());
- }
- pos = 1;
- }
-
- if (!stricmp(driver, "RawGenBook")) {
- newmod = new RawGenBook(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
- pos = 1;
- }
-
- if (pos == 1) {
- SWBuf &dp = section["AbsoluteDataPath"];
- for (int i = dp.length() - 1; i; i--) {
- if (dp[i] == '/') {
- dp.setSize(i);
- break;
- }
- }
- }
-
- // if a specific module type is set in the config, use this
- if ((entry = section.find("Type")) != section.end())
- newmod->Type(entry->second.c_str());
-
- newmod->setConfig(&section);
- return newmod;
-}
-
-
-void SWMgr::AddGlobalOptions(SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end) {
- for (;start != end; start++) {
- FilterMap::iterator it;
- it = optionFilters.find((*start).second);
- if (it != optionFilters.end()) {
- module->AddOptionFilter((*it).second); // add filter to module and option as a valid option
- StringList::iterator loop;
- for (loop = options.begin(); loop != options.end(); loop++) {
- if (!strcmp((*loop).c_str(), (*it).second->getOptionName()))
- break;
- }
- if (loop == options.end()) // if we have not yet included the option
- options.push_back((*it).second->getOptionName());
- }
- }
- if (filterMgr)
- filterMgr->AddGlobalOptions(module, section, start, end);
-#ifdef _ICU_
- module->AddOptionFilter(transliterator);
-#endif
-}
-
-
-void SWMgr::AddLocalOptions(SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end)
-{
- for (;start != end; start++) {
- FilterMap::iterator it;
- it = optionFilters.find((*start).second);
- if (it != optionFilters.end()) {
- module->AddOptionFilter((*it).second); // add filter to module
- }
- }
-
- if (filterMgr)
- filterMgr->AddLocalOptions(module, section, start, end);
-}
-
-
-void SWMgr::AddRawFilters(SWModule *module, ConfigEntMap &section) {
- SWBuf sourceformat, cipherKey;
- ConfigEntMap::iterator entry;
-
- cipherKey = ((entry = section.find("CipherKey")) != section.end()) ? (*entry).second : (SWBuf)"";
- if (cipherKey.length()) {
- SWFilter *cipherFilter = new CipherFilter(cipherKey.c_str());
- cipherFilters.insert(FilterMap::value_type(module->Name(), cipherFilter));
- cleanupFilters.push_back(cipherFilter);
- module->AddRawFilter(cipherFilter);
- }
-
- if (filterMgr)
- filterMgr->AddRawFilters(module, section);
-}
-
-
-void SWMgr::AddEncodingFilters(SWModule *module, ConfigEntMap &section) {
- if (filterMgr)
- filterMgr->AddEncodingFilters(module, section);
-}
-
-
-void SWMgr::AddRenderFilters(SWModule *module, ConfigEntMap &section) {
- SWBuf sourceformat;
- ConfigEntMap::iterator entry;
-
- sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (SWBuf)"";
-
- // Temporary: To support old module types
- // TODO: Remove at 1.6.0 release?
- if (!sourceformat.length()) {
- sourceformat = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (SWBuf)"";
- if (!stricmp(sourceformat.c_str(), "RawGBF"))
- sourceformat = "GBF";
- else sourceformat = "";
- }
-
-// process module - eg. follows
-// if (!stricmp(sourceformat.c_str(), "GBF")) {
-// module->AddRenderFilter(gbftortf);
-// }
-
- if (filterMgr)
- filterMgr->AddRenderFilters(module, section);
-
-}
-
-
-void SWMgr::AddStripFilters(SWModule *module, ConfigEntMap &section)
-{
- SWBuf sourceformat;
- ConfigEntMap::iterator entry;
-
- sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (SWBuf)"";
- // Temporary: To support old module types
- if (!sourceformat.length()) {
- sourceformat = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (SWBuf)"";
- if (!stricmp(sourceformat.c_str(), "RawGBF"))
- sourceformat = "GBF";
- else sourceformat = "";
- }
-
- if (!stricmp(sourceformat.c_str(), "GBF")) {
- module->AddStripFilter(gbfplain);
- }
- else if (!stricmp(sourceformat.c_str(), "ThML")) {
- module->AddStripFilter(thmlplain);
- }
- else if (!stricmp(sourceformat.c_str(), "OSIS")) {
- module->AddStripFilter(osisplain);
- }
-
- if (filterMgr)
- filterMgr->AddStripFilters(module, section);
-
-}
-
-
-void SWMgr::CreateMods() {
- SectionMap::iterator it;
- ConfigEntMap::iterator start;
- ConfigEntMap::iterator end;
- ConfigEntMap::iterator entry;
- SWModule *newmod;
- SWBuf driver, misc1;
- for (it = config->Sections.begin(); it != config->Sections.end(); it++) {
- ConfigEntMap &section = (*it).second;
- newmod = 0;
-
- driver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (SWBuf)"";
- if (driver.length()) {
- newmod = CreateMod((*it).first, driver, section);
- if (newmod) {
- start = (*it).second.lower_bound("GlobalOptionFilter");
- end = (*it).second.upper_bound("GlobalOptionFilter");
- AddGlobalOptions(newmod, section, start, end);
-
- start = (*it).second.lower_bound("LocalOptionFilter");
- end = (*it).second.upper_bound("LocalOptionFilter");
- AddLocalOptions(newmod, section, start, end);
-
- AddRawFilters(newmod, section);
- AddStripFilters(newmod, section);
- AddRenderFilters(newmod, section);
- AddEncodingFilters(newmod, section);
-
- Modules.insert(ModMap::value_type(newmod->Name(), newmod));
- }
- }
- }
-}
-
-
-void SWMgr::DeleteMods() {
-
- ModMap::iterator it;
-
- for (it = Modules.begin(); it != Modules.end(); it++)
- delete (*it).second;
-
- Modules.clear();
-}
-
-
-void SWMgr::InstallScan(const char *dirname)
-{
- DIR *dir;
- struct dirent *ent;
- int conffd = 0;
- SWBuf newmodfile;
- SWBuf targetName;
-
- if (!access(dirname, 04)) {
- if ((dir = opendir(dirname))) {
- rewinddir(dir);
- while ((ent = readdir(dir))) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- newmodfile = dirname;
- if ((dirname[strlen(dirname)-1] != '\\') && (dirname[strlen(dirname)-1] != '/'))
- newmodfile += "/";
- newmodfile += ent->d_name;
- if (configType) {
- if (config > 0)
- close(conffd);
- targetName = configPath;
- if ((configPath[strlen(configPath)-1] != '\\') && (configPath[strlen(configPath)-1] != '/'))
- targetName += "/";
- targetName += ent->d_name;
- conffd = open(targetName.c_str(), O_WRONLY|O_CREAT, S_IREAD|S_IWRITE);
- }
- else {
- if (conffd < 1) {
- conffd = open(config->filename.c_str(), O_WRONLY|O_APPEND);
- if (conffd > 0)
- lseek(conffd, 0L, SEEK_END);
- }
- }
- AddModToConfig(conffd, newmodfile.c_str());
- unlink(newmodfile.c_str());
- }
- }
- if (conffd > 0)
- close(conffd);
- closedir(dir);
- }
- }
-}
-
-
-char SWMgr::AddModToConfig(int conffd, const char *fname)
-{
- int modfd;
- char ch;
-
- SWLog::systemlog->LogTimedInformation("Found new module [%s]. Installing...", fname);
- modfd = open(fname, O_RDONLY);
- ch = '\n';
- write(conffd, &ch, 1);
- while (read(modfd, &ch, 1) == 1)
- write(conffd, &ch, 1);
- ch = '\n';
- write(conffd, &ch, 1);
- close(modfd);
- return 0;
-}
-
-
-void SWMgr::setGlobalOption(const char *option, const char *value)
-{
- for (FilterMap::iterator it = optionFilters.begin(); it != optionFilters.end(); it++) {
- if ((*it).second->getOptionName()) {
- if (!stricmp(option, (*it).second->getOptionName()))
- (*it).second->setOptionValue(value);
- }
- }
-}
-
-
-const char *SWMgr::getGlobalOption(const char *option)
-{
- for (FilterMap::iterator it = optionFilters.begin(); it != optionFilters.end(); it++) {
- if ((*it).second->getOptionName()) {
- if (!stricmp(option, (*it).second->getOptionName()))
- return (*it).second->getOptionValue();
- }
- }
- return 0;
-}
-
-
-const char *SWMgr::getGlobalOptionTip(const char *option)
-{
- for (FilterMap::iterator it = optionFilters.begin(); it != optionFilters.end(); it++) {
- if ((*it).second->getOptionName()) {
- if (!stricmp(option, (*it).second->getOptionName()))
- return (*it).second->getOptionTip();
- }
- }
- return 0;
-}
-
-
-StringList SWMgr::getGlobalOptions()
-{
- return options;
-}
-
-
-StringList SWMgr::getGlobalOptionValues(const char *option)
-{
- StringList options;
- for (FilterMap::iterator it = optionFilters.begin(); it != optionFilters.end(); it++) {
- if ((*it).second->getOptionName()) {
- if (!stricmp(option, (*it).second->getOptionName())) {
- options = (*it).second->getOptionValues();
- break; // just find the first one. All option filters with the same option name should expect the same values
- }
- }
- }
- return options;
-}
-
-
-signed char SWMgr::setCipherKey(const char *modName, const char *key) {
- FilterMap::iterator it;
- ModMap::iterator it2;
-
- // check for filter that already exists
- it = cipherFilters.find(modName);
- if (it != cipherFilters.end()) {
- ((CipherFilter *)(*it).second)->getCipher()->setCipherKey(key);
- return 0;
- }
- // check if module exists
- else {
- it2 = Modules.find(modName);
- if (it2 != Modules.end()) {
- SWFilter *cipherFilter = new CipherFilter(key);
- cipherFilters.insert(FilterMap::value_type(modName, cipherFilter));
- cleanupFilters.push_back(cipherFilter);
- (*it2).second->AddRawFilter(cipherFilter);
- return 0;
- }
- }
- return -1;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/mgr/swsearchable.cpp b/src/mgr/swsearchable.cpp
deleted file mode 100644
index d81375d..0000000
--- a/src/mgr/swsearchable.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************
- * swsearchable.h - definition of class SWSearchable used to provide an
- * interface for objects that be searched.
- *
- * $Id: swsearchable.cpp,v 1.1 2003/08/29 06:00:16 scribe Exp $
- *
- * Copyright 1998 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 <swsearchable.h>
-
-SWORD_NAMESPACE_START
-
-void SWSearchable::nullPercent(char percent, void *percentUserData) {}
-
-SWSearchable::SWSearchable() {
-}
-
-
-SWSearchable::~SWSearchable() {
-}
-
- // special search framework
-signed char SWSearchable::createSearchFramework() {
- return 0;
-}
-
-
-SWORD_NAMESPACE_END
diff --git a/src/mgr/swsourcemgr.cpp b/src/mgr/swsourcemgr.cpp
deleted file mode 100644
index 58df9f0..0000000
--- a/src/mgr/swsourcemgr.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/******************************************************************************
- * swsourcemgr.cpp - implementaion of class SWMgr used to interact with an install
- * base of sword modules.
- *
- * $Id: swsourcemgr.cpp,v 1.2 2003/06/27 01:41:07 scribe Exp $
- *
- * Copyright 2002 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 "swsourcemgr.h"
- #include "filemgr.h"
- #include "utilstr.h"
- #include "swconfig.h"
- #include <dirent.h>
-
- SWORD_NAMESPACE_START
-
- SWSourceMgr::SWSourceMgr(const char *iConfigPath) {
- SWBuf path;
-
- //init();
-
- path = iConfigPath;
- if ((iConfigPath[strlen(iConfigPath)-1] != '\\') && (iConfigPath[strlen(iConfigPath)-1] != '/'))
- path += "/";
- if (FileMgr::existsFile(path.c_str(), "mods.conf")) {
- stdstr(&prefixPath, path.c_str());
- path += "mods.conf";
- stdstr(&configPath, path.c_str());
- }
- else {
- if (FileMgr::existsDir(path.c_str(), "mods.d")) {
- stdstr(&prefixPath, path.c_str());
- path += "mods.d";
- stdstr(&configPath, path.c_str());
- configType = 1;
- }
- }
-
- if (configPath)
- loadConfigDir(configPath);
-}
-
-void SWSourceMgr::loadConfigDir(const char *ipath)
-{
- DIR *dir;
- struct dirent *ent;
- SWBuf newmodfile;
-
- if ((dir = opendir(ipath))) {
- rewinddir(dir);
- while ((ent = readdir(dir))) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- newmodfile = ipath;
- if ((ipath[strlen(ipath)-1] != '\\') && (ipath[strlen(ipath)-1] != '/'))
- newmodfile += "/";
- newmodfile += ent->d_name;
- if (config) {
- SWConfig tmpConfig(newmodfile.c_str());
- *config += tmpConfig;
- }
- else config = myconfig = new SWConfig(newmodfile.c_str());
- }
- }
- closedir(dir);
- if (!config) { // if no .conf file exist yet, create a default
- newmodfile = ipath;
- if ((ipath[strlen(ipath)-1] != '\\') && (ipath[strlen(ipath)-1] != '/'))
- newmodfile += "/";
- newmodfile += "globals.conf";
- config = myconfig = new SWConfig(newmodfile.c_str());
- }
- }
-}
-
-
-
- SWORD_NAMESPACE_END
diff --git a/src/modules/Makefile b/src/modules/Makefile
deleted file mode 100644
index ef8eccd..0000000
--- a/src/modules/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-root := ../..
-
-all:
- make -C ${root}
diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am
deleted file mode 100644
index 944dc18..0000000
--- a/src/modules/Makefile.am
+++ /dev/null
@@ -1,10 +0,0 @@
-modulesdir = $(top_srcdir)/src/modules
-
-libsword_la_SOURCES += $(modulesdir)/swmodule.cpp
-
-include ../src/modules/common/Makefile.am
-include ../src/modules/filters/Makefile.am
-include ../src/modules/genbook/Makefile.am
-include ../src/modules/texts/Makefile.am
-include ../src/modules/comments/Makefile.am
-include ../src/modules/lexdict/Makefile.am
diff --git a/src/modules/comments/Makefile b/src/modules/comments/Makefile
deleted file mode 100644
index 1a2d00d..0000000
--- a/src/modules/comments/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-root := ../../..
-
-all:
- make -C ${root}
diff --git a/src/modules/comments/Makefile.am b/src/modules/comments/Makefile.am
deleted file mode 100644
index 1568544..0000000
--- a/src/modules/comments/Makefile.am
+++ /dev/null
@@ -1,8 +0,0 @@
-commentsdir = $(top_srcdir)/src/modules/comments
-
-libsword_la_SOURCES += $(commentsdir)/swcom.cpp
-
-include ../src/modules/comments/rawcom/Makefile.am
-include ../src/modules/comments/rawfiles/Makefile.am
-include ../src/modules/comments/zcom/Makefile.am
-include ../src/modules/comments/hrefcom/Makefile.am
diff --git a/src/modules/comments/hrefcom/Makefile b/src/modules/comments/hrefcom/Makefile
deleted file mode 100644
index 35d6648..0000000
--- a/src/modules/comments/hrefcom/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-root := ../../../..
-
-all:
- make -C ${root}
diff --git a/src/modules/comments/hrefcom/Makefile.am b/src/modules/comments/hrefcom/Makefile.am
deleted file mode 100644
index a6a2115..0000000
--- a/src/modules/comments/hrefcom/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
-hrefcomdir = $(top_srcdir)/src/modules/comments/hrefcom
-
-libsword_la_SOURCES += $(hrefcomdir)/hrefcom.cpp
-
diff --git a/src/modules/comments/hrefcom/hrefcom.cpp b/src/modules/comments/hrefcom/hrefcom.cpp
deleted file mode 100644
index 42b2745..0000000
--- a/src/modules/comments/hrefcom/hrefcom.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/******************************************************************************
- * hrefcom.cpp - code for class 'HREFCom'- a module that produces HTML HREFs
- * pointing to actual text desired. Uses standard
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
- */
-
-
-#include <ctype.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#include <utilfuns.h>
-#include <rawverse.h>
-#include <hrefcom.h>
-
-SWORD_NAMESPACE_START
-
- /******************************************************************************
- * HREFCom Constructor - Initializes data for instance of HREFCom
- *
- * ENT: iname - Internal name for module
- * iprefix - string to prepend to each HREF (e.g. "file://mods/com/jfb/")
- * idesc - Name to display to user for module
- * idisp - Display object to use for displaying
- */
-
-HREFCom::HREFCom(const char *ipath, const char *iprefix, const char *iname, const char *idesc, SWDisplay *idisp) : RawVerse(ipath), SWCom(iname, idesc, idisp)
-{
- prefix = 0;
- stdstr(&prefix, iprefix);
-}
-
-
-/******************************************************************************
- * HREFCom Destructor - Cleans up instance of HREFCom
- */
-
-HREFCom::~HREFCom()
-{
- if (prefix)
- delete [] prefix;
-}
-
-
-/******************************************************************************
- * HREFCom::operator char * - Returns the correct verse when char * cast
- * is requested
- *
- * RET: string buffer with verse
- */
-
-SWBuf &HREFCom::getRawEntryBuf() {
- long start;
- unsigned short size;
- VerseKey *key = 0;
-
-#ifndef _WIN32_WCE
- try {
-#endif
- key = SWDYNAMIC_CAST(VerseKey, this->key);
-#ifndef _WIN32_WCE
- }
- catch ( ... ) {}
-#endif
- if (!key)
- key = new VerseKey(this->key);
-
- findOffset(key->Testament(), key->Index(), &start, &size);
- entrySize = size; // support getEntrySize call
-
- SWBuf tmpbuf;
-
- readText(key->Testament(), start, size, tmpbuf);
- entryBuf = prefix;
- entryBuf += tmpbuf.c_str();
- prepText(entryBuf);
-
- if (key != this->key)
- delete key;
-
- return entryBuf;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/comments/hrefcom/jfbgen.cpp b/src/modules/comments/hrefcom/jfbgen.cpp
deleted file mode 100644
index 8b66a60..0000000
--- a/src/modules/comments/hrefcom/jfbgen.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/*****************************************************************************
- *
- */
-
-#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>
-
-#ifndef O_BINARY
- #define O_BINARY 0
-#endif
-
-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;
-
-
-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);
-
- key1 = key2 = key3 = "Genesis 1:1";
-
- openfiles();
-
- num1 = key1.Chapter();
- num2 = key1.Verse();
-
- 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);
-}
-
-
-/**************************************************************************
- * 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++;
-}
-
-
-static VerseKey inckey = "Genesis 1:1";
-
-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;
- char data[256];
- char *bookabrev[66] = {"Ge", "Ex", "Le", "Nu", "De", "Jos", "Jud", "Ru",
- "1Sa", "2Sa", "1Ki", "2Ki", "1Ch", "2Ch", "Ezr", "Ne", "Es",
- "Job", "Ps", "Pr", "Ec", "So", "Isa", "Jer", "La", "Eze", "Da",
- "Ho", "Joe", "Am", "Ob", "Jon", "Mic", "Na", "Heb", "Zep",
- "Hag", "Zec", "Mal",
- "Mt", "Mr", "Lu", "Joh", "Ac", "Ro", "1Co", "2Co", "Ga",
- "Eph", "Php", "Col", "1Th", "2Th", "1Ti", "2Ti", "Tit", "Phm",
- "Heb", "Jas", "1Pe", "2Pe", "1Jo", "2Jo", "3Jo", "Jude", "Re" };
-
- 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();
-
- sprintf(data, "JFB%.2d.htm#%s%d_%d", inckey.Book() + ((inckey.Testament()>1)?39:0), bookabrev[inckey.Book() + ((inckey.Testament()>1)?39:0)-1], inckey.Chapter(), inckey.Verse());
- write(fp, data, strlen(data));
-
- *size = lseek(fp, 0, SEEK_CUR) - *offset;
- write(fp, "\n", 1);
- return 0;
- }
- return 1;
-}
-
-
-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)) == -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)) == -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)) == -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)) == -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 !=1) {
- fprintf(stderr, "usage: %s\n", argv[0]);
- exit(1);
- }
-}
diff --git a/src/modules/comments/rawcom/Makefile b/src/modules/comments/rawcom/Makefile
deleted file mode 100644
index 35d6648..0000000
--- a/src/modules/comments/rawcom/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-root := ../../../..
-
-all:
- make -C ${root}
diff --git a/src/modules/comments/rawcom/Makefile.am b/src/modules/comments/rawcom/Makefile.am
deleted file mode 100644
index 901cf6b..0000000
--- a/src/modules/comments/rawcom/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
-rawcomdir = $(top_srcdir)/src/modules/comments/rawcom
-
-libsword_la_SOURCES += $(rawcomdir)/rawcom.cpp
-
diff --git a/src/modules/comments/rawcom/mhcidx.cpp b/src/modules/comments/rawcom/mhcidx.cpp
deleted file mode 100644
index df16f55..0000000
--- a/src/modules/comments/rawcom/mhcidx.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/*****************************************************************************
- *
- * This code wreaks but works (at least for MHC). Good luck!
- */
-
-#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>
-
-
-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(char *fname);
-void checkparams(int argc, char **argv);
-
-
-VerseKey key1, key2, key3;
-int fp, vfp, cfp, bfp;
-long chapoffset;
-short chapsize;
-char testmnt;
-
-
-main(int argc, char **argv)
-{
- long pos, offset;
- int num1, num2, rangemax, curbook = 0, curchap = 0, curverse = 0;
- char buf[127], startflag = 0;
- short size, tmp;
-
- checkparams(argc, argv);
-
- openfiles(argv[1]);
-
- testmnt = key1.Testament();
- 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);
-
- while(!findbreak(fp, &offset, &num1, &num2, &rangemax, &size)) {
- if (num2) {
- key2.Verse(1);
- key2.Chapter(num1);
- key2.Verse(num2);
- }
- else {
- key2.Verse(1);
- if (!startflag) {
- startflag = 1;
- }
- else {
- if (num1 <= key2.Chapter()) { // new book
- key2.Chapter(1);
- key2.Book(key2.Book()+1);
- }
- }
- key2.Chapter(num1);
- printf("Found Chapter Break: %d ('%s')\n", num1, (const char *)key2);
- chapoffset = offset;
- chapsize = size;
- continue;
- }
-
- key3 = key2;
- key3 += (rangemax - key3.Verse());
-
- writeidx(key1, key2, key3, offset, size);
- }
- close(vfp);
- close(cfp);
- close(bfp);
- close(fp);
-}
-
-
-/**************************************************************************
- * 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;
-
- for (; ((key1 <= key3) && (key1.Error() != KEYERR_OUTOFBOUNDS) && (key1.Testament() == testmnt)); key1+=1) {
- 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);
- }
- }
-}
-
-
-char startentry(char *buf)
-{
- char loop;
-
- if (buf[0] != 10)
- return 0;
- if (buf[1] != '#')
- return 0;
- if (!isdigit(buf[2]))
- return 0;
- for (loop = 3; loop < 7; loop++) {
- if (buf[loop] == ' ')
- break;
- if ((!isdigit(buf[loop])) && (buf[loop] != ',') && (buf[loop] != '-'))
- return 0;
- }
- return 1;
-}
-
-
-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;
-
- memset(buf, ' ', 7);
-
- while (1) {
- if (startentry(buf)) {
- memset(buf, ' ', 2);
- for (loop = 2; loop < 7; loop++) {
- if ((buf[loop] == '-') || (buf[loop] == ',') || (buf[loop] == ' ')) {
- buf[loop] = 0;
- *num2 = atoi(buf);
- break;
- }
- }
- for (ch = loop + 1; ch < 7; ch++) {
- if (buf[ch] == ' ') {
- break;
- }
- }
- buf[ch] = 0;
- *rangemax = atoi(&buf[loop+1]);
- if (!*rangemax)
- *rangemax = *num2;
- *offset = lseek(fp, 0, SEEK_CUR) - 5;
- if (size) {
- if (findbreak(fp, &offset2, &ch2, &vs2, &rm2, 0)) {
- *size = (short) (lseek(fp, 0, SEEK_END) - (*offset));
- }
- else {
- if (vs2) {
- *size = (offset2 - (*offset)) - 3;
- }
- else {
- sprintf(buf2, "$-$-$- XX:%d", ch2);
- *size = (offset2 - (*offset)) - ((strlen(buf2) + 4));
- }
- }
- lseek(fp, *offset, SEEK_SET);
- }
- return 0;
- }
-
- if (!strncmp(buf, "$-$-$-", 6)) {
- memset(buf2, 0, 7);
- loop = 0;
- while ((read(fp, &buf2[loop], 1) == 1) && (loop < 7)) {
- if ((buf2[loop] == 10) || (buf2[loop] == 13)) {
- buf2[loop] = 0;
- break;
- }
- loop++;
- }
- while (read(fp, &ch, 1) == 1) {
- if (ch == '*')
- break;
- }
-
- *offset = lseek(fp, 0, SEEK_CUR) - 1;
- *num2 = 0;
- for (loop = strlen(buf2) - 1; loop; loop--) {
- if (buf2[loop] == ':')
- break;
- }
- *num1 = atoi(&buf2[loop+1]);
- printf("Chapter marker: %s\n", buf2);
- if (size) {
- if (findbreak(fp, &offset2, &ch2, &vs2, &rm2, 0)) {
- *size = (short) (lseek(fp, 0, SEEK_END) - (*offset));
- }
- else {
- if (vs2) {
- *size = (offset2 - (*offset)) - 3;
- }
- else {
- sprintf(buf2, "$-$-$- XX:%d", ch2);
- *size = (offset2 - (*offset)) - ((strlen(buf2) + 4));
- }
- }
- lseek(fp, *offset, SEEK_SET);
- }
- return 0;
- }
-
-
- memmove(buf, &buf[1], 6);
- if (read(fp, &buf[6], 1) != 1)
- return 1;
- }
-}
-
-
-void openfiles(char *fname)
-{
- char buf[255];
-
- if ((fp = open(fname, O_RDONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", fname);
- exit(1);
- }
-
- sprintf(buf, "%s.vss", fname);
- if ((vfp = open(buf, O_CREAT|O_WRONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", buf);
- exit(1);
- }
-
- sprintf(buf, "%s.cps", fname);
- if ((cfp = open(buf, O_CREAT|O_WRONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", buf);
- exit(1);
- }
-
- sprintf(buf, "%s.bks", fname);
- if ((bfp = open(buf, O_CREAT|O_WRONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", buf);
- exit(1);
- }
-}
-
-
-void checkparams(int argc, char **argv)
-{
- if (argc < 2) {
- fprintf(stderr, "usage: %s <file to process> [nt - for new testmt file]\n", argv[0]);
- exit(1);
- }
- if (argc == 3)
- key1 = key2 = key3 = "Matthew 1:1";
- else key1 = key2 = key3 = "Genesis 1:1";
-}
diff --git a/src/modules/comments/rawcom/rawcom.cpp b/src/modules/comments/rawcom/rawcom.cpp
deleted file mode 100644
index e34af2e..0000000
--- a/src/modules/comments/rawcom/rawcom.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-/******************************************************************************
- * rawcom.cpp - code for class 'RawCom'- a module that reads raw commentary
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
- */
-
-
-#include <ctype.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#include <utilfuns.h>
-#include <rawverse.h>
-#include <rawcom.h>
-
-SWORD_NAMESPACE_START
-
- /******************************************************************************
- * RawCom Constructor - Initializes data for instance of RawCom
- *
- * ENT: iname - Internal name for module
- * idesc - Name to display to user for module
- * idisp - Display object to use for displaying
- */
-
-RawCom::RawCom(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding encoding, SWTextDirection dir, SWTextMarkup markup, const char* ilang)
- : RawVerse(ipath),
- SWCom(iname, idesc, idisp, encoding, dir, markup, ilang){
-}
-
-
-/******************************************************************************
- * RawCom Destructor - Cleans up instance of RawCom
- */
-
-RawCom::~RawCom()
-{
-}
-
-
-/******************************************************************************
- * RawCom::getRawEntry() - Returns the correct verse when char * cast
- * is requested
- *
- * RET: string buffer with verse
- */
-
-SWBuf &RawCom::getRawEntryBuf() {
- long start = 0;
- unsigned short size = 0;
- VerseKey *key = &getVerseKey();
-
- findOffset(key->Testament(), key->Index(), &start, &size);
- entrySize = size; // support getEntrySize call
-
- entryBuf = "";
- readText(key->Testament(), start, size, entryBuf);
-
- rawFilter(entryBuf, 0); // hack, decipher
- rawFilter(entryBuf, key);
-
-// if (!isUnicode())
- prepText(entryBuf);
-
- return entryBuf;
-}
-
-
-/******************************************************************************
- * RawCom::increment - Increments module key a number of entries
- *
- * ENT: steps - Number of entries to jump forward
- *
- * RET: *this
- */
-
-void RawCom::increment(int steps) {
- long start;
- unsigned short size;
- VerseKey *tmpkey = &getVerseKey();
-
- findOffset(tmpkey->Testament(), tmpkey->Index(), &start, &size);
-
- SWKey lastgood = *tmpkey;
- while (steps) {
- long laststart = start;
- unsigned short lastsize = size;
- SWKey lasttry = *tmpkey;
- (steps > 0) ? (*key)++ : (*key)--;
- tmpkey = &getVerseKey();
-
- if ((error = key->Error())) {
- *key = lastgood;
- break;
- }
- long index = tmpkey->Index();
- findOffset(tmpkey->Testament(), index, &start, &size);
- if (
- (((laststart != start) || (lastsize != size)) // we're a different entry
-// && (start > 0)
- && (size)) // and we actually have a size
- ||(!skipConsecutiveLinks)) { // or we don't want to skip consecutive links
- steps += (steps < 0) ? 1 : -1;
- lastgood = *tmpkey;
- }
- }
- error = (error) ? KEYERR_OUTOFBOUNDS : 0;
-}
-
-
-void RawCom::setEntry(const char *inbuf, long len) {
- VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->Index(), inbuf, len);
-}
-
-
-void RawCom::linkEntry(const SWKey *inkey) {
- VerseKey *destkey = &getVerseKey();
- const VerseKey *srckey = 0;
-
- // see if we have a VerseKey * or decendant
- try {
- srckey = SWDYNAMIC_CAST(VerseKey, inkey);
- }
- catch ( ... ) {}
- // if we don't have a VerseKey * decendant, create our own
- if (!srckey)
- srckey = new VerseKey(inkey);
-
- doLinkEntry(destkey->Testament(), destkey->Index(), srckey->Index());
-
- if (inkey != srckey) // free our key if we created a VerseKey
- delete srckey;
-}
-
-
-/******************************************************************************
- * RawCom::deleteEntry - deletes this entry
- *
- * RET: *this
- */
-
-void RawCom::deleteEntry() {
-
- VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->Index(), "");
-}
-
-
-VerseKey &RawCom::getVerseKey() {
- static VerseKey tmpVK;
- VerseKey *key;
- // see if we have a VerseKey * or decendant
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) { }
- if (!key) {
- ListKey *lkTest = 0;
- try {
- lkTest = SWDYNAMIC_CAST(ListKey, this->key);
- }
- catch ( ... ) { }
- if (lkTest) {
- try {
- key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
- }
- catch ( ... ) { }
- }
- }
- if (!key) {
- tmpVK = *(this->key);
- return tmpVK;
- }
- else return *key;
-}
-
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/comments/rawcom/rtfidx.cpp b/src/modules/comments/rawcom/rtfidx.cpp
deleted file mode 100644
index 38b38bc..0000000
--- a/src/modules/comments/rawcom/rtfidx.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/*****************************************************************************
- *
- * This code wreaks but works (at least for MHC). Good luck!
- */
-
-#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>
-
-
-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(char *fname);
-void checkparams(int argc, char **argv);
-
-
-VerseKey key1, key2, key3;
-int fp, vfp, cfp, bfp;
-long chapoffset;
-short chapsize;
-char testmnt;
-
-
-main(int argc, char **argv)
-{
- long pos, offset;
- int num1, num2, rangemax, curbook = 0, curchap = 0, curverse = 0;
- char buf[127], startflag = 0;
- short size, tmp;
-
- checkparams(argc, argv);
-
- openfiles(argv[1]);
-
- testmnt = key1.Testament();
- 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);
-
- while(!findbreak(fp, &offset, &num1, &num2, &rangemax, &size)) {
- if (num2) {
- key2.Verse(1);
- key2.Chapter(num1);
- key2.Verse(num2);
- }
- else {
- key2.Verse(1);
- if (!startflag) {
- startflag = 1;
- }
- else {
- if (num1 <= key2.Chapter()) { // new book
- key2.Chapter(1);
- key2.Book(key2.Book()+1);
- }
- }
- key2.Chapter(num1);
- printf("Found Chapter Break: %d ('%s')\n", num1, (char *)key2);
- chapoffset = offset;
- chapsize = size;
- continue;
- }
-
- key3 = key2;
- key3 += (rangemax - key3.Verse());
-
- writeidx(key1, key2, key3, offset, size);
- }
- close(vfp);
- close(cfp);
- close(bfp);
- close(fp);
-}
-
-
-/**************************************************************************
- * 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;
-
- for (; ((key1 <= key3) && (key1.Error() != KEYERR_OUTOFBOUNDS) && (key1.Testament() == testmnt)); key1+=1) {
- 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);
- }
- }
-}
-
-
-char startentry(char *buf)
-{
- char loop;
-
- if (buf[0] != 10)
- return 0;
- if (buf[1] != '#')
- return 0;
- if (!isdigit(buf[2]))
- return 0;
- for (loop = 3; loop < 7; loop++) {
- if (buf[loop] == ' ')
- break;
- if ((!isdigit(buf[loop])) && (buf[loop] != ',') && (buf[loop] != '-'))
- return 0;
- }
- return 1;
-}
-
-
-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;
-
- memset(buf, ' ', 7);
-
- while (1) {
- if (startentry(buf)) {
- memset(buf, ' ', 2);
- for (loop = 2; loop < 7; loop++) {
- if ((buf[loop] == '-') || (buf[loop] == ',') || (buf[loop] == ' ')) {
- buf[loop] = 0;
- *num2 = atoi(buf);
- break;
- }
- }
- for (ch = loop + 1; ch < 7; ch++) {
- if (buf[ch] == ' ') {
- break;
- }
- }
- buf[ch] = 0;
- *rangemax = atoi(&buf[loop+1]);
- if (!*rangemax)
- *rangemax = *num2;
- *offset = lseek(fp, 0, SEEK_CUR) - 5;
- if (size) {
- if (findbreak(fp, &offset2, &ch2, &vs2, &rm2, 0)) {
- *size = (short) (lseek(fp, 0, SEEK_END) - (*offset));
- }
- else {
- if (vs2) {
- *size = (offset2 - (*offset)) - 3;
- }
- else {
- sprintf(buf2, "$-$-$- XX:%d", ch2);
- *size = (offset2 - (*offset)) - ((strlen(buf2) + 4));
- }
- }
- lseek(fp, *offset, SEEK_SET);
- }
- return 0;
- }
-
- if (!strncmp(buf, "$-$-$-", 6)) {
- memset(buf2, 0, 7);
- loop = 0;
- while ((read(fp, &buf2[loop], 1) == 1) && (loop < 7)) {
- if ((buf2[loop] == 10) || (buf2[loop] == 13)) {
- buf2[loop] = 0;
- break;
- }
- loop++;
- }
- while (read(fp, &ch, 1) == 1) {
- if (ch == '*')
- break;
- }
-
- *offset = lseek(fp, 0, SEEK_CUR) - 1;
- *num2 = 0;
- for (loop = strlen(buf2) - 1; loop; loop--) {
- if (buf2[loop] == ':')
- break;
- }
- *num1 = atoi(&buf2[loop+1]);
- printf("Chapter marker: %s\n", buf2);
- if (size) {
- if (findbreak(fp, &offset2, &ch2, &vs2, &rm2, 0)) {
- *size = (short) (lseek(fp, 0, SEEK_END) - (*offset));
- }
- else {
- if (vs2) {
- *size = (offset2 - (*offset)) - 3;
- }
- else {
- sprintf(buf2, "$-$-$- XX:%d", ch2);
- *size = (offset2 - (*offset)) - ((strlen(buf2) + 4));
- }
- }
- lseek(fp, *offset, SEEK_SET);
- }
- return 0;
- }
-
-
- memmove(buf, &buf[1], 6);
- if (read(fp, &buf[6], 1) != 1)
- return 1;
- }
-}
-
-
-void openfiles(char *fname)
-{
- char buf[255];
-
- if ((fp = open(fname, O_RDONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", fname);
- exit(1);
- }
-
- sprintf(buf, "%s.vss", fname);
- if ((vfp = open(buf, O_CREAT|O_WRONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", buf);
- exit(1);
- }
-
- sprintf(buf, "%s.cps", fname);
- if ((cfp = open(buf, O_CREAT|O_WRONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", buf);
- exit(1);
- }
-
- sprintf(buf, "%s.bks", fname);
- if ((bfp = open(buf, O_CREAT|O_WRONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", buf);
- exit(1);
- }
-}
-
-
-void checkparams(int argc, char **argv)
-{
- if (argc < 2) {
- fprintf(stderr, "usage: %s <file to process> [nt - for new testmt file]\n", argv[0]);
- exit(1);
- }
- if (argc == 3)
- key1 = key2 = key3 = "Matthew 1:1";
- else key1 = key2 = key3 = "Genesis 1:1";
-}
diff --git a/src/modules/comments/rawcom/rwpidx.cpp b/src/modules/comments/rawcom/rwpidx.cpp
deleted file mode 100644
index afcbd81..0000000
--- a/src/modules/comments/rawcom/rwpidx.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/*****************************************************************************
- *
- * This code wreaks but works (at least for RWP). Good luck!
- */
-
-#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>
-
-
-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(char *fname);
-void checkparams(int argc, char **argv);
-
-
-VerseKey key1, key2, key3;
-int fp, vfp, cfp, bfp;
-long chapoffset;
-short chapsize;
-char testmnt;
-
-
-main(int argc, char **argv)
-{
- long pos, offset;
- int num1 = 0, num2 = 0, rangemax, curbook = 0, curchap = 0, curverse = 0;
- char buf[127], startflag = 0;
- short size, tmp;
-
- checkparams(argc, argv);
-
- openfiles(argv[1]);
-
- testmnt = key1.Testament();
- 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);
-
- while(!findbreak(fp, &offset, &num1, &num2, &rangemax, &size)) {
- if (num2) {
- key2.Verse(1);
- key2.Chapter(num1);
- key2.Verse(num2);
- }
- else {
- key2.Verse(1);
- if (!startflag) {
- startflag = 1;
- }
- else {
- if (num1 <= key2.Chapter()) { // new book
- key2.Chapter(1);
- key2.Book(key2.Book()+1);
- }
- }
- key2.Chapter(num1);
- printf("Found Chapter Break: %d ('%s')\n", num1, (const char *)key2);
- chapoffset = offset;
- chapsize = size;
- continue;
- }
-
- key3 = key2;
- key3 += (rangemax - key3.Verse());
-
- printf("Found verse Break: ('%s')\n", (const char *)key2);
- writeidx(key1, key2, key3, offset, size);
- }
- close(vfp);
- close(cfp);
- close(bfp);
- close(fp);
-}
-
-
-/**************************************************************************
- * 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;
-
- for (; ((key1 <= key3) && (key1.Error() != KEYERR_OUTOFBOUNDS) && (key1.Testament() == testmnt)); key1+=1) {
- 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);
- }
- }
-}
-
-
-char startentry(char *buf)
-{
- char colon = 0;
-
- if (buf[0] != 10)
- return 0;
- if (buf[1] != 10)
- return 0;
- if (!isdigit(buf[2]))
- return 0;
- if (!isdigit(buf[3])) {
- if (buf[3]!= ':')
- return 0;
- else colon++;
- }
- if (!isdigit(buf[4])) {
- if (buf[4]!= ':')
- return 0;
- else colon++;
- }
- if (colon != 1)
- return 0;
- return 1;
-}
-
-
-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;
-
- memset(buf, ' ', 7);
-
- while (1) {
- if (startentry(buf)) {
- buf[0] = ' ';
- buf[1] = ' ';
- sscanf(buf, "%d:%d", num1, num2);
- *rangemax = *num2;
- *offset = lseek(fp, 0, SEEK_CUR) - 5;
- if (size) {
- if (findbreak(fp, &offset2, &ch2, &vs2, &rm2, 0)) {
- *size = (short) (lseek(fp, 0, SEEK_END) - (*offset));
- }
- else {
- if (vs2) {
- *size = (offset2 - (*offset)) - 2;
- }
- else {
- *size = (offset2 - (*offset)) - 6;
- }
- }
- lseek(fp, *offset, SEEK_SET);
- }
- return 0;
- }
-
- if (!strncmp(buf, "$-$-$-", 6)) {
- *offset = lseek(fp, 0, SEEK_CUR) - 1;
- *num2 = 0;
- (*num1)++;
- printf("Book marker: %s\n", buf2);
- if (size) {
- if (findbreak(fp, &offset2, &ch2, &vs2, &rm2, 0)) {
- *size = (short) (lseek(fp, 0, SEEK_END) - (*offset));
- }
- else {
- if (vs2) {
- *size = (offset2 - (*offset)) - 2;
- }
- else {
- *size = (offset2 - (*offset)) - 6;
- }
- }
- lseek(fp, *offset, SEEK_SET);
- }
- return 0;
- }
-
-
- memmove(buf, &buf[1], 6);
- if (read(fp, &buf[6], 1) != 1)
- return 1;
- }
-}
-
-
-void openfiles(char *fname)
-{
- char buf[255];
-
- if ((fp = open(fname, O_RDONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", fname);
- exit(1);
- }
-
- sprintf(buf, "%s.vss", fname);
- if ((vfp = open(buf, O_CREAT|O_WRONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", buf);
- exit(1);
- }
-
- sprintf(buf, "%s.cps", fname);
- if ((cfp = open(buf, O_CREAT|O_WRONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", buf);
- exit(1);
- }
-
- sprintf(buf, "%s.bks", fname);
- if ((bfp = open(buf, O_CREAT|O_WRONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", buf);
- exit(1);
- }
-}
-
-
-void checkparams(int argc, char **argv)
-{
- if (argc < 2) {
- fprintf(stderr, "usage: %s <file to process> [nt - for new testmt file]\n", argv[0]);
- exit(1);
- }
- if (argc == 3)
- key1 = key2 = key3 = "Matthew 1:1";
- else key1 = key2 = key3 = "Genesis 1:1";
-}
diff --git a/src/modules/comments/rawfiles/Makefile b/src/modules/comments/rawfiles/Makefile
deleted file mode 100644
index 35d6648..0000000
--- a/src/modules/comments/rawfiles/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-root := ../../../..
-
-all:
- make -C ${root}
diff --git a/src/modules/comments/rawfiles/Makefile.am b/src/modules/comments/rawfiles/Makefile.am
deleted file mode 100644
index 53aadbe..0000000
--- a/src/modules/comments/rawfiles/Makefile.am
+++ /dev/null
@@ -1,3 +0,0 @@
-rawfilesdir = $(top_srcdir)/src/modules/comments/rawfiles
-
-libsword_la_SOURCES += $(rawfilesdir)/rawfiles.cpp
diff --git a/src/modules/comments/rawfiles/rawfiles.cpp b/src/modules/comments/rawfiles/rawfiles.cpp
deleted file mode 100644
index 9ffa00f..0000000
--- a/src/modules/comments/rawfiles/rawfiles.cpp
+++ /dev/null
@@ -1,269 +0,0 @@
-/******************************************************************************
- * rawfiles.cpp - code for class 'RawFiles'- a module that produces HTML HREFs
- * pointing to actual text desired. Uses standard
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
- */
-
-
-#include <ctype.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#include <utilfuns.h>
-#include <rawverse.h>
-#include <rawfiles.h>
-#include <filemgr.h>
-
-#ifndef O_BINARY // O_BINARY is needed in Borland C++ 4.53
-#define O_BINARY 0 // If it hasn't been defined than we probably
-#endif // don't need it.
-
-SWORD_NAMESPACE_START
-
- /******************************************************************************
- * RawFiles Constructor - Initializes data for instance of RawFiles
- *
- * ENT: iname - Internal name for module
- * idesc - Name to display to user for module
- * idisp - Display object to use for displaying
- */
-
-RawFiles::RawFiles(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang) : RawVerse(ipath, O_RDWR), SWCom(iname, idesc, idisp, enc, dir, mark, ilang)
-{
-}
-
-
-/******************************************************************************
- * RawFiles Destructor - Cleans up instance of RawFiles
- */
-
-RawFiles::~RawFiles()
-{
-}
-
-
-/******************************************************************************
- * RawFiles::getRawEntry - Returns the correct verse when char * cast
- * is requested
- *
- * RET: string buffer with verse
- */
-
-SWBuf &RawFiles::getRawEntryBuf() {
- FileDesc *datafile;
- long start = 0;
- unsigned short size = 0;
- char *tmpbuf;
- VerseKey *key = 0;
-
-#ifndef _WIN32_WCE
- try {
-#endif
- key = SWDYNAMIC_CAST(VerseKey, this->key);
-#ifndef _WIN32_WCE
- }
- catch ( ... ) {}
-#endif
- if (!key)
- key = new VerseKey(this->key);
-
- findOffset(key->Testament(), key->Index(), &start, &size);
-
- entryBuf = "";
- if (size) {
- SWBuf tmpbuf = path;
- tmpbuf += '/';
- readText(key->Testament(), start, size, entryBuf);
- tmpbuf += entryBuf;
- entryBuf = "";
- datafile = FileMgr::systemFileMgr.open(tmpbuf.c_str(), O_RDONLY|O_BINARY);
- if (datafile->getFd() > 0) {
- size = lseek(datafile->getFd(), 0, SEEK_END);
- char *tmpBuf = new char [ size + 1 ];
- memset(tmpBuf, 0, size + 1);
- lseek(datafile->getFd(), 0, SEEK_SET);
- read(datafile->getFd(), tmpBuf, size);
- entryBuf = tmpBuf;
- delete [] tmpBuf;
-// preptext(entrybuf);
- }
- FileMgr::systemFileMgr.close(datafile);
- }
-
- if (key != this->key)
- delete key;
-
- return entryBuf;
-}
-
-
-/******************************************************************************
- * RawFiles::setEntry(char *)- Update the modules current key entry with
- * provided text
- */
-
-void RawFiles::setEntry(const char *inbuf, long len) {
- FileDesc *datafile;
- long start;
- unsigned short size;
- VerseKey *key = 0;
-
- len = (len<0)?strlen(inbuf):len;
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- if (!key)
- key = new VerseKey(this->key);
-
- findOffset(key->Testament(), key->Index(), &start, &size);
-
- if (size) {
- SWBuf tmpbuf;
- entryBuf = path;
- entryBuf += '/';
- readText(key->Testament(), start, size, tmpbuf);
- entryBuf += tmpbuf;
- }
- else {
- SWBuf tmpbuf;
- entryBuf = path;
- entryBuf += '/';
- tmpbuf = getNextFilename();
- doSetText(key->Testament(), key->Index(), tmpbuf);
- entryBuf += tmpbuf;
- }
- datafile = FileMgr::systemFileMgr.open(entryBuf, O_CREAT|O_WRONLY|O_BINARY|O_TRUNC);
- if (datafile->getFd() > 0) {
- write(datafile->getFd(), inbuf, len);
- }
- FileMgr::systemFileMgr.close(datafile);
-
- if (key != this->key)
- delete key;
-}
-
-
-/******************************************************************************
- * RawFiles::linkEntry(SWKey *)- Link the modules current key entry with
- * another module entry
- *
- * RET: *this
- */
-
-void RawFiles::linkEntry(const SWKey *inkey) {
-
- long start;
- unsigned short size;
- char *tmpbuf;
- const VerseKey *key = 0;
-
- try {
- key = SWDYNAMIC_CAST(VerseKey, inkey);
- }
- catch ( ... ) {}
- if (!key)
- key = new VerseKey(this->key);
-
- findOffset(key->Testament(), key->Index(), &start, &size);
-
- if (size) {
- SWBuf tmpbuf;
- readText(key->Testament(), start, size + 2, tmpbuf);
-
- if (key != inkey)
- delete key;
- key = 0;
-
- try {
- key = SWDYNAMIC_CAST(VerseKey, inkey);
- }
- catch ( ... ) {}
- if (!key)
- key = new VerseKey(this->key);
- doSetText(key->Testament(), key->Index(), tmpbuf.c_str());
- }
-
- if (key != inkey)
- delete key;
-}
-
-
-/******************************************************************************
- * RawFiles::deleteEntry - deletes this entry
- *
- * RET: *this
- */
-
-void RawFiles::deleteEntry() {
-
- VerseKey *key = 0;
-
-#ifndef _WIN32_WCE
- try {
-#endif
- key = SWDYNAMIC_CAST(VerseKey, this->key);
-#ifndef _WIN32_WCE
- }
- catch ( ... ) {}
-#endif
- if (!key)
- key = new VerseKey(this->key);
-
- doSetText(key->Testament(), key->Index(), "");
-
- if (key != this->key)
- delete key;
-}
-
-
-/******************************************************************************
- * RawFiles::getNextfilename - generates a valid filename in which to store
- * an entry
- *
- * RET: filename
- */
-
-char *RawFiles::getNextFilename() {
- static char incfile[255];
- long number;
- FileDesc *datafile;
-
- sprintf(incfile, "%s/incfile", path);
- datafile = FileMgr::systemFileMgr.open(incfile, O_RDONLY|O_BINARY);
- if (read(datafile->getFd(), &number, 4) != 4)
- number = 0;
- number++;
- FileMgr::systemFileMgr.close(datafile);
-
- datafile = FileMgr::systemFileMgr.open(incfile, O_CREAT|O_WRONLY|O_BINARY|O_TRUNC);
- write(datafile->getFd(), &number, 4);
- FileMgr::systemFileMgr.close(datafile);
- sprintf(incfile, "%.7ld", number-1);
- return incfile;
-}
-
-
-char RawFiles::createModule (const char *path) {
- char *incfile = new char [ strlen (path) + 16 ];
- static long zero = 0;
- FileDesc *datafile;
-
- sprintf(incfile, "%s/incfile", path);
- datafile = FileMgr::systemFileMgr.open(incfile, O_CREAT|O_WRONLY|O_BINARY|O_TRUNC);
- delete [] incfile;
- write(datafile->getFd(), &zero, 4);
- FileMgr::systemFileMgr.close(datafile);
-
- return RawVerse::createModule (path);
-}
-
-
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/comments/rawfiles/rawfilesgen.cpp b/src/modules/comments/rawfiles/rawfilesgen.cpp
deleted file mode 100644
index f60c9e2..0000000
--- a/src/modules/comments/rawfiles/rawfilesgen.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/*****************************************************************************
- *
- */
-
-#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>
-
-#ifndef O_BINARY
- #define O_BINARY 0
-#endif
-
-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;
-
-
-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);
-
- key1 = key2 = key3 = "Genesis 1:1";
-
- openfiles();
-
- num1 = key1.Chapter();
- num2 = key1.Verse();
-
- 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("Created Empty Entry: %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);
-}
-
-
-/**************************************************************************
- * 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);
- size = 0;
- write(vfp, &size, 2);
- }
- else {
- pos = 0;
- tmp = 0;
- write(vfp, &pos, 4);
- write(vfp, &tmp, 2);
- }
- key1++;
-}
-
-
-static VerseKey inckey = "Genesis 1:1";
-
-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;
- char data[16];
-
- memset (data,0,16);
-
- 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();
-
-
- write(fp, data, 16);
-
- *size = lseek(fp, 0, SEEK_CUR) - *offset;
- return 0;
- }
- return 1;
-}
-
-
-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)) == -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)) == -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)) == -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)) == -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 !=1) {
- fprintf(stderr, "usage: %s\n", argv[0]);
- exit(1);
- }
-}
diff --git a/src/modules/comments/swcom.cpp b/src/modules/comments/swcom.cpp
deleted file mode 100644
index 3f2b940..0000000
--- a/src/modules/comments/swcom.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/******************************************************************************
- * swcom.cpp - code for base class 'SWCom'- The basis for all commentary
- * modules
- */
-
-#include <swcom.h>
-
-SWORD_NAMESPACE_START
-
-/******************************************************************************
- * SWCom Constructor - Initializes data for instance of SWCom
- *
- * ENT: imodname - Internal name for module
- * imoddesc - Name to display to user for module
- * idisp - Display object to use for displaying
- */
-
-SWCom::SWCom(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang): SWModule(imodname, imoddesc, idisp, "Commentaries", enc, dir, mark, ilang)
-{
- delete key;
- key = CreateKey();
-}
-
-
-/******************************************************************************
- * SWCom Destructor - Cleans up instance of SWCom
- */
-
-SWCom::~SWCom()
-{
-}
-
-
-long SWCom::Index() const {
- VerseKey *key = 0;
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- if (!key)
- key = new VerseKey(this->key);
-
- entryIndex = key->NewIndex();
-
- if (key != this->key)
- delete key;
-
- return entryIndex;
-}
-
-long SWCom::Index(long iindex) {
- VerseKey *key = 0;
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) {}
- if (!key)
- key = new VerseKey(this->key);
-
- key->Testament(1);
- key->Index(iindex);
-
- if (key != this->key) {
- this->key->copyFrom(*key);
- delete key;
- }
-
- return Index();
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/comments/zcom/Makefile b/src/modules/comments/zcom/Makefile
deleted file mode 100644
index 35d6648..0000000
--- a/src/modules/comments/zcom/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-root := ../../../..
-
-all:
- make -C ${root}
diff --git a/src/modules/comments/zcom/Makefile.am b/src/modules/comments/zcom/Makefile.am
deleted file mode 100644
index ad1ef6a..0000000
--- a/src/modules/comments/zcom/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
-zcomdir = $(top_srcdir)/src/modules/comments/zcom
-
-libsword_la_SOURCES += $(zcomdir)/zcom.cpp
-
diff --git a/src/modules/comments/zcom/makeidx.c b/src/modules/comments/zcom/makeidx.c
deleted file mode 100644
index 311103e..0000000
--- a/src/modules/comments/zcom/makeidx.c
+++ /dev/null
@@ -1,146 +0,0 @@
-#include <stdio.h>
-#include <fcntl.h>
-
-
-char findbreak(int fp, int *offset, int *num1, int *num2, short *size);
-
-
-main(int argc, char **argv)
-{
- int fp, vfp, cfp, bfp;
- long pos;
- short size, tmp;
- int num1, num2, offset, curbook = 0, curchap = 0, curverse = 0;
- char buf[127];
-
- if (argc != 2) {
- fprintf(stderr, "usage: %s <file to process>\n", argv[0]);
- exit(1);
- }
-
- if ((fp = open(argv[1], O_RDONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", argv[1]);
- exit(1);
- }
-
- sprintf(buf, "%s.vss", argv[1]);
- if ((vfp = open(buf, O_CREAT|O_WRONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", buf);
- exit(1);
- }
-
- sprintf(buf, "%s.cps", argv[1]);
- if ((cfp = open(buf, O_CREAT|O_WRONLY)) == -1) {
- fprintf(stderr, "Couldn't open file: %s\n", buf);
- exit(1);
- }
-
- sprintf(buf, "%s.bks", argv[1]);
- if ((bfp = open(buf, O_CREAT|O_WRONLY)) == -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);
-
- while (!findbreak(fp, &offset, &num1, &num2, &size)) {
-
- if (num2 == 1) { /* if we're at a new chapter */
- if (num1 == 1) { /* if we're at a 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);
- pos = 0;
- 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 = 0;
- tmp = 0;
- write(vfp, &pos, 4); /* Chapter intro */
- write(vfp, &tmp, 2);
- curchap++;
- }
- else curverse++;
-
- printf("%2d:%3d:%3d found at offset: %7d\n", curbook, num1, num2, offset);
-
- if (num1 != curchap) {
- fprintf(stderr, "Error: Found chaptures out of sequence\n", buf);
- break;
- }
- if (num2 != curverse) {
- fprintf(stderr, "Error: Found verses out of sequence\n", buf);
- break;
- }
- write(vfp, &offset, 4);
- write(vfp, &size, 2);
- }
-
- close(vfp);
- close(cfp);
- close(bfp);
- close(fp);
-}
-
-
-char findbreak(int fp, int *offset, int *num1, int *num2, short *size)
-{
- char buf[7];
- char buf2[7];
- char loop;
- int offset2, ch2, vs2;
-
- memset(buf, ' ', 7);
-
- while (1) {
- if (buf[3] == ':') {
- memcpy(buf2, buf, 7);
- for (loop = 0; loop < 7; loop++) {
- if (!isdigit(buf2[loop]))
- buf2[loop] = ' ';
- }
- buf2[3] = 0;
- *num1 = atoi(buf2);
- *num2 = atoi(&buf2[4]);
- if (*num1 && *num2) {
- *offset = lseek(fp, 0, SEEK_CUR);
- sprintf(buf2, "%d", *num2);
- *offset -= 2 - strlen(buf2);
- if (size) {
- if (findbreak(fp, &offset2, &ch2, &vs2, 0)) {
- *size = (short) (lseek(fp, 0, SEEK_END) - (*offset));
- }
- else {
- sprintf(buf2, "%d:%d", ch2, vs2);
- *size = (offset2 - (*offset)) - (strlen(buf2) + 2);
- }
- lseek(fp, *offset, SEEK_SET);
- }
- return 0;
- }
- }
- memmove(buf, &buf[1], 6);
- if (read(fp, &buf[6], 1) != 1)
- return 1;
- }
-}
-
diff --git a/src/modules/comments/zcom/rawtxt2z.cpp b/src/modules/comments/zcom/rawtxt2z.cpp
deleted file mode 100644
index f8c18d0..0000000
--- a/src/modules/comments/zcom/rawtxt2z.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-#include <ctype.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#include <swcomprs.h>
-
-
-main(int argc, char **argv)
-{
- SWCompress *zobj;
- int ifd, ofd, ixfd, oxfd;
- long offset, loffset, lzoffset;
- short size, lsize, lzsize;
- char *tmpbuf;
-
- if (argc != 2) {
- fprintf(stderr, "usage: %s <datafilename>\n", argv[0]);
- exit(1);
- }
-
- zobj = new SWCompress();
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
- tmpbuf = new char [ strlen(argv[1]) + 9 ];
- ifd = open(argv[1], O_RDONLY|O_BINARY);
- sprintf(tmpbuf, "%s.vss", argv[1]);
- ixfd = open(tmpbuf, O_RDONLY|O_BINARY);
- sprintf(tmpbuf, "%s.zzz", argv[1]);
- ofd = open(tmpbuf, O_WRONLY|O_BINARY|O_CREAT);
- sprintf(tmpbuf, "%s.zzz.vss", argv[1]);
- oxfd = open(tmpbuf, O_WRONLY|O_BINARY|O_CREAT);
-
- delete [] tmpbuf;
-
- printf("\n");
-
- while (1) {
- if (read(ixfd, &offset, 4) != 4)
- break;
- if (read(ixfd, &size, 2) != 2)
- break;
-
- if ((offset == loffset) && (size == lsize)) {
- printf("using previous offset,size\n", size);
- write(oxfd, &lzoffset, 4);
- write(oxfd, &lzsize, 2);
- }
- else {
- printf("%d -> ", size);
- lsize = size;
- loffset = offset;
-
- if (size) {
- tmpbuf = (char *) calloc(size + 1, 1);
- lseek(ifd, offset, SEEK_SET);
- read(ifd, tmpbuf, size);
- zobj->Buf(tmpbuf);
- zobj->zBuf(&size);
- free(tmpbuf);
- }
- offset = lseek(ofd, 0, SEEK_END);
- write(oxfd, &offset, 4);
- if (size)
- write(ofd, zobj->zBuf(&size), size);
- lzoffset = offset;
- write(oxfd, &size, 2);
- lzsize = size;
- printf("%d \n", size);
- }
- }
- delete zobj;
-}
diff --git a/src/modules/comments/zcom/zcom.cpp b/src/modules/comments/zcom/zcom.cpp
deleted file mode 100644
index 744a509..0000000
--- a/src/modules/comments/zcom/zcom.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/******************************************************************************
- * rawcom.cpp - code for class 'zCom'- a module that reads raw commentary
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
- */
-
-
-#include <ctype.h>
-#include <stdio.h>
-#include <fcntl.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#include <utilfuns.h>
-#include <zverse.h>
-#include <zcom.h>
-
-SWORD_NAMESPACE_START
-
-/******************************************************************************
- * zCom Constructor - Initializes data for instance of zCom
- *
- * ENT: ipath - path to data files
- * iname - Internal name for module
- * idesc - Name to display to user for module
- * iblockType - verse, chapter, book, etc. of index chunks
- * icomp - Compressor object
- * idisp - Display object to use for displaying
- */
-
-zCom::zCom(const char *ipath, const char *iname, const char *idesc, int iblockType, SWCompress *icomp, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang) : zVerse(ipath, -1, iblockType, icomp), SWCom(iname, idesc, idisp, enc, dir, mark, ilang)/*, SWCompress()*/
-{
- blockType = iblockType;
- lastWriteKey = 0;
-}
-
-/******************************************************************************
- * zCom Destructor - Cleans up instance of zCom
- */
-
-zCom::~zCom() {
- flushCache();
-
- if (lastWriteKey)
- delete lastWriteKey;
-}
-
-/******************************************************************************
- * zCom::getRawEntry - Returns the correct verse when char * cast
- * is requested
- *
- * RET: string buffer with verse
- */
-SWBuf &zCom::getRawEntryBuf() {
- long start = 0;
- unsigned short size = 0;
- VerseKey *key = &getVerseKey();
-
- findOffset(key->Testament(), key->Index(), &start, &size);
- entrySize = size; // support getEntrySize call
-
- entryBuf = "";
- zReadText(key->Testament(), start, size, entryBuf);
-
- rawFilter(entryBuf, key);
-
-// if (!isUnicode())
- prepText(entryBuf);
-
- return entryBuf;
-}
-
-
-bool zCom::sameBlock(VerseKey *k1, VerseKey *k2) {
- if (k1->Testament() != k2->Testament())
- return false;
-
- switch (blockType) {
- case VERSEBLOCKS:
- if (k1->Verse() != k2->Verse())
- return false;
- case CHAPTERBLOCKS:
- if (k1->Chapter() != k2->Chapter())
- return false;
- case BOOKBLOCKS:
- if (k1->Book() != k2->Book())
- return false;
- }
- return true;
-}
-
-void zCom::setEntry(const char *inbuf, long len) {
- VerseKey *key = &getVerseKey();
-
- // see if we've jumped across blocks since last write
- if (lastWriteKey) {
- if (!sameBlock(lastWriteKey, key)) {
- flushCache();
- }
- delete lastWriteKey;
- }
-
- doSetText(key->Testament(), key->Index(), inbuf, len);
-
- lastWriteKey = (VerseKey *)key->clone(); // must delete
-}
-
-
-void zCom::linkEntry(const SWKey *inkey) {
- VerseKey *destkey = &getVerseKey();
- const VerseKey *srckey = 0;
-
- // see if we have a VerseKey * or decendant
- try {
- srckey = (const VerseKey *) SWDYNAMIC_CAST(VerseKey, inkey);
- }
- catch ( ... ) {
- }
- // if we don't have a VerseKey * decendant, create our own
- if (!srckey)
- srckey = new VerseKey(inkey);
-
- doLinkEntry(destkey->Testament(), destkey->Index(), srckey->Index());
-
- if (inkey != srckey) // free our key if we created a VerseKey
- delete srckey;
-}
-
-/******************************************************************************
- * zCom::deleteEntry - deletes this entry
- *
- * RET: *this
- */
-
-void zCom::deleteEntry() {
-
- VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->Index(), "");
-}
-
-
-/******************************************************************************
- * zCom::increment - Increments module key a number of entries
- *
- * ENT: increment - Number of entries to jump forward
- *
- * RET: *this
- */
-
-void zCom::increment(int steps) {
- long start;
- unsigned short size;
- VerseKey *tmpkey = &getVerseKey();
-
- findOffset(tmpkey->Testament(), tmpkey->Index(), &start, &size);
-
- SWKey lastgood = *tmpkey;
- while (steps) {
- long laststart = start;
- unsigned short lastsize = size;
- SWKey lasttry = *tmpkey;
- (steps > 0) ? (*key)++ : (*key)--;
- tmpkey = &getVerseKey();
-
- if ((error = key->Error())) {
- *key = lastgood;
- break;
- }
- long index = tmpkey->Index();
- findOffset(tmpkey->Testament(), index, &start, &size);
- if (
- (((laststart != start) || (lastsize != size)) // we're a different entry
-// && (start > 0)
- && (size)) // and we actually have a size
- ||(!skipConsecutiveLinks)) { // or we don't want to skip consecutive links
- steps += (steps < 0) ? 1 : -1;
- lastgood = *tmpkey;
- }
- }
- error = (error) ? KEYERR_OUTOFBOUNDS : 0;
-}
-
-
-VerseKey &zCom::getVerseKey() {
- static VerseKey tmpVK;
- VerseKey *key;
- // see if we have a VerseKey * or decendant
- try {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- catch ( ... ) { }
- if (!key) {
- ListKey *lkTest = 0;
- try {
- lkTest = SWDYNAMIC_CAST(ListKey, this->key);
- }
- catch ( ... ) { }
- if (lkTest) {
- try {
- key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
- }
- catch ( ... ) { }
- }
- }
- if (!key) {
- tmpVK = *(this->key);
- return tmpVK;
- }
- else return *key;
-}
-
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/common/Makefile b/src/modules/common/Makefile
deleted file mode 100644
index 81f7721..0000000
--- a/src/modules/common/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-root := ../../..
-
-all:
- make -C ${root}
diff --git a/src/modules/common/Makefile.am b/src/modules/common/Makefile.am
deleted file mode 100644
index b411660..0000000
--- a/src/modules/common/Makefile.am
+++ /dev/null
@@ -1,21 +0,0 @@
-commondir = $(top_srcdir)/src/modules/common
-
-libsword_la_SOURCES += $(commondir)/rawstr.cpp
-libsword_la_SOURCES += $(commondir)/rawstr4.cpp
-libsword_la_SOURCES += $(commondir)/swcomprs.cpp
-libsword_la_SOURCES += $(commondir)/lzsscomprs.cpp
-
-if ZLIB
-SWZLIB = $(commondir)/zipcomprs.cpp
-else
-SWZLIB =
-endif
-libsword_la_SOURCES += $(SWZLIB)
-libsword_la_SOURCES += $(commondir)/rawverse.cpp
-libsword_la_SOURCES += $(commondir)/swcipher.cpp
-libsword_la_SOURCES += $(commondir)/zverse.cpp
-libsword_la_SOURCES += $(commondir)/zstr.cpp
-libsword_la_SOURCES += $(commondir)/entriesblk.cpp
-
-libsword_la_SOURCES += $(commondir)/sapphire.cpp
-
diff --git a/src/modules/common/compress.cpp b/src/modules/common/compress.cpp
deleted file mode 100644
index 5031adb..0000000
--- a/src/modules/common/compress.cpp
+++ /dev/null
@@ -1,767 +0,0 @@
-Compression Info, 10-11-95
-Jeff Wheeler
-
-Source of Algorithm
--------------------
-
-The compression algorithms used here are based upon the algorithms developed and published by Haruhiko Okumura in a paper entitled "Data Compression Algorithms of LARC and LHarc." This paper discusses three compression algorithms, LSZZ, LZARI, and LZHUF. LZSS is described as the "first" of these, and is described as providing moderate compression with good speed. LZARI is described as an improved LZSS, a combination of the LZSS algorithm with adaptive arithmetic compression. It is described as being slower than LZSS but with better compression. LZHUF (the basis of the common LHA compression program) was included in the paper, however, a free usage license was not included.
-
-The following are copies of the statements included at the beginning of each source code listing that was supplied in the working paper.
-
- LZSS, dated 4/6/89, marked as "Use, distribute and
- modify this program freely."
-
- LZARI, dated 4/7/89, marked as "Use, distribute and
- modify this program freely."
-
- LZHUF, dated 11/20/88, written by Haruyasu Yoshizaki,
- translated by Haruhiko Okumura on 4/7/89. Not
- expressly marked as redistributable or modifiable.
-
-Since both LZSS and LZARI are marked as "use, distribute and modify freely" we have felt at liberty basing our compression algorithm on either of these.
-
-Selection of Algorithm
-----------------------
-
-Working samples of three possible compression algorithms are supplied in Okumura's paper. Which should be used?
-
-LZSS is the fastest at decompression, but does not generated as small a compressed file as the other methods. The other two methods provided, perhaps, a 15% improvement in compression. Or, put another way, on a 100K file, LZSS might compress it to 50K while the others might approach 40-45K. For STEP purposes, it was decided that decoding speed was of more importance than tighter compression. For these reasons, the first compression algorithm implemented is the LZSS algorithm.
-
-About LZSS Encoding
--------------------
-
-(adapted from Haruhiko Okumura's paper)
-
-This scheme was proposed by Ziv and Lempel [1]. A slightly modified version is described by Storer and Szymanski [2]. An implementation using a binary tree has been proposed by Bell [3].
-
-The algorithm is quite simple.
-1. Keep a ring buffer which initially contains all space characters.
-2. Read several letters from the file to the buffer.
-3. Search the buffer for the longest string that matches the letters just read, and send its length and position into the buffer.
-
-If the ring buffer is 4096 bytes, the position can be stored in 12 bits. If the length is represented in 4 bits, the <position, length> pair is two bytes long. If the longest match is no more than two characters, then just one character is sent without encoding. The process starts again with the next character. An extra bit is sent each time to tell the decoder whether the next item is a character of a <position, length> pair.
-
-[1] J. Ziv and A. Lempel, IEEE Transactions IT-23, 337-343 (1977).
-[2] J. A. Storer and T. G. Szymanski, J. ACM, 29, 928-951 (1982).
-[3] T.C. Gell, IEEE Transactions COM-34, 1176-1182 (1986).
-
-void InitTree( // no return value
- void); // no parameters
-
-void InsertNode( // no return value
- short int Pos); // position in the buffer
-
-void DeleteNode( // no return value
- short int Node); // node to be removed
-
-void Encode( // no return value
- void); // no parameters
-
-void Decode( // no return value
- void); // no parameters
-
-// The following are constant sizes used by the compression algorithm.
-//
-// N - This is the size of the ring buffer. It is set
-// to 4K. It is important to note that a position
-// within the ring buffer requires 12 bits.
-//
-// F - This is the maximum length of a character sequence
-// that can be taken from the ring buffer. It is set
-// to 18. Note that a length must be 3 before it is
-// worthwhile to store a position/length pair, so the
-// length can be encoded in only 4 bits. Or, put yet
-// another way, it is not necessary to encode a length
-// of 0-18, it is necessary to encode a length of
-// 3-18, which requires 4 bits.
-//
-// THRESHOLD - It takes 2 bytes to store an offset and
-// a length. If a character sequence only
-// requires 1 or 2 characters to store
-// uncompressed, then it is better to store
-// it uncompressed than as an offset into
-// the ring buffer.
-//
-// Note that the 12 bits used to store the position and the 4 bits
-// used to store the length equal a total of 16 bits, or 2 bytes.
-
-#define N 4096
-#define F 18
-#define THRESHOLD 3
-#define NOT_USED N
-
-// m_ring_buffer is a text buffer. It contains "nodes" of
-// uncompressed text that can be indexed by position. That is,
-// a substring of the ring buffer can be indexed by a position
-// and a length. When decoding, the compressed text may contain
-// a position in the ring buffer and a count of the number of
-// bytes from the ring buffer that are to be moved into the
-// uncompressed buffer.
-//
-// This ring buffer is not maintained as part of the compressed
-// text. Instead, it is reconstructed dynamically. That is,
-// it starts out empty and gets built as the text is decompressed.
-//
-// The ring buffer contain N bytes, with an additional F - 1 bytes
-// to facilitate string comparison.
-
-unsigned char m_ring_buffer[N + F - 1];
-
-// m_match_position and m_match_length are set by InsertNode().
-//
-// These variables indicate the position in the ring buffer
-// and the number of characters at that position that match
-// a given string.
-
-short int m_match_position;
-short int m_match_length;
-
-// m_lson, m_rson, and m_dad are the Japanese way of referring to
-// a tree structure. The dad is the parent and it has a right and
-// left son (child).
-//
-// For i = 0 to N-1, m_rson[i] and m_lson[i] will be the right
-// and left children of node i.
-//
-// For i = 0 to N-1, m_dad[i] is the parent of node i.
-//
-// For i = 0 to 255, rson[N + i + 1] is the root of the tree for
-// strings that begin with the character i. Note that this requires
-// one byte characters.
-//
-// These nodes store values of 0...(N-1). Memory requirements
-// can be reduces by using 2-byte integers instead of full 4-byte
-// integers (for 32-bit applications). Therefore, these are
-// defined as "short ints."
-
-short int m_lson[N + 1];
-short int m_rson[N + 257];
-short int m_dad[N + 1];
-
-/*
- -------------------------------------------------------------------------
- cLZSS::InitTree
-
- This function initializes the tree nodes to "empty" states.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::InitTree( // no return value
- void) // no parameters
- throw() // exception list
-
- {
- int i;
-
- // For i = 0 to N - 1, m_rson[i] and m_lson[i] will be the right
- // and left children of node i. These nodes need not be
- // initialized. However, for debugging purposes, it is nice to
- // have them initialized. Since this is only used for compression
- // (not decompression), I don't mind spending the time to do it.
- //
- // For the same range of i, m_dad[i] is the parent of node i.
- // These are initialized to a known value that can represent
- // a "not used" state.
-
- for (i = 0; i < N; i++)
- {
- m_lson[i] = NOT_USED;
- m_rson[i] = NOT_USED;
- m_dad[i] = NOT_USED;
- }
-
- // For i = 0 to 255, m_rson[N + i + 1] is the root of the tree
- // for strings that begin with the character i. This is why
- // the right child array is larger than the left child array.
- // These are also initialzied to a "not used" state.
- //
- // Note that there are 256 of these, one for each of the possible
- // 256 characters.
-
- for (i = N + 1; i <= (N + 256); i++)
- {
- m_rson[i] = NOT_USED;
- }
-
- // Done.
- }
-
-/*
- -------------------------------------------------------------------------
- cLZSS::InsertNode
-
- This function inserts a string from the ring buffer into one of
- the trees. It loads the match position and length member variables
- for the longest match.
-
- The string to be inserted is identified by the parameter Pos,
- A full F bytes are inserted. So, m_ring_buffer[Pos ... Pos+F-1]
- are inserted.
-
- If the matched length is exactly F, then an old node is removed
- in favor of the new one (because the old one will be deleted
- sooner).
-
- Note that Pos plays a dual role. It is used as both a position
- in the ring buffer and also as a tree node. m_ring_buffer[Pos]
- defines a character that is used to identify a tree node.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::InsertNode( // no return value
- short int Pos) // position in the buffer
- throw() // exception list
-
- {
- short int i;
- short int p;
- int cmp;
- unsigned char * key;
-
- ASSERT(Pos >= 0);
- ASSERT(Pos < N);
-
- cmp = 1;
- key = &(m_ring_buffer[Pos]);
-
- // The last 256 entries in m_rson contain the root nodes for
- // strings that begin with a letter. Get an index for the
- // first letter in this string.
-
- p = (short int) (N + 1 + key[0]);
-
- // Set the left and right tree nodes for this position to "not
- // used."
-
- m_lson[Pos] = NOT_USED;
- m_rson[Pos] = NOT_USED;
-
- // Haven't matched anything yet.
-
- m_match_length = 0;
-
- for ( ; ; )
- {
- if (cmp >= 0)
- {
- if (m_rson[p] != NOT_USED)
- {
- p = m_rson[p];
- }
- else
- {
- m_rson[p] = Pos;
- m_dad[Pos] = p;
- return;
- }
- }
- else
- {
- if (m_lson[p] != NOT_USED)
- {
- p = m_lson[p];
- }
- else
- {
- m_lson[p] = Pos;
- m_dad[Pos] = p;
- return;
- }
- }
-
- // Should we go to the right or the left to look for the
- // next match?
-
- for (i = 1; i < F; i++)
- {
- cmp = key[i] - m_ring_buffer[p + i];
- if (cmp != 0)
- break;
- }
-
- if (i > m_match_length)
- {
- m_match_position = p;
- m_match_length = i;
-
- if (i >= F)
- break;
- }
- }
-
- m_dad[Pos] = m_dad[p];
- m_lson[Pos] = m_lson[p];
- m_rson[Pos] = m_rson[p];
-
- m_dad[ m_lson[p] ] = Pos;
- m_dad[ m_rson[p] ] = Pos;
-
- if (m_rson[ m_dad[p] ] == p)
- {
- m_rson[ m_dad[p] ] = Pos;
- }
- else
- {
- m_lson[ m_dad[p] ] = Pos;
- }
-
- // Remove "p"
-
- m_dad[p] = NOT_USED;
- }
-
-/*
- -------------------------------------------------------------------------
- cLZSS::DeleteNode
-
- This function removes the node "Node" from the tree.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::DeleteNode( // no return value
- short int Node) // node to be removed
- throw() // exception list
-
- {
- short int q;
-
- ASSERT(Node >= 0);
- ASSERT(Node < (N+1));
-
- if (m_dad[Node] == NOT_USED)
- {
- // not in tree, nothing to do
- return;
- }
-
- if (m_rson[Node] == NOT_USED)
- {
- q = m_lson[Node];
- }
- else if (m_lson[Node] == NOT_USED)
- {
- q = m_rson[Node];
- }
- else
- {
- q = m_lson[Node];
- if (m_rson[q] != NOT_USED)
- {
- do
- {
- q = m_rson[q];
- }
- while (m_rson[q] != NOT_USED);
-
- m_rson[ m_dad[q] ] = m_lson[q];
- m_dad[ m_lson[q] ] = m_dad[q];
- m_lson[q] = m_lson[Node];
- m_dad[ m_lson[Node] ] = q;
- }
-
- m_rson[q] = m_rson[Node];
- m_dad[ m_rson[Node] ] = q;
- }
-
- m_dad[q] = m_dad[Node];
-
- if (m_rson[ m_dad[Node] ] == Node)
- {
- m_rson[ m_dad[Node] ] = q;
- }
- else
- {
- m_lson[ m_dad[Node] ] = q;
- }
-
- m_dad[Node] = NOT_USED;
- }
-
-/*
- -------------------------------------------------------------------------
- cLZSS::Encode
-
- This function "encodes" the input stream into the output stream.
- The GetChars() and SendChars() functions are used to separate
- this method from the actual i/o.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::Encode( // no return value
- void) // no parameters
-
- {
- short int i; // an iterator
- short int r; // node number in the binary tree
- short int s; // position in the ring buffer
- unsigned short int len; // len of initial string
- short int last_match_length; // length of last match
- short int code_buf_pos; // position in the output buffer
- unsigned char code_buf[17]; // the output buffer
- unsigned char mask; // bit mask for byte 0 of out buf
- unsigned char c; // character read from string
-
- // Start with a clean tree.
-
- InitTree();
-
- // code_buf[0] works as eight flags. A "1" represents that the
- // unit is an unencoded letter (1 byte), and a "0" represents
- // that the next unit is a <position,length> pair (2 bytes).
- //
- // code_buf[1..16] stores eight units of code. Since the best
- // we can do is store eight <position,length> pairs, at most 16
- // bytes are needed to store this.
- //
- // This is why the maximum size of the code buffer is 17 bytes.
-
- code_buf[0] = 0;
- code_buf_pos = 1;
-
- // Mask iterates over the 8 bits in the code buffer. The first
- // character ends up being stored in the low bit.
- //
- // bit 8 7 6 5 4 3 2 1
- // | |
- // | first sequence in code buffer
- // |
- // last sequence in code buffer
-
- mask = 1;
-
- s = 0;
- r = (short int) N - (short int) F;
-
- // Initialize the ring buffer with spaces...
-
- // Note that the last F bytes of the ring buffer are not filled.
- // This is because those F bytes will be filled in immediately
- // with bytes from the input stream.
-
- memset(m_ring_buffer, ' ', N - F);
-
- // Read F bytes into the last F bytes of the ring buffer.
- //
- // This function loads the buffer with X characters and returns
- // the actual amount loaded.
-
- len = GetChars(&(m_ring_buffer[r]), F);
-
- // Make sure there is something to be compressed.
-
- if (len == 0)
- return;
-
- // Insert the F strings, each of which begins with one or more
- // 'space' characters. Note the order in which these strings
- // are inserted. This way, degenerate trees will be less likely
- // to occur.
-
- for (i = 1; i <= F; i++)
- {
- InsertNode((short int) (r - i));
- }
-
- // Finally, insert the whole string just read. The
- // member variables match_length and match_position are set.
-
- InsertNode(r);
-
- // Now that we're preloaded, continue till done.
-
- do
- {
-
- // m_match_length may be spuriously long near the end of
- // text.
-
- if (m_match_length > len)
- {
- m_match_length = len;
- }
-
- // Is it cheaper to store this as a single character? If so,
- // make it so.
-
- if (m_match_length < THRESHOLD)
- {
- // Send one character. Remember that code_buf[0] is the
- // set of flags for the next eight items.
-
- m_match_length = 1;
- code_buf[0] |= mask;
- code_buf[code_buf_pos++] = m_ring_buffer[r];
- }
-
- // Otherwise, we do indeed have a string that can be stored
- // compressed to save space.
-
- else
- {
- // The next 16 bits need to contain the position (12 bits)
- // and the length (4 bits).
-
- code_buf[code_buf_pos++] = (unsigned char) m_match_position;
- code_buf[code_buf_pos++] = (unsigned char) (
- ((m_match_position >> 4) & 0xf0) |
- (m_match_length - THRESHOLD) );
- }
-
- // Shift the mask one bit to the left so that it will be ready
- // to store the new bit.
-
- mask = (unsigned char) (mask << 1);
-
- // If the mask is now 0, then we know that we have a full set
- // of flags and items in the code buffer. These need to be
- // output.
-
- if (mask == 0)
- {
- // code_buf is the buffer of characters to be output.
- // code_buf_pos is the number of characters it contains.
-
- SendChars(code_buf, code_buf_pos);
-
- // Reset for next buffer...
-
- code_buf[0] = 0;
- code_buf_pos = 1;
- mask = 1;
- }
-
- last_match_length = m_match_length;
-
- // Delete old strings and read new bytes...
-
- for (i = 0; i < last_match_length; i++)
- {
-
- // Get next character...
-
- if (GetChars(&c, 1) != 1)
- break;
-
- // Delete "old strings"
-
- DeleteNode(s);
-
- // Put this character into the ring buffer.
- //
- // The original comment here says "If the position is near
- // the end of the buffer, extend the buffer to make
- // string comparison easier."
- //
- // That's a little misleading, because the "end" of the
- // buffer is really what we consider to be the "beginning"
- // of the buffer, that is, positions 0 through F.
- //
- // The idea is that the front end of the buffer is duplicated
- // into the back end so that when you're looking at characters
- // at the back end of the buffer, you can index ahead (beyond
- // the normal end of the buffer) and see the characters
- // that are at the front end of the buffer wihtout having
- // to adjust the index.
- //
- // That is...
- //
- // 1234xxxxxxxxxxxxxxxxxxxxxxxxxxxxx1234
- // | | |
- // position 0 end of buffer |
- // |
- // duplicate of front of buffer
-
- m_ring_buffer[s] = c;
-
- if (s < F - 1)
- {
- m_ring_buffer[s + N] = c;
- }
-
- // Increment the position, and wrap around when we're at
- // the end. Note that this relies on N being a power of 2.
-
- s = (short int) ( (s + 1) & (N - 1) );
- r = (short int) ( (r + 1) & (N - 1) );
-
- // Register the string that is found in
- // m_ring_buffer[r..r+F-1].
-
- InsertNode(r);
- }
-
- // If we didn't quit because we hit the last_match_length,
- // then we must have quit because we ran out of characters
- // to process.
-
- while (i++ < last_match_length)
- {
- DeleteNode(s);
-
- s = (short int) ( (s + 1) & (N - 1) );
- r = (short int) ( (r + 1) & (N - 1) );
-
- // Note that len hitting 0 is the key that causes the
- // do...while() to terminate. This is the only place
- // within the loop that len is modified.
- //
- // Its original value is F (or a number less than F for
- // short strings).
-
- if (--len)
- {
- InsertNode(r); /* buffer may not be empty. */
- }
- }
-
- // End of do...while() loop. Continue processing until there
- // are no more characters to be compressed. The variable
- // "len" is used to signal this condition.
- }
- while (len > 0);
-
- // There could still be something in the output buffer. Send it
- // now.
-
- if (code_buf_pos > 1)
- {
- // code_buf is the encoded string to send.
- // code_buf_ptr is the number of characters.
-
- SendChars(code_buf, code_buf_pos);
- }
-
- // Done!
- }
-
-/*
- -------------------------------------------------------------------------
- cLZSS::Decode
-
- This function "decodes" the input stream into the output stream.
- The GetChars() and SendChars() functions are used to separate
- this method from the actual i/o.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::Decode( // no return value
- void) // no parameters
-
- {
- int k;
- int r; // node number
- unsigned char c[F]; // an array of chars
- unsigned char flags; // 8 bits of flags
- int flag_count; // which flag we're on
- short int pos; // position in the ring buffer
- short int len; // number of chars in ring buffer
-
- // Initialize the ring buffer with a common string.
- //
- // Note that the last F bytes of the ring buffer are not filled.
-
- memset(m_ring_buffer, ' ', N - F);
-
- r = N - F;
-
- flags = (char) 0;
- flag_count = 0;
-
- for ( ; ; )
- {
-
- // If there are more bits of interest in this flag, then
- // shift that next interesting bit into the 1's position.
- //
- // If this flag has been exhausted, the next byte must
- // be a flag.
-
- if (flag_count > 0)
- {
- flags = (unsigned char) (flags >> 1);
- flag_count--;
- }
- else
- {
- // Next byte must be a flag.
-
- if (GetChars(&flags, 1) != 1)
- break;
-
- // Set the flag counter. While at first it might appear
- // that this should be an 8 since there are 8 bits in the
- // flag, it should really be a 7 because the shift must
- // be performed 7 times in order to see all 8 bits.
-
- flag_count = 7;
- }
-
- // If the low order bit of the flag is now set, then we know
- // that the next byte is a single, unencoded character.
-
- if (flags & 1)
- {
- if (GetChars(c, 1) != 1)
- break;
-
- if (SendChars(c, 1) != 1)
- break;
-
- // Add to buffer, and increment to next spot. Wrap at end.
-
- m_ring_buffer[r] = c[0];
- r = (short int) ( (r + 1) & (N - 1) );
- }
-
- // Otherwise, we know that the next two bytes are a
- // <position,length> pair. The position is in 12 bits and
- // the length is in 4 bits.
-
- else
- {
- // Original code:
- // if ((i = getc(infile)) == EOF)
- // break;
- // if ((j = getc(infile)) == EOF)
- // break;
- // i |= ((j & 0xf0) << 4);
- // j = (j & 0x0f) + THRESHOLD;
- //
- // I've modified this to only make one input call, and
- // have changed the variable names to something more
- // obvious.
-
- if (GetChars(c, 2) != 2)
- break;
-
- // Convert these two characters into the position and
- // length. Note that the length is always at least
- // THRESHOLD, which is why we're able to get a length
- // of 18 out of only 4 bits.
-
- pos = (short int) ( c[0] | ((c[1] & 0xf0) << 4) );
-
- len = (short int) ( (c[1] & 0x0f) + THRESHOLD );
-
- // There are now "len" characters at position "pos" in
- // the ring buffer that can be pulled out. Note that
- // len is never more than F.
-
- for (k = 0; k < len; k++)
- {
- c[k] = m_ring_buffer[(pos + k) & (N - 1)];
-
- // Add to buffer, and increment to next spot. Wrap at end.
-
- m_ring_buffer[r] = c[k];
- r = (short int) ( (r + 1) & (N - 1) );
- }
-
- // Add the "len" characters to the output stream.
-
- if (SendChars(c, len) != len)
- break;
- }
- }
- }
-
diff --git a/src/modules/common/entriesblk.cpp b/src/modules/common/entriesblk.cpp
deleted file mode 100644
index f4fbdeb..0000000
--- a/src/modules/common/entriesblk.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-#include <entriesblk.h>
-#include <stdlib.h>
-#include <string.h>
-
-SWORD_NAMESPACE_START
-
-const int EntriesBlock::METAHEADERSIZE = 4;
- // count(4);
-const int EntriesBlock::METAENTRYSIZE = 8;
- // offset(4); size(4);
-
-EntriesBlock::EntriesBlock(const char *iBlock, unsigned long size) {
- block = (char *)calloc(1, size);
- memcpy(block, iBlock, size);
-}
-
-
-EntriesBlock::EntriesBlock() {
- block = (char *)calloc(1, sizeof(__u32));
-}
-
-
-EntriesBlock::~EntriesBlock() {
- free(block);
-}
-
-
-void EntriesBlock::setCount(int count) {
- __u32 rawCount = archtosword32(count);
- memcpy(block, &rawCount, sizeof(__u32));
-}
-
-
-int EntriesBlock::getCount() {
- __u32 count = 0;
- memcpy(&count, block, sizeof(__u32));
- count = swordtoarch32(count);
- return count;
-}
-
-
-void EntriesBlock::getMetaEntry(int index, unsigned long *offset, unsigned long *size) {
- __u32 rawOffset = 0;
- __u32 rawSize = 0;
- *offset = 0;
- *size = 0;
- if (index >= getCount()) // assert index < count
- return;
-
- // first 4 bytes is count, each 6 bytes after is each meta entry
- memcpy(&rawOffset, block + METAHEADERSIZE + (index * METAENTRYSIZE), sizeof(rawOffset));
- memcpy(&rawSize, block + METAHEADERSIZE + (index * METAENTRYSIZE) + sizeof(rawOffset), sizeof(rawSize));
-
- *offset = (unsigned long)swordtoarch32(rawOffset);
- *size = (unsigned long)swordtoarch32(rawSize);
-}
-
-
-void EntriesBlock::setMetaEntry(int index, unsigned long offset, unsigned long size) {
- __u32 rawOffset = archtosword32(offset);
- __u32 rawSize = archtosword32(size);
-
- if (index >= getCount()) // assert index < count
- return;
-
- // first 4 bytes is count, each 6 bytes after is each meta entry
- memcpy(block + METAHEADERSIZE + (index * METAENTRYSIZE), &rawOffset, sizeof(rawOffset));
- memcpy(block + METAHEADERSIZE + (index * METAENTRYSIZE) + sizeof(rawOffset), &rawSize, sizeof(rawSize));
-}
-
-
-const char *EntriesBlock::getRawData(unsigned long *retSize) {
- unsigned long max = 4;
- int loop;
- unsigned long offset;
- unsigned long size;
- for (loop = 0; loop < getCount(); loop++) {
- getMetaEntry(loop, &offset, &size);
- max = ((offset + size) > max) ? (offset + size) : max;
- }
- *retSize = max;
- return block;
-}
-
-
-int EntriesBlock::addEntry(const char *entry) {
- unsigned long dataSize;
- getRawData(&dataSize);
- unsigned long len = strlen(entry);
- unsigned long offset;
- unsigned long size;
- int count = getCount();
- unsigned long dataStart = METAHEADERSIZE + (count * METAENTRYSIZE);
- // new meta entry + new data size + 1 because null
- block = (char *)realloc(block, dataSize + METAENTRYSIZE + len + 1);
- // shift right to make room for new meta entry
- memmove(block + dataStart + METAENTRYSIZE, block + dataStart, dataSize - dataStart);
-
- for (int loop = 0; loop < count; loop++) {
- getMetaEntry(loop, &offset, &size);
- if (offset) { // if not a deleted entry
- offset += METAENTRYSIZE;
- setMetaEntry(loop, offset, size);
- }
- }
-
- offset = dataSize; // original dataSize before realloc
- size = len + 1;
- // add our text to the end
- memcpy(block + offset + METAENTRYSIZE, entry, size);
- // increment count
- setCount(count + 1);
- // add our meta entry
- setMetaEntry(count, offset + METAENTRYSIZE, size);
- // return index of our new entry
- return count;
-}
-
-
-const char *EntriesBlock::getEntry(int entryIndex) {
- unsigned long offset;
- unsigned long size;
- static char *empty = "";
-
- getMetaEntry(entryIndex, &offset, &size);
- return (offset) ? block+offset : empty;
-}
-
-
-unsigned long EntriesBlock::getEntrySize(int entryIndex) {
- unsigned long offset;
- unsigned long size;
-
- getMetaEntry(entryIndex, &offset, &size);
- return (offset) ? size : 0;
-}
-
-
-void EntriesBlock::removeEntry(int entryIndex) {
- unsigned long offset;
- unsigned long size, size2;
- unsigned long dataSize;
- getRawData(&dataSize);
- getMetaEntry(entryIndex, &offset, &size);
- unsigned long len = size - 1;
- int count = getCount();
- unsigned long dataStart = METAHEADERSIZE + (count * METAENTRYSIZE);
-
- if (!offset) // already deleted
- return;
-
- // shift left to retrieve space used for old entry
- memmove(block + offset, block + offset + size, dataSize - (offset + size));
-
- // fix offset for all entries after our entry that were shifted left
- for (int loop = entryIndex + 1; loop < count; loop++) {
- getMetaEntry(loop, &offset, &size2);
- if (offset) { // if not a deleted entry
- offset -= size;
- setMetaEntry(loop, offset, size2);
- }
- }
-
- // zero out our meta entry
- setMetaEntry(entryIndex, 0L, 0);
-}
-
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/common/lzsscomprs.cpp b/src/modules/common/lzsscomprs.cpp
deleted file mode 100644
index bd8f768..0000000
--- a/src/modules/common/lzsscomprs.cpp
+++ /dev/null
@@ -1,668 +0,0 @@
-/******************************************************************************
- * lzsscomprs.cpp - code for class 'LZSSCompress'- a driver class that
- * provides LZSS compression
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <lzsscomprs.h>
-
-SWORD_NAMESPACE_START
-
-/******************************************************************************
- * LZSSCompress Statics
- */
-
-// m_ring_buffer is a text buffer. It contains "nodes" of
-// uncompressed text that can be indexed by position. That is,
-// a substring of the ring buffer can be indexed by a position
-// and a length. When decoding, the compressed text may contain
-// a position in the ring buffer and a count of the number of
-// bytes from the ring buffer that are to be moved into the
-// uncompressed buffer.
-//
-// This ring buffer is not maintained as part of the compressed
-// text. Instead, it is reconstructed dynamically. That is,
-// it starts out empty and gets built as the text is decompressed.
-//
-// The ring buffer contain N bytes, with an additional F - 1 bytes
-// to facilitate string comparison.
-
-unsigned char LZSSCompress::m_ring_buffer[N + F - 1];
-
-// m_match_position and m_match_length are set by InsertNode().
-//
-// These variables indicate the position in the ring buffer
-// and the number of characters at that position that match
-// a given string.
-
-short int LZSSCompress::m_match_position;
-short int LZSSCompress::m_match_length;
-
-// m_lson, m_rson, and m_dad are the Japanese way of referring to
-// a tree structure. The dad is the parent and it has a right and
-// left son (child).
-//
-// For i = 0 to N-1, m_rson[i] and m_lson[i] will be the right
-// and left children of node i.
-//
-// For i = 0 to N-1, m_dad[i] is the parent of node i.
-//
-// For i = 0 to 255, rson[N + i + 1] is the root of the tree for
-// strings that begin with the character i. Note that this requires
-// one byte characters.
-//
-// These nodes store values of 0...(N-1). Memory requirements
-// can be reduces by using 2-byte integers instead of full 4-byte
-// integers (for 32-bit applications). Therefore, these are
-// defined as "short ints."
-
-short int LZSSCompress::m_lson[N + 1];
-short int LZSSCompress::m_rson[N + 257];
-short int LZSSCompress::m_dad[N + 1];
-
-
-/******************************************************************************
- * LZSSCompress Constructor - Initializes data for instance of LZSSCompress
- *
- */
-
-LZSSCompress::LZSSCompress() : SWCompress() {
-}
-
-
-/******************************************************************************
- * LZSSCompress Destructor - Cleans up instance of LZSSCompress
- */
-
-LZSSCompress::~LZSSCompress() {
-}
-
-
-/******************************************************************************
- * LZSSCompress::InitTree - This function initializes the tree nodes to
- * "empty" states.
- */
-
-void LZSSCompress::InitTree(void) {
- int i;
-
- // For i = 0 to N - 1, m_rson[i] and m_lson[i] will be the right
- // and left children of node i. These nodes need not be
- // initialized. However, for debugging purposes, it is nice to
- // have them initialized. Since this is only used for compression
- // (not decompression), I don't mind spending the time to do it.
- //
- // For the same range of i, m_dad[i] is the parent of node i.
- // These are initialized to a known value that can represent
- // a "not used" state.
-
- for (i = 0; i < N; i++) {
- m_lson[i] = NOT_USED;
- m_rson[i] = NOT_USED;
- m_dad[i] = NOT_USED;
- }
-
- // For i = 0 to 255, m_rson[N + i + 1] is the root of the tree
- // for strings that begin with the character i. This is why
- // the right child array is larger than the left child array.
- // These are also initialzied to a "not used" state.
- //
- // Note that there are 256 of these, one for each of the possible
- // 256 characters.
-
- for (i = N + 1; i <= (N + 256); i++) {
- m_rson[i] = NOT_USED;
- }
-}
-
-
-/******************************************************************************
- * LZSSCompress::InsertNode - This function inserts a string from the ring
- * buffer into one of the trees. It loads the
- * match position and length member variables
- * for the longest match.
- *
- * The string to be inserted is identified by
- * the parameter Pos, A full F bytes are
- * inserted. So,
- * m_ring_buffer[Pos ... Pos+F-1]
- * are inserted.
- *
- * If the matched length is exactly F, then an
- * old node is removed in favor of the new one
- * (because the old one will be deleted
- * sooner).
- *
- * Note that Pos plays a dual role. It is
- * used as both a position in the ring buffer
- * and also as a tree node.
- * m_ring_buffer[Pos] defines a character that
- * is used to identify a tree node.
- *
- * ENT: pos - position in the buffer
- */
-
-void LZSSCompress::InsertNode(short int Pos)
-{
- short int i;
- short int p;
- int cmp;
- unsigned char * key;
-
-/*
- ASSERT(Pos >= 0);
- ASSERT(Pos < N);
-*/
-
- cmp = 1;
- key = &(m_ring_buffer[Pos]);
-
- // The last 256 entries in m_rson contain the root nodes for
- // strings that begin with a letter. Get an index for the
- // first letter in this string.
-
- p = (short int) (N + 1 + key[0]);
-
- // Set the left and right tree nodes for this position to "not
- // used."
-
- m_lson[Pos] = NOT_USED;
- m_rson[Pos] = NOT_USED;
-
- // Haven't matched anything yet.
-
- m_match_length = 0;
-
- for ( ; ; ) {
- if (cmp >= 0) {
- if (m_rson[p] != NOT_USED) {
- p = m_rson[p];
- }
- else {
- m_rson[p] = Pos;
- m_dad[Pos] = p;
- return;
- }
- }
- else {
- if (m_lson[p] != NOT_USED) {
- p = m_lson[p];
- }
- else {
- m_lson[p] = Pos;
- m_dad[Pos] = p;
- return;
- }
- }
-
- // Should we go to the right or the left to look for the
- // next match?
-
- for (i = 1; i < F; i++) {
- cmp = key[i] - m_ring_buffer[p + i];
- if (cmp != 0)
- break;
- }
-
- if (i > m_match_length) {
- m_match_position = p;
- m_match_length = i;
-
- if (i >= F)
- break;
- }
- }
-
- m_dad[Pos] = m_dad[p];
- m_lson[Pos] = m_lson[p];
- m_rson[Pos] = m_rson[p];
-
- m_dad[ m_lson[p] ] = Pos;
- m_dad[ m_rson[p] ] = Pos;
-
- if (m_rson[ m_dad[p] ] == p) {
- m_rson[ m_dad[p] ] = Pos;
- }
- else {
- m_lson[ m_dad[p] ] = Pos;
- }
-
- // Remove "p"
-
- m_dad[p] = NOT_USED;
-}
-
-
-/******************************************************************************
- * LZSSCompress::DeleteNode - This function removes the node "Node" from the
- * tree.
- *
- * ENT: node - node to be removed
- */
-
-void LZSSCompress::DeleteNode(short int Node)
-{
- short int q;
-
-/*
- ASSERT(Node >= 0);
- ASSERT(Node < (N+1));
-*/
-
- if (m_dad[Node] == NOT_USED) { // not in tree, nothing to do
- return;
- }
-
- if (m_rson[Node] == NOT_USED) {
- q = m_lson[Node];
- }
- else if (m_lson[Node] == NOT_USED) {
- q = m_rson[Node];
- }
- else {
- q = m_lson[Node];
- if (m_rson[q] != NOT_USED) {
- do {
- q = m_rson[q];
- } while (m_rson[q] != NOT_USED);
-
- m_rson[ m_dad[q] ] = m_lson[q];
- m_dad[ m_lson[q] ] = m_dad[q];
- m_lson[q] = m_lson[Node];
- m_dad[ m_lson[Node] ] = q;
- }
-
- m_rson[q] = m_rson[Node];
- m_dad[ m_rson[Node] ] = q;
- }
-
- m_dad[q] = m_dad[Node];
-
- if (m_rson[ m_dad[Node] ] == Node) {
- m_rson[ m_dad[Node] ] = q;
- }
- else {
- m_lson[ m_dad[Node] ] = q;
- }
-
- m_dad[Node] = NOT_USED;
-}
-
-
-/******************************************************************************
- * LZSSCompress::Encode - This function "encodes" the input stream into the
- * output stream.
- * The GetChars() and SendChars() functions are
- * used to separate this method from the actual
- * i/o.
- * NOTE: must set zlen for parent class to know length of
- * compressed buffer.
- */
-
-void LZSSCompress::Encode(void)
-{
- short int i; // an iterator
- short int r; // node number in the binary tree
- short int s; // position in the ring buffer
- unsigned short int len; // len of initial string
- short int last_match_length; // length of last match
- short int code_buf_pos; // position in the output buffer
- unsigned char code_buf[17]; // the output buffer
- unsigned char mask; // bit mask for byte 0 of out buf
- unsigned char c; // character read from string
-
- // Start with a clean tree.
-
- InitTree();
- direct = 0; // set direction needed by parent [Get|Send]Chars()
-
- // code_buf[0] works as eight flags. A "1" represents that the
- // unit is an unencoded letter (1 byte), and a "0" represents
- // that the next unit is a <position,length> pair (2 bytes).
- //
- // code_buf[1..16] stores eight units of code. Since the best
- // we can do is store eight <position,length> pairs, at most 16
- // bytes are needed to store this.
- //
- // This is why the maximum size of the code buffer is 17 bytes.
-
- code_buf[0] = 0;
- code_buf_pos = 1;
-
- // Mask iterates over the 8 bits in the code buffer. The first
- // character ends up being stored in the low bit.
- //
- // bit 8 7 6 5 4 3 2 1
- // | |
- // | first sequence in code buffer
- // |
- // last sequence in code buffer
-
- mask = 1;
-
- s = 0;
- r = (short int) N - (short int) F;
-
- // Initialize the ring buffer with spaces...
-
- // Note that the last F bytes of the ring buffer are not filled.
- // This is because those F bytes will be filled in immediately
- // with bytes from the input stream.
-
- memset(m_ring_buffer, ' ', N - F);
-
- // Read F bytes into the last F bytes of the ring buffer.
- //
- // This function loads the buffer with X characters and returns
- // the actual amount loaded.
-
- len = GetChars((char *) &(m_ring_buffer[r]), F);
-
- // Make sure there is something to be compressed.
-
- if (len == 0)
- return;
-
- // Insert the F strings, each of which begins with one or more
- // 'space' characters. Note the order in which these strings
- // are inserted. This way, degenerate trees will be less likely
- // to occur.
-
- for (i = 1; i <= F; i++) {
- InsertNode((short int) (r - i));
- }
-
- // Finally, insert the whole string just read. The
- // member variables match_length and match_position are set.
-
- InsertNode(r);
-
- // Now that we're preloaded, continue till done.
-
- do {
-
- // m_match_length may be spuriously long near the end of
- // text.
-
- if (m_match_length > len) {
- m_match_length = len;
- }
-
- // Is it cheaper to store this as a single character? If so,
- // make it so.
-
- if (m_match_length < THRESHOLD) {
- // Send one character. Remember that code_buf[0] is the
- // set of flags for the next eight items.
-
- m_match_length = 1;
- code_buf[0] |= mask;
- code_buf[code_buf_pos++] = m_ring_buffer[r];
- }
-
- // Otherwise, we do indeed have a string that can be stored
- // compressed to save space.
-
- else {
- // The next 16 bits need to contain the position (12 bits)
- // and the length (4 bits).
-
- code_buf[code_buf_pos++] = (unsigned char) m_match_position;
- code_buf[code_buf_pos++] = (unsigned char) (
- ((m_match_position >> 4) & 0xf0) |
- (m_match_length - THRESHOLD) );
- }
-
- // Shift the mask one bit to the left so that it will be ready
- // to store the new bit.
-
- mask = (unsigned char) (mask << 1);
-
- // If the mask is now 0, then we know that we have a full set
- // of flags and items in the code buffer. These need to be
- // output.
-
- if (!mask) {
- // code_buf is the buffer of characters to be output.
- // code_buf_pos is the number of characters it contains.
-
- SendChars((char *) code_buf, code_buf_pos);
-
- // Reset for next buffer...
-
- code_buf[0] = 0;
- code_buf_pos = 1;
- mask = 1;
- }
-
- last_match_length = m_match_length;
-
- // Delete old strings and read new bytes...
-
- for (i = 0; i < last_match_length; i++) {
- // Get next character...
-
- if (GetChars((char *) &c, 1) != 1)
- break;
-
- // Delete "old strings"
-
- DeleteNode(s);
-
- // Put this character into the ring buffer.
- //
- // The original comment here says "If the position is near
- // the end of the buffer, extend the buffer to make
- // string comparison easier."
- //
- // That's a little misleading, because the "end" of the
- // buffer is really what we consider to be the "beginning"
- // of the buffer, that is, positions 0 through F.
- //
- // The idea is that the front end of the buffer is duplicated
- // into the back end so that when you're looking at characters
- // at the back end of the buffer, you can index ahead (beyond
- // the normal end of the buffer) and see the characters
- // that are at the front end of the buffer wihtout having
- // to adjust the index.
- //
- // That is...
- //
- // 1234xxxxxxxxxxxxxxxxxxxxxxxxxxxxx1234
- // | | |
- // position 0 end of buffer |
- // |
- // duplicate of front of buffer
-
- m_ring_buffer[s] = c;
-
- if (s < F - 1) {
- m_ring_buffer[s + N] = c;
- }
-
- // Increment the position, and wrap around when we're at
- // the end. Note that this relies on N being a power of 2.
-
- s = (short int) ( (s + 1) & (N - 1) );
- r = (short int) ( (r + 1) & (N - 1) );
-
- // Register the string that is found in
- // m_ring_buffer[r..r+F-1].
-
- InsertNode(r);
- }
-
- // If we didn't quit because we hit the last_match_length,
- // then we must have quit because we ran out of characters
- // to process.
-
- while (i++ < last_match_length) {
- DeleteNode(s);
-
- s = (short int) ( (s + 1) & (N - 1) );
- r = (short int) ( (r + 1) & (N - 1) );
-
- // Note that len hitting 0 is the key that causes the
- // do...while() to terminate. This is the only place
- // within the loop that len is modified.
- //
- // Its original value is F (or a number less than F for
- // short strings).
-
- if (--len) {
- InsertNode(r); /* buffer may not be empty. */
- }
- }
-
- // End of do...while() loop. Continue processing until there
- // are no more characters to be compressed. The variable
- // "len" is used to signal this condition.
- } while (len > 0);
-
- // There could still be something in the output buffer. Send it
- // now.
-
- if (code_buf_pos > 1) {
- // code_buf is the encoded string to send.
- // code_buf_ptr is the number of characters.
-
- SendChars((char *) code_buf, code_buf_pos);
- }
-
-
- // must set zlen for parent class to know length of compressed buffer
- zlen = zpos;
-}
-
-
-/******************************************************************************
- * LZSSCompress::Decode - This function "decodes" the input stream into the
- * output stream.
- * The GetChars() and SendChars() functions are
- * used to separate this method from the actual
- * i/o.
- */
-
-void LZSSCompress::Decode(void)
-{
- int k;
- int r; // node number
- unsigned char c[F]; // an array of chars
- unsigned char flags; // 8 bits of flags
- int flag_count; // which flag we're on
- short int pos; // position in the ring buffer
- short int len; // number of chars in ring buffer
- unsigned long totalLen = 0;
-
- direct = 1; // set direction needed by parent [Get|Send]Chars()
-
- // Initialize the ring buffer with a common string.
- //
- // Note that the last F bytes of the ring buffer are not filled.
-
- memset(m_ring_buffer, ' ', N - F);
-
- r = N - F;
-
- flags = (char) 0;
- flag_count = 0;
-
- for ( ; ; ) {
-
- // If there are more bits of interest in this flag, then
- // shift that next interesting bit into the 1's position.
- //
- // If this flag has been exhausted, the next byte must
- // be a flag.
-
- if (flag_count > 0) {
- flags = (unsigned char) (flags >> 1);
- flag_count--;
- }
- else {
- // Next byte must be a flag.
-
- if (GetChars((char *) &flags, 1) != 1)
- break;
-
- // Set the flag counter. While at first it might appear
- // that this should be an 8 since there are 8 bits in the
- // flag, it should really be a 7 because the shift must
- // be performed 7 times in order to see all 8 bits.
-
- flag_count = 7;
- }
-
- // If the low order bit of the flag is now set, then we know
- // that the next byte is a single, unencoded character.
-
- if (flags & 1) {
- if (GetChars((char *) c, 1) != 1)
- break;
-
- if (SendChars((char *) c, 1) != 1) {
- totalLen++;
- break;
- }
-
- // Add to buffer, and increment to next spot. Wrap at end.
-
- m_ring_buffer[r] = c[0];
- r = (short int) ( (r + 1) & (N - 1) );
- }
-
- // Otherwise, we know that the next two bytes are a
- // <position,length> pair. The position is in 12 bits and
- // the length is in 4 bits.
-
- else {
- // Original code:
- // if ((i = getc(infile)) == EOF)
- // break;
- // if ((j = getc(infile)) == EOF)
- // break;
- // i |= ((j & 0xf0) << 4);
- // j = (j & 0x0f) + THRESHOLD;
- //
- // I've modified this to only make one input call, and
- // have changed the variable names to something more
- // obvious.
-
- if (GetChars((char *) c, 2) != 2)
- break;
-
- // Convert these two characters into the position and
- // length. Note that the length is always at least
- // THRESHOLD, which is why we're able to get a length
- // of 18 out of only 4 bits.
-
- pos = (short int) ( c[0] | ((c[1] & 0xf0) << 4) );
-
- len = (short int) ( (c[1] & 0x0f) + THRESHOLD );
-
- // There are now "len" characters at position "pos" in
- // the ring buffer that can be pulled out. Note that
- // len is never more than F.
-
- for (k = 0; k < len; k++) {
- c[k] = m_ring_buffer[(pos + k) & (N - 1)];
-
- // Add to buffer, and increment to next spot. Wrap at end.
-
- m_ring_buffer[r] = c[k];
- r = (short int) ( (r + 1) & (N - 1) );
- }
-
- // Add the "len" :characters to the output stream.
-
- if (SendChars((char *) c, len) != (unsigned int)len) {
- totalLen += len;
- break;
- }
- }
- }
- slen = totalLen;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/common/rawstr.cpp b/src/modules/common/rawstr.cpp
deleted file mode 100644
index 5c4ef0e..0000000
--- a/src/modules/common/rawstr.cpp
+++ /dev/null
@@ -1,555 +0,0 @@
-/******************************************************************************
- * rawstr.cpp - code for class 'RawStr'- a module that reads raw text
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
- * and provides lookup and parsing functions based on
- * class StrKey
- */
-
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#include <stdlib.h>
-#include <utilfuns.h>
-#include <rawstr.h>
-#include <sysdata.h>
-
-SWORD_NAMESPACE_START
-
-/******************************************************************************
- * RawStr Statics
- */
-
-int RawStr::instance = 0;
-char RawStr::nl = '\n';
-
-
-/******************************************************************************
- * RawStr Constructor - Initializes data for instance of RawStr
- *
- * ENT: ipath - path of the directory where data and index files are located.
- * be sure to include the trailing separator (e.g. '/' or '\')
- * (e.g. 'modules/texts/rawtext/webster/')
- */
-
-RawStr::RawStr(const char *ipath, int fileMode)
-{
- char buf[127];
-
- lastoff = -1;
- path = 0;
- stdstr(&path, ipath);
-
-#ifndef O_BINARY // O_BINARY is needed in Borland C++ 4.53
-#define O_BINARY 0 // If it hasn't been defined than we probably
-#endif // don't need it.
-
- if (fileMode == -1) { // try read/write if possible
- fileMode = O_RDWR;
- }
-
- sprintf(buf, "%s.idx", path);
- idxfd = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- sprintf(buf, "%s.dat", path);
- datfd = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- if (datfd < 0) {
- sprintf(buf, "Error: %d", errno);
- perror(buf);
- }
-
- instance++;
-}
-
-
-/******************************************************************************
- * RawStr Destructor - Cleans up instance of RawStr
- */
-
-RawStr::~RawStr()
-{
- if (path)
- delete [] path;
-
- --instance;
-
- FileMgr::systemFileMgr.close(idxfd);
- FileMgr::systemFileMgr.close(datfd);
-}
-
-
-/******************************************************************************
- * RawStr::getidxbufdat - Gets the index string at the given idx offset
- * NOTE: buf is allocated and must be freed by
- * calling function
- *
- * ENT: ioffset - offset in dat file to lookup
- * buf - address of pointer to allocate for storage of string
- */
-
-void RawStr::getIDXBufDat(long ioffset, char **buf)
-{
- int size;
- char ch;
- if (datfd > 0) {
- lseek(datfd->getFd(), ioffset, SEEK_SET);
- for (size = 0; read(datfd->getFd(), &ch, 1) == 1; size++) {
- if ((ch == '\\') || (ch == 10) || (ch == 13))
- break;
- }
- *buf = (*buf) ? (char *)realloc(*buf, size*2 + 1) : (char *)malloc(size*2 + 1);
- if (size) {
- lseek(datfd->getFd(), ioffset, SEEK_SET);
- read(datfd->getFd(), *buf, size);
- }
- (*buf)[size] = 0;
- toupperstr_utf8(*buf, size*2);
- }
- else {
- *buf = (*buf) ? (char *)realloc(*buf, 1) : (char *)malloc(1);
- **buf = 0;
- }
-}
-
-
-/******************************************************************************
- * RawStr::getidxbuf - Gets the index string at the given idx offset
- * NOTE: buf is allocated and must be freed by
- * calling function
- *
- * ENT: ioffset - offset in idx file to lookup
- * buf - address of pointer to allocate for storage of string
- */
-
-void RawStr::getIDXBuf(long ioffset, char **buf)
-{
- char *trybuf, *targetbuf;
- long offset;
-
- if (idxfd > 0) {
- lseek(idxfd->getFd(), ioffset, SEEK_SET);
- read(idxfd->getFd(), &offset, 4);
-
- offset = swordtoarch32(offset);
-
- getIDXBufDat(offset, buf);
- }
-}
-
-
-/******************************************************************************
- * RawStr::findoffset - Finds the offset of the key string from the indexes
- *
- * ENT: key - key string to lookup
- * start - address to store the starting offset
- * size - address to store the size of the entry
- * away - number of entries before of after to jump
- * (default = 0)
- *
- * RET: error status -1 general error; -2 new file
- */
-
-signed char RawStr::findOffset(const char *ikey, long *start, unsigned short *size, long away, long *idxoff)
-{
- char *trybuf, *targetbuf, *key = 0, quitflag = 0;
- signed char retval = -1;
- long headoff, tailoff, tryoff = 0, maxoff = 0;
-
- if (idxfd->getFd() >=0) {
- tailoff = maxoff = lseek(idxfd->getFd(), 0, SEEK_END) - 6;
- retval = (tailoff >= 0) ? 0 : -2; // if NOT new file
- if (*ikey) {
- headoff = 0;
-
- stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
-
- trybuf = 0;
-
- while (headoff < tailoff) {
- tryoff = (lastoff == -1) ? headoff + ((((tailoff / 6) - (headoff / 6))) / 2) * 6 : lastoff;
- lastoff = -1;
- getIDXBuf(tryoff, &trybuf);
-
- if (!*trybuf && tryoff) { // In case of extra entry at end of idx (not first entry)
- tryoff += (tryoff > (maxoff / 2))?-6:6;
- retval = -1;
- break;
- }
-
- if (!strcmp(key, trybuf))
- break;
-
- int diff = strcmp(key, trybuf);
- if (diff < 0)
- tailoff = (tryoff == headoff) ? headoff : tryoff;
- else headoff = tryoff;
- if (tailoff == headoff + 6) {
- if (quitflag++)
- headoff = tailoff;
- }
- }
- if (headoff >= tailoff)
- tryoff = headoff;
- if (trybuf)
- free(trybuf);
- delete [] key;
- }
- else tryoff = 0;
-
- lseek(idxfd->getFd(), tryoff, SEEK_SET);
-
- *start = *size = 0;
- read(idxfd->getFd(), start, 4);
- read(idxfd->getFd(), size, 2);
- if (idxoff)
- *idxoff = tryoff;
-
- *start = swordtoarch32(*start);
- *size = swordtoarch16(*size);
-
- while (away) {
- long laststart = *start;
- unsigned short lastsize = *size;
- long lasttry = tryoff;
- tryoff += (away > 0) ? 6 : -6;
-
- bool bad = false;
- if (((tryoff + (away*6)) < -6) || (tryoff + (away*6) > (maxoff+6)))
- bad = true;
- else if (lseek(idxfd->getFd(), tryoff, SEEK_SET) < 0)
- bad = true;
- if (bad) {
- retval = -1;
- *start = laststart;
- *size = lastsize;
- tryoff = lasttry;
- if (idxoff)
- *idxoff = tryoff;
- break;
- }
- read(idxfd->getFd(), start, 4);
- read(idxfd->getFd(), size, 2);
- if (idxoff)
- *idxoff = tryoff;
-
- *start = swordtoarch32(*start);
- *size = swordtoarch16(*size);
-
- if (((laststart != *start) || (lastsize != *size)) && (*start >= 0) && (*size))
- away += (away < 0) ? 1 : -1;
- }
-
- lastoff = tryoff;
- }
- else {
- *start = 0;
- *size = 0;
- if (idxoff)
- *idxoff = 0;
- retval = -1;
- }
- return retval;
-}
-
-
-/******************************************************************************
- * RawStr::preptext - Prepares the text before returning it to external
- * objects
- *
- * ENT: buf - buffer where text is stored and where to store the prep'd
- * text.
- */
-
-void RawStr::prepText(SWBuf &buf) {
- unsigned int to, from;
- char space = 0, cr = 0, realdata = 0, nlcnt = 0;
- char *rawBuf = buf.getRawData();
- for (to = from = 0; rawBuf[from]; from++) {
- switch (rawBuf[from]) {
- case 10:
- if (!realdata)
- continue;
- space = (cr) ? 0 : 1;
- cr = 0;
- nlcnt++;
- if (nlcnt > 1) {
-// *to++ = nl;
- rawBuf[to++] = 10;
-// *to++ = nl[1];
-// nlcnt = 0;
- }
- continue;
- case 13:
- if (!realdata)
- continue;
-// *to++ = nl[0];
- rawBuf[to++] = 10;
- space = 0;
- cr = 1;
- continue;
- }
- realdata = 1;
- nlcnt = 0;
- if (space) {
- space = 0;
- if (rawBuf[from] != ' ') {
- rawBuf[to++] = ' ';
- from--;
- continue;
- }
- }
- rawBuf[to++] = rawBuf[from];
- }
- buf.setSize(to);
-
- while (to > 1) { // remove trailing excess
- to--;
- if ((rawBuf[to] == 10) || (rawBuf[to] == ' '))
- buf.setSize(to);
- else break;
- }
-}
-
-
-/******************************************************************************
- * RawStr::readtext - gets text at a given offset
- *
- * ENT:
- * start - starting offset where the text is located in the file
- * size - size of text entry
- * buf - buffer to store text
- *
- */
-
-void RawStr::readText(long istart, unsigned short *isize, char **idxbuf, SWBuf &buf)
-{
- unsigned int ch;
- char *idxbuflocal = 0;
- getIDXBufDat(istart, &idxbuflocal);
- long start = istart;
-
- do {
- if (*idxbuf)
- delete [] *idxbuf;
- buf = "";
- buf.setFillByte(0);
- buf.setSize(++(*isize));
-
- *idxbuf = new char [ (*isize) ];
-
- lseek(datfd->getFd(), start, SEEK_SET);
- read(datfd->getFd(), buf.getRawData(), (int)((*isize) - 1));
-
- for (ch = 0; buf[ch]; ch++) { // skip over index string
- if (buf[ch] == 10) {
- ch++;
- break;
- }
- }
- buf = SWBuf(buf.c_str()+ch);
- // resolve link
- if (!strncmp(buf.c_str(), "@LINK", 5)) {
- for (ch = 0; buf[ch]; ch++) { // null before nl
- if (buf[ch] == 10) {
- buf[ch] = 0;
- break;
- }
- }
- findOffset(buf.c_str() + 6, &start, isize);
- }
- else break;
- }
- while (true); // while we're resolving links
-
- if (idxbuflocal) {
- int localsize = strlen(idxbuflocal);
- localsize = (localsize < (*isize - 1)) ? localsize : (*isize - 1);
- strncpy(*idxbuf, idxbuflocal, localsize);
- (*idxbuf)[localsize] = 0;
- free(idxbuflocal);
- }
-}
-
-
-/******************************************************************************
- * RawLD::settext - Sets text for current offset
- *
- * ENT: key - key for this entry
- * buf - buffer to store
- * len - length of buffer (0 - null terminated)
- */
-
-void RawStr::doSetText(const char *ikey, const char *buf, long len)
-{
-
- long start, outstart;
- long idxoff;
- long endoff;
- long shiftSize;
- unsigned short size;
- unsigned short outsize;
- static const char nl[] = {13, 10};
- char *tmpbuf = 0;
- char *key = 0;
- char *dbKey = 0;
- char *idxBytes = 0;
- char *outbuf = 0;
- char *ch = 0;
-
- char errorStatus = findOffset(ikey, &start, &size, 0, &idxoff);
- stdstr(&key, ikey, 2);
- toupperstr_utf8(key, strlen(key)*2);
-
- len = (len < 0) ? strlen(buf) : len;
-
- getIDXBufDat(start, &dbKey);
-
- if (strcmp(key, dbKey) < 0) {
- }
- else if (strcmp(key, dbKey) > 0) {
- if (errorStatus != -2) // not a new file
- idxoff += 6;
- else idxoff = 0;
- }
- else if ((!strcmp(key, dbKey)) && (len>0 /*we're not deleting*/)) { // got absolute entry
- do {
- tmpbuf = new char [ size + 2 ];
- memset(tmpbuf, 0, size + 2);
- lseek(datfd->getFd(), start, SEEK_SET);
- read(datfd->getFd(), tmpbuf, (int)(size - 1));
-
- for (ch = tmpbuf; *ch; ch++) { // skip over index string
- if (*ch == 10) {
- ch++;
- break;
- }
- }
- memmove(tmpbuf, ch, size - (unsigned short)(ch-tmpbuf));
-
- // resolve link
- if (!strncmp(tmpbuf, "@LINK", 5) && (len)) {
- for (ch = tmpbuf; *ch; ch++) { // null before nl
- if (*ch == 10) {
- *ch = 0;
- break;
- }
- }
- findOffset(tmpbuf + 6, &start, &size, 0, &idxoff);
- }
- else break;
- }
- while (true); // while we're resolving links
- }
-
- endoff = lseek(idxfd->getFd(), 0, SEEK_END);
-
- shiftSize = endoff - idxoff;
-
- if (shiftSize > 0) {
- idxBytes = new char [ shiftSize ];
- lseek(idxfd->getFd(), idxoff, SEEK_SET);
- read(idxfd->getFd(), idxBytes, shiftSize);
- }
-
- outbuf = new char [ len + strlen(key) + 5 ];
- sprintf(outbuf, "%s%c%c", key, 13, 10);
- size = strlen(outbuf);
- memcpy(outbuf + size, buf, len);
- size = outsize = size + (len);
-
- start = outstart = lseek(datfd->getFd(), 0, SEEK_END);
-
- outstart = archtosword32(start);
- outsize = archtosword16(size);
-
- lseek(idxfd->getFd(), idxoff, SEEK_SET);
- if (len > 0) {
- lseek(datfd->getFd(), start, SEEK_SET);
- write(datfd->getFd(), outbuf, (int)size);
-
- // add a new line to make data file easier to read in an editor
- write(datfd->getFd(), &nl, 2);
-
- write(idxfd->getFd(), &outstart, 4);
- write(idxfd->getFd(), &outsize, 2);
- if (idxBytes) {
- write(idxfd->getFd(), idxBytes, shiftSize);
- delete [] idxBytes;
- }
- }
- else { // delete entry
- if (idxBytes) {
- write(idxfd->getFd(), idxBytes+6, shiftSize-6);
- lseek(idxfd->getFd(), -1, SEEK_CUR); // last valid byte
- FileMgr::systemFileMgr.trunc(idxfd); // truncate index
- delete [] idxBytes;
- }
- }
-
- delete [] key;
- delete [] outbuf;
- free(dbKey);
-}
-
-
-/******************************************************************************
- * RawLD::linkentry - links one entry to another
- *
- * ENT: testmt - testament to find (0 - Bible/module introduction)
- * destidxoff - dest offset into .vss
- * srcidxoff - source offset into .vss
- */
-
-void RawStr::doLinkEntry(const char *destkey, const char *srckey) {
- char *text = new char [ strlen(destkey) + 7 ];
- sprintf(text, "@LINK %s", destkey);
- doSetText(srckey, text);
- delete [] text;
-}
-
-
-/******************************************************************************
- * RawLD::CreateModule - Creates new module files
- *
- * ENT: path - directory to store module files
- * RET: error status
- */
-
-signed char RawStr::createModule(const char *ipath)
-{
- char *path = 0;
- char *buf = new char [ strlen (ipath) + 20 ];
- FileDesc *fd, *fd2;
-
- stdstr(&path, ipath);
-
- if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\'))
- path[strlen(path)-1] = 0;
-
- sprintf(buf, "%s.dat", path);
- unlink(buf);
- fd = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd->getFd();
- FileMgr::systemFileMgr.close(fd);
-
- sprintf(buf, "%s.idx", path);
- unlink(buf);
- fd2 = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd2->getFd();
- FileMgr::systemFileMgr.close(fd2);
-
- delete [] path;
-
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/common/rawstr4.cpp b/src/modules/common/rawstr4.cpp
deleted file mode 100644
index e278675..0000000
--- a/src/modules/common/rawstr4.cpp
+++ /dev/null
@@ -1,561 +0,0 @@
-/******************************************************************************
- * rawstr.cpp - code for class 'RawStr'- a module that reads raw text
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
- * and provides lookup and parsing functions based on
- * class StrKey
- */
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#include <stdlib.h>
-#include <utilfuns.h>
-#include <rawstr4.h>
-#include <sysdata.h>
-
-SWORD_NAMESPACE_START
-
-/******************************************************************************
- * RawStr Statics
- */
-
-int RawStr4::instance = 0;
-
-
-/******************************************************************************
- * RawStr Constructor - Initializes data for instance of RawStr
- *
- * ENT: ipath - path of the directory where data and index files are located.
- * be sure to include the trailing separator (e.g. '/' or '\')
- * (e.g. 'modules/texts/rawtext/webster/')
- */
-
-RawStr4::RawStr4(const char *ipath, int fileMode)
-{
- char buf[127];
-
- nl = '\n';
- lastoff = -1;
- path = 0;
- stdstr(&path, ipath);
-
-#ifndef O_BINARY // O_BINARY is needed in Borland C++ 4.53
-#define O_BINARY 0 // If it hasn't been defined than we probably
-#endif // don't need it.
-
- if (fileMode == -1) { // try read/write if possible
- fileMode = O_RDWR;
- }
-
- sprintf(buf, "%s.idx", path);
- idxfd = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- sprintf(buf, "%s.dat", path);
- datfd = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- if (datfd < 0) {
- sprintf(buf, "Error: %d", errno);
- perror(buf);
- }
-
- instance++;
-}
-
-
-/******************************************************************************
- * RawStr Destructor - Cleans up instance of RawStr
- */
-
-RawStr4::~RawStr4()
-{
- if (path)
- delete [] path;
-
- --instance;
-
- FileMgr::systemFileMgr.close(idxfd);
- FileMgr::systemFileMgr.close(datfd);
-}
-
-
-/******************************************************************************
- * RawStr4::getidxbufdat - Gets the index string at the given idx offset
- * NOTE: buf is allocated and must be freed by
- * calling function
- *
- * ENT: ioffset - offset in dat file to lookup
- * buf - address of pointer to allocate for storage of string
- */
-
-void RawStr4::getIDXBufDat(long ioffset, char **buf) {
- int size;
- char ch;
- if (datfd > 0) {
- lseek(datfd->getFd(), ioffset, SEEK_SET);
- for (size = 0; read(datfd->getFd(), &ch, 1) == 1; size++) {
- if ((ch == '\\') || (ch == 10) || (ch == 13))
- break;
- }
- *buf = (*buf) ? (char *)realloc(*buf, size*2 + 1) : (char *)malloc(size*2 + 1);
- if (size) {
- lseek(datfd->getFd(), ioffset, SEEK_SET);
- read(datfd->getFd(), *buf, size);
- }
- (*buf)[size] = 0;
- toupperstr_utf8(*buf, size*2);
- }
- else {
- *buf = (*buf) ? (char *)realloc(*buf, 1) : (char *)malloc(1);
- **buf = 0;
- }
-}
-
-
-/******************************************************************************
- * RawStr4::getidxbuf - Gets the index string at the given idx offset
- * NOTE: buf is allocated and must be freed by
- * calling function
- *
- * ENT: ioffset - offset in idx file to lookup
- * buf - address of pointer to allocate for storage of string
- */
-
-void RawStr4::getIDXBuf(long ioffset, char **buf)
-{
- char *trybuf, *targetbuf;
- long offset;
-
- if (idxfd > 0) {
- lseek(idxfd->getFd(), ioffset, SEEK_SET);
- read(idxfd->getFd(), &offset, 4);
-
- offset = swordtoarch32(offset);
-
- getIDXBufDat(offset, buf);
-
-/* What the heck is this supposed to do??????
- for (trybuf = targetbuf = *buf; *trybuf; trybuf++, targetbuf++) {
- *targetbuf = *trybuf;
- }
- *targetbuf = 0;
- trybuf = 0;
- toupperstr_utf8(targetbuf);
-*/
- }
-}
-
-
-/******************************************************************************
- * RawStr4::findoffset - Finds the offset of the key string from the indexes
- *
- * ENT: key - key string to lookup
- * start - address to store the starting offset
- * size - address to store the size of the entry
- * away - number of entries before of after to jump
- * (default = 0)
- *
- * RET: error status -1 general error; -2 new file
- */
-
-signed char RawStr4::findOffset(const char *ikey, long *start, unsigned long *size, long away, long *idxoff)
-{
- char *trybuf, *targetbuf, *key = 0, quitflag = 0;
- signed char retval = -1;
- long headoff, tailoff, tryoff = 0, maxoff = 0;
-
- if (idxfd->getFd() >=0) {
- tailoff = maxoff = lseek(idxfd->getFd(), 0, SEEK_END) - 8;
- retval = (tailoff >= 0) ? 0 : -2; // if NOT new file
- if (*ikey) {
- headoff = 0;
-
- stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
-
- trybuf = 0;
-
- while (headoff < tailoff) {
- tryoff = (lastoff == -1) ? headoff + ((((tailoff / 8) - (headoff / 8))) / 2) * 8 : lastoff;
- lastoff = -1;
- getIDXBuf(tryoff, &trybuf);
-
- if (!*trybuf) { // In case of extra entry at end of idx
- tryoff += (tryoff > (maxoff / 2))?-8:8;
- retval = -1;
- break;
- }
-
- if (!strcmp(key, trybuf))
- break;
-
- int diff = strcmp(key, trybuf);
- if (diff < 0)
- tailoff = (tryoff == headoff) ? headoff : tryoff;
- else headoff = tryoff;
- if (tailoff == headoff + 8) {
- if (quitflag++)
- headoff = tailoff;
- }
- }
- if (headoff >= tailoff)
- tryoff = headoff;
- if (trybuf)
- free(trybuf);
- delete [] key;
- }
- else tryoff = 0;
-
- lseek(idxfd->getFd(), tryoff, SEEK_SET);
-
- *start = *size = 0;
- read(idxfd->getFd(), start, 4);
- read(idxfd->getFd(), size, 4);
- if (idxoff)
- *idxoff = tryoff;
-
- *start = swordtoarch32(*start);
- *size = swordtoarch32(*size);
-
- while (away) {
- long laststart = *start;
- unsigned long lastsize = *size;
- long lasttry = tryoff;
- tryoff += (away > 0) ? 8 : -8;
-
- bool bad = false;
- if (((tryoff + (away*8)) < -8) || (tryoff + (away*8) > (maxoff+8)))
- bad = true;
- else if (lseek(idxfd->getFd(), tryoff, SEEK_SET) < 0)
- bad = true;
- if (bad) {
- retval = -1;
- *start = laststart;
- *size = lastsize;
- tryoff = lasttry;
- if (idxoff)
- *idxoff = tryoff;
- break;
- }
- read(idxfd->getFd(), start, 4);
- read(idxfd->getFd(), size, 4);
- if (idxoff)
- *idxoff = tryoff;
-
- *start = swordtoarch32(*start);
- *size = swordtoarch32(*size);
-
- if (((laststart != *start) || (lastsize != *size)) && (*start >= 0) && (*size))
- away += (away < 0) ? 1 : -1;
- }
-
- lastoff = tryoff;
- }
- else {
- *start = 0;
- *size = 0;
- if (idxoff)
- *idxoff = 0;
- retval = -1;
- }
- return retval;
-}
-
-
-/******************************************************************************
- * RawStr4::preptext - Prepares the text before returning it to external
- * objects
- *
- * ENT: buf - buffer where text is stored and where to store the prep'd
- * text.
- */
-
-void RawStr4::prepText(SWBuf &buf) {
- unsigned int to, from;
- char space = 0, cr = 0, realdata = 0, nlcnt = 0;
- char *rawBuf = buf.getRawData();
- for (to = from = 0; rawBuf[from]; from++) {
- switch (rawBuf[from]) {
- case 10:
- if (!realdata)
- continue;
- space = (cr) ? 0 : 1;
- cr = 0;
- nlcnt++;
- if (nlcnt > 1) {
-// *to++ = nl;
- rawBuf[to++] = 10;
-// *to++ = nl[1];
-// nlcnt = 0;
- }
- continue;
- case 13:
- if (!realdata)
- continue;
-// *to++ = nl[0];
- rawBuf[to++] = 10;
- space = 0;
- cr = 1;
- continue;
- }
- realdata = 1;
- nlcnt = 0;
- if (space) {
- space = 0;
- if (rawBuf[from] != ' ') {
- rawBuf[to++] = ' ';
- from--;
- continue;
- }
- }
- rawBuf[to++] = rawBuf[from];
- }
- buf.setSize(to);
-
- while (to > 1) { // remove trailing excess
- to--;
- if ((rawBuf[to] == 10) || (rawBuf[to] == ' '))
- buf.setSize(to);
- else break;
- }
-}
-
-
-/******************************************************************************
- * RawStr4::readtext - gets text at a given offset
- *
- * ENT:
- * start - starting offset where the text is located in the file
- * size - size of text entry
- * buf - buffer to store text
- *
- */
-
-void RawStr4::readText(long istart, unsigned long *isize, char **idxbuf, SWBuf &buf)
-{
- unsigned int ch;
- char *idxbuflocal = 0;
- getIDXBufDat(istart, &idxbuflocal);
- long start = istart;
-
- do {
- if (*idxbuf)
- delete [] *idxbuf;
- *idxbuf = new char [ (*isize) ];
-
- buf = "";
- buf.setFillByte(0);
- buf.setSize(*isize);
- lseek(datfd->getFd(), start, SEEK_SET);
- read(datfd->getFd(), buf.getRawData(), (int)((*isize) - 1));
-
- for (ch = 0; buf[ch]; ch++) { // skip over index string
- if (buf[ch] == 10) {
- ch++;
- break;
- }
- }
- buf = SWBuf(buf.c_str()+ch);
- // resolve link
- if (!strncmp(buf.c_str(), "@LINK", 5)) {
- for (ch = 0; buf[ch]; ch++) { // null before nl
- if (buf[ch] == 10) {
- buf[ch] = 0;
- break;
- }
- }
- findOffset(buf.c_str() + 6, &start, isize);
-
- }
- else break;
- }
- while (true); // while we're resolving links
-
- if (idxbuflocal) {
- int localsize = strlen(idxbuflocal);
- localsize = (localsize < (*isize - 1)) ? localsize : (*isize - 1);
- strncpy(*idxbuf, idxbuflocal, localsize);
- (*idxbuf)[localsize] = 0;
- free(idxbuflocal);
- }
-}
-
-
-/******************************************************************************
- * RawLD::settext - Sets text for current offset
- *
- * ENT: key - key for this entry
- * buf - buffer to store
- * len - length of buffer (0 - null terminated)
- */
-
-void RawStr4::doSetText(const char *ikey, const char *buf, long len) {
-
- long start, outstart;
- long idxoff;
- long endoff;
- long shiftSize;
- unsigned long size;
- unsigned long outsize;
- static const char nl[] = {13, 10};
- char *tmpbuf = 0;
- char *key = 0;
- char *dbKey = 0;
- char *idxBytes = 0;
- char *outbuf = 0;
- char *ch = 0;
-
- char errorStatus = findOffset(ikey, &start, &size, 0, &idxoff);
- stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
-
- len = (len < 0) ? strlen(buf) : len;
- getIDXBufDat(start, &dbKey);
-
- if (strcmp(key, dbKey) < 0) {
- }
- else if (strcmp(key, dbKey) > 0) {
- if (errorStatus != -2) // not a new file
- idxoff += 8;
- else idxoff = 0;
- }
- else if ((!strcmp(key, dbKey)) && (len>0/*we're not deleting*/)) { // got absolute entry
- do {
- tmpbuf = new char [ size + 2 ];
- memset(tmpbuf, 0, size + 2);
- lseek(datfd->getFd(), start, SEEK_SET);
- read(datfd->getFd(), tmpbuf, (int)(size - 1));
-
- for (ch = tmpbuf; *ch; ch++) { // skip over index string
- if (*ch == 10) {
- ch++;
- break;
- }
- }
- memmove(tmpbuf, ch, size - (unsigned long)(ch-tmpbuf));
-
- // resolve link
- if (!strncmp(tmpbuf, "@LINK", 5) && (len > 0)) {
- for (ch = tmpbuf; *ch; ch++) { // null before nl
- if (*ch == 10) {
- *ch = 0;
- break;
- }
- }
- findOffset(tmpbuf + 8, &start, &size, 0, &idxoff);
- ++size;
- }
- else break;
- }
- while (true); // while we're resolving links
- }
-
- endoff = lseek(idxfd->getFd(), 0, SEEK_END);
-
- shiftSize = endoff - idxoff;
-
- if (shiftSize > 0) {
- idxBytes = new char [ shiftSize ];
- lseek(idxfd->getFd(), idxoff, SEEK_SET);
- read(idxfd->getFd(), idxBytes, shiftSize);
- }
-
- outbuf = new char [ len + strlen(key) + 5 ];
- sprintf(outbuf, "%s%c%c", key, 13, 10);
- size = strlen(outbuf);
- memcpy(outbuf + size, buf, len);
- size = outsize = size + len;
-
- start = outstart = lseek(datfd->getFd(), 0, SEEK_END);
-
- outstart = archtosword32(start);
- outsize = archtosword32(size);
-
- lseek(idxfd->getFd(), idxoff, SEEK_SET);
- if (len>0) {
- lseek(datfd->getFd(), start, SEEK_SET);
- write(datfd->getFd(), outbuf, (long)size);
-
- // add a new line to make data file easier to read in an editor
- write(datfd->getFd(), &nl, 2);
-
- write(idxfd->getFd(), &outstart, 4);
- write(idxfd->getFd(), &outsize, 4);
- if (idxBytes) {
- write(idxfd->getFd(), idxBytes, shiftSize);
- delete [] idxBytes;
- }
- }
- else { // delete entry
- if (idxBytes) {
- write(idxfd->getFd(), idxBytes+8, shiftSize-8);
- lseek(idxfd->getFd(), -1, SEEK_CUR); // last valid byte
- FileMgr::systemFileMgr.trunc(idxfd); // truncate index
- delete [] idxBytes;
- }
- }
-
- delete [] key;
- delete [] outbuf;
- free(dbKey);
-}
-
-
-/******************************************************************************
- * RawLD::linkentry - links one entry to another
- *
- * ENT: testmt - testament to find (0 - Bible/module introduction)
- * destidxoff - dest offset into .vss
- * srcidxoff - source offset into .vss
- */
-
-void RawStr4::doLinkEntry(const char *destkey, const char *srckey) {
- char *text = new char [ strlen(destkey) + 7 ];
- sprintf(text, "@LINK %s", destkey);
- doSetText(srckey, text);
- delete [] text;
-}
-
-
-/******************************************************************************
- * RawLD::CreateModule - Creates new module files
- *
- * ENT: path - directory to store module files
- * RET: error status
- */
-
-signed char RawStr4::createModule(const char *ipath)
-{
- char *path = 0;
- char *buf = new char [ strlen (ipath) + 20 ];
- FileDesc *fd, *fd2;
-
- stdstr(&path, ipath);
-
- if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\'))
- path[strlen(path)-1] = 0;
-
- sprintf(buf, "%s.dat", path);
- unlink(buf);
- fd = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd->getFd();
- FileMgr::systemFileMgr.close(fd);
-
- sprintf(buf, "%s.idx", path);
- unlink(buf);
- fd2 = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd2->getFd();
- FileMgr::systemFileMgr.close(fd2);
-
- delete [] path;
-
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/common/rawverse.cpp b/src/modules/common/rawverse.cpp
deleted file mode 100644
index b5bff9f..0000000
--- a/src/modules/common/rawverse.cpp
+++ /dev/null
@@ -1,353 +0,0 @@
-/******************************************************************************
- * rawverse.cpp - code for class 'RawVerse'- a module that reads raw text
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
- * and provides lookup and parsing functions based on
- * class VerseKey
- */
-
-
-#include <ctype.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#include <sys/stat.h>
-#else
-#include <unistd.h>
-#endif
-
-#include <utilfuns.h>
-#include <rawverse.h>
-#include <versekey.h>
-#include <sysdata.h>
-
-#ifndef O_BINARY // O_BINARY is needed in Borland C++ 4.53
-#define O_BINARY 0 // If it hasn't been defined than we probably
-#endif // don't need it.
-
-SWORD_NAMESPACE_START
-
-/******************************************************************************
- * RawVerse Statics
- */
-
-int RawVerse::instance = 0;
-const char *RawVerse::nl = "\r\n";
-
-
-/******************************************************************************
- * RawVerse Constructor - Initializes data for instance of RawVerse
- *
- * ENT: ipath - path of the directory where data and index files are located.
- * be sure to include the trailing separator (e.g. '/' or '\')
- * (e.g. 'modules/texts/rawtext/webster/')
- */
-
-RawVerse::RawVerse(const char *ipath, int fileMode)
-{
- char *buf;
-
- path = 0;
- stdstr(&path, ipath);
- buf = new char [ strlen(path) + 80 ];
- if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\'))
- path[strlen(path)-1] = 0;
-
- if (fileMode == -1) { // try read/write if possible
- fileMode = O_RDWR;
- }
-
- sprintf(buf, "%s/ot.vss", path);
- idxfp[0] = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- sprintf(buf, "%s/nt.vss", path);
- idxfp[1] = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- sprintf(buf, "%s/ot", path);
- textfp[0] = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- sprintf(buf, "%s/nt", path);
- textfp[1] = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- delete [] buf;
- instance++;
-}
-
-
-/******************************************************************************
- * RawVerse Destructor - Cleans up instance of RawVerse
- */
-
-RawVerse::~RawVerse()
-{
- int loop1;
-
- if (path)
- delete [] path;
-
- --instance;
-
- for (loop1 = 0; loop1 < 2; loop1++) {
- FileMgr::systemFileMgr.close(idxfp[loop1]);
- FileMgr::systemFileMgr.close(textfp[loop1]);
- }
-}
-
-
-/******************************************************************************
- * RawVerse::findoffset - Finds the offset of the key verse from the indexes
- *
- * ENT: testmt - testament to find (0 - Bible/module introduction)
- * idxoff - offset into .vss
- * start - address to store the starting offset
- * size - address to store the size of the entry
- */
-
-void RawVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *size) {
- idxoff *= 6;
- if (!testmt)
- testmt = ((idxfp[1]) ? 1:2);
-
- if (idxfp[testmt-1]->getFd() >= 0) {
- lseek(idxfp[testmt-1]->getFd(), idxoff, SEEK_SET);
- read(idxfp[testmt-1]->getFd(), start, 4);
- long len = read(idxfp[testmt-1]->getFd(), size, 2); // read size
-
- *start = swordtoarch32(*start);
- *size = swordtoarch16(*size);
-
- if (len < 2) {
- *size = (unsigned short)((*start) ? (lseek(textfp[testmt-1]->getFd(), 0, SEEK_END) - (long)*start) : 0); // if for some reason we get an error reading size, make size to end of file
- }
- }
- else {
- *start = 0;
- *size = 0;
- }
-}
-
-
-/******************************************************************************
- * RawVerse::preptext - Prepares the text before returning it to external
- * objects
- *
- * ENT: buf - buffer where text is stored and where to store the prep'd
- * text.
- */
-
-void RawVerse::prepText(SWBuf &buf) {
- unsigned int to, from;
- char space = 0, cr = 0, realdata = 0, nlcnt = 0;
- char *rawBuf = buf.getRawData();
- for (to = from = 0; rawBuf[from]; from++) {
- switch (rawBuf[from]) {
- case 10:
- if (!realdata)
- continue;
- space = (cr) ? 0 : 1;
- cr = 0;
- nlcnt++;
- if (nlcnt > 1) {
-// *to++ = nl;
- rawBuf[to++] = 10;
-// *to++ = nl[1];
-// nlcnt = 0;
- }
- continue;
- case 13:
- if (!realdata)
- continue;
-// *to++ = nl[0];
- rawBuf[to++] = 10;
- space = 0;
- cr = 1;
- continue;
- }
- realdata = 1;
- nlcnt = 0;
- if (space) {
- space = 0;
- if (rawBuf[from] != ' ') {
- rawBuf[to++] = ' ';
- from--;
- continue;
- }
- }
- rawBuf[to++] = rawBuf[from];
- }
- buf.setSize(to);
-
- while (to > 1) { // remove trailing excess
- to--;
- if ((rawBuf[to] == 10) || (rawBuf[to] == ' '))
- buf.setSize(to);
- else break;
- }
-}
-
-
-/******************************************************************************
- * RawVerse::readtext - gets text at a given offset
- *
- * ENT: testmt - testament file to search in (0 - Old; 1 - New)
- * start - starting offset where the text is located in the file
- * size - size of text entry + 2 (null)(null)
- * buf - buffer to store text
- *
- */
-
-void RawVerse::readText(char testmt, long start, unsigned short size, SWBuf &buf) {
- buf = "";
- buf.setFillByte(0);
- buf.setSize(size + 1);
- if (!testmt)
- testmt = ((idxfp[1]) ? 1:2);
- if (size) {
- if (textfp[testmt-1]->getFd() >= 0) {
- lseek(textfp[testmt-1]->getFd(), start, SEEK_SET);
- read(textfp[testmt-1]->getFd(), buf.getRawData(), (int)size);
- }
- }
-}
-
-
-/******************************************************************************
- * RawVerse::settext - Sets text for current offset
- *
- * ENT: testmt - testament to find (0 - Bible/module introduction)
- * idxoff - offset into .vss
- * buf - buffer to store
- * len - length of buffer (0 - null terminated)
- */
-
-void RawVerse::doSetText(char testmt, long idxoff, const char *buf, long len)
-{
- long start, outstart;
- unsigned short size;
- unsigned short outsize;
-
- idxoff *= 6;
- if (!testmt)
- testmt = ((idxfp[1]) ? 1:2);
-
- size = outsize = (len < 0) ? strlen(buf) : len;
-
- start = outstart = lseek(textfp[testmt-1]->getFd(), 0, SEEK_END);
- lseek(idxfp[testmt-1]->getFd(), idxoff, SEEK_SET);
-
- if (size) {
- lseek(textfp[testmt-1]->getFd(), start, SEEK_SET);
- write(textfp[testmt-1]->getFd(), buf, (int)size);
-
- // add a new line to make data file easier to read in an editor
- write(textfp[testmt-1]->getFd(), nl, 2);
- }
- else {
- start = 0;
- }
-
- outstart = archtosword32(start);
- outsize = archtosword16(size);
-
- write(idxfp[testmt-1]->getFd(), &outstart, 4);
- write(idxfp[testmt-1]->getFd(), &outsize, 2);
-
-
-}
-
-
-/******************************************************************************
- * RawVerse::linkentry - links one entry to another
- *
- * ENT: testmt - testament to find (0 - Bible/module introduction)
- * destidxoff - dest offset into .vss
- * srcidxoff - source offset into .vss
- */
-
-void RawVerse::doLinkEntry(char testmt, long destidxoff, long srcidxoff) {
- long start;
- unsigned short size;
-
- destidxoff *= 6;
- srcidxoff *= 6;
-
- if (!testmt)
- testmt = ((idxfp[1]) ? 1:2);
-
- // get source
- lseek(idxfp[testmt-1]->getFd(), srcidxoff, SEEK_SET);
- read(idxfp[testmt-1]->getFd(), &start, 4);
- read(idxfp[testmt-1]->getFd(), &size, 2);
-
- // write dest
- lseek(idxfp[testmt-1]->getFd(), destidxoff, SEEK_SET);
- write(idxfp[testmt-1]->getFd(), &start, 4);
- write(idxfp[testmt-1]->getFd(), &size, 2);
-}
-
-
-/******************************************************************************
- * RawVerse::CreateModule - Creates new module files
- *
- * ENT: path - directory to store module files
- * RET: error status
- */
-
-char RawVerse::createModule(const char *ipath)
-{
- char *path = 0;
- char *buf = new char [ strlen (ipath) + 20 ];
- FileDesc *fd, *fd2;
-
- stdstr(&path, ipath);
-
- if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\'))
- path[strlen(path)-1] = 0;
-
- sprintf(buf, "%s/ot", path);
- unlink(buf);
- fd = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd->getFd();
- FileMgr::systemFileMgr.close(fd);
-
- sprintf(buf, "%s/nt", path);
- unlink(buf);
- fd = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd->getFd();
- FileMgr::systemFileMgr.close(fd);
-
- sprintf(buf, "%s/ot.vss", path);
- unlink(buf);
- fd = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd->getFd();
-
- sprintf(buf, "%s/nt.vss", path);
- unlink(buf);
- fd2 = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd2->getFd();
-
- VerseKey vk;
- vk.Headings(1);
- long offset = 0;
- short size = 0;
- for (vk = TOP; !vk.Error(); vk++) {
- write((vk.Testament() == 1) ? fd->getFd() : fd2->getFd(), &offset, 4);
- write((vk.Testament() == 1) ? fd->getFd() : fd2->getFd(), &size, 2);
- }
-
- FileMgr::systemFileMgr.close(fd);
- FileMgr::systemFileMgr.close(fd2);
-
- delete [] path;
- delete [] buf;
-/*
- RawVerse rv(path);
- VerseKey mykey("Rev 22:21");
-*/
-
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/common/sapphire.cpp b/src/modules/common/sapphire.cpp
deleted file mode 100644
index 1c97934..0000000
--- a/src/modules/common/sapphire.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-/* sapphire.cpp -- the Saphire II stream cipher class.
- Dedicated to the Public Domain the author and inventor:
- (Michael Paul Johnson). This code comes with no warranty.
- Use it at your own risk.
- Ported from the Pascal implementation of the Sapphire Stream
- Cipher 9 December 1994.
- Added hash pre- and post-processing 27 December 1994.
- Modified initialization to make index variables key dependent,
- made the output function more resistant to cryptanalysis,
- and renamed to Sapphire II 2 January 1995
-*/
-
-
-#ifdef WIN32
-#include <memory.h>
-#endif
-
-#ifdef UNIX
-#include <memory.h>
-#include <unistd.h>
-#else
-#ifndef _MSC_VER
-#include <mem.h>
-#endif
-#endif
-
-#ifdef _WIN32_WCE
-#include <string.h>
-#endif
-
-#include "sapphire.h"
-
-SWORD_NAMESPACE_START
-
-unsigned char sapphire::keyrand(int limit,
- unsigned char *user_key,
- unsigned char keysize,
- unsigned char *rsum,
- unsigned *keypos)
- {
- unsigned u, // Value from 0 to limit to return.
- retry_limiter, // No infinite loops allowed.
- mask; // Select just enough bits.
-
- if (!limit) return 0; // Avoid divide by zero error.
- retry_limiter = 0;
- mask = 1; // Fill mask with enough bits to cover
- while (mask < (unsigned)limit) // the desired range.
- mask = (mask << 1) + 1;
- do
- {
- *rsum = cards[*rsum] + user_key[(*keypos)++];
- if (*keypos >= keysize)
- {
- *keypos = 0; // Recycle the user key.
- *rsum += keysize; // key "aaaa" != key "aaaaaaaa"
- }
- u = mask & *rsum;
- if (++retry_limiter > 11)
- u %= limit; // Prevent very rare long loops.
- }
- while (u > (unsigned)limit);
- return u;
- }
-
-void sapphire::initialize(unsigned char *key, unsigned char keysize)
- {
- // Key size may be up to 256 bytes.
- // Pass phrases may be used directly, with longer length
- // compensating for the low entropy expected in such keys.
- // Alternatively, shorter keys hashed from a pass phrase or
- // generated randomly may be used. For random keys, lengths
- // of from 4 to 16 bytes are recommended, depending on how
- // secure you want this to be.
-
- int i;
- unsigned char toswap, swaptemp, rsum;
- unsigned keypos;
-
- // If we have been given no key, assume the default hash setup.
-
- if (keysize < 1)
- {
- hash_init();
- return;
- }
-
- // Start with cards all in order, one of each.
-
- for (i=0;i<256;i++)
- cards[i] = i;
-
- // Swap the card at each position with some other card.
-
- toswap = 0;
- keypos = 0; // Start with first byte of user key.
- rsum = 0;
- for (i=255;i>=0;i--)
- {
- toswap = keyrand(i, key, keysize, &rsum, &keypos);
- swaptemp = cards[i];
- cards[i] = cards[toswap];
- cards[toswap] = swaptemp;
- }
-
- // Initialize the indices and data dependencies.
- // Indices are set to different values instead of all 0
- // to reduce what is known about the state of the cards
- // when the first byte is emitted.
-
- rotor = cards[1];
- ratchet = cards[3];
- avalanche = cards[5];
- last_plain = cards[7];
- last_cipher = cards[rsum];
-
- toswap = swaptemp = rsum = 0;
- keypos = 0;
- }
-
-void sapphire::hash_init(void)
- {
- // This function is used to initialize non-keyed hash
- // computation.
-
- int i, j;
-
- // Initialize the indices and data dependencies.
-
- rotor = 1;
- ratchet = 3;
- avalanche = 5;
- last_plain = 7;
- last_cipher = 11;
-
- // Start with cards all in inverse order.
-
- for (i=0, j=255;i<256;i++,j--)
- cards[i] = (unsigned char) j;
- }
-
-sapphire::sapphire(unsigned char *key, unsigned char keysize)
- {
- if (key && keysize)
- initialize(key, keysize);
- }
-
-void sapphire::burn(void)
- {
- // Destroy the key and state information in RAM.
- memset(cards, 0, 256);
- rotor = ratchet = avalanche = last_plain = last_cipher = 0;
- }
-
-sapphire::~sapphire()
- {
- burn();
- }
-
-unsigned char sapphire::encrypt(unsigned char b)
- {
-#ifdef USBINARY
- // Picture a single enigma rotor with 256 positions, rewired
- // on the fly by card-shuffling.
-
- // This cipher is a variant of one invented and written
- // by Michael Paul Johnson in November, 1993.
-
- unsigned char swaptemp;
-
- // Shuffle the deck a little more.
-
- ratchet += cards[rotor++];
- swaptemp = cards[last_cipher];
- cards[last_cipher] = cards[ratchet];
- cards[ratchet] = cards[last_plain];
- cards[last_plain] = cards[rotor];
- cards[rotor] = swaptemp;
- avalanche += cards[swaptemp];
-
- // Output one byte from the state in such a way as to make it
- // very hard to figure out which one you are looking at.
-
- last_cipher = b^cards[(cards[ratchet] + cards[rotor]) & 0xFF] ^
- cards[cards[(cards[last_plain] +
- cards[last_cipher] +
- cards[avalanche])&0xFF]];
- last_plain = b;
- return last_cipher;
-#else
- return b;
-#endif
- }
-
-unsigned char sapphire::decrypt(unsigned char b)
- {
- unsigned char swaptemp;
-
- // Shuffle the deck a little more.
-
- ratchet += cards[rotor++];
- swaptemp = cards[last_cipher];
- cards[last_cipher] = cards[ratchet];
- cards[ratchet] = cards[last_plain];
- cards[last_plain] = cards[rotor];
- cards[rotor] = swaptemp;
- avalanche += cards[swaptemp];
-
- // Output one byte from the state in such a way as to make it
- // very hard to figure out which one you are looking at.
-
- last_plain = b^cards[(cards[ratchet] + cards[rotor]) & 0xFF] ^
- cards[cards[(cards[last_plain] +
- cards[last_cipher] +
- cards[avalanche])&0xFF]];
- last_cipher = b;
- return last_plain;
- }
-
-void sapphire::hash_final(unsigned char *hash, // Destination
- unsigned char hashlength) // Size of hash.
- {
- int i;
-
- for (i=255;i>=0;i--)
- encrypt((unsigned char) i);
- for (i=0;i<hashlength;i++)
- hash[i] = encrypt(0);
- }
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/common/swcipher.cpp b/src/modules/common/swcipher.cpp
deleted file mode 100644
index bd4d551..0000000
--- a/src/modules/common/swcipher.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/******************************************************************************
- * swcipher.cpp - code for class 'SWCipher'- a driver class that provides
- * cipher utilities.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <swcipher.h>
-
-SWORD_NAMESPACE_START
-
-/******************************************************************************
- * SWCipher Constructor - Initializes data for instance of SWCipher
- *
- */
-
-SWCipher::SWCipher(unsigned char *key) {
- master.initialize(key, strlen((char *)key));
- buf = 0;
-}
-
-
-/******************************************************************************
- * SWCipher Destructor - Cleans up instance of SWCipher
- */
-
-SWCipher::~SWCipher()
-{
- if (buf)
- free(buf);
-}
-
-
-char *SWCipher::Buf(const char *ibuf, unsigned long ilen)
-{
- if (ibuf) {
-
- if (buf)
- free(buf);
-
- if (!ilen) {
- len = strlen(buf);
- ilen = len + 1;
- }
- else len = ilen;
-
- buf = (char *) malloc(ilen);
- memcpy(buf, ibuf, ilen);
- cipher = false;
- }
-
- Decode();
-
- return buf;
-}
-
-
-char *SWCipher::cipherBuf(unsigned long *ilen, const char *ibuf)
-{
- if (ibuf) {
-
- if (buf)
- free(buf);
-
- buf = (char *) malloc(*ilen+1);
- memcpy(buf, ibuf, *ilen);
- len = *ilen;
- cipher = true;
- }
-
- Encode();
-
- *ilen = len;
- return buf;
-}
-
-
-/******************************************************************************
- * SWCipher::Encode - This function "encodes" the input stream into the
- * output stream.
- * The GetChars() and SendChars() functions are
- * used to separate this method from the actual
- * i/o.
- */
-
-void SWCipher::Encode(void)
-{
- if (!cipher) {
- work = master;
- for (unsigned long i = 0; i < len; i++)
- buf[i] = work.encrypt(buf[i]);
- cipher = true;
- }
-}
-
-
-/******************************************************************************
- * SWCipher::Decode - This function "decodes" the input stream into the
- * output stream.
- * The GetChars() and SendChars() functions are
- * used to separate this method from the actual
- * i/o.
- */
-
-void SWCipher::Decode(void)
-{
- if (cipher) {
- work = master;
- unsigned long i;
- for (i = 0; i < len; i++)
- buf[i] = work.decrypt(buf[i]);
- buf[i] = 0;
- cipher = false;
- }
-}
-
-
-/******************************************************************************
- * SWCipher::setCipherKey - setter for a new CipherKey
- *
- */
-
-void SWCipher::setCipherKey(const char *ikey) {
- unsigned char *key = (unsigned char *)ikey;
- master.initialize(key, strlen((char *)key));
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/common/swcomprs.cpp b/src/modules/common/swcomprs.cpp
deleted file mode 100644
index 02d7d7b..0000000
--- a/src/modules/common/swcomprs.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-/******************************************************************************
- * swcomprs.cpp - code for class 'SWCompress'- a driver class that provides
- * compression utilities.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <swcomprs.h>
-
-SWORD_NAMESPACE_START
-
-/******************************************************************************
- * SWCompress Constructor - Initializes data for instance of SWCompress
- *
- */
-
-SWCompress::SWCompress()
-{
- buf = zbuf = 0;
- Init();
-}
-
-
-/******************************************************************************
- * SWCompress Destructor - Cleans up instance of SWCompress
- */
-
-SWCompress::~SWCompress()
-{
- if (zbuf)
- free(zbuf);
-
- if (buf)
- free(buf);
-}
-
-
-void SWCompress::Init()
-{
- if (buf)
- free(buf);
-
- if (zbuf)
- free(zbuf);
-
- buf = 0;
- zbuf = 0;
- direct = 0;
- zlen = 0;
- slen = 0;
- zpos = 0;
- pos = 0;
-}
-
-
-char *SWCompress::Buf(const char *ibuf, unsigned long *len) {
- // setting an uncompressed buffer
- if (ibuf) {
- Init();
- slen = (len) ? *len : strlen(ibuf);
- buf = (char *) calloc(slen + 1, 1);
- memcpy(buf, ibuf, slen);
- }
-
- // getting an uncompressed buffer
- if (!buf) {
- buf = (char *)calloc(1,1); // be sure we at least allocate an empty buf for return;
- direct = 1;
- Decode();
-// slen = strlen(buf);
- if (len)
- *len = slen;
- }
- return buf;
-}
-
-
-char *SWCompress::zBuf(unsigned long *len, char *ibuf)
-{
- // setting a compressed buffer
- if (ibuf) {
- Init();
- zbuf = (char *) malloc(*len);
- memcpy(zbuf, ibuf, *len);
- zlen = *len;
- }
-
- // getting a compressed buffer
- if (!zbuf) {
- direct = 0;
- Encode();
- }
-
- *len = zlen;
- return zbuf;
-}
-
-
-unsigned long SWCompress::GetChars(char *ibuf, unsigned long len)
-{
- if (direct) {
- len = (((zlen - zpos) > (unsigned)len) ? len : zlen - zpos);
- if (len > 0) {
- memmove(ibuf, &zbuf[zpos], len);
- zpos += len;
- }
- }
- else {
-// slen = strlen(buf);
- len = (((slen - pos) > (unsigned)len) ? len : slen - pos);
- if (len > 0) {
- memmove(ibuf, &buf[pos], len);
- pos += len;
- }
- }
- return len;
-}
-
-
-unsigned long SWCompress::SendChars(char *ibuf, unsigned long len)
-{
- if (direct) {
- if (buf) {
-// slen = strlen(buf);
- if ((pos + len) > (unsigned)slen) {
- buf = (char *) realloc(buf, pos + len + 1024);
- memset(&buf[pos], 0, len + 1024);
- }
- }
- else buf = (char *)calloc(1, len + 1024);
- memmove(&buf[pos], ibuf, len);
- pos += len;
- }
- else {
- if (zbuf) {
- if ((zpos + len) > zlen) {
- zbuf = (char *) realloc(zbuf, zpos + len + 1024);
- zlen = zpos + len + 1024;
- }
- }
- else {
- zbuf = (char *)calloc(1, len + 1024);
- zlen = len + 1024;
- }
- memmove(&zbuf[zpos], ibuf, len);
- zpos += len;
- }
- return len;
-}
-
-
-/******************************************************************************
- * SWCompress::Encode - This function "encodes" the input stream into the
- * output stream.
- * The GetChars() and SendChars() functions are
- * used to separate this method from the actual
- * i/o.
- */
-
-void SWCompress::Encode(void)
-{
- cycleStream();
-}
-
-
-/******************************************************************************
- * SWCompress::Decode - This function "decodes" the input stream into the
- * output stream.
- * The GetChars() and SendChars() functions are
- * used to separate this method from the actual
- * i/o.
- */
-
-void SWCompress::Decode(void)
-{
- cycleStream();
-}
-
-
-void SWCompress::cycleStream() {
- char buf[1024];
- unsigned long len, totlen = 0;
-
- do {
- len = GetChars(buf, 1024);
- if (len)
- totlen += SendChars(buf, len);
- } while (len == 1024);
-
- zlen = slen = totlen;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/common/swcomprs.doc b/src/modules/common/swcomprs.doc
deleted file mode 100644
index b6817f2..0000000
--- a/src/modules/common/swcomprs.doc
+++ /dev/null
@@ -1,802 +0,0 @@
-The following is the original information send from Parson's Technologies via
-Craig Rairden.
-_______________________________________________________________________________
-Compression Info, 10-11-95
-Jeff Wheeler
-
-Source of Algorithm
--------------------
-
-The compression algorithms used here are based upon the algorithms developed
-and published by Haruhiko Okumura in a paper entitled "Data Compression
-Algorithms of LARC and LHarc." This paper discusses three compression
-algorithms, LSZZ, LZARI, and LZHUF. LZSS is described as the "first" of
-these, and is described as providing moderate compression with good speed.
-LZARI is described as an improved LZSS, a combination of the LZSS algorithm
-with adaptive arithmetic compression. It is described as being slower than
-LZSS but with better compression. LZHUF (the basis of the common LHA
-compression program) was included in the paper, however, a free usage license
-was not included.
-
-The following are copies of the statements included at the beginning of each
-source code listing that was supplied in the working paper.
-
- LZSS, dated 4/6/89, marked as "Use, distribute and
- modify this program freely."
-
- LZARI, dated 4/7/89, marked as "Use, distribute and
- modify this program freely."
-
- LZHUF, dated 11/20/88, written by Haruyasu Yoshizaki,
- translated by Haruhiko Okumura on 4/7/89. Not
- expressly marked as redistributable or modifiable.
-
-Since both LZSS and LZARI are marked as "use, distribute and modify freely" we
-have felt at liberty basing our compression algorithm on either of these.
-
-Selection of Algorithm
-----------------------
-
-Working samples of three possible compression algorithms are supplied in
-Okumura's paper. Which should be used?
-
-LZSS is the fastest at decompression, but does not generated as small a
-compressed file as the other methods. The other two methods provided, perhaps,
-a 15% improvement in compression. Or, put another way, on a 100K file, LZSS
-might compress it to 50K while the others might approach 40-45K. For STEP
-purposes, it was decided that decoding speed was of more importance than
-tighter compression. For these reasons, the first compression algorithm
-implemented is the LZSS algorithm.
-
-About LZSS Encoding
--------------------
-
-(adapted from Haruhiko Okumura's paper)
-
-This scheme was proposed by Ziv and Lempel [1]. A slightly modified version
-is described by Storer and Szymanski [2]. An implementation using a binary
-tree has been proposed by Bell [3].
-
-The algorithm is quite simple.
-1. Keep a ring buffer which initially contains all space characters.
-2. Read several letters from the file to the buffer.
-3. Search the buffer for the longest string that matches the letters just
- read, and send its length and position into the buffer.
-
-If the ring buffer is 4096 bytes, the position can be stored in 12 bits. If the
-length is represented in 4 bits, the <position, length> pair is two bytes
-long. If the longest match is no more than two characters, then just one
-character is sent without encoding. The process starts again with the next
-character. An extra bit is sent each time to tell the decoder whether the
-next item is a character of a <position, length> pair.
-
-[1] J. Ziv and A. Lempel, IEEE Transactions IT-23, 337-343 (1977).
-[2] J. A. Storer and T. G. Szymanski, J. ACM, 29, 928-951 (1982).
-[3] T.C. Gell, IEEE Transactions COM-34, 1176-1182 (1986).
-
-class SWCompress {
-public:
-void InitTree( // no return value
- void); // no parameters
-
-void InsertNode( // no return value
- short int Pos); // position in the buffer
-
-void DeleteNode( // no return value
- short int Node); // node to be removed
-
-void Encode( // no return value
- void); // no parameters
-
-void Decode( // no return value
- void); // no parameters
-};
-
-// The following are constant sizes used by the compression algorithm.
-//
-// N - This is the size of the ring buffer. It is set
-// to 4K. It is important to note that a position
-// within the ring buffer requires 12 bits.
-//
-// F - This is the maximum length of a character sequence
-// that can be taken from the ring buffer. It is set
-// to 18. Note that a length must be 3 before it is
-// worthwhile to store a position/length pair, so the
-// length can be encoded in only 4 bits. Or, put yet
-// another way, it is not necessary to encode a length
-// of 0-18, it is necessary to encode a length of
-// 3-18, which requires 4 bits.
-//
-// THRESHOLD - It takes 2 bytes to store an offset and
-// a length. If a character sequence only
-// requires 1 or 2 characters to store
-// uncompressed, then it is better to store
-// it uncompressed than as an offset into
-// the ring buffer.
-//
-// Note that the 12 bits used to store the position and the 4 bits
-// used to store the length equal a total of 16 bits, or 2 bytes.
-
-#define N 4096
-#define F 18
-#define THRESHOLD 3
-#define NOT_USED N
-
-// m_ring_buffer is a text buffer. It contains "nodes" of
-// uncompressed text that can be indexed by position. That is,
-// a substring of the ring buffer can be indexed by a position
-// and a length. When decoding, the compressed text may contain
-// a position in the ring buffer and a count of the number of
-// bytes from the ring buffer that are to be moved into the
-// uncompressed buffer.
-//
-// This ring buffer is not maintained as part of the compressed
-// text. Instead, it is reconstructed dynamically. That is,
-// it starts out empty and gets built as the text is decompressed.
-//
-// The ring buffer contain N bytes, with an additional F - 1 bytes
-// to facilitate string comparison.
-
-unsigned char m_ring_buffer[N + F - 1];
-
-// m_match_position and m_match_length are set by InsertNode().
-//
-// These variables indicate the position in the ring buffer
-// and the number of characters at that position that match
-// a given string.
-
-short int m_match_position;
-short int m_match_length;
-
-// m_lson, m_rson, and m_dad are the Japanese way of referring to
-// a tree structure. The dad is the parent and it has a right and
-// left son (child).
-//
-// For i = 0 to N-1, m_rson[i] and m_lson[i] will be the right
-// and left children of node i.
-//
-// For i = 0 to N-1, m_dad[i] is the parent of node i.
-//
-// For i = 0 to 255, rson[N + i + 1] is the root of the tree for
-// strings that begin with the character i. Note that this requires
-// one byte characters.
-//
-// These nodes store values of 0...(N-1). Memory requirements
-// can be reduces by using 2-byte integers instead of full 4-byte
-// integers (for 32-bit applications). Therefore, these are
-// defined as "short ints."
-
-short int m_lson[N + 1];
-short int m_rson[N + 257];
-short int m_dad[N + 1];
-
-
-
-
-/*
- -------------------------------------------------------------------------
- cLZSS::InitTree
-
- This function initializes the tree nodes to "empty" states.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::InitTree( // no return value
- void) // no parameters
- throw() // exception list
-
- {
- int i;
-
- // For i = 0 to N - 1, m_rson[i] and m_lson[i] will be the right
- // and left children of node i. These nodes need not be
- // initialized. However, for debugging purposes, it is nice to
- // have them initialized. Since this is only used for compression
- // (not decompression), I don't mind spending the time to do it.
- //
- // For the same range of i, m_dad[i] is the parent of node i.
- // These are initialized to a known value that can represent
- // a "not used" state.
-
- for (i = 0; i < N; i++)
- {
- m_lson[i] = NOT_USED;
- m_rson[i] = NOT_USED;
- m_dad[i] = NOT_USED;
- }
-
- // For i = 0 to 255, m_rson[N + i + 1] is the root of the tree
- // for strings that begin with the character i. This is why
- // the right child array is larger than the left child array.
- // These are also initialzied to a "not used" state.
- //
- // Note that there are 256 of these, one for each of the possible
- // 256 characters.
-
- for (i = N + 1; i <= (N + 256); i++)
- {
- m_rson[i] = NOT_USED;
- }
-
- // Done.
- }
-
-/*
- -------------------------------------------------------------------------
- cLZSS::InsertNode
-
- This function inserts a string from the ring buffer into one of
- the trees. It loads the match position and length member variables
- for the longest match.
-
- The string to be inserted is identified by the parameter Pos,
- A full F bytes are inserted. So, m_ring_buffer[Pos ... Pos+F-1]
- are inserted.
-
- If the matched length is exactly F, then an old node is removed
- in favor of the new one (because the old one will be deleted
- sooner).
-
- Note that Pos plays a dual role. It is used as both a position
- in the ring buffer and also as a tree node. m_ring_buffer[Pos]
- defines a character that is used to identify a tree node.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::InsertNode( // no return value
- short int Pos) // position in the buffer
- throw() // exception list
-
- {
- short int i;
- short int p;
- int cmp;
- unsigned char * key;
-
- ASSERT(Pos >= 0);
- ASSERT(Pos < N);
-
- cmp = 1;
- key = &(m_ring_buffer[Pos]);
-
- // The last 256 entries in m_rson contain the root nodes for
- // strings that begin with a letter. Get an index for the
- // first letter in this string.
-
- p = (short int) (N + 1 + key[0]);
-
- // Set the left and right tree nodes for this position to "not
- // used."
-
- m_lson[Pos] = NOT_USED;
- m_rson[Pos] = NOT_USED;
-
- // Haven't matched anything yet.
-
- m_match_length = 0;
-
- for ( ; ; )
- {
- if (cmp >= 0)
- {
- if (m_rson[p] != NOT_USED)
- {
- p = m_rson[p];
- }
- else
- {
- m_rson[p] = Pos;
- m_dad[Pos] = p;
- return;
- }
- }
- else
- {
- if (m_lson[p] != NOT_USED)
- {
- p = m_lson[p];
- }
- else
- {
- m_lson[p] = Pos;
- m_dad[Pos] = p;
- return;
- }
- }
-
- // Should we go to the right or the left to look for the
- // next match?
-
- for (i = 1; i < F; i++)
- {
- cmp = key[i] - m_ring_buffer[p + i];
- if (cmp != 0)
- break;
- }
-
- if (i > m_match_length)
- {
- m_match_position = p;
- m_match_length = i;
-
- if (i >= F)
- break;
- }
- }
-
- m_dad[Pos] = m_dad[p];
- m_lson[Pos] = m_lson[p];
- m_rson[Pos] = m_rson[p];
-
- m_dad[ m_lson[p] ] = Pos;
- m_dad[ m_rson[p] ] = Pos;
-
- if (m_rson[ m_dad[p] ] == p)
- {
- m_rson[ m_dad[p] ] = Pos;
- }
- else
- {
- m_lson[ m_dad[p] ] = Pos;
- }
-
- // Remove "p"
-
- m_dad[p] = NOT_USED;
- }
-
-/*
- -------------------------------------------------------------------------
- cLZSS::DeleteNode
-
- This function removes the node "Node" from the tree.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::DeleteNode( // no return value
- short int Node) // node to be removed
- throw() // exception list
-
- {
- short int q;
-
- ASSERT(Node >= 0);
- ASSERT(Node < (N+1));
-
- if (m_dad[Node] == NOT_USED)
- {
- // not in tree, nothing to do
- return;
- }
-
- if (m_rson[Node] == NOT_USED)
- {
- q = m_lson[Node];
- }
- else if (m_lson[Node] == NOT_USED)
- {
- q = m_rson[Node];
- }
- else
- {
- q = m_lson[Node];
- if (m_rson[q] != NOT_USED)
- {
- do
- {
- q = m_rson[q];
- }
- while (m_rson[q] != NOT_USED);
-
- m_rson[ m_dad[q] ] = m_lson[q];
- m_dad[ m_lson[q] ] = m_dad[q];
- m_lson[q] = m_lson[Node];
- m_dad[ m_lson[Node] ] = q;
- }
-
- m_rson[q] = m_rson[Node];
- m_dad[ m_rson[Node] ] = q;
- }
-
- m_dad[q] = m_dad[Node];
-
- if (m_rson[ m_dad[Node] ] == Node)
- {
- m_rson[ m_dad[Node] ] = q;
- }
- else
- {
- m_lson[ m_dad[Node] ] = q;
- }
-
- m_dad[Node] = NOT_USED;
- }
-
-/*
- -------------------------------------------------------------------------
- cLZSS::Encode
-
- This function "encodes" the input stream into the output stream.
- The GetChars() and SendChars() functions are used to separate
- this method from the actual i/o.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::Encode( // no return value
- void) // no parameters
-
- {
- short int i; // an iterator
- short int r; // node number in the binary tree
- short int s; // position in the ring buffer
- unsigned short int len; // len of initial string
- short int last_match_length; // length of last match
- short int code_buf_pos; // position in the output buffer
- unsigned char code_buf[17]; // the output buffer
- unsigned char mask; // bit mask for byte 0 of out buf
- unsigned char c; // character read from string
-
- // Start with a clean tree.
-
- InitTree();
-
- // code_buf[0] works as eight flags. A "1" represents that the
- // unit is an unencoded letter (1 byte), and a "0" represents
- // that the next unit is a <position,length> pair (2 bytes).
- //
- // code_buf[1..16] stores eight units of code. Since the best
- // we can do is store eight <position,length> pairs, at most 16
- // bytes are needed to store this.
- //
- // This is why the maximum size of the code buffer is 17 bytes.
-
- code_buf[0] = 0;
- code_buf_pos = 1;
-
- // Mask iterates over the 8 bits in the code buffer. The first
- // character ends up being stored in the low bit.
- //
- // bit 8 7 6 5 4 3 2 1
- // | |
- // | first sequence in code buffer
- // |
- // last sequence in code buffer
-
- mask = 1;
-
- s = 0;
- r = (short int) N - (short int) F;
-
- // Initialize the ring buffer with spaces...
-
- // Note that the last F bytes of the ring buffer are not filled.
- // This is because those F bytes will be filled in immediately
- // with bytes from the input stream.
-
- memset(m_ring_buffer, ' ', N - F);
-
- // Read F bytes into the last F bytes of the ring buffer.
- //
- // This function loads the buffer with X characters and returns
- // the actual amount loaded.
-
- len = GetChars(&(m_ring_buffer[r]), F);
-
- // Make sure there is something to be compressed.
-
- if (len == 0)
- return;
-
- // Insert the F strings, each of which begins with one or more
- // 'space' characters. Note the order in which these strings
- // are inserted. This way, degenerate trees will be less likely
- // to occur.
-
- for (i = 1; i <= F; i++)
- {
- InsertNode((short int) (r - i));
- }
-
- // Finally, insert the whole string just read. The
- // member variables match_length and match_position are set.
-
- InsertNode(r);
-
- // Now that we're preloaded, continue till done.
-
- do
- {
-
- // m_match_length may be spuriously long near the end of
- // text.
-
- if (m_match_length > len)
- {
- m_match_length = len;
- }
-
- // Is it cheaper to store this as a single character? If so,
- // make it so.
-
- if (m_match_length < THRESHOLD)
- {
- // Send one character. Remember that code_buf[0] is the
- // set of flags for the next eight items.
-
- m_match_length = 1;
- code_buf[0] |= mask;
- code_buf[code_buf_pos++] = m_ring_buffer[r];
- }
-
- // Otherwise, we do indeed have a string that can be stored
- // compressed to save space.
-
- else
- {
- // The next 16 bits need to contain the position (12 bits)
- // and the length (4 bits).
-
- code_buf[code_buf_pos++] = (unsigned char) m_match_position;
- code_buf[code_buf_pos++] = (unsigned char) (
- ((m_match_position >> 4) & 0xf0) |
- (m_match_length - THRESHOLD) );
- }
-
- // Shift the mask one bit to the left so that it will be ready
- // to store the new bit.
-
- mask = (unsigned char) (mask << 1);
-
- // If the mask is now 0, then we know that we have a full set
- // of flags and items in the code buffer. These need to be
- // output.
-
- if (mask == 0)
- {
- // code_buf is the buffer of characters to be output.
- // code_buf_pos is the number of characters it contains.
-
- SendChars(code_buf, code_buf_pos);
-
- // Reset for next buffer...
-
- code_buf[0] = 0;
- code_buf_pos = 1;
- mask = 1;
- }
-
- last_match_length = m_match_length;
-
- // Delete old strings and read new bytes...
-
- for (i = 0; i < last_match_length; i++)
- {
-
- // Get next character...
-
- if (GetChars(&c, 1) != 1)
- break;
-
- // Delete "old strings"
-
- DeleteNode(s);
-
- // Put this character into the ring buffer.
- //
- // The original comment here says "If the position is near
- // the end of the buffer, extend the buffer to make
- // string comparison easier."
- //
- // That's a little misleading, because the "end" of the
- // buffer is really what we consider to be the "beginning"
- // of the buffer, that is, positions 0 through F.
- //
- // The idea is that the front end of the buffer is duplicated
- // into the back end so that when you're looking at characters
- // at the back end of the buffer, you can index ahead (beyond
- // the normal end of the buffer) and see the characters
- // that are at the front end of the buffer wihtout having
- // to adjust the index.
- //
- // That is...
- //
- // 1234xxxxxxxxxxxxxxxxxxxxxxxxxxxxx1234
- // | | |
- // position 0 end of buffer |
- // |
- // duplicate of front of buffer
-
- m_ring_buffer[s] = c;
-
- if (s < F - 1)
- {
- m_ring_buffer[s + N] = c;
- }
-
- // Increment the position, and wrap around when we're at
- // the end. Note that this relies on N being a power of 2.
-
- s = (short int) ( (s + 1) & (N - 1) );
- r = (short int) ( (r + 1) & (N - 1) );
-
- // Register the string that is found in
- // m_ring_buffer[r..r+F-1].
-
- InsertNode(r);
- }
-
- // If we didn't quit because we hit the last_match_length,
- // then we must have quit because we ran out of characters
- // to process.
-
- while (i++ < last_match_length)
- {
- DeleteNode(s);
-
- s = (short int) ( (s + 1) & (N - 1) );
- r = (short int) ( (r + 1) & (N - 1) );
-
- // Note that len hitting 0 is the key that causes the
- // do...while() to terminate. This is the only place
- // within the loop that len is modified.
- //
- // Its original value is F (or a number less than F for
- // short strings).
-
- if (--len)
- {
- InsertNode(r); /* buffer may not be empty. */
- }
- }
-
- // End of do...while() loop. Continue processing until there
- // are no more characters to be compressed. The variable
- // "len" is used to signal this condition.
- }
- while (len > 0);
-
- // There could still be something in the output buffer. Send it
- // now.
-
- if (code_buf_pos > 1)
- {
- // code_buf is the encoded string to send.
- // code_buf_ptr is the number of characters.
-
- SendChars(code_buf, code_buf_pos);
- }
-
- // Done!
- }
-
-/*
- -------------------------------------------------------------------------
- cLZSS::Decode
-
- This function "decodes" the input stream into the output stream.
- The GetChars() and SendChars() functions are used to separate
- this method from the actual i/o.
- -------------------------------------------------------------------------
-*/
-
-void cLZSS::Decode( // no return value
- void) // no parameters
-
- {
- int k;
- int r; // node number
- unsigned char c[F]; // an array of chars
- unsigned char flags; // 8 bits of flags
- int flag_count; // which flag we're on
- short int pos; // position in the ring buffer
- short int len; // number of chars in ring buffer
-
- // Initialize the ring buffer with a common string.
- //
- // Note that the last F bytes of the ring buffer are not filled.
-
- memset(m_ring_buffer, ' ', N - F);
-
- r = N - F;
-
- flags = (char) 0;
- flag_count = 0;
-
- for ( ; ; )
- {
-
- // If there are more bits of interest in this flag, then
- // shift that next interesting bit into the 1's position.
- //
- // If this flag has been exhausted, the next byte must
- // be a flag.
-
- if (flag_count > 0)
- {
- flags = (unsigned char) (flags >> 1);
- flag_count--;
- }
- else
- {
- // Next byte must be a flag.
-
- if (GetChars(&flags, 1) != 1)
- break;
-
- // Set the flag counter. While at first it might appear
- // that this should be an 8 since there are 8 bits in the
- // flag, it should really be a 7 because the shift must
- // be performed 7 times in order to see all 8 bits.
-
- flag_count = 7;
- }
-
- // If the low order bit of the flag is now set, then we know
- // that the next byte is a single, unencoded character.
-
- if (flags & 1)
- {
- if (GetChars(c, 1) != 1)
- break;
-
- if (SendChars(c, 1) != 1)
- break;
-
- // Add to buffer, and increment to next spot. Wrap at end.
-
- m_ring_buffer[r] = c[0];
- r = (short int) ( (r + 1) & (N - 1) );
- }
-
- // Otherwise, we know that the next two bytes are a
- // <position,length> pair. The position is in 12 bits and
- // the length is in 4 bits.
-
- else
- {
- // Original code:
- // if ((i = getc(infile)) == EOF)
- // break;
- // if ((j = getc(infile)) == EOF)
- // break;
- // i |= ((j & 0xf0) << 4);
- // j = (j & 0x0f) + THRESHOLD;
- //
- // I've modified this to only make one input call, and
- // have changed the variable names to something more
- // obvious.
-
- if (GetChars(c, 2) != 2)
- break;
-
- // Convert these two characters into the position and
- // length. Note that the length is always at least
- // THRESHOLD, which is why we're able to get a length
- // of 18 out of only 4 bits.
-
- pos = (short int) ( c[0] | ((c[1] & 0xf0) << 4) );
-
- len = (short int) ( (c[1] & 0x0f) + THRESHOLD );
-
- // There are now "len" characters at position "pos" in
- // the ring buffer that can be pulled out. Note that
- // len is never more than F.
-
- for (k = 0; k < len; k++)
- {
- c[k] = m_ring_buffer[(pos + k) & (N - 1)];
-
- // Add to buffer, and increment to next spot. Wrap at end.
-
- m_ring_buffer[r] = c[k];
- r = (short int) ( (r + 1) & (N - 1) );
- }
-
- // Add the "len" characters to the output stream.
-
- if (SendChars(c, len) != len)
- break;
- }
- }
- }
-
diff --git a/src/modules/common/zipcomprs.cpp b/src/modules/common/zipcomprs.cpp
deleted file mode 100644
index 6a5ed22..0000000
--- a/src/modules/common/zipcomprs.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/******************************************************************************
- * swcomprs.cpp - code for class 'ZipCompress'- a driver class that provides
- * compression utilities. - using zlib
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <zipcomprs.h>
-#include <zlib.h>
-
-SWORD_NAMESPACE_START
-
-/******************************************************************************
- * ZipCompress Constructor - Initializes data for instance of ZipCompress
- *
- */
-
-ZipCompress::ZipCompress() : SWCompress()
-{
-// fprintf(stderr, "init compress\n");
-}
-
-
-/******************************************************************************
- * ZipCompress Destructor - Cleans up instance of ZipCompress
- */
-
-ZipCompress::~ZipCompress() {
-}
-
-
-/******************************************************************************
- * ZipCompress::Encode - This function "encodes" the input stream into the
- * output stream.
- * The GetChars() and SendChars() functions are
- * used to separate this method from the actual
- * i/o.
- * NOTE: must set zlen for parent class to know length of
- * compressed buffer.
- */
-
-void ZipCompress::Encode(void)
-{
-/*
-ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
- Compresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be at least 0.1% larger than
- sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
- compressed buffer.
- This function can be used to compress a whole file at once if the
- input file is mmap'ed.
- compress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer.
-*/
- direct = 0; // set direction needed by parent [Get|Send]Chars()
-
- // get buffer
- char chunk[1024];
- char *buf = (char *)calloc(1, 1024);
- char *chunkbuf = buf;
- unsigned long chunklen;
- unsigned long len = 0;
- while((chunklen = GetChars(chunk, 1023))) {
- memcpy(chunkbuf, chunk, chunklen);
- len += chunklen;
- if (chunklen < 1023)
- break;
- else buf = (char *)realloc(buf, len + 1024);
- chunkbuf = buf+len;
- }
-
-
- zlen = (long) (len*1.001)+15;
- char *zbuf = new char[zlen+1];
- if (len)
- {
- //printf("Doing compress\n");
- if (compress((Bytef*)zbuf, &zlen, (const Bytef*)buf, len)!=Z_OK)
- {
- printf("ERROR in compression\n");
- }
- else {
- SendChars(zbuf, zlen);
- }
- }
- else
- {
- fprintf(stderr, "No buffer to compress\n");
- }
- delete [] zbuf;
- free (buf);
-}
-
-
-/******************************************************************************
- * ZipCompress::Decode - This function "decodes" the input stream into the
- * output stream.
- * The GetChars() and SendChars() functions are
- * used to separate this method from the actual
- * i/o.
- */
-
-void ZipCompress::Decode(void)
-{
-/*
-ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer.
- This function can be used to decompress a whole file at once if the
- input file is mmap'ed.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted.
-*/
-
- // get buffer
- char chunk[1024];
- char *zbuf = (char *)calloc(1, 1024);
- char *chunkbuf = zbuf;
- int chunklen;
- unsigned long zlen = 0;
- while((chunklen = GetChars(chunk, 1023))) {
- memcpy(chunkbuf, chunk, chunklen);
- zlen += chunklen;
- if (chunklen < 1023)
- break;
- else zbuf = (char *)realloc(zbuf, zlen + 1024);
- chunkbuf = zbuf + zlen;
- }
-
- //printf("Decoding complength{%ld} uncomp{%ld}\n", zlen, blen);
- if (zlen) {
- unsigned long blen = zlen*20; // trust compression is less than 1000%
- char *buf = new char[blen];
- //printf("Doing decompress {%s}\n", zbuf);
- if (uncompress((Bytef*)buf, &blen, (Bytef*)zbuf, zlen) != Z_OK) {
- fprintf(stderr, "no room in outbuffer to during decompression. see zipcomp.cpp\n");
- }
- SendChars(buf, blen);
- delete [] buf;
- slen = blen;
- }
- else {
- fprintf(stderr, "No buffer to decompress!\n");
- }
- //printf("Finished decoding\n");
- free (zbuf);
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/common/zstr.cpp b/src/modules/common/zstr.cpp
deleted file mode 100644
index 92a4960..0000000
--- a/src/modules/common/zstr.cpp
+++ /dev/null
@@ -1,718 +0,0 @@
-/******************************************************************************
- * zstr.cpp - code for class 'zStr'- a module that reads compressed text
- * files and provides lookup and parsing functions based on
- * class StrKey
- */
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#include <stdlib.h>
-#include <utilfuns.h>
-#include <zstr.h>
-#include <swcomprs.h>
-
-#include <sysdata.h>
-#include <entriesblk.h>
-
-SWORD_NAMESPACE_START
-
-/******************************************************************************
- * zStr Statics
- */
-
-int zStr::instance = 0;
-const int zStr::IDXENTRYSIZE = 8;
-const int zStr::ZDXENTRYSIZE = 8;
-
-
-/******************************************************************************
- * zStr Constructor - Initializes data for instance of zStr
- *
- * ENT: ipath - path of the directory where data and index files are located.
- */
-
-zStr::zStr(const char *ipath, int fileMode, long blockCount, SWCompress *icomp) {
- char buf[127];
-
- nl = '\n';
- lastoff = -1;
- path = 0;
- stdstr(&path, ipath);
-
- compressor = (icomp) ? icomp : new SWCompress();
- this->blockCount = blockCount;
-#ifndef O_BINARY // O_BINARY is needed in Borland C++ 4.53
-#define O_BINARY 0 // If it hasn't been defined than we probably
-#endif // don't need it.
-
- if (fileMode == -1) { // try read/write if possible
- fileMode = O_RDWR;
- }
-
- sprintf(buf, "%s.idx", path);
- idxfd = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- sprintf(buf, "%s.dat", path);
- datfd = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- sprintf(buf, "%s.zdx", path);
- zdxfd = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- sprintf(buf, "%s.zdt", path);
- zdtfd = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- if (datfd <= 0) {
- sprintf(buf, "Error: %d", errno);
- perror(buf);
- }
-
- cacheBlock = 0;
- cacheBlockIndex = -1;
- cacheDirty = false;
-
- instance++;
-}
-
-
-/******************************************************************************
- * zStr Destructor - Cleans up instance of zStr
- */
-
-zStr::~zStr() {
-
- flushCache();
-
- if (path)
- delete [] path;
-
- --instance;
-
- FileMgr::systemFileMgr.close(idxfd);
- FileMgr::systemFileMgr.close(datfd);
- FileMgr::systemFileMgr.close(zdxfd);
- FileMgr::systemFileMgr.close(zdtfd);
-
-
- if (compressor)
- delete compressor;
-
-}
-
-
-/******************************************************************************
- * zStr::getidxbufdat - Gets the index string at the given dat offset
- * NOTE: buf is calloc'd, or if not null, realloc'd and must
- * be free'd by calling function
- *
- * ENT: ioffset - offset in dat file to lookup
- * buf - address of pointer to allocate for storage of string
- */
-
-void zStr::getKeyFromDatOffset(long ioffset, char **buf) {
- int size;
- char ch;
- if (datfd > 0) {
- lseek(datfd->getFd(), ioffset, SEEK_SET);
- for (size = 0; read(datfd->getFd(), &ch, 1) == 1; size++) {
- if ((ch == '\\') || (ch == 10) || (ch == 13))
- break;
- }
- *buf = (*buf) ? (char *)realloc(*buf, size*2 + 1) : (char *)malloc(size*2 + 1);
- if (size) {
- lseek(datfd->getFd(), ioffset, SEEK_SET);
- read(datfd->getFd(), *buf, size);
- }
- (*buf)[size] = 0;
- toupperstr_utf8(*buf, size*2);
- }
- else {
- *buf = (*buf) ? (char *)realloc(*buf, 1) : (char *)malloc(1);
- **buf = 0;
- }
-}
-
-
-/******************************************************************************
- * zStr::getidxbuf - Gets the index string at the given idx offset
- * NOTE: buf is calloc'd, or if not null, realloc'd
- * and must be freed by calling function
- *
- * ENT: ioffset - offset in idx file to lookup
- * buf - address of pointer to allocate for storage of string
- */
-
-void zStr::getKeyFromIdxOffset(long ioffset, char **buf) {
- __u32 offset;
-
- if (idxfd > 0) {
- lseek(idxfd->getFd(), ioffset, SEEK_SET);
- read(idxfd->getFd(), &offset, sizeof(__u32));
- offset = swordtoarch32(offset);
- getKeyFromDatOffset(offset, buf);
- }
-}
-
-
-/******************************************************************************
- * zStr::findoffset - Finds the offset of the key string from the indexes
- *
- * ENT: key - key string to lookup
- * offset - address to store the starting offset
- * size - address to store the size of the entry
- * away - number of entries before of after to jump
- * (default = 0)
- *
- * RET: error status
- */
-
-signed char zStr::findKeyIndex(const char *ikey, long *idxoff, long away) {
- char *trybuf = 0, *key = 0, quitflag = 0;
- signed char retval = 0;
- __s32 headoff, tailoff, tryoff = 0, maxoff = 0;
- __u32 start, size;
-
- if (idxfd->getFd() >= 0) {
- tailoff = maxoff = lseek(idxfd->getFd(), 0, SEEK_END) - IDXENTRYSIZE;
- if (*ikey) {
- headoff = 0;
- stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
-
- while (headoff < tailoff) {
- tryoff = (lastoff == -1) ? headoff + (((((tailoff / IDXENTRYSIZE) - (headoff / IDXENTRYSIZE))) / 2) * IDXENTRYSIZE) : lastoff;
- lastoff = -1;
-
- getKeyFromIdxOffset(tryoff, &trybuf);
-
- if (!*trybuf && tryoff) { // In case of extra entry at end of idx (not first entry)
- tryoff += (tryoff > (maxoff / 2))?-IDXENTRYSIZE:IDXENTRYSIZE;
- retval = -1;
- break;
- }
-
- int diff = strcmp(key, trybuf);
- if (!diff)
- break;
-
- if (diff < 0)
- tailoff = (tryoff == headoff) ? headoff : tryoff;
- else headoff = tryoff;
- if (tailoff == headoff + IDXENTRYSIZE) {
- if (quitflag++)
- headoff = tailoff;
- }
- }
- if (headoff >= tailoff)
- tryoff = headoff;
- if (trybuf)
- free(trybuf);
- delete [] key;
- }
- else { tryoff = 0; }
-
- lseek(idxfd->getFd(), tryoff, SEEK_SET);
-
- start = size = 0;
- retval = (read(idxfd->getFd(), &start, sizeof(__u32))==sizeof(__u32)) ? retval : -1;
- retval = (read(idxfd->getFd(), &size, sizeof(__u32))==sizeof(__u32)) ? retval : -1;
- start = swordtoarch32(start);
- size = swordtoarch32(size);
-
- if (idxoff)
- *idxoff = tryoff;
-
- while (away) {
- __u32 laststart = start;
- __u32 lastsize = size;
- __s32 lasttry = tryoff;
- tryoff += (away > 0) ? IDXENTRYSIZE : -IDXENTRYSIZE;
-
- bool bad = false;
- if (((long)(tryoff + (away*IDXENTRYSIZE)) < -IDXENTRYSIZE) || (tryoff + (away*IDXENTRYSIZE) > (maxoff+IDXENTRYSIZE)))
- bad = true;
- else if (lseek(idxfd->getFd(), tryoff, SEEK_SET) < 0)
- bad = true;
- if (bad) {
- retval = -1;
- start = laststart;
- size = lastsize;
- tryoff = lasttry;
- if (idxoff)
- *idxoff = tryoff;
- break;
- }
- read(idxfd->getFd(), &start, sizeof(__u32));
- read(idxfd->getFd(), &size, sizeof(__u32));
- start = swordtoarch32(start);
- size = swordtoarch32(size);
-
- if (idxoff)
- *idxoff = tryoff;
-
-
- if (((laststart != start) || (lastsize != size)) && (start >= 0) && (size))
- away += (away < 0) ? 1 : -1;
- }
-
- lastoff = tryoff;
- }
- else {
- if (idxoff)
- *idxoff = 0;
- retval = -1;
- }
- return retval;
-}
-
-
-/******************************************************************************
- * zStr::preptext - Prepares the text before returning it to external
- * objects
- *
- * ENT: buf - buffer where text is stored and where to store the prep'd
- * text.
- */
-
-void zStr::prepText(SWBuf &buf) {
- unsigned int to, from;
- char space = 0, cr = 0, realdata = 0, nlcnt = 0;
- char *rawBuf = buf.getRawData();
- for (to = from = 0; rawBuf[from]; from++) {
- switch (rawBuf[from]) {
- case 10:
- if (!realdata)
- continue;
- space = (cr) ? 0 : 1;
- cr = 0;
- nlcnt++;
- if (nlcnt > 1) {
-// *to++ = nl;
- rawBuf[to++] = 10;
-// *to++ = nl[1];
-// nlcnt = 0;
- }
- continue;
- case 13:
- if (!realdata)
- continue;
-// *to++ = nl[0];
- rawBuf[to++] = 10;
- space = 0;
- cr = 1;
- continue;
- }
- realdata = 1;
- nlcnt = 0;
- if (space) {
- space = 0;
- if (rawBuf[from] != ' ') {
- rawBuf[to++] = ' ';
- from--;
- continue;
- }
- }
- rawBuf[to++] = rawBuf[from];
- }
- buf.setSize(to);
-
- while (to > 1) { // remove trailing excess
- to--;
- if ((rawBuf[to] == 10) || (rawBuf[to] == ' '))
- buf.setSize(to);
- else break;
- }
-}
-
-
-/******************************************************************************
- * zStr::getText - gets text at a given offset
- *
- * ENT:
- * offset - idxoffset where the key is located.
- * buf - buffer to store text
- * idxbuf - buffer to store index key
- * NOTE: buffer will be alloc'd / realloc'd and
- * should be free'd by the client
- *
- */
-
-void zStr::getText(long offset, char **idxbuf, char **buf) {
- char *ch;
- char *idxbuflocal = 0;
- getKeyFromIdxOffset(offset, &idxbuflocal);
- __u32 start;
- __u32 size;
-
- do {
- lseek(idxfd->getFd(), offset, SEEK_SET);
- read(idxfd->getFd(), &start, sizeof(__u32));
- read(idxfd->getFd(), &size, sizeof(__u32));
- start = swordtoarch32(start);
- size = swordtoarch32(size);
-
- *buf = (*buf) ? (char *)realloc(*buf, size*2 + 1) : (char *)malloc(size*2 + 1);
- *idxbuf = (*idxbuf) ? (char *)realloc(*idxbuf, size*2 + 1) : (char *)malloc(size*2 + 1);
- memset(*buf, 0, size + 1);
- memset(*idxbuf, 0, size + 1);
- lseek(datfd->getFd(), start, SEEK_SET);
- read(datfd->getFd(), *buf, (int)(size));
-
- for (ch = *buf; *ch; ch++) { // skip over index string
- if (*ch == 10) {
- ch++;
- break;
- }
- }
- memmove(*buf, ch, size - (unsigned long)(ch-*buf));
-
- // resolve link
- if (!strncmp(*buf, "@LINK", 5)) {
- for (ch = *buf; *ch; ch++) { // null before nl
- if (*ch == 10) {
- *ch = 0;
- break;
- }
- }
- findKeyIndex(*buf + 6, &offset);
- }
- else break;
- }
- while (true); // while we're resolving links
-
- if (idxbuflocal) {
- __u32 localsize = strlen(idxbuflocal);
- localsize = (localsize < (size - 1)) ? localsize : (size - 1);
- strncpy(*idxbuf, idxbuflocal, localsize);
- (*idxbuf)[localsize] = 0;
- free(idxbuflocal);
- }
- __u32 block = 0;
- __u32 entry = 0;
- memmove(&block, *buf, sizeof(__u32));
- memmove(&entry, *buf + sizeof(__u32), sizeof(__u32));
- block = swordtoarch32(block);
- entry = swordtoarch32(entry);
- getCompressedText(block, entry, buf);
-}
-
-
-/******************************************************************************
- * zStr::getCompressedText - Get text entry from a compressed index / zdata
- * file.
- */
-
-void zStr::getCompressedText(long block, long entry, char **buf) {
-
- __u32 size = 0;
-
- if (cacheBlockIndex != block) {
- __u32 start = 0;
-
- lseek(zdxfd->getFd(), block * ZDXENTRYSIZE, SEEK_SET);
- read(zdxfd->getFd(), &start, sizeof(__u32));
- read(zdxfd->getFd(), &size, sizeof(__u32));
- start = swordtoarch32(start);
- size = swordtoarch32(size);
-
- SWBuf buf;
- buf.setSize(size + 5);
- lseek(zdtfd->getFd(), start, SEEK_SET);
- read(zdtfd->getFd(), buf.getRawData(), size);
-
- flushCache();
-
- unsigned long len = size;
- buf.setSize(size);
- rawZFilter(buf, 0); // 0 = decipher
-
- compressor->zBuf(&len, buf.getRawData());
- char *rawBuf = compressor->Buf(0, &len);
- cacheBlock = new EntriesBlock(rawBuf, len);
- cacheBlockIndex = block;
- }
- size = cacheBlock->getEntrySize(entry);
- *buf = (*buf) ? (char *)realloc(*buf, size*2 + 1) : (char *)malloc(size*2 + 1);
- strcpy(*buf, cacheBlock->getEntry(entry));
-}
-
-
-/******************************************************************************
- * zLD::settext - Sets text for current offset
- *
- * ENT: key - key for this entry
- * buf - buffer to store
- * len - length of buffer (0 - null terminated)
- */
-
-void zStr::setText(const char *ikey, const char *buf, long len) {
-
- __u32 start, outstart;
- __u32 size, outsize;
- __s32 endoff;
- long idxoff = 0;
- __s32 shiftSize;
- static const char nl[] = {13, 10};
- char *tmpbuf = 0;
- char *key = 0;
- char *dbKey = 0;
- char *idxBytes = 0;
- char *outbuf = 0;
- char *ch = 0;
-
- len = (len < 0) ? strlen(buf) : len;
- stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
-
- char notFound = findKeyIndex(ikey, &idxoff, 0);
- if (!notFound) {
- getKeyFromIdxOffset(idxoff, &dbKey);
- int diff = strcmp(key, dbKey);
- if (diff < 0) {
- }
- else if (diff > 0) {
- idxoff += IDXENTRYSIZE;
- }
- else if ((!diff) && (len > 0 /*we're not deleting*/)) { // got absolute entry
- do {
- lseek(idxfd->getFd(), idxoff, SEEK_SET);
- read(idxfd->getFd(), &start, sizeof(__u32));
- read(idxfd->getFd(), &size, sizeof(__u32));
- start = swordtoarch32(start);
- size = swordtoarch32(size);
-
- tmpbuf = new char [ size + 2 ];
- memset(tmpbuf, 0, size + 2);
- lseek(datfd->getFd(), start, SEEK_SET);
- read(datfd->getFd(), tmpbuf, size);
-
- for (ch = tmpbuf; *ch; ch++) { // skip over index string
- if (*ch == 10) {
- ch++;
- break;
- }
- }
- memmove(tmpbuf, ch, size - (unsigned long)(ch-tmpbuf));
-
- // resolve link
- if (!strncmp(tmpbuf, "@LINK", 5) && (len)) {
- for (ch = tmpbuf; *ch; ch++) { // null before nl
- if (*ch == 10) {
- *ch = 0;
- break;
- }
- }
- findKeyIndex(tmpbuf + IDXENTRYSIZE, &idxoff);
- delete [] tmpbuf;
- }
- else break;
- }
- while (true); // while we're resolving links
- }
- }
-
- endoff = lseek(idxfd->getFd(), 0, SEEK_END);
-
- shiftSize = endoff - idxoff;
-
- if (shiftSize > 0) {
- idxBytes = new char [ shiftSize ];
- lseek(idxfd->getFd(), idxoff, SEEK_SET);
- read(idxfd->getFd(), idxBytes, shiftSize);
- }
-
- outbuf = new char [ len + strlen(key) + 5 ];
- sprintf(outbuf, "%s%c%c", key, 13, 10);
- size = strlen(outbuf);
- if (len > 0) { // NOT a link
- if (!cacheBlock) {
- flushCache();
- cacheBlock = new EntriesBlock();
- cacheBlockIndex = (lseek(zdxfd->getFd(), 0, SEEK_END) / ZDXENTRYSIZE);
- }
- else if (cacheBlock->getCount() >= blockCount) {
- flushCache();
- cacheBlock = new EntriesBlock();
- cacheBlockIndex = (lseek(zdxfd->getFd(), 0, SEEK_END) / ZDXENTRYSIZE);
- }
- __u32 entry = cacheBlock->addEntry(buf);
- cacheDirty = true;
- outstart = archtosword32(cacheBlockIndex);
- outsize = archtosword32(entry);
- memcpy (outbuf + size, &outstart, sizeof(__u32));
- memcpy (outbuf + size + sizeof(__u32), &outsize, sizeof(__u32));
- size += (sizeof(__u32) * 2);
- }
- else { // link
- memcpy(outbuf + size, buf, len);
- size += len;
- }
-
- start = lseek(datfd->getFd(), 0, SEEK_END);
-
- outstart = archtosword32(start);
- outsize = archtosword32(size);
-
- lseek(idxfd->getFd(), idxoff, SEEK_SET);
- if (len > 0) {
- lseek(datfd->getFd(), start, SEEK_SET);
- write(datfd->getFd(), outbuf, size);
-
- // add a new line to make data file easier to read in an editor
- write(datfd->getFd(), &nl, 2);
-
- write(idxfd->getFd(), &outstart, sizeof(__u32));
- write(idxfd->getFd(), &outsize, sizeof(__u32));
- if (idxBytes) {
- write(idxfd->getFd(), idxBytes, shiftSize);
- }
- }
- else { // delete entry
- if (idxBytes) {
- write(idxfd->getFd(), idxBytes+IDXENTRYSIZE, shiftSize-IDXENTRYSIZE);
- lseek(idxfd->getFd(), -1, SEEK_CUR); // last valid byte
- FileMgr::systemFileMgr.trunc(idxfd); // truncate index
- }
- }
-
- if (idxBytes)
- delete [] idxBytes;
- delete [] key;
- delete [] outbuf;
- free(dbKey);
-}
-
-
-/******************************************************************************
- * zLD::linkentry - links one entry to another
- *
- * ENT: testmt - testament to find (0 - Bible/module introduction)
- * destidxoff - dest offset into .vss
- * srcidxoff - source offset into .vss
- */
-
-void zStr::linkEntry(const char *destkey, const char *srckey) {
- char *text = new char [ strlen(destkey) + 7 ];
- sprintf(text, "@LINK %s", destkey);
- setText(srckey, text);
- delete [] text;
-}
-
-
-void zStr::flushCache() {
- if (cacheBlock) {
- if (cacheDirty) {
- __u32 start = 0;
- unsigned long size = 0;
- __u32 outstart = 0, outsize = 0;
-
- const char *rawBuf = cacheBlock->getRawData(&size);
- compressor->Buf(rawBuf, &size);
- compressor->zBuf(&size);
-
- SWBuf buf;
- buf.setSize(size + 5);
- memcpy(buf.getRawData(), compressor->zBuf(&size), size); // 1 = encipher
- buf.setSize(size);
- rawZFilter(buf, 1); // 1 = encipher
-
- long zdxSize = lseek(zdxfd->getFd(), 0, SEEK_END);
- long zdtSize = lseek(zdtfd->getFd(), 0, SEEK_END);
-
- if ((cacheBlockIndex * ZDXENTRYSIZE) > (zdxSize - ZDXENTRYSIZE)) { // New Block
- start = zdtSize;
- }
- else {
- lseek(zdxfd->getFd(), cacheBlockIndex * ZDXENTRYSIZE, SEEK_SET);
- read(zdxfd->getFd(), &start, sizeof(__u32));
- read(zdxfd->getFd(), &outsize, sizeof(__u32));
- start = swordtoarch32(start);
- outsize = swordtoarch32(outsize);
- if (start + outsize >= zdtSize) { // last entry, just overwrite
- // start is already set
- }
- else if (size < outsize) { // middle entry, but smaller, that's fine and let's preserve bigger size
- size = outsize;
- }
- else { // middle and bigger-- we have serious problems, for now let's put it at the end = lots of wasted space
- start = zdtSize;
- }
- }
-
-
-
- outstart = archtosword32(start);
- outsize = archtosword32((__u32)size);
-
- lseek(zdxfd->getFd(), cacheBlockIndex * ZDXENTRYSIZE, SEEK_SET);
- lseek(zdtfd->getFd(), start, SEEK_SET);
- write(zdtfd->getFd(), buf, size);
-
- // add a new line to make data file easier to read in an editor
- write(zdtfd->getFd(), &nl, 2);
-
- write(zdxfd->getFd(), &outstart, sizeof(__u32));
- write(zdxfd->getFd(), &outsize, sizeof(__u32));
- }
- delete cacheBlock;
- cacheBlock = 0;
- }
- cacheBlockIndex = -1;
- cacheDirty = false;
-}
-
-
-/******************************************************************************
- * zLD::CreateModule - Creates new module files
- *
- * ENT: path - directory to store module files
- * RET: error status
- */
-
-signed char zStr::createModule(const char *ipath) {
- char *path = 0;
- char *buf = new char [ strlen (ipath) + 20 ];
- FileDesc *fd, *fd2;
-
- stdstr(&path, ipath);
-
- if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\'))
- path[strlen(path)-1] = 0;
-
- sprintf(buf, "%s.dat", path);
- unlink(buf);
- fd = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd->getFd();
- FileMgr::systemFileMgr.close(fd);
-
- sprintf(buf, "%s.idx", path);
- unlink(buf);
- fd2 = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd2->getFd();
- FileMgr::systemFileMgr.close(fd2);
-
- sprintf(buf, "%s.zdt", path);
- unlink(buf);
- fd2 = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd2->getFd();
- FileMgr::systemFileMgr.close(fd2);
-
- sprintf(buf, "%s.zdx", path);
- unlink(buf);
- fd2 = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd2->getFd();
- FileMgr::systemFileMgr.close(fd2);
-
- delete [] path;
-
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/common/zverse.cpp b/src/modules/common/zverse.cpp
deleted file mode 100644
index 1f7f25d..0000000
--- a/src/modules/common/zverse.cpp
+++ /dev/null
@@ -1,538 +0,0 @@
-/******************************************************************************
- * zverse.h - code for class 'zVerse'- a module that reads raw text
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
- * and provides lookup and parsing functions based on
- * class VerseKey for compressed modules
- */
-
-
-#include <ctype.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#include <utilfuns.h>
-#include <versekey.h>
-#include <zverse.h>
-#include <sysdata.h>
-#include <swbuf.h>
-
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-SWORD_NAMESPACE_START
-
-/******************************************************************************
- * zVerse Statics
- */
-
-int zVerse::instance = 0;
-
-const char zVerse::uniqueIndexID[] = {'X', 'r', 'v', 'c', 'b'};
-
-/******************************************************************************
- * zVerse Constructor - Initializes data for instance of zVerse
- *
- * ENT: ipath - path of the directory where data and index files are located.
- * be sure to include the trailing separator (e.g. '/' or '\')
- * (e.g. 'modules/texts/rawtext/webster/')
- * fileMode - open mode for the files (O_RDONLY, etc.)
- * blockType - verse, chapter, book, etc.
- */
-
-zVerse::zVerse(const char *ipath, int fileMode, int blockType, SWCompress *icomp)
-{
- char buf[127];
-
- nl = '\n';
- path = 0;
- cacheBufIdx = -1;
- cacheTestament = 0;
- cacheBuf = 0;
- dirtyCache = false;
- stdstr(&path, ipath);
-
- if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\'))
- path[strlen(path)-1] = 0;
-
- compressor = (icomp) ? icomp : new SWCompress();
-
- if (fileMode == -1) { // try read/write if possible
- fileMode = O_RDWR;
- }
-
- sprintf(buf, "%s/ot.%czs", path, uniqueIndexID[blockType]);
- idxfp[0] = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- sprintf(buf, "%s/nt.%czs", path, uniqueIndexID[blockType]);
- idxfp[1] = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- sprintf(buf, "%s/ot.%czz", path, uniqueIndexID[blockType]);
- textfp[0] = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- sprintf(buf, "%s/nt.%czz", path, uniqueIndexID[blockType]);
- textfp[1] = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- sprintf(buf, "%s/ot.%czv", path, uniqueIndexID[blockType]);
- compfp[0] = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- sprintf(buf, "%s/nt.%czv", path, uniqueIndexID[blockType]);
- compfp[1] = FileMgr::systemFileMgr.open(buf, fileMode|O_BINARY, true);
-
- instance++;
-}
-
-
-/******************************************************************************
- * zVerse Destructor - Cleans up instance of zVerse
- */
-
-zVerse::~zVerse()
-{
- int loop1;
-
- if (cacheBuf) {
- flushCache();
- free(cacheBuf);
- }
-
- if (path)
- delete [] path;
-
- if (compressor)
- delete compressor;
-
- --instance;
-
- for (loop1 = 0; loop1 < 2; loop1++) {
- FileMgr::systemFileMgr.close(idxfp[loop1]);
- FileMgr::systemFileMgr.close(textfp[loop1]);
- FileMgr::systemFileMgr.close(compfp[loop1]);
- }
-}
-
-
-/******************************************************************************
- * zVerse::findoffset - Finds the offset of the key verse from the indexes
- *
- *
- *
- * ENT: testmt - testament to find (0 - Bible/module introduction)
- * book - book to find (0 - testament introduction)
- * chapter - chapter to find (0 - book introduction)
- * verse - verse to find (0 - chapter introduction)
- * start - address to store the starting offset
- * size - address to store the size of the entry
- */
-
-void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *size)
-{
- // set start to offset in
- // set size to
- // set
- unsigned long ulBuffNum=0; // buffer number
- unsigned long ulVerseStart=0; // verse offset within buffer
- unsigned short usVerseSize=0; // verse size
- unsigned long ulCompOffset=0; // compressed buffer start
- unsigned long ulCompSize=0; // buffer size compressed
- unsigned long ulUnCompSize=0; // buffer size uncompressed
- char *pcCompText=NULL; // compressed text
-
- *start = *size = 0;
- //printf ("Finding offset %ld\n", idxoff);
- idxoff *= 10;
- if (!testmt) {
- testmt = ((idxfp[0]) ? 1:2);
- }
-
- // assert we have and valid file descriptor
- if (compfp[testmt-1]->getFd() < 1)
- return;
-
- long newOffset = lseek(compfp[testmt-1]->getFd(), idxoff, SEEK_SET);
- if (newOffset == idxoff) {
- if (read(compfp[testmt-1]->getFd(), &ulBuffNum, 4) != 4) {
- printf ("Error reading ulBuffNum\n");
- return;
- }
- }
- else return;
-
- ulBuffNum = swordtoarch32(ulBuffNum);
-
- if (read(compfp[testmt-1]->getFd(), &ulVerseStart, 4) < 2)
- {
- printf ("Error reading ulVerseStart\n");
- return;
- }
- if (read(compfp[testmt-1]->getFd(), &usVerseSize, 2) < 2)
- {
- printf ("Error reading usVerseSize\n");
- return;
- }
-
- *start = swordtoarch32(ulVerseStart);
- *size = swordtoarch16(usVerseSize);
-
- if (*size) {
- if (((long) ulBuffNum == cacheBufIdx) && (testmt == cacheTestament) && (cacheBuf)) {
- // have the text buffered
- return;
- }
-
- //printf ("Got buffer number{%ld} versestart{%ld} versesize{%d}\n", ulBuffNum, ulVerseStart, usVerseSize);
-
-
- if (lseek(idxfp[testmt-1]->getFd(), ulBuffNum*12, SEEK_SET)!=(long) ulBuffNum*12)
- {
- printf ("Error seeking compressed file index\n");
- return;
- }
- if (read(idxfp[testmt-1]->getFd(), &ulCompOffset, 4)<4)
- {
- printf ("Error reading ulCompOffset\n");
- return;
- }
- if (read(idxfp[testmt-1]->getFd(), &ulCompSize, 4)<4)
- {
- printf ("Error reading ulCompSize\n");
- return;
- }
- if (read(idxfp[testmt-1]->getFd(), &ulUnCompSize, 4)<4)
- {
- printf ("Error reading ulUnCompSize\n");
- return;
- }
-
- ulCompOffset = swordtoarch32(ulCompOffset);
- ulCompSize = swordtoarch32(ulCompSize);
- ulUnCompSize = swordtoarch32(ulUnCompSize);
-
- if (lseek(textfp[testmt-1]->getFd(), ulCompOffset, SEEK_SET)!=(long)ulCompOffset)
- {
- printf ("Error: could not seek to right place in compressed text\n");
- return;
- }
- SWBuf pcCompText;
- pcCompText.setSize(ulCompSize+5);
-
- if (read(textfp[testmt-1]->getFd(), pcCompText.getRawData(), ulCompSize)<(long)ulCompSize) {
- printf ("Error reading compressed text\n");
- return;
- }
- pcCompText.setSize(ulCompSize);
- rawZFilter(pcCompText, 0); // 0 = decipher
-
- compressor->zBuf(&ulCompSize, pcCompText.getRawData());
-
- if (cacheBuf) {
- flushCache();
- free(cacheBuf);
- }
-
- unsigned long len = 0;
- compressor->Buf(0, &len);
- cacheBuf = (char *)calloc(len + 1, 1);
- memcpy(cacheBuf, compressor->Buf(), len);
-
- cacheTestament = testmt;
- cacheBufIdx = ulBuffNum;
- }
-}
-
-
-/******************************************************************************
- * zVerse::zreadtext - gets text at a given offset
- *
- * ENT: testmt - testament file to search in (0 - Old; 1 - New)
- * start - starting offset where the text is located in the file
- * size - size of text entry + 1 (null)
- * buf - buffer to store text
- *
- */
-
-void zVerse::zReadText(char testmt, long start, unsigned short size, SWBuf &inBuf) {
- inBuf = "";
- inBuf.setFillByte(0);
- inBuf.setSize(size+1);
- if (size > 0) {
- if (cacheBuf)
- strncpy(inBuf.getRawData(), &(cacheBuf[start]), size);
- }
- inBuf.setSize(strlen(inBuf.c_str()));
-}
-
-
-/******************************************************************************
- * zVerse::settext - Sets text for current offset
- *
- * ENT: testmt - testament to find (0 - Bible/module introduction)
- * idxoff - offset into .vss
- * buf - buffer to store
- * len - length of buffer (0 - null terminated)
- */
-
-void zVerse::doSetText(char testmt, long idxoff, const char *buf, long len) {
-
- len = (len < 0) ? strlen(buf) : len;
- if (!testmt)
- testmt = ((idxfp[0]) ? 1:2);
- if ((!dirtyCache) || (cacheBufIdx < 0)) {
- cacheBufIdx = lseek(idxfp[testmt-1]->getFd(), 0, SEEK_END) / 12;
- cacheTestament = testmt;
- if (cacheBuf)
- free(cacheBuf);
- cacheBuf = (char *)calloc(len + 1, 1);
- }
- else cacheBuf = (char *)((cacheBuf)?realloc(cacheBuf, strlen(cacheBuf)+(len + 1)):calloc((len + 1), 1));
-
- dirtyCache = true;
-
- unsigned long start, outstart;
- unsigned long outBufIdx = cacheBufIdx;
- unsigned short size;
- unsigned short outsize;
-
- idxoff *= 10;
- size = outsize = len;
-
- start = strlen(cacheBuf);
-
- if (!size)
- start = outBufIdx = 0;
-
- outBufIdx = archtosword32(outBufIdx);
- outstart = archtosword32(start);
- outsize = archtosword16(size);
-
- lseek(compfp[testmt-1]->getFd(), idxoff, SEEK_SET);
- write(compfp[testmt-1]->getFd(), &outBufIdx, 4);
- write(compfp[testmt-1]->getFd(), &outstart, 4);
- write(compfp[testmt-1]->getFd(), &outsize, 2);
- strcat(cacheBuf, buf);
-}
-
-
-void zVerse::flushCache() {
- if (dirtyCache) {
- unsigned long idxoff;
- unsigned long start, outstart;
- unsigned long size, outsize;
- unsigned long zsize, outzsize;
-
- idxoff = cacheBufIdx * 12;
- if (cacheBuf) {
- size = outsize = zsize = outzsize = strlen(cacheBuf);
- if (size) {
- // if (compressor) {
- // delete compressor;
- // compressor = new LZSSCompress();
- // }
- compressor->Buf(cacheBuf);
- compressor->zBuf(&zsize);
- outzsize = zsize;
-
- SWBuf buf;
- buf.setSize(zsize + 5);
- memcpy(buf.getRawData(), compressor->zBuf(&zsize), zsize);
- buf.setSize(zsize);
- rawZFilter(buf, 1); // 1 = encipher
-
- start = outstart = lseek(textfp[cacheTestament-1]->getFd(), 0, SEEK_END);
-
- outstart = archtosword32(start);
- outsize = archtosword32(size);
- outzsize = archtosword32(zsize);
-
- write(textfp[cacheTestament-1]->getFd(), buf, zsize);
-
- lseek(idxfp[cacheTestament-1]->getFd(), idxoff, SEEK_SET);
- write(idxfp[cacheTestament-1]->getFd(), &outstart, 4);
- write(idxfp[cacheTestament-1]->getFd(), &outzsize, 4);
- write(idxfp[cacheTestament-1]->getFd(), &outsize, 4);
- }
- free(cacheBuf);
- cacheBuf = 0;
- }
- dirtyCache = false;
- }
-}
-
-/******************************************************************************
- * RawVerse::linkentry - links one entry to another
- *
- * ENT: testmt - testament to find (0 - Bible/module introduction)
- * destidxoff - dest offset into .vss
- * srcidxoff - source offset into .vss
- */
-
-void zVerse::doLinkEntry(char testmt, long destidxoff, long srcidxoff) {
- long bufidx;
- long start;
- unsigned short size;
-
- destidxoff *= 10;
- srcidxoff *= 10;
-
- if (!testmt)
- testmt = ((idxfp[1]) ? 1:2);
-
- // get source
- lseek(compfp[testmt-1]->getFd(), srcidxoff, SEEK_SET);
- read(compfp[testmt-1]->getFd(), &bufidx, 4);
- read(compfp[testmt-1]->getFd(), &start, 4);
- read(compfp[testmt-1]->getFd(), &size, 2);
-
- // write dest
- lseek(compfp[testmt-1]->getFd(), destidxoff, SEEK_SET);
- write(compfp[testmt-1]->getFd(), &bufidx, 4);
- write(compfp[testmt-1]->getFd(), &start, 4);
- write(compfp[testmt-1]->getFd(), &size, 2);
-}
-
-
-/******************************************************************************
- * RawVerse::CreateModule - Creates new module files
- *
- * ENT: path - directory to store module files
- * RET: error status
- */
-
-char zVerse::createModule(const char *ipath, int blockBound)
-{
- char *path = 0;
- char *buf = new char [ strlen (ipath) + 20 ];
- FileDesc *fd, *fd2;
-
- stdstr(&path, ipath);
-
- if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\'))
- path[strlen(path)-1] = 0;
-
- sprintf(buf, "%s/ot.%czs", path, uniqueIndexID[blockBound]);
- unlink(buf);
- fd = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd->getFd();
- FileMgr::systemFileMgr.close(fd);
-
- sprintf(buf, "%s/nt.%czs", path, uniqueIndexID[blockBound]);
- unlink(buf);
- fd = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd->getFd();
- FileMgr::systemFileMgr.close(fd);
-
- sprintf(buf, "%s/ot.%czz", path, uniqueIndexID[blockBound]);
- unlink(buf);
- fd = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd->getFd();
- FileMgr::systemFileMgr.close(fd);
-
- sprintf(buf, "%s/nt.%czz", path, uniqueIndexID[blockBound]);
- unlink(buf);
- fd2 = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd2->getFd();
- FileMgr::systemFileMgr.close(fd);
-
- sprintf(buf, "%s/ot.%czv", path, uniqueIndexID[blockBound]);
- unlink(buf);
- fd = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd->getFd();
-
- sprintf(buf, "%s/nt.%czv", path, uniqueIndexID[blockBound]);
- unlink(buf);
- fd2 = FileMgr::systemFileMgr.open(buf, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
- fd2->getFd();
-
- VerseKey vk;
- vk.Headings(1);
- long offset = 0;
- short size = 0;
- for (vk = TOP; !vk.Error(); vk++) {
- write((vk.Testament() == 1) ? fd->getFd() : fd2->getFd(), &offset, 4); //compBufIdxOffset
- write((vk.Testament() == 1) ? fd->getFd() : fd2->getFd(), &offset, 4);
- write((vk.Testament() == 1) ? fd->getFd() : fd2->getFd(), &size, 2);
- }
-
- FileMgr::systemFileMgr.close(fd);
- FileMgr::systemFileMgr.close(fd2);
-
- delete [] path;
- delete [] buf;
-/*
- RawVerse rv(path);
- VerseKey mykey("Rev 22:21");
-*/
-
- return 0;
-}
-
-
-/******************************************************************************
- * zVerse::preptext - Prepares the text before returning it to external
- * objects
- *
- * ENT: buf - buffer where text is stored and where to store the prep'd
- * text.
- */
-
-void zVerse::prepText(SWBuf &buf) {
- unsigned int to, from;
- char space = 0, cr = 0, realdata = 0, nlcnt = 0;
- char *rawBuf = buf.getRawData();
- for (to = from = 0; rawBuf[from]; from++) {
- switch (rawBuf[from]) {
- case 10:
- if (!realdata)
- continue;
- space = (cr) ? 0 : 1;
- cr = 0;
- nlcnt++;
- if (nlcnt > 1) {
-// *to++ = nl;
- rawBuf[to++] = 10;
-// *to++ = nl[1];
-// nlcnt = 0;
- }
- continue;
- case 13:
- if (!realdata)
- continue;
-// *to++ = nl[0];
- rawBuf[to++] = 10;
- space = 0;
- cr = 1;
- continue;
- }
- realdata = 1;
- nlcnt = 0;
- if (space) {
- space = 0;
- if (rawBuf[from] != ' ') {
- rawBuf[to++] = ' ';
- from--;
- continue;
- }
- }
- rawBuf[to++] = rawBuf[from];
- }
- buf.setSize(to);
-
- while (to > 1) { // remove trailing excess
- to--;
- if ((rawBuf[to] == 10) || (rawBuf[to] == ' '))
- buf.setSize(to);
- else break;
- }
-}
-
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/Makefile b/src/modules/filters/Makefile
deleted file mode 100644
index 1a2d00d..0000000
--- a/src/modules/filters/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-root := ../../..
-
-all:
- make -C ${root}
diff --git a/src/modules/filters/Makefile.am b/src/modules/filters/Makefile.am
deleted file mode 100644
index c9a6bef..0000000
--- a/src/modules/filters/Makefile.am
+++ /dev/null
@@ -1,92 +0,0 @@
-filtersdir = $(top_srcdir)/src/modules/filters
-
-libsword_la_SOURCES += $(filtersdir)/swbasicfilter.cpp
-libsword_la_SOURCES += $(filtersdir)/swoptfilter.cpp
-
-libsword_la_SOURCES += $(filtersdir)/gbfhtml.cpp
-libsword_la_SOURCES += $(filtersdir)/gbfhtmlhref.cpp
-libsword_la_SOURCES += $(filtersdir)/gbfwebif.cpp
-libsword_la_SOURCES += $(filtersdir)/gbfplain.cpp
-libsword_la_SOURCES += $(filtersdir)/gbfrtf.cpp
-libsword_la_SOURCES += $(filtersdir)/plainhtml.cpp
-libsword_la_SOURCES += $(filtersdir)/cipherfil.cpp
-libsword_la_SOURCES += $(filtersdir)/rtfhtml.cpp
-
-libsword_la_SOURCES += $(filtersdir)/gbfstrongs.cpp
-libsword_la_SOURCES += $(filtersdir)/gbffootnotes.cpp
-libsword_la_SOURCES += $(filtersdir)/gbfheadings.cpp
-libsword_la_SOURCES += $(filtersdir)/gbfredletterwords.cpp
-libsword_la_SOURCES += $(filtersdir)/gbfmorph.cpp
-libsword_la_SOURCES += $(filtersdir)/plainfootnotes.cpp
-
-libsword_la_SOURCES += $(filtersdir)/thmlstrongs.cpp
-libsword_la_SOURCES += $(filtersdir)/thmlfootnotes.cpp
-libsword_la_SOURCES += $(filtersdir)/thmlheadings.cpp
-libsword_la_SOURCES += $(filtersdir)/thmlmorph.cpp
-libsword_la_SOURCES += $(filtersdir)/thmllemma.cpp
-libsword_la_SOURCES += $(filtersdir)/thmlscripref.cpp
-libsword_la_SOURCES += $(filtersdir)/thmlvariants.cpp
-
-libsword_la_SOURCES += $(filtersdir)/gbfthml.cpp
-libsword_la_SOURCES += $(filtersdir)/thmlgbf.cpp
-libsword_la_SOURCES += $(filtersdir)/thmlrtf.cpp
-libsword_la_SOURCES += $(filtersdir)/thmlhtml.cpp
-libsword_la_SOURCES += $(filtersdir)/thmlhtmlhref.cpp
-libsword_la_SOURCES += $(filtersdir)/thmlwebif.cpp
-
-libsword_la_SOURCES += $(filtersdir)/thmlosis.cpp
-libsword_la_SOURCES += $(filtersdir)/gbfosis.cpp
-libsword_la_SOURCES += $(filtersdir)/thmlplain.cpp
-
-libsword_la_SOURCES += $(filtersdir)/osisheadings.cpp
-libsword_la_SOURCES += $(filtersdir)/osisfootnotes.cpp
-libsword_la_SOURCES += $(filtersdir)/osishtmlhref.cpp
-libsword_la_SOURCES += $(filtersdir)/osiswebif.cpp
-libsword_la_SOURCES += $(filtersdir)/osismorph.cpp
-libsword_la_SOURCES += $(filtersdir)/osisstrongs.cpp
-libsword_la_SOURCES += $(filtersdir)/osisplain.cpp
-libsword_la_SOURCES += $(filtersdir)/osisrtf.cpp
-libsword_la_SOURCES += $(filtersdir)/osislemma.cpp
-libsword_la_SOURCES += $(filtersdir)/osisredletterwords.cpp
-libsword_la_SOURCES += $(filtersdir)/osisscripref.cpp
-
-libsword_la_SOURCES += $(filtersdir)/unicodertf.cpp
-libsword_la_SOURCES += $(filtersdir)/latin1utf8.cpp
-libsword_la_SOURCES += $(filtersdir)/latin1utf16.cpp
-libsword_la_SOURCES += $(filtersdir)/utf8utf16.cpp
-libsword_la_SOURCES += $(filtersdir)/utf16utf8.cpp
-libsword_la_SOURCES += $(filtersdir)/scsuutf8.cpp
-libsword_la_SOURCES += $(filtersdir)/utf8html.cpp
-libsword_la_SOURCES += $(filtersdir)/utf8latin1.cpp
-
-libsword_la_SOURCES += $(filtersdir)/utf8cantillation.cpp
-libsword_la_SOURCES += $(filtersdir)/utf8hebrewpoints.cpp
-libsword_la_SOURCES += $(filtersdir)/utf8greekaccents.cpp
-
-libsword_la_SOURCES += $(filtersdir)/greeklexattribs.cpp
-
-SWICUSRC = $(filtersdir)/utf8transliterator.cpp
-SWICUSRC += $(filtersdir)/utf8nfc.cpp
-SWICUSRC += $(filtersdir)/utf8nfkd.cpp
-SWICUSRC += $(filtersdir)/utf8arshaping.cpp
-SWICUSRC += $(filtersdir)/utf8bidireorder.cpp
-
-if ICU
-ICUDEFS = -D_ICU_
-DISTSWICUSRC =
-SWREALICUSRC = $(SWICUSRC)
-else
-if ICUSWORD
-ICUDEFS = -D_ICU_ -D_ICUSWORD_
-DISTSWICUSRC =
-SWREALICUSRC = $(SWICUSRC)
-else
-DISTSWICUSRC = $(SWICUSRC)
-SWREALICUSRC =
-endif
-endif
-
-INCLUDES += $(ICUDEFS)
-libsword_la_SOURCES += $(SWREALICUSRC)
-EXTRA_DIST = $(DISTSWICUSRC)
-
diff --git a/src/modules/filters/cipherfil.cpp b/src/modules/filters/cipherfil.cpp
deleted file mode 100644
index abdd0fc..0000000
--- a/src/modules/filters/cipherfil.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/******************************************************************************
- *
- * cipherfil - SWFilter descendant to decipher a module
- */
-
-
-#include <stdlib.h>
-#include <cipherfil.h>
-
-SWORD_NAMESPACE_START
-
-CipherFilter::CipherFilter(const char *key) {
- cipher = new SWCipher((unsigned char *)key);
-}
-
-
-CipherFilter::~CipherFilter() {
- delete cipher;
-}
-
-
-SWCipher *CipherFilter::getCipher() {
- return cipher;
-}
-
-
-char CipherFilter::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- if (text.length() > 2) { //check if it's large enough to substract 2 in the next step.
- unsigned long len = text.length();
- if (!key) { // hack, using key to determine encipher, or decipher
- cipher->cipherBuf(&len, text.getRawData()); //set buffer to enciphered text
- memcpy(text.getRawData(), cipher->Buf(), len);
-// text = cipher->Buf(); //get the deciphered buffer
- }
- else if ((unsigned long)key == 1) {
- cipher->Buf(text.getRawData(), len);
- memcpy(text.getRawData(), cipher->cipherBuf(&len), len);
-// text = cipher->cipherBuf(&len);
- }
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/gbffootnotes.cpp b/src/modules/filters/gbffootnotes.cpp
deleted file mode 100644
index 38f1106..0000000
--- a/src/modules/filters/gbffootnotes.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/******************************************************************************
- *
- * gbffootnotes - SWFilter descendant to hide or show footnotes
- * in a GBF module.
- */
-
-
-#include <stdlib.h>
-#include <gbffootnotes.h>
-#include <swmodule.h>
-#include <swbuf.h>
-#include <versekey.h>
-#include <utilxml.h>
-#ifndef __GNUC__
-#else
-#include <unixstr.h>
-#endif
-
-SWORD_NAMESPACE_START
-
-const char oName[] = "Footnotes";
-const char oTip[] = "Toggles Footnotes On and Off if they exist";
-
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
-
-
-GBFFootnotes::GBFFootnotes() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
-}
-
-
-GBFFootnotes::~GBFFootnotes() {
-}
-
-
-char GBFFootnotes::processText (SWBuf &text, const SWKey *key, const SWModule *module)
-{
-
- SWBuf token;
- bool intoken = false;
- bool hide = false;
- SWBuf tagText;
- XMLTag startTag;
- SWBuf refs = "";
- int footnoteNum = 1;
- char buf[254];
- VerseKey parser = key->getText();
-
- SWBuf orig = text;
- const char *from = orig.c_str();
-
- for (text = ""; *from; from++) {
- if (*from == '<') {
- intoken = true;
- token = "";
- continue;
- }
- if (*from == '>') { // process tokens
- intoken = false;
-
- XMLTag tag(token);
- if (!strcmp(tag.getName(), "RF")) {
- refs = "";
- startTag = tag;
- hide = true;
- tagText = "";
- continue;
- }
- else if (!strcmp(tag.getName(), "Rf")) {
- if (module->isProcessEntryAttributes()) {
- if(tagText.length() == 1 || !strcmp(module->Name(), "IGNT")) {
- if (option) { // for ASV marks text in verse then put explanation at end of verse
- text += " <FA>(";
- text.append(tagText);
- text += ")<Fr>";
- hide = false;
- continue;
- }
- }
- SWBuf fc = module->getEntryAttributes()["Footnote"]["count"]["value"];
- footnoteNum = (fc.length()) ? atoi(fc.c_str()) : 0;
- sprintf(buf, "%i", ++footnoteNum);
- module->getEntryAttributes()["Footnote"]["count"]["value"] = buf;
- StringList attributes = startTag.getAttributeNames();
- for (StringList::iterator it = attributes.begin(); it != attributes.end(); it++) {
- module->getEntryAttributes()["Footnote"][buf][it->c_str()] = startTag.getAttribute(it->c_str());
- }
- module->getEntryAttributes()["Footnote"][buf]["body"] = tagText;
- startTag.setAttribute("swordFootnote", buf);
- }
- hide = false;
- if (option) {
- text += startTag;
- text.append(tagText);
- }
- else continue;
- }
- if (!hide) {
- text += '<';
- text.append(token);
- text += '>';
- }
- else {
- tagText += '<';
- tagText.append(token);
- tagText += '>';
- }
- continue;
- }
- if (intoken) { //copy token
- token += *from;
- }
- else if (!hide) { //copy text which is not inside a token
- text += *from;
- }
- else tagText += *from;
- }
- return 0;
-
-
-
-
-
-
-
-
- /*
- if (!option) { // if we don't want footnotes
- char token[4096]; // cheese. Fix.
- int tokpos = 0;
- bool intoken = false;
- int len;
- bool hide = false;
-
- const char *from;
- SWBuf orig = text;
- from = orig.c_str();
- for (text = ""; *from; from++) {
- if (*from == '<') {
- intoken = true;
- tokpos = 0;
-// memset(token, 0, 4096);
- token[0] = 0;
- token[1] = 0;
- token[2] = 0;
- continue;
- }
- if (*from == '>') { // process tokens
- intoken = false;
- switch (*token) {
- case 'R': // Reference
- switch(token[1]) {
- case 'F': // Begin footnote
- hide = true;
- break;
- case 'f': // end footnote
- hide = false;
- break;
- }
- continue; // skip token
- case 'W':
- if (token[1] == 'T') {
- switch (token[2]) {
- case 'P':
- case 'S':
- case 'A':
- continue; // remove this token
- default:
- break;
- }
- }
- }
- // if not a footnote token, keep token in text
- if (!hide) {
- text += '<';
- text += token;
- text += '>';
- }
- continue;
- }
- if (intoken) {
- if (tokpos < 4090)
- token[tokpos++] = *from;
- token[tokpos+2] = 0; // +2 cuz we init token with 2 extra '0' because of switch statement
- }
- else {
- if (!hide) {
- text += *from;
- }
- }
- }
- }
- return 0;*/
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/gbfheadings.cpp b/src/modules/filters/gbfheadings.cpp
deleted file mode 100644
index 01a34ca..0000000
--- a/src/modules/filters/gbfheadings.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/******************************************************************************
- *
- * gbfheadings - SWFilter descendant to hide or show headings
- * in a GBF module.
- */
-
-
-#include <stdlib.h>
-#include <gbfheadings.h>
-#ifndef __GNUC__
-#else
-#include <unixstr.h>
-#endif
-
-SWORD_NAMESPACE_START
-
-
-const char oName[] = "Headings";
-const char oTip[] = "Toggles Headings On and Off if they exist";
-
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
-
-GBFHeadings::GBFHeadings() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
-}
-
-
-GBFHeadings::~GBFHeadings() {
-}
-
-
-char GBFHeadings::processText (SWBuf &text, const SWKey *key, const SWModule *module) {
- if (!option) { // if we don't want headings
- char token[2048]; // cheese. Fix.
- int tokpos = 0;
- bool intoken = false;
- int len;
- bool hide = false;
-
- const char *from;
- SWBuf orig = text;
- from = orig.c_str();
- for (text = ""; *from; from++) {
- if (*from == '<') {
- intoken = true;
- tokpos = 0;
-// memset(token, 0, 2048);
- token[0] = 0;
- token[1] = 0;
- token[2] = 0;
- continue;
- }
- if (*from == '>') { // process tokens
- intoken = false;
- switch (*token) {
- case 'T': // Reference
- switch(token[1]) {
- case 'S': // Begin heading
- hide = true;
- break;
- case 's': // end heading
- hide = false;
- break;
- }
- continue; // skip token
- }
- // if not a heading token, keep token in text
- if (!hide) {
- text += '<';
- for (char *tok = token; *tok; tok++)
- text += *tok;
- text += '>';
- }
- continue;
- }
- if (intoken) {
- if (tokpos < 2045)
- token[tokpos++] = *from;
- token[tokpos+2] = 0;
- }
- else {
- if (!hide) {
- text += *from;
- }
- }
- }
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/gbfhtml.cpp b/src/modules/filters/gbfhtml.cpp
deleted file mode 100644
index 775bc06..0000000
--- a/src/modules/filters/gbfhtml.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/***************************************************************************
- gbfhtml.cpp - GBF to HTML filter
- -------------------
- begin : 2001-09-03
- copyright : 2001 by CrossWire Bible Society
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include <stdlib.h>
-#include <gbfhtml.h>
-#include <ctype.h>
-
-SWORD_NAMESPACE_START
-
-GBFHTML::GBFHTML() {
- setTokenStart("<");
- setTokenEnd(">");
-
- setTokenCaseSensitive(true);
-
- addTokenSubstitute("Rf", ")</small></font>");
- addTokenSubstitute("Rx", "</a>");
- addTokenSubstitute("FI", "<i>"); // italics begin
- addTokenSubstitute("Fi", "</i>");
- addTokenSubstitute("FB", "<n>"); // bold begin
- addTokenSubstitute("Fb", "</n>");
- addTokenSubstitute("FR", "<font color=\"#FF0000\">"); // words of Jesus begin
- addTokenSubstitute("Fr", "</font>");
- addTokenSubstitute("FU", "<u>"); // underline begin
- addTokenSubstitute("Fu", "</u>");
- addTokenSubstitute("FO", "<cite>"); // Old Testament quote begin
- addTokenSubstitute("Fo", "</cite>");
- addTokenSubstitute("FS", "<sup>"); // Superscript begin// Subscript begin
- addTokenSubstitute("Fs", "</sup>");
- addTokenSubstitute("FV", "<sub>"); // Subscript begin
- addTokenSubstitute("Fv", "</sub>");
- addTokenSubstitute("TT", "<big>"); // Book title begin
- addTokenSubstitute("Tt", "</big>");
- addTokenSubstitute("PP", "<cite>"); // poetry begin
- addTokenSubstitute("Pp", "</cite>");
- addTokenSubstitute("Fn", "</font>"); // font end
- addTokenSubstitute("CL", "<br />"); // new line
- addTokenSubstitute("CM", "<!P><br />"); // paragraph <!P> is a non showing comment that can be changed in the front end to <P> if desired
- addTokenSubstitute("CG", ""); // ???
- addTokenSubstitute("CT", ""); // ???
- addTokenSubstitute("JR", "<div align=\"right\">"); // right align begin
- addTokenSubstitute("JC", "<div align=\"center\">"); // center align begin
- addTokenSubstitute("JL", "</div>"); // align end
-
-}
-
-
-bool GBFHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
- const char *tok;
- char val[128];
- char *valto;
- const char *num;
- MyUserData *u = (MyUserData *)userData;
-
- if (!substituteToken(buf, token)) {
- // deal with OSIS note tags. Just hide till OSISRTF
- if (!strncmp(token, "note ", 5)) {
- // let's stop text from going to output
- u->suspendTextPassThru = true;
- }
-
- else if (!strncmp(token, "/note", 5)) {
- u->suspendTextPassThru = false;
- }
-
- else if (!strncmp(token, "w", 1)) {
- // OSIS Word (temporary until OSISRTF is done)
- valto = val;
- num = strstr(token, "lemma=\"x-Strongs:");
- if (num) {
- for (num+=17; ((*num) && (*num != '\"')); num++)
- *valto++ = *num;
- *valto = 0;
- if (atoi((!isdigit(*val))?val+1:val) < 5627) {
- buf += " <small><em>&lt;";
- for (tok = (!isdigit(*val))?val+1:val; *tok; tok++)
- buf += *tok;
- buf += "&gt;</em></small> ";
- }
- }
- valto = val;
- num = strstr(token, "morph=\"x-Robinson:");
- if (num) {
- for (num+=18; ((*num) && (*num != '\"')); num++)
- *valto++ = *num;
- *valto = 0;
- // normal robinsons tense
- buf += " <small><em>(";
- for (tok = val; *tok; tok++)
- buf += *tok;
- buf += ")</em></small> ";
- }
- }
-
- else if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers
- buf += " <small><em>&lt;";
- for (tok = token + 2; *tok; tok++)
- buf += *tok;
- buf += "&gt;</em></small> ";
- }
-
- else if (!strncmp(token, "WTG", 3) || !strncmp(token, "WTH", 3)) { // strong's numbers tense
- buf += " <small><em>&lt;";
- for (tok = token + 3; *tok; tok++)
- if(*tok != '\"')
- buf += *tok;
- buf += ")</em></small> ";
- }
-
- else if (!strncmp(token, "RX", 2)) {
- buf += "<i>";
- for (tok = token + 3; *tok; tok++) {
- if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
- buf += *tok;
- }
- else {
- break;
- }
- }
- buf += "</i>";
- }
-
- else if (!strncmp(token, "RB", 2)) {
- buf += "<i>";
- u->hasFootnotePreTag = true;
- }
-
- else if (!strncmp(token, "RF", 2)) {
- if (u->hasFootnotePreTag) {
- u->hasFootnotePreTag = false;
- buf += "</i> ";
- }
- buf += "<font color=\"#800000\"><small> (";
- }
-
- else if (!strncmp(token, "FN", 2)) {
- buf += "<font face=\"";
- for (tok = token + 2; *tok; tok++)
- if(*tok != '\"')
- buf += *tok;
- buf += "\">";
- }
-
- else if (!strncmp(token, "CA", 2)) { // ASCII value
- buf += (char)atoi(&token[2]);
- }
-
- else {
- return false;
- }
- }
- return true;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/gbfhtmlhref.cpp b/src/modules/filters/gbfhtmlhref.cpp
deleted file mode 100644
index 4061150..0000000
--- a/src/modules/filters/gbfhtmlhref.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/***************************************************************************
- gbfhtmlhref.cpp - GBF to HTML filter with hrefs
- for strongs and morph tags
- -------------------
- begin : 2001-09-03
- copyright : 2001 by CrossWire Bible Society
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include <stdlib.h>
-#include <gbfhtmlhref.h>
-#include <swmodule.h>
-#include <utilxml.h>
-#include <versekey.h>
-#include <ctype.h>
-
-SWORD_NAMESPACE_START
-
-GBFHTMLHREF::GBFHTMLHREF() {
- setTokenStart("<");
- setTokenEnd(">");
-
- setTokenCaseSensitive(true);
-
- //addTokenSubstitute("Rf", ")</small></font>");
- addTokenSubstitute("FA", "<font color=\"#800000\">"); // for ASV footnotes to mark text
- addTokenSubstitute("Rx", "</a>");
- addTokenSubstitute("FI", "<i>"); // italics begin
- addTokenSubstitute("Fi", "</i>");
- addTokenSubstitute("FB", "<b>"); // bold begin
- addTokenSubstitute("Fb", "</b>");
- addTokenSubstitute("FR", "<font color=\"#FF0000\">"); // words of Jesus begin
- addTokenSubstitute("Fr", "</font>");
- addTokenSubstitute("FU", "<u>"); // underline begin
- addTokenSubstitute("Fu", "</u>");
- addTokenSubstitute("FO", "<cite>"); // Old Testament quote begin
- addTokenSubstitute("Fo", "</cite>");
- addTokenSubstitute("FS", "<sup>"); // Superscript begin// Subscript begin
- addTokenSubstitute("Fs", "</sup>");
- addTokenSubstitute("FV", "<sub>"); // Subscript begin
- addTokenSubstitute("Fv", "</sub>");
- addTokenSubstitute("TT", "<big>"); // Book title begin
- addTokenSubstitute("Tt", "</big>");
- addTokenSubstitute("PP", "<cite>"); // poetry begin
- addTokenSubstitute("Pp", "</cite>");
- addTokenSubstitute("Fn", "</font>"); // font end
- addTokenSubstitute("CL", "<br />"); // new line
- addTokenSubstitute("CM", "<!P><br />"); // paragraph <!P> is a non showing comment that can be changed in the front end to <P> if desired
- addTokenSubstitute("CG", ""); // ???
- addTokenSubstitute("CT", ""); // ???
- addTokenSubstitute("JR", "<div align=\"right\">"); // right align begin
- addTokenSubstitute("JC", "<div align=\"center\">"); // center align begin
- addTokenSubstitute("JL", "</div>"); // align end
-
-}
-
-
-bool GBFHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
- const char *tok;
- char val[128];
- char *valto;
- const char *num;
- MyUserData *u = (MyUserData *)userData;
-
- if (!substituteToken(buf, token)) {
- XMLTag tag(token);
- if (!strncmp(token, "w", 1)) {
- // OSIS Word (temporary until OSISRTF is done)
- valto = val;
- num = strstr(token, "lemma=\"x-Strongs:");
- if (num) {
- for (num+=17; ((*num) && (*num != '\"')); num++)
- *valto++ = *num;
- *valto = 0;
- if (atoi((!isdigit(*val))?val+1:val) < 5627) {
- buf += " <small><em>&lt;<a href=\"type=Strongs value=";
- for (tok = val; *tok; tok++)
- buf += *tok;
- buf += "\">";
- for (tok = (!isdigit(*val))?val+1:val; *tok; tok++)
- buf += *tok;
- buf += "</a>&gt;</em></small> ";
- //cout << buf;
-
- }
- /* forget these for now
- else {
- // verb morph
- sprintf(wordstr, "%03d", word-1);
- module->getEntryAttributes()["Word"][wordstr]["Morph"] = val;
- }
- */
- }
- valto = val;
- num = strstr(token, "morph=\"x-Robinson:");
- if (num) {
- for (num+=18; ((*num) && (*num != '\"')); num++)
- *valto++ = *num;
- *valto = 0;
- buf += " <small><em>(<a href=\"type=morph class=Robinson value=";
- for (tok = val; *tok; tok++)
- // normal robinsons tense
- buf += *tok;
- buf += "\">";
- for (tok = val; *tok; tok++)
- //if(*tok != '\"')
- buf += *tok;
- buf += "</a>)</em></small> ";
- }
- }
-
- else if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers
- buf += " <small><em>&lt;<a href=\"type=Strongs value=";
- for (tok = token+1; *tok; tok++)
- //if(token[i] != '\"')
- buf += *tok;
- buf += "\">";
- for (tok = token + 2; *tok; tok++)
- //if(token[i] != '\"')
- buf += *tok;
- buf += "</a>&gt;</em></small>";
- }
-
- else if (!strncmp(token, "WTG", 3) || !strncmp(token, "WTH", 3)) { // strong's numbers tense
- buf += " <small><em>(<a href=\"type=Strongs value=";
- for (tok = token + 2; *tok; tok++)
- if(*tok != '\"')
- buf += *tok;
- buf += "\">";
- for (tok = token + 3; *tok; tok++)
- if(*tok != '\"')
- buf += *tok;
- buf += "</a>)</em></small>";
- }
-
- else if (!strncmp(token, "WT", 2) && strncmp(token, "WTH", 3) && strncmp(token, "WTG", 3)) { // morph tags
- buf += " <small><em>(<a href=\"type=morph class=none value=";
- for (tok = token + 2; *tok; tok++)
- if(*tok != '\"')
- buf += *tok;
- buf += "\">";
- for (tok = token + 2; *tok; tok++)
- if(*tok != '\"')
- buf += *tok;
- buf += "</a>)</em></small>";
- }
-
- else if (!strcmp(tag.getName(), "RX")) {
- buf += "<a href=\"";
- for (tok = token + 3; *tok; tok++) {
- if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
- buf += *tok;
- }
- else {
- break;
- }
- }
- buf += "\">";
- }
- else if (!strcmp(tag.getName(), "RF")) {
- SWBuf type = tag.getAttribute("type");
- SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
- VerseKey *vkey;
- // see if we have a VerseKey * or descendant
- try {
- vkey = SWDYNAMIC_CAST(VerseKey, u->key);
- }
- catch ( ... ) { }
- if (vkey) {
- // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
- //char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
- buf.appendFormatted("<a href=\"noteID=%s.%c.%s\"><small><sup>*%c</sup></small></a> ", vkey->getText(), 'n', footnoteNumber.c_str(), 'n');
- }
- u->suspendTextPassThru = true;
- }
- else if (!strcmp(tag.getName(), "Rf")) {
- u->suspendTextPassThru = false;
- }
-/*
- else if (!strncmp(token, "RB", 2)) {
- buf += "<i> ";
- u->hasFootnotePreTag = true;
- }
-
- else if (!strncmp(token, "Rf", 2)) {
- buf += "&nbsp<a href=\"note=";
- buf += u->lastTextNode.c_str();
- buf += "\">";
- buf += "<small><sup>*n</sup></small></a>&nbsp";
- // let's let text resume to output again
- u->suspendTextPassThru = false;
- }
-
- else if (!strncmp(token, "RF", 2)) {
- if (u->hasFootnotePreTag) {
- u->hasFootnotePreTag = false;
- buf += "</i> ";
- }
- u->suspendTextPassThru = true;
- }
-*/
- else if (!strncmp(token, "FN", 2)) {
- buf += "<font face=\"";
- for (tok = token + 2; *tok; tok++)
- if(*tok != '\"')
- buf += *tok;
- buf += "\">";
- }
-
- else if (!strncmp(token, "CA", 2)) { // ASCII value
- buf += (char)atoi(&token[2]);
- }
-
- else {
- return false;
- }
- }
- return true;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/gbfmorph.cpp b/src/modules/filters/gbfmorph.cpp
deleted file mode 100644
index 996baf9..0000000
--- a/src/modules/filters/gbfmorph.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/******************************************************************************
- *
- * gbfmorph - SWFilter descendant to hide or show morph tags
- * in a GBF module.
- */
-
-
-#include <stdlib.h>
-#include <gbfmorph.h>
-#ifndef __GNUC__
-#else
-#include <unixstr.h>
-#endif
-
-SWORD_NAMESPACE_START
-
-const char oName[] = "Morphological Tags";
-const char oTip[] = "Toggles Morphological Tags On and Off if they exist";
-
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
-
-GBFMorph::GBFMorph() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
-}
-
-
-GBFMorph::~GBFMorph() {
-}
-
-
-char GBFMorph::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- if (!option) { // if we don't want morph tags
- const char *from;
- char token[2048]; // cheese. Fix.
- int tokpos = 0;
- bool intoken = false;
- int len;
- bool lastspace = false;
-
- SWBuf orig = text;
- from = orig.c_str();
-
- for (text = ""; *from; from++) {
- if (*from == '<') {
- intoken = true;
- tokpos = 0;
- token[0] = 0;
- token[1] = 0;
- token[2] = 0;
- continue;
- }
- if (*from == '>') { // process tokens
- intoken = false;
- if (*token == 'W' && token[1] == 'T') { // Morph
- if ((from[1] == ' ') || (from[1] == ',') || (from[1] == ';') || (from[1] == '.') || (from[1] == '?') || (from[1] == '!') || (from[1] == ')') || (from[1] == '\'') || (from[1] == '\"')) {
- if (lastspace)
- text--;
- }
- continue;
- }
- // if not a morph tag token, keep token in text
- text += '<';
- text += token;
- text += '>';
- continue;
- }
- if (intoken) {
- if (tokpos < 2045)
- token[tokpos++] = *from;
- token[tokpos+2] = 0;
- }
- else {
- text += *from;
- lastspace = (*from == ' ');
- }
- }
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/gbfosis.cpp b/src/modules/filters/gbfosis.cpp
deleted file mode 100644
index b5dd8e1..0000000
--- a/src/modules/filters/gbfosis.cpp
+++ /dev/null
@@ -1,439 +0,0 @@
-/******************************************************************************
- *
- * gbfstrongs - SWFilter descendant to hide or show strongs number
- * in a GBF module.
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <gbfosis.h>
-#include <swmodule.h>
-#include <versekey.h>
-#include <swlog.h>
-#include <stdarg.h>
-#ifndef __GNUC__
-#else
-#include <unixstr.h>
-#endif
-
-SWORD_NAMESPACE_START
-
-GBFOSIS::GBFOSIS() {
-}
-
-
-GBFOSIS::~GBFOSIS() {
-}
-
-
-char GBFOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
-/*
- char *to, *from, token[2048]; // cheese. Fix.
- int tokpos = 0;
- bool intoken = false;
- int len;
- bool lastspace = false;
- int word = 1;
- char val[128];
- char buf[128];
- char wordstr[5];
- char *valto;
- char *ch;
- char *textStart, *textEnd;
- char *wordStart, *wordEnd;
- char *fromStart;
- bool newText = false;
- bool newWord = false;
- SWBuf tmp;
- bool suspendTextPassThru = false;
- bool keepToken = false;
- bool handled = false;
-
- 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;
-
- textStart = from;
- fromStart = from;
- wordStart = text;
-
- static QuoteStack quoteStack;
-
- // -------------------------------
-
- for (to = text; *from; from++) {
- if (*from == '<') {
- intoken = true;
- tokpos = 0;
- token[0] = 0;
- token[1] = 0;
- token[2] = 0;
- textEnd = from-1;
- wordEnd = to;
- continue;
- }
- if (*from == '>') { // process tokens
- intoken = false;
- keepToken = false;
- suspendTextPassThru = false;
- newWord = true;
- handled = false;
-
- while (wordStart < (text+maxlen)) {
-// if (strchr(" ,;.?!()'\"", *wordStart))
- if (strchr(";, .:?!()'\"", *wordStart) && wordStart[0] && wordStart[1])
- wordStart++;
- else break;
- }
- while (wordEnd > wordStart) {
- if (strchr(" ,;.:?!()'\"", *wordEnd))
- wordEnd--;
- else break;
- }
-
- // Scripture Reference
- if (!strncmp(token, "scripRef", 8)) {
- // pushString(buf, "<reference work=\"Bible.KJV\" reference=\"");
- suspendTextPassThru = true;
- newText = true;
- handled = true;
- }
- else if (!strncmp(token, "/scripRef", 9)) {
- tmp = "";
- tmp.append(textStart, (int)(textEnd - textStart)+1);
- pushString(&to, convertToOSIS(tmp.c_str(), key));
- lastspace = false;
- suspendTextPassThru = false;
- handled = true;
- }
-
- // Footnote
- if (!strcmp(token, "RF")) {
- // pushString(buf, "<reference work=\"Bible.KJV\" reference=\"");
- pushString(&to, "<note type=\"x-StudyNote\">");
- newText = true;
- lastspace = false;
- handled = true;
- }
- else if (!strcmp(token, "Rf")) {
- pushString(&to, "</note>");
- lastspace = false;
- handled = true;
- }
- // hebrew titles
- if (!strcmp(token, "TH")) {
- pushString(&to, "<title type=\"psalm\">");
- newText = true;
- lastspace = false;
- handled = true;
- }
- else if (!strcmp(token, "Th")) {
- pushString(&to, "</title>");
- lastspace = false;
- handled = true;
- }
- // Italics assume transchange
- if (!strcmp(token, "FI")) {
- pushString(&to, "<transChange type=\"added\">");
- newText = true;
- lastspace = false;
- handled = true;
- }
- else if (!strcmp(token, "Fi")) {
- pushString(&to, "</transChange>");
- lastspace = false;
- handled = true;
- }
- // Paragraph break. For now use empty paragraph element
- if (!strcmp(token, "CM")) {
- pushString(&to, "<milestone type=\"x-p\" />");
- newText = true;
- lastspace = false;
- handled = true;
- }
-
- // Figure
- else if (!strncmp(token, "img ", 4)) {
- const char *src = strstr(token, "src");
- if (!src) // assert we have a src attribute
- continue;
-// return false;
-
- pushString(&to, "<figure src=\"");
- const char *c;
- for (c = src;((*c) && (*c != '"')); c++);
-
-// uncomment for SWORD absolute path logic
-// if (*(c+1) == '/') {
-// pushString(buf, "file:");
-// pushString(buf, module->getConfigEntry("AbsoluteDataPath"));
-// if (*((*buf)-1) == '/')
-// c++; // skip '/'
-// }
-// end of uncomment for asolute path logic
-
- for (c++;((*c) && (*c != '"')); c++)
- *to++ = *c;
-
- pushString(&to, "\" />");
- lastspace = false;
- handled = true;
- }
-
- // Strongs numbers
- else if (*token == 'W' && (token[1] == 'G' || token[1] == 'H')) { // Strongs
- bool divineName = false;
- if (module->isProcessEntryAttributes()) {
- valto = val;
- for (unsigned int i = 1; ((token[i]) && (i < 150)); i++)
- *valto++ = token[i];
- *valto = 0;
- // normal strongs number
- strstrip(val);
- if (!strncmp(wordStart, "<w ", 3)) {
- strtok(wordStart, ">");
- char *attStart = strstr(wordStart, "lemma");
- if (attStart) {
- attStart += 7;
- sprintf(buf, "x-Strongs:%s|", val);
- }
- else {
- attStart = wordStart + 3;
- sprintf(buf, "lemma=\"x-Strongs:%s\" ", val);
- }
- wordStart[strlen(wordStart)] = '>';
- memmove(attStart+strlen(buf), attStart, (to-attStart)+1);
- memcpy(attStart, buf, strlen(buf));
- to+=strlen(buf);
- }
- else {
- if (!strcmp(val, "H03068")) { //divineName
- sprintf(buf, "<divineName><w lemma=\"x-Strongs:%s\">", val);
- divineName = true;
- }
- else sprintf(buf, "<w lemma=\"x-Strongs:%s\">", val);
-
- memmove(wordStart+strlen(buf), wordStart, (to-wordStart)+1);
- memcpy(wordStart, buf, strlen(buf));
- to+=strlen(buf);
-
- if (divineName) {
- wordStart += 12;
- pushString(&to, "</w></divineName>");
- }
- else pushString(&to, "</w>");
-
- module->getEntryAttributes()["Word"][wordstr]["Strongs"] = val;
- lastspace = false;
- }
- }
- handled = true;
- }
-
- // Morphology
- else if (*token == 'W' && token[1] == 'T' && (token[2] == 'G' || token[2] == 'H')) { // Strongs
- valto = val;
- for (unsigned int i = 1; ((token[i]) && (i < 150)); i++)
- *valto++ = token[i];
- *valto = 0;
- strstrip(val);
- if (!strncmp(wordStart, "<w ", 3)) {
- strtok(wordStart, ">");
- char *attStart = strstr(wordStart, "morph");
- if (attStart) {
- attStart += 7;
- sprintf(buf, "x-%s:%s|", "StrongsMorph", val);
- }
- else {
- attStart = wordStart + 3;
- sprintf(buf, "morph=\"x-%s:%s\" ", "StrongsMorph", val);
- }
- wordStart[strlen(wordStart)] = '>';
- memmove(attStart+strlen(buf), attStart, (to-attStart)+1);
- memcpy(attStart, buf, strlen(buf));
- to+=strlen(buf);
- }
- else {
- sprintf(buf, "<w morph=\"x-%s:%s\">", "StrongsMorph", val);
- memmove(wordStart+strlen(buf), wordStart, (to-wordStart)+1);
- memcpy(wordStart, buf, strlen(buf));
- to+=strlen(buf);
- pushString(&to, "</w>");
- lastspace = false;
- }
- handled = true;
- }
-
- if (!keepToken) {
- if (!handled) {
- SWLog::systemlog->LogError("Unprocessed Token: <%s>", token);
-// exit(-1);
- }
- if (from[1] && strchr(" ,;.:?!()'\"", from[1])) {
- if (lastspace)
- to--;
- }
- if (newText) {textStart = from+1; newText = false; }
-// if (newWord) {wordStart = to; newWord = false; }
- continue;
- }
- // if not a strongs token, keep token in text
- *to++ = '<';
- for (char *tok = token; *tok; tok++)
- *to++ = *tok;
- *to++ = '>';
- if (newText) {textStart = to; newWord = false; }
-// if (newWord) {wordStart = to; newWord = false; }
- continue;
- }
- if (intoken) {
- if ((tokpos < 2045) && ((*from != 10)&&(*from != 13))) {
- token[tokpos++] = *from;
- token[tokpos+2] = 0;
- }
- }
- else {
- switch (*from) {
- case '\'':
- case '\"':
- case '`':
-// quoteStack.handleQuote(fromStart, from, &to);
- *to++ = *from;
- from++;
- break;
- default:
- if (newWord && (*from != ' ')) {wordStart = to; newWord = false; memset(to, 0, 10); }
- if (!suspendTextPassThru) {
- *to++ = *from;
- lastspace = (*from == ' ');
- }
- }
- }
- }
-
- VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
- if (vkey) {
- char ref[254];
- if (vkey->Verse())
- sprintf(ref, "\t\t<verse osisID=\"%s\">", vkey->getOSISRef());
- else *ref = 0;
- if (*ref) {
- memmove(text+strlen(ref), text, maxlen-strlen(ref)-1);
- memcpy(text, ref, strlen(ref));
- to+=strlen(ref);
- if (vkey->Verse()) {
- VerseKey tmp;
- tmp = *vkey;
- tmp.AutoNormalize(0);
- tmp.Headings(1);
- sprintf(ref, "</verse>");
- pushString(&to, ref);
- tmp = MAXVERSE;
- if (*vkey == tmp) {
- tmp.Verse(0);
-// sprintf(ref, "\t</div>");
-// pushString(&to, ref);
- tmp = MAXCHAPTER;
- tmp = MAXVERSE;
- if (*vkey == tmp) {
- tmp.Chapter(0);
- tmp.Verse(0);
-// sprintf(ref, "\t</div>");
-// pushString(&to, ref);
- if (!quoteStack.empty()) {
- SWLog::systemlog->LogError("popping unclosed quote at end of book");
- quoteStack.clear();
- }
- }
- }
- }
-
-//
-// else if (vkey->Chapter()) {
-// sprintf(ref, "\t<div type=\"chapter\" osisID=\"%s\">", vkey->getOSISRef());
-// }
-// else sprintf(ref, "\t<div type=\"book\" osisID=\"%s\">", vkey->getOSISRef());
-//
- }
- }
- *to++ = 0;
- *to = 0;
-*/
- return 0;
-}
-
-
-const char *GBFOSIS::convertToOSIS(const char *inRef, const SWKey *key) {
- static SWBuf outRef;
-
- outRef = "";
-
- VerseKey defLanguage;
- ListKey verses = defLanguage.ParseVerseList(inRef, (*key), true);
- const char *startFrag = inRef;
- for (int i = 0; i < verses.Count(); i++) {
- VerseKey *element = SWDYNAMIC_CAST(VerseKey, verses.GetElement(i));
- char buf[5120];
- char frag[800];
- if (element) {
- memmove(frag, startFrag, ((const char *)element->userData - startFrag) + 1);
- frag[((const char *)element->userData - startFrag) + 1] = 0;
- startFrag = (const char *)element->userData + 1;
- sprintf(buf, "<reference osisRef=\"%s-%s\">%s</reference>", element->LowerBound().getOSISRef(), element->UpperBound().getOSISRef(), frag);
- }
- else {
- memmove(frag, startFrag, ((const char *)verses.GetElement(i)->userData - startFrag) + 1);
- frag[((const char *)verses.GetElement(i)->userData - startFrag) + 1] = 0;
- startFrag = (const char *)verses.GetElement(i)->userData + 1;
- sprintf(buf, "<reference osisRef=\"%s\">%s</reference>", VerseKey(*verses.GetElement(i)).getOSISRef(), frag);
- }
- outRef+=buf;
- }
- return outRef.c_str();
-}
-
-
-QuoteStack::QuoteStack() {
- clear();
-}
-
-
-void QuoteStack::clear() {
- while (!quotes.empty()) quotes.pop();
-}
-
-
-QuoteStack::~QuoteStack() {
- clear();
-}
-
-
-void QuoteStack::handleQuote(char *buf, char *quotePos, SWBuf &text) {
-//QuoteInstance(char startChar = '\"', char level = 1, string uniqueID = "", char continueCount = 0) {
- if (!quotes.empty()) {
- QuoteInstance last = quotes.top();
- if (last.startChar == *quotePos) {
- text += "</quote>";
- quotes.pop();
- }
- else {
- quotes.push(QuoteInstance(*quotePos, last.level+1));
- quotes.top().pushStartStream(text);
- }
- }
- else {
- quotes.push(QuoteInstance(*quotePos));
- quotes.top().pushStartStream(text);
- }
-}
-
-void QuoteStack::QuoteInstance::pushStartStream(SWBuf &text) {
- text.appendFormatted("<quote level=\"%d\">", level);
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/gbfplain.cpp b/src/modules/filters/gbfplain.cpp
deleted file mode 100644
index f519a25..0000000
--- a/src/modules/filters/gbfplain.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/******************************************************************************
- *
- * gbfplain - SWFilter descendant to strip out all GBF tags or convert to
- * ASCII rendered symbols.
- */
-
-
-#include <stdlib.h>
-#include <gbfplain.h>
-
-SWORD_NAMESPACE_START
-
-GBFPlain::GBFPlain() {
-}
-
-
-char GBFPlain::processText (SWBuf &text, const SWKey *key, const SWModule *module)
-{
- char token[2048];
- int tokpos = 0;
- bool intoken = false;
- const char *from;
- SWBuf orig = text;
- from = orig.c_str();
- for (text = ""; *from; from++) {
- if (*from == '<') {
- intoken = true;
- tokpos = 0;
- token[0] = 0;
- token[1] = 0;
- token[2] = 0;
- continue;
- }
- if (*from == '>') {
- intoken = false;
- // process desired tokens
- switch (*token) {
- case 'W': // Strongs
- switch(token[1]) {
- case 'G': // Greek
- case 'H': // Hebrew
- case 'T': // Tense
- text += " <";
- for (char *tok = token + 2; *tok; tok++)
- text += *tok;
- text += "> ";
- continue;
- }
- break;
- case 'R':
- switch(token[1]) {
- case 'F': // footnote begin
- text += " [";
- continue;
- case 'f': // footnote end
- text += "] ";
- continue;
- }
- break;
- case 'C':
- switch(token[1]) {
- case 'A': // ASCII value
- text += (char)atoi(&token[2]);
- continue;
- case 'G':
- text += ">";
- continue;
-/* Bug in WEB
- case 'L':
- *to++ = '<';
- continue;
-*/
- case 'L': // Bug in WEB. Use above entry when fixed
- case 'N': // new line
- text += '\n';
- continue;
- case 'M': // new paragraph
- text += "\n\n";
- continue;
- }
- break;
- }
- continue;
- }
- if (intoken) {
- if (tokpos < 2045)
- token[tokpos++] = *from;
- token[tokpos+2] = 0;
- }
- else text += *from;
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/gbfredletterwords.cpp b/src/modules/filters/gbfredletterwords.cpp
deleted file mode 100644
index df7438d..0000000
--- a/src/modules/filters/gbfredletterwords.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/******************************************************************************
- *
- * GBFRedLetterWords - SWFilter descendant to toggle red coloring of words of
- * Christ in a GBF module.
- */
-
-
-#include <stdlib.h>
-#include <gbfredletterwords.h>
-#include <swmodule.h>
-#ifndef __GNUC__
-#else
-#include <unixstr.h>
-#endif
-#include <ctype.h>
-
-SWORD_NAMESPACE_START
-
-const char oName[] = "Words of Christ in Red";
-const char oTip[] = "Toggles Red Coloring for Words of Christ On and Off if they are marked";
-
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
-
-GBFRedLetterWords::GBFRedLetterWords() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
-}
-
-
-GBFRedLetterWords::~GBFRedLetterWords() {
-}
-
-
-char GBFRedLetterWords::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
-/** This function removes the red letter words in Bible like the WEB
-* The words are marked by <FR> as start and <Fr> as end tag.
-*/
- if (!option) { // if we don't want footnotes
- char token[4096]; // cheese. Fix.
- int tokpos = 0;
- bool intoken = false;
- int len;
- bool hide = false;
-
- const char *from;
- SWBuf orig = text;
- from = orig.c_str();
- for (text = ""; *from; from++) {
- if (*from == '<') {
- intoken = true;
- tokpos = 0;
-// memset(token, 0, 4096);
- token[0] = 0;
- token[1] = 0;
- token[2] = 0;
- continue;
- }
- if (*from == '>') { // process tokens
- intoken = false;
- /*switch (*token) {
- case 'F': // Font attribute
- switch(token[1]) {
- case 'R': // Begin red letter words
- hide = true;
- break;
- case 'r': // end red letter words
- hide = false;
- break;
- }
- continue; // skip token
- }*/
-
- //hide the token if either FR or Fr was detected
- hide = (token[0] == 'F' && ( (token[1] == 'R') || (token[1] == 'r') ));
-
- // if not a red letter word token, keep token in text
- if (!hide) {
- text += '<';
- for (char *tok = token; *tok; tok++)
- text += *tok;
- text += '>';
- }
- continue;
- }
- if (intoken) {
- if (tokpos < 4090)
- token[tokpos++] = *from;
- token[tokpos+2] = 0; // +2 cuz we init token with 2 extra '0' because of switch statement
- }
- else {
- text += *from;
- }
- }
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/gbfrtf.cpp b/src/modules/filters/gbfrtf.cpp
deleted file mode 100644
index 4a18fbf..0000000
--- a/src/modules/filters/gbfrtf.cpp
+++ /dev/null
@@ -1,289 +0,0 @@
-/******************************************************************************
- *
- * gbfrtf - SWFilter descendant to convert all GBF tags to RTF tags
- */
-
-
-#include <gbfrtf.h>
-#include <ctype.h>
-
-SWORD_NAMESPACE_START
-
-GBFRTF::GBFRTF() {
-}
-
-
-char GBFRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module)
-{
- char token[2048];
- char val[128];
- char *valto;
- char *num;
- int tokpos = 0;
- bool intoken = false;
- int len;
- const char *tok;
- SWBuf strongnum;
- SWBuf strongtense;
- bool hideText = false;
- int wordLen = 0;
- int wordCount = 0;
- int i;
-
- const char *from;
- SWBuf orig = text;
- from = orig.c_str();
- for (text = ""; *from; from++) {
- if (*from == '<') {
- wordLen = wordCount;
- wordCount = 0;
- intoken = true;
- tokpos = 0;
- token[0] = 0;
- token[1] = 0;
- token[2] = 0;
- continue;
- }
- if (*from == '>') {
- intoken = false;
- // process desired tokens
- // deal with OSIS note tags. Just hide till OSISRTF
- if (!strncmp(token, "note ", 5)) {
- hideText = true;
- }
- if (!strncmp(token, "/note", 5)) {
- hideText = false;
- }
-
- switch (*token) {
- case 'w': // OSIS Word (temporary until OSISRTF is done)
- strongnum = "";
- strongtense = "";
- valto = val;
- num = strstr(token, "lemma=\"x-Strongs:");
- if (num) {
- for (num+=17; ((*num) && (*num != '\"')); num++)
- *valto++ = *num;
- *valto = 0;
- if (atoi((!isdigit(*val))?val+1:val) < 5627) {
- // normal strongs number
- strongnum += "{\\cf3 \\sub <";
- for (tok = (!isdigit(*val))?val+1:val; *tok; tok++)
- strongnum += *tok;
- strongnum += ">}";
- }
- /* forget these for now
- else {
- // verb morph
- sprintf(wordstr, "%03d", word-1);
- module->getEntryAttributes()["Word"][wordstr]["Morph"] = val;
- }
- */
- }
- valto = val;
- num = strstr(token, "morph=\"x-Robinson:");
- if (num) {
- for (num+=18; ((*num) && (*num != '\"')); num++)
- *valto++ = *num;
- *valto = 0;
- // normal robinsons tense
- strongtense += "{\\cf4 \\sub (";
- for (tok = val; *tok; tok++)
- strongtense += *tok;
- strongtense += ")}";
- }
- continue;
-
- case '/':
- if (token[1] == 'w') {
- if ((wordCount > 0) || (strongnum != "{\\cf3 \\sub <3588>}")) {
- //for (i = 0; i < strongnum.length(); i++)
- text += strongnum;
- //for (i = 0; i < strongtense.length(); i++)
- text += strongtense;
- }
- }
- continue;
-
- case 'W': // Strongs
- switch(token[1]) {
- case 'G': // Greek
- case 'H': // Hebrew
- text += "{\\cf3 \\sub <";
- for (tok = token + 2; *tok; tok++)
- text += *tok;
- text += ">}";
- continue;
-
- case 'T': // Tense
- text += "{\\cf4 \\sub (";
- bool separate = false;
- for (tok = token + 2; *tok; tok++) {
- if (separate) {
- text += "; ";
- separate = false;
- }
- switch (*tok) {
- case 'G':
- case 'H':
- for (tok++; *tok; tok++) {
- if (isdigit(*tok)) {
- text += *tok;
- separate = true;
- }
- else {
- tok--;
- break;
- }
- }
- break;
- default:
- for (; *tok; tok++) {
- text += *tok;
- }
- }
- }
- text += ")}";
- continue;
- }
- break;
- case 'R':
- switch(token[1]) {
- case 'X':
- text += "<a href=\"\">";
- continue;
- case 'x':
- text += "</a>";
- continue;
- case 'F': // footnote begin
- text += "{\\i1 \\sub (";
- continue;
- case 'f': // footnote end
- text += ") }";
- continue;
- }
- break;
- case 'F': // font tags
- switch(token[1]) {
- case 'I': // italic start
- text += "\\i1 ";
- continue;
- case 'i': // italic end
- text += "\\i0 ";
- continue;
- case 'B': // bold start
- text += "\\b1 ";
- continue;
- case 'b': // bold end
- text += "\\b0 ";
- continue;
- case 'N':
- text += '{';
- if (!strnicmp(token+2, "Symbol", 6))
- text += "\\f7 ";
- if (!strnicmp(token+2, "Courier", 7))
- text += "\\f8 ";
- continue;
- case 'n':
- text += '}';
- continue;
- case 'S':
- text += "{\\super ";
- continue;
- case 's':
- text += '}';
- continue;
- case 'R':
- text += "{\\cf6 ";
- continue;
- case 'r':
- text += '}';
- continue;
- case 'O':
- case 'C':
- text += "\\scaps1 ";
- continue;
- case 'o':
- case 'c':
- text += "\\scaps0 ";
- continue;
- case 'V':
- text += "{\\sub ";
- continue;
- case 'v':
- text += '}';
- continue;
- case 'U':
- text += "\\ul1 ";
- continue;
- case 'u':
- text += "\\ul0 ";
- continue;
- }
- break;
- case 'C': // special character tags
- switch(token[1]) {
- case 'A': // ASCII value
- text += (char)atoi(&token[2]);
- continue;
- case 'G':
- text += '>';
- continue;
- case 'L': // line break
- text += "\\line ";
- continue;
- case 'M': // new paragraph
- text += "\\par ";
- continue;
- case 'T':
- text += '<';
- }
- break;
- case 'T': // title formatting
- switch(token[1])
- {
- case 'T': // Book title begin
- text += "{\\large ";
- continue;
- case 't':
- text += '}';
- continue;
- case 'S':
- text += "\\par {\\i1\\b1 ";
- continue;
- case 's':
- text += "}\\par ";
- continue;
- }
- break;
- case 'J': // Strongs
- switch(token[1]) {
- case 'L':
- text += "\\ql ";
- case 'C':
- text += "\\qc ";
- case 'R':
- text += "\\qr ";
- case 'F':
- text += "\\qj ";
- }
- }
- continue;
- }
- if (intoken) {
- if (tokpos < 2045)
- token[tokpos++] = *from;
- token[tokpos+2] = 0;
- }
- else {
- if (!hideText) {
- wordCount++;
- text += *from;
- }
- }
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
-
diff --git a/src/modules/filters/gbfstrongs.cpp b/src/modules/filters/gbfstrongs.cpp
deleted file mode 100644
index bd5088a..0000000
--- a/src/modules/filters/gbfstrongs.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/******************************************************************************
- *
- * gbfstrongs - SWFilter descendant to hide or show strongs number
- * in a GBF module.
- */
-
-
-#include <stdlib.h>
-#include <gbfstrongs.h>
-#include <swmodule.h>
-#ifndef __GNUC__
-#else
-#include <unixstr.h>
-#endif
-#include <ctype.h>
-
-SWORD_NAMESPACE_START
-
-const char oName[] = "Strong's Numbers";
-const char oTip[] = "Toggles Strong's Numbers On and Off if they exist";
-
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
-
-GBFStrongs::GBFStrongs() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
-}
-
-
-GBFStrongs::~GBFStrongs() {
-}
-
-
-char GBFStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- char token[2048]; // cheese. Fix.
- int tokpos = 0;
- bool intoken = false;
- int len;
- bool lastspace = false;
- int word = 1;
- char val[128];
- char wordstr[5];
- char *valto;
- char *ch;
- unsigned int textStart = 0, textEnd = 0;
- bool newText = false;
- SWBuf tmp;
- const char *from;
-
- SWBuf orig = text;
- from = orig.c_str();
-
- for (text = ""; *from; from++) {
- if (*from == '<') {
- intoken = true;
- tokpos = 0;
- token[0] = 0;
- token[1] = 0;
- token[2] = 0;
- textEnd = text.size();
- continue;
- }
- if (*from == '>') { // process tokens
- intoken = false;
-
- if (*token == 'W' && (token[1] == 'G' || token[1] == 'H')) { // Strongs
- if (module->isProcessEntryAttributes()) {
- valto = val;
- for (unsigned int i = 2; ((token[i]) && (i < 150)); i++)
- *valto++ = token[i];
- *valto = 0;
- if (atoi((!isdigit(*val))?val+1:val) < 5627) {
- // normal strongs number
- sprintf(wordstr, "%03d", word++);
- module->getEntryAttributes()["Word"][wordstr]["Strongs"] = val;
- tmp = "";
- tmp.append(text.c_str()+textStart, (int)(textEnd - textStart));
- module->getEntryAttributes()["Word"][wordstr]["Text"] = tmp;
- newText = true;
- }
- else {
- // verb morph
- sprintf(wordstr, "%03d", word-1);
- module->getEntryAttributes()["Word"][wordstr]["Morph"] = val;
- }
- }
- if (!option) {
- if ((from[1] == ' ') || (from[1] == ',') || (from[1] == ';') || (from[1] == '.') || (from[1] == '?') || (from[1] == '!') || (from[1] == ')') || (from[1] == '\'') || (from[1] == '\"')) {
- if (lastspace)
- text--;
- }
- if (newText) {textStart = text.size(); newText = false; }
- continue;
- }
- }
- // if not a strongs token, keep token in text
- text += '<';
- text += token;
- text += '>';
- if (newText) {textStart = text.size(); newText = false; }
- continue;
- }
- if (intoken) {
- if (tokpos < 2045)
- token[tokpos++] = *from;
- token[tokpos+2] = 0;
- }
- else {
- text += *from;
- lastspace = (*from == ' ');
- }
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/gbfthml.cpp b/src/modules/filters/gbfthml.cpp
deleted file mode 100644
index 03b8d8a..0000000
--- a/src/modules/filters/gbfthml.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/***************************************************************************
- gbfthml.cpp - GBF to ThML filter
- -------------------
- begin : 1999-10-27
- copyright : 2001 by CrossWire Bible Society
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include <stdlib.h>
-#include <gbfthml.h>
-
-SWORD_NAMESPACE_START
-
-GBFThML::GBFThML()
-{
-}
-
-
-char GBFThML::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- const char *from;
- char token[2048];
- int tokpos = 0;
- bool intoken = false;
- int len;
- const char *tok;
-
- SWBuf orig = text;
- from = orig.c_str();
-
- for (text = ""; *from; from++) {
- if (*from == '<') {
- intoken = true;
- tokpos = 0;
- token[0] = 0;
- token[1] = 0;
- token[2] = 0;
- continue;
- }
- if (*from == '>')
- {
- intoken = false;
- // process desired tokens
- switch (*token) {
- case 'W': // Strongs
- switch(token[1]) {
- case 'G':
- case 'H':
- text += "<sync type=\"Strongs\" value=\"";
- for (tok = token + 1; *tok; tok++)
- text += *tok;
- text += "\" />";
- continue;
-
- case 'T': // Tense
- text += "<sync type=\"Morph\" value=\"";
- for (tok = token + 2; *tok; tok++)
- text += *tok;
- text += "\" />";
- continue;
- }
- break;
- case 'R':
- switch(token[1])
- {
- case 'X':
- text += "<a href=\"";
- for (tok = token + 3; *tok; tok++) {
- if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
- text += *tok;
- }
- else {
- break;
- }
- }
- text += "\">";
- continue;
- case 'x':
- text += "</a>";
- continue;
- case 'F': // footnote begin
- text += "<note>";
- continue;
- case 'f': // footnote end
- text += "</note>";
- continue;
- }
- break;
- case 'F': // font tags
- switch(token[1])
- {
- case 'N':
- text += "<font face=\"";
- for (tok = token + 2; *tok; tok++)
- text += *tok;
- text += "\">";
- continue;
- case 'n':
- text += "</font>";
- continue;
- case 'I': // italic start
- text += "<i>";
- continue;
- case 'i': // italic end
- text += "</i>";
- continue;
- case 'B': // bold start
- text += "<b>";
- continue;
- case 'b': // bold end
- text += "</b>";
- continue;
-
- case 'R': // words of Jesus begin
- text += "<font color=\"#ff0000\">";
- continue;
- case 'r': // words of Jesus end
- text += "</font>";
- continue;
- case 'U': // Underline start
- text += "<u>";
- continue;
- case 'u': // Underline end
- text += "</u>";
- continue;
- case 'O': // Old Testament quote begin
- text += "<cite>";
- continue;
- case 'o': // Old Testament quote end
- text += "</cite>";
- continue;
- case 'S': // Superscript begin
- text += "<sup>";
- continue;
- case 's': // Superscript end
- text += "</sup>";
- continue;
- case 'V': // Subscript begin
- text += "<sub>";
- continue;
- case 'v': // Subscript end
- text += "</sub>";
- continue;
- }
- break;
- case 'C': // special character tags
- switch(token[1])
- {
- case 'A': // ASCII value
- text += (char)atoi(&token[2]);
- continue;
- case 'G':
- //*to++ = ' ';
- continue;
- case 'L': // line break
- text += "<br /> ";
- continue;
- case 'M': // new paragraph
- text += "<p />";
- continue;
- case 'T':
- //*to++ = ' ';
- continue;
- }
- break;
- case 'T': // title formatting
- switch(token[1])
- {
- case 'T': // Book title begin
- text += "<big>";
- continue;
- case 't':
- text += "</big>";
- continue;
- case 'S':
- text += "<div class=\"sechead\">";
- continue;
- case 's':
- text += "</div>";
- continue;
- }
- break;
-
- case 'P': // special formatting
- switch(token[1]) {
- case 'P': // Poetry begin
- text += "<verse>";
- continue;
- case 'p':
- text += "</verse>";
- continue;
- }
- break;
- }
- continue;
- }
- if (intoken) {
- if (tokpos < 2045)
- token[tokpos++] = *from;
- token[tokpos+2] = 0;
- }
- else text += *from;
- }
- return 0;
-}
-
-
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/gbfwebif.cpp b/src/modules/filters/gbfwebif.cpp
deleted file mode 100644
index 131f359..0000000
--- a/src/modules/filters/gbfwebif.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/***************************************************************************
- GBFWEBIF.cpp - GBF to HTML filter with hrefs
- for strongs and morph tags
- -------------------
- begin : 2001-09-03
- copyright : 2001 by CrossWire Bible Society
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include <gbfwebif.h>
-#include <ctype.h>
-#include <utilweb.h>
-
-SWORD_NAMESPACE_START
-
-GBFWEBIF::GBFWEBIF() : baseURL(""), passageStudyURL(baseURL + "passagestudy.jsp") {
-//all is done in GBFHTMLHREF since it inherits form this class
- addTokenSubstitute("FR", "<span class=\"wordsOfJesus\">"); // words of Jesus begin
- addTokenSubstitute("Fr", "</span>");
-}
-
-bool GBFWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
- const char *tok;
- char val[128];
- char *valto;
- const char *num;
- SWBuf url;
-
- if (!substituteToken(buf, token)) {
- if (!strncmp(token, "w", 1)) {
- // OSIS Word (temporary until OSISRTF is done)
- valto = val;
- num = strstr(token, "lemma=\"x-Strongs:");
-
- if (num) {
- for (num+=17; ((*num) && (*num != '\"')); num++)
- *valto++ = *num;
- *valto = 0;
-
- if (atoi((!isdigit(*val))?val+1:val) < 5627) {
- buf += " <small><em>&lt;";
- url = "";
- for (tok = val; *tok; tok++) {
- url += *tok;
- }
- if ((url.length() > 1) && strchr("GH", url[0])) {
- if (isdigit(url[1]))
- url = url.c_str()+1;
- }
- buf.appendFormatted("<a href=\"%s?showStrong=%s#cv\">", passageStudyURL.c_str(), encodeURL(url).c_str());
-
- for (tok = (!isdigit(*val))?val+1:val; *tok; tok++) {
- buf += *tok;
- }
- buf += "</a>&gt;</em></small> ";
- }
- }
- valto = val;
- num = strstr(token, "morph=\"x-Robinson:");
- if (num) {
- for (num+=18; ((*num) && (*num != '\"')); num++)
- *valto++ = *num;
- *valto = 0;
- buf += " <small><em>(";
- url = "";
- for (tok = val; *tok; tok++) {
- // normal robinsons tense
- buf += *tok;
- }
- buf.appendFormatted("<a href=\"%s?showMorph=%s#cv\">", passageStudyURL.c_str(), encodeURL(url).c_str());
-
- for (tok = val; *tok; tok++) {
- buf += *tok;
- }
- buf += "</a>)</em></small> ";
- }
- }
-
- else if (!strncmp(token, "WG", 2) || !strncmp(token, "WH", 2)) { // strong's numbers
- buf += " <small><em>&lt;";
- url = "";
-
- for (tok = token+1; *tok; tok++) {
- url += *tok;
- }
- if ((url.length() > 1) && strchr("GH", url[0])) {
- if (isdigit(url[1]))
- url = url.c_str()+1;
- }
- buf.appendFormatted("<a href=\"%s?showStrong=%s#cv\">", passageStudyURL.c_str(), encodeURL(url).c_str());
-
- for (tok = token + 2; *tok; tok++) {
- buf += *tok;
- }
- buf += "</a>&gt;</em></small>";
- }
-
- else if (!strncmp(token, "WTG", 3) || !strncmp(token, "WTH", 3)) { // strong's numbers tense
- buf += " <small><em>(";
- url = "";
- for (tok = token + 2; *tok; tok++) {
- if(*tok != '\"')
- url += *tok;
- }
- if ((url.length() > 1) && strchr("GH", url[0])) {
- if (isdigit(url[1]))
- url = url.c_str()+1;
- }
- buf.appendFormatted("<a href=\"%s?showStrong=%s#cv\">", passageStudyURL.c_str(), encodeURL(url).c_str());
-
- for (tok = token + 3; *tok; tok++)
- if(*tok != '\"')
- buf += *tok;
- buf += "</a>)</em></small>";
- }
-
- else if (!strncmp(token, "WT", 2) && strncmp(token, "WTH", 3) && strncmp(token, "WTG", 3)) { // morph tags
- buf += " <small><em>(";
- for (tok = token + 2; *tok; tok++) {
- if(*tok != '\"')
- buf += *tok;
- }
- buf.appendFormatted("<a href=\"%s?showMorph=%s#cv\">", passageStudyURL.c_str(), encodeURL(url).c_str());
-
- for (tok = token + 2; *tok; tok++) {
- if(*tok != '\"')
- buf += *tok;
- }
- buf += "</a>)</em></small>";
- }
-
- else if (!strncmp(token, "RX", 2)) {
- buf += "<a href=\"";
- for (tok = token + 3; *tok; tok++) {
- if(*tok != '<' && *tok+1 != 'R' && *tok+2 != 'x') {
- buf += *tok;
- }
- else {
- break;
- }
- }
-
- buf.appendFormatted("a href=\"%s?key=%s#cv\">", passageStudyURL.c_str(), encodeURL(url).c_str());
- }
-
- else {
- return GBFHTMLHREF::handleToken(buf, token, userData);
- }
- }
- return true;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/greeklexattribs.cpp b/src/modules/filters/greeklexattribs.cpp
deleted file mode 100644
index 073ba39..0000000
--- a/src/modules/filters/greeklexattribs.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/******************************************************************************
- *
- * greeklexattribs - SWFilter descendant to set entry attributes for greek
- * lexicons
- */
-
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <string>
-#include <greeklexattribs.h>
-#include <swmodule.h>
-
-using std::string;
-
-SWORD_NAMESPACE_START
-
-GreekLexAttribs::GreekLexAttribs() {
-}
-
-
-char GreekLexAttribs::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
-
- if (module->isProcessEntryAttributes()) {
- const char *from;
- bool inAV = false;
- string phrase;
- string freq;
- char val[128], *valto;
- char wordstr[7];
- const char *currentPhrase = 0, *ch = 0;
- const char *currentPhraseEnd = 0;
- int number = 0;
-
-
- for (from = text.c_str(); *from; from++) {
- if (inAV) {
- if (currentPhrase == 0) {
- if (isalpha(*from))
- currentPhrase = from;
- }
- else {
- if ((!isalpha(*from)) && (*from != ' ') && (*from != '+') && (*from !='(') && (*from != ')') && (*from != '\'')) {
- if (*from == '<') {
- if (!currentPhraseEnd)
- currentPhraseEnd = from - 1;
- for (; *from && *from != '>'; from++) {
- if (!strncmp(from, "value=\"", 7)) {
- valto = val;
- from += 7;
- for (unsigned int i = 0; from[i] != '\"' && i < 127; i++)
- *valto++ = from[i];
- *valto = 0;
- sprintf(wordstr, "%03d", number+1);
- module->getEntryAttributes()["AVPhrase"][wordstr]["CompoundedWith"] = val;
- from += strlen(val);
- }
- }
- continue;
- }
-
- phrase = "";
- phrase.append(currentPhrase, (int)(((currentPhraseEnd>currentPhrase)?currentPhraseEnd:from) - currentPhrase)-1);
- currentPhrase = from;
- while (*from && isdigit(*from)) from++;
- freq = "";
- freq.append(currentPhrase, (int)(from - currentPhrase));
- if ((freq.length() > 0) && (phrase.length() > 0)) {
- sprintf(wordstr, "%03d", ++number);
- if ((strchr(phrase.c_str(), '(') > phrase.c_str()) && (strchr(phrase.c_str(), ')') > phrase.c_str() + 1)) {
- string tmp = phrase.substr(0, phrase.find_first_of("("));
- phrase.erase(phrase.find_first_of("("), 1);
- phrase.erase(phrase.find_first_of(")"), 1);
- phrase.erase(0,phrase.find_first_not_of("\r\n\v\t ")); phrase.erase(phrase.find_last_not_of("\r\n\v\t ")+1);
- module->getEntryAttributes()["AVPhrase"][wordstr]["Alt"] = phrase.c_str();
- phrase = tmp;
- }
- phrase.erase(0,phrase.find_first_not_of("\r\n\v\t ")); phrase.erase(phrase.find_last_not_of("\r\n\v\t ")+1);
- freq.erase(0,freq.find_first_not_of("\r\n\v\t ")); freq.erase(freq.find_last_not_of("\r\n\v\t ")+1);
- module->getEntryAttributes()["AVPhrase"][wordstr]["Phrase"] = phrase.c_str();
- module->getEntryAttributes()["AVPhrase"][wordstr]["Frequency"] = freq.c_str();
- currentPhrase = 0;
- currentPhraseEnd = 0;
- }
- }
- }
- if (*from == ';') inAV = false;
-
- }
- else if (!strncmp(from, "AV-", 3)) {
- inAV = true;
- from+=2;
- }
- }
- }
- return 0;
-}
-
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/latin1utf16.cpp b/src/modules/filters/latin1utf16.cpp
deleted file mode 100644
index 8067381..0000000
--- a/src/modules/filters/latin1utf16.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/******************************************************************************
- *
- * Latin1UTF16 - SWFilter descendant to convert a Latin-1 character to UTF-16
- *
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <latin1utf16.h>
-
-SWORD_NAMESPACE_START
-
-Latin1UTF16::Latin1UTF16() {
-}
-
-
-char Latin1UTF16::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- const unsigned char *from;
- int len;
- if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
- return -1;
-
-
- SWBuf orig = text;
- from = (const unsigned char *)orig.c_str();
-
- for (text = ""; *from; from++) {
- text.setSize(text.size()+2);
- switch (*from) {
- case 0x80: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x20AC;
- break;
- case 0x82: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x201A;
- break;
- case 0x83: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x0192;
- break;
- case 0x84: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x201E;
- break;
- case 0x85: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x2026;
- break;
- case 0x86: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x2020;
- break;
- case 0x87: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x2021;
- break;
- case 0x88: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x02C6;
- break;
- case 0x89: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x2030;
- break;
- case 0x8A: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x0160;
- break;
- case 0x8B: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x2039;
- break;
- case 0x8C: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x0152;
- break;
- case 0x8E: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x017D;
- break;
- case 0x91: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x2018;
- break;
- case 0x92: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x2019;
- break;
- case 0x93: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x201C;
- break;
- case 0x94: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x201D;
- break;
- case 0x95: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x2022;
- break;
- case 0x96: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x2013;
- break;
- case 0x97: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x2014;
- break;
- case 0x98: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x02DC;
- break;
- case 0x99: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x2122;
- break;
- case 0x9A: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x0161;
- break;
- case 0x9B: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x203A;
- break;
- case 0x9C: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x0153;
- break;
- case 0x9E: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x017E;
- break;
- case 0x9F: // ''
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) 0x0178;
- break;
- default:
- *((unsigned short *)(text.getRawData()+(text.size()-2))) = (unsigned short) *from;
- }
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/latin1utf8.cpp b/src/modules/filters/latin1utf8.cpp
deleted file mode 100644
index 6d7d87b..0000000
--- a/src/modules/filters/latin1utf8.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-/******************************************************************************
- *
- * Latin1UTF8 - SWFilter descendant to convert a Latin-1 character to UTF-8
- *
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <latin1utf8.h>
-#include <swmodule.h>
-
-SWORD_NAMESPACE_START
-
-Latin1UTF8::Latin1UTF8() {
-}
-
-
-char Latin1UTF8::processText(SWBuf &text, const SWKey *key, const SWModule *module)
-{
- const unsigned char *from;
-
- if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
- return -1;
-
- SWBuf orig = text;
- from = (const unsigned char *)orig.c_str();
-
- for (text = ""; *from; from++) {
- if (*from < 0x80) {
- text += *from;
- }
- else if (*from < 0xc0) {
- switch(*from) {
- case 0x80: // ''
- text += 0xe2; // ''
- text += 0x82; // ''
- text += 0xac; // ''
- break;
- case 0x82: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0x9a; // ''
- break;
- case 0x83: // ''
- text += 0xc6; // ''
- text += 0x92; // ''
- break;
- case 0x84: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0x9e; // ''
- break;
- case 0x85: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0xa6; // ''
- break;
- case 0x86: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0xa0; // ''
- break;
- case 0x87: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0xa1; // ''
- break;
- case 0x88: // ''
- text += 0xcb; // ''
- text += 0x86; // ''
- break;
- case 0x89: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0xb0; // ''
- break;
- case 0x8A: // ''
- text += 0xc5; // ''
- text += 0xa0; // ''
- break;
- case 0x8B: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0xb9; // ''
- break;
- case 0x8C: // ''
- text += 0xc5; // ''
- text += 0x92; // ''
- break;
- case 0x8E: // ''
- text += 0xc5; // ''
- text += 0xbd; // ''
- break;
- case 0x91: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0x98; // ''
- break;
- case 0x92: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0x99; // ''
- break;
- case 0x93: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0x9c; // ''
- break;
- case 0x94: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0x9d; // ''
- break;
- case 0x95: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0xa2; // ''
- break;
- case 0x96: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0x93; // ''
- break;
- case 0x97: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0x94; // ''
- break;
- case 0x98: // ''
- text += 0xcb; // ''
- text += 0x9c; // ''
- break;
- case 0x99: // ''
- text += 0xe2; // ''
- text += 0x84; // ''
- text += 0xa2; // ''
- break;
- case 0x9A: // ''
- text += 0xc5; // ''
- text += 0xa1; // ''
- break;
- case 0x9B: // ''
- text += 0xe2; // ''
- text += 0x80; // ''
- text += 0xba; // ''
- break;
- case 0x9C: // ''
- text += 0xc5; // ''
- text += 0x93; // ''
- break;
- case 0x9E: // ''
- text += 0xc5; // ''
- text += 0xbe; // ''
- break;
- case 0x9F: // ''
- text += 0xc5; // ''
- text += 0xb8; // ''
- break;
- default:
- text += 0xC2;
- text += *from;
- }
- }
- else {
- text += 0xC3;
- text += (*from - 0x40);
- }
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/osisfootnotes.cpp b/src/modules/filters/osisfootnotes.cpp
deleted file mode 100644
index 59a7cae..0000000
--- a/src/modules/filters/osisfootnotes.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/******************************************************************************
- *
- * osisfootnotes - SWFilter descendant to hide or show footnotes
- * in an OSIS module.
- */
-
-
-#include <stdlib.h>
-#include <osisfootnotes.h>
-#include <swmodule.h>
-#include <swbuf.h>
-#include <versekey.h>
-#include <utilxml.h>
-#ifndef __GNUC__
-#else
-#include <unixstr.h>
-#endif
-
-SWORD_NAMESPACE_START
-
-const char oName[] = "Footnotes";
-const char oTip[] = "Toggles Footnotes On and Off if they exist";
-
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
-
-OSISFootnotes::OSISFootnotes() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
-}
-
-
-OSISFootnotes::~OSISFootnotes() {
-}
-
-
-char OSISFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- SWBuf token;
- bool intoken = false;
- bool hide = false;
- SWBuf tagText;
- XMLTag startTag;
- SWBuf refs = "";
- int footnoteNum = 1;
- char buf[254];
- VerseKey parser = key->getText();
-
- SWBuf orig = text;
- const char *from = orig.c_str();
-
- for (text = ""; *from; from++) {
-
- // remove all newlines temporarily to fix kjv2003 module
- if ((*from == 10) || (*from == 13)) {
- if ((text.length()>1) && (text[text.length()-2] != ' ') && (*(from+1) != ' '))
- text += ' ';
- continue;
- }
-
-
- if (*from == '<') {
- intoken = true;
- token = "";
- continue;
- }
- if (*from == '>') { // process tokens
- intoken = false;
-
- XMLTag tag(token);
- if (!strcmp(tag.getName(), "note")) {
- if (!tag.isEndTag()) {
- if (SWBuf("strongsMarkup") == tag.getAttribute("type")) { // handle bug in KJV2003 module where some note open tags were <note ... />
- tag.setEmpty(false);
- }
- if (!tag.isEmpty()) {
-// if ((!tag.isEmpty()) || (SWBuf("strongsMarkup") == tag.getAttribute("type"))) {
- refs = "";
- startTag = tag;
- hide = true;
- tagText = "";
- continue;
- }
- }
- if (hide && tag.isEndTag()) {
- if (module->isProcessEntryAttributes()) {
- sprintf(buf, "%i", footnoteNum++);
- StringList attributes = startTag.getAttributeNames();
- for (StringList::iterator it = attributes.begin(); it != attributes.end(); it++) {
- module->getEntryAttributes()["Footnote"][buf][it->c_str()] = startTag.getAttribute(it->c_str());
- }
- module->getEntryAttributes()["Footnote"][buf]["body"] = tagText;
- startTag.setAttribute("swordFootnote", buf);
- if ((startTag.getAttribute("type")) && (!strcmp(startTag.getAttribute("type"), "crossReference"))) {
- if (!refs.length())
- refs = parser.ParseVerseList(tagText.c_str(), parser, true).getRangeText();
- module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str();
- }
- }
- hide = false;
- if ((option) || ((startTag.getAttribute("type") && (!strcmp(startTag.getAttribute("type"), "crossReference"))))) { // we want the tag in the text; crossReferences are handled by another filter
- text += startTag;
- text.append(tagText);
- }
- else continue;
- }
- }
-
- // if not a heading token, keep token in text
- if ((!strcmp(tag.getName(), "reference")) && (!tag.isEndTag())) {
- SWBuf osisRef = tag.getAttribute("osisRef");
- if (refs.length())
- refs += "; ";
- refs += osisRef;
- }
- if (!hide) {
- text += '<';
- text.append(token);
- text += '>';
- }
- else {
- tagText += '<';
- tagText.append(token);
- tagText += '>';
- }
- continue;
- }
- if (intoken) { //copy token
- token += *from;
- }
- else if (!hide) { //copy text which is not inside a token
- text += *from;
- }
- else tagText += *from;
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
-
diff --git a/src/modules/filters/osisheadings.cpp b/src/modules/filters/osisheadings.cpp
deleted file mode 100644
index 8ec9ce3..0000000
--- a/src/modules/filters/osisheadings.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/******************************************************************************
- *
- *osisheadings - SWFilter descendant to hide or show headings
- * in an OSIS module.
- */
-
-
-#include <stdlib.h>
-#include <osisheadings.h>
-#include <swmodule.h>
-#include <utilxml.h>
-#ifndef __GNUC__
-#else
-#include <unixstr.h>
-#endif
-
-SWORD_NAMESPACE_START
-
-const char oName[] = "Headings";
-const char oTip[] = "Toggles Headings On and Off if they exist";
-
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
-
-OSISHeadings::OSISHeadings() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
-}
-
-
-OSISHeadings::~OSISHeadings() {
-}
-
-
-char OSISHeadings::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- SWBuf token;
- bool intoken = false;
- bool hide = false;
- bool preverse = false;
- SWBuf header;
- int headerNum = 0;
- int pvHeaderNum = 0;
- char buf[254];
-
- SWBuf orig = text;
- const char *from = orig.c_str();
-
- for (text = ""; *from; from++) {
- if (*from == '<') {
- intoken = true;
- token = "";
- continue;
- }
- if (*from == '>') { // process tokens
- intoken = false;
-
- XMLTag tag(token);
- if (!stricmp(tag.getName(), "title")) {
- if ((tag.getAttribute("subtype")) && (!stricmp(tag.getAttribute("subtype"), "x-preverse"))) {
- hide = true;
- preverse = true;
- header = "";
- continue;
- }
- if (!tag.isEndTag()) {
- hide = true;
- header = "";
- if (option) { // we want the tag in the text
- text += '<';
- text.append(token);
- text += '>';
- }
- continue;
- }
- if (hide && tag.isEndTag()) {
-
- if (module->isProcessEntryAttributes() && option) {
- if (preverse) {
- sprintf(buf, "%i", pvHeaderNum++);
- module->getEntryAttributes()["Heading"]["Preverse"][buf] = header;
- }
- else {
- sprintf(buf, "%i", headerNum++);
- module->getEntryAttributes()["Heading"]["Interverse"][buf] = header;
- if (option) { // we want the tag in the text
- text.append(header);
- }
- }
- }
- hide = false;
- if ((!option) || (preverse)) { // we don't want the tag in the text anymore
- preverse = false;
- continue;
- }
- preverse = false;
- }
- }
-
- // if not a heading token, keep token in text
- if (!hide) {
- text += '<';
- text.append(token);
- text += '>';
- }
- continue;
- }
- if (intoken) { //copy token
- token += *from;
- }
- else if (!hide) { //copy text which is not inside a token
- text += *from;
- }
- else header += *from;
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
-
diff --git a/src/modules/filters/osishtmlhref.cpp b/src/modules/filters/osishtmlhref.cpp
deleted file mode 100644
index 26e6dff..0000000
--- a/src/modules/filters/osishtmlhref.cpp
+++ /dev/null
@@ -1,339 +0,0 @@
-/***************************************************************************
- osishtmlhref.cpp - OSIS to HTML with hrefs filter
- -------------------
- begin : 2003-06-24
- copyright : 2003 by CrossWire Bible Society
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include <stdlib.h>
-#include <osishtmlhref.h>
-#include <utilxml.h>
-#include <versekey.h>
-#include <swmodule.h>
-
-SWORD_NAMESPACE_START
-
-
-OSISHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
- osisQToTick = ((!module->getConfigEntry("OSISqToTick")) || (strcmp(module->getConfigEntry("OSISqToTick"), "false")));
-}
-
-
-OSISHTMLHREF::OSISHTMLHREF() {
- setTokenStart("<");
- setTokenEnd(">");
-
- setEscapeStart("&");
- setEscapeEnd(";");
-
- setEscapeStringCaseSensitive(true);
-
- addEscapeStringSubstitute("amp", "&");
- addEscapeStringSubstitute("apos", "'");
- addEscapeStringSubstitute("lt", "<");
- addEscapeStringSubstitute("gt", ">");
- addEscapeStringSubstitute("quot", "\"");
- addTokenSubstitute("lg", "<br />");
- addTokenSubstitute("/lg", "<br />");
-
- setTokenCaseSensitive(true);
-}
-
-
-bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
- // manually process if it wasn't a simple substitution