diff options
author | Roberto C. Sanchez <roberto@connexer.com> | 2014-03-29 10:53:49 -0400 |
---|---|---|
committer | Roberto C. Sanchez <roberto@connexer.com> | 2014-03-29 10:53:49 -0400 |
commit | 8c8aa6b07e595cfac56838b5964ab3e96051f1b2 (patch) | |
tree | da38e2c1979148dbd3b0c7b87f930746f5ba7f44 /src/modules/genbook | |
parent | 8d3fc864d094eeadc721f8e93436b37a5fab173e (diff) |
Imported Upstream version 1.5.7
Diffstat (limited to 'src/modules/genbook')
-rw-r--r-- | src/modules/genbook/rawgenbook/rawgenbook.cpp | 65 | ||||
-rw-r--r-- | src/modules/genbook/swgenbook.cpp | 2 |
2 files changed, 18 insertions, 49 deletions
diff --git a/src/modules/genbook/rawgenbook/rawgenbook.cpp b/src/modules/genbook/rawgenbook/rawgenbook.cpp index fab309f..4850509 100644 --- a/src/modules/genbook/rawgenbook/rawgenbook.cpp +++ b/src/modules/genbook/rawgenbook/rawgenbook.cpp @@ -13,7 +13,6 @@ #include <unistd.h> #endif -#include <string.h> #include <utilfuns.h> #include <rawgenbook.h> #include <rawstr.h> @@ -22,6 +21,8 @@ #define O_BINARY 0 #endif +SWORD_NAMESPACE_START + /****************************************************************************** * RawGenBook Constructor - Initializes data for instance of RawGenBook * @@ -35,7 +36,6 @@ RawGenBook::RawGenBook(const char *ipath, const char *iname, const char *idesc, int fileMode = O_RDWR; char *buf = new char [ strlen (ipath) + 20 ]; - entryBuf = 0; path = 0; stdstr(&path, ipath); @@ -66,43 +66,35 @@ RawGenBook::~RawGenBook() { if (path) delete [] path; - if (entryBuf) - delete [] entryBuf; } /****************************************************************************** - * RawGenBook::operator char * - Returns the correct verse when char * cast + * RawGenBook::getRawEntry - Returns the correct verse when char * cast * is requested * * RET: string buffer with verse */ -char *RawGenBook::getRawEntry() { +SWBuf &RawGenBook::getRawEntryBuf() { __u32 offset = 0; __u32 size = 0; TreeKeyIdx *key = 0; -#ifndef _WIN32_WCE try { -#endif key = SWDYNAMIC_CAST(TreeKeyIdx, (this->key)); -#ifndef _WIN32_WCE } catch ( ... ) {} -#endif if (!key) { key = (TreeKeyIdx *)CreateKey(); (*key) = *(this->key); } - if (entryBuf) - delete [] entryBuf; - int dsize; key->getUserData(&dsize); + entryBuf = ""; if (dsize > 7) { memcpy(&offset, key->getUserData(), 4); offset = swordtoarch32(offset); @@ -112,21 +104,16 @@ char *RawGenBook::getRawEntry() { entrySize = size; // support getEntrySize call - entryBuf = new char [ (size + 2) * FILTERPAD ]; - *entryBuf = 0; + entryBuf.setFillByte(0); + entryBuf.setSize(size); lseek(bdtfd->getFd(), offset, SEEK_SET); - read(bdtfd->getFd(), entryBuf, size); + read(bdtfd->getFd(), entryBuf.getRawData(), size); - rawFilter(entryBuf, size, key); + rawFilter(entryBuf, 0); // hack, decipher + rawFilter(entryBuf, key); - if (!isUnicode()) - RawStr::preptext(entryBuf); - } - else { - entryBuf = new char [2]; - entryBuf[0] = 0; - entryBuf[1] = 0; - entrySize = 0; +// if (!isUnicode()) + RawStr::prepText(entryBuf); } if (key != this->key) // free our key if we created a VerseKey @@ -136,17 +123,7 @@ char *RawGenBook::getRawEntry() { } - -#ifdef _MSC_VER -SWModule &RawGenBook::operator =(SW_POSITION p) { -#else -RawGenBook &RawGenBook::operator =(SW_POSITION p) { -#endif - SWModule::operator =(p); - return *this; -} - -SWModule &RawGenBook::setentry(const char *inbuf, long len) { +void RawGenBook::setEntry(const char *inbuf, long len) { __u32 offset = archtosword32(lseek(bdtfd->getFd(), 0, SEEK_END)); __u32 size = 0; @@ -164,27 +141,17 @@ SWModule &RawGenBook::setentry(const char *inbuf, long len) { memcpy(userData+4, &size, 4); key->setUserData(userData, 8); key->save(); - - return *this; -} - -SWModule &RawGenBook::operator <<(const char *inbuf) { - return setentry(inbuf, 0); } -SWModule &RawGenBook::operator <<(const SWKey *inkey) { +void RawGenBook::linkEntry(const SWKey *inkey) { TreeKeyIdx *srckey = 0; TreeKeyIdx *key = ((TreeKeyIdx *)this->key); // see if we have a VerseKey * or decendant -#ifndef _WIN32_WCE try { -#endif srckey = SWDYNAMIC_CAST(TreeKeyIdx, inkey); -#ifndef _WIN32_WCE } catch ( ... ) {} -#endif // if we don't have a VerseKey * decendant, create our own if (!srckey) { srckey = (TreeKeyIdx *)CreateKey(); @@ -196,8 +163,6 @@ SWModule &RawGenBook::operator <<(const SWKey *inkey) { if (inkey != srckey) // free our key if we created a VerseKey delete srckey; - - return *this; } @@ -240,3 +205,5 @@ SWKey *RawGenBook::CreateKey() { TreeKeyIdx *newKey = new TreeKeyIdx(path); return newKey; } + +SWORD_NAMESPACE_END diff --git a/src/modules/genbook/swgenbook.cpp b/src/modules/genbook/swgenbook.cpp index 589b0b9..3381ef8 100644 --- a/src/modules/genbook/swgenbook.cpp +++ b/src/modules/genbook/swgenbook.cpp @@ -5,6 +5,7 @@ #include <swgenbook.h> +SWORD_NAMESPACE_START /****************************************************************************** * SWLD Constructor - Initializes data for instance of SWLD @@ -25,3 +26,4 @@ SWGenBook::SWGenBook(const char *imodname, const char *imoddesc, SWDisplay *idis SWGenBook::~SWGenBook() { } +SWORD_NAMESPACE_END |