diff options
author | Christian Segundo | 2023-06-17 11:17:31 +0200 |
---|---|---|
committer | Christian Segundo | 2023-06-17 11:17:31 +0200 |
commit | b02b7f71978a172848322f0671d580e425634916 (patch) | |
tree | 057fba90b084b82a200ca76b424a9dd9fa204d2f /src | |
parent | c7412022c3c607c809f774db2459f9259ba95038 (diff) | |
download | zmission-b02b7f71978a172848322f0671d580e425634916.tar.gz |
one step closer
Diffstat (limited to 'src')
-rw-r--r-- | src/main.zig | 28 | ||||
-rw-r--r-- | src/transmission.zig | 3 | ||||
-rw-r--r-- | src/types.zig | 52 |
3 files changed, 62 insertions, 21 deletions
diff --git a/src/main.zig b/src/main.zig index b01188b..a88bf8a 100644 --- a/src/main.zig +++ b/src/main.zig @@ -14,24 +14,13 @@ export fn add(a: i32, b: i32) i32 { var client = transmission.Client.init(allocator, clientOptions); defer client.deinit(); - //{ - //const body = transmission.session_get_raw(&client, null) catch |err| { - //std.debug.print("error: {any}\n", .{err}); - //unreachable; - //}; - //defer allocator.free(body); - //std.debug.print("body: {s}\n", .{body}); - //} - { - const body = transmission.torrent_get_(&client, null) catch |err| { + const body = transmission.session_get_raw(&client, null) catch |err| { std.debug.print("error: {any}\n", .{err}); unreachable; }; - //defer allocator.free(body); - for (body.arguments.torrent_get.torrents.?) |t| { - std.debug.print("name: {any}\n", .{t}); - } + defer allocator.free(body); + std.debug.print("body: {s}\n", .{body}); } //{ @@ -40,6 +29,17 @@ export fn add(a: i32, b: i32) i32 { //unreachable; //}; ////defer allocator.free(body); + //for (body.arguments.torrent_get.torrents.?) |t| { + //std.debug.print("name: {any}\n", .{t}); + //} + //} + + //{ + //const body = transmission.torrent_get_(&client, null) catch |err| { + //std.debug.print("error: {any}\n", .{err}); + //unreachable; + //}; + ////defer allocator.free(body); //std.debug.print("body: {any}\n", .{body}); //} diff --git a/src/transmission.zig b/src/transmission.zig index 409b4b1..9f0f5f0 100644 --- a/src/transmission.zig +++ b/src/transmission.zig @@ -126,6 +126,9 @@ pub fn torrent_get_raw(client: *Client, torrent_get: ?Request.TorrentGet) ![]u8 .arguments = .{ .torrent_get = torrent_get orelse default }, }; const body = try client.do(r); + std.debug.print("{s}\n", .{body}); + if (1 == 1) + @panic(""); return body; } diff --git a/src/types.zig b/src/types.zig index b8029ca..7de8fa1 100644 --- a/src/types.zig +++ b/src/types.zig @@ -11,9 +11,14 @@ pub const Torrent = struct { // When the torrent was first added. addedDate: ?i64 = null, - //availability: []struct {}, array (see below) tr_torrepieceCountntAvailability() + // An array of numbers representing the number of connected peers that + // have each piece, or -1 if we already have the piece ourselves. + availability: ?[]i64 = null, - //bandwidthPriority: ?usize = null, + // ?? + bandwidthPriority: ?i8 = null, + + // ?? comment: ?[]u8 = null, // Byte count of all the corrupt data you've ever downloaded for @@ -21,8 +26,11 @@ pub const Torrent = struct { // grow very large. corruptEver: ?u64 = null, + // ?? creator: ?[]u8 = null, - //dateCreated: ?usize = null, + + // ?? + dateCreated: ?i64 = null, // Byte count of all the piece data we want and don't have yet, // but that a connected peer does have. @@ -31,6 +39,7 @@ pub const Torrent = struct { // When the torrent finished downloading. doneDate: ?i64 = null, + // ?? downloadDir: ?[]u8 = null, // Byte count of all the non-corrupt data you've ever downloaded @@ -38,7 +47,9 @@ pub const Torrent = struct { // time, this will be `2*totalSize`. downloadedEver: ?u64 = null, + // TODO: ?? can't find the definition anywhere //downloadLimit: ?usize = null, + downloadLimited: ?bool = null, // The last time during this session that a rarely-changing field @@ -47,7 +58,22 @@ pub const Torrent = struct { // to reload fields that rarely change. editDate: ?i64 = null, - //@"error": ?usize = null, + // Defines what kind of text is in errorString. + @"error": ?enum { + // everything's fine + ok, + + // when we announced to the tracker, we got a warning in the response + tracker_warning, + + // when we announced to the tracker, we got an error in the response + tracker_error, + + // local trouble, such as disk full or permissions error + local_error, + }, + + // A warning or error message regarding the torrent. errorString: ?[]u8 = null, // If downloading, estimated number of seconds left until the torrent is done. @@ -57,9 +83,21 @@ pub const Torrent = struct { // If seeding, number of seconds left until the idle time limit is reached. etaIdle: ?i64 = null, - //@"file-count": ?usize = null, - ////files array (see below) n/a - ////fileStats array (see below) n/a + // ?? + @"file-count": ?usize = null, + + // ?? TODO: this is most likely outdated, the returned json is missing + // some of the fields in the docs + files: ?[]struct { + bytesCompleted: ?u64 = null, + length: ?u64 = null, + name: ?[]u8 = null, + beginPiece: ?u32 = null, + endPiece: ?u32 = null, + } = null, + + //fileStats array (see below) n/a + group: ?[]u8 = null, hashString: ?[]u8 = null, |