From 4ec68e612e5d6670a154677b4c8914f22153b122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 14 Dec 2014 19:28:28 +0100 Subject: 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. --- programs/src/kconfig/symlist.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 programs/src/kconfig/symlist.c (limited to 'programs/src/kconfig/symlist.c') diff --git a/programs/src/kconfig/symlist.c b/programs/src/kconfig/symlist.c new file mode 100644 index 0000000..7dcd2c6 --- /dev/null +++ b/programs/src/kconfig/symlist.c @@ -0,0 +1,49 @@ +#include "symlist.h" + +struct symlist *symlist_create() { + struct symlist *ret; + ret = malloc(sizeof(struct symlist)); + ret->size = 2; + ret->pos = 0; + ret->array = malloc(ret->size * sizeof(struct symlist_el)); + return ret; +} + +void symlist_add(struct symlist *sl, char *name) { + if (sl->pos >= sl->size) { + sl->size *= 2; + sl->array = + realloc(sl->array, sl->size * sizeof(struct symlist_el)); + } + sl->array[sl->pos].id = sl->pos + 1; + sl->array[sl->pos].name = name; + sl->array[sl->pos].be = NULL; + sl->pos++; +} + +struct symlist_el *symlist_find(struct symlist *sl, char *name) { + int i = 0; + while (i < sl->pos) { + if (!strcmp(name, sl->array[i].name)) + return &sl->array[i]; + i++; + } + return NULL; +} + +void symlist_print(struct symlist *sl) { + int i; + for (i = 0; i < sl->pos; i++) { + printf("%d:%s\n", sl->array[i].id, sl->array[i].name); + if (sl->array[i].be != NULL) { + printf(" "); + boolexp_print(sl->array[i].be); + printf("\n"); + } + } +} + +void symlist_free(struct symlist *sl) { + free(sl->array); + free(sl); +} -- cgit v1.2.3