Crinit -- Configurable Rootfs Init
confmap.c File Reference

(2023-08-28, commit: c9b21e6)

Implementation file related to mapping configuration options and their string representations. More...

#include "confmap.h"
#include <stdlib.h>
#include "common.h"
#include "logio.h"
Include dependency graph for confmap.c:

Functions

static int crinitCompareConfigMappings (const void *a, const void *b)
 
const crinitConfigMapping_tcrinitFindConfigMapping (const crinitConfigMapping_t *map, size_t mapSize, const char *keyStr)
 

Variables

const crinitConfigMapping_t crinitTaskCfgMap []
 
const size_t crinitTaskCfgMapSize = crinitNumElements(crinitTaskCfgMap)
 
const crinitConfigMapping_t crinitSeriesCfgMap []
 
const size_t crinitSeriesCfgMapSize = crinitNumElements(crinitSeriesCfgMap)
 

Detailed Description

Implementation file related to mapping configuration options and their string representations.

Function Documentation

◆ crinitCompareConfigMappings()

static int crinitCompareConfigMappings ( const void *  a,
const void *  b 
)
static

Comparison function between two crinitConfigMapping_t, for bsearch()

◆ crinitFindConfigMapping()

const crinitConfigMapping_t* crinitFindConfigMapping ( const crinitConfigMapping_t map,
size_t  mapSize,
const char *  keyStr 
)

Searches for an entry in an array of crinitConfigMapping_t by crinitConfigMapping_t::configKey.

Uses bsearch() with the assumption that the array is lexicographically ordered by crinitConfigMapping_t::configKey.

Parameters
mapThe array of crinitConfigMapping_t to search in.
mapSizeThe number of elements in the array to search.
keyStrThe name of the mapping to search for.

Variable Documentation

◆ crinitSeriesCfgMap

const crinitConfigMapping_t crinitSeriesCfgMap[]
Initial value:
= {
}
int crinitCfgFilterHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:241
int crinitCfgTasksHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:475
int crinitCfgDebugHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:359
int crinitCfgTaskDirHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:445
int crinitCfgTaskSuffixHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:430
int crinitCfgEnvHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:210
int crinitCfgElosPortHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:578
int crinitCfgShdGpHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:413
int crinitCfgInclSuffixHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:377
int crinitCfgElosServerHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:566
int crinitCfgInclDirHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:393
int crinitCfgTaskDirSlHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:463
int crinitCfgSyslogHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:532
int crinitCfgElosHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:549
#define CRINIT_CONFIG_KEYSTR_USE_SYSLOG
Config file key for USE_SYSLOG global option.
Definition: confparse.h:24
#define CRINIT_CONFIG_KEYSTR_INCLDIR
Config file key for INCLUDEDIR global option.
Definition: confparse.h:21
#define CRINIT_CONFIG_KEYSTR_TASKS
Config key for the list of task file names.
Definition: confparse.h:14
#define CRINIT_CONFIG_KEYSTR_ELOS_SERVER
Config file key for ELOS_SERVER global option.
Definition: confparse.h:26
#define CRINIT_CONFIG_KEYSTR_ELOS_PORT
Config file key for ELOS_PORT global option.
Definition: confparse.h:27
#define CRINIT_CONFIG_KEYSTR_TASKDIR
Config file key for TASKDIR global option.
Definition: confparse.h:20
#define CRINIT_CONFIG_KEYSTR_SHDGRACEP
Config file key for SHUTDOWN_GRACE_PERIOD_US global option.
Definition: confparse.h:22
#define CRINIT_CONFIG_KEYSTR_INCL_SUFFIX
Config file key for INCLUDE_SUFFIX global option.
Definition: confparse.h:28
#define CRINIT_CONFIG_KEYSTR_TASK_FILE_SUFFIX
Config key for the task file extension in dynamic configurations.
Definition: confparse.h:29
@ CRINIT_CONFIG_DEBUG
Definition: confparse.h:67
@ CRINIT_CONFIG_TASKS
Definition: confparse.h:85
@ CRINIT_CONFIG_USE_ELOS
Definition: confparse.h:87
@ CRINIT_CONFIG_TASKDIR_FOLLOW_SYMLINKS
Definition: confparse.h:84
@ CRINIT_CONFIG_FILTER_DEFINE
Definition: confparse.h:72
@ CRINIT_CONFIG_TASKDIR
Definition: confparse.h:83
@ CRINIT_CONFIG_ELOS_SERVER
Definition: confparse.h:70
@ CRINIT_CONFIG_USE_SYSLOG
Definition: confparse.h:86
@ CRINIT_CONFIG_ELOS_PORT
Definition: confparse.h:69
@ CRINIT_CONFIG_INCLUDE_SUFFIX
Definition: confparse.h:74
@ CRINIT_CONFIG_INCLUDEDIR
Definition: confparse.h:75
@ CRINIT_CONFIG_TASK_FILE_SUFFIX
Definition: confparse.h:82
@ CRINIT_CONFIG_SHDGRACEP
Definition: confparse.h:81
@ CRINIT_CONFIG_ENV_SET
Definition: confparse.h:71
#define CRINIT_CONFIG_KEYSTR_TASKDIR_SYMLINKS
configurations.
Definition: confparse.h:16
#define CRINIT_CONFIG_KEYSTR_ENV_SET
Config key to set an environment variable with.
Definition: confparse.h:34
#define CRINIT_CONFIG_KEYSTR_DEBUG
Config file key for DEBUG global option.
Definition: confparse.h:19
#define CRINIT_CONFIG_KEYSTR_FILTER_DEFINE
Config key to define an elos filter.
Definition: confparse.h:35
#define CRINIT_CONFIG_KEYSTR_USE_ELOS
Config file key for USE_ELOS global option.
Definition: confparse.h:25

Constant (at compile-time) array of mappings between series/global configuration names and their indices and properties.

Must be lexicographically ordered (by crinitConfigMapping_t::configKey), so that crinitFindConfigMapping() works. This is tested by a unit/regression test.

◆ crinitSeriesCfgMapSize

const size_t crinitSeriesCfgMapSize = crinitNumElements(crinitSeriesCfgMap)

Size of crinitSeriesCfgMap, known at compile-time.

◆ crinitTaskCfgMap

const crinitConfigMapping_t crinitTaskCfgMap[]
Initial value:
= {
}
int crinitCfgRespHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:308
int crinitCfgNameHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:296
int crinitCfgDepHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:90
int crinitCfgIoRedirHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:272
int crinitCfgRespRetHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:319
int crinitTaskIncludeHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:330
int crinitCfgPrvHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:143
int crinitCfgCmdHandler(void *tgt, const char *val, crinitConfigType_t type)
Definition: confhdl.c:68
#define CRINIT_CONFIG_KEYSTR_COMMAND
Config key to add a command to the task.
Definition: confparse.h:32
#define CRINIT_CONFIG_KEYSTR_NAME
Config key for the task name.
Definition: confparse.h:38
#define CRINIT_CONFIG_KEYSTR_IOREDIR
Config key for IO redirections.
Definition: confparse.h:37
@ CRINIT_CONFIG_INCLUDE
Definition: confparse.h:73
@ CRINIT_CONFIG_COMMAND
Definition: confparse.h:66
@ CRINIT_CONFIG_NAME
Definition: confparse.h:77
@ CRINIT_CONFIG_RESPAWN
Definition: confparse.h:79
@ CRINIT_CONFIG_PROVIDES
Definition: confparse.h:78
@ CRINIT_CONFIG_DEPENDS
Definition: confparse.h:68
@ CRINIT_CONFIG_RESPAWN_RETRIES
Definition: confparse.h:80
@ CRINIT_CONFIG_IOREDIR
Definition: confparse.h:76
#define CRINIT_CONFIG_KEYSTR_INCLUDE
Config key for file include directives.
Definition: confparse.h:36
#define CRINIT_CONFIG_KEYSTR_DEPENDS
Config key to add dependencies to the task.
Definition: confparse.h:33
#define CRINIT_CONFIG_KEYSTR_RESPAWN
Config key to set a task to be respawning.
Definition: confparse.h:40
#define CRINIT_CONFIG_KEYSTR_PROVIDES
Config key for provided features.
Definition: confparse.h:39
#define CRINIT_CONFIG_KEYSTR_RESPAWN_RETRIES
Config key to set how often a task is allowed to respawn on failure.
Definition: confparse.h:41

Constant (at compile-time) array of mappings between task-specific configuration names and their indices and properties.

Must be lexicographically ordered (by crinitConfigMapping_t::configKey), so that crinitFindConfigMapping() works. This is tested by a unit/regression test.

◆ crinitTaskCfgMapSize

const size_t crinitTaskCfgMapSize = crinitNumElements(crinitTaskCfgMap)

Size of crinitTaskCfgMap, known at compile-time.