const std = @import("std");
const module = @import("../module.zig");

const gpa = std.heap.page_allocator;

fn cb() ![]const u8 {
    var uname_buf: std.os.linux.utsname = undefined;
    _ = std.os.linux.uname(&uname_buf);

    // Find the null-terminated end of the release string
    var len: usize = 0;
    while (uname_buf.release[len] != 0) : (len += 1) {}

    // Allocate and copy the string
    const kernel_str = try gpa.alloc(u8, len);
    std.mem.copyForwards(u8, kernel_str, uname_buf.release[0..len]);

    return kernel_str;
}

pub const kernel = module {
    .name = "kernel",
    .prefix = "Kernel: ",
    .callback = cb
};
