Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
/*	$NetBSD: menus.mi,v 1.19.2.2 2020/11/05 08:10:21 sborrill Exp $	*/

/*-
 * Copyright (c) 2003 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by David Laight.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * Menu system definitions -- machine and language independent
 *
 * Some menus may be called directly in the code rather than via the 
 * menu system.
 *
 *  This file must be first in the sed command line.
 *
 */

{
#include <stdio.h>
#include <time.h>
#include <curses.h>
#include "defs.h"
#include "md.h"
#include "msg_defs.h"
#include "menu_defs.h"

static menudesc menu_def[];

static void
expand_option_text(menudesc *menu, void *arg, int sel)
{
	arg_replace *ar = arg;
	struct menu_ent *opt = &menu->opts[sel];

	if (menu->opts[sel].opt_exp_name)
		return;	/* has already been expanded */

	opt->opt_exp_name =
	    str_arg_subst(MSG_XLAT(opt->opt_name), ar->argc, ar->argv);
}

void
expand_all_option_texts(menudesc *menu, void *arg)
{
	arg_replace *ar = arg;
	const char *title;
	int i;

	if (menu->title != NULL && menu->exp_title == NULL) {
		title = MSG_XLAT(menu->title);
		if (needs_expanding(title, ar->argc)) {
			menu->exp_title = str_arg_subst(title,
			    ar->argc, ar->argv);
		}
	}
	for (i = 0; i < menu->numopts; i++) {
		const char *t = MSG_XLAT(menu->opts[i].opt_name);

		if (t == NULL) continue;

		if (needs_expanding(t, ar->argc))
			expand_option_text(menu, arg, i);
	}
}

/*
 * Re-create the menu window with heigh/width updated to current state.
 */
void
resize_menu_height(menudesc *m)
{

	if (m->mw == NULL)
		return;

	wclear(m->mw);
	if (m->sv_mw) {
		overwrite(m->sv_mw, m->mw);
		delwin(m->sv_mw);
		m->sv_mw = NULL;
	}
	wnoutrefresh(m->mw);
	delwin(m->mw);	 
	m->mw = NULL;
}

static void
src_legend(menudesc *menu, const char *legend, const char *text)
{
        wprintw(menu->mw, "%-35s %.50s", MSG_XLAT(legend), MSG_XLAT(text));
}

static void
src_prompt(const char *prompt, char *buf, size_t size)
{
	msg_prompt_win(prompt, -1, 12, 0, 0, buf, buf, size);
}

static void
remove_sub_menu(int menuID)
{

	for (size_t i = 0; i < DYN_MENU_START; i++) {
		for (int j = 0; j < menu_def[i].numopts; j++) {
			if ((menu_def[i].opts[j].opt_flags & OPT_SUB)
			    && menu_def[i].opts[j].opt_menu == menuID) {

				for (int k = j + 1; k < menu_def[i].numopts;
				    k++) {
					menu_def[i].opts[k-1] =
					    menu_def[i].opts[k];
				}
				menu_def[i].numopts--;
				return;

			}
		}
	}
}

#ifndef NO_PARTMAN
static void
remove_menu_option(int menuID, const char *option)
{

	for (int j = 0; j < menu_def[menuID].numopts; j++) {
		if (menu_def[menuID].opts[j].opt_name == option) {
			for (int k = j + 1; k < menu_def[menuID].numopts;
			    k++) {
				menu_def[menuID].opts[k-1] =
				    menu_def[menuID].opts[k];
			}
			menu_def[menuID].numopts--;
			return;

		}
	}
}
#endif

void
remove_color_options()
{
	/*
	 * Current terminal type does not support colors, so remove all
	 * menu entries (actually that is: Utils/Color Scheme) that do not
	 * make any sense in this case.
	 */
	remove_sub_menu(MENU_colors);
}

#ifndef NO_PARTMAN
void
remove_raid_options()
{
	/*
	 * No raidframe available, remove the following menu entries:
	 */
	remove_menu_option(MENU_pmdiskentry, MSG_fmtasraid);
	remove_menu_option(MENU_pmpartentry, MSG_fmtasraid);
}

void
remove_lvm_options()
{
	/*
	 * No LVM available, remove the following menu entries:
	 */
	remove_menu_option(MENU_pmdiskentry, MSG_fmtaslvm);
	remove_menu_option(MENU_pmpartentry, MSG_fmtaslvm);
}

void
remove_cgd_options()
{
	/*
	 * No CGD available, remove the following menu entries:
	 */
	remove_menu_option(MENU_pmdiskentry, MSG_encrypt);
	remove_menu_option(MENU_pmpartentry, MSG_encrypt);
}
#endif

}

default y=12, no exit, scrollable;

allow dynamic menus;
allow dynamic messages;
allow expand;

error action {
	fprintf (stderr, "Could not initialize menu system, please check "
	    "your terminal type.\n");
	exit(4);
};

/*
 * Called with arg = struct single_part_fs_edit*
 */
menu mountoptions, title MSG_toggle, y=5, x=30, exitstring MSG_unchanged;
	/*
	 *  XXX - enable / disable options depending on FS type in
	 *  display action
	*/
	option "log", exit, action
		{ struct single_part_fs_edit *edit = arg;
		  edit->pset->infos[edit->index].mountflags ^= PUIMNT_LOG; };
	option "async", exit, action
		{ struct single_part_fs_edit *edit = arg;
		  edit->pset->infos[edit->index].mountflags ^= PUIMNT_ASYNC; };
	option "noatime", exit, action
		{ struct single_part_fs_edit *edit = arg;
		  edit->pset->infos[edit->index].mountflags ^= PUIMNT_NOATIME; };
	option "nodev", exit, action
		{ struct single_part_fs_edit *edit = arg;
		  edit->pset->infos[edit->index].mountflags ^= PUIMNT_NODEV; };
	option "nodevmtime", exit, action
		{ struct single_part_fs_edit *edit = arg;
		  edit->pset->infos[edit->index].mountflags ^= PUIMNT_NODEVMTIME; };
	option "noexec", exit, action
		{ struct single_part_fs_edit *edit = arg;
		  edit->pset->infos[edit->index].mountflags ^= PUIMNT_NOEXEC; };
	option "nosuid", exit, action
		{ struct single_part_fs_edit *edit = arg;
		  edit->pset->infos[edit->index].mountflags ^= PUIMNT_NOSUID; };
	option "noauto", exit, action
		{ struct single_part_fs_edit *edit = arg;
		  edit->pset->infos[edit->index].mountflags ^= PUIMNT_NOAUTO; };

menu netbsd, title MSG_NetBSD_VERSION_Install_System, y=-1,
    exit, exitstring MSG_Exit_Install_System;
	display action  { toplevel(); };
	option MSG_Install_NetBSD_to_hard_disk,
		action { do_install(); };
	option MSG_Upgrade_NetBSD_on_a_hard_disk,
		action { do_upgrade(); };
	option MSG_Re_install_sets_or_install_additional_sets,
		action { do_reinstall_sets(); };
	option MSG_Reboot_the_computer, exit,
		action (endwin) { system("/sbin/reboot -q"); };
	option MSG_Utility_menu, sub menu utility;
	option MSG_Config_menu, action { do_configmenu(NULL); };

menu utility, title MSG_NetBSD_VERSION_Utilities, exit,
		exitstring MSG_exit_menu_generic;
	display action  { toplevel(); };
	option MSG_Run_bin_sh,
		action (endwin) { system("/bin/sh"); };
	option MSG_Set_timezone, 
		action { set_timezone(); };
	option MSG_Configure_network,
		action {
			extern int network_up;
			network_up = 0;
			config_network();
		};
	option MSG_Partition_a_disk,
		action {
#ifndef NO_PARTMAN
			partman_go = 1;
			partman();
#endif
		};
	option MSG_Logging_functions, action { do_logging(); };
	option MSG_Color_scheme, sub menu colors;
	option MSG_Halt_the_system, exit,
		action (endwin) { system("/sbin/halt -q"); };

menu colors, title MSG_Color_scheme, exit,
		exitstring MSG_exit_menu_generic;
	option MSG_White_on_black, action { do_coloring(COLOR_WHITE,COLOR_BLACK); };
	option MSG_Black_on_white, action { do_coloring(COLOR_BLACK,COLOR_WHITE); };
	option MSG_White_on_blue,  action { do_coloring(COLOR_WHITE,COLOR_BLUE); };
	option MSG_Green_on_black, action { do_coloring(COLOR_GREEN,COLOR_BLACK); };


menu yesno, y=-10;
	display action { arg_rv *p = arg;
		menu->title = p->arg ? p->arg : MSG_yes_or_no; };
	option MSG_Yes, exit, action  { ((arg_rv*)arg)->rv = 1; };
	option MSG_No,  exit, action  { ((arg_rv*)arg)->rv = 0; };

menu noyes, y=-10;
	display action { arg_rv *p = arg;
		menu->title = p->arg ? p->arg : MSG_yes_or_no; };
	option MSG_No,  exit, action  { ((arg_rv*)arg)->rv = 0; };
	option MSG_Yes, exit, action  { ((arg_rv*)arg)->rv = 1; };

menu ok, no shortcut, y=-10;
	display action { menu->title = arg; };
	option MSG_Hit_enter_to_continue, exit;

menu sizechoice, sub menu, y=0, title MSG_Choose_your_size_specifier;
	display action {
		if (sizemult == pm->current_cylsize)
			menu->cursel = 2;
		else if (sizemult == 1)
			menu->cursel = 3;
		else if (sizemult == (GIG/pm->sectorsize))
			menu->cursel = 0;
		else
			menu->cursel = 1; };
	option MSG_Gigabytes, exit, action
		{ set_sizemult(GIG, pm->sectorsize); };
	option MSG_Megabytes, exit, action
		{ set_sizemult(MEG, pm->sectorsize); };
	option MSG_Cylinders, exit, action
		{ set_sizemult(pm->current_cylsize*pm->sectorsize, pm->sectorsize); };
	option MSG_Sectors, exit, action
		{ set_sizemult(pm->sectorsize, pm->sectorsize); };

menu ptnsize_replace_existing_partition, sub menu, y=0,
	title MSG_ptnsize_replace_existing;
	display action { menu->cursel = 1; };
	option MSG_Yes, exit, action { *((int*)arg) = 1; };
	option MSG_cancel, exit, action { *((int*)arg) = 0; };

menu distmedium, title MSG_Select_medium, y=-5;
	option MSG_cdrom,     exit, action { *(int *)arg = get_via_cdrom(); };
	option MSG_http,      exit, action { *(int *)arg = get_via_ftp(XFER_HTTP); };
	option MSG_ftp,	      exit, action { *(int *)arg = get_via_ftp(XFER_FTP); };
	option MSG_nfs,	      exit, action { *(int *)arg = get_via_nfs(); };
	option MSG_floppy,    exit, action { *(int *)arg = get_via_floppy(); };
	option MSG_local_fs,  exit, action { *(int *)arg = get_via_localfs(); };
	option MSG_local_dir, exit, action { *(int *)arg = get_via_localdir();};
	option MSG_Skip_set,  exit, action { *(int *)arg = SET_SKIP; };
	option MSG_Skip_group,exit, action { *(int *)arg = SET_SKIP_GROUP; };
	option MSG_Abandon,   exit, action { *(int *)arg = SET_ABANDON; };

menu distset, title MSG_Select_your_distribution, exit,
	    no default exit, exitstring MSG_Abandon;
	display action { msg_display (MSG_distset); };
	option MSG_Full_installation, exit, action { *(int *)arg = 1; init_set_status(0);  };
	option MSG_Full_installation_nox, exit, action { *(int *)arg = 1; init_set_status(SFLAG_NOX); };
	option MSG_Minimal_installation, exit, action { *(int *)arg = 1; init_set_status(SFLAG_MINIMAL); };
	option MSG_Custom_installation, exit, action { *(int *)arg = 1; init_set_status(SFLAG_MINIMAL); customise_sets(); };

menu ftpsource, y=-4, x=0, w=70, no box, no clear,
	    exitstring MSG_Get_Distribution;
	display action {
		msg_display_subst(MSG_ftpsource, 2, "." SETS_TAR_SUFF,
		    url_proto((uintptr_t)((arg_rv*)arg)->arg));
	    };
	option {src_legend(menu, MSG_Host, ftp.xfer_host[(uintptr_t)((arg_rv*)arg)->arg]);},
		action { src_prompt(MSG_Host, ftp.xfer_host[(uintptr_t)((arg_rv*)arg)->arg], sizeof ftp.xfer_host[(uintptr_t)((arg_rv*)arg)->arg]); };
	option {src_legend(menu, MSG_Base_dir, ftp.dir);},
		action { src_prompt(MSG_Base_dir, ftp.dir, sizeof ftp.dir); };
	option {src_legend(menu, MSG_Set_dir_bin, set_dir_bin);},
		action { src_prompt(MSG_Set_dir_bin, set_dir_bin, sizeof set_dir_bin); };
	option {src_legend(menu, MSG_Set_dir_src, set_dir_src);},
		action { src_prompt(MSG_Set_dir_src, set_dir_src, sizeof set_dir_src); };
	option {src_legend(menu, MSG_User, ftp.user);},
		action { src_prompt(MSG_User, ftp.user, sizeof ftp.user);
			ftp.pass[0] = 0;
		};
	option {src_legend(menu, MSG_Password,
		    strcmp(ftp.user, "ftp") == 0 || ftp.pass[0] == 0
			? ftp.pass : msg_string(MSG_hidden));},
		action { if (strcmp(ftp.user, "ftp") == 0)
			src_prompt(MSG_email, ftp.pass, sizeof ftp.pass);
		  else {
			msg_prompt_noecho(MSG_Password, "",
					ftp.pass, sizeof ftp.pass);
		  }
		};
	option {src_legend(menu, MSG_Proxy, ftp.proxy);},
		action { src_prompt(MSG_Proxy, ftp.proxy, sizeof ftp.proxy);
		  if (strcmp(ftp.proxy, "") == 0) {
			unsetenv("ftp_proxy");
			unsetenv("http_proxy");
		  } else {
			setenv("ftp_proxy", ftp.proxy, 1);
			setenv("http_proxy", ftp.proxy, 1);
		  }
		};
	option {src_legend(menu, MSG_Xfer_dir, xfer_dir);},
		action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
	option {src_legend(menu, MSG_delete_xfer_file,
			clean_xfer_dir ? MSG_Yes : MSG_No);},
		action {clean_xfer_dir = ask_yesno(MSG_delete_xfer_file); };
	option MSG_Configure_network,
		action {
			extern int network_up;
			network_up = 0;
			config_network();
		};
	option MSG_exit_menu_generic, exit, action { ((arg_rv*)arg)->rv = SET_RETRY; };


menu nfssource, y=-4, x=0, w=70, no box, no clear,
	    exitstring MSG_Get_Distribution;
	display action { const char suff[] = "." SETS_TAR_SUFF;
		msg_display_subst(MSG_nfssource, 1, &suff); };
	option {src_legend(menu, MSG_Host, nfs_host);},
		action { src_prompt(MSG_Host, nfs_host, sizeof nfs_host); };
	option {src_legend(menu, MSG_Base_dir, nfs_dir);},
		action { src_prompt(MSG_Base_dir, nfs_dir, sizeof nfs_dir); };
	option {src_legend(menu, MSG_Set_dir_bin, set_dir_bin);},
		action { src_prompt(MSG_Set_dir_bin, set_dir_bin, sizeof set_dir_bin); };
	option {src_legend(menu, MSG_Set_dir_src, set_dir_src);},
		action { src_prompt(MSG_Set_dir_src, set_dir_src, sizeof set_dir_src); };
	option MSG_Configure_network,
		action {
			extern int network_up;
			network_up = 0;
			config_network();
		};
	option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };

menu fdremount, title MSG_What_do_you_want_to_do;
	option MSG_Try_again, exit, action { *(int *)arg = SET_CONTINUE; };
	option MSG_Set_finished, exit, action { *(int *)arg = SET_OK; };
	option MSG_Abort_fetch, exit, action { *(int *)arg = SET_RETRY; };

menu fdok, title MSG_What_do_you_want_to_do;
	option MSG_OK, exit, action { *(int *)arg = SET_CONTINUE; };
	option MSG_Set_finished, exit, action { *(int *)arg = SET_OK; };
	option MSG_Abort_fetch, exit, action { *(int *)arg = SET_RETRY; };

menu fd_type, title MSG_fd_type, y=16;
	option "msdos", exit, action { fd_type = "msdos"; };
	option "ffs",   exit, action { fd_type = "ffs"; };
.if ADOS_FLOPPY
	option "ados",  exit, action { fd_type = "ados"; };
.endif

menu floppysource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
	display action { msg_display(MSG_floppysource); };
	option {src_legend(menu, MSG_Device, fd_dev);},
		action { src_prompt(MSG_dev, fd_dev, sizeof fd_dev); };
	option {src_legend(menu, MSG_fd_type, fd_type);}, sub menu fd_type;
	option {src_legend(menu, MSG_Xfer_dir, xfer_dir);},
		action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
	option {src_legend(menu, MSG_delete_xfer_file,
			clean_xfer_dir ? MSG_Yes : MSG_No);},
		action {clean_xfer_dir = ask_yesno(MSG_delete_xfer_file); };
	option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };

menu cdromsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
	display action { const char suff[] = "." SETS_TAR_SUFF;
		msg_display_add_subst(MSG_cdromsource, 1, &suff); };
	option {src_legend(menu, MSG_Device, cdrom_dev);},
		action { src_prompt(MSG_dev, cdrom_dev, sizeof cdrom_dev); };
	option {src_legend(menu, MSG_Set_dir_bin, set_dir_bin);},
		action { src_prompt(MSG_Set_dir_bin, set_dir_bin, sizeof set_dir_bin); };
	option {src_legend(menu, MSG_Set_dir_src, set_dir_src);},
		action { src_prompt(MSG_Set_dir_src, set_dir_src, sizeof set_dir_src); };
	option MSG_abort_install, exit, action { *((int*)arg) = SET_ABANDON; };
	option MSG_source_sel_retry, exit, action { *((int*)arg) = SET_RETRY; };

menu localfssource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
	display action { const char suff[] = "." SETS_TAR_SUFF;
		msg_display_subst(MSG_localfssource, 1, &suff); };
	option {src_legend(menu, MSG_Device, localfs_dev);},
		action { src_prompt(MSG_dev, localfs_dev, sizeof localfs_dev);};
	option {src_legend(menu, MSG_File_system, localfs_fs);},
		action { src_prompt(MSG_filesys, localfs_fs, sizeof localfs_fs); };
	option {src_legend(menu, MSG_Base_dir, localfs_dir);},
		action { src_prompt(MSG_Base_dir, localfs_dir, sizeof localfs_dir);};
	option {src_legend(menu, MSG_Set_dir_bin, set_dir_bin);},
		action { src_prompt(MSG_Set_dir_bin, set_dir_bin, sizeof set_dir_bin); };
	option {src_legend(menu, MSG_Set_dir_src, set_dir_src);},
		action { src_prompt(MSG_Set_dir_src, set_dir_src, sizeof set_dir_src); };
	option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };

menu localdirsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_Continue;
	display action { const char suff[] = "." SETS_TAR_SUFF;
		msg_display_subst(MSG_localdir, 1, &suff); };
	option {src_legend(menu, MSG_Base_dir, localfs_dir);},
		action { src_prompt(MSG_Base_dir, localfs_dir, 60); };
	option {src_legend(menu, MSG_Set_dir_bin, set_dir_bin);},
		action { src_prompt(MSG_Set_dir_bin, set_dir_bin, 60); };
	option {src_legend(menu, MSG_Set_dir_src, set_dir_src);},
		action { src_prompt(MSG_Set_dir_src, set_dir_src, 60); };
	option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };

menu namesrv6, title MSG_Select_DNS_server;
	option "google-public-dns-a.google.com (IPv4)", exit, action
		{
#ifdef INET6
		  strlcpy(net_namesvr, "8.8.8.8",
		      sizeof(net_namesvr));
		  *((int*)arg) = 1;
#else
		  *((int*)arg) = 0;
#endif
		}; 
	option "google-public-dns-b.google.com (IPv4)", exit, action
		{
#ifdef INET6
		  strlcpy(net_namesvr, "8.8.4.4",
		      sizeof(net_namesvr));
		  *((int*)arg) = 1;
#else
		  *((int*)arg) = 0;
#endif
		}; 
	option "google-public-dns-a.google.com (IPv6)", exit, action
		{
#ifdef INET6
		  strlcpy(net_namesvr, "2001:4860:4860::8888",
		      sizeof(net_namesvr));
		  *((int*)arg) = 1;
#else
		  *((int*)arg) = 0;
#endif
		}; 
	option "google-public-dns-b.google.com (IPv6)", exit, action
		{
#ifdef INET6
		  strlcpy(net_namesvr, "2001:4860:4860::8844",
		      sizeof(net_namesvr));
		  *((int*)arg) = 1;
#else
		  *((int*)arg) = 0;
#endif
		}; 
	option MSG_other, exit, action
		{ *((int*)arg) = 0; };

menu rootsh, title MSG_Root_shell, no clear;
	option "/bin/sh",  exit, action {*(const char **)arg = "/bin/sh";}; 
	option "/bin/ksh", exit, action {*(const char **)arg = "/bin/ksh";};
	option "/bin/csh", exit, action {*(const char **)arg = "/bin/csh";};

menu zeroconf, title "Zeroconf", no clear;
	option "run mdnsd only", exit, action {*(const char **)arg = "mdnsd";};
	option "run mdnsd and resolve local names", exit, action {*(const char **) arg = "mdnsd+nsswitch";};
	option "do not run mdnsd", exit, action {*(const char **)arg = "No";};

menu binpkg, y=-4, x=0, w=70, no box, no clear,
	    exitstring MSG_Install_pkgin;
	display action { msg_display(MSG_pkgpath); };
	option {src_legend(menu, MSG_Host, pkg.xfer_host[pkg.xfer]);},
		action { src_prompt(MSG_Host, pkg.xfer_host[pkg.xfer], sizeof pkg.xfer_host[pkg.xfer]); };
	option {src_legend(menu, MSG_Base_dir, pkg.dir);},
		action { src_prompt(MSG_Base_dir, pkg.dir, sizeof pkg.dir); };
	option {src_legend(menu, MSG_Pkg_dir, pkg_dir);},
		action { src_prompt(MSG_Pkg_dir, pkg_dir, sizeof pkg_dir); };
	option {src_legend(menu, MSG_User, pkg.user);},
		action { src_prompt(MSG_User, pkg.user, sizeof pkg.user);
			pkg.pass[0] = 0;
		};
	option {src_legend(menu, MSG_Password,
		    strcmp(pkg.user, "ftp") == 0 || pkg.pass[0] == 0
			? pkg.pass : msg_string(MSG_hidden));},
		action { if (strcmp(pkg.user, "ftp") == 0)
			src_prompt(MSG_email, pkg.pass, sizeof pkg.pass);
		  else {
			msg_prompt_noecho(MSG_Password, "",
					pkg.pass, sizeof pkg.pass);
		  }
		};
	option {src_legend(menu, MSG_Proxy, pkg.proxy);},
		action { src_prompt(MSG_Proxy, pkg.proxy, sizeof pkg.proxy);
		  if (strcmp(pkg.proxy, "") == 0) {
			unsetenv("ftp_proxy");
			unsetenv("http_proxy");
		  } else {
			setenv("ftp_proxy", pkg.proxy, 1);
			setenv("http_proxy", pkg.proxy, 1);
		  }
		};
	option {src_legend(menu, "Additional packages", (char*)(((arg_rv*)arg)->arg)); }, /*TODO*/
		action { src_prompt("Additional packages", (char*)(((arg_rv*)arg)->arg),
			 sizeof(char) * STRSIZE); };
	option MSG_Configure_network,
		action {
			extern int network_up;
			network_up = 0;
			config_network();
			mnt_net_config();
		};
	option {src_legend(menu, MSG_transfer_method, url_proto(pkg.xfer));},
		action { pkg.xfer = (pkg.xfer+1) % (XFER_MAX+1); };
	option MSG_quit_pkgs_install, exit, action { ((arg_rv*)arg)->rv = SET_SKIP; };

menu pkgsrc, y=-4, x=0, w=70, no box, no clear,
	    exit, exitstring MSG_Install_pkgsrc;
	display action { msg_display(MSG_pkgsrc); };
	option {src_legend(menu, MSG_Host, pkgsrc.xfer_host[pkgsrc.xfer]);},
		action { src_prompt(MSG_Host, pkgsrc.xfer_host[pkgsrc.xfer],
			sizeof pkgsrc.xfer_host[pkgsrc.xfer]); };
	option {src_legend(menu, MSG_Pkgsrc_dir, pkgsrc_dir);},
		action { src_prompt(MSG_Pkgsrc_dir, pkgsrc_dir, sizeof pkgsrc_dir); };
	option {src_legend(menu, MSG_User, pkgsrc.user);},
		action { src_prompt(MSG_User, pkgsrc.user, sizeof pkgsrc.user);
			pkgsrc.pass[0] = 0;
		};
	option {src_legend(menu, MSG_Password,
		    strcmp(pkgsrc.user, "ftp") == 0 || pkgsrc.pass[0] == 0
			? pkgsrc.pass : msg_string(MSG_hidden));},
		action { if (strcmp(pkgsrc.user, "ftp") == 0)
			src_prompt(MSG_email, pkgsrc.pass, sizeof pkgsrc.pass);
		  else {
			msg_prompt_noecho(MSG_Password, "",
					pkgsrc.pass, sizeof pkgsrc.pass);
		  }
		};
	option {src_legend(menu, MSG_Proxy, pkgsrc.proxy);},
		action { src_prompt(MSG_Proxy, pkgsrc.proxy, sizeof pkgsrc.proxy);
		  if (strcmp(pkgsrc.proxy, "") == 0) {
			unsetenv("ftp_proxy");
			unsetenv("http_proxy");
		  } else {
			setenv("ftp_proxy", pkgsrc.proxy, 1);
			setenv("http_proxy", pkgsrc.proxy, 1);
		  }
		};
	option {src_legend(menu, MSG_Xfer_dir, xfer_dir);},
		action { src_prompt(MSG_Xfer_dir, xfer_dir, sizeof xfer_dir); };
	option {src_legend(menu, MSG_delete_xfer_file,
			clean_xfer_dir ? MSG_Yes : MSG_No);},
		action {clean_xfer_dir = ask_yesno(MSG_delete_xfer_file); };
	option {src_legend(menu, MSG_transfer_method, url_proto(pkgsrc.xfer));},
		action { pkgsrc.xfer = (pkgsrc.xfer+1) % (XFER_MAX+1); };
	option MSG_quit_pkgsrc, exit, action { *((int*)arg) = SET_SKIP;};

menu usersh, title MSG_User_shell, no clear;
	option "/bin/sh",  exit, action { ushell = "/bin/sh";}; 
	option "/bin/ksh", exit, action { ushell = "/bin/ksh";};
	option "/bin/csh", exit, action { ushell = "/bin/csh";};

menu convertscheme, title MSG_cvtscheme_hdr;
	option MSG_cvtscheme_keep,		exit, action { *(int*)arg = 0; };
	option MSG_cvtscheme_delete,		exit, action { *(int*)arg = 1; };
	option MSG_cvtscheme_convert,		exit, action { *(int*)arg = 2; };
	option MSG_cvtscheme_abort,		exit, action { *(int*)arg = 3; };


menu reedit, title MSG_reeditpart, y=-10;
	expand action { expand_all_option_texts(menu, arg); };
	option MSG_reedit_partitions, exit,
	    action  {((arg_rep_int*)arg)->rv = 1;};
	option MSG_use_partitions_anyway, exit,
	    action  {((arg_rep_int*)arg)->rv = 2;};
	option MSG_abort_installation,       exit,
	    action  {((arg_rep_int*)arg)->rv = 0;};