aboutsummaryrefslogtreecommitdiff
path: root/examples_library/sade.c
blob: 1c1d74e5a501ec5be6989ba28f0a757c79640b20 (plain) (blame)
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
/*-
 * SPDX-License-Identifier: CC0-1.0
 *
 * Written in 2021 by Alfonso Sabato Siciliano.
 * To the extent possible under law, the author has dedicated all copyright
 * and related and neighboring rights to this software to the public domain
 * worldwide. This software is distributed without any warranty, see:
 *   <http://creativecommons.org/publicdomain/zero/1.0/>.
 */

#include <bsddialog.h>
#include <stdio.h>
#include <string.h>

/* Figure 15 - https://docs.freebsd.org/en/books/handbook/bsdinstall/ */
int main()
{
	int i, output;
	struct bsddialog_conf conf;
	char *text = "Please review the disk setup. When complete, press the "
	    "Finish button";
	struct bsddialog_menuitem items[5] = {
	    {"", false, 0, "ada0",   "16 GB GPT", ""},
	    {"", false, 1, "ada0p1", "512 KB freebsd-boot", ""},
	    {"", false, 1, "ada0p2", "15 GB freebsd-ufs", ""},
	    {"", false, 1, "ada0p3", "819 MB freebsd-swap none", ""},
	    {"", false, 0, "ada1",   "16 GB", ""}
	};
	
	bsddialog_initconf(&conf);

	conf.title                 = "Partition Editor";
	conf.menu.shortcut_buttons = true;
	conf.menu.align_left       = true;
	conf.button.ok_label       = "Create";
	conf.button.with_extra     = true;
	conf.button.extra_label    = "Delete";
	conf.button.cancel_label   = "Cancel";
	conf.button.with_help      = true;
	conf.button.help_label     = "Revert";
	conf.button.generic1_label = "Auto";
	conf.button.generic2_label = "Finish";
	conf.button.default_label  = "Finish";
	
	if (bsddialog_init() == BSDDIALOG_ERROR)
		return (1);
	output = bsddialog_menu(&conf, text, 20, 0, 10, 5, items, NULL);
	bsddialog_end();

	printf("Menu:\n");
	for (i=0; i<5; i++)
		printf(" [%c] %s\n", items[i].on ? 'X' : ' ', items[i].name);
		
	
	return (output);
}