aboutsummaryrefslogtreecommitdiff
path: root/programs/src/kconfig/output.c
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2014-12-14 19:28:28 +0100
committerKarel Kočí <cynerd@email.cz>2014-12-14 19:28:28 +0100
commit4ec68e612e5d6670a154677b4c8914f22153b122 (patch)
tree7fa4379e01336d0ac4e3613bb6b4d6ea7e66a04e /programs/src/kconfig/output.c
parent5b99a9efbdd7026185266d71fca9615e124a6132 (diff)
downloadlinux-conf-perf-4ec68e612e5d6670a154677b4c8914f22153b122.tar.gz
linux-conf-perf-4ec68e612e5d6670a154677b4c8914f22153b122.tar.bz2
linux-conf-perf-4ec68e612e5d6670a154677b4c8914f22153b122.zip
Add kconfig_parser
kconfig_parser is placed to new folder tree. In folder "programs" will be all programs. Files in folder programs/src/kconfig/kconfig are taken from kernel v3.18-rc3. In future, they should be updated if new changes will be added to kernel.
Diffstat (limited to 'programs/src/kconfig/output.c')
-rw-r--r--programs/src/kconfig/output.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/programs/src/kconfig/output.c b/programs/src/kconfig/output.c
new file mode 100644
index 0000000..ed9daec
--- /dev/null
+++ b/programs/src/kconfig/output.c
@@ -0,0 +1,82 @@
+#include "output.h"
+
+void fprint_rules(struct symlist *sl) {
+ FILE *f;
+ f = fopen(RULES_FILE, "w");
+ if (f == NULL) {
+ fprintf(stderr, "Can't create file: %s\n", RULES_FILE);
+ return;
+ }
+ int i;
+ struct symlist_el *el;
+ struct boolexp *be;
+ struct boolexp **stack;
+ size_t stack_size = 2, stack_pos = 0;
+ int count_or, count_and;
+ stack = malloc(stack_size * sizeof(struct boolexp *));
+ for (i = 0; i < sl->pos; i++) {
+ if (sl->array[i].be != NULL) {
+ el = sl->array + i;
+ be = el->be;
+ stack_pos = 0;
+ count_or = 0;
+ count_and = 0;
+ fprintf(f, "-%d ", el->id);
+ while (be != NULL) {
+ if (stack_pos >= stack_size) {
+ stack_size *= 2;
+ stack =
+ realloc(stack,
+ stack_size * sizeof(struct boolexp *));
+ }
+ switch (be->type) {
+ case BE_NOT:
+ fprintf(f, "-");
+ be = be->left.be;
+ break;
+ case BE_AND:
+ count_and++;
+ stack[stack_pos++] = be->right.be;
+ be = be->left.be;
+ break;
+ case BE_OR:
+ count_or++;
+ stack[stack_pos++] = be->right.be;
+ be = be->left.be;
+ break;
+ case BE_LEAF:
+ fprintf(f, "%d", be->left.id);
+ if (count_or > 0) {
+ fprintf(f, " ");
+ count_or--;
+ } else if (count_and > 0) {
+ fprintf(f, "\n-%d ", el->id);
+ count_and--;
+ }
+ if (stack_pos > 0)
+ be = stack[--stack_pos];
+ else
+ be = NULL;
+ break;
+ }
+ }
+ fprintf(f, "\n");
+ }
+ }
+ free(stack);
+ fclose(f);
+}
+
+void fprint_linker(struct symlist *sl) {
+ FILE *f;
+ f = fopen(LINKER_FILE, "w");
+ if (f == NULL) {
+ fprintf(stderr, "Can't create file: %s\n", RULES_FILE);
+ return;
+ }
+ int i;
+ for (i = 0; i < sl->pos; i++) {
+ fprintf(f, "%d:%s\n", sl->array[i].id, sl->array[i].name);
+ }
+ fclose(f);
+}