diff --git a/contrib/bsddialog/bsddialog.c b/contrib/bsddialog/bsddialog.c index a902d751dab0..d84df4b494d9 100644 --- a/contrib/bsddialog/bsddialog.c +++ b/contrib/bsddialog/bsddialog.c @@ -1,1430 +1,1431 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2021-2022 Alfonso Sabato Siciliano * * 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 AUTHOR 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 AUTHOR 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. */ #include #include #include #include #include #include #include #include #include #include #include #define BSDDIALOG_VERSION "0.2" enum OPTS { /* Common options */ ASCII_LINES = '?' + 1, BACKTITLE, BEGIN_X, BEGIN_Y, CANCEL_LABEL, CLEAR, COLORS, CR_WRAP, DATE_FORMAT, DEFAULT_BUTTON, DEFAULT_ITEM, DEFAULT_NO, DISABLE_ESC, ESC_CANCELVALUE, EXIT_LABEL, EXTRA_BUTTON, EXTRA_LABEL, GENERIC_BUTTON1, GENERIC_BUTTON2, HELP, HELP_BUTTON, HELP_LABEL, HELP_STATUS, HELP_TAGS, HFILE, HLINE, HMSG, IGNORE, INSECURE, ITEM_DEPTH, ITEM_HELP, ITEM_PREFIX, MAX_INPUT, NO_CANCEL, NO_COLLAPSE, NO_ITEMS, NO_LINES, NO_NL_EXPAND, NO_OK, NO_SHADOW, NO_TAGS, OK_LABEL, OUTPUT_FD, OUTPUT_SEPARATOR, PRINT_MAXSIZE, PRINT_SIZE, PRINT_VERSION, QUOTED, SEPARATE_OUTPUT, SHADOW, SINGLE_QUOTED, SLEEP, STDERR, STDOUT, TAB_LEN, THEME, TIME_FORMAT, TITLE, TRIM, VERSION, /* Dialogs */ CHECKLIST, DATEBOX, FORM, GAUGE, INFOBOX, INPUTBOX, MENU, MIXEDFORM, MIXEDGAUGE, MSGBOX, PASSWORDBOX, PASSWORDFORM, PAUSE, RADIOLIST, RANGEBOX, TEXTBOX, TIMEBOX, TREEVIEW, YESNO }; /* Menus options */ static bool item_prefix_opt, item_bottomdesc_opt, item_output_sepnl_opt; static bool item_singlequote_opt, list_items_on_opt, item_tag_help_opt; static bool item_always_quote_opt, item_depth_opt; static char *item_output_sep_opt, *item_default_opt; /* Date and Time options */ static char *date_fmt_opt, *time_fmt_opt; /* Forms options */ static int unsigned max_input_form_opt; /* General options */ static int output_fd_opt; static void custom_text(bool cr_wrap, bool no_collapse, bool no_nl_expand, bool trim, char *text, char *buf); static void sigint_handler(int sig); /* Dialogs */ #define BUILDER_ARGS struct bsddialog_conf conf, char* text, int rows, \ int cols, int argc, char **argv, char *errbuf static int checklist_builder(BUILDER_ARGS); static int datebox_builder(BUILDER_ARGS); static int form_builder(BUILDER_ARGS); static int gauge_builder(BUILDER_ARGS); static int infobox_builder(BUILDER_ARGS); static int inputbox_builder(BUILDER_ARGS); static int menu_builder(BUILDER_ARGS); static int mixedform_builder(BUILDER_ARGS); static int mixedgauge_builder(BUILDER_ARGS); static int msgbox_builder(BUILDER_ARGS); static int passwordbox_builder(BUILDER_ARGS); static int passwordform_builder(BUILDER_ARGS); static int pause_builder(BUILDER_ARGS); static int radiolist_builder(BUILDER_ARGS); static int rangebox_builder(BUILDER_ARGS); static int textbox_builder(BUILDER_ARGS); static int timebox_builder(BUILDER_ARGS); static int treeview_builder(BUILDER_ARGS); static int yesno_builder(BUILDER_ARGS); static void usage(void) { printf("usage: bsddialog --help\n"); printf(" bsddialog --version\n"); printf(" bsddialog [--] -- " " [--]\n"); printf("\n"); printf("Common Options:\n"); printf("--ascii-lines, --backtitle , --begin-x , " "--begin-y , --cancel-label