EnvGet
Description
Read an environment variable. Returns the value of environment variable name, or NULL if not set. Implementation calls into the platform env-lookup API so consumers don’t have to pull in libc headers for the prototype.
Parameters
| Name | Direction | Description |
|---|---|---|
name |
in | NUL-terminated environment variable name. |
Success
Returns a pointer to the value string (process-owned).
Failure
Returns NULL when name is NULL, when the variable is not set, or when the platform has no envp source linked (freestanding Windows, Darwin with no caller-captured envp).
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Sys.c:328:
#endif
Zstr EnvGet(Zstr name) {
if (!name) {
return NULL;- In
Sys.c:357:
return NULL;
#else
# error "EnvGet: unsupported platform (Linux x86_64/aarch64, Darwin, Windows only)"
#endif
}- In
PdbCache.c:28:
static Zstr tmp_dir_path(void) {
#if PLATFORM_WINDOWS
Zstr p = EnvGet("TEMP");
if (p && *p)
return p;- In
PdbCache.c:31:
if (p && *p)
return p;
p = EnvGet("TMP");
if (p && *p)
return p;- In
PdbCache.c:36:
return "C:/Windows/Temp";
#else
Zstr p = EnvGet("TMPDIR");
if (p && *p)
return p;
Last updated on