Crinit -- Configurable Rootfs Init
|
Implementation of type- and target-specific handler functions for configuration parsing. More...
#include "confhdl.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "common.h"
#include "confconv.h"
#include "globopt.h"
#include "lexers.h"
#include "logio.h"
Macros | |
#define | crinitCfgHandlerTypeCheck(t) |
Functions | |
static int | crinitCfgHandlerSetTaskOptFromStr (crinitTaskOpts_t *tgt, crinitTaskOpts_t opt, const char *val) |
static void * | crinitCfgHandlerManageArrayMem (void *dynArr, size_t elementSize, size_t curSize, size_t reqSize) |
static bool | crinitDirExists (const char *path) |
int | crinitCfgCmdHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgDepHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgPrvHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgEnvHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgFilterHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgIoRedirHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgNameHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgRespHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgRespRetHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitTaskIncludeHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgDebugHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgInclSuffixHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgInclDirHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgShdGpHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgTaskSuffixHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgTaskDirHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgTaskDirSlHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgTasksHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgSyslogHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgElosHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgElosServerHandler (void *tgt, const char *val, crinitConfigType_t type) |
int | crinitCfgElosPortHandler (void *tgt, const char *val, crinitConfigType_t type) |
Implementation of type- and target-specific handler functions for configuration parsing.
#define crinitCfgHandlerTypeCheck | ( | t | ) |
Macro to assert that the given crinitConfigType_t in a crinitConfigHandler_t has a specific value.
t | The target value of the parameter type . If unequal to the value given to the encompassing function, the function will print an error and return -1. |
int crinitCfgCmdHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for COMMAND
config directives. See crinitConfigHandler_t.
int crinitCfgDebugHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for DEBUG
config directives. See crinitConfigHandler_t.
int crinitCfgDepHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for DEPENDS
config directives. See crinitConfigHandler_t.
int crinitCfgElosHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for USE_ELOS
config directives. See crinitConfigHandler_t.
int crinitCfgElosPortHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for ELOS_PORT
config directives. See crinitConfigHandler_t.
int crinitCfgElosServerHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for ELOS_SERVER
config directives. See crinitConfigHandler_t.
int crinitCfgEnvHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for ENV_SET
config directives. See crinitConfigHandler_t.
int crinitCfgFilterHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for FILTER_DEFINE
config directives. See crinitConfigHandler_t.
|
inlinestatic |
(Re-)allocate memory for generic arrays.
Given current size of an array and required size, the function will allocate/grow the array. Shrinking is unsupported and will lead to an error being returned. Initializes newly allocated memory to 0.
dynArr | The array to reallocate or NULL if we want a new array. |
elementSize | Size of a single element in the array. |
curSize | Current number of elements in the array. |
reqSize | Required number of elements in the array. |
|
inlinestatic |
Helper function to set a bitmask value in crinitTask_t::opts.
tgt | Direct pointer to the crinitTaskOpts_t inside an crinitTask_t which shall be modified. |
opt | Bitmask of the task option to be set, one of CRINIT_TASK_OPT_* |
val | The string value indicating if the bit should be set or unset. Uses crinitConfConvToBool(). |
int crinitCfgInclDirHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for INCLUDEDIR
config directives. See crinitConfigHandler_t.
int crinitCfgInclSuffixHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for INCLUDE_SUFFIX
config directives. See crinitConfigHandler_t.
int crinitCfgIoRedirHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for IO_REDIRECT
config directives. See crinitConfigHandler_t.
int crinitCfgNameHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for NAME
config directives. See crinitConfigHandler_t.
int crinitCfgPrvHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for PROVIDES
config directives. See crinitConfigHandler_t.
int crinitCfgRespHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for RESPAWN
config directives. See crinitConfigHandler_t.
int crinitCfgRespRetHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for RESPAWN_RETRIES
config directives. See crinitConfigHandler_t.
int crinitCfgShdGpHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for SHUTDOWN_GRACE_PERIOD_US
config directives. See crinitConfigHandler_t.
int crinitCfgSyslogHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for USE_SYSLOG
config directives. See crinitConfigHandler_t.
int crinitCfgTaskDirHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for TASKDIR
config directives. See crinitConfigHandler_t.
int crinitCfgTaskDirSlHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for TASKDIR_FOLLOW_SYMLINKS
config directives. See crinitConfigHandler_t.
int crinitCfgTasksHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for TASKS
config directives. See crinitConfigHandler_t.
int crinitCfgTaskSuffixHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for TASK_SUFFIX
config directives. See crinitConfigHandler_t.
|
static |
Check if a path exists, is accessible, and a directory.
Uses stat() with S_ISDIR().
path | The path to check. |
int crinitTaskIncludeHandler | ( | void * | tgt, |
const char * | val, | ||
crinitConfigType_t | type | ||
) |
Handler for INCLUDE
config directives. See crinitConfigHandler_t.