/*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2021-2023 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 "util.h" enum OPTS { /* Options */ ALTERNATE_SCREEN = '?' + 1, AND_DIALOG, ASCII_LINES, BACKTITLE, BEGIN_X, BEGIN_Y, BIKESHED, CANCEL_EXIT_CODE, CANCEL_LABEL, CLEAR_DIALOG, CLEAR_SCREEN, COLUMNS_PER_ROW, CR_WRAP, DATEBOX_FORMAT, DATE_FORMAT, DEFAULT_BUTTON, DEFAULT_ITEM, DEFAULT_NO, DISABLE_ESC, ERROR_EXIT_CODE, ESC_EXIT_CODE, EXIT_LABEL, EXTRA_BUTTON, EXTRA_EXIT_CODE, EXTRA_LABEL, HELP_BUTTON, HELP_EXIT_CODE, HELP_LABEL, HELP_PRINT_ITEMS, HELP_PRINT_NAME, HFILE, HLINE, HMSG, IGNORE, INSECURE, ITEM_BOTTOM_DESC, ITEM_DEPTH, ITEM_PREFIX, LEFT1_BUTTON, LEFT1_EXIT_CODE, LEFT2_BUTTON, LEFT2_EXIT_CODE, LEFT3_BUTTON, LEFT3_EXIT_CODE, LOAD_THEME, MAX_INPUT_FORM, NO_CANCEL, NO_DESCRIPTIONS, NO_LINES, NO_NAMES, NO_OK, NO_SHADOW, NORMAL_SCREEN, OK_EXIT_CODE, OK_LABEL, OUTPUT_FD, OUTPUT_SEPARATOR, PRINT_MAXSIZE, PRINT_SIZE, PRINT_VERSION, QUOTED, RIGHT1_BUTTON, RIGHT1_EXIT_CODE, RIGHT2_BUTTON, RIGHT2_EXIT_CODE, RIGHT3_BUTTON, RIGHT3_EXIT_CODE, SAVE_THEME, SEPARATE_OUTPUT, SHADOW, SINGLE_QUOTED, SLEEP, STDERR, STDOUT, SWITCH_BUTTONS, TAB_ESCAPE, TAB_LEN, TEXT_ESCAPE, TEXT_UNCHANGED, THEME, TIMEOUT_EXIT_CODE, TIME_FORMAT, TITLE, /* Dialogs */ CALENDAR, CHECKLIST, DATEBOX, FORM, GAUGE, INFOBOX, INPUTBOX, MENU, MIXEDFORM, MIXEDGAUGE, MSGBOX, PASSWORDBOX, PASSWORDFORM, PAUSE, RADIOLIST, RANGEBOX, TEXTBOX, TIMEBOX, TREEVIEW, YESNO }; /* options descriptor */ static struct option longopts[] = { /* Options */ {"alternate-screen", no_argument, NULL, ALTERNATE_SCREEN}, {"and-dialog", no_argument, NULL, AND_DIALOG}, {"and-widget", no_argument, NULL, AND_DIALOG}, {"ascii-lines", no_argument, NULL, ASCII_LINES}, {"backtitle", required_argument, NULL, BACKTITLE}, {"begin-x", required_argument, NULL, BEGIN_X}, {"begin-y", required_argument, NULL, BEGIN_Y}, {"bikeshed", no_argument, NULL, BIKESHED}, {"cancel-exit-code", required_argument, NULL, CANCEL_EXIT_CODE}, {"cancel-label", required_argument, NULL, CANCEL_LABEL}, {"clear", no_argument, NULL, CLEAR_SCREEN}, {"clear-dialog", no_argument, NULL, CLEAR_DIALOG}, {"clear-screen", no_argument, NULL, CLEAR_SCREEN}, {"colors", no_argument, NULL, TEXT_ESCAPE}, {"columns-per-row", required_argument, NULL, COLUMNS_PER_ROW}, {"cr-wrap", no_argument, NULL, CR_WRAP}, {"datebox-format", required_argument, NULL, DATEBOX_FORMAT}, {"date-format", required_argument, NULL, DATE_FORMAT}, {"defaultno", no_argument, NULL, DEFAULT_NO}, {"default-button", required_argument, NULL, DEFAULT_BUTTON}, {"default-item", required_argument, NULL, DEFAULT_ITEM}, {"default-no", no_argument, NULL, DEFAULT_NO}, {"disable-esc", no_argument, NULL, DISABLE_ESC}, {"error-exit-code", required_argument, NULL, ERROR_EXIT_CODE}, {"esc-exit-code", required_argument, NULL, ESC_EXIT_CODE}, {"exit-label", required_argument, NULL, EXIT_LABEL}, {"extra-button", no_argument, NULL, EXTRA_BUTTON}, {"extra-exit-code", required_argument, NULL, EXTRA_EXIT_CODE}, {"extra-label", required_argument, NULL, EXTRA_LABEL}, {"help-button", no_argument, NULL, HELP_BUTTON}, {"help-exit-code", required_argument, NULL, HELP_EXIT_CODE}, {"help-label", required_argument, NULL, HELP_LABEL}, {"help-print-items", no_argument, NULL, HELP_PRINT_ITEMS}, {"help-print-name", no_argument, NULL, HELP_PRINT_NAME}, {"help-status", no_argument, NULL, HELP_PRINT_ITEMS}, {"help-tags", no_argument, NULL, HELP_PRINT_NAME}, {"hfile", required_argument, NULL, HFILE}, {"hline", required_argument, NULL, HLINE}, {"hmsg", required_argument, NULL, HMSG}, {"ignore", no_argument, NULL, IGNORE}, {"insecure", no_argument, NULL, INSECURE}, {"item-bottom-desc", no_argument, NULL, ITEM_BOTTOM_DESC}, {"item-depth", no_argument, NULL, ITEM_DEPTH}, {"item-help", no_argument, NULL, ITEM_BOTTOM_DESC}, {"item-prefix", no_argument, NULL, ITEM_PREFIX}, {"keep-tite", no_argument, NULL, ALTERNATE_SCREEN}, {"left1-button", required_argument, NULL, LEFT1_BUTTON}, {"left1-exit-code", required_argument, NULL, LEFT1_EXIT_CODE}, {"left2-button", required_argument, NULL, LEFT2_BUTTON}, {"left2-exit-code", required_argument, NULL, LEFT2_EXIT_CODE}, {"left3-button", required_argument, NULL, LEFT3_BUTTON}, {"left3-exit-code", required_argument, NULL, LEFT3_EXIT_CODE}, {"load-theme", required_argument, NULL, LOAD_THEME}, {"max-input", required_argument, NULL, MAX_INPUT_FORM}, {"no-cancel", no_argument, NULL, NO_CANCEL}, {"nocancel", no_argument, NULL, NO_CANCEL}, {"no-descriptions", no_argument, NULL, NO_DESCRIPTIONS}, {"no-items", no_argument, NULL, NO_DESCRIPTIONS}, {"no-label", required_argument, NULL, CANCEL_LABEL}, {"no-lines", no_argument, NULL, NO_LINES}, {"no-names", no_argument, NULL, NO_NAMES}, {"no-ok", no_argument, NULL, NO_OK}, {"nook", no_argument, NULL, NO_OK}, {"no-shadow", no_argument, NULL, NO_SHADOW}, {"no-tags", no_argument, NULL, NO_NAMES}, {"normal-screen", no_argument, NULL, NORMAL_SCREEN}, {"ok-exit-code", required_argument, NULL, OK_EXIT_CODE}, {"ok-label", required_argument, NULL, OK_LABEL}, {"output-fd", required_argument, NULL, OUTPUT_FD}, {"output-separator", required_argument, NULL, OUTPUT_SEPARATOR}, {"print-maxsize", no_argument, NULL, PRINT_MAXSIZE}, {"print-size", no_argument, NULL, PRINT_SIZE}, {"print-version", no_argument, NULL, PRINT_VERSION}, {"quoted", no_argument, NULL, QUOTED}, {"right1-button", required_argument, NULL, RIGHT1_BUTTON}, {"right1-exit-code", required_argument, NULL, RIGHT1_EXIT_CODE}, {"right2-button", required_argument, NULL, RIGHT2_BUTTON}, {"right2-exit-code", required_argument, NULL, RIGHT2_EXIT_CODE}, {"right3-button", required_argument, NULL, RIGHT3_BUTTON}, {"right3-exit-code", required_argument, NULL, RIGHT3_EXIT_CODE}, {"save-theme", required_argument, NULL, SAVE_THEME}, {"separate-output", no_argument, NULL, SEPARATE_OUTPUT}, {"separator", required_argument, NULL, OUTPUT_SEPARATOR}, {"shadow", no_argument, NULL, SHADOW}, {"single-quoted", no_argument, NULL, SINGLE_QUOTED}, {"sleep", required_argument, NULL, SLEEP}, {"stderr", no_argument, NULL, STDERR}, {"stdout", no_argument, NULL, STDOUT}, {"switch-buttons", no_argument, NULL, SWITCH_BUTTONS}, {"tab-escape", no_argument, NULL, TAB_ESCAPE}, {"tab-len", required_argument, NULL, TAB_LEN}, {"text-escape", no_argument, NULL, TEXT_ESCAPE}, {"text-unchanged", no_argument, NULL, TEXT_UNCHANGED}, {"theme", required_argument, NULL, THEME}, {"timeout-exit-code", required_argument, NULL, TIMEOUT_EXIT_CODE}, {"time-format", required_argument, NULL, TIME_FORMAT}, {"title", required_argument, NULL, TITLE}, {"yes-label", required_argument, NULL, OK_LABEL}, /* Dialogs */ {"calendar", no_argument, NULL, CALENDAR}, {"checklist", no_argument, NULL, CHECKLIST}, {"datebox", no_argument, NULL, DATEBOX}, {"form", no_argument, NULL, FORM}, {"gauge", no_argument, NULL, GAUGE}, {"infobox", no_argument, NULL, INFOBOX}, {"inputbox", no_argument, NULL, INPUTBOX}, {"menu", no_argument, NULL, MENU}, {"mixedform", no_argument, NULL, MIXEDFORM}, {"mixedgauge", no_argument, NULL, MIXEDGAUGE}, {"msgbox", no_argument, NULL, MSGBOX}, {"passwordbox", no_argument, NULL, PASSWORDBOX}, {"passwordform", no_argument, NULL, PASSWORDFORM}, {"pause", no_argument, NULL, PAUSE}, {"radiolist", no_argument, NULL, RADIOLIST}, {"rangebox", no_argument, NULL, RANGEBOX}, {"textbox", no_argument, NULL, TEXTBOX}, {"timebox", no_argument, NULL, TIMEBOX}, {"treeview", no_argument, NULL, TREEVIEW}, {"yesno", no_argument, NULL, YESNO}, /* END */ { NULL, 0, NULL, 0} }; void usage(void) { printf("usage: bsddialog --help | --version\n"); printf(" bsddialog [--] -- " "[] [--]\n"); printf(" bsddialog ... -- ... [--and-dialog -- " "...] ...\n"); printf("\n"); printf("Options:\n"); printf(" --alternate-screen, --ascii-lines, --backtitle ," " --begin-x ,\n --begin-y , --bikeshed," " --cancel-exit-code , --cancel-label