2021-06-01 12:17:24 +01:00
|
|
|
const std = @import("std");
|
|
|
|
|
2021-06-01 11:18:21 +01:00
|
|
|
pub fn add_int(writer: anytype, number: u32) !void {
|
2021-06-01 12:17:24 +01:00
|
|
|
try writer.writeIntBig(u32, number);
|
2021-06-01 11:18:21 +01:00
|
|
|
}
|
2021-06-01 10:38:42 +01:00
|
|
|
|
2021-06-01 11:18:21 +01:00
|
|
|
pub fn add_short(writer: anytype, number: u16) !void {
|
2021-06-01 12:17:24 +01:00
|
|
|
try writer.writeIntBig(u16, number);
|
2021-06-01 11:18:21 +01:00
|
|
|
}
|
2021-06-01 10:38:42 +01:00
|
|
|
|
2021-06-01 11:18:21 +01:00
|
|
|
pub fn add_byte(writer: anytype, byte: u8) !void {
|
2021-06-01 12:17:24 +01:00
|
|
|
try writer.writeByte(byte);
|
2021-06-01 11:18:21 +01:00
|
|
|
}
|
|
|
|
|
2021-06-01 11:22:56 +01:00
|
|
|
pub fn add_string(writer: anytype, str: []const u8) !void {
|
2021-06-01 12:17:24 +01:00
|
|
|
try writer.writeAll(str);
|
|
|
|
try writer.writeByte('\x00');
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn add_stringlist(writer: anytype, strList: std.ArrayList([]const u8)) !void {
|
|
|
|
try add_int(writer, @intCast(u32, strList.items.len));
|
|
|
|
for (strList.items) |string| {
|
|
|
|
try add_string(writer, string);
|
|
|
|
}
|
|
|
|
}
|