diff options
author | Chris Wilson <chris+github@qwirx.com> | 2007-07-26 22:11:03 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2007-07-26 22:11:03 +0000 |
commit | 498e58eb188d98c6ec78e57cdc5f0c211f1f4dcf (patch) | |
tree | 4455a5542918955c8f5ade2915d4ae9a6b341093 /bin/bbackupquery/bbackupquery.cpp | |
parent | 88edb51fc08aa8dfe1fed4c614343d1f2405dac9 (diff) |
Make Configuration take a std::string filename instead of a char array,
in C++ style.
Add a function to get default config file paths at runtime, dependent on
the location of the executable being run.
Pass the config file name directly to Daemon::Main, instead of faking argv.
No default raid file path at compile time on Windows, depends on
executable location when run.
Determine RaidFile path at runtime if not supplied in config file
on Windows.
Don't define default locations for config files at compile time on Windows,
provide macros to determine them at runtime instead.
Make FileHandleGuard take a std::string instead of a char array, C++ style.
Determine config file location at runtime instead of hard-coding on
Windows. Thanks to Paul MacKenzie, Per Thomsen, Pete Jalajas, Stuart
Sanders, Dave Bamford and Gary for pushing me to do this. (fixes #12)
Determine config file path at runtime. Call Daemon::Main with config file
name instead of building fake argv.
(refs #3, merges [1684] [1685] [1686] [1687] [1688] [1689] [1690]
[1691] [1692])
Diffstat (limited to 'bin/bbackupquery/bbackupquery.cpp')
-rw-r--r-- | bin/bbackupquery/bbackupquery.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/bin/bbackupquery/bbackupquery.cpp b/bin/bbackupquery/bbackupquery.cpp index d02c3922..9cc3eb1a 100644 --- a/bin/bbackupquery/bbackupquery.cpp +++ b/bin/bbackupquery/bbackupquery.cpp @@ -66,7 +66,8 @@ int main(int argc, const char *argv[]) { int returnCode = 0; - MAINHELPER_SETUP_MEMORY_LEAK_EXIT_REPORT("bbackupquery.memleaks", "bbackupquery") + MAINHELPER_SETUP_MEMORY_LEAK_EXIT_REPORT("bbackupquery.memleaks", + "bbackupquery") MAINHELPER_START #ifdef WIN32 @@ -77,7 +78,7 @@ int main(int argc, const char *argv[]) if (WSAStartup(0x0101, &info) == SOCKET_ERROR) { - // throw error? perhaps give it its own id in the furture + // throw error? perhaps give it its own id in the future THROW_EXCEPTION(BackupStoreException, Internal) } #endif @@ -90,7 +91,13 @@ int main(int argc, const char *argv[]) FILE *logFile = 0; // Filename for configuration file? - const char *configFilename = BOX_FILE_BBACKUPD_DEFAULT_CONFIG; + std::string configFilename; + + #ifdef WIN32 + configFilename = BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE; + #else + configFilename = BOX_FILE_BBACKUPD_DEFAULT_CONFIG; + #endif // Flags bool quiet = false; @@ -215,9 +222,14 @@ int main(int argc, const char *argv[]) #endif // WIN32 // Read in the configuration file - if(!quiet) printf("Using configuration file %s\n", configFilename); + if(!quiet) printf("Using configuration file %s\n", + configFilename.c_str()); + std::string errs; - std::auto_ptr<Configuration> config(Configuration::LoadAndVerify(configFilename, &BackupDaemonConfigVerify, errs)); + std::auto_ptr<Configuration> config( + Configuration::LoadAndVerify + (configFilename, &BackupDaemonConfigVerify, errs)); + if(config.get() == 0 || !errs.empty()) { printf("Invalid configuration file:\n%s", errs.c_str()); |