[sword-svn] r1963 - in trunk: . bindings/corba/orbitcpp include src/mgr

scribe at www.crosswire.org scribe at www.crosswire.org
Tue Aug 29 21:16:42 MST 2006


Author: scribe
Date: 2006-08-29 21:16:40 -0700 (Tue, 29 Aug 2006)
New Revision: 1963

Modified:
   trunk/ChangeLog
   trunk/bindings/corba/orbitcpp/server.cpp
   trunk/bindings/corba/orbitcpp/webmgr.hpp
   trunk/include/config.h
   trunk/include/swmgr.h
   trunk/src/mgr/swmgr.cpp
Log:
	Added recognition for the sysConfig parameter in SWMgr c-tor
	Updated CORBA server to allow option -sysConf /path/sword.conf



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-08-30 00:46:47 UTC (rev 1962)
+++ trunk/ChangeLog	2006-08-30 04:16:40 UTC (rev 1963)
@@ -1,6 +1,10 @@
 API ChangeLog	(see the ChangeLog in each 'apps' directory for
 		app specific changes)
 
+29-Aug-2006	Troy A. Griffitts <scribe at crosswire.org>
+	Added recognition for the sysConfig parameter in SWMgr c-tor
+	Updated CORBA server to allow option -sysConf /path/sword.conf
+
 16-Aug-2006	Troy A. Griffitts <scribe at crosswire.org>
 	Added new module lookup options:
 		./sword.conf

Modified: trunk/bindings/corba/orbitcpp/server.cpp
===================================================================
--- trunk/bindings/corba/orbitcpp/server.cpp	2006-08-30 00:46:47 UTC (rev 1962)
+++ trunk/bindings/corba/orbitcpp/server.cpp	2006-08-30 04:16:40 UTC (rev 1963)
@@ -5,12 +5,36 @@
 #include <swmgr.h>
 #include "webmgr.hpp"
 
-WebMgr swordmgr;
+SWConfig *sysConf = 0;
+WebMgr *swordMgr = 0;
 
+class CleanStatics {
+public:
+	CleanStatics() {}
+	~CleanStatics() {
+		if (swordMgr)
+			delete swordMgr;
 
+		if (sysConf)
+			delete sysConf;
+	}
+} cleanStatics;
 
+
+
+
 int main (int argc, char* argv[]) {
   try {
+
+	for (int i = 1; i < argc; i++) {
+		if (!strcmp(argv[i], "-sysConf")) {
+			if ((i+1) < argc)
+				sysConf = new SWConfig(argv[i+1]);
+		}
+	}
+
+	swordMgr = new WebMgr(sysConf);
+
  	  // Initialize the CORBA orb
  	  CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv);
 	
@@ -26,7 +50,7 @@
  	  mgr->activate();
 
  	  // Create a Servant and explicitly create a CORBA object
- 	  swordorb::SWMgr_impl servant(&swordmgr);
+ 	  swordorb::SWMgr_impl servant(swordMgr);
  	  CORBA::Object_var object = servant._this();
 
  	  // Here we get the IOR for the Hello server object.

Modified: trunk/bindings/corba/orbitcpp/webmgr.hpp
===================================================================
--- trunk/bindings/corba/orbitcpp/webmgr.hpp	2006-08-30 00:46:47 UTC (rev 1962)
+++ trunk/bindings/corba/orbitcpp/webmgr.hpp	2006-08-30 04:16:40 UTC (rev 1963)
@@ -21,7 +21,7 @@
 	SWModule *defaultHebParse;
 
 public:
-	WebMgr() : SWMgr(0, 0, false, new MarkupFilterMgr(FMT_WEBIF)) {
+	WebMgr(SWConfig *sysConf) : SWMgr(0, sysConf, false, new MarkupFilterMgr(FMT_WEBIF)) {
 		defaultGreekLex   = 0;
 		defaultHebLex     = 0;
 		defaultGreekParse = 0;

Modified: trunk/include/config.h
===================================================================
--- trunk/include/config.h	2006-08-30 00:46:47 UTC (rev 1962)
+++ trunk/include/config.h	2006-08-30 04:16:40 UTC (rev 1963)
@@ -44,19 +44,19 @@
 #define PACKAGE_NAME "sword"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "sword 1.5.9"
+#define PACKAGE_STRING "sword 1.5.8"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "sword"
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "1.5.9"
+#define PACKAGE_VERSION "1.5.8"
 
 /* Define to 1 if you have the ANSI C header files. */
 #define STDC_HEADERS 1
 
 /* Version number of package */
-#define VERSION "1.5.9"
+#define VERSION "1.5.8"
 
 /* Define to 1 if your processor stores words with the most significant byte
    first (like Motorola and SPARC, unlike Intel and VAX). */

Modified: trunk/include/swmgr.h
===================================================================
--- trunk/include/swmgr.h	2006-08-30 00:46:47 UTC (rev 1962)
+++ trunk/include/swmgr.h	2006-08-30 04:16:40 UTC (rev 1963)
@@ -167,7 +167,7 @@
 	/**
 	 *
 	 */
-	static void findConfig(char *configType, char **prefixPath, char **configPath, StringList *augPaths = 0);
+	static void findConfig(char *configType, char **prefixPath, char **configPath, StringList *augPaths = 0, SWConfig *providedSysConf = 0);
 
 	SWConfig *config;
 	SWConfig *sysconfig;

Modified: trunk/src/mgr/swmgr.cpp
===================================================================
--- trunk/src/mgr/swmgr.cpp	2006-08-30 00:46:47 UTC (rev 1962)
+++ trunk/src/mgr/swmgr.cpp	2006-08-30 04:16:40 UTC (rev 1963)
@@ -250,7 +250,7 @@
 }
 
 
-void SWMgr::commonInit(SWConfig * iconfig, SWConfig * isysconfig, bool autoload, SWFilterMgr *filterMgr, bool multiMod) {
+void SWMgr::commonInit(SWConfig *iconfig, SWConfig *isysconfig, bool autoload, SWFilterMgr *filterMgr, bool multiMod) {
 
 	init();
 
@@ -334,6 +334,9 @@
 	if (homeConfig)
 		delete homeConfig;
 
+	if (mysysconfig)
+		delete mysysconfig;
+
 	if (myconfig)
 		delete myconfig;
 
@@ -348,7 +351,7 @@
 }
 
 
-void SWMgr::findConfig(char *configType, char **prefixPath, char **configPath, std::list<SWBuf> *augPaths) {
+void SWMgr::findConfig(char *configType, char **prefixPath, char **configPath, std::list<SWBuf> *augPaths, SWConfig *providedSysConf) {
 	SWBuf path;
 	SWBuf sysConfPath;
 	ConfigEntMap::iterator entry;
@@ -356,108 +359,119 @@
 
 	char *envsworddir = getenv("SWORD_PATH");
 	char *envhomedir  = getenv("HOME");
+	SWConfig *sysConf = 0;
 
 	*configType = 0;
 	//debug=1;
 
-	// check working directory
-	DEBUGSTR("Checking working directory for sword.conf...");
-	if (FileMgr::existsFile(".", "sword.conf")) {
-		DEBUGSTR("\nOverriding any systemwide or ~/.sword/ sword.conf with one found in current directory.\n");
-		sysConfPath = "./sword.conf";
+	// check for a sysConf passed in to us
+	DEBUGSTR("Checking for provided SWConfig(\"sword.conf\")...");
+	if (providedSysConf) {
+		sysConf = providedSysConf;
+		DEBUGSTR("found.\n");
 	}
 	else {
-		DEBUGSTR("\nChecking working directory for mods.conf...");
-		if (FileMgr::existsFile(".", "mods.conf")) {
-			DEBUGSTR("found\n");
-			stdstr(prefixPath, "./");
-			stdstr(configPath, "./mods.conf");
-			return;
+		// check working directory
+		DEBUGSTR("\nChecking working directory for sword.conf...");
+		if (FileMgr::existsFile(".", "sword.conf")) {
+			DEBUGSTR("\nOverriding any systemwide or ~/.sword/ sword.conf with one found in current directory.\n");
+			sysConfPath = "./sword.conf";
 		}
+		else {
+			DEBUGSTR("\nChecking working directory for mods.conf...");
+			if (FileMgr::existsFile(".", "mods.conf")) {
+				DEBUGSTR("found\n");
+				stdstr(prefixPath, "./");
+				stdstr(configPath, "./mods.conf");
+				return;
+			}
 
-		DEBUGSTR("\nChecking working directory for mods.d...");
-		if (FileMgr::existsDir(".", "mods.d")) {
-			DEBUGSTR("found\n");
-			stdstr(prefixPath, "./");
-			stdstr(configPath, "./mods.d");
-			*configType = 1;
-			return;
-		}
-
-	   // check working directory ../library/
-		DEBUGSTR("\nChecking working directory ../library/ for mods.d...");
-		if (FileMgr::existsDir("../library", "mods.d")) {
-			DEBUGSTR("found\n");
-			stdstr(prefixPath, "../library/");
-			stdstr(configPath, "../library/mods.d");
-			*configType = 1;
-			return;
-		}
-
-		// check environment variable SWORD_PATH
-		DEBUGSTR("\nChecking SWORD_PATH...");
-
-		if (envsworddir != NULL) {
-			
-			DEBUGSTR("found (" << envsworddir << ")\n");
-			path = envsworddir;
-			if ((envsworddir[strlen(envsworddir)-1] != '\\') && (envsworddir[strlen(envsworddir)-1] != '/'))
-				path += "/";
-
-			DEBUGSTR("\nChecking $SWORD_PATH for mods.conf...");
-			if (FileMgr::existsFile(path.c_str(), "mods.conf")) {
+			DEBUGSTR("\nChecking working directory for mods.d...");
+			if (FileMgr::existsDir(".", "mods.d")) {
 				DEBUGSTR("found\n");
-				stdstr(prefixPath, path.c_str());
-				path += "mods.conf";
-				stdstr(configPath, path.c_str());
+				stdstr(prefixPath, "./");
+				stdstr(configPath, "./mods.d");
+				*configType = 1;
 				return;
 			}
 
-			DEBUGSTR("\nChecking $SWORD_PATH for mods.d...");
-			if (FileMgr::existsDir(path.c_str(), "mods.d")) {
+		   // check working directory ../library/
+			DEBUGSTR("\nChecking working directory ../library/ for mods.d...");
+			if (FileMgr::existsDir("../library", "mods.d")) {
 				DEBUGSTR("found\n");
-				stdstr(prefixPath, path.c_str());
-				path += "mods.d";
-				stdstr(configPath, path.c_str());
+				stdstr(prefixPath, "../library/");
+				stdstr(configPath, "../library/mods.d");
 				*configType = 1;
 				return;
 			}
-		}
 
+			// check environment variable SWORD_PATH
+			DEBUGSTR("\nChecking SWORD_PATH...");
 
-		// check for systemwide globalConfPath
+			if (envsworddir != NULL) {
+				
+				DEBUGSTR("found (" << envsworddir << ")\n");
+				path = envsworddir;
+				if ((envsworddir[strlen(envsworddir)-1] != '\\') && (envsworddir[strlen(envsworddir)-1] != '/'))
+					path += "/";
 
-		DEBUGSTR("\nParsing " << globalConfPath << "...");
-		char *globPaths = 0;
-		char *gfp;
-		stdstr(&globPaths, globalConfPath);
-		for (gfp = strtok(globPaths, ":"); gfp; gfp = strtok(0, ":")) {
-			DEBUGSTR("\nChecking for " << gfp << "...");
-			if (FileMgr::existsFile(gfp)) {
-				DEBUGSTR("found\n");
-				break;
+				DEBUGSTR("\nChecking $SWORD_PATH for mods.conf...");
+				if (FileMgr::existsFile(path.c_str(), "mods.conf")) {
+					DEBUGSTR("found\n");
+					stdstr(prefixPath, path.c_str());
+					path += "mods.conf";
+					stdstr(configPath, path.c_str());
+					return;
+				}
+
+				DEBUGSTR("\nChecking $SWORD_PATH for mods.d...");
+				if (FileMgr::existsDir(path.c_str(), "mods.d")) {
+					DEBUGSTR("found\n");
+					stdstr(prefixPath, path.c_str());
+					path += "mods.d";
+					stdstr(configPath, path.c_str());
+					*configType = 1;
+					return;
+				}
 			}
-		}
-		if (gfp)
-			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)) {
-				DEBUGSTR("\nOverriding any systemwide sword.conf with one found in users home directory.\n");
-				sysConfPath = homeDir;
+
+			// check for systemwide globalConfPath
+
+			DEBUGSTR("\nParsing " << globalConfPath << "...");
+			char *globPaths = 0;
+			char *gfp;
+			stdstr(&globPaths, globalConfPath);
+			for (gfp = strtok(globPaths, ":"); gfp; gfp = strtok(0, ":")) {
+				DEBUGSTR("\nChecking for " << gfp << "...");
+				if (FileMgr::existsFile(gfp)) {
+					DEBUGSTR("found\n");
+					break;
+				}
 			}
+			if (gfp)
+				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)) {
+					DEBUGSTR("\nOverriding any systemwide sword.conf with one found in users home directory.\n");
+					sysConfPath = homeDir;
+				}
+			}
 		}
 	}
 
+	if (sysConfPath.size()) {
+		sysConf = new SWConfig(sysConfPath);
+	}
 
-	if (sysConfPath.size()) {
-		SWConfig etcconf(sysConfPath);
-		if ((entry = etcconf.Sections["Install"].find("DataPath")) != etcconf.Sections["Install"].end()) {
+	if (sysConf) {
+		if ((entry = sysConf->Sections["Install"].find("DataPath")) != sysConf->Sections["Install"].end()) {
 			path = (*entry).second;
 			if (((*entry).second.c_str()[strlen((*entry).second.c_str())-1] != '\\') && ((*entry).second.c_str()[strlen((*entry).second.c_str())-1] != '/'))
 				path += "/";
@@ -485,8 +499,8 @@
 		}
 		if (augPaths) {
 			augPaths->clear();
-			entry     = etcconf.Sections["Install"].lower_bound("AugmentPath");
-			lastEntry = etcconf.Sections["Install"].upper_bound("AugmentPath");
+			entry     = sysConf->Sections["Install"].lower_bound("AugmentPath");
+			lastEntry = sysConf->Sections["Install"].upper_bound("AugmentPath");
 			for (;entry != lastEntry; entry++) {
 				path = entry->second;
 				if ((entry->second.c_str()[strlen(entry->second.c_str())-1] != '\\') && (entry->second.c_str()[strlen(entry->second.c_str())-1] != '/'))
@@ -496,6 +510,10 @@
 		}
 	}
 
+	if ((sysConf) && (!providedSysConf)) {
+		delete sysConf;
+	}
+
 	if (*configType)
 		return;
 
@@ -635,7 +653,7 @@
 	if (!config) {	// If we weren't passed a config object at construction, find a config file
 		if (!configPath) {	// If we weren't passed a config path at construction...
 			DEBUGSTR("LOOKING UP MODULE CONFIGURATION...\n");
-			findConfig(&configType, &prefixPath, &configPath, &augPaths);
+			findConfig(&configType, &prefixPath, &configPath, &augPaths, sysconfig);
 			DEBUGSTR("LOOKING UP MODULE CONFIGURATION COMPLETE.\n\n");
 		}
 		if (configPath) {




More information about the sword-cvs mailing list