Initial import from FreeBSD RELENG_4:
[dragonfly.git] / gnu / lib / libdialog / TESTS / tree.c
1 /*
2  * tree.c
3  *
4  * small test-driver for new dialog functionality
5  *
6  * Copyright (c) 1998, Anatoly A. Orehovsky
7  *
8  * $FreeBSD: src/gnu/lib/libdialog/TESTS/tree.c,v 1.2 2000/01/10 11:52:10 phantom Exp $
9  */
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <dialog.h>
14
15 unsigned char *names[] = {
16         "/",
17         "/dev",
18         "/dev/fd",
19         "/tmp",
20         "/usr",
21         "/var",
22         "/home",
23         "/stand",
24         "/stand/etc",
25         "/stand/en_US.ISO8859-1",
26         "/stand/info",
27         "/stand/info/bin",
28         "/stand/info/des",
29         "/stand/info/games",
30         "/stand/info/manpages",
31         "/stand/info/proflibs",
32         "/stand/info/dict",
33         "/stand/info/info",
34         "/stand/info/src",
35         "/etc",
36         "/etc/gnats",
37         "/etc/kerberosIV",
38         "/etc/mtree",
39         "/etc/namedb",
40         "/etc/ppp",
41         "/etc/uucp",
42         "/etc/sliphome",
43         "/proc",
44         "/lkm",
45         "/mnt",
46         "/root",
47         "/sbin",
48         "/bin",
49         0
50 };
51
52 unsigned char *names1[] = {
53         "a",
54         "a:b",
55         "a:b:c",
56         "a:d"
57 };
58
59 int
60 main(int argc, char **argv)
61 {
62         int retval;
63         unsigned char *tresult;
64         char comstr[BUFSIZ];
65
66         init_dialog();
67         do {
68                 use_helpline("Press OK for listing directory");
69                 retval = dialog_tree(names, 
70                         sizeof(names)/sizeof(unsigned char *) - 1,
71                          '/',
72                         "tree dialog box example",
73                         "Typical find -x / -type d output", 
74                         -1, -1, 15,
75                                     &tresult);
76                 
77                 if (retval)
78                         break;
79                 
80                 use_helpline(NULL);
81                 (void)snprintf(comstr, sizeof(comstr), 
82                         "ls -CF %s", tresult);
83
84                 retval = dialog_prgbox(
85                         comstr, 
86                         comstr, 20, 60, TRUE, TRUE);
87
88                 dialog_clear();
89                 
90                 retval = dialog_tree(names1, 
91                         sizeof(names1)/sizeof(unsigned char *),
92                          ':',
93                         "tree dialog box example",
94                         "Other tree", 
95                         -1, -1, 5,
96                                     &tresult);
97                 if (!retval)
98                 {
99                         dialog_clear();
100                 }
101         } while (!retval);
102
103         dialog_update();
104         
105         dialog_clear();
106         
107         end_dialog();
108         
109         exit(retval);
110 }