|
MRTKLIB 0.7.14
Modernized GNSS Positioning Library
|
#include "mrtklib/mrtk_toml.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/stat.h>#include "mrtklib/mrtk_const.h"#include "mrtklib/mrtk_trace.h"#include "tomlc99/toml.h"Go to the source code of this file.
Classes | |
| struct | toml_map_t |
| struct | toml_alias_t |
Functions | |
| static toml_table_t * | navigate_table (toml_table_t *root, const char *path) |
| Navigate to a nested TOML table by dotted path. | |
| static int | is_known_key (const char *section, const char *key) |
| Report whether a section.key pair is recognized by the loader. | |
| static void | check_unknown_keys (toml_table_t *tab, const char *path) |
| Recursively walk a parsed TOML table and warn on unrecognized keys. Sub-tables extend the dotted section path; scalar/array leaves are checked against is_known_key(). Catches values silently dropped because their section.key is not in the mapping (typo or stale name). | |
| static int | toml_val_to_str (toml_table_t *tbl, const char *key, char *buf, int bufsz) |
| Read a TOML key value and convert to string representation compatible with str2opt(). | |
| static int | navsys_stricmp (const char *a, const char *b) |
| static int | navsys_str2mask (const char *name) |
| int | loadopts_toml (const char *file, opt_t *opts) |
| Load options from a TOML configuration file. | |
| int | saveopts_toml (const char *file, const char *comment, const opt_t *opts) |
| Save options to a TOML configuration file. | |
Variables | |
| static const toml_map_t | toml_mapping [] |
| static const toml_alias_t | toml_alias [] |
| static const char *const | toml_app_sections [] = {"cssr2rtcm3", "signal_remap", NULL} |
|
static |
Recursively walk a parsed TOML table and warn on unrecognized keys. Sub-tables extend the dotted section path; scalar/array leaves are checked against is_known_key(). Catches values silently dropped because their section.key is not in the mapping (typo or stale name).
| [in] | tab | TOML table to walk. |
| [in] | path | Dotted section path accumulated so far ("" at the root). |
Definition at line 455 of file mrtk_toml.c.
References check_unknown_keys(), is_known_key(), toml_key_in(), toml_table_in(), toml_table_narr(), toml_table_nkval(), and toml_table_ntab().
Referenced by check_unknown_keys(), and loadopts_toml().
|
static |
Report whether a section.key pair is recognized by the loader.
| [in] | section | Dotted TOML section path. |
| [in] | key | Leaf key name. |
Definition at line 420 of file mrtk_toml.c.
References toml_alias_t::old_key, toml_alias_t::old_section, toml_alias, toml_app_sections, toml_map_t::toml_key, toml_mapping, and toml_map_t::toml_section.
Referenced by check_unknown_keys().
|
extern |
Load options from a TOML configuration file.
| [in] | file | Path to the TOML file. |
| [out] | opts | Options table (sysopts[]-compatible, terminated by empty name). |
Reads a TOML file and maps semantic section.key paths to legacy option names in the opts table. Unknown TOML keys are silently skipped.
Definition at line 608 of file mrtk_toml.c.
References check_unknown_keys(), free, toml_alias_t::legacy_name, toml_map_t::legacy_name, MAXSTRPATH, navigate_table(), navsys_str2mask(), toml_alias_t::new_key, toml_alias_t::new_section, toml_datum_t::ok, toml_alias_t::old_key, toml_alias_t::old_section, toml_datum_t::s, searchopt(), str2opt(), toml_alias, toml_array_in(), toml_array_nelem(), toml_free(), toml_map_t::toml_key, toml_key_exists(), toml_mapping, toml_parse_file(), toml_map_t::toml_section, toml_string_at(), toml_val_to_str(), trace(), toml_datum_t::u, and opt_t::var.
Referenced by loadopts().
|
static |
Navigate to a nested TOML table by dotted path.
| [in] | root | Root TOML table. |
| [in] | path | Dotted path (e.g. "positioning.atmosphere"). |
Definition at line 386 of file mrtk_toml.c.
References toml_table_in().
Referenced by loadopts_toml().
|
static |
Definition at line 588 of file mrtk_toml.c.
References navsys_stricmp(), SYS_CMP, SYS_GAL, SYS_GLO, SYS_GPS, SYS_IRN, SYS_QZS, and SYS_SBS.
Referenced by loadopts_toml().
|
static |
Definition at line 579 of file mrtk_toml.c.
Referenced by navsys_str2mask().
|
extern |
Save options to a TOML configuration file.
| [in] | file | Path to the output TOML file. |
| [in] | comment | Header comment (NULL for none). |
| [in] | opts | Options table (terminated by empty name). |
Definition at line 785 of file mrtk_toml.c.
References opt_t::format, toml_map_t::legacy_name, opt2str(), searchopt(), toml_map_t::toml_key, toml_mapping, toml_map_t::toml_section, and trace().
Referenced by saveopts().
|
static |
Read a TOML key value and convert to string representation compatible with str2opt().
| [in] | tbl | TOML table containing the key. |
| [in] | key | Key name within the table. |
| [out] | buf | Buffer to receive the string value. |
| [in] | bufsz | Size of buf. |
Definition at line 490 of file mrtk_toml.c.
References toml_datum_t::b, toml_datum_t::d, free, toml_datum_t::i, toml_datum_t::ok, toml_datum_t::s, toml_array_in(), toml_array_nelem(), toml_bool_in(), toml_double_at(), toml_double_in(), toml_int_at(), toml_int_in(), toml_string_at(), toml_string_in(), and toml_datum_t::u.
Referenced by loadopts_toml().
|
static |
Definition at line 340 of file mrtk_toml.c.
Referenced by is_known_key(), and loadopts_toml().
|
static |
Definition at line 376 of file mrtk_toml.c.
Referenced by is_known_key().
|
static |
Definition at line 30 of file mrtk_toml.c.
Referenced by is_known_key(), loadopts_toml(), and saveopts_toml().