summaryrefslogtreecommitdiff
path: root/core/emit.c
diff options
context:
space:
mode:
authorChloe M. <chloe@aptel.org>2026-08-23 06:37:47 +0000
committerChloe M. <chloe@aptel.org>2026-08-23 06:37:47 +0000
commit9bf5da82de7c19360c291d990814128a7b86c92e (patch)
tree59b7d7901e3d99e85ede0c45408f14a6f71953cb /core/emit.c
parentbaff5613531a0e0f8c7397f9b87a8ce1b6e2f5f4 (diff)
core: parser: Parse and emit define directives
Signed-off-by: Chloe M. <chloe@aptel.org>
Diffstat (limited to 'core/emit.c')
-rw-r--r--core/emit.c27
1 files changed, 27 insertions, 0 deletions
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 <stdio.h>
+#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;
+}