mdb.c revision 1.48 1 1.48 martin /* $NetBSD: mdb.c,v 1.48 2019/01/04 15:27:19 martin 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.46 mbalmer * 3. The name of Piermont Information Systems Inc. may not be used to endorse
18 1.1 phil * or promote products derived from this software without specific prior
19 1.1 phil * written permission.
20 1.1 phil *
21 1.1 phil * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
22 1.1 phil * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1 phil * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1 phil * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
25 1.1 phil * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 1.1 phil * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 1.1 phil * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 1.1 phil * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 1.1 phil * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 1.1 phil * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 1.1 phil * THE POSSIBILITY OF SUCH DAMAGE.
32 1.1 phil *
33 1.1 phil */
34 1.1 phil
35 1.1 phil /* mdb.c - menu database manipulation */
36 1.34 agc
37 1.40 jmc #if HAVE_NBTOOL_CONFIG_H
38 1.40 jmc #include "nbtool_config.h"
39 1.40 jmc #endif
40 1.40 jmc
41 1.34 agc #include <sys/cdefs.h>
42 1.34 agc
43 1.36 lukem #if defined(__RCSID) && !defined(lint)
44 1.48 martin __RCSID("$NetBSD: mdb.c,v 1.48 2019/01/04 15:27:19 martin Exp $");
45 1.34 agc #endif
46 1.34 agc
47 1.1 phil
48 1.1 phil #include <stdio.h>
49 1.1 phil #include <stdlib.h>
50 1.1 phil #include <string.h>
51 1.1 phil #include "mdb.h"
52 1.1 phil #include "defs.h"
53 1.22 bjh21 #include "pathnames.h"
54 1.1 phil
55 1.1 phil /* Data */
56 1.23 tv #undef MAX
57 1.11 phil #define MAX 1000
58 1.4 mrg static int menu_no = 0;
59 1.1 phil static id_rec *menus[MAX];
60 1.1 phil
61 1.11 phil /* Other defines */
62 1.26 dsl #define OPT_SUB 1
63 1.26 dsl #define OPT_ENDWIN 2
64 1.26 dsl #define OPT_EXIT 4
65 1.11 phil
66 1.1 phil
67 1.1 phil /* get_menu returns a pointer to a newly created id_rec or an old one. */
68 1.1 phil
69 1.1 phil id_rec *
70 1.46 mbalmer get_menu(char *name)
71 1.1 phil {
72 1.1 phil id_rec *temp;
73 1.1 phil
74 1.1 phil temp = find_id (root, name);
75 1.1 phil
76 1.1 phil if (temp == NULL) {
77 1.1 phil if (menu_no < MAX) {
78 1.46 mbalmer temp = (id_rec *)malloc(sizeof(id_rec));
79 1.1 phil temp->id = strdup(name);
80 1.1 phil temp->info = NULL;
81 1.1 phil temp->menu_no = menu_no;
82 1.1 phil menus[menu_no++] = temp;
83 1.46 mbalmer insert_id(&root, temp);
84 1.1 phil } else {
85 1.46 mbalmer (void)fprintf(stderr, "Too many menus. "
86 1.46 mbalmer "Increase MAX.\n");
87 1.1 phil exit(1);
88 1.1 phil }
89 1.1 phil }
90 1.1 phil
91 1.1 phil return temp;
92 1.1 phil }
93 1.1 phil
94 1.1 phil
95 1.1 phil /* Verify that all menus are defined. */
96 1.1 phil void
97 1.46 mbalmer check_defined(void)
98 1.1 phil {
99 1.1 phil int i;
100 1.1 phil
101 1.46 mbalmer for (i = 0; i < menu_no; i++)
102 1.1 phil if (!menus[i]->info)
103 1.1 phil yyerror ("Menu '%s' undefined.", menus[i]->id);
104 1.1 phil }
105 1.1 phil
106 1.1 phil
107 1.1 phil /* Write out the menu file. */
108 1.1 phil void
109 1.46 mbalmer write_menu_file(char *initcode)
110 1.1 phil {
111 1.46 mbalmer FILE *out_file, *sys_file;
112 1.1 phil int i, j;
113 1.46 mbalmer char hname[1024], cname[1024], sname[1024];
114 1.46 mbalmer char *sys_prefix, *tmpstr;
115 1.46 mbalmer int name_is_code, nlen, ch;
116 1.1 phil optn_info *toptn;
117 1.1 phil
118 1.1 phil /* Generate file names */
119 1.46 mbalmer snprintf(hname, 1024, "%s.h", out_name);
120 1.1 phil nlen = strlen(hname);
121 1.1 phil if (hname[nlen-2] != '.' || hname[nlen-1] != 'h') {
122 1.46 mbalmer (void)fprintf(stderr, "%s: name `%s` too long.\n",
123 1.46 mbalmer prog_name, out_name);
124 1.1 phil exit(1);
125 1.1 phil }
126 1.46 mbalmer snprintf(cname, 1024, "%s.c", out_name);
127 1.1 phil
128 1.1 phil /* Open the menu_sys file first. */
129 1.46 mbalmer sys_prefix = getenv("MENUDEF");
130 1.1 phil if (sys_prefix == NULL)
131 1.22 bjh21 sys_prefix = _PATH_DEFSYSPREFIX;
132 1.46 mbalmer snprintf(sname, 1024, "%s/%s", sys_prefix, sys_name);
133 1.1 phil sys_file = fopen (sname, "r");
134 1.1 phil if (sys_file == NULL) {
135 1.46 mbalmer (void)fprintf(stderr, "%s: could not open %s.\n",
136 1.46 mbalmer prog_name, sname);
137 1.46 mbalmer exit(1);
138 1.1 phil }
139 1.1 phil
140 1.1 phil /* Output the .h file first. */
141 1.46 mbalmer out_file = fopen(hname, "w");
142 1.1 phil if (out_file == NULL) {
143 1.46 mbalmer (void)fprintf(stderr, "%s: could not open %s.\n",
144 1.46 mbalmer prog_name, hname);
145 1.46 mbalmer exit(1);
146 1.1 phil }
147 1.1 phil
148 1.1 phil /* Write it */
149 1.46 mbalmer (void)fprintf(out_file, "%s",
150 1.1 phil "/* menu system definitions. */\n"
151 1.1 phil "\n"
152 1.1 phil "#ifndef MENU_DEFS_H\n"
153 1.1 phil "#define MENU_DEFS_H\n"
154 1.1 phil "#include <stdlib.h>\n"
155 1.1 phil "#include <string.h>\n"
156 1.1 phil "#include <ctype.h>\n"
157 1.11 phil "#include <curses.h>\n\n"
158 1.11 phil );
159 1.9 phil
160 1.33 dsl if (do_msgxlat)
161 1.33 dsl (void)fprintf(out_file, "#define MSG_XLAT(x) msg_string(x)\n");
162 1.33 dsl else
163 1.33 dsl (void)fprintf(out_file, "#define MSG_XLAT(x) (x)\n");
164 1.9 phil if (do_dynamic)
165 1.33 dsl (void)fprintf(out_file, "#define DYNAMIC_MENUS\n");
166 1.47 martin if (do_expands)
167 1.47 martin (void)fprintf(out_file, "#define MENU_EXPANDS\n");
168 1.33 dsl if (do_dynamic || do_msgxlat)
169 1.33 dsl (void)fprintf(out_file, "\n");
170 1.9 phil
171 1.35 dsl (void)fprintf(out_file,
172 1.30 dsl "typedef struct menudesc menudesc;\n"
173 1.30 dsl "typedef struct menu_ent menu_ent;\n"
174 1.11 phil "struct menu_ent {\n"
175 1.29 dsl " const char *opt_name;\n"
176 1.47 martin "#ifdef MENU_EXPANDS\n"
177 1.47 martin " const char *opt_exp_name;\n"
178 1.47 martin "#endif\n"
179 1.26 dsl " int opt_menu;\n"
180 1.26 dsl " int opt_flags;\n"
181 1.38 dsl " int (*opt_action)(menudesc *, void *);\n"
182 1.30 dsl "};\n\n"
183 1.26 dsl "#define OPT_SUB 1\n"
184 1.26 dsl "#define OPT_ENDWIN 2\n"
185 1.26 dsl "#define OPT_EXIT 4\n"
186 1.35 dsl "#define OPT_IGNORE 8\n"
187 1.48 martin "#define OPT_NOSHORT 16\n"
188 1.26 dsl "#define OPT_NOMENU -1\n\n"
189 1.1 phil "struct menudesc {\n"
190 1.29 dsl " const char *title;\n"
191 1.26 dsl " int y, x;\n"
192 1.26 dsl " int h, w;\n"
193 1.26 dsl " int mopt;\n"
194 1.27 dsl " int numopts;\n"
195 1.26 dsl " int cursel;\n"
196 1.26 dsl " int topline;\n"
197 1.26 dsl " menu_ent *opts;\n"
198 1.26 dsl " WINDOW *mw;\n"
199 1.41 dsl " WINDOW *sv_mw;\n"
200 1.26 dsl " const char *helpstr;\n"
201 1.47 martin " const char *exitstr;\n");
202 1.47 martin if (do_expands)
203 1.47 martin (void)fprintf(out_file,
204 1.47 martin " void (*expand_act)(menudesc *, "
205 1.47 martin "void *);\n");
206 1.47 martin (void)fprintf(out_file,
207 1.32 dsl " void (*post_act)(menudesc *, void *);\n"
208 1.32 dsl " void (*exit_act)(menudesc *, void *);\n"
209 1.35 dsl " void (*draw_line)(menudesc *, int, void *);\n"
210 1.30 dsl "};\n"
211 1.1 phil "\n"
212 1.1 phil "/* defines for mopt field. */\n"
213 1.41 dsl #define STR(x) #x
214 1.41 dsl #define MC_OPT(x) "#define " #x " " STR(x) "\n"
215 1.41 dsl MC_OPT(MC_NOEXITOPT)
216 1.41 dsl MC_OPT(MC_NOBOX)
217 1.41 dsl MC_OPT(MC_SCROLL)
218 1.41 dsl MC_OPT(MC_NOSHORTCUT)
219 1.41 dsl MC_OPT(MC_NOCLEAR)
220 1.41 dsl MC_OPT(MC_DFLTEXIT)
221 1.41 dsl MC_OPT(MC_ALWAYS_SCROLL)
222 1.41 dsl MC_OPT(MC_SUBMENU)
223 1.41 dsl MC_OPT(MC_VALID)
224 1.41 dsl #undef MC_OPT
225 1.41 dsl #undef STR
226 1.35 dsl );
227 1.9 phil
228 1.46 mbalmer (void)fprintf(out_file, "%s",
229 1.1 phil "\n"
230 1.1 phil "/* Prototypes */\n"
231 1.37 dsl "int menu_init(void);\n"
232 1.37 dsl "void process_menu(int, void *);\n"
233 1.45 joerg "__dead void __menu_initerror(void);\n"
234 1.11 phil );
235 1.11 phil
236 1.11 phil if (do_dynamic)
237 1.46 mbalmer (void)fprintf(out_file, "%s",
238 1.37 dsl "int new_menu(const char *, menu_ent *, int, \n"
239 1.37 dsl "\tint, int, int, int, int,\n"
240 1.37 dsl "\tvoid (*)(menudesc *, void *), "
241 1.37 dsl "void (*)(menudesc *, int, void *),\n"
242 1.37 dsl "\tvoid (*)(menudesc *, void *), "
243 1.37 dsl "const char *, const char *);\n"
244 1.37 dsl "void free_menu(int);\n"
245 1.32 dsl "void set_menu_numopts(int, int);\n"
246 1.11 phil );
247 1.11 phil
248 1.46 mbalmer (void)fprintf(out_file, "\n/* Menu names */\n");
249 1.46 mbalmer for (i = 0; i < menu_no; i++)
250 1.46 mbalmer (void)fprintf(out_file, "#define MENU_%s\t%d\n",
251 1.46 mbalmer menus[i]->id, i);
252 1.9 phil
253 1.11 phil if (do_dynamic)
254 1.46 mbalmer (void)fprintf(out_file, "\n#define DYN_MENU_START\t%d",
255 1.46 mbalmer menu_no);
256 1.11 phil
257 1.46 mbalmer (void)fprintf (out_file, "\n#define MAX_STRLEN %d\n"
258 1.46 mbalmer "#endif\n", max_strlen);
259 1.46 mbalmer fclose(out_file);
260 1.1 phil
261 1.1 phil /* Now the C file */
262 1.46 mbalmer out_file = fopen(cname, "w");
263 1.1 phil if (out_file == NULL) {
264 1.46 mbalmer (void)fprintf(stderr, "%s: could not open %s.\n",
265 1.46 mbalmer prog_name, cname);
266 1.46 mbalmer exit(1);
267 1.1 phil }
268 1.1 phil
269 1.1 phil /* initial code */
270 1.46 mbalmer fprintf(out_file, "#include \"%s\"\n\n", hname);
271 1.46 mbalmer fprintf(out_file, "%s\n\n", initcode);
272 1.1 phil
273 1.1 phil /* data definitions */
274 1.1 phil
275 1.11 phil /* func defs */
276 1.46 mbalmer for (i = 0; i < menu_no; i++) {
277 1.47 martin if (do_expands && strlen(menus[i]->info->expact.code)) {
278 1.47 martin (void)fprintf(out_file, "/*ARGSUSED*/\n"
279 1.47 martin "static void menu_%d_expact(menudesc *menu, void *arg)\n{\n", i);
280 1.47 martin if (menus[i]->info->expact.endwin)
281 1.47 martin (void)fprintf(out_file, "\tendwin();\n");
282 1.47 martin (void)fprintf(out_file, "\t%s\n}\n\n",
283 1.47 martin menus[i]->info->expact.code);
284 1.47 martin }
285 1.11 phil if (strlen(menus[i]->info->postact.code)) {
286 1.46 mbalmer (void)fprintf(out_file, "/*ARGSUSED*/\n"
287 1.46 mbalmer "static void menu_%d_postact(menudesc *menu, void *arg)\n{\n", i);
288 1.11 phil if (menus[i]->info->postact.endwin)
289 1.46 mbalmer (void)fprintf(out_file, "\tendwin();\n");
290 1.46 mbalmer (void)fprintf(out_file, "\t%s\n}\n\n",
291 1.46 mbalmer menus[i]->info->postact.code);
292 1.11 phil }
293 1.11 phil if (strlen(menus[i]->info->exitact.code)) {
294 1.46 mbalmer (void)fprintf(out_file, "/*ARGSUSED*/\n"
295 1.46 mbalmer "static void menu_%d_exitact(menudesc *menu, void *arg)\n{\n", i);
296 1.11 phil if (menus[i]->info->exitact.endwin)
297 1.46 mbalmer (void)fprintf(out_file, "\tendwin();\n");
298 1.46 mbalmer (void)fprintf(out_file, "\t%s\n}\n\n",
299 1.46 mbalmer menus[i]->info->exitact.code);
300 1.11 phil }
301 1.11 phil j = 0;
302 1.1 phil toptn = menus[i]->info->optns;
303 1.46 mbalmer for (; toptn != NULL; j++, toptn = toptn->next) {
304 1.30 dsl if (strlen(toptn->optact.code) == 0)
305 1.30 dsl continue;
306 1.30 dsl
307 1.46 mbalmer (void)fprintf(out_file, "/*ARGSUSED*/\n"
308 1.46 mbalmer "static int opt_act_%d_%d(menudesc *m, void *arg)\n"
309 1.46 mbalmer "{\n\t%s\n\treturn %s;\n}\n\n",
310 1.46 mbalmer i, j, toptn->optact.code,
311 1.46 mbalmer (toptn->doexit ? "1" : "0"));
312 1.11 phil }
313 1.11 phil
314 1.11 phil }
315 1.11 phil
316 1.11 phil /* optentX */
317 1.46 mbalmer for (i = 0; i < menu_no; i++) {
318 1.11 phil if (menus[i]->info->numopt > 53) {
319 1.46 mbalmer (void)fprintf(stderr, "Menu %s has "
320 1.11 phil "too many options.\n",
321 1.11 phil menus[i]->info->title);
322 1.46 mbalmer exit(1);
323 1.11 phil }
324 1.46 mbalmer (void)fprintf(out_file, "static menu_ent optent%d[] = {\n", i);
325 1.42 dsl name_is_code = 0;
326 1.42 dsl for (j = 0, toptn = menus[i]->info->optns; toptn;
327 1.42 dsl toptn = toptn->next, j++) {
328 1.42 dsl name_is_code += toptn->name_is_code;
329 1.47 martin (void)fprintf(out_file, "\t{ .opt_name = %s, "
330 1.47 martin ".opt_menu=%d, .opt_flags=%d, .opt_action=",
331 1.42 dsl toptn->name_is_code ? "0" : toptn->name,
332 1.42 dsl toptn->menu,
333 1.11 phil (toptn->issub ? OPT_SUB : 0)
334 1.11 phil +(toptn->doexit ? OPT_EXIT : 0)
335 1.11 phil +(toptn->optact.endwin ? OPT_ENDWIN : 0));
336 1.11 phil if (strlen(toptn->optact.code))
337 1.46 mbalmer (void)fprintf(out_file, "opt_act_%d_%d}", i, j);
338 1.8 phil else
339 1.46 mbalmer (void)fprintf(out_file, "NULL}");
340 1.46 mbalmer (void)fprintf(out_file, "%s\n",
341 1.11 phil (toptn->next ? "," : ""));
342 1.1 phil }
343 1.46 mbalmer (void)fprintf(out_file, "\t};\n\n");
344 1.11 phil
345 1.42 dsl if (name_is_code) {
346 1.42 dsl menus[i]->info->name_is_code = 1;
347 1.42 dsl fprintf(out_file, "static void menu_%d_legend("
348 1.42 dsl "menudesc *menu, int opt, void *arg)\n{\n"
349 1.42 dsl "\tswitch (opt) {\n", i);
350 1.42 dsl for (j = 0, toptn = menus[i]->info->optns; toptn;
351 1.42 dsl toptn = toptn->next, j++) {
352 1.42 dsl if (!toptn->name_is_code)
353 1.42 dsl continue;
354 1.42 dsl fprintf(out_file, "\tcase %d:\n\t\t{%s};\n"
355 1.42 dsl "\t\tbreak;\n", j, toptn->name);
356 1.42 dsl }
357 1.42 dsl fprintf(out_file, "\t}\n}\n\n");
358 1.42 dsl }
359 1.1 phil }
360 1.1 phil
361 1.11 phil
362 1.1 phil /* menus */
363 1.46 mbalmer if (!do_dynamic)
364 1.46 mbalmer (void)fprintf(out_file, "static int num_menus = %d;\n",
365 1.46 mbalmer menu_no);
366 1.46 mbalmer
367 1.46 mbalmer (void)fprintf(out_file, "static struct menudesc menu_def[] = {\n");
368 1.46 mbalmer for (i = 0; i < menu_no; i++) {
369 1.46 mbalmer (void)fprintf(out_file,
370 1.41 dsl "\t{%s,%d,%d,%d,%d,%d,%d,0,0,optent%d,NULL,NULL,",
371 1.1 phil menus[i]->info->title, menus[i]->info->y,
372 1.1 phil menus[i]->info->x, menus[i]->info->h,
373 1.1 phil menus[i]->info->w, menus[i]->info->mopt,
374 1.1 phil menus[i]->info->numopt, i);
375 1.5 phil if (menus[i]->info->helpstr == NULL)
376 1.46 mbalmer (void)fprintf(out_file, "NULL");
377 1.5 phil else {
378 1.5 phil tmpstr = menus[i]->info->helpstr;
379 1.41 dsl if (*tmpstr != '"')
380 1.41 dsl (void)fprintf(out_file, "%s", tmpstr);
381 1.41 dsl else {
382 1.41 dsl /* Skip an initial newline. */
383 1.41 dsl if (tmpstr[1] == '\n')
384 1.41 dsl *++tmpstr = '"';
385 1.46 mbalmer (void)fprintf(out_file, "\n");
386 1.41 dsl while (*tmpstr) {
387 1.41 dsl if (*tmpstr != '\n') {
388 1.46 mbalmer fputc(*tmpstr++, out_file);
389 1.41 dsl continue;
390 1.41 dsl }
391 1.46 mbalmer (void)fprintf(out_file, "\\n\"\n\"");
392 1.5 phil tmpstr++;
393 1.5 phil }
394 1.41 dsl }
395 1.5 phil }
396 1.46 mbalmer (void)fprintf(out_file, ",");
397 1.41 dsl if (menus[i]->info->mopt & MC_NOEXITOPT)
398 1.14 cgd (void) fprintf (out_file, "NULL");
399 1.14 cgd else if (menus[i]->info->exitstr != NULL)
400 1.46 mbalmer (void)fprintf(out_file, "%s", menus[i]->info->exitstr);
401 1.14 cgd else
402 1.46 mbalmer (void)fprintf(out_file, "\"Exit\"");
403 1.47 martin if (do_expands) {
404 1.47 martin if (strlen(menus[i]->info->expact.code))
405 1.47 martin (void)fprintf(out_file, ",menu_%d_expact", i);
406 1.47 martin else
407 1.47 martin (void)fprintf(out_file, ",NULL");
408 1.47 martin }
409 1.11 phil if (strlen(menus[i]->info->postact.code))
410 1.46 mbalmer (void)fprintf(out_file, ",menu_%d_postact", i);
411 1.11 phil else
412 1.46 mbalmer (void)fprintf(out_file, ",NULL");
413 1.11 phil if (strlen(menus[i]->info->exitact.code))
414 1.46 mbalmer (void)fprintf(out_file, ",menu_%d_exitact", i);
415 1.9 phil else
416 1.46 mbalmer (void)fprintf(out_file, ",NULL");
417 1.42 dsl if (menus[i]->info->name_is_code)
418 1.46 mbalmer (void)fprintf(out_file, ",menu_%d_legend", i);
419 1.42 dsl else
420 1.46 mbalmer (void)fprintf(out_file, ",NULL");
421 1.11 phil
422 1.46 mbalmer (void)fprintf(out_file, "},\n");
423 1.9 phil
424 1.5 phil }
425 1.46 mbalmer (void)fprintf(out_file, "{NULL, 0, 0, 0, 0, 0, 0, 0, 0, "
426 1.47 martin "NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL");
427 1.47 martin if (do_expands)
428 1.47 martin (void)fprintf(out_file, ", NULL");
429 1.47 martin (void)fprintf(out_file, "}};\n\n");
430 1.1 phil
431 1.2 phil /* __menu_initerror: initscr failed. */
432 1.46 mbalmer (void)fprintf(out_file,
433 1.2 phil "/* __menu_initerror: initscr failed. */\n"
434 1.2 phil "void __menu_initerror (void) {\n");
435 1.2 phil if (error_act.code == NULL) {
436 1.46 mbalmer (void)fprintf(out_file,
437 1.2 phil "\t(void) fprintf (stderr, "
438 1.20 phil "\"%%s: Could not initialize curses\\n\", "
439 1.21 cgd "getprogname());\n"
440 1.2 phil "\texit(1);\n"
441 1.2 phil "}\n");
442 1.2 phil } else {
443 1.2 phil if (error_act.endwin)
444 1.46 mbalmer (void)fprintf(out_file, "\tendwin();\n");
445 1.46 mbalmer (void)fprintf(out_file, "%s\n}\n", error_act.code);
446 1.2 phil }
447 1.2 phil
448 1.11 phil /* Copy menu_sys.def file. */
449 1.11 phil while ((ch = fgetc(sys_file)) != '\014') /* Control-L */
450 1.26 dsl fputc(ch, out_file);
451 1.11 phil
452 1.11 phil if (do_dynamic) {
453 1.11 phil while ((ch = fgetc(sys_file)) != '\n')
454 1.11 phil /* skip it */;
455 1.11 phil while ((ch = fgetc(sys_file)) != EOF)
456 1.11 phil fputc(ch, out_file);
457 1.11 phil }
458 1.46 mbalmer fclose(out_file);
459 1.46 mbalmer fclose(sys_file);
460 1.1 phil }
461