| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 
 | 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> | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 7 |  * | 
 | 8 |  * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 |  */ | 
 | 10 |  | 
 | 11 | #include <sys/ioctl.h> | 
 | 12 | #include <sys/wait.h> | 
 | 13 | #include <ctype.h> | 
 | 14 | #include <errno.h> | 
 | 15 | #include <fcntl.h> | 
 | 16 | #include <limits.h> | 
 | 17 | #include <signal.h> | 
 | 18 | #include <stdarg.h> | 
 | 19 | #include <stdlib.h> | 
 | 20 | #include <string.h> | 
 | 21 | #include <termios.h> | 
 | 22 | #include <unistd.h> | 
| Jean-Christophe Dubois | 442ff70 | 2005-06-25 14:55:43 -0700 | [diff] [blame] | 23 | #include <locale.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 |  | 
 | 25 | #define LKC_DIRECT_LINK | 
 | 26 | #include "lkc.h" | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 27 | #include "lxdialog/dialog.h" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 |  | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 29 | static const char mconf_readme[] = N_( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | "Overview\n" | 
 | 31 | "--------\n" | 
 | 32 | "Some kernel features may be built directly into the kernel.\n" | 
 | 33 | "Some may be made into loadable runtime modules.  Some features\n" | 
 | 34 | "may be completely removed altogether.  There are also certain\n" | 
 | 35 | "kernel parameters which are not really features, but must be\n" | 
 | 36 | "entered in as decimal or hexadecimal numbers or possibly text.\n" | 
 | 37 | "\n" | 
| Matej Laitl | b5d609d | 2007-10-02 13:46:50 -0700 | [diff] [blame] | 38 | "Menu items beginning with following braces represent features that\n" | 
 | 39 | "  [ ] can be built in or removed\n" | 
 | 40 | "  < > can be built in, modularized or removed\n" | 
 | 41 | "  { } can be built in or modularized (selected by other feature)\n" | 
 | 42 | "  - - are selected by other feature,\n" | 
 | 43 | "while *, M or whitespace inside braces means to build in, build as\n" | 
 | 44 | "a module or to exclude the feature respectively.\n" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | "\n" | 
 | 46 | "To change any of these features, highlight it with the cursor\n" | 
 | 47 | "keys and press <Y> to build it in, <M> to make it a module or\n" | 
 | 48 | "<N> to removed it.  You may also press the <Space Bar> to cycle\n" | 
 | 49 | "through the available options (ie. Y->N->M->Y).\n" | 
 | 50 | "\n" | 
 | 51 | "Some additional keyboard hints:\n" | 
 | 52 | "\n" | 
 | 53 | "Menus\n" | 
 | 54 | "----------\n" | 
 | 55 | "o  Use the Up/Down arrow keys (cursor keys) to highlight the item\n" | 
 | 56 | "   you wish to change or submenu wish to select and press <Enter>.\n" | 
 | 57 | "   Submenus are designated by \"--->\".\n" | 
 | 58 | "\n" | 
 | 59 | "   Shortcut: Press the option's highlighted letter (hotkey).\n" | 
 | 60 | "             Pressing a hotkey more than once will sequence\n" | 
 | 61 | "             through all visible items which use that hotkey.\n" | 
 | 62 | "\n" | 
 | 63 | "   You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n" | 
 | 64 | "   unseen options into view.\n" | 
 | 65 | "\n" | 
 | 66 | "o  To exit a menu use the cursor keys to highlight the <Exit> button\n" | 
 | 67 | "   and press <ENTER>.\n" | 
 | 68 | "\n" | 
 | 69 | "   Shortcut: Press <ESC><ESC> or <E> or <X> if there is no hotkey\n" | 
 | 70 | "             using those letters.  You may press a single <ESC>, but\n" | 
 | 71 | "             there is a delayed response which you may find annoying.\n" | 
 | 72 | "\n" | 
 | 73 | "   Also, the <TAB> and cursor keys will cycle between <Select>,\n" | 
 | 74 | "   <Exit> and <Help>\n" | 
 | 75 | "\n" | 
 | 76 | "o  To get help with an item, use the cursor keys to highlight <Help>\n" | 
 | 77 | "   and Press <ENTER>.\n" | 
 | 78 | "\n" | 
 | 79 | "   Shortcut: Press <H> or <?>.\n" | 
 | 80 | "\n" | 
 | 81 | "\n" | 
 | 82 | "Radiolists  (Choice lists)\n" | 
 | 83 | "-----------\n" | 
 | 84 | "o  Use the cursor keys to select the option you wish to set and press\n" | 
 | 85 | "   <S> or the <SPACE BAR>.\n" | 
 | 86 | "\n" | 
 | 87 | "   Shortcut: Press the first letter of the option you wish to set then\n" | 
 | 88 | "             press <S> or <SPACE BAR>.\n" | 
 | 89 | "\n" | 
 | 90 | "o  To see available help for the item, use the cursor keys to highlight\n" | 
 | 91 | "   <Help> and Press <ENTER>.\n" | 
 | 92 | "\n" | 
 | 93 | "   Shortcut: Press <H> or <?>.\n" | 
 | 94 | "\n" | 
 | 95 | "   Also, the <TAB> and cursor keys will cycle between <Select> and\n" | 
 | 96 | "   <Help>\n" | 
 | 97 | "\n" | 
 | 98 | "\n" | 
 | 99 | "Data Entry\n" | 
 | 100 | "-----------\n" | 
 | 101 | "o  Enter the requested information and press <ENTER>\n" | 
 | 102 | "   If you are entering hexadecimal values, it is not necessary to\n" | 
 | 103 | "   add the '0x' prefix to the entry.\n" | 
 | 104 | "\n" | 
 | 105 | "o  For help, use the <TAB> or cursor keys to highlight the help option\n" | 
 | 106 | "   and press <ENTER>.  You can try <TAB><H> as well.\n" | 
 | 107 | "\n" | 
 | 108 | "\n" | 
 | 109 | "Text Box    (Help Window)\n" | 
 | 110 | "--------\n" | 
 | 111 | "o  Use the cursor keys to scroll up/down/left/right.  The VI editor\n" | 
 | 112 | "   keys h,j,k,l function here as do <SPACE BAR> and <B> for those\n" | 
 | 113 | "   who are familiar with less and lynx.\n" | 
 | 114 | "\n" | 
 | 115 | "o  Press <E>, <X>, <Enter> or <Esc><Esc> to exit.\n" | 
 | 116 | "\n" | 
 | 117 | "\n" | 
 | 118 | "Alternate Configuration Files\n" | 
 | 119 | "-----------------------------\n" | 
 | 120 | "Menuconfig supports the use of alternate configuration files for\n" | 
 | 121 | "those who, for various reasons, find it necessary to switch\n" | 
 | 122 | "between different kernel configurations.\n" | 
 | 123 | "\n" | 
 | 124 | "At the end of the main menu you will find two options.  One is\n" | 
 | 125 | "for saving the current configuration to a file of your choosing.\n" | 
 | 126 | "The other option is for loading a previously saved alternate\n" | 
 | 127 | "configuration.\n" | 
 | 128 | "\n" | 
 | 129 | "Even if you don't use alternate configuration files, but you\n" | 
 | 130 | "find during a Menuconfig session that you have completely messed\n" | 
 | 131 | "up your settings, you may use the \"Load Alternate...\" option to\n" | 
 | 132 | "restore your previously saved settings from \".config\" without\n" | 
 | 133 | "restarting Menuconfig.\n" | 
 | 134 | "\n" | 
 | 135 | "Other information\n" | 
 | 136 | "-----------------\n" | 
 | 137 | "If you use Menuconfig in an XTERM window make sure you have your\n" | 
 | 138 | "$TERM variable set to point to a xterm definition which supports color.\n" | 
 | 139 | "Otherwise, Menuconfig will look rather bad.  Menuconfig will not\n" | 
 | 140 | "display correctly in a RXVT window because rxvt displays only one\n" | 
 | 141 | "intensity of color, bright.\n" | 
 | 142 | "\n" | 
 | 143 | "Menuconfig will display larger menus on screens or xterms which are\n" | 
 | 144 | "set to display more than the standard 25 row by 80 column geometry.\n" | 
 | 145 | "In order for this to work, the \"stty size\" command must be able to\n" | 
 | 146 | "display the screen's current row and column geometry.  I STRONGLY\n" | 
 | 147 | "RECOMMEND that you make sure you do NOT have the shell variables\n" | 
 | 148 | "LINES and COLUMNS exported into your environment.  Some distributions\n" | 
 | 149 | "export those variables via /etc/profile.  Some ncurses programs can\n" | 
 | 150 | "become confused when those variables (LINES & COLUMNS) don't reflect\n" | 
 | 151 | "the true screen size.\n" | 
 | 152 | "\n" | 
 | 153 | "Optional personality available\n" | 
 | 154 | "------------------------------\n" | 
 | 155 | "If you prefer to have all of the kernel options listed in a single\n" | 
 | 156 | "menu, rather than the default multimenu hierarchy, run the menuconfig\n" | 
 | 157 | "with MENUCONFIG_MODE environment variable set to single_menu. Example:\n" | 
 | 158 | "\n" | 
 | 159 | "make MENUCONFIG_MODE=single_menu menuconfig\n" | 
 | 160 | "\n" | 
 | 161 | "<Enter> will then unroll the appropriate category, or enfold it if it\n" | 
 | 162 | "is already unrolled.\n" | 
 | 163 | "\n" | 
 | 164 | "Note that this mode can eventually be a little more CPU expensive\n" | 
 | 165 | "(especially with a larger number of unrolled categories) than the\n" | 
| Sam Ravnborg | 4589721 | 2006-07-24 22:04:04 +0200 | [diff] [blame] | 166 | "default mode.\n" | 
 | 167 | "\n" | 
 | 168 | "Different color themes available\n" | 
 | 169 | "--------------------------------\n" | 
 | 170 | "It is possible to select different color themes using the variable\n" | 
 | 171 | "MENUCONFIG_COLOR. To select a theme use:\n" | 
 | 172 | "\n" | 
 | 173 | "make MENUCONFIG_COLOR=<theme> menuconfig\n" | 
 | 174 | "\n" | 
 | 175 | "Available themes are\n" | 
 | 176 | " mono       => selects colors suitable for monochrome displays\n" | 
 | 177 | " blackbg    => selects a color scheme with black background\n" | 
| Sam Ravnborg | 350b5b7 | 2006-07-24 22:19:51 +0200 | [diff] [blame] | 178 | " classic    => theme with blue background. The classic look\n" | 
 | 179 | " bluetitle  => a LCD friendly version of classic. (default)\n" | 
| Sam Ravnborg | 4589721 | 2006-07-24 22:04:04 +0200 | [diff] [blame] | 180 | "\n"), | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 181 | menu_instructions[] = N_( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | 	"Arrow keys navigate the menu.  " | 
 | 183 | 	"<Enter> selects submenus --->.  " | 
 | 184 | 	"Highlighted letters are hotkeys.  " | 
 | 185 | 	"Pressing <Y> includes, <N> excludes, <M> modularizes features.  " | 
 | 186 | 	"Press <Esc><Esc> to exit, <?> for Help, </> for Search.  " | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 187 | 	"Legend: [*] built-in  [ ] excluded  <M> module  < > module capable"), | 
 | 188 | radiolist_instructions[] = N_( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | 	"Use the arrow keys to navigate this window or " | 
 | 190 | 	"press the hotkey of the item you wish to select " | 
 | 191 | 	"followed by the <SPACE BAR>. " | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 192 | 	"Press <?> for additional information about this option."), | 
 | 193 | inputbox_instructions_int[] = N_( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | 	"Please enter a decimal value. " | 
 | 195 | 	"Fractions will not be accepted.  " | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 196 | 	"Use the <TAB> key to move from the input field to the buttons below it."), | 
 | 197 | inputbox_instructions_hex[] = N_( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | 	"Please enter a hexadecimal value. " | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 199 | 	"Use the <TAB> key to move from the input field to the buttons below it."), | 
 | 200 | inputbox_instructions_string[] = N_( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | 	"Please enter a string value. " | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 202 | 	"Use the <TAB> key to move from the input field to the buttons below it."), | 
 | 203 | setmod_text[] = N_( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | 	"This feature depends on another which has been configured as a module.\n" | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 205 | 	"As a result, this feature will be built as a module."), | 
 | 206 | nohelp_text[] = N_( | 
 | 207 | 	"There is no help available for this kernel option.\n"), | 
 | 208 | load_config_text[] = N_( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | 	"Enter the name of the configuration file you wish to load.  " | 
 | 210 | 	"Accept the name shown to restore the configuration you " | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 211 | 	"last retrieved.  Leave blank to abort."), | 
 | 212 | load_config_help[] = N_( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | 	"\n" | 
 | 214 | 	"For various reasons, one may wish to keep several different kernel\n" | 
 | 215 | 	"configurations available on a single machine.\n" | 
 | 216 | 	"\n" | 
 | 217 | 	"If you have saved a previous configuration in a file other than the\n" | 
 | 218 | 	"kernel's default, entering the name of the file here will allow you\n" | 
 | 219 | 	"to modify that configuration.\n" | 
 | 220 | 	"\n" | 
 | 221 | 	"If you are uncertain, then you have probably never used alternate\n" | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 222 | 	"configuration files.  You should therefor leave this blank to abort.\n"), | 
 | 223 | save_config_text[] = N_( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | 	"Enter a filename to which this configuration should be saved " | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 225 | 	"as an alternate.  Leave blank to abort."), | 
 | 226 | save_config_help[] = N_( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | 	"\n" | 
 | 228 | 	"For various reasons, one may wish to keep different kernel\n" | 
 | 229 | 	"configurations available on a single machine.\n" | 
 | 230 | 	"\n" | 
 | 231 | 	"Entering a file name here will allow you to later retrieve, modify\n" | 
 | 232 | 	"and use the current configuration as an alternate to whatever\n" | 
 | 233 | 	"configuration options you have selected at that time.\n" | 
 | 234 | 	"\n" | 
 | 235 | 	"If you are uncertain what all this means then you should probably\n" | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 236 | 	"leave this blank.\n"), | 
 | 237 | search_help[] = N_( | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | 	"\n" | 
 | 239 | 	"Search for CONFIG_ symbols and display their relations.\n" | 
| Randy Dunlap | 503af33 | 2005-10-30 15:02:15 -0800 | [diff] [blame] | 240 | 	"Regular expressions are allowed.\n" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | 	"Example: search for \"^FOO\"\n" | 
 | 242 | 	"Result:\n" | 
 | 243 | 	"-----------------------------------------------------------------\n" | 
 | 244 | 	"Symbol: FOO [=m]\n" | 
 | 245 | 	"Prompt: Foo bus is used to drive the bar HW\n" | 
 | 246 | 	"Defined at drivers/pci/Kconfig:47\n" | 
 | 247 | 	"Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" | 
 | 248 | 	"Location:\n" | 
 | 249 | 	"  -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n" | 
 | 250 | 	"    -> PCI support (PCI [=y])\n" | 
 | 251 | 	"      -> PCI access mode (<choice> [=y])\n" | 
 | 252 | 	"Selects: LIBCRC32\n" | 
 | 253 | 	"Selected by: BAR\n" | 
 | 254 | 	"-----------------------------------------------------------------\n" | 
 | 255 | 	"o The line 'Prompt:' shows the text used in the menu structure for\n" | 
 | 256 | 	"  this CONFIG_ symbol\n" | 
 | 257 | 	"o The 'Defined at' line tell at what file / line number the symbol\n" | 
 | 258 | 	"  is defined\n" | 
 | 259 | 	"o The 'Depends on:' line tell what symbols needs to be defined for\n" | 
 | 260 | 	"  this symbol to be visible in the menu (selectable)\n" | 
 | 261 | 	"o The 'Location:' lines tell where in the menu structure this symbol\n" | 
 | 262 | 	"  is located\n" | 
 | 263 | 	"    A location followed by a [=y] indicate that this is a selectable\n" | 
 | 264 | 	"    menu item - and current value is displayed inside brackets.\n" | 
 | 265 | 	"o The 'Selects:' line tell what symbol will be automatically\n" | 
 | 266 | 	"  selected if this symbol is selected (y or m)\n" | 
 | 267 | 	"o The 'Selected by' line tell what symbol has selected this symbol\n" | 
 | 268 | 	"\n" | 
 | 269 | 	"Only relevant lines are shown.\n" | 
 | 270 | 	"\n\n" | 
 | 271 | 	"Search examples:\n" | 
 | 272 | 	"Examples: USB	=> find all CONFIG_ symbols containing USB\n" | 
 | 273 | 	"          ^USB => find all CONFIG_ symbols starting with USB\n" | 
 | 274 | 	"          USB$ => find all CONFIG_ symbols ending with USB\n" | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 275 | 	"\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | static int indent; | 
 | 278 | static struct termios ios_org; | 
 | 279 | static int rows = 0, cols = 0; | 
 | 280 | static struct menu *current_menu; | 
 | 281 | static int child_count; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | static int single_menu_mode; | 
 | 283 |  | 
 | 284 | static void conf(struct menu *menu); | 
 | 285 | static void conf_choice(struct menu *menu); | 
 | 286 | static void conf_string(struct menu *menu); | 
 | 287 | static void conf_load(void); | 
 | 288 | static void conf_save(void); | 
 | 289 | static void show_textbox(const char *title, const char *text, int r, int c); | 
 | 290 | static void show_helptext(const char *title, const char *text); | 
 | 291 | static void show_help(struct menu *menu); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 |  | 
 | 293 | static void init_wsize(void) | 
 | 294 | { | 
 | 295 | 	struct winsize ws; | 
 | 296 | 	char *env; | 
 | 297 |  | 
 | 298 | 	if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) { | 
 | 299 | 		rows = ws.ws_row; | 
 | 300 | 		cols = ws.ws_col; | 
 | 301 | 	} | 
 | 302 |  | 
 | 303 | 	if (!rows) { | 
 | 304 | 		env = getenv("LINES"); | 
 | 305 | 		if (env) | 
 | 306 | 			rows = atoi(env); | 
 | 307 | 		if (!rows) | 
 | 308 | 			rows = 24; | 
 | 309 | 	} | 
 | 310 | 	if (!cols) { | 
 | 311 | 		env = getenv("COLUMNS"); | 
 | 312 | 		if (env) | 
 | 313 | 			cols = atoi(env); | 
 | 314 | 		if (!cols) | 
 | 315 | 			cols = 80; | 
 | 316 | 	} | 
 | 317 |  | 
 | 318 | 	if (rows < 19 || cols < 80) { | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 319 | 		fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); | 
 | 320 | 		fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | 		exit(1); | 
 | 322 | 	} | 
 | 323 |  | 
 | 324 | 	rows -= 4; | 
 | 325 | 	cols -= 5; | 
 | 326 | } | 
 | 327 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | static void get_prompt_str(struct gstr *r, struct property *prop) | 
 | 329 | { | 
 | 330 | 	int i, j; | 
 | 331 | 	struct menu *submenu[8], *menu; | 
 | 332 |  | 
 | 333 | 	str_printf(r, "Prompt: %s\n", prop->text); | 
 | 334 | 	str_printf(r, "  Defined at %s:%d\n", prop->menu->file->name, | 
 | 335 | 		prop->menu->lineno); | 
 | 336 | 	if (!expr_is_yes(prop->visible.expr)) { | 
 | 337 | 		str_append(r, "  Depends on: "); | 
 | 338 | 		expr_gstr_print(prop->visible.expr, r); | 
 | 339 | 		str_append(r, "\n"); | 
 | 340 | 	} | 
 | 341 | 	menu = prop->menu->parent; | 
 | 342 | 	for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) | 
 | 343 | 		submenu[i++] = menu; | 
 | 344 | 	if (i > 0) { | 
 | 345 | 		str_printf(r, "  Location:\n"); | 
 | 346 | 		for (j = 4; --i >= 0; j += 2) { | 
 | 347 | 			menu = submenu[i]; | 
 | 348 | 			str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu)); | 
 | 349 | 			if (menu->sym) { | 
 | 350 | 				str_printf(r, " (%s [=%s])", menu->sym->name ? | 
 | 351 | 					menu->sym->name : "<choice>", | 
 | 352 | 					sym_get_string_value(menu->sym)); | 
 | 353 | 			} | 
 | 354 | 			str_append(r, "\n"); | 
 | 355 | 		} | 
 | 356 | 	} | 
 | 357 | } | 
 | 358 |  | 
 | 359 | static void get_symbol_str(struct gstr *r, struct symbol *sym) | 
 | 360 | { | 
 | 361 | 	bool hit; | 
 | 362 | 	struct property *prop; | 
 | 363 |  | 
| Sam Ravnborg | a67cb13 | 2007-09-19 21:23:09 +0200 | [diff] [blame] | 364 | 	if (sym && sym->name) | 
 | 365 | 		str_printf(r, "Symbol: %s [=%s]\n", sym->name, | 
 | 366 | 		                                    sym_get_string_value(sym)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | 	for_all_prompts(sym, prop) | 
 | 368 | 		get_prompt_str(r, prop); | 
 | 369 | 	hit = false; | 
 | 370 | 	for_all_properties(sym, prop, P_SELECT) { | 
 | 371 | 		if (!hit) { | 
 | 372 | 			str_append(r, "  Selects: "); | 
 | 373 | 			hit = true; | 
 | 374 | 		} else | 
 | 375 | 			str_printf(r, " && "); | 
 | 376 | 		expr_gstr_print(prop->expr, r); | 
 | 377 | 	} | 
 | 378 | 	if (hit) | 
 | 379 | 		str_append(r, "\n"); | 
 | 380 | 	if (sym->rev_dep.expr) { | 
 | 381 | 		str_append(r, "  Selected by: "); | 
 | 382 | 		expr_gstr_print(sym->rev_dep.expr, r); | 
 | 383 | 		str_append(r, "\n"); | 
 | 384 | 	} | 
 | 385 | 	str_append(r, "\n\n"); | 
 | 386 | } | 
 | 387 |  | 
 | 388 | static struct gstr get_relations_str(struct symbol **sym_arr) | 
 | 389 | { | 
 | 390 | 	struct symbol *sym; | 
 | 391 | 	struct gstr res = str_new(); | 
 | 392 | 	int i; | 
 | 393 |  | 
 | 394 | 	for (i = 0; sym_arr && (sym = sym_arr[i]); i++) | 
 | 395 | 		get_symbol_str(&res, sym); | 
 | 396 | 	if (!i) | 
 | 397 | 		str_append(&res, "No matches found.\n"); | 
 | 398 | 	return res; | 
 | 399 | } | 
 | 400 |  | 
| Sam Ravnborg | 95e30f9 | 2007-03-18 10:48:46 +0100 | [diff] [blame] | 401 | static char filename[PATH_MAX+1]; | 
 | 402 | static void set_config_filename(const char *config_filename) | 
 | 403 | { | 
 | 404 | 	static char menu_backtitle[PATH_MAX+128]; | 
 | 405 | 	int size; | 
 | 406 | 	struct symbol *sym; | 
 | 407 |  | 
 | 408 | 	sym = sym_lookup("KERNELVERSION", 0); | 
 | 409 | 	sym_calc_value(sym); | 
 | 410 | 	size = snprintf(menu_backtitle, sizeof(menu_backtitle), | 
 | 411 | 	                _("%s - Linux Kernel v%s Configuration"), | 
 | 412 | 		        config_filename, sym_get_string_value(sym)); | 
 | 413 | 	if (size >= sizeof(menu_backtitle)) | 
 | 414 | 		menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; | 
 | 415 | 	set_dialog_backtitle(menu_backtitle); | 
 | 416 |  | 
 | 417 | 	size = snprintf(filename, sizeof(filename), "%s", config_filename); | 
 | 418 | 	if (size >= sizeof(filename)) | 
 | 419 | 		filename[sizeof(filename)-1] = '\0'; | 
 | 420 | } | 
 | 421 |  | 
 | 422 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | static void search_conf(void) | 
 | 424 | { | 
 | 425 | 	struct symbol **sym_arr; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | 	struct gstr res; | 
| Bernhard Walle | 0584f9f | 2007-07-09 11:43:56 -0700 | [diff] [blame] | 427 | 	char *dialog_input; | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 428 | 	int dres; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | again: | 
| Sam Ravnborg | e94c5bd | 2006-09-25 17:35:43 +0200 | [diff] [blame] | 430 | 	dialog_clear(); | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 431 | 	dres = dialog_inputbox(_("Search Configuration Parameter"), | 
| Bernhard Walle | 0584f9f | 2007-07-09 11:43:56 -0700 | [diff] [blame] | 432 | 			      _("Enter CONFIG_ (sub)string to search for " | 
 | 433 | 				"(with or without \"CONFIG\")"), | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 434 | 			      10, 75, ""); | 
 | 435 | 	switch (dres) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | 	case 0: | 
 | 437 | 		break; | 
 | 438 | 	case 1: | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 439 | 		show_helptext(_("Search Configuration"), search_help); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | 		goto again; | 
 | 441 | 	default: | 
 | 442 | 		return; | 
 | 443 | 	} | 
 | 444 |  | 
| Bernhard Walle | 0584f9f | 2007-07-09 11:43:56 -0700 | [diff] [blame] | 445 | 	/* strip CONFIG_ if necessary */ | 
 | 446 | 	dialog_input = dialog_input_result; | 
 | 447 | 	if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0) | 
 | 448 | 		dialog_input += 7; | 
 | 449 |  | 
 | 450 | 	sym_arr = sym_re_search(dialog_input); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | 	res = get_relations_str(sym_arr); | 
 | 452 | 	free(sym_arr); | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 453 | 	show_textbox(_("Search Results"), str_get(&res), 0, 0); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | 	str_free(&res); | 
 | 455 | } | 
 | 456 |  | 
 | 457 | static void build_conf(struct menu *menu) | 
 | 458 | { | 
 | 459 | 	struct symbol *sym; | 
 | 460 | 	struct property *prop; | 
 | 461 | 	struct menu *child; | 
 | 462 | 	int type, tmp, doint = 2; | 
 | 463 | 	tristate val; | 
 | 464 | 	char ch; | 
 | 465 |  | 
 | 466 | 	if (!menu_is_visible(menu)) | 
 | 467 | 		return; | 
 | 468 |  | 
 | 469 | 	sym = menu->sym; | 
 | 470 | 	prop = menu->prompt; | 
 | 471 | 	if (!sym) { | 
 | 472 | 		if (prop && menu != current_menu) { | 
 | 473 | 			const char *prompt = menu_get_prompt(menu); | 
 | 474 | 			switch (prop->type) { | 
 | 475 | 			case P_MENU: | 
 | 476 | 				child_count++; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | 				if (single_menu_mode) { | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 478 | 					item_make("%s%*c%s", | 
 | 479 | 						  menu->data ? "-->" : "++>", | 
 | 480 | 						  indent + 1, ' ', prompt); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | 				} else | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 482 | 					item_make("   %*c%s  --->", indent + 1, ' ', prompt); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 |  | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 484 | 				item_set_tag('m'); | 
 | 485 | 				item_set_data(menu); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | 				if (single_menu_mode && menu->data) | 
 | 487 | 					goto conf_childs; | 
 | 488 | 				return; | 
| Sam Ravnborg | 4887407 | 2007-09-18 21:12:26 +0200 | [diff] [blame] | 489 | 			case P_COMMENT: | 
 | 490 | 				if (prompt) { | 
 | 491 | 					child_count++; | 
 | 492 | 					item_make("   %*c*** %s ***", indent + 1, ' ', prompt); | 
 | 493 | 					item_set_tag(':'); | 
 | 494 | 					item_set_data(menu); | 
 | 495 | 				} | 
 | 496 | 				break; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | 			default: | 
 | 498 | 				if (prompt) { | 
 | 499 | 					child_count++; | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 500 | 					item_make("---%*c%s", indent + 1, ' ', prompt); | 
 | 501 | 					item_set_tag(':'); | 
 | 502 | 					item_set_data(menu); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | 				} | 
 | 504 | 			} | 
 | 505 | 		} else | 
 | 506 | 			doint = 0; | 
 | 507 | 		goto conf_childs; | 
 | 508 | 	} | 
 | 509 |  | 
 | 510 | 	type = sym_get_type(sym); | 
 | 511 | 	if (sym_is_choice(sym)) { | 
 | 512 | 		struct symbol *def_sym = sym_get_choice_value(sym); | 
 | 513 | 		struct menu *def_menu = NULL; | 
 | 514 |  | 
 | 515 | 		child_count++; | 
 | 516 | 		for (child = menu->list; child; child = child->next) { | 
 | 517 | 			if (menu_is_visible(child) && child->sym == def_sym) | 
 | 518 | 				def_menu = child; | 
 | 519 | 		} | 
 | 520 |  | 
 | 521 | 		val = sym_get_tristate_value(sym); | 
 | 522 | 		if (sym_is_changable(sym)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | 			switch (type) { | 
 | 524 | 			case S_BOOLEAN: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 525 | 				item_make("[%c]", val == no ? ' ' : '*'); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | 				break; | 
 | 527 | 			case S_TRISTATE: | 
 | 528 | 				switch (val) { | 
 | 529 | 				case yes: ch = '*'; break; | 
 | 530 | 				case mod: ch = 'M'; break; | 
 | 531 | 				default:  ch = ' '; break; | 
 | 532 | 				} | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 533 | 				item_make("<%c>", ch); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | 				break; | 
 | 535 | 			} | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 536 | 			item_set_tag('t'); | 
 | 537 | 			item_set_data(menu); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | 		} else { | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 539 | 			item_make("   "); | 
 | 540 | 			item_set_tag(def_menu ? 't' : ':'); | 
 | 541 | 			item_set_data(menu); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | 		} | 
 | 543 |  | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 544 | 		item_add_str("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | 		if (val == yes) { | 
 | 546 | 			if (def_menu) { | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 547 | 				item_add_str(" (%s)", menu_get_prompt(def_menu)); | 
 | 548 | 				item_add_str("  --->"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | 				if (def_menu->list) { | 
 | 550 | 					indent += 2; | 
 | 551 | 					build_conf(def_menu); | 
 | 552 | 					indent -= 2; | 
 | 553 | 				} | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 554 | 			} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | 			return; | 
 | 556 | 		} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | 	} else { | 
 | 558 | 		if (menu == current_menu) { | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 559 | 			item_make("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); | 
 | 560 | 			item_set_tag(':'); | 
 | 561 | 			item_set_data(menu); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | 			goto conf_childs; | 
 | 563 | 		} | 
 | 564 | 		child_count++; | 
 | 565 | 		val = sym_get_tristate_value(sym); | 
 | 566 | 		if (sym_is_choice_value(sym) && val == yes) { | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 567 | 			item_make("   "); | 
 | 568 | 			item_set_tag(':'); | 
 | 569 | 			item_set_data(menu); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | 		} else { | 
 | 571 | 			switch (type) { | 
 | 572 | 			case S_BOOLEAN: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | 				if (sym_is_changable(sym)) | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 574 | 					item_make("[%c]", val == no ? ' ' : '*'); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | 				else | 
| Matej Laitl | b5d609d | 2007-10-02 13:46:50 -0700 | [diff] [blame] | 576 | 					item_make("-%c-", val == no ? ' ' : '*'); | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 577 | 				item_set_tag('t'); | 
 | 578 | 				item_set_data(menu); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | 				break; | 
 | 580 | 			case S_TRISTATE: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | 				switch (val) { | 
 | 582 | 				case yes: ch = '*'; break; | 
 | 583 | 				case mod: ch = 'M'; break; | 
 | 584 | 				default:  ch = ' '; break; | 
 | 585 | 				} | 
| Matej Laitl | b5d609d | 2007-10-02 13:46:50 -0700 | [diff] [blame] | 586 | 				if (sym_is_changable(sym)) { | 
 | 587 | 					if (sym->rev_dep.tri == mod) | 
 | 588 | 						item_make("{%c}", ch); | 
 | 589 | 					else | 
 | 590 | 						item_make("<%c>", ch); | 
 | 591 | 				} else | 
 | 592 | 					item_make("-%c-", ch); | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 593 | 				item_set_tag('t'); | 
 | 594 | 				item_set_data(menu); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | 				break; | 
 | 596 | 			default: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 597 | 				tmp = 2 + strlen(sym_get_string_value(sym)); /* () = 2 */ | 
 | 598 | 				item_make("(%s)", sym_get_string_value(sym)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | 				tmp = indent - tmp + 4; | 
 | 600 | 				if (tmp < 0) | 
 | 601 | 					tmp = 0; | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 602 | 				item_add_str("%*c%s%s", tmp, ' ', menu_get_prompt(menu), | 
 | 603 | 					     (sym_has_value(sym) || !sym_is_changable(sym)) ? | 
 | 604 | 					     "" : " (NEW)"); | 
 | 605 | 				item_set_tag('s'); | 
 | 606 | 				item_set_data(menu); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | 				goto conf_childs; | 
 | 608 | 			} | 
 | 609 | 		} | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 610 | 		item_add_str("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), | 
 | 611 | 			  (sym_has_value(sym) || !sym_is_changable(sym)) ? | 
 | 612 | 			  "" : " (NEW)"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | 		if (menu->prompt->type == P_MENU) { | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 614 | 			item_add_str("  --->"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | 			return; | 
 | 616 | 		} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | 	} | 
 | 618 |  | 
 | 619 | conf_childs: | 
 | 620 | 	indent += doint; | 
 | 621 | 	for (child = menu->list; child; child = child->next) | 
 | 622 | 		build_conf(child); | 
 | 623 | 	indent -= doint; | 
 | 624 | } | 
 | 625 |  | 
 | 626 | static void conf(struct menu *menu) | 
 | 627 | { | 
 | 628 | 	struct menu *submenu; | 
 | 629 | 	const char *prompt = menu_get_prompt(menu); | 
 | 630 | 	struct symbol *sym; | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 631 | 	struct menu *active_menu = NULL; | 
 | 632 | 	int res; | 
 | 633 | 	int s_scroll = 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | 	while (1) { | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 636 | 		item_reset(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | 		current_menu = menu; | 
 | 638 | 		build_conf(menu); | 
 | 639 | 		if (!child_count) | 
 | 640 | 			break; | 
 | 641 | 		if (menu == &rootmenu) { | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 642 | 			item_make("--- "); | 
 | 643 | 			item_set_tag(':'); | 
 | 644 | 			item_make(_("    Load an Alternate Configuration File")); | 
 | 645 | 			item_set_tag('L'); | 
 | 646 | 			item_make(_("    Save an Alternate Configuration File")); | 
 | 647 | 			item_set_tag('S'); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | 		} | 
| Sam Ravnborg | e94c5bd | 2006-09-25 17:35:43 +0200 | [diff] [blame] | 649 | 		dialog_clear(); | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 650 | 		res = dialog_menu(prompt ? prompt : _("Main Menu"), | 
 | 651 | 				  _(menu_instructions), | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 652 | 				  active_menu, &s_scroll); | 
| Sam Ravnborg | c8dc68a | 2006-07-29 22:48:57 +0200 | [diff] [blame] | 653 | 		if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | 			break; | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 655 | 		if (!item_activate_selected()) | 
 | 656 | 			continue; | 
 | 657 | 		if (!item_tag()) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | 			continue; | 
 | 659 |  | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 660 | 		submenu = item_data(); | 
 | 661 | 		active_menu = item_data(); | 
| Sam Ravnborg | c8dc68a | 2006-07-29 22:48:57 +0200 | [diff] [blame] | 662 | 		if (submenu) | 
 | 663 | 			sym = submenu->sym; | 
 | 664 | 		else | 
 | 665 | 			sym = NULL; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 |  | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 667 | 		switch (res) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | 		case 0: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 669 | 			switch (item_tag()) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | 			case 'm': | 
 | 671 | 				if (single_menu_mode) | 
 | 672 | 					submenu->data = (void *) (long) !submenu->data; | 
 | 673 | 				else | 
 | 674 | 					conf(submenu); | 
 | 675 | 				break; | 
 | 676 | 			case 't': | 
 | 677 | 				if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) | 
 | 678 | 					conf_choice(submenu); | 
 | 679 | 				else if (submenu->prompt->type == P_MENU) | 
 | 680 | 					conf(submenu); | 
 | 681 | 				break; | 
 | 682 | 			case 's': | 
 | 683 | 				conf_string(submenu); | 
 | 684 | 				break; | 
 | 685 | 			case 'L': | 
 | 686 | 				conf_load(); | 
 | 687 | 				break; | 
 | 688 | 			case 'S': | 
 | 689 | 				conf_save(); | 
 | 690 | 				break; | 
 | 691 | 			} | 
 | 692 | 			break; | 
 | 693 | 		case 2: | 
 | 694 | 			if (sym) | 
 | 695 | 				show_help(submenu); | 
 | 696 | 			else | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 697 | 				show_helptext("README", _(mconf_readme)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | 			break; | 
 | 699 | 		case 3: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 700 | 			if (item_is_tag('t')) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | 				if (sym_set_tristate_value(sym, yes)) | 
 | 702 | 					break; | 
 | 703 | 				if (sym_set_tristate_value(sym, mod)) | 
 | 704 | 					show_textbox(NULL, setmod_text, 6, 74); | 
 | 705 | 			} | 
 | 706 | 			break; | 
 | 707 | 		case 4: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 708 | 			if (item_is_tag('t')) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | 				sym_set_tristate_value(sym, no); | 
 | 710 | 			break; | 
 | 711 | 		case 5: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 712 | 			if (item_is_tag('t')) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | 				sym_set_tristate_value(sym, mod); | 
 | 714 | 			break; | 
 | 715 | 		case 6: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 716 | 			if (item_is_tag('t')) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 717 | 				sym_toggle_tristate_value(sym); | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 718 | 			else if (item_is_tag('m')) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | 				conf(submenu); | 
 | 720 | 			break; | 
 | 721 | 		case 7: | 
 | 722 | 			search_conf(); | 
 | 723 | 			break; | 
 | 724 | 		} | 
 | 725 | 	} | 
 | 726 | } | 
 | 727 |  | 
 | 728 | static void show_textbox(const char *title, const char *text, int r, int c) | 
 | 729 | { | 
| Sam Ravnborg | e94c5bd | 2006-09-25 17:35:43 +0200 | [diff] [blame] | 730 | 	dialog_clear(); | 
| Sam Ravnborg | c8dc68a | 2006-07-29 22:48:57 +0200 | [diff] [blame] | 731 | 	dialog_textbox(title, text, r, c); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 732 | } | 
 | 733 |  | 
 | 734 | static void show_helptext(const char *title, const char *text) | 
 | 735 | { | 
 | 736 | 	show_textbox(title, text, 0, 0); | 
 | 737 | } | 
 | 738 |  | 
 | 739 | static void show_help(struct menu *menu) | 
 | 740 | { | 
 | 741 | 	struct gstr help = str_new(); | 
 | 742 | 	struct symbol *sym = menu->sym; | 
 | 743 |  | 
| Sam Ravnborg | 03d2912 | 2007-07-21 00:00:36 +0200 | [diff] [blame] | 744 | 	if (menu_has_help(menu)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | 	{ | 
 | 746 | 		if (sym->name) { | 
 | 747 | 			str_printf(&help, "CONFIG_%s:\n\n", sym->name); | 
| Sam Ravnborg | 03d2912 | 2007-07-21 00:00:36 +0200 | [diff] [blame] | 748 | 			str_append(&help, _(menu_get_help(menu))); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | 			str_append(&help, "\n"); | 
 | 750 | 		} | 
 | 751 | 	} else { | 
 | 752 | 		str_append(&help, nohelp_text); | 
 | 753 | 	} | 
 | 754 | 	get_symbol_str(&help, sym); | 
 | 755 | 	show_helptext(menu_get_prompt(menu), str_get(&help)); | 
 | 756 | 	str_free(&help); | 
 | 757 | } | 
 | 758 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | static void conf_choice(struct menu *menu) | 
 | 760 | { | 
 | 761 | 	const char *prompt = menu_get_prompt(menu); | 
 | 762 | 	struct menu *child; | 
 | 763 | 	struct symbol *active; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 |  | 
 | 765 | 	active = sym_get_choice_value(menu->sym); | 
 | 766 | 	while (1) { | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 767 | 		int res; | 
 | 768 | 		int selected; | 
 | 769 | 		item_reset(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 |  | 
 | 771 | 		current_menu = menu; | 
 | 772 | 		for (child = menu->list; child; child = child->next) { | 
 | 773 | 			if (!menu_is_visible(child)) | 
 | 774 | 				continue; | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 775 | 			item_make("%s", menu_get_prompt(child)); | 
 | 776 | 			item_set_data(child); | 
 | 777 | 			if (child->sym == active) | 
 | 778 | 				item_set_selected(1); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | 			if (child->sym == sym_get_choice_value(menu->sym)) | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 780 | 				item_set_tag('X'); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | 		} | 
| Sam Ravnborg | e94c5bd | 2006-09-25 17:35:43 +0200 | [diff] [blame] | 782 | 		dialog_clear(); | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 783 | 		res = dialog_checklist(prompt ? prompt : _("Main Menu"), | 
 | 784 | 					_(radiolist_instructions), | 
 | 785 | 					 15, 70, 6); | 
 | 786 | 		selected = item_activate_selected(); | 
 | 787 | 		switch (res) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | 		case 0: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 789 | 			if (selected) { | 
 | 790 | 				child = item_data(); | 
 | 791 | 				sym_set_tristate_value(child->sym, yes); | 
 | 792 | 			} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | 			return; | 
 | 794 | 		case 1: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 795 | 			if (selected) { | 
 | 796 | 				child = item_data(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 797 | 				show_help(child); | 
 | 798 | 				active = child->sym; | 
 | 799 | 			} else | 
 | 800 | 				show_help(menu); | 
 | 801 | 			break; | 
| Sam Ravnborg | f3cbcdc | 2006-07-28 23:57:48 +0200 | [diff] [blame] | 802 | 		case KEY_ESC: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 803 | 			return; | 
| Sam Ravnborg | c8dc68a | 2006-07-29 22:48:57 +0200 | [diff] [blame] | 804 | 		case -ERRDISPLAYTOOSMALL: | 
 | 805 | 			return; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | 		} | 
 | 807 | 	} | 
 | 808 | } | 
 | 809 |  | 
 | 810 | static void conf_string(struct menu *menu) | 
 | 811 | { | 
 | 812 | 	const char *prompt = menu_get_prompt(menu); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 |  | 
 | 814 | 	while (1) { | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 815 | 		int res; | 
 | 816 | 		char *heading; | 
 | 817 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | 		switch (sym_get_type(menu->sym)) { | 
 | 819 | 		case S_INT: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 820 | 			heading = _(inputbox_instructions_int); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | 			break; | 
 | 822 | 		case S_HEX: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 823 | 			heading = _(inputbox_instructions_hex); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 824 | 			break; | 
 | 825 | 		case S_STRING: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 826 | 			heading = _(inputbox_instructions_string); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | 			break; | 
 | 828 | 		default: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 829 | 			heading = "Internal mconf error!"; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | 		} | 
| Sam Ravnborg | e94c5bd | 2006-09-25 17:35:43 +0200 | [diff] [blame] | 831 | 		dialog_clear(); | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 832 | 		res = dialog_inputbox(prompt ? prompt : _("Main Menu"), | 
 | 833 | 				      heading, 10, 75, | 
 | 834 | 				      sym_get_string_value(menu->sym)); | 
 | 835 | 		switch (res) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | 		case 0: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 837 | 			if (sym_set_string_value(menu->sym, dialog_input_result)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 838 | 				return; | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 839 | 			show_textbox(NULL, _("You have made an invalid entry."), 5, 43); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 840 | 			break; | 
 | 841 | 		case 1: | 
 | 842 | 			show_help(menu); | 
 | 843 | 			break; | 
| Sam Ravnborg | f3cbcdc | 2006-07-28 23:57:48 +0200 | [diff] [blame] | 844 | 		case KEY_ESC: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | 			return; | 
 | 846 | 		} | 
 | 847 | 	} | 
 | 848 | } | 
 | 849 |  | 
 | 850 | static void conf_load(void) | 
 | 851 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 |  | 
 | 853 | 	while (1) { | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 854 | 		int res; | 
| Sam Ravnborg | e94c5bd | 2006-09-25 17:35:43 +0200 | [diff] [blame] | 855 | 		dialog_clear(); | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 856 | 		res = dialog_inputbox(NULL, load_config_text, | 
 | 857 | 				      11, 55, filename); | 
 | 858 | 		switch(res) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 859 | 		case 0: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 860 | 			if (!dialog_input_result[0]) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | 				return; | 
| Sam Ravnborg | 95e30f9 | 2007-03-18 10:48:46 +0100 | [diff] [blame] | 862 | 			if (!conf_read(dialog_input_result)) { | 
 | 863 | 				set_config_filename(dialog_input_result); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 864 | 				return; | 
| Sam Ravnborg | 95e30f9 | 2007-03-18 10:48:46 +0100 | [diff] [blame] | 865 | 			} | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 866 | 			show_textbox(NULL, _("File does not exist!"), 5, 38); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | 			break; | 
 | 868 | 		case 1: | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 869 | 			show_helptext(_("Load Alternate Configuration"), load_config_help); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | 			break; | 
| Sam Ravnborg | f3cbcdc | 2006-07-28 23:57:48 +0200 | [diff] [blame] | 871 | 		case KEY_ESC: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | 			return; | 
 | 873 | 		} | 
 | 874 | 	} | 
 | 875 | } | 
 | 876 |  | 
 | 877 | static void conf_save(void) | 
 | 878 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | 	while (1) { | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 880 | 		int res; | 
| Sam Ravnborg | e94c5bd | 2006-09-25 17:35:43 +0200 | [diff] [blame] | 881 | 		dialog_clear(); | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 882 | 		res = dialog_inputbox(NULL, save_config_text, | 
 | 883 | 				      11, 55, filename); | 
 | 884 | 		switch(res) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 885 | 		case 0: | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 886 | 			if (!dialog_input_result[0]) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | 				return; | 
| Sam Ravnborg | 95e30f9 | 2007-03-18 10:48:46 +0100 | [diff] [blame] | 888 | 			if (!conf_write(dialog_input_result)) { | 
 | 889 | 				set_config_filename(dialog_input_result); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 890 | 				return; | 
| Sam Ravnborg | 95e30f9 | 2007-03-18 10:48:46 +0100 | [diff] [blame] | 891 | 			} | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 892 | 			show_textbox(NULL, _("Can't create file!  Probably a nonexistent directory."), 5, 60); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 893 | 			break; | 
 | 894 | 		case 1: | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 895 | 			show_helptext(_("Save Alternate Configuration"), save_config_help); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 896 | 			break; | 
| Sam Ravnborg | f3cbcdc | 2006-07-28 23:57:48 +0200 | [diff] [blame] | 897 | 		case KEY_ESC: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | 			return; | 
 | 899 | 		} | 
 | 900 | 	} | 
 | 901 | } | 
 | 902 |  | 
 | 903 | static void conf_cleanup(void) | 
 | 904 | { | 
 | 905 | 	tcsetattr(1, TCSAFLUSH, &ios_org); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | } | 
 | 907 |  | 
 | 908 | int main(int ac, char **av) | 
 | 909 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 910 | 	char *mode; | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 911 | 	int res; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 |  | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 913 | 	setlocale(LC_ALL, ""); | 
 | 914 | 	bindtextdomain(PACKAGE, LOCALEDIR); | 
 | 915 | 	textdomain(PACKAGE); | 
 | 916 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 917 | 	conf_parse(av[1]); | 
 | 918 | 	conf_read(NULL); | 
 | 919 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 920 | 	mode = getenv("MENUCONFIG_MODE"); | 
 | 921 | 	if (mode) { | 
 | 922 | 		if (!strcasecmp(mode, "single_menu")) | 
 | 923 | 			single_menu_mode = 1; | 
 | 924 | 	} | 
 | 925 |  | 
 | 926 | 	tcgetattr(1, &ios_org); | 
 | 927 | 	atexit(conf_cleanup); | 
 | 928 | 	init_wsize(); | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 929 | 	reset_dialog(); | 
| Sam Ravnborg | 95e30f9 | 2007-03-18 10:48:46 +0100 | [diff] [blame] | 930 | 	init_dialog(NULL); | 
| Sam Ravnborg | d802b50 | 2007-04-01 22:29:38 +0200 | [diff] [blame] | 931 | 	set_config_filename(conf_get_configname()); | 
| Sam Ravnborg | f3cbcdc | 2006-07-28 23:57:48 +0200 | [diff] [blame] | 932 | 	do { | 
 | 933 | 		conf(&rootmenu); | 
| Sam Ravnborg | e94c5bd | 2006-09-25 17:35:43 +0200 | [diff] [blame] | 934 | 		dialog_clear(); | 
| Karsten Wiese | b321429 | 2006-12-13 00:34:06 -0800 | [diff] [blame] | 935 | 		if (conf_get_changed()) | 
 | 936 | 			res = dialog_yesno(NULL, | 
 | 937 | 					   _("Do you wish to save your " | 
 | 938 | 					     "new kernel configuration?\n" | 
 | 939 | 					     "<ESC><ESC> to continue."), | 
 | 940 | 					   6, 60); | 
 | 941 | 		else | 
 | 942 | 			res = -1; | 
| Sam Ravnborg | f3cbcdc | 2006-07-28 23:57:48 +0200 | [diff] [blame] | 943 | 	} while (res == KEY_ESC); | 
| Sam Ravnborg | 2982de6 | 2006-07-27 22:10:27 +0200 | [diff] [blame] | 944 | 	end_dialog(); | 
| Karsten Wiese | b321429 | 2006-12-13 00:34:06 -0800 | [diff] [blame] | 945 |  | 
 | 946 | 	switch (res) { | 
 | 947 | 	case 0: | 
| Sam Ravnborg | 95e30f9 | 2007-03-18 10:48:46 +0100 | [diff] [blame] | 948 | 		if (conf_write(filename)) { | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 949 | 			fprintf(stderr, _("\n\n" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | 				"Error during writing of the kernel configuration.\n" | 
 | 951 | 				"Your kernel configuration changes were NOT saved." | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 952 | 				"\n\n")); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | 			return 1; | 
 | 954 | 		} | 
| Karsten Wiese | b321429 | 2006-12-13 00:34:06 -0800 | [diff] [blame] | 955 | 	case -1: | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 956 | 		printf(_("\n\n" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | 			"*** End of Linux kernel configuration.\n" | 
 | 958 | 			"*** Execute 'make' to build the kernel or try 'make help'." | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 959 | 			"\n\n")); | 
| Karsten Wiese | b321429 | 2006-12-13 00:34:06 -0800 | [diff] [blame] | 960 | 		break; | 
 | 961 | 	default: | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 962 | 		fprintf(stderr, _("\n\n" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 963 | 			"Your kernel configuration changes were NOT saved." | 
| Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 964 | 			"\n\n")); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | 	} | 
 | 966 |  | 
 | 967 | 	return 0; | 
 | 968 | } |