2006-02-21 00:06:40 +03:00
|
|
|
/* $NetBSD: mdb.c,v 1.42 2006/02/20 21:06:40 dsl Exp $ */
|
1997-09-26 21:54:09 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 1997 Piermont Information Systems Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Written by Philip A. Nelson for Piermont Information Systems Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software develooped for the NetBSD Project by
|
|
|
|
* Piermont Information Systems Inc.
|
|
|
|
* 4. The name of Piermont Information Systems Inc. may not be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* mdb.c - menu database manipulation */
|
|
|
|
|
2004-06-21 02:20:14 +04:00
|
|
|
#if HAVE_NBTOOL_CONFIG_H
|
|
|
|
#include "nbtool_config.h"
|
|
|
|
#endif
|
|
|
|
|
2003-06-23 17:05:47 +04:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
2003-07-17 12:33:03 +04:00
|
|
|
#if defined(__RCSID) && !defined(lint)
|
2006-02-21 00:06:40 +03:00
|
|
|
__RCSID("$NetBSD: mdb.c,v 1.42 2006/02/20 21:06:40 dsl Exp $");
|
2003-06-23 17:05:47 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1997-09-26 21:54:09 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "mdb.h"
|
|
|
|
#include "defs.h"
|
2001-10-16 02:20:03 +04:00
|
|
|
#include "pathnames.h"
|
1997-09-26 21:54:09 +04:00
|
|
|
|
|
|
|
/* Data */
|
2002-03-07 23:43:29 +03:00
|
|
|
#undef MAX
|
1998-07-16 11:08:26 +04:00
|
|
|
#define MAX 1000
|
1998-03-30 06:28:37 +04:00
|
|
|
static int menu_no = 0;
|
1997-09-26 21:54:09 +04:00
|
|
|
static id_rec *menus[MAX];
|
|
|
|
|
1998-07-16 11:08:26 +04:00
|
|
|
/* Other defines */
|
2003-05-09 11:30:50 +04:00
|
|
|
#define OPT_SUB 1
|
|
|
|
#define OPT_ENDWIN 2
|
|
|
|
#define OPT_EXIT 4
|
1998-07-16 11:08:26 +04:00
|
|
|
|
1997-09-26 21:54:09 +04:00
|
|
|
|
|
|
|
/* get_menu returns a pointer to a newly created id_rec or an old one. */
|
|
|
|
|
|
|
|
id_rec *
|
|
|
|
get_menu (char *name)
|
|
|
|
{
|
|
|
|
id_rec *temp;
|
|
|
|
|
|
|
|
temp = find_id (root, name);
|
|
|
|
|
|
|
|
if (temp == NULL) {
|
|
|
|
if (menu_no < MAX) {
|
|
|
|
temp = (id_rec *) malloc (sizeof(id_rec));
|
|
|
|
temp->id = strdup(name);
|
|
|
|
temp->info = NULL;
|
|
|
|
temp->menu_no = menu_no;
|
|
|
|
menus[menu_no++] = temp;
|
|
|
|
insert_id (&root, temp);
|
|
|
|
} else {
|
|
|
|
(void) fprintf (stderr, "Too many menus. "
|
|
|
|
"Increase MAX.\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Verify that all menus are defined. */
|
|
|
|
|
|
|
|
void
|
|
|
|
check_defined (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i<menu_no; i++)
|
|
|
|
if (!menus[i]->info)
|
|
|
|
yyerror ("Menu '%s' undefined.", menus[i]->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Write out the menu file. */
|
|
|
|
void
|
|
|
|
write_menu_file (char *initcode)
|
|
|
|
{
|
|
|
|
FILE *out_file;
|
|
|
|
FILE *sys_file;
|
|
|
|
int i, j;
|
|
|
|
char hname[1024];
|
|
|
|
char cname[1024];
|
|
|
|
char sname[1024];
|
|
|
|
char *sys_prefix;
|
1998-06-24 10:46:23 +04:00
|
|
|
char *tmpstr;
|
2006-02-21 00:06:40 +03:00
|
|
|
int name_is_code;
|
1997-09-26 21:54:09 +04:00
|
|
|
|
|
|
|
int nlen;
|
|
|
|
|
1998-01-16 01:36:41 +03:00
|
|
|
int ch;
|
1997-09-26 21:54:09 +04:00
|
|
|
|
|
|
|
optn_info *toptn;
|
|
|
|
|
|
|
|
/* Generate file names */
|
|
|
|
snprintf (hname, 1024, "%s.h", out_name);
|
|
|
|
nlen = strlen(hname);
|
|
|
|
if (hname[nlen-2] != '.' || hname[nlen-1] != 'h') {
|
|
|
|
(void) fprintf (stderr, "%s: name `%s` too long.\n",
|
|
|
|
prog_name, out_name);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
snprintf (cname, 1024, "%s.c", out_name);
|
|
|
|
|
|
|
|
/* Open the menu_sys file first. */
|
|
|
|
sys_prefix = getenv ("MENUDEF");
|
|
|
|
if (sys_prefix == NULL)
|
2001-10-16 02:20:03 +04:00
|
|
|
sys_prefix = _PATH_DEFSYSPREFIX;
|
1997-09-26 21:54:09 +04:00
|
|
|
snprintf (sname, 1024, "%s/%s", sys_prefix, sys_name);
|
|
|
|
sys_file = fopen (sname, "r");
|
|
|
|
if (sys_file == NULL) {
|
|
|
|
(void) fprintf (stderr, "%s: could not open %s.\n",
|
|
|
|
prog_name, sname);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Output the .h file first. */
|
|
|
|
out_file = fopen (hname, "w");
|
|
|
|
if (out_file == NULL) {
|
|
|
|
(void) fprintf (stderr, "%s: could not open %s.\n",
|
|
|
|
prog_name, hname);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write it */
|
|
|
|
(void) fprintf (out_file, "%s",
|
|
|
|
"/* menu system definitions. */\n"
|
|
|
|
"\n"
|
|
|
|
"#ifndef MENU_DEFS_H\n"
|
|
|
|
"#define MENU_DEFS_H\n"
|
|
|
|
"#include <stdlib.h>\n"
|
|
|
|
"#include <string.h>\n"
|
|
|
|
"#include <ctype.h>\n"
|
1998-07-16 11:08:26 +04:00
|
|
|
"#include <curses.h>\n\n"
|
|
|
|
);
|
1998-07-01 11:46:02 +04:00
|
|
|
|
2003-06-10 21:19:04 +04:00
|
|
|
if (do_msgxlat)
|
|
|
|
(void)fprintf(out_file, "#define MSG_XLAT(x) msg_string(x)\n");
|
|
|
|
else
|
|
|
|
(void)fprintf(out_file, "#define MSG_XLAT(x) (x)\n");
|
1998-07-01 11:46:02 +04:00
|
|
|
if (do_dynamic)
|
2003-06-10 21:19:04 +04:00
|
|
|
(void)fprintf(out_file, "#define DYNAMIC_MENUS\n");
|
|
|
|
if (do_dynamic || do_msgxlat)
|
|
|
|
(void)fprintf(out_file, "\n");
|
1998-07-01 11:46:02 +04:00
|
|
|
|
2003-07-07 16:20:56 +04:00
|
|
|
(void)fprintf(out_file,
|
2003-06-03 15:51:56 +04:00
|
|
|
"typedef struct menudesc menudesc;\n"
|
|
|
|
"typedef struct menu_ent menu_ent;\n"
|
1998-07-16 11:08:26 +04:00
|
|
|
"struct menu_ent {\n"
|
2003-05-16 23:57:22 +04:00
|
|
|
" const char *opt_name;\n"
|
2003-05-09 11:30:50 +04:00
|
|
|
" int opt_menu;\n"
|
|
|
|
" int opt_flags;\n"
|
2003-07-27 11:21:57 +04:00
|
|
|
" int (*opt_action)(menudesc *, void *);\n"
|
2003-06-03 15:51:56 +04:00
|
|
|
"};\n\n"
|
2003-05-09 11:30:50 +04:00
|
|
|
"#define OPT_SUB 1\n"
|
|
|
|
"#define OPT_ENDWIN 2\n"
|
|
|
|
"#define OPT_EXIT 4\n"
|
2003-07-07 16:20:56 +04:00
|
|
|
"#define OPT_IGNORE 8\n"
|
2003-05-09 11:30:50 +04:00
|
|
|
"#define OPT_NOMENU -1\n\n"
|
1997-09-26 21:54:09 +04:00
|
|
|
"struct menudesc {\n"
|
2003-05-16 23:57:22 +04:00
|
|
|
" const char *title;\n"
|
2003-05-09 11:30:50 +04:00
|
|
|
" int y, x;\n"
|
|
|
|
" int h, w;\n"
|
|
|
|
" int mopt;\n"
|
2003-05-09 14:21:43 +04:00
|
|
|
" int numopts;\n"
|
2003-05-09 11:30:50 +04:00
|
|
|
" int cursel;\n"
|
|
|
|
" int topline;\n"
|
|
|
|
" menu_ent *opts;\n"
|
|
|
|
" WINDOW *mw;\n"
|
2004-08-03 01:29:07 +04:00
|
|
|
" WINDOW *sv_mw;\n"
|
2003-05-09 11:30:50 +04:00
|
|
|
" const char *helpstr;\n"
|
|
|
|
" const char *exitstr;\n"
|
2003-06-09 22:48:40 +04:00
|
|
|
" void (*post_act)(menudesc *, void *);\n"
|
|
|
|
" void (*exit_act)(menudesc *, void *);\n"
|
2003-07-07 16:20:56 +04:00
|
|
|
" void (*draw_line)(menudesc *, int, void *);\n"
|
2003-06-03 15:51:56 +04:00
|
|
|
"};\n"
|
1997-09-26 21:54:09 +04:00
|
|
|
"\n"
|
|
|
|
"/* defines for mopt field. */\n"
|
2004-08-03 01:29:07 +04:00
|
|
|
#define STR(x) #x
|
|
|
|
#define MC_OPT(x) "#define " #x " " STR(x) "\n"
|
|
|
|
MC_OPT(MC_NOEXITOPT)
|
|
|
|
MC_OPT(MC_NOBOX)
|
|
|
|
MC_OPT(MC_SCROLL)
|
|
|
|
MC_OPT(MC_NOSHORTCUT)
|
|
|
|
MC_OPT(MC_NOCLEAR)
|
|
|
|
MC_OPT(MC_DFLTEXIT)
|
|
|
|
MC_OPT(MC_ALWAYS_SCROLL)
|
|
|
|
MC_OPT(MC_SUBMENU)
|
|
|
|
MC_OPT(MC_VALID)
|
|
|
|
#undef MC_OPT
|
|
|
|
#undef STR
|
2003-07-07 16:20:56 +04:00
|
|
|
);
|
1998-07-01 11:46:02 +04:00
|
|
|
|
|
|
|
(void) fprintf (out_file, "%s",
|
1997-09-26 21:54:09 +04:00
|
|
|
"\n"
|
|
|
|
"/* Prototypes */\n"
|
2003-07-25 11:22:05 +04:00
|
|
|
"int menu_init(void);\n"
|
|
|
|
"void process_menu(int, void *);\n"
|
|
|
|
"void __menu_initerror(void);\n"
|
1998-07-16 11:08:26 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
if (do_dynamic)
|
|
|
|
(void) fprintf (out_file, "%s",
|
2003-07-25 11:22:05 +04:00
|
|
|
"int new_menu(const char *, menu_ent *, int, \n"
|
|
|
|
"\tint, int, int, int, int,\n"
|
|
|
|
"\tvoid (*)(menudesc *, void *), "
|
|
|
|
"void (*)(menudesc *, int, void *),\n"
|
|
|
|
"\tvoid (*)(menudesc *, void *), "
|
|
|
|
"const char *, const char *);\n"
|
|
|
|
"void free_menu(int);\n"
|
2003-06-09 22:48:40 +04:00
|
|
|
"void set_menu_numopts(int, int);\n"
|
1998-07-16 11:08:26 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
(void) fprintf (out_file, "\n/* Menu names */\n");
|
1997-09-26 21:54:09 +04:00
|
|
|
for (i=0; i<menu_no; i++) {
|
|
|
|
(void) fprintf (out_file, "#define MENU_%s\t%d\n",
|
|
|
|
menus[i]->id, i);
|
|
|
|
}
|
|
|
|
|
1998-07-16 11:08:26 +04:00
|
|
|
if (do_dynamic)
|
|
|
|
(void) fprintf (out_file, "\n#define DYN_MENU_START\t%d",
|
|
|
|
menu_no);
|
|
|
|
|
|
|
|
(void) fprintf (out_file, "\n#define MAX_STRLEN %d\n"
|
|
|
|
"#endif\n", max_strlen);
|
1997-09-26 21:54:09 +04:00
|
|
|
fclose (out_file);
|
|
|
|
|
|
|
|
/* Now the C file */
|
|
|
|
out_file = fopen (cname, "w");
|
|
|
|
if (out_file == NULL) {
|
|
|
|
(void) fprintf (stderr, "%s: could not open %s.\n",
|
|
|
|
prog_name, cname);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initial code */
|
|
|
|
fprintf (out_file, "#include \"%s\"\n\n", hname);
|
|
|
|
fprintf (out_file, "%s\n\n", initcode);
|
|
|
|
|
|
|
|
/* data definitions */
|
|
|
|
|
1998-07-16 11:08:26 +04:00
|
|
|
/* func defs */
|
1997-09-26 21:54:09 +04:00
|
|
|
for (i=0; i<menu_no; i++) {
|
1998-07-16 11:08:26 +04:00
|
|
|
if (strlen(menus[i]->info->postact.code)) {
|
|
|
|
(void) fprintf (out_file,
|
2003-06-10 21:19:04 +04:00
|
|
|
"/*ARGSUSED*/\n"
|
|
|
|
"static void menu_%d_postact(menudesc *menu, void *arg)\n{\n", i);
|
1998-07-16 11:08:26 +04:00
|
|
|
if (menus[i]->info->postact.endwin)
|
2004-08-03 01:29:07 +04:00
|
|
|
(void) fprintf (out_file, "\tendwin();\n");
|
1998-07-16 11:08:26 +04:00
|
|
|
(void) fprintf (out_file,
|
2003-06-10 21:19:04 +04:00
|
|
|
"\t%s\n}\n\n",
|
1998-07-16 11:08:26 +04:00
|
|
|
menus[i]->info->postact.code);
|
|
|
|
}
|
|
|
|
if (strlen(menus[i]->info->exitact.code)) {
|
|
|
|
(void) fprintf (out_file,
|
2003-06-10 21:19:04 +04:00
|
|
|
"/*ARGSUSED*/\n"
|
|
|
|
"static void menu_%d_exitact(menudesc *menu, void *arg)\n{\n", i);
|
1998-07-16 11:08:26 +04:00
|
|
|
if (menus[i]->info->exitact.endwin)
|
2004-08-03 01:29:07 +04:00
|
|
|
(void) fprintf (out_file, "\tendwin();\n");
|
1998-07-16 11:08:26 +04:00
|
|
|
(void) fprintf (out_file, "\t%s\n}\n\n",
|
|
|
|
menus[i]->info->exitact.code);
|
|
|
|
}
|
|
|
|
j = 0;
|
1997-09-26 21:54:09 +04:00
|
|
|
toptn = menus[i]->info->optns;
|
2003-06-03 15:51:56 +04:00
|
|
|
for (;toptn != NULL; j++, toptn = toptn->next) {
|
|
|
|
if (strlen(toptn->optact.code) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
(void) fprintf (out_file,
|
|
|
|
"/*ARGSUSED*/\n"
|
2003-07-27 11:21:57 +04:00
|
|
|
"static int opt_act_%d_%d(menudesc *m, void *arg)\n"
|
2003-06-03 15:51:56 +04:00
|
|
|
"{\n\t%s\n\treturn %s;\n}\n\n",
|
|
|
|
i, j, toptn->optact.code,
|
|
|
|
(toptn->doexit ? "1" : "0"));
|
1998-07-16 11:08:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* optentX */
|
|
|
|
for (i=0; i<menu_no; i++) {
|
|
|
|
if (menus[i]->info->numopt > 53) {
|
|
|
|
(void) fprintf (stderr, "Menu %s has "
|
|
|
|
"too many options.\n",
|
|
|
|
menus[i]->info->title);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
(void) fprintf (out_file,
|
|
|
|
"static menu_ent optent%d[] = {\n", i);
|
2006-02-21 00:06:40 +03:00
|
|
|
name_is_code = 0;
|
|
|
|
for (j = 0, toptn = menus[i]->info->optns; toptn;
|
|
|
|
toptn = toptn->next, j++) {
|
|
|
|
name_is_code += toptn->name_is_code;
|
2003-05-08 20:20:56 +04:00
|
|
|
(void) fprintf (out_file, "\t{%s,%d,%d,",
|
2006-02-21 00:06:40 +03:00
|
|
|
toptn->name_is_code ? "0" : toptn->name,
|
|
|
|
toptn->menu,
|
1998-07-16 11:08:26 +04:00
|
|
|
(toptn->issub ? OPT_SUB : 0)
|
|
|
|
+(toptn->doexit ? OPT_EXIT : 0)
|
|
|
|
+(toptn->optact.endwin ? OPT_ENDWIN : 0));
|
|
|
|
if (strlen(toptn->optact.code))
|
|
|
|
(void) fprintf (out_file, "opt_act_%d_%d}",
|
|
|
|
i, j);
|
1998-06-29 12:46:37 +04:00
|
|
|
else
|
1998-07-16 11:08:26 +04:00
|
|
|
(void) fprintf (out_file, "NULL}");
|
|
|
|
(void) fprintf (out_file, "%s\n",
|
|
|
|
(toptn->next ? "," : ""));
|
1997-09-26 21:54:09 +04:00
|
|
|
}
|
1998-07-16 11:08:26 +04:00
|
|
|
(void) fprintf (out_file, "\t};\n\n");
|
|
|
|
|
2006-02-21 00:06:40 +03:00
|
|
|
if (name_is_code) {
|
|
|
|
menus[i]->info->name_is_code = 1;
|
|
|
|
fprintf(out_file, "static void menu_%d_legend("
|
|
|
|
"menudesc *menu, int opt, void *arg)\n{\n"
|
|
|
|
"\tswitch (opt) {\n", i);
|
|
|
|
for (j = 0, toptn = menus[i]->info->optns; toptn;
|
|
|
|
toptn = toptn->next, j++) {
|
|
|
|
if (!toptn->name_is_code)
|
|
|
|
continue;
|
|
|
|
fprintf(out_file, "\tcase %d:\n\t\t{%s};\n"
|
|
|
|
"\t\tbreak;\n", j, toptn->name);
|
|
|
|
}
|
|
|
|
fprintf(out_file, "\t}\n}\n\n");
|
|
|
|
}
|
1997-09-26 21:54:09 +04:00
|
|
|
}
|
|
|
|
|
1998-07-16 11:08:26 +04:00
|
|
|
|
1997-09-26 21:54:09 +04:00
|
|
|
/* menus */
|
1998-07-16 11:08:26 +04:00
|
|
|
(void) fprintf (out_file, "static struct menudesc menu_def[] = {\n");
|
1998-06-24 10:46:23 +04:00
|
|
|
for (i=0; i<menu_no; i++) {
|
1997-09-26 21:54:09 +04:00
|
|
|
(void) fprintf (out_file,
|
2004-08-03 01:29:07 +04:00
|
|
|
"\t{%s,%d,%d,%d,%d,%d,%d,0,0,optent%d,NULL,NULL,",
|
1997-09-26 21:54:09 +04:00
|
|
|
menus[i]->info->title, menus[i]->info->y,
|
|
|
|
menus[i]->info->x, menus[i]->info->h,
|
|
|
|
menus[i]->info->w, menus[i]->info->mopt,
|
|
|
|
menus[i]->info->numopt, i);
|
1998-06-24 10:46:23 +04:00
|
|
|
if (menus[i]->info->helpstr == NULL)
|
1998-07-01 11:46:02 +04:00
|
|
|
(void) fprintf (out_file, "NULL");
|
1998-06-24 10:46:23 +04:00
|
|
|
else {
|
|
|
|
tmpstr = menus[i]->info->helpstr;
|
2004-08-03 01:29:07 +04:00
|
|
|
if (*tmpstr != '"')
|
|
|
|
(void)fprintf(out_file, "%s", tmpstr);
|
|
|
|
else {
|
|
|
|
/* Skip an initial newline. */
|
|
|
|
if (tmpstr[1] == '\n')
|
|
|
|
*++tmpstr = '"';
|
|
|
|
(void) fprintf (out_file, "\n");
|
|
|
|
while (*tmpstr) {
|
|
|
|
if (*tmpstr != '\n') {
|
|
|
|
fputc (*tmpstr++, out_file);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
(void) fprintf (out_file, "\\n\"\n\"");
|
1998-06-24 10:46:23 +04:00
|
|
|
tmpstr++;
|
|
|
|
}
|
2004-08-03 01:29:07 +04:00
|
|
|
}
|
1998-06-24 10:46:23 +04:00
|
|
|
}
|
1999-06-20 06:07:18 +04:00
|
|
|
(void) fprintf (out_file, ",");
|
2004-08-03 01:29:07 +04:00
|
|
|
if (menus[i]->info->mopt & MC_NOEXITOPT)
|
1999-06-20 06:07:18 +04:00
|
|
|
(void) fprintf (out_file, "NULL");
|
|
|
|
else if (menus[i]->info->exitstr != NULL)
|
2000-07-24 02:18:44 +04:00
|
|
|
(void) fprintf (out_file, "%s",
|
|
|
|
menus[i]->info->exitstr);
|
1999-06-20 06:07:18 +04:00
|
|
|
else
|
|
|
|
(void) fprintf (out_file, "\"Exit\"");
|
1997-09-26 21:54:09 +04:00
|
|
|
if (strlen(menus[i]->info->postact.code))
|
1998-07-16 11:08:26 +04:00
|
|
|
(void) fprintf (out_file, ",menu_%d_postact", i);
|
|
|
|
else
|
|
|
|
(void) fprintf (out_file, ",NULL");
|
1997-09-26 21:54:09 +04:00
|
|
|
if (strlen(menus[i]->info->exitact.code))
|
1998-07-16 11:08:26 +04:00
|
|
|
(void) fprintf (out_file, ",menu_%d_exitact", i);
|
|
|
|
else
|
|
|
|
(void) fprintf (out_file, ",NULL");
|
2006-02-21 00:06:40 +03:00
|
|
|
if (menus[i]->info->name_is_code)
|
|
|
|
(void) fprintf (out_file, ",menu_%d_legend", i);
|
|
|
|
else
|
|
|
|
(void) fprintf (out_file, ",NULL");
|
1998-07-16 11:08:26 +04:00
|
|
|
|
|
|
|
(void) fprintf (out_file, "},\n");
|
1997-09-26 21:54:09 +04:00
|
|
|
|
|
|
|
}
|
1998-07-16 11:08:26 +04:00
|
|
|
(void) fprintf (out_file, "{NULL}};\n\n");
|
1997-09-26 21:54:09 +04:00
|
|
|
|
1997-11-09 23:59:11 +03:00
|
|
|
/* __menu_initerror: initscr failed. */
|
|
|
|
(void) fprintf (out_file,
|
|
|
|
"/* __menu_initerror: initscr failed. */\n"
|
|
|
|
"void __menu_initerror (void) {\n");
|
|
|
|
if (error_act.code == NULL) {
|
|
|
|
(void) fprintf (out_file,
|
|
|
|
"\t(void) fprintf (stderr, "
|
2001-01-07 09:09:19 +03:00
|
|
|
"\"%%s: Could not initialize curses\\n\", "
|
2001-02-21 02:51:59 +03:00
|
|
|
"getprogname());\n"
|
1997-11-09 23:59:11 +03:00
|
|
|
"\texit(1);\n"
|
|
|
|
"}\n");
|
|
|
|
} else {
|
|
|
|
if (error_act.endwin)
|
|
|
|
(void) fprintf (out_file, "\tendwin();\n");
|
|
|
|
(void) fprintf (out_file, "%s\n}\n", error_act.code);
|
|
|
|
}
|
|
|
|
|
1998-07-16 11:08:26 +04:00
|
|
|
/* Copy menu_sys.def file. */
|
|
|
|
while ((ch = fgetc(sys_file)) != '\014') /* Control-L */
|
2003-05-09 11:30:50 +04:00
|
|
|
fputc(ch, out_file);
|
1998-07-16 11:08:26 +04:00
|
|
|
|
|
|
|
if (do_dynamic) {
|
|
|
|
while ((ch = fgetc(sys_file)) != '\n')
|
|
|
|
/* skip it */;
|
|
|
|
while ((ch = fgetc(sys_file)) != EOF)
|
|
|
|
fputc(ch, out_file);
|
|
|
|
}
|
|
|
|
|
1997-09-26 21:54:09 +04:00
|
|
|
fclose (out_file);
|
|
|
|
fclose (sys_file);
|
|
|
|
}
|