|
Crinit -- Configurable Rootfs Init
|
Implementation file related to working with environment variable sets. More...
#include "envset.h"#include <stdlib.h>#include <string.h>#include "confconv.h"#include "lexers.h"#include "logio.h"
Functions | |
| static int | crinitEnvSetGrow (crinitEnvSet_t *es) |
| static ssize_t | crinitEnvSetSearch (const crinitEnvSet_t *es, const char *envName) |
| int | crinitEnvSetInit (crinitEnvSet_t *es, size_t initSize, size_t sizeIncrement) |
| int | crinitEnvSetDestroy (crinitEnvSet_t *es) |
| int | crinitEnvSetDup (crinitEnvSet_t *copy, const crinitEnvSet_t *orig) |
| static char * | crinitEnvSetGetVal (const crinitEnvSet_t *es, const size_t idx) |
| static int | crinitEnvSetValid (const crinitEnvSet_t *es) |
| const char * | crinitEnvSetGet (const crinitEnvSet_t *es, const char *envName) |
| int | crinitEnvSetSet (crinitEnvSet_t *es, const char *envName, const char *envVal) |
Implementation file related to working with environment variable sets.
| int crinitEnvSetDestroy | ( | crinitEnvSet_t * | es | ) |
Frees the memory associated with an environment set.
Will free all pointers allocated through crinitEnvSetInit() and crinitEnvSetSet().
| es | The environment set to free. |
| int crinitEnvSetDup | ( | crinitEnvSet_t * | copy, |
| const crinitEnvSet_t * | orig | ||
| ) |
Duplicates an environment set.
Will have the same allocation parameter and same content but point to different memory.
| copy | The crinitEnvSet_t to copy to, must be uninitialized or freed via crinitEnvSetDestroy(). |
| orig | The crinitEnvSet_t to copy from, must have been initialized. |
| const char * crinitEnvSetGet | ( | const crinitEnvSet_t * | es, |
| const char * | envName | ||
| ) |
Gets the value for a given variable from an environment set.
| es | The environment set to search in. |
| envName | The name of the variable to look for. |
|
inlinestatic |
|
static |
Grows an environment set according to its size increment.
Used by crinitEnvSetSet() if not enough space is left in the set.
| es | The environment set to grow, must be initialized. |
| int crinitEnvSetInit | ( | crinitEnvSet_t * | es, |
| size_t | initSize, | ||
| size_t | sizeIncrement | ||
| ) |
Initializes an environment set.
Will initialize es such that crinitEnvSet_t::envp has allocated space for initSize pointers to char and crinitEnvSet_t::allocSz, crinitEnvSet_t::allocInc reflect the given parameters.
| es | The environment set to initialize. |
| initSize | The allocation size of the initialized environment set. |
| sizeIncrement | The increment to add to the allocation size if we run out of space. |
|
static |
Searches for a given environment variable and returns its index in the set if found.
| es | The environment set to search in. |
| envName | Then name of the variable to search for. |
| int crinitEnvSetSet | ( | crinitEnvSet_t * | es, |
| const char * | envName, | ||
| const char * | envVal | ||
| ) |
Sets the value for a given variable in an environment set.
Creates a new variable if no variable with the given name yet exists in the set. Otherwise an existing variable with the same name will be overwritten.
If a new variable is created and the allocation size of the set is not sufficient, the set will be grown by the size increment.
| es | The environment set to be modified, must be initialized. |
| envName | The name of the variable to be set. |
| envVal | The content of the variable to be set. |
|
inlinestatic |