xref: /freebsd/contrib/bsddialog/examples_library/msgbox.c (revision edf8578117e8844e02c0121147f45e4609b30680)
1 /*-
2  * SPDX-License-Identifier: CC0-1.0
3  *
4  * Written in 2021 by Alfonso Sabato Siciliano.
5  * To the extent possible under law, the author has dedicated all copyright
6  * and related and neighboring rights to this software to the public domain
7  * worldwide. This software is distributed without any warranty, see:
8  *   <http://creativecommons.org/publicdomain/zero/1.0/>.
9  */
10 
11 #include <bsddialog.h>
12 #include <stdio.h>
13 
14 int main()
15 {
16 	int output;
17 	struct bsddialog_conf conf;
18 
19 	if (bsddialog_init() == BSDDIALOG_ERROR) {
20 		printf("Error: %s\n", bsddialog_geterror());
21 		return (1);
22 	}
23 	bsddialog_initconf(&conf);
24 	conf.title = "msgbox";
25 	output = bsddialog_msgbox(&conf, "Example", 7, 20);
26 	bsddialog_end();
27 
28 	switch (output) {
29 	case BSDDIALOG_ERROR:
30 		printf("Error %s\n", bsddialog_geterror());
31 		return (1);
32 	case BSDDIALOG_OK:
33 		printf("[OK]\n");
34 		break;
35 	}
36 
37 	return (0);
38 }