diff options
| author | Albert Cervin <albert@acervin.com> | 2023-05-18 23:51:51 +0200 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2023-05-24 22:18:12 +0200 |
| commit | 4f3b576db6b01c8c88076985478e2a7fa37be340 (patch) | |
| tree | 9723ed39a19872fd52f2867613e78e02de3cf79b /src/dged/settings.h | |
| parent | a4d17ddb8e7d23ccca13132f4d88cfc5f5730b76 (diff) | |
| download | dged-4f3b576db6b01c8c88076985478e2a7fa37be340.tar.gz dged-4f3b576db6b01c8c88076985478e2a7fa37be340.tar.xz dged-4f3b576db6b01c8c88076985478e2a7fa37be340.zip | |
TOML settings parsing
Currently a very simplistic parser that do not support all TOML
datatypes. Supported are:
- Tables
- Strings (incl multiline)
- Integers
- Inline Tables
- Booleans
- Comments
Diffstat (limited to 'src/dged/settings.h')
| -rw-r--r-- | src/dged/settings.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/dged/settings.h b/src/dged/settings.h index 5d245d9..80f6b0f 100644 --- a/src/dged/settings.h +++ b/src/dged/settings.h @@ -135,3 +135,25 @@ void setting_set_value(struct setting *setting, struct setting_value val); * @param n Size in bytes of @ref buf. */ void setting_to_string(struct setting *setting, char *buf, size_t n); + +/** + * Parse settings from a string in TOML format. + * + * @param toml Pointer to a NULL-terminated string containing TOML settings. + * @param errmsgs Pointer to a string array where error messages will be placed. These + * messages must be freed after use. + * @returns 0 on success, n > 0 where n denotes the number of error messages in + * @ref errmsgs + */ +int32_t settings_from_string(const char *toml, char **errmsgs[]); + +/** + * Parse settings from a file in TOML format. + * + * @param toml Pointer to a NULL-terminated string describing a path to a TOML file with settings. + * @param errmsgs Pointer to a string array where error messages will be placed. These + * messages must be freed after use. + * @returns 0 on success, n > 0 where n denotes the number of error messages in + * @ref errmsgs + */ +int32_t settings_from_file(const char *path, char **errmsgs[]); |
