solidc
Robust collection of general-purpose cross-platform C libraries and data structures designed for rapid and safe development in C
Loading...
Searching...
No Matches
Macros
env.h File Reference

Environment variable utilities and safe access functions. More...

#include <stdlib.h>
Include dependency graph for env.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define GETENV(name)   getenv(name)
 
#define SETENV(name, value, overwrite)   setenv(name, value, overwrite)
 
#define UNSETENV(name)   unsetenv(name)
 

Detailed Description

Environment variable utilities and safe access functions.

Definition in file env.h.

Macro Definition Documentation

◆ GETENV

#define GETENV (   name)    getenv(name)

Cross-platform environment variable access macros.

GETENV: Retrieves environment variable value safely.

  • Linux: Uses secure_getenv() which returns NULL in secure contexts
  • Other: Uses standard getenv()

SETENV: Sets environment variable value.

  • POSIX: Uses setenv(name, value, overwrite)
  • Windows: Uses _putenv_s(name, value) - always overwrites

UNSETENV: Removes environment variable.

  • POSIX: Uses unsetenv(name)
  • Windows: Uses _putenv_s(name, "") to clear the variable

Definition at line 35 of file env.h.

◆ SETENV

#define SETENV (   name,
  value,
  overwrite 
)    setenv(name, value, overwrite)

Sets environment variable on POSIX systems.

Parameters
nameVariable name
valueVariable value
overwrite1 to overwrite existing value, 0 to preserve
Returns
0 on success, -1 on failure

Definition at line 66 of file env.h.

◆ UNSETENV

#define UNSETENV (   name)    unsetenv(name)

Removes environment variable on POSIX systems.

Parameters
nameVariable name to remove
Returns
0 on success, -1 on failure

Definition at line 73 of file env.h.