xref: /freebsd/contrib/bsddialog/examples_library/msgbox.c (revision d9a42747950146bf03cda7f6e25d219253f8a57a)
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 #include <string.h>
14 
15 int main()
16 {
17 	int output;
18 	struct bsddialog_conf conf;
19 
20 	if (bsddialog_init() == BSDDIALOG_ERROR) {
21 		printf("Error: %s\n", bsddialog_geterror());
22 		return (1);
23 	}
24 
25 	bsddialog_initconf(&conf);
26 	conf.title = "msgbox";
27 	output = bsddialog_msgbox(&conf, "Example", 7, 20);
28 
29 	bsddialog_end();
30 
31 	switch (output) {
32 	case BSDDIALOG_ERROR:
33 		printf("Error %s\n", bsddialog_geterror());
34 		break;
35 	case BSDDIALOG_OK:
36 		printf("OK\n");
37 		break;
38 	}
39 
40 	return (output);
41 }