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