freebsd-src/contrib/bsddialog/examples_library/gauge.c
Alfonso S. Siciliano a6d8be451f
contrib/bsddialog: Import version 1.0.2
Implicitly import also 1.0.1, both versions are for fixing and
feature requests.

Fixing:
Change --mixedform behavior to fix a bsdinstall fault avoiding
to change the command line in wlanconfig.

Feature requests:
 * Add keys to navigate menus.
 * Add key to redraw dialogs.
 * Avoid to handle env NCURSES_NO_UTF8_ACS in PuTTY.

See '2024-04-11 Version 1.0.2' and '2023-11-16 Version 1.0.1' in
/usr/src/contrib/bsddialog/CHANGELOG for more detailed information.

PR:			274472
Differential Revision:	D42380

Merge commit 'be8846bd9e069f4a6bea3d769005bea96cf43990'
2024-05-16 15:32:56 +02:00

57 lines
1.2 KiB
C

/*-
* SPDX-License-Identifier: CC0-1.0
*
* Written in 2023 by Alfonso Sabato Siciliano.
* To the extent possible under law, the author has dedicated all copyright
* and related and neighboring rights to this software to the public domain
* worldwide. This software is distributed without any warranty, see:
* <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
#include <bsddialog.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static void sender(int fd)
{
int i;
for (i = 1; i <= 10; i++) {
sleep(1);
dprintf(fd, "SEP\n");
dprintf(fd, "%d\n", i * 10);
dprintf(fd, "In Progress... [%d / 10]\n", i);
dprintf(fd, "SEP\n");
}
sleep(1);
dprintf(fd, "EOF\n");
}
int main()
{
int rv, fd[2];
struct bsddialog_conf conf;
/* add checks and sync */
pipe(fd);
if (fork() == 0) {
close(fd[0]);
sender(fd[1]);
exit (0);
}
close(fd[1]);
if (bsddialog_init() == BSDDIALOG_ERROR) {
printf("Error: %s\n", bsddialog_geterror());
return (1);
}
bsddialog_initconf(&conf);
conf.title = "gauge";
rv = bsddialog_gauge(&conf, "Example", 7, 30, 0, fd[0], "SEP", "EOF");
bsddialog_end();
if (rv == BSDDIALOG_ERROR)
printf("Error: %s\n", bsddialog_geterror());
return (0);
}