-rw-r--r-- | scripts/kconfig/mconf.c | 101 |
1 files changed, 85 insertions, 16 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index dec8603..eba5ff7 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -1,136 +1,159 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
3 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
4 | * | ||
5 | * Introduced single menu mode (show all sub-menus in one large tree). | ||
6 | * 2002-11-06 Petr Baudis <pasky@ucw.cz> | ||
4 | */ | 7 | */ |
5 | 8 | ||
6 | #include <sys/ioctl.h> | 9 | #include <sys/ioctl.h> |
7 | #include <sys/wait.h> | 10 | #include <sys/wait.h> |
8 | #include <ctype.h> | 11 | #include <ctype.h> |
9 | #include <errno.h> | 12 | #include <errno.h> |
10 | #include <fcntl.h> | 13 | #include <fcntl.h> |
14 | #include <limits.h> | ||
11 | #include <signal.h> | 15 | #include <signal.h> |
12 | #include <stdarg.h> | 16 | #include <stdarg.h> |
13 | #include <stdlib.h> | 17 | #include <stdlib.h> |
14 | #include <string.h> | 18 | #include <string.h> |
19 | #include <termios.h> | ||
15 | #include <unistd.h> | 20 | #include <unistd.h> |
16 | 21 | ||
17 | #define LKC_DIRECT_LINK | 22 | #define LKC_DIRECT_LINK |
18 | #include "lkc.h" | 23 | #include "lkc.h" |
19 | 24 | ||
20 | static char menu_backtitle[128]; | 25 | static char menu_backtitle[128]; |
21 | static const char menu_instructions[] = | 26 | static const char menu_instructions[] = |
22 | "Arrow keys navigate the menu. " | 27 | "Arrow keys navigate the menu. " |
23 | "<Enter> selects submenus --->. " | 28 | "<Enter> selects submenus --->. " |
24 | "Highlighted letters are hotkeys. " | 29 | "Highlighted letters are hotkeys. " |
25 | "Pressing <Y> includes, <N> excludes, <M> modularizes features. " | 30 | "Pressing <Y> includes, <N> excludes, <M> modularizes features. " |
26 | "Press <Esc><Esc> to exit, <?> for Help. " | 31 | "Press <Esc><Esc> to exit, <?> for Help. " |
27 | "Legend: [*] built-in [ ] excluded <M> module < > module capable", | 32 | "Legend: [*] built-in [ ] excluded <M> module < > module capable", |
28 | radiolist_instructions[] = | 33 | radiolist_instructions[] = |
29 | "Use the arrow keys to navigate this window or " | 34 | "Use the arrow keys to navigate this window or " |
30 | "press the hotkey of the item you wish to select " | 35 | "press the hotkey of the item you wish to select " |
31 | "followed by the <SPACE BAR>. " | 36 | "followed by the <SPACE BAR>. " |
32 | "Press <?> for additional information about this option.", | 37 | "Press <?> for additional information about this option.", |
33 | inputbox_instructions_int[] = | 38 | inputbox_instructions_int[] = |
34 | "Please enter a decimal value. " | 39 | "Please enter a decimal value. " |
35 | "Fractions will not be accepted. " | 40 | "Fractions will not be accepted. " |
36 | "Use the <TAB> key to move from the input field to the buttons below it.", | 41 | "Use the <TAB> key to move from the input field to the buttons below it.", |
37 | inputbox_instructions_hex[] = | 42 | inputbox_instructions_hex[] = |
38 | "Please enter a hexadecimal value. " | 43 | "Please enter a hexadecimal value. " |
39 | "Use the <TAB> key to move from the input field to the buttons below it.", | 44 | "Use the <TAB> key to move from the input field to the buttons below it.", |
40 | inputbox_instructions_string[] = | 45 | inputbox_instructions_string[] = |
41 | "Please enter a string value. " | 46 | "Please enter a string value. " |
42 | "Use the <TAB> key to move from the input field to the buttons below it.", | 47 | "Use the <TAB> key to move from the input field to the buttons below it.", |
43 | setmod_text[] = | 48 | setmod_text[] = |
44 | "This feature depends on another which has been configured as a module.\n" | 49 | "This feature depends on another which has been configured as a module.\n" |
45 | "As a result, this feature will be built as a module.", | 50 | "As a result, this feature will be built as a module.", |
46 | nohelp_text[] = | 51 | nohelp_text[] = |
47 | "There is no help available for this option.\n", | 52 | "There is no help available for this kernel option.\n", |
48 | load_config_text[] = | 53 | load_config_text[] = |
49 | "Enter the name of the configuration file you wish to load. " | 54 | "Enter the name of the configuration file you wish to load. " |
50 | "Accept the name shown to restore the configuration you " | 55 | "Accept the name shown to restore the configuration you " |
51 | "last retrieved. Leave blank to abort.", | 56 | "last retrieved. Leave blank to abort.", |
52 | load_config_help[] = | 57 | load_config_help[] = |
53 | "\n" | 58 | "\n" |
54 | "For various reasons, one may wish to keep several different\n" | 59 | "For various reasons, one may wish to keep several different kernel\n" |
55 | "configurations available on a single machine.\n" | 60 | "configurations available on a single machine.\n" |
56 | "\n" | 61 | "\n" |
57 | "If you have saved a previous configuration in a file other than the\n" | 62 | "If you have saved a previous configuration in a file other than the\n" |
58 | "default, entering the name of the file here will allow you\n" | 63 | "kernel's default, entering the name of the file here will allow you\n" |
59 | "to modify that configuration.\n" | 64 | "to modify that configuration.\n" |
60 | "\n" | 65 | "\n" |
61 | "If you are uncertain, then you have probably never used alternate\n" | 66 | "If you are uncertain, then you have probably never used alternate\n" |
62 | "configuration files. You should therefor leave this blank to abort.\n", | 67 | "configuration files. You should therefor leave this blank to abort.\n", |
63 | save_config_text[] = | 68 | save_config_text[] = |
64 | "Enter a filename to which this configuration should be saved " | 69 | "Enter a filename to which this configuration should be saved " |
65 | "as an alternate. Leave blank to abort.", | 70 | "as an alternate. Leave blank to abort.", |
66 | save_config_help[] = | 71 | save_config_help[] = |
67 | "\n" | 72 | "\n" |
68 | "For various reasons, one may wish to keep different\n" | 73 | "For various reasons, one may wish to keep different kernel\n" |
69 | "configurations available on a single machine.\n" | 74 | "configurations available on a single machine.\n" |
70 | "\n" | 75 | "\n" |
71 | "Entering a file name here will allow you to later retrieve, modify\n" | 76 | "Entering a file name here will allow you to later retrieve, modify\n" |
72 | "and use the current configuration as an alternate to whatever\n" | 77 | "and use the current configuration as an alternate to whatever\n" |
73 | "configuration options you have selected at that time.\n" | 78 | "configuration options you have selected at that time.\n" |
74 | "\n" | 79 | "\n" |
75 | "If you are uncertain what all this means then you should probably\n" | 80 | "If you are uncertain what all this means then you should probably\n" |
76 | "leave this blank.\n" | 81 | "leave this blank.\n" |
77 | ; | 82 | ; |
78 | 83 | ||
79 | static char buf[4096], *bufptr = buf; | 84 | static char buf[4096], *bufptr = buf; |
80 | static char input_buf[4096]; | 85 | static char input_buf[4096]; |
86 | static char filename[PATH_MAX+1] = ".config"; | ||
81 | static char *args[1024], **argptr = args; | 87 | static char *args[1024], **argptr = args; |
82 | static int indent = 0; | 88 | static int indent = 0; |
89 | static struct termios ios_org; | ||
83 | static int rows, cols; | 90 | static int rows, cols; |
84 | static struct menu *current_menu; | 91 | static struct menu *current_menu; |
85 | static int child_count; | 92 | static int child_count; |
86 | static int do_resize; | 93 | static int do_resize; |
94 | static int single_menu_mode; | ||
87 | 95 | ||
88 | static void conf(struct menu *menu); | 96 | static void conf(struct menu *menu); |
89 | static void conf_choice(struct menu *menu); | 97 | static void conf_choice(struct menu *menu); |
90 | static void conf_string(struct menu *menu); | 98 | static void conf_string(struct menu *menu); |
91 | static void conf_load(void); | 99 | static void conf_load(void); |
92 | static void conf_save(void); | 100 | static void conf_save(void); |
93 | static void show_textbox(const char *title, const char *text, int r, int c); | 101 | static void show_textbox(const char *title, const char *text, int r, int c); |
94 | static void show_helptext(const char *title, const char *text); | 102 | static void show_helptext(const char *title, const char *text); |
95 | static void show_help(struct menu *menu); | 103 | static void show_help(struct menu *menu); |
96 | static void show_readme(void); | 104 | static void show_readme(void); |
97 | 105 | ||
98 | static void cprint_init(void); | 106 | static void cprint_init(void); |
99 | static int cprint1(const char *fmt, ...); | 107 | static int cprint1(const char *fmt, ...); |
100 | static void cprint_done(void); | 108 | static void cprint_done(void); |
101 | static int cprint(const char *fmt, ...); | 109 | static int cprint(const char *fmt, ...); |
102 | 110 | ||
103 | static void init_wsize(void) | 111 | static void init_wsize(void) |
104 | { | 112 | { |
105 | struct winsize ws; | 113 | struct winsize ws; |
114 | char *env; | ||
106 | 115 | ||
107 | if (ioctl(1, TIOCGWINSZ, &ws) == -1) { | 116 | if (ioctl(1, TIOCGWINSZ, &ws) == -1) { |
108 | rows = 24; | 117 | rows = 24; |
109 | cols = 80; | 118 | cols = 80; |
110 | } else { | 119 | } else { |
111 | rows = ws.ws_row; | 120 | rows = ws.ws_row; |
112 | cols = ws.ws_col; | 121 | cols = ws.ws_col; |
122 | if (!rows) { | ||
123 | env = getenv("LINES"); | ||
124 | if (env) | ||
125 | rows = atoi(env); | ||
126 | if (!rows) | ||
127 | rows = 24; | ||
128 | } | ||
129 | if (!cols) { | ||
130 | env = getenv("COLUMNS"); | ||
131 | if (env) | ||
132 | cols = atoi(env); | ||
133 | if (!cols) | ||
134 | cols = 80; | ||
135 | } | ||
113 | } | 136 | } |
114 | 137 | ||
115 | if (rows < 19 || cols < 80) { | 138 | if (rows < 19 || cols < 80) { |
116 | fprintf(stderr, "Your display is too small to run Menuconfig!\n"); | 139 | fprintf(stderr, "Your display is too small to run Menuconfig!\n"); |
117 | fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); | 140 | fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); |
118 | exit(1); | 141 | exit(1); |
119 | } | 142 | } |
120 | 143 | ||
121 | rows -= 4; | 144 | rows -= 4; |
122 | cols -= 5; | 145 | cols -= 5; |
123 | } | 146 | } |
124 | 147 | ||
125 | static void cprint_init(void) | 148 | static void cprint_init(void) |
126 | { | 149 | { |
127 | bufptr = buf; | 150 | bufptr = buf; |
128 | argptr = args; | 151 | argptr = args; |
129 | memset(args, 0, sizeof(args)); | 152 | memset(args, 0, sizeof(args)); |
130 | indent = 0; | 153 | indent = 0; |
131 | child_count = 0; | 154 | child_count = 0; |
132 | cprint("./scripts/lxdialog/lxdialog"); | 155 | cprint("./scripts/lxdialog/lxdialog"); |
133 | cprint("--backtitle"); | 156 | cprint("--backtitle"); |
134 | cprint(menu_backtitle); | 157 | cprint(menu_backtitle); |
135 | } | 158 | } |
136 | 159 | ||
@@ -253,52 +276,62 @@ static int exec_conf(void) | |||
253 | return WEXITSTATUS(stat); | 276 | return WEXITSTATUS(stat); |
254 | } | 277 | } |
255 | 278 | ||
256 | static void build_conf(struct menu *menu) | 279 | static void build_conf(struct menu *menu) |
257 | { | 280 | { |
258 | struct symbol *sym; | 281 | struct symbol *sym; |
259 | struct property *prop; | 282 | struct property *prop; |
260 | struct menu *child; | 283 | struct menu *child; |
261 | int type, tmp, doint = 2; | 284 | int type, tmp, doint = 2; |
262 | tristate val; | 285 | tristate val; |
263 | char ch; | 286 | char ch; |
264 | 287 | ||
265 | if (!menu_is_visible(menu)) | 288 | if (!menu_is_visible(menu)) |
266 | return; | 289 | return; |
267 | 290 | ||
268 | sym = menu->sym; | 291 | sym = menu->sym; |
269 | prop = menu->prompt; | 292 | prop = menu->prompt; |
270 | if (!sym) { | 293 | if (!sym) { |
271 | if (prop && menu != current_menu) { | 294 | if (prop && menu != current_menu) { |
272 | const char *prompt = menu_get_prompt(menu); | 295 | const char *prompt = menu_get_prompt(menu); |
273 | switch (prop->type) { | 296 | switch (prop->type) { |
274 | case P_MENU: | 297 | case P_MENU: |
275 | child_count++; | 298 | child_count++; |
276 | cprint("m%p", menu); | 299 | cprint("m%p", menu); |
277 | if (menu->parent != &rootmenu) | 300 | |
278 | cprint1(" %*c", indent + 1, ' '); | 301 | if (single_menu_mode) { |
279 | cprint1("%s --->", prompt); | 302 | cprint1("%s%*c%s", |
303 | menu->data ? "-->" : "++>", | ||
304 | indent + 1, ' ', prompt); | ||
305 | } else { | ||
306 | if (menu->parent != &rootmenu) | ||
307 | cprint1(" %*c", indent + 1, ' '); | ||
308 | cprint1("%s --->", prompt); | ||
309 | } | ||
310 | |||
280 | cprint_done(); | 311 | cprint_done(); |
312 | if (single_menu_mode && menu->data) | ||
313 | goto conf_childs; | ||
281 | return; | 314 | return; |
282 | default: | 315 | default: |
283 | if (prompt) { | 316 | if (prompt) { |
284 | child_count++; | 317 | child_count++; |
285 | cprint(":%p", menu); | 318 | cprint(":%p", menu); |
286 | cprint("---%*c%s", indent + 1, ' ', prompt); | 319 | cprint("---%*c%s", indent + 1, ' ', prompt); |
287 | } | 320 | } |
288 | } | 321 | } |
289 | } else | 322 | } else |
290 | doint = 0; | 323 | doint = 0; |
291 | goto conf_childs; | 324 | goto conf_childs; |
292 | } | 325 | } |
293 | 326 | ||
294 | type = sym_get_type(sym); | 327 | type = sym_get_type(sym); |
295 | if (sym_is_choice(sym)) { | 328 | if (sym_is_choice(sym)) { |
296 | struct symbol *def_sym = sym_get_choice_value(sym); | 329 | struct symbol *def_sym = sym_get_choice_value(sym); |
297 | struct menu *def_menu = NULL; | 330 | struct menu *def_menu = NULL; |
298 | 331 | ||
299 | child_count++; | 332 | child_count++; |
300 | for (child = menu->list; child; child = child->next) { | 333 | for (child = menu->list; child; child = child->next) { |
301 | if (menu_is_visible(child) && child->sym == def_sym) | 334 | if (menu_is_visible(child) && child->sym == def_sym) |
302 | def_menu = child; | 335 | def_menu = child; |
303 | } | 336 | } |
304 | 337 | ||
@@ -371,48 +404,49 @@ static void build_conf(struct menu *menu) | |||
371 | cprint_done(); | 404 | cprint_done(); |
372 | goto conf_childs; | 405 | goto conf_childs; |
373 | } | 406 | } |
374 | } | 407 | } |
375 | cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), | 408 | cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), |
376 | sym_has_value(sym) ? "" : " (NEW)"); | 409 | sym_has_value(sym) ? "" : " (NEW)"); |
377 | cprint_done(); | 410 | cprint_done(); |
378 | } | 411 | } |
379 | 412 | ||
380 | conf_childs: | 413 | conf_childs: |
381 | indent += doint; | 414 | indent += doint; |
382 | for (child = menu->list; child; child = child->next) | 415 | for (child = menu->list; child; child = child->next) |
383 | build_conf(child); | 416 | build_conf(child); |
384 | indent -= doint; | 417 | indent -= doint; |
385 | } | 418 | } |
386 | 419 | ||
387 | static void conf(struct menu *menu) | 420 | static void conf(struct menu *menu) |
388 | { | 421 | { |
389 | struct menu *submenu; | 422 | struct menu *submenu; |
390 | const char *prompt = menu_get_prompt(menu); | 423 | const char *prompt = menu_get_prompt(menu); |
391 | struct symbol *sym; | 424 | struct symbol *sym; |
392 | char active_entry[40]; | 425 | char active_entry[40]; |
393 | int stat, type, i; | 426 | int stat, type, i; |
394 | 427 | ||
428 | unlink("lxdialog.scrltmp"); | ||
395 | active_entry[0] = 0; | 429 | active_entry[0] = 0; |
396 | while (1) { | 430 | while (1) { |
397 | cprint_init(); | 431 | cprint_init(); |
398 | cprint("--title"); | 432 | cprint("--title"); |
399 | cprint("%s", prompt ? prompt : "Main Menu"); | 433 | cprint("%s", prompt ? prompt : "Main Menu"); |
400 | cprint("--menu"); | 434 | cprint("--menu"); |
401 | cprint(menu_instructions); | 435 | cprint(menu_instructions); |
402 | cprint("%d", rows); | 436 | cprint("%d", rows); |
403 | cprint("%d", cols); | 437 | cprint("%d", cols); |
404 | cprint("%d", rows - 10); | 438 | cprint("%d", rows - 10); |
405 | cprint("%s", active_entry); | 439 | cprint("%s", active_entry); |
406 | current_menu = menu; | 440 | current_menu = menu; |
407 | build_conf(menu); | 441 | build_conf(menu); |
408 | if (!child_count) | 442 | if (!child_count) |
409 | break; | 443 | break; |
410 | if (menu == &rootmenu) { | 444 | if (menu == &rootmenu) { |
411 | cprint(":"); | 445 | cprint(":"); |
412 | cprint("--- "); | 446 | cprint("--- "); |
413 | cprint("L"); | 447 | cprint("L"); |
414 | cprint("Load an Alternate Configuration File"); | 448 | cprint("Load an Alternate Configuration File"); |
415 | cprint("S"); | 449 | cprint("S"); |
416 | cprint("Save Configuration to an Alternate File"); | 450 | cprint("Save Configuration to an Alternate File"); |
417 | } | 451 | } |
418 | stat = exec_conf(); | 452 | stat = exec_conf(); |
@@ -421,129 +455,142 @@ static void conf(struct menu *menu) | |||
421 | 455 | ||
422 | if (stat == 1 || stat == 255) | 456 | if (stat == 1 || stat == 255) |
423 | break; | 457 | break; |
424 | 458 | ||
425 | type = input_buf[0]; | 459 | type = input_buf[0]; |
426 | if (!type) | 460 | if (!type) |
427 | continue; | 461 | continue; |
428 | 462 | ||
429 | for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++) | 463 | for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++) |
430 | ; | 464 | ; |
431 | if (i >= sizeof(active_entry)) | 465 | if (i >= sizeof(active_entry)) |
432 | i = sizeof(active_entry) - 1; | 466 | i = sizeof(active_entry) - 1; |
433 | input_buf[i] = 0; | 467 | input_buf[i] = 0; |
434 | strcpy(active_entry, input_buf); | 468 | strcpy(active_entry, input_buf); |
435 | 469 | ||
436 | sym = NULL; | 470 | sym = NULL; |
437 | submenu = NULL; | 471 | submenu = NULL; |
438 | if (sscanf(input_buf + 1, "%p", &submenu) == 1) | 472 | if (sscanf(input_buf + 1, "%p", &submenu) == 1) |
439 | sym = submenu->sym; | 473 | sym = submenu->sym; |
440 | 474 | ||
441 | switch (stat) { | 475 | switch (stat) { |
442 | case 0: | 476 | case 0: |
443 | switch (type) { | 477 | switch (type) { |
444 | case 'm': | 478 | case 'm': |
445 | conf(submenu); | 479 | if (single_menu_mode) |
480 | submenu->data = (void *) !submenu->data; | ||
481 | else | ||
482 | conf(submenu); | ||
446 | break; | 483 | break; |
447 | case 't': | 484 | case 't': |
448 | if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) | 485 | if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) |
449 | conf_choice(submenu); | 486 | conf_choice(submenu); |
450 | break; | 487 | break; |
451 | case 's': | 488 | case 's': |
452 | conf_string(submenu); | 489 | conf_string(submenu); |
453 | break; | 490 | break; |
454 | case 'L': | 491 | case 'L': |
455 | conf_load(); | 492 | conf_load(); |
456 | break; | 493 | break; |
457 | case 'S': | 494 | case 'S': |
458 | conf_save(); | 495 | conf_save(); |
459 | break; | 496 | break; |
460 | } | 497 | } |
461 | break; | 498 | break; |
462 | case 2: | 499 | case 2: |
463 | if (sym) | 500 | if (sym) |
464 | show_help(submenu); | 501 | show_help(submenu); |
465 | else | 502 | else |
466 | show_readme(); | 503 | show_readme(); |
467 | break; | 504 | break; |
468 | case 3: | 505 | case 3: |
469 | if (type == 't') { | 506 | if (type == 't') { |
470 | if (sym_set_tristate_value(sym, yes)) | 507 | if (sym_set_tristate_value(sym, yes)) |
471 | break; | 508 | break; |
472 | if (sym_set_tristate_value(sym, mod)) | 509 | if (sym_set_tristate_value(sym, mod)) |
473 | show_textbox(NULL, setmod_text, 6, 74); | 510 | show_textbox(NULL, setmod_text, 6, 74); |
474 | } | 511 | } |
475 | break; | 512 | break; |
476 | case 4: | 513 | case 4: |
477 | if (type == 't') | 514 | if (type == 't') |
478 | sym_set_tristate_value(sym, no); | 515 | sym_set_tristate_value(sym, no); |
479 | break; | 516 | break; |
480 | case 5: | 517 | case 5: |
481 | if (type == 't') | 518 | if (type == 't') |
482 | sym_set_tristate_value(sym, mod); | 519 | sym_set_tristate_value(sym, mod); |
483 | break; | 520 | break; |
484 | case 6: | 521 | case 6: |
485 | if (type == 't') | 522 | if (type == 't') |
486 | sym_toggle_tristate_value(sym); | 523 | sym_toggle_tristate_value(sym); |
524 | else if (type == 'm') | ||
525 | conf(submenu); | ||
487 | break; | 526 | break; |
488 | } | 527 | } |
489 | } | 528 | } |
490 | } | 529 | } |
491 | 530 | ||
492 | static void show_textbox(const char *title, const char *text, int r, int c) | 531 | static void show_textbox(const char *title, const char *text, int r, int c) |
493 | { | 532 | { |
494 | int fd; | 533 | int fd; |
495 | 534 | ||
496 | fd = creat(".help.tmp", 0777); | 535 | fd = creat(".help.tmp", 0777); |
497 | write(fd, text, strlen(text)); | 536 | write(fd, text, strlen(text)); |
498 | close(fd); | 537 | close(fd); |
499 | do { | 538 | do { |
500 | cprint_init(); | 539 | cprint_init(); |
501 | if (title) { | 540 | if (title) { |
502 | cprint("--title"); | 541 | cprint("--title"); |
503 | cprint("%s", title); | 542 | cprint("%s", title); |
504 | } | 543 | } |
505 | cprint("--textbox"); | 544 | cprint("--textbox"); |
506 | cprint(".help.tmp"); | 545 | cprint(".help.tmp"); |
507 | cprint("%d", r); | 546 | cprint("%d", r); |
508 | cprint("%d", c); | 547 | cprint("%d", c); |
509 | } while (exec_conf() < 0); | 548 | } while (exec_conf() < 0); |
510 | unlink(".help.tmp"); | 549 | unlink(".help.tmp"); |
511 | } | 550 | } |
512 | 551 | ||
513 | static void show_helptext(const char *title, const char *text) | 552 | static void show_helptext(const char *title, const char *text) |
514 | { | 553 | { |
515 | show_textbox(title, text, rows, cols); | 554 | show_textbox(title, text, rows, cols); |
516 | } | 555 | } |
517 | 556 | ||
518 | static void show_help(struct menu *menu) | 557 | static void show_help(struct menu *menu) |
519 | { | 558 | { |
520 | const char *help; | 559 | const char *help; |
560 | char *helptext; | ||
561 | struct symbol *sym = menu->sym; | ||
521 | 562 | ||
522 | help = menu->sym->help; | 563 | help = sym->help; |
523 | if (!help) | 564 | if (!help) |
524 | help = nohelp_text; | 565 | help = nohelp_text; |
525 | show_helptext(menu_get_prompt(menu), help); | 566 | if (sym->name) { |
567 | helptext = malloc(strlen(sym->name) + strlen(help) + 16); | ||
568 | sprintf(helptext, "CONFIG_%s:\n\n%s", sym->name, help); | ||
569 | show_helptext(menu_get_prompt(menu), helptext); | ||
570 | free(helptext); | ||
571 | } else | ||
572 | show_helptext(menu_get_prompt(menu), help); | ||
526 | } | 573 | } |
527 | 574 | ||
528 | static void show_readme(void) | 575 | static void show_readme(void) |
529 | { | 576 | { |
530 | do { | 577 | do { |
531 | cprint_init(); | 578 | cprint_init(); |
532 | cprint("--textbox"); | 579 | cprint("--textbox"); |
533 | cprint("scripts/README.Menuconfig"); | 580 | cprint("scripts/README.Menuconfig"); |
534 | cprint("%d", rows); | 581 | cprint("%d", rows); |
535 | cprint("%d", cols); | 582 | cprint("%d", cols); |
536 | } while (exec_conf() == -1); | 583 | } while (exec_conf() == -1); |
537 | } | 584 | } |
538 | 585 | ||
539 | static void conf_choice(struct menu *menu) | 586 | static void conf_choice(struct menu *menu) |
540 | { | 587 | { |
541 | const char *prompt = menu_get_prompt(menu); | 588 | const char *prompt = menu_get_prompt(menu); |
542 | struct menu *child; | 589 | struct menu *child; |
543 | struct symbol *active; | 590 | struct symbol *active; |
544 | int stat; | 591 | int stat; |
545 | 592 | ||
546 | while (1) { | 593 | while (1) { |
547 | cprint_init(); | 594 | cprint_init(); |
548 | cprint("--title"); | 595 | cprint("--title"); |
549 | cprint("%s", prompt ? prompt : "Main Menu"); | 596 | cprint("%s", prompt ? prompt : "Main Menu"); |
@@ -610,102 +657,124 @@ static void conf_string(struct menu *menu) | |||
610 | case 0: | 657 | case 0: |
611 | if (sym_set_string_value(menu->sym, input_buf)) | 658 | if (sym_set_string_value(menu->sym, input_buf)) |
612 | return; | 659 | return; |
613 | show_textbox(NULL, "You have made an invalid entry.", 5, 43); | 660 | show_textbox(NULL, "You have made an invalid entry.", 5, 43); |
614 | break; | 661 | break; |
615 | case 1: | 662 | case 1: |
616 | show_help(menu); | 663 | show_help(menu); |
617 | break; | 664 | break; |
618 | case 255: | 665 | case 255: |
619 | return; | 666 | return; |
620 | } | 667 | } |
621 | } | 668 | } |
622 | } | 669 | } |
623 | 670 | ||
624 | static void conf_load(void) | 671 | static void conf_load(void) |
625 | { | 672 | { |
626 | int stat; | 673 | int stat; |
627 | 674 | ||
628 | while (1) { | 675 | while (1) { |
629 | cprint_init(); | 676 | cprint_init(); |
630 | cprint("--inputbox"); | 677 | cprint("--inputbox"); |
631 | cprint(load_config_text); | 678 | cprint(load_config_text); |
632 | cprint("11"); | 679 | cprint("11"); |
633 | cprint("55"); | 680 | cprint("55"); |
634 | cprint("%s", conf_filename); | 681 | cprint("%s", filename); |
635 | stat = exec_conf(); | 682 | stat = exec_conf(); |
636 | switch(stat) { | 683 | switch(stat) { |
637 | case 0: | 684 | case 0: |
638 | if (!input_buf[0]) | 685 | if (!input_buf[0]) |
639 | return; | 686 | return; |
640 | if (!conf_read(input_buf)) | 687 | if (!conf_read(input_buf)) |
641 | return; | 688 | return; |
642 | show_textbox(NULL, "File does not exist!", 5, 38); | 689 | show_textbox(NULL, "File does not exist!", 5, 38); |
643 | break; | 690 | break; |
644 | case 1: | 691 | case 1: |
645 | show_helptext("Load Alternate Configuration", load_config_help); | 692 | show_helptext("Load Alternate Configuration", load_config_help); |
646 | break; | 693 | break; |
647 | case 255: | 694 | case 255: |
648 | return; | 695 | return; |
649 | } | 696 | } |
650 | } | 697 | } |
651 | } | 698 | } |
652 | 699 | ||
653 | static void conf_save(void) | 700 | static void conf_save(void) |
654 | { | 701 | { |
655 | int stat; | 702 | int stat; |
656 | 703 | ||
657 | while (1) { | 704 | while (1) { |
658 | cprint_init(); | 705 | cprint_init(); |
659 | cprint("--inputbox"); | 706 | cprint("--inputbox"); |
660 | cprint(save_config_text); | 707 | cprint(save_config_text); |
661 | cprint("11"); | 708 | cprint("11"); |
662 | cprint("55"); | 709 | cprint("55"); |
663 | cprint("%s", conf_filename); | 710 | cprint("%s", filename); |
664 | stat = exec_conf(); | 711 | stat = exec_conf(); |
665 | switch(stat) { | 712 | switch(stat) { |
666 | case 0: | 713 | case 0: |
667 | if (!input_buf[0]) | 714 | if (!input_buf[0]) |
668 | return; | 715 | return; |
669 | if (!conf_write(input_buf)) | 716 | if (!conf_write(input_buf)) |
670 | return; | 717 | return; |
671 | show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); | 718 | show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); |
672 | break; | 719 | break; |
673 | case 1: | 720 | case 1: |
674 | show_helptext("Save Alternate Configuration", save_config_help); | 721 | show_helptext("Save Alternate Configuration", save_config_help); |
675 | break; | 722 | break; |
676 | case 255: | 723 | case 255: |
677 | return; | 724 | return; |
678 | } | 725 | } |
679 | } | 726 | } |
680 | } | 727 | } |
681 | 728 | ||
729 | static void conf_cleanup(void) | ||
730 | { | ||
731 | tcsetattr(1, TCSAFLUSH, &ios_org); | ||
732 | unlink(".help.tmp"); | ||
733 | unlink("lxdialog.scrltmp"); | ||
734 | } | ||
735 | |||
682 | int main(int ac, char **av) | 736 | int main(int ac, char **av) |
683 | { | 737 | { |
738 | struct symbol *sym; | ||
739 | char *mode; | ||
684 | int stat; | 740 | int stat; |
741 | |||
685 | conf_parse(av[1]); | 742 | conf_parse(av[1]); |
686 | conf_read(NULL); | 743 | conf_read(NULL); |
687 | 744 | ||
688 | sprintf(menu_backtitle, "Configuration"); | 745 | sym = sym_lookup("KERNELRELEASE", 0); |
746 | sym_calc_value(sym); | ||
747 | sprintf(menu_backtitle, "Linux Kernel v%s Configuration", | ||
748 | sym_get_string_value(sym)); | ||
749 | |||
750 | mode = getenv("MENUCONFIG_MODE"); | ||
751 | if (mode) { | ||
752 | if (!strcasecmp(mode, "single_menu")) | ||
753 | single_menu_mode = 1; | ||
754 | } | ||
689 | 755 | ||
756 | tcgetattr(1, &ios_org); | ||
757 | atexit(conf_cleanup); | ||
690 | init_wsize(); | 758 | init_wsize(); |
691 | conf(&rootmenu); | 759 | conf(&rootmenu); |
692 | 760 | ||
693 | do { | 761 | do { |
694 | cprint_init(); | 762 | cprint_init(); |
695 | cprint("--yesno"); | 763 | cprint("--yesno"); |
696 | cprint("Do you wish to save your new configuration?"); | 764 | cprint("Do you wish to save your new configuration?"); |
697 | cprint("5"); | 765 | cprint("5"); |
698 | cprint("60"); | 766 | cprint("60"); |
699 | stat = exec_conf(); | 767 | stat = exec_conf(); |
700 | } while (stat < 0); | 768 | } while (stat < 0); |
701 | 769 | ||
702 | if (stat == 0) { | 770 | if (stat == 0) { |
703 | conf_write(NULL); | 771 | conf_write(NULL); |
704 | printf("\n\n" | 772 | printf("\n\n" |
705 | "*** End of configuration.\n" | 773 | "*** End of Linux kernel configuration.\n" |
706 | "*** Check the top-level Makefile for additional configuration.\n"); | 774 | "*** Check the top-level Makefile for additional configuration.\n" |
775 | "*** Next, you may run 'make bzImage', 'make bzdisk', or 'make install'.\n\n"); | ||
707 | } else | 776 | } else |
708 | printf("\n\nYour configuration changes were NOT saved.\n\n"); | 777 | printf("\n\nYour kernel configuration changes were NOT saved.\n\n"); |
709 | 778 | ||
710 | return 0; | 779 | return 0; |
711 | } | 780 | } |