blob: 7cbf4828c47c2bf1adb9c9a23083e004e45c0c2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// 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* gpDaemonService = NULL;
extern HANDLE gStopServiceEvent;
unsigned int WINAPI RunService(LPVOID lpParameter)
{
DWORD retVal = gpDaemonService->WinService((const char*) lpParameter);
SetEvent(gStopServiceEvent);
return retVal;
}
void TerminateService(void)
{
gpDaemonService->SetTerminateWanted();
}
DWORD Win32BackupService::WinService(const char* pConfigFileName)
{
char exepath[MAX_PATH];
GetModuleFileName(NULL, exepath, sizeof(exepath));
std::string configfile;
if (pConfigFileName != NULL)
{
configfile = pConfigFileName;
}
else
{
// make the default config file name,
// based on the program path
configfile = exepath;
configfile = configfile.substr(0,
configfile.rfind(DIRECTORY_SEPARATOR_ASCHAR));
configfile += DIRECTORY_SEPARATOR "bbackupd.conf";
}
const char *argv[] = {exepath, "-c", configfile.c_str()};
int argc = sizeof(argv) / sizeof(*argv);
DWORD ret;
MAINHELPER_START
ret = this->Main(BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv);
MAINHELPER_END
return ret;
}
#endif // WIN32
|