Import with #import "std/environment_linux".
EnvironmentFailure :: enum { None = 0; InvalidName = 1; Unset = 2; Empty = 3; TooLong = 4; NotNumber = 5; OutOfRange = 6; }Named validation failures for process-controlled text. These are input failures, not memory-safety modes: every successful value is first copied into caller-owned bounded storage.
ArgumentFailure :: enum { None = 0; InvalidIndex = 1; NullArgument = 2; TooLong = 3; }BoundedHostText :: (value: *u8, output: []u8) -> Result(string, EnvironmentFailure)Copy a NUL-terminated host value without first creating an unbounded string view. The returned string contains at most output.count bytes and borrows OUTPUT.
EnvironmentRead :: (name: string, output: []u8) -> Result(string, EnvironmentFailure)Read NAME into caller-owned bounded storage. Unset and empty are distinct outcomes, and embedded NUL or overlong names are rejected before getenv.
EnvironmentRange :: (name: string, minimum: s64, maximum: s64, input: []u8) -> Result(s64, EnvironmentFailure)A complete base-ten s64 in the inclusive range. Leading signs other than one '-' and trailing bytes are named NotNumber; arithmetic overflow and a value outside the requested range are named OutOfRange.
ArgumentRead :: (argc: s32, argv: **u8, index: s32, output: []u8) -> Result(string, ArgumentFailure)Copy one argv entry into caller-owned bounded storage. This validates the count, vector and slot before reading the C string.
EnvironmentText :: (name: string) -> stringThe value of `name`, or "" when it is unset. The view borrows the environment and lasts until the variable changes.
EnvironmentNumber :: (name: string, fallback: s64) -> s64The whole number that starts `name`'s value, or `fallback` when it is unset or does not start with one.