1 /* $OpenBSD: frm_hook.c,v 1.6 2001/01/22 18:02:15 millert Exp $ */ 2 3 /**************************************************************************** 4 * Copyright (c) 1998,2000 Free Software Foundation, Inc. * 5 * * 6 * Permission is hereby granted, free of charge, to any person obtaining a * 7 * copy of this software and associated documentation files (the * 8 * "Software"), to deal in the Software without restriction, including * 9 * without limitation the rights to use, copy, modify, merge, publish, * 10 * distribute, distribute with modifications, sublicense, and/or sell * 11 * copies of the Software, and to permit persons to whom the Software is * 12 * furnished to do so, subject to the following conditions: * 13 * * 14 * The above copyright notice and this permission notice shall be included * 15 * in all copies or substantial portions of the Software. * 16 * * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 24 * * 25 * Except as contained in this notice, the name(s) of the above copyright * 26 * holders shall not be used in advertising or otherwise to promote the * 27 * sale, use or other dealings in this Software without prior written * 28 * authorization. * 29 ****************************************************************************/ 30 31 /**************************************************************************** 32 * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 * 33 ****************************************************************************/ 34 35 #include "form.priv.h" 36 37 MODULE_ID("$From: frm_hook.c,v 1.9 2000/12/10 02:09:37 tom Exp $") 38 39 /* "Template" macro to generate function to set application specific hook */ 40 #define GEN_HOOK_SET_FUNCTION( typ, name ) \ 41 NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (FORM *form, Form_Hook func)\ 42 {\ 43 (Normalize_Form( form ) -> typ ## name) = func ;\ 44 RETURN(E_OK);\ 45 } 46 47 /* "Template" macro to generate function to get application specific hook */ 48 #define GEN_HOOK_GET_FUNCTION( typ, name ) \ 49 NCURSES_IMPEXP Form_Hook NCURSES_API typ ## _ ## name ( const FORM *form )\ 50 {\ 51 return ( Normalize_Form( form ) -> typ ## name );\ 52 } 53 54 /*--------------------------------------------------------------------------- 55 | Facility : libnform 56 | Function : int set_field_init(FORM *form, Form_Hook f) 57 | 58 | Description : Assigns an application defined initialization function 59 | to be called when the form is posted and just after 60 | the current field changes. 61 | 62 | Return Values : E_OK - success 63 +--------------------------------------------------------------------------*/ 64 GEN_HOOK_SET_FUNCTION(field,init) 65 66 /*--------------------------------------------------------------------------- 67 | Facility : libnform 68 | Function : Form_Hook field_init(const FORM *form) 69 | 70 | Description : Retrieve field initialization routine address. 71 | 72 | Return Values : The address or NULL if no hook defined. 73 +--------------------------------------------------------------------------*/ 74 GEN_HOOK_GET_FUNCTION(field,init) 75 76 /*--------------------------------------------------------------------------- 77 | Facility : libnform 78 | Function : int set_field_term(FORM *form, Form_Hook f) 79 | 80 | Description : Assigns an application defined finalization function 81 | to be called when the form is unposted and just before 82 | the current field changes. 83 | 84 | Return Values : E_OK - success 85 +--------------------------------------------------------------------------*/ 86 GEN_HOOK_SET_FUNCTION(field,term) 87 88 /*--------------------------------------------------------------------------- 89 | Facility : libnform 90 | Function : Form_Hook field_term(const FORM *form) 91 | 92 | Description : Retrieve field finalization routine address. 93 | 94 | Return Values : The address or NULL if no hook defined. 95 +--------------------------------------------------------------------------*/ 96 GEN_HOOK_GET_FUNCTION(field,term) 97 98 /*--------------------------------------------------------------------------- 99 | Facility : libnform 100 | Function : int set_form_init(FORM *form, Form_Hook f) 101 | 102 | Description : Assigns an application defined initialization function 103 | to be called when the form is posted and just after 104 | a page change. 105 | 106 | Return Values : E_OK - success 107 +--------------------------------------------------------------------------*/ 108 GEN_HOOK_SET_FUNCTION(form,init) 109 110 /*--------------------------------------------------------------------------- 111 | Facility : libnform 112 | Function : Form_Hook form_init(const FORM *form) 113 | 114 | Description : Retrieve form initialization routine address. 115 | 116 | Return Values : The address or NULL if no hook defined. 117 +--------------------------------------------------------------------------*/ 118 GEN_HOOK_GET_FUNCTION(form,init) 119 120 /*--------------------------------------------------------------------------- 121 | Facility : libnform 122 | Function : int set_form_term(FORM *form, Form_Hook f) 123 | 124 | Description : Assigns an application defined finalization function 125 | to be called when the form is unposted and just before 126 | a page change. 127 | 128 | Return Values : E_OK - success 129 +--------------------------------------------------------------------------*/ 130 GEN_HOOK_SET_FUNCTION(form,term) 131 132 /*--------------------------------------------------------------------------- 133 | Facility : libnform 134 | Function : Form_Hook form_term(const FORM *form) 135 | 136 | Description : Retrieve form finalization routine address. 137 | 138 | Return Values : The address or NULL if no hook defined. 139 +--------------------------------------------------------------------------*/ 140 GEN_HOOK_GET_FUNCTION(form,term) 141 142 /* frm_hook.c ends here */ 143