menus.entropy revision 1.2 1 /* $NetBSD: menus.entropy,v 1.2 2021/10/08 15:59:55 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 /* Menu system definitions -- entropy setup */
33
34 /* arg is an int*, returning a magic value for the selected menu option */
35 menu not_enough_entropy, title MSG_not_enough_entropy, y=-1, no box, clear,
36 exit, exitstring MSG_continue_without_entropy;
37 option MSG_entropy_add_manually, exit,
38 action { *((int*)arg) = 1; };
39 option MSG_entropy_download_seed, exit,
40 action { *((int*)arg) = 2; };
41 option MSG_entropy_download_raw, exit,
42 action { *((int*)arg) = 3; };
43 option MSG_entropy_retry, exit,
44 action { *((int*)arg) = 4; };
45
46
47 /* arg is an int*, returning a magic value for the selected menu option */
48 menu entropy_select_file, title MSG_entropy_select_file, y=-5, box,
49 exit, exitstring MSG_cancel;
50 option MSG_entropy_add_download_http, exit,
51 action { *((int*)arg) = 1; };
52 option MSG_entropy_add_download_ftp, exit,
53 action { *((int*)arg) = 2; };
54 option MSG_entropy_add_nfs, exit,
55 action { *((int*)arg) = 3; };
56 option MSG_entropy_add_local, exit,
57 action { *((int*)arg) = 4; };
58
59
60 /* arg is an int*, set to SET_RETRY when the menu is aborted */
61 menu entropy_nfssource, y=-5, x=0, w=70, no box, no clear,
62 exitstring MSG_load_entropy;
63 option {src_legend(menu, MSG_Host, nfs_host);},
64 action { src_prompt(MSG_Host, nfs_host, sizeof nfs_host); };
65 option {src_legend(menu, MSG_Base_dir, nfs_dir);},
66 action { src_prompt(MSG_Base_dir, nfs_dir, sizeof nfs_dir); };
67 option {src_legend(menu, MSG_entropy_file, entropy_file);},
68 action { src_prompt(MSG_set_entropy_file, entropy_file, sizeof entropy_file); };
69 option MSG_cancel, exit,
70 action { *((int*)arg) = SET_RETRY; };
71
72
73 /* arg is an arg_rv*, pointing to a struct ftpinfo and a return value */
74 menu entropy_ftpsource, y=-4, x=0, w=70, no box, no clear,
75 exitstring MSG_download_entropy;
76 option {src_legend(menu, MSG_Host,
77 ((struct ftpinfo*)((arg_rv*)arg)->arg)->xfer_host[
78 ((struct ftpinfo*)((arg_rv*)arg)->arg)->xfer]);},
79 action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg;
80 src_prompt(MSG_Host, fpi->xfer_host[fpi->xfer],
81 sizeof fpi->xfer_host[fpi->xfer]); };
82 option {src_legend(menu, MSG_entropy_path_and_file, entropy_file);},
83 action { src_prompt(MSG_entropy_path_and_file,
84 entropy_file, sizeof entropy_file); };
85 option {src_legend(menu, MSG_User,
86 ((struct ftpinfo*)((arg_rv*)arg)->arg)->user);},
87 action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg;
88 src_prompt(MSG_User, fpi->user, sizeof fpi->user);
89 fpi->pass[0] = 0;
90 };
91 option {src_legend(menu, MSG_Password,
92 strcmp(((struct ftpinfo*)((arg_rv*)arg)->arg)->user,
93 "ftp") == 0 ||
94 ((struct ftpinfo*)((arg_rv*)arg)->arg)->pass[0] == 0
95 ? ((struct ftpinfo*)((arg_rv*)arg)->arg)->pass
96 : msg_string(MSG_hidden));},
97 action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg;
98 if (strcmp(fpi->user, "ftp") == 0)
99 src_prompt(MSG_email, fpi->pass, sizeof fpi->pass);
100 else {
101 msg_prompt_noecho(MSG_Password, "",
102 fpi->pass, sizeof fpi->pass);
103 }
104 };
105 option {src_legend(menu, MSG_Proxy,
106 ((struct ftpinfo*)((arg_rv*)arg)->arg)->proxy);},
107 action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg;
108 src_prompt(MSG_Proxy, fpi->proxy, sizeof fpi->proxy);
109 if (strcmp(fpi->proxy, "") == 0) {
110 unsetenv("ftp_proxy");
111 unsetenv("http_proxy");
112 } else {
113 setenv("ftp_proxy", fpi->proxy, 1);
114 setenv("http_proxy", fpi->proxy, 1);
115 }
116 };
117 option MSG_cancel, exit, action { ((arg_rv*)arg)->rv = SET_RETRY; };
118
119
120 /* arg is an int*, set to SET_RETRY when the menu is aborted */
121 menu entropy_localfs, y=-4, x=0, w=70, no box, no clear,
122 exitstring MSG_load_entropy;
123 display action { msg_display(MSG_entropy_localfs); };
124 option {src_legend(menu, MSG_Device, localfs_dev);},
125 action { src_prompt(MSG_dev, localfs_dev, sizeof localfs_dev);};
126 option {src_legend(menu, MSG_File_system, localfs_fs);},
127 action { src_prompt(MSG_filesys, localfs_fs, sizeof localfs_fs); };
128 option {src_legend(menu, MSG_entropy_path_and_file, entropy_file);},
129 action { src_prompt(MSG_entropy_path_and_file, entropy_file, sizeof entropy_file);};
130 option MSG_cancel, exit, action { *((int*)arg) = SET_RETRY; };
131
132