/* * V 5c * Released under the terms of the GNU GPL v2.0. */ #include #include #include "lkc.h" void printconf(FILE *); void printsym(FILE *, struct menu *); int main(int ac, char **av) { const char *name; if (ac != 2) exit(1); name = av[1]; conf_parse(name); printconf(stdout); /*zconfdump(stdout);*/ return 0; } void decodeflags (FILE *out, int flags); void decodeflags (FILE *out, int flags) { /* taken from expr.h */ int flaglist[] = { SYMBOL_CONST , /* 0x0001 symbol is const */ SYMBOL_CHECK , /* 0x0008 used during dependency checking */ SYMBOL_CHOICE , /* 0x0010 start of a choice block (null name) */ SYMBOL_CHOICEVAL, /* 0x0020 used as a value in a choice block */ SYMBOL_VALID , /* 0x0080 set when symbol.curr is calculated */ SYMBOL_OPTIONAL , /* 0x0100 choice is optional - values can be 'n' */ SYMBOL_WRITE , /* 0x0200 ? */ SYMBOL_CHANGED , /* 0x0400 ? */ SYMBOL_AUTO , /* 0x1000 value from environment variable */ SYMBOL_CHECKED , /* 0x2000 used during dependency checking */ SYMBOL_WARNED , /* 0x8000 warning has been issued */ 0x0 }; char *flagnames[] = { "CONST" , /* 0x0001 symbol is const */ "CHECK" , /* 0x0008 used during dependency checking */ "CHOICE" , /* 0x0010 start of a choice block (null name) */ "CHOICEVAL", /* 0x0020 used as a value in a choice block */ "VALID" , /* 0x0080 set when symbol.curr is calculated */ "OPTIONAL" , /* 0x0100 choice is optional - values can be 'n' */ "WRITE" , /* 0x0200 ? */ "CHANGED" , /* 0x0400 ? */ "AUTO" , /* 0x1000 value from environment variable */ "CHECKED" , /* 0x2000 used during dependency checking */ "WARNED" /* 0x8000 warning has been issued */ }; fprintf(out,"\t"); int i; for(i=0; flaglist[i]; i++) { if (flags & flaglist[i]) { fprintf(out,"%s",flagnames[i]); } } fprintf(out,"\n"); } void decodeexpr_type(FILE *out, char* tagname,int val); void decodeexpr_type(FILE *out, char* tagname,int val) { char *value; switch (val) { case E_NONE: value = "NONE"; break; case E_OR: value = "OR"; break; case E_AND: value = "AND"; break; case E_NOT: value = "NOT"; break; case E_EQUAL: value = "EQUAL"; break; case E_UNEQUAL: value = "UNEQUAL"; break; case E_LIST: value = "LIST"; break; case E_SYMBOL: value = "SYMBOL"; break; case E_RANGE: value = "RANGE"; break; default: fprintf(stderr, "ERROR: decodeexpr_type() '%d': should never happen\n",val); exit(1); } fprintf(out, "\t<%s>%s\n", tagname, value, tagname); } void decodesym(FILE *out, char* tagname,struct symbol_value symval); void decodesym(FILE *out, char* tagname,struct symbol_value symval) { fprintf(out, "\t<%s>%s\n", tagname, (char *)symval.val, tagname); } void printsym(FILE *out, struct menu *menu) { struct property *prop; // int have_properties = 0; int open_menu = 0; fprintf(out, "\n"); if (open_menu) // fprintf(out, "\n", menu->sym->name); fprintf(out, "\n", menu->sym->name,menu->sym->prop->file->name,menu->sym->prop->lineno); } void tag (FILE *out, char *tagname, char *value); void tag (FILE *out, char *tagname, char *value) { fprintf(out, "\t<%s>%s\n", tagname, value, tagname); } void printconf(FILE *out) { /* struct property *prop; */ struct menu *menu; fprintf(out, "\n"); fprintf(out, "\n"); fprintf(out, "\n"); menu = rootmenu.list; while (menu) { if ( menu->prompt ) { switch (menu->prompt->type) { case P_UNKNOWN: fprintf(out, "\t%s\n", "unknown"); break; case P_PROMPT: /* prompt "foo prompt" or "BAZ Value" */ // fprintf(out, "\t%s\n", "prompt"); break; case P_COMMENT: /* text associated with a comment */ // fprintf(out, "\t%s\n", "comment"); break; case P_MENU: /* prompt associated with a menuconfig option */ // fprintf(out, "\t%s\n", "menu"); break; case P_DEFAULT: /* default y */ fprintf(out, "\t%s\n", "default"); break; case P_CHOICE: /* choice value */ fprintf(out, "\t%s\n", "choice"); break; case P_SELECT: /* select BAR */ fprintf(out, "\t%s\n", "select"); break; case P_RANGE: /* range 7..100 (for a symbol) */ fprintf(out, "\t%s\n", "range"); break; case P_ENV: /* value from environment variable */ fprintf(out, "\t%s\n", "env"); break; case P_SYMBOL: /* where a symbol is defined */ fprintf(out, "\t%s\n", "symbol"); break; default: fprintf(stderr, "ERROR: menu->prompt->type '%d': should never happen\n",menu->prompt->type); exit(1); } } if (menu->sym) { printsym(out, menu); } else if (menu->prompt) { switch (menu->prompt->type) { case P_COMMENT: fprintf(out, "%s\n", menu->prompt->text); break; case P_MENU: if ( menu->sym ) { fprintf(out, "\n\t%s\n", menu->sym->name, menu->sym->prop->file->name, menu->sym->prop->lineno, menu->prompt->text); } else { fprintf(out, "\n\t%s\n", menu->prompt->text, menu->prompt->file->name, menu->prompt->file->lineno, menu->prompt->text); } // fprintf(out, "\n", menu->sym->name,menu->sym->prop->file->name,menu->sym->prop->lineno); break; case P_PROMPT: fprintf(out, "\n", menu->prompt->text); break; default: fprintf(stderr, "ERROR: menu->prompt->type '%d': should never happen\n",menu->prompt->type); exit(1); } if (menu->visibility) { decodeexpr_type(out,"visibility",menu->visibility->type); } } if (menu->list) menu = menu->list; else if (menu->next) menu = menu->next; else while ((menu = menu->parent)) { if (menu->prompt && menu->prompt->type == P_MENU) fprintf(out, "\n", menu->sym?menu->sym->name:menu->prompt->text); if (menu->next) { menu = menu->next; break; } } } fprintf(out, "\n"); fprintf(out, "\n"); }