1*041394f3SDevin Teske /*- 2*041394f3SDevin Teske * Copyright (c) 2013-2014 Devin Teske <dteske@FreeBSD.org> 3*041394f3SDevin Teske * All rights reserved. 4*041394f3SDevin Teske * 5*041394f3SDevin Teske * Redistribution and use in source and binary forms, with or without 6*041394f3SDevin Teske * modification, are permitted provided that the following conditions 7*041394f3SDevin Teske * are met: 8*041394f3SDevin Teske * 1. Redistributions of source code must retain the above copyright 9*041394f3SDevin Teske * notice, this list of conditions and the following disclaimer. 10*041394f3SDevin Teske * 2. Redistributions in binary form must reproduce the above copyright 11*041394f3SDevin Teske * notice, this list of conditions and the following disclaimer in the 12*041394f3SDevin Teske * documentation and/or other materials provided with the distribution. 13*041394f3SDevin Teske * 14*041394f3SDevin Teske * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*041394f3SDevin Teske * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*041394f3SDevin Teske * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*041394f3SDevin Teske * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*041394f3SDevin Teske * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*041394f3SDevin Teske * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*041394f3SDevin Teske * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*041394f3SDevin Teske * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*041394f3SDevin Teske * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*041394f3SDevin Teske * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*041394f3SDevin Teske * SUCH DAMAGE. 25*041394f3SDevin Teske */ 26*041394f3SDevin Teske 27*041394f3SDevin Teske #ifndef _DIALOG_UTIL_H_ 28*041394f3SDevin Teske #define _DIALOG_UTIL_H_ 29*041394f3SDevin Teske 30*041394f3SDevin Teske #include <sys/types.h> 31*041394f3SDevin Teske 32*041394f3SDevin Teske #include "dialogrc.h" 33*041394f3SDevin Teske 34*041394f3SDevin Teske #define DIALOG_SPAWN_DEBUG 0 /* Debug spawning of [X]dialog(1) */ 35*041394f3SDevin Teske 36*041394f3SDevin Teske /* dialog(3) and [X]dialog(1) characteristics */ 37*041394f3SDevin Teske #define DIALOG "dialog" 38*041394f3SDevin Teske #define XDIALOG "Xdialog" 39*041394f3SDevin Teske #define PROMPT_MAX 16384 40*041394f3SDevin Teske #define ENV_DIALOG "DIALOG" 41*041394f3SDevin Teske #define ENV_USE_COLOR "USE_COLOR" 42*041394f3SDevin Teske #define ENV_XDIALOG_HIGH_DIALOG_COMPAT "XDIALOG_HIGH_DIALOG_COMPAT" 43*041394f3SDevin Teske extern uint8_t dialog_test; 44*041394f3SDevin Teske extern uint8_t use_libdialog; 45*041394f3SDevin Teske extern uint8_t use_dialog; 46*041394f3SDevin Teske extern uint8_t use_xdialog; 47*041394f3SDevin Teske extern uint8_t use_color; 48*041394f3SDevin Teske extern char dialog[]; 49*041394f3SDevin Teske 50*041394f3SDevin Teske /* dialog(3) and [X]dialog(1) functionality */ 51*041394f3SDevin Teske extern char *title, *backtitle; 52*041394f3SDevin Teske extern int dheight, dwidth; 53*041394f3SDevin Teske 54*041394f3SDevin Teske __BEGIN_DECLS 55*041394f3SDevin Teske uint8_t dialog_prompt_nlstate(const char *_prompt); 56*041394f3SDevin Teske void dialog_maxsize_free(void); 57*041394f3SDevin Teske char *dialog_prompt_lastline(char *_prompt, uint8_t _nlstate); 58*041394f3SDevin Teske int dialog_maxcols(void); 59*041394f3SDevin Teske int dialog_maxrows(void); 60*041394f3SDevin Teske int dialog_prompt_wrappedlines(char *_prompt, int _ncols, 61*041394f3SDevin Teske uint8_t _nlstate); 62*041394f3SDevin Teske int dialog_spawn_gauge(char *_init_prompt, pid_t *_pid); 63*041394f3SDevin Teske int tty_maxcols(void); 64*041394f3SDevin Teske #define tty_maxrows() dialog_maxrows() 65*041394f3SDevin Teske unsigned int dialog_prompt_longestline(const char *_prompt, 66*041394f3SDevin Teske uint8_t _nlstate); 67*041394f3SDevin Teske unsigned int dialog_prompt_numlines(const char *_prompt, uint8_t _nlstate); 68*041394f3SDevin Teske __END_DECLS 69*041394f3SDevin Teske 70*041394f3SDevin Teske #endif /* !_DIALOG_UTIL_H_ */ 71