[Box Backup-dev] COMMIT r504 - box/chris/general/bin/bbackupctl

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Sat Feb 25 14:25:52 GMT 2006


Author: chris
Date: 2006-02-25 14:25:50 +0000 (Sat, 25 Feb 2006)
New Revision: 504

Modified:
   box/chris/general/bin/bbackupctl/bbackupctl.cpp
Log:
* bin/bbackupctl/bbackupctl.cpp
- Changed dashes in command names to underscores, to work around bugs with
  the current getopt emulation under win32/MSVC


Modified: box/chris/general/bin/bbackupctl/bbackupctl.cpp
===================================================================
--- box/chris/general/bin/bbackupctl/bbackupctl.cpp	2006-02-24 01:55:27 UTC (rev 503)
+++ box/chris/general/bin/bbackupctl/bbackupctl.cpp	2006-02-25 14:25:50 UTC (rev 504)
@@ -33,17 +33,17 @@
 	printf("Usage: bbackupctl [-q] [-c config_file] <command>\n"
 	"Commands are:\n"
 	"  sync -- start a syncronisation run now\n"
-	"  force-sync -- force the start of a syncronisation run, "
+	"  force_sync -- force the start of a syncronisation run, "
 	"even if SyncAllowScript says no\n"
 	"  reload -- reload daemon configuration\n"
 	"  terminate -- terminate daemon now\n"
-	"  wait-for-sync -- wait until the next sync starts, then exit\n"
-	"  sync-and-wait -- start sync, wait until it finishes, then exit\n"
+	"  wait_for_sync -- wait until the next sync starts, then exit\n"
+	"  sync_and_wait -- start sync, wait until it finishes, then exit\n"
 	);
 	exit(1);
 }
 
-int main(int argc, const char *argv[])
+int main(int argc, char *argv[])
 {
 	int returnCode = 0;
 
@@ -64,7 +64,7 @@
 	
 	// See if there's another entry on the command line
 	int c;
-	while((c = getopt(argc, (char * const *)argv, "qc:l:")) != -1)
+	while((c = getopt(argc, argv, "qc:l:")) != -1)
 	{
 		switch(c)
 		{
@@ -189,12 +189,13 @@
 	// Print summary?
 	if(!quiet)
 	{
-		printf("Daemon configuration summary:\n"	\
-			   "  AutomaticBackup = %s\n"			\
-			   "  UpdateStoreInterval = %d seconds\n"	\
-			   "  MinimumFileAge = %d seconds\n"	\
-			   "  MaxUploadWait = %d seconds\n",
-			   autoBackup?"true":"false", updateStoreInterval, minimumFileAge, maxUploadWait);
+		printf("Daemon configuration summary:\n"
+			"  AutomaticBackup = %s\n"
+			"  UpdateStoreInterval = %d seconds\n"
+			"  MinimumFileAge = %d seconds\n"
+			"  MaxUploadWait = %d seconds\n",
+			autoBackup?"true":"false", updateStoreInterval, 
+			minimumFileAge, maxUploadWait);
 	}
 
 	std::string stateLine;
@@ -220,19 +221,30 @@
 	bool areWaitingForSync = false;
 	bool areWaitingForSyncEnd = false;
 
-	if(::strcmp(argv[0], "wait-for-sync") == 0)
+	if(::strcmp(argv[0], "force_sync") == 0)
 	{
-		// Check that it's not in non-automatic mode, because then it'll never start
+		argv[0] = "force-sync";
+	}
+
+	if(::strcmp(argv[0], "wait-for-sync") == 0 ||
+		::strcmp(argv[0], "wait_for_sync") == 0)
+	{
+		// Check that it's not in non-automatic mode, 
+		// because then it'll never start
+
 		if(!autoBackup)
 		{
-			printf("ERROR: Daemon is not in automatic mode -- sync will never start!\n");
+			printf("ERROR: Daemon is not in automatic mode -- "
+				"sync will never start!\n");
 			return 1;
 		}
 	
-		// Yes... set the flag so we know what we're waiting for a sync to start
+		// Yes... set the flag so we know what we're 
+		// waiting for a sync to start
 		areWaitingForSync = true;
 	}
-	else if (::strcmp(argv[0], "sync-and-wait") == 0)
+	else if (::strcmp(argv[0], "sync-and-wait") == 0 ||
+		::strcmp(argv[0], "sync_and_wait") == 0)
 	{
 		// send a sync command
 		std::string cmd("force-sync\n");




More information about the Boxbackup-dev mailing list