summaryrefslogtreecommitdiff
path: root/bin/bbackupd/Win32BackupService.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bin/bbackupd/Win32BackupService.cpp')
-rw-r--r--bin/bbackupd/Win32BackupService.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/bin/bbackupd/Win32BackupService.cpp b/bin/bbackupd/Win32BackupService.cpp
new file mode 100644
index 00000000..aa3bf55c
--- /dev/null
+++ b/bin/bbackupd/Win32BackupService.cpp
@@ -0,0 +1,51 @@
+// Win32 service functions for Box Backup, by Nick Knight
+
+#ifdef WIN32
+
+#include "Box.h"
+#include "BackupDaemon.h"
+#include "MainHelper.h"
+#include "BoxPortsAndFiles.h"
+#include "BackupStoreException.h"
+
+#include "MemLeakFindOn.h"
+
+#include "Win32BackupService.h"
+
+Win32BackupService gDaemonService;
+extern HANDLE gStopServiceEvent;
+
+unsigned int WINAPI RunService(LPVOID lpParameter)
+{
+ DWORD retVal = gDaemonService.WinService();
+ SetEvent( gStopServiceEvent );
+ return retVal;
+}
+
+void TerminateService(void)
+{
+ gDaemonService.SetTerminateWanted();
+}
+
+DWORD Win32BackupService::WinService(void)
+{
+ int argc = 2;
+ //first off get the path name for the default
+ char buf[MAX_PATH];
+
+ GetModuleFileName(NULL, buf, sizeof(buf));
+ std::string buffer(buf);
+ std::string conf( "-c");
+ std::string cfile(buffer.substr(0,(buffer.find("bbackupd.exe")))
+ + "bbackupd.conf");
+
+ const char *argv[] = {conf.c_str(), cfile.c_str()};
+
+ MAINHELPER_START
+
+ return this->Main(BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv);
+
+ MAINHELPER_END
+}
+
+#endif // WIN32