improve error reporting of lazy_bdecode to use error_code

This commit is contained in:
Arvid Norberg
2010-10-28 04:01:59 +00:00
parent d737dd051d
commit fc1b44b560
19 changed files with 135 additions and 73 deletions

View File

@@ -842,7 +842,8 @@ int main(int argc, char* argv[])
if (load_file(".ses_state", in) == 0)
{
lazy_entry e;
if (lazy_bdecode(&in[0], &in[0] + in.size(), e) == 0)
error_code ec;
if (lazy_bdecode(&in[0], &in[0] + in.size(), e, ec) == 0)
ses.load_state(e);
}

View File

@@ -60,17 +60,18 @@ int main(int argc, char* argv[])
return 1;
}
lazy_entry e;
ret = lazy_bdecode(&buf[0], &buf[0] + buf.size(), e);
error_code ec;
int pos;
ret = lazy_bdecode(&buf[0], &buf[0] + buf.size(), e, ec, &pos);
if (ret != 0)
{
fprintf(stderr, "invalid bencoding: %d\n", ret);
fprintf(stderr, "failed to decode: '%s' at character: %d\n", ec.message().c_str(), pos);
return 1;
}
printf("\n\n----- raw info -----\n\n%s\n", print_entry(e).c_str());
error_code ec;
torrent_info t(e, ec);
if (ec)
{