update
This commit is contained in:
parent
8295df646f
commit
d9e6f8b3a3
5 changed files with 348 additions and 3 deletions
26
toml-parse.c
Normal file
26
toml-parse.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct {
|
||||
char api_key[128];
|
||||
char location[64];
|
||||
char units[16];
|
||||
} config_t;
|
||||
|
||||
static bool load_config_toml(config_t *cfg, const char *path) {
|
||||
|
||||
int main() {
|
||||
config_t cfg = {0};
|
||||
char config_path[512];
|
||||
snprintf(config_path, sizeof(config_path), "%s/.config/cclock/config", getenv("HOME"));
|
||||
|
||||
if (!load_config_toml(&cfg, config_path)) {
|
||||
printf("Failed to load config from %s\n", config_path);
|
||||
}
|
||||
|
||||
else if (load_config_toml(&cfg, config_path)) {
|
||||
printf("Loaded config from %s\n", config_path);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue