xref: /freebsd/contrib/bsddialog/examples_library/yesno.c (revision bce40c0242b167a541cc051b6b0dbcc5f3d04319)
1f499134dSBaptiste Daroussin /*-
2f499134dSBaptiste Daroussin  * SPDX-License-Identifier: CC0-1.0
3f499134dSBaptiste Daroussin  *
4f499134dSBaptiste Daroussin  * Written in 2021 by Alfonso Sabato Siciliano.
5f499134dSBaptiste Daroussin  * To the extent possible under law, the author has dedicated all copyright
6f499134dSBaptiste Daroussin  * and related and neighboring rights to this software to the public domain
7f499134dSBaptiste Daroussin  * worldwide. This software is distributed without any warranty, see:
8f499134dSBaptiste Daroussin  *   <http://creativecommons.org/publicdomain/zero/1.0/>.
9f499134dSBaptiste Daroussin  */
10f499134dSBaptiste Daroussin 
11*bce40c02SAlfonso S. Siciliano #include <bsddialog.h>
12f499134dSBaptiste Daroussin #include <stdio.h>
13f499134dSBaptiste Daroussin #include <string.h>
14f499134dSBaptiste Daroussin 
15f499134dSBaptiste Daroussin int main()
16f499134dSBaptiste Daroussin {
17f499134dSBaptiste Daroussin 	int output;
18f499134dSBaptiste Daroussin 	struct bsddialog_conf conf;
19f499134dSBaptiste Daroussin 
20263660c0SAlfonso Siciliano 	if (bsddialog_init() == BSDDIALOG_ERROR) {
21263660c0SAlfonso Siciliano 		printf("Error: %s\n", bsddialog_geterror());
22263660c0SAlfonso Siciliano 		return (1);
23263660c0SAlfonso Siciliano 	}
24263660c0SAlfonso Siciliano 
25f499134dSBaptiste Daroussin 	bsddialog_initconf(&conf);
26f499134dSBaptiste Daroussin 	conf.title = "yesno";
27f499134dSBaptiste Daroussin 	output = bsddialog_yesno(&conf, "Example", 7, 25);
28f499134dSBaptiste Daroussin 
29f499134dSBaptiste Daroussin 	bsddialog_end();
30f499134dSBaptiste Daroussin 
31263660c0SAlfonso Siciliano 	switch (output) {
32263660c0SAlfonso Siciliano 	case BSDDIALOG_ERROR:
33263660c0SAlfonso Siciliano 		printf("Error %s\n", bsddialog_geterror());
34263660c0SAlfonso Siciliano 		break;
35263660c0SAlfonso Siciliano 	case BSDDIALOG_YES:
36263660c0SAlfonso Siciliano 		printf("YES\n");
37263660c0SAlfonso Siciliano 		break;
38263660c0SAlfonso Siciliano 	case BSDDIALOG_NO:
39263660c0SAlfonso Siciliano 		printf("NO\n");
40263660c0SAlfonso Siciliano 		break;
41263660c0SAlfonso Siciliano 	}
42263660c0SAlfonso Siciliano 
43263660c0SAlfonso Siciliano 	return (output);
44f499134dSBaptiste Daroussin }