diff options
-rw-r--r-- | include/config.h | 8 | ||||
-rw-r--r-- | src/config.c | 28 |
2 files changed, 36 insertions, 0 deletions
diff --git a/include/config.h b/include/config.h new file mode 100644 index 0000000..035a10c --- /dev/null +++ b/include/config.h @@ -0,0 +1,8 @@ +#ifndef __CONFIG_H +#define __CONFIG_H + +#define DELIM "=>" + +void config_parse(char *content); + +#endif diff --git a/src/config.c b/src/config.c new file mode 100644 index 0000000..2b05ad6 --- /dev/null +++ b/src/config.c @@ -0,0 +1,28 @@ +#define _GNU_SOURCE + +#include <config.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <util.h> + +void +config_parse(char *content) +{ + char *buffer = strdup(content); + + char *line_internal = strtok(buffer, "\n"); + while (line_internal != NULL) { + char *line = strdup(line_internal); + char *key = strsep(&line, "="); + line = trim(line); + key = trim(key); + + printf("Key: %s\n", key); + printf("Value: %s\n", line); + + line_internal = strtok(NULL, "\n"); + } + + free(buffer); +} |