htils 1
A small set of utilities for C programming.
Loading...
Searching...
No Matches
dotenv.h File Reference
#include <htils/arena.h>
#include <htils/basictypes.h>
#include <htils/string.h>

Go to the source code of this file.

Functions

i32 htils_dotenv_load (arena_t *arena, const string *path)
 Load environment variables from a .env file.

Function Documentation

◆ htils_dotenv_load()

i32 htils_dotenv_load ( arena_t * arena,
const string * path )

Load environment variables from a .env file.

Parses KEY=VALUE lines and sets each as a process environment variable with setenv() (overwriting). path may be the .env file itself, or a directory containing one, in which case the first .env found is used.

Parameters
arenaThe arena to allocate from.
pathThe .env file, or a directory to search for one.
Precondition
  • path and arena must be valid and not null.
  • path must exist.
Returns
The number of variables loaded, or -1 on failure.