DoxigAlpha

parsePort

Function parameters

Parameters

#
str:[]const u8

Type definitions in this namespace

Types

#

Functions in this namespace

Functions

#
tcpConnectToHost
All memory allocated with `allocator` will be freed before this function returns.
getAddressList
Call `AddressList.deinit` on the result.

Error sets in this namespace

Error Sets

#

= switch (native_os) { .windows => builtin.os.version_range.windows.isAtLeast(.win10_rs4) orelse false, .wasi => false, else => true, }

Values

#
has_unix_sockets
= switch (native_os) { .windows => builtin.os.version_range.windows.isAtLeast(.win10_rs4) orelse false, .wasi => false, else => true, }

Source

Implementation

#
fn parsePort(str: []const u8) ?u16 {
    var p: u16 = 0;
    for (str) |c| switch (c) {
        '0'...'9' => {
            const shifted = std.math.mul(u16, p, 10) catch return null;
            p = std.math.add(u16, shifted, c - '0') catch return null;
        },
        else => return null,
    };
    if (p == 0) return null;
    return p;
}