[Box Backup-commit] COMMIT r2127 - in box/trunk: . bin/bbackupd bin/bbackupquery bin/bbstoreaccounts bin/bbstored documentation lib/backupclient lib/backupstore lib/common lib/compress lib/crypto lib/intercept lib/raidfile lib/server test/backupdiff test/basicserver test/bbackupd test/bbackupd/testfiles test/common test/compress test/raidfile

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Fri Apr 4 23:11:47 BST 2008


Author: chris
Date: 2008-04-04 22:11:45 +0000 (Fri, 04 Apr 2008)
New Revision: 2127

Modified:
   box/trunk/bin/bbackupd/BackupClientContext.cpp
   box/trunk/bin/bbackupd/BackupClientContext.h
   box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp
   box/trunk/bin/bbackupd/BackupDaemon.cpp
   box/trunk/bin/bbackupd/Win32ServiceFunctions.cpp
   box/trunk/bin/bbackupd/bbackupd-config.in
   box/trunk/bin/bbackupquery/BackupQueries.cpp
   box/trunk/bin/bbackupquery/bbackupquery.cpp
   box/trunk/bin/bbstoreaccounts/bbstoreaccounts.cpp
   box/trunk/bin/bbstored/BBStoreDHousekeeping.cpp
   box/trunk/bin/bbstored/BackupContext.cpp
   box/trunk/bin/bbstored/bbstored-config.in
   box/trunk/configure.ac
   box/trunk/documentation/bbackupctl.xml
   box/trunk/documentation/bbackupquery.xml
   box/trunk/documentation/bbstoreaccounts.xml
   box/trunk/documentation/bbstored-certs.xml
   box/trunk/documentation/bbstored-config.xml
   box/trunk/documentation/raidfile-config.xml
   box/trunk/lib/backupclient/BackupClientRestore.cpp
   box/trunk/lib/backupclient/BackupDaemonConfigVerify.cpp
   box/trunk/lib/backupclient/BackupStoreFileDiff.cpp
   box/trunk/lib/backupclient/BackupStoreFilenameClear.cpp
   box/trunk/lib/backupclient/BackupStoreObjectDump.cpp
   box/trunk/lib/backupstore/BackupStoreCheck.cpp
   box/trunk/lib/backupstore/BackupStoreCheck2.cpp
   box/trunk/lib/backupstore/BackupStoreCheckData.cpp
   box/trunk/lib/backupstore/BackupStoreConfigVerify.cpp
   box/trunk/lib/common/Box.h
   box/trunk/lib/common/BoxTime.cpp
   box/trunk/lib/common/Configuration.cpp
   box/trunk/lib/common/Configuration.h
   box/trunk/lib/common/DebugMemLeakFinder.cpp
   box/trunk/lib/common/EventWatchFilesystemObject.cpp
   box/trunk/lib/common/FileStream.cpp
   box/trunk/lib/common/FileStream.h
   box/trunk/lib/common/Guards.h
   box/trunk/lib/common/Logging.h
   box/trunk/lib/common/PartialReadStream.cpp
   box/trunk/lib/common/Utils.cpp
   box/trunk/lib/common/Utils.h
   box/trunk/lib/compress/Compress.h
   box/trunk/lib/compress/CompressStream.cpp
   box/trunk/lib/crypto/CipherContext.cpp
   box/trunk/lib/intercept/intercept.cpp
   box/trunk/lib/raidfile/RaidFileController.cpp
   box/trunk/lib/raidfile/RaidFileWrite.cpp
   box/trunk/lib/server/Daemon.cpp
   box/trunk/lib/server/Daemon.h
   box/trunk/lib/server/ProtocolUncertainStream.cpp
   box/trunk/lib/server/ServerControl.h
   box/trunk/lib/server/ServerStream.h
   box/trunk/lib/server/ServerTLS.h
   box/trunk/lib/server/SocketListen.h
   box/trunk/lib/server/SocketStream.cpp
   box/trunk/test/backupdiff/testbackupdiff.cpp
   box/trunk/test/basicserver/testbasicserver.cpp
   box/trunk/test/bbackupd/testbbackupd.cpp
   box/trunk/test/bbackupd/testfiles/bbackupd-temploc.conf
   box/trunk/test/bbackupd/testfiles/bbackupd.conf.in
   box/trunk/test/bbackupd/testfiles/bbstored.conf
   box/trunk/test/common/testcommon.cpp
   box/trunk/test/compress/testcompress.cpp
   box/trunk/test/raidfile/testraidfile.cpp
Log:
Undo mangling by tailor


Modified: box/trunk/bin/bbackupd/BackupClientContext.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupClientContext.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/bin/bbackupd/BackupClientContext.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -44,6 +44,7 @@
 	BackupDaemon &rDaemon, 
 	TLSContext &rTLSContext, 
 	const std::string &rHostname,
+	int Port,
 	int32_t AccountNumber, 
 	bool ExtendedLogging,
 	bool ExtendedLogToFile,
@@ -52,6 +53,7 @@
 	: mrDaemon(rDaemon),
 	  mrTLSContext(rTLSContext),
 	  mHostname(rHostname),
+	  mPort(Port),
 	  mAccountNumber(AccountNumber),
 	  mpSocket(0),
 	  mpConnection(0),
@@ -129,7 +131,8 @@
 			mHostname << "'...");
 
 		// Connect!
-		mpSocket->Open(mrTLSContext, Socket::TypeINET, mHostname.c_str(), BOX_PORT_BBSTORED);
+		mpSocket->Open(mrTLSContext, Socket::TypeINET,
+			mHostname.c_str(), mPort);
 		
 		// And create a procotol object
 		mpConnection = new BackupProtocolClient(*mpSocket);
@@ -146,8 +149,8 @@
 
 			if (!mpExtendedLogFileHandle)
 			{
-				BOX_ERROR("Failed to open extended log "
-					"file: " << strerror(errno));
+				BOX_LOG_SYS_ERROR("Failed to open extended "
+					"log file: " << mExtendedLogFile);
 			}
 			else
 			{

Modified: box/trunk/bin/bbackupd/BackupClientContext.h
===================================================================
--- box/trunk/bin/bbackupd/BackupClientContext.h	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/bin/bbackupd/BackupClientContext.h	2008-04-04 22:11:45 UTC (rev 2127)
@@ -41,6 +41,7 @@
 		BackupDaemon &rDaemon, 
 		TLSContext &rTLSContext, 
 		const std::string &rHostname,
+		int32_t Port,
 		int32_t AccountNumber, 
 		bool ExtendedLogging,
 		bool ExtendedLogToFile,
@@ -201,6 +202,7 @@
 	BackupDaemon &mrDaemon;
 	TLSContext &mrTLSContext;
 	std::string mHostname;
+	int mPort;
 	int32_t mAccountNumber;
 	SocketStreamTLS *mpSocket;
 	BackupProtocolClient *mpConnection;

Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -1014,7 +1014,8 @@
 	// Delete the pending entries, if the map is entry
 	if(mpPendingEntries != 0 && mpPendingEntries->size() == 0)
 	{
-		TRACE1("Deleting mpPendingEntries from dir ID %lld\n", mObjectID);
+		BOX_TRACE("Deleting mpPendingEntries from dir ID " <<
+			BOX_FORMAT_OBJECTID(mObjectID));
 		delete mpPendingEntries;
 		mpPendingEntries = 0;
 	}
@@ -1249,8 +1250,8 @@
 						rLocalPath, 
 						dirname.GetClearFilename());
 
-					TRACE1("Deleted directory record for "
-						"%s\n", name.c_str());
+					BOX_TRACE("Deleted directory record "
+						"for " << name);
 				}				
 			}
 		}

Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupDaemon.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/bin/bbackupd/BackupDaemon.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -958,6 +958,7 @@
 					*this, 
 					tlsContext, 
 					conf.GetKeyValue("StoreHostname"),
+					conf.GetKeyValueInt("StorePort"),
 					conf.GetKeyValueInt("AccountNumber"), 
 					conf.GetKeyValueBool("ExtendedLogging"),
 					conf.KeyExists("ExtendedLogFile"),
@@ -1812,10 +1813,9 @@
 				if(::statfs(apLoc->mPath.c_str(), &s) != 0)
 #endif // HAVE_STRUCT_STATVFS_F_MNTONNAME
 				{
-					BOX_WARNING("Failed to stat location "
+					BOX_LOG_SYS_WARNING("Failed to stat location "
 						"path '" << apLoc->mPath <<
-						"' (" << strerror(errno) <<
-						"), skipping location '" <<
+						"', skipping location '" <<
 						apLoc->mName << "'");
 					continue;
 				}
@@ -2189,9 +2189,8 @@
 #endif
 		if(::rename(newmap.c_str(), target.c_str()) != 0)
 		{
-			BOX_ERROR("failed to rename ID map: " << newmap
-				<< " to " << target << ": " 
-				<< strerror(errno));
+			BOX_LOG_SYS_ERROR("Failed to rename ID map: " <<
+				newmap << " to " << target);
 			THROW_EXCEPTION(CommonException, OSFileError)
 		}
 	}
@@ -3055,9 +3054,10 @@
 	// Check to see if the file exists
 	if(!FileExists(storeObjectInfoFile.c_str()))
 	{
-		// File doesn't exist -- so can't be deleted. But something isn't quite right, so log a message
-		BOX_WARNING("Store object info file did not exist when it "
-			"was supposed to. (" << storeObjectInfoFile << ")");
+		// File doesn't exist -- so can't be deleted. But something
+		// isn't quite right, so log a message
+		BOX_WARNING("StoreObjectInfoFile did not exist when it "
+			"was supposed to: " << storeObjectInfoFile);
 
 		// Return true to stop things going around in a loop
 		return true;
@@ -3066,8 +3066,8 @@
 	// Actually delete it
 	if(::unlink(storeObjectInfoFile.c_str()) != 0)
 	{
-		BOX_ERROR("Failed to delete the old store object info file: "
-			<< storeObjectInfoFile << ": "<< strerror(errno));
+		BOX_LOG_SYS_ERROR("Failed to delete the old "
+			"StoreObjectInfoFile: " << storeObjectInfoFile);
 		return false;
 	}
 

Modified: box/trunk/bin/bbackupd/Win32ServiceFunctions.cpp
===================================================================
--- box/trunk/bin/bbackupd/Win32ServiceFunctions.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/bin/bbackupd/Win32ServiceFunctions.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -207,8 +207,8 @@
 
 		if (emu_stat(pConfigFileName, &st) != 0)
 		{
-			BOX_ERROR("Failed to open configuration file '" <<
-				pConfigFileName << "': " << strerror(errno));
+			BOX_LOG_SYS_ERROR("Failed to open configuration file "
+				"'" << pConfigFileName << "'");
 			return 1;
 		}
 
@@ -221,7 +221,7 @@
 		}
 	}
 
-	SC_HANDLE scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE);
+	SC_HANDLE scm = OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE);
 
 	if (!scm) 
 	{

Modified: box/trunk/bin/bbackupd/bbackupd-config.in
===================================================================
--- box/trunk/bin/bbackupd/bbackupd-config.in	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/bin/bbackupd/bbackupd-config.in	2008-04-04 22:11:45 UTC (rev 2127)
@@ -26,7 +26,7 @@
                         explicitly, using bbackupctl sync
     account-num (hexdecimal) and server-hostname
                         are supplied by the server administrator
-    working-dir         is usually @localstatedir_expanded@
+    working-dir         is usually @localstatedir_expanded@/bbackupd
     backup directories  is list of directories to back up
 
 __E

Modified: box/trunk/bin/bbackupquery/BackupQueries.cpp
===================================================================
--- box/trunk/bin/bbackupquery/BackupQueries.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/bin/bbackupquery/BackupQueries.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -27,6 +27,8 @@
 
 #include <set>
 #include <limits>
+#include <iostream>
+#include <ostream>
 
 #include "BackupQueries.h"
 #include "Utils.h"
@@ -810,8 +812,8 @@
 		}
 		else
 		{
-			BOX_ERROR("Error changing to directory '" <<
-				args[0] << ": " << strerror(errno));
+			BOX_LOG_SYS_ERROR("Failed to change to directory "
+				"'" << args[0] << "'");
 		}
 
 		SetReturnCode(COMMAND_RETURN_ERROR);
@@ -822,8 +824,7 @@
 	char wd[PATH_MAX];
 	if(::getcwd(wd, PATH_MAX) == 0)
 	{
-		BOX_ERROR("Error getting current directory: " <<
-			strerror(errno));
+		BOX_LOG_SYS_ERROR("Error getting current directory");
 		SetReturnCode(COMMAND_RETURN_ERROR);
 		return;
 	}
@@ -1399,9 +1400,8 @@
 		}
 		else
 		{
-			BOX_WARNING("Failed to access local directory '" <<
-				localDirDisplay << ": " << strerror(errno) <<
-				"'.");
+			BOX_LOG_SYS_WARNING("Failed to access local directory "
+				"'" << localDirDisplay << "'");
 			rParams.mUncheckedFiles ++;
 		}
 		return;
@@ -1449,8 +1449,8 @@
 	DIR *dirhandle = ::opendir(rLocalDir.c_str());
 	if(dirhandle == 0)
 	{
-		BOX_WARNING("Failed to open local directory '" << 
-			localDirDisplay << "': " << strerror(errno));
+		BOX_LOG_SYS_WARNING("Failed to open local directory '" << 
+			localDirDisplay << "'");
 		rParams.mUncheckedFiles ++;
 		return;
 	}
@@ -1518,8 +1518,8 @@
 		// Close directory
 		if(::closedir(dirhandle) != 0)
 		{
-			BOX_ERROR("Failed to close local directory '" <<
-				localDirDisplay << "': " << strerror(errno));
+			BOX_LOG_SYS_ERROR("Failed to close local directory "
+				"'" << localDirDisplay << "'");
 		}
 		dirhandle = 0;
 	
@@ -2158,22 +2158,9 @@
 // --------------------------------------------------------------------------
 void BackupQueries::CommandUsageDisplayEntry(const char *Name, int64_t Size, int64_t HardLimit, int32_t BlockSize)
 {
-	// Calculate size in Mb
-	double mb = (((double)Size) * ((double)BlockSize)) / ((double)(1024*1024));
-	int64_t percent = (Size * 100) / HardLimit;
-
-	// Bar graph
-	char bar[41];
-	unsigned int b = (int)((Size * (sizeof(bar)-1)) / HardLimit);
-	if(b > sizeof(bar)-1) {b = sizeof(bar)-1;}
-	for(unsigned int l = 0; l < b; l++)
-	{
-		bar[l] = '*';
-	}
-	bar[b] = '\0';
-
-	// Print the entryj
-	::printf("%14s %10.1fMb %3d%% %s\n", Name, mb, (int32_t)percent, bar);
+	std::cout << FormatUsageLineStart(Name) <<
+		FormatUsageBar(Size, Size * BlockSize, HardLimit * BlockSize) <<
+		std::endl;
 }
 
 

Modified: box/trunk/bin/bbackupquery/bbackupquery.cpp
===================================================================
--- box/trunk/bin/bbackupquery/bbackupquery.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/bin/bbackupquery/bbackupquery.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -174,8 +174,8 @@
 			logFile = ::fopen(optarg, "w");
 			if(logFile == 0)
 			{
-				BOX_ERROR("Failed to open log file '" <<
-					optarg << "': " << strerror(errno));
+				BOX_LOG_SYS_ERROR("Failed to open log file "
+					"'" << optarg << "'");
 			}
 			break;
 
@@ -260,7 +260,9 @@
 	// 2. Connect to server
 	if(!quiet) BOX_INFO("Connecting to store...");
 	SocketStreamTLS socket;
-	socket.Open(tlsContext, Socket::TypeINET, conf.GetKeyValue("StoreHostname").c_str(), BOX_PORT_BBSTORED);
+	socket.Open(tlsContext, Socket::TypeINET,
+		conf.GetKeyValue("StoreHostname").c_str(),
+		conf.GetKeyValueInt("StorePort"));
 	
 	// 3. Make a protocol, and handshake
 	if(!quiet) BOX_INFO("Handshake with store...");

Modified: box/trunk/bin/bbstoreaccounts/bbstoreaccounts.cpp
===================================================================
--- box/trunk/bin/bbstoreaccounts/bbstoreaccounts.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/bin/bbstoreaccounts/bbstoreaccounts.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -13,8 +13,11 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <limits.h>
+
+#include <algorithm>
+#include <iostream>
+#include <ostream>
 #include <vector>
-#include <algorithm>
 
 #include "BoxPortsAndFiles.h"
 #include "BackupStoreConfigVerify.h"
@@ -62,16 +65,10 @@
 	return controller.GetDiscSet(DiscSet).GetBlockSize();
 }
 
-std::string BlockSizeToString(int64_t Blocks, int DiscSet)
+std::string BlockSizeToString(int64_t Blocks, int64_t MaxBlocks, int DiscSet)
 {
-	// Work out size in Mb.
-	double mb = (Blocks * BlockSizeOfDiscSet(DiscSet)) / (1024.0*1024.0);
-	
-	// Format string
-	std::ostringstream buf;
-	buf << Blocks << " blocks " << std::fixed << std::setprecision(2) <<
-		std::showpoint << "(" << mb << " MB)";
-	return buf.str();
+	return FormatUsageBar(Blocks, Blocks * BlockSizeOfDiscSet(DiscSet),
+		MaxBlocks * BlockSizeOfDiscSet(DiscSet));
 }
 
 int64_t SizeStringToBlocks(const char *string, int DiscSet)
@@ -223,15 +220,30 @@
 	std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(ID, rootDir, discSet, true /* ReadOnly */));
 	
 	// Then print out lots of info
-	printf("                  Account ID: %08x\n", ID);
-	printf("              Last object ID: %lld\n", info->GetLastObjectIDUsed());
-	printf("                 Blocks used: %s\n", BlockSizeToString(info->GetBlocksUsed(), discSet).c_str());
-	printf("    Blocks used by old files: %s\n", BlockSizeToString(info->GetBlocksInOldFiles(), discSet).c_str());
-	printf("Blocks used by deleted files: %s\n", BlockSizeToString(info->GetBlocksInDeletedFiles(), discSet).c_str());
-	printf("  Blocks used by directories: %s\n", BlockSizeToString(info->GetBlocksInDirectories(), discSet).c_str());
-	printf("            Block soft limit: %s\n", BlockSizeToString(info->GetBlocksSoftLimit(), discSet).c_str());
-	printf("            Block hard limit: %s\n", BlockSizeToString(info->GetBlocksHardLimit(), discSet).c_str());
-	printf("         Client store marker: %lld\n", info->GetClientStoreMarker());
+	std::cout << FormatUsageLineStart("Account ID") <<
+		BOX_FORMAT_ACCOUNT(ID) << std::endl;
+	std::cout << FormatUsageLineStart("Last object ID") <<
+		BOX_FORMAT_OBJECTID(info->GetLastObjectIDUsed()) << std::endl;
+	std::cout << FormatUsageLineStart("Used") <<
+		BlockSizeToString(info->GetBlocksUsed(),
+			info->GetBlocksHardLimit(), discSet) << std::endl;
+	std::cout << FormatUsageLineStart("Old files") <<
+		BlockSizeToString(info->GetBlocksInOldFiles(),
+			info->GetBlocksHardLimit(), discSet) << std::endl;
+	std::cout << FormatUsageLineStart("Deleted files") <<
+		BlockSizeToString(info->GetBlocksInDeletedFiles(),
+			info->GetBlocksHardLimit(), discSet) << std::endl;
+	std::cout << FormatUsageLineStart("Directories") <<
+		BlockSizeToString(info->GetBlocksInDirectories(),
+			info->GetBlocksHardLimit(), discSet) << std::endl;
+	std::cout << FormatUsageLineStart("Soft limit") <<
+		BlockSizeToString(info->GetBlocksSoftLimit(),
+			info->GetBlocksHardLimit(), discSet) << std::endl;
+	std::cout << FormatUsageLineStart("Hard limit") <<
+		BlockSizeToString(info->GetBlocksHardLimit(),
+			info->GetBlocksHardLimit(), discSet) << std::endl;
+	std::cout << FormatUsageLineStart("Client store marker") <<
+		info->GetLastObjectIDUsed() << std::endl;
 	
 	return 0;
 }

Modified: box/trunk/bin/bbstored/BBStoreDHousekeeping.cpp
===================================================================
--- box/trunk/bin/bbstored/BBStoreDHousekeeping.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/bin/bbstored/BBStoreDHousekeeping.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -193,7 +193,8 @@
 	std::string line;
 	if(mInterProcessComms.GetLine(line, false /* no pre-processing */, MaximumWaitTime))
 	{
-		TRACE1("Housekeeping received command '%s' over interprocess comms\n", line.c_str());
+		BOX_TRACE("Housekeeping received command '" << line <<
+			"' over interprocess comms");
 	
 		int account = 0;
 	

Modified: box/trunk/bin/bbstored/BackupContext.cpp
===================================================================
--- box/trunk/bin/bbstored/BackupContext.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/bin/bbstored/BackupContext.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -382,7 +382,8 @@
 		// Mark that the store info should be saved as soon as possible
 		mSaveStoreInfoDelay = 0;
 		
-		TRACE1("When allocating object ID, found that %lld is already in use\n", id);
+		BOX_WARNING("When allocating object ID, found that " <<
+			BOX_FORMAT_OBJECTID(id) << " is already in use");
 	}
 	
 	THROW_EXCEPTION(BackupStoreException, CouldNotFindUnusedIDDuringAllocation)

Modified: box/trunk/bin/bbstored/bbstored-config.in
===================================================================
--- box/trunk/bin/bbstored/bbstored-config.in	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/bin/bbstored/bbstored-config.in	2008-04-04 22:11:45 UTC (rev 2127)
@@ -196,7 +196,7 @@
 
 Server
 {
-	PidFile = @localstatedir_expanded@/bbstored.pid
+	PidFile = @localstatedir_expanded@/run/bbstored.pid
 	User = $username
 	ListenAddresses = inet:$server
 	CertificateFile = $certificate

Modified: box/trunk/configure.ac
===================================================================
--- box/trunk/configure.ac	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/configure.ac	2008-04-04 22:11:45 UTC (rev 2127)
@@ -6,10 +6,6 @@
 AC_CONFIG_SRCDIR([lib/common/Box.h])
 AC_CONFIG_HEADERS([lib/common/BoxConfig.h])
 
-# override default sysconfdir, for backwards compatibility
-test "$sysconfdir" = NONE && sysconfdir=/etc
-test "$localstatedir" = NONE && localstatedir=/var/run
-
 touch install-sh
 AC_CANONICAL_SYSTEM
 test -s install-sh || rm install-sh
@@ -62,7 +58,6 @@
 	;;
 esac
 
-AC_CHECK_HEADER([zlib.h],, [AC_MSG_ERROR([[cannot find zlib.h]])])
 AC_CHECK_LIB([z], [zlibVersion],, [AC_MSG_ERROR([[cannot find zlib]])])
 VL_LIB_READLINE([have_libreadline=yes], [have_libreadline=no])
 
@@ -274,6 +269,10 @@
   LIBS="-Wl,-Bstatic $LIBS -Wl,-Bdynamic"
 fi
 
+# override default sysconfdir, for backwards compatibility
+test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
+test "$localstatedir" = '${prefix}/var' && localstatedir=/var
+
 ## Kludge to allow makeparcels.pl to use bindir. This is not a good long term
 ## solution because it prevents use of "make exec_prefix=/some/dir"
 saved_prefix=$prefix

Modified: box/trunk/documentation/bbackupctl.xml
===================================================================
--- box/trunk/documentation/bbackupctl.xml	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/documentation/bbackupctl.xml	2008-04-04 22:11:45 UTC (rev 2127)
@@ -3,7 +3,7 @@
   <refmeta>
     <refentrytitle>bbackupctl</refentrytitle>
 
-    <manvolnum>1</manvolnum>
+    <manvolnum>8</manvolnum>
   </refmeta>
 
   <refnamediv>
@@ -23,7 +23,7 @@
 
     <para><literal>bbackupctl</literal> lets the user control the bbackupd
     daemon on a client machine. The main use is to force a sync with the store
-    server. This is especially important if bbackupd(1) is configured to do
+    server. This is especially important if bbackupd(8) is configured to do
     snapshot backups. In that case <literal>bbackupctl</literal> is the only
     way to effect a backup.</para>
 
@@ -31,7 +31,7 @@
     socket. Some platforms (notably Windows) can't determine if the user
     connecting on this socket has the correct credentials to execute the
     commands, leaving a rather sizeable security hole open. To avoid this,
-    unset the CommandSocket parameter in <literal>bbackupd.conf</literal>(8).
+    unset the CommandSocket parameter in <literal>bbackupd.conf</literal>(5).
     That disables the command socket, so bbackupd is secure. This does,
     however, render bbackupctl unusable.</para>
 
@@ -93,9 +93,9 @@
   <refsection>
     <title>See Also</title>
 
-    <para><literal>bbackupd.conf(8)</literal></para>
+    <para><literal>bbackupd.conf(5)</literal></para>
 
-    <para>bbackupd(1)</para>
+    <para><literal>bbackupd(8)</literal></para>
   </refsection>
 
   <refsection>

Modified: box/trunk/documentation/bbackupquery.xml
===================================================================
--- box/trunk/documentation/bbackupquery.xml	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/documentation/bbackupquery.xml	2008-04-04 22:11:45 UTC (rev 2127)
@@ -3,7 +3,7 @@
   <refmeta>
     <refentrytitle>bbackupquery</refentrytitle>
 
-    <manvolnum>1</manvolnum>
+    <manvolnum>8</manvolnum>
   </refmeta>
 
   <refnamediv>
@@ -39,7 +39,7 @@
     <programlisting>bbackupquery "list home-dirs" quit</programlisting>
 
     <para>Note that commands that contain spaces are enclosed in double
-    quotes. If the <literal>quit</literal> command is ommitted, after the
+    quotes. If the <literal>quit</literal> command is omitted, after the
     preceding commands are completed, <literal>bbackupquery</literal> will
     enter interactive mode.</para>
 
@@ -328,7 +328,7 @@
   <refsection>
     <title>See Also</title>
 
-    <para>bbackupd.conf(8)</para>
+    <para>bbackupd.conf(5)</para>
   </refsection>
 
   <refsection>
@@ -357,7 +357,7 @@
       </listitem>
 
       <listitem>
-        <para>The platform you are running on (Hardware and OS), for both
+        <para>The platform you are running on (hardware and OS), for both
         client and server.</para>
       </listitem>
 

Modified: box/trunk/documentation/bbstoreaccounts.xml
===================================================================
--- box/trunk/documentation/bbstoreaccounts.xml	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/documentation/bbstoreaccounts.xml	2008-04-04 22:11:45 UTC (rev 2127)
@@ -3,7 +3,7 @@
   <refmeta>
     <refentrytitle>bbstoreaccounts</refentrytitle>
 
-    <manvolnum>1</manvolnum>
+    <manvolnum>8</manvolnum>
   </refmeta>
 
   <refnamediv>
@@ -28,7 +28,7 @@
     accounts, as well as create, change and delete accounts on the store
     server. </para>
 
-    <para><literal>bbstoreaccounts</literal> alwas takes at least 2
+    <para><literal>bbstoreaccounts</literal> always takes at least 2
     parameters: the command name and the account ID. Some commands require
     additional parameters, and some commands have optional parameters.</para>
 
@@ -160,7 +160,7 @@
 
             <listitem>
               <para>Blocks used by deleted files: The number of blocks used by
-              files that have been deleted on the client. Thi s data is at
+              files that have been deleted on the client. This data is at
               risk for being removed during housekeeping.</para>
             </listitem>
 
@@ -267,7 +267,7 @@
       </listitem>
 
       <listitem>
-        <para>The platform you are running on (Hardware and OS), for both
+        <para>The platform you are running on (hardware and OS), for both
         client and server.</para>
       </listitem>
 

Modified: box/trunk/documentation/bbstored-certs.xml
===================================================================
--- box/trunk/documentation/bbstored-certs.xml	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/documentation/bbstored-certs.xml	2008-04-04 22:11:45 UTC (rev 2127)
@@ -3,7 +3,7 @@
   <refmeta>
     <refentrytitle>bbstored-certs</refentrytitle>
 
-    <manvolnum>1</manvolnum>
+    <manvolnum>8</manvolnum>
   </refmeta>
 
   <refnamediv>
@@ -51,7 +51,7 @@
         <listitem>
           <para><literal>sign <clientcsrfile></literal>: Sign a client
           certificate. The <literal>clientcsrfile</literal> is generated
-          during client setup. See <literal>bbackupd-config(1)</literal>. Send
+          during client setup. See <literal>bbackupd-config(8)</literal>. Send
           the signed certificate back to the client, and install according to
           the instructions given by <literal>bbackupd-config</literal>.</para>
         </listitem>
@@ -72,11 +72,11 @@
   <refsection>
     <title>See Also</title>
 
-    <para><literal>bbstored-config(1)</literal></para>
+    <para><literal>bbstored-config(8)</literal></para>
 
     <para><literal>bbstored.conf(5)</literal></para>
 
-    <para><literal>bbstoreaccounts(1)</literal></para>
+    <para><literal>bbstoreaccounts(8)</literal></para>
   </refsection>
 
   <refsection>
@@ -102,7 +102,7 @@
       </listitem>
 
       <listitem>
-        <para>The platform you are running on (Hardware and OS), for both
+        <para>The platform you are running on (hardware and OS), for both
         client and server.</para>
       </listitem>
 

Modified: box/trunk/documentation/bbstored-config.xml
===================================================================
--- box/trunk/documentation/bbstored-config.xml	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/documentation/bbstored-config.xml	2008-04-04 22:11:45 UTC (rev 2127)
@@ -3,7 +3,7 @@
   <refmeta>
     <refentrytitle>bbstored-config</refentrytitle>
 
-    <manvolnum>1</manvolnum>
+    <manvolnum>8</manvolnum>
   </refmeta>
 
   <refnamediv>
@@ -86,7 +86,7 @@
   <refsection>
     <title>See Also</title>
 
-    <para><literal>raidfile-config(1)</literal></para>
+    <para><literal>raidfile-config(8)</literal></para>
 
     <para><literal>bbstored.conf(5)</literal></para>
 
@@ -117,7 +117,7 @@
       </listitem>
 
       <listitem>
-        <para>The platform you are running on (Hardware and OS), for both
+        <para>The platform you are running on (hardware and OS), for both
         client and server.</para>
       </listitem>
 

Modified: box/trunk/documentation/raidfile-config.xml
===================================================================
--- box/trunk/documentation/raidfile-config.xml	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/documentation/raidfile-config.xml	2008-04-04 22:11:45 UTC (rev 2127)
@@ -3,7 +3,7 @@
   <refmeta>
     <refentrytitle>raidfile-config</refentrytitle>
 
-    <manvolnum>1</manvolnum>
+    <manvolnum>8</manvolnum>
   </refmeta>
 
   <refnamediv>
@@ -45,7 +45,7 @@
 
         <listitem>
           <para><literal>blocksize</literal>: The block size used for file
-          storage in the system, in bytes. Using a multple of the file system
+          storage in the system, in bytes. Using a multiple of the file system
           block size is a good strategy. Depending on the size of the files
           you will be backing up, this multiple varies. Of course it also
           depends on the native block size of your file system.</para>
@@ -90,7 +90,7 @@
   <refsection>
     <title>See Also</title>
 
-    <para><literal>bbstored-config(1)</literal></para>
+    <para><literal>bbstored-config(8)</literal></para>
 
     <para><literal>bbstored.conf(5)</literal></para>
 
@@ -120,7 +120,7 @@
       </listitem>
 
       <listitem>
-        <para>The platform you are running on (Hardware and OS), for both
+        <para>The platform you are running on (hardware and OS), for both
         client and server.</para>
       </listitem>
 

Modified: box/trunk/lib/backupclient/BackupClientRestore.cpp
===================================================================
--- box/trunk/lib/backupclient/BackupClientRestore.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/backupclient/BackupClientRestore.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -267,14 +267,14 @@
 					"restore this object.");
 				if(::unlink(rLocalDirectoryName.c_str()) != 0)
 				{
-					BOX_ERROR("Failed to delete file " <<
-						rLocalDirectoryName << ": " <<
-						strerror(errno));
+					BOX_LOG_SYS_ERROR("Failed to delete "
+						"file '" << 
+						rLocalDirectoryName << "'");
 					return Restore_UnknownError;
 				}
 				BOX_TRACE("In restore, directory name " 
-					"collision with file " <<
-					rLocalDirectoryName);
+					"collision with file '" <<
+					rLocalDirectoryName << "'");
 			}
 			break;
 		case ObjectExists_NoObject:
@@ -378,9 +378,8 @@
 		exists == ObjectExists_File) && 
 		::mkdir(rLocalDirectoryName.c_str(), S_IRWXU) != 0)
 	{
-		BOX_ERROR("Failed to create directory '" <<
-			rLocalDirectoryName << "': " << 
-			strerror(errno));
+		BOX_LOG_SYS_ERROR("Failed to create directory '" <<
+			rLocalDirectoryName << "'");
 		return Restore_UnknownError;
 	}
 
@@ -451,7 +450,9 @@
 			{
 				// Local name
 				BackupStoreFilenameClear nm(en->GetName());
-				std::string localFilename(rLocalDirectoryName + DIRECTORY_SEPARATOR_ASCHAR + nm.GetClearFilename());
+				std::string localFilename(rLocalDirectoryName +
+					DIRECTORY_SEPARATOR_ASCHAR +
+					nm.GetClearFilename());
 				
 				// Unlink anything which already exists:
 				// For resuming restores, we can't overwrite
@@ -459,20 +460,23 @@
 				if(ObjectExists(localFilename) != ObjectExists_NoObject &&
 					::unlink(localFilename.c_str()) != 0)
 				{
-					BOX_ERROR("Failed to delete file '" <<
-						localFilename << "': " <<
-						strerror(errno));
+					BOX_LOG_SYS_ERROR("Failed to delete "
+						"file '" << localFilename << 
+						"'");
 					return Restore_UnknownError;
 				}
 				
 				// Request it from the store
-				rConnection.QueryGetFile(DirectoryID, en->GetObjectID());
+				rConnection.QueryGetFile(DirectoryID,
+					en->GetObjectID());
 		
 				// Stream containing encoded file
-				std::auto_ptr<IOStream> objectStream(rConnection.ReceiveStream());
+				std::auto_ptr<IOStream> objectStream(
+					rConnection.ReceiveStream());
 		
-				// Decode the file -- need to do different things depending on whether 
-				// the directory entry has additional attributes
+				// Decode the file -- need to do different
+				// things depending on whether the directory
+				// entry has additional attributes
 				try
 				{
 					if(en->HasAttributes())

Modified: box/trunk/lib/backupclient/BackupDaemonConfigVerify.cpp
===================================================================
--- box/trunk/lib/backupclient/BackupDaemonConfigVerify.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/backupclient/BackupDaemonConfigVerify.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -17,15 +17,15 @@
 
 static const ConfigurationVerifyKey backuplocationkeys[] = 
 {
-	{"ExcludeFile", 0, ConfigTest_MultiValueAllowed, 0},
-	{"ExcludeFilesRegex", 0, ConfigTest_MultiValueAllowed, 0},
-	{"ExcludeDir", 0, ConfigTest_MultiValueAllowed, 0},
-	{"ExcludeDirsRegex", 0, ConfigTest_MultiValueAllowed, 0},
-	{"AlwaysIncludeFile", 0, ConfigTest_MultiValueAllowed, 0},
-	{"AlwaysIncludeFilesRegex", 0, ConfigTest_MultiValueAllowed, 0},
-	{"AlwaysIncludeDir", 0, ConfigTest_MultiValueAllowed, 0},
-	{"AlwaysIncludeDirsRegex", 0, ConfigTest_MultiValueAllowed, 0},
-	{"Path", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}
+	ConfigurationVerifyKey("ExcludeFile", ConfigTest_MultiValueAllowed),
+	ConfigurationVerifyKey("ExcludeFilesRegex", ConfigTest_MultiValueAllowed),
+	ConfigurationVerifyKey("ExcludeDir", ConfigTest_MultiValueAllowed),
+	ConfigurationVerifyKey("ExcludeDirsRegex", ConfigTest_MultiValueAllowed),
+	ConfigurationVerifyKey("AlwaysIncludeFile", ConfigTest_MultiValueAllowed),
+	ConfigurationVerifyKey("AlwaysIncludeFilesRegex", ConfigTest_MultiValueAllowed),
+	ConfigurationVerifyKey("AlwaysIncludeDir", ConfigTest_MultiValueAllowed),
+	ConfigurationVerifyKey("AlwaysIncludeDirsRegex", ConfigTest_MultiValueAllowed),
+	ConfigurationVerifyKey("Path", ConfigTest_Exists | ConfigTest_LastEntry)
 };
 
 static const ConfigurationVerify backuplocations[] = 
@@ -64,39 +64,54 @@
 
 static const ConfigurationVerifyKey verifyrootkeys[] = 
 {
-	{"AccountNumber", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
-
-	{"UpdateStoreInterval", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
-	{"MinimumFileAge", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
-	{"MaxUploadWait", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
-	{"MaxFileTimeInFuture", "172800", ConfigTest_IsInt, 0},		// file is uploaded if the file is this much in the future (2 days default)
-
-	{"AutomaticBackup", "yes", ConfigTest_IsBool, 0},
+	ConfigurationVerifyKey("AccountNumber",
+		ConfigTest_Exists | ConfigTest_IsInt),
+	ConfigurationVerifyKey("UpdateStoreInterval",
+		ConfigTest_Exists | ConfigTest_IsInt),
+	ConfigurationVerifyKey("MinimumFileAge",
+		ConfigTest_Exists | ConfigTest_IsInt),
+	ConfigurationVerifyKey("MaxUploadWait",
+		ConfigTest_Exists | ConfigTest_IsInt),
+	ConfigurationVerifyKey("MaxFileTimeInFuture", ConfigTest_IsInt, 172800),
+	// file is uploaded if the file is this much in the future
+	// (2 days default)
+	ConfigurationVerifyKey("AutomaticBackup", ConfigTest_IsBool, true),
 	
-	{"SyncAllowScript", 0, 0, 0},			// optional script to run to see if the sync should be started now
-				// return "now" if it's allowed, or a number of seconds if it's not
+	ConfigurationVerifyKey("SyncAllowScript", 0),
+	// script that returns "now" if backup is allowed now, or a number
+	// of seconds to wait before trying again if not
 
-	{"MaximumDiffingTime", 0, ConfigTest_IsInt, 0},
-	{"DeleteRedundantLocationsAfter", "172800", ConfigTest_IsInt, 0},
+	ConfigurationVerifyKey("MaximumDiffingTime", ConfigTest_IsInt),
+	ConfigurationVerifyKey("DeleteRedundantLocationsAfter",
+		ConfigTest_IsInt, 172800),
 
-	{"FileTrackingSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
-	{"DiffingUploadSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
-	{"StoreHostname", 0, ConfigTest_Exists, 0},
-	{"ExtendedLogging",	"no", ConfigTest_IsBool, 0}, // extended log to syslog
-	{"ExtendedLogFile",	NULL, 0, 0}, // extended log to a file
-	{"LogAllFileAccess", "no", ConfigTest_IsBool, 0},
+	ConfigurationVerifyKey("FileTrackingSizeThreshold", 
+		ConfigTest_Exists | ConfigTest_IsInt),
+	ConfigurationVerifyKey("DiffingUploadSizeThreshold",
+		ConfigTest_Exists | ConfigTest_IsInt),
+	ConfigurationVerifyKey("StoreHostname", ConfigTest_Exists),
+	ConfigurationVerifyKey("StorePort", ConfigTest_IsInt,
+		BOX_PORT_BBSTORED),
+	ConfigurationVerifyKey("ExtendedLogging", ConfigTest_IsBool, false),
+	// extended log to syslog
+	ConfigurationVerifyKey("ExtendedLogFile", 0),
+	// extended log to a file
+	ConfigurationVerifyKey("LogAllFileAccess", ConfigTest_IsBool, false),
+	ConfigurationVerifyKey("CommandSocket", 0),
+	// not compulsory to have this
+	ConfigurationVerifyKey("KeepAliveTime", ConfigTest_IsInt),
+ 	ConfigurationVerifyKey("StoreObjectInfoFile", 0),
+	// optional
 
-	{"CommandSocket", 0, 0, 0},				// not compulsory to have this
-	{"KeepAliveTime", 0, ConfigTest_IsInt, 0},				// optional
- 	{"StoreObjectInfoFile", 0, 0, 0},				// optional
-
-	{"NotifyScript", 0, 0, 0},				// optional script to run when backup needs attention, eg store full
+	ConfigurationVerifyKey("NotifyScript", 0),
+	// optional script to run when backup needs attention, eg store full
 	
-	{"CertificateFile", 0, ConfigTest_Exists, 0},
-	{"PrivateKeyFile", 0, ConfigTest_Exists, 0},
-	{"TrustedCAsFile", 0, ConfigTest_Exists, 0},
-	{"KeysFile", 0, ConfigTest_Exists, 0},
-	{"DataDirectory", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}
+	ConfigurationVerifyKey("CertificateFile", ConfigTest_Exists),
+	ConfigurationVerifyKey("PrivateKeyFile", ConfigTest_Exists),
+	ConfigurationVerifyKey("TrustedCAsFile", ConfigTest_Exists),
+	ConfigurationVerifyKey("KeysFile", ConfigTest_Exists),
+	ConfigurationVerifyKey("DataDirectory", 
+		ConfigTest_Exists | ConfigTest_LastEntry),
 };
 
 const ConfigurationVerify BackupDaemonConfigVerify =

Modified: box/trunk/lib/backupclient/BackupStoreFileDiff.cpp
===================================================================
--- box/trunk/lib/backupclient/BackupStoreFileDiff.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/backupclient/BackupStoreFileDiff.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -149,7 +149,7 @@
 	int64_t blocksInIndex = 0;
 	bool canDiffFromThis = false;
 	LoadIndex(rDiffFromBlockIndex, DiffFromObjectID, &pindex, blocksInIndex, Timeout, canDiffFromThis);
-	//TRACE1("Diff: Blocks in index: %lld\n", blocksInIndex);
+	// BOX_TRACE("Diff: Blocks in index: " << blocksInIndex);
 	
 	if(!canDiffFromThis)
 	{
@@ -439,7 +439,9 @@
 	{
 		for(int t = 0; t < BACKUP_FILE_DIFF_MAX_BLOCK_SIZES; ++t)
 		{
-			TRACE3("Diff block size %d: %d (count = %lld)\n", t, Sizes[t], sizeCounts[t]);
+			BOX_TRACE("Diff block size " << t << ": " <<
+				Sizes[t] << " (count = " << 
+				sizeCounts[t] << ")");
 		}
 	}
 #endif
@@ -774,7 +776,7 @@
 			// Already present in table?
 			if(pHashTable[hash] != 0)
 			{
-				//TRACE1("Another hash entry for %d found\n", hash);
+				//BOX_TRACE("Another hash entry for " << hash << " found");
 				// Yes -- need to set the pointer in this entry to the current entry to build the linked list
 				pIndex[b].mpNextInHashList = pHashTable[hash];
 			}
@@ -840,17 +842,19 @@
 	
 	// Then go through the entries in the hash list, comparing with the strong digest calculated
 	scan = pFirstInHashList;
-	//TRACE0("second stage match\n");
+	//BOX_TRACE("second stage match");
 	while(scan != 0)
 	{
-		//TRACE3("scan size %d, block size %d, hash %d\n", scan->mSize, BlockSize, Hash);
+		//BOX_TRACE("scan size " << scan->mSize <<
+		//	", block size " << BlockSize <<
+		//	", hash " << Hash);
 		ASSERT(scan->mSize == BlockSize);
 		ASSERT(RollingChecksum::ExtractHashingComponent(scan->mWeakChecksum) == DEBUG_Hash);
 	
 		// Compare?
 		if(strong.DigestMatches(scan->mStrongChecksum))
 		{
-			//TRACE0("Match!\n");
+			//BOX_TRACE("Match!\n");
 			// Found! Add to list of found blocks...
 			int64_t fileOffset = (FileBlockNumber * BlockSize) + Offset;
 			int64_t blockIndex = (scan - pIndex);	// pointer arthmitic is frowned upon. But most efficient way of doing it here -- alternative is to use more memory
@@ -912,7 +916,8 @@
 		#ifndef NDEBUG
 		if(BackupStoreFile::TraceDetailsOfDiffProcess)
 		{
-			TRACE1("Diff: Default recipe generated, %lld bytes of file\n", SizeOfInputFile);
+			BOX_TRACE("Diff: Default recipe generated, " << 
+				SizeOfInputFile << " bytes of file");
 		}
 		#endif
 		
@@ -1005,10 +1010,14 @@
 	
 	// dump out the recipe
 #ifndef NDEBUG
-	TRACE2("Diff: %lld new bytes found, %lld old blocks used\n", debug_NewBytesFound, debug_OldBlocksUsed);
+	BOX_TRACE("Diff: " << 
+		debug_NewBytesFound << " new bytes found, " <<
+		debug_OldBlocksUsed << " old blocks used");
 	if(BackupStoreFile::TraceDetailsOfDiffProcess)
 	{
-		TRACE1("Diff: Recipe generated (size %d)\n======== ========= ========\nSpace b4 FirstBlk  NumBlks\n", rRecipe.size());
+		BOX_TRACE("Diff: Recipe generated (size " << rRecipe.size());
+		BOX_TRACE("======== ========= ========");
+		BOX_TRACE("Space b4 FirstBlk  NumBlks");
 		{
 			for(unsigned int e = 0; e < rRecipe.size(); ++e)
 			{
@@ -1018,10 +1027,15 @@
 #else
 				sprintf(b, "%8lld", (int64_t)(rRecipe[e].mpStartBlock - pIndex));
 #endif
-				TRACE3("%8lld %s %8lld\n", rRecipe[e].mSpaceBefore, (rRecipe[e].mpStartBlock == 0)?"       -":b, (int64_t)rRecipe[e].mBlocks);
+				BOX_TRACE(std::setw(8) <<
+					rRecipe[e].mSpaceBefore <<
+					" " <<
+					((rRecipe[e].mpStartBlock == 0)?"       -":b) <<
+					" " << std::setw(8) <<
+					rRecipe[e].mBlocks);
 			}
 		}
-		TRACE0("======== ========= ========\n");
+		BOX_TRACE("======== ========= ========");
 	}
 #endif
 }

Modified: box/trunk/lib/backupclient/BackupStoreFilenameClear.cpp
===================================================================
--- box/trunk/lib/backupclient/BackupStoreFilenameClear.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/backupclient/BackupStoreFilenameClear.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -167,7 +167,8 @@
 	switch(encoding)
 	{
 	case Encoding_Clear:
-		TRACE0("**** BackupStoreFilename encoded with Clear encoding ****\n");
+		BOX_TRACE("**** BackupStoreFilename encoded with "
+			"Clear encoding ****");
 		mClearFilename.assign(c_str() + 2, size - 2);
 		break;
 		
@@ -193,7 +194,8 @@
 	if(spEncDecBuffer == 0)
 	{
 #ifndef WIN32
-		TRACE1("Allocating filename encoding/decoding buffer with size %d\n", BufSize);
+		BOX_TRACE("Allocating filename encoding/decoding buffer "
+			"with size " << BufSize);
 #endif
 		spEncDecBuffer = new MemoryBlockGuard<uint8_t *>(BufSize);
 		MEMLEAKFINDER_NOT_A_LEAK(spEncDecBuffer);

Modified: box/trunk/lib/backupclient/BackupStoreObjectDump.cpp
===================================================================
--- box/trunk/lib/backupclient/BackupStoreObjectDump.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/backupclient/BackupStoreObjectDump.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -47,7 +47,7 @@
 	}
 	if(ToTrace)
 	{
-		TRACE1("%s", text);
+		BOX_TRACE(text);
 	}
 }
 
@@ -211,14 +211,16 @@
 		if(s > 0)
 		{
 			nnew++;
-			TRACE2("%8lld this  s=%8lld\n", b, s);
+			BOX_TRACE(std::setw(8) << b << " this  s=" <<
+				std::setw(8) << s);
 		}
 		else
 		{
 			nold++;
-			TRACE2("%8lld other i=%8lld\n", b, 0 - s);		
+			BOX_TRACE(std::setw(8) << b << " other i=" <<
+				std::setw(8) << 0 - s);
 		}
 	}
-	TRACE0("======== ===== ==========\n");
+	BOX_TRACE("======== ===== ==========");
 }
 

Modified: box/trunk/lib/backupstore/BackupStoreCheck.cpp
===================================================================
--- box/trunk/lib/backupstore/BackupStoreCheck.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/backupstore/BackupStoreCheck.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -268,7 +268,8 @@
 		}
 	
 		maxDir = CheckObjectsScanDir(0, 1, mStoreRoot);
-		TRACE1("Max dir starting ID is %llx\n", maxDir);
+		BOX_TRACE("Max dir starting ID is " <<
+			BOX_FORMAT_OBJECTID(maxDir));
 	}
 	
 	// Then go through and scan all the objects within those directories

Modified: box/trunk/lib/backupstore/BackupStoreCheck2.cpp
===================================================================
--- box/trunk/lib/backupstore/BackupStoreCheck2.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/backupstore/BackupStoreCheck2.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -594,6 +594,8 @@
 	}
 }
 
+#define FMT_OID(x) BOX_FORMAT_OBJECTID(x)
+#define FMT_i      BOX_FORMAT_OBJECTID((*i)->GetObjectID())
 
 // --------------------------------------------------------------------------
 //
@@ -620,7 +622,11 @@
 				if(newerEn == 0)
 				{
 					// Depends on something, but it isn't there.
-					TRACE2("Entry id %llx removed because depends on newer version %llx which doesn't exist\n", (*i)->GetObjectID(), dependsNewer);
+					BOX_TRACE("Entry id " << FMT_i <<
+						" removed because depends "
+						"on newer version " <<
+						FMT_OID(dependsNewer) <<
+						" which doesn't exist");
 					
 					// Remove
 					delete *i;
@@ -638,7 +644,12 @@
 					if(newerEn->GetDependsOlder() != (*i)->GetObjectID())
 					{
 						// Wrong entry
-						TRACE3("Entry id %llx, correcting DependsOlder to %llx, was %llx\n", dependsNewer, (*i)->GetObjectID(), newerEn->GetDependsOlder());
+						BOX_TRACE("Entry id " <<
+							FMT_OID(dependsNewer) <<
+							", correcting DependsOlder to " <<
+							FMT_i <<
+							", was " <<
+							FMT_OID(newerEn->GetDependsOlder()));
 						newerEn->SetDependsOlder((*i)->GetObjectID());
 						// Mark as changed
 						changed = true;
@@ -657,7 +668,11 @@
 			if(dependsOlder != 0 && FindEntryByID(dependsOlder) == 0)
 			{
 				// Has an older version marked, but this doesn't exist. Remove this mark
-				TRACE2("Entry id %llx was marked that %llx depended on it, which doesn't exist, dependency info cleared\n", (*i)->GetObjectID(), dependsOlder);
+				BOX_TRACE("Entry id " << FMT_i <<
+					" was marked as depended on by " <<
+					FMT_OID(dependsOlder) << ", "
+					"which doesn't exist, dependency "
+					"info cleared");
 
 				(*i)->SetDependsOlder(0);
 				
@@ -693,7 +708,7 @@
 			bool removeEntry = false;
 			if((*i) == 0)
 			{
-				TRACE0("Remove because null pointer found\n");
+				BOX_TRACE("Remove because null pointer found");
 				removeEntry = true;
 			}
 			else
@@ -704,7 +719,8 @@
 				if(isDir && (((*i)->GetFlags() & Entry::Flags_File) == Entry::Flags_File))
 				{
 					// Bad! Unset the file flag
-					TRACE1("Entry %llx: File flag set when dir flag set\n", (*i)->GetObjectID());
+					BOX_TRACE("Entry " << FMT_i <<
+						": File flag and dir flag both set");
 					(*i)->RemoveFlags(Entry::Flags_File);
 					changed = true;
 				}
@@ -713,7 +729,8 @@
 				if(idsEncountered.find((*i)->GetObjectID()) != idsEncountered.end())
 				{
 					// ID already seen, or type doesn't match
-					TRACE1("Entry %llx: Remove because ID already seen\n", (*i)->GetObjectID());
+					BOX_TRACE("Entry " << FMT_i <<
+						": Remove because ID already seen");
 					removeEntry = true;
 				}
 				else
@@ -730,7 +747,8 @@
 							&& ((*i)->GetFlags() & Entry::Flags_Deleted) == 0)
 						{
 							// Not set, set it
-							TRACE1("Entry %llx: Set old flag\n", (*i)->GetObjectID());
+							BOX_TRACE("Entry " << FMT_i <<
+								": Set old flag");
 							(*i)->AddFlags(Entry::Flags_OldVersion);
 							changed = true;
 						}
@@ -741,7 +759,8 @@
 						if(((*i)->GetFlags() & Entry::Flags_OldVersion) == Entry::Flags_OldVersion)
 						{
 							// Set, unset it
-							TRACE1("Entry %llx: Old flag unset\n", (*i)->GetObjectID());
+							BOX_TRACE("Entry " << FMT_i <<
+								": Old flag unset");
 							(*i)->RemoveFlags(Entry::Flags_OldVersion);
 							changed = true;
 						}

Modified: box/trunk/lib/backupstore/BackupStoreCheckData.cpp
===================================================================
--- box/trunk/lib/backupstore/BackupStoreCheckData.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/backupstore/BackupStoreCheckData.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -189,15 +189,18 @@
 	{
 		IDBlock *pblock = i->second;
 		int32_t bentries = (pblock == mpInfoLastBlock)?mInfoLastBlockEntries:BACKUPSTORECHECK_BLOCK_SIZE;
-		TRACE2("BLOCK @ 0x%08x, %d entries\n", pblock, bentries);
+		BOX_TRACE("BLOCK @ " << BOX_FORMAT_HEX32(pblock) <<
+			", " << bentries << " entries");
 		
 		for(int e = 0; e < bentries; ++e)
 		{
 			uint8_t flags = GetFlags(pblock, e);
-			TRACE4("id %llx, c %llx, %s, %s\n",
-				pblock->mID[e], pblock->mContainer[e],
-				(flags & Flags_IsDir)?"dir":"file",
-				(flags & Flags_IsContained)?"contained":"unattached");
+			BOX_TRACE(std::hex << 
+				"id "  << pblock->mID[e] <<
+				", c " << pblock->mContainer[e] <<
+				", " << ((flags & Flags_IsDir)?"dir":"file") <<
+				", " << ((flags & Flags_IsContained) ? 
+					"contained":"unattached"));
 		}
 	}
 }

Modified: box/trunk/lib/backupstore/BackupStoreConfigVerify.cpp
===================================================================
--- box/trunk/lib/backupstore/BackupStoreConfigVerify.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/backupstore/BackupStoreConfigVerify.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -16,7 +16,8 @@
 
 static const ConfigurationVerifyKey verifyserverkeys[] = 
 {
-	SERVERTLS_VERIFY_SERVER_KEYS(0)	// no default listen addresses
+	SERVERTLS_VERIFY_SERVER_KEYS(ConfigurationVerifyKey::NoDefaultValue)
+	// no default listen addresses
 };
 
 static const ConfigurationVerify verifyserver[] = 
@@ -32,16 +33,18 @@
 
 static const ConfigurationVerifyKey verifyrootkeys[] = 
 {
-	{"AccountDatabase",	0, ConfigTest_Exists, 0},
-	{"TimeBetweenHousekeeping",	0, ConfigTest_Exists | ConfigTest_IsInt, 0},
-	{"ExtendedLogging",	"no", ConfigTest_IsBool, 0},			// make value "yes" to enable in config file
+	ConfigurationVerifyKey("AccountDatabase", ConfigTest_Exists),
+	ConfigurationVerifyKey("TimeBetweenHousekeeping",
+		ConfigTest_Exists | ConfigTest_IsInt),
+	ConfigurationVerifyKey("ExtendedLogging", ConfigTest_IsBool, false),
+	// make value "yes" to enable in config file
 
 	#ifdef WIN32
-		{"RaidFileConf", "", ConfigTest_LastEntry, 0}
+		ConfigurationVerifyKey("RaidFileConf", ConfigTest_LastEntry)
 	#else
-		{"RaidFileConf", BOX_FILE_RAIDFILE_DEFAULT_CONFIG, ConfigTest_LastEntry, 0}
+		ConfigurationVerifyKey("RaidFileConf", ConfigTest_LastEntry,
+			BOX_FILE_RAIDFILE_DEFAULT_CONFIG)
 	#endif
-
 };
 
 const ConfigurationVerify BackupConfigFileVerify =

Modified: box/trunk/lib/common/Box.h
===================================================================
--- box/trunk/lib/common/Box.h	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/common/Box.h	2008-04-04 22:11:45 UTC (rev 2127)
@@ -52,15 +52,6 @@
 	extern bool BoxDebugTraceOn;
 	int BoxDebug_printf(const char *format, ...);
 	int BoxDebugTrace(const char *format, ...);
-	#define	TRACE0(msg) {BoxDebugTrace("%s", msg);}
-	#define	TRACE1(msg, a0) {BoxDebugTrace(msg, a0);}
-	#define	TRACE2(msg, a0, a1) {BoxDebugTrace(msg, a0, a1);}
-	#define	TRACE3(msg, a0, a1, a2) {BoxDebugTrace(msg, a0, a1, a2);}
-	#define	TRACE4(msg, a0, a1, a2, a3) {BoxDebugTrace(msg, a0, a1, a2, a3);}
-	#define	TRACE5(msg, a0, a1, a2, a3, a4) {BoxDebugTrace(msg, a0, a1, a2, a3, a4);}
-	#define	TRACE6(msg, a0, a1, a2, a3, a4, a5) {BoxDebugTrace(msg, a0, a1, a2, a3, a4, a5);}
-	#define	TRACE7(msg, a0, a1, a2, a3, a4, a5, a6) {BoxDebugTrace(msg, a0, a1, a2, a3, a4, a5, a6);}
-	#define	TRACE8(msg, a0, a1, a2, a3, a4, a5, a6, a7) {BoxDebugTrace(msg, a0, a1, a2, a3, a4, a5, a6, a7);}
 	
 	#ifndef PLATFORM_DISABLE_MEM_LEAK_TESTING
 		#define BOX_MEMORY_LEAK_TESTING
@@ -76,16 +67,6 @@
 	#define TRACE_TO_SYSLOG(x) {}
 	#define TRACE_TO_STDOUT(x) {}
 
-	#define TRACE0(msg)
-	#define	TRACE1(msg, a0)
-	#define	TRACE2(msg, a0, a1)
-	#define	TRACE3(msg, a0, a1, a2)
-	#define	TRACE4(msg, a0, a1, a2, a3)
-	#define	TRACE5(msg, a0, a1, a2, a3, a4)
-	#define	TRACE6(msg, a0, a1, a2, a3, a4, a5)
-	#define	TRACE7(msg, a0, a1, a2, a3, a4, a5, a6)
-	#define	TRACE8(msg, a0, a1, a2, a3, a4, a5, a6, a7)
-	
 	// Box Backup builds release get extra information for exception logging
 	#define EXCEPTION_CODENAMES_EXTENDED
 	#define EXCEPTION_CODENAMES_EXTENDED_WITH_DESCRIPTION

Modified: box/trunk/lib/common/BoxTime.cpp
===================================================================
--- box/trunk/lib/common/BoxTime.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/common/BoxTime.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -39,8 +39,8 @@
 		struct timeval tv;
 		if (gettimeofday(&tv, NULL) != 0)
 		{
-			BOX_ERROR("Failed to gettimeofday(), dropping "
-				"precision: " << strerror(errno));
+			BOX_LOG_SYS_ERROR("Failed to gettimeofday(), "
+				"dropping precision");
 		}
 		else
 		{

Modified: box/trunk/lib/common/Configuration.cpp
===================================================================
--- box/trunk/lib/common/Configuration.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/common/Configuration.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -12,6 +12,8 @@
 #include <stdlib.h>
 #include <limits.h>
 
+#include <sstream>
+
 #include "Configuration.h"
 #include "CommonException.h"
 #include "Guards.h"
@@ -29,8 +31,106 @@
 static const char *sValueBooleanStrings[] = {"yes", "true", "no", "false", 0};
 static const bool sValueBooleanValue[] = {true, true, false, false};
 
+ConfigurationVerifyKey::ConfigurationVerifyKey
+(
+	std::string name,
+	int flags,
+	void *testFunction
+)
+: mName(name),
+  mHasDefaultValue(false),
+  mFlags(flags),
+  mTestFunction(testFunction)
+{ }
 
+// to allow passing NULL for default ListenAddresses
 
+ConfigurationVerifyKey::ConfigurationVerifyKey
+(
+	std::string name,
+	int flags,
+	NoDefaultValue_t t,
+	void *testFunction
+)
+: mName(name),
+  mHasDefaultValue(false),
+  mFlags(flags),
+  mTestFunction(testFunction)
+{ }
+
+ConfigurationVerifyKey::ConfigurationVerifyKey
+(
+	std::string name,
+	int flags,
+	std::string defaultValue,
+	void *testFunction
+)
+: mName(name),
+  mDefaultValue(defaultValue),
+  mHasDefaultValue(true),
+  mFlags(flags),
+  mTestFunction(testFunction)
+{ }
+
+ConfigurationVerifyKey::ConfigurationVerifyKey
+(
+	std::string name,
+	int flags,
+	const char *defaultValue,
+	void *testFunction
+)
+: mName(name),
+  mDefaultValue(defaultValue),
+  mHasDefaultValue(true),
+  mFlags(flags),
+  mTestFunction(testFunction)
+{ }
+
+ConfigurationVerifyKey::ConfigurationVerifyKey
+(
+	std::string name,
+	int flags,
+	int defaultValue,
+	void *testFunction
+)
+: mName(name),
+  mHasDefaultValue(true),
+  mFlags(flags),
+  mTestFunction(testFunction)
+{
+	ASSERT(flags & ConfigTest_IsInt);
+	std::ostringstream val;
+	val << defaultValue;
+	mDefaultValue = val.str();
+}
+
+ConfigurationVerifyKey::ConfigurationVerifyKey
+(
+	std::string name,
+	int flags,
+	bool defaultValue,
+	void *testFunction
+)
+: mName(name),
+  mHasDefaultValue(true),
+  mFlags(flags),
+  mTestFunction(testFunction)
+{
+	ASSERT(flags & ConfigTest_IsBool);
+	mDefaultValue = defaultValue ? "yes" : "no";
+}
+
+ConfigurationVerifyKey::ConfigurationVerifyKey
+(
+	const ConfigurationVerifyKey& rToCopy
+)
+: mName(rToCopy.mName),
+  mDefaultValue(rToCopy.mDefaultValue),
+  mHasDefaultValue(rToCopy.mHasDefaultValue),
+  mFlags(rToCopy.mFlags),
+  mTestFunction(rToCopy.mTestFunction)
+{ }
+
 // --------------------------------------------------------------------------
 //
 // Function
@@ -108,8 +208,8 @@
 		if(!rErrorMsg.empty())
 		{
 			// An error occured, return now
-			//TRACE1("Error message from LoadInto: %s", rErrorMsg.c_str());
-			TRACE0("Error at Configuration::LoadInfo\n");
+			BOX_ERROR("Error in Configuration::LoadInfo: " << 
+				rErrorMsg);
 			delete pconfig;
 			pconfig = 0;
 			return std::auto_ptr<Configuration>(0);
@@ -120,8 +220,8 @@
 		{
 			if(!Verify(*pconfig, *pVerify, std::string(), rErrorMsg))
 			{
-				//TRACE1("Error message from Verify: %s", rErrorMsg.c_str());
-				TRACE0("Error at Configuration::Verify\n");
+				BOX_ERROR("Error verifying configuration: " <<
+					rErrorMsg);
 				delete pconfig;
 				pconfig = 0;
 				return std::auto_ptr<Configuration>(0);
@@ -189,7 +289,8 @@
 			}
 			else
 			{
-				rErrorMsg += "Unexpected start block in " + rConfig.mName + "\n";
+				rErrorMsg += "Unexpected start block in " +
+					rConfig.mName + "\n";
 			}
 		}
 		else
@@ -290,36 +391,32 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    Configuration::KeyExists(const char *)
+//		Name:    Configuration::KeyExists(const std::string&)
 //		Purpose: Checks to see if a key exists
 //		Created: 2003/07/23
 //
 // --------------------------------------------------------------------------
-bool Configuration::KeyExists(const char *pKeyName) const
+bool Configuration::KeyExists(const std::string& rKeyName) const
 {
-	if(pKeyName == 0) {THROW_EXCEPTION(CommonException, BadArguments)}
-
-	return mKeys.find(pKeyName) != mKeys.end();
+	return mKeys.find(rKeyName) != mKeys.end();
 }
 
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    Configuration::GetKeyValue(const char *)
+//		Name:    Configuration::GetKeyValue(const std::string&)
 //		Purpose: Returns the value of a configuration variable
 //		Created: 2003/07/23
 //
 // --------------------------------------------------------------------------
-const std::string &Configuration::GetKeyValue(const char *pKeyName) const
+const std::string &Configuration::GetKeyValue(const std::string& rKeyName) const
 {
-	if(pKeyName == 0) {THROW_EXCEPTION(CommonException, BadArguments)}
-
-	std::map<std::string, std::string>::const_iterator i(mKeys.find(pKeyName));
+	std::map<std::string, std::string>::const_iterator i(mKeys.find(rKeyName));
 	
 	if(i == mKeys.end())
 	{
-		BOX_ERROR("Missing configuration key: " << pKeyName);
+		BOX_ERROR("Missing configuration key: " << rKeyName);
 		THROW_EXCEPTION(CommonException, ConfigNoKey)
 	}
 	else
@@ -332,16 +429,14 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    Configuration::GetKeyValueInt(const char *)
+//		Name:    Configuration::GetKeyValueInt(const std::string& rKeyName)
 //		Purpose: Gets a key value as an integer
 //		Created: 2003/07/23
 //
 // --------------------------------------------------------------------------
-int Configuration::GetKeyValueInt(const char *pKeyName) const
+int Configuration::GetKeyValueInt(const std::string& rKeyName) const
 {
-	if(pKeyName == 0) {THROW_EXCEPTION(CommonException, BadArguments)}
-
-	std::map<std::string, std::string>::const_iterator i(mKeys.find(pKeyName));
+	std::map<std::string, std::string>::const_iterator i(mKeys.find(rKeyName));
 	
 	if(i == mKeys.end())
 	{
@@ -362,16 +457,14 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    Configuration::GetKeyValueBool(const char *) const
+//		Name:    Configuration::GetKeyValueBool(const std::string&)
 //		Purpose: Gets a key value as a boolean
 //		Created: 17/2/04
 //
 // --------------------------------------------------------------------------
-bool Configuration::GetKeyValueBool(const char *pKeyName) const
+bool Configuration::GetKeyValueBool(const std::string& rKeyName) const
 {
-	if(pKeyName == 0) {THROW_EXCEPTION(CommonException, BadArguments)}
-
-	std::map<std::string, std::string>::const_iterator i(mKeys.find(pKeyName));
+	std::map<std::string, std::string>::const_iterator i(mKeys.find(rKeyName));
 	
 	if(i == mKeys.end())
 	{
@@ -428,22 +521,21 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    Configuration::SubConfigurationExists(const char *)
+//		Name:    Configuration::SubConfigurationExists(const
+//			 std::string&)
 //		Purpose: Checks to see if a sub configuration exists
 //		Created: 2003/07/23
 //
 // --------------------------------------------------------------------------
-bool Configuration::SubConfigurationExists(const char *pSubName) const
+bool Configuration::SubConfigurationExists(const std::string& rSubName) const
 {
-	if(pSubName == 0) {THROW_EXCEPTION(CommonException, BadArguments)}
-
 	// Attempt to find it...
 	std::list<std::pair<std::string, Configuration> >::const_iterator i(mSubConfigurations.begin());
 	
 	for(; i != mSubConfigurations.end(); ++i)
 	{
 		// This the one?
-		if(i->first == pSubName)
+		if(i->first == rSubName)
 		{
 			// Yes.
 			return true;
@@ -458,22 +550,22 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    Configuration::GetSubConfiguration(const char *)
+//		Name:    Configuration::GetSubConfiguration(const
+//			 std::string&)
 //		Purpose: Gets a sub configuration
 //		Created: 2003/07/23
 //
 // --------------------------------------------------------------------------
-const Configuration &Configuration::GetSubConfiguration(const char *pSubName) const
+const Configuration &Configuration::GetSubConfiguration(const std::string&
+	rSubName) const
 {
-	if(pSubName == 0) {THROW_EXCEPTION(CommonException, BadArguments)}
-
 	// Attempt to find it...
 	std::list<std::pair<std::string, Configuration> >::const_iterator i(mSubConfigurations.begin());
 	
 	for(; i != mSubConfigurations.end(); ++i)
 	{
 		// This the one?
-		if(i->first == pSubName)
+		if(i->first == rSubName)
 		{
 			// Yes.
 			return i->second;
@@ -528,15 +620,14 @@
 		do
 		{
 			// Can the key be found?
-			ASSERT(pvkey->mpName);
-			if(rConfig.KeyExists(pvkey->mpName))
+			if(rConfig.KeyExists(pvkey->Name()))
 			{
 				// Get value
-				const std::string &rval = rConfig.GetKeyValue(pvkey->mpName);
+				const std::string &rval = rConfig.GetKeyValue(pvkey->Name());
 				const char *val = rval.c_str();
 
 				// Check it's a number?
-				if((pvkey->Tests & ConfigTest_IsInt) == ConfigTest_IsInt)
+				if((pvkey->Flags() & ConfigTest_IsInt) == ConfigTest_IsInt)
 				{					
 					// Test it...
 					char *end;
@@ -545,12 +636,12 @@
 					{
 						// not a good value
 						ok = false;
-						rErrorMsg += rLevel + rConfig.mName +"." + pvkey->mpName + " (key) is not a valid integer.\n";
+						rErrorMsg += rLevel + rConfig.mName + "." + pvkey->Name() + " (key) is not a valid integer.\n";
 					}
 				}
 				
 				// Check it's a bool?
-				if((pvkey->Tests & ConfigTest_IsBool) == ConfigTest_IsBool)
+				if((pvkey->Flags() & ConfigTest_IsBool) == ConfigTest_IsBool)
 				{				
 					// See if it's one of the allowed strings.
 					bool found = false;
@@ -568,37 +659,38 @@
 					if(!found)
 					{
 						ok = false;
-						rErrorMsg += rLevel + rConfig.mName +"." + pvkey->mpName + " (key) is not a valid boolean value.\n";
+						rErrorMsg += rLevel + rConfig.mName + "." + pvkey->Name() + " (key) is not a valid boolean value.\n";
 					}
 				}
 				
 				// Check for multi valued statments where they're not allowed
-				if((pvkey->Tests & ConfigTest_MultiValueAllowed) == 0)
+				if((pvkey->Flags() & ConfigTest_MultiValueAllowed) == 0)
 				{
 					// Check to see if this key is a multi-value -- it shouldn't be
 					if(rval.find(MultiValueSeparator) != rval.npos)
 					{
 						ok = false;
-						rErrorMsg += rLevel + rConfig.mName +"." + pvkey->mpName + " (key) multi value not allowed (duplicated key?).\n";
+						rErrorMsg += rLevel + rConfig.mName +"." + pvkey->Name() + " (key) multi value not allowed (duplicated key?).\n";
 					}
 				}				
 			}
 			else
 			{
 				// Is it required to exist?
-				if((pvkey->Tests & ConfigTest_Exists) == ConfigTest_Exists)
+				if((pvkey->Flags() & ConfigTest_Exists) == ConfigTest_Exists)
 				{
 					// Should exist, but doesn't.
 					ok = false;
-					rErrorMsg += rLevel + rConfig.mName + "." + pvkey->mpName + " (key) is missing.\n";
+					rErrorMsg += rLevel + rConfig.mName + "." + pvkey->Name() + " (key) is missing.\n";
 				}
-				else if(pvkey->mpDefaultValue)
+				else if(pvkey->HasDefaultValue())
 				{
-					rConfig.mKeys[std::string(pvkey->mpName)] = std::string(pvkey->mpDefaultValue);
+					rConfig.mKeys[pvkey->Name()] =
+						pvkey->DefaultValue();
 				}
 			}
 		
-			if((pvkey->Tests & ConfigTest_LastEntry) == ConfigTest_LastEntry)
+			if((pvkey->Flags() & ConfigTest_LastEntry) == ConfigTest_LastEntry)
 			{
 				// No more!
 				todo = false;
@@ -618,14 +710,14 @@
 			bool found = false;
 			while(scan)
 			{
-				if(scan->mpName == i->first)
+				if(scan->Name() == i->first)
 				{
 					found = true;
 					break;
 				}
 				
 				// Next?
-				if((scan->Tests & ConfigTest_LastEntry) == ConfigTest_LastEntry)
+				if((scan->Flags() & ConfigTest_LastEntry) == ConfigTest_LastEntry)
 				{
 					break;
 				}
@@ -650,8 +742,7 @@
 		const ConfigurationVerify *scan = rVerify.mpSubConfigurations;
 		while(scan)
 		{
-			ASSERT(scan->mpName);
-			if(scan->mpName[0] == '*')
+			if(scan->mName.length() > 0 && scan->mName[0] == '*')
 			{
 				wildcardverify = scan;
 			}
@@ -659,7 +750,8 @@
 			// Required?
 			if((scan->Tests & ConfigTest_Exists) == ConfigTest_Exists)
 			{
-				if(scan->mpName[0] == '*')
+				if(scan->mName.length() > 0 &&
+					scan->mName[0] == '*')
 				{
 					// Check something exists
 					if(rConfig.mSubConfigurations.size() < 1)
@@ -672,11 +764,11 @@
 				else
 				{
 					// Check real thing exists
-					if(!rConfig.SubConfigurationExists(scan->mpName))
+					if(!rConfig.SubConfigurationExists(scan->mName))
 					{
 						// Should exist, but doesn't.
 						ok = false;
-						rErrorMsg += rLevel + rConfig.mName + "." + scan->mpName + " (block) is missing.\n";
+						rErrorMsg += rLevel + rConfig.mName + "." + scan->mName + " (block) is missing.\n";
 					}
 				}
 			}
@@ -701,7 +793,7 @@
 			ASSERT(name);
 			while(scan)
 			{
-				if(strcmp(scan->mpName, name) == 0)
+				if(scan->mName == name)
 				{
 					// found it!
 					subverify = scan;

Modified: box/trunk/lib/common/Configuration.h
===================================================================
--- box/trunk/lib/common/Configuration.h	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/common/Configuration.h	2008-04-04 22:11:45 UTC (rev 2127)
@@ -29,20 +29,51 @@
 class ConfigurationVerifyKey
 {
 public:
-	const char *mpName;			// "*" for all other keys (not implemented yet)
-	const char *mpDefaultValue;	// default for when it's not present
-	int Tests;
-	void *TestFunction;			// set to zero for now, will implement later
+	typedef enum
+	{
+		NoDefaultValue = 1
+	} NoDefaultValue_t;
+
+	ConfigurationVerifyKey(std::string name, int flags,
+		void *testFunction = NULL);
+	// to allow passing ConfigurationVerifyKey::NoDefaultValue
+	// for default ListenAddresses
+	ConfigurationVerifyKey(std::string name, int flags,
+		NoDefaultValue_t t, void *testFunction = NULL);
+	ConfigurationVerifyKey(std::string name, int flags,
+		std::string defaultValue, void *testFunction = NULL);
+	ConfigurationVerifyKey(std::string name, int flags,
+		const char* defaultValue, void *testFunction = NULL);
+	ConfigurationVerifyKey(std::string name, int flags,
+		int defaultValue, void *testFunction = NULL);
+	ConfigurationVerifyKey(std::string name, int flags,
+		bool defaultValue, void *testFunction = NULL);
+	const std::string& Name() const { return mName; }
+	const std::string& DefaultValue() const { return mDefaultValue; }
+	const bool HasDefaultValue() const { return mHasDefaultValue; }
+	const int Flags() const { return mFlags; }
+	const void* TestFunction() const { return mTestFunction; }
+	ConfigurationVerifyKey(const ConfigurationVerifyKey& rToCopy);
+
+private:
+	ConfigurationVerifyKey& operator=(const ConfigurationVerifyKey&
+		noAssign);
+
+	std::string mName;         // "*" for all other keys (not implemented yet)
+	std::string mDefaultValue; // default for when it's not present
+	bool mHasDefaultValue;
+	int mFlags;
+	void *mTestFunction; // set to zero for now, will implement later
 };
 
 class ConfigurationVerify
 {
 public:
-	const char *mpName;			// "*" for all other sub config names
+	std::string mName; // "*" for all other sub config names
 	const ConfigurationVerify *mpSubConfigurations;
 	const ConfigurationVerifyKey *mpKeys;
 	int Tests;	
-	void *TestFunction;			// set to zero for now, will implement later
+	void *TestFunction; // set to zero for now, will implement later
 };
 
 class FdGetLine;
@@ -79,14 +110,14 @@
 		std::string &rErrorMsg)
 	{ return LoadAndVerify(rFilename, 0, rErrorMsg); }
 	
-	bool KeyExists(const char *pKeyName) const;
-	const std::string &GetKeyValue(const char *pKeyName) const;
-	int GetKeyValueInt(const char *pKeyName) const;
-	bool GetKeyValueBool(const char *pKeyName) const;
+	bool KeyExists(const std::string& rKeyName) const;
+	const std::string &GetKeyValue(const std::string& rKeyName) const;
+	int GetKeyValueInt(const std::string& rKeyName) const;
+	bool GetKeyValueBool(const std::string& rKeyName) const;
 	std::vector<std::string> GetKeyNames() const;
 	
-	bool SubConfigurationExists(const char *pSubName) const;
-	const Configuration &GetSubConfiguration(const char *pSubName) const;
+	bool SubConfigurationExists(const std::string& rSubName) const;
+	const Configuration &GetSubConfiguration(const std::string& rSubName) const;
 	std::vector<std::string> GetSubConfigurationNames() const;
 	
 	std::string mName;

Modified: box/trunk/lib/common/DebugMemLeakFinder.cpp
===================================================================
--- box/trunk/lib/common/DebugMemLeakFinder.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/common/DebugMemLeakFinder.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -146,7 +146,9 @@
 	std::map<void *, MallocBlockInfo>::iterator i(sMallocBlocks.find(ptr));
 	if(ptr && i == sMallocBlocks.end())
 	{
-		TRACE1("Block %x realloc(), but not in list. Error? Or allocated in startup static objects?\n", ptr);
+		BOX_WARNING("Block " << ptr << " realloc()ated, but not "
+			"in list. Error? Or allocated in startup static "
+			"objects?");
 	}
 
 	void *b = ::realloc(ptr, size);
@@ -193,7 +195,9 @@
 		}
 		else
 		{
-			TRACE1("Block %p freed, but not known. Error? Or allocated in startup static allocation?\n", ptr);
+			BOX_WARNING("Block " << ptr << " freed, but not "
+				"known. Error? Or allocated in startup "
+				"static allocation?");
 		}
 
 		if(sTrackMallocInSection)
@@ -293,16 +297,21 @@
 		std::map<void *, MallocBlockInfo>::const_iterator i(sMallocBlocks.find(*s));
 		if(i == sMallocBlocks.end())
 		{
-			TRACE0("Logical error in section block finding\n");
+			BOX_WARNING("Logical error in section block finding");
 		}
 		else
 		{
-			TRACE4("Block %p size %d allocated at %s:%d\n", i->first, i->second.size, i->second.file, i->second.line);
+			BOX_TRACE("Block " << i->first << " size " <<
+				i->second.size << " allocated at " <<
+				i->second.file << ":" << i->second.line);
 		}
 	}
 	for(std::map<void *, ObjectInfo>::const_iterator i(sSectionObjectBlocks.begin()); i != sSectionObjectBlocks.end(); ++i)
 	{
-		TRACE5("Object%s %p size %d allocated at %s:%d\n", i->second.array?" []":"", i->first, i->second.size, i->second.file, i->second.line);
+		BOX_TRACE("Object" << (i->second.array?" []":"") << " " <<
+			i->first << " size " << i->second.size <<
+			" allocated at " << i->second.file << 
+			":" << i->second.line);
 	}
 }
 

Modified: box/trunk/lib/common/EventWatchFilesystemObject.cpp
===================================================================
--- box/trunk/lib/common/EventWatchFilesystemObject.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/common/EventWatchFilesystemObject.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -26,9 +26,10 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    EventWatchFilesystemObject::EventWatchFilesystemObject(const char *)
-//		Purpose: Constructor -- opens the file object
-//		Created: 12/3/04
+//	Name:    EventWatchFilesystemObject::EventWatchFilesystemObject
+//		 (const char *)
+//	Purpose: Constructor -- opens the file object
+//	Created: 12/3/04
 //
 // --------------------------------------------------------------------------
 EventWatchFilesystemObject::EventWatchFilesystemObject(const char *Filename)
@@ -39,9 +40,8 @@
 #ifdef HAVE_KQUEUE
 	if(mDescriptor == -1)
 	{
-		BOX_ERROR("EventWatchFilesystemObject: "
-			"Failed to open file '" << Filename << "': " <<
-			strerror(errno));
+		BOX_LOG_SYS_ERROR("EventWatchFilesystemObject: "
+			"Failed to open file '" << Filename << "'");
 		THROW_EXCEPTION(CommonException, OSFileOpenError)
 	}
 #else
@@ -53,9 +53,9 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    EventWatchFilesystemObject::~EventWatchFilesystemObject()
-//		Purpose: Destructor
-//		Created: 12/3/04
+//	Name:    EventWatchFilesystemObject::~EventWatchFilesystemObject()
+//	Purpose: Destructor
+//	Created: 12/3/04
 //
 // --------------------------------------------------------------------------
 EventWatchFilesystemObject::~EventWatchFilesystemObject()
@@ -70,12 +70,14 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    EventWatchFilesystemObject::EventWatchFilesystemObject(const EventWatchFilesystemObject &)
-//		Purpose: Copy constructor
-//		Created: 12/3/04
+//	Name:    EventWatchFilesystemObject::EventWatchFilesystemObject
+//		 (const EventWatchFilesystemObject &)
+//	Purpose: Copy constructor
+//	Created: 12/3/04
 //
 // --------------------------------------------------------------------------
-EventWatchFilesystemObject::EventWatchFilesystemObject(const EventWatchFilesystemObject &rToCopy)
+EventWatchFilesystemObject::EventWatchFilesystemObject(
+	const EventWatchFilesystemObject &rToCopy)
 	: mDescriptor(::dup(rToCopy.mDescriptor))
 {
 	if(mDescriptor == -1)
@@ -89,17 +91,20 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    EventWatchFilesystemObject::FillInKEvent(struct kevent &, int)
-//		Purpose: For WaitForEvent
-//		Created: 12/3/04
+//	Name:    EventWatchFilesystemObject::FillInKEvent(struct kevent &, int)
+//	Purpose: For WaitForEvent
+//	Created: 12/3/04
 //
 // --------------------------------------------------------------------------
-void EventWatchFilesystemObject::FillInKEvent(struct kevent &rEvent, int Flags) const
+void EventWatchFilesystemObject::FillInKEvent(struct kevent &rEvent,
+	int Flags) const
 {
-	EV_SET(&rEvent, mDescriptor, EVFILT_VNODE, EV_CLEAR, NOTE_DELETE | NOTE_WRITE, 0, (void*)this);
+	EV_SET(&rEvent, mDescriptor, EVFILT_VNODE, EV_CLEAR,
+		NOTE_DELETE | NOTE_WRITE, 0, (void*)this);
 }
 #else
-void EventWatchFilesystemObject::FillInPoll(int &fd, short &events, int Flags) const
+void EventWatchFilesystemObject::FillInPoll(int &fd, short &events,
+	int Flags) const
 {
 	THROW_EXCEPTION(CommonException, KQueueNotSupportedOnThisPlatform)
 }

Modified: box/trunk/lib/common/FileStream.cpp
===================================================================
--- box/trunk/lib/common/FileStream.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/common/FileStream.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -30,7 +30,8 @@
 #else
 	: mOSFileHandle(::open(Filename, flags, mode)),
 #endif
-	  mIsEOF(false)
+	  mIsEOF(false),
+	  mFileName(Filename)
 {
 #ifdef WIN32
 	if(mOSFileHandle == INVALID_HANDLE_VALUE)
@@ -49,9 +50,6 @@
 			THROW_EXCEPTION(CommonException, OSFileOpenError)
 		}
 	}
-#ifdef WIN32
-	this->fileName = Filename;
-#endif
 }
 
 
@@ -65,7 +63,8 @@
 // --------------------------------------------------------------------------
 FileStream::FileStream(tOSFileHandle FileDescriptor)
 	: mOSFileHandle(FileDescriptor),
-	  mIsEOF(false)
+	  mIsEOF(false),
+	  mFileName("HANDLE")
 {
 #ifdef WIN32
 	if(mOSFileHandle == INVALID_HANDLE_VALUE)
@@ -77,9 +76,6 @@
 		BOX_ERROR("FileStream: called with invalid file handle");
 		THROW_EXCEPTION(CommonException, OSFileOpenError)
 	}
-#ifdef WIN32
-	this->fileName = "HANDLE";
-#endif
 }
 
 #if 0
@@ -150,27 +146,32 @@
 		NULL
 		);
 
-	if ( valid )
+	if(valid)
 	{
 		r = numBytesRead;
 	}
-	else if (GetLastError() == ERROR_BROKEN_PIPE)
+	else if(GetLastError() == ERROR_BROKEN_PIPE)
 	{
 		r = 0;
 	}
 	else
 	{
-		BOX_ERROR("Failed to read from file: " <<
-			GetErrorMessage(GetLastError()));
+		BOX_LOG_WIN_ERROR("Failed to read from file: " << mFileName);
 		r = -1;
 	}
 #else
 	int r = ::read(mOSFileHandle, pBuffer, NBytes);
+	if(r == -1)
+	{
+		BOX_LOG_SYS_ERROR("Failed to read from file: " << mFileName);
+	}
 #endif
+
 	if(r == -1)
 	{
 		THROW_EXCEPTION(CommonException, OSFileReadError)
 	}
+
 	if(r == 0)
 	{
 		mIsEOF = true;

Modified: box/trunk/lib/common/FileStream.h
===================================================================
--- box/trunk/lib/common/FileStream.h	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/common/FileStream.h	2008-04-04 22:11:45 UTC (rev 2127)
@@ -57,10 +57,8 @@
 	bool mIsEOF;
 	FileStream(const FileStream &rToCopy) { /* do not call */ }
 
-#ifdef WIN32
 	// for debugging..
-	std::string fileName;
-#endif
+	std::string mFileName;
 };
 
 

Modified: box/trunk/lib/common/Guards.h
===================================================================
--- box/trunk/lib/common/Guards.h	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/common/Guards.h	2008-04-04 22:11:45 UTC (rev 2127)
@@ -37,8 +37,8 @@
 	{
 		if(mOSFileHandle < 0)
 		{
-			BOX_ERROR("FileHandleGuard: failed to open file '" <<
-				rFilename << "': " << strerror(errno));
+			BOX_LOG_SYS_ERROR("FileHandleGuard: failed to open " 
+				"file '" << rFilename << "'");
 			THROW_EXCEPTION(CommonException, OSFileOpenError)
 		}
 	}

Modified: box/trunk/lib/common/Logging.h
===================================================================
--- box/trunk/lib/common/Logging.h	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/common/Logging.h	2008-04-04 22:11:45 UTC (rev 2127)
@@ -27,16 +27,16 @@
 
 #define BOX_LOG(level, stuff) \
 { \
-	std::ostringstream line; \
-	line << stuff; \
-	Logging::Log(level, __FILE__, __LINE__, line.str()); \
+	std::ostringstream _box_log_line; \
+	_box_log_line << stuff; \
+	Logging::Log(level, __FILE__, __LINE__, _box_log_line.str()); \
 }
 
 #define BOX_SYSLOG(level, stuff) \
 { \
-	std::ostringstream line; \
-	line << stuff; \
-	Logging::LogToSyslog(level, __FILE__, __LINE__, line.str()); \
+	std::ostringstream _box_log_line; \
+	_box_log_line << stuff; \
+	Logging::LogToSyslog(level, __FILE__, __LINE__, _box_log_line.str()); \
 }
 
 #define BOX_FATAL(stuff)   BOX_LOG(Log::FATAL,   stuff)
@@ -48,15 +48,32 @@
 	if (Logging::IsEnabled(Log::TRACE)) \
 	{ BOX_LOG(Log::TRACE, stuff) }
 
-#define BOX_FORMAT_ACCOUNT(accno) \
+#define BOX_LOG_SYS_WARNING(stuff) \
+	BOX_WARNING(stuff << ": " << strerror(errno) << " (" << errno << ")")
+#define BOX_LOG_SYS_ERROR(stuff) \
+	BOX_ERROR(stuff << ": " << strerror(errno) << " (" << errno << ")")
+#define BOX_LOG_SYS_FATAL(stuff) \
+	BOX_FATAL(stuff << ": " << strerror(errno) << " (" << errno << ")")
+
+#ifdef WIN32
+	#define BOX_LOG_WIN_ERROR(stuff) \
+		BOX_ERROR(stuff << ": " << GetErrorMessage(GetLastError()))
+	#define BOX_LOG_WIN_ERROR_NUMBER(stuff, number) \
+		BOX_ERROR(stuff << ": " << GetErrorMessage(number))
+#endif
+
+#define BOX_FORMAT_HEX32(number) \
 	std::hex << \
 	std::showbase << \
 	std::internal << \
 	std::setw(10) << \
 	std::setfill('0') << \
-	(accno) << \
+	(number) << \
 	std::dec
 
+#define BOX_FORMAT_ACCOUNT(accno) \
+	BOX_FORMAT_HEX32(accno)
+
 #define BOX_FORMAT_OBJECTID(objectid) \
 	std::hex << \
 	std::showbase << \

Modified: box/trunk/lib/common/PartialReadStream.cpp
===================================================================
--- box/trunk/lib/common/PartialReadStream.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/common/PartialReadStream.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -44,7 +44,8 @@
 	// Warn in debug mode
 	if(mBytesLeft != 0)
 	{
-		TRACE1("PartialReadStream::~PartialReadStream when mBytesLeft = %d\n", mBytesLeft);
+		BOX_TRACE("PartialReadStream destroyed with " << mBytesLeft <<
+			" bytes remaining");
 	}
 }
 

Modified: box/trunk/lib/common/Utils.cpp
===================================================================
--- box/trunk/lib/common/Utils.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/common/Utils.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -53,10 +53,10 @@
 		rOutput.push_back(String.substr(b));
 	}
 /*#ifndef NDEBUG
-	TRACE2("Splitting string '%s' on %c\n", String.c_str(), SplitOn);
+	BOX_TRACE("Splitting string '" << String << " on " << (char)SplitOn);
 	for(unsigned int l = 0; l < rOutput.size(); ++l)
 	{
-		TRACE2("%d = '%s'\n", l, rOutput[l].c_str());
+		BOX_TRACE(l << " = '" << rOutput[l] << "'");
 	}
 #endif*/
 }
@@ -159,6 +159,65 @@
 	return ((st.st_mode & S_IFDIR) == 0)?ObjectExists_File:ObjectExists_Dir;
 }
 
+std::string HumanReadableSize(int64_t Bytes)
+{
+	double readableValue = Bytes;
+	std::string units = " B";
 
+	if (readableValue > 1024)
+	{
+		readableValue /= 1024;
+		units = "kB";
+	}
+  
+	if (readableValue > 1024)
+	{
+		readableValue /= 1024;
+		units = "MB";
+	}
+  
+	if (readableValue > 1024)
+	{
+		readableValue /= 1024;
+		units = "GB";
+	}
+  
+	std::ostringstream result;
+	result << std::fixed << std::setprecision(2) << readableValue <<
+		" " << units;
+	return result.str();
+}
 
+std::string FormatUsageBar(int64_t Blocks, int64_t Bytes, int64_t Max)
+{
+	std::ostringstream result;
+	
+	// Bar graph
+	char bar[17];
+	unsigned int b = (int)((Bytes * (sizeof(bar)-1)) / Max);
+	if(b > sizeof(bar)-1) {b = sizeof(bar)-1;}
+	for(unsigned int l = 0; l < b; l++)
+	{
+		bar[l] = '*';
+	}
+	for(unsigned int l = b; l < sizeof(bar) - 1; l++)
+	{
+		bar[l] = ' ';
+	}
+	bar[sizeof(bar)-1] = '\0';
+	
+	result << std::fixed <<
+		std::setw(10) << Blocks << " blocks, " <<
+		std::setw(10) << HumanReadableSize(Bytes) << ", " << 
+		std::setw(3) << std::setprecision(0) <<
+		((Bytes*100)/Max) << "% |" << bar << "|";
+	
+	return result.str();
+}
 
+std::string FormatUsageLineStart(const std::string& rName)
+{
+	std::ostringstream result;	
+	result << std::setw(20) << std::right << rName << ": ";
+	return result.str();
+}

Modified: box/trunk/lib/common/Utils.h
===================================================================
--- box/trunk/lib/common/Utils.h	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/common/Utils.h	2008-04-04 22:11:45 UTC (rev 2127)
@@ -30,6 +30,9 @@
 	ObjectExists_Dir = 2
 };
 int ObjectExists(const std::string& rFilename);
+std::string HumanReadableSize(int64_t Bytes);
+std::string FormatUsageBar(int64_t Blocks, int64_t Bytes, int64_t Max);
+std::string FormatUsageLineStart(const std::string& rName);
 
 #include "MemLeakFindOff.h"
 

Modified: box/trunk/lib/compress/Compress.h
===================================================================
--- box/trunk/lib/compress/Compress.h	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/compress/Compress.h	2008-04-04 22:11:45 UTC (rev 2127)
@@ -52,10 +52,12 @@
 		if((r = ((Compressing)?(deflateEnd(&mStream))
 			:(inflateEnd(&mStream)))) != Z_OK)
 		{
-			TRACE1("zlib error code = %d\n", r);
+			BOX_WARNING("zlib error code = " << r);
 			if(r == Z_DATA_ERROR)
 			{
-				TRACE0("WARNING: End of compress/decompress without all input being consumed -- possible corruption?\n");
+				BOX_WARNING("End of compress/decompress "
+					"without all input being consumed, "
+					"possible corruption?");
 			}
 			else
 			{
@@ -148,7 +150,7 @@
 		// Check errors
 		if(ret < 0)
 		{
-			TRACE1("zlib error code = %d\n", ret);			
+			BOX_WARNING("zlib error code = " << ret);			
 			THROW_EXCEPTION(CompressException, TransformFailed)
 		}
 		

Modified: box/trunk/lib/compress/CompressStream.cpp
===================================================================
--- box/trunk/lib/compress/CompressStream.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/compress/CompressStream.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -414,7 +414,7 @@
 	{
 		size *= 2;
 	}
-	TRACE1("Allocating CompressStream buffer, size %d\n", size);
+	BOX_TRACE("Allocating CompressStream buffer, size " << size);
 	mpBuffer = ::malloc(size);
 	if(mpBuffer == 0)
 	{

Modified: box/trunk/lib/crypto/CipherContext.cpp
===================================================================
--- box/trunk/lib/crypto/CipherContext.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/crypto/CipherContext.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -166,7 +166,8 @@
 	// Warn if in a transformation (not an error, because a context might not have been finalised if an exception occured)
 	if(mWithinTransform)
 	{
-		TRACE0("CipherContext::Begin called when context flagged as within a transform\n");
+		BOX_WARNING("CipherContext::Begin called when context "
+			"flagged as within a transform");
 	}
 
 	// Initialise the cipher context again
@@ -423,7 +424,8 @@
 	// Warn if in a transformation
 	if(mWithinTransform)
 	{
-		TRACE0("CipherContext::TransformBlock called when context flagged as within a transform\n");
+		BOX_WARNING("CipherContext::TransformBlock called when "
+			"context flagged as within a transform");
 	}
 
 	// Check output buffer size
@@ -521,7 +523,8 @@
 	// Warn if in a transformation
 	if(mWithinTransform)
 	{
-		TRACE0("CipherContext::SetIV called when context flagged as within a transform\n");
+		BOX_WARNING("CipherContext::SetIV called when context "
+			"flagged as within a transform");
 	}
 
 	// Set IV
@@ -559,7 +562,8 @@
 	// Warn if in a transformation
 	if(mWithinTransform)
 	{
-		TRACE0("CipherContext::SetRandomIV called when context flagged as within a transform\n");
+		BOX_WARNING("CipherContext::SetRandomIV called when "
+			"context flagged as within a transform");
 	}
 
 	// Get length of IV

Modified: box/trunk/lib/intercept/intercept.cpp
===================================================================
--- box/trunk/lib/intercept/intercept.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/intercept/intercept.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -375,12 +375,12 @@
 
 	if (hookfn != NULL)
 	{
-		TRACE2("readdir hooked to %p for %s\n", hookfn, dirname);
+		BOX_TRACE("readdir hooked to " << hookfn << " for " << dirname);
 	}
 	else if (intercept_filename != NULL)
 	{
-		TRACE2("readdir unhooked from %p for %s\n", readdir_hook, 
-			intercept_filename);
+		BOX_TRACE("readdir unhooked from " << readdir_hook << 
+			" for " << intercept_filename);
 	}
 
 	intercept_filename = dirname;
@@ -392,11 +392,11 @@
 	/*
 	if (hookfn != NULL)
 	{
-		TRACE2("lstat hooked to %p for %s\n", hookfn, filename);
+		BOX_TRACE("lstat hooked to " << hookfn << " for " << filename);
 	}
 	else
 	{
-		TRACE2("lstat unhooked from %p for %s\n", lstat_hook, 
+		BOX_TRACE("lstat unhooked from " << lstat_hook << " for " <<
 			lstat_file);
 	}
 	*/

Modified: box/trunk/lib/raidfile/RaidFileController.cpp
===================================================================
--- box/trunk/lib/raidfile/RaidFileController.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/raidfile/RaidFileController.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -70,11 +70,14 @@
 
 	static const ConfigurationVerifyKey verifykeys[] =
 	{
-		{"SetNumber",	0,	ConfigTest_Exists | ConfigTest_IsInt, 0},
-		{"BlockSize",	0,	ConfigTest_Exists | ConfigTest_IsInt, 0},
-		{"Dir0", 		0,	ConfigTest_Exists, 0},
-		{"Dir1", 		0,	ConfigTest_Exists, 0},
-		{"Dir2", 		0,	ConfigTest_Exists | ConfigTest_LastEntry, 0}
+		ConfigurationVerifyKey("SetNumber",
+			ConfigTest_Exists | ConfigTest_IsInt),
+		ConfigurationVerifyKey("BlockSize",
+			ConfigTest_Exists | ConfigTest_IsInt),
+		ConfigurationVerifyKey("Dir0", ConfigTest_Exists),
+		ConfigurationVerifyKey("Dir1", ConfigTest_Exists),
+		ConfigurationVerifyKey("Dir2",
+			ConfigTest_Exists | ConfigTest_LastEntry)
 	};
 	
 	static const ConfigurationVerify subverify = 

Modified: box/trunk/lib/raidfile/RaidFileWrite.cpp
===================================================================
--- box/trunk/lib/raidfile/RaidFileWrite.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/raidfile/RaidFileWrite.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -96,7 +96,8 @@
 		RaidFileUtil::ExistType existance = RaidFileUtil::RaidFileExists(rdiscSet, mFilename);
 		if(existance != RaidFileUtil::NoFile)
 		{
-			TRACE2("Trying to overwrite raidfile %d %s\n", mSetNumber, mFilename.c_str());
+			BOX_ERROR("Attempted to overwrite raidfile " <<
+				mSetNumber << " " << mFilename);
 			THROW_EXCEPTION(RaidFileException, CannotOverwriteExistingFile)
 		}
 	}
@@ -178,7 +179,8 @@
 	int written = ::write(mOSFileHandle, pBuffer, Length);
 	if(written != Length)
 	{
-		TRACE3("RaidFileWrite::Write: Write failure, Length = %d, written = %d, errno = %d\n", Length, written, errno);
+		BOX_LOG_SYS_ERROR("RaidFileWrite failed, Length = " <<
+			Length << ", written = " << written);
 		THROW_EXCEPTION(RaidFileException, OSError)
 	}
 }
@@ -779,7 +781,7 @@
 // --------------------------------------------------------------------------
 void RaidFileWrite::Close()
 {
-	TRACE0("Warning: RaidFileWrite::Close() called, discarding file\n");
+	BOX_WARNING("RaidFileWrite::Close() called, discarding file");
 	if(mOSFileHandle != -1)
 	{
 		Discard();

Modified: box/trunk/lib/server/Daemon.cpp
===================================================================
--- box/trunk/lib/server/Daemon.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/server/Daemon.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -465,8 +465,7 @@
 			// Set new session
 			if(::setsid() == -1)
 			{
-				BOX_ERROR("Failed to setsid(): " << 
-					strerror(errno));
+				BOX_LOG_SYS_ERROR("Failed to setsid()");
 				THROW_EXCEPTION(ServerException, DaemoniseFailed)
 			}
 
@@ -475,6 +474,7 @@
 			{
 			case -1:
 				// error
+				BOX_LOG_SYS_ERROR("Failed to fork() a child");
 				THROW_EXCEPTION(ServerException, DaemoniseFailed)
 				break;
 
@@ -497,9 +497,11 @@
 		struct sigaction sa;
 		sa.sa_handler = SignalHandler;
 		sa.sa_flags = 0;
-		sigemptyset(&sa.sa_mask);		// macro
-		if(::sigaction(SIGHUP, &sa, NULL) != 0 || ::sigaction(SIGTERM, &sa, NULL) != 0)
+		sigemptyset(&sa.sa_mask); // macro
+		if(::sigaction(SIGHUP, &sa, NULL) != 0 ||
+			::sigaction(SIGTERM, &sa, NULL) != 0)
 		{
+			BOX_LOG_SYS_ERROR("Failed to set signal handlers");
 			THROW_EXCEPTION(ServerException, DaemoniseFailed)
 		}
 #endif // !WIN32
@@ -515,7 +517,8 @@
 
 		if(::write(pidFile, pid, pidsize) != pidsize)
 		{
-			BOX_FATAL("can't write pid file");
+			BOX_LOG_SYS_FATAL("Failed to write PID file: " <<
+				pidFileName);
 			THROW_EXCEPTION(ServerException, DaemoniseFailed)
 		}
 		
@@ -544,6 +547,7 @@
 			int devnull = ::open(PLATFORM_DEV_NULL, O_RDWR, 0);
 			if(devnull == -1)
 			{
+				BOX_LOG_SYS_ERROR("Failed to open /dev/null");
 				THROW_EXCEPTION(CommonException, OSFileError);
 			}
 			// Then duplicate them to all three handles
@@ -890,6 +894,8 @@
 		{
 			return 0;
 		}
+		BOX_LOG_SYS_ERROR("Failed to stat configuration file: " <<
+			GetConfigFileName());
 		THROW_EXCEPTION(CommonException, OSFileError)
 	}
 	

Modified: box/trunk/lib/server/Daemon.h
===================================================================
--- box/trunk/lib/server/Daemon.h	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/server/Daemon.h	2008-04-04 22:11:45 UTC (rev 2127)
@@ -92,8 +92,9 @@
 	std::string mAppName;
 };
 
-#define DAEMON_VERIFY_SERVER_KEYS 	{"PidFile", 0, ConfigTest_Exists, 0}, \
-									{"User", 0, ConfigTest_LastEntry, 0}
+#define DAEMON_VERIFY_SERVER_KEYS \
+	ConfigurationVerifyKey("PidFile", ConfigTest_Exists), \
+	ConfigurationVerifyKey("User", ConfigTest_LastEntry)
 
 #endif // DAEMON__H
 

Modified: box/trunk/lib/server/ProtocolUncertainStream.cpp
===================================================================
--- box/trunk/lib/server/ProtocolUncertainStream.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/server/ProtocolUncertainStream.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -41,7 +41,8 @@
 {
 	if(!mFinished)
 	{
-		TRACE0("ProtocolUncertainStream::~ProtocolUncertainStream() destroyed when stream not complete\n");
+		BOX_WARNING("ProtocolUncertainStream destroyed before "
+			"stream finished");
 	}
 }
 

Modified: box/trunk/lib/server/ServerControl.h
===================================================================
--- box/trunk/lib/server/ServerControl.h	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/server/ServerControl.h	2008-04-04 22:11:45 UTC (rev 2127)
@@ -142,8 +142,7 @@
 	bool killed = (::kill(pid, SIGTERM) == 0);
 	if (!killed)
 	{
-		BOX_ERROR("Failed to kill process " << pid << ": " <<
-			strerror(errno));
+		BOX_LOG_SYS_ERROR("Failed to kill process " << pid);
 	}
 	TEST_THAT(killed);
 	return killed;

Modified: box/trunk/lib/server/ServerStream.h
===================================================================
--- box/trunk/lib/server/ServerStream.h	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/server/ServerStream.h	2008-04-04 22:11:45 UTC (rev 2127)
@@ -273,7 +273,7 @@
 							}
 							
 							// Log it
-							BOX_WARNING("Message from child process " << pid << ": " << logMessage);
+							BOX_NOTICE("Message from child process " << pid << ": " << logMessage);
 						}
 						else
 						{
@@ -365,8 +365,8 @@
 };
 
 #define SERVERSTREAM_VERIFY_SERVER_KEYS(DEFAULT_ADDRESSES) \
-											{"ListenAddresses", DEFAULT_ADDRESSES, 0, 0}, \
-											DAEMON_VERIFY_SERVER_KEYS 
+	ConfigurationVerifyKey("ListenAddresses", 0, DEFAULT_ADDRESSES), \
+	DAEMON_VERIFY_SERVER_KEYS 
 
 #include "MemLeakFindOff.h"
 

Modified: box/trunk/lib/server/ServerTLS.h
===================================================================
--- box/trunk/lib/server/ServerTLS.h	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/server/ServerTLS.h	2008-04-04 22:11:45 UTC (rev 2127)
@@ -70,11 +70,10 @@
 };
 
 #define SERVERTLS_VERIFY_SERVER_KEYS(DEFAULT_ADDRESSES) \
-											{"CertificateFile", 0, ConfigTest_Exists, 0}, \
-											{"PrivateKeyFile", 0, ConfigTest_Exists, 0}, \
-											{"TrustedCAsFile", 0, ConfigTest_Exists, 0}, \
-											SERVERSTREAM_VERIFY_SERVER_KEYS(DEFAULT_ADDRESSES)
+	ConfigurationVerifyKey("CertificateFile", ConfigTest_Exists), \
+	ConfigurationVerifyKey("PrivateKeyFile", ConfigTest_Exists), \
+	ConfigurationVerifyKey("TrustedCAsFile", ConfigTest_Exists), \
+	SERVERSTREAM_VERIFY_SERVER_KEYS(DEFAULT_ADDRESSES)
 
-
 #endif // SERVERTLS__H
 

Modified: box/trunk/lib/server/SocketListen.h
===================================================================
--- box/trunk/lib/server/SocketListen.h	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/server/SocketListen.h	2008-04-04 22:11:45 UTC (rev 2127)
@@ -108,45 +108,57 @@
 			if(::close(mSocketHandle) == -1)
 #endif
 			{
-				THROW_EXCEPTION(ServerException, SocketCloseError)
+				BOX_LOG_SYS_ERROR("Failed to close network "
+					"socket");
+				THROW_EXCEPTION(ServerException,
+					SocketCloseError)
 			}
 		}
 		mSocketHandle = -1;
 	}
 
-	// --------------------------------------------------------------------------
+	// ------------------------------------------------------------------
 	//
 	// Function
 	//		Name:    SocketListen::Listen(int, char*, int)
 	//		Purpose: Initialises, starts the socket listening.
 	//		Created: 2003/07/31
 	//
-	// --------------------------------------------------------------------------
+	// ------------------------------------------------------------------
 	void Listen(int Type, const char *Name, int Port = 0)
 	{
-		if(mSocketHandle != -1) {THROW_EXCEPTION(ServerException, SocketAlreadyOpen)}
+		if(mSocketHandle != -1)
+		{
+			THROW_EXCEPTION(ServerException, SocketAlreadyOpen);
+		}
 		
 		// Setup parameters based on type, looking up names if required
 		int sockDomain = 0;
 		SocketAllAddr addr;
 		int addrLen = 0;
-		Socket::NameLookupToSockAddr(addr, sockDomain, Type, Name, Port, addrLen);
+		Socket::NameLookupToSockAddr(addr, sockDomain, Type, Name,
+			Port, addrLen);
 	
 		// Create the socket
-		mSocketHandle = ::socket(sockDomain, SOCK_STREAM, 0 /* let OS choose protocol */);
+		mSocketHandle = ::socket(sockDomain, SOCK_STREAM,
+			0 /* let OS choose protocol */);
 		if(mSocketHandle == -1)
 		{
+			BOX_LOG_SYS_ERROR("Failed to create a network socket");
 			THROW_EXCEPTION(ServerException, SocketOpenError)
 		}
 		
 		// Set an option to allow reuse (useful for -HUP situations!)
 #ifdef WIN32
-		if(::setsockopt(mSocketHandle, SOL_SOCKET, SO_REUSEADDR, "", 0) == -1)
+		if(::setsockopt(mSocketHandle, SOL_SOCKET, SO_REUSEADDR, "",
+			0) == -1)
 #else
 		int option = true;
-		if(::setsockopt(mSocketHandle, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option)) == -1)
+		if(::setsockopt(mSocketHandle, SOL_SOCKET, SO_REUSEADDR,
+			&option, sizeof(option)) == -1)
 #endif
 		{
+			BOX_LOG_SYS_ERROR("Failed to set socket options");
 			THROW_EXCEPTION(ServerException, SocketOpenError)
 		}
 
@@ -161,19 +173,25 @@
 		}	
 	}
 	
-	// --------------------------------------------------------------------------
+	// ------------------------------------------------------------------
 	//
 	// Function
 	//		Name:    SocketListen::Accept(int)
-	//		Purpose: Accepts a connection, returning a pointer to a class of
-	//				 the specified type. May return a null pointer if a signal happens,
-	//				 or there's a timeout. Timeout specified in milliseconds, defaults to infinite time.
+	//		Purpose: Accepts a connection, returning a pointer to
+	//			 a class of the specified type. May return a
+	//			 null pointer if a signal happens, or there's
+	//			 a timeout. Timeout specified in
+	//			 milliseconds, defaults to infinite time.
 	//		Created: 2003/07/31
 	//
-	// --------------------------------------------------------------------------
-	std::auto_ptr<SocketType> Accept(int Timeout = INFTIM, std::string *pLogMsg = 0)
+	// ------------------------------------------------------------------
+	std::auto_ptr<SocketType> Accept(int Timeout = INFTIM,
+		std::string *pLogMsg = 0)
 	{
-		if(mSocketHandle == -1) {THROW_EXCEPTION(ServerException, BadSocketHandle)}
+		if(mSocketHandle == -1)
+		{
+			THROW_EXCEPTION(ServerException, BadSocketHandle);
+		}
 		
 		// Do the accept, using the supplied locking type
 		int sock;
@@ -185,8 +203,10 @@
 			
 			if(!socklock.HaveLock())
 			{
-				// Didn't get the lock for some reason. Wait a while, then
-				// return nothing.
+				// Didn't get the lock for some reason.
+				// Wait a while, then return nothing.
+				BOX_ERROR("Failed to get a lock on incoming "
+					"connection");
 				::sleep(1);
 				return std::auto_ptr<SocketType>();
 			}
@@ -202,12 +222,18 @@
 				// signal?
 				if(errno == EINTR)
 				{
+					BOX_ERROR("Failed to accept "
+						"connection: interrupted by "
+						"signal");
 					// return nothing
 					return std::auto_ptr<SocketType>();
 				}
 				else
 				{
-					THROW_EXCEPTION(ServerException, SocketPollError)
+					BOX_LOG_SYS_ERROR("Failed to poll "
+						"connection");
+					THROW_EXCEPTION(ServerException,
+						SocketPollError)
 				}
 				break;
 			case 0:	// timed out
@@ -220,16 +246,19 @@
 			
 			sock = ::accept(mSocketHandle, &addr, &addrlen);
 		}
-		// Got socket (or error), unlock (implcit in destruction)
+
+		// Got socket (or error), unlock (implicit in destruction)
 		if(sock == -1)
 		{
+			BOX_LOG_SYS_ERROR("Failed to accept connection");
 			THROW_EXCEPTION(ServerException, SocketAcceptError)
 		}
 
 		// Log it
 		if(pLogMsg)
 		{
-			*pLogMsg = Socket::IncomingConnectionLogMessage(&addr, addrlen);
+			*pLogMsg = Socket::IncomingConnectionLogMessage(&addr,
+				addrlen);
 		}
 		else
 		{
@@ -243,27 +272,29 @@
 	// Functions to allow adding to WaitForEvent class, for efficient waiting
 	// on multiple sockets.
 #ifdef HAVE_KQUEUE
-	// --------------------------------------------------------------------------
+	// ------------------------------------------------------------------
 	//
 	// Function
 	//		Name:    SocketListen::FillInKEevent
 	//		Purpose: Fills in a kevent structure for this socket
 	//		Created: 9/3/04
 	//
-	// --------------------------------------------------------------------------
+	// ------------------------------------------------------------------
 	void FillInKEvent(struct kevent &rEvent, int Flags = 0) const
 	{
-		EV_SET(&rEvent, mSocketHandle, EVFILT_READ, 0, 0, 0, (void*)this);
+		EV_SET(&rEvent, mSocketHandle, EVFILT_READ, 0, 0, 0,
+			(void*)this);
 	}
 #else
-	// --------------------------------------------------------------------------
+	// ------------------------------------------------------------------
 	//
 	// Function
 	//		Name:    SocketListen::FillInPoll
-	//		Purpose: Fills in the data necessary for a poll operation
+	//		Purpose: Fills in the data necessary for a poll
+	//			 operation
 	//		Created: 9/3/04
 	//
-	// --------------------------------------------------------------------------
+	// ------------------------------------------------------------------
 	void FillInPoll(int &fd, short &events, int Flags = 0) const
 	{
 		fd = mSocketHandle;

Modified: box/trunk/lib/server/SocketStream.cpp
===================================================================
--- box/trunk/lib/server/SocketStream.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/lib/server/SocketStream.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -150,9 +150,11 @@
 	Socket::NameLookupToSockAddr(addr, sockDomain, Type, Name, Port, addrLen);
 
 	// Create the socket
-	mSocketHandle = ::socket(sockDomain, SOCK_STREAM, 0 /* let OS choose protocol */);
+	mSocketHandle = ::socket(sockDomain, SOCK_STREAM,
+		0 /* let OS choose protocol */);
 	if(mSocketHandle == INVALID_SOCKET_VALUE)
 	{
+		BOX_LOG_SYS_ERROR("Failed to create a network socket");
 		THROW_EXCEPTION(ServerException, SocketOpenError)
 	}
 	
@@ -163,23 +165,16 @@
 #ifdef WIN32
 		DWORD err = WSAGetLastError();
 		::closesocket(mSocketHandle);
-#else
-		int err = errno;
+		BOX_LOG_WIN_ERROR_NUMBER("Failed to connect to socket " 
+			"(type " << Type << ", name " << Name <<
+			", port " << Port << ")", err);
+#else // !WIN32
+		BOX_LOG_SYS_ERROR("Failed to connect to socket (type " <<
+			Type << ", name " << Name << ", port " << Port <<
+			")");
 		::close(mSocketHandle);
-#endif
+#endif // WIN32
 
-#ifdef WIN32
-		BOX_ERROR("Failed to connect to socket (type " << Type <<
-			", name " << Name << ", port " << Port << "): " <<
-				GetErrorMessage(err)
-			);
-#else
-		BOX_ERROR("Failed to connect to socket (type " << Type <<
-			", name " << Name << ", port " << Port << "): " <<
-				strerror(err) << " (" << err << ")"
-			);
-#endif
-
 		mSocketHandle = INVALID_SOCKET_VALUE;
 		THROW_EXCEPTION(ConnectionException, Conn_SocketConnectError)
 	}
@@ -220,7 +215,9 @@
 			else
 			{
 				// Bad!
-				THROW_EXCEPTION(ServerException, SocketPollError)
+				BOX_LOG_SYS_ERROR("Failed to poll socket");
+				THROW_EXCEPTION(ServerException,
+					SocketPollError)
 			}
 			break;
 			
@@ -250,9 +247,12 @@
 		else
 		{
 			// Other error
-			THROW_EXCEPTION(ConnectionException, Conn_SocketReadError)
+			BOX_LOG_SYS_ERROR("Failed to read from socket");
+			THROW_EXCEPTION(ConnectionException,
+				Conn_SocketReadError);
 		}
 	}
+
 	// Closed for reading?
 	if(r == 0)
 	{
@@ -297,7 +297,9 @@
 		{
 			// Error.
 			mWriteClosed = true;	// assume can't write again
-			THROW_EXCEPTION(ConnectionException, Conn_SocketWriteError)
+			BOX_LOG_SYS_ERROR("Failed to write to socket");
+			THROW_EXCEPTION(ConnectionException,
+				Conn_SocketWriteError);
 		}
 		
 		// Knock off bytes sent
@@ -310,7 +312,9 @@
 		// Need to wait until it can send again?
 		if(bytesLeft > 0)
 		{
-			TRACE3("Waiting to send data on socket %d, (%d to send of %d)\n", mSocketHandle, bytesLeft, NBytes);
+			BOX_TRACE("Waiting to send data on socket " << 
+				mSocketHandle << " (" << bytesLeft <<
+				" of " << NBytes << " bytes left)");
 			
 			// Wait for data to send.
 			struct pollfd p;
@@ -323,7 +327,10 @@
 				// Don't exception if it's just a signal
 				if(errno != EINTR)
 				{
-					THROW_EXCEPTION(ServerException, SocketPollError)
+					BOX_LOG_SYS_ERROR("Failed to poll "
+						"socket");
+					THROW_EXCEPTION(ServerException,
+						SocketPollError)
 				}
 			}
 		}
@@ -350,6 +357,7 @@
 	if(::close(mSocketHandle) == -1)
 #endif
 	{
+		BOX_LOG_SYS_ERROR("Failed to close socket");
 		THROW_EXCEPTION(ServerException, SocketCloseError)
 	}
 	mSocketHandle = INVALID_SOCKET_VALUE;
@@ -380,6 +388,7 @@
 	// Shut it down!
 	if(::shutdown(mSocketHandle, how) == -1)
 	{
+		BOX_LOG_SYS_ERROR("Failed to shutdown socket");
 		THROW_EXCEPTION(ConnectionException, Conn_SocketShutdownError)
 	}
 }
@@ -458,12 +467,15 @@
 	struct ucred cred;
 	socklen_t credLen = sizeof(cred);
 
-	if(::getsockopt(mSocketHandle, SOL_SOCKET, SO_PEERCRED, &cred, &credLen) == 0)
+	if(::getsockopt(mSocketHandle, SOL_SOCKET, SO_PEERCRED, &cred,
+		&credLen) == 0)
 	{
 		rUidOut = cred.uid;
 		rGidOut = cred.gid;
 		return true;
 	}
+
+	BOX_LOG_SYS_ERROR("Failed to get peer credentials on socket");
 #endif
 
 	// Not available

Modified: box/trunk/test/backupdiff/testbackupdiff.cpp
===================================================================
--- box/trunk/test/backupdiff/testbackupdiff.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/test/backupdiff/testbackupdiff.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -110,8 +110,10 @@
 	TEST_THAT((uint64_t)box_ntoh64(hdr.mOtherFileID) == (uint64_t)OtherFileID);
 	// number of blocks
 	int64_t nblocks = box_ntoh64(hdr.mNumBlocks);
-	TRACE2("Reading index from '%s', has %lld blocks\n", filename, nblocks);
-	TRACE0("======== ===== ========== ======== ========\n   Index Where  EncSz/Idx     Size  WChcksm\n");
+	BOX_TRACE("Reading index from '" << filename << "', has " <<
+		nblocks << " blocks");
+	BOX_TRACE("======== ===== ========== ======== ========");
+	BOX_TRACE("   Index Where  EncSz/Idx     Size  WChcksm");
 	// Read them all in
 	int64_t nnew = 0, nold = 0;
 	for(int64_t b = 0; b < nblocks; ++b)
@@ -119,35 +121,36 @@
 		file_BlockIndexEntry en;
 		TEST_THAT(enc.ReadFullBuffer(&en, sizeof(en), 0));
 		int64_t s = box_ntoh64(en.mEncodedSize);
+
+		// Decode the rest
+		uint64_t iv = box_ntoh64(hdr.mEntryIVBase);
+		iv += b;
+		sBlowfishDecryptBlockEntry.SetIV(&iv);
+		file_BlockIndexEntryEnc entryEnc;
+		sBlowfishDecryptBlockEntry.TransformBlock(&entryEnc,
+			sizeof(entryEnc), en.mEnEnc, sizeof(en.mEnEnc));
+
+
 		if(s > 0)
 		{
 			nnew++;
-			#ifdef WIN32
-			TRACE2("%8I64d this  s=%8I64d", b, s);
-			#else
-			TRACE2("%8lld this  s=%8lld", b, s);
-			#endif
+			BOX_TRACE(std::setw(8) << b << " this  s=" << 
+				std::setw(8) << s << " " <<
+				std::setw(8) << ntohl(entryEnc.mSize) << " " <<
+				std::setw(8) << std::setfill('0') <<
+				std::hex << ntohl(entryEnc.mWeakChecksum));
 		}
 		else
 		{
 			nold++;
-			#ifdef WIN32
-			TRACE2("%8I64d other i=%8I64d", b, 0 - s);		
-			#else
-			TRACE2("%8lld other i=%8lld", b, 0 - s);		
-			#endif
+			BOX_TRACE(std::setw(8) << b << " other i=" << 
+				std::setw(8) << (0-s) << " " <<
+				std::setw(8) << ntohl(entryEnc.mSize) << " " <<
+				std::setw(8) << std::setfill('0') <<
+				std::hex << ntohl(entryEnc.mWeakChecksum));
 		}
-		// Decode the rest
-		uint64_t iv = box_ntoh64(hdr.mEntryIVBase);
-		iv += b;
-		sBlowfishDecryptBlockEntry.SetIV(&iv);			
-		file_BlockIndexEntryEnc entryEnc;
-		sBlowfishDecryptBlockEntry.TransformBlock(&entryEnc, sizeof(entryEnc),
-				en.mEnEnc, sizeof(en.mEnEnc));
-		TRACE2(" %8d %08x\n", ntohl(entryEnc.mSize), ntohl(entryEnc.mWeakChecksum));
-		
 	}
-	TRACE0("======== ===== ========== ======== ========\n");
+	BOX_TRACE("======== ===== ========== ======== ========");
 	TEST_THAT(new_blocks_expected == nnew);
 	TEST_THAT(old_blocks_expected == nold);
 }

Modified: box/trunk/test/basicserver/testbasicserver.cpp
===================================================================
--- box/trunk/test/basicserver/testbasicserver.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/test/basicserver/testbasicserver.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -185,7 +185,7 @@
 {
 	static ConfigurationVerifyKey verifyserverkeys[] = 
 	{
-		SERVERSTREAM_VERIFY_SERVER_KEYS(0)	// no default addresses
+		SERVERSTREAM_VERIFY_SERVER_KEYS(ConfigurationVerifyKey::NoDefaultValue) // no default listen addresses
 	};
 
 	static ConfigurationVerify verifyserver[] = 
@@ -258,7 +258,7 @@
 {
 	static ConfigurationVerifyKey verifyserverkeys[] = 
 	{
-		SERVERTLS_VERIFY_SERVER_KEYS(0)	// no default listen addresses
+		SERVERTLS_VERIFY_SERVER_KEYS(ConfigurationVerifyKey::NoDefaultValue) // no default listen addresses
 	};
 
 	static ConfigurationVerify verifyserver[] = 

Modified: box/trunk/test/bbackupd/testbbackupd.cpp
===================================================================
--- box/trunk/test/bbackupd/testbbackupd.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/test/bbackupd/testbbackupd.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -514,7 +514,8 @@
 		{
 			// connect and log in
 			SocketStreamTLS conn;
-			conn.Open(context, Socket::TypeINET, "localhost", BOX_PORT_BBSTORED);
+			conn.Open(context, Socket::TypeINET, "localhost",
+				22011);
 			BackupProtocolClient protocol(conn);
 			protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION);
 			std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, BackupProtocolClientLogin::Flags_ReadOnly));
@@ -607,7 +608,7 @@
 std::auto_ptr<BackupProtocolClient> Connect(TLSContext& rContext)
 {
 	sSocket.Open(rContext, Socket::TypeINET, 
-		"localhost", BOX_PORT_BBSTORED);
+		"localhost", 22011);
 	std::auto_ptr<BackupProtocolClient> connection;
 	connection.reset(new BackupProtocolClient(sSocket));
 	connection->Handshake();
@@ -2559,13 +2560,6 @@
 				true /* print progress dots */) 
 				== Restore_TargetExists);
 			
-			// Make sure you can't restore to a nonexistant path
-			printf("Try to restore to a path that doesn't exist\n");
-			TEST_THAT(BackupClientRestore(*client, restoredirid, 
-				"testfiles/no-such-path/subdir", 
-				true /* print progress dots */) 
-				== Restore_TargetPathNotFound);
-			
 			// Find ID of the deleted directory
 			deldirid = GetDirID(*client, "x1", restoredirid);
 			TEST_THAT(deldirid != 0);
@@ -2578,6 +2572,15 @@
 				true /* deleted files */) 
 				== Restore_Complete);
 
+			// Make sure you can't restore to a nonexistant path
+			printf("\n\n==== Try to restore to a path "
+				"that doesn't exist\n");
+			fflush(stdout);
+			TEST_THAT(BackupClientRestore(*client, restoredirid, 
+				"testfiles/no-such-path/subdir", 
+				true /* print progress dots */) 
+				== Restore_TargetPathNotFound);
+
 			// Log out
 			client->QueryFinished();
 			sSocket.Close();

Modified: box/trunk/test/bbackupd/testfiles/bbackupd-temploc.conf
===================================================================
--- box/trunk/test/bbackupd/testfiles/bbackupd-temploc.conf	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/test/bbackupd/testfiles/bbackupd-temploc.conf	2008-04-04 22:11:45 UTC (rev 2127)
@@ -8,6 +8,7 @@
 DataDirectory = testfiles/bbackupd-data
 
 StoreHostname = localhost
+StorePort = 22011
 AccountNumber = 0x01234567
 
 UpdateStoreInterval = 3

Modified: box/trunk/test/bbackupd/testfiles/bbackupd.conf.in
===================================================================
--- box/trunk/test/bbackupd/testfiles/bbackupd.conf.in	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/test/bbackupd/testfiles/bbackupd.conf.in	2008-04-04 22:11:45 UTC (rev 2127)
@@ -8,6 +8,7 @@
 DataDirectory = testfiles/bbackupd-data
 
 StoreHostname = localhost
+StorePort = 22011
 AccountNumber = 0x01234567
 
 UpdateStoreInterval = 3

Modified: box/trunk/test/bbackupd/testfiles/bbstored.conf
===================================================================
--- box/trunk/test/bbackupd/testfiles/bbstored.conf	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/test/bbackupd/testfiles/bbstored.conf	2008-04-04 22:11:45 UTC (rev 2127)
@@ -9,7 +9,7 @@
 Server
 {
 	PidFile = testfiles/bbstored.pid
-	ListenAddresses = inet:localhost
+	ListenAddresses = inet:localhost:22011
 	CertificateFile = testfiles/serverCerts.pem
 	PrivateKeyFile = testfiles/serverPrivKey.pem
 	TrustedCAsFile = testfiles/serverTrustedCAs.pem

Modified: box/trunk/test/common/testcommon.cpp
===================================================================
--- box/trunk/test/common/testcommon.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/test/common/testcommon.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -57,15 +57,15 @@
 
 ConfigurationVerifyKey verifykeys1_1_1[] =
 {
-	{"bing", 0, ConfigTest_Exists, 0},
-	{"carrots", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
-	{"terrible", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}
+	ConfigurationVerifyKey("bing", ConfigTest_Exists),
+	ConfigurationVerifyKey("carrots", ConfigTest_Exists | ConfigTest_IsInt),
+	ConfigurationVerifyKey("terrible", ConfigTest_Exists | ConfigTest_LastEntry)
 };
 
 ConfigurationVerifyKey verifykeys1_1_2[] =
 {
-	{"fish", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
-	{"string", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}
+	ConfigurationVerifyKey("fish", ConfigTest_Exists | ConfigTest_IsInt),
+	ConfigurationVerifyKey("string", ConfigTest_Exists | ConfigTest_LastEntry)
 };
 
 
@@ -89,15 +89,15 @@
 
 ConfigurationVerifyKey verifykeys1_1[] =
 {
-	{"value", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
-	{"string1", 0, ConfigTest_Exists, 0},
-	{"string2", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}
+	ConfigurationVerifyKey("value", ConfigTest_Exists | ConfigTest_IsInt),
+	ConfigurationVerifyKey("string1", ConfigTest_Exists),
+	ConfigurationVerifyKey("string2", ConfigTest_Exists | ConfigTest_LastEntry)
 };
 
 ConfigurationVerifyKey verifykeys1_2[] = 
 {
-	{"carrots", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
-	{"string", 0, ConfigTest_Exists | ConfigTest_LastEntry, 0}
+	ConfigurationVerifyKey("carrots", ConfigTest_Exists | ConfigTest_IsInt),
+	ConfigurationVerifyKey("string", ConfigTest_Exists | ConfigTest_LastEntry)
 };
 
 ConfigurationVerify verifysub1[] = 
@@ -120,14 +120,15 @@
 
 ConfigurationVerifyKey verifykeys1[] =
 {
-		{"notExpected", 0, 0, 0},
-		{"HasDefaultValue", "Lovely default value", 0, 0},
-		{"MultiValue", 0, ConfigTest_MultiValueAllowed, 0},
-		{"BoolTrue1", 0, ConfigTest_IsBool, 0},
-		{"BoolTrue2", 0, ConfigTest_IsBool, 0},
-		{"BoolFalse1", 0, ConfigTest_IsBool, 0},
-		{"BoolFalse2", 0, ConfigTest_IsBool, 0},
-		{"TOPlevel", 0, ConfigTest_LastEntry | ConfigTest_Exists, 0}
+		ConfigurationVerifyKey("notExpected", 0),
+		ConfigurationVerifyKey("HasDefaultValue", 0, "Lovely default value"),
+		ConfigurationVerifyKey("MultiValue", ConfigTest_MultiValueAllowed),
+		ConfigurationVerifyKey("BoolTrue1", ConfigTest_IsBool),
+		ConfigurationVerifyKey("BoolTrue2", ConfigTest_IsBool),
+		ConfigurationVerifyKey("BoolFalse1", ConfigTest_IsBool),
+		ConfigurationVerifyKey("BoolFalse2", ConfigTest_IsBool),
+		ConfigurationVerifyKey("TOPlevel", 
+			ConfigTest_LastEntry | ConfigTest_Exists)
 };
 
 ConfigurationVerify verify =

Modified: box/trunk/test/compress/testcompress.cpp
===================================================================
--- box/trunk/test/compress/testcompress.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/test/compress/testcompress.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -90,7 +90,8 @@
 		
 		// Check sizes
 		TEST_THAT(poutput->GetSize() < source.GetSize());
-		TRACE2("compressed size = %d, source size = %d\n", poutput->GetSize(), source.GetSize());
+		BOX_TRACE("compressed size = " << poutput->GetSize() <<
+			", source size = " << source.GetSize());
 		
 		// Decompress the data
 		{

Modified: box/trunk/test/raidfile/testraidfile.cpp
===================================================================
--- box/trunk/test/raidfile/testraidfile.cpp	2008-04-04 21:59:40 UTC (rev 2126)
+++ box/trunk/test/raidfile/testraidfile.cpp	2008-04-04 22:11:45 UTC (rev 2127)
@@ -622,7 +622,8 @@
 		TEST_THAT(n2 != n3);
 		TEST_THAT(n1 != n3);
 		TEST_THAT(n1 == n4);		// ie wraps around
-		TRACE3("Gen paths= '%s','%s',%s'\n", n1.c_str(), n2.c_str(), n3.c_str());
+		BOX_TRACE("Gen paths = '" << n1 << "', '" << n2 << 
+			"', '" << n3);
 	}
 
 	// Create a RaidFile




More information about the Boxbackup-commit mailing list