Add dumpDebug()
This commit is contained in:
parent
655363a79e
commit
c3589cd74f
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
material
|
||||
zig-cache
|
||||
*.bin
|
|
@ -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,14 +49,18 @@ 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);
|
||||
|
||||
try map.put("MsgType", .{ .string = "ClientLogin" });
|
||||
try map.put("User", .{ .string = username });
|
||||
try map.put("Password", .{ .string = password});
|
||||
try map.put("Password", .{ .string = password });
|
||||
|
||||
try write.add_qvariantmap(s.stream.writer(), map);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue