summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-18 14:55:10 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-18 14:55:10 -0500
commit8f039627ab777d2b08c0c46d5acacbe84817d20f (patch)
tree0ac67f93e41e29b2b5da836df2bdef54e037947f /config.c
parente239b66691200163c1983b645c28b34825f32ea4 (diff)
:build working (i think)
Diffstat (limited to 'config.c')
-rw-r--r--config.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/config.c b/config.c
index 9589749..23fe5c9 100644
--- a/config.c
+++ b/config.c
@@ -169,6 +169,11 @@ void config_read(Ted *ted, char const *filename) {
char const *name;
u16 *control, min, max;
} OptionU16;
+ typedef struct {
+ char const *name;
+ char *control;
+ size_t buf_size;
+ } OptionString;
// core options
// (these go at the start so they don't need to be re-computed each time)
OptionBool const options_bool[] = {
@@ -195,6 +200,9 @@ void config_read(Ted *ted, char const *filename) {
{"max-menu-width", &settings->max_menu_width, 10, U16_MAX},
{"error-display-time", &settings->error_display_time, 0, U16_MAX},
};
+ OptionString const options_string[] = {
+ {"build-default-command", settings->build_default_command, sizeof settings->build_default_command},
+ };
FILE *fp = fopen(filename, "rb");
if (fp) {
@@ -377,6 +385,17 @@ void config_read(Ted *ted, char const *filename) {
config_err(cfg, "Invalid %s: %s. This should be a number from %g to %g.", option->name, value, option->min, option->max);
}
}
+
+ for (size_t i = 0; i < arr_count(options_string); ++i) {
+ OptionString const *option = &options_string[i];
+ if (streq(key, option->name)) {
+ if (strlen(value) >= option->buf_size) {
+ config_err(cfg, "%s is too long (length: %zu, maximum length: %zu).", key, strlen(value), option->buf_size - 1);
+ } else {
+ str_cpy(option->control, option->buf_size, value);
+ }
+ }
+ }
} break;
}