1*9e180a65Suwe /* $NetBSD: main.c,v 1.8 2019/12/03 01:45:34 uwe Exp $ */
295f3bf39Sphil
395f3bf39Sphil /*
495f3bf39Sphil * Copyright 1997 Piermont Information Systems Inc.
595f3bf39Sphil * All rights reserved.
695f3bf39Sphil *
795f3bf39Sphil * Written by Philip A. Nelson for Piermont Information Systems Inc.
895f3bf39Sphil *
995f3bf39Sphil * Redistribution and use in source and binary forms, with or without
1095f3bf39Sphil * modification, are permitted provided that the following conditions
1195f3bf39Sphil * are met:
1295f3bf39Sphil * 1. Redistributions of source code must retain the above copyright
1395f3bf39Sphil * notice, this list of conditions and the following disclaimer.
1495f3bf39Sphil * 2. Redistributions in binary form must reproduce the above copyright
1595f3bf39Sphil * notice, this list of conditions and the following disclaimer in the
1695f3bf39Sphil * documentation and/or other materials provided with the distribution.
1795f3bf39Sphil * 3. All advertising materials mentioning features or use of this software
1895f3bf39Sphil * must display the following acknowledgement:
19*9e180a65Suwe * This product includes software developed for the NetBSD Project by
2095f3bf39Sphil * Piermont Information Systems Inc.
2195f3bf39Sphil * 4. The name of Piermont Information Systems Inc. may not be used to endorse
2295f3bf39Sphil * or promote products derived from this software without specific prior
2395f3bf39Sphil * written permission.
2495f3bf39Sphil *
2595f3bf39Sphil * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
2695f3bf39Sphil * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2795f3bf39Sphil * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2895f3bf39Sphil * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
2995f3bf39Sphil * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
3095f3bf39Sphil * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3195f3bf39Sphil * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3295f3bf39Sphil * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3395f3bf39Sphil * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3495f3bf39Sphil * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
3595f3bf39Sphil * THE POSSIBILITY OF SUCH DAMAGE.
3695f3bf39Sphil *
3795f3bf39Sphil */
3895f3bf39Sphil
3995f3bf39Sphil /* main sysinst program. */
4095f3bf39Sphil
4195f3bf39Sphil #include "menu_defs.h"
42d20940b9Sphil #include "msg_defs.h"
4395f3bf39Sphil
main(void)4495f3bf39Sphil int main(void)
4595f3bf39Sphil {
4695f3bf39Sphil
4795f3bf39Sphil /* Menu processing */
483f8c5664Sdsl process_menu (MENU_root, NULL);
4995f3bf39Sphil
5095f3bf39Sphil return 0;
5195f3bf39Sphil }
5295f3bf39Sphil
53d20940b9Sphil /* Dynamic menu suff! */
54d20940b9Sphil
55d20940b9Sphil char ent_text[5][50] = {"name: ", "strt: ", "city: ", "opt 4", "NUM: "};
56d20940b9Sphil
57d20940b9Sphil /* opt processing routines .. */
58d20940b9Sphil
59e2221770Swrstuden int opt_1 (struct menudesc *m, void *p);
60d20940b9Sphil
opt_1(struct menudesc * m,void * p)61e2221770Swrstuden int opt_1 (struct menudesc *m, void *p)
62d20940b9Sphil {
63d20940b9Sphil msg_clear();
64d20940b9Sphil msg_prompt (MSG_name, "", &ent_text[0][6], 40);
65d20940b9Sphil msg_clear();
6611c7d5d3Sphil return 0;
67d20940b9Sphil }
68d20940b9Sphil
69e2221770Swrstuden int opt_2 (struct menudesc *m, void *p);
70d20940b9Sphil
opt_2(struct menudesc * m,void * p)71e2221770Swrstuden int opt_2 (struct menudesc *m, void *p)
72d20940b9Sphil {
73d20940b9Sphil msg_clear();
74d20940b9Sphil msg_prompt (MSG_street, "", &ent_text[1][6], 40);
75d20940b9Sphil msg_clear();
7611c7d5d3Sphil return 0;
77d20940b9Sphil }
78d20940b9Sphil
79e2221770Swrstuden int opt_3 (struct menudesc *m, void *p);
80d20940b9Sphil
opt_3(struct menudesc * m,void * p)81e2221770Swrstuden int opt_3 (struct menudesc *m, void *p)
82d20940b9Sphil {
83d20940b9Sphil msg_clear();
84d20940b9Sphil msg_prompt (MSG_city, "", &ent_text[2][6], 40);
85d20940b9Sphil msg_clear();
8611c7d5d3Sphil return 0;
87d20940b9Sphil }
88d20940b9Sphil
89d20940b9Sphil
90d20940b9Sphil menu_ent mymenu [5] = {
91d20940b9Sphil { ent_text[0], OPT_NOMENU, 0, opt_1},
92d20940b9Sphil { ent_text[1], OPT_NOMENU, 0, opt_2},
93d20940b9Sphil { ent_text[2], OPT_NOMENU, 0, opt_3},
94d20940b9Sphil { ent_text[3], OPT_NOMENU, 0, NULL},
95d20940b9Sphil { ent_text[4], OPT_NOMENU, 0, NULL} };
96d20940b9Sphil
97d20940b9Sphil int num = 0;
98d20940b9Sphil
99d20940b9Sphil
100d20940b9Sphil void do_dynamic(void);
101e2221770Swrstuden void dyn_disp (struct menudesc *, void *);
dyn_disp(struct menudesc * m,void * p)102e2221770Swrstuden void dyn_disp (struct menudesc *m, void *p)
103d20940b9Sphil {
104d20940b9Sphil sprintf (&ent_text[4][5], "%d", num++);
105d20940b9Sphil }
106d20940b9Sphil
do_dynamic(void)107d20940b9Sphil void do_dynamic(void)
108d20940b9Sphil {
109d20940b9Sphil int menu_no;
110d20940b9Sphil
111d20940b9Sphil num = 0;
112d20940b9Sphil menu_no = new_menu (" A test dynamic menu! ", mymenu, 5, 10, 10,
113e2221770Swrstuden 0, 55, MC_SCROLL, dyn_disp, NULL, NULL,
114d20940b9Sphil "Make sure you try at least one option before exiting.\n"
115e2221770Swrstuden "Then look at what changes.\n", "Done now!");
116d20940b9Sphil if (menu_no < 0) {
117d20940b9Sphil endwin();
118d20940b9Sphil (void) fprintf (stderr, "Dynamic memu creation failure. \n");
119d20940b9Sphil exit (1);
120d20940b9Sphil }
1213f8c5664Sdsl process_menu (menu_no, NULL);
122d20940b9Sphil free_menu (menu_no);
123d20940b9Sphil }
124d20940b9Sphil
125