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 12 #include <stdio.h> 13 #include <stdlib.h> 14 #include <string.h> 15 16 #include <bsddialog.h> 17 18 #define H BSDDIALOG_FIELDHIDDEN 19 #define RO BSDDIALOG_FIELDREADONLY 20 21 int main() 22 { 23 int i, output; 24 struct bsddialog_conf conf; 25 struct bsddialog_formitem items[3] = { 26 {"Input:", 1, 1, "value", 1, 11, 30, 50, NULL, 0, "desc 1"}, 27 {"Input:", 2, 1, "read only", 2, 11, 30, 50, NULL, RO, "desc 2"}, 28 {"Password:", 3, 1, "", 3, 11, 30, 50, NULL, H, "desc 3"} 29 }; 30 31 bsddialog_initconf(&conf); 32 conf.title = "form"; 33 conf.form.securech = '*'; 34 35 if (bsddialog_init() < 0) 36 return -1; 37 38 output = bsddialog_form(&conf, "Example", 10, 50, 3, 3, items); 39 40 bsddialog_end(); 41 42 if (output == BSDDIALOG_ERROR) 43 printf("Error: %s", bsddialog_geterror()); 44 45 for (i=0; i<3; i++) { 46 printf("%s \"%s\"\n", items[i].label, items[i].value); 47 free(items[i].value); 48 } 49 50 return output; 51 } 52