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