aboutsummaryrefslogtreecommitdiff
path: root/examples_library/form.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples_library/form.c')
-rw-r--r--examples_library/form.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/examples_library/form.c b/examples_library/form.c
index efb997f31d36..9bc7b0ccbe58 100644
--- a/examples_library/form.c
+++ b/examples_library/form.c
@@ -23,29 +23,37 @@ int main()
int i, output;
struct bsddialog_conf conf;
struct bsddialog_formitem items[3] = {
- {"Input:", 1, 1, "value", 1, 11, 30, 50, NULL, 0, "desc 1"},
- {"Input:", 2, 1, "read only", 2, 11, 30, 50, NULL, RO, "desc 2"},
- {"Password:", 3, 1, "", 3, 11, 30, 50, NULL, H, "desc 3"}
+ {"Input:", 1, 1, "value", 1, 11, 30, 50, NULL, 0, "desc 1"},
+ {"Input:", 2, 1, "read only", 2, 11, 30, 50, NULL, RO, "desc 2"},
+ {"Password:", 3, 1, "", 3, 11, 30, 50, NULL, H, "desc 3"}
};
+ if (bsddialog_init() == BSDDIALOG_ERROR) {
+ printf("Error: %s\n", bsddialog_geterror());
+ return (1);
+ }
+
bsddialog_initconf(&conf);
conf.title = "form";
conf.form.securech = '*';
-
- if (bsddialog_init() < 0)
- return -1;
-
output = bsddialog_form(&conf, "Example", 10, 50, 3, 3, items);
bsddialog_end();
-
- if (output == BSDDIALOG_ERROR)
+
+ if (output == BSDDIALOG_ERROR) {
printf("Error: %s", bsddialog_geterror());
+ return (1);
+ }
+
+ if (output == BSDDIALOG_CANCEL) {
+ printf("Cancel\n");
+ return (0);
+ }
- for (i=0; i<3; i++) {
+ for (i = 0; i < 3; i++) {
printf("%s \"%s\"\n", items[i].label, items[i].value);
free(items[i].value);
}
-
- return output;
-}
+
+ return (output);
+} \ No newline at end of file