36 lines
1.1 KiB
Zig
36 lines
1.1 KiB
Zig
const std = @import("std");
|
|
|
|
const read = @import("./qtshit/read.zig");
|
|
const write = @import("./qtshit/write.zig");
|
|
|
|
const initClient = @import("./client.zig").initClient;
|
|
|
|
pub fn main() !void {
|
|
const allocator = std.heap.page_allocator;
|
|
|
|
var argIter = std.process.args();
|
|
_ = try argIter.next(allocator).?;
|
|
var host = try argIter.next(allocator).?;
|
|
var port = try argIter.next(allocator).?;
|
|
var portInt = try std.fmt.parseInt(u16, port, 10);
|
|
var username = try argIter.next(allocator).?;
|
|
var password = try argIter.next(allocator).?;
|
|
|
|
std.debug.print("host={s} port={d}\n", .{ host, portInt });
|
|
|
|
var sock = try std.net.tcpConnectToHost(allocator, host, portInt);
|
|
var client = initClient(allocator, &sock);
|
|
try client.handshake();
|
|
try client.quassel_init_packet();
|
|
try client.quassel_login(username, password);
|
|
while (true) {
|
|
client.read_quassel_packet() catch |err| {
|
|
if (err == error.DecodeError) {
|
|
std.debug.print("Decode Error.\n", .{});
|
|
} else {
|
|
return err;
|
|
}
|
|
};
|
|
}
|
|
}
|