Merge tag 'ceph-for-6.4-rc1' of https://github.com/ceph/ceph-client
[linux-block.git] / scripts / kconfig / mconf.c
index e67e0db50b2e2510b88f1507f0462ec1812813f4..53d8834d12fe0ceb7458295d73546f6363ad4ac8 100644 (file)
@@ -290,16 +290,6 @@ static int save_and_exit;
 static int silent;
 
 static void conf(struct menu *menu, struct menu *active_menu);
-static void conf_choice(struct menu *menu);
-static void conf_string(struct menu *menu);
-static void conf_load(void);
-static void conf_save(void);
-static int show_textbox_ext(const char *title, char *text, int r, int c,
-                           int *keys, int *vscroll, int *hscroll,
-                           update_text_fn update_text, void *data);
-static void show_textbox(const char *title, const char *text, int r, int c);
-static void show_helptext(const char *title, const char *text);
-static void show_help(struct menu *menu);
 
 static char filename[PATH_MAX+1];
 static void set_config_filename(const char *config_filename)
@@ -358,6 +348,37 @@ static void reset_subtitle(void)
        set_dialog_subtitles(subtitles);
 }
 
+static int show_textbox_ext(const char *title, char *text, int r, int c, int
+                           *keys, int *vscroll, int *hscroll, update_text_fn
+                           update_text, void *data)
+{
+       dialog_clear();
+       return dialog_textbox(title, text, r, c, keys, vscroll, hscroll,
+                             update_text, data);
+}
+
+static void show_textbox(const char *title, const char *text, int r, int c)
+{
+       show_textbox_ext(title, (char *) text, r, c, (int []) {0}, NULL, NULL,
+                        NULL, NULL);
+}
+
+static void show_helptext(const char *title, const char *text)
+{
+       show_textbox(title, text, 0, 0);
+}
+
+static void show_help(struct menu *menu)
+{
+       struct gstr help = str_new();
+
+       help.max_width = getmaxx(stdscr) - 10;
+       menu_get_ext_help(menu, &help);
+
+       show_helptext(menu_get_prompt(menu), str_get(&help));
+       str_free(&help);
+}
+
 struct search_data {
        struct list_head *head;
        struct menu **targets;
@@ -643,158 +664,6 @@ conf_childs:
        indent -= doint;
 }
 
-static void conf(struct menu *menu, struct menu *active_menu)
-{
-       struct menu *submenu;
-       const char *prompt = menu_get_prompt(menu);
-       struct subtitle_part stpart;
-       struct symbol *sym;
-       int res;
-       int s_scroll = 0;
-
-       if (menu != &rootmenu)
-               stpart.text = menu_get_prompt(menu);
-       else
-               stpart.text = NULL;
-       list_add_tail(&stpart.entries, &trail);
-
-       while (1) {
-               item_reset();
-               current_menu = menu;
-               build_conf(menu);
-               if (!child_count)
-                       break;
-               set_subtitle();
-               dialog_clear();
-               res = dialog_menu(prompt ? prompt : "Main Menu",
-                                 menu_instructions,
-                                 active_menu, &s_scroll);
-               if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL)
-                       break;
-               if (item_count() != 0) {
-                       if (!item_activate_selected())
-                               continue;
-                       if (!item_tag())
-                               continue;
-               }
-               submenu = item_data();
-               active_menu = item_data();
-               if (submenu)
-                       sym = submenu->sym;
-               else
-                       sym = NULL;
-
-               switch (res) {
-               case 0:
-                       switch (item_tag()) {
-                       case 'm':
-                               if (single_menu_mode)
-                                       submenu->data = (void *) (long) !submenu->data;
-                               else
-                                       conf(submenu, NULL);
-                               break;
-                       case 't':
-                               if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
-                                       conf_choice(submenu);
-                               else if (submenu->prompt->type == P_MENU)
-                                       conf(submenu, NULL);
-                               break;
-                       case 's':
-                               conf_string(submenu);
-                               break;
-                       }
-                       break;
-               case 2:
-                       if (sym)
-                               show_help(submenu);
-                       else {
-                               reset_subtitle();
-                               show_helptext("README", mconf_readme);
-                       }
-                       break;
-               case 3:
-                       reset_subtitle();
-                       conf_save();
-                       break;
-               case 4:
-                       reset_subtitle();
-                       conf_load();
-                       break;
-               case 5:
-                       if (item_is_tag('t')) {
-                               if (sym_set_tristate_value(sym, yes))
-                                       break;
-                               if (sym_set_tristate_value(sym, mod))
-                                       show_textbox(NULL, setmod_text, 6, 74);
-                       }
-                       break;
-               case 6:
-                       if (item_is_tag('t'))
-                               sym_set_tristate_value(sym, no);
-                       break;
-               case 7:
-                       if (item_is_tag('t'))
-                               sym_set_tristate_value(sym, mod);
-                       break;
-               case 8:
-                       if (item_is_tag('t'))
-                               sym_toggle_tristate_value(sym);
-                       else if (item_is_tag('m'))
-                               conf(submenu, NULL);
-                       break;
-               case 9:
-                       search_conf();
-                       break;
-               case 10:
-                       show_all_options = !show_all_options;
-                       break;
-               }
-       }
-
-       list_del(trail.prev);
-}
-
-static int show_textbox_ext(const char *title, char *text, int r, int c, int
-                           *keys, int *vscroll, int *hscroll, update_text_fn
-                           update_text, void *data)
-{
-       dialog_clear();
-       return dialog_textbox(title, text, r, c, keys, vscroll, hscroll,
-                             update_text, data);
-}
-
-static void show_textbox(const char *title, const char *text, int r, int c)
-{
-       show_textbox_ext(title, (char *) text, r, c, (int []) {0}, NULL, NULL,
-                        NULL, NULL);
-}
-
-static void show_helptext(const char *title, const char *text)
-{
-       show_textbox(title, text, 0, 0);
-}
-
-static void conf_message_callback(const char *s)
-{
-       if (save_and_exit) {
-               if (!silent)
-                       printf("%s", s);
-       } else {
-               show_textbox(NULL, s, 6, 60);
-       }
-}
-
-static void show_help(struct menu *menu)
-{
-       struct gstr help = str_new();
-
-       help.max_width = getmaxx(stdscr) - 10;
-       menu_get_ext_help(menu, &help);
-
-       show_helptext(menu_get_prompt(menu), str_get(&help));
-       str_free(&help);
-}
-
 static void conf_choice(struct menu *menu)
 {
        const char *prompt = menu_get_prompt(menu);
@@ -950,6 +819,127 @@ static void conf_save(void)
        }
 }
 
+static void conf(struct menu *menu, struct menu *active_menu)
+{
+       struct menu *submenu;
+       const char *prompt = menu_get_prompt(menu);
+       struct subtitle_part stpart;
+       struct symbol *sym;
+       int res;
+       int s_scroll = 0;
+
+       if (menu != &rootmenu)
+               stpart.text = menu_get_prompt(menu);
+       else
+               stpart.text = NULL;
+       list_add_tail(&stpart.entries, &trail);
+
+       while (1) {
+               item_reset();
+               current_menu = menu;
+               build_conf(menu);
+               if (!child_count)
+                       break;
+               set_subtitle();
+               dialog_clear();
+               res = dialog_menu(prompt ? prompt : "Main Menu",
+                                 menu_instructions,
+                                 active_menu, &s_scroll);
+               if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL)
+                       break;
+               if (item_count() != 0) {
+                       if (!item_activate_selected())
+                               continue;
+                       if (!item_tag())
+                               continue;
+               }
+               submenu = item_data();
+               active_menu = item_data();
+               if (submenu)
+                       sym = submenu->sym;
+               else
+                       sym = NULL;
+
+               switch (res) {
+               case 0:
+                       switch (item_tag()) {
+                       case 'm':
+                               if (single_menu_mode)
+                                       submenu->data = (void *) (long) !submenu->data;
+                               else
+                                       conf(submenu, NULL);
+                               break;
+                       case 't':
+                               if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
+                                       conf_choice(submenu);
+                               else if (submenu->prompt->type == P_MENU)
+                                       conf(submenu, NULL);
+                               break;
+                       case 's':
+                               conf_string(submenu);
+                               break;
+                       }
+                       break;
+               case 2:
+                       if (sym)
+                               show_help(submenu);
+                       else {
+                               reset_subtitle();
+                               show_helptext("README", mconf_readme);
+                       }
+                       break;
+               case 3:
+                       reset_subtitle();
+                       conf_save();
+                       break;
+               case 4:
+                       reset_subtitle();
+                       conf_load();
+                       break;
+               case 5:
+                       if (item_is_tag('t')) {
+                               if (sym_set_tristate_value(sym, yes))
+                                       break;
+                               if (sym_set_tristate_value(sym, mod))
+                                       show_textbox(NULL, setmod_text, 6, 74);
+                       }
+                       break;
+               case 6:
+                       if (item_is_tag('t'))
+                               sym_set_tristate_value(sym, no);
+                       break;
+               case 7:
+                       if (item_is_tag('t'))
+                               sym_set_tristate_value(sym, mod);
+                       break;
+               case 8:
+                       if (item_is_tag('t'))
+                               sym_toggle_tristate_value(sym);
+                       else if (item_is_tag('m'))
+                               conf(submenu, NULL);
+                       break;
+               case 9:
+                       search_conf();
+                       break;
+               case 10:
+                       show_all_options = !show_all_options;
+                       break;
+               }
+       }
+
+       list_del(trail.prev);
+}
+
+static void conf_message_callback(const char *s)
+{
+       if (save_and_exit) {
+               if (!silent)
+                       printf("%s", s);
+       } else {
+               show_textbox(NULL, s, 6, 60);
+       }
+}
+
 static int handle_exit(void)
 {
        int res;