11.3Smartin/* $NetBSD: menus.entropy,v 1.3 2023/12/17 18:46:42 martin Exp $ */ 21.1Smartin 31.1Smartin/*- 41.1Smartin * Copyright (c) 2003 The NetBSD Foundation, Inc. 51.1Smartin * All rights reserved. 61.1Smartin * 71.1Smartin * This code is derived from software contributed to The NetBSD Foundation 81.1Smartin * by David Laight. 91.1Smartin * 101.1Smartin * Redistribution and use in source and binary forms, with or without 111.1Smartin * modification, are permitted provided that the following conditions 121.1Smartin * are met: 131.1Smartin * 1. Redistributions of source code must retain the above copyright 141.1Smartin * notice, this list of conditions and the following disclaimer. 151.1Smartin * 2. Redistributions in binary form must reproduce the above copyright 161.1Smartin * notice, this list of conditions and the following disclaimer in the 171.1Smartin * documentation and/or other materials provided with the distribution. 181.1Smartin * 191.1Smartin * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Smartin * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Smartin * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Smartin * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Smartin * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Smartin * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Smartin * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Smartin * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Smartin * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Smartin * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Smartin * POSSIBILITY OF SUCH DAMAGE. 301.1Smartin */ 311.1Smartin 321.1Smartin/* Menu system definitions -- entropy setup */ 331.1Smartin 341.1Smartin/* arg is an int*, returning a magic value for the selected menu option */ 351.1Smartinmenu not_enough_entropy, title MSG_not_enough_entropy, y=-1, no box, clear, 361.2Smartin exit, exitstring MSG_continue_without_entropy; 371.1Smartin option MSG_entropy_add_manually, exit, 381.1Smartin action { *((int*)arg) = 1; }; 391.1Smartin option MSG_entropy_download_seed, exit, 401.1Smartin action { *((int*)arg) = 2; }; 411.1Smartin option MSG_entropy_download_raw, exit, 421.1Smartin action { *((int*)arg) = 3; }; 431.1Smartin option MSG_entropy_retry, exit, 441.1Smartin action { *((int*)arg) = 4; }; 451.1Smartin 461.1Smartin 471.1Smartin/* arg is an int*, returning a magic value for the selected menu option */ 481.1Smartinmenu entropy_select_file, title MSG_entropy_select_file, y=-5, box, 491.1Smartin exit, exitstring MSG_cancel; 501.1Smartin option MSG_entropy_add_download_http, exit, 511.1Smartin action { *((int*)arg) = 1; }; 521.1Smartin option MSG_entropy_add_download_ftp, exit, 531.1Smartin action { *((int*)arg) = 2; }; 541.1Smartin option MSG_entropy_add_nfs, exit, 551.1Smartin action { *((int*)arg) = 3; }; 561.1Smartin option MSG_entropy_add_local, exit, 571.1Smartin action { *((int*)arg) = 4; }; 581.1Smartin 591.1Smartin 601.1Smartin/* arg is an int*, set to SET_RETRY when the menu is aborted */ 611.1Smartinmenu entropy_nfssource, y=-5, x=0, w=70, no box, no clear, 621.1Smartin exitstring MSG_load_entropy; 631.1Smartin option {src_legend(menu, MSG_Host, nfs_host);}, 641.1Smartin action { src_prompt(MSG_Host, nfs_host, sizeof nfs_host); }; 651.1Smartin option {src_legend(menu, MSG_Base_dir, nfs_dir);}, 661.1Smartin action { src_prompt(MSG_Base_dir, nfs_dir, sizeof nfs_dir); }; 671.1Smartin option {src_legend(menu, MSG_entropy_file, entropy_file);}, 681.1Smartin action { src_prompt(MSG_set_entropy_file, entropy_file, sizeof entropy_file); }; 691.1Smartin option MSG_cancel, exit, 701.1Smartin action { *((int*)arg) = SET_RETRY; }; 711.1Smartin 721.1Smartin 731.1Smartin/* arg is an arg_rv*, pointing to a struct ftpinfo and a return value */ 741.1Smartinmenu entropy_ftpsource, y=-4, x=0, w=70, no box, no clear, 751.1Smartin exitstring MSG_download_entropy; 761.1Smartin option {src_legend(menu, MSG_Host, 771.1Smartin ((struct ftpinfo*)((arg_rv*)arg)->arg)->xfer_host[ 781.3Smartin XFER_HOST(((struct ftpinfo*) 791.3Smartin ((arg_rv*)arg)->arg)->xfer)]);}, 801.1Smartin action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg; 811.3Smartin src_prompt(MSG_Host, 821.3Smartin fpi->xfer_host[XFER_HOST(fpi->xfer)], 831.3Smartin sizeof fpi->xfer_host[XFER_HOST(fpi->xfer)]); }; 841.1Smartin option {src_legend(menu, MSG_entropy_path_and_file, entropy_file);}, 851.1Smartin action { src_prompt(MSG_entropy_path_and_file, 861.1Smartin entropy_file, sizeof entropy_file); }; 871.1Smartin option {src_legend(menu, MSG_User, 881.1Smartin ((struct ftpinfo*)((arg_rv*)arg)->arg)->user);}, 891.1Smartin action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg; 901.1Smartin src_prompt(MSG_User, fpi->user, sizeof fpi->user); 911.1Smartin fpi->pass[0] = 0; 921.1Smartin }; 931.1Smartin option {src_legend(menu, MSG_Password, 941.1Smartin strcmp(((struct ftpinfo*)((arg_rv*)arg)->arg)->user, 951.1Smartin "ftp") == 0 || 961.1Smartin ((struct ftpinfo*)((arg_rv*)arg)->arg)->pass[0] == 0 971.1Smartin ? ((struct ftpinfo*)((arg_rv*)arg)->arg)->pass 981.1Smartin : msg_string(MSG_hidden));}, 991.1Smartin action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg; 1001.1Smartin if (strcmp(fpi->user, "ftp") == 0) 1011.1Smartin src_prompt(MSG_email, fpi->pass, sizeof fpi->pass); 1021.1Smartin else { 1031.1Smartin msg_prompt_noecho(MSG_Password, "", 1041.1Smartin fpi->pass, sizeof fpi->pass); 1051.1Smartin } 1061.1Smartin }; 1071.1Smartin option {src_legend(menu, MSG_Proxy, 1081.1Smartin ((struct ftpinfo*)((arg_rv*)arg)->arg)->proxy);}, 1091.1Smartin action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg; 1101.1Smartin src_prompt(MSG_Proxy, fpi->proxy, sizeof fpi->proxy); 1111.1Smartin if (strcmp(fpi->proxy, "") == 0) { 1121.1Smartin unsetenv("ftp_proxy"); 1131.1Smartin unsetenv("http_proxy"); 1141.1Smartin } else { 1151.1Smartin setenv("ftp_proxy", fpi->proxy, 1); 1161.1Smartin setenv("http_proxy", fpi->proxy, 1); 1171.1Smartin } 1181.1Smartin }; 1191.1Smartin option MSG_cancel, exit, action { ((arg_rv*)arg)->rv = SET_RETRY; }; 1201.1Smartin 1211.1Smartin 1221.1Smartin/* arg is an int*, set to SET_RETRY when the menu is aborted */ 1231.1Smartinmenu entropy_localfs, y=-4, x=0, w=70, no box, no clear, 1241.1Smartin exitstring MSG_load_entropy; 1251.1Smartin display action { msg_display(MSG_entropy_localfs); }; 1261.1Smartin option {src_legend(menu, MSG_Device, localfs_dev);}, 1271.1Smartin action { src_prompt(MSG_dev, localfs_dev, sizeof localfs_dev);}; 1281.1Smartin option {src_legend(menu, MSG_File_system, localfs_fs);}, 1291.1Smartin action { src_prompt(MSG_filesys, localfs_fs, sizeof localfs_fs); }; 1301.1Smartin option {src_legend(menu, MSG_entropy_path_and_file, entropy_file);}, 1311.1Smartin action { src_prompt(MSG_entropy_path_and_file, entropy_file, sizeof entropy_file);}; 1321.1Smartin option MSG_cancel, exit, action { *((int*)arg) = SET_RETRY; }; 1331.1Smartin 134