~sircmpwn/btqd

34b220ec57497adf0adf34d0cce38276704e87b5 — Drew DeVault 2 years ago 1a87ade master
torrent: parse private boolean
2 files changed, 5 insertions(+), 1 deletions(-)

M cmd/btinfo/main.ha
M torrent/torrent.ha
M cmd/btinfo/main.ha => cmd/btinfo/main.ha +2 -1
@@ 59,7 59,8 @@ fn dump(conf: *config, in: io::handle) void = {
	};
	defer torrent::torrent_free(tor);

	fmt::printfln("name: {}", tor.info.name)!;
	fmt::printfln("name: {}{}", tor.info.name,
		if (tor.info.private) " (private)" else "")!;
	fmt::printfln("announce: {}", tor.announce)!;

	match (tor.info.length) {

M torrent/torrent.ha => torrent/torrent.ha +3 -0
@@ 13,6 13,7 @@ export type info = struct {
	name: str,
	piecelen: size,
	pieces: []u8,
	private: bool,
	length: (size | void),
	files: []file,
};


@@ 66,6 67,8 @@ export fn read(in: io::handle) (*torrent | error) = {
				return invalid;
			};
			t.info.pieces = alloc(pieces...);
		case "private" =>
			t.info.private = getint(rec.1)? == 1;
		case "length" =>
			t.info.length = getint(rec.1)?: size;
		case "files" =>