summaryrefslogtreecommitdiff
path: root/bin/bbackupd/bbackupd.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2006-08-09 12:51:32 +0000
committerChris Wilson <chris+github@qwirx.com>2006-08-09 12:51:32 +0000
commit89bfa52d830f1a623214eb63242a1be99fe710ab (patch)
tree71a1b01142bb81696126a9dd0819cb44387207ec /bin/bbackupd/bbackupd.cpp
parente1c40b699a0ccd9710de27aedad36d706b2ac88a (diff)
* bbackupd.cpp
* Win32ServiceFunctions.h - Revert to trunk
Diffstat (limited to 'bin/bbackupd/bbackupd.cpp')
-rw-r--r--bin/bbackupd/bbackupd.cpp56
1 files changed, 25 insertions, 31 deletions
diff --git a/bin/bbackupd/bbackupd.cpp b/bin/bbackupd/bbackupd.cpp
index e00d3628..089b2d09 100644
--- a/bin/bbackupd/bbackupd.cpp
+++ b/bin/bbackupd/bbackupd.cpp
@@ -19,7 +19,7 @@
#include "Win32ServiceFunctions.h"
#include "Win32BackupService.h"
- extern Win32BackupService* gpDaemonService;
+ extern Win32BackupService gDaemonService;
#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)", LOG_PID, LOG_LOCAL6);
+ ::openlog("Box Backup (bbackupd)", 0, 0);
if(argc == 2 &&
(::strcmp(argv[1], "--help") == 0 ||
@@ -40,25 +40,32 @@ int main(int argc, const char *argv[])
}
if(argc == 2 && ::strcmp(argv[1], "-r") == 0)
{
- return RemoveService();
+ RemoveService();
+ return 0;
}
- if((argc == 2 || argc == 3) && ::strcmp(argv[1], "-i") == 0)
+ if(argc == 2 && ::strcmp(argv[1], "-i") == 0)
{
- const char* config = NULL;
- if (argc == 3)
- {
- config = argv[2];
- }
- return InstallService(config);
+ InstallService();
+ return 0;
}
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;
- gpDaemonService = new Win32BackupService();
+ 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)
+ }
EnableBackupRights();
@@ -66,32 +73,19 @@ int main(int argc, const char *argv[])
if (runAsWin32Service)
{
- 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");
+ syslog(LOG_INFO,"Starting Box Backup Service");
+ OurService();
}
else
{
- ExitCode = gpDaemonService->Main(
+ ExitCode = gDaemonService.Main(
BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv);
}
- ::closelog();
+ // Clean up our sockets
+ WSACleanup();
- delete gpDaemonService;
+ ::closelog();
return ExitCode;