1 /* $NetBSD: menus.mi,v 1.36 2009/08/23 21:16:16 jmcneill Exp $ */
4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
33 * Menu system definitions -- machine and language independent
35 * Some menus may be called directly in the code rather than via the
38 * This file must be first in the sed command line.
49 #include "menu_defs.h"
52 src_legend(menudesc *menu, const char *legend, const char *text)
54 wprintw(menu->mw, "%-25s %.50s", MSG_XLAT(legend), MSG_XLAT(text));
58 src_prompt(const char *prompt, char *buf, size_t size)
60 msg_prompt_win(prompt, -1, 12, 0, 0, buf, buf, size);
64 default y=12, no exit, scrollable;
67 allow dynamic messages;
70 menu selfskind, title MSG_Select_the_type, exitstring MSG_unchanged, y=6, x=30;
73 switch (p->pi_fstype) {
74 case FS_UNUSED: menu->cursel = 0; break;
76 menu->cursel = p->pi_flags & PIF_FFSv2 ? 2 : 1;
78 case FS_SWAP: menu->cursel = 3; break;
79 case FS_MSDOS: menu->cursel = 4; break;
80 case FS_BSDLFS: menu->cursel = 5; break;
81 default : menu->cursel = 6; break;
84 option "unused", exit, action
85 { memset(arg, 0, sizeof (partinfo)); };
86 option "FFSv1", exit, action { set_ptype(arg, FS_BSDFFS, 0); };
87 option "FFSv2", exit, action { set_ptype(arg, FS_BSDFFS, PIF_FFSv2); };
88 option "swap", exit, action { set_ptype(arg, FS_SWAP, 0); };
89 option "msdos", exit, action { set_ptype(arg, FS_MSDOS, 0); };
90 option "LFS", exit, action { set_ptype(arg, FS_BSDLFS, 0); };
91 option MSG_other_types, action
92 { extern int all_fstype_menu;
93 m->opts[m->cursel].opt_menu = all_fstype_menu; };
95 menu selbsize, title MSG_Select_file_system_block_size, y=10, x=40;
99 b = ffs(pi->pi_fsize * pi->pi_frag / 4096) - 1;
100 if (b < 0 || b >= menu->numopts)
104 option "4096", exit, action { set_bsize(arg, 4096); };
105 option "8192", exit, action { set_bsize(arg, 8192); };
106 option "16384", exit, action { set_bsize(arg, 16384); };
107 option "32768", exit, action { set_bsize(arg, 32768); };
109 menu selfsize, title MSG_Select_file_system_fragment_size, y=11, x=40;
113 b = ffs(pi->pi_fsize / 512) - 1;
114 if (b < 0 || b >= menu->numopts)
118 option "512", exit, action { set_fsize(arg, 512); };
119 option "1024", exit, action { set_fsize(arg, 1024); };
120 option "2048", exit, action { set_fsize(arg, 2048); };
121 option "4096", exit, action { set_fsize(arg, 4096); };
122 option "8192", exit, action { set_fsize(arg, 8192); };
123 option "16384", exit, action { set_fsize(arg, 16384); };
124 option "32768", exit, action { set_fsize(arg, 32768); };
126 menu mountoptions, title MSG_toggle, y=5, x=30, exitstring MSG_unchanged;
128 static int actual_numopt;
130 actual_numopt = menu->numopts;
131 menu->numopts = actual_numopt -
132 (((partinfo *)arg)->pi_fstype != FS_BSDFFS);
134 option "log", exit, action
135 { ((partinfo *)arg)->pi_flags ^= PIF_LOG; };
136 option "async", exit, action
137 { ((partinfo *)arg)->pi_flags ^= PIF_ASYNC; };
138 option "noatime", exit, action
139 { ((partinfo *)arg)->pi_flags ^= PIF_NOATIME; };
140 option "nodev", exit, action
141 { ((partinfo *)arg)->pi_flags ^= PIF_NODEV; };
142 option "nodevmtime", exit, action
143 { ((partinfo *)arg)->pi_flags ^= PIF_NODEVMTIME; };
144 option "noexec", exit, action
145 { ((partinfo *)arg)->pi_flags ^= PIF_NOEXEC; };
146 option "nosuid", exit, action
147 { ((partinfo *)arg)->pi_flags ^= PIF_NOSUID; };
149 menu netbsd, title MSG_NetBSD_VERSION_Install_System, y=-1,
150 exit, exitstring MSG_Exit_Install_System;
151 display action { toplevel(); };
152 option MSG_Install_NetBSD_to_hard_disk,
153 action { do_install(); };
154 option MSG_Upgrade_NetBSD_on_a_hard_disk,
155 action { do_upgrade(); };
156 option MSG_Re_install_sets_or_install_additional_sets,
157 action { do_reinstall_sets(); };
158 option MSG_Reboot_the_computer, exit,
159 action (endwin) { system("/sbin/reboot -q"); };
160 option MSG_Utility_menu, sub menu utility;
162 menu utility, title MSG_NetBSD_VERSION_Utilities, exit;
163 display action { toplevel(); };
164 option MSG_Run_bin_sh,
165 action (endwin) { system("/bin/sh"); };
166 option MSG_Set_timezone,
167 action { set_timezone(); };
168 option MSG_Configure_network,
170 extern int network_up;
175 /* option MSG_Partition a disk; XXX add later. */
176 option MSG_Logging_functions, action { do_logging(); };
177 option MSG_Halt_the_system, exit,
178 action (endwin) { system("/sbin/halt -q"); };
181 display action { menu->title = arg ? arg : MSG_yes_or_no; };
182 option MSG_Yes, exit, action {yesno = 1;};
183 option MSG_No, exit, action {yesno = 0;};
186 display action { menu->title = arg ? arg : MSG_yes_or_no; };
187 option MSG_No, exit, action {yesno = 0;};
188 option MSG_Yes, exit, action {yesno = 1;};
190 menu ok, no shortcut, y=-10;
191 display action { menu->title = arg; };
192 option MSG_Hit_enter_to_continue, exit;
194 menu layout, sub menu, y=-1, title MSG_Choose_your_installation;
195 option MSG_Set_Sizes, exit, action { layoutkind = 1; };
196 option MSG_Use_Existing, exit, action { layoutkind = 4; };
198 menu sizechoice, sub menu, y=0, title MSG_Choose_your_size_specifier;
200 if (sizemult == current_cylsize)
202 else if (sizemult == 1)
205 option MSG_Megabytes, exit, action
206 { sizemult = MEG / sectorsize;
207 multname = msg_string(MSG_megname);
209 option MSG_Cylinders, exit, action
210 { sizemult = current_cylsize;
211 multname = msg_string(MSG_cylname);
213 option MSG_Sectors, exit, action
215 multname = msg_string(MSG_secname);
218 menu distmedium, title MSG_Select_medium, y=-5;
219 option MSG_cdrom, exit, action { *(int *)arg = get_via_cdrom(); };
220 option MSG_ftp, exit, action { *(int *)arg = get_via_ftp("ftp"); };
221 option MSG_http, exit, action { *(int *)arg = get_via_ftp("http"); };
222 option MSG_nfs, exit, action { *(int *)arg = get_via_nfs(); };
223 option MSG_floppy, exit, action { *(int *)arg = get_via_floppy(); };
224 option MSG_local_fs, exit, action { *(int *)arg = get_via_localfs(); };
225 option MSG_local_dir, exit, action { *(int *)arg = get_via_localdir();};
226 option MSG_Skip_set, exit, action { *(int *)arg = SET_SKIP; };
227 option MSG_Skip_group,exit, action { *(int *)arg = SET_SKIP_GROUP; };
228 option MSG_Abandon, exit, action { *(int *)arg = SET_ABANDON; };
230 menu distset, title MSG_Select_your_distribution;
231 display action { msg_display (MSG_distset); };
232 option MSG_Full_installation, exit, action { init_set_status(0); };
233 option MSG_Minimal_installation, exit, action { init_set_status(1); };
234 option MSG_Custom_installation, exit, action { init_set_status(1); customise_sets(); };
236 menu ftpsource, y=-4, x=0, w=70, no box, no clear,
237 exitstring MSG_Get_Distribution;
238 display action { msg_display(MSG_ftpsource, arg); };
239 option {src_legend(menu, MSG_Host, ftp.host);},
240 action { src_prompt(MSG_Host, ftp.host, sizeof ftp.host); };
241 option {src_legend(menu, MSG_Base_dir, ftp.dir);},
242 action { src_prompt(MSG_Base_dir, ftp.dir, sizeof ftp.dir); };
243 option {src_legend(menu, MSG_Set_dir, set_dir);},
244 action { src_prompt(MSG_Set_dir, set_dir, sizeof set_dir); };
245 option {src_legend(menu, MSG_User, ftp.user);},
246 action { src_prompt(MSG_User, ftp.user, sizeof ftp.user);
249 option {src_legend(menu, MSG_Password,
250 strcmp(ftp.user, "ftp") == 0 || ftp.pass[0] == 0
251 ? ftp.pass : msg_string(MSG_hidden));},
252 action { if (strcmp(ftp.user, "ftp") == 0)
253 src_prompt(MSG_email, ftp.pass, sizeof ftp.pass);
255 msg_prompt_noecho(MSG_Password, "",
256 ftp.pass, sizeof ftp.pass);
259 option {src_legend(menu, MSG_Proxy, ftp.proxy);},
260 action { src_prompt(MSG_Proxy, ftp.proxy, sizeof ftp.proxy);
261 if (strcmp(ftp.proxy, "") == 0) {
262 unsetenv("ftp_proxy");
263 unsetenv("http_proxy");
265 setenv("ftp_proxy", ftp.proxy, 1);
266 setenv("http_proxy", ftp.proxy, 1);
269 option {src_legend(menu, MSG_Xfer_dir, xfer_dir);},
270 action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
271 option {src_legend(menu, MSG_delete_xfer_file,
272 clean_xfer_dir ? MSG_Yes : MSG_No);},
273 action {process_menu(MENU_yesno, deconst(MSG_delete_xfer_file));
274 clean_xfer_dir = yesno; };
276 menu nfssource, y=-4, x=0, w=70, no box, no clear,
277 exitstring MSG_Continue;
278 display action { msg_display(MSG_nfssource); };
279 option {src_legend(menu, MSG_Host, nfs_host);},
280 action { src_prompt(MSG_Host, nfs_host, sizeof nfs_host); };
281 option {src_legend(menu, MSG_Base_dir, nfs_dir);},
282 action { src_prompt(MSG_Base_dir, nfs_dir, sizeof nfs_dir); };
283 option {src_legend(menu, MSG_Set_dir, set_dir);},
284 action { src_prompt(MSG_Set_dir, set_dir, sizeof set_dir); };
286 menu fdremount, title MSG_What_do_you_want_to_do;
287 option MSG_Try_again, exit, action { *(int *)arg = SET_CONTINUE; };
288 option MSG_Set_finished, exit, action { *(int *)arg = SET_OK; };
289 option MSG_Abort_fetch, exit, action { *(int *)arg = SET_RETRY; };
291 menu fdok, title MSG_What_do_you_want_to_do;
292 option MSG_OK, exit, action { *(int *)arg = SET_CONTINUE; };
293 option MSG_Set_finished, exit, action { *(int *)arg = SET_OK; };
294 option MSG_Abort_fetch, exit, action { *(int *)arg = SET_RETRY; };
296 menu crypttype, title MSG_Password_cipher, y=15;
297 option MSG_SHA1, exit, action { yesno = 4; };
298 option MSG_DES, exit, action { yesno = 1; };
299 option MSG_MD5, exit, action { yesno = 2; };
300 option MSG_Blowfish_2_7_round, exit, action { yesno = 3; };
301 option MSG_do_not_change, exit, action { yesno = 0; };
303 menu fd_type, title MSG_fd_type, y=16;
304 option "msdos", exit, action { fd_type = "msdos"; };
305 option "ffs", exit, action { fd_type = "ffs"; };
307 option "ados", exit, action { fd_type = "ados"; };
310 menu floppysource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
311 display action { msg_display(MSG_floppysource); };
312 option {src_legend(menu, MSG_Device, fd_dev);},
313 action { src_prompt(MSG_dev, fd_dev, sizeof fd_dev); };
314 option {src_legend(menu, MSG_fd_type, fd_type);}, sub menu fd_type;
315 option {src_legend(menu, MSG_Xfer_dir, xfer_dir);},
316 action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
317 option {src_legend(menu, MSG_delete_xfer_file,
318 clean_xfer_dir ? MSG_Yes : MSG_No);},
319 action {process_menu(MENU_yesno, deconst(MSG_delete_xfer_file));
320 clean_xfer_dir = yesno; };
322 menu cdromsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
323 display action { msg_display(MSG_cdromsource); };
324 option {src_legend(menu, MSG_Device, cdrom_dev);},
325 action { src_prompt(MSG_dev, cdrom_dev, sizeof cdrom_dev); };
326 option {src_legend(menu, MSG_Set_dir, set_dir);},
327 action { src_prompt(MSG_Set_dir, set_dir, sizeof set_dir); };
329 menu localfssource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
330 display action { msg_display(MSG_localfssource); };
331 option {src_legend(menu, MSG_Device, localfs_dev);},
332 action { src_prompt(MSG_dev, localfs_dev, sizeof localfs_dev);};
333 option {src_legend(menu, MSG_File_system, localfs_fs);},
334 action { src_prompt(MSG_filesys, localfs_fs, sizeof localfs_fs); };
335 option {src_legend(menu, MSG_Base_dir, localfs_dir);},
336 action { src_prompt(MSG_Base_dir, localfs_dir, sizeof localfs_dir);};
337 option {src_legend(menu, MSG_Set_dir, set_dir);},
338 action { src_prompt(MSG_Set_dir, set_dir, sizeof set_dir); };
340 menu localdirsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
341 display action { msg_display(MSG_localdir); };
342 option {src_legend(menu, MSG_Base_dir, localfs_dir);},
343 action { src_prompt(MSG_Base_dir, localfs_dir, 60); };
344 option {src_legend(menu, MSG_Set_dir, set_dir);},
345 action { src_prompt(MSG_Set_dir, set_dir, 60); };
347 menu namesrv6, title MSG_Select_IPv6_DNS_server;
348 option "ns-wide.wide.ad.jp", exit, action
351 strlcpy(net_namesvr6, "2001:200:0:1::f", sizeof(net_namesvr6));
357 option "light.imasy.or.jp", exit, action
360 strlcpy(net_namesvr6, "2001:200:300:1:2a0:c9ff:fe61:6521",
361 sizeof(net_namesvr6));
367 option MSG_other, exit, action
370 menu rootsh, title MSG_Root_shell;
371 option "/bin/sh", exit, action {*(const char **)arg = "/bin/sh";};
372 option "/bin/ksh", exit, action {*(const char **)arg = "/bin/ksh";};
373 option "/bin/csh", exit, action {*(const char **)arg = "/bin/csh";};