aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ashby <martin@ashbysoft.com>2024-02-01 14:17:55 +0000
committerMartin Ashby <martin@ashbysoft.com>2024-02-01 14:17:55 +0000
commitc99cb339e87b28d937899f9561f106968772ee0c (patch)
tree4b05c8de6bcb4288fa45bc0d820f17ce335acadc
parent4654a36fa71154bb38404ea7191efc5963db9d0f (diff)
downloadsmtp-zig-c99cb339e87b28d937899f9561f106968772ee0c.tar.gz
smtp-zig-c99cb339e87b28d937899f9561f106968772ee0c.tar.bz2
smtp-zig-c99cb339e87b28d937899f9561f106968772ee0c.tar.xz
smtp-zig-c99cb339e87b28d937899f9561f106968772ee0c.zip
Update for zig master
-rw-r--r--build.zig2
-rw-r--r--build.zig.zon1
-rw-r--r--src/main.zig8
3 files changed, 6 insertions, 5 deletions
diff --git a/build.zig b/build.zig
index a5af2a9..a5c2c1d 100644
--- a/build.zig
+++ b/build.zig
@@ -11,7 +11,7 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
b.installArtifact(lib);
- _ = b.addModule("smtp", .{ .source_file = .{ .path = "src/main.zig" } });
+ _ = b.addModule("smtp", .{ .root_source_file = .{ .path = "src/main.zig" } });
const main_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
diff --git a/build.zig.zon b/build.zig.zon
index 97e2bee..959a0e2 100644
--- a/build.zig.zon
+++ b/build.zig.zon
@@ -1,4 +1,5 @@
.{
.name = "smtp",
.version = "0.0.0",
+ .paths = .{""},
} \ No newline at end of file
diff --git a/src/main.zig b/src/main.zig
index a3f7e90..03322b6 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -115,7 +115,7 @@ pub const Client = struct {
const port_str = spl.rest();
const port = try std.fmt.parseInt(u16, port_str, 10);
- var stream = try std.net.tcpConnectToHost(allocator, host, port);
+ const stream = try std.net.tcpConnectToHost(allocator, host, port);
var client = Client{
.allocator = allocator,
.stream = stream,
@@ -154,7 +154,7 @@ pub const Client = struct {
const z = try std.fmt.allocPrint(allocator, "{s}\x00{s}\x00{s}", .{ "", auth.user, auth.pass });
defer allocator.free(z);
const enc = std.base64.standard.Encoder;
- var zz = try allocator.alloc(u8, enc.calcSize(z.len));
+ const zz = try allocator.alloc(u8, enc.calcSize(z.len));
defer allocator.free(zz);
const zzz = enc.encode(zz, z);
const line = try std.fmt.allocPrint(allocator, "AUTH PLAIN {s}", .{zzz});
@@ -246,7 +246,7 @@ pub const Client = struct {
const line = try std.fmt.allocPrint(self.allocator, "MAIL FROM:<{s}>", .{from});
defer self.allocator.free(line);
try self.write_line(line);
- var r = try self.read_expect_code(250);
+ const r = try self.read_expect_code(250);
self.allocator.free(r);
}
@@ -254,7 +254,7 @@ pub const Client = struct {
const line = try std.fmt.allocPrint(self.allocator, "RCPT TO:<{s}>", .{to});
defer self.allocator.free(line);
try self.write_line(line);
- var r = try self.read_expect_code(250);
+ const r = try self.read_expect_code(250);
self.allocator.free(r);
}