summaryrefslogtreecommitdiff
path: root/bin/bbackupd/bbackupd.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2006-07-27 23:18:35 +0000
committerChris Wilson <chris+github@qwirx.com>2006-07-27 23:18:35 +0000
commitc7662795f519d2b6797e4b1ac7fa4a22afa26310 (patch)
treeb1737dfa78d8e7bfb2d5a7e9831bab91869ade97 /bin/bbackupd/bbackupd.cpp
parenta85b710c46ec79e968da349304f30945cb9b7bc1 (diff)
* merge
- This is my current patch queue. I think that all of these are safe to apply. This is just under half of the pending changes in chris/general (the easy half).
Diffstat (limited to 'bin/bbackupd/bbackupd.cpp')
-rw-r--r--bin/bbackupd/bbackupd.cpp56
1 files changed, 31 insertions, 25 deletions
diff --git a/bin/bbackupd/bbackupd.cpp b/bin/bbackupd/bbackupd.cpp
index 089b2d09..e00d3628 100644
--- a/bin/bbackupd/bbackupd.cpp
+++ b/bin/bbackupd/bbackupd.cpp
@@ -19,7 +19,7 @@
#include "Win32ServiceFunctions.h"
#include "Win32BackupService.h"
- extern Win32BackupService gDaemonService;
+ extern Win32BackupService* gpDaemonService;
#endif
int main(int argc, const char *argv[])
@@ -28,7 +28,7 @@ int main(int argc, const char *argv[])
#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,32 +40,25 @@ int main(int argc, const char *argv[])
}
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 && ::strcmp(argv[1], "--service") == 0)
{
runAsWin32Service = true;
}
-
- // Under win32 we must initialise the Winsock library
- // before using sockets
-
- WSADATA info;
- if (WSAStartup(0x0101, &info) == SOCKET_ERROR)
- {
- // box backup will not run without sockets
- ::syslog(LOG_ERR, "Failed to initialise Windows Sockets");
- THROW_EXCEPTION(BackupStoreException, Internal)
- }
+ gpDaemonService = new Win32BackupService();
EnableBackupRights();
@@ -73,20 +66,33 @@ int main(int argc, const char *argv[])
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
{
- ExitCode = gDaemonService.Main(
+ ExitCode = gpDaemonService->Main(
BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv);
}
- // Clean up our sockets
- WSACleanup();
-
::closelog();
+ delete gpDaemonService;
+
return ExitCode;
#else // !WIN32