Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  * Introduced single menu mode (show all sub-menus in one large tree).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  * 2002-11-06 Petr Baudis <pasky@ucw.cz>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) #include <ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include <errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) #include <fcntl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include <limits.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) #include <stdarg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) #include <stdlib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) #include <string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #include <strings.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) #include <signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #include <unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #include "lkc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) #include "lxdialog/dialog.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) static const char mconf_readme[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) "Overview\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) "--------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) "This interface lets you select features and parameters for the build.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) "Features can either be built-in, modularized, or ignored. Parameters\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) "must be entered in as decimal or hexadecimal numbers or text.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) "Menu items beginning with following braces represent features that\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) "  [ ] can be built in or removed\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) "  < > can be built in, modularized or removed\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) "  { } can be built in or modularized (selected by other feature)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) "  - - are selected by other feature,\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) "while *, M or whitespace inside braces means to build in, build as\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) "a module or to exclude the feature respectively.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) "To change any of these features, highlight it with the cursor\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) "keys and press <Y> to build it in, <M> to make it a module or\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) "<N> to remove it.  You may also press the <Space Bar> to cycle\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) "through the available options (i.e. Y->N->M->Y).\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) "Some additional keyboard hints:\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) "Menus\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) "----------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) "o  Use the Up/Down arrow keys (cursor keys) to highlight the item you\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) "   wish to change or the submenu you wish to select and press <Enter>.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) "   Submenus are designated by \"--->\", empty ones by \"----\".\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) "   Shortcut: Press the option's highlighted letter (hotkey).\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) "             Pressing a hotkey more than once will sequence\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) "             through all visible items which use that hotkey.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) "   You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) "   unseen options into view.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) "o  To exit a menu use the cursor keys to highlight the <Exit> button\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) "   and press <ENTER>.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) "   Shortcut: Press <ESC><ESC> or <E> or <X> if there is no hotkey\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) "             using those letters.  You may press a single <ESC>, but\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) "             there is a delayed response which you may find annoying.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) "   Also, the <TAB> and cursor keys will cycle between <Select>,\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) "   <Exit>, <Help>, <Save>, and <Load>.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) "o  To get help with an item, use the cursor keys to highlight <Help>\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) "   and press <ENTER>.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) "   Shortcut: Press <H> or <?>.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) "o  To toggle the display of hidden options, press <Z>.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) "Radiolists  (Choice lists)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) "-----------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) "o  Use the cursor keys to select the option you wish to set and press\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) "   <S> or the <SPACE BAR>.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) "   Shortcut: Press the first letter of the option you wish to set then\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) "             press <S> or <SPACE BAR>.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) "o  To see available help for the item, use the cursor keys to highlight\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) "   <Help> and Press <ENTER>.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) "   Shortcut: Press <H> or <?>.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) "   Also, the <TAB> and cursor keys will cycle between <Select> and\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) "   <Help>\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) "Data Entry\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) "-----------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) "o  Enter the requested information and press <ENTER>\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) "   If you are entering hexadecimal values, it is not necessary to\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) "   add the '0x' prefix to the entry.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) "o  For help, use the <TAB> or cursor keys to highlight the help option\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) "   and press <ENTER>.  You can try <TAB><H> as well.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) "Text Box    (Help Window)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) "--------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) "o  Use the cursor keys to scroll up/down/left/right.  The VI editor\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) "   keys h,j,k,l function here as do <u>, <d>, <SPACE BAR> and <B> for\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) "   those who are familiar with less and lynx.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) "o  Press <E>, <X>, <q>, <Enter> or <Esc><Esc> to exit.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) "Alternate Configuration Files\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) "-----------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) "Menuconfig supports the use of alternate configuration files for\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) "those who, for various reasons, find it necessary to switch\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) "between different configurations.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) "The <Save> button will let you save the current configuration to\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) "a file of your choosing.  Use the <Load> button to load a previously\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) "saved alternate configuration.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) "Even if you don't use alternate configuration files, but you find\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) "during a Menuconfig session that you have completely messed up your\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) "settings, you may use the <Load> button to restore your previously\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) "saved settings from \".config\" without restarting Menuconfig.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) "Other information\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) "-----------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) "If you use Menuconfig in an XTERM window, make sure you have your\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) "$TERM variable set to point to an xterm definition which supports\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) "color.  Otherwise, Menuconfig will look rather bad.  Menuconfig will\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) "not display correctly in an RXVT window because rxvt displays only one\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) "intensity of color, bright.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) "Menuconfig will display larger menus on screens or xterms which are\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) "set to display more than the standard 25 row by 80 column geometry.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) "In order for this to work, the \"stty size\" command must be able to\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) "display the screen's current row and column geometry.  I STRONGLY\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) "RECOMMEND that you make sure you do NOT have the shell variables\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) "LINES and COLUMNS exported into your environment.  Some distributions\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) "export those variables via /etc/profile.  Some ncurses programs can\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) "become confused when those variables (LINES & COLUMNS) don't reflect\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) "the true screen size.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) "Optional personality available\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) "------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) "If you prefer to have all of the options listed in a single menu,\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) "rather than the default multimenu hierarchy, run the menuconfig with\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) "MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) "make MENUCONFIG_MODE=single_menu menuconfig\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) "<Enter> will then unroll the appropriate category, or enfold it if it\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) "is already unrolled.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) "Note that this mode can eventually be a little more CPU expensive\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) "(especially with a larger number of unrolled categories) than the\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) "default mode.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) "Different color themes available\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) "--------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) "It is possible to select different color themes using the variable\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) "MENUCONFIG_COLOR. To select a theme use:\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) "make MENUCONFIG_COLOR=<theme> menuconfig\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) "Available themes are\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) " mono       => selects colors suitable for monochrome displays\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) " blackbg    => selects a color scheme with black background\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) " classic    => theme with blue background. The classic look\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) " bluetitle  => an LCD friendly version of classic. (default)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) "\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) menu_instructions[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 	"Arrow keys navigate the menu.  "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 	"<Enter> selects submenus ---> (or empty submenus ----).  "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 	"Highlighted letters are hotkeys.  "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 	"Pressing <Y> includes, <N> excludes, <M> modularizes features.  "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 	"Press <Esc><Esc> to exit, <?> for Help, </> for Search.  "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 	"Legend: [*] built-in  [ ] excluded  <M> module  < > module capable",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) radiolist_instructions[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 	"Use the arrow keys to navigate this window or "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	"press the hotkey of the item you wish to select "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 	"followed by the <SPACE BAR>. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 	"Press <?> for additional information about this option.",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) inputbox_instructions_int[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 	"Please enter a decimal value. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	"Fractions will not be accepted.  "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 	"Use the <TAB> key to move from the input field to the buttons below it.",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) inputbox_instructions_hex[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 	"Please enter a hexadecimal value. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 	"Use the <TAB> key to move from the input field to the buttons below it.",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) inputbox_instructions_string[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 	"Please enter a string value. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 	"Use the <TAB> key to move from the input field to the buttons below it.",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) setmod_text[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 	"This feature depends on another which has been configured as a module.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 	"As a result, this feature will be built as a module.",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) load_config_text[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 	"Enter the name of the configuration file you wish to load.  "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 	"Accept the name shown to restore the configuration you "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 	"last retrieved.  Leave blank to abort.",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) load_config_help[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 	"\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 	"For various reasons, one may wish to keep several different\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 	"configurations available on a single machine.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 	"\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 	"If you have saved a previous configuration in a file other than the\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 	"default one, entering its name here will allow you to modify that\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 	"configuration.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 	"\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 	"If you are uncertain, then you have probably never used alternate\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	"configuration files. You should therefore leave this blank to abort.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) save_config_text[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	"Enter a filename to which this configuration should be saved "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	"as an alternate.  Leave blank to abort.",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) save_config_help[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 	"\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 	"For various reasons, one may wish to keep different configurations\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 	"available on a single machine.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 	"\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	"Entering a file name here will allow you to later retrieve, modify\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 	"and use the current configuration as an alternate to whatever\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	"configuration options you have selected at that time.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	"\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	"If you are uncertain what all this means then you should probably\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 	"leave this blank.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) search_help[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 	"\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 	"Search for symbols and display their relations.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 	"Regular expressions are allowed.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 	"Example: search for \"^FOO\"\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 	"Result:\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 	"-----------------------------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 	"Symbol: FOO [=m]\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 	"Type  : tristate\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 	"Prompt: Foo bus is used to drive the bar HW\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 	"  Location:\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 	"    -> Bus options (PCI, PCMCIA, EISA, ISA)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 	"      -> PCI support (PCI [=y])\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 	"(1)     -> PCI access mode (<choice> [=y])\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 	"  Defined at drivers/pci/Kconfig:47\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 	"  Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	"  Selects: LIBCRC32\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 	"  Selected by: BAR [=n]\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 	"-----------------------------------------------------------------\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 	"o The line 'Type:' shows the type of the configuration option for\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	"  this symbol (bool, tristate, string, ...)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	"o The line 'Prompt:' shows the text used in the menu structure for\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	"  this symbol\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	"o The 'Defined at' line tells at what file / line number the symbol\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	"  is defined\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	"o The 'Depends on:' line tells what symbols need to be defined for\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	"  this symbol to be visible in the menu (selectable)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 	"o The 'Location:' lines tells where in the menu structure this symbol\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 	"  is located\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 	"    A location followed by a [=y] indicates that this is a\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 	"    selectable menu item - and the current value is displayed inside\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 	"    brackets.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 	"    Press the key in the (#) prefix to jump directly to that\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 	"    location. You will be returned to the current search results\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 	"    after exiting this new menu.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 	"o The 'Selects:' line tells what symbols will be automatically\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 	"  selected if this symbol is selected (y or m)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 	"o The 'Selected by' line tells what symbol has selected this symbol\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	"\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 	"Only relevant lines are shown.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 	"\n\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 	"Search examples:\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 	"Examples: USB	=> find all symbols containing USB\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 	"          ^USB => find all symbols starting with USB\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 	"          USB$ => find all symbols ending with USB\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 	"\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) static int indent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) static struct menu *current_menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) static int child_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) static int single_menu_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) static int show_all_options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) static int save_and_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) static int silent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) static void conf(struct menu *menu, struct menu *active_menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) static void conf_choice(struct menu *menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) static void conf_string(struct menu *menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) static void conf_load(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) static void conf_save(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) static int show_textbox_ext(const char *title, char *text, int r, int c,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 			    int *keys, int *vscroll, int *hscroll,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 			    update_text_fn update_text, void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) static void show_textbox(const char *title, const char *text, int r, int c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) static void show_helptext(const char *title, const char *text);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) static void show_help(struct menu *menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) static char filename[PATH_MAX+1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) static void set_config_filename(const char *config_filename)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 	static char menu_backtitle[PATH_MAX+128];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 	int size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 	size = snprintf(menu_backtitle, sizeof(menu_backtitle),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 			"%s - %s", config_filename, rootmenu.prompt->text);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 	if (size >= sizeof(menu_backtitle))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 		menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 	set_dialog_backtitle(menu_backtitle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 	size = snprintf(filename, sizeof(filename), "%s", config_filename);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	if (size >= sizeof(filename))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 		filename[sizeof(filename)-1] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) struct subtitle_part {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	struct list_head entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	const char *text;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) static LIST_HEAD(trail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) static struct subtitle_list *subtitles;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) static void set_subtitle(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 	struct subtitle_part *sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 	struct subtitle_list *pos, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 	for (pos = subtitles; pos != NULL; pos = tmp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 		tmp = pos->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 		free(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 	subtitles = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 	list_for_each_entry(sp, &trail, entries) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 		if (sp->text) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 			if (pos) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 				pos->next = xcalloc(1, sizeof(*pos));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 				pos = pos->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 				subtitles = pos = xcalloc(1, sizeof(*pos));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 			pos->text = sp->text;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	set_dialog_subtitles(subtitles);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) static void reset_subtitle(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	struct subtitle_list *pos, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 	for (pos = subtitles; pos != NULL; pos = tmp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 		tmp = pos->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 		free(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 	subtitles = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 	set_dialog_subtitles(subtitles);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) struct search_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 	struct list_head *head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 	struct menu **targets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 	int *keys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) static void update_text(char *buf, size_t start, size_t end, void *_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 	struct search_data *data = _data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 	struct jump_key *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 	int k = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 	list_for_each_entry(pos, data->head, entries) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 		if (pos->offset >= start && pos->offset < end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 			char header[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 			if (k < JUMP_NB) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 				int key = '0' + (pos->index % JUMP_NB) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 				sprintf(header, "(%c)", key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 				data->keys[k] = key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 				data->targets[k] = pos->target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 				k++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 				sprintf(header, "   ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 			memcpy(buf + pos->offset, header, sizeof(header) - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 	data->keys[k] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) static void search_conf(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 	struct symbol **sym_arr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 	struct gstr res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 	struct gstr title;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 	char *dialog_input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 	int dres, vscroll = 0, hscroll = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 	bool again;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 	struct gstr sttext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 	struct subtitle_part stpart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 	title = str_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 	str_printf( &title, "Enter (sub)string or regexp to search for "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 			      "(with or without \"%s\")", CONFIG_);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) again:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 	dialog_clear();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 	dres = dialog_inputbox("Search Configuration Parameter",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 			      str_get(&title),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 			      10, 75, "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 	switch (dres) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 		show_helptext("Search Configuration", search_help);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 		goto again;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 		str_free(&title);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 	/* strip the prefix if necessary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 	dialog_input = dialog_input_result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 	if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 		dialog_input += strlen(CONFIG_);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 	sttext = str_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 	str_printf(&sttext, "Search (%s)", dialog_input_result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 	stpart.text = str_get(&sttext);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 	list_add_tail(&stpart.entries, &trail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 	sym_arr = sym_re_search(dialog_input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 		LIST_HEAD(head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 		struct menu *targets[JUMP_NB];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 		int keys[JUMP_NB + 1], i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 		struct search_data data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 			.head = &head,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 			.targets = targets,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 			.keys = keys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 		};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 		struct jump_key *pos, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 		res = get_relations_str(sym_arr, &head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 		set_subtitle();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 		dres = show_textbox_ext("Search Results", (char *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 					str_get(&res), 0, 0, keys, &vscroll,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 					&hscroll, &update_text, (void *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 					&data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 		again = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 		for (i = 0; i < JUMP_NB && keys[i]; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 			if (dres == keys[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 				conf(targets[i]->parent, targets[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 				again = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 		str_free(&res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 		list_for_each_entry_safe(pos, tmp, &head, entries)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 			free(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 	} while (again);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 	free(sym_arr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 	str_free(&title);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	list_del(trail.prev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	str_free(&sttext);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) static void build_conf(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 	struct symbol *sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 	struct property *prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	struct menu *child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 	int type, tmp, doint = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 	tristate val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 	char ch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 	bool visible;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	 * note: menu_is_visible() has side effect that it will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 	 * recalc the value of the symbol.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 	visible = menu_is_visible(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 	if (show_all_options && !menu_has_prompt(menu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 	else if (!show_all_options && !visible)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 	sym = menu->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	prop = menu->prompt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 	if (!sym) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 		if (prop && menu != current_menu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 			const char *prompt = menu_get_prompt(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 			switch (prop->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 			case P_MENU:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 				child_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 				if (single_menu_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 					item_make("%s%*c%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 						  menu->data ? "-->" : "++>",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 						  indent + 1, ' ', prompt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 				} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 					item_make("   %*c%s  %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 						  indent + 1, ' ', prompt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 						  menu_is_empty(menu) ? "----" : "--->");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 				item_set_tag('m');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 				item_set_data(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 				if (single_menu_mode && menu->data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 					goto conf_childs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 			case P_COMMENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 				if (prompt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 					child_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 					item_make("   %*c*** %s ***", indent + 1, ' ', prompt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 					item_set_tag(':');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 					item_set_data(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 				if (prompt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 					child_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 					item_make("---%*c%s", indent + 1, ' ', prompt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 					item_set_tag(':');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 					item_set_data(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 		} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 			doint = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 		goto conf_childs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 	type = sym_get_type(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 	if (sym_is_choice(sym)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 		struct symbol *def_sym = sym_get_choice_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 		struct menu *def_menu = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 		child_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 		for (child = menu->list; child; child = child->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 			if (menu_is_visible(child) && child->sym == def_sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 				def_menu = child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 		val = sym_get_tristate_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 		if (sym_is_changeable(sym)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 			switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 			case S_BOOLEAN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 				item_make("[%c]", val == no ? ' ' : '*');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 			case S_TRISTATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 				switch (val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 				case yes: ch = '*'; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 				case mod: ch = 'M'; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 				default:  ch = ' '; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 				item_make("<%c>", ch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 			item_set_tag('t');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 			item_set_data(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 			item_make("   ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 			item_set_tag(def_menu ? 't' : ':');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 			item_set_data(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 		item_add_str("%*c%s", indent + 1, ' ', menu_get_prompt(menu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 		if (val == yes) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 			if (def_menu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 				item_add_str(" (%s)", menu_get_prompt(def_menu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 				item_add_str("  --->");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 				if (def_menu->list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 					indent += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 					build_conf(def_menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 					indent -= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 		if (menu == current_menu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 			item_make("---%*c%s", indent + 1, ' ', menu_get_prompt(menu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 			item_set_tag(':');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 			item_set_data(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 			goto conf_childs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 		child_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 		val = sym_get_tristate_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 		if (sym_is_choice_value(sym) && val == yes) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 			item_make("   ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 			item_set_tag(':');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 			item_set_data(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 			switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 			case S_BOOLEAN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 				if (sym_is_changeable(sym))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 					item_make("[%c]", val == no ? ' ' : '*');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 				else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 					item_make("-%c-", val == no ? ' ' : '*');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 				item_set_tag('t');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 				item_set_data(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 			case S_TRISTATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 				switch (val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 				case yes: ch = '*'; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 				case mod: ch = 'M'; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 				default:  ch = ' '; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 				if (sym_is_changeable(sym)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 					if (sym->rev_dep.tri == mod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 						item_make("{%c}", ch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 					else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 						item_make("<%c>", ch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 				} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 					item_make("-%c-", ch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 				item_set_tag('t');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 				item_set_data(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 				tmp = 2 + strlen(sym_get_string_value(sym)); /* () = 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 				item_make("(%s)", sym_get_string_value(sym));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 				tmp = indent - tmp + 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 				if (tmp < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 					tmp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 				item_add_str("%*c%s%s", tmp, ' ', menu_get_prompt(menu),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 					     (sym_has_value(sym) || !sym_is_changeable(sym)) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 					     "" : " (NEW)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 				item_set_tag('s');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 				item_set_data(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 				goto conf_childs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 		item_add_str("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 			  (sym_has_value(sym) || !sym_is_changeable(sym)) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 			  "" : " (NEW)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 		if (menu->prompt->type == P_MENU) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 			item_add_str("  %s", menu_is_empty(menu) ? "----" : "--->");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) conf_childs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 	indent += doint;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 	for (child = menu->list; child; child = child->next)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 		build_conf(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 	indent -= doint;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) static void conf(struct menu *menu, struct menu *active_menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 	struct menu *submenu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 	const char *prompt = menu_get_prompt(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 	struct subtitle_part stpart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 	struct symbol *sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 	int res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	int s_scroll = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	if (menu != &rootmenu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 		stpart.text = menu_get_prompt(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 		stpart.text = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 	list_add_tail(&stpart.entries, &trail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 		item_reset();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 		current_menu = menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 		build_conf(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 		if (!child_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 		set_subtitle();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 		dialog_clear();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 		res = dialog_menu(prompt ? prompt : "Main Menu",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 				  menu_instructions,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 				  active_menu, &s_scroll);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 		if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 		if (item_count() != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 			if (!item_activate_selected())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 			if (!item_tag())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 		submenu = item_data();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 		active_menu = item_data();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 		if (submenu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 			sym = submenu->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 			sym = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 		switch (res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 		case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 			switch (item_tag()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 			case 'm':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 				if (single_menu_mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 					submenu->data = (void *) (long) !submenu->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 				else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 					conf(submenu, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 			case 't':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 				if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 					conf_choice(submenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 				else if (submenu->prompt->type == P_MENU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 					conf(submenu, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 			case 's':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 				conf_string(submenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 		case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 			if (sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 				show_help(submenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 			else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 				reset_subtitle();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 				show_helptext("README", mconf_readme);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 		case 3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 			reset_subtitle();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 			conf_save();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 		case 4:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 			reset_subtitle();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 			conf_load();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 		case 5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 			if (item_is_tag('t')) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 				if (sym_set_tristate_value(sym, yes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 					break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 				if (sym_set_tristate_value(sym, mod))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 					show_textbox(NULL, setmod_text, 6, 74);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 		case 6:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 			if (item_is_tag('t'))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 				sym_set_tristate_value(sym, no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 		case 7:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 			if (item_is_tag('t'))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 				sym_set_tristate_value(sym, mod);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 		case 8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 			if (item_is_tag('t'))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 				sym_toggle_tristate_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 			else if (item_is_tag('m'))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 				conf(submenu, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 		case 9:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 			search_conf();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 		case 10:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 			show_all_options = !show_all_options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 	list_del(trail.prev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) static int show_textbox_ext(const char *title, char *text, int r, int c, int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 			    *keys, int *vscroll, int *hscroll, update_text_fn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 			    update_text, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 	dialog_clear();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 	return dialog_textbox(title, text, r, c, keys, vscroll, hscroll,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 			      update_text, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) static void show_textbox(const char *title, const char *text, int r, int c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 	show_textbox_ext(title, (char *) text, r, c, (int []) {0}, NULL, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 			 NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) static void show_helptext(const char *title, const char *text)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 	show_textbox(title, text, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) static void conf_message_callback(const char *s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 	if (save_and_exit) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 		if (!silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 			printf("%s", s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 		show_textbox(NULL, s, 6, 60);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) static void show_help(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	struct gstr help = str_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 	help.max_width = getmaxx(stdscr) - 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 	menu_get_ext_help(menu, &help);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 	show_helptext(menu_get_prompt(menu), str_get(&help));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	str_free(&help);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) static void conf_choice(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 	const char *prompt = menu_get_prompt(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 	struct menu *child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	struct symbol *active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 	active = sym_get_choice_value(menu->sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 	while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 		int res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 		int selected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 		item_reset();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 		current_menu = menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 		for (child = menu->list; child; child = child->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 			if (!menu_is_visible(child))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 			if (child->sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 				item_make("%s", menu_get_prompt(child));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 			else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 				item_make("*** %s ***", menu_get_prompt(child));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 				item_set_tag(':');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 			item_set_data(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 			if (child->sym == active)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 				item_set_selected(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 			if (child->sym == sym_get_choice_value(menu->sym))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 				item_set_tag('X');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 		dialog_clear();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 		res = dialog_checklist(prompt ? prompt : "Main Menu",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 					radiolist_instructions,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 					MENUBOX_HEIGTH_MIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 					MENUBOX_WIDTH_MIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 					CHECKLIST_HEIGTH_MIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 		selected = item_activate_selected();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 		switch (res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 		case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 			if (selected) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 				child = item_data();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 				if (!child->sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 					break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 				sym_set_tristate_value(child->sym, yes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 		case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 			if (selected) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 				child = item_data();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 				show_help(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 				active = child->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 			} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 				show_help(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 		case KEY_ESC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 		case -ERRDISPLAYTOOSMALL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) static void conf_string(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 	const char *prompt = menu_get_prompt(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 	while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 		int res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 		const char *heading;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 		switch (sym_get_type(menu->sym)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 		case S_INT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 			heading = inputbox_instructions_int;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 		case S_HEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 			heading = inputbox_instructions_hex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 		case S_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 			heading = inputbox_instructions_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 			heading = "Internal mconf error!";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 		dialog_clear();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 		res = dialog_inputbox(prompt ? prompt : "Main Menu",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 				      heading, 10, 75,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 				      sym_get_string_value(menu->sym));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 		switch (res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 		case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 			if (sym_set_string_value(menu->sym, dialog_input_result))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 			show_textbox(NULL, "You have made an invalid entry.", 5, 43);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 		case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 			show_help(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 		case KEY_ESC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) static void conf_load(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 	while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 		int res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 		dialog_clear();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 		res = dialog_inputbox(NULL, load_config_text,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 				      11, 55, filename);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 		switch(res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 		case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 			if (!dialog_input_result[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 			if (!conf_read(dialog_input_result)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 				set_config_filename(dialog_input_result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 				sym_set_change_count(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 			show_textbox(NULL, "File does not exist!", 5, 38);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 		case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 			show_helptext("Load Alternate Configuration", load_config_help);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 		case KEY_ESC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) static void conf_save(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 	while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 		int res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 		dialog_clear();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 		res = dialog_inputbox(NULL, save_config_text,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 				      11, 55, filename);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 		switch(res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 		case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 			if (!dialog_input_result[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 			if (!conf_write(dialog_input_result)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 				set_config_filename(dialog_input_result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 			show_textbox(NULL, "Can't create file!", 5, 60);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 		case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 			show_helptext("Save Alternate Configuration", save_config_help);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 		case KEY_ESC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) static int handle_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 	int res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 	save_and_exit = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 	reset_subtitle();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 	dialog_clear();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 	if (conf_get_changed())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 		res = dialog_yesno(NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 				   "Do you wish to save your new configuration?\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 				     "(Press <ESC><ESC> to continue kernel configuration.)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 				   6, 60);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 		res = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 	end_dialog(saved_x, saved_y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	switch (res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 		if (conf_write(filename)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 			fprintf(stderr, "\n\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 					  "Error while writing of the configuration.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 					  "Your configuration changes were NOT saved."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 					  "\n\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 			return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 		conf_write_autoconf(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 		/* fall through */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 	case -1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 		if (!silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 			printf("\n\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 				 "*** End of the configuration.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 				 "*** Execute 'make' to start the build or try 'make help'."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 				 "\n\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 		res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 		if (!silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 			fprintf(stderr, "\n\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 					  "Your configuration changes were NOT saved."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 					  "\n\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 		if (res != KEY_ESC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 			res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) static void sig_handler(int signo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 	exit(handle_exit());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) int main(int ac, char **av)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 	char *mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 	int res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 	signal(SIGINT, sig_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 	if (ac > 1 && strcmp(av[1], "-s") == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 		silent = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 		/* Silence conf_read() until the real callback is set up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 		conf_set_message_callback(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 		av++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 	conf_parse(av[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 	conf_read(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 	mode = getenv("MENUCONFIG_MODE");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 	if (mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 		if (!strcasecmp(mode, "single_menu"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 			single_menu_mode = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 	if (init_dialog(NULL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 		fprintf(stderr, "Your display is too small to run Menuconfig!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 		fprintf(stderr, "It must be at least 19 lines by 80 columns.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 	set_config_filename(conf_get_configname());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 	conf_set_message_callback(conf_message_callback);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 		conf(&rootmenu, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 		res = handle_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 	} while (res == KEY_ESC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) }