From c8a33ffb0aad5ebc2f50045eb8a460daa67f446d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Tue, 28 Jul 2015 10:23:29 +0200 Subject: Allconfig add inv option Added inv option for generating inverted configurations. Inverted configuration contains configuration options that are not in original configuration file. --- scripts/allconfig/inv.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 scripts/allconfig/inv.c (limited to 'scripts/allconfig/inv.c') diff --git a/scripts/allconfig/inv.c b/scripts/allconfig/inv.c new file mode 100644 index 0000000..0e87163 --- /dev/null +++ b/scripts/allconfig/inv.c @@ -0,0 +1,53 @@ +#include "inv.h" + +void inv_prepare(char *input_file) { + FILE *f; + f = fopen(input_file, "r"); + if (f == NULL) { + Eprintf("Can't open input file: %s\n", input_file); + exit(-2); + } + + struct property *fixed_prop; + fixed_prop = malloc(sizeof(struct property)); + fixed_prop->type = P_UNKNOWN; + fixed_prop->lineno = LINENUM_IDENTIFICATOR; + fixed_prop->next = NULL; + char buffer[READBUFFER_SIZE]; + while (fgets(buffer, READBUFFER_SIZE, f) != NULL) { + if (buffer[0] == '\0' || buffer[1] == '\0') + continue; + if (buffer[0] != '#') { + char *wstr = buffer + 7; + char *end = strchr(wstr, '='); + *end = '\0'; + struct symbol *sym = sym_find(wstr); + if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE) + continue; + if (sym->prop == NULL) { + sym->prop = fixed_prop; + continue; + } + struct property *prop; + prop = sym->prop; + while (prop->next != NULL) + prop = prop->next; + prop->next = fixed_prop; + } + } + + fclose(f); +} + +bool inv_fixed(struct symbol *sym) { + if (sym->prop == NULL) + return false; + struct property *prop; + prop = sym->prop; + while (prop->next != NULL) + prop = prop->next; + if (prop->type == P_UNKNOWN && prop->lineno == LINENUM_IDENTIFICATOR) + return true; + else + return false; +} -- cgit v1.2.3