1 /**************************************************************************** 2 * Copyright 2018,2020 Thomas E. Dickey * 3 * Copyright 1998-2012,2016 Free Software Foundation, Inc. * 4 * * 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: * 12 * * 13 * The above copyright notice and this permission notice shall be included * 14 * in all copies or substantial portions of the Software. * 15 * * 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. * 23 * * 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 * 27 * authorization. * 28 ****************************************************************************/ 29 30 /**************************************************************************** 31 * Author: Juergen Pfeifer, 1995,1997 * 32 ****************************************************************************/ 33 34 #include "form.priv.h" 35 36 MODULE_ID("$Id: frm_hook.c,v 1.19 2020/02/02 23:34:34 tom Exp $") 37 38 /* "Template" macro to generate function to set application specific hook */ 39 #define GEN_HOOK_SET_FUNCTION( typ, name ) \ 40 NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (FORM *form, Form_Hook func)\ 41 {\ 42 TR_FUNC_BFR(1); \ 43 T((T_CALLED("set_" #typ"_"#name"(%p,%s)"), (void *) form, TR_FUNC_ARG(0, func)));\ 44 (Normalize_Form( form ) -> typ ## name) = func ;\ 45 RETURN(E_OK);\ 46 } 47 48 /* "Template" macro to generate function to get application specific hook */ 49 #define GEN_HOOK_GET_FUNCTION( typ, name ) \ 50 NCURSES_IMPEXP Form_Hook NCURSES_API typ ## _ ## name ( const FORM *form )\ 51 {\ 52 T((T_CALLED(#typ "_" #name "(%p)"), (const void *) form));\ 53 returnFormHook( Normalize_Form( form ) -> typ ## name );\ 54 } 55 56 /*--------------------------------------------------------------------------- 57 | Facility : libnform 58 | Function : int set_field_init(FORM *form, Form_Hook f) 59 | 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. 63 | 64 | Return Values : E_OK - success 65 +--------------------------------------------------------------------------*/ 66 GEN_HOOK_SET_FUNCTION(field, init) 67 68 /*--------------------------------------------------------------------------- 69 | Facility : libnform 70 | Function : Form_Hook field_init(const FORM *form) 71 | 72 | Description : Retrieve field initialization routine address. 73 | 74 | Return Values : The address or NULL if no hook defined. 75 +--------------------------------------------------------------------------*/ 76 GEN_HOOK_GET_FUNCTION(field, init) 77 78 /*--------------------------------------------------------------------------- 79 | Facility : libnform 80 | Function : int set_field_term(FORM *form, Form_Hook f) 81 | 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. 85 | 86 | Return Values : E_OK - success 87 +--------------------------------------------------------------------------*/ 88 GEN_HOOK_SET_FUNCTION(field, term) 89 90 /*--------------------------------------------------------------------------- 91 | Facility : libnform 92 | Function : Form_Hook field_term(const FORM *form) 93 | 94 | Description : Retrieve field finalization routine address. 95 | 96 | Return Values : The address or NULL if no hook defined. 97 +--------------------------------------------------------------------------*/ 98 GEN_HOOK_GET_FUNCTION(field, term) 99 100 /*--------------------------------------------------------------------------- 101 | Facility : libnform 102 | Function : int set_form_init(FORM *form, Form_Hook f) 103 | 104 | Description : Assigns an application defined initialization function 105 | to be called when the form is posted and just after 106 | a page change. 107 | 108 | Return Values : E_OK - success 109 +--------------------------------------------------------------------------*/ 110 GEN_HOOK_SET_FUNCTION(form, init) 111 112 /*--------------------------------------------------------------------------- 113 | Facility : libnform 114 | Function : Form_Hook form_init(const FORM *form) 115 | 116 | Description : Retrieve form initialization routine address. 117 | 118 | Return Values : The address or NULL if no hook defined. 119 +--------------------------------------------------------------------------*/ 120 GEN_HOOK_GET_FUNCTION(form, init) 121 122 /*--------------------------------------------------------------------------- 123 | Facility : libnform 124 | Function : int set_form_term(FORM *form, Form_Hook f) 125 | 126 | Description : Assigns an application defined finalization function 127 | to be called when the form is unposted and just before 128 | a page change. 129 | 130 | Return Values : E_OK - success 131 +--------------------------------------------------------------------------*/ 132 GEN_HOOK_SET_FUNCTION(form, term) 133 134 /*--------------------------------------------------------------------------- 135 | Facility : libnform 136 | Function : Form_Hook form_term(const FORM *form) 137 | 138 | Description : Retrieve form finalization routine address. 139 | 140 | Return Values : The address or NULL if no hook defined. 141 +--------------------------------------------------------------------------*/ 142 GEN_HOOK_GET_FUNCTION(form, term) 143 144 /* frm_hook.c ends here */ 145