Add dumpDebug()

This commit is contained in:
Kitteh 2021-06-02 12:29:51 +01:00
parent 655363a79e
commit c3589cd74f
2 changed files with 22 additions and 4 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
material
zig-cache
*.bin

View file

@ -3,6 +3,17 @@ const read = @import("./qtshit/read.zig");
const write = @import("./qtshit/write.zig");
const qvar = @import("./qtshit/qvariant.zig");
fn dumpDebug(name: []const u8, list: std.ArrayList(u8)) !void {
const file = try std.fs.cwd().createFile(
name,
.{ .read = true },
);
defer file.close();
try file.writeAll(list.items);
try file.seekTo(0);
}
pub const Client = struct {
allocator: *std.mem.Allocator,
stream: *std.net.Stream,
@ -25,9 +36,11 @@ pub const Client = struct {
if (((resp >> 24) & 2) != 0) {
@panic("No support 4 compression.");
}
std.debug.print("handshake Success!\n", .{});
std.debug.print("Handshake Success!\n", .{});
}
pub fn quassel_init_packet(s: *Client) !void {
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 });
@ -36,7 +49,11 @@ pub const Client = struct {
try map.put("ClientVersion", .{ .string = "0.1 (quasselclient)" });
try map.put("ClientDate", .{ .string = "0" });
try write.add_qvariantmap(s.stream.writer(), map);
try write.add_qvariantmap(list.writer(), map);
try dumpDebug("ClientInit.bin", list);
try s.stream.writer().writeAll(list.items);
}
pub fn quassel_login(s: *Client, username: []const u8, password: []const u8) !void {
var map = std.StringHashMap(qvar.QVariant).init(s.allocator);