Move acpica-unix-20050309 into the Attic
[dragonfly.git] / gnu / lib / libdialog / TESTS / check3.c
blob8cccc57db8c8f882e5f137d5854e0a3b48b13151
1 /*
2 * small test-driver for new dialog functionality
4 * Copyright (c) 1995, Jordan Hubbard
6 * All rights reserved.
8 * This source code may be used, modified, copied, distributed, and
9 * sold, in both source and binary form provided that the above
10 * copyright and these terms are retained, verbatim, as the first
11 * lines of this file. Under no circumstances is the author
12 * responsible for the proper functioning of the software nor does
13 * the author assume any responsibility for damages incurred with
14 * its use.
16 * $FreeBSD: src/gnu/lib/libdialog/TESTS/check3.c,v 1.6 2000/01/10 11:52:03 phantom Exp $
17 * $DragonFly: src/gnu/lib/libdialog/TESTS/check3.c,v 1.2 2003/06/17 04:25:43 dillon Exp $
21 #include <sys/wait.h>
22 #include <dialog.h>
24 /* Hook functions */
26 static int
27 getBool(dialogMenuItem *self)
29 if (self->data && *((int *)self->data))
30 return TRUE;
31 return FALSE;
34 static int
35 setBool(dialogMenuItem *self)
37 if (self->data) {
38 *((int *)self->data) = !*((int *)self->data);
39 return DITEM_SUCCESS;
41 return DITEM_FAILURE;
44 static int german_book, italian_book, slang_book;
45 static int spending;
47 static int
48 check(dialogMenuItem *self)
50 return ((int)self->data == spending);
53 static int
54 spend(dialogMenuItem *self)
56 spending = (int)self->data;
57 return DITEM_SUCCESS | DITEM_REDRAW;
60 /* menu4 - Show off a simulated compound menu (group at top is checklist, group at bottom radio) */
61 /* prompt title checked fire sel, data lbra mark rbra */
62 static dialogMenuItem menu4[] = {
63 { "German", "Buy books on learning German", getBool, setBool, NULL, &german_book },
64 { "Italian","Buy books on learning Italian", getBool, setBool, NULL, &italian_book },
65 { "Slang", "Buy books on commonly used insults", getBool, setBool, NULL, &slang_book },
66 { "-----", "----------------------------------", NULL, NULL, NULL, NULL, ' ', ' ', ' ' },
67 { "1000", "Spend $1,000", check, spend, NULL, (void *)1000, '(', '*', ')' },
68 { "500", "Spend $500", check, spend, NULL, (void *)500, '(', '*', ')' },
69 { "100", "Spend $100", check, spend, NULL, (void *)100, '(', '*', ')' },
72 /* End of hook functions */
74 /* Kick it off, James! */
75 int
76 main(int argc, char **argv)
78 int retval;
80 init_dialog();
83 retval = dialog_checklist("this is dialog_checklist() in action, test #3",
84 "Now we show off some of the button 'styles' one can create.",
85 -1, -1, 7, -7, menu4, NULL);
86 dialog_clear();
87 fprintf(stderr, "spent $%d on %s%s%s books\n", spending, german_book ? " german" : "",
88 italian_book ? " italian" : "", slang_book ? " slang" : "");
90 end_dialog();
91 return 0;