[sword-svn] r2478 - in trunk: . icu include lib m4 src/mgr src/modules src/modules/common src/modules/filters src/utilfuns tests utilities utilities/diatheke

scribe at crosswire.org scribe at crosswire.org
Thu Dec 3 15:36:02 MST 2009


Author: scribe
Date: 2009-12-03 15:36:02 -0700 (Thu, 03 Dec 2009)
New Revision: 2478

Added:
   trunk/m4/colored-echo.m4
Modified:
   trunk/ChangeLog
   trunk/Makefile.am
   trunk/configure.ac
   trunk/icu/Makefile.am
   trunk/include/Makefile.am
   trunk/lib/Makefile.am
   trunk/src/mgr/curlftpt.cpp
   trunk/src/mgr/ftplibftpt.cpp
   trunk/src/modules/common/Makefile.am
   trunk/src/modules/common/sapphire.cpp
   trunk/src/modules/filters/Makefile.am
   trunk/src/modules/swmodule.cpp
   trunk/src/utilfuns/Makefile.am
   trunk/src/utilfuns/ftplib.c
   trunk/tests/Makefile.am
   trunk/usrinst.sh
   trunk/utilities/Makefile.am
   trunk/utilities/addld.cpp
   trunk/utilities/diatheke/Makefile.am
   trunk/utilities/imp2ld.cpp
   trunk/utilities/imp2vs.cpp
   trunk/utilities/installmgr.cpp
   trunk/utilities/osis2mod.cpp
   trunk/utilities/tei2mod.cpp
Log:
Preparing for 1.6.1
	Fixed and updated autoconf configuration
	Updated installmgr util to allow multiple
		commands and update dl progress
	Added progress reporting to FtpLib transport
	Added ability to cancel during file transport,
		per Eeli's suggestion
	Increased clucene buffer size - mwtalbert
	On clucene index creation, error out on no
		write perms - mwtalbert



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/ChangeLog	2009-12-03 22:36:02 UTC (rev 2478)
@@ -1,12 +1,22 @@
 API ChangeLog 
 
 
+02-Dec-2009	Troy A. Griffitts <scribe at crosswire.org>
+	Updated installmgr util to allow multiple
+		commands and update dl progress
+	Added progress reporting to FtpLib transport
+	Added ability to cancel during file transport,
+		per Eeli's suggestion
+	Increased clucene buffer size - mwtalbert
+	On clucene index creation, error out on no
+		write perms - mwtalbert
+
 12-Oct-2009	Troy A. Griffitts <scribe at crosswire.org>
 	Added initial impl for CurlHTTPTransport submitted
 		by Nic Carter <niccarter at mac.com>
 	Added initial Android ifdefs to get things compiling
-		under the Android NDK.
-	Added bindings/java-jni for Android development.
+		under the Android NDK
+	Added bindings/java-jni for Android development
 
 09-Aug-2009	Troy A. Griffitts <scribe at crosswire.org>
 	Added checks for Hebrew and Arabic when stripping

Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/Makefile.am	2009-12-03 22:36:02 UTC (rev 2478)
@@ -1,73 +1,25 @@
 AUTOMAKE_OPTIONS = 1.6
 
-# this WILL NOT WORK for you. only inhouse patched version of
-# sapphire will omit enciphering code when set to yes, so leave
-# as no, unless you really know what you're doing
-
-legalexport := no
-
 ACLOCAL_AMFLAGS = -I m4
+LDADD = $(top_builddir)/lib/libsword.la
 
-##### Customizable stuff. Set it how you like it #####
-
-# if building dll with gcc on windoze (www.mingw.org)
-# note you must set need_local_regex and buildshare to yes
-if MINGW
-mingw = yes
-need_local_regex := yes
-else
-
-# need regular expression stuff?
-need_local_regex := no
-
-# shared library - set to yes if you would like to build
-#buildshare := @enable_shared@
-
-endif
-
-# Debugging options etc...
-debug   := @enable_debug@
-profile := @enable_profile@
-
-
-# endian, etc. support for other hardware
-
-system := @target_system@
-
-#system := intel
-#system := sparc_solaris
-#system := macosx
-#system := arm
-#system := gnu_bigendian
-#system := beos
-
-# SPARC Solaris users should define system as sparc_solaris; SPARC users running Linux or other OSes with glibc, like Debian GNU/Linux should use gnu_bigendian instead
-
-# to build on FreeBSD, simply use gmake instead of make
-
-# to build for Darwin on PPC, set system to macosx
-
-
-# zLib support
-zlib := @with_zlib@
-
-# icu support
-icu := @with_icu@
-
 # Global config directory
 globalconfdir := @sysconfdir@
 
 SUBDIRS = lib . icu
+
 if BUILDTESTS
 TESTSDIR = tests
 else
 TESTSDIR =
 endif
+
 if BUILDUTILS
 UTILSDIR = utilities
 else
 UTILSDIR =
 endif
+
 if BUILDEXAMPLES
 EXAMPLESDIR = examples
 else
@@ -76,7 +28,6 @@
 
 SUBDIRS += $(TESTSDIR) $(UTILSDIR) $(EXAMPLESDIR)
 
-AM_CPPFLAGS = -I $(top_srcdir)/include
 EXTRA_DIST = sword.spec sword.kdevprj sword.bmp usrinst.sh autogen.sh sword.pc.in
 
 if USE_PKGCONF
@@ -99,12 +50,7 @@
 noinst_PROGRAMS = buildtest
 buildtest_SOURCES = buildtest.cpp
 
-if ICU
-iculibs = -licui18n -licuuc
-endif
 
-buildtest_LDADD = $(top_builddir)/lib/libsword.la
-
 include locales.d/Makefile.am
 include samples/Makefile.am
 include doc/Makefile.am

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/configure.ac	2009-12-03 22:36:02 UTC (rev 2478)
@@ -29,6 +29,8 @@
 AC_LIBTOOL_WIN32_DLL
 AC_PROG_LIBTOOL
 
+COLORED_ECHO_INIT
+
 AC_C_BIGENDIAN
 
 ACX_CLUCENE
@@ -99,13 +101,17 @@
 # Check libraries
 # ---------------------------------------------------------------------
 if test x$with_zlib  = xyes; then
-	AC_CHECK_LIB(z, compress)
+	AC_CHECK_LIB(z, compress,,with_zlib="no")
+else
+	with_zlib="no"
 fi
 
-#if test x$with_installmgr  = xftplib; then
-#	AC_CHECK_LIB(ftplib, FtpGet)
-#fi
+if test "x$with_zlib" = xno; then
+	AM_CFLAGS="$AM_CFLAGS -DEXCLUDEZLIB"
+	AM_CXXFLAGS="$AM_CXXFLAGS -DEXCLUDEZLIB"
+fi
 
+
 # ---------------------------------------------------------------------
 # Find CppUnit
 # ---------------------------------------------------------------------
@@ -167,12 +173,19 @@
      AM_CFLAGS="$AM_CFLAGS -D_ICU_"
 fi
 
+if test "x$ICU_LIBS" != x; then
+	with_icu=yes
+	LIBS="$LIBS $ICU_LIBS $ICU_IOLIBS"
+else
+	with_icu=no
+fi
 
+
+# why?  what is this for?
+with_swordicu=$with_icu
+
+
 AM_CXXFLAGS="$AM_CXXFLAGS -ftemplate-depth-25"
-#  AC_DEFINE(DEBUG)
-#else
-#  AC_DEFINE(NDEBUG)
-#fi
 
 if test x$enable_warnings = xyes; then
   AM_CFLAGS="$AM_CFLAGS -Werror"
@@ -193,29 +206,32 @@
 # Check for curl for installmgr suport
 # ---------------------------------------------------------------------
 
-CURL_AM_CFLAGS=
-CURL_LIBS=
-#if test x$with_installmgr = xcurl; then
+with_internalftplib=no
 if test x$with_curl = xyes; then
     AC_PATH_PROG(CURL_CONFIG, curl-config, no)
     if test "$CURL_CONFIG" = "no" ; then
 	echo "*** The curl-config script installed by curl could not be found"
 	echo "*** compiling without libcurl support"
 	with_curl=no
+	with_internalftplib=yes
     else
 	echo "curl found - remote install options available"
 	CURL_AM_CFLAGS=`$CURL_CONFIG --cflags`
 	CURL_LIBS=`$CURL_CONFIG --libs`
-	AM_CXXFLAGS="$AM_CXXFLAGS -DCURLAVAILABLE"
-	AM_CFLAGS="$AM_CFLAGS -DCURLAVAILABLE"
+	AM_CXXFLAGS="$AM_CXXFLAGS -DCURLAVAILABLE $CURL_AM_CFLAGS"
+	AM_CFLAGS="$AM_CFLAGS -DCURLAVAILABLE $CURL_AM_CFLAGS"
+	LIBS="$LIBS $CURL_LIBS"
     fi
+else
+	with_curl=no;
+	with_internalftplib=yes
 fi
 
 # ---------------------------------------------------------------------
 # Check for clucene for lucene searching support
 # ---------------------------------------------------------------------
 
-use_clucene=
+with_clucene=no
 if test -z "$CLUCENE_LIBS"; then
    echo "lucene searching options not available"
 else
@@ -223,7 +239,7 @@
    AM_CXXFLAGS="$AM_CXXFLAGS $CLUCENE_CXXFLAGS -DUSELUCENE"
    AM_CFLAGS="$AM_CFLAGS -DUSELUCENE"
    LIBS="$LIBS $CLUCENE_LIBS"
-   use_clucene="yes"
+   with_clucene="yes"
 fi
 
 AC_CHECK_FUNCS(vsnprintf, [have_vsnprintf="yes"])
@@ -247,13 +263,7 @@
 AC_SUBST(with_conf)
 AC_SUBST(dir_confdef)
 AC_SUBST(CC)
-AC_SUBST(CURL_AM_CFLAGS)
-AC_SUBST(CURL_LIBS)
-#AC_SUBST(LUCENE_LIBS)
-AC_SUBST(ICU_LIBS)
-AC_SUBST(ICU_IOLIBS)
 AC_SUBST(ICU_VER)
-AC_SUBST(XML_LIBS)
 AC_SUBST(enable_debug)
 AC_SUBST(enable_profile)
 AC_SUBST(AM_CXXFLAGS)
@@ -270,24 +280,21 @@
 # ---------------------------------------------------------------------
 # Conditional variables
 # ---------------------------------------------------------------------
+
+# don't #ifdef in .cpp files HAVE_ stuff because non-ac compiles won't be able to switch them since we include config.h
+AM_CONDITIONAL(HAVE_LIBZ, test x$with_zlib = xyes)
+AM_CONDITIONAL(HAVE_ICU, test x$with_icu = xyes)
+AM_CONDITIONAL(HAVE_ICUSWORD, test x$with_swordicu = xyes)
 AM_CONDITIONAL(HAVE_VSNPRINTF, test x$have_vsnprintf = xyes)
+
 AM_CONDITIONAL(MINGW, test x$target_mingw32 = xyes)
-AM_CONDITIONAL(ICU, test x$with_icu = xyes)
-AM_CONDITIONAL(USELUCENE, test x$use_clucene = xyes)
-AM_CONDITIONAL(ICUSWORD, test x$with_icu = xsword)
-AM_CONDITIONAL(ZLIB, test x$with_zlib = xyes)
+AM_CONDITIONAL(USELUCENE, test x$with_clucene = xyes)
 AM_CONDITIONAL(SHAREDLIB, test x$enable_shared = xyes)
 AM_CONDITIONAL(INSTCONF, test x$with_conf = xyes)
-AM_CONDITIONAL(INSTALLMGR, test x$with_curl = xyes)
-#AM_CONDITIONAL(INTERNALFTPLIB, test x$with_installmgr = xinternal)
-#AM_CONDITIONAL(WITHCURL, test x$with_installmgr = xcurl)
 AM_CONDITIONAL(WITHCURL, test x$with_curl = xyes)
-AM_CONDITIONAL(INTERNALFTPLIB, test x$with_curl != xyes)
-#AM_CONDITIONAL(WITHFTPLIB, test x$with_installmgr = xftplib)
+AM_CONDITIONAL(INTERNALFTPLIB, test x$with_internalftplib = xyes)
 AM_CONDITIONAL(CONFDEF, test x$dir_confdef = xyes)
 AM_CONDITIONAL(USE_PKGCONF, test x$use_pkgconfig = xyes)
-#AM_CONDITIONAL(DEBUG, test x$with_debug = xyes)
-#AM_CONDITIONAL(PROFILE, test x$with_profile = xyes)
 AM_CONDITIONAL(BUILDTESTS, test x$enable_tests = xyes)
 AM_CONDITIONAL(BUILDUTILS, test x$enable_utilities = xyes)
 AM_CONDITIONAL(BUILDEXAMPLES, test x$enable_examples = xyes)
@@ -298,3 +305,19 @@
 AC_CONFIG_FILES(Makefile lib/Makefile tests/Makefile tests/cppunit/Makefile utilities/Makefile examples/Makefile examples/cmdline/Makefile utilities/diatheke/Makefile icu/Makefile sword.pc sword.spec)
 AC_OUTPUT
 
+echo
+echo
+COLORED_ECHO([Configuration:])
+COLORED_ECHO([    DEBUG:            $enable_debug])
+COLORED_ECHO([    PROFILE:          $enable_profile])
+COLORED_ECHO([    LIBZ:             $with_zlib])
+COLORED_ECHO([    ICU:              $with_icu])
+COLORED_ECHO([    ICUSWORD:         $with_swordicu])
+COLORED_ECHO([    CURL:             $with_curl])
+COLORED_ECHO([    INTERNAL FTPLIB:  $with_internalftplib])
+COLORED_ECHO([    CLUCENE:          $with_clucene])
+echo
+echo
+
+
+

Modified: trunk/icu/Makefile.am
===================================================================
--- trunk/icu/Makefile.am	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/icu/Makefile.am	2009-12-03 22:36:02 UTC (rev 2478)
@@ -11,7 +11,7 @@
 swicuSOURCES += translit_Any_Latex.txt
 swicuSOURCES += translit_swordindex.txt
 
-if ICU
+if HAVE_ICU
 swicu_DATA = $(swicuSOURCES:.txt=.res)
 else
 swicu_DATA =
@@ -26,7 +26,7 @@
 	$(GENRB) -s . -d . $<
 
 
-if ICU
+if HAVE_ICU
 swicudir = $(pkglibdir)/${VERSION}_icu_${ICU_VER}
 
 #installswicu_DATA: $(swicu_DATA)

Modified: trunk/include/Makefile.am
===================================================================
--- trunk/include/Makefile.am	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/include/Makefile.am	2009-12-03 22:36:02 UTC (rev 2478)
@@ -75,7 +75,9 @@
 pkginclude_HEADERS += $(swincludedir)/rawstr4.h
 pkginclude_HEADERS += $(swincludedir)/rawtext.h
 pkginclude_HEADERS += $(swincludedir)/rawverse.h
+if MINGW
 pkginclude_HEADERS += $(swincludedir)/regex.h
+endif
 pkginclude_HEADERS += $(swincludedir)/roman.h
 pkginclude_HEADERS += $(swincludedir)/rtfhtml.h
 pkginclude_HEADERS += $(swincludedir)/sapphire.h

Modified: trunk/lib/Makefile.am
===================================================================
--- trunk/lib/Makefile.am	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/lib/Makefile.am	2009-12-03 22:36:02 UTC (rev 2478)
@@ -2,40 +2,20 @@
 AM_CPPFLAGS = -I$(top_srcdir)/include -I$(includedir) 
 AM_CPPFLAGS += -DUSE_AUTOTOOLS -DUNIX -Dunix -D__unix__
 
-if ZLIB
-ZLIBDEF = 
-else
-ZLIBDEF = -DEXCLUDEZLIB
-endif
-
-AM_CPPFLAGS += $(ZLIBDEF)
-
 # Global config directory
 globalconfdir := @sysconfdir@
 
 lib_LTLIBRARIES = libsword.la
 
 libsword_la_SOURCES =
-if ICU
-ICULIBADD = $(ICU_LIBS) $(ICU_IOLIBS)
+if HAVE_ICU
 ICUDEF = -DSWICU_DATA=\"${pkglibdir}/${VERSION}_icu_${ICU_VER}\" 
 else
-ICULIBADD =
 ICUDEF =
 endif
 
 AM_CPPFLAGS += $(ICUDEF)
 
-#if WITHCURL
-if INSTALLMGR
-IMGRLIBADD = -lcurl $(CURL_LIBS)
-else
-IMGRLIBADD =
-endif
-
-
-libsword_la_LIBADD = $(ICULIBADD) $(IMGRLIBADD) $(CLUCENE_LIBS)
-
 libsword_la_LDFLAGS = -release $(VERSION)
 
 include ../src/keys/Makefile.am

Added: trunk/m4/colored-echo.m4
===================================================================
--- trunk/m4/colored-echo.m4	                        (rev 0)
+++ trunk/m4/colored-echo.m4	2009-12-03 22:36:02 UTC (rev 2478)
@@ -0,0 +1,75 @@
+dnl
+dnl Macro to output bold and colored text.
+dnl
+
+dnl COLORED_ECHO_INIT
+dnl This macro must be called first to initialize a context.
+AC_DEFUN([COLORED_ECHO_INIT],
+[
+  dnl Prepare fancy console output, taken from GNU shtools.
+  colored_echo_bold=''
+  colored_echo_norm=''
+
+  AC_PROG_AWK
+  if test x"$AWK" = x"not found"; then
+    return
+  fi
+
+  case $TERM in
+  xterm|xterm*|vt220|vt220*)
+    dnl For the most important terminal types we directly know the
+    dnl sequences.
+    colored_echo_bold=`$AWK 'BEGIN { printf("%c%c%c%c", 27, 91, 49, 109); }' </dev/null 2>/dev/null`
+    colored_echo_norm=`$AWK 'BEGIN { printf("%c%c%c", 27, 91, 109); }' </dev/null 2>/dev/null`
+    ;;
+
+  vt100|vt100*|cygwin)
+    colored_echo_bold=`$AWK 'BEGIN { printf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); }' </dev/null 2>/dev/null`
+    colored_echo_norm=`$AWK 'BEGIN { printf("%c%c%c%c%c", 27, 91, 109, 0, 0); }' </dev/null 2>/dev/null`
+    ;;
+
+  *)
+    dnl For all others, we try to use a possibly existing `tput' or
+    dnl `tcout' utility.
+    paths=`$ECHO $PATH | sed -e 's/:/ /g'`
+    for tool in tput tcout; do
+      for dir in $paths; do
+        if test -r "$dir/$tool" ; then
+          for seq in bold md smso; do
+            bold="`$dir/$tool $seq 2>/dev/null`"
+            if test ".$bold" != . ; then
+              colored_echo_bold="$bold"
+              break
+            fi
+          done
+          if test ".$colored_echo_bold" != . ; then
+            for seq in sgr0 me rmso init reset; do
+              norm="`$dir/$tool $seq 2>/dev/null`"
+              if test ".$norm" != . ; then
+                colored_echo_norm="$norm"
+                break
+              fi
+            done
+          fi
+          break
+        fi
+      done
+      if test x"$colored_echo_bold" != "x" -a x"$colored_echo_norm" != "x"; then
+        break;
+      fi
+    done
+    ;;
+  esac
+])
+
+dnl COLORED_ECHO(TEXT)
+dnl Output text with:
+dnl   o  everything between %B and %b displayed bold.
+AC_DEFUN([COLORED_ECHO],
+[
+  text=`$ECHO $seo "$1" | sed -e "s/%B/${colored_echo_bold}/g" -e "s/%b/${colored_echo_norm}/g" 2>/dev/null`
+  $ECHO $seo "$text"
+
+  text=`$ECHO $sec "$1" | sed -e "s/%B//g" -e "s/%b//g" 2>/dev/null`
+  _AS_ECHO_LOG($text)
+])

Modified: trunk/src/mgr/curlftpt.cpp
===================================================================
--- trunk/src/mgr/curlftpt.cpp	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/src/mgr/curlftpt.cpp	2009-12-03 22:36:02 UTC (rev 2478)
@@ -47,7 +47,7 @@
 static CURLFTPTransport_init _CURLFTPTransport_init;
 
 CURLFTPTransport_init::CURLFTPTransport_init() {
-	//curl_global_init(CURL_GLOBAL_DEFAULT);  // curl_easy_init automatically calls it if needed
+	curl_global_init(CURL_GLOBAL_DEFAULT);  // curl_easy_init automatically calls it if needed
 }
 
 CURLFTPTransport_init::~CURLFTPTransport_init() {
@@ -72,9 +72,20 @@
 }
 
 
+struct MyProgressData {
+	StatusReporter *sr;
+	bool *term;
+};
+
+
 int my_fprogress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) {
 	if (clientp) {
-		((StatusReporter *)clientp)->statusUpdate(dltotal, dlnow);
+		MyProgressData *pd = (MyProgressData *)clientp;
+SWLog::getSystemLog()->logDebug("CURLFTPTransport report progress: totalSize: %ld; xfered: %ld\n", (long)dltotal, (long)dlnow);
+		if (pd->sr) {
+			pd->sr->statusUpdate(dltotal, dlnow);
+			if (*(pd->term)) return 1;
+		}
 	}
 	return 0;
 }
@@ -124,6 +135,11 @@
 	CURLcode res;
 	
 	if (session) {
+
+		struct MyProgressData pd;
+		pd.sr = statusReporter;
+		pd.term = &term;
+
 		curl_easy_setopt(session, CURLOPT_URL, sourceURL);
 	
 		SWBuf credentials = u + ":" + p;
@@ -132,7 +148,7 @@
 		if (!passive)
 			curl_easy_setopt(session, CURLOPT_FTPPORT, "-");
 		curl_easy_setopt(session, CURLOPT_NOPROGRESS, 0);
-		curl_easy_setopt(session, CURLOPT_PROGRESSDATA, statusReporter);
+		curl_easy_setopt(session, CURLOPT_PROGRESSDATA, &pd);
 		curl_easy_setopt(session, CURLOPT_PROGRESSFUNCTION, my_fprogress);
 		curl_easy_setopt(session, CURLOPT_DEBUGFUNCTION, my_trace);
 		/* Set a pointer to our struct to pass to the callback */

Modified: trunk/src/mgr/ftplibftpt.cpp
===================================================================
--- trunk/src/mgr/ftplibftpt.cpp	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/src/mgr/ftplibftpt.cpp	2009-12-03 22:36:02 UTC (rev 2478)
@@ -32,9 +32,34 @@
 
 SWORD_NAMESPACE_START
 
+namespace {
 
+struct MyProgressData {
+	StatusReporter *sr;
+	long totalSize;
+	bool *term;
+};
+
+int my_fprogress(netbuf *nControl, int xfered, void *arg) {
+	if (arg) {
+		MyProgressData *pd = (MyProgressData *)arg;
+SWLog::getSystemLog()->logDebug("FTPLibFTPTransport report progress: totalSize: %ld; xfered: %d\n", pd->totalSize, xfered);
+		if (pd->sr) {
+			pd->sr->statusUpdate(pd->totalSize, xfered);
+			if (*(pd->term)) return 0;
+		}
+	}
+	return 1;
+}
+
+}
+
+
+
 static FTPLibFTPTransport_init _FTPLibFTPTransport_init;
 
+
+
 FTPLibFTPTransport_init::FTPLibFTPTransport_init() {
 	FtpInit();
 }
@@ -78,7 +103,15 @@
 	return retVal;
 }
 
+// yeah yeah, I know I know.  Compile with curl support if you don't like it
+#pragma GCC diagnostic ignored "-Wall"
+void my_tmpnam(char *tmpName) {
+	tmpnam(tmpName);
+}
+#pragma GCC diagnostic warning "-Wall"
 
+
+
 char FTPLibFTPTransport::getURL(const char *destPath, const char *sourceURL, SWBuf *destBuf) {
 
 	char retVal = 0;
@@ -100,7 +133,7 @@
 		outFile = "/sdcard/sword/InstallMgr/swtmpbuf.out";
 #else
 		char tmpName[128];
-		tmpnam(tmpName);
+		my_tmpnam(tmpName);
 		outFile = tmpName;
 #endif
 	}
@@ -111,22 +144,35 @@
 		FtpOptions(FTPLIB_CONNMODE, FTPLIB_PASSIVE, ftpConnection);
 	else
 		FtpOptions(FTPLIB_CONNMODE, FTPLIB_PORT, ftpConnection);
+
+	struct MyProgressData pd;
+	pd.sr = statusReporter;
+	pd.term = &term;
+	pd.totalSize = 0;
+
 	// !!!WDG also want to set callback options
+	FtpOptions(FTPLIB_CALLBACK, (long)&my_fprogress, ftpConnection);
+	FtpOptions(FTPLIB_CALLBACKARG, (long)&pd, ftpConnection);
+	FtpOptions(FTPLIB_CALLBACKBYTES, (long)2048, ftpConnection);
+
 	if (sourcePath.endsWith("/") || sourcePath.endsWith("\\")) {
-		SWLog::getSystemLog()->logDebug("getting test directory %s\n", sourcePath.c_str());
-		FtpDir(NULL, sourcePath, ftpConnection);
+//		SWLog::getSystemLog()->logDebug("getting test directory %s\n", sourcePath.c_str());
+//		FtpDir(NULL, sourcePath, ftpConnection);
 		SWLog::getSystemLog()->logDebug("getting real directory %s\n", sourcePath.c_str());
 		retVal = FtpDir(outFile.c_str(), sourcePath, ftpConnection) - 1;
 		SWLog::getSystemLog()->logDebug("got real directory %s to %s\n", sourcePath.c_str(), outFile.c_str());
 	}
 	else {
 		SWLog::getSystemLog()->logDebug("getting file %s\n", sourcePath.c_str());
+		int size;
+		FtpSize(sourcePath, &size, FTPLIB_IMAGE, ftpConnection);
+		pd.totalSize = size;
 		retVal = FtpGet(outFile.c_str(), sourcePath, FTPLIB_IMAGE, ftpConnection) - 1;
 	}
 
 	// Is there a way to FTPGet directly to a buffer?
 	// If not, we probably want to add x-platform way to open a tmp file with FileMgr
-	// This wreaks and will easily fail if a user's CWD is not writable.
+	// Currently outFile is set to tmpFile above sortof unsafe
 	if (destBuf) {
 		SWLog::getSystemLog()->logDebug("filling destBuf\n");
 		FileDesc *fd = FileMgr::getSystemFileMgr()->open(outFile.c_str(), FileMgr::RDONLY);

Modified: trunk/src/modules/common/Makefile.am
===================================================================
--- trunk/src/modules/common/Makefile.am	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/src/modules/common/Makefile.am	2009-12-03 22:36:02 UTC (rev 2478)
@@ -5,7 +5,7 @@
 libsword_la_SOURCES += $(commondir)/swcomprs.cpp
 libsword_la_SOURCES += $(commondir)/lzsscomprs.cpp
 
-if ZLIB
+if HAVE_LIBZ
 SWZLIB = $(commondir)/zipcomprs.cpp
 else
 SWZLIB =

Modified: trunk/src/modules/common/sapphire.cpp
===================================================================
--- trunk/src/modules/common/sapphire.cpp	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/src/modules/common/sapphire.cpp	2009-12-03 22:36:02 UTC (rev 2478)
@@ -144,7 +144,6 @@
 
 unsigned char sapphire::encrypt(unsigned char b)
     {
-#ifdef USBINARY
     // Picture a single enigma rotor with 256 positions, rewired
     // on the fly by card-shuffling.
 
@@ -172,9 +171,6 @@
                                cards[avalanche])&0xFF]];
     last_plain = b;
     return last_cipher;
-#else
-    return b;
-#endif
     }
 
 unsigned char sapphire::decrypt(unsigned char b)

Modified: trunk/src/modules/filters/Makefile.am
===================================================================
--- trunk/src/modules/filters/Makefile.am	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/src/modules/filters/Makefile.am	2009-12-03 22:36:02 UTC (rev 2478)
@@ -83,13 +83,11 @@
 SWICUSRC += $(filtersdir)/utf8arshaping.cpp
 SWICUSRC += $(filtersdir)/utf8bidireorder.cpp
 
-if ICU
-ICUDEFS = -D_ICU_
+if HAVE_ICU
 DISTSWICUSRC =
 SWREALICUSRC = $(SWICUSRC)
 else
-if ICUSWORD
-ICUDEFS = -D_ICU_ -D_ICUSWORD_
+if HAVE_ICUSWORD
 DISTSWICUSRC =
 SWREALICUSRC = $(SWICUSRC)
 else
@@ -98,7 +96,6 @@
 endif
 endif
 
-AM_CPPFLAGS += $(ICUDEFS)
 libsword_la_SOURCES += $(SWREALICUSRC)
 EXTRA_DIST = $(DISTSWICUSRC)
 

Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/src/modules/swmodule.cpp	2009-12-03 22:36:02 UTC (rev 2478)
@@ -432,9 +432,9 @@
 
 #ifdef USELUCENE
 	SWBuf target = getConfigEntry("AbsoluteDataPath");
-	char ch = target.c_str()[strlen(target.c_str())-1];
-	if ((ch != '/') && (ch != '\\'))
+	if (!target.endsWith("/") && !target.endsWith("\\")) {
 		target.append('/');
+	}
 	target.append("lucene");
 #endif
 	if (justCheckIfSupported) {
@@ -511,7 +511,8 @@
 			is = new IndexSearcher(ir);
 			(*percent)(10, percentUserData);
 
-			standard::StandardAnalyzer analyzer;
+			const TCHAR *stopWords[] = { 0 };
+			standard::StandardAnalyzer analyzer(stopWords);
 			lucene_utf8towcs(wcharBuffer, istr, MAX_CONV_SIZE); //TODO Is istr always utf8?
 			q = QueryParser::parse(wcharBuffer, _T("content"), &analyzer);
 			(*percent)(20, percentUserData);
@@ -978,9 +979,9 @@
 void SWModule::deleteSearchFramework() {
 #ifdef USELUCENE
 	SWBuf target = getConfigEntry("AbsoluteDataPath");
-	char ch = target.c_str()[strlen(target.c_str())-1];
-	if ((ch != '/') && (ch != '\\'))
+	if (!target.endsWith("/") && !target.endsWith("\\")) {
 		target.append('/');
+	}
 	target.append("lucene");
 
 	FileMgr::removeDir(target.c_str());
@@ -996,6 +997,14 @@
 	SWKey *searchKey = 0;
 	SWKey textkey;
 	SWBuf c;
+	const int MAX_CONV_SIZE = 1024 * 1024;
+	SWBuf target = getConfigEntry("AbsoluteDataPath");
+	if (!target.endsWith("/") && !target.endsWith("\\")) {
+		target.append('/');
+	}
+	target.append("lucene");
+	int status = FileMgr::createParent(target+"/dummy");
+	if (status) return -1;
 
 
 	// turn all filters to default values
@@ -1030,25 +1039,22 @@
 		setKey(*searchKey);
 	}
 
-	RAMDirectory *ramDir = NULL;
-	IndexWriter *coreWriter = NULL;
-	IndexWriter *fsWriter = NULL;
-	Directory *d = NULL;
+	RAMDirectory *ramDir = 0;
+	IndexWriter *coreWriter = 0;
+	IndexWriter *fsWriter = 0;
+	Directory *d = 0;
 
-	standard::StandardAnalyzer *an = new standard::StandardAnalyzer();
-	SWBuf target = getConfigEntry("AbsoluteDataPath");
+	const TCHAR *stopWords[] = { 0 };
+	standard::StandardAnalyzer *an = new standard::StandardAnalyzer(stopWords);
 	bool includeKeyInSearch = getConfig().has("SearchOption", "IncludeKeyInSearch");
-	char ch = target.c_str()[strlen(target.c_str())-1];
-	if ((ch != '/') && (ch != '\\'))
-		target.append('/');
-	target.append("lucene");
-	FileMgr::createParent(target+"/dummy");
 
 	ramDir = new RAMDirectory();
 	coreWriter = new IndexWriter(ramDir, an, true);
+	coreWriter->setMaxFieldLength(MAX_CONV_SIZE);
 
 
 
+
 	char perc = 1;
 	VerseKey *vkcheck = 0;
 	vkcheck = SWDYNAMIC_CAST(VerseKey, key);
@@ -1075,7 +1081,6 @@
 	SWBuf proxLem;
 	SWBuf strong;
 
-	const short int MAX_CONV_SIZE = 2047;
 	wchar_t wcharBuffer[MAX_CONV_SIZE + 1];
 
 	char err = Error();
@@ -1306,7 +1311,7 @@
 		fsWriter = new IndexWriter( d, an, false);
 	} else {
 		d = FSDirectory::getDirectory(target.c_str(), true);
-		fsWriter = new IndexWriter( d ,an, true);
+		fsWriter = new IndexWriter(d, an, true);
 	}
 
 	Directory *dirs[] = { ramDir, 0 };

Modified: trunk/src/utilfuns/Makefile.am
===================================================================
--- trunk/src/utilfuns/Makefile.am	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/src/utilfuns/Makefile.am	2009-12-03 22:36:02 UTC (rev 2478)
@@ -20,7 +20,7 @@
 ftpsrc =
 endif
 
-if ZLIB
+if HAVE_LIBZ
 UNTGZ = $(utilfunsdir)/zlib/untgz.c
 else
 UNTGZ =

Modified: trunk/src/utilfuns/ftplib.c
===================================================================
--- trunk/src/utilfuns/ftplib.c	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/src/utilfuns/ftplib.c	2009-12-03 22:36:02 UTC (rev 2478)
@@ -325,7 +325,8 @@
                       w = net_write(nData->handle, nbp, FTPLIB_BUFSIZ);
                       if (w != FTPLIB_BUFSIZ)
                         {
-                            printf("net_write(1) returned %d, errno = %d\n", w, errno);
+                            if (ftplib_debug > 1)
+                                printf("net_write(1) returned %d, errno = %d\n", w, errno);
                             return(-1);
                         }
                       nb = 0;
@@ -339,7 +340,8 @@
                 w = net_write(nData->handle, nbp, FTPLIB_BUFSIZ);
                 if (w != FTPLIB_BUFSIZ)
                   {
-                      printf("net_write(2) returned %d, errno = %d\n", w, errno);
+                        if (ftplib_debug > 1)
+                            printf("net_write(2) returned %d, errno = %d\n", w, errno);
                       return(-1);
                   }
                 nb = 0;
@@ -353,7 +355,8 @@
           w = net_write(nData->handle, nbp, nb);
           if (w != nb)
             {
-                printf("net_write(3) returned %d, errno = %d\n", w, errno);
+                if (ftplib_debug > 1)
+                    printf("net_write(3) returned %d, errno = %d\n", w, errno);
                 return(-1);
             }
       }
@@ -409,7 +412,8 @@
     int err;
     wVersionRequested = MAKEWORD(1,1);
     if ((err = WSAStartup(wVersionRequested,&wsadata)) != 0)
-        fprintf(stderr,"Network failed to start: %d\n",err);
+        if (ftplib_debug > 1)
+            fprintf(stderr,"Network failed to start: %d\n",err);
 #endif
 }
 
@@ -538,7 +542,8 @@
           return 0;
       } 
 
-    printf("connected\n");
+    if (ftplib_debug > 1)
+        printf("connected\n");
 
       //set original flags
     fcntl( sControl, F_SETFL, oldflags);
@@ -833,7 +838,8 @@
     FD_SET(nData->handle, &mask);
     tv.tv_usec = 0;
     tv.tv_sec = ACCEPT_TIMEOUT;
-    printf("<<<<<<<<<<<<<<<<%d\n",ACCEPT_TIMEOUT);
+    if (ftplib_debug > 1)
+        printf("<<<<<<<<<<<<<<<<%d\n",ACCEPT_TIMEOUT);
     i = nControl->handle;
     if (i < nData->handle)
         i = nData->handle;
@@ -1223,7 +1229,8 @@
           while ((l = fread(dbuf, 1, FTPLIB_BUFSIZ, local)) > 0)
               if ((c = FtpWrite(dbuf, l, nData)) < l)
                 {
-                    printf("short write: passed %d, wrote %d\n", l, c);
+                    if (ftplib_debug > 1)
+                        printf("short write: passed %d, wrote %d\n", l, c);
                     rv = 0;
                     break;
                 }

Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/tests/Makefile.am	2009-12-03 22:36:02 UTC (rev 2478)
@@ -9,7 +9,7 @@
 romantest testblocks filtertest rawldidxtest lextest swaptest \
  swbuftest xmltest webiftest striptest
 
-if ICU
+if HAVE_ICU
 ICUPROG = icutest translittest tlitmgrtest
 else
 ICUPROG =
@@ -17,14 +17,13 @@
 
 noinst_PROGRAMS += $(ICUPROG)
 
-if ICU
+if HAVE_ICU
 icutest_SOURCES = icutest.cpp
 translittest_SOURCES = translittest.cpp
 tlitmgrtest_SOURCES = tlitmgrtest.cpp
-#tlitmgrtest_LDADD = -lustdio
 endif
 
-if ZLIB
+if HAVE_LIBZ
 ZLIBPROG = compzip
 else
 ZLIBPROG =
@@ -32,7 +31,7 @@
 
 noinst_PROGRAMS += $(ZLIBPROG)
 
-if ZLIB
+if HAVE_LIBZ
 compzip_SOURCES = compzip.cpp
 endif
 

Modified: trunk/usrinst.sh
===================================================================
--- trunk/usrinst.sh	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/usrinst.sh	2009-12-03 22:36:02 UTC (rev 2478)
@@ -40,7 +40,7 @@
 #LIBS="-no-undefined"
 #OPTIONS="lt_cv_deplibs_check_method=pass_all $OPTIONS"
 
-LIBS="$LIBS" CPPFLAGS="$CFLAGS $CPPFLAGS -DUSBINARY" ./configure $OPTIONS $*
+LIBS="$LIBS" ./configure $OPTIONS $*
 
 
 echo ""

Modified: trunk/utilities/Makefile.am
===================================================================
--- trunk/utilities/Makefile.am	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/utilities/Makefile.am	2009-12-03 22:36:02 UTC (rev 2478)
@@ -7,35 +7,17 @@
 addgb genbookutil treeidxutil
 
 bin_PROGRAMS = mod2imp mod2osis osis2mod tei2mod vs2osisref vs2osisreftxt mod2vpl \
-	mkfastmod vpl2mod imp2vs installmgr xml2gbs imp2gbs
+	mkfastmod vpl2mod imp2vs installmgr xml2gbs imp2gbs addld imp2ld
 
-#if INSTALLMGR
-#IMGRPROG =
-#else
-#IMGRPROG = 
-#endif
 
-
-#if ICU
-#ICUPROG = 
-#else
-#ICUPROG =
-#endif
-
-if ZLIB
-ZLIBPROG = mod2zmod addld imp2ld
+if HAVE_LIBZ
+ZLIBPROG = mod2zmod
 else
 ZLIBPROG =
 endif
 
-
-
-#noinst_PROGRAMS += $(ICUPROG)
 bin_PROGRAMS += $(ZLIBPROG) 
-#$(IMGRPROG)
 
-if ICU
-endif
 
 cipherraw_SOURCES = cipherraw.cpp
 lexdump_SOURCES = lexdump.c
@@ -61,14 +43,13 @@
 vs2osisreftxt_SOURCES = vs2osisreftxt.cpp
 genbookutil_SOURCES = genbookutil.cpp
 treeidxutil_SOURCES = treeidxutil.cpp
+addld_SOURCES = addld.cpp
+imp2ld_SOURCES = imp2ld.cpp
 
 installmgr_SOURCES = installmgr.cpp
-#installmgr_LDADD = -lcurl $(CURL_LIBS) $(LDADD)
 
-if ZLIB
+if HAVE_LIBZ
 mod2zmod_SOURCES = mod2zmod.cpp
-addld_SOURCES = addld.cpp
-imp2ld_SOURCES = imp2ld.cpp
 endif
 
 EXTRA_DIST = 

Modified: trunk/utilities/addld.cpp
===================================================================
--- trunk/utilities/addld.cpp	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/utilities/addld.cpp	2009-12-03 22:36:02 UTC (rev 2478)
@@ -92,6 +92,7 @@
       mod.setEntry(buffer, entrysize);	// save text to module at current position
     }
     else if (compress) {
+#ifndef EXCLUDEZLIB
       char buffer[1048576];  //this is the max size of any entry
       zLD mod(argv[2], 0, 0, 200, new ZipCompress());	// open our datapath with our RawText driver.
       SWKey* key = mod.CreateKey();
@@ -109,6 +110,10 @@
       
       entrysize = fread(buffer, sizeof(char), sizeof(buffer), infile);
       mod.setEntry(buffer, entrysize);	// save text to module at current position
+#else
+      fprintf(stderr, "error: %s: SWORD library not built with ZIP compression support.\n", argv[0]);
+      exit(-3);
+#endif
     }
     else {
       char buffer[65536];  //this is the max size of any entry

Modified: trunk/utilities/diatheke/Makefile.am
===================================================================
--- trunk/utilities/diatheke/Makefile.am	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/utilities/diatheke/Makefile.am	2009-12-03 22:36:02 UTC (rev 2478)
@@ -1,23 +1,12 @@
 AUTOMAKE_OPTIONS = 1.6
 
-INCLUDES = -I$(top_srcdir)/include
+LDADD = $(top_builddir)/lib/libsword.la
 
 bin_PROGRAMS = diatheke
 
 diatheke_SOURCES = diatheke.cpp corediatheke.cpp diathekemgr.cpp \
 	diafiltmgr.cpp thmlcgi.cpp gbfcgi.cpp osiscgi.cpp
 
-if ICU
-iculibs = -licui18n -licuuc
-endif
-
-if USELUCENE
-lucenelibs = -lclucene
-endif
-
-diatheke_LDADD = $(top_builddir)/lib/libsword.la \
-	$(iculibs) $(lucenelibs)
-
 noinst_HEADERS = corediatheke.h diafiltmgr.h diathekemgr.h gbfcgi.h thmlcgi.h \
 	osiscgi.h
 

Modified: trunk/utilities/imp2ld.cpp
===================================================================
--- trunk/utilities/imp2ld.cpp	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/utilities/imp2ld.cpp	2009-12-03 22:36:02 UTC (rev 2478)
@@ -84,8 +84,13 @@
 
 	switch (mode) {
 	case 3:
+#ifndef EXCLUDEZLIB
 		zLD::createModule(modname);
 		mod = new zLD(modname, 0, 0, blockCount, new ZipCompress());
+#else
+		fprintf(stderr, "ERROR: %s: SWORD library not compiled with ZIP compression support.\n\tBe sure libzip is available when compiling SWORD library", *argv);
+		exit(-2);
+#endif
 		break;
 	case 2:
 		RawLD::createModule(modname);

Modified: trunk/utilities/imp2vs.cpp
===================================================================
--- trunk/utilities/imp2vs.cpp	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/utilities/imp2vs.cpp	2009-12-03 22:36:02 UTC (rev 2478)
@@ -125,7 +125,11 @@
 	if (!v) std::cout << "Warning: Versification " << v11n << " not found. Using KJV versification...\n";
 
 	if (compType == "ZIP") {
+#ifndef EXCLUDEZLIB
 		compressor = new ZipCompress();
+#else
+		usage(*argv, "ERROR: SWORD library not compiled with ZIP compression support.\n\tBe sure libzip is available when compiling SWORD library");
+#endif
 	}
 	else if (compType == "LZSS") {
 		compressor = new LZSSCompress();

Modified: trunk/utilities/installmgr.cpp
===================================================================
--- trunk/utilities/installmgr.cpp	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/utilities/installmgr.cpp	2009-12-03 22:36:02 UTC (rev 2478)
@@ -17,6 +17,7 @@
 
 #include <swmgr.h>
 #include <installmgr.h>
+#include <ftptrans.h>
 #include <filemgr.h>
 #include <iostream>
 #include <map>
@@ -31,15 +32,17 @@
 using std::map;
 
 
-SWMgr *mgr;
-InstallMgr *installMgr;
+SWMgr *mgr = 0;
+InstallMgr *installMgr = 0;
+StatusReporter *statusReporter = 0;
 SWBuf baseDir;
 SWBuf confPath;
 
+void usage(const char *progName = 0, const char *error = 0);
 
 class MyInstallMgr : public InstallMgr {
 public:
-	MyInstallMgr(const char *privatePath = "./") : InstallMgr(privatePath) {}
+	MyInstallMgr(const char *privatePath = "./", StatusReporter *sr = 0) : InstallMgr(privatePath, sr) {}
 
 virtual bool isUserDisclaimerConfirmed() const {
 	static bool confirmed = false;
@@ -65,27 +68,69 @@
 		char prompt[10];
 		fgets(prompt, 9, stdin);
 		confirmed = (!strcmp(prompt, "yes\n"));
+		cout << "\n";
 	}
 	return confirmed;
 }
 
 };
 
+class MyStatusReporter : public StatusReporter {
+	int last;
+        virtual void statusUpdate(double dltotal, double dlnow) {
+		int p = 74 * (dlnow / dltotal);
+		for (;last < p; ++last) {
+			if (!last) {
+				SWBuf output;
+				output.setFormatted("[ File Bytes: %ld", (long)dltotal);
+				while (output.size() < 75) output += " ";
+				output += "]";
+				cout << output.c_str() << "\n ";
+			}
+			cout << "-";
+		}
+		cout.flush();
+	}
+        virtual void preStatus(long totalBytes, long completedBytes, const char *message) {
+		SWBuf output;
+		output.setFormatted("[ Total Bytes: %ld; Completed Bytes: %ld", totalBytes, completedBytes);
+		while (output.size() < 75) output += " ";
+		output += "]";
+		cout << "\n" << output.c_str() << "\n ";
+		int p = 74 * ((double)completedBytes/totalBytes);
+		for (int i = 0; i < p; ++i) { cout << "="; }
+		cout << "\n\n" << message << "\n";
+		last = 0;
+	}
+};      
 
+
 void init() {
-	mgr = new SWMgr();
-	SWBuf baseDir = mgr->getHomeDir();
-	if (baseDir.length() < 1) baseDir = ".";
-	baseDir += "/.sword/InstallMgr";
-	confPath = baseDir + "/InstallMgr.conf";
-	installMgr = new MyInstallMgr(baseDir);
+	if (!mgr) {
+		mgr = new SWMgr();
+
+		if (!mgr->config)
+			usage(0, "ERROR: SWORD configuration not found.  Please configure SWORD before using this program.");
+
+		SWBuf baseDir = mgr->getHomeDir();
+		if (baseDir.length() < 1) baseDir = ".";
+		baseDir += "/.sword/InstallMgr";
+		confPath = baseDir + "/InstallMgr.conf";
+		statusReporter = new MyStatusReporter();
+		installMgr = new MyInstallMgr(baseDir, statusReporter);
+	}
 }
 
 
 // clean up and exit if status is 0 or negative error code
 void finish(int status) {
+	delete statusReporter;
 	delete installMgr;
 	delete mgr;
+
+	installMgr = 0;
+	mgr        = 0;
+
 	if (status < 1) {
 		cout << "\n";
 		exit(status);
@@ -93,25 +138,6 @@
 }
 
 
-void usage(const char *progName) {
-	fprintf(stderr, "usage: %s <option>\nOptions:\n"
-		"\t-init\t\t\t\tcreate a basic user config file.\n"
-		"\t\t\t\t\t\tWARNING: overwrites existing.\n"
-		"\t-sc\t\t\t\tsync config with known remote repo list\n"
-		"\t-l\t\t\t\tlist installed modules\n"
-		"\t-u <modName>\t\t\tuninstall module\n"
-		"\t-s\t\t\t\tlist remote sources\n"
-		"\t-r  <remoteSrcName>\t\trefresh remote source\n"
-		"\t-rl <remoteSrcName>\t\tlist available modules from remote source\n"
-		"\t-rd <remoteSrcName>\t\tlist new/updated modules from remote source\n"
-		"\t-ri <remoteSrcName> <modName>\tinstall module from remote source\n"
-		"\t-ll <path>\t\t\tlist available modules at local path\n"
-		"\t-li <path> <modName>\t\tinstall module from local path\n"
-		, progName);
-	finish(-1);
-}
-
-
 void createBasicConfig(bool enableRemote, bool addCrossWire) {
 
 	FileMgr::createParent(confPath.c_str());
@@ -132,6 +158,7 @@
 
 
 void initConfig() {
+	init();
 
 	bool enable = installMgr->isUserDisclaimerConfirmed();
 
@@ -143,6 +170,7 @@
 
 
 void syncConfig() {
+	init();
 
 	if (!installMgr->isUserDisclaimerConfirmed()) {  // assert disclaimer is accepted
 		cout << "\n\nDisclaimer not accepted.  Aborting.";
@@ -162,24 +190,8 @@
 }
 
 
-void listModules(SWMgr *otherMgr) {
-	cout << "Installed Modules:\n\n";
-	SWModule *module;
-	std::map<SWModule *, int> mods = InstallMgr::getModuleStatus(*mgr, *otherMgr);
-	for (std::map<SWModule *, int>::iterator it = mods.begin(); it != mods.end(); it++) {
-		module = it->first;
-		SWBuf version = module->getConfigEntry("Version");
-		SWBuf status = " ";
-		if (it->second & InstallMgr::MODSTAT_NEW) status = "*";
-		if (it->second & InstallMgr::MODSTAT_OLDER) status = "-";
-		if (it->second & InstallMgr::MODSTAT_UPDATED) status = "+";
-
-		cout << status << "[" << module->Name() << "]  \t(" << version << ")  \t- " << module->Description() << "\n";
-	}
-}
-
-
 void uninstallModule(const char *modName) {
+	init();
 	SWModule *module;
 	ModMap::iterator it = mgr->Modules.find(modName);
 	if (it == mgr->Modules.end()) {
@@ -193,6 +205,7 @@
 
 
 void listRemoteSources() {
+	init();
 	cout << "Remote Sources:\n\n";
 	for (InstallSourceMap::iterator it = installMgr->sources.begin(); it != installMgr->sources.end(); it++) {
 		cout << "[" << it->second->caption << "]\n";
@@ -204,6 +217,7 @@
 
 
 void refreshRemoteSource(const char *sourceName) {
+	init();
 	InstallSourceMap::iterator source = installMgr->sources.find(sourceName);
 	if (source == installMgr->sources.end()) {
 		fprintf(stderr, "Couldn't find remote source [%s]\n", sourceName);
@@ -211,41 +225,40 @@
 	}
 
 	if (!installMgr->refreshRemoteSource(source->second))
-		cout << "Remote Source Refreshed\n";
-	else	cerr << "Error Refreshing Remote Source\n";
+		cout << "\nRemote Source Refreshed\n";
+	else	cerr << "\nError Refreshing Remote Source\n";
 }
 
 
-void remoteNewModules(const SWMgr *base, const char *sourceName) {
-	cout << "Updated and New Modules:\n(be sure to refresh remote source (-r) first for most current list)\n\n";
-	InstallSourceMap::iterator source = installMgr->sources.find(sourceName);
-	if (source == installMgr->sources.end()) {
-		fprintf(stderr, "Couldn't find remote source [%s]\n", sourceName);
-		finish(-3);
-	}
-	map<SWModule *, int> modStats = installMgr->getModuleStatus(*base, *source->second->getMgr());
+void listModules(SWMgr *otherMgr = 0, bool onlyNewAndUpdates = false) {
+	init();
 	SWModule *module;
-	int status;
-	bool updated;
-	for (map<SWModule *, int>::iterator it = modStats.begin(); it != modStats.end(); it++) {
+	if (!otherMgr) otherMgr = mgr;
+	std::map<SWModule *, int> mods = InstallMgr::getModuleStatus(*mgr, *otherMgr);
+	for (std::map<SWModule *, int>::iterator it = mods.begin(); it != mods.end(); it++) {
 		module = it->first;
-		status = it->second;
-		updated = (status & InstallMgr::MODSTAT_UPDATED);
-		if ((status & InstallMgr::MODSTAT_NEW) || (updated)) {
-			cout << ((updated)?"U":"N") << " [" << module->Name() << "]  \t- " << module->Description() << "\n";
+		SWBuf version = module->getConfigEntry("Version");
+		SWBuf status = " ";
+		if (it->second & InstallMgr::MODSTAT_NEW) status = "*";
+		if (it->second & InstallMgr::MODSTAT_OLDER) status = "-";
+		if (it->second & InstallMgr::MODSTAT_UPDATED) status = "+";
+
+		if (!onlyNewAndUpdates || status == "*" || status == "+") {
+			cout << status << "[" << module->Name() << "]  \t(" << version << ")  \t- " << module->Description() << "\n";
 		}
 	}
 }
 
 
-void remoteListModules(const char *sourceName) {
+void remoteListModules(const char *sourceName, bool onlyNewAndUpdated = false) {
+	init();
 	cout << "Available Modules:\n(be sure to refresh remote source (-r) first for most current list)\n\n";
 	InstallSourceMap::iterator source = installMgr->sources.find(sourceName);
 	if (source == installMgr->sources.end()) {
 		fprintf(stderr, "Couldn't find remote source [%s]\n", sourceName);
 		finish(-3);
 	}
-	listModules(source->second->getMgr());
+	listModules(source->second->getMgr(), onlyNewAndUpdated);
 }
 
 
@@ -257,6 +270,7 @@
 
 
 void remoteInstallModule(const char *sourceName, const char *modName) {
+	init();
 	InstallSourceMap::iterator source = installMgr->sources.find(sourceName);
 	if (source == installMgr->sources.end()) {
 		fprintf(stderr, "Couldn't find remote source [%s]\n", sourceName);
@@ -274,12 +288,13 @@
 
 	int error = installMgr->installModule(mgr, 0, module->Name(), is);
 	if (error) {
-		cout << "Error installing module: [" << module->Name() << "] (write permissions?)\n";
-	} else cout << "Installed module: [" << module->Name() << "]\n";
+		cout << "\nError installing module: [" << module->Name() << "] (write permissions?)\n";
+	} else cout << "\nInstalled module: [" << module->Name() << "]\n";
 }
 
 
 void localDirInstallModule(const char *dir, const char *modName) {
+	init();
 	SWMgr lmgr(dir);
 	SWModule *module;
 	ModMap::iterator it = lmgr.Modules.find(modName);
@@ -290,88 +305,94 @@
 	module = it->second;
 	int error = installMgr->installModule(mgr, dir, module->Name());
 	if (error) {
-		cout << "Error installing module: [" << module->Name() << "] (write permissions?)\n";
-	} else cout << "Installed module: [" << module->Name() << "]\n";
+		cout << "\nError installing module: [" << module->Name() << "] (write permissions?)\n";
+	} else cout << "\nInstalled module: [" << module->Name() << "]\n";
 }
 
 
-int main(int argc, char **argv) {
+void usage(const char *progName, const char *error) {
 
-	SWLog::getSystemLog()->setLogLevel(SWLog::LOG_DEBUG);
+	if (error) fprintf(stderr, "\n%s: %s\n", (progName ? progName : "installmgr"), error);
 
-	init();
+	fprintf(stderr, "\nusage: %s <command> [command ...]\n"
+		"\n  Commands (run in order they are passed):\n\n"
+		"\t-init\t\t\t\tcreate a basic user config file.\n"
+		"\t\t\t\t\t\tWARNING: overwrites existing.\n"
+		"\t-sc\t\t\t\tsync config with known remote repo list\n"
+		"\t\t\t\t\t\tNOTE: also creates if none exists\n"
+		"\t-d\t\t\t\tturn debug output on\n"
+		"\t-l\t\t\t\tlist installed modules\n"
+		"\t-u <modName>\t\t\tuninstall module\n"
+		"\t-s\t\t\t\tlist remote sources\n"
+		"\t-r  <remoteSrcName>\t\trefresh remote source\n"
+		"\t-rl <remoteSrcName>\t\tlist available modules from remote source\n"
+		"\t-rd <remoteSrcName>\t\tlist new/updated modules from remote source\n"
+		"\t-ri <remoteSrcName> <modName>\tinstall module from remote source\n"
+		"\t-ll <path>\t\t\tlist available modules at local path\n"
+		"\t-li <path> <modName>\t\tinstall module from local path\n"
+		, (progName ? progName : "installmgr"));
+	finish(-1);
+}
 
-	cout << "\n";
 
-	if (argc < 2 || !mgr->config)
-		usage(*argv);
+int main(int argc, char **argv) {
 
-	switch (argv[1][1]) {
-	case 'i':
-		if (strcmp(argv[1], "-init"))
-			usage(*argv);
-		initConfig();
-		break;
-	case 'l':
-		switch (argv[1][2]) {
-		case 0:			// -l list installed modules
-			listModules(mgr);
-			break;
-		case 'l':		// -ll list from local directory
-			if (argc < 3)
-				usage(*argv);
-			localDirListModules(argv[2]);
-			break;
-		case 'i':		// -li remote install
-			if (argc < 4)
-				usage(*argv);
-			localDirInstallModule(argv[2], argv[3]);
-			break;
-		default: usage(*argv);
+	if (argc < 2) usage(*argv);
+
+	for (int i = 1; i < argc; i++) {
+		if (!strcmp(argv[i], "-d")) {
+			SWLog::getSystemLog()->setLogLevel(SWLog::LOG_DEBUG);
 		}
-		break;
-	case 'u':
-		if (argc < 3)
-			usage(*argv);
-
-		uninstallModule(argv[2]);
-		break;
-	case 's':
-		switch (argv[1][2]) {
-		case 0:			// -s list sources
+		else if (!strcmp(argv[i], "-init")) {
+			initConfig();
+		}
+		else if (!strcmp(argv[i], "-l")) {	// list installed modules
+			cout << "Installed Modules:\n\n";
+			listModules();
+		}
+		else if (!strcmp(argv[i], "-ll")) {	// list from local directory
+			if (i+1 < argc) localDirListModules(argv[++i]);
+			else usage(*argv, "-ll requires <path>");
+		}
+		else if (!strcmp(argv[i], "-li")) {	// install from local directory
+			if (i+2 < argc) {
+				const char *path = argv[++i];
+				const char *modName = argv[++i];
+				localDirInstallModule(path, modName);
+			}
+			else usage(*argv, "-li requires <path> <modName>");
+		}
+		else if (!strcmp(argv[i], "-u")) {	// uninstall module
+			if (i+1 < argc) uninstallModule(argv[++i]);
+			else usage(*argv, "-u requires <modName>");
+		}
+		else if (!strcmp(argv[i], "-s")) {	// list sources
 			listRemoteSources();
-			break;
-		case 'c':		// -sc sync config with master
+		}
+		else if (!strcmp(argv[i], "-sc")) {	// sync config with master
 			syncConfig();
-			break;
 		}
-		break;
-	case 'r':	// remote option
-		switch (argv[1][2]) {
-		case 0:			// -r refresh
-			if (argc < 3)
-				usage(*argv);
-			refreshRemoteSource(argv[2]);
-			break;
-		case 'l':		// -rl remote list
-			if (argc < 3)
-				usage(*argv);
-			remoteListModules(argv[2]);
-			break;
-		case 'd':		// -rl remote list
-			if (argc < 3)
-				usage(*argv);
-			remoteNewModules(mgr, argv[2]);
-			break;
-		case 'i':		// -ri remote install
-			if (argc < 4)
-				usage(*argv);
-			remoteInstallModule(argv[2], argv[3]);
-			break;
-		default: usage(*argv);
+		else if (!strcmp(argv[i], "-r")) {	// refresh remote source
+			if (i+1 < argc) refreshRemoteSource(argv[++i]);
+			else usage(*argv, "-r requires <remoteSrcName>");
 		}
-		break;
-	default: usage(*argv);
+		else if (!strcmp(argv[i], "-rl")) {	// list remote modules
+			if (i+1 < argc) remoteListModules(argv[++i]);
+			else usage(*argv, "-rl requires <remoteSrcName>");
+		}
+		else if (!strcmp(argv[i], "-rd")) {	// list differences between remote source and installed modules
+			if (i+1 < argc) remoteListModules(argv[++i], true);
+			else usage(*argv, "-rd requires <remoteSrcName>");
+		}
+		else if (!strcmp(argv[i], "-ri")) {	// install from remote directory
+			if (i+2 < argc) {
+				const char *source = argv[++i];
+				const char *modName = argv[++i];
+				remoteInstallModule(source, modName);
+			}
+			else usage(*argv, "-ri requires <remoteSrcName> <modName>");
+		}
+		else usage(*argv, (((SWBuf)"Unknown argument: ")+ argv[i]).c_str());
 	}
 
 	finish(0);

Modified: trunk/utilities/osis2mod.cpp
===================================================================
--- trunk/utilities/osis2mod.cpp	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/utilities/osis2mod.cpp	2009-12-03 22:36:02 UTC (rev 2478)
@@ -1466,7 +1466,11 @@
 	}
 
 	if (compType == "ZIP") {
+#ifndef EXCLUDEZLIB
 		compressor = new ZipCompress();
+#else
+		usage(*argv, "ERROR: SWORD library not compiled with ZIP compression support.\n\tBe sure libzip is available when compiling SWORD library");
+#endif
 	}
 	else if (compType == "LZSS") {
 		compressor = new LZSSCompress();

Modified: trunk/utilities/tei2mod.cpp
===================================================================
--- trunk/utilities/tei2mod.cpp	2009-11-20 05:25:56 UTC (rev 2477)
+++ trunk/utilities/tei2mod.cpp	2009-12-03 22:36:02 UTC (rev 2478)
@@ -419,7 +419,11 @@
 #endif
 
 	if (compType == "ZIP") {
+#ifndef EXCLUDEZLIB
 		compressor = new ZipCompress();
+#else
+		usage(*argv, "ERROR: SWORD library not compiled with ZIP compression support.\n\tBe sure libzip is available when compiling SWORD library");
+#endif
 	}
 	else if (compType = "LZSS") {
 		compressor = new LZSSCompress();




More information about the sword-cvs mailing list