diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/parcini.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/parcini.c b/src/parcini.c index 6c19d7a..83b5de4 100644 --- a/src/parcini.c +++ b/src/parcini.c @@ -74,6 +74,33 @@ slicecpy(char *start, char *end, char **dst, size_t *dstn) return *dst; } +bool +parcini_value_handle(const struct parcini_value *value, + const enum parcini_value_type expected, void *dst) +{ + + if (value->type != expected) { + return false; + } + if(expected == PARCINI_VALUE_STRING) { + char **string = (char **)dst; + *string = strdup(value->value.string); + return true; + } + if(expected == PARCINI_VALUE_INTEGER) { + long int *integer = (long int *)dst; + *integer = value->value.integer; + return true; + } + if(expected == PARCINI_VALUE_BOOLEAN) { + bool *boolean = (bool *)dst; + *boolean = value->value.boolean; + return true; + } + + return false; +} + enum parcini_result parcini_parse_next_line(parcini_t *parser, struct parcini_line *parsed) { |