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