- Timestamp:
- 03/08/2007 00:29:31 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
box/chris/general/bin/bbstoreaccounts/bbstoreaccounts.cpp
r1690 r1790 38 38 if(SoftLimit >= HardLimit) 39 39 { 40 printf("ERROR: Soft limit must be less than the hard limit.\n");40 BOX_FATAL("Soft limit must be less than the hard limit."); 41 41 exit(1); 42 42 } 43 43 if(SoftLimit > ((HardLimit * MAX_SOFT_LIMIT_SIZE) / 100)) 44 44 { 45 printf("ERROR: Soft limit must be no more than %d%% of the hard limit.\n", MAX_SOFT_LIMIT_SIZE); 45 BOX_FATAL("Soft limit must be no more than " << 46 MAX_SOFT_LIMIT_SIZE << "% of the hard limit."); 46 47 exit(1); 47 48 } … … 54 55 if(DiscSet < 0 || DiscSet >= controller.GetNumDiscSets()) 55 56 { 56 printf("Disc set %d does not exist\n", DiscSet);57 BOX_FATAL("Disc set " << DiscSet << " does not exist."); 57 58 exit(1); 58 59 } … … 90 91 if(endptr == string || number == LONG_MIN || number == LONG_MAX) 91 92 { 92 printf("%s is an invalid number\n", string);93 BOX_FATAL("'" << string << "' is not a valid number."); 93 94 exit(1); 94 95 } … … 117 118 118 119 default: 119 printf("%s has an invalid units specifier\nUse B for blocks, M for Mb, G for Gb, eg 2Gb\n", string); 120 BOX_FATAL(string << " has an invalid units specifier " 121 "(use B for blocks, M for Mb, G for Gb, eg 2Gb)"); 120 122 exit(1); 121 123 break; … … 144 146 { 145 147 // Couldn't lock the account -- just stop now 146 printf("Couldn't lock the account -- did not change the limits\nTry again later.\n"); 148 BOX_ERROR("Failed to lock the account, did not change limits. " 149 "Try again later."); 147 150 return 1; 148 151 } … … 169 172 if(!db->EntryExists(ID)) 170 173 { 171 printf("Account %x does not exist\n", ID); 174 BOX_ERROR("Account " << BOX_FORMAT_ACCOUNT(ID) << 175 " does not exist."); 172 176 return 1; 173 177 } … … 199 203 info->Save(); 200 204 201 printf("Limits on account 0x%08x changed to %lld soft, %lld hard\n", ID, softlimit, hardlimit); 205 BOX_NOTICE("Limits on account " << BOX_FORMAT_ACCOUNT(ID) << 206 " changed to " << softlimit << " soft, " << 207 hardlimit << " hard."); 202 208 203 209 return 0; … … 212 218 if(!db->EntryExists(ID)) 213 219 { 214 printf("Account %x does not exist\n", ID); 220 BOX_ERROR("Account " << BOX_FORMAT_ACCOUNT(ID) << 221 " does not exist."); 215 222 return 1; 216 223 } … … 242 249 if(AskForConfirmation) 243 250 { 244 ::printf("Really delete account %08x?\n(type 'yes' to confirm)\n", ID); 251 BOX_WARNING("Really delete account " << 252 BOX_FORMAT_ACCOUNT(ID) << "? (type 'yes' to confirm)"); 245 253 char response[256]; 246 254 if(::fgets(response, sizeof(response), stdin) == 0 || ::strcmp(response, "yes\n") != 0) 247 255 { 248 printf("Deletion cancelled\n");256 BOX_NOTICE("Deletion cancelled."); 249 257 return 0; 250 258 } … … 257 265 if(!db->EntryExists(ID)) 258 266 { 259 printf("Account %x does not exist\n", ID); 267 BOX_ERROR("Account " << BOX_FORMAT_ACCOUNT(ID) << 268 " does not exist."); 260 269 return 1; 261 270 } … … 319 328 } 320 329 } 321 330 331 int retcode = 0; 332 322 333 // Thirdly, delete the directories... 323 334 for(std::vector<std::string>::const_iterator d(toDelete.begin()); d != toDelete.end(); ++d) 324 335 { 325 ::printf("Deleting store directory %s...\n", (*d).c_str());336 BOX_NOTICE("Deleting store directory " << (*d) << "..."); 326 337 // Just use the rm command to delete the files 327 338 std::string cmd("rm -rf "); … … 330 341 if(::system(cmd.c_str()) != 0) 331 342 { 332 ::printf("ERROR: Deletion of %s failed.\n(when cleaning up, remember to delete all raid directories)\n", (*d).c_str()); 333 return 1; 343 BOX_ERROR("Failed to delete files in " << (*d) << 344 ", delete them manually."); 345 retcode = 1; 334 346 } 335 347 } 336 348 337 349 // Success! 338 return 0;350 return retcode; 339 351 } 340 352 … … 347 359 if(!db->EntryExists(ID)) 348 360 { 349 printf("Account %x does not exist\n", ID); 361 BOX_ERROR("Account " << BOX_FORMAT_ACCOUNT(ID) << 362 " does not exist."); 350 363 return 1; 351 364 } … … 382 395 if(db->EntryExists(ID)) 383 396 { 384 printf("Account %x already exists\n", ID); 397 BOX_ERROR("Account " << BOX_FORMAT_ACCOUNT(ID) << 398 " already exists."); 385 399 return 1; 386 400 } … … 390 404 acc.Create(ID, DiscNumber, SoftLimit, HardLimit, rUsername); 391 405 392 printf("Account %x created\n", ID);406 BOX_NOTICE("Account " << BOX_FORMAT_ACCOUNT(ID) << " created."); 393 407 394 408 return 0; … … 445 459 if(config.get() == 0 || !errs.empty()) 446 460 { 447 printf("Invalid configuration file:\n%s", errs.c_str()); 461 BOX_ERROR("Invalid configuration file " << configFilename << 462 ":" << errs); 448 463 } 449 464 … … 485 500 || ::sscanf(argv[2], "%d", &discnum) != 1) 486 501 { 487 printf("create requires raid file disc number, soft and hard limits\n"); 502 BOX_ERROR("create requires raid file disc number, " 503 "soft and hard limits."); 488 504 return 1; 489 505 } … … 507 523 if(argc < 4) 508 524 { 509 printf("setlimit requires soft and hard limits\n");525 BOX_ERROR("setlimit requires soft and hard limits."); 510 526 return 1; 511 527 } … … 541 557 else 542 558 { 543 ::printf("Unknown option %s.\n", argv[o]);559 BOX_ERROR("Unknown option " << argv[o] << "."); 544 560 return 2; 545 561 } … … 551 567 else 552 568 { 553 printf("Unknown command '%s'\n", argv[0]);569 BOX_ERROR("Unknown command '" << argv[0] << "'."); 554 570 return 1; 555 571 }
Note: See TracChangeset
for help on using the changeset viewer.
