transport :: #import "http_server_native"; coding :: #import "content_coding_native"; text :: #import "std/byte_text_linux"; environment :: #import "std/environment_linux"; #scope_file Capacity :: 4096; c :: #system_library "c"; Allocate :: (count: usize, size: usize) -> *void #foreign c "calloc"; Free :: (pointer: *void) #foreign c "free"; GetChar :: () -> s32 #foreign c "getchar"; Flush :: (stream: *void) -> s32 #foreign c "fflush"; State :: struct { wire: [Capacity]u8 count: s64 overflow: bool } Completed :: (context: *void, connection: *void, request: **void, reason: s32) { Free(< s32 { if < 0 { if < cast(usize)(Capacity - state.count) { state.overflow = true } else if !state.overflow { data := text.BytesFromPointer(upload, cast(u64)(< s32 { loopback: [4]u8 = .[127, 0, 0, 1] enabled := environment.EnvironmentText("MESH_TEST_NATIVE_ZSTD") != "0" context: *void = null if enabled { context = cast(*void)(*enabled) } daemon := transport.Start(loopback, 0, 8, context, Dispatch, Completed) if daemon == null { return 1 } defer transport.Stop(daemon) print("%\n", transport.BoundPort(daemon)) Flush(null) GetChar() return 0 }