summaryrefslogtreecommitdiffstats
path: root/gnu/lib/libodialog/TESTS/tree.c
blob: c69b52e7d04f055403d952e17e92caf0cbbecff9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 * tree.c
 *
 * small test-driver for new dialog functionality
 *
 * Copyright (c) 1998, Anatoly A. Orehovsky
 */

#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");

#include <stdio.h>
#include <stdlib.h>
#include <dialog.h>

unsigned char *names[] = {
	"/",
	"/dev",
	"/dev/fd",
	"/tmp",
	"/usr",
	"/var",
	"/home",
	"/stand",
	"/stand/etc",
	"/stand/en_US.ISO8859-1",
	"/stand/info",
	"/stand/info/bin",
	"/stand/info/des",
	"/stand/info/games",
	"/stand/info/manpages",
	"/stand/info/proflibs",
	"/stand/info/dict",
	"/stand/info/info",
	"/stand/info/src",
	"/etc",
	"/etc/gnats",
	"/etc/kerberosIV",
	"/etc/mtree",
	"/etc/namedb",
	"/etc/ppp",
	"/etc/uucp",
	"/etc/sliphome",
	"/proc",
	"/lkm",
	"/mnt",
	"/root",
	"/sbin",
	"/bin",
	0
};

unsigned char *names1[] = {
	"a",
	"a:b",
	"a:b:c",
	"a:d"
};

int
main(int argc, char **argv)
{
	int retval;
	unsigned char *tresult;
	char comstr[BUFSIZ];

	init_dialog();
	do {
		use_helpline("Press OK for listing directory");
		retval = dialog_tree(names, 
			sizeof(names)/sizeof(unsigned char *) - 1,
			 '/',
			"tree dialog box example",
			"Typical find -x / -type d output", 
			-1, -1, 15,
                        	    &tresult);
		
		if (retval)
			break;
		
		use_helpline(NULL);
		(void)snprintf(comstr, sizeof(comstr), 
			"ls -CF %s", tresult);

		retval = dialog_prgbox(
			comstr, 
			comstr, 20, 60, TRUE, TRUE);

		dialog_clear();
  		
		retval = dialog_tree(names1, 
			sizeof(names1)/sizeof(unsigned char *),
			 ':',
			"tree dialog box example",
			"Other tree", 
			-1, -1, 5,
                        	    &tresult);
		if (!retval)
		{
	  		dialog_clear();
  		}
	} while (!retval);

	dialog_update();
	
	dialog_clear();
	
	end_dialog();
  	
	exit(retval);
}
OpenPOWER on IntegriCloud