frm_hook.c revision 1.9
1672SN/A/*	$OpenBSD: frm_hook.c,v 1.9 2023/10/17 09:52:10 nicm Exp $	*/
2672SN/A/****************************************************************************
3672SN/A * Copyright 2018,2020 Thomas E. Dickey                                     *
4672SN/A * Copyright 1998-2012,2016 Free Software Foundation, Inc.                  *
5672SN/A *                                                                          *
6672SN/A * Permission is hereby granted, free of charge, to any person obtaining a  *
7672SN/A * copy of this software and associated documentation files (the            *
8672SN/A * "Software"), to deal in the Software without restriction, including      *
9672SN/A * without limitation the rights to use, copy, modify, merge, publish,      *
10672SN/A * distribute, distribute with modifications, sublicense, and/or sell       *
11672SN/A * copies of the Software, and to permit persons to whom the Software is    *
12672SN/A * furnished to do so, subject to the following conditions:                 *
13672SN/A *                                                                          *
14672SN/A * The above copyright notice and this permission notice shall be included  *
15672SN/A * in all copies or substantial portions of the Software.                   *
16672SN/A *                                                                          *
17672SN/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18672SN/A * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19672SN/A * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20672SN/A * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21672SN/A * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22672SN/A * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23672SN/A * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24672SN/A *                                                                          *
25672SN/A * Except as contained in this notice, the name(s) of the above copyright   *
26672SN/A * holders shall not be used in advertising or otherwise to promote the     *
27672SN/A * sale, use or other dealings in this Software without prior written       *
28672SN/A * authorization.                                                           *
29672SN/A ****************************************************************************/
30672SN/A
31672SN/A/****************************************************************************
32672SN/A *   Author:  Juergen Pfeifer, 1995,1997                                    *
33672SN/A ****************************************************************************/
34672SN/A
35672SN/A#include "form.priv.h"
36672SN/A
37672SN/AMODULE_ID("$Id: frm_hook.c,v 1.9 2023/10/17 09:52:10 nicm Exp $")
38672SN/A
39672SN/A/* "Template" macro to generate function to set application specific hook */
40672SN/A#define GEN_HOOK_SET_FUNCTION( typ, name ) \
41672SN/AFORM_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (FORM *form, Form_Hook func)\
42672SN/A{\
43672SN/A   TR_FUNC_BFR(1); \
44672SN/A   T((T_CALLED("set_" #typ"_"#name"(%p,%s)"), (void *) form, TR_FUNC_ARG(0, func)));\
45672SN/A   (Normalize_Form( form ) -> typ ## name) = func ;\
46672SN/A   RETURN(E_OK);\
47672SN/A}
48672SN/A
49672SN/A/* "Template" macro to generate function to get application specific hook */
50672SN/A#define GEN_HOOK_GET_FUNCTION( typ, name ) \
51672SN/AFORM_IMPEXP Form_Hook NCURSES_API typ ## _ ## name ( const FORM *form )\
52672SN/A{\
53672SN/A   T((T_CALLED(#typ "_" #name "(%p)"), (const void *) form));\
54672SN/A   returnFormHook( Normalize_Form( form ) -> typ ## name );\
55672SN/A}
56672SN/A
57672SN/A/*---------------------------------------------------------------------------
58672SN/A|   Facility      :  libnform
59672SN/A|   Function      :  int set_field_init(FORM *form, Form_Hook f)
60672SN/A|
61672SN/A|   Description   :  Assigns an application defined initialization function
62672SN/A|                    to be called when the form is posted and just after
63672SN/A|                    the current field changes.
64672SN/A|
65672SN/A|   Return Values :  E_OK      - success
66672SN/A+--------------------------------------------------------------------------*/
67672SN/AGEN_HOOK_SET_FUNCTION(field, init)
68672SN/A
69672SN/A/*---------------------------------------------------------------------------
70672SN/A|   Facility      :  libnform
71672SN/A|   Function      :  Form_Hook field_init(const FORM *form)
72672SN/A|
73672SN/A|   Description   :  Retrieve field initialization routine address.
74672SN/A|
75672SN/A|   Return Values :  The address or NULL if no hook defined.
76672SN/A+--------------------------------------------------------------------------*/
77672SN/AGEN_HOOK_GET_FUNCTION(field, init)
78672SN/A
79672SN/A/*---------------------------------------------------------------------------
80672SN/A|   Facility      :  libnform
81672SN/A|   Function      :  int set_field_term(FORM *form, Form_Hook f)
82672SN/A|
83672SN/A|   Description   :  Assigns an application defined finalization function
84672SN/A|                    to be called when the form is unposted and just before
85672SN/A|                    the current field changes.
86672SN/A|
87672SN/A|   Return Values :  E_OK      - success
88672SN/A+--------------------------------------------------------------------------*/
89672SN/AGEN_HOOK_SET_FUNCTION(field, term)
90672SN/A
91672SN/A/*---------------------------------------------------------------------------
92672SN/A|   Facility      :  libnform
93672SN/A|   Function      :  Form_Hook field_term(const FORM *form)
94672SN/A|
95672SN/A|   Description   :  Retrieve field finalization routine address.
96672SN/A|
97672SN/A|   Return Values :  The address or NULL if no hook defined.
98672SN/A+--------------------------------------------------------------------------*/
99672SN/AGEN_HOOK_GET_FUNCTION(field, term)
100672SN/A
101672SN/A/*---------------------------------------------------------------------------
102672SN/A|   Facility      :  libnform
103672SN/A|   Function      :  int set_form_init(FORM *form, Form_Hook f)
104672SN/A|
105672SN/A|   Description   :  Assigns an application defined initialization function
106672SN/A|                    to be called when the form is posted and just after
107672SN/A|                    a page change.
108672SN/A|
109672SN/A|   Return Values :  E_OK       - success
110672SN/A+--------------------------------------------------------------------------*/
111672SN/AGEN_HOOK_SET_FUNCTION(form, init)
112672SN/A
113672SN/A/*---------------------------------------------------------------------------
114672SN/A|   Facility      :  libnform
115672SN/A|   Function      :  Form_Hook form_init(const FORM *form)
116672SN/A|
117672SN/A|   Description   :  Retrieve form initialization routine address.
118672SN/A|
119672SN/A|   Return Values :  The address or NULL if no hook defined.
120672SN/A+--------------------------------------------------------------------------*/
121672SN/AGEN_HOOK_GET_FUNCTION(form, init)
122672SN/A
123672SN/A/*---------------------------------------------------------------------------
124672SN/A|   Facility      :  libnform
125672SN/A|   Function      :  int set_form_term(FORM *form, Form_Hook f)
126672SN/A|
127672SN/A|   Description   :  Assigns an application defined finalization function
128672SN/A|                    to be called when the form is unposted and just before
129672SN/A|                    a page change.
130672SN/A|
131672SN/A|   Return Values :  E_OK       - success
132672SN/A+--------------------------------------------------------------------------*/
133672SN/AGEN_HOOK_SET_FUNCTION(form, term)
134672SN/A
135672SN/A/*---------------------------------------------------------------------------
136672SN/A|   Facility      :  libnform
137672SN/A|   Function      :  Form_Hook form_term(const FORM *form)
138672SN/A|
139672SN/A|   Description   :  Retrieve form finalization routine address.
140672SN/A|
141672SN/A|   Return Values :  The address or NULL if no hook defined.
142672SN/A+--------------------------------------------------------------------------*/
143672SN/AGEN_HOOK_GET_FUNCTION(form, term)
144672SN/A
145672SN/A/* frm_hook.c ends here */
146672SN/A