|
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
|
Minimal key = value configuration-file loader. More...
#include "safecomm/config/config.h"#include <ctype.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <strings.h>Go to the source code of this file.
Functions | |
| static char * | trim (char *s) |
| static void | strip_inline_comment (char *s) |
| static bool | store_entry (safecomm_config_t *cfg, const char *key, const char *value) |
| safecomm_status_t | safecomm_config_load (const char *path, safecomm_config_t *out) |
Load path into out (fully overwrites it). | |
| const char * | safecomm_config_get_str (const safecomm_config_t *cfg, const char *key) |
Raw string value for key. | |
| safecomm_status_t | safecomm_config_get_u32 (const safecomm_config_t *cfg, const char *key, uint32_t *out) |
Unsigned-integer value for key. | |
| 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). | |
Minimal key = value configuration-file loader.
Non-vital: performs syntax parsing only. Every consumer range-checks the values it reads (see docs/architecture/ADR-002).
Definition in file config.c.
|
static |
|
static |
|
static |
| safecomm_status_t safecomm_config_load | ( | const char * | path, |
| safecomm_config_t * | out ) |
Load path into out (fully overwrites it).
Reads at most SAFECOMM_CONFIG_MAX_ENTRIES key = value lines. Blank lines and lines whose first non-space character is '#' are skipped. Leading/trailing whitespace is trimmed from both key and value; an inline # ... comment after the value is stripped. No semantic checks.
| path | file path (NUL-terminated). Non-NULL. |
| out | receives the parsed entries. Non-NULL. |
| const char * safecomm_config_get_str | ( | const safecomm_config_t * | cfg, |
| const char * | key ) |
| safecomm_status_t safecomm_config_get_u32 | ( | const safecomm_config_t * | cfg, |
| const char * | key, | ||
| uint32_t * | out ) |
Unsigned-integer value for key.
| cfg | loaded config. Non-NULL. |
| key | flat "group.name". Non-NULL. |
| out | receives the value on success. Non-NULL. |
| safecomm_status_t safecomm_config_get_bool | ( | const safecomm_config_t * | cfg, |
| const char * | key, | ||
| bool * | out ) |