Home | History | Annotate | Line # | Download | only in sysinst
menus.mi revision 1.9
      1 /*	$NetBSD: menus.mi,v 1.9 2015/05/10 10:14:02 martin Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2003 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by David Laight.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 /*
     33  * Menu system definitions -- machine and language independent
     34  *
     35  * Some menus may be called directly in the code rather than via the
     36  * menu system.
     37  *
     38  *  This file must be first in the sed command line.
     39  *
     40  */
     41 
     42 {
     43 #include <stdio.h>
     44 #include <time.h>
     45 #include <curses.h>
     46 #include "defs.h"
     47 #include "md.h"
     48 #include "msg_defs.h"
     49 #include "menu_defs.h"
     50 
     51 static menudesc menu_def[];
     52 
     53 static void
     54 src_legend(menudesc *menu, const char *legend, const char *text)
     55 {
     56         wprintw(menu->mw, "%-25s %.50s", MSG_XLAT(legend), MSG_XLAT(text));
     57 }
     58 
     59 static void
     60 src_prompt(const char *prompt, char *buf, size_t size)
     61 {
     62 	msg_prompt_win(prompt, -1, 12, 0, 0, buf, buf, size);
     63 }
     64 
     65 static void
     66 remove_sub_menu(int menuID)
     67 {
     68 
     69 	for (size_t i = 0; i < DYN_MENU_START; i++) {
     70 		for (int j = 0; j < menu_def[i].numopts; j++) {
     71 			if ((menu_def[i].opts[j].opt_flags & OPT_SUB)
     72 			    && menu_def[i].opts[j].opt_menu == menuID) {
     73 
     74 				for (int k = j + 1; k < menu_def[i].numopts;
     75 				    k++) {
     76 					menu_def[i].opts[k-1] =
     77 					    menu_def[i].opts[k];
     78 				}
     79 				menu_def[i].numopts--;
     80 				return;
     81 
     82 			}
     83 		}
     84 	}
     85 }
     86 
     87 static void
     88 remove_menu_option(int menuID, const char *option)
     89 {
     90 
     91 	for (int j = 0; j < menu_def[menuID].numopts; j++) {
     92 		if (menu_def[menuID].opts[j].opt_name == option) {
     93 			for (int k = j + 1; k < menu_def[menuID].numopts;
     94 			    k++) {
     95 				menu_def[menuID].opts[k-1] =
     96 				    menu_def[menuID].opts[k];
     97 			}
     98 			menu_def[menuID].numopts--;
     99 			return;
    100 
    101 		}
    102 	}
    103 }
    104 
    105 void
    106 remove_color_options()
    107 {
    108 	/*
    109 	 * Current terminal type does not support colors, so remove all
    110 	 * menu entries (actually that is: Utils/Color Scheme) that do not
    111 	 * make any sense in this case.
    112 	 */
    113 	remove_sub_menu(MENU_colors);
    114 }
    115 
    116 void
    117 remove_raid_options()
    118 {
    119 	/*
    120 	 * No raidframe available, remove the following menu entries:
    121 	 */
    122 	remove_menu_option(MENU_pmdiskentry, MSG_fmtasraid);
    123 	remove_menu_option(MENU_pmpartentry, MSG_fmtasraid);
    124 }
    125 
    126 void
    127 remove_lvm_options()
    128 {
    129 	/*
    130 	 * No LVM available, remove the following menu entries:
    131 	 */
    132 	remove_menu_option(MENU_pmdiskentry, MSG_fmtaslvm);
    133 	remove_menu_option(MENU_pmpartentry, MSG_fmtaslvm);
    134 }
    135 
    136 void
    137 remove_gpt_options()
    138 {
    139 	/*
    140 	 * No GPT available, remove the following menu entries:
    141 	 */
    142 	remove_menu_option(MENU_pmdiskentry, MSG_switchgpt);
    143 	remove_menu_option(MENU_pmpartentry, MSG_switchgpt);
    144 }
    145 
    146 void
    147 remove_cgd_options()
    148 {
    149 	/*
    150 	 * No CGD available, remove the following menu entries:
    151 	 */
    152 	remove_menu_option(MENU_pmdiskentry, MSG_encrypt);
    153 	remove_menu_option(MENU_pmpartentry, MSG_encrypt);
    154 }
    155 
    156 }
    157 
    158 default y=12, no exit, scrollable;
    159 
    160 allow dynamic menus;
    161 allow dynamic messages;
    162 error action {
    163 	fprintf (stderr, "Could not initialize menu system, please check "
    164 	    "your terminal type.\n");
    165 	exit(4);
    166 };
    167 
    168 menu selfskind, title MSG_Select_the_type, exitstring MSG_unchanged, y=6, x=30;
    169 	display action {
    170 		partinfo *p = arg;
    171 		switch (p->pi_fstype) {
    172 		case FS_UNUSED:	menu->cursel = 0; break;
    173 		case FS_BSDFFS:
    174 		    menu->cursel = p->pi_flags & PIF_FFSv2 ? 2 : 1;
    175 		    break;
    176 		case FS_SWAP:	menu->cursel = 3; break;
    177 		case FS_MSDOS:	menu->cursel = 4; break;
    178 		case FS_BSDLFS:	menu->cursel = 5; break;
    179 		default	:	menu->cursel = 6; break;
    180 		};
    181 	};
    182 	option "unused", exit, action
    183 	    { memset(arg, 0, sizeof (partinfo)); };
    184 	option "FFSv1", exit, action { set_ptype(arg, FS_BSDFFS, 0); };
    185 	option "FFSv2", exit, action { set_ptype(arg, FS_BSDFFS, PIF_FFSv2); };
    186 	option "swap",  exit, action { set_ptype(arg, FS_SWAP, 0); };
    187 	option "msdos", exit, action { set_ptype(arg, FS_MSDOS, 0); };
    188 	option "LFS",   exit, action { set_ptype(arg, FS_BSDLFS, 0); };
    189 	option MSG_other_types, action
    190 	    { extern int all_fstype_menu;
    191 	      m->opts[m->cursel].opt_menu = all_fstype_menu; };
    192 
    193 menu selbsize, title MSG_Select_file_system_block_size, y=10, x=40;
    194 	display action {
    195 		partinfo *pi = arg;
    196 		int b;
    197 		b = ffs(pi->pi_fsize * pi->pi_frag / 4096) - 1;
    198 		if (b < 0 || b >= menu->numopts)
    199 			b = 1;
    200 		menu->cursel = b;
    201 	};
    202 	option  "4096", exit, action { set_bsize(arg, 4096); };
    203 	option  "8192", exit, action { set_bsize(arg, 8192); };
    204 	option "16384", exit, action { set_bsize(arg, 16384); };
    205 	option "32768", exit, action { set_bsize(arg, 32768); };
    206 
    207 menu selfsize, title MSG_Select_file_system_fragment_size, y=11, x=40;
    208 	display action {
    209 		partinfo *pi = arg;
    210 		int b;
    211 		b = ffs(pi->pi_fsize / 512) - 1;
    212 		if (b < 0 || b >= menu->numopts)
    213 			b = 1;
    214 		menu->cursel = b;
    215 	};
    216 	option   "512", exit, action { set_fsize(arg, 512); };
    217 	option  "1024", exit, action { set_fsize(arg, 1024); };
    218 	option  "2048", exit, action { set_fsize(arg, 2048); };
    219 	option  "4096", exit, action { set_fsize(arg, 4096); };
    220 	option  "8192", exit, action { set_fsize(arg, 8192); };
    221 	option "16384", exit, action { set_fsize(arg, 16384); };
    222 	option "32768", exit, action { set_fsize(arg, 32768); };
    223 
    224 menu mountoptions, title MSG_toggle, y=5, x=30, exitstring MSG_unchanged;
    225 	display action {
    226 		static int actual_numopt;
    227 		if (!actual_numopt)
    228 			actual_numopt = menu->numopts;
    229 		menu->numopts = actual_numopt -
    230 			(((partinfo *)arg)->pi_fstype !=  FS_BSDFFS);
    231 	};
    232 	option "log", exit, action
    233 		{ ((partinfo *)arg)->pi_flags ^= PIF_LOG; };
    234 	option "async", exit, action
    235 		{ ((partinfo *)arg)->pi_flags ^= PIF_ASYNC; };
    236 	option "noatime", exit, action
    237 		{ ((partinfo *)arg)->pi_flags ^= PIF_NOATIME; };
    238 	option "nodev", exit, action
    239 		{ ((partinfo *)arg)->pi_flags ^= PIF_NODEV; };
    240 	option "nodevmtime", exit, action
    241 		{ ((partinfo *)arg)->pi_flags ^= PIF_NODEVMTIME; };
    242 	option "noexec", exit, action
    243 		{ ((partinfo *)arg)->pi_flags ^= PIF_NOEXEC; };
    244 	option "nosuid", exit, action
    245 		{ ((partinfo *)arg)->pi_flags ^= PIF_NOSUID; };
    246 
    247 menu netbsd, title MSG_NetBSD_VERSION_Install_System, y=-1,
    248     exit, exitstring MSG_Exit_Install_System;
    249 	display action  { toplevel(); };
    250 	option MSG_Install_NetBSD_to_hard_disk,
    251 		action { do_install(); };
    252 	option MSG_Upgrade_NetBSD_on_a_hard_disk,
    253 		action { do_upgrade(); };
    254 	option MSG_Re_install_sets_or_install_additional_sets,
    255 		action { do_reinstall_sets(); };
    256 	option MSG_Reboot_the_computer, exit,
    257 		action (endwin) { system("/sbin/reboot -q"); };
    258 	option MSG_Utility_menu, sub menu utility;
    259 	option MSG_Config_menu, action { do_configmenu(); };
    260 
    261 menu utility, title MSG_NetBSD_VERSION_Utilities, exit,
    262 		exitstring MSG_exit_menu_generic;
    263 	display action  { toplevel(); };
    264 	option MSG_Run_bin_sh,
    265 		action (endwin) { system("/bin/sh"); };
    266 	option MSG_Set_timezone,
    267 		action { set_timezone(); };
    268 	option MSG_Configure_network,
    269 		action {
    270 			extern int network_up;
    271 			network_up = 0;
    272 			config_network();
    273 		};
    274 	option MSG_Partition_a_disk, action { partman_go = 1; partman(); };
    275 	option MSG_Logging_functions, action { do_logging(); };
    276 	option MSG_Color_scheme, sub menu colors;
    277 	option MSG_Halt_the_system, exit,
    278 		action (endwin) { system("/sbin/halt -q"); };
    279 
    280 menu colors, title MSG_Color_scheme, exit,
    281 		exitstring MSG_exit_menu_generic;
    282 	option MSG_White_on_black, action { do_coloring(COLOR_WHITE,COLOR_BLACK); };
    283 	option MSG_Black_on_white, action { do_coloring(COLOR_BLACK,COLOR_WHITE); };
    284 	option MSG_White_on_blue,  action { do_coloring(COLOR_WHITE,COLOR_BLUE); };
    285 	option MSG_Green_on_black, action { do_coloring(COLOR_GREEN,COLOR_BLACK); };
    286 
    287 
    288 menu yesno, y=-10;
    289 	display action { arg_rv *p = arg;
    290 		menu->title = p->arg ? p->arg : MSG_yes_or_no; };
    291 	option MSG_Yes, exit, action  { ((arg_rv*)arg)->rv = 1; };
    292 	option MSG_No,  exit, action  { ((arg_rv*)arg)->rv = 0; };
    293 
    294 menu noyes, y=-10;
    295 	display action { arg_rv *p = arg;
    296 		menu->title = p->arg ? p->arg : MSG_yes_or_no; };
    297 	option MSG_No,  exit, action  { ((arg_rv*)arg)->rv = 0; };
    298 	option MSG_Yes, exit, action  { ((arg_rv*)arg)->rv = 1; };
    299 
    300 menu ok, no shortcut, y=-10;
    301 	display action { menu->title = arg; };
    302 	option MSG_Hit_enter_to_continue, exit;
    303 
    304 menu layout, sub menu, y=-1, title  MSG_Choose_your_installation;
    305 	option MSG_Set_Sizes, 	  exit, action { layoutkind = LY_SETNEW; };
    306 	option MSG_Use_Existing,  exit, action { layoutkind = LY_USEEXIST; };
    307 
    308 menu sizechoice, sub menu, y=0, title MSG_Choose_your_size_specifier;
    309 	display action {
    310 		if (sizemult == pm->current_cylsize)
    311 			menu->cursel = 1;
    312 		else if (sizemult == 1)
    313 			menu->cursel = 2;
    314 		};
    315 	option MSG_Megabytes, exit, action
    316 		{ sizemult = MEG / pm->sectorsize;
    317 		  multname = msg_string(MSG_megname);
    318 		};
    319 	option MSG_Cylinders, exit, action
    320 		{ sizemult = pm->current_cylsize;
    321 		  multname = msg_string(MSG_cylname);
    322 		};
    323 	option MSG_Sectors, exit, action
    324 		{ sizemult = 1;
    325 		  multname = msg_string(MSG_secname);
    326 		};
    327 
    328 menu distmedium, title MSG_Select_medium, y=-5;
    329 	option MSG_cdrom,     exit, action { *(int *)arg = get_via_cdrom(); };
    330 	option MSG_ftp,	      exit, action { *(int *)arg = get_via_ftp("ftp"); };
    331 	option MSG_http,      exit, action { *(int *)arg = get_via_ftp("http"); };
    332 	option MSG_nfs,	      exit, action { *(int *)arg = get_via_nfs(); };
    333 	option MSG_floppy,    exit, action { *(int *)arg = get_via_floppy(); };
    334 	option MSG_local_fs,  exit, action { *(int *)arg = get_via_localfs(); };
    335 	option MSG_local_dir, exit, action { *(int *)arg = get_via_localdir();};
    336 	option MSG_Skip_set,  exit, action { *(int *)arg = SET_SKIP; };
    337 	option MSG_Skip_group,exit, action { *(int *)arg = SET_SKIP_GROUP; };
    338 	option MSG_Abandon,   exit, action { *(int *)arg = SET_ABANDON; };
    339 
    340 menu distset, title MSG_Select_your_distribution, exit,
    341 	    no default exit, exitstring MSG_Abandon;
    342 	display action { msg_display (MSG_distset); };
    343 	option MSG_Full_installation, exit, action { *(int *)arg = 1; init_set_status(0);  };
    344 	option MSG_Full_installation_nox, exit, action { *(int *)arg = 1; init_set_status(SFLAG_NOX); };
    345 	option MSG_Minimal_installation, exit, action { *(int *)arg = 1; init_set_status(SFLAG_MINIMAL); };
    346 	option MSG_Custom_installation, exit, action { *(int *)arg = 1; init_set_status(SFLAG_MINIMAL); customise_sets(); };
    347 
    348 menu ftpsource, y=-4, x=0, w=70, no box, no clear,
    349 	    exitstring MSG_Get_Distribution;
    350 	display action { msg_display(MSG_ftpsource, ((arg_rv*)arg)->arg); };
    351 	option {src_legend(menu, MSG_Host, ftp.host);},
    352 		action { src_prompt(MSG_Host, ftp.host, sizeof ftp.host); };
    353 	option {src_legend(menu, MSG_Base_dir, ftp.dir);},
    354 		action { src_prompt(MSG_Base_dir, ftp.dir, sizeof ftp.dir); };
    355 	option {src_legend(menu, MSG_Set_dir_bin, set_dir_bin);},
    356 		action { src_prompt(MSG_Set_dir_bin, set_dir_bin, sizeof set_dir_bin); };
    357 	option {src_legend(menu, MSG_Set_dir_src, set_dir_src);},
    358 		action { src_prompt(MSG_Set_dir_src, set_dir_src, sizeof set_dir_src); };
    359 	option {src_legend(menu, MSG_User, ftp.user);},
    360 		action { src_prompt(MSG_User, ftp.user, sizeof ftp.user);
    361 			ftp.pass[0] = 0;
    362 		};
    363 	option {src_legend(menu, MSG_Password,
    364 		    strcmp(ftp.user, "ftp") == 0 || ftp.pass[0] == 0
    365 			? ftp.pass : msg_string(MSG_hidden));},
    366 		action { if (strcmp(ftp.user, "ftp") == 0)
    367 			src_prompt(MSG_email, ftp.pass, sizeof ftp.pass);
    368 		  else {
    369 			msg_prompt_noecho(MSG_Password, "",
    370 					ftp.pass, sizeof ftp.pass);
    371 		  }
    372 		};
    373 	option {src_legend(menu, MSG_Proxy, ftp.proxy);},
    374 		action { src_prompt(MSG_Proxy, ftp.proxy, sizeof ftp.proxy);
    375 		  if (strcmp(ftp.proxy, "") == 0) {
    376 			unsetenv("ftp_proxy");
    377 			unsetenv("http_proxy");
    378 		  } else {
    379 			setenv("ftp_proxy", ftp.proxy, 1);
    380 			setenv("http_proxy", ftp.proxy, 1);
    381 		  }
    382 		};
    383 	option {src_legend(menu, MSG_Xfer_dir, xfer_dir);},
    384 		action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
    385 	option {src_legend(menu, MSG_delete_xfer_file,
    386 			clean_xfer_dir ? MSG_Yes : MSG_No);},
    387 		action {clean_xfer_dir = ask_yesno(deconst(MSG_delete_xfer_file)); };
    388 	option MSG_Configure_network,
    389 		action {
    390 			extern int network_up;
    391 			network_up = 0;
    392 			config_network();
    393 		};
    394 	option MSG_exit_menu_generic, exit, action { ((arg_rv*)arg)->rv = SET_RETRY; };
    395 
    396 
    397 menu nfssource, y=-4, x=0, w=70, no box, no clear,
    398 	    exitstring MSG_Get_Distribution;
    399 	display action { msg_display(MSG_nfssource); };
    400 	option {src_legend(menu, MSG_Host, nfs_host);},
    401 		action { src_prompt(MSG_Host, nfs_host, sizeof nfs_host); };
    402 	option {src_legend(menu, MSG_Base_dir, nfs_dir);},
    403 		action { src_prompt(MSG_Base_dir, nfs_dir, sizeof nfs_dir); };
    404 	option {src_legend(menu, MSG_Set_dir_bin, set_dir_bin);},
    405 		action { src_prompt(MSG_Set_dir_bin, set_dir_bin, sizeof set_dir_bin); };
    406 	option {src_legend(menu, MSG_Set_dir_src, set_dir_src);},
    407 		action { src_prompt(MSG_Set_dir_src, set_dir_src, sizeof set_dir_src); };
    408 	option MSG_Configure_network,
    409 		action {
    410 			extern int network_up;
    411 			network_up = 0;
    412 			config_network();
    413 		};
    414 	option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };
    415 
    416 menu fdremount, title MSG_What_do_you_want_to_do;
    417 	option MSG_Try_again, exit, action { *(int *)arg = SET_CONTINUE; };
    418 	option MSG_Set_finished, exit, action { *(int *)arg = SET_OK; };
    419 	option MSG_Abort_fetch, exit, action { *(int *)arg = SET_RETRY; };
    420 
    421 menu fdok, title MSG_What_do_you_want_to_do;
    422 	option MSG_OK, exit, action { *(int *)arg = SET_CONTINUE; };
    423 	option MSG_Set_finished, exit, action { *(int *)arg = SET_OK; };
    424 	option MSG_Abort_fetch, exit, action { *(int *)arg = SET_RETRY; };
    425 
    426 menu fd_type, title MSG_fd_type, y=16;
    427 	option "msdos", exit, action { fd_type = "msdos"; };
    428 	option "ffs",   exit, action { fd_type = "ffs"; };
    429 .if ADOS_FLOPPY
    430 	option "ados",  exit, action { fd_type = "ados"; };
    431 .endif
    432 
    433 menu floppysource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
    434 	display action { msg_display(MSG_floppysource); };
    435 	option {src_legend(menu, MSG_Device, fd_dev);},
    436 		action { src_prompt(MSG_dev, fd_dev, sizeof fd_dev); };
    437 	option {src_legend(menu, MSG_fd_type, fd_type);}, sub menu fd_type;
    438 	option {src_legend(menu, MSG_Xfer_dir, xfer_dir);},
    439 		action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
    440 	option {src_legend(menu, MSG_delete_xfer_file,
    441 			clean_xfer_dir ? MSG_Yes : MSG_No);},
    442 		action {clean_xfer_dir = ask_yesno(deconst(MSG_delete_xfer_file)); };
    443 	option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };
    444 
    445 menu cdromsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
    446 	display action { msg_display(MSG_cdromsource); };
    447 	option {src_legend(menu, MSG_Device, cdrom_dev);},
    448 		action { src_prompt(MSG_dev, cdrom_dev, sizeof cdrom_dev); };
    449 	option {src_legend(menu, MSG_Set_dir_bin, set_dir_bin);},
    450 		action { src_prompt(MSG_Set_dir_bin, set_dir_bin, sizeof set_dir_bin); };
    451 	option {src_legend(menu, MSG_Set_dir_src, set_dir_src);},
    452 		action { src_prompt(MSG_Set_dir_src, set_dir_src, sizeof set_dir_src); };
    453 	option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };
    454 
    455 menu localfssource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
    456 	display action { msg_display(MSG_localfssource); };
    457 	option {src_legend(menu, MSG_Device, localfs_dev);},
    458 		action { src_prompt(MSG_dev, localfs_dev, sizeof localfs_dev);};
    459 	option {src_legend(menu, MSG_File_system, localfs_fs);},
    460 		action { src_prompt(MSG_filesys, localfs_fs, sizeof localfs_fs); };
    461 	option {src_legend(menu, MSG_Base_dir, localfs_dir);},
    462 		action { src_prompt(MSG_Base_dir, localfs_dir, sizeof localfs_dir);};
    463 	option {src_legend(menu, MSG_Set_dir_bin, set_dir_bin);},
    464 		action { src_prompt(MSG_Set_dir_bin, set_dir_bin, sizeof set_dir_bin); };
    465 	option {src_legend(menu, MSG_Set_dir_src, set_dir_src);},
    466 		action { src_prompt(MSG_Set_dir_src, set_dir_src, sizeof set_dir_src); };
    467 	option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };
    468 
    469 menu localdirsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
    470 	display action { msg_display(MSG_localdir); };
    471 	option {src_legend(menu, MSG_Base_dir, localfs_dir);},
    472 		action { src_prompt(MSG_Base_dir, localfs_dir, 60); };
    473 	option {src_legend(menu, MSG_Set_dir_bin, set_dir_bin);},
    474 		action { src_prompt(MSG_Set_dir_bin, set_dir_bin, 60); };
    475 	option {src_legend(menu, MSG_Set_dir_src, set_dir_src);},
    476 		action { src_prompt(MSG_Set_dir_src, set_dir_src, 60); };
    477 	option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };
    478 
    479 menu namesrv6, title MSG_Select_DNS_server;
    480 	option "google-public-dns-a.google.com (IPv4)", exit, action
    481 		{
    482 #ifdef INET6
    483 		  strlcpy(net_namesvr, "8.8.8.8",
    484 		      sizeof(net_namesvr));
    485 		  *((int*)arg) = 1;
    486 #else
    487 		  *((int*)arg) = 0;
    488 #endif
    489 		};
    490 	option "google-public-dns-b.google.com (IPv4)", exit, action
    491 		{
    492 #ifdef INET6
    493 		  strlcpy(net_namesvr, "8.8.4.4",
    494 		      sizeof(net_namesvr));
    495 		  *((int*)arg) = 1;
    496 #else
    497 		  *((int*)arg) = 0;
    498 #endif
    499 		};
    500 	option "google-public-dns-a.google.com (IPv6)", exit, action
    501 		{
    502 #ifdef INET6
    503 		  strlcpy(net_namesvr, "2001:4860:4860::8888",
    504 		      sizeof(net_namesvr));
    505 		  *((int*)arg) = 1;
    506 #else
    507 		  *((int*)arg) = 0;
    508 #endif
    509 		};
    510 	option "google-public-dns-b.google.com (IPv6)", exit, action
    511 		{
    512 #ifdef INET6
    513 		  strlcpy(net_namesvr, "2001:4860:4860::8844",
    514 		      sizeof(net_namesvr));
    515 		  *((int*)arg) = 1;
    516 #else
    517 		  *((int*)arg) = 0;
    518 #endif
    519 		};
    520 	option MSG_other, exit, action
    521 		{ *((int*)arg) = 0; };
    522 
    523 menu rootsh, title MSG_Root_shell, no clear;
    524 	option "/bin/sh",  exit, action {*(const char **)arg = "/bin/sh";};
    525 	option "/bin/ksh", exit, action {*(const char **)arg = "/bin/ksh";};
    526 	option "/bin/csh", exit, action {*(const char **)arg = "/bin/csh";};
    527 
    528 menu zeroconf, title "Zeroconf", no clear;
    529 	option "run mdnsd only", exit, action {*(const char **)arg = "mdnsd";};
    530 	option "run mdnsd and resolve local names", exit, action {*(const char **) arg = "mdnsd+nsswitch";};
    531 	option "do not run mdnsd", exit, action {*(const char **)arg = "No";};
    532 
    533 menu binpkg, y=-4, x=0, w=70, no box, no clear,
    534 	    exitstring MSG_Install_pkgin;
    535 	display action { msg_display(MSG_pkgpath); };
    536 	option {src_legend(menu, MSG_Host, pkg.host);},
    537 		action { src_prompt(MSG_Host, pkg.host, sizeof pkg.host); };
    538 	option {src_legend(menu, MSG_Base_dir, pkg.dir);},
    539 		action { src_prompt(MSG_Base_dir, pkg.dir, sizeof pkg.dir); };
    540 	option {src_legend(menu, MSG_Pkg_dir, pkg_dir);},
    541 		action { src_prompt(MSG_Pkg_dir, pkg_dir, sizeof pkg_dir); };
    542 	option {src_legend(menu, MSG_User, pkg.user);},
    543 		action { src_prompt(MSG_User, pkg.user, sizeof pkg.user);
    544 			pkg.pass[0] = 0;
    545 		};
    546 	option {src_legend(menu, MSG_Password,
    547 		    strcmp(pkg.user, "ftp") == 0 || pkg.pass[0] == 0
    548 			? pkg.pass : msg_string(MSG_hidden));},
    549 		action { if (strcmp(pkg.user, "ftp") == 0)
    550 			src_prompt(MSG_email, pkg.pass, sizeof pkg.pass);
    551 		  else {
    552 			msg_prompt_noecho(MSG_Password, "",
    553 					pkg.pass, sizeof pkg.pass);
    554 		  }
    555 		};
    556 	option {src_legend(menu, MSG_Proxy, pkg.proxy);},
    557 		action { src_prompt(MSG_Proxy, pkg.proxy, sizeof pkg.proxy);
    558 		  if (strcmp(pkg.proxy, "") == 0) {
    559 			unsetenv("ftp_proxy");
    560 			unsetenv("http_proxy");
    561 		  } else {
    562 			setenv("ftp_proxy", pkg.proxy, 1);
    563 			setenv("http_proxy", pkg.proxy, 1);
    564 		  }
    565 		};
    566 	option {src_legend(menu, "Additional packages", (char*)(((arg_rv*)arg)->arg)); }, /*TODO*/
    567 		action { src_prompt("Additional packages", (char*)(((arg_rv*)arg)->arg),
    568 			 sizeof(char) * STRSIZE); };
    569 	option MSG_Configure_network,
    570 		action {
    571 			extern int network_up;
    572 			network_up = 0;
    573 			config_network();
    574 			mnt_net_config();
    575 		};
    576 	option MSG_quit_pkgs_install, exit, action { ((arg_rv*)arg)->rv = SET_SKIP; };
    577 
    578 menu pkgsrc, y=-4, x=0, w=70, no box, no clear,
    579 	    exit, exitstring MSG_Install_pkgsrc;
    580 	display action { msg_display(MSG_pkgsrc); };
    581 	option {src_legend(menu, MSG_Host, pkgsrc.host);},
    582 		action { src_prompt(MSG_Host, pkgsrc.host,
    583 			sizeof pkgsrc.host); };
    584 	option {src_legend(menu, MSG_Pkgsrc_dir, pkgsrc_dir);},
    585 		action { src_prompt(MSG_Pkgsrc_dir, pkgsrc_dir, sizeof pkgsrc_dir); };
    586 	option {src_legend(menu, MSG_User, pkgsrc.user);},
    587 		action { src_prompt(MSG_User, pkgsrc.user, sizeof pkgsrc.user);
    588 			pkgsrc.pass[0] = 0;
    589 		};
    590 	option {src_legend(menu, MSG_Password,
    591 		    strcmp(pkgsrc.user, "ftp") == 0 || pkgsrc.pass[0] == 0
    592 			? pkgsrc.pass : msg_string(MSG_hidden));},
    593 		action { if (strcmp(pkgsrc.user, "ftp") == 0)
    594 			src_prompt(MSG_email, pkgsrc.pass, sizeof pkgsrc.pass);
    595 		  else {
    596 			msg_prompt_noecho(MSG_Password, "",
    597 					pkgsrc.pass, sizeof pkgsrc.pass);
    598 		  }
    599 		};
    600 	option {src_legend(menu, MSG_Proxy, pkgsrc.proxy);},
    601 		action { src_prompt(MSG_Proxy, pkgsrc.proxy, sizeof pkgsrc.proxy);
    602 		  if (strcmp(pkgsrc.proxy, "") == 0) {
    603 			unsetenv("ftp_proxy");
    604 			unsetenv("http_proxy");
    605 		  } else {
    606 			setenv("ftp_proxy", pkgsrc.proxy, 1);
    607 			setenv("http_proxy", pkgsrc.proxy, 1);
    608 		  }
    609 		};
    610 	option {src_legend(menu, MSG_Xfer_dir, xfer_dir);},
    611 		action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
    612 	option {src_legend(menu, MSG_delete_xfer_file,
    613 			clean_xfer_dir ? MSG_Yes : MSG_No);},
    614 		action {clean_xfer_dir = ask_yesno(deconst(MSG_delete_xfer_file)); };
    615 	option MSG_quit_pkgsrc, exit, action { *((int*)arg) = SET_SKIP;};
    616 
    617 menu usersh, title MSG_User_shell, no clear;
    618 	option "/bin/sh",  exit, action { ushell = "/bin/sh";};
    619 	option "/bin/ksh", exit, action { ushell = "/bin/ksh";};
    620 	option "/bin/csh", exit, action { ushell = "/bin/csh";};
    621 
    622 
    623 menu pmdiskentry, x=50, y=5, exit, default exit;
    624 	option MSG_editbsdpart, exit, action { pm_make_bsd_partitions(pm); };
    625 	option MSG_editmbr,		exit, action { md_get_info();
    626 											md_pre_disklabel();
    627 											memset(&pm->bsdlabel, 0, sizeof pm->bsdlabel);};
    628 	option MSG_switchgpt,	exit, action { if (pm_gpt_convert(pm) == 0)
    629 												pm_partusage(pm, -1, 1); };
    630 	option MSG_renamedisk,	exit, action { pm->unsaved = 1; pm_rename(pm); };
    631 	option MSG_fmtasraid,	exit, action { pm->unsaved = 1;
    632 											pm_partusage(pm, -1, 1);
    633 											layoutkind = LY_NEWRAID;
    634 											md_make_bsd_partitions();};
    635 	option MSG_fmtaslvm,	exit, action { pm->unsaved = 1;
    636 											pm_partusage(pm, -1, 1);
    637 											layoutkind = LY_NEWLVM;
    638 											md_make_bsd_partitions(); };
    639 	option MSG_encrypt,		exit, action { pm->unsaved = 1;
    640 											pm_partusage(pm, -1, 1);
    641 											layoutkind = LY_NEWCGD;
    642 											md_make_bsd_partitions();
    643 											pm_cgd_edit(0, &(part_entry_t)
    644 												{.dev_ptr = pm, .dev_num = PART_E}
    645 											); };
    646 	option MSG_setbootable,	exit, action { pm->unsaved = 1;
    647 											pm->bootable = !pm->bootable; };
    648 	option MSG_erase,		next menu shred_modes;
    649 	option MSG_undo,		exit, action { label_read(); pm->unsaved = 0;
    650 											pm_partusage(pm, -1, 1); };
    651 	option MSG_unconfig,	exit, action { if (pm_unconfigure(pm) == 0)
    652 												pm_partusage(pm, -1, 1); };
    653 
    654 menu pmpartentry, x=50, y=5, exit, default exit;
    655 	option MSG_edit,		exit, action {
    656 									pm->unsaved = 1;
    657 									int tpfs = pm->bsdlabel[*(int*)arg].pi_fstype;
    658 									int tplvm = pm->bsdlabel[*(int*)arg].lvmpv;
    659 									pm_editpart(*(int*)arg);
    660 									if (tpfs != pm->bsdlabel[*(int*)arg].pi_fstype ||
    661 										tplvm != pm->bsdlabel[*(int*)arg].lvmpv)
    662 										/* Oops, partition type changed */
    663 										pm_partusage(pm, *(int*)arg, 1);
    664 								};
    665 	option MSG_fmtasraid,	exit, action {
    666 									if (pm->gpt || pm->isspecial) {
    667 										process_menu(MENU_ok, deconst(MSG_notsupported));
    668 										return -1;
    669 									}
    670 									pm->unsaved = 1;
    671 									pm_partusage(pm, *(int*)arg, 1);
    672 									pm_setfstype(pm, *(int*)arg, FS_RAID);
    673 								};
    674 	option MSG_fmtaslvm,	exit, action {
    675 									if (pm->gpt || pm->isspecial) {
    676 										process_menu(MENU_ok, deconst(MSG_notsupported));
    677 										return -1;
    678 									}
    679 									pm->unsaved = 1;
    680 									pm_partusage(pm, *(int*)arg, 1);
    681 									pm_setfstype(pm, *(int*)arg, FS_BSDFFS);
    682 								    pm->bsdlabel[*(int*)arg].lvmpv = 1;
    683 								};
    684 	option MSG_encrypt,		exit, action {
    685 									if (pm->gpt || pm->isspecial) {
    686 										process_menu(MENU_ok, deconst(MSG_notsupported));
    687 										return -1;
    688 									}
    689 									pm->unsaved = 1;
    690 									pm_partusage(pm, *(int*)arg, 1);
    691 									pm_setfstype(pm, *(int*)arg, FS_CGD);
    692 									pm_cgd_edit(0,
    693 										&(part_entry_t){.dev_ptr = pm,
    694 														.dev_num = *(int*)arg});
    695 								};
    696 	option MSG_erase,		next menu shred_modes;
    697 	option MSG_doumount,	exit, action { pm_umount(pm, *(int*)arg); };
    698 	option MSG_Delete_partition,	exit, action {
    699 									pm->unsaved = 1;
    700 									pm_partusage(pm, *(int*)arg, 1);
    701 									if (pm->isspecial)
    702 										pm_unconfigure(pm);
    703 									else
    704 										pm->bsdlabel[*(int*)arg].pi_fstype = FS_UNUSED;
    705 									};
    706 
    707 menu pmgptentry, x=50, y=8, exit, default exit;
    708 	option MSG_editbsdpart, exit, action { pm_make_bsd_partitions(pm); };
    709 	option MSG_switchmbr,	exit, action { if (pm_gpt_convert(pm) == 0)
    710 												pm_partusage(pm, -1, 1); };
    711 	option MSG_setbootable,	exit, action { pm->unsaved = 1;
    712 												pm->bootable = !pm->bootable; };
    713 	option MSG_erase,		next menu shred_modes;
    714 	option MSG_undo,		exit, action { label_read(); pm->unsaved = 0;
    715 											pm_partusage(pm, -1, 1); };
    716 	option MSG_unconfig,	exit, action { if (pm_unconfigure(pm) == 0)
    717 												pm_partusage(pm, -1, 1); };
    718 
    719 menu shred_modes, x=50, y=5, exit, default exit;
    720 	option MSG_fillzeros,	exit,
    721 							action { pm_shred(pm, *(int*)arg, SHRED_ZEROS); };
    722 	option MSG_fillrandom,	exit,
    723 							action { pm_shred(pm, *(int*)arg, SHRED_RANDOM); };
    724 	option MSG_fillcrypto,	exit,
    725 							action { pm_shred(pm, *(int*)arg, SHRED_CRYPTO); };
    726 
    727 menu raidlevel;
    728 	option MSG_raid0, exit, action { *(int *)arg = 0; };
    729 	option MSG_raid1, exit, action { *(int *)arg = 1; };
    730 	option MSG_raid4, exit, action { *(int *)arg = 4; };
    731 	option MSG_raid5, exit, action { *(int *)arg = 5; };
    732 
    733 menu cgd_enctype;
    734 	option "aes-cbc",			exit, action { *(const char**)arg = "aes-cbc"; };
    735 	option "3des-cbc",			exit, action { *(const char**)arg = "3des-cbc"; };
    736 	option "blowfish-cbc",		exit, action { *(const char**)arg = "blowfish-cbc"; };
    737 
    738 menu cgd_ivtype;
    739 	option "encblkno1",			exit, action { *(const char**)arg = "encblkno1"; };
    740 	option "encblkno8",			exit, action { *(const char**)arg = "encblkno8"; };
    741 
    742 menu cgd_keygentype;
    743 	option "pkcs5_pbkdf2/sha1",	exit, action { *(const char**)arg = "pkcs5_pbkdf2/sha1"; };
    744 	option "pkcs5_pbkdf2",		exit, action { *(const char**)arg = "pkcs5_pbkdf2"; };
    745 	option "storedkey",			exit, action { *(const char**)arg = "storedkey"; };
    746 	option "randomkey",			exit, action { *(const char**)arg = "randomkey"; };
    747 	option "urandomkey",		exit, action { *(const char**)arg = "urandomkey"; };
    748 	option "shell_cmd",			exit, action { *(const char**)arg = "shell_cmd"; };
    749 
    750 menu cgd_verifytype;
    751 	option "none",				exit, action { *(const char**)arg = "none"; };
    752 	option "disklabel",			exit, action { *(const char**)arg = "disklabel"; };
    753 	option "ffs",				exit, action { *(const char**)arg = "ffs"; };
    754 	option "re-enter",			exit, action { *(const char**)arg = "re-enter"; };
    755