diff --git a/src/hosts.zig b/src/hosts.zig new file mode 100644 index 0000000..4b0fd71 --- /dev/null +++ b/src/hosts.zig @@ -0,0 +1,6 @@ +const std = @import("std"); +const util = @import("util.zig"); + +pub fn update_hosts(ips: util.IPs) !void { + std.debug.print("{any}\n", .{ips}); +} diff --git a/src/main.zig b/src/main.zig index c8a3f67..7fee4e7 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,24 +1,11 @@ const std = @import("std"); +const util = @import("util.zig"); +const mdns = @import("mdns.zig"); +const hosts = @import("hosts.zig"); pub fn main() !void { - // Prints to stderr (it's a shortcut based on `std.io.getStdErr()`) - std.debug.print("All your {s} are belong to us.\n", .{"codebase"}); - - // stdout is for the actual output of your application, for example if you - // are implementing gzip, then only the compressed bytes should be sent to - // stdout, not any debugging messages. - const stdout_file = std.io.getStdOut().writer(); - var bw = std.io.bufferedWriter(stdout_file); - const stdout = bw.writer(); - - try stdout.print("Run `zig build test` to run the tests.\n", .{}); - - try bw.flush(); // don't forget to flush! -} - -test "simple test" { - var list = std.ArrayList(i32).init(std.testing.allocator); - defer list.deinit(); // try commenting this out and see if zig detects the memory leak! - try list.append(42); - try std.testing.expectEqual(@as(i32, 42), list.pop()); + try util.check_perms(); + const domain = try util.get_input(); + const ips = try mdns.get_mdns(domain); + try hosts.update_hosts(ips); } diff --git a/src/mdns.zig b/src/mdns.zig new file mode 100644 index 0000000..2d9364a --- /dev/null +++ b/src/mdns.zig @@ -0,0 +1,10 @@ +const std = @import("std"); +const util = @import("util.zig"); + +pub fn get_mdns(domain: [:0]const u8) !util.IPs { + std.debug.print("{s}\n", .{domain}); + return util.IPs{ + .v4 = "stub v4", + .v6 = "stub v6", + }; +} diff --git a/src/util.zig b/src/util.zig new file mode 100644 index 0000000..aef7ac3 --- /dev/null +++ b/src/util.zig @@ -0,0 +1,10 @@ +pub const IPs = struct { + v4: [:0]const u8, + v6: [:0]const u8, +}; + +pub fn check_perms() !void {} + +pub fn get_input() ![:0]const u8 { + return "stub"; +}