|
.env Loader
|
Classes | |
| struct | EnvEntry |
| Internal key/value pair for parsed .env entries. More... | |
Macros | |
| #define | _CRT_SECURE_NO_WARNINGS |
Functions | |
| static char * | xstrdup (const char *s) |
| Duplicate a string with malloc(). | |
| static char * | trim_left (char *s) |
| Skip leading spaces and tabs in a string. | |
| static void | trim_right_inplace (char *s) |
| Remove trailing spaces, tabs, and line endings from a string in-place. | |
| static void | unquote_and_unescape_inplace (char *s) |
| Remove surrounding quotes and process escape sequences in-place. | |
| static char * | trim (char *s) |
| Trim both left and right whitespace in-place. | |
| int | env_load (const char *path) |
| Load environment variables from a .env file. | |
| const char * | env_get (const char *key) |
| Get value of an environment variable loaded from .env. | |
| static int | inject_single (const char *k, const char *v, int overwrite) |
| Inject a single key/value into the process environment. | |
| int | env_inject_all (int overwrite) |
| Inject all loaded .env variables into the process environment. | |
| void | env_free (void) |
| Free all memory used by loaded .env variables. | |
Variables | |
| static EnvEntry * | entries =NULL |
| static size_t | entry_count =0 |
| #define _CRT_SECURE_NO_WARNINGS |
| void env_free | ( | void | ) |
Free all memory used by loaded .env variables.
Free all loaded environment variable data.
| const char * env_get | ( | const char * | key | ) |
Get value of an environment variable loaded from .env.
Get value of a loaded environment variable.
| key | Environment variable key. |
| int env_inject_all | ( | int | overwrite | ) |
Inject all loaded .env variables into the process environment.
Inject all loaded environment variables into the process environment.
| overwrite | Nonzero to overwrite existing system variables. |
| int env_load | ( | const char * | path | ) |
Load environment variables from a .env file.
Lines beginning with # are treated as comments and ignored. Keys and values are separated by =.
| path | Path to .env file. |
|
static |
Inject a single key/value into the process environment.
On Windows uses _putenv_s(). On POSIX uses setenv().
| k | Key. |
| v | Value. |
| overwrite | Nonzero to overwrite existing. |
|
static |
Trim both left and right whitespace in-place.
| s | Input string. |
|
static |
Skip leading spaces and tabs in a string.
| s | Input string (modifiable). |
s.
|
static |
Remove trailing spaces, tabs, and line endings from a string in-place.
| s | Input string (modified in place). |
|
static |
Remove surrounding quotes and process escape sequences in-place.
Surrounding single or double quotes are stripped if present. Recognizes:
\n → newline\r → carriage return\t → tab\\ → backslash\" → double quote| s | Input string (modified in place). |
|
static |
Duplicate a string with malloc().
| s | Input string (can be NULL). |
s, or NULL if s is NULL or malloc fails.
|
static |
|
static |