/* $NetBSD: menus.entropy,v 1.2.2.1 2023/12/26 05:54:16 snj 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 -- entropy setup */ /* arg is an int*, returning a magic value for the selected menu option */ menu not_enough_entropy, title MSG_not_enough_entropy, y=-1, no box, clear, exit, exitstring MSG_continue_without_entropy; option MSG_entropy_add_manually, exit, action { *((int*)arg) = 1; }; option MSG_entropy_download_seed, exit, action { *((int*)arg) = 2; }; option MSG_entropy_download_raw, exit, action { *((int*)arg) = 3; }; option MSG_entropy_retry, exit, action { *((int*)arg) = 4; }; /* arg is an int*, returning a magic value for the selected menu option */ menu entropy_select_file, title MSG_entropy_select_file, y=-5, box, exit, exitstring MSG_cancel; option MSG_entropy_add_download_http, exit, action { *((int*)arg) = 1; }; option MSG_entropy_add_download_ftp, exit, action { *((int*)arg) = 2; }; option MSG_entropy_add_nfs, exit, action { *((int*)arg) = 3; }; option MSG_entropy_add_local, exit, action { *((int*)arg) = 4; }; /* arg is an int*, set to SET_RETRY when the menu is aborted */ menu entropy_nfssource, y=-5, x=0, w=70, no box, no clear, exitstring MSG_load_entropy; 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_entropy_file, entropy_file);}, action { src_prompt(MSG_set_entropy_file, entropy_file, sizeof entropy_file); }; option MSG_cancel, exit, action { *((int*)arg) = SET_RETRY; }; /* arg is an arg_rv*, pointing to a struct ftpinfo and a return value */ menu entropy_ftpsource, y=-4, x=0, w=70, no box, no clear, exitstring MSG_download_entropy; option {src_legend(menu, MSG_Host, ((struct ftpinfo*)((arg_rv*)arg)->arg)->xfer_host[ XFER_HOST(((struct ftpinfo*) ((arg_rv*)arg)->arg)->xfer)]);}, action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg; src_prompt(MSG_Host, fpi->xfer_host[XFER_HOST(fpi->xfer)], sizeof fpi->xfer_host[XFER_HOST(fpi->xfer)]); }; option {src_legend(menu, MSG_entropy_path_and_file, entropy_file);}, action { src_prompt(MSG_entropy_path_and_file, entropy_file, sizeof entropy_file); }; option {src_legend(menu, MSG_User, ((struct ftpinfo*)((arg_rv*)arg)->arg)->user);}, action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg; src_prompt(MSG_User, fpi->user, sizeof fpi->user); fpi->pass[0] = 0; }; option {src_legend(menu, MSG_Password, strcmp(((struct ftpinfo*)((arg_rv*)arg)->arg)->user, "ftp") == 0 || ((struct ftpinfo*)((arg_rv*)arg)->arg)->pass[0] == 0 ? ((struct ftpinfo*)((arg_rv*)arg)->arg)->pass : msg_string(MSG_hidden));}, action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg; if (strcmp(fpi->user, "ftp") == 0) src_prompt(MSG_email, fpi->pass, sizeof fpi->pass); else { msg_prompt_noecho(MSG_Password, "", fpi->pass, sizeof fpi->pass); } }; option {src_legend(menu, MSG_Proxy, ((struct ftpinfo*)((arg_rv*)arg)->arg)->proxy);}, action { struct ftpinfo *fpi = (struct ftpinfo*)((arg_rv*)arg)->arg; src_prompt(MSG_Proxy, fpi->proxy, sizeof fpi->proxy); if (strcmp(fpi->proxy, "") == 0) { unsetenv("ftp_proxy"); unsetenv("http_proxy"); } else { setenv("ftp_proxy", fpi->proxy, 1); setenv("http_proxy", fpi->proxy, 1); } }; option MSG_cancel, exit, action { ((arg_rv*)arg)->rv = SET_RETRY; }; /* arg is an int*, set to SET_RETRY when the menu is aborted */ menu entropy_localfs, y=-4, x=0, w=70, no box, no clear, exitstring MSG_load_entropy; display action { msg_display(MSG_entropy_localfs); }; 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_entropy_path_and_file, entropy_file);}, action { src_prompt(MSG_entropy_path_and_file, entropy_file, sizeof entropy_file);}; option MSG_cancel, exit, action { *((int*)arg) = SET_RETRY; };