This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function
pubfngetWindows(environ: Environ, key: [*:0]constu16) ?[:0]constu16 {
// '=' anywhere but the start makes this an invalid environment variable name.constkey_slice = mem.sliceTo(key, 0);
if (key_slice.len == 0ormem.findScalar(u16, key_slice[1..], '=') != null) returnnull;
if (!environ.block.use_global) returnnull;
constpeb = std.os.windows.peb();
assert(std.os.windows.ntdll.RtlEnterCriticalSection(peb.FastPebLock) == .SUCCESS);
deferassert(std.os.windows.ntdll.RtlLeaveCriticalSection(peb.FastPebLock) == .SUCCESS);
constptr = peb.ProcessParameters.Environment;
vari: usize = 0;
while (ptr[i] != 0) {
constkey_value = mem.sliceTo(ptr[i..], 0);
// There are some special environment variables that start with =,// so we need a special case to not treat = as a key/value separator// if it's the first character.// https://devblogs.microsoft.com/oldnewthing/20100506-00/?p=14133constequal_index = mem.findScalarPos(u16, key_value, 1, '=') orelse {
// This is enforced by CreateProcess.// If violated, CreateProcess will fail with INVALID_PARAMETER.unreachable; // must contain a =
};
constthis_key = key_value[0..equal_index];
if (std.os.windows.eqlIgnoreCaseWtf16(key_slice, this_key)) {
returnkey_value[equal_index + 1 ..];
}
// skip past the NUL terminatori += key_value.len + 1;
}
returnnull;
}
Windows-only. Get an environment variable with a null-terminated, WTF-16 encoded name.
This function performs a Unicode-aware case-insensitive lookup using RtlEqualUnicodeString.
See also:
createMapcontainsConstantcontains