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