summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/frontend/X11/Makefile5
-rw-r--r--src/frontend/framework/femain.cpp11
-rw-r--r--src/frontend/im/hebrewmcim.cpp24
-rw-r--r--src/frontend/im/nullim.cpp9
-rw-r--r--src/frontend/im/swinputmeth.cpp21
-rw-r--r--src/frontend/swdisp.cpp20
-rw-r--r--src/frontend/swlog.cpp13
-rw-r--r--src/frontend/windoze/Makefile5
-rw-r--r--src/keys/genarray.c50
-rw-r--r--src/keys/listkey.cpp75
-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.cpp10
-rw-r--r--src/keys/swkey.cpp24
-rw-r--r--src/keys/treekey.cpp8
-rw-r--r--src/keys/treekeyidx.cpp12
-rw-r--r--src/keys/versekey.cpp772
-rw-r--r--src/keys/versetreekey.cpp50
-rw-r--r--src/mgr/Makefile.am4
-rw-r--r--src/mgr/curlftpt.cpp150
-rw-r--r--src/mgr/curlhttpt.cpp142
-rw-r--r--src/mgr/encfiltmgr.cpp150
-rw-r--r--src/mgr/filemgr.cpp19
-rw-r--r--src/mgr/ftplibftpt.cpp126
-rw-r--r--src/mgr/installmgr.cpp118
-rw-r--r--src/mgr/localemgr.cpp17
-rw-r--r--src/mgr/markupfiltmgr.cpp442
-rw-r--r--src/mgr/remotetrans.cpp (renamed from src/mgr/ftptrans.cpp)65
-rw-r--r--src/mgr/stringmgr.cpp125
-rw-r--r--src/mgr/swcacher.cpp13
-rw-r--r--src/mgr/swconfig.cpp14
-rw-r--r--src/mgr/swfiltermgr.cpp12
-rw-r--r--src/mgr/swlocale.cpp24
-rw-r--r--src/mgr/swmgr.cpp179
-rw-r--r--src/mgr/swsearchable.cpp17
-rw-r--r--src/mgr/versificationmgr.cpp (renamed from src/mgr/versemgr.cpp)145
-rw-r--r--src/modules/comments/hrefcom/hrefcom.cpp14
-rw-r--r--src/modules/comments/rawcom/rawcom.cpp39
-rw-r--r--src/modules/comments/rawcom4/Makefile5
-rw-r--r--src/modules/comments/rawcom4/rawcom4.cpp39
-rw-r--r--src/modules/comments/rawfiles/rawfiles.cpp58
-rw-r--r--src/modules/comments/swcom.cpp30
-rw-r--r--src/modules/comments/zcom/zcom.cpp47
-rw-r--r--src/modules/common/Makefile.am4
-rw-r--r--src/modules/common/bz2comprs.cpp181
-rw-r--r--src/modules/common/compress.cpp.txt767
-rw-r--r--src/modules/common/entriesblk.cpp9
-rw-r--r--src/modules/common/lzsscomprs.cpp120
-rw-r--r--src/modules/common/lzsscomprs.txt (renamed from src/modules/common/swcomprs.doc)0
-rw-r--r--src/modules/common/rawstr.cpp22
-rw-r--r--src/modules/common/rawstr4.cpp24
-rw-r--r--src/modules/common/rawverse.cpp13
-rw-r--r--src/modules/common/rawverse4.cpp17
-rw-r--r--src/modules/common/sapphire.cpp48
-rw-r--r--src/modules/common/swcipher.cpp8
-rw-r--r--src/modules/common/swcomprs.cpp7
-rw-r--r--src/modules/common/xzcomprs.cpp181
-rw-r--r--src/modules/common/zipcomprs.cpp8
-rw-r--r--src/modules/common/zstr.cpp27
-rw-r--r--src/modules/common/zverse.cpp38
-rw-r--r--src/modules/filters/Makefile.am14
-rw-r--r--src/modules/filters/cipherfil.cpp11
-rw-r--r--src/modules/filters/gbffootnotes.cpp28
-rw-r--r--src/modules/filters/gbfheadings.cpp29
-rw-r--r--src/modules/filters/gbfhtml.cpp12
-rw-r--r--src/modules/filters/gbfhtmlhref.cpp22
-rw-r--r--src/modules/filters/gbfmorph.cpp26
-rw-r--r--src/modules/filters/gbfosis.cpp22
-rw-r--r--src/modules/filters/gbfplain.cpp11
-rw-r--r--src/modules/filters/gbfredletterwords.cpp26
-rw-r--r--src/modules/filters/gbfrtf.cpp7
-rw-r--r--src/modules/filters/gbfstrongs.cpp26
-rw-r--r--src/modules/filters/gbfthml.cpp13
-rw-r--r--src/modules/filters/gbfwebif.cpp17
-rw-r--r--src/modules/filters/gbfwordjs.cpp43
-rw-r--r--src/modules/filters/gbfxhtml.cpp236
-rw-r--r--src/modules/filters/greeklexattribs.cpp7
-rw-r--r--src/modules/filters/latin1utf16.cpp7
-rw-r--r--src/modules/filters/latin1utf8.cpp12
-rw-r--r--src/modules/filters/osisenum.cpp99
-rw-r--r--src/modules/filters/osisfootnotes.cpp29
-rw-r--r--src/modules/filters/osisglosses.cpp (renamed from src/modules/filters/osisruby.cpp)192
-rw-r--r--src/modules/filters/osisheadings.cpp228
-rw-r--r--src/modules/filters/osishtmlhref.cpp157
-rw-r--r--src/modules/filters/osislemma.cpp28
-rw-r--r--src/modules/filters/osismorph.cpp27
-rw-r--r--src/modules/filters/osismorphsegmentation.cpp27
-rw-r--r--src/modules/filters/osisosis.cpp24
-rw-r--r--src/modules/filters/osisplain.cpp64
-rw-r--r--src/modules/filters/osisredletterwords.cpp25
-rw-r--r--src/modules/filters/osisreferencelinks.cpp114
-rw-r--r--src/modules/filters/osisrtf.cpp25
-rw-r--r--src/modules/filters/osisscripref.cpp26
-rw-r--r--src/modules/filters/osisstrongs.cpp29
-rw-r--r--src/modules/filters/osisvariants.cpp82
-rw-r--r--src/modules/filters/osiswebif.cpp60
-rw-r--r--src/modules/filters/osiswordjs.cpp34
-rw-r--r--src/modules/filters/osisxhtml.cpp772
-rw-r--r--src/modules/filters/osisxlit.cpp99
-rw-r--r--src/modules/filters/papyriplain.cpp6
-rw-r--r--src/modules/filters/plainfootnotes.cpp85
-rw-r--r--src/modules/filters/plainhtml.cpp89
-rw-r--r--src/modules/filters/rtfhtml.cpp38
-rw-r--r--src/modules/filters/scsuutf8.cpp246
-rw-r--r--src/modules/filters/swbasicfilter.cpp28
-rw-r--r--src/modules/filters/swoptfilter.cpp9
-rw-r--r--src/modules/filters/teihtmlhref.cpp22
-rw-r--r--src/modules/filters/teiplain.cpp10
-rw-r--r--src/modules/filters/teirtf.cpp416
-rw-r--r--src/modules/filters/teixhtml.cpp290
-rw-r--r--src/modules/filters/thmlfootnotes.cpp30
-rw-r--r--src/modules/filters/thmlgbf.cpp9
-rw-r--r--src/modules/filters/thmlheadings.cpp26
-rw-r--r--src/modules/filters/thmlhtml.cpp11
-rw-r--r--src/modules/filters/thmlhtmlhref.cpp34
-rw-r--r--src/modules/filters/thmllemma.cpp26
-rw-r--r--src/modules/filters/thmlmorph.cpp25
-rw-r--r--src/modules/filters/thmlosis.cpp22
-rw-r--r--src/modules/filters/thmlplain.cpp7
-rw-r--r--src/modules/filters/thmlrtf.cpp17
-rw-r--r--src/modules/filters/thmlscripref.cpp32
-rw-r--r--src/modules/filters/thmlstrongs.cpp26
-rw-r--r--src/modules/filters/thmlvariants.cpp59
-rw-r--r--src/modules/filters/thmlwebif.cpp14
-rw-r--r--src/modules/filters/thmlwordjs.cpp43
-rw-r--r--src/modules/filters/thmlxhtml.cpp378
-rw-r--r--src/modules/filters/unicodertf.cpp6
-rw-r--r--src/modules/filters/utf16utf8.cpp10
-rw-r--r--src/modules/filters/utf8arabicpoints.cpp174
-rw-r--r--src/modules/filters/utf8arshaping.cpp9
-rw-r--r--src/modules/filters/utf8bidireorder.cpp15
-rw-r--r--src/modules/filters/utf8cantillation.cpp26
-rw-r--r--src/modules/filters/utf8greekaccents.cpp29
-rw-r--r--src/modules/filters/utf8hebrewpoints.cpp30
-rw-r--r--src/modules/filters/utf8html.cpp14
-rw-r--r--src/modules/filters/utf8latin1.cpp11
-rw-r--r--src/modules/filters/utf8nfc.cpp7
-rw-r--r--src/modules/filters/utf8nfkd.cpp12
-rw-r--r--src/modules/filters/utf8transliterator.cpp126
-rw-r--r--src/modules/filters/utf8utf16.cpp8
-rw-r--r--src/modules/genbook/rawgenbook/rawgenbook.cpp22
-rw-r--r--src/modules/genbook/swgenbook.cpp17
-rw-r--r--src/modules/lexdict/rawld/rawld.cpp28
-rw-r--r--src/modules/lexdict/rawld4/rawld4.cpp27
-rw-r--r--src/modules/lexdict/swld.cpp30
-rw-r--r--src/modules/lexdict/zld/zld.cpp28
-rw-r--r--src/modules/readme9
-rw-r--r--src/modules/swmodule.cpp454
-rw-r--r--src/modules/tests/echomod.cpp10
-rw-r--r--src/modules/texts/rawtext/rawtext.cpp49
-rw-r--r--src/modules/texts/rawtext4/Makefile5
-rw-r--r--src/modules/texts/rawtext4/rawtext4.cpp54
-rw-r--r--src/modules/texts/swtext.cpp31
-rw-r--r--src/modules/texts/ztext/ztext.cpp59
-rw-r--r--src/utilfuns/Makefile.am1
-rw-r--r--src/utilfuns/ftplib.c63
-rw-r--r--src/utilfuns/roman.cpp13
-rw-r--r--src/utilfuns/swbuf.cpp50
-rw-r--r--src/utilfuns/swobject.cpp45
-rw-r--r--src/utilfuns/swunicod.cpp138
-rw-r--r--src/utilfuns/swversion.cpp18
-rw-r--r--src/utilfuns/url.cpp90
-rw-r--r--src/utilfuns/utilstr.cpp217
-rw-r--r--src/utilfuns/utilxml.cpp18
-rw-r--r--src/utilfuns/zlib/untgz.c27
167 files changed, 6901 insertions, 4364 deletions
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/femain.cpp b/src/frontend/framework/femain.cpp
index e6580cb..11bf565 100644
--- a/src/frontend/framework/femain.cpp
+++ b/src/frontend/framework/femain.cpp
@@ -1,5 +1,10 @@
-/*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+/******************************************************************************
+ *
+ * femain.cpp - FEMain class definition
+ *
+ * $Id: femain.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -23,7 +28,7 @@ FEMain::FEMain() {
FEMain::~FEMain() {
list <SWDisplay *>::iterator it;
- for (it = displays.begin(); it != displays.end(); it++)
+ for (it = displays.begin(); it != displays.end(); ++it)
delete *it;
}
diff --git a/src/frontend/im/hebrewmcim.cpp b/src/frontend/im/hebrewmcim.cpp
index c8bb5fa..839fcd7 100644
--- a/src/frontend/im/hebrewmcim.cpp
+++ b/src/frontend/im/hebrewmcim.cpp
@@ -1,14 +1,15 @@
-
-/**
- * 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
- */
-
-/*
+/******************************************************************************
+ *
+ * hebrewmcim.cpp - HebrewMCIM: Keyboard mapping for Michigan-Claremont
+ * Hebrew input
+ *
+ * $Id: hebrewmcim.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2.
@@ -20,7 +21,6 @@
*
*/
-
#include <hebrewmcim.h>
HebrewMCIM::HebrewMCIM()
diff --git a/src/frontend/im/nullim.cpp b/src/frontend/im/nullim.cpp
index bceeb23..6fd9c0e 100644
--- a/src/frontend/im/nullim.cpp
+++ b/src/frontend/im/nullim.cpp
@@ -1,5 +1,10 @@
-/*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+/******************************************************************************
+ *
+ * nullim.cpp - NullIM: Null keyboard mapping
+ *
+ * $Id: nullim.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/frontend/im/swinputmeth.cpp b/src/frontend/im/swinputmeth.cpp
index 7ba60dd..49a7833 100644
--- a/src/frontend/im/swinputmeth.cpp
+++ b/src/frontend/im/swinputmeth.cpp
@@ -1,13 +1,14 @@
-/**
- * Title:
- * Description:
- * Copyright: Copyright (c) 2001 CrossWire Bible Society under the terms of the GNU GPL
- * Company:
- * @author Troy A. Griffitts
- * @version 1.0
- */
-
-/*
+/******************************************************************************
+ *
+ * swinputmeth.cpp - SWInputMethod: Input method base class
+ *
+ * $Id: swinputmeth.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2.
diff --git a/src/frontend/swdisp.cpp b/src/frontend/swdisp.cpp
index bf46ff2..268fe7d 100644
--- a/src/frontend/swdisp.cpp
+++ b/src/frontend/swdisp.cpp
@@ -1,8 +1,12 @@
/******************************************************************************
- * swdisp.cpp - code for base class 'swdisp'. swdisp is the basis for all
- * types of displays (e.g. raw textout, curses, xwindow, etc.)
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * swdisp.cpp - code for base class 'SWDisplay'. SWDisplay is the
+ * basis for all types of displays (e.g. raw textout,
+ * curses, xwindow, etc.)
+ *
+ * $Id: swdisp.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -19,9 +23,6 @@
*/
-#ifndef _WIN32_WCE
-#include <iostream>
-#endif
#include <swmodule.h>
#include <swdisp.h>
@@ -40,12 +41,5 @@ SWClass SWDisplay::classdef(classes);
* RET: error status
*/
-char SWDisplay::Display(SWModule &imodule)
-{
-#ifndef _WIN32_WCE
- std::cout << (const char *)imodule;
-#endif
- return 0;
-}
SWORD_NAMESPACE_END
diff --git a/src/frontend/swlog.cpp b/src/frontend/swlog.cpp
index 74b6bd4..7c05b47 100644
--- a/src/frontend/swlog.cpp
+++ b/src/frontend/swlog.cpp
@@ -1,5 +1,10 @@
-/*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+/******************************************************************************
+ *
+ * swlog.cpp -
+ *
+ * $Id: swlog.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -15,8 +20,6 @@
*
*/
-//---------------------------------------------------------------------------
-
#include <stdarg.h>
#include <stdio.h>
#include <iostream>
@@ -26,7 +29,7 @@
#include <unicode/ustream.h>
#endif
#include "swlog.h"
-//---------------------------------------------------------------------------
+
SWORD_NAMESPACE_START
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/genarray.c b/src/keys/genarray.c
deleted file mode 100644
index 112b0f6..0000000
--- a/src/keys/genarray.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
- * CrossWire Bible Society
- * P. O. Box 2528
- * Tempe, AZ 85280-2528
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- */
-
-#include <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, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
- 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
index 1b718cb..4c017d2 100644
--- a/src/keys/listkey.cpp
+++ b/src/keys/listkey.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
- * 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.)
*
+ * 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.)
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: listkey.cpp 2905 2013-07-17 12:18:15Z scribe $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -40,7 +42,7 @@ SWClass ListKey::classdef(classes);
ListKey::ListKey(const char *ikey): SWKey(ikey) {
arraymax = 0;
- ClearList();
+ clear();
init();
}
@@ -74,12 +76,12 @@ SWKey *ListKey::clone() const
ListKey::~ListKey()
{
- ClearList();
+ clear();
}
/******************************************************************************
- * ListKey::ClearList - Clears out elements of list
+ * ListKey::clear - Clears out elements of list
*/
void ListKey::clear()
@@ -106,7 +108,7 @@ void ListKey::clear()
*/
void ListKey::copyFrom(const ListKey &ikey) {
- ClearList();
+ clear();
arraymax = ikey.arraymax;
arraypos = ikey.arraypos;
@@ -115,7 +117,7 @@ void ListKey::copyFrom(const ListKey &ikey) {
for (int i = 0; i < arraycnt; i++)
array[i] = ikey.array[i]->clone();
- SetToElement(0);
+ setToElement(0);
}
@@ -129,7 +131,7 @@ void ListKey::add(const SWKey &ikey) {
arraymax = arraycnt + 32;
}
array[arraycnt-1] = ikey.clone();
- SetToElement(arraycnt-1);
+ setToElement(arraycnt-1);
}
@@ -145,10 +147,10 @@ void ListKey::add(const SWKey &ikey) {
void ListKey::setPosition(SW_POSITION p) {
switch (p) {
case 1: // GCC won't compile P_TOP
- SetToElement(0, p);
+ setToElement(0, p);
break;
case 2: // GCC won't compile P_BOTTOM
- SetToElement(arraycnt-1, p);
+ setToElement(arraycnt-1, p);
break;
}
}
@@ -163,13 +165,13 @@ void ListKey::increment(int step) {
decrement(step*-1);
return;
}
- Error(); // clear error
- for(; step && !Error(); step--) {
+ popError(); // clear error
+ for(; step && !popError(); step--) {
if (arraypos < arraycnt && arraycnt) {
if (array[arraypos]->isBoundSet())
(*(array[arraypos]))++;
- if ((array[arraypos]->Error()) || (!array[arraypos]->isBoundSet())) {
- SetToElement(arraypos+1);
+ if ((array[arraypos]->popError()) || (!array[arraypos]->isBoundSet())) {
+ setToElement(arraypos+1);
}
else SWKey::setText((const char *)(*array[arraypos]));
}
@@ -187,13 +189,13 @@ void ListKey::decrement(int step) {
increment(step*-1);
return;
}
- Error(); // clear error
- for(; step && !Error(); step--) {
+ popError(); // clear error
+ for(; step && !popError(); step--) {
if (arraypos > -1 && arraycnt) {
if (array[arraypos]->isBoundSet())
(*(array[arraypos]))--;
- if ((array[arraypos]->Error()) || (!array[arraypos]->isBoundSet())) {
- SetToElement(arraypos-1, BOTTOM);
+ if ((array[arraypos]->popError()) || (!array[arraypos]->isBoundSet())) {
+ setToElement(arraypos-1, BOTTOM);
}
else SWKey::setText((const char *)(*array[arraypos]));
}
@@ -203,23 +205,24 @@ void ListKey::decrement(int step) {
/******************************************************************************
- * ListKey::Count - Returns number of elements in list
+ * ListKey::getCount - Returns number of elements in list
*/
-int ListKey::Count() {
+int ListKey::getCount() const {
return arraycnt;
}
/******************************************************************************
- * ListKey::SetToElement - Sets key to element number
+ * ListKey::setToElement - Sets key to element number
*
* ENT: ielement - element number to set to
+ * pos - set the subkey element to position (TOP) or BOTTOM
*
* RET: error status
*/
-char ListKey::SetToElement(int ielement, SW_POSITION pos) {
+char ListKey::setToElement(int ielement, SW_POSITION pos) {
arraypos = ielement;
if (arraypos >= arraycnt) {
arraypos = (arraycnt>0)?arraycnt - 1:0;
@@ -247,14 +250,14 @@ char ListKey::SetToElement(int ielement, SW_POSITION pos) {
/******************************************************************************
- * ListKey::GetElement - Gets a key element number
+ * 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) {
+const SWKey *ListKey::getElement(int pos) const {
if (pos < 0)
pos = arraypos;
@@ -263,20 +266,26 @@ SWKey *ListKey::getElement(int pos) {
return (error) ? 0:array[pos];
}
+
+SWKey *ListKey::getElement(int pos) {
+ const ListKey &self = *this;
+ return const_cast<SWKey *>(self.getElement(pos));
+}
+
/******************************************************************************
- * ListKey::Remove - Removes current element from list
+ * ListKey::remove - Removes current element from list
*/
-void ListKey::Remove() {
+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);
+ setToElement((arraypos)?arraypos-1:0);
}
}
@@ -327,6 +336,12 @@ const char *ListKey::getText() const {
return (key) ? key->getText() : keytext;
}
+const char *ListKey::getShortText() const {
+ int pos = arraypos;
+ SWKey *key = (pos >= arraycnt || !arraycnt) ? 0:array[pos];
+ return (key) ? key->getShortText() : keytext;
+}
+
void ListKey::setText(const char *ikey) {
// at least try to set the current element to this text
@@ -335,7 +350,7 @@ void ListKey::setText(const char *ikey) {
if (key) {
if (key->isTraversable() && key->isBoundSet()) {
key->setText(ikey);
- if (!key->Error())
+ if (!key->popError())
break;
}
else {
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
index 4171e36..0b5a2cb 100644
--- a/src/keys/strkey.cpp
+++ b/src/keys/strkey.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
- * StrKey.cpp - code for class 'StrKey'- a standard string key class (used
- * for modules that index on single strings (eg. cities,
- * names, words, etc.)
*
+ * strkey.cpp - code for class 'StrKey'- a standard string key class
+ * (used for modules that index on single strings (eg.
+ * cities, names, words, etc.)
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: strkey.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/keys/swkey.cpp b/src/keys/swkey.cpp
index 3709cdc..8e40004 100644
--- a/src/keys/swkey.cpp
+++ b/src/keys/swkey.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
- * swkey.cpp - code for base class 'SWKey'. SWKey is the basis for all
- * types of keys for indexing into modules (e.g. verse, word,
+ *
+ * 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.)
*
+ * $Id: swkey.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -95,7 +97,7 @@ SWKey::~SWKey() {
* RET: value of persist
*/
-char SWKey::Persist() const
+bool SWKey::isPersist() const
{
return persist;
}
@@ -126,20 +128,14 @@ SWLocale *SWKey::getPrivateLocale() const {
/******************************************************************************
* 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
+ * (true - persists in module; false - a copy is attempted
*
* ENT: ipersist - value which to set persist
- * [-1] - only get
- *
- * RET: value of persist
*/
-char SWKey::Persist(signed char ipersist)
+void SWKey::setPersist(bool ipersist)
{
- if (ipersist != -1)
- persist = ipersist;
-
- return persist;
+ persist = ipersist;
}
@@ -149,7 +145,7 @@ char SWKey::Persist(signed char ipersist)
* RET: error status
*/
-char SWKey::Error()
+char SWKey::popError()
{
char retval = error;
diff --git a/src/keys/treekey.cpp b/src/keys/treekey.cpp
index ce769a1..a466da6 100644
--- a/src/keys/treekey.cpp
+++ b/src/keys/treekey.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * versekey.h - code for class 'versekey'- a standard Biblical verse key
*
- * $Id: treekey.cpp 2178 2008-06-20 15:10:47Z scribe $
+ * treekey.cpp - code for class 'versekey'- a standard Biblical
+ * verse key
*
- * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: treekey.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/keys/treekeyidx.cpp b/src/keys/treekeyidx.cpp
index cc93fc0..5164277 100644
--- a/src/keys/treekeyidx.cpp
+++ b/src/keys/treekeyidx.cpp
@@ -1,9 +1,10 @@
/******************************************************************************
- * versekey.h - code for class 'versekey'- a standard Biblical verse key
*
- * $Id: treekeyidx.cpp 2280 2009-03-07 15:34:36Z scribe $
+ * treekeyidx.cpp -
*
- * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: treekeyidx.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -32,7 +33,6 @@
SWORD_NAMESPACE_START
-static const char nl = '\n';
static const char *classes[] = {"TreeKeyIdx", "TreeKey", "SWKey", "SWObject", 0};
SWClass TreeKeyIdx::classdef(classes);
@@ -517,7 +517,7 @@ void TreeKeyIdx::setText(const char *ikey) {
SWBuf leaf = strtok(buf, "/");
leaf.trim();
root();
- while ((leaf.size()) && (!Error())) {
+ while ((leaf.size()) && (!popError())) {
bool ok, inChild = false;
error = KEYERR_OUTOFBOUNDS;
for (ok = firstChild(); ok; ok = nextSibling()) {
@@ -562,7 +562,7 @@ void TreeKeyIdx::setPosition(SW_POSITION p) {
break;
}
positionChanged();
- Error(); // clear error from normalize
+ popError(); // clear error from normalize
}
diff --git a/src/keys/versekey.cpp b/src/keys/versekey.cpp
index 9b75e97..6ce0858 100644
--- a/src/keys/versekey.cpp
+++ b/src/keys/versekey.cpp
@@ -1,8 +1,11 @@
/******************************************************************************
- * VerseKey.cpp - code for class 'VerseKey'- a standard Biblical verse key
*
+ * versekey.cpp - code for class 'VerseKey'- a standard Biblical
+ * verse key
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: versekey.cpp 2893 2013-07-16 03:07:02Z scribe $
+ *
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -32,7 +35,7 @@
#include <versekey.h>
#include <swlocale.h>
#include <roman.h>
-#include <versemgr.h>
+#include <versificationmgr.h>
SWORD_NAMESPACE_START
@@ -55,7 +58,7 @@ void VerseKey::init(const char *v11n) {
instance++;
autonorm = 1; // default auto normalization to true
- headings = 0; // default display headings option is false
+ intros = false; // default display intros option is false
upperBound = 0;
lowerBound = 0;
boundSet = false;
@@ -120,15 +123,19 @@ VerseKey::VerseKey(VerseKey const &k) : SWKey(k)
void VerseKey::setFromOther(const VerseKey &ikey) {
if (refSys == ikey.refSys) {
- testament = ikey.Testament();
- book = ikey.Book();
- chapter = ikey.Chapter();
- verse = ikey.Verse();
+ testament = ikey.getTestament();
+ book = ikey.getBook();
+ chapter = ikey.getChapter();
+ verse = ikey.getVerse();
suffix = ikey.getSuffix();
}
+ // TODO: versification mapping
// Here is where we will do v11n system conversions in the future
- // when we have a conversion mechanism (Ben Morgan has started
- // thinking about this)
+ // when we have a conversion mechanism
+ // Ben Morgan has started thinking about this
+ // Konstantin Maslyuk <kalemas@mail.ru> has submitted a patch)
+ // Asked Konstantin to try his patch out with his favorite
+ // SWORD frontend and report back how it goes. Need to follow up
else {
// For now, this is the best we can do
setText(ikey.getText());
@@ -154,12 +161,12 @@ void VerseKey::positionFrom(const SWKey &ikey) {
}
// should we always perform bounds checks? Tried but seems to cause infinite recursion
- if (_compare(UpperBound()) > 0) {
- setFromOther(UpperBound());
+ if (_compare(getUpperBound()) > 0) {
+ setFromOther(getUpperBound());
error = KEYERR_OUTOFBOUNDS;
}
- if (_compare(LowerBound()) < 0) {
- setFromOther(LowerBound());
+ if (_compare(getLowerBound()) < 0) {
+ setFromOther(getLowerBound());
error = KEYERR_OUTOFBOUNDS;
}
}
@@ -171,17 +178,17 @@ void VerseKey::positionFrom(const SWKey &ikey) {
void VerseKey::copyFrom(const VerseKey &ikey) {
autonorm = ikey.autonorm;
- headings = ikey.headings;
- testament = ikey.Testament();
- book = ikey.Book();
- chapter = ikey.Chapter();
- verse = ikey.Verse();
+ intros = ikey.intros;
+ testament = ikey.getTestament();
+ book = ikey.getBook();
+ chapter = ikey.getChapter();
+ verse = ikey.getVerse();
suffix = ikey.getSuffix();
setLocale(ikey.getLocale());
setVersificationSystem(ikey.getVersificationSystem());
if (ikey.isBoundSet()) {
- LowerBound(ikey.LowerBound());
- UpperBound(ikey.UpperBound());
+ setLowerBound(ikey.getLowerBound());
+ setUpperBound(ikey.getUpperBound());
}
}
@@ -213,15 +220,15 @@ void VerseKey::copyFrom(const SWKey &ikey) {
VerseKey::VerseKey(const char *min, const char *max, const char *v11n) : SWKey()
{
init(v11n);
- ListKey tmpListKey = ParseVerseList(min);
- if (tmpListKey.Count()) {
- VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.GetElement(0));
- LowerBound(*newElement);
+ ListKey tmpListKey = parseVerseList(min);
+ if (tmpListKey.getCount()) {
+ VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.getElement(0));
+ setLowerBound(*newElement);
}
- tmpListKey = ParseVerseList(max, min, true);
- if (tmpListKey.Count()) {
- VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.GetElement(0));
- UpperBound((newElement->isBoundSet())?newElement->UpperBound():*newElement);
+ tmpListKey = parseVerseList(max, min, true);
+ if (tmpListKey.getCount()) {
+ VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.getElement(0));
+ setUpperBound((newElement->isBoundSet())?newElement->getUpperBound():*newElement);
}
setPosition(TOP);
}
@@ -248,9 +255,9 @@ VerseKey::~VerseKey() {
void VerseKey::setVersificationSystem(const char *name) {
- const VerseMgr::System *newRefSys = VerseMgr::getSystemVerseMgr()->getVersificationSystem(name);
+ const VersificationMgr::System *newRefSys = VersificationMgr::getSystemVersificationMgr()->getVersificationSystem(name);
// TODO: cheese, but what should we do if requested v11n system isn't found?
- if (!newRefSys) newRefSys = VerseMgr::getSystemVerseMgr()->getVersificationSystem("KJV");
+ if (!newRefSys) newRefSys = VersificationMgr::getSystemVersificationMgr()->getVersificationSystem("KJV");
if (refSys != newRefSys) {
refSys = newRefSys;
BMAX[0] = refSys->getBMAX()[0];
@@ -259,7 +266,7 @@ void VerseKey::setVersificationSystem(const char *name) {
// TODO: adjust bounds for versificaion system ???
// TODO: when we have mapping done, rethink this
//necessary as our bounds might not mean anything in the new v11n system
- ClearBounds();
+ clearBounds();
}
}
@@ -285,14 +292,15 @@ char VerseKey::parse(bool checkAutoNormalize)
int error = 0;
if (keytext) {
- ListKey tmpListKey = ParseVerseList(keytext);
- if (tmpListKey.Count()) {
+ // pass our own copy of keytext as keytext memory may be freshed during parse
+ ListKey tmpListKey = parseVerseList(SWBuf(keytext).c_str());
+ if (tmpListKey.getCount()) {
this->positionFrom(*tmpListKey.getElement(0));
error = this->error;
} else error = 1;
}
if (checkAutoNormalize) {
- Normalize(1);
+ normalize(true);
}
freshtext();
@@ -344,7 +352,7 @@ void VerseKey::freshtext() const
* RET: book number or < 0 = not valid
*/
-int VerseKey::getBookAbbrev(const char *iabbr) const
+int VerseKey::getBookFromAbbrev(const char *iabbr) const
{
int diff, abLen, min, max, target, retVal = -1;
@@ -424,7 +432,7 @@ int VerseKey::getBookAbbrev(const char *iabbr) const
void VerseKey::validateCurrentLocale() const {
if (SWLog::getSystemLog()->getLogLevel() >= SWLog::LOG_DEBUG) { //make sure log is wanted, this loop stuff costs a lot of time
for (int i = 0; i < refSys->getBookCount(); i++) {
- const int bn = getBookAbbrev(getPrivateLocale()->translate(refSys->getBook(i)->getLongName()));
+ const int bn = getBookFromAbbrev(getPrivateLocale()->translate(refSys->getBook(i)->getLongName()));
if (bn != i+1) {
char *abbr = 0;
stdstr(&abbr, getPrivateLocale()->translate(refSys->getBook(i)->getLongName()), 2);
@@ -448,7 +456,7 @@ void VerseKey::validateCurrentLocale() const {
/******************************************************************************
- * VerseKey::ParseVerseList - Attempts to parse a buffer into separate
+ * VerseKey::parseVerseList - Attempts to parse a buffer into separate
* verse entries returned in a ListKey
*
* ENT: buf - buffer to parse;
@@ -463,7 +471,7 @@ void VerseKey::validateCurrentLocale() const {
* COMMENT: This code works but wreaks. Rewrite to make more maintainable.
*/
-ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool expandRange, bool useChapterAsVerse) {
+ListKey VerseKey::parseVerseList(const char *buf, const char *defaultKey, bool expandRange, bool useChapterAsVerse) {
// hold on to our own copy of params, as threads/recursion may change outside values
const char *bufStart = buf;
@@ -498,17 +506,17 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
VerseKey *curKey = (VerseKey *)this->clone();
VerseKey *lastKey = (VerseKey *)this->clone();
- lastKey->ClearBounds();
- curKey->ClearBounds();
+ lastKey->clearBounds();
+ curKey->clearBounds();
// some silly checks for corner cases
if (!strcmp(buf, "[ Module Heading ]")) {
- curKey->Verse(0);
- curKey->Chapter(0);
- curKey->Book(0);
- curKey->Testament(0);
- lastKey->LowerBound(*curKey);
- lastKey->UpperBound(*curKey);
+ curKey->setVerse(0);
+ curKey->setChapter(0);
+ curKey->setBook(0);
+ curKey->setTestament(0);
+ lastKey->setLowerBound(*curKey);
+ lastKey->setUpperBound(*curKey);
internalListKey << *lastKey;
delete curKey;
delete lastKey;
@@ -517,20 +525,20 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
if ((!strncmp(buf, "[ Testament ", 12)) &&
(isdigit(buf[12])) &&
(!strcmp(buf+13, " Heading ]"))) {
- curKey->Verse(0);
- curKey->Chapter(0);
- curKey->Book(0);
- curKey->Testament(buf[12]-48);
- lastKey->LowerBound(*curKey);
- lastKey->UpperBound(*curKey);
+ curKey->setVerse(0);
+ curKey->setChapter(0);
+ curKey->setBook(0);
+ curKey->setTestament(buf[12]-48);
+ lastKey->setLowerBound(*curKey);
+ lastKey->setUpperBound(*curKey);
internalListKey << *lastKey;
delete curKey;
delete lastKey;
return internalListKey;
}
- curKey->AutoNormalize(AutoNormalize());
- lastKey->AutoNormalize(0);
+ curKey->setAutoNormalize(isAutoNormalize());
+ lastKey->setAutoNormalize(false);
if (defaultKey) *lastKey = defaultKey;
while (*buf) {
@@ -539,8 +547,11 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
if (buf[1] != ' ') { // for silly "Mat 1:1: this verse...."
number[tonumber] = 0;
tonumber = 0;
- if (*number)
- chap = atoi(number);
+ if (*number) {
+ if (chap >= 0)
+ verse = atoi(number);
+ else chap = atoi(number);
+ }
*number = 0;
comma = 0;
break;
@@ -558,7 +569,9 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
break;
}
if (inTerm) {
- book[tobook++] = ' ';
+ if (tobook < 1 || book[tobook-1] != ' ') {
+ book[tobook++] = ' ';
+ }
break;
}
@@ -567,7 +580,7 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
book[tobook] = *buf;
book[tobook+1] = *(buf+1);
book[tobook+2] = 0;
- int bookno = getBookAbbrev(book);
+ int bookno = getBookFromAbbrev(book);
if (bookno > -1) {
tobook++;
buf++;
@@ -588,7 +601,14 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
tobook = 0;
bookno = -1;
if (*book) {
- for (loop = strlen(book) - 1; loop+1; loop--) {
+ loop = strlen(book) - 1;
+
+ for (; loop+1; loop--) { if (book[loop] == ' ') book[loop] = 0; else break; }
+
+ if (loop > 0 && isdigit(book[loop-1]) && book[loop] >= 'a' && book[loop] <= 'z') {
+ book[loop--] = 0;
+ }
+ for (; loop+1; loop--) {
if ((isdigit(book[loop])) || (book[loop] == ' ')) {
book[loop] = 0;
continue;
@@ -618,30 +638,47 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
}
}
+ // check for special inscriptio and subscriptio which are saved as book intro and chap 1 intro (for INTF)
+ for (loop = strlen(book) - 1; loop+1; loop--) {
+ if (book[loop] == ' ') {
+ if (!strnicmp(&book[loop+1], "inscriptio", strlen(&book[loop+1]))) {
+ book[loop] = 0;
+ verse = 0;
+ chap = 0;
+ }
+ else if (!strnicmp(&book[loop+1], "subscriptio", strlen(&book[loop+1]))) {
+ book[loop] = 0;
+ verse = 0;
+ chap = 1;
+ }
+ break;
+ }
+ }
+
if ((!stricmp(book, "V")) || (!stricmp(book, "VER"))) { // Verse abbrev
if (verse == -1) {
verse = chap;
- chap = lastKey->Chapter();
+ chap = lastKey->getChapter();
*book = 0;
}
}
if ((!stricmp(book, "ch")) || (!stricmp(book, "chap"))) { // Verse abbrev
strcpy(book, lastKey->getBookName());
}
- bookno = getBookAbbrev(book);
+ bookno = getBookFromAbbrev(book);
if ((bookno > -1) && (suffix == 'f') && (book[strlen(book)-1] == 'f')) {
suffix = 0;
}
}
if (((bookno > -1) || (!*book)) && ((*book) || (chap >= 0) || (verse >= 0))) {
char partial = 0;
- curKey->Verse(1);
- curKey->Chapter(1);
- curKey->Book(1);
+ curKey->setVerse(1);
+ curKey->setChapter(1);
+ curKey->setBook(1);
if (bookno < 0) {
- curKey->Testament(lastKey->Testament());
- curKey->Book(lastKey->Book());
+ curKey->setTestament(lastKey->getTestament());
+ curKey->setBook(lastKey->getBook());
}
else {
int t = 1;
@@ -649,15 +686,15 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
t++;
bookno -= BMAX[0];
}
- curKey->Testament(t);
- curKey->Book(bookno);
+ curKey->setTestament(t);
+ curKey->setBook(bookno);
}
if (((comma)||((verse < 0)&&(bookno < 0)))&&(!lastPartial)) {
// if (comma) {
- curKey->Chapter(lastKey->Chapter());
- curKey->Verse(chap); // chap because this is the first number captured
+ curKey->setChapter(lastKey->getChapter());
+ curKey->setVerse(chap); // chap because this is the first number captured
if (suffix) {
curKey->setSuffix(suffix);
}
@@ -670,21 +707,21 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
if (chap >= 0) {
- curKey->Chapter(chap);
+ curKey->setChapter(chap);
}
else {
partial++;
- curKey->Chapter(1);
+ curKey->setChapter(1);
}
if (verse >= 0) {
- curKey->Verse(verse);
+ curKey->setVerse(verse);
if (suffix) {
curKey->setSuffix(suffix);
}
}
else {
partial++;
- curKey->Verse(1);
+ curKey->setVerse(1);
}
}
@@ -692,23 +729,25 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
for (q = 0; ((buf[q]) && (buf[q] == ' ')); q++);
if ((buf[q] == '-') && (expandRange)) { // if this is a dash save lowerBound and wait for upper
buf+=q;
- lastKey->LowerBound(*curKey);
+ lastKey->setLowerBound(*curKey);
lastKey->setPosition(TOP);
tmpListKey << *lastKey;
- tmpListKey.GetElement()->userData = (void *)(bufStart+(buf-iBuf.c_str()));
+ ((VerseKey *)tmpListKey.getElement())->setAutoNormalize(isAutoNormalize());
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
else {
if (!dash) { // if last separator was not a dash just add
if (expandRange && partial) {
- lastKey->LowerBound(*curKey);
+ lastKey->setLowerBound(*curKey);
if (partial > 1)
curKey->setPosition(MAXCHAPTER);
if (partial > 0)
*curKey = MAXVERSE;
- lastKey->UpperBound(*curKey);
+ lastKey->setUpperBound(*curKey);
*lastKey = TOP;
tmpListKey << *lastKey;
- tmpListKey.GetElement()->userData = (void *)(bufStart+(buf-iBuf.c_str()));
+ ((VerseKey *)tmpListKey.getElement())->setAutoNormalize(isAutoNormalize());
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
else {
bool f = false;
@@ -716,25 +755,27 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
curKey->setSuffix(0);
f = true;
}
- lastKey->LowerBound(*curKey);
+ lastKey->setLowerBound(*curKey);
if (f && doubleF) (*curKey) = MAXVERSE;
else if (f) (*curKey)++;
- lastKey->UpperBound(*curKey);
+ lastKey->setUpperBound(*curKey);
*lastKey = TOP;
tmpListKey << *lastKey;
- tmpListKey.GetElement()->userData = (void *)(bufStart+(buf-iBuf.c_str()));
+ ((VerseKey *)tmpListKey.getElement())->setAutoNormalize(isAutoNormalize());
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
}
else if (expandRange) {
- VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.GetElement());
+ VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.getElement());
if (newElement) {
if (partial > 1)
*curKey = MAXCHAPTER;
if (partial > 0)
*curKey = MAXVERSE;
- newElement->UpperBound(*curKey);
+ newElement->setUpperBound(*curKey);
+ *lastKey = *curKey;
*newElement = TOP;
- tmpListKey.GetElement()->userData = (void *)(bufStart+(buf-iBuf.c_str()));
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
}
}
@@ -761,19 +802,27 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
case '}':
break;
case '.':
- if (buf > orig) // ignore (break) if preceeding char is not a digit
+ 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)
+ if (!notAllDigits && !isdigit(buf[1]))
break;
+ }
number[tonumber] = 0;
tonumber = 0;
- if (*number)
- chap = atoi(number);
- *number = 0;
+ if (*number) {
+ if (chap >= 0)
+ verse = atoi(number);
+ else chap = atoi(number);
+ *number = 0;
+ }
+ else if (chap == -1 && (tobook < 1 || book[tobook-1] != ' ')) {
+ book[tobook++] = ' ';
+ }
+
break;
default:
@@ -789,9 +838,15 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
break;
default:
// suffixes (and oddly 'f'-- ff.)
- if (((*buf >= 'a' && *buf <= 'z') && (chap >=0)) || *buf == 'f') {
+ if ((*buf >= 'a' && *buf <= 'z' && (chap >=0 || bookno > -1 || lastKey->isBoundSet()))
+ || *buf == 'f') {
// if suffix is already an 'f', then we need to mark if we're doubleF.
doubleF = (*buf == 'f' && suffix == 'f');
+ if (suffix && !doubleF) {
+ // we've already had a suffix one, so this is another letter, thus any number is not a number, e.g., '2jn'. We're on 'n'
+ number[tonumber] = 0;
+ tonumber = 0;
+ }
suffix = *buf;
}
else {
@@ -811,13 +866,25 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
if (*number) {
if (chap >= 0)
verse = atoi(number);
- else chap = atoi(number);
+ else chap = atoi(number);
}
*number = 0;
book[tobook] = 0;
tobook = 0;
if (*book) {
- for (loop = strlen(book) - 1; loop+1; loop--) {
+ loop = strlen(book) - 1;
+
+ // strip trailing spaces
+ for (; loop+1; loop--) { if (book[loop] == ' ') book[loop] = 0; else break; }
+
+ // check if endsWith([0-9][a-z]) and kill the last letter, e.g., ...12a, and chop off the 'a'
+ // why? What's this for? wouldn't this mess up 2t?
+ if (loop > 0 && isdigit(book[loop-1]) && book[loop] >= 'a' && book[loop] <= 'z') {
+ book[loop--] = 0;
+ }
+
+ // skip trailing spaces and numbers
+ for (; loop+1; loop--) {
if ((isdigit(book[loop])) || (book[loop] == ' ')) {
book[loop] = 0;
continue;
@@ -833,6 +900,7 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
break;
}
+ // check for roman numeral chapter
for (loop = strlen(book) - 1; loop+1; loop--) {
if (book[loop] == ' ') {
// "PS C" is ok, but "II C" is not ok
@@ -846,11 +914,29 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
break;
}
}
+ // check for special inscriptio and subscriptio which are saved as book intro and chap 1 intro (for INTF)
+ for (loop = strlen(book) - 1; loop+1; loop--) {
+ if (book[loop] == ' ') {
+ if (!strnicmp(&book[loop+1], "inscriptio", strlen(&book[loop+1]))) {
+ book[loop] = 0;
+ verse = 0;
+ chap = 0;
+ suffix = 0;
+ }
+ else if (!strnicmp(&book[loop+1], "subscriptio", strlen(&book[loop+1]))) {
+ book[loop] = 0;
+ verse = 0;
+ chap = 1;
+ suffix = 0;
+ }
+ break;
+ }
+ }
if ((!stricmp(book, "V")) || (!stricmp(book, "VER"))) { // Verse abbrev.
if (verse == -1) {
verse = chap;
- chap = lastKey->Chapter();
+ chap = lastKey->getChapter();
*book = 0;
}
}
@@ -858,20 +944,20 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
if ((!stricmp(book, "ch")) || (!stricmp(book, "chap"))) { // Verse abbrev
strcpy(book, lastKey->getBookName());
}
- bookno = getBookAbbrev(book);
+ bookno = getBookFromAbbrev(book);
if ((bookno > -1) && (suffix == 'f') && (book[strlen(book)-1] == 'f')) {
suffix = 0;
}
}
if (((bookno > -1) || (!*book)) && ((*book) || (chap >= 0) || (verse >= 0))) {
char partial = 0;
- curKey->Verse(1);
- curKey->Chapter(1);
- curKey->Book(1);
+ curKey->setVerse(1);
+ curKey->setChapter(1);
+ curKey->setBook(1);
if (bookno < 0) {
- curKey->Testament(lastKey->Testament());
- curKey->Book(lastKey->Book());
+ curKey->setTestament(lastKey->getTestament());
+ curKey->setBook(lastKey->getBook());
}
else {
int t = 1;
@@ -879,13 +965,13 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
t++;
bookno -= BMAX[0];
}
- curKey->Testament(t);
- curKey->Book(bookno);
+ curKey->setTestament(t);
+ curKey->setBook(bookno);
}
if (((comma)||((verse < 0)&&(bookno < 0)))&&(!lastPartial)) {
- curKey->Chapter(lastKey->Chapter());
- curKey->Verse(chap); // chap because this is the first number captured
+ curKey->setChapter(lastKey->getChapter());
+ curKey->setVerse(chap); // chap because this is the first number captured
if (suffix) {
curKey->setSuffix(suffix);
}
@@ -898,42 +984,42 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
if (chap >= 0) {
- curKey->Chapter(chap);
+ curKey->setChapter(chap);
}
else {
partial++;
- curKey->Chapter(1);
+ curKey->setChapter(1);
}
if (verse >= 0) {
- curKey->Verse(verse);
+ curKey->setVerse(verse);
if (suffix) {
curKey->setSuffix(suffix);
}
}
else {
partial++;
- curKey->Verse(1);
+ curKey->setVerse(1);
}
}
if ((*buf == '-') && (expandRange)) { // if this is a dash save lowerBound and wait for upper
- lastKey->LowerBound(*curKey);
+ lastKey->setLowerBound(*curKey);
*lastKey = TOP;
tmpListKey << *lastKey;
- tmpListKey.GetElement()->userData = (void *)(bufStart+(buf-iBuf.c_str()));
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
else {
if (!dash) { // if last separator was not a dash just add
if (expandRange && partial) {
- lastKey->LowerBound(*curKey);
+ lastKey->setLowerBound(*curKey);
if (partial > 1)
*curKey = MAXCHAPTER;
if (partial > 0)
*curKey = MAXVERSE;
- lastKey->UpperBound(*curKey);
+ lastKey->setUpperBound(*curKey);
*lastKey = TOP;
tmpListKey << *lastKey;
- tmpListKey.GetElement()->userData = (void *)(bufStart+(buf-iBuf.c_str()));
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
else {
bool f = false;
@@ -941,25 +1027,25 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
curKey->setSuffix(0);
f = true;
}
- lastKey->LowerBound(*curKey);
+ lastKey->setLowerBound(*curKey);
if (f && doubleF) (*curKey) = MAXVERSE;
else if (f) (*curKey)++;
- lastKey->UpperBound(*curKey);
+ lastKey->setUpperBound(*curKey);
*lastKey = TOP;
tmpListKey << *lastKey;
- tmpListKey.GetElement()->userData = (void *)(bufStart+(buf-iBuf.c_str()));
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
}
else if (expandRange) {
- VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.GetElement());
+ VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.getElement());
if (newElement) {
if (partial > 1)
*curKey = MAXCHAPTER;
if (partial > 0)
*curKey = MAXVERSE;
- newElement->UpperBound(*curKey);
+ newElement->setUpperBound(*curKey);
*newElement = TOP;
- tmpListKey.GetElement()->userData = (void *)(bufStart+(buf-iBuf.c_str()));
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
}
}
@@ -977,14 +1063,14 @@ ListKey VerseKey::ParseVerseList(const char *buf, const char *defaultKey, bool e
/******************************************************************************
- * VerseKey::LowerBound - sets / gets the lower boundary for this key
+ * VerseKey::setLowerBound - sets / gets the lower boundary for this key
*/
-VerseKey &VerseKey::LowerBound(const VerseKey &lb)
+void VerseKey::setLowerBound(const VerseKey &lb)
{
initBounds();
- lowerBound = lb.Index();
+ lowerBound = lb.getIndex();
lowerBoundComponents.test = lb.getTestament();
lowerBoundComponents.book = lb.getBook();
lowerBoundComponents.chap = lb.getChapter();
@@ -996,39 +1082,35 @@ VerseKey &VerseKey::LowerBound(const VerseKey &lb)
// and set values without restrictions, as expected
if (upperBound < lowerBound) upperBound = lowerBound;
boundSet = true;
-
- return LowerBound();
}
/******************************************************************************
- * VerseKey::UpperBound - sets / gets the upper boundary for this key
+ * VerseKey::setUpperBound - sets / gets the upper boundary for this key
*/
-VerseKey &VerseKey::UpperBound(const VerseKey &ub)
+void VerseKey::setUpperBound(const VerseKey &ub)
{
initBounds();
- upperBound = ub.Index();
+ upperBound = ub.getIndex();
upperBoundComponents.test = ub.getTestament();
upperBoundComponents.book = ub.getBook();
upperBoundComponents.chap = ub.getChapter();
upperBoundComponents.verse = ub.getVerse();
upperBoundComponents.suffix = ub.getSuffix();
- // see LowerBound comment, above
+ // see setLowerBound comment, above
if (upperBound < lowerBound) upperBound = lowerBound;
boundSet = true;
-
- return UpperBound();
}
/******************************************************************************
- * VerseKey::LowerBound - sets / gets the lower boundary for this key
+ * VerseKey::getLowerBound - gets the lower boundary for this key
*/
-VerseKey &VerseKey::LowerBound() const
+VerseKey &VerseKey::getLowerBound() const
{
initBounds();
if (!isAutoNormalize()) {
@@ -1038,17 +1120,20 @@ VerseKey &VerseKey::LowerBound() const
tmpClone->setVerse (lowerBoundComponents.verse);
tmpClone->setSuffix (lowerBoundComponents.suffix);
}
- else tmpClone->Index(lowerBound);
+ else {
+ tmpClone->setIndex(lowerBound);
+ tmpClone->setSuffix (lowerBoundComponents.suffix);
+ }
return (*tmpClone);
}
/******************************************************************************
- * VerseKey::UpperBound - sets / gets the upper boundary for this key
+ * VerseKey::getUpperBound - sets / gets the upper boundary for this key
*/
-VerseKey &VerseKey::UpperBound() const
+VerseKey &VerseKey::getUpperBound() const
{
initBounds();
if (!isAutoNormalize()) {
@@ -1058,17 +1143,20 @@ VerseKey &VerseKey::UpperBound() const
tmpClone->setVerse (upperBoundComponents.verse);
tmpClone->setSuffix (upperBoundComponents.suffix);
}
- else tmpClone->Index(upperBound);
+ else {
+ tmpClone->setIndex(upperBound);
+ tmpClone->setSuffix (upperBoundComponents.suffix);
+ }
return (*tmpClone);
}
/******************************************************************************
- * VerseKey::ClearBounds - clears bounds for this VerseKey
+ * VerseKey::clearBounds - clears bounds for this VerseKey
*/
-void VerseKey::ClearBounds()
+void VerseKey::clearBounds()
{
delete tmpClone;
tmpClone = 0;
@@ -1080,13 +1168,13 @@ void VerseKey::initBounds() const
{
if (!tmpClone) {
tmpClone = (VerseKey *)this->clone();
- tmpClone->AutoNormalize(0);
- tmpClone->Headings(1);
- tmpClone->Testament((BMAX[1])?2:1);
- tmpClone->Book(BMAX[(BMAX[1])?1:0]);
- tmpClone->Chapter(tmpClone->getChapterMax());
- tmpClone->Verse(tmpClone->getVerseMax());
- upperBound = tmpClone->Index();
+ tmpClone->setAutoNormalize(false);
+ tmpClone->setIntros(true);
+ tmpClone->setTestament((BMAX[1])?2:1);
+ tmpClone->setBook(BMAX[(BMAX[1])?1:0]);
+ tmpClone->setChapter(tmpClone->getChapterMax());
+ tmpClone->setVerse(tmpClone->getVerseMax());
+ upperBound = tmpClone->getIndex();
upperBoundComponents.test = tmpClone->getTestament();
upperBoundComponents.book = tmpClone->getBook();
upperBoundComponents.chap = tmpClone->getChapter();
@@ -1159,46 +1247,51 @@ const char *VerseKey::getBookAbbrev() const {
void VerseKey::setPosition(SW_POSITION p) {
switch (p) {
case POS_TOP: {
- const VerseKey *lb = &LowerBound();
- testament = (lb->Testament() || headings) ? lb->Testament() : 1;
- book = (lb->Book() || headings) ? lb->Book() : 1;
- chapter = (lb->Chapter() || headings) ? lb->Chapter() : 1;
- verse = (lb->Verse() || headings) ? lb->Verse() : 1;
+ const VerseKey *lb = &getLowerBound();
+ testament = (lb->getTestament() || intros) ? lb->getTestament() : 1;
+ book = (lb->getBook() || intros) ? lb->getBook() : 1;
+ chapter = (lb->getChapter() || intros) ? lb->getChapter() : 1;
+ verse = (lb->getVerse() || intros) ? lb->getVerse() : 1;
suffix = lb->getSuffix();
break;
}
case POS_BOTTOM: {
- const VerseKey *ub = &UpperBound();
- testament = (ub->Testament() || headings) ? ub->Testament() : 1;
- book = (ub->Book() || headings) ? ub->Book() : 1;
- chapter = (ub->Chapter() || headings) ? ub->Chapter() : 1;
- verse = (ub->Verse() || headings) ? ub->Verse() : 1;
+ const VerseKey *ub = &getUpperBound();
+ testament = (ub->getTestament() || intros) ? ub->getTestament() : 1;
+ book = (ub->getBook() || intros) ? ub->getBook() : 1;
+ chapter = (ub->getChapter() || intros) ? ub->getChapter() : 1;
+ verse = (ub->getVerse() || intros) ? ub->getVerse() : 1;
suffix = ub->getSuffix();
break;
}
case POS_MAXVERSE:
- Normalize();
+ suffix = 0;
+ verse = 1;
+ normalize();
verse = getVerseMax();
suffix = 0;
break;
case POS_MAXCHAPTER:
- verse = 1;
suffix = 0;
- Normalize();
+ verse = 1;
+ chapter = 1;
+ normalize();
chapter = getChapterMax();
break;
}
- Normalize(1);
- Error(); // clear error from normalize
+ normalize(true);
+ popError(); // clear error from normalize
}
int VerseKey::getChapterMax() const {
- const VerseMgr::Book *b = refSys->getBook(((testament>1)?BMAX[0]:0)+book-1);
+ if (book < 1) return 0;
+ const VersificationMgr::Book *b = refSys->getBook(((testament>1)?BMAX[0]:0)+book-1);
return (b) ? b->getChapterMax() : -1;
}
int VerseKey::getVerseMax() const {
- const VerseMgr::Book *b = refSys->getBook(((testament>1)?BMAX[0]:0)+book-1);
+ if (book < 1) return 0;
+ const VersificationMgr::Book *b = refSys->getBook(((testament>1)?BMAX[0]:0)+book-1);
return (b) ? b->getVerseMax(chapter) : -1;
}
@@ -1212,11 +1305,17 @@ int VerseKey::getVerseMax() const {
*/
void VerseKey::increment(int step) {
+ // if we're not autonormalizing and we're already not normalized
+ if (!autonorm && chapter > 0 && verse > getVerseMax()) {
+ verse += step;
+ checkBounds();
+ return;
+ }
char ierror = 0;
- Index(Index() + step);
- while ((!verse) && (!headings) && (!ierror)) {
- Index(Index() + 1);
- ierror = Error();
+ setIndex(getIndex() + step);
+ while ((!verse) && (!intros) && (!ierror)) {
+ setIndex(getIndex() + 1);
+ ierror = popError();
}
error = (ierror) ? ierror : error;
@@ -1232,14 +1331,19 @@ void VerseKey::increment(int step) {
*/
void VerseKey::decrement(int step) {
+ // if we're not autonormalizing and we're already not normalized
+ if (!autonorm && chapter > 0 && verse > getVerseMax()) {
+ verse -= step;
+ checkBounds();
+ return;
+ }
char ierror = 0;
-
- Index(Index() - step);
- while ((!verse) && (!headings) && (!ierror)) {
- Index(Index() - 1);
- ierror = Error();
+ setIndex(getIndex() - step);
+ while ((!verse) && (!intros) && (!ierror)) {
+ setIndex(getIndex() - 1);
+ ierror = popError();
}
- if ((ierror) && (!headings))
+ if ((ierror) && (!intros))
(*this)++;
error = (ierror) ? ierror : error;
@@ -1247,109 +1351,90 @@ void VerseKey::decrement(int step) {
/******************************************************************************
- * VerseKey::Normalize - checks limits and normalizes if necessary (e.g.
+ * 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)
+void VerseKey::normalize(bool autocheck)
{
- if (((!autocheck) || (autonorm)) // only normalize if we were explicitely called or if autonorm is turned on
- &&
- ((!headings) || ((verse) && (chapter)))) { // this is cheeze and temporary until deciding what actions should be taken; so headings should only be turned on when positioning with Index() or incrementors
+ if ((!autocheck || autonorm) // only normalize if we were explicitely called or if autonorm is turned on
+ ) {
error = 0;
- 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 > getChapterMax()) {
- chapter -= getChapterMax();
- book++;
- continue;
- }
-
- if (chapter < 1) {
- if (--book > 0) {
- chapter += getChapterMax();
- verse = getVerseMax();
+ while ((testament < 3) && (testament > 0)) {
+
+
+ if (book > BMAX[testament-1]) {
+ book -= (BMAX[testament-1] + (intros?1:0));
+ testament++;
+ continue;
}
- else {
- if (testament > 1) {
- chapter += refSys->getBook(BMAX[0]-1)->getChapterMax();
- verse = refSys->getBook(BMAX[0]-1)->getVerseMax(chapter);
+ if (book < (intros?0:1)) {
+ if (--testament > 0) {
+ book += (BMAX[testament-1] + (intros?1:0));
}
+ continue;
+ }
+
+
+ if (chapter > getChapterMax()) {
+ chapter -= (getChapterMax() + (intros?1:0));
+ book++;
+ continue;
+ }
+ if (chapter < (intros?0:1)) {
+ --book;
+ chapter += (getChapterMax() + (intros?1:0));
+ continue;
}
- continue;
- }
- if (verse > getVerseMax()) { // -1 because e.g chapter 1 of Matthew is books[1][0].versemax[0]
- verse -= getVerseMax();
+
+ if (chapter > 0 && verse > getVerseMax()) {
+ verse -= (getVerseMax() + (intros?1:0));
chapter++;
- continue;
- }
-
- if (verse < 1) {
- if (--chapter > 0) {
- verse += getVerseMax();
- }
- else {
- if (book > 1) {
- const VerseMgr::Book *prevBook = refSys->getBook(((testament>1)?BMAX[0]:0)+book-2);
- verse += prevBook->getVerseMax(prevBook->getChapterMax());
- }
- else {
- if (testament > 1) {
- const VerseMgr::Book *lastOTBook = refSys->getBook(BMAX[0]-1);
- verse += lastOTBook->getVerseMax(lastOTBook->getChapterMax());
- }
- }
- }
- continue;
- }
-
- break; // If we've made it this far (all failure checks continue) we're ok
- }
-
- if (testament > (BMAX[1]?2:1)) {
- testament = BMAX[1]?2:1;
- book = BMAX[testament-1];
- chapter = getChapterMax();
- verse = getVerseMax();
- 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);
- }
-
- // should we always perform bounds checks? Tried but seems to cause infinite recursion
- if (_compare(UpperBound()) > 0) {
- positionFrom(UpperBound());
- error = KEYERR_OUTOFBOUNDS;
- }
- if (_compare(LowerBound()) < 0) {
- positionFrom(LowerBound());
- error = KEYERR_OUTOFBOUNDS;
- }
- }
+ continue;
+ }
+ if (verse < (intros?0:1)) {
+ if (--chapter < (intros?0:1)) {
+ --book;
+ chapter += (getChapterMax() + (intros?1:0));
+ }
+ verse += (getVerseMax() + (intros?1:0));
+ continue;
+ }
+
+ break; // If we've made it this far (all failure checks continue) we're ok
+ }
+
+ if (testament > (BMAX[1]?2:1)) {
+ testament = BMAX[1]?2:1;
+ book = BMAX[testament-1];
+ chapter = getChapterMax();
+ verse = getVerseMax();
+ error = KEYERR_OUTOFBOUNDS;
+ }
+
+ if (testament < 1) {
+ error = ((!intros) || (testament < 0) || (book < 0)) ? KEYERR_OUTOFBOUNDS : 0;
+ testament = ((intros) ? 0 : 1);
+ book = ((intros) ? 0 : 1);
+ chapter = ((intros) ? 0 : 1);
+ verse = ((intros) ? 0 : 1);
+ }
+
+ // should we always perform bounds checks? Tried but seems to cause infinite recursion
+ if (_compare(getUpperBound()) > 0) {
+ positionFrom(getUpperBound());
+ error = KEYERR_OUTOFBOUNDS;
+ }
+ if (_compare(getLowerBound()) < 0) {
+ positionFrom(getLowerBound());
+ error = KEYERR_OUTOFBOUNDS;
+ }
+ }
}
@@ -1378,7 +1463,7 @@ char VerseKey::getBook() const
/******************************************************************************
- * VerseKey::Chapter - Gets chapter
+ * VerseKey::getChapter - Gets chapter
*
* RET: value of chapter
*/
@@ -1390,7 +1475,7 @@ int VerseKey::getChapter() const
/******************************************************************************
- * VerseKey::Verse - Gets verse
+ * VerseKey::getVerse - Gets verse
*
* RET: value of verse
*/
@@ -1407,16 +1492,16 @@ int VerseKey::getVerse() const
* ENT: itestament - value which to set testament
* [MAXPOS(char)] - only get
*
- * RET: if unchanged -> value of testament
- * if changed -> previous value of testament
*/
void VerseKey::setTestament(char itestament)
{
- if (itestament != MAXPOS(char)) {
- testament = itestament;
- Normalize(1);
- }
+ suffix = 0;
+ verse = (intros) ? 0 : 1;
+ chapter = (intros) ? 0 : 1;
+ book = (intros) ? 0 : 1;
+ testament = itestament;
+ normalize(true);
}
@@ -1428,10 +1513,11 @@ void VerseKey::setTestament(char itestament)
void VerseKey::setBook(char ibook)
{
- verse = 1;
- chapter = 1;
+ suffix = 0;
+ verse = (intros) ? 0 : 1;
+ chapter = (intros) ? 0 : 1;
book = ibook;
- Normalize(1);
+ normalize(true);
}
@@ -1444,7 +1530,7 @@ void VerseKey::setBook(char ibook)
void VerseKey::setBookName(const char *bname)
{
- int bnum = getBookAbbrev(bname);
+ int bnum = getBookFromAbbrev(bname);
if (bnum > -1) {
if (bnum > BMAX[0]) {
bnum -= BMAX[0];
@@ -1465,11 +1551,10 @@ void VerseKey::setBookName(const char *bname)
void VerseKey::setChapter(int ichapter)
{
- verse = 1;
+ suffix = 0;
+ verse = (intros) ? 0 : 1;
chapter = ichapter;
- Normalize(1);
- // TODO: easiest fix, but should be in Normalize
- verse = 1;
+ normalize(true);
}
@@ -1485,9 +1570,9 @@ void VerseKey::setChapter(int ichapter)
void VerseKey::setVerse(int iverse)
{
- setSuffix(0);
- verse = iverse;
- Normalize(1);
+ suffix = 0;
+ verse = iverse;
+ normalize(true);
}
@@ -1500,7 +1585,7 @@ void VerseKey::setSuffix(char suf) {
}
/******************************************************************************
- * VerseKey::AutoNormalize - Sets/gets flag that tells VerseKey to auto-
+ * VerseKey::isAutoNormalize - gets flag that tells VerseKey to auto-
* matically normalize itself when modified
*/
@@ -1512,67 +1597,37 @@ bool VerseKey::isAutoNormalize() const
void VerseKey::setAutoNormalize(bool iautonorm)
{
autonorm = iautonorm?1:0;
- Normalize(1);
+ normalize(true);
}
/******************************************************************************
- * VerseKey::Headings - Sets/gets flag that tells VerseKey to include
- * chap/book/testmnt/module headings
+ * VerseKey::setIntros - Sets flag that tells VerseKey to include
+ * chap/book/testmnt/module introductions
*
- * ENT: iheadings - value which to set headings
- * [MAXPOS(char)] - only get
+ * ENT: val - value which to set intros
*
- * RET: if unchanged -> value of headings
- * if changed -> previous value of headings
*/
-char VerseKey::Headings(char iheadings)
+void VerseKey::setIntros(bool val)
{
- char retval = headings;
-
- if (iheadings != MAXPOS(char)) {
- headings = iheadings;
- Normalize(1);
- }
- return retval;
+ intros = val;
+ normalize(true);
}
-
-/******************************************************************************
- * 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)
+bool VerseKey::isIntros() const
{
- 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;
+ return intros;
}
/******************************************************************************
- * VerseKey::Index - Gets index based upon current verse
+ * VerseKey::getIndex - Gets index based upon current verse
*
* RET: offset
*/
-long VerseKey::Index() const
+long VerseKey::getIndex() const
{
long offset;
@@ -1590,28 +1645,33 @@ long VerseKey::Index() const
/******************************************************************************
- * VerseKey::TestamentIndex - Gets index based upon current verse
+ * VerseKey::getTestamentIndex - Gets index based upon current verse
*
* RET: offset
*/
-long VerseKey::TestamentIndex() const
+long VerseKey::getTestamentIndex() const
{
- long offset = Index();
+ long offset = getIndex();
return (testament > 1) ? offset - refSys->getNTStartOffset() : offset;
}
/******************************************************************************
- * VerseKey::Index - Sets index based upon current verse
+ * VerseKey::setIndex - Sets index based upon current verse
*
* ENT: iindex - value to set index to
*
- * RET: offset
*/
-long VerseKey::Index(long iindex)
+void VerseKey::setIndex(long iindex)
{
+ // assert we're sane
+ if (iindex < 0) {
+ error = KEYERR_OUTOFBOUNDS;
+ return;
+ }
+
int b;
error = refSys->getVerseFromOffset(iindex, &b, &chapter, &verse);
book = (unsigned char)b;
@@ -1624,19 +1684,23 @@ long VerseKey::Index(long iindex)
if (book < 0) { testament = 0; book = 0; }
if (chapter < 0) { book = 0; chapter = 0; }
- long i = Index();
+ checkBounds();
+}
+
+void VerseKey::checkBounds() {
+
+ long i = getIndex();
initBounds();
if (i > upperBound) {
- i = Index(upperBound);
+ setIndex(upperBound);
+ i = getIndex();
error = KEYERR_OUTOFBOUNDS;
}
if (i < lowerBound) {
- i = Index(lowerBound);
+ setIndex(lowerBound);
error = KEYERR_OUTOFBOUNDS;
}
-
- return i;
}
@@ -1677,14 +1741,14 @@ int VerseKey::_compare(const VerseKey &ivkey)
unsigned long keyval1 = 0;
unsigned long keyval2 = 0;
- keyval1 += Testament() * 1000000000;
- keyval2 += ivkey.Testament() * 1000000000;
- keyval1 += Book() * 10000000;
- keyval2 += ivkey.Book() * 10000000;
- keyval1 += Chapter() * 10000;
- keyval2 += ivkey.Chapter() * 10000;
- keyval1 += Verse() * 50;
- keyval2 += ivkey.Verse() * 50;
+ keyval1 += getTestament() * 1000000000;
+ keyval2 += ivkey.getTestament() * 1000000000;
+ keyval1 += getBook() * 10000000;
+ keyval2 += ivkey.getBook() * 10000000;
+ keyval1 += getChapter() * 10000;
+ keyval2 += ivkey.getChapter() * 10000;
+ keyval1 += getVerse() * 50;
+ keyval2 += ivkey.getVerse() * 50;
keyval1 += (int)getSuffix();
keyval2 += (int)ivkey.getSuffix();
keyval1 = (keyval1 != keyval2) ? ((keyval1 > keyval2) ? 1 : -1) : 0; // -1 | 0 | 1
@@ -1699,11 +1763,11 @@ const char *VerseKey::getOSISRef() const {
if (loop > 4)
loop = 0;
- if (Verse())
- sprintf(buf[loop], "%s.%d.%d", getOSISBookName(), (int)Chapter(), (int)Verse());
- else if (Chapter())
- sprintf(buf[loop], "%s.%d", getOSISBookName(), (int)Chapter());
- else if (Book())
+ if (getVerse())
+ sprintf(buf[loop], "%s.%d.%d", getOSISBookName(), getChapter(), getVerse());
+ else if (getChapter())
+ sprintf(buf[loop], "%s.%d", getOSISBookName(), getChapter());
+ else if (getBook())
sprintf(buf[loop], "%s", getOSISBookName());
else buf[loop][0] = 0;
return buf[loop++];
@@ -1716,9 +1780,9 @@ const char *VerseKey::getOSISRef() const {
const char *VerseKey::getRangeText() const {
if (isBoundSet() && lowerBound != upperBound) {
- SWBuf buf = (const char *)LowerBound();
+ SWBuf buf = (const char *)getLowerBound();
buf += "-";
- buf += (const char *)UpperBound();
+ buf += (const char *)getUpperBound();
stdstr(&rangeText, buf.c_str());
}
else stdstr(&rangeText, getText());
@@ -1732,9 +1796,9 @@ const char *VerseKey::getRangeText() const {
const char *VerseKey::getOSISRefRangeText() const {
if (isBoundSet() && (lowerBound != upperBound)) {
- SWBuf buf = LowerBound().getOSISRef();
+ SWBuf buf = getLowerBound().getOSISRef();
buf += "-";
- buf += UpperBound().getOSISRef();
+ buf += getUpperBound().getOSISRef();
stdstr(&rangeText, buf.c_str());
}
else stdstr(&rangeText, getOSISRef());
@@ -1750,10 +1814,10 @@ const char *VerseKey::convertToOSIS(const char *inRef, const SWKey *lastKnownKey
outRef = "";
VerseKey defLanguage;
- ListKey verses = defLanguage.ParseVerseList(inRef, (*lastKnownKey), true);
+ ListKey verses = defLanguage.parseVerseList(inRef, (*lastKnownKey), true);
const char *startFrag = inRef;
- for (int i = 0; i < verses.Count(); i++) {
- SWKey *element = verses.GetElement(i);
+ for (int i = 0; i < verses.getCount(); i++) {
+ SWKey *element = verses.getElement(i);
// VerseKey *element = SWDYNAMIC_CAST(VerseKey, verses.GetElement(i));
SWBuf buf;
// TODO: This code really needs to not use fixed size arrays
diff --git a/src/keys/versetreekey.cpp b/src/keys/versetreekey.cpp
index edfbcc3..571314f 100644
--- a/src/keys/versetreekey.cpp
+++ b/src/keys/versetreekey.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * VerseTreeKey.cpp - code for class 'VerseTreeKey'- versekey using treekey
- * for data retrieval
*
+ * versetreekey.cpp - code for class 'VerseTreeKey'- versekey using treekey
+ * for data retrieval
+ *
+ * $Id: versetreekey.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2006-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -86,15 +88,15 @@ SWKey *VerseTreeKey::clone() const
}
-int VerseTreeKey::getBookAbbrev(const char *iabbr)
+int VerseTreeKey::getBookFromAbbrev(const char *iabbr) const
{
- int bookno = VerseKey::getBookAbbrev(iabbr);
+ int bookno = VerseKey::getBookFromAbbrev(iabbr);
if (bookno < 0) {
/*
vector<struct sbook>::iterator it = find(books, iabbr);
if (it == books.end()) {
TreeKey *tkey = this->treeKey;
- int saveError = tkey->Error();
+ int saveError = tkey->popError();
long bookmark = tkey->getOffset();
SWBuf segment;
internalPosChange = true;
@@ -129,7 +131,7 @@ void VerseTreeKey::decrement(int steps) {
if (!error) lastGoodOffset = getTreeKey()->getOffset();
do {
treeKey->decrement();
- treeError = treeKey->Error();
+ treeError = treeKey->popError();
// iterate until 3 levels and no versekey parse errors
} while (!treeError && ((treeKey->getLevel() < 3) || error));
if (error && !treeError) {
@@ -141,12 +143,12 @@ void VerseTreeKey::decrement(int steps) {
treeKey->setOffset(lastGoodOffset);
error = treeError;
}
- if (_compare(UpperBound()) > 0) {
- positionFrom(UpperBound());
+ if (_compare(getUpperBound()) > 0) {
+ positionFrom(getUpperBound());
error = KEYERR_OUTOFBOUNDS;
}
- if (_compare(LowerBound()) < 0) {
- positionFrom(LowerBound());
+ if (_compare(getLowerBound()) < 0) {
+ positionFrom(getLowerBound());
error = KEYERR_OUTOFBOUNDS;
}
}
@@ -157,7 +159,7 @@ void VerseTreeKey::increment(int steps) {
if (!error) lastGoodOffset = getTreeKey()->getOffset();
do {
treeKey->increment();
- treeError = treeKey->Error();
+ treeError = treeKey->popError();
// iterate until 3 levels and no versekey parse errors
} while (!treeError && ((treeKey->getLevel() < 3) || error));
if (error && !treeError) {
@@ -170,12 +172,12 @@ void VerseTreeKey::increment(int steps) {
error = treeError;
}
// bounds
- if (_compare(UpperBound()) > 0) {
- positionFrom(UpperBound());
+ if (_compare(getUpperBound()) > 0) {
+ positionFrom(getUpperBound());
error = KEYERR_OUTOFBOUNDS;
}
- if (_compare(LowerBound()) < 0) {
- positionFrom(LowerBound());
+ if (_compare(getLowerBound()) < 0) {
+ positionFrom(getLowerBound());
error = KEYERR_OUTOFBOUNDS;
}
}
@@ -184,7 +186,7 @@ void VerseTreeKey::increment(int steps) {
void VerseTreeKey::positionChanged() {
if (!internalPosChange) {
TreeKey *tkey = this->TreeKey::PositionChangeListener::getTreeKey();
- int saveError = tkey->Error();
+ int saveError = tkey->popError();
long bookmark = tkey->getOffset();
SWBuf seg[4];
internalPosChange = true;
@@ -231,15 +233,15 @@ void VerseTreeKey::positionChanged() {
void VerseTreeKey::syncVerseToTree() {
internalPosChange = true;
SWBuf path;
- if (!Testament()) path = "/"; // "[ Module Heading ]";
- else if (!Book()) path.setFormatted("/[ Testament %d Heading ]", Testament());
+ if (!getTestament()) path = "/"; // "[ Module Heading ]";
+ else if (!getBook()) path.setFormatted("/[ Testament %d Heading ]", getTestament());
else path.setFormatted("/%s/%d/%d", getOSISBookName(), getChapter(), getVerse());
if (getSuffix()) path += getSuffix();
long bookmark = treeKey->getOffset();
treeKey->setText(path);
// if our module has jacked inconsistencies, then let's put our tree back to where it was
- if (treeKey->Error()) {
+ if (treeKey->popError()) {
treeKey->setOffset(bookmark);
}
@@ -270,18 +272,18 @@ void VerseTreeKey::setPosition(SW_POSITION p) {
switch (p) {
case POS_TOP:
- Error();
+ popError();
treeKey->setPosition(p);
increment();
decrement();
- Error();
+ popError();
break;
case POS_BOTTOM:
- Error();
+ popError();
treeKey->setPosition(p);
decrement();
increment();
- Error();
+ popError();
break;
case POS_MAXVERSE:
case POS_MAXCHAPTER:
diff --git a/src/mgr/Makefile.am b/src/mgr/Makefile.am
index 10d7158..6acec3a 100644
--- a/src/mgr/Makefile.am
+++ b/src/mgr/Makefile.am
@@ -23,8 +23,8 @@ 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)/versemgr.cpp
-libsword_la_SOURCES += $(mgrdir)/ftptrans.cpp
+libsword_la_SOURCES += $(mgrdir)/versificationmgr.cpp
+libsword_la_SOURCES += $(mgrdir)/remotetrans.cpp
libsword_la_SOURCES += $(mgrdir)/swlocale.cpp
libsword_la_SOURCES += $(mgrdir)/localemgr.cpp
libsword_la_SOURCES += $(mgrdir)/swcacher.cpp
diff --git a/src/mgr/curlftpt.cpp b/src/mgr/curlftpt.cpp
index 7d2fd3c..63eacb1 100644
--- a/src/mgr/curlftpt.cpp
+++ b/src/mgr/curlftpt.cpp
@@ -1,9 +1,10 @@
- /*****************************************************************************
- * CURLFTPTransport functions
+/*****************************************************************************
*
+ * curlftpt.cpp - CURLFTPTransport
*
+ * $Id: curlftpt.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2004-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -19,106 +20,110 @@
*
*/
-
-
#include <curlftpt.h>
#include <fcntl.h>
#include <curl/curl.h>
-#include <curl/types.h>
#include <curl/easy.h>
#include <swlog.h>
-SWORD_NAMESPACE_START
+SWORD_NAMESPACE_START
-struct FtpFile {
- const char *filename;
- FILE *stream;
- SWBuf *destBuf;
-};
+namespace {
+ struct FtpFile {
+ const char *filename;
+ FILE *stream;
+ SWBuf *destBuf;
+ };
-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 CURLFTPTransport_init _CURLFTPTransport_init;
+ // initialize/cleanup SYSTEMWIDE library with life of this static.
+ static class CURLFTPTransport_init {
+ public:
+ CURLFTPTransport_init() {
+ curl_global_init(CURL_GLOBAL_DEFAULT); // curl_easy_init automatically calls it if needed
+ }
-CURLFTPTransport_init::CURLFTPTransport_init() {
- curl_global_init(CURL_GLOBAL_DEFAULT); // curl_easy_init automatically calls it if needed
-}
+ ~CURLFTPTransport_init() {
+ curl_global_cleanup();
+ }
+ } _curlFTPTransport_init;
-CURLFTPTransport_init::~CURLFTPTransport_init() {
- curl_global_cleanup();
-}
-int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) {
- struct FtpFile *out=(struct FtpFile *)stream;
- if (out && !out->stream && !out->destBuf) {
- /* open file for writing */
- out->stream=fopen(out->filename, "wb");
- if (!out->stream)
- return -1; /* failure, can't open file to write */
- }
- if (out->destBuf) {
- int s = out->destBuf->size();
- out->destBuf->size(s+(size*nmemb));
- memcpy(out->destBuf->getRawData()+s, buffer, size*nmemb);
- return nmemb;
+ static int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) {
+ struct FtpFile *out=(struct FtpFile *)stream;
+ if (out && !out->stream && !out->destBuf) {
+ /* open file for writing */
+ out->stream=fopen(out->filename, "wb");
+ if (!out->stream)
+ return -1; /* failure, can't open file to write */
+ }
+ if (out->destBuf) {
+ int s = out->destBuf->size();
+ out->destBuf->size(s+(size*nmemb));
+ memcpy(out->destBuf->getRawData()+s, buffer, size*nmemb);
+ return nmemb;
+ }
+ return fwrite(buffer, size, nmemb, out->stream);
}
- return fwrite(buffer, size, nmemb, out->stream);
-}
-struct MyProgressData {
- StatusReporter *sr;
- bool *term;
-};
+ struct MyProgressData {
+ StatusReporter *sr;
+ bool *term;
+ };
-int my_fprogress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) {
- if (clientp) {
- MyProgressData *pd = (MyProgressData *)clientp;
-SWLog::getSystemLog()->logDebug("CURLFTPTransport report progress: totalSize: %ld; xfered: %ld\n", (long)dltotal, (long)dlnow);
- if (pd->sr) {
- pd->sr->statusUpdate(dltotal, dlnow);
+ static int my_fprogress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) {
+ if (clientp) {
+ MyProgressData *pd = (MyProgressData *)clientp;
+ SWLog::getSystemLog()->logDebug("CURLFTPTransport report progress: totalSize: %ld; xfered: %ld\n", (long)dltotal, (long)dlnow);
+ if (pd->sr) {
+ if (dltotal < 0) dltotal = 0;
+ if (dlnow < 0) dlnow = 0;
+ if (dlnow > dltotal) dlnow = dltotal;
+ pd->sr->update(dltotal, dlnow);
+ }
+ if (*(pd->term)) return 1;
}
- if (*(pd->term)) return 1;
+ return 0;
}
- return 0;
-}
-static int my_trace(CURL *handle, curl_infotype type, unsigned char *data, size_t size, void *userp) {
- SWBuf header;
- (void)userp; /* prevent compiler warning */
- (void)handle; /* prevent compiler warning */
+ static int my_trace(CURL *handle, curl_infotype type, unsigned char *data, size_t size, void *userp) {
+ SWBuf header;
+ (void)userp; /* prevent compiler warning */
+ (void)handle; /* prevent compiler warning */
- switch (type) {
- case CURLINFO_TEXT: header = "TEXT"; break;
- case CURLINFO_HEADER_OUT: header = "=> Send header"; break;
- case CURLINFO_HEADER_IN: header = "<= Recv header"; break;
-
- // these we don't want to log (HUGE)
- case CURLINFO_DATA_OUT: header = "=> Send data";
- case CURLINFO_SSL_DATA_OUT: header = "=> Send SSL data";
- case CURLINFO_DATA_IN: header = "<= Recv data";
- case CURLINFO_SSL_DATA_IN: header = "<= Recv SSL data";
- default: /* in case a new one is introduced to shock us */
+ switch (type) {
+ case CURLINFO_TEXT: header = "TEXT"; break;
+ case CURLINFO_HEADER_OUT: header = "=> Send header"; break;
+ case CURLINFO_HEADER_IN: header = "<= Recv header"; break;
+
+ // these we don't want to log (HUGE)
+ case CURLINFO_DATA_OUT: header = "=> Send data";
+ case CURLINFO_SSL_DATA_OUT: header = "=> Send SSL data";
+ case CURLINFO_DATA_IN: header = "<= Recv data";
+ case CURLINFO_SSL_DATA_IN: header = "<= Recv SSL data";
+ default: /* in case a new one is introduced to shock us */
+ return 0;
+ }
+
+ if (size > 120) size = 120;
+ SWBuf text;
+ text.size(size);
+ memcpy(text.getRawData(), data, size);
+ SWLog::getSystemLog()->logDebug("CURLFTPTransport: %s: %s", header.c_str(), text.c_str());
return 0;
}
-
- if (size > 120) size = 120;
- SWBuf text;
- text.size(size);
- memcpy(text.getRawData(), data, size);
- SWLog::getSystemLog()->logDebug("CURLFTPTransport: %s: %s", header.c_str(), text.c_str());
- return 0;
}
-CURLFTPTransport::CURLFTPTransport(const char *host, StatusReporter *sr) : FTPTransport(host, sr) {
+
+CURLFTPTransport::CURLFTPTransport(const char *host, StatusReporter *sr) : RemoteTransport(host, sr) {
session = (CURL *)curl_easy_init();
}
@@ -156,6 +161,7 @@ char CURLFTPTransport::getURL(const char *destPath, const char *sourceURL, SWBuf
/* Switch on full protocol/debug output */
curl_easy_setopt(session, CURLOPT_VERBOSE, true);
+ curl_easy_setopt(session, CURLOPT_CONNECTTIMEOUT, 45);
/* FTP connection settings */
diff --git a/src/mgr/curlhttpt.cpp b/src/mgr/curlhttpt.cpp
index b736050..5db0ee7 100644
--- a/src/mgr/curlhttpt.cpp
+++ b/src/mgr/curlhttpt.cpp
@@ -1,9 +1,10 @@
- /*****************************************************************************
- * CURLHTTPTransport functions
+/*****************************************************************************
*
+ * curlhttpt.cpp - CURLHTTPTransport
*
+ * $Id: curlhttpt.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2004-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,7 +26,6 @@
#include <cctype>
#include <curl/curl.h>
-#include <curl/types.h>
#include <curl/easy.h>
#include <swlog.h>
@@ -34,84 +34,77 @@
using std::vector;
-SWORD_NAMESPACE_START
-
-
-struct FtpFile {
- const char *filename;
- FILE *stream;
- SWBuf *destBuf;
-};
+SWORD_NAMESPACE_START
-int my_httpfwrite(void *buffer, size_t size, size_t nmemb, void *stream);
-int my_httpfprogress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
+namespace {
-static CURLHTTPTransport_init _CURLHTTPTransport_init;
+ struct FtpFile {
+ const char *filename;
+ FILE *stream;
+ SWBuf *destBuf;
+ };
-CURLHTTPTransport_init::CURLHTTPTransport_init() {
- //curl_global_init(CURL_GLOBAL_DEFAULT); // curl_easy_init automatically calls it if needed
-}
-CURLHTTPTransport_init::~CURLHTTPTransport_init() {
-// CURLFTPT d-tor cleans this up
-// curl_global_cleanup();
-}
-
-int my_httpfwrite(void *buffer, size_t size, size_t nmemb, void *stream) {
- struct FtpFile *out=(struct FtpFile *)stream;
- if (out && !out->stream && !out->destBuf) {
- /* open file for writing */
- out->stream=fopen(out->filename, "wb");
- if (!out->stream)
- return -1; /* failure, can't open file to write */
- }
- if (out->destBuf) {
- int s = out->destBuf->size();
- out->destBuf->size(s+(size*nmemb));
- memcpy(out->destBuf->getRawData()+s, buffer, size*nmemb);
- return nmemb;
+ static int my_httpfwrite(void *buffer, size_t size, size_t nmemb, void *stream) {
+ struct FtpFile *out=(struct FtpFile *)stream;
+ if (out && !out->stream && !out->destBuf) {
+ /* open file for writing */
+ out->stream=fopen(out->filename, "wb");
+ if (!out->stream)
+ return -1; /* failure, can't open file to write */
+ }
+ if (out->destBuf) {
+ int s = out->destBuf->size();
+ out->destBuf->size(s+(size*nmemb));
+ memcpy(out->destBuf->getRawData()+s, buffer, size*nmemb);
+ return nmemb;
+ }
+ return fwrite(buffer, size, nmemb, out->stream);
}
- return fwrite(buffer, size, nmemb, out->stream);
-}
-int my_httpfprogress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) {
- if (clientp) {
- ((StatusReporter *)clientp)->statusUpdate(dltotal, dlnow);
+ static int my_httpfprogress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) {
+ if (clientp) {
+ if (dltotal < 0) dltotal = 0;
+ if (dlnow < 0) dlnow = 0;
+ if (dlnow > dltotal) dlnow = dltotal;
+ ((StatusReporter *)clientp)->update(dltotal, dlnow);
+ }
+ return 0;
}
- return 0;
-}
-static int myhttp_trace(CURL *handle, curl_infotype type, unsigned char *data, size_t size, void *userp) {
- SWBuf header;
- (void)userp; /* prevent compiler warning */
- (void)handle; /* prevent compiler warning */
+ static int myhttp_trace(CURL *handle, curl_infotype type, unsigned char *data, size_t size, void *userp) {
+ SWBuf header;
+ (void)userp; /* prevent compiler warning */
+ (void)handle; /* prevent compiler warning */
- switch (type) {
- case CURLINFO_TEXT: header = "TEXT"; break;
- case CURLINFO_HEADER_OUT: header = "=> Send header"; break;
- case CURLINFO_HEADER_IN: header = "<= Recv header"; break;
+ switch (type) {
+ case CURLINFO_TEXT: header = "TEXT"; break;
+ case CURLINFO_HEADER_OUT: header = "=> Send header"; break;
+ case CURLINFO_HEADER_IN: header = "<= Recv header"; break;
+
+ // these we don't want to log (HUGE)
+ case CURLINFO_DATA_OUT: header = "=> Send data";
+ case CURLINFO_SSL_DATA_OUT: header = "=> Send SSL data";
+ case CURLINFO_DATA_IN: header = "<= Recv data";
+ case CURLINFO_SSL_DATA_IN: header = "<= Recv SSL data";
+ default: /* in case a new one is introduced to shock us */
+ return 0;
+ }
- // these we don't want to log (HUGE)
- case CURLINFO_DATA_OUT: header = "=> Send data";
- case CURLINFO_SSL_DATA_OUT: header = "=> Send SSL data";
- case CURLINFO_DATA_IN: header = "<= Recv data";
- case CURLINFO_SSL_DATA_IN: header = "<= Recv SSL data";
- default: /* in case a new one is introduced to shock us */
+ if (size > 120) size = 120;
+ SWBuf text;
+ text.size(size);
+ memcpy(text.getRawData(), data, size);
+ SWLog::getSystemLog()->logDebug("CURLHTTPTransport: %s: %s", header.c_str(), text.c_str());
return 0;
}
-
- if (size > 120) size = 120;
- SWBuf text;
- text.size(size);
- memcpy(text.getRawData(), data, size);
- SWLog::getSystemLog()->logDebug("CURLHTTPTransport: %s: %s", header.c_str(), text.c_str());
- return 0;
}
-CURLHTTPTransport::CURLHTTPTransport(const char *host, StatusReporter *sr) : FTPTransport(host, sr) {
+
+CURLHTTPTransport::CURLHTTPTransport(const char *host, StatusReporter *sr) : RemoteTransport(host, sr) {
session = (CURL *)curl_easy_init();
}
@@ -136,6 +129,7 @@ char CURLHTTPTransport::getURL(const char *destPath, const char *sourceURL, SWBu
if (!passive)
curl_easy_setopt(session, CURLOPT_FTPPORT, "-");
curl_easy_setopt(session, CURLOPT_NOPROGRESS, 0);
+ curl_easy_setopt(session, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(session, CURLOPT_PROGRESSDATA, statusReporter);
curl_easy_setopt(session, CURLOPT_PROGRESSFUNCTION, my_httpfprogress);
curl_easy_setopt(session, CURLOPT_DEBUGFUNCTION, myhttp_trace);
@@ -144,7 +138,11 @@ char CURLHTTPTransport::getURL(const char *destPath, const char *sourceURL, SWBu
/* Switch on full protocol/debug output */
curl_easy_setopt(session, CURLOPT_VERBOSE, true);
+ curl_easy_setopt(session, CURLOPT_CONNECTTIMEOUT, 45);
+ /* Disable checking host certificate */
+ curl_easy_setopt(session, CURLOPT_SSL_VERIFYPEER, false);
+
/* FTP connection settings */
#if (LIBCURL_VERSION_MAJOR > 7) || \
@@ -206,7 +204,7 @@ vector<struct DirEntry> CURLHTTPTransport::getDirList(const char *dirURL) {
SWBuf dirBuf;
const char *pBuf;
char *pBufRes;
- char possibleName[400];
+ SWBuf possibleName;
double fSize;
int possibleNameLength = 0;
@@ -215,10 +213,12 @@ vector<struct DirEntry> CURLHTTPTransport::getDirList(const char *dirURL) {
while (pBuf != NULL) {
pBuf += 9;//move to the start of the actual name.
pBufRes = (char *)strchr(pBuf, '\"');//Find the end of the possible file name
+ if (!pBufRes)
+ break;
possibleNameLength = pBufRes - pBuf;
- sprintf(possibleName, "%.*s", possibleNameLength, pBuf);
+ possibleName.setFormatted("%.*s", possibleNameLength, pBuf);
if (isalnum(possibleName[0])) {
- SWLog::getSystemLog()->logDebug("getDirListHTTP: Found a file: %s", possibleName);
+ SWLog::getSystemLog()->logDebug("getDirListHTTP: Found a file: %s", possibleName.c_str());
pBuf = pBufRes;
pBufRes = (char *)findSizeStart(pBuf);
fSize = 0;
@@ -229,13 +229,13 @@ vector<struct DirEntry> CURLHTTPTransport::getDirList(const char *dirURL) {
fSize *= 1024;
else if (pBufRes[0] == 'M')
fSize *= 1048576;
+ pBuf = pBufRes;
}
struct DirEntry i;
i.name = possibleName;
- i.size = fSize;
- i.isDirectory = (possibleName[possibleNameLength-1] == '/');
+ i.size = (long unsigned int)fSize;
+ i.isDirectory = possibleName.endsWith("/");
dirList.push_back(i);
- pBuf = pBufRes;
} else {
pBuf += possibleNameLength;
}
diff --git a/src/mgr/encfiltmgr.cpp b/src/mgr/encfiltmgr.cpp
index cb6dab4..24938bc 100644
--- a/src/mgr/encfiltmgr.cpp
+++ b/src/mgr/encfiltmgr.cpp
@@ -1,9 +1,12 @@
/******************************************************************************
- * 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)
+ * encfiltmgr.cpp - implementaion of class EncodingFilterMgr, subclass of
+ * SWFilterMgr, used to transcode all module text to a
+ * requested encoding
+ *
+ * $Id: encfiltmgr.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -22,6 +25,7 @@
#include <encfiltmgr.h>
#include <utilstr.h>
+#include <scsuutf8.h>
#include <latin1utf8.h>
#include <unicodertf.h>
@@ -32,65 +36,65 @@
#include <swmgr.h>
+
SWORD_NAMESPACE_START
+
/******************************************************************************
* EncodingFilterMgr Constructor - initializes instance of EncodingFilterMgr
*
* ENT:
* enc - Encoding format to emit
*/
+EncodingFilterMgr::EncodingFilterMgr(char enc)
+ : SWFilterMgr() {
-EncodingFilterMgr::EncodingFilterMgr (char enc)
- : SWFilterMgr() {
-
- 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;
- }
+ 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 (latin1utf8)
- delete latin1utf8;
- if (targetenc)
- delete targetenc;
+ delete scsuutf8;
+ delete latin1utf8;
+ 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);
+ 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);
+ if (targetenc)
+ module->addEncodingFilter(targetenc);
}
+
/******************************************************************************
* EncodingFilterMgr::Encoding - sets/gets encoding
*
@@ -99,49 +103,41 @@ void EncodingFilterMgr::AddEncodingFilters(SWModule *module, ConfigEntMap &secti
* 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;
+ 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
index 820440b..d801aaa 100644
--- a/src/mgr/filemgr.cpp
+++ b/src/mgr/filemgr.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
- * filemgr.cpp - implementation of class FileMgr used for pooling file
- * handles
*
- * $Id: filemgr.cpp 2495 2009-12-24 22:22:16Z scribe $
+ * filemgr.cpp - implementation of class FileMgr used for pooling file
+ * handles
*
- * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: filemgr.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -540,12 +541,18 @@ int FileMgr::removeDir(const char *targetDir) {
FileMgr::removeFile(targetPath.c_str());
}
else {
- removeDir(targetPath.c_str());
+ FileMgr::removeDir(targetPath.c_str());
}
}
}
closedir(dir);
- removeFile(targetDir);
+ FileMgr::removeFile(targetDir);
+/*
+ int status = FileMgr::removeFile(targetDir);
+ int stuff = errno;
+ char *err = strerror(errno);
+ int x = stuff;
+*/
}
return 0;
}
diff --git a/src/mgr/ftplibftpt.cpp b/src/mgr/ftplibftpt.cpp
index fe23048..f1d1655 100644
--- a/src/mgr/ftplibftpt.cpp
+++ b/src/mgr/ftplibftpt.cpp
@@ -1,9 +1,10 @@
- /*****************************************************************************
- * FTPLibFTPTransport functions
+/*****************************************************************************
*
+ * ftplibftpt.cpp - FTPLibFTPTransport
*
+ * $Id: ftplibftpt.cpp 2983 2013-09-15 16:22:32Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2004-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -18,7 +19,6 @@
* General Public License for more details.
*
*/
-
#include <stdio.h>
#include <fcntl.h>
@@ -34,41 +34,58 @@ SWORD_NAMESPACE_START
namespace {
-struct MyProgressData {
- StatusReporter *sr;
- long totalSize;
- bool *term;
-};
-
-int my_fprogress(netbuf *nControl, int xfered, void *arg) {
- if (arg) {
- MyProgressData *pd = (MyProgressData *)arg;
-SWLog::getSystemLog()->logDebug("FTPLibFTPTransport report progress: totalSize: %ld; xfered: %d\n", pd->totalSize, xfered);
- if (pd->sr) {
- pd->sr->statusUpdate(pd->totalSize, xfered);
- }
- if (*(pd->term)) return 0;
+ struct MyProgressData {
+ StatusReporter *sr;
+ long totalSize;
+ bool *term;
+ };
+
+ static int my_swbufwriter(netbuf *nControl, void *buffer, size_t size, void *swbuf) {
+ SWBuf &output = *(SWBuf *)swbuf;
+ int s = output.size();
+ output.size(s+size);
+ memcpy(output.getRawData()+s, buffer, size);
+ return size;
}
- return 1;
-}
-}
+#if defined(__GNUC__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+ static int my_fprogress(netbuf *nControl, int xfered, void *arg) {
+ if (arg) {
+ MyProgressData *pd = (MyProgressData *)arg;
+ SWLog::getSystemLog()->logDebug("FTPLibFTPTransport report progress: totalSize: %ld; xfered: %d\n", pd->totalSize, xfered);
+ if (pd->sr) {
+ pd->sr->statusUpdate(pd->totalSize, xfered);
+ }
+ if (*(pd->term)) return 0;
+ }
+ return 1;
+ }
+#if defined(__GNUC__)
+#pragma GCC diagnostic pop
+#endif
-static FTPLibFTPTransport_init _FTPLibFTPTransport_init;
+ // initialize/cleanup SYSTEMWIDE library with life of this static.
+ static class FTPLibFTPTransport_init {
+ public:
+ FTPLibFTPTransport_init() {
+ FtpInit();
+ }
+ ~FTPLibFTPTransport_init() {
+ }
-FTPLibFTPTransport_init::FTPLibFTPTransport_init() {
- FtpInit();
-}
+ } _ftpLibFTPTransport_init;
-FTPLibFTPTransport_init::~FTPLibFTPTransport_init() {
}
-FTPLibFTPTransport::FTPLibFTPTransport(const char *host, StatusReporter *sr) : FTPTransport(host, sr) {
+FTPLibFTPTransport::FTPLibFTPTransport(const char *host, StatusReporter *sr) : RemoteTransport(host, sr) {
ftpConnection = 0;
}
@@ -85,6 +102,8 @@ char FTPLibFTPTransport::assureLoggedIn() {
if (ftpConnection == 0) {
SWLog::getSystemLog()->logDebug("connecting to host: %s...\n", host.c_str());
if (FtpConnect(host, &ftpConnection)) {
+ FtpOptions(FTPLIB_CONNMODE, (passive) ? FTPLIB_PASSIVE : FTPLIB_PORT, ftpConnection);
+
SWLog::getSystemLog()->logDebug("connected. logging in...\n");
if (FtpLogin(u.c_str(), p.c_str(), ftpConnection)) {
SWLog::getSystemLog()->logDebug("logged in.\n");
@@ -103,14 +122,6 @@ char FTPLibFTPTransport::assureLoggedIn() {
return retVal;
}
-// yeah yeah, I know I know. Compile with curl support if you don't like it
-#pragma GCC diagnostic ignored "-Wall"
-void my_tmpnam(char *tmpName) {
- tmpName = tmpnam(tmpName);
-}
-#pragma GCC diagnostic warning "-Wall"
-
-
char FTPLibFTPTransport::getURL(const char *destPath, const char *sourceURL, SWBuf *destBuf) {
@@ -128,29 +139,22 @@ char FTPLibFTPTransport::getURL(const char *destPath, const char *sourceURL, SWB
if (!destBuf) {
outFile = destPath;
}
- else {
-#ifdef ANDROID
- outFile = "/sdcard/sword/InstallMgr/swtmpbuf.out";
-#else
- char tmpName[128];
- my_tmpnam(tmpName);
- outFile = tmpName;
-#endif
- }
sourcePath << (6 + host.length()); // shift << "ftp://hostname";
- SWLog::getSystemLog()->logDebug("getting file %s to %s\n", sourcePath.c_str(), outFile.c_str());
- if (passive)
- FtpOptions(FTPLIB_CONNMODE, FTPLIB_PASSIVE, ftpConnection);
- else
- FtpOptions(FTPLIB_CONNMODE, FTPLIB_PORT, ftpConnection);
-
+ SWLog::getSystemLog()->logDebug("getting file %s to %s\n", sourcePath.c_str(), destBuf ? "*internal buffer*" : outFile.c_str());
struct MyProgressData pd;
pd.sr = statusReporter;
pd.term = &term;
pd.totalSize = 0;
- // !!!WDG also want to set callback options
+ if (destBuf) {
+ FtpOptions(FTPLIB_CALLBACK_WRITER, (long)&my_swbufwriter, ftpConnection);
+ FtpOptions(FTPLIB_CALLBACK_WRITERARG, (long)destBuf, ftpConnection);
+ }
+ else {
+ FtpOptions(FTPLIB_CALLBACK_WRITER, 0L, ftpConnection);
+ }
+
FtpOptions(FTPLIB_CALLBACK, (long)&my_fprogress, ftpConnection);
FtpOptions(FTPLIB_CALLBACKARG, (long)&pd, ftpConnection);
FtpOptions(FTPLIB_CALLBACKBYTES, (long)2048, ftpConnection);
@@ -159,29 +163,15 @@ char FTPLibFTPTransport::getURL(const char *destPath, const char *sourceURL, SWB
// SWLog::getSystemLog()->logDebug("getting test directory %s\n", sourcePath.c_str());
// FtpDir(NULL, sourcePath, ftpConnection);
SWLog::getSystemLog()->logDebug("getting real directory %s\n", sourcePath.c_str());
- retVal = FtpDir(outFile.c_str(), sourcePath, ftpConnection) - 1;
- SWLog::getSystemLog()->logDebug("got real directory %s to %s\n", sourcePath.c_str(), outFile.c_str());
+ retVal = FtpDir(destBuf ? 0 : outFile.c_str(), sourcePath, ftpConnection) - 1;
+ SWLog::getSystemLog()->logDebug("got real directory %s to %s\n", sourcePath.c_str(), destBuf ? "*internal buffer*" : outFile.c_str());
}
else {
SWLog::getSystemLog()->logDebug("getting file %s\n", sourcePath.c_str());
int size;
FtpSize(sourcePath, &size, FTPLIB_IMAGE, ftpConnection);
pd.totalSize = size;
- retVal = FtpGet(outFile.c_str(), sourcePath, FTPLIB_IMAGE, ftpConnection) - 1;
- }
-
- // Is there a way to FTPGet directly to a buffer?
- // If not, we probably want to add x-platform way to open a tmp file with FileMgr
- // Currently outFile is set to tmpFile above sortof unsafe
- if (destBuf) {
- SWLog::getSystemLog()->logDebug("filling destBuf\n");
- FileDesc *fd = FileMgr::getSystemFileMgr()->open(outFile.c_str(), FileMgr::RDONLY);
- long size = fd->seek(0, SEEK_END);
- fd->seek(0, SEEK_SET);
- destBuf->size(size);
- fd->read(destBuf->getRawData(), size);
- FileMgr::getSystemFileMgr()->close(fd);
- FileMgr::removeFile(outFile.c_str());
+ retVal = FtpGet(destBuf ? 0 : outFile.c_str(), sourcePath, FTPLIB_IMAGE, ftpConnection) - 1;
}
SWLog::getSystemLog()->logDebug("FTPLibFTPTransport - returning: %d\n", retVal);
diff --git a/src/mgr/installmgr.cpp b/src/mgr/installmgr.cpp
index b75df6f..1e83db5 100644
--- a/src/mgr/installmgr.cpp
+++ b/src/mgr/installmgr.cpp
@@ -1,10 +1,10 @@
- /*****************************************************************************
- * InstallMgr functions to be made into something usefully exposed by
- * master Glassey
+/*****************************************************************************
*
+ * installmgr.cpp - InstallMgr functions
*
+ * $Id: installmgr.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -20,8 +20,6 @@
*
*/
-
-
#ifndef EXCLUDEZLIB
extern "C" {
#include <untgz.h>
@@ -51,23 +49,26 @@ extern "C" {
#endif
#include <iostream>
+
+
+using std::map;
+
+
SWORD_NAMESPACE_START
namespace {
-void removeTrailingSlash(SWBuf &buf) {
- int len = buf.size();
- if ((buf[len-1] == '/')
- || (buf[len-1] == '\\'))
- buf.size(len-1);
-}
-
-const char *masterRepoList = "masterRepoList.conf";
+ static void removeTrailingSlash(SWBuf &buf) {
+ int len = buf.size();
+ if ((buf[len-1] == '/')
+ || (buf[len-1] == '\\'))
+ buf.size(len-1);
+ }
-};
+ static const char *masterRepoList = "masterRepoList.conf";
+}
-using std::map;
const int InstallMgr::MODSTAT_OLDER = 0x001;
const int InstallMgr::MODSTAT_SAMEVERSION = 0x002;
@@ -76,10 +77,11 @@ const int InstallMgr::MODSTAT_NEW = 0x008;
const int InstallMgr::MODSTAT_CIPHERED = 0x010;
const int InstallMgr::MODSTAT_CIPHERKEYPRESENT = 0x020;
-// override this method and provide your own custom FTPTransport subclass
+
+// override this method and provide your own custom RemoteTransport subclass
// here we try a couple defaults if sword was compiled with support for them.
// see these classes for examples of how to make your own
-FTPTransport *InstallMgr::createFTPTransport(const char *host, StatusReporter *statusReporter) {
+RemoteTransport *InstallMgr::createFTPTransport(const char *host, StatusReporter *statusReporter) {
#ifdef CURLAVAILABLE
return new CURLFTPTransport(host, statusReporter);
#else
@@ -87,7 +89,8 @@ FTPTransport *InstallMgr::createFTPTransport(const char *host, StatusReporter *s
#endif
}
-FTPTransport *InstallMgr::createHTTPTransport(const char *host, StatusReporter *statusReporter) {
+
+RemoteTransport *InstallMgr::createHTTPTransport(const char *host, StatusReporter *statusReporter) {
#ifdef CURLAVAILABLE
return new CURLHTTPTransport(host, statusReporter);
#else
@@ -96,7 +99,6 @@ FTPTransport *InstallMgr::createHTTPTransport(const char *host, StatusReporter *
}
-
InstallMgr::InstallMgr(const char *privatePath, StatusReporter *sr, SWBuf u, SWBuf p) {
userDisclaimerConfirmed = false;
statusReporter = sr;
@@ -125,6 +127,7 @@ InstallMgr::~InstallMgr() {
clearSources();
}
+
void InstallMgr::clearSources() {
for (InstallSourceMap::iterator it = sources.begin(); it != sources.end(); ++it) {
delete it->second;
@@ -132,6 +135,7 @@ void InstallMgr::clearSources() {
sources.clear();
}
+
void InstallMgr::readInstallConf() {
if (installConf) delete installConf;
@@ -147,6 +151,7 @@ void InstallMgr::readInstallConf() {
ConfigEntMap::iterator sourceEnd;
if (confSection != installConf->Sections.end()) {
+
sourceBegin = confSection->second.lower_bound("FTPSource");
sourceEnd = confSection->second.upper_bound("FTPSource");
@@ -158,6 +163,21 @@ void InstallMgr::readInstallConf() {
is->localShadow = (SWBuf)privatePath + "/" + is->uid;
sourceBegin++;
}
+
+#ifdef CURLSFTPAVAILABLE
+ sourceBegin = confSection->second.lower_bound("SFTPSource");
+ sourceEnd = confSection->second.upper_bound("SFTPSource");
+
+ while (sourceBegin != sourceEnd) {
+ InstallSource *is = new InstallSource("SFTP", sourceBegin->second.c_str());
+ sources[is->caption] = is;
+ SWBuf parent = (SWBuf)privatePath + "/" + is->uid + "/file";
+ FileMgr::createParent(parent.c_str());
+ is->localShadow = (SWBuf)privatePath + "/" + is->uid;
+ sourceBegin++;
+ }
+#endif // CURLSFTPAVAILABLE
+
sourceBegin = confSection->second.lower_bound("HTTPSource");
sourceEnd = confSection->second.upper_bound("HTTPSource");
@@ -169,6 +189,18 @@ void InstallMgr::readInstallConf() {
is->localShadow = (SWBuf)privatePath + "/" + is->uid;
sourceBegin++;
}
+
+ sourceBegin = confSection->second.lower_bound("HTTPSSource");
+ sourceEnd = confSection->second.upper_bound("HTTPSSource");
+
+ while (sourceBegin != sourceEnd) {
+ InstallSource *is = new InstallSource("HTTPS", sourceBegin->second.c_str());
+ sources[is->caption] = is;
+ SWBuf parent = (SWBuf)privatePath + "/" + is->uid + "/file";
+ FileMgr::createParent(parent.c_str());
+ is->localShadow = (SWBuf)privatePath + "/" + is->uid;
+ sourceBegin++;
+ }
}
defaultMods.clear();
@@ -270,19 +302,24 @@ int InstallMgr::removeModule(SWMgr *manager, const char *moduleName) {
// TODO: rename to netCopy
-int InstallMgr::ftpCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer, const char *suffix) {
-SWLog::getSystemLog()->logDebug("netCopy: %s, %s, %s, %c, %s", (is?is->source.c_str():"null"), src, (dest?dest:"null"), (dirTransfer?'t':'f'), (suffix?suffix:"null"));
+int InstallMgr::remoteCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer, const char *suffix) {
+SWLog::getSystemLog()->logDebug("remoteCopy: %s, %s, %s, %c, %s", (is?is->source.c_str():"null"), src, (dest?dest:"null"), (dirTransfer?'t':'f'), (suffix?suffix:"null"));
// assert user disclaimer has been confirmed
if (!isUserDisclaimerConfirmed()) return -1;
int retVal = 0;
- FTPTransport *trans = 0;
- if (is->type == "FTP") {
+ RemoteTransport *trans = 0;
+ if (is->type == "FTP"
+#ifdef CURLSFTPAVAILABLE
+ || is->type == "SFTP"
+#endif
+ ) {
+
trans = createFTPTransport(is->source, statusReporter);
trans->setPassive(passive);
}
- else if (is->type == "HTTP") {
+ else if (is->type == "HTTP" || is->type == "HTTPS") {
trans = createHTTPTransport(is->source, statusReporter);
}
transport = trans; // set classwide current transport for other thread terminate() call
@@ -295,7 +332,22 @@ SWLog::getSystemLog()->logDebug("netCopy: %s, %s, %s, %c, %s", (is?is->source.c_
trans->setPasswd(p);
}
- SWBuf urlPrefix = (SWBuf)((is->type == "HTTP") ? "http://" : "ftp://") + is->source;
+ SWBuf urlPrefix;
+ if (is->type == "HTTP") {
+ urlPrefix = (SWBuf) "http://";
+ }
+ else if (is->type == "HTTPS") {
+ urlPrefix = (SWBuf) "https://";
+ }
+#ifdef CURLSFTPAVAILABLE
+ else if (is->type == "SFTP") {
+ urlPrefix = (SWBuf) "sftp://";
+ }
+#endif
+ else {
+ urlPrefix = (SWBuf) "ftp://";
+ }
+ urlPrefix.append(is->source);
// let's be sure we can connect. This seems to be necessary but sucks
// SWBuf url = urlPrefix + is->directory.c_str() + "/"; //dont forget the final slash
@@ -329,7 +381,7 @@ SWLog::getSystemLog()->logDebug("netCopy: %s, %s, %s, %c, %s", (is?is->source.c_
}
}
SWTRY {
- FTPTransport *deleteMe = trans;
+ RemoteTransport *deleteMe = trans;
// do this order for threadsafeness
// (see terminate())
trans = transport = 0;
@@ -386,7 +438,7 @@ int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const ch
if (is) {
while (fileBegin != fileEnd) { // netCopy each file first
buffer = sourceDir + fileBegin->second.c_str();
- if (ftpCopy(is, fileBegin->second.c_str(), buffer.c_str())) {
+ if (remoteCopy(is, fileBegin->second.c_str(), buffer.c_str())) {
aborted = true;
break; // user aborted
}
@@ -446,7 +498,7 @@ int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const ch
SWLog::getSystemLog()->logDebug("***** relativePath: %s \n", relativePath.c_str());
if (is) {
- if (ftpCopy(is, relativePath.c_str(), absolutePath.c_str(), true)) {
+ if (remoteCopy(is, relativePath.c_str(), absolutePath.c_str(), true)) {
aborted = true; // user aborted
}
}
@@ -498,6 +550,7 @@ int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const ch
return 1;
}
+
int InstallMgr::refreshRemoteSource(InstallSource *is) {
// assert user disclaimer has been confirmed
@@ -516,7 +569,7 @@ int InstallMgr::refreshRemoteSource(InstallSource *is) {
#ifndef EXCLUDEZLIB
SWBuf archive = root + "/mods.d.tar.gz";
- errorCode = ftpCopy(is, "mods.d.tar.gz", archive.c_str(), false);
+ errorCode = remoteCopy(is, "mods.d.tar.gz", archive.c_str(), false);
if (!errorCode) { //sucessfully downloaded the tar,gz of module configs
FileDesc *fd = FileMgr::getSystemFileMgr()->open(archive.c_str(), FileMgr::RDONLY);
untargz(fd->getFd(), root.c_str());
@@ -524,7 +577,7 @@ int InstallMgr::refreshRemoteSource(InstallSource *is) {
}
else
#endif
- errorCode = ftpCopy(is, "mods.d", target.c_str(), true, ".conf"); //copy the whole directory
+ errorCode = remoteCopy(is, "mods.d", target.c_str(), true, ".conf"); //copy the whole directory
is->flush();
return errorCode;
@@ -535,6 +588,7 @@ bool InstallMgr::isDefaultModule(const char *modName) {
return defaultMods.count(modName);
}
+
/************************************************************************
* getModuleStatus - compare the modules of two SWMgrs and return a
* vector describing the status of each. See MODSTAT_*
@@ -603,7 +657,7 @@ int InstallMgr::refreshRemoteSourceConfiguration() {
InstallSource is("FTP");
is.source = "ftp.crosswire.org";
is.directory = "/pub/sword";
- int errorCode = ftpCopy(&is, masterRepoList, masterRepoListPath.c_str(), false);
+ int errorCode = remoteCopy(&is, masterRepoList, masterRepoListPath.c_str(), false);
if (!errorCode) { //sucessfully downloaded the repo list
SWConfig masterList(masterRepoListPath);
SectionMap::iterator sections = masterList.Sections.find("Repos");
diff --git a/src/mgr/localemgr.cpp b/src/mgr/localemgr.cpp
index 628d271..90d4716 100644
--- a/src/mgr/localemgr.cpp
+++ b/src/mgr/localemgr.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
- * localemgr.cpp - implementation of class LocaleMgr used to interact with
- * registered locales for a sword installation
*
- * $Id: localemgr.cpp 2499 2010-01-02 04:51:05Z scribe $
+ * localemgr.cpp - implementation of class LocaleMgr used to interact with
+ * registered locales for a SWORD installation
*
- * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: localemgr.cpp 3005 2014-01-09 04:06:11Z greg.hellings $
+ *
+ * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -39,8 +40,10 @@
SWORD_NAMESPACE_START
+
LocaleMgr *LocaleMgr::systemLocaleMgr = 0;
+
class __staticsystemLocaleMgr {
public:
__staticsystemLocaleMgr() { }
@@ -261,12 +264,12 @@ void LocaleMgr::setDefaultLocaleName(const char *name) {
stdstr(&defaultLocaleName, tmplang);
// First check for what we ask for
- if (!getLocale(tmplang)) {
+ if (locales->find(tmplang) == locales->end()) {
// check for locale without country
char *nocntry=0;
stdstr(&nocntry, tmplang);
strtok(nocntry, "_");
- if (getLocale(nocntry)) {
+ if (locales->find(nocntry) != locales->end()) {
stdstr(&defaultLocaleName, nocntry);
}
delete [] nocntry;
@@ -274,4 +277,6 @@ void LocaleMgr::setDefaultLocaleName(const char *name) {
delete [] tmplang;
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/mgr/markupfiltmgr.cpp b/src/mgr/markupfiltmgr.cpp
index 5dca845..fb12583 100644
--- a/src/mgr/markupfiltmgr.cpp
+++ b/src/mgr/markupfiltmgr.cpp
@@ -1,9 +1,12 @@
/******************************************************************************
- * 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)
+ * markupfiltmgr.cpp - implementaion of class MarkupFilterMgr, subclass of
+ * used to transcode all module text to a requested
+ * markup
+ *
+ * $Id: markupfiltmgr.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,7 +30,6 @@
#include <gbfthml.h>
#include <thmlhtml.h>
#include <gbfhtml.h>
-#include <plainhtml.h>
#include <thmlhtmlhref.h>
#include <gbfhtmlhref.h>
#include <teihtmlhref.h>
@@ -43,13 +45,19 @@
#include <thmlwebif.h>
#include <osiswebif.h>
#include <swmodule.h>
+#include <thmlxhtml.h>
+#include <gbfxhtml.h>
+#include <osisxhtml.h>
+#include <teixhtml.h>
#include <markupfiltmgr.h>
#include <swmgr.h>
+
SWORD_NAMESPACE_START
+
/******************************************************************************
* MarkupFilterMgr Constructor - initializes instance of MarkupFilterMgr
*
@@ -58,12 +66,12 @@ SWORD_NAMESPACE_START
* mark - Markup format to emit
*/
-MarkupFilterMgr::MarkupFilterMgr (char mark, char enc)
- : EncodingFilterMgr(enc) {
+MarkupFilterMgr::MarkupFilterMgr(char mark, char enc)
+ : EncodingFilterMgr(enc) {
- markup = mark;
+ markup = mark;
- CreateFilters(markup);
+ CreateFilters(markup);
}
@@ -72,18 +80,14 @@ MarkupFilterMgr::MarkupFilterMgr (char mark, char enc)
*/
MarkupFilterMgr::~MarkupFilterMgr() {
- if (fromthml)
- delete (fromthml);
- if (fromgbf)
- delete (fromgbf);
- if (fromplain)
- delete (fromplain);
- if (fromosis)
- delete (fromosis);
- if (fromtei)
- delete (fromtei);
+ delete fromthml;
+ delete fromgbf;
+ delete fromplain;
+ delete fromosis;
+ delete fromtei;
}
+
/******************************************************************************
* MarkupFilterMgr::Markup - sets/gets markup
*
@@ -92,204 +96,224 @@ MarkupFilterMgr::~MarkupFilterMgr() {
* 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;
- SWFilter * oldtei = fromtei;
-
- 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;
- }
- case FMT_TEI:
- if (oldtei != fromtei) {
- if (oldtei) {
- if (!fromtei) {
- module->second->RemoveRenderFilter(oldtei);
- }
- else {
- module->second->ReplaceRenderFilter(oldtei, fromtei);
- }
- }
- else if (fromtei) {
- module->second->AddRenderFilter(fromtei);
- }
- break;
- }
- }
-
- if (oldthml)
- delete oldthml;
- if (oldgbf)
- delete oldgbf;
- if (oldplain)
- delete oldplain;
- if (oldosis)
- delete oldosis;
- if (oldtei)
- delete oldtei;
- }
- return markup;
+ if (mark && mark != markup) {
+ markup = mark;
+ ModMap::const_iterator module;
+
+ SWFilter *oldplain = fromplain;
+ SWFilter *oldthml = fromthml;
+ SWFilter *oldgbf = fromgbf;
+ SWFilter *oldosis = fromosis;
+ SWFilter *oldtei = fromtei;
+
+ CreateFilters(markup);
+
+ for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); ++module) {
+ switch (module->second->getMarkup()) {
+ 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;
+
+ case FMT_TEI:
+ if (oldtei != fromtei) {
+ if (oldtei) {
+ if (!fromtei) {
+ module->second->removeRenderFilter(oldtei);
+ }
+ else {
+ module->second->replaceRenderFilter(oldtei, fromtei);
+ }
+ }
+ else if (fromtei) {
+ module->second->addRenderFilter(fromtei);
+ }
+ }
+ break;
+ }
+ }
+
+ delete oldthml;
+ delete oldgbf;
+ delete oldplain;
+ delete oldosis;
+ delete oldtei;
+ }
+ 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;
- case FMT_TEI:
- if (fromtei)
- module->AddRenderFilter(fromtei);
- break;
- }
+ switch (module->getMarkup()) {
+ 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;
+ case FMT_TEI:
+ if (fromtei)
+ module->addRenderFilter(fromtei);
+ break;
+ }
}
+
void MarkupFilterMgr::CreateFilters(char markup) {
- switch (markup) {
- case FMT_PLAIN:
- fromplain = NULL;
- fromthml = new ThMLPlain();
- fromgbf = new GBFPlain();
- fromosis = new OSISPlain();
- fromtei = new TEIPlain();
- break;
- case FMT_THML:
- fromplain = NULL;
- fromthml = NULL;
- fromgbf = new GBFThML();
- fromosis = NULL;
- fromtei = NULL;
- break;
- case FMT_GBF:
- fromplain = NULL;
- fromthml = new ThMLGBF();
- fromgbf = NULL;
- fromosis = NULL;
- fromtei = NULL;
- break;
- case FMT_HTML:
- fromplain = new PLAINHTML();
- fromthml = new ThMLHTML();
- fromgbf = new GBFHTML();
- fromosis = NULL;
- fromtei = NULL;
- break;
- case FMT_HTMLHREF:
- fromplain = new PLAINHTML();
- fromthml = new ThMLHTMLHREF();
- fromgbf = new GBFHTMLHREF();
- fromosis = new OSISHTMLHREF();
- fromtei = new TEIHTMLHREF();
- break;
- case FMT_RTF:
- fromplain = NULL;
- fromthml = new ThMLRTF();
- fromgbf = new GBFRTF();
- fromosis = new OSISRTF();
- fromtei = new TEIRTF();
- break;
- case FMT_OSIS:
- fromplain = NULL;
- fromthml = new ThMLOSIS();
- fromgbf = new GBFOSIS();
- fromosis = new OSISOSIS();
- fromtei = NULL;
- break;
- case FMT_WEBIF:
- fromplain = NULL;
- fromthml = new ThMLWEBIF();
- fromgbf = new GBFWEBIF();
- fromosis = new OSISWEBIF();
- fromtei = NULL;
- break;
- case FMT_TEI:
- fromplain = NULL;
- fromthml = NULL;
- fromgbf = NULL;
- fromosis = NULL;
- fromtei = NULL;
- break;
- }
+ switch (markup) {
+ case FMT_PLAIN:
+ fromplain = NULL;
+ fromthml = new ThMLPlain();
+ fromgbf = new GBFPlain();
+ fromosis = new OSISPlain();
+ fromtei = new TEIPlain();
+ break;
+
+ case FMT_THML:
+ fromplain = NULL;
+ fromthml = NULL;
+ fromgbf = new GBFThML();
+ fromosis = NULL;
+ fromtei = NULL;
+ break;
+
+ case FMT_GBF:
+ fromplain = NULL;
+ fromthml = new ThMLGBF();
+ fromgbf = NULL;
+ fromosis = NULL;
+ fromtei = NULL;
+ break;
+
+ case FMT_HTML:
+ fromplain = NULL;
+ fromthml = new ThMLHTML();
+ fromgbf = new GBFHTML();
+ fromosis = NULL;
+ fromtei = NULL;
+ break;
+
+ case FMT_HTMLHREF:
+ fromplain = NULL;
+ fromthml = new ThMLHTMLHREF();
+ fromgbf = new GBFHTMLHREF();
+ fromosis = new OSISHTMLHREF();
+ fromtei = new TEIHTMLHREF();
+ break;
+
+ case FMT_RTF:
+ fromplain = NULL;
+ fromthml = new ThMLRTF();
+ fromgbf = new GBFRTF();
+ fromosis = new OSISRTF();
+ fromtei = new TEIRTF();
+ break;
+
+ case FMT_OSIS:
+ fromplain = NULL;
+ fromthml = new ThMLOSIS();
+ fromgbf = new GBFOSIS();
+ fromosis = new OSISOSIS();
+ fromtei = NULL;
+ break;
+
+ case FMT_WEBIF:
+ fromplain = NULL;
+ fromthml = new ThMLWEBIF();
+ fromgbf = new GBFWEBIF();
+ fromosis = new OSISWEBIF();
+ fromtei = NULL;
+ break;
+
+ case FMT_TEI:
+ fromplain = NULL;
+ fromthml = NULL;
+ fromgbf = NULL;
+ fromosis = NULL;
+ fromtei = NULL;
+ break;
+
+ case FMT_XHTML:
+ fromplain = NULL;
+ fromthml = new ThMLXHTML();
+ fromgbf = new GBFXHTML();
+ fromosis = new OSISXHTML();
+ fromtei = new TEIXHTML();
+ break;
+ }
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/mgr/ftptrans.cpp b/src/mgr/remotetrans.cpp
index 6e17661..03ad3e4 100644
--- a/src/mgr/ftptrans.cpp
+++ b/src/mgr/remotetrans.cpp
@@ -1,9 +1,10 @@
- /*****************************************************************************
- * FTPTransport functions
+/*****************************************************************************
*
+ * remotetrans.cpp -
*
+ * $Id: remotetrans.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2004-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -19,20 +20,19 @@
*
*/
-
-
-
-#include <ftptrans.h>
+#include <remotetrans.h>
#include <filemgr.h>
#include <fcntl.h>
#include <dirent.h>
#include <swlog.h>
+
extern "C" {
#include <ftpparse.h>
}
+
using std::vector;
@@ -41,12 +41,12 @@ SWORD_NAMESPACE_START
namespace {
-void removeTrailingSlash(SWBuf &buf) {
- int len = buf.size();
- if ((buf[len-1] == '/')
- || (buf[len-1] == '\\'))
- buf.size(len-1);
-}
+ void removeTrailingSlash(SWBuf &buf) {
+ int len = buf.size();
+ if ((buf[len-1] == '/')
+ || (buf[len-1] == '\\'))
+ buf.size(len-1);
+ }
};
@@ -54,11 +54,12 @@ void removeTrailingSlash(SWBuf &buf) {
void StatusReporter::preStatus(long totalBytes, long completedBytes, const char *message) {
}
+
void StatusReporter::statusUpdate(double dtTotal, double dlNow) {
}
-FTPTransport::FTPTransport(const char *host, StatusReporter *statusReporter) {
+RemoteTransport::RemoteTransport(const char *host, StatusReporter *statusReporter) {
this->statusReporter = statusReporter;
this->host = host;
u = "ftp";
@@ -67,18 +68,18 @@ FTPTransport::FTPTransport(const char *host, StatusReporter *statusReporter) {
}
-FTPTransport::~FTPTransport() {
+RemoteTransport::~RemoteTransport() {
}
// override this method in your real transport class
-char FTPTransport::getURL(const char *destPath, const char *sourceURL, SWBuf *destBuf) {
+char RemoteTransport::getURL(const char *destPath, const char *sourceURL, SWBuf *destBuf) {
char retVal = 0;
return retVal;
}
-vector<struct DirEntry> FTPTransport::getDirList(const char *dirURL) {
+vector<struct DirEntry> RemoteTransport::getDirList(const char *dirURL) {
vector<struct DirEntry> dirList;
@@ -99,12 +100,15 @@ vector<struct DirEntry> FTPTransport::getDirList(const char *dirURL) {
else if ((*end != 10) && (*end != 13))
break;
}
- SWLog::getSystemLog()->logWarning("FTPURLGetDir: parsing item %s(%d)\n", start, end-start);
+ SWLog::getSystemLog()->logWarning("getDirList: parsing item %s(%d)\n", start, end-start);
int status = ftpparse(&item, start, end - start);
- SWLog::getSystemLog()->logWarning("FTPURLGetDir: got item %s\n", item.name);
- if (status) {
+ // in ftpparse.h, there is a warning that name is not necessarily null terminated
+ SWBuf name;
+ name.append(item.name, item.namelen);
+ SWLog::getSystemLog()->logWarning("getDirList: got item %s\n", name.c_str());
+ if (status && name != "." && name != "..") {
struct DirEntry i;
- i.name = item.name;
+ i.name = name;
i.size = item.size;
i.isDirectory = (item.flagtrycwd == 1);
dirList.push_back(i);
@@ -112,15 +116,14 @@ vector<struct DirEntry> FTPTransport::getDirList(const char *dirURL) {
start = end;
}
}
- else
- {
- SWLog::getSystemLog()->logWarning("FTPURLGetDir: failed to get dir %s\n", dirURL);
+ else {
+ SWLog::getSystemLog()->logWarning("getDirList: failed to get dir %s\n", dirURL);
}
return dirList;
}
-int FTPTransport::copyDirectory(const char *urlPrefix, const char *dir, const char *dest, const char *suffix) {
+int RemoteTransport::copyDirectory(const char *urlPrefix, const char *dir, const char *dest, const char *suffix) {
unsigned int i;
int retVal = 0;
@@ -163,7 +166,7 @@ int FTPTransport::copyDirectory(const char *urlPrefix, const char *dir, const ch
url += dirEntry.name; //dont forget the final slash
if (!dirEntry.isDirectory) {
if (getURL(buffer.c_str(), url.c_str())) {
- SWLog::getSystemLog()->logWarning("FTPCopy: failed to get file %s\n", url.c_str());
+ SWLog::getSystemLog()->logWarning("copyDirectory: failed to get file %s\n", url.c_str());
return -2;
}
completedBytes += dirEntry.size;
@@ -173,7 +176,7 @@ int FTPTransport::copyDirectory(const char *urlPrefix, const char *dir, const ch
removeTrailingSlash(subdir);
subdir += (SWBuf)"/" + dirEntry.name;
if (copyDirectory(urlPrefix, subdir, buffer.c_str(), suffix)) {
- SWLog::getSystemLog()->logWarning("FTPCopy: failed to get file %s\n", subdir.c_str());
+ SWLog::getSystemLog()->logWarning("copyDirectory: failed to get file %s\n", subdir.c_str());
return -2;
}
}
@@ -189,5 +192,13 @@ int FTPTransport::copyDirectory(const char *urlPrefix, const char *dir, const ch
}
+#if defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+void StatusReporter::update(unsigned long totalBytes, unsigned long completedBytes) {
+ statusUpdate(totalBytes, completedBytes);
+}
+
+
SWORD_NAMESPACE_END
diff --git a/src/mgr/stringmgr.cpp b/src/mgr/stringmgr.cpp
index c4a994e..0390905 100644
--- a/src/mgr/stringmgr.cpp
+++ b/src/mgr/stringmgr.cpp
@@ -1,9 +1,10 @@
/******************************************************************************
- * stringmgr.cpp - implementation of class StringMgr
*
- * $Id: stringmgr.cpp 2115 2007-10-16 18:29:00Z scribe $
+ * stringmgr.cpp - implementation of class StringMgr
*
- * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: stringmgr.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2004-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -38,8 +39,10 @@
#endif
+
SWORD_NAMESPACE_START
+
StringMgr *StringMgr::systemStringMgr = 0;
class __staticsystemStringMgr {
@@ -48,70 +51,74 @@ public:
~__staticsystemStringMgr() { if (StringMgr::systemStringMgr) delete StringMgr::systemStringMgr; StringMgr::systemStringMgr = 0; }
} _staticsystemStringMgr;
-/**
- * Determine whether the string contains a valid unicode sequence. The following table give the pattern of a valid UTF-8 character.
- * Unicode Range 1st 2nd 3rd 4th 5th 6th
- * U-00000000 - U-0000007F 0nnnnnnn
- * U-00000080 - U-000007FF 110nnnnn 10nnnnnn
- * U-00000800 - U-0000FFFF 1110nnnn 10nnnnnn 10nnnnnn
- * U-00010000 - U-001FFFFF 11110nnn 10nnnnnn 10nnnnnn 10nnnnnn
- * U-00200000 - U-03FFFFFF 111110nn 10nnnnnn 10nnnnnn 10nnnnnn 10nnnnnn
- * U-04000000 - U-7FFFFFFF 1111110n 10nnnnnn 10nnnnnn 10nnnnnn 10nnnnnn 10nnnnnn
- * Note:
- * The latest UTF-8 RFC allows for a max of 4 bytes. Earlier allowed 6.
- * The number of bits of the leading byte before the first 0 is the total number of bytes
- * The "n" are the bits of the unicode codepoint.
- *
- * This routine does not check to see if the code point is in the range. It could.
- *
- * @param txt the text to check
- * @return 1 if all high order characters form a valid unicode sequence
- * -1 if there are no high order characters
- * 0 if there are high order characters that do not form a valid unicode sequence
- * @author DM Smith [dmsmith555 at yahoo dot com]
- */
-int isValidUTF8(unsigned char *txt) {
- unsigned int countUTF8 = 0;
-#if 0
- unsigned char parts = 0;
-
-
- unsigned char *p = txt;
- while (*p) {
- // Is the high order bit set?
- if (*p & 0x80) {
- // then count the number of high order bits that are set
- // this determines the number of following bytes need to have high order bits set
- unsigned char i = *p;
- for (parts = 0; i & 0x80; parts++) {
- i <<= 1;
- }
-
- // The pattern 10nnnnnn is not a unicode character
- if (parts == 1) {
- return 0;
- }
- else {
- while (--parts && ++*p) {
- // The pattern of each following character must be: 10nnnnnn
- if (0xc0 & *p != 0x80) {
- return 0;
- }
+namespace {
+
+ /**
+ * Determine whether the string contains a valid unicode sequence. The following table give the pattern of a valid UTF-8 character.
+ * Unicode Range 1st 2nd 3rd 4th 5th 6th
+ * U-00000000 - U-0000007F 0nnnnnnn
+ * U-00000080 - U-000007FF 110nnnnn 10nnnnnn
+ * U-00000800 - U-0000FFFF 1110nnnn 10nnnnnn 10nnnnnn
+ * U-00010000 - U-001FFFFF 11110nnn 10nnnnnn 10nnnnnn 10nnnnnn
+ * U-00200000 - U-03FFFFFF 111110nn 10nnnnnn 10nnnnnn 10nnnnnn 10nnnnnn
+ * U-04000000 - U-7FFFFFFF 1111110n 10nnnnnn 10nnnnnn 10nnnnnn 10nnnnnn 10nnnnnn
+ * Note:
+ * The latest UTF-8 RFC allows for a max of 4 bytes. Earlier allowed 6.
+ * The number of bits of the leading byte before the first 0 is the total number of bytes
+ * The "n" are the bits of the unicode codepoint.
+ *
+ * This routine does not check to see if the code point is in the range. It could.
+ *
+ * @param txt the text to check
+ * @return 1 if all high order characters form a valid unicode sequence
+ * -1 if there are no high order characters
+ * 0 if there are high order characters that do not form a valid unicode sequence
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+ int isValidUTF8(unsigned char *txt) {
+ unsigned int countUTF8 = 0;
+ #if 0
+ unsigned char parts = 0;
+
+
+ unsigned char *p = txt;
+ while (*p) {
+ // Is the high order bit set?
+ if (*p & 0x80) {
+ // then count the number of high order bits that are set
+ // this determines the number of following bytes need to have high order bits set
+ unsigned char i = *p;
+ for (parts = 0; i & 0x80; parts++) {
+ i <<= 1;
}
- // Oops, we've run out of bytes too soon: Cannot be UTF-8
- if (parts) {
+
+ // The pattern 10nnnnnn is not a unicode character
+ if (parts == 1) {
return 0;
}
+ else {
+ while (--parts && ++*p) {
+ // The pattern of each following character must be: 10nnnnnn
+ if (0xc0 & *p != 0x80) {
+ return 0;
+ }
+ }
+
+ // Oops, we've run out of bytes too soon: Cannot be UTF-8
+ if (parts) {
+ return 0;
+ }
+ }
+ countUTF8++;
}
- countUTF8++;
}
- }
- // At this point it is either UTF-8 or ascii
-#endif
- return countUTF8 ? 1 : -1;
+ // At this point it is either UTF-8 or ascii
+ #endif
+ return countUTF8 ? 1 : -1;
+ }
}
diff --git a/src/mgr/swcacher.cpp b/src/mgr/swcacher.cpp
index 57d0817..e12bdcb 100644
--- a/src/mgr/swcacher.cpp
+++ b/src/mgr/swcacher.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
- * 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 1688 2005-01-01 04:42:26Z scribe $
+ * swcacher.cpp - definition of class SWCacher used to provide an
+ * interface for objects that cache and want a standard
+ * interface for cleaning up
*
- * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swcacher.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -22,6 +24,7 @@
#include <swcacher.h>
+
SWORD_NAMESPACE_START
@@ -44,4 +47,6 @@ long SWCacher::lastAccess() {
return 0;
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/mgr/swconfig.cpp b/src/mgr/swconfig.cpp
index 309f686..748071c 100644
--- a/src/mgr/swconfig.cpp
+++ b/src/mgr/swconfig.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
- * swconfig.cpp - implementation of Class SWConfig used for saving and
- * retrieval of configuration information
*
- * $Id: swconfig.cpp 2218 2008-12-23 09:33:38Z scribe $
+ * swconfig.cpp - used for saving and retrieval of configuration
+ * information
*
- * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swconfig.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,9 +29,11 @@
SWORD_NAMESPACE_START
+
SWConfig::SWConfig() {
}
+
SWConfig::SWConfig(const char * ifilename) {
filename = ifilename;
Load();
@@ -40,6 +43,7 @@ SWConfig::SWConfig(const char * ifilename) {
SWConfig::~SWConfig() {
}
+
void SWConfig::Load() {
if (!filename.size()) return; // assert we have a filename
@@ -164,4 +168,6 @@ ConfigEntMap & SWConfig::operator [] (const char *section) {
return Sections[section];
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/mgr/swfiltermgr.cpp b/src/mgr/swfiltermgr.cpp
index 434f2e0..5240014 100644
--- a/src/mgr/swfiltermgr.cpp
+++ b/src/mgr/swfiltermgr.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
- * swfiltermgr.cpp - definition of class SWFilterMgr used as an interface to
- * manage filters on a module
*
- * $Id: swfiltermgr.cpp 1688 2005-01-01 04:42:26Z scribe $
+ * swfiltermgr.cpp - Implementation of SWFilterMgr, used as an interface
+ * to manage filters on a module
*
- * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swfiltermgr.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -22,6 +23,7 @@
#include <swfiltermgr.h>
+
SWORD_NAMESPACE_START
@@ -90,4 +92,6 @@ void SWFilterMgr::AddStripFilters(SWModule * module, ConfigEntMap & section) {
void SWFilterMgr::AddRawFilters(SWModule * module, ConfigEntMap & section) {
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/mgr/swlocale.cpp b/src/mgr/swlocale.cpp
index fff35d5..a007238 100644
--- a/src/mgr/swlocale.cpp
+++ b/src/mgr/swlocale.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
- * swlocale.cpp - implementation of Class SWLocale used for retrieval
- * of locale lookups
*
- * $Id: swlocale.cpp 2463 2009-10-14 22:14:55Z chrislit $
+ * swlocale.cpp - implementation of Class SWLocale used for retrieval
+ * of locale lookups
*
- * Copyright 2000 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swlocale.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,15 +26,21 @@
#include <map>
#include <swconfig.h>
#include <versekey.h>
-#include <versemgr.h>
+#include <versificationmgr.h>
+
SWORD_NAMESPACE_START
-typedef std::map < SWBuf, SWBuf, std::less < SWBuf > >LookupMap;
+
+namespace {
+ typedef std::map < SWBuf, SWBuf, std::less < SWBuf > >LookupMap;
+}
+
const char *SWLocale::DEFAULT_LOCALE_NAME="en";
-// I have bridge patterns, but this hides swconfig and map from lots o stuff
+
+// I hate bridge patterns, but this hides swconfig and map from lots o stuff
class SWLocale::Private {
public:
LookupMap lookupTable;
@@ -144,10 +151,12 @@ const char *SWLocale::getDescription() {
return description;
}
+
const char *SWLocale::getEncoding() {
return encoding;
}
+
void SWLocale::augment(SWLocale &addFrom) {
*localeSource += *addFrom.localeSource;
}
@@ -184,3 +193,4 @@ const struct abbrev *SWLocale::getBookAbbrevs(int *retSize) {
SWORD_NAMESPACE_END
+
diff --git a/src/mgr/swmgr.cpp b/src/mgr/swmgr.cpp
index 3ee253f..0a2d583 100644
--- a/src/mgr/swmgr.cpp
+++ b/src/mgr/swmgr.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
- * swmgr.cpp - implementaion of class SWMgr used to interact with an install
- * base of sword modules.
*
- * $Id: swmgr.cpp 2374 2009-05-04 03:48:01Z scribe $
+ * swmgr.cpp - used to interact with an install base of sword modules
*
- * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swmgr.cpp 2985 2013-10-04 14:38:14Z scribe $
+ *
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -51,6 +51,8 @@
#include <gbfheadings.h>
#include <gbfredletterwords.h>
#include <gbfmorph.h>
+#include <osisenum.h>
+#include <osisglosses.h>
#include <osisheadings.h>
#include <osisfootnotes.h>
#include <osisstrongs.h>
@@ -58,8 +60,10 @@
#include <osislemma.h>
#include <osisredletterwords.h>
#include <osismorphsegmentation.h>
-#include <osisruby.h>
#include <osisscripref.h>
+#include <osisvariants.h>
+#include <osisxlit.h>
+#include <osisreferencelinks.h>
#include <thmlstrongs.h>
#include <thmlfootnotes.h>
#include <thmlheadings.h>
@@ -81,6 +85,7 @@
#include <swfiltermgr.h>
#include <swcipher.h>
#include <swoptfilter.h>
+#include <rtfhtml.h>
#include <swlog.h>
@@ -88,6 +93,8 @@
#ifndef EXCLUDEZLIB
#include "zipcomprs.h"
+#include "bz2comprs.h"
+#include "xzcomprs.h"
#endif
@@ -95,8 +102,10 @@
#include <utf8transliterator.h>
#endif
+
SWORD_NAMESPACE_START
+
#ifdef _ICU_
bool SWMgr::isICU = true;
#else
@@ -110,6 +119,14 @@ const char *SWMgr::globalConfPath = GLOBCONFPATH;
const char *SWMgr::globalConfPath = "/etc/sword.conf:/usr/local/etc/sword.conf";
#endif
+
+const char *SWMgr::MODTYPE_BIBLES = "Biblical Texts";
+const char *SWMgr::MODTYPE_COMMENTARIES = "Commentaries";
+const char *SWMgr::MODTYPE_LEXDICTS = "Lexicons / Dictionaries";
+const char *SWMgr::MODTYPE_GENBOOKS = "Generic Books";
+const char *SWMgr::MODTYPE_DAILYDEVOS = "Daily Devotional";
+
+
void SWMgr::init() {
SWOptionFilter *tmpFilter = 0;
configPath = 0;
@@ -123,6 +140,7 @@ void SWMgr::init() {
cipherFilters.clear();
optionFilters.clear();
cleanupFilters.clear();
+ extraFilters.clear();
tmpFilter = new ThMLVariants();
optionFilters.insert(OptionFilterMap::value_type("ThMLVariants", tmpFilter));
cleanupFilters.push_back(tmpFilter);
@@ -179,10 +197,23 @@ void SWMgr::init() {
optionFilters.insert(OptionFilterMap::value_type("OSISMorphSegmentation", tmpFilter));
cleanupFilters.push_back(tmpFilter);
- tmpFilter = new OSISRuby();
+ tmpFilter = new OSISGlosses();
+ optionFilters.insert(OptionFilterMap::value_type("OSISGlosses", tmpFilter));
optionFilters.insert(OptionFilterMap::value_type("OSISRuby", tmpFilter));
cleanupFilters.push_back(tmpFilter);
+ tmpFilter = new OSISXlit();
+ optionFilters.insert(OptionFilterMap::value_type("OSISXlit", tmpFilter));
+ cleanupFilters.push_back(tmpFilter);
+
+ tmpFilter = new OSISEnum();
+ optionFilters.insert(OptionFilterMap::value_type("OSISEnum", tmpFilter));
+ cleanupFilters.push_back(tmpFilter);
+
+ tmpFilter = new OSISVariants();
+ optionFilters.insert(OptionFilterMap::value_type("OSISVariants", tmpFilter));
+ cleanupFilters.push_back(tmpFilter);
+
tmpFilter = new ThMLStrongs();
optionFilters.insert(OptionFilterMap::value_type("ThMLStrongs", tmpFilter));
cleanupFilters.push_back(tmpFilter);
@@ -241,15 +272,25 @@ void SWMgr::init() {
gbfplain = new GBFPlain();
cleanupFilters.push_back(gbfplain);
+ extraFilters.insert(FilterMap::value_type("GBFPlain", gbfplain));
thmlplain = new ThMLPlain();
cleanupFilters.push_back(thmlplain);
+ extraFilters.insert(FilterMap::value_type("ThMLPlain", thmlplain));
osisplain = new OSISPlain();
cleanupFilters.push_back(osisplain);
+ extraFilters.insert(FilterMap::value_type("OSISPlain", osisplain));
teiplain = new TEIPlain();
cleanupFilters.push_back(teiplain);
+ extraFilters.insert(FilterMap::value_type("TEIPlain", teiplain));
+
+ // filters which aren't really used anywhere but which we want available for a "FilterName" -> filter mapping (e.g., filterText)
+ SWFilter *f = new RTFHTML();
+ extraFilters.insert(FilterMap::value_type("RTFHTML", f));
+ cleanupFilters.push_back(f);
+
}
@@ -715,7 +756,7 @@ void SWMgr::augmentModules(const char *ipath, bool multiMod) {
// fix config's Section names to rename modules which are available more than once
// find out which sections are in both config objects
// inserting all configs first is not good because that overwrites old keys and new modules would share the same config
- for (SectionMap::iterator it = config->Sections.begin(); it != config->Sections.end(); ++it) {
+ for (SectionMap::iterator it = config->Sections.begin(); it != config->Sections.end();) {
if (saveConfig->Sections.find( (*it).first ) != saveConfig->Sections.end()) { //if the new section is already present rename it
ConfigEntMap entMap((*it).second);
@@ -727,8 +768,10 @@ void SWMgr::augmentModules(const char *ipath, bool multiMod) {
} while (config->Sections.find(name) != config->Sections.end());
config->Sections.insert(SectionMap::value_type(name, entMap) );
- config->Sections.erase(it);
+ SectionMap::iterator toErase = it++;
+ config->Sections.erase(toErase);
}
+ else ++it;
}
}
@@ -819,7 +862,8 @@ signed char SWMgr::Load() {
return ret;
}
-SWModule *SWMgr::CreateMod(const char *name, const char *driver, ConfigEntMap &section)
+
+SWModule *SWMgr::createModule(const char *name, const char *driver, ConfigEntMap &section)
{
SWBuf description, datapath, misc1;
ConfigEntMap::iterator entry;
@@ -868,7 +912,9 @@ SWModule *SWMgr::CreateMod(const char *name, const char *driver, ConfigEntMap &s
else
markup = FMT_GBF;
- if (!stricmp(encoding.c_str(), "UTF-8")) {
+ if (!stricmp(encoding.c_str(), "SCSU"))
+ enc = ENC_SCSU;
+ else if (!stricmp(encoding.c_str(), "UTF-8")) {
enc = ENC_UTF8;
}
else enc = ENC_LATIN1;
@@ -889,7 +935,6 @@ SWModule *SWMgr::CreateMod(const char *name, const char *driver, ConfigEntMap &s
if ((!stricmp(driver, "zText")) || (!stricmp(driver, "zCom"))) {
SWCompress *compress = 0;
int blockType = CHAPTERBLOCKS;
- int blockNum = 1;
misc1 = ((entry = section.find("BlockType")) != section.end()) ? (*entry).second : (SWBuf)"CHAPTER";
if (!stricmp(misc1.c_str(), "VERSE"))
blockType = VERSEBLOCKS;
@@ -898,14 +943,17 @@ SWModule *SWMgr::CreateMod(const char *name, const char *driver, ConfigEntMap &s
else if (!stricmp(misc1.c_str(), "BOOK"))
blockType = BOOKBLOCKS;
- misc1 = ((entry = section.find("BlockNumber")) != section.end()) ? (*entry).second : (SWBuf)"1";
- blockNum = atoi(misc1.c_str());
-
misc1 = ((entry = section.find("CompressType")) != section.end()) ? (*entry).second : (SWBuf)"LZSS";
#ifndef EXCLUDEZLIB
if (!stricmp(misc1.c_str(), "ZIP"))
compress = new ZipCompress();
else
+ if (!stricmp(misc1.c_str(), "BZIP2_UNSUPPORTED"))
+ compress = new Bzip2Compress();
+ else
+ if (!stricmp(misc1.c_str(), "XZ_UNSUPPORTED"))
+ compress = new XzCompress();
+ else
#endif
if (!stricmp(misc1.c_str(), "LZSS"))
compress = new LZSSCompress();
@@ -949,18 +997,24 @@ SWModule *SWMgr::CreateMod(const char *name, const char *driver, ConfigEntMap &s
int pos = 0; //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());
+ bool caseSensitive = ((entry = section.find("CaseSensitiveKeys")) != section.end()) ? (*entry).second == "true": false;
+ bool strongsPadding = ((entry = section.find("StrongsPadding")) != section.end()) ? (*entry).second == "true": true;
+ newmod = new RawLD(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str(), caseSensitive, strongsPadding);
pos = 1;
}
if (!stricmp(driver, "RawLD4")) {
- newmod = new RawLD4(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
+ bool caseSensitive = ((entry = section.find("CaseSensitiveKeys")) != section.end()) ? (*entry).second == "true": false;
+ bool strongsPadding = ((entry = section.find("StrongsPadding")) != section.end()) ? (*entry).second == "true": true;
+ newmod = new RawLD4(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str(), caseSensitive, strongsPadding);
pos = 1;
}
if (!stricmp(driver, "zLD")) {
SWCompress *compress = 0;
int blockCount;
+ bool caseSensitive = ((entry = section.find("CaseSensitiveKeys")) != section.end()) ? (*entry).second == "true": false;
+ bool strongsPadding = ((entry = section.find("StrongsPadding")) != section.end()) ? (*entry).second == "true": true;
misc1 = ((entry = section.find("BlockCount")) != section.end()) ? (*entry).second : (SWBuf)"200";
blockCount = atoi(misc1.c_str());
blockCount = (blockCount) ? blockCount : 200;
@@ -975,7 +1029,7 @@ SWModule *SWMgr::CreateMod(const char *name, const char *driver, ConfigEntMap &s
compress = new LZSSCompress();
if (compress) {
- newmod = new zLD(datapath.c_str(), name, description.c_str(), blockCount, compress, 0, enc, direction, markup, lang.c_str());
+ newmod = new zLD(datapath.c_str(), name, description.c_str(), blockCount, compress, 0, enc, direction, markup, lang.c_str(), caseSensitive, strongsPadding);
}
pos = 1;
}
@@ -1008,7 +1062,7 @@ SWModule *SWMgr::CreateMod(const char *name, const char *driver, ConfigEntMap &s
if (newmod) {
// 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->setType(entry->second.c_str());
newmod->setConfig(&section);
}
@@ -1018,11 +1072,37 @@ SWModule *SWMgr::CreateMod(const char *name, const char *driver, ConfigEntMap &s
void SWMgr::AddGlobalOptions(SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end) {
- for (;start != end; start++) {
+
+ for (;start != end; ++start) {
OptionFilterMap::iterator it;
- it = optionFilters.find((*start).second);
+ SWBuf filterName = start->second;
+
+
+ // special cases for filters with parameters
+
+ if (filterName.startsWith("OSISReferenceLinks")) {
+ SWBuf params = filterName;
+ filterName = params.stripPrefix('|', true);
+ SWBuf optionName = params.stripPrefix('|', true);
+ SWBuf optionTip = params.stripPrefix('|', true);
+ SWBuf optionType = params.stripPrefix('|', true);
+ SWBuf optionSubType = params.stripPrefix('|', true);
+ SWBuf optionDefaultValue = params.stripPrefix('|', true);
+ // we'll key off of type and subtype.
+ filterName = filterName + "." + optionType + "." + optionSubType;
+
+ it = optionFilters.find(filterName);
+ if (it == optionFilters.end()) {
+ SWOptionFilter *tmpFilter = new OSISReferenceLinks(optionName, optionTip, optionType, optionSubType, optionDefaultValue);
+ optionFilters.insert(OptionFilterMap::value_type(filterName, tmpFilter));
+ cleanupFilters.push_back(tmpFilter);
+ }
+ }
+
+
+ it = optionFilters.find(filterName);
if (it != optionFilters.end()) {
- module->AddOptionFilter((*it).second); // add filter to module and option as a valid option
+ 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()))
@@ -1035,20 +1115,31 @@ void SWMgr::AddGlobalOptions(SWModule *module, ConfigEntMap &section, ConfigEntM
if (filterMgr)
filterMgr->AddGlobalOptions(module, section, start, end);
#ifdef _ICU_
- module->AddOptionFilter(transliterator);
+ module->addOptionFilter(transliterator);
#endif
}
char SWMgr::filterText(const char *filterName, SWBuf &text, const SWKey *key, const SWModule *module)
- {
+{
char retVal = -1;
+ // why didn't we use find here?
for (OptionFilterMap::iterator it = optionFilters.begin(); it != optionFilters.end(); it++) {
if ((*it).second->getOptionName()) {
- if (!stricmp(filterName, (*it).second->getOptionName()))
- retVal = it->second->processText(text, key, module); // add filter to module
+ if (!stricmp(filterName, (*it).second->getOptionName())) {
+ retVal = it->second->processText(text, key, module);
+ break;
+ }
+ }
+ }
+
+ if (retVal == -1) {
+ FilterMap::iterator it = extraFilters.find(filterName);
+ if (it != extraFilters.end()) {
+ retVal = it->second->processText(text, key, module);
}
}
+
return retVal;
}
@@ -1059,7 +1150,7 @@ void SWMgr::AddLocalOptions(SWModule *module, ConfigEntMap &section, ConfigEntMa
OptionFilterMap::iterator it;
it = optionFilters.find((*start).second);
if (it != optionFilters.end()) {
- module->AddOptionFilter((*it).second); // add filter to module
+ module->addOptionFilter((*it).second); // add filter to module
}
}
@@ -1075,7 +1166,7 @@ void SWMgr::AddStripFilters(SWModule *module, ConfigEntMap &section, ConfigEntMa
OptionFilterMap::iterator it;
it = optionFilters.find((*start).second);
if (it != optionFilters.end()) {
- module->AddStripFilter((*it).second); // add filter to module
+ module->addStripFilter((*it).second); // add filter to module
}
}
}
@@ -1088,9 +1179,9 @@ void SWMgr::AddRawFilters(SWModule *module, ConfigEntMap &section) {
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));
+ cipherFilters.insert(FilterMap::value_type(module->getName(), cipherFilter));
cleanupFilters.push_back(cipherFilter);
- module->AddRawFilter(cipherFilter);
+ module->addRawFilter(cipherFilter);
}
if (filterMgr)
@@ -1145,16 +1236,16 @@ void SWMgr::AddStripFilters(SWModule *module, ConfigEntMap &section)
}
if (!stricmp(sourceformat.c_str(), "GBF")) {
- module->AddStripFilter(gbfplain);
+ module->addStripFilter(gbfplain);
}
else if (!stricmp(sourceformat.c_str(), "ThML")) {
- module->AddStripFilter(thmlplain);
+ module->addStripFilter(thmlplain);
}
else if (!stricmp(sourceformat.c_str(), "OSIS")) {
- module->AddStripFilter(osisplain);
+ module->addStripFilter(osisplain);
}
else if (!stricmp(sourceformat.c_str(), "TEI")) {
- module->AddStripFilter(teiplain);
+ module->addStripFilter(teiplain);
}
if (filterMgr)
@@ -1176,19 +1267,19 @@ void SWMgr::CreateMods(bool multiMod) {
driver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (SWBuf)"";
if (driver.length()) {
- newmod = CreateMod((*it).first, driver, section);
+ newmod = createModule((*it).first, driver, section);
if (newmod) {
// Filters to add for this module and globally announce as an option to the user
// e.g. translit, strongs, redletterwords, etc, so users can turn these on and off globally
- start = (*it).second.lower_bound("GlobalOptionFilter");
- end = (*it).second.upper_bound("GlobalOptionFilter");
+ start = section.lower_bound("GlobalOptionFilter");
+ end = section.upper_bound("GlobalOptionFilter");
AddGlobalOptions(newmod, section, start, end);
// Only add the option to the module, don't announce it's availability
// These are useful for like: filters that parse special entryAttribs in a text
// or whatever you might want to happen on entry lookup
- start = (*it).second.lower_bound("LocalOptionFilter");
- end = (*it).second.upper_bound("LocalOptionFilter");
+ start = section.lower_bound("LocalOptionFilter");
+ end = section.upper_bound("LocalOptionFilter");
AddLocalOptions(newmod, section, start, end);
//STRIP FILTERS
@@ -1198,20 +1289,20 @@ void SWMgr::CreateMods(bool multiMod) {
// Any special processing for this module when searching:
// e.g. for papyri, removed all [](). notation
- start = (*it).second.lower_bound("LocalStripFilter");
- end = (*it).second.upper_bound("LocalStripFilter");
+ start = section.lower_bound("LocalStripFilter");
+ end = section.upper_bound("LocalStripFilter");
AddStripFilters(newmod, section, start, end);
AddRawFilters(newmod, section);
AddRenderFilters(newmod, section);
AddEncodingFilters(newmod, section);
- SWModule *oldmod = Modules[newmod->Name()];
+ SWModule *oldmod = Modules[newmod->getName()];
if (oldmod) {
delete oldmod;
}
- Modules[newmod->Name()] = newmod;
+ Modules[newmod->getName()] = newmod;
}
}
}
@@ -1382,11 +1473,13 @@ signed char SWMgr::setCipherKey(const char *modName, const char *key) {
SWFilter *cipherFilter = new CipherFilter(key);
cipherFilters.insert(FilterMap::value_type(modName, cipherFilter));
cleanupFilters.push_back(cipherFilter);
- (*it2).second->AddRawFilter(cipherFilter);
+ (*it2).second->addRawFilter(cipherFilter);
return 0;
}
}
return -1;
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/mgr/swsearchable.cpp b/src/mgr/swsearchable.cpp
index 48ae556..5837c9c 100644
--- a/src/mgr/swsearchable.cpp
+++ b/src/mgr/swsearchable.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
- * swsearchable.h - definition of class SWSearchable used to provide an
- * interface for objects that be searched.
*
- * $Id: swsearchable.cpp 1959 2006-08-28 00:39:56Z scribe $
+ * swsearchable.cpp - used to provide an interface for objects that
+ * can be searched
*
- * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swsearchable.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -23,10 +24,13 @@
#include <swsearchable.h>
#include <listkey.h>
+
SWORD_NAMESPACE_START
+
void SWSearchable::nullPercent(char percent, void *percentUserData) {}
+
SWSearchable::SWSearchable() {
}
@@ -34,7 +38,8 @@ SWSearchable::SWSearchable() {
SWSearchable::~SWSearchable() {
}
- // special search framework
+
+// special search framework
signed char SWSearchable::createSearchFramework(void (*percent)(char, void *), void *percentUserData) {
return 0;
}
@@ -50,4 +55,6 @@ bool SWSearchable::isSearchOptimallySupported(const char *istr, int searchType,
return retVal;
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/mgr/versemgr.cpp b/src/mgr/versificationmgr.cpp
index 354c0df..7972488 100644
--- a/src/mgr/versemgr.cpp
+++ b/src/mgr/versificationmgr.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
- * versemgr.cpp - implementation of class VerseMgr used for managing
- * versification systems
*
- * $Id: versemgr.cpp 2108 2007-10-13 20:35:02Z scribe $
+ * versificationmgr.cpp - implementation of class VersificationMgr used
+ * for managing versification systems
*
- * Copyright 2010 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: versificationmgr.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2008-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -20,7 +21,7 @@
*
*/
-#include <versemgr.h>
+#include <versificationmgr.h>
#include <vector>
#include <map>
#include <treekey.h>
@@ -36,43 +37,48 @@
#include <canon_nrsv.h> // NRSV v11n system
#include <canon_nrsva.h> // NRSV + Apocrypha v11n system
#include <canon_synodal.h> // Russian Synodal v11n system
+#include <canon_synodalprot.h> // Russian Synodal v11n system
#include <canon_vulg.h> // Vulgate v11n system
#include <canon_german.h> // German v11n system
#include <canon_luther.h> // Luther v11n system
#include <canon_catholic.h> // Catholic v11n system (10 chapter Esther)
#include <canon_catholic2.h> // Catholic2 v11n system (16 chapter Esther)
-#include <canon_synodalp.h> // SynodalP v11n system (KJV with Synodal-like verse counts)
+#include <canon_lxx.h> // General LXX v11n system (includes GNT, as used in Orthodox Bibles)
+#include <canon_orthodox.h> // Orthodox v11n system as used in Orthodox Bibles
using std::vector;
using std::map;
using std::distance;
using std::lower_bound;
+
SWORD_NAMESPACE_START
-VerseMgr *VerseMgr::getSystemVerseMgr() {
- if (!systemVerseMgr) {
- systemVerseMgr = new VerseMgr();
- systemVerseMgr->registerVersificationSystem("KJV", otbooks, ntbooks, vm);
- systemVerseMgr->registerVersificationSystem("Leningrad", otbooks_leningrad, ntbooks_null, vm_leningrad);
- systemVerseMgr->registerVersificationSystem("MT", otbooks_mt, ntbooks_null, vm_mt);
- systemVerseMgr->registerVersificationSystem("KJVA", otbooks_kjva, ntbooks, vm_kjva);
- systemVerseMgr->registerVersificationSystem("NRSV", otbooks, ntbooks, vm_nrsv);
- systemVerseMgr->registerVersificationSystem("NRSVA", otbooks_nrsva, ntbooks, vm_nrsva);
- systemVerseMgr->registerVersificationSystem("Synodal", otbooks_synodal, ntbooks_synodal, vm_synodal);
- systemVerseMgr->registerVersificationSystem("Vulg", otbooks_vulg, ntbooks_vulg, vm_vulg);
- systemVerseMgr->registerVersificationSystem("German", otbooks_german, ntbooks, vm_german);
- systemVerseMgr->registerVersificationSystem("Luther", otbooks_luther, ntbooks_luther, vm_luther);
- systemVerseMgr->registerVersificationSystem("Catholic", otbooks_catholic, ntbooks, vm_catholic);
- systemVerseMgr->registerVersificationSystem("Catholic2", otbooks_catholic2, ntbooks, vm_catholic2);
- systemVerseMgr->registerVersificationSystem("SynodalP", otbooks, ntbooks, vm_synodalp);
+VersificationMgr *VersificationMgr::getSystemVersificationMgr() {
+ if (!systemVersificationMgr) {
+ systemVersificationMgr = new VersificationMgr();
+ systemVersificationMgr->registerVersificationSystem("KJV", otbooks, ntbooks, vm);
+ systemVersificationMgr->registerVersificationSystem("Leningrad", otbooks_leningrad, ntbooks_null, vm_leningrad);
+ systemVersificationMgr->registerVersificationSystem("MT", otbooks_mt, ntbooks_null, vm_mt);
+ systemVersificationMgr->registerVersificationSystem("KJVA", otbooks_kjva, ntbooks, vm_kjva);
+ systemVersificationMgr->registerVersificationSystem("NRSV", otbooks, ntbooks, vm_nrsv);
+ systemVersificationMgr->registerVersificationSystem("NRSVA", otbooks_nrsva, ntbooks, vm_nrsva);
+ systemVersificationMgr->registerVersificationSystem("Synodal", otbooks_synodal, ntbooks_synodal, vm_synodal);
+ systemVersificationMgr->registerVersificationSystem("SynodalProt", otbooks_synodalProt, ntbooks_synodal, vm_synodalProt);
+ systemVersificationMgr->registerVersificationSystem("Vulg", otbooks_vulg, ntbooks_vulg, vm_vulg);
+ systemVersificationMgr->registerVersificationSystem("German", otbooks_german, ntbooks, vm_german);
+ systemVersificationMgr->registerVersificationSystem("Luther", otbooks_luther, ntbooks_luther, vm_luther);
+ systemVersificationMgr->registerVersificationSystem("Catholic", otbooks_catholic, ntbooks, vm_catholic);
+ systemVersificationMgr->registerVersificationSystem("Catholic2", otbooks_catholic2, ntbooks, vm_catholic2);
+ systemVersificationMgr->registerVersificationSystem("LXX", otbooks_lxx, ntbooks, vm_lxx);
+ systemVersificationMgr->registerVersificationSystem("Orthodox", otbooks_orthodox, ntbooks, vm_orthodox);
}
- return systemVerseMgr;
+ return systemVersificationMgr;
}
-class VerseMgr::System::Private {
+class VersificationMgr::System::Private {
public:
/** Array[chapmax] of maximum verses in chapters */
vector<Book> books;
@@ -80,11 +86,11 @@ public:
Private() {
}
- Private(const VerseMgr::System::Private &other) {
+ Private(const VersificationMgr::System::Private &other) {
books = other.books;
osisLookup = other.osisLookup;
}
- VerseMgr::System::Private &operator =(const VerseMgr::System::Private &other) {
+ VersificationMgr::System::Private &operator =(const VersificationMgr::System::Private &other) {
books = other.books;
osisLookup = other.osisLookup;
return *this;
@@ -92,7 +98,7 @@ public:
};
-class VerseMgr::Book::Private {
+class VersificationMgr::Book::Private {
friend struct BookOffsetLess;
public:
/** Array[chapmax] of maximum verses in chapters */
@@ -102,12 +108,12 @@ public:
Private() {
verseMax.clear();
}
- Private(const VerseMgr::Book::Private &other) {
+ Private(const VersificationMgr::Book::Private &other) {
verseMax.clear();
verseMax = other.verseMax;
offsetPrecomputed = other.offsetPrecomputed;
}
- VerseMgr::Book::Private &operator =(const VerseMgr::Book::Private &other) {
+ VersificationMgr::Book::Private &operator =(const VersificationMgr::Book::Private &other) {
verseMax.clear();
verseMax = other.verseMax;
offsetPrecomputed = other.offsetPrecomputed;
@@ -115,18 +121,21 @@ public:
}
};
+
struct BookOffsetLess {
- bool operator() (const VerseMgr::Book &o1, const VerseMgr::Book &o2) const { return o1.p->offsetPrecomputed[0] < o2.p->offsetPrecomputed[0]; }
- bool operator() (const long &o1, const VerseMgr::Book &o2) const { return o1 < o2.p->offsetPrecomputed[0]; }
- bool operator() (const VerseMgr::Book &o1, const long &o2) const { return o1.p->offsetPrecomputed[0] < o2; }
+ bool operator() (const VersificationMgr::Book &o1, const VersificationMgr::Book &o2) const { return o1.p->offsetPrecomputed[0] < o2.p->offsetPrecomputed[0]; }
+ bool operator() (const long &o1, const VersificationMgr::Book &o2) const { return o1 < o2.p->offsetPrecomputed[0]; }
+ bool operator() (const VersificationMgr::Book &o1, const long &o2) const { return o1.p->offsetPrecomputed[0] < o2; }
bool operator() (const long &o1, const long &o2) const { return o1 < o2; }
};
-void VerseMgr::Book::init() {
+
+void VersificationMgr::Book::init() {
p = new Private();
}
-void VerseMgr::System::init() {
+
+void VersificationMgr::System::init() {
p = new Private();
BMAX[0] = 0;
BMAX[1] = 0;
@@ -134,7 +143,7 @@ void VerseMgr::System::init() {
}
-VerseMgr::System::System(const System &other) {
+VersificationMgr::System::System(const System &other) {
init();
name = other.name;
BMAX[0] = other.BMAX[0];
@@ -143,7 +152,8 @@ VerseMgr::System::System(const System &other) {
ntStartOffset = other.ntStartOffset;
}
-VerseMgr::System &VerseMgr::System::operator =(const System &other) {
+
+VersificationMgr::System &VersificationMgr::System::operator =(const System &other) {
name = other.name;
BMAX[0] = other.BMAX[0];
BMAX[1] = other.BMAX[1];
@@ -153,22 +163,23 @@ VerseMgr::System &VerseMgr::System::operator =(const System &other) {
}
-VerseMgr::System::~System() {
+VersificationMgr::System::~System() {
delete p;
}
-const VerseMgr::Book *VerseMgr::System::getBook(int number) const {
+
+const VersificationMgr::Book *VersificationMgr::System::getBook(int number) const {
return (number < (signed int)p->books.size()) ? &(p->books[number]) : 0;
}
-int VerseMgr::System::getBookNumberByOSISName(const char *bookName) const {
+int VersificationMgr::System::getBookNumberByOSISName(const char *bookName) const {
map<SWBuf, int>::const_iterator it = p->osisLookup.find(bookName);
return (it != p->osisLookup.end()) ? it->second : -1;
}
-void VerseMgr::System::loadFromSBook(const sbook *ot, const sbook *nt, int *chMax) {
+void VersificationMgr::System::loadFromSBook(const sbook *ot, const sbook *nt, int *chMax) {
int chap = 0;
int book = 0;
long offset = 0; // module heading
@@ -211,7 +222,7 @@ void VerseMgr::System::loadFromSBook(const sbook *ot, const sbook *nt, int *chMa
}
-VerseMgr::Book::Book(const Book &other) {
+VersificationMgr::Book::Book(const Book &other) {
longName = other.longName;
osisName = other.osisName;
prefAbbrev = other.prefAbbrev;
@@ -220,7 +231,8 @@ VerseMgr::Book::Book(const Book &other) {
(*p) = *(other.p);
}
-VerseMgr::Book& VerseMgr::Book::operator =(const Book &other) {
+
+VersificationMgr::Book& VersificationMgr::Book::operator =(const Book &other) {
longName = other.longName;
osisName = other.osisName;
prefAbbrev = other.prefAbbrev;
@@ -231,23 +243,23 @@ VerseMgr::Book& VerseMgr::Book::operator =(const Book &other) {
}
-VerseMgr::Book::~Book() {
+VersificationMgr::Book::~Book() {
delete p;
}
-int VerseMgr::Book::getVerseMax(int chapter) const {
+int VersificationMgr::Book::getVerseMax(int chapter) const {
chapter--;
return (p && (chapter < (signed int)p->verseMax.size()) && (chapter > -1)) ? p->verseMax[chapter] : -1;
}
-int VerseMgr::System::getBookCount() const {
+int VersificationMgr::System::getBookCount() const {
return (p ? p->books.size() : 0);
}
-long VerseMgr::System::getOffsetFromVerse(int book, int chapter, int verse) const {
+long VersificationMgr::System::getOffsetFromVerse(int book, int chapter, int verse) const {
long offset = -1;
chapter--;
@@ -272,7 +284,7 @@ long VerseMgr::System::getOffsetFromVerse(int book, int chapter, int verse) cons
}
-char VerseMgr::System::getVerseFromOffset(long offset, int *book, int *chapter, int *verse) const {
+char VersificationMgr::System::getVerseFromOffset(long offset, int *book, int *chapter, int *verse) const {
if (offset < 1) { // just handle the module heading corner case up front (and error case)
(*book) = -1;
@@ -311,67 +323,67 @@ char VerseMgr::System::getVerseFromOffset(long offset, int *book, int *chapter,
/***************************************************
- * VerseMgr
+ * VersificationMgr
*/
-class VerseMgr::Private {
+class VersificationMgr::Private {
public:
Private() {
}
- Private(const VerseMgr::Private &other) {
+ Private(const VersificationMgr::Private &other) {
systems = other.systems;
}
- VerseMgr::Private &operator =(const VerseMgr::Private &other) {
+ VersificationMgr::Private &operator =(const VersificationMgr::Private &other) {
systems = other.systems;
return *this;
}
map<SWBuf, System> systems;
};
// ---------------- statics -----------------
-VerseMgr *VerseMgr::systemVerseMgr = 0;
+VersificationMgr *VersificationMgr::systemVersificationMgr = 0;
-class __staticsystemVerseMgr {
+class __staticsystemVersificationMgr {
public:
- __staticsystemVerseMgr() { }
- ~__staticsystemVerseMgr() { delete VerseMgr::systemVerseMgr; }
-} _staticsystemVerseMgr;
+ __staticsystemVersificationMgr() { }
+ ~__staticsystemVersificationMgr() { delete VersificationMgr::systemVersificationMgr; }
+} _staticsystemVersificationMgr;
-void VerseMgr::init() {
+void VersificationMgr::init() {
p = new Private();
}
-VerseMgr::~VerseMgr() {
+VersificationMgr::~VersificationMgr() {
delete p;
}
-void VerseMgr::setSystemVerseMgr(VerseMgr *newVerseMgr) {
- if (systemVerseMgr)
- delete systemVerseMgr;
- systemVerseMgr = newVerseMgr;
+void VersificationMgr::setSystemVersificationMgr(VersificationMgr *newVersificationMgr) {
+ if (systemVersificationMgr)
+ delete systemVersificationMgr;
+ systemVersificationMgr = newVersificationMgr;
}
-const VerseMgr::System *VerseMgr::getVersificationSystem(const char *name) const {
+const VersificationMgr::System *VersificationMgr::getVersificationSystem(const char *name) const {
map<SWBuf, System>::const_iterator it = p->systems.find(name);
return (it != p->systems.end()) ? &(it->second) : 0;
}
-void VerseMgr::registerVersificationSystem(const char *name, const sbook *ot, const sbook *nt, int *chMax) {
+void VersificationMgr::registerVersificationSystem(const char *name, const sbook *ot, const sbook *nt, int *chMax) {
p->systems[name] = name;
System &s = p->systems[name];
s.loadFromSBook(ot, nt, chMax);
}
-void VerseMgr::registerVersificationSystem(const char *name, const TreeKey *tk) {
+void VersificationMgr::registerVersificationSystem(const char *name, const TreeKey *tk) {
}
-const StringList VerseMgr::getVersificationSystems() const {
+const StringList VersificationMgr::getVersificationSystems() const {
StringList retVal;
for (map<SWBuf, System>::const_iterator it = p->systems.begin(); it != p->systems.end(); it++) {
retVal.push_back(it->first);
@@ -381,3 +393,4 @@ const StringList VerseMgr::getVersificationSystems() const {
SWORD_NAMESPACE_END
+
diff --git a/src/modules/comments/hrefcom/hrefcom.cpp b/src/modules/comments/hrefcom/hrefcom.cpp
index 7035b08..3716dbf 100644
--- a/src/modules/comments/hrefcom/hrefcom.cpp
+++ b/src/modules/comments/hrefcom/hrefcom.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
- * hrefcom.cpp - code for class 'HREFCom'- a module that produces HTML HREFs
- * pointing to actual text desired. Uses standard
+ *
+ * hrefcom.cpp - code for class 'HREFCom'- a module that produces HTML
+ * HREFs pointing to actual text desired. Uses standard
* files: ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * $Id: hrefcom.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -67,19 +69,19 @@ HREFCom::~HREFCom()
* RET: string buffer with verse
*/
-SWBuf &HREFCom::getRawEntryBuf() {
+SWBuf &HREFCom::getRawEntryBuf() const {
long start;
unsigned short size;
VerseKey *key = 0;
key = &getVerseKey();
- findOffset(key->Testament(), key->TestamentIndex(), &start, &size);
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
entrySize = size; // support getEntrySize call
SWBuf tmpbuf;
- readText(key->Testament(), start, size, tmpbuf);
+ readText(key->getTestament(), start, size, tmpbuf);
entryBuf = prefix;
entryBuf += tmpbuf.c_str();
prepText(entryBuf);
diff --git a/src/modules/comments/rawcom/rawcom.cpp b/src/modules/comments/rawcom/rawcom.cpp
index c0404ae..5189cdc 100644
--- a/src/modules/comments/rawcom/rawcom.cpp
+++ b/src/modules/comments/rawcom/rawcom.cpp
@@ -1,9 +1,12 @@
/******************************************************************************
- * rawcom.cpp - code for class 'RawCom'- a module that reads raw commentary
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * rawcom.cpp - code for class 'RawCom'- a module that reads raw
+ * commentary files:
+ * ot and nt using indexs ??.bks ??.cps ??.vss
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawcom.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -54,7 +57,7 @@ RawCom::~RawCom()
}
-bool RawCom::isWritable() {
+bool RawCom::isWritable() const {
return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
/******************************************************************************
@@ -64,16 +67,16 @@ bool RawCom::isWritable() {
* RET: string buffer with verse
*/
-SWBuf &RawCom::getRawEntryBuf() {
+SWBuf &RawCom::getRawEntryBuf() const {
long start = 0;
unsigned short size = 0;
VerseKey *key = &getVerseKey();
- findOffset(key->Testament(), key->TestamentIndex(), &start, &size);
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
entrySize = size; // support getEntrySize call
entryBuf = "";
- readText(key->Testament(), start, size, entryBuf);
+ readText(key->getTestament(), start, size, entryBuf);
rawFilter(entryBuf, 0); // hack, decipher
rawFilter(entryBuf, key);
@@ -98,7 +101,7 @@ void RawCom::increment(int steps) {
unsigned short size;
VerseKey *tmpkey = &getVerseKey();
- findOffset(tmpkey->Testament(), tmpkey->TestamentIndex(), &start, &size);
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size);
SWKey lastgood = *tmpkey;
while (steps) {
@@ -108,12 +111,12 @@ void RawCom::increment(int steps) {
(steps > 0) ? ++(*key) : --(*key);
tmpkey = &getVerseKey();
- if ((error = key->Error())) {
+ if ((error = key->popError())) {
*key = lastgood;
break;
}
- long index = tmpkey->TestamentIndex();
- findOffset(tmpkey->Testament(), index, &start, &size);
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size);
if (
(((laststart != start) || (lastsize != size)) // we're a different entry
// && (start > 0)
@@ -129,7 +132,7 @@ void RawCom::increment(int steps) {
void RawCom::setEntry(const char *inbuf, long len) {
VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->TestamentIndex(), inbuf, len);
+ doSetText(key->getTestament(), key->getTestamentIndex(), inbuf, len);
}
@@ -137,7 +140,7 @@ void RawCom::linkEntry(const SWKey *inkey) {
VerseKey *destkey = &getVerseKey();
const VerseKey *srckey = &getVerseKey(inkey);
- doLinkEntry(destkey->Testament(), destkey->TestamentIndex(), srckey->TestamentIndex());
+ doLinkEntry(destkey->getTestament(), destkey->getTestamentIndex(), srckey->getTestamentIndex());
if (inkey != srckey) // free our key if we created a VerseKey
delete srckey;
@@ -153,7 +156,7 @@ void RawCom::linkEntry(const SWKey *inkey) {
void RawCom::deleteEntry() {
VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->TestamentIndex(), "");
+ doSetText(key->getTestament(), key->getTestamentIndex(), "");
}
bool RawCom::isLinked(const SWKey *k1, const SWKey *k2) const {
@@ -161,10 +164,10 @@ bool RawCom::isLinked(const SWKey *k1, const SWKey *k2) const {
unsigned short size1, size2;
VerseKey *vk1 = &getVerseKey(k1);
VerseKey *vk2 = &getVerseKey(k2);
- if (vk1->Testament() != vk2->Testament()) return false;
+ if (vk1->getTestament() != vk2->getTestament()) return false;
- findOffset(vk1->Testament(), vk1->TestamentIndex(), &start1, &size1);
- findOffset(vk2->Testament(), vk2->TestamentIndex(), &start2, &size2);
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2);
if (!size1 || !size2) return false;
return start1 == start2;
}
@@ -174,7 +177,7 @@ bool RawCom::hasEntry(const SWKey *k) const {
unsigned short size;
VerseKey *vk = &getVerseKey(k);
- findOffset(vk->Testament(), vk->TestamentIndex(), &start, &size);
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size);
return size;
}
diff --git a/src/modules/comments/rawcom4/Makefile b/src/modules/comments/rawcom4/Makefile
new file mode 100644
index 0000000..a08e07e
--- /dev/null
+++ b/src/modules/comments/rawcom4/Makefile
@@ -0,0 +1,5 @@
+
+root := ../../../..
+
+all:
+ make -C ${root}
diff --git a/src/modules/comments/rawcom4/rawcom4.cpp b/src/modules/comments/rawcom4/rawcom4.cpp
index c0c4a1d..7cfc603 100644
--- a/src/modules/comments/rawcom4/rawcom4.cpp
+++ b/src/modules/comments/rawcom4/rawcom4.cpp
@@ -1,9 +1,12 @@
/******************************************************************************
- * rawcom4.cpp - code for class 'RawCom4'- a module that reads raw commentary
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * rawcom4.cpp - code for class 'RawCom4'- a module that reads raw
+ * commentary files:
+ * ot and nt using indexs ??.bks ??.cps ??.vss
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawcom4.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2007-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -53,7 +56,7 @@ RawCom4::~RawCom4()
}
-bool RawCom4::isWritable() {
+bool RawCom4::isWritable() const {
return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
/******************************************************************************
@@ -63,16 +66,16 @@ bool RawCom4::isWritable() {
* RET: string buffer with verse
*/
-SWBuf &RawCom4::getRawEntryBuf() {
+SWBuf &RawCom4::getRawEntryBuf() const {
long start = 0;
unsigned long size = 0;
VerseKey *key = &getVerseKey();
- findOffset(key->Testament(), key->TestamentIndex(), &start, &size);
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
entrySize = size; // support getEntrySize call
entryBuf = "";
- readText(key->Testament(), start, size, entryBuf);
+ readText(key->getTestament(), start, size, entryBuf);
rawFilter(entryBuf, 0); // hack, decipher
rawFilter(entryBuf, key);
@@ -97,7 +100,7 @@ void RawCom4::increment(int steps) {
unsigned long size;
VerseKey *tmpkey = &getVerseKey();
- findOffset(tmpkey->Testament(), tmpkey->TestamentIndex(), &start, &size);
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size);
SWKey lastgood = *tmpkey;
while (steps) {
@@ -107,12 +110,12 @@ void RawCom4::increment(int steps) {
(steps > 0) ? ++(*key) : --(*key);
tmpkey = &getVerseKey();
- if ((error = key->Error())) {
+ if ((error = key->popError())) {
*key = lastgood;
break;
}
- long index = tmpkey->TestamentIndex();
- findOffset(tmpkey->Testament(), index, &start, &size);
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size);
if (
(((laststart != start) || (lastsize != size)) // we're a different entry
// && (start > 0)
@@ -128,14 +131,14 @@ void RawCom4::increment(int steps) {
void RawCom4::setEntry(const char *inbuf, long len) {
VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->TestamentIndex(), inbuf, len);
+ doSetText(key->getTestament(), key->getTestamentIndex(), inbuf, len);
}
void RawCom4::linkEntry(const SWKey *inkey) {
VerseKey *destkey = &getVerseKey();
const VerseKey *srckey = &getVerseKey(inkey);
- doLinkEntry(destkey->Testament(), destkey->TestamentIndex(), srckey->TestamentIndex());
+ doLinkEntry(destkey->getTestament(), destkey->getTestamentIndex(), srckey->getTestamentIndex());
}
@@ -148,7 +151,7 @@ void RawCom4::linkEntry(const SWKey *inkey) {
void RawCom4::deleteEntry() {
VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->TestamentIndex(), "");
+ doSetText(key->getTestament(), key->getTestamentIndex(), "");
}
bool RawCom4::isLinked(const SWKey *k1, const SWKey *k2) const {
@@ -156,10 +159,10 @@ bool RawCom4::isLinked(const SWKey *k1, const SWKey *k2) const {
unsigned long size1, size2;
VerseKey *vk1 = &getVerseKey(k1);
VerseKey *vk2 = &getVerseKey(k2);
- if (vk1->Testament() != vk2->Testament()) return false;
+ if (vk1->getTestament() != vk2->getTestament()) return false;
- findOffset(vk1->Testament(), vk1->TestamentIndex(), &start1, &size1);
- findOffset(vk2->Testament(), vk2->TestamentIndex(), &start2, &size2);
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2);
if (!size1 || !size2) return false;
return start1 == start2;
}
@@ -169,7 +172,7 @@ bool RawCom4::hasEntry(const SWKey *k) const {
unsigned long size;
VerseKey *vk = &getVerseKey(k);
- findOffset(vk->Testament(), vk->TestamentIndex(), &start, &size);
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size);
return size;
}
diff --git a/src/modules/comments/rawfiles/rawfiles.cpp b/src/modules/comments/rawfiles/rawfiles.cpp
index b0e24fc..7c2d524 100644
--- a/src/modules/comments/rawfiles/rawfiles.cpp
+++ b/src/modules/comments/rawfiles/rawfiles.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
- * rawfiles.cpp - code for class 'RawFiles'- a module that produces HTML HREFs
- * pointing to actual text desired. Uses standard
+ *
+ * rawfiles.cpp - code for class 'RawFiles'- a module that produces HTML
+ * HREFs pointing to actual text desired. Uses standard
* files: ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * $Id: rawfiles.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -57,31 +59,31 @@ RawFiles::~RawFiles()
/** Is the module writable? :)
* @return yes or no
*/
-bool RawFiles::isWritable() {
+bool RawFiles::isWritable() const {
return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
/******************************************************************************
- * RawFiles::getRawEntry - Returns the correct verse when char * cast
- * is requested
+ * RawFiles::getRawEntry - Retrieve the unprocessed entry contents at
+ * the current key position of this module
*
- * RET: string buffer with verse
+ * RET: entry contents
*/
-SWBuf &RawFiles::getRawEntryBuf() {
+SWBuf &RawFiles::getRawEntryBuf() const {
FileDesc *datafile;
long start = 0;
unsigned short size = 0;
VerseKey *key = &getVerseKey();
- findOffset(key->Testament(), key->TestamentIndex(), &start, &size);
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
entryBuf = "";
if (size) {
SWBuf tmpbuf = path;
tmpbuf += '/';
- readText(key->Testament(), start, size, entryBuf);
+ readText(key->getTestament(), start, size, entryBuf);
tmpbuf += entryBuf;
entryBuf = "";
datafile = FileMgr::getSystemFileMgr()->open(tmpbuf.c_str(), FileMgr::RDONLY);
@@ -102,7 +104,7 @@ SWBuf &RawFiles::getRawEntryBuf() {
/******************************************************************************
- * RawFiles::setEntry(char *)- Update the modules current key entry with
+ * RawFiles::setEntry(char *)- Update the module's current key entry with
* provided text
*/
@@ -114,13 +116,13 @@ void RawFiles::setEntry(const char *inbuf, long len) {
len = (len<0)?strlen(inbuf):len;
- findOffset(key->Testament(), key->TestamentIndex(), &start, &size);
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
if (size) {
SWBuf tmpbuf;
entryBuf = path;
entryBuf += '/';
- readText(key->Testament(), start, size, tmpbuf);
+ readText(key->getTestament(), start, size, tmpbuf);
entryBuf += tmpbuf;
}
else {
@@ -128,7 +130,7 @@ void RawFiles::setEntry(const char *inbuf, long len) {
entryBuf = path;
entryBuf += '/';
tmpbuf = getNextFilename();
- doSetText(key->Testament(), key->TestamentIndex(), tmpbuf);
+ doSetText(key->getTestament(), key->getTestamentIndex(), tmpbuf);
entryBuf += tmpbuf;
}
datafile = FileMgr::getSystemFileMgr()->open(entryBuf, FileMgr::CREAT|FileMgr::WRONLY|FileMgr::TRUNC);
@@ -152,14 +154,14 @@ void RawFiles::linkEntry(const SWKey *inkey) {
unsigned short size;
const VerseKey *key = &getVerseKey();
- findOffset(key->Testament(), key->TestamentIndex(), &start, &size);
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size);
if (size) {
SWBuf tmpbuf;
- readText(key->Testament(), start, size + 2, tmpbuf);
+ readText(key->getTestament(), start, size + 2, tmpbuf);
key = &getVerseKey(inkey);
- doSetText(key->Testament(), key->TestamentIndex(), tmpbuf.c_str());
+ doSetText(key->getTestament(), key->getTestamentIndex(), tmpbuf.c_str());
}
}
@@ -172,7 +174,7 @@ void RawFiles::linkEntry(const SWKey *inkey) {
void RawFiles::deleteEntry() {
VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->TestamentIndex(), "");
+ doSetText(key->getTestament(), key->getTestamentIndex(), "");
}
@@ -183,22 +185,22 @@ void RawFiles::deleteEntry() {
* RET: filename
*/
-char *RawFiles::getNextFilename() {
- static char incfile[255];
- __u32 number;
+const char *RawFiles::getNextFilename() {
+ static SWBuf incfile;
+ __u32 number = 0;
FileDesc *datafile;
- sprintf(incfile, "%s/incfile", path);
+ incfile.setFormatted("%s/incfile", path);
datafile = FileMgr::getSystemFileMgr()->open(incfile, FileMgr::RDONLY);
-
- if (datafile->read(&number, 4) != 4) number = 0;
- number = swordtoarch32(number);
-
+ if (datafile->getFd() != -1) {
+ if (datafile->read(&number, 4) != 4) number = 0;
+ number = swordtoarch32(number);
+ }
number++;
FileMgr::getSystemFileMgr()->close(datafile);
datafile = FileMgr::getSystemFileMgr()->open(incfile, FileMgr::CREAT|FileMgr::WRONLY|FileMgr::TRUNC);
- sprintf(incfile, "%.7d", number-1);
+ incfile.setFormatted("%.7d", number-1);
number = archtosword32(number);
datafile->write(&number, 4);
@@ -208,7 +210,7 @@ char *RawFiles::getNextFilename() {
}
-char RawFiles::createModule (const char *path) {
+char RawFiles::createModule(const char *path) {
char *incfile = new char [ strlen (path) + 16 ];
__u32 zero = 0;
diff --git a/src/modules/comments/swcom.cpp b/src/modules/comments/swcom.cpp
index e82751b..52bd61b 100644
--- a/src/modules/comments/swcom.cpp
+++ b/src/modules/comments/swcom.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * swcom.cpp - code for base class 'SWCom'- The basis for all commentary
- * modules
*
+ * swcom.cpp - code for base class 'SWCom'- The basis for all commentary
+ * modules
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swcom.cpp 2893 2013-07-16 03:07:02Z scribe $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -41,9 +43,9 @@ SWCom::SWCom(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTex
this->versification = 0;
stdstr(&(this->versification), versification);
delete key;
- key = (VerseKey *)CreateKey();
- tmpVK1 = (VerseKey *)CreateKey();
- tmpVK2 = (VerseKey *)CreateKey();
+ key = (VerseKey *)createKey();
+ tmpVK1 = (VerseKey *)createKey();
+ tmpVK2 = (VerseKey *)createKey();
tmpSecond = false;
}
@@ -59,7 +61,7 @@ SWCom::~SWCom() {
}
-SWKey *SWCom::CreateKey() const {
+SWKey *SWCom::createKey() const {
VerseKey *vk = new VerseKey();
vk->setVersificationSystem(versification);
@@ -68,22 +70,20 @@ SWKey *SWCom::CreateKey() const {
}
-long SWCom::Index() const {
+long SWCom::getIndex() const {
VerseKey *key = &getVerseKey();
- entryIndex = key->Index();
+ entryIndex = key->getIndex();
return entryIndex;
}
-long SWCom::Index(long iindex) {
+void SWCom::setIndex(long iindex) {
VerseKey *key = &getVerseKey();
- key->Testament(1);
- key->Index(iindex);
+ key->setTestament(1);
+ key->setIndex(iindex);
if (key != this->key) {
this->key->copyFrom(*key);
}
-
- return Index();
}
@@ -104,7 +104,7 @@ VerseKey &SWCom::getVerseKey(const SWKey *keyToConvert) const {
SWCATCH ( ... ) { }
if (lkTest) {
SWTRY {
- key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
+ key = SWDYNAMIC_CAST(VerseKey, lkTest->getElement());
}
SWCATCH ( ... ) { }
}
diff --git a/src/modules/comments/zcom/zcom.cpp b/src/modules/comments/zcom/zcom.cpp
index 35b8946..65c4ca8 100644
--- a/src/modules/comments/zcom/zcom.cpp
+++ b/src/modules/comments/zcom/zcom.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * rawcom.cpp - code for class 'zCom'- a module that reads raw commentary
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * zcom.cpp - code for class 'zCom'- a module that reads raw commentary
+ * files
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: zcom.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -23,6 +25,7 @@
#include <stdio.h>
#include <fcntl.h>
+#include <swbuf.h>
#include <zverse.h>
#include <versekey.h>
#include <zcom.h>
@@ -59,7 +62,7 @@ zCom::~zCom() {
}
-bool zCom::isWritable() {
+bool zCom::isWritable() const {
return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
@@ -70,17 +73,17 @@ bool zCom::isWritable() {
*
* RET: string buffer with verse
*/
-SWBuf &zCom::getRawEntryBuf() {
+SWBuf &zCom::getRawEntryBuf() const {
long start = 0;
unsigned short size = 0;
unsigned long buffnum;
VerseKey *key = &getVerseKey();
- findOffset(key->Testament(), key->TestamentIndex(), &start, &size, &buffnum);
+ findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size, &buffnum);
entrySize = size; // support getEntrySize call
entryBuf = "";
- zReadText(key->Testament(), start, size, buffnum, entryBuf);
+ zReadText(key->getTestament(), start, size, buffnum, entryBuf);
rawFilter(entryBuf, key);
@@ -92,18 +95,18 @@ SWBuf &zCom::getRawEntryBuf() {
bool zCom::sameBlock(VerseKey *k1, VerseKey *k2) {
- if (k1->Testament() != k2->Testament())
+ if (k1->getTestament() != k2->getTestament())
return false;
switch (blockType) {
case VERSEBLOCKS:
- if (k1->Verse() != k2->Verse())
+ if (k1->getVerse() != k2->getVerse())
return false;
case CHAPTERBLOCKS:
- if (k1->Chapter() != k2->Chapter())
+ if (k1->getChapter() != k2->getChapter())
return false;
case BOOKBLOCKS:
- if (k1->Book() != k2->Book())
+ if (k1->getBook() != k2->getBook())
return false;
}
return true;
@@ -120,7 +123,7 @@ void zCom::setEntry(const char *inbuf, long len) {
delete lastWriteKey;
}
- doSetText(key->Testament(), key->TestamentIndex(), inbuf, len);
+ doSetText(key->getTestament(), key->getTestamentIndex(), inbuf, len);
lastWriteKey = (VerseKey *)key->clone(); // must delete
}
@@ -130,7 +133,7 @@ void zCom::linkEntry(const SWKey *inkey) {
VerseKey *destkey = &getVerseKey();
const VerseKey *srckey = &getVerseKey(inkey);
- doLinkEntry(destkey->Testament(), destkey->TestamentIndex(), srckey->TestamentIndex());
+ doLinkEntry(destkey->getTestament(), destkey->getTestamentIndex(), srckey->getTestamentIndex());
if (inkey != srckey) // free our key if we created a VerseKey
delete srckey;
@@ -145,7 +148,7 @@ void zCom::linkEntry(const SWKey *inkey) {
void zCom::deleteEntry() {
VerseKey *key = &getVerseKey();
- doSetText(key->Testament(), key->TestamentIndex(), "");
+ doSetText(key->getTestament(), key->getTestamentIndex(), "");
}
@@ -163,7 +166,7 @@ void zCom::increment(int steps) {
unsigned long buffnum;
VerseKey *tmpkey = &getVerseKey();
- findOffset(tmpkey->Testament(), tmpkey->TestamentIndex(), &start, &size, &buffnum);
+ findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size, &buffnum);
SWKey lastgood = *tmpkey;
while (steps) {
@@ -173,12 +176,12 @@ void zCom::increment(int steps) {
(steps > 0) ? ++(*key) : --(*key);
tmpkey = &getVerseKey();
- if ((error = key->Error())) {
+ if ((error = key->popError())) {
*key = lastgood;
break;
}
- long index = tmpkey->TestamentIndex();
- findOffset(tmpkey->Testament(), index, &start, &size, &buffnum);
+ long index = tmpkey->getTestamentIndex();
+ findOffset(tmpkey->getTestament(), index, &start, &size, &buffnum);
if (
(((laststart != start) || (lastsize != size)) // we're a different entry
// && (start > 0)
@@ -197,10 +200,10 @@ bool zCom::isLinked(const SWKey *k1, const SWKey *k2) const {
unsigned long buffnum1, buffnum2;
VerseKey *vk1 = &getVerseKey(k1);
VerseKey *vk2 = &getVerseKey(k2);
- if (vk1->Testament() != vk2->Testament()) return false;
+ if (vk1->getTestament() != vk2->getTestament()) return false;
- findOffset(vk1->Testament(), vk1->TestamentIndex(), &start1, &size1, &buffnum1);
- findOffset(vk2->Testament(), vk2->TestamentIndex(), &start2, &size2, &buffnum2);
+ findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1, &buffnum1);
+ findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2, &buffnum2);
return start1 == start2 && buffnum1 == buffnum2;
}
@@ -210,7 +213,7 @@ bool zCom::hasEntry(const SWKey *k) const {
unsigned long buffnum;
VerseKey *vk = &getVerseKey(k);
- findOffset(vk->Testament(), vk->TestamentIndex(), &start, &size, &buffnum);
+ findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size, &buffnum);
return size;
}
diff --git a/src/modules/common/Makefile.am b/src/modules/common/Makefile.am
index 34a14bf..90a3f98 100644
--- a/src/modules/common/Makefile.am
+++ b/src/modules/common/Makefile.am
@@ -6,7 +6,9 @@ libsword_la_SOURCES += $(commondir)/swcomprs.cpp
libsword_la_SOURCES += $(commondir)/lzsscomprs.cpp
if HAVE_LIBZ
-SWZLIB = $(commondir)/zipcomprs.cpp
+SWZLIB = $(commondir)/zipcomprs.cpp
+SWZLIB += $(commondir)/bz2comprs.cpp
+SWZLIB += $(commondir)/xzcomprs.cpp
else
SWZLIB =
endif
diff --git a/src/modules/common/bz2comprs.cpp b/src/modules/common/bz2comprs.cpp
new file mode 100644
index 0000000..16f6d11
--- /dev/null
+++ b/src/modules/common/bz2comprs.cpp
@@ -0,0 +1,181 @@
+/******************************************************************************
+ *
+ * bz2comprs.cpp - Bzip2Compress, a driver class that provides bzip2
+ * compression (Burrows–Wheeler with Huffman coding)
+ *
+ * $Id: bz2comprs.cpp 2858 2013-07-08 03:08:10Z chrislit $
+ *
+ * Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <bz2comprs.h>
+#include <zlib.h>
+
+SWORD_NAMESPACE_START
+
+/******************************************************************************
+ * Bzip2Compress Constructor - Initializes data for instance of Bzip2Compress
+ *
+ */
+
+Bzip2Compress::Bzip2Compress() : SWCompress() {
+}
+
+
+/******************************************************************************
+ * Bzip2Compress Destructor - Cleans up instance of Bzip2Compress
+ */
+
+Bzip2Compress::~Bzip2Compress() {
+}
+
+
+/******************************************************************************
+ * Bzip2Compress::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 Bzip2Compress::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, "ERROR: no buffer to compress\n");
+ }
+ delete [] zbuf;
+ free (buf);
+}
+
+
+/******************************************************************************
+ * Bzip2Compress::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 Bzip2Compress::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);
+ slen = 0;
+ switch (uncompress((Bytef*)buf, &blen, (Bytef*)zbuf, zlen)){
+ case Z_OK: SendChars(buf, blen); slen = blen; break;
+ case Z_MEM_ERROR: fprintf(stderr, "ERROR: not enough memory during decompression.\n"); break;
+ case Z_BUF_ERROR: fprintf(stderr, "ERROR: not enough room in the out buffer during decompression.\n"); break;
+ case Z_DATA_ERROR: fprintf(stderr, "ERROR: corrupt data during decompression.\n"); break;
+ default: fprintf(stderr, "ERROR: an unknown error occured during decompression.\n"); break;
+ }
+ delete [] buf;
+ }
+ else {
+ fprintf(stderr, "ERROR: no buffer to decompress!\n");
+ }
+ //printf("Finished decoding\n");
+ free (zbuf);
+}
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/common/compress.cpp.txt b/src/modules/common/compress.cpp.txt
deleted file mode 100644
index 5031adb..0000000
--- a/src/modules/common/compress.cpp.txt
+++ /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
index 6e4c9aa..4872d28 100644
--- a/src/modules/common/entriesblk.cpp
+++ b/src/modules/common/entriesblk.cpp
@@ -1,5 +1,10 @@
-/*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+/******************************************************************************
+ *
+ * entriesblk.cpp - EntriesBlock facilitates compressed lex/dict modules
+ *
+ * $Id: entriesblk.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/common/lzsscomprs.cpp b/src/modules/common/lzsscomprs.cpp
index 624942d..ef1bc8c 100644
--- a/src/modules/common/lzsscomprs.cpp
+++ b/src/modules/common/lzsscomprs.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * lzsscomprs.cpp - code for class 'LZSSCompress'- a driver class that
- * provides LZSS compression
*
+ * lzssomprs.cpp - LZSSCompress: a driver class that provides LZSS
+ * compression
+ *
+ * $Id: lzsscomprs.cpp 2935 2013-08-02 11:06:30Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -23,8 +25,52 @@
#include <string.h>
#include <lzsscomprs.h>
+// 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
+
+
SWORD_NAMESPACE_START
+class LZSSCompress::Private {
+public:
+ static unsigned char m_ring_buffer[N + F - 1];
+ static short int m_match_position;
+ static short int m_match_length;
+ static short int m_lson[N + 1];
+ static short int m_rson[N + 257];
+ static short int m_dad[N + 1];
+ void InitTree();
+ void InsertNode(short int Pos);
+ void DeleteNode(short int Node);
+};
+
/******************************************************************************
* LZSSCompress Statics
*/
@@ -44,7 +90,7 @@ SWORD_NAMESPACE_START
// 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];
+unsigned char LZSSCompress::Private::m_ring_buffer[N + F - 1];
// m_match_position and m_match_length are set by InsertNode().
//
@@ -52,8 +98,8 @@ unsigned char LZSSCompress::m_ring_buffer[N + F - 1];
// 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;
+short int LZSSCompress::Private::m_match_position;
+short int LZSSCompress::Private::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
@@ -73,9 +119,9 @@ short int LZSSCompress::m_match_length;
// 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];
+short int LZSSCompress::Private::m_lson[N + 1];
+short int LZSSCompress::Private::m_rson[N + 257];
+short int LZSSCompress::Private::m_dad[N + 1];
/******************************************************************************
@@ -84,6 +130,7 @@ short int LZSSCompress::m_dad[N + 1];
*/
LZSSCompress::LZSSCompress() : SWCompress() {
+ p = new Private();
}
@@ -92,6 +139,7 @@ LZSSCompress::LZSSCompress() : SWCompress() {
*/
LZSSCompress::~LZSSCompress() {
+ delete p;
}
@@ -100,7 +148,7 @@ LZSSCompress::~LZSSCompress() {
* "empty" states.
*/
-void LZSSCompress::InitTree(void) {
+void LZSSCompress::Private::InitTree(void) {
int i;
// For i = 0 to N - 1, m_rson[i] and m_lson[i] will be the right
@@ -159,7 +207,7 @@ void LZSSCompress::InitTree(void) {
* ENT: pos - position in the buffer
*/
-void LZSSCompress::InsertNode(short int Pos)
+void LZSSCompress::Private::InsertNode(short int Pos)
{
short int i;
short int p;
@@ -257,7 +305,7 @@ void LZSSCompress::InsertNode(short int Pos)
* ENT: node - node to be removed
*/
-void LZSSCompress::DeleteNode(short int Node)
+void LZSSCompress::Private::DeleteNode(short int Node)
{
short int q;
@@ -330,7 +378,7 @@ void LZSSCompress::Encode(void)
// Start with a clean tree.
- InitTree();
+ p->InitTree();
direct = 0; // set direction needed by parent [Get|Send]Chars()
// code_buf[0] works as eight flags. A "1" represents that the
@@ -366,14 +414,14 @@ void LZSSCompress::Encode(void)
// This is because those F bytes will be filled in immediately
// with bytes from the input stream.
- memset(m_ring_buffer, ' ', N - F);
+ memset(p->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);
+ len = GetChars((char *) &(p->m_ring_buffer[r]), F);
// Make sure there is something to be compressed.
@@ -386,13 +434,13 @@ void LZSSCompress::Encode(void)
// to occur.
for (i = 1; i <= F; i++) {
- InsertNode((short int) (r - i));
+ p->InsertNode((short int) (r - i));
}
// Finally, insert the whole string just read. The
// member variables match_length and match_position are set.
- InsertNode(r);
+ p->InsertNode(r);
// Now that we're preloaded, continue till done.
@@ -401,20 +449,20 @@ void LZSSCompress::Encode(void)
// m_match_length may be spuriously long near the end of
// text.
- if (m_match_length > len) {
- m_match_length = len;
+ if (p->m_match_length > len) {
+ p->m_match_length = len;
}
// Is it cheaper to store this as a single character? If so,
// make it so.
- if (m_match_length < THRESHOLD) {
+ if (p->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;
+ p->m_match_length = 1;
code_buf[0] |= mask;
- code_buf[code_buf_pos++] = m_ring_buffer[r];
+ code_buf[code_buf_pos++] = p->m_ring_buffer[r];
}
// Otherwise, we do indeed have a string that can be stored
@@ -424,10 +472,10 @@ void LZSSCompress::Encode(void)
// 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) p->m_match_position;
code_buf[code_buf_pos++] = (unsigned char) (
- ((m_match_position >> 4) & 0xf0) |
- (m_match_length - THRESHOLD) );
+ ((p->m_match_position >> 4) & 0xf0) |
+ (p->m_match_length - THRESHOLD) );
}
// Shift the mask one bit to the left so that it will be ready
@@ -452,7 +500,7 @@ void LZSSCompress::Encode(void)
mask = 1;
}
- last_match_length = m_match_length;
+ last_match_length = p->m_match_length;
// Delete old strings and read new bytes...
@@ -464,7 +512,7 @@ void LZSSCompress::Encode(void)
// Delete "old strings"
- DeleteNode(s);
+ p->DeleteNode(s);
// Put this character into the ring buffer.
//
@@ -491,10 +539,10 @@ void LZSSCompress::Encode(void)
// |
// duplicate of front of buffer
- m_ring_buffer[s] = c;
+ p->m_ring_buffer[s] = c;
if (s < F - 1) {
- m_ring_buffer[s + N] = c;
+ p->m_ring_buffer[s + N] = c;
}
// Increment the position, and wrap around when we're at
@@ -506,7 +554,7 @@ void LZSSCompress::Encode(void)
// Register the string that is found in
// m_ring_buffer[r..r+F-1].
- InsertNode(r);
+ p->InsertNode(r);
}
// If we didn't quit because we hit the last_match_length,
@@ -514,7 +562,7 @@ void LZSSCompress::Encode(void)
// to process.
while (i++ < last_match_length) {
- DeleteNode(s);
+ p->DeleteNode(s);
s = (short int) ( (s + 1) & (N - 1) );
r = (short int) ( (r + 1) & (N - 1) );
@@ -527,7 +575,7 @@ void LZSSCompress::Encode(void)
// short strings).
if (--len) {
- InsertNode(r); /* buffer may not be empty. */
+ p->InsertNode(r); /* buffer may not be empty. */
}
}
@@ -577,7 +625,7 @@ void LZSSCompress::Decode(void)
//
// Note that the last F bytes of the ring buffer are not filled.
- memset(m_ring_buffer, ' ', N - F);
+ memset(p->m_ring_buffer, ' ', N - F);
r = N - F;
@@ -624,7 +672,7 @@ void LZSSCompress::Decode(void)
// Add to buffer, and increment to next spot. Wrap at end.
- m_ring_buffer[r] = c[0];
+ p->m_ring_buffer[r] = c[0];
r = (short int) ( (r + 1) & (N - 1) );
}
@@ -662,11 +710,11 @@ void LZSSCompress::Decode(void)
// len is never more than F.
for (k = 0; k < len; k++) {
- c[k] = m_ring_buffer[(pos + k) & (N - 1)];
+ c[k] = p->m_ring_buffer[(pos + k) & (N - 1)];
// Add to buffer, and increment to next spot. Wrap at end.
- m_ring_buffer[r] = c[k];
+ p->m_ring_buffer[r] = c[k];
r = (short int) ( (r + 1) & (N - 1) );
}
diff --git a/src/modules/common/swcomprs.doc b/src/modules/common/lzsscomprs.txt
index b6817f2..b6817f2 100644
--- a/src/modules/common/swcomprs.doc
+++ b/src/modules/common/lzsscomprs.txt
diff --git a/src/modules/common/rawstr.cpp b/src/modules/common/rawstr.cpp
index 6f17628..788ab6e 100644
--- a/src/modules/common/rawstr.cpp
+++ b/src/modules/common/rawstr.cpp
@@ -1,11 +1,13 @@
/******************************************************************************
- * 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
*
+ * 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
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawstr.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -54,7 +56,7 @@ const int RawStr::IDXENTRYSIZE = 6;
* (e.g. 'modules/texts/rawtext/webster/')
*/
-RawStr::RawStr(const char *ipath, int fileMode)
+RawStr::RawStr(const char *ipath, int fileMode, bool caseSensitive) : caseSensitive(caseSensitive)
{
SWBuf buf;
@@ -121,7 +123,7 @@ void RawStr::getIDXBufDat(long ioffset, char **buf) const
datfd->read(*buf, size);
}
(*buf)[size] = 0;
- toupperstr_utf8(*buf, size*2);
+ if (!caseSensitive) toupperstr_utf8(*buf, size*2);
}
else {
*buf = (*buf) ? (char *)realloc(*buf, 1) : (char *)malloc(1);
@@ -181,7 +183,7 @@ signed char RawStr::findOffset(const char *ikey, __u32 *start, __u16 *size, long
headoff = 0;
stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
+ if (!caseSensitive) toupperstr_utf8(key, strlen(key)*3);
int keylen = strlen(key);
bool substr = false;
@@ -302,7 +304,7 @@ signed char RawStr::findOffset(const char *ikey, __u32 *start, __u16 *size, long
*
*/
-void RawStr::readText(__u32 istart, __u16 *isize, char **idxbuf, SWBuf &buf)
+void RawStr::readText(__u32 istart, __u16 *isize, char **idxbuf, SWBuf &buf) const
{
unsigned int ch;
char *idxbuflocal = 0;
@@ -380,7 +382,7 @@ void RawStr::doSetText(const char *ikey, const char *buf, long len)
char errorStatus = findOffset(ikey, &start, &size, 0, &idxoff);
stdstr(&key, ikey, 2);
- toupperstr_utf8(key, strlen(key)*2);
+ if (!caseSensitive) toupperstr_utf8(key, strlen(key)*2);
len = (len < 0) ? strlen(buf) : len;
diff --git a/src/modules/common/rawstr4.cpp b/src/modules/common/rawstr4.cpp
index 003b2fe..e2ce899 100644
--- a/src/modules/common/rawstr4.cpp
+++ b/src/modules/common/rawstr4.cpp
@@ -1,11 +1,13 @@
/******************************************************************************
- * 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
*
+ * rawstr4.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
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawstr4.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -53,7 +55,7 @@ const int RawStr4::IDXENTRYSIZE = 8;
* (e.g. 'modules/texts/rawtext/webster/')
*/
-RawStr4::RawStr4(const char *ipath, int fileMode)
+RawStr4::RawStr4(const char *ipath, int fileMode, bool caseSensitive) : caseSensitive(caseSensitive)
{
SWBuf buf;
@@ -121,7 +123,7 @@ void RawStr4::getIDXBufDat(long ioffset, char **buf) const
datfd->read(*buf, size);
}
(*buf)[size] = 0;
- toupperstr_utf8(*buf, size*2);
+ if (!caseSensitive) toupperstr_utf8(*buf, size*2);
}
else {
*buf = (*buf) ? (char *)realloc(*buf, 1) : (char *)malloc(1);
@@ -157,7 +159,7 @@ void RawStr4::getIDXBuf(long ioffset, char **buf) const
}
*targetbuf = 0;
trybuf = 0;
- toupperstr_utf8(targetbuf);
+ if (!caseSensitive) toupperstr_utf8(targetbuf);
*/
}
}
@@ -191,7 +193,7 @@ signed char RawStr4::findOffset(const char *ikey, __u32 *start, __u32 *size, lon
headoff = 0;
stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
+ if (!caseSensitive) toupperstr_utf8(key, strlen(key)*3);
int keylen = strlen(key);
bool substr = false;
@@ -311,7 +313,7 @@ signed char RawStr4::findOffset(const char *ikey, __u32 *start, __u32 *size, lon
*
*/
-void RawStr4::readText(__u32 istart, __u32 *isize, char **idxbuf, SWBuf &buf)
+void RawStr4::readText(__u32 istart, __u32 *isize, char **idxbuf, SWBuf &buf) const
{
unsigned int ch;
char *idxbuflocal = 0;
@@ -388,7 +390,7 @@ void RawStr4::doSetText(const char *ikey, const char *buf, long len) {
char errorStatus = findOffset(ikey, &start, &size, 0, &idxoff);
stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
+ if (!caseSensitive) toupperstr_utf8(key, strlen(key)*3);
len = (len < 0) ? strlen(buf) : len;
getIDXBufDat(start, &dbKey);
diff --git a/src/modules/common/rawverse.cpp b/src/modules/common/rawverse.cpp
index 99beaa2..5527d38 100644
--- a/src/modules/common/rawverse.cpp
+++ b/src/modules/common/rawverse.cpp
@@ -1,11 +1,12 @@
/******************************************************************************
- * rawverse.cpp - code for class 'RawVerse'- a module that reads raw text
+ *
+ * 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
*
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -149,7 +150,7 @@ void RawVerse::findOffset(char testmt, long idxoff, long *start, unsigned short
*
*/
-void RawVerse::readText(char testmt, long start, unsigned short size, SWBuf &buf) {
+void RawVerse::readText(char testmt, long start, unsigned short size, SWBuf &buf) const {
buf = "";
buf.setFillByte(0);
buf.setSize(size + 1);
@@ -278,15 +279,15 @@ char RawVerse::createModule(const char *ipath, const char *v11n)
VerseKey vk;
vk.setVersificationSystem(v11n);
- vk.Headings(1);
+ vk.setIntros(1);
__s32 offset = 0;
__u16 size = 0;
offset = archtosword32(offset);
size = archtosword16(size);
- for (vk = TOP; !vk.Error(); vk++) {
- if (vk.Testament() < 2) {
+ for (vk = TOP; !vk.popError(); vk++) {
+ if (vk.getTestament() < 2) {
fd->write(&offset, 4);
fd->write(&size, 2);
}
diff --git a/src/modules/common/rawverse4.cpp b/src/modules/common/rawverse4.cpp
index ee0b207..b87ea0d 100644
--- a/src/modules/common/rawverse4.cpp
+++ b/src/modules/common/rawverse4.cpp
@@ -1,11 +1,14 @@
/******************************************************************************
- * rawverse.cpp - code for class 'RawVerse4'- a module that reads raw text
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
+ *
+ * rawverse4.cpp - code for class 'RawVerse4'- 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
*
+ * $Id: rawverse4.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2007-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -149,7 +152,7 @@ void RawVerse4::findOffset(char testmt, long idxoff, long *start, unsigned long
*
*/
-void RawVerse4::readText(char testmt, long start, unsigned long size, SWBuf &buf) {
+void RawVerse4::readText(char testmt, long start, unsigned long size, SWBuf &buf) const {
buf = "";
buf.setFillByte(0);
buf.setSize(size + 1);
@@ -278,14 +281,14 @@ char RawVerse4::createModule(const char *ipath, const char *v11n)
VerseKey vk;
vk.setVersificationSystem(v11n);
- vk.Headings(1);
+ vk.setIntros(1);
__u32 offset = 0;
__u32 size = 0;
offset = archtosword32(offset);
size = archtosword32(size);
- for (vk = TOP; !vk.Error(); vk++) {
- if (vk.Testament() < 2) {
+ for (vk = TOP; !vk.popError(); vk++) {
+ if (vk.getTestament() < 2) {
fd->write(&offset, 4);
fd->write(&size, 4);
}
diff --git a/src/modules/common/sapphire.cpp b/src/modules/common/sapphire.cpp
index 7b141d2..8cc3e15 100644
--- a/src/modules/common/sapphire.cpp
+++ b/src/modules/common/sapphire.cpp
@@ -1,15 +1,39 @@
-/* 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
-*/
-
+/******************************************************************************
+ *
+ * sapphire.cpp - the Saphire II stream cipher class
+ *
+ * $Id: sapphire.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+/******************************************************************************
+ *
+ * Original license notice & credits:
+ * 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
+ *
+ */
#include <string.h>
diff --git a/src/modules/common/swcipher.cpp b/src/modules/common/swcipher.cpp
index 5ab91ea..16279dc 100644
--- a/src/modules/common/swcipher.cpp
+++ b/src/modules/common/swcipher.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * swcipher.cpp - code for class 'SWCipher'- a driver class that provides
- * cipher utilities.
*
+ * swcipher.cpp - code for class 'SWCipher'- a driver class that
+ * provides cipher utilities
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swcipher.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/common/swcomprs.cpp b/src/modules/common/swcomprs.cpp
index 378c8b1..9df8e7d 100644
--- a/src/modules/common/swcomprs.cpp
+++ b/src/modules/common/swcomprs.cpp
@@ -1,9 +1,10 @@
/******************************************************************************
- * swcomprs.cpp - code for class 'SWCompress'- a driver class that provides
- * compression utilities.
*
+ * swcomprs.cpp - a driver class that provides compression utilities
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swcomprs.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/common/xzcomprs.cpp b/src/modules/common/xzcomprs.cpp
new file mode 100644
index 0000000..db8a4a8
--- /dev/null
+++ b/src/modules/common/xzcomprs.cpp
@@ -0,0 +1,181 @@
+/******************************************************************************
+ *
+ * xzcomprs.cpp - XzCompress, a driver class that provides xz (LZMA2)
+ * compression
+ *
+ * $Id: xzcomprs.cpp 2850 2013-07-02 09:57:20Z chrislit $
+ *
+ * Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <xzcomprs.h>
+#include <zlib.h>
+
+SWORD_NAMESPACE_START
+
+/******************************************************************************
+ * XzCompress Constructor - Initializes data for instance of XzCompress
+ *
+ */
+
+XzCompress::XzCompress() : SWCompress() {
+}
+
+
+/******************************************************************************
+ * XzCompress Destructor - Cleans up instance of XzCompress
+ */
+
+XzCompress::~XzCompress() {
+}
+
+
+/******************************************************************************
+ * XzCompress::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 XzCompress::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, "ERROR: no buffer to compress\n");
+ }
+ delete [] zbuf;
+ free (buf);
+}
+
+
+/******************************************************************************
+ * XzCompress::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 XzCompress::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);
+ slen = 0;
+ switch (uncompress((Bytef*)buf, &blen, (Bytef*)zbuf, zlen)){
+ case Z_OK: SendChars(buf, blen); slen = blen; break;
+ case Z_MEM_ERROR: fprintf(stderr, "ERROR: not enough memory during decompression.\n"); break;
+ case Z_BUF_ERROR: fprintf(stderr, "ERROR: not enough room in the out buffer during decompression.\n"); break;
+ case Z_DATA_ERROR: fprintf(stderr, "ERROR: corrupt data during decompression.\n"); break;
+ default: fprintf(stderr, "ERROR: an unknown error occured during decompression.\n"); break;
+ }
+ delete [] buf;
+ }
+ else {
+ fprintf(stderr, "ERROR: no buffer to decompress!\n");
+ }
+ //printf("Finished decoding\n");
+ free (zbuf);
+}
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/common/zipcomprs.cpp b/src/modules/common/zipcomprs.cpp
index 534d840..3e44abd 100644
--- a/src/modules/common/zipcomprs.cpp
+++ b/src/modules/common/zipcomprs.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * swcomprs.cpp - code for class 'ZipCompress'- a driver class that provides
- * compression utilities. - using zlib
*
+ * zipcomprs.cpp - ZipCompress, a driver class that provides zlib
+ * compression
+ *
+ * $Id: zipcomprs.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/common/zstr.cpp b/src/modules/common/zstr.cpp
index 5b4da64..a745502 100644
--- a/src/modules/common/zstr.cpp
+++ b/src/modules/common/zstr.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
- * zstr.cpp - code for class 'zStr'- a module that reads compressed text
+ *
+ * zstr.cpp - code for class 'zStr'- a module that reads compressed text
* files and provides lookup and parsing functions based on
* class StrKey
*
+ * $Id: zstr.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -54,11 +56,10 @@ const int zStr::ZDXENTRYSIZE = 8;
* ENT: ipath - path of the directory where data and index files are located.
*/
-zStr::zStr(const char *ipath, int fileMode, long blockCount, SWCompress *icomp)
+zStr::zStr(const char *ipath, int fileMode, long blockCount, SWCompress *icomp, bool caseSensitive) : caseSensitive(caseSensitive)
{
SWBuf buf;
- nl = '\n';
lastoff = -1;
path = 0;
stdstr(&path, ipath);
@@ -144,7 +145,7 @@ void zStr::getKeyFromDatOffset(long ioffset, char **buf) const
datfd->read(*buf, size);
}
(*buf)[size] = 0;
- toupperstr_utf8(*buf, size*2);
+ if (!caseSensitive) toupperstr_utf8(*buf, size*2);
}
else {
*buf = (*buf) ? (char *)realloc(*buf, 1) : (char *)malloc(1);
@@ -201,7 +202,7 @@ signed char zStr::findKeyIndex(const char *ikey, long *idxoff, long away) const
if (*ikey) {
headoff = 0;
stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
+ if (!caseSensitive) toupperstr_utf8(key, strlen(key)*3);
int keylen = strlen(key);
bool substr = false;
@@ -321,7 +322,7 @@ signed char zStr::findKeyIndex(const char *ikey, long *idxoff, long away) const
*
*/
-void zStr::getText(long offset, char **idxbuf, char **buf) {
+void zStr::getText(long offset, char **idxbuf, char **buf) const {
char *ch;
char *idxbuflocal = 0;
getKeyFromIdxOffset(offset, &idxbuflocal);
@@ -386,7 +387,7 @@ void zStr::getText(long offset, char **idxbuf, char **buf) {
* file.
*/
-void zStr::getCompressedText(long block, long entry, char **buf) {
+void zStr::getCompressedText(long block, long entry, char **buf) const {
__u32 size = 0;
@@ -431,12 +432,13 @@ void zStr::getCompressedText(long block, long entry, char **buf) {
void zStr::setText(const char *ikey, const char *buf, long len) {
+ static const char nl[] = {13, 10};
+
__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;
@@ -446,7 +448,7 @@ void zStr::setText(const char *ikey, const char *buf, long len) {
len = (len < 0) ? strlen(buf) : len;
stdstr(&key, ikey, 3);
- toupperstr_utf8(key, strlen(key)*3);
+ if (!caseSensitive) toupperstr_utf8(key, strlen(key)*3);
char notFound = findKeyIndex(ikey, &idxoff, 0);
if (!notFound) {
@@ -583,7 +585,10 @@ void zStr::linkEntry(const char *destkey, const char *srckey) {
}
-void zStr::flushCache() {
+void zStr::flushCache() const {
+
+ static const char nl[] = {13, 10};
+
if (cacheBlock) {
if (cacheDirty) {
__u32 start = 0;
diff --git a/src/modules/common/zverse.cpp b/src/modules/common/zverse.cpp
index fa76467..c280d98 100644
--- a/src/modules/common/zverse.cpp
+++ b/src/modules/common/zverse.cpp
@@ -1,11 +1,13 @@
/******************************************************************************
- * zverse.h - code for class 'zVerse'- a module that reads raw text
+ *
+ * zverse.cpp - code for class 'zVerse'- a module that reads raw text
* files: ot and nt using indexs ??.bks ??.cps ??.vss
* and provides lookup and parsing functions based on
* class VerseKey for compressed modules
*
+ * $Id: zverse.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1996-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -155,7 +157,7 @@ void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *s
// set size to
// set
*start = *size = *buffnum = 0;
- //printf ("Finding offset %ld\n", idxoff);
+ //fprintf(stderr, "Finding offset %ld\n", idxoff);
idxoff *= 10;
if (!testmt) {
testmt = ((idxfp[0]) ? 1:2);
@@ -168,7 +170,7 @@ void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *s
long newOffset = compfp[testmt-1]->seek(idxoff, SEEK_SET);
if (newOffset == idxoff) {
if (compfp[testmt-1]->read(&ulBuffNum, 4) != 4) {
- printf ("Error reading ulBuffNum\n");
+ fprintf(stderr, "Error reading ulBuffNum\n");
return;
}
}
@@ -176,12 +178,12 @@ void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *s
if (compfp[testmt-1]->read(&ulVerseStart, 4) < 2)
{
- printf ("Error reading ulVerseStart\n");
+ fprintf(stderr, "Error reading ulVerseStart\n");
return;
}
if (compfp[testmt-1]->read(&usVerseSize, 2) < 2)
{
- printf ("Error reading usVerseSize\n");
+ fprintf(stderr, "Error reading usVerseSize\n");
return;
}
@@ -202,7 +204,7 @@ void zVerse::findOffset(char testmt, long idxoff, long *start, unsigned short *s
*
*/
-void zVerse::zReadText(char testmt, long start, unsigned short size, unsigned long ulBuffNum, SWBuf &inBuf) {
+void zVerse::zReadText(char testmt, long start, unsigned short size, unsigned long ulBuffNum, SWBuf &inBuf) const {
__u32 ulCompOffset = 0; // compressed buffer start
__u32 ulCompSize = 0; // buffer size compressed
__u32 ulUnCompSize = 0; // buffer size uncompressed
@@ -217,26 +219,26 @@ void zVerse::zReadText(char testmt, long start, unsigned short size, unsigned lo
if (size &&
!(((long) ulBuffNum == cacheBufIdx) && (testmt == cacheTestament) && (cacheBuf))) {
- //printf ("Got buffer number{%ld} versestart{%ld} versesize{%d}\n", ulBuffNum, ulVerseStart, usVerseSize);
+ //fprintf(stderr, "Got buffer number{%ld} versestart{%ld} versesize{%d}\n", ulBuffNum, ulVerseStart, usVerseSize);
if (idxfp[testmt-1]->seek(ulBuffNum*12, SEEK_SET)!=(long) ulBuffNum*12)
{
- printf ("Error seeking compressed file index\n");
+ fprintf(stderr, "Error seeking compressed file index\n");
return;
}
if (idxfp[testmt-1]->read(&ulCompOffset, 4)<4)
{
- printf ("Error reading ulCompOffset\n");
+ fprintf(stderr, "Error reading ulCompOffset\n");
return;
}
if (idxfp[testmt-1]->read(&ulCompSize, 4)<4)
{
- printf ("Error reading ulCompSize\n");
+ fprintf(stderr, "Error reading ulCompSize\n");
return;
}
if (idxfp[testmt-1]->read(&ulUnCompSize, 4)<4)
{
- printf ("Error reading ulUnCompSize\n");
+ fprintf(stderr, "Error reading ulUnCompSize\n");
return;
}
@@ -246,14 +248,14 @@ void zVerse::zReadText(char testmt, long start, unsigned short size, unsigned lo
if (textfp[testmt-1]->seek(ulCompOffset, SEEK_SET)!=(long)ulCompOffset)
{
- printf ("Error: could not seek to right place in compressed text\n");
+ fprintf(stderr, "Error: could not seek to right place in compressed text\n");
return;
}
SWBuf pcCompText;
pcCompText.setSize(ulCompSize+5);
if (textfp[testmt-1]->read(pcCompText.getRawData(), ulCompSize)<(long)ulCompSize) {
- printf ("Error reading compressed text\n");
+ fprintf(stderr, "Error reading compressed text\n");
return;
}
pcCompText.setSize(ulCompSize);
@@ -335,7 +337,7 @@ void zVerse::doSetText(char testmt, long idxoff, const char *buf, long len) {
}
-void zVerse::flushCache() {
+void zVerse::flushCache() const {
if (dirtyCache) {
__u32 idxoff;
__u32 start, outstart;
@@ -469,15 +471,15 @@ char zVerse::createModule(const char *ipath, int blockBound, const char *v11n)
VerseKey vk;
vk.setVersificationSystem(v11n);
- vk.Headings(1);
+ vk.setIntros(true);
__s32 offset = 0;
__s16 size = 0;
offset = archtosword32(offset);
size = archtosword16(size);
- for (vk = TOP; !vk.Error(); vk++) {
- if (vk.Testament() < 2) {
+ for (vk = TOP; !vk.popError(); vk++) {
+ if (vk.getTestament() < 2) {
fd->write(&offset, 4); //compBufIdxOffset
fd->write(&offset, 4);
fd->write(&size, 2);
diff --git a/src/modules/filters/Makefile.am b/src/modules/filters/Makefile.am
index 80e65d9..a3d1154 100644
--- a/src/modules/filters/Makefile.am
+++ b/src/modules/filters/Makefile.am
@@ -5,6 +5,7 @@ libsword_la_SOURCES += $(filtersdir)/swoptfilter.cpp
GBFFIL = $(filtersdir)/gbfhtml.cpp
GBFFIL += $(filtersdir)/gbfhtmlhref.cpp
+GBFFIL += $(filtersdir)/gbfxhtml.cpp
GBFFIL += $(filtersdir)/gbfwebif.cpp
GBFFIL += $(filtersdir)/gbfplain.cpp
GBFFIL += $(filtersdir)/gbfrtf.cpp
@@ -26,12 +27,14 @@ THMLFIL += $(filtersdir)/thmlgbf.cpp
THMLFIL += $(filtersdir)/thmlrtf.cpp
THMLFIL += $(filtersdir)/thmlhtml.cpp
THMLFIL += $(filtersdir)/thmlhtmlhref.cpp
+THMLFIL += $(filtersdir)/thmlxhtml.cpp
THMLFIL += $(filtersdir)/thmlwebif.cpp
THMLFIL += $(filtersdir)/thmlwordjs.cpp
TEIFIL = $(filtersdir)/teiplain.cpp
TEIFIL += $(filtersdir)/teirtf.cpp
TEIFIL += $(filtersdir)/teihtmlhref.cpp
+TEIFIL += $(filtersdir)/teixhtml.cpp
CONVFIL = $(filtersdir)/gbfthml.cpp
CONVFIL += $(filtersdir)/gbfosis.cpp
@@ -42,6 +45,7 @@ CONVFIL += $(filtersdir)/osisosis.cpp
OSISFIL = $(filtersdir)/osisheadings.cpp
OSISFIL += $(filtersdir)/osisfootnotes.cpp
OSISFIL += $(filtersdir)/osishtmlhref.cpp
+OSISFIL += $(filtersdir)/osisxhtml.cpp
OSISFIL += $(filtersdir)/osiswebif.cpp
OSISFIL += $(filtersdir)/osismorph.cpp
OSISFIL += $(filtersdir)/osisstrongs.cpp
@@ -53,7 +57,10 @@ OSISFIL += $(filtersdir)/osisscripref.cpp
OSISFIL += $(filtersdir)/osisvariants.cpp
OSISFIL += $(filtersdir)/osiswordjs.cpp
OSISFIL += $(filtersdir)/osismorphsegmentation.cpp
-OSISFIL += $(filtersdir)/osisruby.cpp
+OSISFIL += $(filtersdir)/osisglosses.cpp
+OSISFIL += $(filtersdir)/osisenum.cpp
+OSISFIL += $(filtersdir)/osisxlit.cpp
+OSISFIL += $(filtersdir)/osisreferencelinks.cpp
libsword_la_SOURCES += $(filtersdir)/latin1utf8.cpp
libsword_la_SOURCES += $(filtersdir)/latin1utf16.cpp
@@ -61,6 +68,8 @@ libsword_la_SOURCES += $(filtersdir)/utf8utf16.cpp
libsword_la_SOURCES += $(filtersdir)/utf16utf8.cpp
libsword_la_SOURCES += $(filtersdir)/utf8html.cpp
libsword_la_SOURCES += $(filtersdir)/utf8latin1.cpp
+libsword_la_SOURCES += $(filtersdir)/unicodertf.cpp
+libsword_la_SOURCES += $(filtersdir)/scsuutf8.cpp
libsword_la_SOURCES += $(filtersdir)/utf8cantillation.cpp
libsword_la_SOURCES += $(filtersdir)/utf8hebrewpoints.cpp
@@ -70,10 +79,7 @@ libsword_la_SOURCES += $(filtersdir)/utf8greekaccents.cpp
libsword_la_SOURCES += $(filtersdir)/cipherfil.cpp
PLFIL = $(filtersdir)/rtfhtml.cpp
-PLFIL += $(filtersdir)/plainfootnotes.cpp
-PLFIL += $(filtersdir)/plainhtml.cpp
PLFIL += $(filtersdir)/greeklexattribs.cpp
-PLFIL += $(filtersdir)/unicodertf.cpp
PLFIL += $(filtersdir)/papyriplain.cpp
diff --git a/src/modules/filters/cipherfil.cpp b/src/modules/filters/cipherfil.cpp
index 34d0465..e5422f3 100644
--- a/src/modules/filters/cipherfil.cpp
+++ b/src/modules/filters/cipherfil.cpp
@@ -1,8 +1,11 @@
/******************************************************************************
*
- * cipherfil - SWFilter descendant to decipher a module
+ * cipherfil.cpp - CipherFilter, a SWFilter descendant to decipher
+ * a module
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: cipherfil.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,8 +27,10 @@
#include <swcipher.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
CipherFilter::CipherFilter(const char *key) {
cipher = new SWCipher((unsigned char *)key);
}
@@ -58,4 +63,6 @@ char CipherFilter::processText(SWBuf &text, const SWKey *key, const SWModule *mo
return 0;
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/modules/filters/gbffootnotes.cpp b/src/modules/filters/gbffootnotes.cpp
index a5384cb..7b867f1 100644
--- a/src/modules/filters/gbffootnotes.cpp
+++ b/src/modules/filters/gbffootnotes.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
*
- * gbffootnotes - SWFilter descendant to hide or show footnotes
- * in a GBF module.
+ * gbffootnotes.cpp - SWFilter descendant to hide or show footnotes
+ * in a GBF module
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: gbffootnotes.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,17 +30,23 @@
#include <versekey.h>
#include <utilxml.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Footnotes";
-const char oTip[] = "Toggles Footnotes On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Footnotes";
+ static const char oTip[] = "Toggles Footnotes On and Off if they exist";
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-GBFFootnotes::GBFFootnotes() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+GBFFootnotes::GBFFootnotes() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -86,7 +94,7 @@ char GBFFootnotes::processText (SWBuf &text, const SWKey *key, const SWModule *m
if (module->isProcessEntryAttributes()) {
//tag = token;
- if((tagText.length() == 1) || !strcmp(module->Name(), "IGNT")) {
+ if((tagText.length() == 1) || !strcmp(module->getName(), "IGNT")) {
if (option) { // for ASV marks text in verse then put explanation at end of verse
text.append(" <FS>[");
text.append(tagText);
diff --git a/src/modules/filters/gbfheadings.cpp b/src/modules/filters/gbfheadings.cpp
index 122445e..7e19ea1 100644
--- a/src/modules/filters/gbfheadings.cpp
+++ b/src/modules/filters/gbfheadings.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
*
- * gbfheadings - SWFilter descendant to hide or show headings
- * in a GBF module.
+ * gbfheadings.cpp - SWFilter descendant to hide or show headings
+ * in a GBF module
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: gbfheadings.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -19,20 +21,27 @@
*
*/
+
#include <stdlib.h>
#include <gbfheadings.h>
+
SWORD_NAMESPACE_START
+namespace {
-const char oName[] = "Headings";
-const char oTip[] = "Toggles Headings On and Off if they exist";
+ static const char oName[] = "Headings";
+ static const char oTip[] = "Toggles Headings On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-GBFHeadings::GBFHeadings() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+GBFHeadings::GBFHeadings() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -40,7 +49,7 @@ GBFHeadings::~GBFHeadings() {
}
-char GBFHeadings::processText (SWBuf &text, const SWKey *key, const SWModule *module) {
+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;
diff --git a/src/modules/filters/gbfhtml.cpp b/src/modules/filters/gbfhtml.cpp
index 2467e36..542c4c9 100644
--- a/src/modules/filters/gbfhtml.cpp
+++ b/src/modules/filters/gbfhtml.cpp
@@ -1,10 +1,10 @@
/***************************************************************************
- * gbfhtml.cpp - GBF to HTML filter
- * -------------------
- * begin : 2001-09-03
- * copyright : 2001 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * gbfhtml.cpp - GBF to HTML filter
+ *
+ * $Id: gbfhtml.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -54,7 +54,7 @@ GBFHTML::GBFHTML() {
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("CM", "<br /><br />"); // two new-lines
addTokenSubstitute("CG", ""); // ???
addTokenSubstitute("CT", ""); // ???
addTokenSubstitute("JR", "<div align=\"right\">"); // right align begin
diff --git a/src/modules/filters/gbfhtmlhref.cpp b/src/modules/filters/gbfhtmlhref.cpp
index 3f25e3a..6df038e 100644
--- a/src/modules/filters/gbfhtmlhref.cpp
+++ b/src/modules/filters/gbfhtmlhref.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * gbfhtmlhref.cpp - GBF to HTML filter with hrefs
- * for strongs and morph tags
- * -------------------
- * begin : 2001-09-03
- * copyright : 2001 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * gbfhtmlhref.cpp - GBF to HTML filter with hrefs
+ *
+ * $Id: gbfhtmlhref.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -34,7 +33,7 @@ SWORD_NAMESPACE_START
GBFHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
if (module) {
- version = module->Name();
+ version = module->getName();
}
}
@@ -73,7 +72,8 @@ GBFHTMLHREF::GBFHTMLHREF() {
addTokenSubstitute("JR", "<div align=\"right\">"); // right align begin
addTokenSubstitute("JC", "<div align=\"center\">"); // center align begin
addTokenSubstitute("JL", "</div>"); // align end
-
+
+ renderNoteNumbers = false;
}
@@ -231,6 +231,7 @@ bool GBFHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData
else if (!strcmp(tag.getName(), "RF")) {
SWBuf type = tag.getAttribute("type");
SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
VerseKey *vkey = NULL;
// see if we have a VerseKey * or descendant
SWTRY {
@@ -240,10 +241,11 @@ bool GBFHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData
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=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n</sup></small></a> ",
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a> ",
URL::encode(footnoteNumber.c_str()).c_str(),
URL::encode(u->version.c_str()).c_str(),
- URL::encode(vkey->getText()).c_str());
+ URL::encode(vkey->getText()).c_str(),
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str(): ""));
}
u->suspendTextPassThru = true;
}
diff --git a/src/modules/filters/gbfmorph.cpp b/src/modules/filters/gbfmorph.cpp
index d7c8ab4..3399ae8 100644
--- a/src/modules/filters/gbfmorph.cpp
+++ b/src/modules/filters/gbfmorph.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * gbfmorph - SWFilter descendant to hide or show morph tags
- * in a GBF module.
+ * gbfmorph.cpp - SWFilter descendant to hide or show morph tags
+ * in a GBF module
*
+ * $Id: gbfmorph.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -23,16 +24,23 @@
#include <stdlib.h>
#include <gbfmorph.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Morphological Tags";
-const char oTip[] = "Toggles Morphological Tags On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Morphological Tags";
+ static const char oTip[] = "Toggles Morphological Tags On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-GBFMorph::GBFMorph() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+GBFMorph::GBFMorph() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/gbfosis.cpp b/src/modules/filters/gbfosis.cpp
index 526167a..9333f62 100644
--- a/src/modules/filters/gbfosis.cpp
+++ b/src/modules/filters/gbfosis.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * gbfstrongs - SWFilter descendant to hide or show strongs number
- * in a GBF module.
+ * gbfosis.cpp - GBF to OSIS filter
*
+ * $Id: gbfosis.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -29,8 +29,10 @@
#include <swlog.h>
#include <stdarg.h>
+
SWORD_NAMESPACE_START
+
GBFOSIS::GBFOSIS() {
}
@@ -347,7 +349,7 @@ char GBFOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module)
VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
if (vkey) {
SWBuf ref = "";
- if (vkey->Verse()) {
+ if (vkey->getVerse()) {
ref.appendFormatted("\t\t<verse osisID=\"%s\">", vkey->getOSISRef());
}
@@ -355,24 +357,24 @@ char GBFOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module)
text = ref + text;
- if (vkey->Verse()) {
+ if (vkey->getVerse()) {
VerseKey *tmp = (VerseKey *)vkey->clone();
*tmp = *vkey;
- tmp->AutoNormalize(0);
- tmp->Headings(1);
+ tmp->setAutoNormalize(false);
+ tmp->setIntros(true);
text += "</verse>";
*tmp = MAXVERSE;
if (*vkey == *tmp) {
- tmp->Verse(0);
+ tmp->setVerse(0);
// sprintf(ref, "\t</div>");
// pushString(&to, ref);
*tmp = MAXCHAPTER;
*tmp = MAXVERSE;
if (*vkey == *tmp) {
- tmp->Chapter(0);
- tmp->Verse(0);
+ tmp->setChapter(0);
+ tmp->setVerse(0);
// sprintf(ref, "\t</div>");
// pushString(&to, ref);
/*
diff --git a/src/modules/filters/gbfplain.cpp b/src/modules/filters/gbfplain.cpp
index e90bf94..b2a1ae4 100644
--- a/src/modules/filters/gbfplain.cpp
+++ b/src/modules/filters/gbfplain.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * gbfplain - SWFilter descendant to strip out all GBF tags or convert to
- * ASCII rendered symbols.
+ * gbfplain.cpp - SWFilter descendant to strip out all GBF tags or
+ * convert to ASCII rendered symbols
*
+ * $Id: gbfplain.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,8 +25,10 @@
#include <gbfplain.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
GBFPlain::GBFPlain() {
}
@@ -109,4 +112,6 @@ char GBFPlain::processText (SWBuf &text, const SWKey *key, const SWModule *modul
return 0;
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/modules/filters/gbfredletterwords.cpp b/src/modules/filters/gbfredletterwords.cpp
index 7397781..cac3cd9 100644
--- a/src/modules/filters/gbfredletterwords.cpp
+++ b/src/modules/filters/gbfredletterwords.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * GBFRedLetterWords - SWFilter descendant to toggle red coloring of words of
- * Christ in a GBF module.
+ * gbfredletterwords.cpp - SWFilter descendant to toggle red coloring of
+ * words of Christ in a GBF module
*
+ * $Id: gbfredletterwords.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,16 +26,23 @@
#include <swmodule.h>
#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";
+namespace {
+
+ static const char oName[] = "Words of Christ in Red";
+ static const char oTip[] = "Toggles Red Coloring for Words of Christ On and Off if they are marked";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-GBFRedLetterWords::GBFRedLetterWords() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+GBFRedLetterWords::GBFRedLetterWords() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/gbfrtf.cpp b/src/modules/filters/gbfrtf.cpp
index 7471d0b..8a8e1b1 100644
--- a/src/modules/filters/gbfrtf.cpp
+++ b/src/modules/filters/gbfrtf.cpp
@@ -1,9 +1,10 @@
/******************************************************************************
*
- * gbfrtf - SWFilter descendant to convert all GBF tags to RTF tags
+ * gbfrtf.cpp - SWFilter descendant to convert all GBF tags to RTF tags
*
+ * $Id: gbfrtf.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -42,7 +43,6 @@ char GBFRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module)
SWBuf strongnum;
SWBuf strongtense;
bool hideText = false;
- int wordLen = 0;
int wordCount = 0;
const char *from;
@@ -50,7 +50,6 @@ char GBFRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module)
from = orig.c_str();
for (text = ""; *from; from++) {
if (*from == '<') {
- wordLen = wordCount;
wordCount = 0;
intoken = true;
tokpos = 0;
diff --git a/src/modules/filters/gbfstrongs.cpp b/src/modules/filters/gbfstrongs.cpp
index c7cf6c5..dd4e167 100644
--- a/src/modules/filters/gbfstrongs.cpp
+++ b/src/modules/filters/gbfstrongs.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * gbfstrongs - SWFilter descendant to hide or show strongs number
- * in a GBF module.
+ * gbfstrongs.cpp - SWFilter descendant to hide or show Strong's number
+ * in a GBF module
*
+ * $Id: gbfstrongs.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -26,16 +27,23 @@
#include <swmodule.h>
#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";
+namespace {
+
+ static const char oName[] = "Strong's Numbers";
+ static const char oTip[] = "Toggles Strong's Numbers On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-GBFStrongs::GBFStrongs() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+GBFStrongs::GBFStrongs() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/gbfthml.cpp b/src/modules/filters/gbfthml.cpp
index 4feb1fa..303b240 100644
--- a/src/modules/filters/gbfthml.cpp
+++ b/src/modules/filters/gbfthml.cpp
@@ -1,10 +1,10 @@
/***************************************************************************
- * gbfthml.cpp - GBF to ThML filter
- * -------------------
- * begin : 1999-10-27
- * copyright : 2001 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * gbfthml.cpp - GBF to ThML filter
+ *
+ * $Id: gbfthml.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,8 +24,10 @@
#include <gbfthml.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
GBFThML::GBFThML()
{
}
@@ -218,5 +220,4 @@ char GBFThML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
}
-
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/gbfwebif.cpp b/src/modules/filters/gbfwebif.cpp
index b5ff798..b7b8a0f 100644
--- a/src/modules/filters/gbfwebif.cpp
+++ b/src/modules/filters/gbfwebif.cpp
@@ -1,11 +1,11 @@
/***************************************************************************
- * GBFWEBIF.cpp - GBF to HTML filter with hrefs
- * for strongs and morph tags
- * -------------------
- * begin : 2001-09-03
- * copyright : 2001 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * gbfwebif.cpp - GBF to HTML filter with hrefs for strongs and morph
+ * tags
+ *
+ * $Id: gbfwebif.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -29,9 +29,6 @@
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) {
@@ -189,7 +186,7 @@ bool GBFWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *u
}
else {
- return GBFHTMLHREF::handleToken(buf, token, userData);
+ return GBFXHTML::handleToken(buf, token, userData);
}
}
return true;
diff --git a/src/modules/filters/gbfwordjs.cpp b/src/modules/filters/gbfwordjs.cpp
index c3ab166..c9d1bd3 100644
--- a/src/modules/filters/gbfwordjs.cpp
+++ b/src/modules/filters/gbfwordjs.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * gbfstrongs - SWFilter descendant to hide or show strongs number
- * in a GBF module.
+ * gbfwordjs.cpp - SWFilter descendant for ???
*
+ * $Id: gbfwordjs.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2005-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,17 +28,23 @@
#include <utilstr.h>
#include <versekey.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Word Javascript";
-const char oTip[] = "Toggles Word Javascript data";
+namespace {
+
+ static const char oName[] = "Word Javascript";
+ static const char oTip[] = "Toggles Word Javascript data";
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-GBFWordJS::GBFWordJS() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+GBFWordJS::GBFWordJS() : SWOptionFilter(oName, oTip, oValues()) {
defaultGreekLex = 0;
defaultHebLex = 0;
@@ -57,7 +63,6 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
char token[2112]; // cheese. Fix.
int tokpos = 0;
bool intoken = false;
- bool lastspace = false;
int word = 1;
char val[128];
char wordstr[5];
@@ -66,7 +71,7 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
bool newText = false;
bool needWordOut = false;
AttributeValue *wordAttrs = 0;
- SWBuf modName = (module)?module->Name():"";
+ SWBuf modName = (module)?module->getName():"";
SWBuf wordSrcPrefix = modName;
const SWBuf orig = text;
@@ -146,7 +151,7 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
gh = isdigit(strong[0]) ? 0:strong[0];
if (!gh) {
if (vkey) {
- gh = vkey->Testament() ? 'H' : 'G';
+ gh = vkey->getTestament() ? 'H' : 'G';
}
}
else strong << 1;
@@ -165,7 +170,7 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
if (sLex) {
// we can pass the real lex name in, but we have some
// aliases in the javascript to optimize bandwidth
- lexName = sLex->Name();
+ lexName = sLex->getName();
if (lexName == "StrongsGreek")
lexName = "G";
if (lexName == "StrongsHebrew")
@@ -174,7 +179,7 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
SWBuf wordID;
if (vkey) {
// optimize for bandwidth and use only the verse as the unique entry id
- wordID.appendFormatted("%d", vkey->Verse());
+ wordID.appendFormatted("%d", vkey->getVerse());
}
else {
wordID = key->getText();
@@ -192,10 +197,11 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
+ if (!sMorph) sMorph = 0; // to pass unused warning for now
/*
if (sMorph) {
SWBuf popMorph = "<a onclick=\"";
- popMorph.appendFormatted("p(\'%s\',\'%s\','%s','');\" >%s</a>", sMorph->Name(), morph.c_str(), wordID.c_str(), morph.c_str());
+ popMorph.appendFormatted("p(\'%s\',\'%s\','%s','');\" >%s</a>", sMorph->getName(), morph.c_str(), wordID.c_str(), morph.c_str());
morph = popMorph;
}
*/
@@ -223,7 +229,6 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
}
else {
text += *from;
- lastspace = (*from == ' ');
}
}
@@ -241,7 +246,7 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
gh = isdigit(strong[0]) ? 0:strong[0];
if (!gh) {
if (vkey) {
- gh = vkey->Testament() ? 'H' : 'G';
+ gh = vkey->getTestament() ? 'H' : 'G';
}
}
else strong << 1;
@@ -257,7 +262,7 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
if (sLex) {
// we can pass the real lex name in, but we have some
// aliases in the javascript to optimize bandwidth
- lexName = sLex->Name();
+ lexName = sLex->getName();
if (lexName == "StrongsGreek")
lexName = "G";
if (lexName == "StrongsHebrew")
@@ -266,7 +271,7 @@ char GBFWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modul
SWBuf wordID;
if (vkey) {
// optimize for bandwidth and use only the verse as the unique entry id
- wordID.appendFormatted("%d", vkey->Verse());
+ wordID.appendFormatted("%d", vkey->getVerse());
}
else {
wordID = key->getText();
diff --git a/src/modules/filters/gbfxhtml.cpp b/src/modules/filters/gbfxhtml.cpp
new file mode 100644
index 0000000..56d7663
--- /dev/null
+++ b/src/modules/filters/gbfxhtml.cpp
@@ -0,0 +1,236 @@
+/******************************************************************************
+ *
+ * gbfxhtml.cpp - GBF to classed XHTML
+ *
+ * $Id: gbfxhtml.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2011-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+
+#include <stdlib.h>
+#include <gbfxhtml.h>
+#include <swmodule.h>
+#include <utilxml.h>
+#include <versekey.h>
+#include <ctype.h>
+#include <url.h>
+
+SWORD_NAMESPACE_START
+
+const char *GBFXHTML::getHeader() const {
+ return "\
+ .wordsOfJesus {\
+ color: red;\
+ }\
+ ";
+}
+
+GBFXHTML::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
+ if (module) {
+ version = module->getName();
+ }
+}
+
+GBFXHTML::GBFXHTML() {
+ 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", "<span class=\"wordsOfJesus\">"); // words of Jesus begin
+ addTokenSubstitute("Fr", "</span>");
+ 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
+
+ renderNoteNumbers = false;
+}
+
+
+bool GBFXHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
+ const char *tok;
+ MyUserData *u = (MyUserData *)userData;
+
+ if (!substituteToken(buf, token)) {
+ XMLTag tag(token);
+
+ if (!strncmp(token, "WG", 2)) { // strong's numbers
+ //buf += " <small><em>&lt;<a href=\"type=Strongs value=";
+ buf += " <small><em class=\"strongs\">&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=Greek&value=";
+ for (tok = token+2; *tok; tok++)
+ //if(token[i] != '\"')
+ buf += *tok;
+ buf += "\" class=\"strongs\">";
+ for (tok = token + 2; *tok; tok++)
+ //if(token[i] != '\"')
+ buf += *tok;
+ buf += "</a>&gt;</em></small>";
+ }
+ else if (!strncmp(token, "WH", 2)) { // strong's numbers
+ //buf += " <small><em>&lt;<a href=\"type=Strongs value=";
+ buf += " <small><em class=\"strongs\">&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=Hebrew&value=";
+ for (tok = token+2; *tok; tok++)
+ //if(token[i] != '\"')
+ buf += *tok;
+ buf += "\" class=\"strongs\">";
+ for (tok = token + 2; *tok; tok++)
+ //if(token[i] != '\"')
+ buf += *tok;
+ buf += "</a>&gt;</em></small>";
+ }
+ else if (!strncmp(token, "WTG", 3)) { // strong's numbers tense
+ //buf += " <small><em>(<a href=\"type=Strongs value=";
+ buf += " <small><em class=\"strongs\">(<a href=\"passagestudy.jsp?action=showStrongs&type=Greek&value=";
+ for (tok = token + 3; *tok; tok++)
+ if(*tok != '\"')
+ buf += *tok;
+ buf += "\" class=\"strongs\">";
+ for (tok = token + 3; *tok; tok++)
+ if(*tok != '\"')
+ buf += *tok;
+ buf += "</a>)</em></small>";
+ }
+ else if (!strncmp(token, "WTH", 3)) { // strong's numbers tense
+ //buf += " <small><em>(<a href=\"type=Strongs value=";
+ buf += " <small><em class=\"strongs\">(<a href=\"passagestudy.jsp?action=showStrongs&type=Hebrew&value=";
+ for (tok = token + 3; *tok; tok++)
+ if(*tok != '\"')
+ buf += *tok;
+ buf += "\" class=\"strongs\">";
+ 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=";
+ buf += " <small><em class=\"morph\">(<a href=\"passagestudy.jsp?action=showMorph&type=Greek&value=";
+
+ for (tok = token + 2; *tok; tok++)
+ if(*tok != '\"')
+ buf += *tok;
+ buf += "\" class=\"morph\">";
+ 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");
+ SWBuf noteName = tag.getAttribute("n");
+ VerseKey *vkey = NULL;
+ // see if we have a VerseKey * or descendant
+ SWTRY {
+ vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ }
+ SWCATCH ( ... ) { }
+ 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=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a> ",
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(vkey->getText()).c_str(),
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str(): ""));
+ }
+ 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/greeklexattribs.cpp b/src/modules/filters/greeklexattribs.cpp
index e1a60a2..1c2533d 100644
--- a/src/modules/filters/greeklexattribs.cpp
+++ b/src/modules/filters/greeklexattribs.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * greeklexattribs - SWFilter descendant to set entry attributes for greek
- * lexicons
+ * greeklexattribs.cpp - SWFilter descendant to set entry attributes
+ * for greek lexicons
*
+ * $Id: greeklexattribs.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/filters/latin1utf16.cpp b/src/modules/filters/latin1utf16.cpp
index bf2f3f8..ef27245 100644
--- a/src/modules/filters/latin1utf16.cpp
+++ b/src/modules/filters/latin1utf16.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * Latin1UTF16 - SWFilter descendant to convert a Latin-1 character to UTF-16
+ * latin1utf16.cpp - SWFilter descendant Latin1UTF16 to convert a Latin-1
+ * character to UTF-16
*
+ * $Id: latin1utf16.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/filters/latin1utf8.cpp b/src/modules/filters/latin1utf8.cpp
index 784aafe..a784893 100644
--- a/src/modules/filters/latin1utf8.cpp
+++ b/src/modules/filters/latin1utf8.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * Latin1UTF8 - SWFilter descendant to convert a Latin-1 character to UTF-8
+ * latin1utf8.cpp - SWFilter descendant Latin1UTF8 to convert a Latin-1
+ * character to UTF-8
*
+ * $Id: latin1utf8.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,8 +26,10 @@
#include <latin1utf8.h>
#include <swmodule.h>
+
SWORD_NAMESPACE_START
+
Latin1UTF8::Latin1UTF8() {
}
@@ -35,7 +38,7 @@ char Latin1UTF8::processText(SWBuf &text, const SWKey *key, const SWModule *modu
{
const unsigned char *from;
- if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
+ if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
return (char)-1;
SWBuf orig = text;
@@ -185,4 +188,5 @@ char Latin1UTF8::processText(SWBuf &text, const SWKey *key, const SWModule *modu
return 0;
}
+
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/osisenum.cpp b/src/modules/filters/osisenum.cpp
new file mode 100644
index 0000000..db433b0
--- /dev/null
+++ b/src/modules/filters/osisenum.cpp
@@ -0,0 +1,99 @@
+/******************************************************************************
+ *
+ * osisenum.cpp - SWFilter descendant to hide or show word enumations
+ * in an OSIS module
+ *
+ * $Id: osisenum.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <osisenum.h>
+#include <utilxml.h>
+
+
+SWORD_NAMESPACE_START
+
+namespace {
+
+ static const char oName[] = "Enumerations";
+ static const char oTip[] = "Toggles Enumerations On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
+
+
+OSISEnum::OSISEnum() : SWOptionFilter(oName, oTip, oValues()) {
+}
+
+
+OSISEnum::~OSISEnum() {
+}
+
+
+char OSISEnum::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
+ SWBuf token;
+ bool intoken = false;
+
+ const SWBuf orig = text;
+ const char * from = orig.c_str();
+
+ if (!option) {
+ for (text = ""; *from; ++from) {
+ if (*from == '<') {
+ intoken = true;
+ token = "";
+ continue;
+ }
+ if (*from == '>') { // process tokens
+ intoken = false;
+ if (token.startsWith("w ")) { // Word
+ XMLTag wtag(token);
+ const char *l = wtag.getAttribute("n");
+ if (l) {
+ wtag.setAttribute("n", 0);
+ token = wtag;
+ token.trim();
+ // drop <>
+ token << 1;
+ token--;
+ }
+ }
+
+ // keep token in text
+ text.append('<');
+ text.append(token);
+ text.append('>');
+
+ continue;
+ }
+ if (intoken) {
+ token += *from;
+ }
+ else {
+ text.append(*from);
+ }
+ }
+ }
+ return 0;
+}
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/filters/osisfootnotes.cpp b/src/modules/filters/osisfootnotes.cpp
index 3d0d2d4..8008d5c 100644
--- a/src/modules/filters/osisfootnotes.cpp
+++ b/src/modules/filters/osisfootnotes.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * osisfootnotes - SWFilter descendant to hide or show footnotes
- * in an OSIS module.
+ * osisfootnotes.cpp - SWFilter descendant to hide or show footnotes
+ * in an OSIS module
*
+ * $Id: osisfootnotes.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -29,17 +30,23 @@
#include <utilxml.h>
#include <utilstr.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Footnotes";
-const char oTip[] = "Toggles Footnotes On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Footnotes";
+ static const char oTip[] = "Toggles Footnotes On and Off if they exist";
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-OSISFootnotes::OSISFootnotes() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+OSISFootnotes::OSISFootnotes() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -56,7 +63,7 @@ char OSISFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *m
SWBuf refs = "";
int footnoteNum = 1;
char buf[254];
- SWKey *p = (module) ? module->CreateKey() : (key) ? key->clone() : new VerseKey();
+ SWKey *p = (module) ? module->createKey() : (key) ? key->clone() : new VerseKey();
VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
if (!parser) {
delete p;
@@ -122,7 +129,7 @@ char OSISFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *m
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();
+ refs = parser->parseVerseList(tagText.c_str(), *parser, true).getRangeText();
module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str();
}
}
diff --git a/src/modules/filters/osisruby.cpp b/src/modules/filters/osisglosses.cpp
index c17ea43..d232acc 100644
--- a/src/modules/filters/osisruby.cpp
+++ b/src/modules/filters/osisglosses.cpp
@@ -1,93 +1,99 @@
-/******************************************************************************
- *
- * osisruby - SWFilter descendant to hide or show ruby
- * in a OSIS module.
- *
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
- * CrossWire Bible Society
- * P. O. Box 2528
- * Tempe, AZ 85280-2528
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- */
-
-#include <stdlib.h>
-#include <osisruby.h>
-#include <utilxml.h>
-
-SWORD_NAMESPACE_START
-
-const char oName[] = "Ruby";
-const char oTip[] = "Toggles Ruby On and Off if they exist";
-
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-
-OSISRuby::OSISRuby() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
-}
-
-
-OSISRuby::~OSISRuby() {
-}
-
-
-char OSISRuby::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- SWBuf token;
- bool intoken = false;
- bool lastspace = false;
-
- const SWBuf orig = text;
- const char * from = orig.c_str();
-
- if (!option) {
- for (text = ""; *from; ++from) {
- if (*from == '<') {
- intoken = true;
- token = "";
- continue;
- }
- if (*from == '>') { // process tokens
- intoken = false;
- if (token.startsWith("w ")) { // Word
- XMLTag wtag(token);
- const char *l = wtag.getAttribute("gloss");
- if (l) {
- wtag.setAttribute("gloss", 0);
- token = wtag;
- token.trim();
- // drop <>
- token << 1;
- token--;
- }
- }
-
- // keep token in text
- text.append('<');
- text.append(token);
- text.append('>');
-
- continue;
- }
- if (intoken) {
- token += *from;
- }
- else {
- text.append(*from);
- lastspace = (*from == ' ');
- }
- }
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
+/******************************************************************************
+ *
+ * osisglosses.cpp - SWFilter descendant to hide or show glosses
+ * in an OSIS module
+ *
+ * $Id: osisglosses.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <osisglosses.h>
+#include <utilxml.h>
+
+
+SWORD_NAMESPACE_START
+
+namespace {
+
+ static const char oName[] = "Glosses";
+ static const char oTip[] = "Toggles Glosses On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
+
+
+OSISGlosses::OSISGlosses() : SWOptionFilter(oName, oTip, oValues()) {
+}
+
+
+OSISGlosses::~OSISGlosses() {
+}
+
+
+char OSISGlosses::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
+ SWBuf token;
+ bool intoken = false;
+
+ const SWBuf orig = text;
+ const char * from = orig.c_str();
+
+ if (!option) {
+ for (text = ""; *from; ++from) {
+ if (*from == '<') {
+ intoken = true;
+ token = "";
+ continue;
+ }
+ if (*from == '>') { // process tokens
+ intoken = false;
+ if (token.startsWith("w ")) { // Word
+ XMLTag wtag(token);
+ const char *l = wtag.getAttribute("gloss");
+ if (l) {
+ wtag.setAttribute("gloss", 0);
+ token = wtag;
+ token.trim();
+ // drop <>
+ token << 1;
+ token--;
+ }
+ }
+
+ // keep token in text
+ text.append('<');
+ text.append(token);
+ text.append('>');
+
+ continue;
+ }
+ if (intoken) {
+ token += *from;
+ }
+ else {
+ text.append(*from);
+ }
+ }
+ }
+ return 0;
+}
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/filters/osisheadings.cpp b/src/modules/filters/osisheadings.cpp
index 8872f24..783fa81 100644
--- a/src/modules/filters/osisheadings.cpp
+++ b/src/modules/filters/osisheadings.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- *osisheadings - SWFilter descendant to hide or show headings
- * in an OSIS module.
+ * osisheadings.cpp - SWFilter descendant to hide or show headings
+ * in an OSIS module
*
+ * $Id: osisheadings.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,151 +28,120 @@
#include <utilxml.h>
#include <utilstr.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Headings";
-const char oTip[] = "Toggles Headings On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Headings";
+ static const char oTip[] = "Toggles Headings On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ class MyUserData : public BasicFilterUserData {
+ public:
+ SWBuf currentHeadingName;
+ XMLTag currentHeadingTag;
+ const char *sID;
+ SWBuf heading;
+ int depth;
+ int headerNum;
-OSISHeadings::OSISHeadings() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
+ clear();
+ }
+ void clear() {
+ currentHeadingName = "";
+ currentHeadingTag = "";
+ sID = 0;
+ heading = "";
+ depth = 0;
+ headerNum = 0;
+ }
+ };
}
-OSISHeadings::~OSISHeadings() {
+BasicFilterUserData *OSISHeadings::createUserData(const SWModule *module, const SWKey *key) {
+ return new MyUserData(module, key);
}
-char OSISHeadings::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- SWBuf token;
- bool intoken = false;
- bool hide = false;
- bool preverse = false;
- bool withinTitle = false;
- bool withinPreverseDiv = false;
- SWBuf preverseDivID = "";
- const char *pvDID = 0;
- bool canonical = false;
- SWBuf header;
- int headerNum = 0;
- int pvHeaderNum = 0;
- char buf[254];
- XMLTag startTag;
-
- SWBuf orig = text;
- const char *from = orig.c_str();
-
- XMLTag tag;
-
- for (text = ""; *from; ++from) {
- if (*from == '<') {
- intoken = true;
- token = "";
-
- continue;
- }
- if (*from == '>') { // process tokens
- intoken = false;
- tag = token;
-
- // <title> </title> <div subType="x-preverse"> (</div> ## when in previous)
- if ( (!withinPreverseDiv && !strcmp(tag.getName(), "title")) ||
- (!strcmp(tag.getName(), "div") &&
- ((withinPreverseDiv && (tag.isEndTag(pvDID))) ||
- (tag.getAttribute("subType") && !strcmp(tag.getAttribute("subType"), "x-preverse")))
- )) {
-
- withinTitle = (!tag.isEndTag(pvDID));
- if (!strcmp(tag.getName(), "div")) {
- withinPreverseDiv = (!tag.isEndTag(pvDID));
- if (!pvDID) {
- preverseDivID = tag.getAttribute("sID");
- pvDID = (preverseDivID.length())? preverseDivID.c_str() : 0;
- }
- }
-
- if (!tag.isEndTag(pvDID)) { //start tag
- if (!tag.isEmpty() || pvDID) {
- startTag = tag;
- }
- }
-
- if ( !tag.isEndTag(pvDID) && (withinPreverseDiv
- || (tag.getAttribute("subType") && !stricmp(tag.getAttribute("subType"), "x-preverse"))
- || (tag.getAttribute("subtype") && !stricmp(tag.getAttribute("subtype"), "x-preverse")) // deprecated
- )) {
- hide = true;
- preverse = true;
- header = "";
- canonical = (tag.getAttribute("canonical") && (!stricmp(tag.getAttribute("canonical"), "true")));
- continue;
- }
- if (!tag.isEndTag(pvDID)) { //start tag
- hide = true;
- header = "";
- if (option || canonical) { // we want the tag in the text
- text.append('<');
- text.append(token);
- text.append('>');
- }
- continue;
- }
- if (hide && tag.isEndTag(pvDID)) {
- if (module->isProcessEntryAttributes() && ((option || canonical) || (!preverse))) {
- 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 || canonical) { // we want the tag in the text
- text.append(header);
- }
- }
-
- StringList attributes = startTag.getAttributeNames();
+OSISHeadings::OSISHeadings() : SWOptionFilter(oName, oTip, oValues()) {
+ setPassThruUnknownToken(true);
+}
+
+
+bool OSISHeadings::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
+
+ MyUserData *u = (MyUserData *)userData;
+ XMLTag tag(token);
+ SWBuf name = tag.getName();
+
+ // we only care about titles and divs or if we're already in a heading
+ //
+ // are we currently in a heading?
+ if (u->currentHeadingName.size()) {
+ u->heading.append(u->lastTextNode);
+ if (name == u->currentHeadingName) {
+ if (tag.isEndTag(u->sID)) {
+ if (!u->depth-- || u->sID) {
+ // we've just finished a heading. It's all stored up in u->heading
+ bool canonical = (SWBuf("true") == u->currentHeadingTag.getAttribute("canonical"));
+ bool preverse = (SWBuf("x-preverse") == u->currentHeadingTag.getAttribute("subType") || SWBuf("x-preverse") == u->currentHeadingTag.getAttribute("subtype"));
+
+ // do we want to put anything in EntryAttributes?
+ if (u->module->isProcessEntryAttributes() && (option || canonical || !preverse)) {
+ SWBuf buf; buf.appendFormatted("%i", u->headerNum++);
+ u->module->getEntryAttributes()["Heading"][(preverse)?"Preverse":"Interverse"][buf] = u->heading;
+
+ StringList attributes = u->currentHeadingTag.getAttributeNames();
for (StringList::const_iterator it = attributes.begin(); it != attributes.end(); it++) {
- module->getEntryAttributes()["Heading"][buf][it->c_str()] = startTag.getAttribute(it->c_str());
+ u->module->getEntryAttributes()["Heading"][buf][it->c_str()] = u->currentHeadingTag.getAttribute(it->c_str());
}
}
-
- hide = false;
- if (!(option || canonical) || preverse) { // we don't want the tag in the text anymore
- preverse = false;
- continue;
- }
- preverse = false;
- pvDID = 0;
- }
- }
- if (withinTitle) {
- header.append('<');
- header.append(token);
- header.append('>');
- } else {
- // if not a heading token, keep token in text
- if (!hide) {
- text.append('<');
- text.append(token);
- text.append('>');
+ // do we want the heading in the body?
+ if (!preverse && (option || canonical)) {
+ buf.append(u->currentHeadingTag);
+ buf.append(u->heading);
+ buf.append(tag);
+ }
+ u->suspendTextPassThru = false;
+ u->clear();
}
}
- continue;
+ else u->depth++;
}
- if (intoken) { //copy token
- token.append(*from);
- }
- else if (!hide) { //copy text which is not inside a token
- text.append(*from);
- }
- else header.append(*from);
+ u->heading.append(tag);
+ return true;
}
- return 0;
+
+ // are we a title or a preverse div?
+ else if ( name == "title"
+ || (name == "div"
+ && ( SWBuf("x-preverse") == tag.getAttribute("subType")
+ || SWBuf("x-preverse") == tag.getAttribute("subtype")))) {
+
+ u->currentHeadingName = name;
+ u->currentHeadingTag = tag;
+ u->heading = "";
+ u->sID = u->currentHeadingTag.getAttribute("sID");
+ u->depth = 0;
+ u->suspendTextPassThru = true;
+
+ return true;
+ }
+
+ return false;
}
+
+
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/osishtmlhref.cpp b/src/modules/filters/osishtmlhref.cpp
index 3406e1b..74b2da7 100644
--- a/src/modules/filters/osishtmlhref.cpp
+++ b/src/modules/filters/osishtmlhref.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * osishtmlhref.cpp - OSIS to HTML with hrefs filter
- * -------------------
- * begin : 2003-06-24
- * copyright : 2003 by CrossWire Bible Society
+ *
+ * osishtmlhref.cpp - OSIS to HTML with hrefs filter
*
+ * $Id: osishtmlhref.cpp 3005 2014-01-09 04:06:11Z greg.hellings $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -36,60 +35,6 @@ SWORD_NAMESPACE_START
namespace {
typedef std::stack<SWBuf> TagStack;
-}
-
-// TODO: this bridge pattern is to preserve binary compat on 1.6.x
-class OSISHTMLHREF::TagStacks {
-public:
- TagStack quoteStack;
- TagStack hiStack;
-};
-
-OSISHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
- inXRefNote = false;
- suspendLevel = 0;
- tagStacks = new TagStacks();
- wordsOfChristStart = "<font color=\"red\"> ";
- wordsOfChristEnd = "</font> ";
- if (module) {
- osisQToTick = ((!module->getConfigEntry("OSISqToTick")) || (strcmp(module->getConfigEntry("OSISqToTick"), "false")));
- version = module->Name();
- BiblicalText = (!strcmp(module->Type(), "Biblical Texts"));
- }
- else {
- osisQToTick = true; // default
- version = "";
- }
-}
-
-OSISHTMLHREF::MyUserData::~MyUserData() {
- delete tagStacks;
-}
-
-OSISHTMLHREF::OSISHTMLHREF() {
- setTokenStart("<");
- setTokenEnd(">");
-
- setEscapeStart("&");
- setEscapeEnd(";");
-
- setEscapeStringCaseSensitive(true);
- setPassThruNumericEscapeString(true);
-
- addAllowedEscapeString("quot");
- addAllowedEscapeString("apos");
- addAllowedEscapeString("amp");
- addAllowedEscapeString("lt");
- addAllowedEscapeString("gt");
-
- setTokenCaseSensitive(true);
-
- // addTokenSubstitute("lg", "<br />");
- // addTokenSubstitute("/lg", "<br />");
-
- morphFirst = false;
-}
-
// though this might be slightly slower, possibly causing an extra bool check, this is a renderFilter
// so speed isn't the absolute highest priority, and this is a very minor possible hit
static inline void outText(const char *t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
@@ -157,6 +102,61 @@ void processMorph(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf) {
//}
}
}
+} // end anonymous namespace
+
+// TODO: this bridge pattern is to preserve binary compat on 1.6.x
+class OSISHTMLHREF::TagStacks {
+public:
+ TagStack quoteStack;
+ TagStack hiStack;
+};
+
+OSISHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
+ inXRefNote = false;
+ suspendLevel = 0;
+ tagStacks = new TagStacks();
+ wordsOfChristStart = "<font color=\"red\"> ";
+ wordsOfChristEnd = "</font> ";
+ if (module) {
+ osisQToTick = ((!module->getConfigEntry("OSISqToTick")) || (strcmp(module->getConfigEntry("OSISqToTick"), "false")));
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
+ }
+ else {
+ osisQToTick = true; // default
+ version = "";
+ }
+}
+
+OSISHTMLHREF::MyUserData::~MyUserData() {
+ delete tagStacks;
+}
+
+OSISHTMLHREF::OSISHTMLHREF() {
+ setTokenStart("<");
+ setTokenEnd(">");
+
+ setEscapeStart("&");
+ setEscapeEnd(";");
+
+ setEscapeStringCaseSensitive(true);
+ setPassThruNumericEscapeString(true);
+
+ addAllowedEscapeString("quot");
+ addAllowedEscapeString("apos");
+ addAllowedEscapeString("amp");
+ addAllowedEscapeString("lt");
+ addAllowedEscapeString("gt");
+
+ setTokenCaseSensitive(true);
+
+ // addTokenSubstitute("lg", "<br />");
+ // addTokenSubstitute("/lg", "<br />");
+
+ morphFirst = false;
+ renderNoteNumbers = false;
+}
+
bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
MyUserData *u = (MyUserData *)userData;
@@ -240,6 +240,7 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
if (!strongsMarkup) { // leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off
SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
VerseKey *vkey = NULL;
char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
@@ -251,25 +252,14 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
vkey = SWDYNAMIC_CAST(VerseKey, u->key);
}
SWCATCH ( ... ) { }
- if (vkey) {
- //printf("URL = %s\n",URL::encode(vkey->getText()).c_str());
- buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>",
- ch,
- URL::encode(footnoteNumber.c_str()).c_str(),
- URL::encode(u->version.c_str()).c_str(),
- URL::encode(vkey->getText()).c_str(),
- ch,
- ch);
- }
- else {
- buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>",
- ch,
- URL::encode(footnoteNumber.c_str()).c_str(),
- URL::encode(u->version.c_str()).c_str(),
- URL::encode(u->key->getText()).c_str(),
- ch,
- ch);
- }
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
+ ch,
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(vkey ? vkey->getText() : u->key->getText()).c_str(),
+ ch,
+ ch,
+ (renderNoteNumbers ? noteName.c_str() : ""));
}
}
u->suspendTextPassThru = (++u->suspendLevel);
@@ -381,7 +371,7 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
}
// <lb.../>
- else if (!strcmp(tag.getName(), "lb")) {
+ else if (!strcmp(tag.getName(), "lb") && (!tag.getAttribute("type") || strcmp(tag.getAttribute("type"), "x-optional"))) {
outText("<br />", buf, u);
userData->supressAdjacentWhitespace = true;
}
@@ -485,10 +475,15 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
// <hi> text highlighting
else if (!strcmp(tag.getName(), "hi")) {
SWBuf type = tag.getAttribute("type");
+ // handle tei rend attribute
+ if (!type.length()) type = tag.getAttribute("rend");
if ((!tag.isEndTag()) && (!tag.isEmpty())) {
if (type == "bold" || type == "b" || type == "x-b") {
outText("<b>", buf, u);
}
+ else if (type == "ol") {
+ outText("<span style=\"text-decoration:overline\">", buf, u);
+ }
else { // all other types
outText("<i>", buf, u);
}
@@ -500,10 +495,14 @@ bool OSISHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
XMLTag tag(u->tagStacks->hiStack.top());
u->tagStacks->hiStack.pop();
type = tag.getAttribute("type");
+ if (!type.length()) type = tag.getAttribute("rend");
}
if (type == "bold" || type == "b" || type == "x-b") {
outText("</b>", buf, u);
}
+ else if (type == "ol") {
+ outText("</span>", buf, u);
+ }
else outText("</i>", buf, u);
}
}
diff --git a/src/modules/filters/osislemma.cpp b/src/modules/filters/osislemma.cpp
index 7b56024..cf5d8f4 100644
--- a/src/modules/filters/osislemma.cpp
+++ b/src/modules/filters/osislemma.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * osislemma - SWFilter descendant to hide or show lemmata
- * in a OSIS module.
+ * osislemma.cpp - SWFilter descendant to hide or show lemmata
+ * in a OSIS module
*
+ * $Id: osislemma.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,16 +25,23 @@
#include <osislemma.h>
#include <utilxml.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Lemmas";
-const char oTip[] = "Toggles Lemmas On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Lemmas";
+ static const char oTip[] = "Toggles Lemmas On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-OSISLemma::OSISLemma() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+OSISLemma::OSISLemma() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -44,7 +52,6 @@ OSISLemma::~OSISLemma() {
char OSISLemma::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
SWBuf token;
bool intoken = false;
- bool lastspace = false;
const SWBuf orig = text;
const char * from = orig.c_str();
@@ -90,7 +97,6 @@ char OSISLemma::processText(SWBuf &text, const SWKey *key, const SWModule *modul
}
else {
text.append(*from);
- lastspace = (*from == ' ');
}
}
}
diff --git a/src/modules/filters/osismorph.cpp b/src/modules/filters/osismorph.cpp
index 7ceec79..71de8e5 100644
--- a/src/modules/filters/osismorph.cpp
+++ b/src/modules/filters/osismorph.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * osismorph - SWFilter descendant to hide or show morph tags
- * in a OSIS module.
+ * osismorph.cpp - SWFilter descendant to hide or show morph tags
+ * in a OSIS module
*
+ * $Id: osismorph.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,14 +26,20 @@
SWORD_NAMESPACE_START
-const char oName[] = "Morphological Tags";
-const char oTip[] = "Toggles Morphological Tags On and Off if they exist";
+namespace {
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const char oName[] = "Morphological Tags";
+ static const char oTip[] = "Toggles Morphological Tags On and Off if they exist";
-OSISMorph::OSISMorph() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+
+}
+
+OSISMorph::OSISMorph() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -45,7 +52,6 @@ char OSISMorph::processText(SWBuf &text, const SWKey *key, const SWModule *modul
char token[2048]; // cheese. Fix.
int tokpos = 0;
bool intoken = false;
- bool lastspace = false;
SWBuf orig = text;
const char *from = orig.c_str();
@@ -90,7 +96,6 @@ char OSISMorph::processText(SWBuf &text, const SWKey *key, const SWModule *modul
}
else {
text.append(*from);
- lastspace = (*from == ' ');
}
}
}
diff --git a/src/modules/filters/osismorphsegmentation.cpp b/src/modules/filters/osismorphsegmentation.cpp
index fef7af7..9afc0a1 100644
--- a/src/modules/filters/osismorphsegmentation.cpp
+++ b/src/modules/filters/osismorphsegmentation.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
*
- * osismorphsegmentation - SWFilter descendant to toggle splitting of morphemes
- * (for morpheme segmented Hebrew in the WLC)
+ * osismorphsegmentation.cpp - SWFilter descendant to toggle splitting of
+ * morphemes (for morpheme segmented Hebrew in
+ * the WLC)
*
+ * $Id: osismorphsegmentation.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2006-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -26,16 +28,23 @@
#include <swmodule.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Morpheme Segmentation";
-const char oTip[] = "Toggles Morpheme Segmentation On and Off, when present";
+namespace {
+
+ static const char oName[] = "Morpheme Segmentation";
+ static const char oTip[] = "Toggles Morpheme Segmentation On and Off, when present";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-OSISMorphSegmentation::OSISMorphSegmentation() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+OSISMorphSegmentation::OSISMorphSegmentation() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/osisosis.cpp b/src/modules/filters/osisosis.cpp
index 82a6bfc..2bc5cbb 100644
--- a/src/modules/filters/osisosis.cpp
+++ b/src/modules/filters/osisosis.cpp
@@ -1,10 +1,10 @@
/***************************************************************************
- * osisosis.cpp - internal OSIS to public OSIS filter
- * -------------------
- * begin : 2004-03-13
- * copyright : 2003 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * osisosis.cpp - internal OSIS to public OSIS filter
+ *
+ * $Id: osisosis.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2004-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -59,7 +59,7 @@ char OSISOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module
VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
if (vkey) {
SWBuf ref = "";
- if (vkey->Verse()) {
+ if (vkey->getVerse()) {
ref.appendFormatted("\t\t<verse osisID=\"%s\">", vkey->getOSISRef());
}
@@ -67,24 +67,24 @@ char OSISOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module
text = ref + text;
- if (vkey->Verse()) {
+ if (vkey->getVerse()) {
VerseKey *tmp = (VerseKey *)vkey->clone();
*tmp = *vkey;
- tmp->AutoNormalize(0);
- tmp->Headings(1);
+ tmp->setAutoNormalize(false);
+ tmp->setIntros(true);
text += "</verse>";
*tmp = MAXVERSE;
if (*vkey == *tmp) {
- tmp->Verse(0);
+ tmp->setVerse(0);
// sprintf(ref, "\t</div>");
// pushString(&to, ref);
*tmp = MAXCHAPTER;
*tmp = MAXVERSE;
if (*vkey == *tmp) {
- tmp->Chapter(0);
- tmp->Verse(0);
+ tmp->setChapter(0);
+ tmp->setVerse(0);
// sprintf(ref, "\t</div>");
// pushString(&to, ref);
}
diff --git a/src/modules/filters/osisplain.cpp b/src/modules/filters/osisplain.cpp
index 57105f0..6e583a4 100644
--- a/src/modules/filters/osisplain.cpp
+++ b/src/modules/filters/osisplain.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
- * osisplain.cpp - An SWFilter
- * impl that provides stripping of OSIS tags
*
- * $Id: osisplain.cpp 2334 2009-04-24 00:14:12Z scribe $
+ * osisplain.cpp - An SWFilter that provides stripping of OSIS tags
*
- * Copyright 2001 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: osisplain.cpp 2984 2013-09-20 12:18:45Z scribe $
+ *
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,17 +28,21 @@
SWORD_NAMESPACE_START
+
namespace {
-class MyUserData : public BasicFilterUserData {
-public:
- SWBuf w;
- XMLTag tag;
- VerseKey *vk;
- char testament;
- MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {}
-};
+
+ class MyUserData : public BasicFilterUserData {
+ public:
+ SWBuf w;
+ XMLTag tag;
+ VerseKey *vk;
+ char testament;
+ SWBuf hiType;
+ MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {}
+ };
}
+
OSISPlain::OSISPlain() {
setTokenStart("<");
setTokenEnd(">");
@@ -65,7 +69,7 @@ OSISPlain::OSISPlain() {
BasicFilterUserData *OSISPlain::createUserData(const SWModule *module, const SWKey *key) {
MyUserData *u = new MyUserData(module, key);
u->vk = SWDYNAMIC_CAST(VerseKey, u->key);
- u->testament = (u->vk) ? u->vk->Testament() : 2; // default to NT
+ u->testament = (u->vk) ? u->vk->getTestament() : 2; // default to NT
return u;
}
@@ -202,6 +206,40 @@ bool OSISPlain::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *
end += buf.size() - u->lastTextNode.size();
toupperstr(end);
}
+ else if (!strncmp(token, "hi", 2)) {
+
+ // handle both OSIS 'type' and TEI 'rend' attributes
+ // there is no officially supported OSIS overline attribute,
+ // thus either TEI overline or OSIS x-overline would be best,
+ // but we have used "ol" in the past, as well. Once a valid
+ // OSIS overline attribute is made available, these should all
+ // eventually be deprecated and never documented that they are supported.
+ if (strstr(token, "rend=\"ol\"") || strstr(token, "rend=\"x-overline\"") || strstr(token, "rend=\"overline\"")
+ || strstr(token, "type=\"ol\"") || strstr(token, "type=\"x-overline\"") || strstr(token, "type=\"overline\"")) {
+ u->hiType = "overline";
+ }
+ else u->hiType = "";
+ u->suspendTextPassThru = true;
+ }
+ else if (!strncmp(token, "/hi", 3)) {
+ if (u->hiType == "overline") {
+ const unsigned char *b = (const unsigned char *)u->lastTextNode.c_str();
+ while (*b) {
+ const unsigned char *o = b;
+ if (getUniCharFromUTF8(&b)) {
+ while (o != b) buf.append(*(o++));
+ buf.append((unsigned char)0xCC);
+ buf.append((unsigned char)0x85);
+ }
+ }
+ }
+ else {
+ buf.append("*");
+ buf.append(u->lastTextNode);
+ buf.append("*");
+ }
+ u->suspendTextPassThru = false;
+ }
// <milestone type="line"/>
else if (!strncmp(token, "milestone", 9)) {
diff --git a/src/modules/filters/osisredletterwords.cpp b/src/modules/filters/osisredletterwords.cpp
index 9075fd8..e7c921c 100644
--- a/src/modules/filters/osisredletterwords.cpp
+++ b/src/modules/filters/osisredletterwords.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * OSISRedLetterWords - SWFilter descendant to toggle red coloring for words
- * of Christ in an OSIS module.
+ * osisredletterwords.cpp - SWFilter descendant to toggle red coloring for
+ * words of Christ in an OSIS module
*
+ * $Id: osisredletterwords.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,14 +28,20 @@
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";
+namespace {
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const char oName[] = "Words of Christ in Red";
+ static const char oTip[] = "Toggles Red Coloring for Words of Christ On and Off if they are marked";
-OSISRedLetterWords::OSISRedLetterWords() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("On");
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
+
+
+OSISRedLetterWords::OSISRedLetterWords() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/osisreferencelinks.cpp b/src/modules/filters/osisreferencelinks.cpp
new file mode 100644
index 0000000..83308e4
--- /dev/null
+++ b/src/modules/filters/osisreferencelinks.cpp
@@ -0,0 +1,114 @@
+/******************************************************************************
+ *
+ * osisreferencelinks.cpp - SWFilter descendant to toggle OSIS reference
+ * links with specified type/subType
+ *
+ * $Id: osisreferencelinks.cpp 2995 2013-12-28 06:32:26Z greg.hellings $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <osisreferencelinks.h>
+#include <utilxml.h>
+#include <swmodule.h>
+
+
+SWORD_NAMESPACE_START
+
+
+namespace {
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
+
+
+OSISReferenceLinks::OSISReferenceLinks(const char *optionName, const char *optionTip, const char *type, const char *subType, const char *defaultValue)
+ : SWOptionFilter(),
+ optionName(optionName),
+ optionTip(optionTip),
+ type(type),
+ subType(subType) {
+
+ optName = this->optionName.c_str();
+ optTip = this->optionTip.c_str();
+ optValues = oValues();
+ setOptionValue(defaultValue);
+}
+
+
+OSISReferenceLinks::~OSISReferenceLinks() {
+}
+
+
+char OSISReferenceLinks::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
+ if (option) return 0;
+
+ SWBuf token;
+ bool intoken = false;
+ bool stripThisToken = false;
+
+ SWBuf orig = text;
+ const char *from = orig.c_str();
+
+ for (text = ""; *from; ++from) {
+ if (*from == '<') {
+ intoken = true;
+ token = "";
+ continue;
+ }
+ else if (*from == '>') { // process tokens
+ intoken = false;
+ if (strncmp(token, "reference", 9) && strncmp(token.c_str(), "/reference", 10)) {
+ text.append('<');
+ text.append(token);
+ text.append('>');
+ }
+ else {
+ XMLTag tag;
+ tag = token;
+ if (!tag.isEndTag() && type == tag.getAttribute("type") && (!subType.size() || subType == tag.getAttribute("subType"))) {
+ stripThisToken = true;
+ continue;
+ }
+ else if (tag.isEndTag() && stripThisToken) {
+ stripThisToken = false;
+ continue;
+ }
+ text.append('<');
+ text.append(token);
+ text.append('>');
+ }
+ continue;
+ }
+
+ if (intoken) { //copy token
+ token.append(*from);
+ }
+ else { //copy text which is not inside a token
+ text.append(*from);
+ }
+ }
+ return 0;
+}
+
+SWORD_NAMESPACE_END
+
+
diff --git a/src/modules/filters/osisrtf.cpp b/src/modules/filters/osisrtf.cpp
index b8cf30c..291aa08 100644
--- a/src/modules/filters/osisrtf.cpp
+++ b/src/modules/filters/osisrtf.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * osisrtf.cpp - OSIS to RTF filter
- * -------------------
- * begin : 2003-02-15
- * copyright : 2003 by CrossWire Bible Society
*
+ * osisrtf.cpp - OSIS to RTF filter
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: osisrtf.cpp 3005 2014-01-09 04:06:11Z greg.hellings $ *
+ *
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -53,8 +52,8 @@ namespace {
BiblicalText = false;
suspendLevel = 0;
if (module) {
- version = module->Name();
- BiblicalText = (!strcmp(module->Type(), "Biblical Texts"));
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
}
osisQToTick = ((!module->getConfigEntry("OSISqToTick")) || (strcmp(module->getConfigEntry("OSISqToTick"), "false")));
}
@@ -68,9 +67,11 @@ namespace {
delete [] tagData;
}
}
-static inline void outText(const char *t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
-static inline void outText(char t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
-};
+
+ static inline void outText(const char *t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
+ static inline void outText(char t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
+
+}
OSISRTF::OSISRTF() {
@@ -251,7 +252,7 @@ bool OSISRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *us
SWCATCH ( ... ) { }
if (vkey) {
char ch = ((!strcmp(type.c_str(), "crossReference")) || (!strcmp(type.c_str(), "x-cross-ref"))) ? 'x':'n';
- scratch.setFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, vkey->Verse(), footnoteNumber.c_str());
+ scratch.setFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, vkey->getVerse(), footnoteNumber.c_str());
outText(scratch.c_str(), buf, u);
u->inXRefNote = (ch == 'x');
}
@@ -325,7 +326,7 @@ bool OSISRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *us
}
// <milestone type="line"/> or <lb.../>
- else if ((!strcmp(tag.getName(), "lb")) || ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type")) && (!strcmp(tag.getAttribute("type"), "line")))) {
+ else if ((!strcmp(tag.getName(), "lb") && (!tag.getAttribute("type") || strcmp(tag.getAttribute("type"), "x-optional"))) || ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type")) && (!strcmp(tag.getAttribute("type"), "line")))) {
outText("{\\par}", buf, u);
userData->supressAdjacentWhitespace = true;
}
diff --git a/src/modules/filters/osisscripref.cpp b/src/modules/filters/osisscripref.cpp
index 73c7309..2bb7d15 100644
--- a/src/modules/filters/osisscripref.cpp
+++ b/src/modules/filters/osisscripref.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * OSISScripref - SWFilter descendant to hide or show scripture references
- * in an OSIS module.
+ * osisscripref.cpp - SWFilter descendant to hide or show scripture
+ * references in an OSIS module
*
+ * $Id: osisscripref.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,16 +26,23 @@
#include <swmodule.h>
#include <utilxml.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Cross-references";
-const char oTip[] = "Toggles Scripture Cross-references On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Cross-references";
+ static const char oTip[] = "Toggles Scripture Cross-references On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-OSISScripref::OSISScripref() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("On");
+OSISScripref::OSISScripref() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/osisstrongs.cpp b/src/modules/filters/osisstrongs.cpp
index 8c06b07..b937883 100644
--- a/src/modules/filters/osisstrongs.cpp
+++ b/src/modules/filters/osisstrongs.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * osisstrongs - SWFilter descendant to hide or show strongs number
- * in a OSIS module.
+ * osisstrongs.cpp - SWFilter descendant to hide or show Strong's number
+ * in a OSIS module
*
+ * $Id: osisstrongs.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,17 +29,23 @@
#include <versekey.h>
#include <utilxml.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Strong's Numbers";
-const char oTip[] = "Toggles Strong's Numbers On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Strong's Numbers";
+ static const char oTip[] = "Toggles Strong's Numbers On and Off if they exist";
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-OSISStrongs::OSISStrongs() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+OSISStrongs::OSISStrongs() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -49,7 +56,6 @@ OSISStrongs::~OSISStrongs() {
char OSISStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
SWBuf token;
bool intoken = false;
- bool lastspace = false;
int wordNum = 1;
char wordstr[5];
const char *wordStart = 0;
@@ -151,7 +157,7 @@ char OSISStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *mod
if ((lClass == "x-Strongs") || (lClass == "strong") || (lClass == "Strong")) {
if (isdigit(attrib[0])) {
if (vkey) {
- gh = vkey->Testament() ? 'H' : 'G';
+ gh = vkey->getTestament() ? 'H' : 'G';
}
}
else {
@@ -280,7 +286,6 @@ char OSISStrongs::processText(SWBuf &text, const SWKey *key, const SWModule *mod
}
else {
text.append(*from);
- lastspace = (*from == ' ');
}
}
return 0;
diff --git a/src/modules/filters/osisvariants.cpp b/src/modules/filters/osisvariants.cpp
index 16e0cfb..6cd3eda 100644
--- a/src/modules/filters/osisvariants.cpp
+++ b/src/modules/filters/osisvariants.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * osisvariants - SWFilter descendant to hide or show textual variants
- * in an OSIS module.
+ * osisvariants.cpp - SWFilter descendant to hide or show textual variants
+ * in an OSIS module
*
+ * $Id: osisvariants.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2006-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -23,51 +24,41 @@
#include <stdlib.h>
#include <osisvariants.h>
#include <utilstr.h>
+#include <utilxml.h>
-SWORD_NAMESPACE_START
-const char OSISVariants::primary[] = "Primary Reading";
-const char OSISVariants::secondary[] = "Secondary Reading";
-const char OSISVariants::all[] = "All Readings";
+SWORD_NAMESPACE_START
-const char OSISVariants::optName[] = "Textual Variants";
-const char OSISVariants::optTip[] = "Switch between Textual Variants modes";
+namespace {
+ static const char oName[] = "Textual Variants";
+ static const char oTip[] = "Switch between Textual Variants modes";
+ static const char *choices[4] = { "Primary Reading", "Secondary Reading", "All Readings", "" };
-OSISVariants::OSISVariants() {
- option = false;
- options.push_back(primary);
- options.push_back(secondary);
- options.push_back(all);
+ static const StringList *oValues() {
+ static const StringList oVals(&choices[0], &choices[3]);
+ return &oVals;
+ }
}
-OSISVariants::~OSISVariants() {
+OSISVariants::OSISVariants() : SWOptionFilter(oName, oTip, oValues()) {
}
-void OSISVariants::setOptionValue(const char *ival)
-{
- if (!stricmp(ival, primary)) option = 0;
- else if (!stricmp(ival, secondary)) option = 1;
- else option = 2;
-}
-const char *OSISVariants::getOptionValue()
-{
- if (option == 0) {
- return primary;
- }
- else if (option == 1) {
- return secondary;
- }
- else {
- return all;
- }
+OSISVariants::~OSISVariants() {
}
+
char OSISVariants::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
- if (option == 0 || option == 1) { //we want primary or variant only
+
+ int option = 0;
+ if (optionValue == choices[0]) option = 0;
+ else if (optionValue == choices[1]) option = 1;
+ else option = 2;
+
+ if (option == 0 || option == 1) { //we want primary or variant only
bool intoken = false;
bool hide = false;
bool invar = false;
@@ -75,9 +66,10 @@ char OSISVariants::processText(SWBuf &text, const SWKey *key, const SWModule *mo
SWBuf token;
SWBuf orig = text;
const char *from = orig.c_str();
+ XMLTag tag;
//we use a fixed comparision string to make sure the loop is as fast as the original two blocks with almost the same code
- //const char* variantCompareString = (option == 0) ? "div type=\"variant\" class=\"1\"" : "div type=\"variant\" class=\"2\"";
+ const char* variantChoice = (option == 0) ? "x-2" : "x-1";
for (text = ""; *from; from++) {
if (*from == '<') {
@@ -88,16 +80,16 @@ char OSISVariants::processText(SWBuf &text, const SWKey *key, const SWModule *mo
else if (*from == '>') { // process tokens
intoken = false;
- if (!strncmp(token.c_str(), "seg ", 4)) { //only one of the variants
- invar = true;
- hide = true;
- continue;
- }
- if (!strncmp(token.c_str(), "div type=\"variant\"", 18)) {
- invar = true;
- continue;
+ if (!strncmp(token.c_str(), "seg", 3)) {
+ tag = token;
+
+ if (tag.getAttribute("type") && !strcmp("x-variant", tag.getAttribute("type")) && tag.getAttribute("subType") && !strcmp(variantChoice, tag.getAttribute("subType"))) {
+ invar = true;
+ hide = true;
+ continue;
+ }
}
- if (!strncmp(token.c_str(), "/div", 4)) {
+ if (!strncmp(token.c_str(), "/seg", 4)) {
hide = false;
if (invar) {
invar = false;
@@ -126,8 +118,4 @@ char OSISVariants::processText(SWBuf &text, const SWKey *key, const SWModule *mo
}
-
-
-
-
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/osiswebif.cpp b/src/modules/filters/osiswebif.cpp
index e313836..2cbca0b 100644
--- a/src/modules/filters/osiswebif.cpp
+++ b/src/modules/filters/osiswebif.cpp
@@ -1,11 +1,11 @@
/***************************************************************************
- * OSISWEBIF.cpp - OSIS to HTML filter with hrefs
- * for strongs and morph tags
- * -------------------
- * begin : 2003-10-23
- * copyright : 2003 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * osiswebif.cpp - OSIS to HTML filter with hrefs for strongs and
+ * morph tags
+ *
+ * $Id: osiswebif.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -37,20 +37,13 @@ OSISWEBIF::OSISWEBIF() : baseURL(""), passageStudyURL(baseURL + "passagestudy.js
}
-BasicFilterUserData *OSISWEBIF::createUserData(const SWModule *module, const SWKey *key) {
- MyUserData *u = new MyUserData(module, key);
- u->wordsOfChristStart = "<span class=\"wordsOfJesus\"> ";
- u->wordsOfChristEnd = "</span> ";
- return u;
-}
-
-
bool OSISWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
MyUserData *u = (MyUserData *)userData;
SWBuf scratch;
bool sub = (u->suspendTextPassThru) ? substituteToken(scratch, token) : substituteToken(buf, token);
if (!sub) {
- // manually process if it wasn't a simple substitution
+
+ // manually process if it wasn't a simple substitution
XMLTag tag(token);
// <w> tag
@@ -143,7 +136,7 @@ bool OSISWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *
if (!tag.isEmpty()) {
if (!strongsMarkup) { // leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off
SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
- SWBuf modName = (u->module) ? u->module->Name() : "";
+ SWBuf modName = (u->module) ? u->module->getName() : "";
VerseKey *vkey = NULL;
// see if we have a VerseKey * or descendant
SWTRY {
@@ -165,43 +158,10 @@ bool OSISWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *
}
}
- // <title>
- else if (!strcmp(tag.getName(), "title")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "<h3>";
- }
- else if (tag.isEndTag()) {
- buf += "</h3>";
- }
- }
-
- // Milestoned paragraphs, created by osis2mod
- // <div type="paragraph" sID.../>
- // <div type="paragraph" eID.../>
- else if (tag.isEmpty() && !strcmp(tag.getName(), "div") && tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "paragraph")) {
- // This is properly handled by base class.
- return OSISHTMLHREF::handleToken(buf, token, userData);
- }
-
- // ok to leave these in
- else if (!strcmp(tag.getName(), "div")) {
- buf += tag;
- }
- else if (!strcmp(tag.getName(), "span")) {
- buf += tag;
- }
- else if (!strcmp(tag.getName(), "br")) {
- buf += tag;
- }
// handled appropriately in base class
- // <catchWord> & <rdg> tags (italicize)
- // <hi> text highlighting
- // <q> quote
- // <milestone type="cQuote" marker="x"/>
- // <transChange>
else {
- return OSISHTMLHREF::handleToken(buf, token, userData);
+ return OSISXHTML::handleToken(buf, token, userData);
}
}
return true;
diff --git a/src/modules/filters/osiswordjs.cpp b/src/modules/filters/osiswordjs.cpp
index da573d3..75946a8 100644
--- a/src/modules/filters/osiswordjs.cpp
+++ b/src/modules/filters/osiswordjs.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * osisstrongs - SWFilter descendant to hide or show strongs number
- * in a OSIS module.
+ * osiswordjs.cpp - SWFilter descendant for ???
*
+ * $Id: osiswordjs.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2005-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -30,17 +30,23 @@
#include <versekey.h>
#include <stdio.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Word Javascript";
-const char oTip[] = "Toggles Word Javascript data";
+namespace {
+
+ static const char oName[] = "Word Javascript";
+ static const char oTip[] = "Toggles Word Javascript data";
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-OSISWordJS::OSISWordJS() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+OSISWordJS::OSISWordJS() : SWOptionFilter(oName, oTip, oValues()) {
defaultGreekLex = 0;
defaultHebLex = 0;
@@ -59,10 +65,9 @@ char OSISWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
char token[2112]; // cheese. Fix.
int tokpos = 0;
bool intoken = false;
- bool lastspace = false;
int wordNum = 1;
char wordstr[5];
- SWBuf modName = (module)?module->Name():"";
+ SWBuf modName = (module)?module->getName():"";
// add TR to w src in KJV then remove this next line
SWBuf wordSrcPrefix = (modName == "KJV")?SWBuf("TR"):modName;
@@ -135,10 +140,10 @@ char OSISWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
// we can pass the real lex name in, but we have some
// aliases in the javascript to optimize bandwidth
if ((gh == 'G') && (defaultGreekLex)) {
- lexName = (!strcmp(defaultGreekLex->Name(), "StrongsGreek"))?"G":defaultGreekLex->Name();
+ lexName = (!strcmp(defaultGreekLex->getName(), "StrongsGreek"))?"G":defaultGreekLex->getName();
}
else if ((gh == 'H') && (defaultHebLex)) {
- lexName = (!strcmp(defaultHebLex->Name(), "StrongsHebrew"))?"H":defaultHebLex->Name();
+ lexName = (!strcmp(defaultHebLex->getName(), "StrongsHebrew"))?"H":defaultHebLex->getName();
}
SWBuf xlit = wtag.getAttribute("xlit");
@@ -151,7 +156,7 @@ char OSISWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
SWBuf wordID;
if (vkey) {
// optimize for bandwidth and use only the verse as the unique entry id
- wordID.appendFormatted("%d", vkey->Verse());
+ wordID.appendFormatted("%d", vkey->getVerse());
}
else {
wordID = key->getText();
@@ -186,7 +191,6 @@ char OSISWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
}
else {
text.append(*from);
- lastspace = (*from == ' ');
}
}
}
diff --git a/src/modules/filters/osisxhtml.cpp b/src/modules/filters/osisxhtml.cpp
new file mode 100644
index 0000000..b1040a9
--- /dev/null
+++ b/src/modules/filters/osisxhtml.cpp
@@ -0,0 +1,772 @@
+/******************************************************************************
+ *
+ * osisxhtml.cpp - Render filter for classed XHTML of an OSIS module
+ *
+ * $Id: osisxhtml.cpp 3005 2014-01-09 04:06:11Z greg.hellings $
+ *
+ * Copyright 2011-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <osisxhtml.h>
+#include <utilxml.h>
+#include <utilstr.h>
+#include <versekey.h>
+#include <swmodule.h>
+#include <url.h>
+#include <stringmgr.h>
+#include <stack>
+
+SWORD_NAMESPACE_START
+
+const char *OSISXHTML::getHeader() const {
+ const static char *header = "\
+ .divineName { font-variant: small-caps; }\n\
+ .wordsOfJesus { color: red; }\n\
+ .transChangeSupplied { font-style: italic; }\n\
+ .small, .sub, .sup { font-size: .83em }\n\
+ .sub { vertical-align: sub }\n\
+ .sup { vertical-align: super }\n\
+ .indent1 { margin-left: 10px }\n\
+ .indent2 { margin-left: 20px }\n\
+ .indent3 { margin-left: 30px }\n\
+ .indent4 { margin-left: 40px }\n\
+ ";
+ return header;
+}
+
+
+namespace {
+
+// though this might be slightly slower, possibly causing an extra bool check, this is a renderFilter
+// so speed isn't the absolute highest priority, and this is a very minor possible hit
+static inline void outText(const char *t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
+static inline void outText(char t, SWBuf &o, BasicFilterUserData *u) { if (!u->suspendTextPassThru) o += t; else u->lastSuspendSegment += t; }
+
+void processLemma(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf) {
+ const char *attrib;
+ const char *val;
+ if ((attrib = tag.getAttribute("lemma"))) {
+ int count = tag.getAttributePartCount("lemma", ' ');
+ int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
+ do {
+ attrib = tag.getAttribute("lemma", i, ' ');
+ if (i < 0) i = 0; // to handle our -1 condition
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ SWBuf gh;
+ if(*val == 'G')
+ gh = "Greek";
+ if(*val == 'H')
+ gh = "Hebrew";
+ const char *val2 = val;
+ if ((strchr("GH", *val)) && (isdigit(val[1])))
+ val2++;
+ //if ((!strcmp(val2, "3588")) && (lastText.length() < 1))
+ // show = false;
+ //else {
+ if (!suspendTextPassThru) {
+ buf.appendFormatted("<small><em class=\"strongs\">&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=%s&value=%s\" class=\"strongs\">%s</a>&gt;</em></small>",
+ (gh.length()) ? gh.c_str() : "",
+ URL::encode(val2).c_str(),
+ val2);
+ }
+ //}
+
+ } while (++i < count);
+ }
+}
+
+
+
+void processMorph(bool suspendTextPassThru, XMLTag &tag, SWBuf &buf) {
+ const char * attrib;
+ const char *val;
+ if ((attrib = tag.getAttribute("morph"))) { // && (show)) {
+ SWBuf savelemma = tag.getAttribute("savlm");
+ //if ((strstr(savelemma.c_str(), "3588")) && (lastText.length() < 1))
+ // show = false;
+ //if (show) {
+ int count = tag.getAttributePartCount("morph", ' ');
+ int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
+ do {
+ attrib = tag.getAttribute("morph", i, ' ');
+ if (i < 0) i = 0; // to handle our -1 condition
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ const char *val2 = val;
+ if ((*val == 'T') && (strchr("GH", val[1])) && (isdigit(val[2])))
+ val2+=2;
+ if (!suspendTextPassThru) {
+ buf.appendFormatted("<small><em class=\"morph\">(<a href=\"passagestudy.jsp?action=showMorph&type=%s&value=%s\" class=\"morph\">%s</a>)</em></small>",
+ URL::encode(tag.getAttribute("morph")).c_str(),
+ URL::encode(val).c_str(),
+ val2);
+ }
+ } while (++i < count);
+ //}
+ }
+}
+
+
+} // end anonymous namespace
+
+BasicFilterUserData *OSISXHTML::createUserData(const SWModule *module, const SWKey *key) {
+ return new MyUserData(module, key);
+}
+
+
+OSISXHTML::OSISXHTML() {
+ setTokenStart("<");
+ setTokenEnd(">");
+
+ setEscapeStart("&");
+ setEscapeEnd(";");
+
+ setEscapeStringCaseSensitive(true);
+ setPassThruNumericEscapeString(true);
+
+ addAllowedEscapeString("quot");
+ addAllowedEscapeString("apos");
+ addAllowedEscapeString("amp");
+ addAllowedEscapeString("lt");
+ addAllowedEscapeString("gt");
+
+ setTokenCaseSensitive(true);
+
+ // addTokenSubstitute("lg", "<br />");
+ // addTokenSubstitute("/lg", "<br />");
+
+ morphFirst = false;
+ renderNoteNumbers = false;
+}
+
+class OSISXHTML::TagStack : public std::stack<SWBuf> {
+};
+
+OSISXHTML::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key), quoteStack(new TagStack()), hiStack(new TagStack()), titleStack(new TagStack()), lineStack(new TagStack()) {
+ inXRefNote = false;
+ suspendLevel = 0;
+ wordsOfChristStart = "<span class=\"wordsOfJesus\"> ";
+ wordsOfChristEnd = "</span> ";
+ if (module) {
+ osisQToTick = ((!module->getConfigEntry("OSISqToTick")) || (strcmp(module->getConfigEntry("OSISqToTick"), "false")));
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
+ }
+ else {
+ osisQToTick = true; // default
+ version = "";
+ }
+ consecutiveNewlines = 0;
+}
+
+OSISXHTML::MyUserData::~MyUserData() {
+ delete quoteStack;
+ delete hiStack;
+ delete titleStack;
+ delete lineStack;
+}
+
+void OSISXHTML::MyUserData::outputNewline(SWBuf &buf) {
+ if (++consecutiveNewlines <= 2) {
+ outText("<br />\n", buf, this);
+ supressAdjacentWhitespace = true;
+ }
+}
+bool OSISXHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
+ MyUserData *u = (MyUserData *)userData;
+ SWBuf scratch;
+ bool sub = (u->suspendTextPassThru) ? substituteToken(scratch, token) : substituteToken(buf, token);
+ if (!sub) {
+ // manually process if it wasn't a simple substitution
+ XMLTag tag(token);
+
+ // <w> tag
+ if (!strcmp(tag.getName(), "w")) {
+
+ // start <w> tag
+ if ((!tag.isEmpty()) && (!tag.isEndTag())) {
+ u->w = token;
+ }
+
+ // end or empty <w> tag
+ else {
+ bool endTag = tag.isEndTag();
+ SWBuf lastText;
+ //bool show = true; // to handle unplaced article in kjv2003-- temporary till combined
+
+ if (endTag) {
+ tag = u->w.c_str();
+ lastText = u->lastTextNode.c_str();
+ }
+ else lastText = "stuff";
+
+ const char *attrib;
+ const char *val;
+ if ((attrib = tag.getAttribute("xlit"))) {
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ outText(" ", buf, u);
+ outText(val, buf, u);
+ }
+ if ((attrib = tag.getAttribute("gloss"))) {
+ // I'm sure this is not the cleanest way to do it, but it gets the job done
+ // for rendering ruby chars properly ^_^
+ buf -= lastText.length();
+
+ outText("<ruby><rb>", buf, u);
+ outText(lastText, buf, u);
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ outText("</rb><rp>(</rp><rt>", buf, u);
+ outText(val, buf, u);
+ outText("</rt><rp>)</rp></ruby>", buf, u);
+ }
+ if (!morphFirst) {
+ processLemma(u->suspendTextPassThru, tag, buf);
+ processMorph(u->suspendTextPassThru, tag, buf);
+ }
+ else {
+ processMorph(u->suspendTextPassThru, tag, buf);
+ processLemma(u->suspendTextPassThru, tag, buf);
+ }
+ if ((attrib = tag.getAttribute("POS"))) {
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ outText(" ", buf, u);
+ outText(val, buf, u);
+ }
+
+ /*if (endTag)
+ buf += "}";*/
+ }
+ }
+
+ // <note> tag
+ else if (!strcmp(tag.getName(), "note")) {
+ if (!tag.isEndTag()) {
+ SWBuf type = tag.getAttribute("type");
+ bool strongsMarkup = (type == "x-strongsMarkup" || type == "strongsMarkup"); // the latter is deprecated
+ if (strongsMarkup) {
+ tag.setEmpty(false); // handle bug in KJV2003 module where some note open tags were <note ... />
+ }
+
+ if (!tag.isEmpty()) {
+
+ if (!strongsMarkup) { // leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off
+ SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
+ VerseKey *vkey = NULL;
+ char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
+
+ u->inXRefNote = true; // Why this change? Ben Morgan: Any note can have references in, so we need to set this to true for all notes
+// u->inXRefNote = (ch == 'x');
+
+ // see if we have a VerseKey * or descendant
+ SWTRY {
+ vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ }
+ SWCATCH ( ... ) { }
+ if (vkey) {
+ //printf("URL = %s\n",URL::encode(vkey->getText()).c_str());
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
+ ch,
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(vkey->getText()).c_str(),
+ ch,
+ ch,
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
+ }
+ else {
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
+ ch,
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(u->key->getText()).c_str(),
+ ch,
+ ch,
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
+ }
+ }
+ }
+ u->suspendTextPassThru = (++u->suspendLevel);
+ }
+ if (tag.isEndTag()) {
+ u->suspendTextPassThru = (--u->suspendLevel);
+ u->inXRefNote = false;
+ u->lastSuspendSegment = ""; // fix/work-around for nasb devineName in note bug
+ }
+ }
+
+ // <p> paragraph and <lg> linegroup tags
+ else if (!strcmp(tag.getName(), "p") || !strcmp(tag.getName(), "lg")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) { // non-empty start tag
+ u->outputNewline(buf);
+ }
+ else if (tag.isEndTag()) { // end tag
+ u->outputNewline(buf);
+ }
+ else { // empty paragraph break marker
+ u->outputNewline(buf);
+ }
+ }
+
+ // Milestoned paragraphs, created by osis2mod
+ // <div type="paragraph" sID.../>
+ // <div type="paragraph" eID.../>
+ else if (tag.isEmpty() && !strcmp(tag.getName(), "div") && tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "paragraph")) {
+ // <div type="paragraph" sID... />
+ if (tag.getAttribute("sID")) { // non-empty start tag
+ u->outputNewline(buf);
+ }
+ // <div type="paragraph" eID... />
+ else if (tag.getAttribute("eID")) {
+ u->outputNewline(buf);
+ }
+ }
+
+ // <reference> tag
+ else if (!strcmp(tag.getName(), "reference")) {
+ if (!u->inXRefNote) { // only show these if we're not in an xref note
+ if (!tag.isEndTag()) {
+ SWBuf target;
+ SWBuf work;
+ SWBuf ref;
+ bool is_scripRef = false;
+
+ target = tag.getAttribute("osisRef");
+ const char* the_ref = strchr(target, ':');
+
+ if(!the_ref) {
+ // No work
+ ref = target;
+ is_scripRef = true;
+ }
+ else {
+ // Compensate for starting :
+ ref = the_ref + 1;
+
+ int size = target.size() - ref.size() - 1;
+ work.setSize(size);
+ strncpy(work.getRawData(), target, size);
+
+ // For Bible:Gen.3.15 or Bible.vulgate:Gen.3.15
+ if(!strncmp(work, "Bible", 5))
+ is_scripRef = true;
+ }
+
+ if(is_scripRef)
+ {
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=\">",
+ URL::encode(ref.c_str()).c_str()
+// (work.size()) ? URL::encode(work.c_str()).c_str() : "")
+ );
+ }
+ else
+ {
+ // Dictionary link, or something
+ buf.appendFormatted("<a href=\"sword://%s/%s\">",
+ URL::encode(work.c_str()).c_str(),
+ URL::encode(ref.c_str()).c_str()
+ );
+ }
+ }
+ else {
+ outText("</a>", buf, u);
+ }
+ }
+ }
+
+ // <l> poetry, etc
+ else if (!strcmp(tag.getName(), "l")) {
+ // start line marker
+ if (tag.getAttribute("sID") || (!tag.isEndTag() && !tag.isEmpty())) {
+ // nested lines plus if the line itself has an x-indent type attribute value
+ outText(SWBuf("<span class=\"line indent").appendFormatted("%d\">", u->lineStack->size() + (SWBuf("x-indent") == tag.getAttribute("type")?1:0)).c_str(), buf, u);
+ u->lineStack->push(tag.toString());
+ }
+ // end line marker
+ else if (tag.getAttribute("eID") || tag.isEndTag()) {
+ outText("</span>", buf, u);
+ u->outputNewline(buf);
+ if (u->lineStack->size()) u->lineStack->pop();
+ }
+ // <l/> without eID or sID
+ // Note: this is improper osis. This should be <lb/>
+ else if (tag.isEmpty() && !tag.getAttribute("sID")) {
+ u->outputNewline(buf);
+ }
+ }
+
+ // <lb.../>
+ else if (!strcmp(tag.getName(), "lb") && (!tag.getAttribute("type") || strcmp(tag.getAttribute("type"), "x-optional"))) {
+ u->outputNewline(buf);
+ }
+ // <milestone type="line"/>
+ // <milestone type="x-p"/>
+ // <milestone type="cQuote" marker="x"/>
+ else if ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type"))) {
+ if (!strcmp(tag.getAttribute("type"), "line")) {
+ u->outputNewline(buf);
+ if (tag.getAttribute("subType") && !strcmp(tag.getAttribute("subType"), "x-PM")) {
+ u->outputNewline(buf);
+ }
+ }
+ else if (!strcmp(tag.getAttribute("type"),"x-p")) {
+ if (tag.getAttribute("marker"))
+ outText(tag.getAttribute("marker"), buf, u);
+ else outText("<!p>", buf, u);
+ }
+ else if (!strcmp(tag.getAttribute("type"), "cQuote")) {
+ const char *tmp = tag.getAttribute("marker");
+ bool hasMark = tmp;
+ SWBuf mark = tmp;
+ tmp = tag.getAttribute("level");
+ int level = (tmp) ? atoi(tmp) : 1;
+
+ // first check to see if we've been given an explicit mark
+ if (hasMark)
+ outText(mark, buf, u);
+ // finally, alternate " and ', if config says we should supply a mark
+ else if (u->osisQToTick)
+ outText((level % 2) ? '\"' : '\'', buf, u);
+ }
+ }
+
+ // <title>
+ else if (!strcmp(tag.getName(), "title")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ if (vkey && !vkey->getVerse()) {
+ if (!vkey->getChapter()) {
+ if (!vkey->getBook()) {
+ if (!vkey->getTestament()) {
+ buf += "<h1 class=\"moduleHeader\">";
+ tag.setAttribute("pushed", "h1");
+ }
+ else {
+ buf += "<h1 class=\"testamentHeader\">";
+ tag.setAttribute("pushed", "h1");
+ }
+ }
+ else {
+ buf += "<h1 class=\"bookHeader\">";
+ tag.setAttribute("pushed", "h1");
+ }
+ }
+ else {
+ buf += "<h2 class=\"chapterHeader\">";
+ tag.setAttribute("pushed", "h2");
+ }
+ }
+ else {
+ buf += "<h3>";
+ tag.setAttribute("pushed", "h3");
+ }
+ u->titleStack->push(tag.toString());
+ }
+ else if (tag.isEndTag()) {
+ if (!u->titleStack->empty()) {
+ XMLTag tag(u->titleStack->top());
+ if (u->titleStack->size()) u->titleStack->pop();
+ SWBuf pushed = tag.getAttribute("pushed");
+ if (pushed.size()) {
+ buf += (SWBuf)"</" + pushed + ">\n\n";
+ }
+ else {
+ buf += "</h3>\n\n";
+ }
+ ++u->consecutiveNewlines;
+ u->supressAdjacentWhitespace = true;
+ }
+ }
+ }
+
+ // <list>
+ else if (!strcmp(tag.getName(), "list")) {
+ if((!tag.isEndTag()) && (!tag.isEmpty())) {
+ outText("<ul>\n", buf, u);
+ }
+ else if (tag.isEndTag()) {
+ outText("</ul>\n", buf, u);
+ ++u->consecutiveNewlines;
+ u->supressAdjacentWhitespace = true;
+ }
+ }
+
+ // <item>
+ else if (!strcmp(tag.getName(), "item")) {
+ if((!tag.isEndTag()) && (!tag.isEmpty())) {
+ outText("\t<li>", buf, u);
+ }
+ else if (tag.isEndTag()) {
+ outText("</li>\n", buf, u);
+ ++u->consecutiveNewlines;
+ u->supressAdjacentWhitespace = true;
+ }
+ }
+ // <catchWord> & <rdg> tags (italicize)
+ else if (!strcmp(tag.getName(), "rdg") || !strcmp(tag.getName(), "catchWord")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ outText("<i>", buf, u);
+ }
+ else if (tag.isEndTag()) {
+ outText("</i>", buf, u);
+ }
+ }
+
+ // divineName
+ else if (!strcmp(tag.getName(), "divineName")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ u->suspendTextPassThru = (++u->suspendLevel);
+ }
+ else if (tag.isEndTag()) {
+ SWBuf lastText = u->lastSuspendSegment.c_str();
+ u->suspendTextPassThru = (--u->suspendLevel);
+ if (lastText.size()) {
+ scratch.setFormatted("<span class=\"divineName\">%s</span>", lastText.c_str());
+ outText(scratch.c_str(), buf, u);
+ }
+ }
+ }
+
+ // <hi> text highlighting
+ else if (!strcmp(tag.getName(), "hi")) {
+ SWBuf type = tag.getAttribute("type");
+
+ // handle tei rend attribute if type doesn't exist
+ if (!type.length()) type = tag.getAttribute("rend");
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (type == "bold" || type == "b" || type == "x-b") {
+ outText("<b>", buf, u);
+ }
+
+ // there is no officially supported OSIS overline attribute,
+ // thus either TEI overline or OSIS x-overline would be best,
+ // but we have used "ol" in the past, as well. Once a valid
+ // OSIS overline attribute is made available, these should all
+ // eventually be deprecated and never documented that they are supported.
+ else if (type == "ol" || type == "overline" || type == "x-overline") {
+ outText("<span style=\"text-decoration:overline\">", buf, u);
+ }
+
+ else if (type == "super") {
+ outText("<span class=\"sup\">", buf, u);
+ }
+ else if (type == "sub") {
+ outText("<span class=\"sub\">", buf, u);
+ }
+ else { // all other types
+ outText("<i>", buf, u);
+ }
+ u->hiStack->push(tag.toString());
+ }
+ else if (tag.isEndTag()) {
+ SWBuf type = "";
+ if (!u->hiStack->empty()) {
+ XMLTag tag(u->hiStack->top());
+ if (u->hiStack->size()) u->hiStack->pop();
+ type = tag.getAttribute("type");
+ if (!type.length()) type = tag.getAttribute("rend");
+ }
+ if (type == "bold" || type == "b" || type == "x-b") {
+ outText("</b>", buf, u);
+ }
+ else if ( type == "ol"
+ || type == "super"
+ || type == "sub") {
+ outText("</span>", buf, u);
+ }
+ else outText("</i>", buf, u);
+ }
+ }
+
+ // <q> quote
+ // Rules for a quote element:
+ // If the tag is empty with an sID or an eID then use whatever it specifies for quoting.
+ // Note: empty elements without sID or eID are ignored.
+ // If the tag is <q> then use it's specifications and push it onto a stack for </q>
+ // If the tag is </q> then use the pushed <q> for specification
+ // If there is a marker attribute, possibly empty, this overrides osisQToTick.
+ // If osisQToTick, then output the marker, using level to determine the type of mark.
+ else if (!strcmp(tag.getName(), "q")) {
+ SWBuf type = tag.getAttribute("type");
+ SWBuf who = tag.getAttribute("who");
+ const char *tmp = tag.getAttribute("level");
+ int level = (tmp) ? atoi(tmp) : 1;
+ tmp = tag.getAttribute("marker");
+ bool hasMark = tmp;
+ SWBuf mark = tmp;
+
+ // open <q> or <q sID... />
+ if ((!tag.isEmpty() && !tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute("sID"))) {
+ // if <q> then remember it for the </q>
+ if (!tag.isEmpty()) {
+ u->quoteStack->push(tag.toString());
+ }
+
+ // Do this first so quote marks are included as WoC
+ if (who == "Jesus")
+ outText(u->wordsOfChristStart, buf, u);
+
+ // first check to see if we've been given an explicit mark
+ if (hasMark)
+ outText(mark, buf, u);
+ //alternate " and '
+ else if (u->osisQToTick)
+ outText((level % 2) ? '\"' : '\'', buf, u);
+ }
+ // close </q> or <q eID... />
+ else if ((tag.isEndTag()) || (tag.isEmpty() && tag.getAttribute("eID"))) {
+ // if it is </q> then pop the stack for the attributes
+ if (tag.isEndTag() && !u->quoteStack->empty()) {
+ XMLTag qTag(u->quoteStack->top());
+ if (u->quoteStack->size()) u->quoteStack->pop();
+
+ type = qTag.getAttribute("type");
+ who = qTag.getAttribute("who");
+ tmp = qTag.getAttribute("level");
+ level = (tmp) ? atoi(tmp) : 1;
+ tmp = qTag.getAttribute("marker");
+ hasMark = tmp;
+ mark = tmp;
+ }
+
+ // first check to see if we've been given an explicit mark
+ if (hasMark)
+ outText(mark, buf, u);
+ // finally, alternate " and ', if config says we should supply a mark
+ else if (u->osisQToTick)
+ outText((level % 2) ? '\"' : '\'', buf, u);
+
+ // Do this last so quote marks are included as WoC
+ if (who == "Jesus")
+ outText(u->wordsOfChristEnd, buf, u);
+ }
+ }
+
+ // <transChange>
+ else if (!strcmp(tag.getName(), "transChange")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ SWBuf type = tag.getAttribute("type");
+ u->lastTransChange = type;
+
+ // just do all transChange tags this way for now
+ if ((type == "added") || (type == "supplied"))
+ outText("<span class=\"transChangeSupplied\">", buf, u);
+ else if (type == "tenseChange")
+ buf += "*";
+ }
+ else if (tag.isEndTag()) {
+ SWBuf type = u->lastTransChange;
+ if ((type == "added") || (type == "supplied"))
+ outText("</span>", buf, u);
+ }
+ else { // empty transChange marker?
+ }
+ }
+
+ // image
+ else if (!strcmp(tag.getName(), "figure")) {
+ const char *src = tag.getAttribute("src");
+ if (src) { // assert we have a src attribute
+ SWBuf filepath;
+ if (userData->module) {
+ filepath = userData->module->getConfigEntry("AbsoluteDataPath");
+ if ((filepath.size()) && (filepath[filepath.size()-1] != '/') && (src[0] != '/'))
+ filepath += '/';
+ }
+ filepath += src;
+
+ // images become clickable, if the UI supports showImage.
+ outText("<a href=\"passagestudy.jsp?action=showImage&value=", buf, u);
+ outText(URL::encode(filepath.c_str()).c_str(), buf, u);
+ outText("&module=", buf, u);
+ outText(URL::encode(u->version.c_str()).c_str(), buf, u);
+ outText("\">", buf, u);
+
+ outText("<img src=\"file:", buf, u);
+ outText(filepath, buf, u);
+ outText("\" border=\"0\" />", buf, u);
+
+ outText("</a>", buf, u);
+ }
+ }
+
+ // ok to leave these in
+ else if (!strcmp(tag.getName(), "div")) {
+ SWBuf type = tag.getAttribute("type");
+ if (type == "bookGroup") {
+ }
+ else if (type == "book") {
+ }
+ else if (type == "section") {
+ }
+ else if (type == "majorSection") {
+ }
+ else {
+ buf += tag;
+ }
+ }
+ else if (!strcmp(tag.getName(), "span")) {
+ buf += tag;
+ }
+ else if (!strcmp(tag.getName(), "br")) {
+ buf += tag;
+ }
+ else if (!strcmp(tag.getName(), "table")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "<table><tbody>\n";
+ }
+ else if (tag.isEndTag()) {
+ buf += "</tbody></table>\n";
+ ++u->consecutiveNewlines;
+ u->supressAdjacentWhitespace = true;
+ }
+
+ }
+ else if (!strcmp(tag.getName(), "row")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "\t<tr>";
+ }
+ else if (tag.isEndTag()) {
+ buf += "</tr>\n";
+ }
+
+ }
+ else if (!strcmp(tag.getName(), "cell")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "<td>";
+ }
+ else if (tag.isEndTag()) {
+ buf += "</td>";
+ }
+ }
+ else {
+ if (!u->supressAdjacentWhitespace) u->consecutiveNewlines = 0;
+ return false; // we still didn't handle token
+ }
+ }
+ if (!u->supressAdjacentWhitespace) u->consecutiveNewlines = 0;
+ return true;
+}
+
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/filters/osisxlit.cpp b/src/modules/filters/osisxlit.cpp
new file mode 100644
index 0000000..d5ccbe4
--- /dev/null
+++ b/src/modules/filters/osisxlit.cpp
@@ -0,0 +1,99 @@
+/******************************************************************************
+ *
+ * osisxlit.cpp - SWFilter descendant to hide or show xlit values
+ * (encoded transliterations) in an OSIS module
+ *
+ * $Id: osisxlit.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <osisxlit.h>
+#include <utilxml.h>
+
+
+SWORD_NAMESPACE_START
+
+namespace {
+
+ static const char oName[] = "Transliterated Forms";
+ static const char oTip[] = "Toggles transliterated forms On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
+
+
+OSISXlit::OSISXlit() : SWOptionFilter(oName, oTip, oValues()) {
+}
+
+
+OSISXlit::~OSISXlit() {
+}
+
+
+char OSISXlit::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
+ SWBuf token;
+ bool intoken = false;
+
+ const SWBuf orig = text;
+ const char * from = orig.c_str();
+
+ if (!option) {
+ for (text = ""; *from; ++from) {
+ if (*from == '<') {
+ intoken = true;
+ token = "";
+ continue;
+ }
+ if (*from == '>') { // process tokens
+ intoken = false;
+ if (token.startsWith("w ")) { // Word
+ XMLTag wtag(token);
+ const char *l = wtag.getAttribute("xlit");
+ if (l) {
+ wtag.setAttribute("xlit", 0);
+ token = wtag;
+ token.trim();
+ // drop <>
+ token << 1;
+ token--;
+ }
+ }
+
+ // keep token in text
+ text.append('<');
+ text.append(token);
+ text.append('>');
+
+ continue;
+ }
+ if (intoken) {
+ token += *from;
+ }
+ else {
+ text.append(*from);
+ }
+ }
+ }
+ return 0;
+}
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/filters/papyriplain.cpp b/src/modules/filters/papyriplain.cpp
index 782b52a..bf6c9dd 100644
--- a/src/modules/filters/papyriplain.cpp
+++ b/src/modules/filters/papyriplain.cpp
@@ -1,9 +1,10 @@
/******************************************************************************
*
- * papyriplain - SWFilter descendant to strip out all Papyri tags
+ * papyriplain.cpp - SWFilter descendant to strip out all Papyri tags
*
+ * $Id: papyriplain.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2005-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,6 +25,7 @@
SWORD_NAMESPACE_START
+
PapyriPlain::PapyriPlain() {
}
diff --git a/src/modules/filters/plainfootnotes.cpp b/src/modules/filters/plainfootnotes.cpp
deleted file mode 100644
index 449f7da..0000000
--- a/src/modules/filters/plainfootnotes.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/***************************************************************************
- * plainfootnotes.cpp - description
- * -------------------
- * begin : Wed Oct 13 1999
- * copyright : (C) 1999 by The team of BibleTime
- * email : info@bibletime.de
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
- * CrossWire Bible Society
- * P. O. Box 2528
- * Tempe, AZ 85280-2528
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- */
-
-#include <plainfootnotes.h>
-#include <swkey.h>
-
-#include <stdlib.h>
-
-SWORD_NAMESPACE_START
-
-const char oName[] = "Footnotes";
-const char oTip[] = "Toggles Footnotes On and Off In Bible Texts If They Exist";
-
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-
-PLAINFootnotes::PLAINFootnotes() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
-}
-
-PLAINFootnotes::~PLAINFootnotes(){
-}
-
-
-char PLAINFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- if (!option) { // if we don't want footnotes
- //char token[2048];
- //SWBuf token;
- //int tokpos = 0;
- //bool intoken = false;
- //bool lastspace = false;
-
- bool hide = false;
-
- SWBuf orig = text;
- const char *from = orig.c_str();
- for (text = ""; *from; from++) {
- if (*from == '{') // Footnote start
- {
- hide = true;
- continue;
- }
- else if (*from == '}') // Footnote end
- {
- hide = false;
- continue;
- }
-
- //if (intoken) {
- //if (tokpos < 2045)
- // token += *from;
- // token[tokpos+2] = 0;
- //}
- //else {
- if (!hide) {
- text = *from;
- //lastspace = (*from == ' ');
- }
- //}
- }
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/plainhtml.cpp b/src/modules/filters/plainhtml.cpp
deleted file mode 100644
index 3f989fa..0000000
--- a/src/modules/filters/plainhtml.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/***************************************************************************
- * plainhtml.cpp - description
- * -------------------
- * begin : Thu Jun 24 1999
- * copyright : (C) 1999 by Torsten Uhlmann
- * email : TUhlmann@gmx.de
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
- * CrossWire Bible Society
- * P. O. Box 2528
- * Tempe, AZ 85280-2528
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- */
-
-#include <plainhtml.h>
-#include <swbuf.h>
-
-SWORD_NAMESPACE_START
-
-PLAINHTML::PLAINHTML()
-{
-}
-
-
-char PLAINHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
-{
- int count = 0;
-
- SWBuf orig = text;
- const char *from = orig.c_str();
- for (text = ""; *from; from++)
- {
- if ((*from == '\n') && (from[1] == '\n')) // two newlinea are a paragraph
- {
- text += "<P>";
- from++;
- continue;
- } else {
- if ((*from == '\n')) // && (from[1] != '\n')) // only one new line
- {
- text += "<BR>";
- continue;
- }
- }
-
- if (*from == '{') { //footnote start
- text += "<FONT COLOR=\"#80000\"><SMALL> (";
- continue;
- }
- else if (*from == '}') //footnote end
- {
- text += ") </SMALL></FONT>";
- continue;
- }
- else if (*from == '<') {
- text += "&lt;";
- continue;
- }
- else if (*from == '>') {
- text += "&gt;";
- continue;
- }
- else if (*from == '&') {
- text += "&amp;";
- continue;
- }
- else if ((*from == ' ') && (count > 5000))
- {
- text += "<WBR>";
- count = 0;
- continue;
- }
-
- text += *from;
- count++;
- }
- return 0;
-}
-
-SWORD_NAMESPACE_END
diff --git a/src/modules/filters/rtfhtml.cpp b/src/modules/filters/rtfhtml.cpp
index 7b55721..df02f38 100644
--- a/src/modules/filters/rtfhtml.cpp
+++ b/src/modules/filters/rtfhtml.cpp
@@ -1,11 +1,11 @@
/***************************************************************************
- * rtfhtml.cpp - description
- * -------------------
- * begin : Wed Oct 13 1999
- * copyright : (C) 1999 by The team of BibleTime
- * email : info@bibletime.de
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * rtfhtml.cpp - filter to convert RTF to HTML
+ *
+ * $Id: rtfhtml.cpp 2981 2013-09-15 00:05:26Z scribe $
+ *
+ * Copyright 1999 The team of Bibletime (info@bibletime.de)
+ * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,11 +24,14 @@
#include <stdlib.h>
#include <rtfhtml.h>
#include <swbuf.h>
+#include <utilstr.h>
+#include <ctype.h>
+#include <sysdata.h>
SWORD_NAMESPACE_START
-RTFHTML::RTFHTML() {
-
+RTFHTML::RTFHTML()
+{
}
@@ -43,12 +46,25 @@ char RTFHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
if (*from == '\\') // a RTF command
{
+ // \u12345?
+ if ( *(from+1) == 'u' && (*(from+2) == '-' || isdigit(*(from+2)))) {
+ from += 2;
+ const char *end = from;
+ while (isdigit(*++end));
+ SWBuf num;
+ num.append(from, end-from);
+ __s16 n = atoi(num.c_str());
+ __u32 u = (__u16)n;
+ text.append(getUTF8FromUniChar(u));
+ from += (end-from);
+ continue;
+ }
if ( !strncmp(from+1, "pard", 4) )
//(from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r') && (from[4] == 'd'))
{ // switch all modifiers off
if (center)
{
- text += "</CENTER>";
+ text += "</center>";
center = false;
}
from += 4;
@@ -57,7 +73,7 @@ char RTFHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
if ( !strncmp(from+1, "par", 3) )
//(from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r'))
{
- text += "<P>\n";
+ text += "<p/>\n";
from += 3;
continue;
}
@@ -71,7 +87,7 @@ char RTFHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
if (!center)
{
- text += "<CENTER>";
+ text += "<center>";
center = true;
}
from += 2;
diff --git a/src/modules/filters/scsuutf8.cpp b/src/modules/filters/scsuutf8.cpp
new file mode 100644
index 0000000..c68ea1f
--- /dev/null
+++ b/src/modules/filters/scsuutf8.cpp
@@ -0,0 +1,246 @@
+/******************************************************************************
+ *
+ * scsuutf8.cpp - SWFilter descendant to convert a SCSU character to
+ * UTF-8
+ *
+ * $Id: scsuutf8.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+/* This class is based on:
+ * http://czyborra.com/scsu/scsu.c written by Roman Czyborra@dds.nl
+ * on Andrea's balcony in North Amsterdam on 1998-08-04
+ * Thanks to Richard Verhoeven <rcb5@win.tue.nl> for his suggestion
+ * to correct the haphazard "if" after UQU to "else if" on 1998-10-01
+ *
+ * This is a deflator to UTF-8 output for input compressed in SCSU,
+ * the (Reuters) Standard Compression Scheme for Unicode as described
+ * in http://www.unicode.org/unicode/reports/tr6.html
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <swmodule.h>
+
+#include <scsuutf8.h>
+
+
+SWORD_NAMESPACE_START
+
+
+SCSUUTF8::SCSUUTF8() {
+}
+
+
+unsigned char* SCSUUTF8::UTF8Output(unsigned long uchar, unsigned char* text)
+{
+ /* join UTF-16 surrogates without any pairing sanity checks */
+
+ static int d;
+
+ if (uchar >= 0xd800 && uchar <= 0xdbff) { d = uchar & 0x3f; return text; }
+ if (uchar >= 0xdc00 && uchar <= 0xdfff) { uchar = uchar + 0x2400 + d * 0x400; }
+
+ /* output one character as UTF-8 multibyte sequence */
+
+ if (uchar < 0x80) {
+ *text++ = c;
+ }
+ else if (uchar < 0x800) {
+ *text++ = 0xc0 | uchar >> 6;
+ *text++ = 0x80 | (uchar & 0x3f);
+ }
+ else if (uchar < 0x10000) {
+ *text++ = 0xe0 | uchar >> 12;
+ *text++ = 0x80 | (uchar >> 6 & 0x3f);
+ *text++ = 0x80 | (uchar & 0x3f);
+ }
+ else if (uchar < 0x200000) {
+ *text++ = 0xf0 | uchar >> 18;
+ *text++ = 0x80 | (uchar >> 12 & 0x3f);
+ *text++ = 0x80 | (uchar >> 6 & 0x3f);
+ *text++ = 0x80 | (uchar & 0x3f);
+ }
+
+ return text;
+}
+
+
+char SCSUUTF8::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
+/*
+ unsigned char *to, *from;
+ unsigned long buflen = len * FILTERPAD;
+ char active = 0, mode = 0;
+ if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
+ return -1;
+
+ static unsigned short start[8] = {0x0000,0x0080,0x0100,0x0300,0x2000,0x2080,0x2100,0x3000};
+ static unsigned short slide[8] = {0x0080,0x00C0,0x0400,0x0600,0x0900,0x3040,0x30A0,0xFF00};
+ static unsigned short win[256] = {
+ 0x0000, 0x0080, 0x0100, 0x0180, 0x0200, 0x0280, 0x0300, 0x0380,
+ 0x0400, 0x0480, 0x0500, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780,
+ 0x0800, 0x0880, 0x0900, 0x0980, 0x0A00, 0x0A80, 0x0B00, 0x0B80,
+ 0x0C00, 0x0C80, 0x0D00, 0x0D80, 0x0E00, 0x0E80, 0x0F00, 0x0F80,
+ 0x1000, 0x1080, 0x1100, 0x1180, 0x1200, 0x1280, 0x1300, 0x1380,
+ 0x1400, 0x1480, 0x1500, 0x1580, 0x1600, 0x1680, 0x1700, 0x1780,
+ 0x1800, 0x1880, 0x1900, 0x1980, 0x1A00, 0x1A80, 0x1B00, 0x1B80,
+ 0x1C00, 0x1C80, 0x1D00, 0x1D80, 0x1E00, 0x1E80, 0x1F00, 0x1F80,
+ 0x2000, 0x2080, 0x2100, 0x2180, 0x2200, 0x2280, 0x2300, 0x2380,
+ 0x2400, 0x2480, 0x2500, 0x2580, 0x2600, 0x2680, 0x2700, 0x2780,
+ 0x2800, 0x2880, 0x2900, 0x2980, 0x2A00, 0x2A80, 0x2B00, 0x2B80,
+ 0x2C00, 0x2C80, 0x2D00, 0x2D80, 0x2E00, 0x2E80, 0x2F00, 0x2F80,
+ 0x3000, 0x3080, 0x3100, 0x3180, 0x3200, 0x3280, 0x3300, 0x3800,
+ 0xE000, 0xE080, 0xE100, 0xE180, 0xE200, 0xE280, 0xE300, 0xE380,
+ 0xE400, 0xE480, 0xE500, 0xE580, 0xE600, 0xE680, 0xE700, 0xE780,
+ 0xE800, 0xE880, 0xE900, 0xE980, 0xEA00, 0xEA80, 0xEB00, 0xEB80,
+ 0xEC00, 0xEC80, 0xED00, 0xED80, 0xEE00, 0xEE80, 0xEF00, 0xEF80,
+ 0xF000, 0xF080, 0xF100, 0xF180, 0xF200, 0xF280, 0xF300, 0xF380,
+ 0xF400, 0xF480, 0xF500, 0xF580, 0xF600, 0xF680, 0xF700, 0xF780,
+ 0xF800, 0xF880, 0xF900, 0xF980, 0xFA00, 0xFA80, 0xFB00, 0xFB80,
+ 0xFC00, 0xFC80, 0xFD00, 0xFD80, 0xFE00, 0xFE80, 0xFF00, 0xFF80,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x00C0, 0x0250, 0x0370, 0x0530, 0x3040, 0x30A0, 0xFF60
+ };
+
+ if (!len)
+ return 0;
+
+ memmove(&text[buflen - len], text, len);
+ from = (unsigned char*)&text[buflen - len];
+ to = (unsigned char *)text;
+
+ // -------------------------------
+
+ for (int i = 0; i < len;) {
+
+
+ if (i >= len) break;
+ c = from[i++];
+
+ if (c >= 0x80)
+ {
+ to = UTF8Output (c - 0x80 + slide[active], to);
+ }
+ else if (c >= 0x20 && c <= 0x7F)
+ {
+ to = UTF8Output (c, to);
+ }
+ else if (c == 0x0 || c == 0x9 || c == 0xA || c == 0xC || c == 0xD)
+ {
+ to = UTF8Output (c, to);
+ }
+ else if (c >= 0x1 && c <= 0x8) // SQn
+ {
+ if (i >= len) break;
+ d = from[i++]; // single quote
+
+ to = UTF8Output (d < 0x80 ? d + start [c - 0x1] :
+ d - 0x80 + slide [c - 0x1], to);
+ }
+ else if (c >= 0x10 && c <= 0x17) // SCn
+ {
+ active = c - 0x10; // change window
+ }
+ else if (c >= 0x18 && c <= 0x1F) // SDn
+ {
+ active = c - 0x18; // define window
+ if (i >= len) break;
+ slide [active] = win [from[i++]];
+ }
+ else if (c == 0xB) // SDX
+ {
+ if (i >= len) break;
+ c = from[i++];
+
+ if (i >= len) break;
+ d = from[i++];
+
+ slide [active = c>>5] = 0x10000 + (((c & 0x1F) << 8 | d) << 7);
+ }
+ else if (c == 0xE) // SQU
+ {
+ if (i >= len) break;
+ c = from[i++]; // SQU
+
+ if (i >= len) break;
+ to = UTF8Output (c << 8 | from[i++], to);
+ }
+ else if (c == 0xF) // SCU
+ {
+ mode = 1; // change to Unicode mode
+
+ while (mode)
+ {
+ if (i >= len) break;
+ c = from[i++];
+
+ if (c <= 0xDF || c >= 0xF3)
+ {
+ if (i >= len) break;
+ to = UTF8Output (c << 8 | from[i++], to);
+ }
+ else if (c == 0xF0) // UQU
+ {
+ if (i >= len) break;
+ c = from[i++];
+
+ if (i >= len) break;
+ to = UTF8Output (c << 8 | from[i++], to);
+ }
+ else if (c >= 0xE0 && c <= 0xE7) // UCn
+ {
+ active = c - 0xE0; mode = 0;
+ }
+ else if (c >= 0xE8 && c <= 0xEF) // UDn
+ {
+ if (i >= len) break;
+ slide [active=c-0xE8] = win [from[i++]]; mode = 0;
+ }
+ else if (c == 0xF1) // UDX
+ {
+ if (i >= len) break;
+ c = from[i++];
+
+ if (i >= len) break;
+ d = from[i++];
+
+ slide [active = c>>5] =
+ 0x10000 + (((c & 0x1F) << 8 | d) << 7); mode = 0;
+ }
+ }
+ }
+
+
+ }
+
+ *to++ = 0;
+ *to = 0;
+*/
+ return 0;
+}
+
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/filters/swbasicfilter.cpp b/src/modules/filters/swbasicfilter.cpp
index ef10e45..e66017e 100644
--- a/src/modules/filters/swbasicfilter.cpp
+++ b/src/modules/filters/swbasicfilter.cpp
@@ -1,12 +1,13 @@
/******************************************************************************
- * swbasicfilter.h - definition of class SWBasicFilter. An SWFilter
- * impl that provides some basic methods that
- * many filters will need and can use as a starting
- * point.
*
- * $Id: swbasicfilter.cpp 2167 2008-05-16 23:23:39Z scribe $
+ * swbasicfilter.cpp - definition of class SWBasicFilter. An SWFilter
+ * impl that provides some basic methods that
+ * many filters will need and can use as a starting
+ * point.
*
- * Copyright 2001 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swbasicfilter.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -33,9 +34,11 @@
SWORD_NAMESPACE_START
+
typedef std::map<SWBuf, SWBuf> DualStringMap;
typedef std::set<SWBuf> StringSet;
+
// I hate bridge patterns but this isolates std::map from a ton of filters
class SWBasicFilter::Private {
public:
@@ -44,11 +47,13 @@ public:
StringSet escPassSet;
};
+
const char SWBasicFilter::INITIALIZE = 1;
const char SWBasicFilter::PRECHAR = 2;
const char SWBasicFilter::POSTCHAR = 4;
const char SWBasicFilter::FINALIZE = 8;
+
SWBasicFilter::SWBasicFilter() {
p = new Private;
@@ -98,6 +103,7 @@ void SWBasicFilter::setPassThruUnknownEscapeString(bool val) {
passThruUnknownEsc = val;
}
+
void SWBasicFilter::setPassThruNumericEscapeString(bool val) {
passThruUnknownEsc = val;
}
@@ -132,6 +138,7 @@ void SWBasicFilter::removeTokenSubstitute(const char *findString) {
}
}
+
void SWBasicFilter::addAllowedEscapeString(const char *findString) {
char *buf = 0;
@@ -144,12 +151,14 @@ void SWBasicFilter::addAllowedEscapeString(const char *findString) {
else p->escPassSet.insert(StringSet::value_type(findString));
}
+
void SWBasicFilter::removeAllowedEscapeString(const char *findString) {
if (p->escPassSet.find(findString) != p->escPassSet.end()) {
p->escPassSet.erase( p->escPassSet.find(findString) );
}
}
+
void SWBasicFilter::addEscapeStringSubstitute(const char *findString, const char *replaceString) {
char *buf = 0;
@@ -162,12 +171,14 @@ void SWBasicFilter::addEscapeStringSubstitute(const char *findString, const char
else p->escSubMap.insert(DualStringMap::value_type(findString, replaceString));
}
+
void SWBasicFilter::removeEscapeStringSubstitute(const char *findString) {
if (p->escSubMap.find(findString) != p->escSubMap.end()) {
p->escSubMap.erase( p->escSubMap.find(findString) );
}
}
+
bool SWBasicFilter::substituteToken(SWBuf &buf, const char *token) {
DualStringMap::iterator it;
@@ -187,12 +198,14 @@ bool SWBasicFilter::substituteToken(SWBuf &buf, const char *token) {
return false;
}
+
void SWBasicFilter::appendEscapeString(SWBuf &buf, const char *escString) {
buf += escStart;
buf += escString;
buf += escEnd;
}
+
bool SWBasicFilter::passAllowedEscapeString(SWBuf &buf, const char *escString) {
StringSet::iterator it;
@@ -213,6 +226,7 @@ bool SWBasicFilter::passAllowedEscapeString(SWBuf &buf, const char *escString) {
return false;
}
+
bool SWBasicFilter::handleNumericEscapeString(SWBuf &buf, const char *escString) {
if (passThruNumericEsc) {
appendEscapeString(buf, escString);
@@ -221,6 +235,7 @@ bool SWBasicFilter::handleNumericEscapeString(SWBuf &buf, const char *escString)
return false;
}
+
bool SWBasicFilter::substituteEscapeString(SWBuf &buf, const char *escString) {
DualStringMap::iterator it;
@@ -403,4 +418,5 @@ char SWBasicFilter::processText(SWBuf &text, const SWKey *key, const SWModule *m
return 0;
}
+
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/swoptfilter.cpp b/src/modules/filters/swoptfilter.cpp
index 9d6dac4..5c205f5 100644
--- a/src/modules/filters/swoptfilter.cpp
+++ b/src/modules/filters/swoptfilter.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
*
- * swoptfilter - SWFilter descendant and base class for all option filters
+ * swoptfilter.cpp - SWFilter descendant and base class for all option
+ * filters
*
+ * $Id: swoptfilter.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -33,10 +35,13 @@ SWOptionFilter::SWOptionFilter() {
optValues = &empty;
}
+
SWOptionFilter::SWOptionFilter(const char *oName, const char *oTip, const StringList *oValues) {
optName = oName;
optTip = oTip;
optValues = oValues;
+ if (optValues->begin() != optValues->end()) setOptionValue(*(optValues->begin()));
+ isBooleanVal = optValues->size() == 2 && (optionValue == "On" || optionValue == "Off");
}
diff --git a/src/modules/filters/teihtmlhref.cpp b/src/modules/filters/teihtmlhref.cpp
index 47bb7b9..43fe584 100644
--- a/src/modules/filters/teihtmlhref.cpp
+++ b/src/modules/filters/teihtmlhref.cpp
@@ -1,10 +1,10 @@
/***************************************************************************
- * teirtf.cpp - TEI to HTMLHREF filter
- * -------------------
- * begin : 2006-07-03
- * copyright : 2006 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * teihtmlhref.cpp - TEI to HTML with hrefs filter
+ *
+ * $Id: teihtmlhref.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2008-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -35,8 +35,8 @@ SWORD_NAMESPACE_START
TEIHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
BiblicalText = false;
if (module) {
- version = module->Name();
- BiblicalText = (!strcmp(module->Type(), "Biblical Texts"));
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
}
}
@@ -57,6 +57,8 @@ TEIHTMLHREF::TEIHTMLHREF() {
addAllowedEscapeString("gt");
setTokenCaseSensitive(true);
+
+ renderNoteNumbers = false;
}
bool TEIHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
@@ -259,11 +261,13 @@ bool TEIHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData
}
if (tag.isEndTag()) {
SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
- buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n</sup></small></a>",
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a>",
URL::encode(footnoteNumber.c_str()).c_str(),
URL::encode(u->version.c_str()).c_str(),
- URL::encode(u->key->getText()).c_str());
+ URL::encode(u->key->getText()).c_str(),
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
u->suspendTextPassThru = false;
}
diff --git a/src/modules/filters/teiplain.cpp b/src/modules/filters/teiplain.cpp
index 90b7c7c..954beb4 100644
--- a/src/modules/filters/teiplain.cpp
+++ b/src/modules/filters/teiplain.cpp
@@ -1,10 +1,10 @@
/***************************************************************************
- * teiplain.cpp - TEI to Plaintext filter
- * -------------------
- * begin : 2006-07-05
- * copyright : 2006 by CrossWire Bible Society
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * teiplain.cpp - TEI to Plaintext filter
+ *
+ * $Id: teiplain.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2006-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/filters/teirtf.cpp b/src/modules/filters/teirtf.cpp
index 8e135b5..979e4a6 100644
--- a/src/modules/filters/teirtf.cpp
+++ b/src/modules/filters/teirtf.cpp
@@ -1,208 +1,208 @@
-/***************************************************************************
- * teirtf.cpp - TEI to RTF filter
- * -------------------
- * begin : 2006-07-03
- * copyright : 2006 by CrossWire Bible Society
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
- * CrossWire Bible Society
- * P. O. Box 2528
- * Tempe, AZ 85280-2528
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- */
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <teirtf.h>
-#include <utilxml.h>
-#include <swmodule.h>
-#include <versekey.h>
-
-SWORD_NAMESPACE_START
-
-
-TEIRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
- BiblicalText = false;
- inOsisRef = false;
- if (module) {
- version = module->Name();
- BiblicalText = (!strcmp(module->Type(), "Biblical Texts"));
- }
-}
-
-
-TEIRTF::TEIRTF() {
- setTokenStart("<");
- setTokenEnd(">");
-
- setEscapeStart("&");
- setEscapeEnd(";");
-
- setEscapeStringCaseSensitive(true);
-
- addEscapeStringSubstitute("amp", "&");
- addEscapeStringSubstitute("apos", "'");
- addEscapeStringSubstitute("lt", "<");
- addEscapeStringSubstitute("gt", ">");
- addEscapeStringSubstitute("quot", "\"");
-
- setTokenCaseSensitive(true);
-}
-
-
-bool TEIRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
- // manually process if it wasn't a simple substitution
- if (!substituteToken(buf, token)) {
- MyUserData *u = (MyUserData *)userData;
- XMLTag tag(token);
-
- // <p> paragraph tag
- if (!strcmp(tag.getName(), "p")) {
- if (!tag.isEndTag()) { // non-empty start tag
- buf += "{\\sb100\\fi200\\par}";
- }
- }
-
- // <hi>
- else if (!strcmp(tag.getName(), "hi") || !strcmp(tag.getName(), "emph")) {
- SWBuf rend = tag.getAttribute("rend");
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (rend == "ital" || rend == "italic")
- buf += "{\\i1 ";
- else if (rend == "bold")
- buf += "{\\b1 ";
- else if (rend == "sup")
- buf += "{\\super ";
-
- }
- else if (tag.isEndTag()) {
- buf += "}";
- }
- }
-
- // <entryFree>
- else if (!strcmp(tag.getName(), "entryFree")) {
- SWBuf n = tag.getAttribute("n");
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (n != "") {
- buf += "{\\b1 ";
- buf += n;
- buf += ". }"; }
- }
- }
-
- // <sense>
- else if (!strcmp(tag.getName(), "sense")) {
- SWBuf n = tag.getAttribute("n");
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (n != "") {
- buf += "{\\sb100\\par\\b1 ";
- buf += n;
- buf += ". }";
- }
- }
- }
-
- // <div>
- else if (!strcmp(tag.getName(), "div")) {
-
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf.append("{\\pard\\sa300}");
- }
- else if (tag.isEndTag()) {
- }
- }
-
- // <pos>, <gen>, <case>, <gram>, <number>, <mood>
- else if (!strcmp(tag.getName(), "pos") || !strcmp(tag.getName(), "gen") || !strcmp(tag.getName(), "case") || !strcmp(tag.getName(), "gram") || !strcmp(tag.getName(), "number") || !strcmp(tag.getName(), "mood")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "{\\i1 ";
- }
- else if (tag.isEndTag()) {
- buf += "}";
- }
- }
-
- // <tr>
- else if (!strcmp(tag.getName(), "tr")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "{\\i1 ";
- }
- else if (tag.isEndTag()) {
- buf += "}";
- }
- }
-
- // <etym>
- else if (!strcmp(tag.getName(), "etym")) {
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- buf += "[";
- }
- else if (tag.isEndTag()) {
- buf += "]";
- }
- }
-
- // <note> tag
- else if (!strcmp(tag.getName(), "note")) {
- if (!tag.isEndTag()) {
- if (!tag.isEmpty()) {
- SWBuf type = tag.getAttribute("type");
-
- SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
- VerseKey *vkey = 0;
- // see if we have a VerseKey * or descendant
- SWTRY {
- vkey = SWDYNAMIC_CAST(VerseKey, u->key);
- }
- SWCATCH ( ... ) { }
- if (vkey) {
- buf.appendFormatted("{\\super <a href=\"\">*%s</a>} ", footnoteNumber.c_str());
- }
- u->suspendTextPassThru = true;
- }
- }
- if (tag.isEndTag()) {
- u->suspendTextPassThru = false;
- }
- }
-
- // <lb/> tag
- else if (!strcmp(tag.getName(), "lb")) {
- buf += "{\\par}";
- userData->supressAdjacentWhitespace = true;
- }
-
- // <ref> tag
- else if (!strcmp(tag.getName(), "ref")) {
- if (!tag.isEndTag() && tag.getAttribute("osisRef")) {
- buf += "{<a href=\"\">";
- u->inOsisRef = true;
- }
- else if (tag.isEndTag() && u->inOsisRef) {
- buf += "</a>}";
- u->inOsisRef = false;
- }
- }
-
-
- else {
- return false; // we still didn't handle token
- }
-
- }
- return true;
-}
-
-
-SWORD_NAMESPACE_END
-
+/***************************************************************************
+ *
+ * teirtf.cpp - TEI to RTF filter
+ *
+ * $Id: teirtf.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2006-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <teirtf.h>
+#include <utilxml.h>
+#include <swmodule.h>
+#include <versekey.h>
+
+SWORD_NAMESPACE_START
+
+
+TEIRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
+ BiblicalText = false;
+ inOsisRef = false;
+ if (module) {
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
+ }
+}
+
+
+TEIRTF::TEIRTF() {
+ setTokenStart("<");
+ setTokenEnd(">");
+
+ setEscapeStart("&");
+ setEscapeEnd(";");
+
+ setEscapeStringCaseSensitive(true);
+
+ addEscapeStringSubstitute("amp", "&");
+ addEscapeStringSubstitute("apos", "'");
+ addEscapeStringSubstitute("lt", "<");
+ addEscapeStringSubstitute("gt", ">");
+ addEscapeStringSubstitute("quot", "\"");
+
+ setTokenCaseSensitive(true);
+}
+
+
+bool TEIRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
+ // manually process if it wasn't a simple substitution
+ if (!substituteToken(buf, token)) {
+ MyUserData *u = (MyUserData *)userData;
+ XMLTag tag(token);
+
+ // <p> paragraph tag
+ if (!strcmp(tag.getName(), "p")) {
+ if (!tag.isEndTag()) { // non-empty start tag
+ buf += "{\\sb100\\fi200\\par}";
+ }
+ }
+
+ // <hi>
+ else if (!strcmp(tag.getName(), "hi") || !strcmp(tag.getName(), "emph")) {
+ SWBuf rend = tag.getAttribute("rend");
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (rend == "ital" || rend == "italic")
+ buf += "{\\i1 ";
+ else if (rend == "bold")
+ buf += "{\\b1 ";
+ else if (rend == "sup")
+ buf += "{\\super ";
+
+ }
+ else if (tag.isEndTag()) {
+ buf += "}";
+ }
+ }
+
+ // <entryFree>
+ else if (!strcmp(tag.getName(), "entryFree")) {
+ SWBuf n = tag.getAttribute("n");
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (n != "") {
+ buf += "{\\b1 ";
+ buf += n;
+ buf += ". }"; }
+ }
+ }
+
+ // <sense>
+ else if (!strcmp(tag.getName(), "sense")) {
+ SWBuf n = tag.getAttribute("n");
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (n != "") {
+ buf += "{\\sb100\\par\\b1 ";
+ buf += n;
+ buf += ". }";
+ }
+ }
+ }
+
+ // <div>
+ else if (!strcmp(tag.getName(), "div")) {
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf.append("{\\pard\\sa300}");
+ }
+ else if (tag.isEndTag()) {
+ }
+ }
+
+ // <pos>, <gen>, <case>, <gram>, <number>, <mood>
+ else if (!strcmp(tag.getName(), "pos") || !strcmp(tag.getName(), "gen") || !strcmp(tag.getName(), "case") || !strcmp(tag.getName(), "gram") || !strcmp(tag.getName(), "number") || !strcmp(tag.getName(), "mood")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "{\\i1 ";
+ }
+ else if (tag.isEndTag()) {
+ buf += "}";
+ }
+ }
+
+ // <tr>
+ else if (!strcmp(tag.getName(), "tr")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "{\\i1 ";
+ }
+ else if (tag.isEndTag()) {
+ buf += "}";
+ }
+ }
+
+ // <etym>
+ else if (!strcmp(tag.getName(), "etym")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "[";
+ }
+ else if (tag.isEndTag()) {
+ buf += "]";
+ }
+ }
+
+ // <note> tag
+ else if (!strcmp(tag.getName(), "note")) {
+ if (!tag.isEndTag()) {
+ if (!tag.isEmpty()) {
+ SWBuf type = tag.getAttribute("type");
+
+ SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ VerseKey *vkey = 0;
+ // see if we have a VerseKey * or descendant
+ SWTRY {
+ vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ }
+ SWCATCH ( ... ) { }
+ if (vkey) {
+ buf.appendFormatted("{\\super <a href=\"\">*%s</a>} ", footnoteNumber.c_str());
+ }
+ u->suspendTextPassThru = true;
+ }
+ }
+ if (tag.isEndTag()) {
+ u->suspendTextPassThru = false;
+ }
+ }
+
+ // <lb/> tag
+ else if (!strcmp(tag.getName(), "lb")) {
+ buf += "{\\par}";
+ userData->supressAdjacentWhitespace = true;
+ }
+
+ // <ref> tag
+ else if (!strcmp(tag.getName(), "ref")) {
+ if (!tag.isEndTag() && tag.getAttribute("osisRef")) {
+ buf += "{<a href=\"\">";
+ u->inOsisRef = true;
+ }
+ else if (tag.isEndTag() && u->inOsisRef) {
+ buf += "</a>}";
+ u->inOsisRef = false;
+ }
+ }
+
+
+ else {
+ return false; // we still didn't handle token
+ }
+
+ }
+ return true;
+}
+
+
+SWORD_NAMESPACE_END
+
diff --git a/src/modules/filters/teixhtml.cpp b/src/modules/filters/teixhtml.cpp
new file mode 100644
index 0000000..6a390a1
--- /dev/null
+++ b/src/modules/filters/teixhtml.cpp
@@ -0,0 +1,290 @@
+/***************************************************************************
+ *
+ * teixhtml.cpp - TEI to XHTML filter
+ *
+ * $Id: teixhtml.cpp 2984 2013-09-20 12:18:45Z scribe $
+ *
+ * Copyright 2012-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <teixhtml.h>
+#include <utilxml.h>
+#include <swmodule.h>
+#include <url.h>
+#include <iostream>
+
+
+SWORD_NAMESPACE_START
+
+
+TEIXHTML::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
+ BiblicalText = false;
+ if (module) {
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
+ }
+}
+
+
+TEIXHTML::TEIXHTML() {
+ setTokenStart("<");
+ setTokenEnd(">");
+
+ setEscapeStart("&");
+ setEscapeEnd(";");
+
+ setEscapeStringCaseSensitive(true);
+
+ addAllowedEscapeString("quot");
+ addAllowedEscapeString("apos");
+ addAllowedEscapeString("amp");
+ addAllowedEscapeString("lt");
+ addAllowedEscapeString("gt");
+
+ setTokenCaseSensitive(true);
+
+ renderNoteNumbers = false;
+}
+
+bool TEIXHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
+ // manually process if it wasn't a simple substitution
+ if (!substituteToken(buf, token)) {
+ MyUserData *u = (MyUserData *)userData;
+ XMLTag tag(token);
+
+ if (!strcmp(tag.getName(), "p")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) { // non-empty start tag
+ buf += "<!P><br />";
+ }
+ else if (tag.isEndTag()) { // end tag
+ buf += "<!/P><br />";
+ //userData->supressAdjacentWhitespace = true;
+ }
+ else { // empty paragraph break marker
+ buf += "<!P><br />";
+ //userData->supressAdjacentWhitespace = true;
+ }
+ }
+
+ // <hi>
+ else if (!strcmp(tag.getName(), "hi")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ SWBuf rend = tag.getAttribute("rend");
+
+ u->lastHi = rend;
+ if (rend == "ital")
+ buf += "<i>";
+ else if (rend == "italic")
+ buf += "<i>";
+ else if (rend == "bold")
+ buf += "<b>";
+ else if (rend == "sup")
+ buf += "<small><sup>";
+ else if (rend == "overline")
+ buf += "<span style=\"text-decoration:overline\">";
+
+ }
+ else if (tag.isEndTag()) {
+ SWBuf rend = u->lastHi;
+ if (rend == "ital")
+ buf += "</i>";
+ else if (rend == "italic")
+ buf += "</i>";
+ else if (rend == "bold")
+ buf += "</b>";
+ else if (rend == "sup")
+ buf += "</sup></small>";
+ else if (rend == "overline")
+ buf += "</span>";
+ }
+ }
+
+ // <entryFree>
+ else if (!strcmp(tag.getName(), "entryFree")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ SWBuf n = tag.getAttribute("n");
+ if (n != "") {
+ buf += "<b>";
+ buf += n;
+ buf += "</b>";
+ }
+ }
+ }
+
+ // <sense>
+ else if (!strcmp(tag.getName(), "sense")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ SWBuf n = tag.getAttribute("n");
+ if (n != "") {
+ buf += "<br /><b>";
+ buf += n;
+ buf += "</b>";
+ }
+ }
+ }
+
+ // <div>
+ else if (!strcmp(tag.getName(), "div")) {
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "<!P>";
+ }
+ else if (tag.isEndTag()) {
+ }
+ }
+
+ // <lb.../>
+ else if (!strcmp(tag.getName(), "lb")) {
+ buf += "<br />";
+ }
+
+ // <pos>, <gen>, <case>, <gram>, <number>, <mood>, <pron>, <def>
+ else if (!strcmp(tag.getName(), "pos") ||
+ !strcmp(tag.getName(), "gen") ||
+ !strcmp(tag.getName(), "case") ||
+ !strcmp(tag.getName(), "gram") ||
+ !strcmp(tag.getName(), "number") ||
+ !strcmp(tag.getName(), "pron") /*||
+ !strcmp(tag.getName(), "def")*/) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "<i>";
+ }
+ else if (tag.isEndTag()) {
+ buf += "</i>";
+ }
+ }
+
+ // <tr>
+ else if (!strcmp(tag.getName(), "tr")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "<i>";
+ }
+ else if (tag.isEndTag()) {
+ buf += "</i>";
+ }
+ }
+
+ // orth
+ else if (!strcmp(tag.getName(), "orth")) {
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ buf += "<b>";
+ }
+ else if (tag.isEndTag()) {
+ buf += "</b>";
+ }
+ }
+
+ // <etym>, <usg>
+ else if (!strcmp(tag.getName(), "etym") ||
+ !strcmp(tag.getName(), "usg")) {
+ // do nothing here
+ }
+ else if (!strcmp(tag.getName(), "ref")) {
+ if (!tag.isEndTag()) {
+ u->suspendTextPassThru = true;
+ SWBuf target;
+ SWBuf work;
+ SWBuf ref;
+
+ int was_osisref = false;
+ if(tag.getAttribute("osisRef"))
+ {
+ target += tag.getAttribute("osisRef");
+ was_osisref=true;
+ }
+ else if(tag.getAttribute("target"))
+ target += tag.getAttribute("target");
+
+ if(target.size())
+ {
+ const char* the_ref = strchr(target, ':');
+
+ if(!the_ref) {
+ // No work
+ ref = target;
+ }
+ else {
+ // Compensate for starting :
+ ref = the_ref + 1;
+
+ int size = target.size() - ref.size() - 1;
+ work.setSize(size);
+ strncpy(work.getRawData(), target, size);
+ }
+
+ if(was_osisref)
+ {
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=%s\">",
+ (ref) ? URL::encode(ref.c_str()).c_str() : "",
+ (work.size()) ? URL::encode(work.c_str()).c_str() : "");
+ }
+ else
+ {
+ // Dictionary link, or something
+ buf.appendFormatted("<a href=\"sword://%s/%s\">",
+ (work.size()) ? URL::encode(work.c_str()).c_str() : u->version.c_str(),
+ (ref) ? URL::encode(ref.c_str()).c_str() : ""
+ );
+ }
+ }
+ else
+ {
+ //std::cout << "TARGET WASN'T\n";
+ }
+
+ }
+ else {
+ buf += u->lastTextNode.c_str();
+ buf += "</a>";
+
+ u->suspendTextPassThru = false;
+ }
+ }
+
+ // <note> tag
+ else if (!strcmp(tag.getName(), "note")) {
+ if (!tag.isEndTag()) {
+ if (!tag.isEmpty()) {
+ u->suspendTextPassThru = true;
+ }
+ }
+ if (tag.isEndTag()) {
+ SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
+
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a>",
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(u->key->getText()).c_str(),
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
+
+ u->suspendTextPassThru = false;
+ }
+ }
+
+ else {
+ return false; // we still didn't handle token
+ }
+
+ }
+ return true;
+}
+
+
+SWORD_NAMESPACE_END
+
diff --git a/src/modules/filters/thmlfootnotes.cpp b/src/modules/filters/thmlfootnotes.cpp
index e75311a..566551f 100644
--- a/src/modules/filters/thmlfootnotes.cpp
+++ b/src/modules/filters/thmlfootnotes.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmlfootnotes - SWFilter descendant to hide or show footnotes
- * in a ThML module.
+ * thmlfootnotes.cpp - SWFilter descendant to hide or show footnotes
+ * in a ThML module
*
+ * $Id: thmlfootnotes.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -30,16 +31,23 @@
#include <versekey.h>
#include <utilxml.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Footnotes";
-const char oTip[] = "Toggles Footnotes On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Footnotes";
+ static const char oTip[] = "Toggles Footnotes On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-ThMLFootnotes::ThMLFootnotes() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ThMLFootnotes::ThMLFootnotes() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -56,7 +64,7 @@ char ThMLFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *m
SWBuf refs = "";
int footnoteNum = 1;
char buf[254];
- SWKey *p = (module) ? module->CreateKey() : (key) ? key->clone() : new VerseKey();
+ SWKey *p = (module) ? module->createKey() : (key) ? key->clone() : new VerseKey();
VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
if (!parser) {
delete p;
@@ -101,7 +109,7 @@ char ThMLFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *m
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();
+ refs = parser->parseVerseList(tagText.c_str(), *parser, true).getRangeText();
module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str();
}
}
diff --git a/src/modules/filters/thmlgbf.cpp b/src/modules/filters/thmlgbf.cpp
index e2e8e1c..e85fdef 100644
--- a/src/modules/filters/thmlgbf.cpp
+++ b/src/modules/filters/thmlgbf.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * thmlgbf.cpp - ThML to GBF filter
- * -------------------
- * begin : 1999-10-28
- * copyright : 2001 by CrossWire Bible Society
*
+ * thmlgbf.cpp - ThML to GBF filter
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: thmlgbf.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/filters/thmlheadings.cpp b/src/modules/filters/thmlheadings.cpp
index e2b7c97..46498d0 100644
--- a/src/modules/filters/thmlheadings.cpp
+++ b/src/modules/filters/thmlheadings.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmlheadings - SWFilter descendant to hide or show headings
- * in a ThML module.
+ * thmlheadings.cpp - SWFilter descendant to hide or show headings
+ * in a ThML module
*
+ * $Id: thmlheadings.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,16 +29,23 @@
#include <swmodule.h>
#include <stdio.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Headings";
-const char oTip[] = "Toggles Headings On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Headings";
+ static const char oTip[] = "Toggles Headings On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-ThMLHeadings::ThMLHeadings() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ThMLHeadings::ThMLHeadings() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/thmlhtml.cpp b/src/modules/filters/thmlhtml.cpp
index 4c66b87..b5f624e 100644
--- a/src/modules/filters/thmlhtml.cpp
+++ b/src/modules/filters/thmlhtml.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * thmlhtml.cpp - ThML to HTML filter
- * -------------------
- * begin : 1999-10-27
- * copyright : 2001 by CrossWire Bible Society
*
+ * thmlhtml.cpp - ThML to HTML filter
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: thmlhtml.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -26,8 +25,10 @@
#include <swmodule.h>
#include <utilxml.h>
+
SWORD_NAMESPACE_START
+
ThMLHTML::ThMLHTML() {
setTokenStart("<");
setTokenEnd(">");
diff --git a/src/modules/filters/thmlhtmlhref.cpp b/src/modules/filters/thmlhtmlhref.cpp
index c0887f1..f72a93e 100644
--- a/src/modules/filters/thmlhtmlhref.cpp
+++ b/src/modules/filters/thmlhtmlhref.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * thmlhtmlhref.cpp - ThML to HTML filter with hrefs
- * -------------------
- * begin : 2001-09-03
- * copyright : 2001 by CrossWire Bible Society
*
+ * thmlhtmlhref.cpp - ThML to HTML filter with hrefs
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: thmlhtmlhref.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -29,13 +28,14 @@
#include <versekey.h>
#include <url.h>
+
SWORD_NAMESPACE_START
ThMLHTMLHREF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
if (module) {
- version = module->Name();
- BiblicalText = (!strcmp(module->Type(), "Biblical Texts"));
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
SecHead = false;
}
}
@@ -160,6 +160,8 @@ ThMLHTMLHREF::ThMLHTMLHREF() {
setTokenCaseSensitive(true);
// addTokenSubstitute("scripture", "<i> ");
addTokenSubstitute("/scripture", "</i> ");
+
+ renderNoteNumbers = false;
}
@@ -206,6 +208,7 @@ bool ThMLHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
if (!tag.isEmpty()) {
SWBuf type = tag.getAttribute("type");
SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
VerseKey *vkey = NULL;
// see if we have a VerseKey * or descendant
SWTRY {
@@ -215,23 +218,25 @@ bool ThMLHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
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=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>",
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
ch,
URL::encode(footnoteNumber.c_str()).c_str(),
URL::encode(u->version.c_str()).c_str(),
URL::encode(vkey->getText()).c_str(),
ch,
- ch);
+ ch,
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
}
else {
char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
- buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c</sup></small></a>",
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
ch,
URL::encode(footnoteNumber.c_str()).c_str(),
URL::encode(u->version.c_str()).c_str(),
URL::encode(u->key->getText()).c_str(),
ch,
- ch);
+ ch,
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
}
u->suspendTextPassThru = true;
}
@@ -265,6 +270,7 @@ bool ThMLHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
}
else {
SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
VerseKey *vkey = NULL;
// see if we have a VerseKey * or descendant
SWTRY {
@@ -274,11 +280,11 @@ bool ThMLHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserDat
if (vkey) {
// leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
//buf.appendFormatted("<a href=\"noteID=%s.x.%s\"><small><sup>*x</sup></small></a> ", vkey->getText(), footnoteNumber.c_str());
- buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=x&value=%s&module=%s&passage=%s\"><small><sup class=\"x\">*x</sup></small></a>",
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=x&value=%s&module=%s&passage=%s\"><small><sup class=\"x\">*x%s</sup></small></a>",
URL::encode(footnoteNumber.c_str()).c_str(),
URL::encode(u->version.c_str()).c_str(),
- URL::encode(vkey->getText()).c_str());
-
+ URL::encode(vkey->getText()).c_str(),
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
}
}
diff --git a/src/modules/filters/thmllemma.cpp b/src/modules/filters/thmllemma.cpp
index 53eec58..acc324f 100644
--- a/src/modules/filters/thmllemma.cpp
+++ b/src/modules/filters/thmllemma.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmllemma - SWFilter descendant to hide or show lemmas
- * in a ThML module.
+ * thmllemma.cpp - SWFilter descendant to hide or show lemmas
+ * in a ThML module
*
+ * $Id: thmllemma.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -23,16 +24,23 @@
#include <stdlib.h>
#include <thmllemma.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Lemmas";
-const char oTip[] = "Toggles Lemmas On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Lemmas";
+ static const char oTip[] = "Toggles Lemmas On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-ThMLLemma::ThMLLemma() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ThMLLemma::ThMLLemma() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/thmlmorph.cpp b/src/modules/filters/thmlmorph.cpp
index d3cf597..3259acc 100644
--- a/src/modules/filters/thmlmorph.cpp
+++ b/src/modules/filters/thmlmorph.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmlmorph - SWFilter descendant to hide or show morph tags
- * in a ThML module.
+ * thmlmorph.cpp - SWFilter descendant to hide or show morph tags
+ * in a ThML module
*
+ * $Id: thmlmorph.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,14 +26,20 @@
SWORD_NAMESPACE_START
-const char oName[] = "Morphological Tags";
-const char oTip[] = "Toggles Morphological Tags On and Off if they exist";
+namespace {
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const char oName[] = "Morphological Tags";
+ static const char oTip[] = "Toggles Morphological Tags On and Off if they exist";
-ThMLMorph::ThMLMorph() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
+
+
+ThMLMorph::ThMLMorph() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/thmlosis.cpp b/src/modules/filters/thmlosis.cpp
index 25fdf23..3acd959 100644
--- a/src/modules/filters/thmlosis.cpp
+++ b/src/modules/filters/thmlosis.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * thmlstrongs - SWFilter descendant to hide or show strongs number
- * in a ThML module.
+ * thmlosis.cpp - filter to convert ThML to OSIS
*
+ * $Id: thmlosis.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -540,7 +540,7 @@ char ThMLOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module
VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
if (vkey) {
SWBuf ref = "";
- if (vkey->Verse()) {
+ if (vkey->getVerse()) {
ref.appendFormatted("\t\t<verse osisID=\"%s\">", vkey->getOSISRef());
}
@@ -548,24 +548,24 @@ char ThMLOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module
text = ref + text;
- if (vkey->Verse()) {
+ if (vkey->getVerse()) {
VerseKey *tmp = (VerseKey *)vkey->clone();
*tmp = *vkey;
- tmp->AutoNormalize(0);
- tmp->Headings(1);
+ tmp->setAutoNormalize(false);
+ tmp->setIntros(true);
text += "</verse>";
*tmp = MAXVERSE;
if (*vkey == *tmp) {
- tmp->Verse(0);
+ tmp->setVerse(0);
// sprintf(ref, "\t</div>");
// pushString(&to, ref);
*tmp = MAXCHAPTER;
*tmp = MAXVERSE;
if (*vkey == *tmp) {
- tmp->Chapter(0);
- tmp->Verse(0);
+ tmp->setChapter(0);
+ tmp->setVerse(0);
// sprintf(ref, "\t</div>");
// pushString(&to, ref);
/*
@@ -578,7 +578,7 @@ char ThMLOSIS::processText(SWBuf &text, const SWKey *key, const SWModule *module
}
delete tmp;
}
-// else if (vkey->Chapter()) {
+// else if (vkey->getChapter()) {
// sprintf(ref, "\t<div type=\"chapter\" osisID=\"%s\">", vkey->getOSISRef());
// }
// else sprintf(ref, "\t<div type=\"book\" osisID=\"%s\">", vkey->getOSISRef());
diff --git a/src/modules/filters/thmlplain.cpp b/src/modules/filters/thmlplain.cpp
index 8c9358f..b9b9839 100644
--- a/src/modules/filters/thmlplain.cpp
+++ b/src/modules/filters/thmlplain.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmlplain - SWFilter descendant to strip out all ThML tags or convert to
- * ASCII rendered symbols.
+ * thmlplain.cpp - SWFilter descendant to strip out all ThML tags or
+ * convert to ASCII rendered symbols
*
+ * $Id: thmlplain.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/filters/thmlrtf.cpp b/src/modules/filters/thmlrtf.cpp
index fdb41df..dc50ae9 100644
--- a/src/modules/filters/thmlrtf.cpp
+++ b/src/modules/filters/thmlrtf.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * thmlrtf.cpp - ThML to RTF filter
- * -------------------
- * begin : 1999-10-27
- * copyright : 2001 by CrossWire Bible Society
*
+ * thmlrtf.cpp - ThML to RTF filter
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: thmlrtf.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -215,8 +214,8 @@ ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : Basi
this->SecHead = false;
XMLTag startTag = "";
if (module) {
- version = module->Name();
- BiblicalText = (!strcmp(module->Type(), "Biblical Texts"));
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
}
}
@@ -263,7 +262,7 @@ bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *us
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("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, vkey->Verse(), footnoteNumber.c_str());
+ buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, vkey->getVerse(), footnoteNumber.c_str());
}
u->suspendTextPassThru = true;
}
@@ -301,7 +300,7 @@ bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *us
SWCATCH ( ... ) {}
if (vkey) {
// leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
- buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", vkey->Verse(), footnoteNumber.c_str());
+ buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", vkey->getVerse(), footnoteNumber.c_str());
}
}
diff --git a/src/modules/filters/thmlscripref.cpp b/src/modules/filters/thmlscripref.cpp
index e46d679..1ea4a40 100644
--- a/src/modules/filters/thmlscripref.cpp
+++ b/src/modules/filters/thmlscripref.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmlscripref - SWFilter descendant to hide or show scripture
- * referebces in a ThML module.
+ * thmlscripref.cpp - SWFilter descendant to hide or show scripture
+ * referebces in a ThML module
*
+ * $Id: thmlscripref.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,16 +28,23 @@
#include <versekey.h>
#include <swmodule.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Cross-references";
-const char oTip[] = "Toggles Scripture Cross-references On and Off if they exist";
+namespace {
+
+ static const char oName[] = "Cross-references";
+ static const char oTip[] = "Toggles Scripture Cross-references On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-ThMLScripref::ThMLScripref() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("On");
+ThMLScripref::ThMLScripref() : SWOptionFilter(oName, oTip, oValues()) {
}
@@ -53,7 +61,7 @@ char ThMLScripref::processText(SWBuf &text, const SWKey *key, const SWModule *mo
SWBuf refs = "";
int footnoteNum = 1;
char buf[254];
- SWKey *p = (module) ? module->CreateKey() : (key) ? key->clone() : new VerseKey();
+ SWKey *p = (module) ? module->createKey() : (key) ? key->clone() : new VerseKey();
VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
if (!parser) {
delete p;
@@ -98,8 +106,8 @@ char ThMLScripref::processText(SWBuf &text, const SWKey *key, const SWModule *mo
startTag.setAttribute("swordFootnote", buf);
SWBuf passage = startTag.getAttribute("passage");
if (passage.length())
- refs = parser->ParseVerseList(passage.c_str(), *parser, true).getRangeText();
- else refs = parser->ParseVerseList(tagText.c_str(), *parser, true).getRangeText();
+ refs = parser->parseVerseList(passage.c_str(), *parser, true).getRangeText();
+ else refs = parser->parseVerseList(tagText.c_str(), *parser, true).getRangeText();
module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str();
}
hide = false;
diff --git a/src/modules/filters/thmlstrongs.cpp b/src/modules/filters/thmlstrongs.cpp
index 457e28b..09658a9 100644
--- a/src/modules/filters/thmlstrongs.cpp
+++ b/src/modules/filters/thmlstrongs.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmlstrongs - SWFilter descendant to hide or show strongs number
- * in a ThML module.
+ * thmlstrongs.cpp - SWFilter descendant to hide or show Strong's number
+ * in a ThML module
*
+ * $Id: thmlstrongs.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,16 +28,23 @@
#include <utilstr.h>
#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";
+namespace {
+
+ static const char oName[] = "Strong's Numbers";
+ static const char oTip[] = "Toggles Strong's Numbers On and Off if they exist";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
-ThMLStrongs::ThMLStrongs() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ThMLStrongs::ThMLStrongs() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/thmlvariants.cpp b/src/modules/filters/thmlvariants.cpp
index 4f28dbe..1a57971 100644
--- a/src/modules/filters/thmlvariants.cpp
+++ b/src/modules/filters/thmlvariants.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * thmlvariants - SWFilter descendant to hide or show textual variants
- * in a ThML module.
+ * thmlvariants.cpp - SWFilter descendant to hide or show textual variants
+ * in a ThML module
*
+ * $Id: thmlvariants.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,50 +25,39 @@
#include <thmlvariants.h>
#include <utilstr.h>
-SWORD_NAMESPACE_START
-const char ThMLVariants::primary[] = "Primary Reading";
-const char ThMLVariants::secondary[] = "Secondary Reading";
-const char ThMLVariants::all[] = "All Readings";
+SWORD_NAMESPACE_START
-const char ThMLVariants::optName[] = "Textual Variants";
-const char ThMLVariants::optTip[] = "Switch between Textual Variants modes";
+namespace {
+ static const char oName[] = "Textual Variants";
+ static const char oTip[] = "Switch between Textual Variants modes";
+ static const char *choices[4] = { "Primary Reading", "Secondary Reading", "All Readings", "" };
-ThMLVariants::ThMLVariants() {
- option = false;
- options.push_back(primary);
- options.push_back(secondary);
- options.push_back(all);
+ static const StringList *oValues() {
+ static const StringList oVals(&choices[0], &choices[3]);
+ return &oVals;
+ }
}
-ThMLVariants::~ThMLVariants() {
+ThMLVariants::ThMLVariants() : SWOptionFilter(oName, oTip, oValues()) {
}
-void ThMLVariants::setOptionValue(const char *ival)
-{
- if (!stricmp(ival, primary)) option = 0;
- else if (!stricmp(ival, secondary)) option = 1;
- else option = 2;
-}
-const char *ThMLVariants::getOptionValue()
-{
- if (option == 0) {
- return primary;
- }
- else if (option == 1) {
- return secondary;
- }
- else {
- return all;
- }
+ThMLVariants::~ThMLVariants() {
}
+
char ThMLVariants::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
- if ( option == 0 || option == 1) { //we want primary or variant only
+
+ int option = 0;
+ if (optionValue == choices[0]) option = 0;
+ else if (optionValue == choices[1]) option = 1;
+ else option = 2;
+
+ if (option == 0 || option == 1) { //we want primary or variant only
bool intoken = false;
bool hide = false;
bool invar = false;
@@ -127,7 +117,4 @@ char ThMLVariants::processText(SWBuf &text, const SWKey *key, const SWModule *mo
-
-
-
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/thmlwebif.cpp b/src/modules/filters/thmlwebif.cpp
index 0192703..29d9ef5 100644
--- a/src/modules/filters/thmlwebif.cpp
+++ b/src/modules/filters/thmlwebif.cpp
@@ -1,11 +1,10 @@
/***************************************************************************
- * ThMLWEBIF.cpp - ThML to HTML filter with hrefs
- * -------------------
- * begin : 2001-09-03
- * copyright : 2001 by CrossWire Bible Society
*
+ * thmlwebif.cpp - ThML to HTML filter with hrefs
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: thmlwebif.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -30,10 +29,11 @@
SWORD_NAMESPACE_START
+
ThMLWEBIF::ThMLWEBIF() : baseURL(""), passageStudyURL(baseURL + "passagestudy.jsp") {
- //all's done in ThMLHTMLHREF
}
+
bool ThMLWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution
@@ -100,7 +100,7 @@ bool ThMLWEBIF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *
}
}
else {
- return ThMLHTMLHREF::handleToken(buf,token,userData);
+ return ThMLXHTML::handleToken(buf, token, userData);
}
}
return true;
diff --git a/src/modules/filters/thmlwordjs.cpp b/src/modules/filters/thmlwordjs.cpp
index 12fbeb1..7d80a00 100644
--- a/src/modules/filters/thmlwordjs.cpp
+++ b/src/modules/filters/thmlwordjs.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * thmlstrongs - SWFilter descendant to hide or show strongs number
- * in a ThML module.
+ * thmlwordjs.cpp - SWFilter descendant to ???
*
+ * $Id: thmlwordjs.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2005-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -29,17 +29,23 @@
#include <utilstr.h>
#include <versekey.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Word Javascript";
-const char oTip[] = "Toggles Word Javascript data";
+namespace {
+
+ static const char oName[] = "Word Javascript";
+ static const char oTip[] = "Toggles Word Javascript data";
-const SWBuf choices[3] = {"Off", "On", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-ThMLWordJS::ThMLWordJS() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+ThMLWordJS::ThMLWordJS() : SWOptionFilter(oName, oTip, oValues()) {
defaultGreekLex = 0;
defaultHebLex = 0;
@@ -58,7 +64,6 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
char token[2112]; // cheese. Fix.
int tokpos = 0;
bool intoken = false;
- bool lastspace = false;
int word = 1;
char val[128];
char *valto;
@@ -69,7 +74,7 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
bool newText = false;
bool needWordOut = false;
AttributeValue *wordAttrs = 0;
- SWBuf modName = (module)?module->Name():"";
+ SWBuf modName = (module)?module->getName():"";
SWBuf wordSrcPrefix = modName;
const SWBuf orig = text;
@@ -160,7 +165,7 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
gh = isdigit(strong[0]) ? 0:strong[0];
if (!gh) {
if (vkey) {
- gh = vkey->Testament() ? 'H' : 'G';
+ gh = vkey->getTestament() ? 'H' : 'G';
}
}
else strong << 1;
@@ -179,7 +184,7 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
if (sLex) {
// we can pass the real lex name in, but we have some
// aliases in the javascript to optimize bandwidth
- lexName = sLex->Name();
+ lexName = sLex->getName();
if (lexName == "StrongsGreek")
lexName = "G";
if (lexName == "StrongsHebrew")
@@ -188,7 +193,7 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
SWBuf wordID;
if (vkey) {
// optimize for bandwidth and use only the verse as the unique entry id
- wordID.appendFormatted("%d", vkey->Verse());
+ wordID.appendFormatted("%d", vkey->getVerse());
}
else {
wordID = key->getText();
@@ -206,10 +211,11 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
+ if (!sMorph) sMorph = 0; // avoid unused warnings for now
/*
if (sMorph) {
SWBuf popMorph = "<a onclick=\"";
- popMorph.appendFormatted("p(\'%s\',\'%s\','%s','');\" >%s</a>", sMorph->Name(), morph.c_str(), wordID.c_str(), morph.c_str());
+ popMorph.appendFormatted("p(\'%s\',\'%s\','%s','');\" >%s</a>", sMorph->getName(), morph.c_str(), wordID.c_str(), morph.c_str());
morph = popMorph;
}
*/
@@ -237,7 +243,6 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
}
else {
text += *from;
- lastspace = (*from == ' ');
}
}
@@ -255,7 +260,7 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
gh = isdigit(strong[0]) ? 0:strong[0];
if (!gh) {
if (vkey) {
- gh = vkey->Testament() ? 'H' : 'G';
+ gh = vkey->getTestament() ? 'H' : 'G';
}
}
else strong << 1;
@@ -271,7 +276,7 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
if (sLex) {
// we can pass the real lex name in, but we have some
// aliases in the javascript to optimize bandwidth
- lexName = sLex->Name();
+ lexName = sLex->getName();
if (lexName == "StrongsGreek")
lexName = "G";
if (lexName == "StrongsHebrew")
@@ -280,7 +285,7 @@ char ThMLWordJS::processText(SWBuf &text, const SWKey *key, const SWModule *modu
SWBuf wordID;
if (vkey) {
// optimize for bandwidth and use only the verse as the unique entry id
- wordID.appendFormatted("%d", vkey->Verse());
+ wordID.appendFormatted("%d", vkey->getVerse());
}
else {
wordID = key->getText();
diff --git a/src/modules/filters/thmlxhtml.cpp b/src/modules/filters/thmlxhtml.cpp
new file mode 100644
index 0000000..b17eb50
--- /dev/null
+++ b/src/modules/filters/thmlxhtml.cpp
@@ -0,0 +1,378 @@
+/******************************************************************************
+ *
+ * thmlxhtml.cpp - ThML to classed XHTML
+ *
+ * $Id: thmlxhtml.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2011-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * CrossWire Bible Society
+ * P. O. Box 2528
+ * Tempe, AZ 85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <stdlib.h>
+#include <thmlxhtml.h>
+#include <swmodule.h>
+#include <utilxml.h>
+#include <utilstr.h>
+#include <versekey.h>
+#include <url.h>
+
+SWORD_NAMESPACE_START
+
+
+const char *ThMLXHTML::getHeader() const {
+ return "\
+ ";
+}
+
+
+ThMLXHTML::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) {
+ if (module) {
+ version = module->getName();
+ BiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
+ SecHead = false;
+ }
+}
+
+
+ThMLXHTML::ThMLXHTML() {
+ setTokenStart("<");
+ setTokenEnd(">");
+
+ setEscapeStart("&");
+ setEscapeEnd(";");
+
+ setEscapeStringCaseSensitive(true);
+ setPassThruNumericEscapeString(true);
+
+ addAllowedEscapeString("quot");
+ addAllowedEscapeString("amp");
+ addAllowedEscapeString("lt");
+ addAllowedEscapeString("gt");
+
+ addAllowedEscapeString("nbsp");
+ addAllowedEscapeString("brvbar"); // "Š"
+ addAllowedEscapeString("sect"); // "§"
+ addAllowedEscapeString("copy"); // "©"
+ addAllowedEscapeString("laquo"); // "«"
+ addAllowedEscapeString("reg"); // "®"
+ addAllowedEscapeString("acute"); // "Ž"
+ addAllowedEscapeString("para"); // "¶"
+ addAllowedEscapeString("raquo"); // "»"
+
+ addAllowedEscapeString("Aacute"); // "Á"
+ addAllowedEscapeString("Agrave"); // "À"
+ addAllowedEscapeString("Acirc"); // "Â"
+ addAllowedEscapeString("Auml"); // "Ä"
+ addAllowedEscapeString("Atilde"); // "Ã"
+ addAllowedEscapeString("Aring"); // "Å"
+ addAllowedEscapeString("aacute"); // "á"
+ addAllowedEscapeString("agrave"); // "à"
+ addAllowedEscapeString("acirc"); // "â"
+ addAllowedEscapeString("auml"); // "ä"
+ addAllowedEscapeString("atilde"); // "ã"
+ addAllowedEscapeString("aring"); // "å"
+ addAllowedEscapeString("Eacute"); // "É"
+ addAllowedEscapeString("Egrave"); // "È"
+ addAllowedEscapeString("Ecirc"); // "Ê"
+ addAllowedEscapeString("Euml"); // "Ë"
+ addAllowedEscapeString("eacute"); // "é"
+ addAllowedEscapeString("egrave"); // "è"
+ addAllowedEscapeString("ecirc"); // "ê"
+ addAllowedEscapeString("euml"); // "ë"
+ addAllowedEscapeString("Iacute"); // "Í"
+ addAllowedEscapeString("Igrave"); // "Ì"
+ addAllowedEscapeString("Icirc"); // "Î"
+ addAllowedEscapeString("Iuml"); // "Ï"
+ addAllowedEscapeString("iacute"); // "í"
+ addAllowedEscapeString("igrave"); // "ì"
+ addAllowedEscapeString("icirc"); // "î"
+ addAllowedEscapeString("iuml"); // "ï"
+ addAllowedEscapeString("Oacute"); // "Ó"
+ addAllowedEscapeString("Ograve"); // "Ò"
+ addAllowedEscapeString("Ocirc"); // "Ô"
+ addAllowedEscapeString("Ouml"); // "Ö"
+ addAllowedEscapeString("Otilde"); // "Õ"
+ addAllowedEscapeString("oacute"); // "ó"
+ addAllowedEscapeString("ograve"); // "ò"
+ addAllowedEscapeString("ocirc"); // "ô"
+ addAllowedEscapeString("ouml"); // "ö"
+ addAllowedEscapeString("otilde"); // "õ"
+ addAllowedEscapeString("Uacute"); // "Ú"
+ addAllowedEscapeString("Ugrave"); // "Ù"
+ addAllowedEscapeString("Ucirc"); // "Û"
+ addAllowedEscapeString("Uuml"); // "Ü"
+ addAllowedEscapeString("uacute"); // "ú"
+ addAllowedEscapeString("ugrave"); // "ù"
+ addAllowedEscapeString("ucirc"); // "û"
+ addAllowedEscapeString("uuml"); // "ü"
+ addAllowedEscapeString("Yacute"); // "Ý"
+ addAllowedEscapeString("yacute"); // "ý"
+ addAllowedEscapeString("yuml"); // "ÿ"
+
+ addAllowedEscapeString("deg"); // "°"
+ addAllowedEscapeString("plusmn"); // "±"
+ addAllowedEscapeString("sup2"); // "²"
+ addAllowedEscapeString("sup3"); // "³"
+ addAllowedEscapeString("sup1"); // "¹"
+ addAllowedEscapeString("nbsp"); // "º"
+ addAllowedEscapeString("pound"); // "£"
+ addAllowedEscapeString("cent"); // "¢"
+ addAllowedEscapeString("frac14"); // "Œ"
+ addAllowedEscapeString("frac12"); // "œ"
+ addAllowedEscapeString("frac34"); // "Ÿ"
+ addAllowedEscapeString("iquest"); // "¿"
+ addAllowedEscapeString("iexcl"); // "¡"
+ addAllowedEscapeString("ETH"); // "Ð"
+ addAllowedEscapeString("eth"); // "ð"
+ addAllowedEscapeString("THORN"); // "Þ"
+ addAllowedEscapeString("thorn"); // "þ"
+ addAllowedEscapeString("AElig"); // "Æ"
+ addAllowedEscapeString("aelig"); // "æ"
+ addAllowedEscapeString("Oslash"); // "Ø"
+ addAllowedEscapeString("curren"); // "€"
+ addAllowedEscapeString("Ccedil"); // "Ç"
+ addAllowedEscapeString("ccedil"); // "ç"
+ addAllowedEscapeString("szlig"); // "ß"
+ addAllowedEscapeString("Ntilde"); // "Ñ"
+ addAllowedEscapeString("ntilde"); // "ñ"
+ addAllowedEscapeString("yen"); // "¥"
+ addAllowedEscapeString("not"); // "¬"
+ addAllowedEscapeString("ordf"); // "ª"
+ addAllowedEscapeString("uml"); // "š"
+ addAllowedEscapeString("shy"); // "­"
+ addAllowedEscapeString("macr"); // "¯"
+
+ addAllowedEscapeString("micro"); // "µ"
+ addAllowedEscapeString("middot"); // "·"
+ addAllowedEscapeString("cedil"); // "ž"
+ addAllowedEscapeString("ordm"); // "º"
+ addAllowedEscapeString("times"); // "×"
+ addAllowedEscapeString("divide"); // "÷"
+ addAllowedEscapeString("oslash"); // "ø"
+
+ setTokenCaseSensitive(true);
+// addTokenSubstitute("scripture", "<i> ");
+ addTokenSubstitute("/scripture", "</i> ");
+
+ renderNoteNumbers = false;
+}
+
+
+bool ThMLXHTML::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
+ if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution
+ MyUserData *u = (MyUserData *)userData;
+
+ XMLTag tag(token);
+ if ((!tag.isEndTag()) && (!tag.isEmpty()))
+ u->startTag = tag;
+
+ if (tag.getName() && !strcmp(tag.getName(), "sync")) {
+ SWBuf value = tag.getAttribute("value");
+ if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt;
+ if(value.length())
+ buf.appendFormatted("<small><em class=\"morph\">(<a href=\"passagestudy.jsp?action=showMorph&type=Greek&value=%s\" class=\"morph\">%s</a>)</em></small>",
+ URL::encode(value.c_str()).c_str(),
+ value.c_str());
+ }
+ else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "lemma")) { //&gt;
+ if(value.length())
+ // empty "type=" is deliberate.
+ buf.appendFormatted("<small><em class=\"strongs\">&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=&value=%s\" class=\"strongs\">%s</a>&gt;</em></small>",
+ URL::encode(value.c_str()).c_str(),
+ value.c_str());
+ }
+ else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) {
+ char ch = *value;
+ value<<1;
+ buf.appendFormatted("<small><em class=\"strongs\">&lt;<a href=\"passagestudy.jsp?action=showStrongs&type=%s&value=%s\" class=\"strongs\">",
+ ((ch == 'H') ? "Hebrew" : "Greek"),
+ URL::encode(value.c_str()).c_str());
+ buf += (value.length()) ? value.c_str() : "";
+ buf += "</a>&gt;</em></small>";
+ }
+ else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) {
+ buf += (tag.isEndTag() ? "</b>" : "<b>");
+ }
+
+ }
+ // <note> tag
+ else if (!strcmp(tag.getName(), "note")) {
+ if (!tag.isEndTag()) {
+ if (!tag.isEmpty()) {
+ SWBuf type = tag.getAttribute("type");
+ SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
+ VerseKey *vkey = NULL;
+ // see if we have a VerseKey * or descendant
+ SWTRY {
+ vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ }
+ SWCATCH ( ... ) { }
+ 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=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
+ ch,
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(vkey->getText()).c_str(),
+ ch,
+ ch,
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
+ }
+ else {
+ char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=%c&value=%s&module=%s&passage=%s\"><small><sup class=\"%c\">*%c%s</sup></small></a>",
+ ch,
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(u->key->getText()).c_str(),
+ ch,
+ ch,
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
+ }
+ u->suspendTextPassThru = true;
+ }
+ }
+ if (tag.isEndTag()) {
+ u->suspendTextPassThru = false;
+ }
+ }
+ else if (!strcmp(tag.getName(), "scripture")) {
+ buf += (tag.isEndTag() ? "</i>" : "<i>");
+ }
+ // <scripRef> tag
+ else if (!strcmp(tag.getName(), "scripRef")) {
+ if (!tag.isEndTag()) {
+ if (!tag.isEmpty()) {
+ u->suspendTextPassThru = true;
+ }
+ }
+ if (tag.isEndTag()) { // </scripRef>
+ if (!u->BiblicalText) {
+ SWBuf refList = u->startTag.getAttribute("passage");
+ if (!refList.length())
+ refList = u->lastTextNode;
+ SWBuf version = tag.getAttribute("version");
+
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=%s\">",
+ (refList.length()) ? URL::encode(refList.c_str()).c_str() : "",
+ (version.length()) ? URL::encode(version.c_str()).c_str() : "");
+ buf += u->lastTextNode.c_str();
+ buf += "</a>";
+ }
+ else {
+ SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote");
+ SWBuf noteName = tag.getAttribute("n");
+ VerseKey *vkey = NULL;
+ // see if we have a VerseKey * or descendant
+ SWTRY {
+ vkey = SWDYNAMIC_CAST(VerseKey, u->key);
+ }
+ SWCATCH ( ... ) {}
+ if (vkey) {
+ // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
+ //buf.appendFormatted("<a href=\"noteID=%s.x.%s\"><small><sup>*x</sup></small></a> ", vkey->getText(), footnoteNumber.c_str());
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=x&value=%s&module=%s&passage=%s\"><small><sup class=\"x\">*x%s</sup></small></a>",
+ URL::encode(footnoteNumber.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str(),
+ URL::encode(vkey->getText()).c_str(),
+ (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
+ }
+ }
+
+ // let's let text resume to output again
+ u->suspendTextPassThru = false;
+ }
+ }
+ else if (tag.getName() && !strcmp(tag.getName(), "div")) {
+ if (tag.isEndTag() && u->SecHead) {
+ buf += "</i></b><br />";
+ u->SecHead = false;
+ }
+ else if (tag.getAttribute("class")) {
+ if (!stricmp(tag.getAttribute("class"), "sechead")) {
+ u->SecHead = true;
+ buf += "<br /><b><i>";
+ }
+ else if (!stricmp(tag.getAttribute("class"), "title")) {
+ u->SecHead = true;
+ buf += "<br /><b><i>";
+ }
+ else {
+ buf += tag;
+ }
+ }
+ else {
+ buf += tag;
+ }
+ }
+ else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) {
+ const char *src = strstr(token, "src");
+ if (!src) // assert we have a src attribute
+ return false;
+
+ const char *c, *d;
+ if (((c = strchr(src+3, '"')) == NULL) ||
+ ((d = strchr( ++c , '"')) == NULL)) // identify endpoints.
+ return false; // abandon hope.
+
+ SWBuf imagename = "file:";
+ if (*c == '/') // as below, inside for loop.
+ imagename += userData->module->getConfigEntry("AbsoluteDataPath");
+ while (c != d) // move bits into the name.
+ imagename += *(c++);
+
+ // images become clickable, if the UI supports showImage.
+ buf.appendFormatted("<a href=\"passagestudy.jsp?action=showImage&value=%s&module=%s\"><",
+ URL::encode(imagename.c_str()).c_str(),
+ URL::encode(u->version.c_str()).c_str());
+
+ for (c = token; *c; c++) {
+ if ((*c == '/') && (*(c+1) == '\0'))
+ continue;
+ if (c == src) {
+ for (;((*c) && (*c != '"')); c++)
+ buf += *c;
+
+ if (!*c) { c--; continue; }
+
+ buf += '"';
+ if (*(c+1) == '/') {
+ buf += "file:";
+ buf += userData->module->getConfigEntry("AbsoluteDataPath");
+ if (buf[buf.length()-2] == '/')
+ c++; // skip '/'
+ }
+ continue;
+ }
+ buf += *c;
+ }
+ buf += " border=0 /></a>";
+ }
+ else {
+ buf += '<';
+ /*for (const char *tok = token; *tok; tok++)
+ buf += *tok;*/
+ buf += token;
+ buf += '>';
+ //return false; // we still didn't handle token
+ }
+ }
+ return true;
+}
+
+
+SWORD_NAMESPACE_END
diff --git a/src/modules/filters/unicodertf.cpp b/src/modules/filters/unicodertf.cpp
index 768aecc..997597b 100644
--- a/src/modules/filters/unicodertf.cpp
+++ b/src/modules/filters/unicodertf.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * unicodertf - SWFilter descendant to convert a double byte unicode file
- * to RTF tags
+ * unicodertf.cpp - SWFilter descendant to convert UTF-8 to RTF tags
*
+ * $Id: unicodertf.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/filters/utf16utf8.cpp b/src/modules/filters/utf16utf8.cpp
index a488e18..6356284 100644
--- a/src/modules/filters/utf16utf8.cpp
+++ b/src/modules/filters/utf16utf8.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * UTF16UTF8 - SWFilter descendant to convert UTF-16 to UTF-8
+ * utf16utf8.cpp - SWFilter descendant to convert UTF-16 to UTF-8
*
+ * $Id: utf16utf8.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,8 +27,10 @@
#include <utf16utf8.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
UTF16UTF8::UTF16UTF8() {
}
@@ -102,6 +104,4 @@ char UTF16UTF8::processText(SWBuf &text, const SWKey *key, const SWModule *modul
}
-
-
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/utf8arabicpoints.cpp b/src/modules/filters/utf8arabicpoints.cpp
index bd3169b..42bfaa5 100644
--- a/src/modules/filters/utf8arabicpoints.cpp
+++ b/src/modules/filters/utf8arabicpoints.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * UTF8ArabicPoints - SWFilter descendant to remove UTF-8 Arabic vowel points
+ * utf8arabicpoints.cpp - SWFilter descendant to remove UTF-8
+ * Arabic vowel points
*
- * $Id: utf8arabicpoints.h 1688 2008-11-30 04:42:26Z refdoc $
+ * $Id: utf8arabicpoints.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2009-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,36 +26,163 @@
#include <stdio.h>
#include <utf8arabicpoints.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Arabic Vowel Points";
-const char oTip[] = "Toggles Arabic Vowel Points";
+namespace {
+
+ static const char oName[] = "Arabic Vowel Points";
+ static const char oTip[] = "Toggles Arabic Vowel Points";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+
+
+ static char *nextMark(const char* from, int* mark_size) {
+ // Arabic vowel points currently targeted for elimination:
+ // Table entries excerpted from
+ // http://www.utf8-chartable.de/unicode-utf8-table.pl.
+ // Code UTF-8 Description
+ // point
+ // ----- --------- -----------
+ // U+064B d9 8b ARABIC FATHATAN
+ // U+064C d9 8c ARABIC DAMMATAN
+ // U+064D d9 8d ARABIC KASRATAN
+ // U+064E d9 8e ARABIC FATHA
+ // U+064F d9 8f ARABIC DAMMA
+ // U+0650 d9 90 ARABIC KASRA
+ // U+0651 d9 91 ARABIC SHADDA
+ // U+0652 d9 92 ARABIC SUKUN
+ // U+0653 d9 93 ARABIC MADDAH ABOVE
+ // U+0654 d9 94 ARABIC HAMZA ABOVE
+ // U+0655 d9 95 ARABIC HAMZA BELOW
+ //
+ // U+FC5E ef b1 9e ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM
+ // U+FC5F ef b1 9f ARABIC LIGATURE SHADDA WITH KASRATAN ISOLATED FORM
+ // U+FC60 ef b1 a0 ARABIC LIGATURE SHADDA WITH FATHA ISOLATED FORM
+ // U+FC61 ef b1 a1 ARABIC LIGATURE SHADDA WITH DAMMA ISOLATED FORM
+ // U+FC62 ef b1 a2 ARABIC LIGATURE SHADDA WITH KASRA ISOLATED FORM
+ // U+FC63 ef b1 a3 ARABIC LIGATURE SHADDA WITH SUPERSCRIPT ALEF ISOLATED FORM
+ //
+ // U+FE70 ef b9 b0 ARABIC FATHATAN ISOLATED FORM
+ // U+FE71 ef b9 b1 ARABIC TATWEEL WITH FATHATAN ABOVE
+ // U+FE72 ef b9 b2 ARABIC DAMMATAN ISOLATED FORM
+ // U+FE73 ef b9 b3 ARABIC TAIL FRAGMENT
+ // U+FE74 ef b9 b4 ARABIC KASRATAN ISOLATED FORM
+ // U+FE75 ef b9 b5 ???
+ // U+FE76 ef b9 b6 ARABIC FATHA ISOLATED FORM
+ // U+FE77 ef b9 b7 ARABIC FATHA MEDIAL FORM
+ // U+FE78 ef b9 b8 ARABIC DAMMA ISOLATED FORM
+ // U+FE79 ef b9 b9 ARABIC DAMMA MEDIAL FORM
+ // U+FE7A ef b9 ba ARABIC KASRA ISOLATED FORM
+ // U+FE7B ef b9 bb ARABIC KASRA MEDIAL FORM
+ // U+FE7C ef b9 bc ARABIC SHADDA ISOLATED FORM
+ // U+FE7D ef b9 bd ARABIC SHADDA MEDIAL FORM
+ // U+FE7E ef b9 be ARABIC SUKUN ISOLATED FORM
+ // U+FE7F ef b9 bf ARABIC SUKUN MEDIAL FORM
+
+ unsigned char* byte = (unsigned char*) from;
+ for (; *byte; ++byte) {
+ if (byte[0] == 0xD9) {
+ if (byte[1] >= 0x8B && byte[1] <= 0x95) {
+ *mark_size = 2;
+ break;
+ }
+ continue;
+ }
+ if (byte[0] == 0xEF) {
+ if (byte[1] == 0xB1) {
+ if (byte[2] >= 0x9E && byte[2] <= 0xA3) {
+ *mark_size = 3;
+ break;
+ }
+ continue;
+ }
+ if (byte[1] == 0xB9) {
+ if (byte[2] >= 0xB0 && byte[2] <= 0xBF) {
+ *mark_size = 3;
+ break;
+ }
+ continue;
+ }
+ }
+ }
+ return (char*)byte;
+ }
+}
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
-UTF8ArabicPoints::UTF8ArabicPoints() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("On");
+UTF8ArabicPoints::UTF8ArabicPoints() : SWOptionFilter(oName, oTip, oValues()) {
}
+
UTF8ArabicPoints::~UTF8ArabicPoints(){};
-char UTF8ArabicPoints::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
- if (!option) {
- //The UTF-8 range 0xFC 0xE5 to 0xFC 0x63 consist of Arabic vowel marks so block those out.
- // Also ranges 0xFE70 til OxFE7F and 0x064b-0x0655
- SWBuf orig = text;
- const unsigned char* from = (unsigned char*)orig.c_str();
- for (text = ""; *from; from++) {
- if (((*from == 0xFC) && (*(from + 1) >= 0xE5 && *(from + 1) <= 0x63)) || ((*from == 0xFE) && (*(from + 1) >= 0x70 && *(from + 1) <= 0x7F)) || ((*from == 0x06) && (*(from + 1) >= 0x4B && *(from + 1) <= 0x55))){
- from++;
- }
- else {
- text += *from;
- }
+
+char UTF8ArabicPoints::processText(SWBuf &text, const SWKey *, const SWModule *) {
+ // A non-zero/true option setting means that setOptionValue("On")
+ // was called which apparently means that Arabic Vowel Marks are ENABLED,
+ // so the filter's actions are DISABLED.
+ if (option)
+ return 0;
+
+ // Eliminate Arabic vowel marks from the text.
+ // The recognized marks are determined by the "nextMark" function.
+
+ // If nextMark were polymorphic (a virtual function or a function
+ // pointer), this function could be generically used in any filter that
+ // only removed (vs. replaced) areas of text based on the arbitrary
+ // match criteria encapsulated in the specific nextMark
+ // implementation.
+ int mark_size = 0;
+ char* mark_pos = nextMark(text.c_str(), &mark_size);
+
+ // Here and at the end of the loop,
+ // test BOTH mark_pos AND *mark_pos for safety and to give nextMark
+ // the option of returning either NULL or a pointer to the null
+ // terminator when done.
+ if (!mark_pos || !*mark_pos)
+ return 0; // no marks found.
+
+ // Purposely granting write access into SWBuf internal buffer via
+ // "end_of_output" avoids a needless temporary SWBuf copy.
+ // Everything before the first mark is already in its final position
+ // and can be safely ignored. So start appending at the current mark.
+ char* end_of_output = mark_pos;
+
+ // For consistency, input starts at (vs. after) the first mark as well
+ // -- not a problem since the mark itself gets skipped, anyway.
+ const char* start_of_input = mark_pos;
+ do {
+ // At this point, "mark_pos" and "mark_pos+mark_size" delimit
+ // the text to drop.
+ // "start_of_input" is either mark_pos or any text between the
+ // end of any previous mark and the current mark_pos.
+ // This text is now ready to be moved into the output.
+ int ready_size = mark_pos - start_of_input;
+ if (ready_size > 0) {
+ // Append the input text before the current mark to the
+ // output.
+ // Must use bcopy vs. strncpy because the final
+ // end_of_output may overtake the original
+ // start_of_input.
+ memmove(end_of_output, start_of_input, ready_size);
+ // Keep appending to end_of_output.
+ end_of_output += ready_size;
}
- }
+ // Ensure the mark never gets copied.
+ start_of_input = mark_pos + mark_size;
+ // Find the next mark.
+ mark_pos = nextMark(start_of_input, &mark_size);
+
+ } while (mark_pos && *mark_pos); // No more marks.
+
+ // Copy any trailing input text AND always the terminating null.
+ memmove(end_of_output, start_of_input, strlen(start_of_input)+1);
return 0;
}
diff --git a/src/modules/filters/utf8arshaping.cpp b/src/modules/filters/utf8arshaping.cpp
index 09d8973..04dea2d 100644
--- a/src/modules/filters/utf8arshaping.cpp
+++ b/src/modules/filters/utf8arshaping.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * utf8arshaping - SWFilter descendant to perform Arabic shaping on
- * UTF-8 text
+ * utf8arshaping.cpp - SWFilter descendant to perform Arabic shaping on
+ * UTF-8 text
*
+ * $Id: utf8arshaping.cpp 2931 2013-07-31 13:07:26Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -31,7 +32,7 @@
SWORD_NAMESPACE_START
-UTF8arShaping::UTF8arShaping() {
+UTF8arShaping::UTF8arShaping() : err(U_ZERO_ERROR) {
conv = ucnv_open("UTF-8", &err);
}
diff --git a/src/modules/filters/utf8bidireorder.cpp b/src/modules/filters/utf8bidireorder.cpp
index 71dc804..b945a5b 100644
--- a/src/modules/filters/utf8bidireorder.cpp
+++ b/src/modules/filters/utf8bidireorder.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
*
- * utf8bidireorder - SWFilter descendant to perform reordering of UTF-8
- * text to visual order according to Unicode BiDi
+ * utf8bidireorder.cpp - SWFilter descendant to perform reordering of
+ * UTF-8 text to visual order according to the
+ * Unicode Bidirectional Algorithm (UBA)
*
+ * $Id: utf8bidireorder.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -29,18 +31,22 @@
#include <utf8bidireorder.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
-UTF8BiDiReorder::UTF8BiDiReorder() {
+
+UTF8BiDiReorder::UTF8BiDiReorder() : err(U_ZERO_ERROR) {
conv = ucnv_open("UTF-8", &err);
}
+
UTF8BiDiReorder::~UTF8BiDiReorder() {
ucnv_close(conv);
}
+
char UTF8BiDiReorder::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
UChar *ustr, *ustr2;
@@ -72,5 +78,6 @@ char UTF8BiDiReorder::processText(SWBuf &text, const SWKey *key, const SWModule
return 0;
}
+
SWORD_NAMESPACE_END
#endif
diff --git a/src/modules/filters/utf8cantillation.cpp b/src/modules/filters/utf8cantillation.cpp
index 73785b4..91ca58a 100644
--- a/src/modules/filters/utf8cantillation.cpp
+++ b/src/modules/filters/utf8cantillation.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * UTF8Cantillation - SWFilter descendant to remove UTF-8 Hebrew cantillation
+ * utf8cantillation.cpp - SWFilter descendant to remove UTF-8 Hebrew
+ * cantillation
*
+ * $Id: utf8cantillation.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,16 +25,23 @@
#include <stdio.h>
#include <utf8cantillation.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Hebrew Cantillation";
-const char oTip[] = "Toggles Hebrew Cantillation Marks";
+namespace {
+
+ static const char oName[] = "Hebrew Cantillation";
+ static const char oTip[] = "Toggles Hebrew Cantillation Marks";
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"Off", "On", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
-UTF8Cantillation::UTF8Cantillation() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
+UTF8Cantillation::UTF8Cantillation() : SWOptionFilter(oName, oTip, oValues()) {
}
diff --git a/src/modules/filters/utf8greekaccents.cpp b/src/modules/filters/utf8greekaccents.cpp
index 5fdb047..039f9a4 100644
--- a/src/modules/filters/utf8greekaccents.cpp
+++ b/src/modules/filters/utf8greekaccents.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * UTF8GreekAccents - SWFilter descendant to remove UTF-8 Greek accents
+ * utf8greekaccents.cpp - SWFilter descendant to remove UTF-8 Greek
+ * accents
*
+ * $Id: utf8greekaccents.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -30,19 +31,27 @@
sword::UTF8NFKD decompose;
#endif
+
SWORD_NAMESPACE_START
-const char oName[] = "Greek Accents";
-const char oTip[] = "Toggles Greek Accents";
+namespace {
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const char oName[] = "Greek Accents";
+ static const char oTip[] = "Toggles Greek Accents";
-UTF8GreekAccents::UTF8GreekAccents() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("On");
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
}
-UTF8GreekAccents::~UTF8GreekAccents(){};
+
+UTF8GreekAccents::UTF8GreekAccents() : SWOptionFilter(oName, oTip, oValues()) {
+}
+
+
+UTF8GreekAccents::~UTF8GreekAccents() {};
char UTF8GreekAccents::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
diff --git a/src/modules/filters/utf8hebrewpoints.cpp b/src/modules/filters/utf8hebrewpoints.cpp
index ba7c746..ff53e4f 100644
--- a/src/modules/filters/utf8hebrewpoints.cpp
+++ b/src/modules/filters/utf8hebrewpoints.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * UTF8HebrewPoints - SWFilter descendant to remove UTF-8 Hebrew vowel points
+ * utf8hebrewpoints.cpp - SWFilter descendant to remove UTF-8 Hebrew
+ * vowel points
*
+ * $Id: utf8hebrewpoints.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -24,24 +25,32 @@
#include <stdio.h>
#include <utf8hebrewpoints.h>
+
SWORD_NAMESPACE_START
-const char oName[] = "Hebrew Vowel Points";
-const char oTip[] = "Toggles Hebrew Vowel Points";
+namespace {
-const SWBuf choices[3] = {"On", "Off", ""};
-const StringList oValues(&choices[0], &choices[2]);
+ static const char oName[] = "Hebrew Vowel Points";
+ static const char oTip[] = "Toggles Hebrew Vowel Points";
-UTF8HebrewPoints::UTF8HebrewPoints() : SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("On");
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
}
+
+UTF8HebrewPoints::UTF8HebrewPoints() : SWOptionFilter(oName, oTip, oValues()) {
+}
+
+
UTF8HebrewPoints::~UTF8HebrewPoints(){};
char UTF8HebrewPoints::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
if (!option) {
- //The UTF-8 range 0xD6 0xB0 to 0xD6 0xBF excluding 0xD6 0x consist of Hebrew cantillation marks so block those out.
+ //The UTF-8 range 0xD6 0xB0 to 0xD6 0xBF excluding 0xD6 0xBE consist of Hebrew cantillation marks so block those out.
SWBuf orig = text;
const unsigned char* from = (unsigned char*)orig.c_str();
for (text = ""; *from; from++) {
@@ -56,4 +65,5 @@ char UTF8HebrewPoints::processText(SWBuf &text, const SWKey *key, const SWModule
return 0;
}
+
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/utf8html.cpp b/src/modules/filters/utf8html.cpp
index 0d1dce3..1f05ac7 100644
--- a/src/modules/filters/utf8html.cpp
+++ b/src/modules/filters/utf8html.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * utf8html - SWFilter descendant to convert a UTF-8 stream to HTML escapes
+ * utf8html.cpp - SWFilter descendant to convert a UTF-8 stream to
+ * HTML escapes
*
+ * $Id: utf8html.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -25,8 +26,10 @@
#include <utf8html.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
UTF8HTML::UTF8HTML() {
}
@@ -34,14 +37,11 @@ UTF8HTML::UTF8HTML() {
char UTF8HTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
unsigned char *from;
- int len;
char digit[10];
unsigned long ch;
if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
return (char)-1;
- len = strlen(text.c_str()) + 2; // shift string to right of buffer
-
SWBuf orig = text;
from = (unsigned char *)orig.c_str();
@@ -82,4 +82,6 @@ char UTF8HTML::processText(SWBuf &text, const SWKey *key, const SWModule *module
return 0;
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/modules/filters/utf8latin1.cpp b/src/modules/filters/utf8latin1.cpp
index 25df0c1..1bf8d3b 100644
--- a/src/modules/filters/utf8latin1.cpp
+++ b/src/modules/filters/utf8latin1.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * UTF8Latin1 - SWFilter descendant to convert UTF-8 to Latin-1
+ * utf8latin1.cpp - SWFilter descendant to convert UTF-8 to Latin-1
*
+ * $Id: utf8latin1.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -26,8 +26,10 @@
#include <utf8latin1.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
UTF8Latin1::UTF8Latin1(char rchar) : replacementChar(rchar) {
}
@@ -36,14 +38,12 @@ char UTF8Latin1::processText(SWBuf &text, const SWKey *key, const SWModule *modu
{
unsigned char *from;
- int len;
unsigned long uchar;
unsigned char significantFirstBits, subsequent;
if ((unsigned long)key < 2) {// hack, we're en(1)/de(0)ciphering
return (char)-1;
}
- len = strlen(text.c_str()) + 1; // shift string to right of buffer
SWBuf orig = text;
from = (unsigned char*)orig.c_str();
@@ -87,5 +87,6 @@ char UTF8Latin1::processText(SWBuf &text, const SWKey *key, const SWModule *modu
return 0;
}
+
SWORD_NAMESPACE_END
diff --git a/src/modules/filters/utf8nfc.cpp b/src/modules/filters/utf8nfc.cpp
index 82d404e..49f12bb 100644
--- a/src/modules/filters/utf8nfc.cpp
+++ b/src/modules/filters/utf8nfc.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * utf8nfc - SWFilter descendant to perform NFC (canonical composition
- * normalization) on UTF-8 text
+ * utf8nfc.cpp - SWFilter descendant to perform NFC (canonical
+ * composition normalization) on UTF-8 text
*
+ * $Id: utf8nfc.cpp 2833 2013-06-29 06:40:28Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
diff --git a/src/modules/filters/utf8nfkd.cpp b/src/modules/filters/utf8nfkd.cpp
index 1d6acf3..e4454d2 100644
--- a/src/modules/filters/utf8nfkd.cpp
+++ b/src/modules/filters/utf8nfkd.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * utf8nfkd - SWFilter descendant to perform NFKD (compatability decomposition
- * normalization) on UTF-8 text
+ * utf8nfkd.cpp - SWFilter descendant to perform NFKD (compatability
+ * decomposition normalization) on UTF-8 text
*
+ * $Id: utf8nfkd.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -29,16 +30,20 @@
#include <utf8nfkd.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
UTF8NFKD::UTF8NFKD() {
conv = ucnv_open("UTF-8", &err);
}
+
UTF8NFKD::~UTF8NFKD() {
ucnv_close(conv);
}
+
char UTF8NFKD::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering
@@ -64,5 +69,6 @@ char UTF8NFKD::processText(SWBuf &text, const SWKey *key, const SWModule *module
return 0;
}
+
SWORD_NAMESPACE_END
#endif
diff --git a/src/modules/filters/utf8transliterator.cpp b/src/modules/filters/utf8transliterator.cpp
index d6aafe2..b5b1902 100644
--- a/src/modules/filters/utf8transliterator.cpp
+++ b/src/modules/filters/utf8transliterator.cpp
@@ -1,10 +1,11 @@
/******************************************************************************
*
- * utf8transliterators - SWFilter descendant to transliterate between
- * ICU-supported scripts.
+ * utf8transliterator.cpp - SWFilter descendant to transliterate between
+ * ICU-supported scripts
*
+ * $Id: utf8transliterator.cpp 2908 2013-07-17 22:44:29Z chrislit $
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -41,54 +42,57 @@ SWORD_NAMESPACE_START
const char UTF8Transliterator::optionstring[NUMTARGETSCRIPTS][16] = {
"Off",
"Latin",
- // "IPA",
- // "Basic Latin",
- // "SBL",
- // "TC",
- // "Beta",
- // "BGreek",
- // "SERA",
- // "Hugoye",
- // "UNGEGN",
- // "ISO",
- // "ALA-LC",
- // "BGN",
- // "Greek",
- // "Hebrew",
- // "Cyrillic",
- // "Arabic",
- // "Syriac",
- // "Katakana",
- // "Hiragana",
- // "Hangul",
- // "Devanagari",
- // "Tamil",
- // "Bengali",
- // "Gurmukhi",
- // "Gujarati",
- // "Oriya",
- // "Telugu",
- // "Kannada",
- // "Malayalam",
- // "Thai",
- // "Georgian",
- // "Armenian",
- // "Ethiopic",
- // "Gothic",
- // "Ugaritic",
- // "Coptic",
- // "Linear B",
- // "Cypriot",
- // "Runic",
- // "Ogham",
- // "Thaana",
- // "Glagolitic",
- // "Cherokee",
+ /*
+ "IPA",
+ "Basic Latin",
+ "SBL",
+ "TC",
+ "Beta",
+ "BGreek",
+ "SERA",
+ "Hugoye",
+ "UNGEGN",
+ "ISO",
+ "ALA-LC",
+ "BGN",
+ "Greek",
+ "Hebrew",
+ "Cyrillic",
+ "Arabic",
+ "Syriac",
+ "Katakana",
+ "Hiragana",
+ "Hangul",
+ "Devanagari",
+ "Tamil",
+ "Bengali",
+ "Gurmukhi",
+ "Gujarati",
+ "Oriya",
+ "Telugu",
+ "Kannada",
+ "Malayalam",
+ "Thai",
+ "Georgian",
+ "Armenian",
+ "Ethiopic",
+ "Gothic",
+ "Ugaritic",
+ "Coptic",
+ "Linear B",
+ "Cypriot",
+ "Runic",
+ "Ogham",
+ "Thaana",
+ "Glagolitic",
+ "Cherokee",
+ */
};
const char UTF8Transliterator::optName[] = "Transliteration";
const char UTF8Transliterator::optTip[] = "Transliterates between scripts";
+#ifdef ICU_CUSTOM_RESOURCE_BUILDING
SWTransMap UTF8Transliterator::transMap;
#ifndef _ICUSWORD_
@@ -128,7 +132,7 @@ SWCharString::~SWCharString() {
}
#endif // _ICUSWORD_
-
+#endif // ICU_CUSTOM_RESOURCE_BUILDING
UTF8Transliterator::UTF8Transliterator() {
option = 0;
@@ -136,17 +140,19 @@ UTF8Transliterator::UTF8Transliterator() {
for (i = 0; i < NUMTARGETSCRIPTS; i++) {
options.push_back(optionstring[i]);
}
+#ifdef ICU_CUSTOM_RESOURCE_BUILDING
#ifndef _ICUSWORD_
utf8status = U_ZERO_ERROR;
Load(utf8status);
#endif
+#endif
}
UTF8Transliterator::~UTF8Transliterator() {
}
-
+#ifdef ICU_CUSTOM_RESOURCE_BUILDING
void UTF8Transliterator::Load(UErrorCode &status)
{
#ifndef _ICUSWORD_
@@ -299,23 +305,29 @@ bool UTF8Transliterator::checkTrans(const UnicodeString& ID, UErrorCode &status
return true;
#endif // _ICUSWORD_
}
+#endif // ICU_CUSTOM_RESOURCE_BUILDING
bool UTF8Transliterator::addTrans(const char* newTrans, SWBuf* transList) {
+#ifdef ICU_CUSTOM_RESOURCE_BUILDING
#ifdef _ICUSWORD_
- UErrorCode status;
+ UErrorCode status;
if (checkTrans(UnicodeString(newTrans), status)) {
#endif
+#endif // ICU_CUSTOM_RESOURCE_BUILDING
*transList += newTrans;
- *transList += ";";
- return true;
+ *transList += ";";
+ return true;
+#ifdef ICU_CUSTOM_RESOURCE_BUILDING
#ifdef _ICUSWORD_
- }
- else {
- return false;
- }
+ }
+ else {
+ return false;
+ }
#endif
+#endif // ICU_CUSTOM_RESOURCE_BUILDING
}
+
Transliterator * UTF8Transliterator::createTrans(const UnicodeString& ID, UTransDirection dir, UErrorCode &status )
{
Transliterator *trans = Transliterator::createInstance(ID,UTRANS_FORWARD,status);
@@ -450,7 +462,7 @@ char UTF8Transliterator::processText(SWBuf &text, const SWKey *key, const SWModu
//Simple X to Latin transliterators
if (scripts[SE_GREEK]) {
- if (strnicmp (((SWModule*)module)->Lang(), "cop", 3)) {
+ if (strnicmp (((SWModule*)module)->getLanguage(), "cop", 3)) {
if (option == SE_SBL)
addTrans("Greek-Latin/SBL", &ID);
else if (option == SE_TC)
@@ -653,7 +665,7 @@ char UTF8Transliterator::processText(SWBuf &text, const SWKey *key, const SWModu
}
if (scripts[SE_HAN]) {
- if (!strnicmp (((SWModule*)module)->Lang(), "ja", 2)) {
+ if (!strnicmp (((SWModule*)module)->getLanguage(), "ja", 2)) {
addTrans("Kanji-Romaji", &ID);
}
else {
diff --git a/src/modules/filters/utf8utf16.cpp b/src/modules/filters/utf8utf16.cpp
index e5b96d7..be8ad4b 100644
--- a/src/modules/filters/utf8utf16.cpp
+++ b/src/modules/filters/utf8utf16.cpp
@@ -1,10 +1,10 @@
/******************************************************************************
*
- * UTF8UTF16 - SWFilter descendant to convert UTF-8 to UTF-16
+ * utf8utf16.cpp - SWFilter descendant to convert UTF-8 to UTF-16
*
+ * $Id: utf8utf16.cpp 2980 2013-09-14 21:51:47Z scribe $
*
- *
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,8 +28,10 @@
#include <utilstr.h>
#include <swbuf.h>
+
SWORD_NAMESPACE_START
+
UTF8UTF16::UTF8UTF16() {
}
diff --git a/src/modules/genbook/rawgenbook/rawgenbook.cpp b/src/modules/genbook/rawgenbook/rawgenbook.cpp
index eff68f5..6101241 100644
--- a/src/modules/genbook/rawgenbook/rawgenbook.cpp
+++ b/src/modules/genbook/rawgenbook/rawgenbook.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * rawtext.cpp - code for class 'RawGenBook'- a module that reads raw text
- * files: ot and nt using indexs ??.bks ??.cps ??.vss
*
+ * rawgenbook.cpp - code for class 'RawGenBook'- a module that reads raw
+ * text files: ot and nt using indexs ??.bks ??.cps ??.vss
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawgenbook.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -51,13 +53,13 @@ RawGenBook::RawGenBook(const char *ipath, const char *iname, const char *idesc,
stdstr(&path, ipath);
verseKey = !strcmp("VerseKey", keyType);
- if (verseKey) Type("Biblical Texts");
+ if (verseKey) setType("Biblical Texts");
if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\'))
path[strlen(path)-1] = 0;
delete key;
- key = CreateKey();
+ key = createKey();
sprintf(buf, "%s.bdt", path);
@@ -82,7 +84,7 @@ RawGenBook::~RawGenBook() {
}
-bool RawGenBook::isWritable() {
+bool RawGenBook::isWritable() const {
return ((bdtfd->getFd() > 0) && ((bdtfd->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
@@ -94,7 +96,7 @@ bool RawGenBook::isWritable() {
* RET: string buffer with verse
*/
-SWBuf &RawGenBook::getRawEntryBuf() {
+SWBuf &RawGenBook::getRawEntryBuf() const {
__u32 offset = 0;
__u32 size = 0;
@@ -160,7 +162,7 @@ void RawGenBook::linkEntry(const SWKey *inkey) {
SWCATCH ( ... ) {}
// if we don't have a VerseKey * decendant, create our own
if (!srckey) {
- srckey = (TreeKeyIdx *)CreateKey();
+ srckey = (TreeKeyIdx *)createKey();
(*srckey) = *inkey;
}
@@ -207,7 +209,7 @@ char RawGenBook::createModule(const char *ipath) {
}
-SWKey *RawGenBook::CreateKey() const {
+SWKey *RawGenBook::createKey() const {
TreeKey *tKey = new TreeKeyIdx(path);
if (verseKey) { SWKey *vtKey = new VerseTreeKey(tKey); delete tKey; return vtKey; }
return tKey;
@@ -218,7 +220,7 @@ bool RawGenBook::hasEntry(const SWKey *k) const {
int dsize;
key.getUserData(&dsize);
- return (dsize > 7) && key.Error() == '\x00';
+ return (dsize > 7) && key.popError() == '\x00';
}
SWORD_NAMESPACE_END
diff --git a/src/modules/genbook/swgenbook.cpp b/src/modules/genbook/swgenbook.cpp
index e7feea2..fef41ad 100644
--- a/src/modules/genbook/swgenbook.cpp
+++ b/src/modules/genbook/swgenbook.cpp
@@ -1,9 +1,10 @@
/******************************************************************************
- * swld.cpp - code for base class 'SWLD'. SWLD is the basis for all
- * types of Lexicon and Dictionary modules (hence the 'LD').
*
+ * swgenbook.cpp - Implementation of SWGenBook class
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swgenbook.cpp 2893 2013-07-16 03:07:02Z scribe $
+ *
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -26,7 +27,7 @@
SWORD_NAMESPACE_START
/******************************************************************************
- * SWLD Constructor - Initializes data for instance of SWLD
+ * SWGenBook Constructor - Initializes data for instance of SWGenBook
*
* ENT: imodname - Internal name for module
* imoddesc - Name to display to user for module
@@ -39,7 +40,7 @@ SWGenBook::SWGenBook(const char *imodname, const char *imoddesc, SWDisplay *idis
/******************************************************************************
- * SWLD Destructor - Cleans up instance of SWGenBook
+ * SWGenBook Destructor - Cleans up instance of SWGenBook
*/
SWGenBook::~SWGenBook() {
@@ -65,11 +66,11 @@ TreeKey &SWGenBook::getTreeKey(const SWKey *k) const {
SWCATCH ( ... ) { }
if (lkTest) {
SWTRY {
- key = SWDYNAMIC_CAST(TreeKey, lkTest->GetElement());
+ key = SWDYNAMIC_CAST(TreeKey, lkTest->getElement());
if (!key) {
VerseTreeKey *tkey = 0;
SWTRY {
- tkey = SWDYNAMIC_CAST(VerseTreeKey, lkTest->GetElement());
+ tkey = SWDYNAMIC_CAST(VerseTreeKey, lkTest->getElement());
}
SWCATCH ( ... ) {}
if (tkey) key = tkey->getTreeKey();
@@ -89,7 +90,7 @@ TreeKey &SWGenBook::getTreeKey(const SWKey *k) const {
if (!key) {
delete tmpTreeKey;
- tmpTreeKey = (TreeKey *)CreateKey();
+ tmpTreeKey = (TreeKey *)createKey();
(*tmpTreeKey) = *(thiskey);
return (*tmpTreeKey);
}
diff --git a/src/modules/lexdict/rawld/rawld.cpp b/src/modules/lexdict/rawld/rawld.cpp
index e6a4d57..7446c10 100644
--- a/src/modules/lexdict/rawld/rawld.cpp
+++ b/src/modules/lexdict/rawld/rawld.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * rawld.cpp - code for class 'RawLD'- a module that reads raw lexicon and
- * dictionary files: *.dat *.idx
*
+ * rawld.cpp - code for class 'RawLD'- a module that reads raw lexicon and
+ * dictionary files: *.dat *.idx
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawld.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,8 +30,10 @@
#include <stdio.h>
+
SWORD_NAMESPACE_START
+
/******************************************************************************
* RawLD Constructor - Initializes data for instance of RawLD
*
@@ -39,7 +43,7 @@ SWORD_NAMESPACE_START
* idisp - Display object to use for displaying
*/
-RawLD::RawLD(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang) : RawStr(ipath), SWLD(iname, idesc, idisp, enc, dir, mark, ilang)
+RawLD::RawLD(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, bool caseSensitive, bool strongsPadding) : RawStr(ipath, -1, caseSensitive), SWLD(iname, idesc, idisp, enc, dir, mark, ilang, strongsPadding)
{
}
@@ -53,7 +57,7 @@ RawLD::~RawLD()
}
-bool RawLD::isWritable() {
+bool RawLD::isWritable() const {
return ((idxfd->getFd() > 0) && ((idxfd->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
@@ -67,7 +71,7 @@ bool RawLD::isWritable() {
* RET: error status
*/
-char RawLD::getEntry(long away)
+char RawLD::getEntry(long away) const
{
__u32 start = 0;
__u16 size = 0;
@@ -77,14 +81,14 @@ char RawLD::getEntry(long away)
char *buf = new char [ strlen(*key) + 6 ];
strcpy(buf, *key);
- strongsPad(buf);
+ if (strongsPadding) strongsPad(buf);
if (!(retval = findOffset(buf, &start, &size, away))) {
readText(start, &size, &idxbuf, entryBuf);
rawFilter(entryBuf, 0); // hack, decipher
rawFilter(entryBuf, key);
entrySize = size; // support getEntrySize call
- if (!key->Persist()) // If we have our own key
+ if (!key->isPersist()) // If we have our own key
*key = idxbuf; // reset it to entry index buffer
stdstr(&entkeytxt, idxbuf); // set entry key text that module 'snapped' to.
@@ -106,7 +110,7 @@ char RawLD::getEntry(long away)
* RET: string buffer with entry
*/
-SWBuf &RawLD::getRawEntryBuf() {
+SWBuf &RawLD::getRawEntryBuf() const {
char ret = getEntry();
if (!ret) {
@@ -132,7 +136,7 @@ void RawLD::increment(int steps) {
if (key->isTraversable()) {
*key += steps;
- error = key->Error();
+ error = key->popError();
steps = 0;
}
@@ -176,7 +180,7 @@ long RawLD::getEntryForKey(const char *key) const {
char *buf = new char [ strlen(key) + 6 ];
strcpy(buf, key);
- strongsPad(buf);
+ if (strongsPadding) strongsPad(buf);
findOffset(buf, &start, &size, 0, &offset);
@@ -192,4 +196,6 @@ char *RawLD::getKeyForEntry(long entry) const {
return key;
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/modules/lexdict/rawld4/rawld4.cpp b/src/modules/lexdict/rawld4/rawld4.cpp
index 6d60d9a..1f81d83 100644
--- a/src/modules/lexdict/rawld4/rawld4.cpp
+++ b/src/modules/lexdict/rawld4/rawld4.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * rawld.cpp - code for class 'RawLD'- a module that reads raw lexicon and
- * dictionary files: *.dat *.idx
*
+ * rawld4.cpp - code for class 'RawLD'- a module that reads raw
+ * lexicon and dictionary files: *.dat *.idx
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: rawld4.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -28,8 +30,10 @@
#include <stdio.h>
+
SWORD_NAMESPACE_START
+
/******************************************************************************
* RawLD Constructor - Initializes data for instance of RawLD
*
@@ -39,7 +43,7 @@ SWORD_NAMESPACE_START
* idisp - Display object to use for displaying
*/
-RawLD4::RawLD4(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang) : RawStr4(ipath), SWLD(iname, idesc, idisp, enc, dir, mark, ilang)
+RawLD4::RawLD4(const char *ipath, const char *iname, const char *idesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, bool caseSensitive, bool strongsPadding) : RawStr4(ipath, -1, caseSensitive), SWLD(iname, idesc, idisp, enc, dir, mark, ilang, strongsPadding)
{
}
@@ -53,7 +57,7 @@ RawLD4::~RawLD4()
}
-bool RawLD4::isWritable() {
+bool RawLD4::isWritable() const {
return ((idxfd->getFd() > 0) && ((idxfd->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
@@ -67,7 +71,7 @@ bool RawLD4::isWritable() {
* RET: error status
*/
-char RawLD4::getEntry(long away)
+char RawLD4::getEntry(long away) const
{
__u32 start = 0;
__u32 size = 0;
@@ -85,7 +89,7 @@ char RawLD4::getEntry(long away)
rawFilter(entryBuf, 0); // hack, decipher
rawFilter(entryBuf, key);
entrySize = size; // support getEntrySize call
- if (!key->Persist()) // If we have our own key
+ if (!key->isPersist()) // If we have our own key
*key = idxbuf; // reset it to entry index buffer
stdstr(&entkeytxt, idxbuf); // set entry key text that module 'snapped' to.
@@ -104,7 +108,7 @@ char RawLD4::getEntry(long away)
* RET: string buffer with entry
*/
-SWBuf &RawLD4::getRawEntryBuf() {
+SWBuf &RawLD4::getRawEntryBuf() const {
char ret = getEntry();
if (!ret) {
@@ -130,7 +134,7 @@ void RawLD4::increment(int steps) {
if (key->isTraversable()) {
*key += steps;
- error = key->Error();
+ error = key->popError();
steps = 0;
}
@@ -160,11 +164,13 @@ void RawLD4::deleteEntry() {
doSetText(*key, "");
}
+
long RawLD4::getEntryCount() const {
if (idxfd < 0) return 0;
return idxfd->seek(0, SEEK_END) / IDXENTRYSIZE;
}
+
long RawLD4::getEntryForKey(const char *key) const {
__u32 start, offset;
__u32 size;
@@ -181,10 +187,13 @@ long RawLD4::getEntryForKey(const char *key) const {
return offset / IDXENTRYSIZE;
}
+
char *RawLD4::getKeyForEntry(long entry) const {
char *key = 0;
getIDXBuf(entry * IDXENTRYSIZE, &key);
return key;
}
+
SWORD_NAMESPACE_END
+
diff --git a/src/modules/lexdict/swld.cpp b/src/modules/lexdict/swld.cpp
index bccf5d8..5e1909b 100644
--- a/src/modules/lexdict/swld.cpp
+++ b/src/modules/lexdict/swld.cpp
@@ -1,9 +1,11 @@
/******************************************************************************
- * swld.cpp - code for base class 'SWLD'. SWLD is the basis for all
- * types of Lexicon and Dictionary modules (hence the 'LD').
*
+ * swld.cpp - code for base class 'SWLD'. SWLD is the basis for all
+ * types of Lexicon and Dictionary modules (hence the 'LD').
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swld.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 1997-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -23,9 +25,12 @@
#include <stdio.h>
#include <swld.h>
#include <strkey.h>
+#include <swkey.h>
+
SWORD_NAMESPACE_START
+
/******************************************************************************
* SWLD Constructor - Initializes data for instance of SWLD
*
@@ -34,10 +39,10 @@ SWORD_NAMESPACE_START
* idisp - Display object to use for displaying
*/
-SWLD::SWLD(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang) : SWModule(imodname, imoddesc, idisp, (char *)"Lexicons / Dictionaries", enc, dir, mark, ilang)
+SWLD::SWLD(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, bool strongsPadding) : SWModule(imodname, imoddesc, idisp, (char *)"Lexicons / Dictionaries", enc, dir, mark, ilang), strongsPadding(strongsPadding)
{
delete key;
- key = CreateKey();
+ key = createKey();
entkeytxt = new char [1];
*entkeytxt = 0;
}
@@ -54,7 +59,7 @@ SWLD::~SWLD()
}
-SWKey *SWLD::CreateKey() const { return new StrKey(); }
+SWKey *SWLD::createKey() const { return new StrKey(); }
/******************************************************************************
@@ -67,13 +72,11 @@ SWKey *SWLD::CreateKey() const { return new StrKey(); }
* RET: pointer to keytext
*/
-const char *SWLD::KeyText(const char *ikeytext)
-{
- if (key->Persist() && !ikeytext) {
+const char *SWLD::getKeyText() const {
+ if (key->isPersist()) {
getRawEntryBuf(); // force module key to snap to entry
- return entkeytxt;
}
- else return SWModule::KeyText(ikeytext);
+ return entkeytxt;
}
@@ -96,12 +99,13 @@ void SWLD::setPosition(SW_POSITION p) {
getRawEntryBuf();
}
+
bool SWLD::hasEntry(const SWKey *key) const {
const char *key_str = *key;
char *buf = new char [ strlen(key_str) + 6 ];
strcpy(buf, key_str);
- strongsPad(buf);
+ if (strongsPadding) strongsPad(buf);
bool retVal = !strcmp(buf, getKeyForEntry(getEntryForKey(buf)));
delete buf;
@@ -109,6 +113,7 @@ bool SWLD::hasEntry(const SWKey *key) const {
return retVal;
}
+
/******************************************************************************
* SWLD::strongsPad - Pads a key if (it-1) is 100% digits to 5 places
* allows for final to be alpha, e.g. '123B'
@@ -161,3 +166,4 @@ void SWLD::strongsPad(char *buf)
SWORD_NAMESPACE_END
+
diff --git a/src/modules/lexdict/zld/zld.cpp b/src/modules/lexdict/zld/zld.cpp
index 2c46657..71919d4 100644
--- a/src/modules/lexdict/zld/zld.cpp
+++ b/src/modules/lexdict/zld/zld.cpp
@@ -1,8 +1,11 @@
/******************************************************************************
- * rawld.cpp - code for class 'RawLD'- a module that reads raw lexicon and
- * dictionary files: *.dat *.idx
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * zld.cpp - code for class 'zLD'- a module that reads zlib compressed
+ * lexicon and dictionary files
+ *
+ * $Id: zld.cpp 2980 2013-09-14 21:51:47Z scribe $
+ *
+ * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,8 +30,10 @@
#include <stdio.h>
+
SWORD_NAMESPACE_START
+
/******************************************************************************
* RawLD Constructor - Initializes data for instance of RawLD
*
@@ -38,7 +43,7 @@ SWORD_NAMESPACE_START
* idisp - Display object to use for displaying
*/
-zLD::zLD(const char *ipath, const char *iname, const char *idesc, long blockCount, SWCompress *icomp, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang) : zStr(ipath, -1, blockCount, icomp), SWLD(iname, idesc, idisp, enc, dir, mark, ilang) {
+zLD::zLD(const char *ipath, const char *iname, const char *idesc, long blockCount, SWCompress *icomp, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, bool caseSensitive, bool strongsPadding) : zStr(ipath, -1, blockCount, icomp, caseSensitive), SWLD(iname, idesc, idisp, enc, dir, mark, ilang, strongsPadding) {
}
@@ -52,7 +57,7 @@ zLD::~zLD() {
}
-bool zLD::isWritable() {
+bool zLD::isWritable() const {
return ((idxfd->getFd() > 0) && ((idxfd->mode & FileMgr::RDWR) == FileMgr::RDWR));
}
@@ -66,7 +71,7 @@ bool zLD::isWritable() {
* RET: error status
*/
-char zLD::getEntry(long away) {
+char zLD::getEntry(long away) const {
char *idxbuf = 0;
char *ebuf = 0;
char retval = 0;
@@ -75,7 +80,7 @@ char zLD::getEntry(long away) {
char *buf = new char [ strlen(*key) + 6 ];
strcpy(buf, *key);
- strongsPad(buf);
+ if (strongsPadding) strongsPad(buf);
entryBuf = "";
if (!(retval = findKeyIndex(buf, &index, away))) {
@@ -86,7 +91,7 @@ char zLD::getEntry(long away) {
rawFilter(entryBuf, key);
entrySize = size; // support getEntrySize call
- if (!key->Persist()) // If we have our own key
+ if (!key->isPersist()) // If we have our own key
*key = idxbuf; // reset it to entry index buffer
stdstr(&entkeytxt, idxbuf); // set entry key text that module 'snapped' to.
@@ -106,7 +111,7 @@ char zLD::getEntry(long away) {
* RET: string buffer with entry
*/
-SWBuf &zLD::getRawEntryBuf() {
+SWBuf &zLD::getRawEntryBuf() const {
if (!getEntry() /*&& !isUnicode()*/) {
prepText(entryBuf);
}
@@ -128,7 +133,7 @@ void zLD::increment(int steps) {
if (key->isTraversable()) {
*key += steps;
- error = key->Error();
+ error = key->popError();
steps = 0;
}
@@ -172,7 +177,7 @@ long zLD::getEntryForKey(const char* key) const
char *buf = new char [ strlen(key) + 6 ];
strcpy(buf, key);
- strongsPad(buf);
+ if (strongsPadding) strongsPad(buf);
findKeyIndex(buf, &offset);
@@ -191,3 +196,4 @@ char *zLD::getKeyForEntry(long entry) const
SWORD_NAMESPACE_END
+
diff --git a/src/modules/readme b/src/modules/readme
deleted file mode 100644
index 92cc99e..0000000
--- a/src/modules/readme
+++ /dev/null
@@ -1,9 +0,0 @@
-This directory contains all different module types that are usable by the SWORD
-API.
-
- comments Commentaries
- common common utility objects
- lexdict Lexicons/Dictionaries
- maps Maps
- parsers Language Parsers
- texts Scripture Texts
diff --git a/src/modules/swmodule.cpp b/src/modules/swmodule.cpp
index 758b8d2..6944c4e 100644
--- a/src/modules/swmodule.cpp
+++ b/src/modules/swmodule.cpp
@@ -1,10 +1,12 @@
/******************************************************************************
- * swmodule.cpp - code for base class 'module'. Module is the basis for all
- * types of modules (e.g. texts, commentaries, maps, lexicons,
- * etc.)
*
+ * swmodule.cpp - code for base class 'SWModule'. SWModule is the basis
+ * for all types of modules (e.g. texts, commentaries,
+ * maps, lexicons, etc.)
*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+ * $Id: swmodule.cpp 2976 2013-09-10 14:09:44Z scribe $
+ *
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -27,7 +29,6 @@
#include <sysdata.h>
#include <swmodule.h>
#include <utilstr.h>
-#include <regex.h> // GNU
#include <swfilter.h>
#include <versekey.h> // KLUDGE for Search
#include <treekeyidx.h> // KLUDGE for Search
@@ -38,9 +39,17 @@
#include <iostream>
#endif
+#ifdef USECXX11REGEX
+#include <regex>
+#ifndef REG_ICASE
+#define REG_ICASE std::regex::icase
+#endif
+#else
+#include <regex.h> // GNU
+#endif
+
#ifdef USELUCENE
#include <CLucene.h>
-#include <CLucene/CLBackwards.h>
//Lucence includes
//#include "CLucene.h"
@@ -61,7 +70,7 @@ using std::vector;
SWORD_NAMESPACE_START
-SWDisplay SWModule::rawdisp;
+SWModule::StdOutDisplay SWModule::rawdisp;
typedef std::list<SWBuf> StringList;
@@ -77,7 +86,7 @@ typedef std::list<SWBuf> StringList;
*/
SWModule::SWModule(const char *imodname, const char *imoddesc, SWDisplay *idisp, const char *imodtype, SWTextEncoding encoding, SWTextDirection direction, SWTextMarkup markup, const char *imodlang) {
- key = CreateKey();
+ key = createKey();
entryBuf = "";
config = &ownConfig;
modname = 0;
@@ -120,44 +129,44 @@ SWModule::~SWModule()
delete [] modlang;
if (key) {
- if (!key->Persist())
+ if (!key->isPersist())
delete key;
}
stripFilters->clear();
- rawFilters->clear();
- renderFilters->clear();
- optionFilters->clear();
- encodingFilters->clear();
+ rawFilters->clear();
+ renderFilters->clear();
+ optionFilters->clear();
+ encodingFilters->clear();
entryAttributes.clear();
- delete stripFilters;
- delete rawFilters;
- delete renderFilters;
- delete optionFilters;
- delete encodingFilters;
+ delete stripFilters;
+ delete rawFilters;
+ delete renderFilters;
+ delete optionFilters;
+ delete encodingFilters;
}
/******************************************************************************
- * SWModule::CreateKey - Allocates a key of specific type for module
+ * SWModule::createKey - Allocates a key of specific type for module
*
* RET: pointer to allocated key
*/
-SWKey *SWModule::CreateKey() const
+SWKey *SWModule::createKey() const
{
return new SWKey();
}
/******************************************************************************
- * SWModule::Error - Gets and clears error status
+ * SWModule::popError - Gets and clears error status
*
* RET: error status
*/
-char SWModule::Error()
+char SWModule::popError()
{
char retval = error;
@@ -175,11 +184,7 @@ char SWModule::Error()
* RET: pointer to modname
*/
-char *SWModule::Name(const char *imodname) {
- return stdstr(&modname, imodname);
-}
-
-char *SWModule::Name() const {
+const char *SWModule::getName() const {
return modname;
}
@@ -193,11 +198,7 @@ char *SWModule::Name() const {
* RET: pointer to moddesc
*/
-char *SWModule::Description(const char *imoddesc) {
- return stdstr(&moddesc, imoddesc);
-}
-
-char *SWModule::Description() const {
+const char *SWModule::getDescription() const {
return moddesc;
}
@@ -211,70 +212,20 @@ char *SWModule::Description() const {
* RET: pointer to modtype
*/
-char *SWModule::Type(const char *imodtype) {
- return stdstr(&modtype, imodtype);
-}
-
-char *SWModule::Type() const {
+const char *SWModule::getType() const {
return modtype;
}
/******************************************************************************
- * SWModule::Direction - Sets/gets module direction
+ * SWModule::getDirection - Sets/gets module direction
*
* ENT: newdir - value which to set direction
* [-1] - only get
*
* RET: char direction
*/
-char SWModule::Direction(signed char newdir) {
- if (newdir != -1)
- direction = newdir;
- return direction;
-}
-
-/******************************************************************************
- * SWModule::Encoding - Sets/gets module encoding
- *
- * ENT: newdir - value which to set direction
- * [-1] - only get
- *
- * RET: char encoding
- */
-char SWModule::Encoding(signed char newenc) {
- if (newenc != -1)
- encoding = newenc;
- return encoding;
-}
-
-/******************************************************************************
- * SWModule::Markup - Sets/gets module markup
- *
- * ENT: newdir - value which to set direction
- * [-1] - only get
- *
- * RET: char markup
- */
-char SWModule::Markup(signed char newmark) {
- if (newmark != -1)
- markup = newmark;
- return markup;
-}
-
-
-/******************************************************************************
- * SWModule::Lang - Sets/gets module language
- *
- * ENT: imodlang - value which to set modlang
- * [0] - only get
- *
- * RET: pointer to modname
- */
-
-char *SWModule::Lang(const char *imodlang)
-{
- if (imodlang) stdstr(&modlang, imodlang);
- return modlang;
+char SWModule::getDirection() const {
+ return direction;
}
@@ -295,19 +246,17 @@ void SWModule::setDisplay(SWDisplay *idisp) {
disp = idisp;
}
-
/******************************************************************************
- * SWModule::Display - Calls this modules display object and passes itself
- *
- * RET: error status
- */
+ * * SWModule::Display - Calls this modules display object and passes itself
+ * *
+ * * RET: error status
+ * */
-char SWModule::Display() {
- disp->Display(*this);
+char SWModule::display() {
+ disp->display(*this);
return 0;
}
-
/******************************************************************************
* SWModule::getKey - Gets the key from this module that points to the position
* record
@@ -333,12 +282,12 @@ char SWModule::setKey(const SWKey *ikey) {
SWKey *oldKey = 0;
if (key) {
- if (!key->Persist()) // if we have our own copy
+ if (!key->isPersist()) // if we have our own copy
oldKey = key;
}
- if (!ikey->Persist()) { // if we are to keep our own copy
- key = CreateKey();
+ if (!ikey->isPersist()) { // if we are to keep our own copy
+ key = createKey();
*key = *ikey;
}
else key = (SWKey *)ikey; // if we are to just point to an external key
@@ -360,7 +309,7 @@ char SWModule::setKey(const SWKey *ikey) {
void SWModule::setPosition(SW_POSITION p) {
*key = p;
- char saveError = key->Error();
+ char saveError = key->popError();
switch (p) {
case POS_TOP:
@@ -388,7 +337,7 @@ void SWModule::setPosition(SW_POSITION p) {
void SWModule::increment(int steps) {
(*key) += steps;
- error = key->Error();
+ error = key->popError();
}
@@ -402,7 +351,7 @@ void SWModule::increment(int steps) {
void SWModule::decrement(int steps) {
(*key) -= steps;
- error = key->Error();
+ error = key->popError();
}
@@ -426,7 +375,7 @@ void SWModule::decrement(int steps) {
ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *scope, bool *justCheckIfSupported, void (*percent)(char, void *), void *percentUserData) {
- listKey.ClearList();
+ listKey.clear();
SWBuf term = istr;
bool includeComponents = false; // for entryAttrib e.g., /Lemma.1/
@@ -447,10 +396,21 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
return listKey;
}
- SWKey *saveKey = 0;
+ SWKey *saveKey = 0;
SWKey *searchKey = 0;
- SWKey *resultKey = CreateKey();
+ SWKey *resultKey = createKey();
+ SWKey *lastKey = createKey();
+ SWBuf lastBuf = "";
+
+#ifdef USECXX11REGEX
+ std::locale oldLocale;
+ std::locale::global(std::locale("en_US.UTF-8"));
+
+ std::regex preg;
+#else
regex_t preg;
+#endif
+
vector<SWBuf> words;
vector<SWBuf> window;
const char *sres;
@@ -460,36 +420,40 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
// determine if we might be doing special strip searches. useful for knowing if we can use shortcuts
bool specialStrips = (getConfigEntry("LocalStripFilter")
- || (getConfig().has("GlobalOptionFilter", "UTF8GreekAccents"))
- || (getConfig().has("GlobalOptionFilter", "UTF8HebrewPoints"))
- || (getConfig().has("GlobalOptionFilter", "UTF8ArabicPoints"))
- || (strchr(istr, '<')));
+ || (getConfig().has("GlobalOptionFilter", "UTF8GreekAccents"))
+ || (getConfig().has("GlobalOptionFilter", "UTF8HebrewPoints"))
+ || (getConfig().has("GlobalOptionFilter", "UTF8ArabicPoints"))
+ || (strchr(istr, '<')));
- processEntryAttributes(searchType == -3);
+ setProcessEntryAttributes(searchType == -3);
- if (!key->Persist()) {
- saveKey = CreateKey();
+ if (!key->isPersist()) {
+ saveKey = createKey();
*saveKey = *key;
}
else saveKey = key;
- searchKey = (scope)?scope->clone():(key->Persist())?key->clone():0;
+ searchKey = (scope)?scope->clone():(key->isPersist())?key->clone():0;
if (searchKey) {
- searchKey->Persist(1);
+ searchKey->setPersist(true);
setKey(*searchKey);
}
(*percent)(perc, percentUserData);
*this = BOTTOM;
- long highIndex = key->Index();
+ long highIndex = key->getIndex();
if (!highIndex)
highIndex = 1; // avoid division by zero errors.
*this = TOP;
if (searchType >= 0) {
+#ifdef USECXX11REGEX
+ preg = std::regex((SWBuf(".*")+istr+".*").c_str(), std::regex_constants::extended & flags);
+#else
flags |=searchType|REG_NOSUB|REG_EXTENDED;
regcomp(&preg, istr, flags);
+#endif
}
(*percent)(++perc, percentUserData);
@@ -497,10 +461,6 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
#ifdef USELUCENE
if (searchType == -4) { // lucene
- //Buffers for the wchar<->utf8 char* conversion
- const unsigned short int MAX_CONV_SIZE = 2047;
- wchar_t wcharBuffer[MAX_CONV_SIZE + 1];
- char utfBuffer[MAX_CONV_SIZE + 1];
lucene::index::IndexReader *ir = 0;
lucene::search::IndexSearcher *is = 0;
@@ -513,20 +473,18 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
const TCHAR *stopWords[] = { 0 };
standard::StandardAnalyzer analyzer(stopWords);
- lucene_utf8towcs(wcharBuffer, istr, MAX_CONV_SIZE); //TODO Is istr always utf8?
- q = QueryParser::parse(wcharBuffer, _T("content"), &analyzer);
+ q = QueryParser::parse((wchar_t *)utf8ToWChar(istr).getRawData(), _T("content"), &analyzer);
(*percent)(20, percentUserData);
h = is->search(q);
(*percent)(80, percentUserData);
// iterate thru each good module position that meets the search
bool checkBounds = getKey()->isBoundSet();
- for (long i = 0; i < h->length(); i++) {
+ for (unsigned long i = 0; i < (unsigned long)h->length(); i++) {
Document &doc = h->doc(i);
// set a temporary verse key to this module position
- lucene_wcstoutf8(utfBuffer, doc.get(_T("key")), MAX_CONV_SIZE);
- *resultKey = utfBuffer; //TODO Does a key always accept utf8?
+ *resultKey = wcharToUTF8(doc.get(_T("key"))); //TODO Does a key always accept utf8?
// check to see if it sets ok (within our bounds) and if not, skip
if (checkBounds) {
@@ -536,7 +494,7 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
}
}
listKey << *resultKey;
- listKey.GetElement()->userData = (void *)((__u32)(h->score(i)*100));
+ listKey.getElement()->userData = (__u64)((__u32)(h->score(i)*100));
}
(*percent)(98, percentUserData);
}
@@ -606,8 +564,8 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
(*percent)(perc, percentUserData);
- while ((searchType != -4) && !Error() && !terminateSearch) {
- long mindex = key->Index();
+ while ((searchType != -4) && !popError() && !terminateSearch) {
+ long mindex = key->getIndex();
float per = (float)mindex / highIndex;
per *= 93;
per += 5;
@@ -619,17 +577,35 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
else if (newperc < perc) {
#ifndef _MSC_VER
std::cerr << "Serious error: new percentage complete is less than previous value\n";
- std::cerr << "index: " << (key->Index()) << "\n";
+ std::cerr << "index: " << (key->getIndex()) << "\n";
std::cerr << "highIndex: " << highIndex << "\n";
std::cerr << "newperc ==" << (int)newperc << "%" << "is smaller than\n";
std::cerr << "perc == " << (int )perc << "% \n";
#endif
}
if (searchType >= 0) {
- if (!regexec(&preg, StripText(), 0, 0, 0)) {
+ SWBuf textBuf = stripText();
+#ifdef USECXX11REGEX
+ if (std::regex_match(std::string(textBuf.c_str()), preg)) {
+#else
+ if (!regexec(&preg, textBuf, 0, 0, 0)) {
+#endif
*resultKey = *getKey();
resultKey->clearBound();
listKey << *resultKey;
+ lastBuf = "";
+ }
+#ifdef USECXX11REGEX
+ else if (std::regex_match(std::string((lastBuf + ' ' + textBuf).c_str()), preg)) {
+#else
+ else if (!regexec(&preg, lastBuf + ' ' + textBuf, 0, 0, 0)) {
+#endif
+ lastKey->clearBound();
+ listKey << *lastKey;
+ lastBuf = textBuf;
+ }
+ else {
+ lastBuf = textBuf;
}
}
@@ -640,10 +616,10 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
// phrase
case -1:
- textBuf = StripText();
+ textBuf = stripText();
if ((flags & REG_ICASE) == REG_ICASE) toupperstr(textBuf);
sres = strstr(textBuf.c_str(), term.c_str());
- if (sres) { //it's also in the StripText(), so we have a valid search result item now
+ if (sres) { //it's also in the stripText(), so we have a valid search result item now
*resultKey = *getKey();
resultKey->clearBound();
listKey << *resultKey;
@@ -655,7 +631,7 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
int loopCount = 0;
unsigned int foundWords = 0;
do {
- textBuf = ((loopCount == 0)&&(!specialStrips)) ? getRawEntry() : StripText();
+ textBuf = ((loopCount == 0)&&(!specialStrips)) ? getRawEntry() : stripText();
foundWords = 0;
for (unsigned int i = 0; i < words.size(); i++) {
@@ -680,7 +656,7 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
// entry attributes
case -3: {
- RenderText(); // force parse
+ renderText(); // force parse
AttributeTypeList &entryAttribs = getEntryAttributes();
AttributeTypeList::iterator i1Start, i1End;
AttributeList::iterator i2Start, i2End;
@@ -804,25 +780,32 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
break;
} // end switch
}
+ *lastKey = *getKey();
(*this)++;
}
// cleaup work
- if (searchType >= 0)
+ if (searchType >= 0) {
+#ifdef USECXX11REGEX
+ std::locale::global(oldLocale);
+#else
regfree(&preg);
+#endif
+ }
setKey(*saveKey);
- if (!saveKey->Persist())
+ if (!saveKey->isPersist())
delete saveKey;
if (searchKey)
delete searchKey;
delete resultKey;
+ delete lastKey;
listKey = TOP;
- processEntryAttributes(savePEA);
+ setProcessEntryAttributes(savePEA);
(*percent)(100, percentUserData);
@@ -833,7 +816,7 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
/******************************************************************************
- * SWModule::StripText() - calls all stripfilters on current text
+ * SWModule::stripText() - calls all stripfilters on current text
*
* ENT: buf - buf to massage instead of this modules current text
* len - max len of buf
@@ -841,29 +824,45 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
* RET: this module's text at current key location massaged by Strip filters
*/
-const char *SWModule::StripText(const char *buf, int len) {
- return RenderText(buf, len, false);
+const char *SWModule::stripText(const char *buf, int len) {
+ static SWBuf local;
+ local = renderText(buf, len, false);
+ return local.c_str();
+}
+
+
+/** SWModule::getRenderHeader() - Produces any header data which might be
+ * useful which associated with the processing done with this filter.
+ * A typical example is a suggested CSS style block for classed
+ * containers.
+ */
+const char *SWModule::getRenderHeader() const {
+ FilterList::const_iterator first = getRenderFilters().begin();
+ if (first != getRenderFilters().end()) {
+ return (*first)->getHeader();
+ }
+ return "";
}
/******************************************************************************
- * SWModule::RenderText - calls all renderfilters on current text
+ * SWModule::renderText - calls all renderfilters on current text
*
* ENT: buf - buffer to Render instead of current module position
*
- * RET: this module's text at current key location massaged by RenderText filters
+ * RET: this module's text at current key location massaged by renderText filters
*/
- const char *SWModule::RenderText(const char *buf, int len, bool render) {
+ SWBuf SWModule::renderText(const char *buf, int len, bool render) {
bool savePEA = isProcessEntryAttributes();
if (!buf) {
entryAttributes.clear();
}
else {
- processEntryAttributes(false);
+ setProcessEntryAttributes(false);
}
- static SWBuf local;
+ SWBuf local;
if (buf)
local = buf;
@@ -889,37 +888,37 @@ const char *SWModule::StripText(const char *buf, int len) {
tmpbuf = null;
}
- processEntryAttributes(savePEA);
+ setProcessEntryAttributes(savePEA);
return tmpbuf;
}
/******************************************************************************
- * SWModule::RenderText - calls all renderfilters on current text
+ * SWModule::renderText - calls all renderfilters on current text
*
* ENT: tmpKey - key to use to grab text
*
* RET: this module's text at current key location massaged by RenderFilers
*/
- const char *SWModule::RenderText(const SWKey *tmpKey) {
+SWBuf SWModule::renderText(const SWKey *tmpKey) {
SWKey *saveKey;
const char *retVal;
- if (!key->Persist()) {
- saveKey = CreateKey();
+ if (!key->isPersist()) {
+ saveKey = createKey();
*saveKey = *key;
}
else saveKey = key;
setKey(*tmpKey);
- retVal = RenderText();
+ retVal = renderText();
setKey(*saveKey);
- if (!saveKey->Persist())
+ if (!saveKey->isPersist())
delete saveKey;
return retVal;
@@ -927,35 +926,53 @@ const char *SWModule::StripText(const char *buf, int len) {
/******************************************************************************
- * SWModule::StripText - calls all StripTextFilters on current text
+ * SWModule::stripText - calls all StripTextFilters on current text
*
* ENT: tmpKey - key to use to grab text
*
* RET: this module's text at specified key location massaged by Strip filters
*/
-const char *SWModule::StripText(const SWKey *tmpKey) {
+const char *SWModule::stripText(const SWKey *tmpKey) {
SWKey *saveKey;
const char *retVal;
- if (!key->Persist()) {
- saveKey = CreateKey();
+ if (!key->isPersist()) {
+ saveKey = createKey();
*saveKey = *key;
}
else saveKey = key;
setKey(*tmpKey);
- retVal = StripText();
+ retVal = stripText();
setKey(*saveKey);
- if (!saveKey->Persist())
+ if (!saveKey->isPersist())
delete saveKey;
return retVal;
}
+/******************************************************************************
+ * SWModule::getBibliography -Returns bibliographic data for a module in the
+ * requested format
+ *
+ * ENT: bibFormat format of the bibliographic data
+ *
+ * RET: bibliographic data in the requested format as a string (BibTeX by default)
+ */
+
+SWBuf SWModule::ge