aboutsummaryrefslogtreecommitdiff
path: root/scripts/config/mconf.c
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2005-04-19 09:55:06 +0000
committerPeter Kjellerstedt <peter.kjellerstedt@axis.com>2005-04-19 09:55:06 +0000
commitbae38db8e42b2d09b920d9430d18ee41bdcc0b17 (patch)
tree3e1ebb993c7c1979858d58dfd5a923e60a67ec5d /scripts/config/mconf.c
parent2bf88a891fb9359951bab83b74296ce036a50ae0 (diff)
downloadbusybox-w32-bae38db8e42b2d09b920d9430d18ee41bdcc0b17.tar.gz
busybox-w32-bae38db8e42b2d09b920d9430d18ee41bdcc0b17.tar.bz2
busybox-w32-bae38db8e42b2d09b920d9430d18ee41bdcc0b17.zip
Updated to match trunk/uClibc/extra/config as of r10132, and thus
Linux 2.6.11.
Diffstat (limited to 'scripts/config/mconf.c')
-rw-r--r--scripts/config/mconf.c376
1 files changed, 320 insertions, 56 deletions
diff --git a/scripts/config/mconf.c b/scripts/config/mconf.c
index 63b4ff72f..5bc2abdd8 100644
--- a/scripts/config/mconf.c
+++ b/scripts/config/mconf.c
@@ -23,18 +23,150 @@
23#include <termios.h> 23#include <termios.h>
24#include <unistd.h> 24#include <unistd.h>
25 25
26#include "dialog.h" 26#include "lxdialog/dialog.h"
27 27
28#define LKC_DIRECT_LINK 28#define LKC_DIRECT_LINK
29#include "lkc.h" 29#include "lkc.h"
30 30
31static char menu_backtitle[128]; 31static char menu_backtitle[128];
32static const char menu_instructions[] = 32static const char mconf_readme[] =
33"Overview\n"
34"--------\n"
35"Some features may be built directly into BusyBox. Some features\n"
36"may be completely removed altogether. There are also certain\n"
37"parameters which are not really features, but must be\n"
38"entered in as decimal or hexadecimal numbers or possibly text.\n"
39"\n"
40"Menu items beginning with [*] or [ ] represent features\n"
41"configured to be built in or removed respectively.\n"
42"\n"
43"To change any of these features, highlight it with the cursor\n"
44"keys and press <Y> to build it in or <N> to removed it.\n"
45"You may also press the <Space Bar> to cycle\n"
46"through the available options (ie. Y->N->Y).\n"
47"\n"
48"Some additional keyboard hints:\n"
49"\n"
50"Menus\n"
51"----------\n"
52"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n"
53" you wish to change or submenu wish to select and press <Enter>.\n"
54" Submenus are designated by \"--->\".\n"
55"\n"
56" Shortcut: Press the option's highlighted letter (hotkey).\n"
57" Pressing a hotkey more than once will sequence\n"
58" through all visible items which use that hotkey.\n"
59"\n"
60" You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n"
61" unseen options into view.\n"
62"\n"
63"o To exit a menu use the cursor keys to highlight the <Exit> button\n"
64" and press <ENTER>.\n"
65"\n"
66" Shortcut: Press <ESC><ESC> or <E> or <X> if there is no hotkey\n"
67" using those letters. You may press a single <ESC>, but\n"
68" there is a delayed response which you may find annoying.\n"
69"\n"
70" Also, the <TAB> and cursor keys will cycle between <Select>,\n"
71" <Exit> and <Help>\n"
72"\n"
73"o To get help with an item, use the cursor keys to highlight <Help>\n"
74" and Press <ENTER>.\n"
75"\n"
76" Shortcut: Press <H> or <?>.\n"
77"\n"
78"\n"
79"Radiolists (Choice lists)\n"
80"-----------\n"
81"o Use the cursor keys to select the option you wish to set and press\n"
82" <S> or the <SPACE BAR>.\n"
83"\n"
84" Shortcut: Press the first letter of the option you wish to set then\n"
85" press <S> or <SPACE BAR>.\n"
86"\n"
87"o To see available help for the item, use the cursor keys to highlight\n"
88" <Help> and Press <ENTER>.\n"
89"\n"
90" Shortcut: Press <H> or <?>.\n"
91"\n"
92" Also, the <TAB> and cursor keys will cycle between <Select> and\n"
93" <Help>\n"
94"\n"
95"\n"
96"Data Entry\n"
97"-----------\n"
98"o Enter the requested information and press <ENTER>\n"
99" If you are entering hexadecimal values, it is not necessary to\n"
100" add the '0x' prefix to the entry.\n"
101"\n"
102"o For help, use the <TAB> or cursor keys to highlight the help option\n"
103" and press <ENTER>. You can try <TAB><H> as well.\n"
104"\n"
105"\n"
106"Text Box (Help Window)\n"
107"--------\n"
108"o Use the cursor keys to scroll up/down/left/right. The VI editor\n"
109" keys h,j,k,l function here as do <SPACE BAR> and <B> for those\n"
110" who are familiar with less and lynx.\n"
111"\n"
112"o Press <E>, <X>, <Enter> or <Esc><Esc> to exit.\n"
113"\n"
114"\n"
115"Alternate Configuration Files\n"
116"-----------------------------\n"
117"Menuconfig supports the use of alternate configuration files for\n"
118"those who, for various reasons, find it necessary to switch\n"
119"between different configurations.\n"
120"\n"
121"At the end of the main menu you will find two options. One is\n"
122"for saving the current configuration to a file of your choosing.\n"
123"The other option is for loading a previously saved alternate\n"
124"configuration.\n"
125"\n"
126"Even if you don't use alternate configuration files, but you\n"
127"find during a Menuconfig session that you have completely messed\n"
128"up your settings, you may use the \"Load Alternate...\" option to\n"
129"restore your previously saved settings from \".config\" without\n"
130"restarting Menuconfig.\n"
131"\n"
132"Other information\n"
133"-----------------\n"
134"If you use Menuconfig in an XTERM window make sure you have your\n"
135"$TERM variable set to point to a xterm definition which supports color.\n"
136"Otherwise, Menuconfig will look rather bad. Menuconfig will not\n"
137"display correctly in a RXVT window because rxvt displays only one\n"
138"intensity of color, bright.\n"
139"\n"
140"Menuconfig will display larger menus on screens or xterms which are\n"
141"set to display more than the standard 25 row by 80 column geometry.\n"
142"In order for this to work, the \"stty size\" command must be able to\n"
143"display the screen's current row and column geometry. I STRONGLY\n"
144"RECOMMEND that you make sure you do NOT have the shell variables\n"
145"LINES and COLUMNS exported into your environment. Some distributions\n"
146"export those variables via /etc/profile. Some ncurses programs can\n"
147"become confused when those variables (LINES & COLUMNS) don't reflect\n"
148"the true screen size.\n"
149"\n"
150"Optional personality available\n"
151"------------------------------\n"
152"If you prefer to have all of the options listed in a single\n"
153"menu, rather than the default multimenu hierarchy, run the menuconfig\n"
154"with MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
155"\n"
156"make MENUCONFIG_MODE=single_menu menuconfig\n"
157"\n"
158"<Enter> will then unroll the appropriate category, or enfold it if it\n"
159"is already unrolled.\n"
160"\n"
161"Note that this mode can eventually be a little more CPU expensive\n"
162"(especially with a larger number of unrolled categories) than the\n"
163"default mode.\n",
164menu_instructions[] =
33 "Arrow keys navigate the menu. " 165 "Arrow keys navigate the menu. "
34 "<Enter> selects submenus --->. " 166 "<Enter> selects submenus --->. "
35 "Highlighted letters are hotkeys. " 167 "Highlighted letters are hotkeys. "
36 "Pressing <Y> selectes a feature, while <N> will exclude a feature. " 168 "Pressing <Y> selectes a feature, while <N> will exclude a feature. "
37 "Press <Esc><Esc> to exit, <?> for Help. " 169 "Press <Esc><Esc> to exit, <?> for Help, </> for Search. "
38 "Legend: [*] feature is selected [ ] feature is excluded", 170 "Legend: [*] feature is selected [ ] feature is excluded",
39radiolist_instructions[] = 171radiolist_instructions[] =
40 "Use the arrow keys to navigate this window or " 172 "Use the arrow keys to navigate this window or "
@@ -85,23 +217,50 @@ save_config_help[] =
85 "\n" 217 "\n"
86 "If you are uncertain what all this means then you should probably\n" 218 "If you are uncertain what all this means then you should probably\n"
87 "leave this blank.\n", 219 "leave this blank.\n",
88top_menu_help[] = 220search_help[] =
89 "\n" 221 "\n"
90 "Use the Up/Down arrow keys (cursor keys) to highlight the item\n" 222 "Search for CONFIG_ symbols and display their relations.\n"
91 "you wish to change or submenu wish to select and press <Enter>.\n" 223 "Example: search for \"^FOO\"\n"
92 "Submenus are designated by \"--->\".\n" 224 "Result:\n"
225 "-----------------------------------------------------------------\n"
226 "Symbol: FOO [=m]\n"
227 "Prompt: Foo bus is used to drive the bar HW\n"
228 "Defined at drivers/pci/Kconfig:47\n"
229 "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
230 "Location:\n"
231 " -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n"
232 " -> PCI support (PCI [=y])\n"
233 " -> PCI access mode (<choice> [=y])\n"
234 "Selects: LIBCRC32\n"
235 "Selected by: BAR\n"
236 "-----------------------------------------------------------------\n"
237 "o The line 'Prompt:' shows the text used in the menu structure for\n"
238 " this CONFIG_ symbol\n"
239 "o The 'Defined at' line tell at what file / line number the symbol\n"
240 " is defined\n"
241 "o The 'Depends on:' line tell what symbols needs to be defined for\n"
242 " this symbol to be visible in the menu (selectable)\n"
243 "o The 'Location:' lines tell where in the menu structure this symbol\n"
244 " is located\n"
245 " A location followed by a [=y] indicate that this is a selectable\n"
246 " menu item - and current value is displayed inside brackets.\n"
247 "o The 'Selects:' line tell what symbol will be automatically\n"
248 " selected if this symbol is selected (y or m)\n"
249 "o The 'Selected by' line tell what symbol has selected this symbol\n"
93 "\n" 250 "\n"
94 "Shortcut: Press the option's highlighted letter (hotkey).\n" 251 "Only relevant lines are shown.\n"
95 "\n" 252 "\n\n"
96 "You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n" 253 "Search examples:\n"
97 "unseen options into view.\n" 254 "Examples: USB => find all CONFIG_ symbols containing USB\n"
98; 255 " ^USB => find all CONFIG_ symbols starting with USB\n"
256 " USB$ => find all CONFIG_ symbols ending with USB\n"
257 "\n";
99 258
100static char filename[PATH_MAX+1] = ".config"; 259static char filename[PATH_MAX+1] = ".config";
101static int indent = 0; 260static int indent;
102static struct termios ios_org; 261static struct termios ios_org;
103static int rows, cols; 262static int rows = 0, cols = 0;
104struct menu *current_menu; 263static struct menu *current_menu;
105static int child_count; 264static int child_count;
106static int single_menu_mode; 265static int single_menu_mode;
107 266
@@ -116,33 +275,31 @@ static void conf_save(void);
116static void show_textbox(const char *title, const char *text, int r, int c); 275static void show_textbox(const char *title, const char *text, int r, int c);
117static void show_helptext(const char *title, const char *text); 276static void show_helptext(const char *title, const char *text);
118static void show_help(struct menu *menu); 277static void show_help(struct menu *menu);
119static void show_readme(void); 278static void show_file(const char *filename, const char *title, int r, int c);
120 279
121static void init_wsize(void) 280static void init_wsize(void)
122{ 281{
123 struct winsize ws; 282 struct winsize ws;
124 char *env; 283 char *env;
125 284
126 if (ioctl(1, TIOCGWINSZ, &ws) == -1) { 285 if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) {
127 rows = 24;
128 cols = 80;
129 } else {
130 rows = ws.ws_row; 286 rows = ws.ws_row;
131 cols = ws.ws_col; 287 cols = ws.ws_col;
132 if (!rows) { 288 }
133 env = getenv("LINES"); 289
134 if (env) 290 if (!rows) {
135 rows = atoi(env); 291 env = getenv("LINES");
136 if (!rows) 292 if (env)
137 rows = 24; 293 rows = atoi(env);
138 } 294 if (!rows)
139 if (!cols) { 295 rows = 24;
140 env = getenv("COLUMNS"); 296 }
141 if (env) 297 if (!cols) {
142 cols = atoi(env); 298 env = getenv("COLUMNS");
143 if (!cols) 299 if (env)
144 cols = 80; 300 cols = atoi(env);
145 } 301 if (!cols)
302 cols = 80;
146 } 303 }
147 304
148 if (rows < 19 || cols < 80) { 305 if (rows < 19 || cols < 80) {
@@ -214,6 +371,103 @@ static void cdone(void)
214 item_no = 0; 371 item_no = 0;
215} 372}
216 373
374static void get_prompt_str(struct gstr *r, struct property *prop)
375{
376 int i, j;
377 struct menu *submenu[8], *menu;
378
379 str_printf(r, "Prompt: %s\n", prop->text);
380 str_printf(r, " Defined at %s:%d\n", prop->menu->file->name,
381 prop->menu->lineno);
382 if (!expr_is_yes(prop->visible.expr)) {
383 str_append(r, " Depends on: ");
384 expr_gstr_print(prop->visible.expr, r);
385 str_append(r, "\n");
386 }
387 menu = prop->menu->parent;
388 for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
389 submenu[i++] = menu;
390 if (i > 0) {
391 str_printf(r, " Location:\n");
392 for (j = 4; --i >= 0; j += 2) {
393 menu = submenu[i];
394 str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu));
395 if (menu->sym) {
396 str_printf(r, " (%s [=%s])", menu->sym->name ?
397 menu->sym->name : "<choice>",
398 sym_get_string_value(menu->sym));
399 }
400 str_append(r, "\n");
401 }
402 }
403}
404
405static void get_symbol_str(struct gstr *r, struct symbol *sym)
406{
407 bool hit;
408 struct property *prop;
409
410 str_printf(r, "Symbol: %s [=%s]\n", sym->name,
411 sym_get_string_value(sym));
412 for_all_prompts(sym, prop)
413 get_prompt_str(r, prop);
414 hit = false;
415 for_all_properties(sym, prop, P_SELECT) {
416 if (!hit) {
417 str_append(r, " Selects: ");
418 hit = true;
419 } else
420 str_printf(r, " && ");
421 expr_gstr_print(prop->expr, r);
422 }
423 if (hit)
424 str_append(r, "\n");
425 if (sym->rev_dep.expr) {
426 str_append(r, " Selected by: ");
427 expr_gstr_print(sym->rev_dep.expr, r);
428 str_append(r, "\n");
429 }
430 str_append(r, "\n\n");
431}
432
433static struct gstr get_relations_str(struct symbol **sym_arr)
434{
435 struct symbol *sym;
436 struct gstr res = str_new();
437 int i;
438
439 for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
440 get_symbol_str(&res, sym);
441 if (!i)
442 str_append(&res, "No matches found.\n");
443 return res;
444}
445
446static void search_conf(void)
447{
448 struct symbol **sym_arr;
449 struct gstr res;
450
451again:
452 switch (dialog_inputbox("Search Configuration Parameter",
453 "Enter Keyword", 10, 75,
454 NULL)) {
455 case 0:
456 break;
457 case 1:
458 show_helptext("Search Configuration", search_help);
459 goto again;
460 default:
461 return;
462 }
463
464 sym_arr = sym_re_search(dialog_input_result);
465 res = get_relations_str(sym_arr);
466 free(sym_arr);
467 show_textbox("Search Results", str_get(&res), 0, 0);
468 str_free(&res);
469}
470
217static void build_conf(struct menu *menu) 471static void build_conf(struct menu *menu)
218{ 472{
219 struct symbol *sym; 473 struct symbol *sym;
@@ -308,6 +562,11 @@ static void build_conf(struct menu *menu)
308 return; 562 return;
309 } 563 }
310 } else { 564 } else {
565 if (menu == current_menu) {
566 cprint_tag(":%p", menu);
567 cprint_name("---%*c%s", indent + 1, ' ', menu_get_prompt(menu));
568 goto conf_childs;
569 }
311 child_count++; 570 child_count++;
312 val = sym_get_tristate_value(sym); 571 val = sym_get_tristate_value(sym);
313 if (sym_is_choice_value(sym) && val == yes) { 572 if (sym_is_choice_value(sym) && val == yes) {
@@ -376,7 +635,7 @@ static void conf(struct menu *menu)
376 while (1) { 635 while (1) {
377 indent = 0; 636 indent = 0;
378 child_count = 0; 637 child_count = 0;
379 current_menu = menu; 638 current_menu = menu;
380 cdone(); cinit(); 639 cdone(); cinit();
381 build_conf(menu); 640 build_conf(menu);
382 if (!child_count) 641 if (!child_count)
@@ -441,7 +700,7 @@ static void conf(struct menu *menu)
441 if (sym) 700 if (sym)
442 show_help(submenu); 701 show_help(submenu);
443 else 702 else
444 show_readme(); 703 show_helptext("README", mconf_readme);
445 break; 704 break;
446 case 3: 705 case 3:
447 if (type == 't') { 706 if (type == 't') {
@@ -465,6 +724,9 @@ static void conf(struct menu *menu)
465 else if (type == 'm') 724 else if (type == 'm')
466 conf(submenu); 725 conf(submenu);
467 break; 726 break;
727 case 7:
728 search_conf();
729 break;
468 } 730 }
469 } 731 }
470} 732}
@@ -476,37 +738,39 @@ static void show_textbox(const char *title, const char *text, int r, int c)
476 fd = creat(".help.tmp", 0777); 738 fd = creat(".help.tmp", 0777);
477 write(fd, text, strlen(text)); 739 write(fd, text, strlen(text));
478 close(fd); 740 close(fd);
479 while (dialog_textbox(title, ".help.tmp", r, c) < 0) 741 show_file(".help.tmp", title, r, c);
480 ;
481 unlink(".help.tmp"); 742 unlink(".help.tmp");
482} 743}
483 744
484static void show_helptext(const char *title, const char *text) 745static void show_helptext(const char *title, const char *text)
485{ 746{
486 show_textbox(title, text, rows, cols); 747 show_textbox(title, text, 0, 0);
487} 748}
488 749
489static void show_help(struct menu *menu) 750static void show_help(struct menu *menu)
490{ 751{
491 const char *help; 752 struct gstr help = str_new();
492 char *helptext;
493 struct symbol *sym = menu->sym; 753 struct symbol *sym = menu->sym;
494 754
495 help = sym->help; 755 if (sym->help)
496 if (!help) 756 {
497 help = nohelp_text; 757 if (sym->name) {
498 if (sym->name) { 758 str_printf(&help, "%s:\n\n", sym->name);
499 helptext = malloc(strlen(sym->name) + strlen(help) + 16); 759 str_append(&help, sym->help);
500 sprintf(helptext, "%s:\n\n%s", sym->name, help); 760 str_append(&help, "\n");
501 show_helptext(menu_get_prompt(menu), helptext); 761 }
502 free(helptext); 762 } else {
503 } else 763 str_append(&help, nohelp_text);
504 show_helptext(menu_get_prompt(menu), help); 764 }
765 get_symbol_str(&help, sym);
766 show_helptext(menu_get_prompt(menu), str_get(&help));
767 str_free(&help);
505} 768}
506 769
507static void show_readme(void) 770static void show_file(const char *filename, const char *title, int r, int c)
508{ 771{
509 show_helptext("Help", top_menu_help); 772 while (dialog_textbox(title, filename, r ? r : rows, c ? c : cols) < 0)
773 ;
510} 774}
511 775
512static void conf_choice(struct menu *menu) 776static void conf_choice(struct menu *menu)
@@ -667,9 +931,9 @@ static void winch_handler(int sig)
667 931
668int main(int ac, char **av) 932int main(int ac, char **av)
669{ 933{
670 int stat;
671 char *mode;
672 struct symbol *sym; 934 struct symbol *sym;
935 char *mode;
936 int stat;
673 937
674 conf_parse(av[1]); 938 conf_parse(av[1]);
675 conf_read(NULL); 939 conf_read(NULL);
@@ -697,7 +961,7 @@ int main(int ac, char **av)
697 init_dialog(); 961 init_dialog();
698 do { 962 do {
699 stat = dialog_yesno(NULL, 963 stat = dialog_yesno(NULL,
700 "Do you wish to save your new BusyBox configuration?", 5, 60); 964 "Do you wish to save your new BusyBox configuration?", 5, 60);
701 } while (stat < 0); 965 } while (stat < 0);
702 end_dialog(); 966 end_dialog();
703 967