* Improved error handling for settings. LibTorrent now consistently

throws torrent::input_error and rtorrent catches those and prints good
error messages.

* torrent::set_{bind,local}_address now accepts dns addresses.

* Fixed bug that caused multiple instances of the setting
up/download_rate to change the relative rate, rather than constant.

* Minor change to the way PCB decides to not request more pieces.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@601 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-11-24 17:21:32 +00:00
parent 93c6369b69
commit 98a8fc8638
11 changed files with 140 additions and 191 deletions
+24 -7
View File
@@ -38,18 +38,35 @@
#include <fstream>
#include <stdexcept>
#include <stdio.h>
#include <torrent/exceptions.h>
#include "option_file.h"
void
OptionFile::process(std::istream* stream) {
char buf[max_size_line];
bool
OptionFile::process_file(const std::string& filename) {
std::fstream file(filename.c_str(), std::ios::in);
while (stream->good()) {
stream->getline(buf, max_size_line);
if (!file.good())
return false;
parse_line(buf);
int lineNumber = 0;
char buffer[max_size_line];
try {
while (file.getline(buffer, max_size_line).good()) {
lineNumber++;
parse_line(buffer);
}
} catch (torrent::input_error& e) {
snprintf(buffer, max_size_line, "Error in option file: %s:%i: %s", filename.c_str(), lineNumber, e.what());
throw std::runtime_error(buffer);
}
return true;
}
void
@@ -69,7 +86,7 @@ OptionFile::parse_line(const char* line) {
if ((result = std::sscanf(line, "%63s = \"%511[^\"]s", key, opt)) != 2 &&
(result = std::sscanf(line, "%63s = %511s", key, opt)) != 2 &&
result == 1)
throw std::runtime_error("Error parseing option file.");
throw torrent::input_error("Error parseing option file.");
if (opt[0] == '"' && opt[1] == '"')
opt[0] = '\0';