conf: improve configuration file parsing

* Strip whitespaces from keys and values
* Detect (and ignore) comments
* Detect syntax errors (no value specified etc)
* Error out on syntax errors and invalid keys
This commit is contained in:
Daniel Eklöf 2019-07-17 10:12:14 +02:00
parent c11cc2be57
commit de575ac58e
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 66 additions and 16 deletions

View file

@ -1,9 +1,11 @@
#pragma once
#include <stdbool.h>
struct config {
char *shell;
char *font;
};
struct config config_load(void);
bool config_load(struct config *conf);
void config_free(struct config conf);