Crinit -- Configurable Rootfs Init
|
Definitions related to conversion operations from configuration values to structured data. More...
Go to the source code of this file.
Macros | |
#define | crinitConfConvToInteger(out, confVal, base) |
Functions | |
char ** | crinitConfConvToStrArr (int *numElements, const char *confVal, bool doubleQuoting) |
int | crinitConfConvToIoRedir (crinitIoRedir_t *ior, const char *confVal) |
int | crinitConfConvToEnvSetMember (crinitEnvSet_t *es, const char *confVal) |
int | crinitConfConvToIntegerI (int *x, const char *confVal, int base) |
int | crinitConfConvToIntegerULL (unsigned long long *x, const char *confVal, int base) |
int | crinitConfConvToBool (bool *b, const char *confVal) |
Definitions related to conversion operations from configuration values to structured data.
#define crinitConfConvToInteger | ( | out, | |
confVal, | |||
base | |||
) |
Type-generic macro for string to integer conversion.
Currently only implemented for int
and unsigned long long
.
out | Output pointer, type-generic (but must be a pointer). |
confVal | The string to convert. |
base | The decimal base to use in conversion. |
int crinitConfConvToBool | ( | bool * | b, |
const char * | confVal | ||
) |
Converts a string to bool.
String must be equal to either NO
(==false
) or YES
(==true
).
b | Output pointer to bool variable. |
confVal | The string to convert. |
int crinitConfConvToEnvSetMember | ( | crinitEnvSet_t * | es, |
const char * | confVal | ||
) |
Parses a single ENV_SET directive and sets the variable in question accordingly.
For details on the syntax, see the relevant section in README.md.
es | The environment set to be modified, must be initialized. |
confVal | The ENV_SET directive to be parsed and "executed" on the set. |
int crinitConfConvToIntegerI | ( | int * | x, |
const char * | confVal, | ||
int | base | ||
) |
Converts a string to a signed integer, see crinitConfConvToInteger()
int crinitConfConvToIntegerULL | ( | unsigned long long * | x, |
const char * | confVal, | ||
int | base | ||
) |
Converts a string to an unsigned long long, see crinitConfConvToInteger()
int crinitConfConvToIoRedir | ( | crinitIoRedir_t * | ior, |
const char * | confVal | ||
) |
Initializes an instance of crinitIoRedir_t from an IO redirection statement in a string.
The string must be of the form
Where REDIRECT_FROM is one of STDOUT, STDERR, STDIN and REDIRECT_TO may either also be one of those streams or an absolute path to a file. APPEND or TRUNCATE signify whether an existing file at that location should be appended to or truncated. Default ist TRUNCATE. OCTAL MODE sets the permission bits if the file is newly created. Default is 0644.
The function may allocate memory inside the crinitIoRedir_t struct which must be freed using crinitDestroyIoRedir().
ior | The crinitIoRedir_t instance to initialize. |
confVal | The string with the statement to parse. |
char** crinitConfConvToStrArr | ( | int * | numElements, |
const char * | confVal, | ||
bool | doubleQuoting | ||
) |
Extract an array of strings from the value mapped to an indexed key in an crinitConfKvList_t.
Will split confVal along spaces. Will optionally respect quoting using double quotes if doubleQuoting is set to true. A dynamically-allocated array-of-strings is returned. If no longer needed it should be freed using crinitFreeArgvArray(). numElements will contain the number of strings inside the output array and the output array will be additionally NULL-terminated, same as argc/argv in main()
.
numElements | Will contain the number of strings in the output. |
confVal | The string to split. |
doubleQuoting | If true, crinitConfConvToStrArr will respect quoting with double quotes. |