1274116Sdteske/*-
2274116Sdteske * Copyright (c) 2013-2014 Devin Teske <dteske@FreeBSD.org>
3274116Sdteske * All rights reserved.
4274116Sdteske *
5274116Sdteske * Redistribution and use in source and binary forms, with or without
6274116Sdteske * modification, are permitted provided that the following conditions
7274116Sdteske * are met:
8274116Sdteske * 1. Redistributions of source code must retain the above copyright
9274116Sdteske *    notice, this list of conditions and the following disclaimer.
10274116Sdteske * 2. Redistributions in binary form must reproduce the above copyright
11274116Sdteske *    notice, this list of conditions and the following disclaimer in the
12274116Sdteske *    documentation and/or other materials provided with the distribution.
13274116Sdteske *
14274116Sdteske * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15274116Sdteske * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16274116Sdteske * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17274116Sdteske * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18274116Sdteske * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19274116Sdteske * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20274116Sdteske * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21274116Sdteske * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22274116Sdteske * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23274116Sdteske * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24274116Sdteske * SUCH DAMAGE.
25274116Sdteske *
26274116Sdteske * $FreeBSD$
27274116Sdteske */
28274116Sdteske
29274116Sdteske#ifndef _DIALOG_UTIL_H_
30274116Sdteske#define _DIALOG_UTIL_H_
31274116Sdteske
32274116Sdteske#include <sys/types.h>
33274116Sdteske
34274116Sdteske#include "dialogrc.h"
35274116Sdteske
36274116Sdteske#define DIALOG_SPAWN_DEBUG	0	/* Debug spawning of [X]dialog(1) */
37274116Sdteske
38274116Sdteske/* dialog(3) and [X]dialog(1) characteristics */
39274116Sdteske#define DIALOG		"dialog"
40274116Sdteske#define XDIALOG		"Xdialog"
41274116Sdteske#define PROMPT_MAX	16384
42274116Sdteske#define ENV_DIALOG	"DIALOG"
43274116Sdteske#define ENV_USE_COLOR	"USE_COLOR"
44274116Sdteske#define ENV_XDIALOG_HIGH_DIALOG_COMPAT	"XDIALOG_HIGH_DIALOG_COMPAT"
45274116Sdteskeextern uint8_t dialog_test;
46274116Sdteskeextern uint8_t use_libdialog;
47274116Sdteskeextern uint8_t use_dialog;
48274116Sdteskeextern uint8_t use_xdialog;
49274116Sdteskeextern uint8_t use_color;
50274116Sdteskeextern char dialog[];
51274116Sdteske
52274116Sdteske/* dialog(3) and [X]dialog(1) functionality */
53274116Sdteskeextern char *title, *backtitle;
54274116Sdteskeextern int dheight, dwidth;
55274116Sdteske
56274116Sdteske__BEGIN_DECLS
57274116Sdteskeuint8_t		 dialog_prompt_nlstate(const char *_prompt);
58274116Sdteskevoid		 dialog_maxsize_free(void);
59274116Sdteskechar		*dialog_prompt_lastline(char *_prompt, uint8_t _nlstate);
60274116Sdteskeint		 dialog_maxcols(void);
61274116Sdteskeint		 dialog_maxrows(void);
62274116Sdteskeint		 dialog_prompt_wrappedlines(char *_prompt, int _ncols,
63274116Sdteske		    uint8_t _nlstate);
64274116Sdteskeint		 dialog_spawn_gauge(char *_init_prompt, pid_t *_pid);
65274116Sdteskeint		 tty_maxcols(void);
66274116Sdteske#define		 tty_maxrows() dialog_maxrows()
67274116Sdteskeunsigned int	 dialog_prompt_longestline(const char *_prompt,
68274116Sdteske		    uint8_t _nlstate);
69274116Sdteskeunsigned int	 dialog_prompt_numlines(const char *_prompt, uint8_t _nlstate);
70274116Sdteske__END_DECLS
71274116Sdteske
72274116Sdteske#endif /* !_DIALOG_UTIL_H_ */
73