diff options
Diffstat (limited to 'bin/bbackupd/bbackupd.cpp')
-rw-r--r-- | bin/bbackupd/bbackupd.cpp | 78 |
1 files changed, 17 insertions, 61 deletions
diff --git a/bin/bbackupd/bbackupd.cpp b/bin/bbackupd/bbackupd.cpp index 1ccfc7f8..c8320454 100644 --- a/bin/bbackupd/bbackupd.cpp +++ b/bin/bbackupd/bbackupd.cpp @@ -1,4 +1,4 @@ -// distribution boxbackup-0.10 (svn version: 494) +// distribution boxbackup-0.11rc1 (svn version: 2023_2024) // // Copyright (c) 2003 - 2006 // Ben Summers and contributors. All rights reserved. @@ -50,6 +50,7 @@ #include "MainHelper.h" #include "BoxPortsAndFiles.h" #include "BackupStoreException.h" +#include "Logging.h" #include "MemLeakFindOn.h" @@ -57,82 +58,37 @@ #include "Win32ServiceFunctions.h" #include "Win32BackupService.h" - extern Win32BackupService gDaemonService; + extern Win32BackupService* gpDaemonService; #endif int main(int argc, const char *argv[]) { - MAINHELPER_START - -#ifdef WIN32 - - ::openlog("Box Backup (bbackupd)", 0, 0); + int ExitCode = 0; - if(argc == 2 && - (::strcmp(argv[1], "--help") == 0 || - ::strcmp(argv[1], "-h") == 0)) - { - printf("-h help, -i install service, -r remove service,\n" - "-c <config file> start daemon now"); - return 2; - } - if(argc == 2 && ::strcmp(argv[1], "-r") == 0) - { - RemoveService(); - return 0; - } - if(argc == 2 && ::strcmp(argv[1], "-i") == 0) - { - InstallService(); - return 0; - } + MAINHELPER_START - bool runAsWin32Service = false; - if (argc == 2 && ::strcmp(argv[1], "--service") == 0) - { - runAsWin32Service = true; - } + Logging::SetProgramName("Box Backup (bbackupd)"); + Logging::ToConsole(true); + Logging::ToSyslog (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) - } +#ifdef WIN32 EnableBackupRights(); - int ExitCode = 0; - - if (runAsWin32Service) - { - syslog(LOG_INFO,"Starting Box Backup Service"); - OurService(); - } - else - { - ExitCode = gDaemonService.Main( - BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv); - } - - // Clean up our sockets - WSACleanup(); - - ::closelog(); - - return ExitCode; + gpDaemonService = new Win32BackupService(); + ExitCode = gpDaemonService->Daemon::Main( + BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE, + argc, argv); + delete gpDaemonService; #else // !WIN32 BackupDaemon daemon; - return daemon.Main(BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv); + ExitCode = daemon.Main(BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv); #endif // WIN32 MAINHELPER_END + + return ExitCode; } |