summaryrefslogtreecommitdiff
path: root/bin/bbackupd/Win32BackupService.cpp
blob: aa3bf55cc393b44badc568903c72267e196f797f (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
// 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