diff options
author | Chris Wilson <chris+github@qwirx.com> | 2006-08-09 17:51:00 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2006-08-09 17:51:00 +0000 |
commit | 753960ecd7f89708431fee9565d2d6fd3235e710 (patch) | |
tree | 47e84245ebb48891d73bb7fe4c160f821ce240ab /bin | |
parent | 432985db4c66b30874af49af456eba5189aa25db (diff) |
* bin/bbackupd/Win32BackupService.cpp
- Made RunService() pass the configuration file name to
Win32BackupService::WinService()
- Made WinService() calculate the default configuration file name
more sanely and safely
- Made WinService() not return before MAINHELPER_END
Diffstat (limited to 'bin')
-rw-r--r-- | bin/bbackupd/Win32BackupService.cpp | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/bin/bbackupd/Win32BackupService.cpp b/bin/bbackupd/Win32BackupService.cpp index aa3bf55c..2f9c1583 100644 --- a/bin/bbackupd/Win32BackupService.cpp +++ b/bin/bbackupd/Win32BackupService.cpp @@ -17,8 +17,8 @@ extern HANDLE gStopServiceEvent; unsigned int WINAPI RunService(LPVOID lpParameter) { - DWORD retVal = gDaemonService.WinService(); - SetEvent( gStopServiceEvent ); + DWORD retVal = gDaemonService.WinService((const char*) lpParameter); + SetEvent(gStopServiceEvent); return retVal; } @@ -27,25 +27,36 @@ void TerminateService(void) gDaemonService.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 |