static int conf_choice(struct menu *menu) { struct symbol *sym, *def_sym; struct menu *child; bool is_new; sym = menu->sym; is_new = !sym_has_value(sym); if (sym_is_changable(sym)) { conf_sym(menu); sym_calc_value(sym); switch (sym_get_tristate_value(sym)) { case no: return 1; case mod: return 0; case yes: break; } } else { switch (sym_get_tristate_value(sym)) { case no: return 1; case mod: printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu))); return 0; case yes: break; } } while (1) { int cnt, def; printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu))); def_sym = sym_get_choice_value(sym); cnt = def = 0; line[0] = 0; for (child = menu->list; child; child = child->next) { if (!menu_is_visible(child)) continue; if (!child->sym) { printf("%*c %s\n", indent, '*', _(menu_get_prompt(child))); continue; } cnt++; if (child->sym == def_sym) { def = cnt; printf("%*c", indent, '>'); } else printf("%*c", indent, ' '); printf(" %d. %s", cnt, _(menu_get_prompt(child))); if (child->sym->name) printf(" (%s)", child->sym->name); if (!sym_has_value(child->sym)) printf(_(" (NEW)")); printf("\n"); } printf(_("%*schoice"), indent - 1, ""); if (cnt == 1) { printf("[1]: 1\n"); goto conf_childs; } printf("[1-%d", cnt); if (menu_has_help(menu)) printf("?"); printf("]: "); switch (input_mode) { case oldconfig: case silentoldconfig: if (!is_new) { cnt = def; printf("%d\n", cnt); break; } check_stdin(); /* fall through */ case oldaskconfig: fflush(stdout); xfgets(line, 128, stdin); strip(line); if (line[0] == '?') { print_help(menu); continue; } if (!line[0]) cnt = def; else if (isdigit(line[0])) cnt = atoi(line); else continue; break; default: break; } conf_childs: for (child = menu->list; child; child = child->next) { if (!child->sym || !menu_is_visible(child)) continue; if (!--cnt) break; } if (!child) continue; if (line[0] && line[strlen(line) - 1] == '?') { print_help(child); continue; } sym_set_choice_value(sym, child->sym); for (child = child->list; child; child = child->next) { indent += 2; conf(child); indent -= 2; } return 1; } }
static int conf_choice(struct menu *menu) { struct symbol *sym, *def_sym; struct menu *cmenu, *def_menu; const char *help; int type, len; bool is_new; sym = menu->sym; type = sym_get_type(sym); is_new = !sym_has_value(sym); if (sym_is_changable(sym)) { conf_sym(menu); sym_calc_value(sym); switch (sym_get_tristate_value(sym)) { case no: return 1; case mod: return 0; case yes: break; } } else { sym->def = sym->curr; if (S_TRI(sym->curr) == mod) { printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); return 0; } } while (1) { printf("%*s%s ", indent - 1, "", menu_get_prompt(menu)); def_sym = sym_get_choice_value(sym); def_menu = NULL; for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { if (!menu_is_visible(cmenu)) continue; printo(menu_get_prompt(cmenu)); if (cmenu->sym == def_sym) def_menu = cmenu; } printo(NULL); if (def_menu) printf("[%s] ", menu_get_prompt(def_menu)); else { printf("\n"); return 1; } switch (input_mode) { case ask_new: case ask_silent: case ask_all: if (is_new) sym->flags |= SYMBOL_NEW; conf_askvalue(sym, menu_get_prompt(def_menu)); strip(line); break; default: line[0] = 0; printf("\n"); } if (line[0] == '?' && !line[1]) { help = nohelp_text; if (menu->sym->help) help = menu->sym->help; printf("\n%s\n", help); continue; } if (line[0]) { len = strlen(line); line[len] = 0; def_menu = NULL; for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { if (!cmenu->sym || !menu_is_visible(cmenu)) continue; if (!strncasecmp(line, menu_get_prompt(cmenu), len)) { def_menu = cmenu; break; } } } if (def_menu) { sym_set_choice_value(sym, def_menu->sym); if (def_menu->list) { indent += 2; conf(def_menu->list); indent -= 2; } return 1; } } }
static int conf_choice(struct menu *menu) { struct symbol *sym, *def_sym; struct menu *child; int type; bool is_new; sym = menu->sym; type = sym_get_type(sym); is_new = !sym_has_value(sym); if (sym_is_changable(sym)) { conf_sym(menu); sym_calc_value(sym); switch (sym_get_tristate_value(sym)) { case no: return 1; case mod: return 0; case yes: break; } } else { switch (sym_get_tristate_value(sym)) { case no: return 1; case mod: printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); return 0; case yes: break; } } while (1) { int cnt, def; printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); def_sym = sym_get_choice_value(sym); cnt = def = 0; line[0] = 0; for (child = menu->list; child; child = child->next) { if (!menu_is_visible(child)) continue; if (!child->sym) { printf("%*c %s\n", indent, '*', menu_get_prompt(child)); continue; } cnt++; if (child->sym == def_sym) { def = cnt; printf("%*c", indent, '>'); } else printf("%*c", indent, ' '); printf(" %d. %s", cnt, menu_get_prompt(child)); if (child->sym->name) printf(" (%s)", child->sym->name); if (!sym_has_value(child->sym)) printf(" (NEW)"); printf("\n"); } printf("%*schoice", indent - 1, ""); if (cnt == 1) { printf("[1]: 1\n"); goto conf_childs; } printf("[1-%d", cnt); if (sym->help) printf("?"); printf("]: "); switch (input_mode) { case ask_new: case ask_silent: if (!is_new) { cnt = def; printf("%d\n", cnt); break; } check_stdin(); case ask_all: fflush(stdout); fgets(line, 128, stdin); strip(line); if (line[0] == '?') { printf("\n%s\n", menu->sym->help ? menu->sym->help : nohelp_text); continue; } if (!line[0]) cnt = def; else if (isdigit(line[0])) cnt = atoi(line); else continue; break; case set_random: def = (random() % cnt) + 1; case set_default: case set_yes: case set_mod: case set_no: cnt = def; printf("%d\n", cnt); break; } conf_childs: for (child = menu->list; child; child = child->next) { if (!child->sym || !menu_is_visible(child)) continue; if (!--cnt) break; } if (!child) continue; if (line[strlen(line) - 1] == '?') { printf("\n%s\n", child->sym->help ? child->sym->help : nohelp_text); continue; } sym_set_choice_value(sym, child->sym); if (child->list) { indent += 2; conf(child->list); indent -= 2; } return 1; } }
static int conf_choice(struct menu *menu) { struct symbol *sym, *def_sym; struct menu *child; // int type; backported future linux patch to 2.6.30 to fix gcc4.6 compiler warning bool is_new; sym = menu->sym; // type = sym_get_type(sym); see backported comment above is_new = !sym_has_value(sym); if (sym_is_changable(sym)) { conf_sym(menu); sym_calc_value(sym); switch (sym_get_tristate_value(sym)) { case no: return 1; case mod: return 0; case yes: break; } } else { switch (sym_get_tristate_value(sym)) { case no: return 1; case mod: printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu))); return 0; case yes: break; } } while (1) { int cnt, def; printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu))); def_sym = sym_get_choice_value(sym); cnt = def = 0; line[0] = 0; for (child = menu->list; child; child = child->next) { if (!menu_is_visible(child)) continue; if (!child->sym) { printf("%*c %s\n", indent, '*', _(menu_get_prompt(child))); continue; } cnt++; if (child->sym == def_sym) { def = cnt; printf("%*c", indent, '>'); } else printf("%*c", indent, ' '); printf(" %d. %s", cnt, _(menu_get_prompt(child))); if (child->sym->name) printf(" (%s)", child->sym->name); if (!sym_has_value(child->sym)) printf(_(" (NEW)")); printf("\n"); } printf(_("%*schoice"), indent - 1, ""); if (cnt == 1) { printf("[1]: 1\n"); goto conf_childs; } printf("[1-%d", cnt); if (menu_has_help(menu)) printf("?"); printf("]: "); switch (input_mode) { case ask_new: case ask_silent: if (!is_new) { cnt = def; printf("%d\n", cnt); break; } check_stdin(); case ask_all: fflush(stdout); if (NULL == fgets(line, 128, stdin)) { //BRCM: check ret val to fix compiler warning printf("fgets failed, exiting\n"); exit(2); } strip(line); if (line[0] == '?') { printf("\n%s\n", get_help(menu)); continue; } if (!line[0]) cnt = def; else if (isdigit(line[0])) cnt = atoi(line); else continue; break; default: break; } conf_childs: for (child = menu->list; child; child = child->next) { if (!child->sym || !menu_is_visible(child)) continue; if (!--cnt) break; } if (!child) continue; if (line[strlen(line) - 1] == '?') { printf("\n%s\n", get_help(child)); continue; } sym_set_choice_value(sym, child->sym); for (child = child->list; child; child = child->next) { indent += 2; conf(child); indent -= 2; } return 1; } }