Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / gnu / lib / libdialog / TESTS / radio2.c
1 /*
2  * small test-driver for new dialog functionality
3  *
4  * Copyright (c) 1995, Jordan Hubbard
5  *
6  * All rights reserved.
7  *
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.
15  *
16  * $FreeBSD: src/gnu/lib/libdialog/TESTS/radio2.c,v 1.7 2000/01/10 11:52:09 phantom Exp $
17  * $DragonFly: src/gnu/lib/libdialog/TESTS/radio2.c,v 1.2 2003/06/17 04:25:44 dillon Exp $
18  */
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <unistd.h>
24 #include <sys/wait.h>
25 #include <dialog.h>
26
27 /* Hook functions */
28
29 static char bachelor[10], bachelette[10];
30
31 static int
32 getBachelor(dialogMenuItem *self)
33 {
34     return !strcmp(bachelor, self->prompt);
35 }
36
37 static int
38 setBachelor(dialogMenuItem *self)
39 {
40     strcpy(bachelor, self->prompt);
41     return DITEM_SUCCESS | DITEM_REDRAW;
42 }
43
44 static int
45 getBachelette(dialogMenuItem *self)
46 {
47     return !strcmp(bachelette, self->prompt);
48 }
49
50 static int
51 setBachelette(dialogMenuItem *self)
52 {
53     strcpy(bachelette, self->prompt);
54     return DITEM_SUCCESS | DITEM_REDRAW;
55 }
56
57 /* menu6- More complex radiolist menu that creates two groups in a single menu */
58 /* prompt       title                                                           checked         fire */
59 static dialogMenuItem menu6[] = {
60     { "Tom",    "Tom's a dynamic shoe salesman from Tulsa, OK!",                getBachelor,    setBachelor },
61     { "Dick",   "Dick's a retired engine inspector from McDonnell-Douglas!",    getBachelor,    setBachelor },
62     { "Harry",  "Harry's a professional female impersonator from Las Vegas!",   getBachelor,    setBachelor },
63     { "-----",  "----------------------------------",           NULL, NULL, NULL, NULL, ' ', ' ', ' ' },
64     { "Jane",   "Jane's a twice-divorced housewife from Moose, Oregon!",        getBachelette,  setBachelette },
65     { "Sally",  "Sally's a shy Human Resources Manager for IBM!",               getBachelette,  setBachelette },
66     { "Mary",   "Mary's an energetic serial killer on the lam!",                getBachelette,  setBachelette },
67 };
68
69 /* End of hook functions */
70
71 /* Kick it off, James! */
72 int
73 main(int argc, char **argv)
74 {
75     int retval;
76     
77     init_dialog();
78     
79     retval = dialog_radiolist("this is dialog_radiolist() in action, test #2",
80                               "Welcome to \"The Love Blender!\" - America's favorite game show\n"
81                               "where YOU, the contestant, get to choose which of these two\n"
82                               "fine specimens of humanity will go home together, whether they\n"
83                               "like it or not!", -1, -1, 7, -7, menu6, NULL);
84     dialog_clear();
85     fprintf(stderr, "I'm sure that %s and %s will be very happy together!\n", bachelor, bachelette);
86     
87     end_dialog();
88     return 0;
89 }