aboutsummaryrefslogtreecommitdiff
path: root/scripts/parse_kconfig/output.c
blob: f931ba285c0069228f2fb394852acce525d7cec4 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "output.h"

FILE *frules, *fsymmap;

int output_init(char *rules_file, char *symbolmap_file) {
    if ((frules = fopen(rules_file, "w")) == NULL)
        return 1;
    if ((fsymmap = fopen(symbolmap_file, "w")) == NULL)
        return 2;
    return 0;
}

void output_finish(void) {
    fclose(frules);
    fclose(fsymmap);
}


// Functions for symbol_map
void output_push_symbol(unsigned id, char *name) {
    fprintf(fsymmap, "%d:%s\n", id, name);
}

// Functions for rules
void output_rules_symbol(int id) {
    fprintf(frules, "%d ", id);
}

void output_rules_endterm(void) {
    fprintf(frules, "\n");
}

// Functions for variable_count
void output_write_variable_count(char *var_file, int count,
                                 unsigned lastoption) {
    FILE *f;
    f = fopen(var_file, "w");
    fprintf(f, "%d\n", count);
    fprintf(f, "%d", lastoption);
    fclose(f);
}