[sword-cvs] sword/src/mgr encfiltmgr.cpp,1.3,1.4 filemgr.cpp,1.24,1.25 installmgr.cpp,1.5,1.6 localemgr.cpp,1.14,1.15 swconfig.cpp,1.12,1.13 swmgr.cpp,1.90,1.91 swsourcemgr.cpp,1.1,1.2
sword@www.crosswire.org
sword@www.crosswire.org
Thu, 26 Jun 2003 18:41:11 -0700
Update of /usr/local/cvsroot/sword/src/mgr
In directory www:/tmp/cvs-serv19920/src/mgr
Modified Files:
encfiltmgr.cpp filemgr.cpp installmgr.cpp localemgr.cpp
swconfig.cpp swmgr.cpp swsourcemgr.cpp
Log Message:
no message
Index: encfiltmgr.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/mgr/encfiltmgr.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** encfiltmgr.cpp 1 Oct 2002 22:04:58 -0000 1.3
--- encfiltmgr.cpp 27 Jun 2003 01:41:07 -0000 1.4
***************
*** 83,88 ****
ConfigEntMap::iterator entry;
! std::string encoding = ((entry = section.find("Encoding")) != section.end()) ? (*entry).second : (std::string)"";
! if (encoding.empty() || !stricmp(encoding.c_str(), "Latin-1")) {
module->AddRawFilter(latin1utf8);
}
--- 83,88 ----
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);
}
Index: filemgr.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/mgr/filemgr.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** filemgr.cpp 25 Feb 2003 04:12:47 -0000 1.24
--- filemgr.cpp 27 Jun 2003 01:41:07 -0000 1.25
***************
*** 25,33 ****
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdio.h>
- #include <string.h>
#ifndef __GNUC__
#include <io.h>
--- 25,33 ----
#include <dirent.h>
+ #include <dir.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdio.h>
#ifndef __GNUC__
#include <io.h>
***************
*** 264,270 ****
}
signed char retVal = !access(path, 04);
! delete [] path;
! return retVal;
}
SWORD_NAMESPACE_END
--- 264,331 ----
}
signed char retVal = !access(path, 04);
! delete [] path;
! return retVal;
! }
!
!
! int FileMgr::createParent(const char *pName) {
! char *buf = new char [ strlen(pName) + 1 ];
! int retCode = 0;
!
! strcpy(buf, pName);
! int end = strlen(buf) - 1;
! while (end) {
! if (buf[end] == '/')
! break;
! end--;
! }
! buf[end] = 0;
! if (strlen(buf)>0) {
! if (access(buf, 02)) { // not exists with write access?
! if ((retCode = mkdir(buf))) {
! createParent(buf);
! retCode = mkdir(buf);
! }
! }
! }
! else retCode = -1;
! delete [] buf;
! return retCode;
}
+
+
+ int FileMgr::createPathAndFile(const char *fName) {
+ int fd;
+
+ fd = ::open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
+ if (fd < 1) {
+ createParent(fName);
+ fd = ::open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE);
+ }
+ return fd;
+ }
+
+
+ int FileMgr::copyFile(const char *sourceFile, const char *targetFile) {
+ int sfd, dfd, len;
+ char buf[4096];
+
+ if ((sfd = ::open(sourceFile, O_RDONLY|O_BINARY)) < 1)
+ return -1;
+ if ((dfd = createPathAndFile(targetFile)) < 1)
+ return -1;
+
+ do {
+ len = read(sfd, buf, 4096);
+ write(dfd, buf, len);
+ }
+ while(len == 4096);
+ ::close(dfd);
+ ::close(sfd);
+
+ return 0;
+ }
+
+
SWORD_NAMESPACE_END
Index: installmgr.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/mgr/installmgr.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** installmgr.cpp 30 May 2003 19:22:32 -0000 1.5
--- installmgr.cpp 27 Jun 2003 01:41:07 -0000 1.6
***************
*** 240,243 ****
--- 240,443 ----
return 1;
}
+
+
+
+ InstallSource::InstallSource(const char *confEnt, const char *type) {
+ char *buf = 0;
+ stdstr(&buf, confEnt);
+
+ caption = strtok(buf, "|");
+ source = strtok(0, "|");
+ directory = strtok(0, "|");
+ delete [] buf;
+ this->type = type;
+ mgr = 0;
+ }
+
+
+ InstallSource::~InstallSource() {
+ if (mgr)
+ delete mgr;
+ }
+
+
+ int installModule(const char *fromLocation, const char *modName, InstallSource *is) {
+ SectionMap::iterator module, section;
+ ConfigEntMap::iterator fileBegin;
+ ConfigEntMap::iterator fileEnd;
+ ConfigEntMap::iterator entry;
+ SWBuf sourceDir;
+ SWBuf buffer;
+ bool aborted = false;
+ bool cipher = false;
+
+ sourceDir = fromLocation;
+ /*
+ if (ist)
+ sourceDir = (SWBuf)"./sources/" + ist->is.source;
+ else sourceDir = getLocalDir();
+ */
+ SWMgr mgr(sourceDir.c_str());
+
+ module = mgr.config->Sections.find(modName);
+
+ if (module != mgr.config->Sections.end()) {
+
+ entry = module->second.find("CipherKey");
+ if (entry != module->second.end())
+ cipher = true;
+
+ fileEnd = module->second.upper_bound("File");
+ fileBegin = module->second.lower_bound("File");
+
+ if (fileBegin != fileEnd) { // copy each file
+ if (is) {
+ while (fileBegin != fileEnd) { // ftp each file first
+ buffer = sourceDir + "/" + fileBegin->second.c_str();
+ if (FTPCopy(is, fileBegin->second.c_str(), buffer.c_str())) {
+ aborted = true;
+ break; // user aborted
+ }
+ fileBegin++;
+ }
+ fileBegin = module->second.lower_bound("File");
+ }
+
+ if (!aborted) {
+ // DO THE INSTALL
+ while (fileBegin != fileEnd) {
+ copyFileToCWD(sourceDir.c_str(), fileBegin->second.c_str());
+ fileBegin++;
+ }
+ }
+ //---------------
+
+ if (is) {
+ fileBegin = module->second.lower_bound("File");
+ while (fileBegin != fileEnd) { // delete each tmp ftp file
+ buffer = sourceDir + "/" + fileBegin->second.c_str();
+ remove(buffer.c_str());
+ fileBegin++;
+ }
+ }
+ }
+ else { //copy all files in DataPath directory
+ DIR *dir;
+ struct dirent *ent;
+ ConfigEntMap::iterator entry;
+ SWBuf modDir;
+ SWBuf modFile;
+ SWBuf sourceOrig = sourceDir;
+
+ entry = module->second.find("DataPath");
+ if (entry != module->second.end()) {
+ modDir = entry->second.c_str();
+ entry = module->second.find("ModDrv");
+ if (entry != module->second.end()) {
+ if (!strcmp(entry->second.c_str(), "RawLD") || !strcmp(entry->second.c_str(), "RawLD4") || !strcmp(entry->second.c_str(), "zLD") || !strcmp(entry->second.c_str(), "RawGenBook") || !strcmp(entry->second.c_str(), "zGenBook")) {
+ char *buf = new char [ strlen(modDir.c_str()) + 1 ];
+
+ strcpy(buf, modDir.c_str());
+ int end = strlen(buf) - 1;
+ while (end) {
+ if (buf[end] == '/')
+ break;
+ end--;
+ }
+ buf[end] = 0;
+ modDir = buf;
+ delete [] buf;
+ }
+ }
+
+ if (is) {
+ buffer = sourceDir + "/" + modDir;
+ if (FTPCopy(is, modDir.c_str(), buffer.c_str(), true)) {
+ aborted = true; // user aborted
+ }
+ }
+ sourceDir += "/";
+ sourceDir += modDir;
+ if (!aborted) {
+ if (dir = opendir(sourceDir.c_str())) {
+ rewinddir(dir);
+ while ((ent = readdir(dir))) {
+ if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+ modFile = modDir;
+ modFile += "/";
+ modFile += ent->d_name;
+ copyFileToSWORDInstall(sourceOrig.c_str(), modFile.c_str());
+ }
+ }
+ closedir(dir);
+ }
+ }
+ if (is) { // delete tmp ftp files
+ if (dir = opendir(sourceDir.c_str())) {
+ rewinddir(dir);
+ while ((ent = readdir(dir))) {
+ if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+ modFile = sourceOrig + "/" + modDir;
+ modFile += "/";
+ modFile += ent->d_name;
+ remove(modFile.c_str());
+ }
+ }
+ closedir(dir);
+ }
+ }
+ sourceDir = sourceOrig;
+ sourceDir += "/mods.d/";
+ if (!aborted) {
+ if (dir = opendir(sourceDir.c_str())) { // find and copy .conf file
+ rewinddir(dir);
+ while ((ent = readdir(dir))) {
+ if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+ modFile = sourceDir;
+ modFile += ent->d_name;
+ SWConfig *config = new SWConfig(modFile.c_str());
+ if (config->Sections.find(modName) != config->Sections.end()) {
+ delete config;
+ SWBuf targetFile = manager->configPath; //"./mods.d/";
+ targetFile += "/";
+ targetFile += ent->d_name;
+ FileMgr::copyFile(modFile.c_str(), targetFile.c_str());
+ if (cipher) {
+ CipherForm->modName = modName;
+ CipherForm->confFile = targetFile;
+ if (CipherForm->ShowModal() == mrCancel) {
+ removeModule(modName);
+ aborted = true;
+ }
+ }
+ }
+ else delete config;
+ }
+ }
+ closedir(dir);
+ }
+ }
+ }
+ }
+ return (aborted) ? -1 : 0;
+ }
+ return 1;
+ }
+
+
+ int copyFileToSWORDInstall(const char *sourceDir, const char *fName) {
+ SWBuf sourcePath = sourceDir;
+ sourcePath += fName;
+
+ SWBuf dest;
+ dest = manager->prefixPath;
+ if ((manager->prefixPath[strlen(manager->prefixPath)-1] != '\\') && ( manager->prefixPath[strlen(manager->prefixPath)-1] != '/'))
+ dest += "/";
+ dest += fName;
+
+ return FileMgr::copyFile(sourcePath.c_str(), dest.c_str());
+ }
+
+
SWORD_NAMESPACE_END
Index: localemgr.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/mgr/localemgr.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** localemgr.cpp 1 Oct 2002 22:04:59 -0000 1.14
--- localemgr.cpp 27 Jun 2003 01:41:07 -0000 1.15
***************
*** 49,53 ****
char *configPath = 0;
char configType = 0;
! std::string path;
defaultLocaleName = 0;
--- 49,53 ----
char *configPath = 0;
char configType = 0;
! SWBuf path;
defaultLocaleName = 0;
***************
*** 105,109 ****
DIR *dir;
struct dirent *ent;
! std::string newmodfile;
LocaleMap::iterator it;
--- 105,109 ----
DIR *dir;
struct dirent *ent;
! SWBuf newmodfile;
LocaleMap::iterator it;
***************
*** 155,160 ****
! std::list <std::string> LocaleMgr::getAvailableLocales() {
! std::list <std::string> retVal;
for (LocaleMap::iterator it = locales.begin(); it != locales.end(); it++)
retVal.push_back((*it).second->getName());
--- 155,160 ----
! std::list <SWBuf> LocaleMgr::getAvailableLocales() {
! std::list <SWBuf> retVal;
for (LocaleMap::iterator it = locales.begin(); it != locales.end(); it++)
retVal.push_back((*it).second->getName());
Index: swconfig.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/mgr/swconfig.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** swconfig.cpp 16 Feb 2003 02:42:56 -0000 1.12
--- swconfig.cpp 27 Jun 2003 01:41:07 -0000 1.13
***************
*** 36,40 ****
! char SWConfig::getline(FILE *fp, std::string &line)
{
char retval = 0;
--- 36,40 ----
! char SWConfig::getline(FILE *fp, SWBuf &line)
{
char retval = 0;
***************
*** 70,76 ****
FILE *cfile;
char *buf, *data;
! std::string line;
ConfigEntMap cursect;
! std::string sectname;
bool first = true;
--- 70,76 ----
FILE *cfile;
char *buf, *data;
! SWBuf line;
ConfigEntMap cursect;
! SWBuf sectname;
bool first = true;
***************
*** 111,118 ****
void SWConfig::Save() {
FILE *cfile;
! std::string buf;
SectionMap::iterator sit;
ConfigEntMap::iterator entry;
! std::string sectname;
if ((cfile = fopen(filename.c_str(), "w"))) {
--- 111,118 ----
void SWConfig::Save() {
FILE *cfile;
! SWBuf buf;
SectionMap::iterator sit;
ConfigEntMap::iterator entry;
! SWBuf sectname;
if ((cfile = fopen(filename.c_str(), "w"))) {
Index: swmgr.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/mgr/swmgr.cpp,v
retrieving revision 1.90
retrieving revision 1.91
diff -C2 -d -r1.90 -r1.91
*** swmgr.cpp 17 Jun 2003 22:14:18 -0000 1.90
--- swmgr.cpp 27 Jun 2003 01:41:07 -0000 1.91
***************
*** 249,253 ****
SWMgr::SWMgr(const char *iConfigPath, bool autoload, SWFilterMgr *filterMgr) {
! std::string path;
this->filterMgr = filterMgr;
--- 249,253 ----
SWMgr::SWMgr(const char *iConfigPath, bool autoload, SWFilterMgr *filterMgr) {
! SWBuf path;
this->filterMgr = filterMgr;
***************
*** 306,311 ****
! void SWMgr::findConfig(char *configType, char **prefixPath, char **configPath, std::list<std::string> *augPaths) {
! std::string path;
ConfigEntMap::iterator entry;
ConfigEntMap::iterator lastEntry;
--- 306,311 ----
! void SWMgr::findConfig(char *configType, char **prefixPath, char **configPath, std::list<SWBuf> *augPaths) {
! SWBuf path;
ConfigEntMap::iterator entry;
ConfigEntMap::iterator lastEntry;
***************
*** 551,555 ****
DIR *dir;
struct dirent *ent;
! std::string newmodfile;
if ((dir = opendir(ipath))) {
--- 551,555 ----
DIR *dir;
struct dirent *ent;
! SWBuf newmodfile;
if ((dir = opendir(ipath))) {
***************
*** 581,585 ****
void SWMgr::augmentModules(const char *ipath) {
! std::string path = ipath;
if ((ipath[strlen(ipath)-1] != '\\') && (ipath[strlen(ipath)-1] != '/'))
path += "/";
--- 581,585 ----
void SWMgr::augmentModules(const char *ipath) {
! SWBuf path = ipath;
if ((ipath[strlen(ipath)-1] != '\\') && (ipath[strlen(ipath)-1] != '/'))
path += "/";
***************
*** 649,653 ****
CreateMods();
! for (std::list<std::string>::iterator pathIt = augPaths.begin(); pathIt != augPaths.end(); pathIt++) {
augmentModules(pathIt->c_str());
}
--- 649,653 ----
CreateMods();
! for (std::list<SWBuf>::iterator pathIt = augPaths.begin(); pathIt != augPaths.end(); pathIt++) {
augmentModules(pathIt->c_str());
}
***************
*** 655,659 ****
char *envhomedir = getenv ("HOME");
if (envhomedir != NULL && configType != 2) { // 2 = user only
! std::string path = envhomedir;
if ((envhomedir[strlen(envhomedir)-1] != '\\') && (envhomedir[strlen(envhomedir)-1] != '/'))
path += "/";
--- 655,659 ----
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 += "/";
***************
*** 674,693 ****
}
! SWModule *SWMgr::CreateMod(std::string name, std::string driver, ConfigEntMap §ion)
{
! std::string description, datapath, misc1;
ConfigEntMap::iterator entry;
SWModule *newmod = 0;
! std::string lang, sourceformat, encoding;
! signed char direction, enc, markup;
! description = ((entry = section.find("Description")) != section.end()) ? (*entry).second : (std::string)"";
! lang = ((entry = section.find("Lang")) != section.end()) ? (*entry).second : (std::string)"en";
! sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (std::string)"";
! encoding = ((entry = section.find("Encoding")) != section.end()) ? (*entry).second : (std::string)"";
datapath = prefixPath;
if ((prefixPath[strlen(prefixPath)-1] != '\\') && (prefixPath[strlen(prefixPath)-1] != '/'))
datapath += "/";
! misc1 += ((entry = section.find("DataPath")) != section.end()) ? (*entry).second : (std::string)"";
char *buf = new char [ strlen(misc1.c_str()) + 1 ];
char *buf2 = buf;
--- 674,693 ----
}
! SWModule *SWMgr::CreateMod(const char *name, const char *driver, ConfigEntMap §ion)
{
! SWBuf description, datapath, misc1;
ConfigEntMap::iterator entry;
SWModule *newmod = 0;
! SWBuf lang, sourceformat, encoding;
! signed char direction, enc, markup;
! description = ((entry = section.find("Description")) != section.end()) ? (*entry).second : (SWBuf)"";
! lang = ((entry = section.find("Lang")) != section.end()) ? (*entry).second : (SWBuf)"en";
! sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (SWBuf)"";
! encoding = ((entry = section.find("Encoding")) != section.end()) ? (*entry).second : (SWBuf)"";
datapath = prefixPath;
if ((prefixPath[strlen(prefixPath)-1] != '\\') && (prefixPath[strlen(prefixPath)-1] != '/'))
datapath += "/";
! misc1 += ((entry = section.find("DataPath")) != section.end()) ? (*entry).second : (SWBuf)"";
char *buf = new char [ strlen(misc1.c_str()) + 1 ];
char *buf2 = buf;
***************
*** 704,715 ****
section["AbsoluteDataPath"] = datapath;
! if (!stricmp(sourceformat.c_str(), "GBF"))
! markup = FMT_GBF;
! else if (!stricmp(sourceformat.c_str(), "ThML"))
! markup = FMT_THML;
! else if (!stricmp(sourceformat.c_str(), "OSIS"))
! markup = FMT_OSIS;
! else
! markup = FMT_GBF;
if (!stricmp(encoding.c_str(), "SCSU"))
--- 704,715 ----
section["AbsoluteDataPath"] = datapath;
! if (!stricmp(sourceformat.c_str(), "GBF"))
! markup = FMT_GBF;
! else if (!stricmp(sourceformat.c_str(), "ThML"))
! markup = FMT_THML;
! else if (!stricmp(sourceformat.c_str(), "OSIS"))
! markup = FMT_OSIS;
! else
! markup = FMT_GBF;
if (!stricmp(encoding.c_str(), "SCSU"))
***************
*** 721,740 ****
if ((entry = section.find("Direction")) == section.end()) {
! direction = DIRECTION_LTR;
! }
! else if (!stricmp((*entry).second.c_str(), "rtol")) {
! direction = DIRECTION_RTL;
! }
! else if (!stricmp((*entry).second.c_str(), "bidi")) {
! direction = DIRECTION_BIDI;
! }
! else {
! direction = DIRECTION_LTR;
! }
! if ((!stricmp(driver.c_str(), "zText")) || (!stricmp(driver.c_str(), "zCom"))) {
SWCompress *compress = 0;
int blockType = CHAPTERBLOCKS;
! misc1 = ((entry = section.find("BlockType")) != section.end()) ? (*entry).second : (std::string)"CHAPTER";
if (!stricmp(misc1.c_str(), "VERSE"))
blockType = VERSEBLOCKS;
--- 721,740 ----
if ((entry = section.find("Direction")) == section.end()) {
! direction = DIRECTION_LTR;
! }
! else if (!stricmp((*entry).second.c_str(), "rtol")) {
! direction = DIRECTION_RTL;
! }
! else if (!stricmp((*entry).second.c_str(), "bidi")) {
! direction = DIRECTION_BIDI;
! }
! else {
! direction = DIRECTION_LTR;
! }
! if ((!stricmp(driver, "zText")) || (!stricmp(driver, "zCom"))) {
SWCompress *compress = 0;
int blockType = CHAPTERBLOCKS;
! misc1 = ((entry = section.find("BlockType")) != section.end()) ? (*entry).second : (SWBuf)"CHAPTER";
if (!stricmp(misc1.c_str(), "VERSE"))
blockType = VERSEBLOCKS;
***************
*** 744,748 ****
blockType = BOOKBLOCKS;
! misc1 = ((entry = section.find("CompressType")) != section.end()) ? (*entry).second : (std::string)"LZSS";
#ifndef EXCLUDEZLIB
if (!stricmp(misc1.c_str(), "ZIP"))
--- 744,748 ----
blockType = BOOKBLOCKS;
! misc1 = ((entry = section.find("CompressType")) != section.end()) ? (*entry).second : (SWBuf)"LZSS";
#ifndef EXCLUDEZLIB
if (!stricmp(misc1.c_str(), "ZIP"))
***************
*** 754,804 ****
if (compress) {
! if (!stricmp(driver.c_str(), "zText"))
! newmod = new zText(datapath.c_str(), name.c_str(), description.c_str(), blockType, compress, 0, enc, direction, markup, lang.c_str());
! else newmod = new zCom(datapath.c_str(), name.c_str(), description.c_str(), blockType, compress, 0, enc, direction, markup, lang.c_str());
}
}
! if (!stricmp(driver.c_str(), "RawText")) {
! newmod = new RawText(datapath.c_str(), name.c_str(), description.c_str(), 0, enc, direction, markup, lang.c_str());
}
// backward support old drivers
! if (!stricmp(driver.c_str(), "RawGBF")) {
! newmod = new RawText(datapath.c_str(), name.c_str(), description.c_str(), 0, enc, direction, markup, lang.c_str());
}
! if (!stricmp(driver.c_str(), "RawCom")) {
! newmod = new RawCom(datapath.c_str(), name.c_str(), description.c_str(), 0, enc, direction, markup, lang.c_str());
}
! if (!stricmp(driver.c_str(), "RawFiles")) {
! newmod = new RawFiles(datapath.c_str(), name.c_str(), description.c_str(), 0, enc, direction, markup, lang.c_str());
}
! if (!stricmp(driver.c_str(), "HREFCom")) {
! misc1 = ((entry = section.find("Prefix")) != section.end()) ? (*entry).second : (std::string)"";
! newmod = new HREFCom(datapath.c_str(), misc1.c_str(), name.c_str(), description.c_str());
}
! string::size_type pos; //used for position of final / in AbsoluteDataPath, but also set to 1 for modules types that need to strip module name
! if (!stricmp(driver.c_str(), "RawLD")) {
! newmod = new RawLD(datapath.c_str(), name.c_str(), description.c_str(), 0, enc, direction, markup, lang.c_str());
pos = 1;
}
! if (!stricmp(driver.c_str(), "RawLD4")) {
! newmod = new RawLD4(datapath.c_str(), name.c_str(), description.c_str(), 0, enc, direction, markup, lang.c_str());
pos = 1;
}
! if (!stricmp(driver.c_str(), "zLD")) {
SWCompress *compress = 0;
int blockCount;
! misc1 = ((entry = section.find("BlockCount")) != section.end()) ? (*entry).second : (std::string)"200";
blockCount = atoi(misc1.c_str());
blockCount = (blockCount) ? blockCount : 200;
! misc1 = ((entry = section.find("CompressType")) != section.end()) ? (*entry).second : (std::string)"LZSS";
#ifndef EXCLUDEZLIB
if (!stricmp(misc1.c_str(), "ZIP"))
--- 754,804 ----
if (compress) {
! if (!stricmp(driver, "zText"))
! newmod = new zText(datapath.c_str(), name, description.c_str(), blockType, compress, 0, enc, direction, markup, lang.c_str());
! else newmod = new zCom(datapath.c_str(), name, description.c_str(), blockType, compress, 0, enc, direction, markup, lang.c_str());
}
}
! if (!stricmp(driver, "RawText")) {
! newmod = new RawText(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
}
// backward support old drivers
! if (!stricmp(driver, "RawGBF")) {
! newmod = new RawText(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
}
! if (!stricmp(driver, "RawCom")) {
! newmod = new RawCom(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
}
! if (!stricmp(driver, "RawFiles")) {
! newmod = new RawFiles(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
}
! if (!stricmp(driver, "HREFCom")) {
! misc1 = ((entry = section.find("Prefix")) != section.end()) ? (*entry).second : (SWBuf)"";
! newmod = new HREFCom(datapath.c_str(), misc1.c_str(), name, description.c_str());
}
! int pos; //used for position of final / in AbsoluteDataPath, but also set to 1 for modules types that need to strip module name
! if (!stricmp(driver, "RawLD")) {
! newmod = new RawLD(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
pos = 1;
}
! if (!stricmp(driver, "RawLD4")) {
! newmod = new RawLD4(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
pos = 1;
}
! if (!stricmp(driver, "zLD")) {
SWCompress *compress = 0;
int blockCount;
! misc1 = ((entry = section.find("BlockCount")) != section.end()) ? (*entry).second : (SWBuf)"200";
blockCount = atoi(misc1.c_str());
blockCount = (blockCount) ? blockCount : 200;
! misc1 = ((entry = section.find("CompressType")) != section.end()) ? (*entry).second : (SWBuf)"LZSS";
#ifndef EXCLUDEZLIB
if (!stricmp(misc1.c_str(), "ZIP"))
***************
*** 810,834 ****
if (compress) {
! newmod = new zLD(datapath.c_str(), name.c_str(), description.c_str(), blockCount, compress, 0, enc, direction, markup, lang.c_str());
}
! pos = 1;
}
! if (!stricmp(driver.c_str(), "RawGenBook")) {
! newmod = new RawGenBook(datapath.c_str(), name.c_str(), description.c_str(), 0, enc, direction, markup, lang.c_str());
! pos = 1;
}
! if (pos == 1) {
! pos = section["AbsoluteDataPath"].rfind("/");
! section["AbsoluteDataPath"].erase(pos, section["AbsoluteDataPath"].length() - pos);
! }
! // if a specific module type is set in the config, use this
! if ((entry = section.find("Type")) != section.end())
! newmod->Type(entry->second.c_str());
! newmod->setConfig(§ion);
! return newmod;
}
--- 810,839 ----
if (compress) {
! newmod = new zLD(datapath.c_str(), name, description.c_str(), blockCount, compress, 0, enc, direction, markup, lang.c_str());
}
! pos = 1;
}
! if (!stricmp(driver, "RawGenBook")) {
! newmod = new RawGenBook(datapath.c_str(), name, description.c_str(), 0, enc, direction, markup, lang.c_str());
! pos = 1;
}
! if (pos == 1) {
! SWBuf &dp = section["AbsoluteDataPath"];
! for (int i = dp.length() - 1; i; i--) {
! if (dp[i] == '/') {
! dp.setSize(i);
! break;
! }
! }
! }
! // if a specific module type is set in the config, use this
! if ((entry = section.find("Type")) != section.end())
! newmod->Type(entry->second.c_str());
! newmod->setConfig(§ion);
! return newmod;
}
***************
*** 873,881 ****
void SWMgr::AddRawFilters(SWModule *module, ConfigEntMap §ion) {
! std::string sourceformat, cipherKey;
ConfigEntMap::iterator entry;
! cipherKey = ((entry = section.find("CipherKey")) != section.end()) ? (*entry).second : (std::string)"";
! if (!cipherKey.empty()) {
SWFilter *cipherFilter = new CipherFilter(cipherKey.c_str());
cipherFilters.insert(FilterMap::value_type(module->Name(), cipherFilter));
--- 878,886 ----
void SWMgr::AddRawFilters(SWModule *module, ConfigEntMap §ion) {
! SWBuf sourceformat, cipherKey;
ConfigEntMap::iterator entry;
! cipherKey = ((entry = section.find("CipherKey")) != section.end()) ? (*entry).second : (SWBuf)"";
! if (cipherKey.length()) {
SWFilter *cipherFilter = new CipherFilter(cipherKey.c_str());
cipherFilters.insert(FilterMap::value_type(module->Name(), cipherFilter));
***************
*** 890,894 ****
void SWMgr::AddEncodingFilters(SWModule *module, ConfigEntMap §ion) {
-
if (filterMgr)
filterMgr->AddEncodingFilters(module, section);
--- 895,898 ----
***************
*** 897,909 ****
void SWMgr::AddRenderFilters(SWModule *module, ConfigEntMap §ion) {
! std::string sourceformat;
ConfigEntMap::iterator entry;
! sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (std::string)"";
// Temporary: To support old module types
! // TODO: Remove at 1.6.0 release?
! if (sourceformat.empty()) {
! sourceformat = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (std::string)"";
if (!stricmp(sourceformat.c_str(), "RawGBF"))
sourceformat = "GBF";
--- 901,913 ----
void SWMgr::AddRenderFilters(SWModule *module, ConfigEntMap §ion) {
! SWBuf sourceformat;
ConfigEntMap::iterator entry;
! sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (SWBuf)"";
// Temporary: To support old module types
! // TODO: Remove at 1.6.0 release?
! if (!sourceformat.length()) {
! sourceformat = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (SWBuf)"";
if (!stricmp(sourceformat.c_str(), "RawGBF"))
sourceformat = "GBF";
***************
*** 924,934 ****
void SWMgr::AddStripFilters(SWModule *module, ConfigEntMap §ion)
{
! std::string sourceformat;
ConfigEntMap::iterator entry;
! sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (std::string)"";
// Temporary: To support old module types
! if (sourceformat.empty()) {
! sourceformat = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (std::string)"";
if (!stricmp(sourceformat.c_str(), "RawGBF"))
sourceformat = "GBF";
--- 928,938 ----
void SWMgr::AddStripFilters(SWModule *module, ConfigEntMap §ion)
{
! SWBuf sourceformat;
ConfigEntMap::iterator entry;
! sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (SWBuf)"";
// Temporary: To support old module types
! if (!sourceformat.length()) {
! sourceformat = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (SWBuf)"";
if (!stricmp(sourceformat.c_str(), "RawGBF"))
sourceformat = "GBF";
***************
*** 958,968 ****
ConfigEntMap::iterator entry;
SWModule *newmod;
! std::string driver, misc1;
for (it = config->Sections.begin(); it != config->Sections.end(); it++) {
ConfigEntMap §ion = (*it).second;
newmod = 0;
! driver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (std::string)"";
! if (!driver.empty()) {
newmod = CreateMod((*it).first, driver, section);
if (newmod) {
--- 962,972 ----
ConfigEntMap::iterator entry;
SWModule *newmod;
! SWBuf driver, misc1;
for (it = config->Sections.begin(); it != config->Sections.end(); it++) {
ConfigEntMap §ion = (*it).second;
newmod = 0;
! driver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (SWBuf)"";
! if (driver.length()) {
newmod = CreateMod((*it).first, driver, section);
if (newmod) {
***************
*** 1003,1008 ****
struct dirent *ent;
int conffd = 0;
! std::string newmodfile;
! std::string targetName;
if (!access(dirname, 04)) {
--- 1007,1012 ----
struct dirent *ent;
int conffd = 0;
! SWBuf newmodfile;
! SWBuf targetName;
if (!access(dirname, 04)) {
Index: swsourcemgr.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/mgr/swsourcemgr.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** swsourcemgr.cpp 23 Oct 2002 23:14:39 -0000 1.1
--- swsourcemgr.cpp 27 Jun 2003 01:41:07 -0000 1.2
***************
*** 25,29 ****
#include "utilstr.h"
#include "swconfig.h"
- #include <string>
#include <dirent.h>
--- 25,28 ----
***************
*** 31,35 ****
SWSourceMgr::SWSourceMgr(const char *iConfigPath) {
! std::string path;
//init();
--- 30,34 ----
SWSourceMgr::SWSourceMgr(const char *iConfigPath) {
! SWBuf path;
//init();
***************
*** 60,64 ****
DIR *dir;
struct dirent *ent;
! std::string newmodfile;
if ((dir = opendir(ipath))) {
--- 59,63 ----
DIR *dir;
struct dirent *ent;
! SWBuf newmodfile;
if ((dir = opendir(ipath))) {