[sword-svn] r2085 - in trunk: include src/mgr src/modules src/modules/filters tests utilities

scribe at www.crosswire.org scribe at www.crosswire.org
Sun Sep 23 15:07:22 MST 2007


Author: scribe
Date: 2007-09-23 15:07:22 -0700 (Sun, 23 Sep 2007)
New Revision: 2085

Modified:
   trunk/include/ftplibftpt.h
   trunk/include/utf8transliterator.h
   trunk/src/mgr/ftplibftpt.cpp
   trunk/src/modules/filters/utf8transliterator.cpp
   trunk/src/modules/swmodule.cpp
   trunk/tests/tlitmgrtest.cpp
   trunk/utilities/cipherraw.cpp
   trunk/utilities/installmgr.cpp
Log:
Changed FTPLibTransport to delay login until first use.
Fixed some warnings.


Modified: trunk/include/ftplibftpt.h
===================================================================
--- trunk/include/ftplibftpt.h	2007-09-23 20:42:20 UTC (rev 2084)
+++ trunk/include/ftplibftpt.h	2007-09-23 22:07:22 UTC (rev 2085)
@@ -4,8 +4,11 @@
 #include <defs.h>
 #include <ftptrans.h>
 
+typedef struct NetBuf netbuf;
+
 SWORD_NAMESPACE_START
 
+
 // initialize/cleanup SYSTEMWIDE library with life of this static.
 class FTPLibFTPTransport_init {
 public:
@@ -15,8 +18,10 @@
 
 
 class SWDLLEXPORT FTPLibFTPTransport : public FTPTransport {
-	void *nControl;
+	netbuf *ftpConnection;
 
+	char assureLoggedIn();
+
 public:
 	FTPLibFTPTransport(const char *host, StatusReporter *statusReporter = 0);
 	~FTPLibFTPTransport();

Modified: trunk/include/utf8transliterator.h
===================================================================
--- trunk/include/utf8transliterator.h	2007-09-23 20:42:20 UTC (rev 2084)
+++ trunk/include/utf8transliterator.h	2007-09-23 22:07:22 UTC (rev 2085)
@@ -54,7 +54,7 @@
 class SWDLLEXPORT UTF8Transliterator : public SWOptionFilter {
 private:
 
-	char option;
+	unsigned char option;
 
 	static const char optionstring[NUMTARGETSCRIPTS][16];
 

Modified: trunk/src/mgr/ftplibftpt.cpp
===================================================================
--- trunk/src/mgr/ftplibftpt.cpp	2007-09-23 20:42:20 UTC (rev 2084)
+++ trunk/src/mgr/ftplibftpt.cpp	2007-09-23 22:07:22 UTC (rev 2085)
@@ -27,43 +27,64 @@
 
 
 FTPLibFTPTransport::FTPLibFTPTransport(const char *host, StatusReporter *sr) : FTPTransport(host, sr) {
-	void *retVal = 0;
 
-	SWLog::getSystemLog()->logDebug("connecting to host %s\n", host);
-	if (FtpConnect(host, (netbuf **)&nControl))
-		retVal = nControl;
-	else
-		SWLog::getSystemLog()->logDebug("Failed to connect to %s\n", host);
-	if (!FtpLogin("anonymous", "installmgr at user.com", (netbuf *)nControl))
-		SWLog::getSystemLog()->logDebug("Failed to login to %s\n", host);
+	ftpConnection = 0;
 }
 
 
 FTPLibFTPTransport::~FTPLibFTPTransport() {
-	FtpQuit((netbuf *) nControl);
+	if (ftpConnection)
+		FtpQuit(ftpConnection);
 }
 
 
+char FTPLibFTPTransport::assureLoggedIn() {
+	char retVal = 0;
+	if (ftpConnection == 0) {
+		SWLog::getSystemLog()->logDebug("connecting to host %s\n", host.c_str());
+		if (FtpConnect(host, &ftpConnection))
+			if (FtpLogin("anonymous", "installmgr at user.com", ftpConnection)) {
+				retVal = 0;
+			}
+			else {
+				SWLog::getSystemLog()->logError("Failed to login to %s\n", host.c_str());
+				retVal = -2;
+			}
+		else {
+			SWLog::getSystemLog()->logError("Failed to connect to %s\n", host.c_str());
+			retVal = -1;
+		}
+	}
+	return retVal;
+}
+
+
 char FTPLibFTPTransport::getURL(const char *destPath, const char *sourceURL, SWBuf *destBuf) {
+
 	char retVal = 0;
+
+	// assert we can login
+	retVal = assureLoggedIn();
+	if (retVal) return retVal;
+
 	SWBuf sourcePath = sourceURL;
 	SWBuf outFile = (!destBuf) ? destPath : "swftplib.tmp";
 	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, (netbuf *)nControl);
+		FtpOptions(FTPLIB_CONNMODE, FTPLIB_PASSIVE, ftpConnection);
 	else
-		FtpOptions(FTPLIB_CONNMODE, FTPLIB_PORT, (netbuf *)nControl);
+		FtpOptions(FTPLIB_CONNMODE, FTPLIB_PORT, ftpConnection);
 	// !!!WDG also want to set callback options
 	if (sourcePath.endsWith("/") || sourcePath.endsWith("\\")) {
 		SWLog::getSystemLog()->logDebug("getting test directory %s\n", sourcePath.c_str());
-		FtpDir(NULL, sourcePath, (netbuf *)nControl);
+		FtpDir(NULL, sourcePath, ftpConnection);
 		SWLog::getSystemLog()->logDebug("getting real directory %s\n", sourcePath.c_str());
-		retVal = FtpDir(outFile.c_str(), sourcePath, (netbuf *)nControl) - 1;
+		retVal = FtpDir(outFile.c_str(), sourcePath, ftpConnection) - 1;
 	}
 	else {
 		SWLog::getSystemLog()->logDebug("getting file %s\n", sourcePath.c_str());
-		retVal = FtpGet(outFile.c_str(), sourcePath, FTPLIB_IMAGE, (netbuf *)nControl) - 1;
+		retVal = FtpGet(outFile.c_str(), sourcePath, FTPLIB_IMAGE, ftpConnection) - 1;
 	}
 
 	// Is there a way to FTPGet directly to a buffer?

Modified: trunk/src/modules/filters/utf8transliterator.cpp
===================================================================
--- trunk/src/modules/filters/utf8transliterator.cpp	2007-09-23 20:42:20 UTC (rev 2084)
+++ trunk/src/modules/filters/utf8transliterator.cpp	2007-09-23 22:07:22 UTC (rev 2085)
@@ -133,7 +133,7 @@
 #ifndef _ICUSWORD_
 	static const char translit_swordindex[] = "translit_swordindex";
 	
-	UResourceBundle *bundle, *transIDs, *colBund;
+	UResourceBundle *bundle = 0, *transIDs = 0, *colBund = 0;
 	bundle = ures_openDirect(SW_RESDATA, translit_swordindex, &status);
 	if (U_FAILURE(status)) {
 		SWLog::getSystemLog()->logError("UTF8Transliterator: ICU: no resource index to load");
@@ -142,7 +142,7 @@
 	}
 
 	transIDs = ures_getByKey(bundle, SW_RB_RULE_BASED_IDS, 0, &status);
-	UParseError parseError;
+	//UParseError parseError;
 
 	int32_t row, maxRows;
 	if (U_SUCCESS(status)) {
@@ -163,7 +163,7 @@
 						// 'file' or 'internal';
 						// row[2]=resource, row[3]=direction
 						{
-							UBool visible = (type == 0x0066 /*f*/);
+							//UBool visible = (type == 0x0066 /*f*/);
 							UTransDirection dir =
 								(ures_getUnicodeStringByIndex(colBund, 3, &status).charAt(0) ==
 								0x0046 /*F*/) ?

Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp	2007-09-23 20:42:20 UTC (rev 2084)
+++ trunk/src/modules/swmodule.cpp	2007-09-23 22:07:22 UTC (rev 2085)
@@ -926,8 +926,6 @@
 	SWKey *saveKey = 0;
 	SWKey *searchKey = 0;
 	SWKey textkey;
-	char *word = 0;
-	char *wordBuf = 0;
 	SWBuf c;
 
 

Modified: trunk/tests/tlitmgrtest.cpp
===================================================================
--- trunk/tests/tlitmgrtest.cpp	2007-09-23 20:42:20 UTC (rev 2084)
+++ trunk/tests/tlitmgrtest.cpp	2007-09-23 22:07:22 UTC (rev 2085)
@@ -488,7 +488,7 @@
                         // 'file' or 'internal';
                         // row[2]=resource, row[3]=direction
                         {
-                            UBool visible = (type == 0x0066 /*f*/);
+                            //UBool visible = (type == 0x0066 /*f*/);
                             UTransDirection dir =
                                 (ures_getUnicodeStringByIndex(colBund, 3, &status).charAt(0) ==
                                  0x0046 /*F*/) ?
@@ -556,7 +556,7 @@
                         // 'file' or 'internal';
                         // row[2]=resource, row[3]=direction
                         {
-                            UBool visible = (type == 0x0066 /*f*/);
+                            //UBool visible = (type == 0x0066 /*f*/);
                             UTransDirection dir =
                                 (ures_getUnicodeStringByIndex(colBund, 3, &status).charAt(0) ==
                                  0x0046 /*F*/) ?
@@ -604,7 +604,7 @@
 	}
 
     transIDs = ures_getByKey(bundle, RB_RULE_BASED_IDS, 0, &status);
-	UParseError parseError;
+	//UParseError parseError;
 
     int32_t row, maxRows;
     if (U_SUCCESS(status)) {
@@ -625,7 +625,7 @@
                         // 'file' or 'internal';
                         // row[2]=resource, row[3]=direction
                         {
-                            UBool visible = (type == 0x0066 /*f*/);
+                            //UBool visible = (type == 0x0066 /*f*/);
                             UTransDirection dir =
                                 (ures_getUnicodeStringByIndex(colBund, 3, &status).charAt(0) ==
                                  0x0046 /*F*/) ?

Modified: trunk/utilities/cipherraw.cpp
===================================================================
--- trunk/utilities/cipherraw.cpp	2007-09-23 20:42:20 UTC (rev 2084)
+++ trunk/utilities/cipherraw.cpp	2007-09-23 22:07:22 UTC (rev 2085)
@@ -31,7 +31,7 @@
 	char *tmpbuf;
 	
 	if (argc != 3) {
-		printf("%d %d\n", sizeof(long), sizeof(unsigned short));
+		printf("%ld %ld\n", sizeof(long), sizeof(unsigned short));
 		fprintf(stderr, "usage: %s <datapath> \"<key>\"\n", argv[0]);
 		exit(1);
 	}

Modified: trunk/utilities/installmgr.cpp
===================================================================
--- trunk/utilities/installmgr.cpp	2007-09-23 20:42:20 UTC (rev 2084)
+++ trunk/utilities/installmgr.cpp	2007-09-23 22:07:22 UTC (rev 2085)
@@ -120,8 +120,9 @@
 		fprintf(stderr, "Couldn't find remote source [%s]\n", sourceName);
 		finish(-3);
 	}
-	installMgr->refreshRemoteSource(source->second);
-	cout << "Remote Source Refreshed\n";
+	if (!installMgr->refreshRemoteSource(source->second))
+		cout << "Remote Source Refreshed\n";
+	else	cerr << "Error Refreshing Remote Source\n";
 }
 
 




More information about the sword-cvs mailing list