frm_opts.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /****************************************************************************
  2. * Copyright (c) 1998-2004,2005 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_opts.c,v 1.14 2005/04/16 16:59:18 tom Exp $")
  33. /*---------------------------------------------------------------------------
  34. | Facility : libnform
  35. | Function : int set_form_opts(FORM *form, Form_Options opts)
  36. |
  37. | Description : Turns on the named options and turns off all the
  38. | remaining options for that form.
  39. |
  40. | Return Values : E_OK - success
  41. | E_BAD_ARGUMENT - invalid options
  42. +--------------------------------------------------------------------------*/
  43. NCURSES_EXPORT(int)
  44. set_form_opts(FORM *form, Form_Options opts)
  45. {
  46. T((T_CALLED("set_form_opts(%p,%d)"), form, opts));
  47. opts &= ALL_FORM_OPTS;
  48. if (opts & ~ALL_FORM_OPTS)
  49. RETURN(E_BAD_ARGUMENT);
  50. else
  51. {
  52. Normalize_Form(form)->opts = opts;
  53. RETURN(E_OK);
  54. }
  55. }
  56. /*---------------------------------------------------------------------------
  57. | Facility : libnform
  58. | Function : Form_Options form_opts(const FORM *)
  59. |
  60. | Description : Retrieves the current form options.
  61. |
  62. | Return Values : The option flags.
  63. +--------------------------------------------------------------------------*/
  64. NCURSES_EXPORT(Form_Options)
  65. form_opts(const FORM *form)
  66. {
  67. T((T_CALLED("form_opts(%p)"), form));
  68. returnCode((int)(Normalize_Form(form)->opts & ALL_FORM_OPTS));
  69. }
  70. /*---------------------------------------------------------------------------
  71. | Facility : libnform
  72. | Function : int form_opts_on(FORM *form, Form_Options opts)
  73. |
  74. | Description : Turns on the named options; no other options are
  75. | changed.
  76. |
  77. | Return Values : E_OK - success
  78. | E_BAD_ARGUMENT - invalid options
  79. +--------------------------------------------------------------------------*/
  80. NCURSES_EXPORT(int)
  81. form_opts_on(FORM *form, Form_Options opts)
  82. {
  83. T((T_CALLED("form_opts_on(%p,%d)"), form, opts));
  84. opts &= ALL_FORM_OPTS;
  85. if (opts & ~ALL_FORM_OPTS)
  86. RETURN(E_BAD_ARGUMENT);
  87. else
  88. {
  89. Normalize_Form(form)->opts |= opts;
  90. RETURN(E_OK);
  91. }
  92. }
  93. /*---------------------------------------------------------------------------
  94. | Facility : libnform
  95. | Function : int form_opts_off(FORM *form, Form_Options opts)
  96. |
  97. | Description : Turns off the named options; no other options are
  98. | changed.
  99. |
  100. | Return Values : E_OK - success
  101. | E_BAD_ARGUMENT - invalid options
  102. +--------------------------------------------------------------------------*/
  103. NCURSES_EXPORT(int)
  104. form_opts_off(FORM *form, Form_Options opts)
  105. {
  106. T((T_CALLED("form_opts_off(%p,%d)"), form, opts));
  107. opts &= ALL_FORM_OPTS;
  108. if (opts & ~ALL_FORM_OPTS)
  109. RETURN(E_BAD_ARGUMENT);
  110. else
  111. {
  112. Normalize_Form(form)->opts &= ~opts;
  113. RETURN(E_OK);
  114. }
  115. }
  116. /* frm_opts.c ends here */