-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprobe.zig
More file actions
37 lines (30 loc) · 1.01 KB
/
Copy pathprobe.zig
File metadata and controls
37 lines (30 loc) · 1.01 KB
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
// SPDX-License-Identifier: AGPL-3.0-or-later
// probe.zig - Typed-WASM server probing module
const std = @import("std");
// Export with interface types for Typed-WASM
pub export fn probeServer(host: []const u8, port: u16) bool {
// Validate port range (typed-WASM ensures this is checked)
if (port < 1 or port > 65535) {
return false;
}
// Fast path: check if host is valid
if (host.len == 0) {
return false;
}
// TODO: Add actual network probing logic
// For now, return true to demonstrate the interface
return true;
}
// Typed-WASM interface definition
pub export fn validateConfig(configJson: []const u8) bool {
// Validate JSON structure using typed-WASM
// Returns true if config is valid
return configJson.len > 0;
}
// Memory management functions for typed-WASM
pub export fn alloc(bytes: usize) [*]u8 {
return std.heap.page_allocator.alloc(u8, bytes) catch null;
}
pub export fn free(ptr: [*]u8) void {
std.heap.page_allocator.free(ptr);
}