From afac4c8c7780cc40bb41d8bae97a4ae83a79db9f Mon Sep 17 00:00:00 2001 From: Nic Gaffney Date: Tue, 20 Oct 2026 03:35:56 -0500 Subject: Finished minimal message impl --- src/lib/tmp.zig | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 src/lib/tmp.zig (limited to 'src/lib/tmp.zig') diff --git a/src/lib/tmp.zig b/src/lib/tmp.zig deleted file mode 100644 index 3777b31..0000000 --- a/src/lib/tmp.zig +++ /dev/null @@ -1,50 +0,0 @@ -const std = @import("std"); - -const Code = enum(u16) { - OK = 250, - UNKNOWN = 404, -}; - -const Response = struct { - code: Code, - pass: bool, - msg: []const u8, -}; - -const Message = struct { - name: []const u8, - pass: []const Code, - fail: []const Code, - handle: fn (*std.Io.Writer, *std.Io.net.Server, args: anytype) anyerror!Response, -}; - -const Messages = union(enum(u8)) { - HELO = Message{ - .name = "HELO", - .pass = .{.OK}, - .fail = .{.UNKNOWN}, - .handle = blk: { - const f = struct { - pub fn handle(w: *std.Io.Writer, s: *std.Io.net.Server, args: anytype) !Response { - var resp: Response = .{ .code = .OK, .pass = true, .contents = undefined }; - if (args.domain) |d| { - resp.contents = d; - try w.print("{d} {s}\r\n", .{ resp.code, resp.contents }); - try w.flush(); - return resp; - } - try w.print("{d} ", .{resp.code}); - var buf: [64]u8 = undefined; - var fw: std.Io.Writer = .fixed(&buf); - try s.socket.address.format(&fw); - const full = fw.buffered(); - const host = if (std.mem.lastIndexOfScalar(u8, full, ':')) |i| full[0..i] else full; - try w.print("[{s}]\r\n", .{host}); - resp.contents = host; - return resp; - } - }; - break :blk f.handle; - }, - }, -}; -- cgit v1.2.3