Stub impl
This commit is contained in:
parent
f94f530437
commit
94a4d1de24
4 changed files with 33 additions and 20 deletions
6
src/hosts.zig
Normal file
6
src/hosts.zig
Normal file
|
@ -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});
|
||||
}
|
27
src/main.zig
27
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);
|
||||
}
|
||||
|
|
10
src/mdns.zig
Normal file
10
src/mdns.zig
Normal file
|
@ -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",
|
||||
};
|
||||
}
|
10
src/util.zig
Normal file
10
src/util.zig
Normal file
|
@ -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";
|
||||
}
|
Loading…
Reference in a new issue