1*61ba55bcSBaptiste Daroussin /*- 2*61ba55bcSBaptiste Daroussin * SPDX-License-Identifier: BSD-2-Clause 3*61ba55bcSBaptiste Daroussin * 4*61ba55bcSBaptiste Daroussin * Copyright (c) 2021-2023 Alfonso Sabato Siciliano 5*61ba55bcSBaptiste Daroussin * 6*61ba55bcSBaptiste Daroussin * Redistribution and use in source and binary forms, with or without 7*61ba55bcSBaptiste Daroussin * modification, are permitted provided that the following conditions 8*61ba55bcSBaptiste Daroussin * are met: 9*61ba55bcSBaptiste Daroussin * 1. Redistributions of source code must retain the above copyright 10*61ba55bcSBaptiste Daroussin * notice, this list of conditions and the following disclaimer. 11*61ba55bcSBaptiste Daroussin * 2. Redistributions in binary form must reproduce the above copyright 12*61ba55bcSBaptiste Daroussin * notice, this list of conditions and the following disclaimer in the 13*61ba55bcSBaptiste Daroussin * documentation and/or other materials provided with the distribution. 14*61ba55bcSBaptiste Daroussin * 15*61ba55bcSBaptiste Daroussin * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16*61ba55bcSBaptiste Daroussin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17*61ba55bcSBaptiste Daroussin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18*61ba55bcSBaptiste Daroussin * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19*61ba55bcSBaptiste Daroussin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20*61ba55bcSBaptiste Daroussin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21*61ba55bcSBaptiste Daroussin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22*61ba55bcSBaptiste Daroussin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23*61ba55bcSBaptiste Daroussin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24*61ba55bcSBaptiste Daroussin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25*61ba55bcSBaptiste Daroussin * SUCH DAMAGE. 26*61ba55bcSBaptiste Daroussin */ 27*61ba55bcSBaptiste Daroussin 28*61ba55bcSBaptiste Daroussin #ifndef _BSDDIALOG_UTIL_H_ 29*61ba55bcSBaptiste Daroussin #define _BSDDIALOG_UTIL_H_ 30*61ba55bcSBaptiste Daroussin 31*61ba55bcSBaptiste Daroussin /* 32*61ba55bcSBaptiste Daroussin * Exit codes and errors, bsddialog.c 33*61ba55bcSBaptiste Daroussin */ 34*61ba55bcSBaptiste Daroussin #define BSDDIALOG_ITEM_HELP 12 35*61ba55bcSBaptiste Daroussin 36*61ba55bcSBaptiste Daroussin void set_exit_code(int lib_retval, int exitcode); 37*61ba55bcSBaptiste Daroussin void exit_error(bool usage, const char *fmt, ...); 38*61ba55bcSBaptiste Daroussin void error_args(const char *dialog, int argc, char **argv); 39*61ba55bcSBaptiste Daroussin 40*61ba55bcSBaptiste Daroussin /* 41*61ba55bcSBaptiste Daroussin * Command Line, util_cli.c 42*61ba55bcSBaptiste Daroussin */ 43*61ba55bcSBaptiste Daroussin struct options { 44*61ba55bcSBaptiste Daroussin /* Menus options */ 45*61ba55bcSBaptiste Daroussin bool item_always_quote; 46*61ba55bcSBaptiste Daroussin char *item_default; 47*61ba55bcSBaptiste Daroussin bool item_depth; 48*61ba55bcSBaptiste Daroussin char *item_output_sep; 49*61ba55bcSBaptiste Daroussin bool item_output_sepnl; 50*61ba55bcSBaptiste Daroussin bool item_prefix; 51*61ba55bcSBaptiste Daroussin bool item_singlequote; 52*61ba55bcSBaptiste Daroussin /* Menus and Forms options */ 53*61ba55bcSBaptiste Daroussin bool help_print_item_name; 54*61ba55bcSBaptiste Daroussin bool help_print_items; 55*61ba55bcSBaptiste Daroussin bool item_bottomdesc; 56*61ba55bcSBaptiste Daroussin /* Forms options */ 57*61ba55bcSBaptiste Daroussin int unsigned max_input_form; 58*61ba55bcSBaptiste Daroussin /* Date and Time options */ 59*61ba55bcSBaptiste Daroussin char *date_fmt; 60*61ba55bcSBaptiste Daroussin char *time_fmt; 61*61ba55bcSBaptiste Daroussin /* General options */ 62*61ba55bcSBaptiste Daroussin int getH; 63*61ba55bcSBaptiste Daroussin int getW; 64*61ba55bcSBaptiste Daroussin bool ignore; 65*61ba55bcSBaptiste Daroussin int output_fd; 66*61ba55bcSBaptiste Daroussin /* Text option */ 67*61ba55bcSBaptiste Daroussin bool cr_wrap; 68*61ba55bcSBaptiste Daroussin bool tab_escape; 69*61ba55bcSBaptiste Daroussin bool text_unchanged; 70*61ba55bcSBaptiste Daroussin /* Theme and Screen options*/ 71*61ba55bcSBaptiste Daroussin char *backtitle; 72*61ba55bcSBaptiste Daroussin bool bikeshed; 73*61ba55bcSBaptiste Daroussin enum bsddialog_default_theme theme; 74*61ba55bcSBaptiste Daroussin bool clearscreen; 75*61ba55bcSBaptiste Daroussin char *loadthemefile; 76*61ba55bcSBaptiste Daroussin char *savethemefile; 77*61ba55bcSBaptiste Daroussin const char *screen_mode; 78*61ba55bcSBaptiste Daroussin /* Dialog */ 79*61ba55bcSBaptiste Daroussin bool mandatory_dialog; 80*61ba55bcSBaptiste Daroussin const char *name; 81*61ba55bcSBaptiste Daroussin int (*dialogbuilder)(struct bsddialog_conf *conf, char* text, int rows, 82*61ba55bcSBaptiste Daroussin int cols, int argc, char **argv, struct options *opt); 83*61ba55bcSBaptiste Daroussin }; 84*61ba55bcSBaptiste Daroussin 85*61ba55bcSBaptiste Daroussin void usage(void); 86*61ba55bcSBaptiste Daroussin int 87*61ba55bcSBaptiste Daroussin parseargs(int argc, char **argv, struct bsddialog_conf *conf, 88*61ba55bcSBaptiste Daroussin struct options *opt); 89*61ba55bcSBaptiste Daroussin 90*61ba55bcSBaptiste Daroussin /* 91*61ba55bcSBaptiste Daroussin * Dialogs builders, util_builders.c 92*61ba55bcSBaptiste Daroussin */ 93*61ba55bcSBaptiste Daroussin #define BUILDER_ARGS struct bsddialog_conf *conf, char* text, int rows, \ 94*61ba55bcSBaptiste Daroussin int cols, int argc, char **argv, struct options *opt 95*61ba55bcSBaptiste Daroussin int calendar_builder(BUILDER_ARGS); 96*61ba55bcSBaptiste Daroussin int checklist_builder(BUILDER_ARGS); 97*61ba55bcSBaptiste Daroussin int datebox_builder(BUILDER_ARGS); 98*61ba55bcSBaptiste Daroussin int form_builder(BUILDER_ARGS); 99*61ba55bcSBaptiste Daroussin int gauge_builder(BUILDER_ARGS); 100*61ba55bcSBaptiste Daroussin int infobox_builder(BUILDER_ARGS); 101*61ba55bcSBaptiste Daroussin int inputbox_builder(BUILDER_ARGS); 102*61ba55bcSBaptiste Daroussin int menu_builder(BUILDER_ARGS); 103*61ba55bcSBaptiste Daroussin int mixedform_builder(BUILDER_ARGS); 104*61ba55bcSBaptiste Daroussin int mixedgauge_builder(BUILDER_ARGS); 105*61ba55bcSBaptiste Daroussin int msgbox_builder(BUILDER_ARGS); 106*61ba55bcSBaptiste Daroussin int passwordbox_builder(BUILDER_ARGS); 107*61ba55bcSBaptiste Daroussin int passwordform_builder(BUILDER_ARGS); 108*61ba55bcSBaptiste Daroussin int pause_builder(BUILDER_ARGS); 109*61ba55bcSBaptiste Daroussin int radiolist_builder(BUILDER_ARGS); 110*61ba55bcSBaptiste Daroussin int rangebox_builder(BUILDER_ARGS); 111*61ba55bcSBaptiste Daroussin int textbox_builder(BUILDER_ARGS); 112*61ba55bcSBaptiste Daroussin int timebox_builder(BUILDER_ARGS); 113*61ba55bcSBaptiste Daroussin int treeview_builder(BUILDER_ARGS); 114*61ba55bcSBaptiste Daroussin int yesno_builder(BUILDER_ARGS); 115*61ba55bcSBaptiste Daroussin 116*61ba55bcSBaptiste Daroussin /* 117*61ba55bcSBaptiste Daroussin * Theme, util_theme.c 118*61ba55bcSBaptiste Daroussin */ 119*61ba55bcSBaptiste Daroussin void savetheme(const char *file); 120*61ba55bcSBaptiste Daroussin void loadtheme(const char *file, bool compatibility); 121*61ba55bcSBaptiste Daroussin void setdeftheme(enum bsddialog_default_theme theme); 122*61ba55bcSBaptiste Daroussin void bikeshed(struct bsddialog_conf *conf); 123*61ba55bcSBaptiste Daroussin void startuptheme(void); 124*61ba55bcSBaptiste Daroussin 125*61ba55bcSBaptiste Daroussin #endif 126