aboutsummaryrefslogtreecommitdiff
path: root/scripts/config/conf.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-08-05 02:18:25 +0000
committerEric Andersen <andersen@codepoet.org>2003-08-05 02:18:25 +0000
commit72d8e444f0e9e002b16328e73464ef9015979048 (patch)
treed1d99e668617e95836a1f767257e1263963feaa5 /scripts/config/conf.c
parent461c279ac176a28dec40d1e40ebaffe4f0ac688d (diff)
downloadbusybox-w32-72d8e444f0e9e002b16328e73464ef9015979048.tar.gz
busybox-w32-72d8e444f0e9e002b16328e73464ef9015979048.tar.bz2
busybox-w32-72d8e444f0e9e002b16328e73464ef9015979048.zip
Merge/rework config system per the latest from linux-2.6.0-test2.
Fix the config bugs revealed by the updated config system. -Erik
Diffstat (limited to 'scripts/config/conf.c')
-rw-r--r--scripts/config/conf.c226
1 files changed, 113 insertions, 113 deletions
diff --git a/scripts/config/conf.c b/scripts/config/conf.c
index 884175e54..013a679dd 100644
--- a/scripts/config/conf.c
+++ b/scripts/config/conf.c
@@ -35,50 +35,12 @@ static struct menu *rootEntry;
35 35
36static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; 36static char nohelp_text[] = "Sorry, no help available for this option yet.\n";
37 37
38#if 0
39static void printc(int ch)
40{
41 static int sep = 0;
42
43 if (!sep) {
44 putchar('[');
45 sep = 1;
46 } else if (ch)
47 putchar('/');
48 if (!ch) {
49 putchar(']');
50 putchar(' ');
51 sep = 0;
52 } else
53 putchar(ch);
54}
55#endif
56
57static void printo(const char *o)
58{
59 static int sep = 0;
60
61 if (!sep) {
62 putchar('(');
63 sep = 1;
64 } else if (o) {
65 putchar(',');
66 putchar(' ');
67 }
68 if (!o) {
69 putchar(')');
70 putchar(' ');
71 sep = 0;
72 } else
73 printf("%s", o);
74}
75
76static void strip(char *str) 38static void strip(char *str)
77{ 39{
78 char *p = str; 40 char *p = str;
79 int l; 41 int l;
80 42
81 while ((isspace((int)*p))) 43 while ((isspace(*p)))
82 p++; 44 p++;
83 l = strlen(p); 45 l = strlen(p);
84 if (p != str) 46 if (p != str)
@@ -86,10 +48,20 @@ static void strip(char *str)
86 if (!l) 48 if (!l)
87 return; 49 return;
88 p = str + l - 1; 50 p = str + l - 1;
89 while ((isspace((int)*p))) 51 while ((isspace(*p)))
90 *p-- = 0; 52 *p-- = 0;
91} 53}
92 54
55static void check_stdin(void)
56{
57 if (!valid_stdin && input_mode == ask_silent) {
58 printf("aborted!\n\n");
59 printf("Console input/output is redirected. ");
60 printf("Run 'make oldconfig' to update configuration.\n\n");
61 exit(1);
62 }
63}
64
93static void conf_askvalue(struct symbol *sym, const char *def) 65static void conf_askvalue(struct symbol *sym, const char *def)
94{ 66{
95 enum symbol_type type = sym_get_type(sym); 67 enum symbol_type type = sym_get_type(sym);
@@ -101,6 +73,13 @@ static void conf_askvalue(struct symbol *sym, const char *def)
101 line[0] = '\n'; 73 line[0] = '\n';
102 line[1] = 0; 74 line[1] = 0;
103 75
76 if (!sym_is_changable(sym)) {
77 printf("%s\n", def);
78 line[0] = '\n';
79 line[1] = 0;
80 return;
81 }
82
104 switch (input_mode) { 83 switch (input_mode) {
105 case ask_new: 84 case ask_new:
106 case ask_silent: 85 case ask_silent:
@@ -108,12 +87,7 @@ static void conf_askvalue(struct symbol *sym, const char *def)
108 printf("%s\n", def); 87 printf("%s\n", def);
109 return; 88 return;
110 } 89 }
111 if (!valid_stdin && input_mode == ask_silent) { 90 check_stdin();
112 printf("aborted!\n\n");
113 printf("Console input/output is redirected. ");
114 printf("Run 'make oldconfig' to update configuration.\n\n");
115 exit(1);
116 }
117 case ask_all: 91 case ask_all:
118 fflush(stdout); 92 fflush(stdout);
119 fgets(line, 128, stdin); 93 fgets(line, 128, stdin);
@@ -294,9 +268,8 @@ help:
294static int conf_choice(struct menu *menu) 268static int conf_choice(struct menu *menu)
295{ 269{
296 struct symbol *sym, *def_sym; 270 struct symbol *sym, *def_sym;
297 struct menu *cmenu, *def_menu; 271 struct menu *child;
298 const char *help; 272 int type;
299 int type, len;
300 bool is_new; 273 bool is_new;
301 274
302 sym = menu->sym; 275 sym = menu->sym;
@@ -314,72 +287,111 @@ static int conf_choice(struct menu *menu)
314 break; 287 break;
315 } 288 }
316 } else { 289 } else {
317 sym->def = sym->curr; 290 switch (sym_get_tristate_value(sym)) {
318 if (S_TRI(sym->curr) == mod) { 291 case no:
292 return 1;
293 case mod:
319 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); 294 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
320 return 0; 295 return 0;
296 case yes:
297 break;
321 } 298 }
322 } 299 }
323 300
324 while (1) { 301 while (1) {
325 printf("%*s%s ", indent - 1, "", menu_get_prompt(menu)); 302 int cnt, def;
303
304 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
326 def_sym = sym_get_choice_value(sym); 305 def_sym = sym_get_choice_value(sym);
327 def_menu = NULL; 306 cnt = def = 0;
328 for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { 307 line[0] = '0';
329 if (!menu_is_visible(cmenu)) 308 line[1] = 0;
309 for (child = menu->list; child; child = child->next) {
310 if (!menu_is_visible(child))
330 continue; 311 continue;
331 printo(menu_get_prompt(cmenu)); 312 if (!child->sym) {
332 if (cmenu->sym == def_sym) 313 printf("%*c %s\n", indent, '*', menu_get_prompt(child));
333 def_menu = cmenu; 314 continue;
334 } 315 }
335 printo(NULL); 316 cnt++;
336 if (def_menu) 317 if (child->sym == def_sym) {
337 printf("[%s] ", menu_get_prompt(def_menu)); 318 def = cnt;
338 else { 319 printf("%*c", indent, '>');
320 } else
321 printf("%*c", indent, ' ');
322 printf(" %d. %s", cnt, menu_get_prompt(child));
323 if (child->sym->name)
324 printf(" (%s)", child->sym->name);
325 if (!sym_has_value(child->sym))
326 printf(" (NEW)");
339 printf("\n"); 327 printf("\n");
340 return 1;
341 } 328 }
329 printf("%*schoice", indent - 1, "");
330 if (cnt == 1) {
331 printf("[1]: 1\n");
332 goto conf_childs;
333 }
334 printf("[1-%d", cnt);
335 if (sym->help)
336 printf("?");
337 printf("]: ");
342 switch (input_mode) { 338 switch (input_mode) {
343 case ask_new: 339 case ask_new:
344 case ask_silent: 340 case ask_silent:
341 if (!is_new) {
342 cnt = def;
343 printf("%d\n", cnt);
344 break;
345 }
346 check_stdin();
345 case ask_all: 347 case ask_all:
346 conf_askvalue(sym, menu_get_prompt(def_menu)); 348 fflush(stdout);
349 fgets(line, 128, stdin);
347 strip(line); 350 strip(line);
351 if (line[0] == '?') {
352 printf("\n%s\n", menu->sym->help ?
353 menu->sym->help : nohelp_text);
354 continue;
355 }
356 if (!line[0])
357 cnt = def;
358 else if (isdigit(line[0]))
359 cnt = atoi(line);
360 else
361 continue;
362 break;
363 case set_random:
364 def = (random() % cnt) + 1;
365 case set_default:
366 case set_yes:
367 case set_mod:
368 case set_no:
369 cnt = def;
370 printf("%d\n", cnt);
348 break; 371 break;
349 default:
350 line[0] = 0;
351 printf("\n");
352 } 372 }
353 if (line[0] == '?' && !line[1]) { 373
354 help = nohelp_text; 374 conf_childs:
355 if (menu->sym->help) 375 for (child = menu->list; child; child = child->next) {
356 help = menu->sym->help; 376 if (!child->sym || !menu_is_visible(child))
357 printf("\n%s\n", help); 377 continue;
358 continue; 378 if (!--cnt)
379 break;
359 } 380 }
360 if (line[0]) { 381 if (!child)
361 len = strlen(line); 382 continue;
362 line[len] = 0; 383 if (line[strlen(line) - 1] == '?') {
363 384 printf("\n%s\n", child->sym->help ?
364 def_menu = NULL; 385 child->sym->help : nohelp_text);
365 for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { 386 continue;
366 if (!cmenu->sym || !menu_is_visible(cmenu))
367 continue;
368 if (!strncasecmp(line, menu_get_prompt(cmenu), len)) {
369 def_menu = cmenu;
370 break;
371 }
372 }
373 } 387 }
374 if (def_menu) { 388 sym_set_choice_value(sym, child->sym);
375 sym_set_choice_value(sym, def_menu->sym); 389 if (child->list) {
376 if (def_menu->list) { 390 indent += 2;
377 indent += 2; 391 conf(child->list);
378 conf(def_menu->list); 392 indent -= 2;
379 indent -= 2;
380 }
381 return 1;
382 } 393 }
394 return 1;
383 } 395 }
384} 396}
385 397
@@ -420,7 +432,7 @@ static void conf(struct menu *menu)
420 432
421 if (sym_is_choice(sym)) { 433 if (sym_is_choice(sym)) {
422 conf_choice(menu); 434 conf_choice(menu);
423 if (S_TRI(sym->curr) != mod) 435 if (sym->curr.tri != mod)
424 return; 436 return;
425 goto conf_childs; 437 goto conf_childs;
426 } 438 }
@@ -454,29 +466,17 @@ static void check_conf(struct menu *menu)
454 return; 466 return;
455 467
456 sym = menu->sym; 468 sym = menu->sym;
457 if (!sym) 469 if (sym) {
458 goto conf_childs; 470 if (sym_is_changable(sym) && !sym_has_value(sym)) {
459
460 if (sym_is_choice(sym)) {
461 if (!sym_has_value(sym)) {
462 if (!conf_cnt++) 471 if (!conf_cnt++)
463 printf("*\n* Restart config...\n*\n"); 472 printf("*\n* Restart config...\n*\n");
464 rootEntry = menu_get_parent_menu(menu); 473 rootEntry = menu_get_parent_menu(menu);
465 conf(rootEntry); 474 conf(rootEntry);
466 } 475 }
467 if (sym_get_tristate_value(sym) != mod) 476 if (sym_is_choice(sym) && sym_get_tristate_value(sym) != mod)
468 return; 477 return;
469 goto conf_childs;
470 } 478 }
471 479
472 if (!sym_has_value(sym)) {
473 if (!conf_cnt++)
474 printf("*\n* Restart config...\n*\n");
475 rootEntry = menu_get_parent_menu(menu);
476 conf(rootEntry);
477 }
478
479conf_childs:
480 for (child = menu->list; child; child = child->next) 480 for (child = menu->list; child; child = child->next)
481 check_conf(child); 481 check_conf(child);
482} 482}
@@ -536,8 +536,8 @@ int main(int ac, char **av)
536 printf("***\n" 536 printf("***\n"
537 "*** You have not yet configured BusyBox!\n" 537 "*** You have not yet configured BusyBox!\n"
538 "***\n" 538 "***\n"
539 "*** Please run some configurator (e.g. \"make oldconfig\"\n" 539 "*** Please run some configurator (e.g. \"make config\" or\n"
540 "*** or \"make menuconfig\").\n" 540 "*** \"make oldconfig\" or \"make menuconfig\").\n"
541 "***\n"); 541 "***\n");
542 exit(1); 542 exit(1);
543 } 543 }