Crinit -- Configurable Rootfs Init
Loading...
Searching...
No Matches
globopt.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
7#ifndef __GLOBOPT_H__
8#define __GLOBOPT_H__
9
10#include <stdbool.h>
11#include <string.h>
12
13#include "envset.h"
14
38
39#define CRINIT_GLOBOPT_DEBUG debug
40#define CRINIT_GLOBOPT_USE_SYSLOG useSyslog
41#define CRINIT_GLOBOPT_USE_ELOS useElos
42#define CRINIT_GLOBOPT_ELOS_EVENT_POLL_INTERVAL elosEventPollInterval
43#define CRINIT_GLOBOPT_ELOS_PORT elosPort
44#define CRINIT_GLOBOPT_ELOS_SERVER elosServer
45#define CRINIT_GLOBOPT_INCLDIR inclDir
46#define CRINIT_GLOBOPT_INCL_SUFFIX inclSuffix
47#define CRINIT_GLOBOPT_TASKDIR taskDir
48#define CRINIT_GLOBOPT_TASKDIR_FOLLOW_SYMLINKS taskDirFollowSl
49#define CRINIT_GLOBOPT_TASK_FILE_SUFFIX taskFileSuffix
50#define CRINIT_GLOBOPT_TASKS tasks
51#define CRINIT_GLOBOPT_LAUNCHER_CMD launcherCmd
52#define CRINIT_GLOBOPT_SHDGRACEP shdGraceP
53#define CRINIT_GLOBOPT_ENV globEnv
54#define CRINIT_GLOBOPT_FILTERS globFilters
55#define CRINIT_GLOBOPT_SIGNATURES signatures
56#define CRINIT_GLOBOPT_SIGKEYDIR sigKeyDir
57
59static crinitGlobOptStore_t crinitGenericGlobOptHelper __attribute__((unused));
60
61// clang-format off
62// Rationale: Used version of clang-format does not format _Generic macros correctly. This is a known bug and has been
63// fixed very recently. We may remove this exemption once we are on the new clang version as standard.
64// See: https://github.com/llvm/llvm-project/issues/18080
77#define crinitGlobOptGet(globOptMember, retPtr) \
78 _Generic((crinitGenericGlobOptHelper.globOptMember), \
79 char * : crinitGlobOptGetString, \
80 bool : crinitGlobOptGetBoolean, \
81 int : crinitGlobOptGetInteger, \
82 unsigned long long : crinitGlobOptGetUnsignedLL, \
83 crinitEnvSet_t : crinitGlobOptGetEnvSet) \
84 ((offsetof(crinitGlobOptStore_t, globOptMember)), (retPtr))
96#define crinitGlobOptSet(globOptMember, val) \
97 _Generic((crinitGenericGlobOptHelper.globOptMember), \
98 char * : crinitGlobOptSetString, \
99 const char * : crinitGlobOptSetString, \
100 bool : crinitGlobOptSetBoolean, \
101 int : crinitGlobOptSetInteger, \
102 unsigned long long : crinitGlobOptSetUnsignedLL, \
103 crinitEnvSet_t : crinitGlobOptSetEnvSet) \
104 ((offsetof(crinitGlobOptStore_t, globOptMember)), (val))
105// clang-format on
106
115
121void crinitGlobOptDestroy(void);
122
138int crinitGlobOptRemit(void);
139
151int crinitGlobOptSetString(size_t memberOffset, const char *val);
163int crinitGlobOptSetBoolean(size_t memberOffset, bool val);
175int crinitGlobOptSetInteger(size_t memberOffset, int val);
187int crinitGlobOptSetUnsignedLL(size_t memberOffset, unsigned long long val);
199int crinitGlobOptSetEnvSet(size_t memberOffset, const crinitEnvSet_t *val);
200
215int crinitGlobOptGetString(size_t memberOffset, char **val);
227int crinitGlobOptGetBoolean(size_t memberOffset, bool *val);
239int crinitGlobOptGetInteger(size_t memberOffset, int *val);
251int crinitGlobOptGetUnsignedLL(size_t memberOffset, unsigned long long *val);
263int crinitGlobOptGetEnvSet(size_t memberOffset, crinitEnvSet_t *val);
264
265#endif /* __GLOBOPT_H__ */
Header defining data types and functions to work with sets of environment variables.
int crinitGlobOptGetBoolean(size_t memberOffset, bool *val)
Definition globopt.c:166
int crinitGlobOptGetInteger(size_t memberOffset, int *val)
Definition globopt.c:188
int crinitGlobOptRemit(void)
Definition globopt.c:268
int crinitGlobOptSetString(size_t memberOffset, const char *val)
Definition globopt.c:114
int crinitGlobOptInitDefault(void)
Definition globopt.c:40
int crinitGlobOptSetEnvSet(size_t memberOffset, const crinitEnvSet_t *val)
Definition globopt.c:221
int crinitGlobOptGetString(size_t memberOffset, char **val)
Definition globopt.c:133
crinitGlobOptStore_t * crinitGlobOptBorrow(void)
Definition globopt.c:260
int crinitGlobOptGetEnvSet(size_t memberOffset, crinitEnvSet_t *val)
Definition globopt.c:243
int crinitGlobOptSetBoolean(size_t memberOffset, bool val)
Definition globopt.c:155
int crinitGlobOptGetUnsignedLL(size_t memberOffset, unsigned long long *val)
Definition globopt.c:210
void crinitGlobOptDestroy(void)
Definition globopt.c:279
int crinitGlobOptSetInteger(size_t memberOffset, int val)
Definition globopt.c:177
static crinitGlobOptStore_t crinitGenericGlobOptHelper __attribute__((unused))
int crinitGlobOptSetUnsignedLL(size_t memberOffset, unsigned long long val)
Definition globopt.c:199
Definition envset.h:25
Definition globopt.h:18
int elosPort
Value for the ELOS_PORT global option.
Definition globopt.h:25
unsigned long long elosEventPollInterval
Value for the ELOS_EVENT_POLL_INTERVAL global option.
Definition globopt.h:24
crinitEnvSet_t globFilters
Storage for global task filter variables.
Definition globopt.h:36
char * taskFileSuffix
Value for the TASK_FILE_SUFFIX global option.
Definition globopt.h:31
char * inclDir
Value for the INCLUDEDIR global option.
Definition globopt.h:27
char * launcherCmd
Value for the LAUNCHER_CMD global option.
Definition globopt.h:33
char * taskDir
Value for the TASKDIR global option.
Definition globopt.h:29
unsigned long long shdGraceP
Value for the SHUTDOWN_GRACE_PERIOD_US global option.
Definition globopt.h:34
char * elosServer
Value for the ELOS_SERVER global option.
Definition globopt.h:26
bool taskDirFollowSl
Value for the TASKDIR_FOLLOW_SYMLINKS global option.
Definition globopt.h:30
bool debug
Value for the DEBUG global option.
Definition globopt.h:19
bool useElos
Value for the USE_ELOS global option.
Definition globopt.h:21
crinitEnvSet_t globEnv
Storage for global task environment variables.
Definition globopt.h:35
bool signatures
Value for the crinit.signatures Kernel command line option.
Definition globopt.h:22
char * inclSuffix
Value for the INCLUDE_SUFFIX global option.
Definition globopt.h:28
bool useSyslog
Value for the USE_SYSLOG global option.
Definition globopt.h:20
char * sigKeyDir
Value for the crinit.sigkeydir Kernel command line option.
Definition globopt.h:23
char ** tasks
Value for the TASKS global option.
Definition globopt.h:32