1 /****************************************************************************
2 * Copyright 2018,2020 Thomas E. Dickey *
3 * Copyright 1998-2012,2016 Free Software Foundation, Inc. *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
28 ****************************************************************************/
30 /****************************************************************************
31 * Author: Juergen Pfeifer, 1995,1997 *
32 ****************************************************************************/
34 #include "form.priv.h"
36 MODULE_ID("$Id: frm_hook.c,v 1.20 2020/05/24 01:40:20 anonymous.maarten Exp $")
38 /* "Template" macro to generate function to set application specific hook */
39 #define GEN_HOOK_SET_FUNCTION( typ, name ) \
40 FORM_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (FORM *form, Form_Hook func)\
43 T((T_CALLED("set_" #typ"_"#name"(%p,%s)"), (void *) form, TR_FUNC_ARG(0, func)));\
44 (Normalize_Form( form ) -> typ ## name) = func ;\
48 /* "Template" macro to generate function to get application specific hook */
49 #define GEN_HOOK_GET_FUNCTION( typ, name ) \
50 FORM_IMPEXP Form_Hook NCURSES_API typ ## _ ## name ( const FORM *form )\
52 T((T_CALLED(#typ "_" #name "(%p)"), (const void *) form));\
53 returnFormHook( Normalize_Form( form ) -> typ ## name );\
56 /*---------------------------------------------------------------------------
58 | Function : int set_field_init(FORM *form, Form_Hook f)
60 | Description : Assigns an application defined initialization function
61 | to be called when the form is posted and just after
62 | the current field changes.
64 | Return Values : E_OK - success
65 +--------------------------------------------------------------------------*/
66 GEN_HOOK_SET_FUNCTION(field, init)
68 /*---------------------------------------------------------------------------
70 | Function : Form_Hook field_init(const FORM *form)
72 | Description : Retrieve field initialization routine address.
74 | Return Values : The address or NULL if no hook defined.
75 +--------------------------------------------------------------------------*/
76 GEN_HOOK_GET_FUNCTION(field, init)
78 /*---------------------------------------------------------------------------
80 | Function : int set_field_term(FORM *form, Form_Hook f)
82 | Description : Assigns an application defined finalization function
83 | to be called when the form is unposted and just before
84 | the current field changes.
86 | Return Values : E_OK - success
87 +--------------------------------------------------------------------------*/
88 GEN_HOOK_SET_FUNCTION(field, term)
90 /*---------------------------------------------------------------------------
92 | Function : Form_Hook field_term(const FORM *form)
94 | Description : Retrieve field finalization routine address.
96 | Return Values : The address or NULL if no hook defined.
97 +--------------------------------------------------------------------------*/
98 GEN_HOOK_GET_FUNCTION(field, term)
100 /*---------------------------------------------------------------------------
101 | Facility : libnform
102 | Function : int set_form_init(FORM *form, Form_Hook f)
104 | Description : Assigns an application defined initialization function
105 | to be called when the form is posted and just after
108 | Return Values : E_OK - success
109 +--------------------------------------------------------------------------*/
110 GEN_HOOK_SET_FUNCTION(form, init)
112 /*---------------------------------------------------------------------------
113 | Facility : libnform
114 | Function : Form_Hook form_init(const FORM *form)
116 | Description : Retrieve form initialization routine address.
118 | Return Values : The address or NULL if no hook defined.
119 +--------------------------------------------------------------------------*/
120 GEN_HOOK_GET_FUNCTION(form, init)
122 /*---------------------------------------------------------------------------
123 | Facility : libnform
124 | Function : int set_form_term(FORM *form, Form_Hook f)
126 | Description : Assigns an application defined finalization function
127 | to be called when the form is unposted and just before
130 | Return Values : E_OK - success
131 +--------------------------------------------------------------------------*/
132 GEN_HOOK_SET_FUNCTION(form, term)
134 /*---------------------------------------------------------------------------
135 | Facility : libnform
136 | Function : Form_Hook form_term(const FORM *form)
138 | Description : Retrieve form finalization routine address.
140 | Return Values : The address or NULL if no hook defined.
141 +--------------------------------------------------------------------------*/
142 GEN_HOOK_GET_FUNCTION(form, term)
144 /* frm_hook.c ends here */