Changeset 1777
- Timestamp:
- 26/07/2007 23:11:03 (5 years ago)
- Location:
- box/chris/merge
- Files:
-
- 13 edited
-
bin/bbackupctl/bbackupctl.cpp (modified) (2 diffs)
-
bin/bbackupd/Win32BackupService.cpp (modified) (1 diff)
-
bin/bbackupd/bbackupd.cpp (modified) (1 diff)
-
bin/bbackupquery/bbackupquery.cpp (modified) (4 diffs)
-
bin/bbstoreaccounts/bbstoreaccounts.cpp (modified) (2 diffs)
-
bin/bbstored/BackupStoreDaemon.cpp (modified) (1 diff)
-
bin/bbstored/bbstored.cpp (modified) (1 diff)
-
lib/backupstore/BackupStoreConfigVerify.cpp (modified) (1 diff)
-
lib/common/BoxPortsAndFiles.h (modified) (1 diff)
-
lib/common/Guards.h (modified) (1 diff)
-
lib/win32/emu.cpp (modified) (5 diffs)
-
lib/win32/emu.h (modified) (1 diff)
-
test/bbackupd/testbbackupd.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
box/chris/merge/bin/bbackupctl/bbackupctl.cpp
r1349 r1777 67 67 68 68 // Filename for configuration file? 69 const char *configFilename = BOX_FILE_BBACKUPD_DEFAULT_CONFIG; 69 std::string configFilename; 70 71 #ifdef WIN32 72 configFilename = BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE; 73 #else 74 configFilename = BOX_FILE_BBACKUPD_DEFAULT_CONFIG; 75 #endif 70 76 71 77 // Quiet? … … 104 110 105 111 // Read in the configuration file 106 if(!quiet) printf("Using configuration file %s\n", configFilename); 112 if(!quiet) printf("Using configuration file %s\n", 113 configFilename.c_str()); 114 107 115 std::string errs; 108 std::auto_ptr<Configuration> config(Configuration::LoadAndVerify(configFilename, &BackupDaemonConfigVerify, errs)); 116 std::auto_ptr<Configuration> config( 117 Configuration::LoadAndVerify 118 (configFilename, &BackupDaemonConfigVerify, errs)); 119 109 120 if(config.get() == 0 || !errs.empty()) 110 121 { -
box/chris/merge/bin/bbackupd/Win32BackupService.cpp
r1031 r1777 30 30 DWORD Win32BackupService::WinService(const char* pConfigFileName) 31 31 { 32 char exepath[MAX_PATH]; 33 GetModuleFileName(NULL, exepath, sizeof(exepath)); 32 DWORD ret; 34 33 35 std::string configfile; 36 34 // keep MAINHELPER_START happy 35 int argc = 0; 36 char* argv[] = {NULL}; 37 38 MAINHELPER_START 39 37 40 if (pConfigFileName != NULL) 38 41 { 39 configfile = pConfigFileName;42 ret = this->Main(pConfigFileName); 40 43 } 41 44 else 42 45 { 43 // make the default config file name, 44 // based on the program path 45 configfile = exepath; 46 configfile = configfile.substr(0, 47 configfile.rfind(DIRECTORY_SEPARATOR_ASCHAR)); 48 configfile += DIRECTORY_SEPARATOR "bbackupd.conf"; 46 ret = this->Main(BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE); 49 47 } 50 48 51 const char *argv[] = {exepath, "-c", configfile.c_str()};52 int argc = sizeof(argv) / sizeof(*argv);53 DWORD ret;54 55 MAINHELPER_START56 ret = this->Main(BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv);57 49 MAINHELPER_END 58 50 -
box/chris/merge/bin/bbackupd/bbackupd.cpp
r1254 r1777 90 90 { 91 91 ExitCode = gpDaemonService->Main( 92 BOX_ FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv);92 BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE, argc, argv); 93 93 } 94 94 -
box/chris/merge/bin/bbackupquery/bbackupquery.cpp
r1602 r1777 67 67 int returnCode = 0; 68 68 69 MAINHELPER_SETUP_MEMORY_LEAK_EXIT_REPORT("bbackupquery.memleaks", "bbackupquery") 69 MAINHELPER_SETUP_MEMORY_LEAK_EXIT_REPORT("bbackupquery.memleaks", 70 "bbackupquery") 70 71 MAINHELPER_START 71 72 … … 78 79 if (WSAStartup(0x0101, &info) == SOCKET_ERROR) 79 80 { 80 // throw error? perhaps give it its own id in the furture81 // throw error? perhaps give it its own id in the future 81 82 THROW_EXCEPTION(BackupStoreException, Internal) 82 83 } … … 91 92 92 93 // Filename for configuration file? 93 const char *configFilename = BOX_FILE_BBACKUPD_DEFAULT_CONFIG; 94 std::string configFilename; 95 96 #ifdef WIN32 97 configFilename = BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE; 98 #else 99 configFilename = BOX_FILE_BBACKUPD_DEFAULT_CONFIG; 100 #endif 94 101 95 102 // Flags … … 216 223 217 224 // Read in the configuration file 218 if(!quiet) printf("Using configuration file %s\n", configFilename); 225 if(!quiet) printf("Using configuration file %s\n", 226 configFilename.c_str()); 227 219 228 std::string errs; 220 std::auto_ptr<Configuration> config(Configuration::LoadAndVerify(configFilename, &BackupDaemonConfigVerify, errs)); 229 std::auto_ptr<Configuration> config( 230 Configuration::LoadAndVerify 231 (configFilename, &BackupDaemonConfigVerify, errs)); 232 221 233 if(config.get() == 0 || !errs.empty()) 222 234 { -
box/chris/merge/bin/bbstoreaccounts/bbstoreaccounts.cpp
r217 r1777 403 403 int main(int argc, const char *argv[]) 404 404 { 405 MAINHELPER_SETUP_MEMORY_LEAK_EXIT_REPORT("bbstoreaccounts.memleaks", "bbstoreaccounts") 405 MAINHELPER_SETUP_MEMORY_LEAK_EXIT_REPORT("bbstoreaccounts.memleaks", 406 "bbstoreaccounts") 406 407 407 408 MAINHELPER_START 408 409 409 // Filename for configuraiton file? 410 const char *configFilename = BOX_FILE_BBSTORED_DEFAULT_CONFIG; 410 // Filename for configuration file? 411 std::string configFilename; 412 413 #ifdef WIN32 414 configFilename = BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE; 415 #else 416 configFilename = BOX_FILE_BBSTORED_DEFAULT_CONFIG; 417 #endif 411 418 412 419 // See if there's another entry on the command line … … 432 439 // Read in the configuration file 433 440 std::string errs; 434 std::auto_ptr<Configuration> config(Configuration::LoadAndVerify(configFilename, &BackupConfigFileVerify, errs)); 441 std::auto_ptr<Configuration> config( 442 Configuration::LoadAndVerify 443 (configFilename, &BackupConfigFileVerify, errs)); 444 435 445 if(config.get() == 0 || !errs.empty()) 436 446 { -
box/chris/merge/bin/bbstored/BackupStoreDaemon.cpp
r1476 r1777 133 133 // Initialise the raid files controller 134 134 RaidFileController &rcontroller = RaidFileController::GetController(); 135 rcontroller.Initialise(config.GetKeyValue("RaidFileConf").c_str()); 135 136 std::string raidFileConfig; 137 138 #ifdef WIN32 139 if (!config.KeyExists("RaidFileConf")) 140 { 141 raidFileConfig = BOX_GET_DEFAULT_RAIDFILE_CONFIG_FILE; 142 } 143 else 144 { 145 raidFileConfig = config.GetKeyValue("RaidFileConf"); 146 } 147 #else 148 raidFileConfig = config.GetKeyValue("RaidFileConf"); 149 #endif 150 151 rcontroller.Initialise(raidFileConfig); 136 152 137 153 // Load the account database -
box/chris/merge/bin/bbstored/bbstored.cpp
r1488 r1777 24 24 25 25 BackupStoreDaemon daemon; 26 return daemon.Main(BOX_FILE_BBSTORED_DEFAULT_CONFIG, argc, argv); 26 27 #ifdef WIN32 28 return daemon.Main(BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE, 29 argc, argv); 30 #else 31 return daemon.Main(BOX_FILE_BBSTORED_DEFAULT_CONFIG, 32 argc, argv); 33 #endif 27 34 28 35 MAINHELPER_END -
box/chris/merge/lib/backupstore/BackupStoreConfigVerify.cpp
r217 r1777 36 36 {"TimeBetweenHousekeeping", 0, ConfigTest_Exists | ConfigTest_IsInt, 0}, 37 37 {"ExtendedLogging", "no", ConfigTest_IsBool, 0}, // make value "yes" to enable in config file 38 {"RaidFileConf", BOX_FILE_RAIDFILE_DEFAULT_CONFIG, ConfigTest_LastEntry, 0} 38 39 #ifdef WIN32 40 {"RaidFileConf", "", ConfigTest_LastEntry, 0} 41 #else 42 {"RaidFileConf", BOX_FILE_RAIDFILE_DEFAULT_CONFIG, ConfigTest_LastEntry, 0} 43 #endif 44 39 45 }; 40 46 -
box/chris/merge/lib/common/BoxPortsAndFiles.h
r217 r1777 15 15 16 16 // Backup store daemon 17 #define BOX_PORT_BBSTORED (BOX_PORT_BASE+1)18 #define BOX_FILE_BBSTORED_DEFAULT_CONFIG "/etc/box/bbstored.conf" 17 #define BOX_PORT_BBSTORED (BOX_PORT_BASE+1) 18 19 19 // directory within the RAIDFILE root for the backup store daemon 20 #define BOX_RAIDFILE_ROOT_BBSTORED "backup"20 #define BOX_RAIDFILE_ROOT_BBSTORED "backup" 21 21 22 // Backup client daemon22 // configuration file paths 23 23 #ifdef WIN32 24 #define BOX_FILE_BBACKUPD_DEFAULT_CONFIG "C:\\Program Files\\Box Backup\\bbackupd.conf" 24 // no default config file path, use these macros to call 25 // GetDefaultConfigFilePath() instead. 26 27 #define BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE \ 28 GetDefaultConfigFilePath("bbackupd.conf").c_str() 29 #define BOX_GET_DEFAULT_RAIDFILE_CONFIG_FILE \ 30 GetDefaultConfigFilePath("raidfile.conf").c_str() 31 #define BOX_GET_DEFAULT_BBSTORED_CONFIG_FILE \ 32 GetDefaultConfigFilePath("bbstored.conf").c_str() 25 33 #else 26 34 #define BOX_FILE_BBACKUPD_DEFAULT_CONFIG "/etc/box/bbackupd.conf" 35 #define BOX_FILE_RAIDFILE_DEFAULT_CONFIG "/etc/box/raidfile.conf" 36 #define BOX_FILE_BBSTORED_DEFAULT_CONFIG "/etc/box/bbstored.conf" 27 37 #endif 28 29 // RaidFile conf location default30 #define BOX_FILE_RAIDFILE_DEFAULT_CONFIG "/etc/box/raidfile.conf"31 38 32 39 // Default name of the named pipe -
box/chris/merge/lib/common/Guards.h
r1437 r1777 33 33 { 34 34 public: 35 FileHandleGuard(const char *filename)36 : mOSFileHandle(::open( filename, flags, mode))35 FileHandleGuard(const std::string& rFilename) 36 : mOSFileHandle(::open(rFilename.c_str(), flags, mode)) 37 37 { 38 38 if(mOSFileHandle < 0) 39 39 { 40 40 BOX_ERROR("FileHandleGuard: failed to open file '" << 41 filename << "': " << strerror(errno));41 rFilename << "': " << strerror(errno)); 42 42 THROW_EXCEPTION(CommonException, OSFileOpenError) 43 43 } -
box/chris/merge/lib/win32/emu.cpp
r1756 r1777 217 217 return true; 218 218 } 219 } 220 221 // forward declaration 222 char* ConvertFromWideString(const WCHAR* pString, unsigned int codepage); 223 224 // -------------------------------------------------------------------------- 225 // 226 // Function 227 // Name: GetDefaultConfigFilePath(std::string name) 228 // Purpose: Calculates the default configuration file name, 229 // by using the directory location of the currently 230 // executing program, and appending the provided name. 231 // In case of fire, returns an empty string. 232 // Created: 26th May 2007 233 // 234 // -------------------------------------------------------------------------- 235 std::string GetDefaultConfigFilePath(const std::string& rName) 236 { 237 WCHAR exePathWide[MAX_PATH]; 238 GetModuleFileNameW(NULL, exePathWide, MAX_PATH-1); 239 240 char* exePathUtf8 = ConvertFromWideString(exePathWide, CP_UTF8); 241 if (exePathUtf8 == NULL) 242 { 243 return ""; 244 } 245 246 std::string configfile = exePathUtf8; 247 delete [] exePathUtf8; 248 249 // make the default config file name, 250 // based on the program path 251 configfile = configfile.substr(0, 252 configfile.rfind('\\')); 253 configfile += "\\"; 254 configfile += rName; 255 256 return configfile; 219 257 } 220 258 … … 1253 1291 // as the event source 1254 1292 1255 char cmd[MAX_PATH]; 1256 if (GetModuleFileName(NULL, cmd, sizeof(cmd)-1) == 0) 1293 WCHAR cmd[MAX_PATH]; 1294 DWORD len = GetModuleFileNameW(NULL, cmd, MAX_PATH); 1295 1296 if (len == 0) 1257 1297 { 1258 1298 ::syslog(LOG_ERR, "Failed to get the program file name: %s", … … 1260 1300 return FALSE; 1261 1301 } 1262 cmd[sizeof(cmd)-1] = 0;1263 std::string exepath(cmd);1264 1302 1265 1303 // Create the event source as a subkey of the log. … … 1283 1321 // Set the name of the message file. 1284 1322 1285 if (RegSetValueEx (hk,// subkey handle1286 "EventMessageFile", // value name1287 0, // must be zero1288 REG_EXPAND_SZ, // value type1289 (LPBYTE) exepath.c_str(),// pointer to value data1290 (DWORD) (exepath.size()))) // data size1323 if (RegSetValueExW(hk, // subkey handle 1324 L"EventMessageFile", // value name 1325 0, // must be zero 1326 REG_EXPAND_SZ, // value type 1327 (LPBYTE)cmd, // pointer to value data 1328 len*sizeof(WCHAR))) // data size 1291 1329 { 1292 1330 ::syslog(LOG_ERR, "Failed to set the event message file: %s", … … 1316 1354 // Set the category message file and number of categories. 1317 1355 1318 if (RegSetValueEx (hk,// subkey handle1319 "CategoryMessageFile",// value name1320 0,// must be zero1321 REG_EXPAND_SZ,// value type1322 (LPBYTE) exepath.c_str(),// pointer to value data1323 (DWORD) (exepath.size())))// data size1356 if (RegSetValueExW(hk, // subkey handle 1357 L"CategoryMessageFile", // value name 1358 0, // must be zero 1359 REG_EXPAND_SZ, // value type 1360 (LPBYTE)cmd, // pointer to value data 1361 len*sizeof(WCHAR))) // data size 1324 1362 { 1325 1363 ::syslog(LOG_ERR, "Failed to set the category message file: " -
box/chris/merge/lib/win32/emu.h
r1770 r1777 378 378 bool ConvertConsoleToUtf8(const char* pString, std::string& rDest); 379 379 380 // Utility function which returns a default config file name, 381 // based on the path of the current executable. 382 std::string GetDefaultConfigFilePath(const std::string& rName); 383 380 384 // GetErrorMessage() returns a system error message, like strerror() 381 385 // but for Windows error codes. -
box/chris/merge/test/bbackupd/testbbackupd.cpp
r1757 r1777 613 613 614 614 BackupDaemon daemon; 615 const char* fake_argv[] = { "bbackupd", "testfiles/bbackupd.conf" }; 616 617 int result = daemon.Main(BOX_FILE_BBACKUPD_DEFAULT_CONFIG, 2, 618 fake_argv); 615 int result = daemon.Main("testfiles/bbackupd.conf"); 619 616 620 617 TEST_THAT(result == 0);
Note: See TracChangeset
for help on using the changeset viewer.
