summaryrefslogtreecommitdiff
path: root/bin/bbackupd/Win32BackupService.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2006-07-27 23:18:35 +0000
committerChris Wilson <chris+github@qwirx.com>2006-07-27 23:18:35 +0000
commitc7662795f519d2b6797e4b1ac7fa4a22afa26310 (patch)
treeb1737dfa78d8e7bfb2d5a7e9831bab91869ade97 /bin/bbackupd/Win32BackupService.cpp
parenta85b710c46ec79e968da349304f30945cb9b7bc1 (diff)
* merge
- This is my current patch queue. I think that all of these are safe to apply. This is just under half of the pending changes in chris/general (the easy half).
Diffstat (limited to 'bin/bbackupd/Win32BackupService.cpp')
-rw-r--r--bin/bbackupd/Win32BackupService.cpp47
1 files changed, 29 insertions, 18 deletions
diff --git a/bin/bbackupd/Win32BackupService.cpp b/bin/bbackupd/Win32BackupService.cpp
index aa3bf55c..7cbf4828 100644
--- a/bin/bbackupd/Win32BackupService.cpp
+++ b/bin/bbackupd/Win32BackupService.cpp
@@ -12,40 +12,51 @@
#include "Win32BackupService.h"
-Win32BackupService gDaemonService;
+Win32BackupService* gpDaemonService = NULL;
extern HANDLE gStopServiceEvent;
unsigned int WINAPI RunService(LPVOID lpParameter)
{
- DWORD retVal = gDaemonService.WinService();
- SetEvent( gStopServiceEvent );
+ DWORD retVal = gpDaemonService->WinService((const char*) lpParameter);
+ SetEvent(gStopServiceEvent);
return retVal;
}
void TerminateService(void)
{
- gDaemonService.SetTerminateWanted();
+ gpDaemonService->SetTerminateWanted();
}
-DWORD Win32BackupService::WinService(void)
+DWORD Win32BackupService::WinService(const char* pConfigFileName)
{
- 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");
+ char exepath[MAX_PATH];
+ GetModuleFileName(NULL, exepath, sizeof(exepath));
- const char *argv[] = {conf.c_str(), cfile.c_str()};
+ 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
-
- return this->Main(BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv);
-
+ ret = this->Main(BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv);
MAINHELPER_END
+
+ return ret;
}
#endif // WIN32