m_hook.c revision 1.2
1/*-----------------------------------------------------------------------------+ 2| The ncurses menu library is Copyright (C) 1995-1997 | 3| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | 4| All Rights Reserved. | 5| | 6| Permission to use, copy, modify, and distribute this software and its | 7| documentation for any purpose and without fee is hereby granted, provided | 8| that the above copyright notice appear in all copies and that both that | 9| copyright notice and this permission notice appear in supporting | 10| documentation, and that the name of the above listed copyright holder(s) not | 11| be used in advertising or publicity pertaining to distribution of the | 12| software without specific, written prior permission. | 13| | 14| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO | 15| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- | 16| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR | 17| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- | 18| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | 19| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH | 20| THE USE OR PERFORMANCE OF THIS SOFTWARE. | 21+-----------------------------------------------------------------------------*/ 22 23/*************************************************************************** 24* Module menu_hook * 25* Assign application specific routines for automatic invocation by menus * 26***************************************************************************/ 27 28#include "menu.priv.h" 29 30MODULE_ID("Id: m_hook.c,v 1.4 1997/05/01 16:47:26 juergen Exp $") 31 32/* "Template" macro to generate function to set application specific hook */ 33#define GEN_HOOK_SET_FUNCTION( typ, name ) \ 34int set_ ## typ ## _ ## name (MENU *menu, Menu_Hook func )\ 35{\ 36 (Normalize_Menu(menu) -> typ ## name = func );\ 37 RETURN(E_OK);\ 38} 39 40/* "Template" macro to generate function to get application specific hook */ 41#define GEN_HOOK_GET_FUNCTION( typ, name ) \ 42Menu_Hook typ ## _ ## name ( const MENU *menu )\ 43{\ 44 return (Normalize_Menu(menu) -> typ ## name);\ 45} 46 47/*--------------------------------------------------------------------------- 48| Facility : libnmenu 49| Function : int set_menu_init(MENU *menu, void (*f)(MENU *)) 50| 51| Description : Set user-exit which is called when menu is posted 52| or just after the top row changes. 53| 54| Return Values : E_OK - success 55+--------------------------------------------------------------------------*/ 56GEN_HOOK_SET_FUNCTION( menu, init ) 57 58/*--------------------------------------------------------------------------- 59| Facility : libnmenu 60| Function : void (*)(MENU *) menu_init(const MENU *menu) 61| 62| Description : Return address of user-exit function which is called 63| when a menu is posted or just after the top row 64| changes. 65| 66| Return Values : Menu init function address or NULL 67+--------------------------------------------------------------------------*/ 68GEN_HOOK_GET_FUNCTION( menu, init ) 69 70/*--------------------------------------------------------------------------- 71| Facility : libnmenu 72| Function : int set_menu_term (MENU *menu, void (*f)(MENU *)) 73| 74| Description : Set user-exit which is called when menu is unposted 75| or just before the top row changes. 76| 77| Return Values : E_OK - success 78+--------------------------------------------------------------------------*/ 79GEN_HOOK_SET_FUNCTION( menu, term ) 80 81/*--------------------------------------------------------------------------- 82| Facility : libnmenu 83| Function : void (*)(MENU *) menu_term(const MENU *menu) 84| 85| Description : Return address of user-exit function which is called 86| when a menu is unposted or just before the top row 87| changes. 88| 89| Return Values : Menu finalization function address or NULL 90+--------------------------------------------------------------------------*/ 91GEN_HOOK_GET_FUNCTION( menu, term ) 92 93/*--------------------------------------------------------------------------- 94| Facility : libnmenu 95| Function : int set_item_init (MENU *menu, void (*f)(MENU *)) 96| 97| Description : Set user-exit which is called when menu is posted 98| or just after the current item changes. 99| 100| Return Values : E_OK - success 101+--------------------------------------------------------------------------*/ 102GEN_HOOK_SET_FUNCTION( item, init ) 103 104/*--------------------------------------------------------------------------- 105| Facility : libnmenu 106| Function : void (*)(MENU *) item_init (const MENU *menu) 107| 108| Description : Return address of user-exit function which is called 109| when a menu is posted or just after the current item 110| changes. 111| 112| Return Values : Item init function address or NULL 113+--------------------------------------------------------------------------*/ 114GEN_HOOK_GET_FUNCTION( item, init ) 115 116/*--------------------------------------------------------------------------- 117| Facility : libnmenu 118| Function : int set_item_term (MENU *menu, void (*f)(MENU *)) 119| 120| Description : Set user-exit which is called when menu is unposted 121| or just before the current item changes. 122| 123| Return Values : E_OK - success 124+--------------------------------------------------------------------------*/ 125GEN_HOOK_SET_FUNCTION( item, term ) 126 127/*--------------------------------------------------------------------------- 128| Facility : libnmenu 129| Function : void (*)(MENU *) item_init (const MENU *menu) 130| 131| Description : Return address of user-exit function which is called 132| when a menu is unposted or just before the current item 133| changes. 134| 135| Return Values : Item finalization function address or NULL 136+--------------------------------------------------------------------------*/ 137GEN_HOOK_GET_FUNCTION( item, term ) 138 139/* m_hook.c ends here */ 140