summaryrefslogtreecommitdiff
path: root/core/emit.c
blob: ec00ed29d9afede64214d229a649866ac96f737a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
}