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