frm_hook.c revision 1.3
1/*	$OpenBSD: frm_hook.c,v 1.3 1997/12/03 05:40:13 millert Exp $	*/
2
3/*-----------------------------------------------------------------------------+
4|           The ncurses form 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#include "form.priv.h"
26
27MODULE_ID("Id: frm_hook.c,v 1.5 1997/05/01 16:47:54 juergen Exp $")
28
29/* "Template" macro to generate function to set application specific hook */
30#define GEN_HOOK_SET_FUNCTION( typ, name ) \
31int set_ ## typ ## _ ## name (FORM *form, Form_Hook func)\
32{\
33   (Normalize_Form( form ) -> typ ## name) = func ;\
34   RETURN(E_OK);\
35}
36
37/* "Template" macro to generate function to get application specific hook */
38#define GEN_HOOK_GET_FUNCTION( typ, name ) \
39Form_Hook typ ## _ ## name ( const FORM *form )\
40{\
41   return ( Normalize_Form( form ) -> typ ## name );\
42}
43
44/*---------------------------------------------------------------------------
45|   Facility      :  libnform
46|   Function      :  int set_field_init(FORM *form, Form_Hook f)
47|
48|   Description   :  Assigns an application defined initialization function
49|                    to be called when the form is posted and just after
50|                    the current field changes.
51|
52|   Return Values :  E_OK      - success
53+--------------------------------------------------------------------------*/
54GEN_HOOK_SET_FUNCTION(field,init)
55
56/*---------------------------------------------------------------------------
57|   Facility      :  libnform
58|   Function      :  Form_Hook field_init(const FORM *form)
59|
60|   Description   :  Retrieve field initialization routine address.
61|
62|   Return Values :  The address or NULL if no hook defined.
63+--------------------------------------------------------------------------*/
64GEN_HOOK_GET_FUNCTION(field,init)
65
66/*---------------------------------------------------------------------------
67|   Facility      :  libnform
68|   Function      :  int set_field_term(FORM *form, Form_Hook f)
69|
70|   Description   :  Assigns an application defined finalization function
71|                    to be called when the form is unposted and just before
72|                    the current field changes.
73|
74|   Return Values :  E_OK      - success
75+--------------------------------------------------------------------------*/
76GEN_HOOK_SET_FUNCTION(field,term)
77
78/*---------------------------------------------------------------------------
79|   Facility      :  libnform
80|   Function      :  Form_Hook field_term(const FORM *form)
81|
82|   Description   :  Retrieve field finalization routine address.
83|
84|   Return Values :  The address or NULL if no hook defined.
85+--------------------------------------------------------------------------*/
86GEN_HOOK_GET_FUNCTION(field,term)
87
88/*---------------------------------------------------------------------------
89|   Facility      :  libnform
90|   Function      :  int set_form_init(FORM *form, Form_Hook f)
91|
92|   Description   :  Assigns an application defined initialization function
93|                    to be called when the form is posted and just after
94|                    a page change.
95|
96|   Return Values :  E_OK       - success
97+--------------------------------------------------------------------------*/
98GEN_HOOK_SET_FUNCTION(form,init)
99
100/*---------------------------------------------------------------------------
101|   Facility      :  libnform
102|   Function      :  Form_Hook form_init(const FORM *form)
103|
104|   Description   :  Retrieve form initialization routine address.
105|
106|   Return Values :  The address or NULL if no hook defined.
107+--------------------------------------------------------------------------*/
108GEN_HOOK_GET_FUNCTION(form,init)
109
110/*---------------------------------------------------------------------------
111|   Facility      :  libnform
112|   Function      :  int set_form_term(FORM *form, Form_Hook f)
113|
114|   Description   :  Assigns an application defined finalization function
115|                    to be called when the form is unposted and just before
116|                    a page change.
117|
118|   Return Values :  E_OK       - success
119+--------------------------------------------------------------------------*/
120GEN_HOOK_SET_FUNCTION(form,term)
121
122/*---------------------------------------------------------------------------
123|   Facility      :  libnform
124|   Function      :  Form_Hook form_term(const FORM *form)
125|
126|   Description   :  Retrieve form finalization routine address.
127|
128|   Return Values :  The address or NULL if no hook defined.
129+--------------------------------------------------------------------------*/
130GEN_HOOK_GET_FUNCTION(form,term)
131
132/* frm_hook.c ends here */
133