Add code for handling NULL return from initscr(). Added "ERROR ACTION"
for user code for above error.
This commit is contained in:
parent
37ac6a5ba8
commit
1ec08fd982
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: defs.h,v 1.1.1.1 1997/09/26 17:54:09 phil Exp $ */
|
||||
/* $NetBSD: defs.h,v 1.2 1997/11/09 20:59:11 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -70,6 +70,8 @@ EXTERN id_rec *root INIT(NULL);
|
|||
EXTERN struct menu_info default_info;
|
||||
EXTERN id_rec default_menu;
|
||||
|
||||
EXTERN action error_act INIT({NULL});
|
||||
|
||||
/* Prototypes. */
|
||||
|
||||
/* From util.c */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mdb.c,v 1.1.1.1 1997/09/26 17:54:09 phil Exp $ */
|
||||
/* $NetBSD: mdb.c,v 1.2 1997/11/09 20:59:14 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -172,6 +172,7 @@ write_menu_file (char *initcode)
|
|||
"\n"
|
||||
"/* Prototypes */\n"
|
||||
"void process_menu (int num);\n"
|
||||
"void __menu_initerror (void);\n"
|
||||
"\n"
|
||||
"/* Menu names */\n"
|
||||
);
|
||||
|
@ -286,6 +287,22 @@ write_menu_file (char *initcode)
|
|||
while ((ch = fgetc(sys_file)) != EOF)
|
||||
fputc(ch, out_file);
|
||||
|
||||
/* __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, "
|
||||
"\"Could not initialize curses\\n\");\n"
|
||||
"\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);
|
||||
}
|
||||
|
||||
fclose (out_file);
|
||||
fclose (sys_file);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: menu_sys.def,v 1.1.1.1 1997/09/26 17:54:09 phil Exp $ */
|
||||
/* $NetBSD: menu_sys.def,v 1.2 1997/11/09 20:59:15 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -277,7 +277,10 @@ void process_menu (int num)
|
|||
|
||||
/* Initialize? */
|
||||
if (!__menu_init) {
|
||||
initscr();
|
||||
if (initscr() == NULL) {
|
||||
__menu_initerror();
|
||||
return;
|
||||
}
|
||||
cbreak();
|
||||
noecho();
|
||||
__menu_init = 1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: parse.y,v 1.1.1.1 1997/09/26 17:54:09 phil Exp $ */
|
||||
/* $NetBSD: parse.y,v 1.2 1997/11/09 20:59:16 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -56,7 +56,7 @@ static optn_info *cur_optn;
|
|||
|
||||
|
||||
%token <i_value> X Y W H NO BOX SUB MENU NEXT EXIT ACTION ENDWIN OPTION TITLE
|
||||
%token <i_value> DEFAULT DISPLAY
|
||||
%token <i_value> DEFAULT DISPLAY ERROR
|
||||
%token <s_value> STRING NAME CODE INT_CONST CHAR_CONST
|
||||
|
||||
%type <s_value> init_code system
|
||||
|
@ -82,8 +82,12 @@ init_code : /* empty */ { $$ = ""; }
|
|||
menu_list : /* empty */
|
||||
| menu_list menu_def
|
||||
| menu_list default_def
|
||||
| menu_list initerror_def
|
||||
;
|
||||
|
||||
initerror_def : ERROR action ';'
|
||||
{ error_act = $2; }
|
||||
|
||||
default_def : DEFAULT
|
||||
{ cur_menu = &default_menu; }
|
||||
opt opt_list ";"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: scan.l,v 1.1.1.1 1997/09/26 17:54:09 phil Exp $ */
|
||||
/* $NetBSD: scan.l,v 1.2 1997/11/09 20:59:18 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -92,6 +92,7 @@ default { return DEFAULT; }
|
|||
|
||||
display { return DISPLAY; }
|
||||
|
||||
error { return ERROR; }
|
||||
|
||||
\"([^\"\n]*(\\\")?)*\" {
|
||||
yylval.s_value = strdup (yytext);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: menus.mc,v 1.1.1.1 1997/09/26 17:54:10 phil Exp $ */
|
||||
/* $NetBSD: menus.mc,v 1.2 1997/11/09 20:59:20 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -44,6 +44,9 @@
|
|||
|
||||
default x=20, y=10;
|
||||
|
||||
error action { fprintf (stderr, "Testm: Could not initialize curses.\n");
|
||||
exit(1); };
|
||||
|
||||
menu root, title " Main Menu of Test System";
|
||||
option "Do nothing option",
|
||||
action { }
|
||||
|
|
Loading…
Reference in New Issue