xref: /freebsd/contrib/bsddialog/lib/bsddialog_progressview.h (revision 61ba55bcf70f2340f9c943c9571113b3fd8eda69)
1d93b4d32SBaptiste Daroussin /*-
2d93b4d32SBaptiste Daroussin  * SPDX-License-Identifier: BSD-2-Clause
3d93b4d32SBaptiste Daroussin  *
4*61ba55bcSBaptiste Daroussin  * Copyright (c) 2021-2023 Alfonso Sabato Siciliano
5d93b4d32SBaptiste Daroussin  *
6d93b4d32SBaptiste Daroussin  * Redistribution and use in source and binary forms, with or without
7d93b4d32SBaptiste Daroussin  * modification, are permitted provided that the following conditions
8d93b4d32SBaptiste Daroussin  * are met:
9d93b4d32SBaptiste Daroussin  * 1. Redistributions of source code must retain the above copyright
10d93b4d32SBaptiste Daroussin  *    notice, this list of conditions and the following disclaimer.
11d93b4d32SBaptiste Daroussin  * 2. Redistributions in binary form must reproduce the above copyright
12d93b4d32SBaptiste Daroussin  *    notice, this list of conditions and the following disclaimer in the
13d93b4d32SBaptiste Daroussin  *    documentation and/or other materials provided with the distribution.
14d93b4d32SBaptiste Daroussin  *
15d93b4d32SBaptiste Daroussin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16d93b4d32SBaptiste Daroussin  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17d93b4d32SBaptiste Daroussin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18d93b4d32SBaptiste Daroussin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19d93b4d32SBaptiste Daroussin  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20d93b4d32SBaptiste Daroussin  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21d93b4d32SBaptiste Daroussin  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22d93b4d32SBaptiste Daroussin  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23d93b4d32SBaptiste Daroussin  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24d93b4d32SBaptiste Daroussin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25d93b4d32SBaptiste Daroussin  * SUCH DAMAGE.
26d93b4d32SBaptiste Daroussin  */
27d93b4d32SBaptiste Daroussin 
28d93b4d32SBaptiste Daroussin #ifndef _LIBBSDDIALOG_PROGRESSVIEW_H_
29d93b4d32SBaptiste Daroussin #define _LIBBSDDIALOG_PROGRESSVIEW_H_
30d93b4d32SBaptiste Daroussin 
31263660c0SAlfonso Siciliano /*
32263660c0SAlfonso Siciliano  * Undocumented API, DO NOT USE!
33263660c0SAlfonso Siciliano  * Please consider this file private: it is used by bsdinstall/distextract,
34263660c0SAlfonso Siciliano  * could be deleted or changed in the future.
35263660c0SAlfonso Siciliano  */
36263660c0SAlfonso Siciliano 
37d93b4d32SBaptiste Daroussin extern bool bsddialog_interruptprogview;
38d93b4d32SBaptiste Daroussin extern bool bsddialog_abortprogview;
39*61ba55bcSBaptiste Daroussin extern long long int bsddialog_total_progview;
40d93b4d32SBaptiste Daroussin 
41d93b4d32SBaptiste Daroussin struct bsddialog_fileminibar {
42263660c0SAlfonso Siciliano 	const char *path;
43263660c0SAlfonso Siciliano 	const char *label;
44263660c0SAlfonso Siciliano 	int status; /* next if BSDDIALOG_MG_DONE or BSDDIALOG_MG_FAILED */
45*61ba55bcSBaptiste Daroussin 	long long int size;
46*61ba55bcSBaptiste Daroussin 	long long int read;
47d93b4d32SBaptiste Daroussin };
48d93b4d32SBaptiste Daroussin 
49d93b4d32SBaptiste Daroussin struct bsddialog_progviewconf {
50263660c0SAlfonso Siciliano 	const char *fmtbottomstr;
51d93b4d32SBaptiste Daroussin 	unsigned int refresh; /* in seconds */
52d93b4d32SBaptiste Daroussin 	int (*callback)(struct bsddialog_fileminibar *minibar);
53d93b4d32SBaptiste Daroussin };
54d93b4d32SBaptiste Daroussin 
55d93b4d32SBaptiste Daroussin int
56263660c0SAlfonso Siciliano bsddialog_progressview (struct bsddialog_conf *conf, const char *text, int rows,
57d93b4d32SBaptiste Daroussin     int cols, struct bsddialog_progviewconf *pvconf, unsigned int nminibar,
58d93b4d32SBaptiste Daroussin     struct bsddialog_fileminibar *minibar);
59d93b4d32SBaptiste Daroussin 
60d93b4d32SBaptiste Daroussin #endif