From 52bee8473da2399e4f7cbd5a1308ef54e323a502 Mon Sep 17 00:00:00 2001 From: Kitteh Date: Wed, 2 Jun 2021 16:32:43 +0100 Subject: [PATCH] do more test --- src/client.zig | 5 +++-- src/main.zig | 2 +- src/qtshit/qvariant.zig | 2 +- src/qtshit/write.zig | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/client.zig b/src/client.zig index 53dc3fa..2594e39 100644 --- a/src/client.zig +++ b/src/client.zig @@ -8,10 +8,10 @@ fn dumpDebug(name: []const u8, list: std.ArrayList(u8)) !void { const file = try std.fs.cwd().createFile( name, - .{ .truncate = false }, + .{ .truncate = true }, ); defer file.close(); - + try file.seekTo(0); try file.writeAll(list.items); } @@ -43,6 +43,7 @@ pub const Client = struct { var list = std.ArrayList(u8).init(s.allocator); var map = std.StringHashMap(qvar.QVariant).init(s.allocator); + try map.put("UseSSL", .{ .byte = 0 }); try map.put("UseCompression", .{ .byte = 0 }); try map.put("ProtocolVersion", .{ .int = 10 }); diff --git a/src/main.zig b/src/main.zig index a7ee4ee..a6105b8 100644 --- a/src/main.zig +++ b/src/main.zig @@ -7,7 +7,7 @@ const initClient = @import("./client.zig").initClient; pub fn main() !void { const allocator = std.heap.page_allocator; - var sock = try std.net.tcpConnectToHost(allocator, "127.0.0.1", 64242); + var sock = try std.net.tcpConnectToHost(allocator, "127.0.0.1", 4242); var client = initClient(allocator, &sock); try client.handshake(); diff --git a/src/qtshit/qvariant.zig b/src/qtshit/qvariant.zig index 1112a50..51e4ef3 100644 --- a/src/qtshit/qvariant.zig +++ b/src/qtshit/qvariant.zig @@ -29,7 +29,7 @@ pub fn qvariant_type_id(variant: QVariant) !u32 { return @enumToInt(QVariantTypes.byte); }, .int => { - return @enumToInt(QVariantTypes.int_1); + return @enumToInt(QVariantTypes.int_2); }, .qmap => { return @enumToInt(QVariantTypes.qmap); diff --git a/src/qtshit/write.zig b/src/qtshit/write.zig index f267975..518a70d 100644 --- a/src/qtshit/write.zig +++ b/src/qtshit/write.zig @@ -19,7 +19,7 @@ pub fn add_bytearray(writer: anytype, array: std.ArrayList(u8)) !void { } pub fn add_string(writer: anytype, allocator: *std.mem.Allocator, str: []const u8) !void { - try writer.writeIntBig(i32, @intCast(i32, str.len)); + try writer.writeIntBig(i32, @intCast(i32, str.len*16)); var ut16Str = try allocator.alloc(u16, str.len); defer allocator.free(ut16Str); for (str) |character, index| { @@ -94,7 +94,7 @@ pub fn add_message(writer: anytype, allocator: *std.mem.Allocator, map: std.Stri var data = std.ArrayList(u8).init(allocator); try add_qvariantmap(data.writer(), allocator, map); - try add_int(writer, @intCast(u32, data.items.len) * 8); + try add_int(writer, @intCast(u32, data.items.len * 8)); try writer.writeAll(data.items); return;