blob: 3959f083fa945058f98a77b2456a78c687b91cbc (
plain) (
blame)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 | const is_debug = builtin.mode == .Debug;
/// This creates a debug allocator that can only be referenced in debug mode.
/// You should check for is_debug around every reference to dba.
var dba: DebugAllocator =
    if (is_debug)
        DebugAllocator.init
    else
        @compileError("Should not use debug allocator in release mode");
pub fn main() !void {
    defer if (is_debug) {
        _ = dba.deinit();
    };
    const gpa = if (is_debug) dba.allocator() else std.heap.smp_allocator;
    const args = try std.process.argsAlloc(gpa);
    defer std.process.argsFree(gpa, args);
    var message = ArrayList(u8).init(gpa);
    defer message.deinit();
    for (args[1..], 0..) |arg, i| {
        try message.appendSlice(arg);
        if (i < args.len - 1)
            try message.append(' ');
    }
    try Saprus.init();
    defer Saprus.deinit();
    // _ = try Saprus.sendInitialConnection(if (message.items.len > 0) message.items else "Hello darkness my old friend", 6868, gpa);
    try Saprus.connect(if (message.items.len > 0) message.items else "Hello darkness my old friend", gpa);
    // try Saprus.sendRelay(if (message.items.len > 0) message.items else "Hello darkness my old friend", gpa);
}
const builtin = @import("builtin");
const std = @import("std");
const DebugAllocator = std.heap.DebugAllocator(.{});
const ArrayList = std.ArrayList;
const Saprus = @import("./saprus.zig");
 |