58 int len = (int)buf.
size();
59 if ((buf[len-1] ==
'/')
60 || (buf[len-1] ==
'\\'))
106 this->privatePath = 0;
109 stdstr(&(this->privatePath), privatePath);
110 if (this->privatePath) {
111 int len = (int)strlen(this->privatePath);
112 if ((this->privatePath[len-1] ==
'/')
113 || (this->privatePath[len-1] ==
'\\'))
114 this->privatePath[len-1] = 0;
131 for (InstallSourceMap::iterator it =
sources.begin(); it !=
sources.end(); ++it) {
147 long t = atol((*
installConf)[
"General"][
"TimeoutMillis"].c_str());
152 ConfigEntMap::iterator sourceBegin;
153 ConfigEntMap::iterator sourceEnd;
157 sourceBegin = confSection->second.lower_bound(
"FTPSource");
158 sourceEnd = confSection->second.upper_bound(
"FTPSource");
160 while (sourceBegin != sourceEnd) {
169 #ifdef CURLSFTPAVAILABLE
170 sourceBegin = confSection->second.lower_bound(
"SFTPSource");
171 sourceEnd = confSection->second.upper_bound(
"SFTPSource");
173 while (sourceBegin != sourceEnd) {
181 #endif // CURLSFTPAVAILABLE
183 sourceBegin = confSection->second.lower_bound(
"HTTPSource");
184 sourceEnd = confSection->second.upper_bound(
"HTTPSource");
186 while (sourceBegin != sourceEnd) {
195 sourceBegin = confSection->second.lower_bound(
"HTTPSSource");
196 sourceEnd = confSection->second.upper_bound(
"HTTPSSource");
198 while (sourceBegin != sourceEnd) {
211 sourceBegin = confSection->second.lower_bound(
"DefaultMod");
212 sourceEnd = confSection->second.upper_bound(
"DefaultMod");
214 while (sourceBegin != sourceEnd) {
226 for (InstallSourceMap::iterator it =
sources.begin(); it !=
sources.end(); ++it) {
228 installConf->
getSection(
"Sources").insert(ConfigEntMap::value_type(it->second->type +
"Source", it->second->getConfEnt().c_str()));
231 (*installConf)[
"General"][
"PassiveFTP"] = (
isFTPPassive()) ?
"true" :
"false";
242 SectionMap::iterator
module;
243 ConfigEntMap::iterator fileBegin;
244 ConfigEntMap::iterator fileEnd, entry;
248 SWBuf modName = moduleName;
256 fileBegin = module->second.lower_bound(
"File");
257 fileEnd = module->second.upper_bound(
"File");
261 entry = module->second.find(
"AbsoluteDataPath");
262 modDir = entry->second.
c_str();
264 if (fileBegin != fileEnd) {
265 while (fileBegin != fileEnd) {
268 modFile += fileBegin->second.
c_str();
275 ConfigEntMap::iterator entry;
278 for (
unsigned int i = 0; i < dirList.size(); ++i) {
279 if (dirList[i].name.endsWith(
".conf")) {
283 modFile += dirList[i].name;
301 SWLOGD(
"remoteCopy: %s, %s, %s, %c, %s", (is?is->
source.
c_str():
"null"), src, (dest?dest:
"null"), (dirTransfer?
't':
'f'), (suffix?suffix:
"null"));
308 if (is->
type ==
"FTP"
309 #ifdef CURLSFTPAVAILABLE
310 || is->
type ==
"SFTP"
318 else if (is->
type ==
"HTTP" || is->
type ==
"HTTPS") {
334 if (is->
type ==
"HTTP") {
335 urlPrefix = (
SWBuf)
"http://";
337 else if (is->
type ==
"HTTPS") {
338 urlPrefix = (
SWBuf)
"https://";
340 #ifdef CURLSFTPAVAILABLE
341 else if (is->
type ==
"SFTP") {
342 urlPrefix = (
SWBuf)
"sftp://";
346 urlPrefix = (
SWBuf)
"ftp://";
361 dir += (
SWBuf)
"/" + src;
362 SWLOGD(
"remoteCopy: dirTransfer: %s", dir.
c_str());
372 url += (
SWBuf)
"/" + src;
375 SWLOGD(
"netCopy: failed to get file %s", url.
c_str());
396 SectionMap::iterator
module, section;
397 ConfigEntMap::iterator fileBegin;
398 ConfigEntMap::iterator fileEnd;
399 ConfigEntMap::iterator entry;
402 bool aborted =
false;
406 SWLOGD(
"***** InstallMgr::installModule\n");
408 SWLOGD(
"***** fromLocation: %s \n", fromLocation);
410 SWLOGD(
"***** modName: %s \n", modName);
414 else sourceDir = fromLocation;
425 entry = module->second.find(
"CipherKey");
426 if (entry != module->second.end())
433 fileEnd = module->second.upper_bound(
"File");
434 fileBegin = module->second.lower_bound(
"File");
436 if (fileBegin != fileEnd) {
438 while (fileBegin != fileEnd) {
439 buffer = sourceDir + fileBegin->second.
c_str();
446 fileBegin = module->second.lower_bound(
"File");
451 while (fileBegin != fileEnd && !retVal) {
452 SWBuf sourcePath = sourceDir;
453 sourcePath += fileBegin->second.
c_str();
457 dest += fileBegin->second.
c_str();
466 fileBegin = module->second.lower_bound(
"File");
467 while (fileBegin != fileEnd) {
468 buffer = sourceDir + fileBegin->second.
c_str();
481 ConfigEntMap::iterator entry;
483 entry = module->second.find(
"AbsoluteDataPath");
484 if (entry != module->second.end()) {
486 SWBuf relativePath = absolutePath;
487 entry = module->second.find(
"PrefixPath");
488 if (entry != module->second.end()) {
489 relativePath << strlen(entry->second.c_str());
496 SWLOGD(
"***** absolutePath: %s \n", absolutePath.
c_str());
497 SWLOGD(
"***** relativePath: %s \n", relativePath.
c_str());
515 SWBuf confDir = sourceDir +
"mods.d/";
517 for (
unsigned int i = 0; i < dirList.size() && !retVal; ++i) {
518 if (dirList[i].name.endsWith(
".conf")) {
520 modFile += dirList[i].name;
526 targetFile += dirList[i].name;
544 return (aborted) ? -9 : retVal;
557 SWBuf target = root +
"/mods.d";
566 SWBuf archive = root +
"/mods.d.tar.gz";
574 else if (errorCode > -2)
593 map<SWModule *, int> retVal;
596 SWBuf softwareVersion;
608 const char *v = mod->second->getConfigEntry(
"CipherKey");
614 targetVersion =
"0.0";
615 sourceVersion =
"1.0";
618 v = mod->second->getConfigEntry(
"Version");
619 if (v) sourceVersion = v;
621 v = mod->second->getConfigEntry(
"MinimumVersion");
622 if (v) softwareVersion = v;
626 targetVersion =
"1.0";
628 if (v) targetVersion = v;
635 retVal[mod->second] = modStat;
654 is.
source =
"ftp.crosswire.org";
656 int errorCode =
remoteCopy(&is, masterRepoList, masterRepoListPath.
c_str(),
false);
658 SWConfig masterList(masterRepoListPath);
659 SectionMap::iterator sections = masterList.
getSections().find(
"Repos");
661 for (ConfigEntMap::iterator actions = sections->second.begin(); actions != sections->second.end(); actions++) {
663 InstallSourceMap::iterator it;
666 if ((it->second) && (it->second->uid == actions->first)) {
667 if (actions->second ==
"REMOVE") {
675 if (key ==
"FTPSource") {
684 it->second =
new InstallSource(
"FTP", actions->second.c_str());
685 it->second->
uid = actions->first;
694 if (key ==
"FTPSource") {
695 if (actions->second !=
"REMOVE") {
697 is->
uid = actions->first;
780 std::cout <<
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
781 std::cout <<
" -=+* WARNING *+=- -=+* WARNING *+=-\n\n\n";
782 std::cout <<
"Although Install Manager provides a convenient way for installing\n";
783 std::cout <<
"and upgrading SWORD components, it also uses a systematic method\n";
784 std::cout <<
"for accessing sites which gives packet sniffers a target to lock\n";
785 std::cout <<
"into for singling out users. \n\n\n";
786 std::cout <<
"IF YOU LIVE IN A PERSECUTED COUNTRY AND DO NOT WISH TO RISK DETECTION,\n";
787 std::cout <<
"YOU SHOULD *NOT* USE INSTALL MANAGER'S REMOTE SOURCE FEATURES.\n\n\n";
788 std::cout <<
"Also, Remote Sources other than CrossWire may contain less than\n";
789 std::cout <<
"quality modules, modules with unorthodox content, or even modules\n";
790 std::cout <<
"which are not legitimately distributable. Many repositories\n";
791 std::cout <<
"contain wonderfully useful content. These repositories simply\n";
792 std::cout <<
"are not reviewed or maintained by CrossWire and CrossWire\n";
793 std::cout <<
"cannot be held responsible for their content. CAVEAT EMPTOR.\n\n\n";
794 std::cout <<
"If you understand this and are willing to enable remote source features\n";
795 std::cout <<
"then type yes at the prompt\n\n";
796 std::cout <<
"enable? [no] ";
799 fgets(prompt, 9, stdin);
virtual int refreshRemoteSourceConfiguration()
static char unTarGZ(int fd, const char *destPath)
static const char * masterRepoList
#define SWORD_NAMESPACE_START
void setUnverifiedPeerAllowed(bool val)
bool unverifiedPeerAllowed
static int removeDir(const char *targetDir)
unsigned long length() const
virtual RemoteTransport * createFTPTransport(const char *host, StatusReporter *statusReporter)
static const unsigned int MODSTAT_OLDER
static const unsigned int MODSTAT_CIPHERKEYPRESENT
virtual SectionMap & getSections()
void setTimeoutMillis(long timeoutMillis)
static signed char existsDir(const char *ipath, const char *idirName=0)
static int openFileReadOnly(const char *fName)
virtual const char * getConfigEntry(const char *key) const
virtual char getURL(const char *destPath, const char *sourceURL, SWBuf *destBuf=0)
StatusReporter * statusReporter
bool isDefaultModule(const char *modName)
ModMap & getUtilModules()
static void closeFile(int fd)
void setPassive(bool passive)
StatusReporter * statusReporter
int stricmp(const char *s1, const char *s2)
void setUnverifiedPeerAllowed(bool allowed)
void setTimeoutMillis(long timeoutMillis)
static const unsigned int MODSTAT_NEW
SWModule * getModule(const char *modName)
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
ConfigEntMap & getSection(const char *section)
static std::map< SWModule *, int > getModuleStatus(const SWMgr &base, const SWMgr &other, bool utilModules=false)
bool isUnverifiedPeerAllowed()
const char * c_str() const
SWBuf & append(const char *str, long max=-1)
static int removeFile(const char *fName)
static int copyFile(const char *srcFile, const char *destFile)
void setFTPPassive(bool passive)
int copyDirectory(const char *urlPrefix, const char *dir, const char *dest, const char *suffix)
static void removeTrailingSlash(SWBuf &buf)
void setUser(const char *user)
std::set< SWBuf > defaultMods
static const unsigned int MODSTAT_CIPHERED
static int createParent(const char *pName)
unsigned long size() const
const char * stripPrefix(char separator, bool endOfStringAsSeparator=false)
static bool userDisclaimerConfirmed
static std::vector< struct DirEntry > getDirList(const char *dirPath, bool includeSize=false, bool includeIsDirectory=true)
virtual int installModule(SWMgr *destMgr, const char *fromLocation, const char *modName, InstallSource *is=0)
void setPasswd(const char *passwd)
static SWVersion currentVersion
static int createPathAndFile(const char *fName)
virtual int remoteCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer=false, const char *suffix="")
virtual int refreshRemoteSource(InstallSource *is)
static int copyDir(const char *srcDir, const char *destDir)
void deleteModule(const char *)
virtual RemoteTransport * createHTTPTransport(const char *host, StatusReporter *statusReporter)
InstallMgr(const char *privatePath="./", StatusReporter *statusReporter=0, SWBuf u="ftp", SWBuf p="installmgr@user.com")
static const unsigned int MODSTAT_UPDATED
#define SWORD_NAMESPACE_END
RemoteTransport * transport
virtual int removeModule(SWMgr *manager, const char *modName)
virtual bool getCipherCode(const char *modName, SWConfig *config)
InstallSource(const char *type, const char *confEnt=0)
virtual bool isUserDisclaimerConfirmed() const
static const unsigned int MODSTAT_SAMEVERSION
virtual void save() const