Safe Communication Framework 0.1.0 build feea4f9
ERTMS/ETCS safe communication (Subset-037 EuroRadio, Subset-098 RBC/RBC), CENELEC EN 50128 SIL 4 oriented
Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
1
38#ifndef SAFECOMM_CONFIG_H
39#define SAFECOMM_CONFIG_H
40
41#include <stdbool.h>
42#include <stddef.h>
43#include <stdint.h>
44
45#include "safecomm/status.h"
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
52#define SAFECOMM_CONFIG_MAX_ENTRIES 64U
53#define SAFECOMM_CONFIG_MAX_KEY_LEN 64U
54#define SAFECOMM_CONFIG_MAX_VALUE_LEN 192U
55#define SAFECOMM_CONFIG_MAX_LINE_LEN 320U
56
58typedef struct
59{
60 char key[SAFECOMM_CONFIG_MAX_KEY_LEN];
61 char value[SAFECOMM_CONFIG_MAX_VALUE_LEN];
63
65typedef struct
66{
68 uint32_t count;
70
88
94const char *safecomm_config_get_str(const safecomm_config_t *cfg, const char *key);
95
105safecomm_status_t safecomm_config_get_u32(const safecomm_config_t *cfg, const char *key, uint32_t *out);
106
112safecomm_status_t safecomm_config_get_bool(const safecomm_config_t *cfg, const char *key, bool *out);
113
114#ifdef __cplusplus
115}
116#endif
117
118#endif /* SAFECOMM_CONFIG_H */
safecomm_status_t safecomm_config_load(const char *path, safecomm_config_t *out)
Load path into out (fully overwrites it).
Definition config.c:74
#define SAFECOMM_CONFIG_MAX_ENTRIES
Definition config.h:52
const char * safecomm_config_get_str(const safecomm_config_t *cfg, const char *key)
Raw string value for key.
Definition config.c:141
safecomm_status_t safecomm_config_get_bool(const safecomm_config_t *cfg, const char *key, bool *out)
Boolean value for key ("true"/"false"/"1"/"0", case-insensitive).
Definition config.c:178
safecomm_status_t safecomm_config_get_u32(const safecomm_config_t *cfg, const char *key, uint32_t *out)
Unsigned-integer value for key.
Definition config.c:159
Common status codes for the Safe Communication Framework.
safecomm_status_t
Result of a Safe Communication Framework operation.
Definition status.h:17
One parsed key/value pair.
Definition config.h:59
A loaded configuration file. Caller-allocated, opaque in use.
Definition config.h:66