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