Provide an accessor for the menu description structure by manu identifier.

Usefull for dynamic menus where you want to change details on the
fly "from the outside" (i.e. while not in one of the callback functions).
This commit is contained in:
martin 2019-02-06 20:08:15 +00:00
parent a27520238a
commit fbb0a702e6
2 changed files with 13 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mdb.c,v 1.49 2019/01/09 19:43:37 martin Exp $ */
/* $NetBSD: mdb.c,v 1.50 2019/02/06 20:08:15 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: mdb.c,v 1.49 2019/01/09 19:43:37 martin Exp $");
__RCSID("$NetBSD: mdb.c,v 1.50 2019/02/06 20:08:15 martin Exp $");
#endif
@ -248,6 +248,7 @@ write_menu_file(char *initcode)
"const char *, const char *);\n"
"void free_menu(int);\n"
"void set_menu_numopts(int, int);\n"
"menudesc *get_menudesc(int);\n"
);
(void)fprintf(out_file, "\n/* Menu names */\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: menu_sys.def,v 1.64 2019/01/09 19:43:37 martin Exp $ */
/* $NetBSD: menu_sys.def,v 1.65 2019/02/06 20:08:15 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -809,6 +809,15 @@ set_menu_numopts(int menu, int numopts)
MENUS(menu).numopts = numopts;
}
menudesc *
get_menudesc(int menu)
{
if (menu < 0 || menu >= num_menus)
return NULL;
return &MENUS(menu);
}
/* Control L is end of standard routines, remaining only for dynamic. */
/* Beginning of routines for dynamic menus. */