Working option file, doesn't yet load from a sane place.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@449 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-06-01 13:33:44 +00:00
parent 74930f86b3
commit 0206ee066d
8 changed files with 178 additions and 33 deletions
+27 -1
View File
@@ -48,6 +48,7 @@
#include "utils/task_schedule.h"
#include "signal_handler.h"
#include "option_file.h"
#include "option_handler.h"
#include "option_handler_rules.h"
#include "option_parser.h"
@@ -108,6 +109,30 @@ parse_options(ui::Control* c, OptionHandler* optionHandler, int argc, char** arg
return optionParser.process(argc, argv);
}
void
initialize_option_handler(ui::Control* c, OptionHandler* optionHandler) {
core::DownloadSlotMap* dsm = &c->get_core().get_default_settings();
optionHandler->insert("min_peers", new OptionHandlerDownloadInt<&apply_download_min_peers, &validate_download_peers>(dsm));
optionHandler->insert("max_peers", new OptionHandlerDownloadInt<&apply_download_max_peers, &validate_download_peers>(dsm));
optionHandler->insert("max_uploads", new OptionHandlerDownloadInt<&apply_download_max_uploads, &validate_download_peers>(dsm));
}
void
load_option_file(const std::string& filename, OptionHandler* optionHandler, bool require = false) {
std::fstream f(filename.c_str(), std::ios::in);
if (!f.is_open())
return;
std::cout << "Loaded option file \"" << filename << "\"" << std::endl;
OptionFile optionFile;
optionFile.slot_option(sigc::mem_fun(*optionHandler, &OptionHandler::process));
optionFile.process(&f);
}
void
load_session_torrents(ui::Control* c) {
// Load session torrents.
@@ -146,7 +171,7 @@ main(int argc, char** argv) {
srandom(utils::Timer::cache().usec());
srand48(utils::Timer::cache().usec());
optionHandler.insert("min_peers", new OptionHandlerDownloadMinPeers(&uiControl.get_core().get_default_settings()));
initialize_option_handler(&uiControl, &optionHandler);
try {
@@ -155,6 +180,7 @@ main(int argc, char** argv) {
SignalHandler::set_handler(SIGSEGV, sigc::bind(sigc::ptr_fun(&do_panic), SIGSEGV));
SignalHandler::set_handler(SIGBUS, sigc::bind(sigc::ptr_fun(&do_panic), SIGBUS));
load_option_file("./test_options", &optionHandler);
int firstArg = parse_options(&uiControl, &optionHandler, argc, argv);
initialize_display(&uiControl);