summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--scripts/kconfig/mconf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index b9cf25f..0967471 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -1,802 +1,802 @@
1/* 1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
4 * 4 *
5 * Introduced single menu mode (show all sub-menus in one large tree). 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 */ 7 */
8 8
9#include <sys/ioctl.h> 9#include <sys/ioctl.h>
10#include <sys/wait.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 <signal.h>
16#include <stdarg.h> 16#include <stdarg.h>
17#include <stdlib.h> 17#include <stdlib.h>
18#include <string.h> 18#include <string.h>
19#include <termios.h> 19#include <termios.h>
20#include <unistd.h> 20#include <unistd.h>
21 21
22#define LKC_DIRECT_LINK 22#define LKC_DIRECT_LINK
23#include "lkc.h" 23#include "lkc.h"
24 24
25static char menu_backtitle[128]; 25static char menu_backtitle[128];
26static const char menu_instructions[] = 26static const char menu_instructions[] =
27 "Arrow keys navigate the menu. " 27 "Arrow keys navigate the menu. "
28 "<Enter> selects submenus --->. " 28 "<Enter> selects submenus --->. "
29 "Highlighted letters are hotkeys. " 29 "Highlighted letters are hotkeys. "
30 "Pressing <Y> includes, <N> excludes, <M> modularizes features. " 30 "Pressing <Y> includes, <N> excludes, <M> modularizes features. "
31 "Press <Esc><Esc> to exit, <?> for Help. " 31 "Press <Esc><Esc> to exit, <?> for Help. "
32 "Legend: [*] built-in [ ] excluded <M> module < > module capable", 32 "Legend: [*] built-in [ ] excluded <M> module < > module capable",
33radiolist_instructions[] = 33radiolist_instructions[] =
34 "Use the arrow keys to navigate this window or " 34 "Use the arrow keys to navigate this window or "
35 "press the hotkey of the item you wish to select " 35 "press the hotkey of the item you wish to select "
36 "followed by the <SPACE BAR>. " 36 "followed by the <SPACE BAR>. "
37 "Press <?> for additional information about this option.", 37 "Press <?> for additional information about this option.",
38inputbox_instructions_int[] = 38inputbox_instructions_int[] =
39 "Please enter a decimal value. " 39 "Please enter a decimal value. "
40 "Fractions will not be accepted. " 40 "Fractions will not be accepted. "
41 "Use the <TAB> key to move from the input field to the buttons below it.", 41 "Use the <TAB> key to move from the input field to the buttons below it.",
42inputbox_instructions_hex[] = 42inputbox_instructions_hex[] =
43 "Please enter a hexadecimal value. " 43 "Please enter a hexadecimal value. "
44 "Use the <TAB> key to move from the input field to the buttons below it.", 44 "Use the <TAB> key to move from the input field to the buttons below it.",
45inputbox_instructions_string[] = 45inputbox_instructions_string[] =
46 "Please enter a string value. " 46 "Please enter a string value. "
47 "Use the <TAB> key to move from the input field to the buttons below it.", 47 "Use the <TAB> key to move from the input field to the buttons below it.",
48setmod_text[] = 48setmod_text[] =
49 "This feature depends on another which has been configured as a module.\n" 49 "This feature depends on another which has been configured as a module.\n"
50 "As a result, this feature will be built as a module.", 50 "As a result, this feature will be built as a module.",
51nohelp_text[] = 51nohelp_text[] =
52 "There is no help available for this option.\n", 52 "There is no help available for this option.\n",
53load_config_text[] = 53load_config_text[] =
54 "Enter the name of the configuration file you wish to load. " 54 "Enter the name of the configuration file you wish to load. "
55 "Accept the name shown to restore the configuration you " 55 "Accept the name shown to restore the configuration you "
56 "last retrieved. Leave blank to abort.", 56 "last retrieved. Leave blank to abort.",
57load_config_help[] = 57load_config_help[] =
58 "\n" 58 "\n"
59 "For various reasons, one may wish to keep several different \n" 59 "For various reasons, one may wish to keep several different \n"
60 "configurations available on a single machine.\n" 60 "configurations available on a single machine.\n"
61 "\n" 61 "\n"
62 "If you have saved a previous configuration in a file other than the\n" 62 "If you have saved a previous configuration in a file other than the\n"
63 "default, entering the name of the file here will allow you\n" 63 "default, entering the name of the file here will allow you\n"
64 "to modify that configuration.\n" 64 "to modify that configuration.\n"
65 "\n" 65 "\n"
66 "If you are uncertain, then you have probably never used alternate\n" 66 "If you are uncertain, then you have probably never used alternate\n"
67 "configuration files. You should therefor leave this blank to abort.\n", 67 "configuration files. You should therefor leave this blank to abort.\n",
68save_config_text[] = 68save_config_text[] =
69 "Enter a filename to which this configuration should be saved " 69 "Enter a filename to which this configuration should be saved "
70 "as an alternate. Leave blank to abort.", 70 "as an alternate. Leave blank to abort.",
71save_config_help[] = 71save_config_help[] =
72 "\n" 72 "\n"
73 "For various reasons, one may wish to keep different\n" 73 "For various reasons, one may wish to keep different\n"
74 "configurations available on a single machine.\n" 74 "configurations available on a single machine.\n"
75 "\n" 75 "\n"
76 "Entering a file name here will allow you to later retrieve, modify\n" 76 "Entering a file name here will allow you to later retrieve, modify\n"
77 "and use the current configuration as an alternate to whatever\n" 77 "and use the current configuration as an alternate to whatever\n"
78 "configuration options you have selected at that time.\n" 78 "configuration options you have selected at that time.\n"
79 "\n" 79 "\n"
80 "If you are uncertain what all this means then you should probably\n" 80 "If you are uncertain what all this means then you should probably\n"
81 "leave this blank.\n" 81 "leave this blank.\n"
82; 82;
83 83
84static char buf[4096], *bufptr = buf; 84static char buf[4096], *bufptr = buf;
85static char input_buf[4096]; 85static char input_buf[4096];
86static char filename[PATH_MAX+1] = ".config"; 86static char filename[PATH_MAX+1] = ".config";
87static char *args[1024], **argptr = args; 87static char *args[1024], **argptr = args;
88static int indent = 0; 88static int indent = 0;
89static struct termios ios_org; 89static struct termios ios_org;
90static int rows, cols; 90static int rows, cols;
91static struct menu *current_menu; 91struct menu *current_menu;
92static int child_count; 92static int child_count;
93static int do_resize; 93static int do_resize;
94static int single_menu_mode; 94static int single_menu_mode;
95 95
96static void conf(struct menu *menu); 96static void conf(struct menu *menu);
97static void conf_choice(struct menu *menu); 97static void conf_choice(struct menu *menu);
98static void conf_string(struct menu *menu); 98static void conf_string(struct menu *menu);
99static void conf_load(void); 99static void conf_load(void);
100static void conf_save(void); 100static void conf_save(void);
101static void show_textbox(const char *title, const char *text, int r, int c); 101static void show_textbox(const char *title, const char *text, int r, int c);
102static void show_helptext(const char *title, const char *text); 102static void show_helptext(const char *title, const char *text);
103static void show_help(struct menu *menu); 103static void show_help(struct menu *menu);
104static void show_readme(void); 104static void show_readme(void);
105 105
106static void cprint_init(void); 106static void cprint_init(void);
107static int cprint1(const char *fmt, ...); 107static int cprint1(const char *fmt, ...);
108static void cprint_done(void); 108static void cprint_done(void);
109static int cprint(const char *fmt, ...); 109static int cprint(const char *fmt, ...);
110 110
111static void init_wsize(void) 111static void init_wsize(void)
112{ 112{
113 struct winsize ws; 113 struct winsize ws;
114 char *env; 114 char *env;
115 115
116 if (ioctl(1, TIOCGWINSZ, &ws) == -1) { 116 if (ioctl(1, TIOCGWINSZ, &ws) == -1) {
117 rows = 24; 117 rows = 24;
118 cols = 80; 118 cols = 80;
119 } else { 119 } else {
120 rows = ws.ws_row; 120 rows = ws.ws_row;
121 cols = ws.ws_col; 121 cols = ws.ws_col;
122 if (!rows) { 122 if (!rows) {
123 env = getenv("LINES"); 123 env = getenv("LINES");
124 if (env) 124 if (env)
125 rows = atoi(env); 125 rows = atoi(env);
126 if (!rows) 126 if (!rows)
127 rows = 24; 127 rows = 24;
128 } 128 }
129 if (!cols) { 129 if (!cols) {
130 env = getenv("COLUMNS"); 130 env = getenv("COLUMNS");
131 if (env) 131 if (env)
132 cols = atoi(env); 132 cols = atoi(env);
133 if (!cols) 133 if (!cols)
134 cols = 80; 134 cols = 80;
135 } 135 }
136 } 136 }
137 137
138 if (rows < 19 || cols < 80) { 138 if (rows < 19 || cols < 80) {
139 fprintf(stderr, "Your display is too small to run Menuconfig!\n"); 139 fprintf(stderr, "Your display is too small to run Menuconfig!\n");
140 fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); 140 fprintf(stderr, "It must be at least 19 lines by 80 columns.\n");
141 exit(1); 141 exit(1);
142 } 142 }
143 143
144 rows -= 4; 144 rows -= 4;
145 cols -= 5; 145 cols -= 5;
146} 146}
147 147
148static void cprint_init(void) 148static void cprint_init(void)
149{ 149{
150 char *env = getenv("LXDIALOG"); 150 char *env = getenv("LXDIALOG");
151 bufptr = buf; 151 bufptr = buf;
152 argptr = args; 152 argptr = args;
153 memset(args, 0, sizeof(args)); 153 memset(args, 0, sizeof(args));
154 indent = 0; 154 indent = 0;
155 child_count = 0; 155 child_count = 0;
156 if(env != NULL) { 156 if(env != NULL) {
157 cprint(env); 157 cprint(env);
158 } else { 158 } else {
159 cprint("./scripts/lxdialog/lxdialog"); 159 cprint("./scripts/lxdialog/lxdialog");
160 } 160 }
161 cprint("--backtitle"); 161 cprint("--backtitle");
162 cprint(menu_backtitle); 162 cprint(menu_backtitle);
163} 163}
164 164
165static int cprint1(const char *fmt, ...) 165static int cprint1(const char *fmt, ...)
166{ 166{
167 va_list ap; 167 va_list ap;
168 int res; 168 int res;
169 169
170 if (!*argptr) 170 if (!*argptr)
171 *argptr = bufptr; 171 *argptr = bufptr;
172 va_start(ap, fmt); 172 va_start(ap, fmt);
173 res = vsprintf(bufptr, fmt, ap); 173 res = vsprintf(bufptr, fmt, ap);
174 va_end(ap); 174 va_end(ap);
175 bufptr += res; 175 bufptr += res;
176 176
177 return res; 177 return res;
178} 178}
179 179
180static void cprint_done(void) 180static void cprint_done(void)
181{ 181{
182 *bufptr++ = 0; 182 *bufptr++ = 0;
183 argptr++; 183 argptr++;
184} 184}
185 185
186static int cprint(const char *fmt, ...) 186static int cprint(const char *fmt, ...)
187{ 187{
188 va_list ap; 188 va_list ap;
189 int res; 189 int res;
190 190
191 *argptr++ = bufptr; 191 *argptr++ = bufptr;
192 va_start(ap, fmt); 192 va_start(ap, fmt);
193 res = vsprintf(bufptr, fmt, ap); 193 res = vsprintf(bufptr, fmt, ap);
194 va_end(ap); 194 va_end(ap);
195 bufptr += res; 195 bufptr += res;
196 *bufptr++ = 0; 196 *bufptr++ = 0;
197 197
198 return res; 198 return res;
199} 199}
200 200
201pid_t pid; 201pid_t pid;
202 202
203static void winch_handler(int sig) 203static void winch_handler(int sig)
204{ 204{
205 if (!do_resize) { 205 if (!do_resize) {
206 kill(pid, SIGINT); 206 kill(pid, SIGINT);
207 do_resize = 1; 207 do_resize = 1;
208 } 208 }
209} 209}
210 210
211static int exec_conf(void) 211static int exec_conf(void)
212{ 212{
213 int pipefd[2], stat, size; 213 int pipefd[2], stat, size;
214 struct sigaction sa; 214 struct sigaction sa;
215 sigset_t sset, osset; 215 sigset_t sset, osset;
216 216
217 sigemptyset(&sset); 217 sigemptyset(&sset);
218 sigaddset(&sset, SIGINT); 218 sigaddset(&sset, SIGINT);
219 sigprocmask(SIG_BLOCK, &sset, &osset); 219 sigprocmask(SIG_BLOCK, &sset, &osset);
220 220
221 signal(SIGINT, SIG_DFL); 221 signal(SIGINT, SIG_DFL);
222 222
223 sa.sa_handler = winch_handler; 223 sa.sa_handler = winch_handler;
224 sigemptyset(&sa.sa_mask); 224 sigemptyset(&sa.sa_mask);
225 sa.sa_flags = SA_RESTART; 225 sa.sa_flags = SA_RESTART;
226 sigaction(SIGWINCH, &sa, NULL); 226 sigaction(SIGWINCH, &sa, NULL);
227 227
228 *argptr++ = NULL; 228 *argptr++ = NULL;
229 229
230 pipe(pipefd); 230 pipe(pipefd);
231 pid = fork(); 231 pid = fork();
232 if (pid == 0) { 232 if (pid == 0) {
233 sigprocmask(SIG_SETMASK, &osset, NULL); 233 sigprocmask(SIG_SETMASK, &osset, NULL);
234 dup2(pipefd[1], 2); 234 dup2(pipefd[1], 2);
235 close(pipefd[0]); 235 close(pipefd[0]);
236 close(pipefd[1]); 236 close(pipefd[1]);
237 execv(args[0], args); 237 execv(args[0], args);
238 _exit(EXIT_FAILURE); 238 _exit(EXIT_FAILURE);
239 } 239 }
240 240
241 close(pipefd[1]); 241 close(pipefd[1]);
242 bufptr = input_buf; 242 bufptr = input_buf;
243 while (1) { 243 while (1) {
244 size = input_buf + sizeof(input_buf) - bufptr; 244 size = input_buf + sizeof(input_buf) - bufptr;
245 size = read(pipefd[0], bufptr, size); 245 size = read(pipefd[0], bufptr, size);
246 if (size <= 0) { 246 if (size <= 0) {
247 if (size < 0) { 247 if (size < 0) {
248 if (errno == EINTR || errno == EAGAIN) 248 if (errno == EINTR || errno == EAGAIN)
249 continue; 249 continue;
250 perror("read"); 250 perror("read");
251 } 251 }
252 break; 252 break;
253 } 253 }
254 bufptr += size; 254 bufptr += size;
255 } 255 }
256 *bufptr++ = 0; 256 *bufptr++ = 0;
257 close(pipefd[0]); 257 close(pipefd[0]);
258 waitpid(pid, &stat, 0); 258 waitpid(pid, &stat, 0);
259 259
260 if (do_resize) { 260 if (do_resize) {
261 init_wsize(); 261 init_wsize();
262 do_resize = 0; 262 do_resize = 0;
263 sigprocmask(SIG_SETMASK, &osset, NULL); 263 sigprocmask(SIG_SETMASK, &osset, NULL);
264 return -1; 264 return -1;
265 } 265 }
266 if (WIFSIGNALED(stat)) { 266 if (WIFSIGNALED(stat)) {
267 printf("\finterrupted(%d)\n", WTERMSIG(stat)); 267 printf("\finterrupted(%d)\n", WTERMSIG(stat));
268 exit(1); 268 exit(1);
269 } 269 }
270#if 0 270#if 0
271 printf("\fexit state: %d\nexit data: '%s'\n", WEXITSTATUS(stat), input_buf); 271 printf("\fexit state: %d\nexit data: '%s'\n", WEXITSTATUS(stat), input_buf);
272 sleep(1); 272 sleep(1);
273#endif 273#endif
274 sigpending(&sset); 274 sigpending(&sset);
275 if (sigismember(&sset, SIGINT)) { 275 if (sigismember(&sset, SIGINT)) {
276 printf("\finterrupted\n"); 276 printf("\finterrupted\n");
277 exit(1); 277 exit(1);
278 } 278 }
279 sigprocmask(SIG_SETMASK, &osset, NULL); 279 sigprocmask(SIG_SETMASK, &osset, NULL);
280 280
281 return WEXITSTATUS(stat); 281 return WEXITSTATUS(stat);
282} 282}
283 283
284static void build_conf(struct menu *menu) 284static void build_conf(struct menu *menu)
285{ 285{
286 struct symbol *sym; 286 struct symbol *sym;
287 struct property *prop; 287 struct property *prop;
288 struct menu *child; 288 struct menu *child;
289 int type, tmp, doint = 2; 289 int type, tmp, doint = 2;
290 tristate val; 290 tristate val;
291 char ch; 291 char ch;
292 292
293 if (!menu_is_visible(menu)) 293 if (!menu_is_visible(menu))
294 return; 294 return;
295 295
296 sym = menu->sym; 296 sym = menu->sym;
297 prop = menu->prompt; 297 prop = menu->prompt;
298 if (!sym) { 298 if (!sym) {
299 if (prop && menu != current_menu) { 299 if (prop && menu != current_menu) {
300 const char *prompt = menu_get_prompt(menu); 300 const char *prompt = menu_get_prompt(menu);
301 switch (prop->type) { 301 switch (prop->type) {
302 case P_MENU: 302 case P_MENU:
303 child_count++; 303 child_count++;
304 cprint("m%p", menu); 304 cprint("m%p", menu);
305 305
306 if (single_menu_mode) { 306 if (single_menu_mode) {
307 cprint1("%s%*c%s", 307 cprint1("%s%*c%s",
308 menu->data ? "-->" : "++>", 308 menu->data ? "-->" : "++>",
309 indent + 1, ' ', prompt); 309 indent + 1, ' ', prompt);
310 } else 310 } else
311 cprint1(" %*c%s --->", indent + 1, ' ', prompt); 311 cprint1(" %*c%s --->", indent + 1, ' ', prompt);
312 312
313 cprint_done(); 313 cprint_done();
314 if (single_menu_mode && menu->data) 314 if (single_menu_mode && menu->data)
315 goto conf_childs; 315 goto conf_childs;
316 return; 316 return;
317 default: 317 default:
318 if (prompt) { 318 if (prompt) {
319 child_count++; 319 child_count++;
320 cprint(":%p", menu); 320 cprint(":%p", menu);
321 cprint("---%*c%s", indent + 1, ' ', prompt); 321 cprint("---%*c%s", indent + 1, ' ', prompt);
322 } 322 }
323 } 323 }
324 } else 324 } else
325 doint = 0; 325 doint = 0;
326 goto conf_childs; 326 goto conf_childs;
327 } 327 }
328 328
329 type = sym_get_type(sym); 329 type = sym_get_type(sym);
330 if (sym_is_choice(sym)) { 330 if (sym_is_choice(sym)) {
331 struct symbol *def_sym = sym_get_choice_value(sym); 331 struct symbol *def_sym = sym_get_choice_value(sym);
332 struct menu *def_menu = NULL; 332 struct menu *def_menu = NULL;
333 333
334 child_count++; 334 child_count++;
335 for (child = menu->list; child; child = child->next) { 335 for (child = menu->list; child; child = child->next) {
336 if (menu_is_visible(child) && child->sym == def_sym) 336 if (menu_is_visible(child) && child->sym == def_sym)
337 def_menu = child; 337 def_menu = child;
338 } 338 }
339 339
340 val = sym_get_tristate_value(sym); 340 val = sym_get_tristate_value(sym);
341 if (sym_is_changable(sym)) { 341 if (sym_is_changable(sym)) {
342 cprint("t%p", menu); 342 cprint("t%p", menu);
343 switch (type) { 343 switch (type) {
344 case S_BOOLEAN: 344 case S_BOOLEAN:
345 cprint1("[%c]", val == no ? ' ' : '*'); 345 cprint1("[%c]", val == no ? ' ' : '*');
346 break; 346 break;
347 case S_TRISTATE: 347 case S_TRISTATE:
348 switch (val) { 348 switch (val) {
349 case yes: ch = '*'; break; 349 case yes: ch = '*'; break;
350 case mod: ch = 'M'; break; 350 case mod: ch = 'M'; break;
351 default: ch = ' '; break; 351 default: ch = ' '; break;
352 } 352 }
353 cprint1("<%c>", ch); 353 cprint1("<%c>", ch);
354 break; 354 break;
355 } 355 }
356 } else { 356 } else {
357 cprint("%c%p", def_menu ? 't' : ':', menu); 357 cprint("%c%p", def_menu ? 't' : ':', menu);
358 cprint1(" "); 358 cprint1(" ");
359 } 359 }
360 360
361 cprint1("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); 361 cprint1("%*c%s", indent + 1, ' ', menu_get_prompt(menu));
362 if (val == yes) { 362 if (val == yes) {
363 if (def_menu) { 363 if (def_menu) {
364 cprint1(" (%s)", menu_get_prompt(def_menu)); 364 cprint1(" (%s)", menu_get_prompt(def_menu));
365 cprint1(" --->"); 365 cprint1(" --->");
366 cprint_done(); 366 cprint_done();
367 if (def_menu->list) { 367 if (def_menu->list) {
368 indent += 2; 368 indent += 2;
369 build_conf(def_menu); 369 build_conf(def_menu);
370 indent -= 2; 370 indent -= 2;
371 } 371 }
372 } else 372 } else
373 cprint_done(); 373 cprint_done();
374 return; 374 return;
375 } 375 }
376 cprint_done(); 376 cprint_done();
377 } else { 377 } else {
378 if (menu == current_menu) { 378 if (menu == current_menu) {
379 cprint(":%p", menu); 379 cprint(":%p", menu);
380 cprint("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); 380 cprint("---%*c%s", indent + 1, ' ', menu_get_prompt(menu));
381 goto conf_childs; 381 goto conf_childs;
382 } 382 }
383 child_count++; 383 child_count++;
384 val = sym_get_tristate_value(sym); 384 val = sym_get_tristate_value(sym);
385 if (sym_is_choice_value(sym) && val == yes) { 385 if (sym_is_choice_value(sym) && val == yes) {
386 cprint(":%p", menu); 386 cprint(":%p", menu);
387 cprint1(" "); 387 cprint1(" ");
388 } else { 388 } else {
389 switch (type) { 389 switch (type) {
390 case S_BOOLEAN: 390 case S_BOOLEAN:
391 cprint("t%p", menu); 391 cprint("t%p", menu);
392 if (sym_is_changable(sym)) 392 if (sym_is_changable(sym))
393 cprint1("[%c]", val == no ? ' ' : '*'); 393 cprint1("[%c]", val == no ? ' ' : '*');
394 else 394 else
395 cprint1("---"); 395 cprint1("---");
396 break; 396 break;
397 case S_TRISTATE: 397 case S_TRISTATE:
398 cprint("t%p", menu); 398 cprint("t%p", menu);
399 switch (val) { 399 switch (val) {
400 case yes: ch = '*'; break; 400 case yes: ch = '*'; break;
401 case mod: ch = 'M'; break; 401 case mod: ch = 'M'; break;
402 default: ch = ' '; break; 402 default: ch = ' '; break;
403 } 403 }
404 if (sym_is_changable(sym)) 404 if (sym_is_changable(sym))
405 cprint1("<%c>", ch); 405 cprint1("<%c>", ch);
406 else 406 else
407 cprint1("---"); 407 cprint1("---");
408 break; 408 break;
409 default: 409 default:
410 cprint("s%p", menu); 410 cprint("s%p", menu);
411 tmp = cprint1("(%s)", sym_get_string_value(sym)); 411 tmp = cprint1("(%s)", sym_get_string_value(sym));
412 tmp = indent - tmp + 4; 412 tmp = indent - tmp + 4;
413 if (tmp < 0) 413 if (tmp < 0)
414 tmp = 0; 414 tmp = 0;
415 cprint1("%*c%s%s", tmp, ' ', menu_get_prompt(menu), 415 cprint1("%*c%s%s", tmp, ' ', menu_get_prompt(menu),
416 (sym_has_value(sym) || !sym_is_changable(sym)) ? 416 (sym_has_value(sym) || !sym_is_changable(sym)) ?
417 "" : " (NEW)"); 417 "" : " (NEW)");
418 cprint_done(); 418 cprint_done();
419 goto conf_childs; 419 goto conf_childs;
420 } 420 }
421 } 421 }
422 cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), 422 cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu),
423 (sym_has_value(sym) || !sym_is_changable(sym)) ? 423 (sym_has_value(sym) || !sym_is_changable(sym)) ?
424 "" : " (NEW)"); 424 "" : " (NEW)");
425 if (menu->prompt->type == P_MENU) { 425 if (menu->prompt->type == P_MENU) {
426 cprint1(" --->"); 426 cprint1(" --->");
427 cprint_done(); 427 cprint_done();
428 return; 428 return;
429 } 429 }
430 cprint_done(); 430 cprint_done();
431 } 431 }
432 432
433conf_childs: 433conf_childs:
434 indent += doint; 434 indent += doint;
435 for (child = menu->list; child; child = child->next) 435 for (child = menu->list; child; child = child->next)
436 build_conf(child); 436 build_conf(child);
437 indent -= doint; 437 indent -= doint;
438} 438}
439 439
440static void conf(struct menu *menu) 440static void conf(struct menu *menu)
441{ 441{
442 struct menu *submenu; 442 struct menu *submenu;
443 const char *prompt = menu_get_prompt(menu); 443 const char *prompt = menu_get_prompt(menu);
444 struct symbol *sym; 444 struct symbol *sym;
445 char active_entry[40]; 445 char active_entry[40];
446 int stat, type, i; 446 int stat, type, i;
447 447
448 unlink("lxdialog.scrltmp"); 448 unlink("lxdialog.scrltmp");
449 active_entry[0] = 0; 449 active_entry[0] = 0;
450 while (1) { 450 while (1) {
451 cprint_init(); 451 cprint_init();
452 cprint("--title"); 452 cprint("--title");
453 cprint("%s", prompt ? prompt : "Main Menu"); 453 cprint("%s", prompt ? prompt : "Main Menu");
454 cprint("--menu"); 454 cprint("--menu");
455 cprint(menu_instructions); 455 cprint(menu_instructions);
456 cprint("%d", rows); 456 cprint("%d", rows);
457 cprint("%d", cols); 457 cprint("%d", cols);
458 cprint("%d", rows - 10); 458 cprint("%d", rows - 10);
459 cprint("%s", active_entry); 459 cprint("%s", active_entry);
460 current_menu = menu; 460 current_menu = menu;
461 build_conf(menu); 461 build_conf(menu);
462 if (!child_count) 462 if (!child_count)
463 break; 463 break;
464 if (menu == &rootmenu) { 464 if (menu == &rootmenu) {
465 cprint(":"); 465 cprint(":");
466 cprint("--- "); 466 cprint("--- ");
467 cprint("L"); 467 cprint("L");
468 cprint(" Load an Alternate Configuration File"); 468 cprint(" Load an Alternate Configuration File");
469 cprint("S"); 469 cprint("S");
470 cprint(" Save Configuration to an Alternate File"); 470 cprint(" Save Configuration to an Alternate File");
471 } 471 }
472 stat = exec_conf(); 472 stat = exec_conf();
473 if (stat < 0) 473 if (stat < 0)
474 continue; 474 continue;
475 475
476 if (stat == 1 || stat == 255) 476 if (stat == 1 || stat == 255)
477 break; 477 break;
478 478
479 type = input_buf[0]; 479 type = input_buf[0];
480 if (!type) 480 if (!type)
481 continue; 481 continue;
482 482
483 for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++) 483 for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++)
484 ; 484 ;
485 if (i >= sizeof(active_entry)) 485 if (i >= sizeof(active_entry))
486 i = sizeof(active_entry) - 1; 486 i = sizeof(active_entry) - 1;
487 input_buf[i] = 0; 487 input_buf[i] = 0;
488 strcpy(active_entry, input_buf); 488 strcpy(active_entry, input_buf);
489 489
490 sym = NULL; 490 sym = NULL;
491 submenu = NULL; 491 submenu = NULL;
492 if (sscanf(input_buf + 1, "%p", &submenu) == 1) 492 if (sscanf(input_buf + 1, "%p", &submenu) == 1)
493 sym = submenu->sym; 493 sym = submenu->sym;
494 494
495 switch (stat) { 495 switch (stat) {
496 case 0: 496 case 0:
497 switch (type) { 497 switch (type) {
498 case 'm': 498 case 'm':
499 if (single_menu_mode) 499 if (single_menu_mode)
500 submenu->data = (void *) !submenu->data; 500 submenu->data = (void *) !submenu->data;
501 else 501 else
502 conf(submenu); 502 conf(submenu);
503 break; 503 break;
504 case 't': 504 case 't':
505 if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) 505 if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
506 conf_choice(submenu); 506 conf_choice(submenu);
507 else if (submenu->prompt->type == P_MENU) 507 else if (submenu->prompt->type == P_MENU)
508 conf(submenu); 508 conf(submenu);
509 break; 509 break;
510 case 's': 510 case 's':
511 conf_string(submenu); 511 conf_string(submenu);
512 break; 512 break;
513 case 'L': 513 case 'L':
514 conf_load(); 514 conf_load();
515 break; 515 break;
516 case 'S': 516 case 'S':
517 conf_save(); 517 conf_save();
518 break; 518 break;
519 } 519 }
520 break; 520 break;
521 case 2: 521 case 2:
522 if (sym) 522 if (sym)
523 show_help(submenu); 523 show_help(submenu);
524 else 524 else
525 show_readme(); 525 show_readme();
526 break; 526 break;
527 case 3: 527 case 3:
528 if (type == 't') { 528 if (type == 't') {
529 if (sym_set_tristate_value(sym, yes)) 529 if (sym_set_tristate_value(sym, yes))
530 break; 530 break;
531 if (sym_set_tristate_value(sym, mod)) 531 if (sym_set_tristate_value(sym, mod))
532 show_textbox(NULL, setmod_text, 6, 74); 532 show_textbox(NULL, setmod_text, 6, 74);
533 } 533 }
534 break; 534 break;
535 case 4: 535 case 4:
536 if (type == 't') 536 if (type == 't')
537 sym_set_tristate_value(sym, no); 537 sym_set_tristate_value(sym, no);
538 break; 538 break;
539 case 5: 539 case 5:
540 if (type == 't') 540 if (type == 't')
541 sym_set_tristate_value(sym, mod); 541 sym_set_tristate_value(sym, mod);
542 break; 542 break;
543 case 6: 543 case 6:
544 if (type == 't') 544 if (type == 't')
545 sym_toggle_tristate_value(sym); 545 sym_toggle_tristate_value(sym);
546 else if (type == 'm') 546 else if (type == 'm')
547 conf(submenu); 547 conf(submenu);
548 break; 548 break;
549 } 549 }
550 } 550 }
551} 551}
552 552
553static void show_textbox(const char *title, const char *text, int r, int c) 553static void show_textbox(const char *title, const char *text, int r, int c)
554{ 554{
555 int fd; 555 int fd;
556 556
557 fd = creat(".help.tmp", 0777); 557 fd = creat(".help.tmp", 0777);
558 write(fd, text, strlen(text)); 558 write(fd, text, strlen(text));
559 close(fd); 559 close(fd);
560 do { 560 do {
561 cprint_init(); 561 cprint_init();
562 if (title) { 562 if (title) {
563 cprint("--title"); 563 cprint("--title");
564 cprint("%s", title); 564 cprint("%s", title);
565 } 565 }
566 cprint("--textbox"); 566 cprint("--textbox");
567 cprint(".help.tmp"); 567 cprint(".help.tmp");
568 cprint("%d", r); 568 cprint("%d", r);
569 cprint("%d", c); 569 cprint("%d", c);
570 } while (exec_conf() < 0); 570 } while (exec_conf() < 0);
571 unlink(".help.tmp"); 571 unlink(".help.tmp");
572} 572}
573 573
574static void show_helptext(const char *title, const char *text) 574static void show_helptext(const char *title, const char *text)
575{ 575{
576 show_textbox(title, text, rows, cols); 576 show_textbox(title, text, rows, cols);
577} 577}
578 578
579static void show_help(struct menu *menu) 579static void show_help(struct menu *menu)
580{ 580{
581 const char *help; 581 const char *help;
582 char *helptext; 582 char *helptext;
583 struct symbol *sym = menu->sym; 583 struct symbol *sym = menu->sym;
584 584
585 help = sym->help; 585 help = sym->help;
586 if (!help) 586 if (!help)
587 help = nohelp_text; 587 help = nohelp_text;
588 if (sym->name) { 588 if (sym->name) {
589 helptext = malloc(strlen(sym->name) + strlen(help) + 16); 589 helptext = malloc(strlen(sym->name) + strlen(help) + 16);
590 sprintf(helptext, "CONFIG_%s:\n\n%s", sym->name, help); 590 sprintf(helptext, "CONFIG_%s:\n\n%s", sym->name, help);
591 show_helptext(menu_get_prompt(menu), helptext); 591 show_helptext(menu_get_prompt(menu), helptext);
592 free(helptext); 592 free(helptext);
593 } else 593 } else
594 show_helptext(menu_get_prompt(menu), help); 594 show_helptext(menu_get_prompt(menu), help);
595} 595}
596 596
597static void show_readme(void) 597static void show_readme(void)
598{ 598{
599 do { 599 do {
600 cprint_init(); 600 cprint_init();
601 cprint("--textbox"); 601 cprint("--textbox");
602 cprint("scripts/README.Menuconfig"); 602 cprint("scripts/README.Menuconfig");
603 cprint("%d", rows); 603 cprint("%d", rows);
604 cprint("%d", cols); 604 cprint("%d", cols);
605 } while (exec_conf() == -1); 605 } while (exec_conf() == -1);
606} 606}
607 607
608static void conf_choice(struct menu *menu) 608static void conf_choice(struct menu *menu)
609{ 609{
610 const char *prompt = menu_get_prompt(menu); 610 const char *prompt = menu_get_prompt(menu);
611 struct menu *child; 611 struct menu *child;
612 struct symbol *active; 612 struct symbol *active;
613 int stat; 613 int stat;
614 614
615 while (1) { 615 while (1) {
616 cprint_init(); 616 cprint_init();
617 cprint("--title"); 617 cprint("--title");
618 cprint("%s", prompt ? prompt : "Main Menu"); 618 cprint("%s", prompt ? prompt : "Main Menu");
619 cprint("--radiolist"); 619 cprint("--radiolist");
620 cprint(radiolist_instructions); 620 cprint(radiolist_instructions);
621 cprint("15"); 621 cprint("15");
622 cprint("70"); 622 cprint("70");
623 cprint("6"); 623 cprint("6");
624 624
625 current_menu = menu; 625 current_menu = menu;
626 active = sym_get_choice_value(menu->sym); 626 active = sym_get_choice_value(menu->sym);
627 for (child = menu->list; child; child = child->next) { 627 for (child = menu->list; child; child = child->next) {
628 if (!menu_is_visible(child)) 628 if (!menu_is_visible(child))
629 continue; 629 continue;
630 cprint("%p", child); 630 cprint("%p", child);
631 cprint("%s", menu_get_prompt(child)); 631 cprint("%s", menu_get_prompt(child));
632 cprint(child->sym == active ? "ON" : "OFF"); 632 cprint(child->sym == active ? "ON" : "OFF");
633 } 633 }
634 634
635 stat = exec_conf(); 635 stat = exec_conf();
636 switch (stat) { 636 switch (stat) {
637 case 0: 637 case 0:
638 if (sscanf(input_buf, "%p", &menu) != 1) 638 if (sscanf(input_buf, "%p", &menu) != 1)
639 break; 639 break;
640 sym_set_tristate_value(menu->sym, yes); 640 sym_set_tristate_value(menu->sym, yes);
641 return; 641 return;
642 case 1: 642 case 1:
643 show_help(menu); 643 show_help(menu);
644 break; 644 break;
645 case 255: 645 case 255:
646 return; 646 return;
647 } 647 }
648 } 648 }
649} 649}
650 650
651static void conf_string(struct menu *menu) 651static void conf_string(struct menu *menu)
652{ 652{
653 const char *prompt = menu_get_prompt(menu); 653 const char *prompt = menu_get_prompt(menu);
654 int stat; 654 int stat;
655 655
656 while (1) { 656 while (1) {
657 cprint_init(); 657 cprint_init();
658 cprint("--title"); 658 cprint("--title");
659 cprint("%s", prompt ? prompt : "Main Menu"); 659 cprint("%s", prompt ? prompt : "Main Menu");
660 cprint("--inputbox"); 660 cprint("--inputbox");
661 switch (sym_get_type(menu->sym)) { 661 switch (sym_get_type(menu->sym)) {
662 case S_INT: 662 case S_INT:
663 cprint(inputbox_instructions_int); 663 cprint(inputbox_instructions_int);
664 break; 664 break;
665 case S_HEX: 665 case S_HEX:
666 cprint(inputbox_instructions_hex); 666 cprint(inputbox_instructions_hex);
667 break; 667 break;
668 case S_STRING: 668 case S_STRING:
669 cprint(inputbox_instructions_string); 669 cprint(inputbox_instructions_string);
670 break; 670 break;
671 default: 671 default:
672 /* panic? */; 672 /* panic? */;
673 } 673 }
674 cprint("10"); 674 cprint("10");
675 cprint("75"); 675 cprint("75");
676 cprint("%s", sym_get_string_value(menu->sym)); 676 cprint("%s", sym_get_string_value(menu->sym));
677 stat = exec_conf(); 677 stat = exec_conf();
678 switch (stat) { 678 switch (stat) {
679 case 0: 679 case 0:
680 if (sym_set_string_value(menu->sym, input_buf)) 680 if (sym_set_string_value(menu->sym, input_buf))
681 return; 681 return;
682 show_textbox(NULL, "You have made an invalid entry.", 5, 43); 682 show_textbox(NULL, "You have made an invalid entry.", 5, 43);
683 break; 683 break;
684 case 1: 684 case 1:
685 show_help(menu); 685 show_help(menu);
686 break; 686 break;
687 case 255: 687 case 255:
688 return; 688 return;
689 } 689 }
690 } 690 }
691} 691}
692 692
693static void conf_load(void) 693static void conf_load(void)
694{ 694{
695 int stat; 695 int stat;
696 696
697 while (1) { 697 while (1) {
698 cprint_init(); 698 cprint_init();
699 cprint("--inputbox"); 699 cprint("--inputbox");
700 cprint(load_config_text); 700 cprint(load_config_text);
701 cprint("11"); 701 cprint("11");
702 cprint("55"); 702 cprint("55");
703 cprint("%s", filename); 703 cprint("%s", filename);
704 stat = exec_conf(); 704 stat = exec_conf();
705 switch(stat) { 705 switch(stat) {
706 case 0: 706 case 0:
707 if (!input_buf[0]) 707 if (!input_buf[0])
708 return; 708 return;
709 if (!conf_read(input_buf)) 709 if (!conf_read(input_buf))
710 return; 710 return;
711 show_textbox(NULL, "File does not exist!", 5, 38); 711 show_textbox(NULL, "File does not exist!", 5, 38);
712 break; 712 break;
713 case 1: 713 case 1:
714 show_helptext("Load Alternate Configuration", load_config_help); 714 show_helptext("Load Alternate Configuration", load_config_help);
715 break; 715 break;
716 case 255: 716 case 255:
717 return; 717 return;
718 } 718 }
719 } 719 }
720} 720}
721 721
722static void conf_save(void) 722static void conf_save(void)
723{ 723{
724 int stat; 724 int stat;
725 725
726 while (1) { 726 while (1) {
727 cprint_init(); 727 cprint_init();
728 cprint("--inputbox"); 728 cprint("--inputbox");
729 cprint(save_config_text); 729 cprint(save_config_text);
730 cprint("11"); 730 cprint("11");
731 cprint("55"); 731 cprint("55");
732 cprint("%s", filename); 732 cprint("%s", filename);
733 stat = exec_conf(); 733 stat = exec_conf();
734 switch(stat) { 734 switch(stat) {
735 case 0: 735 case 0:
736 if (!input_buf[0]) 736 if (!input_buf[0])
737 return; 737 return;
738 if (!conf_write(input_buf)) 738 if (!conf_write(input_buf))
739 return; 739 return;
740 show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); 740 show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60);
741 break; 741 break;
742 case 1: 742 case 1:
743 show_helptext("Save Alternate Configuration", save_config_help); 743 show_helptext("Save Alternate Configuration", save_config_help);
744 break; 744 break;
745 case 255: 745 case 255:
746 return; 746 return;
747 } 747 }
748 } 748 }
749} 749}
750 750
751static void conf_cleanup(void) 751static void conf_cleanup(void)
752{ 752{
753 tcsetattr(1, TCSAFLUSH, &ios_org); 753 tcsetattr(1, TCSAFLUSH, &ios_org);
754 unlink(".help.tmp"); 754 unlink(".help.tmp");
755 unlink("lxdialog.scrltmp"); 755 unlink("lxdialog.scrltmp");
756} 756}
757 757
758int main(int ac, char **av) 758int main(int ac, char **av)
759{ 759{
760 struct symbol *sym; 760 struct symbol *sym;
761 char *mode; 761 char *mode;
762 int stat; 762 int stat;
763 763
764 conf_parse(av[1]); 764 conf_parse(av[1]);
765 conf_read(NULL); 765 conf_read(NULL);
766 766
767 sym = sym_lookup("KERNELRELEASE", 0); 767 sym = sym_lookup("KERNELRELEASE", 0);
768 sym_calc_value(sym); 768 sym_calc_value(sym);
769 sprintf(menu_backtitle, "Build Configuration"); 769 sprintf(menu_backtitle, "Build Configuration");
770 770
771 mode = getenv("MENUCONFIG_MODE"); 771 mode = getenv("MENUCONFIG_MODE");
772 if (mode) { 772 if (mode) {
773 if (!strcasecmp(mode, "single_menu")) 773 if (!strcasecmp(mode, "single_menu"))
774 single_menu_mode = 1; 774 single_menu_mode = 1;
775 } 775 }
776 776
777 tcgetattr(1, &ios_org); 777 tcgetattr(1, &ios_org);
778 atexit(conf_cleanup); 778 atexit(conf_cleanup);
779 init_wsize(); 779 init_wsize();
780 conf(&rootmenu); 780 conf(&rootmenu);
781 781
782 do { 782 do {
783 cprint_init(); 783 cprint_init();
784 cprint("--yesno"); 784 cprint("--yesno");
785 cprint("Do you wish to save your new configuration?"); 785 cprint("Do you wish to save your new configuration?");
786 cprint("5"); 786 cprint("5");
787 cprint("60"); 787 cprint("60");
788 stat = exec_conf(); 788 stat = exec_conf();
789 } while (stat < 0); 789 } while (stat < 0);
790 790
791 if (stat == 0) { 791 if (stat == 0) {
792 conf_write(NULL); 792 conf_write(NULL);
793 printf("\n\n" 793 printf("\n\n"
794 "*** End of configuration.\n" 794 "*** End of configuration.\n"
795 "\n\n"); 795 "\n\n");
796 } else 796 } else
797 printf("\n\n" 797 printf("\n\n"
798 "Your configuration changes were NOT saved." 798 "Your configuration changes were NOT saved."
799 "\n\n"); 799 "\n\n");
800 800
801 return 0; 801 return 0;
802} 802}