issues with parsing
This commit is contained in:
parent
a68c3e2c82
commit
a108f9befd
|
@ -6,7 +6,7 @@ const write = @import("./qtshit/write.zig");
|
||||||
const initClient = @import("./client.zig").initClient;
|
const initClient = @import("./client.zig").initClient;
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
const allocator = std.heap.page_allocator;
|
const allocator = &std.heap.loggingAllocator(std.heap.page_allocator, std.io.getStdErr().writer()).allocator;
|
||||||
|
|
||||||
var argIter = std.process.args();
|
var argIter = std.process.args();
|
||||||
_ = try argIter.next(allocator).?;
|
_ = try argIter.next(allocator).?;
|
||||||
|
@ -18,7 +18,6 @@ pub fn main() !void {
|
||||||
|
|
||||||
std.debug.print("host={s} port={d}\n", .{host, portInt});
|
std.debug.print("host={s} port={d}\n", .{host, portInt});
|
||||||
|
|
||||||
|
|
||||||
var sock = try std.net.tcpConnectToHost(allocator, host, portInt);
|
var sock = try std.net.tcpConnectToHost(allocator, host, portInt);
|
||||||
var client = initClient(allocator, &sock);
|
var client = initClient(allocator, &sock);
|
||||||
try client.handshake();
|
try client.handshake();
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
const std = @import("std");
|
||||||
pub fn readByte(reader: anytype) !u8 {
|
pub fn readByte(reader: anytype) !u8 {
|
||||||
|
std.debug.print("read: readByte\n", .{});
|
||||||
return try reader.readByte();
|
return try reader.readByte();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
pub fn readInt(reader: anytype) !i32 {
|
pub fn readInt(reader: anytype) !i32 {
|
||||||
|
std.debug.print("read: readInt\n", .{});
|
||||||
return try reader.readIntBig(i32);
|
return try reader.readIntBig(i32);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
pub fn readLong(reader: anytype) !i64 {
|
pub fn readLong(reader: anytype) !i64 {
|
||||||
|
std.debug.print("read: readLong\n", .{});
|
||||||
return try reader.readIntBig(i64);
|
return try reader.readIntBig(i64);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const readUInt = @import("./readUInt.zig").readUInt;
|
const readUInt = @import("./readUInt.zig").readUInt;
|
||||||
const readByte = @import("./readByte.zig").readByte;
|
|
||||||
|
|
||||||
pub fn readQByteArray(reader: anytype, allocator: *std.mem.Allocator) ![]u8 {
|
pub fn readQByteArray(reader: anytype, allocator: *std.mem.Allocator) ![]u8 {
|
||||||
var length = try readUInt(reader);
|
var length = try readUInt(reader);
|
||||||
|
std.debug.print("read: readQByteArray length={d} \n", .{length});
|
||||||
|
|
||||||
var byteList = try allocator.alloc(u8, @intCast(usize, length));
|
var byteList = try allocator.alloc(u8, @intCast(usize, length));
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ pub fn readQByteArray(reader: anytype, allocator: *std.mem.Allocator) ![]u8 {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (index == length) return byteList;
|
if (index == length) return byteList;
|
||||||
|
|
||||||
const byte = try readByte(reader);
|
const byte = try reader.readByte();
|
||||||
byteList[index] = byte;
|
byteList[index] = byte;
|
||||||
index += 1;
|
index += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ const readString = @import("./readString.zig").readString;
|
||||||
|
|
||||||
pub fn readQStringList(reader: anytype, allocator: *std.mem.Allocator) ![][]const u8 {
|
pub fn readQStringList(reader: anytype, allocator: *std.mem.Allocator) ![][]const u8 {
|
||||||
var length = try readUInt(reader);
|
var length = try readUInt(reader);
|
||||||
|
std.debug.print("read: readQStringList length={d} \n", .{length});
|
||||||
|
|
||||||
var stringList = try allocator.alloc([]const u8, @intCast(usize, length));
|
var stringList = try allocator.alloc([]const u8, @intCast(usize, length));
|
||||||
|
|
||||||
var iter = range(u32, 0, length);
|
var iter = range(u32, 0, length);
|
||||||
|
|
|
@ -7,6 +7,8 @@ const QVariant = @import("../types/QVariant.zig").QVariant;
|
||||||
|
|
||||||
pub fn readQVariant(reader: anytype, allocator: *std.mem.Allocator) !QVariant {
|
pub fn readQVariant(reader: anytype, allocator: *std.mem.Allocator) !QVariant {
|
||||||
var type_id = try readUInt(reader);
|
var type_id = try readUInt(reader);
|
||||||
|
std.debug.print("read: readQVariant type_id={d}\n", .{type_id});
|
||||||
|
|
||||||
_ = try readByte(reader);
|
_ = try readByte(reader);
|
||||||
return try readQVariantT(reader, type_id, allocator);
|
return try readQVariantT(reader, type_id, allocator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,10 @@ const readQVariant = @import("./readQVariant.zig").readQVariant;
|
||||||
const QVariant = @import("../types/QVariant.zig").QVariant;
|
const QVariant = @import("../types/QVariant.zig").QVariant;
|
||||||
|
|
||||||
|
|
||||||
pub fn readQVariantList(reader: anytype, allocator: *std.mem.Allocator) ![]QVariant {
|
pub fn readQVariantList(reader: anytype, allocator: *std.mem.Allocator) ![]QVariant {
|
||||||
var length = try readUInt(reader);
|
var length = try readUInt(reader);
|
||||||
|
std.debug.print("read: readQVariantList length={d}\n", .{length});
|
||||||
|
|
||||||
var variantList = try allocator.alloc(QVariant, @intCast(usize, length));
|
var variantList = try allocator.alloc(QVariant, @intCast(usize, length));
|
||||||
|
|
||||||
var iter = range(u32, 0, length);
|
var iter = range(u32, 0, length);
|
||||||
|
|
|
@ -11,6 +11,8 @@ const QVariant = @import("../types/QVariant.zig").QVariant;
|
||||||
pub fn readQVariantMap(reader: anytype, allocator: *std.mem.Allocator) !std.StringHashMap(QVariant) {
|
pub fn readQVariantMap(reader: anytype, allocator: *std.mem.Allocator) !std.StringHashMap(QVariant) {
|
||||||
var map = std.StringHashMap(QVariant).init(allocator);
|
var map = std.StringHashMap(QVariant).init(allocator);
|
||||||
var numItems = try readUInt(reader);
|
var numItems = try readUInt(reader);
|
||||||
|
std.debug.print("read: readQVariantMap length={d} \n", .{numItems});
|
||||||
|
|
||||||
|
|
||||||
var iter = range(u32, 0, numItems);
|
var iter = range(u32, 0, numItems);
|
||||||
while (iter.next()) |i| {
|
while (iter.next()) |i| {
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
pub fn readShort(reader: anytype) !u16 {
|
pub fn readShort(reader: anytype) !u16 {
|
||||||
|
std.debug.print("read: readShort\n", .{});
|
||||||
|
|
||||||
return try reader.readIntBig(u16);
|
return try reader.readIntBig(u16);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
pub fn readSignedByte(reader: anytype) !i8 {
|
pub fn readSignedByte(reader: anytype) !i8 {
|
||||||
|
std.debug.print("read: readSignedByte\n", .{});
|
||||||
return try reader.readIntBig(i8);
|
return try reader.readIntBig(i8);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,13 @@ pub fn readString(reader: anytype, allocator: *std.mem.Allocator) ![]u8 {
|
||||||
|
|
||||||
var length = try readInt(reader);
|
var length = try readInt(reader);
|
||||||
var chars = @divTrunc(length, 2);
|
var chars = @divTrunc(length, 2);
|
||||||
|
std.debug.print("read: readString length={d} \n", .{length});
|
||||||
|
|
||||||
var index: usize = 0;
|
var index: usize = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (index == chars) break;
|
if (index == chars) break;
|
||||||
|
|
||||||
const byte = try readShort(reader);
|
const byte = try reader.readIntBig(u16);
|
||||||
try data.append(@truncate(u8, byte));
|
try data.append(@truncate(u8, byte));
|
||||||
index += 1;
|
index += 1;
|
||||||
}
|
}
|
||||||
|
@ -23,5 +24,7 @@ pub fn readString(reader: anytype, allocator: *std.mem.Allocator) ![]u8 {
|
||||||
ut8Str[i] = char;
|
ut8Str[i] = char;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std.debug.print("string: {s}\n", .{ut8Str});
|
||||||
|
|
||||||
return ut8Str;
|
return ut8Str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
pub fn readUInt(reader: anytype) !u32 {
|
pub fn readUInt(reader: anytype) !u32 {
|
||||||
|
std.debug.print("read: readUInt\n", .{});
|
||||||
return try reader.readIntBig(u32);
|
return try reader.readIntBig(u32);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ const readQVariantMap = @import("../readQVariantMap.zig").readQVariantMap;
|
||||||
pub fn readUserType(reader: anytype, allocator: *std.mem.Allocator) !UserType {
|
pub fn readUserType(reader: anytype, allocator: *std.mem.Allocator) !UserType {
|
||||||
var userTypeName = try readQByteArray(reader, allocator);
|
var userTypeName = try readQByteArray(reader, allocator);
|
||||||
userTypeName = userTypeName[0 .. userTypeName.len - 1];
|
userTypeName = userTypeName[0 .. userTypeName.len - 1];
|
||||||
|
std.debug.print("read: readUserType name={s} \n", .{userTypeName});
|
||||||
|
|
||||||
if (std.mem.eql(u8, userTypeName, "BufferId")) {
|
if (std.mem.eql(u8, userTypeName, "BufferId")) {
|
||||||
return UserType{
|
return UserType{
|
||||||
|
|
Loading…
Reference in a new issue