[Box Backup-dev] COMMIT r523 - box/chris/general/bin/bbackupd

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Sun, 26 Feb 2006 14:23:11 +0000 (GMT)


Author: chris
Date: 2006-02-26 14:23:11 +0000 (Sun, 26 Feb 2006)
New Revision: 523

Modified:
   box/chris/general/bin/bbackupd/bbackupd.cpp
Log:
* bbackupd.cpp
- openlog() on Win32 with the same options as Daemon.cpp, not that it matters
- Return exit codes from InstallService and RemoveService
- Pass configuration file name, if given on command line, to InstallService
  and OurService (allows configuration file to be specified for service)
- Log service shutdown as well as startup


Modified: box/chris/general/bin/bbackupd/bbackupd.cpp
===================================================================
--- box/chris/general/bin/bbackupd/bbackupd.cpp	2006-02-26 14:20:45 UTC (rev 522)
+++ box/chris/general/bin/bbackupd/bbackupd.cpp	2006-02-26 14:23:11 UTC (rev 523)
@@ -28,7 +28,7 @@
 
 #ifdef WIN32
 
-	::openlog("Box Backup (bbackupd)", 0, 0);
+	::openlog("Box Backup (bbackupd)", LOG_PID, LOG_LOCAL6);
 
 	if(argc == 2 &&
 		(::strcmp(argv[1], "--help") == 0 ||
@@ -40,17 +40,20 @@
 	}
 	if(argc == 2 && ::strcmp(argv[1], "-r") == 0)
 	{
-		RemoveService();
-		return 0;
+		return RemoveService();
 	}
-	if(argc == 2 && ::strcmp(argv[1], "-i") == 0)
+	if((argc == 2 || argc == 3) && ::strcmp(argv[1], "-i") == 0)
 	{
-		InstallService();
-		return 0;
+		const char* config = NULL;
+		if (argc == 3)
+		{
+			config = argv[2];
+		}
+		return InstallService(config);
 	}
 
 	bool runAsWin32Service = false;
-	if (argc == 2 && ::strcmp(argv[1], "--service") == 0)
+	if ((argc == 2 || argc == 3) && ::strcmp(argv[1], "--service") == 0)
 	{
 		runAsWin32Service = true;
 	}
@@ -75,8 +78,22 @@
 
 	if (runAsWin32Service)
 	{
-		syslog(LOG_INFO,"Starting Box Backup Service");
-		OurService();
+		syslog(LOG_INFO, "Box Backup service starting");
+
+		char* config = NULL;
+		if (argc == 3)
+		{
+			config = strdup(argv[2]);
+		}
+
+		OurService(config);
+
+		if (config)
+		{
+			free(config);
+		}
+
+		syslog(LOG_INFO, "Box Backup service shut down");
 	}
 	else
 	{