From d8192f73672488234bd12319229402153e7b6c21 Mon Sep 17 00:00:00 2001 From: pommicket Date: Sun, 14 Sep 2025 00:33:18 -0400 Subject: pom_conf_print implementation --- pom.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'pom.c') diff --git a/pom.c b/pom.c index 7fc754f..5a4433f 100644 --- a/pom.c +++ b/pom.c @@ -2,7 +2,6 @@ TODO: - error_to_string - conf_copy -- conf_print - typed get functions */ #include "pom.h" @@ -1412,3 +1411,31 @@ pom_conf_merge(pom_conf *conf, const pom_conf *other) { *conf = new_conf; return true; } + +void +pom_conf_print(const pom_conf *conf) { + const pom_item *item; + pom_item_iter *iter = NULL; + while ((item = pom_conf_next_item(conf, &iter))) { + printf("%s: \"", item->key); + char c; + for (const char *p = item->value; (c = *p); p++) { + if (c == '\n') { + printf("\\n"); + } else if (c == '\t') { + printf("\\t"); + } else if (c == '\r') { + printf("\\r"); + } else if (c == '\\') { + printf("\\\\"); + } else if (c == '"') { + printf("\\\""); + } else if (c < 0x20) { + printf("\\x%02X", c); + } else { + putchar(c); + } + } + printf("\"\n"); + } +} -- cgit v1.2.3