1*525a267eSThomas Cort /* $NetBSD: main.c,v 1.6 2004/09/17 18:16:44 wrstuden Exp $ */
2*525a267eSThomas Cort
3*525a267eSThomas Cort /*
4*525a267eSThomas Cort * Copyright 1997 Piermont Information Systems Inc.
5*525a267eSThomas Cort * All rights reserved.
6*525a267eSThomas Cort *
7*525a267eSThomas Cort * Written by Philip A. Nelson for Piermont Information Systems Inc.
8*525a267eSThomas Cort *
9*525a267eSThomas Cort * Redistribution and use in source and binary forms, with or without
10*525a267eSThomas Cort * modification, are permitted provided that the following conditions
11*525a267eSThomas Cort * are met:
12*525a267eSThomas Cort * 1. Redistributions of source code must retain the above copyright
13*525a267eSThomas Cort * notice, this list of conditions and the following disclaimer.
14*525a267eSThomas Cort * 2. Redistributions in binary form must reproduce the above copyright
15*525a267eSThomas Cort * notice, this list of conditions and the following disclaimer in the
16*525a267eSThomas Cort * documentation and/or other materials provided with the distribution.
17*525a267eSThomas Cort * 3. All advertising materials mentioning features or use of this software
18*525a267eSThomas Cort * must display the following acknowledgement:
19*525a267eSThomas Cort * This product includes software develooped for the NetBSD Project by
20*525a267eSThomas Cort * Piermont Information Systems Inc.
21*525a267eSThomas Cort * 4. The name of Piermont Information Systems Inc. may not be used to endorse
22*525a267eSThomas Cort * or promote products derived from this software without specific prior
23*525a267eSThomas Cort * written permission.
24*525a267eSThomas Cort *
25*525a267eSThomas Cort * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
26*525a267eSThomas Cort * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27*525a267eSThomas Cort * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28*525a267eSThomas Cort * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
29*525a267eSThomas Cort * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30*525a267eSThomas Cort * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31*525a267eSThomas Cort * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32*525a267eSThomas Cort * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33*525a267eSThomas Cort * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34*525a267eSThomas Cort * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
35*525a267eSThomas Cort * THE POSSIBILITY OF SUCH DAMAGE.
36*525a267eSThomas Cort *
37*525a267eSThomas Cort */
38*525a267eSThomas Cort
39*525a267eSThomas Cort /* main sysinst program. */
40*525a267eSThomas Cort
41*525a267eSThomas Cort #include "menu_defs.h"
42*525a267eSThomas Cort #include "msg_defs.h"
43*525a267eSThomas Cort
44*525a267eSThomas Cort int main(void);
45*525a267eSThomas Cort
main(void)46*525a267eSThomas Cort int main(void)
47*525a267eSThomas Cort {
48*525a267eSThomas Cort
49*525a267eSThomas Cort /* Menu processing */
50*525a267eSThomas Cort process_menu (MENU_root, NULL);
51*525a267eSThomas Cort
52*525a267eSThomas Cort return 0;
53*525a267eSThomas Cort }
54*525a267eSThomas Cort
55*525a267eSThomas Cort /* Dynamic menu suff! */
56*525a267eSThomas Cort
57*525a267eSThomas Cort char ent_text[5][50] = {"name: ", "strt: ", "city: ", "opt 4", "NUM: "};
58*525a267eSThomas Cort
59*525a267eSThomas Cort /* opt processing routines .. */
60*525a267eSThomas Cort
61*525a267eSThomas Cort int opt_1 (struct menudesc *m, void *p);
62*525a267eSThomas Cort
opt_1(struct menudesc * m,void * p)63*525a267eSThomas Cort int opt_1 (struct menudesc *m, void *p)
64*525a267eSThomas Cort {
65*525a267eSThomas Cort msg_clear();
66*525a267eSThomas Cort msg_prompt (MSG_name, "", &ent_text[0][6], 40);
67*525a267eSThomas Cort msg_clear();
68*525a267eSThomas Cort return 0;
69*525a267eSThomas Cort }
70*525a267eSThomas Cort
71*525a267eSThomas Cort int opt_2 (struct menudesc *m, void *p);
72*525a267eSThomas Cort
opt_2(struct menudesc * m,void * p)73*525a267eSThomas Cort int opt_2 (struct menudesc *m, void *p)
74*525a267eSThomas Cort {
75*525a267eSThomas Cort msg_clear();
76*525a267eSThomas Cort msg_prompt (MSG_street, "", &ent_text[1][6], 40);
77*525a267eSThomas Cort msg_clear();
78*525a267eSThomas Cort return 0;
79*525a267eSThomas Cort }
80*525a267eSThomas Cort
81*525a267eSThomas Cort int opt_3 (struct menudesc *m, void *p);
82*525a267eSThomas Cort
opt_3(struct menudesc * m,void * p)83*525a267eSThomas Cort int opt_3 (struct menudesc *m, void *p)
84*525a267eSThomas Cort {
85*525a267eSThomas Cort msg_clear();
86*525a267eSThomas Cort msg_prompt (MSG_city, "", &ent_text[2][6], 40);
87*525a267eSThomas Cort msg_clear();
88*525a267eSThomas Cort return 0;
89*525a267eSThomas Cort }
90*525a267eSThomas Cort
91*525a267eSThomas Cort
92*525a267eSThomas Cort menu_ent mymenu [5] = {
93*525a267eSThomas Cort { ent_text[0], OPT_NOMENU, 0, opt_1},
94*525a267eSThomas Cort { ent_text[1], OPT_NOMENU, 0, opt_2},
95*525a267eSThomas Cort { ent_text[2], OPT_NOMENU, 0, opt_3},
96*525a267eSThomas Cort { ent_text[3], OPT_NOMENU, 0, NULL},
97*525a267eSThomas Cort { ent_text[4], OPT_NOMENU, 0, NULL} };
98*525a267eSThomas Cort
99*525a267eSThomas Cort int num = 0;
100*525a267eSThomas Cort
101*525a267eSThomas Cort
102*525a267eSThomas Cort void do_dynamic(void);
103*525a267eSThomas Cort void dyn_disp (struct menudesc *, void *);
dyn_disp(struct menudesc * m,void * p)104*525a267eSThomas Cort void dyn_disp (struct menudesc *m, void *p)
105*525a267eSThomas Cort {
106*525a267eSThomas Cort sprintf (&ent_text[4][5], "%d", num++);
107*525a267eSThomas Cort }
108*525a267eSThomas Cort
do_dynamic(void)109*525a267eSThomas Cort void do_dynamic(void)
110*525a267eSThomas Cort {
111*525a267eSThomas Cort int menu_no;
112*525a267eSThomas Cort
113*525a267eSThomas Cort num = 0;
114*525a267eSThomas Cort menu_no = new_menu (" A test dynamic menu! ", mymenu, 5, 10, 10,
115*525a267eSThomas Cort 0, 55, MC_SCROLL, dyn_disp, NULL, NULL,
116*525a267eSThomas Cort "Make sure you try at least one option before exiting.\n"
117*525a267eSThomas Cort "Then look at what changes.\n", "Done now!");
118*525a267eSThomas Cort if (menu_no < 0) {
119*525a267eSThomas Cort endwin();
120*525a267eSThomas Cort (void) fprintf (stderr, "Dynamic memu creation failure. \n");
121*525a267eSThomas Cort exit (1);
122*525a267eSThomas Cort }
123*525a267eSThomas Cort process_menu (menu_no, NULL);
124*525a267eSThomas Cort free_menu (menu_no);
125*525a267eSThomas Cort }
126*525a267eSThomas Cort
127