xref: /freebsd/contrib/bsddialog/examples_library/yesno.c (revision 61ba55bcf70f2340f9c943c9571113b3fd8eda69)
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 
11bce40c02SAlfonso S. Siciliano #include <bsddialog.h>
12f499134dSBaptiste Daroussin #include <stdio.h>
13f499134dSBaptiste Daroussin 
main()14f499134dSBaptiste Daroussin int main()
15f499134dSBaptiste Daroussin {
16f499134dSBaptiste Daroussin 	int output;
17f499134dSBaptiste Daroussin 	struct bsddialog_conf conf;
18f499134dSBaptiste Daroussin 
19263660c0SAlfonso Siciliano 	if (bsddialog_init() == BSDDIALOG_ERROR) {
20263660c0SAlfonso Siciliano 		printf("Error: %s\n", bsddialog_geterror());
21263660c0SAlfonso Siciliano 		return (1);
22263660c0SAlfonso Siciliano 	}
23f499134dSBaptiste Daroussin 	bsddialog_initconf(&conf);
24f499134dSBaptiste Daroussin 	conf.title = "yesno";
25f499134dSBaptiste Daroussin 	output = bsddialog_yesno(&conf, "Example", 7, 25);
26f499134dSBaptiste Daroussin 	bsddialog_end();
27f499134dSBaptiste Daroussin 
28263660c0SAlfonso Siciliano 	switch (output) {
29263660c0SAlfonso Siciliano 	case BSDDIALOG_ERROR:
30263660c0SAlfonso Siciliano 		printf("Error %s\n", bsddialog_geterror());
31*61ba55bcSBaptiste Daroussin 		return (1);
32263660c0SAlfonso Siciliano 	case BSDDIALOG_YES:
33*61ba55bcSBaptiste Daroussin 		printf("[YES]\n");
34263660c0SAlfonso Siciliano 		break;
35263660c0SAlfonso Siciliano 	case BSDDIALOG_NO:
36*61ba55bcSBaptiste Daroussin 		printf("[NO]\n");
37263660c0SAlfonso Siciliano 		break;
38263660c0SAlfonso Siciliano 	}
39263660c0SAlfonso Siciliano 
40*61ba55bcSBaptiste Daroussin 	return (0);
41f499134dSBaptiste Daroussin }