diff options
author | Karel Kočí <cynerd@email.cz> | 2015-03-26 15:17:05 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2015-03-26 15:17:05 +0100 |
commit | a457b9823e4c46b5d7bc7d5800008a483502ad32 (patch) | |
tree | 794e88f8a1416e2d317a7aa0af4a1ef973c710fd /scripts/kconfig_parser/output.c | |
parent | f91e9e472d50795b6e67dfb3905559800a3bef66 (diff) | |
download | linux-conf-perf-a457b9823e4c46b5d7bc7d5800008a483502ad32.tar.gz linux-conf-perf-a457b9823e4c46b5d7bc7d5800008a483502ad32.tar.bz2 linux-conf-perf-a457b9823e4c46b5d7bc7d5800008a483502ad32.zip |
kconfig_parser moved from programs to scripts
This way all executable code is inside scripts directory.
Diffstat (limited to 'scripts/kconfig_parser/output.c')
-rw-r--r-- | scripts/kconfig_parser/output.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/scripts/kconfig_parser/output.c b/scripts/kconfig_parser/output.c new file mode 100644 index 0000000..989f4f0 --- /dev/null +++ b/scripts/kconfig_parser/output.c @@ -0,0 +1,65 @@ +#include "output.h" + +void fprint_rules_cnf(FILE * f, unsigned id, struct cnfexpr *cnf, bool nt) { + unsigned i, y; + switch (cnf->type) { + case CT_FALSE: + // Never satisfiable + if (!nt) + fprintf(f, "-"); + fprintf(f, "%d\n", id); + break; + case CT_TRUE: + // Always satisfiable + break; + case CT_EXPR: + for (i = 0; i < cnf->size; i++) { + if (!nt) + fprintf(f, "-"); + fprintf(f, "%d ", id); + for (y = 0; y < cnf->sizes[i] - 1; y++) { + fprintf(f, "%d ", cnf->exprs[i][y]); + } + fprintf(f, "%d ", cnf->exprs[i][cnf->sizes[i] - 1]); + fprintf(f, "\n"); + } + break; + } +} + +void fprint_rules(struct symlist *sl, char *output) { + FILE *f; + f = fopen(output, "w"); + if (f == NULL) { + fprintf(stderr, "Can't create file: %s\n", output); + return; + } + size_t i; + struct symlist_el *el; + for (i = 0; i < sl->pos; i++) { + if (sl->array[i].be != NULL) { + el = sl->array + i; + if (el->be != NULL) { + fprint_rules_cnf(f, el->id, el->be, false); + } + if (el->re_be != NULL) { + fprint_rules_cnf(f, el->id, el->re_be, true); + } + } + } + fclose(f); +} + +void fprint_symbol_map(struct symlist *sl, char *output) { + FILE *f; + f = fopen(output, "w"); + if (f == NULL) { + fprintf(stderr, "Can't create file: %s\n", output); + return; + } + size_t i; + for (i = 0; i < sl->pos; i++) { + fprintf(f, "%d:%s\n", sl->array[i].id, sl->array[i].name); + } + fclose(f); +} |