frm_hook.c 6.7 KB

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