[sword-svn] r2240 - in trunk: . include src/mgr src/modules/comments/rawfiles src/modules/common src/modules/lexdict/rawld src/modules/lexdict/rawld4
scribe at crosswire.org
scribe at crosswire.org
Sat Feb 7 17:47:44 MST 2009
Author: scribe
Date: 2009-02-07 17:47:44 -0700 (Sat, 07 Feb 2009)
New Revision: 2240
Modified:
trunk/ChangeLog
trunk/include/rawstr.h
trunk/include/rawstr4.h
trunk/include/swmgr.h
trunk/src/mgr/swmgr.cpp
trunk/src/modules/comments/rawfiles/rawfiles.cpp
trunk/src/modules/common/rawstr.cpp
trunk/src/modules/common/rawstr4.cpp
trunk/src/modules/common/rawverse.cpp
trunk/src/modules/common/rawverse4.cpp
trunk/src/modules/common/zstr.cpp
trunk/src/modules/common/zverse.cpp
trunk/src/modules/lexdict/rawld/rawld.cpp
trunk/src/modules/lexdict/rawld4/rawld4.cpp
Log:
Universally cleaned up numeric read/writes with datafiles
Added basic concession lookup for $ALLUSERSPROFILE/Application Data/
Fixed personal home lookup on windoze to use non-posix $HOMEDRIVE$HOMEPATH
Added concession to try ~/sword (after ~/.sword)
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-02-07 08:50:09 UTC (rev 2239)
+++ trunk/ChangeLog 2009-02-08 00:47:44 UTC (rev 2240)
@@ -1,5 +1,15 @@
API ChangeLog
+07-Feb-2008 Troy A. Griffitts <scribe at crosswire.org>
+ Added fallback checks for OS specific module
+ locations:
+ $ALLUSERSPROFILE/Application Data/sword
+
+ ~ additionally looked for at:
+ $HOMEDRIVE$HOMEPATH/Application Data
+
+ added ~/sword (note the absense of '.')
+
26-Dec-2008 Troy A. Griffitts <scribe at crosswire.org>
Added list support in OSIS HTML conversion (ghellings)
Modified: trunk/include/rawstr.h
===================================================================
--- trunk/include/rawstr.h 2009-02-07 08:50:09 UTC (rev 2239)
+++ trunk/include/rawstr.h 2009-02-08 00:47:44 UTC (rev 2240)
@@ -26,6 +26,7 @@
#define RAWSTR_H
#include <defs.h>
+#include <sysdata.h>
SWORD_NAMESPACE_START
@@ -48,8 +49,8 @@
virtual ~RawStr();
void getIDXBuf(long ioffset, char **buf);
void getIDXBufDat(long ioffset, char **buf);
- signed char findOffset(const char *key, long *start, unsigned short *size, long away = 0, long *idxoff = 0);
- void readText(long start, unsigned short *size, char **idxbuf, SWBuf &buf);
+ signed char findOffset(const char *key, __u32 *start, __u16 *size, long away = 0, __u32 *idxoff = 0);
+ void readText(__u32 start, __u16 *size, char **idxbuf, SWBuf &buf);
static signed char createModule(const char *path);
};
Modified: trunk/include/rawstr4.h
===================================================================
--- trunk/include/rawstr4.h 2009-02-07 08:50:09 UTC (rev 2239)
+++ trunk/include/rawstr4.h 2009-02-08 00:47:44 UTC (rev 2240)
@@ -26,6 +26,7 @@
#define RAWSTR4_H
#include <defs.h>
+#include <sysdata.h>
SWORD_NAMESPACE_START
@@ -48,9 +49,8 @@
virtual ~RawStr4();
void getIDXBuf(long ioffset, char **buf);
void getIDXBufDat(long ioffset, char **buf);
- signed char findOffset(const char *key, long *start, unsigned long *size,
- long away = 0, long *idxoff = 0);
- void readText(long start, unsigned long *size, char **idxbuf, SWBuf &buf);
+ signed char findOffset(const char *key, __u32 *start, __u32 *size, long away = 0, __u32 *idxoff = 0);
+ void readText(__u32 start, __u32 *size, char **idxbuf, SWBuf &buf);
static signed char createModule(const char *path);
};
Modified: trunk/include/swmgr.h
===================================================================
--- trunk/include/swmgr.h 2009-02-07 08:50:09 UTC (rev 2239)
+++ trunk/include/swmgr.h 2009-02-08 00:47:44 UTC (rev 2240)
@@ -157,6 +157,7 @@
static bool isICU;
static const char *globalConfPath;
+ static SWBuf getHomeDir();
/**
*
Modified: trunk/src/mgr/swmgr.cpp
===================================================================
--- trunk/src/mgr/swmgr.cpp 2009-02-07 08:50:09 UTC (rev 2239)
+++ trunk/src/mgr/swmgr.cpp 2009-02-08 00:47:44 UTC (rev 2240)
@@ -245,10 +245,31 @@
teiplain = new TEIPlain();
cleanupFilters.push_back(teiplain);
-//#endif
}
+SWBuf SWMgr::getHomeDir() {
+
+ // figure out 'home' directory for app data
+ SWBuf homeDir = getenv("HOME");
+ if (!homeDir.length()) {
+ // silly windows
+ homeDir = getenv("HOMEDRIVE");
+ if (homeDir.length()) {
+ homeDir += getenv("HOMEPATH");
+ homeDir += "/Application Data";
+ }
+ }
+ if (homeDir.length()) {
+ if ((homeDir[homeDir.length()-1] != '\\') && (homeDir[homeDir.length()-1] != '/')) {
+ homeDir += "/";
+ }
+ }
+
+ return homeDir;
+}
+
+
void SWMgr::commonInit(SWConfig *iconfig, SWConfig *isysconfig, bool autoload, SWFilterMgr *filterMgr, bool multiMod) {
init();
@@ -356,12 +377,12 @@
ConfigEntMap::iterator entry;
ConfigEntMap::iterator lastEntry;
- char *envsworddir = getenv("SWORD_PATH");
- char *envhomedir = getenv("HOME");
SWConfig *sysConf = 0;
*configType = 0;
+ SWBuf homeDir = getHomeDir();
+
// check for a sysConf passed in to us
SWLog::getSystemLog()->logDebug("Checking for provided SWConfig(\"sword.conf\")...");
if (providedSysConf) {
@@ -404,13 +425,14 @@
}
// check environment variable SWORD_PATH
- SWLog::getSystemLog()->logDebug("Checking SWORD_PATH...");
+ SWLog::getSystemLog()->logDebug("Checking $SWORD_PATH...");
- if (envsworddir != NULL) {
+ SWBuf envsworddir = getenv("SWORD_PATH");
+ if (envsworddir.length()) {
- SWLog::getSystemLog()->logDebug("found (%s).", envsworddir);
+ SWLog::getSystemLog()->logDebug("found (%s).", envsworddir.c_str());
path = envsworddir;
- if ((envsworddir[strlen(envsworddir)-1] != '\\') && (envsworddir[strlen(envsworddir)-1] != '/'))
+ if ((envsworddir[envsworddir.length()-1] != '\\') && (envsworddir[envsworddir.length()-1] != '/'))
path += "/";
SWLog::getSystemLog()->logDebug("Checking $SWORD_PATH for mods.conf...");
@@ -451,15 +473,21 @@
sysConfPath = gfp;
delete [] globPaths;
- SWBuf homeDir = envhomedir;
- if (homeDir.size() > 0) {
- if ((homeDir[homeDir.size()-1] != '\\') && (homeDir[homeDir.size()-1] != '/'))
- homeDir += "/";
- homeDir += ".sword/sword.conf";
- if (FileMgr::existsFile(homeDir)) {
- SWLog::getSystemLog()->logDebug("Overriding any systemwide sword.conf with one found in users home directory.");
- sysConfPath = homeDir;
+ if (homeDir.length()) {
+ SWBuf tryPath = homeDir;
+ tryPath += ".sword/sword.conf";
+ if (FileMgr::existsFile(tryPath)) {
+ SWLog::getSystemLog()->logDebug("Overriding any systemwide sword.conf with one found in users home directory (%s)", tryPath.c_str());
+ sysConfPath = tryPath;
}
+ else {
+ SWBuf tryPath = homeDir;
+ tryPath += "sword/sword.conf";
+ if (FileMgr::existsFile(tryPath)) {
+ SWLog::getSystemLog()->logDebug("Overriding any systemwide sword.conf with one found in users home directory (%s)", tryPath.c_str());
+ sysConfPath = tryPath;
+ }
+ }
}
}
}
@@ -515,14 +543,40 @@
if (*configType)
return;
+ // WE STILL HAVEN'T FOUND A CONFIGURATION. LET'S LOOK IN SOME OS SPECIFIC
+ // LOCATIONS
+ //
+ // for various flavors of windoze...
+ // check %ALLUSERSPROFILE%/Application Data/sword/
+
+ SWLog::getSystemLog()->logDebug("Checking $ALLUSERSPROFILE/Application Data/sword/...");
+
+ SWBuf envallusersdir = getenv("ALLUSERSPROFILE");
+ if (envallusersdir != NULL) {
+ SWLog::getSystemLog()->logDebug("found (%s).", envallusersdir.c_str());
+ path = envallusersdir;
+ if ((envallusersdir[envallusersdir.length()-1] != '\\') && (envallusersdir[envallusersdir.length()-1] != '/'))
+ path += "/";
+
+ SWLog::getSystemLog()->logDebug("Checking $ALLUSERSPROFILE for mods.d...");
+ if (FileMgr::existsDir(path.c_str(), "mods.d")) {
+ SWLog::getSystemLog()->logDebug("found.");
+ stdstr(prefixPath, path.c_str());
+ path += "mods.d";
+ stdstr(configPath, path.c_str());
+ *configType = 1;
+ return;
+ }
+ }
+
+
+ // FINALLY CHECK PERSONAL HOME DIRECTORY LOCATIONS
// check ~/.sword/
SWLog::getSystemLog()->logDebug("Checking home directory for ~/.sword...");
- if (envhomedir != NULL) {
- path = envhomedir;
- if ((envhomedir[strlen(envhomedir)-1] != '\\') && (envhomedir[strlen(envhomedir)-1] != '/'))
- path += "/";
+ if (homeDir.length()) {
+ path = homeDir;
path += ".sword/";
SWLog::getSystemLog()->logDebug(" Checking for %smods.conf...", path.c_str());
if (FileMgr::existsFile(path.c_str(), "mods.conf")) {
@@ -542,6 +596,18 @@
*configType = 2;
return;
}
+
+ path = homeDir;
+ path += "sword/";
+ SWLog::getSystemLog()->logDebug(" Checking for %smods.d...", path.c_str());
+ if (FileMgr::existsDir(path.c_str(), "mods.d")) {
+ SWLog::getSystemLog()->logDebug("found.");
+ stdstr(prefixPath, path.c_str());
+ path += "mods.d";
+ stdstr(configPath, path.c_str());
+ *configType = 2;
+ return;
+ }
}
}
@@ -685,17 +751,18 @@
}
if (augmentHome) {
// augment config with ~/.sword/mods.d if it exists ---------------------
- char *envhomedir = getenv("HOME");
- if (envhomedir != NULL && configType != 2) { // 2 = user only
- SWBuf path = envhomedir;
- if ((envhomedir[strlen(envhomedir)-1] != '\\') && (envhomedir[strlen(envhomedir)-1] != '/'))
- path += "/";
+ SWBuf homeDir = getHomeDir();
+ if (homeDir.length() && configType != 2) { // 2 = user only
+ SWBuf path = homeDir;
path += ".sword/";
augmentModules(path.c_str(), mgrModeMultiMod);
+ path = homeDir;
+ path += "sword/";
+ augmentModules(path.c_str(), mgrModeMultiMod);
}
}
// -------------------------------------------------------------------------
- if ( !Modules.size() ) // config exists, but no modules
+ if (!Modules.size()) // config exists, but no modules
ret = 1;
}
Modified: trunk/src/modules/comments/rawfiles/rawfiles.cpp
===================================================================
--- trunk/src/modules/comments/rawfiles/rawfiles.cpp 2009-02-07 08:50:09 UTC (rev 2239)
+++ trunk/src/modules/comments/rawfiles/rawfiles.cpp 2009-02-08 00:47:44 UTC (rev 2240)
@@ -28,6 +28,7 @@
#include <rawfiles.h>
#include <filemgr.h>
#include <versekey.h>
+#include <sysdata.h>
SWORD_NAMESPACE_START
@@ -235,32 +236,40 @@
char *RawFiles::getNextFilename() {
static char incfile[255];
- long number;
+ __u32 number;
FileDesc *datafile;
sprintf(incfile, "%s/incfile", path);
datafile = FileMgr::getSystemFileMgr()->open(incfile, FileMgr::RDONLY);
- if (datafile->read(&number, 4) != 4)
- number = 0;
+
+ 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);
+
+ number = archtosword32(number);
datafile->write(&number, 4);
+
FileMgr::getSystemFileMgr()->close(datafile);
- sprintf(incfile, "%.7ld", number-1);
return incfile;
}
char RawFiles::createModule (const char *path) {
char *incfile = new char [ strlen (path) + 16 ];
- static long zero = 0;
+
+ __u32 zero = 0;
+ zero = archtosword32(zero);
+
FileDesc *datafile;
sprintf(incfile, "%s/incfile", path);
datafile = FileMgr::getSystemFileMgr()->open(incfile, FileMgr::CREAT|FileMgr::WRONLY|FileMgr::TRUNC);
- delete [] incfile;
+ delete [] incfile;
datafile->write(&zero, 4);
FileMgr::getSystemFileMgr()->close(datafile);
Modified: trunk/src/modules/common/rawstr.cpp
===================================================================
--- trunk/src/modules/common/rawstr.cpp 2009-02-07 08:50:09 UTC (rev 2239)
+++ trunk/src/modules/common/rawstr.cpp 2009-02-08 00:47:44 UTC (rev 2240)
@@ -139,7 +139,7 @@
void RawStr::getIDXBuf(long ioffset, char **buf)
{
- long offset;
+ __u32 offset;
if (idxfd > 0) {
idxfd->seek(ioffset, SEEK_SET);
@@ -164,7 +164,7 @@
* RET: error status -1 general error; -2 new file
*/
-signed char RawStr::findOffset(const char *ikey, long *start, unsigned short *size, long away, long *idxoff)
+signed char RawStr::findOffset(const char *ikey, __u32 *start, __u16 *size, long away, __u32 *idxoff)
{
char *trybuf, *maxbuf, *key = 0, quitflag = 0;
signed char retval = -1;
@@ -231,14 +231,16 @@
idxfd->seek(tryoff, SEEK_SET);
- *start = *size = 0;
- idxfd->read(start, 4);
- idxfd->read(size, 2);
+ __u32 tmpStart;
+ __u16 tmpSize;
+ *start = *size = tmpStart = tmpSize = 0;
+ idxfd->read(&tmpStart, 4);
+ idxfd->read(&tmpSize, 2);
if (idxoff)
*idxoff = tryoff;
- *start = swordtoarch32(*start);
- *size = swordtoarch16(*size);
+ *start = swordtoarch32(tmpStart);
+ *size = swordtoarch16(tmpSize);
while (away) {
long laststart = *start;
@@ -260,13 +262,13 @@
*idxoff = tryoff;
break;
}
- idxfd->read(start, 4);
- idxfd->read(size, 2);
+ idxfd->read(&tmpStart, 4);
+ idxfd->read(&tmpSize, 2);
if (idxoff)
*idxoff = tryoff;
- *start = swordtoarch32(*start);
- *size = swordtoarch16(*size);
+ *start = swordtoarch32(tmpStart);
+ *size = swordtoarch16(tmpSize);
if (((laststart != *start) || (lastsize != *size)) && (*start >= 0) && (*size))
away += (away < 0) ? 1 : -1;
@@ -295,12 +297,12 @@
*
*/
-void RawStr::readText(long istart, unsigned short *isize, char **idxbuf, SWBuf &buf)
+void RawStr::readText(__u32 istart, __u16 *isize, char **idxbuf, SWBuf &buf)
{
unsigned int ch;
char *idxbuflocal = 0;
getIDXBufDat(istart, &idxbuflocal);
- long start = istart;
+ __u32 start = istart;
do {
if (*idxbuf)
@@ -357,12 +359,12 @@
void RawStr::doSetText(const char *ikey, const char *buf, long len)
{
- long start, outstart;
- long idxoff;
- long endoff;
- long shiftSize;
- unsigned short size;
- unsigned short outsize;
+ __u32 start, outstart;
+ __u32 idxoff;
+ __u32 endoff;
+ __u32 shiftSize;
+ __u16 size;
+ __u16 outsize;
static const char nl[] = {13, 10};
char *tmpbuf = 0;
char *key = 0;
Modified: trunk/src/modules/common/rawstr4.cpp
===================================================================
--- trunk/src/modules/common/rawstr4.cpp 2009-02-07 08:50:09 UTC (rev 2239)
+++ trunk/src/modules/common/rawstr4.cpp 2009-02-08 00:47:44 UTC (rev 2240)
@@ -139,12 +139,12 @@
void RawStr4::getIDXBuf(long ioffset, char **buf)
{
- long offset;
+ __u32 offset;
if (idxfd > 0) {
idxfd->seek(ioffset, SEEK_SET);
+
idxfd->read(&offset, 4);
-
offset = swordtoarch32(offset);
getIDXBufDat(offset, buf);
@@ -173,7 +173,7 @@
* RET: error status -1 general error; -2 new file
*/
-signed char RawStr4::findOffset(const char *ikey, long *start, unsigned long *size, long away, long *idxoff)
+signed char RawStr4::findOffset(const char *ikey, __u32 *start, __u32 *size, long away, __u32 *idxoff)
{
char *trybuf, *maxbuf, *key = 0, quitflag = 0;
signed char retval = -1;
@@ -240,14 +240,15 @@
idxfd->seek(tryoff, SEEK_SET);
- *start = *size = 0;
- idxfd->read(start, 4);
- idxfd->read(size, 4);
+ __u32 tmpStart, tmpSize;
+ *start = *size = tmpStart = tmpSize = 0;
+ idxfd->read(&tmpStart, 4);
+ idxfd->read(&tmpSize, 4);
if (idxoff)
*idxoff = tryoff;
- *start = swordtoarch32(*start);
- *size = swordtoarch32(*size);
+ *start = swordtoarch32(tmpStart);
+ *size = swordtoarch32(tmpSize);
while (away) {
long laststart = *start;
@@ -269,13 +270,13 @@
*idxoff = tryoff;
break;
}
- idxfd->read(start, 4);
- idxfd->read(size, 4);
+ idxfd->read(&tmpStart, 4);
+ idxfd->read(&tmpSize, 4);
if (idxoff)
*idxoff = tryoff;
- *start = swordtoarch32(*start);
- *size = swordtoarch32(*size);
+ *start = swordtoarch32(tmpStart);
+ *size = swordtoarch32(tmpSize);
if (((laststart != *start) || (lastsize != *size)) && (*start >= 0) && (*size))
away += (away < 0) ? 1 : -1;
@@ -304,12 +305,12 @@
*
*/
-void RawStr4::readText(long istart, unsigned long *isize, char **idxbuf, SWBuf &buf)
+void RawStr4::readText(__u32 istart, __u32 *isize, char **idxbuf, SWBuf &buf)
{
unsigned int ch;
char *idxbuflocal = 0;
getIDXBufDat(istart, &idxbuflocal);
- long start = istart;
+ __u32 start = istart;
do {
if (*idxbuf)
@@ -365,12 +366,12 @@
void RawStr4::doSetText(const char *ikey, const char *buf, long len) {
- long start, outstart;
- long idxoff;
- long endoff;
- long shiftSize;
- unsigned long size;
- unsigned long outsize;
+ __u32 start, outstart;
+ __u32 idxoff;
+ __u32 endoff;
+ __u32 shiftSize;
+ __u32 size;
+ __u32 outsize;
static const char nl[] = {13, 10};
char *tmpbuf = 0;
char *key = 0;
Modified: trunk/src/modules/common/rawverse.cpp
===================================================================
--- trunk/src/modules/common/rawverse.cpp 2009-02-07 08:50:09 UTC (rev 2239)
+++ trunk/src/modules/common/rawverse.cpp 2009-02-08 00:47:44 UTC (rev 2240)
@@ -120,11 +120,13 @@
if (idxfp[testmt-1]->getFd() >= 0) {
idxfp[testmt-1]->seek(idxoff, SEEK_SET);
- idxfp[testmt-1]->read(start, 4);
- long len = idxfp[testmt-1]->read(size, 2); // read size
+ __s32 tmpStart;
+ __u16 tmpSize;
+ idxfp[testmt-1]->read(&tmpStart, 4);
+ long len = idxfp[testmt-1]->read(&tmpSize, 2); // read size
- *start = swordtoarch32(*start);
- *size = swordtoarch16(*size);
+ *start = swordtoarch32(tmpStart);
+ *size = swordtoarch16(tmpSize);
if (len < 2) {
*size = (unsigned short)((*start) ? (textfp[testmt-1]->seek(0, SEEK_END) - (long)*start) : 0); // if for some reason we get an error reading size, make size to end of file
@@ -173,17 +175,16 @@
void RawVerse::doSetText(char testmt, long idxoff, const char *buf, long len)
{
- long start, outstart;
- unsigned short size;
- unsigned short outsize;
+ __s32 start;
+ __u16 size;
idxoff *= 6;
if (!testmt)
testmt = ((idxfp[1]) ? 1:2);
- size = outsize = (len < 0) ? strlen(buf) : len;
+ size = (len < 0) ? strlen(buf) : len;
- start = outstart = textfp[testmt-1]->seek(0, SEEK_END);
+ start = textfp[testmt-1]->seek(0, SEEK_END);
idxfp[testmt-1]->seek(idxoff, SEEK_SET);
if (size) {
@@ -197,13 +198,11 @@
start = 0;
}
- outstart = archtosword32(start);
- outsize = archtosword16(size);
+ start = archtosword32(start);
+ size = archtosword16(size);
- idxfp[testmt-1]->write(&outstart, 4);
- idxfp[testmt-1]->write(&outsize, 2);
-
-
+ idxfp[testmt-1]->write(&start, 4);
+ idxfp[testmt-1]->write(&size, 2);
}
@@ -216,8 +215,8 @@
*/
void RawVerse::doLinkEntry(char testmt, long destidxoff, long srcidxoff) {
- long start;
- unsigned short size;
+ __s32 start;
+ __u16 size;
destidxoff *= 6;
srcidxoff *= 6;
@@ -279,8 +278,12 @@
VerseKey vk;
vk.Headings(1);
- long offset = 0;
- short size = 0;
+
+ __s32 offset = 0;
+ __u16 size = 0;
+ offset = archtosword32(offset);
+ size = archtosword16(size);
+
for (vk = TOP; !vk.Error(); vk++) {
if (vk.Testament() == 1) {
fd->write(&offset, 4);
Modified: trunk/src/modules/common/rawverse4.cpp
===================================================================
--- trunk/src/modules/common/rawverse4.cpp 2009-02-07 08:50:09 UTC (rev 2239)
+++ trunk/src/modules/common/rawverse4.cpp 2009-02-08 00:47:44 UTC (rev 2240)
@@ -120,11 +120,13 @@
if (idxfp[testmt-1]->getFd() >= 0) {
idxfp[testmt-1]->seek(idxoff, SEEK_SET);
- idxfp[testmt-1]->read(start, 4);
- long len = idxfp[testmt-1]->read(size, 4); // read size
+ __u32 tmpStart;
+ __u32 tmpSize;
+ idxfp[testmt-1]->read(&tmpStart, 4);
+ long len = idxfp[testmt-1]->read(&tmpSize, 4); // read size
- *start = swordtoarch32(*start);
- *size = swordtoarch32(*size);
+ *start = swordtoarch32(tmpStart);
+ *size = swordtoarch32(tmpSize);
if (len < 2) {
*size = (unsigned long)((*start) ? (textfp[testmt-1]->seek(0, SEEK_END) - (long)*start) : 0); // if for some reason we get an error reading size, make size to end of file
@@ -173,17 +175,16 @@
void RawVerse4::doSetText(char testmt, long idxoff, const char *buf, long len)
{
- long start, outstart;
- unsigned long size;
- unsigned long outsize;
+ __u32 start;
+ __u32 size;
idxoff *= 8;
if (!testmt)
testmt = ((idxfp[1]) ? 1:2);
- size = outsize = (len < 0) ? strlen(buf) : len;
+ size = (len < 0) ? strlen(buf) : len;
- start = outstart = textfp[testmt-1]->seek(0, SEEK_END);
+ start = textfp[testmt-1]->seek(0, SEEK_END);
idxfp[testmt-1]->seek(idxoff, SEEK_SET);
if (size) {
@@ -197,13 +198,11 @@
start = 0;
}
- outstart = archtosword32(start);
- outsize = archtosword32(size);
+ start = archtosword32(start);
+ size = archtosword32(size);
- idxfp[testmt-1]->write(&outstart, 4);
- idxfp[testmt-1]->write(&outsize, 4);
-
-
+ idxfp[testmt-1]->write(&start, 4);
+ idxfp[testmt-1]->write(&size, 4);
}
@@ -216,8 +215,8 @@
*/
void RawVerse4::doLinkEntry(char testmt, long destidxoff, long srcidxoff) {
- long start;
- unsigned long size;
+ __u32 start;
+ __u32 size;
destidxoff *= 8;
srcidxoff *= 8;
@@ -279,8 +278,11 @@
VerseKey vk;
vk.Headings(1);
- long offset = 0;
- long size = 0;
+ __u32 offset = 0;
+ __u32 size = 0;
+ offset = archtosword32(offset);
+ size = archtosword32(size);
+
for (vk = TOP; !vk.Error(); vk++) {
if (vk.Testament() == 1) {
fd->write(&offset, 4);
Modified: trunk/src/modules/common/zstr.cpp
===================================================================
--- trunk/src/modules/common/zstr.cpp 2009-02-07 08:50:09 UTC (rev 2239)
+++ trunk/src/modules/common/zstr.cpp 2009-02-08 00:47:44 UTC (rev 2240)
@@ -166,7 +166,7 @@
if (idxfd > 0) {
idxfd->seek(ioffset, SEEK_SET);
- idxfd->read(&offset, sizeof(__u32));
+ idxfd->read(&offset, 4);
offset = swordtoarch32(offset);
getKeyFromDatOffset(offset, buf);
}
@@ -251,8 +251,8 @@
idxfd->seek(tryoff, SEEK_SET);
start = size = 0;
- retval = (idxfd->read(&start, sizeof(__u32))==sizeof(__u32)) ? retval : -1;
- retval = (idxfd->read(&size, sizeof(__u32))==sizeof(__u32)) ? retval : -1;
+ retval = (idxfd->read(&start, 4) == 4) ? retval : -1;
+ retval = (idxfd->read(&size, 4) == 4) ? retval : -1;
start = swordtoarch32(start);
size = swordtoarch32(size);
@@ -279,8 +279,8 @@
*idxoff = tryoff;
break;
}
- idxfd->read(&start, sizeof(__u32));
- idxfd->read(&size, sizeof(__u32));
+ idxfd->read(&start, 4);
+ idxfd->read(&size, 4);
start = swordtoarch32(start);
size = swordtoarch32(size);
@@ -324,8 +324,8 @@
do {
idxfd->seek(offset, SEEK_SET);
- idxfd->read(&start, sizeof(__u32));
- idxfd->read(&size, sizeof(__u32));
+ idxfd->read(&start, 4);
+ idxfd->read(&size, 4);
start = swordtoarch32(start);
size = swordtoarch32(size);
@@ -388,8 +388,8 @@
__u32 start = 0;
zdxfd->seek(block * ZDXENTRYSIZE, SEEK_SET);
- zdxfd->read(&start, sizeof(__u32));
- zdxfd->read(&size, sizeof(__u32));
+ zdxfd->read(&start, 4);
+ zdxfd->read(&size, 4);
start = swordtoarch32(start);
size = swordtoarch32(size);
@@ -454,8 +454,8 @@
else if ((!diff) && (len > 0 /*we're not deleting*/)) { // got absolute entry
do {
idxfd->seek(idxoff, SEEK_SET);
- idxfd->read(&start, sizeof(__u32));
- idxfd->read(&size, sizeof(__u32));
+ idxfd->read(&start, 4);
+ idxfd->read(&size, 4);
start = swordtoarch32(start);
size = swordtoarch32(size);
@@ -539,8 +539,8 @@
// add a new line to make data file easier to read in an editor
datfd->write(&nl, 2);
- idxfd->write(&outstart, sizeof(__u32));
- idxfd->write(&outsize, sizeof(__u32));
+ idxfd->write(&outstart, 4);
+ idxfd->write(&outsize, 4);
if (idxBytes) {
idxfd->write(idxBytes, shiftSize);
}
@@ -602,8 +602,8 @@
}
else {
zdxfd->seek(cacheBlockIndex * ZDXENTRYSIZE, SEEK_SET);
- zdxfd->read(&start, sizeof(__u32));
- zdxfd->read(&outsize, sizeof(__u32));
+ zdxfd->read(&start, 4);
+ zdxfd->read(&outsize, 4);
start = swordtoarch32(start);
outsize = swordtoarch32(outsize);
if (start + outsize >= zdtSize) { // last entry, just overwrite
@@ -629,8 +629,8 @@
// add a new line to make data file easier to read in an editor
zdtfd->write(&nl, 2);
- zdxfd->write(&outstart, sizeof(__u32));
- zdxfd->write(&outsize, sizeof(__u32));
+ zdxfd->write(&outstart, 4);
+ zdxfd->write(&outsize, 4);
}
delete cacheBlock;
cacheBlock = 0;
Modified: trunk/src/modules/common/zverse.cpp
===================================================================
--- trunk/src/modules/common/zverse.cpp 2009-02-07 08:50:09 UTC (rev 2239)
+++ trunk/src/modules/common/zverse.cpp 2009-02-08 00:47:44 UTC (rev 2240)
@@ -151,12 +151,12 @@
// set start to offset in
// set size to
// set
- unsigned long ulBuffNum=0; // buffer number
- unsigned long ulVerseStart=0; // verse offset within buffer
- unsigned short usVerseSize=0; // verse size
- unsigned long ulCompOffset=0; // compressed buffer start
- unsigned long ulCompSize=0; // buffer size compressed
- unsigned long ulUnCompSize=0; // buffer size uncompressed
+ __u32 ulBuffNum = 0; // buffer number
+ __u32 ulVerseStart = 0; // verse offset within buffer
+ __u16 usVerseSize = 0; // verse size
+ __u32 ulCompOffset = 0; // compressed buffer start
+ __u32 ulCompSize = 0; // buffer size compressed
+ __u32 ulUnCompSize = 0; // buffer size uncompressed
*start = *size = 0;
//printf ("Finding offset %ld\n", idxoff);
@@ -243,7 +243,8 @@
pcCompText.setSize(ulCompSize);
rawZFilter(pcCompText, 0); // 0 = decipher
- compressor->zBuf(&ulCompSize, pcCompText.getRawData());
+ unsigned long bufSize = ulCompSize;
+ compressor->zBuf(&bufSize, pcCompText.getRawData());
if (cacheBuf) {
flushCache();
@@ -307,13 +308,12 @@
dirtyCache = true;
- unsigned long start, outstart;
- unsigned long outBufIdx = cacheBufIdx;
- unsigned short size;
- unsigned short outsize;
+ __u32 start;
+ __u16 size;
+ __u32 outBufIdx = cacheBufIdx;
idxoff *= 10;
- size = outsize = len;
+ size = len;
start = strlen(cacheBuf);
@@ -321,23 +321,23 @@
start = outBufIdx = 0;
outBufIdx = archtosword32(outBufIdx);
- outstart = archtosword32(start);
- outsize = archtosword16(size);
+ start = archtosword32(start);
+ size = archtosword16(size);
compfp[testmt-1]->seek(idxoff, SEEK_SET);
compfp[testmt-1]->write(&outBufIdx, 4);
- compfp[testmt-1]->write(&outstart, 4);
- compfp[testmt-1]->write(&outsize, 2);
+ compfp[testmt-1]->write(&start, 4);
+ compfp[testmt-1]->write(&size, 2);
strcat(cacheBuf, buf);
}
void zVerse::flushCache() {
if (dirtyCache) {
- unsigned long idxoff;
- unsigned long start, outstart;
- unsigned long size, outsize;
- unsigned long zsize, outzsize;
+ __u32 idxoff;
+ __u32 start, outstart;
+ __u32 size, outsize;
+ __u32 zsize, outzsize;
idxoff = cacheBufIdx * 12;
if (cacheBuf) {
@@ -348,12 +348,14 @@
// compressor = new LZSSCompress();
// }
compressor->Buf(cacheBuf);
- compressor->zBuf(&zsize);
- outzsize = zsize;
+ unsigned long tmpSize;
+ compressor->zBuf(&tmpSize);
+ outzsize = zsize = tmpSize;
SWBuf buf;
buf.setSize(zsize + 5);
- memcpy(buf.getRawData(), compressor->zBuf(&zsize), zsize);
+ memcpy(buf.getRawData(), compressor->zBuf(&tmpSize), tmpSize);
+ outzsize = zsize = tmpSize;
buf.setSize(zsize);
rawZFilter(buf, 1); // 1 = encipher
@@ -386,9 +388,9 @@
*/
void zVerse::doLinkEntry(char testmt, long destidxoff, long srcidxoff) {
- long bufidx;
- long start;
- unsigned short size;
+ __s32 bufidx;
+ __s32 start;
+ __u16 size;
destidxoff *= 10;
srcidxoff *= 10;
@@ -464,8 +466,12 @@
VerseKey vk;
vk.Headings(1);
- long offset = 0;
- short size = 0;
+
+ __s32 offset = 0;
+ __s16 size = 0;
+ offset = archtosword32(offset);
+ size = archtosword16(size);
+
for (vk = TOP; !vk.Error(); vk++) {
if (vk.Testament() == 1) {
fd->write(&offset, 4); //compBufIdxOffset
@@ -484,10 +490,6 @@
delete [] path;
delete [] buf;
-/*
- RawVerse rv(path);
- VerseKey mykey("Rev 22:21");
-*/
return 0;
}
Modified: trunk/src/modules/lexdict/rawld/rawld.cpp
===================================================================
--- trunk/src/modules/lexdict/rawld/rawld.cpp 2009-02-07 08:50:09 UTC (rev 2239)
+++ trunk/src/modules/lexdict/rawld/rawld.cpp 2009-02-08 00:47:44 UTC (rev 2240)
@@ -113,8 +113,8 @@
char RawLD::getEntry(long away)
{
- long start = 0;
- unsigned short size = 0;
+ __u32 start = 0;
+ __u16 size = 0;
char *idxbuf = 0;
char retval = 0;
Modified: trunk/src/modules/lexdict/rawld4/rawld4.cpp
===================================================================
--- trunk/src/modules/lexdict/rawld4/rawld4.cpp 2009-02-07 08:50:09 UTC (rev 2239)
+++ trunk/src/modules/lexdict/rawld4/rawld4.cpp 2009-02-08 00:47:44 UTC (rev 2240)
@@ -113,10 +113,10 @@
char RawLD4::getEntry(long away)
{
- long start = 0;
- unsigned long size = 0;
+ __u32 start = 0;
+ __u32 size = 0;
char *idxbuf = 0;
- char retval = 0;
+ char retval = 0;
char *buf = new char [ strlen(*key) + 6 ];
strcpy(buf, *key);
More information about the sword-cvs
mailing list