From 9bf5da82de7c19360c291d990814128a7b86c92e Mon Sep 17 00:00:00 2001 From: "Chloe M." Date: Sun, 23 Aug 2026 06:37:47 +0000 Subject: core: parser: Parse and emit define directives Signed-off-by: Chloe M. --- core/emit.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 core/emit.c (limited to 'core/emit.c') diff --git a/core/emit.c b/core/emit.c new file mode 100644 index 0000000..ec00ed2 --- /dev/null +++ b/core/emit.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2026, Apollo Telephone Laboratories. + * Provided under the BSD-3 clause. + */ + +#include +#include "defconf/emit.h" + +int +emit_data(const char *ident, struct data_value *v) +{ + if (ident == NULL || v == NULL) { + return -1; + } + + switch (v->type) { + case DATA_TYPE_INT: + printf("-D%s=%zu\n", ident, v->v); + return 0; + case DATA_TYPE_STR: + printf("-D%s=\"%s\"\n", ident, v->s); + return 0; + } + + printf("fatal: got bad data value during emission\n"); + return -1; +} -- cgit v1.2.3